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())
hyaku = X // 500
amari = X % 500
go = amari // 5

print(hyaku * 1000 + go * 5)

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

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

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

print(1000*a + 5*c)

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

print(x * 1000 + (n - x * 500) // 5 * 5)

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

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

Solution (Python):
x = int(input())
d1, m = divmod(x, 500)
d2, _ = divmod(m, 5)

ans = d1 * 1000 + d2 * 5
print(ans)

Solution (Python):

"""
Created on Sat Mar 28 20:51:25 2020

@author: naoki
"""

X = int(input())

A = X // 500
remain = X % 500

B = remain // 5

print(A*1000 + B*5)

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

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

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

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

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

print(ans)

Solution (Python):
def calc(X):
    a = X // 500
    b = (X - 500 * a) // 5
    return a * 1000 + b * 5

X = int(input())
print(calc(X))

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

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

Solution (Python):
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


X = I()

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

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

Solution (Python):


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

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

if __name__ == "__main__":
    main()

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

total = 0

n = X // 500
total += n * 1000
X -= n * 500

n = X // 5
total += n * 5
X -= n * 5

print(total)

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

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

print(a*1000+5*b)

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

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

Solution (Python):



import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    a = N // 500
    b = N % 500 // 5
    print(a * 1000 + b * 5)
    return

main()

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

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):
def main ():
    x = int(input())
    n = x//500
    m = (x-n*500)//5
    ans = 1000*n + 5*m
    print(ans)




    
if __name__ == '__main__':
    main()

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

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

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

    ans = X // 500 * 1000

    X = X % 500

    ans += X // 5 * 5

    print(ans)


resolve()

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

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

Solution (Python):
import bisect
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29



def main():
    X = iRaw()
    d500 = X//500
    d5 = (X%500)//5
    return d500*1000+d5*5

if __name__ == "__main__":
    print(main())

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

Solution (Python):
x = int(input())
total = 0
a, b = divmod(x, 500)
total += a * 1000
c, d = divmod(b, 5)
total += c * 5
print(total)

Solution (Python):
import sys
import math
from functools import reduce
from operator import mul
sys.setrecursionlimit(10**6)

def InMap(): return list(map(int, sys.stdin.readline().split(' ')))
def In(): return int(sys.stdin.readline())
def InS(): return sys.stdin.readline()

X = In()
M = X // 500
X -= 500 * M
D = X // 5
print((M*1000)+(D*5))

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

fivehundred = X//500

remaining = X%500

five = remaining//5

print(fivehundred*1000 + five*5)

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

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 6)  
to_index = lambda x: int(x) - 1  
print_list_in_2D = lambda x: print(*x, sep="\n")  


def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

def MII_split():
    return map(int, input().split())

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())


def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

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


def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

X = input_int()

joy = 0
while X >= 500:
    X -= 500
    joy += 1000

while X >= 5:
    X -= 5
    joy += 5

print(joy)

Solution (Python):

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

print(u)

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

print(v // 500 * 1000 + (v % 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())
print(x//500 * 1000 + (x-(x//500)*500)//5 * 5)

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

print(ans)

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

ans = 0

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

z = x // 5
ans += z * 5

print(ans)

Solution (Python):
x = int(input())
c500, m = divmod(x, 500)
c5, m2 = divmod(m, 5)

print(c500*1000 + c5*5)

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

Solution (Python):


from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key



__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x



if __name__ == '__main__':
    X = intinput()

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

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

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

print(h)

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

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


if __name__ == '__main__':
    main()

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

ans = 0

ans += (s//500)*1000
s = s%500

ans += (s//5)*5

print(ans)

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

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

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

result = 0

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

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

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

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

ans = ans + (n//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())

A = X // 500

B = (X - A*500) // 5

print(A*1000 + B*5)

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

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

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

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

Solution (Python):


iim = lambda: map(int, input().rstrip().split())

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

    a, b = divmod(X, 500)
    ans = a * 1000
    a, b = divmod(b, 5)
    ans += a * 5
    print(ans)

if __name__ == "__main__":
    resolve()

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

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

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

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

print(sum)

Solution (Python):

from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

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

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

num_500 = X/500
remain = X%500

num_5 = remain/5

print num_500*1000 + num_5*5

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

Solution (Python):



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

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


if __name__ == "__main__":
    resolve()

Solution (Python):
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))


x = load()

c500 = 0
c5 = 0

while x >= 500:
    x -= 500
    c500 += 1

while x >= 5:
    x -= 5
    c5 += 1


print(c500 * 1000 + c5 * 5)

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

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

if __name__ == '__main__':
    solve()

Solution (Python):
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

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

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

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

    print(ans)

if __name__ == "__main__":
    main()

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

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

b = a // 500
cha = a % 500
c = cha // 5
d = 1000 * b + c * 5
print(d)

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

Solution (Python):
import math
import copy
from copy import deepcopy
import sys
import fractions

from functools import reduce

import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)







def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList




x = int(input())

ans = 0

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

Solution (Python):

import sys
import math
import numpy as np
import itertools

x = int(input())

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

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

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

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


n_500 = X // 500
X -= 500 * n_500


n_5 = X // 5
X -= 5 * n_5

print(1000 * n_500 + 5 * n_5)

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

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


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):


import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

X = INT()

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

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

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
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 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 = float('inf')
mod = 10 ** 9 + 7

x = INT()

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

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

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

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

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

ans += 5*(x // 5)

print(ans)

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

gohyaku = X // 500
X = X % 500

go = X // 5
X = X % 5

print(gohyaku*1000 + go * 5)

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

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

Solution (Python):

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

Solution (Python):
import sys

x = int(input())

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


print(a * 1000 + c * 5)

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

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

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

print(ans)

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

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

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

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

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

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

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

Solution (Python):
import string
def num():
    return int(input())
def nums():
    return list(map(int,input().split()))

X = num()
bc = X // 500
sc = (X - (bc*500)) // 5
print( bc * 1000 + sc * 5)

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

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

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

print(ans)

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

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

Solution (Python):
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

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

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

x = n_in()

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

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

if __name__ == "__main__":
    main()

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

Solution (Python):
import sys
import math
import numpy

x = int(input())

e = int(x / 500)
f = int((x - 500*e) / 5 )

print(e*1000 + f * 5)

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

x = int(input())
memo = math.floor(x / 500)
ans = memo * 1000 + math.floor((x - memo * 500) / 5) * 5
print(ans)

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

s = x//500
t = x%500
k = t//5

print(int(s*1000+k*5))

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

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

n = X // 500
m = X % 500 // 5

print(1000 * n + 5 * m)

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

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

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

Solution (Python):
def II():return int(input())
def MI():return map(int,input().split())
def LI():return list(MI())
def ok():print("Yes")
def ng():print("No");exit()

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

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

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

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

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

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

ans = 0

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

print(ans)

Solution (Python):
import sys
INF = 10 ** 11
MOD = 10 ** 9 + 7
from collections import deque
sys.setrecursionlimit(100000000)
from heapq import heapify,heappush,heappop   

def main():
    x = int(input())
    a = x//500
    x -= a * 500
    b = 0
    if x > 0:
        b += x//5
    ans = 1000 * a + 5 * b
    print(ans)

if __name__=='__main__':
    main()

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

q1, r = divmod(x, 500)

q2 = r // 5
print(q1 * 1000 + q2 * 5)

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

Solution (Python):
x=int(input())
ans=0
d,m=divmod(x,500)
ans+=d*1000
d,_=divmod(m,5)
ans+=d*5
print(ans)

Solution (Python):


MOD = 10**9
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

X = int(input())

go = X//500

ans = go*1000

nokori = (X - go*500)//5

ans += nokori*5

print(ans)

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

res = 0

tmp = X//500
res += tmp * 1000
X -= tmp * 500

tmp = X//5
res += tmp * 5

print(res)

Solution (Python):
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

X = ir()
hundred, remain = divmod(X, 500)
five = remain  // 5
answer = 1000 * hundred + 5 * five
print(answer)

Solution (Python):


X = int(input().split()[0])
t = 0
t += (X // 500) * 1000
t += ((X % 500) // 5) * 5
print(t)

Solution (Python):
from sys import stdin
def main():
    readline=stdin.readline
    x=int(readline())
    y=x//500
    print(y*1000+((x-y*500)//5)*5)
        
if __name__=="__main__":
    main()

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

n_500 = x // 500

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

print(n_500*1000+n_5*5)

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

ans = 0

num = X // 500
X -= 500 * num
ans += num * 1000

num = X // 5
ans += num * 5

print(ans)

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

Solution (Python):

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

Solution (Python):


X = int(input())
ans = 0

div, mod = divmod(X, 500)
ans += 1000 * div
ans += 5 * (mod // 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())
happy500=x//500
happy5=(x-(x//500)*500)//5
print(happy500*1000+happy5*5)

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


if __name__ == "__main__":
    main()

Solution (Python):



def solve(*args: str) -> str:
    x = int(args[0])
    a = x//500
    b = (x-(500*a))//5

    return str(1000*a+5*b)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

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

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

yen_500 = x // 500
yen_50 = (x - yen_500 * 500) // 5
answer = yen_500*1000 + yen_50*5

print(answer)

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

a = X // 500
b = X % 500


print(a * 1000 + (b//5)*5)

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

amari = x % 500
gyaku = x // 500

go = amari // 5

print(gyaku*1000 + go*5)

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

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

print(a+b)

Solution (Python):



import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

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

Solution (Python):
if __name__ == '__main__':
    x = int(input())

    five_hundred = x // 500
    fives = (x % 500) // 5

    print(five_hundred * 1000 + fives * 5)

Solution (Python):

import sys


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

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

Solution (Python):

X = int(input())

a=X//500

b=X%500

c=b//5

print(1000*a+5*c)

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

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

Solution (Python):

MOD = 10 ** 9 + 7
INFI = 10**10

import math

import itertools



import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default




def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)


def main():
    n=int(input())
    go=n//500
    aaa=n-go*500
    go2=aaa//5
    print(1000*go+5*go2)




if __name__ == "__main__":

    main()

Solution (Python):


X=int(input())

N=X//500

M=(X-N*500)//5

print(N*1000+M*5)

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

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

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

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

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


main()

Solution (Python):



from math import *
from copy import *
from string import *				
from random import *				
from bisect import *				
from sys import stdin				
from sys import maxsize
from operator import *				
from itertools import *
from collections import Counter		
from collections import defaultdict 

'''

'''

def solve(l):
	n = len(l)
	

N = int(stdin.readline())
ans = 0
ans += 1000*(N//500)
mod = N%500
ans += 5*(mod//5)
print(ans)

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