node_ids
sequencelengths 4
1.4k
| edge_index
sequencelengths 1
2.22k
| text
sequencelengths 4
1.4k
| source
stringlengths 14
427k
|
---|---|---|---|
[
7,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
2,
4,
13,
13,
17,
0,
13,
13,
41,
28,
13,
13,
4,
13,
13,
2,
2,
13,
18,
13,
13,
2,
13,
13,
4,
17,
4,
13,
4,
13,
13,
10,
4,
13,
10,
13,
13
] | [
[
48,
2
],
[
10,
9
],
[
9,
19
],
[
51,
22
],
[
52,
30
],
[
52,
35
],
[
48,
49
],
[
51,
52
]
] | [
"N = int(input())\nA = [int(i) - 1 for i in input().split()]\nprint(len([1 for i, a in enumerate(A) if i == A[a] and i < a]))",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"int(i) - 1 for i in input().split()",
"for i in input().split()",
"i",
"input().split()",
"().split",
"()",
"input",
"split",
"for i in input().split()",
"int(i) - 1",
"int(i)",
"int",
"i",
"1",
"A = [int(i) - 1 for i in input().split()]",
"A",
"[int(i) - 1 for i in input().split()]",
"1 for i, a in enumerate(A) if i == A[a] and i < a",
"for i, a in enumerate(A) if i == A[a] and i < a",
"i",
"a",
"enumerate(A)",
"enumerate",
"A",
"i == A[a] and i < a",
"i == A[a]",
"i",
"A[a]",
"A",
"a",
"i < a",
"i",
"a",
"if i == A[a] and i < a",
"1",
"print(len([1 for i, a in enumerate(A) if i == A[a] and i < a]))",
"print",
"len([1 for i, a in enumerate(A) if i == A[a] and i < a])",
"len",
"[1 for i, a in enumerate(A) if i == A[a] and i < a]",
"N = int(input())",
"int(input())",
"N",
"A = [int(i) - 1 for i in input().split()]",
"[int(i) - 1 for i in input().split()]",
"A"
] | N = int(input())
A = [int(i) - 1 for i in input().split()]
print(len([1 for i, a in enumerate(A) if i == A[a] and i < a])) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
0,
13,
18,
13,
2,
13,
17,
0,
13,
18,
13,
2,
13,
17,
14,
2,
13,
13,
0,
13,
17,
4,
13,
2,
13,
17,
10,
18,
13,
10,
18,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13
] | [
[
72,
2
],
[
66,
8
],
[
69,
20
],
[
24,
23
],
[
73,
28
],
[
60,
31
],
[
67,
33
],
[
23,
35
],
[
57,
38
],
[
67,
40
],
[
61,
42
],
[
23,
46
],
[
58,
47
],
[
63,
49
],
[
64,
54
],
[
70,
54
],
[
57,
58
],
[
60,
61
],
[
63,
64
],
[
66,
67
],
[
69,
70
],
[
72,
73
]
] | [
"n = int(input())\na = list(map(int, input().split()))\n\nans = 0\nfor i in range(1, (n + 1)):\n like1 = a[i - 1]\n like2 = a[like1 - 1]\n if i == like2:\n ans += 1\nprint(ans // 2)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a = list(map(int, input().split()))",
"a",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"ans = 0",
"ans",
"0",
"for i in range(1, (n + 1)):\n like1 = a[i - 1]\n like2 = a[like1 - 1]\n if i == like2:\n ans += 1",
"i",
"range(1, (n + 1))",
"range",
"1",
"n + 1",
"n",
"1",
"like1 = a[i - 1]",
"like1",
"a[i - 1]",
"a",
"i - 1",
"i",
"1",
"like2 = a[like1 - 1]",
"like2",
"a[like1 - 1]",
"a",
"like1 - 1",
"like1",
"1",
"if i == like2:\n ans += 1",
"i == like2",
"i",
"like2",
"ans += 1",
"ans",
"1",
"print(ans // 2)",
"print",
"ans // 2",
"ans",
"2",
"like2 = a[like1 - 1]",
"a[like1 - 1]",
"like2",
"like1 = a[i - 1]",
"a[i - 1]",
"like1",
"ans += 1",
"1",
"ans",
"a = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a",
"ans = 0",
"0",
"ans",
"n = int(input())",
"int(input())",
"n"
] | n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(1, (n + 1)):
like1 = a[i - 1]
like2 = a[like1 - 1]
if i == like2:
ans += 1
print(ans // 2)
|
[
7,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
2,
4,
13,
13,
17,
0,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
18,
13,
18,
13,
13,
13,
4,
13,
2,
13,
17,
10,
4,
13,
10,
17,
13,
10,
13,
13
] | [
[
46,
2
],
[
10,
9
],
[
9,
19
],
[
52,
22
],
[
49,
25
],
[
29,
28
],
[
47,
31
],
[
53,
35
],
[
53,
37
],
[
28,
38
],
[
28,
39
],
[
50,
43
],
[
46,
47
],
[
49,
50
],
[
52,
53
]
] | [
"N = int(input())\nA = [int(a) - 1 for a in input().split()]\nans = 0\nfor i in range(N):\n if A[A[i]] == i: ans += 1\nprint(ans // 2)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"int(a) - 1 for a in input().split()",
"for a in input().split()",
"a",
"input().split()",
"().split",
"()",
"input",
"split",
"for a in input().split()",
"int(a) - 1",
"int(a)",
"int",
"a",
"1",
"A = [int(a) - 1 for a in input().split()]",
"A",
"[int(a) - 1 for a in input().split()]",
"ans = 0",
"ans",
"0",
"for i in range(N):\n if A[A[i]] == i: ans += 1",
"i",
"range(N)",
"range",
"N",
"if A[A[i]] == i: ans ",
"A[A[i]] == i",
"A[A[i]]",
"A",
"A[i]",
"A",
"i",
"i",
"print(ans // 2)",
"print",
"ans // 2",
"ans",
"2",
"N = int(input())",
"int(input())",
"N",
"ans = 0",
"0",
"ans",
"A = [int(a) - 1 for a in input().split()]",
"[int(a) - 1 for a in input().split()]",
"A"
] | N = int(input())
A = [int(a) - 1 for a in input().split()]
ans = 0
for i in range(N):
if A[A[i]] == i: ans += 1
print(ans // 2) |
[
7,
15,
12,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
18,
13,
2,
18,
13,
13,
17,
2,
13,
17,
0,
13,
17,
4,
13,
2,
13,
17,
14,
2,
13,
17,
4,
13,
17,
4,
13,
10,
12,
13
] | [
[
6,
5
],
[
13,
12
],
[
5,
16
],
[
19,
18
],
[
5,
27
],
[
31,
30
],
[
34,
33
],
[
12,
36
],
[
18,
40
],
[
18,
43
],
[
33,
44
],
[
33,
47
],
[
51,
50
],
[
50,
55
],
[
30,
55
],
[
68,
65
]
] | [
"#!/usr/bin/env python3\n\nfrom sys import stdin, setrecursionlimit\n\n\ndef main():\n input = stdin.buffer.readline\n n = int(input())\n a = list(map(int, input().split()))\n ans = 0\n for i in range(n):\n if a[a[i] - 1] == i + 1:\n ans += 1\n print(ans // 2)\n\n\nif __name__ == \"__main__\":\n setrecursionlimit(10000)\n main()",
"from sys import stdin, setrecursionlimit",
"def main():\n input = stdin.buffer.readline\n n = int(input())\n a = list(map(int, input().split()))\n ans = 0\n for i in range(n):\n if a[a[i] - 1] == i + 1:\n ans += 1\n print(ans // 2)",
"main",
"input = stdin.buffer.readline",
"input",
"stdin.buffer.readline",
"stdin.buffer",
"stdin",
"buffer",
"readline",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a = list(map(int, input().split()))",
"a",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"ans = 0",
"ans",
"0",
"for i in range(n):\n if a[a[i] - 1] == i + 1:\n ans += 1\n ",
"i",
"range(n)",
"range",
"n",
"if a[a[i] - 1] == i + 1:\n ans += 1\n ",
"a[a[i] - 1] == i + 1",
"a[a[i] - 1]",
"a",
"a[i] - 1",
"a[i]",
"a",
"i",
"1",
"i + 1",
"i",
"1",
"ans += 1",
"ans",
"1",
"print(ans // 2)",
"print",
"ans // 2",
"ans",
"2",
"if __name__ == \"__main__\":\n setrecursionlimit(10000)\n main()",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"setrecursionlimit(10000)",
"setrecursionlimit",
"10000",
"main()",
"main",
"def main():\n input = stdin.buffer.readline\n n = int(input())\n a = list(map(int, input().split()))\n ans = 0\n for i in range(n):\n if a[a[i] - 1] == i + 1:\n ans += 1\n print(ans // 2)",
"def main():\n input = stdin.buffer.readline\n n = int(input())\n a = list(map(int, input().split()))\n ans = 0\n for i in range(n):\n if a[a[i] - 1] == i + 1:\n ans += 1\n print(ans // 2)",
"main"
] | #!/usr/bin/env python3
from sys import stdin, setrecursionlimit
def main():
input = stdin.buffer.readline
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
if a[a[i] - 1] == i + 1:
ans += 1
print(ans // 2)
if __name__ == "__main__":
setrecursionlimit(10000)
main()
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
18,
13,
13,
14,
2,
18,
13,
2,
13,
17,
2,
13,
17,
0,
13,
17,
4,
13,
2,
13,
17,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
18,
13
] | [
[
57,
2
],
[
54,
8
],
[
60,
20
],
[
24,
23
],
[
58,
26
],
[
63,
28
],
[
55,
30
],
[
23,
31
],
[
55,
35
],
[
64,
37
],
[
23,
40
],
[
51,
43
],
[
52,
48
],
[
61,
48
],
[
51,
52
],
[
54,
55
],
[
57,
58
],
[
60,
61
],
[
63,
64
]
] | [
"n = int(input())\nal = list(map(int, input().split()))\ncnt = 0\nfor i in range(n):\n tmp = al[i]\n if al[tmp-1] == i+1:\n cnt += 1\n else:\n pass\nprint(cnt//2)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"al = list(map(int, input().split()))",
"al",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"cnt = 0",
"cnt",
"0",
"for i in range(n):\n tmp = al[i]\n if al[tmp-1] == i+1:\n cnt += 1\n else:\n pass",
"i",
"range(n)",
"range",
"n",
"tmp = al[i]",
"tmp",
"al[i]",
"al",
"i",
"if al[tmp-1] == i+1:\n cnt += 1\n else:\n pass",
"al[tmp-1] == i+1",
"al[tmp-1]",
"al",
"tmp-1",
"tmp",
"1",
"i+1",
"i",
"1",
"cnt += 1",
"cnt",
"1",
"print(cnt//2)",
"print",
"cnt//2",
"cnt",
"2",
"cnt += 1",
"1",
"cnt",
"al = list(map(int, input().split()))",
"list(map(int, input().split()))",
"al",
"n = int(input())",
"int(input())",
"n",
"cnt = 0",
"0",
"cnt",
"tmp = al[i]",
"al[i]",
"tmp"
] | n = int(input())
al = list(map(int, input().split()))
cnt = 0
for i in range(n):
tmp = al[i]
if al[tmp-1] == i+1:
cnt += 1
else:
pass
print(cnt//2) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
13,
4,
13,
13,
14,
2,
18,
13,
2,
13,
17,
2,
13,
17,
0,
13,
17,
4,
13,
2,
13,
17,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13
] | [
[
47,
2
],
[
53,
8
],
[
56,
20
],
[
54,
27
],
[
54,
31
],
[
50,
39
],
[
51,
44
],
[
57,
44
],
[
47,
48
],
[
50,
51
],
[
53,
54
],
[
56,
57
]
] | [
"N = int(input())\nan = list(map(int, input().split()))\nans = 0\nfor i, a in enumerate(an):\n if an[a-1] == i+1:\n ans += 1\nprint(ans//2)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"an = list(map(int, input().split()))",
"an",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"ans = 0",
"ans",
"0",
"for i, a in enumerate(an):\n if an[a-1] == i+1:\n ans += 1",
"i",
"a",
"enumerate(an)",
"enumerate",
"an",
"if an[a-1] == i+1:\n ans += 1",
"an[a-1] == i+1",
"an[a-1]",
"an",
"a-1",
"a",
"1",
"i+1",
"i",
"1",
"ans += 1",
"ans",
"1",
"print(ans//2)",
"print",
"ans//2",
"ans",
"2",
"N = int(input())",
"int(input())",
"N",
"ans += 1",
"1",
"ans",
"an = list(map(int, input().split()))",
"list(map(int, input().split()))",
"an",
"ans = 0",
"0",
"ans"
] | N = int(input())
an = list(map(int, input().split()))
ans = 0
for i, a in enumerate(an):
if an[a-1] == i+1:
ans += 1
print(ans//2) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
18,
13,
2,
13,
17,
18,
13,
13,
28,
13,
13,
4,
18,
13,
13,
14,
2,
18,
13,
13,
13,
0,
13,
17,
4,
13,
2,
13,
17,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13
] | [
[
61,
2
],
[
67,
8
],
[
64,
20
],
[
73,
23
],
[
27,
26
],
[
62,
29
],
[
36,
31
],
[
65,
32
],
[
26,
34
],
[
68,
37
],
[
26,
38
],
[
65,
44
],
[
65,
49
],
[
70,
53
],
[
71,
58
],
[
74,
58
],
[
61,
62
],
[
64,
65
],
[
67,
68
],
[
70,
71
],
[
73,
74
]
] | [
"N = int(input())\na = list(map(int, input().split()))\npair = {}\nans = 0\nfor i in range(N):\n pair[i + 1] = a[i]\n\nfor key, value in pair.items():\n if pair[value] == key:\n ans += 1\n\nprint(ans // 2)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"a = list(map(int, input().split()))",
"a",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"pair = {}",
"pair",
"{}",
"ans = 0",
"ans",
"0",
"for i in range(N):\n pair[i + 1] = a[i]",
"i",
"range(N)",
"range",
"N",
"pair[i + 1] = a[i]",
"pair[i + 1]",
"pair",
"i + 1",
"i",
"1",
"a[i]",
"a",
"i",
"for key, value in pair.items():\n if pair[value] == key:\n ans += 1",
"key",
"value",
"pair.items()",
"pair.items",
"pair",
"items",
"if pair[value] == key:\n ans += 1",
"pair[value] == key",
"pair[value]",
"pair",
"value",
"key",
"ans += 1",
"ans",
"1",
"print(ans // 2)",
"print",
"ans // 2",
"ans",
"2",
"N = int(input())",
"int(input())",
"N",
"pair = {}",
"{}",
"pair",
"a = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a",
"ans += 1",
"1",
"ans",
"ans = 0",
"0",
"ans"
] | N = int(input())
a = list(map(int, input().split()))
pair = {}
ans = 0
for i in range(N):
pair[i + 1] = a[i]
for key, value in pair.items():
if pair[value] == key:
ans += 1
print(ans // 2)
|
[
7,
12,
13,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
2,
13,
17,
18,
13,
2,
18,
13,
13,
17,
0,
13,
17,
4,
13,
2,
13,
17,
14,
2,
13,
17,
4,
13,
10,
12,
13
] | [
[
5,
4
],
[
12,
11
],
[
11,
20
],
[
23,
22
],
[
26,
25
],
[
29,
28
],
[
4,
31
],
[
28,
35
],
[
22,
38
],
[
22,
41
],
[
28,
42
],
[
46,
45
],
[
45,
50
],
[
25,
50
],
[
60,
57
]
] | [
"def solve():\n N = int(input())\n A = [int(i) for i in input().split()]\n ans = 0\n for i in range(N):\n if i + 1 == A[A[i] - 1]:\n ans += 1\n print(ans // 2)\n\nif __name__ == \"__main__\":\n solve()",
"def solve():\n N = int(input())\n A = [int(i) for i in input().split()]\n ans = 0\n for i in range(N):\n if i + 1 == A[A[i] - 1]:\n ans += 1\n print(ans // 2)",
"solve",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"int(i) for i in input().split()",
"for i in input().split()",
"i",
"input().split()",
"().split",
"()",
"input",
"split",
"for i in input().split()",
"int(i)",
"int",
"i",
"A = [int(i) for i in input().split()]",
"A",
"[int(i) for i in input().split()]",
"ans = 0",
"ans",
"0",
"for i in range(N):\n if i + 1 == A[A[i] - 1]:\n ans += 1\n ",
"i",
"range(N)",
"range",
"N",
"if i + 1 == A[A[i] - 1]:\n ans += 1\n ",
"i + 1 == A[A[i] - 1]",
"i + 1",
"i",
"1",
"A[A[i] - 1]",
"A",
"A[i] - 1",
"A[i]",
"A",
"i",
"1",
"ans += 1",
"ans",
"1",
"print(ans // 2)",
"print",
"ans // 2",
"ans",
"2",
"if __name__ == \"__main__\":\n solve()",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"solve()",
"solve",
"def solve():\n N = int(input())\n A = [int(i) for i in input().split()]\n ans = 0\n for i in range(N):\n if i + 1 == A[A[i] - 1]:\n ans += 1\n print(ans // 2)",
"def solve():\n N = int(input())\n A = [int(i) for i in input().split()]\n ans = 0\n for i in range(N):\n if i + 1 == A[A[i] - 1]:\n ans += 1\n print(ans // 2)",
"solve"
] | def solve():
N = int(input())
A = [int(i) for i in input().split()]
ans = 0
for i in range(N):
if i + 1 == A[A[i] - 1]:
ans += 1
print(ans // 2)
if __name__ == "__main__":
solve()
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
13,
4,
2,
2,
2,
18,
13,
13,
17,
13,
2,
2,
18,
13,
2,
18,
13,
13,
17,
17,
13,
4,
13,
4,
18,
13,
13,
17,
10,
4,
13,
10,
4,
13
] | [
[
53,
2
],
[
56,
8
],
[
22,
21
],
[
54,
24
],
[
57,
30
],
[
21,
31
],
[
21,
33
],
[
57,
37
],
[
57,
40
],
[
21,
41
],
[
21,
44
],
[
53,
54
],
[
56,
57
]
] | [
"N = int(input())\nA = list(map(int, input().split()))\n\nprint([A[i] - 1 > i and A[A[i] - 1] - 1 == i for i in range(N)].count(1))",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"A = list(map(int, input().split()))",
"A",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"A[i] - 1 > i and A[A[i] - 1] - 1 == i for i in range(N)",
"for i in range(N)",
"i",
"range(N)",
"range",
"N",
"for i in range(N)",
"A[i] - 1 > i and A[A[i] - 1] - 1 == i",
"A[i] - 1 > i",
"A[i] - 1",
"A[i]",
"A",
"i",
"1",
"i",
"A[A[i] - 1] - 1 == i",
"A[A[i] - 1] - 1",
"A[A[i] - 1]",
"A",
"A[i] - 1",
"A[i]",
"A",
"i",
"1",
"1",
"i",
"print([A[i] - 1 > i and A[A[i] - 1] - 1 == i for i in range(N)].count(1))",
"print",
"[A[i] - 1 > i and A[A[i] - 1] - 1 == i for i in range(N)].count(1)",
"[A[i] - 1 > i and A[A[i] - 1] - 1 == i for i in range(N)].count",
"[A[i] - 1 > i and A[A[i] - 1] - 1 == i for i in range(N)]",
"count",
"1",
"N = int(input())",
"int(input())",
"N",
"A = list(map(int, input().split()))",
"list(map(int, input().split()))",
"A"
] | N = int(input())
A = list(map(int, input().split()))
print([A[i] - 1 > i and A[A[i] - 1] - 1 == i for i in range(N)].count(1)) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
13,
4,
13,
13,
17,
14,
2,
18,
13,
2,
13,
17,
13,
0,
13,
17,
4,
13,
2,
13,
17,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13
] | [
[
49,
2
],
[
46,
8
],
[
55,
20
],
[
47,
27
],
[
47,
32
],
[
52,
38
],
[
53,
43
],
[
56,
43
],
[
46,
47
],
[
49,
50
],
[
52,
53
],
[
55,
56
]
] | [
"n = int(input())\na = list(map(int, input().split()))\ncnt = 0\nfor i, tgt in enumerate(a, 1):\n if a[tgt - 1] == i:\n cnt += 1\nprint(cnt // 2)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a = list(map(int, input().split()))",
"a",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"cnt = 0",
"cnt",
"0",
"for i, tgt in enumerate(a, 1):\n if a[tgt - 1] == i:\n cnt += 1",
"i",
"tgt",
"enumerate(a, 1)",
"enumerate",
"a",
"1",
"if a[tgt - 1] == i:\n cnt += 1",
"a[tgt - 1] == i",
"a[tgt - 1]",
"a",
"tgt - 1",
"tgt",
"1",
"i",
"cnt += 1",
"cnt",
"1",
"print(cnt // 2)",
"print",
"cnt // 2",
"cnt",
"2",
"a = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a",
"n = int(input())",
"int(input())",
"n",
"cnt += 1",
"1",
"cnt",
"cnt = 0",
"0",
"cnt"
] | n = int(input())
a = list(map(int, input().split()))
cnt = 0
for i, tgt in enumerate(a, 1):
if a[tgt - 1] == i:
cnt += 1
print(cnt // 2) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
13,
4,
13,
13,
4,
2,
18,
13,
2,
13,
17,
2,
13,
17,
4,
13,
2,
4,
13,
13,
17,
10,
4,
13,
10,
4,
13
] | [
[
44,
2
],
[
47,
8
],
[
48,
25
],
[
48,
29
],
[
44,
45
],
[
47,
48
]
] | [
"N = int(input())\na = list(map(int, input().split()))\nprint(sum([a[x-1]==i+1 for i,x in enumerate(a)])//2)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"a = list(map(int, input().split()))",
"a",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a[x-1]==i+1 for i,x in enumerate(a)",
"for i,x in enumerate(a)",
"i",
"x",
"enumerate(a)",
"enumerate",
"a",
"for i,x in enumerate(a)",
"a[x-1]==i+1",
"a[x-1]",
"a",
"x-1",
"x",
"1",
"i+1",
"i",
"1",
"print(sum([a[x-1]==i+1 for i,x in enumerate(a)])//2)",
"print",
"sum([a[x-1]==i+1 for i,x in enumerate(a)])//2",
"sum([a[x-1]==i+1 for i,x in enumerate(a)])",
"sum",
"[a[x-1]==i+1 for i,x in enumerate(a)]",
"2",
"N = int(input())",
"int(input())",
"N",
"a = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a"
] | N = int(input())
a = list(map(int, input().split()))
print(sum([a[x-1]==i+1 for i,x in enumerate(a)])//2) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
17,
2,
13,
17,
4,
13,
0,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
18,
13,
13,
18,
13,
2,
18,
13,
13,
17,
0,
13,
17,
0,
18,
13,
13,
17,
4,
13,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
13,
13
] | [
[
65,
2
],
[
74,
8
],
[
22,
21
],
[
66,
26
],
[
21,
29
],
[
77,
31
],
[
68,
34
],
[
38,
37
],
[
66,
40
],
[
78,
44
],
[
37,
45
],
[
75,
47
],
[
57,
49
],
[
75,
50
],
[
37,
51
],
[
71,
54
],
[
60,
57
],
[
75,
58
],
[
37,
59
],
[
72,
63
],
[
69,
63
],
[
65,
66
],
[
68,
69
],
[
71,
72
],
[
74,
75
],
[
77,
78
]
] | [
"n = int(input())\nA = list(map(int,input().split()))\nB = [i for i in range(1,n+1)]\ncnt = 0\nfor i in range(n):\n if B[i]==A[(A[i]-1)]:\n cnt+=1\n A[i]=0\nprint(cnt) ",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"A = list(map(int,input().split()))",
"A",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"i for i in range(1,n+1)",
"for i in range(1,n+1)",
"i",
"range(1,n+1)",
"range",
"1",
"n+1",
"n",
"1",
"for i in range(1,n+1)",
"i",
"B = [i for i in range(1,n+1)]",
"B",
"[i for i in range(1,n+1)]",
"cnt = 0",
"cnt",
"0",
"for i in range(n):\n if B[i]==A[(A[i]-1)]:\n cnt+=1\n A[i]=0",
"i",
"range(n)",
"range",
"n",
"if B[i]==A[(A[i]-1)]:\n cnt+=1\n A[i]=0",
"B[i]==A[(A[i]-1)]",
"B[i]",
"B",
"i",
"A[(A[i]-1)]",
"A",
"A[i]-1",
"A[i]",
"A",
"i",
"1",
"cnt+=1",
"cnt",
"1",
"A[i]=0",
"A[i]",
"A",
"i",
"0",
"print(cnt)",
"print",
"cnt",
"n = int(input())",
"int(input())",
"n",
"cnt = 0",
"0",
"cnt",
"cnt+=1",
"1",
"cnt",
"A = list(map(int,input().split()))",
"list(map(int,input().split()))",
"A",
"B = [i for i in range(1,n+1)]",
"[i for i in range(1,n+1)]",
"B"
] | n = int(input())
A = list(map(int,input().split()))
B = [i for i in range(1,n+1)]
cnt = 0
for i in range(n):
if B[i]==A[(A[i]-1)]:
cnt+=1
A[i]=0
print(cnt) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
17,
2,
13,
17,
4,
13,
0,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
4,
18,
13,
13,
39,
18,
13,
13,
18,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
2,
18,
18,
13,
13,
17,
18,
18,
13,
2,
18,
18,
13,
13,
17,
17,
17,
2,
18,
18,
13,
13,
17,
18,
18,
13,
2,
18,
18,
13,
13,
17,
17,
17,
0,
13,
17,
4,
13,
2,
13,
17,
10,
13,
13,
10,
17,
13,
10,
4,
13,
10,
39,
13,
10,
17,
13,
10,
4,
13
] | [
[
120,
2
],
[
111,
8
],
[
22,
21
],
[
121,
26
],
[
21,
29
],
[
105,
31
],
[
114,
34
],
[
38,
37
],
[
121,
40
],
[
115,
43
],
[
112,
47
],
[
37,
48
],
[
106,
50
],
[
37,
51
],
[
108,
53
],
[
57,
56
],
[
121,
59
],
[
115,
65
],
[
56,
66
],
[
115,
70
],
[
115,
74
],
[
56,
75
],
[
115,
82
],
[
56,
83
],
[
115,
87
],
[
115,
91
],
[
56,
92
],
[
117,
97
],
[
118,
102
],
[
109,
102
],
[
105,
106
],
[
108,
109
],
[
111,
112
],
[
114,
115
],
[
117,
118
],
[
120,
121
]
] | [
"N=int(input())\na=list(map(int,input().split()))\nI=[i for i in range (1,N+1)]\nb=[]\nfor i in range(N):\n b.append([a[i],I[i]])\ncount=0\nfor i in range(N):\n if b[i][0]==b[b[i][0]-1][1] and b[i][1]==b[b[i][0]-1][0]:\n count+=1\nprint(count//2)",
"N=int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"a=list(map(int,input().split()))",
"a",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"i for i in range (1,N+1)",
"for i in range (1,N+1)",
"i",
"range (1,N+1)",
"range",
"1",
"N+1",
"N",
"1",
"for i in range (1,N+1)",
"i",
"I=[i for i in range (1,N+1)]",
"I",
"[i for i in range (1,N+1)]",
"b=[]",
"b",
"[]",
"for i in range(N):\n b.append([a[i],I[i]])",
"i",
"range(N)",
"range",
"N",
"b.append([a[i],I[i]])",
"b.append",
"b",
"append",
"[a[i],I[i]]",
"a[i]",
"a",
"i",
"I[i]",
"I",
"i",
"count=0",
"count",
"0",
"for i in range(N):\n if b[i][0]==b[b[i][0]-1][1] and b[i][1]==b[b[i][0]-1][0]:\n count+=1",
"i",
"range(N)",
"range",
"N",
"if b[i][0]==b[b[i][0]-1][1] and b[i][1]==b[b[i][0]-1][0]:\n count+=1",
"b[i][0]==b[b[i][0]-1][1] and b[i][1]==b[b[i][0]-1][0]",
"b[i][0]==b[b[i][0]-1][1]",
"b[i][0]",
"[i]",
"b",
"i",
"0",
"b[b[i][0]-1][1]",
"[b[i][0]-1]",
"b",
"b[i][0]-1",
"b[i][0]",
"[i]",
"b",
"i",
"0",
"1",
"1",
"b[i][1]==b[b[i][0]-1][0]",
"b[i][1]",
"[i]",
"b",
"i",
"1",
"b[b[i][0]-1][0]",
"[b[i][0]-1]",
"b",
"b[i][0]-1",
"b[i][0]",
"[i]",
"b",
"i",
"0",
"1",
"0",
"count+=1",
"count",
"1",
"print(count//2)",
"print",
"count//2",
"count",
"2",
"I=[i for i in range (1,N+1)]",
"[i for i in range (1,N+1)]",
"I",
"count=0",
"0",
"count",
"a=list(map(int,input().split()))",
"list(map(int,input().split()))",
"a",
"b=[]",
"[]",
"b",
"count+=1",
"1",
"count",
"N=int(input())",
"int(input())",
"N"
] | N=int(input())
a=list(map(int,input().split()))
I=[i for i in range (1,N+1)]
b=[]
for i in range(N):
b.append([a[i],I[i]])
count=0
for i in range(N):
if b[i][0]==b[b[i][0]-1][1] and b[i][1]==b[b[i][0]-1][0]:
count+=1
print(count//2) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
2,
18,
13,
13,
13,
2,
18,
13,
18,
13,
13,
2,
13,
17,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13
] | [
[
50,
2
],
[
53,
8
],
[
56,
20
],
[
59,
23
],
[
27,
26
],
[
51,
29
],
[
54,
34
],
[
26,
35
],
[
57,
36
],
[
57,
39
],
[
54,
41
],
[
26,
42
],
[
26,
44
],
[
60,
48
],
[
50,
51
],
[
53,
54
],
[
56,
57
],
[
59,
60
]
] | [
"n = int(input())\na = list(map(int, input().split()))\n\nd = {}\nans = 0\nfor i in range(n):\n if a[i] in d and d[a[i]] == i+1: ans += 1\n else: d[i+1] = a[i]\nprint(ans)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a = list(map(int, input().split()))",
"a",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"d = {}",
"d",
"{}",
"ans = 0",
"ans",
"0",
"for i in range(n):\n if a[i] in d and d[a[i]] == i+1: ans += 1\n else: d[i+1] = a[i]",
"i",
"range(n)",
"range",
"n",
"if a[i] in d and d[a[i]] == i+1: ans += 1\n else: d[i+1] = a[i]",
"a[i] in d and d[a[i]] == i+1",
"a[i] in d",
"a[i]",
"a",
"i",
"d",
"d[a[i]] == i+1",
"d[a[i]]",
"d",
"a[i]",
"a",
"i",
"i+1",
"i",
"1",
"print(ans)",
"print",
"ans",
"n = int(input())",
"int(input())",
"n",
"a = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a",
"d = {}",
"{}",
"d",
"ans = 0",
"0",
"ans"
] | n = int(input())
a = list(map(int, input().split()))
d = {}
ans = 0
for i in range(n):
if a[i] in d and d[a[i]] == i+1: ans += 1
else: d[i+1] = a[i]
print(ans) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
18,
13,
2,
18,
13,
13,
17,
2,
13,
17,
0,
13,
17,
4,
13,
4,
13,
2,
13,
17,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13
] | [
[
50,
2
],
[
56,
8
],
[
59,
20
],
[
24,
23
],
[
51,
26
],
[
57,
30
],
[
57,
33
],
[
23,
34
],
[
23,
37
],
[
53,
40
],
[
54,
47
],
[
60,
47
],
[
50,
51
],
[
53,
54
],
[
56,
57
],
[
59,
60
]
] | [
"n = int(input())\na = list(map(int,input().split()))\ncount = 0\nfor i in range(n):\n if(a[a[i]-1] == i+1):\n count += 1\nprint(int(count/2))",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a = list(map(int,input().split()))",
"a",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"count = 0",
"count",
"0",
"for i in range(n):\n if(a[a[i]-1] == i+1):\n count += 1",
"i",
"range(n)",
"range",
"n",
"if(a[a[i]-1] == i+1):\n count += 1",
"a[a[i]-1] == i+1",
"a[a[i]-1]",
"a",
"a[i]-1",
"a[i]",
"a",
"i",
"1",
"i+1",
"i",
"1",
"count += 1",
"count",
"1",
"print(int(count/2))",
"print",
"int(count/2)",
"int",
"count/2",
"count",
"2",
"n = int(input())",
"int(input())",
"n",
"count += 1",
"1",
"count",
"a = list(map(int,input().split()))",
"list(map(int,input().split()))",
"a",
"count = 0",
"0",
"count"
] | n = int(input())
a = list(map(int,input().split()))
count = 0
for i in range(n):
if(a[a[i]-1] == i+1):
count += 1
print(int(count/2)) |
[
7,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
14,
2,
18,
13,
18,
13,
13,
13,
0,
13,
17,
4,
13,
2,
13,
17,
10,
17,
13,
10,
2,
13,
10,
17,
13,
10,
4,
13
] | [
[
62,
2
],
[
10,
9
],
[
9,
18
],
[
56,
20
],
[
59,
26
],
[
30,
29
],
[
63,
34
],
[
57,
39
],
[
57,
41
],
[
29,
42
],
[
29,
43
],
[
53,
45
],
[
54,
50
],
[
60,
50
],
[
53,
54
],
[
56,
57
],
[
59,
60
],
[
62,
63
]
] | [
"n = int (input())\nA = [None] + [int(x) for x in input().split()]\n\nans = 0\nfor i in range(1, n+1):\n if A[A[i]] == i:\n ans += 1\nprint(ans //2)",
"n = int (input())",
"n",
"int (input())",
"int",
"input()",
"input",
"int(x) for x in input().split()",
"for x in input().split()",
"x",
"input().split()",
"().split",
"()",
"input",
"split",
"for x in input().split()",
"int(x)",
"int",
"x",
"A = [None] + [int(x) for x in input().split()]",
"A",
"[None] + [int(x) for x in input().split()]",
"[None]",
"None",
"[int(x) for x in input().split()]",
"ans = 0",
"ans",
"0",
"for i in range(1, n+1):\n if A[A[i]] == i:\n ans += 1",
"i",
"range(1, n+1)",
"range",
"1",
"n+1",
"n",
"1",
"if A[A[i]] == i:\n ans += 1",
"A[A[i]] == i",
"A[A[i]]",
"A",
"A[i]",
"A",
"i",
"i",
"ans += 1",
"ans",
"1",
"print(ans //2)",
"print",
"ans //2",
"ans",
"2",
"ans += 1",
"1",
"ans",
"A = [None] + [int(x) for x in input().split()]",
"[None] + [int(x) for x in input().split()]",
"A",
"ans = 0",
"0",
"ans",
"n = int (input())",
"int (input())",
"n"
] | n = int (input())
A = [None] + [int(x) for x in input().split()]
ans = 0
for i in range(1, n+1):
if A[A[i]] == i:
ans += 1
print(ans //2) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
18,
13,
13,
14,
2,
2,
18,
13,
2,
13,
17,
17,
13,
0,
13,
17,
4,
13,
2,
13,
17,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
18,
13
] | [
[
57,
2
],
[
54,
8
],
[
60,
20
],
[
24,
23
],
[
58,
26
],
[
63,
28
],
[
55,
30
],
[
23,
31
],
[
55,
36
],
[
64,
38
],
[
23,
41
],
[
51,
43
],
[
52,
48
],
[
61,
48
],
[
51,
52
],
[
54,
55
],
[
57,
58
],
[
60,
61
],
[
63,
64
]
] | [
"N = int(input())\nA = list(map(int, input().split()))\ncount = 0\nfor x in range(N):\n find = A[x]\n if A[find - 1] - 1 == x:\n count += 1\nprint(count // 2)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"A = list(map(int, input().split()))",
"A",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"count = 0",
"count",
"0",
"for x in range(N):\n find = A[x]\n if A[find - 1] - 1 == x:\n count += 1",
"x",
"range(N)",
"range",
"N",
"find = A[x]",
"find",
"A[x]",
"A",
"x",
"if A[find - 1] - 1 == x:\n count += 1",
"A[find - 1] - 1 == x",
"A[find - 1] - 1",
"A[find - 1]",
"A",
"find - 1",
"find",
"1",
"1",
"x",
"count += 1",
"count",
"1",
"print(count // 2)",
"print",
"count // 2",
"count",
"2",
"count += 1",
"1",
"count",
"A = list(map(int, input().split()))",
"list(map(int, input().split()))",
"A",
"N = int(input())",
"int(input())",
"N",
"count = 0",
"0",
"count",
"find = A[x]",
"A[x]",
"find"
] | N = int(input())
A = list(map(int, input().split()))
count = 0
for x in range(N):
find = A[x]
if A[find - 1] - 1 == x:
count += 1
print(count // 2)
|
[
7,
15,
13,
0,
13,
4,
13,
4,
13,
0,
13,
4,
18,
4,
13,
13,
0,
13,
4,
18,
4,
18,
13,
13,
13,
13,
13,
0,
13,
17,
28,
13,
13,
4,
13,
13,
14,
2,
18,
13,
2,
13,
17,
2,
13,
17,
0,
13,
2,
13,
17,
4,
13,
2,
13,
17,
10,
2,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] | [
[
66,
4
],
[
69,
10
],
[
63,
17
],
[
70,
24
],
[
60,
28
],
[
64,
35
],
[
70,
35
],
[
64,
39
],
[
70,
39
],
[
57,
47
],
[
61,
49
],
[
58,
49
],
[
58,
54
],
[
61,
54
],
[
57,
58
],
[
60,
61
],
[
63,
64
],
[
66,
67
],
[
69,
70
]
] | [
"import numpy as np\nN = int(input())\na = input().split()\na = np.array(a).astype(int)\ncount = 0\nfor i,ai in enumerate(a):\n \n if a[ai-1] == i+1:\n count = count + 1\nprint(count//2)",
"import numpy as np",
"numpy",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"a = input().split()",
"a",
"input().split()",
"().split",
"()",
"input",
"split",
"a = np.array(a).astype(int)",
"a",
"np.array(a).astype(int)",
"np.array(a).astype",
"np.array(a)",
"np.array",
"np",
"array",
"a",
"astype",
"int",
"count = 0",
"count",
"0",
"for i,ai in enumerate(a):\n \n if a[ai-1] == i+1:\n count = count + 1",
"i",
"ai",
"enumerate(a)",
"enumerate",
"a",
"if a[ai-1] == i+1:\n count = count + 1",
"a[ai-1] == i+1",
"a[ai-1]",
"a",
"ai-1",
"ai",
"1",
"i+1",
"i",
"1",
"count = count + 1",
"count",
"count + 1",
"count",
"1",
"print(count//2)",
"print",
"count//2",
"count",
"2",
"count = count + 1",
"count + 1",
"count",
"count = 0",
"0",
"count",
"a = np.array(a).astype(int)",
"np.array(a).astype(int)",
"a",
"N = int(input())",
"int(input())",
"N",
"a = input().split()",
"input().split()",
"a"
] | import numpy as np
N = int(input())
a = input().split()
a = np.array(a).astype(int)
count = 0
for i,ai in enumerate(a):
if a[ai-1] == i+1:
count = count + 1
print(count//2) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
17,
41,
28,
13,
4,
13,
2,
13,
17,
4,
17,
0,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
28,
13,
4,
13,
13,
0,
18,
13,
2,
13,
17,
18,
13,
13,
28,
13,
4,
13,
17,
2,
13,
17,
14,
2,
18,
13,
18,
13,
13,
13,
0,
13,
17,
4,
13,
2,
13,
17,
10,
17,
13,
10,
13,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13
] | [
[
86,
2
],
[
74,
8
],
[
13,
12
],
[
87,
16
],
[
77,
21
],
[
83,
24
],
[
37,
36
],
[
87,
39
],
[
46,
41
],
[
78,
42
],
[
36,
44
],
[
84,
47
],
[
36,
48
],
[
51,
50
],
[
87,
55
],
[
78,
60
],
[
78,
62
],
[
50,
63
],
[
50,
64
],
[
80,
66
],
[
81,
71
],
[
75,
71
],
[
74,
75
],
[
77,
78
],
[
80,
81
],
[
83,
84
],
[
86,
87
]
] | [
"n = int(input())\nans = 0\nflag = [-1 for i in range(n+1)]\nA = list(map(int,input().split()))\nfor i in range(n):\n flag[i+1] = A[i]\nfor i in range(1,n+1):\n if flag[flag[i]] == i:\n ans += 1\nprint(ans//2)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"ans = 0",
"ans",
"0",
"-1 for i in range(n+1)",
"for i in range(n+1)",
"i",
"range(n+1)",
"range",
"n+1",
"n",
"1",
"for i in range(n+1)",
"-1",
"flag = [-1 for i in range(n+1)]",
"flag",
"[-1 for i in range(n+1)]",
"A = list(map(int,input().split()))",
"A",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"for i in range(n):\n flag[i+1] = A[i]",
"i",
"range(n)",
"range",
"n",
"flag[i+1] = A[i]",
"flag[i+1]",
"flag",
"i+1",
"i",
"1",
"A[i]",
"A",
"i",
"for i in range(1,n+1):\n if flag[flag[i]] == i:\n ans += 1",
"i",
"range(1,n+1)",
"range",
"1",
"n+1",
"n",
"1",
"if flag[flag[i]] == i:\n ans += 1",
"flag[flag[i]] == i",
"flag[flag[i]]",
"flag",
"flag[i]",
"flag",
"i",
"i",
"ans += 1",
"ans",
"1",
"print(ans//2)",
"print",
"ans//2",
"ans",
"2",
"ans = 0",
"0",
"ans",
"flag = [-1 for i in range(n+1)]",
"[-1 for i in range(n+1)]",
"flag",
"ans += 1",
"1",
"ans",
"A = list(map(int,input().split()))",
"list(map(int,input().split()))",
"A",
"n = int(input())",
"int(input())",
"n"
] | n = int(input())
ans = 0
flag = [-1 for i in range(n+1)]
A = list(map(int,input().split()))
for i in range(n):
flag[i+1] = A[i]
for i in range(1,n+1):
if flag[flag[i]] == i:
ans += 1
print(ans//2) |
[
7,
15,
13,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
18,
13,
13,
13,
0,
13,
2,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
13,
18,
13,
18,
13,
13,
0,
13,
17,
4,
13,
2,
13,
17,
10,
17,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13
] | [
[
64,
4
],
[
73,
10
],
[
67,
22
],
[
74,
27
],
[
61,
29
],
[
68,
31
],
[
74,
31
],
[
70,
34
],
[
38,
37
],
[
65,
40
],
[
37,
43
],
[
62,
45
],
[
68,
45
],
[
74,
45
],
[
62,
47
],
[
68,
47
],
[
74,
47
],
[
37,
48
],
[
58,
50
],
[
59,
55
],
[
71,
55
],
[
58,
59
],
[
61,
62
],
[
64,
65
],
[
67,
68
],
[
70,
71
],
[
73,
74
]
] | [
"import numpy as np\nN = int(input())\n\na = list(map(int, input().split()))\na = np.array(a)\na = a - 1\n\ncnt = 0\n\nfor i in range(N):\n if i == a[a[i]]:\n cnt += 1\n\nprint(cnt//2)",
"import numpy as np",
"numpy",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"a = list(map(int, input().split()))",
"a",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a = np.array(a)",
"a",
"np.array(a)",
"np.array",
"np",
"array",
"a",
"a = a - 1",
"a",
"a - 1",
"a",
"1",
"cnt = 0",
"cnt",
"0",
"for i in range(N):\n if i == a[a[i]]:\n cnt += 1",
"i",
"range(N)",
"range",
"N",
"if i == a[a[i]]:\n cnt += 1",
"i == a[a[i]]",
"i",
"a[a[i]]",
"a",
"a[i]",
"a",
"i",
"cnt += 1",
"cnt",
"1",
"print(cnt//2)",
"print",
"cnt//2",
"cnt",
"2",
"cnt += 1",
"1",
"cnt",
"a = a - 1",
"a - 1",
"a",
"N = int(input())",
"int(input())",
"N",
"a = np.array(a)",
"np.array(a)",
"a",
"cnt = 0",
"0",
"cnt",
"a = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a"
] | import numpy as np
N = int(input())
a = list(map(int, input().split()))
a = np.array(a)
a = a - 1
cnt = 0
for i in range(N):
if i == a[a[i]]:
cnt += 1
print(cnt//2)
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
18,
4,
13,
17,
13,
13,
31,
13,
4,
13,
2,
4,
13,
2,
2,
13,
17,
18,
13,
2,
18,
13,
13,
17,
17,
10,
4,
13
] | [
[
35,
2
],
[
35,
15
],
[
35,
36
]
] | [
"n,*a=map(int,open(0).read().split())\nprint(sum(i+1==a[a[i]-1] for i in range(n))//2)",
"n,*a=map(int,open(0).read().split())",
"n",
"map(int,open(0).read().split())",
"map",
"int",
"open(0).read().split()",
"(0).read().split",
"(0).read()",
"(0).read",
"(0)",
"open",
"0",
"read",
"split",
"*a",
"a",
"print(sum(i+1==a[a[i]-1] for i in range(n))//2)",
"print",
"sum(i+1==a[a[i]-1] for i in range(n))//2",
"sum(i+1==a[a[i]-1] for i in range(n))",
"sum",
"i+1==a[a[i]-1]",
"i+1",
"i",
"1",
"a[a[i]-1]",
"a",
"a[i]-1",
"a[i]",
"a",
"i",
"1",
"2",
"n,*a=map(int,open(0).read().split())",
"map(int,open(0).read().split())",
"n"
] | n,*a=map(int,open(0).read().split())
print(sum(i+1==a[a[i]-1] for i in range(n))//2) |
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
4,
13,
4,
13,
0,
13,
2,
39,
17,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
13,
4,
13,
13,
14,
2,
13,
17,
9,
14,
2,
13,
18,
13,
13,
0,
13,
17,
4,
13,
2,
13,
17,
10,
2,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
18,
13
] | [
[
79,
4
],
[
73,
18
],
[
80,
22
],
[
67,
24
],
[
80,
36
],
[
76,
39
],
[
68,
46
],
[
68,
56
],
[
70,
59
],
[
71,
64
],
[
77,
64
],
[
67,
68
],
[
70,
71
],
[
73,
74
],
[
76,
77
],
[
79,
80
]
] | [
"import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10 ** 7)\n\nn = int(input())\na = [0] + list(map(int, input().split()))\n\nans = 0\nfor i, v in enumerate(a):\n if i == 0:\n continue\n if i == a[v]:\n ans += 1\nprint(ans // 2)",
"import sys",
"sys",
"input = sys.stdin.readline",
"input",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"sys.setrecursionlimit(10 ** 7)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10 ** 7",
"10",
"7",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a = [0] + list(map(int, input().split()))",
"a",
"[0] + list(map(int, input().split()))",
"[0]",
"0",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"ans = 0",
"ans",
"0",
"for i, v in enumerate(a):\n if i == 0:\n continue\n if i == a[v]:\n ans += 1",
"i",
"v",
"enumerate(a)",
"enumerate",
"a",
"if i == 0:\n continue\n ",
"i == 0",
"i",
"0",
"continue",
"if i == a[v]:\n ans += 1",
"i == a[v]",
"i",
"a[v]",
"a",
"v",
"ans += 1",
"ans",
"1",
"print(ans // 2)",
"print",
"ans // 2",
"ans",
"2",
"a = [0] + list(map(int, input().split()))",
"[0] + list(map(int, input().split()))",
"a",
"ans += 1",
"1",
"ans",
"n = int(input())",
"int(input())",
"n",
"ans = 0",
"0",
"ans",
"input = sys.stdin.readline",
"sys.stdin.readline",
"input"
] | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
n = int(input())
a = [0] + list(map(int, input().split()))
ans = 0
for i, v in enumerate(a):
if i == 0:
continue
if i == a[v]:
ans += 1
print(ans // 2)
|
[
7,
15,
13,
12,
13,
29,
4,
13,
4,
13,
12,
13,
29,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
12,
13,
0,
13,
4,
13,
29,
4,
13,
18,
13,
39,
4,
13,
13,
12,
13,
29,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
0,
13,
4,
13,
0,
13,
39,
17,
0,
13,
13,
0,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
14,
2,
2,
18,
13,
18,
13,
13,
13,
2,
18,
13,
13,
17,
0,
13,
17,
4,
13,
2,
13,
17,
10,
12,
13,
10,
12,
13,
10,
13,
13,
10,
12,
13,
10,
4,
13,
10,
12,
13,
10,
17,
13,
10,
39,
13,
10,
4,
13,
10,
17,
13
] | [
[
27,
26
],
[
26,
33
],
[
26,
37
],
[
110,
50
],
[
99,
52
],
[
122,
54
],
[
102,
56
],
[
119,
58
],
[
104,
62
],
[
123,
63
],
[
116,
65
],
[
69,
68
],
[
111,
73
],
[
105,
79
],
[
120,
79
],
[
105,
81
],
[
120,
81
],
[
68,
82
],
[
68,
83
],
[
105,
86
],
[
120,
86
],
[
68,
87
],
[
125,
90
],
[
126,
95
],
[
117,
95
],
[
123,
104
],
[
104,
105
],
[
110,
111
],
[
116,
117
],
[
119,
120
],
[
122,
123
],
[
125,
126
]
] | [
"# For taking integer inputs.\nimport math\n\n\ndef inp():\n return(int(input()))\n\n\n# For taking List inputs.\ndef inlist():\n return(list(map(int, input().split())))\n\n\n# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.\ndef instr():\n s = input()\n return(list(s[:len(s)]))\n\n\n# For taking space seperated integer variable inputs.\ndef invr():\n return(map(int, input().split()))\n\n\nn = inp()\n\na = inlist()\nb = [0]\nb += a\np = 0\nfor i in range(1, n+1):\n if b[b[i]] == i and b[i] > 0:\n p += 1\n\n\nprint(p//2)",
"import math",
"math",
"def inp():\n return(int(input()))\n\n\n# For taking List inputs.",
"inp",
"return(int(input()))",
"int(input())",
"int",
"input()",
"input",
"def inlist():\n return(list(map(int, input().split())))\n\n\n# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.",
"inlist",
"return(list(map(int, input().split())))",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"def instr():\n s = input()\n return(list(s[:len(s)]))\n\n\n# For taking space seperated integer variable inputs.",
"instr",
"s = input()",
"s",
"input()",
"input",
"return(list(s[:len(s)]))",
"list(s[:len(s)])",
"list",
"s[:len(s)]",
"s",
":len(s)",
"len(s)",
"len",
"s",
"def invr():\n return(map(int, input().split()))",
"invr",
"return(map(int, input().split()))",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"n = inp()",
"n",
"inp()",
"inp",
"a = inlist()",
"a",
"inlist()",
"inlist",
"b = [0]",
"b",
"[0]",
"0",
"b += a",
"b",
"a",
"p = 0",
"p",
"0",
"for i in range(1, n+1):\n if b[b[i]] == i and b[i] > 0:\n p += 1",
"i",
"range(1, n+1)",
"range",
"1",
"n+1",
"n",
"1",
"if b[b[i]] == i and b[i] > 0:\n p += 1",
"b[b[i]] == i and b[i] > 0",
"b[b[i]] == i",
"b[b[i]]",
"b",
"b[i]",
"b",
"i",
"i",
"b[i] > 0",
"b[i]",
"b",
"i",
"0",
"p += 1",
"p",
"1",
"print(p//2)",
"print",
"p//2",
"p",
"2",
"def inp():\n return(int(input()))\n\n\n# For taking List inputs.",
"def inp():\n return(int(input()))\n\n\n# For taking List inputs.",
"inp",
"def inlist():\n return(list(map(int, input().split())))\n\n\n# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.",
"def inlist():\n return(list(map(int, input().split())))\n\n\n# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.",
"inlist",
"b += a",
"a",
"b",
"def invr():\n return(map(int, input().split()))",
"def invr():\n return(map(int, input().split()))",
"invr",
"n = inp()",
"inp()",
"n",
"def instr():\n s = input()\n return(list(s[:len(s)]))\n\n\n# For taking space seperated integer variable inputs.",
"def instr():\n s = input()\n return(list(s[:len(s)]))\n\n\n# For taking space seperated integer variable inputs.",
"instr",
"p = 0",
"0",
"p",
"b = [0]",
"[0]",
"b",
"a = inlist()",
"inlist()",
"a",
"p += 1",
"1",
"p"
] | # For taking integer inputs.
import math
def inp():
return(int(input()))
# For taking List inputs.
def inlist():
return(list(map(int, input().split())))
# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
s = input()
return(list(s[:len(s)]))
# For taking space seperated integer variable inputs.
def invr():
return(map(int, input().split()))
n = inp()
a = inlist()
b = [0]
b += a
p = 0
for i in range(1, n+1):
if b[b[i]] == i and b[i] > 0:
p += 1
print(p//2)
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
13,
0,
13,
17,
14,
2,
18,
13,
2,
13,
17,
13,
0,
13,
17,
4,
13,
2,
13,
17,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13
] | [
[
57,
2
],
[
54,
8
],
[
51,
20
],
[
48,
23
],
[
27,
26
],
[
55,
26
],
[
60,
29
],
[
55,
34
],
[
26,
36
],
[
61,
38
],
[
49,
38
],
[
63,
40
],
[
64,
45
],
[
52,
45
],
[
48,
49
],
[
51,
52
],
[
54,
55
],
[
57,
58
],
[
60,
61
],
[
63,
64
]
] | [
"n = int(input())\nA = list(map(int, input().split()))\n\nans = 0\ncnt = 0\n\nfor a in A:\n cnt += 1\n if A[a-1] == cnt:\n ans += 1\n\nprint(ans//2)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"A = list(map(int, input().split()))",
"A",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"ans = 0",
"ans",
"0",
"cnt = 0",
"cnt",
"0",
"for a in A:\n cnt += 1\n if A[a-1] == cnt:\n ans += 1",
"a",
"A",
"cnt += 1",
"cnt",
"1",
"if A[a-1] == cnt:\n ans += 1",
"A[a-1] == cnt",
"A[a-1]",
"A",
"a-1",
"a",
"1",
"cnt",
"ans += 1",
"ans",
"1",
"print(ans//2)",
"print",
"ans//2",
"ans",
"2",
"cnt = 0",
"0",
"cnt",
"ans = 0",
"0",
"ans",
"A = list(map(int, input().split()))",
"list(map(int, input().split()))",
"A",
"n = int(input())",
"int(input())",
"n",
"cnt += 1",
"1",
"cnt",
"ans += 1",
"1",
"ans"
] | n = int(input())
A = list(map(int, input().split()))
ans = 0
cnt = 0
for a in A:
cnt += 1
if A[a-1] == cnt:
ans += 1
print(ans//2)
|
[
7,
15,
13,
15,
13,
0,
13,
17,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
28,
13,
4,
13,
13,
14,
2,
13,
2,
18,
13,
2,
18,
13,
13,
17,
17,
0,
13,
17,
4,
13,
4,
13,
2,
13,
17,
10,
17,
13,
10,
4,
13,
10,
13,
13,
10,
17,
13
] | [
[
66,
6
],
[
60,
9
],
[
17,
16
],
[
16,
25
],
[
63,
27
],
[
31,
30
],
[
61,
33
],
[
30,
36
],
[
64,
39
],
[
64,
42
],
[
30,
43
],
[
57,
47
],
[
58,
54
],
[
67,
54
],
[
57,
58
],
[
60,
61
],
[
63,
64
],
[
66,
67
]
] | [
"import math\nimport copy\n\nneko = 0\nn = int(input())\na = [int(x) for x in input().split()]\nfor i in range(n):\n if i == a[a[i]-1]-1:\n neko += 1\nprint(int(neko/2))",
"import math",
"math",
"import copy",
"copy",
"neko = 0",
"neko",
"0",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"int(x) for x in input().split()",
"for x in input().split()",
"x",
"input().split()",
"().split",
"()",
"input",
"split",
"for x in input().split()",
"int(x)",
"int",
"x",
"a = [int(x) for x in input().split()]",
"a",
"[int(x) for x in input().split()]",
"for i in range(n):\n if i == a[a[i]-1]-1:\n neko += 1",
"i",
"range(n)",
"range",
"n",
"if i == a[a[i]-1]-1:\n neko += 1",
"i == a[a[i]-1]-1",
"i",
"a[a[i]-1]-1",
"a[a[i]-1]",
"a",
"a[i]-1",
"a[i]",
"a",
"i",
"1",
"1",
"neko += 1",
"neko",
"1",
"print(int(neko/2))",
"print",
"int(neko/2)",
"int",
"neko/2",
"neko",
"2",
"neko += 1",
"1",
"neko",
"n = int(input())",
"int(input())",
"n",
"a = [int(x) for x in input().split()]",
"[int(x) for x in input().split()]",
"a",
"neko = 0",
"0",
"neko"
] | import math
import copy
neko = 0
n = int(input())
a = [int(x) for x in input().split()]
for i in range(n):
if i == a[a[i]-1]-1:
neko += 1
print(int(neko/2)) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
12,
2,
4,
13,
13,
17,
23,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
18,
13,
18,
13,
13,
13,
0,
13,
17,
4,
13,
2,
13,
17,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13
] | [
[
53,
2
],
[
50,
8
],
[
59,
26
],
[
30,
29
],
[
54,
32
],
[
51,
36
],
[
51,
38
],
[
29,
39
],
[
29,
40
],
[
56,
42
],
[
57,
47
],
[
60,
47
],
[
50,
51
],
[
53,
54
],
[
56,
57
],
[
59,
60
]
] | [
"N = int(input())\na = list(map(lambda x:int(x)-1,input().split()))\nans = 0\nfor i in range(N):\n if a[a[i]] == i:\n ans += 1\nprint(ans//2)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"a = list(map(lambda x:int(x)-1,input().split()))",
"a",
"list(map(lambda x:int(x)-1,input().split()))",
"list",
"map(lambda x:int(x)-1,input().split())",
"map",
"lambda x:int(x)-1",
"int(x)-1",
"int(x)",
"int",
"x",
"1",
"x",
"input().split()",
"().split",
"()",
"input",
"split",
"ans = 0",
"ans",
"0",
"for i in range(N):\n if a[a[i]] == i:\n ans += 1",
"i",
"range(N)",
"range",
"N",
"if a[a[i]] == i:\n ans += 1",
"a[a[i]] == i",
"a[a[i]]",
"a",
"a[i]",
"a",
"i",
"i",
"ans += 1",
"ans",
"1",
"print(ans//2)",
"print",
"ans//2",
"ans",
"2",
"a = list(map(lambda x:int(x)-1,input().split()))",
"list(map(lambda x:int(x)-1,input().split()))",
"a",
"N = int(input())",
"int(input())",
"N",
"ans += 1",
"1",
"ans",
"ans = 0",
"0",
"ans"
] | N = int(input())
a = list(map(lambda x:int(x)-1,input().split()))
ans = 0
for i in range(N):
if a[a[i]] == i:
ans += 1
print(ans//2) |
[
7,
0,
31,
13,
4,
13,
13,
4,
18,
4,
18,
4,
13,
17,
13,
13,
0,
13,
17,
28,
13,
13,
4,
13,
13,
0,
13,
2,
2,
18,
13,
39,
13,
2,
13,
17,
39,
13,
2,
13,
17,
4,
13,
2,
13,
17,
10,
2,
13,
10,
17,
13
] | [
[
4,
2
],
[
50,
17
],
[
47,
26
],
[
48,
44
],
[
51,
44
],
[
47,
48
],
[
50,
51
]
] | [
"*a, = map(int, open(0).read().split())\nc = 0\nfor i, j in enumerate(a):\n c += (a[j:j+1] == [i])*(i > 0)\nprint(c // 2)",
"*a, = map(int, open(0).read().split())",
"*a",
"a",
"map(int, open(0).read().split())",
"map",
"int",
"open(0).read().split()",
"(0).read().split",
"(0).read()",
"(0).read",
"(0)",
"open",
"0",
"read",
"split",
"c = 0",
"c",
"0",
"for i, j in enumerate(a):\n c += (a[j:j+1] == [i])*(i > 0)",
"i",
"j",
"enumerate(a)",
"enumerate",
"a",
"c += (a[j:j+1] == [i])*(i > 0)",
"c",
"(a[j:j+1] == [i])*(i > 0)",
"a[j:j+1] == [i]",
"a[j:j+1]",
"a",
"j:j+1",
"j",
"j+1",
"j",
"1",
"[i]",
"i",
"i > 0",
"i",
"0",
"print(c // 2)",
"print",
"c // 2",
"c",
"2",
"c += (a[j:j+1] == [i])*(i > 0)",
"(a[j:j+1] == [i])*(i > 0)",
"c",
"c = 0",
"0",
"c"
] | *a, = map(int, open(0).read().split())
c = 0
for i, j in enumerate(a):
c += (a[j:j+1] == [i])*(i > 0)
print(c // 2) |
[
7,
15,
13,
15,
13,
15,
13,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
13,
4,
13,
13,
14,
2,
18,
13,
2,
13,
17,
2,
13,
17,
0,
13,
17,
4,
13,
2,
13,
17,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13
] | [
[
53,
8
],
[
56,
14
],
[
62,
26
],
[
57,
33
],
[
57,
37
],
[
59,
45
],
[
60,
50
],
[
63,
50
],
[
53,
54
],
[
56,
57
],
[
59,
60
],
[
62,
63
]
] | [
"#!/usr/bin/env python3\nimport collections\nimport itertools as it\nimport math\n#import numpy as np\n \n# = input()\nn = int(input())\n# = map(int, input().split())\na = list(map(int, input().split()))\n# = [int(input()) for i in range(N)]\n#\n# c = collections.Counter()\n\nans_ = 0\nfor i, a_ in enumerate(a):\n if a[a_-1] == i + 1: \n ans_ += 1\nprint(ans_ // 2)",
"import collections",
"collections",
"import itertools as it",
"itertools",
"import math",
"math",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a = list(map(int, input().split()))",
"a",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"ans_ = 0",
"ans_",
"0",
"for i, a_ in enumerate(a):\n if a[a_-1] == i + 1: \n ans_ += 1",
"i",
"a_",
"enumerate(a)",
"enumerate",
"a",
"if a[a_-1] == i + 1: \n ans_ += 1",
"a[a_-1] == i + 1",
"a[a_-1]",
"a",
"a_-1",
"a_",
"1",
"i + 1",
"i",
"1",
"ans_ += 1",
"ans_",
"1",
"print(ans_ // 2)",
"print",
"ans_ // 2",
"ans_",
"2",
"n = int(input())",
"int(input())",
"n",
"a = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a",
"ans_ += 1",
"1",
"ans_",
"ans_ = 0",
"0",
"ans_"
] | #!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
# = input()
n = int(input())
# = map(int, input().split())
a = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
#
# c = collections.Counter()
ans_ = 0
for i, a_ in enumerate(a):
if a[a_-1] == i + 1:
ans_ += 1
print(ans_ // 2)
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
18,
13,
2,
18,
13,
13,
17,
2,
13,
17,
0,
13,
17,
0,
18,
13,
13,
17,
4,
13,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13
] | [
[
54,
2
],
[
60,
8
],
[
51,
20
],
[
24,
23
],
[
55,
26
],
[
61,
30
],
[
43,
32
],
[
61,
33
],
[
23,
34
],
[
23,
37
],
[
57,
40
],
[
46,
43
],
[
61,
44
],
[
23,
45
],
[
58,
49
],
[
52,
49
],
[
51,
52
],
[
54,
55
],
[
57,
58
],
[
60,
61
]
] | [
"N = int(input())\nl = list(map(int, input().split()))\n\ncounter = 0\n\nfor i in range(N):\n if l[l[i]-1] == i+1:\n counter += 1\n l[i] = -99\nprint(counter)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"l = list(map(int, input().split()))",
"l",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"counter = 0",
"counter",
"0",
"for i in range(N):\n if l[l[i]-1] == i+1:\n counter += 1\n l[i] = -99",
"i",
"range(N)",
"range",
"N",
"if l[l[i]-1] == i+1:\n counter += 1\n l[i] = -99",
"l[l[i]-1] == i+1",
"l[l[i]-1]",
"l",
"l[i]-1",
"l[i]",
"l",
"i",
"1",
"i+1",
"i",
"1",
"counter += 1",
"counter",
"1",
"l[i] = -99",
"l[i]",
"l",
"i",
"-99",
"print(counter)",
"print",
"counter",
"counter = 0",
"0",
"counter",
"N = int(input())",
"int(input())",
"N",
"counter += 1",
"1",
"counter",
"l = list(map(int, input().split()))",
"list(map(int, input().split()))",
"l"
] | N = int(input())
l = list(map(int, input().split()))
counter = 0
for i in range(N):
if l[l[i]-1] == i+1:
counter += 1
l[i] = -99
print(counter)
|
[
7,
12,
13,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
18,
13,
2,
18,
13,
13,
17,
2,
13,
17,
0,
13,
17,
4,
13,
2,
13,
17,
4,
13,
10,
12,
13
] | [
[
5,
4
],
[
11,
10
],
[
23,
22
],
[
26,
25
],
[
4,
28
],
[
10,
32
],
[
10,
35
],
[
25,
36
],
[
25,
39
],
[
43,
42
],
[
42,
47
],
[
22,
47
],
[
53,
50
]
] | [
"def resolve():\n N = int(input())\n a = list(map(int, input().split()))\n ans = 0\n for i in range(N):\n if a[a[i]-1] == i+1:\n ans += 1\n print(ans//2)\nresolve()",
"def resolve():\n N = int(input())\n a = list(map(int, input().split()))\n ans = 0\n for i in range(N):\n if a[a[i]-1] == i+1:\n ans += 1\n print(ans//2)",
"resolve",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"a = list(map(int, input().split()))",
"a",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"ans = 0",
"ans",
"0",
"for i in range(N):\n if a[a[i]-1] == i+1:\n ans += 1\n ",
"i",
"range(N)",
"range",
"N",
"if a[a[i]-1] == i+1:\n ans += 1\n ",
"a[a[i]-1] == i+1",
"a[a[i]-1]",
"a",
"a[i]-1",
"a[i]",
"a",
"i",
"1",
"i+1",
"i",
"1",
"ans += 1",
"ans",
"1",
"print(ans//2)",
"print",
"ans//2",
"ans",
"2",
"resolve()",
"resolve",
"def resolve():\n N = int(input())\n a = list(map(int, input().split()))\n ans = 0\n for i in range(N):\n if a[a[i]-1] == i+1:\n ans += 1\n print(ans//2)",
"def resolve():\n N = int(input())\n a = list(map(int, input().split()))\n ans = 0\n for i in range(N):\n if a[a[i]-1] == i+1:\n ans += 1\n print(ans//2)",
"resolve"
] | def resolve():
N = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(N):
if a[a[i]-1] == i+1:
ans += 1
print(ans//2)
resolve() |
[
7,
15,
0,
13,
4,
13,
4,
18,
4,
18,
13,
13,
13,
0,
13,
2,
39,
17,
4,
13,
4,
13,
13,
4,
18,
4,
18,
4,
18,
13,
13,
13,
13,
0,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
14,
2,
18,
13,
18,
13,
13,
13,
0,
13,
17,
4,
13,
2,
13,
17,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
2,
13
] | [
[
67,
3
],
[
70,
14
],
[
61,
34
],
[
38,
37
],
[
68,
42
],
[
71,
47
],
[
71,
49
],
[
37,
50
],
[
37,
51
],
[
64,
53
],
[
65,
58
],
[
62,
58
],
[
61,
62
],
[
64,
65
],
[
67,
68
],
[
70,
71
]
] | [
"from sys import stdin\n\nn = int(stdin.readline().rstrip())\nli = [1]+list(map(int,stdin.readline().rstrip().split()))\npoint = 0\nfor i in range(1,n+1):\n if li[li[i]] == i:\n point += 1\nprint(point//2)",
"from sys import stdin",
"n = int(stdin.readline().rstrip())",
"n",
"int(stdin.readline().rstrip())",
"int",
"stdin.readline().rstrip()",
"stdin.readline().rstrip",
"stdin.readline()",
"stdin.readline",
"stdin",
"readline",
"rstrip",
"li = [1]+list(map(int,stdin.readline().rstrip().split()))",
"li",
"[1]+list(map(int,stdin.readline().rstrip().split()))",
"[1]",
"1",
"list(map(int,stdin.readline().rstrip().split()))",
"list",
"map(int,stdin.readline().rstrip().split())",
"map",
"int",
"stdin.readline().rstrip().split()",
"stdin.readline().rstrip().split",
"stdin.readline().rstrip()",
"stdin.readline().rstrip",
"stdin.readline()",
"stdin.readline",
"stdin",
"readline",
"rstrip",
"split",
"point = 0",
"point",
"0",
"for i in range(1,n+1):\n if li[li[i]] == i:\n point += 1",
"i",
"range(1,n+1)",
"range",
"1",
"n+1",
"n",
"1",
"if li[li[i]] == i:\n point += 1",
"li[li[i]] == i",
"li[li[i]]",
"li",
"li[i]",
"li",
"i",
"i",
"point += 1",
"point",
"1",
"print(point//2)",
"print",
"point//2",
"point",
"2",
"point = 0",
"0",
"point",
"point += 1",
"1",
"point",
"n = int(stdin.readline().rstrip())",
"int(stdin.readline().rstrip())",
"n",
"li = [1]+list(map(int,stdin.readline().rstrip().split()))",
"[1]+list(map(int,stdin.readline().rstrip().split()))",
"li"
] | from sys import stdin
n = int(stdin.readline().rstrip())
li = [1]+list(map(int,stdin.readline().rstrip().split()))
point = 0
for i in range(1,n+1):
if li[li[i]] == i:
point += 1
print(point//2) |
[
7,
15,
13,
0,
13,
12,
4,
18,
4,
18,
18,
13,
13,
13,
13,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
17,
0,
13,
13,
28,
13,
4,
13,
17,
2,
13,
17,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
14,
2,
18,
13,
18,
13,
13,
13,
0,
13,
17,
4,
13,
2,
13,
17,
10,
17,
13,
10,
12,
13,
10,
4,
13,
10,
17,
13,
10,
13,
13,
10,
4,
13
] | [
[
94,
4
],
[
97,
16
],
[
95,
20
],
[
106,
22
],
[
95,
31
],
[
36,
35
],
[
98,
39
],
[
103,
44
],
[
48,
47
],
[
98,
52
],
[
58,
55
],
[
104,
56
],
[
47,
57
],
[
107,
59
],
[
47,
61
],
[
91,
64
],
[
68,
67
],
[
98,
72
],
[
104,
77
],
[
55,
78
],
[
104,
79
],
[
67,
80
],
[
67,
81
],
[
100,
83
],
[
101,
88
],
[
92,
88
],
[
91,
92
],
[
94,
95
],
[
97,
98
],
[
100,
101
],
[
103,
104
],
[
106,
107
]
] | [
"import sys\ninput = lambda: sys.stdin.readline().rstrip()\nn = int(input())\na = list(map(int, input().split()))\nto = [0 for _ in range(n + 1)]\n\nfor i in range(1, n + 1):\n to[i] = a[i - 1]\nans = 0\nfor i in range(1, n + 1):\n if to[to[i]] == i:\n ans += 1\nprint(ans // 2)",
"import sys",
"sys",
"input = lambda: sys.stdin.readline().rstrip()",
"input",
"lambda: sys.stdin.readline().rstrip()",
"sys.stdin.readline().rstrip()",
"sys.stdin.readline().rstrip",
"sys.stdin.readline()",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"rstrip",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a = list(map(int, input().split()))",
"a",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"0 for _ in range(n + 1)",
"for _ in range(n + 1)",
"_",
"range(n + 1)",
"range",
"n + 1",
"n",
"1",
"for _ in range(n + 1)",
"0",
"to = [0 for _ in range(n + 1)]",
"to",
"[0 for _ in range(n + 1)]",
"for i in range(1, n + 1):\n to[i] = a[i - 1]",
"i",
"range(1, n + 1)",
"range",
"1",
"n + 1",
"n",
"1",
"to[i] = a[i - 1]",
"to[i]",
"to",
"i",
"a[i - 1]",
"a",
"i - 1",
"i",
"1",
"ans = 0",
"ans",
"0",
"for i in range(1, n + 1):\n if to[to[i]] == i:\n ans += 1",
"i",
"range(1, n + 1)",
"range",
"1",
"n + 1",
"n",
"1",
"if to[to[i]] == i:\n ans += 1",
"to[to[i]] == i",
"to[to[i]]",
"to",
"to[i]",
"to",
"i",
"i",
"ans += 1",
"ans",
"1",
"print(ans // 2)",
"print",
"ans // 2",
"ans",
"2",
"ans = 0",
"0",
"ans",
"input = lambda: sys.stdin.readline().rstrip()",
"lambda: sys.stdin.readline().rstrip()",
"input",
"n = int(input())",
"int(input())",
"n",
"ans += 1",
"1",
"ans",
"to = [0 for _ in range(n + 1)]",
"[0 for _ in range(n + 1)]",
"to",
"a = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a"
] | import sys
input = lambda: sys.stdin.readline().rstrip()
n = int(input())
a = list(map(int, input().split()))
to = [0 for _ in range(n + 1)]
for i in range(1, n + 1):
to[i] = a[i - 1]
ans = 0
for i in range(1, n + 1):
if to[to[i]] == i:
ans += 1
print(ans // 2)
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
13,
4,
13,
13,
17,
14,
2,
13,
18,
13,
2,
13,
17,
0,
13,
17,
4,
13,
2,
13,
17,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13
] | [
[
52,
2
],
[
55,
8
],
[
49,
20
],
[
56,
27
],
[
56,
33
],
[
46,
38
],
[
47,
43
],
[
50,
43
],
[
46,
47
],
[
49,
50
],
[
52,
53
],
[
55,
56
]
] | [
"n = int(input())\n\na = list(map(int,input().split()))\n\nres = 0\n\nfor i,v in enumerate(a,1):\n if i == a[v-1]:\n res += 1\nprint(res//2)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a = list(map(int,input().split()))",
"a",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"res = 0",
"res",
"0",
"for i,v in enumerate(a,1):\n if i == a[v-1]:\n res += 1",
"i",
"v",
"enumerate(a,1)",
"enumerate",
"a",
"1",
"if i == a[v-1]:\n res += 1",
"i == a[v-1]",
"i",
"a[v-1]",
"a",
"v-1",
"v",
"1",
"res += 1",
"res",
"1",
"print(res//2)",
"print",
"res//2",
"res",
"2",
"res += 1",
"1",
"res",
"res = 0",
"0",
"res",
"n = int(input())",
"int(input())",
"n",
"a = list(map(int,input().split()))",
"list(map(int,input().split()))",
"a"
] | n = int(input())
a = list(map(int,input().split()))
res = 0
for i,v in enumerate(a,1):
if i == a[v-1]:
res += 1
print(res//2) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
17,
28,
13,
13,
4,
13,
13,
14,
18,
13,
13,
9,
14,
2,
2,
18,
13,
2,
13,
17,
17,
13,
0,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
2,
13,
17,
17,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
2,
13,
10,
17,
13
] | [
[
68,
2
],
[
71,
8
],
[
77,
20
],
[
69,
24
],
[
74,
26
],
[
72,
33
],
[
78,
36
],
[
72,
43
],
[
80,
50
],
[
56,
53
],
[
78,
54
],
[
63,
58
],
[
78,
59
],
[
81,
66
],
[
75,
66
],
[
68,
69
],
[
71,
72
],
[
74,
75
],
[
77,
78
],
[
80,
81
]
] | [
"n = int(input())\nA = list(map(int, input().split()))\nchecked = [False] * n\nans = 0\nfor i, a in enumerate(A):\n if checked[i]:\n continue\n if A[a - 1] - 1 == i:\n ans += 1\n checked[i] = True\n checked[a - 1] = True\nprint(ans)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"A = list(map(int, input().split()))",
"A",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"checked = [False] * n",
"checked",
"[False] * n",
"[False]",
"False",
"n",
"ans = 0",
"ans",
"0",
"for i, a in enumerate(A):\n if checked[i]:\n continue\n if A[a - 1] - 1 == i:\n ans += 1\n checked[i] = True\n checked[a - 1] = True",
"i",
"a",
"enumerate(A)",
"enumerate",
"A",
"if checked[i]:\n continue\n ",
"checked[i]",
"checked",
"i",
"continue",
"if A[a - 1] - 1 == i:\n ans += 1\n checked[i] = True\n checked[a - 1] = True",
"A[a - 1] - 1 == i",
"A[a - 1] - 1",
"A[a - 1]",
"A",
"a - 1",
"a",
"1",
"1",
"i",
"ans += 1",
"ans",
"1",
"checked[i] = True",
"checked[i]",
"checked",
"i",
"True",
"checked[a - 1] = True",
"checked[a - 1]",
"checked",
"a - 1",
"a",
"1",
"True",
"print(ans)",
"print",
"ans",
"n = int(input())",
"int(input())",
"n",
"A = list(map(int, input().split()))",
"list(map(int, input().split()))",
"A",
"ans = 0",
"0",
"ans",
"checked = [False] * n",
"[False] * n",
"checked",
"ans += 1",
"1",
"ans"
] | n = int(input())
A = list(map(int, input().split()))
checked = [False] * n
ans = 0
for i, a in enumerate(A):
if checked[i]:
continue
if A[a - 1] - 1 == i:
ans += 1
checked[i] = True
checked[a - 1] = True
print(ans) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
18,
13,
13,
17,
9,
14,
2,
18,
13,
2,
18,
13,
13,
17,
2,
13,
17,
0,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
2,
18,
13,
13,
17,
17,
0,
18,
13,
13,
17,
4,
13,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
13,
13,
10,
4,
13
] | [
[
95,
2
],
[
89,
8
],
[
22,
21
],
[
96,
24
],
[
92,
28
],
[
83,
31
],
[
35,
34
],
[
96,
37
],
[
75,
40
],
[
61,
40
],
[
93,
41
],
[
34,
42
],
[
90,
48
],
[
90,
51
],
[
34,
52
],
[
34,
55
],
[
86,
58
],
[
64,
61
],
[
93,
62
],
[
34,
63
],
[
73,
66
],
[
93,
67
],
[
90,
70
],
[
34,
71
],
[
78,
75
],
[
93,
76
],
[
34,
77
],
[
87,
81
],
[
84,
81
],
[
83,
84
],
[
86,
87
],
[
89,
90
],
[
92,
93
],
[
95,
96
]
] | [
"N=int(input())\na=list(map(int,input().split()))\n\nchk=[0 for i in range(N)]\nans=0\nfor i in range(N):\n if chk[i]==1:\n continue\n if a[a[i]-1]==(i+1):\n ans+=1\n chk[i]=1\n chk[a[i]-1]=1\n else:\n chk[i]=1\n\nprint(ans)",
"N=int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"a=list(map(int,input().split()))",
"a",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"0 for i in range(N)",
"for i in range(N)",
"i",
"range(N)",
"range",
"N",
"for i in range(N)",
"0",
"chk=[0 for i in range(N)]",
"chk",
"[0 for i in range(N)]",
"ans=0",
"ans",
"0",
"for i in range(N):\n if chk[i]==1:\n continue\n if a[a[i]-1]==(i+1):\n ans+=1\n chk[i]=1\n chk[a[i]-1]=1\n else:\n chk[i]=1",
"i",
"range(N)",
"range",
"N",
"if chk[i]==1:\n continue\n ",
"chk[i]==1",
"chk[i]",
"chk",
"i",
"1",
"continue",
"if a[a[i]-1]==(i+1):\n ans+=1\n chk[i]=1\n chk[a[i]-1]=1\n else:\n chk[i]=1",
"a[a[i]-1]==(i+1)",
"a[a[i]-1]",
"a",
"a[i]-1",
"a[i]",
"a",
"i",
"1",
"i+1",
"i",
"1",
"ans+=1",
"ans",
"1",
"chk[i]=1",
"chk[i]",
"chk",
"i",
"1",
"chk[a[i]-1]=1",
"chk[a[i]-1]",
"chk",
"a[i]-1",
"a[i]",
"a",
"i",
"1",
"1",
"chk[i]=1",
"chk[i]",
"chk",
"i",
"1",
"print(ans)",
"print",
"ans",
"ans=0",
"0",
"ans",
"ans+=1",
"1",
"ans",
"a=list(map(int,input().split()))",
"list(map(int,input().split()))",
"a",
"chk=[0 for i in range(N)]",
"[0 for i in range(N)]",
"chk",
"N=int(input())",
"int(input())",
"N"
] | N=int(input())
a=list(map(int,input().split()))
chk=[0 for i in range(N)]
ans=0
for i in range(N):
if chk[i]==1:
continue
if a[a[i]-1]==(i+1):
ans+=1
chk[i]=1
chk[a[i]-1]=1
else:
chk[i]=1
print(ans) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
17,
0,
31,
13,
4,
13,
13,
4,
18,
4,
13,
13,
28,
13,
13,
4,
13,
13,
14,
2,
18,
13,
2,
18,
13,
13,
17,
2,
13,
17,
0,
13,
17,
4,
13,
2,
13,
17,
10,
4,
13,
10,
17,
13,
10,
17,
13
] | [
[
48,
2
],
[
54,
8
],
[
13,
11
],
[
51,
40
],
[
52,
45
],
[
55,
45
],
[
48,
49
],
[
51,
52
],
[
54,
55
]
] | [
"p = int(input())\nans = 0\n*A,= map(int,input().split())\nfor j,i in enumerate(A):\n if A[A[j]-1]==j+1:\n ans+=1\nprint(ans//2)",
"p = int(input())",
"p",
"int(input())",
"int",
"input()",
"input",
"ans = 0",
"ans",
"0",
"*A,= map(int,input().split())",
"*A",
"A",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"for j,i in enumerate(A):\n if A[A[j]-1]==j+1:\n ans+=1",
"j",
"i",
"enumerate(A)",
"enumerate",
"A",
"if A[A[j]-1]==j+1:\n ans+=1",
"A[A[j]-1]==j+1",
"A[A[j]-1]",
"A",
"A[j]-1",
"A[j]",
"A",
"j",
"1",
"j+1",
"j",
"1",
"ans+=1",
"ans",
"1",
"print(ans//2)",
"print",
"ans//2",
"ans",
"2",
"p = int(input())",
"int(input())",
"p",
"ans+=1",
"1",
"ans",
"ans = 0",
"0",
"ans"
] | p = int(input())
ans = 0
*A,= map(int,input().split())
for j,i in enumerate(A):
if A[A[j]-1]==j+1:
ans+=1
print(ans//2) |
[
7,
12,
13,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
0,
13,
17,
28,
13,
13,
4,
13,
13,
14,
2,
18,
13,
2,
13,
17,
2,
13,
17,
0,
13,
17,
4,
13,
2,
13,
17,
4,
13,
10,
12,
13
] | [
[
5,
4
],
[
12,
11
],
[
11,
20
],
[
23,
22
],
[
26,
25
],
[
22,
32
],
[
22,
36
],
[
45,
44
],
[
44,
49
],
[
25,
49
],
[
55,
52
]
] | [
"def main():\n N=int(input())\n a=[int(_) for _ in input().split()]\n ans = 0\n for i,v in enumerate(a):\n if a[v-1] == i+1:\n ans += 1\n print(ans//2)\n\nmain()",
"def main():\n N=int(input())\n a=[int(_) for _ in input().split()]\n ans = 0\n for i,v in enumerate(a):\n if a[v-1] == i+1:\n ans += 1\n print(ans//2)",
"main",
"N=int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"int(_) for _ in input().split()",
"for _ in input().split()",
"_",
"input().split()",
"().split",
"()",
"input",
"split",
"for _ in input().split()",
"int(_)",
"int",
"_",
"a=[int(_) for _ in input().split()]",
"a",
"[int(_) for _ in input().split()]",
"ans = 0",
"ans",
"0",
"for i,v in enumerate(a):\n if a[v-1] == i+1:\n ans += 1\n ",
"i",
"v",
"enumerate(a)",
"enumerate",
"a",
"if a[v-1] == i+1:\n ans += 1\n ",
"a[v-1] == i+1",
"a[v-1]",
"a",
"v-1",
"v",
"1",
"i+1",
"i",
"1",
"ans += 1",
"ans",
"1",
"print(ans//2)",
"print",
"ans//2",
"ans",
"2",
"main()",
"main",
"def main():\n N=int(input())\n a=[int(_) for _ in input().split()]\n ans = 0\n for i,v in enumerate(a):\n if a[v-1] == i+1:\n ans += 1\n print(ans//2)",
"def main():\n N=int(input())\n a=[int(_) for _ in input().split()]\n ans = 0\n for i,v in enumerate(a):\n if a[v-1] == i+1:\n ans += 1\n print(ans//2)",
"main"
] | def main():
N=int(input())
a=[int(_) for _ in input().split()]
ans = 0
for i,v in enumerate(a):
if a[v-1] == i+1:
ans += 1
print(ans//2)
main() |
[
7,
15,
13,
15,
13,
0,
13,
12,
2,
4,
13,
13,
17,
23,
0,
13,
18,
18,
18,
13,
13,
13,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
4,
18,
13,
13,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
31,
13,
0,
13,
17,
28,
13,
13,
4,
13,
13,
14,
2,
18,
13,
13,
13,
0,
13,
17,
4,
13,
2,
13,
17,
10,
12,
13,
10,
18,
13,
10,
18,
13,
10,
17,
13,
10,
4,
13,
10,
18,
13,
10,
17,
13
] | [
[
82,
6
],
[
85,
15
],
[
97,
24
],
[
88,
33
],
[
94,
47
],
[
83,
50
],
[
86,
54
],
[
94,
56
],
[
91,
59
],
[
100,
74
],
[
101,
79
],
[
92,
79
],
[
82,
83
],
[
85,
86
],
[
88,
89
],
[
91,
92
],
[
94,
95
],
[
97,
98
],
[
100,
101
]
] | [
"#! /usr/bin/env python3\n\nimport sys\nimport numpy as np\nint1 = lambda x: int(x) - 1\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nsys.setrecursionlimit(500000)\n\n_, *A = map(int1, read().split())\n\nans = 0\nfor i, a in enumerate(A):\n if A[a] == i:\n ans += 1\n\nprint(ans // 2)",
"import sys",
"sys",
"import numpy as np",
"numpy",
"int1 = lambda x: int(x) - 1",
"int1",
"lambda x: int(x) - 1",
"int(x) - 1",
"int(x)",
"int",
"x",
"1",
"x",
"read = sys.stdin.buffer.read",
"read",
"sys.stdin.buffer.read",
"sys.stdin.buffer",
"sys.stdin",
"sys",
"stdin",
"buffer",
"read",
"readline = sys.stdin.buffer.readline",
"readline",
"sys.stdin.buffer.readline",
"sys.stdin.buffer",
"sys.stdin",
"sys",
"stdin",
"buffer",
"readline",
"readlines = sys.stdin.buffer.readlines",
"readlines",
"sys.stdin.buffer.readlines",
"sys.stdin.buffer",
"sys.stdin",
"sys",
"stdin",
"buffer",
"readlines",
"sys.setrecursionlimit(500000)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"500000",
"_, *A = map(int1, read().split())",
"_",
"map(int1, read().split())",
"map",
"int1",
"read().split()",
"().split",
"()",
"read",
"split",
"*A",
"A",
"ans = 0",
"ans",
"0",
"for i, a in enumerate(A):\n if A[a] == i:\n ans += 1",
"i",
"a",
"enumerate(A)",
"enumerate",
"A",
"if A[a] == i:\n ans += 1",
"A[a] == i",
"A[a]",
"A",
"a",
"i",
"ans += 1",
"ans",
"1",
"print(ans // 2)",
"print",
"ans // 2",
"ans",
"2",
"int1 = lambda x: int(x) - 1",
"lambda x: int(x) - 1",
"int1",
"read = sys.stdin.buffer.read",
"sys.stdin.buffer.read",
"read",
"readlines = sys.stdin.buffer.readlines",
"sys.stdin.buffer.readlines",
"readlines",
"ans = 0",
"0",
"ans",
"_, *A = map(int1, read().split())",
"map(int1, read().split())",
"_",
"readline = sys.stdin.buffer.readline",
"sys.stdin.buffer.readline",
"readline",
"ans += 1",
"1",
"ans"
] | #! /usr/bin/env python3
import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)
_, *A = map(int1, read().split())
ans = 0
for i, a in enumerate(A):
if A[a] == i:
ans += 1
print(ans // 2)
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
2,
18,
13,
2,
18,
13,
13,
17,
17,
13,
0,
13,
17,
4,
13,
2,
13,
17,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13
] | [
[
54,
2
],
[
57,
8
],
[
51,
20
],
[
24,
23
],
[
55,
26
],
[
58,
31
],
[
58,
34
],
[
23,
35
],
[
23,
38
],
[
48,
40
],
[
49,
45
],
[
52,
45
],
[
48,
49
],
[
51,
52
],
[
54,
55
],
[
57,
58
]
] | [
"n = int(input())\na = list(map(int,input().split()))\nans = 0\nfor i in range(n):\n if a[a[i]-1]-1 == i:\n ans += 1\nprint(ans // 2)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a = list(map(int,input().split()))",
"a",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"ans = 0",
"ans",
"0",
"for i in range(n):\n if a[a[i]-1]-1 == i:\n ans += 1",
"i",
"range(n)",
"range",
"n",
"if a[a[i]-1]-1 == i:\n ans += 1",
"a[a[i]-1]-1 == i",
"a[a[i]-1]-1",
"a[a[i]-1]",
"a",
"a[i]-1",
"a[i]",
"a",
"i",
"1",
"1",
"i",
"ans += 1",
"ans",
"1",
"print(ans // 2)",
"print",
"ans // 2",
"ans",
"2",
"ans += 1",
"1",
"ans",
"ans = 0",
"0",
"ans",
"n = int(input())",
"int(input())",
"n",
"a = list(map(int,input().split()))",
"list(map(int,input().split()))",
"a"
] | n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n):
if a[a[i]-1]-1 == i:
ans += 1
print(ans // 2) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
18,
13,
13,
14,
2,
18,
13,
2,
13,
17,
2,
13,
17,
0,
13,
17,
4,
13,
2,
13,
17,
10,
18,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13
] | [
[
60,
2
],
[
57,
8
],
[
54,
20
],
[
24,
23
],
[
61,
26
],
[
51,
28
],
[
58,
30
],
[
23,
31
],
[
58,
35
],
[
52,
37
],
[
23,
40
],
[
63,
43
],
[
64,
48
],
[
55,
48
],
[
51,
52
],
[
54,
55
],
[
57,
58
],
[
60,
61
],
[
63,
64
]
] | [
"N=int(input())\nlike=list(map(int,input().split()))\ncount=0\n\nfor i in range(N):\n like_1=like[i]\n #print(\"like_1\")\n #print(like_1)\n if like[like_1-1]==i+1:\n #print(like[like_1-1])\n #print(i+1)\n count+=1\n #print(\"///\")\n \nprint(count//2)",
"N=int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"like=list(map(int,input().split()))",
"like",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"count=0",
"count",
"0",
"for i in range(N):\n like_1=like[i]\n #print(\"like_1\")\n #print(like_1)\n if like[like_1-1]==i+1:\n #print(like[like_1-1])\n #print(i+1)\n count+=1\n #print(\"///\")\n ",
"i",
"range(N)",
"range",
"N",
"like_1=like[i]",
"like_1",
"like[i]",
"like",
"i",
"if like[like_1-1]==i+1:\n #print(like[like_1-1])\n #print(i+1)\n count+=1\n #print(\"///\")\n ",
"like[like_1-1]==i+1",
"like[like_1-1]",
"like",
"like_1-1",
"like_1",
"1",
"i+1",
"i",
"1",
"count+=1",
"count",
"1",
"print(count//2)",
"print",
"count//2",
"count",
"2",
"like_1=like[i]",
"like[i]",
"like_1",
"count=0",
"0",
"count",
"like=list(map(int,input().split()))",
"list(map(int,input().split()))",
"like",
"N=int(input())",
"int(input())",
"N",
"count+=1",
"1",
"count"
] | N=int(input())
like=list(map(int,input().split()))
count=0
for i in range(N):
like_1=like[i]
#print("like_1")
#print(like_1)
if like[like_1-1]==i+1:
#print(like[like_1-1])
#print(i+1)
count+=1
#print("///")
print(count//2) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
39,
0,
13,
17,
28,
13,
4,
13,
17,
13,
4,
18,
13,
13,
39,
2,
13,
17,
18,
13,
13,
28,
13,
13,
13,
14,
2,
18,
18,
13,
2,
13,
17,
17,
13,
0,
13,
17,
4,
13,
2,
13,
17,
10,
17,
13,
10,
4,
13,
10,
39,
13,
10,
4,
13,
10,
17,
13
] | [
[
74,
2
],
[
68,
8
],
[
71,
20
],
[
65,
23
],
[
27,
26
],
[
75,
30
],
[
72,
33
],
[
26,
37
],
[
69,
40
],
[
26,
41
],
[
72,
50
],
[
77,
57
],
[
78,
62
],
[
66,
62
],
[
65,
66
],
[
68,
69
],
[
71,
72
],
[
74,
75
],
[
77,
78
]
] | [
"N = int(input())\na = list(map(int, input().split()))\nlike = []\ncnt = 0\n\nfor i in range(0, N):\n like.append([i+1, a[i]])\n\nfor j, k in like:\n if like[k-1][1] == j:\n cnt += 1\n\nprint(cnt // 2)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"a = list(map(int, input().split()))",
"a",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"like = []",
"like",
"[]",
"cnt = 0",
"cnt",
"0",
"for i in range(0, N):\n like.append([i+1, a[i]])",
"i",
"range(0, N)",
"range",
"0",
"N",
"like.append([i+1, a[i]])",
"like.append",
"like",
"append",
"[i+1, a[i]]",
"i+1",
"i",
"1",
"a[i]",
"a",
"i",
"for j, k in like:\n if like[k-1][1] == j:\n cnt += 1",
"j",
"k",
"like",
"if like[k-1][1] == j:\n cnt += 1",
"like[k-1][1] == j",
"like[k-1][1]",
"[k-1]",
"like",
"k-1",
"k",
"1",
"1",
"j",
"cnt += 1",
"cnt",
"1",
"print(cnt // 2)",
"print",
"cnt // 2",
"cnt",
"2",
"cnt = 0",
"0",
"cnt",
"a = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a",
"like = []",
"[]",
"like",
"N = int(input())",
"int(input())",
"N",
"cnt += 1",
"1",
"cnt"
] | N = int(input())
a = list(map(int, input().split()))
like = []
cnt = 0
for i in range(0, N):
like.append([i+1, a[i]])
for j, k in like:
if like[k-1][1] == j:
cnt += 1
print(cnt // 2) |
[
7,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
0,
13,
17,
28,
13,
13,
4,
13,
13,
14,
2,
18,
13,
2,
13,
17,
2,
13,
17,
4,
13,
4,
13,
2,
13,
17,
10,
17,
13,
10,
13,
13,
10,
4,
13
] | [
[
55,
2
],
[
10,
9
],
[
9,
18
],
[
52,
20
],
[
49,
23
],
[
53,
30
],
[
53,
34
],
[
50,
46
],
[
49,
50
],
[
52,
53
],
[
55,
56
]
] | [
"n = int(input())\na = [int(x) for x in input().split()]\nans = 0\nfor i, a_i in enumerate(a):\n if a[a_i - 1] == i + 1: ans += 1\nprint(int(ans/2))",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"int(x) for x in input().split()",
"for x in input().split()",
"x",
"input().split()",
"().split",
"()",
"input",
"split",
"for x in input().split()",
"int(x)",
"int",
"x",
"a = [int(x) for x in input().split()]",
"a",
"[int(x) for x in input().split()]",
"ans = 0",
"ans",
"0",
"for i, a_i in enumerate(a):\n if a[a_i - 1] == i + 1: ans += 1",
"i",
"a_i",
"enumerate(a)",
"enumerate",
"a",
"if a[a_i - 1] == i + 1: ans ",
"a[a_i - 1] == i + 1",
"a[a_i - 1]",
"a",
"a_i - 1",
"a_i",
"1",
"i + 1",
"i",
"1",
"print(int(ans/2))",
"print",
"int(ans/2)",
"int",
"ans/2",
"ans",
"2",
"ans = 0",
"0",
"ans",
"a = [int(x) for x in input().split()]",
"[int(x) for x in input().split()]",
"a",
"n = int(input())",
"int(input())",
"n"
] | n = int(input())
a = [int(x) for x in input().split()]
ans = 0
for i, a_i in enumerate(a):
if a[a_i - 1] == i + 1: ans += 1
print(int(ans/2)) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
13,
4,
13,
13,
4,
2,
13,
17,
13,
0,
13,
13,
0,
13,
17,
28,
13,
13,
4,
18,
13,
13,
14,
2,
13,
18,
13,
13,
0,
13,
17,
4,
13,
2,
13,
17,
10,
17,
13,
10,
4,
13,
10,
13,
13,
10,
4,
13,
10,
17,
13
] | [
[
68,
2
],
[
62,
8
],
[
63,
25
],
[
65,
32
],
[
59,
35
],
[
66,
42
],
[
63,
42
],
[
66,
48
],
[
63,
48
],
[
71,
51
],
[
72,
56
],
[
60,
56
],
[
59,
60
],
[
62,
63
],
[
65,
66
],
[
68,
69
],
[
71,
72
]
] | [
"n = int(input()) #兎の数\na = list(map(int,(input().split())))\na = {i+1: v for i, v in enumerate(a)}\n#print(a)\n#print(a[1])\n\ncounter = 0\n\nfor i,j in a.items():\n if i == a[j]:\n #print(i,j)\n counter += 1\n\nprint(counter//2)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a = list(map(int,(input().split())))",
"a",
"list(map(int,(input().split())))",
"list",
"map(int,(input().split()))",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"i+1: v for i, v in enumerate(a)",
"for i, v in enumerate(a)",
"i",
"v",
"enumerate(a)",
"enumerate",
"a",
"for i, v in enumerate(a)",
"i+1",
"i",
"1",
"v",
"a = {i+1: v for i, v in enumerate(a)}",
"a",
"{i+1: v for i, v in enumerate(a)}",
"counter = 0",
"counter",
"0",
"for i,j in a.items():\n if i == a[j]:\n #print(i,j)\n counter += 1",
"i",
"j",
"a.items()",
"a.items",
"a",
"items",
"if i == a[j]:\n #print(i,j)\n counter += 1",
"i == a[j]",
"i",
"a[j]",
"a",
"j",
"counter += 1",
"counter",
"1",
"print(counter//2)",
"print",
"counter//2",
"counter",
"2",
"counter = 0",
"0",
"counter",
"a = list(map(int,(input().split())))",
"list(map(int,(input().split())))",
"a",
"a = {i+1: v for i, v in enumerate(a)}",
"{i+1: v for i, v in enumerate(a)}",
"a",
"n = int(input())",
"int(input())",
"n",
"counter += 1",
"1",
"counter"
] | n = int(input()) #兎の数
a = list(map(int,(input().split())))
a = {i+1: v for i, v in enumerate(a)}
#print(a)
#print(a[1])
counter = 0
for i,j in a.items():
if i == a[j]:
#print(i,j)
counter += 1
print(counter//2) |
[
7,
15,
12,
13,
0,
13,
18,
13,
13,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
12,
2,
4,
13,
13,
17,
23,
4,
18,
4,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
18,
13,
13,
14,
2,
2,
18,
13,
13,
17,
2,
18,
13,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
13,
17,
4,
13,
13,
14,
2,
13,
17,
4,
13,
10,
12,
13
] | [
[
6,
5
],
[
11,
10
],
[
5,
14
],
[
17,
16
],
[
5,
31
],
[
35,
34
],
[
10,
38
],
[
41,
40
],
[
44,
43
],
[
10,
46
],
[
49,
48
],
[
16,
50
],
[
43,
51
],
[
70,
55
],
[
34,
56
],
[
48,
57
],
[
16,
61
],
[
48,
62
],
[
43,
63
],
[
68,
65
],
[
34,
66
],
[
43,
67
],
[
73,
70
],
[
34,
71
],
[
48,
72
],
[
76,
75
],
[
75,
79
],
[
40,
79
],
[
88,
85
]
] | [
"from sys import stdin\ndef main():\n #入力\n readline=stdin.readline\n N=int(readline())\n a=list(map(lambda x:int(x)-1,readline().split()))\n\n flags=[False]*N\n res=0\n for i in range(N):\n j=a[i]\n if flags[j]==False and a[j]==i:\n flags[i]=True\n flags[j]=True\n res+=1\n\n print(res)\n \nif __name__==\"__main__\":\n main()",
"from sys import stdin",
"def main():\n #入力\n readline=stdin.readline\n N=int(readline())\n a=list(map(lambda x:int(x)-1,readline().split()))\n\n flags=[False]*N\n res=0\n for i in range(N):\n j=a[i]\n if flags[j]==False and a[j]==i:\n flags[i]=True\n flags[j]=True\n res+=1\n\n print(res)\n ",
"main",
"readline=stdin.readline",
"readline",
"stdin.readline",
"stdin",
"readline",
"N=int(readline())",
"N",
"int(readline())",
"int",
"readline()",
"readline",
"a=list(map(lambda x:int(x)-1,readline().split()))",
"a",
"list(map(lambda x:int(x)-1,readline().split()))",
"list",
"map(lambda x:int(x)-1,readline().split())",
"map",
"lambda x:int(x)-1",
"int(x)-1",
"int(x)",
"int",
"x",
"1",
"x",
"readline().split()",
"().split",
"()",
"readline",
"split",
"flags=[False]*N",
"flags",
"[False]*N",
"[False]",
"False",
"N",
"res=0",
"res",
"0",
"for i in range(N):\n j=a[i]\n if flags[j]==False and a[j]==i:\n flags[i]=True\n flags[j]=True\n res+=1\n\n ",
"i",
"range(N)",
"range",
"N",
"j=a[i]",
"j",
"a[i]",
"a",
"i",
"if flags[j]==False and a[j]==i:\n flags[i]=True\n flags[j]=True\n res+=1\n\n ",
"flags[j]==False and a[j]==i",
"flags[j]==False",
"flags[j]",
"flags",
"j",
"False",
"a[j]==i",
"a[j]",
"a",
"j",
"i",
"flags[i]=True",
"flags[i]",
"flags",
"i",
"True",
"flags[j]=True",
"flags[j]",
"flags",
"j",
"True",
"res+=1",
"res",
"1",
"print(res)",
"print",
"res",
"if __name__==\"__main__\":\n main()",
"__name__==\"__main__\"",
"__name__",
"\"__main__\"",
"main()",
"main",
"def main():\n #入力\n readline=stdin.readline\n N=int(readline())\n a=list(map(lambda x:int(x)-1,readline().split()))\n\n flags=[False]*N\n res=0\n for i in range(N):\n j=a[i]\n if flags[j]==False and a[j]==i:\n flags[i]=True\n flags[j]=True\n res+=1\n\n print(res)\n ",
"def main():\n #入力\n readline=stdin.readline\n N=int(readline())\n a=list(map(lambda x:int(x)-1,readline().split()))\n\n flags=[False]*N\n res=0\n for i in range(N):\n j=a[i]\n if flags[j]==False and a[j]==i:\n flags[i]=True\n flags[j]=True\n res+=1\n\n print(res)\n ",
"main"
] | from sys import stdin
def main():
#入力
readline=stdin.readline
N=int(readline())
a=list(map(lambda x:int(x)-1,readline().split()))
flags=[False]*N
res=0
for i in range(N):
j=a[i]
if flags[j]==False and a[j]==i:
flags[i]=True
flags[j]=True
res+=1
print(res)
if __name__=="__main__":
main() |
[
7,
15,
13,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
18,
13,
2,
13,
17,
18,
13,
13,
28,
13,
4,
13,
13,
14,
2,
18,
13,
18,
13,
2,
13,
17,
2,
13,
17,
0,
13,
17,
0,
13,
17,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13
] | [
[
71,
4
],
[
68,
10
],
[
74,
22
],
[
80,
25
],
[
29,
28
],
[
72,
31
],
[
38,
33
],
[
75,
34
],
[
28,
36
],
[
69,
39
],
[
28,
40
],
[
43,
42
],
[
72,
45
],
[
75,
49
],
[
75,
51
],
[
42,
53
],
[
42,
56
],
[
83,
59
],
[
77,
62
],
[
78,
66
],
[
84,
66
],
[
81,
66
],
[
68,
69
],
[
71,
72
],
[
74,
75
],
[
77,
78
],
[
80,
81
],
[
83,
84
]
] | [
"import collections\nn = int(input())\na = list(map(int, input().split()))\nd = {}\nans = 0\nfor i in range(n):\n d[i + 1] = a[i]\nfor i in range(n):\n if d[d[i + 1]] == i + 1:\n ans += 1\nans //= 2\nprint(ans)",
"import collections",
"collections",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a = list(map(int, input().split()))",
"a",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"d = {}",
"d",
"{}",
"ans = 0",
"ans",
"0",
"for i in range(n):\n d[i + 1] = a[i]",
"i",
"range(n)",
"range",
"n",
"d[i + 1] = a[i]",
"d[i + 1]",
"d",
"i + 1",
"i",
"1",
"a[i]",
"a",
"i",
"for i in range(n):\n if d[d[i + 1]] == i + 1:\n ans += 1",
"i",
"range(n)",
"range",
"n",
"if d[d[i + 1]] == i + 1:\n ans += 1",
"d[d[i + 1]] == i + 1",
"d[d[i + 1]]",
"d",
"d[i + 1]",
"d",
"i + 1",
"i",
"1",
"i + 1",
"i",
"1",
"ans += 1",
"ans",
"1",
"ans //= 2",
"ans",
"2",
"print(ans)",
"print",
"ans",
"a = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a",
"n = int(input())",
"int(input())",
"n",
"d = {}",
"{}",
"d",
"ans //= 2",
"2",
"ans",
"ans = 0",
"0",
"ans",
"ans += 1",
"1",
"ans"
] | import collections
n = int(input())
a = list(map(int, input().split()))
d = {}
ans = 0
for i in range(n):
d[i + 1] = a[i]
for i in range(n):
if d[d[i + 1]] == i + 1:
ans += 1
ans //= 2
print(ans) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
2,
18,
13,
13,
17,
14,
2,
18,
13,
13,
2,
13,
17,
0,
13,
17,
4,
13,
4,
13,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
2,
13
] | [
[
51,
2
],
[
57,
8
],
[
54,
20
],
[
24,
23
],
[
52,
26
],
[
63,
28
],
[
58,
31
],
[
23,
32
],
[
58,
37
],
[
64,
38
],
[
23,
40
],
[
60,
43
],
[
61,
49
],
[
55,
49
],
[
51,
52
],
[
54,
55
],
[
57,
58
],
[
60,
61
],
[
63,
64
]
] | [
"N = int(input())\na = list(map(int, input().split()))\n\nans = 0\nfor i in range(N):\n ai = a[i]-1\n if a[ai]==i+1:\n ans += 0.5\n\nprint(int(ans))",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"a = list(map(int, input().split()))",
"a",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"ans = 0",
"ans",
"0",
"for i in range(N):\n ai = a[i]-1\n if a[ai]==i+1:\n ans += 0.5",
"i",
"range(N)",
"range",
"N",
"ai = a[i]-1",
"ai",
"a[i]-1",
"a[i]",
"a",
"i",
"1",
"if a[ai]==i+1:\n ans += 0.5",
"a[ai]==i+1",
"a[ai]",
"a",
"ai",
"i+1",
"i",
"1",
"ans += 0.5",
"ans",
"0.5",
"print(int(ans))",
"print",
"int(ans)",
"int",
"ans",
"N = int(input())",
"int(input())",
"N",
"ans = 0",
"0",
"ans",
"a = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a",
"ans += 0.5",
"0.5",
"ans",
"ai = a[i]-1",
"a[i]-1",
"ai"
] | N = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(N):
ai = a[i]-1
if a[ai]==i+1:
ans += 0.5
print(int(ans)) |
[
7,
15,
0,
13,
4,
13,
4,
13,
0,
31,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
0,
13,
17,
4,
18,
18,
13,
18,
13,
13,
13,
2,
13,
17,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13
] | [
[
60,
3
],
[
11,
9
],
[
63,
20
],
[
66,
25
],
[
29,
28
],
[
61,
31
],
[
28,
36
],
[
64,
38
],
[
28,
40
],
[
69,
43
],
[
64,
48
],
[
28,
51
],
[
28,
54
],
[
70,
58
],
[
67,
58
],
[
60,
61
],
[
63,
64
],
[
66,
67
],
[
69,
70
]
] | [
"from collections import defaultdict\n\nN=int(input())\n*A,=map(int,input().split())\n\nlike=defaultdict(set)\nans=0\nfor i in range(N):\n if A[i] in like[i+1]:\n ans += 1\n like[A[i]].add(i+1)\n \nprint(ans)",
"from collections import defaultdict",
"N=int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"*A,=map(int,input().split())",
"*A",
"A",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"like=defaultdict(set)",
"like",
"defaultdict(set)",
"defaultdict",
"set",
"ans=0",
"ans",
"0",
"for i in range(N):\n if A[i] in like[i+1]:\n ans += 1\n like[A[i]].add(i+1)\n ",
"i",
"range(N)",
"range",
"N",
"if A[i] in like[i+1]:\n ans += 1\n ",
"A[i] in like[i+1]",
"A[i]",
"A",
"i",
"like[i+1]",
"like",
"i+1",
"i",
"1",
"ans += 1",
"ans",
"1",
"like[A[i]].add(i+1)",
"[A[i]].add",
"[A[i]]",
"like",
"A[i]",
"A",
"i",
"add",
"i+1",
"i",
"1",
"print(ans)",
"print",
"ans",
"N=int(input())",
"int(input())",
"N",
"like=defaultdict(set)",
"defaultdict(set)",
"like",
"ans=0",
"0",
"ans",
"ans += 1",
"1",
"ans"
] | from collections import defaultdict
N=int(input())
*A,=map(int,input().split())
like=defaultdict(set)
ans=0
for i in range(N):
if A[i] in like[i+1]:
ans += 1
like[A[i]].add(i+1)
print(ans) |
[
7,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
18,
13,
2,
18,
13,
13,
17,
2,
13,
17,
0,
13,
17,
4,
13,
2,
13,
17,
10,
4,
13,
10,
17,
13,
10,
13,
13,
10,
17,
13
] | [
[
51,
2
],
[
10,
9
],
[
9,
18
],
[
57,
20
],
[
60,
23
],
[
27,
26
],
[
52,
29
],
[
58,
33
],
[
58,
36
],
[
26,
37
],
[
26,
40
],
[
54,
43
],
[
55,
48
],
[
61,
48
],
[
51,
52
],
[
54,
55
],
[
57,
58
],
[
60,
61
]
] | [
"n = int(input())\na = [int(s) for s in input().split()]\n\nans = 0\nfor i in range(n):\n if a[a[i]-1] == i + 1:\n ans += 1\nprint(ans // 2)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"int(s) for s in input().split()",
"for s in input().split()",
"s",
"input().split()",
"().split",
"()",
"input",
"split",
"for s in input().split()",
"int(s)",
"int",
"s",
"a = [int(s) for s in input().split()]",
"a",
"[int(s) for s in input().split()]",
"ans = 0",
"ans",
"0",
"for i in range(n):\n if a[a[i]-1] == i + 1:\n ans += 1",
"i",
"range(n)",
"range",
"n",
"if a[a[i]-1] == i + 1:\n ans += 1",
"a[a[i]-1] == i + 1",
"a[a[i]-1]",
"a",
"a[i]-1",
"a[i]",
"a",
"i",
"1",
"i + 1",
"i",
"1",
"ans += 1",
"ans",
"1",
"print(ans // 2)",
"print",
"ans // 2",
"ans",
"2",
"n = int(input())",
"int(input())",
"n",
"ans += 1",
"1",
"ans",
"a = [int(s) for s in input().split()]",
"[int(s) for s in input().split()]",
"a",
"ans = 0",
"0",
"ans"
] | n = int(input())
a = [int(s) for s in input().split()]
ans = 0
for i in range(n):
if a[a[i]-1] == i + 1:
ans += 1
print(ans // 2)
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
18,
13,
2,
18,
13,
13,
17,
2,
13,
17,
0,
13,
17,
4,
13,
2,
13,
17,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13
] | [
[
48,
2
],
[
51,
8
],
[
57,
20
],
[
24,
23
],
[
49,
26
],
[
52,
30
],
[
52,
33
],
[
23,
34
],
[
23,
37
],
[
54,
40
],
[
55,
45
],
[
58,
45
],
[
48,
49
],
[
51,
52
],
[
54,
55
],
[
57,
58
]
] | [
"N = int(input())\na = list(map(int,input().split()))\nans = 0\nfor k in range(N):\n if a[a[k]-1] == k+1:\n ans += 1\nprint(ans//2)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"a = list(map(int,input().split()))",
"a",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"ans = 0",
"ans",
"0",
"for k in range(N):\n if a[a[k]-1] == k+1:\n ans += 1",
"k",
"range(N)",
"range",
"N",
"if a[a[k]-1] == k+1:\n ans += 1",
"a[a[k]-1] == k+1",
"a[a[k]-1]",
"a",
"a[k]-1",
"a[k]",
"a",
"k",
"1",
"k+1",
"k",
"1",
"ans += 1",
"ans",
"1",
"print(ans//2)",
"print",
"ans//2",
"ans",
"2",
"N = int(input())",
"int(input())",
"N",
"a = list(map(int,input().split()))",
"list(map(int,input().split()))",
"a",
"ans += 1",
"1",
"ans",
"ans = 0",
"0",
"ans"
] | N = int(input())
a = list(map(int,input().split()))
ans = 0
for k in range(N):
if a[a[k]-1] == k+1:
ans += 1
print(ans//2)
|
[
7,
15,
13,
0,
13,
18,
13,
13,
0,
13,
12,
4,
13,
4,
13,
0,
13,
12,
4,
13,
4,
13,
13,
4,
18,
4,
18,
13,
13,
13,
0,
13,
12,
4,
18,
4,
18,
13,
13,
13,
0,
13,
4,
13,
0,
13,
4,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
2,
18,
13,
2,
18,
13,
13,
17,
17,
13,
0,
13,
17,
4,
13,
2,
13,
17,
10,
12,
13,
10,
12,
13,
10,
17,
13,
10,
18,
13,
10,
12,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13
] | [
[
86,
4
],
[
89,
9
],
[
77,
16
],
[
87,
27
],
[
80,
31
],
[
87,
37
],
[
95,
41
],
[
90,
43
],
[
98,
45
],
[
78,
47
],
[
83,
49
],
[
53,
52
],
[
96,
55
],
[
99,
60
],
[
99,
63
],
[
52,
64
],
[
52,
67
],
[
92,
69
],
[
93,
74
],
[
84,
74
],
[
77,
78
],
[
80,
81
],
[
83,
84
],
[
86,
87
],
[
89,
90
],
[
92,
93
],
[
95,
96
],
[
98,
99
]
] | [
"import sys\n\nstdin = sys.stdin\n \nri = lambda: int(rs())\nrl = lambda: list(map(int, stdin.readline().split()))\nrs = lambda: stdin.readline().rstrip() # ignore trailing spaces\n\nN = ri()\nA = rl()\nanswer = 0\nfor i in range(N):\n if A[A[i]-1]-1 == i:\n answer += 1\n\nprint(answer//2)",
"import sys",
"sys",
"stdin = sys.stdin",
"stdin",
"sys.stdin",
"sys",
"stdin",
"ri = lambda: int(rs())",
"ri",
"lambda: int(rs())",
"int(rs())",
"int",
"rs()",
"rs",
"rl = lambda: list(map(int, stdin.readline().split()))",
"rl",
"lambda: list(map(int, stdin.readline().split()))",
"list(map(int, stdin.readline().split()))",
"list",
"map(int, stdin.readline().split())",
"map",
"int",
"stdin.readline().split()",
"stdin.readline().split",
"stdin.readline()",
"stdin.readline",
"stdin",
"readline",
"split",
"rs = lambda: stdin.readline().rstrip()",
"rs",
"lambda: stdin.readline().rstrip()",
"stdin.readline().rstrip()",
"stdin.readline().rstrip",
"stdin.readline()",
"stdin.readline",
"stdin",
"readline",
"rstrip",
"N = ri()",
"N",
"ri()",
"ri",
"A = rl()",
"A",
"rl()",
"rl",
"answer = 0",
"answer",
"0",
"for i in range(N):\n if A[A[i]-1]-1 == i:\n answer += 1",
"i",
"range(N)",
"range",
"N",
"if A[A[i]-1]-1 == i:\n answer += 1",
"A[A[i]-1]-1 == i",
"A[A[i]-1]-1",
"A[A[i]-1]",
"A",
"A[i]-1",
"A[i]",
"A",
"i",
"1",
"1",
"i",
"answer += 1",
"answer",
"1",
"print(answer//2)",
"print",
"answer//2",
"answer",
"2",
"rl = lambda: list(map(int, stdin.readline().split()))",
"lambda: list(map(int, stdin.readline().split()))",
"rl",
"rs = lambda: stdin.readline().rstrip()",
"lambda: stdin.readline().rstrip()",
"rs",
"answer = 0",
"0",
"answer",
"stdin = sys.stdin",
"sys.stdin",
"stdin",
"ri = lambda: int(rs())",
"lambda: int(rs())",
"ri",
"answer += 1",
"1",
"answer",
"N = ri()",
"ri()",
"N",
"A = rl()",
"rl()",
"A"
] | import sys
stdin = sys.stdin
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip() # ignore trailing spaces
N = ri()
A = rl()
answer = 0
for i in range(N):
if A[A[i]-1]-1 == i:
answer += 1
print(answer//2)
|
[
7,
15,
13,
13,
13,
13,
13,
13,
13,
13,
15,
13,
12,
13,
12,
13,
0,
13,
4,
13,
0,
13,
4,
13,
0,
13,
17,
28,
13,
13,
4,
13,
13,
17,
14,
2,
13,
17,
9,
14,
2,
18,
13,
2,
13,
17,
13,
0,
13,
17,
0,
18,
13,
2,
13,
17,
17,
4,
13,
13,
10,
17,
13,
10,
12,
13,
10,
17,
13,
10,
12,
13,
10,
4,
13,
10,
4,
13
] | [
[
76,
17
],
[
65,
19
],
[
73,
21
],
[
71,
23
],
[
67,
25
],
[
74,
32
],
[
74,
42
],
[
61,
48
],
[
56,
51
],
[
74,
52
],
[
62,
59
],
[
68,
59
],
[
61,
62
],
[
67,
68
],
[
73,
74
],
[
76,
77
]
] | [
"import bisect,collections,copy,heapq,itertools,math,numpy,string\nimport sys\ndef I(): return int(sys.stdin.readline().rstrip())\ndef LI(): return list(map(int,sys.stdin.readline().rstrip().split()))\nN = I()\na = LI()\nans = 0\nfor i,x in enumerate(a,1):\n if x=='*':\n continue\n if a[x-1]==i:\n ans += 1\n a[x-1] = '*'\nprint(ans)",
"import bisect,collections,copy,heapq,itertools,math,numpy,string",
"bisect",
"collections",
"copy",
"heapq",
"itertools",
"math",
"numpy",
"string",
"import sys",
"sys",
"def I(): return int(sys.stdin.readline().rstrip())",
"I",
"def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))",
"LI",
"N = I()",
"N",
"I()",
"I",
"a = LI()",
"a",
"LI()",
"LI",
"ans = 0",
"ans",
"0",
"for i,x in enumerate(a,1):\n if x=='*':\n continue\n if a[x-1]==i:\n ans += 1\n a[x-1] = '*'",
"i",
"x",
"enumerate(a,1)",
"enumerate",
"a",
"1",
"if x=='*':\n continue\n ",
"x=='*'",
"x",
"'*'",
"continue",
"if a[x-1]==i:\n ans += 1\n a[x-1] = '*'",
"a[x-1]==i",
"a[x-1]",
"a",
"x-1",
"x",
"1",
"i",
"ans += 1",
"ans",
"1",
"a[x-1] = '*'",
"a[x-1]",
"a",
"x-1",
"x",
"1",
"'*'",
"print(ans)",
"print",
"ans",
"ans += 1",
"1",
"ans",
"def I(): return int(sys.stdin.readline().rstrip())",
"def I(): return int(sys.stdin.readline().rstrip())",
"I",
"ans = 0",
"0",
"ans",
"def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))",
"def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))",
"LI",
"a = LI()",
"LI()",
"a",
"N = I()",
"I()",
"N"
] | import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
a = LI()
ans = 0
for i,x in enumerate(a,1):
if x=='*':
continue
if a[x-1]==i:
ans += 1
a[x-1] = '*'
print(ans)
|
[
7,
15,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
13,
28,
13,
13,
4,
13,
13,
0,
13,
17,
0,
13,
2,
2,
4,
13,
4,
13,
13,
13,
17,
4,
13,
4,
13,
13,
13,
0,
18,
13,
13,
17,
0,
13,
17,
28,
13,
13,
4,
18,
13,
13,
14,
2,
13,
17,
0,
13,
17,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
2,
13
] | [
[
77,
3
],
[
89,
9
],
[
80,
21
],
[
90,
30
],
[
33,
32
],
[
92,
35
],
[
55,
52
],
[
81,
53
],
[
93,
54
],
[
83,
57
],
[
81,
64
],
[
86,
71
],
[
87,
75
],
[
84,
75
],
[
77,
78
],
[
80,
81
],
[
83,
84
],
[
86,
87
],
[
89,
90
],
[
92,
93
]
] | [
"from collections import defaultdict\n\nn = int(input())\nalst = list(map(int, input().split()))\ndd = defaultdict(int)\n\nfor i, num in enumerate(alst, start = 1):\n s = str(min(i, num)) + \"-\" + str(max(i, num))\n dd[s] += 1\n\nans = 0\nfor i, j in dd.items():\n if j == 2:\n ans += 1\nprint(ans)",
"from collections import defaultdict",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"alst = list(map(int, input().split()))",
"alst",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"dd = defaultdict(int)",
"dd",
"defaultdict(int)",
"defaultdict",
"int",
"for i, num in enumerate(alst, start = 1):\n s = str(min(i, num)) + \"-\" + str(max(i, num))\n dd[s] += 1",
"i",
"num",
"enumerate(alst, start = 1)",
"enumerate",
"alst",
"start = 1",
"start",
"1",
"s = str(min(i, num)) + \"-\" + str(max(i, num))",
"s",
"str(min(i, num)) + \"-\" + str(max(i, num))",
"str(min(i, num)) + \"-\"",
"str(min(i, num))",
"str",
"min(i, num)",
"min",
"i",
"num",
"\"-\"",
"str(max(i, num))",
"str",
"max(i, num)",
"max",
"i",
"num",
"dd[s] += 1",
"dd[s]",
"dd",
"s",
"1",
"ans = 0",
"ans",
"0",
"for i, j in dd.items():\n if j == 2:\n ans += 1",
"i",
"j",
"dd.items()",
"dd.items",
"dd",
"items",
"if j == 2:\n ans += 1",
"j == 2",
"j",
"2",
"ans += 1",
"ans",
"1",
"print(ans)",
"print",
"ans",
"n = int(input())",
"int(input())",
"n",
"dd = defaultdict(int)",
"defaultdict(int)",
"dd",
"ans = 0",
"0",
"ans",
"ans += 1",
"1",
"ans",
"alst = list(map(int, input().split()))",
"list(map(int, input().split()))",
"alst",
"s = str(min(i, num)) + \"-\" + str(max(i, num))",
"str(min(i, num)) + \"-\" + str(max(i, num))",
"s"
] | from collections import defaultdict
n = int(input())
alst = list(map(int, input().split()))
dd = defaultdict(int)
for i, num in enumerate(alst, start = 1):
s = str(min(i, num)) + "-" + str(max(i, num))
dd[s] += 1
ans = 0
for i, j in dd.items():
if j == 2:
ans += 1
print(ans) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
18,
13,
2,
18,
13,
13,
17,
2,
13,
17,
0,
13,
17,
4,
13,
2,
13,
17,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13
] | [
[
54,
2
],
[
48,
8
],
[
51,
20
],
[
24,
23
],
[
55,
26
],
[
49,
30
],
[
49,
33
],
[
23,
34
],
[
23,
37
],
[
57,
40
],
[
58,
45
],
[
52,
45
],
[
48,
49
],
[
51,
52
],
[
54,
55
],
[
57,
58
]
] | [
"N=int(input())\na=list(map(int,input().split()))\n\nK=0\nfor i in range(N):\n if a[a[i]-1]==i+1:\n K+=1\nprint(K//2)",
"N=int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"a=list(map(int,input().split()))",
"a",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"K=0",
"K",
"0",
"for i in range(N):\n if a[a[i]-1]==i+1:\n K+=1",
"i",
"range(N)",
"range",
"N",
"if a[a[i]-1]==i+1:\n K+=1",
"a[a[i]-1]==i+1",
"a[a[i]-1]",
"a",
"a[i]-1",
"a[i]",
"a",
"i",
"1",
"i+1",
"i",
"1",
"K+=1",
"K",
"1",
"print(K//2)",
"print",
"K//2",
"K",
"2",
"a=list(map(int,input().split()))",
"list(map(int,input().split()))",
"a",
"K=0",
"0",
"K",
"N=int(input())",
"int(input())",
"N",
"K+=1",
"1",
"K"
] | N=int(input())
a=list(map(int,input().split()))
K=0
for i in range(N):
if a[a[i]-1]==i+1:
K+=1
print(K//2) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
39,
0,
13,
39,
28,
13,
4,
13,
13,
0,
13,
39,
18,
13,
13,
2,
13,
17,
4,
18,
13,
13,
4,
18,
13,
13,
2,
2,
18,
13,
17,
13,
18,
13,
17,
4,
13,
2,
4,
13,
13,
4,
13,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
39,
13,
10,
39,
13,
10,
39,
13
] | [
[
68,
2
],
[
71,
8
],
[
80,
20
],
[
74,
23
],
[
27,
26
],
[
69,
29
],
[
77,
31
],
[
72,
34
],
[
26,
35
],
[
26,
37
],
[
78,
41
],
[
75,
41
],
[
81,
45
],
[
78,
50
],
[
75,
50
],
[
69,
52
],
[
78,
54
],
[
75,
54
],
[
81,
61
],
[
81,
66
],
[
68,
69
],
[
71,
72
],
[
74,
75
],
[
77,
78
],
[
80,
81
]
] | [
"N=int(input())\na=list(map(int,input().split()))\nl=[]\nbuf=[]\nfor i in range(N):\n buf=[a[i],i+1]\n buf.sort()\n l.append(buf[0]*N+buf[1])\nprint(len(l)-len(set(l)))\n",
"N=int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"a=list(map(int,input().split()))",
"a",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"l=[]",
"l",
"[]",
"buf=[]",
"buf",
"[]",
"for i in range(N):\n buf=[a[i],i+1]\n buf.sort()\n l.append(buf[0]*N+buf[1])",
"i",
"range(N)",
"range",
"N",
"buf=[a[i],i+1]",
"buf",
"[a[i],i+1]",
"a[i]",
"a",
"i",
"i+1",
"i",
"1",
"buf.sort()",
"buf.sort",
"buf",
"sort",
"l.append(buf[0]*N+buf[1])",
"l.append",
"l",
"append",
"buf[0]*N+buf[1]",
"buf[0]*N",
"buf[0]",
"buf",
"0",
"N",
"buf[1]",
"buf",
"1",
"print(len(l)-len(set(l)))",
"print",
"len(l)-len(set(l))",
"len(l)",
"len",
"l",
"len(set(l))",
"len",
"set(l)",
"set",
"l",
"N=int(input())",
"int(input())",
"N",
"a=list(map(int,input().split()))",
"list(map(int,input().split()))",
"a",
"buf=[]",
"[]",
"buf",
"buf=[a[i],i+1]",
"[a[i],i+1]",
"buf",
"l=[]",
"[]",
"l"
] | N=int(input())
a=list(map(int,input().split()))
l=[]
buf=[]
for i in range(N):
buf=[a[i],i+1]
buf.sort()
l.append(buf[0]*N+buf[1])
print(len(l)-len(set(l)))
|
[
7,
0,
13,
4,
13,
4,
13,
0,
31,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
0,
13,
17,
42,
2,
13,
13,
14,
2,
2,
13,
17,
18,
13,
2,
18,
13,
13,
17,
0,
13,
17,
0,
13,
17,
4,
13,
2,
13,
17,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13
] | [
[
55,
2
],
[
10,
8
],
[
58,
19
],
[
52,
22
],
[
59,
26
],
[
65,
26
],
[
56,
27
],
[
59,
31
],
[
65,
31
],
[
59,
38
],
[
65,
38
],
[
61,
41
],
[
64,
44
],
[
62,
49
],
[
53,
49
],
[
52,
53
],
[
55,
56
],
[
58,
59
],
[
61,
62
],
[
64,
65
]
] | [
"N=int(input())\n*A,=map(int,input().split())\ni=0\nans=0\nwhile i<N:\n if i+1==A[A[i]-1]:\n ans+=1\n i+=1\nprint(ans//2)",
"N=int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"*A,=map(int,input().split())",
"*A",
"A",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"i=0",
"i",
"0",
"ans=0",
"ans",
"0",
"while i<N:\n if i+1==A[A[i]-1]:\n ans+=1\n i+=1",
"i<N",
"i",
"N",
"if i+1==A[A[i]-1]:\n ans+=1\n ",
"i+1==A[A[i]-1]",
"i+1",
"i",
"1",
"A[A[i]-1]",
"A",
"A[i]-1",
"A[i]",
"A",
"i",
"1",
"ans+=1",
"ans",
"1",
"i+=1",
"i",
"1",
"print(ans//2)",
"print",
"ans//2",
"ans",
"2",
"ans=0",
"0",
"ans",
"N=int(input())",
"int(input())",
"N",
"i=0",
"0",
"i",
"ans+=1",
"1",
"ans",
"i+=1",
"1",
"i"
] | N=int(input())
*A,=map(int,input().split())
i=0
ans=0
while i<N:
if i+1==A[A[i]-1]:
ans+=1
i+=1
print(ans//2) |
[
7,
15,
13,
0,
13,
4,
13,
4,
13,
0,
13,
4,
18,
13,
13,
4,
18,
4,
13,
13,
0,
13,
18,
13,
13,
0,
13,
2,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
18,
13,
13,
14,
2,
18,
13,
13,
13,
0,
13,
17,
4,
13,
2,
13,
17,
10,
2,
13,
10,
17,
13,
10,
4,
13,
10,
18,
13,
10,
4,
13,
10,
17,
13
] | [
[
64,
4
],
[
70,
10
],
[
22,
21
],
[
58,
26
],
[
71,
28
],
[
61,
31
],
[
35,
34
],
[
65,
37
],
[
67,
39
],
[
59,
41
],
[
71,
41
],
[
34,
42
],
[
59,
46
],
[
71,
46
],
[
68,
47
],
[
34,
48
],
[
73,
50
],
[
74,
55
],
[
62,
55
],
[
58,
59
],
[
61,
62
],
[
64,
65
],
[
67,
68
],
[
70,
71
],
[
73,
74
]
] | [
"# from math import factorial,sqrt,ceil,gcd\n# from itertools import permutations as permus\n# from collections import deque,Counter\n# import re\n# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)\n# from decimal import Decimal, getcontext\n# # getcontext().prec = 1000\n# # eps = Decimal(10) ** (-100)\n\nimport numpy as np\n# import networkx as nx\n# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson\n# from scipy.sparse import csr_matrix\n# from scipy.special import comb\n\n# slist = \"abcdefghijklmnopqrstuvwxyz\"\nN = int(input())\narrA = np.array(input().split(),dtype=np.int64)\narrA = arrA -1\n\nans = 0\nfor i in range(N):\n num = arrA[i]\n if arrA[num]==i:\n ans += 1\n\nprint(ans//2)\n# print(*ans) # unpackして出力。間にスペースが入る\n# for row in board:\n# print(*row,sep=\"\") #unpackして間にスペース入れずに出力する\n# print(\"{:.10f}\".format(ans))\n# print(\"{:0=10d}\".format(ans))",
"import numpy as np",
"numpy",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"arrA = np.array(input().split(),dtype=np.int64)",
"arrA",
"np.array(input().split(),dtype=np.int64)",
"np.array",
"np",
"array",
"input().split()",
"().split",
"()",
"input",
"split",
"dtype=np.int64",
"dtype",
"np.int64",
"np",
"int64",
"arrA = arrA -1",
"arrA",
"arrA -1",
"arrA",
"1",
"ans = 0",
"ans",
"0",
"for i in range(N):\n num = arrA[i]\n if arrA[num]==i:\n ans += 1",
"i",
"range(N)",
"range",
"N",
"num = arrA[i]",
"num",
"arrA[i]",
"arrA",
"i",
"if arrA[num]==i:\n ans += 1",
"arrA[num]==i",
"arrA[num]",
"arrA",
"num",
"i",
"ans += 1",
"ans",
"1",
"print(ans//2)",
"print",
"ans//2",
"ans",
"2",
"arrA = arrA -1",
"arrA -1",
"arrA",
"ans = 0",
"0",
"ans",
"N = int(input())",
"int(input())",
"N",
"num = arrA[i]",
"arrA[i]",
"num",
"arrA = np.array(input().split(),dtype=np.int64)",
"np.array(input().split(),dtype=np.int64)",
"arrA",
"ans += 1",
"1",
"ans"
] | # from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)
import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb
# slist = "abcdefghijklmnopqrstuvwxyz"
N = int(input())
arrA = np.array(input().split(),dtype=np.int64)
arrA = arrA -1
ans = 0
for i in range(N):
num = arrA[i]
if arrA[num]==i:
ans += 1
print(ans//2)
# print(*ans) # unpackして出力。間にスペースが入る
# for row in board:
# print(*row,sep="") #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))
|
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
2,
18,
13,
2,
18,
13,
13,
17,
17,
13,
0,
13,
17,
4,
13,
2,
13,
17,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
18,
13
] | [
[
69,
4
],
[
66,
11
],
[
70,
15
],
[
60,
17
],
[
70,
26
],
[
63,
29
],
[
33,
32
],
[
67,
35
],
[
61,
40
],
[
61,
43
],
[
32,
44
],
[
32,
47
],
[
57,
49
],
[
58,
54
],
[
64,
54
],
[
57,
58
],
[
60,
61
],
[
63,
64
],
[
66,
67
],
[
69,
70
]
] | [
"# n, m, l = map(int, input().split())\n\n# list_n = list(map(int, input().split()))\n\n# n = input()\n# list = [input() for i in range(N)\n\n# list = [[i for i in range(N)] for _ in range(M)]\n\nimport sys\ninput = sys.stdin.readline\n\nN = int(input())\nA = list(map(int, input().split()))\n\nans = 0\nfor i in range(N):\n if A[A[i] - 1] - 1 == i:\n ans += 1\nprint(ans//2)",
"import sys",
"sys",
"input = sys.stdin.readline",
"input",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"A = list(map(int, input().split()))",
"A",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"ans = 0",
"ans",
"0",
"for i in range(N):\n if A[A[i] - 1] - 1 == i:\n ans += 1",
"i",
"range(N)",
"range",
"N",
"if A[A[i] - 1] - 1 == i:\n ans += 1",
"A[A[i] - 1] - 1 == i",
"A[A[i] - 1] - 1",
"A[A[i] - 1]",
"A",
"A[i] - 1",
"A[i]",
"A",
"i",
"1",
"1",
"i",
"ans += 1",
"ans",
"1",
"print(ans//2)",
"print",
"ans//2",
"ans",
"2",
"ans += 1",
"1",
"ans",
"A = list(map(int, input().split()))",
"list(map(int, input().split()))",
"A",
"ans = 0",
"0",
"ans",
"N = int(input())",
"int(input())",
"N",
"input = sys.stdin.readline",
"sys.stdin.readline",
"input"
] | # n, m, l = map(int, input().split())
# list_n = list(map(int, input().split()))
# n = input()
# list = [input() for i in range(N)
# list = [[i for i in range(N)] for _ in range(M)]
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(N):
if A[A[i] - 1] - 1 == i:
ans += 1
print(ans//2)
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
13,
2,
2,
18,
13,
2,
18,
13,
13,
17,
17,
13,
4,
13,
0,
13,
13,
4,
13,
2,
4,
13,
13,
17,
10,
4,
13,
10,
13,
13,
10,
4,
13
] | [
[
55,
2
],
[
49,
8
],
[
22,
21
],
[
56,
24
],
[
50,
28
],
[
50,
31
],
[
21,
32
],
[
21,
35
],
[
21,
37
],
[
52,
39
],
[
53,
46
],
[
49,
50
],
[
52,
53
],
[
55,
56
]
] | [
"n=int(input())\na=list(map(int,input().split()))\ncnt=[i for i in range(n) if a[a[i]-1]-1==i]\nprint(len(cnt)//2)",
"n=int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a=list(map(int,input().split()))",
"a",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"i for i in range(n) if a[a[i]-1]-1==i",
"for i in range(n) if a[a[i]-1]-1==i",
"i",
"range(n)",
"range",
"n",
"a[a[i]-1]-1==i",
"a[a[i]-1]-1",
"a[a[i]-1]",
"a",
"a[i]-1",
"a[i]",
"a",
"i",
"1",
"1",
"i",
"if a[a[i]-1]-1==i",
"i",
"cnt=[i for i in range(n) if a[a[i]-1]-1==i]",
"cnt",
"[i for i in range(n) if a[a[i]-1]-1==i]",
"print(len(cnt)//2)",
"print",
"len(cnt)//2",
"len(cnt)",
"len",
"cnt",
"2",
"a=list(map(int,input().split()))",
"list(map(int,input().split()))",
"a",
"cnt=[i for i in range(n) if a[a[i]-1]-1==i]",
"[i for i in range(n) if a[a[i]-1]-1==i]",
"cnt",
"n=int(input())",
"int(input())",
"n"
] | n=int(input())
a=list(map(int,input().split()))
cnt=[i for i in range(n) if a[a[i]-1]-1==i]
print(len(cnt)//2) |
[
7,
15,
13,
13,
13,
13,
13,
13,
13,
13,
15,
13,
12,
13,
12,
13,
0,
13,
4,
13,
0,
13,
4,
13,
0,
13,
17,
0,
13,
17,
28,
13,
13,
4,
13,
13,
17,
0,
18,
13,
13,
13,
28,
13,
13,
4,
18,
13,
13,
14,
2,
13,
39,
18,
13,
13,
0,
13,
17,
4,
13,
2,
13,
17,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
12,
13,
10,
12,
13,
10,
4,
13,
10,
17,
13
] | [
[
65,
17
],
[
75,
19
],
[
80,
21
],
[
78,
23
],
[
71,
25
],
[
83,
28
],
[
81,
35
],
[
41,
38
],
[
84,
39
],
[
84,
47
],
[
84,
54
],
[
68,
57
],
[
69,
62
],
[
72,
62
],
[
65,
66
],
[
68,
69
],
[
71,
72
],
[
80,
81
],
[
83,
84
]
] | [
"import bisect,collections,copy,heapq,itertools,math,numpy,string\nimport sys\ndef I(): return int(sys.stdin.readline().rstrip())\ndef LI(): return list(map(int,sys.stdin.readline().rstrip().split()))\nN = I()\na = LI()\ncount = 0\na_dict = {}\nfor i,x in enumerate(a,1):\n a_dict[i] = x\nfor k,v in a_dict.items():\n if k in [a_dict[v]]:\n count +=1\nprint(count//2)",
"import bisect,collections,copy,heapq,itertools,math,numpy,string",
"bisect",
"collections",
"copy",
"heapq",
"itertools",
"math",
"numpy",
"string",
"import sys",
"sys",
"def I(): return int(sys.stdin.readline().rstrip())",
"I",
"def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))",
"LI",
"N = I()",
"N",
"I()",
"I",
"a = LI()",
"a",
"LI()",
"LI",
"count = 0",
"count",
"0",
"a_dict = {}",
"a_dict",
"{}",
"for i,x in enumerate(a,1):\n a_dict[i] = x",
"i",
"x",
"enumerate(a,1)",
"enumerate",
"a",
"1",
"a_dict[i] = x",
"a_dict[i]",
"a_dict",
"i",
"x",
"for k,v in a_dict.items():\n if k in [a_dict[v]]:\n count +=1",
"k",
"v",
"a_dict.items()",
"a_dict.items",
"a_dict",
"items",
"if k in [a_dict[v]]:\n count +=1",
"k in [a_dict[v]]",
"k",
"[a_dict[v]]",
"a_dict[v]",
"a_dict",
"v",
"count +=1",
"count",
"1",
"print(count//2)",
"print",
"count//2",
"count",
"2",
"N = I()",
"I()",
"N",
"count +=1",
"1",
"count",
"count = 0",
"0",
"count",
"def I(): return int(sys.stdin.readline().rstrip())",
"def I(): return int(sys.stdin.readline().rstrip())",
"I",
"def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))",
"def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))",
"LI",
"a = LI()",
"LI()",
"a",
"a_dict = {}",
"{}",
"a_dict"
] | import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
a = LI()
count = 0
a_dict = {}
for i,x in enumerate(a,1):
a_dict[i] = x
for k,v in a_dict.items():
if k in [a_dict[v]]:
count +=1
print(count//2)
|
[
7,
15,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
4,
13,
17,
0,
13,
2,
2,
17,
17,
17,
12,
13,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
13,
2,
18,
13,
2,
18,
13,
13,
17,
17,
0,
13,
17,
4,
13,
2,
13,
17,
14,
2,
13,
17,
4,
13,
10,
18,
13,
10,
18,
13,
10,
2,
13,
10,
4,
13,
10,
12,
13,
10,
18,
13
] | [
[
107,
4
],
[
119,
13
],
[
104,
22
],
[
113,
38
],
[
110,
43
],
[
53,
52
],
[
120,
56
],
[
59,
58
],
[
120,
67
],
[
71,
70
],
[
74,
73
],
[
52,
76
],
[
73,
79
],
[
58,
82
],
[
58,
85
],
[
73,
86
],
[
91,
90
],
[
90,
95
],
[
70,
95
],
[
117,
102
],
[
104,
105
],
[
107,
108
],
[
110,
111
],
[
113,
114
],
[
119,
120
]
] | [
"import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nsys.setrecursionlimit(10 ** 8)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\ndef main():\n N = int(readline())\n A = list(map(int, readline().split()))\n ans = 0\n for i in range(N):\n if i==A[A[i]-1]-1:\n ans += 1\n print(ans//2)\n\n\nif __name__ == '__main__':\n main()",
"import sys",
"sys",
"read = sys.stdin.buffer.read",
"read",
"sys.stdin.buffer.read",
"sys.stdin.buffer",
"sys.stdin",
"sys",
"stdin",
"buffer",
"read",
"readline = sys.stdin.buffer.readline",
"readline",
"sys.stdin.buffer.readline",
"sys.stdin.buffer",
"sys.stdin",
"sys",
"stdin",
"buffer",
"readline",
"readlines = sys.stdin.buffer.readlines",
"readlines",
"sys.stdin.buffer.readlines",
"sys.stdin.buffer",
"sys.stdin",
"sys",
"stdin",
"buffer",
"readlines",
"sys.setrecursionlimit(10 ** 8)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10 ** 8",
"10",
"8",
"INF = float('inf')",
"INF",
"float('inf')",
"float",
"'inf'",
"MOD = 10 ** 9 + 7",
"MOD",
"10 ** 9 + 7",
"10 ** 9",
"10",
"9",
"7",
"def main():\n N = int(readline())\n A = list(map(int, readline().split()))\n ans = 0\n for i in range(N):\n if i==A[A[i]-1]-1:\n ans += 1\n print(ans//2)",
"main",
"N = int(readline())",
"N",
"int(readline())",
"int",
"readline()",
"readline",
"A = list(map(int, readline().split()))",
"A",
"list(map(int, readline().split()))",
"list",
"map(int, readline().split())",
"map",
"int",
"readline().split()",
"().split",
"()",
"readline",
"split",
"ans = 0",
"ans",
"0",
"for i in range(N):\n if i==A[A[i]-1]-1:\n ans += 1\n ",
"i",
"range(N)",
"range",
"N",
"if i==A[A[i]-1]-1:\n ans += 1\n ",
"i==A[A[i]-1]-1",
"i",
"A[A[i]-1]-1",
"A[A[i]-1]",
"A",
"A[i]-1",
"A[i]",
"A",
"i",
"1",
"1",
"ans += 1",
"ans",
"1",
"print(ans//2)",
"print",
"ans//2",
"ans",
"2",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"readlines = sys.stdin.buffer.readlines",
"sys.stdin.buffer.readlines",
"readlines",
"read = sys.stdin.buffer.read",
"sys.stdin.buffer.read",
"read",
"MOD = 10 ** 9 + 7",
"10 ** 9 + 7",
"MOD",
"INF = float('inf')",
"float('inf')",
"INF",
"def main():\n N = int(readline())\n A = list(map(int, readline().split()))\n ans = 0\n for i in range(N):\n if i==A[A[i]-1]-1:\n ans += 1\n print(ans//2)",
"def main():\n N = int(readline())\n A = list(map(int, readline().split()))\n ans = 0\n for i in range(N):\n if i==A[A[i]-1]-1:\n ans += 1\n print(ans//2)",
"main",
"readline = sys.stdin.buffer.readline",
"sys.stdin.buffer.readline",
"readline"
] | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
def main():
N = int(readline())
A = list(map(int, readline().split()))
ans = 0
for i in range(N):
if i==A[A[i]-1]-1:
ans += 1
print(ans//2)
if __name__ == '__main__':
main()
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
18,
13,
2,
18,
13,
13,
17,
2,
13,
17,
0,
13,
17,
4,
13,
2,
13,
17,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13
] | [
[
52,
2
],
[
55,
8
],
[
61,
20
],
[
58,
24
],
[
28,
27
],
[
53,
30
],
[
56,
34
],
[
56,
37
],
[
27,
38
],
[
27,
41
],
[
64,
44
],
[
65,
49
],
[
59,
49
],
[
52,
53
],
[
55,
56
],
[
58,
59
],
[
61,
62
],
[
64,
65
]
] | [
"N = int(input())\na = list(map(int, input().split()))\nnum = set()\nans = 0\nfor i in range(N):\n # print(a[a[i]-1], a[i])\n if a[a[i]-1] == i+1:\n ans += 1\n\nprint(ans//2)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"a = list(map(int, input().split()))",
"a",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"num = set()",
"num",
"set()",
"set",
"ans = 0",
"ans",
"0",
"for i in range(N):\n # print(a[a[i]-1], a[i])\n if a[a[i]-1] == i+1:\n ans += 1",
"i",
"range(N)",
"range",
"N",
"if a[a[i]-1] == i+1:\n ans += 1",
"a[a[i]-1] == i+1",
"a[a[i]-1]",
"a",
"a[i]-1",
"a[i]",
"a",
"i",
"1",
"i+1",
"i",
"1",
"ans += 1",
"ans",
"1",
"print(ans//2)",
"print",
"ans//2",
"ans",
"2",
"N = int(input())",
"int(input())",
"N",
"a = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a",
"ans = 0",
"0",
"ans",
"num = set()",
"set()",
"num",
"ans += 1",
"1",
"ans"
] | N = int(input())
a = list(map(int, input().split()))
num = set()
ans = 0
for i in range(N):
# print(a[a[i]-1], a[i])
if a[a[i]-1] == i+1:
ans += 1
print(ans//2)
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
4,
18,
13,
13,
17,
17,
0,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
14,
2,
13,
18,
13,
18,
13,
13,
0,
13,
17,
0,
13,
17,
4,
13,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13
] | [
[
60,
2
],
[
54,
8
],
[
55,
21
],
[
66,
26
],
[
30,
29
],
[
61,
34
],
[
29,
38
],
[
55,
40
],
[
55,
42
],
[
29,
43
],
[
63,
45
],
[
57,
48
],
[
58,
52
],
[
64,
52
],
[
67,
52
],
[
54,
55
],
[
57,
58
],
[
60,
61
],
[
63,
64
],
[
66,
67
]
] | [
"n = int(input())\na = list(map(int, input().split()))\na.insert(0, 0)\nans = 0\nfor i in range(1, n + 1):\n if i == a[a[i]]:\n ans += 1\nans //= 2\nprint(ans)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a = list(map(int, input().split()))",
"a",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a.insert(0, 0)",
"a.insert",
"a",
"insert",
"0",
"0",
"ans = 0",
"ans",
"0",
"for i in range(1, n + 1):\n if i == a[a[i]]:\n ans += 1",
"i",
"range(1, n + 1)",
"range",
"1",
"n + 1",
"n",
"1",
"if i == a[a[i]]:\n ans += 1",
"i == a[a[i]]",
"i",
"a[a[i]]",
"a",
"a[i]",
"a",
"i",
"ans += 1",
"ans",
"1",
"ans //= 2",
"ans",
"2",
"print(ans)",
"print",
"ans",
"a = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a",
"ans //= 2",
"2",
"ans",
"n = int(input())",
"int(input())",
"n",
"ans += 1",
"1",
"ans",
"ans = 0",
"0",
"ans"
] | n = int(input())
a = list(map(int, input().split()))
a.insert(0, 0)
ans = 0
for i in range(1, n + 1):
if i == a[a[i]]:
ans += 1
ans //= 2
print(ans) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
2,
39,
17,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
14,
2,
13,
18,
13,
18,
13,
13,
0,
13,
17,
0,
13,
17,
4,
13,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
2,
13
] | [
[
51,
2
],
[
63,
8
],
[
60,
23
],
[
27,
26
],
[
52,
31
],
[
26,
35
],
[
64,
37
],
[
64,
39
],
[
26,
40
],
[
54,
42
],
[
57,
45
],
[
58,
49
],
[
55,
49
],
[
61,
49
],
[
51,
52
],
[
54,
55
],
[
57,
58
],
[
60,
61
],
[
63,
64
]
] | [
"n = int(input())\na = [0] + list(map(int, input().split()))\ncnt = 0\nfor i in range(1, n + 1):\n if i == a[a[i]]:\n cnt += 1\ncnt //= 2\nprint(cnt)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a = [0] + list(map(int, input().split()))",
"a",
"[0] + list(map(int, input().split()))",
"[0]",
"0",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"cnt = 0",
"cnt",
"0",
"for i in range(1, n + 1):\n if i == a[a[i]]:\n cnt += 1",
"i",
"range(1, n + 1)",
"range",
"1",
"n + 1",
"n",
"1",
"if i == a[a[i]]:\n cnt += 1",
"i == a[a[i]]",
"i",
"a[a[i]]",
"a",
"a[i]",
"a",
"i",
"cnt += 1",
"cnt",
"1",
"cnt //= 2",
"cnt",
"2",
"print(cnt)",
"print",
"cnt",
"n = int(input())",
"int(input())",
"n",
"cnt += 1",
"1",
"cnt",
"cnt //= 2",
"2",
"cnt",
"cnt = 0",
"0",
"cnt",
"a = [0] + list(map(int, input().split()))",
"[0] + list(map(int, input().split()))",
"a"
] | n = int(input())
a = [0] + list(map(int, input().split()))
cnt = 0
for i in range(1, n + 1):
if i == a[a[i]]:
cnt += 1
cnt //= 2
print(cnt)
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
18,
13,
13,
17,
14,
2,
2,
18,
13,
2,
18,
13,
13,
17,
17,
13,
0,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
2,
18,
13,
13,
17,
17,
4,
13,
13,
10,
17,
13,
10,
4,
13,
10,
2,
13,
10,
17,
13,
10,
4,
13
] | [
[
84,
2
],
[
75,
8
],
[
78,
20
],
[
85,
24
],
[
72,
26
],
[
30,
29
],
[
85,
32
],
[
55,
35
],
[
79,
36
],
[
29,
37
],
[
76,
43
],
[
76,
46
],
[
29,
47
],
[
29,
50
],
[
81,
52
],
[
58,
55
],
[
79,
56
],
[
29,
57
],
[
67,
60
],
[
79,
61
],
[
76,
64
],
[
29,
65
],
[
82,
70
],
[
73,
70
],
[
72,
73
],
[
75,
76
],
[
78,
79
],
[
81,
82
],
[
84,
85
]
] | [
"n=int(input())\na=list(map(int,input().split()))\nflag=[0]*n\nans=0\nfor i in range(n):\n if flag[i]==0:\n if (a[a[i]-1]-1)==i:\n ans+=1\n flag[i]=1\n flag[a[i]-1]=1\nprint(ans)",
"n=int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a=list(map(int,input().split()))",
"a",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"flag=[0]*n",
"flag",
"[0]*n",
"[0]",
"0",
"n",
"ans=0",
"ans",
"0",
"for i in range(n):\n if flag[i]==0:\n if (a[a[i]-1]-1)==i:\n ans+=1\n flag[i]=1\n flag[a[i]-1]=1",
"i",
"range(n)",
"range",
"n",
"if flag[i]==0:\n if (a[a[i]-1]-1)==i:\n ans+=1\n flag[i]=1\n flag[a[i]-1]=1",
"flag[i]==0",
"flag[i]",
"flag",
"i",
"0",
"if (a[a[i]-1]-1)==i:\n ans+=1\n flag[i]=1\n flag[a[i]-1]=1",
"(a[a[i]-1]-1)==i",
"a[a[i]-1]-1",
"a[a[i]-1]",
"a",
"a[i]-1",
"a[i]",
"a",
"i",
"1",
"1",
"i",
"ans+=1",
"ans",
"1",
"flag[i]=1",
"flag[i]",
"flag",
"i",
"1",
"flag[a[i]-1]=1",
"flag[a[i]-1]",
"flag",
"a[i]-1",
"a[i]",
"a",
"i",
"1",
"1",
"print(ans)",
"print",
"ans",
"ans=0",
"0",
"ans",
"a=list(map(int,input().split()))",
"list(map(int,input().split()))",
"a",
"flag=[0]*n",
"[0]*n",
"flag",
"ans+=1",
"1",
"ans",
"n=int(input())",
"int(input())",
"n"
] | n=int(input())
a=list(map(int,input().split()))
flag=[0]*n
ans=0
for i in range(n):
if flag[i]==0:
if (a[a[i]-1]-1)==i:
ans+=1
flag[i]=1
flag[a[i]-1]=1
print(ans) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
2,
13,
17,
18,
13,
2,
18,
13,
13,
17,
0,
13,
17,
4,
13,
2,
13,
17,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13
] | [
[
57,
2
],
[
51,
8
],
[
54,
20
],
[
24,
23
],
[
58,
26
],
[
23,
30
],
[
52,
33
],
[
52,
36
],
[
23,
37
],
[
48,
40
],
[
49,
45
],
[
55,
45
],
[
48,
49
],
[
51,
52
],
[
54,
55
],
[
57,
58
]
] | [
"N = int(input())\nA = list(map(int,input().split()))\n\ncnt = 0\nfor n in range(N):\n if n+1 == A[A[n]-1]:\n cnt += 1\n\nprint(cnt//2)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"A = list(map(int,input().split()))",
"A",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"cnt = 0",
"cnt",
"0",
"for n in range(N):\n if n+1 == A[A[n]-1]:\n cnt += 1",
"n",
"range(N)",
"range",
"N",
"if n+1 == A[A[n]-1]:\n cnt += 1",
"n+1 == A[A[n]-1]",
"n+1",
"n",
"1",
"A[A[n]-1]",
"A",
"A[n]-1",
"A[n]",
"A",
"n",
"1",
"cnt += 1",
"cnt",
"1",
"print(cnt//2)",
"print",
"cnt//2",
"cnt",
"2",
"cnt += 1",
"1",
"cnt",
"A = list(map(int,input().split()))",
"list(map(int,input().split()))",
"A",
"cnt = 0",
"0",
"cnt",
"N = int(input())",
"int(input())",
"N"
] | N = int(input())
A = list(map(int,input().split()))
cnt = 0
for n in range(N):
if n+1 == A[A[n]-1]:
cnt += 1
print(cnt//2) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
4,
13,
13,
0,
13,
18,
13,
13,
14,
2,
18,
13,
2,
13,
17,
2,
13,
17,
0,
13,
17,
4,
13,
4,
13,
2,
13,
17,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
18,
13,
10,
17,
13
] | [
[
67,
2
],
[
58,
8
],
[
61,
18
],
[
59,
21
],
[
73,
23
],
[
27,
26
],
[
62,
31
],
[
70,
33
],
[
62,
35
],
[
26,
36
],
[
62,
40
],
[
71,
42
],
[
26,
45
],
[
64,
48
],
[
65,
55
],
[
74,
55
],
[
58,
59
],
[
61,
62
],
[
64,
65
],
[
67,
68
],
[
70,
71
],
[
73,
74
]
] | [
"N = int(input())\nAAA = map(int,input().split())\nAA = list(AAA)\ncount = 0\nfor i in range(len(AA)):\n a = AA[i]\n if AA[a-1] == i+1:\n count +=1\nprint(int(count/2))",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"AAA = map(int,input().split())",
"AAA",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"AA = list(AAA)",
"AA",
"list(AAA)",
"list",
"AAA",
"count = 0",
"count",
"0",
"for i in range(len(AA)):\n a = AA[i]\n if AA[a-1] == i+1:\n count +=1",
"i",
"range(len(AA))",
"range",
"len(AA)",
"len",
"AA",
"a = AA[i]",
"a",
"AA[i]",
"AA",
"i",
"if AA[a-1] == i+1:\n count +=1",
"AA[a-1] == i+1",
"AA[a-1]",
"AA",
"a-1",
"a",
"1",
"i+1",
"i",
"1",
"count +=1",
"count",
"1",
"print(int(count/2))",
"print",
"int(count/2)",
"int",
"count/2",
"count",
"2",
"AAA = map(int,input().split())",
"map(int,input().split())",
"AAA",
"AA = list(AAA)",
"list(AAA)",
"AA",
"count +=1",
"1",
"count",
"N = int(input())",
"int(input())",
"N",
"a = AA[i]",
"AA[i]",
"a",
"count = 0",
"0",
"count"
] | N = int(input())
AAA = map(int,input().split())
AA = list(AAA)
count = 0
for i in range(len(AA)):
a = AA[i]
if AA[a-1] == i+1:
count +=1
print(int(count/2)) |
[
7,
15,
13,
15,
12,
13,
0,
13,
18,
13,
13,
0,
13,
17,
0,
13,
4,
13,
17,
4,
18,
13,
13,
2,
17,
17,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
0,
13,
4,
13,
0,
13,
4,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
18,
13,
18,
13,
13,
13,
0,
13,
17,
4,
2,
2,
13,
17,
17,
4,
13,
2,
13,
17,
14,
2,
13,
17,
4,
13,
10,
12,
13
] | [
[
8,
7
],
[
13,
12
],
[
16,
15
],
[
44,
43
],
[
29,
45
],
[
48,
47
],
[
39,
49
],
[
52,
51
],
[
55,
54
],
[
43,
57
],
[
47,
61
],
[
47,
63
],
[
54,
64
],
[
54,
65
],
[
68,
67
],
[
67,
72
],
[
51,
72
],
[
67,
78
],
[
51,
78
],
[
88,
85
]
] | [
"#!/usr/bin/env python3\n\nimport sys\nfrom typing import Any, Callable, Deque, Dict, List, Mapping, Optional, Sequence, Set, Tuple, TypeVar, Union\n# import time\n# import math, cmath\n# import numpy as np\n# import scipy.sparse.csgraph as cs # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall\n# import random # random, uniform, randint, randrange, shuffle, sample\n# import string # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits\n# import re # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)\n# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).\n# from collections import deque # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()\n# from collections import defaultdict # subclass of dict. defaultdict(facroty)\n# from collections import Counter # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)\n# from datetime import date, datetime # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj\n# from datetime.datetime import strptime # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj\n# from datetime import timedelta # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.\n# from copy import copy, deepcopy # use deepcopy to copy multi-dimentional matrix without reference\n# from functools import reduce # reduce(f, iter[, init])\n# from functools import lru_cache # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)\n# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).\n# from heapq import _heapify_max, _heappop_max, _siftdown_max\n# from heapq import nlargest, nsmallest # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).\n# from itertools import count, cycle, repeat # count(start[,step]), cycle(iter), repeat(elm[,n])\n# from itertools import groupby # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]\n# from itertools import starmap # starmap(pow, [[2,5], [3,2]]) returns [32, 9]\n# from itertools import product, permutations # product(iter, repeat=n), permutations(iter[,r])\n# from itertools import combinations, combinations_with_replacement\n# from itertools import accumulate # accumulate(iter[, f])\n# from operator import itemgetter # itemgetter(1), itemgetter('key')\n# from fractions import Fraction # Fraction(a, b) => a / b ∈ Q. note: Fraction(0.1) do not returns Fraciton(1, 10). Fraction('0.1') returns Fraction(1, 10)\n\n\n\ndef main():\n Num = Union[int, float]\n mod = 1000000007 # 10^9+7\n inf = float('inf') # sys.float_info.max = 1.79e+308\n # inf = 2 ** 63 - 1 # (for fast JIT compile in PyPy) 9.22e+18\n sys.setrecursionlimit(10**6) # 1000 -> 1000000\n def input(): return sys.stdin.readline().rstrip()\n def ii(): return int(input())\n def isp(): return input().split()\n def mi(): return map(int, input().split())\n def mi_0(): return map(lambda x: int(x)-1, input().split())\n def lmi(): return list(map(int, input().split()))\n def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))\n def li(): return list(input())\n # def _heappush_max(h, item): h.append(item); _siftdown_max(h, 0, len(h)-1)\n \n \n n = ii()\n L = lmi_0()\n\n cnt = 0\n for i in range(n):\n if L[L[i]] == i:\n cnt += 1\n assert cnt % 2 == 0\n print(cnt // 2)\n\n\nif __name__ == \"__main__\":\n main()",
"import sys",
"sys",
"from typing import Any, Callable, Deque, Dict, List, Mapping, Optional, Sequence, Set, Tuple, TypeVar, Union",
"def main():\n Num = Union[int, float]\n mod = 1000000007 # 10^9+7\n inf = float('inf') # sys.float_info.max = 1.79e+308\n # inf = 2 ** 63 - 1 # (for fast JIT compile in PyPy) 9.22e+18\n sys.setrecursionlimit(10**6) # 1000 -> 1000000\n def input(): return sys.stdin.readline().rstrip()\n def ii(): return int(input())\n def isp(): return input().split()\n def mi(): return map(int, input().split())\n def mi_0(): return map(lambda x: int(x)-1, input().split())\n def lmi(): return list(map(int, input().split()))\n def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))\n def li(): return list(input())\n # def _heappush_max(h, item): h.append(item); _siftdown_max(h, 0, len(h)-1)\n \n \n n = ii()\n L = lmi_0()\n\n cnt = 0\n for i in range(n):\n if L[L[i]] == i:\n cnt += 1\n assert cnt % 2 == 0\n print(cnt // 2)",
"main",
"Num = Union[int, float]",
"Num",
"Union[int, float]",
"Union",
"int",
"mod = 1000000007",
"mod",
"1000000007",
"inf = float('inf')",
"inf",
"float('inf')",
"float",
"'inf'",
"sys.setrecursionlimit(10**6)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10**6",
"10",
"6",
"def input(): return sys.stdin.readline().rstrip()\n ",
"input",
"def ii(): return int(input())\n ",
"ii",
"def isp(): return input().split()\n ",
"isp",
"def mi(): return map(int, input().split())\n ",
"mi",
"def mi_0(): return map(lambda x: int(x)-1, input().split())\n ",
"mi_0",
"def lmi(): return list(map(int, input().split()))\n ",
"lmi",
"def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))\n ",
"lmi_0",
"def li(): return list(input())\n # def _heappush_max(h, item): h.append(item); _siftdown_max(h, 0, len(h)-1)\n \n \n ",
"li",
"n = ii()",
"n",
"ii()",
"ii",
"L = lmi_0()",
"L",
"lmi_0()",
"lmi_0",
"cnt = 0",
"cnt",
"0",
"for i in range(n):\n if L[L[i]] == i:\n cnt += 1\n ",
"i",
"range(n)",
"range",
"n",
"if L[L[i]] == i:\n cnt += 1\n ",
"L[L[i]] == i",
"L[L[i]]",
"L",
"L[i]",
"L",
"i",
"i",
"cnt += 1",
"cnt",
"1",
"assert cnt % 2 == 0",
"cnt % 2 == 0",
"cnt % 2",
"cnt",
"2",
"0",
"print(cnt // 2)",
"print",
"cnt // 2",
"cnt",
"2",
"if __name__ == \"__main__\":\n main()",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"main()",
"main",
"def main():\n Num = Union[int, float]\n mod = 1000000007 # 10^9+7\n inf = float('inf') # sys.float_info.max = 1.79e+308\n # inf = 2 ** 63 - 1 # (for fast JIT compile in PyPy) 9.22e+18\n sys.setrecursionlimit(10**6) # 1000 -> 1000000\n def input(): return sys.stdin.readline().rstrip()\n def ii(): return int(input())\n def isp(): return input().split()\n def mi(): return map(int, input().split())\n def mi_0(): return map(lambda x: int(x)-1, input().split())\n def lmi(): return list(map(int, input().split()))\n def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))\n def li(): return list(input())\n # def _heappush_max(h, item): h.append(item); _siftdown_max(h, 0, len(h)-1)\n \n \n n = ii()\n L = lmi_0()\n\n cnt = 0\n for i in range(n):\n if L[L[i]] == i:\n cnt += 1\n assert cnt % 2 == 0\n print(cnt // 2)",
"def main():\n Num = Union[int, float]\n mod = 1000000007 # 10^9+7\n inf = float('inf') # sys.float_info.max = 1.79e+308\n # inf = 2 ** 63 - 1 # (for fast JIT compile in PyPy) 9.22e+18\n sys.setrecursionlimit(10**6) # 1000 -> 1000000\n def input(): return sys.stdin.readline().rstrip()\n def ii(): return int(input())\n def isp(): return input().split()\n def mi(): return map(int, input().split())\n def mi_0(): return map(lambda x: int(x)-1, input().split())\n def lmi(): return list(map(int, input().split()))\n def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))\n def li(): return list(input())\n # def _heappush_max(h, item): h.append(item); _siftdown_max(h, 0, len(h)-1)\n \n \n n = ii()\n L = lmi_0()\n\n cnt = 0\n for i in range(n):\n if L[L[i]] == i:\n cnt += 1\n assert cnt % 2 == 0\n print(cnt // 2)",
"main"
] | #!/usr/bin/env python3
import sys
from typing import Any, Callable, Deque, Dict, List, Mapping, Optional, Sequence, Set, Tuple, TypeVar, Union
# import time
# import math, cmath
# import numpy as np
# import scipy.sparse.csgraph as cs # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random # random, uniform, randint, randrange, shuffle, sample
# import string # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict # subclass of dict. defaultdict(facroty)
# from collections import Counter # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce # reduce(f, iter[, init])
# from functools import lru_cache # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import _heapify_max, _heappop_max, _siftdown_max
# from heapq import nlargest, nsmallest # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate # accumulate(iter[, f])
# from operator import itemgetter # itemgetter(1), itemgetter('key')
# from fractions import Fraction # Fraction(a, b) => a / b ∈ Q. note: Fraction(0.1) do not returns Fraciton(1, 10). Fraction('0.1') returns Fraction(1, 10)
def main():
Num = Union[int, float]
mod = 1000000007 # 10^9+7
inf = float('inf') # sys.float_info.max = 1.79e+308
# inf = 2 ** 63 - 1 # (for fast JIT compile in PyPy) 9.22e+18
sys.setrecursionlimit(10**6) # 1000 -> 1000000
def input(): return sys.stdin.readline().rstrip()
def ii(): return int(input())
def isp(): return input().split()
def mi(): return map(int, input().split())
def mi_0(): return map(lambda x: int(x)-1, input().split())
def lmi(): return list(map(int, input().split()))
def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
def li(): return list(input())
# def _heappush_max(h, item): h.append(item); _siftdown_max(h, 0, len(h)-1)
n = ii()
L = lmi_0()
cnt = 0
for i in range(n):
if L[L[i]] == i:
cnt += 1
assert cnt % 2 == 0
print(cnt // 2)
if __name__ == "__main__":
main()
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
13,
4,
13,
13,
14,
2,
2,
13,
17,
18,
13,
2,
13,
17,
0,
13,
17,
4,
13,
2,
13,
17,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13
] | [
[
50,
2
],
[
56,
8
],
[
53,
20
],
[
57,
27
],
[
57,
34
],
[
47,
39
],
[
48,
44
],
[
54,
44
],
[
47,
48
],
[
50,
51
],
[
53,
54
],
[
56,
57
]
] | [
"a = int(input())\nl = list(map(int,input().split()))\nans = 0\nfor e , i in enumerate(l):\n\tif (e+1) == l[i-1]:\n\t\tans +=1\nprint(ans//2)",
"a = int(input())",
"a",
"int(input())",
"int",
"input()",
"input",
"l = list(map(int,input().split()))",
"l",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"ans = 0",
"ans",
"0",
"for e , i in enumerate(l):\n\tif (e+1) == l[i-1]:\n\t\tans +=1",
"e",
"i",
"enumerate(l)",
"enumerate",
"l",
"if (e+1) == l[i-1]:\n\t\tans +=1",
"(e+1) == l[i-1]",
"e+1",
"e",
"1",
"l[i-1]",
"l",
"i-1",
"i",
"1",
"ans +=1",
"ans",
"1",
"print(ans//2)",
"print",
"ans//2",
"ans",
"2",
"ans +=1",
"1",
"ans",
"a = int(input())",
"int(input())",
"a",
"ans = 0",
"0",
"ans",
"l = list(map(int,input().split()))",
"list(map(int,input().split()))",
"l"
] | a = int(input())
l = list(map(int,input().split()))
ans = 0
for e , i in enumerate(l):
if (e+1) == l[i-1]:
ans +=1
print(ans//2) |
[
7,
12,
13,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
2,
4,
13,
13,
17,
0,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
13,
18,
13,
18,
13,
13,
0,
13,
17,
4,
13,
2,
13,
17,
14,
2,
13,
17,
4,
13,
10,
12,
13
] | [
[
5,
4
],
[
12,
11
],
[
11,
21
],
[
25,
24
],
[
28,
27
],
[
31,
30
],
[
4,
33
],
[
30,
36
],
[
24,
38
],
[
24,
40
],
[
30,
41
],
[
44,
43
],
[
43,
48
],
[
27,
48
],
[
58,
55
]
] | [
"def main():\n N = int(input())\n A = [int(x)-1 for x in input().split()]\n ans = 0\n for i in range(N):\n if i==A[A[i]]:\n ans += 1\n print(ans//2)\nif __name__ == '__main__':\n main()",
"def main():\n N = int(input())\n A = [int(x)-1 for x in input().split()]\n ans = 0\n for i in range(N):\n if i==A[A[i]]:\n ans += 1\n print(ans//2)",
"main",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"int(x)-1 for x in input().split()",
"for x in input().split()",
"x",
"input().split()",
"().split",
"()",
"input",
"split",
"for x in input().split()",
"int(x)-1",
"int(x)",
"int",
"x",
"1",
"A = [int(x)-1 for x in input().split()]",
"A",
"[int(x)-1 for x in input().split()]",
"ans = 0",
"ans",
"0",
"for i in range(N):\n if i==A[A[i]]:\n ans += 1\n ",
"i",
"range(N)",
"range",
"N",
"if i==A[A[i]]:\n ans += 1\n ",
"i==A[A[i]]",
"i",
"A[A[i]]",
"A",
"A[i]",
"A",
"i",
"ans += 1",
"ans",
"1",
"print(ans//2)",
"print",
"ans//2",
"ans",
"2",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"def main():\n N = int(input())\n A = [int(x)-1 for x in input().split()]\n ans = 0\n for i in range(N):\n if i==A[A[i]]:\n ans += 1\n print(ans//2)",
"def main():\n N = int(input())\n A = [int(x)-1 for x in input().split()]\n ans = 0\n for i in range(N):\n if i==A[A[i]]:\n ans += 1\n print(ans//2)",
"main"
] | def main():
N = int(input())
A = [int(x)-1 for x in input().split()]
ans = 0
for i in range(N):
if i==A[A[i]]:
ans += 1
print(ans//2)
if __name__ == '__main__':
main() |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
18,
4,
13,
17,
13,
13,
31,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
2,
18,
13,
2,
18,
13,
13,
17,
17,
13,
0,
13,
17,
4,
13,
2,
13,
17,
10,
4,
13,
10,
17,
13,
10,
17,
13
] | [
[
46,
2
],
[
46,
15
],
[
52,
18
],
[
22,
21
],
[
47,
24
],
[
21,
33
],
[
21,
36
],
[
49,
38
],
[
50,
43
],
[
53,
43
],
[
46,
47
],
[
49,
50
],
[
52,
53
]
] | [
"#!/usr/bin/env python3\nn, *a = map(int, open(0).read().split())\nans = 0\nfor i in range(n):\n if a[a[i] - 1] - 1 == i:\n ans += 1\nprint(ans // 2)",
"n, *a = map(int, open(0).read().split())",
"n",
"map(int, open(0).read().split())",
"map",
"int",
"open(0).read().split()",
"(0).read().split",
"(0).read()",
"(0).read",
"(0)",
"open",
"0",
"read",
"split",
"*a",
"a",
"ans = 0",
"ans",
"0",
"for i in range(n):\n if a[a[i] - 1] - 1 == i:\n ans += 1",
"i",
"range(n)",
"range",
"n",
"if a[a[i] - 1] - 1 == i:\n ans += 1",
"a[a[i] - 1] - 1 == i",
"a[a[i] - 1] - 1",
"a[a[i] - 1]",
"a",
"a[i] - 1",
"a[i]",
"a",
"i",
"1",
"1",
"i",
"ans += 1",
"ans",
"1",
"print(ans // 2)",
"print",
"ans // 2",
"ans",
"2",
"n, *a = map(int, open(0).read().split())",
"map(int, open(0).read().split())",
"n",
"ans += 1",
"1",
"ans",
"ans = 0",
"0",
"ans"
] | #!/usr/bin/env python3
n, *a = map(int, open(0).read().split())
ans = 0
for i in range(n):
if a[a[i] - 1] - 1 == i:
ans += 1
print(ans // 2)
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
18,
13,
13,
17,
14,
2,
2,
18,
13,
2,
18,
13,
13,
17,
17,
13,
0,
13,
17,
0,
18,
13,
2,
18,
13,
13,
17,
17,
0,
18,
13,
13,
17,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13
] | [
[
69,
2
],
[
66,
8
],
[
75,
20
],
[
24,
23
],
[
70,
26
],
[
58,
29
],
[
67,
30
],
[
23,
31
],
[
67,
37
],
[
58,
39
],
[
67,
40
],
[
23,
41
],
[
23,
44
],
[
72,
46
],
[
56,
49
],
[
67,
50
],
[
58,
52
],
[
67,
53
],
[
23,
54
],
[
61,
58
],
[
67,
59
],
[
23,
60
],
[
73,
64
],
[
76,
64
],
[
66,
67
],
[
69,
70
],
[
72,
73
],
[
75,
76
]
] | [
"n = int(input())\na = list(map(int,input().split()))\nc = 0\n\nfor i in range(n):\n if a[i] == -1:\n pass\n elif a[a[i] - 1] - 1 == i:\n c += 1\n a[a[i] - 1] = -1\n a[i] = -1\n else:\n pass\n\nprint(c)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a = list(map(int,input().split()))",
"a",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"c = 0",
"c",
"0",
"for i in range(n):\n if a[i] == -1:\n pass\n elif a[a[i] - 1] - 1 == i:\n c += 1\n a[a[i] - 1] = -1\n a[i] = -1\n else:\n pass",
"i",
"range(n)",
"range",
"n",
"if a[i] == -1:\n pass\n elif a[a[i] - 1] - 1 == i:\n c += 1\n a[a[i] - 1] = -1\n a[i] = -1\n else:\n pass",
"a[i] == -1",
"a[i]",
"a",
"i",
"-1",
"elif a[a[i] - 1] - 1 == i:\n c += 1\n a[a[i] - 1] = -1\n a[i] = -1\n ",
"a[a[i] - 1] - 1 == i",
"a[a[i] - 1] - 1",
"a[a[i] - 1]",
"a",
"a[i] - 1",
"a[i]",
"a",
"i",
"1",
"1",
"i",
"c += 1",
"c",
"1",
"a[a[i] - 1] = -1",
"a[a[i] - 1]",
"a",
"a[i] - 1",
"a[i]",
"a",
"i",
"1",
"-1",
"a[i] = -1",
"a[i]",
"a",
"i",
"-1",
"print(c)",
"print",
"c",
"a = list(map(int,input().split()))",
"list(map(int,input().split()))",
"a",
"n = int(input())",
"int(input())",
"n",
"c += 1",
"1",
"c",
"c = 0",
"0",
"c"
] | n = int(input())
a = list(map(int,input().split()))
c = 0
for i in range(n):
if a[i] == -1:
pass
elif a[a[i] - 1] - 1 == i:
c += 1
a[a[i] - 1] = -1
a[i] = -1
else:
pass
print(c) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
18,
13,
13,
17,
9,
0,
13,
2,
18,
13,
13,
17,
14,
2,
18,
13,
13,
2,
13,
17,
0,
13,
17,
0,
18,
13,
13,
17,
4,
13,
13,
10,
4,
13,
10,
2,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13
] | [
[
61,
2
],
[
73,
8
],
[
70,
20
],
[
24,
23
],
[
62,
26
],
[
74,
30
],
[
23,
31
],
[
64,
35
],
[
74,
38
],
[
23,
39
],
[
53,
43
],
[
74,
44
],
[
65,
45
],
[
23,
47
],
[
67,
50
],
[
56,
53
],
[
74,
54
],
[
65,
55
],
[
68,
59
],
[
71,
59
],
[
61,
62
],
[
64,
65
],
[
67,
68
],
[
70,
71
],
[
73,
74
]
] | [
"N = int(input())\nlikes = list(map(int, input().split()))\ncnt = 0\nfor i in range(N):\n if likes[i] == -1:\n continue\n idx = likes[i]-1\n if likes[idx] == i + 1:\n cnt += 1\n likes[idx] = -1\nprint(cnt)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"likes = list(map(int, input().split()))",
"likes",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"cnt = 0",
"cnt",
"0",
"for i in range(N):\n if likes[i] == -1:\n continue\n idx = likes[i]-1\n if likes[idx] == i + 1:\n cnt += 1\n likes[idx] = -1",
"i",
"range(N)",
"range",
"N",
"if likes[i] == -1:\n continue\n ",
"likes[i] == -1",
"likes[i]",
"likes",
"i",
"-1",
"continue",
"idx = likes[i]-1",
"idx",
"likes[i]-1",
"likes[i]",
"likes",
"i",
"1",
"if likes[idx] == i + 1:\n cnt += 1\n likes[idx] = -1",
"likes[idx] == i + 1",
"likes[idx]",
"likes",
"idx",
"i + 1",
"i",
"1",
"cnt += 1",
"cnt",
"1",
"likes[idx] = -1",
"likes[idx]",
"likes",
"idx",
"-1",
"print(cnt)",
"print",
"cnt",
"N = int(input())",
"int(input())",
"N",
"idx = likes[i]-1",
"likes[i]-1",
"idx",
"cnt += 1",
"1",
"cnt",
"cnt = 0",
"0",
"cnt",
"likes = list(map(int, input().split()))",
"list(map(int, input().split()))",
"likes"
] | N = int(input())
likes = list(map(int, input().split()))
cnt = 0
for i in range(N):
if likes[i] == -1:
continue
idx = likes[i]-1
if likes[idx] == i + 1:
cnt += 1
likes[idx] = -1
print(cnt)
|
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
18,
13,
13,
14,
2,
2,
13,
17,
18,
13,
2,
13,
17,
4,
13,
2,
13,
17,
10,
18,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
18,
13
] | [
[
57,
4
],
[
66,
11
],
[
58,
15
],
[
60,
17
],
[
58,
26
],
[
63,
29
],
[
33,
32
],
[
67,
35
],
[
69,
37
],
[
61,
39
],
[
32,
40
],
[
32,
44
],
[
61,
47
],
[
70,
49
],
[
64,
54
],
[
57,
58
],
[
60,
61
],
[
63,
64
],
[
66,
67
],
[
69,
70
]
] | [
"import sys\ninput = sys.stdin.readline\nN = int(input())\na = list(map(int, input().split()))\nres = 0\nfor x in range(N):\n y = a[x]\n if x + 1 == a[y - 1]: res += 1\nprint(res // 2)",
"import sys",
"sys",
"input = sys.stdin.readline",
"input",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"a = list(map(int, input().split()))",
"a",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"res = 0",
"res",
"0",
"for x in range(N):\n y = a[x]\n if x + 1 == a[y - 1]: res += 1",
"x",
"range(N)",
"range",
"N",
"y = a[x]",
"y",
"a[x]",
"a",
"x",
"if x + 1 == a[y - 1]: res +=",
"x + 1 == a[y - 1]",
"x + 1",
"x",
"1",
"a[y - 1]",
"a",
"y - 1",
"y",
"1",
"print(res // 2)",
"print",
"res // 2",
"res",
"2",
"input = sys.stdin.readline",
"sys.stdin.readline",
"input",
"a = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a",
"res = 0",
"0",
"res",
"N = int(input())",
"int(input())",
"N",
"y = a[x]",
"a[x]",
"y"
] | import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
res = 0
for x in range(N):
y = a[x]
if x + 1 == a[y - 1]: res += 1
print(res // 2) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
17,
0,
13,
17,
28,
13,
4,
13,
4,
13,
13,
14,
2,
2,
2,
18,
13,
13,
17,
13,
2,
13,
2,
18,
13,
2,
18,
13,
13,
17,
17,
0,
13,
2,
13,
17,
4,
13,
13,
10,
4,
13,
10,
17,
13,
10,
2,
13,
10,
4,
13
] | [
[
59,
2
],
[
68,
8
],
[
62,
21
],
[
25,
24
],
[
69,
29
],
[
69,
35
],
[
24,
36
],
[
24,
38
],
[
24,
40
],
[
69,
43
],
[
69,
46
],
[
24,
47
],
[
65,
51
],
[
63,
53
],
[
66,
53
],
[
66,
57
],
[
63,
57
],
[
59,
60
],
[
62,
63
],
[
65,
66
],
[
68,
69
]
] | [
"N=int(input())\na=list(map(int, input().split(\" \")))\n\ncount=0\n\nfor i in range(len(a)):\n if a[i]-1>i and i==a[a[i]-1]-1:\n count=count+1\n \nprint(count)",
"N=int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"a=list(map(int, input().split(\" \")))",
"a",
"list(map(int, input().split(\" \")))",
"list",
"map(int, input().split(\" \"))",
"map",
"int",
"input().split(\" \")",
"().split",
"()",
"input",
"split",
"\" \"",
"count=0",
"count",
"0",
"for i in range(len(a)):\n if a[i]-1>i and i==a[a[i]-1]-1:\n count=count+1\n ",
"i",
"range(len(a))",
"range",
"len(a)",
"len",
"a",
"if a[i]-1>i and i==a[a[i]-1]-1:\n count=count+1\n ",
"a[i]-1>i and i==a[a[i]-1]-1",
"a[i]-1>i",
"a[i]-1",
"a[i]",
"a",
"i",
"1",
"i",
"i==a[a[i]-1]-1",
"i",
"a[a[i]-1]-1",
"a[a[i]-1]",
"a",
"a[i]-1",
"a[i]",
"a",
"i",
"1",
"1",
"count=count+1",
"count",
"count+1",
"count",
"1",
"print(count)",
"print",
"count",
"N=int(input())",
"int(input())",
"N",
"count=0",
"0",
"count",
"count=count+1",
"count+1",
"count",
"a=list(map(int, input().split(\" \")))",
"list(map(int, input().split(\" \")))",
"a"
] | N=int(input())
a=list(map(int, input().split(" ")))
count=0
for i in range(len(a)):
if a[i]-1>i and i==a[a[i]-1]-1:
count=count+1
print(count) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
4,
18,
13,
13,
17,
17,
0,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
14,
2,
18,
13,
18,
13,
13,
13,
0,
13,
17,
4,
13,
4,
13,
2,
13,
17,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13
] | [
[
58,
2
],
[
55,
8
],
[
56,
21
],
[
64,
26
],
[
30,
29
],
[
59,
34
],
[
56,
39
],
[
56,
41
],
[
29,
42
],
[
29,
43
],
[
61,
45
],
[
62,
52
],
[
65,
52
],
[
55,
56
],
[
58,
59
],
[
61,
62
],
[
64,
65
]
] | [
"N = int(input())\nA = list(map(int,input().split()))\nA.insert(0,0)\nans = 0\nfor i in range(1,N+1):\n if A[A[i]] == i:\n ans += 1\nprint(int(ans/2)) ",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"A = list(map(int,input().split()))",
"A",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"A.insert(0,0)",
"A.insert",
"A",
"insert",
"0",
"0",
"ans = 0",
"ans",
"0",
"for i in range(1,N+1):\n if A[A[i]] == i:\n ans += 1",
"i",
"range(1,N+1)",
"range",
"1",
"N+1",
"N",
"1",
"if A[A[i]] == i:\n ans += 1",
"A[A[i]] == i",
"A[A[i]]",
"A",
"A[i]",
"A",
"i",
"i",
"ans += 1",
"ans",
"1",
"print(int(ans/2))",
"print",
"int(ans/2)",
"int",
"ans/2",
"ans",
"2",
"A = list(map(int,input().split()))",
"list(map(int,input().split()))",
"A",
"N = int(input())",
"int(input())",
"N",
"ans += 1",
"1",
"ans",
"ans = 0",
"0",
"ans"
] | N = int(input())
A = list(map(int,input().split()))
A.insert(0,0)
ans = 0
for i in range(1,N+1):
if A[A[i]] == i:
ans += 1
print(int(ans/2)) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
13,
4,
13,
13,
14,
2,
2,
13,
17,
18,
13,
2,
13,
17,
0,
13,
17,
4,
13,
2,
13,
17,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13
] | [
[
53,
2
],
[
47,
8
],
[
50,
20
],
[
48,
27
],
[
48,
34
],
[
56,
39
],
[
57,
44
],
[
51,
44
],
[
47,
48
],
[
50,
51
],
[
53,
54
],
[
56,
57
]
] | [
"N = int(input())\na = list(map(int, input().split()))\n\ncount = 0\nfor index, x in enumerate(a):\n # print (x)\n if index + 1 == a[x - 1]:\n count += 1\n\nprint (count // 2)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"a = list(map(int, input().split()))",
"a",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"count = 0",
"count",
"0",
"for index, x in enumerate(a):\n # print (x)\n if index + 1 == a[x - 1]:\n count += 1",
"index",
"x",
"enumerate(a)",
"enumerate",
"a",
"if index + 1 == a[x - 1]:\n count += 1",
"index + 1 == a[x - 1]",
"index + 1",
"index",
"1",
"a[x - 1]",
"a",
"x - 1",
"x",
"1",
"count += 1",
"count",
"1",
"print (count // 2)",
"print",
"count // 2",
"count",
"2",
"a = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a",
"count = 0",
"0",
"count",
"N = int(input())",
"int(input())",
"N",
"count += 1",
"1",
"count"
] | N = int(input())
a = list(map(int, input().split()))
count = 0
for index, x in enumerate(a):
# print (x)
if index + 1 == a[x - 1]:
count += 1
print (count // 2) |
[
7,
15,
13,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
2,
4,
18,
13,
13,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
18,
13,
18,
13,
13,
13,
0,
13,
17,
4,
13,
2,
13,
17,
10,
2,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13
] | [
[
58,
4
],
[
67,
10
],
[
55,
22
],
[
68,
28
],
[
61,
31
],
[
35,
34
],
[
59,
37
],
[
56,
41
],
[
68,
41
],
[
56,
43
],
[
68,
43
],
[
34,
44
],
[
34,
45
],
[
64,
47
],
[
65,
52
],
[
62,
52
],
[
55,
56
],
[
58,
59
],
[
61,
62
],
[
64,
65
],
[
67,
68
]
] | [
"import numpy as np\nn = int(input())\na = list(map(int, input().split()))\na = np.array(a) - 1\n\nans = 0\nfor i in range(n):\n if a[a[i]] == i:\n ans += 1\n\nprint(ans // 2)",
"import numpy as np",
"numpy",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a = list(map(int, input().split()))",
"a",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a = np.array(a) - 1",
"a",
"np.array(a) - 1",
"np.array(a)",
"np.array",
"np",
"array",
"a",
"1",
"ans = 0",
"ans",
"0",
"for i in range(n):\n if a[a[i]] == i:\n ans += 1",
"i",
"range(n)",
"range",
"n",
"if a[a[i]] == i:\n ans += 1",
"a[a[i]] == i",
"a[a[i]]",
"a",
"a[i]",
"a",
"i",
"i",
"ans += 1",
"ans",
"1",
"print(ans // 2)",
"print",
"ans // 2",
"ans",
"2",
"a = np.array(a) - 1",
"np.array(a) - 1",
"a",
"n = int(input())",
"int(input())",
"n",
"ans = 0",
"0",
"ans",
"ans += 1",
"1",
"ans",
"a = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a"
] | import numpy as np
n = int(input())
a = list(map(int, input().split()))
a = np.array(a) - 1
ans = 0
for i in range(n):
if a[a[i]] == i:
ans += 1
print(ans // 2)
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
17,
0,
13,
2,
39,
17,
13,
28,
13,
13,
4,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
14,
2,
18,
13,
2,
13,
17,
17,
14,
2,
18,
13,
2,
13,
17,
13,
4,
13,
13,
10,
17,
13,
10,
4,
13,
10,
2,
13
] | [
[
54,
2
],
[
51,
8
],
[
57,
11
],
[
55,
15
],
[
58,
34
],
[
58,
42
],
[
52,
49
],
[
51,
52
],
[
54,
55
],
[
57,
58
]
] | [
"n=int(input())\nans=0\ntable=[-1]*n\nfor i,j in enumerate(list(map(int,input().split()))):\n if table[j-1]==-1:table[i]=j-1\n elif table[j-1]==i:ans+=1\nprint(ans)",
"n=int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"ans=0",
"ans",
"0",
"table=[-1]*n",
"table",
"[-1]*n",
"[-1]",
"-1",
"n",
"for i,j in enumerate(list(map(int,input().split()))):\n if table[j-1]==-1:table[i]=j-1\n elif table[j-1]==i:ans+=1",
"i",
"j",
"enumerate(list(map(int,input().split())))",
"enumerate",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"if table[j-1]==-1:table[i]=j-1\n elif table[j-1]==i:ans+=1",
"table[j-1]==-1",
"table[j-1]",
"table",
"j-1",
"j",
"1",
"-1",
"elif table[j-1]==i:an",
"table[j-1]==i",
"table[j-1]",
"table",
"j-1",
"j",
"1",
"i",
"print(ans)",
"print",
"ans",
"ans=0",
"0",
"ans",
"n=int(input())",
"int(input())",
"n",
"table=[-1]*n",
"[-1]*n",
"table"
] | n=int(input())
ans=0
table=[-1]*n
for i,j in enumerate(list(map(int,input().split()))):
if table[j-1]==-1:table[i]=j-1
elif table[j-1]==i:ans+=1
print(ans) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
28,
13,
4,
13,
13,
14,
18,
13,
13,
9,
0,
18,
13,
13,
17,
14,
2,
2,
13,
17,
18,
13,
2,
18,
13,
13,
17,
0,
18,
13,
2,
18,
13,
13,
17,
17,
0,
13,
17,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
13,
13
] | [
[
76,
2
],
[
79,
8
],
[
82,
20
],
[
25,
24
],
[
77,
27
],
[
88,
31
],
[
35,
34
],
[
77,
37
],
[
89,
40
],
[
34,
41
],
[
47,
44
],
[
89,
45
],
[
34,
46
],
[
34,
51
],
[
80,
54
],
[
80,
57
],
[
34,
58
],
[
68,
61
],
[
89,
62
],
[
80,
65
],
[
34,
66
],
[
85,
70
],
[
86,
74
],
[
83,
74
],
[
76,
77
],
[
79,
80
],
[
82,
83
],
[
85,
86
],
[
88,
89
]
] | [
"n = int(input())\na = list(map(int, input().split()))\n\ncnt = 0\nchk = [False for i in range(n)]\nfor i in range(n):\n\tif chk[i]:\n\t\tcontinue\n\tchk[i] = True\n\tif i+1 == a[a[i]-1]:\n\t\tchk[a[i]-1] = True\n\t\tcnt += 1\nprint (cnt)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a = list(map(int, input().split()))",
"a",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"cnt = 0",
"cnt",
"0",
"False for i in range(n)",
"for i in range(n)",
"i",
"range(n)",
"range",
"n",
"for i in range(n)",
"False",
"chk = [False for i in range(n)]",
"chk",
"[False for i in range(n)]",
"for i in range(n):\n\tif chk[i]:\n\t\tcontinue\n\tchk[i] = True\n\tif i+1 == a[a[i]-1]:\n\t\tchk[a[i]-1] = True\n\t\tcnt += 1",
"i",
"range(n)",
"range",
"n",
"if chk[i]:\n\t\tcontinue\n\t",
"chk[i]",
"chk",
"i",
"continue",
"chk[i] = True",
"chk[i]",
"chk",
"i",
"True",
"if i+1 == a[a[i]-1]:\n\t\tchk[a[i]-1] = True\n\t\tcnt += 1",
"i+1 == a[a[i]-1]",
"i+1",
"i",
"1",
"a[a[i]-1]",
"a",
"a[i]-1",
"a[i]",
"a",
"i",
"1",
"chk[a[i]-1] = True",
"chk[a[i]-1]",
"chk",
"a[i]-1",
"a[i]",
"a",
"i",
"1",
"True",
"cnt += 1",
"cnt",
"1",
"print (cnt)",
"print",
"cnt",
"n = int(input())",
"int(input())",
"n",
"a = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a",
"cnt = 0",
"0",
"cnt",
"cnt += 1",
"1",
"cnt",
"chk = [False for i in range(n)]",
"[False for i in range(n)]",
"chk"
] | n = int(input())
a = list(map(int, input().split()))
cnt = 0
chk = [False for i in range(n)]
for i in range(n):
if chk[i]:
continue
chk[i] = True
if i+1 == a[a[i]-1]:
chk[a[i]-1] = True
cnt += 1
print (cnt) |
[
7,
12,
13,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
2,
18,
13,
2,
18,
13,
13,
17,
17,
13,
0,
13,
17,
4,
13,
2,
13,
17,
29,
14,
2,
13,
17,
4,
13,
10,
12,
13
] | [
[
5,
4
],
[
11,
10
],
[
23,
22
],
[
26,
25
],
[
4,
28
],
[
10,
33
],
[
10,
36
],
[
25,
37
],
[
25,
40
],
[
43,
42
],
[
42,
47
],
[
22,
47
],
[
58,
55
]
] | [
"def resolve():\n n = int(input())\n a = list(map(int, input().split()))\n ans = 0\n for i in range(n):\n if a[a[i]-1]-1 == i:\n ans += 1\n print(ans//2)\n return\n\nif __name__ == \"__main__\":\n resolve()",
"def resolve():\n n = int(input())\n a = list(map(int, input().split()))\n ans = 0\n for i in range(n):\n if a[a[i]-1]-1 == i:\n ans += 1\n print(ans//2)\n return",
"resolve",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a = list(map(int, input().split()))",
"a",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"ans = 0",
"ans",
"0",
"for i in range(n):\n if a[a[i]-1]-1 == i:\n ans += 1\n ",
"i",
"range(n)",
"range",
"n",
"if a[a[i]-1]-1 == i:\n ans += 1\n ",
"a[a[i]-1]-1 == i",
"a[a[i]-1]-1",
"a[a[i]-1]",
"a",
"a[i]-1",
"a[i]",
"a",
"i",
"1",
"1",
"i",
"ans += 1",
"ans",
"1",
"print(ans//2)",
"print",
"ans//2",
"ans",
"2",
"return",
"if __name__ == \"__main__\":\n resolve()",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"resolve()",
"resolve",
"def resolve():\n n = int(input())\n a = list(map(int, input().split()))\n ans = 0\n for i in range(n):\n if a[a[i]-1]-1 == i:\n ans += 1\n print(ans//2)\n return",
"def resolve():\n n = int(input())\n a = list(map(int, input().split()))\n ans = 0\n for i in range(n):\n if a[a[i]-1]-1 == i:\n ans += 1\n print(ans//2)\n return",
"resolve"
] | def resolve():
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
if a[a[i]-1]-1 == i:
ans += 1
print(ans//2)
return
if __name__ == "__main__":
resolve()
|
[
7,
12,
13,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
13,
4,
13,
13,
0,
13,
2,
13,
17,
0,
18,
13,
13,
13,
0,
13,
17,
28,
13,
4,
18,
13,
13,
14,
2,
18,
13,
18,
13,
13,
13,
0,
13,
17,
4,
13,
2,
13,
17,
14,
2,
13,
17,
4,
13,
10,
12,
13
] | [
[
5,
4
],
[
11,
10
],
[
23,
22
],
[
10,
29
],
[
32,
31
],
[
31,
33
],
[
39,
36
],
[
22,
37
],
[
31,
38
],
[
42,
41
],
[
45,
44
],
[
22,
47
],
[
22,
52
],
[
22,
54
],
[
44,
55
],
[
44,
56
],
[
59,
58
],
[
58,
63
],
[
41,
63
],
[
73,
70
]
] | [
"\ndef main():\n n = int(input())\n a_s = list(map(int,input().split()))\n dct = {}\n for i,value in enumerate(a_s):\n i = i+1\n dct[i] = value\n counter = 0\n for key in dct.keys():\n if dct[dct[key]] == key:\n counter += 1\n print(counter//2)\n\n\nif __name__ == '__main__':\n main()",
"def main():\n n = int(input())\n a_s = list(map(int,input().split()))\n dct = {}\n for i,value in enumerate(a_s):\n i = i+1\n dct[i] = value\n counter = 0\n for key in dct.keys():\n if dct[dct[key]] == key:\n counter += 1\n print(counter//2)",
"main",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a_s = list(map(int,input().split()))",
"a_s",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"dct = {}",
"dct",
"{}",
"for i,value in enumerate(a_s):\n i = i+1\n dct[i] = value\n ",
"i",
"value",
"enumerate(a_s)",
"enumerate",
"a_s",
"i = i+1",
"i",
"i+1",
"i",
"1",
"dct[i] = value",
"dct[i]",
"dct",
"i",
"value",
"counter = 0",
"counter",
"0",
"for key in dct.keys():\n if dct[dct[key]] == key:\n counter += 1\n ",
"key",
"dct.keys()",
"dct.keys",
"dct",
"keys",
"if dct[dct[key]] == key:\n counter += 1\n ",
"dct[dct[key]] == key",
"dct[dct[key]]",
"dct",
"dct[key]",
"dct",
"key",
"key",
"counter += 1",
"counter",
"1",
"print(counter//2)",
"print",
"counter//2",
"counter",
"2",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"def main():\n n = int(input())\n a_s = list(map(int,input().split()))\n dct = {}\n for i,value in enumerate(a_s):\n i = i+1\n dct[i] = value\n counter = 0\n for key in dct.keys():\n if dct[dct[key]] == key:\n counter += 1\n print(counter//2)",
"def main():\n n = int(input())\n a_s = list(map(int,input().split()))\n dct = {}\n for i,value in enumerate(a_s):\n i = i+1\n dct[i] = value\n counter = 0\n for key in dct.keys():\n if dct[dct[key]] == key:\n counter += 1\n print(counter//2)",
"main"
] |
def main():
n = int(input())
a_s = list(map(int,input().split()))
dct = {}
for i,value in enumerate(a_s):
i = i+1
dct[i] = value
counter = 0
for key in dct.keys():
if dct[dct[key]] == key:
counter += 1
print(counter//2)
if __name__ == '__main__':
main()
|
[
7,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
0,
13,
17,
28,
13,
4,
13,
2,
13,
17,
14,
2,
13,
18,
13,
2,
18,
13,
2,
13,
17,
17,
0,
13,
17,
4,
13,
4,
13,
2,
13,
17,
10,
17,
13,
10,
17,
13,
10,
13,
13,
10,
4,
13
] | [
[
64,
2
],
[
10,
9
],
[
9,
18
],
[
61,
20
],
[
55,
23
],
[
27,
26
],
[
65,
30
],
[
26,
34
],
[
62,
36
],
[
62,
39
],
[
26,
41
],
[
58,
45
],
[
59,
52
],
[
56,
52
],
[
55,
56
],
[
58,
59
],
[
61,
62
],
[
64,
65
]
] | [
"n = int(input())\na = [int(x) for x in input().split()]\n\n# print(a)\n\n# print(n)\n# print(a)\ncount = 0\n\n\nfor i in range(n + 1):\n if(i == a[a[i - 1] - 1]):\n count += 1\n\n\nprint(int(count/2))",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"int(x) for x in input().split()",
"for x in input().split()",
"x",
"input().split()",
"().split",
"()",
"input",
"split",
"for x in input().split()",
"int(x)",
"int",
"x",
"a = [int(x) for x in input().split()]",
"a",
"[int(x) for x in input().split()]",
"count = 0",
"count",
"0",
"for i in range(n + 1):\n if(i == a[a[i - 1] - 1]):\n count += 1",
"i",
"range(n + 1)",
"range",
"n + 1",
"n",
"1",
"if(i == a[a[i - 1] - 1]):\n count += 1",
"i == a[a[i - 1] - 1]",
"i",
"a[a[i - 1] - 1]",
"a",
"a[i - 1] - 1",
"a[i - 1]",
"a",
"i - 1",
"i",
"1",
"1",
"count += 1",
"count",
"1",
"print(int(count/2))",
"print",
"int(count/2)",
"int",
"count/2",
"count",
"2",
"count = 0",
"0",
"count",
"count += 1",
"1",
"count",
"a = [int(x) for x in input().split()]",
"[int(x) for x in input().split()]",
"a",
"n = int(input())",
"int(input())",
"n"
] | n = int(input())
a = [int(x) for x in input().split()]
# print(a)
# print(n)
# print(a)
count = 0
for i in range(n + 1):
if(i == a[a[i - 1] - 1]):
count += 1
print(int(count/2))
|
[
7,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
0,
13,
17,
0,
13,
4,
13,
28,
13,
4,
13,
13,
0,
13,
2,
13,
17,
0,
13,
18,
13,
13,
14,
2,
2,
39,
13,
13,
13,
2,
39,
13,
13,
13,
0,
13,
17,
4,
18,
13,
13,
39,
13,
13,
4,
18,
13,
13,
39,
13,
13,
4,
13,
13,
10,
18,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
2,
13,
10,
17,
13
] | [
[
83,
2
],
[
10,
9
],
[
9,
18
],
[
89,
20
],
[
80,
23
],
[
86,
26
],
[
31,
30
],
[
84,
33
],
[
92,
35
],
[
30,
37
],
[
77,
40
],
[
90,
42
],
[
30,
43
],
[
87,
50
],
[
87,
55
],
[
95,
57
],
[
87,
61
],
[
87,
68
],
[
96,
75
],
[
81,
75
],
[
77,
78
],
[
80,
81
],
[
83,
84
],
[
86,
87
],
[
89,
90
],
[
92,
93
],
[
95,
96
]
] | [
"# https://atcoder.jp/contests/code-festival-2016-quala/tasks/codefestival_2016_qualA_b\n\nn = int(input())\nnums = [int(i) for i in input().split()]\n\nans = 0\nd = set()\nfor i in range(n):\n a = i + 1\n b = nums[i]\n if (a, b) in d or (b, a) in d:\n ans += 1\n else:\n d.add((a, b))\n d.add((b, a))\nprint(ans)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"int(i) for i in input().split()",
"for i in input().split()",
"i",
"input().split()",
"().split",
"()",
"input",
"split",
"for i in input().split()",
"int(i)",
"int",
"i",
"nums = [int(i) for i in input().split()]",
"nums",
"[int(i) for i in input().split()]",
"ans = 0",
"ans",
"0",
"d = set()",
"d",
"set()",
"set",
"for i in range(n):\n a = i + 1\n b = nums[i]\n if (a, b) in d or (b, a) in d:\n ans += 1\n else:\n d.add((a, b))\n d.add((b, a))",
"i",
"range(n)",
"range",
"n",
"a = i + 1",
"a",
"i + 1",
"i",
"1",
"b = nums[i]",
"b",
"nums[i]",
"nums",
"i",
"if (a, b) in d or (b, a) in d:\n ans += 1\n else:\n d.add((a, b))\n d.add((b, a))",
"(a, b) in d or (b, a) in d",
"(a, b) in d",
"(a, b)",
"a",
"b",
"d",
"(b, a) in d",
"(b, a)",
"b",
"a",
"d",
"ans += 1",
"ans",
"1",
"d.add((a, b))",
"d.add",
"d",
"add",
"(a, b)",
"a",
"b",
"d.add((b, a))",
"d.add",
"d",
"add",
"(b, a)",
"b",
"a",
"print(ans)",
"print",
"ans",
"b = nums[i]",
"nums[i]",
"b",
"ans = 0",
"0",
"ans",
"n = int(input())",
"int(input())",
"n",
"d = set()",
"set()",
"d",
"nums = [int(i) for i in input().split()]",
"[int(i) for i in input().split()]",
"nums",
"a = i + 1",
"i + 1",
"a",
"ans += 1",
"1",
"ans"
] | # https://atcoder.jp/contests/code-festival-2016-quala/tasks/codefestival_2016_qualA_b
n = int(input())
nums = [int(i) for i in input().split()]
ans = 0
d = set()
for i in range(n):
a = i + 1
b = nums[i]
if (a, b) in d or (b, a) in d:
ans += 1
else:
d.add((a, b))
d.add((b, a))
print(ans)
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
40,
18,
13,
13,
17,
2,
18,
13,
2,
18,
13,
13,
17,
2,
13,
17,
0,
13,
17,
0,
18,
13,
2,
18,
13,
13,
17,
17,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13
] | [
[
64,
2
],
[
61,
8
],
[
67,
20
],
[
24,
23
],
[
65,
26
],
[
62,
31
],
[
23,
32
],
[
62,
36
],
[
62,
39
],
[
23,
40
],
[
23,
43
],
[
70,
46
],
[
56,
49
],
[
62,
50
],
[
62,
53
],
[
23,
54
],
[
71,
59
],
[
68,
59
],
[
61,
62
],
[
64,
65
],
[
67,
68
],
[
70,
71
]
] | [
"n=int(input())\na=list(map(int,input().split()))\n\ncnt=0\nfor i in range(n):\n if a[i] >= 0 and a[a[i] - 1] == i + 1:\n cnt+=1\n a[a[i] - 1] = -1\nprint(cnt)",
"n=int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a=list(map(int,input().split()))",
"a",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"cnt=0",
"cnt",
"0",
"for i in range(n):\n if a[i] >= 0 and a[a[i] - 1] == i + 1:\n cnt+=1\n a[a[i] - 1] = -1",
"i",
"range(n)",
"range",
"n",
"if a[i] >= 0 and a[a[i] - 1] == i + 1:\n cnt+=1\n a[a[i] - 1] = -1",
"a[i] >= 0 and a[a[i] - 1] == i + 1",
"a[i] >= 0",
"a[i]",
"a",
"i",
"0",
"a[a[i] - 1] == i + 1",
"a[a[i] - 1]",
"a",
"a[i] - 1",
"a[i]",
"a",
"i",
"1",
"i + 1",
"i",
"1",
"cnt+=1",
"cnt",
"1",
"a[a[i] - 1] = -1",
"a[a[i] - 1]",
"a",
"a[i] - 1",
"a[i]",
"a",
"i",
"1",
"-1",
"print(cnt)",
"print",
"cnt",
"a=list(map(int,input().split()))",
"list(map(int,input().split()))",
"a",
"n=int(input())",
"int(input())",
"n",
"cnt=0",
"0",
"cnt",
"cnt+=1",
"1",
"cnt"
] | n=int(input())
a=list(map(int,input().split()))
cnt=0
for i in range(n):
if a[i] >= 0 and a[a[i] - 1] == i + 1:
cnt+=1
a[a[i] - 1] = -1
print(cnt) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
28,
13,
4,
13,
13,
0,
18,
13,
13,
2,
18,
13,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
18,
13,
18,
13,
13,
13,
0,
13,
17,
4,
13,
2,
13,
17,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13
] | [
[
67,
2
],
[
58,
8
],
[
21,
20
],
[
68,
23
],
[
28,
25
],
[
59,
26
],
[
20,
27
],
[
25,
29
],
[
59,
30
],
[
20,
31
],
[
64,
34
],
[
38,
37
],
[
68,
40
],
[
59,
44
],
[
25,
45
],
[
59,
46
],
[
37,
47
],
[
37,
48
],
[
61,
50
],
[
62,
55
],
[
65,
55
],
[
58,
59
],
[
61,
62
],
[
64,
65
],
[
67,
68
]
] | [
"n=int(input())\na=list(map(int,input().split()))\nfor i in range(n):\n a[i]=a[i]-1\nc=0\nfor i in range(n):\n if a[a[i]]==i:\n c+=1\nprint(c//2)",
"n=int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a=list(map(int,input().split()))",
"a",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"for i in range(n):\n a[i]=a[i]-1",
"i",
"range(n)",
"range",
"n",
"a[i]=a[i]-1",
"a[i]",
"a",
"i",
"a[i]-1",
"a[i]",
"a",
"i",
"1",
"c=0",
"c",
"0",
"for i in range(n):\n if a[a[i]]==i:\n c+=1",
"i",
"range(n)",
"range",
"n",
"if a[a[i]]==i:\n c+=1",
"a[a[i]]==i",
"a[a[i]]",
"a",
"a[i]",
"a",
"i",
"i",
"c+=1",
"c",
"1",
"print(c//2)",
"print",
"c//2",
"c",
"2",
"a=list(map(int,input().split()))",
"list(map(int,input().split()))",
"a",
"c+=1",
"1",
"c",
"c=0",
"0",
"c",
"n=int(input())",
"int(input())",
"n"
] | n=int(input())
a=list(map(int,input().split()))
for i in range(n):
a[i]=a[i]-1
c=0
for i in range(n):
if a[a[i]]==i:
c+=1
print(c//2) |
[
7,
15,
13,
4,
18,
13,
13,
2,
2,
17,
17,
17,
12,
13,
12,
13,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
18,
13,
2,
18,
13,
13,
17,
2,
13,
17,
0,
13,
17,
4,
13,
2,
13,
17,
4,
13,
10,
12,
13,
10,
12,
13
] | [
[
18,
17
],
[
69,
21
],
[
24,
23
],
[
69,
32
],
[
36,
35
],
[
39,
38
],
[
17,
41
],
[
23,
45
],
[
23,
48
],
[
38,
49
],
[
38,
52
],
[
56,
55
],
[
55,
60
],
[
35,
60
],
[
66,
63
]
] | [
"import sys\nsys.setrecursionlimit(10 ** 5 + 10)\ndef input(): return sys.stdin.readline().strip()\n\ndef resolve():\n \n n=int(input())\n A=list(map(int,input().split()))\n cnt=0\n for i in range(n):\n if A[A[i]-1]==i+1:\n cnt+=1\n print(cnt//2) \nresolve()",
"import sys",
"sys",
"sys.setrecursionlimit(10 ** 5 + 10)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10 ** 5 + 10",
"10 ** 5",
"10",
"5",
"10",
"def input(): return sys.stdin.readline().strip()",
"input",
"def resolve():\n \n n=int(input())\n A=list(map(int,input().split()))\n cnt=0\n for i in range(n):\n if A[A[i]-1]==i+1:\n cnt+=1\n print(cnt//2) ",
"resolve",
"n=int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"A=list(map(int,input().split()))",
"A",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"cnt=0",
"cnt",
"0",
"for i in range(n):\n if A[A[i]-1]==i+1:\n cnt+=1\n ",
"i",
"range(n)",
"range",
"n",
"if A[A[i]-1]==i+1:\n cnt+=1\n ",
"A[A[i]-1]==i+1",
"A[A[i]-1]",
"A",
"A[i]-1",
"A[i]",
"A",
"i",
"1",
"i+1",
"i",
"1",
"cnt+=1",
"cnt",
"1",
"print(cnt//2)",
"print",
"cnt//2",
"cnt",
"2",
"resolve()",
"resolve",
"def resolve():\n \n n=int(input())\n A=list(map(int,input().split()))\n cnt=0\n for i in range(n):\n if A[A[i]-1]==i+1:\n cnt+=1\n print(cnt//2) ",
"def resolve():\n \n n=int(input())\n A=list(map(int,input().split()))\n cnt=0\n for i in range(n):\n if A[A[i]-1]==i+1:\n cnt+=1\n print(cnt//2) ",
"resolve",
"def input(): return sys.stdin.readline().strip()",
"def input(): return sys.stdin.readline().strip()",
"input"
] | import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()
def resolve():
n=int(input())
A=list(map(int,input().split()))
cnt=0
for i in range(n):
if A[A[i]-1]==i+1:
cnt+=1
print(cnt//2)
resolve() |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
4,
13,
13,
14,
2,
18,
13,
2,
18,
13,
13,
17,
2,
13,
17,
0,
13,
17,
4,
13,
2,
13,
17,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13
] | [
[
59,
2
],
[
56,
8
],
[
53,
20
],
[
24,
23
],
[
57,
28
],
[
57,
32
],
[
57,
35
],
[
23,
36
],
[
23,
39
],
[
50,
42
],
[
51,
47
],
[
54,
47
],
[
50,
51
],
[
53,
54
],
[
56,
57
],
[
59,
60
]
] | [
"n=int(input())\na=list(map(int,input().split()))\ncnt=0\nfor i in range(len(a)):\n if a[a[i]-1]==i+1:\n cnt+=1\nprint(cnt//2)",
"n=int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a=list(map(int,input().split()))",
"a",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"cnt=0",
"cnt",
"0",
"for i in range(len(a)):\n if a[a[i]-1]==i+1:\n cnt+=1",
"i",
"range(len(a))",
"range",
"len(a)",
"len",
"a",
"if a[a[i]-1]==i+1:\n cnt+=1",
"a[a[i]-1]==i+1",
"a[a[i]-1]",
"a",
"a[i]-1",
"a[i]",
"a",
"i",
"1",
"i+1",
"i",
"1",
"cnt+=1",
"cnt",
"1",
"print(cnt//2)",
"print",
"cnt//2",
"cnt",
"2",
"cnt+=1",
"1",
"cnt",
"cnt=0",
"0",
"cnt",
"a=list(map(int,input().split()))",
"list(map(int,input().split()))",
"a",
"n=int(input())",
"int(input())",
"n"
] | n=int(input())
a=list(map(int,input().split()))
cnt=0
for i in range(len(a)):
if a[a[i]-1]==i+1:
cnt+=1
print(cnt//2) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
18,
13,
13,
0,
13,
18,
13,
2,
13,
17,
14,
2,
2,
13,
17,
13,
0,
13,
17,
0,
13,
17,
4,
13,
13,
10,
4,
13,
10,
18,
13,
10,
4,
13,
10,
18,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13
] | [
[
55,
2
],
[
61,
8
],
[
73,
20
],
[
24,
23
],
[
56,
26
],
[
58,
28
],
[
62,
30
],
[
23,
31
],
[
64,
33
],
[
62,
35
],
[
59,
37
],
[
23,
42
],
[
65,
44
],
[
70,
46
],
[
67,
49
],
[
68,
53
],
[
71,
53
],
[
74,
53
],
[
55,
56
],
[
58,
59
],
[
61,
62
],
[
64,
65
],
[
67,
68
],
[
70,
71
],
[
73,
74
]
] | [
"n=int(input())\na=list(map(int,input().split()))\nans=0\nfor i in range(n):\n b=a[i]\n c=a[b-1]\n if i+1==c:\n ans+=1\nans//=2\nprint(ans)",
"n=int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a=list(map(int,input().split()))",
"a",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"ans=0",
"ans",
"0",
"for i in range(n):\n b=a[i]\n c=a[b-1]\n if i+1==c:\n ans+=1",
"i",
"range(n)",
"range",
"n",
"b=a[i]",
"b",
"a[i]",
"a",
"i",
"c=a[b-1]",
"c",
"a[b-1]",
"a",
"b-1",
"b",
"1",
"if i+1==c:\n ans+=1",
"i+1==c",
"i+1",
"i",
"1",
"c",
"ans+=1",
"ans",
"1",
"ans//=2",
"ans",
"2",
"print(ans)",
"print",
"ans",
"n=int(input())",
"int(input())",
"n",
"b=a[i]",
"a[i]",
"b",
"a=list(map(int,input().split()))",
"list(map(int,input().split()))",
"a",
"c=a[b-1]",
"a[b-1]",
"c",
"ans//=2",
"2",
"ans",
"ans+=1",
"1",
"ans",
"ans=0",
"0",
"ans"
] | n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
b=a[i]
c=a[b-1]
if i+1==c:
ans+=1
ans//=2
print(ans)
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
2,
18,
13,
2,
18,
13,
13,
17,
2,
13,
17,
2,
18,
13,
13,
18,
13,
2,
18,
13,
2,
18,
13,
13,
17,
17,
0,
13,
17,
0,
18,
13,
2,
18,
13,
13,
17,
17,
0,
18,
13,
13,
17,
4,
13,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13
] | [
[
85,
2
],
[
76,
8
],
[
79,
20
],
[
24,
23
],
[
86,
26
],
[
77,
31
],
[
68,
33
],
[
77,
34
],
[
23,
35
],
[
23,
38
],
[
68,
41
],
[
77,
42
],
[
23,
43
],
[
77,
45
],
[
77,
48
],
[
68,
50
],
[
77,
51
],
[
23,
52
],
[
82,
56
],
[
66,
59
],
[
77,
60
],
[
68,
62
],
[
77,
63
],
[
23,
64
],
[
71,
68
],
[
77,
69
],
[
23,
70
],
[
83,
74
],
[
80,
74
],
[
76,
77
],
[
79,
80
],
[
82,
83
],
[
85,
86
]
] | [
"n=int(input())\na=list(map(int,input().split()))\nans=0\nfor i in range(n):\n if a[a[i]-1]==i+1 and a[i]==a[a[a[i]-1]-1]:\n ans+=1\n a[a[i]-1]=0\n a[i]=0\nprint(ans)",
"n=int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a=list(map(int,input().split()))",
"a",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"ans=0",
"ans",
"0",
"for i in range(n):\n if a[a[i]-1]==i+1 and a[i]==a[a[a[i]-1]-1]:\n ans+=1\n a[a[i]-1]=0\n a[i]=0",
"i",
"range(n)",
"range",
"n",
"if a[a[i]-1]==i+1 and a[i]==a[a[a[i]-1]-1]:\n ans+=1\n a[a[i]-1]=0\n a[i]=0",
"a[a[i]-1]==i+1 and a[i]==a[a[a[i]-1]-1]",
"a[a[i]-1]==i+1",
"a[a[i]-1]",
"a",
"a[i]-1",
"a[i]",
"a",
"i",
"1",
"i+1",
"i",
"1",
"a[i]==a[a[a[i]-1]-1]",
"a[i]",
"a",
"i",
"a[a[a[i]-1]-1]",
"a",
"a[a[i]-1]-1",
"a[a[i]-1]",
"a",
"a[i]-1",
"a[i]",
"a",
"i",
"1",
"1",
"ans+=1",
"ans",
"1",
"a[a[i]-1]=0",
"a[a[i]-1]",
"a",
"a[i]-1",
"a[i]",
"a",
"i",
"1",
"0",
"a[i]=0",
"a[i]",
"a",
"i",
"0",
"print(ans)",
"print",
"ans",
"a=list(map(int,input().split()))",
"list(map(int,input().split()))",
"a",
"ans=0",
"0",
"ans",
"ans+=1",
"1",
"ans",
"n=int(input())",
"int(input())",
"n"
] | n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
if a[a[i]-1]==i+1 and a[i]==a[a[a[i]-1]-1]:
ans+=1
a[a[i]-1]=0
a[i]=0
print(ans)
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
18,
13,
13,
17,
14,
2,
18,
13,
2,
18,
13,
13,
17,
2,
13,
17,
0,
13,
17,
0,
18,
13,
2,
18,
13,
13,
17,
17,
4,
13,
13,
10,
4,
13,
10,
17,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13
] | [
[
67,
2
],
[
76,
8
],
[
73,
20
],
[
68,
24
],
[
70,
26
],
[
30,
29
],
[
68,
32
],
[
74,
36
],
[
29,
37
],
[
77,
42
],
[
77,
45
],
[
29,
46
],
[
29,
49
],
[
79,
52
],
[
62,
55
],
[
74,
56
],
[
77,
59
],
[
29,
60
],
[
80,
65
],
[
71,
65
],
[
67,
68
],
[
70,
71
],
[
73,
74
],
[
76,
77
],
[
79,
80
]
] | [
"n=int(input())\na=list(map(int,input().split()))\n\npair=[0]*n\n\ncnt=0\nfor i in range(n):\n if pair[i]==0:\n if a[a[i]-1]==i+1:\n cnt+=1\n pair[a[i]-1]=1\n\nprint(cnt)",
"n=int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a=list(map(int,input().split()))",
"a",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"pair=[0]*n",
"pair",
"[0]*n",
"[0]",
"0",
"n",
"cnt=0",
"cnt",
"0",
"for i in range(n):\n if pair[i]==0:\n if a[a[i]-1]==i+1:\n cnt+=1\n pair[a[i]-1]=1",
"i",
"range(n)",
"range",
"n",
"if pair[i]==0:\n if a[a[i]-1]==i+1:\n cnt+=1\n pair[a[i]-1]=1",
"pair[i]==0",
"pair[i]",
"pair",
"i",
"0",
"if a[a[i]-1]==i+1:\n cnt+=1\n pair[a[i]-1]=1",
"a[a[i]-1]==i+1",
"a[a[i]-1]",
"a",
"a[i]-1",
"a[i]",
"a",
"i",
"1",
"i+1",
"i",
"1",
"cnt+=1",
"cnt",
"1",
"pair[a[i]-1]=1",
"pair[a[i]-1]",
"pair",
"a[i]-1",
"a[i]",
"a",
"i",
"1",
"1",
"print(cnt)",
"print",
"cnt",
"n=int(input())",
"int(input())",
"n",
"cnt=0",
"0",
"cnt",
"pair=[0]*n",
"[0]*n",
"pair",
"a=list(map(int,input().split()))",
"list(map(int,input().split()))",
"a",
"cnt+=1",
"1",
"cnt"
] | n=int(input())
a=list(map(int,input().split()))
pair=[0]*n
cnt=0
for i in range(n):
if pair[i]==0:
if a[a[i]-1]==i+1:
cnt+=1
pair[a[i]-1]=1
print(cnt) |
[
7,
15,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
0,
13,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
4,
18,
18,
13,
18,
13,
13,
13,
2,
13,
17,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
0,
13,
17,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
17,
13,
10,
17,
13
] | [
[
64,
3
],
[
11,
10
],
[
10,
19
],
[
70,
21
],
[
67,
24
],
[
73,
29
],
[
33,
32
],
[
65,
35
],
[
68,
39
],
[
71,
41
],
[
32,
42
],
[
32,
45
],
[
71,
50
],
[
32,
51
],
[
68,
53
],
[
32,
55
],
[
76,
58
],
[
77,
62
],
[
74,
62
],
[
64,
65
],
[
67,
68
],
[
70,
71
],
[
73,
74
],
[
76,
77
]
] | [
"from collections import defaultdict\nn=int(input())\na=[int(i) for i in input().split()]\n\ndic = defaultdict(set)\nans=0\nfor i in range(n):\n dic[a[i]].add(i+1)\n if a[i] in dic[i+1]:\n ans+=1\nprint(ans)",
"from collections import defaultdict",
"n=int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"int(i) for i in input().split()",
"for i in input().split()",
"i",
"input().split()",
"().split",
"()",
"input",
"split",
"for i in input().split()",
"int(i)",
"int",
"i",
"a=[int(i) for i in input().split()]",
"a",
"[int(i) for i in input().split()]",
"dic = defaultdict(set)",
"dic",
"defaultdict(set)",
"defaultdict",
"set",
"ans=0",
"ans",
"0",
"for i in range(n):\n dic[a[i]].add(i+1)\n if a[i] in dic[i+1]:\n ans+=1",
"i",
"range(n)",
"range",
"n",
"dic[a[i]].add(i+1)",
"[a[i]].add",
"[a[i]]",
"dic",
"a[i]",
"a",
"i",
"add",
"i+1",
"i",
"1",
"if a[i] in dic[i+1]:\n ans+=1",
"a[i] in dic[i+1]",
"a[i]",
"a",
"i",
"dic[i+1]",
"dic",
"i+1",
"i",
"1",
"ans+=1",
"ans",
"1",
"print(ans)",
"print",
"ans",
"n=int(input())",
"int(input())",
"n",
"dic = defaultdict(set)",
"defaultdict(set)",
"dic",
"a=[int(i) for i in input().split()]",
"[int(i) for i in input().split()]",
"a",
"ans=0",
"0",
"ans",
"ans+=1",
"1",
"ans"
] | from collections import defaultdict
n=int(input())
a=[int(i) for i in input().split()]
dic = defaultdict(set)
ans=0
for i in range(n):
dic[a[i]].add(i+1)
if a[i] in dic[i+1]:
ans+=1
print(ans) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
18,
13,
13,
14,
2,
18,
13,
2,
13,
17,
2,
13,
17,
0,
13,
17,
4,
13,
2,
13,
17,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
18,
13,
10,
17,
13
] | [
[
54,
2
],
[
51,
8
],
[
57,
20
],
[
24,
23
],
[
55,
26
],
[
60,
28
],
[
52,
30
],
[
23,
31
],
[
52,
35
],
[
61,
37
],
[
23,
40
],
[
63,
43
],
[
64,
48
],
[
58,
48
],
[
51,
52
],
[
54,
55
],
[
57,
58
],
[
60,
61
],
[
63,
64
]
] | [
"n = int(input())\nal = list(map(int, input().split()))\n\ncnt = 0\nfor i in range(n):\n j = al[i]\n if al[j-1] == i + 1:\n cnt += 1\n\nprint(cnt//2)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"al = list(map(int, input().split()))",
"al",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"cnt = 0",
"cnt",
"0",
"for i in range(n):\n j = al[i]\n if al[j-1] == i + 1:\n cnt += 1",
"i",
"range(n)",
"range",
"n",
"j = al[i]",
"j",
"al[i]",
"al",
"i",
"if al[j-1] == i + 1:\n cnt += 1",
"al[j-1] == i + 1",
"al[j-1]",
"al",
"j-1",
"j",
"1",
"i + 1",
"i",
"1",
"cnt += 1",
"cnt",
"1",
"print(cnt//2)",
"print",
"cnt//2",
"cnt",
"2",
"al = list(map(int, input().split()))",
"list(map(int, input().split()))",
"al",
"n = int(input())",
"int(input())",
"n",
"cnt = 0",
"0",
"cnt",
"j = al[i]",
"al[i]",
"j",
"cnt += 1",
"1",
"cnt"
] | n = int(input())
al = list(map(int, input().split()))
cnt = 0
for i in range(n):
j = al[i]
if al[j-1] == i + 1:
cnt += 1
print(cnt//2) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
18,
13,
13,
17,
9,
14,
2,
18,
13,
2,
18,
13,
13,
17,
2,
13,
17,
0,
18,
13,
2,
18,
13,
13,
17,
17,
0,
13,
17,
4,
13,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13
] | [
[
71,
2
],
[
65,
8
],
[
62,
20
],
[
24,
23
],
[
72,
26
],
[
66,
30
],
[
23,
31
],
[
66,
37
],
[
66,
40
],
[
23,
41
],
[
23,
44
],
[
54,
47
],
[
66,
48
],
[
66,
51
],
[
23,
52
],
[
68,
56
],
[
69,
60
],
[
63,
60
],
[
62,
63
],
[
65,
66
],
[
68,
69
],
[
71,
72
]
] | [
"n = int(input())\na = list(map(int , input().split()))\ncount = 0\nfor i in range(n):\n if a[i] == 0:\n continue\n if a[a[i] - 1] == i + 1:\n a[a[i] - 1] = 0\n count += 1\nprint(count)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a = list(map(int , input().split()))",
"a",
"list(map(int , input().split()))",
"list",
"map(int , input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"count = 0",
"count",
"0",
"for i in range(n):\n if a[i] == 0:\n continue\n if a[a[i] - 1] == i + 1:\n a[a[i] - 1] = 0\n count += 1",
"i",
"range(n)",
"range",
"n",
"if a[i] == 0:\n continue\n ",
"a[i] == 0",
"a[i]",
"a",
"i",
"0",
"continue",
"if a[a[i] - 1] == i + 1:\n a[a[i] - 1] = 0\n count += 1",
"a[a[i] - 1] == i + 1",
"a[a[i] - 1]",
"a",
"a[i] - 1",
"a[i]",
"a",
"i",
"1",
"i + 1",
"i",
"1",
"a[a[i] - 1] = 0",
"a[a[i] - 1]",
"a",
"a[i] - 1",
"a[i]",
"a",
"i",
"1",
"0",
"count += 1",
"count",
"1",
"print(count)",
"print",
"count",
"count = 0",
"0",
"count",
"a = list(map(int , input().split()))",
"list(map(int , input().split()))",
"a",
"count += 1",
"1",
"count",
"n = int(input())",
"int(input())",
"n"
] | n = int(input())
a = list(map(int , input().split()))
count = 0
for i in range(n):
if a[i] == 0:
continue
if a[a[i] - 1] == i + 1:
a[a[i] - 1] = 0
count += 1
print(count) |
[
7,
14,
2,
13,
17,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
2,
18,
13,
2,
18,
13,
13,
17,
17,
13,
0,
13,
17,
4,
13,
2,
13,
17,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13
] | [
[
61,
6
],
[
55,
12
],
[
52,
24
],
[
28,
27
],
[
62,
30
],
[
56,
35
],
[
56,
38
],
[
27,
39
],
[
27,
42
],
[
58,
44
],
[
59,
49
],
[
53,
49
],
[
52,
53
],
[
55,
56
],
[
58,
59
],
[
61,
62
]
] | [
"if __name__ == \"__main__\":\n n = int(input())\n a = list(map(int, input().split()))\n\n ans = 0\n for i in range(n):\n if a[a[i]-1] - 1 == i:\n ans += 1\n\n print(ans//2)",
"if __name__ == \"__main__\":\n n = int(input())\n a = list(map(int, input().split()))\n\n ans = 0\n for i in range(n):\n if a[a[i]-1] - 1 == i:\n ans += 1\n\n print(ans//2)",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a = list(map(int, input().split()))",
"a",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"ans = 0",
"ans",
"0",
"for i in range(n):\n if a[a[i]-1] - 1 == i:\n ans += 1\n\n ",
"i",
"range(n)",
"range",
"n",
"if a[a[i]-1] - 1 == i:\n ans += 1\n\n ",
"a[a[i]-1] - 1 == i",
"a[a[i]-1] - 1",
"a[a[i]-1]",
"a",
"a[i]-1",
"a[i]",
"a",
"i",
"1",
"1",
"i",
"ans += 1",
"ans",
"1",
"print(ans//2)",
"print",
"ans//2",
"ans",
"2",
"ans = 0",
"0",
"ans",
"a = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a",
"ans += 1",
"1",
"ans",
"n = int(input())",
"int(input())",
"n"
] | if __name__ == "__main__":
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
if a[a[i]-1] - 1 == i:
ans += 1
print(ans//2)
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
0,
13,
39,
28,
13,
4,
13,
13,
14,
2,
2,
13,
17,
18,
13,
2,
18,
13,
13,
17,
0,
13,
17,
4,
13,
4,
13,
2,
13,
17,
10,
17,
13,
10,
4,
13,
10,
39,
13,
10,
17,
13,
10,
4,
13
] | [
[
56,
2
],
[
65,
8
],
[
53,
20
],
[
59,
23
],
[
27,
26
],
[
57,
29
],
[
26,
33
],
[
66,
36
],
[
66,
39
],
[
26,
40
],
[
62,
43
],
[
63,
50
],
[
54,
50
],
[
53,
54
],
[
56,
57
],
[
59,
60
],
[
62,
63
],
[
65,
66
]
] | [
"N = int(input())\na_li = list(map(int, input().split()))\nans = 0\nchk = []\nfor i in range(N):\n if i + 1 == a_li[a_li[i] - 1] :\n ans += 1\nprint(int(ans / 2))",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"a_li = list(map(int, input().split()))",
"a_li",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"ans = 0",
"ans",
"0",
"chk = []",
"chk",
"[]",
"for i in range(N):\n if i + 1 == a_li[a_li[i] - 1] :\n ans += 1",
"i",
"range(N)",
"range",
"N",
"if i + 1 == a_li[a_li[i] - 1] :\n ans += 1",
"i + 1 == a_li[a_li[i] - 1]",
"i + 1",
"i",
"1",
"a_li[a_li[i] - 1]",
"a_li",
"a_li[i] - 1",
"a_li[i]",
"a_li",
"i",
"1",
"ans += 1",
"ans",
"1",
"print(int(ans / 2))",
"print",
"int(ans / 2)",
"int",
"ans / 2",
"ans",
"2",
"ans = 0",
"0",
"ans",
"N = int(input())",
"int(input())",
"N",
"chk = []",
"[]",
"chk",
"ans += 1",
"1",
"ans",
"a_li = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a_li"
] | N = int(input())
a_li = list(map(int, input().split()))
ans = 0
chk = []
for i in range(N):
if i + 1 == a_li[a_li[i] - 1] :
ans += 1
print(int(ans / 2))
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
2,
39,
17,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
39,
0,
13,
13,
28,
13,
4,
13,
17,
2,
13,
17,
4,
18,
18,
13,
18,
13,
13,
13,
13,
0,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
14,
2,
2,
18,
13,
13,
18,
13,
13,
2,
13,
18,
13,
18,
13,
13,
0,
13,
17,
4,
13,
2,
13,
17,
10,
17,
13,
10,
17,
13,
10,
13,
13,
10,
4,
13,
10,
2,
13
] | [
[
97,
2
],
[
100,
8
],
[
25,
24
],
[
98,
28
],
[
94,
33
],
[
37,
36
],
[
98,
41
],
[
95,
46
],
[
101,
48
],
[
36,
49
],
[
36,
51
],
[
91,
53
],
[
57,
56
],
[
98,
61
],
[
101,
67
],
[
56,
68
],
[
95,
70
],
[
56,
71
],
[
56,
73
],
[
95,
75
],
[
101,
77
],
[
56,
78
],
[
88,
80
],
[
89,
85
],
[
92,
85
],
[
88,
89
],
[
91,
92
],
[
94,
95
],
[
97,
98
],
[
100,
101
]
] | [
"n = int(input())\na = [0] + list(map(int, input().split()))\n\nG = [[] for _ in range(n + 1)]\n\nfor i in range(1, n + 1):\n\tG[a[i]].append(i)\n\ncnt = 0\nfor i in range(1, n + 1):\n\tif a[i] in G[i] and i in G[a[i]]:\n\t\tcnt += 1\nprint(cnt // 2)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a = [0] + list(map(int, input().split()))",
"a",
"[0] + list(map(int, input().split()))",
"[0]",
"0",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"[] for _ in range(n + 1)",
"for _ in range(n + 1)",
"_",
"range(n + 1)",
"range",
"n + 1",
"n",
"1",
"for _ in range(n + 1)",
"[]",
"G = [[] for _ in range(n + 1)]",
"G",
"[[] for _ in range(n + 1)]",
"for i in range(1, n + 1):\n\tG[a[i]].append(i)",
"i",
"range(1, n + 1)",
"range",
"1",
"n + 1",
"n",
"1",
"G[a[i]].append(i)",
"[a[i]].append",
"[a[i]]",
"G",
"a[i]",
"a",
"i",
"append",
"i",
"cnt = 0",
"cnt",
"0",
"for i in range(1, n + 1):\n\tif a[i] in G[i] and i in G[a[i]]:\n\t\tcnt += 1",
"i",
"range(1, n + 1)",
"range",
"1",
"n + 1",
"n",
"1",
"if a[i] in G[i] and i in G[a[i]]:\n\t\tcnt += 1",
"a[i] in G[i] and i in G[a[i]]",
"a[i] in G[i]",
"a[i]",
"a",
"i",
"G[i]",
"G",
"i",
"i in G[a[i]]",
"i",
"G[a[i]]",
"G",
"a[i]",
"a",
"i",
"cnt += 1",
"cnt",
"1",
"print(cnt // 2)",
"print",
"cnt // 2",
"cnt",
"2",
"cnt += 1",
"1",
"cnt",
"cnt = 0",
"0",
"cnt",
"G = [[] for _ in range(n + 1)]",
"[[] for _ in range(n + 1)]",
"G",
"n = int(input())",
"int(input())",
"n",
"a = [0] + list(map(int, input().split()))",
"[0] + list(map(int, input().split()))",
"a"
] | n = int(input())
a = [0] + list(map(int, input().split()))
G = [[] for _ in range(n + 1)]
for i in range(1, n + 1):
G[a[i]].append(i)
cnt = 0
for i in range(1, n + 1):
if a[i] in G[i] and i in G[a[i]]:
cnt += 1
print(cnt // 2) |
[
7,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
13,
4,
13,
13,
17,
0,
18,
13,
13,
13,
28,
13,
4,
13,
17,
2,
13,
17,
14,
2,
2,
18,
13,
13,
4,
18,
13,
13,
2,
18,
13,
18,
13,
13,
13,
0,
13,
17,
4,
13,
2,
13,
17,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
13,
13
] | [
[
80,
2
],
[
10,
9
],
[
9,
18
],
[
86,
20
],
[
83,
23
],
[
77,
26
],
[
87,
33
],
[
39,
36
],
[
84,
37
],
[
42,
41
],
[
81,
46
],
[
36,
51
],
[
84,
52
],
[
41,
53
],
[
84,
56
],
[
84,
60
],
[
36,
61
],
[
84,
62
],
[
41,
63
],
[
41,
64
],
[
74,
66
],
[
75,
71
],
[
78,
71
],
[
74,
75
],
[
77,
78
],
[
80,
81
],
[
83,
84
],
[
86,
87
]
] | [
"n = int(input())\nA = [int(x) for x in input().split()]\ndict = {}\nres = 0\nfor i, a in enumerate(A, 1):\n dict[i] = a\nfor i in range(1, n+1):\n if dict[i] in dict.keys() and dict[dict[i]] == i:\n res += 1\nprint(res // 2)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"int(x) for x in input().split()",
"for x in input().split()",
"x",
"input().split()",
"().split",
"()",
"input",
"split",
"for x in input().split()",
"int(x)",
"int",
"x",
"A = [int(x) for x in input().split()]",
"A",
"[int(x) for x in input().split()]",
"dict = {}",
"dict",
"{}",
"res = 0",
"res",
"0",
"for i, a in enumerate(A, 1):\n dict[i] = a",
"i",
"a",
"enumerate(A, 1)",
"enumerate",
"A",
"1",
"dict[i] = a",
"dict[i]",
"dict",
"i",
"a",
"for i in range(1, n+1):\n if dict[i] in dict.keys() and dict[dict[i]] == i:\n res += 1",
"i",
"range(1, n+1)",
"range",
"1",
"n+1",
"n",
"1",
"if dict[i] in dict.keys() and dict[dict[i]] == i:\n res += 1",
"dict[i] in dict.keys() and dict[dict[i]] == i",
"dict[i] in dict.keys()",
"dict[i]",
"dict",
"i",
"dict.keys()",
"dict.keys",
"dict",
"keys",
"dict[dict[i]] == i",
"dict[dict[i]]",
"dict",
"dict[i]",
"dict",
"i",
"i",
"res += 1",
"res",
"1",
"print(res // 2)",
"print",
"res // 2",
"res",
"2",
"res += 1",
"1",
"res",
"res = 0",
"0",
"res",
"n = int(input())",
"int(input())",
"n",
"dict = {}",
"{}",
"dict",
"A = [int(x) for x in input().split()]",
"[int(x) for x in input().split()]",
"A"
] | n = int(input())
A = [int(x) for x in input().split()]
dict = {}
res = 0
for i, a in enumerate(A, 1):
dict[i] = a
for i in range(1, n+1):
if dict[i] in dict.keys() and dict[dict[i]] == i:
res += 1
print(res // 2) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
13,
4,
13,
13,
14,
2,
13,
2,
18,
13,
2,
13,
17,
17,
0,
13,
17,
4,
13,
2,
13,
17,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13
] | [
[
56,
2
],
[
50,
8
],
[
47,
20
],
[
51,
27
],
[
51,
33
],
[
53,
39
],
[
54,
44
],
[
48,
44
],
[
47,
48
],
[
50,
51
],
[
53,
54
],
[
56,
57
]
] | [
"N=int(input())\nA=list(map(int,input().split()))\ncnt=0\nfor idx,i in enumerate(A):\n if idx==A[i-1]-1:\n cnt+=1\nprint(cnt//2)\n",
"N=int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"A=list(map(int,input().split()))",
"A",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"cnt=0",
"cnt",
"0",
"for idx,i in enumerate(A):\n if idx==A[i-1]-1:\n cnt+=1",
"idx",
"i",
"enumerate(A)",
"enumerate",
"A",
"if idx==A[i-1]-1:\n cnt+=1",
"idx==A[i-1]-1",
"idx",
"A[i-1]-1",
"A[i-1]",
"A",
"i-1",
"i",
"1",
"1",
"cnt+=1",
"cnt",
"1",
"print(cnt//2)",
"print",
"cnt//2",
"cnt",
"2",
"cnt=0",
"0",
"cnt",
"A=list(map(int,input().split()))",
"list(map(int,input().split()))",
"A",
"cnt+=1",
"1",
"cnt",
"N=int(input())",
"int(input())",
"N"
] | N=int(input())
A=list(map(int,input().split()))
cnt=0
for idx,i in enumerate(A):
if idx==A[i-1]-1:
cnt+=1
print(cnt//2)
|
[
7,
15,
13,
12,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
4,
13,
4,
13,
0,
13,
17,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
28,
13,
13,
4,
13,
13,
14,
2,
18,
13,
2,
13,
17,
2,
13,
17,
4,
13,
2,
13,
17,
29,
17,
14,
2,
13,
17,
4,
13,
10,
12,
13
] | [
[
7,
6
],
[
14,
13
],
[
6,
17
],
[
20,
19
],
[
24,
23
],
[
6,
27
],
[
23,
32
],
[
35,
34
],
[
34,
41
],
[
34,
45
],
[
19,
55
],
[
67,
64
]
] | [
"import sys\n\ndef solve():\n input = sys.stdin.readline\n N = int(input())\n pair = 0\n A = [int(a) for a in input().split()]\n for i, a in enumerate(A):\n if A[a-1] == i + 1: pair += 1\n print(pair // 2)\n\n return 0\n\nif __name__ ==\"__main__\":\n solve()",
"import sys",
"sys",
"def solve():\n input = sys.stdin.readline\n N = int(input())\n pair = 0\n A = [int(a) for a in input().split()]\n for i, a in enumerate(A):\n if A[a-1] == i + 1: pair += 1\n print(pair // 2)\n\n return 0",
"solve",
"input = sys.stdin.readline",
"input",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"pair = 0",
"pair",
"0",
"int(a) for a in input().split()",
"for a in input().split()",
"a",
"input().split()",
"().split",
"()",
"input",
"split",
"for a in input().split()",
"int(a)",
"int",
"a",
"A = [int(a) for a in input().split()]",
"A",
"[int(a) for a in input().split()]",
"for i, a in enumerate(A):\n if A[a-1] == i + 1: pair += 1\n ",
"i",
"a",
"enumerate(A)",
"enumerate",
"A",
"if A[a-1] == i + 1: pair += 1\n ",
"A[a-1] == i + 1",
"A[a-1]",
"A",
"a-1",
"a",
"1",
"i + 1",
"i",
"1",
"print(pair // 2)",
"print",
"pair // 2",
"pair",
"2",
"return 0",
"0",
"if __name__ ==\"__main__\":\n solve()",
"__name__ ==\"__main__\"",
"__name__",
"\"__main__\"",
"solve()",
"solve",
"def solve():\n input = sys.stdin.readline\n N = int(input())\n pair = 0\n A = [int(a) for a in input().split()]\n for i, a in enumerate(A):\n if A[a-1] == i + 1: pair += 1\n print(pair // 2)\n\n return 0",
"def solve():\n input = sys.stdin.readline\n N = int(input())\n pair = 0\n A = [int(a) for a in input().split()]\n for i, a in enumerate(A):\n if A[a-1] == i + 1: pair += 1\n print(pair // 2)\n\n return 0",
"solve"
] | import sys
def solve():
input = sys.stdin.readline
N = int(input())
pair = 0
A = [int(a) for a in input().split()]
for i, a in enumerate(A):
if A[a-1] == i + 1: pair += 1
print(pair // 2)
return 0
if __name__ =="__main__":
solve() |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
0,
13,
18,
13,
2,
13,
17,
14,
2,
2,
13,
13,
2,
18,
13,
2,
13,
17,
13,
0,
13,
17,
4,
13,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
18,
13
] | [
[
65,
2
],
[
62,
8
],
[
59,
20
],
[
24,
23
],
[
66,
28
],
[
68,
31
],
[
63,
33
],
[
23,
35
],
[
69,
40
],
[
23,
41
],
[
63,
44
],
[
69,
46
],
[
23,
48
],
[
56,
50
],
[
57,
54
],
[
60,
54
],
[
56,
57
],
[
59,
60
],
[
62,
63
],
[
65,
66
],
[
68,
69
]
] | [
"N = int(input())\nA = list(map(int, input().split()))\nans = 0\nfor i in range(1, N+1):\n j = A[i-1]\n if j > i and A[j-1] == i:\n ans += 1\nprint(ans)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"A = list(map(int, input().split()))",
"A",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"ans = 0",
"ans",
"0",
"for i in range(1, N+1):\n j = A[i-1]\n if j > i and A[j-1] == i:\n ans += 1",
"i",
"range(1, N+1)",
"range",
"1",
"N+1",
"N",
"1",
"j = A[i-1]",
"j",
"A[i-1]",
"A",
"i-1",
"i",
"1",
"if j > i and A[j-1] == i:\n ans += 1",
"j > i and A[j-1] == i",
"j > i",
"j",
"i",
"A[j-1] == i",
"A[j-1]",
"A",
"j-1",
"j",
"1",
"i",
"ans += 1",
"ans",
"1",
"print(ans)",
"print",
"ans",
"ans += 1",
"1",
"ans",
"ans = 0",
"0",
"ans",
"A = list(map(int, input().split()))",
"list(map(int, input().split()))",
"A",
"N = int(input())",
"int(input())",
"N",
"j = A[i-1]",
"A[i-1]",
"j"
] | N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(1, N+1):
j = A[i-1]
if j > i and A[j-1] == i:
ans += 1
print(ans) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.