Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02684 (python)

Fixed submission:
def main():

    N_machi, K_teleport = map(int, input().split())
    to_teleport = list(map(int, input().split()))

    visited_city = [1]
    order = [-1 for i in range(N_machi + 1)]
    order[1] = 0
    next_city = 1
    
    for i in range(N_machi):
        next_city = to_teleport[next_city - 1]
        tmp = order[next_city]
        
        if (tmp == -1):
            visited_city.append(next_city)
            order[next_city] = i + 1
        else:
            break
    
    first = order[next_city]
    len_loop = len(visited_city) - first
    
    if (K_teleport < first):
        ans = visited_city[K_teleport]
    else:
        mod = (K_teleport - first) % len_loop
        ans = visited_city[first + mod]
    
    print(ans)
        

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():

    N_ko, K_kai = map(int, input().split())
    teleport = list(map(int, input().split()))

    index = 0
    ctr = 0
    before_ctr = 0

    Visited = []
    Visited.append(ctr)

    for i in range(N_ko + 1):

        ctr += 1
        index = teleport[index] - 1
        Visited.append(index)
        
        if (index == 0):
            FLAG = 1
            break

        if (len(Visited) != len(set(Visited))):
            FLAG = 0
            break


    if (FLAG):
        mod = K_kai % ctr
        city = 0

        for i in range(mod):
            city = teleport[city] - 1

        ans = city + 1

    # else:
    #     cnt = 0
    #     before_ctr = 0

    #     for i in range(N_ko + 1):
    #         cnt += 1
    #         current_index = teleport[index] - 1
            
    #         if (current_index == index):
    #             before_ctr = cnt
    #             break
        
    #     if (K_kai < ctr):
    #         city = 0
            
    #         for i in range(K_kai):
    #             city = teleport[city] - 1

    #         ans = city + 1

    #     else:
    #         ans = (K_kai - before_ctr) % (ctr - before_ctr)
    #         ans += 1
            

    print(ans)


if __name__ == '__main__':
    main()
Problem p02696 (python)

Fixed submission:
import math

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

ans_x = min(N, B - 1)
ans = math.floor(A * ans_x / B) - A * math.floor(ans_x / B)

print(ans)

Buggy submission (verdict: Runtime Error):
def main():
    import math

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

    if (N >= B):
        syou = N // B
    else:
        syou = 0

    if (syou == N / B):
        a=1
        ## ans = syou * (A - 1) + 1
        # ans = math.floor(A * syou) - A * syou
        # ans = syou * (A - 1)

    else:
        ans = syou * (A - 1)
        mod = N / B - N // B
        y = 1 - mod
        cnt = 0
        for i in range(1, A):
            num = i / A
            if (num > y):
                cnt = A - i
                break
        ans += cnt

    print(ans)

if __name__ == '__main__':
    main()
Problem p02702 (python)

Fixed submission:
def main():
    import collections

    S = input()

    mod_list = [0]

    for i in range(len(S)):
        index = len(S) - i - 1
        num = int(S[index])

        mod_list.append((mod_list[-1] + num * pow(10, i, 2019)) % 2019)

    CTR_mod_list = collections.Counter(mod_list).most_common()
    cnt = 0

    for i in range(len(CTR_mod_list)):
        n = CTR_mod_list[i][1]

        if (n == 1):
            break

        cnt += n * (n - 1) // 2

    print(cnt)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    S = sys.stdin.readline()[:-1]

    S = input()
    int_S = int(S)
    N = len(S)
    cnt = 0
    pos_l = 0
    pos_r = 0


    while (True):
        pos_r +=  + 1
        
        if (pos_r < N):
            tmp = int(S[pos_l: pos_r + 1])
            if (tmp % 2019 == 0):
                cnt += 1
                pos_l = pos_r
        else:
            pos_l += 1
        
        if (pos_l >= N):
            break


    print(cnt)

if __name__ == '__main__':
    main()
Problem p02714 (python)

Fixed submission:
import collections

N = int(input())
S = list(input())

CNT_S = collections.Counter(S)

cnt_r = CNT_S['R']
cnt_b = CNT_S['B']
cnt_g = CNT_S['G']

total = cnt_r * cnt_g * cnt_b
subdu = 0


for pos in range(N):
    for i in range(1, N):
    
        index_r = pos
        index_m = pos + i
        index_l = pos + 2 * i
        
        if (index_l < N and index_m < N and index_r < N):
            if (S[index_l] != S[index_m] and S[index_l] != S[index_r] and S[index_m] != S[index_r]):
                subdu += 1


ans = total - subdu

print(ans)

Buggy submission (verdict: Runtime Error):
def main():
 
  import sys
  input() = sys.stdin.readline()[:-1]
  
  import collections
 
  N = int(input())
  S = list(input())
 
  CNT_S = collections.Counter(S)
 
  cnt_r = CNT_S['R']
  cnt_b = CNT_S['B']
  cnt_g = CNT_S['G']
 
  total = cnt_r * cnt_g * cnt_b
  subdu = 0
 
 
  for pos in range(N):
      for i in range(1, N):
 
          index_r = pos
          index_m = pos + i
          index_l = pos + 2 * i
 
          if (index_l < N and index_m < N and index_r < N):
              if (S[index_l] != S[index_m] and S[index_l] != S[index_r] and S[index_m] != S[index_r]):
                  subdu += 1
 
 
  ans = total - subdu
 
  print(ans)
  
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import collections
 
N = int(input())
S = list(input())
 
CNT_S = collections.Counter(S)
 
cnt_r = CNT_S['R']
cnt_b = CNT_S['B']
cnt_g = CNT_S['G']
 
total = cnt_r * cnt_g * cnt_b
subdu = 0
 
 
for pos in range(N):
    for i in range(1, N):
    
        index_r = pos
        index_m = pos + i
        index_l = pos + 2 * i
        
        if (index_l < N and index_m < N and index_r < N):
            if (S[index_l] != S[index_m] and S[index_l] != S[index_r] and S[index_m] != S[index_r]):
                subdu += 1
 
 
ans = total - subdu
 
print(ans)
Problem p02756 (python)

Fixed submission:
from collections import deque

S = deque(input())
Q = int(input())
reverse = 1


for i in range(Q):
    
    q = input()
    
    if (q == '1'):
        reverse *= -1
    else:
        integer, judge, cha = q.split()
        
        if (judge == '1'):
            if (reverse == 1):
                S.appendleft(cha)
            else:
                S.append(cha)
        
        elif (judge == '2'):
            if (reverse == 1):
                S.append(cha)
            else:
                S.appendleft(cha)

if (reverse == -1):
    S.reverse()

print(''.join(list(S)))

Buggy submission (verdict: Runtime Error):
from collections import deque

S = deque(input())
Q = int(input())
reverse = 1


for i in range(Q):
    
    q = input()
    
    if (q == 1):
        reverse *= -1
    else:
        integer, judge, cha = q.split()
        
        if (judge == '1'):
            if (reverse == 1):
                S.appendleft(cha)
            else:
                S.append(cha)
        elif (judge == '2'):
            if (reverse == -1):
                S.append(cha)
            else:
                S.appendleft(cha)

if (reverse == -1):
    S.reverse()

print(''.join(list(S)))

Buggy submission (verdict: Runtime Error):
S = input()
Q = int(input())
 
for i in range(Q):
    q = list(input().split())
 
    if (len(q) == 1):
        S = S[::-1]
    else:
        judge = q[1]
        cha = q[2]
        
        if (int(judge) == 1):
            S = cha + S
        else:
            S = S + cha
 
print(S)
Problem p02761 (python)

Fixed submission:
N_keta, M_ko = map(int, input().split())
conditions = [list(map(int, input().split())) for i in range(M_ko)]

answers = []

for num in range(0, 10 ** N_keta):

    judge = True
    str_num = str(num)
    
    if (len(str_num) != N_keta):
        judge = False
        continue

    
    for i in range(M_ko):
        keta, n = conditions[i]
        keta -= 1

        if (keta + 1 > len(str_num)):
            judge = False
            break

        elif (str_num[keta] != str(n)):
            judge = False
            break
    
    if (judge):
        answers.append(num)

print(-1 if (len(answers) == 0) else min(answers))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
number = [0 for i in range(N)]
judge = []


for i in range(M):
    keta, num = map(int, input().split())
    keta -= 1
    judge.append(keta)

    if (len(judge) != len(set(judge))):
        ans = -1
    else:
        number[keta] = num

if (number[0] == 0):
    ans = -1
else:
    ans = str(number[0]) + str(number[1]) + str(number[2])
    ans=int(ans)

print(ans)
Problem p02789 (python)

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

if (N==M):
    print('Yes')
else :
    print('No')

Buggy submission (verdict: Runtime Error):
import numpy as np

N = int(input())
Ps = list(map(int, input().split()))
Ps = np.array(Ps)
count = 0

for i in xrange(N):
    low = Ps[i]
    if ( np.sum(Ps[:i] < low) == 0):
        count += 1

print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
Ps = list(map(int, input().split()))
count = 0
low = -1

for i in range(N):
    low = Ps[i]

    if ( sum(x < low for x in Ps[:i]) == 0):
        count += 1

print(count)
Problem p02791 (python)

Fixed submission:
N = int(input())
Ps = list(map(int, input().split()))
count = 0
min = Ps[0]+1

for i in range(N):
    if (Ps[i] < min):
        min = Ps[i]
        count += 1

print(count)

Buggy submission (verdict: Runtime Error):
import numpy as np

N = int(input())
Ps = list(map(int, input().split()))
Ps = np.array(Ps)
count = 0

for i in range(N):
    low = Ps[i]
    if ( np.sum(Ps[:i] < low) == 0):
        count += 1

print(count)

Buggy submission (verdict: Runtime Error):
import numpy as np
from numba import double
from numba.decorators import jit

N = int(input())
Ps = list(map(int, input().split()))
Ps = np.array(Ps)
count = 0

@jit
for i in range(N):
    low = Ps[i]
    if ( np.sum(Ps[:i] < low) == 0):
        count += 1

print(count)
Problem p02812 (python)

Fixed submission:
N = int(input())
S = input()
ctr = ptr = 0

def count_ABC(pos, count):
    if (S[pos]=='A' and S[pos+1]=='B' and S[pos+2]=='C'):
        count += 1
        pos += 3
    else :
        pos += 1
    
    return(pos, count)

while (ptr < (N-2)):
    ptr, ctr = count_ABC(ptr, ctr)

print(ctr)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
ctr = ptr = 0

def count_ABC(pos, count):
    if (S[pos]=='A' and S[pos+1]=='B' and S[pos+2]=='C'):
        count += 1
        pos += 3
    else :
        pos += 1
    
    return(pos, count)

while (ptr <= (N-2)):
    ptr, ctr = count_ABC(ptr, ctr)

print(ctr)
Problem p02817 (python)

Fixed submission:
s = input()
ls = s.split()
print(ls[1] + ls[0])

Buggy submission (verdict: Runtime Error):
str1, str2 = input().strip()

print("".join((str1,str2)))

Buggy submission (verdict: Runtime Error):
Str1, str2 = input().split()
print(str1+str2)

Buggy submission (verdict: Runtime Error):
    def print_character(str1, str2):
      str outputWord
      outputWord = str1 + str2
      print(outputWord)

Buggy submission (verdict: Runtime Error):
def print_character(str1, str2):
  str outputWord
  outputWord = str1 + str2
  return(outputWord)
Problem p02844 (python)

Fixed submission:
def main():
    N_keta = int(input())
    S = input()

    total = 0

    for n in range(0, 1000):
        FLAG = True
        n_str = "{:03}".format(n)
        pos = 0
        
        for i in n_str:
            numberS = S[pos:]
            if (i not in numberS):
                FLAG = False
                break
            else:
                pos += numberS.index(i) + 1
        
        if (FLAG):
            total += 1

    print(total)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N_keta = int(input())
    S = input()

    total = 0

    for n in range(0, 1000):
        FLAG = False
        n_str = str(n)
        
        while (len(n_str) < 3):
            n_str = '0' + n_str
        
        pos = 0
        cnt = 0
        
        for i in range(3):
            number = int(n_str[i])
            
            while (pos < N_keta):
                num = int(S[pos])
                if (num == number):
                    cnt += 1
                    pos += 1
                    break
                else:
                    pos += 1
            
            if (cnt == 3):
                FLAG = True
                break
        
        if (FLAG):
            total += 1

    print(total)


if __name__ == '__main__':
    main()
Problem p03106 (python)

Fixed submission:
import fractions

A, B, K_ban = map(int, input().split())

gc = fractions.gcd(A, B)
ctr = 1

while (gc > 0):

    if (A % gc == 0 and B % gc == 0):
        
        if (ctr == K_ban):
            print(gc)
            break
        else:
            ctr += 1
    
    gc -= 1

Buggy submission (verdict: Runtime Error):
import math

A, B, K_ban = map(int, input().split())

gc = math.gcd(A, B)
ctr = 1

while (gc > 0):

    if (A % gc == 0 and B % gc == 0):
        
        if (ctr == K_ban):
            print(gc)
            break
        else:
            ctr += 1
    
    gc -= 1
Problem p03282 (python)

Fixed submission:
S = input()
K = int(input())
num = 0

for i in range(len(S)):
    num = int(S[i])
    if (num != 1):
        num = i
        break

if (S[0] == '1' and K - 1 < num):
    ans = 1
elif (S[0] == '1'):
    ans = S[num]
else:
    ans = S[0]

print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
num = 0

for i in range(len(S)):
    num = int(S[i])
    if (num != 1):
        num = i
        break

if (S[0] == '1'):
    ans = S[num]
else:
    ans = S[0]

print(ans)
Problem p03469 (python)

Fixed submission:
s_17 = list(input())
s_18 = ''

for s in range(len(s_17)):
    if (s == 3):
        s_18 += '8'
    else:
        s_18 += s_17[s]

print(s_18)

Buggy submission (verdict: Runtime Error):
s_17 = input()
# print(s_17)
s_17[3] = 8
print(*s_17)
Problem p03633 (python)

Fixed submission:
import fractions

N = int(input())
times = [int(input()) for i in range(N)]

gcdd = 1

for i in range(N):
    num = times[i]
    gcdd = gcdd * num // (fractions.gcd(gcdd, num))


print(gcdd)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
times = [int(input()) for i in range(N)]

gcdd = 1

for i in range(N):
    num = times[i]
    gcdd = gcdd * num // (math.gcd(gcdd, num))


print(gcdd)
Problem p03136 (python)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
print("Yes" if sum(l) - max(l) > max(l) else "No")

Buggy submission (verdict: Runtime Error):
n = int(input())
l = map(int,input().split())
print("Yes" if sum(l) - max(l) > max(l) else "No")

Buggy submission (verdict: Runtime Error):
n = int(input())
l = [int(input()) for i in range(n)]
print("Yes" if (sum(l) - max(l)) > max(l) else "No")

Buggy submission (verdict: Runtime Error):

n = int(input())
l = [int(input()) for i in range(n)]
print("Yes" if sum(l) - max(l) > max(l) else "No")
Problem p03292 (python)

Fixed submission:
a,b,c = sorted(map(int,input().split()))
print(c-a)

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input())
print(c-a)
Problem p02767 (python)

Fixed submission:
N = int(input())
X1 = list(map(int, input().split()))
ans = []
if N == 1:
    print(0)
    exit()
    
if min(X1) == max(X1):
    print(0)
    exit()
    
for p in range(min(X1), max(X1)):
    num = 0
    for i in range(N):
        num += (X1[i] - p)*(X1[i] - p)
        
    ans.append(int(num))

print(min(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
X1 = list(map(int, input().split()))
ans = []
if N == 1:
    print(0)
    exit()
    
for p in range(min(X1), max(X1)):
    num = 0
    for i in range(N):
        num += (X1[i] - p)*(X1[i] - p)
        
    ans.append(int(num))


print(min(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
X1 = list(map(int, input().split()))
ans = []
for p in range(min(X1), max(X1)):
    poi = 0
    for i in range(N):
        poi += (X1[i] - p)*(X1[i] - p)
        
    ans.append(int(poi))


print(min(ans))
Problem p03544 (python)

Fixed submission:
n = int(input())
l = [2, 1]
for i in range(n-1):
    L = l[i] + l[i+1]
    l.append(L)
print(l[n])

Buggy submission (verdict: Runtime Error):
n = int(input())
l = [2, 1]
for i in range(n-1):
    L = l[i] + l[i+1]
    l.append(L)
print(L)
Problem p02579 (python)

Fixed submission:
from collections import deque
h, w = map(int ,input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
ch -= 1
cw -= 1
dh -= 1
dw -= 1

s = []
for i in range(h):
  t = input()
  s.append(t)

dx = [1,0,-1,0]
dy = [0,1,0,-1]

queue = deque([[ch,cw]])
visited = [[1000000 for i in range(w)] for j in range(h)]
visited[ch][cw] = 0
while queue:
  l,m = queue.popleft()
  d = visited[l][m]
  for k in range(4):
    x = l + dx[k]
    y = m + dy[k]
    if x < 0 or y < 0 or x >= h or y >= w or visited[x][y] <= d or s[x][y] == "#":
      continue
    visited[x][y] = d
    queue.appendleft([x,y])
  for i in range(-2,3):
    for j in range(-2,3):
      if (i== 1 and j == 0)or(i==-1 and j == 0)or(i==0 and j == 1)or(i==0 and j==-1)or(i==0 and j==0):
        continue
      x = l + i
      y = m + j
      if x < 0 or y < 0 or x >= h or y >= w or visited[x][y] <= d+1 or s[x][y] == "#":
        continue
      visited[x][y] = d + 1
      queue.append([x,y])
  #print (queue)
if visited[dh][dw] == 1000000:
  print (-1)
else:
  print (visited[dh][dw])

Buggy submission (verdict: Runtime Error):
from collections import deque
h, w = map(int ,input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
ch -= 1
cw -= 1
dh -= 1
dw -= 1

s = []
for i in range(h):
  t = input()
  s.append(t)

dx = [1,0,-1,0]
dy = [0,1,0,-1]

queue = deque([[ch,cw]])
visited = [[False for i in range(w)] for j in range(h)]
magic = [[-1 for i in range(w)] for j in range(h)]
visited[ch][cw] = True
magic[ch][cw] = 0
while queue:
  l,m = queue.popleft()
  for k in range(4):
    x = l + dx[k]
    y = m + dy[k]
    if x < 0 or y < 0 or x >= h or y >= w or visited[x][y] or s[x][y] == "#":
      continue
    #visited[x][y] = visited[l][m] + 1
    visited[x][y] = True
    magic[x][y] = magic[l][m]
    queue.append([x,y])
  if len(queue) == 0:
    for i in range(-2,3):
      for j in range(-2,3):
        if (i== 1 and j == 0)or(i==-1 and j == 0)or(i==0 and j == 1)or(i==0 and j==-1)or(i==0 and j==0):
          continue
        x = l + i
        y = m + j
        if x < 0 or y < 0 or x >= h or y >= w or visited[x][y] or s[x][y] == "#":
          continue
        visited[x][y] = True
        magic[x][y] = magic[l][m] + 1
        queue.append([x,y])
        cnt += 1
print (magic[dh][dw])
Problem p02582 (python)

Fixed submission:
s = input()

if s == 'RSR':
  print (1)
else:
  print (s.count('R'))

Buggy submission (verdict: Runtime Error):
x,k,d = map(int, input().split())
mx = x + d*k
mn = x - d*k
 
if (x <= 0 and mx > 0) or (x >= 0 and mn < 0):
  if k%2 == 0:
    if x < 0:
      b = min(abs(abs(x)%(2*d)),abs(abs(x)%(2*d)-2*d))
    else:
      b = min(abs(x%(2*d)),abs(x%(2*d)-2*d))
    b = min(abs(b),abs(mx),abs(mn))
  else:
    if x > 0:
      b = min(abs(abs(x-d)%(2*d)),abs(abs(x-d)%(2*d)-2*d))
    else:
      b = min(abs(abs(x+d)%(2*d)),abs(abs(x+d)%(2*d)-2*d))
  ans = min(abs(b),abs(mx),abs(mn))
else:
  ans = min(abs(mx),abs(mn))
print (ans)
Problem p02730 (python)

Fixed submission:
s = input()
n = len(s)
if s != s[::-1]:
	print ("No")
	exit()
if s[:n//2] != s[:n//2][::-1]:
	print ("No")
	exit()
if s[(n+3)//2-1:] != s[(n+3)//2-1:][::-1]:
	print ("No")
	exit()
print ("Yes")

Buggy submission (verdict: Runtime Error):

n, m = map(int, input().split())
import math
def comb(n, r):
	return math.factorial(s) // (math.factorial(s - r) * math.factorial(s))
print (comb(n,2) + comb(m,2))
Problem p02744 (python)

Fixed submission:
n = int(input())
v = 'abcdefghijk'

w = []
def dfs(s,t):
  if len(s) == n:
    w.append(s)
    return
  u = len(set(s))
  for i in range(u+1):
    dfs(s+v[i],u+1)

dfs('a',1)

for i in w:
  print (i)

Buggy submission (verdict: Runtime Error):
n = int(input())

if n == 1:
  w = ['a']
elif n == 2:
  w = ['aa','ab']
elif n == 3:
  w = ['aaa','aab','aba','abb','abc']
for s in w:
  print (s)

Buggy submission (verdict: Runtime Error):
n = int(input())

if n == 1:
  w = ['a']
elif n == 2:
  w = ['aa','ab']
elif n == 3:
  w = ['aaa','aab','aba','abb']
for s in w:
  print (s)
Problem p02747 (python)

Fixed submission:
s = input()
if s == "hi" or s == "hihi" or s == "hihihi" or s == "hihihihi" or s == "hihihihihi":
	print ("Yes")
else:
	print ("No")

Buggy submission (verdict: Runtime Error):
s = input()
if s == "hi" or s == "hihi" or s == "hihihi" or s == "hihihihi" or s == "hihihihihi"
	print ("Yes")
else:
	print ("No")
Problem p02761 (python)

Fixed submission:
n, m = map(int, input().split())
a = []
for i in range(m):
	s,c = map(int, input().split())
	a.append([s,c])

for i in range(10**(n-1)-1,10**n):
	if len(str(i)) != n:
		continue
	if all(str(i)[s-1] == str(c) for s,c in a):
		print (i)
		exit()
print (-1)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
ary = []
a = []
b = []
d = []
for i in range(m):
	s,c = map(int, input().split())
	if s == 1:
		a.append(c)
	elif s == 2:
		b.append(c)
	else:
		d.append(c)
if m == 0:
	print (-1)
	exit()
if n == 1:
	print (min(d))
	exit()
ans = 1000
if len(a) == 0:
	a.append(0)
if len(b) == 0:
	b.append(0)
if len(d) == 0:
	d.append(0)
for i in a:
	for j in b:
		for k in d:
			wk = str(i) + str(j) + str(k)
			if len(str(int(wk))) != n:
				continue
			else:
				ans = min(ans, int(wk))
if ans >= 1000:
	print (-1)
else:
	print (ans)
Problem p02811 (python)

Fixed submission:
k, x = map(int, input().split())
if k*500 >= x:
	print ("Yes")
else:
	print ("No")

Buggy submission (verdict: Runtime Error):
k, x = map(int, input().spilt())
if 500*k >= x:
	print("Yes")
else:
	print ("No")
Problem p02850 (python)

Fixed submission:
from collections import deque
n = int(input())
a = [[] for i in range(n)]
e = []
for i in range(n-1):
  b, c = map(int, input().split())
  b -= 1
  c -= 1
  a[b].append(c)
  e.append(c)
col = [0 for i in range(n)]
v = deque([0])

while v:
  d = v.popleft()
  k = 1
  for i in a[d]:
    if col[d] == k:
      k += 1
    col[i] = k
    v.append(i)
    k += 1
print (max(col))
for i in e:
  print(col[i])

Buggy submission (verdict: Runtime Error):
n = int(input())

a = [set() for i in range(n)]

for i in range(n-1):
  b, c = map(int, input().split())
  b -= 1
  c -= 1
  if i == 0:
    s = b
  a[b].add(c)
  a[c].add(b)

col = [0 for i in range(n)]
visited = [False for i in range(n)]
visited[0] = True

def dfs(s,k):
  visited[s] = True
  col[s] = k
  j = 1
  for i in a[s]:
    if visited[i] == False:
      if col[s] == j:
        j += 1
      dfs(i,j)
      j += 1

dfs(0,0)

print (max(col))
for i in col[1:]:
  print (i)
Problem p02865 (python)

Fixed submission:
n = int(input())
cnt = 0
for i in range(n//2):
	if (i+1)+ (i+1) == n:
		continue
	cnt +=1
print (cnt)

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

d.sort()
mod = 998244353
s = [0 for i in range(max(d)+1)]

for i in range(n):
  s[d[i]] += 1
ans = 1
for i in range(len(s)):
  if s[i] == 0:
    print (0)
    exit()
  if i == 0:
    if s[i] > 1:
      print (0)
      exit()
    continue
  ans *= s[i-1]**(s[i])
  ans %= mod
print (ans)
Problem p02983 (python)

Fixed submission:
l, r = map(int, input().split())
a = 10**5
if r - l >= 2017:
	print (0)
	exit()
else:
	for i in range(l,r+1):
		for j in range(i+1,r+1):
			a = min(a,i*j%2019)
print (a)

Buggy submission (verdict: Runtime Error):
l, r = map(int, input().split())
if r-l >= 2017:
	print (0)
	exit()
else:
	for i in range(l,r+1):
		for j in range(i+1,r+1):
			a = min(a,i*j%2019)
print (a)