Harryxun/stf_run huggingface dataset:
N = int(input())
Nodes = [[int(i) for i in input().split()] for j in range(N - 1)]
C = [int(i) for i in input().split()]
C.sort()
# 根から始め、巡回した葉にCの大きなものから順に書き込んで行く。
# int_list = list(sorted(C))
graph = [[] for _ in range(N)]
for u, v in Nodes:  # 0-basedとする
    graph[u - 1].append(v - 1)
    graph[v - 1].append(u - 1)
# print(Nodes)
# print(graph)

# 各頂点にCの値が大きなもの順に書き込んでいく
ret = [0] * N
def dfs(c):
    if min(ret) > 0:    # 全て処理済み
        return 1
    # ret[c] = int_list.pop()
    ret[c] = C.pop()
    for next_edge in graph[c]:
        if ret[next_edge] == 0:  # まだ見ていない頂点だけ調べる
            dfs(next_edge)
    return 1
dfs(c=0)

print(sum(ret[1:]))
print(" ".join(map(str, ret)))

### FIXED CODE ###

def d_maximum_sum_of_minimum(N, Nodes, C):
    # 根から始め、巡回した葉にCの大きなものから順に書き込んで行く。
    import sys
    sys.setrecursionlimit(10**6)

    int_list = list(sorted(C))
    graph = [[] for _ in range(N)]
    for u, v in Nodes:  # 0-basedとする
        graph[u - 1].append(v - 1)
        graph[v - 1].append(u - 1)

    def traverse_tree(parent, current, ret=[0] * N):
        """各頂点にCの値が大きなもの順に書き込んでいく"""
        def dfs(p, c):
            ret[c] = int_list.pop()
            for next_edge in graph[c]:
                if next_edge != p:  # 木を「逆戻り」しない頂点だけ調べる
                    dfs(c, next_edge)
        dfs(parent, current)
        return ret
    tmp = traverse_tree(-1, 0)
    return str(sum(tmp[1:])) + '\n' + ' '.join(map(str, tmp))

N = int(input())
Nodes = [[int(i) for i in input().split()] for j in range(N - 1)]
C = [int(i) for i in input().split()]
print(d_maximum_sum_of_minimum(N, Nodes, C))
n, k = map(int, input().split())

sunuke = [[0] * (n+2)] * (k+2)
ans = 0
for j in range(1, k+1) :
    num_have_okashi = int(input())
    oakshi_sunuke = list(map(int,input().split()))

    for i in oakshi_sunuke :
        sunuke[i][j] = 1
        print('num_have_okashi = [%d]' % (num_have_okashi))
        print(oakshi_sunuke)
        print('sunuke[%d][%d] = %d' % (i, j, sunuke[i][j]))
        ans = ans + 1
        break

print(n-ans)


### FIXED CODE ###

num_sunuke, num_okashi_kind = map(int, input().split())
sunuke = [0] * (num_sunuke+1)

ans = 0
for idx_okashi_kind in range(1, num_okashi_kind+1) :
    num_have_okashi = int(input())
    idx_sunuke_with_okashi = map(int,input().split())

    for i in range(1, num_have_okashi+1) :
        for j in idx_sunuke_with_okashi :
            sunuke[j] = 1

for s in sunuke :
    if s == 1 :
        ans = ans + 1

print(num_sunuke - ans)
A,B,C,D = map(int, input().split())

AB = abs(A-B)
BC = abs(B-C)
ans = 0

if AB <= D and BC <= D or AC <= D:
    ans = "Yes"
else:
    ans = "No"
        
print(ans)
    

### FIXED CODE ###

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

AB = abs(A-B)
BC = abs(B-C)
AC = abs(A-C) 
ans = 0

if AB <= D and BC <= D or AC <= D:
    ans = "Yes"
else:
    ans = "No"
        
print(ans)
N = int(input())
d = list(map(int,input().split()))
chuou1 = d[N//2]
chuou2 = d[(N//2)+1]
print(str(chuou2 - chuou1))

### FIXED CODE ###

N = int(input())
d = list(map(int,input().split()))
d = sorted(d)
chuou1 = d[N//2-1]
chuou2 = d[(N//2)]
if(chuou2 - chuou1 < 0):
  print("0")
else:
  print(str(chuou2 - chuou1))
from itertools import count

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

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

for i in range(N):
    for w in range(W+1):
        if w - WV[i][0] >= 0:  # 品物を追加できるとき
            dp[i+1][w] = max(dp[i+1][w], dp[i][w-WV[i][0]] + WV[i][1])
        # できないとき
        dp[i+1][w] = max(dp[i+1][w], dp[i][w])
print(dp[N][W])


### FIXED CODE ###

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

V = 10**3
dp = [[float('INF')]*(N*(V+1)) for _ in range(N+1)]  # Nとv≦10**3の制約から取りうるvの範囲
dp[0][0] = 0

for i in range(N):
    for v in range((i+1)*(V+1)):
        if v - WV[i][1] >= 0:  # 品物を追加できるとき
            dp[i+1][v] = min(dp[i+1][v], dp[i][v-WV[i][1]] + WV[i][0])
        # できないとき
        dp[i+1][v] = min(dp[i+1][v], dp[i][v])

ans = 0
for i in range(N*(V+1)):
    if dp[N][i] <= W:
        ans = i
print(ans)
# -*- coding: utf-8 -*-
"""
Created on Sat Feb 16 19:31:10 2019
ABC118D
@author: maezawa
"""
import copy

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

nmatch = [2,5,5,4,5,6,3,7,6]
rmatch = list(reversed(nmatch))
nmdic = dict([(i+1,nmatch[i]) for i in range(9)])
#nums = [[],[],[1],[7],[4],[2,3,5],[6,9],[8]]
nums = [[] for _ in range(10)]
for i in range(10):
    if i in a:
        nums[nmdic[i]].append(i)
        
#print(nmdic)
#print(nums)

dp = [[-1,[]] for _ in range(n+1)]
dp[0] = [0, []]
#print(dp)

for i in range(1, n+1):
    maxorder = 0
    cnds = []
    for j in range(1, 7):
        if nums[j] == []:
            continue
        if dp[i-j][0] == -1:
            continue
        cndo = dp[i-j][0]+1
        cndos = copy.copy(dp[i-j][1])
        cndos.append(max(nums[j]))
        cnds.append([cndo, cndos])
        #print(i, i-j, cnds, cndos)
    if cnds == []:
        continue
    dp[i] = max(cnds, key=lambda x: x[0])

ans = ''.join(map(str, sorted(dp[n][1], reverse=True)))
print(ans)



### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sat Feb 16 19:31:10 2019
ABC118D
@author: maezawa
"""
import copy

n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort(reverse=True)

nmatch = [2,5,5,4,5,6,3,7,6]
rmatch = list(reversed(nmatch))
nmdic = dict([(i+1,nmatch[i]) for i in range(9)])
#nums = [[],[],[1],[7],[4],[2,3,5],[6,9],[8]]
nums = [[] for _ in range(10)]
for  i in a:
    nums[nmdic[i]].append(i)
        
#print(nmdic)
#print(nums)

dp = [[-1,[]] for _ in range(n+1)]
dp[0] = [0, []]
#print(dp)

for i in range(1, n+1):
    cnds = []
    for k in a:
        j = nmdic[k]
        if i-j < 0:
            continue
        if dp[i-j][0] == -1:
            continue
        cndo = dp[i-j][0]+1
        cndos = copy.copy(dp[i-j][1])
        cndos.append(max(nums[j]))
        cnds.append([cndo, cndos])
        #print(i, i-j, cnds, cndos)
    if cnds == []:
        continue
    dp[i] = max(cnds, key=lambda x: x[0])

ans = ''.join(map(str, sorted(dp[n][1], reverse=True)))
print(ans)
a,b,c=map(int,input().split())
print('delicious' if c<b else 'safe' if c-b<a else 'dengerous'))

### FIXED CODE ###

a,b,c=map(int,input().split())
print('delicious' if c<=b else 'safe' if c-b<=a else 'dangerous')
from bisect import bisect_left
n=int(input())
l=list(map(int,input().split()))
l.sort()

ans=0
for a in range(n-2):
    for b in range(a+1,n-1):
        r=bisect_left(l, l[a] + l[b], b + 1, n)
        l=b+1
        ans+=r-l
        
print(ans)


### FIXED CODE ###

from bisect import bisect_left
n=int(input())
l=list(map(int,input().split()))
l.sort()

ans=0
for a in range(n-2):
    for b in range(a+1,n-1):
        ans+=max(0,bisect_left(l, l[a] + l[b])-b-1)
        
        
print(ans)
import re
print(["No", "Yes"][re.Match("C.*F", input())])

### FIXED CODE ###

import re
S = input()
print(["Yes", "No"][re.match(".*C.*F.*", S) is None])
N = int(input())
S = list(input())  # len:N

S = sorted(S)  #  アルファベット順に並べ替え
U = [0] * 26  #  ユニーク数数え上げ
tmp = "0"
count = 0
u_count = 0
for i in range(N):
    if i > 0:
        if tmp == S[i]:
            U[count] += 1
        else:
            tmp = S[i]
            count += 1
            U[count] += 1
    else:
        tmp = S[i]
        U[count] += 1


for u in range(26):
    if U[u] != 0:
        u_count += 1


for i in range(len(U)):
    if U[0] == 0:
        U.pop(0)

U = list(map(lambda x:x+1, U))
print(np.array(U).prod()-1)

### FIXED CODE ###

from collections import Counter
N = int(input())
S = input()
answer = 1
counter = Counter(S).most_common()

for i in range(len(counter)):
    answer = answer * (counter[i][1] + 1) % (10**9 + 7)

print(answer-1)
n = int(input())
t = list(map(int,input(),split()))
m = int(input())
p = [0]* m 
x = [0]* m 
for i in range(m):
    p[i],x[i]= map(int(input(),split()))
for i in range(m):
    print(sum(t)-t[p[i]-1]+x[i])


### FIXED CODE ###

n=int(input())
t=list(map(int,input().split()))
m=int(input())
p=[0]*m
x=[0]*m
for i in range(m):
  p[i],x[i]=map(int,input().split())  
for i in range(m):
  print(sum(t)-t[p[i]-1]+x[i])
numa = int(a)
numb = int(b)
num = numa * numb
if num % 2 == 0:
    print("Even")
else:
    print("Odd")

### FIXED CODE ###

a,b=map(int,input().split())
if (a*b)%2 == 1:
  print('Odd')
else:
  print('Even')
N = 0;
A = 0;
B = 0;

input(N);

if N == 1:
    print("Hello World")
    
else:
    input(A);
    input(B);
    print(A+B);

### FIXED CODE ###

N = input()
N = int(N)

if N == 1:
    print("Hello World")
    
if N == 2:
    A = input()
    B = input()
    A = int(A)
    B = int(B)
    print(A+B);
def mod_fact(N,p):
    mod=1
    for n in range(1,N+1):
        mod = (mod*(n%p))%p
        
    mod = mod%p
    
    return mod

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

Z = X+Y

if Z%3 != 0:
    ans=0
    
elif min(X,Y) >= Z//3:
    b=0
    for z in range(Z//3,((Z//3)*2)+1):
        if z == X:
            break
        b+=1
    a = Z//3 - b 
    
    p=(10**9)+7

    Z_= mod_fact(Z//3 , p)
    a_= mod_fact(a , p)
    b_= mod_fact(b , p)

    a_= pow(a_,p-2,p)
    b_= pow(b_,p-2,p)

    ans=(Z_*(a_*b_))%p
    
print(ans)

### FIXED CODE ###

def mod_fact(N,p):
    mod=1
    for n in range(1,N+1):
        mod = (mod*(n%p))%p
        
    mod = mod%p
    
    return mod

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

Z = X+Y

ans=0

if Z%3 != 0:
    ans=0
    
elif min(X,Y) >= Z//3:
    b=0
    for z in range(Z//3,((Z//3)*2)+1):
        if z == X:
            break
        b+=1
    a = Z//3 - b 
    
    p=(10**9)+7

    Z_= mod_fact(Z//3 , p)
    a_= mod_fact(a , p)
    b_= mod_fact(b , p)

    a_= pow(a_,p-2,p)
    b_= pow(b_,p-2,p)

    ans=(Z_*(a_*b_))%p
    
print(ans)
y = ""
while True:
    try:
        c = raw_input().lower()
        y = y + c
    except:
        break

for i in range(ord('a'),ord('z')+1):
    print("{}: {}".format(chr(i),y.count(chr(i)))

### FIXED CODE ###

s =""
while True:
    try:
        s += input().lower()
    except:
        break
    
s = list(map(ord,list(s)))
for i in range(ord("a"),ord("z")+1):
    print(chr(i) + " : " + str(s.count(i)))
import sys

input = sys.stdin.readline
n = int(input())
sl = list(input())

q = int(input())
kl = list(map(int,input().split()))

for k in kl:
    # i文字目までのdとmとdmの数

    dp = [[0, 0, 0] for i in range(n+1)]
    ans = 0
    for i, s in enumerate(sl):
        if i - k >= 0:
            if sl[i-k] == "D":
                dp[i][0] -= 1
                dp[i][2] -= dp[i][1]
            if sl[i-k] == "M":
                dp[i][1] -= 1
        if s == "D":
            dp[i+1][0] = dp[i][0] + 1
        else:
            dp[i+1][0] = dp[i][0]
        if s == "M":
            dp[i+1][1] = dp[i][1] + 1
            dp[i+1][2] = dp[i][2] + dp[i][0]
        else:
            dp[i+1][1] = dp[i][1]
            dp[i + 1][2] = dp[i][2]
        if s == "C":
            ans += dp[i][2]

    print(ans)









### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    N = int(input())
    S = input()
    Q = int(input())
    x = tuple(map(int,input().split()))
    for k in x:
        d,m,dm,dmc = 0,0,0,0
        for i in range(N):
            if S[i] == "D":
                d += 1
            elif S[i] == "M":
                m += 1
                dm += d
            elif S[i] == "C":
                dmc += dm
            if i >= k-1:
                if S[i-k+1] == "D":
                    dm -= m
                    d -= 1
                elif S[i-k+1] == "M":
                    m -= 1
        print(dmc)
    
if __name__ == "__main__":
    main()
def main():
    N = input()
    if int(N) < 1 or int(N) >= 2*10**5:
        raise ValueError
    A = []
    for i in input().split():
        if int(i) < 1 or int(i) >= 10**9:
            raise ValueError
        A.append(int(i))
    temp = A[0]
    su = 0
    for i in A:
        if i >= temp:
            height = 0
        else:
            height = temp-i
        temp = i + height
        su += height
    print(su)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N = int(input())
    A = list(map(int, input().split()))
    temp = A[0]
    su = 0
    for i in range(1, N):
        if A[i - 1] > A[i]:
            su += A[i - 1] - A[i]
            A[i] = A[i - 1]
    print(su)


if __name__ == '__main__':
    main()
a = map(int,input())
b = map(int,input())
c = map(int,input())
d = map(int,input())
e = map(int,input())
k = map(int,input())

List = list(a,b,c,d,d,e)
if max(List)-min(List) <= k:
	print("Yay!")
else<
	print(":(")

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

List = [a,b,c,d,e]
if max(List) - min(List) <= k:
	print("Yay!")
else:
	print(":(")
from collections import defaultdict

h, w, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

d = defaultdict(int)

for a, b in ab:
    for hi in range(a - 2, a + 1):
        for wi in range(b - 2, b + 1):
            if 1 <= hi <= h - 2 and 1 <= wi <= w - 2:
                d[(hi, wi)] += 1

cnt = [0] * 9
for v in d.values():
    cnt[v] += 1

cnt[0] = (h - 2) * (w - 2) - sum(cnt[1:])
print(*cnt, sep="\n")


### FIXED CODE ###

from collections import defaultdict

h, w, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

d = defaultdict(int)

for a, b in ab:
    for hi in range(a - 2, a + 1):
        for wi in range(b - 2, b + 1):
            if 1 <= hi <= h - 2 and 1 <= wi <= w - 2:
                d[(hi, wi)] += 1

cnt = [0] * 10
for v in d.values():
    cnt[v] += 1

cnt[0] = (h - 2) * (w - 2) - sum(cnt[1:])
print(*cnt, sep="\n")
N = int(input())
S = input()
c = 0
fi = list(S)
for i in range(N):
    if S[i] == "A":
        if S[i+1] == "B":
            if S[i+2] == "C":
                c += 1
print(c)

### FIXED CODE ###

N = int(input())
S = input()
c = 0
fi = list(S)
for i in range(N-2):
    if S[i] == "A":
        if S[i+1] == "B":
            if S[i+2] == "C":
                c += 1
print(c)
import numpy as np

def ceil(a):
    return int(np.ceil(a))

def sol2():
    A,B,C,D,E,F = map(int, input().split(' '))
    na, nb, nc, nd = ceil(F/A/100),ceil(F/B/100),ceil(E*F/C/100),ceil(E*F/D/100) 
    sug = np.arange(0,nc).reshape(1,1,nc,1)*C+np.arange(0,nd).reshape(1,1,1,nd)*D
    wat = np.arange(0,na).reshape(na,1,1,1)*A*100+np.arange(0,nb).reshape(1,nb,1,1)*B*100
    sug2=np.unique(sug[sug<=F*F/100])
    wat2=np.unique(wat[wat<=F])[1:]
    tot =  wat2.reshape(len(wat2),1) + sug2
    e2 = E/(100+E)
    dense = (sug2/tot)[tot<=F]
    
    if E==0:
        print(wat2[1],0)
        return
    
    maxi = np.argmax(dense[dense<=e2])
    stot = tot[tot<=F][dense<=e2]
    ssug = (sug2 + tot*0)[tot<=F][dense<=e2]
    
    if dense[maxi] ==0:
        print(wat2[1],0)
    else:
        print(int(stot[maxi]),int(ssug[maxi]))
sol2()

### FIXED CODE ###

import numpy as np

def ceil(a):
    return int(np.ceil(a))

def sol2():
    A,B,C,D,E,F = map(int, input().split(' '))
    na, nb, nc, nd = ceil(F/A/100),ceil(F/B/100),ceil(E*F/C/100),ceil(E*F/D/100) 
    sug = np.arange(0,nc).reshape(1,1,nc,1)*C+np.arange(0,nd).reshape(1,1,1,nd)*D
    wat = np.arange(0,na).reshape(na,1,1,1)*A*100+np.arange(0,nb).reshape(1,nb,1,1)*B*100
    sug2=np.unique(sug[sug<=F*F/100])
    wat2=np.unique(wat[wat<=F])
    
    if len(wat2)==1:
        print(0,0)
        return
    elif E==0:
        print(wat2[1],0)
        return
    
    tot =  wat2[1:].reshape(len(wat2[1:]),1) + sug2
    e2 = E/(100+E)
    dense = (sug2/tot)[tot<=F]
    
    maxi = np.argmax(dense[dense<=e2])
    stot = tot[tot<=F][dense<=e2]
    ssug = (sug2 + tot*0)[tot<=F][dense<=e2]
    
    if dense[maxi] ==0:
        print(wat2[1],0)
    else:
        print(int(stot[maxi]),int(ssug[maxi]))
sol2()
n, k = map(int, input().split())
dp = [0] * n
a = list(map(int, input().split()))
for i, h in enumerate(a):
    if i != 0:
        g = 0 if i - k < 0 else i - k
        dp[i] = min([abs(h - d) + p for d, p in zip(a[g:i], s[g:i])])
print(s[-1])

### FIXED CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*n
for i,I in enumerate(h):
    if i !=0:
        j=0 if i<k else i-k
        dp[i]=min(abs(I-p)+q for p,q in zip(h[j:i],dp[j:i]))
print(dp[n-1])
def: isort(n,a):
    print " ".join(map(str, a))
    for j in range(1,n):
        key = a[j]
        i = j-1
        while i >= 0 and a[i] > key:
            a[i+1] = a[i]
            i = i - 1
        a[i+1] = key
        print " ".join(map(str, a))

n = int(raw_input())
a = map(int, raw_input().split())
isort(n,a)

### FIXED CODE ###

n = int(raw_input())
a = map(int, raw_input().split())
print " ".join(map(str, a))
for j in range(1,len(a)):
    key = a[j]
    i = j -1
    while i >= 0 and a[i] > key:
        a[i + 1] = a[i]
        i = i -1
    a[i+1]= key
    print " ".join(map(str, a))
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-07-26 13:24:14 +0900
# LastModified: 2020-07-30 16:22:23 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from math import sqrt


def prime_factors(p, prime_box):
    while p % 2 == 0:
        prime_box[2] += 1
        p //= 2

    for i in range(3, len(prime_box), 2):
        while p % i == 0:
            prime_box[i] += 1
            p //= i


def main():
    n, p = map(int, input().split())
    if n == 1:
        print(p)
        return
    prime_box = [0] * (p+1)
    prime_factors(p, prime_box)
    prime_box = list(map(lambda x: x//n, prime_box))
    if sum(i*prime_box[i] for i in range(len(prime_box))) == 0:
        print(1)
    else:
        print(sum(i*prime_box[i] for i in range(len(prime_box))))


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-07-26 13:24:14 +0900
# LastModified: 2020-07-30 16:53:52 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from math import sqrt
from collections import Counter


def prime_factors(p, prime_box):
    while p % 2 == 0:
        prime_box.append(2)
        p //= 2

    for i in range(3, int(sqrt(p))+1, 2):
        while p % i == 0:
            prime_box.append(i)
            p //= i
    if p > 2:
        prime_box.append(p)


def main():
    n, p = map(int, input().split())
    if n == 1:
        print(p)
        return
    prime_box = []
    prime_factors(p, prime_box)
    prime_box = list(map(list, Counter(prime_box).items()))
    prime_box = [[s, t//n] for s, t in prime_box]
    ans = 1
    for s, t in prime_box:
        ans *= s**t
    print(ans)


if __name__ == "__main__":
    main()
a,b = map(int,input().split())
c,d = map(int,input().split())
m31 = [1,3,5,7,8,10,12]
m30 = [4,6,9,11]

if a in m31 and b == 31:
    print(1)
elif a in m30 and b == 30:
    print(1)
elif a == 2 and b == 28:
    print(1)
else:
    print(0) 

### FIXED CODE ###

a,b = map(int,input().split())
c,d = map(int,input().split())
m31 = [1,3,5,7,8,10,12]
m30 = [4,6,9,11]

if a in m31 and b == 31:
    print(1)
elif a in m30 and b == 30:
    print(1)
elif a == 2 and b == 28:
    print(1)
else:
    print(0)
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
        
def lcm(a,b):
    res = int(a/gcd(a,b)*b)
    return res
    

n = int(input())
t = []
for i in range(n):
    t.append(int(input()))

ans=1
for i in range(n):
    ans = lcm(ans,t[i])
    
print(ans)

### FIXED CODE ###

n = int(raw_input())

def gcd(a,b):
    if a > b:
        a,b = b,a
    # a <= b
    while a > 0:
        a,b = b%a, a
    return b

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

x = 1
for i in range(n):
    ti = int(raw_input())
    x = lcm(x, ti)

print x
a,b,c=map(int,open(0).read().split())

if a==b==c and a%2==0:
    print(-1)
else:
    num=0
    while true:
        if a%2==1 or b%2==1 or c%2==1:
            break
        else:
            l=[(b+c)/2,(c+a)/2,(a+b)/2]
            num+=1
            l=[(l[1]+l[2])/2, (l[2]+l[0])/2, (l[0]+l[2])/2]
            a=l[0]
            b=l[1]
            c=l[2]
    else:
        print(num)

### FIXED CODE ###

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

if a==b==c and a%2==0:
    print(-1)
else:
    num=0
    while True:
        if a%2==1 or b%2==1 or c%2==1:
            break
        num+=1
        l0=(b+c)/2
        l1=(c+a)/2
        l2=(a+b)/2
        a,b,c=l0,l1,l2
    print(num)
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect_left

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
A = LIST()
tmp = [0]*40
for a in A:  # tmpに各ビット毎の1の出現回数を保存
    for i in range(39, -1, -1):
        if a&(1<<i):
            tmp[k]+=1
# print(tmp)
a = 0  # K をこえないように管理する
for i in range(39,-1,-1):
	if a + (1<<i) <= K and tmp[i] < (N+1)//2:
		a += (1<<i)

# print(tmp2)

ans = 0
for i in A:
	ans += i^a
print(ans)


### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect_left

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
A = LIST()
tmp = [0]*40
for a in A:  # tmpに各ビット毎の1の出現回数を保存
    for i in range(40):
        if a&(1<<i):
            tmp[i]+=1
# print(tmp)
a = 0  # K をこえないように管理する
for i in range(39,-1,-1):
	if a + (1<<i) <= K and tmp[i] < (N+1)//2:
		a += (1<<i)

# print(tmp2)

ans = 0
for i in A:
	ans += i^a
print(ans)
n,m=map(int,input().split())
if if n*500>=m:
    print("Yes")
else:
    print("No")

### FIXED CODE ###


n,m=map(int,input().split())
print("Yes") if n*500>=m else print("No")
N = int(input())
for i in range(N//4):
    for j in range(N//7):
        if(4*i + 7+j == N):
            print("Yes")
            exit()
print("No")
            

### FIXED CODE ###

N, K = map(int, input().split())
print(-(-N//K) - N//K)
def f_c():
    import math
    a, b, c, d = map(int, input().split())
    c_n = b//c-a//c+1 if a%c==0 else b//c-a//c
    d_n = b//d-a//d+1 if a%d==0 else b//d-a//d
    cd = c*d//math.gcd(c, d)
    cd_n = b//cd-a//cd+1 if a%cd==0 else b//cd-a//cd
    print(b-a+1-(c_n+d_n-cd_n))

if __name__ == "__main__":
    f_c()


### FIXED CODE ###

def f_c():
    import fractions
    a, b, c, d = map(int, input().split())
    c_n = b//c-a//c+1 if a%c==0 else b//c-a//c
    d_n = b//d-a//d+1 if a%d==0 else b//d-a//d
    cd = c*d//fractions.gcd(c, d)
    cd_n = b//cd-a//cd+1 if a%cd==0 else b//cd-a//cd
    print(b-a+1-(c_n+d_n-cd_n))

if __name__ == "__main__":
    f_c()
S,T=input().split()
A,B=map(int,input().split())
U=input()
if U=S:
  print(A-1,B)
else
  print(B,A-1)

### FIXED CODE ###

S,T=input().split()
A,B=map(int,input().split())
U=input()
if U==S:
  print(A-1,B)
else:
  print(A,B-1)
args = str(input())
args = args.split(" ")
a = int(args[0])
b = int(args[1])
k = int(args[2])

turn = 0
for i in range(k):
    if (turn==0):
        if (a>0):
            if (a % 2 == 1):
                a = a - 1
        if (a>0):
            g = a/2
            a = a - g
            b = b + g
        turn=1
    elif (turn==1):
        if (b>0):
            if (b % 2 == 1):
                b = b -1
        if (b>0):
            g = b/2
            b = b - g
            a = a + g
        turn=0

print(int(a),int(b))


### FIXED CODE ###

a = str(input())
if (len(a)==2):
    print(a)
else:
    print(a[::-1])