Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))

p.sort()
q.sort()
r.sort()


red=0
for _ in range(x):
	pMax=max(p)
	rMax=max(r)
	if pMax >rMax:
		red+=pMax
		p.pop(p.index(pMax))
	else:
		red+=rMax
		r.pop(r.index(rMax))

white=0
for _ in range(y):
	qMax=max(q)
	rMax=max(r)
	if qMax >rMax:
		red+=qMax
		q.pop(q.index(qMax))
	else:
		red+=rMax
		r.pop(r.index(rMax))

print(white+red)

Fixed submission:
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

p=p[:x]
q=q[:y]

p.extend(q)#白なし
p.sort()
r=r[:x+y]# able add
lenR=len(r)

temp=p[:lenR]# 白なしの小さいものたち
temp.extend(r)#白と前の小さい者たちの合計
temp.sort(reverse=True)
temp=temp[:lenR]#白ありでのMAX

print(sum(p[lenR:])+sum(temp))

Buggy python submission (verdict: Runtime Error):
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split())).sort()
q=list(map(int,input().split())).sort()
r=list(map(int,input().split())).sort()


red=0
for _ in range(x):
	pMax=max(p)
	rMax=max(r)
	if pMax >rMax:
		red+=pMax
		p.pop(p.index(pMax))
	else:
		red+=rMax
		r.pop(r.index(rMax))

white=0
for _ in range(y):
	qMax=max(q)
	rMax=max(r)
	if qMax >rMax:
		red+=qMax
		q.pop(q.index(qMax))
	else:
		red+=rMax
		r.pop(r.index(rMax))

print(white+red)

Fixed submission:
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

p=p[:x]
q=q[:y]

p.extend(q)#白なし
p.sort()
r=r[:x+y]# able add
lenR=len(r)

temp=p[:lenR]# 白なしの小さいものたち
temp.extend(r)#白と前の小さい者たちの合計
temp.sort(reverse=True)
temp=temp[:lenR]#白ありでのMAX

print(sum(p[lenR:])+sum(temp))

Buggy python submission (verdict: Runtime Error):
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))

#red
red=0
for _ in range(x):
	pMax=max(p)
	rMax=max(r)
	if pMax >rMax:
		red+=pMax
		p.pop(p.index(pMax))
	else:
		red+=rMax
		r.pop(r.index(rMax))

white=0
for _ in range(y):
	qMax=max(q)
	rMax=max(r)
	if qMax >rMax:
		red+=qMax
		q.pop(q.index(qMax))
	else:
		red+=rMax
		r.pop(r.index(rMax))

print(white+red)

Fixed submission:
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

p=p[:x]
q=q[:y]

p.extend(q)#白なし
p.sort()
r=r[:x+y]# able add
lenR=len(r)

temp=p[:lenR]# 白なしの小さいものたち
temp.extend(r)#白と前の小さい者たちの合計
temp.sort(reverse=True)
temp=temp[:lenR]#白ありでのMAX

print(sum(p[lenR:])+sum(temp))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[]
for _ in range(n):
	s.append(input())
element=list(set(s))

Max=0
for i in element:
	Max=max(Max,s.count(i))

ans=[]
for i in element:
	if Max==s.count(i):
		ans.append(i)
ans.sort()
for i in ans:
	print(i)
		

Fixed submission:
n=int(input())
s={}
for _ in range(n):
	_s=input()
	if _s in s:
		s[_s]=s[_s]+1
	else:
		s[_s]=1

s=sorted(s.items(),key=lambda x:(x[1],x[0]))
max=s[-1][1]
for i in s:
	if i[1]==max:
		print(i[0])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))

ans=True
for i in range(n):
	for k in range(i+1,n):
		if a[i]==a[k]:
			ans=False

print("YES" if ans else "NO")

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
setA=set(a)
print("YES" if len(setA)==n else "NO")
Buggy python submission (verdict: Time Limit Exceeded):
x=int(input())
count=0

n=1
while True:
	n+=1
	ans=True
	for i in range(2,int(x**0.5)):
		if n%i==0:
			ans=False
	if ans and n>=x:
		print(n)
		break


Fixed submission:
x=int(input())
count=0

n=1
while True:
	n+=1
	ans=True
	for i in range(2,int(x**0.5)):
		if n%i==0:
			ans=False
			break
	if ans and n>=x:
		print(n)
		break
Buggy python submission (verdict: Runtime Error):
import numpy as np
n=int(input())
a=np.sort(np.array(input().split(" "),dtype="int32"))
a_=list(a[:])
for i in a:
	print(a_.index(i)+1,end=" ")

Fixed submission:
n=int(input())
if n%2==0:
	print((n//2)/n)

else:
	print((n//2+1)/n)
Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
T=[]
for  i in range(n):
	T.append(int(input()))

ans=T[0]
for i in range(1,len(T)):
	ans=ans*T[i]//math.gcd(int(ans),T[i])


print(int(ans))

Fixed submission:
import fractions as math
n=int(input())
T=[]
for  i in range(n):
	T.append(int(input()))

ans=T[0]
for i in range(1,len(T)):
	ans=ans*T[i]//math.gcd(int(ans),T[i])


print(int(ans))

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

ans=T[0]
for i in range(1,len(T)):
	ans=ans*T[i]/math.gcd(int(ans),T[i])


print(int(ans))

Fixed submission:
import fractions as math
n=int(input())
T=[]
for  i in range(n):
	T.append(int(input()))

ans=T[0]
for i in range(1,len(T)):
	ans=ans*T[i]//math.gcd(int(ans),T[i])


print(int(ans))
Buggy python submission (verdict: Runtime Error):
import math
n, p = map(int,input().split())
a = list(map(int,input().split()))

even=0
odd=0
for i in a:
    if i%2 == 0:
        even+=1
    else:
        odd+=1
ans = 0
if p == 0:
    ans += 1<<even
    i = 2
    while(i <= odd):
        ans += math.comb(odd, i)
        i+=2

    print(ans)

else:
    evens = 0
    i = 1
    while(i <= even):
        evens += math.comb(even, i)

        i+=1

    i = 1
    while(i <= odd):
        ans += math.comb(odd, i) + math.comb(odd, i)*evens

        i+=2
    print(ans)

Fixed submission:
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


n, p = map(int,input().split())
a = list(map(int,input().split()))

even=0
odd=0
for i in a:
    if i%2 == 0:
        even+=1
    else:
        odd+=1
ans = 0
if p == 0:
    evens = 0
    i = 1
    while(i <= even):
        evens += cmb(even, i)

        i+=1

    ans += 1<<even
    i = 2
    while(i <= odd):
        ans += cmb(odd, i) + cmb(odd, i)*evens
        i+=2

    print(ans)

else:
    evens = 0
    i = 1
    while(i <= even):
        evens += cmb(even, i)

        i+=1

    i = 1
    while(i <= odd):
        ans += cmb(odd, i) + cmb(odd, i)*evens

        i+=2
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ans=1
for i in range(1,n+1):
	ans*=i

print(ans%(10**9+7))


Fixed submission:
n=int(input())
ans=1
for i in range(1,n+1):
	ans=i*ans%(10**9+7)

print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[]
b=[]
for i in range(n):
	a.append(input())
for i in range(m):
	b.append(input())

check = False
for i in range(n):

	if b[0]in a[i]:
		index=a[i].index(b[0])
		check=True
		for k in range(m):
			if i+k>n:
				check=False
				break

			if not b[k]in a[i+k] or a[i+k].index(b[k])!=index:
				check=False
				break

	if check:
		break

print("Yes" if check else "No")

Fixed submission:
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

for i in a:
    for j in b:
        if j not in i:
            print("No")
            quit()
print("Yes")

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[]
b=[]
for i in range(n):
	a.append(input())
for i in range(m):
	b.append(input())

check = False
for i in range(n):

	if b[0]in a[i]:
		index=a[i].index(b[0])
		check=True
		for k in range(m):
			if i+k>=n:
				check=False
				break

			if a[i+k].index(b[k])!=index or not b[k]in a[i+k] :

				check=False
				break
	if check:
		break

print("Yes" if check else "No")

Fixed submission:
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

for i in a:
    for j in b:
        if j not in i:
            print("No")
            quit()
print("Yes")

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[]
b=[]
for i in range(n):
	a.append(input())
for i in range(m):
	b.append(input())

check = False
for i in range(n):
	if b[0]in a[i]:
		index=a[i].index(b[0])
		check=True
		for k in range(m):
			if i+k>=n:
				break
			if not b[k]in a[i+k] and a[i+k].index(b[k])!=index:
				check=False
				break
	if check:
		break

print("Yes" if check else "No")

Fixed submission:
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

for i in a:
    for j in b:
        if j not in i:
            print("No")
            quit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
import bisect

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

Q = int(input())

A.sort()
B = list(set(A))
X = [[0 for j in range(2)] for i in range(len(B))]
for i in range(len(B)):
  b=bisect.bisect_left(A,B[i])
  c=bisect.bisect_right(A,B[i])
  num = c - b #B[i]の要素数
  X[i][0] = B[i]
  X[i][1] = num

M = [0 for j in range(Q)]
N = [0 for j in range(Q)]
for i in range(Q):
  M[i],N[i] = map(int,input().split())
B_len = len(B)
ans = int()
for i in range(Q):
  x = M[i]
  y = N[i]
  ans = 0
  jg = False
  for j in range(B_len):
    if X[j][0] == y:
      jg = True
      jgx = j
  for j in range(B_len):
    if X[j][0] == x:
      X[j][0] = y
      if jg == True:
        X[j][1] += X[jgx][1]
        X[jgx][0] = 0
        B_len = B_len-1
    ans += X[j][0] * X[j][1]
  print(ans)
  #print(X)
  



Fixed submission:
x = str(input())
if x.isupper() == True:
  print("A")
else:
  print("a")

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

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

Q = int(input())

A.sort()
B = list(set(A))
X = [[0 for j in range(2)] for i in range(len(B))]
for i in range(len(B)):
  b=bisect.bisect_left(A,B[i])
  c=bisect.bisect_right(A,B[i])
  num = c - b #B[i]の要素数
  X[i][0] = B[i]
  X[i][1] = num

M = [0 for j in range(Q)]
N = [0 for j in range(Q)]
for i in range(Q):
  M[i],N[i] = map(int,input().split())

ans = int()
for i in range(Q):
  x = M[i]
  y = N[i]
  ans = 0
  jg = False
  for j in range(len(B)):
    if X[j][0] == y:
      jg = True
      jgx = j
  for j in range(len(B)):
    if X[j][0] == x:
      X[j][0] = y
      if jg == True:
        X[j][1] += X[jgx][1]
        X[jgx][0] = 0
    ans += X[j][0] * X[j][1]
  print(ans)
  #print(X)
  



Fixed submission:
x = str(input())
if x.isupper() == True:
  print("A")
else:
  print("a")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

ans = 1
for i in range(N):
  ans = ans * A[i]

if ans > 1e+18:
  print(-1)
else:
  print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
A.sort()

ans = 1

for i in range(N):
  if A[i] == 0:
    ans = 0
    break
  ans = ans * A[i]
  if ans > 1e+18:
    ans = -1
    break

print(ans)

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

ans = 1
for i in range(N):
  ans *= A[i]

if ans >= 1e+18:
  print(-1)
else:
  print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
A.sort()

ans = 1

for i in range(N):
  if A[i] == 0:
    ans = 0
    break
  ans = ans * A[i]
  if ans > 1e+18:
    ans = -1
    break

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

if K <= A:
	max = K
elif A < K and K <= A+B
	max = A
else:
	max = A-(K-(A+B))
	
print(max)

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

if K <= A:
	max = K
elif A < K and K <= A+B:
	max = A
else:
	max = A-(K-(A+B))
	
print(max)
Buggy python submission (verdict: Runtime Error):
S = input()

if S = 'ARC':
	print('ABC')
else
	ptint('ARC')

Fixed submission:
S = input()

if S == 'ARC':
	print('ABC')
else:
	print('ARC')
Buggy python submission (verdict: Runtime Error):

N, M = map(int,input().split())

H = [0] + list(map(int,input().split()))

path = [0]
for i in range(1,N+1):
	path.append([])

for i in range(1,M+1):
	A, B = map(int,input().split())
	path[A].append(B)
	path[B].append(A)

count = 0

for i in range(1,N+1):
	if H[i] > max(H[j] for j in path[i]):
		count += 1
	
print(count)

Fixed submission:

N, M = map(int,input().split())

H = [0] + list(map(int,input().split()))

path = [0]
for i in range(1,N+1):
	path.append([])

for i in range(1,M+1):
	A, B = map(int,input().split())
	path[A].append(B)
	path[B].append(A)

count = 0

for i in range(1,N+1):
	if len(path[i]) == 0:
		count += 1
	elif H[i] > max(H[j] for j in path[i]):
		count += 1
	
print(count)

Buggy python submission (verdict: Runtime Error):

N, M = map(int,input().split())]

H = [0] + list(map(int,input().split()))

path = {}
for i in range(1,N+1):
	path[i] = {}

for i in range(1,M+1):
	A, B = map(int,input().split())
	path[A].add(B)
	path[B].add(A)

count = 0

for i in range(1,N+1)
	if H[i] > max(H[j] for j in path[i]):
		count += 1
	
print(count)

Fixed submission:

N, M = map(int,input().split())

H = [0] + list(map(int,input().split()))

path = [0]
for i in range(1,N+1):
	path.append([])

for i in range(1,M+1):
	A, B = map(int,input().split())
	path[A].append(B)
	path[B].append(A)

count = 0

for i in range(1,N+1):
	if len(path[i]) == 0:
		count += 1
	elif H[i] > max(H[j] for j in path[i]):
		count += 1
	
print(count)
Buggy python submission (verdict: Runtime Error):
S = int(input())
W = int(input())

if W >= S:
 print('unsafe')
else:
 print('safe')

Fixed submission:
S = list(map(int,input().split()))
 
if S[1] >= S[0]:
 print('unsafe')
else:
 print('safe')
Buggy python submission (verdict: Runtime Error):
n = input()
sum = 0
for i in range(1,n+1):
  if i % 3 == 0 or i % 5 == 0:
    continue
  else: 
    sum += i
print(sum)

Fixed submission:
n = int(input())
sum = 0
for i in range(1,n+1):
  if i % 3 == 0 or i % 5 == 0:
    continue
  else: 
    sum += i
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
import math
k = int(input())
total = 0
gcd_ab = 0

for a in range(1,k+1):
  for b in range(1, k+1):
    for c in range(1,k+1):
      gcd_ab = math.gcd(a,b)
      total += math.gcd(gcd_ab, c)

print(total)

Fixed submission:
import math
k = int(input())
total = 0
gcd_ab = 0

for a in range(1,k+1):
  for b in range(1, k+1):
    for c in range(1,k+1):
      gcd_ab = math.gcd(a,b)
      total += math.gcd(gcd_ab, c)

print(total)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().lower().split())
h = map(int, input().lower().split())

h = list(h)
max_monster = []

if k >= len(h):
  print("0")
else:
  for i in range(0, len(h)):
      h[i] = int(h[i])
      
  for i in range(0, k):
    max_monster.append(max(h))
  print(sum(h) - sum(max_monster))
  
  


Fixed submission:
N, K = map(int, input().lower().split())
H = []
total = 0
input_string = input()
H = input_string.split()
H = list(map(int, H))

H.sort(reverse = True)
del H[0:K]

print(sum(H))

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

h = list(h)

if k >= len(h):
  print("0")
else:
  for i in range(0, len(h)):
      h[i] = int(h[i])
      
  for i in range(0, k):
    h.remove(max(h))
  print(sum(h))
  

Fixed submission:
N, K = map(int, input().lower().split())
H = []
total = 0
input_string = input()
H = input_string.split()
H = list(map(int, H))

H.sort(reverse = True)
del H[0:K]

print(sum(H))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
arr = list(map(int, input().split()))

p = 1
for i in arr[:k]: p *= i
j = 0
for i in arr[k:]:
	s = (p // arr[j]) * i
	if s > p:print('Yes')
	else:print('No')
	p = s
	j += 1

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

j = 0
for i in arr[k:]:
	if i > arr[j]:print('Yes')
	else:print('No')
	j += 1
Buggy python submission (verdict: Runtime Error):
n = int(input())
arr = list(map(int, input().split()))
s = 0
for i in range(0, n, 2):
  if arr[i]%2:ans+=1
print(ans)

Fixed submission:
n = int(input())
arr = list(map(int, input().split()))
ans = 0
for i in range(0, n, 2):
  if arr[i]%2:ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
f = []

if n > 26:
	while n:
		n -= 1
		n, r = divmod(n, 26)
		f += [r]
else:
	f += [n]

g = ''
s = string. ascii_lowercase
f.reverse()
for i in f:
	g += s[i]

print(g)

Fixed submission:
import string

n = int(input())
f = []

if n > 26:
	while n:
		n -= 1
		n, r = divmod(n, 26)
		f += [r]
else:
	f += [n-1]

g = ''
s = string. ascii_lowercase
f.reverse()
for i in f:
	g += s[i]

print(g)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
#a, b = map(int, input().split())
#x, y, z = map(int, input().split())
#a, b, h, m = map(int, input().split())
arr = list(map(int, input().split()))

p = 1
for i in arr:
	p *= i
		
if p > (10**18):
	print(-1)
else:
	print(p)


Fixed submission:
n = int(input())
#a, b = map(int, input().split())
#x, y, z = map(int, input().split())
#a, b, h, m = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
p = 1
if 0 in arr:
	print(0)
else:
	for i in reversed(arr):
		p *= i
		if p > (10**18):
			print(-1)
			exit()
	print(p)
Buggy python submission (verdict: Runtime Error):
a, b, c, k = map(int, input().split())
s = min(c, k)
k -= s
if k == 0:
	print(s)
else:
	d = min(k, b)
	k -= d:
	if k == 0:
		print(s)
	else:
		f = min(k, a)
		s -= f
		print(s)

Fixed submission:
c, b, a, k = map(int, input().split())
s = min(c, k)
k -= s
if k == 0:
	print(s)
else:
	d = min(k, b)
	k -= d
	if k == 0:
		print(s)
	else:
		f = min(k, a)
		s -= f
		print(s)
Buggy python submission (verdict: Runtime Error):
from itertools import combinations as c
n, m, q = map(int, input().split())
arr = []
for i in range(q):
  l = [*map(int, input().split())]
  arr.append(l)
res = 0
for g in c(list(range(1, m+1)), n):
  f = 0
  for h in arr:
    if g[1] - g[0] == g[2]:
      f += g[3]
  res = max(res, f)
print(res)

Fixed submission:
from itertools import combinations_with_replacement as c 
n, m, q = map(int, input().split()) 
arr = [] 
for i in range(q): 
    l = [*map(int, input().split())] 
    arr.append(l) 
res = 0
for g in c(list(range(1, m+1)), n): 
    f = 0 
    for h in arr:
        if g[h[1]-1] - g[h[0]-1] == h[2]: 
            f += h[3]
    res = max(res, f) 
print(res)
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())
n, m, h = map(int, input().split())



print(h, n, m)

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

print(h, n, m)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
# x = (a * 100) // 8
y = (b * 100) // 10

for i in range(y, y + 10):
  if (i * 10) // 100 = b and (i * 8) // 100 == a:
    print(i)
    exit()
print(-1)

Fixed submission:
a, b = map(int, input().split())
# x = (a * 100) // 8
y = (b * 100) // 10

for i in range(y, y + 10):
  if (i * 10) // 100 == b and (i * 8) // 100 == a:
    print(i)
    exit()
print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdout

s = input()
q = int(input())
order = 1
for i in range (q):
  e = input().split()
  if e[0] == '1':
    order *= (-1)
  else:
    if order == 1:
      if e[1] == '1':
        s = e[2] + s
      else:
        s += e[2]
    else:
      if e[1] == '2':
        s = e[2] + s
      else:
        s += e[2]
stdout.write(s if order == 1 else s[::-1])

Fixed submission:
from sys import stdout

s = input()
q = int(input())
pref = ''
suff = ''
order = 1
for i in range (q):
  e = input().split()
  if e[0] == '1':
    order *= (-1)
  else:
    if order == 1:
      if e[1] == '1':
        pref = e[2] + pref
      else:
        suff += e[2]
    else:
      if e[1] == '2':
        pref = e[2] + pref
      else:
        suff += e[2]
if order == 1:
    stdout.write(pref)
    stdout.write(s)
    stdout.write(suff)
else:
    stdout.write(suff[::-1])
    stdout.write(s[::-1])
    stdout.write(pref[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
order = 1
for i in range (q):
  e = input().split()
  if e[0] == '1':
    order *= (-1)
  else:
    if order == 1:
      if e[1] == '1':
        s = e[2] + s
      else:
        s += e[2]
    else:
      if e[1] == '2':
        s = e[2] + s
      else:
        s += e[2]
print(s if order == 1 else s[::-1])

Fixed submission:
from sys import stdout

s = input()
q = int(input())
pref = ''
suff = ''
order = 1
for i in range (q):
  e = input().split()
  if e[0] == '1':
    order *= (-1)
  else:
    if order == 1:
      if e[1] == '1':
        pref = e[2] + pref
      else:
        suff += e[2]
    else:
      if e[1] == '2':
        pref = e[2] + pref
      else:
        suff += e[2]
if order == 1:
    stdout.write(pref)
    stdout.write(s)
    stdout.write(suff)
else:
    stdout.write(suff[::-1])
    stdout.write(s[::-1])
    stdout.write(pref[::-1])
Buggy python submission (verdict: Runtime Error):
n, r = map(int, input.split())
if n >= 10:
  print(r)
else:
  print(r+100*(10-n))

Fixed submission:
n, r = map(int, input().split())
if n >= 10:
  print(r)
else:
  print(r+100*(10-n))
Buggy python submission (verdict: Runtime Error):
n = int(input())
arr = list(map(int, input().spli()))
s = sum(arr)
p = s//n
r = 0
for i in arr:
  r += (p-i)**2
print(r)

Fixed submission:
n = int(input())
arr = list(map(int, input().split()))
m = 1000000000000000
for p in range (1, max(arr)+1):
  r = 0
  for i in arr:
    r += (p-i)**2
  m = min(m, r)
print(m)