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

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


def solv(a, b, c, d, e, k):
    ants = [a, b, c, d, e]
    for i in range(1, len(ants)):
        for j in range(i):
            if abs(ants[i] - ants[j]) > k:
                return ':('
    return 'Yay!'


if __name__ == '__main__':

    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())
    k = int(input())

    ans = solv(a, b, c, d, e, k)

    print(ans)

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



def solv(x, y, z, k, a, b, c):
    a = sorted(a, reverse=True)
    b = sorted(b, reverse=True)
    c = sorted(c, reverse=True)

    m = max(a[0] - a[-1], b[0] - b[-1], c[0] - c[-1])

    while True:
        aa = list(filter(lambda v: v > a[0] - m, a))
        bb = list(filter(lambda v: v > b[0] - m, b))
        cc = list(filter(lambda v: v > c[0] - m, c))

        if len(aa) * len(bb) * len(cc) < 10000:
            break

        m = m * 0.8

    aa = a
    bb = b
    cc = c

    all = []
    for ai in a:
        for bi in b:
            for ci in c:
                all.append(ai+bi+ci)

    all = sorted(all, reverse=True)

    return all[:k]


if __name__ == '__main__':

    x, y, z, k = map(int, input().split())
    a = map(int, input().split())
    b = map(int, input().split())
    c = map(int, input().split())

    ans = solv(x, y, z, k, a, b, c)

    for ans_i in ans:
        print(ans_i)
Problem p02859 (python)

Fixed submission:
N = int(input())

print(N*N)

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

print(N*N)
Problem p02723 (python)

Fixed submission:
s=input()
f=-1
if s[2]==s[3]:
    if s[4]==s[5]:
        f=1
if f==1:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s=input()
f==-1
if s[2]==s[3]:
    if s[4]==s[5]:
        f==1
if f==1:
    print('Yes')
else:
    print('No')
Problem p02773 (python)

Fixed submission:
n=int(input())
s=[]
for i in range(n):
    s.append(input())
s=sorted(s)
t=0
c=0
ct=[]
for i in range(1,n):
    c+=1
    if s[t]!=s[i]:
        ct.append(c)
        c=0
        t=i
ct.append(c+1)
u=0
cm=max(ct)
for i in ct:
    if i==cm:
        print(s[u])
    u+=i

Buggy submission (verdict: Runtime Error):
import collections
n=int(input())
s=[]
for i in range(n):
    s.append(input())

ss=sorted(s)
t=0
c=1
count=[]
for i in range(1,n):
    if i==n-1:
        if ss[t]==ss[i]:
            count.append(c+1)
        else:
            count.append(c)
            count(1)
    else:
        if ss[t]==ss[i]:
            c+=1
        else:
            t=i
            count.append(c)
            c=1
u=0
for i in count:
    if i==max(count):
        print(ss[u])
    u+=i
Problem p02777 (python)

Fixed submission:
s,t=map(str,input().split())
a,b=map(int,input().split())
u=input()
if s==u:
    a-=1
elif t==u:
    b-=1

print('{} {}'.format(a,b))

Buggy submission (verdict: Runtime Error):
red blue
5 5
blue
Problem p02785 (python)

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort(reverse=True)
c=0
for i in range(k,n):
    c+=h[i]

print(c)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort(reverse=True)
c=0
for i in range(k):
    h.pop(0)

for i in range(len(h)):
    c+=h[i]
print(c)
Problem p02829 (python)

Fixed submission:
A=[1,2,3]
a=int(input())
b=int(input())
A.remove(a)
A.remove(b)
print(A[0])

Buggy submission (verdict: Runtime Error):
N=int(input())
if N%2 == 1:
    print(0)
else:
    d = 5
    count=0
    while N>1:
        n = N
        while n%d == 0:
            count+=1
            n/=d
    N-=2
print(count)
Problem p02835 (python)

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

if sum >= 22:
    print('bust')
else:
    print('win')

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

if 22 <= sum:
    print('bust')
else:
    print('win')

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

if sum >= 22:
    print('bust')
else:
    print('win')
Problem p02836 (python)

Fixed submission:
S = input()
len_S = len(S)
c = 0
s = len_S // 2
for i in range(s):
    if S[i] is not S[len_S-1 -i]:
        c += 1
print(c)

Buggy submission (verdict: Runtime Error):
S = input()
len_S = len(S)
c = 0
s = len_S // 2
for i in range(s-1):
    if S[i] == S[len_S -i]:
        c += 1
cal = s - c
print(cal)

Buggy submission (verdict: Runtime Error):
S = input()
len_S = len(S)
c = 0
s = len_S // 2
for i in range(s):
    if S[i] == S[len_S -i]:
        c += 1
cal = s - c
print(cal)
Problem p02699 (python)

Fixed submission:
import sys

def solve():
    i = input()
    s, w = i.split()
    s = int(s)
    w = int(w)
    
    if (w >= s):
        print('unsafe')
    else :
        print('safe')
    
    return 

if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):

def solve():
    s = int(input())
    w = int(input())
    
    if (w >= s):
        print('unsafe')
    else :
        print('safe')
    
    return 

if __name__ == '__main__':
    solve()
Problem p02773 (python)

Fixed submission:
n = int(input())

s = {}
for i in range(n):
    temp = input()
    if temp in s:
        s[temp] += 1
    else:
        s[temp] = 1



max_s_val = max(s.values())
t = [k for k, v in s.items() if v == max_s_val]
t.sort()

for i in range(len(t)):
    print(t[i])

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

s = {}
for i in range(n):
    temp = input()
    if temp in s:
        s[temp] += 1
    else:
        s[temp] = 1



max_s_val = max(s.value())
t = [k for k, v in s.items() if v == max_s_val]
t.sort()

for i in range(len(t)):
    print(t[i])
Problem p02831 (python)

Fixed submission:
import fractions

def solve():
    a, b = map(int, input().split())
    ans = a * b / fractions.gcd(a, b)
    print(int(ans))

if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
import math

def solve():
    a, b = map(int, input().split())
    ans = a * b / math.gcd(a, b)
    print(int(ans))

if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
import math

def solve():
    a, b = map(int, input().split())
    ans = a * b / math.gcd(a, b)
    print(int(ans))

if __name__ == '__main__':
    solve()
Problem p02594 (python)

Fixed submission:
x = int(input())

if x >=30 :
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
int(raw_input())
if x >30 :
    print('Yes')
else:
    print('No')
Problem p02682 (python)

Fixed submission:
ls = list(map(int, input().split()))
nokori = ls[-1]
nokori_ = ls[-1]
sum_max = 0
for i, j in zip(ls[:-1], [1, 0, -1]):
    nokori -= i
    if nokori > 0:
        sum_max += i*j
    elif nokori == 0:
        sum_max += i*j
        break
    else:
        sum_max += nokori_*j
        break
    nokori_ = nokori
print(sum_max)

Buggy submission (verdict: Runtime Error):
ls = list(map(int, input().split()))
nokori = ls[-1]
sum_max = 0
for i, j in zip(ls[:-1], [1, 0, -1]):
    nokori -= i
    if nokori > 0:
        sum_max += i*j
    elif nokori == 0:
        sum_max += i*j
        break
    else:
        sum_max += nokori_*j
        break
    nokori_ = nokori
print(sum_max)

Buggy submission (verdict: Runtime Error):
ls = list(map(int, input().split()))
nokori = ls[-1]
sum_max = 0
for i, j in zip(ls[:-1], [1, 0, -1]):
    nokori -= i
    if nokori >= 0:
        sum_max += i*j
    else:
        sum_max += nokori_*j
        break
    nokori_ = nokori
print(sum_max)

Buggy submission (verdict: Runtime Error):
ls = list(map(int, input().split()))
check = 0
for i, j in zip(ls[:-1], [1, 0 -1]):
    check+=i
    nokori = ls[-1] - check
    if check =< ls[-1]:
        sum_max += i*j
    else:
        sum_max += nokori*j
        break

print(sum_max)
Problem p02832 (python)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]
k = 0
flg = False
for ai in a:
  if ai == k + 1:
    k += 1
  else:
    flg = True
if k == 0 and flg:
  print(-1)
else:
  print(n - k)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]
k = 0
for _ in range(n):
  if a[k] == k+1:
    k += 1
  else:
    del a[k]
  print(a, k)
if k == 0:
  print(-1)
else:
  print(n - k)
Problem p02859 (python)

Fixed submission:
r = int(input())
print(r**2)

Buggy submission (verdict: Runtime Error):
mod = 10 ** 9 + 7
x, y = [int(i) for i in input().split()]
if (2*x - y) % 3 != 0 or (2*y - x) % 3 != 0:
  print(0)
a = (2*x - y) // 3
b = (2*y - x) // 3
def mygcd(a_b, b, mod):
    b = min(a_b, b)
    cnt = 1
    for i in range(b):
        cnt = cnt * (a_b - i) * pow(i+1, mod-2, mod) % mod
    return cnt
print(mygcd(a+b, b, mod))
Problem p02596 (python)

Fixed submission:
K = int(input())
a = 7
count = 1
for i in range(K):
    if a % K == 0:
        break
    a = (a * 10 + 7) % K
    count += 1
if count == K + 1:
    print(-1)
else:
    print(count)

Buggy submission (verdict: Runtime Error):
K = int(input())
if K % 2 == 0:
    print(-1)
else:
    a = 7
    count = 1
    while True:
        if a % K == 0:
            break
        a = (a * 10) + 7
        count += 1
print(count)
Problem p02633 (python)

Fixed submission:
import math
x = int(input())
s =  x * 360 / math.gcd(x, 360)
print(int(s//x))

Buggy submission (verdict: Runtime Error):
x = int(input())
s =  x * 360 / math.gcd(x, 360)
print(s/x)

Buggy submission (verdict: Runtime Error):
x = int(input())
s = x * 360/ gcd(x,360)
print(s/x)
Problem p02693 (python)

Fixed submission:
def main():
  k = int(input())
  a, b = map(int,input().split())
  for i in range(a, b+1):
    if i%k ==0:
      print('OK')
      return
  print('NG')
  return
 
main()

Buggy submission (verdict: Runtime Error):
  k = int(input())
  a, b = map(int,input().split())
  for i in range(a, b):
    if i%k ==0:
      print('OK')
      return
    print('NG')
  return

Buggy submission (verdict: Runtime Error):
k = int(input())
a, b = int(input())
if k <= b-a+1:
  print('Yes')
else:
  print('No')
Problem p02771 (python)

Fixed submission:

A, B, C = map(int,input().split())
if A == B and B != C:
  print('Yes')
elif C == B and C != A:
  print('Yes')
elif A == C and C != B:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
A, B, C = map(int,input().split())
if A == B and B != C:
    print('Yes')
elif C == B and C != A:
    print('Yes')
elif A == C and C != B:
    print('Yes')
else('No')

Buggy submission (verdict: Runtime Error):
A, B, C = map(int,input().split())
if A = B and B != C:
    print('Yes')
elif C = B and C != A:
    print('Yes')
elif A = C and C != B:
    print('Yes')
else('No')
Problem p02836 (python)

Fixed submission:
S = input()
hug = 0
if len(S) % 2 == 0:
  for i in range(int(len(S)/2)):
    if not S[i] == S[-i-1]:
      hug += 1
    else:
      pass
else:
  for i in range(int((len(S)+1)/2)):
    if not S[i] ==S[-i-1]:
      hug += 1
    else:
      pass
print(hug)

Buggy submission (verdict: Runtime Error):
S = input()
hug = 0
if len(S) % 2 == 0:
  for i in range(len(S/2)):
    if not S[i] == S[-i-1]:
      hug += 1
    else:
      pass
else:
  for i in range(int((len(S)+1)/2)):
    if not S[i] ==S[-i-1]:
      hug += 1
    else:
      pass
print(hug)

Buggy submission (verdict: Runtime Error):
S = input()
hug = 0
if len(S) % 2 == 0:
  for i in range(len(S/2)):
    if not S[i] == S[-i-1]:
      hug += 1
    else:
      pass
else:
  for i in range(len((S+1)/2)):
    if not S[i] ==S[-i-1]:
      hug += 1
    else:
      pass
print(hug)
Problem p02959 (python)

Fixed submission:
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    n = int(input())
    a_list = li()
    b_list = li()

    monster = 0
    for index in range(n):
        monster_add = min(a_list[index], b_list[index])
        monster = monster + monster_add
        a_list[index] = a_list[index] - monster_add
        b_list[index] = b_list[index] - monster_add

        monster_add = min(a_list[index + 1], b_list[index])
        monster = monster + monster_add
        a_list[index + 1] = a_list[index + 1] - monster_add
        b_list[index] = b_list[index] - monster_add
    print(monster)

Buggy submission (verdict: Runtime Error):
import numpy


def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    n = int(input())
    a_list = li()
    b_list = li()
    # i0_list = []
    # for a, b in zip(a_list[:n], b_list):
    #     i0_list.append(min(a, b))
    # i1_list = []
    # for a, b in zip(a_list[1:], b_list):
    #     i1_list.append(min(a, b))
    # i0_cum = numpy.cumsum(i0_list).tolist()
    # tmp = [0]
    # tmp.extend(i0_cum)
    # i0_cum = tmp
    # i1_cum = numpy.cumsum(i1_list[::-1]).tolist()
    # tmp = [0]
    # tmp.extend(i1_cum)
    # i1_cum = tmp[::-1]
    #
    # print(i0_cum)
    # print(i1_cum)
    # max_val = 0
    # for i0, i1 in zip(i0_cum, i1_cum):
    #     if i0 + i1 > max_val:
    #         max_val = i0 + i1
    # print(max_val)

    monster = 0
    for index in range(len(b_list)):
        monster_add = min(a_list[index], b_list[index])
        monster = monster + monster_add
        a_list[index] = a_list[index] - monster_add
        b_list[index] = b_list[index] - monster_add

        monster_add = min(a_list[index + 1], b_list[index])
        monster = monster + monster_add
        a_list[index] = a_list[index + 1] - monster_add
        b_list[index] = b_list[index] - monster_add
    print(monster)

# 尺取り的に全部求められる？
# iの場合とi+1の場合を全て計算して累積和を使えばいけそう
Problem p03013 (python)

Fixed submission:
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    [n, m] = li()
    broken = [int(input()) for _ in range(m)]
    mod = 10 ** 9 + 7

    pattern = [0] * (n + 1)
    pattern[0] = 1
    broken_index = 0
    checking = broken[broken_index] if len(broken) > broken_index else -1
    if checking != 1:
        pattern[1] = 1
    else:
        pattern[1] = 0
        broken_index = broken_index + 1
        checking = broken[broken_index] if len(broken) > broken_index else -1

    for i in range(2, n + 1):
        if checking != i:
            pattern[i] = (pattern[i - 2] + pattern[i - 1]) % mod
        else:
            pattern[i] = 0
            broken_index = broken_index + 1
            checking = broken[broken_index] if len(broken) > broken_index else -1
    print(pattern[n])

Buggy submission (verdict: Runtime Error):
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    [n, m] = li()
    broken = [int(input()) for _ in range(m)]

    pattern = [0] * (n + 1)
    pattern[0] = 1
    pattern[1] = 1 if broken[0] != 1 else 0
    for i in range(2, n + 1):
        if broken.count(i) == 0:
            pattern[i] = (pattern[i - 2] + pattern[i - 1]) % (10 ** 9 + 7)
        else:
            pattern[i] = 0
    print(pattern[-1])
Problem p03018 (python)

Fixed submission:
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    s = input()
    ope_num = 0
    index = 0
    a_stock = 0
    b_stock = 0
    s = list(s)
    while index < len(s):
        # print(s)
        # print(index)
        # print(ope_num)
        # print()
        si = s[index]
        if si == "A":
            if b_stock > 0:
                a_stock = 1
            else:
                a_stock = a_stock + 1
            b_stock = 0
        elif a_stock > 0:
            if b_stock == 0:
                if si == "B":
                    b_stock = 1
                else:
                    a_stock = 0
                    b_stock = 0
            elif si == "C":
                ope_num = ope_num + a_stock
                # s[index - 2 - a_stock + 1] = "B"
                # s[index - 1 - a_stock + 1] = "C"
                # s[index] = "A"
                # index = index - 1
                a_stock = a_stock
                b_stock = 0
            else:
                a_stock = 0
                b_stock = 0
        else:
            a_stock = 0
            b_stock = 0
        index = index + 1
    print(ope_num)

# ABCの数
# ABCの前にあるAの分だけ追加で操作できる
# ABCの後にある(BC)の分だけ追加で操作できる

# Aがあれば覚えておく
# ABCと来たら、それより前側に隣接しているAの回数だけ追加で操作できる
# 見つかったABCをBCAに置き換える
# BCAのAから走査を継続する

Buggy submission (verdict: Runtime Error):
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    s = input()
    ope_num = 0
    index = 0
    a_stock = 0
    b_stock = 0
    s = list(s)
    while index < len(s):
        si = s[index]
        # print(index)
        # print(si)
        # print(a_stock)
        # print(b_stock)
        # print(ope_num)
        # print()
        if si == "A":
            if b_stock > 0:
                b_stock = 0
                a_stock = 1
            else:
                a_stock = 1
        elif si == "B" and a_stock > 0 and b_stock == 0:
            b_stock.append(si)
        elif si == "C" and a_stock > 0 and b_stock > 0:
            ope_num = ope_num + 1
            s[index - 2] = "B"
            s[index - 1] = "C"
            s[index] = "A"
            a_stock = 0
            b_stock = 0
            if index - 4 >= -1:
                index = index - 4
            else:
                index = index - 1
        else:
            a_stock = 0
            b_stock = 0
        index = index + 1
    print(ope_num)

# ABCの数
# ABCの前にあるAの分だけ追加で操作できる
# ABCの後にある(BC)の分だけ追加で操作できる

# Aがあれば覚えておく
# ABCと来たら、それより前側に隣接しているAの回数だけ追加で操作できる
# 見つかったABCをBCAに置き換える
# BCAのAから走査を継続する
Problem p03038 (python)

Fixed submission:
if __name__ == '__main__':
    [n, m] = list(map(int, input().split()))
    a = list(map(int, input().split()))
    bc = [list(map(int, input().split())) for _ in range(m)]

    a.sort()
    bc.sort(key=lambda x: x[1], reverse=True)

    index = 0
    for b, c in bc:
        if index >= len(a) or c <= a[index]:
            break
        for _ in range(b):
            if index < len(a) and c > a[index]:
                a[index] = c
                index = index + 1
            else:
                break

    # print(a)
    print(sum(a))

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
    [n, m] = list(map(int, input().split()))
    a = list(map(int, input().split()))
    bc = [list(map(int, input().split())) for _ in range(m)]

    a.sort()
    bc.sort(key=lambda x: x[1], reverse=True)

    index = 0
    for b, c in bc:
        if c <= a[index]:
            break
        for _ in range(b):
            if c > a[index]:
                a[index] = c
                index = index + 1
            else:
                break

    # print(a)
    print(sum(a))
Problem p02676 (python)

Fixed submission:
K = int(input())
S = input()
if len(S) > K:
  print(S[:K]+"...")
else:
  print(S)

Buggy submission (verdict: Runtime Error):
k = int(input())
S = input()
if len(S) > K:
  print(S[:K]+"...")
else:
  print(S)

Buggy submission (verdict: Runtime Error):
k = int(input())
S = input()
if len(S) > K:
  print(S[:K])
else:
  print(S)
Problem p02833 (python)

Fixed submission:
N = int(input())
num = 10
cnt = 0
if N%2!=0:
  print(0)
  exit()
for i in range(1, N+1):
  cnt += N//num
  num = num*5
  if num > N:
    break
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = str(N)[0]+"0"
if N%2==1:
  print(0)
else:
  if N >= 24:
    print(int(a)**(len(str(N))-2)+25*10**(len(str(N))-4)-5)
  else:
    print(int(a)**(len(str(N))-2))

Buggy submission (verdict: Runtime Error):
N = int(input())
a = str(N)[0]+"0"
if N%2==1:
  print(0)
else:
  if N >= 24:
    print(int(a)**(len(str(N))-1)+25*10**(len(str(N))-3)-5)
  else:
    print(int(a)**(len(str(N))-2))
Problem p02860 (python)

Fixed submission:
n = int(input())
s = input()
if n % 2 == 1:
  print("No")
else:
  s1 = s[:(n//2)]
  s2 = s[(n//2):]
  if s1 == s2:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
if n % 2 == 1:
  print("No")
else:
  s1 = s[:n/2+1]
  s2 = s[n/2+1:]
  if s1 == s2:
    print("Yes")
  else:
    print("No")
Problem p02862 (python)

Fixed submission:
X, Y = map(int,input().split())
n = int((2*Y-X)/3)
m = int((2*X-Y)/3)
if (X+Y)%3!=0:
  print(0)
  exit()
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
p = 10 ** 9 + 7
N = 10 ** 6  
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
print(cmb(n+m, n, p))

Buggy submission (verdict: Runtime Error):
import math
X, Y = map(int,input().split())
n = (2*Y-X)//3
m = (2*X-Y)//3
if n < 0 or m < 0:
  print(0)
else:
  print((math.factorial(n+m)/(math.factorial(n)*math.factorial(m)))%(10**9+7))
Problem p02879 (python)

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

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
n1 = int(math.sqrt(n))
cnt = 10**18
for i in range(1, n1+1):
  if n % i == 0:
      j = (n/i) - 1
      ans = i-1
      cnt = min(cnt, j+ans)
  else:
    continue
print(int(cnt))
Problem p03038 (python)

Fixed submission:
N, M = map(int,input().split())
A = sorted([int(i) for i in input().split()])
BC = [list(map(int,input().split())) for i in range(M)]
BC = sorted(BC, key=lambda x: x[1])[::-1]
ind = 0
for b, c in BC:
  for i in range(b):
    if A[ind] < c:
      A[ind] = c
      ind += 1
      if ind == N:
        print(sum(A))
        exit()
    else:
      break
print(sum(A))

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
A = sorted([int(i) for i in input().split()])
BC = [list(map(int,input().split())) for i in range(M)]
BC = sorted(BC, key=lambda x: x[1])[::-1]
ind = 0
for b, c in BC:
  for i in range(b):
    if A[ind] <= c:
      A[ind] = c
      ind += 1
    else:
      break  
print(sum(A))

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
A = sorted([int(i) for i in input().split()])
BC = [list(map(int,input().split())) for i in range(M)]
BC = sorted(BC, key=lambda x: x[1])[::-1]
ind = 0
for b, c in BC:
  for i in range(b):
    if A[ind] < c:
      A[ind] = c
      ind += 1
    else:
      break
print(sum(A))
Problem p03077 (python)

Fixed submission:
import math
n = int(input())
l = [int(input()) for i in range(5)]
print(math.ceil(n/min(l))+4)

Buggy submission (verdict: Runtime Error):
x, y, z, k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list((map(int,input().split())))
D = []
E = []
for i in range(x):
  for j in range(y):
    D.append(A[i]+B[j])
D.sort()
for i in range(z):
  for j in range(min(len(D),k)):
    E.append(C[i]+D[::-1][j])
print("\n".join(map(str,sorted(E)[::-1][:k])))
Problem p03107 (python)

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

Buggy submission (verdict: Runtime Error):
a = input()
sum = 0
i = 0
while True:
  if a[i] == "0" and a[i+1] == "1" and i < len(a)-2 and len(a) > 2:
    sum += 2
    a = a[:i] + a[i+2:]
    i = 0
  elif a[i] == "1" and a[i+1] == "0" and i < len(a)-2 and len(a) > 2:
    sum += 2
    a = a[:i] + a[i+2]
    i = 0
  elif a[i] == "0" and a[i+1] == "1" and i == len(a)-2 and len(a) > 2:
    sum += 2
    a = a[:i]
    i = 0
  elif a[i] == "1" and a[i+1] == "0" and i == len(a)-2 and len(a) > 2:
    sum += 2
    a = a[:i]
    i = 0
  elif len(a) == 2 and a[i] == "0" and a[i+1] == "1":
    sum += 2
    break
  elif len(a) == 2 and a[i] == "1" and a[i+1] == "0":
    sum += 2
    break
  else:
    i += 1
    pass
  
print(sum)

Buggy submission (verdict: Runtime Error):
a = input()
sum = 0
for i in range(len(a)):
  if a[i] == "0" and a[i+1] == "1" and i < len(a-2):
    sum += 2
    a = a[:i] + a[i+2:]
  elif a[i] == "1" and a[i+1] == "0" and i < len(a-2):
    sum += 2
    a = a[:i] + a[i+2]
  elif a[i] == "0" and a[i+1] == "1" and i == len(a-2):
    sum += 2
    a = a[:i]
  elif a[i] == "1" and a[i+1] == "0" and i == len(a-2):
    sum += 2
    a = a[:i]
  else:
    pass
print(sum)