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:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B = MAP()
if A > 0:
    print(A + N % (A + B))
else:
    print(0)

Submission status: Wrong Answer

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

C = N // (A+B)
print(N-B*C)

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())
cnt = 0
ans = 0
if n//(a+b) <= 10**100:
    ans += a * n//(a+b)
    cnt += (n//(a+b))*(a+b)
else:
    ans += a * (10**100//(a+b))
    cnt += (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())
if a==0:
    print(0)
else:
    print(a+(n-(b+a)))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#B

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

#処理
C=A+B

x=N//C
y=N%C
z=0

z+=x*A
if N-x<y:
    z+=A
else:
    z+=y

print(z)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():
    N, A, B = map( int, input().split())
    n = N//(A+B)
    ans = n*A
    N -= n*(A+B)
    if n < A:
        ans += N
    else:
        ans += A
    print(ans )
if __name__ == '__main__':
    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())
ans = (n//(a+b))*a
ans += min((n-n%(a+b)),a)
print(ans)

Submission status: Wrong Answer

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

# print('-----output-----')
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 + b:
  print(n // (a + b) * a + n % (a + b))
else:
  print(min(n, a))

Submission status: Wrong Answer

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

t = a+b
q = n%t
p = (n-q)//t

print(min(p+q,p+a))

Submission status: Wrong Answer

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

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

AB = A + B

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

ans = A * N // AB
ans_mod = N % AB 

if ans_mod == 0:
    print(ans)
    sys.exit()

if ans_mod > A:
    ans += A
else:
    ans += ans_mod

print(ans)

Submission status: Wrong Answer

Solution code:

import collections


class Solution:
    def solve(self, N, A, B):
        return A * (N//(A+B)) + (N % (A+B))


sol = Solution()

[N, A, B] = list(map(int, input().strip().split()))
print(sol.solve(N, A, B))

Submission status: Wrong Answer

Solution code:
[N,A,B] = list(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())
ans = 0

if A == 0:
    ans = 0
elif N <= A:
    ans = A
else:
    total = A + B
    i = N // total
    mod = N % total
    ans = A * i + mod

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#coding:utf-8

import queue

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = b * (n // (b+r))
ans += (n - ((b+r) * ( n // (b+r))))
print(ans if b != 0 else 0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce
sys.setrecursionlimit(4100000)
from functools import lru_cache
INF = 1 << 60

#ここから書き始める
n, a, b = map(int, input().split())
ans = (n // (a + b)) * a
# print(ans)
if ans % n != 0:
    ans += min(n % (a + b), a)
print(ans)

Submission status: Wrong Answer

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

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(" "))
c=A+B
print(int(N/c)*A+N%c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

ans = 0
ans += x*A
ans += max(0, N-y, A)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

n, a, b = np.asarray(input().split(), dtype=np.uint64)

times = n // (a+b)

last = n % (a+b)

if last <= a:
    answer = times * a + last
else:
    answer = a * (times + 1)

print(answer)

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=[int(i) for i in input().split()]

#１セットで増える数
c=a+b


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

t1 = n // (a+b)
t2 = n % (a+b)
ans = t1 * a + t2

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

Submission status: Wrong Answer

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

x = (a+b)//n + ((a+b)%n != 0)
rem = n - (a+b)*x
ans = a * x + min(a, rem)
print(ans)

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) <= 3:
    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())
cnt = n // (a+b)
print(a * cnt + max(0, n - (a+b)*cnt))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if n%(a+b) >a:
    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())
ans = 0
i = 0
while(N>0):
    if i%2==0:
        N-=A
        ans+=A
        if N<0:
            break
    else:
        N-=B
    i += 1
print(ans+N)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
C=A+B
D=N//C #何セットあるか
E=C*D

if N-E>=A:
  ans= D*A
else:
  ans= D*A+ (N-E)
  
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

ans = b * (n // (b+r))
ans += n - (b+r) * ( n // (b+r))
print(ans if b != 0 else 0)

Submission status: Wrong Answer

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

c = a + b

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
n,a,b = map(int,input().split())
if a == 0:
    print(0)
    sys.exit()
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())

count = 0
t1 = (N * A) // (A + B)
t2 = N % (A + B)

count += t1
count += min(t2, A)

print(count)

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,B,A = map(int, input().split())
print(N-A)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

print(n*b + mod)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, open(0).read().split())
q, r = divmod(n, a+b)
print(q*a + r)

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

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

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

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 A == 0:
    print(0)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
N, A, B = map(int, input().split())


s = A + B

a = N // s

ans = A*a
nokori = N-s*a

if nokori>A:pass
else:ans += nokori

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
nums=input().split(" ")
N,B,R=[int(nums[i]) for i in range(len(nums))]
if N>=B:
  print(B)
else:
  print(N)

Submission status: Wrong Answer

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

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

print(cnt)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

ans = 0
ans += (N // (a+b)) * a

ans += (N % (a+b))

print(ans)

Submission status: Wrong Answer

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

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

print(temp1*a+temp2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if A>=N:
    print(N)
else:
    s, a = divmod(N, A+B)
    print(s*A+a)

Submission status: Wrong Answer

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

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

if __name__ == '__main__':
    main()

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






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

Submission status: Wrong Answer

Solution code:
import sys


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


def main():
    N, A, B = map(int, input().split())
    r = N // (A + B)
    l = N - r * (A + B)
    cnt = r * A
    if l <= N:
        cnt += l
    else:
        cnt += N
    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

#############
# Libraries #
#############

import math
from functools import lru_cache

#############
# Constants #
#############

MOD = 10**9 +7
INF = float('inf')

#############
# Functions #
#############

kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#############
# Main Code #
#############

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


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

if amari<A:
  last = amari
else:
  last = A



print(int(sho*A+last))

Submission status: Wrong Answer

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

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=int(N/(A+B))
    x=N%(A+B)
    print(b*A+x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

S = A+B

P = N//S

Ans = P*A + (N-S*P)

print(Ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

print(t * A + mod)

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:
from sys import stdin
N,A,B = [int(x) for x in stdin.readline().rstrip().split()]

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

Submission status: Wrong Answer

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

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

ans = 0
ans += x*A
ans += max(0, N-y)
print(ans)

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()
    print(A)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
"""
// Author : snape_here - Susanta Mukherjee
     
"""
 
from __future__ import division, print_function
 
import os,sys
from io import BytesIO, IOBase
 
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
 
 
def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().split())
def li(): return list(mi())
 
 
def gcd(x, y):
    while y:
        x, y = y, x % y
    return x
    
 
def read():
    sys.stdin = open('input.txt', 'r')  
    sys.stdout = open('output.txt', 'w') 
 
 
import math

mod=1000000007 

def main():

    n,a,b=mi()
    s=a+b
    if a==0:
        print(a)
        exit() 
    c=(n//s)*a
    d=n%s 
    print(c+d)

# region fastio#
 
BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()
 
 
if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
 
input = lambda: sys.stdin.readline().rstrip("\r\n")
 
# endregion
 
 
if __name__ == "__main__":
    #read()
    main() 
#Comment read()

Submission status: Wrong Answer

Solution code:



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


cnt = N // (A+B)
print(cnt * A + (N % (A+B)))

Submission status: Wrong Answer

Solution code:
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = [int(input()) for i in range(n)]
    #a = list(map(int, input().split()))
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    n, a, b = map(int, input().split())
    cnt = 0
    if a == 0:
        print(0)
    while n > 0:
        cnt += min(n,a)
        n -= a
        n -= b
    print(cnt)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

AB = A + B

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

ans = A * N // AB
ans_mod = N % AB 

if ans_mod == 0:
    print(ans)
    sys.exit()

if ans_mod > A:
    ans += A
else:
    ans += ans_mod - B

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
from collections import deque
def main():
    n,a,b = tuple([int(t)for t in input().split()])

    if b == 0:
        print(n)
    else:
        print(min(n,a))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:


def resolve():
    N,A,B=map(int,input().split())
    C=A+B
    S=N%C
    print(A*N//C+min(A,S))



if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

AB = A+B
print ((N-(N//AB)*AB) + (N//AB*A))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

P = N // (A + B)
Q = N % (A + B)

print(P * A + Q)

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:
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(*args):
    print(*args,file=sys.stderr)

def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
     
#input

def resolve():
    N,A,B=pin()
    ans=0
    cycle=A+B
    ans+=A*(N//cycle)
    t=N%cycle
    if t <= A:
        ans+=t
    else:
        ans+=A
    print(ans)
    #print(N//cycle)
    #print(ans)
    #print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])
#if __name__=="__main__":resolve()

"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """8 3 4"""
        output = """4"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """8 0 4"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """6 2 4"""
        output = """2"""
        self.assertIO(input, output)

# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(*args):
    print(*args,file=sys.stderr)

def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
     
#input

def resolve():
    N,A,B=pin()
    ans=0
    cycle=A+B
    ans+=A*(N//cycle)
    t=N%cycle
    if t <= A:
        ans+=t
    else:
        ans+=A
    print(ans)
    #print(N//cycle)
    #print(ans)
    #print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])
#if __name__=="__main__":resolve()

"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """8 3 4"""
        output = """4"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """8 0 4"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """6 2 4"""
        output = """2"""
        self.assertIO(input, output)

if __name__ == "__main__":
    unittest.main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

import sys, math
sys.setrecursionlimit(300000)


def solve(N: int, A: int, B: int):
    tmp = N // (A + B)
    ret = tmp * A
    ret += N % (A + B)
    print(ret)
    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,a,b=list(map(int,input().split()))

l=a+b
sub=n//l
ans=sub*a

zan=n-sub*l
ans+=min(b,zan)
print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B=[int(i) for i in input().split(" ")]
ball=N*A//(A+B)
if N%(A+B)>A:
    ball+=A
else:
    ball+=N%(A+B)

print(ball)

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())
r=n//(a+b)
ans=a*r+(n-(a+b)*r)
print(ans)