Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
TXY = [list(map(int, input().split())) for _ in range(N)]
TXY.insert(0,[0,0,0])

point_a, point_b = 0, 0
for i in range(N):
    if TXY[i+1][0] - TXY[i][0] < abs(TXY[i+1][1] - TXY[i][1]) + abs(TXY[i+1][2] - TXY[i][2]):
        point += 1

for i in range(N):
    if point_a == 0 and (TXY[i+1][0] - TXY[i][0] % 2 != abs(TXY[i+1][1] - TXY[i][1]) + abs(TXY[i+1][2] - TXY[i][2]) %2) :
        point_b += 1

if point_a == 0 and point_b == 0:
    print('Yes')
else:
    print('No')

Fixed submission:
N = int(input())
TXY = [list(map(int, input().split())) for _ in range(N)]
TXY.insert(0,[0,0,0])

point_a, point_b = 0, 0
for i in range(N):
    if TXY[i+1][0] - TXY[i][0] < abs(TXY[i+1][1] - TXY[i][1]) + abs(TXY[i+1][2] - TXY[i][2]):
        point_a += 1

for i in range(N):
    if point_a == 0 and ((TXY[i+1][0] - TXY[i][0]) % 2 != (abs(TXY[i+1][1] - TXY[i][1]) + abs(TXY[i+1][2] - TXY[i][2])) %2) :
        point_b += 1

if point_a == 0 and point_b == 0:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
N = int(input())
TXY = [list(map(int, input().split())) for _ in range(N)]
TXY.insert(0,[0,0,0])

point = 0
for i in range(N+1):
    if TXY[i+1][0] - TXY[i][0] < abs(TXY[i+1][1] - TXY[i][1]) + abs(TXY[i+1][2] - TXY[i][2]):
        point += 1

for i in range(N+1):
    if TXY[i+1][0] - TXY[i][0] % 2 != abs(TXY[i+1][1] - TXY[i][1]) + abs(TXY[i+1][2] - TXY[i][2]) %2 :
        point += 1

if point == 0:
    print('Yes')
else:
    print('No')

Fixed submission:
N = int(input())
TXY = [list(map(int, input().split())) for _ in range(N)]
TXY.insert(0,[0,0,0])

point_a, point_b = 0, 0
for i in range(N):
    if TXY[i+1][0] - TXY[i][0] < abs(TXY[i+1][1] - TXY[i][1]) + abs(TXY[i+1][2] - TXY[i][2]):
        point_a += 1

for i in range(N):
    if point_a == 0 and ((TXY[i+1][0] - TXY[i][0]) % 2 != (abs(TXY[i+1][1] - TXY[i][1]) + abs(TXY[i+1][2] - TXY[i][2])) %2) :
        point_b += 1

if point_a == 0 and point_b == 0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
sss = input()
masu = list(sss)
counter = 0
if(masu[0] == 1):
    counter += 1
    elif (masu[1] == 1):
        counter += 1
    elif (masu[2] == 1):
        counter += 1
print(counter)

Fixed submission:
sss = input()
masu = list(sss)
counter = 0
if(masu[0] == '1'):
    counter += 1
if (masu[1] == '1'):
    counter += 1
if (masu[2] == '1'):
    counter += 1
print(counter)
Buggy python submission (verdict: Runtime Error):
n,a,b = map(int, input().split())
if a * n < b:
  print(a * n)
else:
  printf(b)

Fixed submission:
n,a,b = map(int, input().split())
if a * n < b:
  print(a * n)
else:
  print(b)
Buggy python submission (verdict: Runtime Error):
def iread():
    return int(input())


def sread():
    return input()


def aread_int():
    tmp = input().split()
    ret = [int(i) for i in tmp]
    return ret


def aread_str():
    return input().split()

if __name__ == '__main__':
    n, x = map(int, input().split())
    l = aread_int()
    current = 0
    cnt = 0
    while current + l[cnt] <= x :
        current += l[cnt]
        cnt += 1
    
    print(cnt + 1)

Fixed submission:
def iread():
    return int(input())


def sread():
    return input()


def aread_int():
    tmp = input().split()
    ret = [int(i) for i in tmp]
    return ret


def aread_str():
    return input().split()

if __name__ == '__main__':
    n, x = map(int, input().split())
    l = aread_int()
    current = 0
    cnt = 0
    while cnt < n and current + l[cnt] <= x :
        current += l[cnt]
        cnt += 1
    
    print(cnt + 1)
Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split())
if a < 6:
    print(0)
    return
elif a < 14:
    print(int(b / 2))
	return
else:
    print(b)

Fixed submission:
a,b = map(int, input().split())
if a >= 13:
    print(b)
    exit()
elif a >= 6:
    print(int(b / 2))
    exit()
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split())
if a < 6:
    print(0)
    exit()
elif a < 14:
    print(int(b / 2))
	exit()
else:
    print(b)

Fixed submission:
a,b = map(int, input().split())
if a >= 13:
    print(b)
    exit()
elif a >= 6:
    print(int(b / 2))
    exit()
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split())
if a < 6:
    print(0)
else if a < 14:
    print(int(b / 2))
else:
    print(b)

Fixed submission:
a,b = map(int, input().split())
if a >= 13:
    print(b)
    exit()
elif a >= 6:
    print(int(b / 2))
    exit()
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
def iread():
    return int(input())


def sread():
    return input()


def aread_int():
    tmp = input().split()
    ret = [int(i) for i in tmp]
    return ret


def aread_str():
    return input().split()

if __name__ == '__main__':
    n, m = map(int, input().split())
    
    x = aread_int()
    x = sorted(x)
    x_dist = [0] * (m - 1)
    for i in range(m - 1) :
        x_dist[i] += abs(x[i] - x[i + 1])
    
    if n > m :
        print(0)
        exit()
    
    cost = sum(x_dist)
    for i in range(n - 1) :
        max_idx = x_dist.index(max(x_dist))
        cost -= x_dist[max_idx]
        # print(x_dist[max_idx])
        x_dist[max_idx] = 0

    print(cost)

Fixed submission:
def iread():
    return int(input())


def sread():
    return input()


def aread_int():
    tmp = input().split()
    ret = [int(i) for i in tmp]
    return ret


def aread_str():
    return input().split()

if __name__ == '__main__':
    n, m = map(int, input().split())
    
    x = aread_int()
    x = sorted(x)
    x_dist = [0] * (m - 1)
    for i in range(m - 1) :
        x_dist[i] += abs(x[i] - x[i + 1])
    
    if n > m :
        print(0)
        exit()
    
    x_dist = sorted(x_dist)
    idx = len(x_dist) - 1
    cost = sum(x_dist)
    for i in range(n - 1) :
        cost -= x_dist[idx]
        x_dist[idx] = 0
        idx -= 1

    print(cost)
Buggy python submission (verdict: Runtime Error):
a, b, c = map(string, input().split())
name = a[0] + b[0] + c[0]
print(name)

Fixed submission:
def main():
    s = aread("str")
    print(s[0][0] + s[1][0] + s[2][0])

def iread():
    return int(input())


def sread():
    return input()


def aread(t="int"):
    if t == "int":
        ret = [int(i) for i in input().split()]
    elif t == "str":
        ret = list(input().split( ))
    return ret


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


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [int(x) for x in input().split()]

ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        # print(i, j)
        ans += (A[i] * A[j]) % (10**9+7)
        ans %= (10**9+7)
print(ans)


Fixed submission:
n = int(input())
A = [int(x) for x in input().split()]
l = []

a = 0
for i in reversed(A):
    a += i
    l.append(a)
l.pop(n-1)
ans = 0

l.reverse()
for i in range(n-1):
    ans += (A[i]*l[i])
print(ans%(10**9+7))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from collections import Counter
import numpy as np

n, k = list(map(int,input().split()))
table = np.zeros((2*k,2*k),dtype='int32')
for i in range(n):
    t = input().split()
    if(t[2]=='B'):
        table[int(t[0])%(2*k)][int(t[1])%(2*k)] += 1
    else:
        table[(int(t[0])+k)%(2*k)][int(t[1])%(2*k)] += 1
        
n_table = np.zeros((3*k,3*k),dtype='int32')
n_table[0:2*k,0:2*k] = table
n_table[2*k:3*k,0:2*k] = table[0:k,0:2*k]
n_table[0:2*k,2*k:3*k] = table[0:2*k,0:k]
n_table[2*k:3*k,2*k:3*k] = table[0:k,0:k]

i_table = np.zeros((3*k,3*k),dtype='int32')

for i in range(0,3*k):
    i_table[i][0] = n_table[i][0]
    for j in range(1,3*k):
        i_table[i][j] += i_table[i][j-1] + n_table[i][j] 
for i in range(1,3*k):
    for j in range(0,3*k):
        i_table[i][j] += i_table[i-1][j]  

ans = 0
hope1 = i_table[k-1][k-1]
hope2 = i_table[2*k-1][2*k-1] - i_table[2*k-1][k-1] - i_table[k-1][2*k-1] + i_table[k-1][k-1]
ans = max(ans,hope1+hope2)
for i in range(1,k):
    hope1 = i_table[k-1][i+k-1] - i_table[k-1][i-1]
    hope2 = i_table[2*k-1][i+2*k-1] - i_table[2*k-1][i+k-1] - i_table[k-1][i+2*k-1] + i_table[k-1][i+k-1]
    ans = max(ans,hope1+hope2)
for i in range(1,k):        
        hope1 = i_table[i+k-1][k-1]- i_table[i-1][k-1]
        hope2 = i_table[i+2*k-1][2*k-1] - i_table[i+2*k-1][k-1] - i_table[i+k-1][2*k-1] + i_table[i+k-1][k-1]
        ans = max(ans,hope1+hope2)

for i in range(1,k):
    for j in range(1,k):        
        hope1 = i_table[i+k-1][j+k-1] - i_table[i+k-1][j-1] - i_table[i-1][j+k-1] + i_table[i-1][j-1]
        hope2 = i_table[i+2*k-1][j+2*k-1] - i_table[i+2*k-1][j+k-1] - i_table[i+k-1][j+2*k-1] + i_table[i+k-1][j+k-1]
        ans = max(ans,hope1+hope2)
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-      
import sys

n = int(input())
tprev = 0
tdiff = 0
pos = [0, 0]
for i in range(n):
    t, x, y = list(map(int,input().split()))
    tdiff = t - tprev
    if(tdiff>=abs(x-pos[0])+abs(y-pos[1])):
        if((tdiff-(abs(x-pos[0])+abs(y-pos[1])))%2 == 0):
            tprev = t
            pos = [x, y]
        else:
            print('No')
            sys.exit()
    else:
        print('No')
        sys.exit()
else:
    print('Yes')
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-       

s = input()
t = input()
ansstr = []

for i in range(len(s)-len(t)+1)[::-1]:
    tmpstr = s[i:i+len(t)]
    flg = True
    for j in range(len(t)):
        if(tmpstr[j] == '?'):
            pass
        elif(tmpstr[j] == t[j]):
            pass
        else:
            flg = False
    if(flg):
        uset = list(range(i,i+len(t)))
        for k in range(len(s)):
            if(k in uset):
                ansstr += t[k-i]
            elif(s[k]=='?'):
                ansstr += 'a'
            else:
                ansstr += s[k]
        break
print(''.join(ansstr) if flg else 'UNRESTORABLE')     
        
        

Fixed submission:
# -*- coding: utf-8 -*-       

s = input()
t = input()
ansstr = []

if(len(s)<len(t)):
    flg = False
for i in range(len(s)-len(t)+1)[::-1]:
    tmpstr = s[i:i+len(t)]
    flg = True
    for j in range(len(t)):
        if(tmpstr[j] == '?'):
            pass
        elif(tmpstr[j] == t[j]):
            pass
        else:
            flg = False
    if(flg):
        uset = list(range(i,i+len(t)))
        for k in range(len(s)):
            if(k in uset):
                ansstr += t[k-i]
            elif(s[k]=='?'):
                ansstr += 'a'
            else:
                ansstr += s[k]
        break
print(''.join(ansstr) if flg else 'UNRESTORABLE')

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-       

s = input()
t = input()
ansstr = []

for i in range(len(s)-len(t)+1):
    p = len(s)-len(t)-i
    tmpstr = s[p:p+len(t)]
    flg = True
    for j in range(len(t)):
        if(tmpstr[j] == '?'):
            pass
        elif(tmpstr[j] == t[j]):
            pass
        else:
            flg = False
    if(flg):
        for k in range(len(s)):
            if(p<=k and k<p+len(t)):
                ansstr += t[k-p]
            elif(s[k]=='?'):
                ansstr += 'a'
            else:
                ansstr += s[k]
        break
print(''.join(ansstr) if flg else 'UNRESTORABLE')
                

Fixed submission:
# -*- coding: utf-8 -*-       

s = input()
t = input()
ansstr = []

if(len(s)<len(t)):
    flg = False
for i in range(len(s)-len(t)+1)[::-1]:
    tmpstr = s[i:i+len(t)]
    flg = True
    for j in range(len(t)):
        if(tmpstr[j] == '?'):
            pass
        elif(tmpstr[j] == t[j]):
            pass
        else:
            flg = False
    if(flg):
        uset = list(range(i,i+len(t)))
        for k in range(len(s)):
            if(k in uset):
                ansstr += t[k-i]
            elif(s[k]=='?'):
                ansstr += 'a'
            else:
                ansstr += s[k]
        break
print(''.join(ansstr) if flg else 'UNRESTORABLE')
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))

d.sort()
t.sort()

p = 0
for i in range(len(t)):
    for j in range(p,len(d)):
        if(t[i] == d[j]):
            t[i] = 0
            d[j] = 0
            p = j
            break
            
print('YES' if sum(t) == 0 else 'NO')

Fixed submission:
# -*- coding: utf-8 -*-
import collections

n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))

dc = collections.Counter(d)
tc = collections.Counter(t)
s = [0 for i in range(len(tc))]
for i,index in enumerate(tc):
    s[i] = dc[index]-tc[index]
    

print('YES' if all(list(map(lambda x : x >= 0 , s))) else 'NO')

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))

d.sort()
t.sort()

p = 0
for i in range(len(t)):
    for j in range(p,len(d)):
        if(t[i] == d[j]):
            t[i] = 0
            d[j] = 0
            p = j
            
print('YES' if sum(t) == 0 else 'NO')

Fixed submission:
# -*- coding: utf-8 -*-
import collections

n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))

dc = collections.Counter(d)
tc = collections.Counter(t)
s = [0 for i in range(len(tc))]
for i,index in enumerate(tc):
    s[i] = dc[index]-tc[index]
    

print('YES' if all(list(map(lambda x : x >= 0 , s))) else 'NO')
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import math
n,m = map(int, raw_input().split())
mod = 10**9+7
if(n==m):
    print((2*(math.factorial(n))**2)%mod)
elif(abs(n-m)==1):
    tmp = math.factorial(min(n,m))
    print((max(n,m)*(tmp**2)%mod))
else:
    print(0)

Fixed submission:
# -*- coding: utf-8 -*-
def fact(x):
    f = 1
    for i in range(1,x+1):
        f *= i
        f %= 10**9+7
    return f             

n,m = map(int, raw_input().split())
mod = 10**9+7
if(n==m):
    print((2*(fact(n))**2)%mod)
elif(abs(n-m)==1):
    tmp = fact(min(n,m))
    print(max(n,m)*(tmp**2)%mod)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

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

x = map(int, raw_input().split())
y = map(int, raw_input().split())

area = 0
for i in range(n):
    for j in range(i,n):
        for k in range(m):
            for l in range(k,m):
                area += (x[j]-x[i])*(y[l]-y[k])
                area = area%1000000007
print(area)

Fixed submission:
# -*- coding: utf-8 -*-

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

x = map(int, raw_input().split())
y = map(int, raw_input().split())

mod = 10**9+7
xsum = 0
ysum = 0
for i in range(n):
    xsum += (2*(i+1)-n-1)*x[i]

for i in range(m):
    ysum += (2*(i+1)-m-1)*y[i]
area = xsum*ysum%mod
print(area)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

N = input()
S = raw_input()
Ans = ''
StartString = ['SS','SW','WS','WW']
CheckFlag = 0
for i in range(4):
    Ans += StartString[i]
    for j in range(N-1):
        if(Ans[j+1]=='S' and S[j+1]=='o'):
            Ans += Ans[j]
        elif(Ans[j+1]=='S' and S[j+1]=='x'):
            if(Ans[j]=='S'):
                Ans += 'W'
            else:
                Ans += 'S'
        elif(Ans[j+1]=='W' and S[j+1]=='o'):
            if(Ans[j]=='S'):
                Ans += 'W'
            else:
                Ans += 'S'
        elif(Ans[j+1]=='W' and S[j+1]=='x'):
            Ans += Ans[j]
    if(Ans[0]==Ans[N]):
        print(Ans[:N])
        CheckFlag = 1
        break
    else:
        Ans = ''
        
if(CheckFlag == 0):
    print('-1')


Fixed submission:
# -*- coding: utf-8 -*-
N = input()
paid = 800*N
cashback = (N/15)*200
print(paid-cashback)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

N = input()
power = 1
for i in range(N):
    power = power*(i+1)

print(power%1000000007)

Fixed submission:
# -*- coding: utf-8 -*-

import math

N = input()
power = 1
for i in range(N):
    power = math.fmod(power*(i+1),1000000007)

print(int(power))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

n,t = map(int, raw_input().split())
a = map(int, raw_input().split()) 

l,r = 0,0
diff = 0
num = 0
lp = 0
for l in range(n):
    if(a[lp]<a[l]):
        pass
    else:
        for r in range(l+1,n):
            #print(l,r)
            if(a[r]-a[l]>diff):
                lp = l
                diff = a[r]-a[l]
                num = 1
            elif(a[r]-a[l]==diff):
                num += 1
print(num)
            
 


Fixed submission:
# -*- coding: utf-8 -*-
 
n,t = map(int, raw_input().split())
a = map(int, raw_input().split()) 
 
m = 10**9+1
num = 0
diff = 0
for i in range(n):
    if(a[i]<m):
        m = a[i]
    if(a[i]-m > diff):
        diff = a[i]-m
        num = 1
    elif(a[i]-m == diff):
        num += 1
print(num)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

n,t = map(int, raw_input().split())
a = map(int, raw_input().split()) 

l,r = 0,0
diff = 0
num = 0
lp = 0
for l in range(n):
    if(a[lp]<a[l]):
        pass
    else:
        lp = l
        for r in range(l+1,n):
            if(a[r]-a[l]>diff):
                diff = a[r]-a[l]
                num = 1
            elif(a[r]-a[l]==diff):
                num += 1
print(num)
            
 


Fixed submission:
# -*- coding: utf-8 -*-
 
n,t = map(int, raw_input().split())
a = map(int, raw_input().split()) 
 
m = 10**9+1
num = 0
diff = 0
for i in range(n):
    if(a[i]<m):
        m = a[i]
    if(a[i]-m > diff):
        diff = a[i]-m
        num = 1
    elif(a[i]-m == diff):
        num += 1
print(num)
Buggy python submission (verdict: Time Limit Exceeded):
from math import gcd
import sys

MAXN = 10**6+10
sieve = [i for i in range(MAXN+1)]
p = 2
while p*p <= MAXN:
    if sieve[p] == p:
        for q in range(2*p,MAXN+1,p):
            if sieve[q] == q:
                sieve[q] = p
    p += 1
    
def pf(a):
    tmp = set()
    while a > 1:
        tmp.add(sieve[a])
        a //= sieve[a]
        
    return list(tmp)




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



g = 0
for a in A:
    g = gcd(g,a)
if g > 1:
    print('not coprime')
    sys.exit()

A=[i for i in A if i != 1]    

B=[pf(A[i]) for i in range(len(A))]
B=sum(B,[])

if len(B) == len(set(B)):
    print("pairwise coprime")
    
else:
    print("setwise coprime")
    

Fixed submission:
from math import gcd
import sys

MAXN = 10**6+10
sieve = [i for i in range(MAXN+1)]
p = 2
while p*p <= MAXN:
    if sieve[p] == p:
        for q in range(2*p,MAXN+1,p):
            if sieve[q] == q:
                sieve[q] = p
    p += 1
    
def pf(a):
    tmp = set()
    while a > 1:
        tmp.add(sieve[a])
        a //= sieve[a]
        
    return list(tmp)




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



g = 0
for a in A:
    g = gcd(g,a)
if g > 1:
    print('not coprime')
    sys.exit()

deta = set()
for a in A:
    a=pf(a)
    
    for p in a:
        if p in deta:
            print("setwise coprime")
            sys.exit()
            
        deta.add(p)


print("pairwise coprime")
Buggy python submission (verdict: Runtime Error):
n,m,k = map(int,input().split()) 
Al=list(map(int,input().split()) )
Bl=list(map(int,input().split()) )
bmax=0
A=[0]
B=[0]
for i in range(1,n+1):
    A[i] += A[i-1]+Al[i]  
for i in range(1,m+1):
    B[i] += B[i-1]+Bl[i]
    if B[i]<=k:
        bmax=i

ans=0
b=bmax
for a in range(len(A)):
    if A[a]>k:
        break
    # ans = max(ans, a+1)
    
    while A[a] + B[b] >k and b>=0:
        b -= 1
        
        
    ans = max(ans, a+b+2)
        
print(ans)


Fixed submission:
n,m,k = map(int,input().split()) 
Al=list(map(int,input().split()) )
Bl=list(map(int,input().split()) )
bmax=0
A=[0]
B=[0]
for i in range(1,n+1):
    A.append(A[i-1]+Al[i-1])  
for i in range(1,m+1):
    B.append(B[i-1]+Bl[i-1])
    if B[i]<=k:
        bmax=i

ans=0
b=bmax
for a in range(len(A)):
    if A[a]>k:
        break
    # ans = max(ans, a+1)
    
    while A[a] + B[b] >k and b>=0:
        b -= 1
        
        
    ans = max(ans, a+b)
        
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split()) 
print(n*m)

Fixed submission:
n,m = input().split()

n=int(n)
m=float(m)*100+0.5
m=int(m)

ans = int(n*m//100)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=list(map(int,input().split()) )

left = [i+A[i] for i in range(n)]
right = [i-A[i] for i in range(n)]

ans = 0

for l in left:
    ans += right.count(l)

print(ans)

Fixed submission:
from collections import Counter

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

left = [i+A[i] for i in range(n)]
right = [i-A[i] for i in range(n)]

r_counter = Counter(right)

ans = 0

for l in left:
    ans += r_counter[l]

print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,n = map(int,input().split()) 

ans=[]

for i in range(B):
    
    ans.append(int(a*i/b) - a * int(i/b))

print(max(ans))

Fixed submission:
a,b,n = map(int,input().split()) 

x=min(n,b-1)

ans = (int(a*x/b) - a * int(x/b))

print(ans)

Buggy python submission (verdict: Runtime Error):
a,b,n = map(int,input().split()) 

ans=[]

for i in range(B):
    
    ans.append(int(a*i/b) - a * int(i/b))

print(min(ans))

Fixed submission:
a,b,n = map(int,input().split()) 

x=min(n,b-1)

ans = (int(a*x/b) - a * int(x/b))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
import collections

n,x,y = map(int,input().split()) 

connect=[[i-1,i+1] for i in range(1,n-1)]
connect.insert(0,[1])
connect.append([n-2])
connect[x-1].append(y-1)
connect[y-1].append(x-1)

dist_from_i = []

for i in range(0,n):
    
    d=0
    dist = [10**6]*n
    
    dq=deque()
    dq.append([i,d])
    dist[i]=d
    
    while len(dq):
        
        x,d = dq.popleft()
                
        for nextx in connect[x]:
            if d<dist[nextx]:
                dq.append([nextx,d+1])
                dist[nextx] = d+1
                
    dist_from_i.append(dist)
            
    c = collections.Counter(sum(dist_from_i,[]))

for k in range(1,n):
    print(c[k]//2)
    

Fixed submission:
n,x,y = map(int,input().split()) 

dist = [0]*n

for i in range(0,n-1):
    for j in range(i,n):
        
        #xy使わない距離
        dist1 = j-i
        
        #xy使う距離
        dist2 = abs((x-1) - i) + 1 + abs((y-1) - j)
        
        
        # print(i,j,dist1,dist2)
        
        #最短距離
        dist_min = min(dist1,dist2)
        
        dist[dist_min] += 1
        
for k in range(1,n):
    print(dist[k])
Buggy python submission (verdict: Runtime Error):
n,a,b = map(int,input().split())

mod = 10**9+7

all_combi = pow(2,n,mod)




p = 1
q = 1

for i in range(b):
    
    p *= n-i
    p %= mod
    q *= i+1
    q %= mod
    
    if i==a-1:
        nca = p * pow(q,-1,mod) % mod
        
    if i==b-1:
        ncb = p * pow(q,-1,mod) % mod

        
ans = all_combi -nca -ncb -1
ans %= (10**9+7)
    
print(ans)

Fixed submission:
n,a,b = map(int,input().split())

mod = 10**9+7

all_combi = pow(2,n,mod)




p = 1
q = 1

for i in range(b):
    
    p *= n-i
    p %= mod
    q *= i+1
    q %= mod
    
    if i==a-1:
        nca = p * pow(q,mod-2,mod) % mod
        
    if i==b-1:
        ncb = p * pow(q,mod-2,mod) % mod

        
ans = all_combi -nca -ncb -1
ans %= (10**9+7)
    
print(ans)