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

Fixed submission:
n, k = list(map(int, input().split()))
s = list(input())
d = {"A":"a", "B":"b", "C":"c"}
s[k-1] = d[s[k-1]]
print("".join(s))

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

n = int(input())
edges = [[] for _ in range(n + 1)]
for _ in range(n - 1):
	u, v, w = list(map(int, input().split()))
	edges[u].append([v, w % 2])
	edges[v].append([u, w % 2])


bw = [-1 for i in range(n + 1)]
bw[1] = 0

def dfs(frm):
	for ne in edges[frm]:
		if bw[ne[0]] >= 0:
			continue
		else:
			bw[ne[0]] = abs(bw[frm] - ne[1])
			dfs(ne[0])

dfs(1)
for i in range(1, n + 1):
	print(bw[i])
Problem p03631 (python)

Fixed submission:
def main():
	n = int(input())
	a = n // 100
	b = n - (n // 10) * 10
	if a == b:
		print("Yes")
	else:
		print("No")
 
if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
# encoding:utf-8
import sys
 
def main():
	n = int(input())
	vers = [list(map(int, input().split())) for _ in range(n - 1)]
	q, k = list(map(int, input().split()))
	queries = [list(map(int, input().split())) for _ in range(q)]
 
	#n = 10 ** 5
	#vers = [[i + 1, i + 2, 10 ** 9] for i in range(n - 1)]
 
	new_vers = mapping(n, vers)
	dist = calcMinDist(n, new_vers, k, queries)
	calcQueries(dist, queries, k)
	
def mapping(n, vers):
	new_vers = {i :[] for i in range(n)}
	for ver in vers:
		new_vers[ver[0] - 1].append((ver[1], ver[2]))
		new_vers[ver[1] - 1].append((ver[0], ver[2]))
	return new_vers
 
def calcMinDist(n, new_vers, k, queries):
	dist = [- 1 for _ in range(n)]
	flag = [False for _ in range(n)]
	dist[k - 1] = 0
	flag[k - 1] = True
	dfs(new_vers, dist, flag, k)
	return dist
 
def dfs(new_vers, dist, flag, frm):
	flag[frm - 1] = True
	vs = new_vers[frm - 1]
	for v in vs:
		if flag[v[0] - 1] == False:
			dist[v[0] - 1] = dist[frm - 1] + v[1]
			new_ver, dist, flag, _ = dfs(new_vers, dist, flag, v[0])
 
	return [new_vers, dist, flag, frm]
 
def calcQuery(dist, query, k):
	print(dist[query[0] - 1] + dist[query[1] - 1])
 
def calcQueries(dist, queries, k):
	for query in queries:
		calcQuery(dist, query, k)
 
if __name__ == '__main__':
	sys.setrecursionlimit(1000000)
	main()
Problem p03038 (python)

Fixed submission:
from heapq import heappush, heappop, heapify

def main():
    N, M = map(int, input().split())
    A_card = [-int(x) for x in input().split()]

    change_list = []
    for i in range(M):
        B, C = [int(x) for x in input().split()]
        change_list.append(((-1) * C, B))

    hq = []
    for i in range(N):
        heappush(hq, (A_card[i], 1))

    for i in range(M):
        heappush(hq, change_list[i])

    result_sum = 0
    count = 0
    while True:
        if count == N:
            break
        tmp = heappop(hq)
        if count + tmp[1] <= N:
            result_sum += (tmp[0] * tmp[1])
            count += tmp[1]
        else:
            result_sum += (tmp[0] * (N - count))
            break

    print(result_sum * (-1))

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N, M = map(int, input().split())
    A = [int(x) for x in input().split()]
    for m in range(0, M):
        tmp = [int(x) for x in input().split()]
        A.extend([tmp[1]] * tmp[0])

    A = A.sort(A, reverse = True)
    A = A[:N]
    print(sum(A))


if __name__ == "__main__":
    main()
Problem p03834 (python)

Fixed submission:
def main():
    s = input()
    print(s.replace(",", " "))

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <string>
using namespace std;

int main(){
    string input_str;

    cin >> input_str;

    input_str[5] = ' ', input_str[13] = '';

    cout << input_str << endl;

    return 0;
}

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <string>
using namespace std;

int main(){
    string input_str;

    cin >> input_str;

    for (int i=0; i < input_str.size(); i++){
        if (input_str[i] == ',') input_str[i] = ' ';
    }

    cout << input_str << endl;

    return 0;
}
Problem p02682 (python)

Fixed submission:
A,B,C,K= map(int,input().split())

if A >= K:
  print(K)
elif (A+B) >= K:
  print(A)
else:
  nok =K-(A+B)
  print(A-nok)

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

if A >= K:
  print(K)
elif (A+B) >= K
  print(A)
else:
  nok =K-(A+B)
  print(A-nok)
Problem p02699 (python)

Fixed submission:
a,b=map(int,input().split())
if a<=b:
  print('unsafe')
else:
  print('safe')

Buggy submission (verdict: Runtime Error):
a,b=map(int,input.split())
if a<=b:
  print('unsafe')
else:
  print('safe')
Problem p02712 (python)

Fixed submission:
N=int(input())
cnt=0
for i in range(1,N+1):
  if i%3==0:
    continue
  if i%5==0:
    continue
  if i%15==0:
    continue
  else:
    cnt+=i
print(cnt)

Buggy submission (verdict: Runtime Error):
N=int(input()):
cnt=0
for i in range(1,N+1):
  if i%3==0:
    continue
  if i%5==0:
    continue
  if i%15==0:
    continue
  else:
    cnt+=i
print(cnt)
Problem p02725 (python)

Fixed submission:
K,N=map(int,input().split())
A=[int(_) for _ in input().split()]
a=K-A[N-1]+A[0]
for i in range(N-1):
  tmp=A[i+1]-A[i]
  if a<tmp:
    a=tmp

print(K-a)

Buggy submission (verdict: Runtime Error):
K,N=map(int,input().split())
A=[int(_) for _ input().split()]
a=0
for i in range(N-1):
  tmp=A[i+1]-A[i]
  if a<tmp:
    a=tmp
print(K-a)
Problem p02773 (python)

Fixed submission:
import collections
N = int(input())
s = [input() for i in range(N)]
 
counter = collections.Counter(s)
count = counter.most_common()
 
most = count[0][1]
 
c =[]
for i in range(len(count)):
    if count[i][1] == most:
        c.append(count[i][0])
 
c.sort()
 
for i in range(len(c)):
    print(c[i])

Buggy submission (verdict: Runtime Error):
import collections
N=int(input())
S=[input() for i in range(N)]
c=collections.Counter(S)
most=c.most_common()[0][1]
if len(c)==1:
  print(c.most_common()[0][0])
else:
  for i in range(len(c)):
    print(c.most_common()[i][0])
    if c.most_common()[i+1][1] !=most:
      break

Buggy submission (verdict: Runtime Error):
import collections
N=int(input())
S=[input() for i in range(N)]
c=collections.Counter(S)
most=c.most_comon()[0][1]
if len(c)==1:
  print(c.most_common()[0][0])
else:
  for i in range(len(c)):
    print(c.most_common()[i][0])
    if c.most_common()[i+1][1] !=most:
      break

Buggy submission (verdict: Runtime Error):
import collections
N=int(input())
S=[input() for i in range(N)]
c=collections.Counter(S)
if len(c.most_common())==1:
  print(c.most_common()[0][0])
else:
  for i in range(len(c.most_common())):
    print(c.most_common()[i][0])
    if c.most_common()[i][1] !=c.most_common()[i+1][1]:
      break

Buggy submission (verdict: Runtime Error):
import collections
N=int(input())
S=[input() for i in range(N)]
c=collections.Counter(S)
for i in range(len(c.most_common())):
  print(c.most_common()[i][0])
  if c.most_common()[i][1] !=c.most_common()[i+1][1]:
    break
Problem p02831 (python)

Fixed submission:
import fractions
A,B=map(int,input().split())
C=(A*B)//(fractions.gcd(A,B))
print(C)

Buggy submission (verdict: Runtime Error):
import math
A,B=map(int,input().split())
C=(A*B)/(math.gcd(A,B))
print(C)
Problem p02881 (python)

Fixed submission:
import math
N=int(input())
tmp=N+1
for i in range(1,int(math.sqrt(N)+1)):
  if N%i==0:
    if i+(N/i)<=tmp:
      tmp=i+(N/i)
if tmp==N+1:
  print(int(N-1))
else:
  print(int(tmp-2))

Buggy submission (verdict: Runtime Error):
N=int(input())
list=[]
for i in range(1,N//2):
  if N%i==0:
    list.append(i+(N/i))
if min(list)==N:
  print(N-1)
else:
  print(int(min(list)-2))

Buggy submission (verdict: Runtime Error):
N=int(input())
list=[]
for i in range(1,N//2):
  if N%i==0:
    list.append(i+(N/i))
if min(list)==N:
  print(N-1)
else:
  print(int(min(list)-2))
Problem p02897 (python)

Fixed submission:
N=int(input())

if N%2==0:
  print(float(0.5))

else:
  s=float(((N+1)/2)/N)
  print(s)

Buggy submission (verdict: Runtime Error):
N=int(input())
St=[int(x) for x in input().split()]
num=1
out=[]
while num<=N:
  for i in range(N):
    if St[i] ==num:
      out.append(i)
      num+=1

for i in range(N):
  print(out[i]+1,end=" ")

Buggy submission (verdict: Runtime Error):
N=int(input())
St=[int(x) for x in input().split()]
num=1
out=[]
while num<=N:
  for i in range(N):
    if St[i] ==num:
      out.append(i)
      num+=1

for i in range(N):
  print(out[i]+1,end=" ")
Problem p02916 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
sum=0
for i in range(len(A)-1):
  sum+=B[i]
  if A[i]+1==A[i+1]:
      sum+=C[A[i]-1]
sum+=B[len(A)-1]
print(sum)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
sum=0
for i in range(len(A)):
  sum+=B[i]
  try
    if A[i]+1==A[i+1]:
      sum+=C[i]
  except:
    pass
print(sum)
Problem p02860 (python)

Fixed submission:
n=int(input())
s=list(input())
c=0
if n%2 != 0:
    print('No')
    exit()
else:
    for i in range(n//2):
        if s[i]!=s[i+n//2]:
            c+=1
    if c==0:
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input())
c=0
if n%2 != 0:
    print('No')
    exit()
else:
    for i in range(n/2):
        if s[i]!=s[i+n/2]:
            c+=1
    if c==0:
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input())
c=0
for i in range(n//2):
    if s[i]!=s[i+n//2]:
        c+=1
if c==0:
    print('Yes'):
else:
    print('No')
Problem p02873 (python)

Fixed submission:
s=list(input())
a=[0]*(len(s)+1)
if s[0]=='<':
    a[0]=0
    l=0
    while s[l]=='<':
        a[l+1]=a[l]+1
        l+=1
        if l>len(s)-1:
          break
if s[len(s)-1]=='>':
    a[len(s)]=0
    m=len(s)-1
    while s[m]=='>':
        a[m]=a[m+1]+1
        m-=1
        if m<0:
          break
for i in range(len(s)-1):
    if s[i]=='>' and s[i+1]=='<':
        a[i+1]=0
        k=i
        t=i+1
        while s[k]=='>':
            a[k]=a[k+1]+1
            k-=1
            if k<0 or k>len(s)-1:
                break
        while s[t]=='<':
            a[t+1]=a[t]+1
            t+=1
            if t<0 or t>len(s)-1:
                break
for i in range(len(s)-1):
    if s[i]=='<' and s[i+1]=='>':
        a[i+1]=max(a[i],a[i+2])+1
print(sum(a))

Buggy submission (verdict: Runtime Error):
s=list(input())
a=[0]*(len(s)+1)
if s[0]=='<':
    a[0]=0
    l=0
    while s[l]=='<':
        a[l+1]=a[l]+1
        l+=1
        if l>len(s)-1:
          break
if s[len(s)-1]=='>':
    a[len(s)]=0
    m=len(s)-1
    while s[m]=='>':
        a[m]=a[m+1]+1
        m-=1
for i in range(len(s)-1):
    if s[i]=='>' and s[i+1]=='<':
        a[i+1]=0
        k=i
        t=i+1
        while s[k]=='>':
            a[k]=a[k+1]+1
            k-=1
            if k<0 or k>len(s)-1:
                break
        while s[t]=='<':
            a[t+1]=a[t]+1
            t+=1
            if t<0 or t>len(s)-1:
                break
for i in range(len(s)-1):
    if s[i]=='<' and s[i+1]=='>':
        a[i+1]=max(a[i],a[i+2])+1
print(sum(a))

Buggy submission (verdict: Runtime Error):
s=list(input())
a=[0]*(len(s)+1)
if s[0]=='<':
    a[0]=0
    l=0
    while s[l]=='<':
        a[l+1]=a[l]+1
        l+=1
if s[len(s)-1]=='>':
    a[len(s)]=0
    m=len(s)-1
    while s[m]=='>':
        a[m]=a[m+1]+1
        m-=1
for i in range(len(s)-1):
    if s[i]=='>' and s[i+1]=='<':
        a[i+1]=0
        k=i
        t=i+1
        while s[k]=='>':
            a[k]=a[k+1]+1
            k-=1
            if k<0 or k>len(s)-1 or s[k]=='<':
                break
        while s[t]=='<':
            a[t+1]=a[t]+1
            t+=1
            if t<0 or t>len(s)-1 or s[t]=='>':
                break
for i in range(len(s)-1):
    if s[i]=='<' and s[i+1]=='>':
        a[i+1]=max(a[i],a[i+2])+1
print(sum(a))
Problem p02987 (python)

Fixed submission:
#132  Fifty-Fifty
A = input()
if len(set(A)) == 2 & A.count(A[0]) == 2:
       print('Yes')
else:
       print('No')

Buggy submission (verdict: Runtime Error):
A = list(input())
if len(set(A) == 2 & A.count(A[0]) == 2:
       print('Yes')
else:
       print('No')

Buggy submission (verdict: Runtime Error):
A = input()
if len(set(A) == 2 & A.count(A[0]) == 2:
       print('Yes')
else:
       print('No')
Problem p03041 (python)

Fixed submission:
N,K=map(int,input().split())
S=input()
print(S[0:K-1]+S[K-1].lower()+S[K:])

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
S=list(input())
S=S[0:K-1].append(S[K-1].lower)+S[K-1:]
Problem p02689 (python)

Fixed submission:
l = list(map(int, input().split()))
li =  list(map(int, input().split()))

g = []
for i in range(l[1]):
    a, b = map(int, input().split())
    if li[a-1] == li[b-1]:
        g += [a, b]
    if li[a-1] > li[b-1]:
        g += [b]
    else:
        g += [a]

g = set(g)
r = l[0] - len(g)
print(r)

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

g = []
for i in range(l[1]):
    a, b = map(int, input().split())
    if li[a-1] == li[b-1]:
        g += [a, b]
    if li[a-1] >= li[b-1]:
        g += [b]
    else:
        g += [a]
    print(g)

g = set(g)
print(l[0] - len(g))
Problem p03835 (python)

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

count = 0
for x in range(min(k+1,s + 1)):
    for y in range(x,min(x+k+1,s +1)):
        if s - y <=k:
                
            count += 1
print(count)

Buggy submission (verdict: Runtime Error):
count= 0
#全探索は時計が切れる
for x in range(k+1):
    for y in range(k+1):
        if 0 <= s - (x +y) <= k:
            count += 1

print(count)
Problem p02711 (python)

Fixed submission:
input = int(input())
list = [int(x) for x in str(input)]
count = 0
for x in list:
  if x == 7:
    count = count + 1
if count >= 1:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
input = int(input())
a = []
while(i <= input):
    if i%3 == 0 or i%5 == 0:
        pass
    else:
        a.append(i)
    i += 1
sum = 0
for j in a:
    sum = sum + a[j]
print(sum)
Problem p02712 (python)

Fixed submission:
input = input()
a = []
i = 1
while(i <= int(input)):
    if i%3 == 0 or i%5 == 0:
        pass
    else:
        a.append(i)
    i += 1
res = 0
for j in a:
  res = res + j
print(res)

Buggy submission (verdict: Runtime Error):
input = int(input())
a = []
while(i <= input):
    if i%3 == 0 or i%5 == 0:
        pass
    else:
        a.append(i)
    i += 1

print(sum(a))

Buggy submission (verdict: Runtime Error):
input = int(input())
a = []
while(i <= input):
  if i%3 == 0 or i%5 == 0:
    pass
  else:
    a.append(i)
  i += 1
sum = 0
for j in a:
    sum = sum + a[j]
print(sum)

Buggy submission (verdict: Runtime Error):
zinput = int(input())
a = []
b = []
i = 1
while(i <= input):
  if i%3 == 0 and i%5 == 0:
    a[i] = "FizzBuzz"
  elif i%3 == 0:
    a[i] = "Fizz"
  elif i%5 == 0:
    a[i] = "Buzz"
  else:
    a[i] = "i"
  i += 1
sum = 0
for j in a:
  if a[j] != "FizzBuzz" and a[j] != "Fizz" and a[j] != "Buzz":
    sum = sum + int(a[j])
print(sum)

Buggy submission (verdict: Runtime Error):
zinput = int(input())
a = []
b = []
i = 1
while(i <= input):
  if i%3 == 0 and i%5 == 0:
    a[i] = "FizzBuzz"
  elif i%3 == 0:
    a[i] = "Fizz"
  elif i%5 == 0:
    a[i] = "Buzz"
  else:
    a[i] = i
    b.append(i)
  i += 1
sum = 0
for j in a:
    sum = sum + b[j]
print(sum)

Buggy submission (verdict: Runtime Error):
input = int(input())
a = []
i = 1
while(i <= input):
  if i%3 == 0 and i%5 == 0:
    a[i] = FizzBuzz
  elif i%3 == 0:
    a[i] = Fizz
  elif i%5 == 0:
    a[i] = Buzz
  else:
    a[i] = i
  i += 1
sum = 0
for j in a:
  if a[j] != "Fizz" and a[j] != "Buzz" and a[j] != "FizzBuzz":
    sum = sum + a[j]
print(sum)

Buggy submission (verdict: Runtime Error):
input = int(input())
a = []
i = 1
while(i <= input):
  if i%3 == 0 and i%5 == 0:
    a[i] = FizzBuzz
  elif i%3 == 0:
    a[i] = Fizz
  elif i%5 == 0:
    a[i] = Buzz
  else:
    a[i] = i
  i += 1
sum = 0
for j in a:
  if a[i] != "Fizz" and a[i] != "Buzz" and a[i] != "FizzBuzz":
    sum = sum + a[i]
print(sum)
Problem p02831 (python)

Fixed submission:
#バージョン的にfractionsにある
import fractions

a,b = map(int, input().split())

print((a * b) // fractions.gcd(a, b))

Buggy submission (verdict: Runtime Error):
import math

a,b = map(int, input().split())


def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))
Problem p02781 (python)

Fixed submission:
import itertools

def comb(a,b):
    if a<=0:
        return 0
    if b==1:
        return a
    elif b==2:
        return a*(a-1)//2
    else:
        return a*(a-1)*(a-2)//6

def tmp(L, K):
    ret=[]
    if K==1:
        bases=itertools.combinations(range(L+1),K)    
        for b in bases:
            ret+=[ k*10**b[0] for k in range(1,10)]
    if K==2:
        bases=itertools.combinations(range(L+1),K)
        kk=list(itertools.product(range(1,10),range(1,10)))
        for b in bases:
            ret+=[ k[0]*10**b[0] + k[1]*10**b[1] for k in kk]
    return ret

Nst=input()
K=int(input())
L=len(Nst)
N1=int(Nst[0])

if K==1:
    ans=comb( L-1, K) * 9 + N1
elif K>=2:
    ans=comb( L-1, K) * 9**(K) + comb( L-1, K-1) * 9**(K-1) *(N1-1)
    lst=[ 10**(L-1)*N1 + a for a in tmp(L-1, K-1)]
    ans+=sum([x <= int(Nst) for x in lst])
print (ans)

Buggy submission (verdict: Runtime Error):
import itertools

def comb(a,b):
    if a<=0:
        return 0
    if b==1:
        return a
    elif b==2:
        return a*(a-1)//2
    else:
        return a*(a-1)*(a-2)//6

def tmp(L, K):
    ret=[]
    if K==1:
        bases=itertools.combinations(range(L+1),K)    
        for b in bases:
            ret+=[ k*10**b[0] for k in range(1,10)]
    if K==2:
        bases=itertools.combinations(range(L+1),K)
        kk=list(itertools.product(range(1,10),range(1,10)))
        for b in bases:
            ret+=[ k[0]*10**b[0] + k[1]*10**b[1] for k in kk]
    return ret

Nst=input()
K=int(input())
L=len(Nst)
N1=int(Nst[0])
N2=int(Nst[1])

if K==1:
    ans=comb( L-1, K) * 9 + N1
elif K>=2:
    ans=comb( L-1, K) * 9**(K) + comb( L-1, K-1) * 9**(K-1) *(N1-1)
    lst=[ 10**(L-1)*N1 + a for a in tmp(L-1, K-1)]
    ans+=sum([x <= int(Nst) for x in lst])
print (ans)
Problem p02915 (python)

Fixed submission:
N=int(input())
print (N**3)

Buggy submission (verdict: Runtime Error):
N=int(input())
print N**3
Problem p02699 (python)

Fixed submission:
S, W = map(int, input().split())
print('unsafe' if S <= W else 'safe')

Buggy submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())
t_eq = -(-C//B)
a_eq = -(-A//D)
if t_eq <= a_eq:
    print('Yes')
else:
    print('No')
Problem p02729 (python)

Fixed submission:
from math import factorial
n, m = map(int, input().split())
c_n = factorial(n) / (factorial(2) * factorial(n - 2)) if n > 1 else 0
c_m = factorial(m) / (factorial(2) * factorial(m - 2)) if m > 1 else 0
ans = int(c_n) + int(c_m)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n, m = map(int, input().split())
ans = math.factorial(n - 1) + math.factorial(m)
print(ans)
Problem p02682 (python)

Fixed submission:
a,b,c,k = map(int,input().split())
if k <= a:
    print(k)
elif k <= a+b:
    print(a)
else:
    print(a-(k-(a+b)))

Buggy submission (verdict: Runtime Error):
a,b,c,k = map(int,input().split())
l = [1]*a + [0]*b + [-1]*c
print(sum(l[0:k]))
Problem p02693 (python)

Fixed submission:
k = int(input())
a,b=map(int, input().split())
for i in range(1,2000):
    x=k*i
    if a <= x and x <= b:
        print("OK")
        break
    elif b < x:
        print("NG")
        break

Buggy submission (verdict: Runtime Error):
k = int(input())
a,b=map(int, input().split())
for i in range(1,2000):
    x=k*i
    if a <= k and k <= b:
        print("OK")
        break
    else b < k:
        print("NG")
	break
Problem p03038 (python)

Fixed submission:
import sys
input = sys.stdin.readline
n,m = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
a.sort()
bc=[None]*m
for i in range(m):
    bc[i] = list(map(int, input().split(" ")))
bc.sort(reverse=True, key=lambda x:x[1])
l=[]
for [b,c] in bc:
    l.extend([c]*b)
    if n < len(l):
        break
for i in range(n):
    if len(l) <= i or l[i] <= a[i]:
        break
    a[i] = l[i]
print(sum(a))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n,m = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
a.sort()
bc=[None]*m
for i in range(m):
    bc[i] = list(map(int, input().split(" ")))
bc.sort(reverse=True, key=lambda x:x[1])
l=[]
for [b,c] in bc:
    l.extend([c]*b)
    if n < len(l):
        break
for i in range(n):
    if len(l) <= i or l[i] <= a[i]:
	break
    a[i] = l[i]
print(sum(a))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n,m = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
a.sort()
bc=[None]*m
for i in range(m):
    bc[i] = list(map(int, input().split(" ")))
bc.sort(reverse=True, key=lambda x:x[c])
l=[]
for [b,c] in bc:
    l = l+[c]*b
    if n < len(l):
        break
print(sorted(l))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n,m = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
a.sort()
bc=[]
for i in range(m):
    b,c = map(int, input().split(" "))
    bc = bc + [c]*b
bc.sort(reverse=True)
for i in range(n):
    if bc[i] <= a[i]:
        break
    a[i] = bc[i]
print(sum(a))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n,m = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
a.sort()
bc=[None]*m
for i in range(m):
    bc[i] = list(map(int, input().split(" ")))
bc.sort(key=lambda x:x[1], reverse=True)
result = 0
for [b,c] in bc:
    if len(a) == 0 or c < a[0]:
        break
    for i in range(b):
        if c < a[i]:
            break
        a[i] = c
    result = result + sum(a[0:b])
    a = a[b:]
print(sum(a)+result)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n,m = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
a.sort()
bc=[None]*m
for i in range(m):
    bc[i] = list(map(int, input().split(" ")))
bc = sorted(bc, key=lambda x:x[1], reverse=True)
result = 0
for [b,c] in bc:
    if len(a) == 0:
        break
    if c < a[0]:
        break
    for i in range(b):
        if c < a[i]:
            break
        a[i] = c
    result = result + sum(a[0:b])
    a = a[b:]
print(sum(a)+result)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n,m = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
a.sort()
bc=[None]*m
for i in range(m):
    bc[i] = list(map(int, input().split(" ")))
bc = sorted(bc, key=lambda x:x[1], reverse=True)
result = 0
for [b,c] in bc:
    if c < a[0]:
        break
    for i in range(b):
        if c < a[i]:
            break
        a[i] = c
    result = result + sum(a[0:b])
    a = a[b:]
print(sum(a)+result)
Problem p03041 (python)

Fixed submission:
n,k = map(int, input().split(" "))
s = list(input())
s[k-1] = s[k-1].lower()
print("".join(s))

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split(" "))
s = input()
s[k-1] = s[k-1].lower()
print(s)
Problem p02659 (python)

Fixed submission:
import sys
from decimal import Decimal

num_list = input().split()
ans = Decimal(num_list[0]) * Decimal(num_list[1])
print(int(ans))

Buggy submission (verdict: Runtime Error):
import sys
import math

num_list = input().split()
ans = int(num_list[0]) * float(num_list[1]) * 100
ans = str(int(ans))[:-2]
print(int(ans))