Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
A,B,K = map(int,input().split())
kazu = list(range(A,B+1))
for i in kazu:
	if i < A+K or B-K < i:
		print(i)

Fixed submission:
A,B,K = map(int,input().split())
list_A = list(range(A,min(B,A+K)))
list_B = list(range(max(A,B-K+1),B+1))
list_C = list_A + list_B
set_C = set(list_C)
list_D = sorted(list(set_C))
for i in list_D:
	print(i)

Buggy python submission (verdict: Runtime Error):
A,B,K = map(int,input().split())
list1 = list(range(A,B+1))
for i in list1:
	if i < A+K or B-K < i:
		print(i)

Fixed submission:
A,B,K = map(int,input().split())
list_A = list(range(A,min(B,A+K)))
list_B = list(range(max(A,B-K+1),B+1))
list_C = list_A + list_B
set_C = set(list_C)
list_D = sorted(list(set_C))
for i in list_D:
	print(i)

Buggy python submission (verdict: Runtime Error):
A,B,K = map(int,input().split())
list1 = list(range(A,B+1))
for i in list1:
	if A+K <= i <= B-K:
		pass
	else:
		print(i)

Fixed submission:
A,B,K = map(int,input().split())
list_A = list(range(A,min(B,A+K)))
list_B = list(range(max(A,B-K+1),B+1))
list_C = list_A + list_B
set_C = set(list_C)
list_D = sorted(list(set_C))
for i in list_D:
	print(i)
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
a=[int(x)for x in list(sys.argv[1][0:3])]+[-1]
print(str(a[0]+0if(np.trim_zeros(np.diff(a))[0]<0)else 1)*3)


Fixed submission:
import sys
import numpy as np
a=[int(x)for x in list(sys.stdin.readline()[0:3])]+[-1]
print(str(a[0]+(1if(np.trim_zeros(np.diff(a))[0]>0)else 0))*3)

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
a=[int(x)for x in list(sys.argv[1])]+[-1]
print(str(a[0]+0if(np.trim_zeros(np.diff(a))[0]<0)else 1)*3)


Fixed submission:
import sys
import numpy as np
a=[int(x)for x in list(sys.stdin.readline()[0:3])]+[-1]
print(str(a[0]+(1if(np.trim_zeros(np.diff(a))[0]>0)else 0))*3)
Buggy python submission (verdict: Runtime Error):
s = list[input()]
ans = 0
for c in s:
  if c == '+':
    ans += 1
  else:
    ans -= 1
print(ans)

Fixed submission:
s = list(input())
ans = 0
for c in s:
  if c == '+':
    ans += 1
  else:
    ans -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
dp = [None for _ in range(N)]
for i in range(N):
  p = int(input())
  if (p != 1) and (dp[p - 2] == None):
    dp[p - 1] = 1
  else:
    dp[p - 1] = dp[p - 2] + 1
print(N - max(dp))

Fixed submission:
N = int(input())
dp = [None for _ in range(N)]
for i in range(N):
  p = int(input())
  if dp[p - 2] == None or p == 1:
    dp[p - 1] = 1
  else:
    dp[p - 1] = dp[p - 2] + 1
print(N - max(dp))

Buggy python submission (verdict: Runtime Error):
N = int(input())
dp = [None for _ in range(N)]
for i in range(N):
  p = int(input())
  if p != 1 and (dp[p - 2]) == None:
    dp[p - 1] = 1
  else:
    dp[p - 1] = dp[p - 2] + 1
print(N - max(dp))

Fixed submission:
N = int(input())
dp = [None for _ in range(N)]
for i in range(N):
  p = int(input())
  if dp[p - 2] == None or p == 1:
    dp[p - 1] = 1
  else:
    dp[p - 1] = dp[p - 2] + 1
print(N - max(dp))

Buggy python submission (verdict: Runtime Error):
N = int(input())
dp = [None for _ in range(N)]
for i in range(N):
  p = int(input())
  if 0 <= p - 2 and dp[p - 2] == None:
    dp[p - 1] = 1
  else:
    dp[p - 1] = dp[p - 2] + 1
print(N - max(dp))

Fixed submission:
N = int(input())
dp = [None for _ in range(N)]
for i in range(N):
  p = int(input())
  if dp[p - 2] == None or p == 1:
    dp[p - 1] = 1
  else:
    dp[p - 1] = dp[p - 2] + 1
print(N - max(dp))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
groups = []
for i in range(N):
  p = int(input())
  b = False
  for g in groups:
    if g[len(g) - 1] == p - 1:
      g.append(p)
      b = True
      break
  if not b:
    groups.append([p])
lengths = list(map(len, groups))
print(N - max(lengths))

Fixed submission:
N = int(input())
dp = [None for _ in range(N)]
for i in range(N):
  p = int(input())
  if dp[p - 2] == None or p == 1:
    dp[p - 1] = 1
  else:
    dp[p - 1] = dp[p - 2] + 1
print(N - max(dp))
Buggy python submission (verdict: Runtime Error):
Python Editor 5.2.0.    New   Open   Save   Run   Export  untitle.py [no ads ?]  Snippets    

print(A)
1
import numpy as np
2
​
3
A, B, C = (list(map(int, input().split())))
4
if(A == B):
5
  print(C)
6
elif(A == C):
7
  print(B)
8
else:
9
  print(A)


Fixed submission:
import numpy as np

A, B, C = (list(map(int, input().split())))
if(A == B):
  print(C)
elif(A == C):
  print(B)
else:
  print(A)
Buggy python submission (verdict: Runtime Error):
N = input()
D = map(int, raw_input().split())
M = input()
T = map(int, raw_input().split())
var = []
result = True
for i in range(N):
  var[D[i]] += 1
for j in range(M):
  if(var[T[j]] == 0):
    result = False
    break
  else:
    var[T[j]] -= 1
if(result):
  print("YES")
else:
  print("NO")

Fixed submission:
import numpy as np

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
res = True
dic = {}
for i in range(N):
  if D[i] in dic:
    dic[D[i]] += 1
  else:
    dic[D[i]] = 1
for j in range(M):
  if (dic.get(T[j], 0) == 0):
    res = False
    break
  else:
    dic[T[j]] -= 1
if(res):
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
#import numpy as np

def FindMaxCon(res, water, C, D, E):
  c = 0
  d = 0
  tmpCon = 0
  dp = list([False] * 3001)
  dp[0] = True
  for i in range(3001):
    if(i - C >= 0 and i - D >= 0):
      dp[i] = dp[i - C] or dp[i - D]
    elif(i - C >= 0):
      dp[i] = dp[i - C]
    elif(i - D >= 0):
      dp[i] = dp[i - D]
  tmpSugar = 0
  for i in range(min(res, int(E * water / 100)) + 1):
    if(dp[i]):
      tmpSugar = i
  ans = tmpSugar
  return ans

A, B, C, D, E, F = (int(_) for _ in input().split())
amax = F / (A * 100)
bmax = F / (B * 100)
amax = int(amax)
bmax = int(bmax)
water = 0
sugar = 0
waterAns= 100 * A
sugarAns = 0
con = 0
conAns = 0
for a in range(1, amax + 1):
  for b in range(bmax + 1):
    water = 100 * (a * A + b * B)
    if(water > F):
      continue
    else:
      res = F - water
      tmp = FindMaxCon(res, water, C, D, E)
      sugar = tmp
      con = sugar / water
      if(con > conAns):
        conAns = con
        waterAns = water
        sugarAns = sugar
answer = str(waterAns + sugarAns) + " " + str(sugarAns)
print(answer)

Fixed submission:
import numpy as np

N = int(input())
A = int(input())

print(N**2 - A)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

for i in range(n):
  j = i + 1
  b = a.count(j)
  print(b)


Fixed submission:
import numpy as np

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

b = np.zeros(shape=(n), dtype=np.int)

for i in a:
  b[i-1] += 1

for i in range(n):
  print(b[i])

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

for i in range(n):
  j = i + 1
  b = a.count(j)
  print(b)

Fixed submission:
import numpy as np

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

b = np.zeros(shape=(n), dtype=np.int)

for i in a:
  b[i-1] += 1

for i in range(n):
  print(b[i])
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())

a = 1
for i in range(k, n + 1):
  mmin = summ(i - 1)
  mmax = summ(n, n - i)
  m = mmax - mmin + 1
  a += m

k = 10**9 + 7
print(int(a%k))

    
def summ(n, nn=0):
  nn = max(nn, 0)
  return n*(n+1)/2 - nn*(nn+1)/2


Fixed submission:
def summ(n, nn=0):
  nn = max(nn, 0)
  return n*(n+1)/2 - nn*(nn+1)/2

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

a = 1
for i in range(k, n + 1):
  mmin = summ(i - 1)
  mmax = summ(n, n - i)
  m = mmax - mmin + 1
  a += m

k = 10**9 + 7
print(int(a%k))

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

a = 1
for i in range(k, n + 1):
  mmin = summ(i - 1)
  mmax = summ(n, n - i)
  m = mmax - mmin + 1
  a += m

  k = 10**9 + 7
  print(int(a%k))

    
def summ(n, nn=0):
  nn = max(nn, 0)
  return n*(n+1)/2 - nn*(nn+1)/2


Fixed submission:
def summ(n, nn=0):
  nn = max(nn, 0)
  return n*(n+1)/2 - nn*(nn+1)/2

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

a = 1
for i in range(k, n + 1):
  mmin = summ(i - 1)
  mmax = summ(n, n - i)
  m = mmax - mmin + 1
  a += m

k = 10**9 + 7
print(int(a%k))

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

a = 1
for i in range(k, n + 1):
  mmin = summ(i - 1)
  mmax = summ(n, n - i)
  m = mmax - mmin + 1
  a += m
  # print('{},{},{}'.format(i, mmin, mmax))

  k = 10**9 + 7
  print(a%k)

    
def summ(n, nn=0):
  nn = max(nn, 0)
  return n*(n+1)/2 - nn*(nn+1)/2


Fixed submission:
def summ(n, nn=0):
  nn = max(nn, 0)
  return n*(n+1)/2 - nn*(nn+1)/2

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

a = 1
for i in range(k, n + 1):
  mmin = summ(i - 1)
  mmax = summ(n, n - i)
  m = mmax - mmin + 1
  a += m

k = 10**9 + 7
print(int(a%k))

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

a = 1
for i in range(k, n + 1):
  mmin = summ(i)
  mmax = summ(n, n - i)
  m = mmax - mmin
  a += m

print(a)

def summ(n, nn=0):
  nn = max(nn, 0)
  return n*(n+1)/2 - nn*(nn+1)/2


Fixed submission:
def summ(n, nn=0):
  nn = max(nn, 0)
  return n*(n+1)/2 - nn*(nn+1)/2

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

a = 1
for i in range(k, n + 1):
  mmin = summ(i - 1)
  mmax = summ(n, n - i)
  m = mmax - mmin + 1
  a += m

k = 10**9 + 7
print(int(a%k))

Buggy python submission (verdict: Runtime Error):
import numpy as np

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

a = 1
for i in range(k, n + 1):
  mmin = summ(i)
  mmax = summ(n, n - i)
  m = mmax - mmin
  a += m
  
def summ(n, nn=0):
  nn = max(nn, 0)
  return n*(n+1)/2 - nn*(nn+1)/2

Fixed submission:
def summ(n, nn=0):
  nn = max(nn, 0)
  return n*(n+1)/2 - nn*(nn+1)/2

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

a = 1
for i in range(k, n + 1):
  mmin = summ(i - 1)
  mmax = summ(n, n - i)
  m = mmax - mmin + 1
  a += m

k = 10**9 + 7
print(int(a%k))
Buggy python submission (verdict: Runtime Error):
import cmath

param = list(map(int,input().split()))

A = param[0]
B = param[1]
h = param[2]
m = param[3]

print(abs(A*pow(math.e, (math.pi*m/30)*1j) - B*pow(math.e, (math.pi*h/6)*1j))

Fixed submission:
import cmath

param = list(map(int,input().split()))

A = param[0]
B = param[1]
h = param[2]
m = param[3]

v = (A*pow(cmath.e, (cmath.pi*m/30)*1j) - B*pow(cmath.e, (cmath.pi*h/6 + cmath.pi*m/360)*1j))

print(abs(v))
Buggy python submission (verdict: Time Limit Exceeded):
#C
n = int(input())
a = list(map(int, input().split()))

stu = [0] * n

for i in range(n):
    come = a.index(i + 1) + 1
    stu[i] = come
print(*stu)


Fixed submission:
#C
n = int(input())
a = list(map(int, input().split()))

stu = [0] * n

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

print(*stu)
Buggy python submission (verdict: Runtime Error):
#D
from fraction import gcd
#from math import gcd
import collections
a, b = map(int,input().split())
tmp = gcd(a, b)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

if tmp == 1:
    l = 1
    ans = 1
else:
    l = prime_factorize(tmp)
    clist = collections.Counter(prime_factorize(840))
    ans = len(clist.keys())
print(ans)



Fixed submission:
#D
from fractions import gcd
#from math import gcd
import collections
a, b = map(int,input().split())
tmp = gcd(a, b)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

if tmp == 1:
    l = 1
    ans = 1
else:
    l = prime_factorize(tmp) + [1]
    clist = collections.Counter(l)
    ans = len(clist.keys())
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
acgt = ['A','C','G','T']
N, Q = map(int, input().split())
S = list(input())
for _ in range(Q):
    cnt = 0
    li, ri = map(int, input().split())
    tmpS = S[li-1:ri]
    i = 1
    while i < len(tmpS):
        t = tmpS[i]
        if t == 'A':
            i += 1
        elif t == 'C':
            if tmpS[i-1] == 'A':
                cnt += 1
            i += 2
        else:
            i += 2
    print(cnt)


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

cnt = 0
tmpS = S
i = 1
L = [0]
lapp = L.append
while i < N:
    t = tmpS[i]
    if t == 'A':
        lapp(cnt)
        i += 1
    elif t == 'C':
        if tmpS[i-1] == 'A':
            cnt += 1
        lapp(cnt)
        lapp(cnt)
        i += 2
    else:
        lapp(cnt)
        lapp(cnt)
        i += 2
for _ in range(Q):
    li, ri = map(int, input().split())
    print(L[ri - 1] - L[li - 1])

Buggy python submission (verdict: Time Limit Exceeded):
acgt = ['A','C','G','T']
N, Q = map(int, input().split())
S = list(input())
for _ in range(Q):
    cnt = 0
    li, ri = map(int, input().split())
    tmpS = S[li-1:ri]
    i = 1
    while i < len(tmpS):
        if tmpS[i] == 'C':
            if tmpS[i - 1] == 'A':
                cnt += 1
        i += 1
    print(cnt)


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

cnt = 0
tmpS = S
i = 1
L = [0]
lapp = L.append
while i < N:
    t = tmpS[i]
    if t == 'A':
        lapp(cnt)
        i += 1
    elif t == 'C':
        if tmpS[i-1] == 'A':
            cnt += 1
        lapp(cnt)
        lapp(cnt)
        i += 2
    else:
        lapp(cnt)
        lapp(cnt)
        i += 2
for _ in range(Q):
    li, ri = map(int, input().split())
    print(L[ri - 1] - L[li - 1])
Buggy python submission (verdict: Runtime Error):
T, X = map(int, input.split()) 
print(T / X)



Fixed submission:
T, X = map(int, input().split()) 
print(T / X)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
M = list(map(lambda x: int(x)-1, input().split()))
s = 0
order = [s]
sets = set(order)
while True:
  if M[s] in sets:
    #print(order, M[s])
    
    if K < order.index(M[s]):
      print(order[K-1]+1)
    else:
      K -= order.index(M[s])
      order = order[order.index(M[s]):]
      print(order[K%len(order)]+1)
    break
  order.append(M[s])
  sets.add(M[s])
  s = M[s]



Fixed submission:
A = input()
B = input()
print("Yes") if len(A)+1==len(B) and A == B[:len(A)] else print("No")

Buggy python submission (verdict: Runtime Error):
A = input()
B = input()
print("Yes") if A == B[:len(A)] and len(A)+1=len(B) else print("No")

Fixed submission:
A = input()
B = input()
print("Yes") if len(A)+1==len(B) and A == B[:len(A)] else print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import itertools
N, M, K = map(int, input().split())
Q = [np.asarray(input().split(), dtype=int) for i in range(N)]
min_cost = 10**9
for q in itertools.permutations(Q):
  cost = 0
  C = np.zeros(M)
  for i in q:
    cost += i[0]
    C = C + i[1:]
    if (C >= K).all():
      min_cost = min([cost, min_cost])
      break
print(min_cost) if min_cost != 10**9 else print(-1)


Fixed submission:
import numpy as np
import itertools
N, M, K = map(int, input().split())
Q = [np.asarray(input().split(), dtype=int) for i in range(N)]
min_cost = 10**9
def dfs(cost, C, depth=0):
  global min_cost
  if (C >= K).all():
    min_cost = min([cost, min_cost])
    return
  if depth == N:
    return
  dfs(cost+Q[depth][0], C + Q[depth][1:], depth+1)
  dfs(cost, C, depth+1)
  
dfs(0, np.zeros(M))
    
print(min_cost) if min_cost != 10**9 else print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N, M, K = map(int, input().split())
Q = [list(map(int, input().split())) for i in range(N)]
min_cost = 10**9
for q in itertools.permutations(Q):
  cost = 0
  C = [0] * M
  for i in q:
    cost += i[0]
    for j,c in enumerate(i[1:]):
      C[j] += c
    if len([c for c in C if c >= K]) == M:
      min_cost = min([cost, min_cost])
      break
print(min_cost) if min_cost != 10**9 else print(-1)


Fixed submission:
import numpy as np
import itertools
N, M, K = map(int, input().split())
Q = [np.asarray(input().split(), dtype=int) for i in range(N)]
min_cost = 10**9
def dfs(cost, C, depth=0):
  global min_cost
  if (C >= K).all():
    min_cost = min([cost, min_cost])
    return
  if depth == N:
    return
  dfs(cost+Q[depth][0], C + Q[depth][1:], depth+1)
  dfs(cost, C, depth+1)
  
dfs(0, np.zeros(M))
    
print(min_cost) if min_cost != 10**9 else print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N, M, K = map(int, input().split())
Q = [list(map(int, input().split())) for i in range(N)]
min_cost = 10**9
for q in itertools.permutations(Q):
  cost = 0
  C = [0] * M
  for i in q:
    cost += i[0]
    for j,c in enumerate(i[1:]):
      C[j] += c
    if len([c for c in C if c >= K]) == M:
      min_cost = min([cost, min_cost])
      break
print(min_cost) if min_cost != 10**9 else print(-1)

Fixed submission:
import numpy as np
import itertools
N, M, K = map(int, input().split())
Q = [np.asarray(input().split(), dtype=int) for i in range(N)]
min_cost = 10**9
def dfs(cost, C, depth=0):
  global min_cost
  if (C >= K).all():
    min_cost = min([cost, min_cost])
    return
  if depth == N:
    return
  dfs(cost+Q[depth][0], C + Q[depth][1:], depth+1)
  dfs(cost, C, depth+1)
  
dfs(0, np.zeros(M))
    
print(min_cost) if min_cost != 10**9 else print(-1)
Buggy python submission (verdict: Runtime Error):
import sys
X = int(input())
MAX = 10**9
M = [0]
i = 1
while i**5 < MAX:
  M.append(i**5)
  M.append(-i**5)
  i += 1
#print(M)
  
for i in M:
  for j in M:
    if (i%MAX - j%MAX)%MAX == X%MAX:
      if j < 0:
        print(int(i**(1/5)), -int((-j)**(1/5)))
      else:
        print(int(i**(1/5)), int(j**(1/5)))
      sys.exit(0)


Fixed submission:
import sys
X = int(input())
MOD = 10**9+7
M = [i*m for i in range(0, 10**4) for m in [-1, 1]]
for i in range(0, 10**4):
  for j in M:
    if i == j:
      break
    if X%(i-j)==0:
      if i**5-j**5==X:
        print(i, j)
        sys.exit(0)

Buggy python submission (verdict: Runtime Error):
import sys
X = int(input())
MAX = 10**9
M = [0]
i = 1
while i**5 < MAX:
  M.append(i**5)
  M.append(-i**5)
  i += 1
#print(M)
  
for i in M:
  for j in M:
    if (i%MAX - j%MAX)%MAX == X%MAX:
      if j < 0:
        print(int(i**(1/5)), -int((-j)**(1/5)))
      else:
        print(int(i**(1/5)), int(j**(1/5)))
      sys.exit(0)


Fixed submission:
import sys
X = int(input())
MOD = 10**9+7
M = [i*m for i in range(0, 10**4) for m in [-1, 1]]
for i in range(0, 10**4):
  for j in M:
    if i == j:
      break
    if X%(i-j)==0:
      if i**5-j**5==X:
        print(i, j)
        sys.exit(0)

Buggy python submission (verdict: Runtime Error):
import sys
X = int(input())
MAX = 10**9
M = [0]
i = 1
while i**5 < MAX:
  M.append(i**5)
  M.append(-i**5)
  i += 1
#print(M)
  
for i in M:
  for j in M:
    if i - j == X:
      if j < 0:
        print(int(i**(1/5)), -int((-j)**(1/5)))
      else:
        print(int(i**(1/5)), int(j**(1/5)))
      sys.exit(0)


Fixed submission:
import sys
X = int(input())
MOD = 10**9+7
M = [i*m for i in range(0, 10**4) for m in [-1, 1]]
for i in range(0, 10**4):
  for j in M:
    if i == j:
      break
    if X%(i-j)==0:
      if i**5-j**5==X:
        print(i, j)
        sys.exit(0)

Buggy python submission (verdict: Runtime Error):
import sys
X = int(input())
MAX = 10**9
M = [1, -1]
i = 1
while i**5 < MAX:
  i += 1
  M.append(i**5)
  M.append(-i**5)
  
for i in M:
  for j in M:
    if i - j == X:
      if j < 0:
        print(int(i**(1/5)), -int((-j)**(1/5)))
      else:
        print(int(i**(1/5)), int(j**(1/5)))
      sys.exit(0)


Fixed submission:
import sys
X = int(input())
MOD = 10**9+7
M = [i*m for i in range(0, 10**4) for m in [-1, 1]]
for i in range(0, 10**4):
  for j in M:
    if i == j:
      break
    if X%(i-j)==0:
      if i**5-j**5==X:
        print(i, j)
        sys.exit(0)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
M = np.asarray(input().split(), dtype=int)
C = np.arange(1,N+1)
print(np.sum([np.sum(M[i+M[i]+1:]==C[:N-i-M[i]-1]) for i in range(N)]))

Fixed submission:
N = int(input())
M = list(map(int, input().split()))
L = [0] * N
R = [0] * N
for i,m in enumerate(M):
  if i+m >= N:
    continue
  L[i+m] += 1
for i,m in enumerate(M[::-1]):
  if i+m >= N:
    continue
  R[i+m] += 1
R = R[::-1]
#print(L)
#print(R)
print(sum([l*r for l,r in zip(L,R)]))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
M = np.asarray(input().split(), dtype=int)
print(np.sum([np.sum(M[i+M[i]+1:]==np.arange(1,N-i-M[i])) for i in range(N)]))

Fixed submission:
N = int(input())
M = list(map(int, input().split()))
L = [0] * N
R = [0] * N
for i,m in enumerate(M):
  if i+m >= N:
    continue
  L[i+m] += 1
for i,m in enumerate(M[::-1]):
  if i+m >= N:
    continue
  R[i+m] += 1
R = R[::-1]
#print(L)
#print(R)
print(sum([l*r for l,r in zip(L,R)]))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
M = np.asarray(input().split(), dtype=int)
result = 0
for i in range(N):
  x = M[i]
  result += np.sum(M[i+x+1:]==np.arange(1,N-i-x))
print(result)

Fixed submission:
N = int(input())
M = list(map(int, input().split()))
L = [0] * N
R = [0] * N
for i,m in enumerate(M):
  if i+m >= N:
    continue
  L[i+m] += 1
for i,m in enumerate(M[::-1]):
  if i+m >= N:
    continue
  R[i+m] += 1
R = R[::-1]
#print(L)
#print(R)
print(sum([l*r for l,r in zip(L,R)]))

Buggy python submission (verdict: Time Limit Exceeded):
#import numpy as np
N = int(input())
M = list(map(int, input().split()))
result = 0
for i in range(N):
  x = M[i]
  #print(i, x)
  result += len([1 for m,n in enumerate(range(i+x+1, N)) if m+1 == M[n]])
print(result)


Fixed submission:
N = int(input())
M = list(map(int, input().split()))
L = [0] * N
R = [0] * N
for i,m in enumerate(M):
  if i+m >= N:
    continue
  L[i+m] += 1
for i,m in enumerate(M[::-1]):
  if i+m >= N:
    continue
  R[i+m] += 1
R = R[::-1]
#print(L)
#print(R)
print(sum([l*r for l,r in zip(L,R)]))

Buggy python submission (verdict: Time Limit Exceeded):
#import numpy as np
N = int(input())
M = list(map(int, input().split()))
result = 0
for i in range(N):
  x = M[i]
  #print(i, x)
  result += len([1 for m,n in enumerate(range(i+x+1, N)) if m+1 == M[n]])
print(result)

Fixed submission:
N = int(input())
M = list(map(int, input().split()))
L = [0] * N
R = [0] * N
for i,m in enumerate(M):
  if i+m >= N:
    continue
  L[i+m] += 1
for i,m in enumerate(M[::-1]):
  if i+m >= N:
    continue
  R[i+m] += 1
R = R[::-1]
#print(L)
#print(R)
print(sum([l*r for l,r in zip(L,R)]))
Buggy python submission (verdict: Runtime Error):
N, M, Q = list(map(int, input().split()))
Qs = [list(map(int, input().split())) for i in range(Q)]

patterns = []
def dfs(a):
  if len(a) == N:
    patterns.append(a)
  else:
    for i in range(int(a[-1]), M+1):
   	  dfs(a+str(i))

dfs("1")
result = 0
for p in patterns:
  p = [int(i) for i in p]
  r = 0
  for q in Qs:
    if p[q[1]-1]-p[q[0]-1]==q[2]:
      r += q[3]
  #print(p, r)
  result = max([result, r])
print(result)

Fixed submission:
N, M, Q = list(map(int, input().split()))
Qs = [list(map(int, input().split())) for i in range(Q)]

patterns = []
def dfs(a):
  if len(a) == N:
    patterns.append(a)
  else:
    for i in range(int(a[-1]), M+1):
   	  dfs(a+[i])

dfs(a=[1])
result = 0
for p in patterns:
  r = 0
  for q in Qs:
    if p[q[1]-1]-p[q[0]-1]==q[2]:
      r += q[3]
  #print(p, r)
  result = max([result, r])
print(result)