peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
from collections import deque
n, m = map(int, input().split())
graph = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

queue = deque([0])
ans = [-1]*n
ans[0] = 0
while len(queue)>0:
    node = queue.popleft()
    for c_node in graph[node]:
        if ans[c_node]>=0:
            continue
        ans[c_node] = node+1
        queue.append(c_node)
print('Yes')
for i in ans[1:]:
    print(i)
# Judge status: Accepted
def f(n):
	keta = 0
	while n:
		keta += 1
		n //= 10
	return keta % 2 == 1

N = int(input())
ans = 0
for i in range(1, N+1):
	if f(i):
		ans += 1
print(ans)
# Judge status: Wrong Answer
n = int(input())
a,b, sA, sB, result= 1, 0,0,0,0
soma = []
while a<=n:
    b=n-a
    for i in str(a):
         sA+=int(i)
    for j in str(b):
        sB+=int(j)
    soma.append(sA+sB)
    a=a+1
for k in str(min(soma)):
    result += int(k)
print(result)
# Judge status: Accepted
N = int(input())
D = [int(n) for n in str(N)]
ans = D[0] - 1 + 9 * (len(D) - 1)
ans = max(ans, sum(D))
print(ans)
# Judge status: Wrong Answer
s=input()
print("YNeos"[s != len(s) * s[0]::2])
# Judge status: Wrong Answer
n=int(input())
blue=[input() for _ in range(n)]
bset = set(blue)

m=int(input())
red=[input() for _ in range(m)]

print(max([blue.count(b) - red.count(b) for b in bset]))
# Judge status: Wrong Answer
X = int(input())
ans = 'YES' if X == 3 or X == 5 or X == 7 else 'No'
print(ans)
# Judge status: Accepted
def resolve():
    import numpy as np

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

    A = np.insert(np.cumsum(A), 0, 0)
    B = np.insert(np.cumsum(B), 0, 0)

    ans = 0
    j = M
    for i in range(N + 1):
        if A[i] > K:
            break
        while A[i] + B[j] > K:
            j -= 1

        ans = max(ans, i + j)

    print(ans)

resolve()
# Judge status: Accepted
import sys
input = sys.stdin.readline
import bisect
from collections import deque

def main():
    N = int(input())
    use = deque([int(input())])
    for _ in range(N-1):
        num = int(input())
        index = bisect.bisect_left(use,num)
        if index == 0:
            use.appendleft(num)
        else:
            use[index-1] = num
    
    print(len(use))
    
if __name__ == "__main__":
    main()
# Judge status: Accepted
from collections import deque
n, m, *AB = map(int, open(0).read().split())
graph = [[] for _ in range(n)]
for a, b in zip(AB[::2], AB[1::2]):
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

d = [0] * n
queue = deque([0])
while queue:
    current_node = queue.popleft()
    for next_node in graph[current_node]:
        if d[next_node] == 0:
            d[next_node] = current_node+1
            queue.append(next_node)
print('Yes')
print(*d[1:], sep='\n')
# Judge status: Accepted
n, k = map(int, input().split())
mod = 10 ** 9 + 7
a = [i for i in range(n + 1)]
b = [0] * (n + 1)
c = [0] * (n + 1)
for i in range(1, n + 1):
    b[i] = b[i - 1] + a[i]
a.reverse()
c[0] = a[0]
for i in range(1, n + 1):
    c[i] = c[i - 1] + a[i]
ans = 0
for i in range(n + 1):
    if i + 1 >= k:
        ans += (c[i] - b[i] + 1)
        ans %= mod
print(ans)
# Judge status: Accepted
a,b,c,x,y = map(int,input().split())
ans = 0
if a+b>2*c:
    if x>y:
        ans = min(c*2*x,c*y*2+(x-y)*a)
    else:
        ans = min(c*2*y,c*x*2+(y-x)*b)
else:
    ans = a*x + b*y
print(ans)
# Judge status: Accepted
from math import gcd
n,start = map(int,input().split())
x_ls = list(map(int, input().split()))
diff_ls = [0] * n

for i in range(n):
    diff_ls[i] = abs(start-x_ls[i])

ans = diff_ls[0]
for i in range(1,n):
    ans = gcd(ans,diff_ls[i])

print(ans)
# Judge status: Accepted
n=int(input())
a=list(map(lambda x:int(x)-1,input().split()))

cnt=0
lis=set()
for i in range(n-1):
    if i in lis:
        continue
    if a[i]==i and a[i+1]==i+1:
        cnt+=1
        lis.add(i+1)
    elif a[i]==i:
        cnt+=1
if n-1 not in lis and a[n-1]==n-1:
    cnt+=1
print(cnt)
# Judge status: Wrong Answer
import bisect
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
for i in range(M):
    B,C = map(int,input().split())
    D = bisect.bisect_left(A,C)
    if D <= B:
        A[:D] = [C]*D
    else:
        A[:B] = [C]*B
print(sum(A))
# Judge status: Accepted
d, t, s = map(int, input().split())
print('Yes') if d/s <= t else print('No')
# Judge status: Wrong Answer
W, a, b = map(int, input().split())
if a + W < b:
    print(b - (a + W))
elif a - W <= b or b <= a + W:
    print('0')
else:
    print(a - (b + W))
# Judge status: Accepted
lst=list(str(input()))
temp=[]
for i in range(4):
  if lst[i] not in temp:
    temp.append(lst[i])
if len(temp)!=2:
  print("No")
else:
  if lst.count(temp[0])==2 and lst.count(lst[1])==2:
    print("Yes")
  else:
    print("No")
# Judge status: Wrong Answer
W, H, x, y = map(int, input().split())

area = W * H / 2
div = 0
if W // 2 == x and H // 2 == y:
    div = 1

print(area, div)
# Judge status: Accepted
n = int(input())
a = int(input())

if (n%500) <= a:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n, y = map(int, input().split())
for i in range(n):
    for j in range(n):
        k = y-(i*10000 + j*5000)
        if k >= 0:
            k = k // 1000
            if i + j + k == n:
                print(i, j, k)
                exit()
print(-1, -1, -1)
# Judge status: Wrong Answer
K,X = map(int,input().split())
num = []
num.append(X)
for i in range(X,X+K-1):
  num.append(X-(i-X+1))
  num.append(i+1)
num.sort()
[print(x,end='') for x in num]
# Judge status: Wrong Answer
S=str(input())
T=str(input())

def longestSubstringFinder(string1, string2):
    answer = ""
    len1, len2 = len(string1), len(string2)
    for i in range(len1):
        match = ""
        for j in range(len2):
            if (i + j < len1 and string1[i + j] == string2[j]):
                match += string2[j]
            else:
                if (len(match) > len(answer)): answer = match
                match = ""
    return answer

print (len(T)-len(longestSubstringFinder(S,T)))
# Judge status: Wrong Answer
from fractions import gcd

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

lcm = int(C*D / gcd(C, D))
nA = A - (int(A/C) + int(A/D) - int(A/lcm))  
nB = B - (int(B/C) + int(B/D) - int(B/lcm))
print(nB - nA)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

leaf = []
miki = []
under = 1

for i, a in enumerate(A):
    can = 2 ** i
    if a > can or under == 0:
        print(-1)
        exit()
    miki.append(under - a)
    under = miki[-1] * 2


ans = 0
child = 0
for i in reversed(range(N + 1)):
    child = min(child, miki[i]) + A[i]
    ans += child

print(ans)
# Judge status: Accepted
a, b, c = map(int, input().split())
print(min((b//a), c))
# Judge status: Accepted
n, m = map(int, input().split())
s = [0 for i in range(n)]
e = [0 for i in range(n)]
for i in range(m):
    x, y = map(int, input().split())
    if x == 1:
        s[y] = 1
    elif y == n:
        e[x] = 1
flag = False
for i in range(n):
    if s[i] == 1 and e[i] == 1:
        flag = True
        break
if flag:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
# Judge status: Wrong Answer
S = list(input())
S.reverse()
S = ''.join(S)
st = ['maerd','remeard','esare','resare']
ans = 'YES'
while S != '':
    if S[0:5] in st:
        S = S[5:]
    elif S[0:4] in st:
        S = S[4:]
    elif S[0:6] in st:
        S = S[6:]
    else:
        ans = 'NO'
        break
print(ans)
# Judge status: Wrong Answer
N = int(input())
mylist = (input().split(" "))
result = 1

for i in range(N):
    result *= int(mylist[i])
    if result > 10 ** 18:
        result = -1
        break
    else:
        continue

print(result)
# Judge status: Accepted
a = int(input())

A=10000
pi=0
for L in range(1,A):
    if L%2==0:
        B=-1
    else:
        B=1
    pi+=(4/(2*L-1))*B

answer = 2*pi*a

print(answer)
# Judge status: Wrong Answer
#ABC-113-B
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
ans = -1
ans_diff = 10**19

for i in range(N):
    tempe = (T-H[i]*0.006)
    if ans_diff > A - tempe:
        ans_diff = A - tempe
        ans = i

print(ans+1)
# Judge status: Accepted
n, a, b = map(int, input().split())
ans = 0

for i in range(1, n + 1):
    istr = map(int, list(str(i)))
    if a <= sum(istr) <= b:
        ans = ans + i

print(ans)
# Judge status: Accepted
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  s = int(input())
  remain   = - s % (10**9) % (10**9)
  quotient = (s + remain) // (10**9)
  print(0, 0, 1, 10**9, quotient, remain)
  
if __name__=='__main__':
  main()
# Judge status: Accepted
import collections
import numpy as np
import sys
sys.setrecursionlimit(10000000)
import copy
#N=int(input())
N,K=map(int,input().split())
D=list(map(int,input().split()))
for i in range(N,100000):
    t=set(map(int,list(str(i))))
    temp=D+list(t)
    temp2=set(temp)
    if len(temp)==len(temp2):
        #print(temp)
        #print(temp2)
        print(i)
        exit()
# Judge status: Accepted
c = [list(map(int,input().split())) for _ in range(3)]

ans = 'Yes'

if not c[0][1] - c[0][0] == c[1][1] - c[1][0] == c[2][1] - c[2][0]:
    ans = 'No'
if not c[0][2] - c[0][1] == c[1][2] - c[1][1] == c[2][2] - c[2][1]:
    ans = 'No'

print(ans)
# Judge status: Accepted
c= input()
print(chr(ord(c)+1))
# Judge status: Accepted
a,b,c = map(int, input().split())
for num in range(a,10**5,a):
    if num%b==c:
        print("YES")
        exit()
print("NO")
# Judge status: Accepted
def main():
  A,B,C,K = map(int, input().split())
  
  sum = 0
  
  if K > A:
    sum += 1 * A
  elif K <= A:
    sum += 1 * K
  
  if K > A + B:
    sum += -1 * (K - (A + B))
  
  print(sum)
  
main()
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
costs = []

for i in range(101):
  cost = 0
  for j in range(N):
    cost += (A[j]-i)**2
  costs.append(cost)
  cost = 0
  for j in range(N):
    cost += (A[j]+i)**2
  costs.append(cost)

print(min(costs))
# Judge status: Wrong Answer
x=int(input())
u=0##初期

## x=500*a+50*b+c d=50*b+c
a=x//500
d=x%500
b=d%5

print(a*1000+b*5)
# Judge status: Accepted
N=int(input())
Ki=[list(map(int,input().split())) for i in range(N)]
f=False
for i in Ki:
  t,x,y=i
  s=x+y
  if (t%2==0 and s%2!=0) or (t%2!=0 and s%2==0) or t<s:
    f=True
    break
if f:
  print('No')
else:
  print('Yes')
# Judge status: Wrong Answer
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
l=[0]*n #得点の列
for i in range(n):
  if t[i]=="r":
    l[i]=p
  elif t[i]=="s":
    l[i]=r
  else:
    l[i]=s
    
res=0
for i in range(n):
  if i>k-1 and l[i-k]==l[i]:
    l[i]=0
  res+=l[i]
  
print(res)
# Judge status: Accepted
a = list(map(int,input().split()))
A = a[0]
B = a[1]

if (A+B) % 2 == 0:
    print((A+B)//2)
else:
    print('IMPOSSIBLE')
# Judge status: Wrong Answer
n,a,b=map(int,input().split())
if n==1 and a!=b:
    print(0)
    exit()
mi=(n-1)*a+b
ma=(n-1)*b+a
print(ma-mi+1)
# Judge status: Accepted
N, W, *t = map( int, open( 0 ).read().split() )
d = [[ 0 for _ in range( W + 1 ) ] for _ in range( N + 1 ) ]
ans = 0
 
i = 0
for w, v in zip( *[ iter( t )] * 2 ):
  for j in range( 1, W + 1 ):
    d[ i + 1 ][ j ] = d[ i ][ j ]
    if j - w >= 0:
      d[ i + 1 ][ j ] = max( d[ i ][ j - w ] + v, d[ i ][ j ] )
  i += 1
print( d[N][W])
# Judge status: Accepted
N, K, Q = map(int, input().split())
answered = [0] * N
passed = 0

for i in range(Q):
    who = int(input())
    answered[who-1] += 1

for point in answered:
    if point > Q - K:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
a, b = 2, 1
for i in range(int(input())-1):
    a, b = b, a+b
print(b)
# Judge status: Accepted
a=input()
b=input()
if a==b[::-1]:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
import math

def main():
    strA = input()
    listA = strA.split(" ")

    N = int(listA[0])
    K = int(listA[1])

    x = N
    y = 0
    while(1):
        x = x/K

        y = y + 1
        if(x < K):
            if K - x > 0:
                y = y + 1
            break

    print(y)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
#!/usr/bin/env python3
import bisect
import sys
import math
sys.setrecursionlimit(10**6)


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

a = []
b = []
ab = []
for i in range(n):
    a_tmp, b_tmp = list(map(int, input().split()))
    a.append(a_tmp)
    b.append(b_tmp)
    # ab.append((b_tmp, a_tmp))

a_max = max(a)
b.sort()

index = bisect.bisect_right(b, a_max)

ans = 0
for i in reversed(range(index, n)):
    h -= b[i]
    ans += 1
    if h <= 0:
        break

if h > 0:
    ans += math.floor(h/a_max)

print(ans)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

ans=0
right=0
left=0
for i in range(n):
    left=min(a[i],b[i])
    ans+=left
    a[i]-=left
    b[i]-=left
    
    right=min(a[i+1],b[i])
    ans+=right
    a[i+1]-=right
    b[i]-=right
print(ans)
# Judge status: Accepted
import math

n = int(input())
print(math.factorial(n) % (10**9 + 7))
# Judge status: Accepted
a,b = map(int,input().split())

if (a*b%2 == 0):
  print("Even")
else:
  print("Odd")
# Judge status: Wrong Answer
n,d = map(int, input().split())
k = n%(2*d + 1)
if k == 0:
  print(n//(2*d+1))
else:
  print(n//(2*d+1))
# Judge status: Accepted
n = int(input())
s = input()

s = list(s)
ans = 0
count = 0

for a in range(1, n):
    l1 = list(set(s[:a]))
    l2 = set(s[a:])

    length1 = len(l1)

    for x in range(length1):
        if l1[x] in l2:
            count += 1
    ans = max(ans, count)
    count = 0

print(ans)
# Judge status: Accepted
N, K = map(int, input().split())

qs = 0
for i in range(1, N+1):
    if i >= K:
        qs += 1/N
    elif i < K:
        q = 1/N
        while i < K:
            q *= 1/2
            i *= 2
        qs += q
print(qs)
# Judge status: Wrong Answer
line_1 = input().split()
N = int(line_1[0])
line_2 = input().split()
M = list(map(int,line_2))

Ms = sum(M)

if Ms-N > 0 :
  print(Ms-N)
else:
  print(-1)
# Judge status: Wrong Answer
N,K,S=map(int,input().split())
for i in range(K):
    print(S,"",end="")
for i in range(K,N):
    print(S+1,"",end="")
print()
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

a_sorted = sorted(a)
divisible_list = [0] * (max(a)+1)

for i in range(len(a)):
    # 過去にすでに同じ数字への加算があったら飛ばす
    if divisible_list[a[i]] > 2:
        continue
    for j in range(0, len(divisible_list), a[i]):
        divisible_list[j] += 1

ans = 0
for i in range(len(a)):
    if divisible_list[a[i]] == 1:
        ans+=1
print(ans)
# Judge status: Accepted
s = input()

num_a = num_b = num_c = 0

for st in s:
    if st == "a":
        num_a += 1
    elif st == "b":
        num_b += 1
    elif st == "c":
        num_c += 1

if max(num_a, num_b, num_c) - min(num_a, num_b, num_c) <= 1:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
n=int(input())
lis=list(map(int,input().split()))
print("Yes" if max(lis)<(sum(lis)-max(lis)) else "No")
# Judge status: Accepted
N=int(input())
B=list(map(int,input().split()))

s=0
for i in range(0,N):
    if i==0:
        s=s+B[0]
    elif i!=N-1:
        s=s+min([B[i-1],B[i]])
    else:
        s=s+B[N-2]
print(s)
# Judge status: Accepted
q,h,s,d=map(int, input().split( ))
n=int(input())#ちょうど
n*=4
lst=[(q*4,q,1),(h*2,h,2),(s,s,4),(d/2,d,8)]
lst.sort()
ans=0
for _,t,x in lst:
    ans+=(n//x)*t
    n-=(n//x)*x
print(ans)
# Judge status: Wrong Answer
n = int(input())
ans = []
cnt = 0
for i in range(1, int(n**(2/3))):
    if n > cnt:
        ans.append(i)
        cnt += i
    else:
        if cnt - n in ans:
            ans.remove(cnt - n)
            break
for i in ans:
    print(i)
# Judge status: Wrong Answer
N = int(input())
S = [sorted(list(input())) for _ in range(N)]
i = 0
A = []
for a in S:
    A.append("".join(a))


print(len(A) - len(set(A)))
# Judge status: Wrong Answer
x = int(input())
if x == 30 or x > 30:
  print('yes')
else: 
  print('no')
# Judge status: Accepted
s = input()
if s == "a" or s == "i" or s == "u" or s == "e" or s == "o":
    print("vowel")
else:
    print("consonant")
# Judge status: Accepted
S = int(input())
Mod = 10**9+7
a=[1]
for i in range(S):
    i += 1
    if i > 2:
        a.append((a[-1] + a[-3])%Mod)
    else:
        a.append(0)
print(a[S])
# Judge status: Accepted
from collections import Counter

s = list(input())
t = list(input())

sc = Counter(s).values()
tc = Counter(t).values()

sl = Counter(sc)
tl = Counter(tc)

if sl == tl:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import copy
N=int(input())
X=list(map(int,input().split()))
B=[]
P=copy.copy(X)
X.sort()
a=X[N//2-1]
b=X[N//2]
for i in range(N):
  if P[i]<=a:
    B.append(b)
  else:
    B.append(a)
for j in range(N):
  print(B[j])
# Judge status: Accepted
from collections import Counter
def main():
    N, P = map( int, input().split())
    A = Counter(list( map( lambda x: int(x)%2, input().split())))
    zero = A[0]
    one = A[1]
    ans = 1
    now = 1
    for i in range(1,one+1):
        now *= (one-i+1)
        now //= i
        if i%2 == 0:
            ans += now
    if P == 0:
        print( ans*pow(2,zero))
    else:
        print(pow(2,N) - ans*pow(2,zero))
        
if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
h = int(input())

n = 0
while 2**n < h:
    n += 1

print(2**n-1)
# Judge status: Wrong Answer
n=list(input())

if int(n[0])>=int(n[1])>=int(n[2]):
    ans = [n[0]]*3
else:
    ans = [int(n[0])+1]*3
print(*ans,sep="")
# Judge status: Accepted
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N = int(input())
    res = INF
    for i in range(1, int(math.sqrt(N))+1):
        if N%i==0:
            res = min(res, i + N//i - 2)
    print(res)


if __name__ == '__main__':
    main()
# Judge status: Accepted
N = list(input())

if ('7' in N):
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
S = input()
strs = list(reversed(S))
rev_S = ''.join(strs)
while True:
  if len(rev_S)< 5:
    break
  elif rev_S[:6] == 'resare'or rev_S[:6] == 'remaerd':
    rev_S = rev_S[6:]
    continue
  elif rev_S[:5] == 'esare' or rev_S[:5] == 'maerd':
    rev_S = rev_S[5:]
    continue
  else:
    break

if rev_S == '':
  print('YES')
else:
  print('NO')
# Judge status: Accepted
import sys
n = int(input())
cake = 0
for i in range(n//4 + 1):
    don = 0
    for j in range(n//7 + 1):
        
        if cake + don == n:
            print("Yes")
            sys.exit()
        don += 7
    cake += 4
print("No")
# Judge status: Accepted
def main():
    a,b,c = (int(x) for x in input().split())
    if (a+b)==c or (a+c)==b or (b+c)==a:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()
# Judge status: Accepted
S = input()
c =  "2018" + S[4:] 
print(c)
# Judge status: Accepted
N,M,Q=map(int,input().split())
SC=[list(map(int,input().split())) for i in range(Q)]

def nextlist(A):
    for i in range(A[-1],M+1):
        yield A+[i]

X=[[1]]
for rep in range(N-1):
    NX=[]
    for x in X:
        NX.extend(nextlist(x))
    X=NX

ANS=0
for x in X:
    score=0
    for a,b,c,d in SC:
        if x[b-1]-x[a-1]==c:
            score+=d
    ANS=max(ANS,score)

print(ANS)
# Judge status: Accepted
N = int(input())
lst = list(map(int, input().split()))
idx = 1
rem = 0
for i in range(N):
    if lst[i] == idx:
        idx += 1
    else:
        rem += 1
if rem == N:
    print(-1)
else:
    print(rem)
# Judge status: Wrong Answer
import math
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
logof2=[0]*N
mi=0
#print(A)
for i in range(N):
    logof2[i]=math.log(A[i],2)
#print(logof2)
for i in range(M):
    if logof2[0]<0:
        break
    else:
        logof2[0]=logof2[0]-1
        logof2.sort(reverse=True)
    #print(logof2)
for i in range(N):
    mi=mi+math.floor(pow(2,logof2[i]))

print(mi)
# Judge status: Wrong Answer
import collections
a=collections.deque(list(input()))
b=collections.deque(list(input()))
c=collections.deque(list(input()))
next_='a'
while len(a)>0 and len(b)>0 and len(c)>0:
    if next_=='a':next_=a.popleft()
    if next_=='b':next_=b.popleft()
    if next_=='c':next_=c.popleft()
    if len(a)==0 or len(b)==0 or len(c)==0: break
print(str(next_).upper())
# Judge status: Accepted
s = list(input())
mi = 10 ** 10
for i in range(len(s) - 2):
    mi = min(mi, abs(753 - int("".join(s[i:i + 3]))))
print(mi)
# Judge status: Accepted
from collections import Counter
N = int(input())
S = [list(input()) for _ in range(N)]
for i in range(N):
    S[i].sort()
    S[i] = ''.join(S[i])
C = Counter(S)
ans = 0
for i in C.values():
    ans += i*(i-1)//2
print(ans)
# Judge status: Accepted
n = []
s = input()
def culc(cur, op_c,ans):
    if op_c == 3:
        if cur == 7:
            print(ans + "=7")
            exit()
    else:
        culc(cur+int(s[op_c+1]), op_c+1, ans + "+" + s[op_c+1])
        culc(cur-int(s[op_c+1]), op_c+1, ans + "-" + s[op_c+1])
culc(int(s[0]), 0, s[0])
# Judge status: Accepted
a, b, k = map(int, input().split())

ans = set()
k = min(k,b-a+1)
for i in range(a, a+k):
    ans.add(i)

for i in range(b, b - k, -1):
    ans.add(i)

ans=sorted(list(ans))

for i in (ans):
    print(i)
# Judge status: Wrong Answer
a =int(input())
print(a+pow(a,2),pow(a,3))
# Judge status: Accepted
import math
a,b = map(str, input().split())
a = int(a)
b = b.replace(".","")
if len(b) == 2:
    b = b + '0'
b = int(b)
ans = a*b
if len(str(ans)) <= 2:
    print(math.floor(ans/100))
else:
    print(int(str(ans)[:-2]))
# Judge status: Wrong Answer
PQR = list(map(int, input().split()))
PQR.sort
print(sum(PQR[:-1]))
# Judge status: Wrong Answer
n, m = map(int, input().split())
an = [input() for _ in range(n)]
bn = [input() for _ in range(m)]
lena = len(an[0])
lenb = len(bn[0])
diff = n-m+1
flag = False
for i in range(diff):
    for j in range(diff):
        if [a[j:diff+j] for a in an[i:diff+i]] == bn:
            flag = True
            break
    else:
        continue
    break
print('Yes' if flag else 'No')
# Judge status: Accepted
def ntukusi(a,b,c):
    return "YES" if (b - a) == (c - b) else "NO"

def main():
    a , b , c = map(int, input().split())
    print(ntukusi(a , b , c))

if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
A_ls = input().split(' ')
A_set = { i for i in A_ls }
if len(A_set) == N:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
h, n = map(int, input().split(' '))
commands = list(map(int, input().split(' ')))

if sum(commands) >= h:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
N = int(input())
s = []
for i in range(N):
    s.append(input())

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

s_set = list(set(s))
t_set = list(set(t))

ans = 0
for i in range(len(s_set)):
    y = 0
    for j in range(N):
        if s_set[i] == s[j]:
            y += 1
    for k in range(M):
        if s_set[i] == t[k]:
            y -= 1
    if y > ans:
      ans = y

print(ans)
# Judge status: Wrong Answer
n=int(input())

print(n*3.141592)
# Judge status: Accepted
def aChristmas(d):

    ans = "Christmas"
    for i in range(abs(25-d)):
        ans += " Eve"
    return ans

def main():
    d = int(input())
    print(aChristmas(d))

if __name__ == '__main__':
    main()
# Judge status: Accepted
mod = 10 ** 9 + 7
x, y = map(int, input().split())
if (x + y) % 3 != 0 or x * 2 < y or y * 2 < x:
    print(0)
    exit()
l = [1]
for i in range(1, (x + y) // 3 + 100):
    l.append(l[-1] * i % mod)
def comb(n, r, m):
    return l[n] * pow(l[r], m - 2, m) * pow(l[n - r], m - 2, m) % m
a, b = y - (x + y) // 3, x - (x + y) // 3
print(comb(a + b, a, mod) % mod)
# Judge status: Wrong Answer
from collections import Counter

N = int(input())
S = list(input())

C = Counter(S)
count = 1
mod = 10*9 + 7
for i in C.values():
    count *= i+1
print((count-1)%mod)
# Judge status: Accepted
N = int(input())
a = [int(x) for x in input().split()]

M = max(a)

C = [0] * (M + 1)

for i in range(N):
    C[a[i]] += 1 

ans = 0

for i in range(1,M):
    wa = C[i - 1] + C[i] + C[i + 1]
    ans = max(ans, wa)

if M <= 1:
    ans = N

print(ans)