peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n, a, b = map(int,input().split())
s = input()
a_pass = 0
b_pass = 0

for i in s:
    if i == 'a' and a_pass + b_pass < a + b:
        print('Yes')
        a_pass += 1
    elif i == 'b' and a_pass + b_pass < a + b and b_pass < b:
        print('Yes')
        b_pass += 1
    else:
        print('No')
# Judge status: Wrong Answer
N,M = map(int,input().split())

def solve(N,M):
  # 今あるもの
  if M < N * 2:
    return N
  
  M -= N * 2
  
  ans = N + M // 4
  return ans

print(solve(N,M))
# Judge status: Accepted
[N,K,S] = list(map(int,input().split()))
cnt = 0
output = []
if S != 10**9:
    for i in range(K):
        output.append(S)
    for i in range(N-K):
        output.append(S+1)
else:
    for i in range(K):
        output.append(S)
    for i in range(N-K):
        output.append(1)

print(*output)
# Judge status: Accepted
D = int(input())
for _ in range(D):
    print(1)
# Judge status: Wrong Answer
d,n = map(int,input().split())
print((100)**d*n)
# Judge status: Wrong Answer
S=input()
from collections import Counter
A=Counter(S)

if min(A.values())>=2:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
N = int(input())
results = []
for i in range(1, N):
    results.append(sum(map(int, str(i))) + sum(map(int, str(N-i))))
print(min(results))
# Judge status: Wrong Answer

N = int(input())
X = list(map(int, input().split()))

y = [abs(v) for v in X]
if N % 2 == 0:
    print(sum(y))
else:
    print(sum(y) - 2 * min(y))
# Judge status: Accepted
n = int(input())
l = list(map(int,input().split()))
ans = 0
for i in range(n):
    for j in range(i, n):
        if l[i] != l[j]:
            for k in range(j, n):
                if l[i] != l[k]:
                    if l[j] != l[k]:
                        if max(l[i], l[j], l[k]) < (l[i] + l[j] + l[k])/2:
                            ans += 1
print(ans)
# Judge status: Accepted
s = input()
a = [int(c) for c in s]
if a[0]==a[1] and a[1]==a[2]:
	print('Yes')
elif a[1]==a[2] and a[2]==a[3]:
	print('Yes')
else:
	print('No')
# Judge status: Accepted
n = int(input())
b = list(map(int, input().split()))

a = [0]*(n)

for i in range(len(a)):
  if (i == 0):
    a[i] = b[i]
  elif i == len(a)-1:
    a[i] = b[i-1]
  else:
    a[i] = min(b[i-1], b[i])
    
print(sum(a))
# Judge status: Wrong Answer
input()
flag = True
counter = 0
a = list(map(int, input().split()))
while(flag):
  for i in range(len(a)):
    if a[i] % 2 == 0:
      a[i] = a[i] // 2
    else:
      flag = False
      break
  counter += 1
print(counter)
# Judge status: Wrong Answer
import heapq

N,M=input().split()
N,M=int(N),int(M)
A=input().split()
A=[-int(n) for n in A]

heapq.heapify(A)

for i in range(M):
    a=heapq.heappop(A)//2
    heapq.heappush(A,a)
sum=0
for i in range(N):
    sum+=A[i]
print(-sum)
# Judge status: Wrong Answer
H, N = map(int, input().split())
A = list(map(int, input().split()))

if H <= sum(A):
    print ('Yse')
else:
    print ('No')
# Judge status: Accepted
A, B, C = map(int, input().split())
K = int(input())
counter = 0
while A >= B:
    B *= 2
    counter += 1
while B >= C:
    C *= 2
    counter += 1
print('Yes' if counter <= K else 'No')
# Judge status: Accepted
alpha = input()

if alpha.isupper():
  print("A")
else:
  print("a")
# Judge status: Wrong Answer
x = int(input())
cnt = 0
for a in range(1, x+1):
    for b in range(1, x+1):
        for c in range(1, x+1):
            kai = (a * b) + c
            if kai == x:
                print(a,b,c)
                cnt += 1
print(cnt)
# Judge status: Wrong Answer
x = int(input())

result = 0
for i in range(2,x+1):
  beki = 2
  while (i**beki) <= x:
    result = i**beki 
    beki+=1

if result == 0:
  print(1)
else:
  print(result)
# Judge status: Accepted
n,k=map(int,input().split())
k-=1
a=list(map(int, input().split()))
for i in range(n):
    if a[i]==1:
        index=i
print(-(-i//k)-(-(n-i-1)//k))
# Judge status: Accepted
n,x,y=map(int,input().split())

#最短距離が１の時２の時、、、という風に実験しても途方に暮れるだけだった
#i,j固定して最短距離がどう表せるかを考える
def min_route_count(i,j):
  return min(abs(j-i),abs(j-y)+1+abs(x-i))

ans_list=[0]*(n-1)
for i in range(1,n):
  for j in range(i+1,n+1):
    ans_list[min_route_count(i,j)-1]+=1
    
for t in range(n-1):
  print(ans_list[t])
# Judge status: Accepted
s = input()
k = 0
for i in range(len(s) // 2):
  if s[i] == s[len(s) - i -1]:
    next
  else:
    k += 1
print(k)
# Judge status: Accepted
from itertools import permutations
n = int(input())
a = list(permutations(range(1,n+1),n))
print(abs(a.index(tuple(map(int,input().split())))-a.index(tuple(map(int,input().split())))))
# Judge status: Wrong Answer
a,b,c,d = map(int, input().split())
i = 1
while a >= 0 & c >= 0:
    a = a
    c = c - i*b

    a = a-i*d
    c = c

    i += 1
if a <= 0:
    print('No')
else :
    print('Yes')
# Judge status: Accepted
from collections import deque

X = input()

ret = deque([X[0]])
for i in range(1, len(X)):
    x = X[i]
    if x == 'S':
        ret.append(x)
    else:
        if len(ret) > 0 and ret[-1] == 'S':
            ret.pop()
        else:
            ret.append(x)
print(len(ret))
# Judge status: Accepted
n=int(input())
ans=0
for i in range(1,50000+1):
    z=i*1.08
    if n<=z<(n+1):
        ans=i
        break
if ans==0:
    print(":(")
else:
    print(ans)
# Judge status: Wrong Answer
S = input()
T = input()

ns = len(S)
nt = len(T)
idx = None

for i in range(ns - nt + 1):
    for j in range(nt):
        if S[i+j] != T[j] and S[i+j] != '?':
            break
    else:
        idx = i
        break

if idx:
    ans = S[:idx] + T + S[idx+nt:]
    print(ans.replace('?', 'a'))
else:
    print('UNRESTORABLE')
# Judge status: Wrong Answer
import sys

N = int(input())
D = sorted(list(map(int,input().split())))

if N % 2 != 0:
    print(0)
    sys.exit()

low  = D[0:N//2]
high = D[N//2::]

cnt = 0
flg = True
for i in range(low[-1], max(D)):
    flg = True
    for L in low:
        if i <= L:
            flg = False
    for L in high:
        if i > L:
            flg = False

    if flg == True:
        cnt = cnt + 1
print(cnt)
# Judge status: Wrong Answer
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    A, B = map(int, input().split())
    result = 0
    for i in range(A, B + 1):
        i = str(i)
        mid = len(i) // 2
        if i[:mid] == i[mid + 1:]:
            result += 1
    print(result)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
n = int(input())
s = list(map(int, input().split()))
t = []
cnt = 2
for a in s:
  try:
    t[a-1].append(cnt)
  except IndexError:
    for _ in range(a-len(t)):
      t.append([])
      t[-1].append(cnt)
for i in range(len(t)):
  print(len(t[i]))
for _ in range(n-len(t)):
  print(0)
# Judge status: Wrong Answer
from collections import Counter
S = input()
work = list(Counter(S).values())
a = work[0]
b = work[1] if len(work)>1 else 0
c = work[2] if len(work)>2 else 0
result = "YES"
if ((a > b + 1 or a > c + 1) or c == 0) and not len(S)==1 and not (len(S) == len(work) == 2):
    result = "NO"
print(result)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
edge=[0]*(n+1)
ans=0
edge[0]=1
for i in range(1,n):
    edge[i]=edge[i-1]*2-a[i]
for i in range(n-1,-1,-1):
    bcnt=edge[i+1]+a[i+1]
    if bcnt//2+bcnt%2>edge[i]:
        ans=-1
        break
    if bcnt<edge[i]:
        edge[i]=bcnt
if a[0]>0:
    ans=-1
if ans!=-1:
    ans=sum(edge)+sum(a)
print(ans)
# Judge status: Wrong Answer
a,b = input().split()
a = int(a)
b =int(b)
print (int((a+b) / 2))
# Judge status: Accepted
n,k = map(int,input().split())
x = list(map(int,input().split()))
ans = 10**18
for i in range(n-k+1):
    l = x[i]
    r = x[i+k-1]
    if r<=0:
        ans = min(ans,abs(l))
    if l*r<0:
        ans = min(ans,min(abs(l),abs(r))+r-l)
    if l>=0:
        ans = min(ans,r)
print(ans)
# Judge status: Accepted
a = int(input())
if a<=6:
    print("1")
    exit()
if a<=11:
    print("2")
    exit()
if a%11==0:
    print(int(a/11)*2)
    exit()
if a%11<=6:
    print(int(a/11)*2+1)
else:
    print(int(a / 11) * 2 + 2)
# Judge status: Accepted
s = input()
ans = []
for i in s:
  ans.append(i)
  
print(ans[0]+ans[1]+ans[2])
# Judge status: Wrong Answer
n=int(input())

num=n//1.08

if num*1.08==n:
  print(num)
else:
  print(":(")
# Judge status: Accepted
import numpy as np
(n,m,x)=map(int,input().split())

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

a=np.array(a)
result=np.array([[0]*(m+1)])
for i in range(n):
    l=list()
    for j in range(len(result)):
        l.append(a[i]+result[j])
        l.append(result[j])
    result=np.array(l)

c=list()
h=[x]*m
for line in result:
    if np.all(line[1:]>=h):
        c.append(line[0])
if len(c)==0:
    print(-1)
else:
    print(min(c))
# Judge status: Accepted
x=int(input())
ans=0
for i in range(1000000000):
  ans+=i
  if ans>=x:
    print(i)
    exit()
# Judge status: Accepted
n = int(input())
s = list(map(int,input().split()))
ans = 2020202020
a = 0
b = sum(s)
for i in range(n):
    a += s[i]
    b -= s[i]
    ans = min(ans,abs(a-b))
print(ans)
# Judge status: Wrong Answer
s = int(input())
lis = []

def func(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n+1
 
while func(s) !=4:
    print(func(s))
    s = func(s)
    lis.append(s)
    
print(len(lis)+5)
# Judge status: Accepted
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())

print(N * 800 - N // 15 * 200)
# Judge status: Accepted
num=int(input())
if num%9==0:
  result='Yes'
else:
  result='No'
  
print(result)
# Judge status: Wrong Answer
nums = input().split()
N = int(nums[0])
K = int(nums[1])
totalProb = 0

for i in range(N):
    x = i + 1
    tempProb = 1/N

    while x < K:
        tempProb = tempProb / 2
        x = x * 2
        print(tempProb)

    totalProb += tempProb

print(totalProb)
# Judge status: Accepted
n, m, k = map(int, input().split())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))

a = []
a.append(0)
for i in range(n):
    a.append(a[i]+a_list[i])
    
b = []
b.append(0)
for i in range(m):
    b.append(b[i]+b_list[i])
    

ans = 0
for i in range(n+1):
    if a[i]>k:
        break
    while a[i] + b[m] > k:
        m -= 1
    ans = max(ans, i+m)
    
print(ans)
# Judge status: Wrong Answer
N = int(input())
H = list(map(int, input().split()))

ans = 100000
cnt = 0

for i in range(N-2):
  for j in range(i, N-1):
    if H[j] >= H[j+1]:
      cnt += 1
    else:
      if ans > cnt:
        ans = cnt
      cnt = 0
print(ans)
# Judge status: Accepted
N=int(input())
D=list(map(int,input().split()))
mod=998244353
ans=1
count=[0 for i in range(0,N)]
for i in range(0,N):
    count[D[i]]+=1

able=True
if D[0]!=0 or count[0]!=1:
    able=False
for i in range(0,N-1):
    if count[i]==0 and count[i+1]!=0:
        able=False

if able:
    for i in range(0,N-1):
        ans=(ans*pow(count[i],count[i+1],mod))%mod
    print(ans)
else:
    print(0)
# Judge status: Accepted
from sys import stdin, stdout
import math
import bisect
import re

x = int(stdin.readline().strip())

for a in range(-500, 500):
    for b in range(-500, 500):
        if a ** 5 - b ** 5 == x:
            stdout.writelines(str(a) + ' ' + str(b) + '\n')
            exit(0)
# Judge status: Accepted
x=int(input())
c=x//11*2
m=x%11
if m==0:print(c)
elif m<=6:print(c+1)
else:print(c+2)
# Judge status: Accepted
s=input()
t = set(s)
if len(s) ==1:
    print("YES")
    exit(0)
elif len(s) == 2 and len(t) ==2:
    print("YES")
    exit(0)
if len(t) != 3:
    print("NO")
else:
    a = s.count("a")
    b = s.count("b")
    c = s.count("c")
    M = max(a,b,c)
    m = min(a,b,c)
    if M - m >1 :
        print("NO")
    else:
        print("YES")
# Judge status: Accepted
N = int(input())

dp = [[0]*3 for _ in range(N+1)]
for i in range(1, N+1):
  a, b, c = map(int, input().split())
  dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a
  dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b
  dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c
  
print(max(dp[N]))
# Judge status: Accepted
import sys
input = sys.stdin.readline

s = list(input())
n = len(s)-1

res = 0

d = dict()
mod = 2019
d[0] = 1

tmp = 0
for i in range(n-1,-1,-1):
    tmp = (tmp + int(s[i])*pow(10,n-1-i,mod))%mod
    if tmp in d:
        res += d[tmp]
        d[tmp] += 1
    else:
        d[tmp] = 1

print(res)
# Judge status: Accepted
import sys

N, K = map(int, sys.stdin.readline().split())
ans = 0
for i in range(1, N+1):
    if K <= i:
        ans += 1 / N
    else:
        count = 0
        while i < K:
            count += 1
            i *= 2
        ans += (1 / N) * 0.5 ** count

print(ans)
# Judge status: Wrong Answer
x = int(input())
power5 = [i ** 5 for i in range(100)]
for i in power5:
  for j in power5:
    if i - j == x:
      print(i, j)
      exit()
for i in power5:
  for j in power5:
    if i + j == x:
      print(i, -j)
      exit()
# Judge status: Accepted
def black_jack():
    # 入力
    A1, A2, A3 = map(int, input().split())
    # 初期処理
    sum = A1 + A2 + A3
    # 判別処理
    if sum >= 22:
        return 'bust'
    elif sum <= 21:
        return 'win'

result = black_jack()
print(result)
# Judge status: Accepted
N, M = list(map(int,input().split()))
base = N
if N%2==1:
  for i in range(1,M+1):
    print(i,base-i)
else:
  if N%4==0:
    candidate = []
    for i in range(1,N//4+1):
      candidate.append((i,N+1-i))
    for i in range(N//4+1,N//2):
      candidate.append((i,N-i))
  else:
    candidate = []
    for i in range(1,N//4+1):
      candidate.append((i,N+1-i))
    for i in range(N//4+1,N//2):
      candidate.append((i,N-i))
  for i in range(M):
    a,b = candidate[i]
    print(a,b)
# Judge status: Wrong Answer
n,a=open(0);*a,=map(int,a.split());m=max(a);print(m,min(a,key=lambda x:abs(m-x*2)))
# Judge status: Accepted
X, N = map(int, input().split())
P = sorted(list(map(int, input().split())))

res, diff = 0, float("inf")
for i in range(0, 110):
    if i in P:
        continue
    if diff > abs(X - i):
        res = i
        diff = abs(X - i)

print(res)
# Judge status: Accepted
S = input()
if S.find("RRR") == 0 :
    print(3)
elif S.find("RR") >= 0 :
    print(2)
elif S.find("R") >= 0 :
    print(1)
else:
    print(0)
# Judge status: Accepted
k,x=[int(x) for x in input().split()]
l=list(range(x-k+1,x+k))
L=map(str,l)
print(" ".join(L))
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
for i in range(n):
    z=0
    for j in range(i+1):
        z+=a[j]
    for j in range(i,n):
        z+=b[j]
    ans=max(ans,z)
print(ans)
# Judge status: Accepted
import math

NUM = input().split()

A = float(NUM[0])
B = float(NUM[1])
H = float(NUM[2])
M = float(NUM[3])

rad_A = H * 2*math.pi / 12. + M * 2*math.pi / 12. / 60.
rad_B = M * 2*math.pi / 60.

X_A = A * math.cos(rad_A)
Y_A = A * math.sin(rad_A)
X_B = B * math.cos(rad_B)
Y_B = B * math.sin(rad_B)

D = math.sqrt((X_A - X_B)**2. + (Y_A - Y_B)**2.)

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

result = 0
for i in range(a,b+1):
  tar = str(i)
  if tar[0] == tar[4] and tar[1] == tar[3]:
    result += 1
print(result)
# Judge status: Accepted
N , K , Q = list(map(int, input().split()))

a = [0] * Q
p = [K] * N

# 行数の入力
for i in range(Q):
    a[i] = int(input())
    p[a[i]-1] = p[a[i]-1] + 1

for j in range(N):
    if p[j] - Q > 0:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
n=int(input())
s=input()
ans=0
for i in range(n):
    tmp = len(set(s[:i])&set(s[i:]))
    ans = max(ans,tmp)
print(ans)
# Judge status: Wrong Answer
N=int(input())
s=[i for i in input()]
L=R=True
ss=s[:]
for i in range(N):
    if L or R:
        if L and s[i]==".":
            ss.pop(0)
        else:
            L=False
        if R and s[-1-i]=="#":
            ss.pop(-1)
        else:
            R=False
    else:
        break
print(min(ss.count("."),ss.count("#")))
# Judge status: Accepted
N=int(input())
s=0
for A in range(1,1+N):
  s+=N//A
  if N%A==0:
    s-=1
print(s)
# Judge status: Accepted
import sys
input = sys.stdin.readline
def main():
    N = int( input())
    X = []
    for _ in range(N):
        x, l = map( int, input().split())
        X.append((x+l-1, x-l+1))
    X.sort()
    ans = 1
    now = X[0][0]
    for i in range(1,N):
        b, a = X[i]
        if now +1< a:
            now = b
            ans += 1
    print(ans)
    
if __name__ == '__main__':
    main()
# Judge status: Accepted
s=int(input())
a=[]
a.append(s)
i=1
# print(len(a),s,a[0])
while(True):
    if(a[i-1]%2==0):
        x=a[i-1]//2
        if(x in a):
            print(i+1)
            exit()
        a.append(x)
    else:
        x=(a[i-1]*3)+1
        if(x in a):
            print(i+1)
            exit()
        a.append(x)
    i+=1
# Judge status: Wrong Answer
n, a, b, c, d = map(int, input().split())
s = input()
if s[min(a, b): max(c, d)].count("##") or (d < c and s[b-1: d].count("...") == 0):
    print("No")
else:
    print("Yes")
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
ans=[0]*3
for i in a:
  if i%4==0:
    ans[2]+=1
  elif i%2==0:
    ans[1]+=1
  else:ans[0]+=1
if ans[0]<=ans[2] or (ans[0]<=ans[2]+1 and ans[1]==0):print('Yes')
else:print('No')
# Judge status: Accepted
c = [list(map(int,input().split())) for _ in range(3)]
a1 = 0
b1 = c[0][0] - a1
b2 = c[0][1] - a1
b3 = c[0][2] - a1
a2 = c[1][0] - b1
a3 = c[2][0] - b1
flag = c[1][1] == a2 + b2 and c[1][2] == a2 + b3 and c[2][1] == a3 + b2 and c[2][2] == a3 + b3

print('Yes' if flag else 'No')
# Judge status: Wrong Answer
N = bool(input())
print(int(not N))
# Judge status: Accepted
S = input().strip()
T = input().strip()
N = len(S)
K = len(T)
A = list(S)
for i in range(N-K,-1,-1):
    a = S[i:i+K]
    flag = 0
    for j in range(K):
        if a[j]!="?" and a[j]!=T[j]:
            flag = 1
            break
    if flag==1:continue
    A[i:i+K] = T[:]
    for j in range(N):
        if A[j]=="?":
            A[j]="a"
    break
if "?" in A:
    print("UNRESTORABLE")
else:
    print("".join(A))
# Judge status: Accepted
a = input()
if a.isupper():
  print('A')
else:
  print('a')
# Judge status: Accepted
# -*- coding: utf-8 -*-

N = int(input().strip())
a_list = [int(i) for i in input().rstrip().split()]
#-----

def gcd(a,b):
    if b == 0: 
        return a
    return gcd(b, a % b)

ans = a_list[0]
for i in a_list[1:]:
    ans = gcd(ans, i)

print(ans)
# Judge status: Wrong Answer
h, w = map(int, input().split())
print(round(h*w))
# Judge status: Accepted
x = int(input())

count = 1
a = 100
while True:
  a *= 1.01
  a = int(a)
  if int(a) >= x:
    break
  else:
    count += 1
print(count)
# Judge status: Accepted
import heapq
def main():
    n, m = list(map(int, input().split()))
    t = list(map(int, input().split()))
    t = list(map(lambda x: x*(-1), t))
    heapq.heapify(t)
    while m > 0:
        v = heapq.heappop(t) * -1
        heapq.heappush(t, (v // 2)* -1)
        m -= 1

    print(sum(t)*-1)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 23 16:58:10 2020

@author: liang
"""

N = int(input())
A = [int(input()) for _ in range(N)]+[-1]
A.sort()
ans = 0
count = 1
for i in range(N):
    if A[i] == A[i+1]:
        count += 1
    else:
        if count%2 == 1:
            ans += 1
        count = 1
print(ans)
# Judge status: Wrong Answer
n = int(input())
d = []

for _ in range(n):
  d.append(list(map(int, input().split())))
  
dp = [0] * (n+1)
dps = [5] * (n+1)

for i in range(n):  
  tdp = 0
  tdps = 5
  for j in range(3):
    if tdp < d[i][j]:
      if i == 0 or j != dps[i-1]:
        tdp = d[i][j]
        tdps = j
  dp[i] = tdp
  dps[i] = tdps
  
print(sum(dp))
# Judge status: Accepted
n = int(input())
ans = 8
for i in range(600,2001,200):
	if n < i:
		print(ans)
		break
	ans -= 1
# Judge status: Accepted
A,B,C = map(int,input().split())

maxL = max(A,B,C)
minL = min(A,B,C)
midium = A+B+C - maxL - minL

print(int(minL*midium/2))
# Judge status: Wrong Answer
from math import *
x = int(input())
m = 11
ans = ceil(x*2/m)
print(ans)
# Judge status: Accepted
from fractions import gcd
def list_gcd(list):
    c=list[0]
    for i in list:
        c=gcd(c,i)
    return c
n=int(input())
print(list_gcd(list(map(int,input().split()))))
# Judge status: Wrong Answer
def main():
    line = input()
    n, T = [int(x) for x in line.split()]
    lista_tempos = []
    lista_custos = []
    for i in range(n):
        line = input()
        c, t = [int(x) for x in line.split()]
        if t <= T:
            lista_tempos.append(t)
            lista_custos.append(c)
    if lista_tempos:
        print(min(lista_custos))
    else:
        print('TLE')
# Judge status: Wrong Answer
N,A,B=map(int,input().split())
t=N//(A+B)
if N%(A+B)==0:
  print(t*A)
else:
  print(t*A+N%(A+B))
# Judge status: Accepted
n=input()
if n[0]==n[1] and n[1]==n[2] or n[1]==n[2] and n[2]==n[3]:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
def candy():
    boxNum, x = [int(i) for i in input().split()]
    ain = input()
    alist = ain.split(' ')

    s = 0
    for i in range(0, boxNum-1):
        if int(alist[i+1]) + int(alist[i]) > x:
            s = s + (int(alist[i+1]) + int(alist[i]) - x)
            alist[i+1] = x - int(alist[i+1])
        
    print(s)
    
candy()
# Judge status: Accepted
import bisect
N, M = map(int, input().split())
A = [0]*M
for i in range(M):
  A[i] = int(input())

def index(a, x):
  i = bisect.bisect_left(a, x)
  if i != len(a) and a[i] == x:
    return i
  else:
    return -1

def dp(a,n):
  if n==N:
    return 1
  if n>N:
    return 0
  if index(a,n)!=-1:
    return 0
  else:
    return (DP[n+1]+DP[n+2])%(10**9+7)
    
DP=[0]*(N+3)

for i in range(N+2,-1,-1):
  DP[i]=dp(A,i)

ans=DP[0]
print(ans)
# Judge status: Wrong Answer
n, m = map(int, input().split())
h = list(map(int, input().split()))
bridge = []
connected = [0 for _ in range(n)]
good = [0 for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if h[a] < h[b]:
        good[b] += 1
    elif h[b] < h[a]:
        good[a] += 1
    connected[a] = 1
    connected[b] = 1

noc = connected.count(0)
gc = n - good.count(0)

print(noc + gc)
# Judge status: Accepted
n,m = map(int,input().split())

ansl = []

start = n // 2
end = n // 2 + 1
for i in range(m):
    if n % 2 == 0 and end - start + 2 * i >= n // 2:
        ansl.append((start - i-1, end + i))
    else:
        ansl.append((start-i, end+i))

for a,b in sorted(ansl):
    print(a,b)
# Judge status: Accepted
s = input()
print(len(s)-s[-1:0:-1].index('Z')-s.index('A'))
# Judge status: Accepted
import sys
input = sys.stdin.readline
import math
from functools import reduce


def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)


# 最小公倍数
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

# AでもBでも割り切れる数の最小値、それが最小公倍数だ
A, B = [int(x) for x in input().split()]

ans = lcm(A, B)
print(ans)
# Judge status: Accepted
s = int(input())
mod = 10**9 + 7
dp = [0]*(s + 1)
dp[0] = 1

for i in range(1, s+1):
    for j in range(0, (i-3)+1):
        dp[i] += dp[j]
        dp[i] %= mod

print(dp[s])
# Judge status: Accepted
N, M = map(int, input().split())
matches = []
i = 1
l = N // 2 - 1 if N % 2 == 0 else N // 2
while len(matches) < M:
    if l <= 0:
        i = N // 2 + 1 if N % 2 == 0 else N // 2 + 2
        l = N // 2 - 2 if N % 2 == 0 else N // 2 - 1
        continue
    matches.append((i, i+l))
    i += 1; l -= 2
for a, b in matches: print(a, b)
# Judge status: Wrong Answer

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

if a == b+c:
    print("YES")
elif b == a+c:
    print("YES")
elif c == a+b:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))
s=sum(l)
m=100000000
c=0
for i in range(n):
    c+=l[i]
    x=s-c
    d=abs(c-x)
    m=min(m,d)
print(m)
# Judge status: Accepted
n,m = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(m)]

box = [1]*(n+1)
red = [0]*(n+1)
red[1] = 1
for x,y in xy:
    box[x] -= 1
    box[y] += 1
    if red[x] == 1: red[y] = 1
    if box[x] == 0: red[x] = 0
print(red.count(1))