Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
#D問題
N = int(input())

if N%4 == 0:
    print("No")
elif N%2 == 0:
    n = N//4 + 2
    nn = 2*n - 1
    M = N-(2*n-1)
    m = M//2
    print("Yes")
    print(n+1)
    print(n,end=" ")
    for i in range(n):
        print(i+1,end=" ")
    print()
    print(n,end=" ")
    for i in range(n):
        print(i+n,end=" ")
        
    S = [[] for i in range(m+2)]
    for i in range(m+1):
        S[0].append(nn+i+1)
    for i in range(m+1):
        S[1].append(nn+i+1+m)
    for i in range(m):
        S[i+2].append(nn+i+1); S[i+2].append(nn+m+i+2)
        
    for i in range(n-1):
        print()
        print(2+len(S[i]),end=" ")
        print(i+1,i+n+1,end=" ")
        for s in S[i]:
            print(s,end=" ")
    
else:
    print("Yes")
    n = N//2
    print(n+2)
    print(n+1,end=" ")
    for i in range(n+1):
        print(i+1,end=" ")
    print()
    print(n+1,end=" ")
    for i in range(n+1):
        print(n+i+1,end=" ")
    print()
    for i in range(n):
        print(2,end=" ")
        print(i+1,n+i+2)


# Example run
# Input:
1
# Output:
Yes
2
1 1 
1 1
n=int(input())
count=1
index=1
while count<n:
  index+=1
  count+=index
if count!=n:
  print("No")
elif n==1:
  print("Yes")
  print(2)
  print("1 1")
  print("1 1")
else:
  print("Yes")
  print(index+1)
  l=[]
  now=1
  num=1
  while now<n:
    l.append(now)
    now+=num
    num+=1
  for i in range(index):
    l1=[str(index)]
    l1.append(str(l[i]))
    num=l[i]
    count1=0
    while count1<i:
      num+=1
      count1+=1
      l1.append(str(num))
    for j in range(1+i,index):
      num+=j
      l1.append(str(num))
    print(" ".join(l1))
  l1=[str(index),str(l[0])]
  num=0
  for j in range(2,index+1):
    num+=j
    l1.append(str(l[0]+num))
  print(" ".join(l1))


# Example run
# Input:
-3
# Output:
No
N = int(input())

ss = [[1], [1]]
n = 2

for i in range(1, N):
    l = i + 1
    ss = [ss[i] + [n + i] for i in range(l)]
    ss += [[n + i for i in range(l)]]
    n += l
    if n - 1 >= N:
        break

if n - 1 == N:
    print("Yes")
    print(len(ss))
    for r in ss:
        print(len(r), *r)
else:
    print("No")


# Example run
# Input:
0
# Output:
No
import math
def p(a):
    b,c,i=range(2,int(10+2*math.log(a)*a)),[],0
    while len(c)!=a:
        c.append(b[0])
        b=[i for i in b[1:] if i%b[0]!=0]
    return sum(c)
a=map(int,input().split())
for i in a:
    if i!=0:
        print(str(p(i)))
    else:
        break

# Example run
# Input:
815
# Output:
2371102
n = int(input())
for i in range(n):
  print('nan')

# Example run
# Input:
-41270
# Output:
N = input()
print(int(N[0])-1+9*(len(N)-1))


# Example run
# Input:
4M>w'<6/6
# Output:
75
MIS = lambda: map(int,input().split())
from math import acos

def ccw(p1, p2, p3):
    # positive -> ccw; negative -> cw; 0 -> collinear
    return (p2[0]-p1[0])*(p3[1]-p1[1]) - (p2[1]-p1[1])*(p3[0]-p1[0])

def ConvexHull(p):
    U = []; L = []; p.sort()
    for q in p:
        while len(U)>1 and ccw(U[-2], U[-1], q) >= 0: U.pop()
        while len(L)>1 and ccw(L[-2], L[-1], q) <= 0: L.pop()
        U.append(q); L.append(q)
    return U + L[-2:0:-1]

def angle(v1, v2):
    inner = v1[0]*v2[0] + v1[1]*v2[1]
    v1s = (v1[0]**2 + v1[1]**2) ** .5
    v2s = (v2[0]**2 + v2[1]**2) ** .5
    return acos(inner / v1s / v2s)

n = int(input())
if n == 1: print(1); exit()
if n == 2: print(0.5); print(0.5); exit()

p = [tuple(MIS())+(i,) for i in range(n)]
CH = ConvexHull(p)
bsc = []
for i in range(len(CH)):
    x1, y1, i1 = CH[i]
    x2, y2, i2 = CH[i-1]
    bsc.append((y1-y2, x2-x1))
if len(CH) == 2: angles = [1, 1]
else: angles = [angle(bsc[i], bsc[i-1]) for i in range(len(CH))]
S = sum(angles)

ans = [0] * n
for i in range(len(CH)):
    x, y, ind = CH[i-1]
    ans[ind] = angles[i] / S
for x in ans: print(x)

# Example run
# Input:
-3
# Output:
a=list(map(int, input().split()))
print(min(a),max(a))


# Example run
# Input:
-74186
# Output:
-74186 -74186
abc = [int(x) for x in input().split()]

print(min(abc), max(abc))



# Example run
# Input:
-1138
# Output:
-1138 -1138
a=list(map(int, input().split()))
print(min(a),max(a))


# Example run
# Input:
-5654
# Output:
-5654 -5654
l = list(map(int, input().split()))
print(min(l),max(l))


# Example run
# Input:
-2046600
# Output:
-2046600 -2046600
a = list(map(int,input().split()))
print(min(a),max(a))


# Example run
# Input:
2657144
# Output:
2657144 2657144
abc = [int(x) for x in input().split()]
 
print(min(abc), max(abc))


# Example run
# Input:
38254
# Output:
38254 38254
# AOJ ITP2_3_A: Min-Max
# Python3 2018.6.24 bal4u

a = list(map(int, input().split()))
print(min(a), max(a))


# Example run
# Input:
55
# Output:
55 55
a=list(map(int, input().split()))
print(min(a),max(a))


# Example run
# Input:
332
# Output:
332 332
a=[int(i) for i in input().split()]
print(min(a),max(a))


# Example run
# Input:
36241
# Output:
36241 36241
l = list(map(int,(input().split())))


print(f'{min(l)} {max(l)}')


# Example run
# Input:
1
# Output:
1 1
l = [int(x) for x in input().split()]
print("{} {}".format(min(l),max(l)))


# Example run
# Input:
94838
# Output:
94838 94838
n = list(map(int,input().split()))
print(min(n),max(n))


# Example run
# Input:
-147113079
# Output:
-147113079 -147113079
if __name__ == "__main__":

    param = input().split(" ")

    seq = [ int(a) for a in param]

    min = min(seq)
    max = max(seq)

    print(str(min) + " " + str(max))



# Example run
# Input:
1169288485
# Output:
1169288485 1169288485
a=list(map(int, input().split()))
print(min(a),max(a))


# Example run
# Input:
-56446
# Output:
-56446 -56446
a = list(map(int, input().split()))
print(min(a), max(a))



# Example run
# Input:
542366274
# Output:
542366274 542366274
A = list(map(int, input().split()))
print(min(A), max(A))



# Example run
# Input:
-255155
# Output:
-255155 -255155
nums = list(map(int, input().split(' ')))

max = -float('inf')
min = float('inf')
for num in nums:
    if num > max: max = num
    if num < min: min = num

print(min, max)



# Example run
# Input:
14865
# Output:
14865 14865
a = list(map(int,input().split()))
print("%d %d"%(min(a),max(a)))


# Example run
# Input:
-1799682701
# Output:
-1799682701 -1799682701
def main():
    n = list(map(int,input().split()))
    print (min(n),max(n))


if __name__ == '__main__':
    main()




# Example run
# Input:
116
# Output:
116 116
num=list(map(int,input().split()))
print(str(min(num))+" "+str(max(num)))



# Example run
# Input:
-1
# Output:
-1 -1
A = list(map(int,input().split()))
print(min(A),max(A))


# Example run
# Input:
1686
# Output:
1686 1686
a=list(map(int,input().split()))

print(min(a),max(a))


# Example run
# Input:
1
# Output:
1 1
A = [int(a) for a in input().split()]
print(min(A), max(A))


# Example run
# Input:
655579180
# Output:
655579180 655579180
a = list(map(int, input().split()))
print(min(a), end = " ")
print(max(a))


# Example run
# Input:
-4107400
# Output:
-4107400 -4107400
a=list(map(int,input().split()))

max=a[0]
min=a[0]

for i in range(1,len(a)):
    if max<a[i]:
        max=a[i]
    if min>a[i]:
        min=a[i]

print(str(min)+" "+str(max))


# Example run
# Input:
-307342969
# Output:
-307342969 -307342969
if __name__ == "__main__":
    numbers = list(map(lambda x: int(x), input().split()))
    min_num = min(numbers)
    max_num = max(numbers)
    print(f"{min_num} {max_num}")



# Example run
# Input:
-293149433
# Output:
-293149433 -293149433
num = list(map(int, input().split()))
print(min(num), max(num))


# Example run
# Input:
981571
# Output:
981571 981571
a = list(map(int, input().split()))
print(min(a), max(a))



# Example run
# Input:
1525741
# Output:
1525741 1525741
# coding=utf-8

A = list(map(int, input().split()))
print("{0} {1}".format(min(A), max(A)))



# Example run
# Input:
4743227
# Output:
4743227 4743227
ary = list(map(int, input().split(' ')))
print(min(ary), max(ary))



# Example run
# Input:
-163
# Output:
-163 -163
# -*- coding: utf-8 -*-
"""
Basic Operations - Min-Max
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_3_A&lang=jp

"""
res = sorted(map(int, input().split()))
print(res[0], res[-1])



# Example run
# Input:
-1839
# Output:
-1839 -1839
a=list(map(int,input().split()))
print("{} {}".format(min(a),max(a)))


# Example run
# Input:
57961
# Output:
57961 57961
def resolve():
    A = [int(i) for i in input().split()]
    print(min(A), max(A))


resolve()



# Example run
# Input:
-22
# Output:
-22 -22
numbers = list(map(int, input().split()))
print(str(min(numbers))+" "+str(max(numbers)))



# Example run
# Input:
648948451
# Output:
648948451 648948451
list_num = list(map(int, input().split()))

print(min(list_num), max(list_num))



# Example run
# Input:
5330
# Output:
5330 5330
a = list(map(int,input().split()))
print(str(min(a)) + " " + str(max(a)))


# Example run
# Input:
-16
# Output:
-16 -16
a = list(map(int, input().split()))
print(min(a), max(a))


# Example run
# Input:
-150069
# Output:
-150069 -150069
a = list(map(int, input().split()))
print('%d %d' % (min(a), max(a)))


# Example run
# Input:
-755
# Output:
-755 -755
a = list(map(int, input().split()))
print(min(a), max(a))


# Example run
# Input:
-1
# Output:
-1 -1
a = list(map(int, input().split()))
print(min(a), max(a))


# Example run
# Input:
-73
# Output:
-73 -73
a = list(map(int, input().split()))
print(min(a), max(a))



# Example run
# Input:
-5701370
# Output:
-5701370 -5701370
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	min_max
# CreatedDate:  2020-05-24 15:21:55 +0900
# LastModified: 2020-05-24 15:22:54 +0900
#


import os
import sys

def main():
    a = list(map(int,input().split()))
    print("{} {}".format(min(a),max(a)))

    


if __name__ == "__main__":
    main()



# Example run
# Input:
19928
# Output:
19928 19928
a = list(map(int,input().split()))
print(min(a),max(a))


# Example run
# Input:
-58138
# Output:
-58138 -58138
temp = list(map(int, input().split()))
print(min(temp), max(temp))


# Example run
# Input:
3986
# Output:
3986 3986
S = list(map(int,input().split()))

print("{} {}".format(min(S),max(S)))


# Example run
# Input:
141725276
# Output:
141725276 141725276
inp = list(map(int, input().split()))
print("{} {}".format(min(inp), max(inp)))


# Example run
# Input:
5507
# Output:
5507 5507
li = [int(i) for i in input().split()]
print(min(li), max(li))


# Example run
# Input:
-241292
# Output:
-241292 -241292
num = list(map(int, input().split()))
print(min(num), max(num))


# Example run
# Input:
0
# Output:
0 0
nums = list(map(int, input().split()))
print(min(nums), max(nums))


# Example run
# Input:
68
# Output:
68 68
a= list(map(int, input().split()))
print('{} {}'.format(min(a), max(a)))


# Example run
# Input:
-1140169349
# Output:
-1140169349 -1140169349
arr = [*map(int, input().split())]
print(min(arr), max(arr))


# Example run
# Input:
26445607
# Output:
26445607 26445607
l=list(map(int,input().split()))
print(min(l),max(l))


# Example run
# Input:
-65934
# Output:
-65934 -65934
*A, = map(int, input().split())
A.sort()
print(A[0], A[-1])


# Example run
# Input:
17147623
# Output:
17147623 17147623
a = sorted(list(map(int,input().split())))
print(a[0],a[-1])


# Example run
# Input:
981571
# Output:
981571 981571
x = list(map(int,input().split()))
print(min(x),max(x))


# Example run
# Input:
-2610757
# Output:
-2610757 -2610757
abc = [int(x) for x in input().split()]
 
print(min(abc), max(abc))


# Example run
# Input:
-1140169349
# Output:
-1140169349 -1140169349
nums = list(map(int, input().split()))
print(min(nums), max(nums))


# Example run
# Input:
633744878
# Output:
633744878 633744878
S = input()
n= int(input())

for i in range(n):
  Q = [i for i in input().split()]
  if Q[0] =='1':
    S = S[::-1]
    #print(S)
  else:
    if Q[1]=='1':
      S = Q[2]+S
    else:
      S =S+Q[2]
    #print(S)
print(S)

# Example run
# Input:
NxW
-8164991
# Output:
NxW
from collections import deque
s = input()
q = int(input())
flag = True
atama = deque()
osiri = deque()
for i in range(q):
    inp = input()
    if inp == '1':
        flag = not flag

    else:
        _, f, c = map(str, inp.split())
        if f == '1':
            if flag:
                atama.appendleft(c)
            else:
                osiri.append(c)
        else:
            if flag:
                osiri.append(c)
            else:
                atama.appendleft(c)

if flag:
    while(atama):
        tmp = atama.popleft()
        print(tmp, end='')
    print(s, end='')
    while(osiri):
        tmp = osiri.popleft()
        print(tmp, end='')
else:
    while(osiri):
        tmp = osiri.pop()
        print(tmp, end='')
    print(s[::-1], end='')
    while(atama):
        tmp = atama.pop()
        print(tmp, end='')


# Example run
# Input:
ET:$eN,o
-7315831
# Output:
ET:$eN,
import collections

s = input()
q = int(input())
rev = 0
ans = collections.deque(['S'])

for _ in range(q):
  query = list(input().split())
  if int(query[0]) == 1:
    rev += 1
  else:
    if int(query[1]) == 1:      # 先頭
      if rev%2 == 0:
        ans.appendleft(query[2])
      else:
        ans.append(query[2])
    else:                       # 末尾
      if rev%2 == 0:
        ans.append(query[2])
      else:
        ans.appendleft(query[2])

ans = ''.join(ans)
mes = ans.replace("S", s)
if rev%2 == 0:
  print(mes)
else:
  print(mes[::-1])



# Example run
# Input:
|@`(
-18231
# Output:
|@`(
S = input()
Q = int(input())
QUERY = []
for i in range(Q):
    # q = list(map(int, input().split()))
    q = input().split()
    if q[0] == '1':
        QUERY.append([int(q[0])])
    else:
        QUERY.append([int(q[0]), int(q[1]), q[2]])

st = []
en = []
rev = False
rev_c = 0
for q in QUERY:
    if q[0] == 1:
        if rev:
            rev = False
        else:
            rev = True
        rev_c += 1
    else:
        if q[1] == 1:
            if not rev:
                st.append(q[2])
            else:
                en.append(q[2])
        else:
            if not rev:
                en.append(q[2])
            else:
                st.append(q[2])

# print(st)
# print(en)

st_s = "".join(st)
st_s = st_s[::-1]
en_s = "".join(en)

ans = st_s + S + en_s
if rev_c % 2 == 0:
    pass
else:
    ans = ans[::-1]

print(ans)

# Example run
# Input:
2.#lfK|@
-4190
# Output:
2.#lfK|@
# coding: utf-8

S = input()
Q = int(input())

query = []

for i in range(Q):
    query.append(input().split())


bool = True
pre =''
suf =''

for i in query:
    if len(i) == 1:
        bool = not bool

    else:
        if i[1]=="1":
            if bool:
                pre = i[2]+pre
            else:
                suf += i[2]
        else:
            if bool:
                suf += i[2]
            else:
                pre = i[2]+pre

S = pre+ S +suf
print(S) if bool else print(S[::-1])


# Example run
# Input:
N3*zs
-421815818
# Output:
N3*zs
s = input()
q = int(input())

r = 0
sort = 0
for i in range(q):
  List=list(input().split())
  if len(List) > 1 :
    if List[1] == '1' and r == 0 :
      s = s + List[2] 
    elif List[1] == '1' and r == 1 :
      s = List[2] + s 
    elif List[1] == '2' and r == 0 :
      s = List[2] + s 
    elif List[1] == '2' and r == 1 :
      s = s + List[2] 
    r = 0
  else:
    if r == 1 :
      r=0
    else:
      r=1
  if i == q-1 and len(List) == 1 :
    sort = 1


ans = ''
if sort == 0:
  print(s)
else:
  for j in range(len(s)):
    ans += s[len(s)-j-1:len(s)-j]

print(ans)





# Example run
# Input:
xgI8vLA
-81206326
# Output:
xgI8vLA
a = input()
b = input()
c = input()


def stack2(a, b):
    max_reduce = min(len(a), len(b))
    reduce = 0
    stacked = a + b
    for i in reversed(range(max_reduce)):
        a_end = a[len(a)-i-1:]
        b_begin = b[:i+1]
        flag = True
        for j in range(len(a_end)):
            if a_end[j] != b_begin[j] and a_end[j] != '?' and b_begin[j] != '?':
                flag = False
                break
        if flag == True:
            reduce = len(a_end)
            a_begin = a[:len(a) - i - 1]
            b_end = b[i+1:]
            mid = ''
            for k in range(i+1):
                if a_end[k] != '?':
                    letter = a_end[k]
                else:
                    letter = b_begin[k]
                mid = mid + letter
            stacked = a_begin + mid + b_end
            break
    return stacked, reduce

S = len(a) + len(b) + len(c)

r1 = stack2(a, b)[1] + stack2(stack2(a, b)[0], c)[1]
r2 = stack2(a, c)[1] + stack2(stack2(a, c)[0], b)[1]
r3 = stack2(b, a)[1] + stack2(stack2(b, a)[0], c)[1]
r4 = stack2(b, c)[1] + stack2(stack2(b, c)[0], a)[1]
r5 = stack2(c, a)[1] + stack2(stack2(c, a)[0], b)[1]
r6 = stack2(c, b)[1] + stack2(stack2(c, b)[0], a)[1]

r = max(r1, r2, r3, r4, r5, r6)

print(S-r)


# Example run
# Input:
#*\J
O5T
true
# Output:
11
S = list(input())
Q = int(input())

flag = True

for i in range(Q):
    q = list(map(str, input().split()))
    if len(q) == 1:
        flag = not flag
    else:
        if (q[1] == '1' and flag == True) or (q[1] == '2' and flag == False):
            S.insert(0, q[2])
        else:
            S.append(q[2])

if flag == True:
    print(*S, sep="")
else:
    S.reverse()
    print(*S, sep="")

# Example run
# Input:
/F!
0
# Output:
/F!
s = input()
q = int(input())

query = [""]*q
f = [""]*q
c = [""]*q

for i in range(q):
    query[i] = input()
    if query[i]=="1":
        s = s[::-1]
    else:
        r = query[i].split()
        if r[1]=="1":
            s = r[2]+s
        elif r[1]=="2":
            s += r[2]

print(s)

# Example run
# Input:
9\60Qh=t8
0
# Output:
9\60Qh=t8
a = input()
b = input()
c = input()


def stack2(a, b):
    max_reduce = min(len(a), len(b))
    reduce = 0
    stacked = a + b
    for i in reversed(range(max_reduce)):
        a_end = a[len(a)-i-1:]
        b_begin = b[:i+1]
        flag = True
        for j in range(len(a_end)):
            if a_end[j] != b_begin[j] and a_end[j] != '?' and b_begin[j] != '?':
                flag = False
                break
        if flag == True:
            reduce = len(a_end)
            a_begin = a[:len(a) - i - 1]
            b_end = b[i+1:]
            mid = ''
            for k in range(i+1):
                if a_end[k] != '?':
                    letter = a_end[k]
                else:
                    letter = b_begin[k]
                mid = mid + letter
            stacked = a_begin + mid + b_end
            break
    return stacked, reduce

S = len(a) + len(b) + len(c)

r1 = stack2(a, b)[1] + stack2(stack2(a, b)[0], c)[1]
r2 = stack2(a, c)[1] + stack2(stack2(a, c)[0], b)[1]
r3 = stack2(b, a)[1] + stack2(stack2(b, a)[0], c)[1]
r4 = stack2(b, c)[1] + stack2(stack2(b, c)[0], a)[1]
r5 = stack2(c, a)[1] + stack2(stack2(c, a)[0], b)[1]
r6 = stack2(c, b)[1] + stack2(stack2(c, b)[0], a)[1]

r = max(r1, r2, r3, r4, r5, r6)

print(S-r)

# Example run
# Input:
54h
GY%Wj:$h
false
# Output:
16
from collections import deque

s=input()
q=int(input())

t=deque(s)
reverse=False

for i in range(q):
  query=input()
  if query[0]=='1':
    reverse=not reverse
  elif query[0]=='2':
    i,f,c=query.split()
    if f=='1':
      if reverse:
        t.append(c)
      else:
        t.appendleft(c)
    elif f=='2':
      if reverse:
        t.appendleft(c)
      else:
        t.append(c)
result=''.join(t)
if reverse:
  result=result[::-1]
print(result)

# Example run
# Input:
2.)t.
0
# Output:
2.)t.
import heapq
from collections import Counter


class HuffmanTreeNode:
    def __init__(self, char, freq):
        self.char = char
        self.freq = freq
        self.left = None
        self.right = None
    
    def __lt__(self, other):
        return self.freq < other.freq


def huffman_code_helper(root, code='', codes={}):
    if not root:
        return codes
    
    if not root.left and not root.right:
        codes[root.char] = code if code else '0'
        return codes
    
    huffman_code_helper(root.left, code + '0', codes)
    huffman_code_helper(root.right, code + '1', codes)
    return codes


def huffman_code(text):
    counter = Counter(text)
    heap = []
    for char, freq in counter.items():
        heap.append(HuffmanTreeNode(char, freq))
    heapq.heapify(heap)

    while len(heap) > 1:
        left, right = heapq.heappop(heap), heapq.heappop(heap)
        node = HuffmanTreeNode('', left.freq + right.freq)
        node.left, node.right = left, right
        heapq.heappush(heap, node)
    root = heap[0]

    return huffman_code_helper(root)


def solution():
    text = input()
    codes = huffman_code(text)
    encoded = []
    for char in text:
        encoded.append(codes[char])
    print(len(''.join(encoded)))

solution()


# Example run
# Input:
mGQ
# Output:
5
class Node():
    p = None
    l = None
    r = None
    char = ''
    count = 0

    def __init__(self, char='', count=0):
        self.char = char
        self.count = count


def solve(n, h):
    if n.char:
        # print('{}:{}'.format(n.char, h))
        return len(h) * n.count
    else:
        ret = 0
        if n.l: ret += solve(n.l, h + '0')
        if n.r: ret += solve(n.r, h + '1')
        return ret


# --------------------
S = input()
C = {}
T = []

for s in S:
    C.setdefault(s, 0)
    C[s] += 1

T = [Node(*x) for x in C.items()]
T.sort(key=lambda x: x.count)

if len(T) == 1:
    n = Node()
    n.l = T.pop(0)
    T.append(n)
else:
    while len(T) != 1:
        n = Node()
        n.l = T.pop(0)
        n.r = T.pop(0)
        n.count = n.l.count + n.r.count
        T.append(n)
        T.sort(key=lambda x: x.count)

print(solve(T[0], ''))


# Example run
# Input:
cESE\wLj
# Output:
22
import heapq

code_list = dict()

class Node():
    def __init__(self, alphabet, rate):
        self.alphabet = alphabet
        self.rate = rate
        self.left = None
        self.right = None

def create_code(node, target, code):
    
    if node == None:
        return 

    if node.alphabet == target:
        code_list[target] = code
        return
        
    create_code(node.left, target, code + "0")
    create_code(node.right, target, code + "1")

def Main():
    S = input().replace("\n", "")
    N = len(S)

    node_list = list()
    count_list = dict()

    character = set(S)
    character = sorted(character)

    for c in character:
        count = S.count(c)
        count_list[c] = count
        n = Node(c, float(count/N))
        node_list.append(n)

    huf_tree = None

    if len(node_list) == 1:
        n1 = node_list.pop()
        new = Node("", n1.rate)
        new.left = n1

        huf_tree = new

    else:
        while len(node_list) >= 2:
            node_list.sort(key = lambda x : x.rate, reverse = True)

            n1 = node_list.pop()
            n2 = node_list.pop()

            new = Node("", n1.rate + n2.rate)
            new.left = n1
            new.right = n2
            node_list.append(new)

            huf_tree = new

    code_length = 0

    for c in character:
        create_code(huf_tree, c, "")
        code_length += len(code_list[c]) * count_list[c]

    print(code_length)

Main()


# Example run
# Input:
e3zvshd]
# Output:
24
S = input()


dict_string = {}
dict_depth = {}

for s in S:
    if s in dict_string:
        dict_string[s] += 1
    else:
        dict_string[s] = 1
        dict_depth[s] = 0


dict_string_calc = dict_string.copy()


while len(dict_string_calc) != 1:
    x = None
    y = None

    for k, v in sorted(dict_string_calc.items(), key=lambda x: x[1]):
        if x == None:
            x = k
            x_cnt = v
            continue

        if y == None:
            y = k
            y_cnt = v
            break

    for s in (x + y):
        if s in dict_depth:
            dict_depth[s] += 1
        else:
            raise

    del dict_string_calc[x]
    del dict_string_calc[y]

    dict_string_calc[x + y] = x_cnt + y_cnt


ans = 0

for k, v in dict_depth.items():
    ans += dict_string[k] * v


if len(dict_string) == 1:
    ans = len(S)

print(ans)


# Example run
# Input:
1.3330191804166436e-109
# Output:
72