Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n=int(input())
ans=set([])
for i in range(n):
    a=int(input())
    if a in ans:
        ans.remove(a)
    else:
        ans.append(a)
print(len(ans))


Fixed submission:
n=int(input())
ans=set([])
for i in range(n):
    a=int(input())
    if a in ans:
        ans.remove(a)
    else:
        ans.add(a)
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[]
ans=[]
for i in range(n):
    b=input()
    a+=[b]
    if a[i] in ans:
        ans.remove(a[i])
    else:
        ans.append(a[i])
print(len(ans))

Fixed submission:
n=int(input())
ans=set([])
for i in range(n):
    a=int(input())
    if a in ans:
        ans.remove(a)
    else:
        ans.add(a)
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[]
ans=[]
for i in range(n):
    b=input()
    a+=[b]
for i in range(n):
    if a[i] in ans:
        ans.remove(a[i])
    else:
        ans.append(a[i])
print(len(ans))

Fixed submission:
n=int(input())
ans=set([])
for i in range(n):
    a=int(input())
    if a in ans:
        ans.remove(a)
    else:
        ans.add(a)
print(len(ans))
Buggy python submission (verdict: Runtime Error):
s=list(input())
a=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
d=list(set(s))
d.sort()
ans="None"
for i in range(max(len(a),len(d))):
    if d[i]!=a[i]:
        ans=a[i]
        break
print(ans)

Fixed submission:
s=list(input())
a=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
d=list(set(s))
d.sort()
ans="None"
for i in range(min(len(a),len(d))):
    if d[i]!=a[i]:
        ans=a[i]
        break
    u=i
if len(d)<len(a) and ans=="None":
    ans=a[u+1]
print(ans)

Buggy python submission (verdict: Runtime Error):
s=list(input())
a=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
d=list(set(s))
d.sort()
ans="None"
for i in range(len(a)):
    if d[i]!=a[i]:
        ans=a[i]
        break
print(ans)

Fixed submission:
s=list(input())
a=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
d=list(set(s))
d.sort()
ans="None"
for i in range(min(len(a),len(d))):
    if d[i]!=a[i]:
        ans=a[i]
        break
    u=i
if len(d)<len(a) and ans=="None":
    ans=a[u+1]
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
n=int(input())
t=[int(input()) for i in range(n) ]
def lcm_sorce(x,y):
    return (x*y)//math.gcd(x,y)
def lcm_list(list_name):
    return reduce(lcm_sorce,list_name)
print(lcm_list(t))

Fixed submission:
from fractions import gcd
from functools import reduce
n=int(input())
t=[int(input()) for i in range(n) ]
def lcm_sorce(x,y):
    return (x*y)//gcd(x,y)
def lcm_list(list_name):
    return reduce(lcm_sorce,list_name)
print(lcm_list(t))

Buggy python submission (verdict: Runtime Error):
n=int(input())
t=[int(input()) for i in range(n) ]
import math
from functools import reduce
def lcm_sorce(x,y):
    return (x*y)//math.gcd(x,y)
def lcm_list(list_name):
    return reduce(lcm_sorce,list_name)
print(lcm_list(t))

Fixed submission:
from fractions import gcd
from functools import reduce
n=int(input())
t=[int(input()) for i in range(n) ]
def lcm_sorce(x,y):
    return (x*y)//gcd(x,y)
def lcm_list(list_name):
    return reduce(lcm_sorce,list_name)
print(lcm_list(t))
Buggy python submission (verdict: Runtime Error):
n.m=map(int,input().split())
print((n-1)*(m-1))

Fixed submission:
n,m=map(int,input().split())
print((n-1)*(m-1))
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
c = a+b
if(c>=24):
  print(c-24):
else:
  print(c)


Fixed submission:
a, b = map(int, input().split())
c = a + b
if c >= 24:
    print(c - 24)
else:
    print(c)

Buggy python submission (verdict: Runtime Error):
a,b = map(int.input().split())
c = a+b
if(c>=24):
  print(c-24):
else:
  print(c)

Fixed submission:
a, b = map(int, input().split())
c = a + b
if c >= 24:
    print(c - 24)
else:
    print(c)
Buggy python submission (verdict: Runtime Error):
a,b = map(str,input8).split()
if a==b:
  print("H")
else:
  print("D")

Fixed submission:
a,b = map(str,input().split())
if a==b:
  print("H")
else:
  print("D")
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
count = 0
for i in range(k+1):
    for j in range(k+1):
        for u in range(k+1):
            if (i + j + u) == s:
                count += 1
print(count)

Fixed submission:
k,s=list(map(int,input().split()))
o=0
for i in range(k+1):
    for u in range(k+1):
        if 0<=(s-i-u)<=k:
            o+=1
print(o)

Buggy python submission (verdict: Time Limit Exceeded):
k,s=list(map(int,input().split()))
o=0
for i in range(k+1):
    for u in range(k+1):
        for y in range(k+1):
            if (i+u+y)==s:
                o+=1
print(o)

Fixed submission:
k,s=list(map(int,input().split()))
o=0
for i in range(k+1):
    for u in range(k+1):
        if 0<=(s-i-u)<=k:
            o+=1
print(o)
Buggy python submission (verdict: Time Limit Exceeded):
N, D, A = map(int, input().split())
XH = [list(map(int, input().split())) for _ in range(N)]

XH = sorted(XH)

for i in range(N):
    XH[i][1] = (XH[i][1] + A - 1) // A

adjust = [0 for _ in range(N + 1)]

ans = 0
done = 0

for i in range(N):
    done -= adjust[i]
    XH[i][1] -= done
    if XH[i][1] < 0: continue

    v = XH[i][0] + 2 * D
    ng = 0
    ok = N
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if XH[mid][0] > v: ok = mid
        else: ng = mid

    ans += XH[i][1]
    done += XH[i][1]
    adjust[ok] += XH[i][1]

print(ans)

Fixed submission:
import sys
N, D, A = map(int, sys.stdin.readline().split())
XH = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]

XH = sorted(XH)

for i in range(N):
    XH[i][1] = (XH[i][1] + A - 1) // A

adjust = [0 for _ in range(N + 1)]

def findi(v):
    ng = 0
    ok = N
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if XH[mid][0] > v: ok = mid
        else: ng = mid
    return ok

ans = 0
done = 0

for i in range(N):
    done -= adjust[i]
    XH[i][1] -= done
    if XH[i][1] < 0: continue

    ans += XH[i][1]
    index = findi(XH[i][0] + D * 2)
    done += XH[i][1]
    adjust[index] += XH[i][1]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, D, A = map(int, input().split())
XH = [list(map(int, input().split())) for _ in range(N)]

XH = sorted(XH)

for i in range(N):
    XH[i][1] = (XH[i][1] + A - 1) // A

adjust = [0 for _ in range(N + 1)]

def findi(v):
    ng = 0
    ok = N
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if XH[mid][0] > v: ok = mid
        else: ng = mid
    return ok

ans = 0
done = 0

for i in range(N):
    done -= adjust[i]
    XH[i][1] -= done
    if XH[i][1] < 0: continue

    ans += XH[i][1]
    index = findi(XH[i][0] + D * 2)
    done += XH[i][1]
    adjust[index] += XH[i][1]

print(ans)

Fixed submission:
import sys
N, D, A = map(int, sys.stdin.readline().split())
XH = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]

XH = sorted(XH)

for i in range(N):
    XH[i][1] = (XH[i][1] + A - 1) // A

adjust = [0 for _ in range(N + 1)]

def findi(v):
    ng = 0
    ok = N
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if XH[mid][0] > v: ok = mid
        else: ng = mid
    return ok

ans = 0
done = 0

for i in range(N):
    done -= adjust[i]
    XH[i][1] -= done
    if XH[i][1] < 0: continue

    ans += XH[i][1]
    index = findi(XH[i][0] + D * 2)
    done += XH[i][1]
    adjust[index] += XH[i][1]

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

if b * 2 >= a:
  	print(0)
else:
  	s = a - b * 2  
    print(s)

Fixed submission:
a, b = input().split()
a = int(a)
b = int(b)
 
ans = max(a-b*2, 0)
print(ans)
Buggy python submission (verdict: Runtime Error):
n=input()
n=int(n)
m=input()
m=int(m)
d=input()
d=int(d)
if(d!=0):
    d=2
if(d==0):
    d=1
print(d*(m-1)*(n-1)/(n*n))


Fixed submission:
n,m,d = map(int,input().split())
if(d==0):
    ans=(m-1)/n
elif(n/d<2):
    ans=2*(m-1)*(n-d)/n
else:
    ans=2*(m-1)*(n-d)/(n*n)
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B,C,X = [int(input()) for i in range(4)]

count = 0
for a in range(0,A+1):
    Xa  = X - 500*a
    if Xa < 0:
        break
    for b in range(0,B+1):
        Xab = Xa - 100*b
        if Xab < 0:
            break
        for c in range(0,C+1):
            if Xabc == Xab - 50*c == 0:
                count += 1
                break
                
print(count)

Fixed submission:
X = int(input())
A = int(input())
B = int(input())
print((X-A)%B)
Buggy python submission (verdict: Runtime Error):
A,B,C,X = [int(input()) for i in range(4)]

count = 0
for a in range(0,A+1):
    Xa  = X - 500*a
    if Xa < 0:
        break
    for b in range(0,B+1):
        Xab = Xa - 100*b
        if Xab < 0:
            break
        for c in range(0,C+1):
            if Xabc == Xab - 50*c == 0:
                count += 1
                break
                
print(count)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for a in range(0,A+1):
    Xa  = X - 500*a
    if Xa < 0:
        break
    for b in range(0,B+1):
        Xab = Xa - 100*b
        if Xab < 0:
            break
        for c in range(0,C+1):
            Xabc = Xab - 50*c
            if Xabc == 0:
                count += 1
                break
                
print(count)

Buggy python submission (verdict: Runtime Error):
A,B,C,X = [int(input()) for i in range(4)]

count = 0
for a in range(0,A+1):
    Xa  = X - 500*a
    if Xa < 0:
        break
    for b in range(0,B+1):
        Xab = Xa - 100*b
        if Xab < 0:
            break
        for c in range(0,C+1):
            if Xabc == Xab - 50*c == 0:
                count += 1
                break
                
print(count)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for a in range(0,A+1):
    Xa  = X - 500*a
    if Xa < 0:
        break
    for b in range(0,B+1):
        Xab = Xa - 100*b
        if Xab < 0:
            break
        for c in range(0,C+1):
            Xabc = Xab - 50*c
            if Xabc == 0:
                count += 1
                break
                
print(count)
Buggy python submission (verdict: Runtime Error):
a=1
b=0
c=-1
A,B,C,K=input().split()
A=int(A)
B=int(B)
C=int(C)
K=int(K)
if K>0:
    if K>=0:
        test=a*A
        K=K-A
    if K>=0:
        test=test+b*B
        K=K-B
    if K>=0:
        test=test+c*K
else:
    test=0
print(test)

Fixed submission:
S=input()
T=input()


if len(S)+1==len(T):
    for i in range(len(S)): #回数の時は絶対range()
        if S[i]==T[i]:
            a='ok'
            continue
        else:
            a='no'
            break
else:
    print('no')

if a=='ok':
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
S=input()
T=input()


if len(S)+1==len(T):
    for i in range(len(S)): #回数の時は絶対range()
        if S[i]==T[i]:
            a='ok'
            continue
        else:
            a='no'
            break
else:
    print('no')

if a=='ok':
    print('Yes')
else:
    print('No')

Fixed submission:
a=1
b=0
c=-1
A,B,C,K=input().split()
A=int(A)
B=int(B)
C=int(C)
K=int(K)
test=0
if K>=A:
    a=a*A
    test=test+a
    K=K-A
elif K<=A:
    a=a*K
    test=test+a
    c=0
if K>=B:
    b=b*B
    test=test+b
    K=K-B
elif K<=B: 
    b=b*K
    test=test+b
    c=0
    
if K>=C:
    c=c*C
    test=test+c
    K=K-C
elif K<=C:
    c=c*K
    test=test+c
    
    
print(test)
Buggy python submission (verdict: Runtime Error):
import math
import numpy as np
X=int(input())
count=0
atcor=100


while True:
    if atcor==X:
        print(count)
        break
    else:
        p=atcor/100
        atcor=atcor+p
        atcor=math.floor(atcor)
        count+=1


Fixed submission:
import math

X=int(input())
count=0
# count=float(count)
atcor=100
atcor=int(atcor)


while True:
    
    if atcor>=X:
        print(count)
        break
    else:
        p=atcor/100
        atcor=atcor+p
        atcor=math.floor(atcor)
        count+=1

Buggy python submission (verdict: Runtime Error):
import math
X=int(input())
count=0
atcor=100
p=0.01

while True:
    if atcor==X:
        print(count)
        break
    else:
        atcor=(atcor*p)+atcor
        atcor=math.floor(atcor)
        count+=1

Fixed submission:
import math

X=int(input())
count=0
# count=float(count)
atcor=100
atcor=int(atcor)


while True:
    
    if atcor>=X:
        print(count)
        break
    else:
        p=atcor/100
        atcor=atcor+p
        atcor=math.floor(atcor)
        count+=1
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
print((a-1)*(b-1))

Fixed submission:
a,b = map(int, input().split())
print((a-1)*(b-1))
Buggy python submission (verdict: Runtime Error):
def ans():
  s = input()
  k = int(input())
  for i in range(k+1):
    if s[i] != '1':
      print(s[i])
      return
  print("1")
  return

ans()

Fixed submission:
def ans():
  s = input()
  k = int(input())
  for i in range(k):
    if s[i] != '1':
      print(s[i])
      return
  print("1")
  return

ans()
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n > 4:
	if n % 4 == 0 or n % 7 == 0 or n % 28 == 0 or n % 11 == 0:
  		print("Yes")
    else:
      print("No")
else:
	print("No")

Fixed submission:
def ans():
  n = int(input())
  for a in range(n // 4 + 1):
    for b in range(n // 7+ 1):
      if 4 * a + 7 * b == n:
        print("Yes")
        return
  print("No")

ans()
Buggy python submission (verdict: Runtime Error):
a = map(int, input().split())
b = map(int, input().split())
c = map(int, input().split())
ans = a[0]+b[1]+c[2]
print(ans)


Fixed submission:
a = list(map(str, input()))
b = list(map(str, input()))
c = list(map(str, input()))
print(a[0] + b[1] + c[2])

Buggy python submission (verdict: Runtime Error):
a = map(int, input().split())
b = map(int, input().split())
c = map(int, input().split())
print(a[0]b[1]c[2])

Fixed submission:
a = list(map(str, input()))
b = list(map(str, input()))
c = list(map(str, input()))
print(a[0] + b[1] + c[2])
Buggy python submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
print(math.floar((a+b)/2))

Fixed submission:
import math
a,b=map(int,input().split())
print(math.ceil((a+b)/2))
Buggy python submission (verdict: Runtime Error):
x, t = list(map(int,input().split())
if x < t:
	print("0")
else:
	print(x-t)

Fixed submission:
x, t = list(map(int,input().split()))
if x < t:
	print("0")
else:
	print(x-t)
Buggy python submission (verdict: Runtime Error):
n,m = int(input())
print((n-1) * (m-1))

Fixed submission:
n,m = list(map(int, input().split()))
print((n-1) * (m-1))
Buggy python submission (verdict: Runtime Error):
a,b,c = list(map(int, input()))
if a <= c and c <= b:
  print("Yes")
else:
  print("No")

Fixed submission:
a,b,c = list(map(int, input().split()))
if a <= c and c <= b:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
print(800 * n - (n // 15) * 200


Fixed submission:
n = int(input())
print(800 * n - (n // 15) * 200)

Buggy python submission (verdict: Runtime Error):
n = int(input())
print(800 * n - (n // 15) * 200

Fixed submission:
n = int(input())
print(800 * n - (n // 15) * 200)
Buggy python submission (verdict: Runtime Error):
a,op,b = list(map(str, input().split()))
if op == "+":
  ans = int(a) + int(b)
else:
  ans == int(a) - int(b)
print(ans)

Fixed submission:
a,op,b = list(map(str, input().split()))
if op == "+":
  ans = int(a) + int(b)
else:
  ans = int(a) - int(b)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
d = len(str(n))
c = 0
for i in range(1, d):
  if i % 2 == 1:
  	c += 9 * (10**(i-1))
  
c += n - int('9'*(d-1)) if d % 2 == 1 else 0

print(c)

Fixed submission:
n = int(input())
d = len(str(n))
a = [9, 0, 900, 0, 9000]
c = 0
for i in range(1, d):
  if i % 2 == 1:
  	c += 9 * (10**(i-1))
  
if d == 1:
  c += n
else:
  c += n - int('9'*(d-1)) if d % 2 == 1 else 0

print(c)
Buggy python submission (verdict: Runtime Error):
n, d = map(int, input())
print(n//(2*d+1)+(1 if n%(2*d+1)!=0 else 0))

Fixed submission:
n, d = map(int, input().split())
print(n//(2*d+1)+(1 if n%(2*d+1)!=0 else 0))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
arr = [int(input()) for _ in range(n)]
max_v = max(arr)

for i in range(n):
  print(max_v if arr[i]!=max_v else max(arr[:i]+arr[i+1:]))

Fixed submission:
n = int(input())
arr = []
fst = 0
scd = 0
for i in range(n):
  t = int(input())
  fst, scd = sorted([fst, scd, t], reverse=True)[:2]
  arr.append(t)

for i in range(n):
  print(fst if arr[i]!=fst else scd)
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
ls = list(map(int, input().split()))

bounce = [0]

while bounce[-1] < x:
  bounce.append(bounce[len(bounce)-1] + ls[len(bounce)-1])

print(len(bounce))


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

bounce = [0] + [ sum(ls[:i]) for i in range(1, len(ls)+1) ]

for i, v in enumerate(bounce):
  if v > x:
    print(i)
    break
else:
  print(len(bounce))
Buggy python submission (verdict: Runtime Error):
N = int(input())
rs = []
for _ in range(N):
  s, p = map(int, input().split())
  rs.append((i+1, s, p))

rs.sort(key=lambda x:(x[1], -x[2]))
for r in rs:
  print(r[0])

Fixed submission:
N = int(input())
rs = []
for i in range(N):
  s, p = input().split()
  rs.append((i+1, s, int(p)))

rs.sort(key=lambda x:(x[1], -x[2]))
for r in rs:
  print(r[0])
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
master = set(range(1, N+1))

for _ in range(M):
    L, R = map(int, input().split())
    master = master & set(range(L, R+1))

print(len(master))

Fixed submission:
N, M = map(int, input().split())
lb = 1
rb = N

for _ in range(M):
    L, R = map(int, input().split())
    lb = max(lb, L)
    rb = min(rb, R)

print(rb-lb+1 if lb <= rb else 0)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
state = [n, 0, 0, 0, 0, 0]
capacities = list(reversed([int(input()) for _ in range(5)]))
t = 0
while state[5]!=n:
    for idx, capa in enumerate(capacities):
        passengers = capa if capa <= state[4-idx] else state[4-idx]
        if passengers != 0:
            state[4-idx] -= passengers
            state[5-idx] += passengers
    t += 1
print(t)


Fixed submission:
import math
n = int(input())
state = [n, 0, 0, 0, 0, 0]
capacities = [int(input()) for _ in range(5)]
for i in range(1, 5):
    if capacities[i - 1] < capacities[i]:
        capacities[i] = capacities[i - 1]
print(4+math.ceil(n/capacities[4]))
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split(" "))
S = input()
bi_gram = [1 if S[k:k + 2] == "AC" else 0 for k in range(N - 1)]
qs = [list(map(int, input().split(" "))) for i in range(Q)]

for q in qs:
    print(sum(bi_gram[q[0] - 1: q[1] - 1]))

Fixed submission:
N, Q = map(int, input().split(" "))
S = input()
ac_cnts = [0]
ac_cnt = 0
for i in range(N-1):
    if S[i:i+2] == "AC":
        ac_cnt += 1
    ac_cnts.append(ac_cnt)
for j in range(Q):
    l, r = map(int, input().split(" "))
    print(ac_cnts[r-1] - ac_cnts[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split(" "))
S = input()
qs = [list(map(int, input().split(" "))) for i in range(Q)]

for q in qs:
    cnt = 0
    target = S[q[0]-1:q[1]]
    for i in range(q[1] - q[0]):
        if target[i:i+2] == "AC":
            cnt += 1
    print(cnt)

Fixed submission:
N, Q = map(int, input().split(" "))
S = input()
ac_cnts = [0]
ac_cnt = 0
for i in range(N-1):
    if S[i:i+2] == "AC":
        ac_cnt += 1
    ac_cnts.append(ac_cnt)
for j in range(Q):
    l, r = map(int, input().split(" "))
    print(ac_cnts[r-1] - ac_cnts[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
N, Q = map(int, input().split(" "))
S = input()
bi_gram = [S[k:k+2] for k in range(N - 1)]
qs = [list(map(int, input().split(" "))) for i in range(Q)]

for q in qs:
    print(reduce(lambda x, y: x + (1 if y == "AC" else 0), bi_gram[q[0]-1: q[1]-1], 0))

Fixed submission:
N, Q = map(int, input().split(" "))
S = input()
ac_cnts = [0]
ac_cnt = 0
for i in range(N-1):
    if S[i:i+2] == "AC":
        ac_cnt += 1
    ac_cnts.append(ac_cnt)
for j in range(Q):
    l, r = map(int, input().split(" "))
    print(ac_cnts[r-1] - ac_cnts[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
N, Q = map(int, input().split(" "))
S = input()
qs = [list(map(int, input().split(" "))) for i in range(Q)]

for q in qs:
    t = S[q[0]-1:q[1]]
    bi_gram = [t[k:k+2] for k in range(len(t) - 1)]
    print(reduce(lambda x, y: x + (1 if y == "AC" else 0), bi_gram, 0))

Fixed submission:
N, Q = map(int, input().split(" "))
S = input()
ac_cnts = [0]
ac_cnt = 0
for i in range(N-1):
    if S[i:i+2] == "AC":
        ac_cnt += 1
    ac_cnts.append(ac_cnt)
for j in range(Q):
    l, r = map(int, input().split(" "))
    print(ac_cnts[r-1] - ac_cnts[l-1])
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split(" "))
stores = dict()
p = 10000000000

for i in range(N):
    if 1 in stores and stores[1] >= M:
      break
    Ai, Bi = map(int, input().split(" "))
    if Ai in stores:
        stores[Ai] += Bi
    else:
        stores[Ai] = Bi
    p = min(p, Ai)


price = 0
while True:
    if p in stores:
        if M <= stores[p]:
            price += p * M
            break
        else:
            price += p * stores[p]
            M -= stores[p]
    p += 1
print(price)


Fixed submission:
H, W = map(int, input().split(" "))
h, w = map(int, input().split(" "))
print((H - h)*(W - w))
Buggy python submission (verdict: Runtime Error):
def ls_devider(num):
    fs = set()
    fs.add(1)

    if num > 1:
        for i in range(2, num):
            if num % i == 0:
                fs.add(i)

    return fs


a, b, k = map(int, input().split(' '))
a_dvs = ls_devider(a)
b_dvs = ls_devider(b)

print(sorted(a_dvs&b_dvs)[k-1])




Fixed submission:
def ls_devider(num):
    fs = set()
    fs.add(1)

    if num > 1:
        for i in range(2, num+1):
            if num % i == 0:
                fs.add(i)

    return fs


a, b, k = map(int, input().split(' '))
a_dvs = ls_devider(a)
b_dvs = ls_devider(b)

print(sorted(a_dvs&b_dvs, reverse=True)[k-1])
Buggy python submission (verdict: Runtime Error):
def binary_decomp(num):
  return _binary_decomp(num, list())

def _binary_decomp(num, p):
  if num == 0:
    return p
  k = 0
  while 2**k <= num:
    k+=1
  p.append(k-1)
  return _binary_decomp(num-2**(k-1), p)

def bin_to_num(ls):
  r = 0
  for idx, v in enumerate(ls):
    if v==1:
      r += 2**idx

  return r


n, k = map(int, input().split(" "))
bin_k = binary_decomp(k)
o = max(bin_k) + 1
bin_as = [0 for _ in range(o)]
for v in map(int, input().split(" ")):
  for i in binary_decomp(v):
    bin_as[i] += 1
pred = [1 if n > 2*bin_as[i] else 0 for i in range(o)]
change=0
while bin_to_num(pred) > k:
  pred[change] = 0
  change += 1

ans = 0
for idx, (m, r) in enumerate(zip(bin_as, pred)):
  ans += (m if r==0 else n-m)*(2**idx)

print(ans)

Fixed submission:
n, k = map(int, input().split(" "))
b_k = list(map(int, format(k+1, "b").zfill(40)[::-1]))
target = [ 0 for _ in range(40) ]
numbers = list(map(int, input().split(" ")))
for i in numbers:
  for idx, v in enumerate(format(i, "b")[::-1]):
    if v=="1":
      target[idx] += 1
best = [ 1 if n > 2*target[i] else 0 for i in range(40) ]

maxr = sum(numbers)
for i in range(len(b_k)):
  if b_k[i] == 1:
    maxr = max(maxr, sum((2**idx)*(t if r==0 else n-t) for idx, (t, r) in enumerate(zip(target, best[:i] + [0] + b_k[i+1:]))))
print(maxr)