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:
# B
n, a, b = map(int, input().split())

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

Submission status: Wrong Answer

Solution code:
import sys
from io import StringIO
import unittest

doTest=0

def yn(n):
    if n==1:
        print("Yes")
    else:
        print("No")
    return

def resolve():
    readline=sys.stdin.readline

    n,a,b=list(map(int, readline().strip().split()))
    #arr=list(map(int, readline().strip().split()))
    #n=int(readline().strip())
    #yn(n)
    ab = a+b
    if n <= ab:
        print(a)
        return
    t = n//ab
    print(t*a + min(n-t*ab, a))

    return

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


if N>=(A+B):
    amari = N%(A+B)
    syou  = N//(A+B)
    sum = 0
    if syou>=1:
        syou = syou * A
        sum = sum + syou
    sum = sum + amari
    print(sum)
else:
    print(A)

Submission status: Wrong Answer

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

if n - cnt >= a:
    ans += a
else:
    ans += n - cnt
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,a,b=mi()

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

    tmp = n%(a+b) 

    if(tmp >0):
        ans += min(tmp,a)

    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N,B,R=map(int,input().split())
process_n = N//(B+R)
amari = N%(B+R)
result = process_n*B
if amari >0 and B >0:
    B -= 1
    amari -= 1
    result += 1
print(result)

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:
N,A,B = map(int,input().split())
x = A+B
y = N-x
ans = 0
ans += A*(N//x)
if y >= A:
  ans += A
else:
  ans += y
print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B = [int(x) for x in input().split()]
n = 0
blue = 0
for i in range(10*100):
    n = n + A
    blue = blue + A
    if n >= N:
        blue = blue - (n-N)
        break
    else:
        n = n + B
        if n >= N:
            break
print(blue)

Submission status: Wrong Answer

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

if A == 0:
    print(0)
else:
    div = N // (A+B)
    rem = N % (A+B)
    print(div*A + rem)

Submission status: Wrong Answer

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

x = []
z = n // (a+b) + 1
for i in range(z):
    for j in range(a):
        x.append(0)
    for j in range(b):
        x.append(1)

print(x.count(1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#R,B

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

#print N,A,B

matmari = A + B

times = N / matmari

#print times , matmari

print (times * A) + (N - matmari * times)

Submission status: Wrong Answer

Solution code:
def main():

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

    # blue = ['b']*A
    # red = ['r']*B
    # l = []
    # while len(l) <= N:
    #     l.extend(blue)
    #     l.extend(red)
    # print(l[:N].count('b'))

    c = 0
    len = 0
    while len <= N-A:
        len += A+B
        c += A
    c += N-len
    print(c)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

ans = 0
d = (int)(N / (A + B))
if d != 0:
    ans += d * A
m = (int)(N % (A + B))
if m != 0:
    if m <= A:
        ans += m

print(ans)

Submission status: Wrong Answer

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

n,a,b = map(int,readline().split())
if a == 0:
    print(0)
ans = n//(a+b)*a
res = n%(a+b)

res = min(a,res)

ans += res
print(ans)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

c = n - 2 - 4
print(a + c)

Submission status: Wrong Answer

Solution code:
import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def S(): return input().rstrip()

def main():
    N, A, B = MI()
    if A != 0:
        print(N-B)
    else:
        print(0)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys
import copy

sys.setrecursionlimit(10**9)
mod = 10**7+9
inf = 10**20


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

if n<a+b:
    l = (a+b)//n
    p = min((a+b)%n,a)

    print((l*a)+p)
else:
    ans = (n//(a+b))*a
    ans += min(n%(a+b),a)
    print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B = [int(i) for i in input().split()]
tmp = A * N//(A+B)
res = N - (A+B) * (N//(A+B))
if res > A:
    print(tmp + A)
else:
    print(tmp + res)

Submission status: Wrong Answer

Solution code:
from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
import bisect
import heapq as hq

def main():
    try:
        n,a,b=In()
        temp=a+b
        n=n//temp
        print(n*a)
    except:
        pass
def add(a, b, c):
    res = a + b;
    if (res >= c):return res - c;
    else:return res;
def mod(a, b, c):
    res = a * b
    if (res >= c):return res % c
    else:return res
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(a, b):
    w = a // gcd(a, b)
    return w * b
def expo(a, b):
    x, y = 1, a
    while (b > 0):
        if (b & 1):
            x = x * y
        y = y * y
        b >>= 1
    return x
def power(a, b, m):
    x, y = 1,
    while (b > 0):
        if (b & 1):x = mod(x, y, m)
        y = mod(y, y, m)
        b >>= 1
    return x
def L():
    return list(map(int, stdin.readline().split()))
def In():
    return map(int, stdin.readline().split())
def I():
    return int(stdin.readline())
P = 1000000007


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,a,b  =map(int,input().split())
br = 0
cnt = 0
if a == 0:
    print(0)
elif b == 0:
    print(n)
else:
    while br < n:
        br += a+b
        cnt +=1
    if br !=n:
        cnt -=1
    res = a*cnt
    n -= (a+b)*cnt
    res += n
    print(res)

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

Submission status: Wrong Answer

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

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

print((q * A) + mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

repeat_num = n // (a+b)
bluenum = repeat_num*a
if a != 0:
  bluenum += (n - (a+b)*repeat_num)
print(bluenum)

Submission status: Wrong Answer

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

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

if (n % (a+b)) <= a:
    res += n % (a+b)

print(int(res))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

while N!=0:
    if N-A<0:
        result += A - N
        N = 0
    else:
        result += A
        N -= A
    if N-B<0:
        N = 0
    else:
        N -= B
print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
n, a, b = i2()
cnt = n//(a+b)
c = n%(a+b)
if c <=b:
    print(a*cnt+c)
else:
    print(a*cnt+c-b)

Submission status: Wrong Answer

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

if n<=a:
    print(n)
    exit()

if n<=a+b:
    print(a)
    exit()

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

if b==0:
    print(n)
    exit()

temp1=n//(a+b)
temp2=n%(a+b)

print(temp1*a+temp2)

Submission status: Wrong Answer

Solution code:

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

sum = a+b
n % sum  

res = (n//sum)*a + n % sum
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

if n >= a:
    print(a)
else:
    print(n)

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n, a, b = map(int, input().split())
r1 = n // (a+b)
r2 = n % (a+b)

print(a * r1 + r2)

Submission status: Wrong Answer

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

if a == 0:
    print(0)

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

print((a*q)+mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

c = a+b

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N, A, B = MAP()
    print(N//(A+B)*A + N%(A+B))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
XAB = input().split(' ')
X = int(XAB[0])
A = int(XAB[1])
B = int(XAB[2])
AB = A+B
res=0
while X >A:
    res += A
    X -= AB
res += X
print(res)

Submission status: Wrong Answer

Solution code:
import sys


def input():
    return sys.stdin.readline()[:-1]


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


all_set, mod_ = divmod(N, (A+B))
ov = mod_ - A
if ov > 0:
	print(all_set*A + ov)
else:
	print(all_set*A + mod_)

Submission status: Wrong Answer

Solution code:
import sys
n,a,b = map(int,input().split())
if a ==0:
	print(0)
	sys.exit()
ab = a*(n//(a+b)) + (n-(a+b))
print(ab)

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(" "))
print(a * int(n / (a+b)) + (n % (a+b) if n % (a+b) <= a else 0))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

n,a,b = map(int,input().split())
if a!=0:
    if n<a+b:
        print(a)
    else:
        print(n-b)
else:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
def main():
    N, A, B = map(int, input().split())
    k = N // (A + B)
    g = N % (A + B)

    ans = (k * A) + g

    if B == 0:
        print(0)
    else:
        print(ans)

    return 0
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def count_ball(n, a, b):
    print(n//(a+b)*a + n%(a+b))

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

count_ball(n, a, b)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if a+b > n:
    print(a)
    exit()

taba = a+b

sho = n//taba
amari = n%taba
if amari >= a:
    amari = a
else:
    amari = amari
ans = sho*a + amari

print(ans)

Submission status: Wrong Answer

Solution code:
cmin = lambda a,b : a if a<b else b
cmax = lambda a,b : a if a>b else b
iin = lambda : int(input())
lin = lambda : list(map(int,input().split()))
rin = lambda n : [int(input()) for _ in range(n)]

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

d,m = divmod(n,a+b)

print(d*a+m if m<b else d*a+m-b)

Submission status: Wrong Answer

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

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

print(r)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


def solve(N: int, A: int, B: int):

    # if A+B < N : N = A+B
    k = N // (A+B)
    rem = N - (A+B)*k
    b_ = A - rem
    if  b_ >= 0: print(k*A+rem)
    else : print(k*A) 


    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,b,r = map(int, input().split())		# 5 7 2

ans = (n//(b+r)) + min(n%(b+r),b)

print(ans)

Submission status: Wrong Answer

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

c=a+b
num=n%c+a
print(num)

Submission status: Wrong Answer

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

def solve(N, A, B):
    if A == 0:
        return 0
    repeats = N // (A + B)
    right = N - (A + B) * repeats
    blues = A * repeats + right % A
    return blues


if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
i = 0
AB = A+B
ans = 0
for x in range(N):
    if i < A:
        ans += 1
    if i == AB:
        i = 0
    i += 1

print(ans)

Submission status: Wrong Answer

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

if b == 0:
    print(0)
elif n-(b+r) == 0:
    print(b)
elif n-(b+r) > 0:
    print(n-(b+r)+b)

Submission status: Wrong Answer

Solution code:
import math

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

print(math.ceil(n * a / (a + b)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

br = b + r

a = n / br
a_ = n % br

print(a * b + (b if a_ >= b else a_))

Submission status: Wrong Answer

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

if a == 0:
  print(0)
else:
  c = a*n//(a+b) + min(n%(a+b),a)
  
  print(c)

Submission status: Wrong Answer

Solution code:
import math

a=list(map(int,input().split()))
N = a[0]
A = a[1]
B = a[2]

ans = math.floor(A*(N/(A+B)))
amari = math.floor(N%(A+B))
if amari <= A:
    ans += amari
else:
    ans += A

print(ans)

Submission status: Wrong Answer

Solution code:
total,blue,red=map(int,input().split())
num = total//(blue+red)
if blue == 0:
    print(0)
else:
    print(num*blue+(total%(blue+red)))

Submission status: Wrong Answer

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

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

x = n // (a + b)

ans = x * a

xx = x * (n - (a + b))

print(ans + xx)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B = map(int, input().split())
sum=0
for i in range(1000):
    sum = sum + B
    if (sum <= N):
        break
print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sum = 0
if a == 0:
  print(0)
else:
  nn = int(n / (a + b))
  na = n // (a + b)
  sum = nn * a + min(na,a) 
  print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N, A, B = read_int()

def solve():
    ans = (N / (A + B)) * A
    r = (N % (A + B))
    ans += r if r < A else A
    return ans

if __name__ == "__main__":
    print(solve())

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] = list(map(int, input().split()))

def main(N, A, B):

    if A == 0:
        return 0
    if A == 0 and B == 0:
        return 0
    
    # main
    sumBlue = A * N // (A + B)

    # amari
    sumBlue += N % (A + B)

    return sumBlue

if __name__ == "__main__":

    answer = main(N, A, B)
    print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
  n, blue, red = input_list()
  d = n % (blue+red)
  if d == 0:
    print(blue * (n // (blue+red)))
  else:
    print(blue * (n // (blue+red))+d)
    
def input_list():
  return map(int, input().split())

def input_list_str():
  return map(str, input().split())

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

import math
import fractions
from functools import reduce
main()

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
def main():
    N, A, B = map(int, input().split())
    ret = 0
    AB = A + B
    times = N // AB
    ret += A

    left = min(N - AB*times, A)
    ret += left
    print(ret)

main()

Submission status: Wrong Answer

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

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

set_count = N // (A+B)
extra = N % (A+B)

print(set_count*A + extra)

Submission status: Wrong Answer

Solution code:

import glob


# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = 'ABC\\158\\B'

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class Solver(Common):

    def resolve(self):

        q = [int(i) for i in self.input_data().split()]
        N = q[0]
        A = q[1]
        B = q[2]

        shou = int(N / (A + B))
        amari = N % (A + B)

        if amari <= A:
            result = shou * A + amari
        else:
            result = shou * (A+1)


        print(str(result))


solver = Solver(REL_PATH)
solver.exec_resolve()

Submission status: Wrong Answer

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

if B==0:
    print(N)

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

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

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split(' '))
L = 0
n = 0
for _ in range(10000):
  if L + A > N:
    print(n + A - (L + A - N))
    break
  else:
    L += (A + B)
    n += A
  if L > N:
    print(n)
    break

Submission status: Wrong Answer

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

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

t = N // (A + B)
if N % (A + B) == 0:
  mod = 0
else:
  mod = A

print(t * A + mod)

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

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, A: int, B: int):
    print(A*(N//(A+B))+N%(A+B))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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