Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math

N,X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x.sort()

if N != 1:
    A = [0]*(N-1)
    for i in range(N-1):
        A[i] = x[i+1]-x[i]

    a = A[0]
    for i in range(N-1):
        a = math.gcd(a,A[i])
    print(a)
else:
    print(x[1]-x[0])

Fixed submission:
import fractions

N,X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x.sort()

if N != 1:
    A = [0]*N
    for i in range(N):
        A[i] = x[i+1]-x[i]
    a = A[0]
    for j in range(N):
        a = fractions.gcd(a,A[j])
    print(a)
else:
    print(x[1]-x[0])
Buggy python submission (verdict: Runtime Error):
k = int(input())
if k%2==1:
  print((k//2)*(k//2+1))
else:
  print(k//2)**2


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

Buggy python submission (verdict: Runtime Error):
k = int(input())
if k%2==1:
  print(k//2*(k//2+1))
else:
  print(k//2)**2


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

Buggy python submission (verdict: Runtime Error):
K = int(input())
if K%2 == 0:
  print(int((K/2)**2))
else:
  print(int((K-1)(K+1)/4))
  


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

Buggy python submission (verdict: Runtime Error):
K = int(input())
if K%2 == 0:
  print((K/2)**2)
else:
  print((K-1)(K+1)/4)
  

Fixed submission:
K = int(input())
if K%2 == 0:
  print(int((K/2)**2))
else:
  print(int((K-1)*(K+1)/4))
Buggy python submission (verdict: Runtime Error):
S = list(input())
cnt = 0

array = S[3:-1]
if array.count("C")==1:
  array.remove("C")
  S = S[:3]+array+S[-1]
else:
  cnt += 1

if S[0]=="A":
  del S[0]
else:
  cnt += 1

s = "".join(S)
if s.islower == False:
  cnt += 1
print("AC" if cnt==0 else "WA")


Fixed submission:
S = list(input())
ans = 0
for i in range(2,len(S)-1):
  if S[i] == "C":
    ans += 1
    S[i] = S[i].lower()
if S[0]=="A" and ans==1:
  S[0] = S[0].lower()
  s = ""
  for i in range(len(S)):
    s += S[i]
  if s.islower():
    print("AC")
  else:
    print("WA")
else:
  print("WA")

Buggy python submission (verdict: Runtime Error):
S = list(input("Enter :"))
ans = 0
C_location = 0
for i in range(2,len(S)-1):
  if S[i] == "C":
    ans += 1
	S[i].lower()
if all(S[0]=="A" and ans==1):
  S.swapcase(S[0])
  if S.islower():
	print("AC")
  else:
    print("WA")
else:
  print("WA")

Fixed submission:
S = list(input())
ans = 0
for i in range(2,len(S)-1):
  if S[i] == "C":
    ans += 1
    S[i] = S[i].lower()
if S[0]=="A" and ans==1:
  S[0] = S[0].lower()
  s = ""
  for i in range(len(S)):
    s += S[i]
  if s.islower():
    print("AC")
  else:
    print("WA")
else:
  print("WA")
Buggy python submission (verdict: Runtime Error):
N = input()
S = 0
for n in N:
  S += int(n)
N = int(N)
print("Yes" if N%S == 0 else "No")


Fixed submission:
S = input()
number = 0
for i in range(len(S)):
    if S[i] == "+":
        number += 1
    else:
        number -= 1
print(number)
Buggy python submission (verdict: Runtime Error):
N = input()
S = 0
for n in N:
  S += n
N = int(N)
print("Yes" if N%S == 0 else "No")


Fixed submission:
N = input()
mylist = []
for i in range(len(N)):
  mylist.append(N[i])
newlist = [int(s) for s in mylist]
divisor = 0
for j in range(len(newlist)):
  divisor += newlist[j]
N = int(N)
if N%divisor == 0:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
N = input()
S = 0
for n in N:
  S += n
N = int(N)
print("Yes" if N%S == 0 else "No")

Fixed submission:
N = input()
mylist = []
for i in range(len(N)):
  mylist.append(N[i])
newlist = [int(s) for s in mylist]
divisor = 0
for j in range(len(newlist)):
  divisor += newlist[j]
N = int(N)
if N%divisor == 0:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = [0]*N
for i in range(N):
  S[i] = input()
  
M = int(input())
T = [0]*M
for i in range(N):
  T[i] = input()

ans = 0
for i in range(N):
  x = S[i]
  cnt1 = S.count(x)
  cnt2 = T.count(x)
  ans = max(cnt1-cnt2,ans)
print(ans)

Fixed submission:
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]

ans = 0
for i in S:
  cnt1 = S.count(i)
  cnt2 = T.count(i)
  ans = max(cnt1-cnt2,ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
C=[]
for i in range(3):
  C += list(input())
print(C[0][0]+C[1][1]+C[2][2])

Fixed submission:
C=[]
for i in range(3):
  C.append(list(input()))
print(C[0][0]+C[1][1]+C[2][2])
Buggy python submission (verdict: Runtime Error):
date = [for n in input()]
date[3]="8"
date = "".join(date)
print(date)

Fixed submission:
S = list(map(str, input().split("/")))
S[0] = "2018"
s = "/".join(S)
print(s)

Buggy python submission (verdict: Runtime Error):
date = input()
date[3]=8
print(date)

Fixed submission:
S = list(map(str, input().split("/")))
S[0] = "2018"
s = "/".join(S)
print(s)
Buggy python submission (verdict: Runtime Error):
A = [map(int, input().split())]
if A[0]+A[1] > A[2]+A[3]:
  print("Left")
elif A[0]+A[1] < A[2]+A[3]:
  print("Right")
else:
  print("Balanced")

Fixed submission:
A = list(map(int, input().split()))
if A[0]+A[1] > A[2]+A[3]:
  print("Left")
elif A[0]+A[1] < A[2]+A[3]:
  print("Right")
else:
  print("Balanced")
Buggy python submission (verdict: Runtime Error):
s = input()
print(s.count('1'))

Fixed submission:
s = input()
print(s.count('1'))

Buggy python submission (verdict: Runtime Error):
y = list(input())
# y = [0,1,0]のようなリストになっているはず
x = 0
for i in range(0,2):
	if y[i] == 1:
      x += 1
    else:
      continue
print(x)


Fixed submission:
s = input()
print(s.count('1'))

Buggy python submission (verdict: Runtime Error):
y = list(input())
# y = [0,1,0]のようなリストになっているはず
x = 0
for i in range(0,2):
	if y[i] == 1:
      x += 1
print(x)

Fixed submission:
s = input()
print(s.count('1'))

Buggy python submission (verdict: Runtime Error):
y = list(input())
n = sum(y[i]=1 for i in y)
print(n)

Fixed submission:
s = input()
print(s.count('1'))
Buggy python submission (verdict: Runtime Error):
X,Y = map(str, input().split())
if hex(X)<hex(Y):
  print("<")
elif hex(X)>hex(Y):
  print(">")
else:
  print("=")


Fixed submission:
x,y = map(str, input().split())
if int(x,16) > int(y,16):
  print(">")
elif int(x,16) < int(y,16):
  print("<")
else:
  print("=")

Buggy python submission (verdict: Runtime Error):
X,Y = map(int, input().split())
if hex(X)<hex(Y):
  print("<")
elif hex(X)>hex(Y):
  print(">")
else:
  print("=")

Fixed submission:
x,y = map(str, input().split())
if int(x,16) > int(y,16):
  print(">")
elif int(x,16) < int(y,16):
  print("<")
else:
  print("=")
Buggy python submission (verdict: Runtime Error):
x = input()
y = input()
print("YES" if x=y[::-1] else "NO")

Fixed submission:
c1 = list(input())
c2 = list(input())

if c1==c2[::-1]:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
import math

def gcd3(a, b, c):
    temp = math.gcd(a, b)
    return math.gcd(temp, c)

n = int(input())
s = sum([gcd3(a, b, c) for a in range(1, n + 1) for b in range(1, n + 1) for c in range(1, n + 1)])
print(s)


Fixed submission:
import math

def gcd3(a, b, c):
    temp = math.gcd(a, b)
    return math.gcd(temp, c)

n = int(input())
s = sum([gcd3(a, b, c) for a in range(1, n + 1) for b in range(1, n + 1) for c in range(1, n + 1)])
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
import math
from decimal import *
A,B = list(map(int, input().split()))
ans = -1
for x in range(1, 50000):
    a = math.floor(x * Decimal(0.08))
    b = math.floor(x * Decimal(0.1))
    if a == A and b == B:
        ans = x
        break
print(ans)

Fixed submission:
import math
from decimal import *
A,B = list(map(int, input().split()))
ans = -1
for x in range(1, 10001):
    a = math.floor(x * Decimal(0.08))
    b = math.floor(x * Decimal(0.1))
    if a == A and b == B:
        ans = x
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
readline = sys.stdin.readline
N = int(readline())
L = list(map(int, readline().split()))

ans = 0

for i in range(N):
    for j in range(N):
        if i == j:
            continue
        for k in range(N):
            if i == k or j == k:
                continue
            if (L[i] < L[j] + L[k]) and (L[j] < L[k] + L[i]) and (L[k] < L[i] + L[j]):
                ans += 1

print(ans//6)

Fixed submission:
import sys
import bisect
readline = sys.stdin.readline
N = int(readline())
L = list(map(int, readline().split()))
L.sort()

ans = 0
for i in range(N):
    for j in range(i, N):
        if i == j: continue
        ab = L[i] + L[j]
        to = bisect.bisect_left(L, ab, j, N)
        ans += to - 1 - j
print(ans)
Buggy python submission (verdict: Runtime Error):
# 2より大きい値段のものに高いものから順に割引券を振り分けていく
n,m = list(map(int, input().split()))
a = list(map(int, input().split()))
a = sorted(a, key=lambda x: -x)
coupon = [0 for i in range(n)]

v = 0
for i in range(n):
    if a[i] > 2:
        v += 1

i = 0
while m > 0 and v > 0:
    if len(a) == 1:
        coupon[i] = m
        break
    if a[i] > 2:
        l = a[i] // 2**(coupon[i]+1)
        if l >= 0:
            coupon[i] += 1
            if l == 0:
                v -= 1
        m -= 1
        i += 1
    elif a[i] <= 2 and m > 0:
        i = 0

total = 0
for i in range(n):
    if a[i] < 3 and m > 0:
      total += a[i] // 2
      m -= 1
    else:
      total += a[i] // 2**coupon[i]

print(total)

Fixed submission:
import heapq
n,m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = []
for i in range(n):
    heapq.heappush(b, a[i] * (-1))

while m > 0:
    bb = ((heapq.heappop(b) * (-1)) // 2) * (-1)
    heapq.heappush(b, bb)
    m -= 1

total = 0
for i in range(n):
    total += b[i] * -1

print(total)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
m = 0
for i in range(1, N):
    m += i % (i+1)
print(m)

Fixed submission:
from decimal import Decimal
N = int(input())
print(Decimal(N * (N - 1) // 2))
Buggy python submission (verdict: Runtime Error):
from math import factorial

N = int(input())
s = {}
h = {'a': 2, 'b': 3, 'c': 5, 'd': 7, 'e':11, 'f':13, 'g':17,'h':19,'i':23,'j':29,'k':31,'l':37,'m':41,'n':43,'o':47,'p':53,'q':59,'r':61,'s':67,'t':71,'u':73,'v':79,'w':83,'x':89,'y':97,'z':101}
for i in range(N):
    total = 1
    chs = list(input())
    for j in range(10):
        total *= h[chs[j]]
    s[total] = s.get(total, 0) + 1

cnt = 0
for v in s.values():
    if v < 2: continue
    a = factorial(v) / factorial(2) / factorial(v - 2)
    cnt += a

print(int(cnt))

Fixed submission:
def cmb(n, r):
  if n - r < r: r = n - r
  if r == 0: return 1
  if r == 1: return n

  numerator = [n - r + k + 1 for k in range(r)]
  denominator = [k + 1 for k in range(r)]

  for p in range(2,r+1):
      pivot = denominator[p - 1]
      if pivot > 1:
          offset = (n - r) % p
          for k in range(p-1,r,p):
              numerator[k - offset] /= pivot
              denominator[k] /= pivot

  result = 1
  for k in range(r):
      if numerator[k] > 1:
          result *= int(numerator[k])

  return result

N = int(input())
s = {}
h = {'a': 2, 'b': 3, 'c': 5, 'd': 7, 'e':11, 'f':13, 'g':17,'h':19,'i':23,'j':29,'k':31,'l':37,'m':41,'n':43,'o':47,'p':53,'q':59,'r':61,'s':67,'t':71,'u':73,'v':79,'w':83,'x':89,'y':97,'z':101}
for i in range(N):
    total = 1
    chs = list(input())
    for j in range(10):
        total *= h[chs[j]]
    s[total] = s.get(total, 0) + 1

cnt = 0
for v in s.values():
    if v < 2: continue
    a = cmb(v, 2)
    cnt += a

print(int(cnt))
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N, M = list(map(int, input().split()))
tasks = []
for i in range(N):
    tasks.append(list(map(int, input().split())))

reward = []
heapq.heapify(reward)

total = 0
for i in range(M)[::-1]:
    for j in range(len(reward), N):
        if tasks[j][0] == M - i:
            heapq.heappush(reward, -1 * tasks[j][1])

    if len(reward) > 0:
        total += heapq.heappop(reward) * (-1)

print(total)

Fixed submission:
import heapq
N, M = list(map(int, input().split()))
days = [[] for _ in range(M + 1)]
for i in range(N):
    a, b = list(map(int, input().split()))
    if a > M: continue
    days[a].append(b)

reward = []
heapq.heapify(reward)

total = 0
for i in range(M)[::-1]:
    tasks = days[M - i]
    for task in tasks:
        heapq.heappush(reward, -1 * task)

    if len(reward) > 0:
        total += heapq.heappop(reward) * (-1)

print(total)

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N, M = list(map(int, input().split()))
tasks = []
for i in range(N):
    tasks.append(list(map(int, input().split())))

reward = []
heapq.heapify(reward)

total = 0
for i in range(M)[::-1]:
    for j in range(N):
        if tasks[j][0] == M - i:
            heapq.heappush(reward, -1 * tasks[j][1])
    if len(reward) > 0:
        total += heapq.heappop(reward) * (-1)

print(total)

Fixed submission:
import heapq
N, M = list(map(int, input().split()))
days = [[] for _ in range(M + 1)]
for i in range(N):
    a, b = list(map(int, input().split()))
    if a > M: continue
    days[a].append(b)

reward = []
heapq.heapify(reward)

total = 0
for i in range(M)[::-1]:
    tasks = days[M - i]
    for task in tasks:
        heapq.heappush(reward, -1 * task)

    if len(reward) > 0:
        total += heapq.heappop(reward) * (-1)

print(total)
Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
sl = len(S)
dp = [[0] * 13 for _ in range(sl+1)]
dp[0][0] = 1

c = ''
for i in range(sl):
    if S[i] == '?':
        c = -1
    else:
        c = int(S[i])
    for j in range(10):
        if c != -1 and c != j:
            continue
        for ki in range(13):
            dp[i + 1][(ki * 10 + j) % 13] += dp[i][ki] 

print(dp[-1][5] % (10**9 + 7))

Fixed submission:
S = str(input())
ans = [0] * 13
ans[0] = 1
MOD = 10**9 + 7
for i in S:
    dp = [0] * 13
    for j in range(13):
        dp[(j * 10) % 13] = ans[j] % MOD
    dp += dp
    if i == '?':
        for j in range(13):
            ans[j] = sum(dp[j+4:j+14])
    else:
        for j in range(13):
            ans[j] = dp[j + 13 - int(i)]
print(ans[5] % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
nums = []
for i in range(N):
    nums.append(int(input()))

maxinum = max(nums)
for i in range(N):
    if nums[i] == maxinum:
        print(max(nums[0:i] + nums[i+1:]))
    else:
        print(maxinum)

Fixed submission:
N = int(input())
nums = []
for i in range(N):
    nums.append(int(input()))

maxinum = max(nums)
maxinum2 = -1
for i in range(N):
    if nums[i] == maxinum:
        if maxinum2 == -1:
            maxinum2 = max(nums[0:i] + nums[i+1:])
        print(maxinum2)
    else:
        print(maxinum)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
nums = []
for i in range(N):
    nums.append(int(input()))

for i in range(N):
    print(max(nums[0:i] + nums[i+1:]))

Fixed submission:
N = int(input())
nums = []
for i in range(N):
    nums.append(int(input()))

maxinum = max(nums)
maxinum2 = -1
for i in range(N):
    if nums[i] == maxinum:
        if maxinum2 == -1:
            maxinum2 = max(nums[0:i] + nums[i+1:])
        print(maxinum2)
    else:
        print(maxinum)
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())
mn = 0
res = 2*(10**9)
for i in range(L, R + 1):
    for j in range(L, R + 1):
        if i == j: continue
        mn = (i * j) % 2019
        if mn < res:
            res = mn
print(res)

Fixed submission:
L, R = map(int, input().split())

res = 2 * (10 ** 9)
if R - L > 2019:
	print(0)
else:
	for i in range(L, R + 1):
		for j in range(i + 1, R + 1):
			mod = (i * j) % 2019
			if mod < res: res = mod
	print(res)
Buggy python submission (verdict: Runtime Error):
import math
A,B,C,D = list(map(int, input().split()))

cd = int((C * D) / math.gcd(C, D))

bc = B // C
bd = B // D
bcd = B // cd
ac = (A - 1) // C
ad = (A - 1) // D
acd = (A - 1) // cd

bdiv = bc + bd - bcd
adiv = ac + ad - acd

alldiv = bdiv - adiv

ans = B - A + 1 - alldiv

print(int(ans))

Fixed submission:
# (A ~ B までの個数) - (Cで割り切れるもの + Dで割り切れるもの - CDの最小公倍数で割り切れるもの)
A,B,C,D = list(map(int, input().split()))

def euc(a, b):
    a, b = [max(a, b), min(a, b)]
    if b == 0:
        return a
    else:
        return euc(b, a % b)

Cdiv = (B // C) - ((A-1) // C)
Ddiv = (B // D) - ((A-1) // D)
E = (C * D) // euc(C, D)
CDdiv = (B // E) - ((A-1) // E)

print((B - A + 1) - (Cdiv + Ddiv - CDdiv))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
readline = sys.stdin.readline

n, m = list(map(int, readline().split()))
a = sorted(list(map(int, readline().split())))
bc = []
for _ in range(m):
    b, c = list(map(int, readline().split()))
    for _ in range(b):
        bc.append(c)
bc.sort(key=lambda x: -x)
dbc = deque(bc)
for i in range(n):
    if len(dbc) > 0 and a[i] < dbc[0]:
        a[i] = dbc.popleft()

print(sum(a))

Fixed submission:
import sys
from collections import deque
readline = sys.stdin.readline

n, m = list(map(int, readline().split()))
a = sorted(list(map(int, readline().split())))
bc = []
for _ in range(m):
    b, c = list(map(int, readline().split()))
    bc.append([b * c, c])
bc.sort(key=lambda x: -x[1])
dbc = deque(bc)
for i in range(n):
    if len(dbc) > 0 and a[i] < dbc[0][1]:
        a[i] = dbc[0][1]
        dbc[0][0] -= dbc[0][1]
        if dbc[0][0] == 0:
            dbc.popleft()

print(sum(a))
Buggy python submission (verdict: Runtime Error):
import math
import functools
n = int(input())
*a, = map(int, input().split())

left = [0]*(n+1)
for i in range(n):
    left[i+1] = math.gcd(left[i], a[i])
right = [0]*(n+1)
for i in range(n-1, -1, -1):
    right[i] = math.gcd(right[i+1], a[i])

ans = 0
for i in range(n):
    ans = max(math.gcd(left[i], right[i+1]), ans)

print(ans)


Fixed submission:
def gcd(a, b):
  a, b = [max(a,b), min(a,b)]
  if b == 0:
      return a
  else:
      return gcd(b, a % b)

n = int(input())
a = list(map(int, input().split()))

left = [0]*(n+1)
for i in range(n):
    left[i+1] = gcd(left[i], a[i])
right = [0]*(n+1)

for i in range(n-1, -1, -1):
    right[i] = gcd(right[i+1], a[i])

ans = 0
for i in range(n):
    ans = max(gcd(left[i], right[i+1]), ans)

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

N, Q = list(map(int, readline().split()))
S = list(readline())
lr = []
for i in range(Q):
    l, r = list(map(int, readline().split()))
    lr.append([l-1, r])

ac = 0
acs = [0 for i in range(N)]
for i in range(N):
    if S[i] == 'A' and ac == 0:
        ac += 1
    elif S[i] == 'C' and ac == 1:
        acs[i - 1] = 1
        ac = 0
    else:
        ac = 0

for i in range(Q):
    l, r = lr[i]
    print(acs[l:r-1].count(1))

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

N, Q = map(int, readline().split())
S = readline()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, readline().split())
    print(t[r-1] - t[l-1])
Buggy python submission (verdict: Runtime Error):
import sys
readline = sys.stdin.readline
n,m = list(map(int, readline().split()))
py = []
for _ in range(m):
    py.append(list(map(int, readline().split())))

spy = sorted(py, key=lambda x: x[1])
M = len(spy)

Y = {}
for i in range(M):
    Y[spy[i][1]] = 0

P = [0 for _ in range(M+1)]

for i in range(M):
    P[spy[i][0]] += 1
    Y[spy[i][1]] = P[spy[i][0]]

for i in range(m):
    print(str(py[i][0]).zfill(6) + str(Y[py[i][1]]).zfill(6))

Fixed submission:
import sys
readline = sys.stdin.readline
n,m = list(map(int, readline().split()))
py = []
for _ in range(m):
    py.append(list(map(int, readline().split())))

spy = sorted(py, key=lambda x: x[1])

Y = {}
for i in range(m):
    Y[spy[i][1]] = 0

P = [0 for _ in range(n+1)]

for i in range(m):
    P[spy[i][0]] += 1
    Y[spy[i][1]] = P[spy[i][0]]

for i in range(m):
    print(str(py[i][0]).zfill(6) + str(Y[py[i][1]]).zfill(6))

Buggy python submission (verdict: Runtime Error):
import sys
readline = sys.stdin.readline
n,m = list(map(int, readline().split()))
py = []
for _ in range(m):
    py.append(list(map(int, readline().split())))

spy = sorted(py, key=lambda x: x[1])

Y = {}
for i in range(m):
    Y[spy[i][1]] = 0

P = [0 for _ in range(m+1)]

for i in range(m):
    P[spy[i][0]] += 1
    Y[spy[i][1]] = P[spy[i][0]]

for i in range(m):
    print(str(py[i][0]).zfill(6) + str(Y[py[i][1]]).zfill(6))

Fixed submission:
import sys
readline = sys.stdin.readline
n,m = list(map(int, readline().split()))
py = []
for _ in range(m):
    py.append(list(map(int, readline().split())))

spy = sorted(py, key=lambda x: x[1])

Y = {}
for i in range(m):
    Y[spy[i][1]] = 0

P = [0 for _ in range(n+1)]

for i in range(m):
    P[spy[i][0]] += 1
    Y[spy[i][1]] = P[spy[i][0]]

for i in range(m):
    print(str(py[i][0]).zfill(6) + str(Y[py[i][1]]).zfill(6))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
readline = sys.stdin.readline
N = int(readline())
X = [int(x) for x in readline().split()]
sX = sorted(X)
h = {}
for i in range(len(sX)):
    h[sX[i]] = i
for i in range(N):
    p = h[X[i]]
    lr = sX[:p] + sX[p+1:]
    print(lr[len(lr) // 2])

Fixed submission:
# O(N * log(Xn))
from bisect import bisect_left
import sys
readline = sys.stdin.readline
N = int(readline())
X = [int(x) for x in readline().split()]

# X = [i for i in range(2*10**5)]
# N = len(X)

sX = sorted(X)
m = (N - 1) // 2
for i in range(N):
    p = bisect_left(sX, X[i])
    if p <= m:
        print(sX[m + 1])
    else:
        print(sX[m])

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left
import sys
readline = sys.stdin.readline
N = int(readline())
X = [int(x) for x in readline().split()]
sX = sorted(X)
for i in range(N):
    p = bisect_left(sX, X[i])
    lr = sX[:p] + sX[p+1:]
    print(lr[len(lr) // 2])

Fixed submission:
# O(N * log(Xn))
from bisect import bisect_left
import sys
readline = sys.stdin.readline
N = int(readline())
X = [int(x) for x in readline().split()]

# X = [i for i in range(2*10**5)]
# N = len(X)

sX = sorted(X)
m = (N - 1) // 2
for i in range(N):
    p = bisect_left(sX, X[i])
    if p <= m:
        print(sX[m + 1])
    else:
        print(sX[m])

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left
import sys
readline = sys.stdin.readline
N = int(readline())
X = [int(x) for x in readline().split()]
sX = sorted(X)
for i in range(N):
    p = bisect_left(sX, X[i])
    lr = sX[:p] + sX[p+1:]
    print(lr[len(lr) // 2])

Fixed submission:
# O(N * log(Xn))
from bisect import bisect_left
import sys
readline = sys.stdin.readline
N = int(readline())
X = [int(x) for x in readline().split()]

# X = [i for i in range(2*10**5)]
# N = len(X)

sX = sorted(X)
m = (N - 1) // 2
for i in range(N):
    p = bisect_left(sX, X[i])
    if p <= m:
        print(sX[m + 1])
    else:
        print(sX[m])

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left
N = int(input())
X = list(map(int, input().split()))

sX = sorted(X)

for i in range(N):
    p = bisect_left(sX, X[i])
    lr = sX[:p] + sX[p+1:]
    print(lr[len(lr) // 2])

Fixed submission:
# O(N * log(Xn))
from bisect import bisect_left
import sys
readline = sys.stdin.readline
N = int(readline())
X = [int(x) for x in readline().split()]

# X = [i for i in range(2*10**5)]
# N = len(X)

sX = sorted(X)
m = (N - 1) // 2
for i in range(N):
    p = bisect_left(sX, X[i])
    if p <= m:
        print(sX[m + 1])
    else:
        print(sX[m])