Harryxun/stf_run huggingface dataset:
N = int(input())
dic = {}
plis = [2]
for i in range(3,100):
    s =True
    for p in plis:
        if i%p==0:
            s = False
    if s:
        plis.append(i)
for i in range(N):
    foo = 1
    for j in input():
        j = ord(j) - ord("a")
        foo *= plis[j]
    try:
        dic[foo] += 1
    except:
        dic[foo] = 1
ans = 0
for n in dic.values():
    ans += n*(n-1)//2
print(ans)

### FIXED CODE ###

N = int(input())
dic = {}
plis = [2]
for i in range(3,150):
    s =True
    for p in plis:
        if i%p==0:
            s = False
    if s:
        plis.append(i)
for i in range(N):
    foo = 1
    for j in input():
        j = ord(j) - ord("a")
        foo *= plis[j]
    try:
        dic[foo] += 1
    except:
        dic[foo] = 1
ans = 0
for n in dic.values():
    ans += n*(n-1)//2
print(ans)
a = int(input())

aa = 0

un = 0

p = 0

for i in range(a):
  k = input()
  if k == 'A':
    aa += 1
  elif k == 'Un':
    un += 1
  if un > aa:
    p = 1

if aa > un:
  p = 1
  
if p = 0:
  print("YES")
else:
  print("NO")


### FIXED CODE ###

a = int(input())

aa = 0

un = 0

p = 0

for i in range(a):
  k = input()
  if k == 'A':
    aa += 1
  elif k == 'Un':
    un += 1
  if un > aa:
    p = 1

if aa > un:
  p = 1
  
if p == 0:
  print("YES")
else:
  print("NO")
D,N=map(int,input().split())
if N==100:
  (n+1*(100**D)
else:
  print(N*(100**D)


### FIXED CODE ###

D,N=map(int,input().split())
if N==100:
  print((N+1)*(100**D))
else:
  print(N*(100**D))
a,op,b = input().strip()
if(op=='+'):
    print(int(a)+int(b))
else:
    print(int(a)-int(b))

### FIXED CODE ###

#!/usr/bin/env python
num_str = raw_input()
plus = True if '+' in num_str.split() else False
if plus:
	print(int(num_str.split()[0]) + int(num_str.split()[2]))
else:
	print(int(num_str.split()[0]) - int(num_str.split()[2]))
n=int(input())
a=list(map(int,input().split()))
x=[]
for i in a:
  if i%2==0:
    x+=i
for y in x:
  if x=[]:
    print('APPROVED')
  elif y%3!=0 and y%5!=0:
    print('DENIED')
  else:
    print('APPROVED')

    


### FIXED CODE ###

n=int(input())
ans='APPROVED'
a=list(map(int,input().split()))
for x in a:
  if x%2==0:
    if x%3!=0 and x%5!=0:
      ans='DENIED'
      break
print(ans)
import math

n,k = map(int, input().split())

c = 10**9+7

def cmb(n,r):
    return math.factorial(n) / (math.factorial(n-r)*math.factorial(r))

d = n-k
for i in range(1,k+1):
    print(int((cmb(k-1,i-1)*cmb(d+1,i))%c))
    


### FIXED CODE ###

import math

n,k = map(int, input().split())

c = 10**9+7

def cmb(n,r):
    return math.factorial(n) // (math.factorial(n-r)*math.factorial(r))


for i in range(k):
    try:
        print(((cmb(k-1,i)*cmb(n - k+1,i+1))%c))
    except:
        print(0)
from math import sqrt
n=int(input())
s=0
for i in range(int(sqrt(n))):
    d,m=divmod(n,i+1)
    if m == 0:
        if len(set(divmod(n,d-1))) == 1:
            s += d-1
print(s)

### FIXED CODE ###

from math import sqrt
n=int(input())
s=0
for i in range(int(sqrt(n))):
    d,m=divmod(n,i+1)
    if m == 0:
        if d>1 and len(set(divmod(n,d-1))) == 1:
            s += d-1
print(s)
def p(n):
 for i in range(2,x//2):
  if x%i==0:return 0
 return 1
n=int(input())
print(sum([p(int(input()))for _ in range(n)]))

### FIXED CODE ###

import sys
input()
def s():print(sum(2 in[x,pow(2,x,x)]for x in map(int,sys.stdin.readlines())))
if'__main__'==__name__:s()
import math
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input())
before=math.fabs(t-h[0]*0.006-a)
mi=0
for i in range(n-1):
    diff=before-math.fabs(t-h[i+1]*0.006-a)
    if diff>0:
       before=math.fabs(t-h[i+1]*0.006-a)
       mi=i+1
print(mi)

### FIXED CODE ###

import math
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
before=math.fabs(t-h[0]*0.006-a)
num=1
for i in range(n-1):
  diff=before-math.fabs(t-h[i+1]*0.006-a)
  if diff>0:
    before=math.fabs(t-h[i+1]*0.006-a)
    num=i+2
print(num)
from itertools import product
N, K = map(int, input().split())
A = list(map(int, input().split()))
K_bin = bin(K)[2:]
digit = len(K_bin)
B = [bin(a)[2:].zfill(digit) for a in A]
# d桁目の1の個数の，全てのA_iについての総和
C = [0] * digit
for b in B:
    for i, s in enumerate(b):
        if s == '1':
            C[i] += 1
GAIN = [2**i for i in range(digit)][::-1]
maxval = 0
for comb in product(('01'), repeat=digit):
    comb = ''.join(comb)
    if int(comb, 2) > K:
        break
    tmpval = 0
    for i in range(digit):
        res = C[i] if comb[i] == '0' else (N - C[i])
        tmpval += GAIN[i] * res
    maxval = max(maxval, tmpval)
print(maxval)

### FIXED CODE ###

from itertools import product
N, K = map(int, input().split())
A = list(map(int, input().split()))
K_bin = bin(K)[2:]
digit = max(len(K_bin), len(bin(max(A))[2:]))
K_bin = K_bin.zfill(digit)
B = [bin(a)[2:].zfill(digit) for a in A]
# d桁目の0の個数の，全てのA_iについての総和
C = [0] * digit
for b in B:
    for i, s in enumerate(b):
        if s == '0':
            C[i] += 1
ideal = ''
for c in C:
    binary = '1' if c > N//2 else '0'
    ideal += binary
dp = [[0 for _ in range(2)] for _ in range(digit)]
cands = [0]
gain = [2**i for i in range(digit)][::-1]

def calc(s):
    ret = 0
    for i in range(digit):
        tmp = C[i] if s[i] == '1' else N-C[i]
        ret += tmp * gain[i]
    return ret

for i in range(digit):
    if K_bin[i] == '1':
        cands.append(calc(K_bin[:i] + '0' + ideal[i+1:]))
print(max(max(cands), calc(K_bin)))
from bisect import bisect_left

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

P = []
Y = []
PY = [[] for _ in range(N+1)]

for _ in range(M):
    p, y = map(int, input().split())
    P.append(p)
    Y.append(y)
    PY[p].append(y)

for i in range(M+1):
    PY[i].sort()

for i in range(M):
    x = bisect_left(PY[P[i]], Y[i]) + 1
    print("%06d%06d" % (P[i], x))

### FIXED CODE ###

from bisect import bisect_left

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

P = []
Y = []
PY = [[] for _ in range(N+1)]

for _ in range(M):
    p, y = map(int, input().split())
    P.append(p)
    Y.append(y)
    PY[p].append(y)

for i in range(N+1):
    PY[i].sort()

for i in range(M):
    x = bisect_left(PY[P[i]], Y[i]) + 1
    print("%06d%06d" % (P[i], x))
N = int(input())
sX = input()

origin_count = sX.count('1')
one_r_count = origin_count -1
zero_r_count = origin_count +1

one_mod = 0
zero_mod =0
for i in range(N):
    if(one_r_count != 0):
        one_mod = (one_mod * 2) + int(sX[i]) % one_r_count
    zero_mod = (zero_mod * 2 ) + int(sX[i]) % zero_r_count

f = [0] * 220000
pop = [0]* 220000

for i in range(1,220000):
    pop[i] = pop[i//2] + i%2
    f[i] = f[i % pop[i]] + 1

onepow = [1] * 220000
zeropow = [1]* 220000

for i in range(1,220000):
    if(one_r_count != '0'):
        onepow[i] = onepow[i-1] * 2 % one_r_count
    zeropow[i] = zeropow[i-1] * 2 % zero_r_count

for i in range(1,N+1):
    if(sX[i-1] == '1'):
        if(one_r_count != 0):
            Xi_n = one_mod - onepow[N-i]
            Xi_n %= one_r_count
            print(f[Xi_n]+1)
        else:
            print(0)
    else:
        Xi_n = zero_mod + zeropow[N-i]
        Xi_n %= zero_r_count
        print(f[Xi_n]+1)



### FIXED CODE ###

N = int(input())
sX = input()

origin_count = sX.count('1')
one_r_count = origin_count -1
zero_r_count = origin_count +1

one_mod = 0
zero_mod =0
for b in sX:
    if one_r_count != 0:
        one_mod = (one_mod * 2 + int(b) )% one_r_count
    zero_mod = (zero_mod * 2  + int(b) )% zero_r_count

f = [0] * 220000
pop = [0]* 220000

for i in range(1,220000):
    pop[i] = pop[i//2] + i % 2
    f[i] = f[i % pop[i]] + 1

onepow = [1] * 220000
zeropow = [1]* 220000

for i in range(1,220000):
    if one_r_count != 0:
        onepow[i] = onepow[i-1] * 2 % one_r_count
    zeropow[i] = zeropow[i-1] * 2 % zero_r_count

for i in range(1,N+1):
    if sX[i-1] == '1':
        if one_r_count != 0:
            Xi_n = one_mod - onepow[N-i]
            Xi_n %= one_r_count
            print(f[Xi_n]+1)
        else:
            print(0)
    if sX[i-1] == '0':
        Xi_n = zero_mod + zeropow[N-i]
        Xi_n %= zero_r_count
        print(f[Xi_n]+1)
s=input()
i=1
while 1:
    if s[i-1]!="1":
        t=i 
        ans=int(s[i-1])
        break
    i+=1
# print(t)
if int(input())<t:
    print(1);exit()
print(ans)

### FIXED CODE ###

s=input()
i=1
while 1:
    if i==len(s)+1:
        print(1);exit()
    if s[i-1]!="1":
        t=i 
        ans=int(s[i-1])
        break
    i+=1
# print(t)
if int(input())<t:
    print(1);exit()
print(ans)
tmp = []

for i in range(1,10):
  for l in range(1,10):
    tmp.append(i*l)

cnt = 0
    
for n in tmp:
  if n == x:
    cnt += 1
    
if cnt == 0:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

x = int(input())

tmp = []

for i in range(1,10):
  for l in range(1,10):
    tmp.append(i*l)

cnt = 0
    
for n in tmp:
  if n == x:
    cnt += 1
    
if cnt == 0:
  print("No")
else:
  print("Yes")
second=input()
first=spitlines(second)
P=first[0]
S=first[1]
count=0
for t in range(0,len(P)-1):
  if P[t]=S[t]:count=count+1
    else count=count
print(count)

### FIXED CODE ###

a=[input() for i in range(2)]
P=a[0]
S=a[1]
count=0
for t in range(len(P)):
  if P[t] != S[t]:
    count=count+1
print(count)
n,m,k=map(int,input().split())
mod=998244353
if m==1:print(0 if k!=n-1 else 1);exit()
fact=[1]*(n-1+1)
inv=[1]*(n-1+1)
for i in range(2,n-1+1):
    fact[i]=i*fact[i-1]%mod
inv[-1]=pow(fact[-1],mod-2,mod)
for i in range(n-1,1,-1):
    inv[i-1]=inv[i]*i%mod
ans=0
po=pow(m-1,n-1,mod)*m%mod
ue=fact[n-1]
iii=pow(m-1,mod-2,mod)%mod
for i in range(k+1):
    ans+=ue*inv[n-1-i]%mod*inv[i]%mod*po%mod
    po*=iii
print(ans%mod)


### FIXED CODE ###

s,d=[input(),input()]
print("Yes") if s==d[:-1] else print("No")
H,W=map(int,input().split(' '))
S=[input().split(' ') for i in range(H)]
row=i+1 if 'snuke' in S[i] for i in range(H)
col='ABCDEFGHIJKLMNOPQRSTUVWXYZ'[S[row-1].index('snuke')]
print(str(col)+str(row))

### FIXED CODE ###

H,W=map(int,input().split(' '))
S=[input().split(' ') for i in range(H)]
row = -1
for i in range(H):
    if 'snuke' in S[i]: row=i+1
col='ABCDEFGHIJKLMNOPQRSTUVWXYZ'[S[row-1].index('snuke')]
print(str(col)+str(row))
import sys

sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def solve(xx,a,b):
    if len(xx)==2:return [a,b]
    k=(a^b).bit_length()-1
    aa=[]
    bb=[]
    for x in xx:
        if x>>k&1==a>>k&1:aa.append(x)
        else:bb.append(x)
    mid=aa[0]
    if mid^1<<k==b:mid=aa[1]
    return solve(aa,a,mid)+solve(bb,mid^1<<k,b)

def main():
    popcnt=lambda x:bin(x).count("1")

    n,a,b=MI()
    if (popcnt(a)&1)^(popcnt(b)&1)==0:
        print("NO")
        exit()

    print("YES")
    print(*solve(list(range(1<<n)),a,b))

main()


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    def parity_onebit(x):
        return bin(x).count("1") & 1

    def make_route(s, g, state):
        if state.count(-1) == 1:
            return [s, g]
        sep_dig = bin(s ^ g)[::-1].find("1")
        s_bit = (s >> sep_dig) & 1
        Lstate = state[:]
        Rstate = state[:]
        Lstate[sep_dig] = s_bit
        Rstate[sep_dig] = 1 - s_bit
        for i in range(16):
            ng = 0
            i_copy = i
            for sk in Lstate[::-1]:
                ng <<= 1
                if sk == -1:
                    ng += i_copy & 1
                    i_copy >>= 1
                else:
                    ng += sk
            ns = ng ^ (1 << sep_dig)
            if ng != s and parity_onebit(ng) != parity_onebit(s) and ns != g:
                break
        res = make_route(s, ng, Lstate)
        state[sep_dig] = 1 - s_bit
        res += make_route(ns, g, Rstate)
        return res

    n, s, g = map(int, input().split())
    if parity_onebit(s) == parity_onebit(g):
        print("NO")
        exit()
    ans=make_route(s, g, [-1] * n)
    print("YES")
    print(*ans)
    #print(*[format(a,"b").zfill(n) for a in ans])

main()
s = input()
tgt = ['A', 'C', 'G', 'T']

lst = []
cnt = 0

for x in s:
  if x in tgt:
    cnt = cnt +1
  else:
    lst.append(cnt)
    cnt = 0

print(max(lst)


### FIXED CODE ###

s = input()
tgt = ['A', 'C', 'G', 'T']

lst = []
cnt = 0

for x in s:
  if x in tgt:
    cnt = cnt +1
  else:
    lst.append(cnt)
    cnt = 0
    
lst.append(cnt)

print(max(lst))
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = [x - 1 for x in A]

id = [-1] * N
x = A[0]
l = 0
a = []
while id[x] == -1:
    a.append(x)
    id[x] = l
    l += 1
    x = A[x]

if K <= l:
    print(a[K] + 1)
else:
    print(a[K % (l - id[x]) - 1] + 1)


### FIXED CODE ###

N, K = map(int, input().split())
A = [-1] + list(map(int, input().split()))

id = [-1] * (N + 1)
x = 1
l = 0
a = []
while id[x] == -1:
    a.append(x)
    id[x] = l
    l += 1
    x = A[x]

c = l - id[x]
if K < l:
    print(a[K])
else:
    K -= l
    print(a[id[x] + K % c])
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    N, K = read_values()
    A = read_list()

    D = {}
    L = []

    l = 0
    r = max(A) + 1

    while l != r:
        m = (l + r) // 2 
        k = 0

        for a in A:
            k += (a - 1) // m 
        if k > K:
            l = m + 1
        else:
            r = m

    print(r)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    N, K = read_values()
    A = read_list()

    D = {}
    L = []

    l = 1
    r = max(A) + 1

    while l != r:
        m = (l + r) // 2 
        k = 0

        for a in A:
            k += (a - 1) // m 
        if k > K:
            l = m + 1
        else:
            r = m

    print(r)


if __name__ == "__main__":
    main()
k=int(input())
num=0

while k>0:
  num+=1
  snum=str(num)
  flg=0
  for i in range(0,len(snum)-1):
    if abs(int(snum[i])-int(snum[i+i]))>1:
      flg=1
      break
  if flg==0:
    k-=1
print(num)

### FIXED CODE ###

k=int(input())
num=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]
keta=0
for i in range(0,k):
  for j in range(0,len(num)-1):
    if num[j]==-1:
      num[j]=1
      keta=j
      break
    elif num[j]!=9 and (num[j+1]==-1 or (num[j]-num[j+1])<1):
      num[j]+=1
      break
  for x in range(j-1,-1,-1):
    num[x]=max(0,num[x+1]-1)

for i in range(keta,-1,-1):
  print(num[i],end='')
print()
n = int(input())
a = list(map(int, input().split()))
s = a[0]
ans = 0
for i in range(1, n):
    ans +=  abs(s + a[i]) + 1 if s * (s + a[i]) >= 0 else 0
    s = -1 * s // abs(s) if s * (s + a[i]) >= 0 else s + a[i]

print(ans)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 10 ** 100
p = lambda x, y: x * y >= 0
po = lambda x, y: abs(x + y) + 1 if p(x, x + y) else 0
popo = lambda x, y: -1 * x // abs(x) if p(x, x + y) else x + y


if a[0] == 0:
    s = [1, -1]
    tmpAns = [1, 1]
    for (_s, _ans) in zip(s, tmpAns):
        for i in range(1, n):
            _ans +=  po(_s, a[i])
            _s = popo(_s, a[i])
        ans = min((ans, _ans))
else:
    s = [a[0], -1 * a[0] // abs(a[0])]
    tmpAns = [0, abs(a[0]) + 1]
    for (_s, _ans) in zip(s, tmpAns):
        for i in range(1, n):
            _ans +=  po(_s, a[i])
            _s = popo(_s, a[i])
        ans = min((ans, _ans))

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

b = a.reverse()
c = b.pop(0)
e = c.apped(0)
print(e)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
b = [0 for l in range(n)]

for i in range(n):
    b[a[i]-1] = i+1

for m in range(n):
    print(b[m],end="")
    print(" ",end="")
n = int(input())
h = list(map(int,input().split()))
c = 0

for i in range(n-1):
    if (h[i+1]-h[i] == 1) and (h[i+2] >= h[i]):
        c += 1
    else:
        pass
if c <= 1:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

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

for i in range(n-1):
    if h[i] <= h[i+1]-1:
        h[i+1] = h[i+1]-1
    elif h[i] == h[i+1]:
        continue
    else:
        c = 1
if c == 1:
    print('No')
else:
    print('Yes')
N, M, K = map(int, input().split())
 
A = input().split()
B = input().split()
 
def solve(A, N, B, M, K):
  
  def cumsum(l):
    rt = []
    s += 0
    for n in l:
      s += n
      rt.append(s)
    return rt
  
  preA = cumsum(A)
  preB = cumsum(B)
  
  total = N + M
  s, e = 0, total - 1
  
  def can_read(num):
    for i in range(N):
      j = num - i - 1
      if j < N and (A[i] + B[j]) <= K
      	return True
    return False
  
  res = 0
  while s < e:
    mid = s + (e - s) / 2
    if can_read(num):
      res = mid
      s = mid + 1
    else:
      e = mid - 1
  
  return res

res = solve(A, N, B, M, K)
print(res)

### FIXED CODE ###

N, M, K = map(int, input().split())
 
A = list(map(int, input().split()))
B = list(map(int, input().split()))
 
def solve(A, N, B, M, K):
  
  def cumsum(l):
    rt = [0]
    s = 0
    for n in l:
      s += n
      rt.append(s)
    return rt
  
  preA = cumsum(A)
  preB = cumsum(B)
  
  s, e = 0, N + M
  
  def can_read(num):
    for i in range(N + 1):
      j = num - i
      if j >= 0 and j < (M + 1) and (preA[i] + preB[j]) <= K:
      	return True
    return False

  res = 0
  while s <= e:
    mid = s + (e - s) // 2
    can = can_read(mid)
    
    if can:
      res = mid
      s = mid + 1
    else:
      e = mid - 1
  
  return res

res = solve(A, N, B, M, K)

print(res)
import numpy as np
K, N = map(int, input().split())
A = list(map(int, input().split()))
new = []
for i in range(N-1):
    new.append(A[i+1]-A[i])
new.append(K + A[0] - A[-1])
new.sort()
print(sum(new[:y-1]

### FIXED CODE ###

K, N = map(int, input().split())
A = list(map(int, input().split()))
new = []
for i in range(N-1):
    new.append(A[i+1]-A[i])
new.append(K + A[0] - A[-1])
new.sort()
print(sum(new[:-1]))
s=input()
asdf=True
deta=tuple(s)
if len(data)==2:
  print("No")
else:
  if s.count(data[0])==2:
    print("Yes")
  else:
    print("No")


### FIXED CODE ###

s = ''.join(sorted(input()))
if(s[0]==s[1] and s[2] == s[3] and s[1] != s[3]):
  print("Yes")
else:
  print("No")
s = string(input())
print(s.count('1'))

### FIXED CODE ###

s = str(input())
print(s.count('1'))
K = int(input())
A, B = map(int, input().split())

s = (B // K) * K
if s => A: #もし最大のKの倍数がA以上ならOK
    print("OK")
else:
    print("NG")

### FIXED CODE ###

k = int(input())
a, b = map(int, input().split())
for i in range(a, b+1):
  if i % k == 0:
    print("OK")
    break
else:
  print("NG")
n, m = map(int, input().split())
mod = 10**9+7
facs = [1] * n
invs = [1] * n
nfac = 1
for i in range(1, n-m+1):
    nfac = nfac * i % mod
    facs[i] = nfac
    invs[i] = pow(facs[i], mod-2, mod)

ans = 1
start = 0
def steps(start, end):
    t = end - start
    pat = 0
    for j in range(-(-t//2)+1):
        pat += (facs[t-j] * invs[j] * invs[t-j-j]) % mod
    return pat

for i in range(m):
    a = int(input())
    end = a-1
    if start == end+1:
        print(0)
        break
    # startからendまで行く方法
    ans *= steps(start, end)
    ans %= mod
    start = a+1
else:
    ans *= steps(start, n)
    ans %= mod
    print(ans)


### FIXED CODE ###

n, m = map(int, input().split())
mod = 10**9+7
facs = [1] * (n-m+1)
invs = [1] * (n-m+1)
nfac = 1
for i in range(1, n-m+1):
    nfac = nfac * i % mod
    facs[i] = nfac
    invs[i] = pow(facs[i], mod-2, mod)

ans = 1
start = 0
def steps(start, end):
    t = end - start
    pat = 0
    for j in range(t//2+1):
        pat += (facs[t-j] * invs[j] * invs[t-j-j]) % mod
    return pat%mod

for i in range(m):
    a = int(input())
    end = a-1
    if start == end+1:
        print(0)
        break
    # startからendまで行く方法
    ans *= steps(start, end)
    ans %= mod
    start = a+1
else:
    ans *= steps(start, n)
    ans %= mod
    print(ans)
while(True):
    a, op, b = input().spilt
    a = int(a)
    b = int(b)
    if(op == '+'):
        print(a+b)
    elif(op == '-'):
        print(a-b)
    elif(op == '*'):
        print(a*b)
    elif(op == '/'):
        print(a//b)
    elif(op == '?'):
        break


### FIXED CODE ###

while(True):
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if(op == '+'):
        print(a+b)
    elif(op == '-'):
        print(a-b)
    elif(op == '*'):
        print(a*b)
    elif(op == '/'):
        print(a//b)
    elif(op == '?'):
        break
#???????????´??° x ?????????????????§???x ?????????????¨????????????????????????????????????°?????????????????????????????????

x = int(import)
print (x ** 3)

### FIXED CODE ###

x = int(input())
print (x ** 3)
import math
a,b,c = map(int, input().split())

if c-b-a>0 and {(c-a-b)**2}-4*a*b>0 :
    print("Yes")
else:
    print("No")

### FIXED CODE ###

import math
a,b,c = map(int, input().split())
x=a**2+b**2+c**2+2*a*b-2*b*c-2*a*c
y=4*a*b

if c-b-a>0 and x-y>0 :
    print("Yes")
else:
    print("No")
import itertools
import math
n=int(input())
l=list(map(int,input().split()))
c = list(itertools.combinations(l, 3))
count=0
r=math.factorial(len(l)) / (math.factorial(len(l) - 3) * 6)
for i in range(r):
    if c[i][0]==c[i][1] or c[i][1]==c[i][2] or c[i][2]==c[i][0]:
        pass
    else:
        if c[i][0]+c[i][1]>c[i][2] and c[i][1]+c[i][2]>c[i][0] and c[i][2]+c[i][0]>c[i][1]:
            count+=1
        else:
            pass
print(count)

### FIXED CODE ###

import itertools
import math
n=int(input())
l=list(map(int,input().split()))
if len(l)<=2:
    print('0')
else:
    c = list(itertools.combinations(l, 3))
    count=0
    r=math.factorial(len(l)) // (math.factorial(len(l) - 3) * 6)
    for i in range(r):
        if c[i][0]==c[i][1] or c[i][1]==c[i][2] or c[i][2]==c[i][0]:
            pass
        else:
            if c[i][0]+c[i][1]>c[i][2] and c[i][1]+c[i][2]>c[i][0] and c[i][2]+c[i][0]>c[i][1]:
                count+=1
            else:
                pass
    print(count)
def main():
    N, M= map(int, input().split())
    
    acList = [False] * N
    waList = [0] * N
    waCount = 0

    for _ in range(M):
        p, s = map(str, input().split())
        p = int(p) - 1
        if atList[p]:
            continue
        if s == "WA":
            waList[p] += 1
            continue
        waCount += waList[p]
        acList[p] = True

    print(sum(acList), waCount)

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    N, M= map(int, input().split())
    
    acList = [False] * N
    waList = [0] * N
    waCount = 0

    for _ in range(M):
        p, s = map(str, input().split())
        p = int(p) - 1
        if acList[p]:
            continue
        if s == "WA":
            waList[p] += 1
            continue
        waCount += waList[p]
        acList[p] = True

    print(sum(acList), waCount)

if __name__ == "__main__":
    main()
n=int(input())
l=[int(input()) for i in range(n)]
s=sum(l)/n
if s-int(s)<int(s)+1-s:
  s=int(s)
else:
  s=int(s)+1
ans=0
for i in l:
  ans+=(s-i)**2
print(ans)

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
s=sum(l)/n
if s-int(s)<int(s)+1-s:
  s=int(s)
else:
  s=int(s)+1
ans=0
for i in l:
  ans+=(s-i)**2
print(ans)