Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
K=int(input())
i='7'
if K%2==0 or K%5==0:
    print('-1')
else:
    for d in range(K):
        if int(i)%K==0:
            print(len(str(i)))
            break
        else:
            i+='7'

Fixed submission:

K=int(input())
i=0
if K%2==0 or K%5==0:
    print('-1')

else:
    for d in range(K):
        i=(10*i+7)%K
        if i==0:
            print(d+1)
            break

Buggy python submission (verdict: Time Limit Exceeded):
K=int(input())
i='7'
if K%2==0 or K%5==0:
    print('-1')
else:
    while True:
        if int(i)%K==0:
            print(len(str(i)))
            break
        else:
            i+='7'

Fixed submission:

K=int(input())
i=0
if K%2==0 or K%5==0:
    print('-1')

else:
    for d in range(K):
        i=(10*i+7)%K
        if i==0:
            print(d+1)
            break

Buggy python submission (verdict: Time Limit Exceeded):
K=int(input())
i='7'
if K%2==1:
    while True:
        if int(i)%K==0:
            print(len(str(i)))
            break
        else:
            i+='7'
else:
    print('-1')

Fixed submission:

K=int(input())
i=0
if K%2==0 or K%5==0:
    print('-1')

else:
    for d in range(K):
        i=(10*i+7)%K
        if i==0:
            print(d+1)
            break
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())
ans = 0
for a in range(1,K+1):
  for b in range(1, K+1):
    for c in range(1, K+1):
      ans += gcd(a,b,c)

print(ans) 

Fixed submission:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())
three = 0
six = 0
same = 0
for a in range(1,K+1):
  for b in range(a, K+1):
    for c in range(b, K+1):
      if(a != b and b != c and a != c):
        six += gcd(a,b,c)
      elif(a == b and b == c and c == a):
        same += a
      else:
        three += gcd(a,b,c)

print(six * 6 + three * 3 + same)

Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

K = int(input())
ans = 0
for a in range(1,200+1):
  for b in range(1, 200+1):
    for c in range(1, 200+1):
      ans += gcd(a,b,c) 
print(ans)

Fixed submission:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())
three = 0
six = 0
same = 0
for a in range(1,K+1):
  for b in range(a, K+1):
    for c in range(b, K+1):
      if(a != b and b != c and a != c):
        six += gcd(a,b,c)
      elif(a == b and b == c and c == a):
        same += a
      else:
        three += gcd(a,b,c)

print(six * 6 + three * 3 + same)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N,K=list(map(int, input().split())) 
P =list(map(int, input().split())) 
e = [sum([ j for j in range(1, P[i]+1)]) / P[i] for i in range(N)]
e_sum = np.cumsum(e)
ans = 0
for i in range(K-1, N):
  if(i == K-1):
    ans = e_sum[i]
  else:
    ans = max([ans, e_sum[i] - e_sum[i-K]])
print(ans)

Fixed submission:
import numpy as np
N,K=list(map(int, input().split())) 
P =list(map(int, input().split())) 
am = np.cumsum(list(range(1, 1000+1)))
e = [am[P[i]-1] / P[i] for i in range(N)]
e_sum = np.cumsum(e)
ans = 0
for i in range(K-1, N):
  if(i == K-1):
    ans = e_sum[i]
  else:
    ans = max([ans, e_sum[i] - e_sum[i-K]])
print(ans)
Buggy python submission (verdict: Runtime Error):
k,x = list(map(int, input().split()))
print("Yes" if 500*k - x >= 0 "No")

Fixed submission:
k,x = list(map(int, input().split()))
print("Yes" if 500*k - x >= 0 else "No")
Buggy python submission (verdict: Runtime Error):
import itertools
li = [1,2,3,4,5,6,7,8]
for v in itertools.combinations(li):
  print(v)

Fixed submission:
import itertools
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
li = [i for i in range(1, n+1)]
j = 1
p_index = 1
q_index = 1
for v in itertools.permutations(li, n):
  if(list(v) == p):
    p_index = j
  if(list(v) == q):
    q_index = j
  j += 1
print(abs(p_index - q_index))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
l=list(map(int, input().split()))
res = [ c for c in itertools.combinations(l,3) if c[0] < c[1] + c[2] and c[1] < c[0] + c[2] and c[2] < c[0] + c[1] ]
print(len(res))

Fixed submission:
from bisect import bisect_left
 
N = int(input())
L = list(map(int, input().split()))
 
L.sort()
ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        ans += bisect_left(L, L[i] + L[j])  - j - 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
l=list(map(int, input().split()))
res = [ c for c in itertools.combinations(l,3) if c[0] < c[1] + c[2] and c[1] < c[0] + c[2] and c[2] < c[0] + c[1] ]
print(len(res))

Fixed submission:
from bisect import bisect_left
 
N = int(input())
L = list(map(int, input().split()))
 
L.sort()
ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        ans += bisect_left(L, L[i] + L[j])  - j - 1
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
h=1
ans=0
while h<b:
    h-=1
    h+=a
    ans+=1
print(ans)

Fixed submission:
import numpy as np
n = int(input())
h = list(map(int, input().split()))
h_diff = np.diff(h)
li = [[]]
for i in range(n-1):
  if(h_diff[i] > 0):
    li.append([])
  else:
    li[-1].append("s")
tmp = 0
for arr in li:
  if(tmp <= len(arr)):
    tmp = len(arr)
print(tmp)
Buggy python submission (verdict: Runtime Error):
n = int(input())
arr = list(map(int, input().split()))
for i in range(n, 1, -1):
  if(arr[i-1] <= arr[i]):
    a = 1
  else:
    if(arr[i-1] - 1 > arr[i]):
      print("No")
      exit()
    else:
      arr[i-1] = arr[i - 1] - 1
if(sorted(arr) == arr):
  print("Yes")
else:
  print("No")

Fixed submission:
n = int(input())
arr = list(map(int, input().split()))
for i in range(n-1, 1, -1):
  if(arr[i-1] <= arr[i]):
    a = 1
  else:
    if(arr[i-1] - 1 > arr[i]):
      print("No")
      exit()
    else:
      arr[i-1] = arr[i - 1] - 1
if(sorted(arr) == arr):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for num in range(n):
	a.append(int(input()))
for num in range(n):
	temp = a.copy()
	del temp[num]
	print(max(temp))


Fixed submission:
n = int(input())
a = []
first = 0
second = 0
for num in range(n):
	hoge = int(input())
	a.append(hoge)
	if hoge >= first:
		second = first
		first = hoge
	elif second <= hoge and hoge <= first:
		second = hoge

#print(first, second)
for num in range(n):
	if(first <= a[num]):
		print(second)
	else:
		print(first)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
for num in range(n):
	a.append(int(input()))

for num in range(n):
	temp = a.copy()
	del temp[num]
	print(max(temp))

Fixed submission:
n = int(input())
a = []
first = 0
second = 0
for num in range(n):
	hoge = int(input())
	a.append(hoge)
	if hoge >= first:
		second = first
		first = hoge
	elif second <= hoge and hoge <= first:
		second = hoge

#print(first, second)
for num in range(n):
	if(first <= a[num]):
		print(second)
	else:
		print(first)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
for num in range(n):
  a.append(int(input()))

for num in range(n):
  temp = a.copy()
  del temp[num]
  print(max(temp))

Fixed submission:
n = int(input())
a = []
first = 0
second = 0
for num in range(n):
	hoge = int(input())
	a.append(hoge)
	if hoge >= first:
		second = first
		first = hoge
	elif second <= hoge and hoge <= first:
		second = hoge

#print(first, second)
for num in range(n):
	if(first <= a[num]):
		print(second)
	else:
		print(first)
Buggy python submission (verdict: Runtime Error):
import math
n,d = map(int, input().split())
x = []
for fuga in range(n):
	x.append(list(map(int, input().split())))

cnt = 0
for i in range(n - 1):
	for j in range(i+1, n):
		hoge = 0
		for num in range(d):
			hoge = hoge + pow(abs(x[i][num] - x[j][num]),2)
			if(hoge == pow(int(math.sqrt(hoge)), 2)):
			cnt = cnt + 1
print(cnt)

Fixed submission:
import math

n,d = map(int, input().split())
x = []
for num in range(n):
  x.append(list(map(int, input().split())))

cnt = 0
for i in range(n - 1):
  for j in range(i+1, n):
    hoge = 0
    for num in range(d):
      hoge = hoge + pow(abs(x[i][num] - x[j][num]),2)
    if(hoge == pow(int(math.sqrt(hoge)), 2)):
       cnt = cnt + 1
print(cnt)

Buggy python submission (verdict: Runtime Error):
n,d = map(int, input().split())
x = []
for num in range(n):
    x.append(list(map(int, input().split())))

cnt = 0
for i in range(n - 1):
    for j in range(i+1, n):
        hoge = 0
        for num in range(d):
            hoge = hoge + pow(abs(x[i][num] - x[j][num]),2)
            if(hoge == pow(int(math.sqrt(hoge)), 2)):
                cnt = cnt + 1
print(cnt)

Fixed submission:
import math

n,d = map(int, input().split())
x = []
for num in range(n):
  x.append(list(map(int, input().split())))

cnt = 0
for i in range(n - 1):
  for j in range(i+1, n):
    hoge = 0
    for num in range(d):
      hoge = hoge + pow(abs(x[i][num] - x[j][num]),2)
    if(hoge == pow(int(math.sqrt(hoge)), 2)):
       cnt = cnt + 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
n = input()
d = list(map(int,input().split()))
d.sort()
print(d[int(n / 2)] - d[int(n/2) -1])


Fixed submission:
n = int(input())
d = list(map(int,input().split()))
d.sort()
print(d[int(n / 2)] - d[int(n/2) -1])

Buggy python submission (verdict: Runtime Error):
n = input()
d = list(map(int,input().split()))
d.sort()
print(d[int(n / 2)] - d[int(n/2) -1 ])


Fixed submission:
n = int(input())
d = list(map(int,input().split()))
d.sort()
print(d[int(n / 2)] - d[int(n/2) -1])
Buggy python submission (verdict: Runtime Error):
import re
s = input()
pattern = r"\d{2}"
if(!re.match(pattern, s)):
  print("Yes")
else:
  print("No")

Fixed submission:
import re
s = input()
pattern = r"(00|11|22|33|44|55|66|77|88|99)"
if(re.search(pattern, s)):
	print("Bad")
else:
	print("Good")

Buggy python submission (verdict: Runtime Error):
import re
s = input()
if(s.match(r"\d{2}")):
  print("Yes")
else:
  print("No")

Fixed submission:
import re
s = input()
pattern = r"(00|11|22|33|44|55|66|77|88|99)"
if(re.search(pattern, s)):
	print("Bad")
else:
	print("Good")

Buggy python submission (verdict: Runtime Error):
s = input()
if(s.match(r"\d{2}")):
  print("Yes")
else:
  print("No")

Fixed submission:
import re
s = input()
pattern = r"(00|11|22|33|44|55|66|77|88|99)"
if(re.search(pattern, s)):
	print("Bad")
else:
	print("Good")
Buggy python submission (verdict: Runtime Error):
n, x = list(map(int, input().split()))
li = list(map(int, input().split()))
d = []
d.append(0)
for l in li:
  d.append(d[-1] + l)
cnt = 0
for hoge in d:
  if(hoge <= d):
    cnt = cnt + 1
print(cnt)

Fixed submission:
n, x = list(map(int, input().split()))
li = list(map(int, input().split()))
d = []
d.append(0)
for l in li:
  d.append(d[-1] + l)
cnt = 0
for hoge in d:
  if(hoge <= x):
    cnt = cnt + 1
print(cnt)

Buggy python submission (verdict: Runtime Error):
n, x = list(map(int, input().split()))
li = list(map(int, input().split()))
d = []
d.append(0)
for l in li:
	d.append(d[-1] + l)
cnt = 0
for hoge in d:
  if(hoge <= d):
    cnt = cnt + 1
print(cnt)

Fixed submission:
n, x = list(map(int, input().split()))
li = list(map(int, input().split()))
d = []
d.append(0)
for l in li:
  d.append(d[-1] + l)
cnt = 0
for hoge in d:
  if(hoge <= x):
    cnt = cnt + 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
s = map(int, input().split())
s.sort()
print(s[0] + s[1])


Fixed submission:
a = [int(_) for _ in input().split()] 
a.sort()
print(a[0] + a[1])
Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
w = np.array(list(map(int, input().split())))
w_amount = w.cumsum()
w_reverse_amount = w[::-1].cumsum()[::-1]

res = abs(w_amount[0] - w_reverse_amount[0])
min_index = 0
for i in range(n):
  if(res => abs(w_amount[i] - w_reverse_amount[i])):
    res = abs(w_amount[i] - w_reverse_amount[i])
    min_index = i
print(i+1)

Fixed submission:
import numpy as np
n = int(input())
w = np.array(list(map(int, input().split())))
w_amount = w.cumsum()
w_reverse_amount = w[::-1].cumsum()[::-1]
res = abs(w_amount[0] - w_reverse_amount[1])
min_index = 0
for i in range(n-1):
  if(res >= abs(w_amount[i] - w_reverse_amount[i+1])):
    res = abs(w_amount[i] - w_reverse_amount[i+1])
print(res)
Buggy python submission (verdict: Runtime Error):
n = int(input())
r = []
for i in range(1, n+1):
  hoge = list(map(int, input().split()))
  hoge.append(i)
  r.append(hoge) 
tmp = sorted(r, key=lambda x:x[1], reverse=True)
res = sorted(tmp, key=lambda x:x[0])
for arr in res:
  print(arr[2])

Fixed submission:
n = int(input())
r = []
for i in range(1, n+1):
  hoge = input().split()
  hoge.append(i)
  r.append(hoge) 
tmp = sorted(r, key=lambda x:int(x[1]), reverse=True)
res = sorted(tmp, key=lambda x:x[0])
for arr in res:
  print(arr[2])

Buggy python submission (verdict: Runtime Error):
n = int(input())
for i in range(1, n+1):
  hoge = list(map(int, input().split()))
  hoge.append(i)
  r.append(hoge) 
tmp = sorted(r, key=lambda x:x[1], reverse=True)
res = sorted(tmp, key=lambda x:x[0])
for arr in res:
  print(arr[2])

Fixed submission:
n = int(input())
r = []
for i in range(1, n+1):
  hoge = input().split()
  hoge.append(i)
  r.append(hoge) 
tmp = sorted(r, key=lambda x:int(x[1]), reverse=True)
res = sorted(tmp, key=lambda x:x[0])
for arr in res:
  print(arr[2])

Buggy python submission (verdict: Runtime Error):
n = int(input())
r = [list(map(int, input().split())).append(i+1) for i in range(n)] 
tmp = sorted(r, key=lambda x:x[1], reverse=True)
res = sorted(tmp, key=lambda x:x[0])
for arr in res:
  print(arr[2])

Fixed submission:
n = int(input())
r = []
for i in range(1, n+1):
  hoge = input().split()
  hoge.append(i)
  r.append(hoge) 
tmp = sorted(r, key=lambda x:int(x[1]), reverse=True)
res = sorted(tmp, key=lambda x:x[0])
for arr in res:
  print(arr[2])

Buggy python submission (verdict: Runtime Error):
n = int(input())
r = [list(map(int, input().split())).append(i+1) for i in range(n)] 
tmp = sorted(data, key=lambda x:x[1], reverse=True)
res = sorted(tmp, key=lambda x:x[0])
for arr in res:
  print(arr[2])

Fixed submission:
n = int(input())
r = []
for i in range(1, n+1):
  hoge = input().split()
  hoge.append(i)
  r.append(hoge) 
tmp = sorted(r, key=lambda x:int(x[1]), reverse=True)
res = sorted(tmp, key=lambda x:x[0])
for arr in res:
  print(arr[2])
Buggy python submission (verdict: Runtime Error):
n, k = list(map(int, input().split()))
s = input()
s[k-1] = s[k-1].upper()
print(s)

Fixed submission:
n, k = list(map(int, input().split()))
s = list(input())
s[k-1] = s[k-1].lower()
print("".join(s))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

H, W = map(int, input().split())
grid = [input() for i in range(H)]

# 初期の黒('#')の位置からの距離
dist = [[-1]*W for _ in range(H)]

# '#'の位置をキューに追加（＝今回はこれが複数あるので、複数スタートとなる）
black_cells = deque()
for h in range(H):
    for w in range(W):
        if grid[h][w] == '#':
            black_cells.append((h, w))
            dist[h][w] = 0

def bfs(black_cells, dist):
    """
    BFSを用いて、全マス目を黒くする回数を求める

    Args:
        black_cells: 「開始時の黒マス」の座標が入ったキュー（複数座標あり）
        dist: 「開始時の黒マス」からの距離の入ったリスト  [[-1, -1, 0], ...]
        　　　（白マスの初期値は0）

    Returns:
        g: 操作を繰り返した数
    """
    d = 0
    while black_cells:
        # キューとして使うのでpop()ではなくpopleft()
        h, w = black_cells.popleft()
        d = dist[h][w]
        for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            new_h = h + dy
            new_w = w + dx
            if new_h < 0 or H <= new_h or new_w < 0 or W <= new_w:
                continue
            if dist[new_h][new_w] == -1:  # セルが白('.')であるのと同義
                dist[new_h][new_w] = d+1
                black_cells.append((new_h, new_w))
    return d

d = bfs(black_cells, dist)
print(d)


Fixed submission:
from collections import deque

H, W = map(int, input().split())
grid = [input() for i in range(H)]

# 初期の黒('#')の位置からの距離
dist = [[-1]*W for _ in range(H)]

# '#'の位置をキューに追加（＝今回はこれが複数あるので、複数スタートとなる）
black_cells = deque()
for h in range(H):
    for w in range(W):
        if grid[h][w] == '#':
            black_cells.append((h, w))
            dist[h][w] = 0

def bfs(black_cells, dist):
    """
    BFSを用いて、全マス目を黒くする回数を求める

    Args:
        black_cells: 「開始時の黒マス」の座標が入ったキュー（複数座標あり）
        dist: 「開始時の黒マス」からの距離の入ったリスト  [[-1, -1, 0], ...]
        　　　（白マスの初期値は0）

    Returns:
        g: 操作を繰り返した数
    """
    d = 0
    while black_cells:
        # キューとして使うのでpop()ではなくpopleft()
        h, w = black_cells.popleft()
        d = dist[h][w]
        for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            new_h = h + dy
            new_w = w + dx
            if new_h < 0 or H <= new_h or new_w < 0 or W <= new_w:
                continue
            if dist[new_h][new_w] == -1:  # セルが白('.')であるのと同義
                dist[new_h][new_w] = d+1
                black_cells.append((new_h, new_w))
    return d

d = bfs(black_cells, dist)
print(d)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0
while(True):
  zero_one = s.count("01")
  one_zero = s.count("10")
  if(zero_one == 0 and one_zero == 0):
    break
  if(zero_one > one_zero):
    ans += zero_one
    s = s.replace('01',"")
  else:
    ans += one_zero
    s = s.replace('10',"")
print(ans*2)

Fixed submission:
s = input()
print(2 * min([s.count("0"), s.count("1")]))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0
while(True):
  zero_one = s.count("01")
  one_zero = s.count("10")
  if(zero_one == 0 and one_zero == 0):
    break
  if(zero_one > one_zero):
    ans += zero_one
    s = s.replace('01',"")
  else:
    ans += one_zero
    s = s.replace('10',"")
print(ans*2)

Fixed submission:
s = input()
print(2 * min([s.count("0"), s.count("1")]))
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(map(int, input().split()))
l2 = l.copy()

l.sort(reverse=True)
l2.sort()
for num in range(n):
	if(l[0] > sum(l2[:n])):
  		print("Yes")
		break
print("No")


Fixed submission:
n = int(input())
l = list(map(int, input().split()))
 
l.sort(reverse=True)
if(l[0] < sum(l[1:n])):
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(map(int, input().split()))
l2 = l.copy()

l.sort(reverse=True)
l2.sort()
for num in range(n):
	if(l[0] > sum(l2[1:n])):
  		print("Yes")
		break
print("No")


Fixed submission:
n = int(input())
l = list(map(int, input().split()))
 
l.sort(reverse=True)
if(l[0] < sum(l[1:n])):
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(map(int, input().split()))
l2 = l.copy()

l.sort(reverse=True)
l2.sort()
for num in range(n)
	if(l[0] > sum(l2[1:n])):
  		print("Yes")
		break
print("No")


Fixed submission:
n = int(input())
l = list(map(int, input().split()))
 
l.sort(reverse=True)
if(l[0] < sum(l[1:n])):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
def f(n):
  if(n % 2 == 0):
    return n // 2
  else:
    return (3 * n) + 1
N = int(input())
 
test = set(N)
before = N
for i in range(1, 10**6 + 1):
  current = f(before)
  if(current in test):
    print(i+1)
    exit()
  before = current
  test.add(current)


Fixed submission:
def f(n):
  if(n % 2 == 0):
    return n // 2
  else:
    return (3 * n) + 1
N = int(input())
 
test = set([N])
before = N
for i in range(1, 10**6 + 1):
  current = f(before)
  if(current in test):
    print(i+1)
    exit()
  before = current
  test.add(before)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = list(map(int, input().split()))
org = list(map(int, input().split()))
h = [10**10 for _ in range(n+k+1)]
for i in range(n):
  h[i] = org[i] 
dp = [10**10 for _ in range(n+k+1)]

dp[0] = 0
for i in range(n):
  for j in range(1, k+1):
    dp[i+j] = min([dp[i+j], dp[i] + abs(h[i] - h[i+j])])
print(dp[n-1])

Fixed submission:
n,k = list(map(int, input().split()))
org = list(map(int, input().split()))
h = [10**10 for _ in range(n+k+1)]
for i in range(n):
  h[i] = org[i] 
dp = [10**10 for _ in range(n+k+1)]

dp[0] = 0
for i in range(n):
  for j in range(1, k+1):
    dp[i+j] = min([dp[i+j], dp[i] + abs(h[i] - h[i+j])])
print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
n,m = list(map(int, input().split()))
cities = defaultdict(list)
cities = [ list(map(int, input().split())) for _ in range(m)]
sorted = sorted(
  cities,
  key = lambda x: (x[0], x[1])
)
hoge = 0
first_code = 0
fuga = 0
second_code = 0
for city in sorted:
  if(hoge < city[0]):
    hoge = city[0]
    first_code += 1
    fuga = 0
    seconde_code = 0
  if(fuga < city[1]):
    fuga = city[1]
    seconde_code += 1    
  print(format(first_code, '06'), format(second_code, '06'),sep="")

Fixed submission:
from collections import defaultdict
import heapq
n_pref, m_city = list(map(int, input().split()))
record = defaultdict(list)
cities = []
for i in range(m_city):
  pref, year = list(map(int, input().split()))
  cities.append({"pref": pref, "year": year})
  heapq.heappush(record[pref], year)
res = defaultdict(dict)
for key ,value in record.items():
  for i in range(1, len(value) + 1):
    res[key][heapq.heappop(value)] = i
for city in cities:
  print(format(city["pref"], '06d'), format(res[city["pref"]][city["year"]], '06d'), sep="")
Buggy python submission (verdict: Runtime Error):
a, b = list(map(int, input()))
print((a-1)*(b-1))

Fixed submission:
a, b = list(map(int, input().split()))
print((a-1)*(b-1))
Buggy python submission (verdict: Runtime Error):
def calc(x):
  ret = 0
  while x % 100 == 0:
    x /= 100
	ret += 1
	return ret

d, n = list(map(int, input().split()))
cnt = 0
val = 0
while cnt < n:
  val +=1
  if(calc(val) == D):
    cnt+=1
  print(val)
  return


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

while True:
  if(d == 0 and i % 100 != 0):
    cnt += 1    
  if(d != 0 and i % (100 ** d) == 0 and i % (100 ** (d+1)) != 0):
    cnt += 1
  if(cnt == n):
    print(i)
    exit()
  i += 1

Buggy python submission (verdict: Runtime Error):
D,N = list(map(int, input().split()))
print(n * (100 ** D))

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

while True:
  if(d == 0 and i % 100 != 0):
    cnt += 1    
  if(d != 0 and i % (100 ** d) == 0 and i % (100 ** (d+1)) != 0):
    cnt += 1
  if(cnt == n):
    print(i)
    exit()
  i += 1
Buggy python submission (verdict: Runtime Error):
def hoge(num):
  for i in range(num):
    if(num % (2 * i) != 0):
      return i
n = int(input())
print(sum(list(map(lambda x: hoge(int(x)), input().split()))))


Fixed submission:
def hoge(num):
  for i in range(10**10):
    if(num % (2 ** i) != 0):
      return i - 1
    
n = int(input())
print(sum(list(map(lambda x: hoge(int(x)), input().split()))))