Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n, m = list(map(int, input().split()))

ranges = np.array([0] * (n))
for i in range(m):
  r, l = list(map(int, input().split()))
  ranges[r-1:l] += 1
  
print((ranges == m).sum())

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

R, L = [], []
for i in range(m):
  l, r = list(map(int, input().split()))
  R.append(r)
  L.append(l)
  
print(max(min(R) - max(L) + 1, 0))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n, m = list(map(int, input().split()))
rl = [list(map(int, input().split())) for i in range(m)]

ranges = np.array([0] * (n))
for r, l in rl:
  ranges[r-1:l] += 1
  
print((ranges == m).sum())

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

R, L = [], []
for i in range(m):
  l, r = list(map(int, input().split()))
  R.append(r)
  L.append(l)
  
print(max(min(R) - max(L) + 1, 0))
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, n = list(map(int, input().split()))

cnt = []
for r in range(n//R + 1):
  nn = n - r*R
  for g in range(nn//G + 1):
    nnn = nn - g*G
    if nnn % B == 0:
      cnt.append([r, g, nnn // B])
print(len(cnt))
    

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

cnt = 0
for i in range(n//a+1):
  an = n - a * i
  for j in range(an//b+1):
    num = an - b * j
    if num >= 0 and num % c == 0:
      cnt+=1
        
print(cnt)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
print(2*min(Counter(list(input()).values()))

Fixed submission:
A, B, C = list(map(int, input().split()))
print(min(B//A, C))
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = [int(i) for i in intpu().split()]

s = sorted(s, reverse=True)
print("Yes" if s[0] < sum(s[1:]) else "No")

Fixed submission:
n = int(input())
x = [int(i) for i in input().split()]
x = sorted(x, reverse=True)
print("Yes" if x[0] < sum(x[1:]) else "No")
Buggy python submission (verdict: Runtime Error):
N = int(intput())

if N == 1:
  print('Hello World')

else:
  print(sum([int(input()) for i in range(2)]))


Fixed submission:
N = int(input())

if N == 1:
  print('Hello World')

else:
  print(sum([int(input()) for i in range(2)]))

Buggy python submission (verdict: Runtime Error):
N, a, b = [int(input()) for i in range(3)]

print('Hello World' if N == 1 else str(a + b))

Fixed submission:
N = int(input())

if N == 1:
  print('Hello World')

else:
  print(sum([int(input()) for i in range(2)]))

Buggy python submission (verdict: Runtime Error):
N, a, b = [int(input()) for i in range(3)]

print('Hello World' if N == 1 else a + b)

Fixed submission:
N = int(input())

if N == 1:
  print('Hello World')

else:
  print(sum([int(input()) for i in range(2)]))
Buggy python submission (verdict: Runtime Error):
s = input()
n = int(input())

for i in range(len(s)):
    if s[i] != "1":
        print(s[i])
        break
        
    else:
        k -= 1
        if k == 0:
            print(1)
            break


Fixed submission:
s = input()
k = int(input())

for i in range(len(s)):
    if s[i] != "1":
        print(s[i])
        break
        
    else:
        k -= 1
        if k == 0:
            print(1)
            break
Buggy python submission (verdict: Runtime Error):
h, w = list(map(int, input().split()))
maps = [list(input()) for i in range(h)]

def search(i, j):
  for dh, dw in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
    x = max(0, min(i + dw, w-1))
    y = max(0, min(j + dh, h-1))
    if i == y and j == x: continue 
    if maps[x][y] == "#":
      return True
  return False

flag = True
for i in range(h):
  for j in range(w):
    if maps[i][j] == "#" and not search(i, j):
        flag = False
        break
        
print("Yes" if flag else "No")

Fixed submission:
import numpy as np
h, w = list(map(int, input().split()))
s = np.array([list(input()) for i in range(h)])

infer = []
for i in range(h):
  for j in range(w):
    if s[i][j] == "#":
      pts = set([
        (max(0, i-1), j), 
        (i, max(0, j-1)), 
        (min(h-1, i+1), j), 
        (i, min(w-1, j+1))
      ])
      check = np.array([ s[ix][iy] for ix, iy in list(pts - set([(i, j)])) ])
      infer.append((check == "#").sum())

print("No" if 0 in infer else "Yes")
Buggy python submission (verdict: Time Limit Exceeded):
A, B, C, x, y = list(map(int, input().split()))

cost = 1e+12
for i in range(x+1):
  for j in range(y+1):
    z = max(x-i, y-j) * 2
    cost = min(cost, A * i + B * j + C * z)
print(cost)

Fixed submission:
a, b, ab, x, y = list(map(int, input().split()))

ab1 = ab * 2
abp = a + b
mins = min(x, y)
maxs = max(x, y)
nedan = min(ab1, abp) * mins

x -= mins
y -= mins
nedan_abp = x * a + y * b
nedan_ab = (maxs - mins) * ab1

if nedan_abp > nedan_ab:
  nedan += nedan_ab
else:
  nedan += nedan_abp
  
print(nedan)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = list(map(int, input().split()))

for i, x in enumerate(range(a, b+1)):
  if i < k or (0 <= (b-a) - i and (b-a) - i < k):
    print(x)

Fixed submission:
a,b,k=map(int,input().split())
l=range(a,b+1)
ans=sorted(set(l[:k])|set(l[-k:]))
for i in ans:
    print(i)
Buggy python submission (verdict: Runtime Error):
import math
a, b = list(map(int, input().split()))
x = a * 100 + b

flag = False
for i in range(1,int(math.sqrt(x))+1):
    if i ** 2 == x:
        flag =True
        break:

print("Yes" if flag else "No")

Fixed submission:
import math
a, b = input().split()
x = int(a) * 10 ** len(b) + int(b)

flag = False
for i in range(1,int(math.sqrt(x))+1):
    if i ** 2 == x:
        flag =True
        break

print("Yes" if flag else "No")

Buggy python submission (verdict: Runtime Error):
import math
a, b = list(map(int, input().split()))
x = a * 100 + b

flag = False
for i in range(1,int(math.sqrt(x))+1):
    if i ** 2 == x:
        flag =True
        break:

print("Yes" if flag 2 else "No")

Fixed submission:
import math
a, b = input().split()
x = int(a) * 10 ** len(b) + int(b)

flag = False
for i in range(1,int(math.sqrt(x))+1):
    if i ** 2 == x:
        flag =True
        break

print("Yes" if flag else "No")
Buggy python submission (verdict: Time Limit Exceeded):
def reduce(n):
  if n == 0:
    return 2
  
  if n == 1:
    return 1
  
  return reduce(n-1) + reduce(n-2)

print(reduce(int(input())))

Fixed submission:
n = int(input())

l = [0 for i in range(n+1)]
l[0], l[1] = 2, 1
for i in range(2, n+1):
  l[i] = l[i-1]+l[i-2]

print(l[-1])
Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
cnt = [0 for i in range(10**6)]

for i in range(n):
  cnt[int(input())-1] += 1
  
print( (np.array(cnt) % 2).sum())

Fixed submission:
from collections import Counter
n = int(input())
a = Counter([int(input()) for i in range(n)])

cnt = 0
for k, v in a.items():
  if v % 2 == 1:
    cnt += 1
print(cnt)

Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
cnt = [0 for i in range(10**6)]

for ai in a:
  cnt[int(input())-1] += 1
  
print( (np.array(cnt) % 2).sum())

Fixed submission:
from collections import Counter
n = int(input())
a = Counter([int(input()) for i in range(n)])

cnt = 0
for k, v in a.items():
  if v % 2 == 1:
    cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
a = [int(input()) for i in range(n)]
cnt = [0 for i in range(max(a))]

for ai in a:
  cnt[ai-1] += 1
  
print( (np.array(cnt) % 2).sum())

Fixed submission:
from collections import Counter
n = int(input())
a = Counter([int(input()) for i in range(n)])

cnt = 0
for k, v in a.items():
  if v % 2 == 1:
    cnt += 1
print(cnt)

Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = [int(input()) for i in range(n)]
cnt = [0 for i in range(1000000)]

for ai in a:
  cnt[ai-1] += 1
  
print( (np.array(cnt) % 2).sum())

Fixed submission:
from collections import Counter
n = int(input())
a = Counter([int(input()) for i in range(n)])

cnt = 0
for k, v in a.items():
  if v % 2 == 1:
    cnt += 1
print(cnt)

Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
cnt = [0 for i in range(1000000)]

for i in range(n):
  cnt[int(input())-1] += 1
  
print( (np.array(cnt) % 2).sum())

Fixed submission:
from collections import Counter
n = int(input())
a = Counter([int(input()) for i in range(n)])

cnt = 0
for k, v in a.items():
  if v % 2 == 1:
    cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
a = np.array([[int(i) + 1, int(i), int(i)-1] for i in input().split()])

maxs = 0
for i in range(a.min(), a.max() + 1):
  maxs = max(maxs, (a==i).sum())

print(maxs)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
li=[]

for i in a:
    li.append(i-1)
    li.append(i+1)
    li.append(i)

import collections
L=collections.Counter(li)
print(max(L.values()))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
a = list(map(int, input().split()))
ap = [i+1 for i in a]
am = [i-1 for i in a]
a = np.array([ap, a, am])

maxs = 0
for i in range(a.min(), a.max() + 1):
  maxs = max(maxs, (a==i).sum())

print(maxs)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
li=[]

for i in a:
    li.append(i-1)
    li.append(i+1)
    li.append(i)

import collections
L=collections.Counter(li)
print(max(L.values()))
Buggy python submission (verdict: Runtime Error):
import collections

n = int(input())
p = list(map(int,input().split()))
cnt = collections.Counter(p)

maxs = []
for k, v in cnt.items():
  if v > 1:
    maxs.append(k)
    
if len(maxs) > 1:
  maxs.sort()
  if len(maxs[-1]) > 3:
    print(maxs[-1] ** 2)
  else:
    print(maxs[-1] * maxs[-2])

else:
  print(0)

Fixed submission:
import collections

n = int(input())
p = list(map(int,input().split()))
cnt = collections.Counter(p)

maxs = []
for k, v in cnt.items():
  if v > 1:
    maxs.append(k)
    
if len(maxs) > 1:
  maxs.sort()
  if cnt[maxs[-1]] > 3:
    print(maxs[-1] ** 2)
  else:
    print(maxs[-1] * maxs[-2])

else:
  print(0)
Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))

a4 = len(a[a % 4 == 0])
a2 = len(a[a % 2 == 0 and a % 4 != 0])
a4n = len(a[a % 4 != 0]) - a2 

if a2 != 0:
  print("Yes" if a4 + 1 >= a4n+1 else "No")

else:
  print("Yes" if a4 + 1 >= a4n else "No")

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

a4, a4n, a2 = 0, 0, 0
for ai in a:
  if ai % 4 == 0:
    a4 += 1
  elif ai % 2 == 0:
    a2 += 1
  else:
    a4n += 1

if a2 != 0:
  print("Yes" if a4 + 1 >= a4n+1 else "No")

else:
  print("Yes" if a4 + 1 >= a4n else "No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for i in range(n)]

flag = False
mem = []
ind = 0
while not flag:
  if a[ind] in mem:
    break

  if a[ind] == 2:
    flag = True
    break
    
  mem.append(a[ind])    
  ind = a[ind] - 1
  
print(len(mem)+1 if flag else -1)
  

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]

flag = False
ind = 1
for cnt in range(n):
  ind = a[ind-1]

  if ind == 2:
    flag = True
    break

print(cnt+1 if flag else -1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

ans = 1
for i in range(1, n+1):
  ans *= i
ans %= (10 ** 9 + 7)
print(ans)

Fixed submission:
import numpy as np
n = int(input())

ans = 1
for i in range(1, n+1):
  ans *= i
  ans %= (10**9 + 7)
  
print(ans)
Buggy python submission (verdict: Runtime Error):
s = list(input())
n = len(s)-1

ans = 0
for x in list(product(["", "+"], repeat=n)):
    x = list(x)
    x.append("")
    
    strs = [i+j for i, j in zip(s, x)]
    ans += eval("".join(strs))
print(ans)

Fixed submission:
from itertools import product
s = list(input())
n = len(s)-1

ans = 0
for x in list(product(["", "+"], repeat=n)):
    x = list(x)
    x.append("")
    
    strs = [i+j for i, j in zip(s, x)]
    ans += eval("".join(strs))
print(ans)
Buggy python submission (verdict: Runtime Error):
s = list(input())

hoge = []
for si in s:
  if si != "B":
    hoge.append(si)
  else:
    hoge.pop()
    
print("".join(hoge))

Fixed submission:
s = list(input())

hoge = []
for si in s:
  if si != "B":
    hoge.append(si)
  elif si == "B" and len(hoge) > 0:
    hoge.pop()
    
print("".join(hoge))
Buggy python submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
xy = [list(map(int, input().split())) for i in range(m)]

ans = [1] * (n)
ans[0] = 1
ball = [0] * (n)
ball[0] = 1
for i in range(m):
    x, y = xy[i]
    ans[y-1] += 1
    ans[x-1] -= 1
    if ball[x-1]:
      ball[y-1] = 1
    if ans[x-1] == 0:
      ball[x-1] = 0
      
print(sum(cnt))

Fixed submission:
n, m = list(map(int, input().split()))
xy = [list(map(int, input().split())) for i in range(m)]

ans = [1] * (n)
ans[0] = 1
ball = [False] * (n)
ball[0] = True
for i in range(m):
    x, y = xy[i]
    ans[y-1] += 1
    ans[x-1] -= 1
    if ball[x-1]:
      ball[y-1] = True
    if ans[x-1] == 0:
      ball[x-1] = False
      
cnt = 0
for i in ball:
  if i:
    cnt += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
m1=int(input())
d1=int(input())
m2=int(input())
d2=int(input())
if m1+1==m2:
  print(1)
else:
  print(0)

Fixed submission:
m1,d1=map(int,input().split())
m2,d2=map(int,input().split())

if m1+1==m2:
  print(1)
else:
  print(0)

Buggy python submission (verdict: Runtime Error):
m1=int(input())
d1=int(intput())
m2=int(input())
d2=int(intput())
if m1+1==m2:
  print(1)
else:
  print(0)
  

Fixed submission:
m1,d1=map(int,input().split())
m2,d2=map(int,input().split())

if m1+1==m2:
  print(1)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
a = list(map(int, input().split()))
ans = 1
if 0 in a:
    print(0)
    exit()
limit = 10**18
for i in a:
    ans*=i
    if ans > lim:
        print(-1)
        exit()
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 1
if 0 in a:
    print(0)
    exit()
limit = 10**18
for i in a:
    ans*=i
    if ans > limit:
        print(-1)
        exit()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
lim = int(x**(1/5))+1
for i in range(-100000*lim, 100000*lim):
    if x + i**5 < 0:
        continue
    if (x+i**5)**(1/5) == int((x+i**5)**(1/5)):
        print(int((x+i**5)**(1/5)), i)
        exit()

Fixed submission:
x = int(input())
lim = int(x**(1/5))+1

for a in range(10**6):
    mul = 1
    if a**5 < x:
        mul = -1
    
    b = ((a**5 - x)*mul)**(1/5)
    b*=mul
    b = int(b)
    if a**5 - b**5 == x:
        print(a, b)
        exit()
Buggy python submission (verdict: Runtime Error):
n, a, b, c = map(int, input().split())
d = {'A':a, 'B':b, 'C':c}
ans = []
def move(inc, dec):
    d[inc]+=1
    d[dec]-=1
    ans.append(inc)
q = []
for i in range(n):
    q.append(input())
for i in range(n):
    x = q[i][0]
    y = q[i][1]
    if d[x] == 0 and d[y] == 0:
        print("No")
        exit()
    if d[x] == 1 and d[y] == 1:
        if i == n-1:
            move(x, y)
        if x in q[i+1]:
            move(x, y)
        else:
            move(y, x)
    else:
        if d[x] >= d[y]:
            move(y, x)
        else:
            move(x, y)
print("Yes")
print(*ans, sep = '\n')

Fixed submission:
n, a, b, c = map(int, input().split())
d = {'A':a, 'B':b, 'C':c}
ans = []
def move(inc, dec):
    d[inc]+=1
    d[dec]-=1
    ans.append(inc)
q = []
for i in range(n):
    q.append(input())
for i in range(n):
    x = q[i][0]
    y = q[i][1]
    if d[x] == 0 and d[y] == 0:
        print("No")
        exit()
    if d[x] == 1 and d[y] == 1:
        if i == n-1:
            move(x, y)
            continue
        if x in q[i+1]:
            move(x, y)
        else:
            move(y, x)
    else:
        if d[x] >= d[y]:
            move(y, x)
        else:
            move(x, y)
print("Yes")
print(*ans, sep = '\n')
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
n = int(input())
d = defaultdict(int)
for i in range(1, n+1):
  s = str(i)
  d[(i[0], i[-1])]+=1
ans = 0
for i, j in d.items():
  ans+=j*d[i[::-1]]
print(ans)

Fixed submission:
from collections import defaultdict
n = int(input())
d = defaultdict(int)
for i in range(1, n+1):
  s = str(i)
  d[(s[0], s[-1])]+=1
ans = 0
x = list(d.keys())
for i in x:
    ans+=d[i[::-1]]*d[i]
print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
n = int(input())
d = defaultdict(int)
for i in range(1, n+1):
  s = str(i)
  d[(i[0], i[1])]+=1
ans = 0
for i, j in d.items():
  ans+=j*d[i[::-1]]
print(ans)

Fixed submission:
from collections import defaultdict
n = int(input())
d = defaultdict(int)
for i in range(1, n+1):
  s = str(i)
  d[(s[0], s[-1])]+=1
ans = 0
x = list(d.keys())
for i in x:
    ans+=d[i[::-1]]*d[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
def find_lcm(num1, num2): 
    if(num1>num2): 
        num = num1 
        den = num2 
    else: 
        num = num2 
        den = num1 
    rem = num % den 
    while(rem != 0): 
        num = den 
        den = rem 
        rem = num % den 
    gcd = den 
    lcm = int(int(num1 * num2)/int(gcd)) 
    return lcm 
n = int(input())
a = list(map(int, input().split()))
lcm = a[0]
mod = 10**9+7
for i in range(1, len(a)): 
    lcm = find_lcm(lcm, a[i])
ans = 0
for i in a:
    ans+=lcm*pow(i, mod-2, mod)
    ans%=mod
print(ans)

Fixed submission:
import math
# Python3 program to compute LCM of  
# array elements modulo M 
MAX = 1000003
  
mod = 1000000007
  
prime = [0 for i in range(MAX)] 
  
max_map = dict() 
  
# function to return a^n 
def power(a, n): 
      
    if n == 0: 
        return 1
    p = power(a, n // 2) % mod 
    p = (p * p) % mod 
      
    if n & 1: 
        p = (p * a) % mod 
    return p 
  
# function to find the smallest prime 
# factors of numbers upto MAX 
def sieve(): 
    prime[0], prime[1] = 1, 1
    for i in range(2, MAX): 
        if prime[i] == 0: 
            for j in range(i * 2, MAX, i): 
                if prime[j] == 0: 
                    prime[j] = i 
            prime[i] = i 
  
# function to return the LCM modulo M 
def lcmModuloM(arr, n): 
      
    for i in range(n): 
        num = arr[i] 
          
        temp = dict() 
          
        # temp stores mapping of prime factors  
        # to its power for the current element 
        while num > 1: 
               
            # factor is the smallest prime 
            # factor of num 
            factor = prime[num] 
              
            # Increase count of factor in temp 
            if factor in temp.keys(): 
                temp[factor] += 1
            else: 
                temp[factor] = 1
                  
            # Reduce num by its prime factor 
            num = num // factor 
              
        for i in temp: 
            # store the higest power of every prime 
            # found till now in a new map max_map 
            if i in max_map.keys(): 
                max_map[i] = max(max_map[i], temp[i]) 
            else: 
                max_map[i] = temp[i] 
              
    ans = 1
      
    for i in max_map: 
          
        # LCM is product of primes to their 
        # higest powers modulo M 
        ans = (ans * power(i, max_map[i])) % mod 
    return ans 
  
# Driver code 
sieve()
n = int(input())
a = list(map(int, input().split()))
if len(a) == 1:
    print(1)
    exit()
mod = 10**9+7
lcm = lcmModuloM(a, len(a))
ans = 0
for i in a:
    ans+=pow(i, mod-2, mod)
    ans%=mod
ans*=lcm
ans%=mod
print(ans)
Buggy python submission (verdict: Runtime Error):
import math 
n, m = map(int, input().split())
a = list(map(int, input().split()))
z = a[0]
for i in a:
    z = math.gcd(z, i)
for i in range(n):
    a[i]//=z
lcm = 1
a = set(a)
for i in a:
    lcm*=i
print(math.ceil((m//lcm)/2))

Fixed submission:
def case():
    k, x = map(int, input().split())
    if 500*k < x:
        print("No")
    else:
        print("Yes")
case()
Buggy python submission (verdict: Runtime Error):
s, t = input().split()
print(t+c)

Fixed submission:
s, t = input().split()
print(t+s)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [0 for i in range(n)]
for i in range(1, n):
    m = 10**10
    index = i-1
    num = k
    while index >= 0 and num:
        m = min(m, dp[index]+abs(h[index]-h[i]))
        index-=1
        num-=1
    dp[i] = m
print(dp[n-1])

Fixed submission:
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [0 for i in range(n)]
for i in range(1, n):
    m = 10**10
    index = i-1
    num = k
    while index >= 0 and num:
        m = min(m, dp[index]+abs(h[index]-h[i]))
        index-=1
        num-=1
    dp[i] = m
print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
a, b = map(float, input().split())

a = int(a)
b = int(b*100)

ans = int(str(a*b)[:-2])

print(ans)

Fixed submission:
from decimal import *
import math

a, b = input().split()

a = int(a)
b = Decimal(b)

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

l = [0]*n
r = [0]*n
for i in range(n):
	l[i] = i+a[i]
	r[i] = i-a[i]

c = 0
for i in range(n):
	c += r.count(l[i])

print(c)

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

l = [0]*n
r = [0]*n

l = [i+a[i] for i in range(n)]
r = [i-a[i] for i in range(n)]
ld = {}
rd = {}

c = 0

for i in range(n):
	if l[i] in ld:
		ld[l[i]] += 1
	else:
		ld[l[i]] = 1
	if r[i] in rd:
		rd[r[i]] += 1
	else:
		rd[r[i]] = 1

for i in ld.keys():
	if i in rd:
		c += ld[i]*rd[i]	
	
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
c = 0
for i in range(n-1):
	for j in range(i+1,n):
		if j-i == a[i]+a[j]:
			c += 1

print(c)

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

l = [0]*n
r = [0]*n

l = [i+a[i] for i in range(n)]
r = [i-a[i] for i in range(n)]
ld = {}
rd = {}

c = 0

for i in range(n):
	if l[i] in ld:
		ld[l[i]] += 1
	else:
		ld[l[i]] = 1
	if r[i] in rd:
		rd[r[i]] += 1
	else:
		rd[r[i]] = 1

for i in ld.keys():
	if i in rd:
		c += ld[i]*rd[i]	
	
print(c)
Buggy python submission (verdict: Runtime Error):
import math

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

if n>=b:
	n1 = n//b*b-1
	n2 = n//b*b-2
	ans = max(math.floor(a*n/b)-a*math.floor(n/b), max(math.floor(a*n1/b)-a*math.floor(n1/b)), math.floor(a*n2/b)-a*math.floor(n2/b))
else:
	ans = math.floor(a*n/b)-a*math.floor(n/b)

print(ans)

Fixed submission:
import math

a, b, n = map(int, input().split())
x = min(n, b-1)
print(math.floor(a*x/b)-a*math.floor(x/b))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
for i in range(1,N+1):
	print(A.count(i))

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

B = [0]*N
for i in range(N-1):
	B[A[i]-1] += 1
for i in range(N):
	print(B[i])