jiahuimbzuai/CoQuIR huggingface dataset:
//  [c]
#include <stdio.h>
int main() {
long long a, i, b, c;
long long x[100];
scanf("%lld", &a);
for (i = 0;i < a;i++) {
scanf("%lld", &x[i]);
} b = x[0];
  c = x[0];
for (i = 1;i < a;i++) {
if (x[i] >= b) b = x[i];
} for (i = 1;i < a;i++) {
if (x[i] <= c) c = x[i];
} printf("%lld\n", b - c);
return 0;
}
//  [c]
#include<stdio.h>

int main(void)
{
	int i,a[100],N,answer;
	static int min=0,max=0;
	scanf("%d",&N);
	for (i = 1; i <= N; i++)
	{
		scanf("%d", &a[i]);
	}
	for (i = 1; i <= N; i++)
	{
		if (max < a[i])
			max = a[i];
	}
	min = max;
	for (i = 1; i <= N; i++) {
		if (min > a[i])
			min = a[i];
	}
	answer = max - min;
	printf("%d", answer);
	return 0;
}
//  [c]
//#define ABS(X) ((X > 0) ? (X) : (-1 * X))
#define ABS(Value) ((Value < 0) ? (Value * -1) : (Value))


#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	int N;
	int *A;
	int max_diff;
	int current;
	int i;
	int j;

	printf("2以上100以下の整数Nを入力：");

	scanf("%d", &N);
	A = (int *)malloc(sizeof(int) + N);
	if (!A){
		printf("malloc error\n");
		return (0);
	}
	i = 0;
	while (i < N){
		printf("%d:", i + 1);
		scanf("%d", &A[i]);
		i++;
	}
	max_diff = 0;

	i = 0;
	while (i < N - 1){
		j = i + 1;
		while (j < N){
			current = A[i] - A[j];
			if (ABS(current) > max_diff){
				max_diff = ABS(current);
			}
			j++;
		}
		i++;
	}
	printf("%d\n", max_diff);
	free(A);
	return (0);
}
//  [c]
#include<stdio.h>
int main(){
  int n,a=1<<29,b=0,t,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){scanf("%d",&t);a=a<t?a:t;b=b<t?t:b;}
  printf("%d",b-a);
}
//  [c]
#include<stdio.h>
int main(){
  int n,a=1<<29,b=0,t,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){scanf("%d",&t);a=a<t?a:t;b=b<t?y:b;}
  printf("%d",b-a);
}
//  [javascript]
function Main(input) {
	input = input.split("\n");
  	var n = parseInt(input[0], 10);
  	A = input[1].split(" ");
  	var a = parseInt(A[0], 10);
  	var max = a;
  	var min = a;
  	for (var i=1; i<n; i++){
      a = parseInt(A[i], 10);
      if(a>max){
       max=a; 
      }else{
       if (a<min){
         min=a;
       }
      }
    }
  console.log('%d',max-min);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict";

var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/),
    cid = 0;

function next() {
    return +cin[cid++];
} // number一個取得
function nextstr() {
    return cin[cid++];
} // 文字列一個取得
function nextbig() {
    return BigInt(cin[cid++]);
} // BigInteger一個取得
// 長さnの配列として取得。aは文字列フラグ
function nexts(n, a) {
    return a ? cin.slice(cid, cid += n) : cin.slice(cid, cid += n).map(a => +a);
}
// 長さnのBigInt配列として取得。
function nextsbig(n) {
    return cin.slice(cid, cid += n).map(a => BigInt(a));
}
// w個ずつを組にして長さhの配列。aは文字列フラグ。
function nextm(h, w, a) {
    var r = [],
        i = 0;
    if (a)
        for (; i < h; i++) r.push(cin.slice(cid, cid += w));
    else
        for (; i < h; i++) r.push(cin.slice(cid, cid += w).map(a => +a));
    return r;
}
// 多次元配列。v,a1,a2,a3 なら、3次元。[[値vで長さa3の配列]をa2個並べた配列]をa1個並べた配列。
function xArray(v) {
    var a = arguments,
        l = a.length,
        r = "Array(a[" + --l + "]).fill().map(x=>{return " + v + ";})";
    while (--l) r = "Array(a[" + l + "]).fill().map(x=>" + r + ")";
    return eval(r);
}


console.log(main().toString());

function main() {
    let n = next();
    let a = nexts(n);
    let min = a[0];
    let max = a[0];
    for (let i = 1; i < n; i++) {
        min = Math.min(min, a[i]);
        max = Math.max(max, a[i]);
    }
    return max - min;
}
//  [javascript]
var main = function main(input) {
    var N = +input.split('\n')[0]
    var A = input.split('\n')[1].split(' ')
    var min = 1000000000
    var max = 1

    for (var i = 0; i < N; i++) {
        if (+A[i] > max) max = +A[i]
        if (+A[i] < min) min = +A[i]
    }
    console.log(max - min)
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf-8'))
//  [javascript]
function compareFunc(a, b) {
  return a - b;
}

function main(input) {
  let inputs = input.split(/\n/);
  let args = inputs[1].split(/\s/);
  args.sort(compareFunc);
  console.log(args[1] - args[0]);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
// https://atcoder.jp/contests/abc102/tasks/abc102_b
"use strict"
function Main(input) {
  const params = input.split('\n')
  const n = Number(params[0]);
  const a = params[1].split(' ').map(Number).sort();
  console.log(a[n - 1] - a[0]);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
  const args = input.split('\n');
  const n = args[0];
  const a = args[1].split(' ');
  const sort = a.sort((a, b) => a > b ? 1 : -1);
  console.log(sort[n-1] - sort[0]);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
  var N int 
  var A []int 

  sc.Split(bufio.ScanWords)

  // n枚を変数にする
  fmt.Scanf("%d", &N)
  // カードをarrayに落とし込む
  for i := 1; i <= N; i++ {
    A = append(A, newLine())
  }

  // sort
  //sort.Ints(a)
  sort.Sort(sort.Reverse(sort.IntSlice(A)))

  fmt.Println(A[0] - A[N-1])
}
//  [go]
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	fmt.Print(a[0] - a[1])
}
//  [go]
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	fmt.Println(a[0] - a[1])
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	arry := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arry[i])
	}
	min := 1000000000
	max := 0
	for i := 0; i < n; i++ {
		// MIN
		if arry[i] < min {
			min = arry[i]
		} else if arry[i] > max {
			max = arry[i]
		}
	}

	fmt.Println(max - min)

}
//  [ruby]
_n = gets.strip.to_i
nums = gets.strip.split.map(&:to_i)
puts nums.max - nums.min
//  [ruby]
n = gets.to_i
a = gets.split.map(&:to_i).sort
puts a[-1] - a[0]
//  [ruby]
N = gets.to_i
A = gets.split(' ').map(&:to_i)

p A.max - A.min
//  [ruby]
n = gets.to_i
num = gets.strip.split.map(&:to_i)
pust num.max-num.min
//  [ruby]
n = gets.chomp.to_i
ary = gets.split(" ").map(&:to_i).sort

puts (ary[-1] - ary[-1]).abs
//  [ruby]
n = gets.chomp.to_i
a = gets.chomp.split("").map(&:to_i)

puts a.max - a.min
//  [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: usize,
        aa: [u32;n]
    }
    println!("{}",
        aa.iter().max().unwrap() - aa.iter().min().unwrap());
}
//  [rust]
use std::io;
use std::cmp::{max, min};

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let n = v[0];
	let v:Vec<u64> = procon_read();
	let mut mini:u64 = v[0];
	let mut maxi:u64 = v[0];
	for i in 0..n {
		mini = min(v[i as usize], mini);
		maxi = max(v[i as usize], maxi);
	}
	println!("{}", maxi - mini);
}
//  [rust]
use std::process;
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)*}
    };
}

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!{
        n: i64, 
        v: [i64; n],
    }   
    let mut ans : Vec<i64> = Vec::new();

    if v.len() ==  2 {
        println!("{}", (v[0] - v[1]).abs());
        process::exit(0);
    }

    for i in 0..v.len() {
        for j in (i+1)..(v.len()-1) {
            ans.push(v[i]-v[j]);
    }
    }

    for i in &v {
    }
    ans.sort();

    println!("{}" , if ans.first().unwrap().abs() > ans.last().unwrap().abs() { ans.first().unwrap().abs()}else {ans.last().unwrap().abs()});

    

    


}
//  [rust]
use std::process;
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)*}
    };
}

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")
    };
}
#[macro_use] extern crate itertools;
use itertools::Itertools;
use std::cmp;
fn main() {
    input!{
        n: i64, 
        v: [i64; n],
    }   
    let mut ans:Vec<i64> = Vec::new();
    for i in v.iter().combinations(2) {
        ans.push(i[0]-i[1]);
    }

    println!("{}", cmp::max(ans.iter().max().unwrap().abs(),ans.iter().min().unwrap().abs()));


}
//  [rust]
use io::*;
use std::*;

fn solve(_n: i64, a: Vec<i64>) {
    let max = a.iter().cloned().fold(i64::MIN, cmp::max);
    let min = a.iter().cloned().fold(i64::MAX, cmp::min);
    println!("{}", max - min);
}

fn main() {
    let con = read_string();
    let mut scanner = Scanner::new(&con);
    let n: i64;
    n = scanner.next();
    let mut a: Vec<i64> = vec![0i64; (n) as usize];
    for i in 0..(n) as usize {
        a[i] = scanner.next();
    }
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(move || solve(n, a)).unwrap().join().unwrap();
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_end().to_owned()
    }
}
//  [swift]
import Foundation
let a = Int(readLine()!)!
let b = readLine()!.split(separator: " ").map({Int($0)!}).sorted()
print(b[a-1] - b[0])
//  [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)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
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)!}
}

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



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

let _ = readLine()!
let arr = readIntSplit(by: " ")
print(arr.max()-arr.min())
//  [swift]
import Foundation

func readInt() -> Int {
    return Int(readLine()!)!
}

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

func readTwoInts() -> (a: Int, b: Int) {
    let ints = readLine()!.split(separator: " ").map { Int($0)! }
    return (a: ints[0], b: ints[1])
}

let N = readInt()

var A = readInts()
A = A.sorted()
print(A[A.count-1]-A[0])
//  [swift]
import Foundation
let a = Int(readLine()!)!
let b = readLine()!.split(separator: " ").map({Int($0)!}).sorted()
print(b[0] - b[a-1])
//  [swift]
import Foundation
let a = Int(readLine()!)!
let b = readLine()!.split(separator: " ").map({Int($0)!}).sorted()
print(b[0] - b[a])
//  [swift]
import Foundation
_ = readLine()
let ai = readInts().sorted()
print(abs(ai.last!-ai.first!))
//  [typescript]
import * as fs from 'fs';

namespace AtCoder.abc102 {
    class ProgramB {
        args: string[];

        constructor(args: string[]) {
            this.args = args;
        }

        main(): void {
            const a: number[] = this.args[1].split(' ').map(Number);
            const sorted: number[] = a.sort((a: number, b: number) => a - b);

            console.log(Math.abs(sorted[sorted.length - 1] - sorted[0]));

        }
    }

    new ProgramB(fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n')).main();
}
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const n = stdin.split('\n')[0]
const a = stdin
  .trim()
  .split('\n')[1]
  .split(' ')
  .map(Number)

const ans = _ => {
  const min = Math.min(...a)
  const max = Math.max(...a)

  return Math.abs(max - min)
}

console.log(ans())
//  [typescript]
const log = console.log;

const parseLines = (s: string) => s.trim().split("\n");

const parseSpaceSeparated = (line: string) => line.trim().split(" ");

const parseDecimalInt = (s: string) => parseInt(s);

const parseSpaceSeparatedDecimalInt = (line: string) =>
  parseSpaceSeparated(line).map(parseDecimalInt);

// ----

function Main(input: string): void {
  const [head, body] = parseLines(input);
  const a = parseSpaceSeparatedDecimalInt(body);

  log(Math.max(...a) - Math.min(...a));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
package main

import (
	"fmt"
	"math"
	"sort"
)

//4
//1 4 6 3
func main() {
	var n int
	fmt.Scanf("%d", &n)

	arr := make([]int, n)
	for i := 0; i < n; i++ {
		var a int
		fmt.Scanf("%d", &a)
		arr[i] = a
	}

	sort.IntSlice(arr).Sort()
	var ans int
	ans = int(math.Abs(float64(arr[len(arr)-1]-arr[0])))
	fmt.Println(ans)
}
//  [typescript]
const Main = (input) => {
  // 1行目がinpt[0], 2行目がinpt[1], …に入る
  const inpt = input.split('\n');
  // 1つめがinpt[0], 2つめがinpt[1], …に入る
  // const inpt = input.split(' ');
  const ar = inpt[1].split(' ');
  let mx = 1, mn = 10 ** 9;
  for (let v of ar) {
    mx = mx > v ? mx : v;
    mn = mn < v ? mn : v;
  }
  console.log(Math.abs(mx - mn));
}

// 標準入力を受け取るおまじない
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [python]
# -*- coding: utf-8 -*-
"""
Created on Thu Dec 19 22:37:09 2019

@author: lucifer
"""
n=int(input())
if n%500==0:
  print(1000*int(n/500))
else:
  s=int(n/500)
  x=1000*s+int((n-(s*500))/5)*5
  print(x)
//  [python]
X= int(input())

div500= int(X/500)
div5= int((X%500)/5)
happy= div500*1000 + div5* 5

print(happy)
//  [python]
x=int(input())
a=x//500
b=x%500
c=b//5
print(a*1000+c*5)
//  [python]
x = int(input())
a = (x/500)*1000
x -= 500*(x/500)
b = 5*(x/5)
print(a+b)
//  [python]
X = int(input())

a, mod = divmod(X, 500)
b = mod % 5

print(a * 1000 + b * 5)
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int N = Integer.parseInt(st.nextToken());
		int x = N / 500;
		int sum = x * 1000;
		N %= 500;
		sum += (N / 5) * 5;
		System.out.println(sum);
	}
}
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	
	public static void main(String[] args) throws IOException{
		BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
		
		int cash=Integer.parseInt(in.readLine());
		
		long total=(cash/500)*1000;
		
		cash%=500;
		
		total+=(cash/5)*5;
		
		
		System.out.println(total);
		

	}

}
//  [java]
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
	InputStream is;
	PrintWriter out;
	String INPUT = "";
	
	void solve() {
		long X = nl();
		long tot = X / 500 * 1000L;
		X -= X / 500 * 500;
		tot += X / 5 * 5L;
		out.println(tot);
	}
			
	void run() throws Exception {
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if (!INPUT.isEmpty())
			tr(System.currentTimeMillis() - s + "ms");
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}
//  [java]
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int i,j;
		int max=0;
		int k=x/500;
		int l=x/5;
		
		for(i=0;i<=k;++i) {
			for(j=0;j<=l/2;++j) {
				if(x-500*i-5*j>=0 && max<(1000*i)+(5*j)){
					max=1000*i+5*j;
				}
			}
		}
		System.out.println(max);
	}

}
//  [java]
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int i,j;
		int max=0;
		int k=x/500;
		int l=x/5;
		
		for(i=0;i<=k;++i) {
			for(j=0;j<=l;++j) {
				if(x-500*i-5*j>=0 && max<(1000*i)+(5*j)){
					max=1000*i+5*j;
				}
			}
		}
		System.out.println(max);
	}

}
//  [java]
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long X = sc.nextLong();
    long happy = 0;
    long cnt1 = 0;
    long cnt2 = 0;
    long rem1 = 0;
    long rem2 = 0;
    long rem3 = 0;
    
    for(int i=1; i<1000; i++) {
      rem1 = X - 500*i;
      if(rem1 > 0) {
        cnt1++;
      } else {
        break;
      }
    }
    
    rem2 = X - 500*2;
    
    for(int i=1; i<1000; i++) {
      rem3 = rem2 - 5*i;
      if(rem3 > 0) {
        cnt2++;
      } else {
        break;
      }
    }

    happy = 1000*cnt1 + 5*cnt2;
    System.out.println(happy);
    
  }
}
//  [cpp]
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
#include<deque>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF (1LL << 40)
int main() {
	int n, k, m, l;
	scanf("%d", &n);
	k = n / 500;
	m = n - k * 500;
	l = m / 5;
	printf("%d\n", k * 1000 + l * 5);
	return 0;
}
//  [cpp]
#include <iostream>
#include <vector>
#include <string>
#include<map>
using namespace std;

int main() {
    int X;
    cin >> X;

    int result500;
    int result5;

    result500 = X / 500;
    X = X - result500 * 500;
    result5 = X / 5;
    int happy = result500 * 1000 + result5 * 5;
    cout << happy << endl;

    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int n;
    cin>>n;
    int ans=(n/500)*1000;
    n%=500;
    ans+=(n/5)*5;
    cout<<ans;
}
//  [cpp]
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll p, ll n, ll m) {
	if (n == 0) return 1;
	else if (n == 1) return p % m;
	else if (n % 2 == 1) return p * pow_mod(p, n - 1, m) % m;
	else {
		ll tmp = pow_mod(p, n / 2, m);
		return (tmp * tmp) % m;
	}
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

ll com_mod(ll n, ll k, ll m) {
	if (k == 0) return 1;
	else {
		ll x = 1;
		ll y = 1;
		for (ll i = 0; i < k; i++) {
			x = (x * (n - i)) % m;
			y = (y * (i + 1)) % m;
		}
		ll res = (x * pow_mod(y, m - 2, m)) % m;
		return res;
	}
}

int main() {
	int x; cin >> x;
	int cnt_500 = x / 500;
	int cnt_5 = (x - x / 500 * 500) / 5;
	ll ans = 1000 * cnt_500 + 5 * cnt_5;
	return 0;
}
//  [cpp]
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

/*--------switch header--------*/
#define ALGORITHM   1
#define CASSERT     0
#define CMATH       0
#define DEQUE       0
#define FUNCTIONAL  1
#define IOMANIP     1
#define IOSTREAM    1
#define LIST        0
#define MAP         0
#define QUEUE       0
#define SET         0
#define STRING      1
#define UTILITY     1
#define VECTOR      1
#define VEC_DEBUG   1

using namespace std;

#pragma region headers
#if VEC_DEBUG
#define _GLIBCXX_DEBUG
#endif
#if ALGORITHM
#include <algorithm>
#endif
#if CASSERT
#include <cassert>
#endif
#if CMATH
#include <cmath>
#endif
#if DEQUE
#include <deque>
#endif
#if FUNCTIONAL
#include <functional>
#endif
#if IOMANIP
#include <iomanip>
#endif
#if IOSTREAM
#include <iostream>
#endif
#if LIST
#include <list>
#endif
#if MAP
#include <map>
#endif
#if QUEUE
#include <queue>
#endif
#if SET
#include <set>
#endif
#if STRING
#include <string>
#endif
#if UTILITY
#include <utility>
#endif
#if VECTOR
#include <vector>
#endif
#pragma endregion


/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define ALL(x)          (x).begin(), (x).end()
#define rALL(x)         (x).rbegin(), (x).rend()
#define REP(i, n)       for(int i = 0; (i) < (n); (i)++)
#define rREP(i, n)      for(int i = n - 1; (i) >= 0 ; (i)--)
#define FOR(i, a, b)    for(int i = (a); (i) < (b) ; (i)++)
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };



/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int x; cin >> x;
    int a = x/500;
    int b = x%1000 / 5;

    cout << a * 1000 + b * 5 << endl;

return 0;
}
//  [cpp]
#include<bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
using ll = long long;

int main()
{
	int n;
	cin >> n;
	ll ans = 0;
	ans += n/1000*2000;
	n -= ans/2;
	ans += n/5*5;
	cout<<ans<<endl;
}
//  [c]
#include <stdio.h>

int main(){
  int x, ans1, ans2;
  scanf("%d",&x);
  ans1=x/500;
  ans1*=1000;
  ans2=x%500;
  ans2/=5;
  ans2*=5;
  printf("%d",ans1+ans2);
}
//  [c]
#include<stdio.h>

int main(){
  int i;
  int s = 0;
  scanf("%d", &i);
  
  s += (i/500)*1000;
  i -= (i/500)*500;
  s += (i/5)*5;
  i -= (i/5)*5;
  printf("%d", s);
  
  return 0;
}
//  [c]
#include<stdio.h>
int main(void){
  int a,b,c,d,x;
  scanf("%d",&a);
  b=a/500;
  b=b*1000;
  c=a%500;
  d=c/5;
  d=d*5;
  x=b+d;
  printf("%d\n",x);
    return 0;
}
//  [c]
#include<stdio.h>

int main(void){
  long long x,c=0;
  scanf("%lld",&x);
  while(x>500){
    c+=1000;
    x-=500;
  }
  while(x>5){
    c+=5;
    x-=5;
  }
  printf("%lld",c);
  return 0;
}
//  [c]
#include<stdio.h>

int main(void){
  int n,c=0,h=0;
  scanf("%d",&n);
  for(int i=1;i<=n;i++){
    c++;
    if(c==500){
      h+=1000;
      c-=500;
    }else if((n-i)<500 && c==5){
      h+=5;
      c-=5;
    }
  }
  printf("%d\n",h);
  return 0;
}
//  [c]
#include<stdio.h>

int main(void){
  int n,c=0,h=0;
  scanf("%d",&n);
  for(int i=1;i<=n;i++){
    c++;
    if(c==500){
      h+=1000;
      c-=500
    }else if((n-i)<500) && c==5){
      h+=5;
      c-=5;
    }
  }
  printf("%d\n",h);
  return 0;
}
//  [javascript]
function Main(input) {
    input = input.split("\n");
  	var a = input[0]-0;
  	var aa = ~~(a/500);
  	var ans = 0;
  	ans += aa*1000;
  	var bb = ~~((a-aa*500)/5);
  	ans += bb*5;
  	console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
    // const input = Number(input)
    const _500 = Math.floor(input / 500)
    const remain = input - (500 * _500)
    // if (_500 >= 1) {
        const _5 = Math.floor((remain) / 5)
        console.log(1000 * _500 + 5 * _5)
    // } else {
    //     console.log(1000 * _500)
    // }
}
// Main(12345613265)
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input){
	var X = parseInt(input,10);
  	var d = Math.floor(X/5);
  	var fhc = Math.floor(d/100);
  	var fc = d%100;
  	var res = (fhc * 1000) + (fc * 5);
	console.log(res);
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));
//  [javascript]
function Main(n) {
    if (n > 499) {
        let _n = Math.floor(n / 500);
        let _n2 = n % 500;
        let _n3 = Math.floor(_n2 % 5);
        console.log((_n * 1000) + (_n3 * 5));
    } else {
        console.log((Math.floor(n / 5) * 5));
    }
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function Main(n) {
    if (n > 499) {
        let _n = Math.floor(n / 500);
        let _n2 = n % 500;
        let _n3 = Math.floor(_n2 % 5);
        console.log((_n * 1000) + (_n3 * 5));
    } else {
        console.log((Math.floor(n / 5) * 5));
    }
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [go]
package main

import "fmt"

func main() {
	var money int
	fmt.Scan(&money)

	var coin500Num int = money / 500
	var rem int = money % 500
	var coin5Num int = rem / 5

	fmt.Println(coin500Num*1000 + coin5Num*5)
}
//  [go]
package main

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

func main() {
	nextReader = newScanner()
	x := nextInt()
	fmt.Println((x / 500 * 1000) + (x % 500 / 5 * 5))
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}
//  [go]
package main

import "fmt"

func main() {
  var X int
  fmt.Scan(&X)
  
  ans := (X/500)*1000 + (X-500*(X/500))/5*5
  fmt.Println(ans)
 
}
//  [go]
package main

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

func main() {
	sc := newScanner()
	var x = sc.readInt64()
	var ans int64
	ans += (x / 500) * 1000
	var r = x % 500
	ans += r * 5
	fmt.Println(ans)

}

//////////////////
//////////////////
//////////////////

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

func min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func reverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func reverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type scanner struct {
	bufScanner *bufio.Scanner
}

func newScanner() *scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &scanner{bufSc}
}

func (sc *scanner) readString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *scanner) readInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *scanner) readInt64() int64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseInt(text, 10, 64)
	if err != nil {
		panic(err)
	}
	return num
}
//  [go]
package main

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

func main() {
	sc := newScanner()
	var x = sc.readInt()
	var ans int
	ans += (x / 500) * 1000
	var r = x % 500
	ans += r * 5
	fmt.Println(ans)

}

//////////////////
//////////////////
//////////////////

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

func min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func reverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func reverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type scanner struct {
	bufScanner *bufio.Scanner
}

func newScanner() *scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &scanner{bufSc}
}

func (sc *scanner) readString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *scanner) readInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *scanner) readInt64() int64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseInt(text, 10, 64)
	if err != nil {
		panic(err)
	}
	return num
}
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

	x := nextInt()
	acount := x / 500
	bcount := x % 500 / 5
	println(acount*1000 + bcount*5)

}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
//  [ruby]
X = gets.to_i

puts X/500*1000 + X%500/5*5
//  [ruby]
num = gets.chomp.to_i
uresisa = 0

uresisa += (num/500) * 1000
num = num%500
uresisa += (num/5) * 5
num = num%5


puts uresisa
//  [ruby]
s = gets.to_i

count_500 = s / 500
rest_500 = s % 500
count_5 = rest_500 / 5

happy = (count_500 * 1000) + (count_5 * 5)

puts happy
//  [ruby]
x = gets.to_i

score = 0
score += x/500 * 1000
x = x/500
score += x/5 * 5

puts score
//  [ruby]
x,y=gets.split.map!(&:to_f)
s=gets.split.map!(&:to_i)
s=s.sort.reverse
max=s.sum
if s[y-1]>=(max/(4*y)).to_f
  puts "Yes"
else
  puts "No"
end
//  [ruby]
num = gets.chomp.to_i
uresisa = 0

uresisa += num/500
num = num%500
uresisa += num/5
num = num%5


puts uresisa
//  [rust]
use proconio::{fastout, input};

#[fastout]
fn main() {
    let mut x: usize;
    input! {x: usize};

    let five_handred_count = x / 500;
    let five_count = (x - five_handred_count * 500) / 5;

    println!("{}", five_handred_count * 1000 + five_count * 5);
}
//  [rust]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let x:u32 = read();
    let n1 = x / 500;
    let n2 = (x - n1 * 500) / 5;
    println!("{}", n1*1000+n2*5);
}
//  [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("failed 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 in_x: i32 = read();
    let a = in_x / 500;
    let b = (in_x % 500) / 5;

    println!("{}", a * 1000 + b * 5);
}
//  [rust]
fn main() {
    let x = read::<usize>();
    let x500 = x / 500;
    let x5 = x % 500;
    println!("{}", x500 * 1000 + x5 * 5);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}
//  [rust]
use std::io::Read;

fn main() {
    let i = input();
    println!("{}", solve(i));
}

fn input() -> usize {
    let mut buf = String::from("");
    std::io::stdin().read_line(&mut buf).unwrap();
    println!("buf = {}", buf);
    buf.pop();
    let i: usize = buf.parse().unwrap();
    i
}

fn solve(input: usize) -> usize {
    if input == 0 {
        return 0;
    }

    let number_500 = input / 500;
    let remain = input - (number_500 * 500);
    let number_5 = remain / 5;

    number_500 * 1000 + number_5 * 5
}
//  [rust]
use std::io::Read;

fn main() {
    let i = input();
    println!("{}", solve(i));
}

fn input() -> usize {
    let mut buf = String::from("");
    std::io::stdin().read_line(&mut buf).unwrap();
    println!("buf = {}", buf);
    buf.retain(|c| c != '\n');
    let i: usize = buf.parse().unwrap();
    i
}

fn solve(input: usize) -> usize {
    if input == 0 {
        return 0;
    }

    let number_500 = input / 500;
    let remain = input - (number_500 * 500);
    let number_5 = remain / 5;

    number_500 * 1000 + number_5 * 5
}
//  [swift]
import Foundation
var X = Int(readLine()!) ?? 0
var moneyArray = [0,0]

moneyArray[0] = (X/500)*1000
X = X%500 
moneyArray[1] = (X/5)*5
X = X%5

let happiness =  moneyArray.reduce(0){(num1: Int, num2: Int)  -> Int in
  return num1 + num2
}
print(happiness)
//  [swift]
import Foundation

var x = Int(readLine()!) ?? 0
var money = [0,0]
 
money[0] = (x / 500) * 1000
x = x % 500 
money[1] = (x / 5) * 5
x = x % 5
 
let happinessScore =  money.reduce(0) { (num1: Int, num2: Int) -> Int in
  return num1 + num2
}

print(happinessScore)
//  [swift]
import Foundation

var num:Int = Int(readLine()!)!
var joy = 0
while (num >= 500){
  num -= 500
  joy += 1000
}
while (num >= 5){
  num -= 5
  joy += 5
}
print(joy)
//  [swift]
import Foundation

var x = Int(readLine()!) ?? 0
var money = [0,0]
 
money[0] = (x / 500) * 1000
x = x % 500 
money[1] = (x / 5) * 5
x = x % 5
 
let happinessScore =  moneyArray.reduce(0) { (num1: Int, num2: Int) -> Int in
  return num1 + num2
}

print(happinessScore)
//  [swift]
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  ll x;
  cin >> x;
  ll ans = 0;
  ans += x / 500 * 1000;
  x %= 500;
  ans += x / 5 * 5;
  print(ans);
  return 0;
}
//  [typescript]
function main(input) {
    const lines = input.split("\n");
    const X = lines[0];

    const coin500 = Math.floor(X / 500);
    const mod = X % 500;
    const coin5 = Math.floor(mod / 5);
    const res = coin500 * 1000 + coin5 * 5;
    
    console.log(res);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
// inputに入力データ全体が入る
function Main(input) {
 
  let val = parseInt(input);
  let ans = Math.floor(val / 500) * 1000;
  val %= 500;
  console.log(ans + Math.floor(val / 5) * 5)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
const main = (input: string) => {
  const hasMoney = Number(input);

  let happyValue = Math.floor(hasMoney / 500) * 1000;
  const modMoney = hasMoney % 500;

  happyValue += Math.floor(modMoney / 5) * 5;

  console.log(happyValue);
}

// *この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
"use strict";

// B - Golden Coins
// https://atcoder.jp/contests/abc160/tasks/abc160_b

function Main(input) {
    const X = parseInt(input, 10);

    const count500 = X / 500;
    const modX = X % 500;
    const count5 = modX / 5;

    //出力
    console.log(count500 * 1000 + count5 * 5);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
class NormalInput {
  input: string[];
  pointer: number;
  constructor(raw: string) {
    this.input = raw.split(/ |\n/);
    this.pointer = 0;
  }
  int = (): number => {
    const ret = parseInt(this.input[this.pointer], 10);
    this.pointer++;
    return ret;
  };
  str = (): string => {
    const ret = this.input[this.pointer];
    this.pointer++;
    return ret;
  };
  strs = (length: number): string[] => {
    let ret: string[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.str());
    }
    return ret;
  };
  ints = (length: number): number[] => {
    let ret: number[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.int());
    }
    return ret;
  };
}

function Main({ int, str, strs, ints }: NormalInput) {
  const X=int();
  console.log(Math.floor(X/5))
}

//DO NOT EDIT
Main(new NormalInput(require("fs").readFileSync("/dev/stdin", "utf8")));
//  [python]
a,b,c = list(map(int, input().split()))
print("Yes" if a+b>=c else "No")
//  [python]
a, b, c = map(int, input().split())
if a + b >= c:
    print('Yes')
else:
    print('No')
//  [python]
#!/usr/bin/env python3
import sys
INF = float("inf")


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(A: int, B: int, C: int):
    if A+B >= C:
        yes()
    else:
        no()
    return


def main():

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


if __name__ == '__main__':
    main()
//  [python]
a,s,d=map(int, input().split())
print('Yes' if a+b>=c else 'No')
//  [python]
A, B, C = map(int, input().split())
print('Yes' if A+B*2 >= C else 'No')
//  [python]
A, B, C = map(int, input())
print('Yes' if A+B*2 >= C else 'No')
//  [java]
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Random;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		PrintWriter pw=new PrintWriter(System.out);
		int A=sc.nextInt();
		int B=sc.nextInt();
		int C=sc.nextInt();
		pw.println((A+B>=C)?"Yes":"No");
		pw.close();
	}

	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public int nextInt() {
    	return Integer.parseInt(next());
    }
    
    public long nextLong() {
    	return Long.parseLong(next());
    }
}
//  [java]
import java.util.Scanner;

public class Sample1_6 {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc1 = new Scanner(System.in);
		String line1 = sc1.nextLine();

		String[] inputText = line1.split(" ");

		int a = Integer.parseInt(inputText[0]) + Integer.parseInt(inputText[1]);
		int b = Integer.parseInt(inputText[2]);
		int c = a - b;

		if (c < 0) {
			System.out.print("No");
		} else {
			System.out.print("Yes");
		}
	}
}