Harryxun/stf_run huggingface dataset:
N, A = [int(_) for _ in input().split()]
x = sorted([int(_) for _ in input().split()])

dp = [[0] * (sum(x)+1) for j in range(N+1)]

dp[0][0] = 1
for i in range(1, N+1):
    for j in list(range(1, N+1))[::-1]:
        for k in list(range(x[i-1], sum(x[:i])+1))[::-1]:
            dp[j][k] += dp[j-1][k - x[i-1]]

print(sum([dp[i][i*A] for i in range(1, N+1)]))


### FIXED CODE ###


N, A = [int(_) for _ in input().split()]
x = sorted([int(_) for _ in input().split()])

dp = [[0] * (sum(x)+1) for j in range(N+1)]

dp[0][0] = 1
for i in range(1, N+1):
    for j in list(range(1, N+1))[::-1]:
        for k in list(range(x[i-1], sum(x[:i])+1))[::-1]:
            dp[j][k] += dp[j-1][k - x[i-1]]

print(sum([dp[i][i*A] for i in range(1, N+1) if i*A <= sum(x)]))
A,B,C,D = int(input()) for i in range(4)
AB = A * B
CD = C * D

if AB == CD:
  print(AB)
else:
  print(AB) if AB > CD else print(CD)

### FIXED CODE ###

A,B,C,D = map(int, input().split())
print(max(A*B,C*D))
import math

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

count = 0



while(a!=[]):
    temp = a[-1]
    a.pop(-1)
    b=2**math.floor(math.log2(temp))
    if a ==[]:
        break
    if 2*b-temp > 0:
        count += 1
        a.pop(a.index(2*b-temp))
    
print(count)



### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a.sort()
b = {}
for i in range(len(a)):
    if a[i] in b:
        b[a[i]] += 1
    else:
        b[a[i]] = 1
twins = []
now = 1
while now <= a[-1]:
    now *= 2
    twins.append(now)
for i in range(len(a) - 1, -1, -1):
    tmpa = 0
    if  b[a[i]] == 0:
        continue
    for j in range(len(twins) - 1, -1, -1):
        if twins[j] <= a[i]:
            break
        tmpa = twins[j] - a[i]
    if tmpa == a[i]:
        if b[tmpa] >= 2:
            b[tmpa] -= 2
    elif tmpa in b and b[tmpa] != 0:
        b[tmpa] -= 1
        b[a[i]] -= 1
countb = 0
for i in b:
    countb += b[i]
print((n - countb) // 2)
N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]

A.sort()
BC.sort(reverse = True, key = lambda x:x[1])
ans = sum(A)
idx = 0

for i in range(M):
    if idx + BC[i][0] >= N :
        BC[i][0] = N-idx
    if A[idx + BC[i][0]] < BC[i][1]:
        ans += BC[i][1] * BC[i][0] - sum(A[idx:idx+BC[i][0]])
    else:
        for j in range(BC[i][0]):
            if A[idx+j] >= BC[i][1]:
                break
        ans += BC[i][1] * j - sum(A[idx:idx + j])
        print(A[idx:idx+j],j)
    idx += BC[i][0]
    if idx > N-1:break
print(ans)

            

### FIXED CODE ###

N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]

A.sort()
BC.sort(reverse = True, key = lambda x:x[1])
ans = sum(A)
idx = 0

for i in range(M):
    if idx + BC[i][0] >= N :
        BC[i][0] = N-idx
    if A[idx + BC[i][0]-1] < BC[i][1]:
        ans += BC[i][1] * BC[i][0] - sum(A[idx:idx+BC[i][0]])
    else:
        for j in range(BC[i][0]):
            if A[idx+j] >= BC[i][1]:
                break
        ans += BC[i][1] * j - sum(A[idx:idx + j])
        break
    idx += BC[i][0]
    if idx > N-1:break
print(ans)
a=list(map(int,input.sprit()))
print(min(a[0]*a[1],a[2]))

### FIXED CODE ###

a=list(map(int,input().split()))
print(min(a[0]*a[1],a[2]))
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b_list = [int(input()) for _ in range(n)]

card = [[0] * 3 for _ in range(3)]
for i in range(3):
    for j in range(3):
        if a[i][j] == b_list:
            card[i][j] = 1

for i in range(3):
    if card[i][:] == [1,1,1] or card[:][i] == [1,1,1]:
        print('Yes')
        exit()
if sum([card[0][0], card[1][1], card[2][2]]) == 3 or sum([card[0][2], card[1][1], card[2][0]) == 3:
    print('Yes')
    exit()
print('No')

### FIXED CODE ###

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

card = [[0] * 3 for _ in range(3)]
for i in range(3):
    for j in range(3):
        if a[i][j] in b_list:
            card[i][j] = 1

for i in range(3):
    if sum(card[i]) == 3 or sum([card[0][i], card[1][i], card[2][i]]) == 3:
        print('Yes')
        exit()
if sum([card[0][0], card[1][1], card[2][2]]) == 3 or sum([card[0][2], card[1][1], card[2][0]]) == 3:
    print('Yes')
    exit()
print('No')
from collections import Counter
n = int(input())
arr = list(map(int, input().split()))

odd_list =[]
num_list =[]

for i in range(n):
    if i%2 == 0:
        odd_list.append(arr[i])
    if i%2 != 0:
        num_list.append(arr[i])

odd_count = Counter(odd_list)
num_count = Counter(num_list)
odd1 = odd_count[odd_count.most_common()[0][0]]
num1 = num_count[num_count.most_common()[0][0]]


if len(set(arr)) == 1:
    print(int(n/2))
    exit()

if len(set(odd_count)) == 1 and len(set(num_count)) != 1:
    num2 = num_count[num_count.most_common()[1][0]]
    if odd_list[0] == num_count.most_common()[0][0]:
        print(int(n/2)-num2)
        exit()
    if odd_list[0] != num_count.most_common()[0][0]:
        print(int(n/2)-num1)
        exit()

if len(set(odd_count)) != 1 and len(set(num_count)) == 1:
    odd2 = odd_list[odd_count.most_common()[1][0]]
    if num_count[0] == odd_count.most_common()[0][0]:
        print(int(n/2)-odd2)
        exit()
    if num_list[0] != odd_count.most_common()[0][0]:
        print(int(n/2)-odd1)
        exit()

odd2 = odd_count[odd_count.most_common()[1][0]]
num2 = num_count[num_count.most_common()[1][0]]

if odd_count.most_common()[0][0] != num_count.most_common()[0][0]:
    print(n-odd1-num1)

if odd_count.most_common()[0][0] == num_count.most_common()[0][0]:
    print(min(n-odd1-num2, n-odd2-num1))

### FIXED CODE ###

from collections import Counter
n = int(input())
arr = list(map(int, input().split()))

odd_list =[]
num_list =[]

for i in range(n):
    if i%2 == 0:
        odd_list.append(arr[i])
    if i%2 != 0:
        num_list.append(arr[i])

odd_count = Counter(odd_list)
num_count = Counter(num_list)
odd1 = odd_count[odd_count.most_common()[0][0]]
num1 = num_count[num_count.most_common()[0][0]]

if odd1 != num1:
    print(n-odd_count.most_common()[0][1]-num_count.most_common()[0][1])
    exit()

if len(set(arr)) == 1:
    print(int(n/2))
    exit()

if len(set(num_list))==1 and len(set(odd_list))==1:
    print(0)
    exit()

if len(set(odd_count)) == 1 and len(set(num_count)) != 1:
    num2 = num_count[num_count.most_common()[1][0]]
    if odd_list[0] == num_count.most_common()[0][0]:
        print(int(n/2)-num2)
        exit()
    if odd_list[0] != num_count.most_common()[0][0]:
        print(int(n/2)-num1)
        exit()

if len(set(odd_count)) != 1 and len(set(num_count)) == 1:
    odd2 = odd_list[odd_count.most_common()[1][0]]
    if num_list[0] == odd_count.most_common()[0][0]:
        print(int(n/2)-odd2)
        exit()
    if num_list[0] != odd_count.most_common()[0][0]:
        print(int(n/2)-odd1)
        exit()

odd2 = odd_count[odd_count.most_common()[1][0]]
num2 = num_count[num_count.most_common()[1][0]]

if odd_count.most_common()[0][0] != num_count.most_common()[0][0]:
    print(n-odd1-num1)

if odd_count.most_common()[0][0] == num_count.most_common()[0][0]:
    print(min(n-odd1-num2, n-odd2-num1))
N = str(input())
N = int(N)
Lines = input().split(" ")
LinesInt = map(int, Lines)
answer = 0
    
for lineI in range(len(N)):
    for lineJ in range(lineI+1,len(N)):
        for lineK in range(lineJ+1,len(N)):
             if (LinesInt[lineI] + LinesInt[lineJ] > LinesInt[lineK]) and (LinesInt[lineK] + LinesInt[lineJ] > LinesInt[lineI]) and (LinesInt[lineK] + LinesInt[lineI] > LinesInt[lineJ]):
                answer += 1
print(answer)

### FIXED CODE ###

N = int(input())
Lines = list(map(int, input().split(" ")))
Lines.sort()
answer = 0
 
import bisect
 
for lineI in range(N):
    for lineJ in range(lineI+1,N):
    	answer += bisect.bisect_left(Lines,Lines[lineI]+Lines[lineJ])-lineJ-1
print(answer)
a, b, k = map(int, input().split())
m = b if a > b else a
ans = []
for i in range(1, (m // 2)+2):
  if a % i == 0 and b % i == 0:
    ans.append(i)
print(ans[-k])

### FIXED CODE ###

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

def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n // i)
  divisors.sort()
  return divisors

a_divs = make_divisors(a)
b_divs = make_divisors(b)

common_divs = []
for i in range(len(a_divs)):
  a_div = a_divs[i]
  if a_div in b_divs:
    common_divs.append(a_div)
print(common_divs[-k])
s = input()
t = input()

if s in t and t = s + 1:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

s = input()
t = input()

if(s == t[:-1]):
    print("Yes")
else:
    print("No")
#abc176-e
import sys,math,collections,itertools
import numpy as np
input = sys.stdin.readline
H,W,M=list(map(int,input().split()))
point_bom = [[0]*(W+1) for _ in range(H+1)]
for _ in range(M):
    h,w = map(int,input().split())
    point_bom[h][w]=1
point_bom = np.array(point_bom)
row_bom = point_bom.sum(axis=0)
col_bom = point_bom.sum(axis=1)
max_row = row_bom.max()
max_col = col_bom.max()

ind_max_row =[]
ind_max_col = []

for i in range(len(row_bom)):
    if row_bom[i] == max_row:
         ind_max_row.append(i)
for i in range(len(col_bom)):
    if col_bom[i] == max_col:
        ind_max_col.append(i)

flag = 1#爆破対象が置かれる　おかれている＝１　いない＝０
for mr in ind_max_row:
    for mc in ind_max_col:
        if point_bom[mc][mr] == 0:
            flag = 0
            break
    if flag == 0:
        break
print(max_row+max_col - flag)
        
        


### FIXED CODE ###

import sys,math,collections,itertools
input = sys.stdin.readline

H,W,M=map(int,input().split())
bom = [] #ボムの場所
bomH =[0]*(H+1) 
bomW=[0]*(W+1)

for _ in range(M):
    h,w=map(int,input().split())
    bom.append((h,w))
    bomH[h]+=1
    bomW[w]+=1

#縦の爆弾と横の爆弾は独立。爆弾を置く場所に爆弾があると-1
max_bomH = max(bomH)
max_bomW = max(bomW)

cnt = 0#爆弾が置かれた場所のbomH,bomWがともにMaxの場所の数
for h,w in bom:
    if bomH[h]==max_bomH and bomW[w] == max_bomW:
        cnt += 1

print(max_bomH +max_bomW -(cnt == bomH.count(max_bomH) * bomW.count(max_bomW)))
#! python
# shell_sort.py

import copy
import math

count = 0

def insertion_sort(A, N, g):
    global count
    for i in range(g, N):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            count += 1
        A[j + g] = v

# h_(i+1) = 3h_i + 1 が最良の間隔
def shell_sort(A, N):
    h = 1
    G = []
    while True:
        G.append(h)
        h = 3*h + 1
        if h > N:
            break
    G = G[::-1]
    m = len(G)

    for i in range(m):
        insertion_sort(A, N, G[i])
    return m, G

n = int(input())
A = [int(input()) for i in range(n)]

m, G = shell_sort(A, n)

print(m)
print(' '.join([str(h) for h in G]))
print(count)
for x in A:
    print(x)


### FIXED CODE ###

import math
import sys

count = 0
m = 0
G = []

def insertion_sort(A, N, g):
    global count
    for i in range(g, N):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            count += 1
        A[j + g] = v

# h_(i+1) = 3h_i + 1 が最良の間隔 (らしい)
def shell_sort(A, N):
    global m, G
    m = math.floor(math.log(2*N+1, 3))
    G = [int((pow(3, i)-1)/2) for i in range(m, 0, -1)]

    for i in range(m):
        insertion_sort(A, N, G[i])


n = int(input())
A = list(map(int, sys.stdin.readlines()))
shell_sort(A, n)

print(m)
print(' '.join([str(h) for h in G]))
print(count)
for x in A:
    print(x)
def gcd(a, b):
 if a < b:
    a, b = b, a
 if b == 0:
    return a
 c = a % b
 return gcd(b, c)
def lcm(a,b):
  return int(a*b/gcd(a,b))

N = int(input())
T = [int(input()) for i in range(N)]
ans = T[0]
for i in T[1:]:
    ans = lcm(ans,i)

print(ans)

### FIXED CODE ###

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

from functools import reduce
from fractions import gcd

def lcm(a,b):
  return a*b //gcd(a,b)

print(reduce(lcm,T))
n,m=map(int,input().split())
s=list(str(input()))
f=0
mf=0
for i in range(n):
    if s[i]=='1':
        f+=1
        mf=max(mf,f)
    else:
        f=0
if mf>=m:
    print(-1)
    exit()
reans=[]
s.reverse()
nk=-1
while nk<n:
    for i in range(m,0,-1):
        if s[nk+i]=='0':
            nk=nk+i
            reans.append(i)
            break
reans.reverse()
print(*reans)
        

### FIXED CODE ###

n,m=map(int,input().split())
s=list(str(input()))
f=0
mf=0
for i in range(n+1):
    if s[i]=='1':
        f+=1
        mf=max(mf,f)
    else:
        f=0
if mf>=m:
    print(-1)
    exit()
reans=[]
s.reverse()
nk=0
while nk<n:
    for i in range(min(n-nk,m),0,-1):
        if s[nk+i]=='0':
            nk=nk+i
            reans.append(i)
            break
reans.reverse()
print(*reans)
import sys
readline = sys.stdin.readline

def solve():
    X, Y = map(int, readline().split())

    Y - X * 2 = a

    if a >= 0 and a % 2 == 0:
        print('Yes')
    else:
        print('No')

solve()

### FIXED CODE ###

import sys
readline = sys.stdin.readline

def solve():
    X, Y = map(int, readline().split())

    a = Y - X * 2

    if a >= 0 and a % 2 == 0 and a // 2 <= X:
        print('Yes')
    else:
        print('No')

solve()
m = [list(input().strip()) for _ in range(H)]
mod = 10**9 + 7

dp = [[-1] * W for _ in range(H)]
dp[H-1][W-1] = 1
que = deque()
que.append((H-2, W-1))
que.append((H-1, W-2))
visited = set([(H-1, W-1)])
while len(que) > 0:
    h, w = que.popleft()
    visited.add((h, w))
    steps = 0
    if h < H-1 and m[h+1][w] == "." and ((h+1, w) in visited):
        steps += dp[h+1][w]
    if w < W-1 and m[h][w+1] == "." and ((h, w+1) in visited):
        steps += dp[h][w+1]
    steps %= mod
    dp[h][w] = steps

    if not ((h-1, w) in visited) and h-1 >= 0 and m[h-1][w] == ".":
        que.append((h-1, w))
    if not ((h, w-1) in visited) and w-1 >= 0 and m[h][w-1] == ".":
        que.append((h, w-1))

print(dp[0][0])

### FIXED CODE ###

H, W = map(int, input().split(" "))
m = [list(input().strip()) for _ in range(H)]
mod = 10**9 + 7

dp = [[0] * W for _ in range(H)]
dp[0][0] = 1

for h in range(H):
    for w in range(W):
        if h+1 < H and m[h+1][w] == ".":
            dp[h+1][w] += dp[h][w]
            dp[h+1][w] %= mod
        if w+1 < W and m[h][w+1] == ".":
            dp[h][w+1] += dp[h][w]
            dp[h][w+1] %= mod

print(dp[H-1][W-1])
import sys
sys.setrecursionlimit(1500)
n=int(input())
arr=list(map(int,input().split()))
vis={}
vis[1]=0
if n < 2:
  print(0)
  exit
vis[2]=abs(arr[0]-arr[1])
if n == 2:
  print(vis[2])
  exit
def c(i):
  if i in vis:
    #print(vis)
    return vis[i]
  x = abs(arr[i-1]-arr[i-2]) + c(i-1)
  y = abs(arr[i-1]-arr[i-3]) + c(i-2)
  vis[i]=min(x, y)
  #print(i, x, y, vis)
  return vis[i]
c(n)
print(vis[n])

### FIXED CODE ###

n=int(input())
arr=list(map(int,input().split()))
if n < 2:
  print(0)
vis = [0] * n
vis[0] = 0
vis[1] = abs(arr[0]-arr[1])
for i in range(2, n):
    step_1 = abs(arr[i]-arr[i-1]) + vis[i-1]
    step_2 = abs(arr[i]-arr[i-2]) + vis[i-2]
    vis[i] = min(step_1, step_2)
print(vis[-1])
from heapq import heappush, heappop

line = input()
v, e = list(map(int, line.split()))
edge = {}
for _ in range(0, e):
    line = input()
    s, t, w = list(map(int, line.split()))
    if s not in edge:
        edge[s]  = [[t, w]]
    else:
        edge[s] += [[t, w]]
    if t not in edge:
        edge[t]  = [[s, w]]
    else:
        edge[t] += [[s, w]]

def solve(v, edge):
    q = []
    vtx = set([i for i in range(0, v)])
    for t, w in edge[0]:
        heappush(q, (w, 0, t))
    vn = set([0])
    en = []
    cost = 0
    while len(vn) < v:
        w = s = t = 0
        qq = []
        while q:
            w, s, t = heappop(q)
            if s in vn and t not in vn:
                s, t = t, s
                break
            if s not in vn and t in vn:
                break
        vn.add(s)
        en += [(s, t)]
        cost += w
        for t, w in edge[s]:
            heappush(q, (w, s, t))
    return cost
        
print(solve(v, edge))


### FIXED CODE ###

from heapq import heappush, heappop

line = input()
v, e = list(map(int, line.split()))
edge = {}
edge[0] = [[0, 0]]
for _ in range(0, e):
    line = input()
    s, t, w = list(map(int, line.split()))
    if s not in edge:
        edge[s]  = [[t, w]]
    else:
        edge[s] += [[t, w]]
    if t not in edge:
        edge[t]  = [[s, w]]
    else:
        edge[t] += [[s, w]]

def solve(v, edge):
    q = []
    vtx = set([i for i in range(0, v)])
    for t, w in edge[0]:
        heappush(q, (w, 0, t))
    vn = set([0])
    en = []
    cost = 0
    while len(vn) < v:
        w = s = t = 0
        qq = []
        while q:
            w, s, t = heappop(q)
            if s in vn and t not in vn:
                s, t = t, s
                break
            if s not in vn and t in vn:
                break
        vn.add(s)
        en += [(s, t)]
        cost += w
        for t, w in edge[s]:
            heappush(q, (w, s, t))
    return cost
        
print(solve(v, edge))
n = input()
ans = 0
for i in range(n):
    l, r = map(int, (input().split()))
    ans += r - l + 1
print(ans)

### FIXED CODE ###

n = int(input())
ans = 0
for i in range(n):
    l, r = map(int, input().split())
    ans += r - l + 1
print(ans)
N,K=[int(s) for s in input().split(" ")]
ListH=[int(s) for s in input().split(" ")]

ListH.sort(reverse=True)
sum=0

if N > K:
    for i in range(K):
        ListH.pop(i)
        
    for i in range(N-K):
        sum+=ListH[i]
else:
    sum=0
    
print(sum)

### FIXED CODE ###

N, K = map(int, input().split())
ListH = list(map(int, input().split()))


if N<=K:
    print(0)
else:
    ListH.sort()
    sum=0
    for i in range(N-K):
        sum+=ListH[i]

    print(sum)
import sys
import collections


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    d = collections.deque(list("keyence"))
    s = str(input().rstrip('\n'))
    for i in range(len(s)):
        p = d.popleft()
        if p != s[i]:
            d.appendleft(p)
    print("YES" if len(d) == 0 else "NO")


if __name__ == '__main__':
    solve()


### FIXED CODE ###

import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    s = list(str(input().rstrip('\n')))
    for i in range(len(s)):
        for j in range(i + 1, len(s)):
            if "".join(s[:i + 1] + s[j:]) == "keyence":
                print("YES")
                exit()
    print("NO")


if __name__ == '__main__':
    solve()
def func(i, routes, marks):
    update_rooms = []
    if i not in routes:
        return marks
    for j in routes[i]:
        room_idx = j
        if room_idx in marks:
            continue
        marks[room_idx] = i
        update_rooms.append(room_idx)
    for j in update_rooms:
        marks = func(j, routes, marks)
    return marks

def get_input():
    N, M =  list(map(int, input().split()))
    routes = {}
    for i in range(M):
        a, b =  list(map(int, input().split()))
        a_idx = a - 1
        b_idx = b - 1
        if a_idx in routes:
            routes[a_idx].append(b_idx)
        else:
            routes[a_idx] = [b_idx]
        
        if b_idx in routes:
            routes[b_idx].append(a_idx)
        else:
            routes[b_idx] = [a_idx]

    return N, M, routes

def write_result(marks, N):
    flag = True
    output_str = ''
    for i in range(1, N):
        if i not in marks:
            flag = False
            break
        output_str += f'{marks[i]+1}\n'
    if flag:
        print('Yes')    
        print(output_str)
    else:
        print('No')

import numpy

N, M, routes = get_input()

marks = {0:0}

marks = func(0, routes, {0: 0})
write_result(marks, N)



### FIXED CODE ###


def get_input():
    N, M =  list(map(int, input().split()))
    routes = {}
    for i in range(M):
        a, b =  list(map(int, input().split()))
        a_idx = a - 1
        b_idx = b - 1
        if a_idx in routes:
            routes[a_idx].append(b_idx)
        else:
            routes[a_idx] = [b_idx]
        
        if b_idx in routes:
            routes[b_idx].append(a_idx)
        else:
            routes[b_idx] = [a_idx]

    return N, M, routes

def write_result(marks, N):
    flag = True
    output_str = ''
    for i in range(1, N):
        if i not in marks:
            flag = False
            break
        output_str += f'{marks[i]+1}\n'
    if flag:
        print('Yes')    
        print(output_str)
    else:
        print('No')

import numpy


marks = {0:0}

N, M, routes = get_input()
mark = {0:0}
start_nodes = [0]
while start_nodes:
    next_nodes = []
    for i in start_nodes:
        for n in routes[i]:
            if n in marks:
                continue
            marks[n] = i
            next_nodes.append(n)
    start_nodes = next_nodes   
write_result(marks, N)
S=input()
count=[]
s=0
for i in range(3):
    if S[i]=='R':
        if i==2 or S[i+1]=='S':
            s=s+1
            count.append(s)
            s=0
        else:
            s=s+1
print(max(count))

### FIXED CODE ###

S=input()
count=[0]
s=0
for i in range(3):
    if S[i]=='R':
        if i==2 or S[i+1]=='S':
            s=s+1
            count.append(s)
            s=0
        else:
            s=s+1
print(max(count))
n = int(input)
count = 0
for c in range(1, n):
    count += divisor_count(c)
print(count)


### FIXED CODE ###

n = int(input()) - 1
lst = [n // k for k in range(1, int(n**0.5+1))]
print(2 * sum(lst) - int(n**0.5)**2)
a, b = map(int, input(), split())
op = ["+", "-", "*", "/", "?"]

for i in range(20000):
      if op == "?":
         break
      else:
         print(a op b)

### FIXED CODE ###

while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == "+":
      print(a + b)
    elif op == "-":
      print(a - b)
    elif op == "*":
      print(a * b)
    elif op == "/":
      print(a // b)
    else:
      break
n, q = map(int, input().split())
link = dict()
counter = list([0]*n)
for i in range(n-1):
  a, b = map(int, input().split())
  if a in link:
    link[a].append(b)
  else:
    link[a] = [b]
def open(ps, x):
  if len(ps) > 0:
    for i in ps:
      counter[i-1] += x
      if i in link:
        open(link[i],x)
        
for i in range(q):
  p,pp = map(int, input().split())
  open([p], pp)

counter = map(str, counter)
ans = ' '.join(counter)
    
print(ans)

### FIXED CODE ###

n, q = map(int, input().split())
link = dict()
counter = list([0]*n)
for i in range(n-1):
    a,b = map(int, input().split())
    link[b-1] = a-1
        
for i in range(q):
  p,pp = map(int, input().split())
  counter[p-1] += pp

for i in range(n):
    if i in link:
        counter[i] += counter[link[i]]

counter = map(str, counter)
ans = " ".join(counter)
print(ans)
a=list(map(int,input().split()))
a,sort()
if a==[1,4,7,9] :
  print("YES")
else:
  print("NO")

### FIXED CODE ###

a=list(map(int,input().split()))
a.sort()
if a==[1,4,7,9] :
  print("YES")
else:
  print("NO")
N = int(input())

T = [[] for i in range(N)]
F = [None for i in range(N-1)]
for i,n in enumerate(range(N-1)):
    a,b = map(int,input().split())
    T[a-1].append(b-1)
    F[i] = b-1

# print(T)

R = [None for i in range(N)]
def dfs(cur, mx, color):
    R[cur] = color
    if color == -1:
        mx = max(len(T[cur]), mx)
    else:
        mx = max(len(T[cur])+1, mx)
    done = 0
    for i,t in enumerate(T[cur], start=1):
        if i==color:
            done=1
        mx = max(mx,dfs(t, mx, i+done))
        # dfs(t, mx, i)
    return mx
mx = dfs(0, 1, -1)
# print(R)
# print(F)
print(mx)
for i,f in enumerate(F):
    print(R[f])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)

N = int(input())

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

# print(E)
# print(T)



R = [None for i in range(N)]
def dfs(using, cur):
    R[cur] = using
    i=0
    for t in T[cur]:
        if i==using:
            i+=1
        dfs(i,t)
        i+=1


dfs(-1, 0)

print(max(R)+1)
# print(K)
for e in E:
    print(R[e[1]]+1)

# print(K)