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.

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

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

if A < N%(A + B):
    print((N//(A + B))*A + A)
else:
    print((N//(A + B))*A + N%(A + B))

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

s = N // (A + B)
a = N % (A + B)

if A >= a:
    ans = A * s + a
else:
    ans = A * s + A

print(ans)

Solution (Python):
N, A, B = map(int, input().split())
n = N % (A+B)
k = N // (A+B)

if n < A:
  print(n+k*A)
else:
  print(A+k*A)

Solution (Python):
import sys

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

Count_Blue = 0
if 1<=N<=10**18 and A > 0 and B >= 0 and \
   0< A + B <= 10**18:
    Add_Blue = 1 * A
    Add_Both = Add_Blue + 1 * B

    q = N // Add_Both
    mod = N % Add_Both
    if mod < Add_Blue:
        Count_Blue = (q *Add_Blue) + mod
    else:
        Count_Blue = (q * Add_Blue) + Add_Blue
    print(Count_Blue)
elif A == 0:
    print(Count_Blue)

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

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

Solution (Python):
n, a, b = list(map(int, input().split()))
if a != 0:
    c1 = n // (a + b)
    c2 = n - ((a + b) * c1)
    print(a * c1 + (c2 if c2 < a else a))
else:
    print("0")

Solution (Python):
N, A, B = map(int, input().split())
len_loop = A + B
n_comp_loop = N//len_loop
blue_res = min(A, N % len_loop)
print(n_comp_loop * A + blue_res)

Solution (Python):
N, A, B = map(int, input().split())
if A > (N % (A + B)):
    print((N // (A + B)) * A + N % (A + B))
else:
    print((N // (A + B)) * A + A)

Solution (Python):
N, A, B = list(map(int, input().split()))
a = N//(A+B)*A
amari = N%(A+B)

if amari >= A:
  print(a + A)
else:
  print(a + amari)

Solution (Python):
n,b,r = map(int,input().split())

loop = n//(b+r)
mod = n%(b+r)
extra = min([b,mod])

print(loop*b+extra)

Solution (Python):
N,A,B = map(int,input().split())
q = N // (A+B)
m = N % (A+B)
if m > A:
    m = A
ans = q*A+m
print(ans)

Solution (Python):
n = 0

N, A, B = [int(i) for i in input().split()]

n += int(N/(A+B)) * A

amari = N % (A+B)
n += min(amari, A)

print(n)

Solution (Python):
N,A,B=map(int,input().split())
x=N//(A+B)
y=N%(A+B)
if A==0:
    print(0)
else:
    if y>A:
        y=A
    print(x*A+y)

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

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

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

Solution (Python):
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


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


if __name__ == '__main__':
    main()

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

cnt = int(n/(a+b))


print(a*cnt + min(a,(n-(cnt*(a+b)))))

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

Solution (Python):
N,A,B = [int(i) for i in input().split()]

bcnt = 0
cnt = N // (A+B)

bcnt += cnt*A
rest = N - (A+B)*cnt

bcnt += min(A, rest)

print(bcnt)

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

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

r_1 = n // (a + b)
r_2 = n % (a + b)
if r_2 > a:
    r_2 = a
print(r_1*a + r_2)

Solution (Python):
N,A,B = map(int,input().split())
a = N // (A+B)
b = N - a*(A+B)
if b >= A:
  print(A*(a+1))
else:
  print(A*a+b)

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

ans = (n // (a + b)) * a

if n % (a + b) < a:
    ans += n % (a + b)
else:
    ans += a

print(ans)

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

Solution (Python):
s = input().split()
N, A, B = int(s[0]), int(s[1]), int(s[2])


def calc_rst(N, L):
    if int(N % L) > A:
        return A
    else:
        return int(N % L)


def solve(N, A, B, L=A+B):
    return (int(N / L) * A) + calc_rst(N, L)


print(solve(N, A, B))

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

if(Blue >= N):
    print(N)
elif (Blue + Red) >= N or Blue == 0:
    print(Blue)
else:
    q = N // (Blue + Red)
    mod = N % (Blue + Red)
    if Blue < mod:
        print(q * Blue  + Blue)
    else:
        print(q * Blue + mod)

Solution (Python):
n, a, b = map(int, input().split())
times = n // (a + b)
r = n % (a + b)

print(times * a + min(r, a))

Solution (Python):
base = input().split()
n = int(base[0])
a = int(base[1])
b = int(base[2])
block = a+b
blockcnt = n//block
partx =a*blockcnt
ans = 0
if a>=(n%block):
    ans = partx+(n%block)
else:
    ans = partx+a
print(ans)

Solution (Python):
if __name__ == '__main__':
    (n, a, b) = tuple(map(int, input().split()))
    ans = n // (a + b) * a
    ans += min(n % (a + b), a)
    print(ans)

Solution (Python):
N, A, B = map(int, input().split())
ans = N//(A+B) * A
if N%(A+B) >= A:
  ans += A
else:
  ans += N%(A+B)
print(ans)

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

Solution (Python):

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

S = int(N / (A+B))
ans = S*A

amari = N % (A+B)
if(amari <= A):
  ans = ans + amari
  print(int(ans))
else:
  ans = ans + A
  print(int(ans))

Solution (Python):
n, b, r = map(int, input().split())
div = n//(b+r)
base = b*div
zan = n%(b+r)
ama = min(zan, b)
print(base+ama)

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

Solution (Python):
import sys

n,a,b=map(int,sys.stdin.readline().split())

c=(n//(a+b))
d=(n%(a+b))

print(c*a+min(d,a))

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

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

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

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

Solution (Python):
import sys

f = sys.stdin.readline()
xx = f.split(' ')
x = [int(str) for str in xx]

n = x[0]
a = x[1]
b = x[2]


ab = a + b

d = int(n / ab)
m = n % ab

if ( a > m):
	sum = a * d + m
else:
	sum = a * d + a

print sum
sys.stdout.flush()

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

Solution (Python):

import sys

N, A, B = map(int, sys.stdin.read().split())

n = N // (A + B)
r = N % (A + B)
a = min(r, A)

print(n * A + a)

Solution (Python):
n,a,b=map(int,input().split())
ans=0
ans=n//(a+b)*a
if n%(a+b)!=0:
  ans+=min(n%(a+b),a)
print(ans)

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

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

Solution (Python):
n,a,b = map(int, input().split())
k = n%(a+b)
p = n//(a+b)
if k < a:
    print(a*p+k)
else:
    print(a*p+a)

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

result=0
result+=N//(A+B)*A
result+=min(N%(A+B),A)
print(result)

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

kuri = n // (a+b)
amari = n % (a+b)
print(kuri * a + min(amari, a))

Solution (Python):
N,A,B = map(int,input().split())
a = N//(A+B)
ans = a*A
ans2 = min(N-(A+B)*a,A)
print(ans+ans2)

Solution (Python):

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

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

if(r <= a and a != 0):
  print("{}".format(q * a + r))
elif(r > a and a != 0):
  print("{}".format((q + 1)* a))
elif(a == 0):
  print("0")

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

c = n // (a+b)
d = n % (a+b)

print(c * a + min(d, a))

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

Solution (Python):
N,A,B = list(map(int,input().split()))
l = N//(A+B)
c = l*A
m = N%(A+B)
print(c + min(A,m))

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

Solution (Python):
N,A,B=map(int,input().split())
print(N//(A+B)*A+(A if N%(A+B)>=A else N%(A+B)))

Solution (Python):
a = input().split()

N = int(a[0])
A = int(a[1])
B = int(a[2])

i = int(N/(A+B))

cut = N - (A+B)*i

if N < A:
  Blue_Ball_Num = N
elif N < A+B:
  Blue_Ball_Num = A
elif cut > A:
  Blue_Ball_Num = A*(i+1)
else:
  Blue_Ball_Num = A*i + (N - (A+B)*i)
  
print(Blue_Ball_Num)

Solution (Python):
tmp = input().split()
N = int(tmp[0])
A = int(tmp[1])
B = int(tmp[2])
print(A*(N//(A+B))+min(A, N%(A+B)))

Solution (Python):
n, a, b = (int(i) for i in input().split());

res = a * (n // (a + b));

curr = n % (a + b);

res += min(a, curr);

print(res);

Solution (Python):
n,a,b=map(int,input().split())
q,r=divmod(n,a+b)
print(q*a+min(r,a))

Solution (Python):
N,A,B=(int(x) for x in input().split())
a=int(A+B)
b=int(N/a)
c=int(N%a)
if c<A:
  print(int(b*A+c))
else:
  print(int(b*A+A))

Solution (Python):
def main():
    n, a, b = map(int, input().split())
    
    div = n // (a+b)
    rest = n % (a+b)
    if rest >= a:
        rest = a

    print(div*a + rest)


if __name__ == '__main__':
    main()

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

q = N//(A + B)
r = N%(A + B)

print(q * A + min(r, A))

Solution (Python):
def isneg(x):
    if x[0]=="-": return True
    else: return False


def neg(x):
    if isneg(x): return x[1:]
    else: return "-" + x

    
def zerot(x):
    rx = list(x[::-1])
    while rx[-1] == "0":
        rx.pop()
        if len(rx) == 0: 
            rx = ["0"]
            break
    return "".join(rx[::-1])


def zerocut(x):
    if isneg(x):
        ans = neg(zerot(neg(x)))
        if ans == "-0": return "0"
        return ans 
    else:
        return zerot(x)


def bigsmal(x, y):
    if isneg(x) or isneg(y): raise Exception("negative input")
    if len(x) > len(y):
        return x,y
    elif len(x) < len(y):
        return y,x
    else: return tuple(sorted([x, y])[::-1])
    

def bigsmall(x, y):
    if (not isneg(x)) and isneg(y):
        return x,y
    elif isneg(x) and (not isneg(y)):
        return y,x
    elif (not isneg(x)) and (not isneg(y)):
        return bigsmal(x, y)
    elif isneg(x) and isneg(y):
        tmp = bigsmal(neg(x), neg(y))[::-1]
        return tuple(neg(i) for i in tmp)
    

def greater(x, y):
    if (bigsmall(x, y) == (x, y)) and x != y: return True
    else: return False
    

def ad(x, y):
    if isneg(x) or isneg(y): raise Exception("negative input")
    ra = [0] * (max(len(x), len(y)) + 1)
    rx = [int(i) for i in x][::-1]
    ry = [int(i) for i in y][::-1]
    for i in range(len(rx)): ra[i] += rx[i]
    for i in range(len(ry)): ra[i] += ry[i]
    for i in range(len(ra) - 1):
        ra[i+1] += ra[i] // 10
        ra[i] = ra[i] % 10
    ans = "".join([str(i) for i in ra][::-1])
    return zerocut(ans)


def s_b(x, y):
    if isneg(x) or isneg(y): raise Exception("negative input")
    if bigsmall(x, y) != (x, y): raise Exception("not x>=y error")
    ra = [0] * (max(len(x), len(y)))
    rx = [int(i) for i in x][::-1]
    ry = [int(i) for i in y][::-1]
    for i in range(len(rx)): ra[i] += rx[i]
    for i in range(len(ry)): ra[i] -= ry[i]
    for i in range(len(ra) - 1):
        if ra[i] < 0:
            ra[i] = 10 + ra[i]
            ra[i+1] -= 1
    ans = "".join([str(i) for i in ra][::-1])    
    return zerocut(ans)


def sb(x, y):
    if isneg(x) or isneg(y): raise Exception("negative input")
    if (x, y) == bigsmall(x, y):
        return s_b(x, y)
    else:
        return neg(s_b(y, x))


def add(x, y):
    if isneg(x) and isneg(y):
        return neg(ad(neg(x), neg(y)))
    elif (not isneg(x)) and (not isneg(y)):
        return ad(x, y)
    elif (not isneg(x)) and isneg(y):
        return sb(x, neg(y))
    elif isneg(x) and (not isneg(y)):
        return sb(y, neg(x))
    

def sub(x, y):
    if isneg(x) and isneg(y):
        return sb(neg(y), neg(x))
    elif (not isneg(x)) and (not isneg(y)):
        return sb(x, y)
    elif (not isneg(x)) and isneg(y):
        return ad(x, neg(y))
    elif isneg(x) and (not isneg(y)):
        return neg(ad(neg(x), y))
        

def ml(x, y):
    if isneg(x) or isneg(y): raise Exception("negative input")
    ra = [0] * (len(x) + len(y))
    rx = [int(i) for i in x][::-1]
    ry = [int(i) for i in y][::-1]
    for i in range(len(rx)):
        for j in range(len(ry)):
            ra[i+j] += rx[i] * ry[j]
    for i in range(len(ra) - 1):
        ra[i+1] += ra[i] // 10
        ra[i] = ra[i] % 10
    ans = "".join([str(i) for i in ra][::-1])
    return zerocut(ans)
    

def mul(x, y):
    if isneg(x) and isneg(y):
        return ml(neg(x), neg(y))
    elif (not isneg(x)) and (not isneg(y)):
        return ml(x, y)
    elif (not isneg(x)) and isneg(y):
        return neg(ml(x, neg(y)))
    elif isneg(x) and (not isneg(y)):
        return neg(ml(neg(x), y))
        

def mod2(x):
    return int(x[-1]) % 2


def div2(x):
    if isneg(x): raise Exception("negative input")
    ans = [0] * len(x)
    xs = [int(i) for i in x]
    for i in range(len(x)-1):
        ans[i] += xs[i]
        ans[i+1] += (ans[i]%2) * 10
        ans[i] //= 2
    ans[len(x)-1] = (ans[len(x)-1] + xs[len(x)-1])//2
    ans = "".join([str(i) for i in ans])
    return zerocut(ans)
        

def isdv(x, a, b):
    if isneg(x) or isneg(a) or isneg(b): raise Exception("negative input")
    if b == "0": raise Exception("zero div error")
    ab = sub(a, b)
    bx = mul(b, x)
    cond1 = greater(bx, ab)
    cond2 = ((a, bx) == bigsmall(a, bx))
    if cond1 and cond2: 
        return True
    else: 
        return False


def dv(a, b):
    """[(str(i), dv("12", str(i))) for i in range(1, 15)]"""
    if isneg(a) or isneg(b): raise Exception("negative input")
    if b == "0": raise Exception("zero div error")
    if b == "1": return a
    left = "0"
    right = a
    while greater(right, add(left, "1")):
        x = div2(add(left, right))
        
        if (a, mul(b, x)) == bigsmall(a, mul(b, x)):
            left = x
        else:
            right = x
    return left


def div(x, y):
    if isneg(x) and isneg(y):
        return dv(neg(x), neg(y))
    elif (not isneg(x)) and (not isneg(y)):
        return dv(x, y)
    elif (not isneg(x)) and isneg(y):
        return neg(dv(x, neg(y)))
    elif isneg(x) and (not isneg(y)):
        return neg(dv(neg(x), y))


def mod(x, y):
    if isneg(x) or isneg(y): raise Exception("negative input")
    divmul = mul(div(x, y), y)
    return sub(x, divmul)


n,a,b = input().split()
ans1 = mul(div(n, add(a, b)), a)
ans2 = bigsmall(mod(n, add(a, b)), a)[1]
print(add(ans1, ans2))

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

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

Solution (Python):
n,a,b = map(int, input().split())
q, mod = divmod(n, a+b)
if mod > a:
    ans = a*(q+1)
else:
    ans = a*q + mod
print(ans)

Solution (Python):
N,A,B = map(int,input().split())
a = (N // (A + B)) * A
b = N % (A + B)
a += min(b,A)
print(a)

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

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

Solution (Python):
n,a,b=list(map(int,input().split()))
m=n//(a+b)
if n%(a+b)>=a:
    print(a*(m+1))
else:
    print(a*m+n%(a+b))

Solution (Python):
from sys import stdin 


N, A, B = map(int, stdin.readline().split())

n, r = divmod(N, A + B)
ans = 0
ans += n*A
ans += min(A, r)
print (ans)

Solution (Python):
nab = input().split(' ')
if len(nab) != 3:
    raise Exception

n = int(nab[0])
a = int(nab[1])
b = int(nab[2])

loop = int(n / (a + b))
count_blue = loop * a
last = n - (a + b) * loop
if last > a:
    count_blue += a
else:
    count_blue += last

print(count_blue)

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

ans = n // (a + b) * a
rem = n % (a + b)
ans += min(rem, a)
print(ans)

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

cnt = 0
cnt += A * (N // (A + B))
if N % (A+B) >= A:
    cnt += A
else:
    cnt += N % (A+B)
print(cnt)

Solution (Python):
n,a,b=[int(j) for j in input().split()]
print(a*(n//(a+b))+min(n%(a+b),a))

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

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

r = N % (A + B)

ans = ans + min(r, A)

print(ans)

Solution (Python):


n, a, b = map(int, input().split())
ans = (n // (a + b))
mod = min(n - ans * (a + b), a)
ans = ans * a + mod
print(ans)

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

Solution (Python):
n, a, b = map(int, input().split())
c, d = divmod(n, a + b)
ans = a * c + min(d, a)

print(ans)

Solution (Python):

num, greenNum, redNum = map(lambda x: int(x), input().split(' '))

numSet = num // (greenNum+redNum)
remain = num % (greenNum+redNum)
numRest = remain if (remain < greenNum) else greenNum

totalGreen = numSet * greenNum + numRest

print(totalGreen)

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

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

print(ans)

Solution (Python):
n,a,b=(int (x) for x in input().split())
sho=n//(a+b)
amari=n%(a+b)
pre=min(amari,a)
ans=a*sho+pre
print(ans)

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

count = N//(A+B)
amari = N%(A+B)

if amari < A:
  c = amari
else:
  c = A
  
ans = A * count + c
print(ans)

Solution (Python):
N, A, B = map(int, input().split())
q, r = divmod(N, A + B)
if r <= A:
    blues = q * A + r
else:
    blues = (q + 1) * A
print(blues)

Solution (Python):
N, blue, red = map(int,input().split())
count = min(N % (blue+red), blue)
count += int(N/(blue+red)) * blue
print(count)

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

q = n // (a + b)

x = a * q

w = n % (a + b)
if w >= a:
    y = a
else:
    y = w

ans = x + y

print(ans)

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

a = A+B

x = N//a  
y = N%a 

if y < A:
    b = y
else:
    b = A

blue_count = A * x + b

print(blue_count)

Solution (Python):
N,A,B = map(int,input().split())
repete = N//(A+B)
sub = N%(A+B)
if sub <= A:
	print(A*repete+sub)
else:
	print(A*repete+A)

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

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

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

a = int(N/(A+B))
b = N % (A+B)
if b > A :
    print(A * a + A)
else:
    print(A * a + b)

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

Solution (Python):
N, A, B = map(int, input().split())
answer = N // (A+B) * A
remainder = N % (A+B)
answer += min(remainder, A)
print(answer)

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

count = (N//(A+B))*A

if N%(A+B) >= A:
    count += A
else:
    count += N%(A+B)

print(int(count))

Solution (Python):
N,A,B = map(int,input().split())
a = N//(A+B)
ans = a*A
ans2 = min(N-(A+B)*a,A)
print(ans+ans2)

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

ans = n//(a + b)*a
ans+=min(a,n%(a+b))
print(ans)

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

def blue(n, a, b):
  res = 0
  s = n // (a+b)
  res += a*s
  n -= s*(a+b)
  if n <= a:
    res += n
  else:
    res += a
  return res

print(blue(N, A, B))

Solution (Python):
N, A, B = map(int, input().split(" "))
x = N // (A + B)
y = N % (A + B)
a = A * min([x, 10 ** 100])
if y > A:
  a += A
else:
  a += y
print(a)

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

t = n //(a+b)
s = min(n-(a+b)*t, a)
print(t*a+s)

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

syou = N // (A + B)
mod = N % (A + B)

ans = A * syou

ans += min(A, mod)

print(ans)

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

syou = N // (A + B)
mod = N % (A + B)

ans = A * syou

if (mod <= A):
    ans += mod
else:
    ans += A

print(ans)

Solution (Python):
S = input()
N,A,B = S.split(' ')
N = int(N)
A = int(A)
B = int(B)
ans = N //(A+B) * A
left = N % (A+B)
if left > A:
    ans += A
else:
    ans += left
print(ans)

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

Solution (Python):
n,a,b=map(int,input().split())
if n%(a+b)<=a:
    lol=n%(a+b)
else:
    lol=a

ans=(n//(a+b))*a+lol
print(ans)

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

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

if y >= a:
    s = a
else:
    s = y

print(a*x + s)

Solution (Python):
n,a,b=map(int,input().split())
ans=0

se=n//(a+b)
n%=a+b
ans+=se*a + min(a,n)
print(ans)

Solution (Python):
class Solution:
    def solve(self, N: int, A: int, B: int) -> int:

        return (N // (A+B)) * A + min(N % (A+B), A)


if __name__ == '__main__':

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

    
    solution = Solution()
    print(solution.solve(N, A, B))

Solution (Python):
n, a, b = map(int, input().split())
if a == 0:
    ans = 0
else:
    ans = (n//(a+b))*a
    n = n-(a+b)*(ans//a) 
    if n >= a:
        ans += a
    else:
        ans += n%a
print(ans)

Solution (Python):
N, A, B = map(int,input().split())
patternNum = N // (A + B)
remains = N % (A + B)
if (remains > A):
	print(patternNum * A + A)
else:
	print(patternNum * A + remains)

Solution (Python):
N,A,B=map(int,input().split())
range=10**100
count=N//(A+B)
amari=N%(A+B) 
add=A if A < amari else amari
print(count*A+add)

Solution (Python):
N,A,B = map(int, input().split())
Q = N//(A + B)
r = N % (A + B)
if r < A+1:
    x = A * Q + r
else:
    x = A * (Q+1)
print(x)

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

q, x = divmod(N, A+B)


ans = q*A+int(min(x,A))

print(ans)

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

Solution (Python):
N, A, B = map(int, input().split())
x = N%(A+B)
y = N//(A+B)

print(y*A + min(x, A))

Solution (Python):
N, A, B = map(int, input().split())
if (A == 0):
    print('0')
elif (B == 0):
    print(N)
else:
    sum = A + B
    div = N // sum
    mod = N % sum
    plus = mod - A
    if (plus > 0):
        ans = div*A + A
        print(ans)
    else:
        ans = div*A + mod
        print(ans)

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

X = N // (A+B)
Y = N % (A+B)
print(X*A+min(Y,A))

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

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

Solution (Python):
'''input
6 2 4
'''
n, a, b = input().split()
n = int(n)
a = int(a)
b = int(b)

ans = 0

t = n // (a + b)

ans = ans + t * a
rem = min(n - t * (a + b), a)

print(ans + rem)

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

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

if(N%(A+B)>A):
    print(A+(N//(A+B))*A)
else:
    print((N//(A+B))*A+N%(A+B))

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

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

q, mod = divmod(n, (a+b))

ans = q * a + min(mod, a)
print(ans)

Solution (Python):
N,A,B=list(map(int,input().split()))
a=N//(A+B)*A
if N==A+B:
  print(a)
else:
  print(a+min(N%(A+B),A))

Solution (Python):
n,a,b = (int(x) for x in input().split())
full = n // (a+b)
rem = n - full*(a+b)
rem_a = min(a, rem)
print(full*a+rem_a)

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

base = A + B
count = (N // base)
remain = min(A, N % base)

print(A * count + remain)

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

x, y = divmod(N, A+B)
print(x * A + min(A, y))

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,a,b = LI()
    c = a+b
    r = n // c * a
    r += min(a, n % c)

    return r


print(main())

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

Solution (Python):


num = input().split()
N, b, r = [int(N) for N in num]

n = N % (b+r)
if n>b:
    print(int(N / (b+r)) * b + b)
else:
    print(int(N / (b+r)) * b + n)

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

ans = n // (a+b) * a
r = n % (a+b)

ans += min(a, r)

print(ans)

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

x = (N // (A + B)) * A
a = (N % (A + B))
x += min(A, a)

print(x)

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



k = n // (a + b)

c = k * a

md = n % (a + b)

if md >= a:
    c += a
else:
    c += md

print(c)

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

q, r = divmod(N, A + B)
print(q * A + (A if A <= r else r))

Solution (Python):
n,a,b=map(int,input().split())
q,mod=divmod(n,a+b)

if mod<a:
  print(a*q+mod)
else:
  print(a*q+a)

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




c = int(n / (a+b))
count = c * a


d = int(n % (a+b))

if d > a:
    count += a


if d <= a:
    count += d

print(count)

Solution (Python):
N,A,B = map(int,input().split())
 
 
S = A+B
div = N//S
dd = N % S
 
ans = div * A + min(dd,A)
 
print(ans)

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

x,y = divmod(N,(A+B))

if y <= A:
  print(A*x+y)
else:  
  print(A*x+A)

Solution (Python):
n, b, r = map(int, input().split())
ans = n // (b+r) * b 
ans += min(n % (b+r), b)
print(ans)

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

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

Solution (Python):
import math
N, A, B = (int(x) for x in input().split(' '))
tmp = A * math.floor(N/(A+B))

if ( N % (A+B) ) > A:
  print(tmp+A) 
else:
  print(tmp+( N % (A+B)))

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

print(n // (a + b) * a + min(n % (a + b) ,a))

Solution (Python):
a=list(map(int,input().split()))
num=a[1]*(a[0]//(a[1]+a[2]))
if a[0]%(a[1]+a[2])>=a[1]:
  num=num+a[1]
else:
  num=num+a[0]%(a[1]+a[2])
print(num)

Solution (Python):
import sys
from collections import Counter

sys.setrecursionlimit(1000000)
input = lambda: sys.stdin.readline().rstrip()

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

Solution (Python):
N,A,B = map(int,input().split())
ans = 0
ans += (N//(A+B)) * A
i = min((N % (A+B)),A)
if i >= 0:
    ans += i
print(ans)

Solution (Python):
n, a, b = map(int,input().split())
if a == 0 and b == 0:
    print(0)
if a != 0 or b != 0:
         
    kumi = n // (a + b)
    nokori = n % (a + b)
    if nokori == 0:
        print(a * kumi)
    elif nokori >= 1 and nokori < a:
        print(a * kumi + nokori)
    elif nokori >= a:
        print(a * kumi + a)

Solution (Python):
N, A, B = [int(i) for i in input().split()]

C = A+B
base = A*(N//C)

if N%C >= A:
    hasu = A
else:
    hasu = N%C

answer = base + hasu
print(answer)

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

Solution (Python):
import sys
sys.setrecursionlimit(1000000)
input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
INF = 500000
mod = 10**9+7

N, A, B = map(int, input().split())
C = A+B
x = N//C
print(x*A+min(N-x*C, A))

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

Solution (Python):
a=input().split()
N,A,B=int(a[0]),int(a[1]),int(a[2])
b=int(N/(A+B))
ans=int(A*b)
if(N-b*(A+B)<=A):
    ans=ans+N-b*(A+B)
else:
    ans+=A
print(int(ans))

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


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


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


print(ans)

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

c = a + b
n_1 = n // c
amari = n % c

print(n_1 * a + min(amari,a))

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

ans1 = n//(a + b) * a
ans2 = min(n % (a + b), a)
print(ans1 + ans2)

Solution (Python):
s = input()
n,a,b = map(int, s.split(" "))
if n%(a+b) <=a:
    print(int(n/(a+b))*a + n%(a+b))
else:
    print(int(n/(a+b))*a + a)