peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
def main():

    N = int(input())
    interval = []
    for _ in range(N):
        X, L = map(int, input().split())
        interval.append([X-L, X+L])
    interval.sort()
    cnt = 0
    i = 0
    while i < N:
        a, b = interval[i]
        cnt += 1
        i += 1
        while i < N and interval[i][0] < b:
            if interval[i][1] < b:
                a, b = interval[i]
            i += 1
    return cnt


if __name__ == '__main__':
    print(main())
# Judge status: Accepted
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    res = 0
    pre = -1
    for i in range(n):
        res += B[A[i] - 1]
        if pre + 1 == A[i]:
            res += C[pre - 1]
        pre = A[i]
    print(res)


if __name__ == '__main__':
    resolve()
# Judge status: Accepted
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n,k = nm()
cnt = 0
while n:
    cnt += 1
    n //= k
print(cnt)
# Judge status: Wrong Answer
S = input()
d = {}
print(S)

for s in S:
  d[s] = True
  
if "N" in d:
  if 'S' not in d:
    print("No")
    exit()
    
if 'S' in d:
  if 'N' not in d:
    print("No")
    exit()

if 'E' in d:
  if 'W' not in d:
    print("No")
    exit()
    
if 'W' in d:
  if 'E' not in d:
    print("No")
    exit()  
    
print("No")
# Judge status: Accepted
words = input()
Flag = True

c_dict = {}

for word in words:
    if word in c_dict:
        Flag = False
        break
    c_dict[word] = 1

if Flag is True:
    print('yes')
else:
    print('no')
# Judge status: Accepted
h = list(map(int, input().split()))
tmp1 = h[0] * 60 + h[1]
tmp2 = h[2] * 60 + h[3]
ans = tmp2 - tmp1
print(ans - h[4])
# Judge status: Wrong Answer
s = input()
a = s.count("dream")
b = s.count("dreamer")
c = s.count("erase")
d = s.count("eraser")
e = s.count("dreamera")
f = s.count("erasera")
b = b-e
d = d-f
a = a-b
c = c-e
if (a+c)*5 + b*7 + d*6 == len(s):
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
K,A,B=list(map(int,input().split()))
hand=0
if B-A<=2:
    print(K+1)
    exit()
K=K-A+1
print(K)
if K%2==1:
    hand=1+int((K-1)/2)*(B-A)
else:
    hand=int(K/2)*(B-A)
print(hand+A)
# Judge status: Accepted
S = input()
List = ["Sunny", "Cloudy", "Rainy"]
res = 0
for i in range(3):
  if S == List[i]:
    res = i+1
if res == 3:
  res = 0
print(List[res])
# Judge status: Wrong Answer
f=lambda:[*map(int,input().split())]
n,x=f()
l=f()
d=[l[i+1]-l[i] for i in range(n-1)]
a=x-l[0]
from math import *
for i in d:
  a=gcd(a,i)
print(a)
# Judge status: Wrong Answer
a=int(input())
if a<10:
  print("ABC00"+str(a))
elif 10<=a<100:
  print("ABC0"+str(a))
elif 100<=a<1000:
  print("ABC"+str(a))
elif 1000<=a<1010:
  print("ABD00"+str(a))
elif 1010<=a<1100:
  print("ABD0"+str(a))
else:
  print("ABD"+str(a))
# Judge status: Wrong Answer
from math import log2
N,K = map(int,input().split())

r = 0
max_cnt = int(log2(K)) + 1

for i in range(1,N+1):
    count = int(log2(K / i)) + 1 if i < K else 0

    r += 2 ** (max_cnt - count)
r = r / (N * (2 ** max_cnt))

print(r)
# Judge status: Wrong Answer
n=int(input())
a = n//(10**9)+1
b = 10**9-(n%(10**9))
if n%(10**9) == 0:
  print(0,0,10**9,0,1,a)
else:
  print(0,0,10**9,b,1,a)
# Judge status: Wrong Answer
import numpy as np
A,N= np.array([list(map(int,input().split())) for _ in range(3)]),int(input())
b=[int(input()) for _ in range(N)]
for i in range(9):
  if A[i//3][i%3] in b:A[i//3][i%3]=0
print(['No','Yes'][int((A.sum(0)*A.sum(1)*A.diagonal()*A[::-1].diagonal()).prod()==0)])
# Judge status: Wrong Answer
A, B, N = map(int, input().split())

n = 0

for i in range(N):
    
    _n = int(A*N/B) - A*int(N/B)
    if n < _n:
        n = _n
    break

print(n)
# Judge status: Wrong Answer
n, a, b = map(int, input().split())
MOD = 10**9+7


def modcmb(n, k, mod):
    k = min(k, n-k)
    rtn = n
    for i in range(1, k):
        rtn = (rtn * ((n-i) % mod) * pow(i+1, mod-2, mod)) % mod

    return rtn


ans = (pow(2, n, MOD) - 1 - modcmb(n, a, MOD) - modcmb(n, b, MOD)) % MOD
print(ans if ans >= 0 else ans + MOD)
# Judge status: Accepted
import sys
import copy
import math
import itertools
import numpy as np
l = [int(c) for c in input().split()]
N=l[0]
K=l[1]
Q=l[2]
A=[int(input()) for c in range(Q)]

S = [K]*N

for i in range(Q):
    S[A[i]-1]+=1

for i in range(N):
    if S[i]-Q>0:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
n = int(input())
moji = "abcdefghijklmnopqrstuvwxyz"
#print(len(moji))

lis = [[0]]
for i in range(n-1):
  temp = []
  for s in lis:
    next = max(s) + 1
    for j in range(0, next+1):
      temp.append(s + [j])
  else:
    lis = temp
#print(lis)

for s in lis:
  for char in s:
    print(moji[char], end="")
  print()
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
r = [0 for _ in range(max(a)+1)]
for i in range(n):
    r[a[i]] += 1
ans = 0
for i in range(len(r)-2):
    ans = max(ans,sum(r[i:i+3]))
print(ans)
# Judge status: Accepted
N, K = [int(_) for _ in input().split()]
for a in range(0, 10**9):
    if K**(a) <= N < K**(a+1):
        print(a+1)
        break
# Judge status: Accepted
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

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 and x+y+z == s):
            #print(x,y,z)
            ans += 1
print(ans)
# Judge status: Accepted
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


a,b = map(int, input().split())
if a>0:
    ans = "Positive"
elif b<0:
    if (b-a+1)%2==0:
        ans = "Positive"
    else:
        ans = "Negative"
else:
    ans = "Zero"
print(ans)
# Judge status: Accepted
# -*- coding: utf-8 -*-
N,R = map(int, input().split())
if N < 10:
	R = R + 100 * (10 - N )
     
print(R)
# Judge status: Accepted
a = int(input())
print(input() if a >= 3200 else 'red')
# Judge status: Wrong Answer
S = input()
a = int(S[:2])
b = int(S[2:])

ym = False
my = False
if a > 0 and b>0 and b <= 12:
  ym = True
if b > 0 and a>0 and a <= 12:
  my = True

if ym and my:
  print("AMBIGUOUS")
elif ym and not(my):
  print('YYMM')
elif not(ym) and my:
  print('MMYY')
else:
  print('NA')
# Judge status: Accepted
n,a,b=map(int,input().split())
mod=10**9+7


def fac(n,a):
    ans=1
    for i in range(n,n-a,-1):
        ans*=i
        ans%=mod
    return ans%mod

def inv_fac(n):
    ans=pow(fac(n,n-1),mod-2,mod)
    return ans%mod



ans=pow(2,n,mod)-fac(n,a)*inv_fac(a)-fac(n,b)*inv_fac(b)
print(ans%mod-1)
# Judge status: Accepted
s = input()
cnt = 0
for s1, s2 in zip(s, s[::-1]):
    if s1 != s2:
        cnt += 1
print(cnt // 2)
# Judge status: Accepted
s = input()
cnt = 0
i = 1
while i < len(s):
    if s[i] == s[i-1]:
        cnt += 1
        i += 3
    else:
        i += 1
print(len(s)-cnt)
# Judge status: Accepted
N=int(input())

mod=pow(10,9)+7

def pow_method(r,N):
    ans=1
    for i in range(N):
        ans=ans*r%mod
    return ans

calc=pow_method(9,N)+pow_method(9,N)-pow_method(8,N)
ans=pow_method(10,N)-calc
ans=ans%mod
ans=(ans+mod)%mod

print(ans)
# Judge status: Accepted
x,k,d = map(int,input().split())


x=abs(x)
if k*d<=x:
    print(x-k*d)
else:
    tem = int(x/d)
    x-= tem*d
    k-= tem
    if k%2==0:
        print(x)
    else:
        print(abs(x-d))
# Judge status: Accepted
N, M = map(int, input().split())
a = [list(map(int, input().split())) for i in range(N)]
c = [list(map(int, input().split())) for i in range(M)]
for i in range(N):
    ans = 0
    dis = 10**9
    for j in range(M):
        if dis > abs(a[i][0]-c[j][0]) + abs(a[i][1]-c[j][1]):
            ans = j+1
            dis = abs(a[i][0]-c[j][0]) + abs(a[i][1]-c[j][1])
    print(ans)
# Judge status: Accepted
n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for i in range(n):
    for j in range(i+1, n):
        d = sum((y-z)**2 for y, z  in zip(x[i], x[j])) ** 0.5
        if int(d) == d:
            ans += 1
print(ans)
# Judge status: Wrong Answer
S,W = map(int, input().split())
if W>S:
  print("unsafe")
else:
  print("safe")
# Judge status: Accepted
N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
xflg = True
yflg = True
for z in range(100):
  if X < z <= Y:
    for xn in x:
      if z <= xn:
        xflg = False  
    if xflg:
      for yn in y:
        if yn < z:
          yflg = False 
      if yflg:
        print('No War')
        exit()
      else:
        yflg = True
    else:
      xflg = True
print('War')
# Judge status: Accepted
import sys
S = input()
T = input()

if T in S:
    print(0)
    sys.exit(0)

ans = []
for i in range(len(S)-len(T)+1):
    s = S[i:i+len(T)]
    cnt = 0
    for x, y in zip(s, T):
        if x == y:
            cnt += 1
    ans.append(cnt)
    
print(len(T)-max(ans))
# Judge status: Accepted
# -*- coding: utf-8 -*-
"""
B - Golden Apple
https://atcoder.jp/contests/abc134/tasks/abc134_b

"""
import sys


def solve(N, D):
    ans = 1
    covered = D + 1 + D
    while covered < N:
        ans += 1
        covered += (2*D + 1)
    return ans


def main(args):
    N, D = map(int, input().split())
    ans = solve(N, D)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
# Judge status: Accepted
n = int(input())
w = list(map(int, input().split()))

ans = 100000
for t in range(1, n):
    ans = min(ans, abs(sum(w[:t]) - sum(w[t:])))

print(ans)
# Judge status: Accepted
X = int(input())
x = 0
time = 0
while x < X:
    time += 1
    x += time
print(time)
# Judge status: Accepted
l = list(map(int,input().split()))
k = int(input())
print(sum(l)+max(l)*(2**k-1))
# Judge status: Accepted
N = input()
res = 9*(len(N)-1)+int(N[0])-1
if str(int(N)+1)[0] != N[0]:
    res += 1
if len(N) == 1:
    res = N
print(res)
# Judge status: Accepted
N = int(input())

if N%2==1:
    print(0)
else:
    counter = 0
    tmp = 1
    while True:
        tmp *= 5
        
        if tmp>N:
            print(counter)
            break
        counter += N//(tmp*2)
# Judge status: Accepted
a,b=map(int,input().split())
if 0<a<=b:
  print("Positive")
elif a<=b<0:
  if (b-a+1)%2==0:
    print("Positive")
  else:
    print("Negative")
elif a<=0<=b:
  print("Zero")
# Judge status: Accepted
K1 = 1
K2 = 27
K3 = 703
K4 = 18279
K5 = 475255
alpha = "abcdefghijklmnopqrstuvwxyz"

n = int(input())

a = ""

def func(n,k):
	global a
	a=alpha[n%26]+a
	if(k>1):
		func(n//26,k-1)

sum = 0
for i in range(1,15):
	sumb = sum
	sum += 26**i
	if(sum >= n):
		#print(n-sumb-1,i)
		func((n-sumb-1),i)
		break
print(a)
# Judge status: Accepted
n,m=map(int,input().split())
p=10**9+7
if abs(n-m)>=2:
    print(0)
elif n==m:
    ans=1
    for i in range(1,n+1):
        ans=(ans*i)%p
    print((2*ans*ans)%p)
else:
    ans=1
    for i in range(1,n+1):
        ans=(ans*i)%p
    for i in range(1,m+1):
        ans=(ans*i)%p
    print(ans%p)
# Judge status: Wrong Answer
n=int(input())
csf=[list(map(int,input().split())) for _ in range(n-1)]
for i in range(n-1):
    ans=0
    for j in range(i,n-1):
        c = csf[j][0]
        s = csf[j][1]
        f = csf[j][2]
        if j==i:
            ans+=s+c
        else:
            if ans<s:
                ans=s+c
            else:
                ans+=(f-(ans-s)%f)+c
    print(ans)
print(0)
# Judge status: Accepted
N=int(input())

slist,s0list,s1list=[],[],[]
for i in range(N):
  s=int(input())
  slist.append(s)
  if s%10==0:
    s0list.append(s)
  else:
    s1list.append(s)
#print(slist,s0list,s1list)

if sum(slist)%10!=0:
  print(sum(slist))
elif len(s1list)==0:
  print(0)
else:
  s1list.sort()
  print(sum(slist)-s1list[0])
# Judge status: Accepted
A1,A2,A3 = map(int,input().split())

if A1 + A2 + A3 >= 22:
    print("bust")
else:
    print("win")
# Judge status: Wrong Answer
a,b = list(map(int, input().split()))
ans = 0

for i in range(a):
  for j in range(a):
    for k in range(a):
      if i+j+k==b:
        ans += 1
        
print(ans)
# Judge status: Wrong Answer
n=int(input())
dp=[]
for i in range(n):
  l=list(map(int,input().split()))
  dp.append(l)
for i in range(1,n):
  for j in range(3):
  	dp[i][(j%3)]+=max(dp[i][(j+1)%3],dp[i][(j+2)%3]) 
print(max(dp[n-1]))
# Judge status: Accepted
N,K=map(int,input().split())
P=list(map(int,input().split()))
from itertools import accumulate
acc=[0]+list(accumulate(P))
print((max(b-a for a,b in zip(acc,acc[K:]))+K)/2)
# Judge status: Accepted
num = int(input())

ac = 0
wa = 0
tle = 0
re = 0

for i in range(num):
    k = input()
    if k == "AC":
        ac += 1
    elif k == "WA":
        wa += 1
    elif k == "TLE":
        tle += 1
    elif k == "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
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
counter=0
tem=0
for i in range(n):
	at=(a[i]-tem)+a[i+1]
	if b[i]>=at:
		counter+=at
		tem=a[i+1]
	if at>b[i]:
		counter+=b[i]
		if b[i]-(a[i]-tem)>0:
			tem=b[i]-(a[i]-tem)
		else:
			tem=0
print(counter)
# Judge status: Accepted
N = int(input())

result = ""

for _ in range(N):
  D1, D2 = map(int, input().split())
  if D1 == D2:
    result += "1"
  else:
    result += "0"

if "111" in result:
  print("Yes")
else:
  print("No")
# Judge status: Accepted

def solve():
#    tmp_max = P[0]
    tmp_min = P[0]
    cnt = 1
    for i in range(0,N):
        if P[i] < tmp_min:
            tmp_min = P[i]
            cnt += 1
    print(cnt)


if __name__ == "__main__":
    N = int(input())
    P = list(map(int, input().split()))
    solve()
# Judge status: Accepted
x,y=map(int,input().split())
i=0
while x<=y:
    i+=1
    x*=2
print(i)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
sum = 0

A.append(0)

for i in range(N):
  sum += B[A[i]-1]
  if A[i+1] == A[i] + 1:
    sum += C[A[i]-1]

print(sum)
# Judge status: Accepted
N = int(input())
cnt = 0
m = float("inf")
S = 0
for a in map(int, input().split()):
    m = min(m, abs(a))
    if a < 0:
        cnt += 1
        S -= a
    else:
        S += a
if cnt%2:
    print(S-2*m)
else:
    print(S)
# Judge status: Accepted
i = int(input())
s = input()
print(s[:i]+"..." if len(s)>i else s)
# Judge status: Accepted
n,k = map(int,input().split())
s = str(input())
print(str(s[:k-1]+s[k-1].lower()+s[k:]))
# Judge status: Accepted
print("bust") if sum(map(int,input().split()))>21 else print("win")
# Judge status: Wrong Answer
a=list(input())
for i in range(3):
  if a[i]==a[i+1]:
    print('Bad')
    break
  else:
    print('Good')
# Judge status: Wrong Answer
a,b,c,d = map(int, input().split())
if b<=c:
  print(0)
  exit()
print(b-c)
# Judge status: Wrong Answer
import itertools

n = int(input())

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

zzz = list(itertools.combinations(l,2))


cnt = 0

for z in zzz:

    b = z[0]
    c = z[1]

    b_flg = True

    c_flg = True

    for i in l:
        if b_flg and i == b:
            continue

        if c_flg and i == c:
            continue
                
        if abs(b-c) < i < b+c:
            cnt += 1

print(cnt / 3)
# Judge status: Wrong Answer
n,k=map(int, input().split())
print(n%k)
# Judge status: Wrong Answer
N = int(input())
A = [[0]*10 for _ in range(10)]
for i in range(N):
  a = i%10 #1の位
  b = i // (10**(len(str(i))-1))
  if a!= 0:
    A[a][b] += 1
t = 0
for i in range(1,10):
  s = A[i][i]
  if s != 0:
    t += int(s + (s*(s-1)))
for i in range(1,9):
  for j in range(i+1,10):
    t += A[i][j] * A[j][i]*2
print(t)
# Judge status: Accepted
n = input()
if n[0] == "9" or n[1] == "9":
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
K,X= input().split()
if 500*K>=X:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
letter = str(input())
N = len(letter)

l_1 = letter[:int((N-1)/2)]
l_2 = letter[int((N+3)/2-1):]

if(letter == letter[::-1] and l_1 == l_1[::-1] and l_2 == l_2[::-1]):
    ans = "Yes"
else:
    ans = "No"
# print(l_1)
# print(l_2)

print(ans)
# Judge status: Accepted
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

lis = set(s)
ans = 0

for i in lis:
    x = s.count(i) - t.count(i)
    ans = max(ans,x)
print(ans)
# Judge status: Wrong Answer
n, k = map(int, input().split())
H = list(map(int, input().split()))
sH = sorted(H, reverse=True)
ans = sum(sH[k:n-1:])
print(ans)
# Judge status: Accepted
a,b=map(int,input().split())
print("Yes"if 500*a>=b else"No")
# Judge status: Wrong Answer
k,n = map(int,input().split())
arr = list(map(int,input().split()))

res = 0
for i in range(n):
    if arr[i] != 0:
        res += abs(arr[i]-(k/2))
print(int(res))
# Judge status: Wrong Answer
data = list(map(int, input().split()))
k = int(input())
if k == 1:
    print( sum(data) + max(data) )
else:
    tmp = max(data)
    for _ in range(k):
        tmp = tmp ** 2
    print( sum(data) + tmp - max(data) )
# Judge status: Wrong Answer
n = int(input())
import math
a = n*100/108
b = (n*100+100)/108
ans = math.ceil(a) if math.ceil(a) != b else ":("
print(ans)
# Judge status: Accepted
n=int(input())
x=0
ans=0
s=input()
for i in s:
  if i=='I':
    x+=1
  else:
    x-=1
  ans=max(ans,x)
print(ans)
# Judge status: Accepted
t=False
for i in input():
    if i=='7':
        t=True
        break
print('Yes' if t==True else 'No')
# Judge status: Accepted
N, M = map(int, input().split(" "))
 
a = list(set(map(int, input().split(" "))))
g = a.copy()
 
while not any(x%2 for x in g): g = [i //2 for i in g]
 
if not all(x%2 for x in g): print(0); exit(0)
 
def gcd(a, b):
 
    while b:
 
        a, b = b, a % b
    return a
 
def lcm(a, b):
    return a * b // gcd(a, b)
 
 
tot = 1
 
for x in a: tot = lcm(tot, x//2)
print((M//tot+1)//2)
# Judge status: Wrong Answer
A,B=map(int,input().split())
ans="Yay!"
if A>9 or B>9:
    ans=":("
print(ans)
# Judge status: Wrong Answer
N = int(input())
a = [int(i) for i in input().split()]
ans = 0
for i in range(N):
    if i%2 == 1:
        if a[i]%2 == 1:
            ans += 1
print(ans)
# Judge status: Accepted
a, b = map(int, input().split())

if(a > 0):
    print("Positive")
elif(a < 0 and b >= 0):
    print("Zero")
elif(a < 0 and b < 0):
    if((abs(a-b)+1)%2 == 0):
        print("Positive")
    else:
        print("Negative")
# Judge status: Accepted

import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,p=map(int,input().split())
A=list(map(int, input().split()))
AA = [0]*n
for i in range(n):
    if A[i]%2:
        AA[i]=1
sumA = sum(AA)
res1 = 0
for i in range(p,sumA+1,2):
    res1 += comb(sumA,i)
res0 = 2**(n-sumA)

print(res1*res0)
# Judge status: Accepted
def resolve():
	x, a, b = map(int, input().split())
	if abs(x-a) > abs(x-b):
		print('B')
	else:
		print('A')
resolve()
# Judge status: Accepted
n=int(input())
c=input()
w_num=c.count("W")
r_num=c.count("R")
now_r_num=0
for i in range(r_num):
    if c[i]=="R":
        now_r_num+=1
print(r_num-now_r_num)
# Judge status: Wrong Answer
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

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

W = H = 0
for k,v in Counter(A).items():
    if v > 1:
        if W == 0: W = k
        elif H == 0:
            H = k
            break

print(H*W)
# Judge status: Accepted
n, x, t = map(int, input().split())

if n % x == 0:
    ans = n // x * t
else:
    ans = (n // x + 1) * t 

print(ans)
# Judge status: Accepted
W, H, N = map(int, input().split())

x_lt = 0
x_rt = W

y_lt = 0
y_rt = H

for _ in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        x_lt = max(x, x_lt)
    elif a == 2:
        x_rt = min(x, x_rt)
    elif a == 3:
        y_lt = max(y, y_lt)
    else:
        y_rt = min(y, y_rt)

res = max(x_rt - x_lt, 0) * max(y_rt - y_lt, 0)

print(res)
# Judge status: Wrong Answer
S = set(input())
T = set(input())
if len(S)==len(T):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
a,b,c,x,y = map(int, input().split())

costs = 0

while x>0 and y>0:
  if a+b>2*c:
    costs += 2*c
  else:
    costs = costs+a+b
  x -= 1
  y -= 1
  
if x>0:
  if a<=2*c:
    costs += x*a
  else:
    costs += x*2*c
    
if y>0:
  if b<=2*c:
    costs += x*b
  else:
    costs += x*2*c
  
print(costs)
# Judge status: Accepted
def digit_sum(n):
    n_lst = list( str(n) )
    n_sum = 0
    for i in range( len(n_lst) ):
        n_sum += int( n_lst[i] )
    return n_sum

n1 = input()
if digit_sum(n1)%9==0 : print("Yes")
else: print("No")
# Judge status: Accepted
#!/usr/bin/env python3
s = input()
ans = len(s)
for i in range(0, 2):
    cnt = 0
    for j in range(0, len(s)):
        if j % 2 == 0 and s[j] != str(i): cnt += 1
        if j % 2 == 1 and s[j] == str(i): cnt += 1
    ans = min(ans, cnt)
print(ans)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

max_cnt=sum(b)-sum(a)
if max_cnt<0:
    print("No")
    exit()
b_cnt=0
a_cnt=0
for i in range(n):
    if a[i]>b[i]:
        b_cnt+=a[i]-b[i]
    elif a[i]<b[i]:
        a_cnt+=(b[i]-a[i])//2
print("Yes" if b_cnt<=a_cnt else "No")
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
m=1000
ze=201
cou=0
for i in range(n):
  if a[i]<ze:
    cou+=m//a[i]
    m=m%a[i]
    ze=a[i]
    
  elif a[i]>ze:
    m+=a[i]*cou
    cou=0
    ze=a[i]
  else:
    continue
print(m)
# Judge status: Wrong Answer
n=int(input())
ans=0
a=[]
for i in range(n):
  a.append(list(map(int,input().split())))
for i in reversed(range(n)):
  if a[i][1] != 1:
    a[i][0] += ans
    ans += a[i][1] - a[i][0] % a[i][1]
print(ans)
# Judge status: Accepted
n = int(input())
sum = float('inf')

for i in range(1, n):
    k = 0
    for j in range(len(str(i))):
        k += float(str(i)[j])
    for l in range(len(str(n-i))):
        k += float(str(n-i)[l])
    sum = min(sum, k)

print(int(sum))
# Judge status: Accepted
import sys
input = sys.stdin.readline

S = list(input().rstrip('\n'))
K = int(input())

n = 1
for i in range(min(len(S), K)):
    if S[i] != '1':
        n = int(S[i])
        break
print(n)
# Judge status: Wrong Answer
S = input()

day = 0
counter = 0

for i in S:
    counter += 1
    if i == 'S':
        if counter == 2:
            day = 0
        pass
    elif i == 'R':
        day += 1

print(day)
# Judge status: Accepted
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
s = input()

if s == 'Sunny':
  print('Cloudy')
elif s == 'Cloudy':
  print('Rainy')
else:
  print('Sunny')
# Judge status: Accepted
s = input()
ans = ''
for k in s:
    if k == 'B':
        if ans: ans = ans[:-1]
    else: ans += k
print(ans)
# Judge status: Accepted
n = int(input())
s = []
for i in range(n):
  s.append(int(input()))
ans = sum(s)
if ans % 10 == 0:
  s.sort()
  f = 0
  for i in range(n):
    if s[i] % 10 == 0:
      next
    else:
      ans -= s[i]
      f = 1
      break
  if f == 0:
    ans = 0
print(ans)
# Judge status: Accepted
N = int(input())

a = []

# 1
a.append(1)

# 6**n
b = 6
while b <= N:
    a.append(b)
    b *= 6

# 9**n
b = 9
while b <= N:
    a.append(b)
    b *= 9

a.sort()

dp = [N] * (N+1)
dp[0] = 0
for i in range(N):
    for j in a:
        if i+j > N:
            break
        dp[i+j] = min(dp[i]+1, dp[i+j])
print(dp[N])
# Judge status: Accepted
import numpy as np
N, M = map(int, input().split())
X = list(map(int, input().split()))
sortX = np.array(sorted(X), dtype=np.int64)
diffX = np.sort(np.diff(sortX))
if N == 1:
    print(np.sum(diffX))
    exit()
ans = np.sum(diffX[:-(N-1)])
print(ans)