Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,m,k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

counter = 0
ans = 0

for i in range(n+1):
    if sum(A[:i])>k:
        break
    for j in range(m+1):
        if sum(A[:i])+sum(B[:j])<=k:
            ans = max(ans, i+j)
        else:
            break
            
print(ans)

Fixed submission:
import bisect

n,m,k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A_cum = [0]
B_cum = [0]

for i in range(n):
  A_cum.append(A_cum[i]+A[i])
  
for i in range(m):
  B_cum.append(B_cum[i]+B[i])

ans = 0  
for i in range(n+1):
  rest = k-A_cum[i]
  if rest<0:
    continue
  
  ans = max(ans, bisect.bisect_right(B_cum, rest)-1+i)
  
print(ans)

Buggy python submission (verdict: Runtime Error):
counter = 0
ans = 0

for i in range(n+1):
    if sum(A[:i])>k:
        break
    for j in range(m+1):
        if sum(A[:i])+sum(B[:j])<=k:
            ans = max(ans, i+j)
        else:
            break
            
print(ans)

Fixed submission:
import bisect

n,m,k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A_cum = [0]
B_cum = [0]

for i in range(n):
  A_cum.append(A_cum[i]+A[i])
  
for i in range(m):
  B_cum.append(B_cum[i]+B[i])

ans = 0  
for i in range(n+1):
  rest = k-A_cum[i]
  if rest<0:
    continue
  
  ans = max(ans, bisect.bisect_right(B_cum, rest)-1+i)
  
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())

a = int(pow(x, 1/5))

while True:
    if pow(a,5)-x<0:
      b = -int(pow(-(a**5-x), 1/5))
    else:
      b = int(pow((a**5-x), 1/5))
      
    if pow(a,5)-pow(b,5)==x:
      break
    a += 1

print(a, b)

Fixed submission:
x = int(input())
found = False
a = 0
b = 0

for i in range(-200, 201):
  for j in range(-200, 201):
    if i**5-j**5==x:
      found = True
      a = i
      b = j
  if found:
    break
    
print(a, b)

Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())

a = int(pow(x, 1/5))

while True:
    if a**5-x<0:
      b = -int(pow(-(a**5-x), 1/5))
    else:
      b = int(pow((a**5-x), 1/5))
      
    if a**5-b**5==x:
      break
    a += 1

print(a, b)

Fixed submission:
x = int(input())
found = False
a = 0
b = 0

for i in range(-200, 201):
  for j in range(-200, 201):
    if i**5-j**5==x:
      found = True
      a = i
      b = j
  if found:
    break
    
print(a, b)

Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())

for i in range(1, int(x**0.5)+1):
  if x%i==0:
    y = i
    z = x//i
    
    a = int(x**(1/5))
    ans = False
    
    while True:
      if a**5-(a-y)**5==x:
        ans = True
        b = a-y
        break
      if a**5-(a-z)**5==x:
        ans = True
        b = a-z
        break
      if a^5-(a-z)^5>x and a^5-(a-z)^5>x:
        break
      a += 1
    
    if ans:
      break
      
print(a, b)

Fixed submission:
x = int(input())
found = False
a = 0
b = 0

for i in range(-200, 201):
  for j in range(-200, 201):
    if i**5-j**5==x:
      found = True
      a = i
      b = j
  if found:
    break
    
print(a, b)

Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())

for i in range(1, int(x**0.5)+1):
  if x%i==0:
    y = i
    z = x//i
    
    a = 1
    ans = False
    
    while True:
      if a**5-(a-y)**5==x:
        ans = True
        b = a-y
        break
      if a**5-(a-z)**5==x:
        ans = True
        b = a-z
        break
      if a^5-(a-z)^5>x and a^5-(a-z)^5>x:
        break
      a += 1
    
    if ans:
      break
      
print(a, b)

Fixed submission:
x = int(input())
found = False
a = 0
b = 0

for i in range(-200, 201):
  for j in range(-200, 201):
    if i**5-j**5==x:
      found = True
      a = i
      b = j
  if found:
    break
    
print(a, b)
Buggy python submission (verdict: Runtime Error):
a,b,n = map(int, input().split())

if b-1>n:
  x = n
else:
  x = (b-1)*(n//(b-1))

ans = max(a*x//b-a*(x//b), a*n//b-a*(n//b))

print(ans)

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

if b==1:
  print(0)
else:  
  if b-1>n:
    x = n
  else:
    x = (b-1)*(n//(b-1))

  ans = max(a*x//b-a*(x//b), a*n//b-a*(n//b))

  print(ans)

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

if b-1>n:
  start = n
else:
  start = (b-1)*(n//(b-1))

ans = 0

for i in range(start, n+1):
  ans = max(ans, (a*i//b)-a*(i//b))

print(ans)

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

if b==1:
  print(0)
else:  
  if b-1>n:
    x = n
  else:
    x = (b-1)*(n//(b-1))

  ans = max(a*x//b-a*(x//b), a*n//b-a*(n//b))

  print(ans)
Buggy python submission (verdict: Runtime Error):
n = input()
ans = 0

for i in range(1, n+1):
  if i%3!=0 and i%5!=0:
    ans += i
    
print(ans)

Fixed submission:
n = int(input())
ans = 0

for i in range(1, n+1):
  if i%3!=0 and i%5!=0:
    ans += i
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd

n = int(input())
temp = []
ans = 0

for i in range(1, n+1):
    for j in range(1, n+1):
      temp.append(gcd(i,j))

for temp_i in temp:
  for k in range(1, n+1):
    ans += gcd(temp_i, k)
    
print(ans)

Fixed submission:
from fractions import gcd
from collections import defaultdict

n = int(input())
temp = defaultdict(int)
ans = 0

for i in range(1, n+1):
    for j in range(1, n+1):
      x = gcd(i,j)
      temp[x] += 1

for k,v in temp.items():
  for w in range(1, n+1):
    ans += gcd(k,w)* v

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd

n = int(input())
ans = 0

for i in range(1, n+1):
    for j in range(1, n+1):
        for k in range(1, n+1):
            x = gcd(i,j)
            ans += gcd(x,k)
            
print(ans)

Fixed submission:
from fractions import gcd
from collections import defaultdict

n = int(input())
temp = defaultdict(int)
ans = 0

for i in range(1, n+1):
    for j in range(1, n+1):
      x = gcd(i,j)
      temp[x] += 1

for k,v in temp.items():
  for w in range(1, n+1):
    ans += gcd(k,w)* v

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd

n = int(input())
ans = 0

for i in range(1, n+1):
    for j in range(1, n+1):
        for k in range(1, n+1):
            temp = gcd(i,j)
            ans += gcd(temp, k)
            
print(ans)

Fixed submission:
from fractions import gcd
from collections import defaultdict

n = int(input())
temp = defaultdict(int)
ans = 0

for i in range(1, n+1):
    for j in range(1, n+1):
      x = gcd(i,j)
      temp[x] += 1

for k,v in temp.items():
  for w in range(1, n+1):
    ans += gcd(k,w)* v

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd

n = int(input())
ans = 0

for i in range(1, n+1):
    for j in range(1, n+1):
        for k in range(1, n+1):
            temp = gcd(i,j)
            ans += gcd(temp, k)
            
print(ans)

Fixed submission:
from fractions import gcd
from collections import defaultdict

n = int(input())
temp = defaultdict(int)
ans = 0

for i in range(1, n+1):
    for j in range(1, n+1):
      x = gcd(i,j)
      temp[x] += 1

for k,v in temp.items():
  for w in range(1, n+1):
    ans += gcd(k,w)* v

print(ans)
Buggy python submission (verdict: Runtime Error):
import sympy

a,b,c=map(int, input().split())
print('Yes' if sympy.sqrt(a) + sympy.sqrt(b) < sympy.sqrt(c) else 'No')

Fixed submission:
a,b,c=map(int, input().split())
print('Yes' if (c-a-b)>0 and 4*a*b < (c-a-b)**2 else 'No')
Buggy python submission (verdict: Runtime Error):
n,a,b = map(int, input().split())

s = 'b'*a+'r'*b
x = n//(a+b) 
y = n%(a+b) 

print(x*a+s[:y].count('b'))

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

ans = n//(a+b)*a 
x = n%(a+b) 

if x<=a:
  ans += x
else:
  ans += a

print(ans)

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

s = 'b'*a+'r'*b
x = n//(a+b) 
y = n%(a+b) 

print(x*a+s[y-1].count('b'))

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

ans = n//(a+b)*a 
x = n%(a+b) 

if x<=a:
  ans += x
else:
  ans += a

print(ans)

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

s = 'b'*a+'r'*b
ind = n%(a+b) 

print(s[ind-1])

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

ans = n//(a+b)*a 
x = n%(a+b) 

if x<=a:
  ans += x
else:
  ans += a

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

s = input()
q = int(input())

d = deque(s)

for _ in range(q):
  Q = list(input().split())
  
  if Q[0]=='1':
    d = deque(reversed(d))
  elif Q[0]=='2':
    if Q[1]=='1':
      d.appendleft(Q[2])
    elif Q[1]=='2':
      d.append(Q[2])

print(*d, sep='')

Fixed submission:
from collections import deque

s = input()
q = int(input())

d = deque(s)
inv = 0

for _ in range(q):
  Q = list(input().split())
  
  if Q[0]=='1':
    inv += 1
  elif Q[0]=='2':
    if Q[1]=='1':
      if inv%2==0:
        d.appendleft(Q[2])
      else:
        d.append(Q[2])
    elif Q[1]=='2':
      if inv%2==0:
        d.append(Q[2])
      else:
        d.appendleft(Q[2])

if inv%2==0:
  print(*d, sep='')
else:
  print(*deque(reversed(d)), sep='')
Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split())
s_1 = str(a)*b
s_2 = str(b)*a

print(_1 if s_1<=s_2 else s_2)

Fixed submission:
a,b = map(int, input().split())
s_1 = str(a)*b
s_2 = str(b)*a

print(s_1 if s_1<=s_2 else s_2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
i = 1
count = 0

while A:
  a = A.pop(0)
  if i != a:
    count += 1
  else:
    i += 1
    
print(-1 if count == n else count)

Fixed submission:
from collections import deque

n = int(input())
A = deque(map(int, input().split()))
i = 1
count = 0

while A:
  a = A.popleft()
  if i != a:
    count += 1
  else:
    i += 1
    
print(-1 if count == n else count)
Buggy python submission (verdict: Time Limit Exceeded):
import re

n = int(input())
s = input()

check_list = []

for i in range(0,10):
  for j in range(0,10):
    for k in range(0,10):
      check_list.append(str(i)+'.*'+str(j)+'.*'+str(k))
  
counter = 0  
for c in check_list:
  if re.findall(c, s):
    counter += 1
      
print(counter)

Fixed submission:
from itertools import product

n = int(input())
s = input()

X = [[str(a),str(b),str(c)] for a,b,c in product(range(10), repeat=3)]
s_index = {s_i:[] for s_i in s}

for i, s_i in enumerate(s):
  s_index[s_i].append(i)

counter = 0
  
for x in X:
  ind_pos = -1
  check = True
  for x_i in x:
    if x_i not in s_index.keys():
      check = False
      break
    else:
      ind_list = [i for i in s_index[x_i] if i>ind_pos]
      if ind_list:
        ind_pos = min(ind_list)
      else:
        check = False
        break
  if check: counter += 1
    
print(counter)
Buggy python submission (verdict: Runtime Error):
x = int(input())
cand_list = []

for i in range(1, int(x**(1/2))):
    if x%i==0:
      cand_list.append([i, x//i])
        
print(min([sum(cand_i)-2 for cand_i in cand_list]))

Fixed submission:
x = int(input())
cand_list = []

for i in range(1, int(x**(1/2))+1):
    if x%i==0:
      cand_list.append([i, x//i])

ans = min([sum(cand_i)-2 for cand_i in cand_list])
if x == 2:
  ans = 1
elif x == 3:
  ans = 2

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a, b = map(int, input().split())

a_set = set()
b_set = set()

i = 2
while a!=1:
  if a%i==0:
    while a%i==0: 
      a//=i
    a_set.add(i)
  i+=1

i = 2
while b!=1:
  if b%i==0:
    while b%i==0: 
      b//=i
    b_set.add(i)
  i+=1  
  
print(len(a_set&b_set)+1)

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

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

print(len(set(factorize(a))&set(factorize(b)))+1)

Buggy python submission (verdict: Time Limit Exceeded):
a, b = map(int, input().split())

ans_list =[]

for i in range(1, min(a, b)+1):
  
  if a%i==0 and b%i==0:
    ans_list.append(i)
    a //= i
    b //= i

print(len(ans_list))

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

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

print(len(set(factorize(a))&set(factorize(b)))+1)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
 
n, k, q = map(int, input().split())
 
members_p = np.array([k for _ in range(n)])
 
for _ in range(q):
  a = int(input()) 
  temp = np.zeros(n)
  temp[a-1] = 1
  members_p = members_p - 1 + temp
 
  # print(members_p)
 
res_list = ['Yes' if member_p > 0 else 'No' for member_p in members_p]
print(*res_list, sep = '\n')

Fixed submission:
n, k, q = map(int, input().split())

members_p = list(k-q for _ in range(n))
a_list = []

for _ in range(q):
  a_list.append(int(input()))
  
for i in range(q):
  target_index = a_list[i]-1
  members_p[target_index] += 1

res = ['Yes' if member > 0 else 'No' for member in members_p]  
  
print(*res, sep = '\n')
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())

item_list = list(map(int, input().split()))

for discount_i in range(m):
  max_item = max(item_list)
  target_index = item_list.index(max_item)
  item_list[target_index] = item_list[target_index]//2
  
print(sum(item_list))

Fixed submission:
import heapq

n, m = map(int, input().split())

item_list = list(map(lambda x: -1 * int(x), input().split()))
heapq.heapify(item_list)

for discount_i in range(m):
  target = -1*(-1*heapq.heappop(item_list)//2)
  heapq.heappush(item_list, target)

print(-1*sum(item_list))

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())

item_list = list(map(int, input().split()))

for discount_i in range(m):
  max_item = max(item_list)
  target_index = item_list.index(max_item)
  item_list[target_index] = item_list[target_index]//2
  
print(sum(item_list))

Fixed submission:
import heapq

n, m = map(int, input().split())

item_list = list(map(lambda x: -1 * int(x), input().split()))
heapq.heapify(item_list)

for discount_i in range(m):
  target = -1*(-1*heapq.heappop(item_list)//2)
  heapq.heappush(item_list, target)

print(-1*sum(item_list))
Buggy python submission (verdict: Time Limit Exceeded):
print(sum(range(1, int(input()))))

Fixed submission:
n = int(input())

print(n*(n-1) // 2)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

print(sum(range(1, n)))

Fixed submission:
n = int(input())

print(n*(n-1) // 2)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

print(sum(range(1, n + 1)) - n)

Fixed submission:
n = int(input())

print(n*(n-1) // 2)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

num_list = [i+1 for i in range(n)]

print(sum(num_list) - n)

Fixed submission:
n = int(input())

print(n*(n-1) // 2)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

num_list = [i+1 for i in range(n)]

best_ans = 0

for i in range(n - 1):
  best_ans += num_list[i] % num_list[i + 1]

print(best_ans)

Fixed submission:
n = int(input())

print(n*(n-1) // 2)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

num_list = [i+1 for i in range(n)]

div_list = num_list[1:]
div_list.append(num_list[0])

best_ans = 0

for i in range(n):
  best_ans += (num_list[i] % div_list[i])


print(best_ans)

Fixed submission:
n = int(input())

print(n*(n-1) // 2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

string_list = [''.join(sorted(input())) for i in range(n)]

counter = 0

for i in range(n):
  str_i = string_list[i]
  for j in range(i + 1, n):
    str_j = string_list[j]
    if str_i == str_j:
      counter += 1

print(counter)

Fixed submission:
n = int(input())

string_list = [''.join(sorted(input())) for i in range(n)]

word_dict = dict()

counter = 0

for i in range(n):
  word_dict.setdefault(string_list[i], 0)
  word_dict[string_list[i]] += 1
  if word_dict[string_list[i]] != 1:
    counter += word_dict[string_list[i]] - 1
  
print(counter)
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())

trans_amouint = min(b - a, c)
print(c - trans_amount)

Fixed submission:
a, b, c = map(int, input().split())
 
trans_amount = min(a - b, c)
print(c - trans_amount)

Buggy python submission (verdict: Runtime Error):
a, b, c = int(input())
print(c - (a - b))

Fixed submission:
a, b, c = map(int, input().split())
 
trans_amount = min(a - b, c)
print(c - trans_amount)
Buggy python submission (verdict: Runtime Error):
n = int(input())
num_list = list(map(int, input().split()))

ans = 'Yes'

for i in range(n - 1):
  
  if i == 0:
    if num_list[i] > num_list[i + 1]:
    num_list[i] -= 1
  
  if num_list[i] > num_list[i + 1]:
    ans = 'No'
    break
  
  if num_list[i] < num_list[i + 1]:
    num_list[i + 1] -= 1
    
print(ans)

Fixed submission:
n = int(input())
num_list = [int(i) for i in input().split()]
 
answer = "Yes"
 
for i in range(n-1):
  if num_list[i] - num_list[i+1] >= 2:
    answer = "No"
    break
  elif num_list[i] - num_list[i+1] >= 1:
    num_list[i+1] += 1
    
print(answer)
Buggy python submission (verdict: Runtime Error):
n = int(input())
w_list = list(map(int, input().split()))
print(min([abs(s[:i]-s[i:]) for i in range(1, n)]))

Fixed submission:
n = int(input())
w_list = list(map(int, input().split()))
print(min([abs(sum(w_list[:i])-sum(w_list[i:])) for i in range(1, n)]))
Buggy python submission (verdict: Runtime Error):
n,m  = map(int, input().split())
A = set(int(input()) for _ in range(m))
mod = 10**9+7

dp_l = [1, 1]+[-1]*(n-1)

def dp(n):
  if n in A:
    dp_l[n] = 0
  
  if dp_l[n] == -1:
    dp_l[n] = (dp(n-1)+dp(n-2))%mod
  
  return(dp_l[n])

print(dp(n))

Fixed submission:
n,m  = map(int, input().split())
A = set(int(input()) for _ in range(m))
mod = 10**9+7

if 1 in A:
  dp_l = [1, 0] + [0]*(n-1)
else:
  dp_l = [1, 1] + [0]*(n-1)

if n==1:
  print(1)
else:
  for i in range(1, len(dp_l)):
    if i in A:
      dp_l[i] = 0
    else:
      dp_l[i] = (dp_l[i-1]+dp_l[i-2])%mod 
  print(dp_l.pop())

Buggy python submission (verdict: Runtime Error):
n,m  = map(int, input().split())
A = set(int(input()) for _ in range(m))
mod = 10**9+7

dp_l = [-1]*(n+1)

def dp(n):
  if n in A:
    return(0)
  
  if n==0:
    return(1)
  elif n==1:
    return(1)
  
  if dp_l[n] == -1:
    dp_l[n] = (dp(n-1)+dp(n-2))%mod
    return(dp_l[n])
  else:
    return(dp_l[n])
    
print(dp(n))

Fixed submission:
n,m  = map(int, input().split())
A = set(int(input()) for _ in range(m))
mod = 10**9+7

if 1 in A:
  dp_l = [1, 0] + [0]*(n-1)
else:
  dp_l = [1, 1] + [0]*(n-1)

if n==1:
  print(1)
else:
  for i in range(1, len(dp_l)):
    if i in A:
      dp_l[i] = 0
    else:
      dp_l[i] = (dp_l[i-1]+dp_l[i-2])%mod 
  print(dp_l.pop())
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())

for m_i in range(m):
  
  l,r = map(int, input().split())
  if m_i==0:
    ans = set(range(l, r+1))
  else:
    ans &= set(range(l, r+1))
    
print(len(ans))

Fixed submission:
n,m = map(int, input().split())

L = []
R = []

for _ in range(m):
  l,r = map(int, input().split())
  L.append(l)
  R.append(r)
    
print(min(R)-max(L)+1 if min(R)-max(L)>=0 else 0)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n,m = map(int, input().split())
A = sorted(map(int, input().split()))

for _ in range(m):
  b,c = map(int, input().split())
  ind = bisect.bisect_left(A, c)
  A = A[:ind]+[c]*b+A[ind:]

print(sum(A[-n:]))

Fixed submission:
n,m = map(int, input().split())
A = list(map(int, input().split()))
BC = sorted([list(map(int, input().split())) for _ in range(m)], key=lambda x: -x[1])

add = []

for b,c in BC:
  add += [c]*b
  if len(add)>n:
    break
    
ans = sorted(A+add)    
print(sum(ans[-n:]))

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())
A = list(map(int, input().split()))

for _ in range(m):
  b,c = map(int, input().split())
  A.extend([c]*b)

ans = sorted(A, key=lambda x:-x)
print(sum(ans[:n]))

Fixed submission:
n,m = map(int, input().split())
A = list(map(int, input().split()))
BC = sorted([list(map(int, input().split())) for _ in range(m)], key=lambda x: -x[1])

add = []

for b,c in BC:
  add += [c]*b
  if len(add)>n:
    break
    
ans = sorted(A+add)    
print(sum(ans[-n:]))

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())
A = list(map(int, input().split()))

for _ in range(m):
  b,c = map(int, input().split())
  A.extend([c]*b)

ans = sorted(A, key=lambda x:-x)
print(sum(ans[:n]))

Fixed submission:
n,m = map(int, input().split())
A = list(map(int, input().split()))
BC = sorted([list(map(int, input().split())) for _ in range(m)], key=lambda x: -x[1])

add = []

for b,c in BC:
  add += [c]*b
  if len(add)>n:
    break
    
ans = sorted(A+add)    
print(sum(ans[-n:]))
Buggy python submission (verdict: Runtime Error):
dish_list = [int(input()) for _ in range(5)]
last_num_list = [int(str(dish_i)[-1]) for dish_i in dish_list]
target_index =min(list(filter(lambda x: x>0, last_num_list)))

last_num_min_index = last_num_list.index(target_index)
ceiling_dish_list = [-10* (-i//10) for i in dish_list]

print(sum(ceiling_dish_list) - ceiling_dish_list[last_num_min_index] + dish_list[last_num_min_index])

Fixed submission:
dish_list = [int(input()) for _ in range(5)]
last_num_list = [int(str(dish_i)[-1]) for dish_i in dish_list]

if sum(last_num_list) % 10 == 0:
  print(sum(dish_list))
else:  
  target_index = min(list(filter(lambda x: x>0, last_num_list)))

  last_num_min_index = last_num_list.index(target_index)
  ceiling_dish_list = [-10* (-i//10) for i in dish_list]

  print(sum(ceiling_dish_list) - ceiling_dish_list[last_num_min_index] + dish_list[last_num_min_index])
Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split()) 
print(b-a if a%b a+b)


Fixed submission:
a, b = map(int, input().split())
print(b-a if b%a else a+b)

Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split()) 
print(b-a a%b a+b)

Fixed submission:
a, b = map(int, input().split())
print(b-a if b%a else a+b)
Buggy python submission (verdict: Runtime Error):
import functools import reduce
import fractions import gcd

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

print(reduce(gcd, A))

Fixed submission:
from functools import reduce
from fractions import gcd

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

print(reduce(gcd, A))