Harryxun/stf_run huggingface dataset:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
A, B, X = map(int, input().split())

ans = "YES"
if A+B < X:
    ans = "NO"
elif:
    A > X:
        ans = "NO"
print(ans)


### FIXED CODE ###

# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
A, B, X = map(int, input().split())

ans = "YES"
if A+B < X:
    ans = "NO"
elif A > X:
    ans = "NO"
print(ans)
N,K=map(int,input().split(" "))
H=[int(input()) for _ in range(N)]
H.sort()
tmax=10**9
for a in range(N-K+1):
    h1,h2=H[a],H[a+K]
    tmax=min(tmax,abs(h1-h2))
    if(tmax==0):
        break
print(tmax)

### FIXED CODE ###

N,K=map(int,input().split(" "))
H=[int(input()) for _ in range(N)]
H.sort()
tmax=10**9
for a in range(N-K+1):
    h1,h2=H[a],H[a+K-1]
    tmax=min(tmax,abs(h1-h2))
    if(tmax==0):
        break
print(tmax)
s = input()
if s == 'A':
	print('T')
else if s == 'T':
	print('A')
else if s == 'G':
	print('C')
else if s == 'C':
	print('G')

### FIXED CODE ###

s = input()
if s == 'A':
	print('T')
elif s == 'T':
    print('A')
elif s == 'G':
	print('C')
elif s == 'C':
	print('G')
import sys
read = sys.stdin.buffer.read
input=lambda :sys.stdin.readline().rstrip()
inputs= sys.stdin.buffer.readlines
INF=float("inf")
MOD=10**9+7
#input = sys.stdin.buffer.readline
sys.setrecursionlimit(2147483647)
#rstrip().decode('utf-8')
#import math
#import numpy as np
#import operator
#import bisect
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
#from scipy.sparse import csr_matrix
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#map(int,input().split())
#from scipy.special import comb

def calc(a,b,p):
	if b == 0:
		return 1
	elif b % 2 == 0:
		d = calc(a, b / 2, p)
		return (d * d) % p
	else:
		return (a * calc(a, b - 1, p)) % p





def main():
	X,Y=map(int,input().split())
	
	a=max(X,Y)
	b=min(X,Y)
	
	ans=0
	
	t=2*a-b
	
	
	if t%3==0 and t>0 and a<=b*2:
		c1=t//3
		c2=a-2*t//3
		
		n=c1+c2
		r=min(c1,c2)
		
		mod = 10 ** 9 + 7  # 出力の制限
		N = n
		g1 = [1, 1]  # 元テーブル
		g2 =1  # 逆元テーブル
		inv = [0, 1]  # 逆元テーブル計算用テーブル
		
		for i in range(2,r+1):
			inv.append(calc(i,mod-2,mod))
		
		for i in range(2,r):
			g2=g2*inv[i]%mod
			
			
		
		for i in range(2, 100):
			g1.append((g1[-1] * i) % mod)
			print(g1[n]*g2)
		
		
	print(ans)
		
	
	
	
	
if __name__ == '__main__':
	main()

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
input=lambda :sys.stdin.readline().rstrip()
inputs= sys.stdin.buffer.readlines
INF=float("inf")
MOD=10**9+7
#input = sys.stdin.buffer.readline
sys.setrecursionlimit(2147483647)
#rstrip().decode('utf-8')
#import math
#import numpy as np
#import operator
#import bisect
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
#from scipy.sparse import csr_matrix
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#map(int,input().split())
#from scipy.special import comb

def framod(n, mod, a=1):
	for i in range(1, n + 1):
		a = a * i % mod
	return a


def power(n, r, mod):
	if r == 0: return 1
	if r % 2 == 0:
		return power(n * n % mod, r // 2, mod) % mod
	if r % 2 == 1:
		return n * power(n, r - 1, mod) % mod


def comb(n, k, mod):
	a = framod(n, mod)
	b = framod(k, mod)
	c = framod(n - k, mod)
	return (a * power(b, mod - 2, mod) * power(c, mod - 2, mod)) % mod


def main():
	X,Y=map(int,input().split())
	
	a=max(X,Y)
	b=min(X,Y)
	
	ans=0
	
	t=2*a-b
	
	
	if t%3==0 and t>0 and a<=b*2:
		c1=t//3
		c2=a-2*t//3
		ans=comb(c1+c2,c1,MOD)
		
	print(ans)
		
	
	
	
	
if __name__ == '__main__':
	main()
def nC2(n):
    return int(n*(n-1)/2)

n = int(input())
a = [0]*n
a = list(map(int, input().split()))
map(lambda x: x-1, a)
ty=[0]*n

for i in range(0, n):
    ty[a[i]]+=1

s = 0

for i in range(0, n):
    if ty[i]>=2:
        s += nC2(ty[i])

for k in range(0, n):
    if ty[a[k]]==2:
        print(s-1)
    elif ty[a[k]]>2:
        print(s-nC2(ty[a[k]])+nC2(ty[a[k]]-1))
    else:
        print(s)

### FIXED CODE ###

import random


def nC2(n):
    return int(n*(n-1)/2)

n = int(input())

a = [0]*n
a = list(map(int, input().split()))
a = [i-1 for i in a]

ty=[0]*n

for i in range(0, n):
    ty[a[i]]+=1

s = 0

for i in range(0, n):
    if ty[i]>=2:
        s += nC2(ty[i])

for k in range(0, n):
    if ty[a[k]]==2:
        print(s-1)
    elif ty[a[k]]>2:
        print(s-nC2(ty[a[k]])+nC2(ty[a[k]]-1))
    else:
        print(s)
N, M = map(int, input().split(" "))
botlist = []
ans = 0
for n in range(M):
    bot = list(map(int, input().split(" ")))
    
    botlist.append(bot)
#botlist
plist = list(map(int, input().split(" ")))

pushlist = [[]for i in range(2**N)]

for p in range(N):
    M = (2**N)/(p+1)
    for q in range(M):
        for r in range(p+1):
            if q%2 == 0:
                pushlist[r*q] = 0
            else:
                pushlist[r*q] = 1

for A in pushlist:
    g = 0
    for B in botlist:
        cou = 0
        for c in range(B[0]):
            cou += A[B[c]]
        if cou % 2 == plist[g]:
            ans += 1
    g +=1

print(ans)


    





### FIXED CODE ###

N, M = map(int, input().split(" "))
botlist = []
ans = 0
for n in range(M):
    bot = list(map(int, input().split(" ")))
    
    botlist.append(bot)
#botlist
plist = list(map(int, input().split(" ")))

pushlist = [[]for i in range(2**N)]

for p in range(N):
    for q in range(2**N):
        if q % (2**(p+1)) <2**p:
            pushlist[q].append(0)
        else:
            pushlist[q].append(1) 

for A in pushlist:
    #print(A)
    g = 0
    faa = 0
    for B in botlist:
        g += 1
        cou = 0
        for c in range(B[0]):
            cou += A[B[c+1]-1]

        if cou % 2 == plist[g-1]:
            faa += 1
    if faa == M:
        ans += 1
    

print(ans)
H, N = map(int, input().split())
tmp_magics = [float('inf') for _ in range(2 * H)]

for _ in range(N):
    a, b = map(int, input().split())
    for i in range(1, H // a + 2):
        if b * i < tmp_magics[a * i]:
            tmp_magics[a * i] = b * i

magics = []
max_magic = -float('inf')
for a, b in enumerate(tmp_magics):
    if b != float('inf'):
        magics.append([a, b])
        max_magic = max(max_magic, a)

M = len(magics)

dp = [float('inf') for _ in range(H + 1)]
dp[0] = 0

for h in range(H + 1):
    for a, b in magics:
        dp[h] = min(dp[h], dp[max(h - a, 0)] + b)

print(dp[-1])


### FIXED CODE ###

import sys

H, N = map(int, input().split())
AB = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]

dp = [0 for _ in range(H + max(AB, key=lambda x: x[0])[0])]
for h in range(1, len(dp)):
    dp[h] = min(dp[h-a] + b for a, b in AB)

print(dp[H])
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))

def main():
  n = ni()

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

  def digitlen(n):
    return len(str(n))

  x = divi(n)
  x.sort()
  m = len(x) // 2
  if m == 1:
    m = 0
  print(max(digitlen(x[m]), digitlen(x[m+1])))

main()

### FIXED CODE ###

N = int(input())
x = round(N**0.5)
while N%x != 0:
  x -= 1
print(len(str(N//x)))
a = int(input())
lim = a // 2
soma_lista = []
for i in range(a - 1, lim, -1):
    b = str(a - abs(i)) + str(abs(i))
    soma = 0
    for digit in b:
        soma += int(digit)
    soma_lista.append(soma)
print(min(soma_lista))


### FIXED CODE ###

#!/usr/bin/python
# -*- coding: utf-8 -*-

n=int(raw_input())
maxv=n
for a in xrange(1,n):
  b=n-a
  if a>b: break
  sa=sum([int(x) for x in str(a)])
  sb=sum([int(x) for x in str(b)])
  maxv=min(maxv, sa+sb)
print(maxv)
n = int(input())
ans = sorted(list(input()))
count = [50 for i in range(len(ans))]
s = [list(input()) for i in range(1,n)]
for i in range(1,n):
  for j in range(len(ans)):
    count[j] = s[i].count(ans[j])
for i in range(len(ans)):
  ret += ans[j]*count[j]
print(ret)

### FIXED CODE ###

n = int(input())
s = [list(input()) for i in range(n)]
ans = sorted(list(set(s[0])))
numbers = [100 for i in range(len(ans))]
for i in range(n):
  for j in range(len(ans)):
    numbers[j] = min(numbers[j], s[i].count(ans[j]))
ret = ""
for i in range(len(ans)):
  ret += ans[i]*numbers[i]
print(ret)
x=int(input())
a=int(input())

if x<a:
  print(0)
else:
  print(10)

### FIXED CODE ###

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

if x<a:
  print(0)
else:
  print(10)
import sys
fin = sys.stdin.readline


def factorial(n, mod):
    if n == 0:
        return 1
    else:
        return n * factorial(n - 1, mod) % mod


MOD = 10**9 + 7
N = int(fin())
A_list = [int(elem) for elem in fin().split()]

fac_N = factorial(N, MOD)
inv_nums = [fac_N * pow(i, MOD - 2, MOD) % MOD for i in range(1, N + 1)]
cuml_inv_nums = [inv_nums[0]]
for inv_num in inv_nums[1:]:
    cuml_inv_nums.append((cuml_inv_nums[-1] + inv_num) % MOD)

ans = 0
for i, A in enumerate(A_list):
    ans += A * (cuml_inv_nums[i] + cuml_inv_nums[N - 1 - i] - cuml_inv_nums[0]) % MOD
    ans %= MOD

print(ans)


### FIXED CODE ###

import sys
fin = sys.stdin.readline
sys.setrecursionlimit(200000)

def factorial(n, mod):
    if n == 0:
        return 1
    else:
        return n * factorial(n - 1, mod) % mod


MOD = 10**9 + 7
N = int(fin())
A_list = [int(elem) for elem in fin().split()]

fac_N = factorial(N, MOD)
inv_nums = [fac_N * pow(i, MOD - 2, MOD) % MOD for i in range(1, N + 1)]
cuml_inv_nums = [inv_nums[0]]
for inv_num in inv_nums[1:]:
    cuml_inv_nums.append((cuml_inv_nums[-1] + inv_num) % MOD)

ans = 0
for i, A in enumerate(A_list):
    ans += A * (cuml_inv_nums[i] + cuml_inv_nums[N - 1 - i] - cuml_inv_nums[0]) % MOD
    ans %= MOD

print(ans)
n, k = map(int, input().split())
a_list = list(map(int, input().split()))
a_list.sort()

import math


def cmb(n, r):
    o = math.factorial(n)
    u = math.factorial(r) * math.factorial(n - r)
    return o / u


max_val = 0
min_val = 0
val = cmb(n - 1, k - 1)
for i in range(n - k + 1):
    if i != 0:
        val = int(val * (n - i - k + 1) / (n - i))
    max_val = int(max_val + (((a_list[-(i + 1)]) * val))) % (10 ** 9 + 7)
    min_val = int(min_val + ((a_list[i]) * val)) % (10 ** 9 + 7)

print(int((max_val - min_val) % (10 ** 9 + 7)))

### FIXED CODE ###

n, k = map(int, input().split())
a_list = list(map(int, input().split()))
a_list.sort()


mod = 10 ** 9 + 7
f_list = [1]
for i in range(1,n+1):
    f_list.append((f_list[-1] * i) % mod)
def comb(n,r):
    return f_list[n] * (pow(f_list[r], mod-2, mod) * pow(f_list[n-r], mod-2, mod) % mod) % mod


max_val = 0
min_val = 0
for i in range(n - k + 1):
    val = comb(n - i - 1, k - 1)
    max_val = (max_val + (((a_list[-(i + 1)]) * val))) % (10 ** 9 + 7)
    min_val = (min_val + ((a_list[i]) * val)) % (10 ** 9 + 7)

print(int((max_val - min_val) % (10 ** 9 + 7)))
A,B,C = map(int,input().split())

ans = 0

while (A%2 == 0) & (B%2 == 0) & (C%2 == 0):
    if (A==B) & (B==C) :
        ans = -1
        break

    a = (B+C)/2
    b = (A+C)/2
    c = (A+B)/2
    A = a
    B = b
    C = c
        ans += 1

print(ans)

### FIXED CODE ###

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

ans = 0

while (A%2 == 0) & (B%2 == 0) & (C%2 == 0):
    if (A==B) & (B==C) :
        ans = -1
        break

    a = (B+C)/2
    b = (A+C)/2
    c = (A+B)/2
    A = a
    B = b
    C = c
    ans += 1

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

for i in range(a):
     for j in range(b):
          print('#')
          print(/n)


### FIXED CODE ###

while True:
    a,b=map(int,input().split())
    if a==0 and b==0:break
    for i in range (a):
        print('#'*b)
    print()
import bisect
n = int(input())
a = int(input())

color = [a]
color_min = a

for i in range(1, n):
    a = int(input())
    if color_min >= a:
        bisect.insort_left(color, a)
        color_min = a
    else:
        j = bisect.bisect_left(color, a)
        color.pop(j-1)
        bisect.insort_left(color, a)
        color_min = color[0]

print(len(color))


### FIXED CODE ###

r = int(input())

print(3 * r ** 2)
A = input().split()

if A[0] + A[1] + A[2] > 22:
  print("bust")
else:
  print("win")

### FIXED CODE ###

A = list(map(int, input().split()))

if sum(A) <= 21:
  print('win')
else:
  print('bust')
import math
from functools import reduce

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


def gcd(numbers):  # "numbers" is list
    return reduce(math.gcd, numbers)


def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)


def lcm(numbers):  # "numbers" is list
    return reduce(lcm_base, numbers,
                  1)  # [third argument] return 1 if "numbers" is empty


print(lcm(T))

### FIXED CODE ###

import math
from functools import reduce

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

# def gcd(numbers):  # "numbers" is list
#     return reduce(math.gcd, numbers)

# def lcm_base(x, y):
#     return (x * y) // math.gcd(x, y)


#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


#a,bの最小公倍数
def lcm_base(a, b):
    return a * b // gcd(a, b)


def lcm(numbers):  # "numbers" is list
    return reduce(lcm_base, numbers,
                  1)  # [third argument] return 1 if "numbers" is empty


print(lcm(T))
N=int(input())

is_prime = [True] * (N+1)
is_prime[0] = False
is_prime[1] = False
for i in range(2, int(N**0.5) + 1):
    if not is_prime[i]:
        continue
    for j in range(i * 2, N+1, i):
        is_prime[j] = False
A=[i for i in range(N + 1) if is_prime[i]]

a=[]
for i in A:
    if N%i==0:
        a.append(i)
print(a)
ans=0
for i in a:
    e=0
    while N%i==0:
            N = N//i
            e+= 1
    x=0
    for j in range(1,100):
        x+=j
        if e>=x:
            ans+=1
        else:
            break

print(ans)


### FIXED CODE ###

P = [1 for _ in range(10**6)]
P[0]=0
P[1]=0
for i in range(2,10**3):
    for j in range(i*i,10**6,i):
        P[j] = 0
Q = []
for i in range(2,10**6):
    if P[i]==1:
        Q.append(i)
N = int(input())
C = {}
for q in Q:
    if N%q==0:
        C[q] = 0
        while N%q==0:
            N = N//q
            C[q] += 1
if N>1:
    C[N] = 1
cnt = 0
for q in C:
    k = C[q]
    n = 1
    while k>(n*(n+1))//2:
        n += 1
    if k==(n*(n+1))//2:
        cnt += n
    else:
        cnt += n-1
print(cnt)
N, M, X = map(int, input().split())
C = [(list(map(int, input().split()))) for _ in range(N)]
 
# bit全探索を行い、参考書に関する全ての組みについて、値段と理解度を求める
ans = 10**10
for i in range(2**N):
  U = [0]*(M+1)
  for j in range(N):
    if ((i >> j) & 1):
      for k in range(M+1):
        U[k] += C[j][k]
  
  # ある組みが条件を満たすなら、その値段をvalに追加
  if sum([u >= X for u in U[1:]]) == M:
    ans = min(ans, U[0])

if ans = 10**10: print(-1)
else: print(ans)

### FIXED CODE ###

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

# bit全探索を行い、参考書に関する全ての組みについて、値段と理解度を求める
val = []
for i in range(2**N):
  U = [0]*(M+1)
  for j in range(N):
    if ((i >> j) & 1):
      for k in range(M+1):
        U[k] += C[j][k]
  
  # ある組みが条件を満たすなら、その値段をvalに追加
  if sum([u >= X for u in U[1:]]) == M:
    val.append(U[0])

# 条件を満たす組みの中で、値段が最小のものを出力し、組みが無ければ-1を出力する
ans = 0
if len(val) == 0: ans = -1
else: ans = min(val)
print(ans)
s = input()
t = input()

t1 = sorted(t,reverse=True)
s1 = sorted(s)

hantei = 0

for i in range(len(s1)):
    if t1[i] > s1[i]:
        hantei = 1
        break
    elif t1[i] < s1[i]:
        break

if hantei == 1:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

s = input()
t = input()

t1 = sorted(t,reverse=True)
s1 = sorted(s)

hantei = 0
count = 0

if len(s1) < len(t1):
    for i in range(len(s1)):
        count += 1
        if t1[i] > s1[i]:
            hantei = 1
            break
        elif t1[i] < s1[i]:
            break
        elif count == len(s1):
            hantei = 1
            break

else :
     for i in range(len(t1)):
        if t1[i] > s1[i]:
            hantei = 1
            break
        elif t1[i] < s1[i]:
            break

if hantei == 1:
    print("Yes")
else:
    print("No")
from collections import Counter
S = [i for i in str(input())]
c = Counter(S)
m = c.most_common()

n = len(S) // 3
if len(S) % 3 == 0:
  if (m[0][1]==n) and (m[1][1]==n) and (m[2][1]==n):
    print('YES')
  else:
    print('NO')
elif len(S) % 3 == 1:
  if (m[0][1]==n+1) and (m[1][1]==n) and (m[2][1]==n):
    print('YES')
  else:
    print('NO')
else:
  if (m[0][1]==n+1) and (m[1][1]==n+1) and (m[2][1]==n):
    print('YES')
  else:
    print('NO')

### FIXED CODE ###

from collections import Counter
S = [i for i in str(input())]
c = Counter(S)
m = c.most_common()

n = len(S) // 3
if len(S) == 1:
  print('YES')
elif len(S) == 2:
  if len(m) == 2:
    print('YES')
  else:
    print('NO')
elif len(m) < 3:
  print('NO')
else:
  if len(S) % 3 == 0:
    if (m[0][1]==n) and (m[1][1]==n) and (m[2][1]==n):
      print('YES')
    else:
      print('NO')
  elif len(S) % 3 == 1:
    if (m[0][1]==n+1) and (m[1][1]==n) and (m[2][1]==n):
      print('YES')
    else:
      print('NO')
  else:
    if (m[0][1]==n+1) and (m[1][1]==n+1) and (m[2][1]==n):
      print('YES')
    else:
      print('NO')
a = input().split(" ")
b = input().split(" ")
c = 0
for i in b:
    c += int(i)
if a >= c:
    print(a - c)
else:
    print(-1)

### FIXED CODE ###

a = input().split(" ")
b = input().split(" ")
c = 0
for i in b:
    c += int(i)
if int(a[0]) >= c:
    print(int(a[0]) - c)
else:
    print(-1)
b = list(input())

for i in len(b):
  if b[i] == "A":
    b[i] = "T"
  elif b[i] == "T":
    b[i] = "A"
  elif b[i] == "C":
    b[i] = "G"
  else:
    b[i] = "C"
    
print(b)

### FIXED CODE ###

b = list(input())

for i in range(len(b)):
  if b[i] == "A":
    b[i] = "T"
  elif b[i] == "T":
    b[i] = "A"
  elif b[i] == "C":
    b[i] = "G"
  else:
    b[i] = "C"
    
print("".join(b))
N, M = map(int, input().split())
X=[]
for i in range(M):
    X.append(list(map(int, input().split())))
P=list(map(int, input().split()))


ans=0
key='{:0'+str(N)+"b}"
for k in range(2**N):
    
    switch=list(key.format(k))
    for i in range(M):
        if P[i]==1:
            odd=0
            for j in range(X[i][0]):
                odd+=int(switch[ X[i][j+1]-1] )
            if odd%2==0:
                break
            #print(X[i],switch,odd)
        else:
            even=0
            for j in range(X[i][0]):
                even+=int(switch[ X[i][j+1]-1] )
            if even%2==1:
                break
    if odd%2==1 and even%2==0:
        ans+=1
        
print(ans)



### FIXED CODE ###

N, M = map(int, input().split())
X=[]
for i in range(M):
    X.append(list(map(int, input().split())))
P=list(map(int, input().split()))
ans=0

key='{:0'+str(N)+"b}"
for k in range(2**N):
    
    switch=list(key.format(k))
    for i in range(M):
        odd=1
        even=0
        if P[i]==1:
            odd=0
            for j in range(X[i][0]):
                odd+=int(switch[ X[i][j+1]-1] )
            if odd%2==0:
                break
            
        else:
            even=0
            for j in range(X[i][0]):
                even+=int(switch[ X[i][j+1]-1] )
            if even%2==1:
                break
    
    if odd%2==1 and even%2==0:
        ans+=1
        #print(X[i],switch,odd,even)
            
print(ans)
S = input()
K = int(input())
num = 0

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

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

print(ans)

### FIXED CODE ###

S = input()
K = int(input())
num = 0

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

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

print(ans)
N, Q = list(map(int, input().split()))
brunch = [[] for _ in range(N)]
value = [0 for _ in range(N)]
for _ in range(N-1):
  a, b = list(map(int, input().split()))
  brunch[a-1].append(b-1)

def flow(fr, v, brunch, v_list):
  v_list[fr] += v
  for to in brunch[fr]:
    v_list = flow(to, v, brunch, v_list)
  return v_list

for _ in range(Q):
  frr, val = list(map(int, input().split()))
  value = flow(frr-1, val, brunch, value)
print(' '.join(map(str, value)))

### FIXED CODE ###

from collections import deque
N, Q = map(int, input().split())
brunch = [[] for _ in range(N)]
value = [0 for _ in range(N)]

for _ in range(N-1):
  a, b = map(int, input().split())
  brunch[a-1].append(b-1)
  brunch[b-1].append(a-1)
  
for _ in range(Q):
  f, val = map(int, input().split())
  value[f-1] += val

d = deque()
d.append((0, -1))
while len(d):
  root, from_root = d.popleft()
  for to in brunch[root]:
    if to == from_root:
      continue
    value[to] += value[root]
    d.append((to, root))
print(' '.join(map(str, value)))
s=input()
t=input()

t_l = len(t)
diff_min = 999999999

def diff_str(s1, s2):
    diff_c = 0
    for j in range(len(seq)):
        if s1[j] != s2[j]:
            diff_c += 1
    return diff_c

if len(s) == len(t):
    diff_min = diff_str(s, t)

for i in range(len(s)-t_l):
    seq=s[i:i+t_l]
    diff_c = diff_str(seq, t)
    if diff_c < diff_min:
        diff_min = diff_c


print(diff_min)





### FIXED CODE ###

s=input()
t=input()

t_l = len(t)
diff_min = 999999999

def diff_str(s1, s2):
    diff_c = 0
    for j in range(len(s1)):
        if s1[j] != s2[j]:
            diff_c += 1
    return diff_c

if len(s) == len(t):
    diff_min = diff_str(s, t)

for i in range(len(s)-t_l):
    seq=s[i:i+t_l]
    diff_c = diff_str(seq, t)
    if diff_c < diff_min:
        diff_min = diff_c


print(diff_min)
n = int(input())
arr = []
for i in range(n-1):
    arr.append([int(s) for s in input().split(" ")])


status = [-1 for i in range(n)]
status2 = [-1 for i in range(n)]
childNodeNums = [0 for i in range(n)]


def prepare(n, arr):
    data = [[] for i in range(n)]

    for ar in arr:
        data[ar[0] - 1].append(ar[1] - 1)
        data[ar[1] - 1].append(ar[0] - 1)

    return data


def dfs(currentNode, arr):
    status[currentNode] = 1
    for i in range(n):
        childNodes = arr[i]

        for j in childNodes:
            if status[j] == -1:
                childNodeNums[i] += 1
                dfs(j, arr)


def dfs2(currentNode, arr, x):
    status2[currentNode] = 1
    childNodes = arr[currentNode]
    kk = 0
    for index,val in enumerate(childNodes):
        if status2[val] == -1:
            kk = kk + 1
            if kk == x:
                kk = kk + 1
            print(kk)

    kk2 = 0
    for index,val in enumerate(childNodes):
        if status2[val] == -1:
            kk2 = kk2 + 1
            if kk2 == x:
                kk2 = kk2 + 1
            dfs2(val,arr,kk2)


data = prepare(n, arr)
dfs(0, data)
lastIndex = childNodeNums.index(max(childNodeNums))
dfs2(lastIndex,data,-1)


### FIXED CODE ###

from sys import setrecursionlimit


def genid(a, b):
    if b < a:
        a, b = b, a
    return a * 100000 + b


def paint(currentNode, usedColor, parentNode, edges, colors):
    color = 1
    for childNode in edges[currentNode]:
        if childNode == parentNode:
            continue
        if color == usedColor:
            color += 1
        colors[genid(currentNode, childNode)] = color
        paint(childNode, color, currentNode, edges, colors)
        color += 1


setrecursionlimit(100000)

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

edges = [[] for _ in range(N)]
for a, b in ab:
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)

colors = {}
paint(0, -1, -1, edges, colors)

print(max(len(e) for e in edges))
for a, b in ab:
    print(colors[genid(a - 1, b - 1)])