peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
N, H = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]

ans = 0
attack = []

for a, b in ab:
    attack += [[a, 0]]
    attack += [[b, 1]]

attack = sorted(attack, key=lambda x:(-x[0], -x[1]))

for a, i in attack:
    if i == 1:
        H -= a
        ans += 1
    else:
        if H <= 0:
            break
        cnt = (H-1)//a + 1
        ans += cnt
        break

print(ans)
# Judge status: Wrong Answer
n = int(input())
k = int(input())
x = int(input())
y = int(input())
a = 0
b = 0
c = 0
e = 0

if n <= k:
    a = n * x
else:
    c = n - k
    b = c * y

e = a + b
print(e)
# Judge status: Wrong Answer
X,Y = map(int,input().split())
y_end = Y - Y%X
count = 0

while X <= y_end:
  print(X)
  count += 1
  X *= 2
print(count)
# Judge status: Wrong Answer
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

N        = int( input() )
dict_all = {}
for nn in range(N):
    text = ''.join( sorted( str( input() ) ) )
    if( text in dict_all ):
        dict_all[text] += dict_all[text] + 1
    else:
        dict_all[text] = 0
        
count = 0
for key in dict_all:
    count += dict_all[key]    

print(count)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=1)
ans=0+a[0]
cnt=1
for i in range(1,n):
    if cnt<n-2:
        ans+=2*a[i]
        cnt+=2
    elif cnt==n-2:
        ans+=a[i]
        break
    elif cnt==n-1:
        break
print(ans)
# Judge status: Accepted
h1,m1,h2,m2,k=map(int,input().split())
print((h2-h1)*60+m2-m1-k)
# Judge status: Accepted
n,T=map(int,input().split())
C=[]
for i in range(n):
    c,t=map(int,input().split())
    if t<=T:
        C.append(c)
if len(C)>0:
    print(min(C))
else:
    print("TLE")
# Judge status: Accepted
a, b, c, d = map(int, input().split())

import math
g = math.gcd(c, d)
l = int(c * d / g)

less_b = b - (b // c + b // d - b // l)
less_a = (a-1) - ((a-1)//c + (a-1) // d - (a-1)//l)
print(less_b-less_a)
# Judge status: Accepted
N = int(input())
S = []
for _ in range(N):
    S.append(int(input()))

s = sum(S)
if s % 10 != 0:
    print(s)
else:
    S.sort()
    for i in S:
        if i % 10 != 0:
            s -= i
            break
    if s % 10 == 0:
        print(0)
    else:
        print(s)
# Judge status: Wrong Answer
N, K = map(int, input().split())
*A, = map(int, input().split())
d = [0]*(N+1)
for a in A:
    d[a] += 1
    d.sort()
    d.reverse()
    print(sum(d[K:]))
# Judge status: Accepted
n, k = map(int, open(0).readline().split())
print((n - 2) // (k - 1) + 1)
# Judge status: Accepted
#!/usr/bin/python
# -*- coding: utf-8 -*-

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

if A%K == 0:
    print('OK')
elif K*(A//K+1) <= B:
    print('OK')
else:
    print('NG')
# Judge status: Wrong Answer
import sys
from string import ascii_lowercase

alphs = list(ascii_lowercase)

n = int(sys.stdin.readline().rstrip())

def main():
    cur = ['a']
    for _ in range(n-1):
        nex = []
        for c in cur:
            i = ord(c[-1]) - 97
            for al in alphs[:i+2]:
                nex.append(c + al)
        cur = nex
    return sorted(cur)

if __name__ == "__main__":
    ans = main()
    print(*ans, sep='\n')
# Judge status: Wrong Answer
s = input()
t = input()
li_s = list(s)
li_t = list(t)
ma = {}
for i,j in zip(li_s,li_t):
    if j not in ma:
        ma[j] = i
    elif ma[j] != i:
        print('No')
        exit()
print('Yes')
# Judge status: Wrong Answer
#  AtCoder Grand Contest 002 B

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

xn = [0] * M
yn = [0] * M

for i in range(M):
    xn[i],yn[i] = map(int,input().split())

if 1 not in xn:
    print(1)
    exit()

a = [1]
count = 0

for i in range(M):
    if xn[i] in a:
        count +=1
        a.append(yn[i])
        
print(count)
# Judge status: Accepted
N, K = map(int, input().split())

m = 1000000007

result = 0
for i in range(K, N + 2):
    # max: N, N -1, ..., N - i + 1
    a = (N + (N - i + 1)) * i // 2
    # min: 0, 1, .., i - 1
    b = (0 + (i - 1)) * i // 2
    result += a - b + 1
    result %= m
print(result)
# Judge status: Accepted
A, B, C = map(int, input().split())
print(C-(A-B) if C-(A-B)>=0 else 0)
# Judge status: Accepted
S = input()
for i in range(len(S)):
  print('x', end='')
print()
# Judge status: Wrong Answer
N = int(input())

if N < 111:
  print(111)
elif N < 222:
  print(222)
elif N < 333:
  print(333)
elif N < 444:
  print(444)
elif N < 555:
  print(555)
elif N < 666:
  print(666)
elif N < 777:
  print(777)
elif N < 888:
  print(888)
else:
  print(999)
# Judge status: Accepted
n=int(input())
s=input()
mod=10**9+7
from collections import Counter

c=list(Counter(s).values())

ans=1

for i in c:
    ans*=(i+1)

print((ans-1)%mod)
# Judge status: Accepted
N=int(input() )
print( int(N*(N+1)/2) )
# Judge status: Accepted
s = input()
kita, minami = sorted([s.count('N'),s.count('S')])
nisi, higasi = sorted([s.count('W'),s.count('E')])
result = ['No','Yes']
r = 1
if kita==minami or kita*minami > 0:
    r *= 1
else:
    r = 0

if nisi==higasi or nisi*higasi > 0:
    r *= 1
else:
    r = 0
print(result[r])
# Judge status: Wrong Answer
A, B, C = map(int, input().split())
print(C if A * C >= B else B // A)
# Judge status: Accepted
N=int(input())
S=[[] for i in range(N)]
for i in range(N):
    s,p=map(str,input().split())
    S[i]=[s,int(p)*(-1),i]

S.sort(key=lambda x:(x[0],x[1]))

for i in range(N):
    print(S[i][2]+1)
# Judge status: Wrong Answer
SX, SY, TX, TY = map(int, input().split())
way1 = 'U' * (TX - SX) + 'R' * (TY - SY)
way2 = 'D' * (TX - SX) + 'L' * (TY - SY)
way3 = 'L' + 'U' * (TX - SX + 1) + 'R' * (TY - SY + 1) + 'D'
way4 = 'R' + 'D' * (TX - SX + 1) + 'L' * (TY - SY + 1) + 'U'
print(way1 + way2 + way3 + way4)
# Judge status: Accepted
n = int(input())
a = [list(map(int, input().split())) for _ in range(2)]

ans = 0
for i in range(n):
   x = 0
   row = 0
   for j in range(n):
      x += a[row][j]
      if i == j:
         row += 1
         x += a[row][j]
   ans = max(ans, x)

print(ans)
# Judge status: Wrong Answer
import itertools
N,K=map(int,input().split())
D=set(int(x) for x in input().split())
T=set(range(10))-D
answer=100000

for x in itertools.product(T,repeat=5):
    p=0
    for i in range(5):
      p +=x[i]*10**i
    if p>=N:
      answer=min(p,answer)
print(answer)
# Judge status: Accepted
l = sorted(list(map(int, input().split())))

if l[0]+l[1] == l[2]:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
from math import gcd
def resolver(X):
    if 360 % X == 0:
        return 360 // X
    ans = 360 * X // gcd(360, X) 
    return ans



def main():
    X = int(input())
    ans = resolver(X)
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
alist = list(map(int,input().split()))
aset = set(alist)
if len(alist) == len(aset):
  print("YES")
else:print("NO")
# Judge status: Accepted
n = int(input().strip())
a = list(map(int, input().split()))
two = 0
four = 0
for e in a:
    if e % 4 == 0:
        four += 1
    elif e % 2 == 0:
        two += 1
if (n - two <= 2 * four) or (two == 0 and n <= (2 * four + 1)):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def main():
    s1 = input()
    s2 = input()

    s2 = s2[::-1]

    print('YES' if s1 == s2 else 'NO')

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
A, B = [int(x) for x in input().split(" ")]

if (A+B)%2 == 0:
  print(int((A+B)/2))
else:
  print("INPOSSIBLE")
# Judge status: Accepted
n,m=map(int,input().split())
cnt1=[0]*(n+1)
cnt2=[0]*(n+1)
for _ in range(m):
  p,s=map(str,input().split())
  p=int(p)
  if cnt1[p]==1:
    continue
  else:
    if s=='AC':
      cnt1[p]=1
    else:
      cnt2[p]+=1
ans1=0
ans2=0
for i in range(1,n+1):
  if cnt1[i]==1:
    ans1+=1
    ans2+=cnt2[i]
print(ans1,ans2)
# Judge status: Wrong Answer
import re
s=input()
a=re.search('([0-9]{4})/([0-9]{2})/([0-9]{2})',s)
if int(str(a.group(2)))<=4:
    print('Heosei')
else:
    print('TBD')
# Judge status: Accepted
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    divisors.reverse()
    return divisors
n, m = map(int, input().split())
l = make_divisors(m)
for i in l:
    if m / n >= i:
        print(i)
        exit()
print(1)
# Judge status: Wrong Answer
import sys,math,collections,itertools
input = sys.stdin.readline

N = int(input())
a = list(map(int,input().split()))
a.insert(0,0)
b = []
c = [0 for _ in range(N+1)]
for i in range(N,0,-1):
    cnt = 0
    for j in range(2*i,N,i):
        if c[j] == 1:
            cnt +=1
    if (cnt%2==1 and a[i] == 0) or (cnt%2==0 and a[i] == 1):
        b.append(i)
        c[i] = 1
print(len(b))
print(*b)
# Judge status: Accepted
n,m=map(int,input().split())
ans=0
b=[0]*m
for _ in range(n):
    aa=list(map(int,input().split()))
    aa=aa[1:]
    for i in aa:
        b[i-1]+=1

for i in b:
    if i==n:
        ans+=1

print(ans)
# Judge status: Accepted
x,y,A,B,C=map(int,input().split())
pa=list(map(int,input().split()))
qb=list(map(int,input().split()))
rc=list(map(int,input().split()))
pa.sort()
qb.sort()
temp=0

pa=pa[-x:]
qb=qb[-y:]
paa=pa+rc
paa.sort()
paa1=paa[-x:]
paa2=paa[:-x]
qbb=qb+paa2
qbb.sort()
qbb1=qbb[-y:]
print(sum(paa1)+sum(qbb1))
# Judge status: Wrong Answer
def main():
  a,b = map(int,input().split())
  ans = check(a,b)
  print(ans)
  
def check(n,m):
    num = ""
    if n < m:
        for i in range(m):
            num = str(num) + str(n)
        return num
    elif n > m:
        for i in range(n):
            num = str(num) + str(m)
        return num

main()
# Judge status: Accepted
s = int(input())
a = s
l = [a]
for i in range(100000):
    if a % 2 == 0:
        a = a // 2
    else:
        a = 3 * a + 1
    if a in l:
        print(i + 2)
        break
    l.append(a)
# Judge status: Accepted
n = int(input())
cnt4 = 0
cnt2 = 0
a = list(map(int, input().split()))
for num in a:
    if num % 4 == 0:
        cnt4 += 1
    elif num % 2 == 0:
        cnt2 += 1

if cnt4 >= n // 2:
    print("Yes")
    exit()
elif cnt4 >= (n - cnt2 + 1) // 2:
    print("Yes")
    exit()
print("No")
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
if b>c:
  print("delicious")
elif a+b >c:
  print("safe")
else:
  print("dangerous")
# Judge status: Wrong Answer
S = list(input())
ans = len(S)
for i in range(2):
  cnt = 0
  for j in range(ans):
    if j % 2 == 0 and S[j] != str(i): cnt += 1
    if j % 2 == 1 and S[j] == str(i): cnt += 1
  ans = min(ans,cnt)
print(ans)
# Judge status: Accepted
n, l = map(int,input().split())
a = []
for i in range(n):
    a.append(input())
    
a.sort()
print(''.join(a))
# Judge status: Accepted
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]
a = set(a)
d = [1] + [1]*n
for i in range(1, n):
  if i in a:
    d[i] = 0
    d[i+1] = d[i-1]
  else:
    d[i+1] = d[i] + d[i-1]
    
print(d[n]%1000000007)
# Judge status: Accepted
import itertools 
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
w = 0
x = 0
S = []
T = []
for i in range(N):
    S.append(i+1)
for j in itertools.permutations(S):
    T.append(list(j))
a = T.index(P)
b = T.index(Q)
print(abs(a-b))
# Judge status: Wrong Answer
k = int(input())
anss = [1,2,3,4,5,6,7,8,9]
for i in range(12):
    if len(anss) > k:
        print(anss[k-1])
        break
    new_anss = []
    for ans in anss:
        if ans % 10 != 0:
            new_anss += [ans*10+ans-1]
        new_anss += [ans*10+ans]
        if ans % 10 != 9:
            new_anss += [ans*10+ans+1]
    k -= len(anss)
    anss = new_anss
# Judge status: Accepted
a, b, c, d = map(int, input().split())
ans = max(a * c, b * c, a * d, b * d)
print(ans)
# Judge status: Wrong Answer
n = int(input())
v = sorted(list(map(int,input().split())))

for _ in range(n-1):
    x = v[0]
    y = v[1]
    num = (x+y)/2
    del v[0]
    v[0] = num

print(int(v[0]))
# Judge status: Wrong Answer
import sys 
n=int(input())
l=[1,6,36,6**4,6**5,6**6,9,9**2,9**3,9**4,9**5]
dp=[float("inf")]*(n+1)
dp[0]=0
dp[1]=1
if n==1:
    print(1)
    sys.exit()
for i in range(2,n+1):
    for j in l[::-1]:
        if i-j>=0:
            dp[i]=min(dp[i],dp[i-j]+1)
print(dp[n])
# Judge status: Accepted
from itertools import groupby as gb
n,s=open(0)
n=int(n)
s=sorted(s[:-1])

ans=1
mod=10**9+7
for i,x in gb(s):
  ans=ans*(len(list(x))+1)%mod
print(ans-1)
# Judge status: Wrong Answer
import math
N = int(input())
#Nは6以上
for n in range(1,N):
    r_n = math.floor(math.sqrt(n))
    count = 0
    for x in range(1,r_n):
        for y in range(1,r_n):
            for z in range(1,r_n):
                if (x*x + y*y + z*z + x*y + y*z + z*x) == n:
                    count+=1
    print(count)
# Judge status: Wrong Answer
n = input()
l = n.replace("hi","a")

print("No" if len(set(l)) != 1 else "Yes")
# Judge status: Accepted
a,b,c,d=map(int,input())

if a==b==c or b==c==d:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
N, K = map(int, input().split())
A = []
for i in range(K):
    di = int(input())
    Ai = list(map(int, input().split()))
    A.extend(Ai)

print(N - len(set(A)))
# Judge status: Accepted
# 061_a
A, B, C = map(int, input().split())
if (-100 <= A <= 100) and (-100 <= B <= 100) and (-100 <= C <= 100):
    if A <= C and C <= B:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
s=input()
count=0
for i in range(97,97+26):
    if chr(i) not in s:
        print(chr(i))
        count+=1
        break
    
if count==0:
    print("None")
# Judge status: Wrong Answer
N,D = [int(x) for x in input().split()]
count = 0

for x in range(N):
    x,y = [int(x) for x in input().split()]
    if x**2 + y**2 <= D:
        count += 1

print(count)
# Judge status: Accepted
def checker(arr):
  d = {}
  for x in arr:
    if x not in d:
      d[x] = 1
    else:
      return "NO"
  return "YES"

n = int(input())
arr = list(map(int, input().split()))
print(checker(arr))
# Judge status: Accepted
S = input()
T = input()
def solve(i):
  flag = True
  for j in range(len(T)):
    if i+j < len(S) and (S[i+j] == "?" or S[i+j] == T[j]):
      continue
    else:
      flag = False
      break
  return flag
anslist = []
for i in range(len(S)):
  if solve(i):
    anstmp = S[:i] + T + S[i+len(T):]
    anstmp = anstmp.replace("?", "a")
    anslist.append(anstmp)
if len(anslist) > 0:
  anslist.sort()
  ans = anslist[0]
else:
  ans = "UNRESTORABLE"
print(ans)
# Judge status: Wrong Answer
N=int(input());tt=0
while(N):
    tt+=(N%10);N//=10
    if tt>81:break
print("No" if tt%9 else "Yes")
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))

a.sort(reverse = True)
p = a[0]
for i in range(N-2): #-1は上記a[0]分、もう-1は最初の要素挿入は加点されないため。
    p += a[(i//2)+1]

print(p)
# Judge status: Wrong Answer
alphabet = 'abcdefghijklmnopqrstuvwxyz'
s = input()
K = int(input())
ans = ''
for i in range(len(s)):
    s_i = alphabet.index(s[i])
    if (26 - s_i < K) & (s_i != 0):
        K -= 26 - s_i
        s_i = 0
    ans += alphabet[s_i]
if K > 0:
    s_i = (alphabet.index(s[-1]) + K) % 26
    ans = ans[:-1] + alphabet[s_i]
print(ans)
# Judge status: Accepted
N,W = [int(x) for x in input().split()]
l = []
for i in range(N):
    l.append([int(x) for x in input().split()])
DP = [[0 for i in range(W+1)] for j in range(N+1)]
for i in range(1,W+1):
    for j in range(1,N+1):
        if l[j-1][0] > i:
            DP[j][i] = DP[j-1][i]
        else:
            DP[j][i] = max(DP[j-1][i],DP[j-1][i-l[j-1][0]]+l[j-1][1])
print(DP[N][W])
# Judge status: Accepted
A,B,K = map(int,input().split())
if A-K>=0:
    print(A-K,B)
else:
    K-=A
    if B-K>=0:
        print(0,B-K)
    else:
        print(0,0)
# Judge status: Wrong Answer
s = input()
n = len(s)
res = []
ans = 0
for i in s:
      if i == 'A' or i == 'C':
        res.append(i)
if s[0] == 'A':
  ans += 1
if s.find('C') >= 2 and s.find('C') < n-2:
  ans += 1
if res == ['A', 'C']:
  ans += 1
if ans == 3:
  print('AC')
else:
  print('WA')
# Judge status: Accepted
N = int(input())
result = sum(list(map(int, str(N))))
if result%9==0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())
alist = list(map(int, input().split()))

b = [(alist[i], i+1) for i in range(N)]
b.sort()
ans = [b[i][1] for i in range(N)]
print(*ans)
# Judge status: Accepted
a, b, c = map(int, input().split())

if max(a, b, c) == a + b + c - max(a, b, c):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N=int(input())
c=input()
r=c.count("R")
w=c.count("W")

if w==0 or r==0:
    print(0)
else:
    ans=w
    cnt=0
    for i in range(N-1,N-w,-1):
        cnt+=(c[i]=="W")
        test=i-cnt+w-i
        ans=min(ans,test)
    print(ans)
# Judge status: Accepted
import collections


N = int(input())
S = [None] * N
for i in range(N):
    S[i] = input()

count = collections.Counter(S)
max_n = max(count.values())
# print(max_n)

keys = [k for k, v in count.items() if v == max_n]
keys.sort()

for s in keys:
    print(s)
# Judge status: Accepted
a = int(input())
array = list(map(int, input().strip().split()))
out = 0
min_num = array[0]
for i in array:
    min_num = min(min_num, i)
    out = out + 1 if i == min_num else out
print(out)
# Judge status: Accepted
s,t=map(str,input().split())
a,b=map(int,input().split())
u=input()
if s==u:
    print(str(a-1)+" "+str(b))
else:
    print(str(a)+" "+str(b-1))
# Judge status: Accepted
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())
for i in range(N):
    if i >= K and T[i-K] == T[i]:
        T[i] = 'a'
ans = 0
for i in T:
    if i == 'r':
        ans += P
    elif i == 's':
        ans += R
    elif i == 'p':
        ans += S
print(ans)
# Judge status: Wrong Answer
a, b = map(float, input().split())
ans = int(a * b)
print(ans)
# Judge status: Accepted
A, B, C = map(int, input().split())
if A % 2 == 0 and A == B and B == C:
    print(-1)
    exit()

count = 0
while (A % 2, B % 2, C % 2) == (0, 0, 0):
    A, B, C = (B + C) // 2, (A + C) // 2, (A + B) // 2
    count += 1

print(count)
# Judge status: Wrong Answer
X,K,D = map(int,input().split())

if X > 0 and X-K*D > 0:
  print(abs(X-K*D))
elif X < 0 and X+K*D < 0:
  print(abs(X+K*D))
else:
  if X > 0:
    A = X//D
    B = X%D
    if (K-A)%2 == 1:
      print(abs(B-D))
    else:
      print(abs(B))
  if X < 0:
    A = (-X)//D
    B = (X%D)-D
    if (K-A)%2 == 1:
      print(abs(B+D))
    else:
      print(abs(B))
# Judge status: Accepted
a, b, c, k = map(int, input().split())

if k <= a :
    print(k)
elif k <= a+b:
    print(a)
else:
    print(a+a+b-k)
# Judge status: Wrong Answer
import numpy as np


##get int
first_input = list(map(lambda x:int(x), input().split(" ")))
second_input = list(map(lambda x:int(x), input().split(" ")))

##get float
#first_input = list(map(lambda x:float(x), input().split(" ")))
#second_input = list(map(lambda x:float(x), input().split(" ")))

##get string
#first_input = input().split(" ")

K = first_input[0]
N= first_input[1]

A_list = second_input

A_list.append(K+A_list[0])

dist_list = np.array(A_list)[1:]-np.array(A_list)[:-1]
print(A_list)
print(dist_list)

print(sum(dist_list)-max(dist_list))
# Judge status: Accepted
import numpy as np

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

a = ab[:, 0]
b = ab[:, 1]

dp = np.zeros(10**5, dtype=np.int)

for i in range(1, h+1):
    dp[i] = min(dp[i-a]+b)

print(dp[h])
# Judge status: Accepted
h = int(input())
w = int(input())
n = int(input())

if h >= w:
  print(-(-n//h))
elif w > h:
  print(-(-n//w))
# Judge status: Wrong Answer
x, y = map(int, input().split())

ans = 0
if x > 0:
  if y >= x:
    ans = y - x
  elif 0 <= y < x:
    ans = 1 + abs(x) + y
  elif -x <= y < 0:
    ans = 1 + abs(x) - abs(y)
  else:
    ans = 1 + abs(y) - abs(x)
else:
  if y >= -x:
    ans = 1 + abs(y) + abs(x)
  elif 0 <= y < -x:
    ans = 1 + abs(y) - abs(x)
  elif x <= y < 0:
    ans = abs(y) - abs(x)
  else:
    ans = 1 + abs(y) - abs(x) + 1
print(ans)
# Judge status: Accepted
import math
def comb(n, r):
  if n-r>=0:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
  else:
    return 0
    
n=int(input())
l=[]
for i in range(n):
  s=sorted(input())
  l.append(s)
l.sort()
cnt=1
ans=0

for i in range(n-1):
  if l[i]==l[i+1]:
    cnt+=1
  else:
    ans+=comb(cnt,2)
    cnt=1
    
ans+=comb(cnt,2)    
    
print(ans)
# Judge status: Accepted
from operator import itemgetter
N, M = map(int, input().split())
PY = sorted(((i, tuple(map(int, input().split()))) for i in range(M)), key=itemgetter(1))
L = []
prev, x = 0, 1
for i, (p, _y) in PY:
    if p == prev:
        x += 1
    else:
        prev = p
        x = 1
    L.append((i, "{:06d}{:06d}".format(p, x)))
L.sort()
print(*[l for _, l in L], sep="\n")
# Judge status: Wrong Answer
import numpy as np
n = int(input())
l = []
for i in range(n):
    l.append(list(map(int , input().split())))
#arr = np.array(l)
maxc = max(l[0])
#print(maxc)
ind = l[0].index(maxc)
for r in range(1,n):
    max1 = 0
    for i in range(3):
        if(ind != i):
            max1 = max(max1,l[r][i])
    ind = l[r].index(max1)
    #print(max1)
    maxc += max1
print(maxc)
# Judge status: Accepted
a = list(map(int,input().split()))

a.sort()

if a[2]%2==0:
    print(0)
else:
    print(a[0]*a[1])
# Judge status: Accepted
D,N=map(int,input().split())
num=N*100**D
if N==100:
    num+=100**D
print(num)
# Judge status: Accepted
x=input()
x=int(x)
if x>=400 and x<600:
  rank=8
elif 600<=x and x<800:
  rank=7
elif 800<=x and x<1000:
  rank=6
elif 1000<=x and x<1200:
  rank=5
elif 1200<=x and x<1400:
  rank=4
elif 1400<=x and x<1600:
  rank=3
elif 1600<=x and x<1800:
  rank=2
elif 1800<=x and x<2000:
  rank =1
print(rank)
# Judge status: Accepted
from collections import defaultdict
S = input()
n = len(S)
N = defaultdict(int)
x = 0
for i in reversed(range(n)):
    x += int(S[i])*pow(10,(n-i-1),2019)
    x %= 2019
    N[x] += 1
ans = N[0]
for j in N.values():
    ans += j*(j-1)//2
print(ans)
# Judge status: Accepted
def main():
  n = int(input())
  a = n // 2
  b = (n + 1) // 2
  print(a*b)
  
if __name__ == "__main__":
  main()
# Judge status: Wrong Answer
s=[[int(j) for j in input().split()] for i in range(2)]
n=s[0][0]
a=s[1]
print(a[0])
alice=0
bob=0
max=0
for i in range(len(a)-1):
    if a[i]<=a[i+1]:
        temp=a[i]
        a[i]=a[i+1]
        a[i+1]=temp
for i in range(len(a)):
    if i % 2==0:
        alice+=a[i]
    else:
        bob+=a[i]
print(alice-bob)
# Judge status: Accepted
s = input()
if s[-1:] == 's':
    print(s + 'es')
else:
    print(s + 's')
# Judge status: Wrong Answer
import bisect

n, m = map(int, input().split())
a = map(int, input().split())
a = sorted(a)[::-1]
for i in range(m):
  a[0] = int(a[0] / 2)
  p = bisect.bisect_left(a[1:], a[0])
  a = a[1:p] + [a[0]] + a[p:]
print(sum(a))
# Judge status: Wrong Answer

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

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

S = sum(A)

print("yes" if H <= S else "no")
# Judge status: Wrong Answer
n = int(input())
si = input()
s = list(si)[::-1]
ln = 0
rn = 0
l = ""
r = ""
for i in range(n):
    if s[i] == ')':
        ln += 1
        rn -= 1
    else:
        rn += 1
    
    if ln == 0 and rn > 0:
        l += ")"
        rn -= 1

r = "(" * (rn*-1)
print(r + si + l)
# Judge status: Accepted
a, b = map(int, input().split())

start = b * 10
flg = True
for i in range(10):
  tmp = start + i
  if int(tmp*0.08) == a:
    flg = False
    break
if flg:
  print('-1')
else:
  print(int(tmp))
# Judge status: Accepted

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

cnt = 0
for a, b in zip(A, B):
    if a > b:
        cnt -= a - b
    if a < b:
        cnt += (b - a) // 2

if cnt < 0:
    print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
n = int(input())
nokori = n-25
eve = ' Eve'*nokori
print('Christmas'+eve)