peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
#!/usr/bin/env python3
#
# Author: Tetsuya Ishikawa <tiskw111@gmail.com>
# Date  : June 30, 2020
##################################################### SOURCE START #####################################################

import itertools
import math

N, A, B = tuple(map(int, input().strip().split()))

Ns = list(range(10))
L  = int(math.log10(N)) + 1
s  = 0

for n in range(N + 1):
    n1 = n % 10
    n2 = (n // 10) % 10
    n3 = (n // 100) % 10
    n4 = (n // 1000) % 10
    p = n1 + n2 + n3 + n4
    if A <= p <= B:
        s += n

print(s)

##################################################### SOURCE FINISH ####################################################
# vim: expandtab tabstop=4 shiftwidth=4 fdm=marker
# Judge status: Accepted
N, K, S = map(int, input().split())
ans = []
for _ in range(K):
    ans.append(S)

if S != 10**9:
    for _ in range(N-K):
        ans.append(S+1)
else:
    for _ in range(N-K):
        ans.append(S-1)

print(*ans)
# Judge status: Wrong Answer
a=input()
print=('chr(ord(a)+1)')
# Judge status: Accepted
S = input()
T = input()
if len(S)+1 == len(T) and S == T[:-1]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
x,y, = map(int, input().split())
if (x in a and y in a) or (x in b and y in b):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
s = input()

if s[-1] == "s":
    print(s+"es")
else:
    print(s+"s")
# Judge status: Accepted
N = int(input())
ans = 0
for i in range(1, N+1):
  ans += i
print(ans)
# Judge status: Accepted
import sys
N = int(sys.stdin.readline().rstrip())
S = list(sys.stdin.readline().rstrip())

count = []
cnt_b = 0
cnt_w = 0
for s in S:
    if s == "#":
        cnt_b += 1
    else:
        cnt_w += 1
    count.append((cnt_b, cnt_w))

ans_1 = N - cnt_b
ans_2 = N - cnt_w
ans_3 = float("inf")

for i, j in count:
    ans_3 = min(ans_3, i + cnt_w - j)

print(min(ans_1, ans_2, ans_3))
# Judge status: Accepted
l=[51]*26
for s in [input() for _ in range(int(input()))]:
  for i in range(26): c=s.count(chr(97+i)); l[i]=min(l[i],c)
a=''
for i in range(26):
  if l[i]<51: a+=chr(97+i)*l[i]
print(a)
# Judge status: Wrong Answer
n=int(input())
from itertools import groupby as gb
l=[eval(input().replace(' ','==')) for i in range(n)]

var=[(a,len(list(b))) for a,b in gb(l)]
for a,b in var:
    if b>=3:print("Yes");exit()
print("No")
# Judge status: Accepted
def main():
    s = input().strip()

    while len(s):
        if s[-5:] in ("dream", "erase"):
            s = s[:-5]
        elif s[-6:] == "eraser":
            s = s[:-6]
        elif s[-7:] == "dreamer":
            s = s[:-7]
        else:
            print("NO")
            return

    print("YES")


if __name__ == "__main__":
    main()
# Judge status: Accepted
n = int(input())
ans = 0
for a in range(1, n):
    ans += (n-1) // a
print(ans)
# Judge status: Accepted
def main():
    a,b = list(map(int, input().split()))
    if a % 3 != 0 and b % 3 != 0:
        if (a+b) % 3 != 0:
            print('Impossible')
            exit()
    print('Possible')

if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
ans = 0
min_diff = 100000

for i in range(N):
    temp = T - H[i] * 0.006
    diff = abs(temp - A)

    if min_diff > diff:
        min_diff = diff
        ans = i + 1
    
print(ans)
# Judge status: Wrong Answer
A, B, C = map(int, input().split())
ans = A*B*C
if (A*B*C)%2==0:
  print(0)
else:
  cnt = float('inf')
  for i in [A,B,C]:
    if i%2==1 and i<cnt:
      cnt = i
  print(ans//i)
# Judge status: Wrong Answer
from fractions import gcd

n=int(input())
a=list(map(int,input().split()))
ans=10**18
t=0
for i in range(1,n):
  if i==1:
    t=gcd(a[i-1],a[i])
    continue
  t=gcd(t,a[i])
  ans=min(t,ans)
print(ans)
# Judge status: Accepted
s = input()
N = len(s)
Ans = ""
for i in range(N):
    if s[i]=="0":
        Ans = Ans + "0"
    elif s[i]=="1":
        Ans = Ans + "1"
    else:
        Ans = Ans[:-1]
        
print(Ans)
# Judge status: Accepted
S=input()

if S[2]==S[3] and S[4]==S[5]:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
N, M = map(int, input().split())
wa, ac = [0]*(N+1), [0]*(N+1)
for i in range(1, M+1):
  pi, Si = input().split()
  pi = int(pi)
  if Si == 'WA' and ac[pi] == 0: 
    wa[pi] += 1
  elif Si == 'AC' and ac[pi] == 0:
    ac[pi] += 1

print('{} {}'.format(sum(ac), sum(wa)))
# Judge status: Accepted
# https://atcoder.jp/contests/abc168/tasks/abc168_b

K = int(input())
S = input()

if len(S) <= K:
    print(S)

else:
    print(S[0: K] + '...')
# Judge status: Accepted
c = input()
ans = chr(ord(c) + 1)
print(ans)
# Judge status: Accepted
import sys


def log(s):
    # print("| " + str(s), file=sys.stderr)
    pass


def output(x):
    print(x, flush=True)


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


def main():
    x, y = tuple(input_ints())
    # t + k == x
    # 2t + 4k == y

    r = False
    for t in range(x+1):
        k = x - t
        if 2 * t + 4 * k == y:
            r = True
            break

    print("Yes" if r else "No")

main()
# Judge status: Wrong Answer
n,k = [int(x) for x in input().split()]

print(n % k)
# Judge status: Accepted
a, b, c, x, y = map(int, input().split())
total = 0
if x >= y:
    total = min(a*x+b*y, c*x*2, c*y*2+a*(x-y))
else:
    total = min(a*x+b*y, c*y*2, c*x*2+b*(y-x))
print(total)
# Judge status: Accepted
#coding:utf-8
n = int(input())
a = list(map(int, input().split()))

card = sorted(a, reverse=True)

alice = sum(card[0::2])
bob = sum(card[1::2])
print(alice - bob)
# Judge status: Wrong Answer
import time
import datetime
from datetime import timedelta
H1,M1,H2,M2,K=map(int,input().split())


delta1=timedelta(minutes=M1,hours=H1)
delta2=timedelta(minutes=M2,hours=H2)

delta=delta2-delta1
delta_minutes=delta.total_seconds()/60
if delta_minutes>30:
  print(delta_minutes-30)
else:
  print(0)
# Judge status: Wrong Answer
s=list(input())
flag=1
if s[0]!='A':
    flag=0
if 'C' not in s[2:-2]:
    flag=0
if s.count('C')!=1:
    flag=0
if 'A' in s:
    s.remove('A')
if 'C' in s:
    s.remove('C')
s=''.join(s)
if s.islower():
    pass
else:
    flag=0
if flag==1:
    print('AC')
else:
    print('WA')
# Judge status: Accepted
def f(num, base):
    # calc max Pth Power
    ret = 1
    while ret <= num:
        ret *= base
    return ret // base


def main():
    N = int(input())
    st = {N}
    ans = 0
    while (all(st)):
        st = {x - f(x, 6) for x in st} | {x - f(x, 9) for x in st}
        ans += 1
    print(ans)
    return


main()
# Judge status: Accepted
K, X = [int(i) for i in input().split(" ")]

if 500 * K >= X:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n,a,b=map(int,input().split())
s=input()
total=0
bb=0
for i in s:
    if i=="a":
        if total<a+b:
            print('Yes')
            total+=1
        else:
            print('No')
    elif i=="b":
        if total<a+b and bb<b:
            print("Yes")
            total+=1
            bb+=1
        else:
            print('No')
    else:
        print("No")
# Judge status: Accepted
n, k, q = map(int, input().split())
quiz = [int(input()) for i in range(q)]
point = [k-q]*n
for i in quiz:
  point[i-1] += 1
[print("Yes") if i > 0 else print("No") for i in point]
'''
1. あらかじめ全員のポイントを Q 減らしておく (つまり，開始時点のポイントは K − Q)．
2. Q 回の正解それぞれに対して，正解者のポイントを 1 増やす．

リストの中身すべてに計算すると「リスト要素」＊「ループ回数」の計算量になる
'''
# Judge status: Accepted
from collections import Counter

w = Counter([c for c in input()])
if all([v % 2 == 0 for k, v in w.items()]):
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
import math
import numpy as np
# math.floor

X = list(input().split())
A = int(X[0])
B = float(X[1])

# s = str(A*B)

ans = (A*int(B*100))//100
print(ans)
# Judge status: Accepted
X = int(input())
i = 1
while True:
  if (360*i) % X == 0:
    print((360*i) // X)
    exit()
  else:
    i += 1
# Judge status: Accepted
# coding: utf-8
import fractions

n = int(input())

monsters = list(map(int, input().rstrip().split(" ")))

ans = monsters[0]
for i in range(1, n):
    ans = fractions.gcd(ans, monsters[i])

print(ans)
# Judge status: Wrong Answer
A,B,C,D=input()
digits=3
op=[""]*digits
for i in range(1<<digits):
    for j in range(digits):
        if (i>>j)&1:
            op[j]="+"
        else:
            op[j]="-"
    if eval(A+op[0]+B+op[1]+C+op[2]+D)==7:
        print(A+op[0]+B+op[1]+C+op[2]+D)
        break
# Judge status: Accepted
N,X = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
k1 = k2 = 0
for i in range (N):
  if sum(A[:i+1]) > X:
    k1 = i
    k2 = 1
    break
  elif sum(A) == X:
    k1 = N
    k2 = 1
    break
if k2 == 0:
  k1 = N - 1
print(k1)
# Judge status: Wrong Answer
n = int(input())

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

i = 1
bb = 0
same = 0
while True:
    if i in nums:
        i_index = nums.index(i)
        if i_index == i - 1:
            same += 1
        bb += len(nums[i - 1:i_index])
        nums = nums[:i - 1] + nums[i_index:]
        i += 1
    else:
        break

if (bb > 0) or ((bb == 0) and (same == n)):
    print(bb)
else:
    print(-1)
# Judge status: Wrong Answer
k, a, b = map(int, input().split())
if a+ 1 >= b:
    ans = k + 1
else:
    if a > k:
        ans = k + 1
    else:
        ans = a
        k -= (a - 1)
        if k % 2 == 0:
            ans += k/2 * (b - a)
        else:
            ans += k//2 * (b - a)
            ans += 1

print(int(ans))
# Judge status: Accepted
a,b,c = map(int,input().split())
if (a==b and a==c and b==c) or (a!=b and b!=c and a!=c):
  print("No")
else:
  print("Yes")
# Judge status: Wrong Answer
x=int(input())
l=[i**5 for i in range(-100,101)]
ok=False
for i in range(len(l)):
    if ok:
        break
    for j in range(len(l)):
        if l[i]-l[j]==x:
            print(i-100,j-100)
            ok=True
            break
# Judge status: Wrong Answer
N = int(input())
H = list(map(int, input().split()))
C = []
for i in range(N):
	iterH = iter(H[i::])
	x = 0
	h1 = next(iterH)
	while True:
		try:
			h2 = next(iterH)
			if h1 < h2:
				C.append(x)
				break
			else:
				x += 1
				h1 = h2
		except:
			C.append(x)
			break
print(max(C), C)
# Judge status: Accepted
n = int(input())
a = [-1]
a.extend(list(map(int, input().split())))
cnt = 0
ansID = []
ans = [-1]*(n+1)

for i in reversed(range(1, len(a))):
  tmp = a[i]
  j = i*2
  while j < len(ans):
    tmp += ans[j]
    j += i
  ans[i] = tmp%2
  cnt += tmp%2
  if tmp%2 == 1:
    ansID.append(i)
  
print(cnt)
for ans in ansID:
  print(ans, end=" ")
# Judge status: Accepted
x,y,z=[int(i) for i in input().split()]
print((x-z)//(y+z))
# Judge status: Wrong Answer
l = list(map(str,input().split()))
n = l[0]+l[1]+l[2]
print(n)
# Judge status: Wrong Answer
s = str(input())
mid = (len(s) + 1)//2

def palin(st):
    return st == st[::-1]

print('Yes' if palin(s[0:mid-1]) and palin(s[mid:]) else 'No')
# Judge status: Accepted
n=int(input())
a=[[0]*3]*n
for i in range(n):
    a[i]=list(map(int,input().split()))
b=[0]*3
for i in range(n-2,-1,-1):
    for j in range(3):
        t=0
        for k in range(3):
            if j!=k:
                t=max(t,a[i][j]+a[i+1][k])
        a[i][j]=t
print(max(a[0]))
# Judge status: Accepted
D, N = map(int, input().split())
if N == 100:
    N = 101
if D == 0:
    print(N)
elif D == 1:
    print(N*100)
else:
    print(N*10000)
# Judge status: Accepted
from math import gcd
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = [i // 2 for i in A]
lcd = 1
for a in A:
    lcd *= a // gcd(lcd, a)
for a in A:
    if lcd // a % 2 == 0:
        print(0)
        exit()
print((M//lcd+1)//2)
# Judge status: Accepted
D, T, S = map(int, input().split())

if D/S <=T: 
  print("Yes")
else:
  print("No")
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

ans = 0

up = None

for i in range(1, N):
    if up == None:
        if not A[i] == A[i - 1]:
            up = A[i] > A[i - 1]
            
    elif up:
        if A[i] < A[i - 1]:
            ans += 1
            up = None

    else:
        if A[i] > A[i - 1]:
            ans += 1
            up = None

print(ans + 1)
# Judge status: Accepted
n,m=map(int,input().split())
a=list(map(int,input().split()))
l=[]
for i in range(m):
  b,c=map(int,input().split())
  l.append([c,b])
for i in range(n):
  l.append([a[i],1])
l.sort(reverse=True)
ans,cnt=0,0
for i in range(n):
  if cnt+l[i][1]>=n:
    ans+=(n-cnt)*l[i][0]
    break
  else:
    ans+=l[i][0]*l[i][1]
    cnt+=l[i][1]
print(ans)
# Judge status: Accepted
A,B,C,X,Y = list(map(int,input().split()))

tan = A*X + B*Y
hukuA = max(X,Y)*2*C
hukuB = min(X,Y)*2*C + (max(X,Y)-min(X,Y)) * (A if X>=Y else B)

print(min(tan,hukuA,hukuB))
# Judge status: Wrong Answer
a,b = input().split()

A = a*int(b)
B = b*int(a)

print(min(int(A),int(B)))
# Judge status: Accepted
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
p.sort()
print(sum(p[:k]))
# Judge status: Accepted
D, T, S = map(int, input().split())
if D/S <= T:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
R = int(input())

import math
pi = math.pi
around = 2 * R * pi
print(around)
# Judge status: Accepted
n = int(input())

L = [0] * 10**3
L[0] = 2
L[1] = 1
i = 2
while i!=n+1:
    L[i] = L[i-2] + L[i-1]
    i += 1

print(L[i-1])
# Judge status: Wrong Answer
S=list(input())
A=[0]*4
A[0]=1
for i in range(3):
    if S[i]==S[i+1]:
        A[i]+=1
        A[i+1]+=A[i]
if max(A)>=3:
    print("Yes")
else:print("No")
# Judge status: Accepted
S=input()
d=753
for i in range(len(S)-2):
    d=min(d,abs(int(S[i:i+3])-753))
print(d)
# Judge status: Accepted
# print('input >>')
S = input()

if S == 'hi' or S == 'hihi' or S == 'hihihi' or S == 'hihihihi' or S == 'hihihihihi':
    print('Yes')

else:
    print('No')

# print('-----output-----')
# Judge status: Wrong Answer
n=int(input())
#a=list(map(int,input().split()))
a=input()
nl=[x for x in range(1,n+1)]

if a!="1" and a.find("1 ")==-1:
  print(-1)
else:
  cnt=0
  for x in set(nl):
    t=a.find(str(x))
    if t == -1:
      print(n-cnt)
      break
    else:
      a=a[t+len(str(x)):]
      cnt+=1
  else:
    print(n-cnt)
# Judge status: Accepted
from _collections import defaultdict
n=int(input())
S=input()
X=defaultdict(int)
for s in S:
    X[s]+=1
ans=1
for v in X.values():
    ans*=(v+1)
print((ans-1)%(10**9+7))
# Judge status: Wrong Answer
S = input()
a = len(S)
count=0
for i in range(a):
  for j in range(i+1,a):
    XX= S[:i] +S[j:a]
    
    if XX == 'keyence':
      count +=1
if count == 0:
  print('NO')
else:
  print('YES')
# Judge status: Wrong Answer
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

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

n, m = rm()
cnt = 0
cnt_money = 0
for i in sorted([rl() for _ in range(n)]):
  a, b = i
  if cnt + b < m:
    cnt += b
    cnt_money += a*b
  else:
    cnt_money += (m - cnt) * a
print(cnt_money)
# Judge status: Accepted
n = input()
print("Yes" if n[0] == '9' or n[1]=='9' else "No")
# Judge status: Wrong Answer
N = int(input())
d_list = list(map(int,input().split()))

dist = [0] * 10**5
max_d = 0
for d in d_list:
    dist[d] += 1
    max_d = max(max_d, d)

MOD = 998244353
if d_list[0] == 1:
    print(0)
    exit()
elif dist[1] == 0:
    print(dist[0])
    exit()

ans = dist[0]
for i in range(1,max_d):
    ans = (ans*(dist[i]**dist[i+1]))%MOD
print(ans)
# Judge status: Wrong Answer
L, R = map(int, input().split())
modL = L % 2019
modL1 = (modL + 1) % 2019
if modL == 0 or (L <= 2018 and R >= 2019):
    print(0)
else:
    print((modL * (modL1)) % 2019)
# Judge status: Wrong Answer
N = int(input())
a = ""
student = list(map(int,input().split()))
for i in range(N):
    a += str(student.index(i+1) + 1)
a = list(a)
print(" ".join(a))
# Judge status: Accepted
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))
abs_A = abs(A)

min_A = min(abs_A)

if (A < 0).sum() % 2:
    print(sum(abs_A) - min_A * 2)
else:
    print(sum(abs_A))
# Judge status: Wrong Answer
D, T, S = map(int, input().split())
print("Yes") if T>=D//S else print("No")
# Judge status: Accepted
A = list(map(int,input().split()))
ans = max(A[0]*A[2],A[0]*A[3],A[1]*A[2],A[1]*A[3])
print(ans)
# Judge status: Wrong Answer
N,M = map(int,input().split())
pref = [[] for i in range(N)]
id = [[]] * M

for i in range(M):
  p,y = map(int,input().split())
  id[i] = [p,y]
  pref[p - 1].append(y)
  #pref[p - 1] = sorted(pref[p - 1])

for i in range(N):
  pref[i] = sorted(pref[i])

orders = [0] * N

for i in range(M):
  p = id[i][0]
  y = id[i][1]
  orders[p - 1] += 1
  order = str(orders[p - 1])
  city = str(p)
  ID = ""
  ID += "0" * (6 - len(city)) + city + "0" * (6 - len(order)) + order
  print(ID)
# Judge status: Accepted
s = sorted(list(str(input())))
t = reversed(sorted(list(str(input()))))
S = str()
T = str()
for i in s:
    S += i
for k in t:
    T += k
print('Yes' if S<T else 'No')
# Judge status: Wrong Answer
a, b, c = map(int, input().split())

end = 0
begin = 0
if b%c == 0:
    end = b//c + 1
else:
    end = b//c

if a%c == 0:
    print(end - a//c)
else:
    print(end - a//c)
# Judge status: Accepted
x, y, z = map(int, input().split())
if x < y:
    print(0)
else:
    l = z
    i = 0
    while l + (z+y) <= x:
        l += (z+y)
        i += 1
    print(i)
# Judge status: Wrong Answer
N,K = map(int,input().split())
if N%K > 0:
    print(N//K - N%K)
else:
    print(0)
# Judge status: Wrong Answer
import math

N = int(input())
baseArea = math.pi

print(int((N**2 * math.pi)/baseArea))
# Judge status: Accepted
N = int(input())
L = list(map(int,input().split()))
L.sort()
import bisect
ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        ans += bisect.bisect_left(L, L[i]+L[j]) - j - 1
print(ans)
# Judge status: Accepted
l=list(map(int,input().split()))
for ll in l:
  if ll==0:
    print(l.index(ll)+1)
    exit()
# Judge status: Accepted
S = input()
print("x" * len(S))
# Judge status: Accepted
n, k = list(map(lambda x: int(x),input().split(' ')))

has_cookie = []
for i in range(k):
  cookie_num = int(input())
  has_cookie.extend(list(map(lambda x: int(x), input().split(' '))))

has_cookie = list(set(has_cookie))

print(n - len(has_cookie))
# Judge status: Accepted
n = int(input())
s = input()
t = input()

for i in range(n):
    if s[i] == t[0]:
        if s[i:] == t[:n-i]: break
if s[i] != t[0]: i += 1
print(len(s[:i]+t))
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))

b = 0
if N%2 == 0:
    b = int((A[N//2-1]+A[N//2])/2 - (N//2-1+N//2)/2)
else:
    b = A[N//2-1] - N//2 - 1
##print(b)
ans = 0
for i in range(N):
    ans += abs(A[i]-(b+i+1))
b += 1
ans2 = 0
for i in range(N):
    ans2 += abs(A[i]-(b+i+1))
ans = min(ans,ans2)
print(int(ans))
# Judge status: Accepted
n = int(input())

w = [input() for _ in range(n)]

print("Yes" if len(set(w)) == n and all([w[i][0] == w[i-1][-1] for i in range(1,n)]) else "No")
# Judge status: Wrong Answer
C=input()
print(str(ord(C)+1))
# Judge status: Accepted
n=int(input())
if n%2:
    print(0)
    exit()
ans=0
for i in range(1,50):
    ans+=n//(2*5**i)
print(ans)
# Judge status: Accepted
def main():
    N, A, B, C, D = (int(i) for i in input().split())
    S = "#" + input() + "#"
    if "##" in S[A:C+1] or "##" in S[B:D+1]:
        return print("No")
    if D < C and "..." not in S[B-1:D+2]:
        return print("No")
    print("Yes")


if __name__ == '__main__':
    main()
# Judge status: Accepted
k = int(input())
s = input()

if len(s) > k:
    print(s[:k] + "...")
else:
    print(s)
# Judge status: Accepted
N = int(input())
count = 0
for i in range(N):
    a, b = map(int, input().split())
    if a == b:
        count += 1
    else:
        count = 0
    if count == 3:
        break
if count >= 3:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
_N, _M = map(int, input().split())
N = max(_N, _M)
M = min(_N, _M)
if N >= 3 or M >= 3:
    long = max(1, N - 2)
    short = abs(M - 2)
    print(long * short)
else:
    if N == 1 and M == 1:
        print(1)
    else:
        print(0)
# Judge status: Accepted
N=int(input())
print(800*N-N//15*200)
# Judge status: Accepted
W,H,N = map(int,input().split())
X = [0]*N
Y = [0]*N
A = [0]*N
X_max= W
X_min= 0
Y_max= H
Y_min= 0
for i in range(N):
	X[i],Y[i],A[i] = map(int,input().split())
for i in range(N):
	if A[i]==1:
		X_min=max(X_min,X[i])
	elif A[i]==2:X_max=min(X_max,X[i])
	elif A[i]==3:Y_min=max(Y_min,Y[i])
	else:Y_max=min(Y_max,Y[i])

if X_max-X_min>0 and Y_max-Y_min>0:
	print((X_max-X_min)*(Y_max-Y_min))
else: print(0)
# Judge status: Accepted
N, K = map(int, input().split())

probs = 0
for i in range(1, N + 1):
    point = i
    cnt = 0
    while point < K:
        point *= 2
        cnt += 1
    probs += (1 / N) * (0.5 ** cnt)

print(probs)
# Judge status: Wrong Answer
w,a,b = map(int,input().split())
c = min(a,b)
d = max(a,b)
if c + w >= d:
  print(0)
else:
  print(c+w-d)
# Judge status: Wrong Answer
import math
N, M = map(int,input().split())
L = list(map(int,input().split()))
max(-1,N-sum(L))
# Judge status: Wrong Answer

a,b,c,d = map(int,input().split())

if b <= c:
    print(0)
elif a <= c <= b <= d:
    print(b-c)
elif a <= c <= d <= b:
    print(d-c)
elif c <= a <= d <= b:
    print(d-a)
elif a <= d <= a <= b:
    print(0)
# Judge status: Accepted
X = int(input())
a = (X - 400) // 200
print(8 - a)
# Judge status: Accepted
a,b,c=map(int,input().split())
ans="NO"
for i in range(1,b+1):
    if a*i%b==c:
        ans="YES"
print(ans)
# Judge status: Accepted


def main():
    N = int(input())
    l1 = list(map(int, input().split()))
    l2 = list(map(int, input().split()))
    res = 0
    for i in range(N):
        sum_v = sum(l1[0 : i + 1]) +  sum(l2[i:])
        if sum_v > res:
            res = sum_v
    print(res)
    



if __name__ == "__main__":
    main()
# Judge status: Accepted
X = int(input())
i = 1
while True:
    if i*X%360 == 0:
        print(i)
        break
    else:
        i += 1
# Judge status: Accepted
import math
def S(i):
    return ((i * (i+1)) // 2)

N = int(input())
ans = 0
sqrt_N = math.floor(math.sqrt(N))

for K in range(1, N+1, 1):
    if((N // K) < sqrt_N):
        break
    # 個別に足す
    ans += S(N // K) * K

for NdivK in range(1, sqrt_N, 1):
    # [N // K]が等しいKの区間を求める
    Kbegin = N // (NdivK + 1)
    Kend = N // NdivK
    ans += (S(NdivK) * (S(Kend) - S(Kbegin)))

print(ans)
# Judge status: Accepted
N = int(input())
for d in range(64):
  if N < (26**(d+1)-1)//(26-1):
    N = N-(26**d-1)//(26-1)
    break
#print(d, N)
L = []
for i in range(d):
  n = N%26
  c = "abcdefghijklmnopqrstuvwxyz"[n]
  L.append(c)
  N = N//26
r = "".join(reversed(L))
print(r)
# Judge status: Accepted
from bisect import bisect_left
N = int(input())
A = list(map(int, input().split()))
A.sort()
if N == 2:
    print(A[1], A[0])
    exit()
a = A[-1]
k = bisect_left(A, a/2)
x = a/2-A[k-1]
y = A[k]-a/2
if x <= y:
    b = A[k-1]
else:
    b = A[k]
print(a, b)
# Judge status: Accepted
S = input()
K = int(input())

for idx in range(K):
    if S[idx] != "1":
        print(S[idx])
        break
else:
    print("1")
# Judge status: Accepted
s1 = input()
s2 = input()[::-1]

if s1==s2:
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
A,B,C = map(int,input().split())

if 2*B == A + C :
  print('Yes')
  
else:
  print('No')
# Judge status: Accepted
# coding: utf-8
# Your code here!
N,K,S=map(int,input().split())
ans=[]
p=N-K

if S!=10**9:
    for i in range(N-K):
        ans.append(str(S+1))
    for i in range(K):
        ans.append(str(S))
else:
    for i in range(N-K):
        ans.append(str(1))
    for i in range(K):
        ans.append(str(S))
#print(ans)
#ans=' '.join(ans)

#print(len(ans))


#print(" ".join([str(n) for n in ans]))
print(*ans)
# Judge status: Accepted
X = int(input())
count = 0
for i in range(X+1):
    count += i
    if X - count <= i+1:
      ans = i+1
      break
print(ans)
# Judge status: Accepted
n = int(input())
b = list(map(int,input().split()))
a = b[0]
for i in range(1,n-1):
    a += min(b[i-1],b[i])
a += b[n-2]
print(a)