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: Accepted

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

pair = N//(A+B)

res = pair * A + min(A, (N - pair*(A+B)))
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,b,r=map(int,input().split())
A=n//(b+r)
if n%(b+r)>=b:
    print(A*b+b)
else:
    print(A*b+(n%(b+r)))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

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

print(m)

Submission status: Accepted

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

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

Submission status: Accepted

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

t = n%(a+b)

if n < a:
    print(n)
else:
    if a > t > 0:
        print(n//(a+b)*a+t)
    elif t >= a:
        print(n//(a+b)*a+a)
    else:
        print(n//(a+b)*a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

times = n//(a+b)
remain = n%(a+b)

if remain < a:
    print(a*times+remain)
else:
    print(a*(times+1))

Submission status: Accepted

Solution code:
#k=int(input())
n,a,b=map(int,input().split())
#hl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
total=a+b
ans=(n//total)*a

print(ans+min(a,n%total))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n, a, b = map(int, input().split())

    mod = n % (a + b)

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


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Accepted

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

Submission status: Accepted

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

if A==0:
    print(0)
elif N%(A+B)<=A:
    print(N//(A+B)*A+N%(A+B))
elif N%(A+B)>A:
    print(N//(A+B)*A+A)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(numb)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC158B

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

Submission status: Accepted

Solution code:
import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
n,a,b=map(int,stdin.readline().split())
ans=0
ans+=a*(n//(a+b))
n=n%(a+b)
if(n<=a):
    ans+=n 
else:
    ans+=a
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

nkome = n % (a+b)
kaisuu = n // (a+b)

if nkome > a:
    print(a*(kaisuu+1))
else:
    print(n-b*kaisuu)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
t= a+b
ans = (n//t)*a

if n%t>=a:
    ans+=a
else:
    ans+=n%t
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

C = A + B
N = min(N, C * 10 ** 100)
print(N // C * A + min(A, N % C))

Submission status: Accepted

Solution code:
N, A, B = list(map(int, input().split()))
#print('N:{}'.format(N), 'A:{}'.format(A), 'B:{}'.format(B))
#print(A*(N//(A+B)), min(A, N%(A+B)))
print(A*(N//(A+B)) + min(A, N%(A+B)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
syou = n//(a+b)
kakutei = syou*a
nokori = n - syou*(a+b)

if nokori <= a:
  print(kakutei + nokori)
else:
  print(kakutei + a)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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



def main():
    nsum = (a+b)
    #n<=(a+b)
    if(a==0):
        print(0)
        return

    if(n<=nsum):
        if(n<a):
            print(n)
        else:
            print(a)
        return
    else:
        div = n//nsum
        remain = n - div*nsum
        ans = div*a
        if(remain<=a):
            ans += remain
        else:
            ans += a
        print(ans)
        return
        
main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A,B = map(int, input().split())
ans = 0
S = A+B
T = N//S
U = N%S


if(A == 0):
    ans = 0
else :
    if(0< U < A):
        ans = A*T+U
    elif(U == 0):
        ans = A*T
    elif(U >= A):
        ans = A*T+A
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = list(map(int,input().split()))
N = a[0]
blue = a[1]
red = a[2]
ans = 0
A = blue + red
X = N // A
Y = N % A
if Y <= blue:
    ans = blue * X + Y
else:
    ans = blue * X + blue
print(ans)

Submission status: Accepted

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

Q = N // (A + B)
r = N - Q * (A + B)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b = [int(i) for i in input().split()]
d=int(n/(a+b))
r=n%(a+b)
if r==0:
  print(d*a)
elif r>a:
  print(d*a+a)
else:
  print(d*a+r)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
import math
import fractions
import functools
n, a, b = map(int, input().split())
count = n // (a+b)*a
if n % (a+b) <= a:
    count += n % (a+b)
if n % (a+b) > a:
    count += a

print(count)

Submission status: Accepted

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: Accepted

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

ans += a*(n//(a+b))
if n%(a+b)>=a:
    ans += a
else:
    ans += n%(a+b)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

class abc_158:
    
    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: Accepted

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


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

AB = A + B

div, mod = divmod(N, AB)

blue = A * div
blue += min(mod, A)

print(blue)

Submission status: Accepted

Solution code:

N, A, B = list(map(int, input().split()))
i = 0
b = 0
r = 0

c = N//(A+B)
#print(c)
d = N%(A+B)
#print(d)
if d <= A:
    b = c*A + d
else:
    b = (c+1)*A
print(b)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

set = N // (A + B)
rest = N - set * (A + B)


if rest <= A:
    ans = A * set + rest

else:
    ans = A * (set + 1)

print(ans)

Submission status: Accepted

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

x = n//(a+b)*a
y = min(a,n%(a+b))

print(x+y)

Submission status: Accepted

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


resolve()

Submission status: Accepted

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

cnt = n%(a+b)
cont = n//(a+b)
ans = 0

if cnt <= a:
    ans = a*cont + cnt
    print(ans)
else:
    ans = a*(cont+1)
    print(ans)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
temp=int(n/(a+b))*a
if n-int(n/(a+b))*(a+b)>=a:
  result=temp+a
else:
  result=temp+n-int(n/(a+b))*(a+b)
print(result)

Submission status: Accepted

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

C=A+B

M=N%C
K=N//C

if A<M:
    print(K*A+A)
else:
    print(K*A+M)

Submission status: Accepted

Solution code:
N,A,B=map(int, raw_input().split())
sho=N/(A+B)
amari=N%(A+B)
print A*sho+min(A,amari)

Submission status: Accepted

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

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

Submission status: Accepted

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

n_c = N // (A+B)
n = N - n_c*(A+B)

ans = n_c*A + min(n, A)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))

def main():
    n,a,b = readInts()
    print(a * (n // (a+b)) + min(a,n%(a+b)))

if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
q, r = divmod(n, a+b)
if r <= a:
    print(a*q+r)
else:
    print(a*q+a)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()
n,a,b=MI()
ans=(n//(a+b))*a+min(n%(a+b),a)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

d = n // (a + b)
ans = d * a
if (n - d * (a + b) <= a):
    ans += n - d * (a + b)
else:
    ans += a

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

n, a, b = [int(x) for x in input().split()]

t = a + b

ans = 0

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

ans += min(a, n % (a + b))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import exit

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

i = n%(a+b)
j = (n-i)//(a+b)

if i <=a:
    ans = j*a + i
else:
    ans = (j+1)*a

print(ans)

Submission status: Accepted

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

d, m = divmod(N, A + B)
ans = A * d + min(m, A)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

n,a,b = myinput()

x = a + b

ans = (n//x) * a

if n%x <= a:
    ans += n%x
else:
    ans += a

print(ans)

Submission status: Accepted

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


a = N//(A+B)*A
b = N%(A+B)

print(a+min(A,b))

Submission status: Accepted

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

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

ans += min(n%(a+b),a)

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import *

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

mo = n%(a+b)
mu = int(n/(a+b))

if mo > a:
    ma = mo-a
    blue = n-ma-b*mu
elif mo <= a:
    blue = n- b*mu

print(str(blue))

Submission status: Accepted

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

Submission status: Accepted

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

A*(N // (A+B)) + (N%(A+B))

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

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
p, d = divmod(n, a + b)
print(a * p + min(a, d))

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0

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

x = n % (a+b)

if x > a:
    cnt += a
else:
    cnt += x

print(cnt)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, a, b = map(int, input().split())
print(n // (a + b) * a + min(a, n % (a + b)))

Submission status: Accepted

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

if a >= n:
  print(n)
elif a+b >= n:
  print(a)
elif n%(a+b) <= a:
  print((n//(a+b))*a + n%(a+b))
else:
  print((n//(a+b))*a + a)

Submission status: Accepted

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

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

Submission status: Accepted

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

if n%(a+b)>a:
    print((n//(a+b))*a+a)
else:
    print((n//(a+b))*a+(n%(a+b)))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

r=n%(a+b)

if r<=a:
    ans+=r
else:
    ans+=a

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, A, B = lr()
q, r = divmod(N, (A+B))
answer = A * q + min(r, A)
print(answer)

Submission status: Accepted

Solution code:
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, A, B = lr()
time = N // (A+B)
remain = N - (A+B) * time
answer = A * time + min(A, remain)
print(answer)

Submission status: Accepted

Solution code:
#! env/bin/local python3
# -*- coding: utf-8 -*-

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

amount_of_b = (n // total) * a
amount_of_b += a if n % total > a else n % total

print(amount_of_b)

Submission status: Accepted

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

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

Submission status: Accepted

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

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

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


a = N // (A+B)
b = N % (A+B)
if b > A:
    b = A

print(int(a * A + b))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline())

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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

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

print(a*A + min(mod, A))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Thu May  7 01:35:43 2020

@author: shinba
"""

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

a = N // (A+B)

b = min(N % (A+B), A) 

print(a*A+b)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
c = a + b #一つの塊
d = n //c #塊が何個あるか
e = n%c #塊じゃないものが何個残るか
katamariblue = a*d
if e >=a:
    blue = a
else:
    blue = e
print(blue + katamariblue)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A,B=list(map(int,input().split()))
n2=N//(A+B)
n=N%(A+B)
ans=A*n2

if n<A:
    ans+=n 
else:
    ans+=A
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, b, r = map(int, input().split())
d, m = divmod(n, b+r)
print(b * d + min(m, b))

Submission status: Accepted

Solution code:
N ,A ,B = map(int,input().split())
s = A+B
d = N//s
i = d*A
u = N%s #残り
if u < A:
  i = i + u
else:
  i = i + A
print(i)

Submission status: Accepted

Solution code:
# B - Count Balls

N, A, B = map(int, input().split())
i = N // (A + B)
j = min(N % (A + B), A)

print(i * A + j)

Submission status: Accepted

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

Submission status: Accepted

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//(A+B))*A + min(A,N % (A+B)))

Submission status: Accepted

Solution code:
def resolve():
    N, A, B = map(int, input().split())
    division = N // (A + B)
    mod = N % (A + B)
    ans = division * A

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

    print(ans)


resolve()

Submission status: Accepted

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

Submission status: Accepted

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

ab = a + b

repeat = n // ab
modular = n % ab

print(a * repeat + min(modular, a))

Submission status: Accepted

Solution code:
import sys

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

if a == 0:
    print(0)
    sys.exit()

amari = n % (a + b)
ao_count = n // (a + b)

if (amari >= 0) and (amari <= a):
    print(a * ao_count + amari)
else:
    print(a * (ao_count + 1))

Submission status: Accepted

Solution code:
import math

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

ans = 0

ONE_BLOCK_NUM = A + B

if ONE_BLOCK_NUM != 0:
    ans += math.floor(N / ONE_BLOCK_NUM) * A # ひとかたまり丸々ある部分
    res = N % ONE_BLOCK_NUM                  # ひとかたまり丸々は無い、最後の部分
    if res >= A:
        ans += A
    else:
        ans += res

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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: Accepted

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

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
set_ = N // (A+B)
mod = N % (A+B)
b_sum = A * set_
if mod == 0:
  print(b_sum)
elif mod >= A:
  b_sum += A
  print(b_sum)
else:
  b_sum += mod
  print(b_sum)

Submission status: Accepted

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

Submission status: Accepted

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

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

ans = x + min(y, A)
print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    n, a, b = MI()

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


if __name__ == '__main__':
    solve()

Submission status: Accepted

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