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

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

Solution (Python):
N = int(input())
NN = N // 500
MM = N % 500
LL = MM // 5

print(NN * 1000 + LL * 5)

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

print(ans+5*(x//5))

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

Solution (Python):
X = int(input())
q , mod = divmod (X , 500)
N = q * 1000
w, e = divmod (mod , 5)
S = w * 5
print (N + S)

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

ha_500 = int(x / 500)
ha_5 = int(int(x % 500) / 5)

print(ha_500 * 1000 + ha_5 * 5)

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

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

Solution (Python):
x=int(input())
ans=0
k=[500,5]
a1=x//500
x2=x%500
a2=x2//5
print(a1*1000+a2*5)

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

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

Solution (Python):
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

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

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


coin500 = money//500

coin5 = money%500//5

happiness = 1000 * coin500 + 5 * coin5
print(happiness)

Solution (Python):
X = int(input())
a = 0
b = 0

if X >= 500:
    a = X // 500 * 1000
    X = X % 500
    if X >= 5:
        b = X // 5 * 5
        print(a + b)
    else:
        print(a)
elif X >= 5:
    b = X // 5 * 5
    print(b)
else:
    print('0')

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

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

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

Solution (Python):
X = int(input())
T = X // 500
rem = X - 500 * T
F = rem // 5

print(1000*T + 5*F)

Solution (Python):
x=int(input())
y=x%500
z=y%5
a=(x-y)*2
b=(y-z)
print(a+b)

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

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

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

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

Solution (Python):

x=int(input())


a=int(x/500)


b=x-500*a


c=int(b/5)

print(1000*a+5*c)

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

fiveh=(X//500)*1000
rest=X-(X//500)*500
five=(rest//5)*5

print(fiveh+five)

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

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

Solution (Python):
X = int(input())
coin500, X = divmod(X, 500)
coin5, X = divmod(X, 5)
print(1000 * coin500 + 5 * coin5)

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

Solution (Python):
import math
total = int(input())
big_coins = math.floor(total/500)
small_coins = math.floor((total - 500 *big_coins) / 5)
print(big_coins * 1000 + small_coins * 5)

Solution (Python):
X=int(input())
fh=X//500
X%=500
f=X//5
print(fh*1000+f*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 = divmod(X, 500)
C, X = divmod(X, 5)
 
print((A * 1000) + (C * 5))

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

Solution (Python):


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

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

c1 = int(X/500)
c2 = int((X-(c1*500))/5)

print(c1*1000+c2*5)

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

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

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

print(A*1000+B*5)

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

a = int(n/500)
b = n - 500*a
b = int(b/5)

print(a*1000 + b*5)

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

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

A=a*1000+b*5

print(A)

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

main()

Solution (Python):
def main():
    X = int(input())
    
    pmax = int(X/500)
    ans = 0
    tmp = 0
    for p in range(pmax+1):
        q = int((X-500*p)/5)
        tmp = 1000*p + 5*q
        ans = max(ans,tmp)
    print(ans)

main()

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

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

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

a,b = divmod(x, 500)
c,d = divmod(b,5)
print(1000*a + 5*c)

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

        ans = 0

        coins = [500,5]
        happy = [1000,5]

        for i in range(2):
                ans += X//coins[i]*happy[i]
                X = X%coins[i]

        print("{}".format(ans))

if __name__=="__main__":
        main()

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

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


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

print(res)

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

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

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

def solve(x):
    coins = x
    happiness = 0
    t = coins // 500

    happiness += t * 1000
    coins -= t * 500

    h = coins // 5
    happiness += h * 5

    print(happiness)

solve(x)

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

Solution (Python):
from sys import stdin, setrecursionlimit


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


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

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

if X/500 > 0:
    a = 1000 * math.floor(X/500)
    b = 5 * math.floor((X%500)/5)
    print(a+b)
elif X/5 > 0:
    c = 5 * math.floor(X/5)
    print(c)
else:
    print('0')

Solution (Python):

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

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

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

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

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

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

a = int(money / 500) * 1000
money = money % 500
b = int(money / 5) * 5

print(a + b)

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

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

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

print(1000*a+5*b)

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

if x>=500:
  print(x//500*1000+(x%500)//5*5)
  
else:
  if x>=5:
    print(x//5*5)
    
  else:
    print(0)

Solution (Python):
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

x = ni()

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

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

soo = floor(X/500)
s = floor((X - 500 * soo)/ 5)
print(soo * 1000 + s * 5)

Solution (Python):
X = int(input())
h = 0
while X>=5:
    if X>=500:
        X-=500
        h+=1000
    elif X<500:
        X-=5
        h+=5
print(h)

Solution (Python):
X = int(input())
h = 0
while X>=0:
    if X>=500:
        X-=500
        h+=1000
    elif X<500:
        X-=5
        h+=5
print(h-5)

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

Solution (Python):
import sys

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

X = int(readline())

div_500,mod_500 = divmod(X, 500)
div_5,mod_5 = divmod(mod_500, 5)

print(div_500*1000 + div_5*5)

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

Solution (Python):


X = int(input())

a = int(X/500)
b = int((X-500*a)/5)
print("{}".format(1000*a+5*b))

Solution (Python):

import sys

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

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

Solution (Python):
def f(x):
    joy = x // 500 * 1000
    x %= 500
    joy += x // 5 * 5
    print(joy)

x = int(input())
f(x)

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

Solution (Python):
def main():
    g = int(input())
    p = (g // 500) * 1000
    l = (g % 500) // 5
    p += l * 5
    print(p)

if __name__ == '__main__':
    main()

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

J = (n//500) * 1000 + (n%500)//5 * 5

print(J)

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

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

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

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

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

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


ans = 0

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

print(ans)

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

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

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

Solution (Python):
import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
n=int(input())
ans=0
ans+=(n//500)*1000
n=n%500
ans+=(n//5)*5
print(ans)

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

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

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

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

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

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

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

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

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

print(ans)

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

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

print(a * 1000 + b * 5)

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

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

print(ans)

Solution (Python):
money = int(input())
happy = 0

while money >= 500:
    money -= 500
    happy += 1000

while money >= 5:
    money -= 5
    happy += 5

print(happy)

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

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

print(y*1000 + a*5)

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

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

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

print(a * 1000 + b * 5)

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

val1 = n//500

val2 = n-val1*500

val3 = val2//5

print(val1*1000 + val3*5)

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
input = lambda: sys.stdin.readline().strip()

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

main()

Solution (Python):
import itertools
import math
import fractions
import functools
x = int(input())
hp = 0

hp = x//500 * 1000
x = x - x//500 * 500

hp += x//5 *5
print(hp)

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

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

c1 = X//500
c2 = (X%500)//5

print(1000*c1 + 5*c2)

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

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

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

a, X= divmod(X, 500)

b, X= divmod(X, 5)

print(a * 1000 + b * 5)

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

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

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

c500, X = divmod(X, 500)
c5, X = divmod(X, 5)

print(c500 * 1000 + c5 * 5)

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

gh = X // 500
g = (X - gh * 500) // 5

print(gh * 1000 + g * 5)

Solution (Python):

x = int(input())

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

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

Solution (Python):

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

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

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

Solution (Python):
x= int(input());  s = 0
while(x>=5):
    if x >= 500:
        s += 1000;        x -= 500
    elif x >= 5:
        s += 5;        x -= 5
print(s)

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(1000*a+5*b)

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

Ureshisa = 0


FiveHundredCoins = X//500
Ureshisa += 1000*FiveHundredCoins


X -= 500*FiveHundredCoins
FiveCoins = X//5
Ureshisa += 5*FiveCoins

print(Ureshisa)

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

Solution (Python):
div500, rem = divmod(int(input()), 500)
print(div500 * 1000 + rem // 5 * 5)

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

Solution (Python):


money = int(input())
a,b = 0,0 
ln = divmod(money, 500) 
a = ln[0]
b = ln[1]//5
print(a*1000+ b*5)

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

five_hundred = (X//500)

rest = X % 500

five = rest // 5

happines = five_hundred * 1000 + five * 5
print(happines)

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

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

medal_500 = X // 500
medal_5 =  (X % 500) // 5

answer = medal_500*1000 + medal_5*5
print(answer)

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


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

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


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

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

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

num = [500, 5]

cnt = 0
while True:
    if X < 500:
        break

    X -= 500
    cnt+=1000

while True:
    if X < 5:
        break

    X -= 5
    cnt+=5

print(cnt)

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
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)]

sys.setrecursionlimit(1000000)
mod = 1000000007

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


if __name__ == "__main__":
    solve()

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

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

a = X // 500
aa = X - 500 * a
b = aa // 5

print(a * 1000 + b * 5)

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

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

print(result)

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

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

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

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

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

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

h=a//500

a=a-500*h

f=a//5

ans=h*1000+f*5

print(ans)

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

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

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

Solution (Python):







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

if __name__ == "__main__":
    main()

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

n_500 = x // 500
n_5 = (x%500)//5

grad = n_500 * 1000 + n_5 * 5

print("{}".format(grad))

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

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

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

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

Solution (Python):
X =int(input())
ans1,X = divmod(X,500)
ans2,X = divmod(X,5)
print(ans1*1000+ans2*5)

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

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

x500 = x // 500
x5 = (x - x500 * 500) // 5

print(x500 * 1000 + x5 * 5)

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

result = int(s/500) * 1000 + int((s%500)/5)*5

print(int(result))

Solution (Python):
a=input()
a=int(a)
result=0
while a>=500:
  a=a-500
  result=result+1000

while a>=5:
  a=a-5
  result=result+5
  
print(result)

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

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

q, mod = divmod(x, 500)
mmod = math.floor(mod/5)
ans = 1000*q + 5*mmod
print(ans)

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

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

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

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

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

Solution (Python):
from sys import stdin


def main():
    x = int(stdin.readline())
    a = x // 500
    b = (x - a * 500) // 5
    print(a * 1000 + b * 5)


if __name__ == "__main__":
    main()

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)//5
print(A*1000+B*5)

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

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

k1 = 500
k2 = 5

k1a = int(x/k1)
xx = x%k1
k2a = int(xx/k2)

ans = 1000*k1a + 5*k2a
print(str(ans))

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

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

print(1000*a+5*b)

Solution (Python):
q_500, mod_500 = divmod(int(input()), 500)
q_5, mod_5 = divmod(mod_500, 5)
print(1000 * q_500 + 5 * q_5)

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

def resolve():
    x=int(input())
    a,b=divmod(x,500)
    print(a*1000+(b//5)*5)
resolve()

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

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

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

Solution (Python):

"""
Created on Wed May  6 16:26:02 2020

@author: shinba
"""
X = int(input())

a = X//500

X -= a*500

b = X//5

happiness = a*1000 + b*5

print(happiness)

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

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

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

Solution (Python):


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

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

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

fi_hun = X // 500
fi_mod = X % 500

fi = fi_mod // 5

print(fi_hun * 1000 + fi * 5)

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

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

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

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

Solution (Python):



x = int(input())

happiness = 0
while x >= 5:
    if x >= 500:
        x -= 500
        happiness += 1000
    else:
        x -= 5
        happiness += 5

print(happiness)

Solution (Python):
import math

yen = int(input())
happiness = 0

if yen / 500 > 0:
    fivehandred_number = math.floor(yen / 500)
    happiness = happiness + (1000 * fivehandred_number)
    yen = yen - (500 * fivehandred_number)

if yen / 5 > 0:
    five_number = math.floor(yen / 5)
    happiness = happiness + (5 * five_number)

print(happiness)

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

print((math.floor(X/500))*1000+(math.floor((X%500)/5)*5))

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

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

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

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

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

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

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

coin1 = int(money / 500)
coin2 = int((money % 500) / 5)

print(coin1 * 1000 + coin2 * 5)

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

print(ans)

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

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

n500, a500 = divmod(x, 500)
n005, a005 = divmod(a500, 5)

print(n500*1000 + n005*5)

Solution (Python):
def function(args):
    X = int(args)
    ureshisa = 0
    div, mod = divmod(X,500)
    ureshisa += div*1000
    div, mod = divmod(mod,5)
    ureshisa += div*5
    
    return str(ureshisa)

if __name__ == '__main__':
    print(function(input()))

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

div500, mod500 = divmod(X, 500)
div5 = mod500 // 5

print(div500 * 1000 + div5 * 5)

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

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


main()

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

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

Solution (Python):
X = int(input())
hand = X//500
one = (X - hand*500)//5

ans = hand*1000 + one *5

print(ans)

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

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

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


if __name__ == '__main__':
    main()

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

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

ans += x // 5 * 5
x -= x // 5 * 5

print(ans)

Solution (Python):
n=int(input());print(2*n-n%500-n%5)

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

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

print(cnt)

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

ans = X // 500 * 1000

X %= 500

ans += X // 5 * 5

print (ans)

Solution (Python):
X = int(input())
ans_1 = 0
ans_2 = 0

A = X//500
X -= 500*A
ans_1 += A*1000
ans_1 += X//5*5

ans_2 = X//5*5
print(max(ans_1,ans_2))

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

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

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

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

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

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

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

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

ans = 0
if num >= 500:
    count = num/500
    num -= int(count)*500
    ans = int(count)*1000
if num >= 5:
    count2 = num/5
    ans += int(count2)*5
print(ans)

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

ans = 0
happpy500 = int( x / 500) * 1000
cnt500 = int( x / 500 )
happy5 =  int( ( x - ( 500 * cnt500 ) ) / 5 ) * 5

print(happpy500 + happy5)

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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    x = I()
    t = x // 5

    return t // 100 * 1000 + t % 100 * 5


print(main())

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  
def Is(): return map(int, input().split())  
def LI(): return list(map(int, input().split()))  
def TI(): return tuple(map(int, input().split()))  
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  
def LS(): return list(input())  
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

x = I()

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

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

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

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    x = II()

    t = x // 500
    x = x % 500

    t2 = x // 5
    
    print(1000*t + 5 * t2)


if __name__ == '__main__':
    solve()

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

hapiness = (money//500)*1000 + ((money%500)//5)*5
print(hapiness)

Solution (Python):
def main():
  X = int(input())
  ans = 0
  while True:
    if 0 <= X - 500:
      X = X - 500
      ans += 1000
    elif 0 <= X - 5:
      X = X - 5
      ans += 5
    else:
      break
  print(ans)

if __name__ == "__main__":
  main()

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

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

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

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

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

res = x // 500
res_ = x % 500

res2 = res_ // 5
print(res * 1000 + res2 * 5)

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
x = int(readline())

ans = 0

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

ans += x//5*5

print(ans)

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

y = x // 500
r = x % 500
z = r // 5

print(1000*y + 5*z)

Solution (Python):

import sys


def solve(X: int):
    happiness = 0
    gohyaku_maisuu, modulo = divmod(X, 500)
    happiness += gohyaku_maisuu * 1000
    happiness += (modulo // 5) * 5
    return happiness


def main():
    X = int(sys.stdin.readline().strip())  
    print(solve(X))


if __name__ == '__main__':
    main()

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

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

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

m = n // 500

n -= m*500

l = n // 5

print(m*1000 + l*5)