Harryxun/stf_run huggingface dataset:
def printing(a_start, a_2, n):
  a_3 = []
  mod_list = []
  
  for i in range(len(a_2)):
    if (a_2[i][1] % a_start[1] not in mod_list) and (a_2[i][1] % a_start[1] != 0):
      a_3.append(a_2[i])
      mod_list.append(a_2[i][1] % a_start[1])
  
  a_3.sort(key=lambda x: x[1], reverse=True)
  if len(a_3) >= 2:
    if (a_start[0] + a_3[-1][0] < n) and (a_3[0][0] < a3[1][0]) and (a_3[1][0] > a_start[0]):
      a_3.pop()

  ans = ""
  while n % a_start[1] != 0:
    for i in range(len(a_3)):
      if n % a_start[1] >= a_3[i][1] % a_start[1]:
        n -= a_3[i][1]
        ans += str(a_3[i][0])
        break
      elif n % a_start[1] == 0:
        break
    else:
      n -= a_3[0][1]
      ans += str(a_3[0][0])
      
  ans = ans + str(a_start[0]) * (n // a_start[1])
  ans_list = sorted([ans[i] for i in range(len(ans))], reverse=True)
  print(''.join(ans_list))

  
def main():
  N, M = map(int, input().split())
  a = list(map(int, input().split()))
  a.sort(reverse=True)
  num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
  a_list = []
  a_2 = []
  
  for i in range(M):
    if num[a[i]] not in a_list:
      a_2.append([a[i], num[a[i]]])
      a_list.append(num[a[i]])

  a_2.sort(key=lambda x: x[1])
  a_start = a_2.pop(0)
  printing(a_start, a_2, N)
      

if __name__ == '__main__':
  main()

### FIXED CODE ###

def printing(a_start, a_2, n):

    a_3 = []
    mod_list = []
    for i in range(len(a_2)):
        if a_2[i][1] % a_start[1] not in mod_list and a_2[i][1] % a_start[1] != 0:
            a_3.append(a_2[i])
            mod_list.append(a_2[i][1] % a_start[1])
    a_3.sort(key=lambda x: x[1], reverse=True)


    if len(a_3) >= 2:
        if a_start[0] + a_3[-1][0] < n and a_3[0][0] < a_3[1][0] and a_3[1][0] > a_start[0]:
            a_3.pop(0)


    ans = ""
    while n % a_start[1] != 0:
        for i in range(len(a_3)):
            if n % a_start[1] >= a_3[i][1] % a_start[1]:
                n -= a_3[i][1]
                ans += str(a_3[i][0])
                break
            elif n % a_start[1] == 0:
                break
        else:
            n -= a_3[0][1]
            ans += str(a_3[0][0])

    ans = ans + str(a_start[0]) * (n // a_start[1])
    ans_list = sorted([ans[i] for i in range(len(ans))], reverse=True)
    print("".join(ans_list))

def main():
    n, m = [int(i) for i in input().split()]
    a = sorted([int(i) for i in input().split()], reverse=True)
    number = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
    a_list = []
    a_2 = []

    for i in range(m):
        if number[a[i]] not in a_list:
            a_2.append([a[i], number[a[i]]])
            a_list.append(number[a[i]])
    a_2.sort(key=lambda x: x[1])
    a_start = a_2.pop(0)
    printing(a_start, a_2, n)

main()
# B problem
import numpy as np
def check_abs(arr, lists):
    ret = 0
    for i, k in lists:
        tmp = ( arr - k ) ** 2
        if (np.sum(tmp) ** 0.5).is_integer():
            ret += 1
    return ret
T = input()
N, D = map(int,T.split())
lists = []
for i in range(N):
    data = input().split()
    tmp = list(map(int, data))
    lists.append(tmp)
tmp2 = np.array(lists)
for i in range(N):
    ress = 0
    arr = tmp2[i]
    np.delete(tmp2, i, 0)
    res = check_abs(arr, tmp2)
    ress += res
print(ress)

### FIXED CODE ###

import sys
input = sys.stdin.readline
import numpy as np
def print_ans(N, D, dr):
    """Test Case
    >>> print_ans(3, 2, [[1, 2], [5, 5], [-2, 8]])
    1
    >>> print_ans(3, 4, [[-3, 7, 8, 2], [-12, 1, 10, 2], [-2, 8, 9, 3]])
    2
    >>> print_ans(5, 1, [[1],[2],[3],[4],[5]])
    10
    """
    dr = [np.array(d) for d in dr]
    ans = 0
    for i in range(N-1):
        for k in range(i + 1, N):
            multi_ar = dr[i] - dr[k] 
            abs_tmp = float(np.sum(multi_ar ** 2) ** (1/2))
            if(abs_tmp.is_integer()):
                ans += 1
    print(ans)



if __name__ == '__main__':
    N, D = map(int, input().rstrip().split())
    dr = [list(map(int, input().rstrip().split())) for _ in range(N)]
    print_ans(N, D, dr)
10 13 15
3
1
4
1
5
9
2
6
5
3
5
8
9
7
9

### FIXED CODE ###

N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
N_array = [K - Q] * N
for x in A:
    N_array[x - 1] += 1
for z in N_array:
    if z > 0:
        print("Yes")
    else:
        print("No")
S=str(input())
s=list(S)
x1=0
x2=1
y=0
for i in range(len(s)-1):
  if s[i+1]==s[i]:
    x2=x2+1
  else:
    if i==0:
      x2=0
    if s[i]=='>':
      if x2<x1:
        x2=x2-1
      else:
        if x2>x1:
          x1=x1-1
    y+=x1*(x1+1)/2
    x1=x2
    x2=1
if s[i+1]=='>':
      if x2<x1:
        x2=x2-1
      else:
        if x2>x1:
          x1=x1-1
y+=x1*(x1+1)/2
y+=x2*(x2+1)/2
print(int(y))

### FIXED CODE ###

import sys
sys.setrecursionlimit(2147483647) 
S=str(input())
s=list(S)
x1=0
x2=1
y=0
len=len(s)-1
for i in range(len):
  if s[i+1]==s[i]:
    x2=x2+1
  else:
    if i==0:
      x2=0
    if s[i]=='>':
      if x2<x1:
        x2=x2-1
      else:
          x1=x1-1
    y+=x1*(x1+1)/2
    x1=x2
    x2=1
if s[len]=='>':
  if x2<x1:
    x2=x2-1
  else:
    x1=x1-1
y+=x1*(x1+1)/2
y+=x2*(x2+1)/2
print(int(y))
import itertools
 
N = int(input())
x = list()
y = list()
 
for i in range(N):
    #print(i)
    xy = list(input().split())
    x.append(int(xy[0]))
    y.append(int(xy[1]))

ans = 0    
for i in range(N):
    for j in range(N):
        tmp = math.sqrt((x[i]-x[j])**2+(y[i]-y[j])**2)
        ans += tmp
 
print(ans/N)

### FIXED CODE ###

import math

N = int(input())
x = []
y = []

for k in range(N):
    #print(i)
    X, Y =  map(int,input().split())
    x.append(X)
    y.append(Y)

ans = 0    
for i in range(N):
    for j in range(N):
        tmp = math.sqrt((x[i]-x[j])**2+(y[i]-y[j])**2)
        ans += tmp
 
print(ans/N)
n = int(input())
h = [int(x) for x in input().split()]
dp = [float("inf")]*(n+10)
dp[0] = 0
for i in range(n):
    if i<n-1:
        dp[i+1] = min(dp[i+1],dp[i]+abs(h[i+1]-h[i]))
    if i<n-2:      
        dp[i+2] = min(dp[i+2],dp[i]+abs(h[i+2]-h[i]))
print(dp[n-1])

### FIXED CODE ###

n,k = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]
dp = [float("inf")]*n
dp[0] = 0
for i in range(1,n):
    for j in range(1,k+1):
        if i>=j:
            dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))

print(dp[n-1])
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

A, B = map(int, input().split())
print(lcm(A, B))

### FIXED CODE ###

a, b = map(int, input().split())
def gcd(a, b):
    while b:
        a, b= b, a%b
    return a
def lcm(a, b):
    return (a * b) // gcd(a, b)
print(lcm(a, b))
N = int(input())
d = [int(x) for x in input().split()]
num = 0

for a in range(N-2):
    for b in range(a + 1, N-1):
        for c in range(b + 1, N):
            if (abs(d[a]-d[b]) < d[c]) and (d[c] < d[a] + d[b]):
                num += 1

print(num)

### FIXED CODE ###

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

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

print(num+1)
import sys

"""[A-Z]"""
az = [chr(i) for i in range(65, 65+26)]

"""inputs"""
lines  = sys.stdin.readlines()
s_num  = int(lines[0])
s_list = list(lines[1])

result = []

"""logic"""
for l in s_list:
  num = az.index(l)
  c = s_num + num
  if c > 25:
    c = c - 25 - 1
  
  result.append(az[c])

"""result"""
print(''.join(result))

### FIXED CODE ###

az = [chr(i) for i in range(65, 65+26)]
n  = int(input())

result = []
for l in list(input()):
  c = n + az.index(l)
  if c > 25:
    c = c - 25 - 1
  result.append(az[c])

print(''.join(result))
N,M=map(int,raw_input().split())

upper=M/N
def factorize(n):
    fct = []
    b, e = 2, 0
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct
def divisorize(fct):
    b, e = fct.pop()
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]
def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a

fct = factorize(M)

Ans=1
for div in divisorize(fct):
    if num(div)<=upper:
        Ans=max(Ans,num(div))
   
print Ans

### FIXED CODE ###

N,M=map(int,raw_input().split())

upper=M/N
def factorize(n):
    fct = []
    b, e = 2, 0
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct
def divisorize(fct):
    b, e = fct.pop()
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]
def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a

fct = factorize(M)
if fct==[]:
    print 1
    exit()

Ans=1
for div in divisorize(fct):
    if num(div)<=upper:
        Ans=max(Ans,num(div))
   
print Ans
n=int(input())
num=int(input().split())
print(max(num)-min(num))

### FIXED CODE ###

n=int(input())
num_str=input().split()
num=list(map(int, num_str))
print(max(num)-min(num))
nums = [int(e) for e in input().split()]
Min=nums[0]
y=nums[1]
t=True
while t:
    a = abs(Min-y)
  if(a<Min):
    Min = a
  elif(a>Min):
    break
print(Min)

### FIXED CODE ###

nums = [int(e) for e in input().split()]
Min=nums[0]
y=nums[1]
ans = Min % y
t = True
if (ans <= Min):
    Min = ans
    while t:
        a = abs(Min - y)
        if(a<Min):
            Min = a
        elif(a>Min):
            break
    print(Min)
else:
    print(ans)
A,B,K = map(int,input().split())
if A+B <= K:
print(0,0)
elif A >= K:
  print(A-K,B)
else:
  print(0,B-K+A)


### FIXED CODE ###

A,B,K = map(int,input().split())
if A+B <= K:
  print(0,0)
elif A >= K:
  print(A-K,B)
else:
  print(0,B-K+A)
N, M = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for i in range(N - 1 + M)]

from collections import defaultdict

vs = defaultdict(set)

for a, b in AB:
    vs[b].add(a)

from functools import lru_cache

@lru_cache(maxsize=N)
def calc(n):
    max_distance = 0
    max_distance_parent = 0
    for m in vs[n]:
        d = calc(m)[0]
        if max_distance < d + 1:
            max_distance = d + 1
            max_distance_parent = m
    return max_distance, max_distance_parent

for i in range(1, N + 1):
    print(calc(i)[1])


### FIXED CODE ###

N, M = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for i in range(N - 1 + M)]

import sys
sys.setrecursionlimit(200000)

from collections import defaultdict

vs = defaultdict(set)
ws = defaultdict(set)

for a, b in AB:
    vs[a].add(b)
    ws[b].add(a)

#print(vs)
#print(ws)

L = []

cs = [0] * (1 + N)

def visit(n):
    if cs[n] == 1:
        return
    elif cs[n] == 0:
        cs[n] = 1
        for m in vs[n]:
            visit(m)
        cs[n] = 2
        L.append(n)

for n in range(1, N + 1):
    if cs[n] == 0:
        visit(n)

#print(L)

nrank = {}

for r, n in enumerate(L):
    nrank[n] = r

#print(nrank)

for n in range(1, N + 1):
    r = 0
    if ws[n]:
        r = sorted(ws[n], key=lambda x:nrank[x])[0]
    print(r)
a,b,c=map(int,input().split())
print((a*b)//2)


### FIXED CODE ###

s=int(input())

l=[s]*(10**6)
for i in range(10**6):
    if l[i]%2==0:
        l[i+1]=l[i]//2
    else:
        l[i+1]=3*l[i]+1
    if l[i]==4:
        print(i+4)
        exit()
    if l[i]==1:
        print(i+4)
        exit()
    if l[i]==2:
        print(i+4)
        exit()
n, m = map(int, input().split())
if m<n:
  print("No")
 else:
 	print("Yes")

### FIXED CODE ###

N, M = map(int, input().split())
if M<N:
  print("No")
else:
  print("Yes")
n = int(input())
a = [0,0,0,0,0,1,0,0,0,0,3,0,0,0,0,0,3,3,0,0,0,0,0,1,6,0,3,0,0,0,0,0,3,3,6,0,0,3,0,0,0,0,3,3,6,0,6,0,0,0,3,0,0,1,6,0,6,6,0,0,6,0,0,0,0,3,3,3,6,0,6,3,6,0,0,0,6,0,0,0,3,3,9,0,6,3,6,0,3,6,0,0,0,0,6,1,6,0,6,6,0,3,12,0,6,0,0,3,6,0,0,0,3,3,12,0,6,3,6,0,3,6,9,0,6,0,0,0,3,6,3,3,6,0,6,3,12,0,3,6,6,0,6,0,6,3,6,0,0,1,6,3,12,6,0,0,12,0,6,0,6,6,12,0,0,6,0,0,6,0,12,3,6,0,6,3,9,6,3,6,6,0,6,0,6,0,15,6,0,0,6,0,3,3,12,0,12,6,6,0,3,6,6,3,12,0,6,0,9,6,0,0,6,3,12,1,6,6,6,6,0,0,18,0,12,0,3,6,12,0,0,6,3,6,12,0,12,0,0,0,9,3,9,6,12,3,12,0,3,6,6,0,12,0,12,0,9,9,0,0,6,3,6,3,12,6,9,3,6,0,12,3,6,3,9,6,12,6,6,0,6,0,9,6,6,0,12,3,6,0,9,6,6,1,6,0,21,12,6,0,12,0,12,0,0,6,15,6,0,6,12,0,12,0,12,0,0,0,12,0,12,12,3,3,18,3,6,3,6,6,9,9,18,0,6,0,12,0,9,6,0,3,12,3,6,6,12,6,6,0,0,0,15,3,18,3,18,3,12,6,3,6,9,0,12,0,12,0,18,12,0,0,12,3,6,0,6,6,9,6,0,0,18,1,18,3,12,6,6,6,12,0,15,6,12,6,18,0,0,6,0,9,12,0,18,0,6,3,12,0,12,12,0,0,12,0,3,6,12,6,18,9,18,0,9,6,18,0,6,0,6,3,27,6,6,6,6,3,6,0,12,6,9,0,6,0,18,0,9,9,15,3,12,6,6,3,9,6,12,12,18,0,18,0,6,6,21,6,0,0,6,3,15,6,12,6,18,0,0,0,12,6,6,3,6,4,18,6,12,6,3,9,30,0,18,0,6,6,12,6,6,9,12,0,18,6,18,0,6,0,12,0,6,12,6,3,18,0,6,6,6,6,15,3,24,0,6,3,18,0,12,6,12,6,24,0,15,18,9,6,0,0,18,3,6,0,15,12,12,6,6,0,18,0,6,3,12,0,12,6,6,9,9,6,24,3,24,0,9,12,6,6,12,0,12,0,21,9,15,6,12,3,18,3,12,6,12,6,0,0,12,0,12,6,24,0,6,12,6,1,9,6,12,6,24,0,18,3,12,6,6,12,24,0,12,6,15,6,18,0,18,0,0,0,18,9,21,12,0,6,18,0,9,6,6,6,12,0,12,0,9,9,27,6,6,3,18,6,21,6,6,12,12,0,12,0,24,12,0,0,24,3,24,6,12,12,18,0,0,0,12,0,18,3,15,6,12,9,6,0,15,6,9,12,24,0,12,3,6,6,21,6,18,3,18,0,21,12,15,6,6,0,12,3,12,9,18,9,12,6,6,6,24,0,18,3,24,0,6,6,0,6,9,6,6,4,30,0,18,12,9,6,24,0,18,0,9,12,21,6,6,12,12,0,18,0,21,15,12,0,12,6,12,12,18,0,18,0,6,0,9,12,18,6,30,0,0,0,24,6,9,3,12,6,30,3,6,12,6,12,12,0,36,0,6,3,27,12,12,6,6,6,24,0,12,6,12,0,18,0,18,15,18,3,18,6,12,6,6,12,3,6,6,0,12,3,39,3,12,12,12,3,18,0,21,12,21,6,18,0,12,0,9,9,12,9,24,9,12,6,12,6,33,0,6,0,18,0,9,15,12,6,24,6,6,3,15,6,15,12,18,0,18,1,18,6,12,6,6,0,24,6,24,12,18,6,24,0,6,6,12,15,24,0,24,6,6,0,18,0,15,18,12,0,24,0,12,6,12,12,18,6,24,0,0,6,24,3,12,0,12,6,30,9,6,12,24,12,12,0,15,18,12,0,18,0,24,6,15,6,18,3,18,3,12,6,24,12,12,12,6,0,36,0,18,3,6,12,6,9,12,0,3,12,36,0,30,0,12,0,18,6,12,9,12,6,24,3,18,12,15,9,24,0,18,6,18,9,18,12,6,6,24,3,24,0,12,12,12,0,6,0,27,12,18,3,30,3,18,6]
for i in range(n):
         print(a[i])


### FIXED CODE ###

n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
         for j in range(1,105):
                  for k in range(1,105):
                           v = i*i+j*j+k*k+i*j+j*k+k*i;
                           if v<10050:
                                    ans[v]+=1
for i in range(n):
         print(ans[i+1])
az = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
sum_az = [0 for x in range(26)]

while True:
    x = raw_input()
    x.lower()
    for i in range(26):
        for j in range(len(x)):
            if x[j] == az[i]:
                sum_az[i] += 1
    if !x:
        break

for i in range(26):
    print ("%s : %d" % (az[i], sum_az[i]))
                

### FIXED CODE ###

import sys
az =["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
sum_az = [0 for x in range(26)]

for x in sys.stdin.read().lower():
    for i in range(26):
        if x == az[i]:
            sum_az[i] += 1


for i in range(26):
    print ("%s : %d" % (az[i], sum_az[i]))
while True:
    H,W = map(int,input().split())
    a = '#.'
    b = '#'
    c = '.#'
    d = '.'

    def bw(n):
        if n % 2 == 0:
            print((n//2)*a)
        else:
            print((n//2)*a + b)

    def wb(n):
        if n % 2 == 0:
            print((n//2)*c)
        else:
            print((n//2)*c + d)

    for i in range(1,H + 1):
        if i % 2 == 0:
            wb(W)
        else:
            bw(W)
    print()

### FIXED CODE ###

while True:
    H,W = map(int,input().split())
    if H == W == 0:
        break
    a = '#.'
    b = '#'
    c = '.#'
    d = '.'

    def bw(n):
        if n % 2 == 0:
            print((n//2)*a)
        else:
            print((n//2)*a + b)

    def wb(n):
        if n % 2 == 0:
            print((n//2)*c)
        else:
            print((n//2)*c + d)

    for i in range(1,H + 1):
        if i % 2 == 0:
            wb(W)
        else:
            bw(W)
    print()
a,b = map(int,input().split())

if a < b:
 print(a < b)
elif a > b:
 print(a > b)
else a == b:
 print(a == b)

### FIXED CODE ###

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

if a < b:
 print("a < b")
elif a > b:
 print("a > b")
else:
 print("a == b")
import decimal
n = float(input())
a = list(map(float, input().split()))

s = 1
for i in a:
    s = s * i

x = (n-1)*sum(a))
s = decimal.Decimal(7)
x = decimal.Decimal(7)
print(float(s)/x)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 0

for i in a:
    ans = ans + 1/i
print(1/ans)
#coding: utf-8
#ABC042C

n,k=map(int,raw_input().split())
d=raw_input().split()

while True:
 if all(x not in str(n) for x in d):
  res=n
  break
 n+=1
 
print res


### FIXED CODE ###

#coding: utf-8
#ABC042A

l=map(int,raw_input().split())

if l.count(5)==2 and l.count(7)==1:
 print "YES"
else:
 print "NO"
# -*- coding: utf-8 -*-

n, k, q =map(int, input().split())
a = []

for i in range(q):
  a.append(int(input()))

m = list([k]*n)

for i in range(a):
  for j in range(n):
    m[j]=m[j]-1
    m[a-1]=m[a-1]+1
  
for i in range(n):
  if m[i]>0:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

# -*- coding: utf-8 -*-
 
n, k, q =map(int, input().split())
a = [int(input()) for i in range(q)]

p = [0]*(n+1)

for i in range(q):
  p[a[i]] += 1
  

for i in range(1,n+1):
  if p[i]>q-k:
    print("Yes")
  else:
    print("No")
def add_node_2_tree_dic(tree_dic, x, y):
    if x not in tree_dic:
        tree_dic[x] = [y]
    else:
        tree_dic[x].append(y)

#   深さ優先探索で行けそう

N = int(input())
tree_dic = {}
for _ in range(N-1):
    a, b = map(int, input().split())
    add_node_2_tree_dic(tree_dic, a, b)
    add_node_2_tree_dic(tree_dic, b, a)

c_lst = list(map(int, input().split()))
c_lst.sort()
ans_lst = [0]*N

def search_next_node_and_add_side_wate(tree_dic, ans, current_node, c_lst, ans_lst):
    
    judge = True
    for key in tree_dic:
        if tree_dic[key] != 0:
            judge = False
    
    if judge:
        return ans

    if len(tree_dic) == 0:  #   これなしでいい？
        return ans

    tmp_lst = tree_dic[current_node][:]
    for next_node in tmp_lst:

        c = c_lst.pop()
        ans += c
        ans_lst[next_node - 1] = c

        tree_dic[current_node].remove(next_node)    #   今回通った枝を取り払う
        tree_dic[next_node].remove(current_node)
            
        ans = search_next_node_and_add_side_wate(tree_dic, ans, next_node, c_lst, ans_lst)

    return ans


ans = 0
current_node = 1
ans_lst[0] = c_lst.pop()
ans = search_next_node_and_add_side_wate(tree_dic, ans, current_node, c_lst, ans_lst)


ans_str = ""
for i in range(N):
    ans_str += str(ans_lst[i])
    if i != N - 1:
        ans_str += " "


print(ans)
print(ans_str)



### FIXED CODE ###

import sys
sys.setrecursionlimit(20000)

def add_node_2_tree_dic(tree_dic, x, y):
    if x not in tree_dic:
        tree_dic[x] = [y]
    else:
        tree_dic[x].append(y)

#   深さ優先探索で行けそう

N = int(input())
tree_dic = {}
for _ in range(N-1):
    a, b = map(int, input().split())
    add_node_2_tree_dic(tree_dic, a, b)
    add_node_2_tree_dic(tree_dic, b, a)

c_lst = list(map(int, input().split()))
c_lst.sort()
ans_lst = [0]*N

def search_next_node_and_add_side_wate(tree_dic, ans, current_node, c_lst, ans_lst):
    next_node_lst = tree_dic[current_node][:]

    for next_node in next_node_lst:
        c = c_lst.pop()
        ans += c
        ans_lst[next_node - 1] = c

        tree_dic[current_node].remove(next_node)    #   今回通った枝を取り払う
        tree_dic[next_node].remove(current_node)

        if len(tree_dic[current_node]) == 0:
            del tree_dic[current_node]#   探索し終えたノードの削除
        if len(tree_dic[next_node]) == 0:
            del tree_dic[next_node]#   探索し終えたノードの削除
        else:   #   次のノードにつながっている辺があるとき
            ans = search_next_node_and_add_side_wate(tree_dic, ans, next_node, c_lst, ans_lst)

    return ans


ans = 0
current_node = 1
ans_lst[0] = c_lst.pop()
ans = search_next_node_and_add_side_wate(tree_dic, ans, current_node, c_lst, ans_lst)


ans_str = ""
for i in range(N):
    ans_str += str(ans_lst[i])
    if i != N - 1:
        ans_str += " "


print(ans)
print(ans_str)
A, B, K = map(int, input().split())

count = 0
for i in range(min(A,B), 0, -1):
	if A % i == 0 and B % i == 0:
		count += 1
	if count == K:
    	print(i)
       	exit()


### FIXED CODE ###

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

count = 0
for i in range(min(A,B), 0, -1):
	if A % i == 0 and B % i == 0:
		count += 1
	if count == K:
		print(i)
		exit()
X, Y = map(int, input().split())

a = (4*Y-2*X)//6
b = (Y-2*X)//-3
if a == 0 and b == 0:
    print(0)
    import sys
    sys.exit()

from math import factorial
print(factorial(a+b)//factorial(a)*factorial(b)%(10e9+7))


### FIXED CODE ###

X, Y = map(int, input().split())

MD = pow(10, 9) + 7

def choose(n, a):
    x, y = 1, 1
    for i in range(a):
        x = x * (n - i) % MD
        y = y * (i + 1) % MD
    return x * pow(y, MD - 2, MD) % MD


a = (2*Y-X)//3
b = (Y-2*X)//-3

if a < 0 or b < 0 or (X+Y) % 3 != 0:
    print(0)
    import sys
    sys.exit()

print(choose(a+b, min(a,b)))
ins = input()


def foo(s):
    last = s[-1]
    # is empty
    if not s:
        return "YES"
    else:
        n = 0
        if last == 'r' and s[-6:] == 'eraser':
            n = -6
        elif last == 'r' and s[-7:] == 'dreamer':
            n = -7
        elif (last == 'e' and s[-5:] == 'erase') or (last == 'm' and s[-5:] == 'dream'):
            n = -5

        if n == 0:
            return "NO"
        else:
            return foo(s[:n])


print(foo(ins))


### FIXED CODE ###

s = input()


while len(s) > 0:
    if s[-6:] == 'eraser':
        s=s[:-6]
    elif s[-7:] == 'dreamer':
        s=s[:-7]
    elif s[-5:] == 'erase' or s[-5:] == 'dream':
        s=s[:-5]
    else:
        print('NO')
        exit(0)
print('YES')
import math
a, b = map(int, input(), split(　))
print(math.ceil((a * b) / 2))

### FIXED CODE ###

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

print(math.ceil((a + b) / 2))
from numba import njit
@njit(parallel=True)
def main():
  n,k=map(int,input().split())
  p=list(map(int,input().split()))
  c=list(map(int,input().split()))
  ans=-10**18
  for i in range(n):
    start,count=i,1
    val=c[start]
    while p[start]-1!=i: #ループ部分
      start=p[start]-1
      count+=1
      val+=c[start]
    start=i
    if val>0:
      a=(k//count-1)*val #一周目はループのどの部分から始めるのが最適かわからないので
      ans=max(a,ans)
      num=count+k%count
    else:
      a=0
      num=min(k,count)
    for _ in range(num):
      start=p[start]-1
      a+=c[start]
      ans=max(a,ans)
  print(ans)
main()


### FIXED CODE ###

from numba import jit
@jit
def main():
  n,k=map(int,input().split())
  p=list(map(int,input().split()))
  c=list(map(int,input().split()))
  ans=-10**18
  for i in range(n):
    start,count=i,1
    val=c[start]
    while p[start]-1!=i: #ループ部分
      start=p[start]-1
      count+=1
      val+=c[start]
    start=i
    if val>0:
      a=(k//count-1)*val #一周目はループのどの部分から始めるのが最適かわからないので
      ans=max(a,ans)
      num=count+k%count
    else:
      a=0
      num=min(k,count)
    for _ in range(num):
      start=p[start]-1
      a+=c[start]
      ans=max(a,ans)
  print(ans)
main()
#!/usr/bin
# -*- coding="utf-8" -*-
 
n = raw_input()
if n >= 64:
  a = 64
elif n >= 32:
  a = 32
elif n >= 16:
  a = 16
elif n >= 8:
  a= 8
elif n >= 4:
  a = 4
elif n >= 2:
  a = 2
else:
  a = 1
print(a)

### FIXED CODE ###

#!/usr/bin
# -*- coding="utf-8" -*-
 
n = int(input())
if n >= 64:
  a = 64
elif n >= 32:
  a = 32
elif n >= 16:
  a = 16
elif n >= 8:
  a= 8
elif n >= 4:
  a = 4
elif n >= 2:
  a = 2
else:
  a = 1
print(a)