Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
pin=sys.stdin.readline

S=pin()[:-1]
Q=int(pin())
now=1

for i in range(Q):
  D=pin().split()
  T=0
  F=0
  C=""
  if len(D)==1:
    T=int(D[0])
  else:
    T=int(D[0])
    F=int(D[1])
    C=D[2]
  if T==1:
    now*=-1
  else:
    if F==1:
      if now==1:
        S=C+S
      else:
        S=S+C
    else:
      if now==1:
        S=S+C
      else:
        S=C+S
if now==1:
  print(S)
else:
  print(S[::-1])


Fixed submission:
import sys
pin=sys.stdin.readline

S=pin()[:-1]
Q=int(pin())
now=1
ans1=""
ans2=""
for i in range(Q):
  D=pin().split()
  T=0
  F=0
  C=""
  if len(D)==1:
    T=int(D[0])
  else:
    T=int(D[0])
    F=int(D[1])
    C=D[2]
  if T==1:
    now*=-1
  else:
    if F==1:
      if now==1:
        ans1=C+ans1
      else:
        ans2=ans2+C
    else:
      if now==1:
        ans2=ans2+C
      else:
        ans1=C+ans1
if now==1:
  print(ans1+S+ans2)
else:
  print(ans2[::-1]+S[::-1]+ans1[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
pin=sys.stdin.readline

S=pin()[:-1]
Q=int(pin())
now=1

for i in range(Q):
  D=pin().split()
  T=0
  F=0
  C=""
  if len(D)==1:
    T=int(D[0])
  else:
    T=int(D[0])
    F=int(D[1])
    C=D[2]
  if T==1:
    now*=-1
  else:
    if F==1:
      if now==1:
        S=C+S
      else:
        S=S+C
    else:
      if now==1:
        S=S+C
      else:
        S=C+S
if now==1:
  print(S)
else:
  print(S[::-1])

Fixed submission:
import sys
pin=sys.stdin.readline

S=pin()[:-1]
Q=int(pin())
now=1
ans1=""
ans2=""
for i in range(Q):
  D=pin().split()
  T=0
  F=0
  C=""
  if len(D)==1:
    T=int(D[0])
  else:
    T=int(D[0])
    F=int(D[1])
    C=D[2]
  if T==1:
    now*=-1
  else:
    if F==1:
      if now==1:
        ans1=C+ans1
      else:
        ans2=ans2+C
    else:
      if now==1:
        ans2=ans2+C
      else:
        ans1=C+ans1
if now==1:
  print(ans1+S+ans2)
else:
  print(ans2[::-1]+S[::-1]+ans1[::-1])
Buggy python submission (verdict: Runtime Error):
'''
Created on 2020/09/10

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N,M=map(int,pin().split())
  if N==3:
    ans=[1,0,0]
    for _ in [0]*M:
      s,c=map(int,pin().split())
      if s==1 and c==0:
        print(-1)
        return 
      if s!=1 and ans[s-1]!=0 and ans[s-1]!=c:
        print(-1)
        return 
      ans[s-1]=c
    a=""
    for i in ans:
      a+=str(i) 
    print(a)
    return 
  elif N==2:
    ans=[1,0]
    for _ in [0]*M:
      s,c=map(int,pin().split())
      if s==1 and c==0:
        print(-1)
        return 
      if s!=1 and ans[s-1]!=0 and ans[s-1]!=c:
        print(-1)
        return 
      ans[s-1]=c
    a=""
    for i in ans:
      a+=str(i)
    print(a)
    return
  else:
    s,c=map(int,pin().split())
    ans=c 
    for j in range(M-1):
      s,c=map(int,pin().split())
      if c!=ans:
        print(-1)
        return 
    print(ans)
    return 
  
main()

Fixed submission:
'''
Created on 2020/08/31

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  N,M=map(int,pin().split())
  ans=[0]*N
  for _ in [0]*M:
    s,c=map(int,pin().split())
    if s==1 and c==0 and N!=1:
      print(-1)
      return 
    if ans[s-1]!=0 and ans[s-1]!=c:
      print(-1)
      return
    ans[s-1]=c
  if N==3:
    if ans[0]==0:
      if ans[1]==0:
        print(f"{1}{0}{ans[2]}")
      else:
        print(f"{1}{ans[1]}{ans[2]}")
      return
    else:
      print(f"{ans[0]}{ans[1]}{ans[2]}")
      return
  elif N==2:
    if ans[0]==0:
      print(f"{1}{ans[1]}")
    else:
      print(f"{ans[0]}{ans[1]}")
    return
  else:
    print(ans[0])
    return
  return
main()
Buggy python submission (verdict: Time Limit Exceeded):
'''
Created on 2020/08/17

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  N=int(pin())
  P=list(map(int,pin().split()))
  ans=0
  for i in range(N):
    if min(P[:i+1])==P[i]:
      ans+=1
  print(ans)
  return 

main()

Fixed submission:
'''
Created on 2020/08/17

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  N=int(pin())
  P=list(map(int,pin().split()))
  ans=0
  m=P[0]
  for i in range(N):
    if m>=P[i]:
      m=P[i]
      ans+=1
  print(ans)
  return 

main()
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
B=[1]*N
for x in range(N):
  B[x]+=A.index(x+1)
for y in B:
  print(y,end="")
  if y!=B[N-1]:
    print(" ",end="")
print("\n")

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
B=[1]*N
for x in range(N):
  B[A[x]-1]+=x
for y in B:
  print(y,end="")
  if y!=B[N-1]:
    print(" ",end="")
print("\n")
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
A=list(map(int,input().split()))
for x in range(M):
  A.sort(reverse=True)
  A[0]//=2
print(sum(A))

Fixed submission:
import heapq
N,M=map(int,input().split())
A=list(map(lambda x: int(x)*(-1),input().split()))
heapq.heapify(A)
for x in range(M):
  t=(-1)*heapq.heappop(A)
  heapq.heappush(A,(-1)*(t//2))
print(-1*sum(A))
Buggy python submission (verdict: Time Limit Exceeded):
'''
Created on 2020/09/08

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  X,Y,Z,K=map(int,pin().split())
  A=list(map(int,pin().split()))
  B=list(map(int,pin().split()))
  C=list(map(int,pin().split()))
#   A.sort(reverse=True)
#   B.sort(reverse=True)
#   C.sort(reverse=True)

  d=[]
  for i in A:
    for j in B:
      d.append(i+j)
  d.sort(reverse=True)
  d=d[:K]
  ans=[]
  for k in d:
    for l in C:
      ans.append(k+l)
  ans.sort(reverse=True)
  for m in range(K):
    print(ans[m])
  return
main()



Fixed submission:
'''
Created on 2020/09/08

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  X,Y,Z,K=map(int,pin().split())
  A=list(map(int,pin().split()))
  B=list(map(int,pin().split()))
  C=list(map(int,pin().split()))
#   A.sort(reverse=True)
#   B.sort(reverse=True)
#   C.sort(reverse=True)

  d=[]
  for i in A:
    for j in B:
      d.append(i+j)
  d.sort(reverse=True)
  d=d[:K]
  ans=[]
  for k in d:
    for l in C:
      ans.append(k+l)
  ans.sort(reverse=True)
  for m in range(K):
    print(ans[m])
  return
main()

Buggy python submission (verdict: Time Limit Exceeded):
'''
Created on 2020/09/08

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  X,Y,Z,K=map(int,pin().split())
  A=list(map(int,pin().split()))
  B=list(map(int,pin().split()))
  C=list(map(int,pin().split()))
#   A.sort(reverse=True)
#   B.sort(reverse=True)
#   C.sort(reverse=True)

  d=[]
  for i in A:
    for j in B:
      d.append(i+j)
#   d.sort(reverse=True)
  ans=[]
  for k in d:
    for l in C:
      ans.append(k+l)
  ans.sort(reverse=True)
  for m in range(K):
    print(ans[m])
  return 
main()



Fixed submission:
'''
Created on 2020/09/08

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  X,Y,Z,K=map(int,pin().split())
  A=list(map(int,pin().split()))
  B=list(map(int,pin().split()))
  C=list(map(int,pin().split()))
#   A.sort(reverse=True)
#   B.sort(reverse=True)
#   C.sort(reverse=True)

  d=[]
  for i in A:
    for j in B:
      d.append(i+j)
  d.sort(reverse=True)
  d=d[:K]
  ans=[]
  for k in d:
    for l in C:
      ans.append(k+l)
  ans.sort(reverse=True)
  for m in range(K):
    print(ans[m])
  return
main()
Buggy python submission (verdict: Runtime Error):
A,B,K=map(int,input().split())
i=0
j=0
while i<K:
  j+=1
  if A*%j==0 and B%j==0:
    i+=1
print(j)

Fixed submission:
A,B,K=map(int,input().split())
i=0
j=min(A,B)+1
while i<K:
  j-=1
  if A%j==0 and B%j==0:
    i+=1
print(j)
Buggy python submission (verdict: Time Limit Exceeded):
'''
Created on 2020/09/15

@author: harurun
'''
import sys
pin=sys.stdin.readline

N,K=map(int,pin().split())
h=list(map(int,pin().split()))
dp=[0]*N
for i in range(1,N):
  dp[i]=dp[i-1]+abs(h[i-1]-h[i])
  for j in range(1,K+1):
    if i-j>=0:
      dp[i]=min(dp[i],dp[i-j]+abs(h[i-j]-h[i]))
print(dp[N-1])
# print(dp)
#解説AC

Fixed submission:
'''
Created on 2020/09/15
 
@author: harurun
'''
import sys
pin=sys.stdin.readline
 
N,K=map(int,pin().split())
h=list(map(int,pin().split()))
dp=[0]*N
for i in range(1,N):
  dp[i]=dp[i-1]+abs(h[i-1]-h[i])
  for j in range(1,K+1):
    if i-j>=0:
      dp[i]=min(dp[i],dp[i-j]+abs(h[i-j]-h[i]))
print(dp[N-1])
# print(dp)
#解説AC
Buggy python submission (verdict: Time Limit Exceeded):
'''
Created on 2020/09/15

@author: harurun
'''
import sys
pin=sys.stdin.readline


N,W=map(int,pin().split())
dp=[[0]*(W+1) for _ in [0]*(N+1)]

for i in range(1,N+1):
  w,v=pin().split()
  w=int(w)
  v=int(v)
  for j in range(W+1):
    if j-w>=0:
      dp[i][j]=max(dp[i-1][j],dp[i-1][j-w]+v)
    else:
      dp[i][j]=dp[i-1][j]
print(dp[N][W])
#解説AC

Fixed submission:
'''
Created on 2020/09/15

@author: harurun
'''
import sys
pin=sys.stdin.readline


N,W=map(int,pin().split())
dp=[[0]*(W+1) for _ in [0]*(N+1)]

for i in range(1,N+1):
  w,v=pin().split()
  w=int(w)
  v=int(v)
  for j in range(W+1):
    if j-w>=0:
      dp[i][j]=max(dp[i-1][j],dp[i-1][j-w]+v)
    else:
      dp[i][j]=dp[i-1][j]
print(dp[N][W])
#解説AC
Buggy python submission (verdict: Time Limit Exceeded):
"""メモリ足りねぇ..."""

import sys
pin=sys.stdin.readline

INF=10**10
N,W=map(int,pin().split())

dp=[[INF]*100001 for _ in [0]*(N+1)]
dp[0][0]=0
for i in range(1,N+1):
  w,v=pin().split()
  w=int(w)
  v=int(v)
  for j in range(100001):
    if j-v>=0:
      dp[i][j]=min(dp[i-1][j],dp[i-1][j-v]+w)
    else:
      dp[i][j]=dp[i-1][j]
ans=100000
while dp[N][ans]>W:
  ans-=1
print(ans)
#解説AC

Fixed submission:
"""メモリ足りねぇ..."""

import sys
pin=sys.stdin.readline

INF=10**10
N,W=map(int,pin().split())

dp=[[INF]*100001 for _ in [0]*(N+1)]
dp[0][0]=0
for i in range(1,N+1):
  w,v=pin().split()
  w=int(w)
  v=int(v)
  for j in range(100001):
    if j-v>=0:
      dp[i][j]=min(dp[i-1][j],dp[i-1][j-v]+w)
    else:
      dp[i][j]=dp[i-1][j]
ans=100000
while dp[N][ans]>W:
  ans-=1
print(ans)
#解説AC

Buggy python submission (verdict: Runtime Error):
'''
Created on 2020/09/15

@author: harurun
'''
import sys
pin=sys.stdin.readline


N,W=map(int,pin().split())
dp=[[0]*(W+1) for _ in [0]*(N+1)]

for i in range(1,N+1):
  w,v=pin().split()
  w=int(w)
  v=int(v)
  for j in range(W+1):
    if j-w>=0:
      dp[i][j]=max(dp[i-1][j],dp[i-1][j-w]+v)
    else:
      dp[i][j]=dp[i-1][j]
print(dp[N][W])


Fixed submission:
"""メモリ足りねぇ..."""

import sys
pin=sys.stdin.readline

INF=10**10
N,W=map(int,pin().split())

dp=[[INF]*100001 for _ in [0]*(N+1)]
dp[0][0]=0
for i in range(1,N+1):
  w,v=pin().split()
  w=int(w)
  v=int(v)
  for j in range(100001):
    if j-v>=0:
      dp[i][j]=min(dp[i-1][j],dp[i-1][j-v]+w)
    else:
      dp[i][j]=dp[i-1][j]
ans=100000
while dp[N][ans]>W:
  ans-=1
print(ans)
#解説AC
Buggy python submission (verdict: Time Limit Exceeded):
'''
Created on 2020/08/26

@author: harurun
'''
def main():
  import math
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N,P=map(int,pin().split())
  t=int(P**(1/N))+1
  if N==1:
    print(P)
    return 
  while t>0:
    s=P
    for i in range(N):
      if s%t!=0:
        break
      s=s//t
    else:
      print(t)
      return
    t-=1
  print(1)
  return 

main()

Fixed submission:
'''
Created on 2020/08/26

@author: harurun
'''
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

def main():
  import math
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  N,P=map(int,pin().split())
  l=factorize(P)
  d=list(set(l))
  ans=1
  for i in d:
    t=l.count(i)
    if t>=N:
      ans*=i**(int(t/N))
  print(ans)
  return

main()

Buggy python submission (verdict: Time Limit Exceeded):
'''
Created on 2020/08/26

@author: harurun
'''
def main():
  import math
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N,P=map(int,pin().split())
  t=int(math.sqrt(P))+1
  if N==1:
    print(P)
    return 
  while t>0:
    s=P
    for i in range(N):
      if s%t!=0:
        break
      s=s//t
    else:
      print(t)
      return
    t-=1
  print(1)
  return 

main()

Fixed submission:
'''
Created on 2020/08/26

@author: harurun
'''
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

def main():
  import math
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  N,P=map(int,pin().split())
  l=factorize(P)
  d=list(set(l))
  ans=1
  for i in d:
    t=l.count(i)
    if t>=N:
      ans*=i**(int(t/N))
  print(ans)
  return

main()
Buggy python submission (verdict: Time Limit Exceeded):
'''
Created on 2020/08/26

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  s=pin()[:-1]
  K=int(pin())
  d=[]
  for i in range(1,len(s)+1):
    ans=[]
    for j in range(len(s)-i+1):
      ans.append(s[j:j+i])
    d=sorted(d+sorted(list(set(ans))))
  print(d[K-1])
  return 
main()

Fixed submission:
'''
Created on 2020/08/26

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  s=pin()[:-1]
  K=int(pin())
  d=[]
  for i in range(1,K+1):
    for j in range(len(s)-i+1):
      d.append(s[j:j+i])
  ans=sorted(list(set(d)))
  print(ans[K-1])
  return
main()

#解説AC

Buggy python submission (verdict: Time Limit Exceeded):
'''
Created on 2020/08/26

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  s=pin()[:-1]
  K=int(pin())
  d=[]
  for i in range(1,len(s)+1):
    for j in range(len(s)-i+1):
      t=s[j:j+i]
      if t not in d:
        d.append(t)
  l=sorted(d)
  print(l[K-1])
  return 
main()

Fixed submission:
'''
Created on 2020/08/26

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  s=pin()[:-1]
  K=int(pin())
  d=[]
  for i in range(1,K+1):
    for j in range(len(s)-i+1):
      d.append(s[j:j+i])
  ans=sorted(list(set(d)))
  print(ans[K-1])
  return
main()

#解説AC

Buggy python submission (verdict: Time Limit Exceeded):
'''
Created on 2020/08/26

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  s=pin()[:-1]
  K=int(pin())
  d=[]
  for i in range(1,len(s)+1):
    for j in range(len(s)-i+1):
      t=s[j:j+i]
      d.append(t)
    d.sort()
  l=sorted(list(set(d)))
  print(l[K-1])
  return 
main()

Fixed submission:
'''
Created on 2020/08/26

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  s=pin()[:-1]
  K=int(pin())
  d=[]
  for i in range(1,K+1):
    for j in range(len(s)-i+1):
      d.append(s[j:j+i])
  ans=sorted(list(set(d)))
  print(ans[K-1])
  return
main()

#解説AC

Buggy python submission (verdict: Time Limit Exceeded):
'''
Created on 2020/08/26

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  s=pin()[:-1]
  K=int(pin())
  d=[]
  for i in range(1,len(s)+1):
    for j in range(len(s)-i+1):
      t=s[j:j+i]
      d.append(t)
  l=sorted(list(set(d)))
  print(l[K-1])
  return 
main()

Fixed submission:
'''
Created on 2020/08/26

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  s=pin()[:-1]
  K=int(pin())
  d=[]
  for i in range(1,K+1):
    for j in range(len(s)-i+1):
      d.append(s[j:j+i])
  ans=sorted(list(set(d)))
  print(ans[K-1])
  return
main()

#解説AC
Buggy python submission (verdict: Time Limit Exceeded):
'''
Created on 2020/08/29

@author: harurun
'''
def main():
  import copy
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  X=list(map(int,pin().split()))
  t=(N+1)//2
  Y=sorted(X)
  for i in range(N):
    T=copy.copy(Y)
    T.remove(X[i])
    print(T[t-1])
  return 

main()

Fixed submission:
'''
Created on 2020/08/29

@author: harurun
'''
def main():
  import copy
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  X=list(map(int,pin().split()))
  t=(N+1)//2
  Y=sorted(X)
  ans1=Y[t-1]
  ans2=Y[t]
  median=ans1+ans2
  for i in range(N):
    s=X[i]
    if s==ans1:
      print(ans2)
    elif s==ans2:
      print(ans1)
    elif  2*s<median:
      print(ans2)
    elif 2*s>median:
      print(ans1)
  return 

main()

Buggy python submission (verdict: Time Limit Exceeded):
'''
Created on 2020/08/29

@author: harurun
'''
def main():
  import statistics
  import math
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  X=list(map(int,pin().split()))
  t=(N+1)//2
  for i in range(N-1):
    print(sorted((X[:i]+X[i+1:]))[t-1])
  print(sorted(X[:N-1])[t-1])
  return 

main()

Fixed submission:
'''
Created on 2020/08/29

@author: harurun
'''
def main():
  import copy
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  X=list(map(int,pin().split()))
  t=(N+1)//2
  Y=sorted(X)
  ans1=Y[t-1]
  ans2=Y[t]
  median=ans1+ans2
  for i in range(N):
    s=X[i]
    if s==ans1:
      print(ans2)
    elif s==ans2:
      print(ans1)
    elif  2*s<median:
      print(ans2)
    elif 2*s>median:
      print(ans1)
  return 

main()

Buggy python submission (verdict: Time Limit Exceeded):
'''
Created on 2020/08/29

@author: harurun
'''
def main():
  import statistics
  import math
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  X=list(map(int,pin().split()))
  for i in range(N):
    try:
      print(statistics.median(X[:i]+X[i+1:]))
    except:
      pass
  return 

main()

Fixed submission:
'''
Created on 2020/08/29

@author: harurun
'''
def main():
  import copy
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  X=list(map(int,pin().split()))
  t=(N+1)//2
  Y=sorted(X)
  ans1=Y[t-1]
  ans2=Y[t]
  median=ans1+ans2
  for i in range(N):
    s=X[i]
    if s==ans1:
      print(ans2)
    elif s==ans2:
      print(ans1)
    elif  2*s<median:
      print(ans2)
    elif 2*s>median:
      print(ans1)
  return 

main()
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
  int N;
  cin >> N;
	vector<int> a(N);
	rep(i,N) cin>>a[i];
	sort(a.rbegin(),a.rend());
	long int ans=0;
	rep(i,N){
	  if (i%2==0)ans+=a[i];
	  else ans-=a[i];
	}
	cout << ans << "\n";
}

Fixed submission:
N=int(input())
a=list(map(int,input().split()))
A=0
B=0
a.sort(reverse=True)
for i in range(N):
  if i%2==0:
    A+=a[i]
  else:
    B+=a[i]
print(A-B)
Buggy python submission (verdict: Runtime Error):
s=input()
t=input()
s.sort()
t.sort(reverse=True)
for i in range(min(len(s),len(t))):
  if ord(s[i])==ord(t[i]):
    continue
  elif ord(s[i])<ord(t[i]):
    print("Yes")
    break
  else:
    print("No")
else:
  print("No")

Fixed submission:
s=list(input())
t=list(input())
s.sort()
t.sort(reverse=True)
s="".join(s)
t="".join(t)
for i in range(min(len(s),len(t))):
  if ord(s[i])==ord(t[i]):
    continue
  elif ord(s[i])<ord(t[i]):
    print("Yes")
    break
  else:
    print("No")
    break
else:
  if len(s)<len(t):
    print("Yes")
  else:
    print("No")

Buggy python submission (verdict: Runtime Error):
s=input()
t=input()
s.sort()
t.sort(reverse=True)
for i in range(min(len(s,t))):
  if ord(s[i])==ord(t[i]):
    continue
  elif ord(s[i])<ord(s[i]):
    print("Yes")
    break
  else:
    print("No")
else:
  print("No")

Fixed submission:
s=list(input())
t=list(input())
s.sort()
t.sort(reverse=True)
s="".join(s)
t="".join(t)
for i in range(min(len(s),len(t))):
  if ord(s[i])==ord(t[i]):
    continue
  elif ord(s[i])<ord(t[i]):
    print("Yes")
    break
  else:
    print("No")
    break
else:
  if len(s)<len(t):
    print("Yes")
  else:
    print("No")

Buggy python submission (verdict: Runtime Error):
import sys
s=input()
t=input()
if s==t:
  print("No")
  sys.exit()
S=list(s)
T=list(t)
for i in s:
  if i in t:
    S.remove(i)
    T.remove(i)
S.sort()
T.sort()
a="".join(S)
b="".join(T)
if b=="":
  print("No")
  sys.exit()
if a=="":
  print("Yes")
  sys.exit()
for j in b:
  if ord(a[0])<ord(j):
    print("Yes")
    break
else:
  print("No")

Fixed submission:
s=list(input())
t=list(input())
s.sort()
t.sort(reverse=True)
s="".join(s)
t="".join(t)
for i in range(min(len(s),len(t))):
  if ord(s[i])==ord(t[i]):
    continue
  elif ord(s[i])<ord(t[i]):
    print("Yes")
    break
  else:
    print("No")
    break
else:
  if len(s)<len(t):
    print("Yes")
  else:
    print("No")

Buggy python submission (verdict: Runtime Error):
import sys
s=input()
t=input()
if s==t:
  print("No")
  sys.exit()
S=list(s)
T=list(t)
for i in s:
  if i in t:
    S.remove(i)
    T.remove(i)
S.sort()
T.sort()
a="".join(S)
b="".join(T)
if a=="":
  print("Yes")
  sys.exit()
for j in b:
  if ord(a[0])<ord(j):
    print("Yes")
    break
else:
  print("No")

Fixed submission:
s=list(input())
t=list(input())
s.sort()
t.sort(reverse=True)
s="".join(s)
t="".join(t)
for i in range(min(len(s),len(t))):
  if ord(s[i])==ord(t[i]):
    continue
  elif ord(s[i])<ord(t[i]):
    print("Yes")
    break
  else:
    print("No")
    break
else:
  if len(s)<len(t):
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
'''
Created on 2020/08/28

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  n=int(pin())
  a=list(map(int,pin().split()))
  b=[]
  for i in a:
    b.append(i)
    b.reverse()
  for j in range(n):
    pout(f"{b[j]}")
    if j!=n-1:
      pout(" ")
  return 
main()
    

Fixed submission:
'''
Created on 2020/08/28

@author: harurun
'''
def main():
  from collections import deque
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  n=int(pin())
  a=list(map(int,pin().split()))
  b=deque([])
  if n%2==0:
    for i in range(n):
      if i%2==0:
        b.append(a[i])
      else:
        b.appendleft(a[i])
  else:
    for j in range(n):
      if j%2==0:
        b.appendleft(a[j])
      else:
        b.append(a[j])
  for k in range(n):
    pout(str(b[k]))
    if k!=n-1:
      pout(" ")
  pout("\n")
  return 
main()
Buggy python submission (verdict: Runtime Error):
O=input()
E=input()
ans=""
for i in range(len(O)):
  ans+=O[i]+E[i]
print(ans)

Fixed submission:
O=input()
E=input()
ans=""
for i in range(len(O)):
  try:
    ans+=O[i]+E[i]
  except:
    ans+=O[i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
ans=0
K,S=map(int,input().split())
for x in range(K+1):
  for y in range(K+1):
    for z in range(K+1):
      if x+y+z==S:
        ans+=1
print(ans)

Fixed submission:
ans=0
K,S=map(int,input().split())
for x in range(K+1):
  for y in range(K+1):
    if 0<=S-x-y and S-x-y<=K:
      ans+=1
print(ans)