Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import numpy as np
n=int(input())
a=[str(input()) for i in range(n)]
b=sorted(set(a),key=lambda x:x)
b=[[i,0]for i in b]
lenb=range(len(b))
for i in lenb:
  for j in a:
    if j==b[i][0]:
      b[i][1]+=1
c=np.array([i[1] for i in b])
maxb=max(c)
#b=sorted(b,key=lambda x:x[0])
for i in lenb:
  if b[i][1]==maxb:
    print(b[i][0])

### FIXED CODE ###

n=int(input())
a=[str(input()) for i in range(n)]
b={}
for i in a:
  if i in b:
    b[i]+=1
  else:
    b[i]=0
maxb=max(b.values())
b=sorted(b.items(),key=lambda x:x[0])
for i,j in b:
  if maxb==j:
    print(i)
### BUGGY CODE ###

import math
import numpy as np

N = int(input())
a = np.array([int(input()) for _ in range(N)])
s = np.sum(a)

# Counts of (R >= s / 2)
dp0 = np.zeros((N + 1, s + 1))
dp0[0, 0] = 1
# Counts of (R == s / 2 and G == s / 2)
dp1 = np.zeros((N + 1, s + 1))
dp1[0, 0] = 1

mod = 998244353
for i, x in enumerate(a):
    dp0[i + 1, :] += dp0[i, :] * 2 % mod
    dp0[i + 1, x:] += dp0[i, :-x] % mod
    dp1[i + 1, :] += dp1[i, :] % mod
    dp1[i + 1, x:] += dp1[i, :-x] % mod

c0 = int(np.sum(dp0[N][math.ceil(s / 2):]))
c1 = int(dp1[N][s // 2]) if s % 2 == 0 else 0

ans = (3 ** N - 3 * c0 + 3 * c1) % 998244353
print(ans)

### FIXED CODE ###

import math
import numpy as np

N = int(input())
a = np.array([int(input()) for _ in range(N)])
s = np.sum(a)

# Counts of (R >= s / 2)
dp0 = np.zeros((N + 1, s + 1))
dp0[0, 0] = 1
# Counts of (R == s / 2 and G == s / 2)
dp1 = np.zeros((N + 1, s // 2 + 1))
dp1[0, 0] = 1

mod = 998244353
for i, x in enumerate(a):
    dp0[i + 1, :] += dp0[i, :] * 2 % mod
    dp0[i + 1, x:] += dp0[i, :-x] % mod
    dp1[i + 1, :] += dp1[i, :] % mod
    dp1[i + 1, x:] += dp1[i, :-x] % mod

c0 = int(np.sum(dp0[N][math.ceil(s / 2):]))
c1 = int(dp1[N][s // 2]) if s % 2 == 0 else 0

ans = (3 ** N - 3 * c0 + 3 * c1) % mod
print(ans)
### BUGGY CODE ###

n, w = map(int, input().split())
goods = [list(map(int, input().split())) for _ in range(n)]
dp = [[0] * (w + 1) for _ in range(n)]
for i in range(n):
    for j in range(w + 1):
        if 0 <= j - goods[i][0]:
            dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - goods[i][0]] + goods[i][1])
        dp[i][j] = max(dp[i][j], dp[i - 1][j])
print(dp[n - 1][w])


### FIXED CODE ###

n, w = map(int, input().split())
goods = [list(map(int, input().split())) for _ in range(n)]
dp = [[0] * (w + 1) for _ in range(n)]
for i in range(n):
    for j in range(w + 1):
        if 0 <= j - goods[i][0]:
            dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - goods[i][0]] + goods[i][1])
        dp[i][j] = max(dp[i][j], dp[i - 1][j])
print(dp[n - 1][w])
### BUGGY CODE ###

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

Bcon = [0] * N
res = 0
p = 0
for n in range(N):
    while p <= N - 1 and B[n] > A[p]:
        p += 1
    Bcon[n] = p

p = 0
for n in range(N):
    while p <= N - 1 and C[n] > B[p]:
        p += 1
    res += sum(Bcon[:p])
    
print(res)

### FIXED CODE ###

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

Bcon = [0] * (N + 1)
res = 0
p = 0
for n in range(N):
    while p <= N - 1 and B[n] > A[p]:
        p += 1
    Bcon[n + 1] = p + Bcon[n]
    
p = 0
for n in range(N):
    while p <= N - 1 and C[n] > B[p]:
        p += 1
    res += Bcon[p]
    
print(res)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10000)

N,M,P=map(int,input().split())
ways=[[] for _ in range(N)]
Rways=[[] for _ in range(N)]

for i in range(M):
  A,B,C=map(int,input().split())
  ways[A-1].append([B-1,C-P])
  Rways[B-1].append(A-1)
  
  
visited=[-float("inf")]*N
visited[0]=0

blacklist=[True]*N
blacklist[-1]=False
"""
for c in range(M):
  for i in range(N):
    if blacklist[i]==True:
      continue
    for to in Rways[i]:
      blacklist[to]=False
"""
def b_update(nord):
  global blacklist
  for to in Rways[nord]:
    if blacklist[to]==True:
      blacklist[to]=False
      b_update(to)
      
b_update(N-1)

for c in range(M+1):
  flag=False
  for i in range(N):
    debit=visited[i]
    if debit==-float("inf"):
      continue
    for to,cost in ways[i]:
      if visited[to]<debit+cost and not blacklist[to]:
        visited[to]=debit+cost
        flag=True
        
  if not flag:
    break
  if c==M:
    print(-1)
    exit()
      
ans=visited[-1]
if ans==-float("inf"):
  print(-1)
else:
  print(max(ans,0))
  
  


### FIXED CODE ###

import sys
sys.setrecursionlimit(10000)

N,M,P=map(int,input().split())
ways=[[] for _ in range(N)]
Rways=[[] for _ in range(N)]

for i in range(M):
  A,B,C=map(int,input().split())
  ways[A-1].append([B-1,C-P])
  Rways[B-1].append(A-1)
  
  
visited=[-float("inf")]*N
visited[0]=0

blacklist=[True]*N
blacklist[-1]=False
"""
for c in range(M):
  for i in range(N):
    if blacklist[i]==True:
      continue
    for to in Rways[i]:
      blacklist[to]=False
"""
def b_update(nord):
  global blacklist
  for to in Rways[nord]:
    if blacklist[to]==True:
      blacklist[to]=False
      b_update(to)
      
b_update(N-1)

for c in range(N):
  flag=False
  for i in range(N):
    debit=visited[i]
    if debit==-float("inf"):
      continue
    for to,cost in ways[i]:
      if visited[to]<debit+cost and not blacklist[to]:
        visited[to]=debit+cost
        flag=True
        
  if not flag:
    break
  if c==N-1:
    print(-1)
    exit()
      
ans=visited[-1]
if ans==-float("inf"):
  print(-1)
else:
  print(max(ans,0))
### BUGGY CODE ###

n,*a= map(int,open(0).read().split())
b=[]
for i in range(1,n+1):
    b.append(a.index(i)+1)
print(*b)

### FIXED CODE ###

n,*a= map(int,open(0).read().split())
"""
b=[]

for i in range(1,n+1):
    b.append(a.index(i)+1)
"""
b=[[a[i],i+1] for i in range(n)]
b.sort(key=lambda x: x[0])
for bb in b:
    print(bb[1],end =" ")
print("")
### BUGGY CODE ###

from collections import deque
from functools import lru_cache
import bisect
import sys
sys.setrecursionlimit(10**9)

def main():
    N = int(input())
    X = []
    for _ in range(N):
        a,b = map(int,input().split())
        bisect.insort(X,(b,a))

    x = 0
    X = deque(X)
    l = len(X)
    for _ in range(l):
        b,a = X.popleft()
        # print(b,a,x)
        if x + a > b:
            print("No")
            exit()

        x += a

    print("Yes")



if __name__ == "__main__":
  main()

### FIXED CODE ###

from collections import deque
import bisect
import sys
sys.setrecursionlimit(10**9)

def main():
    N = int(input())
    X = []
    for _ in range(N):
        a,b = map(int,input().split())
        X.append((b,a))

    x = 0
    X.sort(key=lambda x: x[0])
    X = deque(X)
    l = len(X)
    for _ in range(l):
        b,a = X.popleft()
        # print(b,a,x)
        if x + a > b:
            print("No")
            exit()

        x += a

    print("Yes")



if __name__ == "__main__":
  main()
### BUGGY CODE ###

n=int(input())
a=[int(x) for x in input().rstrip().split()]
done=[False for i in range(n)]

for i in range(n):
  if done[i]==True:
    continue
  for j in range(i+1,n):
    if done[j]==True:
      continue
    if a[i]%a[j]==0:
      done[i]=True

    if a[j]%a[i]==0:
      done[j]=True

print(done.count(False))



### FIXED CODE ###

import sys

n=int(input())
a=[int(x) for x in input().rstrip().split()]
a.sort()
max_val=max(a)
dp=[True for i in range(max_val)]
done=[0 for i in range(max_val)]
cnt=0
ans=0

for i in a:

  if 1<=done[i-1]:
    done[i-1]+=1
    continue

  done[i-1]+=1
  cnt=1
  while(i*cnt<=max_val):
    cnt+=1
    if cnt*i<=max_val:
      done[cnt*i-1]+=1

for i in a:
  if done[i-1]==1:
      ans+=1

print(ans)
### BUGGY CODE ###

s = input()
ss = s
leng = 1
while leng != 0:
	ollen = len(s)
	s = s.replace('01','')
	s = s.replace('10','')
	nwlen = len(s)
	if ollen != nwlen:
		leng = abs(ollen - nwlen)
	else:
		leng = 0

print (len(ss)-len(s))


### FIXED CODE ###

s = input()
cnt0 = 0
cnt1 = 0
cnt0 = s.count("0")
cnt1 = s.count("1")
print (min(cnt0,cnt1)*2)
### BUGGY CODE ###

N = int(input())
kei =[]
for i in range(N):
    s = input()
    if s in kei:
        continue
    else:
        kei.append(s)
print(len(kei))

### FIXED CODE ###

N = int(input())
kei =[]
for i in range(N):
    s = input()
    kei.append(s)
kei.sort()
t=kei[0]
count=1
for i in range(0,N):
    if(kei[i] != t):
        count+=1
        t = kei[i]
print(count)
### BUGGY CODE ###

import math
s=input()
n=len(s)
count=0
a=[0 for i in range(2019)]
a[0]=1
k=0
for i in reversed(range(0,n)):
    k+=(10**(n-i-1)%2019)*int(s[i])
    a[k%2019]+=1        
for i in range(len(a)):
    if a[i]>=2:
        count+=(a[i])*(a[i]-1)//2
print(count)

### FIXED CODE ###

import math
s=input()
n=len(s)
count=0
a=[0 for i in range(2019)]
a[0]=1
k=0
b=[0 for i in range(n)]
b[0]=1
for i in range(1,n):
    b[i]=b[i-1]*10%2019
for i in reversed(range(0,n)):
    k+=(b[n-i-1])*int(s[i])%2019
    a[k%2019]+=1        
for i in range(len(a)):
    if a[i]>=2:
        count+=(a[i])*(a[i]-1)//2
print(count)
### BUGGY CODE ###

import itertools

n=int(input())
list1=[]
for j in range(n):
  s=input()
  if s[0]=='M' or s[0]=='A' or s[0]=='R' or s[0]=='C' or s[0]=='H':
    list1.append(s[0])

#list1.sort()

list2=list(itertools.combinations(list1, 3))

cnt=0
for j in range(len(list2)):
  if len(list2[j])==len(set(list2[j])):
    cnt+=1

print(cnt)


### FIXED CODE ###

n=int(input())

m=0;a=0;r=0;c=0;h=0

for i in range(n):
  s=input()
  if s[0]=='M':
    m+=1
  elif s[0]=='A':
    a+=1
  elif s[0]=='R':
    r+=1      
  elif s[0]=='C':
    c+=1      
  elif s[0]=='H':
    h+=1

#print(m,a,r,c,h)
ans=0
ans+=m*a*r
ans+=m*a*c
ans+=m*a*h
ans+=m*r*c
ans+=m*r*h
ans+=m*c*h
ans+=a*r*c
ans+=a*r*h
ans+=a*c*h
ans+=r*c*h

print(ans)
### BUGGY CODE ###

N, Q = map(int, input().split())
S = input()

for i in range(Q):
    l, r = map(int, input().split())
    print(S[l-1:r].count('AC'))

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()

sum_list = [0]
for i in range(N-1):
    sum_list.append(sum_list[-1] + (1 if S[i:i+2] == 'AC' else 0))

for j in range(Q):
    l, r = map(int, input().split())
    print(sum_list[r-1] - sum_list[l-1])
### BUGGY CODE ###

n,m=map(int,input().split())
L=[int(input()) for i in range(m)]

NL=[0]*(n+1)
NL[0],NL[1]=1,1

if 1 in L:
      NL[1]=0
      
for i in range(2,n+1):
      if i in L:
            NL[i]=0
      else:
            NL[i]=NL[i-2]+NL[i-1]
print(NL[-1]%1000000007)

### FIXED CODE ###

n,m=map(int,input().split())
A=[int(input()) for i in range(m)]

ai=0
n1,n2=0,1
for i in range(1,n+1):
      if ai<m and i==A[ai]:
            ai+=1
            n1=n2
            n2=0
      else:
            tmp=n2
            n2=(n1+n2)%1000000007
            n1=tmp
print(n2)
### BUGGY CODE ###

n = int(input())
V = list(map(int,input().split(" ")))
e,o = [],[]

for i,v in enumerate(V):
    if i % 2 == 0:
        e.append(v)
    else:
        o.append(v)

e_ele = list(set(e))
o_ele = list(set(o))
e1,e2,e1c,e2c = 0,0,0,0
o1,o2,o1c,o2c = 0,0,0,0

for val in e_ele:
    valc = e.count(val)
    if valc > e1c:
        e1 = val
        e1c = valc
        continue
    if valc > e2c:
        e2 = val
        e2c = valc

for val in o_ele:
    valc = o.count(val)
    if valc > o1c:
        o1 = val
        o1c = valc
        continue
    if valc > o2c:
        o2 = val
        o2c = valc

ans = 0
elen = len(e)
olen = len(o)
if e1 != o1:
    ans = elen - e1c + olen - o1c
else:
    ans = elen - e1c + olen - o2c
    if ans > olen - o1c + elen - e2c:
        ans = olen - o1c + elen - e2c
print(ans)

### FIXED CODE ###

import collections

n = int(input())
v = list(map(int,input().split(" ")))
e,o = [],[]
e = v[::2]
o = v[1::2]

ec = collections.Counter(e).most_common(2)
oc = collections.Counter(o).most_common(2)

if ec[0][0] != oc[0][0]:
    print(n - ec[0][1] - oc[0][1])
else:
    if len(ec) == 1:
        print(n // 2)
    else:
        print(n - max(ec[0][1] + oc[1][1], ec[1][1] + oc[0][1]))
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
m = 10 ** 18

ans = 1
for i in range(len(a)):
    ans *= a[i]
    if ans > 10 ** 18 and 0 not in a:
        print(-1)
        exit()

print(ans)


### FIXED CODE ###

from operator import mul
from functools import reduce

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

cnt = 1
if 0 in a:
    print(0)
    exit()

for i in range(len(a)):
    cnt *= a[i]
    if cnt > 10 ** 18:
        print(-1)
        exit()
print(cnt)
### BUGGY CODE ###

N = int(input())

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

place = [0 for _ in range(1000000000)]
counter = 0
max = 0

for i in series:
    place[i] += 1
    if i > max:
        max = i
    
for j in range(len(place)):
    if place[j] > j:
        counter += place[j] - j
    elif j > place[j]:
        counter += place[j]
        
print(counter)

### FIXED CODE ###

N = int(input())

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

place = {}
counter = 0

for i in series:
    if i not in place:
        place[i] = 0
    place[i] += 1
    
for j in place.keys():
    if place[j] > j:
        counter += place[j] - j
    elif j > place[j]:
        counter += place[j]
        
print(counter)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A = inputList()
    
    ans = [0]*N
    B=[]
    ans_str = ""
    for i in range(N, 0, -1):
        cons = 0
        for j in range(i, N+1, i):
            if ans[j-1] == 1:
                cons += 1
        if A[i-1] == 1 and cons % 2 == 0:
            ans[i-1] = 1
            B.append(i)
            ans_str = ans_str + str(i) + " "
            continue
        if A[i-1] == 0 and cons % 2 == 1:
            ans[i-1] = 1
            B.append(i)
            ans_str = ans_str + str(i) + " "
            continue
            
    print(len(B))
    print(ans_str)
            	
if __name__ == "__main__":
	main()


### FIXED CODE ###

import sys
 
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
 
N=INT()
A=LIST()
 
# その位置にボールを入れるかを保持するA2
A2=[0]*N
B=[]
# 後ろから決めていく
for i in range(N-1, -1, -1):
    cur=i+1
    cnt=0
    # curの倍数を全部見に行く
    for j in range(cur*2, N+1, cur):
        cnt^=A2[j-1]
    # ボールを入れるべきかどうか
    if A[i]!=cnt:
        B.append(cur)
        A2[i]=1
 
print(len(B))
print(*B)
### BUGGY CODE ###

from heapq import *
from numpy import array,inf


def djikstra(s,G):
    que = []
    d = [inf]*V
    d[s] = 0
    heappush(que,(0,s))
    while(len(que)!=0):
        p = heappop(que)
        v = p[1]
        if d[v] < p[0]:
            continue
        for i in range(len(G[v])):
            e = G[v][i]
            if d[e[0]] > d[v] + e[1]:
                d[e[0]] = d[v] + e[1]
                heappush(que,(d[e[0]],e[0]))
    return d




n,m,s,t = map(int,input().split())
V = n
Ga = [[] for i in range(n)]
Gb = [[] for i in range(n)]
for i in range(m):
    u,v,a,b = map(int,input().split())
    Ga[u-1].append((v-1,a))
    Ga[v-1].append((u-1,a))
    Gb[u-1].append((v-1,b))
    Gb[v-1].append((u-1,b))


S = djikstra(s-1,Ga)
T = djikstra(t-1,Gb)

M = 10**15-(array(S)+array(T))
ans = [0]*n
ans[n-1] = M[n-1]
for i in range(n-2,-1,-1):
    ans[i] = max(ans[i+1],M[i])

for i in range(n):
    print(ans[i])

### FIXED CODE ###

from heapq import *
from numpy import array,inf


def djikstra(G,s):
    que = []
    d = [inf]*V
    d[s] = 0
    visited = [False] * V
    heappush(que,(0,s))
    while(len(que)!=0):
        p = heappop(que)
        v = p[1]
        if visited[v]:
            continue
        visited[v] = True
        for i in range(len(G[v])):
            e = G[v][i]
            if visited[e[0]]:
                continue
            if d[e[0]] > d[v] + e[1]:
                d[e[0]] = d[v] + e[1]
                heappush(que,(d[e[0]],e[0]))
    return d


n,m,s,t = map(int,input().split())
V = n
Ga = [[] for i in range(n)]
Gb = [[] for i in range(n)]
for i in range(m):
    u,v,a,b = map(int,input().split())
    Ga[u-1].append((v-1,a))
    Ga[v-1].append((u-1,a))
    Gb[u-1].append((v-1,b))
    Gb[v-1].append((u-1,b))

S = djikstra(Ga,s-1)

T = djikstra(Gb,t-1)

M = 10**15-(array(S)+array(T))
ans = [0]*n
ans[n-1] = M[n-1]
for i in range(n-2,-1,-1):
    ans[i] = max(ans[i+1],M[i])

for i in range(n):
    print(ans[i])
### BUGGY CODE ###

n,q = (int(j) for j in input().split())
s = input()
x = [[0,0] for j in range(q)]
count = [0]*q
for j in range(q):
    x[j][0], x[j][1] = (int(k) for k in input().split())
for j in range(q):
    y = x[:]
    ss = s[y[j][0]-1:y[j][1]]
    ss = ss + 'B'
    for k in range(len(ss) - 1):
        if ss[k] == 'A' and ss[k+1] == 'C':
            count[j] = count[j] + 1
for j in range(q):
    print(count[j])

### FIXED CODE ###

n,q = map(int,input().split())
s = input()
l = [[0,0] for _ in range(q)]
for i in range(q):
    l[i][0],l[i][1] = map(int,input().split())
cnt = [0] * n
for i in range(1,n):
    if s[i] == 'C' and s[i-1] == 'A':
        cnt[i] = cnt[i-1] + 1
    else:
        cnt[i] = cnt[i-1]
cnt.insert(0,0)
for i in range(q):
    print(cnt[l[i][1]]-cnt[l[i][0]])
### BUGGY CODE ###

import collections

X, Y = map(int, input().split())

ans = "No"
for i in range(2**X):
    count = collections.Counter(bin(i)[2:].zfill(X))
    num = count["0"]*2 + count["1"]*4
    if num == Y:
        ans = "Yes"
        break
    elif num > Y:
        ans = "No"

print(ans)

### FIXED CODE ###

X, Y = map(int, input().split())

b = (Y - 2*X)/2
a = X - b

is_int = (a.is_integer() and b.is_integer())
is_positive = (a >= 0 and b >= 0)
if is_int and is_positive and (a + b) == X and (2*a + 4*b) == Y:
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

a, b, k = map(int, input().split())

l = []
for i in range(a, b+1):
    l.append(i)
ans = sorted(list(set(l[:k] + l[-k:])))
for a in ans:
    print(a)



### FIXED CODE ###

a, b, k = map(int, input().split())

if b-a>=2*k:
    for i in range(a, a+k):
        print(i)

    for j in range(b-k+1, b+1):
        print(j)
else:
    for n in range(a, b+1):
        print(n)
### BUGGY CODE ###

N=int(input().strip())
L=list(map(int,input().strip().split()))

count=0
for i,a in enumerate(L):
    for  j,b in enumerate(L[i+1:]):
        for c in L[i+1+j+1:]:
            if a<b+c and b<a+c and c<a+b:
                count+=1
print(count)

### FIXED CODE ###

import bisect
 
N = int(input())
L = list(map(int, input().split()))
L.sort()
 
c = 0
for i in range(N-2):
  for j in range(i+1, N-1):
    c += bisect.bisect_right(L, L[i]+L[j]-1) - j - 1
 
 
print(c)
### BUGGY CODE ###

from functools import reduce
from math import gcd
from itertools import product

K = int(input())
b = 0

for a in product(range(1,K+1), repeat=3):
    b += reduce(gcd, a)
print(b)

### FIXED CODE ###

from math import gcd
r = range(1, int(input()) + 1)
print(sum(gcd(gcd(i,j),k) for i in r for j in r for k in r))
### BUGGY CODE ###

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

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

print(ans)


### FIXED CODE ###

from collections import Counter

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

l = []
r = []
for i, ai in enumerate(a):
   l.append(i+ai)
   r.append(i-ai)

ans = 0
b = Counter(r)
for i in l:
   ans += b.get(i, 0)

print(ans)
### BUGGY CODE ###

s=input()
a=int(s)
list=[]
list.append(1)
list.append(6)
list.append(9)
list.append(36)
list.append(81)
list.append(216)
list.append(729)
list.append(1296)
list.append(6561)
list.append(7776)
list.append(59049)
list.append(46656)
pp=[]
def money(x,y):
  for i in range(12):
    if i%2==1:
      if 0<x//list[i]<6:
        if x%list[i]==0:
          pp.append(y+x//list[i])
        else:
          money(x-list[i],y+1)
    elif i%2==0 and i!=0:
      if 0<x//list[i]<9:
        if x%list[i]==0:
          pp.append(y+x//list[i])
        else:
          money(x-list[i],y+1)
    elif i==0:
      if 0<x//list[i]<6:
        pp.append(y+x//list[i])
money(a,0)
print(min(pp))

### FIXED CODE ###

s=input()
a=int(s)
list=[]
list.append(1)
list.append(6)
list.append(9)
list.append(36)
list.append(81)
list.append(216)
list.append(729)
list.append(1296)
list.append(6561)
list.append(7776)
list.append(59049)
list.append(46656)
pp=[]
def money(x,y):
  for i in range(12):
    b=x//list[i]
    if b==0:
      continue
    if i%2==1:
      if 0<b<6:
        if x%list[i]==0:
          pp.append(y+b)
        else:
          if y>20:
            break
          money(x-list[i],y+1)
    elif i%2==0:
      if i!=0:
        if 0<b<9:
          if x%list[i]==0:
            pp.append(y+b)
          else:
            if y>20:
              break
            money(x-list[i],y+1)
      else:
        if 0<b<6:
          pp.append(y+b)
money(a,0)
print(min(pp))
### BUGGY CODE ###

import math
N,K = (int(i) for i in input().split())

count = 0
minus = []
for i in range(1,N+1):
    
    a = i
    b = i
    c = i
    if (a + b) % K == 0:
        count += 1
        count += len(minus) * (3*2)
        if len(minus) >= 2:
            kumiawase = math.factorial(len(minus))/(math.factorial(len(minus)-2)*math.factorial(2))
            count += kumiawase * (3*2)
    if i % K == 0:
        minus.append(i)

print(int(count))

### FIXED CODE ###

#import math
N,K = (int(i) for i in input().split())

count = 0
minus = []
for i in range(1,N+1):
    
    a = i
    b = i
    c = i
    if (a + b) % K == 0:
        count += 1
        count += len(minus) * (3*2)
        if len(minus) >= 2:
            #kumiawase = math.factorial(len(minus))/(math.factorial(len(minus)-2)*math.factorial(2))
            kazu = len(minus)
            kumiawase = kazu * (kazu - 1) / 2
            count += kumiawase * (3*2)
    if i % K == 0:
        minus.append(i)

print(int(count))