Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
change_flag = 1
for i in range(int(input())):
    a = input().split(" ")
    if(a[0] == "1"):
        change_flag *= -1
    else:
        if((a[1] == "1" and change_flag == 1) or (a[1] == "2" and change_flag == -1)):
            s = a[2] + s
        else:
            s = s + a[2]

if(change_flag == -1):
    print(s[::-1])
else:
    print(s)

Fixed submission:
s = input()
b = ""
f = ""
change_flag = 1
for i in range(int(input())):
    a = input().split(" ")
    if(a[0] == "1"):
        change_flag *= -1
    else:
        if((a[1] == "1" and change_flag == 1) or (a[1] == "2" and change_flag == -1)):
            b = a[2] + b
        else:
            f = f + a[2]

if(change_flag == -1):
    print(f[::-1]+s[::-1]+b[::-1])
else:
    print(b+s+f)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
num = int(input())
change_flag = 1
for i in range(num):
    a = input().split(" ")
    if(a[0] == "1"):
        change_flag *= -1
    else:
        if((a[1] == "1" and change_flag == 1) or (a[1] == "2" and change_flag == -1)):
            s = a[2] + s
        else:
            s = s + a[2]

if(change_flag == -1):
    s = s[::-1]
print(s)



Fixed submission:
s = input()
b = ""
f = ""
change_flag = 1
for i in range(int(input())):
    a = input().split(" ")
    if(a[0] == "1"):
        change_flag *= -1
    else:
        if((a[1] == "1" and change_flag == 1) or (a[1] == "2" and change_flag == -1)):
            b = a[2] + b
        else:
            f = f + a[2]

if(change_flag == -1):
    print(f[::-1]+s[::-1]+b[::-1])
else:
    print(b+s+f)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
num = int(input())
for i in range(num):
    a = input().split(" ")
    if(a[0] == "1"):
        s = s[::-1]
    else:
        if(a[1] == "1"):
            s = a[2] + s
        else:
            s = s + a[2]

print(s)



Fixed submission:
s = input()
b = ""
f = ""
change_flag = 1
for i in range(int(input())):
    a = input().split(" ")
    if(a[0] == "1"):
        change_flag *= -1
    else:
        if((a[1] == "1" and change_flag == 1) or (a[1] == "2" and change_flag == -1)):
            b = a[2] + b
        else:
            f = f + a[2]

if(change_flag == -1):
    print(f[::-1]+s[::-1]+b[::-1])
else:
    print(b+s+f)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
num = int(input())
for i in range(num):
    a = input().split(" ")
    a[0] = int(a[0])
    if(a[0] == 1):
        s = s[::-1]
    elif(a[0] == 2):
        a[1] = int(a[1])
        if(a[1] == 1):
            s = a[2] + s
        elif(a[1] == 2):
            s = s + a[2]

print(s)



Fixed submission:
s = input()
b = ""
f = ""
change_flag = 1
for i in range(int(input())):
    a = input().split(" ")
    if(a[0] == "1"):
        change_flag *= -1
    else:
        if((a[1] == "1" and change_flag == 1) or (a[1] == "2" and change_flag == -1)):
            b = a[2] + b
        else:
            f = f + a[2]

if(change_flag == -1):
    print(f[::-1]+s[::-1]+b[::-1])
else:
    print(b+s+f)
Buggy python submission (verdict: Runtime Error):
N = int(input())
if N == 1 :
	print("Hello World")
else :
	A = int(input())
    B = int(input())
    print(A + B)

Fixed submission:
N = int(input())
if N == 1:
    print("Hello World")
else:
    A = int(input())
    B = int(input())
    print(A + B)

Buggy python submission (verdict: Runtime Error):
N = int(input())

if N == 1 :
	print("Hello World")
else :
  	A = int(input())
    B = int(input())
    print(A + B)

Fixed submission:
N = int(input())
if N == 1:
    print("Hello World")
else:
    A = int(input())
    B = int(input())
    print(A + B)
Buggy python submission (verdict: Runtime Error):
char = input()
chars = []
chars.append(char.split())

for cha in chars:
  if cha == 1:
    cha = 9
  else cha == 9:
    cha = 1
  print(cha, end="")

Fixed submission:
char = input()
chars = list(char)

for cha in chars:
  if cha == "1":
    cha = "9"
  elif cha == "9":
    cha = "1"
  print(cha, end="")
Buggy python submission (verdict: Runtime Error):
N = input().split()
N.sort()
print(N)

N1 = N[2] + N[1]
print(int(Nmax) + int(N[0]))


Fixed submission:
N = input().split()
N.sort()

Nmax = N[2] + N[1]
print(int(Nmax) + int(N[0]))
Buggy python submission (verdict: Runtime Error):
x1,y1,x2,y2 = map(int, input().split())
ylen = y2 - y1
xlen = x2 - x1

x3 = x2 - ylen
y3 = y2 + xlen
x4 = x3 - xlen
y4 = y3 - ylen

print(str(x3) + " " + str(y3) + " " + str(x4) + " " + str(y4)) 

Fixed submission:
K = int(input())
 
if K % 2 == 0:
  answer = (K / 2)**2
else:
  answer = ((K + 1) / 2)**2 - ((K + 1) / 2)
 
print(int(answer))

Buggy python submission (verdict: Runtime Error):
K = int(input())

if K % 2 == 0:
  answer = (K % 2)^2
else:
  answer = ((K + 1) % 2))^2

print(answer)

Fixed submission:
K = int(input())
 
if K % 2 == 0:
  answer = (K / 2)**2
else:
  answer = ((K + 1) / 2)**2 - ((K + 1) / 2)
 
print(int(answer))
Buggy python submission (verdict: Runtime Error):
x1,y1,x2,y2 = map(int, input().split())
len = abs(x1 - x2)

x4 = x1 - len
x3 = x2 - len
y4 = y1 - len
y3 = y2 - len

print(x3 + " " + y3 + " " + x4 + " " + y4) 

Fixed submission:
x1,y1,x2,y2 = map(int, input().split())
ylen = y2 - y1
xlen = x2 - x1

x3 = x2 - ylen
y3 = y2 + xlen
x4 = x3 - xlen
y4 = y3 - ylen

print(str(x3) + " " + str(y3) + " " + str(x4) + " " + str(y4))
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input())
print(a if a <= b else a-1)

Fixed submission:
a, b = map(int, input().split())
print(a if a <= b else a-1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = list(map(int, input().split()))
print("Four" if "Y" in s else "Three")

Fixed submission:
n = int(input())
s = list(input().split())
print("Four" if "Y" in s else "Three")
Buggy python submission (verdict: Runtime Error):
s = [int(x) for x in int(input())]

sum = 0
for i in s:
  if i == 1:
    sum += 1

print(sum)

Fixed submission:
s = int(input())
l = [int(x) for x in list(str(s))]

sum = 0
for i in l:
  if i == 1:
    sum += 1

print(sum)
Buggy python submission (verdict: Runtime Error):
import math

n = int(input())
a = round(0, sqrt(n))

print(a ** 2)

Fixed submission:
import math

n = int(input())

print(math.floor(math.sqrt(n)) ** 2)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
Li = list(map(int, input().split()))
Li.reverse()

length = 0
for l, i in Li:
  length += 0
  if i == k - 1:
    break
    
print(length)

Fixed submission:
n, k = map(int, input().split())
Li = list(map(int, input().split()))
Li.sort(reverse=True)

length = 0
for i, l in enumerate(Li):
  length += l
  if i == k - 1:
    break
    
print(length)
Buggy python submission (verdict: Runtime Error):
a1_1, a1_2, a1_3 = map(int, input().split())
a2_1, a2_2, a2_3 = map(int, input().split())
a3_1, a3_2, a3_3 = map(int, input().split())
a_list=[a1_1, a1_2, a1_3, a2_1, a2_2, a2_3, a3_1, a3_2, a3_3]
n = int(input())
b=[]
for i in range(n):
  b_i = int(input())
  b.append(b_i)
  for j in range(len(a_list)):
    if a_list[j] == b_i:
      a_list[j] = -1
if ((a_list[0]==-1 and a_list[1] == -1 and a_list[2] == -1) or
    (a_list[3]==-1 and a_list[4] == -1 and a_list[5] == -1) or
    (a_list[6]==-1 and a_list[7] == -1 and a_list[8] == -1) or
    (a_list[0]==-1 and a_list[3] == -1 and a_list[6] == -1) or
    (a_list[1]==-1 and a_list[4] == -1 and a_list[7] == -1) or
    (a_list[2]==-1 and a_list[5] == -1 and a_list[8] == -1):
  print("Yes")
else:
  print("No")

Fixed submission:
a1_1, a1_2, a1_3 = map(int, input().split())
a2_1, a2_2, a2_3 = map(int, input().split())
a3_1, a3_2, a3_3 = map(int, input().split())
a_list=[a1_1, a1_2, a1_3, a2_1, a2_2, a2_3, a3_1, a3_2, a3_3]
n = int(input())
b=[]
for i in range(n):
  b_i = int(input())
  b.append(b_i)
  for j, a_j in enumerate(a_list):
    if a_j == b_i:
      a_list[j] = -1
    
if ((a_list[0]==-1 and a_list[1] == -1 and a_list[2] == -1) or
    (a_list[3]==-1 and a_list[4] == -1 and a_list[5] == -1) or
    (a_list[6]==-1 and a_list[7] == -1 and a_list[8] == -1) or
    (a_list[0]==-1 and a_list[3] == -1 and a_list[6] == -1) or
    (a_list[1]==-1 and a_list[4] == -1 and a_list[7] == -1) or
    (a_list[2]==-1 and a_list[5] == -1 and a_list[8] == -1) or
    (a_list[0]==-1 and a_list[4] == -1 and a_list[8] == -1) or
	(a_list[2]==-1 and a_list[4] == -1 and a_list[6] == -1)):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int, input().split()))
is_yes = True
for i, a_i in enumerate(a):
  for j, a_j in enumerate(a[i+1:]):
    if a_i == a_j:
      is_yes = False
      break
if is_yes:
  print("YES")
else:
  print("NO")

Fixed submission:
n=int(input())
a=list(map(int, input().split()))
is_yes = True
a_m = {}
for a_i in a:
  if a_i in a_m:
    is_yes = False
    break
  a_m[a_i]=True
if is_yes:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))
s_max = 0
max_i=0
ret = 0
s_list = [sum(p[i:i+k]) for i in range(n-k+1)]
s_max=max(s_list)
print(k/2+s_max/2)

Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split()))
max_i=0
ret = 0
p_s=sum(p[0:k])
s_max=p_s
for i in range(n-k):
  p_s=p_s-p[i]+p[i+k]
  if s_max<p_s:
    s_max=p_s

print(s_max/2+k/2)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))
s_max = 0
max_i=0
ret = 0
s_list = [sum(p[i:i+k]) for i in range(n-k+1)]
s_max=max(s_list)
max_i=s_list.index(s_max)

for i in range(k):
  p_i = p[max_i+i]
  ret+=(1+p_i)*p_i/(2*p_i)
  
print(ret)

Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split()))
max_i=0
ret = 0
p_s=sum(p[0:k])
s_max=p_s
for i in range(n-k):
  p_s=p_s-p[i]+p[i+k]
  if s_max<p_s:
    s_max=p_s

print(s_max/2+k/2)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))
s_max = 0
max_i=0
ret = 0
for i in range(n-k+1):
  p_s=sum(p[i:i+k])
  if s_max<p_s:
    s_max=p_s
    max_i=i
for i in range(k):
  p_i = p[max_i+i]
  ret+=(1+p_i)*p_i/(2*p_i)
  
print(ret)

Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split()))
max_i=0
ret = 0
p_s=sum(p[0:k])
s_max=p_s
for i in range(n-k):
  p_s=p_s-p[i]+p[i+k]
  if s_max<p_s:
    s_max=p_s

print(s_max/2+k/2)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))
ret = 0
for i in range(n-k+1):
  p_s=0
  for j in range(k):
    p_i = p[i+j]
    p_s+=(1+p_i)*p_i/(2*p_i)
  if p_s>ret:
    ret = p_s
print(ret)

Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split()))
max_i=0
ret = 0
p_s=sum(p[0:k])
s_max=p_s
for i in range(n-k):
  p_s=p_s-p[i]+p[i+k]
  if s_max<p_s:
    s_max=p_s

print(s_max/2+k/2)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split(" "))
nac = 0
npe = 0
cp = 0
is_ac = [False]*n
np_list = [0]*n
for i in range(m):
  p_s, s = input().split(" ")
  p = int(p_s)-1
  cis_ac = is_ac[p]
  
  if cis_ac:
    continue
  if s == "AC":
    nac += 1
    is_ac[p]=True
  else:
    np_list[p] += 1

for a in is_ac:
  if a:
    npe += np_list[a]
print(str(nac)+" "+str(npe))


Fixed submission:
n, m = map(int, input().split(" "))
nac = 0
npe = 0
cp = 0
is_ac = [False]*n
np_list = [0]*n
for i in range(m):
  p_s, s = input().split(" ")
  p = int(p_s)-1
  cis_ac = is_ac[p]
  
  if cis_ac:
    continue
  if s == "AC":
    nac += 1
    is_ac[p]=True
  else:
    np_list[p] += 1

for i, a in enumerate(is_ac):
  if a:
    npe += np_list[i]
print(str(nac)+" "+str(npe))
Buggy python submission (verdict: Time Limit Exceeded):
b=list(map(int,input().split()))
LL=[]
for i in range(b[0]):
    LL.append(list(map(int,input().split())))
LL.sort(key=lambda x: x[0])
x=0
z=0
y=b[1]
while y>=0 and not LL==[]:
    if y<=LL[0][1]:
        print(x+LL[0][0]*y)
        break
    else:
        y-=LL[0][1]
        x+=LL[0][1]*LL[0][0]
        LL=LL[1:]

Fixed submission:
b=list(map(int,input().split()))
LL=[]
for i in range(b[0]):
    LL.append(list(map(int,input().split())))
LL.sort()
x=0
z=0
y=b[1]
i=-1
while y>=0 and not LL==[]:
    i+=1
    if y<=LL[i][1]:
        print(x+LL[i][0]*y)
        break
    else:
        y-=LL[i][1]
        x+=LL[i][1]*LL[i][0]

Buggy python submission (verdict: Time Limit Exceeded):
b=list(map(int,input().split()))
LL=[]
for i in range(b[0]):
    LL.append(list(map(int,input().split())))
LL.sort(key=lambda x: x[0])
x=0
z=0
y=b[1]
while y>=0 and not LL==[]:
    if LL==[]:
        print(x-y*(-1)*w)
        z=1
        break
    else:
        y-=LL[0][1]
        x+=LL[0][1]*LL[0][0]
        z=LL[0][1]*LL[0][0]
        w=LL[0][0]
        LL=LL[1:]
print(x-y*(-1)*w)

Fixed submission:
b=list(map(int,input().split()))
LL=[]
for i in range(b[0]):
    LL.append(list(map(int,input().split())))
LL.sort()
x=0
z=0
y=b[1]
i=-1
while y>=0 and not LL==[]:
    i+=1
    if y<=LL[i][1]:
        print(x+LL[i][0]*y)
        break
    else:
        y-=LL[i][1]
        x+=LL[i][1]*LL[i][0]

Buggy python submission (verdict: Time Limit Exceeded):
b=list(map(int,input().split()))
L=[]
l=[]
LL=[]
for i in range(b[0]):
    LL.append(list(map(int,input().split())))
LL.sort(key=lambda x: x[0])
L=[LL[i][0] for i in range(b[0])]
l=[LL[i][1] for i in range(b[0])]
x=0
z=0
y=b[1]
while y>=0 and not L==[]:
    if L==[]:
        print(x-y*(-1)*w)
        z=1
        break
    else:
        y-=l[0]
        x+=l[0]*L[0]
        z=l[0]*L[0]
        w=L[0]
        l=l[1:]
        L=L[1:]
print(x-y*(-1)*w)

Fixed submission:
b=list(map(int,input().split()))
LL=[]
for i in range(b[0]):
    LL.append(list(map(int,input().split())))
LL.sort()
x=0
z=0
y=b[1]
i=-1
while y>=0 and not LL==[]:
    i+=1
    if y<=LL[i][1]:
        print(x+LL[i][0]*y)
        break
    else:
        y-=LL[i][1]
        x+=LL[i][1]*LL[i][0]

Buggy python submission (verdict: Time Limit Exceeded):
b=list(map(int,input().split()))
L=[]
l=[]
for i in range(b[0]):
    q=list(map(int,input().split()))           
    L.append(q[0])
    l.append(q[1])
x=0
z=0
y=b[1]    
while y>=0 and not L==[]:
    if L==[]:
        print(x-y*(-1)*w)
        z=1
        break
    else:
        a=L.index(min(L))
        y-=l[a]
        x+=l[a]*L[a]
        z=l[a]*L[a]
        w=L[a]
        l=l[:a]+l[a+1:]
        L=L[:a]+L[a+1:]
print(x-y*(-1)*w)

Fixed submission:
b=list(map(int,input().split()))
LL=[]
for i in range(b[0]):
    LL.append(list(map(int,input().split())))
LL.sort()
x=0
z=0
y=b[1]
i=-1
while y>=0 and not LL==[]:
    i+=1
    if y<=LL[i][1]:
        print(x+LL[i][0]*y)
        break
    else:
        y-=LL[i][1]
        x+=LL[i][1]*LL[i][0]
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
a=0
b=[s[0]]
for i in range(1,len(s)):
    if b==[]:
        b.append(s[i])
    elif not b[-1]==s[i]:
        a+=2
        b=b[:(len(b)-1)]
    else:
        b.append(s[i])
print(a)

Fixed submission:
s=input()
a=0
b=0
c=0
for i in range(len(s)):
    if c==0:
        b=s[i]
        c+=1
    elif not b==s[i]:
        a+=2
        c-=1
    else:
        b=s[i]
        c+=1
print(a)
Buggy python submission (verdict: Runtime Error):
import math
a=int(input())
A=list(map(int,input().split()))
x=0
for i in range(a):
    x=math.gcd(x,A[i])
print(x)

Fixed submission:
import fractions
a=int(input())
A=list(map(int,input().split()))
x=0
for i in range(a):
    x=fractions.gcd(x,A[i])
print(x)
Buggy python submission (verdict: Runtime Error):
a,b=input().split()
c,d=int(a),int(b)
l=[int(input()) for i in range(c)]
L=sorted(l)
x=L[d]-L[0]
for i in range(c-d+1):
    if L[d+i]-L[i]<x:
        x=L[d+i]-L[i]
print(x)

Fixed submission:
a,b=input().split()
c,d=int(a),int(b)
l=[int(input()) for i in range(c)]
L=sorted(l)
x=L[d-1]-L[0]
for i in range(c-d+1):
    if L[d+i-1]-L[i]<x:
        x=L[d+i-1]-L[i]
print(x)

Buggy python submission (verdict: Time Limit Exceeded):
a,b=input().split()
c,d=int(a),int(b)
l=[int(input()) for i in range(c)]
L=sorted(l)
x=max(L[:d])-min(L[:d])
for i in range(c-d+1):
    if max(L[i:i+d])-min(L[i:i+d])<x:
        x=max(L[i:i+d])-min(L[i:i+d])
print(x)

Fixed submission:
a,b=input().split()
c,d=int(a),int(b)
l=[int(input()) for i in range(c)]
L=sorted(l)
x=L[d-1]-L[0]
for i in range(c-d+1):
    if L[d+i-1]-L[i]<x:
        x=L[d+i-1]-L[i]
print(x)
Buggy python submission (verdict: Runtime Error):
a=input()
x=abs(int(a[0])*100+int(a[1])*10+int(a[2])-753)
for i in range(i-2)
if abs(int(a[i])*100+int(a[i+1])*10+int(a[i+2])-753)<=x:
    x=abs(int(a[i])*100+int(a[i+1])*10+int(a[i+2])-753)

Fixed submission:
a=input()
x=abs(int(a[0])*100+int(a[1])*10+int(a[2])-753)
for i in range(len(a)-2):
    if abs(int(a[i])*100+int(a[i+1])*10+int(a[i+2])-753)<=x:
        x=abs(int(a[i])*100+int(a[i+1])*10+int(a[i+2])-753)
print(x)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
L=[[] for i in range(a)]
u=0
# i番目の県の情報（[i，年，入力順]）をLのi番目に入れる
for i in range(b):
    u+=1
    c=list(map(int,input().split()))
    c.append(u)
    L[int(c[0])-1].append(c)
# Lの要素を年でソート
for i in L:
    i.sort(key=lambda x:x[1])
#　ソートしたので、要素ごとに何番目にできたかを末尾に付け加えておく
for i in L:
    e=0
    for j in i:
        e+=1
        j.append(e)
q=[]
for w in L:
   q.extend(w) #flatten
q.sort(key=lambda x:x[2])　#入力順に並べ替えて、入力した順に出力できるようにする
for r in range(b):
        print(str(q[r][0]).zfill(6)+str(q[r][3]).zfill(6))　#zfill

Fixed submission:
a,b=map(int,input().split())
L=[[] for i in range(a)]
u=0
for i in range(b):
    u+=1
    c=list(map(int,input().split()))
    c.append(u)
    L[int(c[0])-1].append(c)
for i in L:
    i.sort(key=lambda x:x[1])
for i in L:
    e=0
    for j in i:
        e+=1
        j.append(e)
q=[]
for w in L:
   q.extend(w) 
q.sort(key=lambda x:x[2])
for r in range(b):
        print('0'*(6-len(str(q[r][0])))+str(q[r][0])+'0'*(6-len(str(q[r][3])))+str(q[r][3]))

Buggy python submission (verdict: Time Limit Exceeded):
a,b=map(int,input().split())
L=[]
l=[]
ll=[]
u=0
for i in range(b):
    u+=1
    c=list(map(int,input().split()))
    c.append(u)
    L.append(c)
L.sort(key=lambda x:x[0])
for i in range(1,a+1):
    lll=[]
    for j in L:
        if j[0]==i:
            lll.append(j)
    ll.append(lll)
for i in ll:
    i.sort(key=lambda x:x[1])
for i in ll:
    e=0
    for j in i:
        e+=1
        j.append(e)
q=[]
for w in ll:
   q.extend(w) 
q.sort(key=lambda x:x[2])
for r in range(b):
        print('0'*(6-len(str(q[r][0])))+str(q[r][0])+'0'*(6-len(str(q[r][3])))+str(q[r][3]))

Fixed submission:
a,b=map(int,input().split())
L=[[] for i in range(a)]
u=0
for i in range(b):
    u+=1
    c=list(map(int,input().split()))
    c.append(u)
    L[int(c[0])-1].append(c)
for i in L:
    i.sort(key=lambda x:x[1])
for i in L:
    e=0
    for j in i:
        e+=1
        j.append(e)
q=[]
for w in L:
   q.extend(w) 
q.sort(key=lambda x:x[2])
for r in range(b):
        print('0'*(6-len(str(q[r][0])))+str(q[r][0])+'0'*(6-len(str(q[r][3])))+str(q[r][3]))

Buggy python submission (verdict: Time Limit Exceeded):
a,b=map(int,input().split())
L=[]
l=[]
for i in range(b):
    L.append(list(map(int,input().split())))
for i in range(b):
    x=0
    for j in range(b):
        if not j==i and L[i][0]==L[j][0] and L[i][1]>L[j][1]:
            x+=1
    l.append('0'*(6-len(str(L[i][0])))+str(L[i][0])+'0'*(6-len(str(x+1)))+str(x+1))
for r in range(b):
        print(l[r])

Fixed submission:
a,b=map(int,input().split())
L=[[] for i in range(a)]
u=0
for i in range(b):
    u+=1
    c=list(map(int,input().split()))
    c.append(u)
    L[int(c[0])-1].append(c)
for i in L:
    i.sort(key=lambda x:x[1])
for i in L:
    e=0
    for j in i:
        e+=1
        j.append(e)
q=[]
for w in L:
   q.extend(w) 
q.sort(key=lambda x:x[2])
for r in range(b):
        print('0'*(6-len(str(q[r][0])))+str(q[r][0])+'0'*(6-len(str(q[r][3])))+str(q[r][3]))
Buggy python submission (verdict: Runtime Error):
from collections import Counter
# counter（l）.most_common()：リストについて出現回の多い順に（要素、要素数）で返す
a=int(input())
A=list(map(int,input().split()))
bx=[A[i] for i in range(a) if i%2==0]
cx=[A[i] for i in range(a) if i%2==1]
#　全部同じ数の時
if b==c and len(set(b))==1 and len(set(c))==1:
    print(a//2)
else:
    bc=Counter(b).most_common()
    cc=Counter(c).most_common()
    if bc[0][0]==cc[0][0]:
        print(a-max(bc[1][1]+cc[0][1],bc[0][1]+cc[1][1]))
    else: print(a-bc[0][1]-cc[0][1])    

Fixed submission:
from collections import Counter
a=int(input())
A=list(map(int,input().split()))
b=[A[i] for i in range(a) if i%2==0]
c=[A[i] for i in range(a) if i%2==1]
if b==c and len(set(b))==1 and len(set(c))==1:
    print(a//2)
else:
    bc=Counter(b).most_common()
    cc=Counter(c).most_common()
    if bc[0][0]==cc[0][0]:
        print(a-max(bc[1][1]+cc[0][1],bc[0][1]+cc[1][1]))
    else: print(a-bc[0][1]-cc[0][1])
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
t=input()
S=[0 for i in range(26)]
T=[0 for i in range(26)]
for i in range(len(s)):
    S[ord(s[i])-97]=int(str(S[ord(s[i])-97])+str(i))  
for i in range(len(t)):
    T[ord(t[i])-97]=int(str(T[ord(t[i])-97])+str(i))  
ss=sorted(S)
tt=sorted(T)
if ss==tt:
    print('Yes')
else:print('No')

Fixed submission:
#アルファベットの1対1置換が存在すればYes
S=input()
T=input()
#dは、アルファベットの置換、置換は辞書で書く
d={}
#Sを順にみていって、d内になかったらSのi番目とdのi番目が置換関係にある
for i in range(len(S)):
    if S[i] not in d:
        d[S[i]]=T[i] 
    else:
      #1対1の置換でないと判明したらNoを出力
        if d[S[i]]!=T[i]:
            print('No')
            exit()
d={}
for i in range(len(T)):
    if T[i] not in d:
        d[T[i]]=S[i]
    else:
        if d[T[i]]!=S[i]:
            print('No')
            exit()
print('Yes')

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
t=input()
S=[0 for i in range(26)]
T=[0 for i in range(26)]
for i in range(26):
    for j in range(len(s)):
        if s[j]==chr(i+97):
            S[i]=int(str(S[i])+str(j))
for i in range(26):
    for j in range(len(t)):
        if t[j]==chr(i+97):
            T[i]=int(str(T[i])+str(j))  
ss=sorted(S)
tt=sorted(T)
if ss==tt:
    print('Yes')
else:print('No')

Fixed submission:
#アルファベットの1対1置換が存在すればYes
S=input()
T=input()
#dは、アルファベットの置換、置換は辞書で書く
d={}
#Sを順にみていって、d内になかったらSのi番目とdのi番目が置換関係にある
for i in range(len(S)):
    if S[i] not in d:
        d[S[i]]=T[i] 
    else:
      #1対1の置換でないと判明したらNoを出力
        if d[S[i]]!=T[i]:
            print('No')
            exit()
d={}
for i in range(len(T)):
    if T[i] not in d:
        d[T[i]]=S[i]
    else:
        if d[T[i]]!=S[i]:
            print('No')
            exit()
print('Yes')

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
t=input()
S=[[] for i in range(len(s))]
T=[[] for i in range(len(t))]
c=0
d=0
for i in range(len(s)):
    if S[i]==[]:
        S[i]=[s.count(s[i])]
        c=s.count(s[i])
        for j in range(i,len(s)):
            if s[j]==s[i]:
                S[j]=[c]
for i in range(len(t)):
    if T[i]==[]:
        T[i]=[t.count(t[i])]
        d=t.count(t[i])
        for j in range(j,len(t)):
            if t[j]==t[i]:
                T[j]=[d]            
if S==T:
    print('Yes')
else:print('No')

Fixed submission:
#アルファベットの1対1置換が存在すればYes
S=input()
T=input()
#dは、アルファベットの置換、置換は辞書で書く
d={}
#Sを順にみていって、d内になかったらSのi番目とdのi番目が置換関係にある
for i in range(len(S)):
    if S[i] not in d:
        d[S[i]]=T[i] 
    else:
      #1対1の置換でないと判明したらNoを出力
        if d[S[i]]!=T[i]:
            print('No')
            exit()
d={}
for i in range(len(T)):
    if T[i] not in d:
        d[T[i]]=S[i]
    else:
        if d[T[i]]!=S[i]:
            print('No')
            exit()
print('Yes')