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

Fixed submission:
a = int(input())
b = int(input())

if a + b == 3:
    print(3)
elif a + b == 4:
    print(2)
else:
    print(1)

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

if a + b = 3:
    print(3)
elif a + b = 4:
    print(2)
else:
    print(1)
Problem p03107 (python)

Fixed submission:
s=input()
print(2*min(s.count("0"), s.count("1")))

Buggy submission (verdict: Runtime Error):
s=input()
ans=0
num=0
while num<len(s)-1:
    if s[num]!=s[num+1]:
        s=s[:num]+s[num+2:]
        num-=1
        ans+=2
    else:
        num+=1
print(ans)
Problem p02792 (python)

Fixed submission:
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

from collections import defaultdict

n = ni()

def f(x):
    a = x % 10
    b = 0
    while x:
        b = x
        x //= 10
    return (a, b)

freq = [10 * [0] for i in range(10)]
ans = 0

for i in range(1,n+1):
    p = f(i)
    freq[p[0]][p[1]] += 1

for i in range(1,n+1):
    p = f(i)
    q = (p[1], p[0])
    ans += freq[q[0]][q[1]]

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n = ni()
a = na()

def gcd(m, n):
    if n == 0:
        return m
    return gcd(n, m % n)

def lcm(m, n):
    return m * n // gcd(m, n)

l = a[0]
for i in range(n):
    l = lcm(a[i], l)
ans = 0
for i in range(n):
    ans += l // a[i]
    ans = ans % 1000000007

print(ans)
Problem p03012 (python)

Fixed submission:
import sys

stdin = sys.stdin

mod = 1000000007
inf = 1 << 60

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n = ni()
w = na()

ans = inf
d = [0] * (n + 1)
b = [0] * (n + 1)
for i in range(1, n + 1):
	d[i] = w[i - 1] + d[i - 1]
	b[i] = w[n - i] + b[i - 1]
b.reverse()
for i in range(1, n):
	ans = min(ans, abs(d[i] - b[i]))

print(ans)

Buggy submission (verdict: Runtime Error):
import sys

stdin = sys.stdin

mod = 1000000007
inf = 1 << 60

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n = ni()
w = na()

ans = inf
d = [0] * (n + 1)
b = [0] * (n + 1)
for i in range(1, n + 1):
	d[i] = w[i - 1] + d[i - 1]
	b[i] = w[n - i] + b[i - 1]
b.reverse()
for i in range(1, n):
	ans = min(ans, abs(d[i] - b[i]))

print(ans
Problem p03038 (python)

Fixed submission:
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10 ** 7)

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, m = na()
a = na()
cb = []
for i in range(m):
    b, c = na()
    cb.append([c, b])

a.sort()
cb.sort(reverse=True)

cur = 0
for i in range(n):
    if cur >= len(cb):
        break
    c, b = cb[cur]
    if a[i] < c:
        a[i] = c
        b -= 1
        cb[cur][1] = b
        if b == 0:
            cur += 1
    else:
        break

print(sum(a))

Buggy submission (verdict: Runtime Error):
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10 ** 7)

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, m = na()
a = na()
cb = []
for i in range(m):
    b, c = na()
    cb.append([c, b])

a.sort()
cb.sort(reverse=True)

cur = 0
for i in range(n):
    c, b = cb[cur]
    if a[i] < c:
        a[i] = c
        b -= 1
        if b == 0:
            cur += 1
        cb[cur][1] = b
    else:
        break

print(sum(a))
Problem p03272 (python)

Fixed submission:
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

n, i = na()

print(n - i + 1)

Buggy submission (verdict: Runtime Error):
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

n = ni()
i = ni()

print(n - i + 1)
Problem p02623 (python)

Fixed submission:
from itertools import accumulate
from bisect import bisect

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a = [0] + list(accumulate(a))
b = [0] + list(accumulate(b))
ans = 0
j = m
for i in range(n+1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
from bisect import bisect

n, m, k = map(int, input().split())
a = [*accumulate(map(int, input().split()), initial=0)]
b = [*accumulate(map(int, input().split()), initial=0)]
ans = 0
for i, x in enumerate(a):
    if x <= k:
        ans = max(i - 1 + bisect(b, k - x))
print(ans)
Problem p02707 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a_cnt = [0] * (n+1)
for i in a:
    a_cnt[i] += 1
print('\n'.join(map(str, a_cnt[1:])))

Buggy submission (verdict: Runtime Error):
from collections import Counter


n = int(input())
a = list(map(int,input().split()))
a_cnt = Counter(a).most_common()
for i in range(1, n+1):
    if i in a:
        if a_cnt[i-1]:
            print(a_cnt[i-1][1])
        else:
            print(0)
    else:
        print(0)
Problem p02725 (python)

Fixed submission:
k, n = map(int, input().split())
a = list(map(int, input().split()))
a.append(a[0] + k)
a_sub = [0] * (n)
for i in range(n):
    a_sub[i] = a[i+1] - a[i]
print(k - max(a_sub))

Buggy submission (verdict: Runtime Error):
k, n = map(int, input().split())
a = list(map(int, input().split()))
a.append(a[0] + k)
a_sub = [0] * (n - 1)
for i in range(n):
    a_sub[i] = a[i+1] - a[i]
print(k - max(a_sub))
Problem p02891 (python)

Fixed submission:
from itertools import groupby


s = input()
k = int(input())
s_sub = [[h, len(list(g))] for h, g in groupby(s)]
cnt_s = 0
if s[0] == s[-1]:
    if len(s_sub) == 1:
        ans = s_sub[0][1] * k // 2
    else:
        for i in range(1, len(s_sub)-1):
            cnt_s += s_sub[i][1] // 2
        ans = cnt_s * k + s_sub[0][1] // 2 + s_sub[-1][1] // 2 + ((s_sub[0][1] + s_sub[-1][1]) // 2) * (k - 1)
else:
    for i in range(len(s_sub)):
        cnt_s += s_sub[i][1] // 2
    ans = cnt_s * k
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import groupby


s = input()
s_doub = s + s
k = int(input())
s_sub = [[h, len(list(g))] for h, g in groupby(s)]
s_doub_sub = [[h, len(list(g))] for h, g in groupby(s_doub)]
cnt_s = 0
for i in range(len(s_sub)):
    cnt_s += s_sub[i][1] // 2
cnt_s_doub = 0
for i in range(len(s_doub_sub)):
    cnt_s_doub += s_doub_sub[i][1] // 2
if len(list(set(s))) == 1:
    if s_sub[0][1] % 2 == 1:
        ans = cnt_s * k + 1
    else:
        ans = cnt_s * k
else:
    if cnt_s_doub % cnt_s == 0:
        ans = cnt_s * k
    else:
        ans = cnt_s * k + k - 1
print(ans)
Problem p02948 (python)

Fixed submission:
import heapq
n, m = map(int, input().split())
a_b = [[] for _ in range(m)]
for i in range(n):
    a, b = map(int, input().split())
    if a < m+1:
        a_b[a-1].append(-b)
h = []
heapq.heapify(h)
ans = 0
for i in range(m):
    for j in a_b[i]:
        heapq.heappush(h, j)
    if len(h) == 0:
        continue
    ans += heapq.heappop(h)*(-1)
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a_b = []
for i in range(n):
    a_b.append(list(map(int, input().split())))
a_b = sorted(a_b, key=lambda x:x[1], reverse=True)
ans = 0
for i in range(m):
    ans += a_b[i][1]
print(ans)
Problem p02959 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt = 0
dp_1 = [0]*(n)
dp_1[0] = min(a[0], b[0])
dp_2 = [0]*(n)
dp_2[0] = min(a[1], b[0]-min(a[0], b[0]))
for i in range(n-1):
    dp_1[i+1] = min(b[i+1], a[i+1] - dp_2[i])
    dp_2[i+1] = min(a[i+2], b[i+1] - dp_1[i+1])
print(sum(dp_1+dp_2))

Buggy submission (verdict: Runtime Error):
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt = 0
a_ = []
for i in range(n):
    a_.append(a[i] + a[i+1])
for i in range(n):
    cnt += min(a_[i], b[i])
print(cnt)
Problem p02990 (python)

Fixed submission:
mod = 10 ** 9 + 7
n, k = map(int, input().split())
red, blue = n-k, k
ai = red + 1
print(ai)
for i in range(2, blue+1):
    ai = ai * (red-i+2) * (blue-i+1) // (i*(i-1))
    print(ai % mod)

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

def comb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
inf = 10 ** 9 + 7
n, k = map(int, input().split())
for i in range(k):
    print(int(comb(n + 1 - k, i + 1) * comb(k - 1, i) % inf))

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
inf = 10 ** 9 + 7
n, k = map(int, input().split())
for i in range(k):
    print(int(comb(n + 1 - k, i + 1) * comb(k - 1, i) % inf))

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
inf = 10 ** 9 + 7
n, k = map(int, input().split())
for i in range(k):
    print(int(comb(n + 1 - k, i + 1) * comb(k - 1, i) % inf))
Problem p03038 (python)

Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(m)]
a = sorted(a)
bc = sorted(bc, key=lambda x: -x[1])
a_len = len(a)
i = 0
for one in bc:
    for j in range(one[0]):
        if i > a_len-1:
            break
        if a[i] > one[1]:
            break
        a[i] = one[1]
        i += 1
print(sum(a))

Buggy submission (verdict: Runtime Error):
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(m)]
a = sorted(a)
bc = sorted(bc, key=lambda x: -x[1])
a_len = len(a)
i = 0
for one in bc:
    for j in range(one[0]):
        if i > a_len-1:
            break
        if a[i] > one[1]:
            break
        a[i] = one[1]
        i += 1
print(sum(a))
Problem p03042 (python)

Fixed submission:
S = input()
zenhan = int(S[:2])
kouhan = int(S[2:])
if zenhan == 0 and kouhan != 0:
    if kouhan <= 12:
        print('YYMM')
    else:
        print('NA')
elif kouhan == 0 and zenhan != 0:
    if zenhan <= 12:
        print('MMYY')
    else:
        print('NA')
elif zenhan == 0 and kouhan == 0:
    print('NA')
elif zenhan > 12 and kouhan > 12:
    print('NA')
elif zenhan <= 12 and kouhan <= 12:
    print('AMBIGUOUS')
elif zenhan <= 12 and kouhan > 12:
    print('MMYY')
elif zenhan > 12 and kouhan <= 12:
    print('YYMM')

Buggy submission (verdict: Runtime Error):
zenhan = int(S[:2])
kouhan = int(S[2:])
if zenhan == 0 or kouhan == 0:
    print('NA')
elif zenhan > 12 and kouhan > 12:
    print('NA')
elif zenhan <= 12 and kouhan <= 12:
    print('AMBIGUOUS')
elif zenhan <= 12 and kouhan > 12:
    print('MMYY')
elif zenhan > 12 and kouhan <= 12:
    print('YYMM')
Problem p03107 (python)

Fixed submission:
S = list(map(str, input().strip()))
num_of_zero = S.count('0')
num_of_one = S.count('1')
if num_of_zero <=  num_of_one:
    delete_num = 2 * num_of_zero
else:
    delete_num = 2 * num_of_one
print(delete_num)

Buggy submission (verdict: Runtime Error):
N = len(S)
num_one = S.count('1')
num_zero = S.count('0')
print(N - abs(num_one - num_zero))
Problem p03127 (python)

Fixed submission:
def gcd(x, y):
    while y != 0:
        x, y = y, x%y
    return x


N = int(input())
A = list(map(int, input().split()))
first_gcd = A[0]
for i in range(len(A)):
    first_gcd = gcd(first_gcd, A[i])
print(first_gcd)

Buggy submission (verdict: Runtime Error):
import math


N = int(input())
A = list(map(int, input().split()))
first_gcd = A[0]
for i in range(len(A)):
    first_gcd = math.gcd(first_gcd, A[i])
print(first_gcd)

Buggy submission (verdict: Runtime Error):
import math


N = int(input())
A = list(map(int, input().split()))
A.sort()
A_min = min(A)
del A[0]
A_min_2 = min(A)
print(math.gcd(A_min, A_min_2))

Buggy submission (verdict: Runtime Error):
import math


N = int(input())
A = list(map(int, input().split()))
A.sort()
A_min = min(A)
del A[0]
A_min_2 = min(A)
print(math.gcd(A_min, A_min_2))
Problem p03137 (python)

Fixed submission:
N, M = map(int, input().split())
X = list(map(int, input().split()))
if N >=  M:
    print(0)
else:
    X.sort()
    X_sub = []
    for i in range(len(X)-1):
        X_sub.append(X[i+1]-X[i])
    X_sub.sort()
    for i in range(N-1):
        del X_sub[-1]
    print(sum(X_sub))

Buggy submission (verdict: Runtime Error):
X = list(map(int, input().split()))
X.sort()
if N >= M:
    print(0)
else:
    L = []
    for i in range(M-1):
        L.append(X[i+1] - X[i])
    L.sort()
    for i in range(N-1):
        del L[-1]
    print(sum(L))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
X_sub = []
for i in range(len(X)-1):
    X_sub.append(X[i+1]-X[i])
X_sub.sort()
for i in range(N-1):
    del X_sub[-1]
print(sum(X_sub))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
X_sub = []
for i in range(len(X)-1):
    X_sub.append(X[i+1]-X[i])
X_sub.sort()
for i in range(N-1):
    del X_sub[-1]
print(X_sub)
print(sum(X_sub))
Problem p03208 (python)

Fixed submission:
N, K = map(int, input().split())
h = [0] * N
for i in range(N):
    h[i] = int(input())
h.sort()
print(min(h[i+K-1]-h[i] for i in range(N-K+1)))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
h = [0]*N
for i in range(N):
    h[i] = int(input())
h.sort()
print(min(h[i+K+1] - h[i] for i in range(N-K+1)))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
h = [0] * N
for i in range(N):
    h[i] = int(input())
h.sort()
print(min(h[i+K-1]-h[i] for i in range(N)))
Problem p03209 (python)

Fixed submission:
n, x = map(int, input().split())
a, p = [1], [1]
for i in range(n):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)


def f(N, X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + a[N-1]:
        return f(N-1, X-1)
    else:
        return p[N-1] + 1 + f(N-1, X - 2 - a[N-1])


print(f(N=n, X=x))

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
a, p = [1], [1]
for i in range(n):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)


def f(N, X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + a[N-1]:
        return f(N-1, X-1)
    else:
        return p[N-1] + 1 + f(N-1, X - 2 - a[N-1])


print(f(N, X))
Problem p03242 (python)

Fixed submission:
n=int(input())
if n==111:
    print(999)
elif n==119:
    print(991)
elif n==191:
    print(919)
elif n==199:
    print(911)
elif n==911:
    print(199)
elif n==919:
    print(191)
elif n==991:
    print(119)
elif n==999:
    print(111)

Buggy submission (verdict: Runtime Error):
n=int(input())
if n==111:
    print(999)
if n==119:
    prit(991)
if n==191:
    print(919)
if n==199:
    print(911)
if n==911:
    print(199)
if n==919:
    print(191)
if n==991:
    print(119)
if n==999:
    print(111)
Problem p03250 (python)

Fixed submission:
A,B,C=[int(i) for i in input().split()]
list=[]
list.append(A)
list.append(B)
list.append(C)
max=max(list)
list.remove(max)

print(10*max+sum(list))

Buggy submission (verdict: Runtime Error):
A,B,C=[int(i) for i in input().split()]
list=[]
list.append(A)
list.append(B)
list.append(C)
max=max(list)
list.remove(max)

return 10*max+sum(list)
Problem p03317 (python)

Fixed submission:
from math import ceil
n, k = map(int, input().split())
a = list(map(int, input().split()))
print(ceil((n-1)/(k-1)))

Buggy submission (verdict: Runtime Error):
def calculate_median(lst):
    lst.sort()
    median_right = lst[int(len(lst)/2)]
    median_left = lst[int(len(lst)/2)-1]
    return median_right, median_left


N = int(input())
X = list(map(int, input().split()))
X_copy = X.copy()
median_right, median_left = calculate_median(X)
for i in range(N):
    if X_copy[i] >= median_right:
        print(median_left)
    elif X_copy[i] < median_right:
        print(median_right)

Buggy submission (verdict: Runtime Error):
import statistics


def calculate_median(lst):
    lst.sort()
    median_right = lst[int(len(lst)/2)]
    median_left = lst[int(len(lst)/2)-1]
    return median_right, median_left


N = int(input())
X = list(map(int, input().split()))
X_copy = X.copy()
median_right, median_left = calculate_median(X)
for i in range(N):
    if X_copy[i] >= median_right:
        print(median_left)
    elif X_copy[i] < median_right:
        print(median_right)
Problem p03634 (python)

Fixed submission:
from collections import deque
import sys
sys.setrecursionlimit(10 ** 9)


n = int(input())
query = [[] for i in range(n)]
for i in range(n-1):
    a, b, c = map(int, input().split())
    query[a-1].append((b-1, c))
    query[b-1].append((a-1, c))
q, k = map(int, input().split())
stack = deque([(k-1, 0, -1)])
dist = [0] * n
while stack:
    now, cnt, per = stack.pop()
    lis = query[now]
    dist[now] = cnt
    for nx, c in lis:
        if nx == per:
            continue
        if c != 0:
            stack.append((nx, cnt+c, now))
for i in range(q):
    x, y = map(int, input().split())
    print(dist[x-1] + dist[y-1])

Buggy submission (verdict: Runtime Error):
import numpy as np
from scipy.sparse.csgraph import floyd_warshall, dijkstra



n = int(input())
matrix = np.zeros((n, n),dtype=np.int64)
for i in range(n-1):
    a, b, c = map(int, input().split())
    matrix[a-1][b-1] = c
    matrix[b-1][a-1] = c
min_span_matrix = dijkstra(matrix, directed=False,
                                 return_predecessors=False)
q, k = map(int, input().split())
for i in range(q):
    x, y = map(int, input().split())
    print(int(min_span_matrix[x-1][k-1] + min_span_matrix[k-1][y-1]))

Buggy submission (verdict: Runtime Error):
import numpy as np
from scipy.sparse.csgraph import floyd_warshall



n = int(input())
matrix = np.zeros((n, n),dtype=np.int64)
for i in range(n-1):
    a, b, c = map(int, input().split())
    matrix[a-1][b-1] = c
    matrix[b-1][a-1] = c
min_span_matrix = floyd_warshall(matrix, directed=False,
                                 return_predecessors=False)
q, k = map(int, input().split())
for i in range(q):
    x, y = map(int, input().split())
    print(int(min_span_matrix[x-1][k-1] + min_span_matrix[k-1][y-1]))

Buggy submission (verdict: Runtime Error):
import numpy as np
from scipy.sparse.csgraph import floyd_warshall



n = int(input())
matrix = np.zeros((n, n))
for i in range(n-1):
    a, b, c = map(int, input().split())
    matrix[a-1][b-1] = c
    matrix[b-1][a-1] = c
min_span_matrix = floyd_warshall(matrix, directed=False,
                                 return_predecessors=False)
q, k = map(int, input().split())
for i in range(q):
    x, y = map(int, input().split())
    print(min_span_matrix[x-1][k-1] + min_span_matrix[k-1][y-1])
Problem p03011 (python)

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

print(min([a + b, a + c, b + c]))

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

print(min([a + b, a + c, b + c])
Problem p03038 (python)

Fixed submission:
from operator import itemgetter

n, m = map(int, input().split())
arr_a = [int(i) for i in input().split()]
e = [[int(i) for i in input().split()] for i in range(m)] 

# aをソート
al = sorted(arr_a)

# Ciでソート
l = sorted(e, key=itemgetter(1), reverse=True)

c_arr = []

for i in range(len(l)):
    c_arr.extend( [ l[i][1] ] * l[i][0] )
    
    if len(c_arr) >= n:
        c_arr = c_arr[0:n]
        break

for i in range(len(c_arr)):
    if c_arr[i] > al[i]:
        al[i] = c_arr[i]
    else:
        break

print(sum(al))

Buggy submission (verdict: Runtime Error):
from operator import itemgetter

n, m = map(int, input().split())
arr_a = [int(i) for i in input().split()]
e = [[int(i) for i in input().split()] for i in range(m)] 

# aをソート
al = sorted(arr_a)

# Ciでソート
l = sorted(e, key=itemgetter(1), reverse=True)

c_arr = []

for i in range(len(l)):
    c_arr.extend( [ l[i][1] ] * l[i][0] )
    
    if len(c_arr) >= n:
        c_arr = c_arr[0:n+1]
        break

for i in range(len(c_arr)):
    if c_arr[i] > al[i]:
        al[i] = c_arr[i]
    else:
        break

print(sum(al))
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):
a, b, c, d, e = map(int, input().split())

if e - a <= k:
  print("Yay!")
else:
  print(":(")
Problem p03127 (python)

Fixed submission:
from fractions import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

n = int(input())
print(gcd_list([int(i) for i in input().split()]))

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

def gcd_list(numbers):
    return reduce(gcd, numbers)

n = int(input())

print(gcd_list([int(i) for i in input().split()]))

Buggy submission (verdict: Runtime Error):
n = int(input())
e = [int(i) for i in input().split()] 

e.sort()
amari = e[0]
while e[n-2]:
    for i,v in enumerate(e):
        if v != 0:
            e[i] = v % e[0]
            e.sort()
    
print(e[n-2])
Problem p03250 (python)

Fixed submission:
a, b, c = map(int, input().split())
array = [a, b, c]
array.sort()
print(array[-1] * 10 + array[0] + array[1])

Buggy submission (verdict: Runtime Error):
n, m, X, Y = map(int, input().split())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]

x.append(X)
y.append(Y)

if max(x) < min(y):
    print("No War")
else :
    print("War")
Problem p02595 (python)

Fixed submission:
n, d = map(int, input().split())
x, y = [], []
for i in range(n):
  a, b = map(int, input().split())
  x.append(a)
  y.append(b)

count = 0
for xi, yi in zip(x, y):
  if xi**2 + yi**2 <= d**2:
    count += 1

print(count)

Buggy submission (verdict: Runtime Error):
n, d = map(int, input().split())
xy = 0
for i in range(n):
  a, b = map(int, input().split())
  xy += xi**2 + yi**2 <= d**2 for xi, yi in xy

print(xy)

Buggy submission (verdict: Runtime Error):
n, d = map(int, input().split())
xy = []
for i in range(n):
  a, b = map(int, input().split())
  x.append([a, b])
 
count = 0
for xy in xy:
  count += xy[0]**2 + xy[1]**2 <= d**2
 
print(count)

Buggy submission (verdict: Runtime Error):
n, d = map(int, input().split())
xy = []
for i in range(n):
  a, b = map(int, input().split())
  x.append([a, b])
 
count = 0
for xi, yi in xy:
  count += xi**2 + yi**2 <= d**2
 
print(count)