peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
import math
K=int(input())
total = 0

for a in range(1,K+1):
  for b in range(a+1,K+1):
    for c in range(b+1,K+1):
      total += math.gcd(a, math.gcd(b,c) )
total *= 6
for a in range(1,K+1):
  for b in range(a+1,K+1):
    total += math.gcd(a, b)
total *= 6


for a in range(1,K+1):
  total += a

print(total)
# Judge status: Wrong Answer
A=list(map(int,input().split()))

A.sort()
flag=0

if A[0]==5:
    if A[1]==5:
        if A[2]==7:
            print("YES")
            flag+=1
            
if flag==0:
    print("No")
# Judge status: Wrong Answer
S = input()
if S.count('hi') is 0 or S.count('hi') > 10:
    print('No')
print('Yes')
# Judge status: Accepted
s = input()
memo = ''
len_s = len(s)
cnt = 0
ans = 0

for i in range(2 * 10 ** 5):
    ans += 1
    if memo == s[cnt]:
        if cnt == len_s - 1:
            ans -= 1
        memo = s[cnt:cnt + 2]
        cnt += 2
    else:
        memo = s[cnt]
        cnt += 1
    if cnt > len_s - 1:
        break

print(ans)
# Judge status: Accepted
#


def main():
    n, m = map(int, input().split(" "))
    a = [int(s) for s in input().split(" ")]
    total = sum(a)
    lim = total / (4 * m)
    a = sorted(a, reverse=True)
    count = 0
    for i in a:
        if i >= lim:
            count += 1
        else:
            break
    if count >= m:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()
# Judge status: Accepted
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np
import queue

h,n = map(int, input().split())
a = np.array(sorted(list(int(i) for i in input().split()), \
      reverse = True))
print('Yes' if a.sum() >= h else 'No')
# Judge status: Accepted
s, t = input().split(" ")
a, b = map(int, input().split(" "))
u = input()
if u == s:
    a -= 1
else:
    b -= 1
print(a, b)
# Judge status: Wrong Answer
n=int(input())
l=[int(i) for i in input().split()]
m=l[0]
c=0
for i in range(1,n):
    if(l[i]<m):
        c=max(c,m-l[i])
    m=max(l[i],m)
print(c)
# Judge status: Accepted
x, y = map(int, input().split())

a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

if x in a and y in a:
    print("Yes")
elif x in b and y in b:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N=int(input())
pre_t,pre_x,pre_y=0,0,0
reachable=True
for _ in range(N):
  t,x,y=map(int,input().split())
  dist=abs(x-pre_x)+abs(y-pre_y)
  time=t-pre_t
  if dist<=time:
    if dist%2==time%2:
      pre_t,pre_x,pre_y=t,x,y
    else:
      reachable=False
      break
  else:
    reachable=False
    break
  pass
if reachable:print('Yes')
else: print('No')
# Judge status: Wrong Answer
import sys
n = int(input())

if n%4 == 0:
    print('Yes')
else:
    for i in range(n//4+1, 0, -1):
        j = 0
        while i*4+j*7 < n:
            j += 1
        if i*4+j*7 == n:
            print('Yes')
            sys.exit()
    print('No')
# Judge status: Wrong Answer
A=[]
p = int(input())
for i in range(p):
  j,k = input().split()
  A.append([j,k,i+1])
A = sorted(A)
for j,k,l in A:
  print(l)
# Judge status: Accepted
n = int(input())
As = list(map(int, input().split()))

# four = sum([1 for a in As if a%4 == 0])
# odd = sum([1 for a in As if a%2 == 1])
# two = sum([1 for a in As if a%2 == 0 and a%4 != 0])
four = 0
odd = 0
two = 0
for a in As:
    if a % 2 == 1:
        odd += 1
    elif a % 4 == 0:
        four += 1
    else:
        two += 1


if four < two%2 + odd - 1:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
S = input()
print(min(abs(int(S[i:i+3])-753) for i in range(len(S)-2)))
# Judge status: Accepted
N = int(input())
numbers_r = tuple(map(int, input().split(' ')))
numbers_s = sorted(numbers_r)

med_high = numbers_s[N // 2]
med_low = numbers_s[N // 2 - 1]

for number in numbers_r:
    if number == med_low:
        print(med_high)
    elif number == med_high:
        print(med_low)
    elif number < med_low:
        print(med_high)
    elif number > med_high:
        print(med_low)
# Judge status: Wrong Answer
a , b , c, d= map ( int, input ().split())
if (a-b < d) or (b-c < d):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def main():
    import math
    n = int(input())
    inlis = list(map(int, input().split()))
    ans = 0
    for i in range(1, n-1):
        if inlis[i-1] < inlis[i] and inlis[i] < inlis[i+1]:
            ans += 1
        if inlis[i-1] > inlis[i] and inlis[i] > inlis[i+1]:
            ans += 1
    print(ans)
        

    
if __name__ == "__main__":
    main()
# Judge status: Accepted
(n, ), *s = [[*map(int, i.split())] for i in open(0)]
c = 0
for a, b in reversed(s):
    q = (a + c) % b
    c += b * (q > 0) - q
print(c)
# Judge status: Wrong Answer
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
MOD=1000000007

dp=[0]*(n+1)
for i in range(1,n+1):
  if i in a:
    dp[i]=0
  else:
    if i==1:
      dp[i]=1
    elif i==2:
      dp[i]=2
    else:
      dp[i]=dp[i-1]+dp[i-2]
print(dp[n]%MOD)
# Judge status: Accepted
n, m = map(int, input().split())

print(n*(n-1)//2 + m*(m-1)//2)
# Judge status: Accepted
from fractions import gcd
from functools import reduce

def gcd_list(numbers):
  return reduce(gcd, numbers)

n = int(input())
a = list(map(int, input().split()))
gl=[0]
gr=[0]
for i in range(n):
  gl.append(gcd(a[i], gl[-1]))
  gr.append(gcd(a[n-i-1], gr[-1]))
gr=gr[::-1]
ans = 0
for i in range(n):
  ans = max(ans, gcd(gl[i],gr[i+1]))
  
print(ans)
# Judge status: Accepted
from bisect import bisect_right


def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    a.reverse()
    lis = [a[0]]
    for i in range(1, n):
        if a[i] >= lis[-1]:
            lis.append(a[i])
        else:
            lis[bisect_right(lis, a[i])] = a[i]
    print(len(lis))


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n = int(input())
data = list(map(int, input().split()))

def gcd(a, b):
    while b:
        a, b = b, a % b
        # print("a b", a, b)
    return a

left_ = [0] * (n + 1)
right_ = [0] * (n + 1)
ans = []

for i in range(n):
    left_[i] = gcd( left_[i-1], data[i] )

for i in range(n-1, 0, -1):
    right_[i] = gcd( right_[i+1], data[i] )

print( left_ )
print( right_ )

for i in range(n):
    ans += [ gcd( left_[i-1], right_[i+1] ) ]

print( max(ans) )
# Judge status: Accepted
N, K = map(int, input().split())
S = input()
print(S[:K-1] + chr(ord(S[K-1]) - ord('A') + ord('a')) +S[K:])
# Judge status: Wrong Answer
n=int(input())
saisho=10**10
cnt=0
for i in range(n):
    a=int(input())
    if a <= saisho:
        cnt+=1
        saisho=a
    else:
        saisho=min(saisho,a)
print(cnt)
# Judge status: Accepted
n, k, s = map(int, input().split())
if s != 10**9:
  for i in range(n):
    if i < k:
      print(s)
    else:
      print(10**9)
else:
  for i in range(n):
    if i < k:
      print(10**9)
    else:
      print(1)
# Judge status: Accepted
s = int(input())

def f(n):
    if n%2==0:
        return int(n/2)
    else:
        return int(3*n+1)

a=[s]
for i in range(10000000):
    a_last = f(a[i])
    if a_last in a:
        print(i+2)
        break
    a.append(a_last)
# Judge status: Wrong Answer
from functools import reduce
from fractions import gcd

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

X,Y = map(int,input().split())
if lcm(X,Y)//Y > 10**18 or X == Y:
  print(-1)
else:
  print(lcm(X,Y)//Y)
# Judge status: Accepted
import itertools
N = int(input())
Pls = list(map(int,input().split()))
Qls = list(map(int,input().split()))

lis = [i for i in range(1,N+1)]
permutations_lis = itertools.permutations(lis)
i = 0
for case in permutations_lis:
    i += 1
    if list(case) == Pls:
        a = i
    if list(case) == Qls:
        b = i

print(abs(a-b))
# Judge status: Accepted
K, X= map(int, input().split())
total=K*500
if total>=X:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a,b = map(int, input().split())
print('Even' if (a*b)%2==0 else 'Odd')
# Judge status: Accepted
s=input()
if s[len(s)-1]!='s':
    s+="s"
else:
    s+="es"
print(s)
# Judge status: Wrong Answer
n = input()
n = int(n)
if(n%2 == 0):
	n= n/2
else:
	n = (n+1)/2
   
print(n)
# Judge status: Accepted
#!/usr/bin/env python3


def get_points_and_convert(pts):
    x, y = pts
    return x + y, x - y


def main():
    n = int(input())
    points = [
        get_points_and_convert(map(int, input().split()))
        for _ in range(n)
    ]
    plus_coords, minus_coords = list(zip(*points))
    plus_dist = max(plus_coords) - min(plus_coords)
    minus_dist = max(minus_coords) - min(minus_coords)
    print(max(plus_dist, minus_dist))


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
def resolve():
    N = int(input())
    T, A = list(map(int,input().split()))
    H = list(map(int,input().split()))
    ans = 0
    for i in range(1, N):
        if abs(A-T-H[i]*0.006) < abs(A-T-H[ans]*0.006):
            ans = i
    print(ans + 1)

if '__main__' == __name__:
    resolve()
# Judge status: Wrong Answer
def solve(N, As):
    total = 0
    for i in range(N - 1):
        for j in range(i + 1, N):
            total += As[i] * As[j]
    ans = total % (9 ** 9 + 7)
    print(ans)


if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split()))
    solve(N, As)
# Judge status: Wrong Answer
x = list(map(int, input().split()))
ans = 0
for i, xi in enumerate(x):
    if i == 0:
        ans = i + 1
        break
print(ans)
# Judge status: Accepted
import sys
s=input()

for i in range(len(s)):
    for g in range(i,len(s)):
        if "keyence"==s[:i]+s[g:]:
            print("YES")
            sys.exit()
print("NO")
# Judge status: Accepted
def resolve():
    s=list(input())
    output = s.count('1')
    print(output)
resolve()
# Judge status: Wrong Answer
n=int(input()) ; n+=1
A=list(map(int,input().split()))
if n==0:
    if A[0]==1: print(1);exit()
    print(-1);exit()
if A[0]!=0:print(-1);exit()
ANS=[0]*n ;ANS[0]=1
R=[0]*n
for i in range(n-2,-1,-1):
    R[i]=R[i+1]+A[i+1]
#print(R)
for i in range(1,n):
    ANS[i]=min(ANS[i-1]*2-A[i], R[i])
    if ANS[i]<0:print(-1);exit()
print(sum(A)+sum(ANS))
# Judge status: Accepted
N, K = [int(x) for x in input().split()]
P = [int(x) for x in input().split()]

def calc(n):
  return sum(range(1, n + 1)) / n

sums = [0]
s = 0
for i in range(N):
  s += calc(P[i])
  sums.append(s)

max_value = -1
max_index = -1

# print(sums)
for i in range(N - K + 1):
  s = sums[i+K] - sums[i]
  # print(i)
  # print(i+K)
  max_value = max(max_value, s)
  if max_value == s:
    max_index = i

print(max_value)
# print(sum([calc(P[i]) for i in range(max_index, max_index + K)]))
# Judge status: Accepted
A,B,C,X,Y = map(int,input().split())
if A+B <= 2*C:
    ans = A*X+B*Y
elif (A <= 2*C and X>=Y) or (B <= 2*C and X <= Y):
    minAB = min(X,Y)
    ans = 2*C*minAB+(X-minAB)*A+(Y-minAB)*B
else:
    ans = 2*C*max(X,Y)
print(ans)
# Judge status: Accepted
s = input()

A_index = s.index("A")

for i in range(len(s)):
    if s[i] == "Z":
        Z_index = i

print(Z_index - A_index + 1)
# Judge status: Accepted
n = int(input())
count= 0
for i in range(1,n+1):
    if len(str(i)) == 1 or len(str(i)) == 3 or len(str(i)) == 5:
        count+=1
print(count)
# Judge status: Accepted
inputs = open(0).readlines()
n, m = map(int, inputs[0].split())
AB = [list(map(int, AB.split())) for AB in inputs[1:]] 
AB.sort()
ans, count = 0, 0
for a, b in AB:
  if count + b >= m:
    ans += a * (m - count)
    break
  count += b
  ans += a * b
print(ans)
# Judge status: Accepted
S = input()
ch = ["dream", "dreamer", "erase", "eraser"]
while S:
  N = len(S)
  if S[N-5:N] == ch[0] or S[N-5:N] == ch[2]:
    S = S[:N-5]
  elif S[N-6:N] == ch[3]:
    S = S[:N-6]
  elif S[N-7:N] == ch[1]:
    S = S[:N-7]
  else:
    print("NO")
    exit()
print("YES")
# Judge status: Accepted
num=int(input())
print(0 if num==1 else 1)
# Judge status: Wrong Answer
A, B, C, X, Y = map(int, input().split())

K = 2 * C - A - B
S = A*X + B*Y
t =-1 * S * K
z = min(X, Y, t)
Z = max(X, Y)

if K >= 0:
  print(S)
elif S > Z*C*2:
  print(Z*C*2)
else:
  P =S + K* z
  print(P)
# Judge status: Wrong Answer
N, A, B = map(int, input().split())
sum = 0

def FindSumOfDigits(x):
    count = 0
    while x>0:
        count += x%10
        x /= 10
        return count
    
    
for n in range(1, N+1):
    count= FindSumOfDigits(n)
    if A <= count <= B:
        sum += n

print(sum)
# Judge status: Wrong Answer
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

s = rr()
if s[5:5+2] > '04':
  print('Heisei')
else:
  print('TBD')
# Judge status: Wrong Answer
N = int(input())
print(any([(N - 4*i) % 7 == 0 for i in range(N//4)]))
# Judge status: Wrong Answer
N = int(input())
S = input()
now = 0
right = 0
left = 0
add_left = 0
while now < N:
    if S[now] == '(':
        left += 1
    else:
        if left:
            left -= 1
        else:
            add_left += 1
    now += 1
for _ in range(add_left):
    print('(', end='')
print(S, end='')
for _ in range(left):
    print(')', end='')
print()
print('(((()))())')
# Judge status: Wrong Answer
s=input()
a=['Sunny','Cloudy','Rainy','Sunny']

for i in range(2):
  if s==a[i]:
    print(a[i+1])
# Judge status: Accepted
s = input()
l = len(s)
c = 2019
tm = 1
ti = int(s[-1])
co = [0]*2019
co[ti] += 1
for i in range(1, l):
    tm = tm*10 % c
    ti += int(s[l-i-1]) * tm
    ti = ti % c
    co[ti] += 1
if co[0] != 0:
    co[0] += 1
print(sum([i*(i-1)//2 for i in co]))
# Judge status: Accepted
n, x = list(map(int, input().split(' ')))
xs = list(map(int, input().split(' ')))

ns = list(map(lambda n: abs(n - x), xs))


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

result = ns[0]
for i in range(1, n):
    if result > ns[i]:
        result = gcd(result, ns[i])
    else:
        result = gcd(ns[i], result)

print(result)
# Judge status: Accepted
def main():
    N, K = map(int, input().split())
    S = input()
    score = 0
    for i in range(1, N):
        if S[i-1] == S[i]:
            score += 1
    print(min(N-1, score + 2*K))
main()
# Judge status: Wrong Answer
N=int(input())
H=list(map(int,input().split()))
a=0
for i in range(N-1):
  if H[i]>=H[i+1]:
    a+=1
print(a)
# Judge status: Accepted
import sys
input = sys.stdin.buffer.readline
a,b=map(int,input().split())
if a>0:
    print("Positive")
    exit(0)
elif a<=0 and 0<=b:
    print("Zero")
    exit(0)
elif a<0 and b<0:
    num=b-a+1
    if num%2==0:
        print("Positive")
        exit(0)
    else:
        print("Negative")
        exit(0)
# Judge status: Wrong Answer
l,r = list(map(int,input().split()))

l %= 2019
r %= 2019

L = min(l,r)
R = max(l,r)

a = 2019
# print(L,R)
for i in range(L,R+1):
    for j in range(i+1,R+1):
        a = min(a,(i*j)%2019)
if r-l > 2018:
    a= 0

print(a)
# Judge status: Wrong Answer
n_m = input()
sp_n_m = n_m.split()
ai = input()
sp_ai = ai.split()
sum = 0

for num in sp_ai:
  sum += int(num)

th = sum / (4 * int(sp_n_m[1]))

cnt = 0
for num2 in sp_ai:
  if int(num2) > th:
    cnt+= 1

if cnt >= int(sp_n_m[1]):
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
W, H, N = map(int, input().split())

xy = [0, W, 0, H]
judge = True
for n in range(N):
    x, y, a = map(int, input().split())
    a -= 1
    if a<=1 and judge:
        xy[a] = x
        if xy[0] >= xy[1]:
            judge = False
    else:
        xy[a] = y
        if xy[2] >= xy[3]:
            judge = False
area = (xy[1] - xy[0]) * (xy[3] - xy[2])
if not judge:
    area = 0
print(area)
# Judge status: Accepted
#計算でもとまるのか・・・
# 初期入力
import sys
#input = sys.stdin.readline  #文字列では使わない
#*S, = input() 
S =input().strip()
c1 =S.count("1")
c0 =S.count("0")
print(min(c0,c1)*2)
# Judge status: Accepted
s = input()
if s == "ARC":
    print("ABC")
    
else: print("ARC")
# Judge status: Accepted
X, N = list(map(int, input().split()))
p = list(map(int, input().split()))

X_max = X
X_min = X

while True:
    if N == 0 or (X in p) == False:
        print(X)
        break
        break
    X_max += 1
    X_min -= 1
    if (X_min in p) == False:
        print(X_min)
        break
        break
    if (X_max in p) == False:
        print(X_max)
        break
        break
# Judge status: Accepted
N=int(input())
count=0
a=list(map(int,input().split()))
w=[]
s=[]
num=[0]*N
maxi=max(a)
for i in range(N):
  s.append(i-a[i])
  if i+a[i]<N:
    num[i+a[i]]+=1
for i in range(N):
  if s[i]>=0:
    count+=num[s[i]]
print(count)
# Judge status: Accepted
import sys
input = sys.stdin.readline
from collections import *

S = input()[:-1]

if S=='SUN':
    print(7)
elif S=='MON':
    print(6)
elif S=='TUE':
    print(5)
elif S=='WED':
    print(4)
elif S=='THU':
    print(3)
elif S=='FRI':
    print(2)
elif S=='SAT':
    print(1)
# Judge status: Accepted
from fractions import gcd

N = int(input())
A = sorted([int(n) for n in input().split()], reverse=True)

x = A[0]
for i in range(1, N):
    x = gcd(x, A[i])
print(x)
# Judge status: Wrong Answer
A, B = map(int, input().split())
res = sum(i // 1000 == i % 100 for i in range(A, B+1))
print(res)
# Judge status: Accepted
n=int(input())
d=list(map(int,input().split()))
mod=998244353
from collections import Counter

c=dict(Counter(d))
c=sorted(c.items(),key=lambda x: x[0])


if d[0]!=0:
    print(0)
    exit(0)

if c[0][1]!=1:
    print(0)
    exit(0)

for i in range(1,len(c)):
    if c[i][0]!=c[i-1][0]+1:
        print(0)
        exit(0)

ans=1
for i in range(1,len(c)):
    ans*=c[i-1][1]**(c[i][1])

print(ans%mod)
# Judge status: Accepted
A, B, C = map(int, input().split())
if A + B >= C:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import numpy as np
n = int(input())
x = np.array([int(i) for i in input().split()])
p = min(sum((x - np.floor(x.mean())) ** 2), sum((x - np.ceil(x.mean())) ** 2))
print(int(p))
# Judge status: Wrong Answer
s = input()

ans = []
for i in s:
    if i == '0':
        ans.append(i)
    elif i == '1':
        ans.append(i)
    elif i == 'B':
        if len(ans) != 0:
            ans.remove(ans[-1])
print("".join(ans))
# Judge status: Accepted
n,m=map(int,input().split())
if n%2==1:
    [print(i+1,n-i) for i in range(m)]
else:
    [print(i+1,n-i) if i<m/2 else print(i+1,n-i-1) for i in range(m)]
# Judge status: Wrong Answer
A,B=map(int,input().split())
ans=0
for i in range(A,B+1):
    s=str(i);l=len(s)//2
    if s[:l]==s[-l:]:ans+=1
print(ans)
# Judge status: Accepted
s = input()

print(s.replace('?', 'D'))
# Judge status: Accepted
n = int(input())
s = [int(input()) for _ in range(n)]
sum_s = sum(s)
if sum_s%10==0:
    s = sorted(s)
    for i in range(n):
        if s[i]%10!=0:
            sum_s -= s[i]
            break
    if sum_s%10==0:
        print(0)
    else:
        print(sum_s)
else:
    print(sum_s)
# Judge status: Wrong Answer
import math
k = int(input())
ans = 0
for i in range(1,k+1):
  ans += i
  for j in range(i+1,k+1):
    for m in range(j+1,k+1):
      ans += 3*math.gcd(math.gcd(i,j),m)
print(i)
# Judge status: Wrong Answer
n, k = map(int, input().split())
lists = [input() for _ in range(k * 2)]

suspects = set(map(str, set(range(n))))
has_snack = set()
for i, v in enumerate(lists):
    if i % 2 == 1:
        continue
    for j in v.split():
        has_snack.add(j)
obake = suspects - has_snack

print(len(obake))
# Judge status: Accepted
a, b = (map(int, input().split()))
ans = 0
for i in range(2):
    if a > b:
        ans += a
        a -= 1
    else:
        ans += b
        b -= 1
print(ans)
# Judge status: Accepted
import collections
N = int(input())
A = list(map(int, input().split()))
count = collections.Counter(A)
for i in range(N):
  print(count[i+1])
# Judge status: Accepted
tmp = input().split(" ")

A = int(tmp[0])
B = int(tmp[1])
C = int(tmp[2])

print(max([C-A+B,0]))
# Judge status: Accepted
import sys
from collections import Counter
from collections import deque
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

l=[lmp() for i in range(3)]
n1=l[0][0]-l[0][1]
n2=l[0][0]-l[0][2]

for i in range(1,3):

    if n1!=l[i][0]-l[i][1] or n2!=l[i][0]-l[i][2]:
        print("No")
        exit()
print("Yes")
# Judge status: Wrong Answer
Summer_Vac,  HomeWork = map(int, input().split())
SyukuDai = input().rstrip().split(' ')
Ans = Summer_Vac

for i in range(HomeWork):
    Ans = Ans - int(SyukuDai[i])

if Ans > 0 :
    print(Ans)
else : 
    print(-1)
# Judge status: Wrong Answer
a,b=map(int,input().split())
if a or b > 8:
  print(":(")
else:
  print("Yay!")
# Judge status: Wrong Answer
N = int(input())
l = [2, 1]
i = 2
ans =0
if N ==2:
    print(1)
while i < N +1:
    l.append(str(int(l[i-1]) + int(l[i-2])))
    ans = l[i]
    i = i+1
print(ans)
# Judge status: Accepted
N,x = map(int,input().split())
A = list(map(int,input().split()))

ans = 0
for i in range(N-1):
    a = A[i]+A[i+1]
    if a > x:
        m = min(a-x,A[i+1])
        A[i+1] -= m
        ans += m
    a = A[i]+A[i+1]
    if a > x:
        A[i] -= a-x
        ans += a-x
print(ans)
# Judge status: Accepted
H, N = map(int, input().split())
print("Yes" if sum(map(int, input().split())) >= H else "No")
# Judge status: Accepted
l = list(map(int,input().split()))
xr = 0
for i in range(1,6):
  xr ^= i
for i in l:
  xr ^= i
print(xr)
# Judge status: Accepted
s=input()
t=input()
for i in t:
	if i not in s:
		print("No")
		exit(0)
for i in range(-3,len(s)):
	if s==t:
		print("Yes")
		exit(0)
	s=s[-1]+s[:-1]
print("No")
# Judge status: Accepted
a,b,k=map(int,input().split())
if(2*k<=(b-a)):
    for i in range(k):
        print(a+i)
    for i in range(k)[::-1]:
        print(b-i)
else:
    for i in range(b-a+1):
        print(a+i)
# Judge status: Accepted
import math
n = int(input())
food_list = list(map(int, input().split()))
satis_list = list(map(int, input().split()))
moreS_list = list = list(map(int, input().split()))

total = sum(satis_list)

for i in range(n-1):
    if food_list[i] + 1 == food_list[i+1]:
        total += moreS_list[food_list[i]-1]
print(total)
# Judge status: Accepted
a,b,c = map(int, input().split())
if b//a >= c:
    print(c)
else:
    print(b//a)
# Judge status: Accepted
n = int(input())
List = list(map(int,input().split()))
dic = {}
for i in range(n):
  dic[i+1] = 0
for item in List:
  dic[item] += 1
for i in range(n):
  print(dic[i+1])
# Judge status: Accepted
def main2(N,h,K):
    dp = [0] * N
    for i in range(1,N):
        dp[i] = min([dp[j] + abs(h[i] - h[j]) for j in range(max(0, i-K), i)])
    return dp[-1]

N, K = map(int, input().split())
h = list(map(int, input().split()))
print(main2(N,h,K))
# Judge status: Accepted
import math
n, k = map(int, input().split())
al = list(map(int, input().split()))

ans = math.ceil((n-1)/(k-1))
print(ans)
# Judge status: Accepted
#!/usr/bin/env python3
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)

al = 0
bo = 0

for i in range(len(a)):
    if i % 2 == 1:
        bo += a[i]
    else:
        al += a[i]

print(al - bo)
# Judge status: Accepted
H, N = map(int, input().split())
A = map(int, input().split())
if H > sum(A):
    print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
X = list(input())
N = len(X)
LT,RS = 0,0
while X[LT]=="T":
    LT+=1
while X[N-1-RS]=="S":
    RS+=1
print(max(LT,RS)*2)
# Judge status: Accepted
n = int(input())
s = input()
ans = 0
for i in range(1, n+1):
    cnt = 0
    x = s[0:i]
    y = s[i:n+1]
    for j in range(97, 123):
        if chr(j) in x and chr(j) in y:
            cnt += 1
    ans = max(cnt, ans)
print(ans)
# Judge status: Accepted
#058_B
o=input()
e=input()
s=''
for i in range(len(e)):
    s+=o[i]+e[i]
if len(o)>len(e):
    s+=o[-1]
print(s)
# Judge status: Accepted
s=input()
if s=="AAA" or s=="BBB":
  print("No")
else:
  print("Yes")