Harryxun/stf_run huggingface dataset:
import math
N=int(input())

#約数出す
def divisor(x):
    div=[]
    for i in range(1,int(x**(1/2))+1):
        if x%i==0:
            div.append(i)
            if i!=x//i:
                div.append(x//i)
    return sorted(div)

#累乗数判定
def is_perfect_power(x):
    size=int(math.log2(x)+1)
    for b in range(2,size):
        a=int(math.pow(x,1/b))
        if a**b==x or (a+1**b==x): return a
    return 0
    

A=divisor(N)
z=[]
for i in range(len(A)):
    if len(divisor(A[i]))==2:
        z.append(A[i])
    else:
        x=is_perfect_power(A[i])
        if x!=0:
            if len(divisor(x))==2:
                z.append(A[i])
z=sorted(z)
cnt=0
for i in range(N):
    if N>=z[i]:
        if N%z[i]==0:
            N=N//z[i]
            cnt+=1
    else:
        break
print(cnt)

### FIXED CODE ###

N=int(input())

def divisor(x):
    div=[]
    for i in range(1,int(x**(1/2))+1):
        if x%i==0:
            div.append(i)
            if i!=x//i:
                div.append(x//i)
    return sorted(div)

def factorization(n):
    arr=[]
    temp=n
    for i in range(2,int(n**(1/2))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp//=i
            arr.append([i,cnt])
        
    if temp!=1:
        arr.append([temp,1])

    if arr==[]:
        arr.append([n,1])
    
    return arr

zt=[1]
ans=0
while N>1:
    for i in divisor(N):
        if i not in zt:  
            if len(factorization(i))==1:
                z=i
                zt.append(z)
                break
    if z==0:
        break
    N=N//z
    ans+=1
    z=0

print(ans)
import numpy as np
import sys
input = sys.stdin.readline
res = 0
p = 0
R, G, B, N = map(int, input().split())
for i in range (N // R + 1):
    for j in range(N // G + 1):
        P =N - i*R - j*G
        if P < 0:
            break
        else:
            if(P % B == 0):
                res += 1


print(res)

### FIXED CODE ###

N, K =  map(int,input().split())
print(N-K+1)
a=360/n
b=a-360//n
print(int(n*360/math.gcd(n,360)/n))

### FIXED CODE ###

import math
n=int(input())
a=360/n
b=a-360//n
print(int(n*360/math.gcd(n,360)/n))
20 100000
14309 -32939
-56855 100340
151364 25430
103789 -113141
147404 -136977
-37006 -30929
188810 -49557
13419 70401
-88280 165170
-196399 137941
-176527 -61904
46659 115261
-153551 114185
98784 -6820
94111 -86268
-30401 61477
-55056 7872
5901 -163796
138819 -185986
-69848 -96669

### FIXED CODE ###

import math

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

count = 0
for _ in range(n):
    x,y = map(int, input().split())
    dis = math.sqrt((x*x) + (y*y))
    if dis <= d:
        count += 1

print(count)
l = map(int,input().split())
print(sum(l)-max(l))


### FIXED CODE ###

l = list(map(int,input().split()))
print(sum(l)-max(l))
n=input()
if n.count(9)>=1:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

n=input()
if n.count('9')>=1:
    print('Yes')
else:
    print('No')
from collections import defaultdict


def resolve():
    n = int(input())
    v = list(map(int, input().split()))
    d_o = defaultdict(int)
    d_e = defaultdict(int)
    for i in range(n):
        if i % 2:
            d_o[v[i]] += 1
        else:
            d_e[v[i]] += 1
    de = sorted(d_e.items(), key=lambda x: x[1])
    do = sorted(d_o.items(), key=lambda x: x[1])
    if de == do:
        p = max(de[0][1], do[0][1])
        print(n - p)
    if de[0] != do[0]:
        print(n - de[0][1] - do[0][1])
    else:
        p = max(de[0] + do[1], de[1] + do[0])
        print(p)


if __name__ == "__main__":
    resolve()


### FIXED CODE ###

from collections import defaultdict


def resolve():
    n = int(input())
    v = list(map(int, input().split()))
    d_o = defaultdict(int)
    d_e = defaultdict(int)
    for i in range(n):
        if i % 2:
            d_o[v[i]] += 1
        else:
            d_e[v[i]] += 1
    d_e[0] = 0
    d_o[0] = 0
    de = sorted(d_e.items(), key=lambda x: -x[1])
    do = sorted(d_o.items(), key=lambda x: -x[1])
    if de[0][0] != do[0][0]:
        print(n - de[0][1] - do[0][1])
    else:
        p01 = de[0][1] + do[1][1]
        p10 = de[1][1] + do[0][1]
        print(n - max(p01, p10))


if __name__ == "__main__":
    resolve()
N = input()
List = list(input() for i in range(N))
print(len(set(List)))


### FIXED CODE ###

N = int(input())
List = list(input() for i in range(N))
print(len(set(List)))
from math import sqrt
X = int(input())
def is_prime_next(X):
    X_sqrt = int((sqrt(X)-5)/6) 
    if X==2 or X==3:
        return X
    if X%2 == 0:
        return None
    if X%3 == 0:
        return None
    for i in range(1, X_sqrt):
        if X % (6*i+1) == 0 or X % (6*i+5) == 0:
            return None
    return X
while(1):
    X_keep = is_prime_next(X)
    if X_keep != None:
        break
    X += 1
print(X)

### FIXED CODE ###

S, T = map(str, input().split())
T += S
print(T)
N = input()

half = N // 2

if N%2 == 0:
  left_N = N[:half]
  right_N = N[half:]
else:
  left_N = N[:half]
  right_N = N[half+1:]

for l,r in zip(left_N, right_N[::-1]):
  if l != r:
    print('No')
    exit()
    
print('Yes')

### FIXED CODE ###

N = input()

half = len(N) // 2

if len(N)%2 == 0:
  left_N = N[:half]
  right_N = N[half:]
else:
  left_N = N[:half]
  right_N = N[half+1:]

for l,r in zip(left_N, right_N[::-1]):
  if l != r:
    print('No')
    exit()
    
print('Yes')
import sys

n = int(input())

for i in range(n):
    if (n % i == 0) and (n//i < 10):
        print('Yes')
        sys.exit()
print('No')


### FIXED CODE ###

import sys

n = int(input())

for i in range(1,10):
    if (n % i == 0) and (n//i < 10):
        print('Yes')
        sys.exit()
print('No')
N, M = map(int, input().split())
H = list(map(int, input().split()))
a = list(range(1,N+1))
for i in range(M):
  ai, bi = map(int, input().split())
  if H[ai-1] <= H[bi-1] :
    a.remove(ai)
  if H[ai-1] >= H[bi-1]:
    a.remove(bi)
print(len(a))    
  

### FIXED CODE ###

N, M = map(int, input().split())
H = list(map(int, input().split()))
a = [True] * N
for i in range(M):
  ai, bi = map(int, input().split())
  if H[ai-1] <= H[bi-1] :
    a[ai-1] = False
  if H[ai-1] >= H[bi-1]:
    a[bi-1] = False
print(sum(a))
n = input()
a = list(map(int, input().split()))

for i in a:
	sum += a[i] 
	double = a[i] ** 2
print((sum**2-double)/2)

### FIXED CODE ###

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

if (a <= b * 2):
  print (0)
else:
  print (a - b * 2)
n = int(input())
a= list(map(int,input().split()))
if n == 1:
  print(1)
  exit()

a.sort()
if a[0] == 1:
  print(1)
  exit()

dp = [1 for _ in range(n)]

def div(k):
  global dp
  if dp[k] != 0:
    for i in range(k):
      if a[k]%a[i] == 0:
        dp[k] = 0
        if a[k] == a[i]:dp[i] = 0
        break
  if k < n-1:div(k+1)

div(1)
print(sum(dp))

### FIXED CODE ###

from collections import Counter
n = int(input())
a= list(map(int,input().split()))
if n == 1:
  print(1)
  exit()

a.sort()

c = Counter(a)
a = list(set(a))
dp = [0] * (10**6 +1)

for x in a:
  t = x * 2
  while t <= 10**6:
    dp[t] = 1
    t += x

ans = 0
for x in a:
  if (c[x] == 1) & (dp[x] == 0):
    ans += 1

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

w = [[] for _ in range(10001)]

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

money = 0
l = []
for i in range(m):
  l += w[i]
  if len(l) == 0:
    continue

  x = max(l)
  l.remove(x)
  money += x

print(money)

### FIXED CODE ###

from heapq import heappush, heappop

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

w = [[] for _ in range(10**5)]

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

money = 0
l = []
for i in range(m):
  for item in w[i]:
    heappush(l, item * (-1))
  if len(l) == 0:
    continue

  money += heappop(l) * (-1)

print(money)
import numpy as np
from numba import jit
  
data = np.array(input().split(" "), dtype="int")
life = np.array(input().split(" "), dtype="int")
@jit
def calculation(data, life):
    monsters = data[0]
    smash = data[1]
    a = np.sort(life)
    leftover = np.where(a[-smash] > a, a, 0)
    print(np.sum(leftover))

calculation(data, life)

### FIXED CODE ###

import numpy as np

def do():
    data = np.array(input().split(" "), dtype="int64")
    life = np.array(input().split(" "), dtype="int64")
    monsters = data[0]
    smash = data[1]
    if smash == 0:
        print(np.sum(life))
    elif smash >= monsters:
        print(0)
    else:
        a = np.sort(life)[-smash]
        leftover = np.where(life < a, life, 0)
        print(np.sum(leftover))

do()
N, K = list(map(int, input().split(" ")))
A = list(map(int, input().split(" ")))

import numpy as np



Nstock = np.zeros(N)

cpos = 1
Nstock[cpos - 1] = 1
stock = [cpos]
loop = []

idx = 0
for i in range(K):
    cpos = A[cpos-1]
    if Nstock[cpos - 1]  == 1:
        idx = stock.index(cpos)
        loop = stock[idx:]
        break
    Nstock[cpos - 1] = 1
    stock.append(cpos)
    
v = (K - idx) 
a = v %len(loop)

print(loop[a])


### FIXED CODE ###

N, K = list(map(int, input().split(" ")))
A = list(map(int, input().split(" ")))
 
import numpy as np
 
 
 
Nstock = np.zeros(N)
 
cpos = 1
Nstock[cpos - 1] = 1
stock = [cpos]
loop = []
 
idx = 0
for i in range(K):
    cpos = A[cpos-1]
    if Nstock[cpos - 1]  == 1:
        idx = stock.index(cpos)
        loop = stock[idx:]
        break
    Nstock[cpos - 1] = 1
    stock.append(cpos)
    
if loop != []:
    v = (K - idx) 
    a = v %len(loop)
    print(loop[a])
else:
    print(stock[K])
n = int(input())
s = list(input())

ri = [i for i, x in enumerate(s) if x=='R']
gi = [i for i, x in enumerate(s) if x=='G']
bi = [i for i, x in enumerate(s) if x=='B']

ans = len(ri) * len(gi) * len(bi)

for i in range(n):
    for d in range(n):
        j=i+d
        k=i+2*d
        if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
            ans -= 1

print(ans)

### FIXED CODE ###

n = int(input())
s = input()

ri = [i for i, x in enumerate(s) if x=='R']
gi = [i for i, x in enumerate(s) if x=='G']
bi = [i for i, x in enumerate(s) if x=='B']

ans = len(ri) * len(gi) * len(bi)

for i in range(n):
    for d in range(n):
        j=i+d
        k=i+2*d
        if k>=n:
            break
        if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
            ans -= 1

print(ans)
a=input（）
if a.isuppder():
  print('A')
else:
  print('a')

### FIXED CODE ###

import re
a=input()
if re.sub(r'[A-Z]',"",a)=="":
  print('A')
else:
  print('a')
print(int(input() - 1) * int(input() - 1))

### FIXED CODE ###

n, m = list(map(int, input().split()))
print((n - 1) * (m - 1))
def smaller(x, y):
	if x < y: return x
	return y

P, Q, R = map(int, input().split())

r1 = P + Q
r2 = Q + R
r3 = R + P

print(smaller(r1, smaller(r2, r3)))

### FIXED CODE ###

def smaller(x, y):
	if x < y: return x
	return y

P, Q, R = map(int, input().split())

r1 = P + Q
r2 = Q + R
r3 = R + P

print(smaller(r1, smaller(r2, r3)))
n = input()
a = list(map(int, input().split()))
for i in a:
    ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1)
print(round(ans))

### FIXED CODE ###

print(input().count("1"))
import collections as col
import numpy as np
import math as ma
import scipy.misc as spm #miscellaneous

MOD = 10**9 + 7
def inv(a): return pow(a, MOD-2, MOD)
def comb(n,r):
    ans = ma.factorial(n)%MOD * inv(ma.factorial(r)) * inv(ma.factorial(n-r))
    return ans%MOD

def prime(n):
    ans = []
    for i in range(2, int(n**0.5)+1):
        while not n%i: n //= i; ans.append(i)
    if n != 1: ans.append(n)
    return ans

n,m = map(int,input().split())
cnt = col.Counter(prime(m))

ans = 1
for key,val in cnt.items():
    #ans *= comb(val + n-1, n-1)
    ans *= comb(val + n-1, n-1, MOD)
    ans %= MOD
print(ans)



### FIXED CODE ###

import collections as col
import numpy as np
import math as ma
import scipy.misc as spm #miscellaneous

MOD = 10**9 + 7
def inv(a): return pow(a, MOD-2, MOD)
def comb(n,r):
    ans = ma.factorial(n)%MOD * inv(ma.factorial(r)) * inv(ma.factorial(n-r))
    return ans%MOD

def prime(n):
    ans = []
    for i in range(2, int(n**0.5)+1):
        while not n%i: n //= i; ans.append(i)
    if n != 1: ans.append(n)
    return ans

n,m = map(int,input().split())
cnt = col.Counter(prime(m))

ans = 1
for key,val in cnt.items():
    #ans *= comb(val + n-1, n-1)
    ans *= spm.comb(val + n-1, n-1, exact=1)
    ans %= MOD
print(ans)
import math
import sys
from collections import defaultdict
input = sys.stdin.readline

############ ---- Input Functions ---- ############
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
    
n = inp()
A = invr()

map = defaultdict(int)
for i, boss in enumerate(A, 2):
	map[boss] += 1 
	
for i in range(n):
	print map[i+1]


### FIXED CODE ###

import math
import sys
from collections import defaultdict
input = sys.stdin.readline

############ ---- Input Functions ---- ############
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
    
n = inp()
A = invr()

map = defaultdict(int)
for i, boss in enumerate(A, 2):
	map[boss] += 1 
	
for i in range(n):
	print map[i+1]
s = input()

if s = 'ABC':
	print('ARC')
else:
	print('ABC')

### FIXED CODE ###

s = input()

if s == 'ABC':
        print('ARC')
else:
        print('ABC')
from collections import deque
S=deque(input())
q=int(input())
for i in range(q):
  c=list(input().split())
  if c[0]=='1':
    S.reverse()
  elif c[0]=='2':
    if c[1]=='1':
      S.appendleft(c[2])
    elif c[1]=='2':
      S.append(c[2])
ans=''.join(S)
print(ans)

### FIXED CODE ###

a=input()
if len(set(a))==1:
  print("No")
else:
  print("Yes")
L=int("".join(map(str,list(map(int,input().split()))))
if L%4==0:
      print("YES")
else:
      print("NO")

### FIXED CODE ###

L=list(map(int,input().split()))
V=int("".join(map(str,L)))
if V%4==0:
  print("YES")
else:
  print("NO")
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]

s = set(s)
tot = 0
for i in s:
  res = s.count(i) - t.count(i)
  tot = max(res,tot)
  
print(tot)


### FIXED CODE ###

n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]

k = set(s)
tot = 0
for i in k:
  tot = max(s.count(i) - t.count(i),tot)
  
print(tot)
from tqdm import tqdm
N = int(input())

if N == 1:
    print(0)
    exit()

Z = 10 ** 9 + 7
a = 1
b = 1
c = 1
for n in range(N):
    a *= 10
    b *= 9
    c *= 8

    a = a % Z
    b = b % Z
    c = c % Z

print((a - 2 * b + c) % Z)

### FIXED CODE ###


N = int(input())

if N == 1:
    print(0)
    exit()

Z = 10 ** 9 + 7
a = 1
b = 1
c = 1
for n in range(N):
    a *= 10
    b *= 9
    c *= 8

    a = a % Z
    b = b % Z
    c = c % Z

print((a - 2 * b + c) % Z)
s=list(input())
ans=""
l=len(s)
n=0
for i in range(l):
  if s[i]=="0"or s[i]=="1":
    ans+=s[i]
    n+=1
  elif s[i]=="B" and n==0:
    pass
  else:
    ans-=ans[-1]
    n-=1
print(ans)

### FIXED CODE ###

s=list(input())
ans=""
l=len(s)
n=0
for i in range(l):
  if s[i]=="0"or s[i]=="1":
    ans+=s[i]
    n+=1
  elif s[i]=="B" and n==0:
    pass
  else:
    ans= ans[:n-1]
    n-=1
print(ans)
s = input()
st = input()
mx=10**9

rangeforloop= len(s)+1 - len(st)
 
for i in range(rangeforloop):
    mx=min(mx,matcher(s[i:len(st)+i], st))
    
     
print(mx)

### FIXED CODE ###

def matcher(s1,s2):
    match=0
    for i in range(len(s1)):
        if(s1[i]!=s2[i]):
            match+=1
            
    return match

#print(matcher("eforces","atcoder"))

s = input()
st = input()
mx=10**5

rangeforloop= len(s)+1 - len(st)
 
for i in range(rangeforloop):
    mx=min(mx,matcher(s[i:len(st)+i], st))
    
     
print(mx)
N = int(input())
S = []
for i in range(N):
    S.append(input())

def check(S, A, B):
    for i in range(N):
        for j in range(i+1, N):
            if j + B < N:
                b = j + B
            else:
                b = j + B - N
            if i + B < N:
                d = i + B
            else:
                d = i + B - N
            if S[a][b] != S[c][d]:
                return 0
    return 1

cnt = 0
for i in range(N):
    cnt += check(S, 0, i):
print(cnt * N)

### FIXED CODE ###

N = int(input())
S = []
for i in range(N):
    S.append(input())

def check(S, A, B):
    for i in range(N):
        for j in range(i+1, N):
            if S[i][j] != S[j][i]:
                return 0
    return 1

cnt = 0
for i in range(N):
    cnt += check(S[i:] + S[:i], 0, i)
print(cnt * N)
import heapq

n = int(input())
max_i = 0

while n>6**max_i:
  max_i+=1
  
cand_list = list(set([-6**i for i in range(max_i)] + [-9**i for i in range(max_i)]))

heapq.heapify(cand_list)
counter = 0

while n > 0:
  cand_n = -1 * heapq.heappop(cand_list)
  if n >= cand_n:
    n -= cand_n
    counter += 1
  
print(counter)

### FIXED CODE ###

n = int(input())

counter_min = n

for i in range(n+1):
  counter = 0
  n_six = i
  n_nine = n-i

  # 6
  j = 1
  while True:
    if  n_six >= 6**j:
      j += 1
    else:
      div_n = 6**(j-1)
      break
  
  while n_six > 0:
    counter += n_six // div_n
    n_six %= div_n
    div_n //= 6 
    
  # 9
  j = 1
  while True:
    if  n_nine >= 9**j:
      j += 1
    else:
      div_n = 9**(j-1)
      break
        
  while n_nine > 0:
    counter += n_nine // div_n
    n_nine %= div_n
    div_n //= 9
  
  counter_min = min(counter, counter_min)

print(counter_min)
from scipy.sparse import lil_matrix
from scipy.sparse.csgraph import dijkstra
n, m = map(int, input().split())
graph = lil_matrix((n+1,n+1), dtype=int)
for i in range(m):
    u, v = map(int, input().split())
    graph[u, v] = 1
start, goal = map(int, input().split())
graph = graph * graph * graph
k = dijkstra(graph, indices=start)
if k[goal] != float('inf'):
    print(int(k[goal]))
else:
    print(-1)

### FIXED CODE ###

from collections import deque
n, m = map(int, input().split())
inf = 10**9
def bfs(start):
    dist = [inf for i in range((n+1) * 3)]
    que = deque()
    que.append(start)
    finished = set()
    dist[start] = 0
    while que:
        node = que.popleft()
        if node not in finished:
            finished.add(node)
            for i in adjacent_list[node]:
                dist[i] = min(dist[i], dist[node] + 1)
                que.append(i)
    return dist

adjacent_list = [[] for i in range((n+1)*3)]
for _ in range(m):
    u, v = map(int, input().split())
    for i in range(3):
        adjacent_list[u*3 + i].append(v*3 +((i+1)%3))
start, goal = map(int, input().split())
graph = bfs(start*3)
if graph[goal*3] != inf:
    print(int(graph[goal*3]) // 3)
else:
    print(-1)
num_list =[]
ans = 0
for i in range(N):
  for j in range(N):
    for k in range(N):
      if L[i]!=L[j] and L[j]!=L[k] and L[i]!=L[k]:
        num_list.append(L[i])
        num_list.append(L[j])
        num_list.append(L[k])
        num_list.sort()
        if num_list[0]+num_list[1] > num_list[2]:
          ans += 1
          num_list.clear()
        else:
          num_list.clear()
print(int(ans/6))


### FIXED CODE ###

N = int(input())
L = list(map(int, input().split()))
num_list =[]
ans = 0
for i in range(N):
  for j in range(N):
    for k in range(N):
      if L[i]!=L[j] and L[j]!=L[k] and L[i]!=L[k]:
        num_list.append(L[i])
        num_list.append(L[j])
        num_list.append(L[k])
        num_list.sort()
        if num_list[0]+num_list[1] > num_list[2]:
          ans += 1
          num_list.clear()
        else:
          num_list.clear()
print(int(ans/6))
n, a, b, c ,d = map(int, input().split())
# s = input()[:max(c,d)]

def main():
    if "##" in s[b:d-2]:
        return "No"
    if "##" in s[c:c-2]:
        return "No"

    if c < d:
        return "Yes"
    
    else:

        if "..." in s[b-2:d-1]:
            return "Yes"
                
        return "No"

print(main())

### FIXED CODE ###

n, a, b, c ,d = map(int, input().split())
s = input()[:max(c,d)]

def main():
    if "##" in s[b:d-2]:
        return "No"
    if "##" in s[a:c-2]:
        return "No"

    if c < d:
        return "Yes"
    
    else:

        if "..." in s[b-2:d+1]:
            return "Yes"
                
        return "No"

print(main())
N,L=map(int,input().split())
S=[input() for i in range(N)]
print(''.join(S.sort()))


### FIXED CODE ###

N,L=map(int,input().split())
S=list(input() for i in range(N))
S_sort=sorted(S)
print(''.join(S_sort))
N=int(input())
a=[0]*(N-1)
b=[0]*(N-1)
c=[0]*(N-1)
d=[[] for _ in range(N)] # 隣接リスト
e=[ set() for _ in range(N)] #その頂点につながる辺に存在する色のリスト
maxi=0
for i in range(N-1):
    a[i],b[i] = map(int,input().split())
    d[a[i]-1].append(b[i]-1)
    d[b[i]-1].append(a[i]-1)
    
for j in d:
    maxi=max(maxi,len(j))  #最大の色数が確定する

possible=set( i+1 for i in range(maxi) )

for i in range(N-1):
  tmp=set()
  tmp |= possible
  tmp -= e[a[i]-1]
  tmp -= e[b[i]-1]
  c[i]=tmp.pop()
  e[a[i]-1].add(c[i])
  e[b[i]-1].add(c[i])
   
print(maxi)
for color in c:
    print(color)


### FIXED CODE ###

from collections import deque

N=int(input())
a=[0]*(N-1)
b=[0]*(N-1)
c=[set() for _ in range(N)] # 使用している色
d=[set() for _ in range(N)] # 隣接リスト
e=[ False for _ in range(N)] #訪問ずみかどうか
f=[0]*N  #答え
for i in range(N-1):
    a[i],b[i] = map(int,input().split())
    d[a[i]-1].add(b[i]-1)
    d[b[i]-1].add(a[i]-1)

maxi=max([len(d[i]) for i in range(N-1)])
print(maxi)
#print("c:",c)
#print("d",d)
#print("e",e)

#x=0としてBFSする

v=deque([0])
e[0]=True
color=1

while v:
  p = v.popleft()
  for q in d[p]:
    if e[q]==False:
      while color in c[p]:
        color +=1
        if color>maxi:
          color=1
      c[p].add(color)
      c[q].add(color)
      f[q]=color
      e[q]=True
      v.append(q)
      
for i in range(N-1):
  print( f[b[i]-1])
a = int(input())
b = int(input())
if (a% 2 ==0)or(b% 2 ==0):
    print("Even")
else:
    print("Odd")

### FIXED CODE ###

a,b = map(int,input().split())
if (a% 2 ==0)or(b% 2 ==0):
    print("Even")
else:
    print("Odd")
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for i in range(0, A+1):
    xi = X - 500 * i
    if xi < 0: break
    for j in range(0, B+1):
        xj = xi - 100 * j
        if xj < 0: break
        for k in range(0, C+1):
            xk = xj - 50 * k
            # print('{} {} {} {}'.format(i,j,k,xk))
            if xk == 0: ans += 1
            if xk < 0: break

print(ans)

### FIXED CODE ###

X = int(input())
A = int(input())
B = int(input())

print((X - A) % B)
o=input()
e=input()
if len(o)!=len(e):
  for i in range(len(o)):
    print(o[i],end="")
    print(e[i],end="")
  print(o[-1])  
else:
  for i in range(len(o)):
    print(o[i],end="")
    print(e[i],end="")

### FIXED CODE ###

o=input()
e=input()
if len(o)!=len(e):
  for i in range(len(o)-1):
    print(o[i],end="")
    print(e[i],end="")
  print(o[-1])  
else:
  for i in range(len(o)):
    print(o[i],end="")
    print(e[i],end="")
H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]

for i in range(H):
    for j in range(W):
        if s[i][j] == '.':
            count = 0
            for dx, dy in (
                (-1,1), (0,1), (1,1),
                (-1,0), (0,0), (1,0),
                (-1,-1),(0,-1),(1,-1)
            ):
                now_x, now_y = i+dx, j+dy
                if s[now_x][now_y] == '#':
                    if 0 <= now_x and 0 <= now_y and now_x <= H-1 and now_y <= W-1:
                        count += 1
            s[i][j] = str(count)

for i in range(H):
    print(''.join(s[i]))

### FIXED CODE ###

H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]

for i in range(H):
    for j in range(W):
        if s[i][j] == '.':
            count = 0
            for dx, dy in (
                (-1,1), (0,1), (1,1),
                (-1,0), (0,0), (1,0),
                (-1,-1),(0,-1),(1,-1)
            ):
                now_x, now_y = i+dx, j+dy
                if 0 <= now_x and 0 <= now_y and now_x <= H-1 and now_y <= W-1 and s[now_x][now_y] == "#":
                    count += 1
            s[i][j] = str(count)

for i in range(H):
    print(''.join(s[i]))