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

Fixed submission:
N,A,B = map(int,input().split())
count = 0
a = N//(A+B)
#print(a)
count += a*A
#print(count)
b = N%(A+B)
if b > A:
  count +=A
else:
  count +=b
print(count)

Buggy submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
count = 0
Bs = "b"*A
Rs = "r"*B
ballset = Bs+Rs
#print(Bs)
#print(Rs)
n = (N//len(ballset)+1)
#print(len(ballset))
#print(n)
allball = ballset*n
print(allball)
print(allball[:N].count("b"))

Buggy submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
count = 0
Bs = "b"*A
Rs = "r"*B
ballset = Bs+Rs
#print(Bs)
#print(Rs)
n = (N//len(ballset)+1)
#print(len(ballset))
#print(n)
allball = ballset*n
print(allball[:N].count("b"))
Problem p02785 (python)

Fixed submission:
N,K = map(int,input().split())
H = list(map(int,input().split()))
if K == 0:
  print(sum(H))
else:
  H.sort(reverse = True)
  if N>K:
    h = H[K:N]
    print(sum(h))
#    for i in range(K):
 #     del H[i]
  #  print(sum(H))
  else:
    print(0)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
H = list(map(int,input().split()))
if K == 0:
  print(sum(H))
else:
  H.sort(reverse = True)
  if N>K:
    for i in range(K):
      del H[i]
    print(sum(H))
  else:
    print(0)
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):
N = int(input())
if N%2==1:
  print(N-1)
else:
  ans = []
  for i in range(1,N):
    for j in range(1,N):
      cnt=0
      if i*j==N:
        cnt +=i-1
        cnt +=j-1
        ans.append(str(cnt))
  ans=min(ans)
  print(ans)
Problem p03075 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
dis =[]
dis.append(a)
dis.append(b)
dis.append(c)
dis.append(d)
dis.append(e)

if max(dis)-min(dis)>k:
  print(":(")
else:
  print("Yay!")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
dis=list[a,b,c,d,e,k]

if max(dis)-min(dis)>=K:
  print(":(")
else("Yay!")
Problem p02779 (python)

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

Buggy submission (verdict: Runtime Error):
N = int(input())
l = []
for i in range(N):
    A = int(input())
    if A in l:
        print("NO")
        exit()
    l.append(i)
print("YES")
Problem p02859 (python)

Fixed submission:
r = int(input())

print(r**2)

Buggy submission (verdict: Runtime Error):
from math import sqrt 
N = int(input())
k = [list(map(int, input().split())) for _ in range(N)]
result = 0
for i in range(N):
    for j in range(N):
        if i != j:
            result += sqrt((k[i][0] - k[j][0]) * (k[i][0] - k[j][0]) + (k[i][1] - k[j][1]) * (k[i][1] - k[j][1]))
print(result / N)

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

S = S[N // 2 :]
S1 = ''.join(S1)
if S1 == S:
    print('Yes')
else:
    print('No')
Problem p02881 (python)

Fixed submission:
from math import sqrt
from sys import exit

N = int(input())

for i in range(int(sqrt(N)) + 1, -1, -1):
    if N % i == 0:
        print((i - 1) + (N // i - 1))
        exit()

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = 10*10
#N<10**12より√N<10**6]
for i in range(1, i*i <=N):
    if (N % i != 0): continue
    j = N / i
    ans = min(ans, i + j - 2)

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = 10*18
for i in range(1, i*i <=N):
    if (N % i != 0): continue
    j = N / i
    ans = min(ans, i + j - 2)

print(ans)
Problem p02959 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
fenum = sum(A)

if B[0] >= A[0]:
    B[0] -= A[0]
    A[0] = 0
    if B[0] > A[1]:
        A[1] = 0
    else:
        A[1] -= B[0]
        B[0] = 0
    
else:
    A[0] -= B[0] 
    B[0] = 0
    
for i in range(1, N):
    if B[i] >= A[i]:
        B[i] -= A[i]
        A[i] = 0
        if B[i] > A[i + 1]:
            A[i + 1] = 0
            continue
        A[i + 1] -= B[i]
        B[i] = 0
    
    else:
        A[i] -= B[i]
        B[i] = 0

print(fenum - sum(A))

Buggy submission (verdict: Runtime Error):
#N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
fenum = sum(A)

if B[0] >= A[0]:
    B[0] -= A[0]
    A[0] = 0
    if B[0] > A[1]:
        A[1] = 0
    else:
        A[1] -= B[0]
        B[0] = 0
    
else:
    A[0] -= B[0] 
    B[0] = 0
    
for i in range(1, len(B)):
    if B[i] >= A[i]:
        B[i] -= A[i]
        A[i] = 0
        if B[i] > A[i + 1]:
            A[i + 1] = 0
            continue
        A[i + 1] -= B[i]
        B[i] = 0
    
    else:
        A[i] -= B[i]
        B[i] = 0

print(fenum - sum(A))
Problem p03013 (python)

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

bs = [True for i in range(N+1)]
for i in range(M):
    a = int(input())
    bs[a] = False

dp = [0 for i in range(N+1)]
dp[0] = 1
if bs[1] != False: dp[1] = 1

for i in range(2,N+1):
    if bs[i-1] != False:
        dp[i] += dp[i - 1]
    if bs[i - 2] != False:
        dp[i] += dp[i - 2]

print(dp[N] % 1000000007)

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

a = [int(input()) for i in range(M)]
dp = [0 for i in range(N + 1)]
flag = [False for i in range(N + 1)]
dp[0] = 1
if a[0] != 1:
    dp[1] = 1
for i in a:
    flag[i] = True
for i in range(2,N+1):
    if flag[i - 1] != True:
        dp[i] = dp[i - 1]
    if flag[i - 2] != True:
        dp[i] += dp[i - 2]
print(dp[N] % 1000000007 )
Problem p03137 (python)

Fixed submission:
N, M = map(int, input().split())
X = list(map(int, input().split()))
if N >= M:
    print(0)
    exit()
X.sort()
leng = []
for i in range(1, M):
    leng.append(X[i] - X[i-1])
ans = sorted(leng, reverse = True)
print(sum(ans[N - 1:]))

Buggy submission (verdict: Runtime Error):
    N, M = [int(n) for n in input().split()]
    X = sorted([int(n) for n in input().split()])
    if N>=M:
        print(0)
    else:
        dx = []
        for j in range(M-1):
            dx.append(X[j+1]-X[j])
        ans = sorted(dx, reverse=True)
        print(sum(ans[N-1:]))
Problem p03208 (python)

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

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

Fixed submission:
N, A, B = map(int, input().split())
q, mod = divmod(N, A+B)
if mod >= A:
	print(q*A+A)
else: 
	print(q*A+mod)

Buggy submission (verdict: Runtime Error):
N, A, B = input().split()
q, mod = divmod(N, A+B)

if mod > A:
  print((q+1)*A)
else :
  print(q*A+mod)
Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split())
def fib(n) :
    a, b = 1, 1
    if n==0 :
        return a
    elif n==1 :
        return b
    else :
        for i in range(n-1):
            a, b = b, a+b
        return b
a=[]
b=1

for i in range(M):
    a.append(int(input()))
    if a[i]-a[i-1] == 1 :
        b=0

def rest(num) :
    return num % 1000000007
c=0
if b==0 :
    print(c)
else :
    for i in range(M+1):
        if i == 0 == M :
            c += rest(fib(N))
        elif i == 0:
            c += rest(fib(a[i]-1))
        elif i == M:
            c = rest(c * fib(N-a[i-1]-1))
        else :
            c = rest(c * fib(a[i]-a[i-1]-2))
    print(c)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
def fib(n) :
    if n==1 :
        return 1
    elif n==0 :
        return 1
    else :
        return fib(n-1) + fib(n-2)
a=[]
b=1

for i in range(M):
    a.append(int(input()))
    if a[i]-a[i-1] == 1 :
        b=0

def rest(num) :
    return num % 1000000007
c=0
if b==0 :
    print(c)
else :
    for i in range(M+1):
        if i == 0 == M :
            c += rest(fib(N))
        elif i == 0:
            c += rest(fib(a[i]-1))
        elif i == M:
            c = rest(c * fib(N-a[i-1]-1))
        else :
            c = rest(c * fib(a[i]-a[i-1]-2))
    print(c)

Buggy submission (verdict: Runtime Error):
nm = [int(s) for s in input().split()]


def fib(n) :
    if n==1 :
        return 1
    elif n==0 :
        return 1
    else :
        return fib(n-1) + fib(n-2)
a=[]
b=1
for i in range(nm[1]):
    a.append(int(input()))
    if a[i]-a[i-1] == 1 :
        b=0

def rest(num) :
    return num % 1000000007
c=0
if b==0 :
    print(c)
else :
    for i in range(nm[1]+1):
        if i == 0:
            c += rest(fib(a[i]-1))
        elif i == nm[1]:
            c = rest(c * fib(nm[0]-a[i-1]-1))
        else :
            c = rest(c * fib(a[i]-a[i-1]-2))
    print(c)
Problem p02879 (python)

Fixed submission:
ab = input().split(" ")
a = int(ab[0])
b = int(ab[1])


def check(a,b):
	if (a>9 or b>9):
		return -1
	else:
		return a*b
ans = check(a,b)
print(ans)

Buggy submission (verdict: Runtime Error):
ab = input().split(" ")
a = int(ab[0])
b = int(ab[1])


def check(a,b):
	if (a>9 or b>9):
		return -1
	else
		return a*b

print(check(a,b))
Problem p02777 (python)

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

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

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

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

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

if (S==U):
    print(str(A-1) B)
else:
    print(A str(B-1))

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

if (S==U):
    print(A-1 B)
else:
    print(A B-1)

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

if (S==U):
    print(A-1 B)
else:
    print(A B-1)
Problem p03075 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
de = e - d
ce = e - c
cd = d - c
be = e - b
bd = d - b
bc = c - b
ae = e - a
ad = d - a
ac = c - a
ab = b - a
distance = [ab, ac, ad, ae, bc, bd, be, cd, ce, de]
output = []
ok = 'Yay!'
bad = ':('
for i in distance:
    if i > k:
        output.append(bad)
    elif i <= k:
        output.append(ok)
if bad in output:
    print(bad)
elif ok in output:
    print(ok)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
l = [e, d, c, b, a]
de = e - d
ce = e - c
cd = d - c
be = e - b
bd = d - b
bc = c - b
ae = e - a
ad = d - a
ac = c - a
ab = b - a
distance = [ab, ac, ad, ae, bc, bd,be, cd, ce, de]
output = []
ok = 'Yay!'
bad = ':('
for i in distance:
    if i >= k:
        output.append(bad)
    else i < k:
        output.append(ok)
if bad in output:
    print(bad)
elif ok in output:
    print(ok)
Problem p02777 (python)

Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力
a, b = map(str, input().split())
# スペース区切りの整数の入力
c, d = map(int, input().split())
# 文字列の入力
e = str(input())

if a == e:
    c = c - 1
elif b ==e:
    d = d - 1
    
# 出力
print("{} {}".format(c, d))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 文字列の入力
a = int(input())
li = list(map(int, input().split()))
li2 = []

for i in range(a):
    li2.append(li[i])

if len(li2) != len(set(li2)):
    print('NO')
else:
    print('YES')
Problem p02771 (python)

Fixed submission:
a = input()
mylist = list(map(int, a.split(" ")))
A = mylist[0]
B = mylist[1]
C = mylist[2]
 
if (A == B and B != C):
  print("Yes")
elif (A == C and B != C):
  print("Yes")
elif (B == C and A != B):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N = input()
a = input()
mylist = list(map(int, a.split(" ")))
for i in range(N+1):
  if mylist[i] % 2 == 0:
    if mylist[i] % 3 != 0 and mylist[i] % 5 != 0:
      print("DENIED")
    else:
      return
  print("APPROVED")

Buggy submission (verdict: Runtime Error):
a = input()
mylist = list(map(int, a.split(" ")))
A = mylist[0]
B = mylist[1]
C = mylist[2]
 
if (A == B and B != C):
  print(Yes)
elif (A == C and B != C):
  print(Yes)
elif (B == C and A != B):
  print(Yes)
else:
  print(No)

Buggy submission (verdict: Runtime Error):
myinput_H = input()
mylist = list(map(int, myinput_H.split(" ")))
A = mylist[0]
B = mylist[1]
C = mylist[2]
 
if (A == B & B != C):
  print(Yes)
elif (A == C & B != C):
  print(Yes)
elif (B == C & A != B):
  print(Yes)
else:
  print(No)

Buggy submission (verdict: Runtime Error):
myinput_H = input()
mylist = list(map(int, myinput_H.split(" ")))
A = mylist[0]
B = mylist[1]
C = mylist[2]

if (A == B & B != C) or (A == C & B != C) or (B == C & B != A):
  print(Yes)
else:
  print(No)

Buggy submission (verdict: Runtime Error):
myinput_H = input()
mylist = list(map(int, myinput_H.split(" ")))
A = mylist[0]
B = mylist[1]
C = mylist[2]
def check(a,b,c):
  if (a == b & b != c) or (a == c & b != c) or (b == c & b != a):
    print(Yes)
  else:
    print(No)

check(A,B,C)

Buggy submission (verdict: Runtime Error):
mylist = list(map(int, myinput_H.split(" ")))
A = mylist[0]
B = mylist[1]
C = mylist[2]
def check(a,b,c):
  if (a == b & b != c) or (a == c & b != c) or (b == c & b != a):
    print(Yes)
  else:
    print(No)
Problem p02785 (python)

Fixed submission:
myinput = input()
myinput_H = input()
mylist = list(map(int, myinput.split(" ")))
N = mylist[0]
K = mylist[1]
list_H = list(map(int, myinput_H.split(" ")))
if N - K <= 0:
    print(0)
else:
    x = N - K
    list_H.sort()
    l = list_H[0:x]
    sum = sum(l)
    print(sum)

Buggy submission (verdict: Runtime Error):
myinput = input()
myinput_H = input()
mylist = list(map(int, myinput.split(" ")))
N = int(mylist[0])
K = int(mylist[1])
list_H = list(map(int, myinput_H.split(" ")))
for i in range(K):
    list_H.remove(max(list_H))
sum = sum(list_H)
print(sum)
Problem p02773 (python)

Fixed submission:
import collections

N=int(input())
data=[input() for i in range(N)]
c = collections.Counter(data)
score=c
com=c.most_common()

score_sorted = sorted(score.items(), key=lambda x:x[1], reverse=True)

val=score_sorted
L=len(val)
count="Yes"
ii=0
ansa=1
if L==1:
    print(val[0][0])
else:
    while count=="Yes":
        if val[ii][1]==val[ii+1][1]:
            ii+=1

            ansa+=1
            if ii == L-1:
                break
        else:
            count="No"
    data2=[]
    for i in range(ansa):
        data2.append(val[i][0])

    data2.sort()
    for i in range(ansa):
        print(data2[i])

Buggy submission (verdict: Runtime Error):
import collections

N=int(input())
data=[input() for i in range(N)]
c = collections.Counter(data)
score=c
com=c.most_common()

score_sorted = sorted(score.items(), key=lambda x:x[1], reverse=True)

val=score_sorted
L=len(val)
count="Yes"
ii=0
ansa=1
while count=="Yes":
    if val[ii][1]==val[ii+1][1]:
        ii+=1

        ansa+=1
        if ii == L-1:
            break
    else:
        count="No"
data2=[]
for i in range(ansa):
    data2.append(val[i][0])

data2.sort()
for i in range(ansa):
    print(data2[i])

Buggy submission (verdict: Runtime Error):
import collections

N=int(input())
data=[input() for i in range(N)]
c = collections.Counter(data)
score=c
com=c.most_common()

score_sorted = sorted(score.items(), key=lambda x:x[1], reverse=True)

val=score_sorted

count="Yes"
ii=0
ansa=1
while count=="Yes":
    if val[ii][1]==val[ii+1][1]:
        ii+=1
        ansa+=1
    else:
        count="No"
data2=[]
for i in range(ansa):
    data2.append(val[i][0])
    
data2.sort()
for i in range(ansa):
    print(data2[i])

Buggy submission (verdict: Runtime Error):
import collections

N=int(input())
data=[input() for i in range(N)]
c = collections.Counter(data)
score=c
com=c.most_common()
#val=c.values()
#dada=list(val)
#dada.sort()
score_sorted = sorted(score.items(), key=lambda x:x[1], reverse=True)
#print(val)
#val.sort()
#print(dada)
#print(score_sorted)
val=score_sorted
#print("val==",val)
#key=score_sorted.keys()
#dada=list(val)
#dada.sort()
count="Yes"
ii=0
ansa=1
while count=="Yes":
    if val[ii][1]==val[ii+1][1]:
        ii+=1
        ansa+=1
    else:
        count="No"
data2=[]
for i in range(ansa):
    data2.append(val[i][0])
    #print(i,data2)
data2.sort()
for i in range(ansa):
    print(data2[i])
Problem p02754 (python)

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

all = a + b

# a = 0
if a == 0:
    print(0)
    exit(0)

if N <= a:
    print(N)
    exit(0)

# a > 0
c = math.floor(N / all)
d = N % all

roundCnt = a * c
amariCnt = 0

if d != 0:
    if d <= a :
        amariCnt = d
    else:
        amariCnt = a

print(roundCnt + amariCnt)


#a = 0 print 0
#a > 0
# N <= a print N
# N > a
#  N/(a+b)=c     が割り切れる  a * c
#  N/(a+b)=c...d が余りが出る  a * c
#    d <= a のとき a * c + d
#    d >  a のとき a * c + a
#

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

all = a + b

# a = 0
if a == 0:
    print(0)
    exit(0)

if N <= a:
    print(N)
    exit(0)

# a > 0
c = round(N / all)
d = N % all

roundCnt = a * c

if d != 0:
    if d <= a :
        amariCnt = d
    else:
        amariCnt = a

print(roundCnt + amariCnt)


#a = 0 print 0
#a > 0
# N <= a print N
# N > a
#  N/(a+b)=c     が割り切れる  a * c
#  N/(a+b)=c...d が余りが出る  a * c
#    d <= a のとき a * c + d
#    d >  a のとき a * c + a
#
Problem p02777 (python)

Fixed submission:
# -*- coding: utf-8 -*-
s = input().split()
n = list(map(int,input().split()))
s2 = input()

if s[0] == s2:
  n[0] = n[0] - 1
else:
  n[1] = n[1] - 1

print(str(n[0]) +' '+str(n[1]))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
s = input().split()
n = input().split()
s2 = input()
 
if s[0] == s2:
  n[0] = n[0] - 1
else:
  n[1] = n[1] - 1
 
print(str(n[0]) +' '+str(n[1]))

Buggy submission (verdict: Runtime Error):
s = input().split()
n = input().split()
s2 = input()

if s[0] == s2:
  n[0] = n[0] - 1
else:
  n[1] = n[1] - 1

print(str(n[0]) +' '+str(n[1]))
Problem p02829 (python)

Fixed submission:
a = int(input())
b = int(input())
if a == 1:
    if b ==2:
        print(3)
    else:
        print(2)
elif a == 2:
    if b == 1:
        print(3)
    else:
        print(1)
else:
    if b == 1:
        print(2)
    else:
        print(1)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a == 1:
    if b ==2:
        print(3)
    else:
        print(2)
elif a == 2:
    if b == 1:
        print(3)
    else:
        print(1)
else:
    if b == 1:
        print(2)
    else:
        print(1)
Problem p02773 (python)

Fixed submission:
n = int(input())
b = {}
for i in range(n):
    temp = input()
    if temp not in b:
        b[temp] = 1
    else:
        b[temp] += 1

list1 = sorted(b.items(), key=lambda x: x[1])

a = len(list1)-1
temp = len(list1)-1
list2 = []
while a >= 0 and list1[temp][1] == list1[a][1]:
    list2.append(list1[a][0])
    a -= 1
list2.sort()

for a in list2:
    print(a)

Buggy submission (verdict: Runtime Error):
n = int(input())
b = {}
for i in range(n):
    temp = input()
    if temp not in b:
        b[temp] = 1
    else:
        b[temp] += 1

list1 = sorted(b.items(), key=lambda x: x[1])
list1.reverse()

a = 0
list2=[]
while list1[0][1] == list1[a][1]:
    list2.append(list1[a][0])
    list2.sort()
    a += 1

print(list2)
Problem p03250 (python)

Fixed submission:
a = [int(i) for i in input().split()]
a.sort()
print(a[2]*10+a[1]+a[0])

Buggy submission (verdict: Runtime Error):
a = [int(i) for i in input().split())]
a.sort()
print(a[2]*10+a[1]+a[0])
Problem p03011 (python)

Fixed submission:
A = list(map(int, input().split()))
ans = sum(A) - max(A)
print(ans)

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

ans = sum(A) - max(A)
print(ans)
Problem p03038 (python)

Fixed submission:
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
cards = [list(map(int, input().split())) for i in range(M)]
cards = sorted(cards, key=lambda x: x[1], reverse=True)

cnt = 0
for card in cards:
    A += [card[1]]*card[0]
    cnt += card[0]
    if cnt >= N:
        break
A.sort(reverse=True)
print(sum(A[:N]))

Buggy submission (verdict: Runtime Error):
A = list(map(int, input().split()))
BC = []
for i in range(M):
    b, c = list(map(int, input().split()))
    BC.append([b, c])
BC = sorted(BC, reverse=True, key=lambda x:x[1])
 
cnt = 0
com = []
for b, c in BC:
    cnt += b
    if cnt > N:
        add = N-cnt+b
        com.extend([c]*add)
        break
    else:
        x = [c]*b 
        com.extend(x)
A.extend(com)
A = sorted(A, reverse=True)   
 
print(sum(A[:N]))

Buggy submission (verdict: Runtime Error):
A = list(map(int, input().split()))
 
 
 
BC = []
for i in range(M):
    b, c = list(map(int, input().split()))
    BC.append([b, c])
 
BC=sorted(BC, reverse=True, key=lambda x:x[1])
 
cnt = 0
com = []
for b, c in BC:
    cnt += b
    if cnt > N:
        add = N-cnt+b
        com.extend([c]*add)
        break
    else:
        x = [c]*b 
        com.extend(x)
 
A.extend(com)
A = sorted(A, reverse=True)   
 
print(sum(A[:N]))

Buggy submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()

cards = [list(map(int, input().split())) for i in range(M)]
D = []
for card in cards:
    D += [card[1]]*card[0]
D.sort(reverse=True)

i = 0
ans = sum(A)
while (D[i] > A[i]):
    ans += (D[i] - A[i])
    i += 1
    if i == N - 1:
        print(ans)
        exit()
print(ans)
Problem p03075 (python)

Fixed submission:
A = [int(input()) for i in range(5)]
K = int(input())

if (max(A)-min(A) <= K):
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
import itertools


X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

AB = [a + b for (a, b) in list(itertools.product(A, B))]
AB = sorted(AB)[::-1]
ans = [ab + c for (ab, c) in list(itertools.product(AB[:3000], C))]
ans = sorted(ans)[::-1]
for i in range(K):
    print(ans[i])