Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,m=map(int, input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
ans = 1
for i in make_divisors:
    if i>=n:
        ans=max(ans,m//i)
print(ans)

Fixed submission:
n,m=map(int, input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
ans = 1
for i in make_divisors(m):
    if i>=n:
        ans=max(ans,m//i)
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import gcd
n,x=map(int, input().split())
town=list(map(int, input().split()))+[x]
town.sort()
if n == 1:
    town.remove(x)
    print(abs(town[0]-x))
    exit()

d1 = abs(town[0]-town[1])
d2 = abs(town[1]-town[2])
ans = gcd(d1,d2)

for i in range(2,n):
    d = abs(town[i]-town[i+1])
    ans = gcd(d,ans)
print(ans)






Fixed submission:
from fractions import gcd
n,x=map(int, input().split())
town=list(map(int, input().split()))+[x]
town.sort()
if n == 1:
    town.remove(x)
    print(abs(town[0]-x))
    exit()

d1 = abs(town[0]-town[1])
d2 = abs(town[1]-town[2])
ans = gcd(d1,d2)

for i in range(2,n):
    d = abs(town[i]-town[i+1])
    ans = gcd(d,ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
n=int(s)
m=0
for i in s:
    m+=i
if n%m==0:
    print("Yes")
else:
    print("No")

Fixed submission:
s=input()
n=int(s)
m=0
for i in s:
    m+=int(i)
if n%m==0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
q=int(input())
lr = [list(map(int,input().split())) for _ in range(q)]
def primesFactraizar(n):
    is_prime = [True] * (n + 1) #まずは[1]*nを用意
    is_prime[0] = False 
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1): #素数の判定√nまでで十分
        if not is_prime[i]: #非素数は無視
            continue            #continue分はループ中の後続の命令をスキップする
        for j in range(i * 2, n + 1, i): #i*2~nまでのiの倍数を順番に消す
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
primes = primesFactraizar(10**5+1)

cumSum = [0]*(10**5+1)
tmp = 0
for i in range(10**5+1):
    if i in primes and (i+1)//2 in primes:
        tmp += 1 
    cumSum[i] = tmp


for l,r in lr:
    print(cumSum[r]-cumSum[l-1])

Fixed submission:
q=int(input())
lr = [list(map(int,input().split())) for _ in range(q)]
def primesFactraizar(n):
    is_prime = [True] * (n + 1) #まずは[1]*nを用意
    is_prime[0] = False 
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1): #素数の判定√nまでで十分
        if not is_prime[i]: #非素数は無視
            continue            #continue分はループ中の後続の命令をスキップする
        for j in range(i * 2, n + 1, i): #i*2~nまでのiの倍数を順番に消す
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
primes = primesFactraizar(10**5+1)

cumSum = [0]*(10**5+1)
tmp = 0
for i in range(10**5+1):
    if i in primes and (i+1)//2 in primes:
        tmp += 1 
    cumSum[i] = tmp


for l,r in lr:
    print(cumSum[r]-cumSum[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
def primesFactraizar(n):
    is_prime = [True] * (n + 1) #まずは[1]*nを用意
    is_prime[0] = False 
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1): #素数の判定√nまでで十分
        if not is_prime[i]: #非素数は無視
            continue            #continue分はループ中の後続の命令をスキップする
        for j in range(i * 2, n + 1, i): #i*2~nまでのiの倍数を順番に消す
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
primes = primesFactraizar(10**5+1)

cumSum = [0]*(10**5+1)
tmp = 0
for i in range(10**5+1):
    if i in primes and (i+1)//2 in primes:
        tmp += 1 
    cumSum[i] = tmp

q=int(input())
lr = [list(map(int,input().split())) for _ in range(q)]
for l,r in lr:
    print(cumSum[r]-cumSum[l-1])

Fixed submission:
q=int(input())
lr = [list(map(int,input().split())) for _ in range(q)]
def primesFactraizar(n):
    is_prime = [True] * (n + 1) #まずは[1]*nを用意
    is_prime[0] = False 
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1): #素数の判定√nまでで十分
        if not is_prime[i]: #非素数は無視
            continue            #continue分はループ中の後続の命令をスキップする
        for j in range(i * 2, n + 1, i): #i*2~nまでのiの倍数を順番に消す
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
primes = primesFactraizar(10**5+1)

cumSum = [0]*(10**5+1)
tmp = 0
for i in range(10**5+1):
    if i in primes and (i+1)//2 in primes:
        tmp += 1 
    cumSum[i] = tmp


for l,r in lr:
    print(cumSum[r]-cumSum[l-1])
Buggy python submission (verdict: Runtime Error):
a,b,c,d=int(input()),int(input()),int(input()),int(input())
x=range(a,b+1)
y=range(c,d+1)
i=0
J=0
list=[]
for i in x:
    for j in y:
        list.append(i*j)
        j=j+1
    i=i+1
print(max(list))


Fixed submission:
a,b,c,d=list(map(int,input().split()))
print(max([a*c,a*d,b*c,b*d]))
Buggy python submission (verdict: Runtime Error):
import math
N=float(input())
a=math.ceil(N/(1.08))
for i in range(a,N):
    if math.floor(i*1.08)==N:
        print(a)
        break
    else:
        print(':(')

Fixed submission:
import math
N=int(input())
a=math.ceil(N/(1.08))
if math.floor(a*1.08)==N:
        print(a)
else:
        print(':(')

Buggy python submission (verdict: Runtime Error):
import math
N=float(input())
a=math.ceil(N/(1.08))
for i in range(a,N):
    if math.floot(i*1.08)==N:
        print(a)
        break
    else:
        print(':(')

Fixed submission:
import math
N=int(input())
a=math.ceil(N/(1.08))
if math.floor(a*1.08)==N:
        print(a)
else:
        print(':(')

Buggy python submission (verdict: Runtime Error):
import math
N=int(input())
a=math.ceil(N/(1.08))
for i in range(a,N):
    pass in range(a,N):
    if i==N:
        print(a)
        break
    else:
        print(':(')   

Fixed submission:
import math
N=int(input())
a=math.ceil(N/(1.08))
if math.floor(a*1.08)==N:
        print(a)
else:
        print(':(')
Buggy python submission (verdict: Time Limit Exceeded):
N,A,B=list(map(int,input().split()))
S=list(input())
t=0
for i in range(N):
 if S[i]=='a':
     if t<A+B:
         t=t+1
         print("Yes")
     else:
         print("No")
 elif S[i]=='b':
     if t<A+B and B>S[:i].count('b'):
         t=t+1
         print('Yes')
     else:
         print('No')
 else:
     print('No')

Fixed submission:
N,A,B=list(map(int,input().split()))
S=list(input())
t=0
u=0
for i in range(N):
 if S[i]=='a':
     if t<A+B:
         t=t+1
         print("Yes")
     else:
         print("No")
 elif S[i]=='b':
     if t<A+B and B>u:
         t=t+1
         u=u+1
         print('Yes')
     else:
         print('No')
 else:
     print('No')
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
ans = S
reverse = False

for i in range(Q):
    query = input().split()
    if query[0] == "1":
        reverse = not reverse
    if query[0] == "2":
        F, C = query[1:]
        if (F == "1" and not reverse) or (F == "2" and reverse):
            ans = C + ans
        else:
            ans = ans + C

if reverse:
    print(ans[::-1])
else:
    print(ans)


Fixed submission:
from collections import deque

S = input()
Q = int(input())
ans = deque(S)
reverse = False

for _ in range(Q):
    query = input().split()
    if query[0] == "1":
        reverse = not reverse
    if query[0] == "2":
        F, C = query[1:]
        if (F == "1" and not reverse) or (F == "2" and reverse):
            ans.appendleft(C)
        else:
            ans.append(C)

if reverse:
    print("".join(reversed(ans)))
else:
    print("".join(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
p = list(map(int, input().split()))

e = [0] * N

for i in range(N):
    e[i] = (p[i] + 1) / 2

ans = 0

for i in range(N - K + 1):
    total = sum(e[i:i + K])
    if total > ans:
        ans = total

print(ans)


Fixed submission:
N, K = map(int, input().split())
p = list(map(int, input().split()))

e = [0] * N

for i in range(N):
    e[i] = (p[i] + 1) / 2

total = sum(e[0:K])
ans = total

for i in range(N - K):
    total += e[i + K] - e[i]
    if total > ans:
        ans = total

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline
H, N = map(int, input().split())
magic = [list(map(int, input().split())) for _ in range(N)]

max_damage = max(damage for damage, cost in magic)
dp = [0] * (H + max_damage)

for x in range(1, H + max_damage):
    dp[x] = min(dp[x - damage] + cost for damage, cost in magic)

ans = min(dp[H:])

print(ans)


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

ans = (H + (A - 1)) // A

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

input = sys.stdin.readline
H, N = map(int, input().split())
magic = [list(map(int, input().split())) for _ in range(N)]

dp = [0] * (H + 1)

for i in range(1, H + 1):
    dp[i] = min(dp[max(i - damage, 0)] + cost for damage, cost in magic)

ans = dp[H]

print(ans)


Fixed submission:
import sys

input = sys.stdin.readline
H, N = map(int, input().split())
magic = [list(map(int, input().split())) for _ in range(N)]

max_damage = max(damage for damage, cost in magic)
dp = [0] * (H + max_damage)

for i in range(1, H + max_damage):
    dp[i] = min(dp[i - damage] + cost for damage, cost in magic)

ans = min(dp[H:])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H, N = map(int, input().split())
magic = [list(map(int, input().split())) for _ in range(N)]

dp = [0] * (H + 1)

for i in range(1, H + 1):
    min_cost = 10 ** 8
    for j in range(N):
        damage, cost = magic[j]
        min_cost = min(dp[max(i - damage, 0)] + cost, min_cost)
    dp[i] = min_cost

ans = dp[H]

print(ans)


Fixed submission:
import sys

input = sys.stdin.readline
H, N = map(int, input().split())
magic = [list(map(int, input().split())) for _ in range(N)]

max_damage = max(damage for damage, cost in magic)
dp = [0] * (H + max_damage)

for i in range(1, H + max_damage):
    dp[i] = min(dp[i - damage] + cost for damage, cost in magic)

ans = min(dp[H:])

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))

cnt = 1

for i in reversed(range(1, N)):
    if P[i] < min(P[:i]):
        cnt += 1

print(cnt)


Fixed submission:
N = int(input())
P = list(map(int, input().split()))

cnt = 1
p_min = P[0]

for i in range(1, N):
    if P[i] < p_min:
        cnt += 1
        p_min = P[i]

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

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

mod = 10 ** 9 + 7
ans = 0
ni = 1

for i in range(60):
    x = sum([1 for j in range(N) if (A[j] >> i) & 1])
    buff = x * (N - x) * ni
    ans += buff
    ni = ni * 2

print(ans % mod)


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

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

mod = 10 ** 9 + 7
ans = 0
ni = 1

for i in range(60):
    x = sum([1 for j in range(N) if (A[j] >> i) & 1])
    buff = x * (N - x) * ni
    ans += buff
    ni = ni * 2

print(ans % mod)

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

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

mod = 10 ** 9 + 7
ans = 0
ni = 1

for i in range(60):
    x = sum([1 for j in range(N) if (A[j] >> i) & 1])
    buff = x * (N - x) % mod
    buff = buff * ni % mod
    ans += buff
    ans %= mod
    ni = ni * 2 % mod

print(ans)


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

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

mod = 10 ** 9 + 7
ans = 0
ni = 1

for i in range(60):
    x = sum([1 for j in range(N) if (A[j] >> i) & 1])
    buff = x * (N - x) * ni
    ans += buff
    ni = ni * 2

print(ans % mod)

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

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

mod = 10 ** 9 + 7
ans = 0

for i in range(60):
    x = 0
    for j in range(N):
        if (A[j] >> i) & 1:
            x += 1
    buff = x * (N - x) % mod
    for j in range(i):
        buff = buff * 2 % mod
    ans += buff
    ans %= mod

print(ans)


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

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

mod = 10 ** 9 + 7
ans = 0
ni = 1

for i in range(60):
    x = sum([1 for j in range(N) if (A[j] >> i) & 1])
    buff = x * (N - x) * ni
    ans += buff
    ni = ni * 2

print(ans % mod)

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

mod = 10 ** 9 + 7
ans = 0

for i in range(60):
    x = 0
    for j in range(N):
        if (A[j] >> i) & 1:
            x += 1
    buff = x * (N - x) % mod
    for j in range(i):
        buff = buff * 2 % mod
    ans += buff
    ans %= mod

print(ans)


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

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

mod = 10 ** 9 + 7
ans = 0
ni = 1

for i in range(60):
    x = sum([1 for j in range(N) if (A[j] >> i) & 1])
    buff = x * (N - x) * ni
    ans += buff
    ni = ni * 2

print(ans % mod)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int, input().split()))

L.sort()

ans = 0

for i in range(N - 2):
    a = L[i]
    for j in range(i + 1, N - 1):
        b = L[j]
        left = j
        right = N
        if L[left + 1] >= a + b:
            continue
        while right - left > 1:
            mid = (left + right) // 2
            c = L[mid]
            if c < a + b:
                left = mid
            else:
                right = mid
        ans += left - j

print(ans)


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

L.sort()

ans = 0

for i in range(N - 2):
    a = L[i]
    for j in range(i + 1, N - 1):
        b = L[j]
        left = j
        right = N
        if L[left + 1] >= a + b:
            continue
        while right - left > 1:
            mid = (left + right) // 2
            c = L[mid]
            if c < a + b:
                left = mid
            else:
                right = mid
        ans += left - j

print(ans)

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

l_sorted = sorted(L, reverse=True)
ans = 0

for i in range(N - 2):
    a = l_sorted[i]
    for j in range(i + 1, N - 1):
        b = l_sorted[j]
        ans += len(list(filter(lambda x: abs(a - b)
                               < x < a + b, l_sorted[j + 1:])))

print(ans)


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

L.sort()

ans = 0

for i in range(N - 2):
    a = L[i]
    for j in range(i + 1, N - 1):
        b = L[j]
        left = j
        right = N
        if L[left + 1] >= a + b:
            continue
        while right - left > 1:
            mid = (left + right) // 2
            c = L[mid]
            if c < a + b:
                left = mid
            else:
                right = mid
        ans += left - j

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

for _ in range(M):
    A.sort()
    A[-1] //= 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)

ans = sum(A) * -1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = 0

for i in range(1, N):
    ans += i

print(ans)


Fixed submission:
N = int(input())
print((N - 1) * N // 2)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

n = int(input())
alphabet = [chr(ord("a") + i) for i in range(26)]
count = [[0] * 26 for _ in range(n)]
for i in range(n):
    for s in sys.stdin.readline().strip():
        count[i][alphabet.index(s)] += 1

uniq = set(list(map(tuple, count)))
ans = 0
for u in uniq:
    n = count.count(list(u))
    ans += n * (n - 1) // 2
print(ans)


Fixed submission:
import sys
import collections

n = int(input())
lst = [None] * n
for i in range(n):
    lst[i] = "".join(sorted(list(sys.stdin.readline().strip())))

ans = 0
for v in collections.Counter(lst).values():
    ans += v * (v - 1) // 2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
nums = [None] * n

for i in range(n):
    nums[i] = int(input())
sorted_nums = sorted(nums)

for i in range(n):
    if sorted_nums.index(nums[i]) == n - 1:
        max_val = sorted_nums[n - 2]
    else:
        max_val = sorted_nums[n - 1]
    print(max_val)


Fixed submission:
n = int(input())
nums = [None] * n

for i in range(n):
    nums[i] = int(input())
sorted_nums = sorted(nums)

for i in range(n):
    max_val = sorted_nums[n - 1]
    if nums[i] == max_val:
        max_val = sorted_nums[n - 2]
    print(max_val)
Buggy python submission (verdict: Runtime Error):
# import math
import fractions


a, b, c, d = map(int, input().split())


def lcm(x, y):
    # DeprecationWarning: fractions.gcd() is deprecated. Use math.gcd() instead.
    return x * y // fractions.gcd(x, y)


a1 = a - 1
div_a = (a1 // c) + (a1 // d) - (a1 // lcm(c, d))
div_b = (b // c) + (b // d) - (b // lcm(c, d))

print((b - a + 1) - (div_b - div_a))


Fixed submission:
s = input()
msg = "Good"

for i in range(3):
    if s[i] == s[i + 1]:
        msg = "Bad"

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

a, b, c, d = map(int, input().split())


def lcm(x, y):
    return x * y // math.gcd(x, y)


a1 = a - 1
div_a = (a1 // c) + (a1 // d) - (a1 // lcm(c, d))
div_b = (b // c) + (b // d) - (b // lcm(c, d))

print((b - a + 1) - (div_b - div_a))


Fixed submission:
# import math
import fractions


a, b, c, d = map(int, input().split())


def lcm(x, y):
    # DeprecationWarning: fractions.gcd() is deprecated. Use math.gcd() instead.
    return x * y // fractions.gcd(x, y)


a1 = a - 1
div_a = (a1 // c) + (a1 // d) - (a1 // lcm(c, d))
div_b = (b // c) + (b // d) - (b // lcm(c, d))

print((b - a + 1) - (div_b - div_a))
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = 0
cnt = 0

while d <= x:
    d = d + l[cnt]
    cnt += 1

print(cnt)


Fixed submission:
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = 0
cnt = 1

for i in range(n):
    d += l[i]
    if d > x:
        break
    else:
        cnt += 1

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

input = sys.stdin.readline

N, M = map(int, input().split())
A = list(map(int, input().split()))
op = [list(map(int, input().split())) for _ in range(M)]

cards = sorted(A)
op.sort(key=lambda x: -x[1])

i = 0

for m in range(M):
    b, c = op[m]
    for _ in range(b):
        if cards[i] < c:
            cards[i] = c
            i += 1
        if i >= N:
            break
    else:
        continue
    break

print(sum(cards))


Fixed submission:
import sys

input = sys.stdin.readline

N, M = map(int, input().split())
A = list(map(int, input().split()))
op = [list(map(int, input().split())) for _ in range(M)]

cards = sorted(A)
op.sort(key=lambda x: -x[1])

i = 0

for m in range(M):
    b, c = op[m]
    for _ in range(b):
        if cards[i] < c:
            cards[i] = c
            i += 1
            if i >= N:
                break
        else:
            break
    else:
        continue
    break

print(sum(cards))
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
P = [0] * M
Y = [0] * M

data = [[] for i in range(N + 1)]

for i in range(M):
    P[i], Y[i] = map(int, input().split())
    data[P[i]].append(Y[i])

for key in set(P):
    data[key].sort()

for i in range(M):
    x = data[P[i]].index(Y[i]) + 1
    id_number = "{:06}{:06}".format(P[i], x)
    print(id_number)


Fixed submission:
N, M = map(int, input().split())
P = [0] * M
Y = [0] * M

data = [[] for _ in range(N + 1)]

for i in range(M):
    P[i], Y[i] = map(int, input().split())
    data[P[i]].append(Y[i])

for k in set(P):
    data[k].sort()

x = [{} for _ in range(N + 1)]

for k in set(P):
    c = 0
    for v in data[k]:
        c += 1
        x[k][v] = c

for i in range(M):
    id_number = "{:06}{:06}".format(P[i], x[P[i]][Y[i]])
    print(id_number)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
P = [0] * M
Y = [0] * M

pref = {}

for i in range(M):
    P[i], Y[i] = map(int, input().split())
    pref.setdefault(P[i], [])
    pref[P[i]].append(Y[i])

for v in pref.values():
    v.sort()

for i in range(M):
    x = pref[P[i]].index(Y[i]) + 1
    id_number = "{:06}{:06}".format(P[i], x)
    print(id_number)


Fixed submission:
N, M = map(int, input().split())
P = [0] * M
Y = [0] * M

data = [[] for _ in range(N + 1)]

for i in range(M):
    P[i], Y[i] = map(int, input().split())
    data[P[i]].append(Y[i])

for k in set(P):
    data[k].sort()

x = [{} for _ in range(N + 1)]

for k in set(P):
    c = 0
    for v in data[k]:
        c += 1
        x[k][v] = c

for i in range(M):
    id_number = "{:06}{:06}".format(P[i], x[P[i]][Y[i]])
    print(id_number)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
P = [0] * M
Y = [0] * M

pref = {}

for i in range(M):
    P[i], Y[i] = map(int, input().split())
    pref.setdefault(P[i], [])
    pref[P[i]].append(Y[i])

for v in pref.values():
    v.sort()

for i in range(M):
    x = pref[P[i]].index(Y[i]) + 1
    id_number = "{:06}{:06}".format(P[i], x)
    print(id_number)


Fixed submission:
N, M = map(int, input().split())
P = [0] * M
Y = [0] * M

data = [[] for _ in range(N + 1)]

for i in range(M):
    P[i], Y[i] = map(int, input().split())
    data[P[i]].append(Y[i])

for k in set(P):
    data[k].sort()

x = [{} for _ in range(N + 1)]

for k in set(P):
    c = 0
    for v in data[k]:
        c += 1
        x[k][v] = c

for i in range(M):
    id_number = "{:06}{:06}".format(P[i], x[P[i]][Y[i]])
    print(id_number)
Buggy python submission (verdict: Runtime Error):
n = int(input())
v = list(map(int, input().split()))

if len(set(v)) == 1:
    ans = n // 2
else:
    even = [0] * 10 ** 5
    odd = [0] * 10 ** 5

    for i in range(0, n, 2):
        even[v[i]] += 1

    for i in range(1, n, 2):
        odd[v[i]] += 1

    ans = n - max(even) - max(odd)

print(ans)


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


even = [0] * (10 ** 5)
odd = [0] * (10 ** 5)

for i in range(0, n, 2):
    even[v[i] - 1] += 1

for i in range(1, n, 2):
    odd[v[i] - 1] += 1

even_max = max(even)
odd_max = max(odd)

even_max_i = even.index(even_max)
odd_max_i = odd.index(odd_max)

if even_max_i == odd_max_i:
    even[even_max_i] = 0
    odd[odd_max_i] = 0

    even_max_2 = max(even)
    odd_max_2 = max(odd)

    ans = n - max(even_max + odd_max_2, even_max_2 + odd_max)
else:
    ans = n - (even_max + odd_max)

print(ans)
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
K = int(input())

max_n = max(A, B, C)
print(sum([A, B, C]) + (2 ** K - 1) * max_n)


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

print(a if a <= b else a - 1)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, K = map(int, input().split())

for i in range(A, B + 1):
    if i < A + K or i > B - K:
        print(i)


Fixed submission:
A, B, K = map(int, input().split())

for i in range(A, min(B + 1, A + K)):
    if i < A + K:
        print(i)

for i in range(max(B - K, A + K), B + 1):
    if i > B - K:
        print(i)