Harryxun/stf_run huggingface dataset:
# -*- conding:utf-8 -*-
tmp = input().strip().split()
stack = []
for i in tmp:
    l -= 1
    if stack.pop() == "+":
        stack.append(stack.pop() + stack.pop())
    elif stack.pop() == "-":
        stack.append(-stack.pop() + stack.pop())
    elif stack.pop() == "*":
        stack.append(stack.pop() * stack.pop())
    else:
        stack.append(int(i))

print (stack[0])

### FIXED CODE ###

tmp = input().strip().split()
stack = []
for i in tmp:
    if i == '+':
        stack.append(stack.pop() + stack.pop())
    elif i == '-':
        stack.append(-stack.pop() + stack.pop())
    elif i == '*':
        stack.append(stack.pop() * stack.pop())
    else:
        stack.append(int(i))

print (stack[0])
N = 1000001
 
spf = [*range(N)]
i = 2
while i * i < N:
  if spf[i] == i:
    for j in range(i * i, N, i):
      if spf[j] == j:
        spf[j] = i
  i += 1
  
r = 'pairwise'
input()
u = set()
i = None
for x in map(int, input().split()):
  s = set()
  while x > 1:
    p = spf[x]
    if p in u:
      r = 'setwise'
    s.add(p)
    x //= p
  u |= s
  i = (i or s) & s
print('not' if i else r, 'coprime')
N = 1000001
 
spf = [*range(N)]
i = 2
while i * i < N:
  if spf[i] == i:
    for j in range(i * i, N, i):
      if spf[j] == j:
        spf[j] = i
  i += 1
  
r = 'pairwise'
input()
u = set()
i = None
for x in map(int, input().split()):
  s = set()
  while x > 1:
    p = spf[x]
    if p in u:
      r = 'setwise'
    s.add(p)
    x //= p
  u |= s
  i = (i or s) & s
print(('not' if i else r) + ' coprime')


### FIXED CODE ###

N = 1000001
 
spf = [*range(N)]
i = 2
while i * i < N:
  if spf[i] == i:
    for j in range(i * i, N, i):
      if spf[j] == j:
        spf[j] = i
  i += 1
  
r = 'pairwise'
n = int(input())
a = [int(x) for x in input().split() if x > '1']
if len(a) > 1:
  u = set()
  i = None
  for x in a:
    s = set()
    while x > 1:
      p = spf[x]
      if p in u:
        r = 'setwise'
      s.add(p)
      x //= p
    u |= s
    if len(a) == n:
      if i is None: i = s
      else: i &= s
  if i:
    r = 'not'
print(r, 'coprime')
cat atcorder_151_C.py
N, M = map(int, raw_input().split())
#print N, M

state = [-1 for i in range(N)]
pena = [0 for i in range(N)]
WA = [0 for i in range(N)]

for i in range(M):
    s = raw_input().split()
    p = int(s[0])
    sc = s[1]
    #print p, sc
    p -= 1
    if (state[p] == 0):
        continue
    if sc == 'WA':
        pena[p] += 1
    else:
        state[p] = 0

ok = 0
pn = 0
for i in range(N):
    if state[i] == 0:
        ok += 1
        pn += pena[i]

print ok, pn


### FIXED CODE ###

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

state = [-1 for i in range(N)]
pena = [0 for i in range(N)]
WA = [0 for i in range(N)]

for i in range(M):
    s = raw_input().split()
    p = int(s[0])
    sc = s[1]
    #print p, sc
    p -= 1
    if (state[p] == 0):
        continue
    if sc == 'WA':
        pena[p] += 1
    else:
        state[p] = 0

ok = 0
pn = 0
for i in range(N):
    if state[i] == 0:
        ok += 1
        pn += pena[i]

print ok, pn
from math import log2,ceil
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
cnt=defaultdict(lambda :0)

for i in range(n):
    temp=a[i]
    digit=log2(temp)
    for j in range(ceil(digit)+1):
        if (temp>>j)&1:
            cnt[j]+=1

#print(cnt)
ans=0
for digit,count in cnt.items():
    ans+=pow(2,digit)*count*(n-count)
print(ans%mod)

### FIXED CODE ###

import sys
input=sys.stdin.readline
n=int(input())
a=tuple(map(int,input().split()))
mod=10**9+7
cnt=[0]*60

for temp in a:
    if temp==0:continue
    digit=len(bin(temp))-2
    for j in range(digit):
        if (temp>>j)&1:
            cnt[j]=cnt[j]+1

#print(cnt)
ans=0
for i in range(60):
    if cnt[i]==0:continue
    ans=(ans+pow(2,i)*cnt[i]*(n-cnt[i]))%mod
print(ans%mod)
S = list(input())
s = len(S)
K = int(input())
A = []
j = 1

for i in range(0,s-1,1):
  if S[i] == S[i+1]:
    j += 1
  else:
    A.append(j)
    j = 1
A.append(j)

a = len(A)

b = 0
for i in range(0,a,1):
  b += A[i]//2
  
x = b*K

if S[s-1] == S[0] and A[a-1] % 2 == 1 and A[1] % 2 == 1:
  x += K-1

print(b)
print(x)

### FIXED CODE ###

S = list(input())
s = len(S)
K = int(input())
A = []
j = 1

for i in range(0,s-1,1):
  if S[i] == S[i+1]:
    j += 1
  else:
    A.append(j)
    j = 1
A.append(j)

a = len(A)

b = 0
for i in range(0,a,1):
  b += A[i]//2
  
x = b*K

if a == 1:
  x = (s*K)//2
elif S[s-1] == S[0] and A[a-1] % 2 == 1 and A[0] % 2 == 1:
  x += K-1

print(x)
a=int(input)
b=int(input)
c=int(input)
print(a*b*h///2)

### FIXED CODE ###

a=int(input())
b=int(input())
c=int(input())
print((a+b)*c//2)
N,M = map(int,input().split())
AC = 0
WA = 0
lis = [0] * N
for i in range(M):
  a,b = map(input().split())
  if lis[int(a)-1] < 0:
    pass
  elif b == 'AC'
    WA += lis[int(a)-1]
    AC += 1
    lis[int(a)-1] = -1
  else:
    lis[int(a)-1] += 1
print(AC, WA)

### FIXED CODE ###

N,M = map(int,input().split())
AC = 0
WA = 0
lis = [0] * N
for i in range(M):
  a,b = input().split()
  if lis[int(a)-1] < 0:
    pass
  elif b == 'AC':
    WA += lis[int(a)-1]
    AC += 1
    lis[int(a)-1] = -1
  else:
    lis[int(a)-1] += 1
print(AC, WA)
import math
a,b = map(int,input().split())
print(int(a*b/math.gcd(a,b)))

### FIXED CODE ###


def gcd(a,b):
    ma = max(a,b)
    mi = min(a,b)
    while(True):
        los = ma % mi
        ma = mi
        mi = los
        if los == 0:
            result = ma
            break
    return result

a,b = map(int,input().split())
print(a*b//gcd(a,b))
while True :
  x = input()
  if x == '0' :
    break 

  else:
   sum = 0 
   for i  in range(len(x)) :  
   sum += int(x[i])

  print(sum) 

### FIXED CODE ###

while True :
  x = input()
  if x == '0' :
    break 

  else:
   sum = 0 
   for i  in range(len(x)) :  
    sum += int(x[i])

  print(sum)
k = int(input())
s = str(input())
len_s = len(s)
 
if len_s <= k:
  print(s)
else:
  print(''.join([str(x) for x in [s[:k+1], '...']])

### FIXED CODE ###

k = int(input())
s = str(input())
len_s = len(s)
 
if len_s <= k:
  print(s)
else:
  print(s[:k] + '...')
N = int(input())

    if N / sum(int(input())) == 0:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

def f(n):
  return sum(map(int, str(n)))

X = int(input())

if X % f(X) == 0: 
  print("Yes")
else:
  print("No")
N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]

A.sort()
BC.sort(reverse = True, key = lambda x:x[1])
ans = sum(A)
idx = 0

for i in range(M):
    if idx + BC[i][0] >= N :
        BC[i][0] = N-idx
    if A[idx + BC[i][0]] < BC[i][1]:
        ans += BC[i][1] * BC[i][0] - sum(A[idx:idx+BC[i][0]])
    else:
        for j in range(BC[i][0]):
            if A[idx+j] >= BC[i][1]:
                break
        ans += BC[i][1] * j - sum(A[idx:idx + j])
    idx += BC[i][0]
    if idx > N-1:break
print(ans)

            

### FIXED CODE ###

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

A.sort()
BC.sort(reverse = True, key = lambda x:x[1])
ans = sum(A)
idx = 0

for i in range(M):
    if idx + BC[i][0] >= N :
        BC[i][0] = N-idx
    if A[idx + BC[i][0]-1] < BC[i][1]:
        ans += BC[i][1] * BC[i][0] - sum(A[idx:idx+BC[i][0]])
    else:
        for j in range(BC[i][0]):
            if A[idx+j] >= BC[i][1]:
                break
        ans += BC[i][1] * j - sum(A[idx:idx + j])
        break
    idx += BC[i][0]
    if idx > N-1:break
print(ans)
input = -1
cnt = 1
output = []
while input != 0:
	input = input()
	if input == 0:
		break
	output += "Case " + cnt + ": " + input

for x in output:
	print(x)


### FIXED CODE ###

tmp = -1
cnt = 1
output = []
while tmp != 0:
	tmp = int(input())
	if tmp == 0:
		break
	output += ["Case " + str(cnt) + ": " + str(tmp)]
	cnt += 1

for x in output:
	print(x)
N = int(input())
print(len(set([input() for n in range(N)])))

### FIXED CODE ###

print(input().replace('2017', '2018'))
import math
from functools import reduce

def gcd(numbers):
    return reduce(math.gcdm numbers)

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

ans = []

if len(A) == 1:
    ans.append(A[0])
else:
    ans.append(gcd(A[1:]))
    ans.append(gcd(A[:N]))

    for i in range(1, N-1):
        l = []
        l.append(gcd(A[:i]))
        l.append(gcd(A[i+1:]))
        ans.append(gcd(l))

print(max(ans))

### FIXED CODE ###

from math import gcd

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

L = [0] * N
L[0] = A[0]

#配列の左から順番に最大公約数を求める
for i, a in enumerate(A):
    L[i] = gcd(L[max(0, i-1)], a)

# print("L", L)
R = [0] * N
R[0] = A[-1]

#配列の右から順番に最大公約数を求める
for i, a in enumerate(A[::-1]):
    R[i] = gcd(R[max(0, i-1)], a)

# print("R", R)
ans = 0

for i in range(N):
    #一番左の数字を削除
    if i == 0:
        ans = max(ans, R[N-2])
    #一番右の数字を削除
    elif i == N-1:
        ans = max(ans, L[N-2])
    #i+1番目の数字を削除
    else:
        ans = max(ans, gcd(L[i-1], R[N-i-2]))
    
print(ans)
N,K = list(map(int, input().split()))
A = list(map(int, input().split()))
c = [0]*N

idx = 0
stp = 0
while(True):
  stp += 1
  idx = A[idx] - 1
  if c[idx]==0 and idx!=0:
    c[idx] = stp
  else:
    tmp1 = c[idx]
    tmp2 = stp - tmp1
    break
  if stp>=K:
    break

k1 = K - tmp1
k2 = k1%tmp2

for _ in range(k2):
  idx = A[idx] - 1
print(idx+1)

### FIXED CODE ###

N,K = list(map(int, input().split()))
A = list(map(int, input().split()))
c = [0]*N

idx = 0
stp = 0
ans = 0
while(True):
  stp += 1
  idx = A[idx] - 1
  if c[idx]==0 and idx!=0:
    c[idx] = stp
  else:
    tmp1 = c[idx]
    tmp2 = stp - tmp1
    break
  if stp>=K:
    ans = idx + 1
    break

if(ans>0):
  print(ans)
else:
  k1 = K - tmp1
  k2 = k1%tmp2
  for _ in range(k2):
    idx = A[idx] - 1
  print(idx+1)
s, n = map(int,input().split())

a = input()
b = input()
c = input()
ar = [a,b,c]
ar.sort()
result = ''.join(ar)

print(result)

### FIXED CODE ###

a = input()

if (a.count("5") == 2 and a.count("7") == 1):
  print("YES")
  
else:
  print("NO")
n, m, x = map(int, input().split())

A = [[] for _ in range(n)]
c = [0] * n

INF = 10**9
ans = INF

for i in range(n):
  c_as = list(map(int, input().split()))
  c[i], A[i] = c_as[0], c_as[1:]
  
for s in range(0, 1 << n):
  money = 0
  skill = [0] * n
  for i in range(n):
    if(s >> i) % 2 == 0:continue
    money += c[i]
    for j in range(m):
      skill[j] += A[i][j]
  ok = True
  for j in range(m):
    if skill[j] < x:
      ok = False
  if ok:
    ans = min(ans, money)
    
if ans == INF:
  ans = -1
  
print(ans)
      

### FIXED CODE ###

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

A = [[] for _ in range(n)]
c = [0] * n

for i in range(n):
  c_as = list(map(int, input().split()))
  c[i], A[i] = c_as[0], c_as[1:]

INF = 10**9
ans = INF
  
for s in range(0, 1 << n):
  skill = [0] * m
  money = 0
  for i in range(n):
    if(s >> i) % 2 == 0:continue
    money += c[i]
    for j in range(m):
      skill[j] += A[i][j]
  ok = True
  for j in range(m):
    if skill[j] < x:
      ok = False
  if ok:
    ans = min(ans, money)
    
if ans == INF:
  ans = -1
  
print(ans)
import math as m
a,b=list(map(float,input().split()))
print(m.floor(a*(b*1000)/1000))

### FIXED CODE ###

N=int(input())
s=sorted(list(map(int, input().split()))[::-1])
a=1
for i in range(N):
  if a>10**18:
    break
  a*=s[i]
print(-1 if a>10**18 else a)
s=list(map(int,input().stlip())
for i in s:
  if i==0:
     print(i+1)
     exit()
  else:
     pass

### FIXED CODE ###

a=[]
a=input().split()
for i in range(5):
 if a[i]=='0':
   print(str(i+1))
 else:
   pass
print("A" + int()[8] + "C")

### FIXED CODE ###

print("A" + input()[8] + "C")
n,k = map(int,input().split())
a = [0]+list(map(int,input().split()))
b = [1]
c = a[1]
d = 0
length = 0
first = 0
ans = 0

while c not in b:
    b += [c]
    c = a[c]
    d = c

length = len(b)-b.index(d)
first = b.index(d)
ans = b[(k-first)%length+first]
print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
t = [0 for i in range(n+1)]
b = [1]
c = a[1]
d = 0
e=1
length = 0
first = 0
ans = 0


while t[d] < 1:
    t[d]=e
    b += [c]
    c = a[c]
    d = c
    e+=1

if d != 0:
    length = e - t[d]
    first = b.index(d)
if k <= first:
    ans = b[k]
elif d == 0:
    ans = 1
else:
    ans = b[(k - first) % length + first]
print(ans)
n = map(int,raw_input().split())
for i in n
print i,

### FIXED CODE ###

a,b = map(int,raw_input().split())
print ("{0} {1}").format(a*b,2*a+2*b)
hi = list(map(int, input().split()))
hi.sort(reverse=True)
del hi[:k]

num = 0
if hi == []:
    print(0)
else:
    for i in hi:
        num += i
    print(num)


### FIXED CODE ###

import sys

sys.setrecursionlimit(10**9)

h, k = map(int, input().split())
hi = list(map(int, input().split()))
hi.sort(reverse=True)
del hi[:k]

num = 0
if hi == []:
    print(0)
else:
    for i in hi:
        num += i
    print(num)
import sys
mod = pow(10, 9) + 7
def C(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
NNN = (10**6)
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range(2, NNN+1):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
n,m,k=map(int,input().split())
#n=m=k=2
print(C(n*m,k)*C(k,2)%mod*(n+m)*inverse[3]%mod)

### FIXED CODE ###

N, W = map(int, input().split())
if N >=13:
  print(W)
elif N >=6:
  print(W//2)
else:
  print(0)
a,b,c,d=map(int,input().split())
x=(a+d-1)/d
y=(c+b-1)/c
 
if x>=y:
  print("yes")
else:
  print("no")

### FIXED CODE ###

s,w=map(int,input().split())
if s <= w:
    print("unsafe")
else:
    print("safe")
#初見じゃ無理だった。DPを使う
#標準入力
import numpy as np
H, N = map(int, input().split())
AB = []
max_A = 0
for i in range(N):
    ab = list(map(int, input().split()))
    if max_A < ab[0] :
        max_A = ab[0]
    AB.append(ab)

 #DP
DP = [0] * (H + max_A)
for i in range(1, H + max_A ): #DP[i] の最小値を求めていく
    tmp_mini = 10 ** 8
    for j in range(N):
        if i - AB[j][0] >= 0:
            tmp = DP[i - AB[j][0]] + AB[j][1]
            if tmp_mini > tmp:
                tmp_mini = tmp
    DP[i] = tmp_mini
print(min(DP[H: H + max_A]))

### FIXED CODE ###

#初見じゃ無理だった。DPを使う
#標準入力
import math
H, N = map(int, input().split())
AB = []
max_A = 0
for i in range(N):
    ab = list(map(int, input().split()))
    if max_A < ab[0] :
        max_A = ab[0]
    AB.append(ab)

 #DP
DP = [0] * (H + max_A)
for i in range(1, H + max_A ): #DP[i] の最小値を求めていく
    tmp_mini = 10 ** 8
    for j in range(N):
        if i - AB[j][0] >= 0:
            tmp = DP[i - AB[j][0]] + AB[j][1]
            if tmp_mini > tmp:
                tmp_mini = tmp
    DP[i] = tmp_mini
print(min(DP[H: H + max_A]))
"""from operator import mul
from functools import reduce
 
def cmb(n,r):
  if n<2: return 0
  r = min(n-r,r)
  over = reduce(mul, range(n, n - r, -1))
  under = reduce(mul, range(1,r + 1))
  return over // under
"""
from math import factorial
def cmb(n,r=2):
  
  return factorial(n) / factorial(r) / factorial(n - r)
 
 
N=int(input())
a_lis=list(map(int,input().split()))
 
olt={i:0 for i in set(a_lis)}
for i in a_lis:
  olt[i]+=1
#print(olt)
for j in range(N):
  index=a_lis[j]
  olt[index]-=1
  #print(olt)
  san=0
  for i in set(a_lis):
    if olt[i] <2:
      continue
    #print(i,olt[i])
    san+=cmb(olt[i])
  
  print(int(san))
  olt[index]+=1

### FIXED CODE ###

def combi(count):
  if n==1:return 0
  elif n==2:return 1
  else:return int(count*(count-1)/2)
 
 
n=int(input())
alis=list(map(int,input().split()))
dick={st:0 for st in set(alis)}
for i in range(n):
  p=alis[i]
  dick[p]+=1
#print(dick)
point=0
for v in dick.values():
  point+=combi(v)
 
 
for i in range(n):
  idx=alis[i]
  minus=dick[idx]-1
  print(point-minus)
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def baisu(x,a):
    return int(x//a)
a,b,c,d = map(int,input().split())

to_a = a - baisu(a,c) - baisu(a,d) + baisu(a,c*d/gcd(c,d))
to_b = b - baisu(b,c) - baisu(b,d) + baisu(b,c*d/gcd(c,d))



if a%c == 0 or a%d == 0:
    print(int(to_b - to_a))
else:
    print(int(to_b-to_a+1))


### FIXED CODE ###

s = input()
count= 0

for i in range(3):
    if s[i] == s[i+1]:
        count += 1
    else:
        pass
if count>0:
    print("Bad")
else:
    print("Good")
a,b,n = map(int,input().split()) 

ans=[]

for i in range(B):
    
    ans.append(int(a*i/b) - a * int(i/b))

print(min(ans))

### FIXED CODE ###

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

x=min(n,b-1)

ans = (int(a*x/b) - a * int(x/b))

print(ans)
n = int(input())
q = list(map(int,input().split()))
alm = 0
for i in q:
  ans = []
  if i%2 == 0:
    ans.append(i)
  	if ans[0]%3 != 0 or ans[0]%5 != 0:
    	print("DENIED")
        exit()
    ans.pop(0)

print("APPROVED")
  

### FIXED CODE ###

n = int(input())
q = list(map(int,input().split()))
ans = 0
count = 0
for i in q:
    if i%2 == 0:
        alm = i
        count += 1
        if alm%3 == 0 or alm%5 == 0:
            ans += 1
if ans == count:
    print("APPROVED")
else:
    print("DENIED")
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**15
mod = 10**9+7

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 S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a,b,c,d = I()
    if abs(a-c) <= d or (abs(a-b) <= d and abs(b-c) <= d):
        return 'Yes'

    return 'No'



print(main())



### 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**15
mod = 10**9+7

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 S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a,b,c,d = LI()
    if abs(a-c) <= d or (abs(a-b) <= d and abs(b-c) <= d):
        return 'Yes'

    return 'No'



print(main())
= int(input())
s = list(input())
cnt1 = 0
for i in range(n-1):
    if s[i] == '#' and s[i+1] == '.':
        cnt += 1
        s[i+1] = '#'

cnt2 = 0
for i in range(n-1):
    if s[i] == '#' and s[i+1] == '.':
        cnt2 += 1
        s[i+1] = '.'


print(min(cnt1, cnt2))

### FIXED CODE ###

n = int(input())
s = input()
x = 0
y = s.count('.')
c = min(n-y, y)
for i in range(n):
    t = s[i] == '#' #＃であればｔがTrueになる
    x += t
    y -= 1 - t
    c = min(c, x+y)
print(c)
N = int(input())
e = [ [] for i in range(N+1)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    e[u].append((v,w))
    e[v].append((u,w))

col = [ -1 for i in range(N+1)]

def dfs(x,c):
    col[x] = c
    for v,w in e[x]:
        if col[v] == -1:
            dfs(v , c+w)

dfs(1,0)

for i in range(1,N+1):
    if col[i] % 2 == 0:
        print(0)
    else:
        print(1)


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
N = int(input())
e = [ [] for i in range(N+1)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    e[u].append((v,w))
    e[v].append((u,w))

col = [ -1 for i in range(N+1)]

def dfs(x,c):
    col[x] = c
    for v,w in e[x]:
        if col[v] == -1:
            dfs(v , c+w)

dfs(1,0)



for i in range(1,N+1):
    print(col[i] % 2)
i = list(map(int,input().split()))
a = i[0]+i[1]
b = i[0]+i[2]
c = i[1]+i[2]
d = list(a,b,c)
print(min(d))

### FIXED CODE ###

i = list(map(int,input().split()))
a = i[0]+i[1]
b = i[0]+i[2]
c = i[1]+i[2]
d = [a,b,c]
print(min(d))
def abc098_b():
    import numpy as np
    n = int(input())
    s = input()
    counts = []
    for i in range(1, n - 1):
        x = s[:i]
        y = s[i:]
        count = 0
        for let in set(x):
            if let in set(y):
                count += 1
        counts.append(count)
    return np.max(counts)


print(abc098_b())

### FIXED CODE ###

def abc098_b():
    import numpy as np
    n = int(input())
    s = input()
    counts = []
    if len(s) == 2:
        return [0,1][s[0] == s[1]]
    for i in range(1, n - 1):
        x = s[:i]
        y = s[i:]
        count = 0
        for let in set(x):
            if let in set(y):
                count += 1
        counts.append(count)
    return np.max(counts)


print(abc098_b())
import sys
from heapq import*
def g(s,g):
 F=[1e7]*-~n;F[s]=0
 H=[(0,s)]
 while H:
  c,u=heappop(H)
  if u==g:return c
  for f,v in E[u]:
   t=c+f
   if t<F[v]:
    F[v]=t
    heappush(H,(t,v))
 return-1
for e in iter(input,'0 0'):
 n,k=map(int,e.split())
 E=[[]for _ in[0]*-~n]
 for _ in[0]*k:
  f=input()
  if f[0]:
   c,d,e=map(int,f[2;].split())
   E[c]+=[(e,d)];E[d]+=[(e,c)]
  else:print(g(map(int,f[2:].split())))


### FIXED CODE ###

def s():
 import sys
 r=sys.stdin.readline
 I=float('inf')
 for e in iter(r,'0 0\n'):
  n,k=map(int,e.split())
  F=[[I]*-~n for _ in[0]*-~n]
  for i in range(1,n+1):F[i][i]=0
  for _ in[0]*k:
   f=r();g=map(int,f[2:].split())
   if'0'==f[0]:a,b=g;A=F[a][b];print([A,-1][A==I])
   else:
    c,d,e=g
    if e<F[c][d]:
     for i in range(2,n+1):
      for j in range(1,i):
       F[i][j]=F[j][i]=min(F[i][j],F[i][c]+e+F[d][j],F[i][d]+e+F[c][j])
s()
import sys
sys.setrecursionlimit(10 ** 9)
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

# if a>=b or w>=v:
#     print('NO')
#     sys.exit()
for tt in range(1,t+1):
    res = (w - v) * tt + (b - a)
    if res == 0:
        print('YES')
        sys.exit()

print('NO')

### FIXED CODE ###

s = str(input())
a = s[:3]
print(a)
import math
r = int(input())
print("{0:.6f} {1:.6f}".format(math.pi * r ** 2, 2* math.pi * r))

### FIXED CODE ###

import math
r = float(input())
print("{0:.6f} {1:.6f}".format(math.pi * r ** 2, 2* math.pi * r))
import sys
input = sys.stdin.readline
n = innt(input())
chk = []
for i in range(n):
  a = input()
  chk.append(a)
chk.sort()
if n%2 == 0:
  l = [i*2 for i in chk[:n//2]]
  r = [i*2 for i in chk[n//2:]]
  print(sum(r)-sum(l)+chk[n//2-1]-chk[n//2])
else:
  l = [i*2 for i in chk[:(n-1)//2]]
  r = [i*2 for i in chk[(n-1)//2+1:]]
  print(max(sum(r)-sum(l)+chk[(n-1)//2-1]-chk[(n-1)//2]),(sum(r)-sum(l)+chk[(n-1)//2]-chk[(n-1)//2+1]))

### FIXED CODE ###

import sys
input = sys.stdin.readline
n = int(input())
chk = []
for i in range(n):
  a = int(input())
  chk.append(a)
chk.sort()
if n%2 == 0:
  l = [i*2 for i in chk[:n//2]]
  r = [i*2 for i in chk[n//2:]]
  print(sum(r)-sum(l)+chk[n//2-1]-chk[n//2])
else:
  l = [i*2 for i in chk[:(n-1)//2]]
  r = [i*2 for i in chk[(n-1)//2+1:]]
  p = sum(r)-sum(l)+chk[(n-1)//2-1]-chk[(n-1)//2]
  q = sum(r)-sum(l)+chk[(n-1)//2]-chk[(n-1)//2+1]
  print(max(p,q))
n = int(input())
p = map(int, input().split())
l = []
for i in range(1, n + 1):
    if i != p[i - 1]:
        l.append(i)
if len(l) == 2:
    print("YES")
else:
    print("NO")
        

### FIXED CODE ###

n = int(input())
p = list(map(int, input().split()))
l = []
for i in range(1, n + 1):
    if i != p[i - 1]:
        l.append(i)
if len(l) <= 2:
    print("YES")
else:
    print("NO")
merry=[4,1,4,1,2,1,2,1]
while True:
    try:
        gst=map(int,raw_input().split())
    except EOFError:
        break
    m=10000
    ans=set()
    for i in range(len(merry)):
        temp=merry[i:]+merry[:i]
        s=sum([max(gst[i]-temp[i],0) for i in range(len(merry))])
        if s==m:
            ans.add("".join(map(str,temp)))
        elif s<m:
            m=s
            ans.clear()
            ans.add("".join(map(str,temp)))
    print " ".join(min(ans))

### FIXED CODE ###

c=[4,1,4,1,2,1,2,1]
while True:
    try:
        p=map(int,raw_input().split())
    except EOFError:
        break
    m,ans=100000000,"9"*10
    for i in range(len(c)):
        t=c[i:]+c[:i]
        s=sum([p[i]-t[i] for i in range(len(c)) if p[i]>t[i]])
        if (s<m) or (s==m and int(ans)>int("".join(map(str,t)))):
            m=s
            ans="".join(map(str,t))
    print " ".join(ans)