Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03546 (python)

Fixed submission:
H,W=map(int,input().split())
C=[]
A=[]
for i in range(10):
    C.append(list(map(int,input().split())))
for i in range(H):
    A.append(list(map(int,input().split())))
# WF
for i in range(10):
    for j in range(10):
        for k in range(10):
            C[j][k]=min(C[j][k], C[j][i]+C[i][k])
print(sum(sum(C[i][1] for i in AA if i >= 0) for AA in A))

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
C=[]
A=[]
for i in range(10):
    C.append(list(map(int,input().split())))
for i in range(H):
    A.append(list(map(int,input().split())))
# WF
for i in range(10):
    for j in range(10):
        for k in range(10):
            C[i][j]=min(C[i][j], C[i][k]+C[k][j])
for i in range(10):
    cst[i]=djcstra(i,1,C)
print(sum(sum(C[i][1] for i in AA if i >= 0) for AA in A))
Problem p03860 (python)

Fixed submission:
a = input()
list = a.split()
a_list = list[0]
x_list = list[1]
b_list = list[2]
print(a_list[0] + x_list[0] + b_list[0])

Buggy submission (verdict: Runtime Error):
a = input()
x = input()
b = input()
x_list = list(x)
print(a + x_list[0] + b)
Problem p03633 (python)

Fixed submission:
def gcd(a,b):
    m = max(a,b)
    n = min(a,b)
    if n==0:
        return m
    return gcd(n, m%n)

def lcm(a,b):
    return (a*b)//gcd(a,b)

N = input()
Ti = []

for i in range(int(N)):
    tmp = input()
    Ti.append(int(tmp))

ans_lcm = 1
for i in range(len(Ti)):
    ans_lcm = lcm(ans_lcm,Ti[i])
print(ans_lcm)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    m = max(a,b)
    n = min(a,b)
    if n==0:
        return m
    return gcd(n, m%n)

def lcm(a,b):
    return (a*b)/gcd(a,b)

N = input()
Ti = []

for i in range(int(N)):
    tmp = input()
    Ti.append(int(tmp))
Ti.sort()

ans_lcm = lcm(Ti[0],Ti[1])
for i in range(2,len(Ti)):
    ans_lcm = lcm(ans_lcm,Ti[i])
print(int(ans_lcm))

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    if b==0:
        return a
    return gcd(b, a%b)

def lcm(a,b,g):
    return (a*b)/g

N = input()
Ti = []

for i in range(int(N)):
    tmp = input()
    Ti.append(int(tmp))
Ti.sort()

ans_gcd = gcd(Ti[0],Ti[1])
ans_lcm = lcm(Ti[0],Ti[1],ans_gcd)
for i in range(2,len(Ti)):
    ans_gcd = gcd(ans_gcd,Ti[i])
    ans_lcm = lcm(ans_lcm,Ti[i],ans_gcd)

print(int(ans_lcm))

Buggy submission (verdict: Runtime Error):
N = input()
Ti = []

def gcd(a,b):
    while (a != 0):
        a, b = b%a, a
    return b

def lcm(a,b):
    return (a*b)/gcd(a,b)

for i in range(int(N)):
    tmp = input()
    Ti.append(int(tmp))
Ti.sort()

ans_gcd = gcd(Ti[0],Ti[1])
ans_lcm = lcm(Ti[0],Ti[1])
for i in range(2,len(Ti)):
    ans_gcd = gcd(ans_gcd,Ti[i])
    ans_lcm = lcm(ans_lcm,Ti[i])

print(int(ans_lcm))

Buggy submission (verdict: Runtime Error):
N = input()
Ti = []

def gcd(a,b):
    while (a != 0):
        a, b = b%a, a
    return b

for i in range(int(N)):
    tmp = input()
    Ti.append(int(tmp))
Ti.sort()

ans_gcd = gcd(Ti[0],Ti[1])
ans_lcm = (Ti[0]*Ti[-1])/ans_gcd
for i in range(2,len(Ti)):
    ans_gcd = gcd(ans_gcd,Ti[i])
    ans_lcm = (ans_gcd*Ti[-1])/ans_gcd

print(int(ans_lcm))

Buggy submission (verdict: Runtime Error):
N = input()
Ti = []

def gcd(a,b):
    gcd = 1
    for i in range(2,a+1):
        if a%i == 0 and b%i == 0:
            gcd = i
    return gcd

for i in range(int(N)):
    tmp = input()
    Ti.append(int(tmp))
Ti.sort()

ans_gcd = gcd(Ti[0],Ti[1])
ans_lcm = (Ti[0]*Ti[-1])/ans_gcd
for i in range(2,len(Ti)):
    ans_gcd = gcd(ans_gcd,Ti[i])
    ans_lcm = (ans_gcd*Ti[-1])/ans_gcd

print(int(ans_lcm))
Problem p03126 (python)

Fixed submission:
N, M = list(map(int, raw_input().split()))
K = []

array = []
for i in xrange(M): array.append(0)
for i in xrange(N):
    inputs = list(map(int, raw_input().split()))
    K = inputs[0]
    for j in xrange(K):
        array[inputs[j+1]-1] += 1

count = 0
for i in xrange(M):
    if array[i] == N: count += 1

print str(count)

Buggy submission (verdict: Runtime Error):
N, M = list(map(int, raw_input().split()))
K = []

array = []
for i in xrange(M): array.append(0)
for i in xrange(N):
    inputs = list(map(int, raw_input().split()))
    K = inputs[0]
    for j in xrange(K):
        array[inputs[j+1]] += 1

count = 0
for i in xrange(M):
    if array[i] == N: count += 1

print str(count)
Problem p03128 (python)

Fixed submission:
N, M = map(int, raw_input().split())
A = map(int, raw_input().split())
all_cost = [-10**15, 2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [-10**15] * (N+1)

dp[0] = 0
for i in range(1, N+1, 1):
    max_val = -10**15
    for a in A:
        if i - all_cost[a] >= 0 and dp[i - all_cost[a]] != -10**15:
            val = dp[i - all_cost[a]] + 1
            if val > max_val: max_val = val
    dp[i] = max_val

A.sort(reverse=True)

result = ''
idx = N
while idx > 0:
    for a in A:
        if idx - all_cost[a] < 0: continue
        if dp[idx - all_cost[a]] == dp[idx] - 1:
            result += str(a)
            idx -= all_cost[a]
            break

print result

Buggy submission (verdict: Runtime Error):
N, M = map(int, raw_input().split())
A = map(int, raw_input().split())
all_cost = [-10**15, 2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [-10**15] * (N+1)

dp[0] = 0
for i in range(1, N+1, 1):
    max_val = -10**15
    for a in A:
        if i - all_cost[a] >= 0 and dp[i - all_cost[a]] != -10**15:
            val = dp[i - all_cost[a]] + 1
            if val > max_val: max_val = val
    dp[i] = max_val

A.sort(reverse=True)

result = ''
idx = N
while idx > 0:
    for a in A:
        if dp[idx - all_cost[a]] == dp[idx] - 1:
            result += str(a)
            idx -= all_cost[a]
            break

print result
Problem p03125 (python)

Fixed submission:
A,B = map(int, input().split())
if B % A == 0:
  print(A+B)
else:
  print(B-A)

Buggy submission (verdict: Runtime Error):
import collections
N = int(input())
mli = sorted(list(map(int,input().split())), reverse = False)
hp_min = mli[0]
index = 1
for i in range(1,N):
  if mli[index] % hp_min == 0:
    mli.pop(index)
  else:
    mli[index] = mli[index] % hp_min
    hp_min = mli[index]
    index += 1
    
#if mli[i] % hp_min != 0:
  #hp_min = mli[i] % hp_min 
print(hp_min)
Problem p03001 (python)

Fixed submission:
w, h, x, y = map(int, input().split(' '))

max_area = 0
square_area = w * h
multiple_ans = 1 if 2 * x == w and 2 * y == h else 0

print('{max_area} {multiple_ans}'.format(max_area=str(square_area / 2), multiple_ans=str(multiple_ans)))

Buggy submission (verdict: Runtime Error):
class Point():
    def __init__(self, x, y):
        self.x = x
        self.y = y    

w, h, x, y = map(int, input().split(' '))

square_area = w * h

px = w / 2  # 3
py = h / 2  # 3.5

multiple_ans = 0
if px == x and py == y:
    multiple_ans = 1

a = py - y / px - x
b = y - x * a

cross_point = []

cross_x = (h - b) / a  # 一番上
if not 0 <= cross_x <= w:
    cross_point.append(Point(cross_x, h))
cross_x = (b / a) * -1  # 一番下
if not 0 <= cross_x <= w:
    cross_point.append(Point(cross_x, 0))
cross_y = b
if not 0 <= cross_y <= h:
    cross_point.append(Point(0, cross_y))
cross_y = w * a + b
if not 0 <= cross_y <= h:
    cross_point.append(Point(w, cross_y))

cross_1 = cross_point[0]
cross_2 = cross_point[1]

if cross_1.y == 0 and cross_2.x == w:
    area_a = ((h - cross_2.y) * cross_1.x) / 2
    area_b = square_area - area_a
elif cross_2.x == w and cross_1.y == 0:
    area_a = ((w - cross_2.x) * cross_1.y) / 2
    area_b = square_area - area_a
elif cross_2.x == w and cross_1.y == h:
    area_a = (w - cross_1.x) * (h - cross_2.y) / 2
    area_b = square_area - area_a
elif cross_2.x == w and cross_1.y == 0:
    area_a = (cross_1.x * cross_2.x) / 2
    area_b = square_area - area_a
else:
    area_a = (cross_1.y * cross_2.y) / 2
    area_b = square_area - area_a

print('{max_area} {multiple_ans}'.format(max_area=str(min(area_a, area_b)), multiple_ans=str(multiple_ans)))
Problem p03059 (python)

Fixed submission:
args = input()
args = args.split(' ')

a = int(args[0])
b = int(args[1])
t = int(args[2]) + 0.5 - a

r = 0

while t > 0:
    r += b
    t -= a

print(r)

Buggy submission (verdict: Runtime Error):
argv = sys.argv
a = int(input())


b = int(input())

t = int(input()) + 0.5 - a

r = 0

while t > 0:
    r += b
    t -= a

print(r)

Buggy submission (verdict: Runtime Error):
import sys

argv = sys.argv
a = int(argv[1])
b = int(argv[2])
t = int(argv[3]) + 0.5 - a

r = 0

while t > 0:
    r += b
    t -= a

print(r)
Problem p03814 (python)

Fixed submission:
s = input()

idx_a = None
idx_b = 0

for idx, char in enumerate(s):
    if char =='A' and idx_a is None:
        idx_a = idx
    if char == 'Z':
        idx_b = idx

print(idx_b - idx_a + 1)

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

idx_a = None
idx_b = 0

for idx, char in enumerate(s):
    if char =='A' and idx_a:
        idx_a = idx
    if char == 'Z':
        idx_b = idx

print(idx_b - idx_a + 1)
Problem p02848 (python)

Fixed submission:
N = int(input())
S = input()
abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
w = ""
for x in S:
    if abc.index(x) + 1 + N > 26:
        w += abc[abc.index(x) + N - 26]
    else:
        w += abc[abc.index(x) + N]
print(w)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
w = ""
for x in S:
    if abc.index(x) + N > 26:
        w += abc[abc.index(x) + N - 26]
    else:
        w += abc[abc.index(x) + N]
print(w)
Problem p02921 (python)

Fixed submission:
n=list(input())
s=list(input())
g=0
for i in range(3):
    if n[i]==s[i]:
        g+=1

print(g)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=[i for i in range(a)]
c=int(sum(b))
print(c)
Problem p02995 (python)

Fixed submission:
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

a,b,c,d=map(int,input().split())
print((b-a+1) - ((b//c-(a-1)//c) + (b//d-(a-1)//d) - (b//lcm(c,d) - (a-1)//lcm(c,d))))

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

a,b,c,d=map(int,input().split())
print((b-a+1) - ((b//c-(a-1)//c) + (b//d-(a-1)//d) - (b//lcm(c,d) - (a-1)//lcm(c,d))))

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input().split())
print((b-a+1) - ((b//c-(a-1)//c) + (b//d-(a-1)//d) - (b//lcm(c,d) - (a-1)//lcm(c,d))))
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

a,b,c,d=map(int,input().split())
print((b-a+1) - ((b//c-(a-1)//c) + (b//d-(a-1)//d) - (b//lcm(c,d) - (a-1)//lcm(c,d))))
Problem p03478 (python)

Fixed submission:
n,a,b = map(int, input().split())
t=0
for i in range(1,n+1):
    orign=i
    total = 0
    for ii in range(len(str(i))):
        total += i%10
        i=int(i/10)
    if total>=a and total<=b:
        t+=orign
print(t)

Buggy submission (verdict: Runtime Error):
n,a,b = (int(input()) for i in range(3))
t=0
for i in range(1,n+1):
    orign=i
    total = 0
    for ii in range(len(str(i))):
        total += i%10
        i=int(i/10)
    if total>=a and total<=b:
        t+=orign
print(t)

Buggy submission (verdict: Runtime Error):
n,a,b = [int(input()) for i in range(3)]
t=0
for i in range(1,n+1):
    orign=i
    total = 0
    for ii in range(len(str(i))):
        total += i%10
        i=int(i/10)
    if total>=a and total<=b:
        t+=orign
print(t)

Buggy submission (verdict: Runtime Error):
n,a,b = [int(input()) for i in range(3)]
t=0
for i in range(1,n+1):
    orign=i
    total = 0
    for ii in range(len(str(i))):
        total += i%10
        i=int(i/10)
    if total>=a and total<=b:
        t+=orign
print(t)
Problem p03240 (python)

Fixed submission:
N=int(input())
xyh=[]
for i in range(N):
    a=[int(i) for i in input().split()]
    xyh.append(a)
xyh.sort(key=lambda x:x[2],reverse=True)
flag2=True
for i in range(0,101):
    for j in range(0,101):
        flag=True
        H=xyh[0][2]+abs(xyh[0][0]-i)+abs(xyh[0][1]-j)
        for k in range(1,N):
            if xyh[k][2]!=max(0,H-abs(xyh[k][0]-i)-abs(xyh[k][1]-j)):
                flag=False
                break
        if flag==True:
            print("{} {} {}".format(i,j,H))
            flag2=False
            break
    if flag2==False:
        break

Buggy submission (verdict: Runtime Error):
N=int(input())
A=[]
for j in range(N):
    a=[int(i) for i in input().split()]
    A.append(a)
for i in range(0,101):
    for j in range(0,101):
        HH=[]
        P=[]
        for k in range(N):
            if A[k][2]==0:
                if 1>abs(A[k][0]-i)+abs(A[k][1]-j):
                    break
                else:
                    Q=abs(A[k][0]-i)+abs(A[k][1]-j)
                    P.append(Q)
                    if k==N-1:
                        if len(P)==0:
                            print("{} {} {}".format(i,j,HH[0]))
                            break
                        elif H<=max(P):
                            print("{} {} {}".format(i,j,HH[0]))
                        else:
                            break
                    else:
                        continue
            else:
                H=A[k][2]+abs(A[k][0]-i)+abs(A[k][1]-j)
                if len(HH)==0:
                    HH.append(H)
                    continue
                if H in HH:
                    HH.append(H)
                    if k==N-1:
                        if len(P)==0:
                            print("{} {} {}".format(i,j,H))
                        elif H<=max(P):
                            print("{} {} {}".format(i,j,h))
                        else:
                            break
                    else:
                        continue
                else:
                    break
Problem p03262 (python)

Fixed submission:
from fractions import gcd
from functools import reduce
 
N,X=map(int, input().split())
x=map(int, input().split())

lis=[abs(j-X) for j in x]

print(reduce(gcd,lis))

Buggy submission (verdict: Runtime Error):
import math
N,X=[int(i) for i in input().split()]
a=[abs(int(i)-X) for i in input().split()]
c=max(a)
for i in range(len(a)):
    c=math.gcd(c,a[i])
print(c)

Buggy submission (verdict: Runtime Error):
from functools import reduce
from math import gcd

N,X=map(int, input().split())
x=map(int, input().split())

lis=[abs(j-X) for j in x]

print(reduce(gcd,lis))

Buggy submission (verdict: Runtime Error):
from functools import reduce
from math import gcd
 
N,X=[int(i) for i in input().split()]
x=[int(i) for i in input().split()]

lis=[abs(j-X) for j in x]

print(reduce(gcd,lis))

Buggy submission (verdict: Runtime Error):
from functools import reduce
from math import gcd
 
N,X=[int(i) for i in input().split()]
x=[int(i) for i in input().split()]

lis=[abs(x[j]-X) for j in range(N)]

print(reduce(gcd,lis))
Problem p02921 (python)

Fixed submission:
predict = input()
real = input()
cnt = 0
 
for i,j in zip(predict, real):
  if i == j:
    cnt += 1
    
print(cnt)

Buggy submission (verdict: Runtime Error):
predict = input()
real = input()
cnt = 0

for i,j in zip(predict, real):
  if i == j:
    cnt += 1
    
print(cnt
Problem p02934 (python)

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

for i in range(N):
  ans += 1/A[i]
  
ans = 1/ans
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = 0

for i in range(N):
  A = int(input())
  ans += 1//A
  
ans = 1//ans

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = 0

for i in range(N):
  A = int(input())
  ans += 1/A
  
ans = 1/ans

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = 0

for i in range(N):
  A = int(input())
  ans += 1/A
  
ans = 1/ans

print(ans
Problem p03455 (python)

Fixed submission:
num1, num2 = map(int, input().split())
seki = num1 * num2
if seki % 2 == 0:
    print("Even")
else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
num = map(int, input().split())
seki = num[0] * num[1]
if seki % 2 == 0:
    print(Even)
else:
    print(Odd)

Buggy submission (verdict: Runtime Error):
num = map(int, input().split())
seki = num[0] * num[1]
if seki % 2 == 0:
    print("Even")
else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
input_num = map(int, input().split())
seki = input_num[0] * input_num[1]
if seki % 2 == 0:
    print("Even")
else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
input_num = map(int, input().split())
seki = input_num[0] * input_num[1]
if seki % 2 == 0:
    print("Even")
else:
    print("0dd")

Buggy submission (verdict: Runtime Error):
input_num = map(int, input().split())
seki = input_num[0] * input_num[1]
if seki % 2 == 0:
    print("Even")
else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
input_num = map(int, input().split())
seki = input_num[0] * input_num[1]
if seki % 2 == 0:
    print("EvenW\")
else:
    print("Odd")
Problem p03493 (python)

Fixed submission:
num = input()
cnt = 0
for i in num:
    if i == "1":
        cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
_ = int(input())

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

count = 0
is_all_even = None 
while True:
    for num in num_list:
        if num % 2 != 0:
            is_all_even = False
            break
    if is_all_even is not None:
        break
    count += 1
    num_list = list(map(lambda x: x / 2, num_list))
print(count)
Problem p03607 (python)

Fixed submission:
n = int(input())
l = set()

for _ in range(n):
    a = int(input())

    if a in l:
        l.remove(a)
    else:
        l.add(a)

print(len(l))

Buggy submission (verdict: Runtime Error):
n = int(input())
l = set()

for _ in range(n):
    a = int(input())

    if a in l:
        l.remove(a)
    else:
        l.append(a)

print(len(l))
Problem p03696 (python)

Fixed submission:
n = int(input())
a = list(input())
b = []
cou1=0

for i in a:
    if i=="(":
        cou1 += 1
        b.append("(")
    else:
        b.append(")")
        if cou1==0:
            b.insert(0,"(")
            continue
        cou1 -= 1

for _ in range(cou1):
    b.append(")")

print(*b,sep='')

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(input())
b = []
cou1=0

for i in a:
    if i=="(":
        cou1 += 1
        b.append("(")
    else:
        b.append(")")
        if cou1==0:
            b.insert(0,"(")
            continue
        cou1 -= 1

for _ in range(cou1):
    b.append(")")

print(*b,sep='')n = int(input())
a = list(input())
b = []
cou1=0

for i in a:
    if i=="(":
        cou1 += 1
        b.append("(")
    else:
        b.append(")")
        if cou1==0:
            b.insert(0,"(")
            continue
        cou1 -= 1

for _ in range(cou1):
    b.append(")")

print(*b,sep='')
Problem p02885 (python)

Fixed submission:
a, b = map(int, input().split())
print(a - 2*b) if a - 2*b > 0 else print(0)

Buggy submission (verdict: Runtime Error):
import itertools

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

print(sum(x*y for x, y in itertools.combinations(t, 2)))
Problem p02898 (python)

Fixed submission:
n, k = list(map(int,input().split()))
h = list(map(int,input().split()))
print(sum(list(map(lambda x: 1 if x - k >= 0 else 0, h))))

Buggy submission (verdict: Runtime Error):
n, k = list(map(int,input().split()))
h = list(map(int,input().split()))
print(sum([map(lambda x: 1 if x - k >= 0 else 0, h)]))
Problem p02885 (python)

Fixed submission:
A,B=input().split()
A=int(A)
B=int(B)
if A>2*B:
  print(A-2*B)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
A=input()
B=input()
A=int(A)
B=int(A)

if A>2*B:
    print(A-2*B)
else:
    print(0)
Problem p02850 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

N = int(input())
graph = [[] for i in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    graph[a].append([b, i])
    graph[b].append([a, i])

ans = [None]*(N-1)
def dfs(cur, p_color, p=-1):
    color = 1
    for (to, i) in graph[cur]:
        if to == p: continue
        if color == p_color:
            color = color+1
        ans[i] = color
        dfs(to, color, p=cur)
        color = color+1

dfs(0, -1)
print(max(ans))
[print(a) for a in ans]

Buggy submission (verdict: Runtime Error):
N = int(input())
graph = [[] for i in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    graph[a].append([b, i])
    graph[b].append([a, i])

ans = [None]*(N-1)
def dfs(cur, p_color, p=-1):
    color = 1
    for (to, i) in graph[cur]:
        if to == p: continue
        if color == p_color:
            color = color+1
        ans[i] = color
        dfs(to, color, p=cur)
        color = color+1

dfs(0, -1)
print(max(ans))
[print(a) for a in ans]
Problem p03087 (python)

Fixed submission:
n,q=map(int, input().split())
S=input()
lr=[list(map(int, input().split())) for _ in range(q)]
t=[0]*(n+1)
for i in range(n):
    #i桁目までに登場するACを計算する
    t[i+1]=t[i]+(1 if S[i:i+2] == "AC" else 0)
for i in range(q):
    l,r=lr[i][0]-1,lr[i][1]-1
    print(t[r]-t[l])

Buggy submission (verdict: Runtime Error):
n,q=map(int, input().split())
S=input()
lr=[list(map(int, input().split())) for _ in range(q)]
t=[0]*(n+1)
for i in range(n):
    #i桁目までに登場するACを計算する
    t[i+1]=t[i]+(1 if s[i:i+2] == "AC" else 0)
for i in range(q):
    l,r=lr[i][0]-1,lr[i][1]-1
    print(t[r-1]-t[l-1])
Problem p03125 (python)

Fixed submission:
A,B = map(int, input().split())
ans = 0
if B%A == 0:
    ans = A+B
else:
    ans = B-A
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
def num_match(n):
    if n==1:
        return 2
    elif n==2 or n==3 or n==5:
        return 5
    elif n==4:
        return 4
    elif n==6:
        return 6
    elif n==7:
        return 3
    elif n==8:
        return 7
    elif n==9:
        return 6
N,M = map(int, input().split())
A = list(map(int,input().split()))
match = np.array([[a,num_match(a)] for a in A])
sorted_num = match[np.argsort(match[:,0])[::-1]]
sorted_match = match[np.argsort(match[:,1])]
min_num_match = sorted_match[0][1]
max_k = int(N/min_num_match)#一番小さいマッチ数の整数を使える数
rem = N%min_num_match + min_num_match
#rem+match[min_match_index][1]*kがmin以外の組み合わせの合計
ans_exist = False
ans = 0
used_match = []
for k in range(max_k):#remを更新していく？
    if rem in sorted_match[:,1]:
        ans_exist = True
        used_match.append(rem)
        break
    else:
        for n in sorted_match[:,1]:
            if n < rem and n!=min_num_match :
                used_match.append(n)
                rem = rem-n
                break
    if ans_exist:
        #max_k = max_k-k
        break
    else:
        rem = rem + min_num_match
used_match.append(min_num_match)
used_num = []
for um in used_match:
    for i in range(sorted_num.shape[0]):
        if um == sorted_num[i][1]:
            used_num.append(sorted_num[i][0])
            break
base_num=used_num.pop()
sorted_used_num = sorted(used_num,reverse=True)
upper  =[]
lower = []
for s in sorted_used_num:
    if s > base_num:
        upper.append(s)
    else:
        lower.append(s)
lower = sorted(lower)
ans_list = [base_num]*max_k
if len(upper) > 0:
    for i in range(len(upper)):
        ans_list[i] = upper[i]
if len(lower) > 0:
    for j in range(len(lower)):
        ans_list[len(ans_list)-1-j] = lower[j]
ans = ""
for a in ans_list:
    ans = ans + str(a)
ans = int(ans)
print(ans)