Harryxun/stf_run huggingface dataset:
N=input()
D,X=map(int,input().split())
for i range(N):
  X+=(D-1+int(input()))//D
print(X)

### FIXED CODE ###

N=int(input())
D,X=map(int,input().split())
for i in range(N):
  a=int(input())
  X+=(D-1+a)//a
print(X)
n = int(input())

z_vec = [0] * n
w_vec = [0] * n


for i in range(0, n + 1):
    tmp = input().split()
    z_vec[i] = int(tmp[0]) + int(tmp[1])
    w_vec[i] = int(tmp[0]) - int(tmp[1])

z_ans = max(z_vec) - min(z_vec)
w_ans = max(w_vec) - min(w_vec)


print(f'{max(z_ans, w_ans)}')

### FIXED CODE ###

n = int(input())

p_one = input()
p_one_list = p_one.split(' ')

zmax = int(p_one_list[0]) + int(p_one_list[1])
zmin = int(p_one_list[0]) + int(p_one_list[1])
wmax = int(p_one_list[0]) - int(p_one_list[1])
wmin = int(p_one_list[0]) - int(p_one_list[1])


for i in range(1, n):
    line = input()
    tmp = line.split(' ')
    z = int(tmp[0]) + int(tmp[1])
    w = int(tmp[0]) - int(tmp[1])
    zmax = max(zmax, z)
    wmax = max(wmax, w)
    zmin = min(zmin, z)
    wmin = min(wmin, w)


z_ans = zmax - zmin
w_ans = wmax - wmin


print(f'{max(z_ans, w_ans)}')
def inpl():
    return list(map(int, input().split()))


S = input()

p = re.compile(r'([^L][^R])*[^L]?$')

if p.match(S):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

def inpl():
    return list(map(int, input().split()))


S = input()

flag = True
for i in range(len(S)):
    if i % 2 == 0 and S[i] in 'RUD':
        continue
    elif i % 2 == 1 and S[i] in 'LUD':
        continue
    flag = False

print('Yes' if flag is True else 'No')
MAXN = 1005
MAXV = (MAXN * (MAXN - 1)) // 2
to = [[] for _ in range(MAXV)]
ID = [[-1] * MAXN for _ in range(MAXN)]

def toID(i, j):
    if i > j:
        i, j = j, i
    return ID[i][j]

visited = [False] * MAXV
calculated = [False] * MAXV
dp = [0] * MAXV
def dfs(v):
    if visited[v]: #すでに訪れたことがある時
        if not calculated[v]: #計算されたことがない時 = ループがある
            return -1
        return dp[v]
    visited[v] = True
    dp[v] = 1
    for u in to[v]:
        res = dfs(u)
        if res == -1:
            return -1
        dp[v] = max(dp[v], res + 1)
    calculated[v] = True
    return dp[v]

def main():
    N = int(input())
    a = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(N)]

    V = 0 #頂点の数
    for i in range(N - 1):
        for j in range(i + 1, N):
            ID[i][j] = V
            V += 1
    
    for i in range(N):
        for j in range(N - 1):
            a[i][j] = toID(i, a[i][j]) #対戦相手で管理していたのを試合番号に変える
        for j in range(N - 2):
            to[a[i][j + 1]].append(a[i][j])
    
    # import numpy as np
    # print (np.array(to))
    # print (np.array(ID))

    ans = 0
    for i in range(V):
        res = dfs(i)
        if res == -1:
            print (-1)
            return 0
        ans = max(ans, res)
    print (ans)
    return 0

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
from collections import deque

N = int(input())
A = [list(reversed(list(map(lambda x: int(x) - 1, input().split())))) for _ in range(N)]
B = {i: row for i, row in enumerate(A)}

# print (A)
# print (B)

end = 0

for k in range(8000):
    used = set()
    dels = []
    for i, q in B.items():
        if not q:
            continue
        if i in used:
            continue
        j = q[-1]
        if j in used:
            continue
        if A[j][-1] == i:
            A[j].pop()
            A[i].pop()
            used.add(i)
            used.add(j)
            if not A[i]:
                end += 1
                dels.append(i)
            if not A[j]:
                end += 1
                dels.append(j)
    if not used:
        print (-1)
        exit()
    
    if end == N:
        print (k + 1)
        exit()
    
    for i in dels:
        del B[i]
        
print (N * (N - 1) // 2)
n=int(input())
l=list(map(int,input().split()))
l.sort()
lcount=[]
count=0
now=l[0]
for i in range(n):
  if now==l[i]:
    count+=1
  else:
    lcount.append([count,now])
    count=1
    now=l[i]
if count!=1:
  lcount.append([count,now])
count=0
for i in range(1,len(lcount)-1):
  scount=0
  scount+=lcount[i][0]
  if lcount[i][1]-lcount[i-1][1]==1:
    scount+=lcount[i-1][0]
  if lcount[i][1]-lcount[i+1][1]==-1:
    scount+=lcount[i+1][0]
  if scount>count:
    count=scount
count1=lcount[0][0]
if lcount[1][1]-lcount[0][1]==1:
  count1+=lcount[1][0]
count2=lcount[-1][0]
if lcount[-2][1]-lcount[-1][1]==-1:
  count2+=lcount[-2][0]
print(max(count,count1,count2))

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
l.sort()
lcount=[]
count=0
now=l[0]
for i in range(n):
  if now==l[i]:
    count+=1
  else:
    lcount.append([count,now])
    count=1
    now=l[i]
lcount.append([count,now])
if len(lcount)==1:
  print(n)
elif len(lcount)==2:
  l1=lcount[0][0]
  l2=lcount[1][0]
  if lcount[1][1]-lcount[0][1]==1:
    print(l1+l2)
  else:
    print(max(l1,l2))
else:
  count=0
  for i in range(1,len(lcount)-1):
    scount=0
    scount+=lcount[i][0]
    if lcount[i][1]-lcount[i-1][1]==1:
      scount+=lcount[i-1][0]
    if lcount[i][1]-lcount[i+1][1]==-1:
      scount+=lcount[i+1][0]
    if scount>count:
      count=scount
  count1=lcount[0][0]
  if lcount[1][1]-lcount[0][1]==1:
    count1+=lcount[1][0]
  count2=lcount[-1][0]
  if lcount[-2][1]-lcount[-1][1]==-1:
    count2+=lcount[-2][0]
  print(max(count,count1,count2))
a, b = [map(int, input().split())]

print("Odd" if(a % 2 == 1 and b % 2 == 1) else "Even")


### FIXED CODE ###

a, b = map(int, input().split())

print("Odd" if(a % 2 == 1 and b % 2 == 1) else "Even")
x=input()
a=x // 500
y=x-500a
b= y // 5
print(a*1000+b*5)

### FIXED CODE ###

x=int(input())
a =x // 500
y = x-500*a
b = y // 5
happy = a*1000+b*5
print(happy)
s,t=map(int,input().split())
ans=0
for i in range(3):
	if s[i]==t[i]:
		ans+=1
print(ans)

### FIXED CODE ###

s=input()
t=input()
ans=0
for i in range(3):
	if s[i]==t[i]:
		ans+=1
print(ans)
r,d,x = map(int, input().split())

for i in range(10):
  x += r*x - D
  printx(x)
  

### FIXED CODE ###

r,d,x = map(int, input().split())

count = 0
while count < 10:
  x = r*x-d
  print(x)
  count += 1
x, y, a, b, c = map(int,input().split())
p = [list(map(int,input().split())) for _ in range(3)]

for i, e in enumerate(p):
    p[i] = list(sorted(e,reverse=True))

g, h = 0, 0
ans = 0
for i in range(x):
    if p[0][i] >= p[2][g]:
        ans += p[0][i]
    else:
        if p[1][h] < p[0][i]:
            ans += p[0][i]
            h += 1
        else:
            ans += p[2][g]
            g += 1
            p[2][g] = 0

for i, e in enumerate(p):
    p[i] = list(sorted(e,reverse=True))

g = 0
for i in range(y):
    print(p[1][i],p[2][g])
    if p[1][i] >= p[2][g]:
        ans += p[1][i]
    else:
        ans += p[2][g]
        g += 1
print(ans)

### FIXED CODE ###

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())))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
p = p[:x]
q = q[:y]
apple = p + q + r
apple.sort(reverse=True)
ans = sum(apple[:x+y])
print(ans)
L, R = map(int, input().split())

LARGE = 10 ** 9 + 7


def get_l(vl, le_r):
    # vl <= L <= R <= 2 ** le_r - 1
    res_ = 0

    if vl == 0:
        res_ += pow(2, le_r, LARGE)
        vl = 1
    for l_ in range(le_r):
        if vl % (2 ** (l_ + 1)) != 0:
            le_total = le_r - bin(vl).count("1")
            res_ += pow(3, l_, LARGE) * pow(2, le_total - l_, LARGE)
            res_ %= LARGE
            vl += 2 ** l_
    return res_


def get_r(vr):
    # 0 <= L <= R <= vr
    res_ = 0
    if vr == 0:
        return 1
    l_ = 0
    while True:
        if 2 ** (l_ + 1) - 1 > vr:
            break
        l_ += 1

    return (pow(3, l_, LARGE) + 2 * get_r(vr - 2 ** l_)) % LARGE


res = 0
le = 0
left = 2 ** le
right = 2 ** (le + 1) - 1


while True:
    if right < L:
        pass
    elif L <= left <= right <= R:
        res += pow(3, le, LARGE)
    elif R < left:
        break
    elif left <= L <= right <= R:
        res += get_l(L, le + 1)
    elif L <= left <= R <= right:
        res += get_r(R - left)
    else:
        # left <= L <= R <= right:
        # find mid
        mid = left
        for le2 in range(le - 1, -1, -1):
            if L < mid + 2 ** le2 <= R:
                res += get_l(L - mid, le2)
                res += get_r(R - mid)
            elif mid + 2 ** le2 <= L:
                mid += 2 ** le2
            else:
                pass

    res %= LARGE
    le += 1
    left *= 2
    right *= 2
    right += 1

print(res)


### FIXED CODE ###


LARGE = 10 ** 9 + 7

# flag_x : left < x
# flag_y : y < right
# flag_z : msb


def f(pos, flag_x, flag_y, flag_z, memo, left, right):
    if pos == -1:
        return 1
    if memo[pos][flag_x][flag_y][flag_z] != -1:
        return memo[pos][flag_x][flag_y][flag_z]
    ret = 0
    # x 0, y 0
    if flag_x or left[pos] == '0':
        ret += f(pos - 1, flag_x, 1 if right[pos] == '1' else flag_y, flag_z, memo, left, right)
    # x 0, y 1
    if (flag_x or left[pos] == '0') and (flag_y or right[pos] == '1') and flag_z:
        ret += f(pos - 1, flag_x, flag_y, flag_z, memo, left, right)
    # x 1, y 1
    if flag_y or right[pos] == '1':
        ret += f(pos - 1, 1 if left[pos] == '0' else flag_x, flag_y, 1, memo, left, right)
    ret %= LARGE
    memo[pos][flag_x][flag_y][flag_z] = ret
    return ret


def solve_greed_f(L, R):

    res_g = 0

    for i in range(L, R + 1):
        for j in range(i, R + 1):
            if j % i == j ^ i:
                res_g += 1

    return res_g


def main():

    ll, rr = map(int, input().split())

    left = '{:060b}'.format(ll)[::-1]
    right = '{:060b}'.format(rr)[::-1]

    memo = [[[[-1 for m in range(2)] for k in range(2)] for j in range(2)] for i in range(60)]

    res = f(59, 0, 0, 0, memo, left, right)

    print(res)


if __name__ == "__main__":
    main()
S = input()
N = len(S)
if S[0:(N-1)//2] == [((N+2)//2):N]:
  print('Yes')
elif:
  print('No')

### FIXED CODE ###

S = input()
N = len(S)
A = (len(S) - 1) // 2
B = (len(S) + 3) // 2
if S[0:A] == S[B - 1:N]:
  print('Yes')
else:
  print('No')
from operator import mul
from functools import reduce

def com(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def run():
  N = int(input())
  K = int(input())
  Nnum = len(str(N))
  #1
  all1 = com(Nnum, K)*9**K
  #2
  all2 = (9-int(str(N)[0]))*com(Nnum-1, K-1)*9**(K-1)
  if K == 1:
    print(all1-all2)
  #3
  elif K == 2:
    all3 = 0
    for n in range(1, Nnum):
      N2 = int(str(N)[n])
      if N2 != 0:
        all3 += 9-N2
        break
      all3 += 9
    else:
      all3 = (Nnum-1)*9
    print(all1-all2-all3)
  #4
  else:
    all3 = 0
    count = 0
    for n in range(1, Nnum):
      N2 = int(str(N)[n])
      if N2 != 0:
        if count == 0:
          all3 += (9-N2)*com(Nnum-n-1, 1)*9
        elif count == 1:
          all3 += 9-N2
        count += 1
        if count == 2:
          break
      elif count == 0:
        all3 += 9*(Nnum-n-1)*9
      else:
        all3 += 9
    else:
      if count == 0:
        all3 = com(Nnum-1, 2)*9*9
      else
        all3 = (Nnum-1)*9
    print(all1-all2-all3)
    
  

if __name__ == '__main__':
    run()

### FIXED CODE ###

def run():
  N = list(map(int, list(input())))
  K = int(input())
  Nlen = len(N)
  dp = [[[0]*(K+2) for _ in range(2)] for n in range(Nlen+1)]
  dp[0][0][0] = 1
  for nlen in range(Nlen):
    dN = N[nlen]
    for d in range(10):
      for j in range(2):
        for k in range(K+2):
          flagj = j or d < dN
          if (flagj == 0) and (d > dN): continue
          flagk = min(K+1, k+(d != 0))
          dp[nlen+1][flagj][flagk] += dp[nlen][j][k]
  print(dp[-1][0][K]+dp[-1][1][K])
  
if __name__ == '__main__':
    run()
N = int(input())
for i in range(1,3501):
  for j in range(i,3501):
    t = N*i*j % (4*i*j - N*i - j*N)
    if t==0:
      print(t,i,j)
      exit()


### FIXED CODE ###

N = int(input())
for n in range(1, 3501):
    for w in range(n, 3501):

        try:
            t = (N*n*w) % (4*n*w - N*w - N*n)
        except:
            continue

        if t == 0 and 4*n*w - N*w - N*n>=0:
            print((N*n*w) // (4*n*w - N*w - N*n), n, w)
            exit()
import numpy as np

s = [ord(a)-ord('a') for a in input()]
n = len(s)

if n == 2:
    if s[0] == s[1]:
        print('1 2')
    else
        print('-1 -1')
    exit()

cnt = np.array([0] * 26)
cum = [cnt.copy()]

for i, a in enumerate(s):
    cnt[a] += 1
    cum.append(cnt.copy())

def is_check(cum, n):
    for i in range(3, n+1, 2):
        d = i // 2
        for j in range(n-i+1):
            for k in cum[j+i] - cum[j]:
                if k > d:
                    return j+1, j+i
    return -1, -1

print(' '.join(map(str, is_check(cum, len(s)))))

### FIXED CODE ###

import numpy as np

s = [ord(a)-ord('a') for a in input()]
n = len(s)

if n == 2:
    if s[0] == s[1]:
        print('1 2')
    else:
        print('-1 -1')
    exit()

cnt = np.array([0] * 26)
cum = [cnt.copy()]

for i, a in enumerate(s):
    cnt[a] += 1
    cum.append(cnt.copy())

def is_check(cum, n):
    i = 3
    d = 1
    for j in range(n-i+1):
        cum_ = cum[j+i] - cum[j]
        if cum_[cum_>1]:
            return j+1, j+i
    return -1, -1

print(' '.join(map(str, is_check(cum, len(s)))))
#!/usr/bin/env python3

from functools import lru_cache

a = {-1}


@lru_cache(maxsize=10000)
def solv1(n):
    if n == 0:
        return 1
    if n < 0:
        return 0
    count = 0
    if (n-2) not in a:
        count += solv1(n-2)
    if (n-1) not in a:
        count += solv1(n-1)
    return count


def solv(n):
    m = 10000
    while m < n:
        solv1(m)
        m += 10000
    return solv1(n)


if __name__ == '__main__':

    n, m = map(int, input().split())
    for _ in range(m):
        a.add(int(input()))

    ans = solv(n)

    print(ans % 1000000007)


### FIXED CODE ###

#!/usr/bin/env python3

import math
from functools import lru_cache


def ncr(n, r):
    r = min(r, n - r)
    # 桁が小さいときは直接 math.factorial を使ったほうが早い
    if n + r < 4000:
        return math.factorial(n) // math.factorial(n-r) // math.factorial(r)
    if r == 0:
        return 1
    if r == 1:
        return n
    numerator = list(range(n - r + 1, n + 1))
    denominator = list(range(1, r+1))
    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] //= pivot
                denominator[k] //= pivot
    result = 1
    for k in range(r):
        result *= numerator[k]
    return result


# 穴なしで n step 離れている場合の組み合わせ
def no_hole(n):
    count = 0
    m = n // 2
    for i in range(0, m+1):
        count += ncr(n-i, i)
    return count


# 穴なしで n step 離れている場合の組み合わせ(高速化版)
@lru_cache(maxsize=8192)
def no_hole2(n):
    if n <= 5:
        return (1, 1, 2, 3, 5, 8)[n]
    if n % 2:
        h = (n-1) // 2
        m1 = no_hole2(h-1)
        m0 = no_hole2(h)
        return 2 * m1 * m0 + m0 * m0
    else:
        h = n // 2
        m2 = no_hole2(h-2)
        m1 = no_hole2(h-1)
        m0 = no_hole2(h)
        return m1 * m1 + m2 * m0 + m1 * m0


def solv(n, m, a):
    ans = 1
    current_pos = 0
    for pos in a:
        dist = pos - 1 - current_pos
        if dist < 0:
            return 0
        ans *= no_hole2(dist)
        current_pos = pos + 1
    dist = n - current_pos
    ans *= no_hole2(dist)
    return ans


if __name__ == '__main__':

    n, m = map(int, input().split())
    a = [int(input()) for _ in range(m)]

    ans = solv(n, m, a)

    P_NUM = 1000000007
    print(ans % P_NUM)
import math

n,m = map(int, input().split())

for i in range(1, math.ceil(math.sqrt(m+1))):
    if m % i != 0:
        continue
    if m // i > n:
        continue
    ans = i
print(ans)

### FIXED CODE ###

def f():
  n, m = map(int, input().split())
  for i in range(m//n+1)[::-1]:
    if m%i==0:return i
print(f())
import math

n = int(input())

s = input()
count = 0
for i in range(n):
    if (s[i] == 'A' and s[i + 1] == 'B' and s[i+2] == 'C'):
        count += 1

print(count)


### FIXED CODE ###

import math

n = int(input())

s = input()
count = 0
for i in range(2, n):
    if (s[i-2] == 'A' and s[i - 1] == 'B' and s[i] == 'C'):
        count += 1

print(count)
from collections import Counter as ca

s = input()

count = ca(s)
count = list(ca.values())
ans = 'Yes'
for i in count:
  if i % 2 != 0:
    ans = 'No'
    break
    
print(ans)

### FIXED CODE ###

from collections import Counter as ca

s = input()

count = ca(s)
count = list(count.values())
ans = 'Yes'
for i in count:
  if i % 2 != 0:
    ans = 'No'
    break
    
print(ans)
def main():
    import sys
    N,K=list(map(int,sys.stdin.readline().split()))
    A=list(map(int,sys.stdin.readline().split()))

    Ap=[x for x in A if x>=0 ]
    Am=[abs(x) for x in A if x<0]

    if K==N:
        out=1
        for a in A:
            out*=a
            out%=10**9+7
        print(out)
        return


    if K%2==1 and len(Ap)==0:
        Am.sort()
        out=1
        for i in range(K):
            out*=Am[i]
            out%=10**9+7
        print((-out)%(10**9+7))
        return

    Ap.sort(reverse=True)
    Am.sort(reverse=True)
    
    ap_idx=0
    am_idx=0
    result=1
    for _ in range(0,K,2):
        if K%2==0 and ap_idx+1<len(Ap):
            pmax=Ap[ap_idx]*Ap[ap_idx+1]
        elif K%2==1 and ap_idx+2<len(Ap):
            pmax=Ap[ap_idx]*Ap[ap_idx+1]
        else:
            pmax=-1

        if am_idx+1<len(Am):
            mmax=Am[am_idx]*Am[am_idx+1]
        else:
            mmax=-1

        if pmax==-1 and mmax==-1:
            break

        if pmax>mmax:
            result*=pmax
            ap_idx+=2
        else:
            result*=mmax
            am_idx+=2

        result%=(10**9+7)
    
    if K%2==1:
        kkkkkkkkkkkkkkkkkkkkkkkkkk
        result*=Ap[ap_idx]

    print(result%(10**9+7))

main()

### FIXED CODE ###

def main():
    import sys
    N,K=list(map(int,sys.stdin.readline().split()))
    A=list(map(int,sys.stdin.readline().split()))

    Ap=[x for x in A if x>=0 ]
    Am=[abs(x) for x in A if x<0]

    if K==N:
        out=1
        for a in A:
            out*=a
            out%=10**9+7
        print(out)
        return


    if K%2==1 and len(Ap)==0:
        Am.sort()
        out=1
        for i in range(K):
            out*=Am[i]
            out%=10**9+7
        print((-out)%(10**9+7))
        return

    Ap.sort(reverse=True)
    Am.sort(reverse=True)
    
    ap_idx=0
    am_idx=0
    result=1

    for _ in range(0,K-1,2):
        if K%2==0 and ap_idx+1<len(Ap):
            pmax=Ap[ap_idx]*Ap[ap_idx+1]
        elif K%2==1 and ap_idx+2<len(Ap):
            pmax=Ap[ap_idx]*Ap[ap_idx+1]
        else:
            pmax=-1

        if am_idx+1<len(Am):
            mmax=Am[am_idx]*Am[am_idx+1]
        else:
            mmax=-1

        if pmax==-1 and mmax==-1:
            break

        if pmax>mmax:
            result*=pmax
            ap_idx+=2
        else:
            result*=mmax
            am_idx+=2

        result%=(10**9+7)
    
    if K%2==1:
        result*=Ap[ap_idx]

    print(result%(10**9+7))

main()
N = int(input())
As = sorted(list(map(int, input().split())))

sieve = [True] * 1000001

prev = 0

for i in range(N):
    if As[i] == prev:
        sieve[As[i]] = False
        continue
    else:
        prev = As[i]
        for j in range(2, 1000000 // prev + 1):
            sieve[prev * j] = False

count = 0
As = list(set(As))
for i in range(N):
    if sieve[As[i]] is True:
        count += 1
        
print(count)

### FIXED CODE ###

N = int(input())
As = sorted(list(map(int, input().split())))

sieve = [True] * 1000001

prev = 0

for i in range(N):
    if As[i] == prev:
        sieve[As[i]] = False
        continue
    else:
        prev = As[i]
        try:
            for j in range(2, 1000000 // prev + 1):
                sieve[prev * j] = False
        except:
            continue

count = 0
As = list(set(As))
for i in range(len(As)):
    if sieve[As[i]] is True:
        count += 1
        
print(count)
#!/usr/bin/env python3
import copy

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

    ans = [[None] for _ in range(N-1)]

    def dfs(focus,parent_color):
        if focus == N - 1:
            return
        color = 1
        for child,index in sides[focus]:
            if parent_color == color:
                color += 1 #もし親の色と被っていた場合はその色を飛ばす
            ans[index] = color
            dfs(child,color)
            color += 1 #同じ親から続く次の辺の色を変更する

    dfs(0,0)

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

if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
sys.setrecursionlimit(100000)

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

    ans = [[None] for _ in range(N-1)]

    def dfs(focus,parent_color):
        color = 1
        for child,index in sides[focus]:
            if parent_color == color:
                color += 1 #もし親の色と被っていた場合はその色を飛ばす
            ans[index] = color
            if child < N-1:
                dfs(child,color)
            color += 1 #同じ親から続く次の辺の色を変更する

    dfs(0,0)

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


if __name__ == "__main__":
    main()
input = map(int, input().split())
N, A, B = input
string = ''
while len(string) < N:
  string += 'b'*A+'r'*B
print(string[:N].count('b'))

### FIXED CODE ###

def resolve():
    N, A, B = map(int, input().split())
    div, mod = divmod(N, A+B)
    print(A*div + min(mod, A))

resolve()
n,k=map(int,input().split())
l=sorted(int(input()) for _ in range(n),reverse=True)
print(sum(l[:k]))

### FIXED CODE ###

n,k=map(int,input().split())
l=sorted(map(int,input().split()) ,reverse=True)
print(sum(l[:k]))
val, size = map(int, input().split())
disabledList = [int(x) for x in input().split()] # number
enableList = list(set(range(10)) - set(disabledList)) # number
resultList = [] # str, must reverse
isTenOver = False
for char in list(str(val)).reverse():
  targetInt = int(char)
  if isTenOver:
    targetInt += 1
  if int(char) in enableList:
    isTenOver = False
    resultList.append(char)
    continue
  resultList = [min(enableList)] * len(resultList)
  if int(char) > max(enableList):
    isTenOver = True
    resultList.append(str(min(enableList)))
  else:
    isTenOver = False
    minNum = min(filter(lambda x:x > int(char), enableList))
    resultList.append(str(minNum))

if isTenOver:
  minNum = min(filter(lambda x:x > 0, enableList))
  resultList.append(str(minNum))
print(''.join(resultList.reverse()))


### FIXED CODE ###

val, size = map(int, input().split())
disabledList = [int(x) for x in input().split()] # number
enableList = list(set(range(10)) - set(disabledList)) # number
resultList = [] # str, must reverse
isTenOver = False
for char in reversed(list(str(val))):
  targetInt = int(char)
  if isTenOver:
    targetInt += 1
  if targetInt in enableList:
    isTenOver = False
    resultList.append(str(targetInt))
    continue
  resultList = [str(min(enableList))] * len(resultList)
  if targetInt > max(enableList):
    isTenOver = True
    resultList.append(str(min(enableList)))
  else:
    isTenOver = False
    minNum = min(filter(lambda x:x > targetInt, enableList))
    resultList.append(str(minNum))

if isTenOver:
  minNum = min(filter(lambda x:x > 0, enableList))
  resultList.append(str(minNum))
print(''.join(reversed(resultList)))
A, B, K  = list(map(int, input().split()))
for i in range(K):
    if A >= 1:
        A = A-1
    elif B >= 1:
        B = B-1
    elif A == 0 and B == 0:
        break
print(A,B)

### FIXED CODE ###

s = input().split()
S = s[0]
T = s[1]
W1=T+S
print(W1)
N,K=map(int, input().split())
d=list(map(int,input().split()))
ans=0
for i in range(N+1):
    if d[i]>=K:
        ans=ans+1
print(ans)

### FIXED CODE ###

N,K=map(int, input().split())
d=list(map(int,input().split()))
ans=0
for i in range(N):
    if d[i]>=K:
        ans=ans+1
print(ans)