Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
S=list(map(str,input()))
T=list(map(str,input()))
X=[]
Z=0
for I in range(len(S)-len(T)):
    Y=S[I:I+len(T)]
    Z=0
    for J in range(len(T)):
        if Y[J]==T[J]:
            Z=Z+1
    X.append(Z)
print(len(T)-max(X))

Fixed submission:
S=list(map(str,input()))
T=list(map(str,input()))
X=[]
Z=0
for I in range(len(S)-len(T)+1):
    Y=S[I:I+len(T)]
    Z=0
    for J in range(len(T)):
        if Y[J]==T[J]:
            Z=Z+1
    X.append(Z)
if not X==[]:
    print(len(T)-max(X))
elif S==T:
    print(0)
else:
    print(len(T))

Buggy python submission (verdict: Runtime Error):
S=list(map(str,input()))
T=list(map(str,input()))
x=[]
y=0

for i in range(len(S)-len(T)):
    Y=S[i:i+len(T)]
    y=0
    for j in range(len(T)):
        if Y[j]==T[j]:
            y=y+1
    x.append(y)
print(len(T)-max(x)) 

Fixed submission:
S=list(map(str,input()))
T=list(map(str,input()))
X=[]
Z=0
for I in range(len(S)-len(T)+1):
    Y=S[I:I+len(T)]
    Z=0
    for J in range(len(T)):
        if Y[J]==T[J]:
            Z=Z+1
    X.append(Z)
if not X==[]:
    print(len(T)-max(X))
elif S==T:
    print(0)
else:
    print(len(T))

Buggy python submission (verdict: Runtime Error):
S=list(map(str,input()))
T=list(map(str,input()))
x=[]
y=0

for i in range(len(S)-len(T)):
    Y=S[i:i+len(T)]
    y=0
    for j in range(len(T)):
        if Y[j]==T[j]:
            y=y+1
    x.append(y)
print(len(T)-max(x))  

Fixed submission:
S=list(map(str,input()))
T=list(map(str,input()))
X=[]
Z=0
for I in range(len(S)-len(T)+1):
    Y=S[I:I+len(T)]
    Z=0
    for J in range(len(T)):
        if Y[J]==T[J]:
            Z=Z+1
    X.append(Z)
if not X==[]:
    print(len(T)-max(X))
elif S==T:
    print(0)
else:
    print(len(T))
Buggy python submission (verdict: Time Limit Exceeded):
X,K,D=map(int,input().split())
X=abs(X)
if X-K*D>0:
    print(X-K*D)
else:
    i=0
    while X-D*(K-i)<0:
        i=i+1
    if (K-i)%2==1:
        print(abs(X-D*(i+1)))
    else:
        print(abs(X-D*i))

Fixed submission:
X,K,D=map(int,input().split())
X=abs(X)
if X-K*D>0:
    print(X-K*D)
elif (K-X//D)%2==1:
    print(abs(X%D-D))
else:
    print(X%D)

Buggy python submission (verdict: Time Limit Exceeded):
X,K,D=map(int,input().split())
X=abs(X)
if X-K*D>0:
    print(X-K*D)
else:
    i=0
    while X-D*i>0:
        i=i+1
    if (K-i)%2==1:
        print(abs(X-D*(i-1)))
    else:
        print(abs(X-D*i))

Fixed submission:
X,K,D=map(int,input().split())
X=abs(X)
if X-K*D>0:
    print(X-K*D)
elif (K-X//D)%2==1:
    print(abs(X%D-D))
else:
    print(X%D)
Buggy python submission (verdict: Runtime Error):
import itertools

if __name__ == "__main__":
  n = int(input())
  li = list(map(int, input().split()))
  array = list(itertools.combinations(li, 2))
  sum = 0
  for i in range(n):
    sum += array[i][0] * array[i][1]
  print(sum)

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

class main:
  def judge(d, x):
    if d <= x:
      print("Yes")
    else:
      print("No")

if __name__ == "__main__":
  d, t, s = map(int, input().split())
  dis = t * s
  main.judge(d,dis)
Buggy python submission (verdict: Runtime Error):
# -*- using:utf-8 -*-
class main:
  def function(x, k, d):
    for i in range(k):
      if abs(x + d) >= abs(x - d):
        x = x - d
      if abs(x + d) < abs(x - d):
        x = x + d
    print(x)

if __name__ == "__main__":
  x, k, d = map(int, input().split())
  main.function(x,k,d)

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

if __name__ == "__main__":
  s = list(input())
  sum = 0
  for i in range(3):
    if s[i] == 'R':
      sum = 1
  if s[0] == 'R' and s[1] =='R':
    sum += 1
  if s[1] == 'R' and s[2] == 'R':
    sum += 1
  print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- using:utf-8 -*-
class main:
  def function(x, k, d):
    for i in range(k):
      if abs(x + d) > abs(x - d):
        x = x - d
      elif abs(x + d) < abs(x - d):
        x = x + d
      else:
        if (k - i) % 2 == 0:
          return abs(x)
          break
        else:
          return abs(x + d)
          break
    return abs(x)

if __name__ == "__main__":
  x, k, d = map(int, input().split())
  x = main.function(x, k, d)
  print(x)

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

class main:
  def function(x, k, d):
    if x >= k * d:
      ans = x - k * d
    else:
      r = x // d
      n = k - r
      if n % 2 == 0:
        ans = x % d
      else:
        ans = abs(x % d - d)
    return ans

if __name__ == "__main__":
  x, k, d = map(int, input().split())
  x = abs(x)
  ans = main.function(x, k, d)
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- using:utf-8 -*-
class main:
  def function(x, k, d):
    for i in range(k):
      if abs(x + d) >= abs(x - d):
        x = x - d
      else:
        x = x + d
    print(abs(x))

if __name__ == "__main__":
  x, k, d = map(int, input().split())
  main.function(x,k,d)

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

class main:
  def function(x, k, d):
    if x >= k * d:
      ans = x - k * d
    else:
      r = x // d
      n = k - r
      if n % 2 == 0:
        ans = x % d
      else:
        ans = abs(x % d - d)
    return ans

if __name__ == "__main__":
  x, k, d = map(int, input().split())
  x = abs(x)
  ans = main.function(x, k, d)
  print(ans)
Buggy python submission (verdict: Runtime Error):
X = input()
if X >= 30:
    print("Yes")
else:
    print("No")

Fixed submission:
X = int(input())
if X >= 30:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split(" ")))
for i in range(N):
    if i==0:
        cnt+=1
    else:
        h=H[i]
        c=0
        for j in range(i):
            if H[j]>h:
                c=1
        if c==0:
            cnt+=1
print(cnt)


Fixed submission:
N = int(input())
H = list(map(int, input().split(" ")))
cnt=0
for i in range(N):
    if i==0:
        cnt+=1
    else:
        h=H[i]
        c=0
        for j in range(i):
            if H[j]>h:
                c=1
        if c==0:
            cnt+=1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()

def delete_cube(cube):
    new_cube = []
    cnt = 0
    i=0
    while(i < len(cube)):
        if i == len(cube)-1:
            new_cube.append(cube[i])
            i+=1
        elif (cube[i]=='0' and cube[i+1]=='1') or (cube[i]=='1' and cube[i+1]=='0'):
            cnt+=2
            i+=2
        else:
            new_cube.append(cube[i])
            i+=1
    return(new_cube, cnt)

total_cnt=0
while(True):
    S,cnt = delete_cube(S)
    if cnt==0:
        break
    total_cnt+=cnt
print(total_cnt)


Fixed submission:
S = input()

cnt1=0
cnt0=0
for i in range(len(S)):
    if S[i]=='0':
        cnt0+=1
    elif S[i]=='1':
        cnt1+=1
if cnt1 == 0 or cnt0 == 0:
    print(0)
else:
    if cnt1>cnt0:
        print(cnt0*2)
    else:
        print(cnt1*2)
Buggy python submission (verdict: Runtime Error):
a = input()
if (a[-1] == '0' and (int(a[0]) >= int(a[2])) or  (int(a[0]) >= int(a[2]) and int(a[0]) >= int(a[1])):
    ans = int(a[0] * 3)
else:
    ans = str(int(a[0])+1)*3
print(ans)


Fixed submission:
a = input()
if (a[-1] == '0' and (int(a[0]) >= int(a[1]))):
    ans = int(a[0] * 3)
elif(int(a[0]) >= int(a[2]) and int(a[0]) >= int(a[1]) and a[-1] != '0'):
    ans = int(a[0] * 3)
else:
    ans = str(int(a[0])+1)*3
print(ans)

Buggy python submission (verdict: Runtime Error):
a = input()
if (a[-1] == '0' and (int(a[0]) >= int(a[2])) or  (int(a[0]) >= int(a[2]) and int(a[0]) >= int(a[1]))::
    ans = int(a[0] * 3)
else:
    ans = str(int(a[0])+1)*3
print(ans)


Fixed submission:
a = input()
if (a[-1] == '0' and (int(a[0]) >= int(a[1]))):
    ans = int(a[0] * 3)
elif(int(a[0]) >= int(a[2]) and int(a[0]) >= int(a[1]) and a[-1] != '0'):
    ans = int(a[0] * 3)
else:
    ans = str(int(a[0])+1)*3
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

a,b,c,k = map(int, input().split())
p = 0
for i in range(k):
    if i+1 <= a:
        p += 1
    elif a < i+1 <= a + b:
        p += 0
    else:
        p -= 1

print(p)        

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

a,b,c,k = map(int, input().split())

if a + b >= k:
    if a <= k:
        print(a)
    else:
        print(k)
else:
    print(a - (k - (a + b)))
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

h, n = map(int, input().split())
a = [int(i) for i in input().split()]

a.sort(key = lambda x : -1*x)

if h > a[0] + a[1]:
    print("No")
else:
    print("Yes")

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

h, n = map(int, input().split())
a = [int(i) for i in input().split()]

d = 0
for i in a:
    d += i

if h > d:
    print("No")
else:
    print("Yes")

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

h, n = map(int, input().split())
a = [int(i) for i in input().split()]

a.sort(key = lambda x : -1*x)

if h > a[0] + a[1]:
    print("Yes")
else:
    print("No")

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

h, n = map(int, input().split())
a = [int(i) for i in input().split()]

d = 0
for i in a:
    d += i

if h > d:
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

n = int(input())
a = [int(i) for i in input().split()]

k = [0] * 60

for j in range(60):
    l = [i >> j & 1 for i in a]
    for m in l:
        k[j] += m

ans = 0
c = 0
for d in k:
    ans += (d * (n - d) * 2**c)  % (10**9 + 7)
    c += 1
    
print(ans % (10**9 + 7))

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import numpy as np

n = int(input())
a = np.array([int(i) for i in input().split()])

k = [0] * 60

for j in range(60):
    l = a & 1
    k[j] = np.count_nonzero(l)
    a >>= 1

ans = 0
c = 0
for d in k:
    ans += (d * (n - d) * 2**c)  % (10**9 + 7)
    c += 1
    
print(ans % (10**9 + 7))

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

n = int(input())
a = [int(i) for i in input().split()]

k = [0] * 60

for i in a:
    for j in range(60):
        if (i >> j) & 1:
            k[j] += 1

ans = 0
c = 0
for d in k:
    ans += d * (n - d) * 2**c
    c += 1
    
print(ans % (10**9 + 7))

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import numpy as np

n = int(input())
a = np.array([int(i) for i in input().split()])

k = [0] * 60

for j in range(60):
    l = a & 1
    k[j] = np.count_nonzero(l)
    a >>= 1

ans = 0
c = 0
for d in k:
    ans += (d * (n - d) * 2**c)  % (10**9 + 7)
    c += 1
    
print(ans % (10**9 + 7))

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math

n = int(input())
a = [int(i) for i in input().split()]
bound = int(math.log2(max(a)) + 1)

k = [0] * bound

for i in a:
    for j in range(bound):
        if (i >> j) & 1:
            k[j] += 1

ans = 0
c = 0
for d in k:
    ans += (d * (n - d) * 2**c)  % (10**9 + 7)
    c += 1
    
print(ans % (10**9 + 7))

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import numpy as np

n = int(input())
a = np.array([int(i) for i in input().split()])

k = [0] * 60

for j in range(60):
    l = a & 1
    k[j] = np.count_nonzero(l)
    a >>= 1

ans = 0
c = 0
for d in k:
    ans += (d * (n - d) * 2**c)  % (10**9 + 7)
    c += 1
    
print(ans % (10**9 + 7))

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

n = int(input())
a = [int(i) for i in input().split()]

k = [0] * 60

for i in a:
    for j in range(60):
        if (i >> j) & 1:
            k[j] += 1

ans = 0
c = 0
for d in k:
    ans += (d * (n - d) * 2**c)  % (10**9 + 7)
    c += 1
    
print(ans % (10**9 + 7))

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import numpy as np

n = int(input())
a = np.array([int(i) for i in input().split()])

k = [0] * 60

for j in range(60):
    l = a & 1
    k[j] = np.count_nonzero(l)
    a >>= 1

ans = 0
c = 0
for d in k:
    ans += (d * (n - d) * 2**c)  % (10**9 + 7)
    c += 1
    
print(ans % (10**9 + 7))
Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int, input())
print(max(a*c, a*d, b*c, b*d)

Fixed submission:
a,b,c,d = map(int, input().split())
print(max(a*c, a*d, b*c, b*d))
Buggy python submission (verdict: Runtime Error):
import numpy as np

d=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(d):
  s.append(list(map(int,input().split())))

for i in range(d):
  if i%26=0:
    a=np.argmax(s[0])
  print((i+a)%26+1)

Fixed submission:
import numpy as np

d=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(d):
  s.append(list(map(int,input().split())))

for i in range(d):
  print(np.argmax(s[i])+1)
Buggy python submission (verdict: Runtime Error):
n,m,k=map(int, input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))

sa=[0]*n
sb=[0]*m
s=0
for i in range(n):
  s+=a[i]
  sa[i]=s
s=0
for i in range(m):
  s+=b[i]
  sb[i]=s

if sa[n-1]+sb[m-1]<=k:
  print(n+m)
  exit()
  
if m<n:
  ans=n if sa[n-1]<=k else 0
else:
  ans=m if sb[m-1]<=k else 0

j=0
for i in reversed(range(n)):
  if sa[i]+sb[j]>k:
    continue
  while j<m and sa[i]+sb[j+1] <= k:
    j+=1
  if sa[i]+sb[j] <= k and ans<i+j+2:
    ans=i+j+2

print(ans)

Fixed submission:
n,m,k=map(int, input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))

sa=[0]*(n+1)
sb=[0]*(m+1)
s=0
for i in range(n):
  s+=a[i]
  sa[i+1]=s
s=0
for i in range(m):
  s+=b[i]
  sb[i+1]=s

if sa[n]+sb[m]<=k:
  print(n+m)
  exit()

ans=0
j=0
for i in reversed(range(n+1)):
  if sa[i]+sb[j]>k:
    continue
  while j<m and sa[i]+sb[j+1] <= k:
    j+=1
  if sa[i]+sb[j] <= k and ans<i+j:
    ans=i+j

print(ans)

Buggy python submission (verdict: Runtime Error):
n,m,k=map(int, input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))

sa=[0]*n
sb=[0]*m
s=0
for i in range(n):
  s+=a[i]
  sa[i]=s
s=0
for i in range(m):
  s+=b[i]
  sb[i]=s

if sa[n-1]+sb[m-1]<=k:
  print(n+m)
  exit
  
if m<n:
  ans=n if sa[n-1]<=k else 0
else:
  ans=m if sb[m-1]<=k else 0

j=0
for i in reversed(range(n)):
  if sa[i]+sb[j]>k:
    continue
  while j<m and sa[i]+sb[j+1] <= k:
    j+=1
  if sa[i]+sb[j] <= k and ans<i+j+2:
    ans=i+j+2

print(ans)

Fixed submission:
n,m,k=map(int, input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))

sa=[0]*(n+1)
sb=[0]*(m+1)
s=0
for i in range(n):
  s+=a[i]
  sa[i+1]=s
s=0
for i in range(m):
  s+=b[i]
  sb[i+1]=s

if sa[n]+sb[m]<=k:
  print(n+m)
  exit()

ans=0
j=0
for i in reversed(range(n+1)):
  if sa[i]+sb[j]>k:
    continue
  while j<m and sa[i]+sb[j+1] <= k:
    j+=1
  if sa[i]+sb[j] <= k and ans<i+j:
    ans=i+j

print(ans)
Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())
print("Yes" if x*2 <= y <= x*4 and x%2 = 0 else "No")

Fixed submission:
x, y = map(int, input().split())
print("Yes" if x*2 <= y <= x*4 and y%2 == 0 else "No")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
n=int(input())
a=list(map(int,input().split()))
ans=1
for i in range(n):
    ans*=a[i]
if ans>10**18:
    print(-1)
else:
    print(ans)

Fixed submission:
#!/usr/bin/env python3
import sys
n=int(input())
a=list(map(int,input().split()))
ans=1
 
for i in range(n):
    if a[i]==0:
        print(0)
        sys.exit()

for i in range(n):
    ans*=a[i]
    if ans>10**18:
        print(-1)
        sys.exit()
 
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
n=int(input())
a=map(int,input().split())
ans=1
for i in range(n):
  ans*=a[i]
  if ans>10**18:
    print(-1)
    sys.exit()
print(ans)

Fixed submission:
#!/usr/bin/env python3
import sys
n=int(input())
a=list(map(int,input().split()))
ans=1
 
for i in range(n):
    if a[i]==0:
        print(0)
        sys.exit()

for i in range(n):
    ans*=a[i]
    if ans>10**18:
        print(-1)
        sys.exit()
 
print(ans)
Buggy python submission (verdict: Runtime Error):
k=int(input())
s=input()
if len(s)<=k:
    print(s)
else:
    print(s[:k]+"...")

Fixed submission:
n=int(input())
n1=n%10
if n1==3:
    print("bon")
elif n1<=1 or n1==6 or n1==8:
    print("pon")
else:
    print("hon")
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
                                                                                                                                                                                                                                                                      def solve(N: int):                                                                                                                     ans=0
    for i in range(N):
        ans+=i if i%3!=0 and i%5!=0 else 0
    print(ans)                                                                                                                         return                                                                                                                                                                                                                                                                                                                                                                                               # Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():                                                                                                                  for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main() 

Fixed submission:
#!/usr/bin/env python3
import sys

def solve(N: int):
    ans=0
    for i in range(1,N+1):
        ans+=i if i%3!=0 and i%5!=0 else 0
    print(ans)
    return

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
#sys.setrecursionlimit(150000)

#def my_index_multi(l, x):
#    return [i for i, _x in enumerate(l) if _x == x]

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, M: int, A: "List[int]"):
    A.sort()
    sa=sum(A)
    print(YES if sa//(4*M)>A[M] else NO)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
#sys.setrecursionlimit(150000)

#def my_index_multi(l, x):
#    return [i for i, _x in enumerate(l) if _x == x]

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, M: int, A: "List[int]"):
    A=sorted(A,reverse=True)
    sa=sum(A)
    if N==1:
        print(YES)
    else:
        print(YES if sa/(4*M)<=A[M-1] else NO)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
H,W=map(int,input())
if H%2==0:
    print(H//2*W)
elif W%2==0:
    print(W//2*H)
else:
    print((H//2)*W+((W+1)//2))


Fixed submission:
H,W=map(int,input().split())
if H==1 or W==1:
    print(1)
elif H%2==0:
    print(H//2*W)
elif W%2==0:
    print(W//2*H)
else:
    print((H//2)*W+((W+1)//2))
Buggy python submission (verdict: Runtime Error):
s1=input()
q=int(input())
s0=[]
f=1
for i in range(q):
  a=list(input().split())
  #print(i,a,s)
  if int(a[0])==1:
    f=(f+1)%2
  else:
    if (f+int(a[1]))%2==0:
      s0.append(a[2])
    else:
      s1.append(a[2])
if f==1:
  print("".join(s0[::-1])+"".join(s1))
else:
  print("".join(s1[::-1])+"".join(s0))
  

Fixed submission:
s1=list(input())
q=int(input())
s0=[]
f=1
for i in range(q):
  a=list(input().split())
  #print(i,a,s)
  if int(a[0])==1:
    f=(f+1)%2
  else:
    if (f+int(a[1]))%2==0:
      s0.append(a[2])
    else:
      s1.append(a[2])
if f==1:
  print("".join(s0[::-1])+"".join(s1))
else:
  print("".join(s1[::-1])+"".join(s0))

Buggy python submission (verdict: Time Limit Exceeded):
s=[""]*2
s[1]=input()
q=int(input())
s[0]=""
f=1
for i in range(q):
  a=list(input().split())
  #print(i,a,s)
  if int(a[0])==1:
    f=(f+1)%2
  else:
    s[(f+int(a[1]))%2]+=a[2]
    
if f==1:
  print(s[0][::-1]+s[1])
else:
  print(s[1][::-1]+s[0])
  

Fixed submission:
s1=list(input())
q=int(input())
s0=[]
f=1
for i in range(q):
  a=list(input().split())
  #print(i,a,s)
  if int(a[0])==1:
    f=(f+1)%2
  else:
    if (f+int(a[1]))%2==0:
      s0.append(a[2])
    else:
      s1.append(a[2])
if f==1:
  print("".join(s0[::-1])+"".join(s1))
else:
  print("".join(s1[::-1])+"".join(s0))
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(N: int, P: "List[int]"):
    ans=1
    for i in range(1,N):
        if P[i]<=min(P[:i]):
            ans+=1
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, P)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys


def solve(N: int, P: "List[int]"):
    ans=1
    mi=P[0]
    for i in range(1,N):
        if P[i]<=mi:
            ans+=1
            mi=P[i]
            
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, P)

if __name__ == '__main__':
    main()