Harryxun/stf_run huggingface dataset:
N = input()

if N[len(N) - 1] == "s":
    N += "es"
else:
    N += "s"
print(N)
N = input()

if N[len(N) - 1] == "s":
    N += "es"
else:
    N += "s"
print(N)


### FIXED CODE ###

N = input()

if N[len(N) - 1] == "s":
    N += "es"
else:
    N += "s"
print(N)
n,m=map(int,open(0));print((n-1)*(m-1))

### FIXED CODE ###

n,m=map(int,input().split());print((n-1)*(m-1))
s = str(input())
ans = 0

for i in 2**(len(s)-1):
    x = s[0]

    for j in range(len(s)-1):
        if (i>>j) & 1:
            x += '+'
        x += s[j+1]
        
    ans += sum(map(int,x.split('+')))
print(ans)

### FIXED CODE ###

s = str(input())
ans = 0

for i in range(2**(len(s)-1)):
    x = s[0]

    for j in range(len(s)-1):
        if (i>>j) & 1:
            x += '+'
        x += s[j+1]
        
    ans += sum(map(int,x.split('+')))
print(ans)
from collections import deque
import bisect
import sys


N = int(input())
a = list(map(int, f.input().split()))
uvs = [list(map(int, input().split())) for _ in range(N-1)]

routes = [[] for _ in range(N)]

for uv in uvs:
    routes[uv[0]-1].append(uv[1]-1)
    routes[uv[1]-1].append(uv[0]-1)

lis = [10e+100 for _ in range(N)]
shortest = [10e+100 for _ in range(N)]
shortest[0] = 0
minimum = [10e+100 for _ in range(N)]
seen = [False for _ in range(N)]
seen[0] = True

def function(checking):
    insert_posi = bisect.bisect_left(lis, a[checking])
    preserved = lis[insert_posi]
    lis[insert_posi] = a[checking]
    minimum[checking] = bisect.bisect_left(lis, 10e+50)
    for route in routes[checking]:
        if seen[route] == False:
            shortest[route] = shortest[checking]+1
            seen[route] = True
            function(route) 
    lis[insert_posi] = preserved
    return
        
function(0)

[print(i) for i in (minimum)]

### FIXED CODE ###

from collections import deque
import bisect
import sys

sys.setrecursionlimit(200000)

N = int(input())
a = list(map(int, input().split()))
uvs = [list(map(int, input().split())) for _ in range(N-1)]
shortest = [10e+10 for _ in range(N)]
shortest[0] = 0

routes = [[] for _ in range(N)]

for uv in uvs:
    routes[uv[0]-1].append(uv[1]-1)
    routes[uv[1]-1].append(uv[0]-1)

lis = [10e+100 for _ in range(N)]
minimum = [10e+100 for _ in range(N)]
seen = [False for _ in range(N)]
seen[0] = True

def function(checking):
    insert_posi = bisect.bisect_left(lis, a[checking])
    preserved = lis[insert_posi]
    lis[insert_posi] = a[checking]
    minimum[checking] = bisect.bisect_left(lis, 10e+50)
    for route in routes[checking]:
        if seen[route] == False:
            seen[route] = True
            shortest[route] = shortest[checking]+1
            function(route)
    lis[insert_posi] = preserved
    return
        
function(0)

[print(x) for x in minimum]
N=input()
print(sum(map(int, input().split()))-N)

### FIXED CODE ###

N=int(input())
print(sum(map(int, input().split()))-N)
A, B, M = map(int, input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
value = min(a) + min(b)
for i in range(M):
    x,y,c = list(map(int, input().split()))
    if A[x] + B[y] - c < value:
        value = A[x] + B[y] - c

print(value)

### FIXED CODE ###

A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
value = min(a) + min(b)
for i in range(M):
    x,y,c = list(map(int, input().split()))
    if a[x-1] + b[y-1] - c < value:
        value = a[x-1] + b[y-1] - c

print(value)
a=input()
print(a+a**2+a**3)

### FIXED CODE ###

a=input()
a=int(a)
print(int(a+a**2+a**3))
import numpy as np
n,q = map(int, input().split())
A = np.array([float("inf")] * n)
for i in range(q):
 c,x,y = map(int,input().split())
 if c == 0:
  A[x] = y
 else:
  a = np.min(A[x:y+1])
  if a == float("inf"): a = "2147483647"
  else: a = str(a)
  print(a)

### FIXED CODE ###

import math, sys
MAX = pow(2, 31) - 1

#??°????????????????????§????°????????????¨???????????°??????????????????????§????
class SegmentTree():
    def __init__(self, n):
        self.TreeRange = pow(2, math.ceil(math.log2(n)))
        self.List = [MAX] * (2 * self.TreeRange - 1)

    def update(self, i, x):
        i += self.TreeRange - 1
        self.List[i] = x
        while i > 0:
            i = (i - 1) // 2
            self.List[i] = min (self.List[i * 2 + 1], self.List[i * 2 + 2])

    def find(self, s, t, i=0, left=0, right=float("inf")):
        #??¢?´¢????±?????????????????????§????????°?????§???????????????
        if right <= s or t <= left:
            return MAX
        #??¢?´¢????±?????????????????????§????????°??????????????????????????????
        elif s <= left <= right <= t:
            return self.List[i]
        #??¢?´¢????±????????????????????????????????????°????????????????????°
        else:
            l = self.find(s, t, i * 2 + 1, left, (left + right) // 2)
            r = self.find(s, t, i * 2 + 2, (left + right) // 2, right)
            return min(l, r)

_input = sys.stdin.readlines()
n,q = map(int, _input[0].split())
qlist = map(lambda x:x.split(), _input[1:])
ST = SegmentTree(n)

for q in qlist:
    cmd, x, y = map(int, q)
    if cmd == 0:
        ST.update(x, y)
    elif cmd == 1:
        print(ST.find(x,y + 1, right = ST.TreeRange))
n = int(input())
arr = list(map(int, input().split()))
while len(arr) > 1:
  arr = sorted(arr)
  v1 = arr.pop(0)
  v2 = arr.pop(0)
  arr.appned((v1 + v2) / 2)
print(arr[0])



### FIXED CODE ###

n=int(input())
arr=list(map(int, input().split()))
while len(arr)>1:
  arr = sorted(arr)
  v1 = arr.pop(0)
  v2 = arr.pop(0)
  arr.append((v1 + v2) / 2)
print(arr[0])
S = input()
dp = [[0]*13 for _ in range(len(S))]
if S[0]=="?":
  dp[0] = [1]*10+[0]*3
else:
  dp[0][int(S[0])] = 1
mod = 10**9+7
table = {str(i):[(10*j+i)%13 for j in range(13)] for i in range(10)}
for k in range(1,len(S)):
  tmp = dp[k-1]
  if S[k] != "?":
    for i,t in enumerate(table[S[k]]):
      dp[k][t]= tmp[i]
  else:
    for j in range(10):
      for i,t in enumerate(table[str(j)]):
        dp[k][t] += tmp[i]%mod
    dp[k] = [p%mod for p in dp[k]]
print(dp[-1][5])
    
    


### FIXED CODE ###

a,b = map(int,input().split())
if (a+b) % 2 ==0:
  print(int((a+b)/2))
else:
  print("IMPOSSIBLE")
from collections import deque
N,X,Y=map(int,input().split())

count=[0]*N

def bfs(start):
    dist=[-1]*(N+1)#indexと頂点の番号を合わせる
    q=deque()
    q.append([start,0])
    dist[start]=0
    while not q.empty():
        j,kyori=q.popleft()

        if j-1>=1:
            if dist[j-1]==-1:
                q.append([j-1,kyori+1])
                dist[j-1]=kyori+1

        if j+1<=N:
            if dist[j+1]==-1:
                q.append([j+1,kyori+1])
                dist[j+1]=kyori+1
        
        if j == X and dist[Y]==-1:
            q.append([Y,kyori+1])
            dist[Y]=kyori+1

        if j == Y and dist[X]==-1:
            q.append([X,kyori+1])
            dist[X]=kyori+1

    return dist[1:]

def main():
    for start in range(1,N+1):
        dist=bfs(start)
        for d in dist:
            count[d]+=1

    for i in count[1:]:
        print(i//2)

main()

### FIXED CODE ###

from collections import deque
N,X,Y=map(int,input().split())

count=[0]*N

def bfs(start):
    dist=[-1]*(N+1)#indexと頂点の番号を合わせる
    q=deque()
    q.append([start,0])
    dist[start]=0
    while q:
        j,kyori=q.popleft()

        if j-1>=1:
            if dist[j-1]==-1:
                q.append([j-1,kyori+1])
                dist[j-1]=kyori+1

        if j+1<=N:
            if dist[j+1]==-1:
                q.append([j+1,kyori+1])
                dist[j+1]=kyori+1
        
        if j == X and dist[Y]==-1:
            q.append([Y,kyori+1])
            dist[Y]=kyori+1

        if j == Y and dist[X]==-1:
            q.append([X,kyori+1])
            dist[X]=kyori+1

    return dist[1:]

def main():
    for start in range(1,N+1):
        dist=bfs(start)
        for d in dist:
            count[d]+=1

    for i in count[1:]:
        print(i//2)

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

A = max(a)

cnt = [0]*(A+1)
uq = []

for i in a:
    cnt[i] += 1

for i in range(A+1):
    if cnt[i] == 1:
        uq.append(i)

cnt = [0]*((10**6)+1)
cnt1 = 0


a = list(set(a))



for i in a:
    for j in range(2,A+1):
        cnt[i*j] = 1


for i in uq:
    if cnt[i] == 0:
        cnt1 += 1

print(cnt1)


### FIXED CODE ###

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

A = max(a)

cnt = [0]*(A+1)
uq = []

for i in a:
    cnt[i] += 1

for i in range(A+1):
    if cnt[i] == 1:
        uq.append(i)

cnt = [0]*((10**6)+1)
cnt1 = 0


a = list(set(a))

# for i in a:
#     for j in range(2,A+1):
#         if i*j<=A+1:
#             cnt[i*j] = 1

for elem in a:
    for m in range(elem * 2, (10 ** 6) + 1, elem):
        cnt[m] = 1

for i in uq:
    if cnt[i] == 0:
        cnt1 += 1

print(cnt1)
A,B,K=map(int,input().split())
for i in range(K):
    if i%2==0:
        if A%2==1:
            A-=1
        B+=int(A/2)
        A=int(A/2)
    else:
        if B%2==1:
            B-=1
        A+=int(B/2)
        B=int(B/2)
print(A+" "+B)

### FIXED CODE ###

A,B,K=map(int,input().split())
for i in range(K):
    if i%2==0:
        if A%2==1:
            A-=1
        B+=int(A/2)
        A=int(A/2)
    else:
        if B%2==1:
            B-=1
        A+=int(B/2)
        B=int(B/2)
print(A,B)
import math

prims = list()

prims.append(2)

base = int(input())

def _is_prim(n):
  global prims
  for p in prims:
    if n == p:
      return True
    elif n % p == 0:
      return False
  
  return True

# 入力値の平方根までの素数を作る
base_rt = int(math.sqrt(base))
for n in range(rt):
  if n < 2:
    continue
  elif n % 2 == 0:
    continue
  elif _is_prim(n):
    prims.append(n)

# 作った素数値で。。。
while not _is_prim(base):
  base += 1

print(base)   

### FIXED CODE ###

stdin = input().split()
print(stdin[1] + stdin[0])
s=input();k=int(input())    

a=sorted({s[i:i+j+1] for i in range(len(s)) for j in range(k)})[k-1])
print(a)

### FIXED CODE ###

s=input()
k=int(input())

a=sorted({s[i:i+j+1] for i in range(len(s)) for j in range(k)})[k-1]
print(a)
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ax = 0
for aa in range(a+1):
  for bb in range(b+1):
    for cc in range(c+1):
      if aa * 500 + bb * 100 + cc * 50 == X:
        ax += 1
print(ax)

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
x = int(input())
ax = 0
for aa in range(a+1):
  for bb in range(b+1):
    for cc in range(c+1):
      if aa * 500 + bb * 100 + cc * 50 == x:
        ax += 1
print(ax)
R=input()
G=input()
if R<G:
  print(2*G-R)
elif R>G:
  print(-1*(2*G-R))

### FIXED CODE ###

R=int(input())
G=int(input())
print(2*G-R)
def main():
    s = input()
    k = int(input())

    count_l = []
    i = 0
    counter = 1
    while True:

        if s[i] == s[i+1]:
            counter += 1
        else:
            count_l.append(counter)
            counter = 1
        i += 1
        if i == len(s)-1:
            if counter == 1:
                break
            else:
                count_l.append(counter)
                break

    answer = 0
    if len(count_l) >= 3 and s[0] == s[:-1]:
        sub_l = count_l[0]+count_l[-1] + count_l[1:-2]
        if k >= 2:
            for i in range(len(sub_l)):
                answer += (sub_l[i] // 2) * (k - 1)
            for j in range(len(count_l[:-2])):
                answer += count_l[j] // 2
            answer += count_l[:-1] // 2
    elif len(count_l) == 1:
        answer += (count_l[0] * k) // 2
    else:
        for i in range(len(count_l)):
            answer += (count_l[i] // 2) * k

    print(answer)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    s = input()
    k = int(input())

    count_l = []
    i = 0
    counter = 1
    while True:
        if len(s) == 1:
            count_l.append(counter)
            break
        elif s[i] == s[i+1]:
            counter += 1
        else:
            count_l.append(counter)
            counter = 1
        i += 1
        if i == len(s)-1:
            if counter == 1:
                break
            else:
                count_l.append(counter)
                break

    answer = 0
    if len(count_l) >= 3 and s[0] == s[-1] and k >= 2:
        sub_l = [count_l[0] + count_l[-1]] + count_l[1:-1]
        for i in range(len(sub_l)):
            answer += (sub_l[i] // 2) * (k - 1)
        for j in range(len(count_l[:-1])):
            answer += count_l[j] // 2
        answer += count_l[-1] // 2
    elif len(count_l) == 1:
        answer += (count_l[0] * k) // 2
    else:
        for i in range(len(count_l)):
            answer += (count_l[i] // 2) * k

    print(answer)


if __name__ == "__main__":
    main()
def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline
    from collections import deque
    from bisect import bisect_left

    N = int(input())
    a = list(map(int, input().split()))
    tree = [[] for _ in [0]*N]
    for u, v in [map(int, input().split()) for _ in [0]*(N-1)]:
        tree[u-1].append(v-1)
        tree[v-1].append(u-1)
    
    dp = [1001001001] * N
    dp[0] = -1001001001
    ans = [0] * N
    def dfs(now, p=-1):
        idx = bisect_left(dp, a[now])
        old = dp[idx]
        dp[idx] = a[now]
        ans[now] = idx
        if p != -1 and ans[now] < ans[p]:
            ans[now] = ans[p]
        for child in tree[now]:
            if child == p: continue
            dfs(child, now)
        dp[idx] = old
    dfs(0)
    
    print(*ans, sep='\n')

main()

### FIXED CODE ###

def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline
    from collections import deque
    from bisect import bisect_left

    N = int(input())
    a = list(map(int, input().split()))
    tree = [[] for _ in [0]*N]
    for u, v in [map(int, input().split()) for _ in [0]*(N-1)]:
        tree[u-1].append(v-1)
        tree[v-1].append(u-1)
    
    dp = [1001001001] * (N+1)
    dp[0] = -1001001001
    ans = [0] * N
    def dfs(now, p=-1):
        idx = bisect_left(dp, a[now])
        old = dp[idx]
        dp[idx] = a[now]
        ans[now] = idx
        if p != -1 and ans[now] < ans[p]:
            ans[now] = ans[p]
        for child in tree[now]:
            if child == p: continue
            dfs(child, now)
        dp[idx] = old
    dfs(0)

    print(*ans, sep='\n')

main()
b=int(input())
c=input()
c=c.replace(c[b-1],c[b-1].lower())
print(c)

### FIXED CODE ###

N, K = map(int, input().split())
S = input()
K -= 1
answer = S[:K] + S[K].lower() + S[K+1:]
print(answer)
import math
from queue import Queue
H, W = map(int, input().split())
s = [input() for _ in range(H)]
d = [[math.inf]*W for _ in range(H)]
d[0][0] = 1
cs = 0
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            cs += 1
            d[i][j] = 0


def check(t):
    if 0 <= t[0] < H and 0 <= t[1] < W and math.isinf(d[t[0]][t[1]]):
        return True
    return False


q = Queue()
q.put((0, 0))
while not q.empty():
    h, w = q.get()
    for v in [(h-1, w), (h+1, w), (h, w-1), (h, w+1)]:
        if check(v):
            d[v[0]][v[1]] = d[h][w]+1
            q.put(v)

print(H*W-cs-d[-1][-1] if not math.isinf(d[-1][-1]) else -1)


### FIXED CODE ###

from queue import Queue
H, W = map(int, input().split())
s = [input() for _ in range(H)]
d = [[float('inf')]*W for _ in range(H)]
d[0][0] = 1
cs = 0
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            cs += 1
            d[i][j] = 0


def check(t):
    if 0 <= t[0] < H and 0 <= t[1] < W and d[t[0]][t[1]] == float('inf'):
        return True
    return False


q = Queue()
q.put((0, 0))
while not q.empty():
    h, w = q.get()
    for v in [(h-1, w), (h+1, w), (h, w-1), (h, w+1)]:
        if check(v):
            d[v[0]][v[1]] = d[h][w]+1
            q.put(v)

print(H*W-cs-d[-1][-1] if not (d[-1][-1] == float('inf')) else -1)
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under



X, Y = (int(i) for i in input().split())
if (X+Y) % 3 == 0 and max(X,Y) - min(X,Y) <= min(X,Y):
    print(cmb(X+Y/3, abs(X-Y)) % (10**9+7))
else:
    print(0)

### FIXED CODE ###

N = int(input())
print(N ** 2)
N,M = map(int,input().split())
L=[0]*M
for i in range(N):
  A=[int(x) for x in input().split()]
  for j in range(A[0]):
    L[A[j]] +=1
print(L.count(N))

### FIXED CODE ###

N,M =map(int,input().split())
se = set(range(M+1))
for i in range(N):
  A = [int(x) for x in input().split()]
  se &= set(A[1:])
print(len(se))
N=int(input())
L=[]
T=[]
for _ in range(N):
  x=int(input())
  L.append(x)
  if x not in T:
    T.append(x)

T.sort()
if not L.count(T[len(T)-1])!<N//75:
  T.reverse()

for i in range(N):
  for j in range(len(T)):
    elif T[j]!=L[i]:
      print(T[j])
      break
    elif len(T)==1:
      print(T[j])

### FIXED CODE ###

N=int(input())
L=[]
for _ in range(N):
  L.append(int(input()))
sL=sorted(L)
sL.reverse()
m=max(L)
m2=sL[1]

for i in range(N):
  if L[i]==m:
    print(m2)
  else:
    print(m)
import bisect
N=int(input())
D=list(map(int,input().split()))
D.sort()
m=max(D)
counter=[]
if D[0]==0:
    for i in range(1,m+1):
        counter.append(bisect.bisect_right(D,i)-bisect.bisect_left(D,i))
    ans=1
    for i in range(2,m+1):
        if counter[i-1]==0:
            counter[i-1]=1
        ans*=counter[i-1]**counter[i]
    print(ans%998244353)
else:
    print(0)

### FIXED CODE ###

import bisect
N=int(input())
D=list(map(int,input().split()))
if D[0]==0 and D.count(0)==1:
    D.sort()
    m=max(D)
    counter=[]
    for i in range(m+1):
        counter.append(bisect.bisect_right(D,i)-bisect.bisect_left(D,i))
    ans=1
    for i in range(1,m+1):
        ans*=counter[i-1]**counter[i]
    print(ans%998244353)
else:
    print(0)
N, X = map(int, input().split())

# (i)XがLバーガーの半分より上かどうか？を計算
# (ii-i)上の場合: sumに下半分のパティの数を加算。下半分を切り捨てて、L-1バーガに対して、
#        再度X = (X-(Lバーガーの半分の枚数))で(i)から計算
# (ii-ii)下の場合: 上半分を切り捨てて、L-1バーガに対して再度X = (X-(Lバーガーの半分の枚数))で(i)から計算

patty_num_map = {}
size_map = {}
patty_num_map[0] = 1
size_map[0] = 1
for i in range(1, 51):
    patty_num_map[i] = 1+patty_num_map[i-1]*2
    size_map[i] = 3+size_map[i-1]*2

L = N
patty_sum = 0
L1_map = {}
L1_map[0] = 0
L1_map[1] = 0
L1_map[2] = 1
L1_map[3] = 2
L1_map[4] = 3
L1_map[5] = 3
L1_map[6] = 3
while True:
    half = size_map[L]//2+1
    if L < 2:
        patty_sum += L1_map[X]
        break
    if X > half:
        patty_sum += patty_num_map[L-1]+1  # 真ん中のpattyの分
        # X -= half+1  # 一番上のバティの分
        X -= half
        L -= 1
    elif X < half:
        X -= 1  # 一番下のバンの分
        L -= 1
    else:  # ちょうど半分
        patty_sum += patty_num_map[L-1]+1
        break
print(patty_sum)


### FIXED CODE ###

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

# (i)XがLバーガーの半分より上かどうか？を計算
# (ii-i)上の場合: sumに下半分のパティの数を加算。下半分を切り捨てて、L-1バーガに対して、
#        再度X = (X-(Lバーガーの半分の枚数))で(i)から計算
# (ii-ii)下の場合: 上半分を切り捨てて、L-1バーガに対して再度X = (X-(Lバーガーの半分の枚数))で(i)から計算

patty_num_map = {}
size_map = {}
patty_num_map[0] = 1
size_map[0] = 1
for i in range(1, 51):
    patty_num_map[i] = 1+patty_num_map[i-1]*2
    size_map[i] = 3+size_map[i-1]*2

L = N
patty_sum = 0
L1_map = {}
L1_map[0] = 0
L1_map[1] = 0
L1_map[2] = 1
L1_map[3] = 2
L1_map[4] = 3
L1_map[5] = 3
L1_map[6] = 3
for i in range(7, 10000):
    L1_map[i] = 3
while True:
    half = size_map[L]//2+1
    if L < 2:
        patty_sum += L1_map[X]
        break
    if X > half:
        patty_sum += patty_num_map[L-1]+1  # 真ん中のpattyの分
        # X -= half+1  # 一番上のバティの分
        X -= half
        L -= 1
    elif X < half:
        X -= 1  # 一番下のバンの分
        L -= 1
    else:  # ちょうど半分
        patty_sum += patty_num_map[L-1]+1
        break
print(patty_sum)
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) ]))
def invr():
    return(map(int,input().split()))
  
i <- inlt()
D <- i[0]
T <- i[1]
S <- i[2]

if D/T > S:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) ]))
def invr():
    return(map(int,input().split()))
  
i = inlt()
D = i[0]
T = i[1]
S = i[2]
 
if D/T > S:
  print("No")
else:
  print("Yes")
from math import factorial
N = int(input())
s = [''.join(sorted(input())) for i in range(N)]
ns = []
ans = 0
for i in range(len(s)):
    if ns.count(s[i]) == 0:
        aas = s.count(s[i])
        if aas > 0:
            ns.append(s[i])
        abs = int(factorial(aas) / factorial(2) / factorial(aas - 2 ))
        ans += abs
print(ans)

### FIXED CODE ###

from collections import Counter

N = int(input())
s = Counter()
for i in range(N):
    s[''.join(sorted(input()))] += 1
ans = 0
for kw, count in s.most_common():
    for i in range(1, int(count)):
        ans += i
    if int(count) < 2:
        break
print(ans)
# coding: utf-8
# Here your code !
import sys

from collections import deque
n = int(input())
output = []
for i in range(n):
    order,data =input().split() 
    if order == "insert":
        output.append(int(data))
    elif order == "deleteFirst":
        output.pop()
    elif order == "deleteLast":
        output.popleft()
    elif order == "delete":
        try:
            output.remove(int(data))
        except:
            pass
output.reverse()
print(" ".join(map(str,output)))

### FIXED CODE ###

import sys
from collections import deque
n = int(sys.stdin.readline())
lines = sys.stdin.readlines()
 
Q = deque()
for i in range(n):
    command = lines[i].split()
    if command[0] == "insert":
        Q.appendleft(command[1])
    elif command[0] == "deleteFirst":
        Q.popleft()
    elif command[0] == "deleteLast":
        Q.pop()
    elif command[0] == "delete":
        try:
            Q.remove(command[1])
        except:
            pass
print(" ".join(Q))
arg = list(map(int, input().split())) # 1行, 配列
N = arg[0]
K = arg[1]
S = list(map(int, input().split())) # 1行, 配列

dp = [float('inf')] * N
dp[0] = 0
for i in range(1, N):
  if i == 1:
    DP[i] = abs(S[i] - S[i-1])
    continue
  for j in range(K+1):
    if i - j < 0:
      continue
    DP[i] = min(DP[i] , DP[i-j] + abs(S[i] - S[i-j]))

print(DP[-1])

### FIXED CODE ###



arg = list(map(int, input().split())) # 1行, 配列
N = arg[0]
K = arg[1]
S = list(map(int, input().split())) # 1行, 配列

DP = [float('inf')] * N
DP[0] = 0
for i in range(1, N):
  if i == 1:
    DP[i] = abs(S[i] - S[i-1])
    continue
  for j in range(K+1):
    if i - j < 0:
      continue
    DP[i] = min(DP[i] , DP[i-j] + abs(S[i] - S[i-j]))

print(DP[-1])
S = input()
S = S.split()
howMuch = S[0]
Ihave = S[1]
sutis = S[2]
 
if (Ihave // howMuch) < sutis:
    print(Ihave // howMuch)
else:
    print(sutis)

### FIXED CODE ###

S = input()
S = S.split()
howMuch = int(S[0])
Ihave = int(S[1])
sutis = int(S[2])
 
if (Ihave // howMuch) < sutis:
    print(Ihave // howMuch)
else:
    print(sutis)
N, M = map(int, input().split())

if N == 1:
  ans = "*"
elif N == 2:
  ans = "**"
else: #N==3
  ans = "***"

  
ng = False
for i in range(M):
  s, c = input().split()
  s = int(s)
  if ans[s] != '*' or ans[s] != c:
    ng = True
    break
  else:
    ans[s] = c

if N == 1 and ans == "*":
  ans = "0"
if N == 2:
  if ans[0] == "*":
    ans[0] = "1"
  if ans[1] == "*":
    ans[1] = "0"
if N == 3:
  if ans[0] == "*":
    ans[0] = "1"
  if ans[1] == "*":
    ans[1] = "0"
  if ans[2] == "*":
    ans[2] = "0"

if ng:
  print(-1)
else:
  print(int(ans))

### FIXED CODE ###

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

if N == 1:
  ans = ["*"]
elif N == 2:
  ans = ["*","*"]
else: #N==3
  ans = ["*","*","*"]
  
ng = False
for i in range(M):
  s, c = input().split()
  s = int(s)-1
  if ans[s] != '*' and ans[s] != c:
    ng = True
    break
  elif s==0 and c=="0" and N>1:
    ng = True
    break
  else:
    ans[s] = c

if N == 1 and ans[0] == "*":
  ans[0] = "0"
if N == 2:
  if ans[0] == "*":
    ans[0] = "1"
  if ans[1] == "*":
    ans[1] = "0"
if N == 3:
  if ans[0] == "*":
    ans[0] = "1"
  if ans[1] == "*":
    ans[1] = "0"
  if ans[2] == "*":
    ans[2] = "0"

if ng:
  print(-1)
else:
  print("".join(ans))