jiahuimbzuai/CoQuIR huggingface dataset:
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        MyReader reader = new MyReader();
        int[] nab = reader.readInts(" ");
        int n = nab[0];
        int a = nab[1];
        int b = nab[2];
        System.out.println(problem158b(n, a, b));
    }

    private static int problem158b(int n, int a, int b) {
        int ab = a + b;
        if (a == 0 || ab == 0) return 0;
        return a * (n / ab) + (Math.min(a, (n % ab)));
    }

    private static class MyReader {
        private final BufferedReader br;
        private MyReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        private String readString() throws IOException {
            return br.readLine();
        }

        private int readInt() throws IOException {
            return Integer.parseInt(readString());
        }

        private String[] readStrings(String regex) throws IOException {
            return readString().split(regex);
        }

        private int[] readInts(String regex) throws IOException {
            String[] strings = readStrings(regex);
            int[] ints = new int[strings.length];
            for (int i = 0; i < ints.length; i++) {
                ints[i] = Integer.parseInt(strings[i]);
            }
            return ints;
        }
    }
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long maxn,a,b;
	cin>>maxn>>a>>b;
	long long kkk=maxn/(a+b),lll=maxn%(a+b);
	kkk=kkk*a;
	if(lll>a){
		kkk=kkk+lll-(lll-a);
	}else{
		kkk=kkk+lll;
	}
	cout<<kkk<<endl;
	return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

 
int main() {
   int64_t N, A, B, C, D, R;
   cin >>N >>A >>B;
   C = A+B;
   R = N/C;
   D = N - R * C;
   if(D>=A) cout << (R+1)*A << endl;
   if(D<A) cout << R*A+D << endl;


   }
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;
typedef pair<ll,ll> P;

ll N,A,B;
int main(){
  cin>>N>>A>>B;
  ll AB=A+B;
  ll ans =(N/AB)*A;
  ll md = N%AB;

  if(md-A>0){
    print((ans+A))
  }
  else print((ans+md));

}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  if(n%(a+b)<=a){
    cout<<n/(a+b)*a+n%(a+b)<<endl;
  }
  else{
    cout<<n/(a+b)*a+a<<endl;
  }
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))

int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

int main(){
ll N,A,B; cin>>N>>A>>B;
ll amari=N%(A+B);
ll shou=N/(A+B);
ll ans=shou*A+amari;
cout<<ans<<endl;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
int main() {
	ll n,a,b;
	cin>>n>>a>>b;
	cout << n/(a+b)*a+n%(a+b);
	// your code goes here
	return 0;
}
//  [c]
#include <stdio.h>

int main(void)
{
	long n, a, b, x=0;
  
    scanf("%ld%ld%ld", &n, &a, &b);

    x += n/(a+b)*a;
    x += (n%(a+b)<=a) ? n%(a+b) : a;
  
    printf("%ld\n", x);
    
    return 0;
}
//  [c]
#include <stdio.h>

int main (){
  long n, a, b, ab, q, r, totalBolasAzuis=0;

  scanf("%ld", &n);
  scanf("%ld", &a);
  scanf("%ld", &b);

  if (a==0){
    printf("0\n");
    return 0;
  }

  ab = a + b;
  q = n/ab;
  r = n%ab;

  if(r > a){
    totalBolasAzuis = (q*a) + a;
  } else {
    totalBolasAzuis = (q*a) + r;
  }

  printf("%ld\n", totalBolasAzuis);

  return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>

int main()
{
    long long int n,a,b,sum,q,r;
    scanf("%lld%lld%lld",&n,&a,&b);
    sum=a+b;
    q=n/sum;
    r=n%sum;
    if(r<a){
        printf("%lld\n",(a*q)+r);
    }
    else if(r>=a)
        printf("%lld\n",(a*q)+a);
}
//  [c]
#include <stdio.h>
int main(void)
{
    int N,A,B;
    scanf("%d %d %d",&N,&A,&B);
    if(N%(A+B) <= A){
        printf("%d",N-(N/(A+B)*B));
    }else{
        printf("%d",N/(A+B)*A+A);
    }
}
//  [c]
#include <stdio.h>

int main(){
	long long int n;
	long long int a , b;
	
	scanf("%lld %lld %lld",&n,&a,&b);
	
	if(n%(a+b)==0){
		printf("%lld\n",a);
	}
	else {
		printf("%lld\n",a+ (n%(a+b)));
	}
	
	return 0;
}
//  [c]
#include <stdio.h>

int main(){
	long long int n;
	int a , b;
	
	scanf("%d %d %d",&n,&a,&b);
	
	if(n%(a+b)==0){
		printf("%d\n",a);
	}
	else {
		printf("%d\n",a+ (n%(a+b)));
	}
	
	return 0;
}
//  [javascript]
function main(lines) {
  const [N, A, B] = ba();

  const turn = N / (A+B);
  const rest = N % (A+B);
  const ans = A*turn + (A < rest ? A : rest);
  
  return ans.toString();
}



const lines = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");

let lineCount = 0;
const s = () => lines[lineCount++];
const n = () => Number(s());
const b = () => BigInt(s());
const sa = () => s().split(' ');
const na = () => sa().map(Number);
const ba = () => sa().map(BigInt);

const ans = main(lines);
console.log( ans );
//  [javascript]
const input = require("fs").readFileSync("/dev/stdin", "utf8")
const lines = input.split('\n')
const [N, A, B] = lines[0].split(' ').map(Number)
const ans = Math.floor(N / (A + B)) * A + Math.min(N % (A + B), A)
console.log(ans)
//  [javascript]
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var n = Number(lines[0].split(' ')[0]);
 var a = Number(lines[0].split(' ')[1]);
 var b = Number(lines[0].split(' ')[2]);

 var kiri = Math.floor(n / (a + b));
 var blue = kiri * a;
 var amari = n % (a + b);

 if(amari >= a){
   blue += a;
 }else{
   blue += amari;
 }

 console.log(blue);
});
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	a := nextInt()
	b := nextInt()

	if a == 0 {
		fmt.Println(0)
		return
	}

	if n <= a {
		fmt.Println(n)
		return
	}

	if n <= a+b {
		fmt.Println(a)
		return
	}

	base := a * (n / (a + b))
	amari := n % (a + b)
	if a <= amari {
		amari = a
	}

	fmt.Println(base + amari)
}

// ---- readfunc
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var stdInScanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	stdInScanner.Scan()
	i, _ := strconv.Atoi(stdInScanner.Text())
	return i
}

func main() {
	stdInScanner.Split(bufio.ScanWords)

	N := nextInt()
	A := nextInt()
	B := nextInt()

	surplus := N % (A + B)
	if surplus >= A {
		surplus = A
	}
	fmt.Println(((N / (A + B)) * A) + surplus)
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N, A, B := getInt(), getInt(), getInt()

	C := A + B
	p := N / C
	r := N % C
	ans := p * A
	ans += min(A, r)
	out(ans)
}
//  [go]
package main

import (
	"fmt"
)

func main() {

	var N, A, B int
	fmt.Scanf("%d %d %d", &N, &A, &B)

	var countA, countB, countResult int
	for i := 0; i < N; i++ {

		if countA < A {
			countA++
			countResult++
		} else if countA == A && countB < B {
			countB++
		}

		if countA == A && countB == B {
			countA = 0
			countB = 0
		}

	}

	fmt.Println(countResult)
}
//  [go]
package main

import (
"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	sc = initScanner(os.Stdin)
	N, A, B := scanInt(sc), scanInt(sc), scanInt(sc)

	fmt.Println(resolve(N, A, B))
}

func resolve(N, A, B int) int {
	var count int

	for {
		if N > A {
			N -= A
			count += A
		} else {
			count += N
			break
		}

		N -= B

		if N <= 0 {
			break
		}
	}

	return count
}


// --------------- BASE DEFINITIONS ---------------

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanIntSlice(sc *bufio.Scanner, n int) []int {
	is := make([]int, n)
	for i:=0; i<n; i++ {
		is[i] = scanInt(sc)
	}

	return is
}
//  [go]
package main

import "fmt"

func main() {
	var n, a, b, count int

	fmt.Scan(&n, &a, &b)

	if a == 0{
		count = 0
	}

	if a + b >= n{
		count = a
	}else if a + b < n{
		if n % (a+b) >= a{
			count = n / (a+b) + a
		}else{
			count = n / (a+b) + n % (a+b)
		}
	}

	fmt.Print(count)
}
//  [ruby]
n,a,b = gets.split(" ").map(&:to_i)

wa = a + b
count = n / wa
reds = count * a

amari = n % wa
amari = a if amari > a

puts reds + amari
//  [ruby]
n, a, b = gets.chomp.split(" ").map(&:to_i)

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

if amari < a
  sum += amari
else
  sum += a
end

puts sum
//  [ruby]
n, a, b = gets.chomp.split().map(&:to_i)

quotient = n / (a + b) * a
amari = n % (a + b)

if amari >= a
  quotient += a
else
  quotient += amari
end

puts quotient
//  [ruby]
N, A, B = gets.split.map &:to_i
div = N / (A + B)
rem = N % (A + B)
puts div * A + rem
//  [ruby]
A,B,N = gets.split(" ").map(&:to_i)

x = ((N/(A+B)).floor)*A
y = [N%(A+B),A].min

puts x+y
//  [ruby]
n,a,b = gets.chomp.split(' ').map(&:to_i)
puts (n / (a + b)) * a + [(n % (a + b)),b].min
//  [rust]
#![allow(unused_imports)]

use std::cmp;
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::stdin;
use std::ops::*;
use std::process::exit;
use std::str::FromStr;

pub const MOD: usize = 1000000007;

fn main() {
    let (n, a, b): (i64, i64, i64) = input_three();
    let ans = n / (a + b) * a + min(a, n % (a + b));
    println!("{}", ans);
}

pub fn input<T: FromStr>() -> T {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}

pub fn input_vec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>()
}

pub fn input_lines<T: FromStr>(l: usize) -> Vec<T> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input());
    }
    res
}

pub fn input_lines_two<T: FromStr, U: FromStr>(l: usize) -> Vec<(T, U)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_two());
    }
    res
}

pub fn input_lines_three<T: FromStr, U: FromStr, V: FromStr>(l: usize) -> Vec<(T, U, V)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_three());
    }
    res
}

pub fn input_two<T: FromStr, U: FromStr>() -> (T, U) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
    )
}

pub fn input_three<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
        s[2].parse::<V>().ok().unwrap(),
    )
}

pub fn input_four<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse().ok().unwrap(),
        s[1].parse().ok().unwrap(),
        s[2].parse().ok().unwrap(),
        s[3].parse().ok().unwrap(),
    )
}
//  [rust]
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (N, A, B) = read!(usize, usize, usize);

    let k = A + B;
    let total = A * (N / k) + min(N % k, A);

    println!("{}", total);
}
//  [rust]
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        n: u64,
        a: u64,
        b: u64,
    }
    let d = n / (a+b);
    let m = n % (a+b);
    println!("{}", a * d + std::cmp::min(a,m));
}
/* vim:set foldmethod=marker: */
//  [rust]
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        mut n: usize,
        a: usize,
        b: usize,
    }

    let mut ans = 0;

    for _ in 0..100000 {
        if n == 0 {
            break;
        }
        if a <= n {
            ans += a;
            n -=  a;
        } else {
            ans += n;
            n = 0;
        }

        if b <= n {
            n -= b;
        } else {
            n = 0;
        }
    }

    println!("{}", ans);
}
//  [rust]
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        mut n: usize,
        a: usize,
        b: usize,
    }

    let mut ans = 0;

    for _ in 0..10000 {
        if n == 0 {
            break;
        }
        if a <= n {
            ans += a;
            n -=  a;
        } else {
            ans += n;
            n = 0;
        }

        if b <= n {
            n -= b;
        } else {
            n = 0;
        }
    }

    println!("{}", ans);
}
//  [rust]
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        mut n: usize,
        a: usize,
        b: usize,
    }

    let mut ans = 0;

    for _ in 0..1000 {
        if n == 0 {
            break;
        }
        if a <= n {
            ans += a;
            n = n - a;
        } else {
            ans += n;
            n = 0;
        }

        if b <= n {
            n = n - b;
        } else {
            n = 0;
        }
    }

    println!("{}", ans);
}
//  [swift]
let l = readLine()!.split(separator:" ").map{Int($0)!}
print(l[0]/(l[1]+l[2])*l[1]+min(l[1],l[0]%(l[1]+l[2])))
//  [swift]
import Foundation
var inl=readLine()!.components(separatedBy:" ")
var n=Int(inl[0])!
var a=Int(inl[1])!
var b=Int(inl[2])!
var c=a+b
var s=0
s+=(n/c)*a
if(n%c>a){
  s+=a
}else{
  s+=n%c
}
print(s)
//  [swift]
import Foundation

func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let nab = readInts()
    let (n,a,b) = (nab[0],nab[1],nab[2])
    var ans = 0
        
    ans = n / (a + b) * a
    let rem = n % (a + b)
    ans += rem < a ? rem: a
    print(ans)
}
main()
//  [swift]
import Foundation

func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let nab = [8, 0, 4]//readInts()
    let (n,a,b) = (nab[0],nab[1],nab[2])
    var ans = 0
        
    ans = n / (a + b) * a
    let rem = n % (a + b)
    ans += rem < a ? rem: a
    print(ans)
}
main()
//  [typescript]
import * as fs from 'fs';
// main
function main(input: string[]) {
    // param
    let n: bigint = 0n;
    let a: bigint = 0n;
    let b: bigint = 0n;
    let ans: string = "";
    // init
    [n, a, b] = input.shift().split(" ").map(x => BigInt(x));
    // solve
    let s = n % (a + b);
    let t = (n - s) / (a + b);
    let u = (a < s) ? a : s;
    ans = String(a * t + u).replace("n", "");
    // answer
    console.log(ans);
}
// entrypoint
function entrypoint() {
    try {
        // linux
        let input = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        console.debug = function () { };
        main(input);
    }
    catch (ex) {
        // windows
        const lines: string[] = [];
        // @ts-ignore
        const reader = require('readline').createInterface({
            // @ts-ignore
            input: process.stdin,
            // @ts-ignore
            output: process.stdout
        });
        reader.on('line', function (line: string) {
            lines.push(line);
        });
        reader.on('close', function () {
            let input = lines;
            main(input);
        });
    }
}
entrypoint();
//  [typescript]
function main(input) {
  const inputs =input.split('\n')
  const [N, A, B] = inputs[0].split(' ').map(Number)
  let s = Math.floor(N / (A + B)) * A
  const r = N % ( A + B )
  if (r > A) {
    s = s + A
  } else {
    s = s + r
  }
  console.log(s)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [typescript]
function main(input) {
  const inputs =input.split('\n')
  const [N, A, B] = inputs[0].split(' ').map(Number)
  let s = N / (A + B) * A
  const r = N % ( A + B )
  if (r > A) {
    s = s + A
  } else {
    s = s + r
  }
  console.log(s)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [python]
def get_one_position(number):
    return number % 10


def get_ten_div(number):
    return number // 10 * 10 + 10


if __name__ == '__main__':
    numbers = []
    ans = 0
    min_one_point = 9
    min_one_point_index = 5
    for i in range(5):
        number = int(input())
        numbers.append(number)
        if get_one_position(number) <= min_one_point and get_one_position(number) != 0:
            min_one_point = get_one_position(number)
            min_one_point_index = i

    for i in range(len(numbers)):
        if i != min_one_point_index:
            if numbers[i] % 10 == 0:
                ans += numbers[i]
            else:
                ans += get_ten_div(numbers[i])
        else:
            ans += numbers[i]

    print(ans)
//  [python]
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
a = A % 10
b = B % 10
c = C % 10
d = D % 10
e = E % 10
f = [a, b, c, d, e]
g = f.count(0)
a1 = A // 10
b1 = B // 10
c1 = C // 10
d1 = D // 10
e1 = E // 10
if g == 5:
    print(A + B + C + D + E)
else:
    f = [i for i in f if i > 0]
    print((a1 + b1 + c1 + d1 + e1 + 4 - g) * 10 + min(f))
//  [python]
T = [int(input()) for i in range(5)]
s = sum([x-((x-1)%10+1) for x in T])
m = sorted([(x-1)%10+1 for x in T])
print(s+m[0]+sum([(x+9)//10*10 for x in m[1:]]))
//  [python]
dish=[int(input()) for i in range(5)]
dish_s=[(dish[i]+9)//10 for i in range(5)]
dish_d=[dish[i]%10 for i in range(5)]
sum=0
for i in range(5):
  sum+=dish_s[i]
min=9
for i in range(5):
  if dish_d[i]!=0 and dish_d[i]<min:
    min=dish_d[i]  
print((sum-1)*10+min)
//  [python]
dishes = [int(input()) for i in range(5)] 

d = [abs(d % 10 -10) for d in dishes if d % 10 != 0] # select nums which can be divided by 10
d.remove(max(d)) 
print(sum(dishes) + sum(d))
//  [python]
import sys
a = list(sys.stdin.read().split())
t = [[int(n[:-1] or 0), int(n[-1])] for n in a]
t = list(zip(*t))
ans = (sum(t[0]) + (len(u := list(filter(lambda n: n > 0, t[1]))) - 1)) * 10 + min(u)
print(ans)
//  [java]
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    int[] a;
    private void solve() {
        a = new int[5];
        int ans = 0;
        int max = 0;
        for(int i = 0;i < 5;i++) {
            a[i] = nextInt();
            ans += a[i];
            int mod = 10 - a[i] % 10;
            if (mod != 10) {
                max = Math.max(max, mod);
            }
            ans += mod % 10;
        }

        out.println(ans - max);


    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}
//  [java]
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int[] num = new int[5];
    int ans = 0;
    int min = 10;
    for(int i=0; i<5; i++){
      num[i] = Integer.parseInt(in.readLine());
      if(num[i]%10==0)
        ans += num[i];
      else
        ans += (num[i]/10)*10+10;
      
      if(num[i]%10!=0)
       min = Math.min(num[i]%10,min);
    }
    System.out.println(ans-10+min);
  }
}
//  [java]

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long sum=0;

		for (int i = 0; i < 4; i++) {
			int let =sc.nextInt() ;
			if (let % 10 !=0) {
				let =(let/10 + 1)*10;
			}
			sum+=let;
		}

		System.out.println(sum+sc.nextInt());

	}
}
//  [java]
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int[]a = new int[5];
    ArrayList<Integer>b = new ArrayList<>();

    for(int i=0; i<5; i++) {
    	a[i] = sc.nextInt();
    	if(a[i]%10 != 0) {
    		b.add(a[i]%10); 
    	}
    }	
    Collections.sort(b);
    int last = 0;
    for(int i=0; i<5; i++) {
    	if(a[i]%10 == b.get(0)) {
    		last = a[i];
    		break;
    	}
    }
    int al = 0;
    int cou = 0;
    for(int i=0; i<5; i++) {
    	if(a[i] != last) {
    		if(a[i]%10==0) {
    			al += a[i];
    		}else {
    			al += ((a[i]/10)+1)*10;
    		}
    		cou++;
    	}
     }
    if(cou != 4) {
    	al += ((last/10)+1)*10*(4-cou);
    }
    System.out.println(al + last);
    }
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
int a[5];
int main(){
    int p,d=0,mx=0,i,sum=0;
    cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
    for(i=0;i<5;i++){
        if (a[i]%10!=0){
            d=(a[i]/10+1)*10-a[i];
            if(d>mx){
                mx=d;
                p=i;
            }
        }
    }
    for(i=0;i<5;i++){
        if(p!=i){
            if(a[i]%10!=0){
                sum+=
				(a[i]/10+1)*10;
            }
            else sum+=a[i];
        }
    }
    cout<<(sum+a[p])<<endl;
    return 0;

}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

int main() {
    vector<int> as(5);
    for (int i = 0; i < 5; i++) cin >> as[i];
    int ans = 1e9;
    for (int i = 0; i < 5; i++) {
        int tmp = 0;
        for (int j = 0; j < 5; j++) {
            if (i == j) {
                tmp += as[j];
            } else {
                tmp += (as[j] + 9) / 10 * 10;
            }
        }
        // cerr << tmp << endl;
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}
//  [cpp]
#include <iostream>
#include <climits>
using namespace std;

int best = INT_MAX;

int dish[5];
bool checked[5] = {false};

void dfs(int depth, int i_time);

int main()
{
    int i_time = 0;
    int cook = 0;
    cin >> dish[0];
    cin >> dish[1];
    cin >> dish[2];
    cin >> dish[3];
    cin >> dish[4];

    dfs(1, i_time);

    cout << best << endl;

    return 0;
}

void dfs(int depth, int i_time)
{

    for (int i = 0; i < 5; i++)
    {
        //メニューを選んで
        if (checked[i])
            continue;

        //注文する
        checked[i] = true;
        if (depth == 5)
        {
            if (i_time + dish[i] < best)
            {
                best = i_time + dish[i];
            }
        }
        else
        {
            int cook = dish[i];
            int i_i_time = i_time;
            //注文して時間を加算する 次の注文ができる時刻を求める
            while (cook > 0)
            {
                i_i_time = i_i_time + 10;
                cook = cook - 10;
            }
            dfs(depth+1, i_i_time);
        }
        checked[i] = false;
    }
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    IOS;
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >>e;
    vector<int>nums;
    nums.push_back(a);
    nums.push_back(b);
    nums.push_back(c);
    nums.push_back(d);
    nums.push_back(e);
    vector<int> vec;
    for(int i=0; i<5; i++){
        if(10-(nums[i]%10)!= 10){
            vec.push_back(10-(nums[i]%10));
        }
    }
    sort(vec.begin(),vec.end());
    int count = 0;
    for(int i=0; i<vec.size()-1; i++){
        count+=vec[i];
    }
    int ans = a+b+c+d+e;
    cout << ans+count <<endl;

}
//  [cpp]
import math


def main():
    t = []
    for i in range(5):
        t.append(int(input()))

    max_wait = 0
    max_wait_order = 0
    for i in range(len(t)):
        if t[i] % 10 != 0 and 10 - (t[i] % 10) >= max_wait:
            max_wait = 10 - t[i] % 10
            max_wait_order = i

    time = 0
    for i in range(len(t)):
        if i == max_wait_order:
            continue
        else:
            time += math.ceil(t[i] / 10) * 10
    time += t[max_wait_order]

    print(time)


if __name__ == '__main__':
    main()
//  [cpp]
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main(){
  int t, ans = 0, min_t = 129;
  for(int i = 0;i < 5;i++){
    cin >> t;
    if(t % 10){
      if(t % 10 <= min_t % 10) min_t = t;
      ans += ceil((double)t / 10) * 10;
    }else ans += t;
  }
  
  ans -= ceil((double)min_t / 10) * 10;
  ans += min_t;
  cout << ans << endl;
  
  return 0;
}
//  [c]
#include <stdio.h>

void better(){
    int X[5], x[5], i, last = 0;
    int S = 0;
    for(i = 0; i < 5; i++){
        scanf("%d", &X[i]);
        x[i] = X[i]%10;
        if(i == 0) continue;
        last = (x[i] < x[last] || x[last] == 0) && x[i] != 0? i : last;
    }
    //printf("%d\n", last);
    if(last == 4) goto aftSwap;

    int temp = X[4];
    X[4] = X[last];
    X[last] = temp;

    temp = x[4];
    x[4] = x[last];
    x[last] = temp;
    
    aftSwap:
    for(i = 0; i < 4; i++){
        S = x[i] != 0? S+X[i]+10-x[i] : S+X[i];
    }
    S += X[4];
    printf("%d\n", S);
}

int main(){
    better();
    return 0;
}
//  [c]
#include<stdio.h>
int main()
{
	int a[5],b[5],i,j,t,mt,sum=0;
	for(i=0;i<5;i++)
		scanf("%d",&a[i]);
	for(i=0;i<5;i++)
	{
		b[i]=a[i]%10;
		sum=sum+a[i]-b[i];
	}
	for(i=0;i<4;i++)
	{
		for(j=i+1;j<5;j++)
		{
			if(b[i]<b[j])
			{
				t=b[j];
				b[j]=b[i];
				b[i]=t;
			}
		}
	}
	for(i=0;i<4;i++)
	{
		if(b[i+1]==0)
		{
			mt=sum+10*i+b[i];
			break;
		}
		else
			mt=sum+40+b[4];
	}
	printf("%d\n",mt);
	return 0;
}
//  [c]
#include<stdio.h>
int a[5],b[5];
int main()
{
    int i,j,r,t,t1,t2,m,d,max;
    for(i=0;i<5;i++)
    {
        scanf("%d",&a[i]);
    }
     t=0;j=0;t1=0;
     for(i=0;i<5;i++)
    {
        if(a[i]%10==0)
        {
            t=t+a[i];
        }
        else
        {
            r=a[i]%10;
             t1=t1+(a[i]+(10-r));
             d=a[i]/10;
           b[j]=((d+1)*10)-a[i];

            j++;


        }
    }

    max=b[0];
     for(i=0;i<j;i++)

     {

        if(b[i]>max)
        {
            max=b[i];
        }

     }

    printf("%d\n",(t+t1)-max);
    return 0;
}
//  [c]
#include<stdio.h>
int main(void){
	
	int a[5],k=99999,x,i,m=0,w,o,y;
	
	scanf("%d",&a[0]);
	scanf("%d",&a[1]);
	scanf("%d",&a[2]);
	scanf("%d",&a[3]);
	scanf("%d",&a[4]);
	
	for(i=0;i<5;i++){
		w=a[i]%10;
		if(w<=k){
			if(w!=0){
				k=w;
				o=a[i];
				y=i;
			}
		}
	}
	printf("kは%d\n",k);
	
	for(x=0;x<5;x++){
		if(x!=y){
			if(a[x]%10!=0){
				a[x]=(a[x]/10)+1;
				a[x]=a[x]*10;
			}
			m+=a[x];
		}
	}
	m+=o;
	printf("%d",m);
	return(0);
}
//  [c]
#include<stdio.h>
int main(void){
	
	int a[5],k=99999,x,i,m=0,w,o;
	
	scanf("%d",&a[0]);
	scanf("%d",&a[1]);
	scanf("%d",&a[2]);
	scanf("%d",&a[3]);
	scanf("%d",&a[4]);
	
	for(i=0;i<5;i++){
		w=a[i]%10;
		if(w<=k){
			if(w!=0){
				k=w;
				o=a[i];
			}
		}
	}
	
	for(x=0;x<5;x++){
		w=a[x]%10;
		if(w!=k){
			if(a[x]%10!=0){
				a[x]=(a[x]/10)+1;
				a[x]=a[x]*10;
			}
			m+=a[x];
		}
	}
	m+=o;
	printf("%d",m);
	return(0);
}
//  [c]
#include<stdio.h>
int main(void){
	
	int a[5],k=99999,x,i,m=0,w,o;
	
	scanf("%d",&a[0]);
	scanf("%d",&a[1]);
	scanf("%d",&a[2]);
	scanf("%d",&a[3]);
	scanf("%d",&a[4]);
	
	for(i=0;i<5;i++){
		w=a[i]%10;
		if(w<k){
			if(w!=0){
				k=w;
				o=a[i];
			}
		}
	}
	
	for(x=0;x<5;x++){
		w=a[x]%10;
		if(w!=k){
			if(a[x]%10!=0){
				a[x]=(a[x]/10)+1;
				a[x]=a[x]*10;
			}
			m+=a[x];
		}
	}
	m+=o;
	printf("%d",m);
	return(0);
}
//  [javascript]
function Main(input) {
    input = input.split("\n").map(Number);
    var max = 0;
    input.forEach(function(val){
        if(max<(10-((val-0.1)%10))-0.1) max = 10-((val-0.1)%10)-0.1;
    });
    var sum = 0;
        input.forEach(function(val){
            sum += Math.ceil(val/10)*10;
    });
    console.log(sum-max);
}Main(require("fs").readFileSync("/dev/stdin","utf8").trim());
//  [javascript]
'use strict'
function Main(input) {
  const cookT = input.split("\n").map(Number);
  cookT.pop();
  // console.log({ cookT });

  let hitoketa = 10;

  for (let i = 0; i < 5; i++) {
    let num = cookT[i] % 10;
    if (num !== 0 && hitoketa > num) {
      hitoketa = num;
    }
  }

  let result = 0;

  for (let i = 0; i < 5; i++) {
    result += Math.ceil(cookT[i] / 10) * 10;
    // console.log(result);
  }
  result = result - 10 + hitoketa;
  console.log(result);



}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input){
  const abcde = input.split("\n").map(n=>parseInt(n));
  // const len = abcde.length;
  const len = 5;
 
  var total_time = 0;
 
  var last_cal_num = 10;
  var last_cal_num_index = 0;
 
  // 最後に注文するものを割り出す
  for(var i = 0; i < len; i++){
    var j = abcde[i] % 10
    if(0 < j && j < last_cal_num){
      last_cal_num = j;
      last_cal_num_index = i;
    }
  }
   
  // 最後に注文するもの以外の時間を足す
  for(var i = 0; i < len; i++){
    if(i !== last_cal_num_index){
      var j = abcde[i];
      var k = j % 10;
      j = k ? j + (10-k) : j; // k=0の時はそのままの値を入れる
      total_time += j;
    }
  }
   
  // 最後の注文の時間を足す
  total_time += abcde[last_cal_num_index];
  console.log(String(total_time).trim());
   
}
 
Main(require("fs").readFileSync("/dev/stdin","utf-8"));
//  [javascript]
'use strict';
// inputに入力データ全体が入る
function Main(input) {
  input = input.split("\n");
  let modArr = input.map(function(val){
    val = parseInt(val);
    if(val%10===0){
      return 10;
    }else{
      return val%10;
    }
  });
  let min = modArr.indexOf(Math.min.apply(null, modArr));
  let last = parseInt(input[min]);

  input.splice(min, 1);
  let result =0;
  for(let i = 0 ; i< input.length; i++){
  	let x = Math.ceil(input[i] /10)*10;
    result += x;
  };
  result += last;
  console.log(result);  	
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let dishs = []
    while(hasNext()){
        let tmp = nextInt()
        dish.push([tmp, tmp % 10, tmp + tmp % 10])
    }
    dish.sort((a,b) => a[1]-b[1])
    let total = 0
    total += dish[0][2]
    total += dish[1][2]
    total += dish[2][2]
    total += dish[3][2]
    total += dish[4][0]
    console.log(total)
}
Main()
//  [javascript]
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
  var a = Number(lines[0]);
  var b = Number(lines[1]);
  var c = Number(lines[2]);
  var d = Number(lines[3]);
  var e = Number(lines[4]);
  var ans = 0;
  var info = [];
 
  info.push(a);
  info.push(b);
  info.push(c);
  info.push(d);
  info.push(e);
 
  var amari = [];
  amari.push(a%10);
  amari.push(b%10);
  amari.push(c%10);
  amari.push(d%10);
  amari.push(e%10);
  var amari_t = amari.filter(function(value){
    return !(value == 0);
  });
 
  var min = Math.min(...amari_t);
 
  var index = amari.indexOf(min);
 
  for(i=0; i<5; i++){
    if(i==index){
      continue;
      console.log('A');
    }
    ans += info[i]
    if(ans%10 !== 0){
      while(ans%10 !== 0){
        ans++;
      }
    }
  }
 
  ans += info[index];
 
  console.log(ans);

});
//  [go]
package main

import (
        "fmt"
        "sort"
)

type Order []int

func (o Order) Len() int {
        return len(o)
}

func (o Order) Swap(i, j int) {
        o[i], o[j] = o[j], o[i]
}

func (o Order) Less(i, j int) bool {
        if o[i]%10 == 0 {
                return true
        }
        return o[i]%10 > o[j]%10
}

func solution(order Order) int {
        sort.Sort(order)
        out := 0
        for i := 0; i < 4; i++ {
                t := 0
                if order[i]%10 == 0 {
                        t = order[i]
                } else {
                        t = order[i] + 10 - order[i]%10
                }
                out += t
        }
        return out + order[4]
}

func main() {
        order := make(Order, 0, 5)
        for i := 0; i < 5; i++ {
                n := 0
                fmt.Scan(&n)
                order = append(order, n)
        }
        fmt.Println(solution(order))
}
//  [go]
package main

import "fmt"

func main() {
	A := make([]int, 5)
	for i := 0; i < 5; i++ {
		fmt.Scanf("%d", &A[i])
	}

	mini := -1
	min := 10
	for i := 0; i < 5; i++ {
		if A[i]%10 != 0 && A[i]%10 < min {
			min = A[i] % 10
			mini = i
		}
	}
	sum := 0
	for i := 0; i < 5; i++ {
		if A[i]%10 == 0 {
			sum += A[i]
		} else {
			if mini == i {
				sum += A[i]
			} else {
				sum += A[i] - A[i]%10 + 10
			}
		}
	}
	fmt.Println(sum)

}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func scanInts(n int) []int {
	sl := make([]int, n)
	for i := range sl {
		sl[i] = scanInt()
	}
	return sl
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInts(5)

	var sum, maxRem int
	for _, e := range n {
		sum += maxTime(e)

		if maxRem < remTime(e) {
			maxRem = remTime(e)
		}
	}

	fmt.Println(sum - maxRem)
}

func maxTime(n int) int {
	return ((n + 9) / 10) * 10
}

func remTime(n int) int {
	return maxTime(n) - n
}
//  [ruby]
food = []

5.times do
  food << gets.to_i
end

min = 10
sum = 0

food.each do |n|
  sum += (n/10.0).ceil * 10
  while n/10 != 0
    n %= 10
  end
  next if n == 0
  min = [min, n].min
end

puts sum - (10-min)
//  [ruby]
a = []
5.times do
	a << gets.to_i
end
a.sort!
sum = 1000
a.permutation(5).each do |per|
  tmp = 0
  per.each do |i|
    if tmp % 10 == 0
      tmp += i
    else
      while tmp % 10 != 0
        tmp += 1
      end
      tmp += i
    end
  end
  sum = tmp if tmp < sum
end
puts sum
//  [ruby]
as=$<.read.split.map(&:to_i)

ret = 0
min = 10
as.each do |a|
    ret += ((a/10.0).ceil * 10).to_i
    t = a % 10
    min = t if t < min && t != 0
end

ret -= 10-min
puts ret
//  [ruby]
time = []
min = Float::INFINITY
min_1 = 9
5.times do
  x = gets.chomp
  if x[-1].to_i != 0 && x[-1].to_i <= min_1
    min_1 = x[-1].to_i
    min = x.to_i
  end
  time << x.to_i
end
time.delete_at(time.find_index(min))
puts time.inject(min){|a,b| a+b.ceil(-1) }
//  [ruby]
time = []
min = Float::INFINITY
min_1 = 9
5.times do
  x = gets.chomp
  if x[-1].to_i != 0 && x[-1].to_i < min_1
    min_1 = x[-1].to_i
    min = x.to_i
  end
  time << x.to_i
end
time.delete_at(time.find_index(min))
puts time.inject(min){|a,b| a+b.ceil(-1) }
//  [ruby]
s=[]
a=[]
5.times do |i|
  s[i]=gets.to_i
  a[i]=10-s[i]%10
end
sum=0
a.zip(s).sort.each{|c,d|sum+=(c+d)}
puts sum-a.max
//  [rust]
#![allow(dead_code, unused_variables, unused_macros, unused_imports)]

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes .by_ref() .map(|r|r.unwrap() as char) .skip_while(|c|c.is_whitespace()) .take_while(|c|!c.is_whitespace()) .collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

fn main() {
    input! {
        mut foods: [i32; 5],
    }

    foods.sort_by(|a, b| match (a % 10, b % 10) {
        (0, 0) => std::cmp::Ordering::Equal,
        (0, _) => std::cmp::Ordering::Greater,
        (_, 0) => std::cmp::Ordering::Less,
        (a, b) => a.cmp(&b),
    });
    let mut ans = foods[0];
    for &x in foods.iter().skip(1) {
        ans += if x % 10 == 0 { x } else { x / 10 * 10 + 10 };
    }
    println!("{}", ans);
}
//  [rust]
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut arr:Vec<u64> = (0..5).map(|_| read()).collect();
    arr.sort_by_key(|&x| ((x as f64/10.0).ceil()*10.0)as u64 - x );
    let mut cnt = 0.0;
    let last = arr.pop().unwrap();
    for i in arr {
        cnt += (i as f64 / 10.0).ceil() * 10.0;
    }
    cnt += last as f64;
    println!("{}", cnt);
}
//  [rust]
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:[isize;5],
    }
    let mut z =110;
    let mut ans =0;
    for i in 0..5 {
        ans+=(a[i]+9)/10*10;
        if z>a[i]%10&&a[i]%10!=0 {z=a[i]%10;}
    }
    println!("{}",ans+z-10)
}
//  [rust]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: [usize; 5]);

    let mut min = 100_000;

    let mut sum = 0;
    for v in &n {
        let d_v = *v % 10;

        if d_v != 0 {
            min = std::cmp::min(min, d_v);
        }

        sum += *v + (10 - d_v) % 10;
    }
    println!("{}", sum - (10 - min) % 10);
}
//  [rust]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: [usize; 5]);

    let mut min = 100_000;

    let mut sum = 0;
    for v in &n {
        let d_v = *v % 10;

        if d_v != 0 {
            min = std::cmp::min(min, d_v);
        }

        sum += *v + (10 - d_v) % 10;
    }
    println!("{}", sum - (10 - min));
}
//  [swift]
var array: [Int] = []
var sum = 0

for _ in 0..<5 {
  let item = Int(readLine()!)!
  let a = item % 10
  sum += (item - a)
  if a != 0 {
    array.append(a)
  }
}

if array.count == 0 {
  print(sum)
} else {
  array.sortInPlace { (lhs, rhs) in
    return lhs > rhs
  }
  for i in 0..<array.count-1 {
    let item = array[i]
    let amari = item % 10
    let add = item + 10 - amari
    sum += add
  }
  sum += array[array.count-1]
  print(sum)
}
//  [swift]
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    func count() -> Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
}
extension Array where Element: Comparable {
    func max() -> Element! {
        return self.maxElement()
    }
    func min() -> Element! {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

var input: [Int] = []
for _ in 0..<5 {
    input.append(readInt()!)
}
var sum = 0
var overTime: [Int] = []
for i in input {
    let time = (i + 9) / 10 * 10
    sum += time
    overTime.append(time - i)
}
print(sum - overTime.max()!)
//  [swift]
var array: [Int] = []
var sum = 0

for _ in 0..<5 {
  let item = Int(readLine()!)!
  let a = item % 10
  sum += (item - a)
  if a != 0 {
    array.append(a)
  }
}

if array.count == 0 {
  print(sum)
} else {
  array.sortInPlace { (lhs, rhs) in
    return a > b
  }
  for i in 0..<array.count-1 {
    let item = array[i]
    let amari = item % 10
    let add = item + 10 - amari
    sum += add
  }
  sum += array[array.count-1]
  print(sum)
}
//  [swift]
var array1: [Int] = []
var array2 : [Int] = []

for _ in 0..<5 {
  let line = readLine()!
  let item = Int(line)!
  if item % 10 == 0 {
    array1.append(item)
  } else {
    array2.append(item)
  }
}

array2.sortInPlace { (lhs, rhs) in
  let a = lhs % 10
  let b = rhs % 10
  return a > b
}

var sum = 0
for i in 0..<array1.count {
  let item = array1[i]
  sum += item
}

for i in 0..<array2.count-1 {
  let item = array2[i]
  let amari = item % 10
  let add = item + 10 - amari
  sum += add
}
sum += array2[array2.count-1]

print(sum)
//  [swift]
var array1: [Int] = []
var array2 : [Int] = []

for _ in 0..<5 {
  let line = readLine()!
  let item = Int(line)!
  if item % 10 == 0 {
    array1.append(item)
  } else {
    array2.append(item)
  }
}

array2.sortInPlace { (lhs, rhs) in
  let a = lhs % 10
  let b = rhs % 10
  return a > b
}

var sum = 0
for i in 0..<array1.count {
  let item = array1[i]
  sum += item
}

for i in 0..<array2.count-1 {
  let item = array2[i]
  let amari = item % 10
  let add = item + 10 - amari
  sum += add
}
sum += array2[array2.count]

print(sum)