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

Solution (Python):
s = int(input())
gohyaku = s//500
go=(s%500)//5

print(gohyaku*1000+go*5)

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

t = x // 500

x_new = x - 500 * t 

t_2 = x_new // 5

print(1000*t + 5 * t_2)

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

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

hap += 5 * (n // 5)
n %= 5

print(hap)

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

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

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

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

Solution (Python):
X = int(input())
x_500, mod_500 = divmod(X, 500)
x_5, _ = divmod(X - x_500 * 500, 5)
print(x_500 * 1000 + x_5 * 5)

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

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


if __name__ == '__main__':
    resolve()

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

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

print(res)

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

Solution (Python):



import sys


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


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

    num_500 = x // 500

    amari_500 = x % 500

    num_5 = amari_500 // 5

    ans = num_500 * 1000 + num_5 * 5

    print(ans)


if __name__ == "__main__":
    resolve()

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

Solution (Python):




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

    q1, x = divmod(X, 500)
    q2 = x // 5

    print(q1 * 1000 + q2 * 5)


if __name__ == '__main__':
    main()

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

p500 = N//500 * 1000
p5 = N%500//5 * 5

print(p500 + p5)

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

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

ans = 0

ans += (x//500)*1000

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

ans += (x//5)*5

print(ans)

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

Solution (Python):

n=int(input())
k=n//500
m=(n-k*500)//5
print(k*1000+5*m)

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

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

fivehundled = x // 500
x = x - (500 * fivehundled)

five = x // 5
x = x - (5 * five)

happy = (fivehundled * 1000) + (five * 5)
print(happy)

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

a = X // 500
X -= a * 500

b = X // 5

print( a * 1000 + b * 5 )

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

Solution (Python):
x=int(input())
y,mod=divmod(x, 500)
z,_=divmod(mod, 5)
print(y*1000+z*5)

Solution (Python):

import sys


def solve(X: int):
    n500 = X // 500
    n5 = (X - 500 * n500) // 5
    print(n500*1000 + n5 * 5)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  
    solve(X)

if __name__ == '__main__':
    main()

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

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

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

    b = X // 5


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

    return 0


if __name__ == '__main__':
    main()

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

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

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

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

print(ans)

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

    print(ans)
    

if __name__ == '__main__':
    main()

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

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

Solution (Python):
value = int(input())
num_500 = value // 500
value = value % 500
num_5 = value // 5

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

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

ans = 0

n = x // 500
x -= 500 * n
ans += n * 1000
n = x // 5
x -= 5 * n
ans += n * 5

print(ans)

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


while(1):
    if(x>=500):
        ure = ure+1000
        x = x-500
    elif(x>=5):
        ure = ure+5
        x = x-5
    else:
        break

print(ure)

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



if __name__ == "__main__":
    b()

Solution (Python):
n = int(input())
n = n - (n % 5)

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

print(1000 * a + 5 * b)

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

X = int(input())
ans = 0
a,b = divmod(X,500)
ans += a*1000
c,d = divmod(b,5)
ans += c*5
print(ans)

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

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

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

h = 1000 * (n // 500)

n -= 500 * (n // 500)

h += 5 * (n // 5)

print(h)

Solution (Python):
import sys

X = int(sys.stdin.readline().strip())

r1 = X // 500
r2 = (X - 500*r1) // 5

print(r1*1000 + r2*5)

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

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

Solution (Python):
[X] = map(int, input().split())
q, mod = divmod(X, 500)
modq, mod = divmod(mod, 5)
print(q * 1000 + modq * 5)

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


n500 = X // 500
x = X % 500

n5 = x // 5

print(n500*1000 + n5*5)

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

print(a * 1000 + b * 5)

Solution (Python):

X = int(input())


h = X // 500
f = (X - (500 * h)) // 5

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

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

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

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

d, mod = divmod(X, 500)
e = mod // 5
print(d * 1000 + e * 5)

Solution (Python):
import numpy as np

X = int(input())

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

print(1000 * A + C * 5)

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

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

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

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

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

n500 = X // 500
r = X - (n500 * 500)
n5 = r // 5

print(n500 * 1000 + n5 * 5)

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

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

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

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

fh = X//500
five = (X-500*fh)//5

ans = 1000*fh+5*five

print(ans)

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

X_500 = X // 500

X_5 = (X- (X_500 * 500))//5

print(X_500*1000 + X_5 * 5)

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

Solution (Python):

import sys


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



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  
    print(solve(X))

if __name__ == '__main__':
    main()

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

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

Solution (Python):
x = int(input())
five_h = x//500
rem = x%500
five = rem//5
print(five_h*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())
ans = 0
for i in [500, 5]:
    m = x // i
    x -= m * i
    if i == 500:
        ans += 1000 * m
    if i == 5:
        ans += 5 * m
print(ans)

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

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

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

N_500 = X // 500
mod_x = X - 500 * N_500
N_5 = mod_x // 5

ans = N_500 * 1000 + N_5 * 5

print(ans)

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

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

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

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

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

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

print(a * 1000 + b * 5)

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

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

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

Solution (Python):
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect




from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
input = sys.stdin.readline

sys.setrecursionlimit(2147483647)

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

if __name__ == '__main__':
  main()

Solution (Python):
R = 0
inp = int(input())
D = divmod(inp,500)
R += D[0] *1000
D = divmod(D[1],5)
R += D[0] *5
print(R)

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

n1 = x//500

n2 = (x%500)//5

print(n1*1000+n2*5)

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

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

a = X // 500 * 1000
b = 0
if X % 500 != 0:
    b = (X % 500) // 5 * 5
print(a + b)

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

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

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

score = 0
while(X >= 500):
    X -= 500
    score += 1000

while(X >= 5):
    X -= 5
    score += 5
print(score)

Solution (Python):
x=int(input())
fh, mod = divmod(x, 500)
f = mod // 5
ans = fh * 1000 + f * 5
print(ans)

Solution (Python):
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:input()

"""========main code==============="""

t=ii()
ans=0
k=t//500
ans+=(k*1000)
t-=(k*500)

p=t//5
ans+=p*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(a * 1000 + b * 5)

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

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

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

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

print(ok)

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

Solution (Python):
import sys
input = sys.stdin.readline
n=int(input())
a = n//500
b = n%500
b = b//5
print(a*1000+b*5)

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

fh=x//500
hy=(x-(500*fh))//5

print(fh*1000+hy*5)

Solution (Python):
import math
x = int(input())
thousand = math.floor(x/500)

y = x - 500*thousand

five = math.floor(y/5)

ans = 1000*thousand + 5 * five

print(ans)

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

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

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

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

Solution (Python):

x = int(input())

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

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

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

n = int(sys.stdin.readline().strip())
print(n // 500 * 1000 + (n % 500) // 5 * 5)

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

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

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

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

H = X //500
mod = X % 500

F = mod // 5

print(H*1000 + F*5)

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

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

Solution (Python):


import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

x = ni()
ans = 0

while x:
    if x // 500 == 0:
        ans += x // 5 * 5
        break
    else:
        ans += x // 500 * 1000
        x %= 500

print(ans)

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

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

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


s -= (s//500)*500

ans += (s//5)*5

print(ans)

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

happy_1 = X//500 * 1000 
happy_rest = (X % 500) // 5
happy_2 = happy_rest * 5

print(happy_1+ happy_2)

Solution (Python):
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
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 [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  x=I()

  ans=0
  while True:
    if x//500>0:
      ans+=(x//500)*1000
      x=x%500
    else:
      ans+=(x//5)*5
      return ans


print(main())

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

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

Solution (Python):
X = int(input())
result = 0
if X / 500 >= 1:
    result = int(X / 500) * 1000
    X = X % 500
if X / 5 >= 1:
    result += int(X / 5) * 5

print(result)

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

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

y500 = int(x/500)
y5 = int((x % 500)/5)

print(y500*1000+y5*5)

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

ans = 0

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

tmp = X // 5
ans += tmp * 5
X -= 5 * tmp

print(ans)

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

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

ans = 0

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

print(ans)

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

if X >= 500:
    a = X//500
    total += 1000 * a
    X -= 500 * a
if X >= 5:
    b = X//5
    total += 5 * b

print(total)

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

l = [500, 5]
ans = 0
ans += (X // 500) * 1000
X = X % 500
ans += (X // 5) * 5 
print(ans)

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

Solution (Python):
import math

s = int(input())

a = s // 500
b = s % 500

c = b // 5

ans = a * 1000 + c * 5

print(ans)

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

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

Solution (Python):
x = int(input())
a = x // 500
y = x % 500

b = y // 5

print(a*1000 + b*5)

Solution (Python):
import sys
import math
import collections
from collections import deque
x = int(input())




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

print(1000*a + 5*c)

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

Solution (Python):
from sys import stdin

def main():

    input = stdin.readline

    X = int(input())

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

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

Solution (Python):












x = int(input())

jpy500 = 0
jpy5 = 0

jpy500 = x//500
x -= 500*jpy500
jpy5 = x//5

ans = jpy500*1000 + jpy5*5
print(ans)

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

v500 = 0
v5 = 0

if X >= 500:
    v500 = X // 500
    X = X % 500

if X >= 5:
    v5 = X // 5
    
print(v500*1000 + v5*5)

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

n_500 = inp // 500
happy_500 = 1000 * n_500

res = inp - n_500 * 500
n_5 = res // 5
happy_5 = 5 * n_5

print(happy_5 + happy_500)

Solution (Python):
from sys import stdin
n = int(input())
k = n // 500
n = n- k*500
t = n // 5
print(1000*k + 5 * t)

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

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

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

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

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

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

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

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

print(sum)

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

q1, r1 = divmod(x, 500)
q2, r2 = divmod(r1, 5)

ans = q1 * 1000 + q2 * 5
print(ans)

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

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

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

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

print(ans)

Solution (Python):

X = int(input())

happiness = 0

gohyaku = X // 500
happiness += gohyaku * 1000
X -= 500 * gohyaku
go = X // 5
happiness += go * 5


print(happiness)

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

Solution (Python):
import sys
import math
import bisect

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

def main():
    n = int(input())
    print(solve(n))

if __name__ == "__main__":
    main()

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

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

coin = [500, 5,1]
num = []

for ic in coin:
    num.append(X//ic)
    X = X%ic

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

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

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



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

Solution (Python):
import sys
X=input()
MONEY=int(X)
BIG=MONEY//500
left=MONEY%500
SMALL=left//5
print(BIG*1000+SMALL*5)

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

print(ans)

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

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

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

Solution (Python):
X = int(input())
num500 = X//500
num5 = (X-500*num500)//5

print(num500*1000+num5*5)

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

    count = 0

    num1 = a // 500
    num2 = a % 500
    count = num1 * 1000
    num3 = num2 // 5
    count = count + num3* 5

    print(count)

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

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

over_fh = x // 500

under_fh = x % 500

ans = over_fh * 1000 + (under_fh // 5) * 5

print(ans)

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

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

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

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

c_500 = x//500

tmp = x%500

c_5 = tmp//5

print(1000*c_500+5*c_5)

Solution (Python):

"""
Created on Sat Mar 28 21:03:36 2020

@author: Kanaru Sato
"""

x = int(input())

countone = 0
counttwo = 0

while x >= 500:
    x = x-500
    countone += 1
while x >= 5:
    x = x-5
    counttwo += 1

ans = countone*1000 + counttwo*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())

q1, mod1 = divmod(X, 500)
q2, mod2 = divmod(mod1, 5)
print(1000*q1 + 5*q2)

Solution (Python):

"""
Created on Sat Mar 28 20:59:46 2020

@author: H_Hoshigi
"""

X = int(input())

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

print(n_500*1000 + n_5*5)

Solution (Python):

X = int(input())


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

Solution (Python):
def main():
    X = int(input())
    b_1 = X // 500
    b_2 = (X % 500) // 5
    print("{}".format(b_1*1000 + b_2*5))

if __name__ == '__main__':
    main()

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

Solution (Python):
x = int(input())
n500 = x // 500
r500 = x % 500
n5 = r500 // 5

print(n500 * 1000 + n5 * 5)

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

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

happy = 0
n500 = X // 500
happy += n500*1000
X -= n500*500
happy += (X // 5)*5

print(happy)

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

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

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

sum = (n//500)*1000
m = n % 500

sum += (m//5)*5

print(sum)

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

h_500 = x//500*1000
h_5 = (x%500)//5*5

print(h_500+h_5)

Solution (Python):
ans = int(input())
print((ans // 500 * 1000) + ((ans % 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):
from collections import deque
import heapq
import itertools
import math

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

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

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

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

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

Solution (Python):



def main():
    t = int(input())
    gohyaku = t // 500
    remain = t - gohyaku * 500
    goen = 0
    if remain > 0:
        goen = remain // 5
    print(gohyaku * 1000 + goen * 5)


if __name__ == '__main__':
    main()

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

Solution (Python):


from math import floor

x = int(input())

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

c = floor(b / 5)

print(a * 1000 + c * 5)

Solution (Python):

X = int(input())
ans = 0
while X>5:
    if X>=500:
        ans +=1000
        X-=500
    elif X>=5:
        ans += 5
        X-=5

print(ans)

Solution (Python):
from sys import stdin



X = int(input())

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

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

a=0
b=0

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

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

Solution (Python):
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True 
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

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

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

gohyaku = y//500
y -= gohyaku*500

goen = y//5

print(gohyaku * 1000 + goen * 5)

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

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

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

print(a*1000 + b*5)

Solution (Python):

n = int(input())

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

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

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

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

k = x // 500
y = x - (500*k)
z = y // 5

print(k*1000 + z* 5)

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

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

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

A = N // 500
B = (N % 500) // 5

print(A * 1000 + B * 5)

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

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

u1 = int(x / 500)
u2 = int((x - u1*500) / 5)

print(u1*1000 + u2*5)

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

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

f_hund = x // 500
amari = x - f_hund * 500
f_en = amari // 5

print(f_en * 5 + f_hund * 1000)

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

happy = 0
q, m = divmod(X, 500)
happy += q*1000

q, m = divmod(m, 5)
happy += q*5

print(happy)

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

a500 = x//500
a005 = (x%500)//5

ans = a500 * 1000 + a005 * 5

print(ans)

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

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

cnt_500 = X // 500
cnt_5 = (X - cnt_500 * 500) // 5

print(cnt_500 * 1000 + cnt_5 * 5)

Solution (Python):
def main():
    X = int(input())
    res = 0
    ct = X//500
    res += 1000 * ct
    X -= ct * 500

    ct = X //5
    res += 5 * ct
    print(res)
    

main()

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

Solution (Python):
import sys
x = int(sys.stdin.readline())

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

Solution (Python):




x = int(input())

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

print(ans)

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

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



one_time = input_line // 500



amari = input_line%500

two_time = amari // 5



print(one_time*1000+two_time*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
b = x % 500//5

print(a*1000+b*5)

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

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

Solution (Python):
input = raw_input

x = int(input())
d1 = x // 500
x -= d1 * 500
out = d1 * 1000

d2 = x // 5
out += d2 * 5

print(out)

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

Solution (Python):
def solve(x):
    res = 0
    res += (x // 500) * 1000
    x = x % 500
    res += (x // 5) * 5
    return res


def main():
    x = int(input())
    res = solve(x)
    print(res)


def test():
    assert solve(1024) == 2020
    assert solve(0) == 0
    assert solve(1000000000) == 2000000000


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

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

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

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

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

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

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

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

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

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

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

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

print(A*1000+B*5)

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

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

Solution (Python):
A = int(input())
total = 0
total += (A // 500) * 1000
A -= total / 2
total += (A // 5) * 5
print(int(total))

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

c_500 = X // 500
X -= X // 500 * 500
c_5 = X // 5

print(c_500 * 1000 + c_5 * 5)

Solution (Python):
x= int(input())
a = [500,100,50,10,5,1]
ans = 0
now = x
ans += (now//500)*1000
now = now%500
ans += (now//5)*5
print(ans)

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

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

gohyakuen = X // 500
goen = (X % 500) // 5

ans = gohyakuen * 1000 + goen * 5

print(ans)

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