Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

N=int(input())
A=[int(x) for x in input().split()]
Com=0

A_C=Counter(A)

for name,x in A_C.items():
    Com+=int(x*(x-1)/2)
    
for i in range(N):
    y=A.count(A[i])
    print(Com-y+1)

Fixed submission:
from collections import Counter

N=int(input())
A=[int(x) for x in input().split()]
Com=0

A_C=Counter(A)

for name,x in A_C.items():
    Com+=int(x*(x-1)/2)
    
for i in range(N):
    y=A_C[A[i]]
    print(Com-y+1)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

N=int(input())
A=[int(x) for x in input().split()]
A_s=list(dict.fromkeys(A))
Com=0

A_C=Counter(A)

for name,x in A_C.items():
    Com+=int(x*(x-1)/2)
    
for i in range(N):
    y=A.count(A[i])
    print(Com-y+1)

Fixed submission:
from collections import Counter

N=int(input())
A=[int(x) for x in input().split()]
Com=0

A_C=Counter(A)

for name,x in A_C.items():
    Com+=int(x*(x-1)/2)
    
for i in range(N):
    y=A_C[A[i]]
    print(Com-y+1)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(x) for x in input().split()]
A_s=list(dict.fromkeys(A))
Com=0
for k in A_s:
    x=A.count(k)
    Com+=int(x*(x-1)/2)
    
for i in range(N):
    y=A.count(A[i])
    print(Com-y+1)

Fixed submission:
from collections import Counter

N=int(input())
A=[int(x) for x in input().split()]
Com=0

A_C=Counter(A)

for name,x in A_C.items():
    Com+=int(x*(x-1)/2)
    
for i in range(N):
    y=A_C[A[i]]
    print(Com-y+1)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(x) for x in input().split()]
A_s=set(A)
Com=0
for k in A_s:
    x=A.count(k)
    Com+=int(x*(x-1)/2)
    
for i in range(N):
    y=A.count(A[i])
    print(Com-y+1)

Fixed submission:
from collections import Counter

N=int(input())
A=[int(x) for x in input().split()]
Com=0

A_C=Counter(A)

for name,x in A_C.items():
    Com+=int(x*(x-1)/2)
    
for i in range(N):
    y=A_C[A[i]]
    print(Com-y+1)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(x) for x in input().split()]
A_s=set(A)
for i in range(N):
    Com=0
    A_k=A.copy()
    A_k[i]=""
    for k in A_s:
        x=A_k.count(k)
        Com+=int(x*(x-1)/2)
    print(Com)

Fixed submission:
from collections import Counter

N=int(input())
A=[int(x) for x in input().split()]
Com=0

A_C=Counter(A)

for name,x in A_C.items():
    Com+=int(x*(x-1)/2)
    
for i in range(N):
    y=A_C[A[i]]
    print(Com-y+1)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(x) for x in input().split()]
A_s=set(A)
for i in range(N):
    Com=0
    A_k=A.copy()
    A_k[i]=""
    A_k_s=set(A_k)
    for k in A_k_s:
        x=A_k.count(k)
        Com+=int(x*(x-1)/2)
    print(Com)

Fixed submission:
from collections import Counter

N=int(input())
A=[int(x) for x in input().split()]
Com=0

A_C=Counter(A)

for name,x in A_C.items():
    Com+=int(x*(x-1)/2)
    
for i in range(N):
    y=A_C[A[i]]
    print(Com-y+1)
Buggy python submission (verdict: Runtime Error):
N=int(input())
S="a"
bottom=""
alpha="abcdefghijklmnopqrstuvwxyz"

for i in range(N):
    if i>25:
        bottom=bottom+"z"
    else:
        bottom=bottom+alpha[i]
    S=S+"a"
print(bottom)

C=0
S=""
def F(S,loop,N,C):
    for i in range(0,loop):
        if N==C+1:
            print(S+bottom[i])
        else:
            F(S+bottom[i],i+2,L,C+1)
    return None
            
F(S,1,L,C)

Fixed submission:
N=int(input())
S="a"
bottom=""
alpha="abcdefghijklmnopqrstuvwxyz"

for i in range(N):
    if i>25:
        bottom=bottom+"z"
    else:
        bottom=bottom+alpha[i]
    S=S+"a"

C=0
S=""
def F(S,loop,N,C):
    for i in range(0,loop):
        if N==C+1:
            print(S+bottom[i])
        else:
            if loop==i+1:
                loop+=1
            F(S+bottom[i],loop,N,C+1)
    return None
            
F(S,1,N,C)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S = [input() for i in range(N)]
result=[]
name=[]

result=[S.count(S[i]) for i in range(N)]
m=max(result)

for i in range(N):
    if m==result[i]:
        name.append(S[i])
name_set=set(name)
name_list=sorted(list(name_set))

for i in range(len(name_list)):
    print(name_list[i])

Fixed submission:
from collections import Counter

N=int(input())
S = [input() for i in range(N)]
result=[]

counter = Counter(S)
m = max(counter.values())

for name in counter.keys():
    if m==counter[name]:
        result.append(name)

result_sort=sorted(result)

for i in range(len(result_sort)):
    print(result_sort[i])

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S = [input() for i in range(N)]
result=[]
max=0
name=[]

for i in range(N):
    C=S.count(S[i])
    result.append(C)
    if C>max:
        max=C
for i in range(N):
    if max==result[i]:
        name.append(S[i])
name_set=set(name)
name_list=sorted(list(name_set))

for i in range(len(name_list)):
    print(name_list[i])

Fixed submission:
from collections import Counter

N=int(input())
S = [input() for i in range(N)]
result=[]

counter = Counter(S)
m = max(counter.values())

for name in counter.keys():
    if m==counter[name]:
        result.append(name)

result_sort=sorted(result)

for i in range(len(result_sort)):
    print(result_sort[i])
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A = [int(x) for x in input().split()]
flag=False
for i in range(N):
    check=A[i]
    for k in range(N):
        if i!=k and check==A[k]:
            flag=True
            break
    if flag:
        break
if flag:
    print("NO")
else:
    print("YES")

Fixed submission:
#C
from collections import Counter
N=int(input())
A=[int(x) for x in input().split()]

A_C=Counter(A)

flag=True
for i,v in A_C.items():
    if v!=1:
        flag=False
        break
if flag:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
#D
H=int(input())
cnt=1
ans=1
while True:
    H=int((H-H%2)/2)
    ans+=pow(2,cnt)
    cnt+=1
    if H==1:
        break
print(ans)

Fixed submission:
#D
H=int(input())
cnt=0
ans=0
while True:
    ans+=pow(2,cnt)
    cnt+=1
    if H==1:
        break
    H=int((H-H%2)/2)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#D
H=int(input())
cnt=1
ans=1
while True:
    H=int((H-H%2)/2)
    ans+=2**cnt
    cnt+=1
    if H==1:
        break
print(ans)

Fixed submission:
#D
H=int(input())
cnt=0
ans=0
while True:
    ans+=pow(2,cnt)
    cnt+=1
    if H==1:
        break
    H=int((H-H%2)/2)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#D
N=int(input())
ans=0
D={}
for x in range(1,10):
    for y in range(1,10):
        D[(x,y)]=0

for key in D.keys():
    x,y=key
    for i in range(1,N+1):
        a=int(str(i)[0])
        b=int(str(i)[-1])
        if x==a and y==b:
            D[key]+=1
for i in range(1,10):
    for j in range(1,10):
        ans+=D[(i,j)]*D[(j,i)]
print(ans)

Fixed submission:
#D
N=int(input())
ans=0
D=[[0 for i in range(10)] for j in range(10)]

for i in range(1,10):
    for j in range(1,10):
        for k in range(1,N+1):
            if str(i)==str(k)[0] and str(j)==str(k)[-1]:
                D[i][j]+=1
for i in range(1,10):
    for j in range(1,10):
        ans+=D[i][j]*D[j][i]
print(ans)
Buggy python submission (verdict: Runtime Error):
#C
N,M=map(int,input().split())
re=[0 for i in range(N+1)]
P=[0 for i in range(N+1)]
x=0
y=0
for i in range(M):
    p,S=input().split()
    p=int(p)
    if re[p]=="AC":
        continue
    elif S=="WA":
        P[p]+=1
    elif S=="AC":
        re[p]="AC"
        y+=1
for i in range(1,N+1):
    if re[p]=="AC":
        x+=P[p]
print(y,x)

Fixed submission:
#C
N,M=map(int,input().split())
re=[0 for i in range(N+1)]
P=[0 for i in range(N+1)]
x=0
y=0
for i in range(M):
    p,S=input().split()
    p=int(p)
    if re[p]=="AC":
        continue
    elif S=="WA":
        P[p]+=1
    elif S=="AC":
        re[p]="AC"
        y+=1
for i in range(1,N+1):
    if re[i]=="AC":
        x+=P[i]
print(y,x)
Buggy python submission (verdict: Runtime Error):
#D
import queue
H,W=map(int,input().split())
P=[0 for i in range(H)]
for i in range(H):
    P[i]=str(input())

ans=0
for i in range(H*W):
    s=(i%W,i//W)
    if P[s[0]][s[1]]=="#":
        continue
    st=queue.Queue()
    st.put(s)
    log=[[-1 for i in range(W)] for j in range(H)]
    log[s[0]][s[1]]=0
    while not st.empty():
        x,y=st.get()
        for z,w in [(x+1,y),(x-1,y),(x,y+1),(x,y-1)]:
            if not (0<=z and 0<=w):
                continue
            elif not (z<W and w<H):
                continue
            elif P[z][w]=="." and log[z][w]==-1:
                st.put((z,w))
                log[z][w]=log[x][y]+1
                ans=max(ans,log[z][w])
print(ans)

Fixed submission:
#D
import queue
H,W=map(int,input().split())
P=[0 for i in range(H)]
for i in range(H):
    P[i]=str(input())
ans=0
for i in range(H*W):
    s=(i//W,i%W)
    if P[s[0]][s[1]]=="#":
        continue
    st=queue.Queue()
    st.put(s)
    log=[[-1 for i in range(W)] for j in range(H)]
    log[s[0]][s[1]]=0
    while not st.empty():
        y,x=st.get()
        for z,w in [(y+1,x),(y-1,x),(y,x+1),(y,x-1)]:
            if 0>z or 0>w:
                continue
            elif z>=H or w>=W:
                continue
            elif P[z][w]=="." and log[z][w]==-1:
                st.put((z,w))
                log[z][w]=log[y][x]+1
                ans=max(ans,log[z][w])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
A=list(map(int,input().split()))
A=sorted(A,reverse=True)

Pair=[0 for i in range(N)]
for i in range(N-1):
    Pair[i]=A[i]+A[i+1]

ans=0
cnt=0
mode=0
Next=[]
i=0
while i<M:
    if mode==0:
        ans+=2*A[cnt]
        mode=1
        Next.append([cnt,cnt+1])
        cnt+=1
        i+=1
    else:
        Max=0
        for j in Next:
            if Max<=A[j[0]]+A[j[1]]:
                Max=A[j[0]]+A[j[1]]
                p_cnt=j
        ans+=A[p_cnt[0]]+A[p_cnt[1]]
        i+=1
        
        if i<=M-1:
            ans+=A[p_cnt[0]]+A[p_cnt[1]]
            i+=1
        Next.remove(p_cnt)
        if p_cnt[1]+1<N:
            p_cnt[1]+=1
            Next.append(p_cnt)
            
        Max=max(Max,A[p_cnt[0]]+A[p_cnt[1]])
        if Max<=A[cnt]*2 or Next==[]:
            mode=0
        
print(ans)

Fixed submission:
#E
from bisect import bisect_left
from itertools import accumulate

N,M=map(int,input().split())
A=list(map(int,input().split()))
A=sorted(A)
A_r=list(reversed(A))
B=[0]+list(accumulate(A_r))

def f(x):
    count=0
    for i in A:
        idx=bisect_left(A,x-i)
        count+=N-idx
    if count>=M:
        return True
    else:
        return False
    
MIN=0
MAX=2*10**5+1
while MAX-MIN>1:
    MID=(MIN+MAX)//2
    if f(MID):
        MIN=MID
    else:
        MAX=MID

ans=0
count=0
for i in A_r:
    idx=bisect_left(A,MIN-i)
    ans+=i*(N-idx)+B[N-idx]
    count+=N-idx
print(ans-(count-M)*MIN)

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

Pair=[0 for i in range(N)]
for i in range(N-1):
    Pair[i]=A[i]+A[i+1]

print(A)

ans=0
cnt=0
mode=0
Next=[]
i=0
while i<M:
    if mode==0:
        ans+=2*A[cnt]
        mode=1
        Next.append([cnt,cnt+1])
        cnt+=1
        i+=1
    else:
        Max=0
        for j in Next:
            if Max<=A[j[0]]+A[j[1]]:
                Max=A[j[0]]+A[j[1]]
                p_cnt=j
        ans+=A[p_cnt[0]]+A[p_cnt[1]]
        i+=1
        
        if i<=M-1:
            ans+=A[p_cnt[0]]+A[p_cnt[1]]
            i+=1
        Next.remove(p_cnt)
        if p_cnt[1]+1<N:
            p_cnt[1]+=1
            Next.append(p_cnt)
            
        Max=max(Max,A[p_cnt[0]]+A[p_cnt[1]])
        if Max<=A[cnt]*2:
            mode=0
        
print(ans)

Fixed submission:
#E
from bisect import bisect_left
from itertools import accumulate

N,M=map(int,input().split())
A=list(map(int,input().split()))
A=sorted(A)
A_r=list(reversed(A))
B=[0]+list(accumulate(A_r))

def f(x):
    count=0
    for i in A:
        idx=bisect_left(A,x-i)
        count+=N-idx
    if count>=M:
        return True
    else:
        return False
    
MIN=0
MAX=2*10**5+1
while MAX-MIN>1:
    MID=(MIN+MAX)//2
    if f(MID):
        MIN=MID
    else:
        MAX=MID

ans=0
count=0
for i in A_r:
    idx=bisect_left(A,MIN-i)
    ans+=i*(N-idx)+B[N-idx]
    count+=N-idx
print(ans-(count-M)*MIN)
Buggy python submission (verdict: Runtime Error):
#C
from math import gcd
A,B=map(int,input().split())
LCM=A*B/gcd(A,B)
print(int(LCM))

Fixed submission:
#C
A,B=map(int,input().split())
GCD=1
for i in range(2,10**5+1):
    if A%i==0 and B%i==0:
        GCD=i

LCM=A*B/GCD
print(int(LCM))
Buggy python submission (verdict: Time Limit Exceeded):
#2
def chmin(a,b):
    if a>b:
        return b
    else:
        return a

N,K=map(int,input().split())
H=[int(x) for x in input().split()]

dp=[float("inf")]*N
dp[0]=0

for i in range(N):
    for j in range(1,K+1):
        if i+j<N:
            dp[i+j]=chmin(abs(H[i+j]-H[i])+dp[i],dp[i+j])
        else:
            break
print(dp[-1])

Fixed submission:
#2
def chmin(a,b):
    if a>b:
        return b
    else:
        return a

N,K=map(int,input().split())
H=[int(x) for x in input().split()]

dp=[float("inf")]*N
dp[0]=0

for i in range(N):
    for j in range(1,K+1):
        if i+j<N:
            dp[i+j]=chmin(abs(H[i+j]-H[i])+dp[i],dp[i+j])
        else:
            break
print(dp[-1])

Buggy python submission (verdict: Runtime Error):
#2
N,K=map(int,input().split())
H=[int(x) for x in input().split()]

diff=[0]*(K+1)
dp=[0]*N


for i in range(1,N):
    
    for k in range(1,K+1):
        if i-k>-1:
            diff[k]=abs(H[i]-H[i-k])
        else:
            break
    
    Min=diff[1]
    for k in range(2,min(i+1,K+1)):
        if diff[k]<Min:
            Min=diff[k]
            Min_p=k

    dp[i]=dp[i-Min_p]+Min
print(dp[-1])   

Fixed submission:
#2
def chmin(a,b):
    if a>b:
        return b
    else:
        return a

N,K=map(int,input().split())
H=[int(x) for x in input().split()]

dp=[float("inf")]*N
dp[0]=0

for i in range(N):
    for j in range(1,K+1):
        if i+j<N:
            dp[i+j]=chmin(abs(H[i+j]-H[i])+dp[i],dp[i+j])
        else:
            break
print(dp[-1])

Buggy python submission (verdict: Runtime Error):
#2
N,K=map(int,input().split())
H=[int(x) for x in input().split()]

diff=[0]*(K+1)
dp=[0]*N


for i in range(1,N):
    
    for k in range(1,K+1):
        if i-k>-1:
            diff[k]=abs(H[i]-H[i-k])
        else:
            break
    
    Min=diff[1]
    for k in range(2,min(i+1,K+1)):
        if diff[k]<Min:
            Min=diff[k]
            Min_p=k

    dp[i]=dp[i-Min_p]+Min
print(dp[-1])   

Fixed submission:
#2
def chmin(a,b):
    if a>b:
        return b
    else:
        return a

N,K=map(int,input().split())
H=[int(x) for x in input().split()]

dp=[float("inf")]*N
dp[0]=0

for i in range(N):
    for j in range(1,K+1):
        if i+j<N:
            dp[i+j]=chmin(abs(H[i+j]-H[i])+dp[i],dp[i+j])
        else:
            break
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
#G
N,M=map(int,input().split())
A=[[] for i in range(N+1)]
dp=[[] for j in range(N)]

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

flag=False
for i in range(2,N):
    for x in dp[i-1]:
        dp[i]=dp[i]+A[x]
            
        if dp[i]==[]:
            flag=True
            result=i
            break
    if flag:
        break

print(result)

Fixed submission:
#G
N,M=map(int,input().split())
A=[[] for i in range(N+1)]
B=[0 for i in range(N+1)]
dp=[0 for j in range(N+1)]

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

st=[]
for i in range(1,N+1):
    if B[i]==0:
        st.append(i)
        dp[i]

while len(st):
    x=st.pop()
    for y in A[x]:
        dp[y]=max(dp[y],dp[x]+1)
        B[y]-=1
        if B[y]==0:
            st.append(y)
print(max(dp))

Buggy python submission (verdict: Runtime Error):
#G
N,M=map(int,input().split())
A=[[] for i in range(N+1)]
dp=[[] for j in range(N)]

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

flag=False
for i in range(2,N):
    for x in dp[i-1]:
        for y in A[x]:
            dp[i]=dp[i]+[y]
            
        if dp[i]==[]:
            flag=True
            result=i
            break
    if flag:
        break

print(result)

Fixed submission:
#G
N,M=map(int,input().split())
A=[[] for i in range(N+1)]
B=[0 for i in range(N+1)]
dp=[0 for j in range(N+1)]

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

st=[]
for i in range(1,N+1):
    if B[i]==0:
        st.append(i)
        dp[i]

while len(st):
    x=st.pop()
    for y in A[x]:
        dp[y]=max(dp[y],dp[x]+1)
        B[y]-=1
        if B[y]==0:
            st.append(y)
print(max(dp))
Buggy python submission (verdict: Time Limit Exceeded):
#ABC077-C
N=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))
ans=0
for i in range(N):
    b=B[i]
    if A[-1]<b:
        a_comb=N
    elif A[0]>=b:
        a_comb=0
    elif A[0]<b and A[1]>=b:
        a_comb=1
    else:
        p=N//2
        while True:
            if A[p]<b and A[p+1]>=b:
                a_comb=p+1
                break
            elif A[p]<b and A[p+1]<b:
                p=(N+p)//2
                continue
            elif A[p]>=b:
                p=(p+1)//2
                continue
    if C[0]>b:
        c_comb=N
    elif C[-1]<=b:
        c_comb=0
    elif C[-1]>b and C[-2]<=b:
        c_comb=1
    else:
        p=N//2
        while True:
            if C[p]>b and C[p-1]<=b:
                c_comb=N-p
                break
            elif C[p]>b and C[p-1]>b:
                p=(p+1)//2
                continue
            elif C[p]<=b:
                p=(N+p)//2
                continue
    ans+=a_comb*c_comb
print(ans)

Fixed submission:
#ABC077-C
N=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))

ans=0
for i in range(N):
    b=B[i]
    left=0
    right=N-1
    if A[-1]<b:
        a_comb=N
    elif A[0]>=b:
        a_comb=0
    elif A[0]<b and A[1]>=b:
        a_comb=1
    else:
        a_comb=0
        while left<=right:
            mid=(left+right)//2
            if A[mid]<b and A[mid+1]>=b:
                a_comb=mid+1
                break
            elif A[mid]<b and A[mid+1]<b:
                left=mid+1
            elif A[mid]>=b:
                right=mid-1

    left=0
    right=N-1
    if C[0]>b:
        c_comb=N
    elif C[-1]<=b:
        c_comb=0
    elif C[-1]>b and C[-2]<=b:
        c_comb=1
    else:
        c_comb=0
        while left<=right:
            mid=(left+right)//2
            if C[mid]>b and C[mid-1]<=b:
                c_comb=N-mid
                break
            elif C[mid]>b and C[mid-1]>b:
                right=mid-1
            elif C[mid]<=b:
                left=mid+1
    ans+=a_comb*c_comb
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int, input().split())
A=list(map(int, input().split()))
tb = 1
for i in range(K):
  tb *= A[i]
for i in range(K,N):
  t = tb // A[i-K]
  t *= A[i]
  if t > tb:
    print("Yes")
  else:
    print("No")
  tb = t


Fixed submission:
N,K=map(int, input().split())
A=list(map(int, input().split()))
for i in range(K,N):
  if A[i-K] < A[i]:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
A,V=map(int, input().split())
B,W=map(int, input().split())
T = int(input())
k = abs(A-B)
d = V-W
if d <= 0:
  print("NO")
else:
  for i in range(T):
    k -= d
    if k <= 0:
      print("YES")
      break
  else:
    print("NO")


Fixed submission:
A,V=map(int, input().split())
B,W=map(int, input().split())
T = int(input())
k = abs(A-B)
d = V-W
if d <= 0:
  print("NO")
else:
  if (k / d) > T:
    print("NO")
  else:
    print("YES")
Buggy python submission (verdict: Runtime Error):
import math
r=int(input())
print(r*2*math.pai)


Fixed submission:
import math
r=int(input())
print(r*2*math.pi)
Buggy python submission (verdict: Time Limit Exceeded):
S=input()
Q=int(input())
inv = 0
for i in range(Q):
  q = input()
  if q[0] == "1":
    if inv == 0: inv = 1
    else: inv = 0
  else:
    q,f,c = q.split()
    if f == "1":
      if inv == 0:
        S = c+S
      else:
        S = S+c
    else:
      if inv == 1:
        S = c+S
      else:
        S = S+c
if inv == 1:
  S = S[::-1]
print(S)


Fixed submission:
S=input()
Q=int(input())
inv = 0
s0 = ""
s1 = ""
for i in range(Q):
  q = input()
  if q[0] == "1":
    if inv == 0: inv = 1
    else: inv = 0
  else:
    q,f,c = q.split()
    if f == "1":
      if inv == 0:
        s0 += c
      else:
        s1 += c
    else:
      if inv == 1:
        s0 += c
      else:
        s1 += c
if inv == 1:
  S = s1[::-1] + S[::-1] + s0
else:
  S = s0[::-1] + S + s1

print(S)
Buggy python submission (verdict: Runtime Error):
  N,M=map(int,input().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: Time Limit Exceeded):
N=int(input())
A = list(map(int,input().split()))
MOD = 1000000007

def GCD(a,b):
  if a % b == 0:
    return b
  return GCD(b, a%b)

A.append(1)
a = A[0]
b = A[1]
lcm = a * b // GCD(a,b)
for i in range(2,N):
  a = lcm
  b = A[i]
  lcm = a * b // GCD(a,b)
ans = 0
for i in range(N):
  ans = (ans + (lcm // A[i]))
print(ans%MOD)


Fixed submission:
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

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

lcm = lcm_list(A)
ans = 0
for i in range(N):
  ans = (ans + (lcm // A[i]))
print(ans % MOD)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A = list(map(int,input().split()))
MOD = 1000000007

def GCD(a,b):
  if a % b == 0:
    return b
  return GCD(b, a%b)

A.append(1)
a = A[0]
b = A[1]
lcm = a * b // GCD(a,b)
for i in range(2,N):
  a = lcm
  b = A[i]
  lcm = a * b // GCD(a,b)
ans = 0
for i in range(N):
  ans = (ans + (lcm // A[i])) % MOD
print(ans)


Fixed submission:
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

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

lcm = lcm_list(A)
ans = 0
for i in range(N):
  ans = (ans + (lcm // A[i]))
print(ans % MOD)
Buggy python submission (verdict: Runtime Error):
K,M=mao(int,input().split())
if K*500>=M:
  print("Yes")
else:
  print("No")
  

Fixed submission:
K,M=map(int,input().split())
if K*500>=M:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
import sys
N,M=map(int,input().split())
A = list( map(int,input().split()) )
for i in range(N): A[i] = A[i]//2


def GCD(a,b):
    if a % b == 0:
        return b
    return GCD( b, a%b )

# 全Aが2で和切れる数が等しいか確認
cnt = 1
while A[0]%(1<<cnt) == 0 :
    cnt += 1
for i in range(1,N):
    if (A[i]%(1<<cnt) == 0) or (A[i]%(1<<(cnt-1)) != 0):
        print(0)
        sys.exit()

a = A[0]
b = A[1]
A.append(1)
lcm = a * b // GCD(a,b)
#print(lcm)
if lcm > M:
    print(0)
    sys.exit()
for i in range(2,N):
    a = lcm
    b = A[i]
    lcm = a * b // GCD(a,b)
    if lcm > M:
        print(0)
        sys.exit()
print( (M+lcm+1) // (lcm*2) )



Fixed submission:
import sys
N,M=map(int,input().split())
A = list( map(int,input().split()) )
for i in range(N): A[i] = A[i]//2


def GCD(a,b):
    if a % b == 0:
        return b
    return GCD( b, a%b )

# 全Aが2で割り切れる数が等しいか確認
cnt = 1
while A[0]%(1<<cnt) == 0 :
    cnt += 1
for i in range(1,N):
    if (A[i]%(1<<cnt) == 0) or (A[i]%(1<<(cnt-1)) != 0):
        print(0)
        sys.exit()

A.append(1)
a = A[0]
b = A[1]
lcm = a * b // GCD(a,b)
#print(lcm)
if lcm > M:
    print(0)
    sys.exit()
for i in range(2,N):
    a = lcm
    b = A[i]
    lcm = a * b // GCD(a,b)
    if lcm > M:
        print(0)
        sys.exit()
print( (M+lcm) // (lcm*2) )