Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import itertools

maxnum=0

def parm_check(n,maxnum):
    #print(tmp)
    #print(list(itertools.combinations(a,n)))
    a_sort = sorted(a,reverse=True)
    comb = list(itertools.combinations(a_sort,n))
    for j in range(len(comb)):
        sumnum = sum(comb[j])
        if(sumnum % 10 != 0 and maxnum < sumnum):
            maxnum = sumnum
            break
    return maxnum

if(__name__=="__main__"):
    N = int(input())
    a =[int(input()) for i in range(N)]
    #print(sum(a))
    
    if(sum(a) % 10 != 0):
        print(sum(a))
    else:
        for i in range(N-1,1,-1):
            maxnum = parm_check(i,maxnum)
            if(maxnum != 0):
                break

        print(maxnum)


### FIXED CODE ###

maxnum=0

if(__name__=="__main__"):
    N = int(input())
    a =[int(input()) for i in range(N)]
    #print(sum(a))
    
    if(sum(a) % 10 != 0):
        print(sum(a))
    else:
        a_sort = sorted(a)
        for i in range(0,N):
            if(a_sort[i] % 10 != 0):
                del a_sort[i]
                maxnum = sum(a_sort)
                break
            

        print(maxnum)
### BUGGY CODE ###

import numpy as np
n = int(input())
a = [int(input()) for i in range(n)]
c = [a[-1]]
if len(np.unique(a)) == 1:
    print(len(a))
else:
    for i in a[::-1][1:]:
        if c[-1] <= i:
            c.append(i)
            c.sort()
        else:
            c[np.where(np.array(c)>i)[0][0]] = i
    print(len(c))

### FIXED CODE ###

def se(c, x, h, l):
    if h == l:
        return l
    t = (h+l)//2
    if c[t] <= x:
        a = se(c,x,h,t+1)
    else:
        a = se(c,x,t,l)
    return a
        
    
import numpy as np
n = int(input())
a = [int(input()) for i in range(n)]
c = [a[-1]]
diff = np.diff(a)
tmp = np.sum(diff<=0)
if tmp == len(diff):
    print(len(a))
elif tmp == 0:
    print(1)
else:
    for i in a[::-1][1:]:
        if c[-1] <= i:
            c.append(i)
        else:
            c[se(c,i,len(c),0)] = i
    print(len(c))
### BUGGY CODE ###

from sys import stdin

n = int(stdin.readline().rstrip())
l = [int(x) for x in range(1, n + 1)]
p = l[1:] + [l[0]]

total_m = sum([i % p[i - 1] for i in range(1, n + 1)])
print(total_m)


### FIXED CODE ###

from sys import stdin

n = int(stdin.readline().rstrip())
print((n - 1) * (n) // 2)
### BUGGY CODE ###

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

import bisect

def main():
  MAX = 10**9
  n, m = map(int, input().strip().split())
  As = sorted(list(map(int, input().strip().split())))
  for _ in range(m):
    x = As.pop(len(As)-1)
    x >>= 1
    As.insert(bisect.bisect_left(As, x), x)
  print(sum(As))
    

if __name__=='__main__':
  main()



### FIXED CODE ###

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

import heapq

def main():
  MAX = 10**9
  n, m = map(int, input().strip().split())
  As = sorted(list(map(lambda x:-int(x), input().strip().split())))
  hq = heapq.heapify(As)
  for _ in range(m):
    x = heapq.heappop(As)
    x = -(-x//2)
    x = heapq.heappush(As, x)
  print(-sum(As))
    
if __name__=='__main__':
  main()
### BUGGY CODE ###

n, m = map(int, input().split())
e=[[] for _ in range(n+1)]
c=[0]*(n+1)
s1=set()
s2=set()
for _ in range(m):
    a, b = map(int, input().split())
    s1.add(a)
    s2.add(b)
    e[a].append(b)

s1=s1-s2

for v in s1:
    i=0
    q=e[v]
    while q:
        i=i+1
        t=[]
        for w in q:
            t.extend(e[w])
            if c[w]<i: c[w]=i
        q=t

print(max(c))

### FIXED CODE ###

n, m = map(int, input().split())
dp=[0]*(n+1)
e=[ set() for _ in range(n+1)]
for _ in range(m):
    a, b = map(int, input().split())
    e[a].add(b)
    dp[b]+=1

q=[0]*(n+1)
j=0
for z in range(len(dp)):
    if dp[z]==0:
        q[j]=z
        j=j+1
color=0
i=1
while i<j:
    end=j
    for qel in range(i, end):
        for w in e[q[qel]]:
            dp[w]-=1
            if dp[w]==0: 
                q[j]=w
                j=j+1
    i=end
    color=color+1

print(color-1)
### BUGGY CODE ###

n,q=map(int,input().split())
s=list(input())
#print(s)
i=0
a=[]
x=0
while i!=len(s):
 if n<10000:

    if s[i]=="C" and a1==1:
        x=x+1
        a1=0
    elif s[i]=="A":
        a1=1
    else:
        a1=0
    i=i+1
    a.append(x)

#print(a)
i=0
while i!=q:
  try:
    l,r=map(int,input().split())
    i=i+1
    s=a[r-1]-a[l-1]
    print(s)
  except:
      break


### FIXED CODE ###

n,q=map(int,input().split())
s=list(input())
#print(s)
i=1
a=[0]
x=0
while i!=n:
    if s[i-1]=="A":
        if s[i]=="C":
            x=x+1
    i=i+1
    a.append(x)

#print(a)
i=0
while i!=q:
  try:
    l,r=map(int,input().split())
    i=i+1
    s=a[r-1]-a[l-1]
    print(s)
  except:
      break
### BUGGY CODE ###

N=int(input())
S=list(range(1, N+1))#頂点の数
H = [list(map(int,input().split())) for i in range(N-1)]#辺のリスト

F = 0
for i in range(1,N+1):
    for j in range(i,N+1):	
        L=i
        R=j
        Hselect = [H[x] for x in range(N-1) if L <= H[x][0] <= R and L <= H[x][1] <= R]#L以上R以下の頂点で構成される辺のリスト
        tyouten = R-L+1#L以上R以下の数の個数＝頂点数
        renketu = tyouten - len(Hselect)#頂点数からHselectの要素数を引いた数＝連結成分数
        F += renketu#fに連結成分数を足す
#以上の処理をL＝1〜N、R＝L〜Nまで繰り返す

print(F)

### FIXED CODE ###

N=int(input())
S=list(range(1, N+1))#頂点の数
H = [sorted(list(map(int,input().split()))) for i in range(N-1)]#辺のリスト。頂点は右にいくほど大きい
F = 0
tyouten = int(N*(N+1)*(N+2)/6)
for i in range(len(H)):
    F += H[i][0]*(N-H[i][1]+1)#uVの組み合わせによって得られる辺の数をFに追加
print(tyouten-F)#頂点数からHselectの要素数を引いた数＝連結成分数
### BUGGY CODE ###

import sys
input=sys.stdin.readline
from collections import defaultdict,deque
def conv(n,a,b):
    return a*(2*n-a-1)//2+b-a-1

n=int(input())
v=n*(n-1)//2
A=[list(map(lambda x: int(x)-1,input().split())) for _ in range(n)]
Edges=[]
for i in range(n):
    l=len(A[i])
    for j in range(l-1):
        a=A[i][j]
        b=A[i][j+1]
        fr_i,fr_j=min(i,a),max(i,a)
        to_i,to_j=min(i,b),max(i,b)
        Edges.append((conv(n,fr_i,fr_j),conv(n,to_i,to_j)))
Outs=defaultdict(list)
In_cnt=defaultdict(int)
for v1,v2 in Edges:
    Outs[v1].append(v2)
    In_cnt[v2]+=1
q=deque((v0,1) for v0 in range(v) if In_cnt[v0]==0)
TopologicalSort=[]
while q:
    v1,d=q.popleft()
    TopologicalSort.append((v1,d))
    for v2 in Outs[v1]:
        In_cnt[v2]-=1
        if In_cnt[v2]==0:
            q.append((v2,d+1))
print(TopologicalSort[-1][1] if len(TopologicalSort)==n*(n-1)//2 else -1)

### FIXED CODE ###

import sys
input=sys.stdin.readline
from collections import defaultdict,deque
def conv(n,a,b):
    return a*(2*n-a-1)//2+b-a-1

n=int(input())
v=n*(n-1)//2
A=[list(map(lambda x: int(x)-1,input().split())) for _ in range(n)]
Edges=[]
for i in range(n):
    l=len(A[i])
    for j in range(l-1):
        a=A[i][j]
        b=A[i][j+1]
        fr_i,fr_j=min(i,a),max(i,a)
        to_i,to_j=min(i,b),max(i,b)
        Edges.append((conv(n,fr_i,fr_j),conv(n,to_i,to_j)))
Outs=defaultdict(list)
In_cnt=defaultdict(int)
for v1,v2 in Edges:
    Outs[v1].append(v2)
    In_cnt[v2]+=1
q=deque((v0,1) for v0 in range(v) if In_cnt[v0]==0)
TopologicalSort=[]
while q:
    v1,d=q.popleft()
    TopologicalSort.append((v1,d))
    for v2 in Outs[v1]:
        In_cnt[v2]-=1
        if In_cnt[v2]==0:
            q.append((v2,d+1))
print(TopologicalSort[-1][1] if len(TopologicalSort)==n*(n-1)//2 else -1)
### BUGGY CODE ###

n = (int(input()))
while n > 0:
  if n%10==7:
    print('Yes')
    break
  elif n < 10:
    print('No')
  else:
    n /= 10

### FIXED CODE ###

import math
n = int(input())
for i in range(3):
  if n%10 == 7:
    print('Yes')
    break
  elif n/10 < 1:
    print('No')
  else:
    n = math.floor(n/10)
### BUGGY CODE ###

import numpy as np
n = int(input())

dp = np.zeros(n+1,np.int64)
#dp[1]=1
for i in range(1,n+1):
    for j in range(i,n+1,i):
        dp[j]+=1
dp*=np.arange(n+1)
print(dp.sum())


### FIXED CODE ###

n = int(input())
ans = 0
for i in range(1,n+1):
    ans+=n//i*(n//i+1)//2*i
print(ans)
### BUGGY CODE ###

def main():
    N = int(input())
    a = list(map(int, input().split()))
    inf = 10 ** 13
    dp = [[0]*N for i in range(N)]
    s = [0] * (N+1)
    for i, x in enumerate(a):
        s[i+1] = s[i] + x
        dp[i][i] = 0
    for i in range(N-1, -1, -1):
        DP = dp[i]
        si = s[i]
        for j in range(i+1, N):
            tmp = s[j+1] - si
            D = inf
            for k in range(i, j):
                if D > DP[k]+dp[k+1][j] + tmp:
                    D = DP[k]+dp[k+1][j] + tmp
            DP[j] = D
    print(dp[0][N-1])
main()


### FIXED CODE ###

def main():
    N = int(input())
    a = list(map(int, input().split()))

    dp = [[10**13]*N for i in range(N)]
    s = [0] * (N+1)
    for i in range(N):
        s[i+1] = s[i] + a[i]
        dp[i][i] = 0
    for i in range(N-1, -1, -1):
        for j in range(i+1, N):
            tmp = s[j+1] - s[i]
            for k in range(i, j):
                dp[i][j] = min(dp[i][j], dp[i][k]+dp[k+1][j] + tmp)

    print(dp[0][N-1])


main()
### BUGGY CODE ###

from copy import deepcopy
from functools import reduce


class Divisor:
    def __init__(self, n):
        """ make divisors list and prime factorization list of n
            complexity: O(n^(1/2))
            used in ProjectEuler No.12, yukicoder No.36
        """
        assert(n >= 1)
        number = n
        if number == 1:
            self.primeFactorization = {}
        else:
            self.primeFactorization = {}
            for i in range(2, int(n**0.5)+1):
                cnt = 0
                while number % i == 0:
                    cnt += 1
                    number //= i
                if cnt > 0:
                    self.primeFactorization[i] = cnt
            if number > 1:
                self.primeFactorization[number] = 1

    def primeFactors(self):
        return deepcopy(self.primeFactorization)

    def numDivisors(self):
        """ the number of divisors """
        if self.primeFactorization.get(1, 0) == 1:
            return 1
        numDiv = 1
        for _, cnt in self.primeFactorization.items():
            numDiv *= cnt+1
        return numDiv

    def sumDivisors(self):
        return reduce(lambda x, y: x * y, [sum(p**i for i in range(n+1)) for p, n in self.primeFactorization.items()])


mod = 10 ** 9 + 7

N = int(input())
A = [int(x) for x in input().split()]
divs = [Divisor(a) for a in A]
lcm = {}
for div in divs:
    ps = set(div.primeFactorization.keys()) | set(lcm.keys())
    for p in ps:
        lcm[p] = max(div.primeFactorization.get(p, 0), lcm.get(p, 0))
ans = 0
for div in divs:
    ret = 1
    for key, val in lcm.items():
        ret = ret * pow(key, val - div.primeFactorization.get(key, 0), mod) % mod
    ans = (ans + ret) % mod
print(ans)


### FIXED CODE ###

import sys
import math
if sys.version_info.minor >= 5:
    from math import gcd
else:
    from fractions import gcd


def inv(x, mod):
    return pow(x, mod-2, mod)


def lcm(arr, mod = 10 ** 9 + 7):
    ret = 1
    for a in arr:
        ret = ret * a // gcd(ret, a)
    return ret

mod = 10 ** 9 + 7

N = int(input())
A = [int(x) for x in input().split()]
a = lcm(A)
print(sum(a * inv(x, mod) for x in A) % mod)
### BUGGY CODE ###

import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

N = _I()
T = [_I() for _ in range(N)]

times = 1
while True:
    max_t = max(T) * times
    for t in T:
        if max_t % t != 0:
            times += 1
            break
    else:
        print(max_t)
        break


### FIXED CODE ###

import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

N = _I()
T = set([_I() for _ in range(N)])

def lcm(a,b):
    g = fractions.gcd(a,b)
    return a * b // g

l = 1
for t in T:
    l = lcm(l, t)

print(l)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
a.append(0)
a.insert(0,0)
e=[]
for i in range(1,n+2):
    e.append(abs(a[i]-a[i-1]))
for i in range(1,n+1):
    print(sum(e)-sum(e[i-1:i+1])+abs(a[i+1]-a[i-1]))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
a.append(0)
a.insert(0,0)
e=0
for i in range(1,n+2):
    e+=abs(a[i]-a[i-1])
for i in range(1,n+1):
    print(e-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]))
### BUGGY CODE ###

s = input()
Q = int(input())
state = 0
for q in range(Q):
    query = input()
    if query[0] == '1':
        if state == 0:
            state = 1
        else:
            state = 0
    else:
        if query[2] == '1':
            if state == 0:
                s = query[-1] + s
            else:
                s += query[-1]
        else:
            if state == 0:
                s += query[-1]
            else:
                s = query[-1] + s

if state == 1:
    print(s[::-1])
else:
    print(s)


### FIXED CODE ###

from queue import deque

s = deque([i for i in input()])
Q = int(input())
state = 0
for _ in range(Q):
    q = input()
    if q[0] == '1':
        if state == 0:
            state = 1
        else:
            state = 0
    else:
        if int(q[2]) == 1:
            if state == 0:
                s.appendleft(q[-1])
            else:
                s.append(q[-1])
        elif int(q[2]) == 2:
            if state == 0:
                s.append(q[-1])
            else:
                s.appendleft(q[-1])

if state == 1:
    s.reverse()
print(''.join(s))
### BUGGY CODE ###

s=input().split()

N=int(s[0])
K=int(s[1])

if N > K/2 and N < K:
    print(abs(N-K))

if N <= K/2:
    print(N)

if N==K:
    print(0)

if N > K:
    while N > K:
        N=N-K
        if N <= K:
            break

    if N > K/2 and N < K:
        print(abs(N-K))

    if N <= K/2:
        print(N)

    if N==K:
        print(0)
    




### FIXED CODE ###

s=input().split()

N=int(s[0])
K=int(s[1])

if N > K/2 and N < K:
    print(abs(N-K))

if N <= K/2:
    print(N)

if N==K:
    print(0)



if N > K:

    


    if N >2*K:
        L=N//K
        N=N-L*K
    else:
        N=N-K
    

    if N > K/2 and N < K:
        print(abs(N-K))

    if N <= K/2:
        print(N)

    if N==K:
        print(0)
### BUGGY CODE ###

n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
mod = 1000000007
dp = [0] * (n + 1)
dp[0] = 1
dp[1] = dp[0] if not 1 in a else 0
for i in range(2, n + 1):
    if not i in a:
        dp[i] = (dp[i - 1] + dp[i - 2]) % mod
    else:
        dp[i]=  0
print(dp[n])


### FIXED CODE ###

n, m = map(int, input().split())
mod = 1000000007
a = [True] * (n + 1)
for i in range(m):
    a[int(input())] = False
dp = [0] * (n + 1)
dp[0] = 1

dp[1] = dp[0] if a[1] else 0

for i in range(2, n + 1):
    if a[i]:
        dp[i] = (dp[i - 1] + dp[i - 2]) % mod

print(dp[n])
### BUGGY CODE ###

N,M=map(int,input().split())
li=[]
H=list(map(int,input().split()))

for i in range(M):
    A,B=map(int,input().split())
    C=H[A-1]
    D=H[B-1]
    if C>D:
        if B in li:
            pass
        else:
            li.append(B)
    elif D>C:
        if A in li:
            pass
        else:
            li.append(A)
    else:
        if A in li and B in li:
            pass
        elif A in li:
            li.append(B)
        elif B in li:
            li.append(A)
        else:
            li.append(A)
            li.append(B)

print(N-len(li))


### FIXED CODE ###

N,M=map(int,input().split())
h=list(map(int,input().split()))
li=[1]*N
for i in range(M):
    a,b=list(map(int,input().split()))
    if h[a-1]>h[b-1]:
        li[b-1]*=0
    elif h[a-1]==h[b-1]:
        li[a-1]*=0
        li[b-1]*=0
    else:
        li[a-1]*=0

ans=li.count(1)
print(ans)
### BUGGY CODE ###

def gcd(a,b):
	if a==0:
		return(b)
	return(gcd(b%a,a))
a,b=map(int,input().split())
g=gcd(a,b)
divide=2

ans=1
while(g!=1):
	if g%divide==0:
		ans+=1
		while(g%divide==0):
			g//=divide
	divide+=1
print(ans)

### FIXED CODE ###

from math import sqrt
def gcd(a,b):
	if a==0:
		return(b)
	return(gcd(b%a,a))
a,b=map(int,input().split())
g=gcd(a,b)
ans=1
if g%2==0:
	ans+=1
	while(g%2==0):
		g//=2
for divide in range(3,int(sqrt(g))+1,2):
	if g%divide==0:
		ans+=1
		while(g%divide==0):
			g//=divide
if g>2:
	ans+=1
print(ans)
### BUGGY CODE ###

n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
for i in range(m):
        a[-1] //= 2
        a.sort()
print(sum(a))

### FIXED CODE ###

import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = list(map(lambda x: x*(-1), a))
heapq.heapify(a)
for i in range(m):
        maxVal = heapq.heappop(a)*(-1)
        heapq.heappush(a, (maxVal//2)*(-1))

print((-1)*(sum(a)))
### BUGGY CODE ###

n=int(input().split()[0])
s=input().split()
l=[0 for i in range(n)]
m=[0 for i in range(n)]
M=[0 for i in range(n)]
for i in range(n):
  l[i]=int(s[i])
m[0]=l[0]
M[0]=l[-1]
for i in range(1,n):
  m[i]=min(m[i-1],l[i])
  M[i]=max(M[i-1],l[-i-1])
M.reverse()
d=[M[i]-m[i] for i in range(n)]
ma=max(d)
l=[]
for i in range(n):
  if d[i]==ma:
    if m[i] not in l:
      l.append(m[i])
print(len(l))

### FIXED CODE ###

n=int(input().split()[0])
s=input().split()
l=[0 for i in range(n)]
m=[0 for i in range(n)]
M=[0 for i in range(n)]
for i in range(n):
  l[i]=int(s[i])
m[0]=l[0]
M[0]=l[-1]
for i in range(1,n):
  m[i]=min(m[i-1],l[i])
  M[i]=max(M[i-1],l[-i-1])
M.reverse()
d=[M[i]-m[i] for i in range(n)]
ma=max(d)
memo=-1
cnt=0
for i in range(n):
   if d[i]==ma and m[i]!=memo:
      cnt+=1
      memo=m[i]
print(cnt)
### BUGGY CODE ###

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

answer_list = []
for i in range(N):
    counter = 0
    i_num = N - i

    for j in range(i):
        j_num = i_num + j + 1
        if j_num // i_num == 0 and j_num in answer_list:
            counter += 1
    if counter // 2 == A[i_num - 1]:
        continue
    else:
        answer_list.append(i_num)
print(len(answer_list))
if answer_list:
    print(" ".join(map(str, answer_list)))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
flag = [-1] * (N+1)
answer_list = []
for i in range(N):
    counter = 0
    i_num = N - i
    for j in range(i_num, N+1, i_num):
        if j == i_num:
            continue
        else:
            if flag[j] == 1:
                counter += 1
    if counter % 2 == A[i_num - 1]:
        flag[i_num] = 0
    else:
        flag[i_num] = 1
        answer_list.append(i_num)
print(len(answer_list))
if answer_list:
    print(" ".join(map(str, answer_list)))
### BUGGY CODE ###

N,K=map(int,input().split())
List = list(map(int, input().split()))
data_x = [0]*N
res = [0]*N

def imosu(x,k):
  data = [0]*k
  for i in range(k):
    first = i-x[i]
    last = i+x[i]
    if first < 0:
      first = 0
    data[first] += 1
    if last+1 < k:
      data[last+1] +=-1
  return data

def ruiseki_f(y, k):
  ruiseki = [0]*k
  ruiseki[0] = y[0]
  for i in range(k-1):
    ruiseki[i+1] = ruiseki[i] + y[i+1]
  return ruiseki

for i in range(K):
  data_x = imosu(List,N)
  List = ruiseki_f(data_x,N)
  for j in range(N):
    if List[j] == N:
      break
res = List
print(*res)

### FIXED CODE ###

N,K=map(int,input().split())
List = list(map(int, input().split()))
 
def imosu(x,k):
  data = [0]*k
  for i in range(k):
    first = i-x[i]
    last = i+x[i]
    if first < 0:
      first = 0
    data[first] += 1
    if last+1 < k:
      data[last+1] +=-1
  ruiseki = [0]*k
  ruiseki[0] = data[0]
  for i in range(k-1):
    ruiseki[i+1] = ruiseki[i] + data[i+1]
  return ruiseki
 
for i in range(K):
  List = imosu(List,N)
  if List.count(N) == N:
    break
print(*List)
### BUGGY CODE ###

# -*- Coding: utf-8 -*-

n = int(input())
A = [list(map(int,input().split())) for i in range(n-1)]
C = list(map(int,input().split()))

C2 = []
for i in range(n):
    C2.append([C[i],i])

C2.sort()

ans = sum(C)-C2[-1][0]

T = [[] for i in range(n+1)]
for i in range(len(A)):
    T[A[i][0]].append(A[i][1])
    T[A[i][1]].append(A[i][0])

E = []
co = 0
while co < n-1:
    #print(co)
    t = 0
    while t < n+1 :
        if len(T[t]) == 1:
            E.append(t)
            if co == n-2 :
                E.append(T[t][0])
            T[T[t][0]].remove(t)
            T[t] = []
            co += 1
        t += 1



#print(E)

D = [0 for i in range(n)]
for i in range(n):
    D[E[i]-1] = C2[i][0]

print(ans)
s = ""
for i in range(n):
    s += str(D[i])
    s += " "

print(s)


### FIXED CODE ###

# -*- Coding: utf-8 -*-

n = int(input())
A = []
A = [list(map(int,input().split())) for i in range(n-1)]
C = list(map(int,input().split()))

C2 = []
for i in range(n):
    C2.append([C[i],i])

C2.sort()

ans = sum(C)-C2[-1][0]

T = [[] for i in range(n)]
for i in range(len(A)):
    T[A[i][0]-1].append(A[i][1]-1)
    T[A[i][1]-1].append(A[i][0]-1)
#print(T)


E = [[0,i] for i in range(n)]
E[0][0]=1
# co = 0
# while co < n-1:
#     #print(co)
#     t = 0
#     while t < n+1 :
#         if len(T[t]) == 1:
#             E.append(t)
#             if co == n-2 :
#                 E.append(T[t][0])
#             T[T[t][0]].remove(t)
#             T[t] = []
#             co += 1
#         t += 1

holist=[0]
hot = 0

def ho(u):
    p = E[u][0]
    for j in range(len(T[u])):
        if E[T[u][j]][0] == 0:
            E[T[u][j]][0] = p+1
            holist.append(T[u][j])

while hot < len(holist):
    ho(holist[hot])
    hot += 1
#print(E)
E.sort(reverse=1)


#print(E)

D = [0 for i in range(n)]
for i in range(n):
    D[E[i][1]] = C2[i][0]

print(ans)
s = ""
for i in range(n):
    s += str(D[i])
    s += " "

print(s)
### BUGGY CODE ###

n, m = map(int, input().split())
ans = 1
for i in range(n, m):
    if m % i == 0:
        ans = m//i
        break
print(ans)

### FIXED CODE ###

import math
n, m = map(int, input().split())
ans = 1
k = m
soy = []
for i in range(2, int(math.sqrt(m))+1):
    if k % i == 0:
        are = 0
        while True:
            if k % i == 0:
                k = k // i
                are += 1
            else:
                break
        soy.append([i, are])
if k != 1:
    soy.append([k, 1])
for i in range(10-len(soy)):
    soy.append([1, 0])
for a in range(soy[0][1] + 1):
    for b in range(soy[1][1] + 1):
        for c in range(soy[2][1] + 1):
            for d in range(soy[3][1] + 1):
                for e in range(soy[4][1] + 1):
                    for f in range(soy[5][1] + 1):
                        for g in range(soy[6][1] + 1):
                            for h in range(soy[7][1] + 1):
                                for i in range(soy[8][1] + 1):
                                    for j in range(soy[9][1] + 1):
                                        t = soy[0][0]**a * soy[1][0]**b * soy[2][0]**c * soy[3][0]**d * soy[4][0]**e * soy[5][0]**f * soy[6][0]**g * soy[7][0]**h * soy[8][0]**i * soy[9][0]**j
                                        if n <= t:
                                        	ans = max(ans, m//t)
print(ans)