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

import sys

input = sys.stdin.readline

def search(r):
    while root[r] != r: r = root[r]
    return r
        
N, M = map(int, input().split())
p = list(map(int, input().split()))

root = {i:i for i in range(1, N+1)}
size = {i:1 for i in range(1, N+1)}

for i in range(M):
    x, y = map(int, input().split())
    x, y = p[x-1], p[y-1]
    
    x_r, y_r = search(x), search(y)
    if x_r == y_r: continue

    root[x_r] = y_r
    size[y_r] += size[x_r]
    
ans = 0

for i, j in enumerate(p):
    if search(i+1) == search(j): ans += 1
print(ans)

### FIXED CODE ###

def find(x):
    while union[x] != x:
        x = union[x]
        
    return x

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

union = [i for i in range(N+1)]

for i in range(M):
    x, y = map(int, input().split())
    x = find(x)
    while union[y] != y:
        union[y], y = x, union[y]
        
    union[y] = x
    
ans = 0
for idx, n in enumerate(p):
    if idx+1 == n:
        ans += 1
    else:
        x, y = find(idx+1), find(n)
        if x == y:
            ans += 1
        
print(ans)
### BUGGY CODE ###

n = int(input())
a = sorted(list(map(int, input().split())))
while True:
    a = sorted(list(set(a)))
    tmp = sorted(a[:20])
    for i in tmp:
        if i == a[0]:
            continue
        elif i % a[0] == 0:
            a.remove(i)
        else:
            a.append(i % a[0])
            a.remove(i)
    if len(a) == 1:
        break
print(a[0])


### FIXED CODE ###

n = int(input())
a = sorted(list(map(int, input().split())))
while True:
    a = sorted(list(set(a)))
    tmp = sorted(a[:])
    for i in tmp:
        if i == a[0]:
            continue
        elif i % a[0] == 0:
            a.remove(i)
        else:
            a.append(i % a[0])
            if i % a[0] == 1:
                print(1)
                exit()
            a.remove(i)
    if len(a) == 1:
        break
print(a[0])
### BUGGY CODE ###

n=int(input())
l=list(map(int,input().split()))
ans=[0]*n

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

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
b = [[0,0] for i in range (n)]
c = []
for i in range(n):
    b[i][1] = a[i]
    b[i][0] = i+1
b.sort(key=lambda x:x[1])
for i in range(n):
    c.append(b[i][0])
print(*c)
### BUGGY CODE ###

import sys
from collections import deque
from bisect import bisect_left as bisect
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def main():
    N = int(input())
    A = inpl()
    edges = [[] for _ in range(N + 1)]
    for _ in range(N - 1):
        u, v = inpl()
        edges[u].append(v)
        edges[v].append(u)
    DPs = [[]] * (N + 1)

    Q = deque()
    Q.append(1)
    parent = [-1] * (N + 1)
    parent[1] = 0
    while Q:
        nv = Q.popleft()
        DPs[nv] = DPs[parent[nv]].copy()
        t = bisect(DPs[nv], A[nv - 1])
        if t >= len(DPs[nv]):
            DPs[nv].append(A[nv - 1])
        else:
            DPs[nv][t] = A[nv - 1]

        for kouho in edges[nv]:
            if parent[kouho] == -1:
                Q.append(kouho)
                parent[kouho] = nv

    for i in range(1, N + 1):
        print(len(DPs[i]))
    # print(edges)
    # print(parent)
    # print(DPs)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from bisect import bisect_left as bisect
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


class solve:
    def __init__(self, N):
        self.ans = [0] * N
        self.DP = []

    def recur(self, i, pi=-1):
        # DPテーブルを更新し、答えを求める。
        # また、巻き戻す値を覚える。
        rev_i = bisect(self.DP, self.A[i])
        if rev_i == len(self.DP):
            self.DP.append(self.A[i])
            rev_v = None
        else:
            rev_v = self.DP[rev_i]
            self.DP[rev_i] = self.A[i]

        self.ans[i] = len(self.DP)

        for nv in self.edges[i]:
            if nv != pi:
                self.recur(nv, i)

        # 巻き戻す。.
        if rev_v is None:
            self.DP.pop()
        else:
            self.DP[rev_i] = rev_v

        return


def main():
    N = int(input())
    S = solve(N)
    S.A = inpl()
    S.edges = [[] for _ in range(N)]
    for _ in range(N - 1):
        u, v = inpl()
        S.edges[u - 1].append(v - 1)
        S.edges[v - 1].append(u - 1)

    S.recur(0)

    print(*S.ans, sep='\n')
    # print(edges)
    # print(parent)
    # print(DPs)


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

A, B, K = map(int, input().split())

for i in range(K):
    if A>=1:
        A=A-1
    else:
        if B>=1:
            B=B-1
        else:
            pass
print(A, B)

### FIXED CODE ###

A, B, K = map(int, input().split())

if A-K >= 0:
    print(A-K, B)
elif A-K < 0:
    if B-(K-A)>=0:
        print(0, B-(K-A))
    else:
        print(0, 0)
### BUGGY CODE ###

from collections import deque
import sys 
sys.setrecursionlimit(10**5)
n, m = map(int, input().split())
adjacent_list = [[] for i in range(n+1)]
not_root = set()
for i in range(m):
    x, y = map(int, input().split())
    not_root.add(y)
    adjacent_list[x].append(y)
root_cand = set(list(range(1, n+1))) - not_root
root_cand = deque(root_cand)
dp = [0] * (n+1)
def dfs(node, count):
    dp[node] = max(dp[node], count + 1)
    if len(adjacent_list[node]) != 0:
        for i in adjacent_list[node]:
            dfs(i, dp[node])

while len(root_cand) != 0:
    root = root_cand.pop()
    dfs(root, -1)
print(max(dp))


### FIXED CODE ###

from collections import deque
import sys 
input = sys.stdin.readline
sys.setrecursionlimit(10**5)
n, m = map(int, input().split())
adjacent_list = [[] for i in range(n+1)]
not_root = set()
for i in range(m):
    x, y = map(int, input().split())
    not_root.add(y)
    adjacent_list[x].append(y)
dp = [-1 for i in range(n+1)]
def cul(x):
    if dp[x] != -1:
        return dp[x]
    else:
        if len(adjacent_list[x]) == 0:
            return 0
        dp[x] = max([cul(i) + 1 for i in adjacent_list[x]])
        return dp[x]
for i in range(1,n+1):
    cul(i)
print(max(dp))
### BUGGY CODE ###

from sys import stdin, stdout

int_in = lambda: int(stdin.readline())
arr_in = lambda: [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for y in range(rows)]
str_in = lambda: stdin.readline().strip()
out = lambda o: stdout.write("{}\n".format(o))
arr_out = lambda o: out(" ".join(map(str, o)))
bool_out = lambda o: out("YES" if o else "NO")
tests = lambda: range(1, int_in() + 1)
case_out = lambda i, o: out("Case #{}: {}".format(i, o))

def divisors(n):
    i = 2
    result = set()
    while i * i <= n:
        if n % i == 0:
            result.add(i)
            result.add(n // i)
        i += 1
    return result

def solve(n, a):
    counts = {}
    for item in a:
        if item not in counts:
            counts[item] = 0
        counts[item] += 1
    if 1 in counts:
        return 1 if counts[1] == 1 else 0
    items_in_a = set(a)
    result = 0
    for item in a:
        if counts[item] == 1:
            d = divisors(item)
            if len(items_in_a.intersection(d)) == 0:
                result += 1
    return result


if __name__ == "__main__":
    n = int_in()
    a = arr_in()
    out(solve(n, a))

### FIXED CODE ###

from math import sqrt
from sys import stdin, stdout
out = lambda o: stdout.write("{}\n".format(o))


def solve(a):
    a.sort()
    size = a[-1] + 1

    seive = [1] * size

    seen = set()
    for item in a:
        if item in seen:
            seive[item] = 0
        seen.add(item)

    for item in a:
        for j in range(2 * item, size, item):
            seive[j] = 0

    return sum(map(lambda x: seive[x], a))


if __name__ == "__main__":
    n = int(stdin.buffer.readline())
    a = [int(x) for x in stdin.buffer.readline().split()]
    out(solve(a))
### BUGGY CODE ###

n,y=map(int,input().split())
y=y/1000
count=0
for i in range(int(y/10)+1):
    for j in range(int((y-10*i)/5)+1):
        if 10*i+5*j+n-i-j==y:
            print(str(i)+" "+str(j)+" "+str(n-i-j))
            count=1
            break
        elif 10*i+5*j+n-i-j>y:
            break
    if count==1:
        break
if count==0:
    print("-1 -1 -1")

### FIXED CODE ###

n,y=map(int,input().split())
y=y/1000
count=0
for i in range(min(int(y/10),n)+1):
    for j in range(min(int((y-10*i)/5),n-i)+1):
        if 10*i+5*j+n-i-j==y:
            print(str(i)+" "+str(j)+" "+str(n-i-j))
            count=1
            break
        elif 10*i+5*j+n-i-j>y:
            break
    if count==1:
        break
if count==0:
    print("-1 -1 -1")
### BUGGY CODE ###

import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)



def main():
    from collections import Counter
    n = int(input())
    a = list(map(int, readline().split()))

    def enum_primes(n):
        if n == 2:
            return [2]

        flag_num = (n + 1) // 2
        prime_flag = [True] * flag_num


        for i in range(1, int(n ** 0.5) + 1, 2):
            if prime_flag[i]:
                p = 2 * i + 1
                for j in range(2 * i * (i + 1), flag_num, p):
                    prime_flag[j] = False

        primes = [2]
        temp = [i * 2 + 1 for i in range(1, flag_num) if prime_flag[i]]
        primes.extend(temp)

        return primes

    nmax = max(a)

    if nmax == 1:
        print(n)
        sys.exit()

    primes = enum_primes(nmax)

    def factorization(n):
        factors = []

        for i in primes:
            while n % i == 0:
                factors.append(i)
                n //= i
        if n != 1:
            factors.append(n)

        return Counter(factors)

    a_fac = [0] * n

    for i, num in enumerate(a):
        a_fac[i] = factorization(num)

    lcm = Counter([1])

    for i, fac in enumerate(a_fac):
        add_temp = fac - lcm
        add = Counter({key: value for key, value in add_temp.items() if value > 0})
        lcm += add

    b = [0] * n
    ans = 0

    for i, fac in enumerate(a_fac):
        b_fac = lcm - fac
        temp = 1
        for key, value in b_fac.items():
            temp *= pow(key, value)
            temp %= MOD
        ans += temp
        ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import Counter
    n = int(input())
    a = list(map(int, readline().split()))

    def factorization(n):
        factors = []

        while n % 2 == 0:
            factors.append(2)
            n //= 2

        for i in range(3, int(n ** 0.5) + 5, 2):
            while n % i == 0:
                factors.append(i)
                n //= i
        if n != 1:
            factors.append(n)

        return Counter(factors)

    a_fac = [0] * n

    for i, num in enumerate(a):
        a_fac[i] = factorization(num)

    lcm = {1: 1}

    for fac in a_fac:
        for key, value in fac.items():
            lcm[key] = max(lcm.get(key, 0), value)

    ans = 0

    lcmmod = 1

    for key, value in lcm.items():
        lcmmod *= pow(key, value, MOD)
        lcmmod %= MOD

    for ele in a:
        ainv = pow(ele, MOD - 2, MOD)
        ans += ((lcmmod*ainv) % MOD)
        ans %= MOD

    print(ans)


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

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

mp_score = {"r": P, "s": R, "p": S}

lines = [""] * K
for ix in range(K):
    for t in range(len(T)):
        if t%K == ix:
            lines[ix] += T[t]

# print(lines)
ans = 0
for l in lines:
    before = ""
    for c in l:
        if before == c:
            before = ""

        else:
            ans += mp_score[c]
            before = c

print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

mp_score = {"r": P, "s": R, "p": S}

lines = [""] * K
for ix in range(len(T)):
    lines[ix%K] += T[ix]

ans = 0
for l in lines:
    before = ""
    for c in l:
        if before == c:
            before = ""

        else:
            ans += mp_score[c]
            before = c

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

def dijkstra(n):
    inf = 10 ** 6 + 1
    dist = [0] + [inf] * (n - 1)
    visited = [False] * n

    while not all(visited):
        dmin = inf
        for i, (d, v) in enumerate(zip(dist, visited)):
            if dmin > d and not v:
                dmin, u = d, i
        visited[u] = True
        for (v, c) in edge[u]:
            if dist[v] > dist[u] + c:
                dist[v] = dist[u] + c
    return dist

n = int(input())
edge = [[]] * n
for _ in range(n):
    l = list(map(int, input().split()))
    edge[l[0]] = (e for e in zip(l[2::2], l[3::2]))
for i, c in enumerate(dijkstra(n)):
    print(i, c)

### FIXED CODE ###

import heapq


def dijkstra(n):
    inf = 10 ** 6 + 1
    dist = [0] + [inf] * (n - 1)
    q = [(0, 0)]
    while q:
        u = heapq.heappop(q)[1]
        for (v, c) in edge[u]:
            alt = dist[u] + c
            if dist[v] > alt:
                dist[v] = alt
                heapq.heappush(q, (alt, v))
    return dist

n = int(input())
edge = [[]] * n
for _ in range(n):
    l = list(map(int, input().split()))
    edge[l[0]] = (e for e in zip(l[2::2], l[3::2]))
for i, c in enumerate(dijkstra(n)):
    print(i, c)
### BUGGY CODE ###

class Unionfind():
    def __init__(self, progsize):
        self.table = [-1 for _ in range(progsize)]
        self.size = [1 for _ in range(progsize)]

    def find(self, x):
        while(self.table[x] >= 0):
            x = self.table[x]
        return x

    def union(self, x, y):
        xl = self.find(x)
        yl = self.find(y)
        if xl != yl:
            if self.table[xl] <= self.table[yl]:
                self.table[yl] = xl
                self.table[xl] -= 1
                self.size[xl] += self.size[yl]
            else:
                self.table[xl] = yl
                self.table[yl] -= 1
                self.size[yl] += self.size[xl]

n, m = [int(x) for x in input().split()]
b = []
for i in range(m):
  b.append(tuple(int(x) - 1 for x in input().split()))
r = []
t = n*(n-1)//2
ds = Unionfind(n)
for i in range(m):
  q, p = b[-i-1]
  r.insert(0, t)
  qq, pp = ds.find(p), ds.find(q)
  if pp != qq:
    t -= ds.size[pp] * ds.size[qq]
  ds.union(p, q)
for x in r:
  print(x)

### FIXED CODE ###

class Unionfind():
    def __init__(self, progsize):
        self.table = [-1 for _ in range(progsize)]
        self.size = [1 for _ in range(progsize)]

    def find(self, x):
        while(self.table[x] >= 0):
            x = self.table[x]
        return x

    def union(self, x, y):
        xl = self.find(x)
        yl = self.find(y)
        if xl != yl:
            if self.table[xl] <= self.table[yl]:
                self.table[yl] = xl
                self.table[xl] -= 1
                self.size[xl] += self.size[yl]
            else:
                self.table[xl] = yl
                self.table[yl] -= 1
                self.size[yl] += self.size[xl]

n, m = map(int, input().split())
bridge = [tuple(map(int, input().split())) for _ in range(m)]
bridge.reverse()
uf = Unionfind(n)
cur = n * (n-1) // 2
ans = [cur]
for a, b in bridge:
    ap = uf.find(a-1)
    bp = uf.find(b-1)
    if ap != bp:
        cur -= uf.size[ap] * uf.size[bp]
    uf.union(a-1, b-1)
    ans.append(cur)
for a in reversed(ans[0:m]):
    print(a)
### BUGGY CODE ###

import numpy as np

s = input()
l = len(s)
mod = (10**9)+7

dp = np.zeros((l,13), dtype=np.int64)

if s[0] == '?':
    dp[0][0:10] = 1
else:
    dp[0][int(s[0])] = 1

for i in range(l-1):
    a = i+1
    x = s[a]
    if x == '?':
        for j in range(10):
            for k in range(13):
                dp[a][(k*10+j)%13] += dp[a-1][k]%mod
    else:
        for k in range(13):
            dp[a][(k*10+int(x))%13] += dp[a-1][k]%mod

print(dp[-1][5]%mod)

### FIXED CODE ###

s = input()
l = len(s)
mod = (10**9)+7

dp = [[0 for j in range(13)] for i in range(l)]

if s[0] == '?':
    dp[0][0:9] = [1 for x in range(10)]
else:
    dp[0][int(s[0])] = 1

for i in range(l-1):
    a = i+1
    x = s[a]
    if x == '?':
        for j in range(10):
            for k in range(13):
                dp[a][(k*10+j)%13] += dp[a-1][k]%mod
    else:
        for k in range(13):
            dp[a][(k*10+int(x))%13] += dp[a-1][k]%mod

print(dp[-1][5]%mod)
### BUGGY CODE ###

import numpy as np


def solve(s):
    MOD = 10 ** 9 + 7
    dp = np.zeros(13, dtype=np.int64)
    idx = [0] * 13
    for i in range(13):
        idx[i * 10 % 13] = i
    dp[0] = 1
    for c in s:
        if c == '?':
            tdp = dp[idx]
            ndp = tdp.copy()
            for i in range(1, 10):
                ndp += np.roll(tdp, i)
            ndp %= MOD
            dp = ndp
        else:
            i = int(c)
            dp = np.roll(dp[idx], i)
    return dp[5]


s = input()
print(solve(s))


### FIXED CODE ###

import numpy as np


def solve(s):
    MOD = 10 ** 9 + 7
    dp = np.zeros(13, dtype=np.int64)
    dp[0] = 1
    idx = np.zeros(13, dtype=np.int8)
    for i in range(13):
        idx[i * 10 % 13] = i
    window = np.ones(10, dtype=np.int8)
    for c in s:
        if c == '?':
            tdp = dp[idx]
            ndp = np.concatenate([tdp[4:], tdp])
            dp = np.convolve(ndp, window, mode='valid') % MOD
        else:
            dp = np.roll(dp[idx], int(c))
    return dp[5]


s = input()
print(solve(s))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N,K = map(int,input().split())
X = list(map(int,input().split()))
ans = 10**9
for i in range(N-K+1):
    #print(X[i:i+K])
    if min(X[i:i+K]) >= 0:
        #print('a')
        ans = min(ans,max(X[i:i+K]))
    elif max(X[i:i+K]) <= 0:
        #print('b')
        ans = min(ans,abs(min(X[i:i+K])))
    else:
        #print('c')
        ans = min(ans,abs(min(X[i:i+K])*2)+max(X[i:i+K]))
print(ans)

### FIXED CODE ###

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

ans = 10**9
for i in range(N-K+1):
    ans = min(ans,X[i+K-1]-X[i]+min(abs(X[i]),abs(X[i+K-1])))
print(ans)
### BUGGY CODE ###

import numpy as np

def find_nearest(array, value):
    array = np.asarray(array)
    idx = (np.abs(array - value)).argmin()
    return array[idx]

A_len, B_len, K = map(int, input().split(' '))
#print("Aは{0}冊. Bは{1}冊. 上限{2}分".format(A_len, B_len, K))

A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))
#print(A, B)

# A,Bの累積和の配列を出して、A_acc,B_accの要素番地が最大となるような組み合わせを出す

A_acc = []
for idx_A in range(A_len): 
  if(idx_A == 0):
    A_acc.append(A[0])
  else:
    A_acc.append(A_acc[idx_A - 1] + A[idx_A])
A_acc.insert(0, 0)
    
B_acc = []
for idx_B in range(B_len):
  if(idx_B == 0):
    B_acc.append(B[0])
  else:
    B_acc.append(B_acc[idx_B - 1] + B[idx_B])
B_acc.insert(0, 0)

#print(A_acc, B_acc)

max_num = 0
left_time = K
for a_num in range(A_len + 1):
  b_num = 0
  left_time = K - A_acc[a_num]
  #print("Aから{0}冊読んだ場合はそもそも残り{1}分".format(a_num, left_time))
  if(left_time < 0):
    break
  
  #while(True):
  #  print("Bから{0}冊読んでる場合,残り時間{1}".format(b_num, left_time - B_acc[b_num]))
    
  #  if(b_num + 1 > B_len):
  #    break
    
  #  if(left_time - B_acc[b_num + 1] < 0):
  #    break
    
  #  b_num += 1
  nearest_b = find_nearest(B_acc, left_time)
  b_num = B_acc.index(nearest_b)
  if(left_time < nearest_b and b_num > 0):
    b_num -= 1
  #print("最も近い分数は{0}. 冊数は{1}".format(nearest_b, b_num))
    
  #print("結果,A棚から{0}冊、B棚から{1}冊で合計{2}冊で経過時間{3}"
  #      .format(a_num, b_num, a_num + b_num, A_acc[a_num] + B_acc[b_num]))
  max_num = max(max_num, (a_num + b_num))
  #print("現在max{0}".format(max_num))
  
print(max_num)
    


### FIXED CODE ###

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

a, b = [0], [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
  if a[i] > K:
    break
    
  while b[j] > K - a[i]:
    j -= 1
    
  ans = max(ans, i + j)

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

n=int(input());a,b=1,1
for i in range(n):
  c,d=map(int,input().split())
  cc,dd=c,d
  while a>c or b>d:c+=cc;d+=dd
  a,b=c,d
print(a+b)

### FIXED CODE ###

n=int(input());a,b=map(int,input().split())
for i in range(n-1):
  c,d=map(int,input().split())
  m=max((a-1)//c,(b-1)//d)+1
  a,b=c*m,d*m
print(a+b)
### BUGGY CODE ###

N = int(input())
al = list(map(int,input().split()))
bl = list(map(int,input().split()))
cl = list(map(int,input().split()))

cnt = 0
for b in range(N):
    cntab = 0
    for a in range(N):
        if al[a] < bl[b]:
            cntab += 1
    cntbc = 0
    for c in range(N):
        if bl[b] < cl[c]:
            cntbc += 1
    cnt += cntab*cntbc
print(cnt)

### FIXED CODE ###

import bisect

N = int(input())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
cl = list(map(int, input().split()))
al.sort()
# print(al)
bl.sort()
# print(bl)
cl.sort()
# print(cl)

cnt = 0
for i in range(N):
    cnt_ab = bisect.bisect_left(al, bl[i])  # bl[b] = 6 idx= 3
    cnt_bc = len(cl) - bisect.bisect(cl, bl[i])  # bl[b] = 6 idx2= 1
    # print(cnt_ab,cnt_bc)
    cnt += cnt_ab * cnt_bc

print(cnt)
### BUGGY CODE ###

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

### FIXED CODE ###

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

check = {}
ans = 0

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

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

A, B = map(int, input().split())

total =min(A, B)

while True:
    if total %A ==0 and total %B ==0:
        ans = total
        break
    else:
        total +=1

print(ans)

### FIXED CODE ###

A, B = map(int, input().split())

k = B
while True:
    if k % A ==0:
        ans = k
        break
    else:
        k += B

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

a=input().split()
K=int(a[0])
S=int(a[1])
cnt=0
for X in range(0,K+1):
    for Y in range(0,K+1):
        for Z in range(0,K+1):
            if X+Y+Z==S:
                cnt+=1
print(cnt)

### FIXED CODE ###

K,S=map(int,input().split())
cnt=0
for X in range(K+1):
  for Y in range(K+1):
    if 0<=S-X-Y and S-X-Y<=K:
      cnt+=1
print(cnt)