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

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

ans = 0
for i in range(2 ** 3):
    lst = [0] * N
    for j in range(3):
        if (i >> j) & 1:
            for k in range(N):
                lst[k] += xyz[k][j]
        else:
            for k in range(N):
                lst[k] -= xyz[k][j]
    lst.sort(reverse = True)
    ans = max(ans, sum(lst[:M]))

print (ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
xyz = [list(map(int, input().split())) for _ in range(N)]

dp = [[[0, 0, 0] for _ in range(M + 1)] for _ in range(N + 1)]
# for i in dp:
#     print (i)


def calc(i, j): #残りのi個からj個選ぶ
    if j == 0: #選び終わった時
        # print ('A', i, j)
        return [0, 0, 0]
    if dp[i][j] != [0, 0, 0]: #初期状態出でない時
        # print ('B', i, j)
        return dp[i][j]
    if i == j: #残りからすべて選ばないと行けない時
        tmp = calc(i - 1, j - 1)
        dp[i][j] = [tmp[0] + xyz[N - i][0], tmp[1] + xyz[N - i][1], tmp[2] + xyz[N - i][2]]
        # print ('C', i, j)
        return dp[i][j]
    if i > j: #選ぶ余地がある時
        #使わない時
        dp[i][j] = calc(i - 1, j)
        #使う時
        tmp = calc(i - 1, j - 1)
        tmp = [tmp[0] + xyz[N - i][0], tmp[1] + xyz[N - i][1], tmp[2] + xyz[N - i][2]]
        if (abs(dp[i][j][0]) + abs(dp[i][j][1]) + abs(dp[i][j][2])) < (abs(tmp[0]) + abs(tmp[1]) + abs(tmp[2])): #使わない方が良い時
            dp[i][j] = tmp
        # print ('D',i, j)
        return dp[i][j]

ans = calc(N, M)
# print (dp)
# print (ans)
print (abs(ans[0]) + abs(ans[1]) + abs(ans[2]))
Problem p03329 (python)

Fixed submission:
#DP　動的計画法

N = int(input())

INF = 10 ** 9
dp = [INF] * (N+1) #初期化配列

dp[0] = 0
for n in range(1, N+1):
    power = 1
    while power <= N:
        dp[n] = min(dp[n], dp[n-power]+1)
        power *= 6
    power = 1
    while power <= N:
        dp[n] = min(dp[n], dp[n-power]+1)
        power *= 9

#print (dp)
print (dp[N])

Buggy submission (verdict: Runtime Error):
#反例　459 = 216 * 1 + 81 * 3
N = int(input())

count = 0

flag = True
a = N
while flag:
    if a//6 != 0:
        count += 1
        a = a//6
    else:
        flag = not flag

lst = []
for i in range(count+1):
    if (6 ** i)<= N:
        lst += [6 ** i]
        if   (9 ** i)<=N:
            lst += [9 ** i]

lst.sort(reverse = True)
#print (lst)

def hikidashi(j, n): #j番目より小さい数でnまで引き出すときの最小
    if j == len(lst):
        return n #残りをすべて1で埋める場合
    elif lst[j] > n: #引き出したい数 > 残額の時
        return hikidashi(j+1, n)
    else:
        a = hikidashi(j+1, n) #使わずに次の番目に行く
        b = hikidashi(j, n-lst[j]) + 1 #一つ使う
        return min (a, b)

print (hikidashi(0, N))
Problem p03332 (python)

Fixed submission:
import numpy as np
MOD = 998244353

class Factorial:
    def __init__(self, n, mod):
        self.f = [1]
        self.mod = mod
        for j in range(1, n + 1):
            self.f.append(self.f[-1] * j % mod)
        self.i = [pow(self.f[-1], mod - 2, mod)]
        for j in range(n, 0, -1):
            self.i.append(self.i[-1] * j % mod)
        self.i.reverse()
    def factorial(self, j):
        return self.f[j]
    def ifactorial(self, j):
        return self.i[j]
    def comb(self, n, k):
        return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod if n >= k else 0

def gcd(a, b):
    if a > b:
        a, b = b, a
    if b % a == 0:
        return a
    return gcd(b % a, a)

N, A, B, K = map(int, input().split())

if A < B:
    A, B = B, A

# n = 2 * min(K // A + 2, N + 1) + 3
n = min((K + A - 1) // A, N) + 1
lcm = A * B // gcd(A, B)
step = lcm // A

c = Factorial(N + 1, MOD).comb #O(N)

def calc(a, b):
    if a > b:
        a, b = b, a #必ずaのほうが小さくなる
    return (c(N, a) * c(N, b)) % MOD


def count(a, b):
    if a <= N and b <= N:
        return calc(a, b)
    return 0

def maike_satrt(step):
    for i in range(step):
        if (K - A * i) % B == 0:
            return i

start = maike_satrt(step)
# print (start, n)
ans = 0
for a in range(start, n, step): #Aの数
    if A * a > K:
        break
    # if (K - A * a) % B != 0:
    #     continue
    b = (K - A * a) // B
    # print ('a=', a, 'b=', b)
    ans += count(a, b)
    ans %= MOD

print (ans)

Buggy submission (verdict: Runtime Error):
class Factorial:
    def __init__(self, n, mod):
        self.f = [1]
        self.mod = mod
        for j in range(1, n + 1):
            self.f.append(self.f[-1] * j % mod)
        self.i = [pow(self.f[-1], mod - 2, mod)]
        for j in range(n, 0, -1):
            self.i.append(self.i[-1] * j % mod)
        self.i.reverse()
    def factorial(self, j):
        return self.f[j]
    def ifactorial(self, j):
        return self.i[j]
    def comb(self, n, k):
        return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod if n >= k else 0


N, A, B, K = map(int, input().split())
MOD = 998244353

c = Factorial(N + 1, MOD).comb

def calc(a, b):
    return (c(N, a) * c(N, b)) % MOD

ans = 0
for a in range(N + 1):
    b = (K - (A * a)) // B
    if A * a + B * b == K and b <= N:
        ans += calc(a, b)
        ans %= MOD

print (ans)
Problem p03426 (python)

Fixed submission:
H, W, D = map(int, input().split())

#盤面を取得
lst = [0] * (H * W + 1)
for i in range(1, H + 1):
    tmp = list(map(int, input().split()))
    for j in range(1, W + 1):
        lst[tmp[j - 1]] = [i, j]
#前処理

#xからyに移動するのにかかるコストを返す関数
def cost(x, y): 
    return abs(lst[x][0] - lst[y][0]) + abs(lst[x][1] - lst[y][1])

check_lst = [False] * (H * W + 1)
cost_lst = [0] * (H * W + 1)
for i in range(1, H * W + 1):
    if check_lst[i]:
        continue
    check_lst[i]  = True
    tmp = i
    while tmp + D <= H * W:
        cost_lst[tmp + D] = cost_lst[tmp] + cost(tmp, tmp + D)
        check_lst[tmp + D] = True
        tmp += D

#出力
Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    print (cost_lst[R] - cost_lst[L])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

from collections import defaultdict

H, W, D = map(int, input().split())
A = [list(map(int, input().split()))  for _ in range(H)]

dic = defaultdict(list)

for h in range(W):
    for w in range(W):
        dic[A[h][w]] = [h, w]

def calc(l, r):
    return abs(dic[l][0] - dic[r][0]) + abs(dic[l][1] - dic[r][1])

lst = [0] * (H * W + 1)
for d in range(1, D + 1):
    tmp = d
    while tmp + D <= (H * W):
        lst[tmp + D] = lst[tmp] + calc(tmp, tmp + D)
        tmp += D

# print (lst)
Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    ans = lst[R] - lst[L]
    print (ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

from collections import defaultdict

H, W, D = map(int, input().split())
A = [list(map(int, input().split()))  for _ in range(H)]

dic = defaultdict(list)

for h in range(W):
    for w in range(W):
        dic[A[h][w]] = [h, w]

def calc(l, r):
    return abs(dic[l][0] - dic[r][0]) + abs(dic[l][1] - dic[r][1])

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    ans = 0
    while L != R:
        ans += calc(L, L + D)
        L += D
    print (ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

from collections import defaultdict

H, W, D = map(int, input().split())
A = [list(map(int, input().split()))  for _ in range(H)]

dic = defaultdict(list)

for h in range(W):
    for w in range(W):
        dic[A[h][w]] = [h, w]

def calc(l, r):
    return abs(dic[l][0] - dic[r][0]) + abs(dic[l][1] - dic[r][1])

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    ans = 0
    while L != R:
        ans += calc(L, L + D)
        L += D
    print (ans)
Problem p03834 (python)

Fixed submission:
S = input().split(',')
print (S[0]+' '+S[1]+' '+S[2])

Buggy submission (verdict: Runtime Error):
K, S = map(int, input().split())

count = 0
for x in range(0,K):
    for y in range(0,K):
        a = S-x-y
        if a <= K and a>= 0:
            count += 1
print (count)
Problem p03013 (python)

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

mod = 10**9 + 7
dp = [0] * (n + 3)
dp[0] = 1
if 1 not in a:
    dp[1] = 1
if 2 not in a:
    dp[2] = dp[0] + dp[1]
for i in range(3, n + 1):
    if i not in a:
        dp[i] = (dp[i - 1] + dp[i - 2]) % mod
print(dp[n] % mod)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
a = set([int(input()) for i in range(m)])

mod = 10**9 + 7
dp = [0] * (n+1)
dp[0] = 1
if 1 not in a:
    dp[1] = 1
if 2 not in a:
    dp[2] = dp[0] + dp[1]
for i in range(3, n+1):
    if i not in a:
        dp[i] = (dp[i-1] + dp[i-2]) % mod
print(dp[n] % mod)
Problem p03041 (python)

Fixed submission:
n, k = map(int, input().split())
s = input()
upper = {
    'A': 'a',
    'B': 'b',
    'C': 'c',
}
print(s[:k-1] + upper[s[k-1]] + s[k:])

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = input()
upper = {
    'A': 'a',
    'B': 'b',
    'C': 'c',
}
print(s[:k] + upper[s[k]] + s[k+1:])
Problem p03075 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if e-a <= k:
    print('Yay!')
else:
    print(':(')

Buggy submission (verdict: Runtime Error):
v=[int(input()) for_ in range(6)]
print('Yay!' if v[4]-v[0]<=v[5] else ':(')

Buggy submission (verdict: Runtime Error):
v=[int(input()) for_ in range(6)]
print('Yay!' if all([v[i+1]-v[i]<=v[5] for i in range(4)]) else ':(')

Buggy submission (verdict: Runtime Error):
v=[int(input()) for_ in range(6)]
print('Yay!' if all([abs(v[i]-v[i+1])<=v[5] for i in range(4)) else ':(')
Problem p03250 (python)

Fixed submission:
a,b,c = sorted(list(map(int, input().split())))
print(c*10+b+a)

Buggy submission (verdict: Runtime Error):
a,b,c = *sorted(list(map(int, input().split())))
print(a*10+b+c)
Problem p03329 (python)

Fixed submission:
n = int(input())

min_cnt = float('inf')
for i in range(0, n+1, 9):
    cnt = 0
    t = i
    while t >= 9:
        cnt += t % 9
        t //= 9
    cnt += t

    t = (n-i)
    while t >= 1:
        cnt += t % 6
        t //= 6
    cnt += t

    if cnt < min_cnt:
        min_cnt = cnt
print(min_cnt)

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

min_cnt = float('inf')
for i in range(n//6+1):
  cnt = 0
  t = i
  while t>6:
	cnt += t%6
  	t //= 6
  cnt += t
  
  for j in range((n-6*i)//9+1):
    t = j
    while t>9:
      cnt += t%9
      t //= 9
    cnt += t
    cnt += (n-6*i-9*j)
    if cnt < min_cnt:
      min_cnt = cnt
print(min_cnt)
Problem p03073 (python)

Fixed submission:
import sys, math
input = sys.stdin.readline

S = list(input().replace('\n',''))
S = list(map(int, S))
prev = S[0]
ans = 0
for i in range(1, len(S)):
  cur = S[i]
  if prev ^ cur == 0:
    ans += 1
#     if i == 1:
#       if cur ^ S[i+1] == 1:
#         prev = cur
#       else:
#         prev = 2 + ~cur
#     else:
    prev = 2 + ~cur
  else:
    prev = cur

print(ans)

Buggy submission (verdict: Runtime Error):
import sys, math
input = sys.stdin.readline

S = list(input().replace('\n',''))
S = map(int, S)
prev = S[0]
ans = 0
for i in range(1, len(S)-1):
  cur = S[i]
  if prev ^ cur == 0:
    ans += 1
    prev = 2 + ~cur
  else:
    prev = cur

print(ans)
Problem p02695 (python)

Fixed submission:
import itertools

N, M, Q = [int(i) for i in input().split()]
ABCD = [list(map(int, input().split())) for i in range(Q)]
score = 0
for A in itertools.combinations_with_replacement(range(1, M+1), N):
    tmp = 0
    for a, b, c, d in ABCD:
        if A[b-1] - A[a-1] == c:
            tmp += d
    score = max(score, tmp)
print(score)

Buggy submission (verdict: Runtime Error):
import itertools

N, M, Q = [int(i) for i in input().split()]
pos_A = sorted([i for i in range(1, M+1)] * N)
comb_A = list(itertools.combinations(pos_A, N))

for i in range(Q):
    a, b, c, d  = [int(i) for i in input().split()]
    for j, k in enumerate(comb_A):
        if k[b-1] - k[a-1] == c:
            score[j] += d
print(max(score))
Problem p02754 (python)

Fixed submission:
a,b,c = map(int,(input().split()))
d = (a//(b+c))*b + min((a%(b+c)),b)
print(d)

Buggy submission (verdict: Runtime Error):
from collections import Counter
a,b,c = map(int,input().split())
d = ""
e = ("1"*b + "0"*c)*a
f = e[:a]
g = Counter(f)
print(g["1"])

Buggy submission (verdict: Runtime Error):
from collections import Counter
a,b,c = map(int,input().split())
d = ""
e = ("1"*b + "0"*c)*a
f = d[:a]
g = Counter(f)
print(g["1"])

Buggy submission (verdict: Runtime Error):
from collections import Counter
a,b,c = map(int,input().split())
d = ""
for i in range(a):
    e = "1"*b + "0"*c
    d += e
f = d[:a]
g = Counter(f)
print(g["1"])
Problem p02759 (python)

Fixed submission:
a = int(input())
print((a+1)//2)

Buggy submission (verdict: Runtime Error):
a = iint(input())
print(a/2 if a % 2 == 1 else a//2+1)
Problem p02779 (python)

Fixed submission:
m = int(input())
n = list(map(int,input().split()))
print("YES" if len(set(n)) == m else "NO")

Buggy submission (verdict: Runtime Error):
m = int(input())
n = list(map(int,input().split))
print("YES" if len(set(n)) == m else "NO")
Problem p02832 (python)

Fixed submission:
a = int(input())
b = list(map(int,input().split()))
c = 1
ans = 0
for i in b:
    if i == c:
        c += 1
    else:
        ans += 1
if ans == a:
    ans = -1
print(ans)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = list(map(int,input().split()))
c = 1
ans = 0
for i in range b:
    if i == c:
        c += 1
    else:
        ans += 1
if ans == a:
    ans = -1
print(ans)
Problem p02860 (python)

Fixed submission:
#a,b,c = map(int,input().split())
a = int(input())
b = input()
c = b[:a//2]
d = b[a//2:a]
print("Yes" if c == d else "No")

Buggy submission (verdict: Runtime Error):
n = ont(input())
for i in range(2,n):
    if n % i == o:
        print("No")
        exit()
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
#a,b,c = map(int,input().split())
a = int(input())
b = input()
c = s[:a//2]
d = s[a//2:a]
print("No" if c == d else "Yes")

Buggy submission (verdict: Runtime Error):
#a,b,c = map(int,input().split())
a = int(input())
b = input()
c = s[:a//2]
d = s[a//2:a]
print("No" if c = d else "Yes")
Problem p02595 (python)

Fixed submission:
n,d = map(int,input().split())
ans = 0
import numpy as np
for i in range(n):
  x,y = map(int,input().split())
  if np.linalg.norm(np.array([x,y]),ord=2) <= d:
    ans+=1
    
print(ans)

Buggy submission (verdict: Runtime Error):
n,d = map(int,input().split())
ans = 0
import numpy as np
for i in range(n):
  x,y = map(int,input().split())
  if np.norm(np.array([x,y]),ord=2) <= d:
    ans+=1
    
print(ans)
Problem p02627 (python)

Fixed submission:
a = input()
if a.isupper():
  print('A')
else:
  print('a')

Buggy submission (verdict: Runtime Error):
a = input()
if a.isupper():
  print('A')
elif:
  print('a')
Problem p03072 (python)

Fixed submission:
n = int(input())
h=list(map(int,input().split()))
ans=0
for i in range(n):
  flag = True
  for j in range(i):
    if h[i]<h[j]:
      flag = False
      break
  if(flag):
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
h=[int(input())for i in range(n)]
ans=0
for i in range(n):
  flag = True
  for j in range(i):
    if h[i]<h[j]:
      flag = False
      break
  if(flag):
    ans+=1
print(ans)
Problem p03803 (python)

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

if a == b:
  print("Draw")
elif a == 1:
  print("Alice")
elif b == 1:
  print("Bob")
elif a < b:
  print("Bob")
else:
  print("Alice")

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

if a == 1:
  print("Alice")
elif b == 1:
  print("Bob")
elif a < b:
  print("Bob")
else:
  print("Alice")
Problem p03834 (python)

Fixed submission:
s = input()
for i in s:
  if i == ',':
    i = ' '
  print(i,end="")

print()

Buggy submission (verdict: Runtime Error):
s = input()
for i in s:
  if i == ',':
    i = ' ':
print(s)
Problem p02771 (python)

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

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

Buggy submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
s = set(a, b, c)
if len(s) == 2:
  print("Yes")
else:
  print("No")
Problem p02729 (python)

Fixed submission:
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(abs(n - r)) * math.factorial(r))

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

print(combinations_count(N, 2) + combinations_count(M, 2))

Buggy submission (verdict: Runtime Error):
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

print(combinations_count(N, 2) + combinations_count(M, 2))

Buggy submission (verdict: Runtime Error):
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

print(combinations_count(N, 2) + combinations_count(M, 2))
Problem p02860 (python)

Fixed submission:
N = int(input())
S = input()
if N % 2 != 0:
    print('No')
else:
    if S[N // 2:] == S[:N // 2]:
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
 = int(input())
S = input()
if N % 2 != 0:
    print('No')
else:
    if S[N // 2:] == S[:N // 2]:
        print('Yes')
    else:
        print('No')
Problem p03252 (python)

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

used = []
res  = []

for i in range(len(S)):
    if S[i] not in used:
        used.append(S[i])
    res.append(used.index(S[i]))

#print(used)
#print(res)
used = []
ret = []

for i in range(len(T)):
    if T[i] not in used:
        used.append(T[i])
    ret.append(used.index(T[i]))

if res == ret:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
cnt = []
ans = 1
fis1 = [index for index, word in enumerate(S) if S[i] == S[0]]
fis2 = [index for index, word in enumerate(T) if T[i] == T[0]]

if fis1 != fis2:
    ans = 0
else:
    for i in range(len(S)):
        if i not in fis1:
            kensa1 = [index for index, word in enumerate(S) if S[i] == word]
            kensa2 = [index for index, word in enumerate(T) if T[i] == word]
            if kensa1 != kensa2:
                ans = 0
                break
            else:
                fis1.append(kensa1)
    
print('Yes' if ans == 1 else 'No')
Problem p03317 (python)

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

if (N-1)%(K-1) ==0:
    print((N-1)//(K-1))
else:
    print((N-1)//(K-1)+1)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
min_in = A.index(1)

left = len(A[0:min_in])

right = len(A[min_in+1:])
#print(left,  right)
if N ==K:
    ans = 1
    
else:
    if (min(left, right) + 1) < K:
        ans += 1
        tuyoi = len(A-K)
        
        ans += tuyoi//K
        
        if tuyoi % K !=0:
            ans +=1
    
    else:
        if left != 0:
            ans += left//(K-1)
            
            if left%(K-1) != 0:
                ans += 1
        
        if right != 0:
            ans += right//(K-1)
            
            if right%(K-1) != 0:
                ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
min_in = A.index(1)

left = len(A[0:min_in])

right = len(A[min_in+1:])

if N ==K:
    ans = 0
    
else:
    if (min(left, right) + 1) < K:
        ans += 1
        tuyoi = len(A-K)
        
        ans += tuyoi//K
        
        if tuyoi % K !=0:
            ans +=1
    
    else:
        if left != 0:
            ans += left//(K-1)
            
            if left%(K-1) != 0:
                ans += 1
        
        if right != 0:
            ans += right//(K-1)
            
            if right%(K-1) != 0:
                ans += 1
print(ans)
Problem p03774 (python)

Fixed submission:
N, M =map(int, input().split())
a, b = [0]*N, [0]*N
c, d = [0]*M, [0]*M
ans = []
for i in range(N):
    a[i], b[i] = map(int, input().split())
for i in range(M):
    c[i], d[i] = map(int, input().split())
    

for i in range(N):
    length = 10**9
    ind = 0
    for j in range(M):
        man =  abs(a[i] - c[j])+abs(b[i] - d[j])
        if length > man:
            length = man
            ind = j+1
    ans.append(ind)

for i in ans:
    print(i)

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

for i in range(N):
    length = 10**9
    ind = 0
    for j in range(M):
        man =  abs(a[i] - c[j])+abs(b[i] - d[j])
        if length > man:
            length = man
            ind = j+1
    ans.append(ind)

for i in ans:
    print(i)
Problem p03834 (python)

Fixed submission:
print(input().replace(',',' '))

Buggy submission (verdict: Runtime Error):
k,s=map(int,input().split())
c=0
for i in range(k+1):
    for j in range(k+1):
        if s>=i+j and s-(i+j)<=k:
            c+=1
print(c)
Problem p02578 (python)

Fixed submission:
def main():
    n = int(input())
    A = list(map(int, input().split()))

    tallest = A[0]
    cnt = 0

    for height in A:
        if tallest > height:
            cnt += tallest - height
        else:
            tallest = height

    print(cnt)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)

n = int(input())
A = list(map(int, input().split()))
count = 0


def func(a, cnt=0):
    global count
    for i in range(len(a)-1):
        if a[i] > a[i+1]:
            a[i+1] += 1
            cnt += 1
            count = max(cnt, count)
            func(a, cnt)
        else:
            continue
    return count


COUNT = func(A)
print(COUNT)
Problem p02627 (python)

Fixed submission:
aa = input()

alpha = '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'
alpha.split(',')

print('a' if aa in alpha else 'A')

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
q = int(input())
x = [0] * 100001
ans = sum(a)

for ai in a:
    x[ai] += 1  # xのなかでaiが登場する個数のカウント

for _ in range(q):
    b, c = map(int, input().split())
    ans += (c-b) * x[b]
    x[c] += x[b]  # bをcに入れ替えた個数だけcが増加する
    x[b] = 0
    print(ans)

# for i in range(q):
#     count = 0
#     b, c = map(int, input().split())
#
#     for j in a:
#         if j == b:
#             a[count] = c
#         count += 1
#     a_list = [_ for _ in a]
#     ans.append(a_list)
#
# for answer in ans:
#     print(sum(answer))
Problem p02682 (python)

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

if k <= a:
    print(k)
elif a < k <= a+b:
    print(a)
elif a+b < k:
    print(a - (k-a-b))

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

ans = []

a_list = list(range(a + 1))
b_list = list(range(b + 1))

for l in a_list:
    for m in b_list:
        ans.append(l - (k - l - m))

print(max(ans))