Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N, K= map(int, input().split())
lists = list(map(int, input().split()))
lists.sort()
if K>=N:
  print(0)
else:
  if K==0:
    SUM = sum(lists)
    print(SUM)
  else:
      del lists[-K:]
      SUM = sum(lists)
      print(SUM)

Fixed submission:
H, A = map(int,input().split())
a = int(H/A)
b = H/A
if a==b:
  print(a)
else:
  c = a+1
  print(c)

Buggy python submission (verdict: Runtime Error):
N, K= map(int, input().split())
lists = list(map(int, input().split()))
lists.sort()
if K>=N:
  print(0)
else:
  del lists[-K:]
  SUM = sum(lists)
  print(SUM)

Fixed submission:
H, A = map(int,input().split())
a = int(H/A)
b = H/A
if a==b:
  print(a)
else:
  c = a+1
  print(c)

Buggy python submission (verdict: Runtime Error):
N, K= map(int, input().split())
lists = list(map(int, input().split()))
lists.sort()
if K>=N:
  print(0)
else:
  if K==0:
    print(SUM)
  else:
      del lists[-K:-1]
      SUM = sum(lists)
      print(SUM)

Fixed submission:
H, A = map(int,input().split())
a = int(H/A)
b = H/A
if a==b:
  print(a)
else:
  c = a+1
  print(c)

Buggy python submission (verdict: Runtime Error):
N, K= map(int, input().split())
lists = list(map(int, input().split()))
lists.sort()
if K>=N:
  print(0)
else:
  del lists[-K:]
  SUM = sum(lists)
  print(SUM)

Fixed submission:
H, A = map(int,input().split())
a = int(H/A)
b = H/A
if a==b:
  print(a)
else:
  c = a+1
  print(c)

Buggy python submission (verdict: Runtime Error):
H,N = map(int, input().split())
lists = list(map(int, input().split()))
lists.sort()
if N>=2:
  if lists[-2]+lists[-1]>=H:
    print('Yes')
  else:
    print('No')
else:
  if lists[0]>=H:
    print('Yes')
  else:
    print('No')

Fixed submission:
H, A = map(int,input().split())
a = int(H/A)
b = H/A
if a==b:
  print(a)
else:
  c = a+1
  print(c)

Buggy python submission (verdict: Runtime Error):
H,N = map(int, input().split())
lists = list(map(int, input().split()))
lists.sort()
if N>=2:
  if lists[N-1]+lists[N-2]>=H:
    print('Yes')
  else:
    print('No')
else:
  if lists[0]>=H:
    print('Yes')
  else:
    print('No')

Fixed submission:
H, A = map(int,input().split())
a = int(H/A)
b = H/A
if a==b:
  print(a)
else:
  c = a+1
  print(c)

Buggy python submission (verdict: Runtime Error):
H,N = map(int, input().split())
lists = list(map(int, input().split())
lists.sort()
if N>=2 and lists[N-1]+lists[N-2]>=H:
  print('Yes')
If N==1 and lists[0]>=H:
  print('Yes')
if N==1 and lists[0]<H:
  print('No')
else:
  print('No')

Fixed submission:
H, A = map(int,input().split())
a = int(H/A)
b = H/A
if a==b:
  print(a)
else:
  c = a+1
  print(c)

Buggy python submission (verdict: Runtime Error):
H,N = map(int, input().split())
lists = [] 
lists.append(int, input().split())
lists = lists.sort()
if N>=2 and lists[N-1]+lists[N-2]>=H:
  print('Yes')
If N==1 and lists[0]>=H:
  print('Yes')
if N==1 and lists[0]<H:
  print('No')
else:
  print('No')

Fixed submission:
H, A = map(int,input().split())
a = int(H/A)
b = H/A
if a==b:
  print(a)
else:
  c = a+1
  print(c)
Buggy python submission (verdict: Runtime Error):
H,N = map(int, input().split())
lists = [] lists.append(int, input().split())
lists = lists.sort()
if N>=2 and lists[N-1]+lists[N-2]>=H:
  print('Yes')
If N==1 and lists[0]>=H:
  print('Yes')
if N==1 and lists[0]<H:
  print('No')
else:
  print('No')

Fixed submission:
H,N = map(int, input().split())
lists = list(map(int, input().split()))
lists.sort()
SAM = sum(lists)
if SAM>=H:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
a = int(input())
s = input()
if a>=3200:
  print(s)
else
  print("red")

Fixed submission:
a = int(input())
s = input()
if a>=3200:
  print(s)
else:
  print('red')

Buggy python submission (verdict: Runtime Error):
a = int(input())
s = input()
if a>=3200:
  print("red")
  else:
    print(s)

Fixed submission:
a = int(input())
s = input()
if a>=3200:
  print(s)
else:
  print('red')

Buggy python submission (verdict: Runtime Error):
a = int(input())
s = input()
if a>=3200:
  print(red)
else:
  print(s)

Fixed submission:
a = int(input())
s = input()
if a>=3200:
  print(s)
else:
  print('red')
Buggy python submission (verdict: Runtime Error):
a, b = int(input().split())
print(a*b)

Fixed submission:
a, b = list(map(int, input().split()))
print(a*b)
Buggy python submission (verdict: Runtime Error):
k = int(input())
a, b = list(map(int, input().split()))
if(k >= a and ((k / b) <= a and (k / b) =< b)):
    print('OK')
else:
    print('NG')


Fixed submission:
import math
k = int(input())
a, b = list(map(int, input().split()))
mul = math.floor(b/k) * k

if(mul >= a and (mul >= a and mul <= b)):
    print('OK')
else:
    print('NG')
Buggy python submission (verdict: Runtime Error):
k, x = list(map(int, input().split))
print('Yes') if k *500 <= x else print('No')

Fixed submission:
k, x = list(map(int, input().split()))
print('Yes') if k *500 >= x else print('No')
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
print(( 2 * n ) // math.gcd(2, n))

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

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
print(( 2 * n ) //math.gcd(2, n))

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

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
print(( 2 * n ) //math.gcd(2, n))


Fixed submission:
n = int(input())
if n % 2 == 0:
    print(n)
else:
    print(n * 2)
Buggy python submission (verdict: Time Limit Exceeded):
a = list(map(int,input().split()))
n = a[0]
k = a[1]

while n > abs(n-k):
  n = abs(n-k)
print(n)

Fixed submission:
a = list(map(int,input().split()))
n = a[0]
k = a[1]

if 2*n <= k:
  n = n
elif (k<2*n)and(n<=k):
  n = k-n
elif k<n:
  n = n%k
  if 2*n<=k:
    n = n
  else:
    n = k-n
print(n)
Buggy python submission (verdict: Runtime Error):
import math

def a():
    s = input()
    print(s[:3])


def b():
    a, v = map(int, input().split())
    b, w = map(int, input().split())
    t = int(input())
    if v > w:
        if abs(a-b) / (v -w) <= t
            print('YES')
        else:
            print('NO')
    else:
        print('NO')


def c():
    print('')



def d():
    print('')


b()

Fixed submission:
import math

def a():
    s = input()
    print(s[:3])


def b():
    a, v = map(int, input().split())
    b, w = map(int, input().split())
    t = int(input())
    if v > w:
        if abs(a-b) / (v -w) <= t:
            print('YES')
        else:
            print('NO')
    else:
        print('NO')


def c():
    print('')



def d():
    print('')


b()
Buggy python submission (verdict: Runtime Error):
def a():
    n = int(input()) % 10
    if n == 2 or n == 4 or n == 5 or n == 7 or n == 9:
        print('hon')
    elif n == 3:
        print('bon')
    else:
        print('pon')




def b():

def c():
    

# def d():


a()

Fixed submission:
def a():
    n = int(input()) % 10
    if n == 2 or n == 4 or n == 5 or n == 7 or n == 9:
        print('hon')
    elif n == 3:
        print('bon')
    else:
        print('pon')




# def b():

# def c():
    

# def d():


a()
Buggy python submission (verdict: Time Limit Exceeded):

def c():
    n = int(input())
    s = ['']*n
    for i in range(n):
        temp = input()
        if temp not in s:
            s[i]  = temp
    print(n - s.count(''))

def b():
    a,b,c,d = map(int, input().split())
    while True:
        c -= b
        if c <= 0:
            print('Yes')
            break
        a -= d
        if a <= 0:
            print('No')
            break

def a():
    s, w = map(int, input().split())
    if w >= s:
        print('unsafe')
    else:
        print('safe')



c()

Fixed submission:

def c():
    n = int(input())
    s = ['']*n
    for i in range(n):
        s[i] = input()
    s.sort()
    count = 1
    for i in range(1, n):
        if s[i - 1] != s[i]:
            count += 1
    print(count)

def b():
    a,b,c,d = map(int, input().split())
    while True:
        c -= b
        if c <= 0:
            print('Yes')
            break
        a -= d
        if a <= 0:
            print('No')
            break

def a():
    s, w = map(int, input().split())
    if w >= s:
        print('unsafe')
    else:
        print('safe')



c()

Buggy python submission (verdict: Time Limit Exceeded):

def c():
    n = int(input())
    s = []
    for i in range(n):
        temp = input()
        if temp not in s:
            s.append(temp)
    print(len(s))

def b():
    a,b,c,d = map(int, input().split())
    while True:
        c -= b
        if c <= 0:
            print('Yes')
            break
        a -= d
        if a <= 0:
            print('No')
            break

def a():
    s, w = map(int, input().split())
    if w >= s:
        print('unsafe')
    else:
        print('safe')



c()

Fixed submission:

def c():
    n = int(input())
    s = ['']*n
    for i in range(n):
        s[i] = input()
    s.sort()
    count = 1
    for i in range(1, n):
        if s[i - 1] != s[i]:
            count += 1
    print(count)

def b():
    a,b,c,d = map(int, input().split())
    while True:
        c -= b
        if c <= 0:
            print('Yes')
            break
        a -= d
        if a <= 0:
            print('No')
            break

def a():
    s, w = map(int, input().split())
    if w >= s:
        print('unsafe')
    else:
        print('safe')



c()
Buggy python submission (verdict: Time Limit Exceeded):
# import numpy as np

# aとbの最大公約数
def GCD(a,b):
    # ユークリッドの互除法
    if b == 0:
        return a
    else:
        return GCD(b,a % b)



k = int(input())
sum = 0

for i in range(1, k + 1):
    for j in range(1, k + 1):
        for k in range(1, k + 1):
            sum = sum + GCD(GCD(i, j),k)
print(sum)

Fixed submission:
# import numpy as np

# aとbの最大公約数
def GCD(a,b):
    # ユークリッドの互除法
    if b == 0:
        return a
    else:
        return GCD(b,a % b)



k = int(input())
sum = 0
count = [0] * k

for i in range(1, k + 1):
    for j in range(1, k + 1):
        count[GCD(i, j) - 1] += 1

# print(count)
for i in range(1, k + 1):
    for j, n in enumerate(count):
        sum = sum + GCD(i, j + 1) * n
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
l.sort()
count = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        for k in range(j + 1, n):
            if l[k] < l[i] + l[j]:
                count += 1
            else:
                break
print(count)

Fixed submission:
import bisect
n = int(input())
l = list(map(int, input().split()))
l.sort()
count = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        itr = bisect.bisect_left(l, l[i] + l[j])
        count += itr - 1 - j
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
count = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        for k in range(j + 1, n):
            if l[i] < l[j] + l[k] and l[j] < l[i] + l[k] and l[k] < l[i] + l[j]:
                count += 1
print(count)

Fixed submission:
import bisect
n = int(input())
l = list(map(int, input().split()))
l.sort()
count = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        itr = bisect.bisect_left(l, l[i] + l[j])
        count += itr - 1 - j
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
for i in range(1, n + 1):
    print(a.index(i)+1, end=' ')

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [0]*n
for index, item in enumerate(a, 1):
    b[item-1] = index
for i in b:
    print(i,end=' ')
Buggy python submission (verdict: Runtime Error):
def in(x):
	if x == 0:
		return 1
    if x == 1:
		return 0
x = int(input())
print(in(x))

Fixed submission:
x = int(input())
if x == 0:
  print(1)
if x == 1:
  print(0)
Buggy python submission (verdict: Runtime Error):
s = str(input())
t = str(input())
count = 0
for i range(len(s)):
  if s[i] == t[i]:
  	pass
  else:
    count += 1
print(count)

Fixed submission:
s=str(input())
t=str(input())
length=len(s)
count=0
for i in range(length):
	if s[i]==t[i]:
		pass
	else:
		count+=1
print(count)

Buggy python submission (verdict: Runtime Error):
s = str(input())
t = str(input())
count = 0
for i range(len(s)+1):
  if s[i] == t[i]:
    pass
  else:
    count += 1
print(count)

Fixed submission:
s=str(input())
t=str(input())
length=len(s)
count=0
for i in range(length):
	if s[i]==t[i]:
		pass
	else:
		count+=1
print(count)

Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
count = 0
for i range(len(s)):
  if s[i] == t[i]:
    pass
  else:
    count += 1
print(count)

Fixed submission:
s=str(input())
t=str(input())
length=len(s)
count=0
for i in range(length):
	if s[i]==t[i]:
		pass
	else:
		count+=1
print(count)

Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
count = 0
for i range(len(s)+1):
  if s[i] == t[i]:
    pass
  else:
    count += 1
print(count)

Fixed submission:
s=str(input())
t=str(input())
length=len(s)
count=0
for i in range(length):
	if s[i]==t[i]:
		pass
	else:
		count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
k = int(input())
a, b = map(input().split())
for i in range(a, b):
    if i % k == 0:
        print("OK")
    else:
        print("NG")

Fixed submission:
k = int(input())
a, b = map(int, input().split())
re = False
for i in range(a, b+1):
    if (i % k) == 0:
        re = True
        break
if re == True:
    print("OK")
else:
    print("NG")
Buggy python submission (verdict: Runtime Error):
s, w = (for i in input().split())
if s > w:
  print("safe")
if w >= s:
  print("unsafe")

Fixed submission:
s, w = (int(x) for x in input().split())
if s > w:
  print("safe")
if w >= s:
  print("unsafe")

Buggy python submission (verdict: Runtime Error):
s, w = int(input().split())
if s > w:
  print("safe")
if w > s:
  print("unsafe")
if s == w:
  print("unsafe")

Fixed submission:
s, w = (int(x) for x in input().split())
if s > w:
  print("safe")
if w >= s:
  print("unsafe")

Buggy python submission (verdict: Runtime Error):
s, w = int(input().split())
if s > w:
  print("Safe")
if w > s:
  print("Unsafe")

Fixed submission:
s, w = (int(x) for x in input().split())
if s > w:
  print("safe")
if w >= s:
  print("unsafe")
Buggy python submission (verdict: Runtime Error):
t, k, c, d = [int(x) for x in input().split()]
while (t >= 0 or c >= 0):
  c = c - k
  if c <= 0:
    print("Yes")
    break
  t = t - d
  if a <= 0:
    print("No")
    break

Fixed submission:
t, k, c, d = (int(x) for x in input().split())
while (t >= 0 or c >= 0):
  c = c - k
  if c <= 0:
    print("Yes")
    break
  t = t - d
  if t <= 0:
    print("No")
    break

Buggy python submission (verdict: Runtime Error):
t, k, c, d = (int(x) for x in input().split())
while (t >= 0 or c >= 0):
  c = c - k
  if c <= 0:
    print("Yes")
    break
  t = t - d
  if a <= 0:
    print("No")
    break

Fixed submission:
t, k, c, d = (int(x) for x in input().split())
while (t >= 0 or c >= 0):
  c = c - k
  if c <= 0:
    print("Yes")
    break
  t = t - d
  if t <= 0:
    print("No")
    break
Buggy python submission (verdict: Runtime Error):
N=input()

N=int(N[-1])

if N==3:
  print("bon")
elif N in [1,2,4,5,7,9]:
  print("hon")
else N in [0,1,6,8]:
  print("pon")
  
  


Fixed submission:
N=input()
 
N=int(N[-1])
 
if N==3:
  print("bon")
elif N in [2,4,5,7,9]:
  print("hon")
else :
  print("pon")
Buggy python submission (verdict: Runtime Error):
A=input()

if A="ABC":
  print("ARC")
else:
  print("ABC")

Fixed submission:
A=input()

if A=="ABC":
  print("ARC")
else:
  print("ABC")
Buggy python submission (verdict: Time Limit Exceeded):
#C
#入力
K=int(input())+1


#デバッグ用
def pront(*n):
    if debug==1:
        print(n)
        
debug=1#0:本番,1:デバッグ

#処理
import math as m

Z=[ [ [-1 for i in range(K)] for j in range(K)] for l in range(K)]
def C_1(i,j,k):
    xx=[i,j,k]
    xx.sort()
    if Z[xx[0]][xx[1]][xx[2]]!=-1:
        return Z[xx[0]][xx[1]][xx[2]]
    else:
        Z[xx[0]][xx[1]][xx[2]]=m.gcd(m.gcd(xx[0],xx[1]),xx[2])
        return Z[xx[0]][xx[1]][xx[2]]


x=0
for i in range(1,K):
    for j in range(1,K):
        if m.gcd(i,j)==1:
            x+=K-1
        else:
            for k in range(1,K):
                x+=C_1(i,j,k)
print(x)

Fixed submission:
#C
#入力
K=int(input())


#デバッグ用
def pront(*n):
    if debug==1:
        print(n)
        
debug=1#0:本番,1:デバッグ

#処理
import math as m
Z=[ [-1 for i in range(K+1)] for j in range(K+1)]
def C_1(i,j):
    if Z[i][j]!=-1:
        return Z[i][j]
    else:
        x=m.gcd(i,j)
        Z[i][j]=x
        Z[j][i]=x
        return Z[i][j]

x=0
for i in range(1,K+1):
    for j in range(1,K+1):
        y=C_1(i,j)
        if y==1:
            x+=K
        else:
            for k in range(1,K+1):
                x+=C_1(y,k)
print(x)

Buggy python submission (verdict: Time Limit Exceeded):
#C
#入力
K=int(input())+1


#デバッグ用
def pront(*n):
    if debug==1:
        print(n)
        
debug=1#0:本番,1:デバッグ

#処理
import math as m

Z=[ [ [-1 for i in range(K)] for j in range(K)] for l in range(K)]
def C_1(i,j,k):
    xx=[i,j,k]
    xx.sort()
    if Z[xx[0]][xx[1]][xx[2]]!=-1:
        return Z[xx[0]][xx[1]][xx[2]]
    else:
        Z[xx[0]][xx[1]][xx[2]]=m.gcd(m.gcd(xx[0],xx[1]),xx[2])
        return Z[xx[0]][xx[1]][xx[2]]


x=0
for i in range(1,K):
    for j in range(1,K):
        for k in range(1,K):
            x+=C_1(i,j,k)
print(x)

Fixed submission:
#C
#入力
K=int(input())


#デバッグ用
def pront(*n):
    if debug==1:
        print(n)
        
debug=1#0:本番,1:デバッグ

#処理
import math as m
Z=[ [-1 for i in range(K+1)] for j in range(K+1)]
def C_1(i,j):
    if Z[i][j]!=-1:
        return Z[i][j]
    else:
        x=m.gcd(i,j)
        Z[i][j]=x
        Z[j][i]=x
        return Z[i][j]

x=0
for i in range(1,K+1):
    for j in range(1,K+1):
        y=C_1(i,j)
        if y==1:
            x+=K
        else:
            for k in range(1,K+1):
                x+=C_1(y,k)
print(x)
Buggy python submission (verdict: Runtime Error):
#B
#入力
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
d=[list(map(int,input().split())) for i in range(M)]

#処理
x=min(a)+min(b)

for i in d:
    t=a[d[0]-1]+b[d[1]-1]-d[2]
    if t>x:
        x=t
print(x)
        

Fixed submission:
#B
#入力
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
d=[list(map(int,input().split())) for i in range(M)]

#処理
x=min(a)+min(b)

for i in d:
    t=a[i[0]-1]+b[i[1]-1]-i[2]
    if t<x:
        x=t
print(x)
Buggy python submission (verdict: Runtime Error):
#C
import math
#入力
A,B=map(int,input().split())

#処理
c=0
d=0
c=max([math.floor(A/0.08),math.floor(B/0.1)])
d=min([math.ceil((A+1)/0.08),math.ceil((B+1)/0.1)])
x=-1
for i in range(c,d+1):
    if math.floor(i*0.08)==A and math.floor(i*0.1)==B:
        z=i
        break
print(z)

Fixed submission:
#C
import math
#入力
A,B=map(int,input().split())

#処理
c=0
d=0
c=max([math.floor(A/0.08),math.floor(B/0.1)])
d=min([math.ceil((A+1)/0.08),math.ceil((B+1)/0.1)])
z=-1
for i in range(c,d+1):
    if math.floor(i*0.08)==A and math.floor(i*0.1)==B:
        z=i
        break
print(z)

Buggy python submission (verdict: Runtime Error):
#C
import math
#入力
A,B=map(int,input().split())

#処理
c=0
d=0
c=max([math.floor(A/0.08),math.floor(B/0.1)])
d=min([math.ceil((A+1)/0.08),math.ceil((B+1)/0.1)])
print(c,d)
x=-1
for i in range(c,d+1):
    if math.floor(i*0.08)==A and math.floor(i*0.1)==B:
        z=i
        break
print(z)


Fixed submission:
#C
import math
#入力
A,B=map(int,input().split())

#処理
c=0
d=0
c=max([math.floor(A/0.08),math.floor(B/0.1)])
d=min([math.ceil((A+1)/0.08),math.ceil((B+1)/0.1)])
z=-1
for i in range(c,d+1):
    if math.floor(i*0.08)==A and math.floor(i*0.1)==B:
        z=i
        break
print(z)
Buggy python submission (verdict: Time Limit Exceeded):
#D
#入力
S=input()
Q=int(input())
#Query=[]
#for i in range(Q):
#    Query.append(list(input().split()))
    
    
#処理
t=0
b=""
a=""
for j in range(Q):
    i=list(input().split())
    if i[0]=="1":
        t+=1
        c=b
        b=a[::-1]
        a=c[::-1]
    elif i[0]=="2":
        if i[1]=="1":
            b=i[2]+b
        elif i[1]=="2":
            a=a+i[2]
if t%2==0:
    print(b+S+a)
    
else:
    print(b+S[::-1]+a)

Fixed submission:
#D
#入力
S=input()
Q=int(input())
#Query=[]
#for i in range(Q):
#    Query.append(list(input().split()))
    
    
#処理
t=0
b=""
a=""
for j in range(Q):
    i=list(input().split())
    if i[0]=="1":
        t+=1
    elif i[0]=="2":
        if t%2==0:
            if i[1]=="1":
                b=i[2]+b
            elif i[1]=="2":
                a=a+i[2]
        elif t%2==1:
            if i[1]=="1":
                a=a+i[2]
            elif i[1]=="2":
                b=i[2]+b
if t%2==0:
    print(b+S+a)
    
else:
    print(a[::-1]+S[::-1]+b[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
#D
#入力
S=input()
Q=int(input())
#Query=[]
#for i in range(Q):
#    Query.append(list(input().split()))
    
    
#処理
t=0
for j in range(Q):
    i=list(input().split())
    if i[0]=="1":
        t+=1
    elif i[0]=="2":
        if t%2==1:
            S=S[::-1]
        t=0
        if i[1]=="1":
            S=i[2]+S
        elif i[1]=="2":
            S=S+i[2]
if t%2==1:
    S=S[::-1]
print(S)

Fixed submission:
#D
#入力
S=input()
Q=int(input())
#Query=[]
#for i in range(Q):
#    Query.append(list(input().split()))
    
    
#処理
t=0
b=""
a=""
for j in range(Q):
    i=list(input().split())
    if i[0]=="1":
        t+=1
    elif i[0]=="2":
        if t%2==0:
            if i[1]=="1":
                b=i[2]+b
            elif i[1]=="2":
                a=a+i[2]
        elif t%2==1:
            if i[1]=="1":
                a=a+i[2]
            elif i[1]=="2":
                b=i[2]+b
if t%2==0:
    print(b+S+a)
    
else:
    print(a[::-1]+S[::-1]+b[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
#D
#入力
S=input()
Q=int(input())
Query=[]
for i in range(Q):
    Query.append(list(input().split()))
    
    
#処理

for i in Query:
    if i[0]=="1":
        S=S[::-1]
    elif i[0]=="2":
        if i[1]=="1":
            S=i[2]+S
        elif i[1]=="2":
            S=S+i[2]
print(S)

Fixed submission:
#D
#入力
S=input()
Q=int(input())
#Query=[]
#for i in range(Q):
#    Query.append(list(input().split()))
    
    
#処理
t=0
b=""
a=""
for j in range(Q):
    i=list(input().split())
    if i[0]=="1":
        t+=1
    elif i[0]=="2":
        if t%2==0:
            if i[1]=="1":
                b=i[2]+b
            elif i[1]=="2":
                a=a+i[2]
        elif t%2==1:
            if i[1]=="1":
                a=a+i[2]
            elif i[1]=="2":
                b=i[2]+b
if t%2==0:
    print(b+S+a)
    
else:
    print(a[::-1]+S[::-1]+b[::-1])