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

Fixed submission:
M = int(input())
sumd, sumc = 0, 0
for i in range(M):
    d, c = map(int, input().split())
    sumd += d * c
    sumc += c

tmp = sumd // 10
while tmp > 0:
    pre = sumd
    sumd += tmp
    tmp = sumd // 10 - pre // 10

ans = sumd // 10 + sumc - 1
print(ans)

Buggy submission (verdict: Runtime Error):
M = int(input())
sumd, sumc = 0, 0
for i in range(M):
    d, c = map(int, input().split())
    sumd += d * c
    sumc += c

for i in range(1, len(str(sumd))):
    tmp = sum // (10 ** i)
    sumd += tmp

ans = sumd // 10 + sumc - 1
print(ans)
Problem p02883 (python)

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

q = [0] * N
start = 0
end = 0
for i in range(N):
    q[i] = A[i] * F[i]
    end = max(end, q[i])

def check(now, K):
    cnt = 0
    for i in range(N):
        if q[i] - now > 0:
            cnt += (q[i] - now + F[i] - 1) // F[i]
            if cnt > K:
                return False
    return True

now = end // 2
while end > start + 1:
    if check(now, K):
        end = now
    else:
        start = now
    now = (start + end) // 2

if check(start, K):
    print(start)
else:
    print(end)

Buggy submission (verdict: Runtime Error):
import numpy as np
from numba import njit

@njit
def solve(A, F, K):
    lo = 0
    hi = 10 ** 12
    while lo < hi:
        mid = (lo + hi) // 2
        total_train = 0
        for i in range(A.shape[0]):
            need = A[i] - mid // F[i]
            total_train += need if need > 0 else 0
        if total_train <= K:
            hi = mid
        else:
            lo = mid + 1
    return lo

stdin = np.fromstring(open(0).read(), dtype=np.int64, sep=' ')
N, K = stdin[:2]
A = stdin[2: 2 + N]
F = stdin[2 + N:]
print(solve(np.sort(A)[::-1], np.sort(F), K))
Problem p03006 (python)

Fixed submission:
import collections
N = int(input())
xy = [[int(i) for i in input().split()] for _ in range(N)]

diff = []

for i in range(N):
    for j in range(N):
        if i == j:
            continue
        else:
            if xy[i][0] > xy[j][0]:
                diff.append((xy[i][0] - xy[j][0], xy[i][1] - xy[j][1]))
            elif xy[i][0] == xy[j][0] and xy[i][1] >= xy[j][1]:
                diff.append((xy[i][0] - xy[j][0], xy[i][1] - xy[j][1]))
            elif xy[i][0] == xy[j][0] and xy[i][1] < xy[j][1]:
                diff.append((xy[j][0] - xy[i][0], xy[j][1] - xy[i][1]))
            else:
                diff.append((xy[j][0] - xy[i][0], xy[j][1] - xy[i][1]))

if N == 1:
    ans = 1
else:
    c = collections.Counter(diff)
    ans = N - sorted(list(c.values()))[-1] // 2
print(ans)

Buggy submission (verdict: Runtime Error):
import collections
N = int(input())
xy = [[int(i) for i in input().split()] for _ in range(N)]

diff = []

for i in range(N):
    for j in range(N):
        if i == j:
            continue
        else:
            if xy[i][0] > xy[j][0]:
                diff.append((xy[i][0] - xy[j][0], xy[i][1] - xy[j][1]))
            elif xy[i][0] == xy[j][0] and xy[i][1] >= xy[j][1]:
                diff.append((xy[i][0] - xy[j][0], xy[i][1] - xy[j][1]))
            elif xy[i][0] == xy[j][0] and xy[i][1] < xy[j][1]:
                diff.append((xy[j][0] - xy[i][0], xy[j][1] - xy[i][1]))
            else:
                diff.append((xy[j][0] - xy[i][0], xy[j][1] - xy[i][1]))
c = collections.Counter(diff)
ans = N - sorted(list(c.values()))[-1] // 2
print(ans)
Problem p03014 (python)

Fixed submission:
import numpy as np
H, W = map(int, input().split())
S = np.array([list(input()) for _ in range(H)]) == '.'
us = np.zeros((H,W), dtype=int)    # .の連続数を格納用
ds = np.zeros((H,W), dtype=int)    # .の連続数を格納用
ls = np.zeros((H,W), dtype=int)    # .の連続数を格納用
rs = np.zeros((H,W), dtype=int)    # .の連続数を格納用

for h in range(1,H):
    us[h, :] = (us[h-1, :] + 1) * S[h-1, :]
for h in range(H-2, -1, -1):
    ds[h, :] = (ds[h+1, :] + 1) * S[h+1, :]
for w in range(1,W):
    ls[:, w] = (ls[:, w-1] + 1) * S[:, w-1]
for w in range(W-2, -1, -1):
    rs[:, w] = (rs[:, w+1] + 1) * S[:, w+1]

ans = ((us + ds + ls + rs)*S).max() + 1
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
H, W = map(int, input().split())
S = []
ij = np.zeros((H,W), dtype=int)    # .の連続数を格納用

for i in range(H):
    S.append(input())
    cnt = 0
    start = 0
    end = 0
    for j in range(W):
        if S[i][j] == '#':
            ij[i, start:end+1] += cnt
            cnt = 0
        elif j > 0 and S[i][j-1] == '#':    # .のstart
            start = j
            end = j
            cnt = 1
        else:
            end = j
            cnt += 1
        if j == W-1:    # 最後に書き込み
            ij[i, start:end+1] += cnt
            cnt = 0

for j in range(W):
    cnt = 0
    start = 0
    end = 0
    for i in range(H):
        if S[i][j] == '#':
            ij[start:end+1, j] += cnt
            cnt = 0
        elif i > 0 and S[i-1][j] == '#':    # .のstart
            start = i
            end = i
            cnt = 1
        else:
            end = i
            cnt += 1
        if i == H-1:    # 最後に書き込み
            ij[start:end+1, j] += cnt
            cnt = 0

ij = ij - 1  # 自分が2回足されるので、1引く
ans = ij.max()
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
H, W = map(int, input().split())
S = []
ij = np.zeros([H,W])    # .の連続数を格納用

for i in range(H):
    S.append(input())
    cnt = 0
    start = 0
    end = 0
    for j in range(W):
        if S[i][j] == '#':
            ij[i, start:end+1] += cnt
            cnt = 0
        elif j > 0 and S[i][j-1] == '#':    # .のstart
            start = j
            end = j
            cnt = 1
        else:
            end = j
            cnt += 1
        if j == W-1:    # 最後に書き込み
            ij[i, start:end+1] += cnt
            cnt = 0

for j in range(W):
    cnt = 0
    start = 0
    end = 0
    for i in range(H):
        if S[i][j] == '#':
            ij[start:end+1, j] += cnt
            cnt = 0
        elif i > 0 and S[i-1][j] == '#':    # .のstart
            start = i
            end = i
            cnt = 1
        else:
            end = i
            cnt += 1
        if i == H-1:    # 最後に書き込み
            ij[start:end+1, j] += cnt
            cnt = 0

ij = ij - 1  # 自分が2回足されるので、1引く
ans = int(ij.max())
print(ans)
Problem p03070 (python)

Fixed submission:
import math
import numpy as np
N = int(input())
a = np.array([int(input()) for _ in range(N)])
s = np.sum(a)
m = 998244353
dp1 = np.zeros((N+1, s+1), dtype=np.int64)
dp1[0, 0] = 1
dp2 = np.zeros((N+1, s//2+1), dtype=np.int64)
dp2[0, 0] = 1
for i, ai in enumerate(a):
    dp1[i+1, :]   += dp1[i, :] * 2 % m
    dp1[i+1, ai:] += dp1[i, :-ai]
    dp2[i+1, :]   += dp2[i, :] % m
    dp2[i+1, ai:] += dp2[i, :-ai]
subset1 = np.sum(dp1[N, math.ceil(s/2):])
subset2 = 0 if s % 2 == 1 else dp2[N, s//2]
print((3 ** N - 3 * subset1 + 3 * subset2) % m)

Buggy submission (verdict: Runtime Error):
import math
import numpy as np
N = int(input())
a = np.array([int(input()) for _ in range(N)])
s = np.sum(a)
m = 998244353
dp1 = np.zeros(N+1, s+1)
dp1[0,0] = 1
dp2 = np.zeros(N+1, s//2+1)
dp2[0,0] = 1
for i, ai in enumerate(a):
    dp1[i+1, :]   += dp1[i, :] * 2
    dp1[i+1, ai:] += dp1[i, :-ai]
    dp2[i+1, :]   += dp2[i, :]
    dp2[i+1, ai:] += dp2[i, :-ai]
subset1 = np.sum(dp1[N][math.ceil(s/2):])
subset2 = 0 if s % 2 == 1 else dp2[N][s/2]
print((3 ** N - 3 * subset1 + 3 * subset2) % m)
Problem p03074 (python)

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

l = [0]
curr = '1'
for c in S:
    if c != curr:
        l.append(1)
        curr = c
    else:
        l[-1] += 1
if curr == '0':
    l.append(0)

n_group = len(l) // 2
sum_ = 0
k = min(K, n_group)
sum_ = sum(l[0:2*k+1])
max_ = sum_
for i in range(k, n_group):
    sum_ -= l[2*i-2*K] + l[2*i+1-2*K]
    sum_ += l[2*i+1] + l[2*i+2]
    max_ = max(max_, sum_)
print(max_)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = input()
Nums = [0]
now = 1 # 今見ている数
cnt = 0 # nowがいくつ並んでいるか
for i in range(N):
    if s == str(now):
        cnt += 1
    else:
        Nums.append(cnt)
        now = 1 - now   # 0と1を切り替えるときの計算 now ^= 1
        cnt = 1
if cnt != 0:
    Nums.append(cnt)
# 1-0-1-0-1-0-1 って感じの配列が欲しい
# 1-0-1-0-1-0 みたいに0で終わっていたら適当に1つ足す
if len(Nums) % 2 == 0:
    Nums.append(0)

Add = 2 * K + 1
ans = 0
# 1-0-1... の1から始めるので、偶数番目だけ見る
for i in range(0, len(Nums), 2):
    tmp = 0
    left = i
    right = min(i + Add, len(Nums))
    for j in range(left, right):
        tmp += Nums[j]
    ans = max(tmp, ans)

print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = input()
l = [0]

for i in range(1, N):
    if S[i] != S[i-1]:
        l.append(i)
l.append(N)

mxcnt = 0
if len(l) <= 2*K+1:
    mxcnt = N
else:
    for i in range(len(l)-2*K):
        if S[i] == '0':
            x = l[i+2*K] - l[i]
            mxcnt = max(mxcnt, x)
        else:
            x = l[i+2*K+1] - l[i]
        mxcnt = max(mxcnt, x)

print(mxcnt)
Problem p03095 (python)

Fixed submission:
n = int(input())
s = input()
ans = 1
mod = 10**9 + 7
for x in set(s):
    ans *= s.count(x) + 1
    ans %= mod

print((ans - 1) % mod)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
csum = [1]

for i in range(1, n):
    if s[i] in s[:i]:
        csum.append(int(csum[-1] * 1.5 + 0.5))
    else:
        csum.append(csum[-1] * 2 + 1)

print(csum[-1])
Problem p03102 (python)

Fixed submission:
import numpy as np
N, M, C = map(int, input().split())
B = np.array(list(map(int, input().split())))
A = np.empty((N, M),dtype=int)
for n in range(N):
    A[n, :] = list(map(int, input().split()))
X = np.dot(A, B) + C
print(len(X[X>0]))

Buggy submission (verdict: Runtime Error):
import numpy as np
N, M, C = map(int, input().split())
B = np.array(list(map(int, input().split())))
A = np.empty((N, M),dtype=int)
for n in range(N):
    A[n, :] = list(map(int, input().split()))
X = np.matmul(A, B) + C
print(len(X[X>0]))
Problem p03157 (python)

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

H, W = map(int, input().split())
S = [input() for _ in range(H)]
check = [[0]*W for _ in range(H)]
di = [-1, 0, 1, 0]
dj = [ 0,-1, 0, 1]
black, white = 0, 0

def dfs(i, j):
    global check, black, white
    if check[i][j]:
        return
    else:
        check[i][j] = 1
    if S[i][j] == '#':
        black += 1
    else:
        white += 1
    for dir in range(4):
        ni = i + di[dir]
        nj = j + dj[dir]
        if ni < 0 or ni >= H or nj < 0 or nj >= W: continue
        if S[i][j] == S[ni][nj]: continue
        dfs(ni, nj)
    return

ans = 0
for i in range(H):
    for j in range(W):
        black, white = 0, 0
        dfs(i, j)
        ans += black * white

print(ans)

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

H, W = map(int, input().split())
S = [input() for _ in range(H)]
check = [[0]*W for _ in range(H)]
di = [-1, 0, 1, 0]
dj = [ 0,-1, 0, 1]

black, white = 0, 0

def dfs(i, j):
    global check, black, white
    if check[i][j]:
        return
    else:
        check[i][j] = 1
    if S[i][j] == '#':
        black += 1
    else:
        white += 1
    for dir in range(4):
        ni = i + di[dir]
        nj = j + dj[dir]
        if ni < 0 or ni >= H or nj < 0 or nj >= W: continue
        if S[i][j] == S[ni][nj]: continue
        dfs(ni, nj)

ans = 0
for i in range(H):
    for j in range(W):
        black, white = 0, 0
        dfs(i, j)
        ans += black * white

print(ans)
Problem p03210 (python)

Fixed submission:
X = int(input())

if X==3 or X==5 or X==7:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
if X == 3 or X == 5 or X == 7:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
if X = 3 or 5 or 7:
  print('YES')
else:
  print('NO')
Problem p03211 (python)

Fixed submission:
s = input()
m = 753
a = 999

for i in range(len(s)-2):
  #print(s[i:i+3])
  if abs(m - int(s[i:i+3])) < a:
    a = abs(m - int(s[i:i+3]))
print(a)

Buggy submission (verdict: Runtime Error):
s = string(input())
m = 753
a = 999

for i in range(len(s)-2):
  #print(s[i:i+3])
  if abs(m - int(s[i:i+3])) < a:
    a = abs(m - int(s[i:i+3]))
print(a)
Problem p03229 (python)

Fixed submission:
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

A.sort()

if N % 2 == 1:
    w = -2*sum(A[:N//2]) +A[N//2] +A[N//2 + 1] + 2*sum(A[N//2 + 2:])
    m = -2*sum(A[:N//2-1]) - A[N//2 - 1] - A[N//2] + 2*sum(A[N//2+1:])
    print(max(w, m))
else:
    print(-2*sum(A[:N//2-1]) - A[N//2-1] + A[N//2] + 2*sum(A[N//2+1:]))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

A.sort()
if N % 2 == 0:
    print((sum(A[N//2:]) - sum(A[:N//2]))*2 - (A[N//2+1] - A[N//2]))
else:
    print((sum(A[N//2+1:]) - sum(A[:N//2]))*2 - min(A[N//2+1] - A[N//2], A[N//2] - A[N//2-1]))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()
if N % 2 == 0:
    print((sum(A[N//2:]) - sum(A[:N//2]))*2 - (A[N//2+1] - A[N//2]))
else:
    print((sum(A[N//2+1:]) - sum(A[:N//2]))*2 - min(A[N//2+1] - A[N//2], A[N//2] - A[N//2-1]))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()
if N % 2 == 0:
    print((sum(A[N//2]) - sum(A[:N//2]))*2 - (A[N//2+1] - A[N//2]))
else:
    print((sum(A[N//2+1]) - sum(A[:N//2]))*2 - min(A[N//2+1] - A[N//2], A[N//2] - A[N//2-1]))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()
if N % 2 == 0:
    print((sum(A[N//2:N]) - sum(A[:N//2]))*2 - (A[N//2+1] - A[N//2]))
else:
    print((sum(A[N//2+1:N]) - sum(A[:N//2]))*2 - min(A[N//2+1] - A[N//2], A[N//2] - A[N//2-1]))
Problem p03244 (python)

Fixed submission:
import numpy as np
even = np.zeros(100001, dtype=int)
odd = np.zeros(100001, dtype=int)

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

for i in range(n):
    if i % 2 == 0:
        even[v[i]] += 1
    else:
        odd[v[i]] += 1

e1 = even.argmax()
e1n = even.max()
o1 = odd.argmax()
o1n = odd.max()

# print(e1, e1n, o1, o1n)
if e1 == o1:
    e2n = np.sort(even)[-2]
    o2n = np.sort(odd)[-2]
    # print(e2n, o2n)
    print(min(n - e1n - o2n, n - e2n - o1n))
else:
    print(n - e1n - o1n)

Buggy submission (verdict: Runtime Error):
import numpy as np
even = np.zeros(100000, dtype=int)
odd = np.zeros(100000, dtype=int)

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

for i in range(n):
    if i % 2 == 0:
        even[v[i]] += 1
    else:
        odd[v[i]] += 1

e1 = even.argmax()
e1n = even.max()
o1 = odd.argmax()
o1n = odd.max()

# print(e1, e1n, o1, o1n)
if e1 == o1:
    e2n = np.sort(even)[-2]
    o2n = np.sort(odd)[-2]
    # print(e2n, o2n)
    print(min(n - e1n - o2n, n - e2n - o1n))
else:
    print(n - e1n - o1n)
Problem p03523 (python)

Fixed submission:
import re
s = input()
if re.match('A?KIHA?BA?RA?$', s):
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
s = input()
t = 'AKIHABARA'
i, j = 0, 0
ans = 'YES'
while j < len(t):
    if i == len(s) and t[j] == 'A':
        j += 1
    elif s[i] == t[j]:
        i += 1
        j += 1
    elif t[j] == 'A':
        j += 1
    else:
        ans = 'NO'
        break
print(ans)
Problem p03150 (python)

Fixed submission:
S = input()
keyence = 'keyence'
n = False
for i in range(len(S) + 1):
    for j in range(i, len(S) + 1):
        rest_str = S[:i] + S[j:]
        if rest_str == keyence:
            n = True
            break
    if n:
        break
if n:
	print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
S = input()
n = False
for i in range(len(S) + 1):
    for j in range(i, len(S) + 1):
        rest_str = S[:i] + S[j:]
        if rest_str == keyence:
            n = True
            break
    if n:
        break
if n:
	print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
S = input()
 
keyence = "keyence"
 
isKey = False
for i in range(len(S) + 1):
    for j in range(i, len(S) + 1):
        rest_str = S[:i] + S[j:]
        if rest_str == keyence:
            isKey = True
            break
if isKey:
  pirnt('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
k = input()
n = 'keyence'
for i in range(len(k)):
    if k[i] == 'k':
        z = 0
        for j in range(len(n)):
            if k[i+j] != n[j]:
                z = 1
                for p in range(i+j, len(k)):
                    
                    if n[j:] in k[p:]:
                        print('YES')
                        break
                    else:
                        z = 2
                        break
                
            break
            
    if i == len(k):
        z = 2
    

if z == 0:
    print('YES')
elif z == 2:
    print('NO')

Buggy submission (verdict: Runtime Error):
k = input()
n = 'keyence'
for i in range(len(k)):
    if k[i] == 'k':
        z = 0
        for j in range(len(n)):
            if k[i+j] != n[j]:
                z = 1
                for p in range(i+j, len(k)):
                    
                    if n[j:] in k[p:]:
                        break
                        break
                    else:
                        z = 2
                        break
            break
            
    if i == len(k):
        z = 2
    

if z == 0 or z == 1:
    print('YES')
else:
    print('NO')
Problem p03260 (python)

Fixed submission:
A, B = map(int, input().split())
x = A * B
if x % 2 == 0:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [input() for i in range(N)]
 
for num in range(N):
  if a[num] in a[:num-1]:
    print('No')
    break
  if num < N-1:
    if a[num][-1] != a[num+1][0]:
    	print('No')
    	break
  if num == N-1:
    print('Yes')

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [input() for i in range(N)]
 
for num in range(N):
  if a[num] in a[:num-1]:
    print('No')
    break
  if num < N-1:
    if a[num][-1] != a[num+1][0]:
    	print('No')
    	break
  print('Yes')

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [input() for i in range(N)]
 
for num in range(N):
  if a[num] in a[:num]:
    print('No')
    break
  if num < N-1:
    if a[num][-1] != a[num+1][0]:
    	print('No')
    	break
  print('Yes')

Buggy submission (verdict: Runtime Error):
A, B = map(int, raw_input().split())
x = A * B
if x % 2 == 0:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
A, B = map(int, raw_input().split(' '))

if (A * B) % 2 == 0:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
A, B = map(int, raw_input().split())

if (A * B) % 2 == 0:
    print('No')
else:
    print('Yes')
Problem p03261 (python)

Fixed submission:
N = int(input())
a = [input() for i in range(N)]
 
for num in range(N):
  if num > 0:
    if a[num] in a[:num-1]:
    	print('No')
    	break
  if num < N-1:
    if a[num][-1] != a[num+1][0]:
    	print('No')
    	break
  if num == N-1:
    print('Yes')

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [input() for i in range(N)]

for num in range(1, N+1):
  if a[num][-1] != a[num+1][0]:
    print('No')
    break
  if a[num] in a:
    print('No')
    break
  print('Yes')

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [input() for i in range(N)]

for num in range(1, N):
  if a[num][-1] != a[num+1][0]:
    print('No')
    break
  if a[num] in a:
    print('No')
    break
  print('Yes')
Problem p03264 (python)

Fixed submission:
x = int(input())
y = x // 2
print(y*(x-y))

Buggy submission (verdict: Runtime Error):
k=input()
x=k//2
if k%2==0:
  print(2*x*x)
else:
  print((2*x+1)*x)
Problem p02548 (python)

Fixed submission:
import math

case_num = 0

N = int(input())

for num in range(N - 1):
  num += 1
  
  case_num += ( math.ceil(N / num) - 1 )


print(case_num)

Buggy submission (verdict: Runtime Error):
case_num = 0

N = int(input())

for num in range(N - 1):
  num += 1
  
  case_num += ( math.ceil(N / num) - 1 )


print(case_num)

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

case_num += N / 2
half_num = case_num

for num in range(half_num - 1):
  num += 1
  
  case_num += ( math.ceil(N / num) - 1 )


print(case_num)
Problem p02628 (python)

Fixed submission:
N, K = map(int, input().split())
price = list(map(int, input().split()))
price.sort()
print(sum(price[:K]))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
price = [int(input()) for _ in range(N)]
price.sort()
print(sum(price[:3]))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
price = [input() for _ in range(N)]
price.sort()
print(sum(price[:3]))
Problem p02641 (python)

Fixed submission:
X, N = map(int, input().split())
if N == 0:
  print(X)
  exit()
p = list(map(int, input().split()))

max_num = max(p)
lst = []
for i in range(max_num+2):
  if i not in p:
    lst.append(i)
tmp = float("inf")
for j in lst:
  if tmp > abs(X-j):
    tmp = abs(X-j)
    ans = j
print(ans)

Buggy submission (verdict: Runtime Error):
X, N = map(int, input().split())
p = list(map(int, input().split()))

max_num = max(p)
lst = []
for i in range(max_num+2):
  if i not in p:
    lst.append(i)
tmp = float("inf")
for j in lst:
  if tmp > abs(X-j):
    tmp = abs(X-j)
    ans = j
print(ans)
Problem p02553 (python)

Fixed submission:
a, b, c, d = map(int, input().split())
print(max(a*c, a*d, b*c, b*d))

Buggy submission (verdict: Runtime Error):
-1000000000 0 -1000000000 0
Problem p02612 (python)

Fixed submission:
n = int(input())%1000
if n:
    print(1000-n)
else:
    print(n)

Buggy submission (verdict: Runtime Error):
print(int(input()[1:]))
Problem p02761 (python)

Fixed submission:
n, m = map(int, input().split())
x = [list(map(int, input().split())) for i in range(m)]
count = 0
for i in range(1000):
    count = 0
    i = str(i)
    if len(i) == n:
        for s, c in x:
            if i[s-1] == str(c):
                count += 1
            else:
                break
        if count == m:
            print(i)
            exit()
print(-1)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
ans = list("000")
x = [list(map(int, input().split())) for i in range(m)]
x = list(map(list, set(map(tuple, x))))
for s, c in x:
    if ans[s-1] == "0":
        ans[s-1] = str(c)
    else:
        print("-1")
        exit()

if n == 1:
    ans = int(ans[2:])
    for i in range(10):
        if i == ans:
            print(i)
            exit() 

if n == 2:
    ans = int(ans[1:])
    for i in range(10, 100):
        if i == ans:
            print(i)
            exit() 

if n == 3:
    ans = int(ans[0:])
    for i in range(100, 1000):
        if i == ans:
            print(i)
            exit()
Problem p02802 (python)

Fixed submission:
n, m = map(int, input().split())
wa = [0]*(10**5)
ac = [0]*(10**5)
WA = 0
for i in range(m):
    p, s = input().split()
    P = int(p)
    if ac[P] != 1:
        if s == "WA":
            wa[P] += 1
        else:
            ac[P] += 1
            WA += wa[P]
print(sum(ac), WA)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
l = [list(input().split()) for i in range(m)]
wa = [0]*(10**5)
ac = [0]*(10**5)
WA = 0
for i in range(m):
    p, s = input().split()
    P = int(p)
    if ac[P] != 1:
        if s == "WA":
            wa[P] += 1
        else:
            ac[P] += 1
            WA += wa[P]
print(sum(ac), WA)
Problem p02841 (python)

Fixed submission:
m1, d2 = map(int, input().split())
m2, d2 = map(int, input().split())

if m2 - m1 == 1:
    print(1)

if m2 - m1 == 0:
    print(0)

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

for i in range(1, n+1):
    if 100*i <= n <= 105*i:
        print(1)
        exit()

print(0)