Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
s = list(input())
print(''.join(li[0:2]))

Fixed submission:
s = input()
print(s[0:3])

Buggy python submission (verdict: Runtime Error):
import random
val = input()
 
if len(val)<=3:
  val = input('Enter your name: ')
elif len(val)>=20:
  val = input('Enter your name: ')
else:
  t = random.randint(0,len(val)-3)
  print(val[t:t+3])

Fixed submission:
val = input()
print(val[0:3])

Buggy python submission (verdict: Runtime Error):
import random
val = input('Enter your name: ')
 
if len(val)<=3:
  val = input('Enter your name: ')
elif len(val)>=20:
  val = input('Enter your name: ')
else:
  print(len(val))
  t = random.randint(0,len(val)-3)
  print(val[t:t+3])

Fixed submission:
val = input()
print(val[0:3])

Buggy python submission (verdict: Runtime Error):
import random
val = input('Enter your name: ')
 
if len(val)<=3:
  val = input('Enter your name: ')
elif len(val)>=20:
  val = input('Enter your name: ')
 
else:
 print(len(val))
 t = random.randint(0,len(val)-3)
 print(val[t:t+3])

Fixed submission:
val = input()
print(val[0:3])

Buggy python submission (verdict: Runtime Error):
val = input('Enter your name: ')

if len(val)<=3:
  val = input('Enter your name: ')
elif len(val)>=20:
  val = input('Enter your name: ')

else:

print(val)

print(len(val))

t = random.randint(0,len(val)-2)

print(val[t]val[t+1]val[t+2])
  

Fixed submission:
val = input()
print(val[0:3])

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10000)

a, v = map(int, input().split(" "))
b, w = map(int, input().split(" "))
t = int(input())


def onigokko(a, v, b, w):
    if v == w or a == b:
        return False

    if b > a:
        time = (b-a)/(v-w)
    else:
        time = (b-a)/(w-v)

    if time < 0:
        return False
    if time.is_integer():
        return True
    if time > t:
        return False

    onigokko(a, v, b, w)


result = onigokko(a, v, b, w)
if result:
    print("YES")
else:
    print("NO")



Fixed submission:
# -*- coding: utf-8 -*-

_in = input()

# if True:
#     print(_in)
# else:
#     print(_in)

print(_in[0:3])

Buggy python submission (verdict: Runtime Error):
import sys
a,v=list(map(int,input().split()))
b,w=list(map(int,input().split()))
t=int(input())
if v-w==0:
  if a==b:
    print("YES")
  else:
    print("NO")
  sys.exit()
temp=(b-a)/(v-w)
if temp<0 or temp>t:
  print("NO")
else:
  print("YES")

Fixed submission:
s=input()
print(s[0:3])
Buggy python submission (verdict: Runtime Error):
n,k=list(map(int,input().split()))
arr=list(map(int,input().split()))
vis=[False for i in range(n)]
a=[]
start=curr=0
vis[0]=True
a.append(start)
for i in range(k):
    curr=a[-1]
    if vis[arr[curr-1]-1]:
        a.append(arr[curr-1] - 1)
        break
    else:
        vis[arr[curr-1]-1]=True
        a.append(arr[curr-1]-1)
#now i have req cycle
if 3>5 and a[0]==a[-1]:
    a.pop()
    #print("helo")
    #print(len(a),a)
    print(a[k%(len(a))]+1)
else:
    count=0
    #print(a,"a")
    for i in range(len(a)):
        if a[i]==a[-1]:
            new=a[i:-1]
            #print(new,a[i:-1])
            break
        else:
            count+=1
    #print(len(new),new)
    #rint(count,"c")
    print(new[(k-count)%(len(new))]+1)


Fixed submission:
s=input()
t=input()
if s==t[:-1]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import sys
n=input()
for i in n:
	if i=='7':
		print('Yes')
        sys.exit()
print('No')

Fixed submission:
import sys
n=input()
for i in n:
	if i=='7':
		print('Yes')
		sys.exit()
print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
k=int(input())
def solve(a,b):
	if a<b:
		if b%a==0:
			return a
		else:
			return solve(a,b%a)
	if a%b==0:
		return b
	else:
		return solve(b,a%b)
arr=[i+1 for i in range(k)]

l = [p for p in itertools.product(arr, repeat=3)]
s=0
dic={}
for i in l:
	a,b,c=i
	s+=solve(c,solve(a,b))
print(s)

Fixed submission:
import itertools
k=int(input())
def solve(a,b):
	if a<b:
		if b%a==0:
			return a
		else:
			return solve(a,b%a)
	if a%b==0:
		return b
	else:
		return solve(b,a%b)
arr=[i+1 for i in range(k)]
l=list(itertools.combinations_with_replacement(arr,3))
#l = [p for p in itertools.product(arr, repeat=3)]
s=0
dic={}

for i in l:
	a,b,c=i
	if a==b and a==c:
		s+=solve(c,solve(a,b))
	elif a==b or b==c or a==c:
		s+=3*(solve(c,solve(a,b)))
	else:
		s+=6*(solve(c,solve(a,b)))
print(s)
Buggy python submission (verdict: Runtime Error):
import random
S=input()
r = random.randint(0,len(S)-4)
result =""
result = S[r]+S[r+1]+S[r+2]
print(result)

Fixed submission:
import random
S=input()
r = random.randint(0,len(S)-3)
result =""
result = S[r]+S[r+1]+S[r+2]
print(result)

Buggy python submission (verdict: Runtime Error):
import random
S=input()
r = random.randint(0,len(S)-4)
result =""
result = S[r]+S[r+1]+S[r+2]
print(result)

Fixed submission:
import random
S=input()
r = random.randint(0,len(S)-3)
result =""
result = S[r]+S[r+1]+S[r+2]
print(result)

Buggy python submission (verdict: Runtime Error):
import random
S=input()
rl=[random.randint(0,len(S))for i in range(3)]
result = ""
for j in rl:
  result = result + S[j]
print(result)


Fixed submission:
import random
S=input()
r = random.randint(0,len(S)-3)
result =""
result = S[r]+S[r+1]+S[r+2]
print(result)

Buggy python submission (verdict: Runtime Error):
import random
i=input()
rl=[random.randint(0,len(i))for i in range(3)]
result = ""
for j in rl:
  result = result + i[j]
print(result)


Fixed submission:
import random
S=input()
r = random.randint(0,len(S)-3)
result =""
result = S[r]+S[r+1]+S[r+2]
print(result)
Buggy python submission (verdict: Runtime Error):
r=map(int,input())
print(r*r)

Fixed submission:
r=int(input())
print(int(r**2))
Buggy python submission (verdict: Runtime Error):
N = input()
H = list(map(int,input().split()))
 
c1 =0
c2 =0
for i in range(N-1):
  if H[i] >= H[i+1]:
    c1+=1
  else:
    if c1 > c2:
      c2=c1
    c1=0
print(c2)

Fixed submission:
N = int(input())
H = list(map(int,input().split()))
 
c1 =0
c2 =0
for i in range(N-1):
  if H[i] >= H[i+1]:
    c1+=1
  else:
    if c1 > c2:
      c2=c1
    c1=0
if c1>c2:
  c2=c1
print(c2)

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

c1 =0
c2 =0
for i in range(N-1):
  c2=0
  for j in range(i+1:N-2):
    if H[i] >= H[j]:
      c2+=1
  c1=c2
print(c1)

Fixed submission:
N = int(input())
H = list(map(int,input().split()))
 
c1 =0
c2 =0
for i in range(N-1):
  if H[i] >= H[i+1]:
    c1+=1
  else:
    if c1 > c2:
      c2=c1
    c1=0
if c1>c2:
  c2=c1
print(c2)
Buggy python submission (verdict: Runtime Error):
n=input()
n.split(" ")
if int(n[0])*int(n[1]) < int(n[2]):
  print(int(n[0])*int(n[1]))
else:
  print(int(n[2]))
  

Fixed submission:
i=input()
ii = i.split()
if int(ii[0]) * int(ii[1]) < int(ii[2]):
  print(int(ii[0]) * int(ii[1]))
else:
  print(int(ii[2]))
Buggy python submission (verdict: Runtime Error):
import numpy as np
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

if V*T <= W*T:
    print("NO")
elif A > B:
    if A - V*T > B - W*T:
        print ("NO")
    else:
        print("YES")
else:
    if A + V*T > B - W*T:
        print("YES")
    else:
        print("NO")
        

Fixed submission:
A = str(input())
print(A[0:3])
Buggy python submission (verdict: Runtime Error):
K = int(input())
S = str(input())

if len(S) <= K:
    print(S)
else:

    print(S[:K+1]+...)

Fixed submission:
K = int(input())
S = str(input())

if len(S) <= K:
    print(S)
else:
    print(S[:K] + "...")
Buggy python submission (verdict: Runtime Error):
import numpy as np
N,M = map(int,input().split())
A = [int(a) for a input().split()]

Asum = sum(A)
if Asum > N:
  print(-1)
else:
  print(N - Asum)

Fixed submission:
N,M = map(int,input().split())
A =list(map(int, input().split()))
Asum = sum(A)
if Asum > N:
  print(-1)
else:
  print(N - Asum)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,inport().split())
if N == M:
  print("Yes")
else:
  print("No")


Fixed submission:
N,M = map(int,input().split())
if N == M:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
N,M = map(str,inport().split())
if N == M:
  print("Yes")
else:
  print("No")

Fixed submission:
N,M = map(int,input().split())
if N == M:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
S,T = map(str,imput().split())
print(S + T)


Fixed submission:
S,T = map(str,input().split())
print(T + S)

Buggy python submission (verdict: Runtime Error):
S,T = map(str,import().split())
print(S + T)

Fixed submission:
S,T = map(str,input().split())
print(T + S)
Buggy python submission (verdict: Runtime Error):
N = int(input())
list = [1,2,3,4,5,6,7,8,9,10,12,14,16,18,15,21,24,27,20,28,32,36,25,35,40,45,30,42,48,54,49,56,63,64,72,81]
for N in list:
  print("Yes")
else:
  print("No")


Fixed submission:
A,B = map(int,input().split())
if A < 10:
  if B < 10:
    print(A*B)
  else:
    print("-1")
else:
  print("-1")
Buggy python submission (verdict: Runtime Error):
N = input()
if N < 10:
  print(N)
else:
  if 9 < N < 100:
    print("9")
  else:
    if 99 < N < 1000:
      print(N - 90)
    else:
      if 999 < N < 10000:
        print("909")
      else:
        if 9999 < N < 100000:
          print(909 +  N - 9999)
        else:
          if N = 100000:
            print("90909")


Fixed submission:
N = int(input())
if N < 10:
  print(N)
else:
  if 9 < N < 100:
    print("9")
  else:
    if 99 < N < 1000:
      print(N - 90)
    else:
      if 999 < N < 10000:
        print("909")
      else:
        if 9999 < N < 100000:
          print(909 +  N - 9999)
        else:
          if N == 100000:
            print("90909")
Buggy python submission (verdict: Runtime Error):
r = map(int,input().split())
s = 3 * r * r
print("s")

Fixed submission:
r = int(input())
s = 3 * r * r
print(s)

Buggy python submission (verdict: Runtime Error):
r = map(int,input())
s = 3 * r * r
print("s")

Fixed submission:
r = int(input())
s = 3 * r * r
print(s)

Buggy python submission (verdict: Runtime Error):
r = input()
s = 3 * r * r
print("s")

Fixed submission:
r = int(input())
s = 3 * r * r
print(s)

Buggy python submission (verdict: Runtime Error):
r = input()
s = 3 * (r ** 2)
print("s")

Fixed submission:
r = int(input())
s = 3 * r * r
print(s)

Buggy python submission (verdict: Runtime Error):
r = input()
s = 3 * (r ** 2)
print(s)

Fixed submission:
r = int(input())
s = 3 * r * r
print(s)

Buggy python submission (verdict: Runtime Error):
r = input()
s = 3 * (a ** 2)
print(s)

Fixed submission:
r = int(input())
s = 3 * r * r
print(s)

Buggy python submission (verdict: Runtime Error):
r = input()
s = 3 * a ** 2
print("s")

Fixed submission:
r = int(input())
s = 3 * r * r
print(s)

Buggy python submission (verdict: Runtime Error):
print(3*input()*input())

Fixed submission:
r = int(input())
s = 3 * r * r
print(s)

Buggy python submission (verdict: Runtime Error):
r = map(int,input().int())
s = 3 * r ** 2
print(s)

Fixed submission:
r = int(input())
s = 3 * r * r
print(s)

Buggy python submission (verdict: Runtime Error):
r = map(int,input())
s = 3 * r ** 2
print(s)

Fixed submission:
r = int(input())
s = 3 * r * r
print(s)

Buggy python submission (verdict: Runtime Error):
r = input()
s = 3 * (r ^ 2)
print(3 * s)

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

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

Buggy python submission (verdict: Runtime Error):
densya = N * A
if densya >= B:
	print(B)
else:
	print(A)

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

Buggy python submission (verdict: Runtime Error):
input.split() = list
densya = list[1] * list[2]
if densya >= list[3]:
	print(list[3])
else:
	print(densya)

Fixed submission:
a,b,c = map(int,input().split())
print(min(a*b , c))
Buggy python submission (verdict: Runtime Error):
a , b = map(int,input().split())
if (a * b) % 2 ==0:
    print("even")
    else:
      print("odd")
      


Fixed submission:
a , b = map(int,input().split())
if (a * b) % 2 ==0:
    print("Even")
else:
    print("Odd")
Buggy python submission (verdict: Runtime Error):
print(48 - input())

Fixed submission:
print(48 - int(input()))

Buggy python submission (verdict: Runtime Error):
M = map(int,input().split())
print(48 - M)

Fixed submission:
print(48 - int(input()))

Buggy python submission (verdict: Runtime Error):
M = map(int,input())
print(48 - M)

Fixed submission:
print(48 - int(input()))

Buggy python submission (verdict: Runtime Error):
M = map(int,input())
a = 48 - M
print(a)

Fixed submission:
print(48 - int(input()))

Buggy python submission (verdict: Runtime Error):
M = map(int,input())
print(48 - M)

Fixed submission:
print(48 - int(input()))
Buggy python submission (verdict: Runtime Error):
print(input().count(1))

Fixed submission:
print(input().count("1"))

Buggy python submission (verdict: Runtime Error):
print(input().counter("1"))

Fixed submission:
print(input().count("1"))

Buggy python submission (verdict: Runtime Error):
s = input().counter(1)
print (s)


Fixed submission:
print(input().count("1"))

Buggy python submission (verdict: Runtime Error):
s = input().count(1)
print (s)

Fixed submission:
print(input().count("1"))
Buggy python submission (verdict: Runtime Error):
n,a = map(int,input().split())
print(n * n - a)

Fixed submission:
n = int(input())
a = int(input())
print(n * n - a)
Buggy python submission (verdict: Runtime Error):
    a,b = int,input().split()
     
    c = float(b)
     
    x = a*c
     
    print(math.floor(x))

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

x = A*B

print(x)

Buggy python submission (verdict: Runtime Error):
A,B = input().split()
x = A*B
print(x)

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

x = A*B

print(x)
Buggy python submission (verdict: Runtime Error):
import numpy as np
data = input()
data = data.split(" ")
ans = 0
dataset = np.zeros(int(data[0]), dtype=np.int)
cont = int(data[1])
if int(data[1]) == 0:
    ans = 0

else:
    for i in range(int(data[0])):
        dataset[i] = 1
    for i in range(int(data[0])):
        if i == cont:
            dataset[cont:int(data[2]) + cont] = 2
            cont = i + int(data[2]) + int(data[1])

print(int(np.count_nonzero(dataset == 1)))

Fixed submission:
data = input()
if (data.count("A") == 3) or (data.count("B") == 3):
    ans = "No"
else:
    ans = "Yes"
print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
data = input()
data = data.split(" ")
ans = 0
dataset = np.zeros(int(data[0]), dtype=np.int)
cont = int(data[1])
if int(data[1]) == 0:
    ans = 0

else:
    for i in range(int(data[0])):
        dataset[i] = 1
    print(cont, data)
    for i in range(int(data[0])):
        #print(i)
        if i == cont:
            print("px")
            dataset[cont:int(data[2]) + cont] = 2
            cont = i + int(data[2]) + int(data[1])

#print(dataset, data[1], int(np.count_nonzero(dataset == 1)))
print(int(np.count_nonzero(dataset == 1)))

Fixed submission:
data = input()
if (data.count("A") == 3) or (data.count("B") == 3):
    ans = "No"
else:
    ans = "Yes"
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a=int(input())
b=0
while a>0 or b==0:
  if a%10==7:
    b=1
  a/=10
  
if b==1:
  print("Yes")
else:
  print("No")
  

Fixed submission:
a=input()

if a[0]=='7' or a[1]=='7' or a[2]=='7':
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
C = 1
for i in range(N):
  C *= A[i]
if C <= 10**18:
  print(C)
else:
  print('-1')

Fixed submission:
N = int(input())
A = sorted(list(map(int, input().split())))
C = 1
for i in range(N):
  C *= A[i]
  if C > 10**18:
    print('-1')
    break
  elif A[i]==0:
    break
if C <= 10**18:
  print(C)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = sorted(list(map(int, input().split())))
C = 1
for i in range(N):
  C *= A[i]
  if C > 10**18:
    print('-1')
if C <= 10**18:
  print(C)

Fixed submission:
N = int(input())
A = sorted(list(map(int, input().split())))
C = 1
for i in range(N):
  C *= A[i]
  if C > 10**18:
    print('-1')
    break
  elif A[i]==0:
    break
if C <= 10**18:
  print(C)
Buggy python submission (verdict: Time Limit Exceeded):
print(sum(range(int(input()))))

Fixed submission:
N = int(input())
print(int((N - 1) * N // 2))

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

Fixed submission:
N = int(input())
print(int((N - 1) * N // 2))
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())
ans = 2018
for i in range(L, R):
  if i % 2019 == 0:
    ans = 0
    break
  for j in range(L+1, R+1):
    ans = min(ans, i * j % 2019)
print(ans)

Fixed submission:
L, R = map(int, input().split())
ans = 2018
for i in range(L, R):
  if i % 2019 == 0:
    ans = 0
    break
  for j in range(L+1, R+1):
    if j % 2019 == 0:
      ans = 0
      break
    ans = min(ans, i * j % 2019)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())
ans = 2018
for i in range(L, R):
  for j in range(L+1, R+1):
    ans = min(ans, i * j % 2019)
print(ans)

Fixed submission:
L, R = map(int, input().split())
ans = 2018
for i in range(L, R):
  if i % 2019 == 0:
    ans = 0
    break
  for j in range(L+1, R+1):
    if j % 2019 == 0:
      ans = 0
      break
    ans = min(ans, i * j % 2019)
print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
if K = 1:
  print(0)
else:
  print(N - K)

Fixed submission:
N, K = map(int, input().split())
if K == 1:
  print(0)
else:
  print(N - K)
Buggy python submission (verdict: Runtime Error):
def first_three(str):
	return str[:3] if len(str) > 3 else str
  
  val = input()
 print(first_three(val))


Fixed submission:
def first_three(str):
	return str[:3] if len(str) > 3 else str
  
val = input()
print(first_three(val))
Buggy python submission (verdict: Runtime Error):
N, A, B = list(map(int, input().rstrip().split(' ')))
LIST_RESULT = []

for i in range(1, N+1):
    str_i = str(i)
    l = len(str_i)

    sum = 0
    for x in range(l):
        sum += int(str_i[x])
    if A <= sum and sum <= B:
        LIST_RESULT.append(sum)

sum_result = sum(LIST_RESULT)
print(sum_result)

Fixed submission:

N, A, B = list(map(int, input().rstrip().split(' ')))
LIST_RESULT = []

for i in range(1, N+1):
    str_i = str(i)
    l = len(str_i)

    sum_tmp = 0
    for x in range(l):
        sum_tmp += int(str_i[x])
    if A <= sum_tmp and sum_tmp <= B:
        LIST_RESULT.append(i)

sum_result = sum(LIST_RESULT)
print(sum_result)
Buggy python submission (verdict: Runtime Error):
import math
a,b = map(float, input().split())
print(math.floor((a*(b*100)/100))

Fixed submission:
a,b=input().split()
a=int(a)
b=int("".join(b.split(".")))
print((a*b)//100)

Buggy python submission (verdict: Runtime Error):
import math
a,b = map(float, input().split())
print(math.floor(((a*(b*100))/100))


Fixed submission:
a,b=input().split()
a=int(a)
b=int("".join(b.split(".")))
print((a*b)//100)

Buggy python submission (verdict: Runtime Error):
import math
a,b = input().split()
b = int(b*100)
print((a*b)//100)



Fixed submission:
a,b=input().split()
a=int(a)
b=int("".join(b.split(".")))
print((a*b)//100)

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



Fixed submission:
a,b=input().split()
a=int(a)
b=int("".join(b.split(".")))
print((a*b)//100)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N,X,Y = map(int, input().split())
cnt = np.zeros(N+1)
for i in range(1,N+1):
    for j in range(i+1,N+1):
        if abs(X-i)+abs(j-Y)+1 < j-i:
            cnt[abs(X-i)+abs(j-Y)+1] += 1
        else:
            cnt[j-i] += 1
for i in range(1,N):
    print(int(cnt[i]))

Fixed submission:
n,x,y=map(int,input().split())
ans=[0]*n
for i in range(1,n+1):
 for j in range(i+1,n+1):
   dist1=j-i
   dist2=abs(x-i)+abs(y-j)+1
   dist3=abs(y-i)+abs(x-j)+1
   d=min(dist1,dist2,dist3)
   ans[d]+=1
for i in range(1,n):
 print(ans[i])
Buggy python submission (verdict: Runtime Error):
import math
N,M = map(int, input().split())
a = 0
b = 0
if N != 1:
    a = math.factorial(N)/(2*math.factorial(N-2))
if M != 1:
    b = math.factorial(M)/(2*math.factorial(M-2))
print(int(a+b))

Fixed submission:
import math
N,M = map(int, input().split())
a = 0
b = 0
if N != 1 and N != 0:
    a = math.factorial(N)/(2*math.factorial(N-2))
if M != 1 and M != 0:
    b = math.factorial(M)/(2*math.factorial(M-2))
print(int(a+b))
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
flg = True
for _ in range(Q):
    query = input()
    if query[0] == "1":
        flg = not flg
    else:
        _,F,C = query.split()
        if (F == "1" and flg) or (F == "2" and not flg):
            S = C + S
        else:
            S = S + C
if not flg:
    S = S[::-1]
print(S)

Fixed submission:
from collections import deque

S = deque(input())
Q = int(input())
flg = True
for _ in range(Q):
    query = input()
    if query[0] == "1":
        flg = not flg
    else:
        _,F,C = query.split()
        if (F == "1" and flg) or (F == "2" and not flg):
            S.appendleft(C)
        else:
            S.append(C)
if not flg:
    S.reverse()

print(''.join(S))

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
for _ in range(Q):
    query = input()
    if query[0] == "1":
        S = S[::-1]
    else:
        _,F,C = query.split()
        if F == "1":
            S = C + S
        else:
            S = S + C
print(S)



Fixed submission:
from collections import deque

S = deque(input())
Q = int(input())
flg = True
for _ in range(Q):
    query = input()
    if query[0] == "1":
        flg = not flg
    else:
        _,F,C = query.split()
        if (F == "1" and flg) or (F == "2" and not flg):
            S.appendleft(C)
        else:
            S.append(C)
if not flg:
    S.reverse()

print(''.join(S))

Buggy python submission (verdict: Runtime Error):
import math
S = input()
Q = int(input())
for n in range(Q):
    T,F,C = input()
    if T == "1":
        S = S[::-1]
    else:
        if F == "1":
            S = C + S
        else:
            S = S + C
print(S)


Fixed submission:
from collections import deque

S = deque(input())
Q = int(input())
flg = True
for _ in range(Q):
    query = input()
    if query[0] == "1":
        flg = not flg
    else:
        _,F,C = query.split()
        if (F == "1" and flg) or (F == "2" and not flg):
            S.appendleft(C)
        else:
            S.append(C)
if not flg:
    S.reverse()

print(''.join(S))
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
print(min(n%k,k%n))

Fixed submission:
n,k=map(int,input().split())
if not n or k == 1:
	print(0)
else:
	if n >= k:
		n = n%k
	print(min(n,k-n))
Buggy python submission (verdict: Runtime Error):
n=int(input())
print(n//500 * 1000 + (n%500)//5 * 5)

Fixed submission:
s=input()
if s[3-1]==s[4-1] and s[5-1]==s[6-1]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n=int(input())
print(n//500 * 1000 + x//5 * 5)

Fixed submission:
n=int(input())
print(n//500 * 1000 + (n%500)//5 * 5)
Buggy python submission (verdict: Runtime Error):
X,Y,A,B,C=map(int,input().split())
P=sorted([int(x) for x in input().split()])
Q=sorted([int(x) for x in input().split()])
R=sorted([int(x) for x in input().split()],reverse=True)

p=A-X
q=B-Y

ans=0

for item in R:

	if item > P[p] and p<A:
		ans+=item
		p+=1
	elif item > Q[q] and q<B:
		ans+=item
		q+=1

print(ans+sum(P[p:])+sum(Q[q:]))


Fixed submission:
X,Y,A,B,C=map(int,input().split())
P=sorted([int(x) for x in input().split()])
Q=sorted([int(x) for x in input().split()])
R=sorted([int(x) for x in input().split()],reverse=True)

p=A-X
q=B-Y

final=sorted(P[p:]+Q[q:])

ans=sum(final)

i=0

for item in R:
	if item > final[i]:
		ans-=final[i]
		ans+=item
		i+=1

print(ans)