Problem:
 Score : 200 points    Problem Statement Takahashi loves gold coins. He gains 1000  happiness points for each 500 -yen coin he has and gains 5 happiness points for each 5 -yen coin he has. (Yen is the currency of Japan.)  Takahashi has X yen. If he exchanges his money so that he will gain the most happiness points, how many happiness points will he earn?  (We assume that there are six kinds of coins available: 500 -yen, 100 -yen, 50 -yen, 10 -yen, 5 -yen, and 1 -yen coins.)      Constraints  0 \leq X \leq 10^9  X is an integer.         Input Input is given from Standard Input in the following format:  X       Output Print the maximum number of happiness points that can be earned.        Sample Input 1 1024      Sample Output 1 2020  By exchanging his money so that he gets two 500 -yen coins and four 5 -yen coins, he gains 2020 happiness points, which is the maximum number of happiness points that can be earned.       Sample Input 2 0      Sample Output 2 0  He is penniless - or yenless.       Sample Input 3 1000000000      Sample Output 3 2000000000  He is a billionaire - in yen.

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

X = int(input())
a = X // 500
rem = X - 500 * a
b = rem // 5

print(a * 1000 + 5 * b)

Solution (Python):
X = int(input())

print((X//500)*1000 + X%500//5*5)

Solution (Python):
X = int(input())
ans = X // 500 * 1000
X %= 500
ans += X // 5 * 5
print(ans)

Solution (Python):
X = int(input())

sum_num = (X//500)*1000
X %= 500
sum_num += (X//5)*5

print(sum_num)

Solution (Python):
x = int(input())


num_500 = x // 500
num_5 = (x % 500)//5

print(num_500*1000 + num_5*5)

Solution (Python):
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

x = int(input())
print((x//500)*1000 + ((x%500)//5)*5)

Solution (Python):
X = int(input())

ans = X//500 * 1000
X %= 500
ans += X//5 * 5

print(ans)

Solution (Python):
x = int(input())

a = x // 500

x -= 500 * a
b = x // 5

print(1000 * a + 5 * b)

Solution (Python):
import sys
input = sys.stdin.readline

X = int(input())

fh = X//500
f = (X%500)//5
print(fh*1000 + f*5)

Solution (Python):
X = int(input())
coin_500, amari = divmod(X,500)
coin_5, amari = divmod(amari, 5)

print(1000*coin_500 + 5*coin_5)

Solution (Python):
from sys import stdin, stdout 
from math import *
import itertools
import sys

x = int(input())
ans = 1000*(x//500)
x -= 500*(x//500)
ans += 5*(x // 5)
print(ans)

Solution (Python):
x = int(input())
a = x // 500
x -= 500*a
b = x // 5
print(1000*a + 5*b)

Solution (Python):
x = int(input())
ans = (x//500)*1000
x%=500
ans += (x//5)*5
print(ans)

Solution (Python):
x = int(input())

a = x // 500 * 1000
b = x % 500
c = b // 5 * 5

print(a+c)

Solution (Python):
X = int(input())
a = X % 500
b = a // 5
c = X // 500
print(c * 1000 + b * 5)

Solution (Python):
X = int(input())

ret = 0
ret += (X // 500) * 1000
X %= 500
ret += (X // 5) * 5

print(ret)

Solution (Python):
x = int(input())
ans = 0
ans += x//500*1000
x %= 500
ans += x//5*5
print(ans)

Solution (Python):

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

X = int(read())

q, r = divmod(X, 500)
answer = 1000 * q + (r // 5) * 5
print(answer)

Solution (Python):
x = int(input())
a = x//500 * 1000
x %= 500
b = x//5 * 5
print(a+b)

Solution (Python):
import math
x=int(input())
a=math.floor(x/500)
zan=x-500*a
b=math.floor(zan/5)
print(1000*a+5*b)

Solution (Python):
n = int(input())
a,b = divmod(n,500)
c = b // 5
ans = a * 1000 + c * 5
print(ans)

Solution (Python):
x = int(input())

c500 = x//500
x %= 500
c5 = x//5

print(1000*c500+5*c5)

Solution (Python):
x = int(input())
a = x // 500
b = (x-500*a) // 5
print(a*1000+b*5)

Solution (Python):
x=int(input())
print(1000*(x//500)+5*((x%500)//5))

Solution (Python):
X = int(input())
ans = 1000*(X//500)
X = X%500
ans += 5*(X//5)
print(ans)

Solution (Python):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    ct=0
    ct+=(n//500)*1000
    n=n-(n//500)*500
    ct+=n//5*5
    print(ct)
if __name__ == '__main__':
    do()

Solution (Python):
x = int(input())
ans = 0
ans += (x//500)*1000
ans += ((x%500)//5)*5
print(ans)

Solution (Python):
x = int(input())

go = x//500
x = x%500
f = x//5

print((go*1000)+(f*5))

Solution (Python):

import sys


def solve(X: int):
    x = X // 500
    y = X % 500 // 5
    print(int(x * 1000 + y * 5))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  
    solve(X)

if __name__ == '__main__':
    main()

Solution (Python):
X=int(input())
ans=(X//500)*1000
X%=500
ans+=(X//5)*5
print(ans)

Solution (Python):
X = int(input())
ans = 1000 * (X // 500) + 5 * ((X % 500) // 5)

print(ans)

Solution (Python):
x=int(input())
ans=x//500*1000
x%=500
print(ans+x//5*5)

Solution (Python):

x = int(input())
ans = x // 500 * 1000
x %= 500
ans += x // 5 * 5
print(ans)

Solution (Python):
x = int(input())
ans = x // 500
x -= ans * 500
ans *= 1000
ans += (x // 5) * 5
print(ans)

Solution (Python):
X = int(input())
a = X // 500
b = (X % 500) // 5
print(a * 1000 + b * 5)

Solution (Python):
import sys

def solve():
    X = int(input())
    L = (X // 500) * 1000
    X -= (X // 500) * 500
    L += (X // 5) * 5
    print(L)

    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
import sys
input=sys.stdin.readline
x=int(input())
y=x//500
ans=y*1000
x=x-y*500
z=x//5
ans+=z*5
print(ans)

Solution (Python):
X = int(input())
Y = X % 500

print(1000*(X//500) + 5 * (Y//5))

Solution (Python):
X = int(input())
print(X // 500 * 1000 + (X % 500) // 5 * 5)

Solution (Python):


import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(0)
	n = int(sys.stdin.readline())
	happy = 0
	happy += n // 500 * 1000
	n %= 500
	happy += n // 5 * 5
	n %= 5
	print(happy)

	


main()

Solution (Python):
x = int(input())
a = x//500
x = x-a*500
b = x//5
ans = 1000*a + 5*b
print(ans)

Solution (Python):
x=int(input())
c500=0
c5=0
while x>=500:
    c500+=1
    x-=500
while x>=5:
    c5+=1
    x-=5
print(c500*1000+c5*5)

Solution (Python):
def main():
    X = int(input())
    cnt_500 = X // 500
    cnt_5 = (X - 500 * cnt_500) // 5
    ans = cnt_500 * 1000 + cnt_5 * 5
    print(ans)





if __name__ == "__main__":
    main()

Solution (Python):
x = int(input())

five_h = x // 500
five = (x % 500) // 5

print(five_h * 1000 + five * 5)

Solution (Python):
X=int(input())

a=X//500
b=X%500
c=b//5

print(1000*a+5*c)

Solution (Python):
X = int(input())

ans = 0
ans += (X // 500) * 1000
ans += ((X % 500) // 5) * 5

print(ans)

Solution (Python):
n = int(input())
n500=n//500
n5=(n-n500*500)//5
ans=n500*1000+n5*5
print(ans)

Solution (Python):


x = int(input())

a = x//500
b = (x%500)//5

print(1000 * a + 5 * b)

Solution (Python):
x = int(input())
a = x // 500
b = (x % 500) // 5
print(a*1000+b*5)

Solution (Python):
x = int(input())

ans = 0
ans = (x//500)*1000
x = x % 500
ans += (x//5)*5
print(ans)

Solution (Python):
x = int(input())
a = x//500
x -= a*500
b = x//5
print(a*1000+b*5)

Solution (Python):
n = int(input())
x = (n//500)*(1000)
y = n%500
z = (y//5)*5
print(x+z)

Solution (Python):
X = int(input())
a = X // 500
Y = X - a * 500
b = Y // 5
print(a*1000+b*5)

Solution (Python):
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)


def get_nums_l():
    return [ int(s) for s in input().split(" ")]


def get_nums_n(n):
    return [ int(input()) for _ in range(n)]


def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

x = int(input())

ans = x // 500 * 1000
y = x % 500
ans += y // 5 * 5

print(ans)

Solution (Python):
X=int(input())
ans=X//500*1000
X%=500
ans+=X//5*5
print(ans)

Solution (Python):
X = int(input())
ans = 0
n = X//500
ans = 1000*n
X %= 500
n = X//5
ans += 5*n
print(ans)

Solution (Python):
x = int(input())
a = x // 500
b = (x % 500) // 5
print(a * 1000 + b * 5)

Solution (Python):
x=int(input())
ans=0

ans+=x//500*1000
x=x%500
ans+=x//5*5

print(ans)

Solution (Python):
x = int(input())
ans = 1000 * (x // 500)
ans += 5 * ((x % 500) // 5)
print(ans)

Solution (Python):
x = int(input())
r = x//500

l = (x-r*500)//5

print(r*1000 + l*5)

Solution (Python):
X = int(input())

m = X // 500
n = (X % 500) // 5
print(1000 * m + 5 * n)

Solution (Python):
X = int(input())

ans = 0
ans += (X // 500) * 1000

X %= 500

ans += (X // 5) * 5
print(ans)

Solution (Python):
x = int(input())
sum = 0
sum += (x//500)*1000
sum += ((x%500)//5)*5
print(sum)

Solution (Python):
def examA():
    S = SI()
    if S[2]==S[3] and S[4]==S[5]:
        print("Yes")
    else:
        print("No")
    return

def examB():
    X = I()
    ans = 0
    ans += (X//500) * 1000
    X %= 500
    ans += (X//5) * 5
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examB()

"""

"""

Solution (Python):
x=int(input())
print((x//500)*1000+((x%500)//5)*5)

Solution (Python):
x = int(input())

ans, xxx = divmod(x, 500)
ans *= 1000
ans += (xxx//5) * 5

print(ans)

Solution (Python):
x=int(input())
a=x//500
b=x%500
c=b//5
print(1000*a+5*c)

Solution (Python):
x = int(input())
f = x//500
amari = x-f*500
res = amari - amari%5
print(f*1000+res)

Solution (Python):
x=int(input())

n1000=x//500
n5=(x-500*n1000)//5
print(n1000*1000+n5*5)

Solution (Python):
n = int(input())
ans = 0
ans += 1000 * (n//500)
n -= (n//500) * 500
ans += n//5 * 5
print(ans)

Solution (Python):
x=int(input())
ans=0
ans+=1000*(x//500)
x-=500*(x//500)
ans+=5*(x//5)
print(ans)

Solution (Python):
x = int(input())
ans = (x // 500)*1000 + ((x%500)//5)*5
print(ans)

Solution (Python):
X = int(input())
ans = (X//500)*1000 + ((X%500)//5)*5
print(ans)

Solution (Python):
def main():
    x = int(input())
    ans = 1000*(x//500)
    x = x % 500
    ans += 5 * (x//5)
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
x=int(input())
u,v=divmod(x,500)
x,y=divmod(v,5)
print(1000*u+5*x)

Solution (Python):
x = int(input())
ans = 0
ans += x//500 *1000
x %= 500
ans += x//5 *5
print(ans)

Solution (Python):
x=int(input())
a=0
t=x//500
a+=t*1000
x=x-t*500
s=x//5
a+=s*5
print(a)

Solution (Python):
X = int(input())
ghk = X // 500
rest = X % 500
five = rest // 5
print(ghk * 1000 + five * 5)

Solution (Python):
x = int(input())
print(x // 500 * 1000 + (x % 500) // 5 * 5)

Solution (Python):
X = int(input())
num_500 = X // 500
X = X % 500
num_5 = X // 5
print(num_500 * 1000 + num_5 * 5)

Solution (Python):
x = int(input())
ans = x // 500 * 1000
ans+=(x % 500)//5*5
print(ans)

Solution (Python):



def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def check(s):
    for i in range(len(s)):
        if s[i] != s[len(s)-1-i]:
            return False
    return True

def main():
    x = ri()
    h1 = x//500
    x -= h1*500
    h2 = x//5
    print(h1*1000+h2*5)


if __name__ == '__main__':
    main()

Solution (Python):
x=int(input())
print((x//500)*1000+(x%500)//5*5)

Solution (Python):
X=int(input())
print(X//500*1000+(X%500)//5*5)

Solution (Python):
X = int(input())
a1 = int(X/500)
a2 = int((X % 500)/5)

print(a1*1000+a2*5)

Solution (Python):
x=int(input())
ans=0
ans+=(x//500)*1000
x=x%500
ans+=(x//5)*5
print(ans)

Solution (Python):
x = int(input())
score = 0
score += (x // 500) * 1000
score += ((x % 500) // 5) * 5
print(score)

Solution (Python):
x = int(input())
a = x // 500
b = x % 500
print(a*1000 + (b // 5)*5)

Solution (Python):
x=int(input())
a=0
a+=x//500*1000
x%=500
a+=x//5*5
print(a)

Solution (Python):
x = int(input())

a = x // 500
b = (x - a * 500) // 5
print(a * 1000 + b * 5)

Solution (Python):
x = int(input())

ans = 0
while x >= 500:
    ans += 1000
    x -= 500
while x >= 5:
    ans += 5
    x -= 5
print(ans)

Solution (Python):


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate
    
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    

    
    

    x = int(input())
    a = x // 500
    b = x %500
    c = b // 5
    print(a*1000+c*5)

if __name__ == '__main__':
    main()

Solution (Python):
X = int(input())

ans = (X // 500) * 1000
X %= 500

ans += (X // 5) * 5

print(ans)

Solution (Python):
n = int(input())

a = n//500
n = n-a*500
b = n//5
print(a*1000+b*5)

Solution (Python):
n = int(input())

a = n // 500
residue = n - 500 * a
b = residue // 5

ans = a * 1000 + b * 5
print(ans)

Solution (Python):

import sys
import math
import string
import collections
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)

X = int(input())

ans = 0
ans += 1000 * (X // 500)
X %= 500
ans += 5 * (X // 5)
print(ans)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

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

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    X = I()
    ans = 0
    ans += (1000 * (X // 500))
    X -= 500 * (X // 500)
    ans += (5 * (X // 5))
    print(ans)

main()

Solution (Python):

import sys
input = sys.stdin.readline

x = int(input())
gohyaku = x // 500
x %= 500
go = x // 5
print(gohyaku * 1000 + go * 5)

Solution (Python):
X = int(input())
print((X // 500) * 1000 + (X % 500) // 5 * 5)

Solution (Python):
x = int(input())
ans = x//500 * 1000
x %= 500
ans += x//5 * 5
print(ans)

Solution (Python):
x = int(input())
ans = 0
ans += (x//500)*1000
x %= 500
ans += (x//5) * 5
print(ans)

Solution (Python):

import sys


X = int(input())
ans = X//500 * 1000
if X%500>=5:
    ans += (X%500)//5 * 5
print(ans)

Solution (Python):
X = int(input())

ans = (X//500) * 1000
ans += (X%500) // 5 * 5

print(ans)

Solution (Python):
x = int(input())
a = x // 500
b = (x - 500 * a) // 5
print(1000*a+b*5)

Solution (Python):
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    
    ans = 0
    ans += (N//500)*1000
    rest = N%500
    ans += (rest//5)*5
    
    print(ans)    
    
    
if __name__ == "__main__":
    main()

Solution (Python):
X = int(input())

A1 = X // 500
X -= A1 * 500
A2 = X // 5
print(A1 * 1000 + A2 * 5)

Solution (Python):

X = int(input())
x = X//500
a = X%500
print(1000*x + 5*(a//5))

Solution (Python):
x = int(input())


print(1000 * (x // 500) + 5 * ((x % 500) // 5))

Solution (Python):
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n) 


def main():
    X = int(input())
    res = 0
    res += X // 500 * 1000
    X = X % 500
    res += X // 5 * 5
    print(res)


if __name__ == "__main__":
    main()

Solution (Python):
X = int(input())
h = X//500 * 1000
X = X%500
h += X//5 * 5
print(h)

Solution (Python):
x = int(input())
ans=0
ans+=x//500*1000
x%=500
ans+=x//5*5
print(ans)

Solution (Python):
x = int(input())

print(x//500 * 1000 + (x%500)//5*5)

Solution (Python):


X = int(input())

a = X // 500
x = X % 500
b = x // 5

print(a * 1000 + b * 5)

Solution (Python):
def main():
    x = int(input())
    q500, r = divmod(x, 500)
    q5, r = divmod(r, 5)
    ret = q500 * 1000 + q5 * 5
    print(ret)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
input=lambda: sys.stdin.readline().rstrip()
x=int(input())
a=x//500
b=(x%500)//5
print(a*1000+b*5)

Solution (Python):
X=int(input())
cnt500=X//500
cnt5=(X%500)//5
print(1000*cnt500+5*cnt5)

Solution (Python):
x = int(input())
a = x//500
x -= a*500
b = x//5
print(a*1000+b*5)

Solution (Python):
X = int(input())
k = X % 500
ans = (X // 500)*1000
ans += (k // 5)*5

print(ans)

Solution (Python):
X = int(input())

print((X//500)*1000+((X%500)//5)*5)

Solution (Python):
x=int(input())
a=x//500
b=x%500//5
print(a*1000+b*5)

Solution (Python):
x = int(input())
if x ==0:
    print(0)
    exit()

a = x//500
x -= 500*a
b = x//5

print(a*1000+b*5)

Solution (Python):

import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    X = II()
    print(X//500*1000+X%500//5*5)

if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
x=n//500
n-=x*500
y=n//5
print(1000*x+5*y)

Solution (Python):
x=int(input())
y=(x//500)
z=((x-y*500)//5)

print(y*1000+z*5)

Solution (Python):
x=int(input())
cta=x//500
x-=cta*500
ctb=x//5
print(cta*1000+ctb*5)

Solution (Python):

N = int(input())

ans = 0
ans += (N//500)*1000
ans += ((N%500)//5)*5

print(ans)

Solution (Python):
import sys
input = sys.stdin.readline

x = int(input())

ans = 0

a = x // 500

ans += a * 1000

x -= a * 500

ans += (x // 5) * 5

print(ans)

Solution (Python):
x=int(input())
print(x//500*1000+(x%500)//5*5)

Solution (Python):
X = int(input())
a,b = X//500,X % 500
print(a*1000+(b//5)*5)

Solution (Python):
s = int(input())
ans = s//500*1000
ans += s%500//5*5

print(ans)

Solution (Python):
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    X = ii()
    fh = X // 500
    fy = (X - (fh * 500)) // 5
    print(fh * 1000 + fy * 5)


if __name__ == '__main__':
    main()

Solution (Python):
X=int(input())
q1=X//500
r1=X%500
q2=r1//5
print(1000*q1+5*q2)

Solution (Python):



import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

X = int(input())
n500 = X // 500
X -= n500 * 500
n5 = X // 5
print(n500 * 1000 + n5 * 5)

Solution (Python):
import sys
import itertools
import bisect
from operator import itemgetter
 
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
ans = 0
ans += N//500 * 1000
N -= N//500 * 500
ans += N//5 * 5
print(ans)

Solution (Python):
x = int(input())
print((x//500)*1000 + ((x%500)//5)*5)

Solution (Python):
a = int(input())
print((a//500)*1000+((a%500)//5)*5)

Solution (Python):
X = int(input())

d, m = divmod(X, 500)

ans = d * 1000

d, m = divmod(m, 5)

ans += d * 5

print(ans)

Solution (Python):
x = int(input())

a = x // 500
x -= a * 500
b = x // 5
print(a * 1000 + b * 5)

Solution (Python):
import sys
input = sys.stdin.readline

X = int(input())

ans = X // 500 * 1000 + (X % 500) // 5 * 5
print(ans)

Solution (Python):
X = int(input())
a1 = X//500*1000
a2 = (X%500)//5*5
print(a1+a2)

Solution (Python):
x = int(input())
ans = (x // 500) * 1000
x %= 500
ans += (x//5) * 5
print(ans)

Solution (Python):
x=int(input())
a=x//500
b=(x-a*500)//5
print(a*1000+b*5)

Solution (Python):
x = int(input())

ans = 0
ans += int(x//500) * 1000
ans += int((x%500)//5)*5

print(ans)

Solution (Python):
X = int(input())
ans = 0
a = X // 500
ans += a*1000
X %= 500
b = X //5
ans += b * 5
print(ans)

Solution (Python):
x=int(input())

x500=x//500
nokori=x%500
x5=nokori//5

print(x500*1000 + x5*5)

Solution (Python):
import sys
input = sys.stdin.buffer.readline

N = int(input())

a = N // 500
N -= a * 500
b = N // 5

print(a * 1000 + b * 5)

Solution (Python):
n = int(input())
print(n//500*1000+(n%500)//5*5)

Solution (Python):
x=int(input())
a=x//500
b=x%500
c=b//5
print(1000*a+5*c)

Solution (Python):
X = int(input())
s500 = X//500
s5 = (X%500)//5
print(s500*1000+s5*5)

Solution (Python):
d,m=divmod(int(input()),500);print(d*1000+m-m%5)

Solution (Python):
X = int(input())
a = X//500
x = X - a * 500
b = x//5
print(a * 1000 + b * 5)

Solution (Python):
X = int(input())

a, b = divmod(X, 500)
c, d = divmod(b, 5)

print(a*1000 + c * 5)

Solution (Python):

X = int(input())
f = X // 500
ans = 0
ans += 1000 * f
X -= f * 500
f = X // 5
ans += 5 * f
print(ans)

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    X = I()
    ans = X//500*1000
    X -= X//500*500
    ans += X//5*5
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
X = int(input())

tmp1 = X // 500
tmp2 = (X - (X // 500) * 500) // 5
print(tmp1*1000+tmp2*5)

Solution (Python):



def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    

    def dump(*args):
        sys.stderr.write(str(args))

    x = int(input())
    print(x//500*1000+(x-x//500*500)//5*5)


if __name__ == '__main__':
    main()

Solution (Python):

X = int(input())

ans = X // 500 * 1000
X %= 500

ans += X // 5 * 5

print (ans)

Solution (Python):

x = int(input())

ans = 0
ans += (x // 500) * 1000
x -= 500 * (x // 500)
ans += (x // 5) * 5
print(ans)

Solution (Python):
X = int(input())

ans = (X // 500) * 1000
X %= 500

ans += (X // 5) * 5

print (ans)

Solution (Python):
x = int(input())

t = x // 500

x = x - t * 500

s = x // 5

print(t * 1000 + s * 5)

Solution (Python):
X = int(input())
n500 = X//500
n5 = (X-n500*500)//5
print(n500*1000+n5*5)

Solution (Python):
n = int(input())
print(n//500*1000+(n%500)//5*5)

Solution (Python):
x = int(input())
ans = 0
ans += x//500*1000
ans += x%500//5*5
print(ans)

Solution (Python):
x = int(input())
f = x // 500
print(f * 1000 + (x - (f * 500)) // 5 * 5)

Solution (Python):
x = int(input())
a = x//500
x -= a * 500
b = x // 5
print(1000*a + 5*b)

Solution (Python):












mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def main():
    x = int(input())
    ans = x // 500 * 1000
    x %= 500
    ans += x // 5 * 5
    print(ans)
    return

if __name__=='__main__':
    main()

Solution (Python):
X = int(input())
ans = 0
K = X//500
X -= 500*K
ans += 1000*K
L = X//5
ans += 5*L
print(ans)

Solution (Python):
X = int(input())
ans = 0
d = X // 500
ans += d * 1000
X -= d * 500
ans += X // 5 * 5
print(ans)

Solution (Python):
X = input()
print X/500*1000+X%500/5*5

Solution (Python):
X = int(input())
ans = 0
ans += (X // 500) * 1000
X %= 500
ans += (X // 5) * 5
print(ans)

Solution (Python):
n = int(input())
print(n//500*1000 + (n%500)//5*5)

Solution (Python):
def main():
    X = int(input())
    ans = X // 500 * 1000
    ans += (X % 500) // 5 * 5
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

po = 0

po += n//500 * 1000

n %= 500

po += n//5 * 5

print(po)

Solution (Python):
x = int(input())
a = x // 500
x -= 500 * a
b = x // 5
print(a * 1000 + b * 5)

Solution (Python):
x = int(input())

print((x//500)*1000+(x%500)//5*5)

Solution (Python):
def main():
    n = int(input())
    ans = 1000*(n//500)
    n %= 500
    ans += 5*(n//5)
    print(ans)


main()

Solution (Python):
x=int(input())
res = (x//500)*1000
x=x%500
res += (x//5)*5
print(res)

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    x = int(input())
    ans = 0
    ans += 1000 * (x // 500)
    ans += 5 * (x % 500 // 5)
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
X = int(input())
r = 0
r += (X // 500)*1000

X %= 500

r += (X // 5)*5

print(r)

Solution (Python):
x = int(input())

a = x//500
x -= a * 500
b = x//5

print(a*1000 + b*5)

Solution (Python):
x = int(input())

print(x // 500 * 1000 + (x % 500) // 5 * 5)

Solution (Python):
X = int(input())

num_500yen, r = divmod(X, 500)
num_5yen, _ = divmod(r, 5)

print(num_5yen * 5 + num_500yen * 1000)

Solution (Python):
x=int(input())
ans=(x//500)*1000
y=x%500
ans+=(y//5)*5
print(ans)

Solution (Python):
x = int(input())

ans = x // 500 * 1000
x -= x // 500 * 500
print(ans + x // 5 * 5)

Solution (Python):
x=int(input())
print((x//500) * 1000 + (x%500)//5 * 5)

Solution (Python):
X = int(input())

GG = X//500
X = X%500
G = X//5

print(1000*GG+5*G)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

x = INT()
ans500 = x // 500
x -= ans500 * 500
ans5 = x // 5
print(ans500 * 1000 + ans5 * 5)

Solution (Python):
X = int(input())
print(X//500*1000+X%500//5*5)

Solution (Python):
def main():
    x = int(input())
    total = 1000*(x//500)
    x %= 500
    total += 5*(x//5)
    print(total)
    


main()

Solution (Python):
def main():
    x = int(input())
    answer = (x // 500) * 1000
    x %= 500
    answer += (x // 5) * 5
    print(answer)


if __name__ == '__main__':
    main()

Solution (Python):
x = int(input())
y, r = divmod(x, 500)
z, r = divmod(r, 5)
print(y*1000+z*5)

Solution (Python):
x = int(input())
print((x // 500) * 1000 + (x % 500) // 5 * 5)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    X = int(input())

    y = X // 500
    X = X - y * 500
    z = X // 5
    print(y * 1000 + z * 5)


if __name__ == '__main__':
    main()

Solution (Python):
a = int(input())

ureshisa =  (a // 500) * 1000
a = a - 500 * (a // 500)
ureshisa += (a // 5) * 5
print(ureshisa)