Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
Tmp = []
Tmp = input().rstrip().split(',')
 
sA = (Tmp[0])
sB = (Tmp[1])
sC = (Tmp[2])
 
print(sA + ' ' + sB ' ' + sC)


Fixed submission:
Tmp = []
Tmp = input().rstrip().split(',')
 
sA = (Tmp[0])
sB = (Tmp[1])
sC = (Tmp[2])
 
print(sA + ' ' + sB +' ' + sC)
Buggy python submission (verdict: Runtime Error):

Tmp = []
Tmp = input().rstrip().split(' ')

S = []
S = int(Tmp[1])

sTmp = S[0]

print('A'+sTmp+'C')


Fixed submission:
Tmp = []
Tmp = input().rstrip().split(' ')
 
S = []
S = (Tmp[1])
 
sTmp = S[0]
 
print('A', end='')
print('%s' %(sTmp), end='')
print('C')
Buggy python submission (verdict: Runtime Error):
import sys
 
nN = int(input())
nK = int(input())
nX = int(input())
nY = int(input())
 
nE = 0
nANs = 0
 
if nN =< nK:
  nAns = nX * nN
  print(nAns)
  sys.exit()
  
nE = nN - nK
 
nAns = nX * nN + nY * nE
print(nAns)
 

Fixed submission:
import sys
 
nN = int(input())
nK = int(input())
nX = int(input())
nY = int(input())
 
nE = 0
nAns = 0
 
if nN <= nK:
  nAns = nX * nN
  print(nAns)
  sys.exit()
  
nE = nN - nK
 
nAns = (nX * nK) + (nY * nE)
print(nAns)

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

nN = int(input())
nK = int(input())
nX = int(input())
nY = int(input())

nE = 0

if nN =< nK:
  nAns = nX * nN
  print(nAns)
  sys.exit()
  
nE = nN - nK

nAns = nX * nN + nY * nE
print(nAns)





Fixed submission:
import sys
 
nN = int(input())
nK = int(input())
nX = int(input())
nY = int(input())
 
nE = 0
nAns = 0
 
if nN <= nK:
  nAns = nX * nN
  print(nAns)
  sys.exit()
  
nE = nN - nK
 
nAns = (nX * nK) + (nY * nE)
print(nAns)
Buggy python submission (verdict: Time Limit Exceeded):
#N,K=map(int,input().split(" "))
N=int(input())
a=list(map(int,input().split(" ")))
b=[]
for _ in range(N):
    buf = a.index(min(a))
    b.append(buf+1)
    a[buf]=N+1
print(" ".join(repr(e) for e in b))

Fixed submission:
#A,B=map(int,input().split(" "))
N=int(input())
a=list(map(int,input().split(" ")))
b=[0 for i in range(N)]
for i in range(N):
    b[a[i]-1]=i+1
#print(b)
print(" ".join(repr(e) for e in b))
Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q=map(int,input().split(" "))
A=[]
for _ in range(Q):
    A.append(int(input()))

ans=[K for _ in range(N)]
for q in A:
    ans=[i-1 for i in ans]
    ans[q-1]+=1
for a in ans:
    if a>0:
        print("Yes")
    else:
        print("No")


Fixed submission:
N,K,Q=map(int,input().split(" "))
A=[]
for _ in range(Q):
    A.append(int(input()))

ans=[K for _ in range(N)]
for q in A:
    ans[q-1]+=1
for a in ans:
    if a>Q:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
ans=0
for i in range(N):
    ans+=B[A[i]-1]
    if i<N-1:
        if A[i+1]==A[i]+1:
            ans+=C[A[i]-1]

print(ans)

Fixed submission:

N=int(input())
A=list(map(int,input().split(" ")))
B=list(map(int,input().split(" ")))
C=list(map(int,input().split(" ")))

ans=0
for i in range(N):
    ans+=B[A[i]-1]
    if i<N-1:
        if A[i+1]==A[i]+1:
            ans+=C[A[i]-1]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
H=list(map(int, input().split(" ")))
ans=0
for i in range(N-1):
    j=i
    cnt=0
    while H[j]>=H[j+1]:
        j+=1
        cnt+=1
        if ans<cnt:
            ans=cnt
        if j+1==N:
            break
print(ans)


Fixed submission:
N=int(input())
H=list(map(int, input().split(" ")))
ans=0
buf=[0 for _ in range(N-1)]
for i in range(N-1):
    if H[i]>=H[i+1]:
        buf[i]=1
cnt=0
for i in range(N-1):
    if buf[i]==1:
        cnt+=1
    else:
        cnt=0
    if cnt>ans:
        ans=cnt
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=[i for i in range(N)]
print(sum(a))

Fixed submission:
N=int(input())
if N % 2 ==1:
    ans=int((N-1)/2) * N
else:
    ans=int(N/2) * (N-1)
print(int(ans))
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split(" "))
A=list(map(int,input().split(" ")))
#N=3
#K=3
#A=[1,3,2]
A1=[set() for _ in range(N)]
cnt=0
cnt1=0
for n1 in range(N):
    for n2 in range(N):
        if n1!=n2 and A[n1]>A[n2]:
            cnt+=1
        if n1<n2 and A[n1]>A[n2]:
            cnt1+=1

#ten=int(cnt1+cnt*(K**2-K)/2+cnt1*(K-1))
k2=(K**2)%(10**9+7)
ten1=int((k2*cnt)%(10**9+7))
ten2=int((K*cnt)%(10**9+7))
ten3=int((cnt1*K)%(10**9+7))
if ten1-ten2<0:
    ten=((ten1-ten2+10**9+7)/2)%(10**9+7)
else:
    ten=((ten1-ten2))/2%(10**9+7)
ten=ten+ten3
print(int(ten%(10**9+7)))


Fixed submission:
M,D=map(int,input().split(" "))
cnt=0
for m in range(M):
    for d in range(D):
        m1=m+1
        d1=d+1
        if len(str(d1))==1:
            continue
        if int(str(d1)[0])>=2 and int(str(d1)[1])>=2 and int(str(d1)[0])*int(str(d1)[1])==m1:

            cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
s = input()

if s = 'Sunny':
    print('Cloudy')
elif s = 'Cloudy':
    print('Rainy')
else s = 'Rainy':
    print('Sunny')

Fixed submission:
s = input()

if s == 'Sunny':
    print('Cloudy')
elif s == 'Cloudy':
    print('Rainy')
elif s == 'Rainy':
    print('Sunny')
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()

ans = 0
for i in range(3):
    if s[i]==t[i]:
        ans+=1
    i+=
print(ans)

Fixed submission:
s = input()
t = input()

ans = 0
for i in range(3):
    if s[i]==t[i]:
        ans+=1
    i+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
a = int(inpur())
s = input()

if a < 3200:
    print('red')
else :
    print(s)

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

if a < 3200:
    print('red')
else :
    print(s)
Buggy python submission (verdict: Runtime Error):
n = int(input())
aa = list(map(int, input().strip().sprit()))

g = 0

# for 文書きたくねぇ
for a in aa:
    g += 1 / a

print(1 / g)

Fixed submission:
n = int(input())
aa = list(map(int, input().strip().split()))

g = 0

# for 文書きたくねぇ
for a in aa:
    g += 1 / a

print(1 / g)

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

g = 0

# for 文書きたくねぇ
for x in a:
    g += 1 / x

print(1 / g)

Fixed submission:
n = int(input())
aa = list(map(int, input().strip().split()))

g = 0

# for 文書きたくねぇ
for a in aa:
    g += 1 / a

print(1 / g)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().sprit())

# 演算子%は余りを出す　//は小数切り捨てて整数値を出す
if (a + b) % 2 == 0:
    print((a+b)//2)
else:
    print('IMPOSSIBLE')

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

# 演算子%は余りを出す　//は小数切り捨てて整数値を出す
if (a + b) % 2 == 0:
    print((a+b)//2)
else:
    print('IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):


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

print(min(b,a*n))

Fixed submission:


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

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

if a == 5 and b == 5 and c == 7:
  print("YES")
elif a == 5 and b == 7 and c == 5:
  print("YES")  
elif a == 7 and b == 5 and c == 5:
  print("YES") 
else
  print("NO") 

Fixed submission:
a, b, c = map(int, input().split())
 
if a == 5 and b == 5 and c == 7:
  print("YES")
elif a == 5 and b == 7 and c == 5:
  print("YES")  
elif a == 7 and b == 5 and c == 5:
  print("YES") 
else:
  print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
k,s = map(int,input().split())
x = 0
for d in range(0,k+1):
    for y in range(0,k+1):
        z = s - d - y
        if d+y+z == s and z<k+1 and z>=0:
            x = x+1
print (x)
 

Fixed submission:
k,s = map(int,input().split())
x = 0
for d in range(0,k+1):
    for y in range(0,k+1):
        z = s - d - y
        if z<k+1 and z>=0:
            x = x+1
print (x)
Buggy python submission (verdict: Runtime Error):
s=input()
l=[]
for ak in range(len(s)):
    l.append(s[ak])
no=[]
s=l
no.append(s[0])
br=0
for i in range(1,len(s)):
    no.append(s[i])
   
    if no[-1]!=no[-2]:
        no.pop(-1)
        no.pop(-1)
        br+=2
print(br)


Fixed submission:
s=input()
l=[]
for ak in range(len(s)):
    l.append(s[ak])
no=[]
s=l
no.append(s[0])
br=0
for i in range(1,len(s)):
    no.append(s[i])
   
    if len(no) >= 2 and no[-1]!=no[-2]:
        no.pop(-1)
        no.pop(-1)
        br+=2
print(br)
Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split())
br=0
k+=1
for x in range(k):
    for y in range(k):
        z=s-x-y
        if x+y+z==s and z>=0 and z<k:
            br+=1
        
print(br)

Fixed submission:
k,s=map(int,input().split())
br=0
k+=1
for x in range(k):
    for y in range(k):
        z=s-x-y
        if x+y+z==s and z>=0 and z<k:
            br+=1
        
print(br)

Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split())
br=0
for x in range(k+1):
    for y in range(k+1):
        z=s-x-y
        if x+y+z==s and z>=0 and z<=k:
            br+=1
        
print(br)

Fixed submission:
k,s=map(int,input().split())
br=0
k+=1
for x in range(k):
    for y in range(k):
        z=s-x-y
        if x+y+z==s and z>=0 and z<k:
            br+=1
        
print(br)
Buggy python submission (verdict: Runtime Error):
a=input()
b=input()

cmax = max((a+b),(a-b),(a*b))
print(cmax)

Fixed submission:
a,b = map(int,input().split())
cmax = max((a+b),(a*b),(a-b))
print(cmax)

Buggy python submission (verdict: Runtime Error):
max((a+b),(a-b),(a*b))

Fixed submission:
a,b = map(int,input().split())
cmax = max((a+b),(a*b),(a-b))
print(cmax)
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=list(map(int,input().split()))
count=0
for i,j in enumerte(a,1):
  if i != j:
    count +=1

if count <= 2:
    print('YES')
else:
    print('NO')
  

Fixed submission:
a=int(input())
b=list(map(int,input().split()))
count=0
for i,j in enumerate(b,1):
  if i != j:
    count +=1

if count <= 2:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
for i in range(1,a):
  if a<=(b*2+1)*i :
    break
print(i)
    

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

print((a-1) // (2*b+1)+1)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
x=[list(map(int,input().split())) for i in range(n)]

count=1
for i in range(i,a):
  for j in range(i+1,a):
    t=0
    for k in range(b):
      t += (x[i][k]-x[j][k])**2
    t = t**(1/2)
    if t.is_integer():
      count += 1
print(count)
    

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

count=0
for i in range(n):
  for j in range(i+1,n):
    t=0
    for k in range(b):
      t += (x[i][k]-x[j][k])**2
    t = t**(1/2)
    if t.is_integer():
      count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(c) for c in input().split()]
for num in range(n):
    print(a.index(num+1)+1,end=" ")

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

Buggy python submission (verdict: Runtime Error):
n=int(input())
list=[]
for num in range(n):
    i=int(input())
    list.append(i)
for num in range(n):
    print(list.index(num+1)+1,end=" ")

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

Buggy python submission (verdict: Runtime Error):
n=int(input())
list=[]
for num in range(n):
    i=int(input())
    list.append(i)
for num in range(n):
    print(list.index(num+1)+1)

Fixed submission:
n=int(input())
a=[0]*n
l =list(map(int, input().split()))
for i in range(n):
    a[l[i]-1]=i+1
for i in range(n):
    print(a[i])
Buggy python submission (verdict: Time Limit Exceeded):
def even_bit_maker(number_length):
    bit = 0
    for i in range(number_length):
        if i % 2 == 0:
            bit += 2 ** i
    return bit


def odd_bit_maker(number_length):
    bit = 0
    for i in range(number_length):
        if i % 2 == 1:
            bit += 2 ** i
    return bit


if __name__ == '__main__':
    init_tile = input()
    init_tile_bit = int(init_tile, 2)
    tile_len = len(init_tile)
    even_bit = init_tile_bit ^ even_bit_maker(tile_len)
    odd_bit = init_tile_bit ^ odd_bit_maker(tile_len)
    even_change_count = bin(even_bit).count('1')
    odd_change_count = bin(odd_bit).count('1')
    print(min(even_change_count, odd_change_count))


Fixed submission:
def even_bit_maker(number_length):
    bit = ['0'] * number_length
    for i in range(number_length):
        if i % 2 == 0:
            bit[i] = '1'
    return int(''.join(bit), 2)


def odd_bit_maker(number_length):
    bit = ['0'] * number_length
    for i in range(number_length):
        if i % 2 == 1:
            bit[i] = '1'
    return int(''.join(bit), 2)


if __name__ == '__main__':
    init_tile = input()
    init_tile_bit = int(init_tile, 2)
    tile_len = len(init_tile)
    even_bit = init_tile_bit ^ even_bit_maker(tile_len)
    odd_bit = init_tile_bit ^ odd_bit_maker(tile_len)
    even_change_count = bin(even_bit).count('1')
    odd_change_count = bin(odd_bit).count('1')
    print(min(even_change_count, odd_change_count))
Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == '__main__':
    length, question_count = map(int, input().split())

    string = input()
    for i in range(question_count):
        l, r = map(int, input().split())
        current_string = string[l - 1:r]
        print(current_string.count('AC'))


Fixed submission:
if __name__ == '__main__':
    length, question_count = map(int, input().split())

    string = input()
    ac_sums = [0]
    for i in range(1, len(string) + 1):
        if i > 1 and string[i - 2] == 'A' and string[i - 1] == 'C':
            ac_sums.append(ac_sums[i - 1] + 1)
        else:
            ac_sums.append(ac_sums[i - 1])

    for i in range(question_count):
        l, r = map(int, input().split())
        ans = ac_sums[r] - ac_sums[l - 1]
        if l > 1 and string[l - 1] == 'C' and string[l - 2] == 'A':
            ans -= 1
        print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == '__main__':
    n, m = map(int, input().split())
    shops = []
    ans = 0
    for i in range(n):
        shops.append(list(map(int, input().split())))
        shops.sort(key=lambda x:x[0])

    for shop in shops:
        price = shop[0]
        available = shop[1]
        if m - available > 0:
            ans += price * available
            m -= available
        else:
            ans += price * m
            break

    print(ans)

Fixed submission:
import sys
input = sys.stdin.readline


if __name__ == '__main__':
    n, m = map(int, input().split())
    shops = []
    ans = 0
    for i in range(n):
        shops.append(list(map(int, input().split())))
    shops.sort(key=lambda x:x[0])

    for shop in shops:
        price = shop[0]
        available = shop[1]
        if m - available > 0:
            ans += price * available
            m -= available
        else:
            ans += price * m
            break

    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == '__main__':
	islands_count, demands_count = list(map(int, input().split()))
	demands = []
	bridges = [True for _ in range(islands_count - 1)]

	for i in range(demands_count):
		demand = list(map(int, input().split()))
		demands.append(demand)

	demands.sort(key=lambda x: x[1])

	for demand in demands:
		is_disconnected = False
		for bridge in range(demand[0] - 1, demand[1] - 1):
			if not bridges[bridge]:
				is_disconnected = True
				break
		if not is_disconnected:
			bridges[demand[1] - 2] = False
	print(bridges.count(False))


Fixed submission:
if __name__ == '__main__':
    islands_count, demands_count = list(map(int, input().split()))
    demands = []
    break_count = 0

    for i in range(demands_count):
        demand = list(map(int, input().split()))
        demands.append(demand)

    demands.sort(key=lambda x: x[1])
    west_edge = 0

    for demand in demands:
        if demand[0] >= west_edge:
            break_count += 1
            west_edge = demand[1]

    print(break_count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = n

for i in range(n):
    w_to_e = s[0:i].count('W')
    e_to_w = s[i+1:n].count('E')
    if w_to_e + e_to_w < ans:
        ans = w_to_e + e_to_w
print(ans)


Fixed submission:
import numpy as np

n = int(input())
s = input()
reverse_list_1 = [0]
reverse_list_2 = [0]
ans = n

for i in range(1,n):
    if s[i-1] == 'W':
        reverse_list_1.append(reverse_list_1[i-1]+1)
    else:
        reverse_list_1.append(reverse_list_1[i-1])

for i in range(1,n):
    if s[n-i] == 'E':
        reverse_list_2.append(reverse_list_2[i-1]+1)
    else:
        reverse_list_2.append(reverse_list_2[i-1])

reverse_list_2 = list(reversed(reverse_list_2))

for i in range(n):
    if reverse_list_1[i]+reverse_list_2[i] < ans:
        ans = reverse_list_1[i]+reverse_list_2[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
if __name__ == '__main__':
    hidden_key = input()
    flag_string = input()

    key_length = len(hidden_key)
    flag_length = len(flag_string)

    key_list = list(hidden_key.replace('?', 'a'))

    for i in reversed(range(key_length - flag_length + 1)):
        part_key = hidden_key[i:i + flag_length]
        is_match = True

        for j in range(flag_length):
            if part_key[j] != '?' and part_key[j] != flag_string[j]:
                is_match = False
                break
            
        if is_match:
            for k in range(flag_length):
                key_list[i + k] = flag_string[k]
            print(''.join(key_list))
            break

    if not is_match:
        print('UNRESTORABLE')


Fixed submission:
if __name__ == '__main__':
    hidden_key = input()
    flag_string = input()

    key_length = len(hidden_key)
    flag_length = len(flag_string)

    if key_length < flag_length:
        print('UNRESTORABLE')
        exit()

    key_list = list(hidden_key.replace('?', 'a'))

    for i in reversed(range(key_length - flag_length + 1)):
        part_key = hidden_key[i:i + flag_length]
        is_match = True

        for j in range(flag_length):
            if part_key[j] != '?' and part_key[j] != flag_string[j]:
                is_match = False
                break
            
        if is_match:
            for k in range(flag_length):
                key_list[i + k] = flag_string[k]
            print(''.join(key_list))
            break

    if not is_match:
        print('UNRESTORABLE')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = [0]
for _ in range(n):
    a_list.append(int(input()))
counter = 0
current_number = 1
already_pushed_list = []

while(True):
    counter += 1
    already_pushed_list.append(current_number)
    current_number = a_list[current_number]
    if current_number in already_pushed_list:
        print(-1)
        break
    if current_number == 2:
        print(counter)
        break


Fixed submission:
n = int(input())
a_list = [0]
for _ in range(n):
    a_list.append(int(input()))
counter = 0
current_number = 1
already_pushed_list = set()

while(True):
    counter += 1
    already_pushed_list.add(current_number)
    current_number = a_list[current_number]
    if current_number in already_pushed_list:
        print(-1)
        break
    if current_number == 2:
        print(counter)
        break
Buggy python submission (verdict: Runtime Error):
mod = 1000000007

n = int(input())
factorial_previous = 1

for i in range(2,n+1):
    factorial = (i*factorial_previous)%mod
    factorial_previous = factorial
print(factorial)


Fixed submission:
mod = 1000000007

n = int(input())
factorial_previous = 1

for i in range(1,n+1):
    factorial = (i*factorial_previous)%mod
    factorial_previous = factorial
print(factorial)
Buggy python submission (verdict: Runtime Error):
s = input()
n = len(s)
answer = 0


for i in range(2**(n-1)):
    calc_str = s[0]
    operator_maker = str(format(i, 'b')).zfill(n-1)
    for j, c in enumerate(operator_maker):
        if c == '1':
            calc_str += '+'
        calc_str += s[j+1]
    answer += eval(calc_str)

print(answer)

Fixed submission:
s = input()
n = len(s)
answer = 0


for i in range(2**(n-1)):
    calc_str = s[0]
    operator_maker = str(format(i, 'b')).zfill(n-1)
    for j, c in enumerate(operator_maker):
        if c == '1':
            calc_str += '+'
        if n != 1:
            calc_str += s[j+1]
    answer += eval(calc_str)

print(answer)
Buggy python submission (verdict: Runtime Error):
l = list(map(int,input().split()))
a = l.pop(min(l))
b = l.pop(min(l))
print(a+b)

Fixed submission:
l = list(map(int,input().split()))
a = l.pop(l.index(min(l)))
b = l.pop(l.index(min(l)))
print(a+b)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
C=[]
for i in range(m):
	b,c = map(int,input().split())
	C.append((b,c))

C = sorted(C,key = lambda x:x[1])

for b,c in C[::-1]:
	cou = 0
	for i in range(len(A)):
		if A[i] < c :
			A[i] = c
			cou += 1
		else :
			break
		if cou == b:
			break
	A.sort()
print(sum(A))

Fixed submission:

def test_function() :
	print(__name__) # __main__

#print("called :",test_function.__name__)
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
C=[]
for i in range(m):
	b,c = map(int,input().split())
	C.append((b,c))
C = sorted(C,key = lambda x:x[1])
before = 0

for b,c in C[::-1]:
	cou = 0  
	#print("[before]=",before)
	for i in range(len(A)-before):
		if A[before+i] < c :
			A[before+i] = c
			cou += 1
			#print("A=",A)
		else :
			before += i+1
			break
		if cou == b:
			before += i+1
			break
print(sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
for i in range(m):
	b,c = map(int,input().split())
	cou = 0
	for i in range(len(A)):
		if A[i] < c :
			A[i] = c
			cou += 1
		else :
			break
		if cou == b:
			break
	A.sort()
print(sum(A))

Fixed submission:

def test_function() :
	print(__name__) # __main__

#print("called :",test_function.__name__)
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
C=[]
for i in range(m):
	b,c = map(int,input().split())
	C.append((b,c))
C = sorted(C,key = lambda x:x[1])
before = 0

for b,c in C[::-1]:
	cou = 0  
	#print("[before]=",before)
	for i in range(len(A)-before):
		if A[before+i] < c :
			A[before+i] = c
			cou += 1
			#print("A=",A)
		else :
			before += i+1
			break
		if cou == b:
			before += i+1
			break
print(sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
R = A.copy()
for i in range(m):
	b,c = map(int,input().split())
	cou = 0
	for i,_ in enumerate(R):
		if A[i] < c :
			A[i] = c
			cou += 1
		if cou == b:
			break
	A.sort()
print(sum(A))

Fixed submission:

def test_function() :
	print(__name__) # __main__

#print("called :",test_function.__name__)
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
C=[]
for i in range(m):
	b,c = map(int,input().split())
	C.append((b,c))
C = sorted(C,key = lambda x:x[1])
before = 0

for b,c in C[::-1]:
	cou = 0  
	#print("[before]=",before)
	for i in range(len(A)-before):
		if A[before+i] < c :
			A[before+i] = c
			cou += 1
			#print("A=",A)
		else :
			before += i+1
			break
		if cou == b:
			before += i+1
			break
print(sum(A))
Buggy python submission (verdict: Runtime Error):


n,k = map(int,input().split(" "))
S = list(input())

s = S[k-1]
if s == "A" :
	S[k-1] = "a"
elif s == "B" :
	s[k-1] = "b"
else :
	s[k-1] = "c"

print("".join(S))

Fixed submission:


n,k = map(int,input().split(" "))
S = list(input())

s = S[k-1]
if s == "A" :
	S[k-1] = "a"
elif s == "B" :
	S[k-1] = "b"
else :
	S[k-1] = "c"

print("".join(S))
Buggy python submission (verdict: Runtime Error):
S = list(input())
n = []
a = 0
for s in S :
	if s in ["A","T","G","C"] :
		a += 1
	else :
		n.append(a if a > 0 else 0)
		a = 0
print(max(n))

Fixed submission:
S = list(input())
n = []
a = 0
for i,s in enumerate(S) :
	if s in ["A","T","G","C"] :
		a += 1
	else :
		n.append(a)
		a = 0
	
	if i+1 == len(S) :
		n.append(a)
		break
print(max(n))