Problem:


Score: 500 points

Problem Statement

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.

Constraints

All values in input are integers.

2 \leq N \leq 2 \times 10^5

1 \leq A_i \leq 10^9\ (1 \leq i \leq N)

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 \dots A_N

Output

Print the number of pairs satisfying the condition.

Sample Input 1

6
2 3 3 1 3 1

Sample Output 1

3

A_1 + A_4 = 3, so the pair of Attendee 1 and 4 satisfy the condition.

A_2 + A_6 = 4, so the pair of Attendee 2 and 6 satisfy the condition.

A_4 + A_6 = 2, so the pair of Attendee 4 and 6 satisfy the condition.

No other pair satisfies the condition, so you should print 3.

Sample Input 2

6
5 2 4 2 8 8

Sample Output 2

0

No pair satisfies the condition, so you should print 0.

Sample Input 3

32
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

Sample Output 3

22



Sample input:
6
2 3 3 1 3 1


Sample output:
3

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(1000000)




def main():
    n = int(input())
    a_dic = {}
    i = 0
    count = 0
    for a in map(int, input().split()):
        a_dic[i] = a
        if i - 2 >= a:
            for j in range(i - a):
                if i - j == a + a_dic[j]:
                    count += 1
        i += 1

    # for i in range(n):
    #     ai = a_dic[i]
    #     for j in range(i+1, n):
    #         # combi = (i,j)
    #         if j - i == ai + a_dic[j]:
    #             count += 1
    print(count)



main()

Submission status: Wrong Answer

Solution code:
num=int(input())
a=input().split(" ")
for i in range(num):
  a[i]=int(a[i])
count=0
for i in range(num-1):
  for j in range(i+1,num):
    id=j-i
    x=abs(a[j]-a[i])
    if x==id:
      count+=1
print(count)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
S = [0]*N
D = [0]*N

for i in range(N):
    if A[i]+i < N:
        S[A[i]+i] += 1
    if i - A[i] > 0:
        D[i - A[i]] += 1
ans = 0
print(S,D)
for l in range(N):
    ans += S[l]*D[l]
    

print(ans)

Submission status: Wrong Answer

Solution code:
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)
'''
for i in range(num):
    aa = com[i]
    # print(aa)
    idA = aa[0]
    idB = aa[1]
    dif = abs(idA - idB)
    indexA = idList.index(idA)
    indexB = idList.index(idB)

    height = a[indexA] + a[indexB]

    if (height == dif):
        ans += 1

print(ans)
'''

Submission status: Wrong Answer

Solution code:
n=int(input())

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

needsearch=[]

for i in range(n):
    a[i]-=(i+1)
    needsearch.append(-2*(i+1)-a[i])

counter=[0]*(2*(10**5))

for i in range(n):
    if 0<a[i]+10**5<2*(10**5):
        counter[a[i]+10**5]+=1

ans = 0
for i in range(len(needsearch)):
    if 0<needsearch[i]+10**5<2*(10**5):
        ans += counter[needsearch[i]+10**5]
    if 0<a[i]+10**5<2*(10**5):
        counter[a[i]+10**5]-=1

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
count = 0

for i in range(1, n-1):
  ans_list = []
  for j in range(n-i):
    ans_list.append(a[j]+a[j+i])
  count += ans_list.count(i)
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
a_l = list(map(int,input().split()))
ia = list(enumerate(a_l))
del_l = []
for j in range(n):
    if ia[j][1] > n:
        del_l.append(j)

for j in del_l[::-1]:
    del ia[j]
        
count = 0
for i1, a1 in ia[:-1]:
    for i2, a2 in ia[i1+a1+1:n]:
        if (i2-i1) == (a2+a1):
            count += 1

print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = 0
l = [0]*(10**8+10)
for i in range(1,len(A)):
  x = i-A[i]
  if x<0:
    continue
  else:
    l[x]+=1
if A[0]<=10**8:
  ans+=l[A[0]]
for i in range(1,N):
  x = i+A[i]
  if x<0:
    continue
  if x>10**8:
    continue
  
  l[i-A[i]]-=1
  ans+=l[x]
  
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(100):
    for j in range(i+1,N):
        if A[i]+A[j] == j-i:
            ans += 1
for i in range(100,N,16):
    for j in range(i+1,N):
        if A[i]+A[j] == j-i:
            ans += 1
for i in range(100,N,37):
    for j in range(i+1,N):
        if A[i]+A[j] == j-i:
            ans += 1
for i in range(100,N,41):
    for j in range(i+1,N):
        if A[i]+A[j] == j-i:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = 0
l = [0]*(10**6+10)
for i in range(1,len(A)):
  x = i-A[i]
  if x<0:
    continue
  else:
    l[x]+=1
if A[0]<=10**6:
  ans+=l[A[0]]
for i in range(1,N):
  x = i+A[i]
  if x<0:
    continue
  if x>10**6:
    continue
  
  l[i-A[i]]-=1
  ans+=l[x]
  
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
box = [[0,0] for i in range(n)]

for i in range(n):
    num = i + 1
    if 0 < num - a[i] < n:
        box[a[i]-num][0] += 1
    if 0 < a[i]+num < n:
        box[a[i]-num][1] += 1
ans = 0
for i in range(n):
    ans += box[i][0] * box[i][1]
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(100):
    for j in range(i+1,N):
        if A[i]+A[j] == j-i:
            ans += 1
for i in range(100,N,16):
    for j in range(i+1,N):
        if A[i]+A[j] == j-i:
            ans += 1
for i in range(100,N,19):
    for j in range(i+1,N):
        if A[i]+A[j] == j-i:
            ans += 1
for i in range(100,N,37):
    for j in range(i+1,N):
        if A[i]+A[j] == j-i:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
*A, = map(int, input().split())
count = 0
for i, a in enumerate(A):
    for j, b in enumerate(A[i + 1:]):
        if a + b <= N:
            if abs(i + 1 - (j + 1 + (i + 1))) == a + b:
                count += 1
        else:
            break
print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())

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

needsearch=[]

for i in range(n):
    a[i]-=(i+1)
    needsearch.append(-2*(i+1)-a[i])

counter=[0]*(2*(10**5))

for i in range(n):
    if 0<a[i]+10**5<2*(10**5):
        counter[a[i]+10**5]+=1

ans = 0
for i in range(len(needsearch)):
    if 0<needsearch[i]+10**5<2*(10**5):
        ans += counter[needsearch[i]+10**5]


print(ans)

Submission status: Wrong Answer

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

ab = []
for i in range(n):
    ab.append([i + 1, a[i]])

ab.sort(key=lambda x: x[1])

flag = False
ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        if ab[i][1] + ab[j][1] > n:
            flag = True
            break
        if max(ab[i][0], ab[j][0]) - min(ab[i][0], ab[j][0]) == ab[i][1] + ab[j][1]:
            ans += 1
    if flag:
        break

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = 0
l = [0]*(3*10**5+10)
for i in range(1,len(A)):
  x = i-A[i]
  if x<0:
    continue
  else:
    l[x]+=1
if A[0]<=2*10**5:
  ans+=l[A[0]]
for i in range(1,N):
  x = i+A[i]
  if x<0:
    continue
  if x>2*10**5:
    continue
  
  l[i-A[i]]-=1
  ans+=l[x]
  
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = 0
l = [0]*(2*10**5+10)
for i in range(1,len(A)):
  x = i-A[i]
  if x<0:
    continue
  else:
    l[x]+=1
if A[0]<=2*10**5:
  ans+=l[A[0]]
for i in range(1,N):
  x = i+A[i]
  if x<0:
    continue
  if x>2*10**5:
    continue
  
  l[i-A[i]]-=1
  ans+=l[x]
  
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(100):
    for j in range(i+1,N):
        if A[i]+A[j] == j-i:
            ans += 1
for i in range(100,N,13):
    for j in range(i+1,N):
        if A[i]+A[j] == j-i:
            ans += 1
for i in range(100,N,17):
    for j in range(i+1,N):
        if A[i]+A[j] == j-i:
            ans += 1
for i in range(100,N,19):
    for j in range(i+1,N):
        if A[i]+A[j] == j-i:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
p=0
for i in range(n):
    for s in range(i,n):
        t=abs(i-s)
        if t in a:
            continue
        if t==a[i]+a[s]:
            p+=1
print(p)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=[0]*N
C=[0]*N
for i in range(N):
  B[i]=A[i]+i+1
  C[i]=i+1-A[i]
B.sort()
C.sort()
start=0
j=0
bcount=1
bs=0
ans=0
for i in range(N-1):
  ccount=0
  x=B[i]
  
  if(x!=B[i+1]):
    bcount=i+1-bs
    #print(bcount)
    bs=i+1
    while(C[j]<=x):
      if(C[j]==x):
        ccount+=1
      if(j==N-1):
        break
      if(j<N-1):
        j+=1
      
    ans+=ccount*bcount
    #print(ccount)
  if(x>28):
    break
#print(B)
#print(C)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
Asort = sorted(A)
Amin = sum(Asort[:2])
Amax = min(sum(Asort[-2:]), N - 1)

cnt = 0
for i in range(N):
    for j in range(Amin, Amax + 1):
        if i - j >= 0 and j == A[i - j] + A[i]:
            cnt += 1
        elif i + j <= N - 1 and j == A[i] + A[i + j]:
            cnt += 1
print(cnt // 2)

Submission status: Wrong Answer

Solution code:
n = int(input())
ais=list(map(int,input().split()))
cnt = 0
for i in range(n-1):
  for j in range(i+1, n):
    if abs(ais[i]-ais[j]) == ais[i]+ais[j]:
      cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
u=N*(N-1)/2
for i in range(1,N):
  for j in range(i+1,N+1):
    t=abs(i-j)
    if t!=A[i-1]+A[j-1]:
      u-=1
print(u)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int, input().split()))
b=[0]*n
c=[0]*n
for i in range(n):
    b[i]=a[i]+i
    c[i]=i-a[i]
bs=sorted(b)
cs=sorted(c)
lx=[1+10**10]*n
ly=[2+10**10]*n
rx=[3+10**10]*n
ry=[4+10**10]*n

lx[0]=1
ly[0]=bs[0]
rx[0]=1
ry[0]=cs[0]

d=0
e=0
for j in range (1,n):
    if bs[j]==bs[j-1]:
        lx[d]+=1
    else:
        d+=1
        lx[d]=1
        ly[d]=bs[j]
        
for k in range (1,n):
    if cs[k]==cs[k-1]:
        rx[e]+=1
    else:
        e+=1
        rx[e]=1
        ry[e]=cs[k]
x=0
ans=0
for l in range(d):
    while ry[x]<=ly[l] and x<e:
        if ry[x]==ly[l]:
            ans+=(lx[l]*rx[x])
            x+=1
        else:
            x+=1
print(ans)

Submission status: Wrong Answer

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

count=0

for i in range(n):
  for h in range(i+1,):
    d=h-i
    g=a[i]+a[h]
    if d==g:
      count+=1
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
A=list(map(int,input().split()))
cnt=0
import numpy as np
table=np.array([[0]*(n+1) for i in range(n)])
for i,a in enumerate(A):
    if a<n:
        table[i][a]=1

for i in range(n-1):
    a=A[i]
    if a+i<n:
        new=table[(a+i):][:n-a-1]
        #print(new)
        cnt+=np.trace(new)
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
hlist = list(map(int, input().split()))
alist = list(range(1, n+1))

## TLE
shlist = []
for height in hlist:
    if height < n - 1:
        shlist.append(height)

ans = 0
# The absolute difference of their attendee numbers is equal to the sum of their heights.
for i, h1 in enumerate(shlist):
    for j, h2 in enumerate(shlist[i+1:]):
        if h1+h2>n:
            continue
        if j+1 == h1+h2:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
i = 0
j = 1
ans = 0
p = 0
nextj = 0
while True:
    if j == n:
        j = max(i+1,nextj)
        p = 0
        i += 1
    
    if p == 0 and a[i] + a[j] == j-i:
        ans += 1
        nextj = j
        p = 1
    elif p == 1 and a[i] + a[j] == j-i:
        ans += 1
    j += 1
    
    if i == n-1:
        print(ans)
        exit()

Submission status: Wrong Answer

Solution code:
import bisect

N = int(input())
A = [int(i) for i in input().split()]
d = [None] * N
for i in range(N):
    d[i] = [i+1-A[i], i+1+A[i]]

d.sort()
keys = [r[0] for r in d]
ans = []

for i in range(N):
    want = d[i][1]
    tmp = keys[i+1:]
    b = bisect.bisect_left(tmp, want)
    if not 0<= b < len(tmp):
        continue
    else:
        ans.append(b)

print(len(ans))

Submission status: Wrong Answer

Solution code:
import itertools

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

del_n = [abs(x - y) for x, y in itertools.combinations(range(1, n+1), 2)]
sum_a = [x + y for x, y in itertools.combinations(a, 2)]
print(del_n)
print(sum_a)
cnt = 0

for d, s in zip(del_n, sum_a):
    if d == s:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
arg = np.argsort(A)
B = np.sort(A)
count = 0
for i in range(N):
    for j in range(i+B[i],N):
        if B[i] + B[j] ==  abs(arg[j] - arg[i]):
            count += 1
        if B[i] + B[j] > N:
            break
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
ai = [int(i) for i in input().split()]

li = [0]*(10**6+1)

for i in range(1,n):
    if ai[i] >= 2*10**5:
        continue
    li[ai[i]-i+5*10**5] += 1

ans = 0
exit()

for i in range(1,n):
    #print(i)
    ans += li[-ai[i-1]-(i-1)+5*10**5]
    if i == n:
        #print(i,i,i)
        break
    if ai[i] < 2*10**5:
        li[ai[i]-i+5*10**5] -= 1
        
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from itertools import combinations as com
n = int(input())
a = list(map(int, input().split()))
cnt = 0
for i, j in com(tuple(range(1, n)), 2):
    if abs(i-j) == a[i-1]+a[j-1]:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
h = list(map(int,input().split()))
table=set()
count = 0
for i in range(n):
  table.add(i+1+h[i])
  if i+1-h[i] in table:
    count+=1
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = []
for i in list(map(int, input().split())):
    # 番号の差の絶対値の最大以上の身長を持つものは条件を満たさないのでパス
    if i < n - 1:
        a.append(i)

answer = 0
for i, hi in enumerate(a):
    for j in range(i + 1, len(a)):
        hj = a[j]
        if abs(i - j) == hi + hj:
            answer += 1
print(answer)

Submission status: Wrong Answer

Solution code:

n = int(input())
a = list(map(int,input().split()))
r = 0
for i in range(1,n+1):
    for j in range(1,n+1):
        if a[i-1] + a[j-1] == abs(i - j):
            r = r + 1
print(r)

Submission status: Wrong Answer

Solution code:
n = int(input())
a_lst = [int(elem) for elem in input().split()]

lst = []
for i in range(n):
    lst.append(i - a_lst[i])

cnt = 0
for j in range(n-1):
    if (j + a_lst[j]) in lst[j+1:]:
        cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
print(len([0 for i in range(N) for j in range(i + A[i], N) if j - 1 == A[i] + A[j]]))

Submission status: Wrong Answer

Solution code:
n = int(input())
h = list(map(int, input().split()))

count=0

for i in range(2,n):
    #番号の差がiの場合
    #print('------ '+ str(i) +' ------')

    #容疑者の選定（身長i未満のみ）
    suspect=[]
    for j in range(n):
        if h[j]<i:
            suspect.append(j)

    n_suspect=len(suspect)
    #print(suspect)

    #数え上げ
    for s1 in range(n_suspect-1):
        for s2 in range(s1+1,n_suspect):
            if h[suspect[s1]]+h[suspect[s2]]==i and suspect[s2]-suspect[s1]==i:
                count +=1
                print(s1, s2)

#print('------------')
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [0] + list(map(int, input().split()))
import itertools
cands = list(itertools.combinations(range(N), 2))
count = 0
for i,j in cands:
    if abs(i-j) == A[i]+A[j]:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
H = list(map(int, input().split()))
H2 = [0]*n
H3 = [0]*n

for i in range(n):
  H2[i] = H[i] - i 
  H3[i] = H[i] + i
  

import collections 
c2 = collections.Counter(H2)
c3 = collections.Counter(H3)

ans = 0
for k2 in c2:
  val = -k2
  if val in c3:
    ans += c3[val]
print(ans)  
#iB - iA = Ha + Hb
# Hb - iB = - (iA + Ha)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = 0
l = [0]*(3*10**5+10)
for i in range(1,N):
  x = i-A[i]
  if x<0:
    continue
  else:
    l[x]+=1
if A[0]<=2*10**5:
  ans+=l[A[0]]
for i in range(1,N):
  x = i+A[i]
  if x>2*10**5:
    continue
  
  l[i-A[i]]-=1
  ans+=l[x]
  
print(ans)

Submission status: Wrong Answer

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


count=0

for i in range(n):
  for h in range(n):
    if i+1==a[i] or h+1==a[h]:
      continue
    else:
      d=i-h
      g=a[i]+a[h]
      if d==g:
        count+=1
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split())) 
ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        if A[i] + A[j] == abs(i-j):
            ans += 1
            print("OK",end="")
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
b1 = []
b2 = []
answer = 0

for i in range(n):
  b1.append(i + 1 - a[i])
  b2.append(i + 1 + a[i])
  
for i in range(n - 1):
  answer += b2[i + 1: n].count(b1[i])
  
print(answer)

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))
count=0
for i1,r1 in enumerate(A):
    for i2,r2 in enumerate(A):
        if abs(i1-i2)==r1+r2:
            count+=1
print(count)

Submission status: Wrong Answer

Solution code:
import numpy as np
n=int(input())
a=list(map(int,input().split()))

S1=(np.array(a)+np.arange(n)).tolist()
s1=set(S1)
S2=(np.arange(n)-np.array(a)).tolist()
s2=set(S2)

check=0
commons=list(s1&s2)

for l in commons:
    s1c=S1.count(l)
    s2c=S2.count(l)
    check+=s1c if s1c>=s2c else s2c
print(check)

Submission status: Wrong Answer

Solution code:
def prime_factorize(n):
    c = []
    while n % 2 == 0:
        c.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            c.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        c.append(n)
    return c

X = int(input())

li = prime_factorize(X)

A = li[0]

x = 0
y = 0
x = A + y
flag = False

if x**5 - y**5 == X:
  flag = True

i = 0

while flag == False:
  if i%2 == 0:
    y = (i // 2) + 1
    x = A + y
    if x**5 - y**5 == X:
      flag = True
      break
  else:
    y = -1 * ((i // 2) + 1)
    x = A + y
    if x**5 - y**5 == X:
      flag = True
      break

  i += 1

print("{} {}".format(x, y))

Submission status: Wrong Answer

Solution code:
from sys import stdin
from collections import Counter
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

d1 = []
d2 = []

for ind,i in enumerate(A):
    d1.append(ind+i+1)
    d2.append(abs(ind-i+1))
    
c1 = Counter(d1)
c2 = Counter(d2)

ans = 0

for i in range(0,10**5+1):
    ans += (c1[i]*c2[i])

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = list(map(int,input().split()))
dem = 0
for i in range(n-1):
   for j in range(i+1,n):
      if j-i==abs(arr[j]+arr[i]):
         print(i,j)
         dem+=1
print(dem)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = sorted(A)
answer = 0
ul = N
for i in range(1, N):
    if B[i]-B[0] >= N-1:
        ul = i
for i in range(ul-1):
    for j in range(i, ul):
        if A[i]+A[j] == j-i:
            answer += 1
print(answer)

Submission status: Wrong Answer

Solution code:
import math
from collections import Counter
n=int(input())
l=[int(x) for x in input().split()]
f1=[]
f2=[]
for i in range(len(l)):
	f1.append(i-l[i])
	f2.append(l[i]+i)
c=0
for i in range(len(l)):
	if f1[i] in f2:
		c+=1
print(c)

Submission status: Wrong Answer

Solution code:
import bisect
N = int(input())
*A, = map(int, input().split())
t = [[A[i], i] for i in range(N)]
t.sort()

ta = [v for v, i in t]
ti = [i for v, i in t]

ans = 0
for i in range(N):
    l, r = 1-A[i], N-i-1-A[i]
    li = bisect.bisect_left(ta, l)
    ri = bisect.bisect_right(ta, r)
    for j in range(li, ri):
        if (A[i]+ta[j]) == abs(i-ti[j]):
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = 0
l = [0]*(3*10**5+10)
for i in range(1,N):
  x = i-A[i]
  if x<0:
    continue
  else:
    l[x]+=1
if A[0]<=2*10**5:
  ans+=l[A[0]]
for i in range(1,N):
  x = i+A[i]
  if x<0:
    continue
  if x>2*10**5:
    continue
  
  l[i-A[i]]-=1
  ans+=l[x]
  
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
plus={}
minus={}
for i in range(n):
  if(a[i]+(i+1)<=10**9):
    if a[i]+(i+1) in plus.keys():
      plus[a[i]+(i+1)]+=1
    else:
      plus[a[i]+(i+1)]=1
  if(a[i]>(i+1)):
    if a[i]-(i+1) in minus.keys():
      minus[a[i]-(i+1)]+=1
    else:
      minus[a[i]-(i+1)]=1
ans=0
for i in plus.keys():
  if i in minus.keys():
    ans+=plus[i]*minus[i]
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
h = list(map(int,input().split()))
table=set()
count = 0
for i in range(n):
  table.add(i+h[i])
  if i-h[i] in table:
    count+=1
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
    for j in range(n):
        if a[i]+a[j]== abs(j-i) :
             ans += 1
print(ans/2)

Submission status: Wrong Answer

Solution code:
N = int(input())

A = list(map(int, input().split()))
S = [-A[i] for i in range(N)]

D = {}
for i in range(N):
    if A[i] in D:
        D[A[i]][0] += 1
    else:
        D[A[i]] = [1, 0]
    if S[i] in D:
        D[S[i]][1] += 1
    else:
        D[S[i]] = [0, 1]
cnt = 0
for i in D:
    cnt += D[i][0] * D[i][1]
print(cnt)

Submission status: Wrong Answer

Solution code:
import itertools
a=int(input())
ct=0
b=list(map(int,input().split()))
n=list(range(len(b)))
c=list(itertools.permutations(n,2))
for i in range(len(c)):
    e=c[i][0]
    f=c[i][1]
    if b[e]+b[f]==abs(e-f):
        ct+=1
print(ct/2)

Submission status: Wrong Answer

Solution code:
import sys
from bisect import bisect_left
input = sys.stdin.readline
def main():
        N = int(input())
        ans = 0
        A = tuple(map(int,input().split()))
        l = N//2
        r = N//2+1
        for k in range(2,N):
            for i in range(k,N-k):
                if A[i]+A[i+k]==k:
                    ans += 1
                if A[i-k]+A[i] == k:
                    ans += 1
        print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    for j in range(n-1):
        if a[i]+a[j]== j-i :
             ans += 1
print(ans-n)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

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

ans = 0

for i in range(2, n-1):
    for j in range(n-i):
        if l[j] + l[i+j] == i:
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
m=0
for i in range(N-1):
  b=A[i]
  j=i+b+1
  for k in range(j,N):
    if k-A[k]>0:
      pass
    else:
      if abs(k-i)==A[i]+A[k]:
        m+=1
print(m)

Submission status: Wrong Answer

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

ans = 0

for i in range(n):
    for j in range(i+a[i]+1,n):
        print(i,j)
        if a[i]+a[j] == j-i:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    X = int(input())
    import math
    for i in range(0,100001,2):
        for j in range(-100000,1,1):
            # if i == j:
            #     continue
            if (i-j) * (pow(i,4) + pow(i,3)*j + pow(i,2)*pow(j,2) + i*pow(j,3) + pow(j,4)) == X:
                print(i,j)
                exit()
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

a = l()

po = [0 for i in range(2*(10**5)+1)]
if n-1-a[0] >= 0:
    po[n-1-a[0]] = 1
ans = 0
for i in range(1,n):
    ppo = n-1-i + a[i]
    if ppo > 2*(10**5):
        continue
    if ppo >= 0:
        ans += po[ppo]
    if n-i-1 - a[i] >= 0:
        po[n-i-1 - a[i]] += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
li = list(map(int,input().split()))
a=0
for i in range(n):
  for j in range(n):
    if li[i] + li[j] and abs(i-j):
      a+=1
print(a/2)

Submission status: Wrong Answer

Solution code:
def main():
  N = int(input())
  sanka_l = list(map(int, input().split()))
  count = 0
  min_num = min(sanka_l)
  for i in range(N):
    if sanka_l[i] >= N-i-min_num:
      break
    for j in range(i, N):
      if sanka_l[i] + sanka_l[j] == j - i:
        count += 1
  print(count)
      
main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

N = int(input())
A  =  [int(i) for i in input().split()]
ans = 0
for i in range(1,N-1):
    k = 0
    while(k+i<N):
        #print(A[k], A[k+i],i)
        if(A[k]+A[k+i]) == i:
            ans += 1
        k+=1
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
from collections import Counter
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

d1 = []
d2 = []

for ind,i in enumerate(A):
    d1.append(ind+i+1)
    d2.append(ind-i+1)
    
c1 = Counter(d1)
c2 = Counter(d2)

ans = 0
for i in range(0,10**5+1):
    ans += (c1[i]*c2[i])

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
from collections import Counter
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

d1 = []
d2 = []

for ind,i in enumerate(A):
    d1.append(ind+i)
    d2.append(ind-i)
    
c1 = Counter(d1)
c2 = Counter(d2)

ans = 0
for i in range(0,10**5+1):
    ans += (c1[i]*c2[i])

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
count=0
for i in range(2,n-1):
    for j in range(n-i):
        if a[j]<i and a[j]+a[j+i]==i:
            count+=1
print(count)

Submission status: Wrong Answer

Solution code:
import numpy as np

# input
n = int(input())
inp_ls = input().split(" ")
a_ls = np.array([int(e) for e in inp_ls[:n]])
print(a_ls)

cnt = 0
for i in range(n-1):
	abs_val = i+1
	l0 = a_ls[:-abs_val]
	l1 = a_ls[abs_val:]
	h_sum_ls = l0+l1
	cnt += np.count_nonzero(h_sum_ls == abs_val)

# result
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(1000000)




def main():
    n = int(input())
    a_dic = {}
    i = 0
    for a in list(map(int, input().split())):
        a_dic[i] = a
        i += 1

    count = 0
    for i in range(n):
        ai = a_dic[i]
        for j in range(i+1, n):
            # combi = (i,j)
            if j - i == ai + a_dic[j]:
                count += 1



main()

Submission status: Wrong Answer

Solution code:
n = int()
A = list(map(int,input().split()))

score = {}

for i, a in enumerate(A):
  if i ==0:
    continue
  s = i-a
  if s not in score:
    score[s] = []
  score[s].append(i)
  
print(score)
  
for i, a in enumerate(A):
  i += 1
  if i+a in score:
    print(score[i+a])

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
k=0
for i in range(n):
    for j in range(i+1,n):
        if abs(a[i]-a[j])==abs(j-i):
            k+=1
print(k-1)

Submission status: Wrong Answer

Solution code:


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()