Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(map(int, input()))

used_i = [False] * 10
ans = []
for i in range(n - 2):
    if not used_i[s[i]]:
        used_j = [False] * 10
        for j in range(i + 1, n - 1):
            if not used_j[s[j]]:
                for k in set(s[j + 1 : n]):
                    pin = f"{s[i]}{s[j]}{k}"
                    if pin not in ans:
                        ans.append(pin)
print(len(ans))

Fixed submission:
n = int(input())
s = list(map(int, input()))

ans = []

for i in range(10):
    if i in s:
        a = s.index(i)
        for j in range(10):
            if j in s[a + 1 :]:
                b = [x for x, y in enumerate(s) if x > a and y == j][0]
                for k in range(10):
                    if k in s[b + 1 :]:
                        ans.append(f"{i}{j}{k}")
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(map(int, input()))

used = [False] * 10
pins = []

for i in range(n - 2):
    if not used[s[i]]:
        used[s[i]] = True
        for j in range(i + 1, n - 1):
            for k in range(j + 1, n):
                pin = f"{s[i]}{s[j]}{s[k]}"
                if pin not in pins:
                    pins.append(pin)
print(len(pins))

Fixed submission:
n = int(input())
s = list(map(int, input()))

ans = []

for i in range(10):
    if i in s:
        a = s.index(i)
        for j in range(10):
            if j in s[a + 1 :]:
                b = [x for x, y in enumerate(s) if x > a and y == j][0]
                for k in range(10):
                    if k in s[b + 1 :]:
                        ans.append(f"{i}{j}{k}")
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())
s = [int(x) for x in input()]

print(len(set(itertools.combinations(s, 3))))

Fixed submission:
n = int(input())
s = list(map(int, input()))

ans = []

for i in range(10):
    if i in s:
        a = s.index(i)
        for j in range(10):
            if j in s[a + 1 :]:
                b = [x for x, y in enumerate(s) if x > a and y == j][0]
                for k in range(10):
                    if k in s[b + 1 :]:
                        ans.append(f"{i}{j}{k}")
print(len(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

ans = 0
for i in range(N):
    ans = ans + i

print(ans)

Fixed submission:
N = int(input())

ans = N * (N - 1) // 2

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter

n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(m)]
bc.sort(key=itemgetter(1), reverse=True)

changed = []

for b, c in bc:
    changed = changed + [c] * b
    if len(changed) > n:
        break

a = a + changed
a.sort(reverse=True)
ans = sum(a[:n])

print(ans)

Fixed submission:
import heapq

n, m = map(int, input().split())
a = list(map(int, input().split()))
heapq.heapify(a)
bc = sorted(
    [list(map(int, input().split())) for _ in range(m)],
    reverse=True,
    key=lambda x: x[1],
)

for i in bc:
    b, c = i
    for _ in range(b):
        mn = heapq.heappop(a)
        if mn < c:
            heapq.heappush(a, c)
        else:
            heapq.heappush(a, mn)
            break

print(sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
import heapq

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

for _ in range(m):
    b, c = map(int, input().split())
    for __ in range(b):
        mn = heapq.heappop(a)
        if mn < c:
            heapq.heappush(a, c)
        else:
            heapq.heappush(a, mn)
            break

print(sum(a))

Fixed submission:
import heapq

n, m = map(int, input().split())
a = list(map(int, input().split()))
heapq.heapify(a)
bc = sorted(
    [list(map(int, input().split())) for _ in range(m)],
    reverse=True,
    key=lambda x: x[1],
)

for i in bc:
    b, c = i
    for _ in range(b):
        mn = heapq.heappop(a)
        if mn < c:
            heapq.heappush(a, c)
        else:
            heapq.heappush(a, mn)
            break

print(sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
import heapq

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

for _ in range(m):
    b, c = map(int, input().split())
    for __ in range(b):
        mn = heapq.heappop(a)
        if mn < c:
            heapq.heappush(a, c)
        else:
            heapq.heappush(a, mn)
            break

print(sum(a))

Fixed submission:
import heapq

n, m = map(int, input().split())
a = list(map(int, input().split()))
heapq.heapify(a)
bc = sorted(
    [list(map(int, input().split())) for _ in range(m)],
    reverse=True,
    key=lambda x: x[1],
)

for i in bc:
    b, c = i
    for _ in range(b):
        mn = heapq.heappop(a)
        if mn < c:
            heapq.heappush(a, c)
        else:
            heapq.heappush(a, mn)
            break

print(sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque


def main():
    n, m = map(int, sys.stdin.readline().split())

    to = [[] for _ in range(n + 1)]
    a_set = {x for x in range(1, n + 1)}
    b_set = set()
    for _ in range(n - 1 + m):
        a, b = map(int, sys.stdin.readline().split())
        to[a].append(b)
        b_set.add(b)
    root = (a_set - b_set).pop()
    dist = [0] * (n + 1)
    pre = [0] * (n + 1)
    que = deque([])
    que.append(root)

    while que:
        p = que.popleft()
        for i in to[p]:
            if dist[i] < dist[p] + 1:
                dist[i] = dist[p] + 1
                pre[i] = p
                que.append(i)

    for i in range(1, n + 1):
        print(pre[i])


if __name__ == "__main__":
    main()

Fixed submission:
import sys
from collections import deque


def main():
    n, m = map(int, sys.stdin.readline().split())

    out_list = [[] for _ in range(n + 1)]
    in_cnt = [0] * (n + 1)
    in_cnt[0] = -1
    for _ in range(n - 1 + m):
        a, b = map(int, sys.stdin.readline().split())
        out_list[a].append(b)
        in_cnt[b] = in_cnt[b] + 1
    root = in_cnt.index(0)
    ans = [0] * (n + 1)
    que = deque([])
    que.append(root)

    while que:
        p = que.popleft()
        for i in out_list[p]:
            in_cnt[i] = in_cnt[i] - 1
            if in_cnt[i] == 0:
                que.append(i)
                ans[i] = p

    for i in ans[1:]:
        print(i)


if __name__ == "__main__":
    main()

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


def main():
    n, m = map(int, sys.stdin.readline().split())

    to = [[] for _ in range(n + 1)]
    a_set = {x for x in range(1, n + 1)}
    b_set = set()
    for _ in range(n - 1 + m):
        a, b = map(int, sys.stdin.readline().split())
        to[a].append(b)
        b_set.add(b)
    root = (a_set - b_set).pop()
    dist = [0] * (n + 1)
    pre = [0] * (n + 1)
    que = deque([])
    que.append(root)

    while que:
        p = que.popleft()
        for i in to[p]:
            if dist[i] < dist[p] + 1:
                dist[i] = dist[p] + 1
                pre[i] = p
                que.append(i)

    for i in range(1, n + 1):
        print(pre[i])


if __name__ == "__main__":
    main()

Fixed submission:
import sys
from collections import deque


def main():
    n, m = map(int, sys.stdin.readline().split())

    out_list = [[] for _ in range(n + 1)]
    in_cnt = [0] * (n + 1)
    in_cnt[0] = -1
    for _ in range(n - 1 + m):
        a, b = map(int, sys.stdin.readline().split())
        out_list[a].append(b)
        in_cnt[b] = in_cnt[b] + 1
    root = in_cnt.index(0)
    ans = [0] * (n + 1)
    que = deque([])
    que.append(root)

    while que:
        p = que.popleft()
        for i in out_list[p]:
            in_cnt[i] = in_cnt[i] - 1
            if in_cnt[i] == 0:
                que.append(i)
                ans[i] = p

    for i in ans[1:]:
        print(i)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

h = len(b)
w = len(b[0])

for i in range(h):
    for j in range(w):
        tmp = []
        for k in range(h):
            tmp.append(a[i + k][j : j + w])
        if b == tmp:
            print("Yes")
            break
    else:
        continue
    break
else:
    print("No")

Fixed submission:
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

ah = len(a)
aw = len(a[0])
bh = len(b)
bw = len(b[0])

for i in range(ah - bh + 1):
    for j in range(aw - bw + 1):
        tmp = []
        for k in range(bh):
            tmp.append(a[i + k][j : j + bw])
        if b == tmp:
            print("Yes")
            break
    else:
        continue
    break
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = map(int, input().split())
s = input()

ans = ["No"] * n
foreigner = 0

for i in range(n):
    if s[i] == "a":
        ans[i] = "Yes"
    elif s[i] == "b" and foreigner < b:
        ans[i] = "Yes"
        foreigner += 1
    if ans.count("Yes") == a + b:
        break

for i in ans:
    print(i)

Fixed submission:
n, a, b = map(int, input().split())
s = input()

success = 0
foreigner = 0
count = 0

for i in s:
    if i == "a":
        print("Yes")
        success += 1
    elif i == "b" and foreigner < b:
        print("Yes")
        success += 1
        foreigner += 1
    else:
        print("No")
    count += 1
    if success == a + b:
        break

for _ in range(n - count):
    print("No")
Buggy python submission (verdict: Runtime Error):
iroha = list(int(input()))

ans = [[5, 5, 7], [5, 7, 5], [7, 5, 5]]

if iroha in ans:
  print("YES")
else:
  print("NO")

Fixed submission:
iroha_list = list(map(int, input().split()))
iroha_set = set(iroha_list)

if sum(iroha_list) != 17:
    print("NO")
else:
    if iroha_set == {5, 7}:
        print("YES")
    else:
        print("NO")
Buggy python submission (verdict: Runtime Error):
t=input()
i=0
ans=0
for i in range(len(s)):
    if s[i]!=t[i]:
        ans+=1
print(ans)

Fixed submission:
s=input()
t=input()
i=0
ans=0
for i in range(len(s)):
    if s[i]!=t[i]:
        ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
a=[0];b=[0];ans=0;j=m
for i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i]+B[i])
for i in range(n+1):
    if a[i]>k:
        break
    while b[j]<k-a[i]:
        j-=1
ans=max(ans,i+j)
print(ans)

Fixed submission:
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
a=[0];b=[0];ans=0;j=m
for i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i]+B[i])
for i in range(n+1):
    if a[i]>k:
        break
    while b[j]>k-a[i]:
        j-=1
    ans=max(ans,i+j)
print(ans)

Buggy python submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
i=0
j=0
while k>=0:
    if i==n and j<m:
        k=k-b[j]
        j+=1
        ans+=1
    elif j==m and i<n:
        k=k-b[i]
        i+=1
        ans+=1
    elif i<n and j<m:
        if a[i]<b[j]:
            k=k-a[i]
            i+=1
            ans+=1
        else:
            k=k-b[j]
            j+=1
            ans+=1
    else:break
if k<0:
    print(ans-1)
else:
    print(ans)

Fixed submission:
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
a=[0];b=[0];ans=0;j=m
for i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i]+B[i])
for i in range(n+1):
    if a[i]>k:
        break
    while b[j]>k-a[i]:
        j-=1
    ans=max(ans,i+j)
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=sorted(list(map(int,input().split())))
ans=1
if 0 in A:
    print(0)
    return
for i in range(N):
    ans*=A[i]
    if ans>=10**18:
        print(-1)
        break
else:print(ans)

Fixed submission:
def main():
    N=int(input())
    A=sorted(list(map(int,input().split())))
    ans=1
    if 0 in A:
        print(0)
        return
    for i in range(N):
        ans*=A[i]
        if ans>10**18:
            print(-1)
            return
    print(ans)
main()
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if c-a-b<0:
    print('No')
else:
    if 4ab<(c-b-a)*(c-b-a):
        print('Yes')
    else:
        print('No')

Fixed submission:
a,b,c=map(int,input().split())
if c-a-b<0:
    print('No')
else:
    if 4*a*b<(c-b-a)*(c-b-a):
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if c-a-b<0:
    print('No')
else:
    if ab<(c-b-a)*(c-b-a):
        print('Yes')
    else:
        print('No')

Fixed submission:
a,b,c=map(int,input().split())
if c-a-b<0:
    print('No')
else:
    if 4*a*b<(c-b-a)*(c-b-a):
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if c-a-b<0:
    print('No')
else:
    if ab<(c-b-a)*(c-b-a)
        print('Yes')
    else:
        print('No')

Fixed submission:
a,b,c=map(int,input().split())
if c-a-b<0:
    print('No')
else:
    if 4*a*b<(c-b-a)*(c-b-a):
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().strip().split())

hh = list(map(int, input().strip().split()))

rrr = [[0 for j in range(n)] for i in range(n)]

for i in range(m):
  a, b = map(int, input().strip().split())
  rrr[a-1][b-1] = hh[b-1]
  rrr[b-1][a-1] = hh[a-1]

c = 0
for a in range(n):
  if all(hh[a] > h for h in rrr[a]):
    c += 1
    
print(c)

Fixed submission:
n, m = map(int, input().strip().split())

hh = list(map(int, input().strip().split()))

rr = [1] * n

for i in range(m):
  a, b = map(int, input().strip().split())
  if hh[a-1] <= hh[b-1]: 
    rr[a-1] = 0
  if hh[b-1] <= hh[a-1]:
    rr[b-1] = 0
    
print(sum(rr))
Buggy python submission (verdict: Time Limit Exceeded):
n, = map(int, input().strip().split())

# a5 - b5 = (a-b)(a4 + a3b + a2b2 + ab3 + b4)

def check(x):
  u = n//x+1
  for a in range(u+1):
    b = a - x
    if abs(b) > u:
      continue
    c = a**4 + a**3 * b + a**2 * b**2 + a * b**3 + b**4
    d = x * c
    if d == n:
      return [a, b]

    a += 1
  return None

for i in range(1, n+1):
  res = check(i)
  if res:
    break

r1, r2 = res
print(r1, r2)
    

Fixed submission:
n, = map(int, input().strip().split())

# a5 - b5 = (a-b)(a4 + a3b + a2b2 + ab3 + b4)

def check(x):
  for a in range(200):
    b = a - x
    c = a**4 + a**3 * b + a**2 * b**2 + a * b**3 + b**4
    d = x * c
    if d == n:
      return [a, b]
  return None

for i in range(1, n+1):
  res = check(i)
  if res:
    break

r1, r2 = res
print(r1, r2)

Buggy python submission (verdict: Time Limit Exceeded):
n, = map(int, input().strip().split())

# a5 - b5 = (a-b)(a4 + a3b + a2b2 + ab3 + b4)

def check(x):
  for a in range(n//x+1):
    b = a - x
    c = a**4 + a**3 * b + a**2 * b**2 + a * b**3 + b**4
    d = x * c
    if d == n:
      return [a, b]

    a += 1
  return None

for i in range(1, n+1):
  res = check(i)
  if res:
    break

r1, r2 = res
print(r1, r2)
    


Fixed submission:
n, = map(int, input().strip().split())

# a5 - b5 = (a-b)(a4 + a3b + a2b2 + ab3 + b4)

def check(x):
  for a in range(200):
    b = a - x
    c = a**4 + a**3 * b + a**2 * b**2 + a * b**3 + b**4
    d = x * c
    if d == n:
      return [a, b]
  return None

for i in range(1, n+1):
  res = check(i)
  if res:
    break

r1, r2 = res
print(r1, r2)

Buggy python submission (verdict: Time Limit Exceeded):
n, = map(int, input().strip().split())

# a5 - b5 = (a-b)(a4 + a3b + a2b2 + ab3 + b4)

def check(x):
  for a in range(n+1):
    b = a - x
    c = a**4 + a**3 * b + a**2 * b**2 + a * b**3 + b**4
    d = x * c 
    if d == n:
      return [a, b]

    a += 1
  return None

for i in range(1, n+1):
  res = check(i)
  if res:
    break

r1, r2 = res
print(r1, r2)

Fixed submission:
n, = map(int, input().strip().split())

# a5 - b5 = (a-b)(a4 + a3b + a2b2 + ab3 + b4)

def check(x):
  for a in range(200):
    b = a - x
    c = a**4 + a**3 * b + a**2 * b**2 + a * b**3 + b**4
    d = x * c
    if d == n:
      return [a, b]
  return None

for i in range(1, n+1):
  res = check(i)
  if res:
    break

r1, r2 = res
print(r1, r2)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
cnt = 1
for i in range(1,N):
  if S[i-1] != S[i]:
    cnt += 1

print(cnt)

Fixed submission:
A,B = map(int,input().split())
ans = A - B*2 if A -B*2 >0 else 0
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
cnt = 0
for i in range(1,N):
  if S[i-1] != S[i]:
    cnt += 1

print(cnt+1)

Fixed submission:
A,B = map(int,input().split())
ans = A - B*2 if A -B*2 >0 else 0
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)
for _ in range(M):
  A[0] //=2
  i = 1
  while i < N:
    if A[0] > A[i]:
      A[0:i-1],A[i-1] = A[1:i], A[0]
      break
    if i == N-1:
      A[0:N-1],A[N-1] = A[1:N],A[0]
    i +=1

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 _ in range(M):
  heapq.heappush(A,((heapq.heappop(A)*-1)//2)*-1)

print(sum(A)*-1)

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)
for _ in range(M):
  A[0] //=2
  i = 1
  while i < N:
    if A[0] > A[i]:
      A[0:i] = [*A[1:i],A[0]]
      break
    if i == N-1:
      A[0:i] = [*A[1:i],A[0]]
    i +=1


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 _ in range(M):
  heapq.heappush(A,((heapq.heappop(A)*-1)//2)*-1)

print(sum(A)*-1)

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
A = list(map(int,input().split()))
for _ in range(M):
  idx = A.index(max(A))
  A[idx] = A[idx]//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 _ in range(M):
  heapq.heappush(A,((heapq.heappop(A)*-1)//2)*-1)

print(sum(A)*-1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = sum(N[:N-1])N = int(input())
ans = round((N-1)*N/2)
print(ans)

Fixed submission:
N = int(input())
ans = (N-1)*N//2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [sorted(list(input())) for _ in range(N)]
count = 0
for i in range(N):
  for j in range(i+1,N):
    if S[i] == S[j]:
      count +=1

print(count)

Fixed submission:
N = int(input())
S = [input() for _ in range(N)]
count = {}

for s in S:
  ls = str(sorted(list(s)))
  if ls in count:
    count[ls] +=1
  else:
    count[ls] = 1

for s in count:
  count[s] = count[s]*(count[s]-1)//2 
print(sum(count.values()))
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
tempL,tempR = map(int,input().split())
gate_id = set(range(tempL,tempR+1))
for i in range(M-1):
  tempL,tempR = map(int,input().split())
  temp_id = set(range(tempL,tempR+1))
  gate_id = gate_id & temp_id
print(len(gate_id))

Fixed submission:
N,M = map(int,input().split())
gateid = [list(map(int,input().split())) for i in range(M)]
idleft = max(gateid,key=lambda x:x[0])
idright = min(gateid,key=lambda x:x[1])
ans = idright[1]-idleft[0]+1
if ans<0:
  ans = 0
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
# print(N,A,sep="\n")
data = set(A)

def culc(data):
  A_min=min(data)
  if len(set(map(lambda x: x%A_min,data)))==1:
    return A_min
  for i in range(A_min,1,-1):
    if len(set(map(lambda x: x%i,data)))==1:
      return i
  return 1


print(culc(data))

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
# print(N,A,sep="\n")
data = set(A)

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

def culc(data):
  A_min=min(data)
  if set(map(lambda x: x%A_min,data))=={0}:
    return A_min
  A.sort()
  ans = A_min
  for i in A[1:]:
    ans=gdc(ans,i)
    if set(map(lambda x: x%ans,data))=={0}:
      return ans
  return ans

print(culc(data))
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int,input().split())
C=[[0 for _ in range(2)] for _ in range(M)]
for i in range(M):
  C[i][0], C[i][1] = map(int,input().split())
D = sorted(C,key = lambda x:x[1])
D.sort(key = lambda x:x[0])
count = [0 for _ in range(M)]
for i in range(M):
  if i == 0:
    count[i]=1
  else:
    if D[i][0]==D[i-1][0]:
      count[i] += count[i-1]+1
    else:
      count[i]=1
for i in C:
  index = D.index(i)
  print("{:06}{:06}".format(i[0],count[index]))

Fixed submission:
N, M = map(int,input().split())
C=[0 for _ in range(M)]
count = [0 for _ in range(N)]
for i in range(M):
  p,y = map(int,input().split())
  C[i] = [i, p, y, 0]

C.sort(key = lambda x:x[2])
for i in C:
  count[i[1]-1] +=1
  i[3] = count[i[1]-1]
for i in sorted(C,key = lambda x:x[0]):
  print("{:06d}{:06d}".format(i[1],i[3]))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int,input().split())
C=[[0 for _ in range(2)] for _ in range(M)]
for i in range(M):
  C[i][0], C[i][1] = map(int,input().split())
D = sorted(C,key = lambda x:x[1])
D.sort(key = lambda x:x[0])
count = [0 for _ in range(M)]
for i in range(M):
  if i == 0:
    count[i]=1
  else:
    if D[i][0]==D[i-1][0]:
      count[i] += count[i-1]+1
    else:
      count[i]=1
for i in C:
  index = D.index(i)
  print("{:06}{:06}".format(i[0],count[index]))

Fixed submission:
N, M = map(int,input().split())
C=[0 for _ in range(M)]
count = [0 for _ in range(N)]
for i in range(M):
  p,y = map(int,input().split())
  C[i] = [i, p, y, 0]

C.sort(key = lambda x:x[2])
for i in C:
  count[i[1]-1] +=1
  i[3] = count[i[1]-1]
for i in sorted(C,key = lambda x:x[0]):
  print("{:06d}{:06d}".format(i[1],i[3]))
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
T = input()
S_list = [i for i in S]
T_list = [i for i in T]
S_set = set(S_list)
T_set = set(T_list)
def judge():
  if len(S_set)==len(T_set)==len(S_list):
    return "Yes"
  for car in S_set:
    if [j for j, x in enumerate(T_list) if x == T_list[S_list.index(car)]]!=[j for j, x in enumerate(S_list) if x == car]:
      return "No"
  return "Yes"

print(judge()) 

Fixed submission:
S = input()
T = input()
S_list = [i for i in S]
T_list = [i for i in T]
S_set = set(S_list)
T_set = set(T_list)
def judge():
  if len(S_set)==len(T_set)==len(S_list):
    return "Yes"
  for car in S_set:
    if [j for j, x in enumerate(T_list) if x == T_list[S_list.index(car)]]!=[j for j, x in enumerate(S_list) if x == car]:
      return "No"
  return "Yes"

print(judge())
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))

if 0 in A:
    print(0)
else:
    out = 1
    for a in A:
        out *= a
    out = -1 if (out > 10 ** 18) else out
    print(out)


Fixed submission:
n = int(input())
A = list(map(int, input().split()))

if 0 in A:
    print(0)
else:
    out = 1
    for a in A:
        out *= a
        if out > 10 ** 18:
            out = -1
            break
    print(out)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = map(int, input().split())
out = 1
for a in A:
    out *= a
out = -1 if (out > 10 ** 18) else out
print(out)


Fixed submission:
n = int(input())
A = list(map(int, input().split()))

if 0 in A:
    print(0)
else:
    out = 1
    for a in A:
        out *= a
        if out > 10 ** 18:
            out = -1
            break
    print(out)