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())
gohyaku = x // 500
x = x - gohyaku * 500
go = x // 5
u_max = gohyaku * 1000 + go * 5
print(u_max)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians

from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))
ZIP = lambda: zip(*(MAP() for _ in range(n)))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
   X = INT()

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


if __name__ == '__main__':
    main()

Solution (Python):

GBN_DEBUG = False
def dprn(s, i):
    if GBN_DEBUG: print(", " + s + " = " + str(i), end = "")
def dprns(s):
    if GBN_DEBUG: print(", " + s, end = "")
def dprni(i):
    if GBN_DEBUG: print(i, end=" ")
def endl(): 
    if GBN_DEBUG: print('')
def puts(s): print(s)




X = int(input())







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

print(c500 * 1000 + c5 * 5)

Solution (Python):


X = int(input())

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

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

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


w = x

tmp = int(x/500)

ans = tmp*1000
x = x-500*tmp

tmp = int(x/5)

ans = ans + tmp*5
print(ans)

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

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

x = int(input())

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

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

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

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

print(ans)

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

Solution (Python):
import sys

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

n = 0
while True:
    if X - 500 >= 0:
        n += 1000
    else:
        break
    X -= 500
while True:
    if X - 5 >= 0:
        n += 5
    else:
        break
    X -= 5
print(n)

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

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

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

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

Solution (Python):
import sys
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    x = int(input())
    cnt = 0
    if x >= 500:
        cnt += (x // 500) * 1000
        x %= 500
    if x >= 5:
        cnt += (x// 5)*5
        x %= 5 
    print(cnt)
    return

if __name__ == '__main__':
    main()

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

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

print(a*1000+b*5)

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

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

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

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

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

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

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

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

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

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

if __name__ == '__main__':
    resolve()

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

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

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

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

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




sho500 = X // 500
amari500 = X % 500
sho5 = amari500 // 5
amari5 = sho5 % 5

print(1000 * sho500 + 5 * sho5)

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

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

amari1=x//500
amari2=(x-amari1*500)//5


print(amari1*1000+amari2*5)

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


resolve()

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

coin = [500, 5, 100, 50, 10, 1]

ans = 0
for i in range(6):
    if i == 0:
        ans += (n // coin[i]) * 1000
    if i == 1:
        ans += (n // coin[i]) * 5
    n = n % coin[i]

print(ans)

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

print(1000 * a + 5 * b)

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

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

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

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

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

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


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

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

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

Solution (Python):


X = int(input())

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

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

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

print(1000*a+5*b)

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

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

Solution (Python):
x = int(input())
ure1000 = x // 500
ure5 = (x - (ure1000 * 500)) // 5

print(ure1000 * 1000 + ure5 * 5)

Solution (Python):

import sys


def solve(X: int):
    y500 = X // 500
    rest = X % 500
    y5 = rest // 5

    glad = y500 * 1000 + y5 * 5
    print(glad)
    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())
ans = 0

ans += (x//500)*1000

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

print(ans)

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

a = x // 500

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

print(a * 1000 + b * 5)

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

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

if __name__ == '__main__':
    main()

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

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

ans = 0

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

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

print(ans)

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

Solution (Python):

x = int(input())

v = 1000 * (x // 500)
x = x % 500

v += 5 * (x // 5)

print(v)

Solution (Python):
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

def main():
    x = ni()

    print(x // 500 * 1000 + ((x - (x // 500) * 500) // 5) * 5)
    
if __name__ == '__main__':
    main()

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

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

if __name__ == '__main__':
    main()

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


if __name__ == '__main__':
    main()

Solution (Python):

X = int(input())
gohyakuen = int(X / 500)
rest = X - gohyakuen * 500

goen = int(rest/5)

print(gohyakuen*1000 + goen*5)

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

A = X // 500

X = X % 500

B = X // 5

calc = A*1000 + B*5

print(calc)

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

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

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

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

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

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

Solution (Python):


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

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

    print((fivehundred * 1000) + (five * 5))

if __name__ == '__main__':
    main()

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

uresii = 0
uresii += (x // 500) * 1000
n = x % 500
uresii += (n // 5) * 5
print(uresii)

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

p = X // 500 * 1000

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

print(p)

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

Solution (Python):
X = int(input())
amari = X % 500

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

Solution (Python):

x = int(input())
happy = 0

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

print(happy)

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

if __name__ == "__main__":
    resolve()

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

Solution (Python):
n=int(input())
r,rem=divmod(n,500)
m=rem//5
print(r*1000+m*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())
a = x % 500
b = x // 500 * 1000

d = a // 5 * 5

print(b + d)

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

Solution (Python):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

X = i_i()

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

ans += int((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):
X = int(input())

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

Solution (Python):





def solv(X):
    n500 = X // 500
    n5 = (X % 500) // 5
    ans = 1000 * n500 + 5 * n5
    return ans


if __name__ == "__main__":

    
    
    X = int(input())
    ans = solv(X)

    print(ans)

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):
'''
Created on 2020/03/28

@author: fanta
'''
N = int(input())

out = 0

gohyaku,go = N // 500, (N % 500) // 5

out = 1000 * gohyaku + 5 * go

print(out)

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

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

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

happy_500 = x//500
x %= 500

happy_5 = x // 5

print(happy_500 * 1000 + happy_5 * 5)

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

num_500 = X // 500
num_5 = (X % 500) // 5

print(1000*num_500 + 5*num_5)

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

y500 = x // 500
tmp = x % 500
y5 = tmp // 5

print(y500 * 1000 + y5 * 5)

Solution (Python):
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
from functools import reduce
from operator import mul
from collections import Counter
import itertools


a = int(stdin.readline().rstrip())
b = int(a/500)
a -= b*500
c = int(a/5)
print(b*1000+c*5)

Solution (Python):
X = int(input())
c500, let = divmod(X, 500)
c5 , let = divmod(let, 5)
print(c500*1000 + c5*5)

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

big=X//500
X=X%500
small=X//5

print(big*1000+small*5)

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

goh = int(X/500)
goe = int((X-goh*500)/5)

print(goh*1000+goe*5)

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

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

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

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

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

answer=0

thousand=X//500
five=(X%500)//5

answer+=1000*thousand+5*five

print(answer)

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)

X = int(input())
div, mod = divmod(X, 500)
ans = div * 1000 + (mod//5)*5
print(ans)

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

L = X//500
ans = L*1000
remain = X%500

l = remain//5
ans += l*5

print(ans)

Solution (Python):





import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

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

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

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

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

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

x = ii()

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

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

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

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

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

ans = 0

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

print(ans)

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

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

print(a * 1000 + b * 5)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	X = II()
	ans = 0
	ans += (X // 500)*1000
	X = X % 500
	ans += (X // 5)*5

	print(ans)

if __name__ == '__main__':
	main()

Solution (Python):
def resolve():
    x = int(input())
    res = 0
    a, rest = divmod(x, 500)
    res += a * 1000
    a, rest = divmod(rest, 5)
    res += a * 5
    print(res)


resolve()

Solution (Python):




x=int(input())

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

print(ans)

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

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

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


if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

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

    ans += (X // 5) * 5

    print(ans)


if __name__ == "__main__":
    main()

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

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

Solution (Python):
x = int(input())
c = 0
if x >= 500:
    c += (x//500)*1000
    y = x%500
    c += (y//5)*5
else:
    c += (x//5)*5

print(c)

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

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

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

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

print(1000*a + 5*b)

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

Solution (Python):
def Main(X):
    a, b = divmod(X, 500)
    c, d = divmod(b, 5)
    return a * 1000 + c * 5

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

if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):
from sys import stdin
X = int(stdin.readline().rstrip())

ans = 0

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

print(ans)

Solution (Python):
import math
X = int(input())
ans = 0
tmp = X // 500
ans = tmp * 1000
X -= tmp * 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())

ii = X // 500
jj = (X-ii*500) // 5

print(1000*ii+5*jj)

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

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

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

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

print(a*1000 + b*5)

Solution (Python):

def main():
    x = int(input())
    gohyaku = x // 500
    x %= 500
    go = x // 5
    x %= 5
    print(gohyaku * 1000 + go * 5)
if __name__ == '__main__':
    main()

Solution (Python):
from math import ceil,sqrt
def main():
    
    
    
    
    
    
    
    
    
    
    
    n=int(input())
    x=n//500
    n%=500
    ans=1000*x
    x=n//5
    ans+=(5*x)
    print(ans)
    
    
    
    
    
    
    
    
    




    
if __name__ =="__main__":
    main()

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

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

result += a*1000 + b*5

print(result)

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

hundred = int(money / 500)
five = int((money - (500 * hundred)) / 5)

print(hundred * 1000 + five * 5)

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

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

s = X // 500
X = X -(s*500)
t = X //5

print(1000*s + 5*t)

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

Solution (Python):
X = int(input())
n_500_cooins = X // 500
n_5_coins = (X % 500) // 5

print(n_500_cooins * 1000 + n_5_coins * 5)

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

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

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

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

Solution (Python):
def main():
    m = int(input())
    num_500 = m // 500
    res = m % 500
    num_5 = res // 5
    print(num_500 * 1000 + num_5 * 5)



if __name__ == "__main__":
    main()

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

a = x // 500

nokori = x - a * 500

b = nokori // 5

print(a * 1000 + b * 5)

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

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

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

x500 = x //500
tmp = x - (x500 * 500)
x5 = tmp // 5
result = x500 * 1000 + x5 * 5
print(result)

Solution (Python):
import sys
import os
from io import BytesIO, IOBase






'''def sieve(n):
    if n < 2: return list()
    prime = [True for _ in range(n + 1)]
    p = 3
    while p * p <= n:
        if prime[p]:
            for i in range(p * 2, n + 1, p):
                prime[i] = False
        p += 2
    r = [2]
    for p in range(3, n + 1, 2):
        if prime[p]:
            r.append(p)
    return r'''


'''def divs(n, start=1):
    divisors = []
    for i in range(start, int(math.sqrt(n) + 1)):
        if n % i == 0:
            if n / i == i:
                divisors.append(i)
            else:
                divisors.extend([i, n // i])
    return divisors'''


'''def divn(n, primes):
    divs_number = 1
    for i in primes:
        if n == 1:
            return divs_number
        t = 1
        while n % i == 0:
            t += 1
            n //= i
        divs_number *= t
    return divs_number'''


'''def flin(d, x, default=-1):
    left = right = -1
    for i in range(len(d)):
        if d[i] == x:
            if left == -1: left = i
            right = i
    if left == -1:
        return (default, default)
    else:
        return (left, right)'''


'''def modpow(b,p,m):
    res=1
    b=b%m
    while(p):
        if p&1:
            res=(res*b)%m
        b=(b*b)%m
        p>>=1
    return res'''


'''def mod_inv(a,m):
    return modpow(a,m-2,m)'''


'''def ncr(n,r,m):
    res=1
    if r==0:
        return 1
    if n-r<r:
        r=n-r
    p,k=1,1
    while(r):
        res=((res%m)*(((n%m)*mod_inv(r,m))%m))%m
        n-=1
        r-=1
    return res'''


'''def ncrlis(n,r,m,fact):
    return (fact[n]*(mod_inv(fact[r],m)*mod_inv(fact[n-r],m))%m)%m'''


def xor1_n(n):
    d={0:n,1:1,2:n+1,3:0}
    return d[n&3]

def ceil(n, k): return n // k + (n % k != 0)
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(map(int, input().split()))
def lcm(a, b): return abs(a * b) // math.gcd(a, b)
def prr(a, sep=' '): print(sep.join(map(str, a)))
def dd(): return collections.defaultdict(int)
def ddl(): return collections.defaultdict(list)
def ddd(): return collections.defaultdict(collections.defaultdict(int))
 


 
BUFSIZE = 8192
 
 
class FastIO(IOBase):
	newlines = 0
 
	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = "x" in file.mode or "r" not in file.mode
		self.write = self.buffer.write if self.writable else None
 
	def read(self):
			while True:
					b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
					if not b:
							break
					ptr = self.buffer.tell()
					self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
			self.newlines = 0
			return self.buffer.read()
 
	def readline(self):
			while self.newlines == 0:
					b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
					self.newlines = b.count(b"\n") + (not b)
					ptr = self.buffer.tell()
					self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
			self.newlines -= 1
			return self.buffer.readline()
 
	def flush(self):
			if self.writable:
					os.write(self._fd, self.buffer.getvalue())
					self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
	def __init__(self, file):
			self.buffer = FastIO(file)
			self.flush = self.buffer.flush
			self.writable = self.buffer.writable
			self.write = lambda s: self.buffer.write(s.encode("ascii"))
			self.read = lambda: self.buffer.read().decode("ascii")
			self.readline = lambda: self.buffer.readline().decode("ascii")
 

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")













for _ in range(1):
    x=ii()
    res=x//500
    res*=1000
    res+=((x%500)//5)*5
    print(res)

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

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

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

happy = 0

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

print(happy)

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

print(1000*a+5*b)

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

gohyaku = n // 500
go = (n-(gohyaku*500))//5

print(gohyaku*1000 + go*5)

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

Solution (Python):

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

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

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

Solution (Python):

x = int(input())
ans, tmp = divmod(x, 500)
ans *= 2 * 500
ans += (tmp // 5) * 5
print(ans)

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

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


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(X):
    ans = 0
    ans += (X // 500) * 1000
    X %= 500
    ans += (X // 5) * 5
    return ans


def main():
    X = read_int()
    print(slv(X))


if __name__ == '__main__':
    main()

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

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

print(a*1000 + b*5)

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

Solution (Python):

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

Solution (Python):

x = int(input())

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

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

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

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

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

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

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

ans = 0

a = (x//500)

x -= a*500

b = (x//5)

ans = a*1000 + b*5

print(ans)

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

a=int(N//500)

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

print(a*1000+b*5)

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

five_hundred = X // 500
rest = X - 500 * five_hundred
five = rest // 5

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

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

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

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