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: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
K=A*int(N/(A+B))
amari=N%(A+B)
i=1
while ((amari-i)>0):
  i=i+1
K=K+i
print(K)

Submission status: Wrong Answer

Solution code:
n,nb,nr = list(map(int,input().split()))
if n >=nb:
    if nb ==0:
        print(0)
    else:
        print(n-nb-nr+nb)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if n < a + b:
    print(max(n - a, 0))
else:
    m = n % (a + b)
    d = n // (a + b)
    print(d * b + max(m - a, 0))

Submission status: Wrong Answer

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

value = N // (A + B)
value *= A
left = N % (A + B)
value += left

print(value)

Submission status: Wrong Answer

Solution code:
quant, azul, verm= input().split()
quant, azul, verm= int(quant), int(azul), int(verm)
eq= azul + (quant - (azul + verm))
if azul==0:
	eq= 0
print(eq)

Submission status: Wrong Answer

Solution code:
import sys
n,a,b=(int(x) for x in input().split())
j=0

c=a+b

q, mod=divmod(n,c)

A=q*a+mod

if(a==0):
 A=0

print(A)

Submission status: Wrong Answer

Solution code:
import sys
n,a,b=(int(x) for x in input().split())
j=0

c=a+b

q, mod=divmod(n,c)

A=q*a+mod

print(A)

Submission status: Wrong Answer

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

if N > A:
    print(A)
else:
    print(N)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import os, sys
import numpy as np

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

rep = np.floor(N / (A+B))
rest = N - (A + B) * rep

# diff = A if rest >= A else rest  
ans = A * (rep) + min(rest, A)

print(int(ans))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import os, sys
import numpy as np

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

rep = np.floor(N / (A+B))
rest = N - (A + B) * rep

# diff = A if rest >= A else rest  
ans = A * (rep + 1) if rest > A else A * (rep) + rest

print(int(ans))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import os, sys
import numpy as np

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

rep = np.floor(N / (A+B))
rest = N - (A + B) * rep

# diff = A if rest >= A else rest  
ans = A * (rep + 1) if rest >= A else A * (rep) + rest

print(int(ans))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import os, sys
import numpy as np

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

rep = np.floor(N / (A+B))
rest = N - (A + B) * rep

diff = A if rest >= A else rest  
ans = A * rep + diff

print(int(ans))

Submission status: Wrong Answer

Solution code:
import math
N,A,B = input().split()
C = math.ceil(int(N) * (int(A)/(int(A) + int(B))))
print(C)

Submission status: Wrong Answer

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

count = n // (a + b)
mod = n % (a + b)

res = count * b
if mod > a:
  res += (mod - a)
  
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

z = n // t
if a == 0:
  x = 0
else:
  x = n % t

print(z*a + x)

Submission status: Wrong Answer

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

z = n // t
x = n % t

print(z*a + x)

Submission status: Wrong Answer

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

while True:
  if n > a + b:
    ans += a
    n -= a + b
  elif n == a + b:
    ans += a
    break
  else:
    ans += n
    break

print(ans)

Submission status: Wrong Answer

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

while True:
  if n > a + b:
    ans += a
    n -= a + b
  else:
    ans += n
    break

print(ans)

Submission status: Wrong Answer

Solution code:
Nf,Af,Bf = (input().split(' '))
N = int(Nf)
A = int(Af)
B = int(Bf)
a = N % (A + B)
b = N // (A + B)

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

Submission status: Wrong Answer

Solution code:
Nf,Af,Bf = (input().split(' '))
N = int(Nf)
A = int(Af)
B = int(Bf)
a = N % (A + B)
b = N // (A + B)

if a > A:
  print(B*b+a)
else:
  print(B*b)

Submission status: Wrong Answer

Solution code:
inp = input().split()
inp = [int(i) for i in inp]
N, A, B = inp
print((N//(A+B))*A + N%(A+B))

Submission status: Wrong Answer

Solution code:
inp = input().split()
inp = [int(i) for i in inp]
N, A, B = inp
print(((N//(A+B)*A + N%(A+B))))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

blue_num = 0
if amari <= B:
    blue_num += A * sho + amari
else:
    blue_num += A * sho + B
    
print(blue_num)

Submission status: Wrong Answer

Solution code:
# p = input()
n,a,b = map(int,raw_input().split())
if a ==0 and b==0 :
    print 0
elif (a+b)>=n:
    if n >a:
        print abs(n-a)
    else:
        print n
else:
    print n%(a+b)+a * (n/(a+b))

Submission status: Wrong Answer

Solution code:
# p = input()
n,a,b = map(int,raw_input().split())
if a ==0 and b==0 :
    print 0
elif a+b>n:
    print a
else:
    print n%(a+b)+a * (n/(a+b))

Submission status: Wrong Answer

Solution code:
# p = input()
n,a,b = map(int,raw_input().split())
if a ==0 and b==0 :
    print 0
else:
    print n%(a+b)+a * (n/(a+b))

Submission status: Wrong Answer

Solution code:
# p = input()
n,a,b = map(int,raw_input().split())
print n%(a+b)+a

Submission status: Wrong Answer

Solution code:
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')


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

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

print(k*a+m)

Submission status: Wrong Answer

Solution code:
n,a,b=input().split()
n=int(n)
a=int(a)
b=int(b)
rcount=0
bcount=0
count=0
for i in range(n):
  if rcount<a:
    rcount+=1
  if rcount==a:
    bcount+=1
    count+=1
    if bcount==b:
      rcount=0
      bcount=0

print(count)

Submission status: Wrong Answer

Solution code:
# A = [list(map(int, input().split())) for _ in range(3)]
# n = int(input())
# B = [int(input()) for _ in range(n)]
# X = list(map(int, input().split()))
n, b, r = map(int, input().split())
total = b+r
circle = total//n
diff = n % total
if b < diff:
    print(diff + circle*b)
else:
    print(b + circle*b)

Submission status: Wrong Answer

Solution code:
n,b,r=map(int,input().split())
alist=[]
count=0

while len(alist)>n:
  for i in range(b):
    alist.append('b')
  for i in range(r):
    alist.append('r')

del alist[n:]

for i in alist:
  if i=='b':
    count+=1

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
x, b, r = map(int, input().split())
count=0
flag_b=0
flag_r=0
while True:
  if count<=x:
    count+=b
    flag_b+=1
  else:
    break
    
  if count<=x:
    count+=r 
    flag_r+=1
  else:
    break
  
  
print(x-(flag_r*r))

Submission status: Wrong Answer

Solution code:
n,blue,red = map(int,input().split())

mod = n % (blue+red)
if mod <= blue:
    print(mod)
    print(blue*(n//(blue+red))+mod)
else:
    print(mod)
    print(blue*(n//(blue+red))+blue)

Submission status: Wrong Answer

Solution code:
n,blue,red = map(int,input().split())

mod = n % (blue+red)
if mod <= blue:
    print(mod)
    print((blue*n)//(blue+red)+mod)
else:
    print(mod)
    print((blue*n)//(blue+red)+blue)

Submission status: Wrong Answer

Solution code:
n,blue,red = map(int,input().split())

mod = n % (blue+red)
if mod <= blue:
    print((blue*n)//(blue+red)+mod)
else:
    print((blue+n)//(blue+red)+blue)

Submission status: Wrong Answer

Solution code:
import math

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

QUO = math.floor(N / (A + B))

if N - (A + B) < A:
  print(QUO * A + N - (A + B))
  
else:
  print(QUO * A + A)

Submission status: Wrong Answer

Solution code:
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, A, B = list(map(int, sys.stdin.buffer.readline().split()))
    n = N//(A+B)
    m = N%(A+B)
    print(A*n + A + B - m if m > A else A*n + m)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, blue, red = map(int,input().split())
sum = blue + red
    
count = round(n / sum)
nokori = n % sum
if blue == 0:
    print(0)
    exit()
if nokori > blue:
    print(int((count+1) * blue))
else:
    print(int(count * blue + nokori))

Submission status: Wrong Answer

Solution code:
n, blue, red = map(int,input().split())
sum = blue + red
count = round(n / sum)
nokori = n % sum
if blue == 0:
    print(0)
    exit()
if nokori > blue:
    print(int((count+1) * blue))
else:
    print(int(count * blue + nokori))

Submission status: Wrong Answer

Solution code:
n, blue, red = map(int,input().split())
sum = blue + red
count = round(n / sum)
nokori = n % sum
if blue == 0:
    print(0)
    exit()
if nokori > blue:
    print(10)
    print(int((count+1) * blue))
else:
    print(int(count * blue + nokori))

Submission status: Wrong Answer

Solution code:
n, blue, red = map(int,input().split())
sum = blue + red
if blue == 0:
    print(0)
    exit()
if sum > n:
    plus = n - sum
    print(blue + plus)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#https://atcoder.jp/contests/abc158/tasks/abc158_b
# -*- coding: utf-8 -*-
N,A,B = map(int,input().split())
syou = N//(A+B)
amari = N%(A+B)
if amari>A:
  amari=amari
ans = syou*A+amari
print(ans)

Submission status: Wrong Answer

Solution code:
text = list(map(int, input().split()))

reply = 0
color_blue = True
color_num = 0
for i in range(text[0]):
    if color_blue == True:
        if color_num < text[1]:
            color_num += 1
            reply += 1
        else:
            color_blue = False
            color_num = 0
    else:
        if color_num < text[2]:
            color_num += 1
        else:
            color_blue = True
            color_num = 0

print(reply)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
input_line = input().split()

N = int(input_line[0])
A = int(input_line[1])
B = int(input_line[2])
if A+B > N:
    print(A)
else:
    baisu =math.floor(N / (A+B))
    tmp = int(N - baisu * B)
    print(tmp)

Submission status: Wrong Answer

Solution code:
import math
input_line = input().split()

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

baisu =math.floor(N / (A+B))
tmp = int(N - baisu * B)
print(tmp)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b=list(map(int,input().split()))
if n<=a:print(n)
elif n<=b or a==0:print(a)
else:print(a+(n-a-b))

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
c = 0
d = a+b
if a==0 and b==0:
    print(0)
elif a==0:
    print(0)
elif b==0:
    print(a)
else:   
    q, mod = divmod(n, d)      
    print(q*a + mod)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
c = 0
d = a+b
if a==0:
    print(0)
else:   
    q, mod = divmod(n, d)      
    print(q*a + mod)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
c = 0
d = a+b
if a==0 or b==0:
    if a==0:
        print(0)
    elif b==0:
        print(n)
else:   
    q, mod = divmod(n, d)      
    print(q*a + mod)

Submission status: Wrong Answer

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

sum=0

if A==0:
    print(0)
else:
    a=N//(A+B)
    b=N%(A+B)

    # print(a)
    # print(b)

    sum=A*a+b

    print(sum)

Submission status: Wrong Answer

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

tmp = 0
suc = 0
num = 0

for i in range(1000):
    tmp += A
    if tmp > N:
        num = i + 1
        break
    else:
        suc = "B"
    tmp += B
    if tmp > N:
        num = i + 1
        break
    else:
        suc = "R"

if suc == "R":
    print(num * A + (N - (A + B) * num))
if suc == "B":
    print(num * A)

Submission status: Wrong Answer

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

tmp = 0
suc = 0
num = 0

for i in range(1000):
    tmp += A
    if tmp > N:
        num = i + 1
        break
    else:
        suc = "B"
    tmp += B
    if tmp > N:
        num = i + 1
        break
    else:
        suc = "R"

print(suc,num)

if suc == "R":
    print(num * A + (N - (A + B) * num))
if suc == "B":
    print(num * A)

Submission status: Wrong Answer

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

tmp = 0
suc = 0
num = 0

for i in range(1000):
    tmp += A
    if tmp > N:
        num = i
        break
    else:
        suc = "B"
    tmp += B
    if tmp > N:
        num = i
        break
    else:
        suc = "R"


if suc == "R":
    print(num * A + (N - (A + B) * num))
if suc == "B":
    print(num * A)

Submission status: Wrong Answer

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

tmp = 0
suc = 0
num = 0

for i in range(1000):
    tmp += A
    if tmp > N:
        num = i
        break
    else:
        suc = "B"
    tmp += B
    if tmp > N:
        num = i
        break
    else:
        suc = "R"


if suc == "R":
    print(num * A + (N - (A + B)))
if suc == "B":
    print(num * A)

Submission status: Wrong Answer

Solution code:
args = input()
nums = args.split(' ')
if int(nums[0]) < int(nums[1]):
  print(nums[0])
  exit()
print(nums[1])

Submission status: Wrong Answer

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

cnt = n // (b + r)

ans = b * cnt

n -= cnt * (b + r)

print(ans + n)

Submission status: Wrong Answer

Solution code:
N=[int(e) for e in input().split()]
if N[1]==0:
    A=0
else:
    M=N[0]//(N[1]+N[2])
    if M==0:
        if N[0]>=N[1]:
            A=N[1]
        else:
            A=N[0]
    else:
        A=M*N[1]+N[0]%(N[1]+N[2])
print(A)

Submission status: Wrong Answer

Solution code:
N=[int(e) for e in input().split()]
if N[1]==0:
    A=0
else:
    M=N[0]//(N[1]+N[2])
    if M==0:
        if N[0]>N[1]:
            A=N[1]
        else:
            A=N[0]
    else:
        A=M*N[1]+N[0]%(N[1]+N[2])
print(A)

Submission status: Wrong Answer

Solution code:
N=[int(e) for e in input().split()]
if N[1]==0:
    A=0
else:
    M=N[0]//(N[1]+N[2])
    if M==0:
        if N[0]>N[1]:
            A=N[1]
        else:
            A=N[0]
    else:
        A=M+N[0]%(N[1]+N[2])
print(A)

Submission status: Wrong Answer

Solution code:
N=[int(e) for e in input().split()]
M=((N[0]//(N[1]+N[2]))*N[1]) + (N[0]%((N[1]+N[2])))
if N[1]==0:
    M=0
print(M)

Submission status: Wrong Answer

Solution code:
N=[int(e) for e in input().split()]
M=((N[0]//(N[1]+N[2]))*N[1]) + (N[0]%((N[1]+N[2])))
print(M)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
C=A+B
D=N//C
count=D*A
N=N-C*D
while N>0:
    N=N-A
    if N-A>0:
        count=count+A
    elif N-A<=0:
        count=count+(A+N)
        break
    N=N-B
    if N-B<=0:
        break
    else:
        pass
print(count)

Submission status: Wrong Answer

Solution code:
import math
list = input().rstrip().split(" ")
n = int(list[0])
a = int(list[1])
b = int(list[2])
n_num = n / (a + b) #N個の中にAB周期がいくつあるか
n_number = int(math.floor(n_num))
b_num1 = math.floor(n_num) * b #周期内のBの個数
n_amari = n % (a + b) #周期から外れたボールの数
b_num2 = n_amari - a #周期外のBの個数
if b_num2 >= 0:
  b_total = b_num1 + b_num2
else:
  b_total = b_num1
print(b_total)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# 標準入力 <int><int>
N, A, B = map(int, input().split())

ans = 0

if A == 0:
    ans = 0
elif B == 0:
    ans = N
else:
    for n in range(N):
        if n + 1 > N:
            break

        if ((n + 1) % (A + B)) <= A and ((n + 1) % (A + B)) != 0:
            print(n+1, A+B, A)
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
a,b,c=input().strip().split(" ")
a,b,c=[int(a),int(b),int(c)]
p=b+c
x=a//p
m=a%p
pp=min(b,m)
print(pp+x*a)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# 標準入力 <int><int>
N, A, B = map(int, input().split())

ans = 0

if A == 0:
    ans = 0
elif B == 0:
    ans = N
else:
    for n in range(10 ** 100):
        if n + 1 > N:
            break

        if ((n + 1) % (A + B)) <= A and ((n + 1) % (A + B)) != 0:
            print(n+1, A+B, A)
            ans += 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

f = n // (a+b)
g = n % (a+b)

if g <= a:
    print(f * a + g)
    
else:
    print(f * (a+1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if A == 0:
	print(0)
else:
	print(A * N // (A + B) + min(N % (A + B), A))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if a>=n:
  print(n)
else:
  print(a)

Submission status: Wrong Answer

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

q, mod = divmod(N, A+B)
print(q, mod)

if A < mod:
	mod_A = A
else:
	mod_A = mod

print(A * q + mod_A)

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline
n, a, b = [int(x) for x in readline().strip().split(" ")]
ans = n // (a + b) * a
if a:
    print(ans + n % (a + b))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline
n, a, b = [int(x) for x in readline().strip().split(" ")]

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

Submission status: Wrong Answer

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


SET = a+b
SET_NUM = n//SET
remain_spot = n%SET
if a == 0:
	print(0)
else:
	print(a*SET_NUM+remain_spot)

Submission status: Wrong Answer

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


SET = a+b
SET_NUM = n//SET
remain_spot = n%SET
print(a*SET_NUM+remain_spot)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
stop,blue,red = map(int,input().split())

set = blue+red
if blue == 0:
  end = 0
else:
  end = blue*int(stop/set)+stop%set
print(end)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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
        print(Count_Blue)
    else:
        Count_Blue = (q * Add_Blue) + Add_Blue
    print(Count_Blue)
elif A == 0:
    print(Count_Blue)

Submission status: Wrong Answer

Solution code:
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 < 1 * A:
        Count_Blue = (q *(Add_Blue)) + mod
    else:
        Count_Blue = (q +(Add_Blue)) + Add_Blue
    print(Count_Blue)
elif A == 0:
    print(Count_Blue)

Submission status: Wrong Answer

Solution code:
import sys

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

Result = 0
Count_Blue = 0
if 1<=N<=10**18 and A >= 0 and B >= 0 and \
   0< A + B <= 10**18:
    LoopCount = 10**100
    for Count in range(LoopCount):
        Result = Result + (1 * A)
        Count_Blue += (1 * A)
        Result = Result + (1 * B)
        if Result > N:
            Count_Blue = Count_Blue - (Result -(1 * B)- N)
            print(Count_Blue)
            sys.exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c=(int(x) for x in input().split())
bc = b + c
if a >= bc:
  print(b)
else:
  d = a / bc
  e = a % bc
  f = d * b
  if e > b:
    f = f + b
  else:
    f = f + e
  print(f)

Submission status: Wrong Answer

Solution code:
a,b,c=(int(x) for x in input().split())
if b == 0:
  print(0)
else:
  bc = b + c
  d = a / bc
  e = a % bc
  f = d * b
  if e > b:
    f = f + b
  else:
    f = f + e
  print(f)

Submission status: Wrong Answer

Solution code:
a,b,c=(int(x) for x in input().split())
bc = b + c
d = a / bc
e = a % bc
f = d * b
if e > b:
  f = f + b
else:
  f = f + e
print(f)

Submission status: Wrong Answer

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

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

print(int(loop*b + extra))

Submission status: Wrong Answer

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

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

print(loop*b + extra)

Submission status: Wrong Answer

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

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

print(loop*b + extra)

Submission status: Wrong Answer

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

loop = n/(b+r)
mod = n%(b+r)
extra = b

if mod < b:
  extra = mod

print(loop*b + extra)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
result = 0
while True:
    if n  >= (a + b):
        result += a
        n -= a+b
    elif 0 <= n <= a:
        result += n
        break
    else:
        break

        
print(result)

Submission status: Wrong Answer

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

if a + b == n:
    print(a)
elif a == 0:
    print(0)
elif a + b < n:
    print(a + (n-(a+b)))

Submission status: Wrong Answer

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

if a + b == n or a > n:
    print(a)
elif a == 0:
    print(0)
elif a + b < n:
    print(n-b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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)
    print(q * Blue + mod)

Submission status: Wrong Answer

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

print(times * a + (n - times * (a + b)))

Submission status: Wrong Answer

Solution code:
#スペース区切りの整数の入力
N, A, B = map(int, input().split())

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

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

Submission status: Wrong Answer

Solution code:
#スペース区切りの整数の入力
N, A, B = map(int, input().split())

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

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

Submission status: Wrong Answer

Solution code:
#スペース区切りの整数の入力
N, A, B = map(int, input().split())

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

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

Submission status: Wrong Answer

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

ans1 = a // (b + c)
ans2 = min(ans1, b)

if a % (b + c) == 0:
    print(ans1)
else:
    print(ans1 + ans2)

Submission status: Wrong Answer

Solution code:
array = input().split()
n = int(array[0])
a = int(array[1])
b = int(array[2])

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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