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

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

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

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

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

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

ans = 0

l500 = x // 500


x -= l500 * 500

l5 = x // 5

print(l500 * 1000 + l5 * 5)

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

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

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

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

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

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

ans = 0

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

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

Solution (Python):
money = int(input())
k_500 = money // 500
moneyb = money % 500
k_5 = moneyb // 5
print(k_500 * 1000 + k_5 * 5)

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

pt500=input_coin//500
pt500_left=input_coin%500
pt5=pt500_left//5
print(1000*pt500+5*pt5)

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

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

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

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

print(result)

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

S = n // 500
mod = n % 500
x = mod // 5

H = 1000 * S + x * 5
print(H)

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

Solution (Python):
def solve(string):
    x = int(string)
    return str(x // 500 * 1000 + x % 500 // 5 * 5)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

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

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

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

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

Solution (Python):
Coin = input()
coin = int(Coin)
five_hundred = 0
five = 0
while(coin>=500):
    five_hundred += 1
    coin -= 500
while(coin>=5):
    five += 1
    coin -= 5
print(five_hundred * 1000 + five * 5)

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

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

num_500 = int(money / 500)

remaining = int(money % 500)

num_5 = int(remaining / 5)

print('{}'.format(num_500 * 1000 + num_5 * 5 ))

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

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

x1 = x//500
x2 = x-(x1*500)
x3 = x2//5
print(x1*1000+x3*5)

Solution (Python):
def B():
    X=int(input())
    sum=0
    
    count500=int(X/500)
    sum+=count500*1000
  
    count5=int((X-(count500*500))/5)
    sum+=count5*5
    
    print(sum)
        
    
    
if __name__=='__main__':
    B()

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

while x >= 5:
    if x >= 500:
        cnt += 1000
        x -= 500

    elif x >= 5:
        cnt += 5
        x -= 5

print(cnt)

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

c5 = N //500
n = N%500
c1 = n //5 
print(c5*1000+c1*5)

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

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

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

Solution (Python):

import re
import math
import itertools
from copy import deepcopy
import fractions
import random
from heapq import heappop,heappush
import time
import os
import sys
import datetime
from functools import lru_cache
readline=sys.stdin.readline
sys.setrecursionlimit(2000)

alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s

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

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

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

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

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

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

print(int(d))

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

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

print(count)

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

Solution (Python):
def main():
    okane = int(input())
    five_handred = okane // 500
    okane -= five_handred * 500
    five = okane // 5
    print(five_handred * 1000 + five * 5)
if __name__ == '__main__':
    main()

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

ans = 0

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

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

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

res500 = int(x / 500)
res5 = int(x % 500 / 5)

print(res500 * 1000 + res5 * 5)

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

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

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

Solution (Python):
X = int(input())
happy = 0
while X >= 5:
  if X >= 500:
    happy += 1000
    X -= 500
    continue
  elif X >= 5:
    happy += 5
    X -= 5
    continue
  else:
    break
print(happy)

Solution (Python):
import math

m = int(input())

maisu_500 = m // 500
amari_50 = (m % 500)
maisu_50  = amari_50 // 5
happy = maisu_500*1000 + maisu_50*5

print(math.floor(happy))

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

print(ans)

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

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

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

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

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

a = x//500

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

print(a*1000+5*b)

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

sum, X = divmod(X, 500)
sum *= 1000
sum += X - (X % 5)

print(sum)

Solution (Python):
import sys

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


def solve():
    X = int(rl())
    ans = 1000 * (X // 500)
    X -= ans // 2
    ans += 5 * (X // 5)
    print(ans)


if __name__ == '__main__':
    solve()

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

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

print(ans)

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

Solution (Python):

"""
Created on Mon Mar 30 20:12:26 2020

@author: black
"""


X = int(input())
Hapiness = 0

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

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

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

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

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

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

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

Y = X//500
Z = (X-Y*500)//5

print(1000*Y+5*Z)

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

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

Solution (Python):
x = int(input())
point = 0
while x != 0:
    if x >= 500:
        result = x // 500
        summ = (500 * result)*2
        point = point + summ
        remainder = x % 500
        x = remainder
    if x >= 5:
        result = x // 5
        summ = 5 * result
        point = point + summ
        break;
print(point)

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

C500 = X // 500
X = X % 500
C5 = X // 5

print(C500*1000+C5*5)

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

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

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

Solution (Python):
x = int(input())
p = 0
while(True):
    if(500 <= x):
        p += 1000
        x -= 500
    elif(5 <= x):
        p += 5
        x -= 5
    else:
        break
print(p)

Solution (Python):

x = int(input())

fh = x // 500
mod = x - 500 * fh
f = mod // 5

print(fh*1000 + f*5)

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

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

x=int(n//500)
y=int((n-x*500)//5)

print(x*1000+y*5)

Solution (Python):

get = int(input())

s1 = int(get/500)
s2 = int((get%500)/5)

r1 = s1 * 1000
r2 = s2 * 5
print(r1+r2)

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

print((i//500)*1000+((i-(i//500*500))//5*5))

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

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

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


point += 1000 * (x // 500)
x %= 500


point += 5 * (x // 5)

print(point)

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

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

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

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

Solution (Python):
import math
numeric = int(input())
result = math.floor(numeric / 500)*1000
intermediate = numeric - math.floor(numeric / 500)*500
result = result + math.floor(intermediate / 5)*5
print(result)

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

Solution (Python):
n=int(input())
def covid(num):
  if num==0:
    return 0
  else:
    happy=0
    fund=num//500
    num-=fund*500
    happy+=fund*1000
    happy+=num//5*5
    return happy
print(covid(n))

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

Solution (Python):
X = int(input())
ans =0 
while(1):
    if X < 5:
        break
    elif X<500:
        tmp = X // 5
        ans +=tmp*5
        X = X% 5
    else:
        tmp = X // 500
        ans +=tmp*1000
        X = X %500
print(ans)

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

Solution (Python):
import math
import string
import collections
from collections import Counter


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


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor



dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

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

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

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

print(1000 * a + 5 * b)

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

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

Solution (Python):
x = int(input())
bigpleasure = (x//500)*1000
smallpleasure = ((x%500)//5)*5

print(bigpleasure+smallpleasure)

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

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

Solution (Python):
import math

X = int(input())
count = [0, 0]
count[0] = math.floor(X / 500)
count[1] = math.floor((X - (500 * count[0])) / 5)

print(count[0] * 1000 + count[1] * 5)

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

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

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

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

s = 0

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

print(s)

Solution (Python):

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

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

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

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

print(a + b)

Solution (Python):


from sys import stdin, stderr

def main():
   N = int(stdin.readline())

   res = (N // 500) * 1000
   
   N %= 500

   res += (N // 5) * 5
   
   print(res)

   return 0

if __name__ == '__main__': main()

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

y1 = x - x1*500
x2 = y1 //5

print(x1*1000 + x2* 5)

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

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

print(c500 * 1000 + c5 * 5)

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

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

print(ans)

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

Solution (Python):
import sys


def input():
    return sys.stdin.readline().strip()


X = int(input())

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

Solution (Python):

X = int(input())



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

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

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

x2, m2 = divmod(x,500)
x3, m3 = divmod(m2,5)
print(x2*1000+x3*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):
S = int(input())
SS = S//500
SSS = (S%500)//5
print(1000*SS + 5*SSS)

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

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

print(ans)

Solution (Python):
X=int(input())
res=0
if X!=0:
    tmp=X//500
    res=tmp*1000+((X-tmp*500)//5)*5
print(res)

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

Solution (Python):
num = int(input())
happiness = 0
num1 = num // 500
num2 = num % 500 

num3 = num2 // 5 

happiness += num1 * 1000 + num3 * 5








print (happiness)

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

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

noguchi = X // 500
goen = X % 500 // 5

print(noguchi * 1000 + goen * 5)

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

Solution (Python):
import collections

local = False
if local:
    file = open("B.txt", "r")

def inp():
    if local:
        return file.readline().rstrip()
    else:
        return input().rstrip()

X = int(inp())

count500 = X // 500
X-=count500*500
count5 = X // 5

print(str(1000*count500+5*count5))

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

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

happy = 0


num_500 = x // 500
happy += num_500 * 1000

x -= num_500 * 500


num_5 = x // 5
happy += num_5 * 5

x -= num_5 * 5

print(happy)

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

a = money // 500

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

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

Solution (Python):
from sys import stdin


inp = stdin.readline

t = int(inp().strip())

print(str(1000*(t//500) + 5*((t-500*(t//500))//5)))

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

coin_500 = X // 500
x = X % 500
coin_5 = x // 5
print(coin_500 * 1000 + coin_5 * 5)

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

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

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

print(ans)

Solution (Python):
a=input()
b=int(a)
takaH=0
while b>0:
    if b>=500:
        takaH+=1000
        b=b-500
    elif b>=5:
        takaH+=5
        b=b-5
    elif b>=100:
        b=b-100
    elif b>50:
        b=b-50
    elif b>=10:
        b=b-10
    else :
        b=b-1
print(takaH)

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

Solution (Python):
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations
import math

def main():
    N = int(input())
    result = math.floor(N / 500) * 1000
    result += math.floor((N % 500)/5)*5
    print(result)


if __name__ == "__main__":
    main()

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

def gold_calc(X):
    g_500=0
    g_5=0

    while X>=500:
        X-=500
        g_500+=1000

    while X>=5:
        X-=5
        g_5+=5
    
    return g_500+g_5

print(gold_calc(X))

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

Solution (Python):
import unittest


class TestB(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(1024), 2020)

    def test_2(self):
        self.assertEqual(think(0), 0)

    def test_3(self):
        self.assertEqual(think(1000000000), 2000000000)


def solve():
    x = read()
    result = think(x)
    write(result)


def read():
    return read_int(1)[0]


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(data):
    result = 1000 * (data // 500)
    data %= 500
    result += 5 * (data // 5)
    return result


def write(result):
    print(result)


if __name__ == '__main__':
    
    solve()

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

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

Solution (Python):
money = int(input(""))
hapiness = (money//500)*1000 + ((money%500)//5)*5

print(hapiness)

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

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

Solution (Python):
coin_values = [[500, 1000], [5, 5]]
result = 0
x = int(input().strip())
idx = 0
for coin, value in coin_values:
    result += value * (x // coin)
    x = x - x // coin * coin
  
print(result)

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

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

coin500 = X/500
coin5 = (X-coin500*500)/5

print coin500*1000+coin5*5

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

coin500 = X // 500

coin5 = (X - coin500 * 500) // 5

print(coin500 * 1000 + coin5 * 5)

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

Solution (Python):
def main():
    n = int(input())
    l = []
    
    if(n<0 or n>1000000000):
        main()
    
    
    if(n!=0):
        h1 = int(n/500)*1000
        ar = n - (int(n/500)*500)
        h1+=int(ar/5)*5
        h2 = int(n/5)*5
        
        l.append(h1)
        l.append(h2)
        print(max(l))
    else:
        print(0)

main()

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

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

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

ureshisa1 = X // 500
ureshisa2 = (X - 500*ureshisa1) // 5

print(ureshisa1 * 1000 + ureshisa2 * 5)

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

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

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

a = n // 500
b = (n % 500) // 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());
happy = 0;
x=0;
y=0;
z=0;

x = X // 500;
y = X % 500;
z = y // 5;
happy = x * 1000 + z * 5;
    
print(happy);

Solution (Python):
n = int(input())
count = 0
if n>=500 :
	a = int(n / 500)
	count += a * 1000
	n = n % 500

if n>=5 :
	a = int(n / 5)
	count += a * 5
	n = n % 5

print(count)

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

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

num = X // 500
num2 = (X - num * 500) // 5

print(1000 * num + 5 * num2)

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

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

coin500 = X // 500
surplus = X % 500

coin5 = surplus // 5

print(coin500 * 1000 + coin5 * 5)

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

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

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

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

print(ans)

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

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

ans += int(n/5)*5

print(int(ans))

Solution (Python):
import math

x = int(input())

s = math.floor(x / 500)
t = x%500
u = math.floor(t/5)

print(s*1000+u*5)

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

yen500 = int(yen / 500)
yen = int(yen - yen500 * 500)

yen5 = int(yen / 5)

print(int(yen500 * 1000 + yen5 * 5))

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

Solution (Python):
n = int(input())
count500 = 0
count5 = 0
praise = 0
while (n >= 500):
    n -= 500
    count500 += 1
while (n >= 5):
    n -= 5
    count5 += 1
print(count500 * 1000 + count5 * 5)

Solution (Python):
c5, c2 = (500, 5)
yens = int(input())
happiness = 0
if yens >= c5:
    happiness += (1000 * (yens // c5))
    yens %= c5
if yens >= c2:
    happiness += (5 * (yens // c2))

print(happiness)

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

div_500, mod_500 = divmod(n,500)
if mod_500 > 0:
    div_5, mod = divmod(mod_500, 5)
    print(div_500*1000 + div_5*5)
else:
    print(div_500*1000)

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

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

i = n % 500
happy = ((n//500)*1000 + (i//5)*5)

print(happy)

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

five_hundred=int(x/500)

five=int((x-five_hundred*500)/5)

print(five_hundred*1000+five*5)

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

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

print(ans)

Solution (Python):

import os

def remove_empty(target_list: list):
    empty_removed_list = [x for x in target_list if x]
    return empty_removed_list

def get_stdin_str_list():
    input_str = input().strip()
    input_str_list = input_str.split()
    return input_str_list

def get_stdin_int_list():
    input_str_list = get_stdin_str_list()
    input_int_list = list(map(int, input_str_list))
    return input_int_list

X = get_stdin_int_list()[0]
n_500 = int(X / 500)
X = X % 500
n_5 = int(X/5)

p = n_500*1000 + n_5*5
print(p)

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

Solution (Python):
def main():
    x = int(input())
    big_happy = x // 500
    amari = x % 500
    small_happy = amari // 5

    print(big_happy * 1000 + small_happy * 5)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

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

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

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

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

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

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

print(a * 1000 + b * 5)

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

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

Solution (Python):


import sys
import math
import collections
import itertools
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]

X = I()

ans = 0

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

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

print(ans)

Solution (Python):


import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]

X = I()

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


print(a*1000 + c*5)

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

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

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

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

c500 = x // 500
x %= 500
c005 = x // 5

print(c500 * 1000 + c005 * 5)

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

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

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

happy1 = x // 500 * 1000
amari = x % 500
happy2 = amari // 5 * 5

print(happy1 + happy2)

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

Solution (Python):

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

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

coin_type = [500,  5, 1]
exchange = []
for i in coin_type:
    count, X = divmod(X, i)
    exchange.append(count)


herty_point = exchange[0] * 1000 + exchange[1] * 5
print(herty_point)

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

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

print(ure)

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

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

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