peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=sum(b)
for i in range(n-1):
    if a[i+1]==a[i]+1:
        ans+=c[a[i]-1]
print(ans)
# Judge status: Wrong Answer
n, m = map(int, input().split())

cnt = n * 2 + m * 1
print(cnt // 4)
# Judge status: Wrong Answer

N = int(input())

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

ans = 1
f = False

for i in range(N-2):

    i += 1

    if f:
        f = False
        continue

    if A[i-1] > A[i] and A[i] < A[i+1]:
        ans += 1
        f = True

    elif A[i-1] < A[i] and A[i] > A[i+1]:
        ans += 1
        f = True

print (ans)
# Judge status: Accepted
a, b, c, x, y = map(int, input().split())
ans1 = a * x + b * y  #そのまま
ans2 = 0
if x > y:  #少ない方をABで補う
    ans2 = c * min(x, y) * 2 + a * (x - y)
else:
    ans2 = c * min(x, y) * 2 + b * (y - x)
ans3 = c * max(x, y) * 2  #すべてABで
print(min(ans1, ans2, ans3))
# Judge status: Accepted
N, M = map(int, input().split())
A = []
B = []
C = []
flag = 0

for i in range(N):
  A.append(input())
for i in range(M):
  B.append(input())

for i in range(N- M+ 1):
  for j in range(N- M+ 1):
    C = []
    for k in range(M):
      C.append(A[j+ k][i:i+ M])
    if(B == C):
      print("Yes")
      flag = 1
      break
  if(flag == 1):
    break
else:
  print("No")
# Judge status: Accepted
def main():
 num = list(map(int,input().split()))
 bad = list(map(int,input().split()))

 while True :
  flg=0
  
  for i in range(0,len(str(num[0]))):
   stnum=str(num[0])
   if int(stnum[i]) in bad:
    flg=1
    break
   
  if flg==1:
   num[0]+=1
   continue
  else:
   break
  
 print(num[0])

main()
# Judge status: Accepted
from collections import deque
import itertools

n,m,q = list(map(int,input().split()))
l = []
for i in range(q):
    line = list(map(int,input().split()))
    l.append(line)
ans = 0

comb = itertools.combinations_with_replacement(range(1,m+1),n)
for s in comb:
    tmp = 0
    for j in range(q):
        a,b,c,d = l[j]
        if c == s[b-1]-s[a-1]:
            tmp += d
    ans = max(ans,tmp)

print(ans)
# Judge status: Wrong Answer
N = int(input())

k = 10
ans = 0
if N % 2 != 0:
    ans = 0
elif N == 0:
    ans = 1
else:
    while k <= N:
        ans += N // k
        k *= 5

print(ans)
# Judge status: Wrong Answer
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()

score=0
scorei=0
myans=[]
myansi=""
for i in range(n):
    if(t[i]=="r"):
        myansi="p"
        scorei=p
    elif(t[i]=="s"):
        myansi="r"
        scorei=r
    else:
        myansi="s"
        scorei=s

    if(i>=k and myansi==myans[i-k]):
        myansi=t[i]
        scorei=0

    myans.append(myansi)
    score+=scorei
print(score)
# Judge status: Wrong Answer
N=int(input())
A=list(map(int,input().split()))
c=0
for i in range(len(A)):
  if A.count(A[i])==0:
    c=c+1

if c==0:
  print("NO")
else:
  print("YES")
# Judge status: Accepted
def resolve():
    d = int(input())
    ci = list(map(int, input().split()))
    si = [list(map(int, input().split())) for _ in range(d)]
    answers = []
    for i in range(d):
        certain_date_s = si[i]
        answers.append(certain_date_s.index(max(certain_date_s))+1)
    [print(answer) for answer in answers]
resolve()
# Judge status: Accepted
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    a = list(map(int, input().split()))
    if sum(a) >= 22:
        print('bust')
    else:
        print('win')        

if __name__ == '__main__':
    main()
# Judge status: Accepted
a, b = map(int, input().split())
if a >= 13:
    print(b)
elif a >= 6:
    print(b // 2)
else:
    print(0)
# Judge status: Wrong Answer
A, B, C = map(int, input().split())
K = int(input())
while A > B:
    B *= 2
    K -= 1
while B > C:
    C *= 2
    K -= 1
if K >= 0 and A < B < C:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N=int(input())
l=[int(x) for x in input().rstrip().split()]
l.sort()
if l[len(l)//2-1]==l[len(l)//2]:
  print(0)
else:
  print(l[len(l)//2]-l[len(l)//2-1])
# Judge status: Accepted
a,b,x=map(int,input().split())

if a==0:
    fl=-1
else:
    fl=(a-1)//x

cl=b//x

print(cl-fl)
# Judge status: Accepted
x = int(input())

ans = 0
syo1 = x // 500
ans += syo1 * 1000
x = x - 500 * syo1
ans = ans + (x // 5) * 5
print(ans)
# Judge status: Accepted
N = input()
lit_N = []
for i in range(int(N)+1):
  if i % 5 == 0 and i % 3 == 0:
    lit_N.append("FizzBuzz")
  elif i % 3 == 0:
    lit_N.append("Fizz")
  elif i % 5 == 0:
  	lit_N.append("Buzz")
  else:
    lit_N.append(i)
print(sum(list(filter(lambda x: isinstance(x,int), lit_N))))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

MOD = 10 ** 9 + 7

def gcd(x, y):
  while y: x, y = y, x % y
  return x

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

tmp = A[0]
for i in range(1, N):
  tmp = lcm(A[i], tmp)
tmp %= MOD

answer = 0
for a in A:
  answer += tmp * pow(a, MOD - 2, MOD)
  
print(answer % MOD)
# Judge status: Wrong Answer
s = input()

ans = 'Good' if s[0] == s[1] or s[1] == s[2] or s[2] == s[3] else 'Bad'
print(ans)
# Judge status: Wrong Answer
N = int(input())

cake = [i for i in range(4, N+1, 4)]

dons = [i for i in range(7, N +1, 7)]

ans = "No"
for i in range(N//4):
    for j in range(N//7):
        if cake[i] + dons[j] == N:
            ans = "Yes"
            break

ans
# Judge status: Accepted
a, b, c = map(int, input().split())

if b-a==c-b:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
def main():
    H = int(input())
    W = int(input())
    N = int(input())
    long = max(H, W)
    cnt = N // long
    if N % long != 0:
        cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()
# Judge status: Accepted
x = int(input())
res = 0
if(x>=500):
  p = x//500
  res = p*1000
  x = x-(p*500)
if(x>=5):
  z = x//5
  res = res+(z*5)
print(res)
# Judge status: Accepted
import math as m
A, B, N = map(int, input().split())
if N >= B: print(m.floor(A * -1 / B) - A * m.floor(-1 / B))
else: print(m.floor(A * N / B) - A * m.floor(N / B))
# Judge status: Wrong Answer
a, x =map(int, input().split())
if (a+x)%2 ==0:
  print((a+x)/2)
else:
  print('IMPOSSIBLE')
# Judge status: Wrong Answer
H = int(input())
flag = 0
while H !=1:
    if H%2 == 1:
        H+=1
    H =H/2
    flag +=1

S =0
for i in range(flag):
    S +=2**(i)

print('{}'.format(2**(flag+1)-1))
# Judge status: Accepted
n, m = map(int,input().split())

if abs(n-m) <= 1:
  sumN = 1
  sumM = 1 
  for i in range(2,n+1):
    sumN = sumN*i % (10**9+7) 
  for i in range(2,m+1):
    sumM = sumM*i % (10**9+7) 
  if n==m:
    print(2*sumM*sumN % (10**9+7))
  else:
    print(sumM*sumN % (10**9+7))
else:
  print(0)
# 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:
  group_x=0
elif x in b:
  group_x=1
else:
  group_x=2

if y in a:
  group_y=0
elif y in b:
  group_y=1
else:
  group_y=2

if group_x==group_y:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
n, a, b = [int(i) for i in input().split()]

x = int(n/(a+b))
y = int(n%(a+b))

if y > a:
  y = int(a)
  

print(int((x*a)+y))
# Judge status: Accepted
K, X = list(map(int, input().split()))

if K * 500 >= X:
  	print('Yes')
else:
  	print('No')
# Judge status: Accepted
N, M = map(int, input().split())

if N==M:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
import bisect
import math

n, m = map(int, input().split())
a = []
b = []
for i in range(n):
    aa, bb = map(int, input().split())
    a.append(aa)
    b.append(bb)

ma = max(a)
b = sorted(b)
mab = bisect.bisect_left(b, ma)
sb = sum(b[mab:])

def cut_throw(ma, sb):
    res = math.ceil((m - sb) / ma)
    return res

if sb <= m:
    print(cut_throw(ma, sb) + n - mab)
else:
    print(bisect.bisect_left(b, m))
# Judge status: Accepted
import collections,sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
A = sorted(LI())
counter_A = collections.Counter(A)
sequence = [0]*(10**6+1)
ans = 0
for k,v in counter_A.items():
    if sequence[k]==1:
        continue
    if v==1:
        ans += 1
    for i in range(k,10**6+1,k):
        sequence[i] = 1
print(ans)
# Judge status: Accepted
n = int(input())
a = [int(i) for i in input().split()]
max_a = max(a)
a.remove(max_a)
da = [abs(ai - max_a/2) for ai in a]
med_i = da.index(min(da))
print(max_a, a[med_i])
# Judge status: Accepted
s = list(input())

ans = float("inf")
for i in range(len(s)-2):
    t = int("".join(s[i:i+3]))
    ans = min(ans, abs(t-753))
print(ans)
# Judge status: Wrong Answer
s = list(input())
num = 0
n = len(s)
l = []
i = 0
while i < n:
  if s[i] == '<':
    l.append(num)
    num+=1
    i+=1
    if i==n:
      l.append(num)
  else:
    cur = 0
    while i < n and s[i]=='>':
      l.append(cur)
      i+=1
      cur+=1
    num = 1
    if i==n:
      l.append(cur)
print(sum(l))
# Judge status: Accepted
A,B=map(int,input().split())

ansA=A*(100/8)#この数か、この数よりでかI数となる
if ansA==int(ansA):#小数点以下０なら
    ansA=int(ansA)
else:
    ansA=int(ansA)+1


ansB=B*10#この数か、この数よりでかい数となる

if ansA>=ansB:
    ans=ansA
else:
    ans=ansB

if int(ans*(8/100))==A and int(ans*(10/100))==B:
    print(ans)
else:
    print(-1)
# Judge status: Wrong Answer
#AGC015-A
n,a,b = map(int,input().split())

mi = a * (n-2)
ma = b * (n-2)
result = ma - mi + 1
if a > b:
    print(0)
elif a == b and n != 1:
    print(0)

elif n == 2:
    print(1)
elif result < 0:
    print(0)
    
else:
    print(result)
# Judge status: Wrong Answer
k = int(input())
a, b = list(map(int, input().split()))

for i in range(a, b):
    if i % k == 0:
        print('OK')
        exit()
print('NG')
# Judge status: Wrong Answer
import math,numpy, collections

n = int(input())
ans = n
cnt = 0
for i in range(n):
    cnt = 0
    x = i
    while x >0:
        cnt += x%6
        x = x//6
    y = n-i
    while y >0:
        cnt += y%9
        y = y//9
    ans = min(ans,cnt)

print(ans)
# Judge status: Wrong Answer
a = int(input())
print((a//2) * (a+1)//2)
# Judge status: Accepted
X = int(input())
for i in range(8):
    if X >= 1800 - 200 * i:
        print(1 + i)
        exit()
# Judge status: Wrong Answer
def calc():
    rem = (a + b)%2
    ans = 0

    if rem == 0:
        ans = (a+b)/2
        return ans
    else:
        ans = (a+b)//2 + 1
        return ans

a, b = map(int,input().split())
print(calc())
# Judge status: Accepted
S = str(input())

data = ['A','C','G','T']

acgt = ''
for s in S:
    if s not in data:
        acgt += '.'
    else:
        acgt += s

ans = 0
for s in acgt.split('.'):
    ans = max(ans, len(s))
print(ans)
# Judge status: Accepted
from collections import deque
N = int(input())
A = [int(x) for x in input().split()]
if N%2==0:
    queue = deque()
    for i in range(0, N, 2):
        queue.append(A[i])
        queue.appendleft(A[i+1])
else:
    queue = deque([A[0]])
    for i in range(1, N, 2):
        queue.append(A[i])
        queue.appendleft(A[i+1])

print(*queue)
# Judge status: Wrong Answer
h = int(input())

dp = [0, 1]

for i in range(2, 100001):
    x = 1 + 2 * dp[i // 2]
    dp.append(x)


if h < 100001:
    print(dp[h])



else:
    l = []
    y = h
    while y >= 100001:
        l = [x] + l
        y = y// 2
    ans = 1 + 2 * dp[l[0] // 2]
    if len(l) > 1:
        for i in range(len(l) - 1):
            ans = 1 + 2 * ans
    print(ans)
# Judge status: Accepted
A, B, H, M = map(int,input().split())

import numpy as np
theta_h=2*np.pi*(H/12 + M/720)#rad
theta_m=2*np.pi*M/60#rad
theta=min((max(theta_h, theta_m)-min(theta_h, theta_m)), 2*np.pi-(max(theta_h, theta_m)-min(theta_h, theta_m)))
print(np.sqrt(A**2 + B**2 - 2*np.cos(theta)*A*B))
# Judge status: Accepted
a,b = map(int, input().split())

if a%3==0 or b%3==0 or (a+b)%3==0:
  print("Possible")
else:
  print("Impossible")
# Judge status: Accepted
def main():
    S = list(input())
    ans = []
    for s in S:
        if s == '0':
            ans.append('0')
        elif s == '1':
            ans.append('1')
        else:
            if len(ans) > 0:
                ans.pop()
    print(''.join(ans))

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
import collections
N = int(input())
A = list((map(int,input().split())))

index = list(range(1,N+1))

R = [index[i] - A[i] for i in range(N)]
L = [index[j] + A[j] for j in range(N)]

R_dict = collections.Counter(R)
L_dict = collections.Counter(L)

ans=0
for i in R_dict.keys()&L_dict.keys():
    # print(R_dict[i])
    # print(L_dict[i])
    ans+=L_dict[i]

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

if N == 1:
  print(1)
else:
  ans = 0
  i = 0
  while i < N:
    while i + 1 < N and A[i] == A[i + 1]:
      i += 1
    if i + 1 < N and A[i] < A[i + 1]:
      while i + 1 < N and A[i] <= A[i + 1]:
        i += 1
    elif i + 1 < N and A[i] > A[i + 1]:
      while i + 1 < N and A[i] >= A[i + 1]:
        i += 1
    
    ans += 1
    i += 1
      
  print(ans)
# Judge status: Wrong Answer
a,b,t=map(int,input().split())
for i in range(20):
    if a*i < t+0.5:
        k=i
    else:
        break
        
print(b*k)
# Judge status: Accepted
h1, m1, h2, m2, k = map(int, input().split())

ans = (h2-h1)*60 + (m2-m1) - k
print(ans)
# Judge status: Accepted
K, X = map(int, input().split())

if 500 * K >= X:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
S = input()

N = len(S)
Aflag = -1
Zflag = 0
for i in range(N):
    if Aflag == -1 and S[i] == 'A':
        Aflag = i
    elif S[i] == 'Z':
        Zflag = i

print(Zflag-Aflag+1)
# Judge status: Wrong Answer
N=int(input())
A=list(map(int,input().split()))
ans=1
for a in A:
  ans=ans*a
  if ans>10**18:
    print(-1)
    exit()
print(ans)
# Judge status: Wrong Answer
import numpy as np

c = [list(map(int, input().split())) for i in range(3)]
c = np.array(c)
flag = False
for a1 in range(min(c[0] + 1)):
    b1 = c[0, 0] - a1
    b2 = c[0, 1] - a1
    b3 = c[0, 2] - a1
    if c[1, 0] - b1 == c[1, 1] - b2 == c[1, 2] - b3 > 0 and c[2, 0] - b1 == c[2, 1] - b2 == c[2, 2] - b3 > 0:
        print('Yes')
        flag = True

if not flag:
    print('No')
# Judge status: Accepted
a, b = [int(x) for x in input().split()]

s = ss = 0
for i in range(1000):
    s += i
    if s-ss == b-a:
        break
    ss = s
print(s-b)
# Judge status: Accepted
a=int(input())
b=[0]*a
c=list(map(int,input().split()))

for i in range(a):
  b[c[i]-1]+=i+1
print(' '.join(map(str, b)))
# Judge status: Accepted
A,V=list(map(int,input().split(' ')))
B,W=list(map(int,input().split(' ')))
T=int(input())
if A<B:
    if A+T*V>= B+T*W:
        print('YES')
    else:
        print('NO')
if A>B:
    if A-T*V<= B-T*W:
        print('YES')
    else:
        print('NO')
# Judge status: Accepted
import re
s = input()
match = re.match(r"^(dream|dreamer|erase|eraser)+$",s)
print("YES" if match else "NO")
# Judge status: Accepted
n, a, b = map(int, input().split())
print(n // (a + b) * a + min(n % (a + b), a))
# Judge status: Wrong Answer
n = int(input())
al = list(map(int, input().split()))


res = [0]*n
m = n //2

if n % 2 ==0:
    for i in range(m):
        res[i] = al[-1-i*2]    
    for j in range(m):
        res[m+j]= al[j*2]
        
    print(res)
    
else:
    for i in range(m+1):
        res[i] = al[-1-i*2]
    for j in range(m):
        res[m+1+j] = al[1+j*2]
    print(res)
# Judge status: Accepted
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
flag = 0
for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            if a[j+k][i:i+m]!=b[k]:
                break
        else:
            flag = 1
print("Yes" if flag else "No")
# Judge status: Wrong Answer
s = input()
print(min(s.count("1"),s.count("2"))*2)
# Judge status: Accepted
s = int(input())
d = {s: 1}
i = 1

while True:
    if s % 2 == 0:
        s //= 2
    else:
        s = 3 * s + 1
    i += 1
    if s in d.keys():
        print(i)
        exit()
    else:
        d[s] = i
# Judge status: Wrong Answer
N = int(input())
s = input()
t = input()

st = s+t
total_len = len(st)
dupl = 0
for n in range(N+1):
    print(st[N-n:N], st[N:N+n])
    if st[N-n:N] == st[N:N+n]:
        dupl = len(s[n-n:N])

total_len = total_len - dupl

print(total_len)
# Judge status: Accepted
n = list(input())
k = int(n[-1])

if k in (0,1,6,8):
    print("pon")
elif k == 3:
    print("bon")
else:
    print("hon")
# Judge status: Accepted
n=int(input())
p=list(map(int,input().split()))
a=p[0]
cnt=1
for i in p:
    if i<a:
        cnt+=1
        a=i
        if i==1:
            break
print(cnt)
# Judge status: Accepted
from math import floor

def solve(n, A):
    B = sorted([a - (i + 1) for i, a in enumerate(A)])
    b = B[n // 2]
    ret = sum(abs(a - (b + i + 1)) for i, a in enumerate(A))
    if n % 2 == 0:
        b = B[n // 2 + 1]
        tmp = sum(abs(a - (b + i + 1)) for i, a in enumerate(A))
        if tmp < ret:
            ret = tmp
    return ret

_n = int(input())
_A = list(map(int, input().split()))
print(solve(_n, _A))
# Judge status: Accepted
n, k = map(int, input().split())
arr = [False for i in range(n + 1)]
count = 0
for i in range(k):
    d = int(input())
    darr = list(map(int, input().split()))
    for j in darr:
        arr[j] = True
for i in range(len(arr)):
    if arr[i] == False:
        count+=1
print(count - 1)
# Judge status: Accepted
def main():
    s = input()
    if s == "ARC":
        print("ABC")
    else:
        print("ARC")
    

if __name__ == "__main__":
    main()
# Judge status: Accepted
H, N = map(int, input().split())

skill_list = []
for i in range(N):
  skill_list.append(list(map(int, input().split())))

max_B = 0
for i in range(N):
  if skill_list[i][0] > max_B: max_B = skill_list[i][0]

dp = [float('inf') for i in range(H + max_B)]

dp[0] = 0
for i in range(H):
  for j in range(N):
    if dp[i + skill_list[j][0]] > dp[i] + skill_list[j][1]:
      dp[i + skill_list[j][0]] = dp[i] + skill_list[j][1]

print(min(dp[H : H + max_B]))
# Judge status: Accepted
N, A, B = map(int, open(0).read().split())

ans = N // (A+B) * A
x = N % (A+B)
if x >= A:
    ans += A
else:
    ans += x

print(ans)
# Judge status: Accepted
import sys

N, A, B = map(int, input().split(' '))
if (B - A) % 2 == 0:
    print((B - A) // 2)
else:
    print(min((A+B-1)//2, (N*2-A-B+1)//2))
# Judge status: Wrong Answer
def readInt():
    return list(map(int,input().split()))
n = int(input())
ans = 0
while n > 0:
    ans += int(n%10)
    n = int(n/10)
print(ans)
# Judge status: Wrong Answer
n,k=map(int,input().split())
ans=[[] for _ in range(n//2)]
for i in range(1,k+1):
  ans[i-1].append(i)
for i in range(1,k+1):
  ans[i-1].append(n-i+1)
for i in range(k):
  print(*ans[i])
# Judge status: Wrong Answer
a = int(input())
b = int(input())
n = int(input())
t = max(a, b)
print(n + t - 1 // t)
# Judge status: Accepted
from collections import deque
N = int(input())
v = list(map(int, input().split()))

v = sorted(v)
v = deque(v)


for i in range(N - 1):
    cal = 0
    cal += v.popleft()
    cal += v.popleft()
    cal = cal / 2
    v.appendleft(cal)

print(v.pop())
# Judge status: Accepted
import collections
s = [input() for i in range(int(input()))]
t = [input() for i in range(int(input()))]
s = list(collections.Counter(s).items())
ans = [0]
for i in range(len(s)):
  ans.append(s[i][1]-t.count(s[i][0]))
ans.sort(reverse = True)
print(ans[0])
# Judge status: Accepted
text = list(map(int, input().split()))
text.sort()
if text[0] == 5 and text[1] == 5 and text[2] == 7:
  print('YES')
else:
  print('NO')
# Judge status: Accepted
N = int(input())
A = [int(x) - 1 for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

result = 0
was = -5
for a in A:
    result += B[a]
    if was == a-1:
        result += C[a-1]
    was = a

print(result)
# Judge status: Wrong Answer
import sys

N, K = map(int, input().split())
A = list(map(int, sys.stdin.readline().rsplit()))

print((N - 1) // (K - 1))
# Judge status: Accepted
a = input()
if a.count(a[0])==2 and a.count(a[1])==2 and a.count(a[2])==2:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
import sys
from collections import deque

sys.setrecursionlimit(10 ** 6)


def input(): return sys.stdin.readline().rstrip()

N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

print('No War' if any(max(x) < Z and min(y) >= Z for Z in range(X + 1, Y + 1)) else 'War')
# Judge status: Accepted
x,a,b=map(int,input().split())
y=abs(x-a)
z=abs(b-x)
if y<z:
    print('A')
else:
    print('B')
# Judge status: Accepted
a,b,c,d = map(int,input().split())
check = min(b,d) - max(a,c)
print(check) if check > 0 else print(0)
# Judge status: Wrong Answer
x, n = map(int, input().split())
pli = [int(i) for i in input().split()]
ans = 0
for s in range(1, 100):
    if not x in pli:
        ans = x
    elif not x - s in pli and not x + s in pli:
        ans = x - s
        break
    elif x - s in pli and not x + s in pli:
        ans = x + s
        break
print(ans)
# Judge status: Accepted
import heapq

N, M = map(int, input().split())
jobs = {m: [] for m in range(1, M + 1)}
for _ in range(N):
    a, b = map(int, input().split())
    if a in jobs:
        jobs[a].append(b)

q = []
ans = 0
for m in range(1, M + 1):
    for b in jobs[m]:
        heapq.heappush(q, -b)
    if len(q) > 0:
        neg_b = heapq.heappop(q)
        ans += -neg_b

print(ans)
# Judge status: Accepted
n = int(input())
a = int(input())
print('No' if n%500>a else 'Yes')
# Judge status: Wrong Answer
def gcd(a,b):
  if b > a:
    c = a
    a = b
    b = c
  while b != 0:
    a = b
    b = a % b
  return a
k = int(input())
ans = 0
for ind0 in range(1,k+1):
  for ind1 in range(1,k+1):
    for ind2 in range(1,k+1):
      ans += gcd(gcd(ind0,ind1),ind2)
print(ans)
# Judge status: Wrong Answer
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    w=list(input())
    w.sort()
    if len(w)%2!=0:
        print('No')
    else:
        for i in range(0,len(w)-1,2):
            if w[i]!=w[i+1]:
                print('No')
                break
        print('Yes')

resolve()
# Judge status: Accepted
K, X = map(int, input().split())
print(' '.join([str(i) for i in range(X-K+1,X+K)]))
# Judge status: Wrong Answer
from bisect import bisect
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

ans = 0
for i in B:
    max_A = bisect(A, i-1)
    min_C = bisect(C, i+1)
    # print("m_A", max_A, "m_C", min_C)
    ans += (max_A)* (len(C) - min_C)
print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
cnt2 = 0
cnt4 = 0
for i in range(n):
    if(a[i] % 4 == 0):
        cnt4 += 1
    elif(a[i] % 2 == 0):
        cnt2 += 1

if((cnt4 * 2 + 1) >= n or cnt2 >= (n - (cnt4 * 2 + 1) + 1)):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N=int(input())
P=list(map(int,input().split()))

Q=[i for i in range(1,N+1)]

count=0
for i in range(N):
  if P[i]!=Q[i]:
    count+=1
if count>=3:
  print("No")
else:print("Yes")
# Judge status: Accepted
def main():
    a, b, c = map(int, input().split())
    Count = 0
    while True:
        b = b-a
        if Count == c or b < 0:
            break
        Count += 1
    print(Count)


if __name__ == "__main__":
    main()
# Judge status: Accepted
n = int(input())
P = list(map(int, input().split()))
sc = sum(p != (i + 1) for i, p in enumerate(P))
if sc == 2 or sc == 0:
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
n = int(input())
xy_li = [list(map(int,input().split())) for _ in range(n)]
from itertools import permutations
import math
def distance(a,b):
    return math.sqrt((a[0]-b[0])**2+(a[1]-b[1])**2)
ans = 0
cnt = 0
i_li = [i for i in range(n)]
for x in permutations(i_li,n):
    cnt += 1
    print(x)
    for i in range(n-1):
        ans += distance(xy_li[x[i]],xy_li[x[i+1]])
        
print(ans/cnt)
# Judge status: Accepted
s = int(input())

div, mod = divmod(s, 10 ** 9)
ans = [0, 0, 10 ** 9, 1]
ans += [(10 ** 9 - mod) * (mod != 0), div + (mod != 0)]
print(*ans)
# Judge status: Accepted
x=int(input())

if x<30 :
  print("No")
else :
  print("Yes")