peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
from heapq import heapify,heappop,heappush
N,M=map(int,input().split())
A=list(map(lambda x:-int(x),input().split()))
heapify(A)
for i in range(M):
    heappush(A,-(-heappop(A)//2))
print(-sum(A))
# Judge status: Accepted


def main():
    N = int(input())
    S = input()

    l = [0]*N
    r = [0]*N
    for i in range(1, N):
        l[i] = l[i-1] + (S[i-1]=="W")
    for i in range(N-1)[::-1]:
        r[i] = r[i+1] + (S[i+1]=="E")

    
    ans = 10**6
    for a, b, in zip(l, r):
        ans = min(a+b, ans)
    print(ans)
    

if __name__ == "__main__":
    main()
# Judge status: Accepted
from sys import stdin

N = int(stdin.readline().rstrip())

As = [int(x) for x in stdin.readline().rstrip().split()]

kazu = [0]*N

for i in range(N-1):
    kazu[As[i]-1] += 1


for i in range(N):
    print(kazu[i])
# Judge status: Accepted
N,K = map(int,input().split())
cnt = [0]*(N+1)
for i in range(K):
    d = int(input())
    num = list(map(int,input().split()))
    for j in range(d):
        cnt[num[j]]+=1
print(cnt.count(0)-1)
# Judge status: Wrong Answer
def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    a.sort()
    diff = []
    for i in range(1,n):
        diff.append(a[i]-a[i-1])
        Min = min(diff)
    if Min==0:
        print(a[0])
        exit()
    tmp = 10**9
    for i in range(n):
        tmp2= a[i]%Min
        if tmp2>0:
            tmp = min(tmp,tmp2)
    print(min(a[0],tmp))
main()
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))

if len(a) != len(set(a)):
  print("NO")
else:
  print("YES")
# Judge status: Accepted
x=int(input())
print(0 if x else 1)
# Judge status: Accepted
n = int(input())
s = input()

l = [0 for i in range(n)]
r = [0 for i in range(n)]
for i in range(1,n):
  rev = -(i+1)
  l[i] = l[i-1] + 1 if s[i-1] == "#" else l[i-1]
  r[rev] = r[rev+1] + 1 if s[rev+1] == "." else r[rev+1]

ans = 1e+9
for i in range(n):
  ans = min(ans, l[i] + r[i])
print(ans)
# Judge status: Accepted
n, T = map(int, input().split())
l = []
for _ in range(n):
    c, t = map(int, input().split())
    l.append([c, t])
    
l.sort()
for i in range(n):
    if l[i][1] <= T:
        print(l[i][0])
        break
    if i == n-1 and l[i][1] > T:
        print('TLE')
# Judge status: Accepted
from collections import defaultdict

b = defaultdict(int)
r = defaultdict(int)

n = int(input())
for i in range(n):
    b[input()] += 1
m = int(input())
for i in range(m):
    r[input()] += 1
ans = 0
for k, v in b.items():
    ans = max(ans, v - r[k])
print(ans)
# Judge status: Accepted
w, a, b = map(int, input().split())
s=0

if a<=b:
    s=b-(a+w)
else:
    s=a-(b+w)

if s<0:
    print(0)
else:
    print(s)
# Judge status: Wrong Answer
N, x = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
prev = A[0]
for i in A[1:]:
    if prev + i > x:
        tmp = prev + i - x
        ans += tmp
        prev = i-tmp
    else:
        prev = i
print(ans)
# Judge status: Wrong Answer
n, m = map(int, input().split())
mod = 10**9+7

if abs(n - m) >= 2:
   print(0)
   exit()

import math

minx = min(n, m)
x = math.factorial(minx) % mod

if n == m:
   print(2*pow(x,2,mod)%mod)
else:
   print(2*pow(x,2,mod)*(x+1)%mod)
# Judge status: Accepted
import sys
import itertools

N = int(input())
A = list(input().split())
A = [int(A[i]) for i in range(N+1)]
MAX = [1 for i in range(N+1)]
A_inter = list(reversed(list(itertools.accumulate(reversed(A)))))

for i in range(N+1):
    if A[i] > MAX[i]:
        print(-1)
        sys.exit()
    elif i != N:
        MAX[i+1] = (MAX[i] - A[i]) * 2
        
print(sum([min(MAX[i], A_inter[i]) for i in range(N+1)]))
# Judge status: Accepted
import itertools
N = int(input())
xy = [[int(x) for x in input().split()] for i in range(N)]
ans = 0
count = 0
for city in itertools.permutations(xy,2):
  ans += ((city[0][0]-city[1][0])**2 + (city[0][1]-city[1][1])**2)**0.5
  count += 1
print(ans/N)
# Judge status: Accepted
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(1,n):
  if a[i]+a[i-1]>x:
    ans+=min(a[i]+a[i-1]-x,a[i])
    a[i]-=min(a[i]+a[i-1]-x,a[i])
    if a[i]+a[i-1]>x:
      ans+=a[i-1]-x
      a[i-1]-=a[i-1]-x
print(ans)
# Judge status: Accepted
n, m = map(int, input().split())
center1 = (m+1) // 2
center2 = center1 + m
for i in range(m):
    if i % 2 == 0:
        a = center1 - i // 2
        b = center1 + i // 2 + 1
    else:
        a = center2 - i // 2
        b = center2 + (i+1) // 2 + 1
    print(f"{a} {b}")
# Judge status: Wrong Answer
x=int(input())
y=list(map(int, input().split()))
t=1
for i in range(x):
	if y[i]<0:
		t=t*-1
	y[i]=abs(y[i])

if y==1:
	print(sum(y))
else:
	print(sum(y)-(min(y)*2))
# Judge status: Wrong Answer
x = []
x.append(int(input()))
x.append(int(input()))
x.append(int(input()))
x.append(int(input()))
x.append(int(input()))
tmp = 0
ans = 0


def a(b):
    c = str(b)
    if c[-1] == 0:
        return b
    else:
        return b - int(c[-1]) + 10


for i in x:
    ans += a(i)
    d = str(i)
    tmp = max(tmp, 10 - int(d[-1]))

print(ans - tmp)
# Judge status: Accepted
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))
mod = 10**9+7

ans = 0
max_digit = 0
for i in range(n):
    max_digit = max(max_digit, len(bin(a[i])))
for i in range(max_digit):
    num1 = np.count_nonzero((a >> i) & 1)  # 1の数
    num2 = n - num1  # 0の数
    ans += pow(2, i, mod) * (num1 * num2) % mod
print(ans % mod)
# Judge status: Accepted
T = list(input())

if len(T) == 1:
    print('D')
    exit()

if T[0] == '?':
    if T[1] == 'P':
        T[0] = 'D'
    else:
        T[0] = 'P'


for i in range(1, len(T)-1):
    if T[i] == '?':
        if T[i - 1] == 'D' and (T[i + 1] == 'D' or T[i + 1] == '?'):
            T[i] = 'P'
        else:
            T[i] = 'D'

if T[-1] == '?':
    T[-1] = 'D'

print(''.join(T))
# Judge status: Accepted
h = int(input())
c = 0
while True:
    if(h==1):
        c = c+1
        break
    else:
        h = h//2
        c=c+1
        c=2*c
print(c)
# Judge status: Wrong Answer
N = int(input())

sum_ = N*(N+1)//2
for i in range(2, N//2+1):
  n = N // i
  sum_ += i*(n*(n+1)//2)

sum_ += (N//2+1 + N) * (N - (N//2+1) + 1) // 2

print(sum_)
# Judge status: Accepted
import math 
s=int(input())
if s<=10**9:
    print(0,0,1,0,0,s)
else:
    b=int(math.ceil(s/10**9))
    a=10**9*b-s
    print(0,0,10**9,1,a,b)
# Judge status: Accepted

def main():
    b = int(input())
    d = dict()

    for i in range(b):
        s = input()
        if s in d:
            d[s] += 1
        else:
            d[s] = 1

    r = int(input())

    for i in range(r):
        s = input()
        if s in d:
            d[s] -= 1
        else:
            d[s] = -1

    print(max(max(d.values()),0))







if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
A = [1, 6, 6**2, 6**3, 6**4, 6**5, 6**6, 9, 9**2, 9**3, 9**4, 9**5]
dp = [1000000] * 300000
dp[0] = 0

for i in range(N):
    for a in A:
        d = dp[i] + 1
        dp[i + a] = min(dp[i + a], d)

print(dp[N])
# Judge status: Accepted
import math
 
a, b = map(int, input().split())
ans = math.ceil((a + b) / 2)
print(ans)
# Judge status: Accepted
x = int(input())
print((x+1)//2)
# Judge status: Wrong Answer
n = int(input())
a = [int(x) for x in input().split()]
ans = 0

for i in a:
  if not i%2:
    break
    
  else:
    ans += 1
    
print(ans)
# Judge status: Accepted
k,s=map(int,input().split())
ans=0
for x in range(k+1):
    for y in range(k+1):
        z = s - x - y
        if z >=0 and z <= k:
            ans+=1
print(ans)
# Judge status: Accepted
N=int(input())
m=list(map(int,input().split()))
t=[]
for i in range(N):
  t.append(0)
for i in range(N):
  t[m[i]-1]+=1
total=0
for i in range(N):
  total+=(t[i]*(t[i]-1))//2
for i in range(N):
  if t[m[i]-1]<2:
    print(total)
  else:
    print(total-(t[m[i]-1]-1))
# Judge status: Accepted
#!/usr/bin/env python3
S={c:list(input()) for c in "abc"}
s="a"
while S[s]:s=S[s].pop(0)
print(s.upper())
# Judge status: Wrong Answer
a,b=map(int,input().split())

if a>8 or b>8:
  print(":(")
else :
  print("yay!")
# Judge status: Wrong Answer
n=int(input())
moto=[0]*n
for k in range(0,n):
  moto[k]=input()
syurui=list(set(moto))
kosu=[0]*len(syurui)
for k in range(0,len(syurui)):
  kosu[k]=moto.count(syurui[k])
answer=[]
for k in range(0,len(syurui)):
  if moto.count(syurui[k])==max(kosu):
    answer.append(syurui[k])
for k in range(0,len(answer)):
  print(answer[k])
# Judge status: Accepted
from collections import Counter

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

a.sort()
cnt = 0
nmax = a[-1]
table = [True] * (nmax+1)
c = Counter(a)

duplicate = []
for i in c.keys():
    if c[i] > 1:
        duplicate.append(i)
for i in a:
    if not table[i]:
        continue
    if not i in duplicate:
        cnt += 1
    for j in range(i*2, nmax+1, i):
        table[j] = False
print(cnt)
# Judge status: Accepted
n,m=map(int,input().split())
a=list(map(int,input().split()))
s=sum(a)
ans=0
for i in a:
    if i>=s/(4*m):
        ans+=1
if ans>=m:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N=int(input())
A=B=list(map(int,input().split()))
s=j=N+1
sum_A=0

if A==sorted(A):
    print(0)
    exit()

for i in range(1,N):
    x=max(B[:s])
    s=B.index(x)
    B[s:j]=[x]*len(B[s:j])
    j=s
    if s==0:
        break
    
print(sum(B)-sum(A))
# Judge status: Accepted
Q, H, S, D = list(map(int, input().split()))
Q *= 8
H *= 4
S *= 2
A = min(Q, H, S, D)
B = int(min(Q, H, S) / 2)
N = int(input())
 
print(int(N//2*A+N%2*B))
# Judge status: Accepted
from collections import defaultdict

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

n = readInt()
a = readInts()
rate = [0]*9


for i in a:
  rate[min(i//400,8)]+=1
base = 8-rate[:-1].count(0)
ma = base+rate[-1]
print(max(base,1),ma)
# Judge status: Wrong Answer
import math
N = int(input())
L = N
if L == 1:
    print(0)
else:
    num = 0
    if L > 100000000:
        limit = int(math.sqrt(L)) + 2
    else:
        limit = L
    for i in range(2, limit):
        if N % i == 0:
            N = N / i
            num = num + 1

    if num == 0:
        print(1)
    else:
        print(num)
# Judge status: Accepted
A = input().split()
A.sort(reverse=True)
print(int(A[0]+A[1])+int(A[2]))
# Judge status: Wrong Answer
a,b,c = map(int,input().split())

x = b - a
y = c - b

if x is y:
  print("YES")
  
else:
  print("NO")
# Judge status: Accepted
n = int(input())
x = [(ind, int(i)) for ind, i in enumerate(input().split())]
x.sort(key=lambda x:x[1])
ans = [None]*n
l = x[n//2-1][1]
r = x[n//2][1]
for ind, (i, _) in enumerate(x):
    if ind<n//2:
        ans[i] = r
    else:
        ans[i] = l
for i in ans:
    print(i)
# Judge status: Accepted
N,K=map(int,input().split())
H=[int(x) for x in input().split()]
H=sorted(H)
ans=0
if N<=K:
    print(0)
    exit()
else:
    for i in range(N-K):
        ans+=H[i]
print(ans)
# Judge status: Accepted
n = int(input())
s = input()
al = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ans = ''
for i in range(len(s)):
    ans += (al[al.index(s[i]) - 26 + n])
 
print(ans)
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
if a==b==c:
    print(-1)
elif a%2!=0 or b%2!=0 or c%2!=0:
    print(0)
else:
    total=0
    while True:
        x=a/2
        y=b/2
        z=c/2
        a=y+z
        b=x+z
        c=x+y
        total+=1
        if a%2!=0 or b%2!=0 or c%2!=0:
            print(total)
            break
# Judge status: Accepted
s1=input()
s2=input()

for i in range(len(s1)):
    s1=list(s1)
    a = s1.pop(-1)
    s1 = ''.join(s1)
    s1 = a+s1
    #print(s1)
    if s1 == s2:
        print('Yes')
        exit()
print('No')
# Judge status: Accepted
n,m = map(int,input().split())


for i in range(1,m+1):
  if i%2==1:
    print(1+i//2,1+i//2+(m+1-i))
  else:
    print(n-i//2+1,n-i//2+1-(m+1-i))
# Judge status: Wrong Answer
n,b=list(map(int,input().split()))

a=[]
for i in range(n-1):
    x=input()
    a.append(x[:-1])
a.append(input())

a.sort()
print("".join(a))
# Judge status: Accepted
a, b, k = map(int, input().split())
print(max(0, a-k), max(0, b-(0 if a >= k else k-a)))
# Judge status: Wrong Answer
from collections import Counter

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

d = Counter(A)

tmp_2 = []
tmp_4 = []
for k, v in d.items():
    if v >= 4:
        tmp_4.append(k)
    elif v >= 2:
        tmp_2.append(k)

ans = 0
if len(tmp_4):
    ans = tmp_4[-1]**2
if len(tmp_2) >= 2:
    ans = max(ans, tmp_2[-1]*tmp_2[-2])
print(ans)
# Judge status: Wrong Answer
x, y = map(int, input().split())

if 0 <= x and x <= y:
    print(y-x)
elif x < 0 and 0 <= y:
    if abs(x) <= y:
        print(1 + y - abs(x))
    else:
        print(-y-x+1)
elif x < y and y < 0:
    print(y-x)
elif 0 <= y and y <= x:
    print(1-y+x+1)
elif y < 0 and 0 <= x:
    print(1+abs(y+x))
elif y < x and x < 0:
    print(1-y+x+1)
# Judge status: Wrong Answer
#import
#import math
#import numpy as np
#= int(input())
#= input()
K, S = map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= {i:[] for i in range(N)}

r = 0

for i in range(K + 1):
    for j in range(K + 1):
        if S - (i + j) <= K:
            r += 1

print(r)
# Judge status: Wrong Answer
n,m=map(int,input().split())
x=[]
sum=0
for i in range(n):
  s=list(map(int,input().split()))
  x+=s
for i in range(1,m+1):
  if x.count(i)==n:
    sum+=1
print(sum)
# Judge status: Accepted
import numpy as np

a, b, c = map(int, raw_input().split())

if b > a:
    temp = a
    a = b
    b = temp

res = c - a
res = res - b
temp = 4*a*b


if res <0:
    print "No"
elif res**2 > temp:
    print "Yes"
else:
    print "No"
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(n):
    if A[i] % 2 == 1 and (i + 1) % 2 == 1:
        ans += 1
print(ans)
# Judge status: Accepted
X,Y,Z=map(int,input().split())
X-=Z
print(X//(Z+Y))
# Judge status: Wrong Answer
n = int(input())

if n % 2 == 0:
	print(n / 2)
elif n % 2 == 1:
	print(n / ((n + 1) / 2))
# Judge status: Accepted
x=list(input())
s=0
t=0
ans=0
for i in range(len(x)):
    if x[i]=="S":
        s+=1

    else:
        if s==0:
            ans+=1
        else:
            s-=1

print(ans+s)
# Judge status: Accepted
N, x = map(int, input().split())
A = sorted(list(map(int, input().split())))

if x>sum(A):
    print(N-1)
    exit()

if x==sum(A):
    print(N)
    exit()

ans = 0
for i in range(N):
    if sum(A[:i]) <= x:
        ans = i
print(ans)
# Judge status: Accepted
N = int(input())
H = list(map(int, input().split()))

flg = True
for i in range(N-2, 0, -1):
    if H[i] - 1 > H[i+1]:
        flg = False
        break
    else:
        if H[i] > H[i+1]: H[i] -= 1
if flg:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
a = input()
c = [int(c) for c in a]

print(c.count(1))
# Judge status: Accepted
N, A, B = map(int, input().split())

ans = 0
for i in range(1, N+1):
  k = list(str(i))
  sum_i = 0
  for j in k:
    sum_i += int(j)
  if A <= sum_i <= B:
    ans += i
    
print(ans)
# Judge status: Accepted
a=input().split()
if a.count('5')==2 and a.count('7')==1:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
import numpy as np
X,N=map(int,input().split())
p=np.array(list(map(int,input().split())))
ans=np.array([X,X])
while True:
  ans+=[-1,1]
  if ans[0] not in p:
    print(ans[0])
    exit()
  if ans[1] not in p:
    print(ans[1])
    exit()
# Judge status: Accepted
n,k=map(int,input().split())
h=list(int(input()) for _ in range(n))
h.sort()
s=[abs(h[i+k-1]-h[i]) for i in range(n-k+1)]
print(min(s))
# Judge status: Wrong Answer
s = list(input())

def check(L):
    if len(L)%2 != 0:
        return False
    
    n = int(len(L)/2)
    if L[:n] == L[n:]:
        #print(L[:n],L[n:])
        return True


#print(check(s))

for i in range(1,len(s)):
    m = len(s) - i
    if check(s[0:m]):
        print(m)
# Judge status: Accepted
N = int(input())
A = [int(x) for x in input().split()]

C = 0
for i in range(0,N,2):
  if A[i] % 2 == 1:
  	C += 1
    
print(C)
# Judge status: Accepted
inputLine = input()

tempStr = inputLine.split(' ')

numSheep = int(tempStr[0])
numWolf = int(tempStr[1])


print("unsafe" if numWolf >= numSheep else "safe")
# Judge status: Accepted
s = input()
ans = []
for i in range(len(s)):
  if s[i] != 'B':
    ans.append(s[i])
  else:
    if len(ans) == 0:
      pass
    else:
      ans.pop()
print(''.join(ans))
# Judge status: Wrong Answer
# A == 10
# B == 2
# C == 1
#最後に50倍

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

x = x / 50
count = 0

for h in range(a +1):
    for i in range(b +1):
        for j in range(c +1):
            if a + b + c == x:
                count += 1
                
print(count)
# Judge status: Wrong Answer
a,b = map(int,input().split())
s = input()

lst = s.split("-")
print(lst)
if len(lst[0]) == a and len(lst[1]) == b and len(lst) == 2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n, m = map(int, input().split())
l = []
c = 0
for _ in range(n):
    l += [list(map(int, input().split()))]
for i, j in sorted(l, key=lambda x: x[0]):
    if j >= m:
        c += m*i
        print(c)
        exit()
    m -= j
    c += i*j
# Judge status: Accepted
from collections import defaultdict

n = int(input())
d = defaultdict(int)

for i in range(1,n+1):
    s = str(i)
    k = (s[0],s[-1])
    d[k] += 1

ans = 0
for i in range(1,n+1):
    s = str(i)
    k = (s[-1],s[0])
    ans += d[k]
print(ans)
# Judge status: Wrong Answer
N,K,T=map(int,input().split())
if N%K==0:
  print((N%K)*T)
else:
  print(((N//K)+1)*T)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

flag = False
for i in range(N):
    if A[i] % 2 == 0:
        if (A[i] % 3 == 0) or (A[i] % 5 == 0):
            flag = True
        else:
            flag = False
            break

if flag == True:
    print("APPROVED")
else:
    print("DENIED")
# Judge status: Accepted
x = int(input())

kaiten=360
while kaiten%x!=0:
  kaiten+=360
  
print(kaiten//x)
# Judge status: Accepted
s = input()
if 'L' in s[::2] or 'R' in s[1::2]:
    print('No')
else:
    print('Yes')
# Judge status: Wrong Answer
from collections import Counter

n = int(input())
c = Counter(map(int, input().split()))
c = sorted((e for e in c.items() if e[1] > 1), key=lambda e: -e[1])
if len(c) < 2:
  print(0)
elif c[0][1] >= 4:
  print(c[0][0] ** 2)
else:
  print(c[0][0] * c[1][0])
# Judge status: Wrong Answer
#8
a,b = input().split()
c = int(a + b)
ans = 0

for i in range(100+1):
    if i*i == c:
        ans = 1
if ans == 0:
    print('No')
else:
    print('Yes')
# Judge status: Accepted
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
L = [0]*N
dic = dict()
dic["r"] = P
dic["s"] = R
dic["p"] = S
dic["0"] = 0
res = 0
for i in range(N):
    if i < N-K and T[i] == T[i+K] and L[i] == 0:
        L[i+K] = 1
    if L[i] == 0:
        res += dic[T[i]]
print(res)
# Judge status: Accepted
import math

n = int(input())
answer = 0
c = 0
b = 0
for i in range(1,n+1):
  b = n//i
  c = i*b*(b+1)/2
  answer = answer + c
print(int(answer))
# Judge status: Wrong Answer
from collections import deque

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

graph = [[] for _ in range(n+1)]
for i in range(m):
    a,b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

print(graph)

dist = [0] * (n + 1)

d=deque()
d.append(1)

while d:
    v = d.popleft()
    
    for i in graph[v]:
        if not dist[i]:
            dist[i] = v
            d.append(i)

ans = dist[2:]
print('Yes')
print(*ans,sep='\n')
# Judge status: Accepted
from functools import lru_cache
N = int(input())
# A * B <= N - 1はいくつありますか？
count = 0
# A ∈ {1, 2, ..., N-1}
for A in range(1, N):
    # B <= (N - 1) // A
    count += (N - 1) // A
print(count)
# Judge status: Accepted
n=int(input())
s=input()

r_cnt=s.count("R")
g_cnt=s.count("G")
b_cnt=s.count("B")

ans=r_cnt*g_cnt*b_cnt

for i in range(n):
    for d in range(n):
        j=i+d
        k=j+d
        if k>=n:break
        if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
            ans -= 1

print(ans)
# Judge status: Wrong Answer
from math import ceil

N = int(input())
is_possible = False

for i in range(ceil(N/4)):
    for j in range(ceil(N/7)):
        if 4*i+7*j == N:
            is_possible = True

if is_possible:
    print("YES")
else:
    print("NO")
# Judge status: Accepted

def main():
    N, K = map(int, input().split())

    ds = []
    current_members = set(range(1,N+1))
    for i in range(K):
        d = int(input())
        members= map(int, input().split())
        current_members -= set(members)
    
    #print(current_members)
    print(len(current_members))


if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
x = list(map(int, input().split()))
ans = float('inf')
energy = []

for i in range(1, 101):
    for j in x:
        energy.append((j - i) ** 2)
    sum_energy = sum(energy)
    if sum_energy < ans:
        ans = sum_energy
    energy = []

print(ans)
# Judge status: Accepted
import sys
import math
S = str(input())
T = str(input())
 
 
d = 0
for i,o in enumerate(S):
        j = 0
        c = 0
        for l in S[i:i+len(T)]:
            if l == T[j]:
                c += 1
            j += 1
        d = max(d, c)
        if i > len(S) - len(T) - 1:
            break
print(len(T)-d)
# Judge status: Accepted
s=int(input())
ans1=s//10**9+1
ans2=10**9-s%10**9
if s==10**18:
  print(0,0,10**9,0,0,10**9)
else:
  print(0,0,10**9,1,ans2,ans1)
# Judge status: Wrong Answer
s= input()
fn1 = "-1"
for i in range(len(s)):
    if s[i] != "1":
        fn1 = s[i]
        break
print("1" if fn1 == "-1" else fn1)
# Judge status: Accepted
X = int(input())
amt = 100
year = 0
while amt < X:
    amt = int(amt * 1.01)
    year += 1
print(year)
# Judge status: Wrong Answer
n = input()
a = map(int, input().split())
ans = 1
for i in a:
  ans *= i
  if ans > 10**18:
    print(-1)
    exit()
print(ans)
# Judge status: Accepted
# coding: utf-8

def main():
    n = int(input())
    count = 0
    for _ in range(n):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            count += 1
        else:
            count = 0
        if count >= 3:
            print('Yes')
            return
    print('No')
    
main()
# Judge status: Accepted
n,l = map(int,input().split())

ans = 0
if l >= 0:
     for i in range(n-1):
          ans += l+i+1
elif l <= 0 <= l+n-1:
     for i in range(n):
          ans += l+i
else:
     for i in range(n-1):
          ans += l + i
print(ans)
# Judge status: Wrong Answer
import sys

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

a_list = [[l for l in input()] for _ in range(n)]
b_list = [[l for l in input()] for _ in range(m)]

for i in range(n-m):
    for j in range(n-m):
        a_list_sub = a_list.copy()
        a_list_sub = a_list[i:i+m]
        a_list2 = [row[j:j+m] for row in a_list_sub]
        if a_list2 == b_list:
            print('Yes')
            sys.exit()

print('No')
# Judge status: Accepted
a, b = map(int, input().split())
print((a+b)//2 if (a+b)%2 == 0 else "IMPOSSIBLE")
# Judge status: Accepted
x, y = map(int, input().split())
ans = abs(abs(x)-abs(y))

if abs(y) > abs(x):
    if x < 0:
        ans += 1
    if y < 0:
        ans += 1

else:
    if x > 0:
        ans += 1
    if y > 0:
        ans += 1
print(ans)
# Judge status: Wrong Answer
# AtCoder
N, M = map(int, input().split())
A = list(map(int, input().split()))

sm = sum(A)
count = N - sm
print(count)
# Judge status: Wrong Answer
N = int(input())
nums = list(map(int,input().split()))
sum = 0

for i in range(N):
  for j in range(N):
    if i == j or i > j :
      continue
    else:
      sum += nums[i]*nums[j]
      
print(sum%10**9+7)
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
k=int(input())

kazu=[a,b,c]
kazu.sort()
#print(kazu)
print(a+b+kazu[2]*2**k)
# Judge status: Accepted
n,k=map(int,input().split())
d=list(input().split())
for j in range(n, 100000):
    flg=False
    for s in set(str(j)):
        if s in d:
            flg=True
            break
    if flg==False:
        print(j)
        break