Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def update_queue(queue):
    out = queue.pop(0)
    mod10 = out % 10
    if mod10 != 0:
        queue.append(10 * out + mod10 - 1)
    queue.append(10 * out + mod10)
    if mod10 != 9:
        queue.append(10 * out + mod10 + 1)

    return out, queue

N = int(input())
Q = [1,2,3,4,5,6,7,8,9]

for _ in range(N):
    out, Q = update_queue(Q)

print(out)

Fixed submission:
def update_queue(n, queue):
    out = queue[n]
    mod10 = out % 10
    if mod10 != 0:
        queue.append(10 * out + mod10 - 1)
    queue.append(10 * out + mod10)
    if mod10 != 9:
        queue.append(10 * out + mod10 + 1)

    return out, queue

N = int(input())
Q = [1,2,3,4,5,6,7,8,9]

for i in range(N):
    out, Q = update_queue(i, Q)

print(out)

Buggy python submission (verdict: Runtime Error):
def update_queue(queue):
    out = queue.pop(0)
    mod10 = out % 10
    if mod10 != 0:
        queue.append(10 * out + mod10 - 1)
    queue.append(10 * queue + mod10)
    if mod10 != 9:
        queue.append(10 * out + mod10 + 1)

    return out, queue

N = int(input())
Q = [1,2,3,4,5,6,7,8,9]

for _ in range(N):
    out, Q = update_queue(Q)

print(out)

Fixed submission:
def update_queue(n, queue):
    out = queue[n]
    mod10 = out % 10
    if mod10 != 0:
        queue.append(10 * out + mod10 - 1)
    queue.append(10 * out + mod10)
    if mod10 != 9:
        queue.append(10 * out + mod10 + 1)

    return out, queue

N = int(input())
Q = [1,2,3,4,5,6,7,8,9]

for i in range(N):
    out, Q = update_queue(i, Q)

print(out)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
rev = 1

for i in range(Q):
  line = input()
  if line == '1':
    rev *= -1
  else:
    line = line.split()
    F = int(line[1])
    C = line[2]
    if rev * F in [1, -2]:
      S = C + S
    else:
      S = S + C

if rev == -1:
  S = S[::-1]
  
print(S)

Fixed submission:
S = input()
Q = int(input())
rev = 1

head = []
tail = []

for i in range(Q):
  line = input()
  if line == '1':
    rev *= -1
  else:
    line = line.split()
    F = int(line[1])
    C = line[2]
    if rev * F in [1, -2]:
      head.append(C)
    else:
      tail.append(C)

head = head[::-1]
S = ''.join(head + [S] + tail)

if rev == -1:
  S = S[::-1]
  
print(S)

Buggy python submission (verdict: Runtime Error):
S = int(input())
Q = int(input())
rev = 1

for i in range(Q):
  line = input()
  if line == '1':
    rev *= -1
  else:
    a, F, C = input().split()
    if rev * int(F) in [1, -2]:
      S = C + S
    else:
      S = S + C

if rev == -1:
  S = S[::-1]
  
print(S)

Fixed submission:
S = input()
Q = int(input())
rev = 1

head = []
tail = []

for i in range(Q):
  line = input()
  if line == '1':
    rev *= -1
  else:
    line = line.split()
    F = int(line[1])
    C = line[2]
    if rev * F in [1, -2]:
      head.append(C)
    else:
      tail.append(C)

head = head[::-1]
S = ''.join(head + [S] + tail)

if rev == -1:
  S = S[::-1]
  
print(S)
Buggy python submission (verdict: Time Limit Exceeded):
num = list (map (int, input().strip().split()))
n = num[0]
k = num[1]
v = list (map (int, input().strip().split()))
sum = 1
for i in range(k):
    sum *= v[i]
for i in range(k, n):
    nsum = sum / v[i - k]
    nsum *= v[i]
    if(sum < nsum):
        print("Yes")
    else:
        print("No")
    sum /= v[i - k]
    sum *= v[i]


Fixed submission:
num = list (map (int, input().strip().split()))
n = num[0]
k = num[1]
v = list (map (int, input().strip().split()))
for i in range(k, n):
    if(v[i - k] < v[i]):
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):

n = int(input())
nums = list(map(int, input().split()))
res = 1
for i in range(n):
    res *= nums[i]
if res <= 1000000000000000000:
    print(res)
else:
    print(-1)

Fixed submission:
n = int(input())
nums = list(map(int, input().split()))
res = 1
for i in range(n):
    if( nums[i] == 0):
        res = 0
if(res != 0):
    for i in range(n):
        res *= nums[i]
        if(res > 1000000000000000000):
            break
if res <= 1000000000000000000:
    print(res)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
    if(a == 0):
        return b
    return gcd(b % a, a)
def lcm(a, b):
    return a / gcd(a, b) * b
t = int(input())
ans = 1
while(t != 0):
    t -= 1
    n = int(input())
    ans = lcm(ans, n)
    ans = int(ans)
print(int(ans))


Fixed submission:
def gcd(a, b):
    if(a == 0):
        return b
    return gcd(b % a, a)
def lcm(a, b):
    return a // gcd(a, b) * b
t = int(input())
ans = 1
while(t != 0):
    t -= 1
    n = int(input())
    ans = lcm(ans, n)
print(int(ans))

Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
    if(a == 0):
        return b
    return gcd(b % a, a)
def lcm(a, b):
    return (a * b) / gcd(a, b) 
t = int(input())
ans = 1
while(t != 0):
    t -= 1
    n = int(input())
    ans = lcm(ans, n)
print(int(ans))


Fixed submission:
def gcd(a, b):
    if(a == 0):
        return b
    return gcd(b % a, a)
def lcm(a, b):
    return a // gcd(a, b) * b
t = int(input())
ans = 1
while(t != 0):
    t -= 1
    n = int(input())
    ans = lcm(ans, n)
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N,K = list(map(int, (input().split())))
A = list(map(int, (input().split())))
scorerange = N-K
for semester in range(scorerange):
    recent = A[semester:semester+K+1]
    if (recent[0]<recent[-1]):
        print("Yes")
    else:
        print("No")

Fixed submission:
N,K = list(map(int, (input().split())))
A = list(map(int, (input().split())))
scorerange = N-K
for semester in range(scorerange):
    if (A[semester]<A[semester+K]):
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
gachalist = []
counter = 0
for i in range(N):
    item = input()
    if item not in gachalist:
        gachalist.append(item)
        counter = counter+1
print(counter)

Fixed submission:
N = int(input())
gachalist=[]
for i in range(N):
    gachalist.append(input())
print(len(set(gachalist)))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
gachalist = []
for i in range(N):
    item = input()
    if item in gachalist:
        continue
    else:
        gachalist.append(item)
print(len(gachalist))

Fixed submission:
N = int(input())
gachalist=[]
for i in range(N):
    gachalist.append(input())
print(len(set(gachalist)))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
gachalist = []
for i in range(N):
    item = input()
    if item not in gachalist:
        gachalist.append(item)
print(len(gachalist))

Fixed submission:
N = int(input())
gachalist=[]
for i in range(N):
    gachalist.append(input())
print(len(set(gachalist)))
Buggy python submission (verdict: Runtime Error):
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
a = list(map(int, input().split(" ")))
min8 = a[0]/0.08
max8 = (a[0]+1)/0.08
min10 = a[1]/0.1
max10 =(a[1]+1)/0.1
a = max(min8, min10)
if ((min8>=max10) or (max8<=min10)):
    print(-1)
else:
    print(Decimal(b).quantize(Decimal('0'), rounding = ROUND_HALF_UP))

Fixed submission:
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
a = list(map(int, input().split(" ")))
min8 = a[0]/0.08
max8 = (a[0]+1)/0.08
min10 = a[1]/0.1
max10 =(a[1]+1)/0.1
b = max(min8, min10)
if ((min8>=max10) or (max8<=min10)):
    print(-1)
else:
    print(Decimal(b).quantize(Decimal('0'), rounding = ROUND_HALF_UP))
Buggy python submission (verdict: Runtime Error):
n = int(input())
w = list(map(int,input().split())
ans = 10000000
sumpoint = 0
for i in range (n):
    sumpoint = sumpoint + w[i];
    ans = min(ans, abs(sum(w)-sumpoint))
print(ans)

Fixed submission:
n = int(input())
w = list(map(int,input().split()))
ans = 10000000
sumpoint = 0
for i in range (n):
    sumpoint += w[i]
    ans = min(ans, abs(sum(w)-(2*sumpoint)))
print(ans)
Buggy python submission (verdict: Runtime Error):
def func(n):
    if n==0: return 1
    if n==1: return 1
    if dp[n]!=-1: return dp[n]
    f1 = func(n-1) if n-1 not in a else 0
    f2 = func(n-2) if n-2 not in a else 0
    dp[n] = (f1 + f2) % 1000000007
    return dp[n]
import sys
sys.setrecursionlimit(1000000)
n,m = map(int, intput().split())
a={int(input()) for i in range(m)}
dp=[-1]*(n+1)
print(func(n))

Fixed submission:
def func(n):
    if n==0: return 1
    if n==1: return 1
    if dp[n]!=-1: return dp[n]
    f1 = func(n-1) if n-1 not in a else 0
    f2 = func(n-2) if n-2 not in a else 0
    dp[n] = (f1 + f2) % 1000000007
    return dp[n]
import sys
sys.setrecursionlimit(1000000)
n,m = map(int, input().split())
a={int(input()) for i in range(m)}
dp=[-1]*(n+1)
print(func(n))

Buggy python submission (verdict: Runtime Error):
def func(n):
    if n==0: return 1
    if n==1: return 1
    if dp[n]!=-1: return dp[n]
    f1 = func(n-1) if n-1 not in a else 0
    f2 = func(n-2) if n-2 not in a else 0
    dp[n] = (f1 + f2) % 1000000007
    return dp[n]
n,m = map(int, intput().split())
a={int(input()) for i in range(m)}
dp=[-1]*(n+1)
print(func(n))

Fixed submission:
def func(n):
    if n==0: return 1
    if n==1: return 1
    if dp[n]!=-1: return dp[n]
    f1 = func(n-1) if n-1 not in a else 0
    f2 = func(n-2) if n-2 not in a else 0
    dp[n] = (f1 + f2) % 1000000007
    return dp[n]
import sys
sys.setrecursionlimit(1000000)
n,m = map(int, input().split())
a={int(input()) for i in range(m)}
dp=[-1]*(n+1)
print(func(n))
Buggy python submission (verdict: Runtime Error):
str = input()
a, b, c, d = str.split(' ')
B = int(b)
C = int(c)

if B >= C:
    print('Yes')
else:
    print('No')

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

output = 'ACL' * K
print(output)
Buggy python submission (verdict: Runtime Error):
N=int(input())
print(N%10000

Fixed submission:
N=int(input())
if N<=1000:
    print(1000-N)
if 2000>=N>1000:
    print(2000-N)
if 3000>=N>2000:
    print(3000-N)
if 4000>=N>3000:
    print(4000-N)
if 5000>=N>4000:
    print(5000-N)
if 6000>=N>5000:
    print(6000-N)
if 7000>=N>6000:
    print(7000-N)
if 8000>=N>7000:
    print(8000-N)
if 9000>=N>8000:
    print(9000-N)
if 10000>=N>=9000:
    print(10000-N)
Buggy python submission (verdict: Runtime Error):
K=int(input())
M,N = map(int,input().rstrip().split(" ")) 
#print(K,M,N)
for number in range(M,N+1):
    if number%K==0:
        ans=True
if ans:
    print("YES")
else:
    print("NG")

Fixed submission:
K=int(input())
ans = False
M,N = map(int,input().rstrip().split(" ")) 
#print(K,M,N)
for number in range(M,N+1):
    if number%K==0:
        ans = True
if ans:
    print("OK")
else:
    print("NG")
Buggy python submission (verdict: Runtime Error):
num=int(input())
if num % 2 == 0:
    ans=num/2
else:
    ans=math.floor(num//2)+1
print(int(ans))

Fixed submission:
n = int(input())
print((n+1)//2)

Buggy python submission (verdict: Runtime Error):
num=int(input())
if num % 2 == 0:
    ans=num/2
else:
    ans=math.floor(num//2)+1
print(int(ans))

Fixed submission:
n = int(input())
print((n+1)//2)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[]
for i in range(n):
  x,y=map(int,input().split())
  a.append([x,y])
f=0;
for i in range(n-2):
  if (a[i][0]=a[i][1]and a[i+1][0]=a[i+1][1] and a[i+2][0]=a[i+2][1]):
    f=1
if f:
  print("Yes")
else :
  print("No")
  

Fixed submission:
n=int(input())
a=[]
for i in range(n):
  x,y=map(int,input().split())
  a.append([x,y])
f=0;
for i in range(n-2):
  if (a[i][0]==a[i][1]and a[i+1][0]==a[i+1][1] and a[i+2][0]==a[i+2][1]):
    f=1
if f:
  print("Yes")
else :
  print("No")
Buggy python submission (verdict: Runtime Error):
n=int(input())
if (n==0)print(1)
else print(0)

Fixed submission:
n=int(input())
if (n==0):print(1)
else :print(0)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
s=sum(a)
if sum>n:
  print(-1)
else:
  print(n-s)

Fixed submission:
n,m=map(int,input().split())
a=list(map(int,input().split()))
s=sum(a)
if s>n:
  print(-1)
else:
  print(n-s)
Buggy python submission (verdict: Runtime Error):
n=int(input())
v=[]
for i in range(1,n):
    for j in range(1,n):
        k=n-i-j 
        if k>0:
            v.append(i*j*k)
print(max(v))

Fixed submission:
n=float(input())
v=[0]
print(n/3*n/3*n/3)
Buggy python submission (verdict: Runtime Error):
s=input()
q=int(input()) 

cnt = [0]*(q+5)
arr=[]
l=0
r=0

for i in range(q):
    t=input().split()
    if t[0]=='1':
        r+=1
        cnt[0]+=1 
        cnt[l]-=1 
    else:
        arr.append([t[2],int(t[1])])
        l+=1 
if r%2==1:
    s=s[::-1]
sm=0
for i in range(len(arr)):
    sm+=cnt[i]
    if sm%2==1:
        if arr[i][1]==1:arr[i][1]=2
        elif arr[i][1]==2:arr[i][1]=1 
ans1=""
ans2=""
for i in range(len(arr)):
    if arr[i][1]==1:
        ans1+=arr[i][0]

    else:ans2+=arr[i][0]
print("%s%s%s"%(ans1[::-1],s,ans2))        
        
    
    
    
    

Fixed submission:
s=input()
if s.count("A")>0 and s.count("B")>0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
q=int(input()) 

cnt = [0]*(q+5)
arr=[]
l=0
r=0

for i in range(q):
    t=input().split()
    if t[0]=='1':
        r+=1
        cnt[0]+=1 
        cnt[l]-=1 
    else:
        arr.append([t[2],int(t[1])])
        l+=1 
if r%2==1:
    s=s[::-1]
sm=0
for i in range(len(arr)):
    sm+=cnt[i]
    if sm%2==1:
        if arr[i][1]==1:arr[i][1]=2
        elif arr[i][1]==2:arr[i][1]=1 
for i in range(len(arr)):
    if arr[i][1]==1:
        s=arr[i][0]+s

    else:s=s+arr[i][0]
print(s)        
        
    
    
    
    

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

cnt = [0]*(q+5)
arr=[]
l=0
r=0

for i in range(q):
    t=input().split()
    if t[0]=='1':
        r+=1
        cnt[0]+=1 
        cnt[l]-=1 
    else:
        arr.append([t[2],int(t[1])])
        l+=1 
if r%2==1:
    s=s[::-1]
sm=0
for i in range(len(arr)):
    sm+=cnt[i]
    if sm%2==1:
        if arr[i][1]==1:arr[i][1]=2
        elif arr[i][1]==2:arr[i][1]=1 
ans1=""
ans2=""
for i in range(len(arr)):
    if arr[i][1]==1:
        ans1+=arr[i][0]

    else:ans2+=arr[i][0]
print("%s%s%s"%(ans1[::-1],s,ans2))
Buggy python submission (verdict: Time Limit Exceeded):
def check(g,h,w,s):
    if (g[0]<0 or g[0]>=h) or (g[1]<0 or g[1]>=w):
        return False
    if s[g[0]][g[1]]==-1:
        return True
    else:
        return False



h,w=map(int,input().split())
c=[int(x)-1 for x in input().split()]
d=[int(x)-1 for x in input().split()]
s=[]
for j in range(h):
    l=[-1 if x=="." else -2 for x in list(input())]
    s.append(l)
s[c[0]][c[1]]=0
u=[c]
i=0
t=0
while t==0:
    for j in u:
        if j==d:
            t=1
            break
        for k in [[j[0]-1,j[1]],[j[0]+1,j[1]],[j[0],j[1]-1],[j[0],j[1]+1]]:
            if check(k,h,w,s):
                s[k[0]][k[1]]=i
                u.append(k)
    i+=1
    v=[]
    for j in u:
        if j==d:
            t=1
            break
        for k1 in range(-2,3):
            for k2 in range(-2,3):
                k=[j[0]+k1,j[1]+k2]
                if check(k,h,w,s):
                    s[k[0]][k[1]]=i
                    v.append(k)
    if v==[]:
        t=1
    u=v
print(s[d[0]][d[1]])

Fixed submission:
def check(g,h,w,s):
    if (g[0]<0 or g[0]>=h) or (g[1]<0 or g[1]>=w):
        return False
    if s[g[0]][g[1]]==-1:
        return True
    else:
        return False



h,w=map(int,input().split())
c=[int(x)-1 for x in input().split()]
d=[int(x)-1 for x in input().split()]
s=[]
for j in range(h):
    l=[-1 if x=="." else -2 for x in list(input())]
    s.append(l)
s[c[0]][c[1]]=0
u=[c]
i=0
t=0
while t==0:
    for j in u:
        if j==d:
            t=1
            break
        for k in [[j[0]-1,j[1]],[j[0]+1,j[1]],[j[0],j[1]-1],[j[0],j[1]+1]]:
            if check(k,h,w,s):
                s[k[0]][k[1]]=i
                u.append(k)
    i+=1
    v=[]
    for j in u:
        if j==d:
            t=1
            break
        for k1 in range(-2,3):
            for k2 in range(-2,3):
                k=[j[0]+k1,j[1]+k2]
                if check(k,h,w,s):
                    s[k[0]][k[1]]=i
                    v.append(k)
    if v==[]:
        t=1
    u=v
print(s[d[0]][d[1]])
Buggy python submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
t=0
for p in range(n):
    if t+a[p]>k:
        p-=1
        break
    t+=a[p]
for q in range(m):
    if t+b[q]>k:
        q-=1
        break
    t+=b[q]
ans=p+q+2
if q==m-1:
    print(ans)
else:
    z=ans
    r=0
    for r in range(p,-1,-1):
        t-=a[q]
        z-=1
        while r<m and t+b[r]<=k:
            t+=b[r]
            r+=1
            z+=1
        if z>ans:
            ans=z
        if r==m-1:
            break
    print(ans)

Fixed submission:
n,m,k=map(int,input().split())
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
t=0
for p in range(n):
    if t+a[p]>k:
        p-=1
        break
    t+=a[p]
for q in range(m):
    if t+b[q]>k:
        q-=1
        break
    t+=b[q]
ans=p+q+2
if q<m-1:
    z=ans
    q+=1
    for s in range(p,-1,-1):
        t-=a[s]
        z-=1
        while q<m and t+b[q]<=k:
            t+=b[q]
            q+=1
            z+=1
        if z>ans:
            ans=z
        if q==m:
            break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
f=[1]*(n+1)
s=1
for c in range(2,n+1):
    for d in range(1,n//c+1):
        f[c*d]+=1
    s+=c*f[c]
print(s)

Fixed submission:
n=int(input())
f=[2-x%2 for x in range(n+1)]
s=5
for c in range(3,n+1):
    for d in range(1,n//c+1):
        f[c*d]+=1
    s+=c*f[c]
if n==1:
    print(1)
elif n==2:
    print(5)
else:
    print(s)
Buggy python submission (verdict: Runtime Error):
def dev(y,x):
    if y<x:
        return 2*(x-y)-1
    else:
        return 2*(y-x)


x,n=map(int,input().split())
if n==0:
    print(x)
else:
    p=[int(y) for y in input().split()]
    q=[dev(y,x) for y in p]
    q.sort()
    r=0
    while True:
        if q[r]!=r:
            break
        r+=1
    if r%2==0:
        print(x+r//2)
    else:
        print(x-(r+1)//2)

Fixed submission:
def dev(y,x):
    if y<x:
        return 2*(x-y)-1
    else:
        return 2*(y-x)


x,n=map(int,input().split())
p=[int(y) for y in input().split()]
q=[dev(y,x) for y in p]
q.sort()
r=0
while r<len(q):
    if q[r]!=r:
        break
    r+=1
if r%2==0:
    print(x+r//2)
else:
    print(x-(r+1)//2)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(x) for x in input().split()]
if 0 in s:
    print(0)
else:
    s=1
    for c in range(n):
        s=s*a[c]
        if s>10**18:
            s=-1
            break
    print(s)

Fixed submission:
n=int(input())
a=[int(x) for x in input().split()]
if 0 in a:
    print(0)
else:
    s=1
    for c in range(n):
        s=s*a[c]
        if s>10**18:
            s=-1
            break
    print(s)
Buggy python submission (verdict: Time Limit Exceeded):
s=[int(x) for x in list(input())]
for c in range(len(s)-1,-1,-1):
    if c==len(s)-1:
        continue
    s[c]=((10**(len(s)-c-1))*s[c]+s[c+1])%2019
s.append(0)
s.sort()
h=[1]
d=s[0]
for c in range(1,len(s)):
    if s[c]!=d:
        h.append(1)
        d=s[c]
    else:
        h[-1]+=1
k=[(x*(x-1))//2 for x in h]
print(sum(k))

Fixed submission:
s=[int(x) for x in list(input())]
for c in range(len(s)-1,-1,-1):
    if c==len(s)-1:
        continue
    s[c]=(pow(10,len(s)-c-1,2019)*s[c]+s[c+1])%2019
s.append(0)
s.sort()
h=[1]
d=s[0]
for c in range(1,len(s)):
    if s[c]!=d:
        h.append(1)
        d=s[c]
    else:
        h[-1]+=1
k=[(x*(x-1))//2 for x in h]
print(sum(k))
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
if (h*w)%2==1:
    print((h*w+1)//2)
else:
    print((h*w)//a2)

Fixed submission:
h,w=map(int,input().split())
if (h-1)*(w-1)==0:
  print(1)
else:
  print(-(-h*w//2))

Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
if (h*w)%2=1:
    print((h*w+1)//2)
else:
    print((h*w)//a2)

Fixed submission:
h,w=map(int,input().split())
if (h-1)*(w-1)==0:
  print(1)
else:
  print(-(-h*w//2))
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
q=int(input())
for c in range(q):
    l=input()
    if l=="1":
        s=s[::-1]
    else:
        if l[2]=="1":
            s=l[4:]+s
        else:
            s=s+l[4:]
print(s)

Fixed submission:
s=input()
q=int(input())
l=[]
for c in range(q):
    i=input().split()
    if i==["1"]:
        l.append([1,0,0])
    else:
        l.append([2,int(i[1]),i[2]])
d=0
for c in range(1,q+1):
    if l[-c][0]==1:
        d=d+1
    else:
        l[-c][1]+=d%2
a=""
for c in range(1,q+1):
    if l[-c][0]==2 and l[-c][1]%2==1:
        a=a+l[-c][2]
if d%2==0:
    a=a+s
else:
    a=a+s[::-1]
for c in range(q):
    if l[c][0]==2 and l[c][1]%2==0:
        a=a+l[c][2]
print(a)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
q=int(input())
l=[]
for c in range(q):
    l.append(input())
for c in range(q):
    if l[c]=="1":
        s=s[::-1]
    else:
        j=l[c].split()
        if j[1]=="1":
            s=j[2]+s
        else:
            s=s+j[2]
print(s)

Fixed submission:
s=input()
q=int(input())
l=[]
for c in range(q):
    i=input().split()
    if i==["1"]:
        l.append([1,0,0])
    else:
        l.append([2,int(i[1]),i[2]])
d=0
for c in range(1,q+1):
    if l[-c][0]==1:
        d=d+1
    else:
        l[-c][1]+=d%2
a=""
for c in range(1,q+1):
    if l[-c][0]==2 and l[-c][1]%2==1:
        a=a+l[-c][2]
if d%2==0:
    a=a+s
else:
    a=a+s[::-1]
for c in range(q):
    if l[c][0]==2 and l[c][1]%2==0:
        a=a+l[c][2]
print(a)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
q=int(input())
for c in range(q):
    l=input()
    if l=="1":
        s=s[::-1]
    else:
        j=l.split()
        if j[1]=="1":
            s=j[2]+s
        else:
            s=s+j[2]
print(s)

Fixed submission:
s=input()
q=int(input())
l=[]
for c in range(q):
    i=input().split()
    if i==["1"]:
        l.append([1,0,0])
    else:
        l.append([2,int(i[1]),i[2]])
d=0
for c in range(1,q+1):
    if l[-c][0]==1:
        d=d+1
    else:
        l[-c][1]+=d%2
a=""
for c in range(1,q+1):
    if l[-c][0]==2 and l[-c][1]%2==1:
        a=a+l[-c][2]
if d%2==0:
    a=a+s
else:
    a=a+s[::-1]
for c in range(q):
    if l[c][0]==2 and l[c][1]%2==0:
        a=a+l[c][2]
print(a)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
q=int(input())
for c in range(q):
    l=input()
    if l=="1":
        s=s[::-1]
    else:
        j=l.split()
        if j[1]=="1":
            s=j[2]+s
        else:
            s=s+j[2]
print(s)

Fixed submission:
s=input()
q=int(input())
l=[]
for c in range(q):
    i=input().split()
    if i==["1"]:
        l.append([1,0,0])
    else:
        l.append([2,int(i[1]),i[2]])
d=0
for c in range(1,q+1):
    if l[-c][0]==1:
        d=d+1
    else:
        l[-c][1]+=d%2
a=""
for c in range(1,q+1):
    if l[-c][0]==2 and l[-c][1]%2==1:
        a=a+l[-c][2]
if d%2==0:
    a=a+s
else:
    a=a+s[::-1]
for c in range(q):
    if l[c][0]==2 and l[c][1]%2==0:
        a=a+l[c][2]
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
def mp(a,n,mod):
    if n==1:
        return a%mod
    aq=(mp(a,n//2,mod))**2
    ar=a**(n%2)
    return (((aq)%mod)*ar)%mod


def s_comb(n,k):
    s=1
    r=min(k,n-k)
    p=10**9+7
    for c in range(r):
        s=(s*(n-c)*mp(c+1,p-2,p))%p
    return s

x,y=map(int,input().split())
if (x+y)%3!=0 or 2*y<x or 2*x<y:
    print(0)
else:
    r=int(min(2*y-x,2*x-y)/3)
    print(s_comb(int((x+y)/3),r))


Fixed submission:


def s_comb(n,k):
    s=1
    r=min(k,n-k)
    p=10**9+7
    for c in range(r):
        s=(s*(n-c)*pow(c+1,p-2,p))%p
    return s

x,y=map(int,input().split())
if (x+y)%3!=0 or 2*y<x or 2*x<y:
    print(0)
else:
    r=int(min(2*y-x,2*x-y)/3)
    print(s_comb(int((x+y)/3),r))
Buggy python submission (verdict: Runtime Error):
n=input()
print(n*n*n)

Fixed submission:
n=int(input())
print(n*n*n)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if (b-1)¥(a-1)==0:
    c=int((b-1)/(a-1))
else:
    c=int((b-1)/(a-1))+1
print(c)

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