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

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

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

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

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

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

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

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

Solution (Python):
import math

X = int(input())

num_500 = math.floor(X/500)
res = X - 500*num_500
num_5 = int(res/5)

happy = num_500*1000 + num_5*5
print(happy)

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

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

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

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

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

SOO = x // 500
S = ( x % 500 ) // 5

print( 1000 * SOO + 5 * S )

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

k = n//500
l = (n-500*k)//5

print(k*1000+ l*5  )

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

k = 0
l = 0
while n>=500:
  n = n-500
  k = k+1

  
while n>5:
  n -= 5 
  l += 1
  

print(k*1000+ l*5  )

Solution (Python):
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline().rstrip()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)

MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
input = sys.stdin.readline

X = I()
num500 = X//500
num5 = (X%500)//5
print(num500*1000+num5*5)

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

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

print(a * 1000 + b * 5)

Solution (Python):




X = int(input())


happy = 0


max_five_hundred = X//500
max_five = (X-(max_five_hundred*500))//5


print((max_five_hundred*1000)+(max_five*5))

Solution (Python):
def main():
	k = int(input())
	ans = 0
	nokori = 0

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

if __name__ == '__main__':
	main()

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

coin_1=0
coin_5=0
coin_500=0

def registar(nyukin,coin):
    oturi=nyukin-coin*int(nyukin/coin)
    return oturi,int(nyukin/coin)

x,coin_500=registar(x,500)

x,coin_5=registar(x,5)
x,coin_1=registar(x,1)


uresisa=coin_500*1000+coin_5*5
print(uresisa)

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

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

Solution (Python):
X = int(input())
coin_500 = X//500
X = X - coin_500*500
coin_5 = X//5

print(1000*coin_500 + 5*coin_5)

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

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

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

Solution (Python):
X=int(input())
k=divmod(X,500)[0]
l=divmod(divmod(X,500)[1],5)[0]
print(k*1000+l*5)

Solution (Python):


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

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10**6) 
import math
from copy import copy, deepcopy
from operator import itemgetter

from bisect import bisect_left, bisect, bisect_right

from collections import deque 



from collections import Counter

from itertools import accumulate

from heapq import heapify,heappop,heappush


def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds




X = int(input())




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

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

if __name__=='__main__':
    main()

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

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

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

print(HP)

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):
x = int(input())
h500 = x//500
h5 = (x%500)//5
print(h500*1000+h5*5)

Solution (Python):

import copy
import random
import bisect 
import fractions 
import math
import sys
import collections

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

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

X = int(input())
ans = 0

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

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

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

print(a)

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

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

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

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

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

shou_500 = int(X/500)
shou_5 = int((X-500*shou_500) / 5)

print(shou_500 * 1000 + shou_5 * 5)

Solution (Python):
import sys

x = int(input())

dai = x//500
syou = (x-500*dai)//5



ans = 1000*dai+5*syou
print(ans)

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

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

ans += 5 * (x // 5)

print(ans)

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

a = 0
b = 0
ans = 0

if N >= 500:
    a = (N // 500) * 1000
    b = ((N % 500) // 5) * 5
    ans = a + b
else:
    ans = (N // 5) * 5

print(ans)

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

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

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

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

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

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

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

n500,r500=divmod(X,500)
n50=r500//5
print(n500*1000+n50*5)

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

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

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

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

num_500 = int(x / 500)

amari = x - 500 * num_500

num_5 = int(amari / 5)

print(1000 * num_500 + 5 * num_5)

Solution (Python):


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    X = read_int()
    return (X//500)*1000+((X%500)//5)*5


if __name__ == '__main__':
    print(solve())

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

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

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

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

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

sen = X//500
X = X - sen * 500
go = X//5

print(sen*1000+5*go)

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



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

print(a*1000+b*5)

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

f_hund  =  int(sum / 500)

f = int((sum - f_hund*500) / 5)

print(f_hund*1000 + f*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
grad = 0

grad = 1000 * a + 5 * c
print(grad)

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

print(1000*a+5*e)

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

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

print (1000*a+5*b)

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

t = (x // 500)
x -= t * 500
f = (x // 5)

print(t*1000+f*5)

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

a1 = D // 500
a2 = (D - a1*500) // 5

print(a1*1000 + a2*5)

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

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

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

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

count500 = X // 500
Xremain = X - (500 * count500)
count5 = Xremain // 5

happy = (1000 * count500) + (5 * count5)
print(happy)

Solution (Python):
import math 
X = int(input())
M = math.floor(X/500)
L = X - M * 500
N = math.floor(L/5)
V = M * 1000 + N * 5
print(V)

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


def main():
    X = int(input())
    happy1 = (X - X % 500)*2
    happy2 = (X % 500-(X % 500 % 5))
    print(happy1+happy2)


if __name__ == '__main__':
    main()

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

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

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

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

Solution (Python):
from sys import stdin

x = int(stdin.readline().rstrip())
t = x // 500
f = (x % 500) // 5

print(1000 * t + 5 * f)

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 % 500 // 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())
luc=0
while X>=500:
  X-=500
  luc+=1000
while X>=5:
  X-=5
  luc+=5
print(luc)

Solution (Python):
s = int(input())
a = s // 500
b = (s-a*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())

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

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

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())
count500 = x // 500 
x -= 500 * count500
count5 = x // 5
print(count500*1000 + count5*5)

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

syou_500 = n//500
amari = n % 500
syou_5 = amari//5
print(syou_500*1000 + syou_5*5)

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

mod = X % 500
num = X//500

print(num * 1000 + mod // 5 * 5)

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

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

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

cumul = 0
cumul += (x / 500) * 1000
x %= 500

cumul += (x / 5) * 5

print cumul

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

useshisa = 0
n_500 = math.floor(X/500)
n_5 = math.floor((X-n_500*500)/5)

ureshisa = n_500*1000 + n_5*5

print(ureshisa)

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

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

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

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

Solution (Python):
X = int(input())
count_500 = X // 500
count_5 = (X - 500*count_500) // 5

print(count_500*1000+count_5*5)

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

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

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

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

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

print(H)

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

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

Solution (Python):

"""
Created on Tue Apr 28 21:57:46 2020
"""

import sys


sys.setrecursionlimit(10 ** 9)


mod = 10**9+7

N = int(input())



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

print(ans)

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

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

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

ans = 0

while 1:
    if x == 0:
        print(ans)
        break
    if x % 500 == 0:
        ans += 1000
        x -= 500
    elif x % 5 == 0:
        ans += 5
        x -= 5
    else:
        x -= 1

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

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

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

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

a=X//500

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

print(1000*a+5*b)

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

Solution (Python):
import math
X = int(input())
happiness = 0

happiness += math.floor(X / 500) * 1000
X -= 500 * math.floor(X / 500)
happiness += math.floor(X / 5) * 5
X -= 5 * math.floor(X / 5)
print(happiness)

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

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

hapiness =0

hapiness += (X // 500) * 1000
X = X % 500

hapiness += (X // 5) * 5

print(hapiness)

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

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

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

fivehundred = int(X/500)
five = int((X-fivehundred*500)/5)

total = 1000*fivehundred + 5*five

print(total)

Solution (Python):
if __name__ == '__main__':
    x = int(input())
    t = x // 500 * 1000
    f = (x % 500) // 5 * 5
    print(t + f)

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

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

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

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

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

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

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

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

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

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

print(siawase)

Solution (Python):
import math

x=int(input())

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

print(a+b)

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

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

Solution (Python):
import sys;input=lambda:sys.stdin.readline().rstrip();aint=lambda:int(input());ints=lambda:list(map(int,input().split()))
import math;floor,ceil=math.floor,math.ceil
from collections import deque
Yes=lambda b:print('Yes')if b else print('No');YES=lambda b:print('YES')if b else print('NO')
is_even=lambda x:True if x%2==0 else False

def main():
    x = aint()
    print((x//500)*1000+((x%500)//5)*5)

if __name__ == '__main__':
    main()

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

m=int(n/500)

k=int((n%500)/5)

total=1000*m+5*k

print(total)

Solution (Python):
import sys

n = int(input())

buf = 0            
m = 0               

if n == 0:
    print("0")
    sys.exit()

def check(x,buf):
    if x >= 500:
        m = x%500
        buf += (x//500)*1000
        buf = check(m,buf)
        return buf
    elif 0 < x >= 5:
        buf += (x//5)*5
        return buf
    else:
        return buf

kei = check(n,buf)
print(kei)

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

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

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

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

Solution (Python):

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

  ans = 0

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

  ans += (x // 5) * 5

  print(ans)

main()

Solution (Python):

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

  ans = 0

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

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

  print(ans)

main()

Solution (Python):

X = int(input())



def main():
    point = int((X/500)) * 1000
    remain = int(X % 500)
    point += int((remain/5)) * 5
    print(point)

main()

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

Solution (Python):
x=int(input())
gohyaku=0
if x >= 500:
    gohyaku=x//500
goen=(x-gohyaku*500) // 5
print((gohyaku*1000)+(goen*5))

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

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

Solution (Python):

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

Solution (Python):
def solve(x):
    result = 0
    fh_yen = x // 500
    x -= 500 * fh_yen
    result += 1000 * fh_yen
    f_yen = x // 5
    result += 5 * f_yen
    return result


if __name__ == "__main__":
    print(solve(int(input())))

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

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

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

Solution (Python):
x = int(input())
tho = x//500
x -= 500*tho

fiv = x//5
ple = 1000*tho + 5*fiv

print(ple)

Solution (Python):






import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]


def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr


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





X = inputI()

a = X//500

r = X%500

b = r//5

print(a*1000+b*5)

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

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

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

n_500 = x // 500
y = x % 500

n_5 = y //5

print(1000*n_500 + 5*n_5)

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

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

n500 = x//500
n5 = (x-n500*500) // 5

happy = 1000*n500 + 5*n5
print(happy)

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

num_500 = X // 500
num_5 = (X - 500 * num_500) // 5

print(1000 * num_500 + 5 * num_5)

Solution (Python):


S = int(input())
count = int(S / 500)
sum = 1000 * count
S = S - 500*count
sum = sum + 5*(int(S/5))
print(sum)

Solution (Python):


S = int(input())
count = int(S / 500)
sum = 1000 * count
S = S - 500*count
sum = sum + 5*(int(S/5))
print(sum)

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

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

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

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

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

Gold500 = int(X / 500)
Gold005 = int((X - (500 * Gold500)) / 5)
Y = Gold500 * 1000 + Gold005 * 5
print(Y)

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())
A=0
G=0
N=0
M=0
Z=0
N=int(X/500)
M=int(X%500)
Z=int(M/5)
N=N+Z
for i in range(0,N):
    if X>=500:
        X=X-500
        G=G+1000
    elif X>=5:
        X=X-5
        G=G+5
    else:
        break
        
print(G)

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

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

happy= 0
if X%500 >= 0:
    happy = X//500*1000
    X = X%500
else:
    pass

if X%5 >= 0:
    happy = happy + X//5*5
else:
    pass

print(happy)

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

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

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

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

Solution (Python):



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

Solution (Python):

X = int(input())

ans = 0
fh, mod = divmod(X, 500)
f, _ = divmod(mod, 5)

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

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

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

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

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

thou = X//500
fifth = (X-thou*500)//5

print(thou*1000 + fifth*5)

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

fivemillion = int(x / 500)
five = int((x % 500) / 5)

print(fivemillion * 1000 + five * 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())

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

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

Solution (Python):
X = int(input())
print(str( 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())
t = 0
while x >=500 :
    x = x - 500
    t += 1000
while x >=5 :
     x = x - 5
     t += 5
print(t)

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

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

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

GoHya = int(X/500)
Go = int((X-GoHya*500)/5)

happiness = int(GoHya*1000 + Go*5)
print(happiness)

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

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

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

print(a*1000+b*5)

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

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

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

Solution (Python):

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

Solution (Python):
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)


inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
from collections import deque, defaultdict, Counter
import math
import sys
sys.setrecursionlimit(10 ** 7)


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



def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


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


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


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


if __name__ == '__main__':
    main()

Solution (Python):

import sys
from collections import Counter
from itertools import permutations, combinations
from fractions import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)
inf = float("inf")

def input():
    return sys.stdin.readline()[:-1]

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    x = int(rl())
    a = 1000 * (x // 500)
    b = 5 * (x % 500 // 5) 
    print(a + b)
    
    
if __name__ == '__main__':
    solve()

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

Y = X//500
Z = X - Y*500
S = Z//5

ans = print(Y*1000 + S*5)

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

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

ureshisa = 0
ureshisa = int(X/500)*1000

X = X%500

ureshisa += int(X/5)*5

print(ureshisa)

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline
'''
n, m = map(int, input().split())
n = int(input())
A = list(map(int, input().split()))
for test in range(int(input())):
'''
inf = 100000000000000000  

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

Solution (Python):
x = int(input())
waru_500 = x // 500
amari = x % 500
waru_5 = amari // 5

print(waru_500 * 1000 + waru_5 * 5)

Solution (Python):


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

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

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

X = int(input())

up = X//500
down = (X%500)//5

print(1000*up + 5*down)

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


Q500,mod500=divmod(s,500)
Q5=mod500//5

URESHISA=Q500*1000+Q5*5

print(URESHISA)

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

Solution (Python):
import numpy as np


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


x = int(input())
solve()

Solution (Python):

import math


x = int(input())


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


print(score)

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

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

Solution (Python):


import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()


x = ni()

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):
x = int(input())
print(x//500*1000+x%500//5*5)

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