Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def main():
	H = int(input())
	cnt = 0
	while 1:
		if H==1:
			break
		else:
			H = H//2
			cnt += 1
	ans = 0
	for i in range(cnt):
		ans += 2**i
	ans += 2**(i+1)
	print(ans)

if __name__ == '__main__':
	main()

Fixed submission:
def main():
	H = int(input())
	cnt = 0
	if H==1:
		print(1)
		exit()
	while 1:
		if H==1:
			break
		else:
			H = H//2
			cnt += 1
	ans = 0
	for i in range(cnt):
		ans += 2**i
	ans += 2**(i+1)
	print(ans)

if __name__ == '__main__':
	main()
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
def main():
    N = int(input())
    P = [int(x) for x in input().split()]
    ls = [0 for _ in range(N)]
    ans = 0
    for i in range(N):
        ls[P[i]-1] = 1
        if sum(ls[0:P[i]])==1:
            ans += 1
    print(ans)
if __name__ == '__main__':
    main()

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

def main():
    N = int(input())
    P = [int(x) for x in input().split()]
    ls = [0 for _ in range(N)]
    ans = 0
    mins = 10**10
    for i in range(N):
        mins = min(mins,P[i])
        if mins==P[i]:
            ans += 1
    print(ans)
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
		def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    zero = 3
    ans = 1
    ls = [0 for _ in range(N)]
    mod = 1000000007
    for i in A:
        if i == 0:
            ans = (ans*zero)%mod
            zero -= 1
            ls[i] += 1
        else:
            ans = (ans*(ls[i-1]-ls[i]))%mod
            ls[i] +=1

    print(ans)
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    zero = 3
    ans = 1
    ls = [0 for _ in range(N)]
    mod = 1000000007
    for i in A:
        if i == 0:
            ans = (ans*zero)%mod
            zero -= 1
            ls[i] += 1
        else:
            ans = (ans*(ls[i-1]-ls[i]))%mod
            ls[i] +=1

    print(ans)
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
from math import gcd
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def main():
    a,b = map(int,input().split())
    c = gcd(a,b)
    print(len(factorization(c))+1)

if __name__ == "__main__":
    main()

Fixed submission:
from fractions import gcd
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def main():
    a,b = map(int,input().split())
    c = gcd(a,b)
    cnt = factorization(c)
    if cnt[0][0]==1:
        print(len(cnt))
    else:
        print(len(cnt)+1)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    b = [0]*n
    for i in reversed(range(n)):
        x = n//(i+1)
        now = 0
        for j in range(1,x+1):
            now += b[k*(i+1)-1]
        if a[i] != now%2:
            b[i]=1
    print(b.count(1))
    if not m==0:
        for i in range(n):
            if b[i]==1:
                print(str(i+1),end=" ")
    
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    b = [0]*n
    for i in reversed(range(n)):
        x = n//(i+1)
        now = 0
        for j in range(1,x+1):
            now += b[j*(i+1)-1]
        if a[i] != now%2:
            b[i]=1
    m = b.count(1)
    print(m)
    if not m==0:
        for i in range(n):
            if b[i]==1:
                print(str(i+1),end=" ")
    
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = sum(a)
a = a+a

m = (n-1)/2

ls = [ans for _ in range(n)]

for i in range(n):
    for j in range(int(m)):
        ls[i] -= 2*(a[i+1+2*j])
    ls[i] = str(ls[i])
print(" ".join(ls))


Fixed submission:
def main():
    n = int(input())
    a = list(map(int,input().split()))
    s = sum(a)
    l1 = 0
    for i in range(n):
        if i%2==0:
            l1 += a[i]
        else:
            l1 -= a[i]
    print(l1,end=" ")
    for i in range(n-1):
        l1 = 2*a[i]-l1
        print(l1,end=" ")
    print()
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
ans = sum(a)
a = a+a

m = (n-1)/2

ls = [ans for _ in range(n)]

for i in range(n):
    for j in range(int(m)):
        ls[i] = str(ls[i]-2*(a[i+1+2*j]))

print(" ".join(ls))


Fixed submission:
def main():
    n = int(input())
    a = list(map(int,input().split()))
    s = sum(a)
    l1 = 0
    for i in range(n):
        if i%2==0:
            l1 += a[i]
        else:
            l1 -= a[i]
    print(l1,end=" ")
    for i in range(n-1):
        l1 = 2*a[i]-l1
        print(l1,end=" ")
    print()
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())


import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(1,k+1):
    print(i)
    print((combinations_count(n-k+1,i)*combinations_count(k-1,i-1))%(10**9+7))

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


import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(1,k+1):
    if n-k+1>=i:
        red = combinations_count(n-k+1,i)
    else:
        red = 0
    
    ls = [int(x) for x in range(1,)]

    
    print((red*combinations_count(k-1,i-1))%(10**9+7))

Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())


import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(1,k+1):

    print((combinations_count(n-k+1,i)*combinations_count(k-1,i-1))%(10**9+7))

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


import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(1,k+1):
    if n-k+1>=i:
        red = combinations_count(n-k+1,i)
    else:
        red = 0
    
    ls = [int(x) for x in range(1,)]

    
    print((red*combinations_count(k-1,i-1))%(10**9+7))
Buggy python submission (verdict: Runtime Error):
n,x = map(int,input().split())

l = [int(x) for x in input().split()]
import sys

sys.setrecursionlimit(20000)

def solve(now,ls,x,cnt):
    if now>x:
        return print(cnt)
    else:
        return solve(now+ls[cnt],ls,x,cnt+1)
solve(0,l,x,0)

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

l = [int(x) for x in input().split()]

cnt = 1
now = 0
for i in l:
    now += i
    if now>x:
        break
    cnt += 1

print(cnt)

Buggy python submission (verdict: Runtime Error):
n,x = map(int,input().split())

l = [int(x) for x in input().split()]

def solve(now,ls,x,cnt):
    if now>x:
        return print(cnt)
    else:
        return solve(now+ls[cnt-1],ls,x,cnt+1)
solve(0,l,x,0)

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

l = [int(x) for x in input().split()]

cnt = 1
now = 0
for i in l:
    now += i
    if now>x:
        break
    cnt += 1

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

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

b = [0] * m
c = [0] * m

for i in range(m):
    b[i], c[i] = map(int, input().split())

for i in range(m):
    lists = [c[i]]*b[i]
    a = a+lists
a.sort(reverse = True)

print(sum(a[:n]))


Fixed submission:
n,m = map(int,input().split())
from collections import defaultdict
d = defaultdict(int)
for a in input().split():
    d[int(a)]+=1

for _ in range(m):
    b,c = map(int,input().split())
    d[c]+=b

d = sorted(d.items(),key=lambda x:x[0],reverse=True)
i=0
ans=0
while n>0:
    if d[i][1]<=n:
        ans += d[i][0]*d[i][1]
        n -= d[i][1]
        i +=1
    else:
        ans += d[i][0]*n
        n=0
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B,T = input().split()
print(int((T//A)*B)

Fixed submission:
A,B,T = map(int,input().split())
print(int((T//A)*B))
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from copy import copy
from functools import reduce

n = int(input())
a = list(map(int,input().split()))
max_ = 0
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

for i in range(n) :
    b = copy(a)
    b.pop(i)
    c = gcd_list(b)
    if max_ <= c:
        max_ = c

print(max_)


Fixed submission:
from fractions import gcd
n = int(input())
a = list(map(int,input().split()))

from fractions import gcd
r = []
l = []
r.append(a[-1])

l.append(a[0])

for i in range(1,n):
    l.append(gcd(l[i-1],a[i]))
    r.append(gcd(r[i-1],a[(n-1)-i]))

l.insert(0,a[-1])
r.insert(0,a[0])


def solve(num):
    ans = gcd(l[num],r[n-1-num])
    return ans

can = []
for i in range(n):
    can.append(solve(i))

print(max(can))
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
num = [int(input()) for i in range(5)]
print(int(4+math.ceil(n/min(min(num)))))

Fixed submission:
import numpy as np
s = [int(i) for i in input()]

n = len(s)

list01 = [int(i%2) for i in range(n)]
list10 = [int((i+1)%2) for i in range(n)]

        
list_a = np.array(s) - np.array(list01)
list_b = np.array(s) - np.array(list10)

count0 = np.sum(list_a == 0)
count1 = np.sum(list_b == 0)
countmin = min((n-count0),(n-count1))
print(countmin)
Buggy python submission (verdict: Runtime Error):
import numpy as np

ls = [int(input()) for _ in range(5)]


max_=0
for h in ls:
    if h%10 == 0:
        pass
    else:
        re =10-h
        if re>=max_:
            max_ = re

time = 0
for i in ls:
    if i%10 == 0:
        time += i
    else:
        time += (i//10+1)*10

time -= re

print(time)


Fixed submission:
import numpy as np

ls = [int(input()) for _ in range(5)]


a=0
for h in ls:
    if h%10 == 0:
        pass
    else:
        re =(h//10+1)*10-h
        if re>=a:
            a = re


time = 0
for i in ls:
    if i%10 == 0:
        time += i
    else:
        time += (i//10+1)*10

time -= a
print(time)
Buggy python submission (verdict: Time Limit Exceeded):
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a,reverse = True)
b = list(map(int,input().split()))
b = sorted(b,reverse = True)
c = list(map(int,input().split()))
c = sorted(c,reverse = True)

ls1= []
for i in range(min(x,k)):
    for j in range(min(y,k)):
        ls1.append(a[i]+b[j])

ls1 = sorted(ls1,reverse=True)

ls1 = ls1[:k]
ls2 = []
for i in range(min(z,k)):
    for j in range(len(ls1)):
        ls2.append(c[i]+ls1[j])

ls2 = sorted(ls2,reverse=True)

for i in range(k):
    print(ls2[i])


Fixed submission:
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a,reverse = True)
b = list(map(int,input().split()))
b = sorted(b,reverse = True)
c = list(map(int,input().split()))
c = sorted(c,reverse = True)

ls1= []
for i in range(min(x,k)):
    for j in range(min(y,k)):
        ls1.append(a[i]+b[j])

ls1 = sorted(ls1,reverse=True)

ls1 = ls1[:k]
ls2 = []
for i in range(min(z,k)):
    for j in range(len(ls1)):
        ls2.append(c[i]+ls1[j])

ls2 = sorted(ls2,reverse=True)

for i in range(k):
    print(ls2[i])

Buggy python submission (verdict: Time Limit Exceeded):
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ls1= []
for i in range(x):
    for j in range(y):
        ls1.append(a[i]+b[j])

ls1 = sorted(ls1,reverse=True)

ls1 = ls1[:k]
ls2 = []
for i in range(z):
    for j in range(len(ls1)):
        ls2.append(c[i]+ls1[j])

ls2 = sorted(ls2,reverse=True)

for i in range(k):
    print(ls2[i])


Fixed submission:
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a,reverse = True)
b = list(map(int,input().split()))
b = sorted(b,reverse = True)
c = list(map(int,input().split()))
c = sorted(c,reverse = True)

ls1= []
for i in range(min(x,k)):
    for j in range(min(y,k)):
        ls1.append(a[i]+b[j])

ls1 = sorted(ls1,reverse=True)

ls1 = ls1[:k]
ls2 = []
for i in range(min(z,k)):
    for j in range(len(ls1)):
        ls2.append(c[i]+ls1[j])

ls2 = sorted(ls2,reverse=True)

for i in range(k):
    print(ls2[i])
Buggy python submission (verdict: Runtime Error):
n = int(input())
for _ in range(n):
    x,u = map(int,input().split())
c = 0    
for i in range(n):
    if u[i] == "JPY":
        c += x[i]
    else:
        c += x[i]*380000.0
print(int(c))

Fixed submission:
count = 0
N =int(input())
for _ in range(N):
    x, u =[_ for _ in input().split()]
    x= float(x)
    if u =='JPY':
        count += x
    else:
        count += x * 380000
print(count)

Buggy python submission (verdict: Runtime Error):
n = int(input())
for _ in range(n):
    x,u = map(int,input().split())
c = 0    
for i in range(n):
    if u[i] == "JPY":
        c += x[i]
    else:
        c += x[i]*380000.0
print(c)

Fixed submission:
count = 0
N =int(input())
for _ in range(N):
    x, u =[_ for _ in input().split()]
    x= float(x)
    if u =='JPY':
        count += x
    else:
        count += x * 380000
print(count)
Buggy python submission (verdict: Runtime Error):
def main():
    N = int(input())
    ls = [[int(x) for x in input().split()] for _ in range(N)]
    ans = 0
    for i in range(N):
        ls[i].append(ls[i][0]+ls[i][1])
    ls = sorted(ls,key=lambda x:-x[2])
    if N==1:
        print(ls[0][1])
    for i in range(N):
        ans -= ls[i][1]

    for i in range(N//2):
        ans += ls[2*i][2]

    if N%2==1:
        ans += ls[2*i+2][2]
    
    print(ans)
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    ls = [[int(x) for x in input().split()] for _ in range(N)]
    ans = 0
    for i in range(N):
        ls[i].append(ls[i][0]+ls[i][1])
    ls = sorted(ls,key=lambda x:-x[2])
    if N==1:
        print(ls[0][1])
        exit()
    for i in range(N):
        ans -= ls[i][1]

    for i in range(N//2):
        ans += ls[2*i][2]

    if N%2==1:
        ans += ls[2*i+2][2]
    
    print(ans)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    N = int(input())
    ls = [[int(x) for x in input().split()] for _ in range(N)]
    ans = 0
    for i in range(N):
        ls[i].append(ls[i][0]+ls[i][1])
    ls = sorted(ls,key=lambda x:-x[2])
    
    for i in range(N):
        ans -= ls[i][1]
    for i in range(N//2):
        ans += ls[2*i][2]

    if N%2==1:
        ans += ls[2*i+2][2]
    
    print(ans)
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    ls = [[int(x) for x in input().split()] for _ in range(N)]
    ans = 0
    for i in range(N):
        ls[i].append(ls[i][0]+ls[i][1])
    ls = sorted(ls,key=lambda x:-x[2])
    if N==1:
        print(ls[0][1])
        exit()
    for i in range(N):
        ans -= ls[i][1]

    for i in range(N//2):
        ans += ls[2*i][2]

    if N%2==1:
        ans += ls[2*i+2][2]
    
    print(ans)
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = [int(input()) for _ in range()]

m = max(p)/2

c = sum(p) - m

print(int(c))

Fixed submission:
n = int(input())
p = [int(input()) for _ in range(n)]

m = max(p)/2

c = sum(p) - m

print(int(c))
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
c = [int(input()) for _ in range(n)]
c.sort()
ans = []
for i in range(n-k+1):
    ans.append(c[i+k]-c[i])
print(min(ans))

Fixed submission:
n,k = map(int,input().split())
c = [int(input()) for _ in range(n)]
c.sort()
ans = []
for i in range(n-k+1):
    ans.append(c[i+k-1]-c[i])
print(min(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
c = [int(input()) for _ in range(n)]

c.sort()

ans = []
for i in range(n-k+1):
    ans.append(max(c[i:k+i])-min(c[i:k+i]))

print(min(ans))

Fixed submission:
n,k = map(int,input().split())
c = [int(input()) for _ in range(n)]
c.sort()
ans = []
for i in range(n-k+1):
    ans.append(c[i+k-1]-c[i])
print(min(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
c = [int(input()) for _ in range(n)]

c.sort()

ans = []
for i in range(n-k+1):
    ans.append(max(c[i:k+i])-min(c[i:k+i]))

print(min(ans))

Fixed submission:
n,k = map(int,input().split())
c = [int(input()) for _ in range(n)]
c.sort()
ans = []
for i in range(n-k+1):
    ans.append(c[i+k-1]-c[i])
print(min(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
c = [int(input()) for _ in range(n)]

c.sort()

ans = []
for i in range(n-k+1):
    ans.append(max(c[i:k+i])-min(c[i:k+i]))

print(min(ans))

Fixed submission:
n,k = map(int,input().split())
c = [int(input()) for _ in range(n)]
c.sort()
ans = []
for i in range(n-k+1):
    ans.append(c[i+k-1]-c[i])
print(min(ans))

Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
c = [int(input()) for _ in range(n)]

c.sort()

ans = []
for i in range(n-k+1):
    ans.append(max(c[i:k+i])-min(c[i:k+i])))

print(min(ans))

Fixed submission:
n,k = map(int,input().split())
c = [int(input()) for _ in range(n)]
c.sort()
ans = []
for i in range(n-k+1):
    ans.append(c[i+k-1]-c[i])
print(min(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
c = [int(input()) for _ in range(n)]

c.sort()

ans = 10**9
for i in range(n-k+1):
    ans = min(ans,max(c[i:k+i])-min(c[i:k+i]))

print(ans)

Fixed submission:
n,k = map(int,input().split())
c = [int(input()) for _ in range(n)]
c.sort()
ans = []
for i in range(n-k+1):
    ans.append(c[i+k-1]-c[i])
print(min(ans))

Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
c = [int(input()) for _ in range(n)]

c.sort()

for i in range(n-k+1):
    ans = min(ans,max(c[i:k+i])-min(c[i:k+i]))

print(ans)

Fixed submission:
n,k = map(int,input().split())
c = [int(input()) for _ in range(n)]
c.sort()
ans = []
for i in range(n-k+1):
    ans.append(c[i+k-1]-c[i])
print(min(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
c = [int(input()) for _ in range(n)]

c.sort()

ans = 10**9
for i in range(n-k+1):
    ls = c[i:k+i]
    ans = min(ans,max(ls)-min(ls))

print(ans)

Fixed submission:
n,k = map(int,input().split())
c = [int(input()) for _ in range(n)]
c.sort()
ans = []
for i in range(n-k+1):
    ans.append(c[i+k-1]-c[i])
print(min(ans))
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
ls = [[int(x) for x in input().split()] for _ in range(m)]

ans = sorted(ls,key=lambda x:(x[0],x[1]))

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

for i in range(m):
    key = ans[i][0]
    value = ans[i][1]
    dic[key].append(value)

for i in range(m):
    print("{:06d}{:06d}".format(ls[i][0],dic[ls[i][0]].index(ls[i][1])+1))

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

for i in range(m):
    a,b = map(int,input().split())
    ls[a].append((b,i))
ans = [None]*m
for i,l in enumerate(ls):
    l.sort()
    for j,(a,b) in enumerate(l):
        ans[b]= "{:06d}{:06d}".format(i,j+1)
for i in range(m):
    print(ans[i])

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
ls = [[int(x) for x in input().split()] for _ in range(m)]

ans = sorted(ls,key=lambda x:(x[0],x[1]))

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

for i in range(m):
    key = ans[i][0]
    value = ans[i][1]
    dic[key+1].append(value)

for i in range(m):
    print("{:06d}{:06d}".format(ls[i][0],dic[ls[i][0]+1].index(ls[i][1])+1))

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

for i in range(m):
    a,b = map(int,input().split())
    ls[a].append((b,i))
ans = [None]*m
for i,l in enumerate(ls):
    l.sort()
    for j,(a,b) in enumerate(l):
        ans[b]= "{:06d}{:06d}".format(i,j+1)
for i in range(m):
    print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
ls = [[int(x) for x in input().split()] for _ in range(m)]

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

for i in range(m):
    idx = ls[i][0]
    cnt[idx].append(ls[i][1])

for i in range(n+1):
    cnt[i].sort()


for i in range(m):
    idx = ls[i][0]
    print("{:06d}{:06d}".format(idx,cnt[idx].index(ls[i][1])))

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

for i in range(m):
    a,b = map(int,input().split())
    ls[a].append((b,i))
ans = [None]*m
for i,l in enumerate(ls):
    l.sort()
    for j,(a,b) in enumerate(l):
        ans[b]= "{:06d}{:06d}".format(i,j+1)
for i in range(m):
    print(ans[i])

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
ls = [[int(x) for x in input().split()] for _ in range(m)]

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

for i in range(m):
    idx = ls[i][0]
    cnt[idx].append(ls[i][1])

for i in range(m):
    cnt[i].sort()


for i in range(m):
    idx = ls[i][0]
    print("{:06d}{:06d}".format(idx,cnt[idx].index(ls[i][1])))

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

for i in range(m):
    a,b = map(int,input().split())
    ls[a].append((b,i))
ans = [None]*m
for i,l in enumerate(ls):
    l.sort()
    for j,(a,b) in enumerate(l):
        ans[b]= "{:06d}{:06d}".format(i,j+1)
for i in range(m):
    print(ans[i])
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = [0]*n
y = [0]*n
h = [0]*n
for i in range(n):
    x[i],y[i],h[i] = map(int,input().split())

H = max(h)
while 1:
  for i in range(101):
    for j in range(101):
      for k in range(n):
        dx,dy = abs(x[k]-i),abs(x[k]-j)
        if max(H-dx-dy)!=h[k]:
          break
        else:
          print(i,j,H)
          exit()
  H +=1
    


Fixed submission:
n = int(input())
x = [0]*n
y = [0]*n
h = [0]*n
for i in range(n):
    x[i],y[i],h[i] = map(int,input().split())

H = max(h)
while 1:
  for i in range(101):
    for j in range(101):
      flg =True
      for k in range(n):
        dx,dy = abs(x[k]-i),abs(y[k]-j)
        if max(H-dx-dy,0)!=h[k]:
          flg = False
      if flg:
        print(i,j,H)
        exit()
  H +=1
Buggy python submission (verdict: Runtime Error):
n = int(input())
w = [str(input()) for _ in range(n)]

def solve(n,ls):
    if n == -1:
        return print("Yes")
    else:
        if ls[n][-1] == ls[n+1][0]:
            return solve(n-1,ls)
        else:
            return print("No")

solve(n,w)

Fixed submission:
n = int(input())
w = [input()  for _ in range(n)]



def solve(n,ls):
    if n == 0:
        return "Yes"
    else:
        if ls[n-1][-1] == ls[n][0]:
            return solve(n-1,ls)
        else:
            return "No"


flg = solve(n-1,w)
if flg == "No":
    pass
else:
    if not len(w) == len(list(set(w))):
        flg ="No"

print(flg)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
x = [int(x) for x in input().split()]

mini = 10**9
for i in range(n-k+1):
    ls = x[i:i+k]
    flg1 = abs(ls[0])+abs(ls[0]-ls[k-1])
    flg2 = abs(ls[k-1])+abs(ls[0]-ls[k-1])
    flg = min(flg1,flg2)
    mini = min(flg,mini)
print(mini)

Fixed submission:
n,k = map(int,input().split())
ls = [int(x) for x in input().split()]

mini = 10**9
for i in range(n-k+1):
    flg1 = abs(ls[i])+abs(ls[i]-ls[i+k-1])
    flg2 = abs(ls[i+k-1])+abs(ls[i]-ls[i+k-1])
    mini = min(flg1,flg2,mini)
print(mini)