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

N, M = map(int, input().split())
P = map(int, input().split())

parent = list(range(N))
rank = [0] * N
key = [[i] for i in range(N)]
val = [[p-1] for p in P]

# union-find
def getRoot(x):
  p = parent[x]
  if p == x:
    return p
  ret = getRoot(p)
  parent[x] = ret
  return ret

def join(x, y):
  rx = getRoot(x)
  ry = getRoot(y)
  if rank[rx] < rank[ry]:
    parent[rx] = ry
    key[ry] += key[rx]
    val[ry] += val[rx]
  else:
    parent[ry] = rx
    key[rx] += key[ry]
    val[rx] += val[ry]
    if rank[rx] == rank[ry]:
      rank[rx] += 1

for _ in range(M):
  x, y = map(int, input().split())
  join(x-1, y-1)

ans = 0
for i in range(N):
  if parent[i] == i:
    ans += len(set(key[i]).intersection(set(val[i])))

print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
P = list(map(int, input().split()))

parent = list(range(N))
rank = [0] * N

idx = [None] * N
for i in range(N):
  idx[P[i]-1] = i

# union-find
def getRoot(x):
  p = parent[x]
  if p == x:
    return p
  ret = getRoot(p)
  parent[x] = ret
  return ret

def join(x, y):
  rx = getRoot(x)
  ry = getRoot(y)
  if rank[rx] < rank[ry]:
    parent[rx] = ry
  else:
    parent[ry] = rx
    if rank[rx] == rank[ry]:
      rank[rx] += 1

for _ in range(M):
  x, y = map(int, input().split())
  join(x-1, y-1)

ans = 0
for i in range(N):
  if getRoot(i) == getRoot(idx[i]):
    ans += 1

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

S = input()
listS = list(S)
done = False

x = 0
n = 0

while not done:
	for i in range(len(listS)-1):
		if listS[i] == "B" and listS[i+1] == "W":
			listS[i] = "W"
			listS[i+1] = "B"
			x += 1
			n += 1

	if x == 0:
		print(n)
		done = True
	x = 0


### FIXED CODE ###

s = input()
s = list(s)


w_sum = 0
w_n = 0
for i, c in enumerate(s):
    if c == "W":
        w_sum += i
        w_n += 1
    
print(w_sum - w_n*(w_n-1)//2)
### BUGGY CODE ###

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

# 山1に降った雨の量を二分探索する
upper = 2 * (10 ** 9)
lower = 0

ansList = []
while True:
    half = (upper + lower) // 2
    if half % 2 == 1:
        half += (upper + lower) % 2
    tmp = half
    ansList = [half]
    for i, a in enumerate(A):
        tmp = 2 * (a - tmp//2)
        if i == N-1:
            if tmp == ansList[0]:
                break
            else:
                ansList = []
                if i % 2 == 0:
                    upper = half
                else:
                    lower = half
                break
        else:
            if tmp < 0:
                if i % 2 == 0:
                    upper = half
                else:
                    lower = half
                ansList = []
                break
            else:
                ansList.append(tmp)
    if len(ansList) == N:
        break
ansList = [str(a) for a in ansList]
ans = ' '.join(ansList)
print(ans)

### FIXED CODE ###

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

S = sum(A)
x1 = S - 2 * sum([A[i] for i in range(len(A)) if i % 2 == 1])
ansList = [x1]
for i in range(1, N):
    tmp = 2 * A[i-1] - ansList[-1]
    ansList.append(tmp)
ansList = [str(a) for a in ansList]
ans = ' '.join(ansList)
print(ans)
### BUGGY CODE ###

N, M = map(int, input().split())
S = 1
for i in range(1, M // N + 1):
  if M % i == 0:
    S = i
print(S)

### FIXED CODE ###

N, M = map(int, input().split())
S = 1
p = 0
X = []
for i in range(2, int(M ** (1/2)) + 1):
  if M % i == 0:
    if i <= M // N:
      p = i
      X.append(i)
    else:
      break
if M // N <= int(M ** (1/2)):
  if p != 0:
    S = p
else:
  if p != 0:
    S = M
    q = 0
    while S > M // N:
      S = M // X[q]
      if S <= M // N:
        break
      q += 1
      if q == len(X):
        break
    if q == len(X):
      S = max(X)
print(S)
### BUGGY CODE ###

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

cur = 0
x = 0
while True:
    pre = cur
    ans = [0 for _ in range(n)]
    ans[0] = cur
    for i in range(n-1):
        cur = a[i] * 2 - cur
        ans[i+1] = cur
        if cur < 0:
            break
    if a[-1] * 2 == cur + pre:
        print(" ".join(list(map(str, ans))))
        break
    x += 1
    cur = x * 2


### FIXED CODE ###

# (d1+d2)/2 == n1, (d2+d3)/2 == n2... が矛盾なくなるようにする
# にぶたんを使う
# なんかしらんけど3問駄目だな...

n = int(input())
dum = list(map(int, input().split()))
count = 0
l, r = 0, (10 ** 10) // 2

while l < r:
    mid = (l + r) // 2
    # print(l, r, mid)
    rain = [0 for _ in range(n)]
    rain[0] += mid * 2
    for i in range(1, n):
        next_amount = (dum[i - 1] - (rain[i - 1] // 2)) * 2
        rain[i] += next_amount
    # print(rain)

    if dum[-1] == (rain[-1] + rain[0]) // 2:
        rain = list(map(str, rain))
        print(" ".join(rain))
        exit()
    if (rain[0] + rain[-1]) // 2 < dum[-1]:
        # 最初に決めたやつが小さすぎた
        # print("{} は小さすぎた".format(rain[0]))
        l = mid + 1
    else:
        # 最初に決めたやつが大きすぎた
        # print("{} は大きすぎた".format(rain[0]))
        r = mid

    # セーフティネット 必要ないけど
    if count > 50:
        t = 5 / 0
        break
    count += 1

"""
7
110 50 53 50 11 36 88

11
38 7 15 15 9 31 23 1 5 55 81
"""
### BUGGY CODE ###

N = int(input())

s = [sorted(input()) for i in range(N)]
    

c = [s[i+1:].count(elm) for i, elm in enumerate(s)]
    

print(sum(c))


### FIXED CODE ###

N = int(input())

s = ["".join(sorted(input())) for i in range(N)]

count = 0
d = {}
for elm in s:
    if elm in d:
        count += d[elm]
        d[elm] += 1
    else:
        d[elm] = 1

print(count)
### BUGGY CODE ###

N = int(input())
S = input()
L = [[] for i in range(3)]
for i in range(len(S)):
    if S[i] == 'R':
        L[0].append(i)
    elif S[i] == 'G':
        L[1].append(i)
    else:
        L[2].append(i)
ans = 0

for i in range(3):
    for j in range(3):
        if i == j:
            continue
        for k in range(3):
            if i == k or j == k:
                continue
            for a in range(len(L[i])):
                for b in range(len(L[j])):
                    if L[i][a] <= L[j][b]:
                        for c in range(len(L[k])):
                            if L[j][b] <= L[k][c] and L[j][b] - L[i][a] != L[k][c] - L[j][b]:
                                ans += 1

print(ans)

### FIXED CODE ###

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

RN = S.count('R')
GN = S.count('G')
BN = S.count('B')

ans = RN * GN * BN

for i in range(N):
    for d in range(N):
        j = i + d
        k = i + 2 * d
        if k >= N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ans -= 1

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

import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    N,M = LI()
    p = [LI() for _ in range(M)]

    p.sort()

    r = [[] for _ in range(N+1)]
    x = []
    d = 0
    j = 0
    for i in range(1,N+1):
        while j < M and p[j][0] == i:
            x.append(d + p[j][2])
            r[p[j][1]].append(d + p[j][2])
            j += 1
        for z in r[i]:
            x.remove(z)
        if i == N: break
        if x == []:
            print(-1)
            return
        else:
            d = min(x)
    print(d)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys,queue,math,copy,itertools,bisect,collections,heapq

class Node:
    def __init__(self,x):
        self.data = x
        self.left = None
        self.right = None

def insert(node,x):
    if node is None: return Node(x)
    elif x < node.data:
        node.left = insert(node.left,x)
    else:
        node.right = insert(node.right,x)
    return node

def search_min(node):
    if node.left is None: return node.data
    return search_min(node.left)

def delete_min(node):
    if node.left is None: return node.right
    node.left = delete_min(node.left)
    return node

def delete(node,x):
    if node:
        if x == node.data:
            if node.left is None:
                return node.right
            elif node.right is None:
                return node.left
            else:
                node.data = search_min(node.right)
                node.right = delete_min(node.right)
        elif x < node.data:
            node.left = delete(node.left,x)
        else:
            node.right = delete(node.right,x)
    return node


def main():
    sys.setrecursionlimit(10**7)
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    N,M = LI()
    p = [LI() for _ in range(M)]

    p.sort()

    r = [[] for _ in range(N+1)]
    d = 0
    j = 0
    root = None
    for i in range(1,N):
        update = False
        while j < M and p[j][0] == i:
            root = insert(root,d + p[j][2])
            update = True
            r[p[j][1]].append(d + p[j][2])
            j += 1
        for z in r[i]:
            root = delete(root,z)
            update = True
        if root == None:
            print(-1)
            return
        if update:
            d = search_min(root)
    print(d)

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

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

b_counter = 0
total = 0
count = 0
color = "test"


while total < n:
  count += 1
  if (count % 2) == 1: #blue
    color="B"
    b_counter += a
    total += a
  else: #red
    color = "R"
    total += b
    
if color == "B":
  b_counter = b_counter - (total - n)
  print(b_counter)
else:
  print(b_counter)

### FIXED CODE ###

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

if (a+b) == 0:
  print(0)
else:
  trial_num = n // (a + b)
  amari = n % (a + b)
  
  if a == 0:
    print(0)
  else:
    if a <= amari:
      print(trial_num*a + a)
    else:
      print(trial_num*a + amari)
### BUGGY CODE ###

n = int(input())
al = list(map(int, input().split()))
ansl = [0]*n

for i,youso in enumerate(al):
    for j in range(n):
        if i == j:
            continue
        else:
            ansl[j] ^= youso 


print(' '.join(map(str, ansl)))

### FIXED CODE ###

from functools import reduce
n = int(input())
al = list(map(int, input().split()))
ansl = [0]*n
test_list = al
  
# printing original list 

  
# List XOR 
# Using reduce() + lambda + "^" operator 
res = reduce(lambda x, y: x ^ y, test_list) 
  
# printing result  
sum = res
for i in range(n):
    ansl[i] = res^al[i]

"""
for i,youso in enumerate(al):
    for j in range(n):
        if i == j:
            continue
        else:
            ansl[j] ^= youso 

"""
print(' '.join(map(str, ansl)))
### BUGGY CODE ###

from collections import deque
N,M,K = (int(x) for x in input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
CD = [list(map(int, input().split())) for _ in range(K)]
friends = [set() for _ in range(N)]
blocks = [set() for _ in range(N)]
searched = [0] * N
ans = [0] * N
d = deque()
for x, y in AB:
    friends[x-1].add(y-1)
    friends[y-1].add(x-1)
for x, y in CD:
    blocks[x-1].add(y-1)
    blocks[y-1].add(x-1)
for i in range(N):
    if searched[i]:
        continue
    trace = set()
    d.append(i)
    while d:
        temp = d.popleft()
        trace.add(temp)
        searched[temp] = 1
        for x in friends[temp]:
            if searched[x] == 0:
                d.append(x)
    chain = len(trace)
    for j in trace:
        ans[j] = chain - 1 - len(trace&friends[j]) - len(trace&blocks[j])
print(*ans)

### FIXED CODE ###

from collections import deque
N,M,K = (int(x) for x in input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
CD = [list(map(int, input().split())) for _ in range(K)]
friends = [set() for _ in range(N)]
blocks = [set() for _ in range(N)]
searched = [0] * N
ans = [0] * N
d = deque()
for x, y in AB:
    friends[x-1].add(y-1)
    friends[y-1].add(x-1)
for x, y in CD:
    blocks[x-1].add(y-1)
    blocks[y-1].add(x-1)
for i in range(N):
    if searched[i]:
        continue
    trace = set()
    d.append(i)
    trace.add(i)
    searched[i] = 1
    while d:
        temp = d.popleft()
        for x in friends[temp]:
            if searched[x] == 0:
                d.append(x)
                trace.add(x)
                searched[x] = 1
    chain = len(trace)
    for j in trace:
        ans[j] = chain - 1 - len(trace&friends[j]) - len(trace&blocks[j])
print(*ans)
### BUGGY CODE ###

s = input()
l = len(s)
s = int(s)

rests = [0]*2019

d = 10**(l-1)

while s > 0:


    r = s % 2019
    rests[r] +=  1

    s = s % d
    d = d // 10

a = 0

for v in rests:
    if v >= 2:
        a += v * (v-1) // 2

a += rests[0]

print(a)





### FIXED CODE ###

from collections import defaultdict

s = input()

rests = [0]
n = 0
a = 0
m = 1
c = defaultdict(int)
c[0] += 1
for i in list(s)[::-1]:
    n = n + int(i)*m

    c[n % 2019] += 1
    m = m * 10 % 2019

for v in c.values():
    a += v * (v-1) // 2
print(a)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
from collections import deque

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

def dim1(x,y):
    return x*N+y

DP=[0]*(N*N)
for i in range(N):
    for j in range(N):
        DP[dim1(i,j)]=min(i,j,N-1-i,N-1-j)

USED=[0]*(N*N)
ANS=0

def dir4(x):
    if x-N>=0:
        yield x-N
    if x+N<N*N:
        yield x+N
    if x%N!=0:
        yield x-1
    if x%N!=N-1:
        yield x+1

for p in P:
    p-=1
    #q,r=divmod(p-1,N)
    ANS+=DP[p]
    DP[p]-=1
    USED[p]=1

    Q=deque([p])

    while Q:
        x=Q.popleft()

        for z in dir4(x):
            if USED[z]==1 and DP[z]>DP[x]:
                DP[z]=DP[x]
                Q.append(z)
                    
            elif DP[z]>DP[x]+1:
                DP[z]=DP[x]+1
                Q.append(z)
    
    #for d in DP:
    #    print(*d)
    #print(ANS)
    #print()
print(ANS)

### FIXED CODE ###

import sys
input = sys.stdin.readline

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

DP=[[0]*N for i in range(N)]
for i in range(N):
    for j in range(N):
        DP[i][j]=min(i,j,N-1-i,N-1-j)

USED=[[1]*N for i in range(N)]
ANS=0

def update(z,w):
    if 0<=z<N and 0<=w<N:
        if DP[z][w]>DP[x][y]+USED[z][w]:
            DP[z][w]=DP[x][y]+USED[z][w]
            Q.append((z,w))
    

for p in P:
    q,r=divmod(p-1,N)
    ANS+=DP[q][r]
    DP[q][r]-=1
    USED[q][r]=0

    Q=[(q,r)]

    while Q:
        x,y=Q.pop()

        update(x+1,y)
        update(x-1,y)
        update(x,y+1)
        update(x,y-1)

print(ANS)
### BUGGY CODE ###

N, K = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))
all_0 = [0 for i in range(N)]
A.sort()
F.sort()
F.reverse()
MUL = [A[i]*F[i] for i in range(N)]

def max_MUL():
    max_MUL = -1
    index = -1
    for i in range(N):
        if max_MUL<MUL[i]:
            max_MUL = MUL[i]
            index = i
        elif max_MUL==MUL[i]:
            if F[index]<F[i]:
                index = i
    return index
def Gluttony(K):
    if A == all_0:
        return 0
    while K>0:
        index = max_MUL()
        A[index]-=1
        MUL[index]=A[index]*F[index]
        K-=1
        if A == all_0:
            return 0
    return MUL[max_MUL()]

print(Gluttony(K))

### FIXED CODE ###

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

A.sort()
F.sort(reverse = True)

def solve(n):
    cnt = 0
    for i in range(N):
        cnt += max(0, A[i] - n // F[i])
    return cnt <= K

left = -1
right = 10 ** 12 + 1

while left + 1 < right:
    mid = (left + right) // 2
    if solve(mid):
        right = mid
    else:
        left = mid

print(right)
### BUGGY CODE ###

#-*-coding:utf-8-*-
 
import sys
import math
 
def main():
    n = int(input())
    root_n=math.ceil(math.sqrt(n))
    ans=[0]*n
    count=0
    for i in range(1,n+1):
        for x in range(1,root_n):
            if x**2 >= i:
                break
            for y in range(1,root_n):
                for z in range(1,root_n):
                    if x**2+y**2+z**2+x*y+y*z+z*x==i:
                        count+=1
        print(count)
        count=0
 
if __name__ == "__main__":
    main()

### FIXED CODE ###

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

import sys
import math

def main():
    n = int(input())
    root_n=math.ceil(math.sqrt(n))
    ans=[0]*n
    count=0

    for x in range(1,root_n):
        for y in range(1,root_n):
            for z in range(1,root_n):
                tmp=x**2+y**2+z**2+x*y+y*z+z*x
                if tmp<n+1:
                    ans[tmp-1]+=1
    for i in ans:
        print(i)

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

import sys

def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N,K = MI()
A = LI()
A.sort()


def f(n):  # Aiが必要か否か
    B = [0] + [A[i] for i in range(N) if i != n]
    dp = [[0]*K for _ in range(N)]  # dp[i][j] = B1~Biを用いてKを作れるか
    dp[0][0] = 1
    for i in range(1,N):
        b = B[i]
        for j in range(K):
            if j >= b:
                dp[i][j] = dp[i-1][j] | dp[i-1][j-b]
            else:
                dp[i][j] = dp[i-1][j]
    if sum(dp[N-1][j] for j in range(max(K-A[n],0),K)) != 0:
        return True
    else:
        return False


left = -1  # 不必要
right = N  # 必要
while left + 1 < right:
    mid = (left + right)//2
    if f(mid):
        right = mid
    else:
        left = mid

print(right)


### FIXED CODE ###

import sys

def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N,K = MI()
A = LI()
A.sort()


def f(n):  # Anが必要か否か
    B = [0] + [A[i] for i in range(N) if i != n]
    dp = [[0]*K for _ in range(2)]  # dp[i][j] = B1~Biを用いてjを作れるか(メモリ節約のため工夫してる)
    dp[0][0] = 1
    for i in range(1,N):
        b = B[i]
        for j in range(K):
            if j >= b:
                dp[i%2][j] = dp[1-i%2][j] | dp[1-i%2][j-b]
            else:
                dp[i%2][j] = dp[1-i%2][j]
    if sum(dp[(N-1) % 2][j] for j in range(max(K-A[n],0),K)) != 0:
        return True
    else:
        return False


left = -1  # 不必要
right = N  # 必要
while left + 1 < right:
    mid = (left + right)//2
    if f(mid):
        right = mid
    else:
        left = mid

print(right)
### BUGGY CODE ###

from math import floor
A,B,N = map(int,input().split())
ans = 0
if B <=  N:
  for x in range(B-1,N+1,B):
    ans = max(ans, floor(A*x/B) - A*floor(x/B))
else:
  ans = floor((A*N)/B) - A*floor(N/B)
print(ans)

### FIXED CODE ###

from math import floor
A,B,N = map(int,input().split())
ans = 0
if B <=  N:
  ans = floor(A*(B-1)/B) - A*floor((B-1)/B)
else:
  ans = floor((A*N)/B) - A*floor(N/B)
print(ans)
### BUGGY CODE ###

n=int(input(""))
ain=input("").split(" ")
a=[]
for i in range(n):
    a+=[int(ain[i])]
q=int(input(""))
c=[]
listb=[]
listc=[]
for i in range(q):
    c+=[input("").split(" ")]
    listb+=[int(c[i][0])]
    listc+=[int(c[i][1])]
    for k in range(n):
        if (a[k]==listb[i]):
            a[k]=listc[i]
    print(sum(a))
    

    


### FIXED CODE ###

n=int(input(""))
ain=input("").split(" ")
a={1:0,}
c=[]
for i in range(n):
    c+=[int(ain[i])]
s=sum(c)
for i in range(n):
    if (c[i] in a):
        a[c[i]]+=1
    else:
        a[c[i]]=1
q=int(input(""))
c=[]

for i in range(q):
    c=input("").split(" ")
    bb=int(c[0])
    cc=int(c[1])
    if (bb in a and a[bb]!=0):
        s+=(cc-bb)*a[bb]
        if (cc in a):
            a[cc]+=a[bb]
        else:
            a[cc]=a[bb]
        a[bb]=0
                              
    print(s)
### 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()
List = [0 for _ in range(N)]
num = 0
for k in range(1,N):
  if S[k-1] == "A" and S[k] == "C":
    num += 1
  List[k] = num
  
for i in range(Q):
  l , r = map(int, input().split())
  print(List[r-1]-List[l-1])
### BUGGY CODE ###

import itertools

def func(x,y,z):
    return x**2+y**2+z**2+x*y+y*z+z*x

n = int(input())
nums = list(range(1,100))
arr = []
ans = 0
i = 0
p = itertools.product(nums,nums)

for com in itertools.product(nums, repeat=3):
    # print(com)
    ans = func(com[0],com[1],com[2])
    arr.append(ans)

for i in range(n):
    print(arr.count(i+1))

### FIXED CODE ###

import itertools
import math
import collections
def main():
    n = int(input())
    s = int(math.sqrt(n))
    a = list(itertools.product(range(1,s),repeat=3))
    ans = []
    for i in range(len(a)):
        t = a[i][0] ** 2 + a[i][1] ** 2 + a[i][2] ** 2 + a[i][0] * a[i][1] + a[i][1] * a[i][2] + a[i][2] * a[i][0]
        ans.append(t)
        # print(ans)
    c = collections.Counter(ans)
    for i in range(1,n+1):
        print(c[i])
        
        
main()
### BUGGY CODE ###

N, M, Q = [int(v) for v in input().split()]
L = []
R = []
p = []
q = []
for i in range(M):
    a, b = [int(v) for v in input().split()]
    L.append(a)
    R.append(b)
for i in range(Q):
    a, b = [int(v) for v in input().split()]
    p.append(a)
    q.append(b)

for i in range(Q):
    ans = 0
    for j in range(M):
        if p[i] <= L[j] and R[j] <= q[i]:
            ans += 1
    print(ans)

### FIXED CODE ###

N, M, Q = [int(v) for v in input().split()]
p = []
q = []
x = [[0] * (N+1) for i in range(N+1)]
c = [[0] * (N+1) for i in range(N+1)]

for i in range(M):
    l, r = [int(v) for v in input().split()]
    x[l][r] += 1
for i in range(1, N+1):
    for j in range(1, N+1):
        c[i][j] = c[i][j-1] + x[i][j]
for i in range(Q):
    a, b = [int(v) for v in input().split()]
    p.append(a)
    q.append(b)

for i in range(Q):
    ans = 0
    for j in range(p[i], q[i]+1):
        ans += c[j][q[i]] - c[j][p[i]-1]
    print(ans)
### BUGGY CODE ###

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

a_p = [0]*n
a_m = [0]*n
ans = 0

for i in range(n):
    a_p[i] = a[i] + i+1
    a_m[i] = i+1 -a[i]

ans = 0
for i in range(n):
    for j in range(i+1,n):
        if a_p[i] == a_m[j]:
            ans = ans + 1

print(ans)

### FIXED CODE ###

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

ans = 0
dp = dict()

for i in range(n):
    a_p = a[i] + i+1
    a_m = i+1 -a[i]
    if a_p in dp:
        dp[a_p] = dp[a_p] + 1
    else:
        dp[a_p] = 1
    if a_m in dp:
        ans = ans + dp[a_m]


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

N,K = map(int,input().split())
x = list(map(int,input().split()))
if K==1 and (0 in x):
    print(0)
else:
    if 0 in x:
        pass
    else:
        K += 1
        counter = 0
        for i in x:
            if i > 0:
                break
            else:
                counter += 1
        x.insert(counter,0)

    result = 10000000000000000000
    g,s = x.index(0),x.index(0)-K+1
    while (not s>x.index(0)):
        if s<0 or g>(len(x)-1):
            s += 1
            g += 1
            continue
        else:
            ad_1 = 2*(-x[s]) + x[g]
            ad_2 = -x[s] + 2*(x[g])
            result = min(ad_1,ad_2,result)
            s += 1
            g += 1
    print(result)

### FIXED CODE ###

N,K = map(int,input().split())
x = list(map(int,input().split()))

result = []
for i in range(N-K+1):
    s,g = i,i+K-1
    result.append(abs(x[s]) + abs(x[s] - x[g]))
    result.append(abs(x[g]) + abs(x[g] - x[s]))
result.sort()
print(result[0])
### BUGGY CODE ###

x,y,a,b,c=map(int,input().split()) #x,yだけ見る。
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
s=sorted(p+q+r, reverse=True)
cntr,cntg,ans=0,0,0
for i in range(a+b+c):
    if cntr<x and (s[i] in set(p) or s[i] in set(r)):
        ans+=s[i]
        cntr+=1
    elif cntg<y and (s[i] in set(q) or s[i] in set(r)):
        ans+=s[i]
        cntg+=1
print(ans)

### FIXED CODE ###

x,y,a,b,c=map(int,input().split()) #x,yだけ見る。
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p=sorted(p,reverse=True)[:x]
q=sorted(q,reverse=True)[:y]
print(sum(sorted(p+q+r, reverse=True)[:x+y]))