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):
x = int(input())

gohyaku = x // 500
nokori = x - 500 * gohyaku
goen = nokori // 5

print(1000 * gohyaku + 5 * goen)

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

Solution (Python):
x = int(input())
gohyaku = x//500
amari = x-500*gohyaku
goen = amari//5
happy = gohyaku*1000 + goen*5
print(happy)

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

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

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

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

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

Solution (Python):
import sys,math
sys.setrecursionlimit(10**9)
from collections import defaultdict
 
IA = lambda: map(int,input().split())
IAS= lambda: map(str,input().split())


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

Solution (Python):
X = int(input())
if X<500:
    print(X//5*5)
else:
    h1 = X//500
    h2 = (X%500)//5
    print(h1*1000+h2*5)

Solution (Python):

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

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

yen_500 = x // 500
yen = x % 500
yen_5 = yen // 5

print(yen_500 * 1000 + yen_5 *5)

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

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

Solution (Python):
X=int(input())
u1=X//500

u2=(X%500)//5

print(u1*1000 + u2*5)

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

m500 = X // 500

m5 = (X-m500*500)//5

print(m500*1000+m5*5)

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

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

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

Large = X//500
Small = (X%500)//5

print(Large*1000 + Small*5)

Solution (Python):
from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
from fractions import gcd

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


def inp(): return int(sys.stdin.readline())


def inp_list(): return list(map(int, sys.stdin.readline().split()))


def lcm(x, y): return (x * y) // gcd(x, y)


X = inp()

cnt_1000 = X // 500
X -= cnt_1000 * 500

cnt_5 = X // 5
print(1000 * cnt_1000 + 5 * cnt_5)

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


n1 = n//500
n2 = (n-n1*500)//5

print(n1*1000 + n2*5)

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

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

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

Solution (Python):


def main():
    x = int(input())
    hap = x // 500 * 1000
    x -= hap // 2
    hap += x // 5 * 5
    print(hap)

if __name__ == '__main__':
    main()

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

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


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

Solution (Python):

N = int(input())

ans_500 = int(N/500)

ans_5 = N - (ans_500 * 500)
ans_5 = int(ans_5/5)

ans = ans_500*1000 + ans_5*5


print(ans)

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

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

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

Solution (Python):
x = int(input())
f = x //500
g = (x%500) //5

print(int(f*1000+g*5))

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

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

Solution (Python):
n=int(input())
if(n==0):
    print(0)
else:
    sum=0
    temp=n//500
    n=n-(temp*500)
    sum+=(temp*1000)
    if(n==0):
        print(sum)
    else:
        temp=n//5
        sum+=(temp*5)
        print(sum)

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

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

print(a*1000 + b*5)

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

Solution (Python):
def main():
    X = int(input())
    c500 = X // 500
    c5 = (X - c500 * 500) // 5
    print(c500 * 1000 + c5 * 5)

if __name__ == "__main__":
    main()

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

Solution (Python):
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp



class UnionFindEx:
    def __init__(self, size):
        
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'

def main():
    X = ii()
    ans = 0
    ans += X//500 * 1000
    X %= 500
    ans += X//5 * 5
    print(ans)


main()

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

h1 = (x // 500) * 1000
h2 = ((x % 500) // 5) * 5
print(h1 + h2)

Solution (Python):
X = int(input())
a = X // 500
b = (X % 500) // 5

print(1000*a + 5*b)

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

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

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

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

p = X//500
q= (X%500)//5

print(p*1000+q*5)

Solution (Python):
if __name__ == '__main__':
    
    s = int(input())
    hap = 0
    hap += int(s/500)*1000
    s -= int(s/500)*500
    hap += int(s/5)*5
    print(hap)

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

while x >= 500:
  x -= 500
  ans += 1000

while x >= 5:
  x -= 5
  ans += 5

print(ans)

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

result = 0

result += int(X/500) * 1000
X -= int(X/500) * 500

result += int(X/5) * 5

print(result)

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

a = 0

a += (y // 500)*1000

y = y - (y // 500)*500

a+= (y // 5)*5

print(a)

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

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

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

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

print(int(a*1000 + c*5))

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

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

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

print(ans)

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

fh = x // 500

r = max(x - (fh*500),0)

f = r // 5

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

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

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

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

print(a+b)

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

c500 = X//500
c5 = (X-c500*500)//5

print(c500*1000+c5*5)

Solution (Python):


import sys


def LI():
    return list(map(int, sys.stdin.buffer.readline().split()))


def I():
    return int(sys.stdin.buffer.readline())


def LS():
    return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()


def S():
    return sys.stdin.buffer.readline().rstrip().decode('utf-8')


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


def SRL(n):
    return [list(S()) for i in range(n)]


def MSRL(n):
    return [[int(j) for j in list(S())] for i in range(n)]




def main():
    x = I()

    yen500 = x // 500
    yen5 = (x - 500 * yen500) // 5

    ans = yen500 * 1000 + yen5 * 5

    print(ans)


main()

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

if __name__ == '__main__':
    main()

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

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

ans_500 = x // 500
ans_5 = (x % 500) // 5

print(ans_500 * 1000 + ans_5 * 5)

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

q1 = X // 500
mod1 = X % 500

q2 = mod1 // 5

print(q1 * 1000 + q2 * 5)

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

p, q = divmod(X, 500)
ans = 1000 * p + 5 * (q // 5)

print(ans)

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

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

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

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

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

print(res)

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

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

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

hap1 = N // 500
N -= hap1 * 500

hap2 = N // 5

print(hap1*1000 + hap2*5)

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

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

q, mod = divmod(X,500)

q2, mod2 = divmod(mod,5)

print(q*1000+q2*5)

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

uresen = x // 500 * 1000

urego = x % 500 // 5 * 5

print(uresen + urego)

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

Acoin=X//500
Bcoin=(X-500*Acoin)//5

print(Acoin*1000+Bcoin*5)

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

c500 = X // 500
zan = X - c500 * 500
c5 = zan // 5

print(c500 * 1000 + c5 * 5)

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

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

n_500 = X // 500

num = X - n_500 * 500

n_5 = num // 5

print(n_500 * 1000 + n_5 * 5)

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

s_500 = X // 500
x_500 = X % 500
s_5 = x_500 // 5

print((s_500 * 1000) + (s_5 * 5))

Solution (Python):
x = int(input())
u500 = 1000
u5 = 5

n500 = x // 500
n5 = (x%500)//5
a = n500*u500 + n5*u5
print(int(a))

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

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

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

Solution (Python):
l=[500,5]
ans=0
n=int(input())
ha=[1000,5]
for i in range(2):
  ans+=(n//l[i])*ha[i]
  n%=l[i]
print(ans)

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

happy500 = a//500
happy5 = (a%500)//5

print(happy500*1000 + happy5*5)

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

Solution (Python):
X = int(input())
A = X // 500
B = X - A*500
C = B // 5
print(A*1000+C*5)

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

fh = X // 500
fd = (X-500*fh)//5
delight = 1000*fh + 5*fd
print(delight)

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 += (X // 500)*1000
ans += ((X % 500)//5)*5
print(ans)

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

score += 1000*(n//500)
n = n%500

score +=  5*(n//5)

print(score)

Solution (Python):



X = int(input())

a = X//500

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

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

from decimal import *

























def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

inf = float('inf')
mod = 1000000007




def main():
	X = inputInt()
	ans = 0
	ans2 = 0

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

	ans2 += tmp // 5
	ans2 = ans2 * 5


	print(ans+ ans2)







def int_sqrt2(n):
    def f(prev):
        while True:
            m = (prev + n / prev) / 2
            if m >= prev:
                return prev
            prev = m

    return f(int(math.sqrt(n) * (1 + 1e-10)))



def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res


def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y



def H(n, r, mod=10**9+7):
	
	
    return combination(n+r-1, r, mod)

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        
        
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

if __name__ == "__main__":
	main()

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

ans1000 = X // 500
amari = X % 500
ans5 = amari //5

print(ans1000 * 1000 + ans5 * 5)

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

Solution (Python):
import sys

x = sys.stdin.readline()
x = int(x)

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

print(sum)

sys.stdout.flush()

Solution (Python):
if __name__ == '__main__':
	X = int(input())
	u1 = X // 500
	u2 = (X%500) // 5
	ans = u1 * 1000 + u2 * 5
	print(ans)

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

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

Solution (Python):

import sys


def solve(X: int):
    f=(X//500)*1000
    ft=((X%500)//5)*5
    print(f+ft)
    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())
print(x//500*1000+(x%500)//5*5)

Solution (Python):
def b160(x):

    ans = 0

    ans += (x // 500) * 500 * 2
    nokori = x % 500
    ans += (nokori // 5) * 5

    return ans

def main():
    x = int(input())
    print(b160(x))

if __name__ == '__main__':
    main()

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

c500 = m//500
c5 = (m - c500*500)//5

ans = c500 * 1000 + c5*5
print(ans)

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

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

print(a+b)

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

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

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

Solution (Python):
X = int(input())
n1 = X // 500
r = X % 500
n2 = r // 5

print(n1 * 1000 + n2 * 5)

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

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

result += 1000 * (X//500)
X -= 500 * (X//500)
result += 5 * (X//5)

print(result)

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

money_500 = X // 500
money_5 = (X % 500) // 5

print(money_500 * 1000 + money_5 * 5)

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

Solution (Python):


import sys
import math
import time

import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq


def dfs(s, prev, pre):
  val[s] += Ope[s] + prev
  for i in G[s]:
    if(i == pre):
      continue
    dfs(i, val[s], s)

def bfs(sx, sy, n):
  que = deque([[sy,sx]])
  while que:
    y,x = que.popleft()
    for i,j in D:
      if(x+i<0 or y+j<0 or x+i>W-1 or y+j>H-1):
        continue
      dist = G[y+j][x+i]
      if(G[y+j][x+i] != "X"):
        if(type(G[y+j][x+i]) is str):
          G[y+j][x+i] = G[y][x]+1
          que.append([y+j,x+i])
        elif(dist>G[y][x]+1):
          G[y+j][x+i] = G[y][x]+1
          que.append([y+j,x+i])
        

def combinations_count(n, r):
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))











X = int(input())
ans = 0

while True:
  if(X-500<0):
    break
  else:
    ans += 1000
    X -= 500

while True:
  if(X-5<0):
    break
  else:
    ans += 5
    X -= 5


print(ans)

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

ans = 0

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

print(ans)

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

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

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

x_500 = x//500
x_5 = (x%500)//5

ans = x_500*1000 + x_5*5

print(ans)

Solution (Python):
def main():
  s = int(input())

  num_500 = int(s /500)
  
  num_5 = int((s % 500) / 5)
  
  score = 1000 * num_500 + 5 * num_5 
  
  print(score)
main()

Solution (Python):



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

    r_500 = x // 500
    r_5 = (x % 500) // 5

    print(int(r_500 * 1000 + r_5 * 5))


if __name__ == '__main__':
    main()

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

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

Solution (Python):
X = int(input())
five_hund_num = int(X/500)
rem = X - 500*five_hund_num
five_num = int(rem/5)
result = 1000*five_hund_num+5*five_num
print(result)

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


happy = 1000*(a//500)
a=a%500

happy+= 5*(a//5)
print(happy)

Solution (Python):
X = int(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())
a, b = divmod(n, 500)
c, d = divmod(b, 5)
print((a*1000)+(c*5))

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

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

c1 = x // 500

x = x - 500*c1

c2 = x // 5

print(c1*1000 + c2*5)

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

happy = 0

yen_500 = int(X/500)
yen_5 = int((X-500*yen_500)/5)

print(1000*yen_500 + 5*yen_5)

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

big = X // 500
remX = X - big * 500
small = remX // 5

print(big * 1000 + small * 5)

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

Solution (Python):




x = int(input())


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

ans = x500 * 1000 + x5 * 5


print(ans)

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

while x >= 500:
    x -=500
    hp +=1000

while x >= 5:
    x -=5
    hp +=5

print(hp)

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

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

Solution (Python):

def solve():
    X = int(input())
    coin500 = X//500
    coin5 = (X % 500)//5

    print(coin500*1000+coin5*5)



if __name__ == "__main__":
    solve()

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

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

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

a = x // 500

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

print(a * 1000 + b * 5)

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

n500=N//500

N-=n500*500

n5=N//5

print(n500*1000+n5*5)

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

count_500 = X // 500
count_5 = (X-count_500*500) // 5

u = count_500 * 1000 + count_5 * 5
print(u)

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

    A = X // 500
    B = X % 500 // 5

    print(A * 1000 + B * 5)


if __name__ == "__main__":
    main()

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

ret = 0

ret += (X//500)*1000

X -= (X//500)*500

ret += (X//5)*5

print(ret)

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

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

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

Solution (Python):
import sys
import math
from collections import defaultdict
n=int(sys.stdin.readline())
ans=0
a,b=n//500,n%500
five=b//5
ans=a*1000+five*5
print(ans)

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

print(happiness)

Solution (Python):
X = int(input())
num_500 = X // 500
X -= num_500 * 500
num_5 = X // 5

print(num_500*1000 + num_5*5)

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

p = N // 500
q = N % 500

r = q // 5
s = q % 5

print(p*1000 + r*5)

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

Solution (Python):

X = int(input())

x = X // 500
y = (X % 500) // 5

happy = x * 1000 + y * 5
print(happy)

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

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

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

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

Solution (Python):
i = int(input())
five_h = i // 500
re_i = i % 500
five = re_i // 5
print(1000*five_h+5*five)

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

r1=X//500
r2=(X-500*r1)//5
re=r1*1000+r2*5
print(re)

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

n1 = x // 500
x = x % 500

n2 = x // 5
x = x % 5

print(1000 * n1 + 5 * n2)

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

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

y, z = divmod(X, 500)
temp = z // 5

print(y*1000+temp*5)

Solution (Python):
X = int(input())
result = 0
while X//500 != 0:
  X -= 500
  result += 1000
while X//5 != 0:
  X -= 5
  result += 5
print(result)

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

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

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

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

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

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

ans = 0
num = x//500
ans += 1000*num

num = (x-500*num)//5
ans += num*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())

value = (x//500)*1000
remaining = x%500

temp_rem = (remaining//5)*5

print(value+temp_rem)

Solution (Python):
X = int(input())
m = X // 500
n = X % 500
o = n // 5

ans = 1000 * m + 5 * o
print(ans)

Solution (Python):



n = int(input())

n500 = n // 500

n = n % 500

n5 = n // 5

print(n500*1000+n5*5)

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

v500 = x // 500

v5 = (x % 500) // 5





print(v500 * 1000 + v5 * 5)

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

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

Solution (Python):
n = int(input())
ans = n // 500 * 1000

n %= 500
ans += n // 5 * 5

print(ans)

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

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

ans = 0
temp = 0
ans = int(X/500) * 1000
temp = int(X%500)

ans = ans + int(temp/5) * 5
print(ans)

Solution (Python):
X = int(input())
big = X//500
Small = (X-500*big)//5

print(big*1000+ Small*5)

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

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

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

num_500 = int(x//500)
num_5 = int((x-500*num_500)//5)

ans = 1000*num_500 + 5*num_5

print(ans)

Solution (Python):
if __name__ == "__main__":
    X = int(input())
    U = 0
    U += (X // 500) * 1000
    X = X % 500
    U += (X // 5) * 5

    print(U)

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

if(X >= 500):
    ans = X//500*1000+((X-500*(X//500))//5)*5
    print(ans)
else:
    ans = (X//5)*5
    print(ans)

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

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

five_hundred = X // 500
five = (X % 500) // 5

print(five_hundred * 1000 + five * 5)

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

n_500 = n//500
n_5 = (n-n_500*500)//5

res = n_500*1000 + n_5*5


print(res)

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

n500, a500 = x // 500, x % 500
n5 = a500//5

print(n500*1000+n5*5)

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

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

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

Solution (Python):
X = int(input())
coin500 = X // 500
X -= 500 * coin500

coin5 = X // 5
print(coin500 * 1000 + coin5 * 5)

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

ans = 0

b = a % 500

c = int(a/500)

ans += c * 1000

d = int(b/5)

ans += d * 5

print(ans)

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

def main(X):

    happy500 = X // 500
    mod_happy = X % 500
    happy5   = mod_happy // 5

    return happy500 * 1000 + happy5 * 5

if __name__ == "__main__":

    answer = main(X)
    print(answer)

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

n_500, mod = divmod(X, 500)
n_5, mod = divmod(mod, 5)

print(n_500*1000 + n_5 * 5)

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

Solution (Python):

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

Solution (Python):

from sys import stdin, stdout


def read():
    x = stdin.readline().rstrip()
    return x


def __main__():

    q = int(read())

    a = q // 500
    b = q - a*500
    c = b // 5

    print(a*1000 + c*5)

__main__()

Solution (Python):
import sys
from math import factorial
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

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

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

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

ans = 0

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

Solution (Python):
x = int(input())
ans = 0
for f in range(x//500+1):
    if(x - 500 >= 0):
        x -= 500
        ans += 1000
for g in range(x//5+1):
    if(x - 5 >= 0):
        x -= 5
        ans += 5
print(ans)

Solution (Python):
x = int(input())
uresi = 0
while x >= 500:
    x = x - 500
    uresi += 1000

while x >= 5:
    x = x - 5
    uresi += 5

print(uresi)

Solution (Python):
x=int(input())
cnt1=0
cnt2=0
num500=x//500
num5=(x%500)//5
print(1000*num500+5*num5)

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

ans = 0

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

Solution (Python):
A = int(input())
B = A//500
C = A - (B*500)
D = C//5
print(B*1000+D*5)

Solution (Python):
S=int(input())
A = S//500
a =S%500//5

print(A*1000 + a*5)

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

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

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

total = 0
total += (n // 500) * 1000
total += ((n%500) // 5) * 5
print(total)

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

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

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

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

print(ans)

Solution (Python):
x=int(input())
num1=0
num2=0
while x>499:
  x=x-500
  num1+=1
while x>4:
  x=x-5
  num2+=1
print((1000*num1)+(5*num2))

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

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

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

Solution (Python):

import sys


def solve(X: int):
    a = X // 500
    print(a * 1000 + ((X - (500 * a)) // 5) * 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):
a=int(input())

num=int(a/500)
ans=int(num*1000)
a-=num*500

num=int(a/5)
ans+=int(num*5)

print(ans)

Solution (Python):


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

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