Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

count = 0
for i in range(n):
    l1 = s[i]
    for j in range(i + 1, n):
        if s[j] == l1:
            continue
        else:
            l2 = s[j]
        for k in range(j + 1, n):
            if s[k] == l1 or s[k] == l2 or (j - i) == (k - j):
                continue
            else:
                count += 1
print(count)

Fixed submission:
n = int(input())
s = input()

import random
from collections import Counter

res = 1
val = Counter(s).values()
if len(val) < 3:
    print(0)
    exit()

for i in val:
    res *= i

count = 0
for i in range(n):
    j = 1
    while i + 2 * j < n:
        if (s[i] != s[i+j]) and (s[i+j] != s[i+2*j]) and (s[i] != s[i+2*j]):
            count += 1
        j += 1

print(res - count)

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

count = 0
for i in range(n):
    l1 = s[i]
    for j in range(i + 1, n):
        if s[j] == l1:
            continue
        else:
            l2 = s[j]
        for k in range(j + 1, n):
            if s[k] == l1 or s[k] == l2 or (j - i) == (k - j):
                continue
            else:
                count += 1
print(count)

Fixed submission:
n = int(input())
s = input()

import random
from collections import Counter

res = 1
val = Counter(s).values()
if len(val) < 3:
    print(0)
    exit()

for i in val:
    res *= i

count = 0
for i in range(n):
    j = 1
    while i + 2 * j < n:
        if (s[i] != s[i+j]) and (s[i+j] != s[i+2*j]) and (s[i] != s[i+2*j]):
            count += 1
        j += 1

print(res - count)
Buggy python submission (verdict: Runtime Error):
def merge(left, right):
    merged = []
    l_i, r_i = 0, 0

    # ソート済み配列をマージするため、それぞれ左から見ていくだけで良い
    while l_i < len(left) and r_i < len(right):
        # ここで=をつけることで安定性を保っている
        if left[l_i] <= right[r_i]:
            merged.append(left[l_i])
            l_i += 1
        else:
            merged.append(right[r_i])
            r_i += 1

    # 上のwhile文のどちらかがFalseになった場合終了するため、あまりをextendする
    if l_i < len(left):
        merged.extend(left[l_i:])
    if r_i < len(right):
        merged.extend(right[r_i:])
    return merged


x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

import numpy as np
p = np.sort(p)[-x:]
q = np.sort(q)[-y:]
r = np.sort(r)

pq = np.array(merge(p, q))
f = True
i = 1
while True:
    f = (r[-i:] >= pq[:i]).all()
    if not f:
        break
    else:
        i += 1

i -= 1
if i:
    print(np.r_[r[-i:], pq[i:]].sum())
else:
    print(pq.sum())

Fixed submission:
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

print(sum(sorted(sorted(p)[-x:] + sorted(q)[-y:] + r)[-(x+y):]))
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
from math import isqrt
if 2 * isqrt(a * b) < c - a - b:
    print('Yes')
else:
    print('No')

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

d = c - a - b
if d > 0 and d**2 > 4 * a * b:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
def int_sqrt2(n):
    def f(prev):
        while True:
            m = (prev + n / prev) / 2
            if m >= prev:
                return prev
            prev = m

    return f(int(sqrt(n) * (1 + 1e-10)))

if 2 * int_sqrt2(a * b) < c - a - b:
    print('Yes')
else:
    print('No')

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

d = c - a - b
if d > 0 and d**2 > 4 * a * b:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
S = input()
Q = int(input())
for i in range(Q):
    q = input()
    if q == '1':
        S = S[::-1]
    else:
        F, C = q.split()[1:]
        if F == '1':
            S = C + S
        else:
            S = S + C
print(S)

Fixed submission:
S = input()
if 'A' in S and 'B' in S:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
rev = False
for i in range(Q):
    q = input()
    if q == '1':
        rev = not rev
    else:
        F, C = q.split()[1:]
        if (F == '1' and not rev) or (F == '2' and rev):
            S = C + S
        else:
            S = S + C
if rev:
    S = S[::-1]
print(S)

Fixed submission:
S = input()
Q = int(input())
rev = False
head = []
tail = []
for i in range(Q):
    q = input()
    if q == '1':
        rev = not rev
    else:
        F, C = q.split()[1:]
        if (F == '1' and not rev) or (F == '2' and rev):
            head.append(C)
        else:
            tail.append(C)

head = ''.join(head)
tail = ''.join(tail)
S = head[::-1] + S + tail
if rev:
    S = S[::-1]
print(S)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
for i in range(Q):
    q = input()
    if q == '1':
        S = S[::-1]
    else:
        F, C = q.split()[1:]
        if F == '1':
            S = C + S
        else:
            S = S + C
print(S)

Fixed submission:
S = input()
Q = int(input())
rev = False
head = []
tail = []
for i in range(Q):
    q = input()
    if q == '1':
        rev = not rev
    else:
        F, C = q.split()[1:]
        if (F == '1' and not rev) or (F == '2' and rev):
            head.append(C)
        else:
            tail.append(C)

head = ''.join(head)
tail = ''.join(tail)
S = head[::-1] + S + tail
if rev:
    S = S[::-1]
print(S)
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input())
m = 10 ** 9 + 7

def combn(n, r, m):
    X = Y = 1
    if n-r < r:
        r = n-r
    for i in range(1, r+1):
        Y = Y*i % m
        X = X*(n-i+1) % m
    Y = pow(Y, m-2, m)
    return X*Y
  
print((pow(2, n, m) - 1 - combn(n, a, m) - combn(n ,b, m)) % m)

Fixed submission:
n, a, b = map(int, input().split())
m = 10 ** 9 + 7

def combn(n, r, m):
    X = Y = 1
    if n-r < r:
        r = n-r
    for i in range(1, r+1):
        Y = Y*i % m
        X = X*(n-i+1) % m
    Y = pow(Y, m-2, m)
    return X*Y
  
print((pow(2, n, m) - 1 - combn(n, a, m) - combn(n ,b, m)) % m)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
d = defaultdict(int)
N = int(input())
for i in range(N):
    d[input()] += 1

for i in sorted([i for i, v in d.items() if v == max(d.values())]):
    print(i)


Fixed submission:
from collections import defaultdict
d = defaultdict(int)
N = int(input())
MAX = 0
max_keys = []
for i in range(N):
    k = input()
    d[k] += 1
    if d[k] == MAX:
        max_keys.append(k)
    elif d[k] > MAX:
        MAX = d[k]
        max_keys = [k]

for i in sorted(max_keys):
    print(i)
# for i in sorted([i for i, v in d.items() if v == max(d.values())]):
#     print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))

import numpy as np
exps = np.array(p) / 2 + 0.5

m = 0
for i in range(0, n - k + 1):
    tmp = exps[i:i + k].sum()
    if tmp > m:
        m = tmp
print(m)

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

import numpy as np
exps = np.array(p) / 2 + 0.5

s = exps[:k].sum()
m = s
for i in range(1, n - k + 1):
    s = s - exps[i-1] + exps[i+k-1]
    if s > m:
        m = s
print(m)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = list(map(int, input().split()))

h.sort()
if k:
    print(sum(h[:-k]))
else
    print(sum(h))

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

h.sort()

if k:
    print(sum(h[:-k]))
else:
    print(sum(h))
Buggy python submission (verdict: Runtime Error):
odd_flag = False
count = 0
while True:
    for i, j in enumerate(A):
        if j % 2 == 1:
            odd_flag = True
            break
        A[i] = j / 2
    if not odd_flag:
        count += 1
    else:
        break

Fixed submission:
n = input()
A = [int(i) for i in input().split()]

odd_flag = False
count = 0
while True:
    for i, j in enumerate(A):
        if j % 2 == 1:
            odd_flag = True
            break
        A[i] = j / 2
    if not odd_flag:
        count += 1
    else:
        break
        
print(count)
Buggy python submission (verdict: Runtime Error):
A, B, C, K = map(int, input().split()) 
import numpy as np
arr = np.concatenate([np.ones(A, int), np.zeros(B, int), np.ones(C, int)*-1])
print(arr[:K].sum())

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

if K < A:
    print(K)
elif K < A+B:
    print(A)
else:
    print(A-(K-A-B))

Buggy python submission (verdict: Runtime Error):
A, B, C, K = map(int, input().split()) 
lis = [1]*A + [0]*B + [-1]*C
print(sum(lis[:K]))

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

if K < A:
    print(K)
elif K < A+B:
    print(A)
else:
    print(A-(K-A-B))
Buggy python submission (verdict: Runtime Error):
import numpy as np
N, M = map(int, input().split()) 
A = np.array(list(map(int, input().split())))
hwdays = A.sum()
if N >= hwdays:
    print(int(N-hwdays))
else:
    print(-1)

Fixed submission:
import numpy as np
N, M = map(int, input().split()) 
A = np.array(list(map(int, input().split())))
hwdays = A.sum()
if N >= hwdays:
    print(int(N-hwdays))
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
d = int(input())
while True:
  val = [int(i) for i in input().split()]
  if len(val) == 0:
    break

print(N - d)

Fixed submission:
# B - Trick or Treat

N, K = map(int, input().split())
ls = []
for _ in range(K):
    d = int(input())
    A = [int(a) for a in input().split()]
    ls += A

print(N - len(set(ls)))
Buggy python submission (verdict: Time Limit Exceeded):
# D - Floor Function

from math import floor

A, B, N = map(int, input().split())
mx = -1 * float('inf')
i = 0

for i in range(N + 1):
    result = floor(A * i / B) - A * floor(i / B)
    if mx <= result:
        mx = result

print(mx)


Fixed submission:
# D - Floor Function

from math import floor

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

if B <= N:
    mx = floor(A * (B - 1) / B) - A * floor((B - 1) / B)
else:
    mx = floor(A * N / B) - A * floor(N / B)

# mx = -1 * float('inf')
# i = 0

# for i in range(N + 1):
#     result = floor(A * i / B) - A * floor(i / B)
#     print(i, result)
#     if mx <= result:
#         mx = result

print(mx)
Buggy python submission (verdict: Time Limit Exceeded):
# C - management

N = int(input())
A = [int(a) for a in input().split()]

for i in range(1, N + 1): print(A.count(i))


Fixed submission:
# C - management

N = int(input())
A = [0] * N
for a in [*map(int, input().split())]: A[a - 1] += 1
print(*A, sep='\n')
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

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 += reduce(math.gcd, (a, b, c))

print(ans)

Fixed submission:
import math
from functools import reduce

K = int(input())

ans = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        ab = math.gcd(a, b)
        for c in range(1, K + 1):
            abc = math.gcd(ab, c)
            ans += abc

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# D - Line++

import queue

N, X, Y = map(int, input().split())
X, Y = X - 1, Y - 1
M = [(i, []) for i in range(N)]
for i in range(N):
    if i != 0:
        M[i][1].append(i - 1)
    if i != N - 1:
        M[i][1].append(i + 1)
    if i == X:
        M[X][1].append(Y)
    if i == Y:
        M[Y][1].append(X)

cost = [[-1] * N for _ in range(N)]
p = [[None] * N for _ in range(N)]
Q = queue.Queue()

for i in range(N):
    Q.put(M[i])
    key = M[i][0]
    cost[key][key] = 0
    p[key][key] = key
    while not Q.empty():
        q = Q.get()
        for j in q[1]:
            if cost[i][j] == -1:
                p[i][j] = q[0]
                cost[i][j] = cost[i][p[i][j]] + 1
                Q.put(M[j])

ans = [0] * N
for i in range(N):
    for j in range(N):
        ans[cost[i][j]] += 1

for i in range(1, N):
    print(int(ans[i] / 2))


Fixed submission:
# D - Line++

n, x, y = map(int, input().split())
x, y = x - 1, y - 1

cnt = [0] * n
for i in range(n):
    for j in range(i + 1, n):
        dist = min(j - i, abs(x - i) + abs(y - j) + 1)
        cnt[dist] += 1

for i in range(1, len(cnt)):
    print(cnt[i])
Buggy python submission (verdict: Time Limit Exceeded):
# D - Banned K

import sys

sys.setrecursionlimit(10 ** 9)

N = int(input())
A = [int(a) for a in input().split()]

def f(i, ls, chosen):
    n1 = len(ls)
    n2 = len(chosen)
    if n1 <= i or n2 == 2:
        if n2 == 2 and chosen[0] == chosen[1]:
            return 1
        return 0
    return f(i + 1, ls, chosen) + f(i + 1, ls, chosen + [ls[i]])

for i in range(N):
    print(f(0, A[:i] + A[i + 1:], []))


Fixed submission:
N = int(input())
A = [int(a) for a in input().split()]
cnt = {}
total = 0

for a in A:
    if a not in cnt:
        cnt[a] = 0
    cnt[a] += 1

for i in cnt.values():
    total += i * (i - 1) // 2

for a in A:
    print(total - (cnt[a] - 1))

Buggy python submission (verdict: Runtime Error):
# D - Banned K

N = int(input())
A = [int(a) for a in input().split()]

def f(i, ls, chosen):
    n1 = len(ls)
    n2 = len(chosen)
    if n1 <= i or n2 == 2:
        if n2 == 2 and chosen[0] == chosen[1]:
            return 1
        return 0
    return f(i + 1, ls, chosen) + f(i + 1, ls, chosen + [ls[i]])

for i in range(N):
    print(f(0, A[:i] + A[i + 1:], []))


Fixed submission:
N = int(input())
A = [int(a) for a in input().split()]
cnt = {}
total = 0

for a in A:
    if a not in cnt:
        cnt[a] = 0
    cnt[a] += 1

for i in cnt.values():
    total += i * (i - 1) // 2

for a in A:
    print(total - (cnt[a] - 1))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(a) for a in input().split()]
cnt = {}
total = 0

for a in A:
    if a not in cnt:
        cnt[a] = 0
    cnt[a] += 1

for i in cnt.values():
    total += i * (i - 1) // 2

for i in range(N):
    print(total - (cnt[i] - 1))


Fixed submission:
N = int(input())
A = [int(a) for a in input().split()]
cnt = {}
total = 0

for a in A:
    if a not in cnt:
        cnt[a] = 0
    cnt[a] += 1

for i in cnt.values():
    total += i * (i - 1) // 2

for a in A:
    print(total - (cnt[a] - 1))
Buggy python submission (verdict: Time Limit Exceeded):
# D - String Formation

S = input()
Q = int(input())
rev = False

for _ in range(Q):
    T = [t for t in input().split()]
    t = int(T[0])
    if t == 1:
        rev = not rev
    if t == 2:
        f, c = int(T[1]), T[2]
        if f == 1:
            if rev:
                S = S + c
            else:
                S = c + S
        if f == 2:
            if rev:
                S = c + S
            else:
                S = S + c

print(S if not rev else S[::-1])


Fixed submission:
# D - String Formation

from collections import deque

S = deque([s for s in input()])
Q = int(input())
rev = False

for _ in range(Q):
    T = [t for t in input().split()]
    t = int(T[0])
    if t == 1:
        rev = not rev
    if t == 2:
        f, c = int(T[1]), T[2]
        if f == 1:
            if rev:
                S.append(c)
            else:
                S.appendleft(c)
        if f == 2:
            if rev:
                S.appendleft(c)
            else:
                S.append(c)

S = ''.join(list(S))
print(S if not rev else S[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
# D - String Formation

S = input()
Q = int(input())

for _ in range(Q):
    T = [t for t in input().split()]
    if T[0] == '1':
        S = S[::-1]
    else:
        if T[1] == '1':
            S = T[2] + S
        else:
            S = S + T[2]

print(S)


Fixed submission:
# D - String Formation

from collections import deque

S = deque([s for s in input()])
Q = int(input())
rev = False

for _ in range(Q):
    T = [t for t in input().split()]
    t = int(T[0])
    if t == 1:
        rev = not rev
    if t == 2:
        f, c = int(T[1]), T[2]
        if f == 1:
            if rev:
                S.append(c)
            else:
                S.appendleft(c)
        if f == 2:
            if rev:
                S.appendleft(c)
            else:
                S.append(c)

S = ''.join(list(S))
print(S if not rev else S[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
# D - String Formation

S = input()
Q = int(input())

for _ in range(Q):
    T = [t for t in input().split()]
    t = int(T[0])
    if t == 1:
        S = S[::-1]
    if t == 2:
        f, c = int(T[1]), T[2]
        if f == 1:
            S = c + S
        if f == 2:
            S = S + c

print(S)


Fixed submission:
# D - String Formation

from collections import deque

S = deque([s for s in input()])
Q = int(input())
rev = False

for _ in range(Q):
    T = [t for t in input().split()]
    t = int(T[0])
    if t == 1:
        rev = not rev
    if t == 2:
        f, c = int(T[1]), T[2]
        if f == 1:
            if rev:
                S.append(c)
            else:
                S.appendleft(c)
        if f == 2:
            if rev:
                S.appendleft(c)
            else:
                S.append(c)

S = ''.join(list(S))
print(S if not rev else S[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
# D - Friend Suggestions

from queue import Queue

N, M, K = map(int, input().split())

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

blocks = [(i, []) for i in range(N)]
for _ in range(K):
    c, d = map(int, input().split())
    c, d = c - 1, d - 1
    blocks[c][1].append(d)
    blocks[d][1].append(c)

Q = Queue()
cnt = [0] * N
for i in range(N):
    visited = [False] * N
    Q.put(friends[i])
    visited[i] = True
    while not Q.empty():
        q = Q.get()
        if (q[0] != i and
                q[0] not in friends[i][1] and
                q[0] not in blocks[i][1]):
            cnt[i] += 1
        for j in q[1]:
            if not visited[j]:
                visited[j] = True
                Q.put(friends[j])

print(*cnt)


Fixed submission:
# D - Friend Suggestions

from queue import Queue

N, M, K = map(int, input().split())

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

blocks = [(i, []) for i in range(N)]
for _ in range(K):
    c, d = map(int, input().split())
    c, d = c - 1, d - 1
    blocks[c][1].append(d)
    blocks[d][1].append(c)

Q = Queue()
visited = [False] * N
group = [0] * N
for i in range(N):
    if visited[i]:
        continue
    Q.put(friends[i])
    visited[i] = True
    while not Q.empty():
        q = Q.get()
        group[q[0]] = i
        for j in q[1]:
            if not visited[j]:
                visited[j] = True
                Q.put(friends[j])

cnt = {}
for num in group:
    if num in cnt:
        cnt[num] += 1
    else:
        cnt[num] = 1

ans = [0] * N
for i in range(N):
    ans[i] = cnt[group[i]] - len(friends[i][1]) - 1
    for block in blocks[i][1]:
        if group[i] == group[block]:
            ans[i] -= 1

print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [input() for _ in range(N)]
dic = {}
for s in S:
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1

for key, value in sorted(dic.items()):
    if value == max(dic.values()):
        print(key)


Fixed submission:
N=int(input())
S=[input() for i in range(N)]
dictionary={}
for word in S:
    if word in dictionary:
        dictionary[word]+=1
    else:
        dictionary[word]=1
maximum=max(dictionary.values())
for key,value in sorted(dictionary.items()):
    if value==maximum:
        print(key)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
dic = {}
for i in range(N):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1

for item in sorted(dic.items()):
    if item[1] == max(dic.values()):
        print(item[0])


Fixed submission:
N=int(input())
S=[input() for i in range(N)]
dictionary={}
for word in S:
    if word in dictionary:
        dictionary[word]+=1
    else:
        dictionary[word]=1
maximum=max(dictionary.values())
for key,value in sorted(dictionary.items()):
    if value==maximum:
        print(key)
Buggy python submission (verdict: Time Limit Exceeded):
# D - Dice in Line

N, K = map(int, input().split())
P = [int(p) for p in input().split()]

Q = [0] * N
for i in range(N):
    Q[i] = ((1 + P[i]) * P[i] / 2) / P[i]

R = [0] * (N - K + 1)
for i in range(N - K + 1):
    R[i] += sum(Q[i:i + K])

print(max(R))


Fixed submission:
# D - Dice in Line

N, K = map(int, input().split())
P = [int(p) for p in input().split()]

Q = [0] * (N + 1)
for i in range(N):
    q = ((1 + P[i]) * P[i] / 2) / P[i]
    Q[i + 1] = Q[i] + q

mx = 0
for i in range(N - K + 1):
    mx = max(mx, Q[i + K] - Q[i])

print(mx)

Buggy python submission (verdict: Time Limit Exceeded):
# D - Dice in Line

N, K = map(int, input().split())
P = [int(p) for p in input().split()]

Q = [0] * N
for i in range(N):
    Q[i] = ((1 + P[i]) * P[i] / 2) / P[i]

R = [0] * (N - K + 1)
for i in range(N - K + 1):
    for j in range(i, i + K):
        R[i] += Q[j]

print(max(R))


Fixed submission:
# D - Dice in Line

N, K = map(int, input().split())
P = [int(p) for p in input().split()]

Q = [0] * (N + 1)
for i in range(N):
    q = ((1 + P[i]) * P[i] / 2) / P[i]
    Q[i + 1] = Q[i] + q

mx = 0
for i in range(N - K + 1):
    mx = max(mx, Q[i + K] - Q[i])

print(mx)

Buggy python submission (verdict: Time Limit Exceeded):
# D - Dice in Line

N, K = map(int, input().split())
P = [int(p) for p in input().split()]
mx = 0
mx_i = 0
for i in range(N - K + 1):
    if mx < sum(P[i:i + K]):
        mx = sum(P[i:i + K])
        mx_i = i

total = 0
for i in range(mx_i, mx_i + K):
    for j in range(1, P[i] + 1):
        total += j / P[i]

print(total)


Fixed submission:
# D - Dice in Line

N, K = map(int, input().split())
P = [int(p) for p in input().split()]

Q = [0] * (N + 1)
for i in range(N):
    q = ((1 + P[i]) * P[i] / 2) / P[i]
    Q[i + 1] = Q[i] + q

mx = 0
for i in range(N - K + 1):
    mx = max(mx, Q[i + K] - Q[i])

print(mx)
Buggy python submission (verdict: Runtime Error):
# C - Snack

from math import gcd

A, B = map(int, input().split())
print(A * B // gcd(A, B))


Fixed submission:
# C - Snack

from fractions import gcd

A, B = map(int, input().split())
print(A * B // gcd(A, B))

Buggy python submission (verdict: Runtime Error):
# C - Snack

from math import gcd

A, B = map(int, input().split())
print(int(A * B / gcd(A, B)))


Fixed submission:
# C - Snack

from fractions import gcd

A, B = map(int, input().split())
print(A * B // gcd(A, B))
Buggy python submission (verdict: Runtime Error):
# D - Coloring Edges on Tree

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

ans = [-1] * (N - 1)

def dfs(key, color=-1, parent=-1):
    k = 1
    for i in range(len(G[key])):
        if G[key][i][0] == parent:
            continue
        if color == k:
            k += 1
        ans[G[key][i][1]] = k
        dfs(G[key][i][0], k, key)
        k += 1

dfs(0)

print(max(ans))
for a in ans:
    print(a)


Fixed submission:
# D - Coloring Edges on Tree

import sys

sys.setrecursionlimit(10 ** 5)

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

ans = [-1] * (N - 1)

def dfs(key, color=-1, parent=-1):
    k = 1
    for i in range(len(G[key])):
        if G[key][i][0] == parent:
            continue
        if color == k:
            k += 1
        ans[G[key][i][1]] = k
        dfs(G[key][i][0], k, key)
        k += 1

dfs(0)

print(max(ans))
for a in ans:
    print(a)