Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def C():
    N = int(input())

    word_dict = dict()
    count = 0

    for i in range(N):
        word = sorted(input())
        if word not in word_dict:
            word_dict[word] = 1
        else:
            count += 1

    print(count)
    
if __name__ == '__main__':
    C()


Fixed submission:
def C():
    N = int(input())

    word_dict = dict()
    count = 0

    for i in range(N):
        word = ''.join(sorted(input()))
        if word not in word_dict.keys():
            word_dict[word] = 1
        else:
            count += word_dict[word]
            word_dict[word] += 1

    print(count)

if __name__ == '__main__':
    C()

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

literals = [[0]*26 for _ in range(N)]

for i in range(N):
    word = input()
    for char in word:
        literals[i][ord(char) - 97] += 1

answer = 0
for i in range(N):
    target = literals.pop()
    answer += literals.count(target)

print(answer)

Fixed submission:
def C():
    N = int(input())

    word_dict = dict()
    count = 0

    for i in range(N):
        word = ''.join(sorted(input()))
        if word not in word_dict.keys():
            word_dict[word] = 1
        else:
            count += word_dict[word]
            word_dict[word] += 1

    print(count)

if __name__ == '__main__':
    C()

Buggy python submission (verdict: Time Limit Exceeded):
def C():
    N = int(input())

    literals = []

    for i in range(N):
        word_vec = [0]*26
        word = input()
        for char in word:
            word_vec[ord(char) - 97] += 1
        literals.append(word_vec)

    answer = 0
    for i in range(N):
        target = literals.pop()
        answer += literals.count(target)

    print(answer)

if __name__ == '__main__':
  C()


Fixed submission:
def C():
    N = int(input())

    word_dict = dict()
    count = 0

    for i in range(N):
        word = ''.join(sorted(input()))
        if word not in word_dict.keys():
            word_dict[word] = 1
        else:
            count += word_dict[word]
            word_dict[word] += 1

    print(count)

if __name__ == '__main__':
    C()
Buggy python submission (verdict: Runtime Error):
import numpy as np

N, D = map(int, input().split())

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

def distance(p1, p2):
  squares = np.square(np.arange(p1) - np.arange(p2))
  return np.sqrt(squares.sum())

count = 0
for i in range(N):
  for j in range(N):
    if i != j:
      dist = distance(points[i], points[j])
      count += dist.is_integer() * 1

print(count)


Fixed submission:
import numpy as np

N, D = map(int, input().split())

points = np.array([list(map(int, input().split())) for _ in range(N)])

def distance(p1, p2):
  squares = np.square(p1 - p2)
  return np.sqrt(squares.sum())

count = 0
for i in range(N):
  for j in range(i+1, N):
    dist = distance(points[i], points[j])
    count += dist.is_integer() * 1

print(count)
Buggy python submission (verdict: Runtime Error):
def code_for_A(S, test=None):

    if not test:
        S = input()

    condition = 0
    for s in S:
        condition += S.count(s) != 2

    if condition:
        answer = 'No'
    else:
        answer = 'Yes'

    print(answer)

code_for_A(,1)

Fixed submission:
def code_for_A(S, test=None):

    if not test:
        S = input()

    condition = 0
    for s in S:
        condition += S.count(s) != 2

    if condition:
        answer = 'No'
    else:
        answer = 'Yes'

    print(answer)

code_for_A(None, 0)
Buggy python submission (verdict: Runtime Error):
def code_for_B(test=None):

    n = int(input)
    list_p = list(map(int, input().split()))
    
    pre = list_p[0]
    count = 0

    for i in range(1,n-1):
        cur = list_p[i]
        nxt = list_p[i+1]
        
        if pre >= cur > nxt:
            count += 1
        elif pre < cur < nxt:
            count += 1
        
        pre, cur = cur, nxt

    print(count)

code_for_B()

Fixed submission:
def code_for_B(test=None):

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

    pre = list_p[0]
    count = 0

    for i in range(1,n-1):
        cur = list_p[i]
        nxt = list_p[i+1]

        if pre >= cur > nxt:
            count += 1
        elif pre < cur < nxt:
            count += 1

        pre, cur = cur, nxt

    print(count)

code_for_B()
Buggy python submission (verdict: Runtime Error):

def code_for_D(test=None):

    N = int(input())

    works = [map(int, input().split()) for _ in range(N)]
    works = sorted(works, key=lambda x: x[1])

    time_now = 0
    time_by = 0
    answer = 'Yes'

    for i in range(N):
        time_now += works[0]
        time_by = works[1]
        
        if time_now > time_by:
            answer = 'No'
        
    print(answer)


def main():
    code_for_C()


if __name__ == '__main__':
    main()


Fixed submission:
def code_for_D(test=None):

    N = int(input())

    works = [list(map(int, input().split())) for _ in range(N)]
    works = sorted(works, key=lambda x: x[1])

    time_now = 0
    answer = 'Yes'

    for work in works:
        time_now += work[0]
        time_by = work[1]

        if time_now > time_by:
            answer = 'No'

    print(answer)


def main():
    code_for_D()


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split())

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

position  = 0
count = 0

for i in range(N):
    position += int(input())
    if position <+ X:
        count += 1

print(count)


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

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

position = 0
count = 1

for l in list_l:
    position += l
    if position <= X:
        count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())

S = input()

K += 1
replaced_S = S[:K] + S[K].lower() + S[K+1:]

print(replaced_S)

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

S = input()

K -= 1
replaced_S = S[:K] + S[K].lower() + S[K+1:]

print(replaced_S)
Buggy python submission (verdict: Runtime Error):
def can_be_month(n):
    if 0 < n < 13:
        return True
    return False


S = input()

if not S:
    print('NA')
elif can_be_month(S[:2]) and can_be_month(S[2:]):
    print('AMBIGUOUS')
elif can_be_month(S[:2]):
    print('MMYY')
elif can_be_month(S[2:]):
    print('YYMM')


Fixed submission:
def can_be_month(n):
    if 0 < int(n) < 13:
        return True
    return False


S = input()

if can_be_month(S[:2]) and can_be_month(S[2:]):
    print('AMBIGUOUS')
elif can_be_month(S[:2]):
    print('MMYY')
elif can_be_month(S[2:]):
    print('YYMM')
else:
    print('NA')
Buggy python submission (verdict: Runtime Error):
 def gcd(x, y):
    a = max(x, y)
    b = min(x, y)
    if b == 0:
        return a
    remainder = a % b
    if remainder == 0:
        return b
    return gcd(b, remainder)


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

left = [0]
right = [0]

for i in range(N):
    left.append(gcd(left[-1], integers[i]))
    right.append(gcd(right[-1], integers[-i-1]))

# left[0] = 0
# right[0] = 0
right.reverse()

lr = []
for i in range(N-1):
    lr.append(gcd(left[i+1], right[i+2]))

print(max(lr))


Fixed submission:
def gcd(x, y):
    a = max(x, y)
    b = min(x, y)
    if b == 0:
        return a
    remainder = a % b
    if remainder == 0:
        return b
    return gcd(b, remainder)


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

left = [0]
right = [0]

for i in range(N):
    left.append(gcd(left[-1], integers[i]))
    right.append(gcd(right[-1], integers[-i-1]))

# right.reverse()

lr = []
for i in range(N):
    lr.append(gcd(left[i], right[-i-2]))

print(max(lr))
Buggy python submission (verdict: Runtime Error):
S = input()

ns = []
n = 0
for s in S:
    if s in 'ACGT':
        n += 1
    else:
        ns.append(n)
        n = 0

print(max(ns))

Fixed submission:
S = input()

ns = [0]
n = 0

for s in S:
    if s in 'ACGT':
        n += 1
    else:
        ns.append(n)
        n = 0
ns.append(n)

print(max(ns))

Buggy python submission (verdict: Runtime Error):
S = input()

ns = []
n = 0
for s in S:
    if s in 'ACGT':
        n += 1
    else:
        ns.append(n)
        n = 0

print(max(ns))

Fixed submission:
S = input()

ns = [0]
n = 0

for s in S:
    if s in 'ACGT':
        n += 1
    else:
        ns.append(n)
        n = 0
ns.append(n)

print(max(ns))

Buggy python submission (verdict: Runtime Error):
S = input()

ns = []
for s in S:
    if s in 'ACGT':
        n += 1
    else:
        ns.append(n)
        n = 0
print(max(ns))

Fixed submission:
S = input()

ns = [0]
n = 0

for s in S:
    if s in 'ACGT':
        n += 1
    else:
        ns.append(n)
        n = 0
ns.append(n)

print(max(ns))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

array = []
for s in set(S):
    array.append(S.count(s))

len_array = len(array)

def recall(cur,t=1,total=0):
    if cur==len_array:
        return t
    for i in [array[cur],1]:
        total += recall(cur+1,t*i)
    return total

print((recall(0)-1)%(10**9+7))

Fixed submission:
N = int(input())
S = input()

mod = 10**9 + 7
alphabet = [chr(i) for i in range(97,97+26)]

ans = 1
for letter in alphabet:
    ans *= S.count(letter) + 1
    ans =  ans%mod
ans -= 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

array = []
for s in set(S):
    array.append(S.count(s))

len_array = len(array)

def recall(cur,t=1,total=0):
    if cur==len_array:
        return t
    for i in [array[cur],1]:
        total += recall(cur+1,t*i)
    return total

print((recall(0)-1)%(10**9+7))

Fixed submission:
N = int(input())
S = input()

mod = 10**9 + 7
alphabet = [chr(i) for i in range(97,97+26)]

ans = 1
for letter in alphabet:
    ans *= S.count(letter) + 1
    ans =  ans%mod
ans -= 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [s for s in input()]

array = []
for s in set(S):
    array.append(S.count(s))

len_array = len(array)

def recall(cur,t=1,total=0):
    if cur==len_array:
        return t
    for i in [array[cur],1]:
        total += recall(cur+1,t*i)
    return total

print((recall(0)-1)%(10**9+7))

Fixed submission:
N = int(input())
S = input()

mod = 10**9 + 7
alphabet = [chr(i) for i in range(97,97+26)]

ans = 1
for letter in alphabet:
    ans *= S.count(letter) + 1
    ans =  ans%mod
ans -= 1

print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int,input().split())
PNs = [list(map(int,input().split())) for _ in range(N)]
#price_and_number_of_drinks

PNs.sort(key=lambda x: x[0])

ans = 0
sum_drinks = 0 #sum of drinks which Takahashi has bought
for i in range(N):
    nos = PNs[i][1] #number of drinks at i_th shop
    nob = min(M-sum_drinks, nos) #number of drinks which he can buy at the shop
    ans += nob*PNs[i][0] #add money he spent at the shop
    sum_drinks += nob
    if s>=M: break

print(ans)


Fixed submission:
N, M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
AB = sorted(AB, key=lambda x: x[0])

ans = 0
s = 0
for i in range(N):
    t = AB[i][1]
    c = min(M-s, t)
    ans += c*AB[i][0]
    s += c
    if s>=M: break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
A,B = map(int,input().split())
l = B-A+1
ans = 0
for i in range(l):
    ans = ans^(A+i)
print(ans)

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

def xor(n):
    m = n+1
    return m//2%2 + n*(m%2)

print(xor(B)^xor(A-1))

Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().split())
L = list(range(A,B+1))

ans = 0
for l in L:
    ans = ans^l

print(ans)

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

def xor(n):
    m = n+1
    return m//2%2 + n*(m%2)

print(xor(B)^xor(A-1))
Buggy python submission (verdict: Runtime Error):
N,A,B,C = map(int, input().split())
 
bms = [int(input()) for _ in Range(N)]
 
def dfs(cur,a,b,c):
    if cur == N:
        s = abs(A-a)+abs(B-b)+abs(C-c)-30 if min(a,b,c) > 0 else 10**9
        return s
    s_0 = dfs(cur+1,a,b,c)
    s_a = dfs(cur+1,a+bms[cur],b,c) + 10
    s_b = dfs(cur+1,a,b+bms[cur],c) + 10
    s_c = dfs(cur+1,a,b,c+bms[cur]) + 10
    return min(s_0,s_a,s_b,s_c)

print(dfs(0,0,0,0))

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

bms = [int(input()) for _ in range(N)]

def dfs(cur,a,b,c):
    if cur == N:
        s = abs(A-a)+abs(B-b)+abs(C-c)-30 if min(a,b,c) > 0 else 10**9
        return s
    s_0 = dfs(cur+1,a,b,c)
    s_a = dfs(cur+1,a+bms[cur],b,c) + 10
    s_b = dfs(cur+1,a,b+bms[cur],c) + 10
    s_c = dfs(cur+1,a,b,c+bms[cur]) + 10
    return min(s_0,s_a,s_b,s_c)

print(dfs(0,0,0,0))

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

bms = [int(input()) for _ in Range(N)]

def dfs(cur,a,b,c):
    if cur == N:
        s = abs(A-a)+abs(B-b)+abs(C-c)-30 if min(a,b,c) > 0 else 10**9
        return s
    s_0 = dfs(cur+1,a,b,c)
    s_a = dfs(cur+1,a+bms[cur],b,c) + 10
    s_b = dfs(cur+1,a,b+bms[cur],c) + 10
    s_c = dfs(cur+1,a,b,c+bms[cur]) + 10
    return min(s_0,s_a,s_b,s_c)

print(dfs(0,0,0,0))

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

bms = [int(input()) for _ in range(N)]

def dfs(cur,a,b,c):
    if cur == N:
        s = abs(A-a)+abs(B-b)+abs(C-c)-30 if min(a,b,c) > 0 else 10**9
        return s
    s_0 = dfs(cur+1,a,b,c)
    s_a = dfs(cur+1,a+bms[cur],b,c) + 10
    s_b = dfs(cur+1,a,b+bms[cur],c) + 10
    s_c = dfs(cur+1,a,b,c+bms[cur]) + 10
    return min(s_0,s_a,s_b,s_c)

print(dfs(0,0,0,0))
Buggy python submission (verdict: Runtime Error):
X,T = map(int, input().split(' '))

print(f'{T/X/1.0}000')

Fixed submission:
T,X = map(int, input().split())

print(T/X+0.000001)

Buggy python submission (verdict: Runtime Error):
X,T = map.(int, input().split(' '))

input(T/X)

Fixed submission:
T,X = map(int, input().split())

print(T/X+0.000001)
Buggy python submission (verdict: Runtime Error):
X,T = map(int, input().split(' '))

print(f'{T/X/1.0}000')

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

flg = 0
for l in L:
  if not sum(L)-l > l:
    print('No')
    flg = 1

if not flg: print('Yes')

Buggy python submission (verdict: Runtime Error):
X,T = map(int, input().split(' '))

print(f'{T/X/1.0}000)

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

flg = 0
for l in L:
  if not sum(L)-l > l:
    print('No')
    flg = 1

if not flg: print('Yes')
Buggy python submission (verdict: Runtime Error):
N,M = list(map(int, input().split(' ')))
Xs = list(map(int, input().split(' ')))

Xs.sort()
L=[]
for i in range(M-1):
  L.append(Xs[i+1]-Xs[i])
  
L.sort()
print(sum(L[1-N]))

Fixed submission:
N,M = list(map(int, input().split(' ')))
Xs = list(map(int, input().split(' ')))

Xs.sort()
L=[]
for i in range(M-1):
  L.append(Xs[i+1]-Xs[i])
  
L.sort()
result = sum(L[:1-N]) if N>1 else sum(L)

print(result)
Buggy python submission (verdict: Runtime Error):
def next_num(n):
  if n%2:
    return 3*n+1
  else:
    return n/2

s = int(input())

n = s
for i in range(1000000):
  if n in [1,2,4]:
    print(i+4)
    break
  except:
    n = next_num(n)

Fixed submission:
def next_num(n):
  if n%2:
    return 3*n+1
  else:
    return n/2

s = int(input())

n = s
for i in range(1000000):
  if n in [1,2,4]:
    print(i+4)
    break
  n = next_num(n)

Buggy python submission (verdict: Runtime Error):
def next_num(n):
  if n%2:
    return 3*n+1
  else:
    return n/2

s = int(input())

n = s
for i in range(1000000):
  ind = [1,2,4].index(n)
  if n >= 0:
    print(ind+i+2)
    break
  n = next_num(n)


Fixed submission:
def next_num(n):
  if n%2:
    return 3*n+1
  else:
    return n/2

s = int(input())

n = s
for i in range(1000000):
  if n in [1,2,4]:
    print(i+4)
    break
  n = next_num(n)
Buggy python submission (verdict: Runtime Error):
N = input()
str_h = input()

fls = flowers(str_h)
ls_fls = fls.str_split0()
water = 0

while(len(ls_fls)>0):
    #print(f'ls_fls = {ls_fls}')
    temp_ls_fls = []
    for fls in ls_fls:
        if len(fls)<=2:
            water += max([int(s) for s in fls])
            continue
        else:
            _fls = flowers(' '.join(fls))
            _fls.minimize()
            _ls_fls = _fls.str_split0()
            water += _fls.water
            temp_ls_fls += _ls_fls
            flg=1
    ls_fls = temp_ls_fls
print(water)

Fixed submission:
class flowers:
    def __init__(self, str_h):
        self.str = str_h.split()
        self.int = []
        self.min = 0
        self.water = 0
        
        self.update_int()
        self.update_min()
    
    def update_str(self):
        self.str = list(map(str, self.int))
        return

    def update_int(self):
        self.int = list(map(int, self.str))
        return
    
    def update_min(self):
        self.min = min(self.int)
        return
    
    def minimize(self):
        self.int = [n-self.min for n in self.int]
        self.water += self.min
        self.update_str()
        self.min = 0
        return
    
    def str_split0(self):
        idxs = [-1] + [i for i,n in enumerate(self.int) if n==0]
        if len(idxs)==1:
            return [self.str]
        else:
            temp_ls = []
            for i in range(len(idxs)-1):
                s = self.str[idxs[i]+1:idxs[i+1]]
                if len(s)>0: temp_ls.append(s)
            if self.int[-1]!=0:
                temp_ls.append(self.str[idxs[-1]+1:])
        return temp_ls

N = input()
str_h = input()

fls = flowers(str_h)
ls_fls = fls.str_split0()
water = 0

while(len(ls_fls)>0):
    #print(f'ls_fls = {ls_fls}')
    temp_ls_fls = []
    for fls in ls_fls:
        if len(fls)<=2:
            water += max([int(s) for s in fls])
            continue
        else:
            _fls = flowers(' '.join(fls))
            _fls.minimize()
            _ls_fls = _fls.str_split0()
            water += _fls.water
            temp_ls_fls += _ls_fls
            flg=1
    ls_fls = temp_ls_fls
print(water)
Buggy python submission (verdict: Runtime Error):
N,K = map(int, input().split())
trees = [int(input()) for _ in range(N)]

trees.sort()

print(min([max_h-min_h for min_h,max_h in zip(trees,trees[K-1:])]))

Fixed submission:
D = int(input())
names = {
	25:'Christmas', 
	24:'Christmas Eve', 
	23:'Christmas Eve Eve', 
	22:'Christmas Eve Eve Eve'
  }

print(names[D])
Buggy python submission (verdict: Runtime Error):
N,K = map(int, input().split())
trees = [int(input()) for _ in range(N)]

def solve(N,K,trees):
    trees.sort()

    diffs = []
    for i,h in enumerate(trees[:N-K+1]):
        min_h = h
        max_h = trees[i+K-1]
        print(min_h,max_h)
        diffs.append(max_h-min_h)

    print(min(diffs))
return

solve(N,K,trees)

Fixed submission:
N,K = map(int, input().split())
trees = [int(input()) for _ in range(N)]

def solve(N,K,trees):
    trees.sort()

    diffs = []
    for i,h in enumerate(trees[:N-K+1]):
        min_h = h
        max_h = trees[i+K-1]
        #print(min_h,max_h)
        diffs.append(max_h-min_h)

    print(min(diffs))
    return

solve(N,K,trees)

Buggy python submission (verdict: Runtime Error):
N,K = map(int, input().split())
trees = [int(input()) for _ in range(N)]

trees.sort()

diffs = []
for i,h in trees[:N-K]:
  min_h = h
  max_h = trees[i+K]
  diffs.append(max_h-min_h)

print(min(diffs))


Fixed submission:
N,K = map(int, input().split())
trees = [int(input()) for _ in range(N)]

def solve(N,K,trees):
    trees.sort()

    diffs = []
    for i,h in enumerate(trees[:N-K+1]):
        min_h = h
        max_h = trees[i+K-1]
        #print(min_h,max_h)
        diffs.append(max_h-min_h)

    print(min(diffs))
    return

solve(N,K,trees)
Buggy python submission (verdict: Runtime Error):
N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    r = 1 if all([i in s for i in '357']) else 0
    for c in '357':
        r += dfs(s+c)
    return r

return(dfs('0'))

Fixed submission:
N = int(input())
 
def dfs(s):
    if int(s) > N:
        return 0
    r = 1 if all([i in s for i in '357']) else 0
    for c in '357':
        r += dfs(s+c)
    return r

print(dfs('0'))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
print(len([n for n in range(1,N+1,2) if set(str(n))=={'3','5','7'}]))

Fixed submission:
N = int(input())
 
def dfs(s):
    if int(s) > N:
        return 0
    r = 1 if all([i in s for i in '357']) else 0
    for c in '357':
        r += dfs(s+c)
    return r

print(dfs('0'))
Buggy python submission (verdict: Runtime Error):
N,M = map(int, input().split())
citys = [list(map(int,input().split()))+[i] for i in range(M)]

citys.sort(key = lambda x:x[1])
nums = [0]*(N+1)
states = [None]*M

for p,y,i in citys:
    nums[p] += 1
    states[i] = [str(p), str(nums[p])]

for s in states:
    print(s[0].zfill(6)+s[1].zfill(6))

Fixed submission:
X,Y = map(int, input().split())

print(int(X+Y/2))

Buggy python submission (verdict: Runtime Error):
N,M = map(int, input().split())
citys = [list(map(int,input().split()))+[i] for i in range(M)]

citys.sort(key = lambda x:x[1])
nums = [0]*(N+1)
states = [None]*(M+1)

for p,y,i in citys:
    nums[p] += 1
    states[i] = [str(p), str(nums[p])]

for s in states:
    print(s[0].zfill(6)+s[1].zfill(6))

Fixed submission:
X,Y = map(int, input().split())

print(int(X+Y/2))
Buggy python submission (verdict: Runtime Error):
ls = [abs(A-(T-x*6/1000)) for x in list_H]
ls.index(min(ls)+1)

Fixed submission:
N = int(input())
T,A = map(int, input().split())
list_H = list(map(int, input().split()))

ls = [abs(A-(T-x*6/1000)) for x in list_H]
print(ls.index(min(ls))+1)
Buggy python submission (verdict: Runtime Error):
N,M = map(int, input().split())
citys = [list(map(int,input().split()))+[i] for i in range(M)]

citys.sort(key = lambda x:x[1])
nums = [0]*(N+1)
states = [None]*(N+1)

for p,y,i in citys:
    nums[p] += 1
    states[i] = [str(p), str(nums[p])]

for s in states:
    print(s[0].zfill(6)+s[1].zfill(6))

Fixed submission:
N,M = map(int, input().split())
citys = [list(map(int,input().split()))+[i] for i in range(M)]

citys.sort(key = lambda x:x[1])
nums = [0]*(N+1)
states = [None]*M

for p,y,i in citys:
    nums[p] += 1
    states[i] = [str(p), str(nums[p])]

for s in states:
    print(s[0].zfill(6)+s[1].zfill(6))

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

citys.sort(key=lambda x: (x[0],x[1]))
states = []
for s in range(N):
    temp = list(filter(lambda x:x[0]==s+1,citys))
    states += [city+[i+1] for i,city in enumerate(temp)]

states.sort(key=lambda x: x[2])

for city in states:
    print(str(city[0]).zfill(6)+str(city[3]).zfill(6))

Fixed submission:
N,M = map(int, input().split())
citys = [list(map(int,input().split()))+[i] for i in range(M)]

citys.sort(key = lambda x:x[1])
nums = [0]*(N+1)
states = [None]*M

for p,y,i in citys:
    nums[p] += 1
    states[i] = [str(p), str(nums[p])]

for s in states:
    print(s[0].zfill(6)+s[1].zfill(6))

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

citys.sort(key=lambda x: (x[0],x[1]))
states = []
for s in range(N):
    temp = list(filter(lambda x:x[0]==s+1,citys))
    states += [city+[i+1] for i,city in enumerate(temp)]

states.sort(key=lambda x: x[2])

def zero6(n):
    return ('0'*6+str(n))[-6:]

for city in states:
    print(zero6(city[0])+zero6(city[3]))

Fixed submission:
N,M = map(int, input().split())
citys = [list(map(int,input().split()))+[i] for i in range(M)]

citys.sort(key = lambda x:x[1])
nums = [0]*(N+1)
states = [None]*M

for p,y,i in citys:
    nums[p] += 1
    states[i] = [str(p), str(nums[p])]

for s in states:
    print(s[0].zfill(6)+s[1].zfill(6))
Buggy python submission (verdict: Runtime Error):
N = int(input())
if N==1:
  print('Hello World')
else:
  A,B = map(int, input().split())
  print(A+B)

Fixed submission:
N = int(input())
if N==1:
  print('Hello World')
else:
  A,B = [int(input()) for _ in range(2)]
  print(A+B)