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

Fixed submission:
from decimal import *
A, B = map(Decimal, input().split())
print(int(A * B // 1))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python

def main():
    A, B = map(float, input().split())
    print(int((A * B) / /1))

if __name__ == '__main__':
    main()
Problem p02693 (python)

Fixed submission:
k = int(input())
a, b = map(int, input().split())
 
flag = False
for i in range(a, b+1):
    if i % k == 0:
        flag = True
 
print("OK") if flag else print("NG")

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

flag = False
for i in range(a, b+1):
	if i % k == 0:
    	flag = True

print("OK") if flag else print("NG")
Problem p02725 (python)

Fixed submission:
#!/usr/bin/env python
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    K, N = map(int, input().split())
    A = tuple(map(int, input().split()))
    tmp = 0
    for i in range(N-1):
        tmp = max(tmp, A[i+1] - A[i])

    tmp = max(tmp, (K-A[N-1]+A[0]))
    print(K-tmp)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
def input():
    return sys.stdin.readline()[:-1]

def main():
    K, N = map(int, input().split())
    A = tuple(map(int, input().split()))
    tmp = 0
    for i in range(N-1):
        tmp = max(tmp, A[i+1] - A[i])

    tmp = max(tmp, (K-A[N-1]+A[0]))
    print(K-tmp)

if __name__ == '__main__':
    main()
Problem p02754 (python)

Fixed submission:
#!/usr/bin/env python

def main():
    n, a, b = map(int, input().split())
    print(n // (a+b) * a + min(n % (a+b), a))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python

def input():
    return sys.stdin.readline()[:-1]

def main():
    n, a, b = map(int, input().split())
    print(n // (a+b) * a + min(n % (a+b), a))

if __name__ == '__main__':
    main()
Problem p02779 (python)

Fixed submission:
#!/usr/bin/env python

def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    s = set()
    for a in A:
        if a in s:
            print("NO")
            exit()
        else:
            s.add(a)
    print("YES")

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python

main():
    N = int(input())
    A = tuple(map(int, input().split()))
    s = set()
    for a in A:
        if a in s:
            print("NO")
            exit()
        else:
            s.add(a)
    print("YES")

if __name__ == '__main__':
    main()
Problem p02951 (python)

Fixed submission:
#!/usr/bin/env python

def main(A, B, C):
    ans = C - (A - B)
    if ans > 0:
        return ans
    else:
        return 0

if __name__ == '__main__':
    A, B, C = list(map(int, input().split()))
    print(main(A, B, C))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python

def main(N, H):
    ans = 'Yes'

    min_val = H[0] -1
    for i in range(1, N):
        if min_val <= H[i] -1:
            min_val = H[i] -1
        elif min_val <= H[i]:
            min_val = H[i]
        else:
            ans = 'No'
            break
    return ans

if __name__ == '__main__':
    N = int(input())
    H = list(map(int, input().split()))
    print(main(N, H))
Problem p03835 (python)

Fixed submission:
# -*- coding: utf-8 -*-
# problem B

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

ans = 0

for i in range(k+1):
    for j in range(k+1):
        z = s-i-j
        if 0 <= z and z <=k:
            ans = ans+1

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# problem B

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

ans = 0

for i in range(k+1):
    forj in range(k+1):
        z = s-i-j
        if 0 <= z and z <=k:
            ans = ans+1

print(ans)
Problem p02659 (python)

Fixed submission:
import decimal
A,B = map(decimal.Decimal,input().split())
c = decimal.Decimal(A * B)
d = c.quantize(decimal.Decimal('0'), rounding=decimal.ROUND_FLOOR)
print(d)

Buggy submission (verdict: Runtime Error):
import math
A,B = map(int,input().split())
ans = math.floor(A*B)
Problem p02723 (python)

Fixed submission:
S = input()

if S[2]==S[3] and S[4]==S[5]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
S = input()
 
if S[3] ==S[4] and S[5] == S[6]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S = input()
 
if S[2] ==S[3] and S[4] == S[5]:
  Print('Yes')
else:
  Print('No')

Buggy submission (verdict: Runtime Error):
S = input()
 
if S[3] ==S[4] and S[5] == S[6]:
  Print('Yes')
else:
  Print('No')

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

if S[3] ==S[4] and S[5] == S[6]:
  Print('Yes')
  else:
    Print('No')
Problem p02729 (python)

Fixed submission:
N, M = map(int,input().split())
a = int((N * (N-1) + M * (M-1)) / 2)
print(a)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split)
a = int((N * (N-1) + M * (M-1)) / 2)
print(a)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split)
a = ((N * (N-1)) + (M * (M-1)))/2
print(a)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split)
print((((N * (N-1)) + ((M *(M-1)))/2)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split)
print(((N * (N-1)) + (M *(M-1))/2)
Problem p02753 (python)

Fixed submission:
S = input()

if S[0] == S[1] == S[2]:
  print('No')
else:
  print('Yes')

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

if S[0] == S[1] = S[2]:
  print('No')
else:
  print('Yes')
Problem p02777 (python)

Fixed submission:
S,T = input().split()
A,B = map(int,input().split())
U = input()
 
if S == U :
    print("{} {}".format(A-1,B))
else :
    print("{} {}".format(A,B-1))

Buggy submission (verdict: Runtime Error):
S,T = input().split()
A,B = map(int,input().split())
U = input()

if S == U:
  print({},{}).format(A-1,B)
else:
  print({},{}).format(A,B-1)
Problem p03286 (python)

Fixed submission:
n = int(input())

def basen(n):
    a = []
    while n!= 0:
        r = n % 2
        if (r < 0):
            r += 2

        n = (n - r)//(-2)
        a.append(r)
    if a == []:
        a.append(0)
    a.reverse()
    return "".join(map(str,a))
print(basen(n))

Buggy submission (verdict: Runtime Error):
n = map(int,input())

def basen(n):
    a = []
    while n!= 0:
        r = n % 2
        if (r < 0):
            r += 2

        n = (n - r)//(-2)
        a.append(r)
        if(a == " "):
            a.append(0)
        reversed(a)
    return a
 
print(basen(n))

Buggy submission (verdict: Runtime Error):
n = map(int,input())


def base-2(n):
    a = ()
    while n! = 0:
        r = n % 2:
        if (r < 0):
            r += 2

            n = (n - r)/2
            a.append(str(r))
    if(a = ""):
    a = "0"
    reversed(a)
print(base(n))
Problem p02659 (python)

Fixed submission:
from decimal import *
def ABC_169_C():
    getcontext().prec=28
    A,B= map(float, input().split())
    k=Decimal(str(A))*Decimal(str(B))
    print(int(k))

if __name__ == '__main__':

    ABC_169_C()

Buggy submission (verdict: Runtime Error):
from decimal import *
def ABC_169_C():
    getcontext().prec=28
    i=0
    A,B= map(float, input().split())
    k=Decimal(A)*Decimal(B)
    k=str(k)
    i=k.index('.')
    print(int(k[0:i]))

if __name__ == '__main__':

    ABC_169_C()

Buggy submission (verdict: Runtime Error):
from decimal import *
def ABC_169_C():
    getcontext().prec=28
    i=0
    A,B= map(float, input().split())
    k=Decimal(A)*Decimal(B)
    k=str(k)
    i=k.index('.')
    print(k[0:i])

if __name__ == '__main__':

    ABC_169_C()
Problem p02754 (python)

Fixed submission:
inputText1 = input()
# inputText1 = "8 3 4"
inputText1List = inputText1.split()
n = int(inputText1List[0])
b = int(inputText1List[1])
r = int(inputText1List[2])
count = 10 **100
if b == 0:
    print(b)
else:
    # i = (count // (b + r)) + 1 # 最大繰り返し数
    baseTextCount = b + r # 7
    i = n // baseTextCount
    mod = n % baseTextCount
    # print(i * b) # あまりを除いた青のボール数
    if mod < b:
        print(i * b + mod)
    else:
        print(i * b + b)

Buggy submission (verdict: Runtime Error):
n, b, r = map(int, input().split())
# inputText1 = "8 3 4"
inputText1List = inputText1.split()
# n = int(inputText1List[0])
# b = int(inputText1List[1])
# r = int(inputText1List[2])
if b == 0:
    print(b)
else:
    # i = (count // (b + r)) + 1 # 最大繰り返し数
    baseTextCount = b + r # 7
    i = n // baseTextCount
    mod = n % baseTextCount
    # print(i * b) # あまりを除いた青のボール数
    if mod < b:
        print(i * b + mod)
    else:
        print(i * b + b)
Problem p02701 (python)

Fixed submission:
group = set()
for _ in range(int(input())):
  group.add(input())
print(len(group))

Buggy submission (verdict: Runtime Error):
group = {}
for _ in range(int(input())):
  group.add(input())
print(len(group))
Problem p03242 (python)

Fixed submission:
print(1110-int(input()))

Buggy submission (verdict: Runtime Error):
print(1110-int(input())
Problem p02762 (python)

Fixed submission:
def find(x): #xの根を求める
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x,y): #xとyの属する集合の併合
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

def same(x,y): #xとyが同じ集合に属するかの判定
    return find(x) == find(y)

def size(x): #xが属する集合の個数
    return -par[find(x)]

N,M,K = map(int, input().split())
par = [-1]*(N+1)
fri = [[] for i in range(N+1)]
for i in range(M):
    a,b = map(int,input().split())
    fri[a].append(b)
    fri[b].append(a)
    unite(a,b)

bro = [[] for i in range(N+1)]
for i in range(K):
    c,d = map(int,input().split())
    bro[c].append(d)
    bro[d].append(c)

ans = [0]*N
for i in range(1,N+1):
    ans[i-1] = size(i)-1
    for f in fri[i]:
        if same(f,i): ans[i-1] -= 1
    for b in bro[i]:
        if same(b,i): ans[i-1] -= 1

# print(par)
ans = list(map(str,ans))
print(" ".join(ans))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
N,M,K = map(int,input().split())
fri = [[] for i in range(N+1)] #iさんの友達
for i in range(M):
    a,b = map(int,input().split())
    fri[a].append(b)
    fri[b].append(a)
bro = [[] for i in range(N+1)] #iさんのブロック
for i in range(K):
    c,d = map(int,input().split())
    bro[c].append(d)
    bro[d].append(c)

def dfs(i):
    seen[i] = True
    size_is[cur] += 1
    n_is[i] = cur
    for a in fri[i]:
        if not seen[a]: dfs(a)

seen = [False]*(N+1)
n_is = [0]*(N+1)
size_is = [0]
cur = 0
for i in range(1,N+1):
    if not seen[a]: #Falseで入る
        cur += 1
        size_is.append(0)
        dfs(i)

ans = [0]*N
for a in range(1,N+1):
    ans[a-1] = size_is[n_is[a]]-1
    for b in fri[a]:
        if n_is[b] == n_is[a]: ans[a-1] -= 1
    for d in bro[a]:
        if n_is[d] == n_is[a]: ans[a-1] -= 1

ans = list(map(str, ans))
print(" ".join(ans))

Buggy submission (verdict: Runtime Error):
N,M,K = map(int,input().split())
fri = [[] for i in range(N+1)] #iさんの友達
for i in range(M):
    a,b = map(int,input().split())
    fri[a].append(b)
    fri[b].append(a)
bro = [[] for i in range(N+1)] #iさんのブロック
for i in range(K):
    c,d = map(int,input().split())
    bro[c].append(d)
    bro[d].append(c)

def dfs(i):
    seen[i] = True
    size_is[cur] += 1
    n_is[i] = cur
    for a in fri[i]:
        if not seen[a]: dfs(a)

seen = [False]*(N+1)
n_is = [0]*(N+1)
size_is = [0]
cur = 0
for i in range(1,N+1):
    if not seen[a]: #Falseで入る
        cur += 1
        size_is.append(0)
        dfs(i)

ans = [0]*N
for a in range(1,N+1):
    ans[a-1] = size_is[n_is[a]]-1
    for b in fri[a]:
        if n_is[b] == n_is[a]: ans[a-1] -= 1
    for d in bro[a]:
        if n_is[d] == n_is[a]: ans[a-1] -= 1

ans = list(map(str, ans))
print(" ".join(ans))
Problem p03011 (python)

Fixed submission:
P,Q,R = map(int, input().split())
print(min(P+Q,Q+R,R+P))

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
s = [[] for i in range(H)]
for i in range(H): s[i] = list(input())
l = [[0]*W for i in range(H)]
r = [[0]*W for i in range(H)]
d = [[0]*W for i in range(H)]
u = [[0]*W for i in range(H)]

for h in range(H):
    for w in range(W):
        if s[h][w] == ".":
            l[h][w], d[h][w] = 1,1
            if w != 0: l[h][w] = l[h][w-1] + 1
            if h != 0: d[h][w] = d[h-1][w] + 1
    for w in range(W):
        if s[H-1-h][W-1-w] == ".":
            r[H-1-h][W-1-w] = 1
            if w != 0: r[H-1-h][W-1-w] = r[H-1-h][W-w] + 1

for h in range(H):
    for w in range(W):
        if s[H-1-h][W-1-w] == ".":
            u[H-1-h][W-1-w] = 1
            if h != 0: u[H-1-h][W-1-w] = u[H-h][W-1-w] + 1
ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans, l[h][w]+r[h][w]+u[h][w]+d[h][w]-3)

print(ans)

Buggy submission (verdict: Runtime Error):
N,M = map(int, input().split())
a = [0]*M
for i in range(M): a[i] = int(input())

mod = [1]*N
inv = [1]*N
inf = 10**9+7
for i in range(N-1): mod[i+1] = mod[i]*(i+2)%inf
inv[N-1] = pow(mod[N-1], inf-2, inf)
for i in range(2,N+1): inv[N-i] = inv[N-i+1]*(N-i+2)%inf

def comb(cur,ai):
    if ai - cur == 1:
        return 1
    elif ai <= cur:
        return 0
    return(comb(cur, ai-1)+comb(cur,ai-2))

cur = 1
if a[0] == 1: cur += 1
cnt = 0
for i in range(M):
    if cur == a[i]:
        cnt = 0
        break
    cnt += comb(cur,a[i])
    cur = a[i]+1

print(cnt)
Problem p03013 (python)

Fixed submission:
N,M = map(int, input().split())
a = [-1]*(M+2)
a[M+1] = N+1
diff = 0
for i in range(1,M+2):
    if i != M+1: a[i] = int(input())
    diff = max(diff, a[i]-a[i-1])

inf = 10**9+7

dp = [0]*diff
dp[0] = 0
dp[1] = 1
for i in range(2,diff):
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] = dp[i]%inf

cnt = 1
for i in range(1,M+2):
    da = a[i]-a[i-1]-1
    if da == 0:
        cnt = 0
        break
    else:
        cnt *= dp[da]
        cnt = cnt%inf

print(cnt%inf)

Buggy submission (verdict: Runtime Error):
N,M = map(int, input().split())
a = [0]*(M+1)
for i in range(M): a[i] = int(input())
a[M] = N+1

inf = 10**9+7

def comb(cur,ai):
    if ai - cur == 1:
        return 1
    elif ai - cur == 2:
        return 2
    elif ai <= cur:
        return 0
    return((comb(cur, ai-1)+comb(cur,ai-2))%inf)

cur = 0
if a[0] == 1: cur += 2
cnt = 1
for i in range(M+1):
    if a[0] == 1 and i == 0: continue
    if cur == a[i]:
        cnt = 0
        break
    cnt *= comb(cur,a[i]-1)%inf
    cnt = cnt%inf
    cur = a[i]+1

print(cnt%inf)
Problem p03018 (python)

Fixed submission:
s = list(input())

i = 0
bc = list("BC")

a_cnt = 0
res = 0
i = 0
while i <= len(s)-1:
  if s[i] == "A":
    a_cnt += 1
  elif s[i:i+2] == bc:
    res += a_cnt
    i += 1
  else:
    a_cnt = 0
  i += 1

print(res)

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

i = 0
abc = list("ABC")

def roop(n): #n:現在地
  if n >= len(s)-2:
    return 0
  elif s[n:n+3] == abc:
    s[n] = "B"
    s[n+1] = "C"
    s[n+2] = "A"
    if n == 0: return roop(n+2)+1 
    return roop(n-1)+1
    # return roop(n-1)+1
  else:
    return roop(n+1)


print(roop(0))
Problem p03135 (python)

Fixed submission:
t,x=map(int,input().split())
print(t/x)

Buggy submission (verdict: Runtime Error):
t,x=map(int,input())
print(t/x)
Problem p02847 (python)

Fixed submission:
days = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
S = input()
print(7 - days.index(S))

Buggy submission (verdict: Runtime Error):
days = ['SUN', 'MON', 'TUE', 'WED', 'THU',' FRI', 'SAT']
S = input()
print(7 - days.index(S))
Problem p02863 (python)

Fixed submission:
n, t = map(int, input().split())
dish = [list(map(int, input().split())) for _ in range(n)]
dish.sort(key=lambda x: x[0])
dp = [[0 for _ in range(3005)] for _ in range(3005)]

ans = 0
for i in range(n):
    for j in range(t):
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
        nj = j + dish[i][0]
        if nj < t:
            dp[i + 1][nj] = max(dp[i + 1][nj], dp[i][j] + dish[i][1])
    now = dp[i][t- 1] + dish[i][1]
    ans = max(ans, now)

print(ans)

Buggy submission (verdict: Runtime Error):
n, t = map(int, input().split())
dish = [list(map(int, input().split())) for _ in range(n)]
dish.sort(key=lambda x: x[0])
dp = [[0 for _ in range(3000)] for _ in range(3000)]
ans = 0

for i in range(n):
    for j in range(t):
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
        nj = j + dish[i][0]
        if nj < t:
            dp[i + 1][nj] = max(dp[i + 1][nj], dp[i][j] + dish[i][1])
    now = dp[i][t- 1] + dish[i][1]
    ans = max(ans, now)

print(ans)
Problem p02879 (python)

Fixed submission:
a, b = map(int, input().split())
if a < 10 and b < 10:
  print(a * b)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
def check():
  n = int(input())
  if n <= 9:
    return 'Yes'
  elif n > 81:
    return 'No'
  else:
    for i in range(2, 9):
      q, mod = divmod(n, i)
      if mod == 0 and q <= 9:
        return 'Yes'
    return 'No'

print(check())

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a < 10 and b < 10:
  print(a * b)
else:
  print(-1)
Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split())
broken_step = [0] * (N + 1)
for _ in range(M):
    n = int(input())
    broken_step[n] = 1

dp = [1] * (N + 1)
dp[1] = 0 if broken_step[1] == 1 else dp[0]

for i in range(2, N + 1):
    if broken_step[i] == 1:
        dp[i] = 0
    else:
        dp[i] = dp[i -1] + dp[i - 2]

print(dp[-1] % 1000000007)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
broken_step = [0] * N
for _ in range(M):
    n = int(input())
    broken_step[n - 1] = 1

dp = [0] * N

dp[0] = 0 if broken_step[0] == 1 else 1
dp[1] = 0 if broken_step[1] == 1 else (1 + dp[0])

for i in range(2, N):
    if broken_step[i] == 1:
        dp[i] = 0
    else:
        dp[i] = dp[i - 1] + dp[i - 2]

print(dp[-1] % 1000000007)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
bs = [int(input()) for _ in range(M)]
bi = 0
pattern = [-1] * N

if bi < M and 1 == bs[bi]:
    pattern[0] = 0
    bi += 1
else:
    pattern[0] = 1

if bi < M and 2 == bs[bi]:
    pattern[1] = 0
    bi += 1
else:
    pattern[1] = 1 + pattern[0]

for i in range(2, N):
    if bi < M and (i + 1) == bs[bi]:
        pattern[i] = 0
        bi += 1
    else:
        pattern[i] = pattern[i -1] + pattern[i - 2]

print(pattern[-1] % 1000000007)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
broken_steps = [int(input()) for _ in range(M)]
pattern = [-1] * N
pattern[0] = 0 if 1 in broken_steps else 1
pattern[1] = 0 if 2 in broken_steps else 1 + pattern[0]

for i in range(2, N):
    pattern[i] = 0 if (i + 1) in broken_steps else (pattern[i -2] + pattern[i - 1])

print(pattern[-1] % 1000000007)
Problem p03127 (python)

Fixed submission:
from fractions import gcd

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

ans = a[0]
for i in range(1, n):
    ans = gcd(ans, a[i])

print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd
n = int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, n):
    ans = gcd(ans, a[i])
print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

ans = a[0]
for i in range(1, n):
    ans = math.gcd(ans, a[i])

print(ans)
Problem p03221 (python)

Fixed submission:
n, m = map(int, input().split())
prefectures = [[] for _ in range(10 ** 5)]

for i in range(m):
    p, y = map(int, input().split())
    prefectures[p - 1].append([y, i])

ans = [''] * m
for p in range(10 ** 5):
    prefecture = prefectures[p]
    prefecture.sort(key=lambda x: x[0])
    for i in range(len(prefecture)):
        ans[prefecture[i][1]] = '{:006}{:006}'.format(p + 1, i + 1)

for i in range(m):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
prefectures = [[] for _ in range(10 ** 5)]

for i in range(m):
    p, y = map(int, input().split())
    prefectures[p].append([y, i])

ans = [''] * m
for p in range(10 ** 5):
    prefecture = prefectures[p]
    prefecture.sort(key=lambda x: x[0])
    for i in range(len(prefecture)):
        ans[prefecture[i][1]] = '{:006}{:006}'.format(p, i + 1)

for i in range(m):
    print(ans[i])
Problem p03774 (python)

Fixed submission:
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
cd = [list(map(int, input().split())) for _ in range(M)]
ans = []

for i in range(N):
    index = 0
    lowest = pow(10, 8) * 4
    for j in range(M):
        dist = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if lowest > dist:
            lowest = dist
            index = j
    print(index + 1)

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

ss = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]

INF = 10 ** 8 * 2
for s in ss:
    dist = INF
    c_point = 0
    a, b = s
    for i, v in enumerate(p):
        c, d = v
        manhattan = abs(a - c) + abs(b - d)
        if manhattan < dist:
            c_point = i + 1
            dist = manhattan
    print(c_point)
Problem p02701 (python)

Fixed submission:
n = int(input())
list = {}
for x in range(n):
	item = input()
	list[item] = x
print(len(list))

Buggy submission (verdict: Runtime Error):
n = int(input())
list = {}
for x in range(n):
	item = input()
	list[item] = x
print(len(lest))
Problem p02682 (python)

Fixed submission:
A,B,C,K = map(int, input().split())
ans =0
for c,i in enumerate([A,B, C]):
  K -= i
  if K>=0:
    if c ==0:
    	ans += i
    elif c == 2:
      	ans -= i
      
  else:
    if c ==0:
    	ans += K +i
    elif c == 2:
      	ans -= K+i
    break
    
  

print(ans)

Buggy submission (verdict: Runtime Error):
A,B,C,K = map(int, input().split())
L=[1]*A + [0]*B + [-1]*C

J = sum(L[:K])

print(J)
Problem p02726 (python)

Fixed submission:
N, R1, R2 = map(int, input().split())
n = R2 - R1 - 1
count={}
for m in range(N-1):
    count[m+1] = 0 
for i in range(N):
    for j in range(i+1, N):
        k = min(j-i, abs((R1-1)-i) + 1 +abs((R2-1)-j))
        count[k]+=1
for k in count.values():
    print(k)

Buggy submission (verdict: Runtime Error):
from collections import deque
N,R1,R2 = map(int, input().split())
graph = [deque([]) for _ in range(N-1)]
count={}
for i in range(N-1):
    count[i+1] = 0


for i in range(N-1):
    if i != R1-1:
        graph[i].append(i+1)
    else:
        graph[i].append(i+1)
        graph[i].append(R2-1)

def dfs(v, counter):
    global count
    gs=[]
    for g in graph[v]:
        count[counter]+=1
        gs.append(g)
    gsm = max(gs)
    if gsm < N-1:
        dfs(gsm, counter+1)
    else:
        return

for i in range(N-1):
    dfs(i, 1)