peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n = int(input())
h = [int(i) for i in input().split()]
m = h[0]
s = 0

for i in h:
  if(i > m):
    m = i
  else:
    s += m - i
    
print(s)
# Judge status: Accepted
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
for i in range(n):
    if a[i] <= x:
        ans += 1
        x -= a[i]
    else:
        break
else:
    if x != 0:
        ans -= 1


print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
print(1 if n % k != 0 else 0)
# Judge status: Wrong Answer
import sys

def solve(n):
  ret = 0
  for i in range(n):
    ret += i
  return ret

def cc_export():
  from numba.pycc import CC
  cc = CC('my_module')
  cc.export('solve', '(i4,)')(solve)
  cc.compile()
 
 
if sys.argv[-1] == 'ONLINE_JUDGE':
  cc_export()
  exit()
else:
  from my_module import solve

print(solve(100))
# Judge status: Wrong Answer
n, k = map(int, input().split())

if n % k == 0:
    print(0)
else:
    while n > abs(n-k):
        n = abs(n-k)
print(n)
# Judge status: Accepted
n,m = map(int, input().split())
l = [[] for _ in range(n)]
ac,wa = (0,0)
for i in range(m):
  p,s = input().split()
  p = int(p)
  if s == "AC":
    if s not in l[p-1]:
      l[p-1].append(s)
      ac += 1
      wa += l[p-1].count("WA")
  else:
    l[p-1].append(s)
print(ac,wa)
# Judge status: Accepted
a,b=map(int,input().split())
s=str()
t=str()
for i in range(b):
    s=s+str(a)
for i in range(a):
    t=t+str(b)
print(sorted([s,t])[0])
# Judge status: Accepted
# A - Sharing Cookies

# A,B,A+Bのいずれかが3の倍数かどうか判定する


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

if A % 3 == 0\
or B % 3 == 0\
or (A+B) % 3 == 0:
    print('Possible')
else:
    print('Impossible')
# Judge status: Accepted
n=int(input())
v=list(map(int,input().split()))

for i in range(n):
    min1=v.pop(v.index(min(v)))
    min2=v.pop(v.index(min(v)))
    new=(min1+min2)/2
    v.append(new)
    if len(v)==1:
        print(new)
        exit()
#for i in range(n):
# Judge status: Wrong Answer
import numpy as np

a = np.arange(1, 366)

np.random.shuffle(a)

print(*a, sep='\n')
# Judge status: Wrong Answer
n,m = map(int,input().split())
h = list(map(int,input().split()))
ans = [0]* n
result =0

for j in range(m):
    text = list(map(int,input().split()))

    if h[text[0]-1] < h[text[1]-1]:
        ans[text[0]-1] += 1
    else:
        ans[text[1]-1] += 1

for i in ans:
    if i == 0:
        result +=1
print(result)
# Judge status: Accepted
N=int(input())
dict={}
cnt=0
for a in range(N):
  s="".join(sorted(input()))
  if s in dict:
    dict[s]+=1
    cnt+=dict[s]
  else:
    dict[s]=0
print(cnt)
# Judge status: Accepted
n=int(input())
an=[]
an=[int(input()) for i in range(n)]
s_an=sorted(an,reverse=True)
m_an=max(an)
m_an2=s_an[1]
for i in an:
    if m_an==i:
        print(m_an2)
    else:
        print(m_an)
# Judge status: Wrong Answer
x = input()

if x[-1] in [2,4,5,7,9]:
  print("hon")
elif x[-1] in [0,1,6,8]:
  print("pon")
else:
  print("bon")
# Judge status: Wrong Answer
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

s = s()

cnt0 = 0
cnt1 = 0
for i in range(1,len(s)):
	if i%2 == 0 :
		if s[i] == "0":
			cnt1 += 1
		else:
			cnt0 += 1
	else:
		if s[i] == "1":
			cnt1 += 1
		else:
			cnt0 += 1
print( min(cnt0, cnt1) )
# Judge status: Accepted
l = list(map(int, input().split()))
k = int(input())
l.sort()
print(l[0] + l[1] + l[2] * (2 ** k))
# Judge status: Wrong Answer
s = list(input())
ans = 0
cnt = 0
for i in range(len(s)):
    if s[i] not in ["A", "C", "G", "T"]:
        ans = max(ans, cnt)
        cnt = 0
    else:
        cnt += 1
print(ans)
# Judge status: Wrong Answer
S = input()
N = len(S)
ACGT = []
others = 'BDEFHIJKLMNOPQRSUVWXYZ'
for i in range(N):
    fl = True
    for j in range(i+1,N+1):
        tmp_S = S[i:j]
        M = len(tmp_S)
        for k in range(M):
            if tmp_S[k] in others:
                fl = False
        if fl==False:
            break
        ACGT.append(tmp_S)
print(ACGT)
len_ACGT = [len(x) for x in ACGT]
print(max(len_ACGT)) if len(len_ACGT)>0 else print(0)
# Judge status: Accepted
N = int(input())
S = sorted([int(input()) for i in range(N)])
min_no_ten = float('inf')
for s in S:
    if s % 10 != 0:
        min_no_ten = s
        break
else:
    print(0)
    exit()

total = sum(S)
if total % 10 != 0:
    print(total)
else:
    print(total - min_no_ten)
# Judge status: Accepted
x = list(input())
y = list(input())
if x == list(reversed(y)):
    print("YES")
else:
    print("NO")
# Judge status: Accepted
#dp[i+1][x]:i日目にxを選んだ時の総和の最大値

N = int(input())
dp = [[0 for i in range(3)] for j in range(N+1)]
for i in range(N):
    a, b, c = map(int, input().split())
    dp[i+1][0] = max(dp[i][1], dp[i][2]) + a
    dp[i+1][1] = max(dp[i][0], dp[i][2]) + b
    dp[i+1][2] = max(dp[i][0], dp[i][1]) + c

print(max(dp[N][0], dp[N][1], dp[N][2]))
# Judge status: Accepted
n = int(input())
S = [input() for i in range(n)]
m = int(input())
T = [input() for j in range(m)]

ANS = []
for i in range(len(S)):
  p = 0
  q = 0
  for j in range(len(S)):
    if S[i]== S[j]:
      p += 1
  for k in range(len(T)):
    if S[i] == T[k]:
      q += -1
  ANS.append(p+q)

print(max(max(ANS),0))
# Judge status: Accepted
n = int(input())
A = [0]*n
B = [0]*n
for i in range(n):
    a, b = map(int, input().split())
    A[i] = a
    B[i] = b

A.sort()
B.sort()

if n%2 == 1:
    ans = B[n//2]-A[n//2]+1
else:
    ans = B[n//2-1]+B[n//2]-(A[n//2-1]+A[n//2])+1
print(ans)
# Judge status: Accepted
N=int(input())
S=str(input())
x=0
y=0
for i in range(N):
  if S[i]=='I':
    x+=1
  elif S[i]=='D':
    x-=1
  y=max(x,y)

print(y)
# Judge status: Wrong Answer
A, B, X= map(int, input().split())
print("YES" if A+B>=X else "NO")
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
d = dict()
for i in range(N):
    if d.get(A[i]) is None:
        d[A[i]] = 1
    else:
        d[A[i]] += 1
ans = 0
for key, value in d.items():
    if key <= value:
        ans += value - key
    else:
        ans += value
print(ans)
# Judge status: Accepted
#n = int(input())
h,n = map(int,input().split())
lst1 = list(map(int,input().split()))

if h > sum(lst1):
    print("No")
else:
    print("Yes")
# Judge status: Accepted
N = int(input())
S = [input() for i in range(N)]

print(len(set(S)))
# Judge status: Wrong Answer
n, k = map(int, input().split())
if n==k or k==1:
  print(0)
else:
  if abs(n-k)<k:
    print(abs(abs(n-k)-(k)))
  else:
    print(abs(n-k)%k)
# Judge status: Accepted
def solve():
  S = input()
  N = len(S)
  dp1,dp2 = [0]*(N+1),[0]*(N+1)
  dp1[1] = 1
  for i in range(2,N+1):
    dp1[i] = dp2[i-1]+1
    if S[i-1]!=S[i-2]:
      dp1[i] = max(dp1[i-1]+1,dp1[i])
    dp2[i] = dp1[i-2]+1
    if i<4 or S[i-2:i]!=S[i-4:i-2]:
      dp2[i] = max(dp2[i],dp2[i-2]+1)
  ans = max(dp1[-1],dp2[-1])
  return ans
print(solve())
# Judge status: Wrong Answer
a, b, c = map(int, input().split())

if a == b and a == c:
  print('No')
elif a != b and a != c:
  print('No')
else:
  print('Yes')
# Judge status: Accepted
a,b = input().split()
c = int(a+b)
print("Yes" if c**0.5 == int(c**0.5) else "No")
# Judge status: Accepted
s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)
s = "".join(s)
t = "".join(t)
if s == t:
    print("No")
    exit()
ans = [s,t]
ans2 = sorted(ans)
if ans == ans2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N, K = map(int, input().split())

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

C = list(set(A))

B = len(C) 
x = B - K

d = {}

for i in A:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1

d = sorted(d.items(), key=lambda x:x[1])

ans = 0
count = 0

if x<=0:
    print('0')
else:
    for key, value in d:
        ans = ans + value
        count = count + 1
        if count == x:
            print(ans)
            break
# Judge status: Accepted
def main():
    from sys import stdin
    r = stdin.readline()[:-1]
    #r = stdin.readlines()

    x, y = map(int, r.split())
    print(x+y//2)
   
if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
INF = 10 ** 8
dp = [INF] * 100010
dp[0] = 0

for i in range(1, n + 1):
    p = 1
    while p <= i:
        dp[i] = min(dp[i], dp[i - p] + 1)
        p *= 6

    p = 1
    while p <= i:
        dp[i] = min(dp[i], dp[i - p] + 1)
        p *= 9

print(dp[n])
# Judge status: Accepted
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    b = list(map(int, input().split()))
    lst = b[:]
    for i in range(N,0,-1):
        j = i
        a = 0
        while j <=N: a, j = a^lst[j-1], j+i
        lst[i-1] = a
    ans = [i+1 for i in range(N) if lst[i]]
    print(len(ans))
    print(*ans)
    

if __name__ == '__main__':
    main()
# Judge status: Accepted
import numpy as np

import math

import collections

if __name__ == '__main__':
    n = int(input())
    print(int(np.lcm(360,n)/n))
# Judge status: Accepted
n, p = map(int, input().split())
a = list(map(int, input().split()))

odd = [i for i in a if i % 2 == 1]
even = [i for i in a if i % 2 == 0]
ecnt = pow(2, len(even))
ocnt = pow(2, max(len(odd)-1,0))
print(0 if (len(odd) == 0 and p == 1) else ecnt * ocnt)
# Judge status: Wrong Answer
a = sorted(input(), reverse=True)
b = sorted(input(), reverse=True)
aa = ''.join(a)
bb = ''.join(b)
k = sorted([aa, bb])
if k[0] == aa:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
A = int(input())
B = int(input())
l = [1,2,3]
l.remove(A)
l.remove(B)
print(l[0])
# Judge status: Accepted
alfa=['z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y']
n = int(input())
ans=''
while n>0:
    ans+=alfa[n%26]
    n=n-1
    n=n//26

print(ans[::-1])
# Judge status: Wrong Answer
n= int(input())
List = []
for i in range(n):
  x = int(input())
  List.append(x)
List = sorted(List)
total = sum(List)
for item in List:
  if total % 10 == 0:
    total -= item
  else:
    break
print(total)
# Judge status: Wrong Answer
a, b = map(int, input().split())
print(-1 if (([a, b] < [1, 1]) or ([a, b] > [9, 9])) else a * b)
# Judge status: Accepted
a, b, c = map(int, input().split())

print(min(c, b // a))
# Judge status: Accepted
n=int(input())
s=input()
t=list(input())

import re 


ans=s

k=-1
for i in range(n):
    tmp=''.join(t[:i+1])

    if tmp in ans:
        k=i

if k<n-1:
    ans+=''.join(t[k+1:])

print(len(ans))
# Judge status: Accepted
N = int(input())
A = [int(input())for _ in range(N)]
A.sort()
ans = sum(A)
if ans % 10 == 0:
    for a in A:
        if a % 10 != 0:
            ans -= a
            break
    else:
        ans = 0
print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
*p, = sorted(map(int, input().split()))

ans = sum(p[:k])

print(ans)
# Judge status: Accepted
a,b,c = map(int, input().split(" "))
pr=True
count=0
while(a%2==0 and b%2==0 and c%2==0):
    ta,tb,tc=a,b,c
    a=tb/2+tc/2
    b=ta/2+tc/2
    c=ta/2+tb/2
    count += 1
    if ta == a and tb == b and tc == c:
        print(-1)
        pr=False
        break
if pr:
    print(count)
# Judge status: Accepted
n = int(input())
s = list(map(int,input().split()))
c = 0
for i in range(n-2):
    if s[i+1] != min(s[i],s[i+1],s[i+2]) and s[i+1] != max(s[i],s[i+1],s[i+2]):
        c += 1
print(c)
# Judge status: Accepted
import math
n=int(input())
m = [list(map(int, input().split())) for _ in range(n)]
ans=0

for i in range(n):
    for j in range(i+1,n):
        ans+=math.sqrt((m[i][0]-m[j][0])**2 + (m[i][1]-m[j][1])**2)
print(ans*2/n)
# Judge status: Accepted
n = int(input())
print("Yes" if any([n == x * y for x in range(1, 10) for y in range(1, 10)]) else "No")
# Judge status: Wrong Answer
n,m,q = [int(i) for i in input().split()]
p = []
for i in range(q):
  p.append([int(i) for i in input().split()])
dmax = 0
a = [1 for i in range(n)]
while True:
  d = 0
  for i in range(q):
    if a[p[i][1]-1]-a[p[i][0]-1] == p[i][2]:
      d += p[i][3]
  if d > dmax:
    dmax = d
  if a[0] == 10:
    break
  c = 1
  l = a.pop()
  while l==10:
    l = a.pop()
    c += 1
  for i in range(c):
    a.append(l+1)
    
print(dmax)
# Judge status: Accepted
s = input()

if s[2] == s[3] and s[4] == s[5]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())
l = list(map(int, input().split()))

l.sort()

max_num = l.pop(-1)

if max_num < sum(l):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
A, B, K = [int(i) for i in input().split()]

if (A + B) <= K:
    print(0, 0)
elif A <= K:
    print(0, B - (K - A))
else:
    print(A - K, B)
# Judge status: Wrong Answer
a,b = map(int,input().split())
if a <=5:
    print("0")
elif 12 >= a >= 6:
    print("50")
else:
    print(b)
# Judge status: Wrong Answer
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()
ans = 0
a = A[0]
n = 0
for i in range(N):
    if a == A[i]:
        n += 1
    else:
        if n % 2 == 1:
            ans += 1
        n = 0
        a = A[i]
print(ans)
# Judge status: Wrong Answer
n=int(input())
num=[]
l=[]
count=0
for _ in range(n):
    a=int(input())
    l.append(a)
l=sorted(l)
print(l)
for i in l:
    if num==[]:
        num.append(i)
    elif num[0]!=i:
        if len(num)%2!=0:
            count+=1
        num=[i]
    else:
        num.append(i)
print(count)
# Judge status: Accepted
A,B,C = list(map(int,input().split()))
count = B // A
if count < C:
    print(count)
else:
    print(C)
# Judge status: Wrong Answer
N,T=map(int,input().split())
cost=10001
ans=0
for i in range(N):
    c,t=map(int,input().split())
    if t<T and c<cost:
        cost=c
        ans=cost
if ans==0:
    print('TLE')
else:
    print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
MOD = 1000000007

sum_all = 0
p = 1
for i in range(60):
    ones = 0
    zeros = 0

    x = 1 << i
    for a in A:
        if a & x:
            ones += 1
        else:
            zeros += 1

    sum_all += p * ones * zeros % MOD
    p *= 2 % MOD


print(sum_all % MOD)
# Judge status: Accepted
N,D = map(int,input().split())
P = []
for i in range (N):
    P.append(list(map(int, input().split())))
Pi = 0
for i in range(N):
    for j in range(i+1, N):
        Di = 0
        for k in range (D):
            Di += (P[i][k]-P[j][k])**2
        if int(Di**0.5) == Di**0.5:
            Pi += 1
print(Pi)
# Judge status: Accepted
N, K = map( int, input().split() )
import math

print( math.floor( math.log( N, K ) ) + 1 )
# Judge status: Wrong Answer
import math
n,x,t = map(float,input().split())
if n%x == 0:
    c = n/x
else:
    c = math.ceil(n/x)
a = c*t
print(a)
# Judge status: Accepted
s = input()
t = input()

l = len(s)

for i in range(l):
    temp = s[i:]+s[:i]
    if temp == t:
        print("Yes")
        exit()

print("No")
# Judge status: Wrong Answer
N = int(input())

S = input()
l = S
r = S[::-1]
w = [0]*(N+1)
e = [0]*(N+1) 

for i in range(N):
    if l[i] == "W":
        w[i+1] = 1
    
    if r[i] == "E":
        e[i+1] = 1

for i in range(N-1):
    w[i+1] += w[i]
    e[i+1] += e[i]

ans = N
for i in range(N):
    d = w[i-1] + e[N-i-1]
    ans = min(ans,d)

print(ans)
# Judge status: Wrong Answer
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()
now = list(mapint())
from itertools import accumulate
iteration = min(N.bit_length()*2, K)
for k in range(iteration):
    nx = [0]*N
    for i, a in enumerate(now):
        nx[max(0, i-a)] += 1
        if i+a+1<N:
            nx[i+a+1] -= 1
    nx = list(accumulate(nx))
    now = nx[:]
print(*now)
# Judge status: Accepted
A,B,C,D = input()
op = ["+","-"]
 
for i in op:
  for j in op:
    for k in op:
      ans = A+i+B+j+C+k+D
      if eval(ans)==7:
        print(ans+"=7")
        exit()
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))

l_max=max(l)
print('Yes' if l_max<sum(l)-l_max else 'No')
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
a = []
for _ in range(N):
  u, v = map(int, input().split())
  a.append((u, v))
a.sort(key = lambda x: (-x[1], -x[0]))
res = 0
day = 0
for i in range(N):
  u, v = a[i]
  if day + u <= M:
    day += 1
    res += v
print(res)
# Judge status: Accepted
C=[0,0]
C[0]=list(map(str,input()))
C[1]=list(map(str,input()))
ans="NO"
X=C[0][::-1]
if C[1]==X:
    ans="YES"
print(ans)
# Judge status: Accepted
# solution
import io

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

data=n

while k:
  if n%data==m%data==0:
    k-=1
  data-=1
print(data+1)
# Judge status: Accepted
from collections import *
n=int(input())
l=list(map(int,input().split()))
d=defaultdict(int)
for i in l:
    d[i]+=1
x=[]
for i in d:
    if(d[i]>=4):
        x.append(i)
        x.append(i)
    elif(d[i]>=2):
        x.append(i)
x.sort(reverse=True)
if(len(x)<2):
    print(0)
else:
    print(x[0]*x[1])
# Judge status: Wrong Answer
N,P = list(map(int, input().split()))
a = list(map(int, input().split()))
num_odd = sum([i%2== 1 for i in a])
num_even = N - num_odd

ce = 2 ** num_even
co = 2 ** (num_odd - 1)
if P==1:
    if num_odd == 0:
        co = 0

print(co * ce)
# Judge status: Accepted
a,b = input().split()
a = int(a)
b = int(b)
if a==b:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n,x=map(int,input().split())
l=list(map(int,input().split()))
c=0
t=l[0]
for a in l[1:]:
    d=t+a-x
    if d>0:
        if a<d:
            a=0
        else:
            a-=d
        c+=d
    t=a
print(c)
# Judge status: Wrong Answer
n, m = map(int, input().split())
a = list(map(int, input().split()))

x = n - sum(a)
print(x if x > 0 else -1)
# Judge status: Accepted
S=input()
ans,n=0,len(S)
dp=[0]*(2019)
s,dp[0],k=0,1,1
for i in S[::-1]:
  s=(s+int(i)*k)%2019
  k=(k*10)%2019
  ans+=dp[s]
  dp[s]+=1
print(ans)
# Judge status: Accepted
n,x=map(int,input().split())
l=list(map(int,input().split()))
d=[0]
for i in range(n):
  d.append(d[i]+l[i])
  if d[i+1]>x:
    print(i+1)
    break
else:
  print(n+1)
# Judge status: Wrong Answer
if input() == "SUN":
  print(7)
# Judge status: Accepted
A1,A2,A3=map(int,input().split())

if(A1+A2+A3>=22):
    print("bust")
else:
    print("win")
# Judge status: Wrong Answer
n = int(input())
a=list(map(int,input().split()))
forward = []
back = []
result = ''
t = 0
for i in range(n):
    t ^= a[i]
    forward.append(t)
t = 0
for i in range(n-1, -1, -1):
    t ^= a[i]
    back.append(t)

print(forward, back)
for i in range(n):
    if i == 0:
        t = back[n-2]
    elif i == n-1:
        t = forward[n-2]
    else:
        t = forward[i-1] ^ back[n-2-i]
    result += str(t) + ' '

print(result)
# Judge status: Accepted
import collections

S = list(input())

c = collections.Counter(S)

if all([cs == 2 for cs in c.values()]):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N,W=map(int,input().split())
DP=[[0 for j in range(W+1)]for i in range(N+1)]
for i in range(N):
    w,v=map(int,input().split())
    for j in range(1,W+1):
        if j>=w:
            DP[i+1][j]=max(DP[i][j-w]+v,DP[i][j])
        else:
            DP[i+1][j]=DP[i][j]
print(DP[N][W])
# Judge status: Accepted
n = int(input())
li = [list(map(int, input().split())) for _ in range(n)]

ans = 0

for i in range(n-1, -1, -1):
    a = li[i][0]
    b = li[i][1]
    
    a += ans
    
    if a%b == 0:
        continue
    s = b - a%b
    ans += s
    
print(ans)
# Judge status: Accepted
#同じ文字の間隔を2文字以上空ける　abcabcabc,,,,,
s=input()
if len(s)==1:
    print("YES")
    exit()
    
c=[0,0,0]
for i in range(len(s)):
    if s[i]=="a":
        c[0]+=1
    elif s[i]=="b":
        c[1]+=1
    elif s[i]=="c":
        c[2]+=1
if max(c)-min(c)>=2:
    print("NO")
else:
    print("YES")
# Judge status: Accepted
input = raw_input

n = int(input())
q3 = n // 3
q5 = n // 5
q15 = n // 15

out = n * (n+1) // 2 - ( 3 * q3 * (q3+1) // 2 + 5 * q5 * (q5+1) // 2) + 15 * q15*(q15+1) // 2
print(out)
# Judge status: Accepted
import numpy as np
n, m = map(int, input().split())
k = [0] * n
for i in range(n):
    k[i] = list(map(int, input().split()))

b = np.zeros((n, m))
for i in range(n):
    w = k[i]
    for j in range(1, len(w)):
        b[i, int(w[j])-1] = 1
print(sum(b.sum(axis=0) == n))
# Judge status: Accepted
N = int(input())
L = sorted(list(map(int, input().split())))
print("Yes" if L[-1] < sum(L[:-1]) else "No")
# Judge status: Accepted
n=int(input())
l=list(map(int, input().split()))
l.sort()
cnt=0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      if l[i]<l[j] and l[j]<l[k]:
        if l[i]+l[j]>l[k]:
          cnt+=1
print(cnt)
# Judge status: Accepted
S = input()
for i in range(2,len(S)+1,2):
    if S[:(len(S)-i)//2-1] == S[(len(S)-i)//2:len(S)-i-1]:
        print(len(S)-i)
        break
# Judge status: Accepted
C1 = input()
C2 = input()
if C1[0] == C2[2] and C1[1] == C2[1] and C1[2] ==C2[0]:
  print("YES")
else:
  print("NO")
# Judge status: Accepted
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if (V - W) * T >= abs(A - B):
    print("YES")
else:
    print("NO")
# Judge status: Accepted
n=int(input())
k=[]
for i in(range(n)):
  k.append(str(input()))
ac=k.count('AC')
wa=k.count('WA')
tle=k.count('TLE')
re=k.count('RE')
print('AC x',ac)
print('WA x',wa)
print('TLE x',tle)
print('RE x',re)
# Judge status: Accepted
n,a,b=map(int,input().split())
if abs(a-b)%2==0:
  print(abs(a-b)//2)
else:
  temp=min(min(a-1,b-1),min(n-a,n-b))+1  
  print(min(temp+(abs(a-b)-1)//2,min(max(a-1,b-1),max(n-a,n-b))))
# Judge status: Accepted

import math
import itertools
import statistics
#import numpy as np
import collections

a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                count += 1
print(count)
# Judge status: Accepted
A,B,K=map(int,input().split())
if A-K>=0:
  print(A-K,B)
else:
  B=B-(K-A)
  if B<=0:
    print(0,0)
  else:
    print(0,B)
# Judge status: Wrong Answer
a,b,x = map(int,input().split())
if x - a < 0:
    print("No")
else:
    print(("NO","YES")[x-a<=b])
# Judge status: Accepted
#coding:utf-8

N = int(input())

C = str(input())

Lis = [0,0] #["R","W"]

for i in C:
    if i == "R":
        Lis[0] += 1
    else:
        Lis[1] += 1

D = "R" * Lis[0] + "W" * Lis[1]

Lis = [0,0]

for s,t in zip(C,D):
    if (s != t) and (s == "R"):
        Lis[0] += 1
    elif (s != t) and (s == "W"):
        Lis[1] += 1

print("{}".format(max(Lis)))
# Judge status: Wrong Answer
S = list(input())
len_S = len(S)
a = [0]*(len_S+1)
for i, s in enumerate(S):
    if s == '<':
        a[i+1] = a[i]+1
for i, s in enumerate(S[::-1]):
    inv_i = len_S-1-i
    if s == '>':
        a[inv_i] = max(a[inv_i+1]+1, a[inv_i])
print(a)
# Judge status: Accepted
x,y,a,b,c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

eat=p[:x]+q[:y]+r
eat.sort(reverse=True)
ans=sum(eat[:x+y])

print(ans)
# Judge status: Accepted
N = list(input())

ok = False

if N[0]==N[1] and N[1]==N[2]:
    ok =True

if N[1]==N[2] and N[2]==N[3]:
    ok = True

print("Yes" if ok else "No")
# Judge status: Accepted
x,y,a,b,c=map(int,input().split())
taste=[sorted(list(map(int,input().split())),reverse=True) for i in range(3)]
red=taste[0][:x]
green=taste[1][:y]
noclo=taste[2]
print(sum(sorted(red+green+noclo)[-(x+y):]))
# Judge status: Accepted
# -*- coding: utf-8 -*-
"""
Created on Thu Mar 12 01:45:52 2020

@author: Kanaru Sato
"""

n = int(input())
flag = 0

for i in range(1,10):
    if n%i == 0 and n//i <= 9:
        flag = 1
      
if flag == 0:
    print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
n = int(input())
A = list(map(int, input().split()))
A = list(map(lambda x: x//400, A))
#print(A)

import collections
c = collections.Counter(A)
#print(c)
f1 = f2 = 0
for k in c.keys():
    if k >= 8:
        f1 += 1
        f2 += c[k]
if f1 == 0:
    min_ = max_ = len(c.keys())

else:
    min_ = len(c.keys()) -f1
    max_ = sum(c.values())
if max_ >8:
    max_ = 8
if min_ <1:
    min_ = 1
print(min_, max_)