Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

A = input().split()

for i in range(1, N + 1):
  print(A.count(str(i)))

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

count = [0] * (N + 1)

for i in range(N - 1):
  count[int(A[i])] += 1

for i in range(1, N + 1):
  print(count[i])
Buggy python submission (verdict: Time Limit Exceeded):
import fractions

N = int(input())

total = 0

for i in range(1, N + 1):
  total += i

for i in range(1, N):
  for j in range(i + 1, N + 1):
    total += (fractions.gcd(i, j) * 6)

for i in range(1, N - 1):
  for j in range(i + 1, N):
    for k in range(j + 1, N + 1):
      total += (fractions.gcd(fractions.gcd(i, j), k) * 6)

print(total)

Fixed submission:
import fractions

N = int(input())

total = 0

for i in range(1, N + 1):
  total += i

for i in range(1, N + 1):
  for j in range(i + 1, N + 1):
    tmp = fractions.gcd(i, j)
    total += (tmp * 6)
    for k in range(j + 1, N + 1):
      total += (fractions.gcd(tmp, k) * 6)

print(total)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions

N = int(input())

total = 0

for i in range(1, N + 1):
  total += i

for i in range(1, N + 1):
  for j in range(i + 1, N + 1):
    total += (fractions.gcd(i, j) * 6)

for i in range(1, N + 1):
  for j in range(i + 1, N + 1):
    for k in range(j + 1, N + 1):
      total += (fractions.gcd(fractions.gcd(i, j), k) * 6)

print(total)

Fixed submission:
import fractions

N = int(input())

total = 0

for i in range(1, N + 1):
  total += i

for i in range(1, N + 1):
  for j in range(i + 1, N + 1):
    tmp = fractions.gcd(i, j)
    total += (tmp * 6)
    for k in range(j + 1, N + 1):
      total += (fractions.gcd(tmp, k) * 6)

print(total)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

RGB = S.count("R") * S.count("G") * S.count("B")

for i in range(N - 2):
  for j in range(i + 1, N - 1):
    k = 2 * j - i
    if ( k >= N ):
      continue
    if (S[i] != S[j]) & (S[j] != S[k]) & (S[i] != S[k]):
      RGB -= 1


print(RGB)

Fixed submission:
N = int(input())
S = input()

RGB = S.count("R") * S.count("G") * S.count("B")

for i in range(N - 2):
  for j in range(i + 1, N - 1):
    k = 2 * j - i
    if ( k >= N ):
      break
    if (S[i] != S[j]) & (S[j] != S[k]) & (S[i] != S[k]):
      RGB -= 1


print(RGB)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

R = []
G = []
B = []

total = 0

for i in range(N):
  if S[i] == "R":
    R.append(i)
  elif S[i] == "G":
    G.append(i)
  else:
    B.append(i)
    
for i in range(len(R)):
  for j in range(len(G)):
    for k in range(len(B)):
      if (R[i] > G[j]) & (R[i] > B[k]):
        if (R[i] - G[j]) == (2 * (R[i] - B[k])):
          continue
        elif (2 * (R[i] - G[j])) == (R[i] - B[k]):
          continue
        else:
          total += 1
      if (G[j] > R[i]) & (G[j] > B[k]):
        if (G[j] - R[i]) == (2 * (G[j] - B[k])):
          continue
        elif (2 * (G[j] - R[i])) == (G[j] - B[k]):
          continue
        else:
          total += 1
      if (B[k] > R[i]) & (B[k] > G[j]):
        if (B[k] - R[i]) == (2 * (B[k] - G[j])):
          continue
        elif (2 * (B[k] - R[i])) == (B[k] - G[j]):
          continue
        else:
          total += 1 
        
print(total)

Fixed submission:
N = int(input())
S = input()

RGB = S.count("R") * S.count("G") * S.count("B")

for i in range(N - 2):
  for j in range(i + 1, N - 1):
    k = 2 * j - i
    if ( k >= N ):
      break
    if (S[i] != S[j]) & (S[j] != S[k]) & (S[i] != S[k]):
      RGB -= 1


print(RGB)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

total = 0

for i in range(N - 2):
  for  j in range(i + 1, N - 1):
    if S[i] == S[j]:
      continue
    for k in range(j + 1, N):
      if (j - i) == (k - j):
        continue
      if (S[i] == S[k]) | (S[j] == S[k]):
        continue
      total += 1
      
print(total)

Fixed submission:
N = int(input())
S = input()

RGB = S.count("R") * S.count("G") * S.count("B")

for i in range(N - 2):
  for j in range(i + 1, N - 1):
    k = 2 * j - i
    if ( k >= N ):
      break
    if (S[i] != S[j]) & (S[j] != S[k]) & (S[i] != S[k]):
      RGB -= 1


print(RGB)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

total = 0

for i in range(N):
  for  j in range(i + 1, N):
    if S[i] == S[j]:
      continue
    for k in range(j + 1, N):
      if (S[i] == S[k]) | (S[j] == S[k]):
        continue
      if (j - i) == (k - j):
        continue
      total += 1
      
print(total)

Fixed submission:
N = int(input())
S = input()

RGB = S.count("R") * S.count("G") * S.count("B")

for i in range(N - 2):
  for j in range(i + 1, N - 1):
    k = 2 * j - i
    if ( k >= N ):
      break
    if (S[i] != S[j]) & (S[j] != S[k]) & (S[i] != S[k]):
      RGB -= 1


print(RGB)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int,input().split())

history = [0] * (K + 1)
total = 0

divide = pow(10, 9) + 7

for i in range(K, 0, -1):
  history[i] = pow(K//i, N)
  for j in range(2, K//i + 1):
    history[i] -= history[i * j]
  total += ((i * history[i]) % divide)
  
total = total % divide
print(total)


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

history = [0] * (K + 1)
total = 0

divide = pow(10, 9) + 7

for i in range(K, 0, -1):
  history[i] = pow(K//i, N, divide)
  for j in range(2, K//i + 1):
    history[i] -= history[i * j]
  total += ((i * history[i]) % divide)
  
total = total % divide
print(total)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

target = int(input())

list_After = [str(n) for n in range(10)]
list_Before = []

count = 9

while 1:
  list_Before = list_After
  list_After = []
  for i in range(10):
    flag = 0
    for element in list_Before:
      if (abs(i - int(element[0])) >= 2) & (flag == 1):
        break
      elif abs(i - int(element[0])) >= 2:
        continue
      else:
        flag = 1
        list_After.append(str(i) + element)
        if i != 0:
          count += 1
          if count == target:
            print(str(i) + element)
            sys.exit()


Fixed submission:
import queue
target = int(input())

q = queue.Queue()

for i in range(1,10):
  q.put(str(i))


for cnt in range(1, target):
  num = q.get()
  mod = int(num) % 10
  
  if mod == 0:
    q.put(num + "0")
    q.put(num + "1")
  elif mod == 9:
    q.put(num + "8")
    q.put(num + "9")
  else:
    q.put(num + str(mod - 1))
    q.put(num + str(mod))
    q.put(num + str(mod + 1))

print(q.get())

Buggy python submission (verdict: Time Limit Exceeded):
import sys

target = int(input())

list_After = [str(n) for n in range(10)]
list_Before = []

count = 9

while 1:
  list_Before = list_After
  list_After = []
  for i in range(10):
    flag = 0
    for element in list_Before:
      if (abs(i - int(element[0])) >= 2) & (flag == 1):
        break
      elif abs(i - int(element[0])) >= 2:
        continue
      else:
        list_After.append(str(i) + element)
        if i != 0:
          count += 1
          if count == target:
            print(str(i) + element)
            sys.exit()


Fixed submission:
import queue
target = int(input())

q = queue.Queue()

for i in range(1,10):
  q.put(str(i))


for cnt in range(1, target):
  num = q.get()
  mod = int(num) % 10
  
  if mod == 0:
    q.put(num + "0")
    q.put(num + "1")
  elif mod == 9:
    q.put(num + "8")
    q.put(num + "9")
  else:
    q.put(num + str(mod - 1))
    q.put(num + str(mod))
    q.put(num + str(mod + 1))

print(q.get())

Buggy python submission (verdict: Time Limit Exceeded):
import sys

target = int(input())

list_After = [str(n) for n in range(10)]
list_Before = []

count = 9

while 1:
  list_Before = list_After
  list_After = []
  for i in range(10):
    flag = 0
    for element in list_Before:
      if (abs(i - int(element[0])) >= 2) & (flag == 1):
        break
      elif abs(i - int(element[0])) >= 2:
        continue
      else:
        list_After.append(str(i) + element)
        if i != 0:
          count += 1
          if count == target:
            print(str(i) + element)
            sys.exit()


Fixed submission:
import queue
target = int(input())

q = queue.Queue()

for i in range(1,10):
  q.put(str(i))


for cnt in range(1, target):
  num = q.get()
  mod = int(num) % 10
  
  if mod == 0:
    q.put(num + "0")
    q.put(num + "1")
  elif mod == 9:
    q.put(num + "8")
    q.put(num + "9")
  else:
    q.put(num + str(mod - 1))
    q.put(num + str(mod))
    q.put(num + str(mod + 1))

print(q.get())
Buggy python submission (verdict: Time Limit Exceeded):
n, m, v = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
i = 0
j = 0
x = 0
for i in range(n + 1):
  c = 0
  t = 0
  for j in range(i):
    if t + a[j] <= v:
      t += a[j]
      c += 1
    else:
      break
  for k in range(m):
    if t + b[k] <= v:
      t += b[k]
      c += 1
    else:
      break
  if x < c:
    x = c
  

print (x)

Fixed submission:
from itertools import accumulate
import bisect

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

a_acc = [0] + list(accumulate(a))  # aを0冊読む=1冊も読まない場合があるので、[0]を先頭に追加します
b_acc = list(accumulate(b))  # bisect_rightでは、x以下の要素がいくつあるか？を求めるので、こちらに0は入れません

ans = 0
for an in range(n + 1):
    rem = k - a_acc[an]
    if rem < 0:
        # aをこれ以上読めません
        break

    bn = bisect.bisect_right(b_acc, rem)
    ans = max(ans, an + bn)

print(ans)

Buggy python submission (verdict: Runtime Error):
s=0
i=0
j=0
n,m,k=(int(x) for x in input().split())
a=[]
a = list(map(int, input().split()))
b=[]
b = list(map(int, input().split()))

if n<=m:
	l=m
else:
	l=n


for ind in range(0,l):
	if s>k:break;
	if a[i]<=b[j]:
		s+=a[i]
		i=i+1
	else:
		s+=b[j]
		j=j+1



print(i+j-1)

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

a,b = [0], [0]

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

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

print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()

if(s=="ABC")print("ARC")
else if(s=="ARC")print("ABC")




Fixed submission:
s=input()

if(s=="ABC"):print("ARC")
if(s=="ARC"):print("ABC")

Buggy python submission (verdict: Runtime Error):
s=input()

if(s=="ABC")print("ARC")
else if("ARC")print("ABC")




Fixed submission:
s=input()

if(s=="ABC"):print("ARC")
if(s=="ARC"):print("ABC")
Buggy python submission (verdict: Runtime Error):
S=input()
if S=="MON" :
	print(1)
else if S=="TUE" :
	print(2)
else if S=="WED" :
	print(3)
else if S=="THU" :
	print(4)
else if S=="FRI" :
	print(5)
else if S=="STA" :
	print(6)
else if S=="SUN" :
	print(7)

Fixed submission:
S=input()
if S=="SUN" :
	print(7)
if S=="MON" :
	print(6)
if S=="TUE" :
	print(5)
if S=="WED" :
	print(4)
if S=="THU" :
	print(3)
if S=="FRI" :
	print(2)
if S=="SAT" :
	print(1)
Buggy python submission (verdict: Runtime Error):
a,b,c = input()

if(a=="7"||b=="7"||c=="7"):
  print("Yes")
else:
  print("No")

Fixed submission:
a,b,c = input()

if(a=="7" or b=="7" or c=="7"):
  print("Yes")
else:
  print("No")

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

if(a=="7"||b=="7"||c=="7"):
  print("Yes")
else:
  print("No")

Fixed submission:
a,b,c = input()

if(a=="7" or b=="7" or c=="7"):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import math
K = int(input())+1
ans =0    
for a in range(1,K):
  for b in range(1,K):
    for c in range(1,K):
      ans += math.gcd(math.gcd(a,b),c)

print(ans)

Fixed submission:
import math
K = int(input())+1
ans=0
for a in range(1,K):
  for b in range(1,K):
    gcdab = math.gcd(a,b)
    for c in range(1,K):
      ans += math.gcd(gcdab,c)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
K = int(input())
ans =0
def koyakusu(A,B,C):
  kotae = math.gcd(A,B)
  kotae = math.gcd(kotae,C)
  return kotae
  
  
for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      ans +=koyakusu(a,b,c)

print(ans)

Fixed submission:
import math
K = int(input())+1
ans=0
for a in range(1,K):
  for b in range(1,K):
    gcdab = math.gcd(a,b)
    for c in range(1,K):
      ans += math.gcd(gcdab,c)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
K = int(input())
ans =0
def koyakusu(A,B,C):
  kotae = A
  kotae = math.gcd(kotae,B)
  kotae = math.gcd(kotae,C)
  return kotae
  
  
for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      ans +=koyakusu(a,b,c)

print(ans)

Fixed submission:
import math
K = int(input())+1
ans=0
for a in range(1,K):
  for b in range(1,K):
    gcdab = math.gcd(a,b)
    for c in range(1,K):
      ans += math.gcd(gcdab,c)

print(ans)
Buggy python submission (verdict: Runtime Error):
N,M =input().split()
A = [int(i) for i in input().split()]
A.sorted(reverse=True)
ans="Yes"
th = sum(A)/(4*M)
print(type(th))
for i in range(M):
  if A[M-1-i] < th:
    ans="No"
    break
print(ans)  

Fixed submission:
N,M =input().split()
A = list(map(int, input().split()))
A.sort(reverse=True)
ans="Yes"

th = sum(A)/(4*int(M))
for i in range(int(M)):
  if A[int(M)-1-i] < th:
    ans="No"
    break
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()

def check(s):
  if(s==s[::-1]):
    return True
  else:
    return False
  
n = len(s)
if(check(s[:(n-1)//2])):
  if(check(s[((n+3)//2)-1:])):
    if(check(2)):
      print('Yes')
    else:
      print('No')
  else:
    print('No')
else:
     print('No')

Fixed submission:
s = input()

def check(s):
  if(s==s[::-1]):
    return True
  else:
    return False
  
n = len(s)
if(check(s[:(n-1)//2])):
  if(check(s[((n+3)//2)-1:])):
    if(check(s)):
    	print('Yes')
    else:
      print('No')
  else:
    print('No')
else:
     print('No')

Buggy python submission (verdict: Runtime Error):
s = input()

def check(s):
  if(s==s[::-1]):
    return True
  else:
    return False
  
n = len(s)
if(check(s[:(n-1)//2])):
  if(check(s[((n+3)//2)-1:])):
    if(check(2)):
    	print('Yes')
    else:
      print('No')
  else:
    print('No')
else:
     print('No')

Fixed submission:
s = input()

def check(s):
  if(s==s[::-1]):
    return True
  else:
    return False
  
n = len(s)
if(check(s[:(n-1)//2])):
  if(check(s[((n+3)//2)-1:])):
    if(check(s)):
    	print('Yes')
    else:
      print('No')
  else:
    print('No')
else:
     print('No')
Buggy python submission (verdict: Runtime Error):
isReversed = False
s = input()
q = int(input())
for i in range(q):
  t = list(input().split())
  if t[0] =='1':
    isReversed = not bool(isReversed)
  else:
    if (t[1] =='1' and isReversed == False) or (t[1] =='2' and isReversed == True) :
      s = t[2] +s
    else:
      s = s + t[2]
                                              
      
if isReversed:
  s = s[::-1]
      
print(s)

Fixed submission:
a,b,c=input()
if a==b and b==c:
  print("No")
else:
  print("Yes")

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

ans = b * 10
status = ''
for i in range(10):
  8*(ans + i)//100
  if(a == 8*(ans + i)//100):
    ans += i
    status = 'ok'
    break;

if status =='ok':
  print(ans)
  
else:
  print(-1)

Fixed submission:
a,b,c=input()
if a==b and b==c:
  print("No")
else:
  print("Yes")

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

ans = n//c
l = n%c
if a>l:
  ans += l
else:
  ans += a
  
print(ans)

Fixed submission:
a,b,c=input()
if a==b and b==c:
  print("No")
else:
  print("Yes")

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

sum1 = n//c
l = n%c
if a>l:
  sum2 = l
else:
  sum2 = a
  
print(sum1+sum2)

Fixed submission:
a,b,c=input()
if a==b and b==c:
  print("No")
else:
  print("Yes")

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

sum1 = c/n
l = c%n
if a>l:
  sum2 = l
else:
  sum2 = a
  
print(sum1+sum2)

Fixed submission:
a,b,c=input()
if a==b and b==c:
  print("No")
else:
  print("Yes")

Buggy python submission (verdict: Runtime Error):
a,b,c=input()
if a==b and b==C:
  print("YES")
else:
  print("NO")

Fixed submission:
a,b,c=input()
if a==b and b==c:
  print("No")
else:
  print("Yes")

Buggy python submission (verdict: Runtime Error):
s1,s2,s3 = input()
if(s1==s2 and s2==s3):
  print('NO')
elif:
  print('YES')

Fixed submission:
a,b,c=input()
if a==b and b==c:
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
n = int(input())
t=0
x=0
y=0
ans ="Yes"
for i in range(n):
  tt,xx,yy = map(int,input().split())
  dif = abs(x-xx)
  dif +=abs(y-yy)
  if dif>(tt-t) :
    ans = "No"
    break;
  t=tt
  x=xx
  y=yy
print(ans)

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

c = a*b

if c%2 ==0:
  print('Even')
else:
  print('Odd')
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
A = list(map(int, input().split()))

L = 2
P = 0

P = A[0]

while L <= K:
   P = A[P-1]
   L = L + 1

print(P)


Fixed submission:
#そのまま処理すると時間超過するので、ループを探索する

N, K = map(int, input().split())
A = list(map(int, input().split()))
 
#町の数だけ-1のチェックを生成する

flag = [-1] * N

#１番目の町は必ず踏むので、０にする

flag[0] = 0

#今いる町の位置i、初期値はリスト番号0

i = 0

#移動回数の初期値

num = 0
 
while True:

#移動回数を加算する

    num += 1

#町を移動する、リスト上では-1する必要がある

    i = A[i] - 1

#-1でない場合は、一度到達しているのでループを終了する

    if flag[i] != -1:

#flag[i]には何手目で到達したかが入っているので、ループに突入するまでの処理数としてiniに登録する

        ini = flag[i]
        break

    flag[i] = num

#loopに必要な数を求める、まずはループに突入するまでの処理数iniを引く
 
loop = num - ini
 
#loopに突入するまでの処理数よりも、与えられた処理数が多いとき

if K > ini:

#loopに突入するまでにかかる数を引く

    K -= ini

#ループに入るスタート位置＋ループ後の余の位置＋１
    
    t = flag.index(ini + K % loop) + 1

    print(t)

#それ以外の時、先に-1しているので+1して補正する

else:
    t = flag.index(K) + 1
    print(t)
Buggy python submission (verdict: Runtime Error):
N,K= map(int, input().split())

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

a = [0] * K
b = [0] * K

for i in range(K):
    a[i], b[i],= map(int, input().split())

X = 0

for (j) in range(K):

    if H[j-1] != H[j-1] :
        X += 1

print(X)

Fixed submission:
#標準入力

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

#[1,1,…,1]というリストを作成する
#最終的に良い展望台の数を和で求めるため、１で始める

good = [1 for i in range(N)]


#標準入力で高さの一覧を取得

height = list(map(int, input().split()))
 
#道の数Mだけ、入力を繰り返す

for i in range(M):
  a,b = map(int, input().split())

#一括で受け取らず、受取→処理をM回繰り返す
#高さのリストと一致させるため-1

  a -= 1
  b -= 1

#２つの高さを比較し、低い方の展望台を、最初のリストで０にする

  if height[a] <= height[b]:
    good[a] = 0

  if height[a] >= height[b]:
    good[b] = 0

#goodリストで「１」のままの展望台は、つながっている道でいけるどの展望台よりも高い

print(sum(good))
Buggy python submission (verdict: Runtime Error):
a,b,N = map(int, input().split())

Ansermax = 0

if b < N :
    N = b
    
for x in range(N+1):

    Anser = 0

    Anser = int((a*x)//b)-a*int(x//b)
    
    if Ansermax < Anser:
        Ansermax = Anser
    
    if x//b >= 1:
     break

print(Ansermax)

Fixed submission:
X = int(input())

#A**5,B**5でとり得る可能性のある数をあらかじめリストで用意する

N = [i**5 for i in range(1000)]
 
#A,Bで別々の処理をするため、変数はi,jの２種を用意する


for i in range(1000):
	for j in range(1000):

#リストから２つの数を抽出し、Xになるか計算を繰り返す
#Xは正の整数であるため、Aが負になる可能性は除外

		if N[j] - N[i] == X:
			print(j, i)
			exit()

#Bが負の場合、符号が変わる可能性があるため、もう１パターン計算

		if N[j] + N[i] == X:
			print(j, -i)
			exit()
Buggy python submission (verdict: Runtime Error):
N = str(input())

if "7" in N:
  print("Yes")
  
else:
  print("No")ｃ

Fixed submission:
N = str(input())
if "7" in N:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import math
import sys

input = sys.stdin.readline
n = int(input())
A = list(map(int,input().split()))
ans = 1
for i in range(n):
    ans = ans * A[i]
if ans > 10**18 :
    print(-1)
else:
    print(ans)

Fixed submission:

n = int(input())
A = list(map(int,input().split()))
ans =1
for i in range(n):
    ans = ans * A[i]
    if ans  > 10**18:
        ans =-1
        break 
if 0 in A:
  print(0)
else:
  print(ans)
Buggy python submission (verdict: Runtime Error):
import collections
n=int(input())

A=list(map(int,input().split())))
B = [(A[0] + A[i] -i)   for i in range(n)]
b = collections.Counter(B)
ans =0
cnt = 0
for i in range(len(B)):
    
    ans += b[cnt]
    if i != 0:
        cnt += (B[i] - B[i-1] -1)

print(ans)

Fixed submission:
import collections
n=int(input())
A=list(map(int,input().split()))
B = [ i-A[i]    for i in range(n)]
C = [ i+A[i]    for i in range(n)]
b = collections.Counter(B)
c = collections.Counter(C)
ans =0
cnt = 0
 
for i in b.keys():
  ans +=c[i]*b[i]
     
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
N = int(input())
Q =[]
flag = True
while True:
    try:
        Q.append(list(map(str,input().split())))

    except:
        break;

for i in range(N):
    if Q[i][0]=="1":
        flag = not(flag)                
    else: 
        if Q[i][1] == "2" and flag == True:
            S += Q[i][2]#先頭
            
        
        elif Q[i][1] == "2" and flag == False:
            S1 = Q[i][2]+ S
            S = S1
            
        elif Q[i][1] == "1" and flag == True:
            S1 = Q[i][2]+S
            S = S1
            
        elif Q[i][1] == "1" and flag == False:
            S += Q[i][2]

if flag == True:
    print(S)
else:
    print(S[::-1])  

Fixed submission:
N=(input())
if N=="AAA" or N == "BBB":
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
print(-(-a//b))

Fixed submission:
x,y = map(int,input().split()) 
print(-(-x//y))
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = [input().split() for i in range(M)]
s1=list()
s2=list()
p=0
w=0
for i in range(M):
    if A[i][0] not in s2 and A[i][1]=="WA":
        s1 +=A[i][0]
    if A[i][0] not in s2 and A[i][1]=="AC":
        p+=1 
        s2 +=A[i][0]
        w += int(s1.count(A[i][0]))        
print(p,w)

Fixed submission:
N = input()
A =[chr(i) for i in range(97, 97+26)]
for k in range(len(A)):
    if N==A[k]:
        print(A[k+1])
Buggy python submission (verdict: Runtime Error):
x,y,z= map(int,input().split())
if sum(x,y,z)>21:
    print("bust")
else:
    print("win")


Fixed submission:
x,y,z= map(int,input().split())
if x+y+z>21:
    print("bust")
else:
    print("win")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
cnt =[]
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            cnt.append(s[i]+s[j]+s[k])
print(len(set(cnt)))

Fixed submission:
import math,time
N = int(input())
S = input()

ans = 0
for i in range(1000):
    locknum = str(i).zfill(3)
    a = S.find(locknum[0])
    b = S.find(locknum[1],a+1)
    c = S.find(locknum[2],b+1)
    if a!=-1 and b!=-1 and c!=-1:
        # print(i)
        ans +=1


             
print(ans)
Buggy python submission (verdict: Runtime Error):
from decimal import * 
import math
a,b,x = map(int,input().split())
X = x/a
P = X /(a*b)
if P >= 0.5 :
    print(math.degrees(math.atan((2*b*(1-P)/a))))
else:
    print(math.degrees(math.atan((a*b**2/(2*x)))))

Fixed submission:
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
M = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, M + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

a, b = map(int, input().split())
N = (a+b)//3
A = (N -abs(a-b))//2
B = (N +abs(a-b))//2
if (a+b)%3!=0 or A<0 :
    print(0)
else :
    print(cmb(N, A, p))
Buggy python submission (verdict: Runtime Error):
import math
a,b,x = map(int,input().split())
P = X /(a*b)
if P >= 0.5:
    print(math.degrees(math.atan((2*b*(1-P)/a))))
else:
    print(math.degrees(math.atan((a*b)**3/(2*x**2))))

Fixed submission:
from decimal import * 
import math
a,b,x = map(int,input().split())
X = x/a
P = X /(a*b)
if P >= 0.5 :
    print(math.degrees(math.atan((2*b*(1-P)/a))))
else:
    print(math.degrees(math.atan((a*b**2/(2*x)))))