problem_id
stringlengths
6
6
user_id
stringlengths
10
10
time_limit
float64
1k
8k
memory_limit
float64
262k
1.05M
problem_description
stringlengths
48
1.55k
codes
stringlengths
35
98.9k
status
stringlengths
28
1.7k
submission_ids
stringlengths
28
1.41k
memories
stringlengths
13
808
cpu_times
stringlengths
11
610
code_sizes
stringlengths
7
505
p02689
u932868243
2,000
1,048,576
There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i. There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j. Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road. Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road. How many good observatories are there?
['n,m=map(int,input().split())\nh=list(map(int,input().split()))\nab=[list(map(int,input().split())) for _ in range(m)]\nlist=[0]*n\nfor a,b in ab:\n list[a-1]+=max(list[a-1],h[b-1])\n list[b-1]+=max(list[b-1],h[a-1])\ncount=0\nfor i in range(n):\n if list[i]<h[i]:\n count+=1\nprint(count)', 'n,m=map(int,input().split())\nh=list(map(int,input().split()))\nab=[list(map(int,input().split())) for _ in range(m)]\nlist=[0]*n\nfor a,b in ab:\n list[a-1]+=max(list[a-1],h[b-1])\n list[b-1]+=max(list[b-1],h[a-1])\nans=0\nfor i in range(n):\n if list[i]<h[i]:\n count+=1\nprint(count)\n ', 'n,m=map(int,input().split())\nh=list(map(int,input().split()))\nlists=[list(map(int,input().split())) for _ in range(m)]\nans=[[]]*n\nfor list in lists:\n ans[list[0]-1].append(list[1])\n ans[list[1]-1].append(list[0])\nnew=[]\nfor x in range(n):\n new.append(list(set(ans[x])))\nhigh=[[]]*n\nfor y in range(n):\n for z in range(len(new[y])):\n high[y].append(h[new[y][z]-1])\ncount=0\nfor x in range(n):\n if h[x]>max(high[x]):\n count+=1\nprint(count)', 'n,m=map(int,input().split())\nh=list(map(int,inpt().split()))\nab=[[] for nn in range(n)]\nfor mm in range(m):\n a,b=map(int,input().split())\n ab[a-1]+=b-1\n ab[b-1]+=a-1\ncnt=0\nfor i in range(n):\n hi=0\n for ll in ab[i]:\n hi=max(hi,h[ll])\n if hi==h[i]:\n cnt+=1\nprint(cnt)', 'n,m=map(int,input().split())\nh=list(map(int,input().split()))\nab=[[] for nn in range(n)]\nfor mm in range(m):\n a,b=map(int,input().split())\n ab[a-1].append(b-1)\n ab[b-1].append(a-1)\ncnt=0\nfor i in range(n):\n hi=0\n for ll in ab[i]:\n hi=max(hi,h[ll])\n if hi<h[i]:\n cnt+=1\nprint(cnt)']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s056956532', 's409873304', 's738660066', 's779617384', 's694123933']
[35204.0, 35252.0, 40512.0, 9124.0, 29480.0]
[467.0, 467.0, 285.0, 25.0, 396.0]
[283, 284, 446, 277, 291]
p02689
u941645670
2,000
1,048,576
There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i. There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j. Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road. Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road. How many good observatories are there?
['n,m =map(int, input().split())\nh = list(map(int, input().split()))\nab = [list(map(int, input().split())) for _ in range(m)]\na, b = [list(i) for i in zip(*ab)]\ntest = []\nfor i in range(1,n+1):\n check = [j[1] for j in ab if j[0] == i] + [j[0] for j in ab if j[1] == i]\n check = list(set(check))\n test.append(check)\nresult = 0\nfor j in range(len(test)):\n flag = 1\n for k in test[j]:\n print(k)\n if h[k-1] >= h[j]:\n flag = 0\n break\n if flag == 1:\n result += 1\nprint(result)', '#c\nn,m =map(int, input().split())\nh = list(map(int, input().split()))\nab = [list(map(int, input().split())) for _ in range(m)]\na, b = [list(i) for i in zip(*ab)]\nresult = []\nfor i in ab:\n if h[i[0]-1] > h[i[1]-1]:\n result.append(i[1])\n elif h[i[1]-1] > h[i[0]-1]:\n result.append(i[0])\n else:\n result.append(i[0])\n result.append(i[1])\nresult = list(set(result))\nprint(n - len(result))']
['Wrong Answer', 'Accepted']
['s815151586', 's775053619']
[39884.0, 39968.0]
[2206.0, 320.0]
[529, 420]
p02689
u942051624
2,000
1,048,576
There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i. There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j. Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road. Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road. How many good observatories are there?
['N,M=map(int, input().split())\nH=list(map(int,input().split()))\nList=[list(map(int,input().split())) for i in range(M)]\n\nsup_list=[1 for i in range(N)]\n\nfor j in range(M):\n if H[List[j][0]-1]>H[List[j][1]-1]:\n sup_list[List[j][1]-1]=0\n elif H[List[j][0]-1]==H[List[j][1]-1]:\n sup_list[List[j][0]-1]=0\n sup_list[List[j][1]-1]=0\n else:\n sup_list[List[j][0]-1]=0\n\nprint(sup_list)\nprint(sum(sup_list))', 'N,M=map(int, input().split())\nH=list(map(int,input().split()))\nList=[list(map(int,input().split())) for i in range(M)]\nans=0\nalllist=[[0 for i in range(N)]for j in range(N)]\n\nfor j in range(M):\n alllist[List[j][0]-1][List[j][1]-1]=1\n alllist[List[j][1]-1][List[j][0]-1]=1\n\n\nfor s in range(M):\n flag=True\n for t in range(M):\n if H[s]<alllist[s][t]*H[t]:\n flag=False\n break\n if flag:\n ans=ans+1\n\nprint(ans) ', 'N,M=map(int, input().split())\nH=list(map(int,input().split()))\nList=[list(map(int,input().split())) for i in range(M)]\n\nsup_list=[1 for i in range(N)]\n\nfor j in range(M):\n if H[List[j][0]-1]>H[List[j][1]-1]:\n sup_list[List[j][1]-1]=0\n elif H[List[j][0]-1]==H[List[j][1]-1]:\n sup_list[List[j][0]-1]=0\n sup_list[List[j][1]-1]=0\n else:\n sup_list[List[j][0]-1]=0\n\n\nprint(sum(sup_list))']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s265854564', 's544987621', 's409855579']
[32652.0, 568224.0, 31928.0]
[320.0, 2221.0, 319.0]
[433, 457, 418]
p02689
u944643608
2,000
1,048,576
There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i. There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j. Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road. Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road. How many good observatories are there?
['N, M = map(int, input().split())\nH = list(map(int, input().split()))\nans = []\ncount = 0\nfor i in range(M):\n A, B = map(int, input().split())\n if (A not in ans) and (B not in ans):\n count += 1\n ans.append(A)\n ans.append(B)\n elif A not in ans:\n ans.append(A)\n elif B not in ans:\n ans.append(B)\nprint(count)', 'N, M = map(int, input().split())\nH = list(map(int, input().split()))\nans_pin = [1] * N\nfor i in range(M):\n A, B = map(int, input().split())\n if H[A -1] < H[B-1] :\n ans_pin[A-1] = 0\n elif H[A -1] > H[B-1]:\n ans_pin[B-1] = 0\n else:\n ans_pin[A-1] = 0\n ans_pin[B-1] = 0\nprint(sum(ans_pin))']
['Wrong Answer', 'Accepted']
['s946881888', 's145192539']
[20028.0, 20040.0]
[2206.0, 259.0]
[324, 302]
p02689
u947047288
2,000
1,048,576
There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i. There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j. Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road. Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road. How many good observatories are there?
['N, M = map(int, input().split())\nHi = list(map(int,input().split(" ")))\npath = [list() for _ in range(M+1)]\n\nfor i in range(M):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n path[a].append(b)\n path[b].append(a)\n \n\ngoodT = 0\nT = range(M)\n\nfor i, p in zip(T, path):\n good = 1\n if p == []:\n goodT += good\n else:\n for t in p:\n if Hi[i] <= Hi[t]:\n good = 0\n goodT +=good\n \nprint (goodT)', 'N, M = map(int, input().split())\nHi = list(map(int,input().split(" ")))\npath = [list[] for _ in range(M+1)]\n\nfor i in range(M):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n path[a].append(b)\n path[b].append(a)\n \n\ngoodT = 0\nT = range(M+1)\n\nfor i, p in zip(T, path):\n good = 1\n if p == []:\n goodT += good\n else:\n for t in p:\n if Hi[i] <= Hi[t]:\n good = 0\n goodT +=good\n \nprint (goodT)', 'N, M = map(int, input().split())\nHi = list(map(int,input().split(" ")))\n#path = [list() for _ in range(M+1)]\n\nTallest = [0]*N\n\nfor i in range(M):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n Tallest[a] = max(Tallest[a], Hi[b])\n Tallest[b] = max(Tallest[b], Hi[a])\n\ngoodT = 0\n\nfor i in range(N):\n if Hi[i]>Tallest[i]:\n goodT +=1\n \nprint (goodT)\n ']
['Runtime Error', 'Runtime Error', 'Accepted']
['s127471025', 's866267087', 's515058661']
[29476.0, 8876.0, 20088.0]
[402.0, 24.0, 316.0]
[467, 469, 386]
p02689
u947327691
2,000
1,048,576
There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i. There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j. Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road. Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road. How many good observatories are there?
['n,m=map(int,input().split())\nl=list(map(int,input().split()))\ntmp=[0]*n\n\nfor i in range(m):\n a,b=map(int,input().split())\n if l[a-1] >= l[b-1]:\n tmp[b-1]=-1\n if l[a-1] <= l[b-1]\n tmp[a-1]=-1\n\nprint(tmp.count(0))', 'n,m=map(int,input().split())\nl=list(map(int,input().split()))\ntmp=[0]*n\n\nfor i in range(m):\n a,b=map(int,input().split())\n\n if l[a-1] > l[b-1]:\n tmp[b-1]=-1\n elif l[a-1] == l[b-1]:\n tmp[a-1]=-1\n tmp[b-1]=-1\n else:\n tmp[a-1]=-1\n\n\nprint(tmp.count(0))\n\n']
['Runtime Error', 'Accepted']
['s343938372', 's797425922']
[9056.0, 20036.0]
[23.0, 247.0]
[234, 290]
p02689
u949618949
2,000
1,048,576
There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i. There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j. Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road. Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road. How many good observatories are there?
["import sys\nimport os\nf = open('input.txt', 'r')\nsys.stdin = f\n\nN, M = map(int, input().split( ))\ni = 1\nViewH = {}\nH_list = input().split( )\ncountlist = []\nwhile i <= N:\n ViewH[i] = int(H_list[i-1])\n countlist.append(0)\n i += 1\n\n\nfor count in range(M - 1):\n A, B = map(int, input().split())\n if ViewH[A] > ViewH[B]:\n countlist[B-1] = 1\n elif ViewH[A] == ViewH[B]:\n countlist[A-1] = 1\n countlist[B-1] = 1\n else:\n countlist[A-1] = 1\n\nprint(countlist.count(0))\n", 'N, M = map(int, input().split( ))\ni = 1\nViewH = {}\nH_list = input().split( )\ncountlist = []\nwhile i <= N:\n ViewH[i] = int(H_list[i-1])\n countlist.append(0)\n i += 1\n#print(ViewH)\n\n\nfor count in range(M):\n A, B = map(int, input().split())\n \n if ViewH[A] > ViewH[B]:\n countlist[B-1] = 1\n elif ViewH[A] == ViewH[B]:\n countlist[A-1] = 1\n countlist[B-1] = 1\n else:\n countlist[A-1] = 1\n\nprint(countlist.count(0))\n']
['Runtime Error', 'Accepted']
['s658142203', 's795147778']
[9156.0, 30940.0]
[25.0, 333.0]
[506, 513]
p02689
u950825280
2,000
1,048,576
There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i. There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j. Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road. Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road. How many good observatories are there?
['n, m = map(int, input().split())\nh = list(map(int, input().split()))\nl = [[] for _ in range(n)]\nans = 0\nfor _ in range(m):\n a, b = map(int, input().split())\n l[a-1].append(h[b-1])\n l[b-1].append(h[a-1])\nprint(l)\nfor i, x in enumerate(l):\n s = h[i]\n if len(x) == 0:\n ans += 1\n break\n if s > max(x):\n ans += 1\nprint(ans)\n ', 'n, m = map(int, input().split())\nh = list(map(int, input().split()))\nl = [[] for _ in range(n)]\nans = 0\nfor _ in range(m):\n a, b = map(int, input().split())\n l[a-1].append(h[b-1])\n l[b-1].append(h[a-1])\n \nfor i in range(n):\n s = h[i]\n x = l[i]\n print(i)\n if len(x) == 0:\n ans += 1\n continue\n if s > max(x):\n ans += 1\nprint(ans)\n ', 'n, m = map(int, input().split())\nh = list(map(int, input().split()))\nl = [[] for _ in range(n)]\nans = 0\nfor _ in range(m):\n a, b = map(int, input().split())\n l[a-1].append(h[b-1])\n l[b-1].append(h[a-1])\n \nfor i in range(n):\n s = h[i]\n x = l[i]\n if len(x) == 0:\n ans += 1\n continue\n if s > max(x):\n ans += 1\nprint(ans)\n ']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s210162454', 's739500992', 's873089729']
[28936.0, 23164.0, 23092.0]
[374.0, 403.0, 397.0]
[362, 380, 367]
p02689
u954488273
2,000
1,048,576
There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i. There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j. Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road. Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road. How many good observatories are there?
['import numpy as np\nn,m=list(map(int,input().split()))\nh=list(map(int,input().split()))\n\nflag=np.zeros(n)+1\n\nfor i in range(m):\n a,b=list(map(int,input().split()))\n if h[a-1]>h[b-1]:\n flag[b-1] = 0\n else:\n flag[a-1] = 0\n \nprint(flag)\nans=np.sum(flag)\nprint(int(ans))', 'import numpy as np\nn,m=list(map(int,input().split()))\nh=list(map(int,input().split()))\n\nflag=np.zeros(n)+1\n\nfor i in range(m):\n a,b=list(map(int,input().split()))\n if h[a-1]>h[b-1]:\n flag[b-1] = 0\n elif h[a-1]==h[b-1]:\n flag[b-1] = 0\n flag[a-1] = 0\n else:\n flag[a-1] = 0\n \nans=np.sum(flag)\nprint(int(ans))']
['Wrong Answer', 'Accepted']
['s170744699', 's527785418']
[38328.0, 38656.0]
[351.0, 361.0]
[277, 324]
p02689
u955248595
2,000
1,048,576
There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i. There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j. Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road. Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road. How many good observatories are there?
['import numpy as np\nN,M = (int(x) for x in input().split())\nH = np.array([int(x) for x in input().split()])\nWay = np.zeros((N,N),dtype=bool)\nfor T in range(0,M):\n A,B = (int(x) for x in input().split())\n Way[A-1,B-1] = True\n Way[B-1,A-1] = True\n \nCount = 0\n#for TT in range(0,N): \n# TrueIndex = [n for n,v in enumerate(Way[TT,:]) if v==True]\n# if np.all(H[TT]>H[TrueIndex]):\n# Count = Count+1\nprint(Count)', 'N,M = (int(x) for x in input().split())\nH = [int(x) for x in input().split()]\nWay = [[] for I in range(N)]\nfor T in range(0,M):\n A,B = (int(x) for x in input().split())\n Way[A-1].append(B)\n Way[B-1].append(A)\n \nCount = 0\nfor TT in range(0,N): \n if all(H[TT]>Ele for Ele in [H[I-1] for I in Way[TT]]):\n Count = Count+1\nprint(Count)']
['Runtime Error', 'Accepted']
['s720935152', 's941091444']
[38624.0, 29932.0]
[138.0, 450.0]
[431, 354]
p02689
u955865184
2,000
1,048,576
There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i. There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j. Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road. Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road. How many good observatories are there?
['import sys\ndef input():\n return list(map(int, sys.stdin.readline().strip().split()))\n\nn, m = input()\nh = input()\ntmp = [[] for i in range(n)]\nfor i in range(m):\n a, b = input()\n tmp[b - 1].append(a - 1)\n tmp[a - 1].append(b - 1)\nans = 0\nfor i in range(n):\n flag = True\n for ele in tmp[i]:\n if(h[i] <= h[ele]):\n \t\tflag = False\n if(flag): ans += 1\nprint(ans)', 'import sys\ndef input():\n return list(map(int, sys.stdin.readline().strip().split()))\n\nn, m = input()\nh = input()\ntmp = [[] for i in range(n)]\nfor i in range(m):\n a, b = input()\n tmp[b - 1].append(a - 1)\n tmp[a - 1].append(b - 1)\nans = 0\nfor i in range(n):\n flag = True\n for ele in tmp[i]:\n if(h[i] <= h[ele]): flag = False\n if(flag): ans += 1\nprint(ans)']
['Runtime Error', 'Accepted']
['s398188186', 's502018851']
[9064.0, 29320.0]
[18.0, 362.0]
[367, 363]
p02689
u959307673
2,000
1,048,576
There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i. There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j. Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road. Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road. How many good observatories are there?
['N,M = map(int, input().split())\nH=list(map(int, input().split()))\nA=[]\nB=[]\nfor i in range(M):\n A1,B1=map(int, input().split())\n A.append(A1)\n B.append(B1)\nmiti={}\nfor i in range(M):\n if A[i] in miti:\n miti[A[i]].append(H[B[i]-1]) \n else:\n miti[A[i]]=[]\n miti[A[i]].append(H[B[i]-1])\n if B[i] in miti:\n miti[B[i]].append(H[A[i]-1]) \n else:\n miti[B[i]]=[]\n miti[B[i]].append(H[A[i]-1])\ncount=0\nprint(miti)\nfor i in range(M):\n if i+1 in miti:\n for j in range(len(miti[i+1])):\n if H[i]<=miti[i+1][j]:\n count+=1\n print(i+1)\n break\nprint(N-count)', 'N,M = map(int, input().split())\nH=list(map(int, input().split()))\nA=[]\nB=[]\nfor i in range(M):\n A1,B1=map(int, input().split())\n A.append(A1)\n B.append(B1)\nmiti={}\nfor i in range(M):\n if A[i] in miti:\n miti[A[i]].append(H[B[i]-1]) \n else:\n miti[A[i]]=[]\n miti[A[i]].append(H[B[i]-1])\n if B[i] in miti:\n miti[B[i]].append(H[A[i]-1]) \n else:\n miti[B[i]]=[]\n miti[B[i]].append(H[A[i]-1])\ncount=0\nprint(miti)\nfor i in range(M):\n if i+1 in miti:\n for j in range(len(miti[i+1])):\n if H[i]<miti[i+1][j]:\n count+=1\n break\n else:\n count+=1\nprint(N-count)', 'N,M = map(int, input().split())\nH=list(map(int, input().split()))\nA=[]\nB=[]\nfor i in range(M):\n A1,B1=map(int, input().split())\n A.append(A1)\n B.append(B1)\nmiti={}\nfor i in range(M):\n if A[i] in miti:\n miti[A[i]].append(H[B[i]-1]) \n else:\n miti[A[i]]=[]\n miti[A[i]].append(H[B[i]-1])\n if B[i] in miti:\n miti[B[i]].append(H[A[i]-1]) \n else:\n miti[B[i]]=[]\n miti[B[i]].append(H[A[i]-1])\ncount=0\nfor i in range(N):\n if i+1 in miti:\n for j in range(len(miti[i+1])):\n if H[i]<=miti[i+1][j]:\n count+=1\n break\nprint(N-count)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s034950930', 's724684333', 's733200149']
[39760.0, 39948.0, 33116.0]
[564.0, 526.0, 552.0]
[692, 691, 653]
p02689
u966207392
2,000
1,048,576
There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i. There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j. Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road. Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road. How many good observatories are there?
['N, M = map(int, input().split())\nH = list(map(int, input().split()))\n\nt = [0]*N\nfor i in range(M):\n a, b = map(int, input().split())\n t[a-1] = max(t[a-1], H[b-1])\n t[b-1] = max(t[b-1], H[a-1])\n\nres = 0\nfor i range(N):\n if H[i] > t[i]:\n res += 1\n\nprint(res) ', 'N, M = map(int, input().split())\nH = list(map(int, input().split()))\n\nt = [0]*N\nfor i in range(M):\n a, b = map(int, input().split())\n t[a-1] = max(t[a-1], H[b-1])\n t[b-1] = max(t[b-1], H[a-1])\n\nres = 0\nfor i in range(N):\n if H[i] > t[i]:\n res += 1\n\nprint(res) ']
['Runtime Error', 'Accepted']
['s530687580', 's210721501']
[9060.0, 20040.0]
[21.0, 331.0]
[273, 276]
p02689
u971124021
2,000
1,048,576
There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i. There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j. Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road. Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road. How many good observatories are there?
['h = list(map(int,input().split()))\nd = [1] * n\nfor i in range(m):\n a,b = list(map(int,input().split()))\n a -= 1\n b -= 1\n if h[a] > h[b]:\n d[b] = 0\n elif h[b] > h[a]:\n d[a] = 0\n else:\n d[a] = 0\n d[b] = 0\n\nprint(sum(d))', '\nn,m = list(map(int,input().split()))\nh = list(map(int,input().split()))\nd = [1] * n\nfor i in range(m):\n a,b = list(map(int,input().split()))\n a -= 1\n b -= 1\n if h[a] > h[b]:\n d[b] = 0\n elif h[b] > h[a]:\n d[a] = 0\n else:\n d[a] = 0\n d[b] = 0\n\nprint(sum(d))']
['Runtime Error', 'Accepted']
['s781428053', 's179966496']
[9104.0, 19960.0]
[29.0, 265.0]
[235, 273]
p02689
u981040490
2,000
1,048,576
There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i. There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j. Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road. Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road. How many good observatories are there?
["# -*- coding: utf-8 -*-\ndef main():\n N,M = map(int, input().split())\n H = list(map(int, input().split()))\n ans = []\n for _ in range(N):\n ans.append(1)\n for i in range(M):\n A,B = map(int, input().split())\n if H[A-1] < H[B-1]:\n ans[A-1] = -1\n elif H[A-1] > H[B-1]:\n ans[B-1] = 0\n else:\n ans[B-1] = 0\n ans[A-1] = 0\n print(sum(ans))\n\nif __name__ == '__main__':\n main()", "# -*- coding: utf-8 -*-\ndef main():\n N,M = map(int, input().split())\n H = list(map(int, input().split()))\n ans = []\n for _ in range(N):\n ans.append(1)\n for i in range(M):\n A,B = map(int, input().split())\n if H[A-1] < H[B-1]:\n ans[A-1] = 0\n elif H[A-1] > H[B-1]:\n ans[B-1] = 0\n else:\n ans[B-1] = 0\n ans[A-1] = 0\n print(sum(ans))\n\nif __name__ == '__main__':\n main()"]
['Wrong Answer', 'Accepted']
['s156426435', 's584466785']
[20124.0, 20124.0]
[251.0, 241.0]
[464, 463]
p02689
u985374340
2,000
1,048,576
There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i. There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j. Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road. Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road. How many good observatories are there?
['\nd = defaultdict(list)\n\nN, M = list(map(int, input().split()))\n\nH = list(map(int, input().split()))\n\nfor i in range(M):\n a, b = list(map(int, input().split()))\n d[a-1].append(b-1)\n d[b-1].append(a-1)\n\nans = 0\nfor i in range(N):\n ng = 0\n\n if(i not in d):\n ans += 1\n continue\n\n for j in d[i]:\n if(H[i] <= H[j]): ng = 1\n if(ng != 1):\n ans += 1\n\nprint(ans)', 'from collections import defaultdict\n\nd = defaultdict(list)\n\nN, M = list(map(int, input().split()))\n\nH = list(map(int, input().split()))\n\nfor i in range(M):\n a, b = list(map(int, input().split()))\n d[a-1].append(b-1)\n d[b-1].append(a-1)\n\nans = 0\nfor i in range(N):\n ng = 0\n\n if(i not in d):\n ans += 1\n continue\n\n for j in d[i]:\n if(H[i] <= H[j]): ng = 1\n if(ng != 1):\n ans += 1\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s133345171', 's232250450']
[9164.0, 34416.0]
[21.0, 460.0]
[401, 437]
p02689
u987326700
2,000
1,048,576
There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i. There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j. Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road. Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road. How many good observatories are there?
['n,m = map(int,input().split())\nh = list(map(int,input().split()))\na = []\nb = []\ncnt = 0\nwhile True:\n try:\n ta,tb = map(int,input().split())\n a.append(ta)\n b.append(tb)\n except:\n break\n\nhighest = h.index(max(h))+1\n\nfor i in range(1,m+1):\n if i not in a and i not in b:\n cnt +=1\n if a[i-1]==highest or b[i-1]==highest:\n cnt +=1\nprint(cnt)', 'n,m = map(int,input().split())\nh = list(map(int,input().split()))\na = []\nb = []\ncnt = 0\nwhile True:\n try:\n ta,tb = map(int,input().split())\n a.append(ta)\n b.append(tb)\n except:\n break\n \nH = [0]*n\n\nfor i in range(m):\n\n if h[a[i]-1]>h[b[i]-1]:\n H[b[i]-1]-=1\n \n if h[a[i]-1]==h[b[i]-1]:\n H[a[i]-1]-=1\n H[b[i]-1]-=1\n if h[a[i]-1]<h[b[i]-1]:\n H[a[i]-1]-=1\nn = [1 for i in H if i>=0]\nprint(len(n))']
['Wrong Answer', 'Accepted']
['s559061685', 's217629402']
[22508.0, 22344.0]
[2206.0, 310.0]
[358, 424]
p02689
u995163736
2,000
1,048,576
There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i. There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j. Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road. Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road. How many good observatories are there?
['N, K = (int(i) for i in input().split())\nH = list(map(int,input().split()))\nans = [1]*N\nfor m in range(M):\n a, b = (int(i) for i in input().split())\n if H[a-1] < H[b-1]:\n ans[a-1] = 0\n elif H[a-1] > H[b-1]:\n ans[b-1] = 0\nprint(ans.count(1))', 'N, M = (int(i) for i in input().split())\nH = list(map(int,input().split()))\nans = [1]*N\nfor m in range(M):\n a, b = (int(i) for i in input().split())\n if H[a-1] < H[b-1]:\n ans[a-1] = 0\n elif H[a-1] > H[b-1]:\n ans[b-1] = 0\n else:\n ans[a-1] = 0\n ans[b-1] = 0\nprint(ans.count(1))']
['Runtime Error', 'Accepted']
['s087209195', 's675238333']
[20104.0, 20004.0]
[49.0, 265.0]
[249, 315]
p02689
u997927785
2,000
1,048,576
There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i. There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j. Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road. Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road. How many good observatories are there?
['N, M = map(int, input().split())\nH = list(map(int, input().split()))\nAB = []\nfor _ in range(M):\n AB.append(list(map(int, input().split())))\n\nprint(AB)\n\nfor d in range(0,M):\n if H[AB[d][0]-1] < H[AB[d][1]-1]:\n AB[d].pop(1)\n elif H[AB[d][0]-1] > H[AB[d][1]-1]:\n AB[d].pop(0)\n\nprint(AB)\n\nbad = [e for row in AB for e in row]\nbadsingle = list(set(bad))\nprint(N - len(badsingle))\n', 'N, M = map(int, input().split())\nH = list(map(int, input().split()))\nAB = []\nfor _ in range(M):\n AB.append(list(map(int, input().split())))\n\n\nfor d in range(0,M):\n if H[AB[d][0]-1] < H[AB[d][1]-1]:\n AB[d].pop(1)\n elif H[AB[d][0]-1] > H[AB[d][1]-1]:\n AB[d].pop(0)\n\n\nbad = [e for row in AB for e in row]\nbadsingle = list(set(bad))\nprint(N - len(badsingle))']
['Wrong Answer', 'Accepted']
['s672976696', 's571670560']
[35056.0, 34664.0]
[367.0, 333.0]
[398, 377]
p02689
u999799597
2,000
1,048,576
There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i. There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j. Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road. Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road. How many good observatories are there?
["def main():\n import collections\n n, m = map(int, input().split())\n hs = list(map(int, input().split()))\n nmap = [0] * n\n cnt = 0\n\n for j in range(m):\n v = input().split()\n v0 = int(v[0]) - 1\n v1 = int(v[1]) - 1\n if hs[v0] < hs[v1]:\n nmap[v0] += 1\n elif hs[v0] == hs[v1]:\n nmap[v0] += 1\n nmap[v1] += 1\n # else:\n # nmap[v1] += 1\n print(nmap)\n for i in nmap:\n if i == 0:\n cnt += 1\n return cnt\n\n\nif __name__ == '__main__':\n print(main())\n", "def main():\n import collections\n n, m = map(int, input().split())\n hs = list(map(int, input().split()))\n nmap = [0] * n\n cnt = 0\n\n for j in range(m):\n v = input().split()\n v0 = int(v[0]) - 1\n v1 = int(v[1]) - 1\n if hs[v0] < hs[v1]:\n nmap[v0] += 1\n elif hs[v0] == hs[v1]:\n nmap[v0] += 1\n nmap[v1] += 1\n else:\n nmap[v1] += 1\n for i in nmap:\n if i == 0:\n cnt += 1\n return cnt\n\n\nif __name__ == '__main__':\n print(main())\n"]
['Wrong Answer', 'Accepted']
['s621327759', 's228375834']
[20536.0, 20492.0]
[235.0, 224.0]
[568, 548]
p02691
u008608569
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['\nn = int(input())\na = np.array(list(map(int, input().split())))\ncnt = 0\nfor i in range(1, n+1):\n for j in range(i+1, n+1):\n if abs(i-j) == (a[i-1]+a[j-1]):\n cnt += 1\nprint(cnt)', 'from collections import defaultdict\nn = int(input())\na = np.array(list(map(int, input().split())))\nci = defaultdict(int)\ncj = defaultdict(int)\nfor i in range(n):\n ci[a[i]+i] += 1\n cj[i-a[i]] += 1\ncnt = 0\nfor k in ci.keys():\n cnt += ci[k] * cj[k]\nprint(cnt)', 'from collections import defaultdict\nn = int(input())\na = list(map(int, input().split()))\nci = defaultdict(int)\ncj = defaultdict(int)\nfor i in range(n):\n ci[a[i]+i] += 1\n cj[i-a[i]] += 1\ncnt = 0\nfor k in ci.keys():\n cnt += ci[k] * cj[k]\nprint(cnt)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s721656819', 's733343449', 's450139222']
[9192.0, 9392.0, 74072.0]
[23.0, 25.0, 359.0]
[222, 265, 255]
p02691
u020962106
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['from collections import Counter\nn = int(input())\na = list(map(int,input().split()))\nL = [0]*n\nR = [0]*n\ncnt=0\nfor i in range(n):\n L[i] = i+a[i]\n R[i] = i-a[i]\nz1=Counter(L)\nz2=Counter(R)\nprint(z1)\nprint(z2)\ncnt=0\nfor k1,v1 in z1.items():\n v2 = z2[k1]\n cnt += v1*v2\nprint(cnt)', 'from collections import Counter\nn = int(input())\na = list(map(int,input().split()))\nL = [0]*n\nR = [0]*n\ncnt=0\nfor i in range(n):\n L[i] = i+a[i]\n R[i] = i-a[i]\nz1=Counter(L)\nz2=Counter(R)\ncnt=0\nfor k1,v1 in z1.items():\n v2 = z2[k1]\n cnt += v1*v2\nprint(cnt)']
['Wrong Answer', 'Accepted']
['s960066871', 's410347331']
[87304.0, 63292.0]
[444.0, 268.0]
[287, 267]
p02691
u027357817
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
["N,A,B,C=map(int,input().split())\n\nS=['']*N\nfor i in range(N):\n S[i]=input()\n\nresult=[]\nkekka=True\n\n\nfor i in range(N):\n if (A==0 and B==0 and S[i]=='AB') or (C==0 and B==0 and S[i]=='BC') or (A==0 and C==0 and S[i]=='AC'):\n kekka=False\n break\n else:\n if S[i]=='AB':\n if A==0:\n A += 1\n B -= 1\n result.append('A')\n elif B==0:\n A -=1\n B +=1\n result.append('B')\n elif A==1 and B==1 and C==0:\n if S[i+1]=='AC':\n A += 1\n B -= 1\n result.append('A')\n else:\n A -=1\n B +=1\n result.append('B')\n elif A>B:\n A -=1\n B +=1\n result.append('B')\n else:\n A +=1\n B -=1\n result.append('A')\n elif S[i]=='AC':\n if A==0:\n A += 1\n C -= 1\n result.append('A')\n elif C==0:\n A -=1\n C +=1\n result.append('C')\n elif A==1 and C==1 and B==0:\n if S[i+1]=='AB':\n A += 1\n C -= 1\n result.append('A')\n else:\n A -=1\n C +=1\n result.append('C')\n elif A>C:\n A -=1\n C +=1\n result.append('C')\n else:\n A +=1\n C -=1\n result.append('A') \n elif S[i]=='BC':\n if B==0:\n B += 1\n C -= 1\n result.append('B')\n elif C==0:\n B -=1\n C +=1\n result.append('C')\n elif B==1 and C==1 and A==0:\n if S[i+1]=='AB':\n B += 1\n C -= 1\n result.append('B')\n else:\n B -=1\n C +=1\n result.append('C')\n elif B>C:\n B -=1\n C +=1\n result.append('C')\n else:\n B +=1\n C -=1\n result.append('B')\n\nif kekka ==False:\n print('No')\nelse:\n print('Yes')\n for i in range(len(result)):\n print(result[i]) \n\n\n", 'N=int(input())\nA=list(map(int,input().split()))\n\nresult=0\n\nD={}\n\nfor j in range(N):\n if j+A[j] in D:\n D[j+A[j]] += 1\n else:\n D[j+A[j]]=1\n\nfor j in range(N):\n if j-A[j] in D:\n result += D[j-A[j]]\n\nprint(result)']
['Runtime Error', 'Accepted']
['s754351426', 's211138120']
[9260.0, 40312.0]
[25.0, 190.0]
[2523, 239]
p02691
u038724782
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['n = int(input())\na_l = list(map(int,input().split()))\nia = list(enumerate(a_l))\ndel_l = []\nfor j in range(n):\n if ia[j][1] >= n-1:\n del_l.append(j)\nfor j in del_l[::-1]:\n del ia[j]\n \ncount = 0\ni = 0\nwhile True:\n if i > len(ia)-1:\n break\n i1, a1 = ia[i]\n if a1 >= n-1-i1:\n del ia[i]\n continue\n for i2, a2 in ia[i1+a1+1:n]:\n if (i2-i1) == (a2+a1):\n count += 1\n i += 1\n\nprint(count)\n\n', 'n = int(input())\na_l = list(map(int,input().split()))\nia = list(enumerate(a_l))\ndel_l = []\nfor j in range(n):\n if ia[j][1] >= n-1:\n del_l.append(j)\nfor j in del_l[::-1]:\n del ia[j]\n \ncount = 0\ni = 0\nwhile True:\n if i > len(ia)-1:\n break\n i1, a1 = ia[i]\n if a1 >= n-1-i1:\n del ia[i]\n continue\n for i2, a2 in ia[i1+a1+1:n]:\n if a2 >= n-1-i1:\n del ia[i2]\n continue\n if (i2-i1) == (a2+a1):\n count += 1\n i += 1\n\nprint(count)\n\n', 'n = int(input())\na_l = list(map(int,input().split()))\n\ncount = 0\nfor i in range(n):\n for j in range(i+1,n):\n if (j-i) == abs(a_l[j-1] - a_l[i-1]):\n count += 1\n\nprint(count)\n\n', 'n = int(input())\na_l = list(map(int,input().split()))\nia = list(enumerate(a_l))\n\nx_dict = {}\ny_dict = {}\nfor i, a in ia:\n x = i+a\n y = i-a\n if x in x_dict:\n x_dict[x] += 1\n else:\n x_dict[x] = 1\n if y in y_dict:\n y_dict[y] += 1\n else:\n y_dict[y] = 1\n\ncount = 0\nfor xkey in x_dict.keys():\n if xkey in y_dict:\n count += x_dict[xkey] * y_dict[xkey]\n\nprint(count)']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s224048290', 's655652518', 's975855273', 's546942231']
[42360.0, 42328.0, 32364.0, 74052.0]
[2207.0, 2206.0, 2206.0, 244.0]
[455, 524, 195, 414]
p02691
u039189422
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['n=int(input())\nA=list(map(int,input().split()))\nB=[0]*(10**10)\nres=0\n\nfor i in range(n):\n\tB[A[i]+i]+=1\nfor i in range(n):\n\tif i-A[i]>0:\n\t\tres+=B[i-A[i]]\n\nprint(res)', 'from collections import defaultdict\n\nn=int(input())\nA=list(map(int,input().split()))\nB=defaultdict(int)\nres=0\n\nfor i in range(n):\n\tB[A[i]+i]+=1\n\tif i-A[i] in B:\n\t\tres+=B[i-A[i]]\n\nprint(res)']
['Runtime Error', 'Accepted']
['s086989373', 's076820502']
[32228.0, 40704.0]
[65.0, 179.0]
[164, 189]
p02691
u044220565
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['# coding: utf-8\nimport sys\nsysread = sys.stdin.readline\nsys.setrecursionlimit(10**7)\n\ndef run():\n N = int(input())\n A = list(map(int, sysread().split()))\n\n import numpy as np\n N = 200000\n A = np.random.randint(1, N, size=N)\n\n A = [(idx, val) for idx, val in enumerate(A, 1) if val < N]\n\n ret = 0\n store = [0] * N\n for idx, val in A:\n ret += store[idx - val]\n try:\n store[idx + val] += 1\n except:\n continue\n print(ret)\n\nif __name__ == "__main__":\n run()', '# coding: utf-8\nimport sys\nsysread = sys.stdin.readline\n\ndef run():\n N = int(input())\n A = list(map(int, sysread().split()))\n\n\n A = [(idx, val) for idx, val in enumerate(A, 1) if val < N]\n\n ret = 0\n store = [0] * N\n for idx, val in A:\n if idx - val > 0:\n ret += store[idx - val]\n try:\n store[idx + val] += 1\n except:\n continue\n print(ret)\n\nif __name__ == "__main__":\n run()']
['Wrong Answer', 'Accepted']
['s255434645', 's262193376']
[56852.0, 37420.0]
[365.0, 155.0]
[528, 451]
p02691
u045953894
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['from collections import Counter\nn = int(input())\na = list(map(int,input().split()))\ncount = 0\nb = []\nc = []\n\nfor i in range(n):\n b.append(a[i]+i)\n c.append(i-a[i])\nt = Counter(b)\nfor s in c:\n count += t[s]\n print(t[s],s)\nprint(t,1)\nprint(count)', 'from collections import Counter\nn = int(input())\na = list(map(int,input().split()))\ncount = 0\nb = []\nc = []\n\nfor i in range(n):\n b.append(a[i]+i)\n c.append(i-a[i])\nt = Counter(b)\nfor s in c:\n count += t[s]\n print(t[s],s)\nprint(t,1)\nprint(count)', 'from collections import Counter\nn = int(input())\na = list(map(int,input().split()))\ncount = 0\nb = []\nc = []\n\nfor i in range(n):\n b.append(a[i]+i)\n c.append(i-a[i])\nt = Counter(c) \nfor s in b:\n count += t[s]\n\nprint(count)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s093999294', 's895579014', 's257472198']
[70860.0, 70976.0, 50760.0]
[472.0, 468.0, 217.0]
[256, 256, 229]
p02691
u060896757
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['N = int(input())\nA = [int(i) for i in input().split()]\ndp = [0] * (10 ** 9 + 2 * (10 ** 5))\nans = 0\nfor i in range(N):\n x = i + 1 - A[i]\n if x >= 0:\n ans += dp[x]\n dp[i + 1 + A[i]] += 1\n\nprint(ans)\n', 'N = int(input())\nA = [int(i) for i in input().split()]\ndp = [0] * 10 ** 7\nans = 0\nfor i in range(N):\n x = i + 1 - A[i]\n if x >= 0:\n ans += dp[x]\n y = i + 1 + A[i]\n if y < 10 ** 7:\n dp[y] += 1\n\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s253894874', 's720467562']
[32336.0, 97968.0]
[72.0, 266.0]
[214, 230]
p02691
u064869465
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['n = int(input())\na = list(map(int, input().split()))\nsu = dict()\nsd = dict()\nfor i in range(n):\n if a[i] + i + 1 in su:\n su[a[i] + i + 1] += 1\n else:\n su[a[i] + i + 1] = 1\n if a[i] - i - 1 in sd:\n sd[a[i] - i - 1] += 1\n else:\n sd[a[i] - i - 1] = 1\nf1 = []\nfor d in su:\n f1.append(d, su[d])\nf1.sort()\nf = []\nfor d in sd:\n f.append(d, su[d])\nf.sort()\ns = 0\ni1 = n-1\nj1 = 0\nwhile (i1 > 0 and j1 < n-1):\n if (su[i1] + sd[j1] == 0):\n s+=1\n i1-=1\n elif (su[i1] + sd[j1] > 0):\n i1-=1\n\n elif (su[i1] + sd[j1] < 0):\n j1+=1\nprint(s)\n', 'n = int(input())\na = list(map(int, input().split()))\nsu = dict()\nsd = dict()\nfor i in range(n):\n if a[i] + i + 1 in su:\n su[a[i] + i + 1] += 1\n else:\n su[a[i] + i + 1] = 1\n if a[i] - i - 1 in sd:\n sd[a[i] - i - 1] += 1\n else:\n sd[a[i] - i - 1] = 1\nfsu = []\nfor d in su:\n fsu.append([d, su[d]])\nfsu.sort()\nfsd = []\nfor d in sd:\n fsd.append([d, sd[d]])\nfsd.sort()\ns = 0\ni1 = len(fsu) - 1\nj1 = 0\n#print(fsu)\n#print(fsd)\nwhile (i1 >= 0 and j1 <= len(fsd)-1):\n if (fsu[i1][0] + fsd[j1][0] == 0):\n s+=fsu[i1][1] * fsd[j1][1]\n i1-=1\n elif (fsu[i1][0] + fsd[j1][0] > 0):\n i1-=1\n elif (fsu[i1][0] + fsd[j1][0] < 0):\n j1+=1\n\nprint(s)\n']
['Runtime Error', 'Accepted']
['s338993264', 's832076159']
[57356.0, 82324.0]
[267.0, 1074.0]
[638, 739]
p02691
u072717685
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
["from collections import Counter\n\ndef main():\n n = int(input())\n a = list(map(int, input().split()))\n cnt = 0\n l1 = []\n for ea in a:\n l1.append(cnt - ea)\n cnt += 1\n l1c = Counter(l1)\n r = 0\n for ea2 in a:\n r += l1c[ea2 + a[ea2]]\n print(int(r))\n\nif __name__ == '__main__':\n main()\n", "import sys\nread = sys.stdin.read\nreadlines = sys.stdin.readlines\nfrom collections import defaultdict\ndef main():\n n = int(input())\n a = list(map(int, input().split()))\n\n d1 = defaultdict(int)\n d2 = defaultdict(int)\n for i, ae in enumerate(a):\n d1[i + ae +1] += 1\n d2[i - ae +1] += 1\n r = 0\n for d1e in d1.keys():\n rt = d1[d1e] * d2[d1e]\n r += rt\n print(r)\n\nif __name__ == '__main__':\n main()"]
['Runtime Error', 'Accepted']
['s863577470', 's973575795']
[42552.0, 73732.0]
[160.0, 292.0]
[330, 446]
p02691
u094191970
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['from collections import Counter\n\nn=int(input())\na=list(map(int,input().split()))\n\nq1=[]\nq2=[]\n\nfor i in range(n):\n q1.append(i+a[i])\n q2.append(i-a[i])\n\nc2=Counter(q2)\n\nans=0\nfor i in c1.keys():\n ans+=c2[i]\n\nprint(ans)', 'from collections import Counter\n\nn=int(input())\na=list(map(int,input().split()))\n\nl1=[i+a[i] for i in range(n)]\nl2=[i-a[i] for i in range(n)]\n\nc2=Counter(l2)\n\nans=0\nfor i in l1:\n ans+=c2[i]\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s466135886', 's932967453']
[50588.0, 50704.0]
[167.0, 187.0]
[221, 202]
p02691
u114933382
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['import numpy as np\nn = int(input())\nA = np.array(list(map(int,input().split())))\nB = np.array([i+1 for i in range(n)])\nC,D = A+B,B-A\nans = 0\nfor i in C:\n ans += np.count_nonzero(D==i)\n', 'import numpy as np\nimport collections\nn = int(input())\nA = np.array(list(map(int,input().split())))\nB = np.array([i+1 for i in range(n)])\nC,D = A+B,B-A\nans = 0\n\nc = collections.Counter(C)\nd = collections.Counter(D)\nans = 0\nfor i in c.keys():\n ans += c[i]*d[i]\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s828279837', 's493594900']
[51004.0, 75124.0]
[2206.0, 410.0]
[187, 274]
p02691
u119148115
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['N = int(input())\nA = list(map(int,input().split()))\nB = A\n\nfor i in range(N):\n A[i] -= i+1\n B[i] += i+1\n\nfrom collections import Counter\n\nC = Counter(A)\nD = Counter(B)\n\nE = list(C.keys())\nF = list(D.keys())\n\n\nans = 0\nfor i in E:\n ans += C[i]*D[i]\n\nprint(ans//2)', 'N = int(input())\nA = list(map(int,input().split()))\n\nfrom copy import deepcopy\n\nB = deepcopy(A)\n\nfor i in range(N):\n A[i] += i+1\n B[i] = (i+1)-B[i]\n\nfrom collections import Counter\n\nC = Counter(A)\nD = Counter(B)\n\nE = list(C.keys())\n\nans = 0\nfor i in E:\n ans += C[i]*D[i]\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s753828053', 's129425672']
[49440.0, 55736.0]
[272.0, 324.0]
[270, 291]
p02691
u127499732
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
["def main():\n x = int(input())\n\n i = 0\n while True:\n j = i ** 5\n a1, a2 = x + j, x - j\n\n p = a1 ** (1 / 5)\n q = a2 ** (1 / 5) if a2 >= 0 else abs(a2) ** (1 / 5) * -1\n\n f = int(p) - p == 0\n g = int(q) - q == 0\n if f:\n print(int(p), i)\n break\n if g:\n print(int(q), -1 * i)\n break\n\n i += 1\n\n\nif __name__ == '__main__':\n main()\n", "def main():\n from collections import defaultdict\n n, *a = map(int, open(0).read().split())\n d = defaultdict(lambda: [0, 0])\n\n ans = 0\n for i, x in enumerate(a, 1):\n d[i + x][0] += 1\n d[i - x][1] += 1\n ans += d[i + x][1] + d[i - x][0]\n\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Accepted']
['s804504481', 's606531672']
[9484.0, 89992.0]
[32.0, 371.0]
[442, 326]
p02691
u166340293
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['N=int(input())\ncount=0\na=list(map(int,input().split()))\nw=[]\ns=[]\nmaxi=max(a)\nmini=min(a)\nnum=[0]*200000000\nmaxi=max(a)\nfor i in range(N):\n w.append(1+i+a[i])\n s.append(1+i-a[i])\n num[1+i-a[i]+maxi]+=1\nfor i in range(N):\n count+=num[w[i]+maxi]\nprint(count)', 'N=int(input())\ncount=0\na=list(map(int.input().split()))\nfor i in range(N-1):\n for j in range(i+a[i]+1,N):\n if j-i==a[i]+a[j]:\n count+=1\nprint(count)', 'N=int(input())\ncount=0\na=list(map(int,input().split()))\nw=[]\ns=[]\nmaxi=max(a)\nmini=min(a)\nnum=[0]*(maxi-mini+N+N)\nmaxi=max(a)\nfor i in range(N):\n w.append(1+i+a[i])\n s.append(1+i-a[i])\n num[1+i-a[i]+(maxi-mini+N+N)//2]+=1\nfor i in range(N):\n count+=num[w[i](maxi-mini+N+N)//2]\nprint(count)', 'N=int(input())\ncount=0\na=list(map(int,input().split()))\nw=[]\ns=[]\nnum=[0]*(1+N+max(a))\n\nfor i in range(N):\n w.append(1+i+a[i])\n s.append(1+i-a[i])\n num[1+i+a[i]]+=1\nfor i in range(N):\n count+=num[w[i]]\nprint(count)', 'N=int(input())\ncount=0\na=list(map(int,input().split()))\nw=[]\ns=[]\nmaxi=max(a)\nmini=min(a)\nnum=[0]*100000000\nmaxi=max(a)\nfor i in range(N):\n w.append(1+i+a[i])\n s.append(1+i-a[i])\n num[1+i-a[i]+maxi/2]+=1\nfor i in range(N):\n count+=num[w[i]+maxi/2]\nprint(count)', 'N=int(input())\ncount=0\na=list(map(int,input().split()))\nw=[]\ns=[]\nmaxi=max(a)\nmini=min(a)\nnum=[0]*150000000\nmaxi=max(a)\nfor i in range(N):\n w.append(1+i+a[i])\n s.append(1+i-a[i])\n num[1+i-a[i]+maxi]+=1\nfor i in range(N):\n count+=num[w[i]+maxi]\nprint(count)', 'N=int(input())\ncount=0\na=list(map(int,input().split()))\nw=[]\ns=[]\nnum=[0]*100000000\n\nfor i in range(N):\n w.append(1+i+a[i])\n s.append(1+i-a[i])\n num[1+i-a[i]+50000000]+=1\nfor i in range(N):\n count+=num[w[i]]\nprint(count)', 'N=int(input())\ncount=0\na=list(map(int,input().split()))\nw=[]\ns=[]\nmaxi=max(a)\nmini=min(a)\nnum=[0]*(maxi-mini+N+N)\nmaxi=max(a)\nfor i in range(N):\n w.append(1+i+a[i])\n s.append(1+i-a[i])\n num[1+i-a[i]+(maxi-mini+N+N)//2]+=1\nfor i in range(N):\n count+=num[w[i]+(maxi-mini+N+N)//2]\nprint(count)', 'N=int(input())\ncount=0\na=list(map(int,input().split()))\nw=[]\ns=[]\nnum=[0]*N\nmaxi=max(a)\nfor i in range(N):\n s.append(i-a[i])\n if i+a[i]<N:\n num[i+a[i]]+=1\nfor i in range(N):\n if s[i]>=0:\n count+=num[s[i]]\nprint(count)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s050661279', 's062011021', 's271596473', 's379124814', 's627406755', 's812424769', 's822042175', 's879268304', 's145622815']
[1597444.0, 9196.0, 39592.0, 38152.0, 801328.0, 1206700.0, 816128.0, 39632.0, 32240.0]
[2220.0, 25.0, 243.0, 239.0, 1102.0, 1746.0, 1241.0, 256.0, 181.0]
[260, 157, 293, 218, 264, 260, 224, 294, 226]
p02691
u179304833
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['import numpy as np\nn=int(input())\na=list(map(int,input().split()))\na1=[]\na2=[]\nfor i in range(n):\n a1.append(i+1-a[i])\nfor i in range(n):\n a2.append(i+1+a[i])\ncount=0\np=0\nq=1\nwhile q==n:\n if a1[q]==a2[p]:\n count+=1\n p+=1\n if p==q:\n p=0\n q+=1\nprint(count)', 'from collections import Counter\nn=int(input())\nalist=list(map(int,input().split()))\na1=[]\na2=[]\nfor i,a in enumerate(alist):\n a2.append(i-a)\n a1.append(i+a)\naa=Counter(a2)\ncount=0\nfor k in a1:\n count+=aa.get(k,0)\nprint(count)']
['Wrong Answer', 'Accepted']
['s874237151', 's567487812']
[51276.0, 50784.0]
[232.0, 192.0]
[268, 228]
p02691
u190735555
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['n=int(input())\na=list(map(int, input().split()))\nb=[0]*n\nc=[0]*n\nfor i in range(n):\n b[i]=a[i]+i\n c[i]=i-a[i]\nbs=sorted(b)\ncs=sorted(c)\nlx=[1+10**10]*n\nly=[2+10**10]*n\nrx=[3+10**10]*n\nry=[4+10**10]*n\n\nlx[0]=1\nly[0]=bs[0]\nrx[0]=1\nry[0]=cs[0]\n\nd=0\ne=0\nfor j in range (1,n):\n if bs[j]==bs[j-1]:\n lx[d]+=1\n else:\n d+=1\n lx[d]=1\n ly[d]=bs[j]\n \nfor k in range (1,n):\n if cs[k]==cs[k-1]:\n rx[e]+=1\n else:\n e+=1\n rx[e]=1\n ry[e]=cs[k]\nx=0\nans=0\nfor l in range(d):\n while ry[x]<=ly[l] and x<e:\n if ry[x]==ly[l]:\n ans+=(lx[l]*rx[x])\n x+=1\n else:\n x+=1\nprint(ans)\n\n', 'n=int(input())\na=list(map(int, input().split()))\nb=[0]*n\nc=[0]*n\nfor i in range(n):\n b[i]=a[i]+i\n c[i]=i-a[i]\nbs=sorted(b)\ncs=sorted(c)\nlx=[1+10**10]*n\nly=[2+10**10]*n\nrx=[3+10**10]*n\nry=[4+10**10]*n\n\nlx[0]=1\nly[0]=bs[0]\nrx[0]=1\nry[0]=cs[0]\n\nd=0\ne=0\nfor j in range (1,n):\n if bs[j]==bs[j-1]:\n lx[d]+=1\n else:\n d+=1\n lx[d]=1\n ly[d]=bs[j]\n \nfor k in range (1,n):\n if cs[k]==cs[k-1]:\n rx[e]+=1\n else:\n e+=1\n rx[e]=1\n ry[e]=cs[k]\nx=0\nans=0\nfor l in range(d):\n while ry[x]<=ly[l] and x<n-1:\n if ry[x]==ly[l]:\n ans+=(lx[l]*rx[x])\n x+=1\n else:\n x+=1\nprint(ans)\n\n']
['Wrong Answer', 'Accepted']
['s756812855', 's919639503']
[43092.0, 43292.0]
[462.0, 509.0]
[684, 686]
p02691
u192154323
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['from itertools import combinations\nn = int(input())\na_ls = list(map(int, input().split()))\nans = 0\ninds = [i for i in range(n)]\nfor ind_a, ind_b in combinations(inds, 2):\n Sum = a_ls[ind_a] + a_ls[ind_b]\n diff = abs(a-b)\n if Sum == diff:\n ans += 1\nprint(ans)', 'from collections import defaultdict\nn = int(input())\na_ls = list(map(int, input().split()))\nL_dict = defaultdict(int)\nfor i in range(n):\n Li = a_ls[i] + i + 1\n L_dict[Li] += 1\n\nans = 0\nfor j in range(n):\n Rj = j + 1 - a_ls[j]\n ans += L_dict[Rj]\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s750187583', 's576435653']
[32404.0, 61552.0]
[81.0, 271.0]
[274, 268]
p02691
u193264896
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
["import sys\nimport numpy as np\nfrom numba import jit\nreadline = sys.stdin.buffer.readline\nsys.setrecursionlimit(10 ** 8)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\n\n\ndef main():\n N = int(input())\n H = np.array(input().split(), np.int64)\n A = np.arange(1,N+1)\n B = np.arange(1,N+1)\n A = A + H\n B = B - H\n ans = 0\n\n @jit(nopython=True)\n def aa(i):\n return N - i - np.count_nonzero(B[i:] - A[:-i])\n for i in range(1,N):\n ans += aa(i)\n print(ans)\n\n\n\nif __name__ == '__main__':\n main()", "import sys\nfrom collections import defaultdict\n\nread = sys.stdin.read\nreadline = sys.stdin.buffer.readline\nsys.setrecursionlimit(10 ** 8)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\n\ndef main():\n N = int(readline())\n A = list(map(int, readline().split()))\n L = defaultdict(int)\n R = defaultdict(int)\n for i in range(N):\n L[i+1+A[i]] += 1\n R[i+1-A[i]] += 1\n ans = 0\n for key, value in L.items():\n ans += value*R[key]\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n"]
['Time Limit Exceeded', 'Accepted']
['s956776617', 's729017865']
[158728.0, 74100.0]
[2209.0, 286.0]
[524, 507]
p02691
u197457087
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['N = int(input())\n\nA = list(map(int, input().split()))\n\nL = {}\nR = {}\n\nfor i in range(N):\n t = A[i]+i\n if t in L:\n L[t] += 1\n else:\n L[t] = 1\n s = i - A[i]\n if s in R:\n R[s] += 1\n else:\n R[s] = 1 \nprint(L,R)\nans = 0\nfor i in range(N):\n t = A[i]+i\n \n if t in R.keys():\n ans += R[t]\n print(t,R[t])\nprint(ans)', 'N = int(input())\n \nA = list(map(int, input().split()))\n \nL = {}\nR = {}\n \nfor i in range(N):\n t = A[i]+i\n if t in L:\n L[t] += 1\n else:\n L[t] = 1\n s = i - A[i]\n if s in R:\n R[s] += 1\n else:\n R[s] = 1 \n#print(L,R)\nans = 0\nfor i in range(N):\n t = A[i]+i\n \n if t in R.keys():\n ans += R[t]\n #print(t,R[t])\nprint(ans)']
['Wrong Answer', 'Accepted']
['s023065235', 's279782952']
[56768.0, 56564.0]
[368.0, 247.0]
[345, 350]
p02691
u219015402
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['x = int(input())\ndef ans(x):\n for a in range(0, 1000)[::-1]:\n for b in range(-1000, 1000)[::-1]:\n if a**5 - b**5 == x:\n return a, b\na,b = ans(x)\nprint(a,b)', 'from collections import Counter\n\nN = int(input())\nalist = list(map(int, input().split()))\nalist = [0] + alist\nsumlist = []\n\nfor i in range(1,N+1):\n sumlist.append(i+alist[i])\nsumlist.sort()\nsum_cnt = Counter(sumlist)\nans = 0\n\nfor i in range(1, N+1):\n diff = i - alist[i]\n if diff in sum_cnt:\n ans += sum_cnt[diff]\nprint(ans)']
['Runtime Error', 'Accepted']
['s323171953', 's746302020']
[9196.0, 42792.0]
[1373.0, 227.0]
[191, 405]
p02691
u221061152
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['n=int(input())\nA=list(map(int,input().split()))\nL,R={},{}\nfor i,a in enumerate(A):\n l,r = i-a,i+a\n if l in L: L[l]=0\n if r in R: R[r]=0\n L[l]+=1\n R[r]+=1\n\ncount = 0\nfor x in L:\n if x not in R: continue\n count += L[x]*R[x]\nprint(count)', 'n=int(input())\nA=list(map(int,input().split()))\nL,R={},{}\nfor i,a in enumerate(A):\n l,r = i-a,i+a\n if l not in L: L[l]=0\n if r not in R: R[r]=0\n L[l]+=1\n R[r]+=1\n\ncount = 0\nfor x in L:\n if x not in R: continue\n count += L[x]*R[x]\nprint(count)']
['Runtime Error', 'Accepted']
['s189283135', 's074637195']
[32328.0, 57344.0]
[67.0, 275.0]
[241, 249]
p02691
u241348301
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['n=int(input())\ny=list(map(int,input().split()))\nfrom collections import Counter\nlhs=Counter([j+y[j] for j in range(n)])\nrhs=Counter([j-y[j] for j in range(n)])\ncount=0\nfor i in lhs:\n if i in rhs:\n count+=lhs[i]+rhs[i]\n\nprint(count)', 'n=int(input())\ny=list(map(int,input().split()))\nfrom collections import Counter\nlhs=Counter([j+y[j] for j in range(n)])\nrhs=Counter([j-y[j] for j in range(n)])\ncount=0\nfor i in lhs:\n if i in rhs:\n count+=lhs[i]*rhs[i]\n\nprint(count)\n']
['Wrong Answer', 'Accepted']
['s164675376', 's742005940']
[61452.0, 61268.0]
[189.0, 190.0]
[238, 239]
p02691
u246448955
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['import collections\nN = int(input())\nA = list(map(int,input().split()))\n\n#index,h\npp =[]\npm = []\nall_set = set()\nfor i in range(N):\n\n pp.append(i + A[i])\n pm.append( i - A[i])\n\ncount = 0\nc = collections.Counter(pp)\n#print(c)\nfor i in range(N):\n count += c[pm[i]] \n print(c[pm[i]])\n\n #count += pp.count(pm[i])\n #count += pm.count(pp[i])\n\nprint(count)', 'import collections\nN = int(input())\nA = list(map(int,input().split()))\n\n#index,h\npp =[]\npm = []\nall_set = set()\nfor i in range(N):\n\n pp.append(i + A[i])\n pm.append( i - A[i])\n\ncount = 0\nc = collections.Counter(pp)\nprint(c)\nfor i in range(N):\n count += c[pm[i]] \n print(c[pm[i]])\n\n #count += pp.count(pm[i])\n #count += pm.count(pp[i])\n\nprint(count)', 'import collections\nN = int(input())\nA = list(map(int,input().split()))\n\n#index,h\npp =[]\npm = []\nall_set = set()\nfor i in range(N):\n\n pp.append(i + A[i])\n pm.append( i - A[i])\n\ncount = 0\nc = collections.Counter(pp)\n#print(c)\nfor i in range(N):\n count += c[pm[i]] \n #print(c[pm[i]])\n\n #count += pp.count(pm[i])\n #count += pm.count(pp[i])\n\nprint(count)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s013077276', 's382492294', 's277418122']
[51024.0, 71176.0, 50524.0]
[325.0, 440.0, 225.0]
[366, 365, 367]
p02691
u265506056
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['N=int(input())\nA=list(map(int,input().split()))\na=[]\nB=[]\nans=0\nfor i in range(1,N):\n b=A[i]+A[0]\n a.append(b-i)\n B.append(A[i]-A[0])\nans=a.counter(0)\nfor i in range(N):\n b=B[i]\n a1=a[i:].copy()\n a1=a1-[b-i-1]\n ans+=a1.counter(0)\nprint(ans)', 'import bisect\nN=int(input())\nA=list(map(int,input().split()))\nL=[]\nR=[]\nans=0\nfor i in range(N):\n L.append(i+1+A[i])\n R.append(i+1-A[i])\nL.sort()\nR.sort()\nfor i in L:\n l=bisect.bisect_left(R,i)\n r=bisect.bisect_right(R,i)\n ans=ans+r-l\nprint(ans)']
['Runtime Error', 'Accepted']
['s722876091', 's848463352']
[34848.0, 35088.0]
[156.0, 434.0]
[261, 260]
p02691
u268181283
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['N = int(input())\narr = map(int,input().split())\n_sum = []\n_del = []\nfor i in range(N):\n _sum.append(arr[i]+i+1)\n _del.append(i+1-arr[i])', 'N = int(input())\narr = list(map(int,input().split()))\ncnt_arr = [0]*N\nans = 0\nfor i in range(N):\n if arr[i]+i+1<N:\n cnt_arr[arr[i]+i+1] += 1\n if i+1-arr[i]>0:\n ans += cnt_arr[i+1-arr[i]]\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s763548940', 's837818954']
[24788.0, 32272.0]
[41.0, 173.0]
[138, 206]
p02691
u268210555
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['from collections import *\nn = int(input())\na = list(map(int, input().split()))\nc = Counter()\nr = 0\nfor i in range(n):\n r += c[a[i]+i] \n c[i-a[i]] += 1\nprint(r)', 'from collections import *\nn = int(input())\na = list(map(int, input().split()))\nc = Counter(i-a[i] for i in range(n))\nr = 0\nfor i in range(n):\n c[i-a[i]] -= 1\n r += c[a[i]+i] \nprint(r)']
['Wrong Answer', 'Accepted']
['s901384776', 's380208974']
[40604.0, 40720.0]
[224.0, 279.0]
[165, 189]
p02691
u268724304
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['# -*- coding: utf-8 -*-\n\nN = int(input())\nA = list(map(int, input().split()))\ncount=0\nL = [0]*N\nR = [0]*N\nhash_L=[0]*10000000000\nhash_R=[0]*10000000000\nfor i in range(N):\n L[i]=A[i]+i\n hash_L[L[i]]=L[i]\n R[i]=-A[i]+i\n hash_R[R[i]]=R[i]\n\nfor i in range(2*N):\n if hash_L[i]==hash_R[i]:\n count=count+1\n\nprint("{}".format(count))', '# -*- coding: utf-8 -*-\n\nN = int(input())\nA = list(map(int, input().split()))\ncount=0\n\nfor i in range(N):\n for j in range(N-i-A[i]):\n k=i+j+A[i]\n if A[i]+A[k]==abs(i-k):\n count = count+1\n print("{} {}".format(i+1,k+1))\n\n\n\nprint("{}".format(count))\n', '# -*- coding: utf-8 -*-\n\nN = int(input())\nA = list(map(int, input().split()))\ncount=0\n\nfor i in range(N):\n m=max[i:]\n for j in range(N-i-A[i]):\n k=i+j+A[i]\n \n if A[i]+A[k]==k-i:\n count = count+1\n #print("{} {}".format(i+1,k+1))\n if A[i]+m+i<k:\n break\n\n\nprint("{}".format(count))\n', '# -*- coding: utf-8 -*-\n\nN = int(input())\nA = list(map(int, input().split()))\ncount=0\n\nfor i in range(N):\n for j in range(N-i):\n k=i+j\n if A[i]+A[k]==abs(i-k):\n count = count+1\n print("{} {}".format(i+1,k+1))\n\n\n\nprint("{}".format(count))\n', '# -*- coding: utf-8 -*-\n\nN = int(input())\nA = list(map(int, input().split()))\ncount=0\nL = [0]*N\nR = [0]*N\nN2=2*N\nhash_L=[0]*N2\nhash_R=[0]*N2\n\nsheet_L=[0]*N2\nsheet_R=[0]*N2\nfor i in range(N):\n L[i]=A[i]+i+1\n if L[i]<N2:\n if sheet_L[L[i]]==0:\n hash_L[L[i]]=L[i]\n sheet_L[L[i]]=1\n else:\n sheet_L[L[i]]=sheet_L[L[i]]+1\n\n R[i]=-A[i]+i+1\n if R[i]>0:\n if sheet_R[R[i]]==0:\n hash_R[R[i]]=R[i]\n sheet_R[R[i]]=1\n else:\n sheet_R[R[i]]=sheet_R[R[i]]+1\n\n\nfor i in range(2*N):\n if not hash_L[i]==0:\n if hash_L[i]==hash_R[i]:\n count=count+sheet_L[i]*sheet_R[i]\n#print("{}".format(hash_L))\n#print("{}".format(hash_R))\nprint("{}".format(count))\n']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s153284381', 's367214245', 's758190972', 's789355822', 's322266675']
[32240.0, 33304.0, 32196.0, 32376.0, 45980.0]
[69.0, 2229.0, 65.0, 2224.0, 360.0]
[347, 287, 346, 277, 755]
p02691
u279735925
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['from collections import defaultdict\n\nN = int(input())\t\n\n\n\nL = defaultdict(lambda: 0)\nR = defaultdict(lambda: 0)\nfor i, val in enumerate(map(int, input().split())):\n L[i - val] += 1\t\n R[i + val] += 1\t\n \nprint(L)\nprint("===")\nprint(R)\n\ncnt = 0\nfor key, val in L.items():\n if key > 0:\n cnt += L[key] * R[key]\n \nprint(cnt)', 'from collections import defaultdict\n \nN = int(input())\t\n \n\n\nL = defaultdict(lambda: 0)\nR = defaultdict(lambda: 0)\nfor i, val in enumerate(map(int, input().split())):\n L[i - val] += 1\t\n R[i + val] += 1\t\n \ncnt = 0\nfor key, val in L.items():\n if key > 0:\n cnt += L[key] * R[key]\n \nprint(cnt)']
['Wrong Answer', 'Accepted']
['s520262915', 's203074321']
[61324.0, 61308.0]
[343.0, 258.0]
[499, 469]
p02691
u290886932
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['N = int(input())\nA = list(map(int, input().split()))\n\nmax1 = max(A)\nA_ = A.copy()\nA_.remove(max1)\nmax2 = max(A_)\nln = max1 + max2\nret = 0\nfor i in range(len(A)-1):\n for j in range(i+1, i+ln + 1):\n if A[j] + A[i] == j - i:\n ret += 1\nprint(ret)', 'N = int(input())\nA_ = list(map(int, input().split()))\nA = list()\nfor i in range(len(A_)):\n if A_[i] < N - 1:\n A.append([i + 1, A_[i]])\nret = 0\nfor i in range(len(A)-1, -1, -1):\n ind, val = A[i][0], A[i][1]\n B = [a for a in A if a[1] < N - 1 - val]\n for b in B:\n if abs(b[0] - ind) == val + b[1]:\n ret += 1\nprint(ret)', 'N = int(input())\nA_ = list(map(int, input().split()))\nA = list()\nfor i in range(len(A_)):\n if A_[i] < N - 1:\n A.append([i + 1, A_[i]])\nret = 0\nfor i in range(len(A)-1, -1, -1):\n ind, val = A[i][0], A[i][1]\n B = [a for a in A if a[1] < N - 1 - val]\n for b in B:\n if abs(b[0] - ind) == val + b[1]:\n ret += 1\nreturn ret', 'N = int(input())\nA = list(map(int, input().split()))\nL1 = list()\nD2 = dict()\nret = 0\nfor i in range(len(A)):\n num1 = i + 1 - A[i]\n num2 = i + 1 + A[i]\n L1.append(num1)\n if num2 not in D2:\n D2[num2] = 1\n else:\n D2[num2] += 1\nret = 0\nretlist = dict()\nfor l in L1:\n if l in D2.keys():\n ret += D2[l]\nprint(ret)']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s419055466', 's460960159', 's641066644', 's302204174']
[32376.0, 45020.0, 9160.0, 46296.0]
[2206.0, 2206.0, 22.0, 231.0]
[263, 353, 353, 345]
p02691
u298945776
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['\n\nimport bisect\nN = int(input())\nA = list(map(int, input().split()))\nX = [A[i]+i for i in range(N)]\nY = [j - A[j] for j in range(N)]\nans = 0\nX.sort()\nfor i in range(N):\n ans += bisect.bisect_left(Y,X[i]) - bisect.bisect_right(Y,X[i])\nprint(ans)\n\n\n', '\n\nimport bisect\nN = int(input())\nA = list(map(int, input().split()))\nX = [A[i]+i for i in range(N)]\nY = [j - A[j] for j in range(N)]\nans = 0\nY.sort()\nfor i in range(N):\n ans += bisect.bisect_right(Y,X[i]) - bisect.bisect_left(Y,X[i])\nprint(ans)\n\n\n']
['Wrong Answer', 'Accepted']
['s828108278', 's830980987']
[33852.0, 33832.0]
[310.0, 331.0]
[642, 642]
p02691
u307592354
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['\n\ndef resolve():\n X= int(input())\n nums = dict()\n for A in range(10**4):\n nums[A**5] = A\n nums[-A**5] = -A \n\n if A**5 - X in nums:\n print(A,nums[A**5-X])\n \n \n\n\n\n \n\nif __name__ == "__main__":\n resolve()\n #unittest.main()', 'def resolve():\n N= int(input())\n A = list(map(int,input().split()))\n\n API = dict()\n ans = 0\n for i,a in enumerate(A):\n api = a+i+1\n ami = i+1-a\n\n if ami in API:\n ans += API[ami]\n\n if not api in API:\n API[api]=0\n API[api]+=1\n \n print(ans)\n\n\n\n\nif __name__ == "__main__":\n resolve()']
['Wrong Answer', 'Accepted']
['s013673232', 's537756764']
[11236.0, 40516.0]
[33.0, 161.0]
[290, 364]
p02691
u312078744
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
["import itertools\nn = int(input())\na = list(map(int, input().split()))\nidList = [i for i in range(1, n+1)]\n'''\ncom = list(itertools.combinations(idList, 2))\n\nnum = len(com)\n'''\nans = 0\n\nfor i in range(n):\n for j in range(i + 1, n):\n key = j - i\n heiA = a[i - 1]\n heiB = a[j - 1]\n height = heiA + heiB\n if (height == key):\n ans += 1\n\nprint(ans)\n\n", 'from collections import Counter\nN = int(input())\nA = list(map(int, input().split()))\n\nminus = [0] * N\nplus = [0] * N\n\nfor i in range(N):\n minus[i] = (i + 1) - A[i]\n plus[i] = (i + 1) + A[i]\n\ncount = Counter(minus)\nmost = count.most_common()\nnum = len(most)\n\ncountPP = Counter(plus)\n#mostPP = countPP.most_common()\n#check = mostPP[:][0]\nans = 0\n\nfor i in range(num):\n elm = most[i]\n fir = elm[0]\n sec = elm[1]\n # if (fir in check):\n\n aa = countPP[fir]\n # print(aa)\n ans += aa * sec\n\n # try countPP[tar]:\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s700707610', 's111233893']
[32012.0, 76668.0]
[2206.0, 359.0]
[662, 548]
p02691
u312907447
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['from collections import Counter\n\nN = int(input())\nA = list(map(int, input().split()))\n\n#cnt = 0\n\n# for j in range(i, N):\n\n# cnt += 1\n\nAp = [A[i]+i for i in range(len(A))]\nAm = [i-A[i] for i in range(len(A))]\n\nS = set(Ap) & set(Am)\n\nCp = Counter(Ap)\nCm = Counter(Am)\n\ncnt = 0\nfor i in S:\n cnt += Cp[i]*Cm[i]', 'from collections import Counter\n\nN = int(input())\nA = list(map(int, input().split()))\n\n#cnt = 0\n\n# for j in range(i, N):\n\n# cnt += 1\n\nAp = [A[i]+i for i in range(len(A))]\nAm = [i-A[i] for i in range(len(A))]\n\nS = set(Ap) & set(Am)\n\nCp = Counter(Ap)\nCm = Counter(Am)\n\ncnt = 0\nfor i in S:\n cnt += Cp[i]*Cm[i]\n \nprint(cnt)']
['Wrong Answer', 'Accepted']
['s295407940', 's865614542']
[64296.0, 64180.0]
[210.0, 223.0]
[361, 375]
p02691
u325282913
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['N = int(input())\narr = list(map(int, input().split()))\nmemo = [0]*(max(arr)*2)\nans = 0\nfor i in range(N):\n if (i+1)-arr[i] >= 0:\n ans += memo[(i+1)-arr[i]]\n if (i+1)+arr[i] > 0:\n memo[(i+1)+arr[i]] += 1\nprint(ans)', 'N = int(input())\narr = list(map(int, input().split()))\nmemo = [0]*((10**9)*2)\nans = 0\nfor i in range(N):\n if (i+1)-arr[i] >= 0:\n ans += memo[(i+1)-arr[i]]\n if (i+1)+arr[i] > 0:\n memo[(i+1)+arr[i]] += 1\nprint(ans)', 'from collections import defaultdict\nd = defaultdict(int)\nN = int(input())\narr = list(map(int, input().split()))\nans = 0\nfor i in range(N):\n ans += d[(i+1)-arr[i]]\n d[(i+1)+arr[i]] += 1\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s194702436', 's757487791', 's343948498']
[32312.0, 32380.0, 61640.0]
[185.0, 65.0, 242.0]
[233, 232, 201]
p02691
u326943507
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['N=int(input())\nL=list(map(int,input().split()))\nL_i=[i+1 for i in range(len(L))]\n\ncnt=0\nfor i in range(N):\n P_L= [m+L[i] for m in L[i:]]\n P_L_i = [x for x in range(N-i)]\n print(P_L)\n print(P_L_i)\n cnt = cnt + sum([w==z for (w, z) in zip(P_L,P_L_i)])\n \nprint(cnt)', 'def main():\n N=int(input())\n L=list(map(int,input().split()))\n L_i,L_j=[],[]\n L_memo = [0]*N\n cnt=0\n for i, j in enumerate(L):\n if i+j<N:\n L_memo[i+j]+=1\n if i-j>0:\n cnt+=L_memo[i-j] \n print(cnt)\nmain()']
['Wrong Answer', 'Accepted']
['s668991389', 's632120151']
[163060.0, 32312.0]
[2375.0, 107.0]
[280, 266]
p02691
u335950809
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['n = int(input())\nl = list(map(int,input().split()))\n\nai = []\naj = []\nans = 0\naiajmin = -9999999\n\n\nfor i in range(n):\n ai.append(i+l[i])\n\nfor j in range(n):\n aj.append(j-l[j])\n\n#print(ai)\n#print(aj)\n \naiajmin = min(max(ai),max(aj))\n\nfor x in range(n):\n if(ai[x] <= aiajmin):\n ans = ans + aj.count(ai[x])\n else:\n break\n \nprint(ans)', 'n = int(input())\nl = list(map(int,input().split()))\n\nmax = max(l) * 2\n\nans = 0\n\nfor i in range(n):\n j = i + 1\n\n while(j < n and j <= i+max):\n\n if abs(j- i) == l[i]+l[j]:\n ans = ans + 1\n print(abs(j-i),l[i]+l[j],i,j)\n j = j + 1\nprint(ans)', 'n = int(input())\nl = list(map(int,input().split()))\n\na=[]\nb={}\nans=0\n\nfor i in range(n):\n a.append(i+l[i])\n b[i-l[i]] = b.get(i-l[i],0) + 1\n\nfor av in a:\n ans = ans + b.get(av,0)\n\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s327601666', 's712853293', 's954364128']
[33884.0, 37940.0, 46412.0]
[2206.0, 2233.0, 227.0]
[361, 279, 199]
p02691
u338824669
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['N=int(input())\nA=[i+1 for i in range(N)]\n\nB=[0]*N\nfor i in range(N):\n if i-A[i]>0:\n B.append(i-A[i])\n\nans=0\nfor i in range(N):\n ans+=B.count(i+A[i])\nprint(ans)', 'N=int(input())\nA=list(map(int,input().split()))\n\nd={}\nfor i in range(N):\n if i-A[i]>0:\n if str(i-A[i]) in d:\n d[str(i-A[i])]+=1\n else:\n d[str(i-A[i])]=1\n\nans=0\nfor j in range(N):\n if str(j+A[j]) in d:\n ans+=d[str(j+A[j])]\nprint(ans)']
['Wrong Answer', 'Accepted']
['s760656564', 's872029847']
[18540.0, 32336.0]
[2206.0, 343.0]
[172, 281]
p02691
u347600233
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['n = int(input())\nL, R = [0] * n, [0] * n\ni = 0\nfor ipt in input().split():\n L[i] = i + ipt \n R[i] = i - ipt\n i += 1\ndef make_dic(L):\n L_set = set(L)\n return dict([(i, L.count(i)) for i in L_set])\nL_dic, R_dic = make_dic(L), make_dic(R)\ncnt = 0\nfor Lk, Lv in L_dic.items():\n try:\n cnt += R_dic[Lk] * Lv\n except KeyError:\n pass\nprint(cnt)', 'from collections import defaultdict\nn = int(input())\nL_dict, R_dict = defaultdict(int), defaultdict(int)\ni = 0\nfor ipt in input().split():\n L_dict[i + int(ipt)] += 1\n R_dict[i - int(ipt)] += 1\n i += 1\ncnt = 0\nfor Lk, Lv in L_dict.items():\n cnt += R_dict[Lk] * Lv\nprint(cnt)']
['Runtime Error', 'Accepted']
['s359155782', 's958357382']
[28952.0, 66228.0]
[42.0, 347.0]
[371, 289]
p02691
u364693468
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['import bisect\nN = int(input())\nA = [0]\nA += list(map(int, input().split()))\ncnt = 0\nL = [- 10 ** 6]\nR = [- 10 ** 6]\n\nfor i in range(1, N + 1):\n L.append(i + A[i])\n R.append(i - A[i])\nL.sort()\nprint(L)\nprint(R)\nfor j in range(1, N + 1):\n x = bisect.bisect_left(L, R[j])\n while R[j] == L[x]:\n cnt += 1\n x += 1\nprint(cnt)', 'import collections\nN = int(input())\nA = [0]\nA += list(map(int, input().split()))\ncnt = 0\nL = [- 10 ** 6]\nR = [- 10 ** 6]\n\nfor i in range(1, N + 1):\n L.append(i + A[i])\n R.append(i - A[i])\nc = collections.Counter(L)\n\nfor j in range(1, N + 1):\n cnt += c.get(R[j], 0)\nprint(cnt)']
['Wrong Answer', 'Accepted']
['s025107527', 's529193882']
[36944.0, 51764.0]
[2210.0, 224.0]
[344, 284]
p02691
u370721525
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['N = int(input())\nA = list(map(int, input().split()))\nans = 0\nfor i in range(N-1):\n for j in range(i+1, N+1):\n number = abs(i-j)\n tall = A[i]+A[j]\n if number == tall:\n ans += 1\n \nprint(ans)', 'from collections import defaultdict\n \nn = int(input())\na = list(map(int, input().split()))\nap = defaultdict(int)\nfor i in range(n):\n ap[i - a[i]] += 1\n\nans= 0\nfor i in range(n):\n ans += ap[a[i] + i]\nprint(ans)']
['Runtime Error', 'Accepted']
['s408066068', 's370773541']
[32376.0, 61584.0]
[117.0, 231.0]
[208, 215]
p02691
u373021729
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['import itertools\nN = int(input())\nA = input().split()\nAi = [int(s) for s in A]\ncount = 0\nfor x, y in itertools.combinations(range(N), 2):\n if abs(x-y)+100 == Ai[x]+Ai[y]:\n count += 1\nprint(count)', 'import itertools\nN = int(input())\nA = input().split()\ncount = 0\nfor x, y in itertools.combinations(range(N), 2):\n if abs(x-y)+100 == int(A[x])+int(A[y]):\n count += 1\nprint(count)', 'from collections import defaultdict\ndic = defaultdict(int)\n\nN = int(input())\nA = list(map(int, input().split()))\n\nfor i, a in enumerate(A):\n dic[i + a] += 1\n\ncounter = 0\nfor i, a in enumerate(A):\n counter += dic[i-a]\n\nprint(counter)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s633906842', 's837923993', 's778271459']
[40460.0, 31236.0, 61808.0]
[2206.0, 2207.0, 246.0]
[213, 196, 238]
p02691
u395202850
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
["import collections\nimport sys\nreadline = sys.stdin.readline\n\n\ndef main():\n n = int(readline().rstrip())\n A = list(map(int, readline().rstrip().split()))\n ans = 0\n c = collections.Counter()\n\n for i in range(n):\n ans += c[i + 1 - A[i]]\n c[i + 1 + A[i]] += 1\n\n print(c)\n\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "import collections\nimport sys\nreadline = sys.stdin.readline\n\n\ndef main():\n n = int(readline().rstrip())\n A = list(map(int, readline().rstrip().split()))\n ans = 0\n c = collections.Counter()\n\n for i in range(n):\n ans += c[i + 1 - A[i]]\n c[i + 1 + A[i]] += 1\n\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Accepted']
['s074186580', 's061683369']
[63284.0, 40604.0]
[326.0, 214.0]
[355, 341]
p02691
u408375121
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['n = int(input())\na = list(map(int, input().split()))\ndic = {}\nfor i in range(n-1):\n idx = i + a[i] + 1\n if idx in dic:\n dic[idx] += 1\n else:\n dic[idx] = 1\nans = 0\nj = n-1\nwhile j > 0:\n target = j + 1 - a[j]\n idx = j + 1 + a[j]\n if target in dic:\n ans += dic[target]\n dic[idx] -= 1\n j -= 1\nprint(ans)', 'n = int(input())\na = list(map(int, input().split()))\ndic = {}\nfor i in range(n-1):\n idx = i + a[i] + 1\n if idx in dic:\n dic[idx] += 1\n else:\n dic[idx] = 1\nans = 0\nj = n-1\nwhile j > 0:\n target = j + 1 - a[j]\n idx = j + 1 + a[j]\n if target in dic:\n ans += dic[target]\n if j < n-1:\n \tdic[idx] -= 1\n j -= 1\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s681100121', 's537239538']
[40292.0, 40400.0]
[227.0, 298.0]
[316, 332]
p02691
u426764965
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['import numpy as np\n\ndef abc166_e():\n N = int(readline())\n A = np.array(readline().split(), dtype=np.int64)\n\n \n idx = np.arange(1, N+1, dtype=np.int64) - np.arange(1, N+1, dtype=np.int64).reshape(-1, 1)\n np.absolute(idx, out=idx)\n \n valsum = A + A.reshape(-1, 1)\n\n \n \n diff = idx - valsum\n ans = N*N - np.count_nonzero(diff)\n ans //= 2 \n print(ans)\n\nabc166_e()', '\n\ndef abc166_e():\n _ = int(input())\n A = list(map(int, input().split()))\n ans = 0\n from collections import defaultdict\n d = defaultdict(int)\n for i, x in enumerate(A, 1):\n ans += d[i - x]\n d[x + i] += 1\n print(ans)\n\nabc166_e()']
['Runtime Error', 'Accepted']
['s075529795', 's344640775']
[27168.0, 61428.0]
[110.0, 218.0]
[630, 318]
p02691
u429029348
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['N = int(input())\nA = list(map(int, input().split()))\n\ncheck = {}\nans = 0\n\nfor i in range(N):\n x = i - A[i]\n y = A[i] + i\n ans += check.get(x, 0)\n check.setdefault(y, 0)\n check[y] += 1\n\nprint(ans)\nprint(check)', 'N = int(input())\nA = list(map(int, input().split()))\n\ncheck = {}\nans = 0\n\nfor i in range(N):\n x = i - A[i]\n y = A[i] + i\n ans += check.get(x, 0)\n check.setdefault(y, 0)\n check[y] += 1\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s103913653', 's999207207']
[40508.0, 40424.0]
[224.0, 195.0]
[223, 210]
p02691
u430336181
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['import collections\n\nN = int(input())\nA = list(map(int, input().split()))\n\nL = [i + A[i] for i in range(N)]\nR = [i - A[i] for i in range(N)]\n\ncountL = collections.Counter(L)\n\ncountR = collections.Counter(R)\n\n\nprint([countL[n] * countR[n] for n in countL.keys()])', 'import collections\n\nN = int(input())\nA = list(map(int, input().split()))\n\nL = [i + A[i] for i in range(N)]\nR = [i - A[i] for i in range(N)]\n\ncountL = collections.Counter(L)\n\ncountR = collections.Counter(R)\n\n\nprint(sum([countL[n] * countR[n] for n in countL.keys()]))']
['Wrong Answer', 'Accepted']
['s788882624', 's500258621']
[63448.0, 63504.0]
[243.0, 237.0]
[261, 266]
p02691
u437351386
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['n=int(input())\nA=list(map(int,input().split()))\nL=[]\nR=[]\nfor i in range(n):\n L.append(i+A[i])\n R.append(i-A[i])\nfrom collections import Counter\nzisyo=R.Counter(R)\nans=0\nfor i in L:\n ans=ans+get(i,0)\nprint(ans)\n \n', 'n=int(input())\nA=list(map(int,input().split()))\nL=[]\nR=[]\nfor i in range(n):\n L.append(i+A[i])\n R.append(i-A[i])\nfrom collections import Counter\nzisyo=Counter(R)\nans=0\nfor i in L:\n ans=ans+zisyo.get(i,0)\nprint(ans)\n ']
['Runtime Error', 'Accepted']
['s706913909', 's883493685']
[35340.0, 50908.0]
[144.0, 216.0]
[217, 220]
p02691
u462329577
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['#!/usr/bin/env python3\nn, m = map(int, input().split())\nh = list(map(int, input().split()))\nnot_good = []\nfor i in range(m):\n a, b = map(int, input().split())\n if h[a - 1] > h[b - 1]: \n not_good.append(b)\n elif h[a - 1] == h[b - 1]:\n not_good.append(a)\n not_good.append(b)\n else:\n not_good.append(a)\nans = 0\nnot_good = list(set(not_good))\nnot_good.sort()\n# print(not_good)\nidx = 0\nfor i in range(1, n + 1):\n if i < not_good[idx]:\n ans += 1\n # print(i, end=" ")\n elif i == not_good[idx]:\n idx += 1\n if idx == len(not_good):\n ans += n - i\n break\n else:\n pass\nprint(ans)\n', '#!/usr/bin/env python3\nimport bisect\n\nn = int(input())\na = list(map(int, input().split()))\n\n\nb = [a[i] - (1 + i) for i in range(0, n)]\nb, idx = zip(*sorted(zip(b, range(1, n + 1))))\n# print(b)\nans = 0\nfor i in range(n):\n \n r = bisect.bisect_right(b, -b[i] - 2 * idx[i])\n l = bisect.bisect_left(b, -b[i] - 2 * idx[i])\n ans += r - l\n # if r - l != 0:\n # print(i, r, l, -b[i] - 2 * idx[i])\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s170187172', 's121082564']
[9240.0, 61140.0]
[22.0, 710.0]
[687, 563]
p02691
u474561976
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['ef main():\n from collections import Counter\n n = int(input())\n As = list(map(int,input().split(" ")))\n \n cnts = Counter()\n dp = [0]*n\n for i in range(1,n):\n dp[i] =dp[i-1] + cnts.get(i-As[i],0)\n cnts[As[i]+i]+=1\n print(dp[n-1])\nmain()', 'def main():\n from collections import Counter\n n = int(input())\n As = list(map(int,input().split(" ")))\n \n cnts = Counter()\n dp = [0]*n\n cnts[As[0]+1]+=1\n for i in range(1,n):\n dp[i] =dp[i-1] + cnts.get(i+1-As[i],0)\n cnts[As[i]+i+1]+=1\n print(dp[n-1])\nmain()']
['Runtime Error', 'Accepted']
['s769320881', 's389194627']
[9036.0, 45784.0]
[24.0, 213.0]
[272, 298]
p02691
u485319545
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
["N=int(input())\nAgents=list(map(int,input().split()))\n\n\n##Miss 1\n# from itertools import combinations\n\n\n\n# cnt=0\n\n# if Agents[i[0]] + Agents[i[1]] == abs(i[0] - i[1]):\n# print(i[0],i[1])\n# cnt+=1\n\n# print(cnt)\n\n# Miss 2\n\n# k=Agents[i]-(i+1)\n# if k<i:\n# k=i+1\n# for j in range(k,N):\n# if Agents[i]+Agents[j]==abs(i-j):\n# # print(i,j,Agents[i],Agents[j])\n# cnt+=1\n\n\nL={}\nfor i in range(N):\n L['{}'.format(i+1)]=i+1 + Agents[i]\nR={}\nfor j in range(N):\n R['{}'.format(j+1)]=j+1 - Agents[j]\n\nprint(L)\nprint(R)\n\ncnt=0\n\nfor key,value in L.items():\n for key2,value2 in R.items():\n if int(key) < int(key2) and value == value2:\n cnt+=1\n\n\nprint(cnt)\n", 'N=int(input())\nAgents=list(map(int,input().split()))\n\n\n##Miss 1\n# from itertools import combinations\n\n\n\n# cnt=0\n\n# if Agents[i[0]] + Agents[i[1]] == abs(i[0] - i[1]):\n# print(i[0],i[1])\n# cnt+=1\n\n# print(cnt)\n\n# Miss 2\n\n# k=Agents[i]-(i+1)\n# if k<i:\n# k=i+1\n# for j in range(k,N):\n# if Agents[i]+Agents[j]==abs(i-j):\n# # print(i,j,Agents[i],Agents[j])\n# cnt+=1\n\n\nL={}\nfor i in range(N):\n s = i+1 + Agents[i] \n if s in L:\n L[s]+=1\n else:\n L[s]=1\n\nR={}\nfor j in range(N):\n s= j+1 - Agents[j]\n if s in R:\n R[s]+=1\n else:\n R[s]=1\ncnt=0\n\nfor key,value in L.items():\n cnt += R.get(key,0) * value\n# for key,value in L.items():\n# for key2,value2 in R.items():\n# if int(key) < int(key2) and value == value2:\n# cnt+=1\n\n\nprint(cnt)\n']
['Wrong Answer', 'Accepted']
['s335585579', 's771531871']
[87460.0, 59344.0]
[2216.0, 274.0]
[827, 956]
p02691
u487594898
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['import collections\nn=int(input())\n\nA=list(map(int,input().split())))\nB = [(A[0] + A[i] -i) for i in range(n)]\nb = collections.Counter(B)\nans =0\ncnt = 0\nfor i in range(len(B)):\n \n ans += b[cnt]\n if i != 0:\n cnt += (B[i] - B[i-1] -1)\n\nprint(ans)', 'import collections\nn=int(input())\nA=list(map(int,input().split()))\nB = [ i-A[i] for i in range(n)]\nC = [ i+A[i] for i in range(n)]\nb = collections.Counter(B)\nc = collections.Counter(C)\nans =0\ncnt = 0\n \nfor i in b.keys():\n ans +=c[i]*b[i]\n \nprint(ans) ']
['Runtime Error', 'Accepted']
['s700913294', 's719835893']
[9024.0, 63448.0]
[25.0, 249.0]
[261, 262]
p02691
u489124637
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['import numpy as np\nimport sys\ninput = sys.stdin.readline\n\n\nN = int(input())\n\na = list(map(int, input().split()))\nA = np.array([a for i in range(N)])\nB = np.array([[a[i]] * N for i in range(N)])\nC = A + B\nd = [i for i in range(N)]\nD = np.array([d for i in range(N)])\nE = np.array([[i] * N for i in range(N)])\n\n#print(D)\n#print(E)\nind = D - E\n#print(ind)\nans = C - ind\n#print(ans)\n\nprint(cnt)', 'import collections\n\nN = int(input())\nA = list(map(int, input().split()))\nB = {}\nC = {}\n\nfor i in range(N):\n if i-A[i] in B:\n B[i-A[i]] += 1\n else:\n B[i-A[i]] = 1\n if i+A[i] in C:\n C[i+A[i]] += 1\n else:\n C[i+A[i]] = 1\n\n#print(C)\nans = 0\nfor i in B:\n #print(i) i=Key\n if i in C:\n ans += B[i]*C[i]\nprint(ans)']
['Runtime Error', 'Accepted']
['s958565498', 's678812647']
[247716.0, 57728.0]
[2207.0, 262.0]
[423, 367]
p02691
u509739538
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['import math\n \ndef readInt():\n\treturn int(input())\ndef readInts():\n\treturn list(map(int, input().split()))\ndef readChar():\n\treturn input()\ndef readChars():\n\treturn input().split()\ndef factorization(n):\n\tres = []\n\tif n%2==0:\n\t\tres.append(2)\n\tfor i in range(3,math.floor(n//2)+1,2):\n\t\tif n%i==0:\n\t\t\tc = 0\n\t\t\tfor j in res:\n\t\t\t\tif i%j==0:\n\t\t\t\t\tc=1\n\t\t\tif c==0:\n\t\t\t\tres.append(i)\n\treturn res\ndef fact2(n):\n\tp = factorization(n)\n\tres = []\n\tfor i in p:\n\t\tc=0\n\t\tz=n\n\t\twhile 1:\n\t\t\tif z%i==0:\n\t\t\t\tc+=1\n\t\t\t\tz/=i\n\t\t\telse:\n\t\t\t\tbreak\n\t\tres.append([i,c])\n\treturn res\ndef pop2(li):\n\tc=1\n\ti=li.pop(0)\n\twhile 1:\n\t\tj=li.pop(0)\n\t\tif j==i:\n\t\t\tc+=1\n\t\telse:\n\t\t\tbreak\n\treturn i,c,[j]+li\n\nn = readInt()\na = readInts()\n\nli = []\nri = []\n\nfor i in range(n):\n\tli.append(i+a[i])\n\tri.append(i-a[i])\n\nli.sort()\nri.sort()\n\nres = 0\n\ntar = []#list(set(li)&set(ri))\n\nfor i in tar:\n\tres+=li.count(i)*ri.count(i)\n\nprint(res)', 'import math\nfrom collections import defaultdict\n \ndef readInt():\n\treturn int(input())\ndef readInts():\n\treturn list(map(int, input().split()))\ndef readChar():\n\treturn input()\ndef readChars():\n\treturn input().split()\ndef factorization(n):\n\tres = []\n\tif n%2==0:\n\t\tres.append(2)\n\tfor i in range(3,math.floor(n//2)+1,2):\n\t\tif n%i==0:\n\t\t\tc = 0\n\t\t\tfor j in res:\n\t\t\t\tif i%j==0:\n\t\t\t\t\tc=1\n\t\t\tif c==0:\n\t\t\t\tres.append(i)\n\treturn res\ndef fact2(n):\n\tp = factorization(n)\n\tres = []\n\tfor i in p:\n\t\tc=0\n\t\tz=n\n\t\twhile 1:\n\t\t\tif z%i==0:\n\t\t\t\tc+=1\n\t\t\t\tz/=i\n\t\t\telse:\n\t\t\t\tbreak\n\t\tres.append([i,c])\n\treturn res\ndef pop2(li):\n\tc=1\n\ti=li.pop(0)\n\twhile 1:\n\t\tj=li.pop(0)\n\t\tif j==i:\n\t\t\tc+=1\n\t\telse:\n\t\t\tbreak\n\treturn i,c,[j]+li\n\nn = readInt()\na = readInts()\n\nli = []\nri = []\n\nd1 = defaultdict(int)\nd2 = defaultdict(int)\n\nfor i in range(n):\n\td1[i+a[i]]+=1\n\td2[i-a[i]]+=1\n\nans = 0\n\nfor key in d1:\n\tans+=d1[key]*d2[key]\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s153931125', 's325016471']
[36332.0, 73844.0]
[226.0, 335.0]
[884, 897]
p02691
u512212329
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
["# class Map(dict):\n\n\n# # self[key] = 0\n# return 0\n\n\ndef main():\n int(input())\n\n d = {}\n ans = 0\n for i, height in enumerate(input().split()):\n height = int(height)\n \n \n got = d.get(i + height) or 0\n d[i + height] += got + 1\n ans += d.get(i - height) or 0\n\n return ans\n\n\nif __name__ == '__main__':\n print(main())\n\n\n# https://kmjp.hatenablog.jp/entry/2020/05/03/1030\n", "def main():\n int(input())\n d = {}\n ans = 0\n for i, height in enumerate(input().split()):\n d[i + height] += 1\n ans += d[i - height]\n\n\nif __name__ == '__main__':\n print(main())\n", "from collections import defaultdict\n\n\ndef main():\n input() # n is never used\n dct = defaultdict(int)\n ans = 0\n it = (int(x) for x in input().split())\n for i, height in enumerate(it):\n dct[i + height] += 1\n ans += dct[i - height]\n print(ans)\n return\n\n\nif __name__ == '__main__':\n main()\n"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s728441168', 's750139945', 's916517537']
[24688.0, 24636.0, 67380.0]
[40.0, 41.0, 216.0]
[687, 204, 325]
p02691
u513491355
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['def main():\n n=int(input())\n heights=list(map(int,input.split()))\n assert len(heights)==n\n i=0\n count=0\n while i<n:\n j=i+1\n while j<n:\n if heights[i]+heights+[j]==(j-i):\n count+=1\n print(count)\nmain()', 'def main():\n n=int(input())\n heights=list(map(int,input().split()))\n assert len(heights)==n\n i=0\n count=0\n while i<n:\n j=i+1\n while j<n:\n if heights[i]+heights+[j]==(j-i):\n count+=1\n print(count)\nmain()', "def main():\n N = int(input())\n A = [int(x) for x in input().split()]\n from collections import defaultdict\n count = defaultdict(int)\n ans = 0\n for i, a in enumerate(A):\n if i - a in count:\n ans += count[i-a]\n count[i+a] += 1\n print(ans)\n \n \nif __name__ == '__main__':\n main()"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s809258129', 's830065585', 's752819306']
[9108.0, 32268.0, 40668.0]
[24.0, 63.0, 151.0]
[225, 227, 323]
p02691
u519123891
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['import numpy as np\n\n# input\nn = int(input())\ninp_ls = input().split(" ")\na_ls = np.array([int(e) for e in inp_ls[:n]])\nprint(a_ls)\n\ncnt = 0\nfor i in range(n-1):\n\tabs_val = i+1\n\tl0 = a_ls[:-abs_val]\n\tl1 = a_ls[abs_val:]\n\th_sum_ls = l0+l1\n\tcnt += np.count_nonzero(h_sum_ls == abs_val)\n\n# result\nprint(cnt)', 'def count_j(arg_ls, th, b_idx, e_idx):\n\tif b_idx-1 == e_idx: return 0\n\tif b_idx == e_idx: return int(arg_ls[b_idx] > th)\n\tcent_idx = (e_idx+1 - b_idx) // 2 + b_idx\n\tcent_j = arg_ls[cent_idx]\n\tif cent_j > th:\n\t\treturn count_j(arg_ls, th, b_idx, cent_idx-1) + (e_idx+1 - cent_idx)\n\telse:\n\t\treturn count_j(arg_ls, th, cent_idx, e_idx)\n\nn = int(input())\ninp_ls = input().split(" ")\na_ls = [int(e) for e in inp_ls[:n]]\n\ni_dic = {}\nfor i,a in enumerate(a_ls):\n\tval = -a+(i+1)\n\tif val not in i_dic: i_dic[val] = []\n\ti_dic[val].append(i+1)\n\ncnt = 0\nfor i in range(len(a_ls)):\n\tval = a_ls[i] + (i+1)\n\tcand_ls = i_dic.get(val, [])\n\tresult = count_j(cand_ls, (i+1), 0, len(cand_ls)-1)\n\tcnt += result\n\nprint(cnt)']
['Wrong Answer', 'Accepted']
['s767989086', 's622524214']
[52532.0, 77452.0]
[2207.0, 771.0]
[303, 700]
p02691
u526094365
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
[' from collections import Counter\n N = int(input())\n A = list(map(int, input().split()))\n\n Y = [int(i + A[i - 1]) for i in range(1, N + 1)]\n Y = Counter(Y)\n\n cnt = 0\n for i in range(1, N+1):\n X = i - A[i - 1]\n if X in Y.keys():\n cnt += Y[X]\n print(cnt)\n', 'from collections import Counter\nN = int(input())\nA = list(map(int, input().split()))\n\nY = [int(i + A[i - 1]) for i in range(1, N + 1)]\nY = Counter(Y)\n\ncnt = 0\nfor i in range(1, N+1):\n X = i - A[i - 1]\n if X in Y.keys():\n cnt += Y[X]\nprint(cnt)\n']
['Runtime Error', 'Accepted']
['s299354728', 's039850197']
[8952.0, 42936.0]
[23.0, 199.0]
[301, 257]
p02691
u529737989
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['import collections\n\nN = int(input())\nA = list(map(int , input().split()))\n\n# N = 32\n# A = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5]\n\n# N = 6\n# A = [2, 3, 3, 1, 3, 1]\n\ni = [k for k in range(1,N+1)]\nj = [k for k in range(1,N+1)]\n\nLi = [i[k]+A[k] for k in range(N)]\nRj = [j[k]-A[k] for k in range(N)]\n\nLi = collections.Counter(Li)\n\ncounter = 0\nfor r in Rj:\n counter += Li[r]', 'import collections\n\nN = int(input())\nA = list(map(int , input().split()))\n\n# N = 32\n# A = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5]\n\n# N = 6\n# A = [2, 3, 3, 1, 3, 1]\n\ni = [k for k in range(1,N+1)]\nj = [k for k in range(1,N+1)]\n\nLi = [i[k]+A[k] for k in range(N)]\nRj = [j[k]-A[k] for k in range(N)]\n\nLi = collections.Counter(Li)\n\ncounter = 0\nfor r in Rj:\n counter += Li[r]\nprint(counter)']
['Wrong Answer', 'Accepted']
['s166832541', 's313947716']
[66480.0, 66524.0]
[207.0, 213.0]
[429, 444]
p02691
u530786533
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['from collections import Counter\n\nn = int(input())\na = list(map(int, input().split()))\n\nr = []\nfor i, ai in enumerate(a):\n l.append(i+ai)\n r.append(i-ai)\n\nans = 0\nb = Counter(r)\nfor i in l:\n ans += b.get(i, 0)\n\nprint(ans)\n', 'from collections import Counter\n\nn = int(input())\na = list(map(int, input().split()))\n\nl = []\nr = []\nfor i, ai in enumerate(a):\n l.append(i+ai)\n r.append(i-ai)\n\nans = 0\nb = Counter(r)\nfor i in l:\n ans += b.get(i, 0)\n\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s812780173', 's661789410']
[33824.0, 50824.0]
[68.0, 200.0]
[227, 234]
p02691
u548545174
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['from collections import Counter\n\nN = int(input())\nA = list(map(int, input().split()))\n\nd = dict(collections.Counter([i + A[i-1] for i in range(1, N+1)]))\nans = sum([d.get(i - A[i-1], 0) for i in range(1, N+1)])\n\nprint(ans)\n', 'from collections import defaultdict\n\nN = int(input())\nA = list(map(int, input().split()))\n\nmemo = defaultdict(int)\nans = 0\nfor i, h in enumerate(A, start=1):\n ans += memo[h+i]\n memo[i-h] += 1\n\nprint(ans)', 'from collections import Counter\n\nN = int(input())\nA = list(map(int, input().split()))\n\nd = dict(Counter([i + A[i-1] for i in range(1, N+1)]))\nans = sum([d.get(i - A[i-1], 0) for i in range(1, N+1)])\n\nprint(ans)\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s441210997', 's676850666', 's881116756']
[33768.0, 61440.0, 47928.0]
[67.0, 231.0, 181.0]
[223, 209, 211]
p02691
u564589929
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
["import sys\nsys.setrecursionlimit(10 ** 6)\n# input = sys.stdin.readline ####\nint1 = lambda x: int(x) - 1\ndef II(): return int(input())\n\ndef MI(): return map(int, input().split())\ndef MI1(): return map(int1, input().split())\n\ndef LI(): return list(map(int, input().split()))\ndef LI1(): return list(map(int1, input().split()))\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\n\ndef printlist(lst, k='\\n'): print(k.join(list(map(str, lst))))\nINF = float('inf')\n\ndef solve():\n n = II()\n A = LI()\n\n memo = {}\n ans = 0\n for j in range(n):\n sa = j - A[j]\n ans += memo.get(sa, 0)\n wa = j + A[j]\n memo[wa] = memo.get(wa, 0) + 1\n print(memo)\n print(ans)\n\n\nif __name__ == '__main__':\n solve()\n", "import sys\nsys.setrecursionlimit(10 ** 9)\n# input = sys.stdin.readline ####\ndef int1(x): return int(x) - 1\ndef II(): return int(input())\ndef MI(): return map(int, input().split())\ndef MI1(): return map(int1, input().split())\ndef LI(): return list(map(int, input().split()))\ndef LI1(): return list(map(int1, input().split()))\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\ndef MS(): return input().split()\ndef LS(): return list(input())\ndef LLS(rows_number): return [LS() for _ in range(rows_number)]\ndef printlist(lst, k=' '): print(k.join(list(map(str, lst))))\nINF = float('inf')\n# from math import ceil, floor, log2\n# from collections import deque\n# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations\n# from heapq import heapify, heappop, heappush\n# import numpy as np # cumsum\n\n\ndef solve():\n N = II()\n A = LI()\n\n memo = {}\n ans = 0\n for i, a in enumerate(A):\n i = i + 1\n \n ans = ans + memo.get(i - a, 0)\n memo[a + i] = memo.get(a + i, 0) + 1\n print(ans)\n\n\nif __name__ == '__main__':\n solve()\n"]
['Runtime Error', 'Accepted']
['s955281694', 's068946007']
[146444.0, 40544.0]
[2194.0, 151.0]
[754, 1206]
p02691
u566159623
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['n = int(input())\na = list(map(int, input().split()))\ncount = 0\nd={}\nfor i in range(n):\n if i - a[i] in d:\n count+=d[i - a[i]]\n if i + a[i] in d:\n d[i+a[i]] + 1\n else:\n d[i+a[i]] = 1\n\nprint(count)', 'n = int(input())\na = list(map(int, input().split()))\ncount = 0\nd={}\nfor i in range(n):\n if i - a[i] in d:\n count+=d[i - a[i]]\n if i + a[i] in d:\n d[i+a[i]] += 1\n else:\n d[i+a[i]] = 1\n\nprint(count)']
['Wrong Answer', 'Accepted']
['s097740930', 's347418716']
[40524.0, 40464.0]
[181.0, 180.0]
[225, 226]
p02691
u572142121
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['N=int(input())\nA=list(map(int, input().split()))\nD={}\nE={}\nfor i in range(N):\n a=i+A[i]\n b=i+A[i]\n D.setdefault(a,0)\n E.setdefault(b,0)\n D[a]+=1\n E[b]+=1\nans=0\nfor i in D.keys():\n if i in E.keys():\n ans+=D[i]*E[i]\nprint(ans)', 'N=int(input())\nA=list(map(int, input().split()))\nD={}\nE={}\nfor i in range(N):\n a=i+1+A[i]\n b=i+1-A[i]\n D.setdefault(a-1,0)\n E.setdefault(b-1,0)\n D[a-1]+=1\n E[b-1]+=1\nprint(D,E)\nans=0\nfor i in D:\n if i in E:\n ans+=D[i]*E[i]\nprint(ans)\n ', 'N=int(input())\nA=list(map(int, input().split()))\nD={}\nE={}\nfor i in range(N):\n a=i+A[i]\n b=i-A[i]\n D.setdefault(a,0)\n E.setdefault(b,0)\n D[a]+=1\n E[b]+=1\nans=0\nfor i in D.keys():\n if i in E.keys():\n ans+=D[i]*E[i]\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s224475905', 's671880368', 's971354979']
[56564.0, 56864.0, 56844.0]
[303.0, 377.0, 271.0]
[234, 248, 234]
p02691
u573678402
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['from math import sqrt\n\nperson = int(input())\nlongs = list(map(int, input().split(" ")))\n\nsum = 0\nfor i in range(person):\n for j in range(i, min(i + longs[i], person)):\n if (j - i) == longs[i] + longs[j]:\n sum += 1\nprint(sum)', 'from math import sqrt\n\nperson = int(input())\nlongs = list(map(int, input().split(" ")))\n\nlongsi_dic = {}\nfor i in range(len(longs)):\n if str(i + longs[i]) not in longsi_dic:\n longsi_dic[str(i + longs[i])] = 0\n longsi_dic[str(i + longs[i])] += 1\n\nlongsj_dic = {}\nfor j in range(len(longs)):\n if str(j - longs[j]) not in longsj_dic:\n longsj_dic[str(j - longs[j])] = 0\n longsj_dic[str(j - longs[j])] += 1\n\nsum = 0\nfor val, sumi in longsi_dic.items():\n if val not in longsj_dic:\n continue\n sum += int(sumi) * int(longsj_dic[val])\n\nprint(sum)']
['Wrong Answer', 'Accepted']
['s574810005', 's783765753']
[33576.0, 71108.0]
[2206.0, 555.0]
[245, 576]
p02691
u595375942
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['from collections import defaultdict\nN = int(input())\nA = list(map(int, input().split()))\nD = defaultdict(int)\nans = 0\n\nfor i, x in enumerate(A, 1):\n ans += D[i-x]\n D[x+i] += 1\n\nprint(ans, D)', 'from collections import defaultdict\nN = int(input())\nA = list(map(int, input().split()))\nD = defaultdict(int)\nans = 0\n\nfor i, x in enumerate(A, 1):\n ans += D[i-x]\n D[x+i] += 1\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s399871329', 's261969256']
[65328.0, 61432.0]
[294.0, 230.0]
[196, 193]
p02691
u599547273
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['from collections import Counter\n\nN = int(input())\nA = list(map(int, input().split()))\n\np = [i+Ai for i, Ai in zip(range(1, N+1), A)]\nq = [j-Aj for j, Aj in zip(range(1, N+1), A)]\n\npc = Counter(p)\nqc = Counter(q)\n\nr = sum(pc[k]*qc[k] for k in pc.keys() & qc.keys())', 'from collections import Counter\n\nN = int(input())\nA = list(map(int, input().split()))\n\np = [i+Ai for i, Ai in zip(range(1, N+1), A)]\nq = [j-Aj for j, Aj in zip(range(1, N+1), A)]\n\npc = Counter(p)\nqc = Counter(q)\n\nr = sum(pc[k]*qc[k] for k in pc.keys() & qc.keys())\n\nprint(r)']
['Wrong Answer', 'Accepted']
['s410516047', 's475064805']
[71708.0, 71828.0]
[191.0, 189.0]
[264, 274]
p02691
u616619529
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['# -*- coding: utf-8 -*-\n\nn = int(input())\nh_list = input().split()\nh_list = [int(h) for h in h_list]\n\ncount = 0\n\nfor i in range(n):\n a_height = h_list[i]\n for k in range(i + 1 + a_height, i+21):\n b_height = h_list[k]\n if k - i == a_height + b_height:\n count += 1\n\nprint(count)\n', '# -*- coding: utf-8 -*-\n\nn = int(input())\nh_list = input().split()\nh_list = [int(h) for h in h_list]\n\ncount = 0\nresult_dict = {}\n\nfor i in range(n):\n key = (i+1) + h_list[i]\n value = result_dict.get(key, 0)\n result_dict[key] = value + 1\n\nfor j in range(n):\n key = (j+1) - h_list[j]\n count += result_dict.get(key, 0)\n\nprint(count)\n']
['Runtime Error', 'Accepted']
['s007809910', 's107373539']
[32324.0, 40308.0]
[566.0, 219.0]
[325, 362]
p02691
u622570247
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['from collections import defaultdict\n\nn, a, b, c = map(int, input().split())\ns = [None] * n\nfor i in range(n):\n s[i] = input().rstrip()\n\nif a + b + c == 0:\n print("No")\n exit(0)\n\nans = [None] * n\nif a + b + c == 1:\n for i in range(n):\n if s[i] == \'AB\':\n if a == 0 and b == 0:\n print(\'No\')\n exit(0)\n if b == 0:\n b += 1\n a -= 1\n ans[i] = \'B\'\n else:\n a += 1\n b -= 1\n ans[i] = \'A\'\n elif s[i] == \'BC\':\n if b == 0 and c == 0:\n print(\'No\')\n exit(0)\n if c == 0:\n b -= 1\n c += 1\n ans[i] = \'C\'\n else:\n b += 1\n c -= 1\n ans[i] = \'B\'\n else:\n if a == 0 and c == 0:\n print(\'No\')\n exit(0)\n if c == 0:\n a -= 1\n c += 1\n ans[i] = \'C\'\n else:\n a += 1\n c -= 1\n ans[i] = \'A\'\n\n print("Yes")\n for i in range(n):\n print(ans[i])\n exit(0)\n\nif s[0] == \'AB\' and a == 0 and b == 0:\n print("No")\n exit(0)\nif s[0] == \'BC\' and b == 0 and c == 0:\n print("No")\n exit(0)\nif s[0] == \'AC\' and a == 0 and c == 0:\n print("No")\n exit(0)\n\nprint("Yes")\nfor i in range(n):\n if s[i] == \'AB\':\n if a == 0:\n print(\'A\')\n a += 1\n b -= 1\n continue\n elif b == 0:\n print(\'B\')\n a -= 1\n b += 1\n continue\n elif s[i] == \'BC\':\n if b == 0:\n b += 1\n c -= 1\n print(\'B\')\n continue\n elif c == 0:\n b -= 1\n c += 1\n print(\'C\')\n continue\n else:\n if a == 0:\n a += 1\n c -= 1\n print(\'A\')\n continue\n elif c == 0:\n a -= 1\n c += 1\n print(\'C\')\n continue\n \n if a + b + c == 2 and i < n - 1 and s[i] != s[i + 1]:\n if s[i] == \'AB\' and a == 1 and b == 1:\n if s[i + 1] == \'AC\':\n a += 1\n b -= 1\n print(\'A\')\n else:\n a -= 1\n b += 1\n print(\'B\')\n elif s[i] == \'BC\' and b == 1 and c == 1:\n if s[i + 1] == \'AB\':\n a -= 1\n b += 1\n print(\'B\')\n else:\n a += 1\n b -= 1\n print(\'A\')\n elif s[i] == \'AC\' and a == 1 and c == 1:\n if s[i + 1] == \'AB\':\n a += 1\n b -= 1\n print(\'A\')\n else:\n a -= 1\n b += 1\n print(\'B\')\n \n if s[i] == \'AB\':\n if a < b:\n a += 1\n b -= 1\n print(\'A\')\n else:\n a -= 1\n b += 1\n print(\'B\')\n elif s[i] == \'BC\':\n if b < c:\n b += 1\n c -= 1\n print(\'B\')\n else:\n b -= 1\n c += 1\n print(\'C\')\n else:\n if a < c:\n a += 1\n c -= 1\n print(\'A\')\n else:\n a -= 1\n c += 1\n print(\'C\')\n', 'from collections import defaultdict\n\nn = int(input())\na = list(map(int, input().split()))\nap = defaultdict(int)\nfor i in range(n):\n ap[i - a[i]] += 1\n\nans = 0\nfor i in range(n):\n ans += ap[a[i] + i]\nprint(ans)']
['Runtime Error', 'Accepted']
['s549607071', 's885502322']
[9484.0, 61756.0]
[26.0, 251.0]
[3439, 215]
p02691
u623659526
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['import logging\n\nlogging.basicConfig(level=logging.INFO, format="%(message)s")\n\n\ndef main():\n N = int(input())\n A_1 = list(map(int, input().split()))\n B_l = [1 - A_1[0]]\n\n sum = 0\n \n for i in range(1, N):\n if A_1[i] in B_l:\n sum += 1\n\n B_l = list(map(lambda x: x+1, B_l))\n B_l.append(0 - A_1[i])\n\n \n print(sum)\n \nif __name__ == "__main__":\n main()\n', 'import logging\n\nlogging.basicConfig(level=logging.INFO, format="%(message)s")\n\n\ndef main():\n N = int(input())\n A_1 = list(map(int, input().split()))\n B_l = [1 - A_1[0]]\n\n sum = 0\n \n for i in range(1, N):\n if A_1[i] in B_l:\n sum += 1\n\n B_l = list(map(lambda x: x+1, B_l))\n B_l.append(2 - A_1[i])\n\n \n print(sum)\n \nif __name__ == "__main__":\n main()\n', 'import logging\n\nlogging.basicConfig(level=logging.INFO, format="%(message)s")\n\n\ndef main():\n N = int(input())\n A_1 = list(map(int, input().split()))\n B_l = [1 - A_1[0]]\n\n sum = 0\n \n for i in range(1, N):\n if A_1[i] in B_l:\n sum += 1\n\n B_l = list(map(lambda x: x+1, B_l))\n B_l.append(1 - A_1[i])\n\n \n print(sum)\n \nif __name__ == "__main__":\n main()\n', 'import logging\nimport collections\n\nlogging.basicConfig(level=logging.INFO, format="%(message)s")\n\n\ndef main():\n N = int(input())\n A_i = list(map(int, input().split()))\n \n Ai_plu_i = collections.Counter([i + 1 + A_i[i] for i in range(N)])\n ans = sum([Ai_plu_i.get(j + 1 - A_i[j], 0) for j in range(N)])\n \n print(ans)\n \nif __name__ == "__main__":\n main()\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s151487567', 's185555413', 's367093101', 's915365098']
[34912.0, 34572.0, 34668.0, 44060.0]
[2206.0, 2206.0, 2206.0, 183.0]
[447, 447, 447, 414]
p02691
u625729943
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['from collections import defaultdict\nenu = enumerate\ndef input(): return sys.stdin.readline()[:-1]\n\nN = int(input())\nA = list(map(int, input().split()))\n\ncnt = 0\nd = defaultdict(int)\nfor i, a in enu(A):\n l = (i+1) + a\n r = (i+1) - a\n cnt += d[r]\n d[l] += 1\n\nprint(cnt)', "#import numpy as np\nimport sys, math\nfrom itertools import permutations, combinations\nfrom collections import defaultdict, Counter, deque\nfrom math import factorial#, gcd\nfrom bisect import bisect_left \nsys.setrecursionlimit(10**7)\nenu = enumerate\nMOD = 10**9+7\ndef input(): return sys.stdin.readline()[:-1]\npl = lambda x: print(*x, sep='\\n')\n\nN = int(input())\nA = list(map(int, input().split()))\n\nd = defaultdict(int)\nres = 0\nfor i, a in enu(A):\n v1 = i+a\n v2 = i-a\n res += d[v2]\n d[v1] += 1\nprint(res)"]
['Runtime Error', 'Accepted']
['s243580662', 's522680980']
[9316.0, 61720.0]
[26.0, 245.0]
[279, 540]
p02691
u638456847
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['from itertools import combinations_with_replacement\nimport sys\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\n\ndef main():\n x = int(readline())\n\n ab = [i**5 for i in range(70)]\n\n C = combinations_with_replacement(ab, 2)\n for a, b in C:\n if a + b == x:\n print(int(pow(b, 0.2)), -int(pow(a, 0.2)))\n break\n \n if b - a == x:\n print(int(pow(b, 0.2)), int(pow(a, 0.2)))\n break\n\n\nif __name__ == "__main__":\n main()\n', 'from collections import Counter\nimport sys\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\n\ndef main():\n N = int(readline())\n A = [int(i) for i in readline().split()]\n\n B = []\n C = []\n for i, a in enumerate(A, start=1):\n B.append(i + a)\n C.append(i - a)\n\n b = Counter(B)\n c = Counter(C)\n\n ans = 0\n for k, v in b.items():\n if k in c:\n ans += v * c[k]\n \n print(ans)\n\n\nif __name__ == "__main__":\n main()\n']
['Wrong Answer', 'Accepted']
['s390778423', 's780814574']
[9472.0, 65172.0]
[23.0, 187.0]
[525, 505]
p02691
u641722141
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['N = int(input())\nA = list(map(int, input().split()))\n\nlst = [0] * N\n\nans = 0\nfor i in range(N):\n if i + 1 + A[i] < n: \n lst[i + A[i]] += 1\n if i + 1 - A[i] >= 1:\n ans += lst[i - A[i]]\n\nprint(ans)', 'N = int(input())\nA = list(map(int, input().split()))\n\nlst = [0] * N\n\nans = 0\nfor i in range(N):\n if i + 1 + A[i] < n: \n lst[i + A[i]] += 1\n if i + 1 - A[i] >= 1:\n ans += lst[i + 1 - A[i]]\n\nprint(ans)', '"""\n\n"""\n\nn = int(input())\nl = list(map(int, input().split()))\n\ncnt = 0\nfor i in range(len(l)):\n for j in range(i+1, len(l)):\n if abs(l[i] - l[j]) == i + j + 2:\n cnt += 1\nprint(cnt)', 'N = int(input())\nA = list(map(int, input().split()))\n\nlst = [0] * N\n\nans = 0\nfor i in range(N):\n if i + 1 + A[i] < N: \n lst[i + A[i]] += 1\n if i + 1 - A[i] >= 1:\n ans += lst[i - A[i]]\n\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s549709514', 's768694009', 's974986168', 's788401792']
[32264.0, 32300.0, 32220.0, 32300.0]
[66.0, 67.0, 2206.0, 167.0]
[261, 265, 202, 261]
p02691
u652656291
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['n = int(input())\nN = [i for i in range(n)]\nA = list(map(int,input().split()))\nL = [N[i]+A[i] for i in range(n)]\nans = 0\nfor i in range(n):\n for j in range(i+1,n):\n if L[i] == L[j]:\n ans += 1\nprint(ans)\n\n', "def main():\n n = int(input())\n A = list(map(int,input().split()))\n ans = 0\n for i in range(n):\n for j in range(i+1,n):\n if j-i == A[i] + A[j]:\n ans += 1\n print(ans)\n\nif __name__ == '__main__':\n main()", 'N = int(input())\nA = list(map(int, input().split()))\n\nX = dict()\nans = 0\nfor i in range(N):\n L = i + A[i]\n if L not in X:\n X[L] = 1\n else:\n X[L] += 1\n\nfor i in range(N):\n R = i - A[i]\n if R in X:\n ans += X[R]\n \nprint(ans)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s067024158', 's890782276', 's049651991']
[40196.0, 44240.0, 40344.0]
[2206.0, 2264.0, 165.0]
[212, 227, 265]
p02691
u659481093
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['n = int(input())\na = list(map(int, input().split()))\n\nadd = dict()\nsub = dict()\nfor i, ai in enumerate(a):\n if i+ai in add.keys():\n add[i+ai] += 1\n else:\n add[i+ai] = 1\n if i-ai in sub.keys():\n add[i-ai] += 1\n else:\n add[i-ai] = 1\n\ncnt = 0\nfor ak, av in add.items():\n if ak not in sub.keys(): continue\n cnt += av*sub[ak]\n\nprint(cnt)\n', 'n = int(input())\na = list(map(int, input().split()))\n\n\n\n\n\nans = 0\nadds = dict()\nfor j in range(n):\n sub = j - a[j]\n if sub in adds.keys():\n ans += adds[sub]\n\n add = j + a[j]\n if add in adds.keys():\n adds[add] += 1\n else:\n adds[add] = 1\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s512092595', 's546613856']
[61404.0, 40348.0]
[274.0, 194.0]
[379, 325]
p02691
u659712937
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['N=int(input())\n\nA=list(map(int,input().split()))\n#B=[]\n#C=[]\nD=[0]*10**9\nE=[0]*10**9\n\nans=0\n\nfor i in range(N):\n #B.append(A[i]+i+1)\n #C.append(-A[i]+i+1)\n D[A[i]+i+1]+=1\n E[-A[i]+i+1]+=1\n\nfor i in range(len(D)):\n #ans+=C.count(i)\n ans+=D[i]*E[i]\n\nprint(ans)', 'N=int(input())\n\nA=list(map(int,input().split()))\n#B=[]\n#C=[]\nD=[0]*10000000\nE=[0]*10000000\n\nans=0\n\nfor i in range(N):\n #B.append(A[i]+i+1)\n #C.append(-A[i]+i+1)\n D[A[i]+i+1]+=1\n E[-A[i]+i+1]+=1\n\nfor i in range(len(D)):\n #ans+=C.count(i)\n ans+=D[i]*E[i]\n\nprint(ans)', 'N=int(input())\n \nA=list(map(int,input().split()))\n#B=[]\n#C=[]\nD=[0]*1000000\nE=[0]*1000000\n \nans=0\n \nfor i in range(N):\n #B.append(A[i]+i+1)\n #C.append(-A[i]+i+1)\n D[2*A[i]+i]+=1\n E[i]+=1\n \nfor i in range(1000000):\n #ans+=C.count(i)\n ans+=D[i]*E[i]\n \nprint(ans)', 'N=int(input())\n\nA=list(map(int,input().split()))\n#B=[]\n#C=[]\nD=[0]*1000000000\nE=[0]*1000000000\n\nans=0\n\nfor i in range(N):\n #B.append(A[i]+i+1)\n #C.append(-A[i]+i+1)\n D[A[i]+i+1]+=1\n E[-A[i]+i+1]+=1\n\nfor i in range(len(D)):\n #ans+=C.count(i)\n ans+=D[i]*E[i]\n\nprint(ans)', 'N=int(input())\n \nA=list(map(int,input().split()))\n#B=[]\n#C=[]\nD=[0]*1000000\nE=[0]*1000000\n \nans=0\n \nfor i in range(N):\n if A[i]<500000:\n #B.append(A[i]+i+1)\n #C.append(-A[i]+i+1)\n #if -A[i]+i>=0:\n \tD[A[i]+i]+=1\n \tE[-A[i]+i]+=1\n #print(E[-A[i]+i],-A[i]+i)\n\nfor i in range(1000000):\n #ans+=C.count(i)\n ans+=D[i]*E[i]\n \nprint(ans)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s238289218', 's476890928', 's524349581', 's618510233', 's127140720']
[32308.0, 175980.0, 35492.0, 32260.0, 35608.0]
[69.0, 1979.0, 311.0, 65.0, 327.0]
[264, 270, 266, 274, 337]
p02691
u664373116
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['#n=int(input())\n#n,m=list(map(int,input().split()))\n#a=list(map(int,input().split()))\nimport math\nimport itertools\nfrom collections import defaultdict\nfrom collections import Counter\nimport numpy as np\n\nimport heapq\n\n\n#n,k=list(map(int,input().split()))\nn=int(input())\n#n=10**3\na=list(map(int,input().split()))\nc=defaultdict(int)\nfor i in range(n):\n ii=i+1\n c[ii+a[i]]+=1\n c[abs(ii-a[i])]+=1\nans=0\nfor each in c.keys():\n ans+=max(0,c[each]-1)\n\nprint(ans)', '#n=int(input())\n#n,m=list(map(int,input().split()))\n#a=list(map(int,input().split()))\nimport math\nimport itertools\nfrom collections import defaultdict\nfrom collections import Counter\nimport numpy as np\n\nimport heapq\ndef combinations_count(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\n\nn=int(input())\n#n=10**5\na=list(map(int,input().split()))\n\nl=defaultdict(int)\nr=defaultdict(int)\nfor i in range(n):\n ii=i+1\n l[ii+a[i]]+=1\n r[(ii-a[i])]+=1\n#print(l)\n#print(r)\nans=0\nfor each in l.keys():\n if each in r.keys():\n ans+=l[each]*r[each]\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s637081103', 's814701479']
[58212.0, 71900.0]
[404.0, 340.0]
[466, 642]
p02691
u665038048
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['from collections import defaultdict\n\n\nn = int(input())\na = list(map(int, input().split()))\n\nmemo = defaultdict(int)\nans = 0\nfor i, x in enumerate(a, 1):\n print(memo)\n ans += memo[i - x]\n memo[x + i] += 1\n\nprint(ans)\n', 'from collections import defaultdict\n\n\nn = int(input())\na = list(map(int, input().split()))\n\nmemo = defaultdict(int)\nans = 0\nfor i, x in enumerate(a, 1):\n ans += memo[i - x]\n memo[x + i] += 1\n\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s860251834', 's501289293']
[147116.0, 61508.0]
[2296.0, 236.0]
[225, 209]
p02691
u672542358
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['n,m=map(int,input().split())\nk=0\nif n%2==1:\n for i in range(m):\n print(i+1,end=" ")\n print(n-i)\nelse:\n for i in range((n+2)//4-1):\n if k>=m:\n break\n print(i+1,end=" ")\n print(n-i)\n k+=1\n for i in range((n+2)//4-1,n//2):\n if k>=m:\n break\n print(i+1,end=" ")\n print(n-i-1)\n k+=1', 'n=int(input())\na=list(map(int,input().split()))\nl1=[0]*n\nl2=[0]*n\nk=0\nans=0\nfor i in a:\n if k+i<n:\n l1[k+i]+=1\n if k-i>=0:\n l2[k-i]+=1\n k+=1\nfor i in range(n):\n ans+=l1[i]*l2[i]\nprint(ans)']
['Runtime Error', 'Accepted']
['s487779094', 's531188286']
[9196.0, 32236.0]
[24.0, 177.0]
[319, 198]
p02691
u686036872
2,000
1,048,576
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens. There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i. According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction. * The absolute difference of their attendee numbers is equal to the sum of their heights. There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above? P.S.: We cannot let you know the secret.
['import collections\n\nN = int(input())\nA = list(map(int, input().split()))\n\nL = [i+j for i, j in enumerate(A)]\nR = [i-j for i, j in enumerate(A)]\n\nl = collections.Counter(L)\nr = collections.Counter(L)\n\nfor i in l.keys():\n ans += l[i]*r[i]\n\nprint(ans)', 'import collections\n\nN = int(input())\nA = list(map(int, input().split()))\n\nL = [i+j for i, j in enumerate(A)]\nR = [i-j for i, j in enumerate(A)]\n\nl = collections.Counter(L)\nr = collections.Counter(R)\n\nfor i in l.keys():\n ans += l[i]*r[i]\n\nprint(ans)', 'import collections\n\nN = int(input())\nA = list(map(int, input().split()))\n\nL = [i+j for i, j in enumerate(A)]\nR = [i-j for i, j in enumerate(A)]\n\nl = collections.Counter(L)\nr = collections.Counter(R)\n\nans = 0\nfor i in l.keys():\n ans += l[i]*r[i]\n\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s577284703', 's864508224', 's241629226']
[63664.0, 63348.0, 63444.0]
[181.0, 168.0, 231.0]
[251, 251, 259]