peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
S=input()
if S=='AAA' or S=='BBB':
  print('No')
else:
  print('Yes')
# Judge status: Accepted
# やっていることは単純だが、何故これで正しい答えが出るのかよくわからない

N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

la = 0
lb = 0
for i in range(N):
    if a[i] > b[i]:
        la += a[i] - b[i]
    elif b[i] > a[i]:
        lb += (b[i] - a[i]) // 2

if lb >= la:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import sys
input = sys.stdin.readline

n, m = map(int, input().split())

print("{}".format(min(n, m)) * max(n, m))
# Judge status: Accepted
S = input()
N = len(S)

Srev = "".join(list(reversed(S)))

if S != Srev:
  print('No')
  exit()

S1 = S[:(N-1)//2]
S1rev = "".join(list(reversed(S1)))
if S1 != S1rev:
  print('No')
  exit()

S2 = S[(N+3)//2 - 1:N]
S2rev = "".join(list(reversed(S2)))

if S2 != S2rev:
  print('No')
  exit()

print('Yes')
# Judge status: Wrong Answer
N,A,B = map(int, input().split())
if A==0:
  print(0)
elif (A+B)>N:
  if N<=A:
    print(A)
  else:
    print(N)
else:
  x=N//(A+B)
  y=N%(A+B)
  print(A*x+y)
# Judge status: Accepted
n = int(input())
dat = list(map(int, input().split()))
maxval = -9999999999999999999
maxind = -1
numminus = 0
dat2 = []

for i in range(n):
    if dat[i] < 0:
        numminus += 1
    dat2.append(abs(dat[i]))

dat2.sort()
#print(numminus)
#print(dat2)

if numminus %2 == 0:
    print(sum(dat2))
else:
    dat2[0] *= -1
    print(sum(dat2))
# Judge status: Accepted
import math

r = int(input())

al = math.pi * r *2

print(al)
# Judge status: Accepted
n = int(input())
a = int(n / 7)
for i in range(a, -1, -1):
    if (n - 7 * i) % 4 == 0:
        print('Yes')
        exit()
print('No')
# Judge status: Accepted
from bisect import bisect_left
N = int(input())
L_list = list(map(int, input().split()))
L_list.sort()

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        a, b = L_list[i], L_list[j]
        r = bisect_left(L_list, a+b)
        ans += max(0,r-j-1)
print(ans)
# Judge status: Wrong Answer
n, m = map(int,input().split())
ans = 0
if n*2 > m:
  if m%2 == 0:
    ans = m//2
  else:
    ans = (m-1)//2
else:
  print("n = {}, m = {}".format(n, m))
  ans += n
  m -= n*2
  print("n = {}, m = {}".format(n, m))
  ans += m//4
print(ans)
# Judge status: Accepted
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]

MOD = 10**9 + 7

safe = [True] * (N+1)
for i in range(len(A)):
    safe[A[i]] = False

dp = [0] * (N+1)
dp[0] = 1
if safe[1]:
    dp[1] = 1

for i in range(2, N+1):
    if(safe[i]):
        dp[i] = dp[i-1] + dp[(i-2)]
        dp[i] = dp[i] % MOD
    else:
        dp[i] = 0

print(dp[N])
# Judge status: Accepted
n = int(input())
count = 0

for i in range(1,n+1):
    if len(str(i)) % 2 == 1:
        count += 1
print(count)
# Judge status: Accepted
Score_Alice, Score_Bob = map(int, input().split())

if Score_Alice == 1 and Score_Bob == 1:
  print('Draw')
elif Score_Alice == 1 and Score_Bob != 1:
  print('Alice')
elif Score_Alice != 1 and Score_Bob == 1:
  print('Bob')
else:
  if Score_Alice > Score_Bob:
    print('Alice')
  elif Score_Alice < Score_Bob:
    print('Bob')
  else:
    print('Draw')
# Judge status: Wrong Answer
import math
numX = int(input())

result = -1

if numX <= 2:
  result = 2
elif numX % 2 == 0:
  numX += 1
  while True:
    upper = math.ceil(math.sqrt(numX))
    isPrime = True
    for i in range(3, upper, 2):
      if numX % i == 0:
        isPrime = False
        break
    if isPrime == True:
      result = numX
      break
    numX += 2
      
print(numX)
# Judge status: Accepted
n=int(input())
s=list(map(int,input().split()))
count=0


for i in range(0,len(s)):
    index_1=i+1
    if(int(s[i])%2 != 0):
        if(int((index_1))% 2 != 0 ):
            count+=1
        else:
            count+=0
    else:
        count+=0

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

B = [1]
for i in range(n):
    B.append((B[i]-A[i])*2)

C = [A[n]]

for s in B:
    if s <= 0:
        print(-1)
        exit()


for i in range(n):
    C.append(C[i]+A[n-1-i])
C = C[::-1]

num = 0
frag = 0
for i in range(n):
    if B[i] >= C[i]:
        frag = 1
    if frag == 0:
        num += B[i]
    else:
        num += C[i]
num += C[n]
print(num)
# Judge status: Wrong Answer
x, y = map(int, input().split())
cnt = 1
while x < y:
    x *= 2
    cnt += 1
print(cnt-1)
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
 
ans = []
for i in range(50):
    if N%2==1:
        ans.append('1')
        if i%2==0:
            N -= 1
        else:
            N += 1
    else:
        ans.append('0')
    N //= 2
    if N==0:
        break
print(''.join(ans[::-1]))
# Judge status: Accepted
W, H, N = map(int, input().split())
X = [0, W]
Y = [0, H]
for _ in range(N):
  x, y, a = map(int, input().split())
  if a == 1 and X[0] < x:
    X[0] = x
  elif a == 2 and X[1] > x:
    X[1] = x
  elif a == 3 and Y[0] < y:
    Y[0] = y
  elif a == 4 and Y[1] > y:
    Y[1] = y

h = Y[1] - Y[0]
w = X[1] - X[0]
print(0 if h < 0 or w < 0 else h * w)
# Judge status: Accepted
n = int(input())
l = list(map(int, input().split()))
l.sort()

same = False
for i in range(0, n-1):
    if l[i] == l[i+1]:
        same = True
        break

print('NO' if same else 'YES')
# Judge status: Accepted
n = list(map(int, reversed(list(input()))))

a = 0
b = 9999
for x in n:
  temp_a = min(a + x, b + x)
  b = min(a + 10 - x + 1, b + 10 - x - 1)
  a = temp_a

print(min(a, b))
# Judge status: Accepted
import numpy

l=int(input())

v=l/3

print(v*v*v)
# Judge status: Wrong Answer
import sys
sa=input()
sb=input()
sc=input()
ss={'a':sa,'b':sb,'c':sc}
t='a'
while True:
  if len(ss[t])==0:
    print(t.upper())
    sys.exit()
  else:
    t=ss[t][0]
    if len(ss[t])==1:
      ss[t]=''
    else:
      ss[t]=ss[t][1:]
# Judge status: Wrong Answer
k = int(input())
answer = -1
cou = 7
for i in range(k):
	if cou%k == 0:
		answer = cou
	else:
		cou*10 + 7
print(answer)
# Judge status: Wrong Answer
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
S = readline().decode().rstrip()
Q = int(readline())
cnt = 0
start = ''
end = ''
for i in range(Q):
    A = list(map(str,readline().decode().split()))
    if A[0] == '1':
        cnt +=1
    else:
        if (cnt + int(A[1])) % 2:
            end += A[2]
        else:
            start += A[2]
ans = start + S + end
if cnt % 2:
    print(ans)
else:
    print(ans[::-1])
# Judge status: Accepted
import sys

n, *aaa = map(int, sys.stdin.buffer.read().split())
ans = 0
for i, a in enumerate(aaa, start=1):
    if i % 2 == 1 and a % 2 == 1:
        ans += 1
print(ans)
# Judge status: Accepted
D,N = map(int,input().split())
print(N*100**D if N<100 else 101*100**D)
# Judge status: Wrong Answer
def resolve():
    n=int(input())
    ans=0

    for i in range(n):
        if i%3!=0 and i%5!=0:
            ans+=i
    print(ans)
if __name__ == "__main__":
    resolve()
# Judge status: Accepted
n, a, b = map(int, input().split())
s = input()
overseas = 0
student = 0
for i in range(n):
    if s[i] == "a":
        if a + b > student:
            print("Yes")
            student += 1
        else:
            print("No")
    if s[i] == "b":
        if a + b > student and overseas < b:
            print("Yes")
            overseas += 1
            student += 1
        else:
            print("No")
    if s[i] == "c":
        print("No")
# Judge status: Accepted
a=int(input())
b=[input() for i in range(a)]
def func(b):
    return len(set(b))
print(func(b))
# Judge status: Accepted
L,R,d = map(int,input().split())
count = 0
for i in range(L,R+1):
    if i % d == 0:
        count += 1
print(count)
# Judge status: Accepted
import collections

S = input()

C = collections.Counter(S)

for _ in 'abc':
    if _ not in C:
        C[_] = 0

M, m = max(C.values()), min(C.values())

print('YES' if M-m < 2 else 'NO')
# Judge status: Accepted

n,k = map(int,input().split())
a = list(map(int,input().split()))


s = []
ord = [-1] * (n+1)

v = 1
c = 1
l = 0
while ord[v] == -1:
    ord[v] = len(s)
    s.append(v)
    v = a[v-1]
c = len(s) - ord[v]
l = ord[v]

if l > k:
    print(s[k])
else:
    k -= l
    k %= c
    print(s[l+k])
# Judge status: Accepted
from fractions import gcd
#from math import gcd
 
def lcm(m, n): return m * n // gcd(m, n)
 
n = int(input())
a = list(map(int, input().split()))
 
MOD = 10 ** 9 + 7
 
mulab = 1
for i in range(n):
    mulab = lcm(mulab, a[i])
 
mulab %= MOD
ans = 0
for i in range(n):
    #フェルマーの小定理
    ans = ans + mulab * pow(a[i], MOD-2, MOD)
    ans %= MOD
 
print(ans)
# Judge status: Wrong Answer
N, A, B = map(int, input().split())
S = input()
domestic = 0
abroad = 0
for i in range(N):
    if S[i] == 'a':
        if domestic+abroad < A+B:
            print('Yes')
            domestic += 1
        else:
            print('No')
    elif S[i] == 'b':
        if domestic+abroad < A+B and abroad <= B:
            print('Yes')
            abroad += 1
        else:
            print('No')
    else:
        print('No')
# Judge status: Wrong Answer
N = int(input())
a = list(map(int,input().split()))
total = 1
k = 10**18
for i in range(len(a)):
	if a[i] == 0:
		total = 0
		break
	total *= a[i]
	if total > k:
		total =-1
		break    
print(total)
# Judge status: Accepted
x,a,b = map(int,input().split())
if abs(x-a)>abs(x-b):
    print("B")
else:
    print("A")
# Judge status: Wrong Answer
import sys

n, *d = map(int, sys.stdin.read().split())

def main():
    d.sort()
    h = n // 2
    l = d[h-1]; r = d[h]
    return r - (l + 1) - 1

if __name__ == '__main__':
    ans = main()
    print(ans)
# Judge status: Accepted
X ,Y = map(int ,input().split())

if X*2 <= Y <= X*4 and Y % 2 == 0:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
n, l = map(int, input().split())

strList = []
for _ in range(0, n):
    strList.append(input())

strList.sort()

ans = ""
for i in range(0, n):
    ans += strList[i]

print(ans)
# Judge status: Wrong Answer
n,m=map(int,input().split())
if n==m:
    temp=1
    for i in range(1,n+1):
      temp=(temp*i)%(10**9+7)
    print((2*((temp*temp)%(10**9+7)))%(10**9+7))
elif abs(n-m)==1:
    temp1=1
    temp2=1
    for i in range(1,n+1):
        temp1=(temp1*(i%(10**9+7)))%(10**9+7)
    for j in range(1,n+1):
        temp2=(temp2*(j%(10**9+7)))%(10**9+7)
    print(temp1+temp2)
else:
    print(0)
# Judge status: Accepted

from sys import exit
import math
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

a = ii()
print(a+a**2+a**3)
# Judge status: Wrong Answer
t = int(input())
b=0
c=0
count = 0
while b < t:
    b += 1
    while c < b:
        c += 1
        d = b/(10**len(str(b)))
        h = c % 10
        e = c/(10**len(str(c)))
        g = b % 10
        if d == h and e == g:
            count += 1

print(count)
# Judge status: Accepted
#Coins
A=int(input())
B=int(input())
C=int(input())
X=int(input())

i=0
#j=0 ここに入れるとだめ
ans=0
while i <=A:
    X_aftera=X-500*i
    if X_aftera<0:
        break
    j=0
    while j<=B:
        X_afterb=X_aftera-100*j
        if X_afterb<0:
            break
        if X_afterb//50<=C:
            ans +=1
        j+=1
    i+=1
print(ans)
# Judge status: Accepted
n=int(input())
list=[list(map(int,input().split())) for _ in range(n)]
list1=sorted(list, key=lambda x:x[1])
t=0
for i in range(n):
  t+=list1[i][0]
  if not t<=list1[i][1]:
    print("No")
    break
else:
  print("Yes")
# Judge status: Wrong Answer
n, h = list(map(int, input().split()))

wield = 0
bs = []

for i in range(n):
    a, b = list(map(int, input().split()))

    if a > wield:
        wield = a

    bs.append(b)

throw = 0
throwCnt = 0

for i in range(n):
    if bs[i] > wield:
        throw += bs[i]
        throwCnt += 1

print(max((h-throw+wield-1)//wield + throwCnt, 1))
# Judge status: Accepted
N,M=[int(i) for i in input().split()]
print("Yes") if N==M else print("No")
# Judge status: Wrong Answer
N = int(input())
ABCDE = []
for i in range(5):
  ABCDE.append(int(input()))

start_time = 0
arrived_time = N//ABCDE[0] + 1
for i in range(4):
  if ABCDE[i] <= ABCDE[i+1]:
    arrived_time += 1
  else:
    num_left = N - (N//ABCDE[i]) * ABCDE[i+1]
    arrived_time += num_left//ABCDE[i+1]+1

print(arrived_time)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
B = [A[i]-i-1 for i in range(N)]

B.sort()
b = B[N//2]
print(sum([abs(A[i]-i-b-1) for i in range(N)]))
# Judge status: Wrong Answer
a = list(map(int, input().split()))
k = int(input())
count = 0

while a[1] <= a[0]:
    a[1] = a[1]*2
    count += 1
while a[2] <= a[1]:
    a[2] = a[2]*2
    count += 1

if count > k:
    print('no')
else:
    print('yes')
# Judge status: Accepted
N,Y= map(int,input().split())

for a in range(N+1):
  for b in range(N-a+1):
    c = N-a-b
    if (10000*a+5000*b+1000*c ==Y):
      print('{} {} {}'.format(a,b,c))
      exit()
print('-1 -1 -1')
# Judge status: Accepted
n=int(input())
l=[int(input()) for i in range(n)]

lis=[i for i in l if i%10!=0]

sum_l=sum(l)

if sum_l%10!=0:
  print(sum_l)
else:
  if len(lis)==0:
    print(0)
  else:
    print(sum_l-min(lis))
# Judge status: Wrong Answer
n=int(input())
a_list=list(map(int,input().split()))
b_list=[]
for i in range(n-1):
  d=a_list[i]-a_list[i+1]
  if(d>=0):
    b_list.append(d)
    a_list[i+1]+=d
    
ans=sum(b_list)
print(b_list)
print(ans)
# Judge status: Wrong Answer
n=int(input())
d={}
for i in range(n):
  A=int(input())
  if A not in d:
    d[A]=1
  elif d[A]==1:
    d[A]==0
  else:
    d[A]=1
print(sum(d.values()))
# Judge status: Accepted
X = list(map(int,input().split()))
X.sort()
print('YES' if X==[5,5,7] else 'NO')
# Judge status: Accepted
s = input()
num = []
for i in range(len(s)-2):
    x = int(s[i:i+3])
    n = abs(753 - x)
    num.append(n)
print(min(num))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
A.sort()
while len(A)>=2: 
    X = (A[0]+A[1])/2
    A.pop(0)
    A.pop(0)
    A.append(X)
    A.sort()
else:
    print(A[0])
# Judge status: Wrong Answer
N = str(input())
if N in ['7']:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
s = input()
d = {}
for i in range(4):
    if s[i] in d:
        d[s[i]] += 1
    else:
        d[s[i]] = 1
if d[s[0]] == d[s[1]] == d[s[2]] == d[s[3]] == 2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n=int(input())
if n%2==0:
    print(-1)
else:
    c=1
    k=7
    while 1:
        if k%n==0:
            break
        if c>n:
            c=-1
            break
        k=(k%n)*10+7
        c+=1
        #print(k)
    print(c)
# Judge status: Wrong Answer
H1, M1, H2, M2, K = map(int,input().split())

if H1 == 0:
    H1 = 24
if H2 == 0:
    H2 = 24

if H2 <= H1:
    print(0)


time2m = H2 * 60 + M2
time1m = H1 * 60 + M1

study_time = time2m - K - time1m

if study_time <= 0:
    print(0)
else:
    print(study_time)
# Judge status: Wrong Answer
n=int(input())
x=[int(input()) for i in range(5)]

bottle_neck=10**15+10
bottle_neck_index=0

for i in range(5):
    if bottle_neck>x[i]:
        bottle_neck_index=i
        bottle_neck=x[i]

if n<=bottle_neck:
    ans=0
else:
    ans=n//bottle_neck
ans=ans+5
print(ans)
# Judge status: Accepted
n,yen=map(int,input().split())
yen//=1000
for x in range(n+1):
  for y in range(n-x+1):
    z=n-x-y
    cur_yen=x*10+y*5+z*1
    if cur_yen == yen:
      print(x,y,z)
      exit()
print(-1,-1,-1)
# Judge status: Accepted
H = int(input())
W = int(input())
N = int(input())

if H < W:
  count = N // W
  rate = N / W
  if count < rate:
     count += 1
  print(count)
else:
  count = N // H
  rate = N / H
  if count < rate:
     count += 1
  print(count)
# Judge status: Wrong Answer
a,b = input().strip().split()
a,b = [int(a), float(b)]
c = a*b;
d = int(c)
print(d)
# Judge status: Accepted
D,T,S = map(int,input().split())
if S*T >= D:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
N = int(input())
c = input()
print(min(c.count("W"), c.count("R"), c[:c.count("W")].count("W")))
# Judge status: Accepted
lst = sorted(list(map(int, input().split())), reverse=True)
k = int(input())
print(lst[0] * (2 ** k) + sum(lst[1:]))
# Judge status: Wrong Answer
# 4桁の数字で3つ以上連続するか判定

N = input()

if N[0] == N[1] and (N[0] == N[2] and N[0] == N[3]):
    print("Yes")
elif N[0] == N[1] and (N[0] == N[2] or N[0] == N[3]):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
x, y = list(map(int, input().split()))

if x == 0:
    print(abs(y))
elif y == 0:
    print(abs(x))
else:
    dif = abs(abs(x)-abs(y))

    if (x > 0 and y > 0) or (x < 0 and y < 0):
        if x < y:
            print(dif)
        else:
            print(dif + 2)
    else:
        print(dif + 1)
# Judge status: Wrong Answer
import sys

A, B, C = map(int, input().split())

count = 0
while True:
    a = B//2 + C//2
    b = C//2 + A//2
    c = A//2 + B//2
    count += 1
    if (A == B and B == C) or (A % 4 == 0 and B % 4 == 0 and C % 4 == 0):
        print('-1')
        sys.exit()
    if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
        break
    A = a
    B = b
    C = c

print(count)
# Judge status: Accepted
import numpy as np

s = np.array(list(map(int, input())))

a01 = np.tile([0,1], len(s)//2)
a10 = np.tile([1,0], len(s)//2)

if len(s)%2 != 0:
    a01 = np.append(a01, 0)
    a10 = np.append(a10, 1)

ans01 = np.abs(s -a01)
ans10 = np.abs(s -a10)

if sum(ans01) >= sum(ans10):
    print(sum(ans10))
else:
    print(sum(ans01))
# Judge status: Wrong Answer
import math

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

X = A / 0.08
Y = B / 0.1

if X > Y:
    Z = X * 0.2

    if Y + Z == X:
        print(X)
    else:
        print(-1)
else: 
    Z = Y * 0.2
    
    if X + Z == Y:
        print(Y)
    else:
        print(-1)
# Judge status: Wrong Answer
s=input()
print("A" + s[0] + "C")
# Judge status: Wrong Answer
import math
n, m = map(int, input().split())

N = math.factorial(n)
M = math.factorial(m)
INF = 10**9 + 7

if abs(n-m) == 1:
    print(N*M%INF)
else:
    print(2*N*M%INF)
# Judge status: Accepted
a,b,k=map(int,input().split())
for i in range(k):
    if a+i<=b:
        print(a+i)
for j in range(k,0,-1):
    if b-j>=a+k-1:
        print(b-j+1)
# Judge status: Wrong Answer
N,R= map(int,input().split())
if N > 9:
    print(R)
else:
    print(R-100*(10-N))
# Judge status: Wrong Answer
N=int(input())
S=input()
print(S[N:]+S[:N])
# Judge status: Accepted
a,b=sorted(map(int,input().split()))

# 最大公約数
def gcd(a, b):
  if b==0:
     return a
  else:
     r = a%b
     return gcd(b,r)

print(int(a*b/gcd(a,b)))
# Judge status: Wrong Answer
c,t=open(0)
a=[0]
for i in t:a+=a[-1]+1-2*(i=='D'),
print(max(a))
# Judge status: Wrong Answer
n = int(input())
s = input()
v = [0] * n
for c in range(ord('a'), ord('z') + 1):
  p = -1
  for i in range(n):
    if s[i] == c:
      if p >= 0:
        v[i] -= 1
        v[p] += 1
      p = i
ans = 0
vsum = 0
for i in v:
  vsum += i
  ans = max(ans, vsum)
print(ans)
# Judge status: Wrong Answer
def solution():
  N = int(input())
  xy = [map(int, input().split()) for _ in range(N)]
  x, y = [list(i) for i in zip(*xy)]

  cnt = 0
  flg = 0
  for i in range(N):
    if x[i] == y[i]:
      if flg+1 == i:
        cnt += 1
        flg = i
      else:
        cnt = 0

  if cnt >= 3:
    return 'Yes'
  return 'No'

print (solution())
# Judge status: Accepted
k,s =map(int,input().split())
cnt=0
for x in range(0,k+1):
    for y in range(0,k+1):
        z=s-x-y
        if 0<=z<=k:
            cnt+=1

print(cnt)
# Judge status: Accepted
n = int(input())
w = list(map(int,input().split()))
s = 0
x = []

for i in range(n):
    s = abs(sum(w[:i])-sum(w[i:]))
    x.append(s)

print(min(x))
# Judge status: Accepted
# A - Colorful Subsequence
from collections import defaultdict as dd
n=int(input())
s=input()
mod=10**9+7
ans=1
c=dd(int)

for ss in s:
    c[ord(ss)-97]+=1

for i in range(26):
    ans*=c[i]+1
    ans%=mod

print((ans+mod-1)%mod)
# Judge status: Accepted
print(-(-sum(map(int,input().split()))//2))
# Judge status: Wrong Answer
n = int(input())
a = [int(_) for _ in input().split()]

ans = 1000000000
for i in range(-100, 100):
    val = 0
    for j in a:
        val += (i-j)**2
    ans = min(ans, val)
print(ans)
# Judge status: Accepted
def resolve():
    n = int(input())
    l = [list(map(int,input().split())) for i in range(2)]

    count = 0
    for i in range(n):
        tmp = 0
        c = -1
        for j in range(0, i+1):
            tmp += l[0][j]
            c += 1
        tmp += l[1][c]
        c += 1
        for k in range(c, n):
            tmp += l[1][k]
        count = max(tmp, count)

    print(count)


if __name__ == '__main__':
    resolve()
# Judge status: Accepted
a,b,c,d=map(int,input().split())
temp=[]
temp.append(a*c)
temp.append(a*d)
temp.append(b*c)
temp.append(b*d)
print(max(temp))
# Judge status: Wrong Answer
x = int(input("あめ")) 

def main(x):
    y = 0
    for i in range(x+1):
        y = y + i
    return y
    
print(main(x))
# Judge status: Wrong Answer
N = int(input())
L1 = 2
L2 = 1
L3 = 3
if N == 1:
    print(L1)
elif N == 2:
    print(L2)
else:
    for i in range(N-2):
        L1 = L3
        L3 += L2
        L2 = L1
    print(L3)
# Judge status: Accepted
n,k = map(int,input().split())
p = list(map(int,input().split()))

p_sort = sorted(p)

ans = 0
cnt = 0
for _ in p_sort:
    ans += _
    cnt += 1

    if cnt >= k:
        break

print(ans)
# Judge status: Wrong Answer
import datetime
s = input()
dt = datetime.datetime.strptime(s, '%Y/%m/%d')
if dt.year >= 2019 and dt.month >= 4 and 1 <= dt.day >= 30:
    print('Heisei')
else:
    print('TBD')
# Judge status: Wrong Answer
x=input()
print(int(360/int(x)))
# Judge status: Accepted
s=input()
d={'Sunny':'Cloudy','Cloudy':'Rainy','Rainy':'Sunny'}
print(d[s])
# Judge status: Accepted
a,b,k=map(int,input().split())

if a>=k:
    a-=k
elif a+b>=k:
    b-=k-a
    a=0
else:
    a=0
    b=0

print('{} {}'.format(a,b))
# Judge status: Wrong Answer
alp=list('qawsedrftgyhujikoplmnbvcxz')
alp.sort()
cnt=[]
for i in range(int(input())):
  tmp=[0 for _ in range(26)]
  for s in list(input()):
    tmp[alp.index(s)]+=1
  cnt.append(tmp)
m=57
ans=''
for i in range(26):
  for j in range(len(cnt)):
    m=min(m,cnt[j][i])
  ans+=alp[i]*m
print(ans)
# Judge status: Wrong Answer
n,m=map(int,input().split())
x=sorted(map(int,input().split()))
a=list()
for i in range(m-1):
    a.append(x[i+1]-x[i])
print(x[-1]-x[0]-sum(sorted(a)[-n+1:]))
# Judge status: Accepted
##B
S = str(input())
N = int(len(S))
##print(N)
S1 = S[0:(N-1)//2]
N1 = len(S1)
S2 = S[(N+3)//2-1:N]
N2 = len(S2)

if S1 == S2:
    if S1 == S1[::-1]:
        if S2 == S2[::-1]:
            print("Yes")
else:
    print("No")
# Judge status: Accepted
n, m = map(int, input().split())
ans = 0
if m - 2*n > 0:
    ans += n
    m -= 2*n
    ans += m//4
else:
    ans += m//2

print(ans)
# Judge status: Accepted
import sys
from functools import lru_cache
def input(): return sys.stdin.readline().rstrip()

@lru_cache(maxsize=None)
def gcd(m, n):
    if n == 0:
        return m
    else:
        return gcd(n, m % n)

def main():
    _ = int(input())
    A = tuple(map(int, input().split()))

    ans = A[0]
    for a in A[1:]:
        ans = gcd(ans, a)
    print(ans)
    
if __name__ == '__main__':
    main()
# Judge status: Accepted
a = int(input())
b = int(input())
h = int(input())
v = ((a+b)*h)/2
print(int(v))
# Judge status: Accepted
x = int(input())
i = 1
while True:
    if (i+1)*i//2 >= x:
        print(i)
        break
    i += 1
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
ans=0
tree=1
node=sum(A)
flag=0
for i in A:
    ans+=i
    node-=i
    if i>tree:
        ans=-1
        break
    tree-=i
    if tree<node:
        ans+=tree
    else:
        ans+=node
    tree=2*tree
print(ans)
# Judge status: Accepted
s=input()
ans=len(s)

while True:
    ans-=2
    s=s[:ans]
    if s[:ans//2]==s[ans//2:]:
        print(ans)
        break
# Judge status: Wrong Answer
cmin = lambda a,b : a if a<b else b
cmax = lambda a,b : a if a>b else b
iin = lambda : int(input())
lin = lambda : list(map(int,input().split()))
rin = lambda n : [int(input()) for _ in range(n)]

n,a,b = map(int,input().split())

d,m = divmod(n,a+b)

print(d*a+m if m<a else d*a+m-b)