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

print(A + N - (A + B))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b = [int(i) for i in input().split()]
answer, amari = divmod(n, a+b)
answer *= a
print(answer + max(a, amari))

Submission status: Wrong Answer

Solution code:
n, a, b = map(int,input().split())
 
x = int(n/(a+b)) #何周目か
y = n%(a+b) 
ans = x * a + y

print(ans)

Submission status: Wrong Answer

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

x = int((a+b)/n) #何周目か
y = (a+b)%n 
ans = x * a + y

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N <= A+B:
    print(N-B)
else:
    while N > A+B:
        num=num+A
        N=N-A-B
        if(N <= A+B and N <= A):
            print(num+N)
        elif(N <= A+B and N >= A):
            print(num+A)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

sum_num = a + b
times = n // sum_num
amari = n % sum_num
if amari >= a:
    print(times * a + amari)
elif amari != 0:
    print(times * a + a)
else :
    print(times * a)

Submission status: Wrong Answer

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

sum_num = a + b
times = n // sum_num
amari = n % sum_num
if amari >= a:
    print(times * a + amari)
else:
    print(times * a + a)

Submission status: Wrong Answer

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

sum_num = a + b
times = n // sum_num
amari = n % sum_num
if amari >= a:
    print(times * a + amari)
else:
    print(times * a )

Submission status: Wrong Answer

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

sum_num = a + b
times = n // sum_num
amari = n % sum_num
if amari > a:
    print(times * a + amari)
else:
    print(times * a )

Submission status: Wrong Answer

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

sum_num = a + b
times = n // sum_num
amari = n % sum_num

print(times * a + amari)

Submission status: Wrong Answer

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

sum_num = a + b
times = n // sum_num
amari = n % sum_num
if amari >= a:
    times = times + 1

print(times * a)

Submission status: Wrong Answer

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

sum_num = a + b
times = n // sum_num
amari = n % sum_num
if amari >= a:
    times + 1

print(times * a)

Submission status: Wrong Answer

Solution code:
L = list(map(int,input().split()))
q = L[0]//(L[1]+L[2])
mod = L[0]%(L[1]+L[2])
if mod > L[1]:
    print(q*L[2]+mod-L[1])
else:
    print(q*L[2])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print((x // (b+r) * b) + min(x % (b+r),r))

Submission status: Wrong Answer

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

x = n[0]
b = n[1]
r = n[2]
answer = 0
switch_blue = True

while x > 0:
    if switch_blue:
       answer += min(x, b)
       x -= answer
    else:
        x -= min(x, r)
    switch_blue = not switch_blue

print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

ans = syou * A 
if amari >= A:
    ans += B
else:
    ans += amari
    
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
x=input().split(" ")
n=int(x[0])
a=int(x[1])
b=int(x[2])
print(a*(n//(a+b))+n%(a+b))

Submission status: Wrong Answer

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

#print(cy)
#print(cynum)
#print(tmpans)

if 0 <= cynum and cynum < A:
    ans = cynum + tmpans
else:
    ans = cynum + A
print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B=[int(s) for s in input().split(" ")]
Ans1=N//(A+B)
Ans2=N%(A+B)
Ans=A*Ans1+Ans2

print(int(Ans))

Submission status: Wrong Answer

Solution code:
N,A,B=[int(s) for s in input().split(" ")]
Ans1=N//(A+B)
Ans2=N%(A+B)
Ans=A*Ans1+Ans2

print(Ans)

Submission status: Wrong Answer

Solution code:
N,A,B=[int(s) for s in input().split(" ")]
Ans1=N//(A+B)
if N%(A+B)!=0:    
    Ans=A*(Ans1)+1
else:
    Ans=A*Ans1

print(Ans)

Submission status: Wrong Answer

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


s = n//(a+b)
t = n% (a+b)

if t>=a:
    print(a*s+a)

if t<=a:
    print(a*s+t)

Submission status: Wrong Answer

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


s = n//(a+b)
t = n% (a+b)

print(a*s +t )

Submission status: Wrong Answer

Solution code:
# place A blue balls first,
# then place B red balls after
# go until you get to N
n, a, b = map(int, input().split())
x = 1
while a * x + b * x < n:
    x += 1
print(a * x)
# if (a * x + b * x) - n > b:
#     pass

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

c=n//(a+b)
d=n%(a+b)
e=c*a
f=c*d

if n<=a:
  print(n)
elif a<n<a+b:
  print(a)
else:
  print(e+f)

Submission status: Wrong Answer

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

c=n//(a+b)
d=n%(a+b)
e=c*a
f=c*d

if n<=a:
  print(n)
if a<n<a+b:
  print(a)
else:
  print(e+f)

Submission status: Wrong Answer

Solution code:

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

if a==0:
  print(0)
else:
  s= n//(a+b)
  sn = n%(a+b)
  if sn > a:
    print (s*a+a)
  else:
    print (s*a+a-sn)

Submission status: Wrong Answer

Solution code:

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

if a==0:
  print(0)
else:
  s= n//(a+b)
  sn = n%(a+b)
  
  print (s*a+sn)

Submission status: Wrong Answer

Solution code:

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

if a==0:
  print(0)
else:
  s= n//(a)
  sn = n%(a)
  
  print (s+sn)

Submission status: Wrong Answer

Solution code:

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

if a == 0:
  print (0)
else:
  print(n-b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

elif a==0:
  print(0)
  
elif n==a+b:
  count+=a
  print(count)

Submission status: Wrong Answer

Solution code:
from sys import stdin

def main():
  N, A, B = map(int,input().split())
  k = N/(A+B)
  val = k*A+ min(A, N-k*(A+B))
  print(int(val))

if __name__ == "__main__":
  main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B = list(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: Wrong Answer

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

c=A+B

b=0

if int(N/c)>0:
  b=(int(N/c)*A)+(N%c)
else:
  if N<A:
    b=N
  else:
    b=A

print(b)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
def LI(): return list(map(int, sys.stdin.readline().split()))
a = LI()
sum = a[0]
b = 0
while sum >= 0:
  if sum - a[1] >= 0:
    b += a[1]
    sum -= a[1]
  else:
    b += sum
    sum = 0
  sum -= a[2]

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

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

rest = n - n // (a + b) * (a + b)

if rest > a:
    result += rest - a

print(result)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

if a == 0:
    print("0")
elif b == 0:
    print(n)
else:
    ans = n // (a+b)
    remainder = n % (a+b)

    if remainder > b:
        print("{}".format(ans*a + a))
    else:
        print("{}".format(ans*a + remainder))

Submission status: Wrong Answer

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

if a == 0:
    print("0")
else:
    ans = n // (a+b)
    remainder = n % (a+b)

    if remainder > b:
        print("{}".format(ans*a + a))
    else:
        print("{}".format(ans*a + remainder))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l = input().split()

[n,a,b] = [int(x) for x in l]

if a==b and a==0:
    print(0)
else:
    x = a+b
    y = n//x

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

Submission status: Wrong Answer

Solution code:
l = input().split()

[n,a,b] = [int(x) for x in l]

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = [list(map(int, s.split())) for s in open(0)] [0]
n, r = a[0] // (a[1] + a[2]), a[0] % (a[1] + a[2])

if a[1] == 0:
    print(0)
else:
    if a[0] <= a[1] + a[2]:
        if a[0] >= a[1]:
            print(a[1])
        else:
            print(a[0])
    else:
        print(n*a[1] + r)

Submission status: Wrong Answer

Solution code:
a = [list(map(int, s.split())) for s in open(0)] [0]
n, r = a[0] // (a[1] + a[2]), a[0] % (a[1] + a[2])
if a[1] == 0:
    print(0)
else:
    print(n*a[1] + r)

Submission status: Wrong Answer

Solution code:
import sys


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

    if a == 0:
        print(0)
        sys.exit(0)
    if b == 0:
        ans = n
        print(ans)
        sys.exit(0)
    div = n // (a+b)
    mod = n % (a+b)
    ans = div * a
    if a >= mod:
        ans += mod
    else:
        ans += b
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Challenge A
"""
import numpy as np
import math as m

    
i = input()
aa = np.array(str.split(i)).astype(int)
#print(aa)
N = aa[0]

char_blue= "b"
char_red = "r"

string_blue= "b"*aa[1]
string_red = "r"*aa[2]
print("16")
"""
string_tot = (string_blue + string_red)*m.ceil(N/(len(string_blue)+len(string_red)))


#print(string_tot)
#print(string_tot[:N])

count_blue = 0

for i in string_tot[:N] :
    if i == 'b':
        count_blue += 1
    
print(count_blue)
"""

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Challenge A
"""
import numpy as np
import math as m

    
i = input()
aa = np.array(str.split(i)).astype(int)
#print(aa)
N = aa[0]
print("16")
"""
char_blue= "b"
char_red = "r"

string_blue= "b"*aa[1]
string_red = "r"*aa[2]
string_tot = (string_blue + string_red)*m.ceil(N/(len(string_blue)+len(string_red)))

#print(string_tot)
#print(string_tot[:N])

count_blue = 0

for i in string_tot[:N] :
    if i == 'b':
        count_blue += 1
    
print(count_blue)
"""

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys

def prob_b(n, a, b):
    x = int(n / (a + b)) * a
    y = n % (a + b)
    print(x+y)


if __name__ == '__main__':
    #args = sys.argv
    #n = args[1]
    #a = args[2]
    #b = args[3]
    n, a, b = map(int, input().split())
    prob_b(n,a,b)

Submission status: Wrong Answer

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

if c < n:
  a += n-c

print(a)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys

def prob_b(n, a, b):
    n, a, b = int(n), int(a), int(b)
    x = int(n / (a + b)) * a
    y = n % (a + b)
    print(x+y)


if __name__ == '__main__':
    #args = sys.argv
    #n = args[1]
    #a = args[2]
    #b = args[3]
    n, a, b = map(int, input().split())
    prob_b(n,a,b)

Submission status: Wrong Answer

Solution code:
# 初期入力
N,A,B = (int(x) for x in input().split(" "))

# 赤と青を並べる
retu = ""
for j in range(10100):
    for i in range(A):
        retu += "b"
    for i in range(B):
        retu += "r"

b_num = retu[:N].count("b")
print(b_num)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys


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

    if a == 0:
        print(0)
        sys.exit(0)
    if b == 0:
        ans = n
        print(ans)
        sys.exit(0)
    div = n // (a+b)
    mod = n % (a+b)
    ans = div * a
    if mod <= b:
        ans += mod
    else:
        ans += b
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys


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

    if a == 0:
        print(0)
        sys.exit(0)
    if b == 0:
        ans = a
        print(ans)
        sys.exit(0)
    div = n // (a+b)
    mod = n % (a+b)
    ans = div * a
    if mod <= b:
        ans += mod
    else:
        ans += b
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys


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

    if a == 0:
        print(0)
        sys.exit(0)
    div = n // (a+b)
    mod = n % (a+b)
    ans = div * a
    if mod <= b:
        ans += mod
    else:
        ans += b
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys


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

    if a == 0 and b == 0:
        print(0)
        sys.exit(0)
    div = n // (a+b)
    mod = n % (a+b)
    ans = div * a
    if mod <= b:
        ans += mod
    else:
        ans += b
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = input().split()
a = list(map(int,a))
(n,m,k)=a
if m==0:
    print(int('0'))
else:
    print(n-k)

Submission status: Wrong Answer

Solution code:
a = input().split()
a = list(map(int,a))
(n,m,k)=a
if m==0:
    print('0')
else:
    print(n-k)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A, B, C = input().split()
A = int(A)
B = int(B)
C = int(C)
if B == 0:
  print(0)
else:
  print(A-C)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# 入力の取得
i = list(map(int, input().split()))
kazoeru = i[0]
ao = i[1]
aka= i[2]
kaisuu = i[0]/(i[1]+i[2])

answer = divmod(kazoeru, (i[1]+i[2]))

if ao == 0:
    print(0)
    exit()

#商の分を計算
aa = ao * answer[0]

#あまりの分を計算
if answer[1] == 0:
    print(aa)
    exit()

#あまり4で、青が6なら
if answer[1] >= kazoeru:
    aa += kazoeru
#あまり3で、青が2なら
else:
    aa += ao
print(aa)

Submission status: Wrong Answer

Solution code:
# 入力の取得
i = list(map(int, input().split()))
kazoeru = i[0]
ao = i[1]
aka= i[2]
kaisuu = i[0]/(i[1]+i[2])

answer = divmod(kazoeru, (i[1]+i[2]))

if ao == 0:
    print(0)
    exit()

#商の分を計算
aa = ao * answer[0]

#あまりの分を計算
if answer[1] == 0:
    print(aa)
    exit()
#あまり4で、青が6なら
if answer[1] > kazoeru:
    aa += answer[1]
#あまり3で、青が2なら
else:
    aa += ao
print(aa)

Submission status: Wrong Answer

Solution code:
# 入力の取得
i = list(map(int, input().split()))
kazoeru = i[0]
ao = i[1]
aka= i[2]
kaisuu = i[0]/(i[1]+i[2])

answer = divmod(kazoeru, (i[1]+i[2]))

if ao == 0:
    print(0)
    exit()

#商の分を計算
aa = ao * answer[0]

#あまりの分を計算
#あまり4で、青が6なら
if answer[1] >= kazoeru:
    aa += answer[1]
#あまり3で、青が2なら
else:
    aa += ao

print(aa)

Submission status: Wrong Answer

Solution code:
# 入力の取得
i = list(map(int, input().split()))
kazoeru = i[0]
ao = i[1]
aka= i[2]
kaisuu = i[0]/(i[1]+i[2])

answer = divmod(kazoeru, (i[1]+i[2]))

if ao == 0:
    print(0)
    exit()

#商の分を計算
aa = ao * answer[0]

#あまりの分を計算
#あまり4で、青が6なら
if answer[1] < kazoeru:
    aa += answer[1]
#あまり3で、青が2なら
else:
    aa += ao

print(aa)

Submission status: Wrong Answer

Solution code:
# 入力の取得
i = list(map(int, input().split()))
kazoeru = i[0]
ao = i[1]
aka= i[2]
kaisuu = i[0]/(i[1]+i[2])

answer = divmod(kazoeru, (i[1]+i[2]))

#商の分を計算
aa = ao * answer[0]
#print(aa)

#あまりの分を計算
#あまり4で、青が6なら
if answer[1] <= kazoeru:
    aa += answer[1]
#あまり3で、青が2なら
else:
    aa += ao

print(aa)

Submission status: Wrong Answer

Solution code:
# 入力の取得
i = list(map(int, input().split()))
kazoeru = i[0]
ao = i[1]
aka= i[2]
kaisuu = i[0]/(i[1]+i[2])

answer = divmod(kazoeru, (i[1]+i[2]))

#商の分を計算
aa = ao * answer[0]
#print(aa)

#あまりの分を計算
#あまり4で、青が6なら
if(answer[1] <= kazoeru):
    aa += answer[1]
#あまり3で、青が2なら
else:
    aa += ao

print(aa)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def cal(N,A,B):
 c=N/(A+B)
 w=N-(A+B)*c
 if w<=A:
  return A*c+w
 else:
  return A*c+A

if __name__=="__main__":
  N,A,B=map(int,input().split())
  print(cal(N,A,B))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
s = s.split(" ")
n = int(s[0])
b = int(s[1])
a = int(s[2])
if n > (a+b)*(10**100):
    print(b*(10**100))
elif b == 0:
    print(0)
elif a == 0:
    print(n)
else:
    num = (n //(a+b))*b +(n%(a+b))%a
    print(num)

Submission status: Wrong Answer

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

if b == 0:
    print(0)
elif a == 0:
    print(n)
else:
    num = (n //(a+b))*b +(n%(a+b))%a
    print(num)

Submission status: Wrong Answer

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

sum1 = n/c
l = n%c
if a>l:
  sum2 = l
else:
  sum2 = a
  
print(sum1+sum2)

Submission status: Wrong Answer

Solution code:
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import fractions
from functools import reduce
from operator import mul
import bisect
import sys
import logging
import heapq
import itertools

logging.basicConfig(level=logging.ERROR)

input = sys.stdin.readline

setrecursionlimit(1000000)


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

main()

Submission status: Wrong Answer

Solution code:
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import fractions
from functools import reduce
from operator import mul
import bisect
import sys
import logging
import heapq
import itertools

logging.basicConfig(level=logging.ERROR)

input = sys.stdin.readline

setrecursionlimit(1000000)


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

main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a=list(input())

IN=[int(x) for x in a if x != " "]
N=IN[0]
A=IN[1]
B=IN[2]

ALL=A+B

cnt=0
num=N
while True:
        num = num - ALL
        if num > 0:
                cnt += 1
        else:
                break

if ALL - num > A:
        ans = A * cnt + A
else:
        ans = A * cnt + ALL - num

print(ans)

Submission status: Wrong Answer

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

c = N//(A + B)

rem = N - c * (A + B)

if rem >= A:
	sum = c * A + rem
else:
	sum =c + rem

print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

div, mod = divmod(n, a+b)
ans = div*a+(mod if mod < b else b)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

count_blue = 0
count_all = 0

while count_all < N:
    count_blue += A
    count_all += A
    if count_all > N:
        count_blue -= (count_all - N)
    count_all += B

Submission status: Wrong Answer

Solution code:
ball = input()
N, A, B = ball.split()
N = int(N)
A = int(A)
B = int(B)
if 1<=N<=(10**18):
    if A >= 0 and B >= 0:
        if 0 < (A+B) <= (10**18):
            if A == 0:
                print(A)
            else:
                print(N-B)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
count = 0
f = 0
 
c = a + b
d = n // c
e = n % c
 
if e >= a:
    f += a
else:
    f += e
count = a * d + f

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
count = 0
f = 0
 
c = a + b
d = n // c
e = n % c
 
if e >= a:
    f += a
 
else:
    f += e
 
count = a * d + f

Submission status: Wrong Answer

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

if n < a :
    print(n)

elif n < a+b :
    print(a)

else:
    while n > 0:
        if n >= a:
            count += a
            n -= a+b

        else:
            count += n
            n -= a+b
            break

print (count)

Submission status: Wrong Answer

Solution code:
n,a,b = input().split()
gokei = 0
b_sum = 0
n = int(n)
a = int(a)
b = int(b)
while gokei < n:
  b_sum += a
  gokei += a
  if gokei > n:
    b_sum = b_sum - (gokei - n)
    break
gokei += b  
print(b_sum)

Submission status: Wrong Answer

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

phrase = A + B

ans = N // phrase * A
ans += N % phrase if N % phrase <= A else 0
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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:
a = list(map(int, input().split()))
N = a[0]
A = a[1]
B = a[2]
count = 0
i = N % (A + B) 
j = N //(A + B)
if i >= A:
  i = A
count = j * A + i

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
N = a[0]
A = a[1]
B = a[2]
count = 0
i = N % (A + B) 
j = N //(A + B)
if i >= A:
  i == A
count = j * A + i
print(count)

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
N = a[0]
A = a[1]
B = a[2]
count = 0
i = N % (A + B) 
j = N //(A + B)
if i >= A:
  i == A
count = j * A + i