Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
N,Q = map(int,input().split())
Graph = [[] for i in range(N + 1)]

for i in range(N - 1):
    a,b = map(int,input().split())
    Graph[a].append(b)
    Graph[b].append(a)

counter = [0] * (N + 1)

for i in range(Q): #counterに値を入れていく．
    a,b = map(int,input().split())
    counter[a] += b

seen = [False] * (N + 1)

def dfs(Graph, seen, v, counter): #s : 根から訪問している頂点までの累積和
    seen[v] = True
    for next_v in Graph[v]:
        if seen[next_v]:
            continue
        counter[next_v] += counter[v]
        dfs(Graph, seen, next_v, counter)
    
    
dfs(Graph, seen, 1, counter)
print(*counter[1:])

Fixed submission:
# coding: utf-8
# Your code here!
import collections
N,Q = map(int,input().split())
Graph = [[] for i in range(N + 1)]

for i in range(N - 1):
    a,b = map(int,input().split())
    Graph[a].append(b)
    Graph[b].append(a)

counter = [0] * (N + 1)

for i in range(Q): #counterに値を入れていく．
    a,b = map(int,input().split())
    counter[a] += b

seen = [False] * (N + 1)
todo = collections.deque()

seen[1] = True
todo.append(1)

while len(todo) != 0:
    v = todo.pop()
    for next_v in Graph[v]:
        if seen[next_v]:
            continue
        seen[next_v] = True
        todo.append(next_v)
        counter[next_v] += counter[v]

print(*counter[1:])

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
N,Q = map(int,input().split())
Graph = [[] for i in range(N + 1)]

for i in range(N - 1):
    a,b = map(int,input().split())
    Graph[a].append(b)
    Graph[b].append(a)

counter = [0] * (N + 1)

for i in range(Q): #counterに値を入れていく．
    a,b = map(int,input().split())
    counter[a] += b

seen = [False] * (N + 1)

def dfs(Graph, seen, v, s): #s : 根から訪問している頂点までの累積和
    seen[v] = True
    s += counter[v]
    print(str(s) + " ", end = "")
    for next_v in Graph[v]:
        if seen[next_v]:
            continue
        dfs(Graph, seen, next_v, s)
    
    
dfs(Graph, seen, 1, 0)

Fixed submission:
# coding: utf-8
# Your code here!
import collections
N,Q = map(int,input().split())
Graph = [[] for i in range(N + 1)]

for i in range(N - 1):
    a,b = map(int,input().split())
    Graph[a].append(b)
    Graph[b].append(a)

counter = [0] * (N + 1)

for i in range(Q): #counterに値を入れていく．
    a,b = map(int,input().split())
    counter[a] += b

seen = [False] * (N + 1)
todo = collections.deque()

seen[1] = True
todo.append(1)

while len(todo) != 0:
    v = todo.pop()
    for next_v in Graph[v]:
        if seen[next_v]:
            continue
        seen[next_v] = True
        todo.append(next_v)
        counter[next_v] += counter[v]

print(*counter[1:])
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import itertools
N = int(input())
balls = []
for i in range(N):
    l = list(map(int,input().split()))	
    balls.append(l)

d = list(itertools.permutations(balls, 2))

#print(d)

dic = {}

for i in range(len(d)):
   p = d[i][1][0] - d[i][0][0]
   q = d[i][1][1] - d[i][0][1]
   dic[str(p) + "," + str(q)] = 0
   
for i in range(len(d)):
   p = d[i][1][0] - d[i][0][0]
   q = d[i][1][1] - d[i][0][1]
   
   dic[str(p) + "," + str(q)] += 1

max_num = max(dic.values())
#p_q = max(dic.items(), key = lambda x:x[1])[0]

#p,q = map(int,p_q.split(","))

#print(max_num)

ans = N - max_num
print(ans)

Fixed submission:
# coding: utf-8
# Your code here!
import sys
import itertools
N = int(input())
balls = []
for i in range(N):
    l = list(map(int,input().split()))	
    balls.append(l)

d = list(itertools.permutations(balls, 2))

#print(d)
if N == 1:
    print(1)
    sys.exit()
    

dic = {}

for i in range(len(d)):
   p = d[i][1][0] - d[i][0][0]
   q = d[i][1][1] - d[i][0][1]
   dic[str(p) + "," + str(q)] = 0
   
for i in range(len(d)):
   p = d[i][1][0] - d[i][0][0]
   q = d[i][1][1] - d[i][0][1]
   dic[str(p) + "," + str(q)] += 1

dic[str(0) + "," + str(0)] = -1


max_num = max(dic.values())
ans = N - max_num
p_q = max(dic.items(), key = lambda x:x[1])[0]
p,q = map(int,p_q.split(","))

#if p == 0 && q == 0:
    
#print(max_num)


print(ans)

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import itertools
N = int(input())
balls = []
for i in range(N):
    l = list(map(int,input().split()))	
    balls.append(l)

d = list(itertools.permutations(balls, 2))

#print(d)

dic = {}

for i in range(len(d)):
   p = d[i][1][0] - d[i][0][0]
   q = d[i][1][1] - d[i][0][1]
   dic[str(p) + "," + str(q)] = 0
   
for i in range(len(d)):
   p = d[i][1][0] - d[i][0][0]
   q = d[i][1][1] - d[i][0][1]
   
   dic[str(p) + "," + str(q)] += 1

max_num = max(dic.values())
#p_q = max(dic.items(), key = lambda x:x[1])[0]

#p,q = map(int,p_q.split(","))

#print(max_num)

ans = N - max_num
print(ans)

Fixed submission:
# coding: utf-8
# Your code here!
import sys
import itertools
N = int(input())
balls = []
for i in range(N):
    l = list(map(int,input().split()))	
    balls.append(l)

d = list(itertools.permutations(balls, 2))

#print(d)
if N == 1:
    print(1)
    sys.exit()
    

dic = {}

for i in range(len(d)):
   p = d[i][1][0] - d[i][0][0]
   q = d[i][1][1] - d[i][0][1]
   dic[str(p) + "," + str(q)] = 0
   
for i in range(len(d)):
   p = d[i][1][0] - d[i][0][0]
   q = d[i][1][1] - d[i][0][1]
   dic[str(p) + "," + str(q)] += 1

dic[str(0) + "," + str(0)] = -1


max_num = max(dic.values())
ans = N - max_num
p_q = max(dic.items(), key = lambda x:x[1])[0]
p,q = map(int,p_q.split(","))

#if p == 0 && q == 0:
    
#print(max_num)


print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
s1 = s
c1 = 0
for i in range(n-1):
    if s1[i:i+2]=="#.":
        c1 += 1
        s1 = s1[:i+1]+"#"+s1[i+2:]
print(c1)

Fixed submission:
n = int(input())
s = input()
b = [0]*n
w = [0]*n
if s[0] == "#":
    b[0] = 1
for i in range(1,n):
    if s[i]=="#":
        b[i] = b[i-1]+1
    else:
        b[i] = b[i-1]
if s[-1] == ".":
    w[-1] = 1
for i in range(n-2,-1,-1):
    if s[i]==".":
        w[i] = w[i+1]+1
    else:
        w[i] = w[i+1]
a = min(w[0],b[n-1])
for i in range(n-1):
    if a > b[i]+w[i+1]:
        a = b[i]+w[i+1]
print(a)
Buggy python submission (verdict: Runtime Error):
n, m = map(int,(input().split()))
d = {}
for i in range(n):
    a, b = map(int,(input().split()))
    d[a]=b
d = sorted(d.items())
ans = 0
for i in range(n):
    if d[i][1] >= m:
        ans += d[i][0]*m
        break
    else:
        ans += d[i][0]*d[i][1]
        m -= d[i][1]
        if m <= 0:
            break
print(ans)

Fixed submission:
n, m = map(int,(input().split()))
d = []
for i in range(n):
    a, b = map(int,(input().split()))
    d.append([a,b])
d = sorted(d)
ans = 0
for i in range(n):
    if d[i][1] >= m: # 残り本数 >= この値段の本数
        ans += d[i][0]*m
        break
    else:
        ans += d[i][0]*d[i][1]
        m -= d[i][1]
        if m <= 0:
            break
print(ans)

Buggy python submission (verdict: Runtime Error):
n, m = map(int,(input().split()))
d = {}
for i in range(n):
    a, b = map(int,(input().split()))
    d[a]=b
d = sorted(d.items())
ans = 0
for i in range(n):
    if d[i][1] >= m:
        ans += d[i][0]*m
        break
    else:
        ans += d[i][0]*d[i][1]
        m -= d[i][1]
print(ans)

Fixed submission:
n, m = map(int,(input().split()))
d = []
for i in range(n):
    a, b = map(int,(input().split()))
    d.append([a,b])
d = sorted(d)
ans = 0
for i in range(n):
    if d[i][1] >= m: # 残り本数 >= この値段の本数
        ans += d[i][0]*m
        break
    else:
        ans += d[i][0]*d[i][1]
        m -= d[i][1]
        if m <= 0:
            break
print(ans)

Buggy python submission (verdict: Runtime Error):
n, m = map(int,(input().split()))
d = {}
for i in range(n):
    a, b = map(int,(input().split()))
    d[a]=b
d = sorted(d.items())
ans = 0
for i in range(n):
    if d[i][1] >= m: # 残り本数 >= この値段の本数
        ans += d[i][0]*m
        print(ans)
        exit
    else:
        ans += d[i][0]*d[i][1]
        m -= d[i][1]


Fixed submission:
n, m = map(int,(input().split()))
d = []
for i in range(n):
    a, b = map(int,(input().split()))
    d.append([a,b])
d = sorted(d)
ans = 0
for i in range(n):
    if d[i][1] >= m: # 残り本数 >= この値段の本数
        ans += d[i][0]*m
        break
    else:
        ans += d[i][0]*d[i][1]
        m -= d[i][1]
        if m <= 0:
            break
print(ans)

Buggy python submission (verdict: Runtime Error):
n, m = map(int,(input().split()))
d = {}
for i in range(n):
    a, b = map(int,(input().split()))
    d[a]=b
d = sorted(d.items())
ans = 0
for i in range(n):
    if d[i][1] >= m: # 残り本数 >= この値段の本数
        ans += d[i][0]*m
        break
    else:
        ans += d[i][0]*d[i][1]
        m -= d[i][1]
print(ans)

Fixed submission:
n, m = map(int,(input().split()))
d = []
for i in range(n):
    a, b = map(int,(input().split()))
    d.append([a,b])
d = sorted(d)
ans = 0
for i in range(n):
    if d[i][1] >= m: # 残り本数 >= この値段の本数
        ans += d[i][0]*m
        break
    else:
        ans += d[i][0]*d[i][1]
        m -= d[i][1]
        if m <= 0:
            break
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)    

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

print(gcd_list(a))

Fixed submission:
import fractions
from functools import reduce
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)    

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

print(gcd_list(a))
Buggy python submission (verdict: Time Limit Exceeded):
n, p = map(int, input().split())
if n == 1 or p== 1:
    print(p)
    exit()
c2 = 0
while p%2 == 0:
    c2 += 1
    p//=2
c = 2**(c2//n)
i = int(p**(1/n))+1
while i > 1:
    if p%(i**n) == 0:
        print(c*i)
        exit()
    else:
        i -= 1
print(c)

Fixed submission:
n, p = map(int, input().split())
if n == 1 or p== 1:
    print(p)
    exit()
c2 = 0
while p%2 == 0:
    c2 += 1
    p//=2
c = 2**(c2//n)
i = int(p**(1/n))+1
if i%2 == 0:
    i -= 1
while i > 1:
    if p%(i**n) == 0:
        print(c*i)
        exit()
    else:
        i -= 2
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n, p = map(int, input().split())
if n == 1 or p== 1:
    print(p)
    exit()
c2 = 0
while p%2 == 0:
    c2 += 1
    p//=2
c = 2**(c2//n)
max = 1
i = 1
while i**n <= p:
    i *= 2
while i > 1:
    if p%(i**n) == 0:
        print(c*i)
        exit()
    else:
        i -= 1
print(c)


Fixed submission:
n, p = map(int, input().split())
if n == 1 or p== 1:
    print(p)
    exit()
c2 = 0
while p%2 == 0:
    c2 += 1
    p//=2
c = 2**(c2//n)
i = int(p**(1/n))+1
if i%2 == 0:
    i -= 1
while i > 1:
    if p%(i**n) == 0:
        print(c*i)
        exit()
    else:
        i -= 2
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n, p = map(int, input().split())
if n == 1 or p== 1:
    print(p)
    exit()
c2 = 0
while p%2 == 0:
    c2 += 1
    p//=2
c = 2**(c2//n)
max = 1
i = 1
while i**n <= p:
    i += 2
while i > 1:
    if p%(i**n) == 0:
        print(c*i)
        exit()
    else:
        i -= 1
print(c)

Fixed submission:
n, p = map(int, input().split())
if n == 1 or p== 1:
    print(p)
    exit()
c2 = 0
while p%2 == 0:
    c2 += 1
    p//=2
c = 2**(c2//n)
i = int(p**(1/n))+1
if i%2 == 0:
    i -= 1
while i > 1:
    if p%(i**n) == 0:
        print(c*i)
        exit()
    else:
        i -= 2
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n, p = map(int, input().split())
if n == 1 or p== 1:
    print(p)
    exit()
c2 = 0
while p%2 == 0:
    c2 += 1
    p//=2
c = 2**(c2//n)
max = 1
i = 1
while i**n <= p:
    if p%(i**n) == 0:
        max = i
    i += 1
print(c*max)

Fixed submission:
n, p = map(int, input().split())
if n == 1 or p== 1:
    print(p)
    exit()
c2 = 0
while p%2 == 0:
    c2 += 1
    p//=2
c = 2**(c2//n)
i = int(p**(1/n))+1
if i%2 == 0:
    i -= 1
while i > 1:
    if p%(i**n) == 0:
        print(c*i)
        exit()
    else:
        i -= 2
print(c)
Buggy python submission (verdict: Runtime Error):
n, k = map(int,(input().split()))
h = []
for i in range(n):
    h.append(int(input()))
h.sort()
min=h[-1]-h[0]
for i in range(n-k+1):
    if h[i+k-1]-h[i] < min:
        min = h[i+k-1]-h[i]
print(min)

Fixed submission:
s=int(input())
if s==25:
    print("Christmas")
elif s==24:
    print("Christmas Eve")
elif s==23:
    print("Christmas Eve Eve")
elif s==22:
    print("Christmas Eve Eve Eve")
Buggy python submission (verdict: Runtime Error):
p = [1]*51
t = [1]*51
def f(n,x):
    if n==0:
        return f
    if x==1:
        return 0
    if x==t[n]:
        return p[n]
    if x==p[n]:
        return p[n-1]+1
    if x<p[n]:
        return f(n-1,x-1)
    return p[n-1]+f(n-1,x-p[n])+1

for i in range(1,51):
    p[i] = p[i-1]*2+1
    t[i] = t[i-1]*2+3
n,x = map(int,input().split())    
print(f(n,x))

Fixed submission:
p = [1]*51
t = [1]*51
def f(n,x):
    if n==0:
        return 1
    if x==1:
        return 0
    if x==t[n]:
        return p[n]
    if x==p[n]:
        return p[n-1]+1
    if x<p[n]:
        return f(n-1,x-1)
    return p[n-1]+f(n-1,x-p[n])+1

for i in range(1,51):
    p[i] = p[i-1]*2+1
    t[i] = t[i-1]*2+3
n,x = map(int,input().split())    
print(f(n,x))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = [a[0]]
for i in range(n-1):
    b.append(b[i]+a[i+1])
c1 = list(itertools.combinations(range(n),2))
s = a
for i in c1:
    s.append(b[i[1]]-b[i[0]]+a[i[0]])
c2 = list(itertools.combinations(range(len(s)),k))
max=0
for i in c2:
    t = s[i[0]]
    for j in i:
        t = t&s[j]
    if max < t:
        max = t
print(max)


Fixed submission:
import itertools
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = [a[0]]
for i in range(n-1):
    b.append(b[i]+a[i+1])
c = list(itertools.combinations(range(n),2))
s = a
for i in c:
    s.append(b[i[1]]-b[i[0]]+a[i[0]])
s.sort(reverse=True)
l = len(bin(s[0]))-2
d = 1<<l-1
t = 0
while d>0:
    s1 = []
    if s[k-1] >= d:
        t += d
        for i in s:
            if i >= d:
                s1.append(i)
            else:
                s=s1
                break
    for i in range(len(s)):
        if s[i] >= d:
            s[i] -= d
        else:
            s.sort(reverse=True)
            break
    d //= 2
print(t)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[[] for i in range(n)]
for i in range(m):
    p,y=input().split()
    l[int(p)-1].append(y.zfill(6)+str(i).zfill(6))
for i in range(n):
    l[i].sort()
s=[0]*m
for i in range(n):
    for j in range(len(l[i])):
        s[int(l[i][j][6:12])]=str(i+1).zfill(6)+str(j+1).zfill(6)
for i in s:
    print(i)

Fixed submission:
n,m=map(int,input().split())
l=[[] for i in range(n)]
for i in range(m):
    p,y=input().split()
    l[int(p)-1].append(y.zfill(10)+str(i).zfill(6))
for i in range(n):
    l[i].sort()
s=[0]*m
for i in range(n):
    for j in range(len(l[i])):
        s[int(l[i][j][10:16])]=str(i+1).zfill(6)+str(j+1).zfill(6)
for i in s:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
c=0
s = k if k%2==1 else k//2
for i in range(s,n+1,s):
    for j in range(s,n+1,s):
        for l in range(s,n+1,s):
            if (i+j)%k==0 and (i+l)%k==0 and (j+l)%k==0:
                c+=1
print(c)


Fixed submission:
n,k=map(int,input().split())
c=0
s = k if k%2==1 else k//2
for i in range(s,n+1,s):
    s2 = k if i%k==0 else s
    n2 = (n-s2)//k+1
    c+=n2**2
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
input = sys.stdin.readline
inf = 200000000
n, m, r = map(int,input().split())
rs = list(map(int,input().split()))
d = [[inf] * (n+1) for j in range(n+1)]
for i in range(n+1):
    d[i][i] = 0
for i in range(m):
    a, b, c = map(int, input().split())
    d[a][b] = d[b][a] = c
for k in range(1,n+1):
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            d[i][j] = d[j][i] = min(d[i][j], d[i][k] + d[k][j])
p = list(itertools.permutations(range(r)))
s = inf
for q in p:
    t = 0
    for i in range(r-1):
        t += d[rs[q[i]]][rs[q[i+1]]]
    if s > t:
        s = t
print(s)

Fixed submission:
import sys
import itertools
input = sys.stdin.readline
inf = 200000000
n, m, r = map(int,input().split())
rs = list(map(int,input().split()))
d = [[inf] * (n+1) for j in range(n+1)]
for i in range(n+1):
    d[i][i] = 0
for i in range(m):
    a, b, c = map(int, input().split())
    d[a][b] = d[b][a] = c
for k in range(1,n+1):
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            d[i][j] = d[j][i] = min(d[i][j], d[i][k] + d[k][j])
p = list(itertools.permutations(range(r)))
s = inf
for q in p:
    t = 0
    for i in range(r-1):
        t += d[rs[q[i]]][rs[q[i+1]]]
    if s > t:
        s = t
print(s)
Buggy python submission (verdict: Runtime Error):
def solve(g):
    for i in range(1, h+1):
        for j in range(1, w+1):
            if g[i][j] == '#' and g[i][j+1] == '.' \
                    and g[i+1][j] == '.' and g[i][j-1] == '.' \
                    and g[i-1][j] == '.':
                        return False
    return True

h, w = list(map(int, input().split()))
g = [['.']*(w+2)]
g += [['.'] + list(input()) + ['.'] for i in range(h)]
g.append(['.']*(w+2))

if solve(g):
    print('Yes')
else:
    print('No')

Fixed submission:
a, b = list(map(int, input().split()))
print(a if b >= a else a-1)
Buggy python submission (verdict: Runtime Error):
N,Y = map(int,input().split())

ans = "-1 -1 -1"

for i in range(N+1):
  for j in range(N+1-j):
    if 0 <= Y - 10000*i - 5000*j <= 500*(N - i - j):
      print(i+" "+j+" "+N-i-j)
      exit()
print(ans)

Fixed submission:
N,Y = map(int,input().split())
ans = "-1 -1 -1"
 
for i in range(N+1):
  for j in range(N+1-i):
    if Y == 10000*i + 5000*j + 1000*(N - i - j):
      print(str(i)+" "+str(j)+" "+str(N-i-j))
      exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
A = list(int(input()))

for i in range(2**3):
  tmp=A[:]
  for j in range(3):
    if (i>>j)&1:
      tmp[j]*=-1
  if sum(A) == 7:
    for s in tmp:
      print(s,end="")
    print("=7")

Fixed submission:
A = list(input())

for i in range(2**3):
  tmp=A[:]
  for j in range(3):
    if (i>>j)&1:
      tmp[j]+="-"
    else:
      tmp[j]+="+"
  if eval("".join(tmp)) == 7:
    tmp[-1]+="=7"
    for s in tmp:
      print(s,end="")
    exit()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
n = N - 1
sum = 0
for i in range(n):
    sum = sum + i+1
print(sum)

Fixed submission:
N = int(input())
print((N*(N-1))//2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
n = N
sum = 0
for i in range(N):
    sum = sum + ((i)%(i+1))

print(sum)

Fixed submission:
N = int(input())
print((N*(N-1))//2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
n = N
sum = 0
for i in range(N):
    if i == 0:
        sum = 0
    else:
        sum = sum + ((i)%(i+1))

print(sum)

Fixed submission:
N = int(input())
print((N*(N-1))//2)
Buggy python submission (verdict: Runtime Error):
N = int(input())
v = list(map(int,input().split()))

sum = 0

for i in range(v)
	sum = 1/v[i] + sum

ans = 1/(sum/N)

print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
 
sum = 0
 
for i in range(len(A)):
	sum = (1/A[i]) + sum

a = 1/(sum)
 
print(a)
Buggy python submission (verdict: Runtime Error):
N = int(input())
v = list(map(int,input().split()))
cnt = N

while cnt is not 1:
		
    titi = max(v)
    haha = min(v)

    v.remove(titi)
    v.remove(haha)

    son = (titi + haha)/2 
    
    cnt = N - 1
    
print(son)

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

v.sort()

son = v[0]

for i in range(1,len(v)):
	son = (v[i] + son)/2

print(son)

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

for i in N:

    titi = max(v)
    haha = min(v)

    v.remove(titi)
    v.remove(haha)

    son = (titi + haha)/2 

    v.add(son)

res = v[0] 
print(str(res))

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

v.sort()

son = v[0]

for i in range(1,len(v)):
	son = (v[i] + son)/2

print(son)

Buggy python submission (verdict: Runtime Error):
N = int(input())
v =  list(map(int,input().split()))

for i in N:

    titi = max(v)
    haha = min(v)

    v.remove(titi)
    v.remove(haha)

    son = (titi + haha)/2 

    v.add(son)

res = v[0] 
print(str(res))


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

v.sort()

son = v[0]

for i in range(1,len(v)):
	son = (v[i] + son)/2

print(son)

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

for i in kazu:

    titi = max(int(sozai))
    haha = min(int(sozai))

    int(sozai).remove(titi)
    int(sozai).remove(haha)

    son = (titi + haha)/2 

    sozai.add(str(son))

print(str(sozai))



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

v.sort()

son = v[0]

for i in range(1,len(v)):
	son = (v[i] + son)/2

print(son)

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

while len(sozai) != 1:

    titi = max(sozai)
    haha = min(sozai)

    sozai.remove(titi)
    sozai.remove(haha)

    son = (titi + haha)/2 

    sozai.add(son)

print(str(sozai))


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

v.sort()

son = v[0]

for i in range(1,len(v)):
	son = (v[i] + son)/2

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

input = sys.stdin.readline

N = int(input())
ab = [list(map(int,input().split())) for i in range(N-1)]

downnum = [0]*N
neighbor = [[] for i in range(N)]
for ai, bi in ab:
	downnum[ai-1] += 1
	neighbor[ai-1].append(bi-1)

K = max(max(downnum[1::])+1, downnum[0])
Kpre = [-1]*N
Kpre[0] = K
anslist = [[0]*N for i in range(N)]
queue = [0]
knum = 1
while len(queue)>0:
	nq = []
	for i in queue:
		kk = Kpre[i]+1
		if kk>K: kk -= K
		for j in neighbor[i]:
			anslist[i][j] = kk
			nq.append(j)
			Kpre[j] = kk
			kk += 1
			if kk>K: kk -= K

	queue = nq

ans = []
for ai, bi in ab:
	ans.append(anslist[ai-1][bi-1])

print(K,*ans,sep='\n')

Fixed submission:
import sys

input = sys.stdin.readline

N = int(input())
ab = [list(map(int,input().split())) for i in range(N-1)]

downnum = [0]*N
neighbor = [[] for i in range(N)]
for ai, bi in ab:
	downnum[ai-1] += 1
	neighbor[ai-1].append(bi-1)

K = max(max(downnum[1::])+1, downnum[0])
Kpre = [-1]*N
Kpre[0] = K
# anslist = [[0]*N for i in range(N)]
queue = [0]
knum = 1
while len(queue)>0:
	nq = []
	for i in queue:
		kk = Kpre[i]+1
		if kk>K: kk -= K
		for j in neighbor[i]:
			nq.append(j)
			Kpre[j] = kk
			kk += 1
			if kk>K: kk -= K

	queue = nq

print(K)
for ai, bi in ab:
	print(Kpre[bi-1])