Problem:


Score : 200 points

Problem Statement

Takahashi has many red balls and blue balls. Now, he will place them in a row.

Initially, there is no ball placed.

Takahashi, who is very patient, will do the following operation 10^{100} times:

Place A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.

How many blue balls will be there among the first N balls in the row of balls made this way?

Constraints

1 \leq N \leq 10^{18}

A, B \geq 0

0 < A + B \leq 10^{18}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N A B

Output

Print the number of blue balls that will be there among the first N balls in the row of balls.

Sample Input 1

8 3 4

Sample Output 1

4

Let b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.

Sample Input 2

8 0 4

Sample Output 2

0

He placed only red balls from the beginning.

Sample Input 3

6 2 4

Sample Output 3

2

Among bbrrrr, there are two blue balls.



Sample input:
8 3 4


Sample output:
4

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
p = N//(A + B) + 1

balls = ("b"*A + "r"*B)*p

if "r" in balls:
  print(len(balls[0:N].replace("r","")))
else:
  print(len(balls[0:N]))

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
p = N//(A + B) + 1

balls = ("b"*A + "r"*B)*p
print(len(balls[0:N].replace("r","")))

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
p = N//(A + B) + 1

balls = ("b"*A + "r"*B)*p

print(len(balls[0:N].replace("r","")))

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())

balls = ""

while len(balls) < N:
  balls += "b"*A + "r"*B

print(len(balls[0:N].replace("r","")))

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
if y<a:
    print(a*(n//(a+b))+())
else:
    print(a*(n//(a+b)+1))

Submission status: Runtime Error

Solution code:
N, A, B = map(int,input().split())

s = ''

while N>len(s):
    s += 'b' * A
    s += 'r' * B

print(s[:N].count('b'))

Submission status: Runtime Error

Solution code:
#include<iostream>
using namespace std;
int main(){
  int n,a,b;
  cin>>n>>a>>b;
  int ans=0;
  ans=(n/(a+b))*a+min(a,n%(a+b));
  cout<<ans<<endl;
  return 0;
}

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
L=""
for _ in range(n//(a+b)+1):
  L += 'b'*a+'r'*b
print(L[:n].count('b'))

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
L=""
for _ in range(10**18):
  L += 'b'*a+'r'*b
print(L[:n].count('b'))

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
L=""
for _ in range(10**100):
  L += 'b'*a+'r'*b
print(L[:n].count('b'))

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
L=""
for _ in range(3):
  L += 'b'*a+'r'*b
print(L[:n].count('b'))

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
ab='u'*A+'r'*B
S=ab*10**100
S4ans=S[:N]
print(S4ans.count('u'))

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
ab='u'*A+'r'*B
S=ab*1000
S4ans=S[:N]
print(S4ans.count('u'))

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
ab='u'*A+'r'*B
S=ab*1000
S4ans=S[:N-1]
print(S4ans.count('u'))

Submission status: Runtime Error

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

k = n//(a+b) + 1
L = ["b"]*a +["r"]*b
L = L*k
print(L[0:n].count("b"))

Submission status: Runtime Error

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

k = n//(a+b) + 
L = ["b"]*a +["r"]*b
L = L*k
print(L[0:n+1].count("b"))

Submission status: Runtime Error

Solution code:
N , A, B, =map(int,input().split())
d, m =divmod(N, A+B)
print(d*A + min(m,A))

Submission status: Runtime Error

Solution code:
def resolve():
    N, A, B = list(map(int, input().split()))
    line = ''
    for i in range(10 ** 100):
        if len(line) > N:
            break
        if i % 2 == 0:
            line += 'b' * A
        else:
            line += 'r' * B

    print(line[:N].count('b'))

    return


resolve()

Submission status: Runtime Error

Solution code:
def resolve():
    N, A, B = list(map(int, input().split()))
    line = ''
    for i in range(10 ** 100):
        if i > N:
            break
        if i % 2 == 0:
            line += 'b' * A
        else:
            line += 'r' * B

    print(line[:N].count('b'))

    return

resolve()

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
S_len=0
S=''
while N>S_len:
  S+=A*'b'+B*'r'
  S_len=len(S)
total=0
for i in range(N):
  if S[i]=='b':
    total+=1
print(total)

Submission status: Runtime Error

Solution code:
import math


def actual(n, a, b):
    # 文字列の長さがN以上になるために必要な操作の回数
    required_operations = math.ceil(n / (a + b))

    s = ''

    for _ in range(required_operations):
        s += '青' * a + '赤' * b

    return s[:n].count('青')


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

Submission status: Runtime Error

Solution code:
def actual(n, a, b):
    s = ''

	for _ in range(10**100):
        s += '青' * a + '赤' * b

        if len(s) >= n:
            return s[:n].count('青')

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

Submission status: Runtime Error

Solution code:
def actual(n, a, b):
    s = ''

    # 無限ループにはならない前提
    while True:
        s += '青' * a + '赤' * b

        if len(s) >= n:
            return s[:n].count('青')

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

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
s = ''
while len(s) < n:
  s += 'b' * a + 'r' * b
print(s[:n].count('b'))

Submission status: Runtime Error

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

s = ""
i = 0

while len(s) < n:
    s += "b"*a if i%2==0 else "r"*b
    i += 1

print(s[:n].count("b"))

Submission status: Runtime Error

Solution code:
N, num_of_blue, num_of_red = map(int, input().split())

num_of_repetition = (N // (num_of_blue + num_of_red))
remainder_s = N % (num_of_blue + num_of_red)
base_s ='b' * num_of_blue + 'r' * num_of_red
count_b = num_of_blue * num_of_repetition + base_s[0:remainder_s].count('b')

print(count_b)

Submission status: Runtime Error

Solution code:
N, num_of_blue, num_of_red = map(int, input().split())

num_of_repetition = (N // (num_of_blue + num_of_red)) + 1
S = ('b' * num_of_blue + 'r' * num_of_red) * num_of_repetition

print(S[0:N].count('b'))

Submission status: Runtime Error

Solution code:
ans = (N // (A+B)) * A
N -= ((A+B) * (N // (A+B)))
if N >= A:
    ans+=A
else:
    ans+=N

print(ans)

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
print(min((N//(A+B))A + N-(N//(A+B), (N//(A+B))A + A))

Submission status: Runtime Error

Solution code:
n = list(map(int, input().split()))
s = b * n[1]
t = r * n[2]
u = 10**100
v = (s + t) * u
w = v.count("b", 0, n[0])
print(w)

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
x=n//(a+b)
y=n%(a+b)

if y<=a:
  print(x*b)
else:
  z=(x*b)+(y-a)
  print z

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())

C = (N // (A + B)) + 1
S = ''
for i in range(C):
  S += 'b'*A + 'r'*B
  
print(S[:N].count('b'))

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
f = ""
for i in range(1000):
    f += a*"b"+b*"r"
print(f[:n].count("b"))

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
f = ""
gg = n // (a+b)
for i in range(gg+1):
    f += a*"b"+b*"r"
print(f[:n].count("b"))

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
f = ""
gg = n // (a+b)
for i in range(gg+1):
    f += a*"b"+b*"r"
print(f[:n])
print(f[:n].count("b"))

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
w='z'*a+'x'*b
f=''
for i in range(1000):
    f+=w
    d=f[:n]
print(d.count('z'))

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
f = ""
for i in range(1000):
    f += a*"b"+b*"r"
print(f[:n]+.count("b"))

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
f = ""
for i in range(1000):
    f += a*"b"+b*"r"
print(f[:n]+.count("b")

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
f = ""
for i in range(1000):
    f += a*"b"+b*"r"
print(f[:n+.count("b")

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
f = ""
for i in range(100):
    f += a*"b"+b*"r"
print(f[:n+.count("b")

Submission status: Runtime Error

Solution code:
n, b, a = map(int, input().split())
print(n // (a + b) * b + min(n % (a + b), b)

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
2 ans = N // (A + B) * A
3 rem = N % (A + B)
4 ans += min(rem, A)
5 print(ans)

Submission status: Runtime Error

Solution code:
N,A,B = input().split()
N = long long (N)
A = int(A)
B = int(B)
rep = (int)(N/(A+B))

numb = min(N%(A+B),A) + rep*A

print(numb)

Submission status: Runtime Error

Solution code:

def resolve():
    n, a, b = map(int, input().split())
    ball = "b" * a
    while len(ball) < n:
        if not len(ball)==0:
            if ball[-1] == "b":
                ball += "r" * b
            else:
                ball += "b" * a
        else:
            ball="r" * b
    print(ball[:n].count("b"))
resolve()

Submission status: Runtime Error

Solution code:
def resolve():
    n, a, b = map(int, input().split())
    ball = "b" * a
    while len(ball) < n:
        if ball[-1] == "b":
            ball += "r" * b
        else
            ball += "b" * a
    print(ball[:8].count("b"))
resolve()

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
S = ''
#print('N:{}'.format(N), 'A:{}'.format(A), 'B:{}'.format(B))

for i in range((N//(A+B))+1):
    S += 'b'*A
    S += 'r'*B
print(S[:N].count('b'))

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
S = ''
print('N:{}'.format(N), 'A:{}'.format(A), 'B:{}'.format(B))

for i in range((N//(A+B))+1):
    S += 'b'*A
    S += 'r'*B
print(S[:N].count('b'))

Submission status: Runtime Error

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

t = []
if n <= a+b:
    print(a)
else:
    for i in range(1,n+1):
        t += "b"*a +"r"*b
        i += 1
    s = t[:n]
    print(s.count("b"))

Submission status: Runtime Error

Solution code:
n,a,b = map(int,input().split())
ans = []
blue = ["b"]*a
red = ["r"]*b

while len(ans) < (n-min(a,b)):
	ans.extend(blue)
	ans.extend(red)

print(ans[:n].count("b"))

Submission status: Runtime Error

Solution code:
n,a,b = map(int,input().split())
ans = []
blue = ["b"]*a
red = ["r"]*b

while len(ans) <= n:
	ans.extend(blue)
	ans.extend(red)
	
tmp = ans[:n]
print(tmp.count("b"))

Submission status: Runtime Error

Solution code:
    
    def __init__(self):
        pass
    
    def A(self):
        S=input()
        if "BA" in S or "AB" in S:print("Yes")
        else:print("No")
    
    def B(self):
        NAB=list(map(int,input().split()))
        
        if NAB[0]<=NAB[1]:ans=NAB[0]
        elif NAB[0]<=NAB[1]+NAB[2]:ans=NAB[1]
        else:
            tail = NAB[0]%(NAB[1]+NAB[2]) if NAB[0]%(NAB[1]+NAB[2])<NAB[1] else NAB[1]
            ans=(int(NAB[0]/(NAB[1]+NAB[2]))*NAB[1])+tail
            
        print(int(ans))
            
    def C(self):
        AB=list(map(int,input().split()))
        ans=-1
        
        #A<B<100
        for i in range(1,1001):
            if AB[0]==int(i*0.08) and AB[1]==int(i*0.1):
                ans=i
                break
            else:continue
        print(ans)
            
    def D(self):
        pass
        
    def E(self):
        pass
    
    def F(self):
        pass
    
    
if __name__=='__main__':
    obj=abc_158()
    obj.B()

Submission status: Runtime Error

Solution code:
import math

n,a,b=map(int,input().split())
st="b"*a+"r"*b

num=math.floor(n/(a+b))
s=st*num

for i in range(n-len(s)):
  if i+1<=a:
    s+="b"
  else:
    s+="r"
    
print(s.count("b"))

Submission status: Runtime Error

Solution code:
import math

n,a,b=map(int,input().split())
st="b"*a+"r"*b

num=math.floor(n/(a+b))
s=st*num

for i in range(n-len(s)):
  if i<=a:
    s+="b"
  else:
    s+="r"
    
print(s.count("b"))

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())

a = ""

blue = 'b'*A
red = 'r'*B
cnt = 0
while cnt<1000:
    a+=blue
    cnt+=1
    a+=red
    cnt+=1

target = a[0:N]
print(target)
num = target.count('b')
print(num)

Submission status: Runtime Error

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

x = n//(a+b)
y = (n-x*(a+b))//a

if y!=0:
  print(a*x+a)
else:
  print(a*x+n-(a+b)*x)

Submission status: Runtime Error

Solution code:
N, A, B = list(map(int,input().split()))
if A = 0:
  print(0)
elif A >= N:
  print(N)
elif A + B >= N:
  print(A)
else:
  print(N - B)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
#  = input()
#a  = int(input())
n, a, b = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

if a == 0:
  print(0)
else:
  nab = n // (a + b)
  ans = nab * a
  mod = n % (nab * (a + b))
  ans += min(mod, a)
  print(ans)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
#  = input()
#a  = int(input())
n, a, b = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

ans = n // a
if (n // (a + b)) % 2 == 1:
    ans += ans % n
print(ans)

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())

Que = []
while len(Que) < N:
    Que = Que + [1]*A
    Que = Que + [0]*B
Que[0:N].count(1)

Submission status: Runtime Error

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

t = n//(a+b)

if t == 0 and n < a:
    c += n
    print(c)
elif t == 0 and n >= a:
    c += a
    print(a)
elif t > 0:
    c += t * a
    r = n%(a+b)
    if r == 0:
        print(c)
    elif r < a:
        c += r 
        print(c)
    elif r > a:
        c += a
        print(c)

Submission status: Runtime Error

Solution code:
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n,a,b = MAP()

q = n//(a+b)
rem = n%(a+b)

ans = q*a
if(rem>a):
    print(ans + a)
else:
    print(ans + rem)

Submission status: Runtime Error

Solution code:
a,b,c=map(int,input().split())
d=''
while a>len(d):
    d+='b'*b
    d+='r'*c
d=d[:a]
print(d)
print(d.count('b'))

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
ans = 'b' * A + 'r' * B
ans *= N // (A + B)
print(ans.count('b'))

Submission status: Runtime Error

Solution code:
import math
a, b = map(int, input().split())
a = math.ceil(a / 0.08)
b = math.ceil(b / 0.1)
tmp_a = set([i for i in range(a, a+13)])
tmp_b = set([i for i in range(b, b+10)])
if len(tmp_a & tmp_b) == 0:
    print(-1)
else:
    print(min(tmp_a & tmp_b))

Submission status: Runtime Error

Solution code:
N.a,b=map(int,input().split())
sho,ama=divmod(N,a+b)
print(N*sho+min(ama,a))

Submission status: Runtime Error

Solution code:
import math
N, A, B = map(int, input().split())
p = A*'b'+B*'r'
v = math.ceil(N/(A+B))
P = p * v
x = P[:N]
print(x.count('b'))

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())

pattern = N // (A + B)

ans += A * pattern
ans += min(N - (A + B) * pattern, A)

print(ans)

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())

Ball = ''

while len(Ball) < N:
    Ball += "B" * A + "R" * B

print(Ball[:N].count("B"))

Submission status: Runtime Error

Solution code:
if a == 0:
    print(0)
else:
    ans = (int(n / (a+b)) * a)
    if n % (a+b) > a:
        print(ans + a)
    else:
        print(ans + (n % (a+b)))

Submission status: Runtime Error

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

if n == 0:
    print(0)
elif: a == 0:
    print(0)
elif b == 0:
    print(n)
elif a >= n:
    print(n)
elif a+b > n > a:
    print(a)
else:
    q,mod = divmod(n, a+b)
    print(q*a + mod)

Submission status: Runtime Error

Solution code:
f a == 0:
    print(0)
elif a > n:
    print(n)
elif a+b > n:
    print(a)
else:
    q,mod = divmod(n, a+b)
    print(q*a + mod)

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
m=A+B
x=int(N/m)
y=int(N%m)
if y<=A:
    print(x*A+y)
else:
    print(A*(X+1))

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
 ans = N // (A + B) * A
 rem = N % (A + B)
 ans += min(rem, A)
 print(ans)

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
 ans = N // (A + B) * A
 rem = N % (A + B)
 ans += min(rem, A)
 print(ans)

Submission status: Runtime Error

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

sum = n//(a+b)*a
res = n%(a*b)
sum += min(res,a)

print(sum)

Submission status: Runtime Error

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

 n//(a+b)

sum = 0
if n >= a:
    while(n > a):
        n = n-a-b
        sum += a
    print(sum+n)
else:
    print(n)

Submission status: Runtime Error

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

sum = 0
if n >= a:
    while(n > a):
        n = n-a-b
        sum += a
print(sum+n)
else:
    print(a)

Submission status: Runtime Error

Solution code:
n = int(input())
a = int(input())
b = int(input())

sum = 0

while(n > a):
    n = n-a-b
    sum += a

print(sum+n)

Submission status: Runtime Error

Solution code:
n, A, B = map(int, input().split())
ans = n // (A + B) * A
#余り
r = n % (A * B)
ans += min(ans, r)
print(ans)

Submission status: Runtime Error

Solution code:
N,A,B =map(int,input().split()) 

from collections import Counter

blues = 'b' * A
reds = 'r' * B

set_balls = blues + reds

all_balls = set_balls * ( N // ( A + B ) + 2 )

balls_N = all_balls[:N]

c = Counter(balls_N)
print(c['b'])

Submission status: Runtime Error

Solution code:
from collections import Counter
N,A,B =map(int,input().split()) 

blue = 'b' * A
red = 'r' * B

set_balls = blue + red
all_balls = set_balls* ( N // ( A + B ) + 1 )
all_balls = all_balls[:N]
c = Counter(all_balls)
print(c['b'])

Submission status: Runtime Error

Solution code:
from collections import Counter
N,A,B =map(int,input().split()) 

blue = 'b'*A
red= 'r'*B

set_balls =blue+red
all_balls = set_balls* ( N//(A+B) + 1 )
all_balls = all_balls[:N]
c = Counter(all_balls)
print(c['b'])

Submission status: Runtime Error

Solution code:
import sys
from collections import Counter

# input処理を高速化する
input = sys.stdin.readline

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

blue = 'b'*A
red= 'r'*B

set_balls =blue+red
all_balls = set_balls* ( N//(A+B) + 1 )
all_balls = all_balls[:N]
c = Counter(all_balls)
print(c['b'])

Submission status: Runtime Error

Solution code:
import sys
from collections import Counter

# input処理を高速化する
input = sys.stdin.readline

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

blue = 'b'*A
red= 'r'*B

ands =red+blue
alls = ands * (N//(A+B) + 1)
alls = alls[:N]
c = Counter(alls)
print(c['b'])

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())

a = "b"*A
b = "r"*B

l = ""
for i in range(1,int(N/(A+B)+1)+1):
    if N - len(l)  > (A+B):
        l = l + a + b
    elif N - len(l) < (A):
        l = l + a[1:(N - len(l)+1)]

l[0:N].count("b")

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())

a = "b"*A
b = "r"*B

l = ""
for i in range(1,int(N/(A+B)+1)+1):
    if N - len(l)  > (A+B):
        l = l + a + b
    elif N - len(l) < (A):
        l = l + a

print(l[0:N].count("b"))

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())

a = "b"*A
b = "r"*B

l = ""
for i in range(1,int(N/(A+B)+1)+1):
    l = l + a + b

print(l[0:N].count("b"))

Submission status: Runtime Error

Solution code:
# import module
import sys
import math
import numpy as np

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

x = int(N / (A+B)) 
y = N % (A+B)

if y > A:
    print(x*A+ A)
else
    print(x*A + y )

Submission status: Runtime Error

Solution code:
i = list(map(int,input().split()))
ans = ""
while len(ans) <= i[0]:
	blue = "b" * i[1]
	red = "r" * i[2]
	ans += blue
	ans += red
end = ans[:i[0]]
print(end.count("b"))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python

def input():
    return sys.stdin.readline()[:-1]

def main():
    n, a, b = map(int, input().split())
    print(n // (a+b) * a + min(n % (a+b), a))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n,a,b = map(int,input())
c = a + b
ans = n/(a+b) + min(n%c,b)

print(ans)

Submission status: Runtime Error

Solution code:
number,b,r=map(int,input().split())
ans=""
for i in range(10):
    ans=ans+("b"*b)+("r"*r)
answer=ans[:number]
answer=answer.replace("r","")
print(len(answer))

Submission status: Runtime Error

Solution code:
number,b,r=map(int,input().split())
ans=""
for i in range(2):
    ans=ans+("b"*b)+("r"*r)
answer=ans[:number]
answer=answer.replace("r","")
print(len(answer))

Submission status: Runtime Error

Solution code:
number,b,r=map(int,input().split())
ans=""
for i in range(number):
    ans=ans+("b"*b)+("r"*r)
answer=ans[:number]
answer=answer.replace("r","")
print(len(answer))

Submission status: Runtime Error

Solution code:
nums = map(int,input().split())
if nums[1] == 0:
	print(0)
else:
	print(nums[1] + nums[0] - nums[2] - nums[1])

Submission status: Runtime Error

Solution code:
s = input().split(" ")
n = int(s[0])
a = int(s[1])
b = int(s[2])
row = []
blue = 0
answer = 0
div = n % (a+b)

for i in range(a):
  row.append("b")
  
for i in range(b):
  row.append("r")

if n > (a+b):
  row.append(row[div])
  
for i in range(0,n):
  if row[i] == "b":
    answer += 1
    
print(answer)

Submission status: Runtime Error

Solution code:
for i in range(10**100):
    total+=B
    b+=1
    if total>N:
        break
    total+=R
    if total>N:
        break
if B==0:
    print(0)

else:
    print(B*b-(total-N))

Submission status: Runtime Error

Solution code:
n, a, b = list(map(int, input().split()))
ans = (n//(a+b)) * a)
ans += n % (a+b) if (n % (a+b)) <= a) else a
print(ans)

Submission status: Runtime Error

Solution code:
n, a, b = list(map(int, input().split()))
ans = (n//(a+b)) * a)
ans += n % (a+b) if (n % (a+b)) <= a) else a
print()

Submission status: Runtime Error

Solution code:
N, A, B = int(input())

print(N//(A+B)*B + max(N%(A+B)-A, 0))

Submission status: Runtime Error

Solution code:
N ,Blue,Red = map(int,input().split())

ans = N //(A+B) *A
rem = N % (A+B)
ans += min(rem,A)
print(ans)

Submission status: Runtime Error

Solution code:
N,A,B=map(int, input().split())

s=N//(A+B)
NA=N%(A+B)
if(A!=0):
  if(NA<A):
    sA=0
    sAG=NA
  else:
    sA=1
    sAG=0
else:
  sA=0
print(s*A+sA*A+sAG)

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())

r = ''
for i in range(10**100):
    r += "b"* A
    if len(r) >= N:
        break
    r += "r"* B
    if len(r) >= N:
        break
print(r[:N].count('b'))

Submission status: Runtime Error

Solution code:
N,A,B = map(float,input().split())

r = ''
while True:
    r += "b"* int(A)
    if len(r) >= int(N):
        break
    r += "r"* int(B)
    if len(r) >= int(N):
        break
print(r[:int(N)].count('b'))

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())

r = ''
while True:
    r += "b"*A
    if len(r) >= N:
        break
    r += "r"*B
    if len(r) >= N:
        break
print(r[:N].count('b'))

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())

r = ''
while True:
    r += "b"*A
    r += "r"*B
    if len(r) >= N:
        break
print(r[:N].count('b'))

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())

x = N // (A+B)
y = N % (A+B)
if A < y:
  sum = A*X + A
else:
  sum = A*X + y
print(sum)

Submission status: Runtime Error

Solution code:
n, a, b = list(map(int, input().split(' ')))
ab = ''

for i in range(n):
    ab = ab + ('a' * a) + ('b' * b)
    if len(ab) == 0:
        break

print(ab[:n].count('a'))

Submission status: Runtime Error

Solution code:
n, a, b = list(map(int, input().split(' ')))
ab = ''

while len(ab) <= n:
    ab = ab + ('a' * a) + ('b' * b)
    if len(ab) == 0:
        break

print(ab[:n].count('a'))

Submission status: Runtime Error

Solution code:
n, a, b = list(map(int, input().split(' ')))
ab = ''

while len(ab) < n:
    ab = ab + ('a' * a) + ('b' * b)
    if len(ab) == 0:
        break

print(ab[:n].count('a'))

Submission status: Runtime Error

Solution code:
n, a, b = list(map(int, input().split(' ')))
ab = ''

while len(ab) < n and a + b != 0:
    ab = ab + ('a' * a) + ('b' * b)

print(ab[:n].count('a'))

Submission status: Runtime Error

Solution code:
n, a, b = list(map(int, input().split(' ')))
ab = ''

while len(ab) < n and a + b != 0 :
    ab = ab + ('a' * a) + ('b' * b)

print(ab[:n].count('a'))

Submission status: Runtime Error

Solution code:
n, a, b = list(map(int, input().split(' ')))
ab = ''

while len(ab) < n:
    ab = ab + ('a' * a) + ('b' * b)

print(ab[:n].count('a'))

Submission status: Runtime Error

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

if a == 0:
  print(0)
else:
  x = n % (a + b)
  y = n // (a + b)
  
ans = a * y + min(x, a)
print(ans)

Submission status: Runtime Error

Solution code:
a,b,c=map(int,input().split())
if a%(b+c)<=b:
  print(((a//b*c)*b)+a%(b+c))
elif b==0:
  print(0)
else:
  print(((a//b*c)*b)+a%(b+c))

Submission status: Runtime Error

Solution code:
N,A,B= map(int,input().split())
    ans=0
    x=0
    i=0
    while(1):
        i+=1
        if x<N:
            if i<=A:
                ans+=1
                x+=1
            elif i>A and i<=A+B:
                x+=1
            else:
                i=0
        else:
            break
    print(ans)

Submission status: Runtime Error

Solution code:
date=input().rstrip().split(" ")
num0=int(date[0])
b=int(num[1])
r=int(num[2])
sum=b+r
if num0%sum==0:
  print(num0/sum*b)
elif num0%sum>=b:
  print((num0-num0%sum)/sum*b+b)
else:
  print((num0-num0%sum)/sum*b+num0%sum)

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
ans = 0

AplusB = A+B

try:
    action_num = N // AplusB
except:
    action_num = 0
ans += action_num * A

try:
    action_mod = N % AplusB
except:
    action_mod = 0

one_action = "B"*A + "R"*B
try:
    for i in range(action_mod):
        if one_action[i] == "B":
            ans += 1
except:
    pass

print(ans)

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
ans = 0

AplusB = A+B

try:
    action_num = N // AplusB
except:
    action_num = 0
ans += action_num * A

try:
    action_mod = N % AplusB
except:
    action_mod = 0

# one_action = "B"*A + "R"*B
for i in range(action_mod):
    if one_action[i] == "B":
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
ans = 0

AplusB = A+B

try:
    action_num = N // AplusB
except:
    action_num = 0
ans += action_num * A

try:
    action_mod = N % AplusB
except:
    action_mod = 0

one_action = "B"*A + "R"*B
# for i in range(action_mod):
#     if one_action[i] == "B":
#         ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
ans = 0

AplusB = A+B

try:
    action_num = N // AplusB
except:
    action_num = 0
ans += action_num * A

try:
    action_mod = N % AplusB
except:
    action_mod = 0

one_action = "B"*A + "R"*B
for i in range(action_mod):
    if one_action[i] == "B":
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
ans = 0

AplusB = A+B

action_num = N // AplusB
ans += action_num * A

action_mod = N % AplusB
one_action = "B"*A + "R"*B
for i in range(action_mod):
    if one_action[i] == "B":
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
def main():
  n,a,b = (int(x) for x in input().split())

  num_a = int(n / (a + b))
  num_b = int(n % (a + b))
  
  if(num_b >= a):
    nun_x = a
  else:
    num_x = num_b

  print(num_a * a + num_x)
  
if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
    a = list(map(int, input().split()))
    if a[0] > a[1] + a[2]:
      print(a[0]-a[2])
    elif a[0]<= a[1]:
      print (a[0])
    elif a[0] > a[1]:
      print (a[1])

Submission status: Runtime Error

Solution code:
from sys import stdin

n,a,b=map(int,input().split())
ans=0
ans+=(n//(a+b))*a
n%=a+b
if n<=a:
    ans+=n
else:
    ans+=a
print(str(ans)+"\n)

Submission status: Runtime Error

Solution code:
N,A,B = map(int, input().split())
  
if N % (A + B) == 0:
  print(N // (A + B) * A)
elif N % (A + B) - A < 0:
  print(N // (A + B) * A + abs(N % (A + B) - A)
elif N % (A + B) - A > 0:
  print(N // (A + B) * A + A)

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
set_bule = N//(A+B) * A
other = N - N//(A+B) * (A+B)
if 0 <= other <= A:
    hashi_ bule = other
else :
    hashi_bule = A
print(set_bule + hashi_bule)

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
set_bule = //(A+B) * A
other = N - N//(A+B) * (A+B)
if 0 <= other <= A:
    hashi_ bule = other
else :
    hashi_bule = A
print(set_bule + hashi_bule)

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())

2 ans = N // (A + B) * A

3 rem = N % (A + B)

4 ans += min(rem, A)

5 print(ans)

Submission status: Runtime Error

Solution code:
date=input().rstrip().split(" ")
num=int(date[0])
list0=[]
for i in range(100):
  j=0
  k=0
  for j in range(int(date[1])):
    list0.append("b")
  for k in range(int(date[2])):
    list0.append("r")
sum=0
for m in range(num):
  if list0[m]=="b":
    sum += 1
print(sum)

Submission status: Runtime Error

Solution code:
S = input()
list_num = S.split(' ')
list_num = map(int, list_num)
N, A, B = list_num[0], list_num[1], list_num[2]

if A+B>N:
  print(N-A-B)
elif A+B=N:
  print(A)

Submission status: Runtime Error

Solution code:
S = input()
list_num = S.split(' ')
list_num = map(int, list_num)
N, A, B = list_num

if A+B>N:
  print(N-A-B)
elif A+B=N:
  print(A)

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())

b = ''
while len(b) < N:
    b += 'b' * A
    b += 'r' * B

print(b[:N].count('b'))

Submission status: Runtime Error

Solution code:
import strutils, sequtils

proc solve(n,a,b:int):int=
  return n.div(a+b)*a+min(a,n.mod(a+b))


var nab = stdin.readline().split(" ").mapIt(it.parseInt)

echo solve(nab[0],nab[1],nab[2])