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, 13, 13, 4, 17, 0, 13, 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, 14, 2, 18, 13, 13, 17, 0, 13, 17, 0, 18, 13, 13, 17, 0, 18, 13, 2, 13, 17, 17, 4, 13, 13, 10, 13, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 83, 2 ], [ 10, 9 ], [ 84, 12 ], [ 74, 16 ], [ 86, 19 ], [ 77, 31 ], [ 87, 38 ], [ 87, 45 ], [ 59, 51 ], [ 75, 52 ], [ 80, 56 ], [ 62, 59 ], [ 75, 60 ], [ 69, 64 ], [ 75, 65 ], [ 81, 72 ], [ 78, 72 ], [ 74, 75 ], [ 77, 78 ], [ 80, 81 ], [ 83, 84 ], [ 86, 87 ] ]
[ "# 数えていく おしまい\nn = int(input())\nused = [False for _ in range(n)]\narr = list(map(int, input().split()))\nans = 0\nfor i, a in enumerate(arr):\n if i + 1 == arr[a - 1]:\n if used[i] == False:\n ans += 1\n used[i] = True\n used[a - 1] = True\nprint(ans)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "False for _ in range(n)", "for _ in range(n)", "_", "range(n)", "range", "n", "for _ in range(n)", "False", "used = [False for _ in range(n)]", "used", "[False for _ in range(n)]", "arr = list(map(int, input().split()))", "arr", "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(arr):\n if i + 1 == arr[a - 1]:\n if used[i] == False:\n ans += 1\n used[i] = True\n used[a - 1] = True", "i", "a", "enumerate(arr)", "enumerate", "arr", "if i + 1 == arr[a - 1]:\n if used[i] == False:\n ans += 1\n used[i] = True\n used[a - 1] = True", "i + 1 == arr[a - 1]", "i + 1", "i", "1", "arr[a - 1]", "arr", "a - 1", "a", "1", "if used[i] == False:\n ans += 1\n used[i] = True\n used[a - 1] = True", "used[i] == False", "used[i]", "used", "i", "False", "ans += 1", "ans", "1", "used[i] = True", "used[i]", "used", "i", "True", "used[a - 1] = True", "used[a - 1]", "used", "a - 1", "a", "1", "True", "print(ans)", "print", "ans", "used = [False for _ in range(n)]", "[False for _ in range(n)]", "used", "ans = 0", "0", "ans", "ans += 1", "1", "ans", "n = int(input())", "int(input())", "n", "arr = list(map(int, input().split()))", "list(map(int, input().split()))", "arr" ]
# 数えていく おしまい n = int(input()) used = [False for _ in range(n)] arr = list(map(int, input().split())) ans = 0 for i, a in enumerate(arr): if i + 1 == arr[a - 1]: if used[i] == False: ans += 1 used[i] = True used[a - 1] = True print(ans)
[ 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, 4, 13, 13, 17, 14, 40, 13, 13, 14, 2, 18, 13, 13, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 46, 2 ], [ 49, 8 ], [ 52, 20 ], [ 55, 23 ], [ 50, 30 ], [ 53, 35 ], [ 53, 39 ], [ 56, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ] ]
[ "n = int(input())\na = list(map(int, input().split()))\n\nd = {}\nans = 0\nfor num,i in enumerate(a,1):\n if i not in d: d[num] = i\n else:\n if d[i] == num: 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", "d = {}", "d", "{}", "ans = 0", "ans", "0", "for num,i in enumerate(a,1):\n if i not in d: d[num] = i\n else:\n if d[i] == num: ans += 1", "num", "i", "enumerate(a,1)", "enumerate", "a", "1", "if i not in d: d[num] = i\n else:\n if d[i] == num: ans += 1", "i not in d", "i", "d", "if d[i] == num: ans ", "d[i] == num", "d[i]", "d", "i", "num", "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 num,i in enumerate(a,1): if i not in d: d[num] = i else: if d[i] == num: 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, 2, 39, 17, 13, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 2, 2, 18, 13, 2, 18, 13, 13, 17, 17, 13, 2, 18, 13, 2, 18, 13, 13, 17, 17, 0, 13, 17, 0, 18, 13, 2, 18, 13, 2, 18, 13, 13, 17, 17, 17, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 2, 13, 10, 17, 13 ]
[ [ 81, 2 ], [ 75, 8 ], [ 84, 20 ], [ 82, 24 ], [ 78, 26 ], [ 30, 29 ], [ 82, 32 ], [ 76, 38 ], [ 76, 41 ], [ 29, 42 ], [ 29, 45 ], [ 85, 48 ], [ 76, 51 ], [ 29, 52 ], [ 87, 56 ], [ 70, 59 ], [ 85, 60 ], [ 76, 63 ], [ 76, 66 ], [ 29, 67 ], [ 88, 73 ], [ 79, 73 ], [ 75, 76 ], [ 78, 79 ], [ 81, 82 ], [ 84, 85 ], [ 87, 88 ] ]
[ "\nn = int(input())\na = list(map(int, input().split()))\nflags = [False] * n\nans = 0\nfor i in range(n):\n if a[a[i] - 1] - 1 == i and flags[a[i] - 1] == False:\n ans += 1\n flags[a[a[i] - 1] - 1] = True\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", "flags = [False] * n", "flags", "[False] * n", "[False]", "False", "n", "ans = 0", "ans", "0", "for i in range(n):\n if a[a[i] - 1] - 1 == i and flags[a[i] - 1] == False:\n ans += 1\n flags[a[a[i] - 1] - 1] = True", "i", "range(n)", "range", "n", "if a[a[i] - 1] - 1 == i and flags[a[i] - 1] == False:\n ans += 1\n flags[a[a[i] - 1] - 1] = True", "a[a[i] - 1] - 1 == i and flags[a[i] - 1] == False", "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", "flags[a[i] - 1] == False", "flags[a[i] - 1]", "flags", "a[i] - 1", "a[i]", "a", "i", "1", "False", "ans += 1", "ans", "1", "flags[a[a[i] - 1] - 1] = True", "flags[a[a[i] - 1] - 1]", "flags", "a[a[i] - 1] - 1", "a[a[i] - 1]", "a", "a[i] - 1", "a[i]", "a", "i", "1", "1", "True", "print(ans)", "print", "ans", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "ans = 0", "0", "ans", "n = int(input())", "int(input())", "n", "flags = [False] * n", "[False] * n", "flags", "ans += 1", "1", "ans" ]
n = int(input()) a = list(map(int, input().split())) flags = [False] * n ans = 0 for i in range(n): if a[a[i] - 1] - 1 == i and flags[a[i] - 1] == False: ans += 1 flags[a[a[i] - 1] - 1] = True print(ans)
[ 7, 15, 13, 4, 18, 13, 13, 2, 17, 17, 0, 13, 2, 17, 17, 0, 13, 2, 2, 17, 17, 17, 0, 13, 12, 4, 18, 4, 18, 18, 13, 13, 13, 13, 0, 13, 12, 4, 13, 8, 13, 39, 4, 13, 17, 4, 13, 17, 23, 0, 13, 12, 4, 13, 8, 13, 39, 4, 13, 17, 4, 13, 17, 23, 0, 13, 12, 2, 4, 13, 13, 17, 23, 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, 18, 13, 13, 0, 13, 17, 0, 13, 17, 4, 13, 13, 10, 2, 13, 10, 12, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 2, 13, 10, 4, 13, 10, 17, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 131, 11 ], [ 116, 16 ], [ 140, 23 ], [ 119, 35 ], [ 146, 50 ], [ 143, 65 ], [ 125, 74 ], [ 141, 78 ], [ 134, 80 ], [ 144, 85 ], [ 141, 89 ], [ 137, 92 ], [ 135, 99 ], [ 135, 104 ], [ 128, 107 ], [ 122, 110 ], [ 123, 114 ], [ 129, 114 ], [ 138, 114 ], [ 116, 117 ], [ 119, 120 ], [ 122, 123 ], [ 125, 126 ], [ 128, 129 ], [ 131, 132 ], [ 134, 135 ], [ 137, 138 ], [ 140, 141 ], [ 143, 144 ], [ 146, 147 ] ]
[ "# -*- coding: utf-8 -*-\nimport sys\nsys.setrecursionlimit(10**9)\nINF=10**18\nMOD=10**9+7\ninput=lambda: sys.stdin.readline().rstrip()\nYesNo=lambda b: bool([print('Yes')] if b else print('No'))\nYESNO=lambda b: bool([print('YES')] if b else print('NO'))\nint1=lambda x:int(x)-1\n\nN=int(input())\na=list(map(int1,input().split()))\nans=0\nfor i,x in enumerate(a):\n if i==a[x]:\n ans+=1\nans//=2\nprint(ans)", "import sys", "sys", "sys.setrecursionlimit(10**9)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10**9", "10", "9", "INF=10**18", "INF", "10**18", "10", "18", "MOD=10**9+7", "MOD", "10**9+7", "10**9", "10", "9", "7", "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", "YesNo=lambda b: bool([print('Yes')] if b else print('No'))", "YesNo", "lambda b: bool([print('Yes')] if b else print('No'))", "bool([print('Yes')] if b else print('No'))", "bool", "[print('Yes')] if b else print('No')", "b", "[print('Yes')]", "print('Yes')", "print", "'Yes'", "print('No')", "print", "'No'", "b", "YESNO=lambda b: bool([print('YES')] if b else print('NO'))", "YESNO", "lambda b: bool([print('YES')] if b else print('NO'))", "bool([print('YES')] if b else print('NO'))", "bool", "[print('YES')] if b else print('NO')", "b", "[print('YES')]", "print('YES')", "print", "'YES'", "print('NO')", "print", "'NO'", "b", "int1=lambda x:int(x)-1", "int1", "lambda x:int(x)-1", "int(x)-1", "int(x)", "int", "x", "1", "x", "N=int(input())", "N", "int(input())", "int", "input()", "input", "a=list(map(int1,input().split()))", "a", "list(map(int1,input().split()))", "list", "map(int1,input().split())", "map", "int1", "input().split()", "().split", "()", "input", "split", "ans=0", "ans", "0", "for i,x in enumerate(a):\n if i==a[x]:\n ans+=1", "i", "x", "enumerate(a)", "enumerate", "a", "if i==a[x]:\n ans+=1", "i==a[x]", "i", "a[x]", "a", "x", "ans+=1", "ans", "1", "ans//=2", "ans", "2", "print(ans)", "print", "ans", "MOD=10**9+7", "10**9+7", "MOD", "YesNo=lambda b: bool([print('Yes')] if b else print('No'))", "lambda b: bool([print('Yes')] if b else print('No'))", "YesNo", "ans//=2", "2", "ans", "N=int(input())", "int(input())", "N", "ans+=1", "1", "ans", "INF=10**18", "10**18", "INF", "a=list(map(int1,input().split()))", "list(map(int1,input().split()))", "a", "ans=0", "0", "ans", "input=lambda: sys.stdin.readline().rstrip()", "lambda: sys.stdin.readline().rstrip()", "input", "int1=lambda x:int(x)-1", "lambda x:int(x)-1", "int1", "YESNO=lambda b: bool([print('YES')] if b else print('NO'))", "lambda b: bool([print('YES')] if b else print('NO'))", "YESNO" ]
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10**9) INF=10**18 MOD=10**9+7 input=lambda: sys.stdin.readline().rstrip() YesNo=lambda b: bool([print('Yes')] if b else print('No')) YESNO=lambda b: bool([print('YES')] if b else print('NO')) int1=lambda x:int(x)-1 N=int(input()) a=list(map(int1,input().split())) ans=0 for i,x in enumerate(a): if i==a[x]: 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, 13, 4, 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 ]
[ [ 50, 2 ], [ 53, 8 ], [ 47, 20 ], [ 54, 27 ], [ 54, 31 ], [ 56, 39 ], [ 57, 44 ], [ 48, 44 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ] ]
[ "N = int(input())\nA = list(map(int,input().split()))\n\ncount = 0\nfor i, a in enumerate(A):\n #i+1はaが好き\n if A[a-1] == i+1:\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 i, a in enumerate(A):\n #i+1はaが好き\n if A[a-1] == i+1:\n count += 1", "i", "a", "enumerate(A)", "enumerate", "A", "if A[a-1] == i+1:\n count += 1", "A[a-1] == i+1", "A[a-1]", "A", "a-1", "a", "1", "i+1", "i", "1", "count += 1", "count", "1", "print(count//2)", "print", "count//2", "count", "2", "count = 0", "0", "count", "N = int(input())", "int(input())", "N", "A = list(map(int,input().split()))", "list(map(int,input().split()))", "A", "count += 1", "1", "count" ]
N = int(input()) A = list(map(int,input().split())) count = 0 for i, a in enumerate(A): #i+1はaが好き if A[a-1] == i+1: count += 1 print(count//2)
[ 7, 12, 13, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 18, 13, 2, 18, 13, 13, 17, 2, 13, 17, 0, 13, 17, 29, 2, 13, 17, 23, 13, 23, 13, 12, 13, 0, 13, 17, 12, 13, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 4, 13, 4, 13, 13, 18, 13, 39, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 5, 4 ], [ 8, 7 ], [ 31, 10 ], [ 33, 14 ], [ 33, 17 ], [ 7, 18 ], [ 7, 21 ], [ 25, 24 ], [ 24, 28 ], [ 4, 28 ], [ 31, 31 ], [ 33, 33 ], [ 38, 37 ], [ 43, 42 ], [ 49, 48 ], [ 75, 62 ], [ 42, 63 ], [ 48, 65 ], [ 81, 72 ] ]
[ "def myAnswer(N:int,A:list) -> int:\n counter = 0\n for i in range(N):\n if(A[A[i]-1] == i + 1):\n counter += 1\n return counter//2\n\n\ndef modelAnswer():\n tmp=1\ndef main():\n N = int(input())\n A = list(map(int,input().split()))\n print(myAnswer(N,A[:]))\nif __name__ == '__main__':\n main()", "def myAnswer(N:int,A:list) -> int:\n counter = 0\n for i in range(N):\n if(A[A[i]-1] == i + 1):\n counter += 1\n return counter//2", "myAnswer", "counter = 0", "counter", "0", "for i in range(N):\n if(A[A[i]-1] == i + 1):\n counter += 1\n ", "i", "range(N)", "range", "N", "if(A[A[i]-1] == i + 1):\n counter += 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", "counter += 1", "counter", "1", "return counter//2", "counter//2", "counter", "2", "N:int", "N", "A:list", "A", "def modelAnswer():\n tmp=1", "modelAnswer", "tmp=1", "tmp", "1", "def main():\n N = int(input())\n A = list(map(int,input().split()))\n print(myAnswer(N,A[:]))", "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", "print(myAnswer(N,A[:]))", "print", "myAnswer(N,A[:])", "myAnswer", "N", "A[:]", "A", ":", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def myAnswer(N:int,A:list) -> int:\n counter = 0\n for i in range(N):\n if(A[A[i]-1] == i + 1):\n counter += 1\n return counter//2", "def myAnswer(N:int,A:list) -> int:\n counter = 0\n for i in range(N):\n if(A[A[i]-1] == i + 1):\n counter += 1\n return counter//2", "myAnswer", "def modelAnswer():\n tmp=1", "def modelAnswer():\n tmp=1", "modelAnswer", "def main():\n N = int(input())\n A = list(map(int,input().split()))\n print(myAnswer(N,A[:]))", "def main():\n N = int(input())\n A = list(map(int,input().split()))\n print(myAnswer(N,A[:]))", "main" ]
def myAnswer(N:int,A:list) -> int: counter = 0 for i in range(N): if(A[A[i]-1] == i + 1): counter += 1 return counter//2 def modelAnswer(): tmp=1 def main(): N = int(input()) A = list(map(int,input().split())) print(myAnswer(N,A[:])) 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, 4, 13, 13, 14, 2, 18, 13, 13, 2, 13, 17, 9, 0, 13, 18, 13, 13, 14, 2, 18, 13, 2, 13, 17, 2, 13, 17, 0, 13, 17, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 18, 13 ]
[ [ 61, 2 ], [ 58, 8 ], [ 67, 20 ], [ 24, 23 ], [ 62, 26 ], [ 59, 30 ], [ 23, 31 ], [ 23, 33 ], [ 70, 37 ], [ 59, 39 ], [ 23, 40 ], [ 59, 44 ], [ 71, 46 ], [ 23, 49 ], [ 64, 52 ], [ 65, 56 ], [ 68, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ], [ 70, 71 ] ]
[ "N=int(input())\nA=list(map(int,input().split()))\ncount=0\nfor i in range (N):\n if A[i]<i+1:\n continue\n K=A[i]\n if A[K-1]==i+1:\n 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 (N):\n if A[i]<i+1:\n continue\n K=A[i]\n if A[K-1]==i+1:\n count+=1", "i", "range (N)", "range", "N", "if A[i]<i+1:\n continue\n ", "A[i]<i+1", "A[i]", "A", "i", "i+1", "i", "1", "continue", "K=A[i]", "K", "A[i]", "A", "i", "if A[K-1]==i+1:\n count+=1", "A[K-1]==i+1", "A[K-1]", "A", "K-1", "K", "1", "i+1", "i", "1", "count+=1", "count", "1", "print(count)", "print", "count", "A=list(map(int,input().split()))", "list(map(int,input().split()))", "A", "N=int(input())", "int(input())", "N", "count+=1", "1", "count", "count=0", "0", "count", "K=A[i]", "A[i]", "K" ]
N=int(input()) A=list(map(int,input().split())) count=0 for i in range (N): if A[i]<i+1: continue K=A[i] if A[K-1]==i+1: count+=1 print(count)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 18, 4, 13, 13, 13, 0, 13, 17, 28, 13, 4, 13, 17, 2, 13, 17, 14, 2, 18, 13, 2, 18, 13, 2, 13, 17, 17, 13, 0, 13, 2, 13, 17, 4, 13, 2, 13, 17, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 2, 13 ]
[ [ 62, 2 ], [ 56, 8 ], [ 59, 23 ], [ 27, 26 ], [ 63, 31 ], [ 57, 36 ], [ 57, 39 ], [ 26, 41 ], [ 26, 44 ], [ 65, 46 ], [ 60, 48 ], [ 66, 48 ], [ 66, 53 ], [ 60, 53 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ] ]
[ "n=int (input())\na= list(map(int, input().strip().split()))\ncount=0\nfor i in range(1,n+1):\n if a[a[i-1]-1]==i:\n count=count+1\nprint(count//2)", "n=int (input())", "n", "int (input())", "int", "input()", "input", "a= list(map(int, input().strip().split()))", "a", "list(map(int, input().strip().split()))", "list", "map(int, input().strip().split())", "map", "int", "input().strip().split()", "().strip().split", "().strip()", "().strip", "()", "input", "strip", "split", "count=0", "count", "0", "for i in range(1,n+1):\n if a[a[i-1]-1]==i:\n count=count+1", "i", "range(1,n+1)", "range", "1", "n+1", "n", "1", "if a[a[i-1]-1]==i:\n count=count+1", "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", "i", "count=count+1", "count", "count+1", "count", "1", "print(count//2)", "print", "count//2", "count", "2", "a= list(map(int, input().strip().split()))", "list(map(int, input().strip().split()))", "a", "count=0", "0", "count", "n=int (input())", "int (input())", "n", "count=count+1", "count+1", "count" ]
n=int (input()) a= list(map(int, input().strip().split())) count=0 for i in range(1,n+1): if a[a[i-1]-1]==i: count=count+1 print(count//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, 0, 13, 39, 0, 13, 2, 39, 17, 13, 28, 13, 4, 13, 13, 14, 18, 13, 13, 9, 14, 2, 18, 13, 18, 13, 13, 13, 0, 13, 17, 0, 18, 13, 18, 13, 13, 17, 4, 13, 13, 10, 17, 13, 10, 2, 13, 10, 39, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 81, 2 ], [ 84, 8 ], [ 78, 26 ], [ 75, 29 ], [ 72, 32 ], [ 82, 36 ], [ 39, 38 ], [ 82, 41 ], [ 73, 44 ], [ 38, 45 ], [ 85, 50 ], [ 85, 52 ], [ 38, 53 ], [ 38, 54 ], [ 69, 56 ], [ 64, 59 ], [ 73, 60 ], [ 85, 62 ], [ 38, 63 ], [ 70, 67 ], [ 79, 67 ], [ 69, 70 ], [ 72, 73 ], [ 75, 76 ], [ 78, 79 ], [ 81, 82 ], [ 84, 85 ] ]
[ "N = int(input())\nA = list(map(lambda x:int(x)-1,input().split()))\nans = 0\npaired = []\nflag = [0]*N\nfor i in range(N):\n if flag[i]:\n continue\n else:\n if A[A[i]] == i:\n ans += 1\n flag[A[i]] = 1\nprint(ans)", "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", "paired = []", "paired", "[]", "flag = [0]*N", "flag", "[0]*N", "[0]", "0", "N", "for i in range(N):\n if flag[i]:\n continue\n else:\n if A[A[i]] == i:\n ans += 1\n flag[A[i]] = 1", "i", "range(N)", "range", "N", "if flag[i]:\n continue\n else:\n if A[A[i]] == i:\n ans += 1\n flag[A[i]] = 1", "flag[i]", "flag", "i", "continue", "if A[A[i]] == i:\n ans += 1\n flag[A[i]] = 1", "A[A[i]] == i", "A[A[i]]", "A", "A[i]", "A", "i", "i", "ans += 1", "ans", "1", "flag[A[i]] = 1", "flag[A[i]]", "flag", "A[i]", "A", "i", "1", "print(ans)", "print", "ans", "ans += 1", "1", "ans", "flag = [0]*N", "[0]*N", "flag", "paired = []", "[]", "paired", "ans = 0", "0", "ans", "N = int(input())", "int(input())", "N", "A = list(map(lambda x:int(x)-1,input().split()))", "list(map(lambda x:int(x)-1,input().split()))", "A" ]
N = int(input()) A = list(map(lambda x:int(x)-1,input().split())) ans = 0 paired = [] flag = [0]*N for i in range(N): if flag[i]: continue else: if A[A[i]] == i: ans += 1 flag[A[i]] = 1 print(ans)
[ 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, 2, 39, 17, 13, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 40, 18, 13, 13, 2, 18, 13, 18, 13, 13, 13, 0, 13, 17, 0, 18, 13, 13, 17, 0, 18, 13, 18, 13, 13, 17, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 74, 2 ], [ 71, 8 ], [ 77, 26 ], [ 75, 30 ], [ 80, 32 ], [ 36, 35 ], [ 75, 38 ], [ 56, 42 ], [ 78, 43 ], [ 35, 44 ], [ 72, 47 ], [ 72, 49 ], [ 35, 50 ], [ 35, 51 ], [ 83, 53 ], [ 59, 56 ], [ 78, 57 ], [ 35, 58 ], [ 66, 61 ], [ 78, 62 ], [ 72, 64 ], [ 35, 65 ], [ 84, 69 ], [ 81, 69 ], [ 71, 72 ], [ 74, 75 ], [ 77, 78 ], [ 80, 81 ], [ 83, 84 ] ]
[ "N = int(input())\nA = list(map(lambda x: int(x) - 1, input().split()))\nchecked = [False] * N\nans = 0\n\nfor i in range(N):\n if not checked[i] and A[A[i]] == i:\n ans += 1\n checked[i] = True\n checked[A[i]] = True\n\nprint(ans)", "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", "checked = [False] * N", "checked", "[False] * N", "[False]", "False", "N", "ans = 0", "ans", "0", "for i in range(N):\n if not checked[i] and A[A[i]] == i:\n ans += 1\n checked[i] = True\n checked[A[i]] = True", "i", "range(N)", "range", "N", "if not checked[i] and A[A[i]] == i:\n ans += 1\n checked[i] = True\n checked[A[i]] = True", "not checked[i] and A[A[i]] == i", "not checked[i]", "checked[i]", "checked", "i", "A[A[i]] == i", "A[A[i]]", "A", "A[i]", "A", "i", "i", "ans += 1", "ans", "1", "checked[i] = True", "checked[i]", "checked", "i", "True", "checked[A[i]] = True", "checked[A[i]]", "checked", "A[i]", "A", "i", "True", "print(ans)", "print", "ans", "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", "checked = [False] * N", "[False] * N", "checked", "ans = 0", "0", "ans", "ans += 1", "1", "ans" ]
N = int(input()) A = list(map(lambda x: int(x) - 1, input().split())) checked = [False] * N ans = 0 for i in range(N): if not checked[i] and A[A[i]] == i: ans += 1 checked[i] = True checked[A[i]] = True 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, 13, 4, 13, 13, 0, 13, 18, 13, 2, 13, 17, 14, 2, 13, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 18, 13 ]
[ [ 57, 2 ], [ 51, 8 ], [ 54, 20 ], [ 52, 27 ], [ 66, 29 ], [ 52, 31 ], [ 67, 37 ], [ 60, 42 ], [ 63, 45 ], [ 64, 49 ], [ 61, 49 ], [ 55, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ] ]
[ "N = int(input())\na = list(map(int,input().split()))\n\ncnt = 0\nfor i,value in enumerate(a):\n b = a[value-1]\n if b == i+1:\n cnt += 1\ncnt //=2\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,value in enumerate(a):\n b = a[value-1]\n if b == i+1:\n cnt += 1", "i", "value", "enumerate(a)", "enumerate", "a", "b = a[value-1]", "b", "a[value-1]", "a", "value-1", "value", "1", "if b == i+1:\n cnt += 1", "b == i+1", "b", "i+1", "i", "1", "cnt += 1", "cnt", "1", "cnt //=2", "cnt", "2", "print(cnt)", "print", "cnt", "a = list(map(int,input().split()))", "list(map(int,input().split()))", "a", "cnt = 0", "0", "cnt", "N = int(input())", "int(input())", "N", "cnt += 1", "1", "cnt", "cnt //=2", "2", "cnt", "b = a[value-1]", "a[value-1]", "b" ]
N = int(input()) a = list(map(int,input().split())) cnt = 0 for i,value in enumerate(a): b = a[value-1] if b == i+1: cnt += 1 cnt //=2 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, 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 ], [ 57, 54 ] ]
[ "def main():\n n = int(input())\n a_list = list(map(int, input().split()))\n cnt = 0\n\n for i in range(n):\n if a_list[a_list[i] - 1] - 1 == i:\n cnt += 1\n\n print(cnt // 2)\n\n\nif __name__ == \"__main__\":\n main()", "def main():\n n = int(input())\n a_list = list(map(int, input().split()))\n cnt = 0\n\n for i in range(n):\n if a_list[a_list[i] - 1] - 1 == i:\n cnt += 1\n\n print(cnt // 2)", "main", "n = int(input())", "n", "int(input())", "int", "input()", "input", "a_list = list(map(int, input().split()))", "a_list", "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_list[a_list[i] - 1] - 1 == i:\n cnt += 1\n\n ", "i", "range(n)", "range", "n", "if a_list[a_list[i] - 1] - 1 == i:\n cnt += 1\n\n ", "a_list[a_list[i] - 1] - 1 == i", "a_list[a_list[i] - 1] - 1", "a_list[a_list[i] - 1]", "a_list", "a_list[i] - 1", "a_list[i]", "a_list", "i", "1", "1", "i", "cnt += 1", "cnt", "1", "print(cnt // 2)", "print", "cnt // 2", "cnt", "2", "if __name__ == \"__main__\":\n main()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "main()", "main", "def main():\n n = int(input())\n a_list = list(map(int, input().split()))\n cnt = 0\n\n for i in range(n):\n if a_list[a_list[i] - 1] - 1 == i:\n cnt += 1\n\n print(cnt // 2)", "def main():\n n = int(input())\n a_list = list(map(int, input().split()))\n cnt = 0\n\n for i in range(n):\n if a_list[a_list[i] - 1] - 1 == i:\n cnt += 1\n\n print(cnt // 2)", "main" ]
def main(): n = int(input()) a_list = list(map(int, input().split())) cnt = 0 for i in range(n): if a_list[a_list[i] - 1] - 1 == i: cnt += 1 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, 4, 13, 0, 13, 17, 28, 13, 4, 13, 13, 0, 18, 13, 2, 13, 17, 18, 13, 13, 14, 2, 4, 18, 13, 13, 18, 13, 13, 17, 2, 13, 17, 0, 13, 17, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 60, 2 ], [ 63, 8 ], [ 72, 20 ], [ 66, 24 ], [ 28, 27 ], [ 61, 30 ], [ 37, 32 ], [ 73, 33 ], [ 27, 35 ], [ 64, 38 ], [ 27, 39 ], [ 73, 44 ], [ 64, 47 ], [ 27, 48 ], [ 27, 51 ], [ 69, 54 ], [ 70, 58 ], [ 67, 58 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ], [ 69, 70 ], [ 72, 73 ] ]
[ "n = int(input())\ndat = list(map(int, input().split()))\nd = dict()\nres = 0\nfor i in range(n):\n d[i+1] = dat[i]\n if d.get(dat[i], -1) == (i + 1):\n res += 1\nprint(res)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "dat = list(map(int, input().split()))", "dat", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "d = dict()", "d", "dict()", "dict", "res = 0", "res", "0", "for i in range(n):\n d[i+1] = dat[i]\n if d.get(dat[i], -1) == (i + 1):\n res += 1", "i", "range(n)", "range", "n", "d[i+1] = dat[i]", "d[i+1]", "d", "i+1", "i", "1", "dat[i]", "dat", "i", "if d.get(dat[i], -1) == (i + 1):\n res += 1", "d.get(dat[i], -1) == (i + 1)", "d.get(dat[i], -1)", "d.get", "d", "get", "dat[i]", "dat", "i", "-1", "i + 1", "i", "1", "res += 1", "res", "1", "print(res)", "print", "res", "n = int(input())", "int(input())", "n", "dat = list(map(int, input().split()))", "list(map(int, input().split()))", "dat", "res = 0", "0", "res", "res += 1", "1", "res", "d = dict()", "dict()", "d" ]
n = int(input()) dat = list(map(int, input().split())) d = dict() res = 0 for i in range(n): d[i+1] = dat[i] if d.get(dat[i], -1) == (i + 1): res += 1 print(res)
[ 7, 15, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 39, 28, 13, 13, 4, 13, 13, 0, 13, 2, 13, 17, 14, 2, 13, 13, 0, 13, 13, 13, 13, 4, 18, 13, 13, 39, 13, 13, 0, 13, 4, 13, 13, 0, 13, 17, 28, 13, 13, 4, 18, 13, 13, 14, 2, 13, 17, 0, 13, 17, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 13, 13, 10, 4, 13, 10, 2, 13, 10, 13, 13, 10, 39, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 85, 3 ], [ 100, 9 ], [ 94, 21 ], [ 101, 28 ], [ 88, 30 ], [ 92, 36 ], [ 89, 37 ], [ 83, 37 ], [ 91, 39 ], [ 89, 40 ], [ 83, 40 ], [ 82, 41 ], [ 92, 42 ], [ 95, 45 ], [ 76, 51 ], [ 95, 54 ], [ 79, 56 ], [ 77, 63 ], [ 97, 70 ], [ 98, 74 ], [ 80, 74 ], [ 76, 77 ], [ 79, 80 ], [ 92, 82 ], [ 82, 83 ], [ 85, 86 ], [ 88, 89 ], [ 89, 91 ], [ 83, 91 ], [ 91, 92 ], [ 94, 95 ], [ 97, 98 ], [ 100, 101 ] ]
[ "from collections import Counter\nn = int(input())\nA = list(map(int, input().split()))\np = []\nfor i, a in enumerate(A):\n idx = i+1\n if a>idx:\n a,idx = idx, a\n p.append((a, idx))\nc = Counter(p)\nans = 0\nfor k,v in c.items():\n if v==2:\n ans += 1\nprint(ans)", "from collections import Counter", "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", "p = []", "p", "[]", "for i, a in enumerate(A):\n idx = i+1\n if a>idx:\n a,idx = idx, a\n p.append((a, idx))", "i", "a", "enumerate(A)", "enumerate", "A", "idx = i+1", "idx", "i+1", "i", "1", "if a>idx:\n a,idx = idx, a\n ", "a>idx", "a", "idx", "a,idx = idx, a", "a", "idx", "idx", "a", "p.append((a, idx))", "p.append", "p", "append", "(a, idx)", "a", "idx", "c = Counter(p)", "c", "Counter(p)", "Counter", "p", "ans = 0", "ans", "0", "for k,v in c.items():\n if v==2:\n ans += 1", "k", "v", "c.items()", "c.items", "c", "items", "if v==2:\n ans += 1", "v==2", "v", "2", "ans += 1", "ans", "1", "print(ans)", "print", "ans", "c = Counter(p)", "Counter(p)", "c", "ans = 0", "0", "ans", "idx = idx, a", "a", "idx", "n = int(input())", "int(input())", "n", "idx = i+1", "i+1", "idx", "a,idx = idx, a", "idx", "a", "p = []", "[]", "p", "ans += 1", "1", "ans", "A = list(map(int, input().split()))", "list(map(int, input().split()))", "A" ]
from collections import Counter n = int(input()) A = list(map(int, input().split())) p = [] for i, a in enumerate(A): idx = i+1 if a>idx: a,idx = idx, a p.append((a, idx)) c = Counter(p) ans = 0 for k,v in c.items(): if v==2: ans += 1 print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 18, 4, 13, 13, 17, 0, 13, 39, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 4, 13, 18, 13, 13, 14, 2, 13, 2, 13, 17, 9, 14, 2, 4, 13, 18, 13, 2, 13, 17, 2, 13, 17, 0, 13, 17, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 39, 13 ]
[ [ 62, 2 ], [ 65, 8 ], [ 74, 16 ], [ 68, 19 ], [ 23, 22 ], [ 63, 25 ], [ 59, 27 ], [ 66, 31 ], [ 22, 32 ], [ 60, 35 ], [ 22, 37 ], [ 66, 45 ], [ 60, 47 ], [ 22, 50 ], [ 71, 53 ], [ 72, 57 ], [ 69, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ], [ 74, 75 ] ]
[ "N = int(input())\nrabit = input().split(\" \")\nskip = []\nnum = 0\n\nfor i in range(N):\n n = int(rabit[i])\n if n < i+1:\n continue\n if int(rabit[n-1]) == i+1:\n num += 1\n\nprint(num)", "N = int(input())", "N", "int(input())", "int", "input()", "input", "rabit = input().split(\" \")", "rabit", "input().split(\" \")", "().split", "()", "input", "split", "\" \"", "skip = []", "skip", "[]", "num = 0", "num", "0", "for i in range(N):\n n = int(rabit[i])\n if n < i+1:\n continue\n if int(rabit[n-1]) == i+1:\n num += 1", "i", "range(N)", "range", "N", "n = int(rabit[i])", "n", "int(rabit[i])", "int", "rabit[i]", "rabit", "i", "if n < i+1:\n continue\n ", "n < i+1", "n", "i+1", "i", "1", "continue", "if int(rabit[n-1]) == i+1:\n num += 1", "int(rabit[n-1]) == i+1", "int(rabit[n-1])", "int", "rabit[n-1]", "rabit", "n-1", "n", "1", "i+1", "i", "1", "num += 1", "num", "1", "print(num)", "print", "num", "n = int(rabit[i])", "int(rabit[i])", "n", "N = int(input())", "int(input())", "N", "rabit = input().split(\" \")", "input().split(\" \")", "rabit", "num = 0", "0", "num", "num += 1", "1", "num", "skip = []", "[]", "skip" ]
N = int(input()) rabit = input().split(" ") skip = [] num = 0 for i in range(N): n = int(rabit[i]) if n < i+1: continue if int(rabit[n-1]) == i+1: num += 1 print(num)
[ 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, 13, 14, 2, 2, 18, 13, 2, 13, 17, 17, 13, 0, 13, 17, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 58, 2 ], [ 49, 8 ], [ 52, 20 ], [ 50, 27 ], [ 50, 36 ], [ 55, 43 ], [ 56, 47 ], [ 53, 47 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ] ]
[ "N = int(input())\nA_list = list(map(int, input().split()))\n\ncnt = 0\nfor i, ai in enumerate(A_list):\n if i < ai:\n if (A_list[ai-1] - 1) == i:\n cnt += 1\nprint(cnt) ", "N = int(input())", "N", "int(input())", "int", "input()", "input", "A_list = list(map(int, input().split()))", "A_list", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "cnt = 0", "cnt", "0", "for i, ai in enumerate(A_list):\n if i < ai:\n if (A_list[ai-1] - 1) == i:\n cnt += 1", "i", "ai", "enumerate(A_list)", "enumerate", "A_list", "if i < ai:\n if (A_list[ai-1] - 1) == i:\n cnt += 1", "i < ai", "i", "ai", "if (A_list[ai-1] - 1) == i:\n cnt += 1", "(A_list[ai-1] - 1) == i", "A_list[ai-1] - 1", "A_list[ai-1]", "A_list", "ai-1", "ai", "1", "1", "i", "cnt += 1", "cnt", "1", "print(cnt)", "print", "cnt", "A_list = list(map(int, input().split()))", "list(map(int, input().split()))", "A_list", "cnt = 0", "0", "cnt", "cnt += 1", "1", "cnt", "N = int(input())", "int(input())", "N" ]
N = int(input()) A_list = list(map(int, input().split())) cnt = 0 for i, ai in enumerate(A_list): if i < ai: if (A_list[ai-1] - 1) == i: cnt += 1 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, 13, 4, 4, 13, 0, 13, 13, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 18, 13, 13, 17, 14, 2, 2, 13, 18, 13, 13, 2, 13, 18, 13, 13, 0, 13, 17, 4, 18, 18, 13, 13, 13, 13, 4, 18, 18, 13, 13, 13, 13, 4, 13, 13, 10, 2, 13, 10, 13, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 91, 2 ], [ 88, 8 ], [ 22, 21 ], [ 92, 24 ], [ 82, 29 ], [ 85, 32 ], [ 36, 35 ], [ 92, 38 ], [ 79, 40 ], [ 89, 43 ], [ 35, 44 ], [ 80, 49 ], [ 83, 51 ], [ 35, 52 ], [ 35, 54 ], [ 83, 56 ], [ 80, 57 ], [ 94, 59 ], [ 83, 64 ], [ 35, 65 ], [ 80, 67 ], [ 83, 71 ], [ 80, 72 ], [ 35, 74 ], [ 95, 77 ], [ 86, 77 ], [ 79, 80 ], [ 82, 83 ], [ 85, 86 ], [ 88, 89 ], [ 91, 92 ], [ 94, 95 ] ]
[ "N = int(input())\nA = list(map(int,input().split()))\nB = [set() for x in range(N)]\n\nans = 0\nfor i in range(N):\n j = A[i] - 1\n if j in B[i] or i in B[j]:\n ans += 1\n else:\n B[i].add(j)\n B[j].add(i)\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", "set() for x in range(N)", "for x in range(N)", "x", "range(N)", "range", "N", "for x in range(N)", "set()", "set", "B = [set() for x in range(N)]", "B", "[set() for x in range(N)]", "ans = 0", "ans", "0", "for i in range(N):\n j = A[i] - 1\n if j in B[i] or i in B[j]:\n ans += 1\n else:\n B[i].add(j)\n B[j].add(i)", "i", "range(N)", "range", "N", "j = A[i] - 1", "j", "A[i] - 1", "A[i]", "A", "i", "1", "if j in B[i] or i in B[j]:\n ans += 1\n else:\n B[i].add(j)\n B[j].add(i)", "j in B[i] or i in B[j]", "j in B[i]", "j", "B[i]", "B", "i", "i in B[j]", "i", "B[j]", "B", "j", "ans += 1", "ans", "1", "B[i].add(j)", "[i].add", "[i]", "B", "i", "add", "j", "B[j].add(i)", "[j].add", "[j]", "B", "j", "add", "i", "print(ans)", "print", "ans", "j = A[i] - 1", "A[i] - 1", "j", "B = [set() for x in range(N)]", "[set() for x in range(N)]", "B", "ans = 0", "0", "ans", "A = list(map(int,input().split()))", "list(map(int,input().split()))", "A", "N = int(input())", "int(input())", "N", "ans += 1", "1", "ans" ]
N = int(input()) A = list(map(int,input().split())) B = [set() for x in range(N)] ans = 0 for i in range(N): j = A[i] - 1 if j in B[i] or i in B[j]: ans += 1 else: B[i].add(j) B[j].add(i) print(ans)
[ 7, 4, 13, 41, 28, 13, 4, 18, 4, 13, 13, 17, 4, 4, 13, 13, 0, 13, 13, 41, 28, 13, 4, 13, 4, 13, 13, 2, 2, 13, 17, 18, 13, 2, 18, 13, 13, 17, 4, 17, 4, 13, 4, 13, 2, 4, 13, 13, 17, 10, 13, 13 ]
[ [ 6, 5 ], [ 5, 15 ], [ 50, 17 ], [ 22, 21 ], [ 51, 26 ], [ 21, 29 ], [ 51, 32 ], [ 51, 35 ], [ 21, 36 ], [ 50, 51 ] ]
[ "input()\nLOVE = [int(i) for i in input().split(' ')]\nprint(int(len([1 for i in range(len(LOVE)) if i + 1 == LOVE[LOVE[i] - 1]]) / 2))", "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", "LOVE = [int(i) for i in input().split(' ')]", "LOVE", "[int(i) for i in input().split(' ')]", "1 for i in range(len(LOVE)) if i + 1 == LOVE[LOVE[i] - 1]", "for i in range(len(LOVE)) if i + 1 == LOVE[LOVE[i] - 1]", "i", "range(len(LOVE))", "range", "len(LOVE)", "len", "LOVE", "i + 1 == LOVE[LOVE[i] - 1]", "i + 1", "i", "1", "LOVE[LOVE[i] - 1]", "LOVE", "LOVE[i] - 1", "LOVE[i]", "LOVE", "i", "1", "if i + 1 == LOVE[LOVE[i] - 1]", "1", "print(int(len([1 for i in range(len(LOVE)) if i + 1 == LOVE[LOVE[i] - 1]]) / 2))", "print", "int(len([1 for i in range(len(LOVE)) if i + 1 == LOVE[LOVE[i] - 1]]) / 2)", "int", "len([1 for i in range(len(LOVE)) if i + 1 == LOVE[LOVE[i] - 1]]) / 2", "len([1 for i in range(len(LOVE)) if i + 1 == LOVE[LOVE[i] - 1]])", "len", "[1 for i in range(len(LOVE)) if i + 1 == LOVE[LOVE[i] - 1]]", "2", "LOVE = [int(i) for i in input().split(' ')]", "[int(i) for i in input().split(' ')]", "LOVE" ]
input() LOVE = [int(i) for i in input().split(' ')] print(int(len([1 for i in range(len(LOVE)) if i + 1 == LOVE[LOVE[i] - 1]]) / 2))
[ 7, 12, 13, 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, 18, 13, 13, 0, 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, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 5, 4 ], [ 11, 10 ], [ 23, 22 ], [ 4, 26 ], [ 29, 28 ], [ 32, 31 ], [ 4, 34 ], [ 22, 37 ], [ 31, 38 ], [ 43, 40 ], [ 22, 41 ], [ 31, 42 ], [ 10, 48 ], [ 10, 51 ], [ 31, 52 ], [ 31, 55 ], [ 58, 57 ], [ 67, 60 ], [ 22, 61 ], [ 10, 64 ], [ 31, 65 ], [ 57, 70 ], [ 28, 70 ], [ 79, 76 ] ]
[ "def main():\n n = int(input())\n a = list(map(int, input().split()))\n f = [True]*n\n ans = 0\n for i in range(n):\n if f[i]:\n f[i] = False\n if a[a[i]-1]-1 == i:\n ans += 1\n f[a[i]-1] = False\n print(ans)\n\nif __name__ == \"__main__\":\n main()", "def main():\n n = int(input())\n a = list(map(int, input().split()))\n f = [True]*n\n ans = 0\n for i in range(n):\n if f[i]:\n f[i] = False\n if a[a[i]-1]-1 == i:\n ans += 1\n f[a[i]-1] = False\n print(ans)", "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", "f = [True]*n", "f", "[True]*n", "[True]", "True", "n", "ans = 0", "ans", "0", "for i in range(n):\n if f[i]:\n f[i] = False\n if a[a[i]-1]-1 == i:\n ans += 1\n f[a[i]-1] = False\n ", "i", "range(n)", "range", "n", "if f[i]:\n f[i] = False\n if a[a[i]-1]-1 == i:\n ans += 1\n f[a[i]-1] = False\n ", "f[i]", "f", "i", "f[i] = False", "f[i]", "f", "i", "False", "if a[a[i]-1]-1 == i:\n ans += 1\n f[a[i]-1] = False\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", "f[a[i]-1] = False", "f[a[i]-1]", "f", "a[i]-1", "a[i]", "a", "i", "1", "False", "print(ans)", "print", "ans", "if __name__ == \"__main__\":\n main()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "main()", "main", "def main():\n n = int(input())\n a = list(map(int, input().split()))\n f = [True]*n\n ans = 0\n for i in range(n):\n if f[i]:\n f[i] = False\n if a[a[i]-1]-1 == i:\n ans += 1\n f[a[i]-1] = False\n print(ans)", "def main():\n n = int(input())\n a = list(map(int, input().split()))\n f = [True]*n\n ans = 0\n for i in range(n):\n if f[i]:\n f[i] = False\n if a[a[i]-1]-1 == i:\n ans += 1\n f[a[i]-1] = False\n print(ans)", "main" ]
def main(): n = int(input()) a = list(map(int, input().split())) f = [True]*n ans = 0 for i in range(n): if f[i]: f[i] = False if a[a[i]-1]-1 == i: ans += 1 f[a[i]-1] = False print(ans) 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, 18, 13, 2, 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 ]
[ [ 56, 2 ], [ 53, 8 ], [ 50, 20 ], [ 54, 27 ], [ 54, 31 ], [ 47, 39 ], [ 48, 44 ], [ 51, 44 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ] ]
[ "n = int(input())\nA = list(map(int, input().split()))\n\ncnt = 0\nfor itr, val in enumerate(A):\n if A[val - 1] == itr + 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 itr, val in enumerate(A):\n if A[val - 1] == itr + 1:\n cnt += 1\n ", "itr", "val", "enumerate(A)", "enumerate", "A", "if A[val - 1] == itr + 1:\n cnt += 1\n ", "A[val - 1] == itr + 1", "A[val - 1]", "A", "val - 1", "val", "1", "itr + 1", "itr", "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 itr, val in enumerate(A): if A[val - 1] == itr + 1: cnt += 1 print(cnt // 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, 41, 28, 13, 4, 13, 13, 4, 4, 13, 0, 13, 13, 28, 13, 4, 13, 13, 4, 18, 18, 13, 18, 13, 13, 13, 13, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 18, 13, 13, 0, 13, 17, 4, 13, 2, 13, 17, 10, 4, 13, 10, 17, 13, 10, 13, 13, 10, 13, 13, 10, 17, 13 ]
[ [ 75, 2 ], [ 10, 9 ], [ 9, 19 ], [ 84, 22 ], [ 27, 26 ], [ 76, 29 ], [ 81, 34 ], [ 38, 37 ], [ 76, 40 ], [ 82, 44 ], [ 85, 46 ], [ 37, 47 ], [ 37, 49 ], [ 78, 51 ], [ 55, 54 ], [ 76, 57 ], [ 85, 61 ], [ 54, 62 ], [ 82, 64 ], [ 54, 65 ], [ 87, 67 ], [ 88, 72 ], [ 79, 72 ], [ 75, 76 ], [ 78, 79 ], [ 81, 82 ], [ 84, 85 ], [ 87, 88 ] ]
[ "N = int(input())\nA = [int(a) - 1 for a in input().split()]\nliked = [set() for _ in range(N)]\nfor i in range(N):\n liked[A[i]].add(i)\n\ncount = 0\nfor i in range(N):\n if A[i] in liked[i]:\n count += 1\n\nprint(count // 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()]", "set() for _ in range(N)", "for _ in range(N)", "_", "range(N)", "range", "N", "for _ in range(N)", "set()", "set", "liked = [set() for _ in range(N)]", "liked", "[set() for _ in range(N)]", "for i in range(N):\n liked[A[i]].add(i)", "i", "range(N)", "range", "N", "liked[A[i]].add(i)", "[A[i]].add", "[A[i]]", "liked", "A[i]", "A", "i", "add", "i", "count = 0", "count", "0", "for i in range(N):\n if A[i] in liked[i]:\n count += 1", "i", "range(N)", "range", "N", "if A[i] in liked[i]:\n count += 1", "A[i] in liked[i]", "A[i]", "A", "i", "liked[i]", "liked", "i", "count += 1", "count", "1", "print(count // 2)", "print", "count // 2", "count", "2", "N = int(input())", "int(input())", "N", "count = 0", "0", "count", "liked = [set() for _ in range(N)]", "[set() for _ in range(N)]", "liked", "A = [int(a) - 1 for a in input().split()]", "[int(a) - 1 for a in input().split()]", "A", "count += 1", "1", "count" ]
N = int(input()) A = [int(a) - 1 for a in input().split()] liked = [set() for _ in range(N)] for i in range(N): liked[A[i]].add(i) count = 0 for i in range(N): if A[i] in liked[i]: count += 1 print(count // 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, 4, 39, 0, 13, 13, 0, 13, 17, 28, 13, 4, 13, 13, 4, 18, 18, 13, 2, 18, 13, 13, 17, 13, 13, 14, 2, 2, 18, 13, 13, 17, 18, 13, 13, 0, 13, 17, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 13, 13, 10, 17, 13 ]
[ [ 66, 2 ], [ 69, 8 ], [ 22, 21 ], [ 67, 24 ], [ 75, 28 ], [ 72, 31 ], [ 35, 34 ], [ 67, 37 ], [ 76, 41 ], [ 70, 44 ], [ 34, 45 ], [ 34, 48 ], [ 70, 53 ], [ 34, 54 ], [ 76, 57 ], [ 34, 58 ], [ 78, 60 ], [ 79, 64 ], [ 73, 64 ], [ 66, 67 ], [ 69, 70 ], [ 72, 73 ], [ 75, 76 ], [ 78, 79 ] ]
[ "n=int(input())\na=list(map(int,input().split()))\nl=[[] for i in range(n)]\nans=0\nfor i in range(n):\n l[a[i]-1].append(i)\n if a[i]-1 in l[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", "[] for i in range(n)", "for i in range(n)", "i", "range(n)", "range", "n", "for i in range(n)", "[]", "l=[[] for i in range(n)]", "l", "[[] for i in range(n)]", "ans=0", "ans", "0", "for i in range(n):\n l[a[i]-1].append(i)\n if a[i]-1 in l[i]:\n ans+=1", "i", "range(n)", "range", "n", "l[a[i]-1].append(i)", "[a[i]-1].append", "[a[i]-1]", "l", "a[i]-1", "a[i]", "a", "i", "1", "append", "i", "if a[i]-1 in l[i]:\n ans+=1", "a[i]-1 in l[i]", "a[i]-1", "a[i]", "a", "i", "1", "l[i]", "l", "i", "ans+=1", "ans", "1", "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", "l=[[] for i in range(n)]", "[[] for i in range(n)]", "l", "ans+=1", "1", "ans" ]
n=int(input()) a=list(map(int,input().split())) l=[[] for i in range(n)] ans=0 for i in range(n): l[a[i]-1].append(i) if a[i]-1 in l[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, 0, 13, 2, 39, 17, 13, 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, 17, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 62, 2 ], [ 59, 8 ], [ 53, 20 ], [ 56, 23 ], [ 60, 27 ], [ 30, 29 ], [ 63, 32 ], [ 29, 35 ], [ 57, 37 ], [ 60, 37 ], [ 57, 39 ], [ 60, 39 ], [ 29, 40 ], [ 50, 42 ], [ 51, 47 ], [ 54, 47 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ] ]
[ "n = int(input())\na = list(map(int,input().split()))\nc = 0\na = [0] + a\nfor i in range(n):\n if i == a[a[i]]:\n c += 1\nelse:\n print(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", "c = 0", "c", "0", "a = [0] + a", "a", "[0] + a", "[0]", "0", "a", "for i in range(n):\n if i == a[a[i]]:\n c += 1\nelse:\n print(c//2)", "i", "range(n)", "range", "n", "if i == a[a[i]]:\n c += 1", "i == a[a[i]]", "i", "a[a[i]]", "a", "a[i]", "a", "i", "c += 1", "c", "1", "print(c//2)", "print", "c//2", "c", "2", "c += 1", "1", "c", "c = 0", "0", "c", "a = [0] + a", "[0] + a", "a", "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())) c = 0 a = [0] + a for i in range(n): if i == a[a[i]]: c += 1 else: print(c//2)
[ 7, 15, 15, 15, 15, 15, 15, 13, 15, 13, 4, 18, 13, 13, 17, 0, 13, 2, 2, 17, 17, 17, 12, 13, 29, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 12, 13, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 41, 28, 13, 4, 13, 13, 4, 17, 0, 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, 13, 18, 13, 18, 13, 13, 0, 13, 17, 4, 13, 2, 13, 17, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 2, 13, 10, 12, 13 ]
[ [ 106, 16 ], [ 39, 38 ], [ 45, 44 ], [ 110, 46 ], [ 50, 49 ], [ 38, 52 ], [ 57, 56 ], [ 60, 59 ], [ 38, 62 ], [ 67, 64 ], [ 56, 65 ], [ 59, 66 ], [ 44, 69 ], [ 59, 70 ], [ 74, 73 ], [ 77, 76 ], [ 38, 79 ], [ 76, 82 ], [ 56, 84 ], [ 64, 85 ], [ 56, 86 ], [ 76, 87 ], [ 90, 89 ], [ 89, 94 ], [ 73, 94 ], [ 104, 101 ], [ 106, 107 ] ]
[ "from statistics import median\n#import collections\n#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]\nfrom fractions import gcd\nfrom itertools import combinations # (string,3) 3回\nfrom collections import deque\nfrom collections import defaultdict\nimport bisect\n#\n# d = m - k[i] - k[j]\n# if kk[bisect.bisect_right(kk,d) - 1] == d:\n#\n#\n#\n# pythonで無理なときは、pypyでやると正解するかも!!\n#\n#\n\nimport sys\nsys.setrecursionlimit(10000000)\nmod = 10**9 + 7\n\ndef readInts():\n return list(map(int,input().split()))\n\ndef main():\n n = int(input())\n A = readInts()\n Pa = [0 for _ in range(n)]\n for i in range(n):\n Pa[i] = A[i] - 1\n cnt = 0\n for i in range(n):\n if i == Pa[Pa[i]]:\n cnt += 1\n print(cnt//2)\nif __name__ == '__main__':\n main()", "from statistics import median", "from fractions import gcd", "from itertools import combinations", "from collections import deque", "from collections import defaultdict", "import bisect", "bisect", "import sys", "sys", "sys.setrecursionlimit(10000000)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10000000", "mod = 10**9 + 7", "mod", "10**9 + 7", "10**9", "10", "9", "7", "def readInts():\n return list(map(int,input().split()))", "readInts", "return list(map(int,input().split()))", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "def main():\n n = int(input())\n A = readInts()\n Pa = [0 for _ in range(n)]\n for i in range(n):\n Pa[i] = A[i] - 1\n cnt = 0\n for i in range(n):\n if i == Pa[Pa[i]]:\n cnt += 1\n print(cnt//2)", "main", "n = int(input())", "n", "int(input())", "int", "input()", "input", "A = readInts()", "A", "readInts()", "readInts", "0 for _ in range(n)", "for _ in range(n)", "_", "range(n)", "range", "n", "for _ in range(n)", "0", "Pa = [0 for _ in range(n)]", "Pa", "[0 for _ in range(n)]", "for i in range(n):\n Pa[i] = A[i] - 1\n ", "i", "range(n)", "range", "n", "Pa[i] = A[i] - 1", "Pa[i]", "Pa", "i", "A[i] - 1", "A[i]", "A", "i", "1", "cnt = 0", "cnt", "0", "for i in range(n):\n if i == Pa[Pa[i]]:\n cnt += 1\n ", "i", "range(n)", "range", "n", "if i == Pa[Pa[i]]:\n cnt += 1\n ", "i == Pa[Pa[i]]", "i", "Pa[Pa[i]]", "Pa", "Pa[i]", "Pa", "i", "cnt += 1", "cnt", "1", "print(cnt//2)", "print", "cnt//2", "cnt", "2", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def main():\n n = int(input())\n A = readInts()\n Pa = [0 for _ in range(n)]\n for i in range(n):\n Pa[i] = A[i] - 1\n cnt = 0\n for i in range(n):\n if i == Pa[Pa[i]]:\n cnt += 1\n print(cnt//2)", "def main():\n n = int(input())\n A = readInts()\n Pa = [0 for _ in range(n)]\n for i in range(n):\n Pa[i] = A[i] - 1\n cnt = 0\n for i in range(n):\n if i == Pa[Pa[i]]:\n cnt += 1\n print(cnt//2)", "main", "mod = 10**9 + 7", "10**9 + 7", "mod", "def readInts():\n return list(map(int,input().split()))", "def readInts():\n return list(map(int,input().split()))", "readInts" ]
from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations # (string,3) 3回 from collections import deque from collections import defaultdict import bisect # # d = m - k[i] - k[j] # if kk[bisect.bisect_right(kk,d) - 1] == d: # # # # pythonで無理なときは、pypyでやると正解するかも!! # # import sys sys.setrecursionlimit(10000000) mod = 10**9 + 7 def readInts(): return list(map(int,input().split())) def main(): n = int(input()) A = readInts() Pa = [0 for _ in range(n)] for i in range(n): Pa[i] = A[i] - 1 cnt = 0 for i in range(n): if i == Pa[Pa[i]]: cnt += 1 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, 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\n\nfor i in range(N):\n if A[A[i]-1] == i + 1:\n count += 1\n\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, 15, 13, 13, 15, 15, 15, 4, 18, 13, 13, 2, 17, 17, 0, 13, 2, 2, 17, 17, 17, 12, 13, 29, 18, 4, 18, 18, 13, 13, 13, 39, 17, 12, 13, 29, 4, 13, 13, 4, 18, 4, 13, 13, 12, 13, 29, 4, 13, 4, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 4, 13, 0, 13, 13, 41, 28, 13, 4, 13, 31, 13, 4, 4, 13, 13, 29, 13, 23, 13, 12, 13, 0, 13, 4, 13, 0, 13, 4, 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, 14, 2, 13, 17, 4, 13, 10, 2, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 129, 15 ], [ 142, 42 ], [ 142, 50 ], [ 56, 55 ], [ 81, 58 ], [ 136, 63 ], [ 66, 65 ], [ 70, 69 ], [ 65, 73 ], [ 69, 77 ], [ 81, 81 ], [ 86, 85 ], [ 145, 87 ], [ 90, 89 ], [ 136, 93 ], [ 96, 95 ], [ 99, 98 ], [ 85, 101 ], [ 89, 105 ], [ 89, 108 ], [ 98, 109 ], [ 98, 112 ], [ 116, 115 ], [ 115, 120 ], [ 95, 120 ], [ 139, 127 ], [ 129, 130 ] ]
[ "import sys, math\nfrom functools import lru_cache\nfrom collections import defaultdict\nfrom decimal import Decimal\nsys.setrecursionlimit(10**9)\nMOD = 10**9+7\n\ndef input():\n return sys.stdin.readline()[:-1]\n\ndef mi():\n return map(int, input().split())\n\ndef ii():\n return int(input())\n\ndef i2(n):\n tmp = [list(mi()) for i in range(n)]\n return [list(i) for i in zip(*tmp)]\n\ndef main():\n N = ii()\n a = list(mi())\n cnt = 0\n for i in range(N):\n if a[a[i]-1] == i+1:\n cnt += 1\n\n print(cnt//2)\n\nif __name__ == '__main__':\n main()", "import sys, math", "sys", "math", "from functools import lru_cache", "from collections import defaultdict", "from decimal import Decimal", "sys.setrecursionlimit(10**9)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10**9", "10", "9", "MOD = 10**9+7", "MOD", "10**9+7", "10**9", "10", "9", "7", "def input():\n return sys.stdin.readline()[:-1]", "input", "return sys.stdin.readline()[:-1]", "sys.stdin.readline()[:-1]", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", ":-1", "-1", "def mi():\n return map(int, input().split())", "mi", "return map(int, input().split())", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "def ii():\n return int(input())", "ii", "return int(input())", "int(input())", "int", "input()", "input", "def i2(n):\n tmp = [list(mi()) for i in range(n)]\n return [list(i) for i in zip(*tmp)]", "i2", "list(mi()) for i in range(n)", "for i in range(n)", "i", "range(n)", "range", "n", "for i in range(n)", "list(mi())", "list", "mi()", "mi", "tmp = [list(mi()) for i in range(n)]", "tmp", "[list(mi()) for i in range(n)]", "list(i) for i in zip(*tmp)", "for i in zip(*tmp)", "i", "zip(*tmp)", "zip", "*tmp", "tmp", "for i in zip(*tmp)", "list(i)", "list", "i", "return [list(i) for i in zip(*tmp)]", "[list(i) for i in zip(*tmp)]", "n", "n", "def main():\n N = ii()\n a = list(mi())\n cnt = 0\n for i in range(N):\n if a[a[i]-1] == i+1:\n cnt += 1\n\n print(cnt//2)", "main", "N = ii()", "N", "ii()", "ii", "a = list(mi())", "a", "list(mi())", "list", "mi()", "mi", "cnt = 0", "cnt", "0", "for i in range(N):\n if a[a[i]-1] == i+1:\n cnt += 1\n\n ", "i", "range(N)", "range", "N", "if a[a[i]-1] == i+1:\n cnt += 1\n\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", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "MOD = 10**9+7", "10**9+7", "MOD", "def i2(n):\n tmp = [list(mi()) for i in range(n)]\n return [list(i) for i in zip(*tmp)]", "def i2(n):\n tmp = [list(mi()) for i in range(n)]\n return [list(i) for i in zip(*tmp)]", "i2", "def mi():\n return map(int, input().split())", "def mi():\n return map(int, input().split())", "mi", "def main():\n N = ii()\n a = list(mi())\n cnt = 0\n for i in range(N):\n if a[a[i]-1] == i+1:\n cnt += 1\n\n print(cnt//2)", "def main():\n N = ii()\n a = list(mi())\n cnt = 0\n for i in range(N):\n if a[a[i]-1] == i+1:\n cnt += 1\n\n print(cnt//2)", "main", "def input():\n return sys.stdin.readline()[:-1]", "def input():\n return sys.stdin.readline()[:-1]", "input", "def ii():\n return int(input())", "def ii():\n return int(input())", "ii" ]
import sys, math from functools import lru_cache from collections import defaultdict from decimal import Decimal sys.setrecursionlimit(10**9) MOD = 10**9+7 def input(): return sys.stdin.readline()[:-1] def mi(): return map(int, input().split()) def ii(): return int(input()) def i2(n): tmp = [list(mi()) for i in range(n)] return [list(i) for i in zip(*tmp)] def main(): N = ii() a = list(mi()) cnt = 0 for i in range(N): if a[a[i]-1] == i+1: cnt += 1 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, 2, 39, 17, 13, 0, 13, 17, 28, 13, 4, 13, 17, 13, 0, 13, 18, 13, 13, 14, 2, 2, 13, 13, 2, 18, 13, 13, 13, 0, 13, 17, 4, 13, 13, 10, 2, 13, 10, 18, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 65, 2 ], [ 68, 8 ], [ 56, 20 ], [ 69, 24 ], [ 71, 26 ], [ 30, 29 ], [ 66, 33 ], [ 59, 35 ], [ 57, 37 ], [ 69, 37 ], [ 29, 38 ], [ 60, 42 ], [ 29, 43 ], [ 57, 46 ], [ 69, 46 ], [ 60, 47 ], [ 29, 48 ], [ 62, 50 ], [ 63, 54 ], [ 72, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ] ]
[ "n=int(input())\na=list(map(int,input().split()))\na = [None] + a\ncnt = 0\nfor i in range(1, n):\n j = a[i]\n if j > i and a[j] == i:\n cnt += 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", "a = [None] + a", "a", "[None] + a", "[None]", "None", "a", "cnt = 0", "cnt", "0", "for i in range(1, n):\n j = a[i]\n if j > i and a[j] == i:\n cnt += 1", "i", "range(1, n)", "range", "1", "n", "j = a[i]", "j", "a[i]", "a", "i", "if j > i and a[j] == i:\n cnt += 1", "j > i and a[j] == i", "j > i", "j", "i", "a[j] == i", "a[j]", "a", "j", "i", "cnt += 1", "cnt", "1", "print(cnt)", "print", "cnt", "a = [None] + a", "[None] + a", "a", "j = a[i]", "a[i]", "j", "cnt += 1", "1", "cnt", "n=int(input())", "int(input())", "n", "a=list(map(int,input().split()))", "list(map(int,input().split()))", "a", "cnt = 0", "0", "cnt" ]
n=int(input()) a=list(map(int,input().split())) a = [None] + a cnt = 0 for i in range(1, n): j = a[i] if j > i and a[j] == i: cnt += 1 print(cnt)
[ 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, 13, 4, 13, 13, 14, 2, 18, 13, 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 ], [ 24, 34 ], [ 24, 38 ], [ 43, 42 ], [ 42, 47 ], [ 27, 47 ], [ 57, 54 ] ]
[ "def main():\n N = int(input())\n A = [int(i)-1 for i in input().split()]\n\n ans = 0\n for i, a in enumerate(A):\n if A[a] == i:\n ans += 1\n print(ans//2)\n\n\nif __name__ == '__main__':\n main()", "def main():\n N = int(input())\n A = [int(i)-1 for i in input().split()]\n\n ans = 0\n for i, a in enumerate(A):\n if A[a] == i:\n ans += 1\n print(ans//2)", "main", "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()]", "ans = 0", "ans", "0", "for i, a in enumerate(A):\n if A[a] == i:\n ans += 1\n ", "i", "a", "enumerate(A)", "enumerate", "A", "if A[a] == i:\n ans += 1\n ", "A[a] == i", "A[a]", "A", "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(i)-1 for i in input().split()]\n\n ans = 0\n for i, a in enumerate(A):\n if A[a] == i:\n ans += 1\n print(ans//2)", "def main():\n N = int(input())\n A = [int(i)-1 for i in input().split()]\n\n ans = 0\n for i, a in enumerate(A):\n if A[a] == i:\n ans += 1\n print(ans//2)", "main" ]
def main(): N = int(input()) A = [int(i)-1 for i in input().split()] ans = 0 for i, a in enumerate(A): if A[a] == i: 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, 17, 28, 13, 4, 13, 13, 14, 2, 2, 2, 13, 17, 18, 13, 2, 18, 13, 13, 17, 2, 13, 18, 13, 13, 0, 13, 17, 4, 13, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 61, 2 ], [ 55, 8 ], [ 52, 20 ], [ 24, 23 ], [ 62, 26 ], [ 23, 31 ], [ 56, 34 ], [ 56, 37 ], [ 23, 38 ], [ 23, 41 ], [ 56, 43 ], [ 23, 44 ], [ 58, 46 ], [ 59, 50 ], [ 53, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ] ]
[ "n = int(input())\na = list(map(int, input().split()))\ncnt = 0\nfor i in range(n):\n if i + 1 == a[a[i] - 1] and i < a[i]:\n cnt += 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 i + 1 == a[a[i] - 1] and i < a[i]:\n cnt += 1", "i", "range(n)", "range", "n", "if i + 1 == a[a[i] - 1] and i < a[i]:\n cnt += 1", "i + 1 == a[a[i] - 1] and i < a[i]", "i + 1 == a[a[i] - 1]", "i + 1", "i", "1", "a[a[i] - 1]", "a", "a[i] - 1", "a[i]", "a", "i", "1", "i < a[i]", "i", "a[i]", "a", "i", "cnt += 1", "cnt", "1", "print(cnt)", "print", "cnt", "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 i in range(n): if i + 1 == a[a[i] - 1] and i < a[i]: cnt += 1 print(cnt)
[ 7, 15, 13, 0, 13, 18, 18, 13, 13, 13, 12, 13, 0, 13, 17, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 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, 10, 18, 13, 10, 12, 13 ]
[ [ 65, 4 ], [ 14, 13 ], [ 17, 16 ], [ 66, 20 ], [ 23, 22 ], [ 66, 31 ], [ 35, 34 ], [ 16, 37 ], [ 22, 41 ], [ 22, 44 ], [ 34, 45 ], [ 34, 48 ], [ 52, 51 ], [ 51, 56 ], [ 13, 56 ], [ 69, 63 ], [ 65, 66 ] ]
[ "import sys\n\ninput = sys.stdin.readline\n\ndef main():\n ans = 0\n n = int(input())\n a = list(map(int, input().split()))\n for i in range(n):\n if a[a[i]-1] == i+1:\n ans +=1\n print(ans//2)\n\nif __name__ == '__main__':\n main()", "import sys", "sys", "input = sys.stdin.readline", "input", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "def main():\n ans = 0\n n = int(input())\n a = list(map(int, input().split()))\n for i in range(n):\n if a[a[i]-1] == i+1:\n ans +=1\n print(ans//2)", "main", "ans = 0", "ans", "0", "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 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 main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "input = sys.stdin.readline", "sys.stdin.readline", "input", "def main():\n ans = 0\n n = int(input())\n a = list(map(int, input().split()))\n for i in range(n):\n if a[a[i]-1] == i+1:\n ans +=1\n print(ans//2)", "def main():\n ans = 0\n n = int(input())\n a = list(map(int, input().split()))\n for i in range(n):\n if a[a[i]-1] == i+1:\n ans +=1\n print(ans//2)", "main" ]
import sys input = sys.stdin.readline def main(): ans = 0 n = int(input()) a = list(map(int, input().split())) for i in range(n): if a[a[i]-1] == i+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, 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, 17, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 64, 2 ], [ 70, 8 ], [ 67, 20 ], [ 24, 23 ], [ 65, 26 ], [ 71, 30 ], [ 23, 31 ], [ 71, 36 ], [ 71, 39 ], [ 23, 40 ], [ 23, 43 ], [ 61, 46 ], [ 56, 49 ], [ 71, 50 ], [ 71, 53 ], [ 23, 54 ], [ 62, 59 ], [ 68, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ], [ 70, 71 ] ]
[ "N = int(input())\na = list(map(int, input().split()))\ncnt = 0\n\nfor i in range(N):\n if a[i] == -1:\n pass\n else:\n if 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] == -1:\n pass\n else:\n if a[a[i]-1] == i+1:\n cnt += 1\n a[a[i]-1] = -1", "i", "range(N)", "range", "N", "if a[i] == -1:\n pass\n else:\n if a[a[i]-1] == i+1:\n cnt += 1\n a[a[i]-1] = -1", "a[i] == -1", "a[i]", "a", "i", "-1", "if a[a[i]-1] == i+1:\n cnt += 1\n 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", "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", "cnt += 1", "1", "cnt", "N = int(input())", "int(input())", "N", "cnt = 0", "0", "cnt", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a" ]
N = int(input()) a = list(map(int, input().split())) cnt = 0 for i in range(N): if a[i] == -1: pass else: if 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, 41, 28, 13, 13, 4, 2, 13, 17, 0, 13, 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, 17, 13, 10, 13, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 63, 2 ], [ 66, 8 ], [ 22, 21 ], [ 67, 21 ], [ 21, 25 ], [ 57, 28 ], [ 54, 31 ], [ 58, 38 ], [ 67, 38 ], [ 58, 42 ], [ 67, 42 ], [ 60, 46 ], [ 61, 51 ], [ 55, 51 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ] ]
[ "n = int(input())\nA = list(map(int, input().split()))\nA = [a - 1 for a in A]\ncount = 0\nfor i, a in enumerate(A):\n\tif A[a] == i:\n\t\tcount += 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", "a - 1 for a in A", "for a in A", "a", "A", "for a in A", "a - 1", "a", "1", "A = [a - 1 for a in A]", "A", "[a - 1 for a in A]", "count = 0", "count", "0", "for i, a in enumerate(A):\n\tif A[a] == i:\n\t\tcount += 1", "i", "a", "enumerate(A)", "enumerate", "A", "if A[a] == i:\n\t\tcount += 1", "A[a] == i", "A[a]", "A", "a", "i", "count += 1", "count", "1", "print(count//2)", "print", "count//2", "count", "2", "count = 0", "0", "count", "A = [a - 1 for a in A]", "[a - 1 for a in A]", "A", "count += 1", "1", "count", "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())) A = [a - 1 for a in A] count = 0 for i, a in enumerate(A): if A[a] == i: count += 1 print(count//2)
[ 7, 0, 13, 4, 13, 4, 13, 0, 31, 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, 17, 13, 10, 4, 13 ]
[ [ 53, 2 ], [ 10, 8 ], [ 50, 19 ], [ 23, 22 ], [ 54, 25 ], [ 22, 29 ], [ 22, 36 ], [ 47, 39 ], [ 48, 44 ], [ 51, 44 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ] ]
[ "N = int(input())\n*a, = map(int, input().split())\n\ncount = 0\nfor i in range(N):\n # print(a[a[i]-1])\n if i + 1 == a[a[i]-1]:\n count += 1\n\nprint(count//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", "count = 0", "count", "0", "for i in range(N):\n # print(a[a[i]-1])\n if i + 1 == a[a[i]-1]:\n count += 1", "i", "range(N)", "range", "N", "if i + 1 == a[a[i]-1]:\n count += 1", "i + 1 == a[a[i]-1]", "i + 1", "i", "1", "a[a[i]-1]", "a", "a[i]-1", "a[i]", "a", "i", "1", "count += 1", "count", "1", "print(count//2)", "print", "count//2", "count", "2", "count += 1", "1", "count", "count = 0", "0", "count", "N = int(input())", "int(input())", "N" ]
N = int(input()) *a, = map(int, input().split()) count = 0 for i in range(N): # print(a[a[i]-1]) if i + 1 == a[a[i]-1]: 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, 28, 13, 13, 4, 13, 13, 0, 13, 2, 17, 13, 14, 2, 13, 2, 18, 13, 2, 13, 17, 17, 0, 13, 17, 4, 13, 2, 13, 17, 10, 2, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 64, 2 ], [ 58, 8 ], [ 61, 20 ], [ 59, 27 ], [ 52, 29 ], [ 59, 38 ], [ 55, 44 ], [ 56, 49 ], [ 62, 49 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ] ]
[ "N=int(input())\nA=list(map(int,input().split()))\ncnt=0\nfor idx,i in enumerate(A):\n a_idx=1+idx\n\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 a_idx=1+idx\n\n if idx==A[i-1]-1:\n cnt+=1", "idx", "i", "enumerate(A)", "enumerate", "A", "a_idx=1+idx", "a_idx", "1+idx", "1", "idx", "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", "a_idx=1+idx", "1+idx", "a_idx", "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 idx,i in enumerate(A): a_idx=1+idx if idx==A[i-1]-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, 17, 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, 4, 13, 10, 17, 13 ]
[ [ 55, 2 ], [ 52, 8 ], [ 58, 21 ], [ 25, 24 ], [ 56, 27 ], [ 24, 31 ], [ 53, 34 ], [ 53, 37 ], [ 24, 38 ], [ 49, 41 ], [ 50, 46 ], [ 59, 46 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ] ]
[ "n=int(input())\na = list(map(int, input().split(\" \")))\ncount = 0\nfor i in range(n):\n if i + 1 == a[a[i] - 1]:\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 i in range(n):\n if i + 1 == a[a[i] - 1]:\n count += 1", "i", "range(n)", "range", "n", "if i + 1 == a[a[i] - 1]:\n count += 1", "i + 1 == a[a[i] - 1]", "i + 1", "i", "1", "a[a[i] - 1]", "a", "a[i] - 1", "a[i]", "a", "i", "1", "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" ]
n=int(input()) a = list(map(int, input().split(" "))) count = 0 for i in range(n): if i + 1 == a[a[i] - 1]: count += 1 print(count // 2)
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 18, 4, 13, 17, 13, 13, 31, 13, 4, 13, 2, 4, 13, 2, 18, 13, 2, 18, 13, 2, 13, 17, 17, 13, 17, 10, 4, 13 ]
[ [ 35, 2 ], [ 35, 15 ], [ 35, 36 ] ]
[ "N,*A=map(int, open(0).read().split())\nprint(sum(A[A[i-1]-1]==i for i in range(1,N+1))//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(A[A[i-1]-1]==i for i in range(1,N+1))//2)", "print", "sum(A[A[i-1]-1]==i for i in range(1,N+1))//2", "sum(A[A[i-1]-1]==i for i in range(1,N+1))", "sum", "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", "i", "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(A[A[i-1]-1]==i for i in range(1,N+1))//2)
[ 7, 12, 13, 15, 13, 0, 13, 18, 18, 13, 13, 13, 4, 18, 13, 13, 2, 17, 17, 15, 15, 15, 15, 15, 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, 10, 12, 13 ]
[ [ 7, 6 ], [ 26, 25 ], [ 6, 29 ], [ 32, 31 ], [ 6, 40 ], [ 44, 43 ], [ 47, 46 ], [ 25, 49 ], [ 31, 53 ], [ 31, 56 ], [ 46, 57 ], [ 46, 60 ], [ 64, 63 ], [ 63, 68 ], [ 43, 68 ], [ 78, 75 ] ]
[ "def main():\n import sys\n input = sys.stdin.readline\n sys.setrecursionlimit(10**7)\n from collections import Counter, deque\n #from collections import defaultdict\n from itertools import combinations, permutations, accumulate, groupby, product\n from bisect import bisect_left,bisect_right\n from heapq import heapify, heappop, heappush\n from math import floor, ceil\n #from operator import itemgetter\n\n #inf = 10**17\n #mod = 10**9 + 7\n\n n = int(input())\n a = list(map(int, input().split()))\n res = 0\n for i in range(n):\n if a[a[i]-1] == i+1:\n res += 1\n print(res//2)\n\nif __name__ == '__main__':\n main()", "def main():\n import sys\n input = sys.stdin.readline\n sys.setrecursionlimit(10**7)\n from collections import Counter, deque\n #from collections import defaultdict\n from itertools import combinations, permutations, accumulate, groupby, product\n from bisect import bisect_left,bisect_right\n from heapq import heapify, heappop, heappush\n from math import floor, ceil\n #from operator import itemgetter\n\n #inf = 10**17\n #mod = 10**9 + 7\n\n n = int(input())\n a = list(map(int, input().split()))\n res = 0\n for i in range(n):\n if a[a[i]-1] == i+1:\n res += 1\n print(res//2)", "main", "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", "from collections import Counter, deque", "from itertools import combinations, permutations, accumulate, groupby, product", "from bisect import bisect_left,bisect_right", "from heapq import heapify, heappop, heappush", "from math import floor, ceil", "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 in range(n):\n if a[a[i]-1] == i+1:\n res += 1\n ", "i", "range(n)", "range", "n", "if a[a[i]-1] == i+1:\n res += 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", "res += 1", "res", "1", "print(res//2)", "print", "res//2", "res", "2", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def main():\n import sys\n input = sys.stdin.readline\n sys.setrecursionlimit(10**7)\n from collections import Counter, deque\n #from collections import defaultdict\n from itertools import combinations, permutations, accumulate, groupby, product\n from bisect import bisect_left,bisect_right\n from heapq import heapify, heappop, heappush\n from math import floor, ceil\n #from operator import itemgetter\n\n #inf = 10**17\n #mod = 10**9 + 7\n\n n = int(input())\n a = list(map(int, input().split()))\n res = 0\n for i in range(n):\n if a[a[i]-1] == i+1:\n res += 1\n print(res//2)", "def main():\n import sys\n input = sys.stdin.readline\n sys.setrecursionlimit(10**7)\n from collections import Counter, deque\n #from collections import defaultdict\n from itertools import combinations, permutations, accumulate, groupby, product\n from bisect import bisect_left,bisect_right\n from heapq import heapify, heappop, heappush\n from math import floor, ceil\n #from operator import itemgetter\n\n #inf = 10**17\n #mod = 10**9 + 7\n\n n = int(input())\n a = list(map(int, input().split()))\n res = 0\n for i in range(n):\n if a[a[i]-1] == i+1:\n res += 1\n print(res//2)", "main" ]
def main(): import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque #from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby, product from bisect import bisect_left,bisect_right from heapq import heapify, heappop, heappush from math import floor, ceil #from operator import itemgetter #inf = 10**17 #mod = 10**9 + 7 n = int(input()) a = list(map(int, input().split())) res = 0 for i in range(n): if a[a[i]-1] == i+1: res += 1 print(res//2) 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, 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, 4, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 50, 4 ], [ 59, 10 ], [ 53, 22 ], [ 26, 25 ], [ 51, 28 ], [ 25, 32 ], [ 60, 35 ], [ 60, 38 ], [ 25, 39 ], [ 56, 42 ], [ 57, 47 ], [ 54, 47 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ] ]
[ "import collections\n\nn = int(input())\na = list(map(int, input().split()))\nans = 0\n\nfor i in range(n):\n if i+1 == a[a[i]-1]:\n ans += 1\n\nprint(ans//2)", "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", "ans = 0", "ans", "0", "for i in range(n):\n if i+1 == a[a[i]-1]:\n ans += 1", "i", "range(n)", "range", "n", "if i+1 == a[a[i]-1]:\n ans += 1", "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", "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 collections n = int(input()) a = list(map(int, input().split())) ans = 0 for i in range(n): if i+1 == a[a[i]-1]: ans += 1 print(ans//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, 39, 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, 17, 13, 10, 17, 13, 10, 4, 13, 10, 13, 13, 10, 39, 13 ]
[ [ 60, 2 ], [ 10, 9 ], [ 9, 18 ], [ 63, 20 ], [ 66, 23 ], [ 54, 26 ], [ 30, 29 ], [ 61, 32 ], [ 64, 36 ], [ 64, 39 ], [ 29, 40 ], [ 29, 43 ], [ 57, 46 ], [ 58, 51 ], [ 55, 51 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ] ]
[ "N = int(input())\nA = [int(x) for x in input().split()]\n\nlike = []\ncnt = 0\nfor i in range(N):\n if A[A[i]-1] == i+1:\n cnt+=1\nprint(cnt//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()]", "like = []", "like", "[]", "cnt = 0", "cnt", "0", "for i in range(N):\n if A[A[i]-1] == i+1:\n cnt+=1", "i", "range(N)", "range", "N", "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 = 0", "0", "cnt", "cnt+=1", "1", "cnt", "N = int(input())", "int(input())", "N", "A = [int(x) for x in input().split()]", "[int(x) for x in input().split()]", "A", "like = []", "[]", "like" ]
N = int(input()) A = [int(x) for x in input().split()] like = [] cnt = 0 for i in range(N): if A[A[i]-1] == i+1: cnt+=1 print(cnt//2)
[ 7, 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, 18, 13, 13, 0, 13, 17, 4, 13, 2, 13, 17, 10, 17, 13, 10, 2, 13, 10, 17, 13 ]
[ [ 45, 4 ], [ 48, 19 ], [ 46, 26 ], [ 46, 31 ], [ 42, 34 ], [ 43, 39 ], [ 49, 39 ], [ 42, 43 ], [ 45, 46 ], [ 48, 49 ] ]
[ "input()\na = [0] + list(map(int, input().split()))\ncnt = 0\nfor i, target in enumerate(a):\n\tif i == a[target]:\n\t\tcnt += 1\nprint(cnt // 2)", "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, target in enumerate(a):\n\tif i == a[target]:\n\t\tcnt += 1", "i", "target", "enumerate(a)", "enumerate", "a", "if i == a[target]:\n\t\tcnt += 1", "i == a[target]", "i", "a[target]", "a", "target", "cnt += 1", "cnt", "1", "print(cnt // 2)", "print", "cnt // 2", "cnt", "2", "cnt += 1", "1", "cnt", "a = [0] + list(map(int, input().split()))", "[0] + list(map(int, input().split()))", "a", "cnt = 0", "0", "cnt" ]
input() a = [0] + list(map(int, input().split())) cnt = 0 for i, target in enumerate(a): if i == a[target]: cnt += 1 print(cnt // 2)
[ 7, 15, 13, 15, 13, 15, 13, 4, 18, 13, 13, 17, 15, 0, 13, 2, 2, 17, 17, 17, 15, 13, 15, 13, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 39, 28, 13, 4, 13, 4, 13, 13, 0, 13, 39, 13, 2, 18, 13, 13, 17, 4, 18, 13, 13, 4, 18, 13, 13, 13, 4, 18, 13, 13, 0, 13, 17, 28, 13, 4, 13, 2, 4, 13, 13, 17, 14, 2, 18, 13, 13, 18, 13, 2, 13, 17, 0, 13, 17, 4, 13, 13, 10, 4, 13, 10, 39, 13, 10, 17, 13, 10, 2, 13, 10, 4, 13, 10, 17, 13, 10, 39, 13 ]
[ [ 112, 14 ], [ 115, 25 ], [ 103, 31 ], [ 121, 43 ], [ 47, 46 ], [ 104, 51 ], [ 106, 53 ], [ 104, 58 ], [ 46, 59 ], [ 107, 63 ], [ 122, 67 ], [ 107, 69 ], [ 122, 72 ], [ 118, 75 ], [ 79, 78 ], [ 122, 84 ], [ 122, 89 ], [ 78, 90 ], [ 122, 92 ], [ 78, 94 ], [ 109, 97 ], [ 110, 101 ], [ 119, 101 ], [ 103, 104 ], [ 106, 107 ], [ 109, 110 ], [ 112, 113 ], [ 115, 116 ], [ 118, 119 ], [ 121, 122 ] ]
[ "import collections\nimport sys\nimport numpy as np\nsys.setrecursionlimit(1000000000)\nfrom heapq import heapify,heappop,heappush,heappushpop\nMOD = 10**9+7\nimport itertools\nimport math\n\nn = int(input())\na = list(map(int,input().split()))\npair = []\nfor i in range(len(a)):\n koho = [i,a[i]-1]\n koho.sort()\n pair.append(koho)\npair.sort()\ncnt = 0\nfor i in range(len(pair)-1):\n if pair[i] == pair[i+1]:\n cnt+=1\nprint(cnt)", "import collections", "collections", "import sys", "sys", "import numpy as np", "numpy", "sys.setrecursionlimit(1000000000)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "1000000000", "from heapq import heapify,heappop,heappush,heappushpop", "MOD = 10**9+7", "MOD", "10**9+7", "10**9", "10", "9", "7", "import itertools", "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", "pair = []", "pair", "[]", "for i in range(len(a)):\n koho = [i,a[i]-1]\n koho.sort()\n pair.append(koho)", "i", "range(len(a))", "range", "len(a)", "len", "a", "koho = [i,a[i]-1]", "koho", "[i,a[i]-1]", "i", "a[i]-1", "a[i]", "a", "i", "1", "koho.sort()", "koho.sort", "koho", "sort", "pair.append(koho)", "pair.append", "pair", "append", "koho", "pair.sort()", "pair.sort", "pair", "sort", "cnt = 0", "cnt", "0", "for i in range(len(pair)-1):\n if pair[i] == pair[i+1]:\n cnt+=1", "i", "range(len(pair)-1)", "range", "len(pair)-1", "len(pair)", "len", "pair", "1", "if pair[i] == pair[i+1]:\n cnt+=1", "pair[i] == pair[i+1]", "pair[i]", "pair", "i", "pair[i+1]", "pair", "i+1", "i", "1", "cnt+=1", "cnt", "1", "print(cnt)", "print", "cnt", "a = list(map(int,input().split()))", "list(map(int,input().split()))", "a", "koho = [i,a[i]-1]", "[i,a[i]-1]", "koho", "cnt+=1", "1", "cnt", "MOD = 10**9+7", "10**9+7", "MOD", "n = int(input())", "int(input())", "n", "cnt = 0", "0", "cnt", "pair = []", "[]", "pair" ]
import collections import sys import numpy as np sys.setrecursionlimit(1000000000) from heapq import heapify,heappop,heappush,heappushpop MOD = 10**9+7 import itertools import math n = int(input()) a = list(map(int,input().split())) pair = [] for i in range(len(a)): koho = [i,a[i]-1] koho.sort() pair.append(koho) pair.sort() cnt = 0 for i in range(len(pair)-1): if pair[i] == pair[i+1]: cnt+=1 print(cnt)
[ 7, 12, 13, 15, 13, 0, 13, 4, 13, 4, 13, 0, 13, 4, 18, 13, 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, 8, 2, 2, 13, 17, 17, 4, 13, 13, 4, 13, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 7, 6 ], [ 13, 12 ], [ 29, 28 ], [ 32, 31 ], [ 6, 34 ], [ 31, 37 ], [ 12, 40 ], [ 12, 43 ], [ 31, 44 ], [ 49, 48 ], [ 48, 55 ], [ 28, 55 ], [ 48, 60 ], [ 28, 60 ], [ 48, 64 ], [ 28, 64 ], [ 70, 67 ] ]
[ "\ndef CODE_festival_2016_A():\n import numpy as np\n N = int(input())\n a = np.array(list(map(int,input().split())))\n\n ans = 0\n for i in range(N):\n if i == a[a[i]-1]-1:\n ans += 1\n\n print(int(ans) if ans%2==1 else int(ans/2))\n\n\nCODE_festival_2016_A()", "def CODE_festival_2016_A():\n import numpy as np\n N = int(input())\n a = np.array(list(map(int,input().split())))\n\n ans = 0\n for i in range(N):\n if i == a[a[i]-1]-1:\n ans += 1\n\n print(int(ans) if ans%2==1 else int(ans/2))", "CODE_festival_2016_A", "import numpy as np", "numpy", "N = int(input())", "N", "int(input())", "int", "input()", "input", "a = np.array(list(map(int,input().split())))", "a", "np.array(list(map(int,input().split())))", "np.array", "np", "array", "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 i == a[a[i]-1]-1:\n ans += 1\n\n ", "i", "range(N)", "range", "N", "if i == a[a[i]-1]-1:\n ans += 1\n\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(int(ans) if ans%2==1 else int(ans/2))", "print", "int(ans) if ans%2==1 else int(ans/2)", "ans%2==1", "ans%2", "ans", "2", "1", "int(ans)", "int", "ans", "int(ans/2)", "int", "ans/2", "ans", "2", "CODE_festival_2016_A()", "CODE_festival_2016_A", "def CODE_festival_2016_A():\n import numpy as np\n N = int(input())\n a = np.array(list(map(int,input().split())))\n\n ans = 0\n for i in range(N):\n if i == a[a[i]-1]-1:\n ans += 1\n\n print(int(ans) if ans%2==1 else int(ans/2))", "def CODE_festival_2016_A():\n import numpy as np\n N = int(input())\n a = np.array(list(map(int,input().split())))\n\n ans = 0\n for i in range(N):\n if i == a[a[i]-1]-1:\n ans += 1\n\n print(int(ans) if ans%2==1 else int(ans/2))", "CODE_festival_2016_A" ]
def CODE_festival_2016_A(): import numpy as np N = int(input()) a = np.array(list(map(int,input().split()))) ans = 0 for i in range(N): if i == a[a[i]-1]-1: ans += 1 print(int(ans) if ans%2==1 else int(ans/2)) CODE_festival_2016_A()
[ 7, 0, 13, 4, 13, 4, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 0, 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, 13, 13, 10, 17, 13, 10, 4, 13, 10, 2, 13, 10, 17, 13 ]
[ [ 62, 2 ], [ 10, 9 ], [ 9, 18 ], [ 56, 20 ], [ 65, 23 ], [ 57, 27 ], [ 68, 29 ], [ 33, 32 ], [ 63, 37 ], [ 66, 42 ], [ 57, 42 ], [ 66, 44 ], [ 57, 44 ], [ 32, 45 ], [ 32, 46 ], [ 59, 48 ], [ 60, 53 ], [ 69, 53 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ] ]
[ "n = int(input())\na = [int(_) for _ in input().split()]\n\na = [0] + a\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(_) 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()]", "a = [0] + a", "a", "[0] + a", "[0]", "0", "a", "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", "a = [int(_) for _ in input().split()]", "[int(_) for _ in input().split()]", "a", "ans += 1", "1", "ans", "n = int(input())", "int(input())", "n", "a = [0] + a", "[0] + a", "a", "ans = 0", "0", "ans" ]
n = int(input()) a = [int(_) for _ in input().split()] a = [0] + a ans = 0 for i in range(1, n+1): if a[a[i]] == i: ans += 1 print(ans//2)
[ 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, 18, 13, 13, 2, 13, 17, 14, 2, 18, 13, 2, 18, 13, 13, 17, 2, 13, 17, 0, 13, 17, 4, 13, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 18, 13 ]
[ [ 75, 4 ], [ 72, 11 ], [ 76, 15 ], [ 66, 17 ], [ 76, 26 ], [ 63, 29 ], [ 33, 32 ], [ 73, 35 ], [ 67, 39 ], [ 32, 40 ], [ 32, 42 ], [ 67, 47 ], [ 67, 50 ], [ 32, 51 ], [ 32, 54 ], [ 69, 57 ], [ 70, 61 ], [ 64, 61 ], [ 63, 64 ], [ 66, 67 ], [ 69, 70 ], [ 72, 73 ], [ 75, 76 ] ]
[ "import sys\ninput = sys.stdin.readline\n\nN=int(input())\na = tuple(map(int,input().split()))\nsum = 0\n\nfor i in range(N):\n if a[i] > i+1:\n if a[a[i]-1] == i+1:\n sum += 1\n\nprint(sum)", "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 = tuple(map(int,input().split()))", "a", "tuple(map(int,input().split()))", "tuple", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "sum = 0", "sum", "0", "for i in range(N):\n if a[i] > i+1:\n if a[a[i]-1] == i+1:\n sum += 1", "i", "range(N)", "range", "N", "if a[i] > i+1:\n if a[a[i]-1] == i+1:\n sum += 1", "a[i] > i+1", "a[i]", "a", "i", "i+1", "i", "1", "if a[a[i]-1] == i+1:\n sum += 1", "a[a[i]-1] == i+1", "a[a[i]-1]", "a", "a[i]-1", "a[i]", "a", "i", "1", "i+1", "i", "1", "sum += 1", "sum", "1", "print(sum)", "print", "sum", "sum = 0", "0", "sum", "a = tuple(map(int,input().split()))", "tuple(map(int,input().split()))", "a", "sum += 1", "1", "sum", "N=int(input())", "int(input())", "N", "input = sys.stdin.readline", "sys.stdin.readline", "input" ]
import sys input = sys.stdin.readline N=int(input()) a = tuple(map(int,input().split())) sum = 0 for i in range(N): if a[i] > i+1: if a[a[i]-1] == i+1: sum += 1 print(sum)
[ 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, 2, 18, 13, 2, 13, 17, 17, 13, 0, 13, 17, 4, 13, 2, 13, 17, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 13, 13 ]
[ [ 50, 2 ], [ 10, 9 ], [ 9, 18 ], [ 59, 20 ], [ 53, 23 ], [ 60, 30 ], [ 60, 35 ], [ 56, 42 ], [ 57, 47 ], [ 54, 47 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ] ]
[ "N = int(input())\nA = [int(i) for i in input().split()]\ncnt = 0\nfor i, a in enumerate(A):\n if A[a-1]-1 == i:\n cnt += 1\n \nprint(cnt//2)", "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()]", "cnt = 0", "cnt", "0", "for i, a in enumerate(A):\n if A[a-1]-1 == i:\n cnt += 1\n ", "i", "a", "enumerate(A)", "enumerate", "A", "if A[a-1]-1 == i:\n cnt += 1\n ", "A[a-1]-1 == i", "A[a-1]-1", "A[a-1]", "A", "a-1", "a", "1", "1", "i", "cnt += 1", "cnt", "1", "print(cnt//2)", "print", "cnt//2", "cnt", "2", "N = int(input())", "int(input())", "N", "cnt = 0", "0", "cnt", "cnt += 1", "1", "cnt", "A = [int(i) for i in input().split()]", "[int(i) for i in input().split()]", "A" ]
N = int(input()) A = [int(i) for i in input().split()] cnt = 0 for i, a in enumerate(A): if A[a-1]-1 == i: cnt += 1 print(cnt//2)
[ 7, 15, 13, 0, 13, 12, 4, 18, 4, 18, 18, 13, 13, 13, 13, 0, 13, 12, 4, 13, 4, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 13, 0, 13, 12, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 0, 13, 12, 13, 0, 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, 0, 13, 17, 4, 13, 2, 13, 17, 10, 12, 13, 10, 4, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 17, 13, 10, 13, 13, 10, 17, 13 ]
[ [ 98, 4 ], [ 107, 16 ], [ 99, 21 ], [ 25, 24 ], [ 99, 28 ], [ 24, 31 ], [ 110, 33 ], [ 39, 38 ], [ 99, 42 ], [ 38, 47 ], [ 104, 49 ], [ 101, 53 ], [ 108, 55 ], [ 59, 58 ], [ 99, 62 ], [ 58, 68 ], [ 116, 71 ], [ 119, 74 ], [ 78, 77 ], [ 102, 80 ], [ 117, 84 ], [ 117, 86 ], [ 77, 87 ], [ 77, 88 ], [ 113, 90 ], [ 114, 95 ], [ 120, 95 ], [ 98, 99 ], [ 101, 102 ], [ 104, 105 ], [ 107, 108 ], [ 110, 111 ], [ 113, 114 ], [ 116, 117 ], [ 119, 120 ] ]
[ "import sys\nrs = lambda: sys.stdin.readline().rstrip()\nri = lambda: int(rs())\nrs_ = lambda: [_ for _ in rs().split()]\nri_ = lambda: [int(_) for _ in rs().split()]\n\nN = ri()\na = [int(_) - 1 for _ in rs().split()]\nans = 0\nfor i in range(N):\n if a[a[i]] == i:\n ans += 1\nprint(ans // 2)", "import sys", "sys", "rs = lambda: sys.stdin.readline().rstrip()", "rs", "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", "ri = lambda: int(rs())", "ri", "lambda: int(rs())", "int(rs())", "int", "rs()", "rs", "_ for _ in rs().split()", "for _ in rs().split()", "_", "rs().split()", "().split", "()", "rs", "split", "for _ in rs().split()", "_", "rs_ = lambda: [_ for _ in rs().split()]", "rs_", "lambda: [_ for _ in rs().split()]", "[_ for _ in rs().split()]", "int(_) for _ in rs().split()", "for _ in rs().split()", "_", "rs().split()", "().split", "()", "rs", "split", "for _ in rs().split()", "int(_)", "int", "_", "ri_ = lambda: [int(_) for _ in rs().split()]", "ri_", "lambda: [int(_) for _ in rs().split()]", "[int(_) for _ in rs().split()]", "N = ri()", "N", "ri()", "ri", "int(_) - 1 for _ in rs().split()", "for _ in rs().split()", "_", "rs().split()", "().split", "()", "rs", "split", "for _ in rs().split()", "int(_) - 1", "int(_)", "int", "_", "1", "a = [int(_) - 1 for _ in rs().split()]", "a", "[int(_) - 1 for _ in rs().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", "rs = lambda: sys.stdin.readline().rstrip()", "lambda: sys.stdin.readline().rstrip()", "rs", "N = ri()", "ri()", "N", "ri_ = lambda: [int(_) for _ in rs().split()]", "lambda: [int(_) for _ in rs().split()]", "ri_", "ri = lambda: int(rs())", "lambda: int(rs())", "ri", "rs_ = lambda: [_ for _ in rs().split()]", "lambda: [_ for _ in rs().split()]", "rs_", "ans += 1", "1", "ans", "a = [int(_) - 1 for _ in rs().split()]", "[int(_) - 1 for _ in rs().split()]", "a", "ans = 0", "0", "ans" ]
import sys rs = lambda: sys.stdin.readline().rstrip() ri = lambda: int(rs()) rs_ = lambda: [_ for _ in rs().split()] ri_ = lambda: [int(_) for _ in rs().split()] N = ri() a = [int(_) - 1 for _ in rs().split()] ans = 0 for i in range(N): if a[a[i]] == i: ans += 1 print(ans // 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, 39, 28, 13, 13, 4, 13, 13, 4, 18, 13, 13, 39, 2, 13, 17, 13, 4, 18, 18, 13, 13, 13, 4, 13, 2, 4, 13, 13, 4, 13, 4, 13, 4, 13, 13, 4, 13, 4, 13, 13, 13, 10, 39, 13, 10, 13, 13, 10, 4, 13 ]
[ [ 72, 2 ], [ 10, 9 ], [ 9, 18 ], [ 69, 20 ], [ 66, 23 ], [ 70, 30 ], [ 67, 33 ], [ 67, 43 ], [ 67, 51 ], [ 67, 64 ], [ 66, 67 ], [ 69, 70 ], [ 72, 73 ] ]
[ "n = int(input())\na = [int(i) for i in input().split()]\nai = []\n\nfor i, j in enumerate(a):\n ai.append([i+1,j])\n ai[i].sort()\n\nprint(len(ai) - len(list(map(list,set(map(tuple, ai))))))\n", "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()]", "ai = []", "ai", "[]", "for i, j in enumerate(a):\n ai.append([i+1,j])\n ai[i].sort()", "i", "j", "enumerate(a)", "enumerate", "a", "ai.append([i+1,j])", "ai.append", "ai", "append", "[i+1,j]", "i+1", "i", "1", "j", "ai[i].sort()", "[i].sort", "[i]", "ai", "i", "sort", "print(len(ai) - len(list(map(list,set(map(tuple, ai))))))", "print", "len(ai) - len(list(map(list,set(map(tuple, ai)))))", "len(ai)", "len", "ai", "len(list(map(list,set(map(tuple, ai)))))", "len", "list(map(list,set(map(tuple, ai))))", "list", "map(list,set(map(tuple, ai)))", "map", "list", "set(map(tuple, ai))", "set", "map(tuple, ai)", "map", "tuple", "ai", "ai = []", "[]", "ai", "a = [int(i) for i in input().split()]", "[int(i) for i in input().split()]", "a", "n = int(input())", "int(input())", "n" ]
n = int(input()) a = [int(i) for i in input().split()] ai = [] for i, j in enumerate(a): ai.append([i+1,j]) ai[i].sort() print(len(ai) - len(list(map(list,set(map(tuple, ai))))))
[ 7, 0, 13, 4, 13, 4, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 2, 4, 13, 13, 17, 0, 13, 13, 15, 0, 13, 2, 39, 17, 13, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 2, 18, 13, 18, 13, 13, 18, 13, 13, 2, 18, 13, 18, 13, 13, 13, 0, 13, 17, 0, 18, 13, 18, 13, 13, 17, 0, 18, 13, 13, 17, 4, 13, 13, 10, 4, 13, 10, 13, 13, 10, 17, 13, 10, 2, 13, 10, 17, 13 ]
[ [ 76, 2 ], [ 10, 9 ], [ 9, 19 ], [ 79, 22 ], [ 85, 26 ], [ 77, 30 ], [ 88, 32 ], [ 36, 35 ], [ 77, 38 ], [ 61, 42 ], [ 86, 43 ], [ 80, 45 ], [ 35, 46 ], [ 68, 47 ], [ 86, 48 ], [ 35, 49 ], [ 80, 52 ], [ 80, 54 ], [ 35, 55 ], [ 35, 56 ], [ 82, 58 ], [ 66, 61 ], [ 86, 62 ], [ 80, 64 ], [ 35, 65 ], [ 71, 68 ], [ 86, 69 ], [ 35, 70 ], [ 83, 74 ], [ 89, 74 ], [ 76, 77 ], [ 79, 80 ], [ 82, 83 ], [ 85, 86 ], [ 88, 89 ] ]
[ "N = int(input())\nA = [int(i)-1 for i in input().split()]\n\nfrom collections import defaultdict\n\nflag = [True] * N\n\ncnt = 0\nfor i in range(N):\n if flag[A[i]] and flag[i] and A[A[i]] == i:\n cnt += 1\n flag[A[i]] = False\n flag[i] = False\n\nprint(cnt)", "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()]", "from collections import defaultdict", "flag = [True] * N", "flag", "[True] * N", "[True]", "True", "N", "cnt = 0", "cnt", "0", "for i in range(N):\n if flag[A[i]] and flag[i] and A[A[i]] == i:\n cnt += 1\n flag[A[i]] = False\n flag[i] = False", "i", "range(N)", "range", "N", "if flag[A[i]] and flag[i] and A[A[i]] == i:\n cnt += 1\n flag[A[i]] = False\n flag[i] = False", "flag[A[i]] and flag[i] and A[A[i]] == i", "flag[A[i]] and flag[i]", "flag[A[i]]", "flag", "A[i]", "A", "i", "flag[i]", "flag", "i", "A[A[i]] == i", "A[A[i]]", "A", "A[i]", "A", "i", "i", "cnt += 1", "cnt", "1", "flag[A[i]] = False", "flag[A[i]]", "flag", "A[i]", "A", "i", "False", "flag[i] = False", "flag[i]", "flag", "i", "False", "print(cnt)", "print", "cnt", "N = int(input())", "int(input())", "N", "A = [int(i)-1 for i in input().split()]", "[int(i)-1 for i in input().split()]", "A", "cnt += 1", "1", "cnt", "flag = [True] * N", "[True] * N", "flag", "cnt = 0", "0", "cnt" ]
N = int(input()) A = [int(i)-1 for i in input().split()] from collections import defaultdict flag = [True] * N cnt = 0 for i in range(N): if flag[A[i]] and flag[i] and A[A[i]] == i: cnt += 1 flag[A[i]] = False flag[i] = False print(cnt)
[ 7, 15, 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, 18, 13, 2, 18, 13, 13, 17, 2, 13, 17, 0, 13, 17, 4, 13, 2, 13, 17, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 4, 13, 10, 2, 13 ]
[ [ 80, 11 ], [ 83, 16 ], [ 26, 25 ], [ 32, 31 ], [ 44, 43 ], [ 47, 46 ], [ 25, 49 ], [ 31, 53 ], [ 31, 56 ], [ 46, 57 ], [ 46, 60 ], [ 64, 63 ], [ 63, 68 ], [ 43, 68 ], [ 78, 75 ], [ 80, 81 ], [ 83, 84 ] ]
[ "import sys\n\nsys.setrecursionlimit(10 ** 7)\nf_inf = float('inf')\nmod = 10 ** 9 + 7\n\n\ndef resolve():\n n = int(input())\n A = list(map(int, input().split()))\n\n res = 0\n for i in range(n):\n if A[A[i] - 1] == i + 1:\n res += 1\n\n print(res // 2)\n\n\nif __name__ == '__main__':\n resolve()", "import sys", "sys", "sys.setrecursionlimit(10 ** 7)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10 ** 7", "10", "7", "f_inf = float('inf')", "f_inf", "float('inf')", "float", "'inf'", "mod = 10 ** 9 + 7", "mod", "10 ** 9 + 7", "10 ** 9", "10", "9", "7", "def resolve():\n n = int(input())\n A = list(map(int, input().split()))\n\n res = 0\n for i in range(n):\n if A[A[i] - 1] == i + 1:\n res += 1\n\n print(res // 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", "res = 0", "res", "0", "for i in range(n):\n if A[A[i] - 1] == i + 1:\n res += 1\n\n ", "i", "range(n)", "range", "n", "if A[A[i] - 1] == i + 1:\n res += 1\n\n ", "A[A[i] - 1] == i + 1", "A[A[i] - 1]", "A", "A[i] - 1", "A[i]", "A", "i", "1", "i + 1", "i", "1", "res += 1", "res", "1", "print(res // 2)", "print", "res // 2", "res", "2", "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\n res = 0\n for i in range(n):\n if A[A[i] - 1] == i + 1:\n res += 1\n\n print(res // 2)", "def resolve():\n n = int(input())\n A = list(map(int, input().split()))\n\n res = 0\n for i in range(n):\n if A[A[i] - 1] == i + 1:\n res += 1\n\n print(res // 2)", "resolve", "f_inf = float('inf')", "float('inf')", "f_inf", "mod = 10 ** 9 + 7", "10 ** 9 + 7", "mod" ]
import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): n = int(input()) A = list(map(int, input().split())) res = 0 for i in range(n): if A[A[i] - 1] == i + 1: res += 1 print(res // 2) if __name__ == '__main__': resolve()
[ 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, 4, 13, 13, 14, 2, 13, 18, 13, 18, 13, 13, 0, 13, 17, 4, 13, 2, 13, 17, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 59, 2 ], [ 56, 8 ], [ 57, 21 ], [ 62, 26 ], [ 30, 29 ], [ 57, 35 ], [ 29, 38 ], [ 57, 40 ], [ 57, 42 ], [ 29, 43 ], [ 53, 45 ], [ 54, 50 ], [ 63, 50 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ] ]
[ "N=int(input())\na=list(map(int,input().split()))\na.insert(0,0)\nans=0\n\nfor i in range(1,len(a)):\n if i==a[a[i]]:\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", "a.insert(0,0)", "a.insert", "a", "insert", "0", "0", "ans=0", "ans", "0", "for i in range(1,len(a)):\n if i==a[a[i]]:\n ans+=1", "i", "range(1,len(a))", "range", "1", "len(a)", "len", "a", "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", "print(ans//2)", "print", "ans//2", "ans", "2", "ans+=1", "1", "ans", "a=list(map(int,input().split()))", "list(map(int,input().split()))", "a", "N=int(input())", "int(input())", "N", "ans=0", "0", "ans" ]
N=int(input()) a=list(map(int,input().split())) a.insert(0,0) ans=0 for i in range(1,len(a)): if i==a[a[i]]: ans+=1 print(ans//2)
[ 7, 15, 13, 13, 13, 15, 15, 15, 15, 15, 15, 15, 12, 13, 12, 13, 12, 13, 12, 13, 12, 13, 12, 13, 12, 13, 4, 18, 13, 13, 2, 17, 17, 0, 13, 18, 13, 13, 0, 13, 2, 2, 17, 17, 17, 0, 13, 4, 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, 12, 13, 10, 17, 13, 10, 18, 13, 10, 4, 13, 10, 4, 13, 10, 12, 13, 10, 17, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 2, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 88, 34 ], [ 112, 39 ], [ 91, 46 ], [ 119, 48 ], [ 94, 50 ], [ 116, 52 ], [ 100, 54 ], [ 58, 57 ], [ 92, 60 ], [ 95, 64 ], [ 95, 67 ], [ 57, 68 ], [ 57, 71 ], [ 85, 74 ], [ 86, 79 ], [ 101, 79 ], [ 85, 86 ], [ 88, 89 ], [ 91, 92 ], [ 94, 95 ], [ 100, 101 ], [ 112, 113 ] ]
[ "import sys, re, os\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians\nfrom itertools import permutations, combinations, product, accumulate\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom fractions import gcd\ndef input(): return sys.stdin.readline().strip()\ndef STR(): return input()\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef S_MAP(): return map(str, input().split())\ndef LIST(): return list(map(int, input().split()))\ndef S_LIST(): return list(map(str, input().split()))\nsys.setrecursionlimit(10 ** 9)\ninf = sys.maxsize\nmod = 10 ** 9 + 7\n\nn = INT()\na = LIST()\nans = 0\nfor i in range(n):\n if a[a[i] - 1] == i + 1:\n ans += 1\nprint(ans // 2)", "import sys, re, os", "sys", "re", "os", "from collections import deque, defaultdict, Counter", "from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians", "from itertools import permutations, combinations, product, accumulate", "from operator import itemgetter, mul", "from copy import deepcopy", "from string import ascii_lowercase, ascii_uppercase, digits", "from fractions import gcd", "def input(): return sys.stdin.readline().strip()", "input", "def STR(): return input()", "STR", "def INT(): return int(input())", "INT", "def MAP(): return map(int, input().split())", "MAP", "def S_MAP(): return map(str, input().split())", "S_MAP", "def LIST(): return list(map(int, input().split()))", "LIST", "def S_LIST(): return list(map(str, input().split()))", "S_LIST", "sys.setrecursionlimit(10 ** 9)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10 ** 9", "10", "9", "inf = sys.maxsize", "inf", "sys.maxsize", "sys", "maxsize", "mod = 10 ** 9 + 7", "mod", "10 ** 9 + 7", "10 ** 9", "10", "9", "7", "n = INT()", "n", "INT()", "INT", "a = LIST()", "a", "LIST()", "LIST", "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", "def S_LIST(): return list(map(str, input().split()))", "def S_LIST(): return list(map(str, input().split()))", "S_LIST", "ans += 1", "1", "ans", "inf = sys.maxsize", "sys.maxsize", "inf", "n = INT()", "INT()", "n", "a = LIST()", "LIST()", "a", "def input(): return sys.stdin.readline().strip()", "def input(): return sys.stdin.readline().strip()", "input", "ans = 0", "0", "ans", "def MAP(): return map(int, input().split())", "def MAP(): return map(int, input().split())", "MAP", "def S_MAP(): return map(str, input().split())", "def S_MAP(): return map(str, input().split())", "S_MAP", "def STR(): return input()", "def STR(): return input()", "STR", "mod = 10 ** 9 + 7", "10 ** 9 + 7", "mod", "def LIST(): return list(map(int, input().split()))", "def LIST(): return list(map(int, input().split()))", "LIST", "def INT(): return int(input())", "def INT(): return int(input())", "INT" ]
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from fractions import gcd def input(): return sys.stdin.readline().strip() def STR(): return input() def INT(): return int(input()) def MAP(): return map(int, input().split()) def S_MAP(): return map(str, input().split()) def LIST(): return list(map(int, input().split())) def S_LIST(): return list(map(str, input().split())) sys.setrecursionlimit(10 ** 9) inf = sys.maxsize mod = 10 ** 9 + 7 n = INT() a = LIST() 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, 31, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 2, 39, 17, 13, 28, 13, 13, 4, 13, 13, 14, 2, 18, 13, 2, 13, 17, 2, 13, 17, 4, 13, 2, 4, 13, 13, 17, 10, 2, 13, 10, 4, 13 ]
[ [ 51, 2 ], [ 10, 8 ], [ 48, 19 ], [ 52, 23 ], [ 49, 45 ], [ 48, 49 ], [ 51, 52 ] ]
[ "N=int(input())\n*A,=map(int, input().split())\n\nB=[0]*N\n\nfor i,a in enumerate(A):\n if A[a-1] == i+1: B[i] = 1\n\nprint(sum(B)//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", "B=[0]*N", "B", "[0]*N", "[0]", "0", "N", "for i,a in enumerate(A):\n if A[a-1] == i+1: B[i] = 1", "i", "a", "enumerate(A)", "enumerate", "A", "if A[a-1] == i+1: B[i]", "A[a-1] == i+1", "A[a-1]", "A", "a-1", "a", "1", "i+1", "i", "1", "print(sum(B)//2)", "print", "sum(B)//2", "sum(B)", "sum", "B", "2", "B=[0]*N", "[0]*N", "B", "N=int(input())", "int(input())", "N" ]
N=int(input()) *A,=map(int, input().split()) B=[0]*N for i,a in enumerate(A): if A[a-1] == i+1: B[i] = 1 print(sum(B)//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, 0, 13, 17, 4, 13, 2, 13, 17, 10, 17, 13, 10, 4, 13, 10, 13, 13, 10, 17, 13 ]
[ [ 52, 2 ], [ 10, 9 ], [ 9, 19 ], [ 55, 22 ], [ 49, 25 ], [ 29, 28 ], [ 53, 31 ], [ 56, 35 ], [ 56, 37 ], [ 28, 38 ], [ 28, 39 ], [ 58, 41 ], [ 59, 46 ], [ 50, 46 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ] ]
[ "n = int(input())\nla = [int(w)-1 for w in input().split()]\n\nans = 0\nfor i in range(n):\n if la[la[i]] == i:\n ans += 1\nprint(ans//2)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "int(w)-1 for w in input().split()", "for w in input().split()", "w", "input().split()", "().split", "()", "input", "split", "for w in input().split()", "int(w)-1", "int(w)", "int", "w", "1", "la = [int(w)-1 for w in input().split()]", "la", "[int(w)-1 for w in input().split()]", "ans = 0", "ans", "0", "for i in range(n):\n if la[la[i]] == i:\n ans += 1", "i", "range(n)", "range", "n", "if la[la[i]] == i:\n ans += 1", "la[la[i]] == i", "la[la[i]]", "la", "la[i]", "la", "i", "i", "ans += 1", "ans", "1", "print(ans//2)", "print", "ans//2", "ans", "2", "ans = 0", "0", "ans", "n = int(input())", "int(input())", "n", "la = [int(w)-1 for w in input().split()]", "[int(w)-1 for w in input().split()]", "la", "ans += 1", "1", "ans" ]
n = int(input()) la = [int(w)-1 for w in input().split()] ans = 0 for i in range(n): if la[la[i]] == i: ans += 1 print(ans//2)
[ 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, 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 ], [ 57, 54 ] ]
[ "def main():\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\nif __name__ == '__main__':\n main()", "def main():\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)", "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 ", "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", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def main():\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)", "def main():\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)", "main" ]
def 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) 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, 4, 13, 17, 2, 13, 17, 0, 13, 18, 13, 2, 18, 13, 2, 13, 17, 17, 14, 2, 13, 13, 0, 13, 17, 4, 13, 2, 13, 17, 10, 18, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 63, 2 ], [ 60, 8 ], [ 66, 20 ], [ 24, 23 ], [ 64, 28 ], [ 54, 31 ], [ 61, 33 ], [ 61, 36 ], [ 23, 38 ], [ 23, 43 ], [ 55, 44 ], [ 57, 46 ], [ 58, 51 ], [ 67, 51 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ] ]
[ "n = int(input())\na = list(map(int, input().split()))\nans = 0\nfor i in range(1, n + 1):\n opp = a[a[i - 1] - 1]\n if i == opp:\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 opp = a[a[i - 1] - 1]\n if i == opp:\n ans += 1", "i", "range(1, n + 1)", "range", "1", "n + 1", "n", "1", "opp = a[a[i - 1] - 1]", "opp", "a[a[i - 1] - 1]", "a", "a[i - 1] - 1", "a[i - 1]", "a", "i - 1", "i", "1", "1", "if i == opp:\n ans += 1", "i == opp", "i", "opp", "ans += 1", "ans", "1", "print(ans // 2)", "print", "ans // 2", "ans", "2", "opp = a[a[i - 1] - 1]", "a[a[i - 1] - 1]", "opp", "ans += 1", "1", "ans", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "n = int(input())", "int(input())", "n", "ans = 0", "0", "ans" ]
n = int(input()) a = list(map(int, input().split())) ans = 0 for i in range(1, n + 1): opp = a[a[i - 1] - 1] if i == opp: ans += 1 print(ans // 2)
[ 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 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)\n\n\n\nresolve()", "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 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, 15, 13, 15, 13, 12, 13, 14, 2, 18, 13, 17, 18, 13, 17, 29, 39, 18, 13, 17, 18, 13, 17, 29, 13, 23, 13, 0, 13, 4, 13, 4, 18, 4, 18, 18, 13, 13, 13, 13, 41, 28, 13, 4, 18, 4, 18, 4, 18, 18, 13, 13, 13, 13, 13, 4, 4, 13, 13, 0, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 13, 4, 13, 4, 13, 17, 2, 13, 17, 13, 4, 18, 13, 13, 0, 13, 4, 18, 13, 13, 13, 0, 13, 17, 28, 13, 4, 18, 13, 13, 14, 2, 18, 13, 17, 17, 3, 0, 13, 2, 13, 17, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 13, 13, 10, 2, 13, 10, 12, 13, 10, 4, 13 ]
[ [ 26, 10 ], [ 26, 13 ], [ 26, 18 ], [ 26, 21 ], [ 26, 24 ], [ 26, 26 ], [ 119, 28 ], [ 43, 42 ], [ 42, 58 ], [ 125, 60 ], [ 116, 63 ], [ 132, 68 ], [ 120, 77 ], [ 126, 79 ], [ 117, 82 ], [ 134, 85 ], [ 117, 90 ], [ 122, 92 ], [ 96, 95 ], [ 135, 98 ], [ 95, 103 ], [ 128, 108 ], [ 123, 110 ], [ 129, 110 ], [ 129, 114 ], [ 123, 114 ], [ 116, 117 ], [ 119, 120 ], [ 122, 123 ], [ 125, 126 ], [ 128, 129 ], [ 134, 135 ] ]
[ "import sys\nimport collections\n\ndef swap(t):\n if t[1] < t[0] :\n return (t[1],t[0])\n else:\n return t\n\nn = int(sys.stdin.readline().rstrip())\na = [int(x) for x in sys.stdin.readline().rstrip().split()]\n\nzippeda = list(map(swap,list(zip(range(1,n+1),a))))\nzippeda.sort()\nc = collections.Counter(zippeda)\ncounter = 0\nfor a in c.most_common():\n if a[1] < 2:\n break\n else:\n counter = counter + 1\n\nprint(counter)", "import sys", "sys", "import collections", "collections", "def swap(t):\n if t[1] < t[0] :\n return (t[1],t[0])\n else:\n return t", "swap", "if t[1] < t[0] :\n return (t[1],t[0])\n else:\n return t", "t[1] < t[0]", "t[1]", "t", "1", "t[0]", "t", "0", "return (t[1],t[0])", "(t[1],t[0])", "t[1]", "t", "1", "t[0]", "t", "0", "return t", "t", "t", "t", "n = int(sys.stdin.readline().rstrip())", "n", "int(sys.stdin.readline().rstrip())", "int", "sys.stdin.readline().rstrip()", "sys.stdin.readline().rstrip", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "rstrip", "int(x) for x in sys.stdin.readline().rstrip().split()", "for x in sys.stdin.readline().rstrip().split()", "x", "sys.stdin.readline().rstrip().split()", "sys.stdin.readline().rstrip().split", "sys.stdin.readline().rstrip()", "sys.stdin.readline().rstrip", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "rstrip", "split", "for x in sys.stdin.readline().rstrip().split()", "int(x)", "int", "x", "a = [int(x) for x in sys.stdin.readline().rstrip().split()]", "a", "[int(x) for x in sys.stdin.readline().rstrip().split()]", "zippeda = list(map(swap,list(zip(range(1,n+1),a))))", "zippeda", "list(map(swap,list(zip(range(1,n+1),a))))", "list", "map(swap,list(zip(range(1,n+1),a)))", "map", "swap", "list(zip(range(1,n+1),a))", "list", "zip(range(1,n+1),a)", "zip", "range(1,n+1)", "range", "1", "n+1", "n", "1", "a", "zippeda.sort()", "zippeda.sort", "zippeda", "sort", "c = collections.Counter(zippeda)", "c", "collections.Counter(zippeda)", "collections.Counter", "collections", "Counter", "zippeda", "counter = 0", "counter", "0", "for a in c.most_common():\n if a[1] < 2:\n break\n else:\n counter = counter + 1", "a", "c.most_common()", "c.most_common", "c", "most_common", "if a[1] < 2:\n break\n else:\n counter = counter + 1", "a[1] < 2", "a[1]", "a", "1", "2", "break", "counter = counter + 1", "counter", "counter + 1", "counter", "1", "print(counter)", "print", "counter", "zippeda = list(map(swap,list(zip(range(1,n+1),a))))", "list(map(swap,list(zip(range(1,n+1),a))))", "zippeda", "n = int(sys.stdin.readline().rstrip())", "int(sys.stdin.readline().rstrip())", "n", "counter = 0", "0", "counter", "a = [int(x) for x in sys.stdin.readline().rstrip().split()]", "[int(x) for x in sys.stdin.readline().rstrip().split()]", "a", "counter = counter + 1", "counter + 1", "counter", "def swap(t):\n if t[1] < t[0] :\n return (t[1],t[0])\n else:\n return t", "def swap(t):\n if t[1] < t[0] :\n return (t[1],t[0])\n else:\n return t", "swap", "c = collections.Counter(zippeda)", "collections.Counter(zippeda)", "c" ]
import sys import collections def swap(t): if t[1] < t[0] : return (t[1],t[0]) else: return t n = int(sys.stdin.readline().rstrip()) a = [int(x) for x in sys.stdin.readline().rstrip().split()] zippeda = list(map(swap,list(zip(range(1,n+1),a)))) zippeda.sort() c = collections.Counter(zippeda) counter = 0 for a in c.most_common(): if a[1] < 2: break else: counter = counter + 1 print(counter)
[ 7, 15, 13, 0, 13, 18, 18, 13, 13, 13, 12, 13, 0, 13, 4, 13, 4, 18, 4, 13, 13, 41, 28, 13, 4, 18, 4, 18, 4, 13, 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, 13, 18, 13, 18, 13, 13, 0, 13, 17, 4, 13, 2, 13, 17, 29, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 18, 13 ]
[ [ 80, 4 ], [ 14, 13 ], [ 81, 19 ], [ 24, 23 ], [ 81, 29 ], [ 23, 35 ], [ 38, 37 ], [ 44, 43 ], [ 47, 46 ], [ 13, 51 ], [ 46, 55 ], [ 37, 57 ], [ 37, 59 ], [ 46, 60 ], [ 63, 62 ], [ 62, 67 ], [ 43, 67 ], [ 78, 75 ], [ 80, 81 ] ]
[ "import sys\ninput = sys.stdin.readline\n# sys.setrecursionlimit(100000)\n\n\ndef main():\n n = int(input().strip())\n A = [None] + [int(i) for i in input().strip().split()]\n ans = 0\n for i in range(1, n + 1):\n if i == A[A[i]]:\n ans += 1\n\n print(ans // 2)\n\n return\n\n\nif __name__ == \"__main__\":\n main()", "import sys", "sys", "input = sys.stdin.readline", "input", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "def main():\n n = int(input().strip())\n A = [None] + [int(i) for i in input().strip().split()]\n ans = 0\n for i in range(1, n + 1):\n if i == A[A[i]]:\n ans += 1\n\n print(ans // 2)\n\n return", "main", "n = int(input().strip())", "n", "int(input().strip())", "int", "input().strip()", "().strip", "()", "input", "strip", "int(i) for i in input().strip().split()", "for i in input().strip().split()", "i", "input().strip().split()", "().strip().split", "().strip()", "().strip", "()", "input", "strip", "split", "for i in input().strip().split()", "int(i)", "int", "i", "A = [None] + [int(i) for i in input().strip().split()]", "A", "[None] + [int(i) for i in input().strip().split()]", "[None]", "None", "[int(i) for i in input().strip().split()]", "ans = 0", "ans", "0", "for i in range(1, n + 1):\n if i == A[A[i]]:\n ans += 1\n\n ", "i", "range(1, n + 1)", "range", "1", "n + 1", "n", "1", "if i == A[A[i]]:\n ans += 1\n\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", "return", "if __name__ == \"__main__\":\n main()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "main()", "main", "def main():\n n = int(input().strip())\n A = [None] + [int(i) for i in input().strip().split()]\n ans = 0\n for i in range(1, n + 1):\n if i == A[A[i]]:\n ans += 1\n\n print(ans // 2)\n\n return", "def main():\n n = int(input().strip())\n A = [None] + [int(i) for i in input().strip().split()]\n ans = 0\n for i in range(1, n + 1):\n if i == A[A[i]]:\n ans += 1\n\n print(ans // 2)\n\n return", "main", "input = sys.stdin.readline", "sys.stdin.readline", "input" ]
import sys input = sys.stdin.readline # sys.setrecursionlimit(100000) def main(): n = int(input().strip()) A = [None] + [int(i) for i in input().strip().split()] ans = 0 for i in range(1, n + 1): if i == A[A[i]]: ans += 1 print(ans // 2) return 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, 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, 4, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 54, 2 ], [ 51, 8 ], [ 63, 20 ], [ 48, 23 ], [ 27, 26 ], [ 52, 26 ], [ 60, 29 ], [ 52, 34 ], [ 26, 36 ], [ 61, 38 ], [ 64, 38 ], [ 57, 40 ], [ 58, 45 ], [ 49, 45 ], [ 48, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ] ]
[ "N = int(input())\nA = list(map(int,input().split()))\na = 0\nans = 0\n\nfor i in A:\n a+=1\n if A[i-1]==a:\n ans+=1\n \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", "a = 0", "a", "0", "ans = 0", "ans", "0", "for i in A:\n a+=1\n if A[i-1]==a:\n ans+=1\n \n ", "i", "A", "a+=1", "a", "1", "if A[i-1]==a:\n ans+=1\n \n ", "A[i-1]==a", "A[i-1]", "A", "i-1", "i", "1", "a", "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", "N = int(input())", "int(input())", "N", "ans+=1", "1", "ans", "a+=1", "1", "a", "a = 0", "0", "a" ]
N = int(input()) A = list(map(int,input().split())) a = 0 ans = 0 for i in A: a+=1 if A[i-1]==a: ans+=1 print(ans//2)
[ 7, 0, 13, 4, 13, 4, 13, 41, 28, 13, 4, 13, 13, 4, 18, 4, 13, 13, 4, 2, 13, 17, 0, 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, 17, 13, 10, 17, 13, 10, 4, 13, 10, 13, 13 ]
[ [ 56, 2 ], [ 10, 9 ], [ 9, 20 ], [ 59, 23 ], [ 53, 26 ], [ 30, 29 ], [ 57, 32 ], [ 60, 36 ], [ 60, 38 ], [ 29, 39 ], [ 29, 40 ], [ 50, 42 ], [ 51, 47 ], [ 54, 47 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ] ]
[ "N = int(input())\nA = [x - 1 for x in map(int, input().split())]\n\ncnt = 0\nfor i in range(N):\n if A[A[i]] == i:\n cnt += 1\nprint(cnt // 2)\n", "N = int(input())", "N", "int(input())", "int", "input()", "input", "x - 1 for x in map(int, input().split())", "for x in map(int, input().split())", "x", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "for x in map(int, input().split())", "x - 1", "x", "1", "A = [x - 1 for x in map(int, input().split())]", "A", "[x - 1 for x in map(int, input().split())]", "cnt = 0", "cnt", "0", "for i in range(N):\n if A[A[i]] == i:\n cnt += 1", "i", "range(N)", "range", "N", "if A[A[i]] == i:\n cnt += 1", "A[A[i]] == i", "A[A[i]]", "A", "A[i]", "A", "i", "i", "cnt += 1", "cnt", "1", "print(cnt // 2)", "print", "cnt // 2", "cnt", "2", "cnt += 1", "1", "cnt", "cnt = 0", "0", "cnt", "N = int(input())", "int(input())", "N", "A = [x - 1 for x in map(int, input().split())]", "[x - 1 for x in map(int, input().split())]", "A" ]
N = int(input()) A = [x - 1 for x in map(int, input().split())] cnt = 0 for i in range(N): if A[A[i]] == 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, 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, 4, 13, 2, 13, 17, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 50, 2 ], [ 53, 8 ], [ 59, 20 ], [ 24, 23 ], [ 51, 26 ], [ 23, 29 ], [ 54, 32 ], [ 54, 35 ], [ 23, 36 ], [ 56, 40 ], [ 57, 47 ], [ 60, 47 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ] ]
[ "n = int(input())\nls = list(map(int, input().split()))\n\ncnt = 0\n\nfor i in range(n):\n if i == ls[ls[i] - 1] - 1:\n cnt += 1\n\nprint(int(cnt * 0.5))", "n = int(input())", "n", "int(input())", "int", "input()", "input", "ls = list(map(int, input().split()))", "ls", "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 i == ls[ls[i] - 1] - 1:\n cnt += 1", "i", "range(n)", "range", "n", "if i == ls[ls[i] - 1] - 1:\n cnt += 1", "i == ls[ls[i] - 1] - 1", "i", "ls[ls[i] - 1] - 1", "ls[ls[i] - 1]", "ls", "ls[i] - 1", "ls[i]", "ls", "i", "1", "1", "cnt += 1", "cnt", "1", "print(int(cnt * 0.5))", "print", "int(cnt * 0.5)", "int", "cnt * 0.5", "cnt", "0.5", "n = int(input())", "int(input())", "n", "ls = list(map(int, input().split()))", "list(map(int, input().split()))", "ls", "cnt += 1", "1", "cnt", "cnt = 0", "0", "cnt" ]
n = int(input()) ls = list(map(int, input().split())) cnt = 0 for i in range(n): if i == ls[ls[i] - 1] - 1: cnt += 1 print(int(cnt * 0.5))
[ 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, 0, 18, 13, 2, 13, 17, 13, 0, 13, 17, 28, 13, 13, 4, 18, 13, 13, 14, 2, 13, 4, 18, 13, 13, 4, 18, 13, 13, 13, 0, 13, 17, 4, 13, 2, 13, 17, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 78, 2 ], [ 69, 8 ], [ 66, 20 ], [ 70, 27 ], [ 34, 29 ], [ 67, 30 ], [ 75, 36 ], [ 67, 43 ], [ 67, 50 ], [ 67, 54 ], [ 72, 58 ], [ 73, 63 ], [ 76, 63 ], [ 66, 67 ], [ 69, 70 ], [ 72, 73 ], [ 75, 76 ], [ 78, 79 ] ]
[ "# B\n\nN = int(input())\nA = list(map(int,input().split()))\n\npears = {}\nfor index,a in enumerate(A):\n pears[index+1] = a\n\n\ncnt = 0\nfor key,value in pears.items():\n if key == pears.get(pears.get(key)):\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", "pears = {}", "pears", "{}", "for index,a in enumerate(A):\n pears[index+1] = a", "index", "a", "enumerate(A)", "enumerate", "A", "pears[index+1] = a", "pears[index+1]", "pears", "index+1", "index", "1", "a", "cnt = 0", "cnt", "0", "for key,value in pears.items():\n if key == pears.get(pears.get(key)):\n cnt += 1", "key", "value", "pears.items()", "pears.items", "pears", "items", "if key == pears.get(pears.get(key)):\n cnt += 1", "key == pears.get(pears.get(key))", "key", "pears.get(pears.get(key))", "pears.get", "pears", "get", "pears.get(key)", "pears.get", "pears", "get", "key", "cnt += 1", "cnt", "1", "print(cnt//2)", "print", "cnt//2", "cnt", "2", "pears = {}", "{}", "pears", "A = list(map(int,input().split()))", "list(map(int,input().split()))", "A", "cnt += 1", "1", "cnt", "cnt = 0", "0", "cnt", "N = int(input())", "int(input())", "N" ]
# B N = int(input()) A = list(map(int,input().split())) pears = {} for index,a in enumerate(A): pears[index+1] = a cnt = 0 for key,value in pears.items(): if key == pears.get(pears.get(key)): cnt += 1 print(cnt//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, 13, 18, 13, 18, 13, 13, 4, 13, 4, 13, 2, 13, 17, 10, 4, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 49, 2 ], [ 55, 8 ], [ 52, 26 ], [ 30, 29 ], [ 50, 32 ], [ 29, 35 ], [ 56, 37 ], [ 56, 39 ], [ 29, 40 ], [ 53, 46 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ] ]
[ "n = int(input())\na = list(map(lambda x:int(x)-1, input().split()))\n\nans = 0\nfor i in range(n):\n if i == a[a[i]]: ans += 1\nprint(int(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 i == a[a[i]]: ans += 1", "i", "range(n)", "range", "n", "if i == a[a[i]]: ans ", "i == a[a[i]]", "i", "a[a[i]]", "a", "a[i]", "a", "i", "print(int(ans/2))", "print", "int(ans/2)", "int", "ans/2", "ans", "2", "n = int(input())", "int(input())", "n", "ans = 0", "0", "ans", "a = list(map(lambda x:int(x)-1, input().split()))", "list(map(lambda x:int(x)-1, input().split()))", "a" ]
n = int(input()) a = list(map(lambda x:int(x)-1, input().split())) ans = 0 for i in range(n): if i == a[a[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, 4, 13, 13, 14, 2, 40, 2, 13, 17, 18, 13, 13, 2, 2, 13, 17, 18, 13, 2, 18, 13, 13, 17, 0, 18, 13, 2, 18, 13, 13, 17, 17, 0, 18, 13, 13, 17, 4, 13, 2, 4, 18, 13, 13, 17, 17, 10, 17, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 74, 2 ], [ 77, 8 ], [ 71, 20 ], [ 24, 23 ], [ 75, 26 ], [ 23, 31 ], [ 57, 33 ], [ 78, 34 ], [ 23, 35 ], [ 23, 38 ], [ 78, 41 ], [ 57, 43 ], [ 78, 44 ], [ 23, 45 ], [ 55, 48 ], [ 78, 49 ], [ 57, 51 ], [ 78, 52 ], [ 23, 53 ], [ 60, 57 ], [ 78, 58 ], [ 23, 59 ], [ 78, 66 ], [ 71, 72 ], [ 74, 75 ], [ 77, 78 ] ]
[ "N = int(input())\na = list(map(int, input().split()))\n\ncnt = 0\n\nfor i in range(N):\n if i+1 != a[i] and i+1 == a[a[i]-1]:\n a[a[i]-1] = 0\n a[i] = 0\n else:\n pass\n\nprint(a.count(0) // 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(N):\n if i+1 != a[i] and i+1 == a[a[i]-1]:\n a[a[i]-1] = 0\n a[i] = 0\n else:\n pass", "i", "range(N)", "range", "N", "if i+1 != a[i] and i+1 == a[a[i]-1]:\n a[a[i]-1] = 0\n a[i] = 0\n else:\n pass", "i+1 != a[i] and i+1 == a[a[i]-1]", "i+1 != a[i]", "i+1", "i", "1", "a[i]", "a", "i", "i+1 == a[a[i]-1]", "i+1", "i", "1", "a[a[i]-1]", "a", "a[i]-1", "a[i]", "a", "i", "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(a.count(0) // 2)", "print", "a.count(0) // 2", "a.count(0)", "a.count", "a", "count", "0", "2", "cnt = 0", "0", "cnt", "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())) cnt = 0 for i in range(N): if i+1 != a[i] and i+1 == a[a[i]-1]: a[a[i]-1] = 0 a[i] = 0 else: pass print(a.count(0) // 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, 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, 18, 13, 10, 18, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 18, 13, 10, 4, 13 ]
[ [ 92, 4 ], [ 77, 13 ], [ 80, 22 ], [ 86, 31 ], [ 95, 37 ], [ 83, 49 ], [ 53, 52 ], [ 87, 55 ], [ 96, 59 ], [ 96, 62 ], [ 52, 63 ], [ 52, 66 ], [ 89, 69 ], [ 90, 74 ], [ 84, 74 ], [ 77, 78 ], [ 80, 81 ], [ 83, 84 ], [ 86, 87 ], [ 89, 90 ], [ 92, 93 ], [ 95, 96 ] ]
[ "import sys\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nn = int(input())\na = list(map(int, input().split()))\ncnt = 0\nfor i in range(n):\n if a[a[i]-1] == i + 1:\n cnt += 1\nprint(cnt//2)", "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", "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", "i", "range(n)", "range", "n", "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", "readline = sys.stdin.buffer.readline", "sys.stdin.buffer.readline", "readline", "readlines = sys.stdin.buffer.readlines", "sys.stdin.buffer.readlines", "readlines", "cnt = 0", "0", "cnt", "n = int(input())", "int(input())", "n", "cnt += 1", "1", "cnt", "read = sys.stdin.buffer.read", "sys.stdin.buffer.read", "read", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a" ]
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines 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)
[ 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, 39, 0, 13, 13, 28, 13, 4, 13, 13, 0, 13, 2, 13, 17, 0, 13, 18, 13, 13, 4, 18, 18, 13, 2, 13, 17, 13, 13, 4, 18, 18, 13, 2, 13, 17, 13, 13, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 4, 18, 18, 13, 13, 13, 18, 13, 13, 17, 0, 13, 17, 4, 13, 2, 13, 17, 10, 4, 13, 10, 4, 13, 10, 13, 13, 10, 2, 13, 10, 18, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 92, 2 ], [ 95, 8 ], [ 22, 21 ], [ 93, 24 ], [ 98, 28 ], [ 32, 31 ], [ 93, 34 ], [ 101, 36 ], [ 31, 38 ], [ 104, 41 ], [ 96, 43 ], [ 31, 44 ], [ 99, 48 ], [ 102, 50 ], [ 105, 53 ], [ 99, 57 ], [ 105, 59 ], [ 102, 62 ], [ 110, 64 ], [ 68, 67 ], [ 93, 70 ], [ 99, 76 ], [ 67, 77 ], [ 111, 78 ], [ 108, 78 ], [ 96, 80 ], [ 67, 81 ], [ 107, 84 ], [ 108, 89 ], [ 111, 89 ], [ 92, 93 ], [ 95, 96 ], [ 98, 99 ], [ 101, 102 ], [ 104, 105 ], [ 107, 108 ], [ 110, 111 ] ]
[ "# n = int(input())\n# a = list(map(int, input().split()))\n# ans = [[i] for i in range(1, n+1)]\n# print(ans)\n# for i in range(n):\n# print(ans[i], a[i])\n# ans[i].apeend(a[i])\n# ans[a[i]-1].append(i)\n# print(ans)\n# これなんでダメだったかわからん\n\nn = int(input())\nb = list(map(int, input().split()))\n\nadlist = [[] for i in range(n)] # 交流のあるやつ同士の隣接リスト\nfor i in range(n): # 1から順に見ていく\n x = i+1\n y = b[i]\n adlist[x-1].append(y)\n adlist[y-1].append(x)\n# print(adlist)\ncount = 0\nfor i in range(n):\n if adlist[i].count(b[i]) == 2:\n count += 1\nprint(count//2)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "b = list(map(int, input().split()))", "b", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "[] for i in range(n)", "for i in range(n)", "i", "range(n)", "range", "n", "for i in range(n)", "[]", "adlist = [[] for i in range(n)]", "adlist", "[[] for i in range(n)]", "for i in range(n): # 1から順に見ていく\n x = i+1\n y = b[i]\n adlist[x-1].append(y)\n adlist[y-1].append(x)\n# print(adlist)", "i", "range(n)", "range", "n", "x = i+1", "x", "i+1", "i", "1", "y = b[i]", "y", "b[i]", "b", "i", "adlist[x-1].append(y)", "[x-1].append", "[x-1]", "adlist", "x-1", "x", "1", "append", "y", "adlist[y-1].append(x)", "[y-1].append", "[y-1]", "adlist", "y-1", "y", "1", "append", "x", "count = 0", "count", "0", "for i in range(n):\n if adlist[i].count(b[i]) == 2:\n count += 1", "i", "range(n)", "range", "n", "if adlist[i].count(b[i]) == 2:\n count += 1", "adlist[i].count(b[i]) == 2", "adlist[i].count(b[i])", "[i].count", "[i]", "adlist", "i", "count", "b[i]", "b", "i", "2", "count += 1", "count", "1", "print(count//2)", "print", "count//2", "count", "2", "n = int(input())", "int(input())", "n", "b = list(map(int, input().split()))", "list(map(int, input().split()))", "b", "adlist = [[] for i in range(n)]", "[[] for i in range(n)]", "adlist", "x = i+1", "i+1", "x", "y = b[i]", "b[i]", "y", "count += 1", "1", "count", "count = 0", "0", "count" ]
# n = int(input()) # a = list(map(int, input().split())) # ans = [[i] for i in range(1, n+1)] # print(ans) # for i in range(n): # print(ans[i], a[i]) # ans[i].apeend(a[i]) # ans[a[i]-1].append(i) # print(ans) # これなんでダメだったかわからん n = int(input()) b = list(map(int, input().split())) adlist = [[] for i in range(n)] # 交流のあるやつ同士の隣接リスト for i in range(n): # 1から順に見ていく x = i+1 y = b[i] adlist[x-1].append(y) adlist[y-1].append(x) # print(adlist) count = 0 for i in range(n): if adlist[i].count(b[i]) == 2: count += 1 print(count//2)
[ 7, 0, 13, 4, 13, 4, 13, 41, 28, 13, 4, 18, 4, 13, 13, 17, 4, 4, 13, 13, 0, 13, 13, 0, 13, 4, 13, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 18, 13, 13, 14, 2, 13, 13, 9, 14, 2, 18, 13, 2, 13, 17, 2, 13, 17, 4, 18, 13, 13, 2, 13, 17, 0, 13, 17, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 18, 13, 10, 13, 13, 10, 17, 13 ]
[ [ 69, 2 ], [ 10, 9 ], [ 9, 19 ], [ 81, 21 ], [ 72, 24 ], [ 75, 28 ], [ 32, 31 ], [ 70, 34 ], [ 78, 36 ], [ 82, 38 ], [ 31, 39 ], [ 31, 42 ], [ 73, 43 ], [ 82, 48 ], [ 79, 50 ], [ 31, 53 ], [ 73, 57 ], [ 79, 60 ], [ 84, 63 ], [ 85, 67 ], [ 76, 67 ], [ 69, 70 ], [ 72, 73 ], [ 75, 76 ], [ 78, 79 ], [ 81, 82 ], [ 84, 85 ] ]
[ "N = int(input())\nrabit = [ int(v) for v in input().split(\" \") ]\nskip = set()\nnum = 0\n \nfor i in range(N):\n n = rabit[i]\n if i in skip:\n continue\n if rabit[n-1] == i+1:\n skip.add(n-1)\n num += 1\n \nprint(num)", "N = int(input())", "N", "int(input())", "int", "input()", "input", "int(v) for v in input().split(\" \")", "for v in input().split(\" \")", "v", "input().split(\" \")", "().split", "()", "input", "split", "\" \"", "for v in input().split(\" \")", "int(v)", "int", "v", "rabit = [ int(v) for v in input().split(\" \") ]", "rabit", "[ int(v) for v in input().split(\" \") ]", "skip = set()", "skip", "set()", "set", "num = 0", "num", "0", "for i in range(N):\n n = rabit[i]\n if i in skip:\n continue\n if rabit[n-1] == i+1:\n skip.add(n-1)\n num += 1\n ", "i", "range(N)", "range", "N", "n = rabit[i]", "n", "rabit[i]", "rabit", "i", "if i in skip:\n continue\n ", "i in skip", "i", "skip", "continue", "if rabit[n-1] == i+1:\n skip.add(n-1)\n num += 1\n ", "rabit[n-1] == i+1", "rabit[n-1]", "rabit", "n-1", "n", "1", "i+1", "i", "1", "skip.add(n-1)", "skip.add", "skip", "add", "n-1", "n", "1", "num += 1", "num", "1", "print(num)", "print", "num", "N = int(input())", "int(input())", "N", "skip = set()", "set()", "skip", "num = 0", "0", "num", "n = rabit[i]", "rabit[i]", "n", "rabit = [ int(v) for v in input().split(\" \") ]", "[ int(v) for v in input().split(\" \") ]", "rabit", "num += 1", "1", "num" ]
N = int(input()) rabit = [ int(v) for v in input().split(" ") ] skip = set() num = 0 for i in range(N): n = rabit[i] if i in skip: continue if rabit[n-1] == i+1: skip.add(n-1) num += 1 print(num)
[ 7, 15, 13, 0, 13, 4, 13, 4, 13, 0, 13, 4, 18, 13, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 0, 13, 17, 0, 13, 2, 39, 17, 13, 28, 13, 13, 4, 13, 13, 14, 18, 13, 13, 9, 0, 18, 13, 13, 17, 14, 2, 18, 13, 13, 13, 0, 13, 17, 0, 18, 13, 13, 17, 4, 13, 13, 10, 2, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 74, 4 ], [ 83, 10 ], [ 77, 26 ], [ 86, 29 ], [ 71, 32 ], [ 75, 36 ], [ 78, 42 ], [ 84, 42 ], [ 72, 45 ], [ 52, 49 ], [ 72, 50 ], [ 78, 56 ], [ 84, 56 ], [ 80, 60 ], [ 66, 63 ], [ 72, 64 ], [ 81, 69 ], [ 87, 69 ], [ 71, 72 ], [ 74, 75 ], [ 77, 78 ], [ 80, 81 ], [ 83, 84 ], [ 86, 87 ] ]
[ "import numpy as np\nn = int(input())\nA = np.array(list(map(int, input().split())))\nA -= 1\n\nans = 0\nseen = [0] * n\nfor i, ai in enumerate(A):\n if seen[i]:\n continue\n seen[i] = 1\n if A[ai] == i:\n ans += 1\n seen[ai] = 1\n\nprint(ans)", "import numpy as np", "numpy", "n = int(input())", "n", "int(input())", "int", "input()", "input", "A = np.array(list(map(int, input().split())))", "A", "np.array(list(map(int, input().split())))", "np.array", "np", "array", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "A -= 1", "A", "1", "ans = 0", "ans", "0", "seen = [0] * n", "seen", "[0] * n", "[0]", "0", "n", "for i, ai in enumerate(A):\n if seen[i]:\n continue\n seen[i] = 1\n if A[ai] == i:\n ans += 1\n seen[ai] = 1", "i", "ai", "enumerate(A)", "enumerate", "A", "if seen[i]:\n continue\n ", "seen[i]", "seen", "i", "continue", "seen[i] = 1", "seen[i]", "seen", "i", "1", "if A[ai] == i:\n ans += 1\n seen[ai] = 1", "A[ai] == i", "A[ai]", "A", "ai", "i", "ans += 1", "ans", "1", "seen[ai] = 1", "seen[ai]", "seen", "ai", "1", "print(ans)", "print", "ans", "seen = [0] * n", "[0] * n", "seen", "n = int(input())", "int(input())", "n", "A -= 1", "1", "A", "ans += 1", "1", "ans", "A = np.array(list(map(int, input().split())))", "np.array(list(map(int, input().split())))", "A", "ans = 0", "0", "ans" ]
import numpy as np n = int(input()) A = np.array(list(map(int, input().split()))) A -= 1 ans = 0 seen = [0] * n for i, ai in enumerate(A): if seen[i]: continue seen[i] = 1 if A[ai] == i: ans += 1 seen[ai] = 1 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, 18, 13, 13, 13, 9, 14, 2, 13, 18, 13, 18, 13, 13, 0, 13, 17, 4, 13, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 2, 13 ]
[ [ 61, 2 ], [ 64, 8 ], [ 55, 23 ], [ 27, 26 ], [ 62, 31 ], [ 65, 36 ], [ 26, 37 ], [ 26, 38 ], [ 26, 42 ], [ 65, 44 ], [ 65, 46 ], [ 26, 47 ], [ 58, 49 ], [ 59, 53 ], [ 56, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ] ]
[ "n = int(input())\nA = [0] + list(map(int, input().split()))\n\nans=0\nfor i in range(1,n+1):\n if A[i]<i:\n #既にチェック済み\n continue\n if i==A[A[i]]:\n ans+=1\n\nprint(ans)", "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 in range(1,n+1):\n if A[i]<i:\n #既にチェック済み\n continue\n if i==A[A[i]]:\n ans+=1", "i", "range(1,n+1)", "range", "1", "n+1", "n", "1", "if A[i]<i:\n #既にチェック済み\n continue\n ", "A[i]<i", "A[i]", "A", "i", "i", "continue", "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", "print(ans)", "print", "ans", "ans=0", "0", "ans", "ans+=1", "1", "ans", "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())) ans=0 for i in range(1,n+1): if A[i]<i: #既にチェック済み continue if i==A[A[i]]: ans+=1 print(ans)
[ 7, 15, 13, 13, 13, 13, 13, 0, 13, 12, 4, 18, 4, 18, 4, 18, 18, 18, 13, 13, 13, 13, 13, 13, 17, 0, 13, 4, 13, 17, 0, 13, 2, 2, 17, 17, 17, 0, 13, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 28, 13, 4, 13, 13, 28, 13, 4, 13, 13, 14, 40, 2, 18, 13, 13, 13, 14, 2, 18, 13, 18, 13, 13, 13, 4, 13, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 13, 13, 10, 12, 13, 10, 2, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 111, 8 ], [ 117, 26 ], [ 114, 31 ], [ 108, 38 ], [ 118, 39 ], [ 99, 41 ], [ 96, 44 ], [ 120, 47 ], [ 105, 50 ], [ 112, 54 ], [ 102, 56 ], [ 112, 65 ], [ 69, 68 ], [ 106, 71 ], [ 74, 73 ], [ 106, 76 ], [ 103, 81 ], [ 73, 82 ], [ 73, 83 ], [ 103, 87 ], [ 103, 89 ], [ 73, 90 ], [ 73, 91 ], [ 100, 94 ], [ 96, 97 ], [ 99, 100 ], [ 102, 103 ], [ 105, 106 ], [ 118, 108 ], [ 108, 109 ], [ 111, 112 ], [ 114, 115 ], [ 117, 118 ], [ 120, 121 ] ]
[ "#!/usr/bin/env python3\nimport sys, math, itertools, collections, bisect\ninput = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')\ninf = float('inf') ;mod = 10**9+7\nmans = inf ;ans = 0 ;count = 0 ;pro = 1\n\nn = int(input())\nA = list(map(int,input().split()))\nfor i in range(n): A[i] -= 1\nfor i in range(n):\n if not A[i] > i:continue\n else:\n if A[A[i]] == i:ans += 1\nprint(ans)", "import sys, math, itertools, collections, bisect", "sys", "math", "itertools", "collections", "bisect", "input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')", "input", "lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')", "sys.stdin.buffer.readline().rstrip().decode('utf-8')", "sys.stdin.buffer.readline().rstrip().decode", "sys.stdin.buffer.readline().rstrip()", "sys.stdin.buffer.readline().rstrip", "sys.stdin.buffer.readline()", "sys.stdin.buffer.readline", "sys.stdin.buffer", "sys.stdin", "sys", "stdin", "buffer", "readline", "rstrip", "decode", "'utf-8'", "inf = float('inf')", "inf", "float('inf')", "float", "'inf'", "mod = 10**9+7", "mod", "10**9+7", "10**9", "10", "9", "7", "mans = inf", "mans", "inf", "ans = 0", "ans", "0", "count = 0", "count", "0", "pro = 1", "pro", "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", "for i in range(n): A[i] -= 1", "i", "range(n)", "range", "n", "for i in range(n):\n if not A[i] > i:continue\n else:\n if A[A[i]] == i:ans += 1", "i", "range(n)", "range", "n", "if not A[i] > i:continue\n else:\n if A[A[i]] == i:ans += 1", "not A[i] > i", "A[i] > i", "A[i]", "A", "i", "i", "if A[A[i]] == i:ans ", "A[A[i]] == i", "A[A[i]]", "A", "A[i]", "A", "i", "i", "print(ans)", "print", "ans", "count = 0", "0", "count", "ans = 0", "0", "ans", "A = list(map(int,input().split()))", "list(map(int,input().split()))", "A", "n = int(input())", "int(input())", "n", "mans = inf", "inf", "mans", "input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')", "lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')", "input", "mod = 10**9+7", "10**9+7", "mod", "inf = float('inf')", "float('inf')", "inf", "pro = 1", "1", "pro" ]
#!/usr/bin/env python3 import sys, math, itertools, collections, bisect input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') inf = float('inf') ;mod = 10**9+7 mans = inf ;ans = 0 ;count = 0 ;pro = 1 n = int(input()) A = list(map(int,input().split())) for i in range(n): A[i] -= 1 for i in range(n): if not A[i] > i:continue else: if A[A[i]] == i:ans += 1 print(ans)
[ 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, 0, 13, 18, 13, 13, 14, 2, 18, 13, 13, 13, 0, 13, 17, 4, 13, 2, 13, 17, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 18, 13, 10, 17, 13 ]
[ [ 56, 2 ], [ 59, 8 ], [ 60, 21 ], [ 62, 26 ], [ 30, 29 ], [ 57, 34 ], [ 65, 37 ], [ 60, 39 ], [ 29, 40 ], [ 60, 44 ], [ 66, 45 ], [ 29, 46 ], [ 68, 48 ], [ 69, 53 ], [ 63, 53 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ] ]
[ "N = int(input())\nA = list(map(int,input().split()))\nA.insert(0,0)\ncnt = 0\nfor i in range(1,N+1):\n ind = A[i]\n if A[ind]==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", "A.insert(0,0)", "A.insert", "A", "insert", "0", "0", "cnt = 0", "cnt", "0", "for i in range(1,N+1):\n ind = A[i]\n if A[ind]==i:\n cnt += 1", "i", "range(1,N+1)", "range", "1", "N+1", "N", "1", "ind = A[i]", "ind", "A[i]", "A", "i", "if A[ind]==i:\n cnt += 1", "A[ind]==i", "A[ind]", "A", "ind", "i", "cnt += 1", "cnt", "1", "print(cnt//2)", "print", "cnt//2", "cnt", "2", "N = int(input())", "int(input())", "N", "A = list(map(int,input().split()))", "list(map(int,input().split()))", "A", "cnt = 0", "0", "cnt", "ind = A[i]", "A[i]", "ind", "cnt += 1", "1", "cnt" ]
N = int(input()) A = list(map(int,input().split())) A.insert(0,0) cnt = 0 for i in range(1,N+1): ind = A[i] if A[ind]==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, 0, 13, 17, 0, 13, 4, 13, 4, 13, 17, 13, 17, 28, 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, 10, 4, 13 ]
[ [ 67, 2 ], [ 64, 8 ], [ 58, 20 ], [ 61, 23 ], [ 68, 29 ], [ 33, 32 ], [ 62, 32 ], [ 65, 37 ], [ 65, 40 ], [ 32, 41 ], [ 32, 44 ], [ 55, 47 ], [ 56, 52 ], [ 59, 52 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ] ]
[ "n = int(input())\na_list = list(map(int, input().split()))\n\ncnt = 0\nindex_list = list(range(0,n,1))\n\nfor i in (index_list):\n if a_list[a_list[i]-1] == i+1:\n cnt += 1\nprint(cnt//2)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "a_list = list(map(int, input().split()))", "a_list", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "cnt = 0", "cnt", "0", "index_list = list(range(0,n,1))", "index_list", "list(range(0,n,1))", "list", "range(0,n,1)", "range", "0", "n", "1", "for i in (index_list):\n if a_list[a_list[i]-1] == i+1:\n cnt += 1", "i", "index_list", "if a_list[a_list[i]-1] == i+1:\n cnt += 1", "a_list[a_list[i]-1] == i+1", "a_list[a_list[i]-1]", "a_list", "a_list[i]-1", "a_list[i]", "a_list", "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", "index_list = list(range(0,n,1))", "list(range(0,n,1))", "index_list", "a_list = list(map(int, input().split()))", "list(map(int, input().split()))", "a_list", "n = int(input())", "int(input())", "n" ]
n = int(input()) a_list = list(map(int, input().split())) cnt = 0 index_list = list(range(0,n,1)) for i in (index_list): if a_list[a_list[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, 14, 2, 2, 18, 13, 2, 13, 17, 17, 13, 0, 13, 17, 0, 13, 2, 13, 17, 4, 13, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 18, 13, 10, 2, 13 ]
[ [ 56, 2 ], [ 65, 8 ], [ 62, 20 ], [ 24, 23 ], [ 57, 26 ], [ 68, 28 ], [ 66, 30 ], [ 23, 31 ], [ 66, 36 ], [ 69, 38 ], [ 23, 41 ], [ 59, 43 ], [ 71, 46 ], [ 60, 48 ], [ 63, 48 ], [ 72, 54 ], [ 60, 54 ], [ 63, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ] ]
[ "n = int(input())\nl = list(map(int, input().split()))\n\ncount = 0\nfor i in range(n):\n x = l[i]\n if l[x-1]-1 == i:\n count += 1\n\ncount = count//2\nprint(int(count))", "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", "count = 0", "count", "0", "for i in range(n):\n x = l[i]\n if l[x-1]-1 == i:\n count += 1", "i", "range(n)", "range", "n", "x = l[i]", "x", "l[i]", "l", "i", "if l[x-1]-1 == i:\n count += 1", "l[x-1]-1 == i", "l[x-1]-1", "l[x-1]", "l", "x-1", "x", "1", "1", "i", "count += 1", "count", "1", "count = count//2", "count", "count//2", "count", "2", "print(int(count))", "print", "int(count)", "int", "count", "n = int(input())", "int(input())", "n", "count += 1", "1", "count", "count = 0", "0", "count", "l = list(map(int, input().split()))", "list(map(int, input().split()))", "l", "x = l[i]", "l[i]", "x", "count = count//2", "count//2", "count" ]
n = int(input()) l = list(map(int, input().split())) count = 0 for i in range(n): x = l[i] if l[x-1]-1 == i: count += 1 count = count//2 print(int(count))
[ 7, 15, 13, 13, 13, 13, 13, 15, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 18, 18, 13, 13, 13, 13, 0, 13, 17, 28, 13, 13, 4, 13, 13, 14, 2, 2, 13, 2, 18, 13, 2, 13, 17, 17, 2, 13, 2, 13, 17, 0, 13, 17, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 62, 9 ], [ 65, 15 ], [ 68, 31 ], [ 66, 38 ], [ 66, 45 ], [ 71, 56 ], [ 72, 60 ], [ 69, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ] ]
[ "import sys, heapq, bisect, math, fractions\nfrom collections import deque\n\nN = int(input())\nA = list(map(int, sys.stdin.readline().rsplit()))\n\nres = 0\nfor i, a in enumerate(A):\n if i == A[a - 1] - 1 and i < a - 1:\n res += 1\n\nprint(res)", "import sys, heapq, bisect, math, fractions", "sys", "heapq", "bisect", "math", "fractions", "from collections import deque", "N = int(input())", "N", "int(input())", "int", "input()", "input", "A = list(map(int, sys.stdin.readline().rsplit()))", "A", "list(map(int, sys.stdin.readline().rsplit()))", "list", "map(int, sys.stdin.readline().rsplit())", "map", "int", "sys.stdin.readline().rsplit()", "sys.stdin.readline().rsplit", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "rsplit", "res = 0", "res", "0", "for i, a in enumerate(A):\n if i == A[a - 1] - 1 and i < a - 1:\n res += 1", "i", "a", "enumerate(A)", "enumerate", "A", "if i == A[a - 1] - 1 and i < a - 1:\n res += 1", "i == A[a - 1] - 1 and i < a - 1", "i == A[a - 1] - 1", "i", "A[a - 1] - 1", "A[a - 1]", "A", "a - 1", "a", "1", "1", "i < a - 1", "i", "a - 1", "a", "1", "res += 1", "res", "1", "print(res)", "print", "res", "N = int(input())", "int(input())", "N", "A = list(map(int, sys.stdin.readline().rsplit()))", "list(map(int, sys.stdin.readline().rsplit()))", "A", "res = 0", "0", "res", "res += 1", "1", "res" ]
import sys, heapq, bisect, math, fractions from collections import deque N = int(input()) A = list(map(int, sys.stdin.readline().rsplit())) res = 0 for i, a in enumerate(A): if i == A[a - 1] - 1 and i < a - 1: res += 1 print(res)
[ 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, 40, 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, 17, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 59, 2 ], [ 53, 8 ], [ 62, 20 ], [ 24, 23 ], [ 60, 26 ], [ 54, 30 ], [ 23, 31 ], [ 45, 35 ], [ 54, 36 ], [ 23, 39 ], [ 56, 42 ], [ 48, 45 ], [ 54, 46 ], [ 57, 51 ], [ 63, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ] ]
[ "N = int(input())\na = list(map(int, input().split()))\n\nans = 0\nfor i in range(N):\n if a[i] != \"\": n = a[i] - 1\n if a[n] == i + 1:\n ans += 1\n a[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", "ans = 0", "ans", "0", "for i in range(N):\n if a[i] != \"\": n = a[i] - 1\n if a[n] == i + 1:\n ans += 1\n a[n] = \"\"", "i", "range(N)", "range", "N", "if a[i] != \"\": n = a[i] - 1\n ", "a[i] != \"\"", "a[i]", "a", "i", "\"\"", "if a[n] == i + 1:\n ans += 1\n a[n] = \"\"", "a[n] == i + 1", "a[n]", "a", "n", "i + 1", "i", "1", "ans += 1", "ans", "1", "a[n] = \"\"", "a[n]", "a", "n", "\"\"", "print(ans)", "print", "ans", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "ans += 1", "1", "ans", "N = int(input())", "int(input())", "N", "ans = 0", "0", "ans" ]
N = int(input()) a = list(map(int, input().split())) ans = 0 for i in range(N): if a[i] != "": n = a[i] - 1 if a[n] == i + 1: ans += 1 a[n] = "" 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, 13, 4, 13, 13, 14, 2, 2, 13, 17, 18, 13, 2, 13, 17, 0, 13, 17, 4, 13, 4, 13, 2, 13, 17, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 52, 2 ], [ 55, 8 ], [ 49, 20 ], [ 56, 27 ], [ 56, 34 ], [ 58, 39 ], [ 59, 46 ], [ 50, 46 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ] ]
[ "n = int(input())\na = list(map(int,input().split()))\nans = 0\nfor index,aa in enumerate(a):\n if index+1 == a[aa-1]:\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", "ans = 0", "ans", "0", "for index,aa in enumerate(a):\n if index+1 == a[aa-1]:\n ans += 1", "index", "aa", "enumerate(a)", "enumerate", "a", "if index+1 == a[aa-1]:\n ans += 1", "index+1 == a[aa-1]", "index+1", "index", "1", "a[aa-1]", "a", "aa-1", "aa", "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", "a = list(map(int,input().split()))", "list(map(int,input().split()))", "a", "ans += 1", "1", "ans" ]
n = int(input()) a = list(map(int,input().split())) ans = 0 for index,aa in enumerate(a): if index+1 == a[aa-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, 0, 13, 17, 28, 39, 13, 13, 4, 13, 4, 13, 13, 13, 14, 2, 13, 2, 18, 13, 2, 13, 17, 17, 0, 13, 17, 4, 13, 2, 13, 17, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 51, 2 ], [ 60, 8 ], [ 57, 20 ], [ 26, 23 ], [ 52, 30 ], [ 61, 31 ], [ 61, 37 ], [ 54, 43 ], [ 55, 48 ], [ 58, 48 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ] ]
[ "n=int(input())\na=list(map(int,input().split()))\nans=0\nfor (i,j) in zip(range(n),a):\n if i==a[j-1]-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 (i,j) in zip(range(n),a):\n if i==a[j-1]-1:\n ans+=1", "(i,j)", "i", "j", "zip(range(n),a)", "zip", "range(n)", "range", "n", "a", "if i==a[j-1]-1:\n ans+=1", "i==a[j-1]-1", "i", "a[j-1]-1", "a[j-1]", "a", "j-1", "j", "1", "1", "ans+=1", "ans", "1", "print(ans//2)", "print", "ans//2", "ans", "2", "n=int(input())", "int(input())", "n", "ans+=1", "1", "ans", "ans=0", "0", "ans", "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,j) in zip(range(n),a): if i==a[j-1]-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, 41, 28, 13, 4, 13, 2, 13, 17, 4, 4, 13, 39, 0, 13, 13, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 2, 13, 17, 18, 13, 18, 13, 13, 0, 13, 17, 4, 18, 18, 13, 2, 13, 17, 13, 18, 13, 13, 4, 13, 13, 10, 17, 13, 10, 13, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 76, 2 ], [ 82, 8 ], [ 22, 21 ], [ 77, 25 ], [ 73, 32 ], [ 70, 35 ], [ 39, 38 ], [ 77, 41 ], [ 38, 45 ], [ 74, 48 ], [ 83, 50 ], [ 38, 51 ], [ 79, 53 ], [ 74, 58 ], [ 38, 60 ], [ 83, 64 ], [ 38, 65 ], [ 80, 68 ], [ 71, 68 ], [ 70, 71 ], [ 73, 74 ], [ 76, 77 ], [ 79, 80 ], [ 82, 83 ] ]
[ "N = int(input())\na = list(map(int,input().split()))\nl = [set([]) for k in range(N+1)]\nans = 0\nfor k in range(N):\n if k+1 in l[a[k]]:\n ans += 1\n l[k+1].add(a[k])\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", "set([]) for k in range(N+1)", "for k in range(N+1)", "k", "range(N+1)", "range", "N+1", "N", "1", "for k in range(N+1)", "set([])", "set", "[]", "l = [set([]) for k in range(N+1)]", "l", "[set([]) for k in range(N+1)]", "ans = 0", "ans", "0", "for k in range(N):\n if k+1 in l[a[k]]:\n ans += 1\n l[k+1].add(a[k])", "k", "range(N)", "range", "N", "if k+1 in l[a[k]]:\n ans += 1\n ", "k+1 in l[a[k]]", "k+1", "k", "1", "l[a[k]]", "l", "a[k]", "a", "k", "ans += 1", "ans", "1", "l[k+1].add(a[k])", "[k+1].add", "[k+1]", "l", "k+1", "k", "1", "add", "a[k]", "a", "k", "print(ans)", "print", "ans", "ans = 0", "0", "ans", "l = [set([]) for k in range(N+1)]", "[set([]) for k in range(N+1)]", "l", "N = int(input())", "int(input())", "N", "ans += 1", "1", "ans", "a = list(map(int,input().split()))", "list(map(int,input().split()))", "a" ]
N = int(input()) a = list(map(int,input().split())) l = [set([]) for k in range(N+1)] ans = 0 for k in range(N): if k+1 in l[a[k]]: ans += 1 l[k+1].add(a[k]) 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, 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, 17, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 60, 2 ], [ 54, 8 ], [ 57, 20 ], [ 55, 27 ], [ 55, 31 ], [ 55, 34 ], [ 51, 41 ], [ 52, 48 ], [ 58, 48 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ] ]
[ "N = int(input())\nA = list(map(int, input().split()))\n\ncounter = 0\n\nfor i, A_i in enumerate(A):\n if A[A[i]-1] == i + 1 :\n counter += 1\n \nprint(int(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", "counter = 0", "counter", "0", "for i, A_i in enumerate(A):\n if A[A[i]-1] == i + 1 :\n counter += 1\n ", "i", "A_i", "enumerate(A)", "enumerate", "A", "if A[A[i]-1] == i + 1 :\n counter += 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", "counter += 1", "counter", "1", "print(int(counter/2))", "print", "int(counter/2)", "int", "counter/2", "counter", "2", "counter += 1", "1", "counter", "A = list(map(int, input().split()))", "list(map(int, input().split()))", "A", "counter = 0", "0", "counter", "N = int(input())", "int(input())", "N" ]
N = int(input()) A = list(map(int, input().split())) counter = 0 for i, A_i in enumerate(A): if A[A[i]-1] == i + 1 : counter += 1 print(int(counter/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, 18, 13, 18, 13, 13, 13, 0, 13, 17, 4, 13, 2, 13, 17, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 53, 2 ], [ 59, 8 ], [ 60, 21 ], [ 62, 26 ], [ 30, 29 ], [ 54, 34 ], [ 60, 39 ], [ 60, 41 ], [ 29, 42 ], [ 29, 43 ], [ 56, 45 ], [ 57, 50 ], [ 63, 50 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ] ]
[ "N=int(input())\nai=list(map(int,input().split()))\nai.insert(0,0)\n\nans=0\n\nfor i in range(1,N+1):\n if ai[ai[i]]==i:\n ans+=1\n else:\n pass\nprint(ans//2)", "N=int(input())", "N", "int(input())", "int", "input()", "input", "ai=list(map(int,input().split()))", "ai", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ai.insert(0,0)", "ai.insert", "ai", "insert", "0", "0", "ans=0", "ans", "0", "for i in range(1,N+1):\n if ai[ai[i]]==i:\n ans+=1\n else:\n pass", "i", "range(1,N+1)", "range", "1", "N+1", "N", "1", "if ai[ai[i]]==i:\n ans+=1\n else:\n pass", "ai[ai[i]]==i", "ai[ai[i]]", "ai", "ai[i]", "ai", "i", "i", "ans+=1", "ans", "1", "print(ans//2)", "print", "ans//2", "ans", "2", "N=int(input())", "int(input())", "N", "ans+=1", "1", "ans", "ai=list(map(int,input().split()))", "list(map(int,input().split()))", "ai", "ans=0", "0", "ans" ]
N=int(input()) ai=list(map(int,input().split())) ai.insert(0,0) ans=0 for i in range(1,N+1): if ai[ai[i]]==i: ans+=1 else: pass print(ans//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, 4, 13, 13, 0, 13, 18, 13, 13, 14, 2, 18, 13, 2, 13, 17, 13, 9, 14, 2, 2, 18, 13, 2, 13, 17, 17, 13, 0, 13, 17, 4, 13, 13, 10, 4, 13, 10, 18, 13, 10, 13, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 61, 2 ], [ 10, 9 ], [ 9, 18 ], [ 67, 20 ], [ 70, 23 ], [ 27, 26 ], [ 62, 29 ], [ 64, 31 ], [ 68, 33 ], [ 26, 34 ], [ 68, 38 ], [ 65, 40 ], [ 65, 42 ], [ 68, 48 ], [ 65, 50 ], [ 26, 53 ], [ 73, 55 ], [ 74, 59 ], [ 71, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ], [ 70, 71 ], [ 73, 74 ] ]
[ "N = int(input())\nA = [int(i) for i in input().split()]\ncnt = 0\nfor i in range(N):\n a = A[i]\n if A[a - 1] < a:\n continue\n if A[a - 1] - 1 == i:\n cnt += 1\nprint(cnt)", "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()]", "cnt = 0", "cnt", "0", "for i in range(N):\n a = A[i]\n if A[a - 1] < a:\n continue\n if A[a - 1] - 1 == i:\n cnt += 1", "i", "range(N)", "range", "N", "a = A[i]", "a", "A[i]", "A", "i", "if A[a - 1] < a:\n continue\n ", "A[a - 1] < a", "A[a - 1]", "A", "a - 1", "a", "1", "a", "continue", "if A[a - 1] - 1 == i:\n cnt += 1", "A[a - 1] - 1 == i", "A[a - 1] - 1", "A[a - 1]", "A", "a - 1", "a", "1", "1", "i", "cnt += 1", "cnt", "1", "print(cnt)", "print", "cnt", "N = int(input())", "int(input())", "N", "a = A[i]", "A[i]", "a", "A = [int(i) for i in input().split()]", "[int(i) for i in input().split()]", "A", "cnt = 0", "0", "cnt", "cnt += 1", "1", "cnt" ]
N = int(input()) A = [int(i) for i in input().split()] cnt = 0 for i in range(N): a = A[i] if A[a - 1] < a: continue if A[a - 1] - 1 == i: 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, 4, 13, 28, 13, 13, 4, 13, 13, 0, 18, 13, 2, 13, 17, 13, 0, 13, 17, 28, 13, 4, 18, 13, 13, 14, 2, 18, 13, 18, 13, 13, 13, 0, 13, 17, 0, 13, 4, 13, 2, 13, 17, 4, 13, 13, 29, 4, 13, 10, 12, 13 ]
[ [ 5, 4 ], [ 11, 10 ], [ 23, 22 ], [ 10, 30 ], [ 37, 32 ], [ 22, 33 ], [ 40, 39 ], [ 43, 42 ], [ 22, 45 ], [ 22, 50 ], [ 22, 52 ], [ 42, 53 ], [ 42, 54 ], [ 57, 56 ], [ 60, 59 ], [ 56, 63 ], [ 39, 63 ], [ 59, 67 ], [ 56, 67 ], [ 39, 67 ], [ 73, 70 ] ]
[ "def resolve():\n N = int(input())\n a = list(map(int, input().split()))\n dic = dict()\n for i, an in enumerate(a):\n dic[i + 1] = an\n ans = 0\n # print('dic', dic)\n for d in dic.keys():\n if dic[dic[d]] == d:\n ans += 1\n ans = int(ans/2)\n print(ans)\n return\nresolve()", "def resolve():\n N = int(input())\n a = list(map(int, input().split()))\n dic = dict()\n for i, an in enumerate(a):\n dic[i + 1] = an\n ans = 0\n # print('dic', dic)\n for d in dic.keys():\n if dic[dic[d]] == d:\n ans += 1\n ans = int(ans/2)\n print(ans)\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", "dic = dict()", "dic", "dict()", "dict", "for i, an in enumerate(a):\n dic[i + 1] = an\n ", "i", "an", "enumerate(a)", "enumerate", "a", "dic[i + 1] = an", "dic[i + 1]", "dic", "i + 1", "i", "1", "an", "ans = 0", "ans", "0", "for d in dic.keys():\n if dic[dic[d]] == d:\n ans += 1\n ", "d", "dic.keys()", "dic.keys", "dic", "keys", "if dic[dic[d]] == d:\n ans += 1\n ", "dic[dic[d]] == d", "dic[dic[d]]", "dic", "dic[d]", "dic", "d", "d", "ans += 1", "ans", "1", "ans = int(ans/2)", "ans", "int(ans/2)", "int", "ans/2", "ans", "2", "print(ans)", "print", "ans", "return", "resolve()", "resolve", "def resolve():\n N = int(input())\n a = list(map(int, input().split()))\n dic = dict()\n for i, an in enumerate(a):\n dic[i + 1] = an\n ans = 0\n # print('dic', dic)\n for d in dic.keys():\n if dic[dic[d]] == d:\n ans += 1\n ans = int(ans/2)\n print(ans)\n return", "def resolve():\n N = int(input())\n a = list(map(int, input().split()))\n dic = dict()\n for i, an in enumerate(a):\n dic[i + 1] = an\n ans = 0\n # print('dic', dic)\n for d in dic.keys():\n if dic[dic[d]] == d:\n ans += 1\n ans = int(ans/2)\n print(ans)\n return", "resolve" ]
def resolve(): N = int(input()) a = list(map(int, input().split())) dic = dict() for i, an in enumerate(a): dic[i + 1] = an ans = 0 # print('dic', dic) for d in dic.keys(): if dic[dic[d]] == d: ans += 1 ans = int(ans/2) print(ans) return resolve()
[ 7, 15, 13, 0, 13, 18, 18, 13, 13, 13, 4, 18, 13, 13, 2, 17, 17, 15, 15, 15, 15, 15, 15, 15, 12, 13, 12, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 4, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 39, 4, 13, 12, 13, 12, 13, 23, 13, 12, 13, 23, 13, 0, 13, 2, 17, 17, 0, 13, 2, 2, 17, 17, 17, 0, 13, 4, 13, 0, 13, 4, 13, 41, 28, 13, 4, 13, 13, 4, 39, 0, 13, 13, 28, 13, 4, 13, 13, 4, 18, 18, 13, 2, 18, 13, 13, 17, 13, 2, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 18, 13, 13, 0, 13, 17, 4, 13, 2, 13, 17, 10, 13, 13, 10, 18, 13, 10, 2, 13, 10, 12, 13, 10, 12, 13, 10, 4, 13, 10, 12, 13, 10, 2, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 17, 13, 10, 17, 13, 10, 12, 13, 10, 4, 13 ]
[ [ 140, 4 ], [ 33, 32 ], [ 141, 40 ], [ 46, 45 ], [ 156, 52 ], [ 58, 58 ], [ 62, 62 ], [ 143, 64 ], [ 158, 69 ], [ 179, 76 ], [ 147, 78 ], [ 152, 80 ], [ 156, 82 ], [ 86, 85 ], [ 180, 88 ], [ 137, 92 ], [ 96, 95 ], [ 180, 98 ], [ 138, 102 ], [ 153, 105 ], [ 95, 106 ], [ 95, 110 ], [ 170, 113 ], [ 117, 116 ], [ 180, 119 ], [ 153, 123 ], [ 116, 124 ], [ 138, 126 ], [ 116, 127 ], [ 173, 129 ], [ 174, 134 ], [ 171, 134 ], [ 137, 138 ], [ 140, 141 ], [ 143, 144 ], [ 152, 153 ], [ 158, 159 ], [ 170, 171 ], [ 173, 174 ], [ 179, 180 ] ]
[ "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**7)\nfrom collections import Counter, deque\nfrom collections import defaultdict\nfrom itertools import combinations, permutations, accumulate, groupby, product\nfrom bisect import bisect_left,bisect_right\nfrom heapq import heapify, heappop, heappush\nfrom math import floor, ceil\nfrom operator import itemgetter\ndef I(): return int(input())\ndef MI(): return map(int, input().split())\ndef LI(): return list(map(int, input().split()))\ndef LI2(): return [int(input()) for i in range(n)]\ndef MXI(): return [[LI()]for i in range(n)]\ndef printns(x): print('\\n'.join(x))\ndef printni(x): print('\\n'.join(list(map(str,x))))\ninf = 10**17\nmod = 10**9 + 7\n#s=input().rstrip()\nn=I()\nlis=LI()\nliked=[[] for i in range(n)]\nfor i in range(n):\n liked[lis[i]-1].append(i+1)\n#print(liked)\ncount=0\nfor i in range(n):\n if lis[i] in liked[i]:\n count+=1\nprint(count//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", "from collections import Counter, deque", "from collections import defaultdict", "from itertools import combinations, permutations, accumulate, groupby, product", "from bisect import bisect_left,bisect_right", "from heapq import heapify, heappop, heappush", "from math import floor, ceil", "from operator import itemgetter", "def I(): return int(input())", "I", "def MI(): return map(int, input().split())", "MI", "def LI(): return list(map(int, input().split()))", "LI", "int(input()) for i in range(n)", "for i in range(n)", "i", "range(n)", "range", "n", "for i in range(n)", "int(input())", "int", "input()", "input", "def LI2(): return [int(input()) for i in range(n)]", "LI2", "[LI()]for i in range(n)", "for i in range(n)", "i", "range(n)", "range", "n", "for i in range(n)", "[LI()]", "LI()", "LI", "def MXI(): return [[LI()]for i in range(n)]", "MXI", "def printns(x): print('\\n'.join(x))", "printns", "x", "x", "def printni(x): print('\\n'.join(list(map(str,x))))", "printni", "x", "x", "inf = 10**17", "inf", "10**17", "10", "17", "mod = 10**9 + 7", "mod", "10**9 + 7", "10**9", "10", "9", "7", "n=I()", "n", "I()", "I", "lis=LI()", "lis", "LI()", "LI", "[] for i in range(n)", "for i in range(n)", "i", "range(n)", "range", "n", "for i in range(n)", "[]", "liked=[[] for i in range(n)]", "liked", "[[] for i in range(n)]", "for i in range(n):\n liked[lis[i]-1].append(i+1)\n#print(liked)", "i", "range(n)", "range", "n", "liked[lis[i]-1].append(i+1)", "[lis[i]-1].append", "[lis[i]-1]", "liked", "lis[i]-1", "lis[i]", "lis", "i", "1", "append", "i+1", "i", "1", "count=0", "count", "0", "for i in range(n):\n if lis[i] in liked[i]:\n count+=1", "i", "range(n)", "range", "n", "if lis[i] in liked[i]:\n count+=1", "lis[i] in liked[i]", "lis[i]", "lis", "i", "liked[i]", "liked", "i", "count+=1", "count", "1", "print(count//2)", "print", "count//2", "count", "2", "liked=[[] for i in range(n)]", "[[] for i in range(n)]", "liked", "input = sys.stdin.readline", "sys.stdin.readline", "input", "inf = 10**17", "10**17", "inf", "def I(): return int(input())", "def I(): return int(input())", "I", "def MI(): return map(int, input().split())", "def MI(): return map(int, input().split())", "MI", "lis=LI()", "LI()", "lis", "def LI(): return list(map(int, input().split()))", "def LI(): return list(map(int, input().split()))", "LI", "mod = 10**9 + 7", "10**9 + 7", "mod", "def LI2(): return [int(input()) for i in range(n)]", "def LI2(): return [int(input()) for i in range(n)]", "LI2", "def MXI(): return [[LI()]for i in range(n)]", "def MXI(): return [[LI()]for i in range(n)]", "MXI", "def printns(x): print('\\n'.join(x))", "def printns(x): print('\\n'.join(x))", "printns", "count=0", "0", "count", "count+=1", "1", "count", "def printni(x): print('\\n'.join(list(map(str,x))))", "def printni(x): print('\\n'.join(list(map(str,x))))", "printni", "n=I()", "I()", "n" ]
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby, product from bisect import bisect_left,bisect_right from heapq import heapify, heappop, heappush from math import floor, ceil from operator import itemgetter def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) def LI2(): return [int(input()) for i in range(n)] def MXI(): return [[LI()]for i in range(n)] def printns(x): print('\n'.join(x)) def printni(x): print('\n'.join(list(map(str,x)))) inf = 10**17 mod = 10**9 + 7 #s=input().rstrip() n=I() lis=LI() liked=[[] for i in range(n)] for i in range(n): liked[lis[i]-1].append(i+1) #print(liked) count=0 for i in range(n): if lis[i] in liked[i]: count+=1 print(count//2)
[ 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, 0, 13, 18, 13, 13, 14, 2, 2, 18, 13, 13, 13, 2, 18, 13, 13, 13, 0, 13, 17, 4, 13, 2, 13, 17, 10, 4, 13, 10, 2, 13, 10, 18, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 59, 2 ], [ 62, 8 ], [ 71, 23 ], [ 27, 26 ], [ 60, 31 ], [ 65, 34 ], [ 63, 36 ], [ 26, 37 ], [ 63, 42 ], [ 26, 43 ], [ 66, 44 ], [ 63, 47 ], [ 66, 48 ], [ 26, 49 ], [ 68, 51 ], [ 69, 56 ], [ 72, 56 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ] ]
[ "n = int(input())\naaa = [0] + list(map(int, input().split()))\nans = 0\nfor i in range(1, n + 1):\n j = aaa[i]\n if aaa[i] == j and aaa[j] == i:\n ans += 1\nprint(ans // 2)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "aaa = [0] + list(map(int, input().split()))", "aaa", "[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 in range(1, n + 1):\n j = aaa[i]\n if aaa[i] == j and aaa[j] == i:\n ans += 1", "i", "range(1, n + 1)", "range", "1", "n + 1", "n", "1", "j = aaa[i]", "j", "aaa[i]", "aaa", "i", "if aaa[i] == j and aaa[j] == i:\n ans += 1", "aaa[i] == j and aaa[j] == i", "aaa[i] == j", "aaa[i]", "aaa", "i", "j", "aaa[j] == i", "aaa[j]", "aaa", "j", "i", "ans += 1", "ans", "1", "print(ans // 2)", "print", "ans // 2", "ans", "2", "n = int(input())", "int(input())", "n", "aaa = [0] + list(map(int, input().split()))", "[0] + list(map(int, input().split()))", "aaa", "j = aaa[i]", "aaa[i]", "j", "ans += 1", "1", "ans", "ans = 0", "0", "ans" ]
n = int(input()) aaa = [0] + list(map(int, input().split())) ans = 0 for i in range(1, n + 1): j = aaa[i] if aaa[i] == j and aaa[j] == i: ans += 1 print(ans // 2)
[ 7, 15, 0, 13, 4, 13, 4, 18, 4, 18, 13, 13, 13, 41, 28, 13, 4, 18, 4, 18, 4, 18, 13, 13, 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, 17, 13, 10, 17, 13, 10, 4, 13, 10, 13, 13 ]
[ [ 68, 3 ], [ 16, 15 ], [ 15, 29 ], [ 71, 31 ], [ 62, 34 ], [ 38, 37 ], [ 69, 40 ], [ 72, 44 ], [ 72, 47 ], [ 37, 48 ], [ 37, 51 ], [ 65, 54 ], [ 66, 59 ], [ 63, 59 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ] ]
[ "from sys import stdin\nN = int(stdin.readline().rstrip())\nA = [int(x) for x in stdin.readline().rstrip().split()]\nans = 0\nfor i in range(N):\n if A[A[i]-1] == i+1:\n ans += 1\nprint(ans//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", "int(x) for x in stdin.readline().rstrip().split()", "for x in stdin.readline().rstrip().split()", "x", "stdin.readline().rstrip().split()", "stdin.readline().rstrip().split", "stdin.readline().rstrip()", "stdin.readline().rstrip", "stdin.readline()", "stdin.readline", "stdin", "readline", "rstrip", "split", "for x in stdin.readline().rstrip().split()", "int(x)", "int", "x", "A = [int(x) for x in stdin.readline().rstrip().split()]", "A", "[int(x) for x in stdin.readline().rstrip().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", "ans = 0", "0", "ans", "ans += 1", "1", "ans", "N = int(stdin.readline().rstrip())", "int(stdin.readline().rstrip())", "N", "A = [int(x) for x in stdin.readline().rstrip().split()]", "[int(x) for x in stdin.readline().rstrip().split()]", "A" ]
from sys import stdin N = int(stdin.readline().rstrip()) A = [int(x) for x in stdin.readline().rstrip().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, 0, 13, 2, 18, 13, 13, 17, 14, 2, 2, 13, 13, 2, 18, 13, 13, 2, 13, 17, 0, 13, 17, 4, 13, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 56, 2 ], [ 59, 8 ], [ 62, 20 ], [ 24, 23 ], [ 57, 26 ], [ 53, 28 ], [ 60, 31 ], [ 23, 32 ], [ 54, 37 ], [ 23, 38 ], [ 60, 41 ], [ 54, 42 ], [ 23, 44 ], [ 65, 47 ], [ 66, 51 ], [ 63, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ] ]
[ "N=int(input())\nA=list(map(int, input().split()))\ncount=0\nfor i in range(N):\n a=A[i]-1\n if a>i and A[a]==i+1:\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 a=A[i]-1\n if a>i and A[a]==i+1:\n count+=1", "i", "range(N)", "range", "N", "a=A[i]-1", "a", "A[i]-1", "A[i]", "A", "i", "1", "if a>i and A[a]==i+1:\n count+=1", "a>i and A[a]==i+1", "a>i", "a", "i", "A[a]==i+1", "A[a]", "A", "a", "i+1", "i", "1", "count+=1", "count", "1", "print(count)", "print", "count", "a=A[i]-1", "A[i]-1", "a", "N=int(input())", "int(input())", "N", "A=list(map(int, input().split()))", "list(map(int, input().split()))", "A", "count=0", "0", "count", "count+=1", "1", "count" ]
N=int(input()) A=list(map(int, input().split())) count=0 for i in range(N): a=A[i]-1 if a>i and A[a]==i+1: count+=1 print(count)
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 18, 4, 13, 17, 13, 13, 31, 13, 4, 13, 2, 4, 13, 2, 18, 13, 2, 13, 17, 2, 13, 17, 17, 10, 4, 13 ]
[ [ 33, 2 ], [ 33, 15 ], [ 33, 34 ] ]
[ "n, *a = map(int, open(0).read().split())\nprint(sum(a[b - 1] == e + 1 for e, b in enumerate(a)) // 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(a[b - 1] == e + 1 for e, b in enumerate(a)) // 2)", "print", "sum(a[b - 1] == e + 1 for e, b in enumerate(a)) // 2", "sum(a[b - 1] == e + 1 for e, b in enumerate(a))", "sum", "a[b - 1] == e + 1", "a[b - 1]", "a", "b - 1", "b", "1", "e + 1", "e", "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(a[b - 1] == e + 1 for e, b 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, 13, 4, 2, 13, 17, 0, 13, 13, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 18, 13, 18, 13, 13, 13, 0, 13, 17, 0, 13, 2, 13, 17, 4, 13, 13, 10, 2, 13, 10, 4, 13, 10, 17, 13, 10, 13, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 61, 2 ], [ 70, 8 ], [ 22, 21 ], [ 71, 21 ], [ 21, 25 ], [ 67, 28 ], [ 73, 31 ], [ 35, 34 ], [ 62, 37 ], [ 68, 41 ], [ 71, 41 ], [ 68, 43 ], [ 71, 43 ], [ 34, 44 ], [ 34, 45 ], [ 64, 47 ], [ 58, 50 ], [ 65, 52 ], [ 74, 52 ], [ 59, 56 ], [ 65, 56 ], [ 74, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ], [ 70, 71 ], [ 73, 74 ] ]
[ "n = int(input())\nA = list(map(int, input().split()))\nA = [a-1 for a in A]\n\nans = 0\nfor i in range(n):\n if A[A[i]] == i:\n ans += 1\nans = ans//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-1 for a in A", "for a in A", "a", "A", "for a in A", "a-1", "a", "1", "A = [a-1 for a in A]", "A", "[a-1 for a in A]", "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", "ans = ans//2", "ans", "ans//2", "ans", "2", "print(ans)", "print", "ans", "ans = ans//2", "ans//2", "ans", "n = int(input())", "int(input())", "n", "ans += 1", "1", "ans", "A = [a-1 for a in A]", "[a-1 for a in A]", "A", "A = list(map(int, input().split()))", "list(map(int, input().split()))", "A", "ans = 0", "0", "ans" ]
n = int(input()) A = list(map(int, input().split())) A = [a-1 for a in A] ans = 0 for i in range(n): if A[A[i]] == i: ans += 1 ans = 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, 39, 17, 0, 13, 13, 0, 13, 17, 28, 13, 4, 13, 17, 2, 13, 17, 14, 2, 13, 18, 13, 18, 13, 13, 0, 13, 17, 4, 13, 2, 13, 17, 10, 39, 13, 10, 4, 13, 10, 13, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 63, 2 ], [ 57, 8 ], [ 54, 20 ], [ 60, 24 ], [ 58, 25 ], [ 66, 27 ], [ 31, 30 ], [ 64, 35 ], [ 30, 39 ], [ 61, 41 ], [ 55, 41 ], [ 61, 43 ], [ 55, 43 ], [ 30, 44 ], [ 69, 46 ], [ 70, 51 ], [ 67, 51 ], [ 54, 55 ], [ 57, 58 ], [ 58, 60 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ], [ 69, 70 ] ]
[ "N = int(input())\na = list(map(int,input().split()))\nb = [0]\nb += a\ncnt = 0\nfor i in range(1,N+1):\n\tif i == b[b[i]]:\n\t\tcnt += 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", "b = [0]", "b", "[0]", "0", "b += a", "b", "a", "cnt = 0", "cnt", "0", "for i in range(1,N+1):\n\tif i == b[b[i]]:\n\t\tcnt += 1", "i", "range(1,N+1)", "range", "1", "N+1", "N", "1", "if i == b[b[i]]:\n\t\tcnt += 1", "i == b[b[i]]", "i", "b[b[i]]", "b", "b[i]", "b", "i", "cnt += 1", "cnt", "1", "print(cnt // 2)", "print", "cnt // 2", "cnt", "2", "b = [0]", "[0]", "b", "a = list(map(int,input().split()))", "list(map(int,input().split()))", "a", "b += a", "a", "b", "N = int(input())", "int(input())", "N", "cnt = 0", "0", "cnt", "cnt += 1", "1", "cnt" ]
N = int(input()) a = list(map(int,input().split())) b = [0] b += a cnt = 0 for i in range(1,N+1): if i == b[b[i]]: cnt += 1 print(cnt // 2)
[ 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, 14, 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 ], [ 57, 54 ] ]
[ "def main():\n rabbits = int(input())\n like = list(map(int, input().split()))\n answer = 0\n for i in range(rabbits):\n if like[like[i] - 1] == i + 1:\n answer += 1\n print(answer // 2)\n\n\nif __name__ == '__main__':\n main()\n", "def main():\n rabbits = int(input())\n like = list(map(int, input().split()))\n answer = 0\n for i in range(rabbits):\n if like[like[i] - 1] == i + 1:\n answer += 1\n print(answer // 2)", "main", "rabbits = int(input())", "rabbits", "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", "answer = 0", "answer", "0", "for i in range(rabbits):\n if like[like[i] - 1] == i + 1:\n answer += 1\n ", "i", "range(rabbits)", "range", "rabbits", "if like[like[i] - 1] == i + 1:\n answer += 1\n ", "like[like[i] - 1] == i + 1", "like[like[i] - 1]", "like", "like[i] - 1", "like[i]", "like", "i", "1", "i + 1", "i", "1", "answer += 1", "answer", "1", "print(answer // 2)", "print", "answer // 2", "answer", "2", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def main():\n rabbits = int(input())\n like = list(map(int, input().split()))\n answer = 0\n for i in range(rabbits):\n if like[like[i] - 1] == i + 1:\n answer += 1\n print(answer // 2)", "def main():\n rabbits = int(input())\n like = list(map(int, input().split()))\n answer = 0\n for i in range(rabbits):\n if like[like[i] - 1] == i + 1:\n answer += 1\n print(answer // 2)", "main" ]
def main(): rabbits = int(input()) like = list(map(int, input().split())) answer = 0 for i in range(rabbits): if like[like[i] - 1] == i + 1: answer += 1 print(answer // 2) if __name__ == '__main__': main()
[ 7, 15, 15, 15, 15, 15, 15, 13, 15, 13, 4, 18, 13, 13, 17, 0, 13, 2, 2, 17, 17, 17, 12, 13, 29, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 12, 13, 0, 13, 4, 13, 4, 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, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 2, 13, 10, 12, 13 ]
[ [ 85, 16 ], [ 39, 38 ], [ 45, 44 ], [ 89, 46 ], [ 49, 48 ], [ 52, 51 ], [ 38, 54 ], [ 44, 58 ], [ 44, 61 ], [ 51, 62 ], [ 51, 65 ], [ 69, 68 ], [ 68, 73 ], [ 48, 73 ], [ 83, 80 ], [ 85, 86 ] ]
[ "from statistics import median\n#import collections\n#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]\nfrom fractions import gcd\nfrom itertools import combinations # (string,3) 3回\nfrom collections import deque\nfrom collections import defaultdict\nimport bisect\n#\n# d = m - k[i] - k[j]\n# if kk[bisect.bisect_right(kk,d) - 1] == d:\n#\n#\n#\n# pythonで無理なときは、pypyでやると正解するかも!!\n#\n#\n\nimport sys\nsys.setrecursionlimit(10000000)\nmod = 10**9 + 7\n\ndef readInts():\n return list(map(int,input().split()))\ndef main():\n n = int(input())\n RA = readInts()\n ans = 0\n for i in range(n):\n if RA[RA[i]-1] == i+1:\n ans += 1\n print(ans//2)\nif __name__ == '__main__':\n main()", "from statistics import median", "from fractions import gcd", "from itertools import combinations", "from collections import deque", "from collections import defaultdict", "import bisect", "bisect", "import sys", "sys", "sys.setrecursionlimit(10000000)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10000000", "mod = 10**9 + 7", "mod", "10**9 + 7", "10**9", "10", "9", "7", "def readInts():\n return list(map(int,input().split()))", "readInts", "return list(map(int,input().split()))", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "def main():\n n = int(input())\n RA = readInts()\n ans = 0\n for i in range(n):\n if RA[RA[i]-1] == i+1:\n ans += 1\n print(ans//2)", "main", "n = int(input())", "n", "int(input())", "int", "input()", "input", "RA = readInts()", "RA", "readInts()", "readInts", "ans = 0", "ans", "0", "for i in range(n):\n if RA[RA[i]-1] == i+1:\n ans += 1\n ", "i", "range(n)", "range", "n", "if RA[RA[i]-1] == i+1:\n ans += 1\n ", "RA[RA[i]-1] == i+1", "RA[RA[i]-1]", "RA", "RA[i]-1", "RA[i]", "RA", "i", "1", "i+1", "i", "1", "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 RA = readInts()\n ans = 0\n for i in range(n):\n if RA[RA[i]-1] == i+1:\n ans += 1\n print(ans//2)", "def main():\n n = int(input())\n RA = readInts()\n ans = 0\n for i in range(n):\n if RA[RA[i]-1] == i+1:\n ans += 1\n print(ans//2)", "main", "mod = 10**9 + 7", "10**9 + 7", "mod", "def readInts():\n return list(map(int,input().split()))", "def readInts():\n return list(map(int,input().split()))", "readInts" ]
from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations # (string,3) 3回 from collections import deque from collections import defaultdict import bisect # # d = m - k[i] - k[j] # if kk[bisect.bisect_right(kk,d) - 1] == d: # # # # pythonで無理なときは、pypyでやると正解するかも!! # # import sys sys.setrecursionlimit(10000000) mod = 10**9 + 7 def readInts(): return list(map(int,input().split())) def main(): n = int(input()) RA = readInts() ans = 0 for i in range(n): if RA[RA[i]-1] == i+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, 17, 28, 13, 4, 13, 13, 14, 2, 2, 18, 13, 13, 2, 13, 17, 2, 2, 13, 17, 18, 13, 2, 18, 13, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 57, 2 ], [ 63, 8 ], [ 69, 20 ], [ 24, 23 ], [ 58, 26 ], [ 64, 31 ], [ 23, 32 ], [ 61, 32 ], [ 23, 34 ], [ 61, 34 ], [ 23, 38 ], [ 61, 38 ], [ 64, 41 ], [ 64, 44 ], [ 23, 45 ], [ 61, 45 ], [ 66, 48 ], [ 60, 51 ], [ 67, 55 ], [ 70, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ], [ 69, 70 ] ]
[ "n=int(input())\na=list(map(int,input().split()))\n\nans = 0\nfor i in range(n):\n\n if a[i] > i+1 and i+1 == a[a[i]-1]:\n\n ans+=1\n\n 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", "ans = 0", "ans", "0", "for i in range(n):\n\n if a[i] > i+1 and i+1 == a[a[i]-1]:\n\n ans+=1\n\n i+=1", "i", "range(n)", "range", "n", "if a[i] > i+1 and i+1 == a[a[i]-1]:\n\n ans+=1\n\n ", "a[i] > i+1 and i+1 == a[a[i]-1]", "a[i] > i+1", "a[i]", "a", "i", "i+1", "i", "1", "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)", "print", "ans", "n=int(input())", "int(input())", "n", "i+=1", "1", "i", "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 i in range(n): if a[i] > i+1 and i+1 == a[a[i]-1]: ans+=1 i+=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, 18, 13, 13, 17, 28, 13, 4, 13, 13, 14, 2, 18, 13, 18, 13, 13, 13, 0, 13, 17, 4, 13, 2, 13, 17, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 60, 2 ], [ 57, 8 ], [ 54, 20 ], [ 24, 23 ], [ 61, 26 ], [ 31, 28 ], [ 58, 29 ], [ 23, 30 ], [ 34, 33 ], [ 61, 36 ], [ 58, 40 ], [ 28, 41 ], [ 58, 42 ], [ 33, 43 ], [ 33, 44 ], [ 63, 46 ], [ 64, 51 ], [ 55, 51 ], [ 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 A[i]-=1\n\nfor i in range(N):\n if A[A[i]]==i:\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", "for i in range(N):\n A[i]-=1", "i", "range(N)", "range", "N", "A[i]-=1", "A[i]", "A", "i", "1", "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", "ans=0", "0", "ans", "A=list(map(int,input().split()))", "list(map(int,input().split()))", "A", "N=int(input())", "int(input())", "N", "ans+=1", "1", "ans" ]
N=int(input()) A=list(map(int,input().split())) ans=0 for i in range(N): A[i]-=1 for i in range(N): 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, 14, 2, 18, 13, 2, 18, 13, 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 ]
[ [ 54, 2 ], [ 51, 8 ], [ 57, 20 ], [ 24, 23 ], [ 55, 26 ], [ 52, 30 ], [ 52, 33 ], [ 23, 34 ], [ 23, 37 ], [ 48, 40 ], [ 49, 45 ], [ 58, 45 ], [ 48, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ] ]
[ "n = int(input())\na = list(map(int, input().split()))\ncnt = 0\nfor i in range(n):\n if a[a[i]-1] == i+1:\n cnt += 1\nprint(cnt >> 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", "cnt = 0", "cnt", "0", "for i in range(n):\n if a[a[i]-1] == i+1:\n cnt += 1", "i", "range(n)", "range", "n", "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 >> 1)", "print", "cnt >> 1", "cnt", "1", "cnt += 1", "1", "cnt", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "n = int(input())", "int(input())", "n", "cnt = 0", "0", "cnt" ]
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 >> 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, 0, 13, 17, 4, 13, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 59, 2 ], [ 56, 8 ], [ 50, 20 ], [ 57, 27 ], [ 57, 32 ], [ 47, 38 ], [ 53, 41 ], [ 54, 45 ], [ 48, 45 ], [ 51, 45 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ] ]
[ "n = int(input())\na = list(map(int, input().split()))\n\ncnt = 0\nfor i, e in enumerate(a, 1):\n if a[e-1] == i:\n cnt += 1\n\ncnt //= 2\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, e in enumerate(a, 1):\n if a[e-1] == i:\n cnt += 1", "i", "e", "enumerate(a, 1)", "enumerate", "a", "1", "if a[e-1] == i:\n cnt += 1", "a[e-1] == i", "a[e-1]", "a", "e-1", "e", "1", "i", "cnt += 1", "cnt", "1", "cnt //= 2", "cnt", "2", "print(cnt)", "print", "cnt", "cnt += 1", "1", "cnt", "cnt = 0", "0", "cnt", "cnt //= 2", "2", "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, e in enumerate(a, 1): if a[e-1] == i: cnt += 1 cnt //= 2 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, 13, 4, 13, 13, 14, 2, 18, 13, 2, 13, 17, 2, 13, 17, 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 ], [ 10, 33 ], [ 42, 41 ], [ 41, 46 ], [ 22, 46 ], [ 56, 53 ] ]
[ "def main():\n n = int(input())\n a = list(map(int, input().split()))\n cnt = 0\n for i, x in enumerate(a):\n if a[x-1] == i+1:\n cnt += 1\n\n print(cnt//2)\n\nif __name__ == '__main__':\n main()", "def main():\n n = int(input())\n a = list(map(int, input().split()))\n cnt = 0\n for i, x in enumerate(a):\n if a[x-1] == i+1:\n cnt += 1\n\n print(cnt//2)", "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", "cnt = 0", "cnt", "0", "for i, x in enumerate(a):\n if a[x-1] == i+1:\n cnt += 1\n\n ", "i", "x", "enumerate(a)", "enumerate", "a", "if a[x-1] == i+1:\n cnt += 1\n\n ", "a[x-1] == i+1", "a[x-1]", "a", "x-1", "x", "1", "i+1", "i", "1", "cnt += 1", "cnt", "1", "print(cnt//2)", "print", "cnt//2", "cnt", "2", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def main():\n n = int(input())\n a = list(map(int, input().split()))\n cnt = 0\n for i, x in enumerate(a):\n if a[x-1] == i+1:\n cnt += 1\n\n print(cnt//2)", "def main():\n n = int(input())\n a = list(map(int, input().split()))\n cnt = 0\n for i, x in enumerate(a):\n if a[x-1] == i+1:\n cnt += 1\n\n print(cnt//2)", "main" ]
def main(): n = int(input()) a = list(map(int, input().split())) cnt = 0 for i, x in enumerate(a): if a[x-1] == i+1: cnt += 1 print(cnt//2) if __name__ == '__main__': main()
[ 7, 15, 13, 13, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 12, 13, 12, 13, 12, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 12, 13, 23, 13, 4, 18, 13, 13, 2, 17, 17, 0, 13, 4, 13, 17, 0, 13, 2, 2, 17, 17, 17, 15, 0, 13, 4, 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, 12, 13, 10, 12, 13, 10, 4, 13, 10, 4, 13, 10, 12, 13, 10, 2, 13, 10, 12, 13, 10, 17, 13, 10, 12, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 26, 25 ], [ 118, 31 ], [ 35, 35 ], [ 99, 44 ], [ 108, 49 ], [ 102, 57 ], [ 97, 59 ], [ 120, 61 ], [ 106, 63 ], [ 114, 65 ], [ 69, 68 ], [ 103, 71 ], [ 121, 75 ], [ 121, 78 ], [ 68, 79 ], [ 68, 82 ], [ 123, 85 ], [ 124, 90 ], [ 115, 90 ], [ 99, 100 ], [ 102, 103 ], [ 108, 109 ], [ 114, 115 ], [ 120, 121 ], [ 123, 124 ] ]
[ "import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log\nfrom itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom bisect import bisect, bisect_left, insort, insort_left\nfrom fractions import gcd\nfrom heapq import heappush, heappop\nfrom functools import reduce\nfrom decimal import Decimal\ndef input(): return sys.stdin.readline().strip()\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(): return list(map(int, input().split()))\ndef ZIP(n): return zip(*(MAP() for _ in range(n)))\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10**9 + 7\nfrom decimal import *\n\nN = INT()\na = LIST()\n\ncnt = 0\nfor i in range(N):\n\tif a[a[i]-1] == i+1:\n\t\tcnt += 1\n\nprint(cnt//2)", "import sys, re", "sys", "re", "from collections import deque, defaultdict, Counter", "from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees", "from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby", "from operator import itemgetter, mul", "from copy import deepcopy", "from string import ascii_lowercase, ascii_uppercase, digits", "from bisect import bisect, bisect_left, insort, insort_left", "from fractions import gcd", "from heapq import heappush, heappop", "from functools import reduce", "from decimal import Decimal", "def input(): return sys.stdin.readline().strip()", "input", "def INT(): return int(input())", "INT", "def MAP(): return map(int, input().split())", "MAP", "def LIST(): return list(map(int, input().split()))", "LIST", "MAP() for _ in range(n)", "for _ in range(n)", "_", "range(n)", "range", "n", "for _ in range(n)", "MAP()", "MAP", "def ZIP(n): return zip(*(MAP() for _ in range(n)))", "ZIP", "n", "n", "sys.setrecursionlimit(10 ** 9)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10 ** 9", "10", "9", "INF = float('inf')", "INF", "float('inf')", "float", "'inf'", "mod = 10**9 + 7", "mod", "10**9 + 7", "10**9", "10", "9", "7", "from decimal import *", "N = INT()", "N", "INT()", "INT", "a = LIST()", "a", "LIST()", "LIST", "cnt = 0", "cnt", "0", "for i in range(N):\n\tif a[a[i]-1] == i+1:\n\t\tcnt += 1", "i", "range(N)", "range", "N", "if a[a[i]-1] == i+1:\n\t\tcnt += 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", "def input(): return sys.stdin.readline().strip()", "def input(): return sys.stdin.readline().strip()", "input", "def INT(): return int(input())", "def INT(): return int(input())", "INT", "INF = float('inf')", "float('inf')", "INF", "N = INT()", "INT()", "N", "def LIST(): return list(map(int, input().split()))", "def LIST(): return list(map(int, input().split()))", "LIST", "mod = 10**9 + 7", "10**9 + 7", "mod", "def ZIP(n): return zip(*(MAP() for _ in range(n)))", "def ZIP(n): return zip(*(MAP() for _ in range(n)))", "ZIP", "cnt = 0", "0", "cnt", "def MAP(): return map(int, input().split())", "def MAP(): return map(int, input().split())", "MAP", "a = LIST()", "LIST()", "a", "cnt += 1", "1", "cnt" ]
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from bisect import bisect, bisect_left, insort, insort_left from fractions import gcd from heapq import heappush, heappop from functools import reduce from decimal import Decimal def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(): return list(map(int, input().split())) def ZIP(n): return zip(*(MAP() for _ in range(n))) sys.setrecursionlimit(10 ** 9) INF = float('inf') mod = 10**9 + 7 from decimal import * N = INT() a = LIST() cnt = 0 for i in range(N): if a[a[i]-1] == i+1: cnt += 1 print(cnt//2)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 2, 39, 17, 2, 13, 17, 0, 18, 13, 39, 17, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 28, 13, 18, 13, 39, 17, 14, 2, 13, 18, 13, 18, 13, 13, 0, 13, 4, 13, 39, 13, 18, 13, 13, 13, 0, 13, 17, 4, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 77, 2 ], [ 71, 8 ], [ 78, 13 ], [ 20, 16 ], [ 72, 17 ], [ 65, 29 ], [ 34, 33 ], [ 72, 35 ], [ 33, 40 ], [ 72, 42 ], [ 72, 44 ], [ 33, 45 ], [ 74, 47 ], [ 72, 53 ], [ 33, 54 ], [ 74, 55 ], [ 80, 57 ], [ 81, 63 ], [ 66, 63 ], [ 65, 66 ], [ 74, 69 ], [ 71, 72 ], [ 74, 75 ], [ 77, 78 ], [ 80, 81 ] ]
[ "n = int(input())\na = [0]*(n+1)\na[1:] = map(int, input().split())\nans = set()\nfor i in a[1:]:\n if i==a[a[i]]:\n j, k = sorted([i, a[i]])\n ans |= {(j, k)}\nprint(len(ans))", "n = int(input())", "n", "int(input())", "int", "input()", "input", "a = [0]*(n+1)", "a", "[0]*(n+1)", "[0]", "0", "n+1", "n", "1", "a[1:] = map(int, input().split())", "a[1:]", "a", "1:", "1", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ans = set()", "ans", "set()", "set", "for i in a[1:]:\n if i==a[a[i]]:\n j, k = sorted([i, a[i]])\n ans |= {(j, k)}", "i", "a[1:]", "a", "1:", "1", "if i==a[a[i]]:\n j, k = sorted([i, a[i]])\n ans |= {(j, k)}", "i==a[a[i]]", "i", "a[a[i]]", "a", "a[i]", "a", "i", "j, k = sorted([i, a[i]])", "j", "sorted([i, a[i]])", "sorted", "[i, a[i]]", "i", "a[i]", "a", "i", "k", "ans |= {(j, k)}", "ans", "{(j, k)}", "print(len(ans))", "print", "len(ans)", "len", "ans", "ans = set()", "set()", "ans", "j, k = sorted([i, a[i]])", "sorted([i, a[i]])", "j", "a = [0]*(n+1)", "[0]*(n+1)", "a", "k = sorted([i, a[i]])", "sorted([i, a[i]])", "k", "n = int(input())", "int(input())", "n", "ans |= {(j, k)}", "{(j, k)}", "ans" ]
n = int(input()) a = [0]*(n+1) a[1:] = map(int, input().split()) ans = set() for i in a[1:]: if i==a[a[i]]: j, k = sorted([i, a[i]]) ans |= {(j, k)} print(len(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, 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, 17, 13, 10, 4, 13 ]
[ [ 74, 2 ], [ 65, 8 ], [ 68, 20 ], [ 24, 23 ], [ 75, 26 ], [ 66, 30 ], [ 66, 33 ], [ 23, 34 ], [ 66, 40 ], [ 66, 43 ], [ 23, 44 ], [ 23, 47 ], [ 71, 50 ], [ 60, 53 ], [ 66, 54 ], [ 66, 57 ], [ 23, 58 ], [ 72, 63 ], [ 69, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ], [ 74, 75 ] ]
[ "N = int(input())\na = list(map(int, input().split()))\n\nans = 0\nfor i in range(N):\n if a[a[i] - 1] < 0: continue\n if a[a[i] - 1] == i + 1:\n ans += 1\n a[a[i] - 1] = 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] < 0: continue\n if a[a[i] - 1] == i + 1:\n ans += 1\n a[a[i] - 1] = 0", "i", "range(N)", "range", "N", "if a[a[i] - 1] < 0: continue\n ", "a[a[i] - 1] < 0", "a[a[i] - 1]", "a", "a[i] - 1", "a[i]", "a", "i", "1", "0", "if a[a[i] - 1] == i + 1:\n ans += 1\n a[a[i] - 1] = 0", "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", "a[a[i] - 1] = 0", "a[a[i] - 1]", "a", "a[i] - 1", "a[i]", "a", "i", "1", "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] < 0: continue if a[a[i] - 1] == i + 1: ans += 1 a[a[i] - 1] = 0 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, 2, 18, 13, 18, 13, 13, 13, 2, 13, 18, 13, 13, 4, 13, 13, 10, 2, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 57, 2 ], [ 51, 8 ], [ 54, 23 ], [ 27, 26 ], [ 58, 31 ], [ 52, 37 ], [ 52, 39 ], [ 26, 40 ], [ 26, 41 ], [ 26, 43 ], [ 52, 45 ], [ 26, 46 ], [ 55, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ] ]
[ "N = int(input())\nA = [-1] + list(map(int,input().split()))\nans = 0\nfor i in range(1,N+1):\n if A[A[i]] == i and i<A[i]: ans += 1\nprint(ans)", "N = int(input())", "N", "int(input())", "int", "input()", "input", "A = [-1] + list(map(int,input().split()))", "A", "[-1] + list(map(int,input().split()))", "[-1]", "-1", "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 if A[A[i]] == i and i<A[i]: ans += 1", "i", "range(1,N+1)", "range", "1", "N+1", "N", "1", "if A[A[i]] == i and i<A[i]: ans +=", "A[A[i]] == i and i<A[i]", "A[A[i]] == i", "A[A[i]]", "A", "A[i]", "A", "i", "i", "i<A[i]", "i", "A[i]", "A", "i", "print(ans)", "print", "ans", "A = [-1] + list(map(int,input().split()))", "[-1] + list(map(int,input().split()))", "A", "ans = 0", "0", "ans", "N = int(input())", "int(input())", "N" ]
N = int(input()) A = [-1] + list(map(int,input().split())) ans = 0 for i in range(1,N+1): if A[A[i]] == i and i<A[i]: ans += 1 print(ans)