TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
import collections
N = int(input())
A = list(map(int,input().split()))

#index,h
pp =[]
pm = []
all_set = set()
for i in range(N):

    pp.append(i + A[i])
    pm.append( i - A[i])

count = 0
c = collections.Counter(pp)
#print(c)
for i in range(N):
    count += c[pm[i]] 
    print(c[pm[i]])

    #count += pp.count(pm[i])
    #count += pm.count(pp[i])

print(count)

import collections
N = int(input())
A = list(map(int,input().split()))

#index,h
pp =[]
pm = []
all_set = set()
for i in range(N):

    pp.append(i + A[i])
    pm.append( i - A[i])

count = 0
c = collections.Counter(pp)
print(c)
for i in range(N):
    count += c[pm[i]] 
    print(c[pm[i]])

    #count += pp.count(pm[i])
    #count += pm.count(pp[i])

print(count)

import collections
N = int(input())
A = list(map(int,input().split()))

#index,h
pp =[]
pm = []
all_set = set()
for i in range(N):

    pp.append(i + A[i])
    pm.append( i - A[i])

count = 0
c = collections.Counter(pp)
#print(c)
for i in range(N):
    count += c[pm[i]] 
    #print(c[pm[i]])

    #count += pp.count(pm[i])
    #count += pm.count(pp[i])

print(count)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N=int(input())
A=list(map(int,input().split()))
a=[]
B=[]
ans=0
for i in range(1,N):
    b=A[i]+A[0]
    a.append(b-i)
    B.append(A[i]-A[0])
ans=a.counter(0)
for i in range(N):
    b=B[i]
    a1=a[i:].copy()
    a1=a1-[b-i-1]
    ans+=a1.counter(0)
print(ans)

import bisect
N=int(input())
A=list(map(int,input().split()))
L=[]
R=[]
ans=0
for i in range(N):
    L.append(i+1+A[i])
    R.append(i+1-A[i])
L.sort()
R.sort()
for i in L:
    l=bisect.bisect_left(R,i)
    r=bisect.bisect_right(R,i)
    ans=ans+r-l
print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
arr = map(int,input().split())
_sum = []
_del = []
for i in range(N):
  _sum.append(arr[i]+i+1)
  _del.append(i+1-arr[i])

N = int(input())
arr = list(map(int,input().split()))
cnt_arr = [0]*N
ans = 0
for i in range(N):
  if arr[i]+i+1<N:
    cnt_arr[arr[i]+i+1] += 1
  if i+1-arr[i]>0:
    ans += cnt_arr[i+1-arr[i]]

print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from collections import *
n = int(input())
a = list(map(int, input().split()))
c = Counter()
r = 0
for i in range(n):
    r += c[a[i]+i] 
    c[i-a[i]] += 1
print(r)

from collections import *
n = int(input())
a = list(map(int, input().split()))
c = Counter(i-a[i] for i in range(n))
r = 0
for i in range(n):
    c[i-a[i]] -= 1
    r += c[a[i]+i] 
print(r)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
# -*- coding: utf-8 -*-

N = int(input())
A = list(map(int, input().split()))
count=0
L = [0]*N
R = [0]*N
hash_L=[0]*10000000000
hash_R=[0]*10000000000
for i in range(N):
    L[i]=A[i]+i
    hash_L[L[i]]=L[i]
    R[i]=-A[i]+i
    hash_R[R[i]]=R[i]

for i in range(2*N):
    if hash_L[i]==hash_R[i]:
        count=count+1

print("{}".format(count))

# -*- coding: utf-8 -*-

N = int(input())
A = list(map(int, input().split()))
count=0

for i in range(N):
    for j in range(N-i-A[i]):
        k=i+j+A[i]
        if A[i]+A[k]==abs(i-k):
            count = count+1
            print("{} {}".format(i+1,k+1))



print("{}".format(count))


# -*- coding: utf-8 -*-

N = int(input())
A = list(map(int, input().split()))
count=0

for i in range(N):
    m=max[i:]
    for j in range(N-i-A[i]):
        k=i+j+A[i]
        
        if A[i]+A[k]==k-i:
            count = count+1
            #print("{} {}".format(i+1,k+1))
        if A[i]+m+i<k:
            break


print("{}".format(count))


# -*- coding: utf-8 -*-

N = int(input())
A = list(map(int, input().split()))
count=0

for i in range(N):
    for j in range(N-i):
        k=i+j
        if A[i]+A[k]==abs(i-k):
            count = count+1
            print("{} {}".format(i+1,k+1))



print("{}".format(count))


# -*- coding: utf-8 -*-

N = int(input())
A = list(map(int, input().split()))
count=0
L = [0]*N
R = [0]*N
N2=2*N
hash_L=[0]*N2
hash_R=[0]*N2

sheet_L=[0]*N2
sheet_R=[0]*N2
for i in range(N):
    L[i]=A[i]+i+1
    if L[i]<N2:
        if sheet_L[L[i]]==0:
            hash_L[L[i]]=L[i]
            sheet_L[L[i]]=1
        else:
            sheet_L[L[i]]=sheet_L[L[i]]+1

    R[i]=-A[i]+i+1
    if R[i]>0:
        if sheet_R[R[i]]==0:
            hash_R[R[i]]=R[i]
            sheet_R[R[i]]=1
        else:
            sheet_R[R[i]]=sheet_R[R[i]]+1


for i in range(2*N):
    if not hash_L[i]==0:
        if hash_L[i]==hash_R[i]:
            count=count+sheet_L[i]*sheet_R[i]
#print("{}".format(hash_L))
#print("{}".format(hash_R))
print("{}".format(count))


Verdicts: Runtime Error

Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import defaultdict

N = int(input())	



L = defaultdict(lambda: 0)
R = defaultdict(lambda: 0)
for i, val in enumerate(map(int, input().split())):
  L[i - val] += 1	
  R[i + val] += 1	
  
print(L)
print("===")
print(R)

cnt = 0
for key, val in L.items():
  if key > 0:
    cnt += L[key] * R[key]
    
print(cnt)

from collections import defaultdict
 
N = int(input())	
 


L = defaultdict(lambda: 0)
R = defaultdict(lambda: 0)
for i, val in enumerate(map(int, input().split())):
  L[i - val] += 1	
  R[i + val] += 1	
  
cnt = 0
for key, val in L.items():
  if key > 0:
    cnt += L[key] * R[key]
    
print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))

max1 = max(A)
A_ = A.copy()
A_.remove(max1)
max2 = max(A_)
ln = max1 + max2
ret = 0
for i in range(len(A)-1):
    for j in range(i+1, i+ln + 1):
        if A[j] + A[i] == j - i:
            ret += 1
print(ret)

N = int(input())
A_ = list(map(int, input().split()))
A = list()
for i in range(len(A_)):
    if A_[i] < N - 1:
        A.append([i + 1, A_[i]])
ret = 0
for i in range(len(A)-1, -1, -1):
    ind, val = A[i][0], A[i][1]
    B = [a for a in A if a[1] < N - 1 - val]
    for b in B:
        if abs(b[0] - ind) == val + b[1]:
            ret += 1
print(ret)

N = int(input())
A_ = list(map(int, input().split()))
A = list()
for i in range(len(A_)):
    if A_[i] < N - 1:
        A.append([i + 1, A_[i]])
ret = 0
for i in range(len(A)-1, -1, -1):
    ind, val = A[i][0], A[i][1]
    B = [a for a in A if a[1] < N - 1 - val]
    for b in B:
        if abs(b[0] - ind) == val + b[1]:
            ret += 1
return ret

N = int(input())
A = list(map(int, input().split()))
L1 = list()
D2 = dict()
ret = 0
for i in range(len(A)):
    num1 = i + 1 - A[i]
    num2 = i + 1 + A[i]
    L1.append(num1)
    if num2 not in D2:
        D2[num2] = 1
    else:
        D2[num2] += 1
ret = 0
retlist = dict()
for l in L1:
    if l in D2.keys():
        ret += D2[l]
print(ret)

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):


import bisect
N = int(input())
A = list(map(int, input().split()))
X = [A[i]+i for i in range(N)]
Y = [j - A[j] for j in range(N)]
ans = 0
X.sort()
for i in range(N):
    ans += bisect.bisect_left(Y,X[i]) - bisect.bisect_right(Y,X[i])
print(ans)






import bisect
N = int(input())
A = list(map(int, input().split()))
X = [A[i]+i for i in range(N)]
Y = [j - A[j] for j in range(N)]
ans = 0
Y.sort()
for i in range(N):
    ans += bisect.bisect_right(Y,X[i]) - bisect.bisect_left(Y,X[i])
print(ans)




Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):


def resolve():
    X= int(input())
    nums = dict()
    for A in range(10**4):
        nums[A**5] = A
        nums[-A**5] = -A        

        if A**5 - X in nums:
            print(A,nums[A**5-X])
            
    



    

if __name__ == "__main__":
    resolve()
    #unittest.main()

def resolve():
    N= int(input())
    A = list(map(int,input().split()))

    API = dict()
    ans = 0
    for i,a in enumerate(A):
        api = a+i+1
        ami = i+1-a

        if ami in API:
            ans += API[ami]

        if not api in API:
            API[api]=0
        API[api]+=1
        
    print(ans)




if __name__ == "__main__":
    resolve()

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import itertools
n = int(input())
a = list(map(int, input().split()))
idList = [i for i in range(1, n+1)]
'''
com = list(itertools.combinations(idList, 2))

num = len(com)
'''
ans = 0

for i in range(n):
    for j in range(i + 1, n):
        key = j - i
        heiA = a[i - 1]
        heiB = a[j - 1]
        height = heiA + heiB
        if (height == key):
            ans += 1

print(ans)



from collections import Counter
N = int(input())
A = list(map(int, input().split()))

minus = [0] * N
plus = [0] * N

for i in range(N):
    minus[i] = (i + 1) - A[i]
    plus[i] = (i + 1) + A[i]

count = Counter(minus)
most = count.most_common()
num = len(most)

countPP = Counter(plus)
#mostPP = countPP.most_common()
#check = mostPP[:][0]
ans = 0

for i in range(num):
    elm = most[i]
    fir = elm[0]
    sec = elm[1]
    # if (fir in check):

    aa = countPP[fir]
    #    print(aa)
    ans += aa * sec

    # try countPP[tar]:

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

#cnt = 0

#  for j in range(i, N):

#      cnt += 1

Ap = [A[i]+i for i in range(len(A))]
Am = [i-A[i] for i in range(len(A))]

S = set(Ap) & set(Am)

Cp = Counter(Ap)
Cm = Counter(Am)

cnt = 0
for i in S:
  cnt += Cp[i]*Cm[i]

from collections import Counter

N = int(input())
A = list(map(int, input().split()))

#cnt = 0

#  for j in range(i, N):

#      cnt += 1

Ap = [A[i]+i for i in range(len(A))]
Am = [i-A[i] for i in range(len(A))]

S = set(Ap) & set(Am)

Cp = Counter(Ap)
Cm = Counter(Am)

cnt = 0
for i in S:
  cnt += Cp[i]*Cm[i]
  
print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
arr = list(map(int, input().split()))
memo = [0]*(max(arr)*2)
ans = 0
for i in range(N):
    if (i+1)-arr[i] >= 0:
        ans += memo[(i+1)-arr[i]]
    if (i+1)+arr[i] > 0:
        memo[(i+1)+arr[i]] += 1
print(ans)

N = int(input())
arr = list(map(int, input().split()))
memo = [0]*((10**9)*2)
ans = 0
for i in range(N):
    if (i+1)-arr[i] >= 0:
        ans += memo[(i+1)-arr[i]]
    if (i+1)+arr[i] > 0:
        memo[(i+1)+arr[i]] += 1
print(ans)

from collections import defaultdict
d = defaultdict(int)
N = int(input())
arr = list(map(int, input().split()))
ans = 0
for i in range(N):
    ans += d[(i+1)-arr[i]]
    d[(i+1)+arr[i]] += 1
print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N=int(input())
L=list(map(int,input().split()))
L_i=[i+1 for i in range(len(L))]

cnt=0
for i in range(N):
    P_L= [m+L[i] for m in L[i:]]
    P_L_i = [x for x in range(N-i)]
    print(P_L)
    print(P_L_i)
    cnt = cnt + sum([w==z for (w, z) in zip(P_L,P_L_i)])
    
print(cnt)

def main():
    N=int(input())
    L=list(map(int,input().split()))
    L_i,L_j=[],[]
    L_memo = [0]*N
    cnt=0
    for i, j in enumerate(L):
        if i+j<N:
            L_memo[i+j]+=1
        if i-j>0:
            cnt+=L_memo[i-j]        
    print(cnt)
main()

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
l = list(map(int,input().split()))

ai = []
aj = []
ans = 0
aiajmin = -9999999


for i in range(n):
    ai.append(i+l[i])

for j in range(n):
    aj.append(j-l[j])

#print(ai)
#print(aj)
    
aiajmin = min(max(ai),max(aj))

for x in range(n):
    if(ai[x] <= aiajmin):
        ans = ans + aj.count(ai[x])
    else:
        break
    
print(ans)

n = int(input())
l = list(map(int,input().split()))

max = max(l) * 2

ans = 0

for i in range(n):
    j = i + 1

    while(j < n and j <= i+max):

        if abs(j- i) == l[i]+l[j]:
            ans = ans + 1
            print(abs(j-i),l[i]+l[j],i,j)
        j = j + 1
print(ans)

n = int(input())
l = list(map(int,input().split()))

a=[]
b={}
ans=0

for i in range(n):
    a.append(i+l[i])
    b[i-l[i]] = b.get(i-l[i],0) + 1

for av in a:
    ans = ans + b.get(av,0)

print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N=int(input())
A=[i+1 for i in range(N)]

B=[0]*N
for i in range(N):
    if i-A[i]>0:
        B.append(i-A[i])

ans=0
for i in range(N):
    ans+=B.count(i+A[i])
print(ans)

N=int(input())
A=list(map(int,input().split()))

d={}
for i in range(N):
    if i-A[i]>0:
        if str(i-A[i]) in d:
            d[str(i-A[i])]+=1
        else:
            d[str(i-A[i])]=1

ans=0
for j in range(N):
    if str(j+A[j]) in d:
        ans+=d[str(j+A[j])]
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
L, R = [0] * n, [0] * n
i = 0
for ipt in input().split():
    L[i] = i + ipt 
    R[i] = i - ipt
    i += 1
def make_dic(L):
    L_set = set(L)
    return dict([(i, L.count(i)) for i in L_set])
L_dic, R_dic = make_dic(L), make_dic(R)
cnt = 0
for Lk, Lv in L_dic.items():
    try:
        cnt += R_dic[Lk] * Lv
    except KeyError:
        pass
print(cnt)

from collections import defaultdict
n = int(input())
L_dict, R_dict = defaultdict(int), defaultdict(int)
i = 0
for ipt in input().split():
    L_dict[i + int(ipt)] += 1
    R_dict[i - int(ipt)] += 1
    i += 1
cnt = 0
for Lk, Lv in L_dict.items():
        cnt += R_dict[Lk] * Lv
print(cnt)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import bisect
N = int(input())
A = [0]
A += list(map(int, input().split()))
cnt = 0
L = [- 10 ** 6]
R = [- 10 ** 6]

for i in range(1, N + 1):
    L.append(i + A[i])
    R.append(i - A[i])
L.sort()
print(L)
print(R)
for j in range(1, N + 1):
    x = bisect.bisect_left(L, R[j])
    while R[j] == L[x]:
        cnt += 1
        x += 1
print(cnt)

import collections
N = int(input())
A = [0]
A += list(map(int, input().split()))
cnt = 0
L = [- 10 ** 6]
R = [- 10 ** 6]

for i in range(1, N + 1):
    L.append(i + A[i])
    R.append(i - A[i])
c = collections.Counter(L)

for j in range(1, N + 1):
    cnt += c.get(R[j], 0)
print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(N-1):
  for j in range(i+1, N+1):
    number = abs(i-j)
    tall = A[i]+A[j]
    if number == tall:
      ans += 1
      
print(ans)

from collections import defaultdict
 
n = int(input())
a = list(map(int, input().split()))
ap = defaultdict(int)
for i in range(n):
    ap[i - a[i]] += 1

ans= 0
for i in range(n):
    ans += ap[a[i] + i]
print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import itertools
N = int(input())
A = input().split()
Ai = [int(s) for s in A]
count = 0
for x, y in itertools.combinations(range(N), 2):
        if abs(x-y)+100 == Ai[x]+Ai[y]:
            count += 1
print(count)

import itertools
N = int(input())
A = input().split()
count = 0
for x, y in itertools.combinations(range(N), 2):
        if abs(x-y)+100 == int(A[x])+int(A[y]):
            count += 1
print(count)

from collections import defaultdict
dic = defaultdict(int)

N = int(input())
A = list(map(int, input().split()))

for i, a in enumerate(A):
    dic[i + a] += 1

counter = 0
for i, a in enumerate(A):
    counter += dic[i-a]

print(counter)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import collections
import sys
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    A = list(map(int, readline().rstrip().split()))
    ans = 0
    c = collections.Counter()

    for i in range(n):
        ans += c[i + 1 - A[i]]
        c[i + 1 + A[i]] += 1

    print(c)

    print(ans)


if __name__ == '__main__':
    main()


import collections
import sys
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    A = list(map(int, readline().rstrip().split()))
    ans = 0
    c = collections.Counter()

    for i in range(n):
        ans += c[i + 1 - A[i]]
        c[i + 1 + A[i]] += 1

    print(ans)


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))
dic = {}
for i in range(n-1):
  idx = i + a[i] + 1
  if idx in dic:
    dic[idx] += 1
  else:
    dic[idx] = 1
ans = 0
j = n-1
while j > 0:
  target = j + 1 - a[j]
  idx = j + 1 + a[j]
  if target in dic:
    ans += dic[target]
  dic[idx] -= 1
  j -= 1
print(ans)

n = int(input())
a = list(map(int, input().split()))
dic = {}
for i in range(n-1):
  idx = i + a[i] + 1
  if idx in dic:
    dic[idx] += 1
  else:
    dic[idx] = 1
ans = 0
j = n-1
while j > 0:
  target = j + 1 - a[j]
  idx = j + 1 + a[j]
  if target in dic:
    ans += dic[target]
  if j < n-1:
  	dic[idx] -= 1
  j -= 1
print(ans)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import numpy as np

def abc166_e():
    N = int(readline())
    A = np.array(readline().split(), dtype=np.int64)

    
    idx = np.arange(1, N+1, dtype=np.int64) - np.arange(1, N+1, dtype=np.int64).reshape(-1, 1)
    np.absolute(idx, out=idx)
    
    valsum = A + A.reshape(-1, 1)

    
    
    diff = idx - valsum
    ans = N*N - np.count_nonzero(diff)
    ans //= 2  
    print(ans)

abc166_e()



def abc166_e():
    _ = int(input())
    A = list(map(int, input().split()))
    ans = 0
    from collections import defaultdict
    d = defaultdict(int)
    for i, x in enumerate(A, 1):
        ans += d[i - x]
        d[x + i] += 1
    print(ans)

abc166_e()

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))

check = {}
ans = 0

for i in range(N):
    x = i - A[i]
    y = A[i] + i
    ans += check.get(x, 0)
    check.setdefault(y, 0)
    check[y] += 1

print(ans)
print(check)

N = int(input())
A = list(map(int, input().split()))

check = {}
ans = 0

for i in range(N):
    x = i - A[i]
    y = A[i] + i
    ans += check.get(x, 0)
    check.setdefault(y, 0)
    check[y] += 1

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import collections

N = int(input())
A = list(map(int, input().split()))

L = [i + A[i] for i in range(N)]
R = [i - A[i] for i in range(N)]

countL = collections.Counter(L)

countR = collections.Counter(R)


print([countL[n] * countR[n] for n in countL.keys()])

import collections

N = int(input())
A = list(map(int, input().split()))

L = [i + A[i] for i in range(N)]
R = [i - A[i] for i in range(N)]

countL = collections.Counter(L)

countR = collections.Counter(R)


print(sum([countL[n] * countR[n] for n in countL.keys()]))

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n=int(input())
A=list(map(int,input().split()))
L=[]
R=[]
for i in range(n):
  L.append(i+A[i])
  R.append(i-A[i])
from collections import Counter
zisyo=R.Counter(R)
ans=0
for i in L:
  ans=ans+get(i,0)
print(ans)
  


n=int(input())
A=list(map(int,input().split()))
L=[]
R=[]
for i in range(n):
  L.append(i+A[i])
  R.append(i-A[i])
from collections import Counter
zisyo=Counter(R)
ans=0
for i in L:
  ans=ans+zisyo.get(i,0)
print(ans)
  

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
#!/usr/bin/env python3
n, m = map(int, input().split())
h = list(map(int, input().split()))
not_good = []
for i in range(m):
    a, b = map(int, input().split())
    if h[a - 1] > h[b - 1]:  
        not_good.append(b)
    elif h[a - 1] == h[b - 1]:
        not_good.append(a)
        not_good.append(b)
    else:
        not_good.append(a)
ans = 0
not_good = list(set(not_good))
not_good.sort()
# print(not_good)
idx = 0
for i in range(1, n + 1):
    if i < not_good[idx]:
        ans += 1
        # print(i, end=" ")
    elif i == not_good[idx]:
        idx += 1
        if idx == len(not_good):
            ans += n - i
            break
    else:
        pass
print(ans)


#!/usr/bin/env python3
import bisect

n = int(input())
a = list(map(int, input().split()))


b = [a[i] - (1 + i) for i in range(0, n)]
b, idx = zip(*sorted(zip(b, range(1, n + 1))))
# print(b)
ans = 0
for i in range(n):
    
    r = bisect.bisect_right(b, -b[i] - 2 * idx[i])
    l = bisect.bisect_left(b, -b[i] - 2 * idx[i])
    ans += r - l
    # if r - l != 0:
    # print(i, r, l, -b[i] - 2 * idx[i])
print(ans)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
ef main():
    from collections import Counter
    n = int(input())
    As = list(map(int,input().split(" ")))
    
    cnts = Counter()
    dp = [0]*n
    for i in range(1,n):
        dp[i] =dp[i-1] + cnts.get(i-As[i],0)
        cnts[As[i]+i]+=1
    print(dp[n-1])
main()

def main():
    from collections import Counter
    n = int(input())
    As = list(map(int,input().split(" ")))
    
    cnts = Counter()
    dp = [0]*n
    cnts[As[0]+1]+=1
    for i in range(1,n):
        dp[i] =dp[i-1] + cnts.get(i+1-As[i],0)
        cnts[As[i]+i+1]+=1
    print(dp[n-1])
main()

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N=int(input())
Agents=list(map(int,input().split()))


##Miss 1
# from itertools import combinations



# cnt=0

#     if Agents[i[0]] + Agents[i[1]] == abs(i[0] - i[1]):
#         print(i[0],i[1])
#         cnt+=1

# print(cnt)

# Miss 2

#     k=Agents[i]-(i+1)
#     if k<i:
#         k=i+1
#     for j in range(k,N):
#         if Agents[i]+Agents[j]==abs(i-j):
#             # print(i,j,Agents[i],Agents[j])
#             cnt+=1


L={}
for i in range(N):
    L['{}'.format(i+1)]=i+1 + Agents[i]
R={}
for j in range(N):
    R['{}'.format(j+1)]=j+1 - Agents[j]

print(L)
print(R)

cnt=0

for key,value in L.items():
    for key2,value2 in R.items():
        if int(key) < int(key2) and value == value2:
            cnt+=1


print(cnt)


N=int(input())
Agents=list(map(int,input().split()))


##Miss 1
# from itertools import combinations



# cnt=0

#     if Agents[i[0]] + Agents[i[1]] == abs(i[0] - i[1]):
#         print(i[0],i[1])
#         cnt+=1

# print(cnt)

# Miss 2

#     k=Agents[i]-(i+1)
#     if k<i:
#         k=i+1
#     for j in range(k,N):
#         if Agents[i]+Agents[j]==abs(i-j):
#             # print(i,j,Agents[i],Agents[j])
#             cnt+=1


L={}
for i in range(N):
    s = i+1 + Agents[i] 
    if s in L:
        L[s]+=1
    else:
        L[s]=1

R={}
for j in range(N):
    s= j+1 - Agents[j]
    if s in R:
        R[s]+=1
    else:
        R[s]=1
cnt=0

for key,value in L.items():
    cnt += R.get(key,0) * value
# for key,value in L.items():
#     for key2,value2 in R.items():
#         if int(key) < int(key2) and value == value2:
#             cnt+=1


print(cnt)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import collections
n=int(input())

A=list(map(int,input().split())))
B = [(A[0] + A[i] -i)   for i in range(n)]
b = collections.Counter(B)
ans =0
cnt = 0
for i in range(len(B)):
    
    ans += b[cnt]
    if i != 0:
        cnt += (B[i] - B[i-1] -1)

print(ans)

import collections
n=int(input())
A=list(map(int,input().split()))
B = [ i-A[i]    for i in range(n)]
C = [ i+A[i]    for i in range(n)]
b = collections.Counter(B)
c = collections.Counter(C)
ans =0
cnt = 0
 
for i in b.keys():
  ans +=c[i]*b[i]
     
print(ans) 

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import numpy as np
import sys
input = sys.stdin.readline


N = int(input())

a = list(map(int, input().split()))
A = np.array([a for i in range(N)])
B = np.array([[a[i]] * N for i in range(N)])
C = A + B
d = [i for i in range(N)]
D = np.array([d for i in range(N)])
E = np.array([[i] * N for i in range(N)])

#print(D)
#print(E)
ind = D - E
#print(ind)
ans = C - ind
#print(ans)

print(cnt)

import collections

N = int(input())
A = list(map(int, input().split()))
B = {}
C = {}

for i in range(N):
    if i-A[i] in B:
        B[i-A[i]] += 1
    else:
        B[i-A[i]] = 1
    if i+A[i] in C:
        C[i+A[i]] += 1
    else:
        C[i+A[i]] = 1

#print(C)
ans = 0
for i in B:
    #print(i) i=Key
    if i in C:
        ans += B[i]*C[i]
print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import math
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def pop2(li):
	c=1
	i=li.pop(0)
	while 1:
		j=li.pop(0)
		if j==i:
			c+=1
		else:
			break
	return i,c,[j]+li

n = readInt()
a = readInts()

li = []
ri = []

for i in range(n):
	li.append(i+a[i])
	ri.append(i-a[i])

li.sort()
ri.sort()

res = 0

tar = []#list(set(li)&set(ri))

for i in tar:
	res+=li.count(i)*ri.count(i)

print(res)

import math
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def pop2(li):
	c=1
	i=li.pop(0)
	while 1:
		j=li.pop(0)
		if j==i:
			c+=1
		else:
			break
	return i,c,[j]+li

n = readInt()
a = readInts()

li = []
ri = []

d1 = defaultdict(int)
d2 = defaultdict(int)

for i in range(n):
	d1[i+a[i]]+=1
	d2[i-a[i]]+=1

ans = 0

for key in d1:
	ans+=d1[key]*d2[key]

print(ans)

Verdicts: Wrong Answer

Accepted