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())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

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

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())

div, mod = divmod(N, (A + B))
res = A * div + min(A, mod)
print(res)

Submission status: Accepted

Solution code:
#

import sys
input=sys.stdin.readline

def main():
    N,A,B=map(int,input().split())
    
    if N<=A:
        print(N)
    else:
        print(A*(N//(A+B))+min(N%(A+B),A))
    
    
if __name__=="__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#https://atcoder.jp/contests/abc158/tasks/abc158_b B - Count Balls

N,A,B = map(int,input().split())
sumab = A + B
quot,mod = divmod(N, sumab)
if A > mod:
    ans = (A * quot) + mod
else:
    ans = (A * quot) + A
    
print(ans)

Submission status: Accepted

Solution code:
from sys import exit
N,A,B = map(int,input().split())
if A == 0:
    print(0)
    exit(0)
else:
    q = N // (A+B)
    r = N %  (A+B)
    
    ans = A * q
    if r >= A:
        ans += A
    else:
        ans += r

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

cnt_blue = 0
total_tmp = 0

try:
    pre_cnt = N // (A+B)
    total_tmp = pre_cnt * (A+B)
    total_tmp += A
    if N <= total_tmp:
        cnt_blue = N -  (pre_cnt * B)
    else:
        cnt_blue = (pre_cnt * A) + A
    print(cnt_blue)
except Exception as e:
    print(0)

Submission status: Accepted

Solution code:
import math
N, A, B = map(int, input().split())
x = math.floor(N/(A+B))
ans = x*A
N = N-(A+B)*x
if N > A:
    ans = ans+A
else:
    ans = ans+N
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import math
def main():
  n, a, b = map(int, input().split())
  total = 0
  
  # if n <= a + b:
  #   print(int(n - b))
  # else:
  x = math.floor(n / (a+b))
  total = a * x
  y = n % (a+b)
  if y >= a:
    total += a
  else:
    total += y
      
      
  print(total)
  
  
main()

Submission status: Accepted

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

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())

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

rest = N % pair

ans += min(A, rest)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
import functools
import math
from collections import Counter
from itertools import combinations

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

ADD=A+B


C=N//ADD
ans = C*A
tmp = C*ADD
if N - tmp >= A:
    print(ans + A)
else:
    print(ans + (N-tmp))

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:
import sys

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

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

set_n = n // (a + b)
amari_n = n % (a + b)

ans = set_n * a + min(amari_n, a)

print(ans)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
mod = n % (a+b)
if mod > a :
  mod = a

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

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 = a + b
if n % c == 0:
    ans = a * (n // c)
elif n % c <= a:
    ans = a * (n // c) + n % c
else:
    ans = a * (n // c +1)

print(ans)

Submission status: Accepted

Solution code:
# B - Count Balls
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())
sho = N //(A+B)
amari = N % (A+B)
if amari > A:
  amari = A
print(sho*A+amari)

Submission status: Accepted

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

Submission status: Accepted

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

ans = n//(a+b)*a
if rest >= a:
  ans += a
elif rest < a:
  ans += rest

print(ans)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
rest = n%(a+b)
n -= rest
ans = n//(a+b)*a
if rest >= a:
  ans += a
elif rest < a:
  ans += rest

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, b, r = map(int, input().split())

t = N//(b+r)
s = N%(b+r)

if s>=b:
    print((t+1)*b)
else:
    print(t*b + s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A,B = (int(a) for a in input().split())
t =  N // (A+B)
print(t*A + min( N-t*(A+B) , A))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

SUM=0
a = N % (A + B)
if a > A:
    SUM = A
else:
    SUM = a 

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

print(SUM)

Submission status: Accepted

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

ans1 = N//C*A
if N%C > A:
    ans2 = A
else:
    ans2 = N%C

print(ans1+ans2)

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:
#inport
import sys
import numpy as np
#import itertools as itlt
#from collections import deque

#input 
N,A,B = [int(x) for x in sys.stdin.readline().split()]

num = int(np.floor(N/(A+B)))*A
if (N%(A+B)) >= A:
    num = num + A
else:
    num = num + N%(A+B)

print(int(num))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A,B = list(map(int,input().split()))
s = N//(A+B) #A+Bの列。青ボールはs*A個
s_1 = min(N % (A+B),A)
print(s*A+s_1)

Submission status: Accepted

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

t = n % (b + r)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

x = n // (a + b)
num += (x * a)

y = n % (a + b)

if y <= a:
    num += y
else:
    num += a

print(num)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

cycle = n//(a+b)
plus = n%(a+b)

ans = a*cycle + min(a, plus)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
ans = n // (a + b) * a
rem = n % (a + b)
ans += min(a, rem)
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())
#aとbの合計値がnを割り切れるだけの個数 X aの個数分
ans = n // (a + b) * a
#aとbの合計値でnが余ってしまった時の個数
rem = n % (a + b)
#aだけ入れれた場合か、bも混ざっている場合か、どちらかをansに追加
ans += min(rem, a)
print(ans)

Submission status: Accepted

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

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

Submission status: Accepted

Solution code:
import numpy as np
def cumsum(x):
    return list(np.cumsum(x))

def cumsum_number(N,K,x):
    ans=[0]*(N-K+1)
    number_cumsum = cumsum(x)
    number_cumsum.insert(0,0)
    for i in range(N-K+1):
        ans[i]=number_cumsum[i+K]-number_cumsum[i]
    return ans
"""
int #整数
float #小数

#for
for name in fruits: #fruitの頭から操作
    print(name)

#リスト
list0 = [] #リスト生成
list0 = [1,2,3,4] #初期化
list0 = [0]*10 #[0,0,0,0,0,0,0,0,0,0]
list1= [i for i in range(10)] #>>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
list1 = list(map(int, input().split()))　# 複数の入力をリストに入れる
number=[int(input()) for i in range(int(input()))] #複数行の入力をリストに
list1 = list1 + [6, 7, 8] #リストの追加
list2.append(34) #リストの追加　最後に（）内が足される
list.insert(3,10) #リストの追加　任意の位置（追加したい位置,追加したい値）
len(list4) #リストの要素数
max(sa) #list saの最小値
list5.count(2) #リスト(文字列も可）内の2の数
list1.sort() #並び替え小さい順
list1.sort(reverse=True)  #並び替え大きい順
set(list1) #list1内の重複している要素を削除し、小さい順に並べる
sum([2,3,   ,3]) #リストの合計

abs(a) #aの絶対値
max(a,b) min(a,b) #最大値　最小値
text1 = text1.replace("34","test") #text1内の"34"を"test"に書き換える(文字列内の文字を入れ替える)

exit(0) #強制終了

cumsum(リスト) #累積和をリストで返す
cumsum_number(N,K,x) #N個の数が含まれるリストx内のK個からなる部分和をリストで返す
"""
N,A,B=map(int,input().split())
S=N//(A+B) #SはA+Bのセット数
M=N-S*(A+B) #Mは残り
if A<=M:
    print(A+S*A)
else:
    print(M+S*A)

Submission status: Accepted

Solution code:
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, A, B = map(int, input().split())
q = N // (A+B)
s = N % (A+B)
print(q*A+min(s,A))

Submission status: Accepted

Solution code:
n,a,b = [int(i) for i in input().split()]
if n!=(a+b): print(a*(n//(a+b))+min(a,n%(a+b)))
else: print(a)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

if t >= A:
    x = A
else:
    x = t

ans = A*s + x

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
count=0
count+=(N//(A+B))*A
M = N%(A+B)
if M >= A:
    count += A
else:
    count += M

print(count)

Submission status: Accepted

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

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,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())
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())

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

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

if A <= b:
  print(a*A + A)
else:
  print(a*A + b)

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

Submission status: Accepted

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

Submission status: Accepted

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

if y<a:
    print(a*x+y)
else:
    print(a*(x+1))

Submission status: Accepted

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

ans = block*a + min(a,rest)
print(ans)

Submission status: Accepted

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

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

ans = a * A + min(b,A)
print(ans)

Submission status: Accepted

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

kiri = n // (a+b);
blue = kiri * a;
amari = n % (a+b);

if amari >= a:
    blue += a
else:
    blue += amari

print(blue);

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
X = N // (A + B)
Y = N % (A + B)

if Y > A:
    blue = X*A + A
else:
    blue = X*A + Y

print(blue)

Submission status: Accepted

Solution code:
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
n, a, b = map(int, input().split())

amari = n%(a+b)
if (amari > a) :
    amari = a

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

print(b+amari)

Submission status: Accepted

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

a = N // (A + B) #青赤のボールの塊の組み合わせが何個できるか
b = N %  (A + B) #そのあまり個数

if b <= A:
    num = a * A + b
else:
    num = a * A + A

print(num)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# coding cell (SUBMIT ONLY THIS CELL)

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

X = N // (A + B) * A
Y = N % (A + B)
if Y <= A:
    Z = Y
else:
    Z = A

print(X + Z)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
s=A+B
r=N//s
b=N%s if N%s < A else A
print(r*A+b)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if a == 0:
    print(ans)
    exit()
elif b == 0:
    print(n)
    exit()

if n <= s and n <= a:
    ans = n
elif n <= s:
    ans = a
else:
    d = n % s
    if d == 0:
        ans += n // s * a
    elif d >= a:
        ans += (n // s * a) + a
    else:
        ans += (n // s * a) + d

print(ans)

Submission status: Accepted

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

num1 = n // (a + b) * a
num2 = n % (a + b)

if num2 >= a:
    print(num1 + a)
else:
    print(num1 + num2)

Submission status: Accepted

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

Submission status: Accepted

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


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

print(a*A+b)

Submission status: Accepted

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

bl1 = N // (A+B)
remain = (N - bl1*(A+B))

if remain >= A:
    remain = A

print(bl1*A+remain)

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
Q=N//(A+B)
R=N%(A+B)

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

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:
## coding: UTF-8
N, A, B = map(int,input().split())

n = N // (A+B)
p = N % (A+B)

if(p>=A):
    ans  = A*n+A
else:
    ans = A*n+p

print(ans)

Submission status: Accepted

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

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

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,b,r=map(int, input().split(" "))
if n % (b+r) > b:
  print(n // (b+r) * b + b)
else:
  print(n // (b+r) * b + n % (b+r))

Submission status: Accepted

Solution code:
N,A,B = (int(x) for x in input().split())
Blue  = A*(N//(A+B))
Red   = B*(N//(A+B))
Rest  = N-(Blue+Red)
if Rest==0:
    print(Blue)
elif 0<Rest<=A:
    print(Blue+Rest)
elif A<Rest<=(A+B):
    print(Blue+A)

Submission status: Accepted

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

Submission status: Accepted

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

count_a = N//(A+B)*A
div = N%(A+B)

if div <= A:
    print(count_a + div)
else:
    print(count_a + A)

Submission status: Accepted

Solution code:
#B
N,A,B = map(int,input().split())
AB = N//(A+B)
rest = N - (A+B)*AB

if rest > A:
    rest = A
print(AB*A+rest)

Submission status: Accepted

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

total += N//(A+B)

blue = total * A

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

Submission status: Accepted

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

ans = 0
d = n // (a+b)

ans += a * d

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

if add-a>0:
    ans+=a
else:
    ans+=add
print(ans)

Submission status: Accepted

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

x = math.floor(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())
if a == 0:
    print(0)
elif n >= 10**100:
    print(a*(10**100))
else:
    print((n//(a+b))*a + (n%(a+b) if n%(a+b) <= a else a))

Submission status: Accepted

Solution code:
#

import sys
input=sys.stdin.readline

def main():
    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)
    
    
    
if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
full=N//(A+B)
rest=N%(A+B)
if rest <=A:
    print(full*A+rest)
    exit()
else:
    print(full*A+A)
    exit()

Submission status: Accepted

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

v = N//(A+B)
z = N %(A+B)

if z < A:
    print(A*v + z)
else:
    print(A*v + A)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, b, r = map(int, input().split())
a = 0
a += n//(r+b) * b
if n - n//(r+b) * (r+b)> b:
    a += b
else:
    a += n - n//(r+b) * (r+b)
print(a)

Submission status: Accepted

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

Submission status: Accepted

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

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 + y)
else:
    print(x + A)

Submission status: Accepted

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

k = a * (n // (a+b))
l = min(n % (a + b),a)

print(k + l)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
waru=n//(a+b)
amari=n%(a+b)
if a==0:
    print(0)
elif amari<a:
    print(waru*a+amari)
else:
    print(waru*a+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:
def solve():
    N, A, B = map(int, input().split())
    print((N//(A+B))*A + min(N%(A+B),A))

if __name__ == '__main__':
    solve()

Submission status: Accepted

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

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())

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

Submission status: Accepted

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

ans=0

times=N//(A+B)
rest=N%(A+B)

ans=times*A
if rest>A:
  a=A
else:
  a=rest

print(ans+a)

Submission status: Accepted

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

nu = n // (a + b)

print(min(nu * a + n % (a + b), (nu + 1) * a))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
if a==0:
  print("0")
  exit()
tmp1 = n // (a+b)
tmp2 = n-(tmp1*(a+b))
if tmp2 >= a:
  print((tmp1*a)+a)
else:
  print((tmp1*a)+tmp2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
p = A*(N//(A+B))
q = N%(A+B)
print(p+q if q<A else p+A)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

    print(ans)

    return


resolve()

Submission status: Accepted

Solution code:
N,A,B = map(int, input().split())
syou=int(N/(A+B))
amari=N%(A+B)
#print(syou,amari)
if amari<=A:
    print(A*syou+amari)
else:
    print(A*syou+A)

Submission status: Accepted

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

num = 0

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

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

print(num)

Submission status: Accepted

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

Submission status: Accepted

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

b_count = n // (a+b) 
if (n-(a+b)*b_count) <= a:
    print(n-b*b_count)
else:
    print(a*b_count + a)

Submission status: Accepted

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

Submission status: Accepted

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

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

ans += min(n, b)

print(ans)

Submission status: Accepted

Solution code:
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

n,a,b = imap()
div,mod = divmod(n, a+b)
ans = div*a + min(mod, a)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

if amari>A:
    amari=A


print(A*count+amari)

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())
c=N//(A+B)
d=N%(A+B)
if d<A:
  k=d
elif d>=A:
  k=A
print(c*A+k)

Submission status: Accepted

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

    ans = (n // (a + b)) * a
    r = n % (a + b)
    ans += r if r < a else a
    print(ans)


if 'unittest' not in globals():
    resolve()

Submission status: Accepted

Solution code:
def actual(n, a, b):
    n_op_least = n // (a + b)

    n_blue_least = a * n_op_least
    adjustment = min(n % (a + b), a)

    return n_blue_least + adjustment

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
p,q=divmod(n,(a+b))
print(p*a + [a,q][q<a])

Submission status: Accepted

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

num_sets = N // (A + B)
rem = N % (A + B)

print(num_sets * A + min(rem, A))

Submission status: Accepted

Solution code:
import sys

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


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

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


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

times, remain = N // (A+B), N % (A+B)
res = times * A + min(remain, A)
print(res)

Submission status: Accepted

Solution code:
def solve():
    N,A,B = map(int, input().split())
    x,y = divmod(N, A+B)
    if y>A:
        y = A
    print(A*x + y)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[14]:


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


# In[15]:


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


# In[ ]:

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)