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())
 
div = int(X/500)
mod = int(X%500)
hap = 0
 
if div != 0:
  hap = div*1000
q = int(mod/5)
hap += q*5
 
print(hap)

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

Solution (Python):
def main():
    x = int(input())
    five_hundreds, zan = divmod(x, 500)
    fives = zan // 5
    print(five_hundreds*1000+fives*5)

main()

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

Obaek = int(X / 500)
X %= 500
Oen = int(X/5)

print (Obaek * 1000 + Oen * 5)

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

Solution (Python):
def resolve():
    x = int(input())
    n500, x = divmod(x, 500)
    n5 = x // 5
    res = n500 * 1000 + n5 * 5
    print(res)


if __name__ == "__main__":
    resolve()

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


if __name__ == "__main__":
    resolve()

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



if __name__ == "__main__":
    resolve()

Solution (Python):
input_int=int(input())
five_h_y=0
five_y=0

five_h_y=int(input_int/500)
input_int=input_int-500*five_h_y

five_y=int(input_int/5)

print(five_h_y*1000+five_y*5)

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

Solution (Python):
from collections import deque
s = int(input())

big = int(s/500)
s = s- big*500

print(big*1000 +int(s/5)*5)

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

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


if 0<=x and x< 5:
    print(0)

if 5<= x and x<500:
    print((x//5)*5)

if x >= 500:
   f = x//500
   a = x % 500
   if 5<= a:
       b = a//5
       print(f*1000 + b*5)
   else:
        print(f*1000)

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

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

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

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

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

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

stdin = sys.stdin

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

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

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

Solution (Python):


X = int(input())

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

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

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

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

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

Solution (Python):



import sys
sys.setrecursionlimit(10000000)


dxdy=((1,0),(0,1))

def pin(type=int):
    return map(type,input().rstrip().split())

def resolve():
    t,=pin()
    print(1000*(t//500)+5*((t%500)//5))
"""         


"""
"""
お前カッコ閉じ,るの忘れてるだろ
"""
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1024"""
        output = """2020"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """0"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1000000000"""
        output = """2000000000"""
        self.assertIO(input, output)


if __name__ == "__main__":
    resolve()

Solution (Python):
cash = int(input().rstrip())
point = cash // 500 * 1000
cash %= 500
point += cash // 5 * 5
print(point)

Solution (Python):
cash = int(input().rstrip())
                             

point = cash // 500 * 1000
cash %= 500


point += cash // 5 * 5
cash %= 5

print(point)

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

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

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

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

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


main()

Solution (Python):
def solve_uresisa(cash,uresisalist):
    coins = uresisalist.keys()
    uresisa = 0
    for coin in coins:
        uresisa += cash//coin * uresisalist[coin]
        cash = cash % coin
    return uresisa

uresisalist = {500:1000,5:5}
cash = int(input())
print(solve_uresisa(cash,uresisalist))

Solution (Python):
x = int(input())
HP = 0
FUCK = False

if x < 5:
  print(0)
  FUCK = True

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

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

if not FUCK:
    print(HP)

Solution (Python):
a = int(input())
q_1, mod = divmod(a, 500)
q_2 = mod // 5
print(q_1 * 1000 + q_2 * 5)

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

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

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

print(1000*num_500 + 5*num_5)

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

Fivehundred_yen = X // 500
Balance = X % 500

five_yen = Balance // 5

total_happy = Fivehundred_yen * 1000 + five_yen * 5
print(total_happy)

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

c500 = X //500

X -= c500 * 500

c5 = X // 5


print(c500*1000+c5*5)

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

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

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

glad = 0

coins = [500,5]

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

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

print(glad)

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

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

c500 = X // 500
X %= 500
c5 = X // 5

print(c500*1000 + c5*5)

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

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

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

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

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())
a,b=divmod(x,500)
print(a*1000+(b//5)*5)

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

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

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

ans += (X//5) * 5

print(ans)

Solution (Python):


x = int(input())

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

Solution (Python):
import sys

x=int(sys.stdin.readline())
ans=x//500*1000
ans+=((x%500)//5)*5

print(ans)

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

Solution (Python):
def int_input():
    return int(input())
  
yens = int_input()

if yens >= 500:
  yens_500 = yens // 500
  yens_5 = (yens % 500) // 5
  happiness_pts = (yens_500 * 1000) + (yens_5 * 5)
  print(happiness_pts)
else:
  print((yens//5) * 5)

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

while yen - 500 >= 0:
    yen -= 500
    count += 1000

while yen - 5 >= 0:
    yen -= 5
    count += 5

print(count)

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

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

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

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

k = a // 5

print((s * 1000) +( k * 5))

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

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

c500 = x // 500
ans += c500 * 1000
x -= c500 * 500
c50 = x // 5
ans += c50 * 5

print(ans)

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

A = int(X/500)
U = int(A*1000 + (X - A*500)//5*5)

print(U)

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

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

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

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

Solution (Python):
def five_h(x):
  count = 0
  count += int(x / 500) * 1000
  x -= int(x / 500) * 500
  count += int(x / 5) * 5
  return count

def main():
  x = int(input())
  count = 0
  
  if(x <= 10 ** 9 and x >= 0):
    if(isinstance(x, int)):
      count += five_h(x)
      print(count)

if __name__ == "__main__":
  main()

Solution (Python):
import math

line = input()
money = int(line)
happy = 0

calc_500 = math.floor(money / 500)

if calc_500 >= 1:
  happy += calc_500 * 1000
  money -= calc_500 * 500
  calc_5 = math.floor(money / 5)
  
  if calc_5 >= 1:
      happy += calc_5 * 5
      print(str(happy))
  else:
      print(str(happy))
else:
    calc_5 = math.floor(money / 5)
    if calc_5 >= 1:
      happy += calc_5 * 5
      print(str(happy))
    else:
      print(str(happy))

Solution (Python):



X = int(input())

count_500, X = divmod(X, 500)
count_5 = X // 5

print(count_500 * 1000 + count_5 * 5)

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

b = 1000*(C//500)
mod = C % 500
s = 5*(mod//5)
print(b+s)

Solution (Python):
S = open(0).read().strip('\n')
q = int(S) // 500
mod = int(S) % 500 //5
print(q*1000+mod*5)

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

a = int(en/500)
b = int(en%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())
coin500 = x//500
x%=500
coin5 = x//5
print(coin500*1000+coin5*5)

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

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

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

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

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

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

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

Solution (Python):








if __debug__:
    debug = lambda *x: None
else:
    import logging
    logger = logging.getLogger()
    logger.setLevel(logging.DEBUG)
    ch = logging.StreamHandler()
    ch.setLevel(logging.DEBUG)
    formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    ch.setFormatter(formatter)
    logger.addHandler(ch)
    debug = logger.debug

x = int(input())

debug(x)

c500 = int(x / 500)
xx = x % 500
c5 = int(xx / 5)

u = c500 * 1000 + c5 * 5

print(u)

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

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

Solution (Python):
x = int(input())
five_hun = 0
five = 0
score = 0

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

Solution (Python):
sum1 = 0
Coin500 = 500
Coin100 = 100
Coin50 = 50
Coin10 = 10
Coin5 = 5
Coin1 = 1

x = int(input())

while True:
    if x - Coin500 >= 0:
        sum1 = sum1 + 1000
        x = x - Coin500
    else:
        break

while True:
    if x - Coin5 >= 0:
        sum1 = sum1 + 5
        x = x - Coin5
    else:
        break

print(sum1)

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

point500 = (n // 500) * 1000
remain500 = n % 500
point5 = (remain500 // 5) * 5
print(point5 + point500)

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

a=x//500

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

print(1000*a+5*b)

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

Solution (Python):
s = int(input())
count1=-1
count2=-1
while s>=0:
 s=s-500
 count1=count1 +1
s=s+500
if s==0:
  yasashisa=count1*1000
  print(yasashisa)
else:
   while s >=0:
     s=s-5
     count2=count2 +1
   yasashisa=count1*1000+count2* 5
   print(yasashisa)

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

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

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

five_hundered_coin = x // 500
five_coin = (x - five_hundered_coin * 500) // 5

happiness = five_hundered_coin * 1000 + five_coin * 5
print(happiness)

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

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

Solution (Python):
import math
a=int(input())
n = math.floor(a/500)
m = math.floor((a - n * 500)/5)
total_price= n * 1000 + m*5
print(total_price)

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
X = X % 500
b = X // 5

print(1000 * a + 5 * b)

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

A = X//500  
nokori = X - A*500

B = nokori //5   

ureshisa = 1000*A + 5*B

print(ureshisa)

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

a = yen // 500
b = yen % 500
c = b // 5

print(1000*a+5*c)

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

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

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

Solution (Python):
a = int(input())
b = a // 500
res1 = b * 1000

c = a - b * 500
d = c // 5
res2 = d * 5

print("{}".format(res1+res2))

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

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

Solution (Python):
if __name__ == "__main__":
    a = int(input())
    tmp = 0
    result = int(0)
    while a >= 5:
        coin500 = int(a / 500)
        a %= 500
        coin5 = int(a / 5)
        a %= 5
        result += (coin5 * 5) + (coin500 * 1000)
    print(result)

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

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

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

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

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

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

more = int(x/500)
left = x%500
less = int(left/5)

print(more*1000 + less*5)

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

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

while X >= 5:
    X -= 5
    sum += 5

print(sum)

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

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


if __name__ == "__main__":
    main()

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

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

Solution (Python):
s = int(input())
sum = 0
if s == 0:
    print(0)
else:
    sum += (s // 500) * 1000
    s -= (s//500) * 500
    sum += (s // 5) * 5
    print(sum)

Solution (Python):
x = int(input())
q1, mod1 = divmod(x, 500)
q2, mod2 = divmod(mod1, 5)
print(1000*q1 + 5*q2)

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

if(0 <= X and X <500):
    q,mod = divmod(X,5)
    Q1 = 5*q
    print(Q1)
if(500 <= X):
    q,mod = divmod(X,500)
    if(5 <= mod):
        q1,mod1 = divmod(mod,5)
    else:
        q1 = 0
    Q = 1000*q + 5*q1
    print(Q)

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

c1 = math.floor(X/500)
res = X%500
c2 = math.floor(res/5)

ans = c1*1000 + c2*5
print(str(ans))

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

Solution (Python):

def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr

    
    
    ref = arr[0]
    ref_count = 0

    for ele in arr:
        if ele < ref:
            left.append(ele)
        elif ele > ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return left + [ref] * ref_count + right


if __name__ == "__main__":
    x = int(input())
    points = 0
    tmp = int(x/500)
    points += tmp * 1000
    x -= tmp*500

    tmp = int(x/5)
    points += tmp*5

    print(points)

Solution (Python):
num_origin = int(input())
gohyoku = int(num_origin/500)
num_zan = num_origin - gohyoku*500
go = int(num_zan/5)
 
num = go*5 + gohyoku*1000
 
print(num)

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

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

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

Solution (Python):
X = input()
X = int(X)
if 0 <= X and X <= 10**9:
  a = X // 500
  b = (X % 500) // 5
  print(a * 1000 + b * 5)

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

cnt_500 = int(x/500)
cnt_5 = int((x-cnt_500*500)/5)

ans = cnt_500*1000+cnt_5*5
print(ans)

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

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

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

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

T=round(A)
F=round(B)
glad=1000*T+5*F

print(glad)

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

yen500 = X // 500
nokori = X - yen500 * 500
yen5 = nokori // 5

print(yen500 * 1000 + yen5 * 5)

Solution (Python):
if __name__=='__main__':
    S = int(input())
    n1 = int(S/500)
    n2 = int((S%500)/5)
    print(n1*1000+n2*5)

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

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

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

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

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

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

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

print(c_500*1000 + c_5*5)

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

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

Solution (Python):
def happiness(cash):
    count_500 = cash // 500
    count_5 = (cash % 500) //5
    return 1000 * count_500 + 5 * count_5

X = int(input())
print(happiness(X))

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

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

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

L = (X // 500)

S = (X - 500 * L) // 5

print(L*1000+S*5)

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

Solution (Python):
n=int(input())
l=[500,100,50,10,5,1]
v=n//500
u=n-v*500
v1=u//5

print(v*1000+v1*5)

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

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

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

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

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

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())
k=n//500
ans=0
ans+= k*1000

y=n%500
ans+= (y//5)*5
print(ans)

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

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

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

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

q = sum // 500
mod = sum % 500

p = mod//5

sum = q*1000 + (p*5)

print(sum)

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

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

score = 0

score += (S//500)*1000

S = S%500

score += (S//5)*5

print(score)

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

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

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

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

print(ureshisa)

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

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

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

print(ans)

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

num_500, mod = divmod(X, 500)
num_5 = mod // 5

print(1000 * num_500 + 5 * num_5)

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

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

ans += X // 5 * 5

print(ans)

Solution (Python):
import sys

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

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

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

Solution (Python):
input_i = int(input())
l_happy = input_i//500
s_happy = (input_i - (l_happy*500))//5

result = l_happy*1000+s_happy*5
print(result)

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

print(ans)

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

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

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

Solution (Python):
def main(money):
    happiness = 0

    happiness += (money // 500) * 1000
    money = money % 500

    happiness += (money // 5) * 5

    print(happiness)


main(int(input()))

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

A = X // 500   
a = X % 500    

B = a // 5

print((A * 1000) + B * 5)

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

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

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

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

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

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

a = (s//500)*1000

b = (s%500)//5*5

print(a+b)

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

times_500 = X // 500
g_1000 = 1000 * times_500

X = X - (500 * times_500)

times_5 = X // 5
g_5 = 5 * times_5

ans = g_1000 + g_5

print(str(ans))

Solution (Python):
X = int(input())
point_1000 = X // 500
point_5 = (X-500*point_1000)//5

print(point_5*5 + point_1000*1000)

Solution (Python):
x=int(input())
happiness = 0
if x>=500:
    ans = divmod(x,500)
    happiness += 1000*ans[0]
    x = ans[1]

if x>=5:
    ans =divmod(x,5)
    happiness += 5*ans[0]

print(happiness)

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

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

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

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

gohun = x // 500
amari = x % 500
go = amari // 5

happy = gohun * 1000 + go * 5
print(happy)

Solution (Python):
"""基本方針：500円で両替出来るだけして、端数を5円に変換する。
"""
import math
X = int(input())
ans = 0


ans += math.floor(X / 500) * 1000
X -= math.floor(X / 500) * 500

ans += math.floor(X / 5) * 5
X -= math.floor(X / 5) * 5

print(ans)

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

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

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

Solution (Python):
X=int(input())
R=X%5
r=(X-R)%500
print(r+(X-R-r)*2)

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

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

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

Solution (Python):
import sys

n = int(sys.stdin.readline())
sys.stdout.write(str((n // 500) * 1000 + (n % 500 // 5) * 5))

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

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

x = int(input())
print(solve(x))

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

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

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

print(a+b)

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

x = int((s - s%500)/500)

e = s%500
d = int((e - (e%5))/5)

print(x*1000 + d*5)

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

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

happiest = 0
happy = 0

if num >= 500:
  happiest = int(num/500)
  num = num % 500
if num >= 5:
  happy = int(num/5)

print(int(happiest*1000+happy*5))

Solution (Python):
x = int(input())
a,b = 0,0
if x // 500 >= 1:
    a = x // 500
    x = x - a*500
if x // 5 >=1:
    b = x // 5
    x = x - b*5
if a >=1 or b >=1:
    print(a*1000+b*5)
else:
    print(0)

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

list = [[500, 1000], [5, 5]]

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

print("{}".format(div_500 * 1000 + div_5 * 5))

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

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

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

Solution (Python):
x = int(input())
thou, amari = divmod(x, 500)
five = amari // 5

print(thou * 1000 + five * 5)

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

Solution (Python):


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

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

    ans += (X//5)*5

    print(ans)


if __name__ == "__main__":
    solve()

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

big = X // 500
small = (X - 500*big) // 5

answer = 1000 * big + small * 5
print(int(answer))

Solution (Python):



def main():
    import sys
    input = sys.stdin.readline

    x = int(input())
    ans = 0

    p, q = divmod(x, 500)
    ans += 1000 * p
    ans += q // 5 * 5

    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):
N=int(input())
print('{}'.format(str(int(N/500)*1000+int(N%500/5)*5)))

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

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

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

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

Solution (Python):
from math import*
n=int(input())
y= floor(n/500)
if (n-y)==0:
    print(1000*y)
else:
    x=n-y*500
    ans=(floor(x/5))*5+1000*y
    print(ans)

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

c500 = X // 500
X -= 500 * c500

c5 = X // 5
happy = c500 * 1000 + c5 * 5
print(happy)

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

h += X//5*5
print(h)

Solution (Python):

X = int(input())
count1 = int(X/500) 



deducation = X - count1 * 500

count2 = int(deducation / 5)



uresisa = count1 * 1000 + count2 * 5
print(uresisa)

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

Solution (Python):
i = int(input())
big_count = i // 500
small_count = (i - 500 * big_count) // 5

print(big_count * 1000 + small_count * 5)

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

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


if __name__ == "__main__":
    main()

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