peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n, a = [int(input()) for i in (0,0)]
print("YNeos"[n%500>a::2])
# Judge status: Accepted
from collections import defaultdict
n, m = map(int, input().split())
r = set()
r.add(1)
d = defaultdict(int)
for i in range(m):
  x, y = map(int, input().split())
  d[x] -= 1
  d[y] += 1
  if x in r:
    r.add(y)
  if d[x] == -1 and x in r:
    r.remove(x)
ans = len(list(r))
for e in d:
  if d[e] == -1 and e in r:
    ans -= 1
print(ans)
# Judge status: Accepted
n = int(input())

ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
    w = input()
    if(w == 'AC'):
        ac += 1
    elif(w == 'WA'):
        wa += 1
    elif(w == 'TLE'):
        tle += 1
    elif(w == 'RE'):
        re += 1

print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))
# Judge status: Accepted
import sys
W,H,x,y = map(int, input().split())

ans = W * H / 2

if W / 2 == x and H / 2 == y:
  print("{} {}".format(ans, 1))
else:
  print("{} {}".format(ans, 0))
# Judge status: Wrong Answer
a,b,x=map(int,input().split())
b1=b//x
a1=a//x
print(b1-a1)
# Judge status: Accepted
import fractions

n,x=map(int,input().split())
l=list(map(int,input().split()))

l.append(x)
sl=sorted(l)

lis=[sl[i+1]-sl[i] for i in range(n)]

ans=0
for i in range(0, n):
    ans = fractions.gcd(ans, lis[i])
    
print(ans)
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))
cnt = 0
sum_ = 0
min_ = float('Inf')
for i in range(N):
    if a[i] < 0:
        cnt += 1
    min_ = min(min_, abs(a[i]))
    sum_ += abs(a[i])
if cnt % 2 == 0:
    print(sum_)
else:
    print(sum_ - 2 * min_)
# Judge status: Accepted
d,t,s = map(int,input().split())
a = d / t
if a > s:
    print("No")
else:
    
    print("Yes")
# Judge status: Wrong Answer
def dist(p1,p2):
  r=0
  for a,b in zip(p1,p2):
    r+=(a-b)**2
  return r

def isSqrt(n):
  i=1
  while i*i<n:
    i+=1
  return i==n
    
N,D = map(int,input().split())
P=[list(map(int,input().split())) for _ in range(N)]
ans=0
for i in range(N):
  for j in range(i):
    d = dist(P[i],P[j])
    if d==int(d):
      ans+=1
print(ans)
# Judge status: Accepted
N = int(input())
dic = {}
for i in range(N):
  A = int(input())
  if A not in dic:
    dic[A]=1
  else:
    dic[A]^=1
print(sum(dic.values()))
# Judge status: Accepted
n, h = map(int, input().split())
a, b = [], []
for _ in range(n):
    ai, bi = map(int, input().split())
    a.append(ai), b.append(bi)
a.sort(), b.sort()

ans, amax = 0, a[-1]
for bi in b[::-1]:
    if bi <= amax or h<=0:
        break
    h -= bi
    ans += 1
print(ans + h // amax + (h % amax > 0) if h > 0 else ans)
# Judge status: Accepted
s = input()

c = 'hi' * int(len(s)/2)

if s == c:
   print('Yes')
else:
   print('No')
# Judge status: Wrong Answer
n = int(input())

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

ans = 0
tmp = 0

for i in range(1,n):
    if lis[i-1] >= lis[i]:
        tmp += 1
    else:
        if tmp >= ans:
            ans = tmp
            tmp = 0

    if tmp >= ans:
        ans = tmp
print(ans)
# Judge status: Wrong Answer
n,k,x,y=[int(input()) for i in range(4)]
print(k*x+max(0,n-k)*y)
# Judge status: Accepted
import heapq
import math
 
def LI():
  return [int(s) for s in input().split()]
 
N,M = LI()
a = LI()
a = list(map(lambda x: x*(-1), a))  # 各要素を-1倍
 
heapq.heapify(a)
 
for i in range(M):
    x = (-1)*(abs(heapq.heappop(a))//2)
    heapq.heappush(a,x)

cost = 0
for i in range(N):
  x = heapq.heappop(a)
  cost+=abs(x)
  
print(cost)
# Judge status: Accepted
N = input()
print('Yes' if (N[0] == N[1] and N[1] == N[2]) or (N[1] == N[2] and N[2] == N[3]) else 'No')
# Judge status: Accepted
import sys

input = sys.stdin.readline

def main():
    ans = 0
    a, b, c = map(int, input().split())
    while a%2 == b%2 == c%2 == 0:
        ans += 1
        ta = a//2
        tb = b//2
        tc = c//2
        a = tb + tc
        b = ta + tc
        c = ta + tb
        if a == b == c:
            ans = -1
            break
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
n,m=map(int,input().split()) 
l=list(map(int,input().split())) 
print(-(-(len(l)-m)//(m-1))+1)
# Judge status: Accepted
n,y=map(int,input().split())

for i in range(n+1):
    for j in range(n+1-i):
        k=n-i-j
        if 10000*i+5000*j+1000*k == y:
            print(i,j,k)
            exit()

print(-1,-1,-1)
# Judge status: Wrong Answer
if __name__ == "__main__":
    n = int(input())
    a=[]
    for i in range(n):
        x,y = map(int,input().split())
        a.append(x+y)
    print(max(a)-min(a))
# Judge status: Accepted
S, T = input().split();
A = list(map(int, input().split()));
U = input();

if U == S:
  A[0] = A[0] - 1;
elif U == T:
  A[1] = A[1] - 1;

print(A[0], A[1])
# Judge status: Accepted
A, B, C = [int(x) for x in input().split()]

ans = 'NO'

for i in range(1, B - 1):
    if (i * A) % B == C:
        ans = 'YES'
        break
print(ans)
# Judge status: Accepted
def resolve():

    N,M=map(int,input().split())
    cnt=0
    if N*2>=M:
        print(M//2)
    else:
        cnt+=N
        M-=N*2
        cnt+=M//4
        print(cnt)


resolve()
# Judge status: Accepted
S=input()
N=len(S)
from collections import Counter
C=Counter(S)
mn=N
mx=0
for c in ['a','b','c']:
    mx=max(mx,C[c])
    mn=min(mn,C[c])
print('YES' if mx-mn<=1 else 'NO')
# Judge status: Accepted
n = int(input())

flag = False
ans = 0
for i in range(50001):
    if int(i * 1.08) == n:
        flag = True
        ans = i
        break
print(ans if flag else ":(")
# Judge status: Accepted
a, b = map(int,input().split())

if a*b <= 0:
    print("Zero")
else:
    if a > 0 and b > 0:
        print("Positive")
    else:
        memo = b-a
        if memo%2 == 0:
            print("Negative")
        else:
            print("Positive")
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
l=[]
r=[]
for i in range(len(a)):
  if i%2==0:
    r.append(a[i])
  else:
    l.append(a[i])
t=l[::-1]+r
if n%2==0:
  print(*t)
else:
  print(*t[::-1])
# Judge status: Accepted
n, m = map(int, input().split())
ok_step = [True for i in range(n + 1)]
dp = [0 for i in range(n + 1)]

for i in range(m):
    broken = int(input())
    ok_step[broken] = False

dp[0] = 1
for now in range(n):
    for next in range(now + 1, min(n, now + 2) + 1):
        if ok_step[next]:
            dp[next] += dp[now]
            dp[next] %= 10**9 + 7
print(dp[n])
# Judge status: Wrong Answer
a,b=map(int,input().split())
b=b*2+1
c=0
c=a/b
if c>1:
  print(c+1)
else:
  print(c)
# Judge status: Wrong Answer
n = str(input())
s = str(input())
if n[0]== s[2]and n[1]==s[1] and n[2]== s[0]:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())
ans = 0

for j in range(1, n+1):
  y = n//j
  ans += j*y*(y+1)//2
  
print(ans)
# Judge status: Wrong Answer
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
if even(n):
    print(-1)
    exit()
s = "7"
count = 1
while True:
    if int(s) <= n:
        s = s+"7"
        count += 1
        continue
    else:
        res = int(s)%n
        if res == 0:
            print(count)
            exit()
        s = str(int(s)%n)
# Judge status: Accepted
#template
def inputlist(): return [int(j) for j in input().split()]
from collections import Counter
#template
#issueから始める
N = int(input())
s = list(input())
ans = -1
for i in range(N):
    lif = s[:i]
    lib = s[i:]
    cf= list(Counter(lif).keys())
    cb= list(Counter(lib).keys())
    k = len(cf) + len(cb) - len(set(cf+cb))
    ans = max(ans,k)
print(ans)
# Judge status: Wrong Answer
n,a,b = map(int,input().split())
if a+b>=n:
    print(a)
elif a == 0:
    print(0)
else:
    c = n//(a+b)
    d = n%(a+b)
    if a>d:
        print(c*a + d)
    else:
        print(c*a + a)
# Judge status: Wrong Answer
n,a,b = map(int,input().split())
s=input()

AB=0
B=0
for i in range(n):
    if s[i] =='a':
        if AB<a+b:
            AB+=1
            print('Yes')
        else:
            print('No')
    elif s[i] =='b':
        if AB<a+b and AB<=b:
            AB+=1
            B+=1
            print('Yes')
        else:
            print('No')
    else:
        print('No')
# Judge status: Wrong Answer
n = int(input())
A = list(map(int, input().split()))
num = 1
ans = 0
for i in range(n):
  if A[i] == num:
    num += 1
    ans += 1
print(n-ans)
# Judge status: Accepted
n = int(input())

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

total = sum(stick)
mid = total // 2

cum = 0
midi = 0
for i, block in enumerate(stick):
    cum += block
    if cum >= mid:
        midi = i
        break

l1 = stick[:midi]
r1 = stick[midi:]
diff1 = abs(sum(l1) - sum(r1))
 
l2 = stick[:midi+1]
r2 = stick[midi+1:]
diff2 = abs(sum(l2) - sum(r2))
 
print(min(diff1, diff2))
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = list(input())
k = int(input())
for i in range(len(s)):
    num = (ord('z') - ord(s[i]) + 1) % 26
    if num <= k:
        k -= num
        s[i] = 'a'
s[-1] = chr((ord(s[-1]) - ord('a') + k) % 26 + ord('a'))
print(*s, sep='')
# Judge status: Accepted
import sys

sys.setrecursionlimit(1000000)



def main():
    n, k = map(int, input().split())

    has_set = set()
    a_dic = {}
    for i in range(k):
        input()
        for z in list(map(int, input().split())):
            has_set.add(z)

    print(n-len(has_set))




main()
# Judge status: Wrong Answer
import numpy as np
N, M = map(int, input().split())
c = []
for _ in range(M):
    a, b= map(int, input().split())
    c.append(a)
    c.append(b)
for i in range(N):
    print(c.count(i+1))
print(c)
# Judge status: Accepted
# coding: utf-8
A, B = map(int, input().split())
lst = []
for i in range(1, 10):
    for j in range(0, 10):
        for k in range(0, 10):
            lst.append(i * 10000 + j * 1000 + k * 100 + j * 10 + i)

ans = [0 for i in lst if A <= i <= B]
print(len(ans))
# Judge status: Wrong Answer
n = int(input())
count=0
#p = [input() for i in range(n)]
p=list(map(int,input().split()))
for i in range(n-2):
    if p[i]<p[i+1] and p[i+2]>p[i+1]:
        count+=1
print(n-count)
# Judge status: Accepted
import string
a2z = string.ascii_lowercase

def routine(X, n):
   div = X//n if X % n > 0 else X//n - 1
   if div:
      return routine(div, n)+a2z[X%n-1]
   return a2z[X%n-1]

print(routine(int(input()), 26))
# Judge status: Wrong Answer
N,K=map(int,input().split())
num=[list(map(int,input().split())) for _ in range(N)]
print([num[i][0] for i in range(N) for _ in range(num[i][1])][K-1])
# Judge status: Accepted
import collections

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


def count_variation(s):
    c = collections.Counter(s)
    return c.keys()


ans = []

for i in range(1, N):
    s1 = S[:i]
    s2 = S[i:]
    mojis = len(count_variation(s1) & count_variation(s2))
    ans.append(mojis)

print(max(ans))
# Judge status: Accepted
import sys
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)
C = sorted(C.items(), reverse=True)
a, b = 0, 0
for k, v in C:
    if a == 0 and v >= 4:
        print(k * k)
        sys.exit()
    if v >= 2:
        if a == 0:
            a = k
        elif b == 0:
            print(a * k)
            sys.exit()
print(0)
# Judge status: Wrong Answer
x = int(input())
job = []
time = []
for i in range(x):
    j, t = list(map(int, input().split()))
    job.append(j)
    time.append(t)
jt = 0
tt = 0
f = 0
for i in range(x):
    jt += job[i]
    if tt < time[i]:
        tt = time[i]
    if jt > tt:
        f = 1
        print("No")
        break
if f == 0:
    print("Yes")
# Judge status: Accepted
import math
k = int(input())
y = 100
i = 0

while (y<k):
    y = math.floor(y*1.01)
    i += 1

print(i)
# Judge status: Accepted
n = int(input())
h = [int(i) for i in input().split()]

j = 0
for i in range(n):
    if h[i] == j:
        pass
    elif h[i] > j:
        j = h[i] - 1
    else:
        if h[i] == j:
            pass
        else:
            print("No")
            break
else:
    print("Yes")
# Judge status: Wrong Answer
N=int(input())
if 1<N<999:
    print("ABC")
else:
    print("ABD")
# Judge status: Accepted
N = int(input())
H = list(map(int, input().split()))
H[0] -= 1
ans = "Yes"
for i in range(1, N):
    if H[i-1] == H[i]:
        continue
    elif H[i-1] <= H[i]-1:
        H[i] -= 1
    elif H[i-1] > H[i]:
        ans = "No"
        break

print(ans)
# Judge status: Accepted
from collections import deque

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

N, M = MI()
room = [[] for _ in range(N)]

for _ in range(M):
    A, B = MI()
    room[A - 1].append(B - 1)
    room[B - 1].append(A - 1)

ans = [-1] * N
queue = deque([0])

while queue:
    u = queue.popleft()
    
    for r in room[u]:
        if ans[r] == -1:
            ans[r] = u + 1
            queue.append(r)

print("Yes")

for a in ans[1:]:
    print(a)
# Judge status: Accepted
N = int(input())
C = [i for i in range(1,N+1)]
print(sum(C))
# Judge status: Accepted
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
a = list(map(int, input().split()))
for j in range(k):
  b = [0] * (n + 1)
  for i in range(n):
    left_edge = max(0, i-a[i])
    right_edge = min(i + a[i] + 1, n)
    b[left_edge] += 1
    b[right_edge] -= 1
  for i in range(1, n+1):
    b[i] = b[i] + b[i-1]
  b.pop(n)
  if a == b:
    break
  a = b.copy()
print(' '.join(str(b[i]) for i in range(n)))
# Judge status: Accepted
n,k =map(int,input().split())
p = list(map(int,input().split()))
p.sort()
print(sum(p[0:k]))
# Judge status: Accepted
import datetime

S = input()
S = datetime.datetime.strptime(S, '%Y/%m/%d')



a = int(S.year)

if a != 2018:
    S = S.replace(2018)
    
print(S.strftime('%Y/%m/%d'))
# Judge status: Accepted
def main():
    n = int(input())
    A = [int(e) for e in input().split()]

    B = [0] * n
    for i in range(n, 0, -1):
        s = 0
        for j in range(n // i):
            s += B[i * (j + 1) - 1]

        if s % 2 != A[i - 1]:
            B[i - 1] = 1

    print(B.count(1))

    if B.count(1) != 0:
        print(' '.join([str(i + 1) for i in range(n) if B[i] == 1]))


if __name__ == '__main__':
    main()
# Judge status: Accepted
S = input()
nick = S[:3]
print(nick)
# Judge status: Accepted
A,B,C =map(int,input().split())

if (A-C)*(B-C)>0:
    print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
    
n = int(input())
    
P = list(map(int, input().split()))
cnt = 0
for i in range(1, n-1):
    if (P[i-1] < P[i] < P[i+1]) or (P[i-1] > P[i] > P[i+1]):
        cnt += 1
    
    print(cnt)
# Judge status: Wrong Answer
A, B, C, D = [int(input()) for i in range(4)]
print(A)
ans=0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            tmp = i * 500 + j * 100 +50 *k
            if(tmp == D):
                ans += 1
print(ans)
# Judge status: Accepted
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    a, b, c = map(int, input().split())
    k = int(input())
    for _ in range(k):
        if a >= b:
            b *= 2
        elif b >= c:
            c *= 2
    if a < b and b < c:
        print('Yes')
    else:
        print('No')
            
if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N,M = map(int,input().split())
AB = []
for _ in range(N):
    AB.append([int(i) for i in input().split()])
AB_sort = sorted(AB,key=lambda x : x[0])
money = 0
for ab in AB_sort:
    if M >= ab[0]:
        money += ab[0] * ab[1]
        M -= ab[1]
    else:
        money += M * ab[1]
        break
print(money)
# Judge status: Wrong Answer
n, m = map(int, input().split())
dic = {}
for i in range(m):
	x, y = map(int, input().split())
	if x in dic:
		dic[x] += 1
	else:
		dic[x] = 1
	if y in dic:
		dic[y] += 1
	else:
		dic[y] = 1
for i,j in sorted(dic.items()):
	print (j)
# Judge status: Accepted
import sys
s = input()
n = len(s)
ans = 7
for bit in range(2**(n - 1)):
    f = s[0]
    for i in range(n - 1):
        if bit & (1 << i):#i番目の数が1なら以下の処理を行う
            f += "+"
            f += s[i + 1]
        else:#i番目の数が0なら以下の処理を行う
            f += "-"
            f += s[i + 1]
    if eval(f)==7:
        print(f+"=7")
        sys.exit()
# Judge status: Accepted
# 初期入力
N,K = (int(x) for x in input().split(" "))

#
zeroika = 0
if K <N:
    zeroika = N//K
else:
    zeroika = 1
N1 =abs(N-K*zeroika) #N1がマイナスになって初めてABS、そこまではKの倍数単調に減る
while N1<N:
    N =N1
    N1 =abs(N-K)
    #print(N1,end=" ")
print(N)
# Judge status: Accepted
n = int(input())
s = input()
print(max([len(set(s[:i + 1]) & set(s[i + 1:])) for i in range(n - 1)]))
# Judge status: Wrong Answer
s=int(input())
ans1=s//10**9+1
ans2=10**9-s%10**9
print(0,0,10**9,1,ans2,ans1)
# Judge status: Accepted
k,x = [int(i) for i in input().split()]
if k*500 >= x:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n,m,q=map(int,input().split())
e=[list(map(int,input().split())) for _ in range(q)]
ans=0
for i in range(1<<(m+n)):
  a=[1]
  for j in range(m+n):
    if (i>>j)&1:a[-1]+=1
    else:a+=[a[-1]]
    if a[-1]>m:
      flag=0
      break
    if len(a)>n:
      flag=1
      break
  else:flag=1
  if flag==0 or len(a)<n:continue
  cnt=0
  for s,t,u,v in e:
    if a[t-1]-a[s-1]==u:cnt+=v
  ans=max(ans,cnt)
print(ans)
# Judge status: Wrong Answer
N=int(input())

i=1
Sum=0
while Sum<=N:
    Sum+=i
    i+=1

ans=[]
Top=i-1
while N:
    if N-Top>=0:
        N-=Top
        ans.append(Top)
    Top-=1

for j in ans:
    print(j)
# Judge status: Accepted
N,M,X=map(int,input().split())
CA=[list(map(int,input().split())) for _ in range(N)]
max_=10**16
ans=max_
for bit in range(2**N):
  check=[0]*M
  ans_=0
  for i in range(N):
    if bit>>i&1:
      ans_+=CA[i][0]
      for j in range(M):
        check[j]+=CA[i][j+1]
  if all([k>=X for k in check]):
    ans=min(ans,ans_)
print(ans if ans!=max_ else -1)
# Judge status: Wrong Answer
import sys

n = int(input())
ab = []
for i in range(n):
    a,b = map(int,input().split())
    ab.append([a,b])
    
ab.sort(key=lambda x:x[1])

limit = 0
for i in range(n):
    limit += ab[i][0]
    if limit < ab[i][1]:
        print("No")
        sys.exit()

print("Yes")
# Judge status: Accepted
a=set(input())
if len(a)==2:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
n = int(input())
trans = [int(input()) for _ in range(5)]
x = min(trans)
t = (n+1) // x
t += 4
print(t)
# Judge status: Accepted
A=[]
B=["a"]
N=int(input())
if N>1:
 for i in range(N-1):
  A=B
  B=[]
  C=len(A)
  for j in range(C):
   F=len(A[j])
   D=0
   for f in range(F):
    D=max(ord(A[j][f])-95,D)
   for k in range(D):
    E=A[j]+chr(97+k)
    B.append(E)
for i in range(len(B)):
 print(B[i])
# Judge status: Wrong Answer
import numpy as np
N = int(input())
# TT = [[0]*10 for i in range(10)]
TT = np.zeros((10,10))

for i in range(N+1):
    top = int(str(i)[0])
    tail = int(str(i)[-1])
    TT[top,tail] += 1
print(TT)
y = 0
for i in range(1,10):
    for j in range(1,10):
        y += TT[i,j]*TT[j,i]
print(int(y))
# Judge status: Accepted
from collections import Counter
N = int(input())
As = list(map(int, input().split()))

ct = Counter(As)
ans = 0
for k, v in ct.items():
    ans += (v * (v-1)) // 2

for a in As:
    c = ct[a]
    if c >= 2:
        print(ans - ((c * (c-1)) // 2) + (((c-1) * (c-2)) // 2))
    else:
        print(ans)
# Judge status: Wrong Answer
def main():
    vowel = ["a", "e", "i", "o", "u"]
    c = input()
    if c in vowel:
        print("vowel")
    else:
        print("constant")
main()
# Judge status: Accepted
n=int(input())
num=[0]+[int(i)  for i in input().split()]

ans=[]
for i in range(n,0,-1):
  cnt,j=0,2
  while i*j<=n:
    cnt+=num[i*j]
    j+=1
  if cnt%2==num[i]:
    num[i]=0
  else:
    num[i]=1
    ans.append(i)
print(len(ans))
print(*ans)
# Judge status: Accepted
A,B = map(int, input().split())
print(A*B if A<=9 and B<=9 else -1)
# 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())

w = l()

cnt = 0
w.sort()
for i in range(len(w) - 1):
	if w[i] == w[i+1]:
		cnt += 1
	elif w[i] != w[i+1]:
		if cnt%2 == 0:
			print("No")
			exit()
		cnt = 0
	
print("Yes")
# Judge status: Accepted
def resolve():
    n, w = map(int, input().split())
    goods = [list(map(int, input().split())) for _ in range(n)]
    dp = [[0] * (w + 1) for _ in range(n + 1)]

    for i in range(1, n + 1):
        for j in range(w + 1):
            tmp = dp[i - 1][j - goods[i - 1][0]] + goods[i - 1][1] if j >= goods[i - 1][0] else 0
            dp[i][j] = max(dp[i - 1][j], tmp)

    print(dp[n][w])
    
resolve()
# Judge status: Accepted
w,h,n = map(int,input().split())
W = []
H = []

for _ in range(n):
  x,y,a = map(int,input().split())
  
  if a==1:
    W+=list(range(x))
  elif a==2:
    W+=list(range(x+1, w+1))
  elif a==3:
    H+=list(range(y))
  elif a==4:
    H+=list(range(y+1, h+1))

print(max(0, h-len(set(H)))*max(0, w-len(set(W))))
# Judge status: Wrong Answer
H, N = map(int, input().split())

count = 0
i = 0
arr = list(map(int, input().split()[:N]))
attack = H

for i in range(N):
    attack = attack - arr[i]
    i = i + 1
    count = count + 1

if count > 1 and attack <= 0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
S = input()
lS = len(S)
l = []
c = -1
for i in range(lS):
    if (c == -1):
        l.append(S[i])
        c += 1
    elif (S[i] == "S"):
        l.append(S[i])
        c += 1
    elif (S[i] == "T"):
        if (l[c] == "S"):
            l.pop()
            c -= 1
        else:
            l.append(S[i])
            c += 1
            
print(c+1)
# Judge status: Wrong Answer
x = int(input())
if 0<=x:
    print(1)
elif x<=1:
    print(0)
else:
    pass
# Judge status: Accepted
k = 0
s = t = ''
for c in input():
    s += c
    if s != t:
        k += 1
        s, t = '', s
print(k)
# Judge status: Wrong Answer
def calcuateCircle(ini, hankei):
    py = 3.14
    singleCircle = ini * ini * py
    inputCircle = hankei * hankei * py

    magnification = inputCircle / singleCircle

    return magnification

def main():
    ini = 1
    hankei = int(input())

    if hankei > 0:
        return calcuateCircle(ini, hankei)
    else:
        return 0
# Judge status: Accepted
n = int(input())
ans = 0
if n % 2 == 1:
  print(ans)
else:
  c = 2
  while c <= n:
    c *= 5
    ans += n // c
  print(ans)
# Judge status: Accepted
a, b, n = [int(x) for x in input().split()]


def solve(n):
    return (a*n)//b - a*(n//b)


print(solve(min(n, b-1)))
# Judge status: Accepted
import math
X = int(input())

total = 100
ans = 0
while total < X:
  total = math.floor(total * 1.01)
  ans += 1
  
print(ans)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int ,input().split()))
d = min(a)-len(a) - len(a)
u = max(a) * 2

while u-d > 1:
    mid = (d + u) // 2
    val = 0
    for i in range(n):
        val += a[i] - (mid + i)
    if val <= 0:
        u = mid
    else:
        d = mid
ans1 = 0
ans2 = 0
#print(u,d)
for i in range(n):
    ans1 += abs(a[i] - (u + i))
    ans2 += abs(a[i] - (d + i))
print(min(ans1,ans2))
# Judge status: Wrong Answer
a,b = map(int,input().split())
print('Even' if (a * b) % 2 == 1 else  'Odd')
# Judge status: Accepted
a,b=map(int,input().split())
c=int((a+b)/2)
if (a+b)%2!=0:
  print("IMPOSSIBLE")
else:
  print(c)
# Judge status: Accepted
N=int(input())
A=sorted([int(i) for i in input().split()],reverse=True)
print(sum(A[0::2])-sum(A[1::2]))
# Judge status: Wrong Answer
N,K = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
minToatalCostList = [10000 for i in range(N)]
minToatalCostList[0] = 0

for i in range(1,N) :
	for j in range(1,K+1) :
		if j > i or minToatalCostList[i] == 0 :
			break
		else :
			minToatalCostList[i] = min(minToatalCostList[i], abs(h[i] - h[i-j]) + minToatalCostList[i-j] )

print(minToatalCostList[N-1])
# Judge status: Accepted
a, b, c = map(int, input().split())
print(b//a if b//a <= c else c)
# Judge status: Accepted
N, L = map(int, input().split())

S = [input() for _ in range(N)]
S.sort()

print("".join(S))