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

# import numpy as np
# import scipy as sp
# print(a,b,c,sep="") # 半角スペースなしで出力(abc)
# n=int(input())  #数値入力 「N」だけの入力のとき
# a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# c=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# s=[list(map(int,list(input()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
# import sys ; sys.exit() # プログラム終了
# from copy import deepcopy ; b=deepcopy(a)
# chr(ord('a') + 1)
# s.sort(key=lambda x: x[1], reverse=False) # 2番目の要素で昇順にソート（Trueなら降順）
#
from copy import deepcopy
h, w = map(int, input().split())
ss = [list(map(str, list(input()))) for i in range(h)]
flag = False
for i in range(h):
    for j in range(w):
        if (ss[i][j] == "."):
            flag = True

ans = 0
while (flag):
    ans += 1
    s = deepcopy(ss)
    for i in range(h):
        for j in range(w):
            if (ss[i][j] == "#"):
                if i+1 < h:
                    s[i+1][j] = "#"
                if i-1 >= 0:
                    s[i-1][j] = "#"
                if j+1 < w:
                    s[i][j+1] = "#"
                if j-1 >= 0:
                    s[i][j-1] = "#"
    ss = deepcopy(s)
    flag = False
    for i in range(h):
        for j in range(w):
            if (ss[i][j] == "."):
                flag = True

print(ans)


### FIXED CODE ###

# import numpy as np
# import scipy as sp
# print(a,b,c,sep="") # 半角スペースなしで出力(abc)
# n=int(input())  #数値入力 「N」だけの入力のとき
# a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# c=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# s=[list(map(int,list(input()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
# import sys ; sys.exit() # プログラム終了
# from copy import deepcopy ; b=deepcopy(a)
# chr(ord('a') + 1)
# s.sort(key=lambda x: x[1], reverse=False) # 2番目の要素で昇順にソート（Trueなら降順）
#
from copy import deepcopy
from collections import deque

d = deque()
h, w = map(int, input().split())
s = [list(map(str, list(input()))) for i in range(h)]
used = [[True for j in range(w)] for i in range(h)]
# used = [[True]*w]*h
for i in range(h):
    for j in range(w):
        if (s[i][j] == "#"):
            d.append([i, j])
            used[i][j] = False


ans = -1
while (d):

    tmp = deque()
    while(d):
        i, j = d.popleft()

        if i+1 < h and used[i+1][j]:
            s[i+1][j] = "#"
            tmp.append([i+1, j])
            used[i+1][j] = False

        if i-1 >= 0 and used[i-1][j]:
            s[i-1][j] = "#"
            tmp.append([i-1, j])
            used[i-1][j] = False

        if j+1 < w and used[i][j+1]:
            s[i][j+1] = "#"
            tmp.append([i, j+1])
            used[i][j+1] = False

        if j-1 >= 0 and used[i][j-1]:
            s[i][j-1] = "#"
            tmp.append([i, j-1])
            used[i][j-1] = False

    d = tmp
    ans += 1

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

# 1. 最大公約数を求める(ユークリッドの互除法)
# 2. 最大公約数を素因数分解する。
# 3. 2.の結果に含まれる素数を２つのグループに分ける

from collections import defaultdict
import itertools

def main():
  a, b = map(int, input().split())
  c = gojo(a,b)
  
  fac = defaultdict(lambda : 0)
  #print(c)
  fac[1] = 1
  fac = facto(c, fac)
  #print(fac)
  keys = list((fac.keys()))
  print(len(keys))  
  
def facto(n, fac):
  if n == 1:
    return fac
  for cursor in primeGenerator(n + 1):
    if n % cursor == 0:
      fac[cursor] += 1
      n = n // cursor
      if n == 1:
        break
      
  return fac

def primeGenerator(max_n):
  is_prime = [True for x in range(max_n)]
  is_prime[0] = 0
  is_prime[1] = 0
  yield 2
  for n in range(3, max_n, 2):
    if is_prime[n]:
      yield n
      for i in range(n, max_n, n):
        is_prime[i] = False      
  
def gojo(a,b):
  if b > a:
    a, b = b, a
  c = a % b
  if c == 0:
    return(b)
  else:
    return gojo(b, c)

if __name__ == "__main__":
  main()


### FIXED CODE ###

# 1. 最大公約数を求める(ユークリッドの互除法)
# 2. 最大公約数を素因数分解する。
# 3. 2.の結果に含まれる素数＋１が答え

import itertools
from fractions import gcd
from math import ceil

def main():
  a, b = map(int, input().split())
  fac = facto(gcd(a,b))
  print(len(fac))  
  
def facto(n):
  fac = [1]
  if n == 1:
    return [1]
  elif n % 2 == 0:
    fac = [1, 2]
    while n % 2 == 0:
      n = n // 2
  
  max_n = ceil(n ** 0.5) + 1
  
  is_prime = [True for x in range(max_n)]
  for cursor in range(3, max_n, 2):
    if is_prime[cursor]:
      if n % cursor == 0:
        fac.append(cursor)
        while n % cursor == 0:
          n = n // cursor
        if n == 1:
          break
      for i in range(cursor, max_n, cursor):
        is_prime[i] = False
  if n != 1:
    fac.append(n)
  return fac

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

import itertools

N = int(input())
V = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

max = 0
pattern = itertools.product(range(2), repeat=N)
for p in pattern:
    sum = 0
    count = 0
    for i in p:
        if i == 1:
            sum += V[count]-C[count]
        else:
            pass
        count +=1
    if sum > max:
        max = sum


print(max)


### FIXED CODE ###

import itertools

N = int(input())
V = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

sum = 0
for i in range(N):
    if V[i]-C[i] > 0:
        sum += V[i]-C[i]

print(sum)
### BUGGY CODE ###

n, m = list(map(int, input().split(' ')))
l = list(map(int, input().split(' ')))
d = {}  # key=match, val=num
d[2] = [1]
d[3] = [7]
d[4] = [4]
d[5] = [5, 3, 2]
d[6] = [9, 6]
d[7] = [8]
enable = [False] * 10
for a in l:
  enable[a] = True
# マッチをk(=2..7)本使う場合の一番大きい値を総当たり
def f(nokori, current):
  k = (nokori, current)
  if nokori <= 0:
    return current if nokori == 0 else -1
  temps = []
  for key, nums in list(d.items())[::-1]:
    for num in nums:
      if enable[num]:
        temps.append(f(nokori-key, current*10+num))
        break
  return max(temps)

# 余裕があるうちは一番マッチの本数が少ないモノをヤケクソで詰めまくる
hoge = False
for key, nums in list(d.items()):
    # print(key, nums, type(nums))
    for num in nums:
      if enable[num]:
        hoge = True
        break
    if hoge:
      break
cs = []
while n > 50:
  n -= key
  cs.append(str(num))

# ヤケクソで詰めたやつと総当たりで調べたマックスを並び替えて辞書順で大きくする
num_ans = str(f(n, 0))
print(''.join(sorted(list(num_ans) + cs)[::-1]))

### FIXED CODE ###

n, m = list(map(int, input().split(' ')))
l = list(map(int, input().split(' ')))
d = {}
# 1 = 2 = 0.5
d[2] = [1]
# 7 = 3 = 2.3 
d[3] = [7]
# 4 = 4 = 1
d[4] = [4]
# 5 = 5 = 1
# 3 = 5 = .6
# 2 = 5 = .4
d[5] = [5, 3, 2]
# 9 = 6 = 1.5
# 6 = 6 = 1
d[6] = [9, 6]
# 8 = 7 = 1.1...
d[7] = [8]
enable = [False] * 10
for a in l:
  enable[a] = True
memo = {}
def f(nokori, current):
#  print(nokori, current)
  k = (nokori, current)  # 順不同
  if k in memo:
    return memo[k]
  if nokori == 0:
    return current
  if nokori < 0:
    return -1
  temps = []
  for key, nums in list(d.items())[::-1]:
    # print(key, nums, type(nums))
    for num in nums:
      if enable[num]:
        if nokori-key != 0 and current % 10 != 0 and current % 10 < num:
          continue
        temps.append(f(nokori-key, current*10+num))
        break
  memo[k] = max(temps)
  return memo[k]

# pre
hoge = False
for key, nums in list(d.items()):
    # print(key, nums, type(nums))
    for num in nums:
      if enable[num]:
        hoge = True
        break
    if hoge:
      break
cs = []
while n > 50:  #
  n -= key
  cs.append(str(num))
num_ans = str(f(n, 0))
print(''.join(sorted(list(num_ans) + cs)[::-1]))
### BUGGY CODE ###

import queue

n,x,y = map(int,input().split())
l = [0] * n
for z in range(n):
    q = queue.Queue()
    q.put(z)
    d = [-1] * n
    d[z] = 0
    while(not q.empty()):
        i = q.get()
        if(d[i] > 0 and i > z):l[d[i]] += 1
        j = i + 1
        if(j < n):
            if(d[j] == -1):
                d[j] = d[i] + 1
                q.put(j)
        j = i - 1
        if(j >= 0):
            if(d[j] == -1):
                d[j] = d[i] + 1
                q.put(j)
        if(i == x - 1):
            j = y - 1
            if(d[j] == -1):
                d[j] = d[i] + 1
                q.put(j)
for i in range(1,n):print(l[i])

### FIXED CODE ###

import queue

n,x,y = map(int,input().split())
x -= 1
y -= 1
l = [0] * n
for i in range(n):
    for j in range(i+1,n):
        d = min([abs(j-i),abs(x-i)+1+abs(j-y),abs(y-i)+1+(j-x)])
        l[d] += 1
for i in range(1,n):print(l[i])
### BUGGY CODE ###

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

index = [0] *(N+1)

for i in range(N-2):
  if S[i:i+2] == 'AC':
    index[i] = 1

for _ in range(Q):
  l, r = map(int,input().split())
  print(sum(index[l-1:r-1]))

### FIXED CODE ###

N,Q = map(int,input().split())
S = input()
index = [0] *(N+1)
for i in range(N):
  index[i+1] = index[i] + (1 if S[i:i+2] =='AC' else 0)
for _ in range(Q):
  r, l = map(int,input().split())
  print(index[l-1] - index[ r -1])
### BUGGY CODE ###

N=int(input())
S={input()}
for i in range(N-1):
    S=S^{input()}
print(len(S))

### FIXED CODE ###

N=int(input())
S=set()
for i in range(N):
    S^={input()}
print(len(S))
### BUGGY CODE ###

n,m=map(int,input().split())
ll=[input().split() for _ in range(m)]
la=list({p for p,s in ll if s=='AC'})
a=len(la);lf=[1]*a;d={};w=0
for p,s in ll:
  if p in la and lf[la.index(p)]:
    if s=='WA': d[p]=d.get(p,0)+1
    else: w+=d.get(p,0); lf[la.index(p)]=0
print(a,w)

### FIXED CODE ###

n, m = map(int, input().split())

lac = [0] * n
lwa = [0] * n

for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if lac[p] == 0:
        if s == 'WA':
            lwa[p] += 1
        if s == 'AC':
            lac[p] = 1

lwa = [x * y for x, y in zip(lac, lwa)]
print(sum(lac), sum(lwa))
### BUGGY CODE ###

import sys
S =input()
Q=int(input())
orders=[]
for line in sys.stdin.readlines():
    orders.append(line.rstrip().split(" "))
dire=1
for order in orders:
    if order[0]=="1":
        dire=dire*(-1)
    elif order[0]=="2" and order[1]=="1":
        if dire==-1:
            S=S+order[2]
        if dire==1:
            S=order[2]+S
    elif order[0]=="2" and order[1]=="2":
        if dire==1:
            S=S+order[2]
        if dire==-1:
            S=order[2]+S
if dire==1:
    print(S)
elif dire==-1:
    S=S[::-1]
    print(S)

### FIXED CODE ###

import sys
S =input()
Q=int(input())
orders=[]
for line in sys.stdin.readlines():
    orders.append(line.rstrip().split(" "))
dire=1
right=""
left=""
center=""
for order in orders:
    if order[0]=="1":
        dire=dire*(-1)
        center=right
        right=left
        left=center
    elif order[0]=="2" and order[1]=="1":
        if dire==1:
            left=order[2]+left
        if dire==-1:
            left=left+order[2]
    elif order[0]=="2" and order[1]=="2":
        if dire==1:
            right=right+order[2]
        if dire==-1:
            right=order[2]+right
if dire==1:
    S=S
    right=right
    left=left
elif dire==-1:
    S=S[::-1]
    right=right[::-1]
    left=left[::-1]
print(left+S+right)
### BUGGY CODE ###

for a in iter(input,'0 0'):
 m=[input()for _ in[0]*int(a.split()[0])]
 y=x=0;s={(0,0)}
 while'.'!=m[y][x]:
  u,v=x,y
  c=m[y][x]
  if c=='>':x+=1;
  if c=='v':y+=1;
  if c=='<':x-=1;
  if c=='^':y-=1;
  if c=='.':print(x,y);break
  else:s|={(x,y)}
 else:print('LOOP')


### FIXED CODE ###

for a in iter(input,'0 0'):
 m=[input()for _ in[0]*int(a.split()[0])]
 y=x=0;s={(0,0)}
 while 1:
  c=m[y][x]
  if'>'==c:x+=1;
  if'v'==c:y+=1;
  if'<'==c:x-=1;
  if'^'==c:y-=1;
  if'.'==c:print(x,y);break
  if(x,y)in s:print('LOOP');break
  else:s|={(x,y)}
### BUGGY CODE ###

def main():
    N = int(input())
    X = int(input(), 2)

    def popcount(num):
        return bin(num).count("1")
    popc_X = popcount(X)
    pop_table = {}
    for i in range(1, N+1):
        pop_table[i] = popcount(i)
    
    def f(x, factor):
        temp = x
        count = 0
        while temp > 0:
            if temp > N:
                # print(temp, popc_X)
                temp = temp % (popc_X + factor)
                count += 1
                # print(temp)
                continue
            temp = temp % pop_table[temp]
            count += 1
        return count
    
    ans = [0]*N
    for i in range(0, N):
        xi = X ^ (1 << i)
        # print(xi, "xi")
        if xi & (1<<i):
            factor = 1
        else:
            factor = -1
        ans[N-i-1] = f(xi, factor)
    for a in ans:
        print(a)
main()

### FIXED CODE ###

N=int(input())
X=input()
num_X = int(X, base=2)
pop_x = X.count("1")
if pop_x <= 1:
    mod0 = pop_x + 1
    res0 = num_X % mod0
else:
    mod1 = pop_x - 1
    mod0 = pop_x + 1
    res1 = num_X % (mod1)
    res0 = num_X % (mod0)

# pops = [0]*(N+20)
for i in range(N):
    tmp = 0
    if X[i] == "0":
        # +
        tmp = (res0 + pow(2, N-i-1, mod0))%mod0
    else:
        if pop_x == 1:
            print(0)
            continue
        tmp = (res1 - pow(2, N-i-1, mod1))%mod1
    
    if tmp == 0:
        print(1)
        continue
    cnt = 1
    while tmp != 0:
        pop = bin(tmp).count("1")
        tmp %= pop
        cnt += 1
    print(cnt)
### BUGGY CODE ###

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

ans = 0
for i in range(n):
    if p[i] <= min(p[0:i+1]):
        ans += 1
print(ans)


### FIXED CODE ###

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

ans = 0
p_min = p[0]
for i in range(n):
    if p[i] <= p_min:
        ans += 1
        p_min = p[i]
print(ans)
### BUGGY CODE ###

N = int(input())
*A, = map(int, input().split())
C = [0]*4
for a in A:
    C[a] += 1

c1, c2, c3 = C[1:]
dp = [[[0]*(c1+c2+c3+1) for i in range(c2+c3+2)] for j in range(c3+2)]
for c in range(c3+1):
    M1 = c2+c3-c
    T = dp[c-1]
    S = dp[c]
    for b in range(M1+1):
        M2 = N-b-c
        X = S[b-1]; Y = S[b]
        Z = T[b+1]
        for a in range(M2==N, M2+1):
            r = N
            if a:
                r += a*Y[a-1]
            if b:
                r += b*X[a+1]
            if c:
                r += c*Z[a]
            Y[a] = r / (a+b+c)
print("%.10f" % dp[c3][c2][c1])

### FIXED CODE ###

N = int(input())
*A, = map(int, input().split())
C = [0]*4
for a in A:
    C[a] += 1

c1, c2, c3 = C[1:]
dp = [[[0]*(c1+c2+c3+1) for i in range(c2+c3+2)] for j in range(c3+2)]
for c in range(c3+1):
    M1 = c2+c3-c
    T = dp[c-1]
    S = dp[c]
    for b in range(M1+1):
        M2 = N-b-c
        X = S[b-1]; Y = S[b]
        Z = T[b+1]
        for a in range(M2==N, M2+1):
            r = N
            if a:
                r += a*Y[a-1]
            if b:
                r += b*X[a+1]
            if c:
                r += c*Z[a]
            Y[a] = r / (a+b+c)
print("%.10f" % dp[c3][c2][c1])
### BUGGY CODE ###

N = int(input())
a_list = [int(x) for x in input().split()]
cnt = 0
b_list = []
for i in range(len(a_list), 0, -1):
    if ( a_list[i-1] != len(list(filter(lambda b: b%i == 0, b_list))) %2):
        b_list.append(i)
M = len(b_list)
print(M)
if (M>0):
    print(" ".join([str(b) for b in b_list]))


### FIXED CODE ###

N = int(input())
a_list = [int(x) for x in input().split()]
cnt = 0
b_list = set()
for i in range(len(a_list), 0, -1):
    tmp = 0
    for j in range(i*2, N+1, i):
        tmp ^= (j in b_list)
    if (tmp != a_list[i-1]):
        b_list.add(i)
M = len(b_list)
print(M)
if (M>0):
    print(" ".join([str(b) for b in b_list]))
### BUGGY CODE ###

N = int(input())
cc = []
for i in range(N):
  a = input()
  if a in  cc:
    continue
  cc.append(a)
print(len(cc))

### FIXED CODE ###

N = int(input())
cc = []
for i in range(N):
  a = input()
  cc.append(a)
aa = set(cc)
print(len(aa))
### BUGGY CODE ###

from itertools import permutations, product

N = int(input())
S = list(input())

R_indices = [i for i in range(N) if S[i] == "R"]
G_indices = [i for i in range(N) if S[i] == "G"]
B_indices = [i for i in range(N) if S[i] == "B"]

count = 0
for indices_1, indices_2, indices_3 in permutations([R_indices, G_indices, B_indices]):
    j_idx_prev = -1
    for i in indices_1:
        j_idx = len(indices_2)
        ng = j_idx_prev
        while j_idx - ng > 1:
            m = (j_idx + ng) // 2
            if i < indices_2[m]:
                j_idx = m
            else:
                ng = m

        j_idx_prev = j_idx - 1
        k_idx_prev = -1
        for j in indices_2[j_idx:]:
            k_idx = len(indices_3)
            ng = k_idx_prev
            while k_idx - ng > 1:
                m = (k_idx + ng) // 2
                if j < indices_3[m]:
                    k_idx = m
                else:
                    ng = m

            k_idx_prev = k_idx - 1
            for k in indices_3[k_idx:]:
                if j - i != k - j:
                    count += 1

print(count)

### FIXED CODE ###

N = int(input())
S = list(input())

r_num = S.count("R")
g_num = S.count("G")
b_num = S.count("B")

count = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        k = j * 2 - i
        if k >= N:
            continue
        si, sj, sk = S[i], S[j], S[k]
        if si != sj and sj != sk and sk != si:
            count += 1

print(r_num * g_num * b_num - count)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(100000)
N, M = map(int, input().split())
Bridge= [[int(i) for i in input().split()] for _ in range(M)]
Parent = [int(i) for i in range(N)]
Rank = [1] * N

def find(x):
    if x == Parent[x]: return x
    else:
        Parent[x] = find(Parent[x])
        return Parent[x]

def unite(x, y):
    rx, ry = find(x), find(y)
    if rx == ry: return
    Parent[rx] = ry
    Rank[ry] += Rank[rx]
    

def same(x, y):
    return find(x) == find(y)

Total = N * (N - 1) // 2
Ans = str(Total)
for i in reversed(range(1, M)):
    A, B = Bridge[i]
    A -= 1
    B -= 1
    if not same(A, B):
        Total -= Rank[find(A)] * Rank[find(B)]
        unite(A, B)
    Ans = str(Total) + "\n" + Ans  

print(Ans)

### FIXED CODE ###

N, M = map(int, input().split())
Bridge= [[int(i) for i in input().split()] for _ in range(M)]
Parent = [int(i) for i in range(N)]
Rank = [1] * N
 
def find(x):
    if x == Parent[x]: return x
    else:
        Parent[x] = y = find(Parent[x])
        return y
 
def unite(x, y, Total):
    rx, ry = find(x), find(y)
    if rx == ry: return Total
    else:
      Total -= Rank[rx] * Rank[ry]
      if Rank[rx] < Rank[ry]:
        Parent[rx] = ry
        Rank[ry] += Rank[rx]
      else:
        Parent[ry] = rx
        Rank[rx] += Rank[ry]
      return Total
 
Total = N * (N - 1) // 2
Ans = [Total] * M
for i in reversed(range(1, M)):
    A, B = Bridge[i]
    Total = unite(A-1, B-1, Total)
    Ans[i-1] = Total  
 
print("\n".join(map(str, Ans)))
### BUGGY CODE ###

from sys import stdin

gets = stdin.readline


def main():
    n = int(gets())
    h, w = 3500, 0
    flag = False
    for _ in range(3500):
        h -= 1
        w = h
        for _ in range(h):
            y = (4 * h * w - n * (h + w))
            if y > 0:
                modulo = n % y * h % y * w % y
                if modulo % y == 0:
                    print(h, w, (n*h*w)//y)
                    flag = True
                    break
            w -= 1
        if flag:
            break
    return


if __name__ == "__main__":
    main()


### FIXED CODE ###

from sys import stdin

gets = stdin.readline


def main():
    n = int(gets())
    h, w = 0, 0
    flag = False
    for _ in range(3500):
        h += 1
        w = 0
        for _ in range(3500):
            w += 1
            y = (4 * h * w - n * (h + w))
            if y > 0:
                modulo = n % y * h % y * w % y
                if modulo % y == 0:
                    print(h, w, (n*h*w)//y)
                    flag = True
                    break
        if flag:
            break
    return


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

# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


N = z()
for n in range(1, N + 1):
    ans = 0
    for x in range(1, 51):
        for y in range(1, 51):
            for z in range(1, 51):
                if(x**2+y**2+z**2+x*y+y*z+x*z == n):
                    ans += 1
    print(ans)

# for x,y,z in itertools.product()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from itertools import accumulate
import copy


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()


def C(line):
    return [sys.stdin.readline()[:-1] for _ in range(line)]


N = z()
ans = [0]*N
for x in range(1, 105):
    for y in range(1, 105):
        for z in range(1, 105):
            if(x**2+y**2+z**2+x*y+y*z+x*z <= N):
                ans[x**2+y**2+z**2+x*y+y*z+x*z - 1] += 1
for i in ans:
    print(i)
### BUGGY CODE ###

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

ans = float('inf')
for i in range(1, N):
    x = sum(A[:i])
    y = sum(A[i:])
    d = abs(x-y)
    ans = min(ans, d)

print(ans)

### FIXED CODE ###

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

ans = float('inf')
s = sum(A)
x = A[0]
y = s - x
d = abs(x-y)
ans = min(ans, d)

for i in range(1, N-1):
    x += A[i]
    y = s - x
    d = abs(x-y)
    ans = min(ans, d)

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

N = int(input())
S = input()
ans = 0
for i in range(1000):
    e = str(i).zfill(3)
    c = 0
    for s in S:
        if s == e[c]:
            c += 1
            if c == 3:
                ans += 1
                break
print(ans)

### FIXED CODE ###

N = int(input())
S = input()
ans = 0
for i in range(1000):
    e = str(i).zfill(3)
    c = 0
    for s in S:
        if s == e[c]:
            c += 1
            if c == 3:
                ans += 1
                break
print(ans)
### BUGGY CODE ###

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

### FIXED CODE ###

import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N = i()
A = l()
L = []
L2 = [0]*(10**6)
for i in range(N):
    if i+A[i]+1 < 10**6:
        L.append(i+A[i]+1)
    if i-A[i]+1 >= 0 and i-A[i]+1 < 10**6:
        L2[i-A[i]+1] += 1
ans = 0
for l in L:
    ans += L2[l]
print(ans)