Harryxun/stf_run huggingface dataset:
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)
INF = 10**9
mod = 10**9+7

N,K = I()
L = [l() for _ in range(N)]
L.sort()
for i in range(N):
    K -= L[i][1]
    if K <= 0:
        print(L[i][0])
        exit()

### 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)
INF = 10**9
mod = 10**9+7

N,K = I()
L = [l() for _ in range(N)]
L.sort()
for i in range(N):
    K -= L[i][1]
    if K <= 0:
        print(L[i][0])
        exit()
N = map(int, input().split())
ans = 0
for i in range(N):
    x, u = input().split()
    if u == 'BTC':
        ans += float(x)*380000.0
    else:
        ans += float(x)
print(ans)

### FIXED CODE ###

N = int(input())
x = [list(input().split()) for i in range(N)]
print(sum([float(i[0])*380000.0 if i[1] == 'BTC' else float(i[0]) for i in x]))
a = int(input())
b = int(input())
c = int(input())
d = int(input())

if abs(a - b) <= d and abs(b - c) <= d or abs(a - c) <= d:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

a, b, c, d = map(int, input().split())

if abs(a - c) <= d:
    print('Yes')
elif (a < b and b < c) or (a > b and b > c):
    if abs(a - b) <= d and abs(b - c) <= d:
        print('Yes')
    else:
        print('No')
else:
    print('No')
import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict
 
x,y = map(int,input().split())
 
for i in range(1, x+1):
    # 足の数
    f = 2 * i + 4 * (x - i)
    if f == y:
        print('Yes')
        sys.exit()
    elif i==x: 
    	print('No')


### FIXED CODE ###

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

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())#整数値　複数の入力
def S_MAP(): return map(str, input().split())#文字　複数の入力
def LIST(): return list(map(int, input().split()))#整数　複数の入力　配列
def S_LIST(): return list(map(str, input().split()))#文字　複数の入力　配列


x=S_LIST()


print(x.index("0")+1)
n = int(input())
a = list(map(int,input().split()))

ttl = a[0]
cst = 0

if a[0]>0:
    flg = 1

elif a[0]<0:
    flg = -1

for i in range(1,n):
    ttl += a[i]
    

    if ttl*flg < 0:
        flg *= -1
    else:
        if flg > 0:
            memo = abs(ttl)+1
            ttl -= memo
            cst += memo
        elif flg < 0:
            memo = abs(ttl)+1
            ttl += memo
            cst += memo
        flg *= -1
   


ttl = a[0]
cst2 = 0


   

print(min(cst,cst2))



### FIXED CODE ###

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

def wh(cst,ttl,flg):
    for i in range(n):
        ttl += a[i]

        if ttl*flg < 0:
            flg *= -1
        else:
            if flg > 0:
                memo = abs(ttl)+1
                ttl -= memo
                cst += memo
            elif flg < 0:
                memo = abs(ttl)+1
                ttl += memo
                cst += memo
            flg *= -1

        
    return cst




ttl = 0
cst = 0



cst = wh(cst,ttl,1)
ttl = 0
cst2 = 0
cst2 = wh(cst2,ttl,-1)
   

print(min(cst,cst2))
H, W = map(int, input().split())
 
INPUT = [list(input()) for i in range(H)]
OUTPUT = INPUT.copy()
 
for i in range(H):
    for j in range(W):
        if INPUT[i][j] == '#':
            OUTPUT[i][j] = '#'
            continue
        else:
            OUTPUT[i][j] = 0
            for I in (i-1, i, i+1):
                if (I < 0 or l <= H):
                    continue
                for J in (j-1, j, j+1):
                    if (J < 0 or W <= J):
                        continue
                    if INPUT[I][J] == '#':
                        OUTPUT[i][j] += 1
 
 
for i in range(H):
    print(''.join(map(str, OUTPUT[i])))

### FIXED CODE ###

H, W = map(int, input().split())

INPUT = [list(input()) for i in range(H)]
OUTPUT = INPUT.copy()

for i in range(H):
    for j in range(W):
        if INPUT[i][j] == '#':
            OUTPUT[i][j] = '#'
            continue
        else:
            OUTPUT[i][j] = 0
            for I in (i-1, i, i+1):
                if (I < 0 or H <= I):
                    continue
                for J in (j-1, j, j+1):
                    if (J < 0 or W <= J):
                        continue
                    if INPUT[I][J] == '#':
                        OUTPUT[i][j] += 1


for i in range(H):
    print(''.join(map(str, OUTPUT[i])))
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

for i in range(n):
    if i == 0:
        continue
    else:
        a[i] += a[i-1]

for i in range(m):
    if i == 0:
        continue
    else:
        b[i] += b[i - 1]

a = [0]+a
b = [0]+b

i = 0
j = m
ans = 0

while a[i] <= k:
    while b[j] > k-a[i]:
        j -= 1
    ans = i+j
    ans =max(ans,i+j)
    i += 1

print(ans)

### FIXED CODE ###

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

for i in range(n):
    if i == 0:
        continue
    else:
        a[i] += a[i-1]

for i in range(m):
    if i == 0:
        continue
    else:
        b[i] += b[i - 1]

a = [0]+a
b = [0]+b

i = 0
j = m
ans = 0

while a[i] <= k:
    while b[j] > k-a[i]:
        j -= 1
        if j<0:
            j=0
            break

    ans =max(ans,i+j)
   
    i += 1
    if i > n:
        break

print(ans)
MAX = int(2e5)+2


n = int(input())
lis = list(map(int,input().split()))
lis2 = [0]*MAX
# lis.sort()
# m = max(lis)
ans = 0
for num in lis:
    lis2[num] += 1

for num in lis:
    for i in range(num*2, MAX, num):
        if lis2[i] > 0:
            lis2[i] += 1

print(len([i for i in lis if lis2[i] == 1]))

### FIXED CODE ###

# MAX = int(1e6)+2


n = int(input())
lis = list(map(int,input().split()))
lis.sort()
MAX = lis[-1]
lis2 = [0]*(MAX+1)
# lis.sort()
# m = max(lis)
ans = 0

for num in lis:
    for i in range(num, MAX+1, num):
            lis2[i] += 1

for j in set(lis):
    if lis2[j] == 1:
        ans += 1
print(ans)
S = int(input())

h = S//3600
m = (S//60)-(S//3600)
s = S//60
p = h:m:s
print(p)




### FIXED CODE ###

S = int(input())
h = S//3600
m = (S//60)-60*(S//3600)
s = S%60
print('{}:{}:{}'.format(h,m,s))
import sys
import queue


class Dijkstra:
    class Edge:
        def __init__(self, end, cost):
            self.to = end
            self.cost = cost

    def __init__(self, node_size, inf):
        self._node = node_size
        self._graph = [[] for _ in range(self._node)]
        self.inf = inf
        self.dist = [self.inf for _ in range(self._node)]

    def add_edge(self, st, ed, cs):
        self._graph[st].append(self.Edge(ed, cs))

    def solve(self, start):
        que = queue.PriorityQueue()
        self.dist[start] = 0
        que.put((0, start))
        while que:
            cur_cost, cur_vertex = que.get()
            if self.dist[cur_vertex] < cur_cost:
                continue
            for e in self._graph[cur_vertex]:
                if self.dist[e.to] > cur_cost + e.cost:
                    self.dist[e.to] = cur_cost + e.cost
                    que.put((self.dist[e.to], e.to))


if __name__ == '__main__':
    V, E, r = map(int, sys.stdin.readline().split())
    dk = Dijkstra(V, 10 ** 10)
    for i in range(E):
        s, t, d = map(int, sys.stdin.readline().split())
        dk.add_edge(s, t, d)
    dk.solve(r)
    for value in dk.dist:
        if value == dk.inf:
            print("INF")
        else:
            print(value)


### FIXED CODE ###

import sys
from heapq import heappush, heappop


class Dijkstra:
    class Edge:
        def __init__(self, end, cost):
            self.to = end
            self.cost = cost

    def __init__(self, node_size, inf):
        self._node = node_size
        self._graph = [[] for _ in range(self._node)]
        self.inf = inf
        self.dist = [self.inf for _ in range(self._node)]

    def add_edge(self, st, ed, cs):
        self._graph[st].append(self.Edge(ed, cs))

    def solve(self, start):
        que = []
        self.dist[start] = 0
        heappush(que, (0, start))
        while que:
            cur_cost, cur_vertex = heappop(que)
            if self.dist[cur_vertex] < cur_cost:
                continue
            for e in self._graph[cur_vertex]:
                if self.dist[e.to] > cur_cost + e.cost:
                    self.dist[e.to] = cur_cost + e.cost
                    heappush(que, (self.dist[e.to], e.to))


if __name__ == '__main__':
    V, E, r = map(int, sys.stdin.readline().split())
    dk = Dijkstra(V, 10 ** 10)
    for i in range(E):
        s, t, d = map(int, sys.stdin.readline().split())
        dk.add_edge(s, t, d)
    dk.solve(r)
    for value in dk.dist:
        if value == dk.inf:
            sys.stdout.write("INF\n")
        else:
            sys.stdout.write("%s\n" % value)
from bisect import bisect_left
N, M=map(int, input().split())
A=list(map(int, input().split()))
A.sort()
for i in range(M):
  tmp=A[-1]//2
  A.pop(N-1)
  A.insert(bisect_left(A, tmp), tmp)
  if A[-1]=0:
    break
print(sum(A))

### FIXED CODE ###

import heapq
N, M=map(int, input().split())
A=list(map(int, input().split()))
A=list(map(lambda x: -x, A))
heapq.heapify(A)
for i in range(M):
  heapq.heappush(A, (heapq.heappop(A)+1)//2)
print(-sum(A))
H,W = map(int,input().split())
L = []
for i in range(H):
    l = list(input())
    L.append(l)

def judge(list,i,j):
    if i != 0:
        top = list[i-1][j]
    else:
        top = "."
    if j != 0:
        left = list[i][j-1]
    else:
        left = "."
    if i != H-1:
        bottom = list[i+1][j]
    else:
        bottom = "."
    if j != W-1:
        right = list[i][j+1]
    else:
        right = "."
    return top == "#" or left == "#" or bottom == "#" or right == "#"

for i in range(H):
    for j in range(W):
        if L[i][i] == "#" and judge(L,i,j) is False:
            print("No")
            exit()
print("Yes")

### FIXED CODE ###

H,W = map(int,input().split())
L = []
for i in range(H):
    l = list(input())
    L.append(l)

def judge(list,i,j):
    if i != 0:
        top = list[i-1][j]
    else:
        top = "."
    if j != 0:
        left = list[i][j-1]
    else:
        left = "."
    if i != H-1:
        bottom = list[i+1][j]
    else:
        bottom = "."
    if j != W-1:
        right = list[i][j+1]
    else:
        right = "."
    return top == "#" or left == "#" or bottom == "#" or right == "#"

for i in range(H):
    for j in range(W):
        if L[i][j] == "#" and judge(L,i,j) is False:
            print("No")
            exit()
print("Yes")
import sys

args=sys.argv
S=args[1]
if S[0] == S[1]:
        if S[1] == S[2]:
                print("No")
        else:
                print("Yes")
else:
        print("Yes")

### FIXED CODE ###

S=list(input())

if S[0] == S[1]:
        if S[1] == S[2]:
                print("No")
        else:
                print("Yes")
else:
        print("Yes")
# -*- coding: utf-8 -*-
import sys;
sys.setrecursionlimit(20000) # 再起呼び出しの最大数をセット

# 整数の入力
#n = int(input())

# スペース区切りの整数の入力
a = [x for x in map(int, input().split())]
#n, y = map(int, input().split())

# 改行区切りの整数の入力
#a = []
#for x in range(n):
#  a.append(int(input()))

# 文字列の入力
#s = input()

# 出力
#print("{} {}".format(a+b+c, s))
#a.sort()
#print(set(a), file=sys.stderr)
#print(len(set(a)))

surfixes = ("dream", "dreamer", "erase", "eraser")

def doit(l):
  #print(s, file=sys.stderr)
  if l == 0:
    return True;
  for x in surfixes:
    if s[:l].endswith(x):
#      return doit(l-len(x))
      if doit(l-len(x)):
        return True
  return False

try:
  if a[0] > 12:
    print("" + [a1])
  elif a[0] > 5:
    print("" + ([a1]/2))
  else
    print("0")
except Exception as e:
  print(e, file=sys.stderr)


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys;
sys.setrecursionlimit(20000) # 再起呼び出しの最大数をセット

# 整数の入力
#n = int(input())

# スペース区切りの整数の入力
a = [x for x in map(int, input().split())]
#n, y = map(int, input().split())

# 改行区切りの整数の入力
#a = []
#for x in range(n):
#  a.append(int(input()))

# 文字列の入力
#s = input()

# 出力
#print("{} {}".format(a+b+c, s))
#a.sort()
#print(set(a), file=sys.stderr)
print(a, file=sys.stderr)

#surfixes = ("dream", "dreamer", "erase", "eraser")

def doit(l):
  #print(s, file=sys.stderr)
  if l == 0:
    return True;
  for x in surfixes:
    if s[:l].endswith(x):
#      return doit(l-len(x))
      if doit(l-len(x)):
        return True
  return False

try:
  if a[0] > 12:
    print("%d" % a[1])
  elif a[0] > 5:
    print("%d" % (a[1]/2))
  else:
    print("0")
except Exception as e:
  print(e, file=sys.stderr)
# -*- coding: utf-8 -*-

n = int(input())
s = [ input() for i in range(n)]
count = 0
x = [sorted(i) for i in s]
_x = sorted(x)

for i in range(n-1):
  	tmp = -x[i]
    for j in range(i+1,n):
        if tmp == _x[j]:
            count += 1
        else:
            break

print(count)

### FIXED CODE ###

# -*- coding: utf-8 -*-
n = int(raw_input())
d = {}
ans = 0
for i in range(n):
    si = ''.join(sorted(raw_input()))
    if si in d:
        ans += d[si]
        d[si] += 1
    else:
        d[si] = 1
print(ans)
n = int(input())
if 1 in n and 9 in n and 7 in n and 4 in n:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

n= list(map(int,input().split()))
n.sort()
if 1 in n and 7 in n and 9 in n and 4 in n:
  print("YES")
else:
  print("NO")
import sys
import itertools
import bisect
import math
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

mod = 10 ** 9 + 7
x, y = na()
dp = [[0 for i in range(x+1)] for j in range(y+1)]
dp[0][0] = 1
for i in range(x+1):
    for j in range(y+1):
        if i >=1 and j >= 2:
            dp[i][j] += dp[i-1][j-2]
        if i >= 2 and j >= 1:
            dp[i][j] += dp[i-2][j-1]
        dp[i][j] %= mod
print(dp[x][y])




### FIXED CODE ###

import sys
import itertools
import bisect
import math

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


mod = 10 ** 9 + 7
x, y = na()
if (x + y) % 3 != 0:
    print(0)
else:
    n = ((x + y) // 3 + (y - x)) // 2
    m = y - (2 * n)
    if n < 0 or m < 0:
        print(0)
    else:
        print(cmb(n+m, n, mod))
from functools import reduce
import fractions

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input().rstrip())
As = input().rstrip().split(" ")
As = [int(p) for p in As]

cand = lcm_list(As)

sum = 0

for num in As:
    sum = sum + cand / num

print(sum)


### FIXED CODE ###

from functools import reduce
import fractions

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input().rstrip())
As = input().rstrip().split(" ")
As = [int(p) for p in As]

cand = lcm_list(As)

sum = 0

for num in As:
    sum = sum + cand // num

print(sum % int(1e9+7) )
x,y = map(int, input().split())
if x == 0 and y == 0:
    break
elif x => y:
    print (y,x)
else
    print (x,y)

### FIXED CODE ###

while True:
    x,y = map(int, input().split())
    if x == 0 and y == 0 :
        break
    elif x <= y :
        print (x,y)
    else :
        print (y,x)
Not

### FIXED CODE ###

n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)
ans=sum(a[1::2][:n])
print(ans)
def combinations_mod(n, r, mod=1000000007):
    """Returns nCr in mod."""
    combs = 1
    for i, j in zip(range(n - r + 1, n + 1), range(1, r + 1)):
        combs = combs % mod * i % mod * pow(j, mod - 2, mod) % mod
    return combs


def main():
    n, a, b = [int(x) for x in input().split()]
    combs = [0] * (n + 1)  # memorize
    combs[0] = 1  # Pick no flower
    ans = 0
    for pick in range(1, n + 1):
        tmp = combs[n - pick]
        if tmp != 0:
            comb = tmp
        else:
            comb = combinations_mod(n, pick)
        combs[pick] = comb
        if pick not in (a, b):
            ans += comb
            ans %= 1000000007

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def combinations_mod(n, r, mod=1000000007):
    """Returns nCr in mod."""
    r = min(r, n - r)
    combs = 1
    for i, j in zip(range(n - r + 1, n + 1), range(1, r + 1)):
        combs = combs % mod * i % mod * pow(j, mod - 2, mod) % mod
    return combs


def main():
    n, a, b = [int(x) for x in input().split()]
    mod = 1000000007
    total = pow(2, n, mod) - 1
    ans = total - combinations_mod(n, a) - combinations_mod(n, b)
    ans %= mod
    print(ans)


if __name__ == '__main__':
    main()
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(H: int, W: int, s: "List[str]"):
    def is_valid(i, j):
        if (i > 0 and s[i - 1][j] == '#' or 
            i < H - 1 and s[i + 1][j] == '#' or 
            j > 0 and s[i][j - 1] == '#' or 
            j < W - 1 and s[i][j + 1] == '#'):
            return True
        return False

    for i, R in enumerate(s):
        for j, c in enumerate(R):
            if c == '#' and not is_valid(i, j):
                print(NO)
                return
    print(YES)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    s = [ next(tokens) for _ in range(W) ]  # type: "List[str]"
    solve(H, W, s)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(H: int, W: int, s: "List[str]"):
    def is_valid(i, j):
        if (i > 0 and s[i - 1][j] == '#' or 
            i < H - 1 and s[i + 1][j] == '#' or 
            j > 0 and s[i][j - 1] == '#' or 
            j < W - 1 and s[i][j + 1] == '#'):
            return True
        return False

    for i, R in enumerate(s):
        for j, c in enumerate(R):
            if c == '#' and not is_valid(i, j):
                print(NO)
                return
    print(YES)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    s = [ next(tokens) for _ in range(H) ]  # type: "List[str]"
    solve(H, W, s)

if __name__ == '__main__':
    main()
a,b=(int(x) for x in input().split())
gcc=1
i=2
while True:
    if(a<i or b<i):
        break
    elif (a%i==0 and b%i==0):
        gcc*=i
        a/=i
        b/=i
        i=2
    else:
        i+=1

print(int(a*b*gcc))


### FIXED CODE ###

N=int(input())
number=input().split(' ')
number_list=[]
for i in number:
    number_list.append(int(i))
index=1
flag=0
count=0
for i in number_list:
    if(i==1 and flag==0):
        flag=1
        index+=1
    elif (i==index):
        index+=1
    else:
        count+=1

if(flag==0):
    print(-1)
else:
    print(count)
import math
n = int(input())
print(n*2/math.gcd(n,2))

### FIXED CODE ###

n = int(input())
if n % 2==0:
    print(n)
else:
    print(2*n)
n=str(input())
print("Good" if all([n[j]!=n[j+1] for i in range(3)]) else "Bad")

### FIXED CODE ###

a, b, c, d = input()
count = 0
if a == b or b == c or c == d:
  count += 1

if count == 1:
  print("Bad")
else:
  print("Good")
import numpy as np
H, W, M = map(int, input().split())
HW = []
A = np.zeros((H, W), dtype='int')

for _ in range(M):
    h, w = map(int, input().split())
    h, w = h - 1, w - 1  # 0-indexed
    HW.append((h, w))
    A[h, w] = 1

print(1)
exit()

arr = A.sum(axis=0)
col_max = arr.max()
col_idx = np.where(arr == col_max)[0]

arr = A.sum(axis=1)
row_max = arr.max()
row_idx = np.where(arr == row_max)[0]

# print(A.sum(axis=0).argsort()[-1])

ans = col_max + row_max
for r in row_idx:
    for c in col_idx:
        if A[r, c] == 0:
            print(ans)
            exit()
print(ans - 1)


### FIXED CODE ###

import numpy as np
H, W, M = map(int, input().split())

C = [0] * W
R = [0] * H
S = set()
for _ in range(M):
    h, w = map(int, input().split())
    h, w = h - 1, w - 1  # 0-indexed
    C[w] += 1
    R[h] += 1
    S.add((h, w))

col_max = max(C)
col_idx = [i for i in range(W) if C[i] == col_max]
row_max = max(R)
row_idx = [i for i in range(H) if R[i] == row_max]

ans = col_max + row_max
for r in row_idx:
    for c in col_idx:
        if not (r, c) in S:
            print(ans)
            exit()
print(ans - 1)
n=int(input())
a=list(map(int, input().split()))
b=[0]*n
c=[0]*n
for i in range(n):
    b[i]=a[i]+i
    c[i]=i-a[i]
bs=sorted(b)
cs=sorted(c)
lx=[1+10**10]*n
ly=[2+10**10]*n
rx=[3+10**10]*n
ry=[4+10**10]*n

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

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


### FIXED CODE ###

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

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

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

### FIXED CODE ###

a,b,x = map(int, input().split())
ans = 0
if a==0:
    a=1
    ans += 1
ans += b//x - (a-1)//x
print(ans)
s = (input()

s1 = s[0]
if s.count(s1) == 2:
    s = s.replace(s1, "")
    s2 = s[0]
    if s.count(s2) == 2:
        print('Yes')
    else:
        print('No')
else:
    print('No')


### FIXED CODE ###

s = input()

s1 = s[0]
if s.count(s1) == 2:
    s = s.replace(s1, "")
    s2 = s[0]
    if s.count(s2) == 2:
        print('Yes')
    else:
        print('No')

else:
    print('No')
s=input()
l=input()
len_s=len(s)
len_l=len(l)
a=len_s-len_l
ans=1001
for i in range(len_s-len_l+!):
    cnt=0
    for j in range(len_l):
        if l[j]!=s[i+j]:
            cnt+=1
    ans=min(ans,cnt)

print(ans)


### FIXED CODE ###

s=input()
l=input()
len_s=len(s)
len_l=len(l)
a=len_s-len_l
ans=1001
for i in range(len_s-len_l+1):
    cnt=0
    for j in range(len_l):
        if l[j]!=s[i+j]:
            cnt+=1
    ans=min(ans,cnt)

print(ans)