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

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

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

n_500 = x // 500
n_5 = (x - 500 * n_500) // 5

print(1000 * n_500 + 5 * n_5)

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

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

ans += 5 * (x // 5)

print(ans)

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

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

Solution (Python):


import sys
input=sys.stdin.readline

def main():
    X=int(input())
    g=(X//500)*1000+((X-(X//500)*500)//5)*5
    print(int(g))
    
    
    
if __name__=="__main__":
    main()

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

Solution (Python):
import math
N = int(input())
ans = 0
ans = math.floor(N//500)*1000
N = N % 500
ans = ans+math.floor(N//5)*5

print(ans)

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

coin_li = [500,5]

ans = 0
while coin_li:
    coin = coin_li.pop(0)
    if coin==500:
        ans+=x//coin*1000
    if coin==5:
        ans+=x//coin*5
    x = x%coin

print(ans)

Solution (Python):
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
X = int(readline())
a = X // 500
b = X % 500
c = b // 5
ans = 1000*a + 5*c
print(ans)

Solution (Python):
import itertools
import functools
import math
from collections import Counter

X = int(input())

p = 0

p_500 = ( X // 500 ) * 1000
X -= ( X // 500 ) * 500
p_5 = ( X // 5 ) * 5

print(p_500+p_5)

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

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

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

print(five_hun*1000+five*5)

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

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

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

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

Solution (Python):

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


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

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


def main():
    print(solve())


if __name__ == '__main__':
    main()

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

    
print(ans)

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

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

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

quotient = int(x / 500)
happiness_500 = 1000 * quotient

resid = x % 500
happiness_5 = (int(resid / 5)) * 5

print(happiness_500 + happiness_5)

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

h = 0

for i in range(X+1):
    if X>=500:
        X -= 500
        h += 1000
    elif 5<=X<500:
        X -= 5
        h += 5
    else:
        print(h)
        exit()

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

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

print(1000*fh+5*f)

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

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

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

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

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

Solution (Python):
import sys
import itertools

import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines




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

print(ans)

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

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

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

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

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

Happy=0
tmp=X


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


tmp//=5
Happy+=5*tmp

print(Happy)

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

Solution (Python):
yen = int(input())
'''
happy= 0
while yen > 499:
  yen -= 500
  happy += 1000

while yen > 4:
  yen -=5
  happy += 5
'''
happy = 1000 * int(yen//500) + 5 * int((yen - (500 * int(yen//500)))//5)

print(happy)

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

Solution (Python):


x = int(input())
n = 0

if x // 500 != 0:
    n += 1000 * (x // 500)
    
    x = x % 500

if x // 5 != 0:
    n += 5 * (x // 5)
    
    x = x % 5

print(n)

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

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

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

FHyen = X // 500
Fyen = (X-500*FHyen) // 5

print(1000*FHyen + 5*Fyen)

Solution (Python):
x = int(input())
five_h = x // 500
five = (x - 500*five_h)//5

ans = 2*500*five_h + 5*five
print(ans)

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

Solution (Python):
import math
syojikinn = int(input())
kouka500 = syojikinn / 500
kouka500 = math.floor(kouka500)
syojikinn = syojikinn - kouka500 * 500
kouka5 = syojikinn / 5
kouka5 = math.floor(kouka5)
siawase = kouka500 * 1000 + kouka5 * 5
print(siawase)

Solution (Python):
s=int(input())
five=s
five  = ((s-(s//500)*500)//5)*5
s=(s//500)*1000

print(five+s)

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

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

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

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

yen_500 = int(x / 500)
rem = x % 500

yen_5 = int(rem /5)

print(yen_500 * 1000 + yen_5 * 5)

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

Solution (Python):
x=int(input())
def money(x):
    if x==0:
        return 0
    cnt500=0
    cnt5=0

    while x>=500:
        x-=500
        cnt500+=1
    if x==0:
        return cnt500*1000
    
    while x>=5:
        x-=5
        cnt5+=1
    return cnt500*1000+cnt5*5
print(money(x))

Solution (Python):
import numpy as np
def cumsum(x):
    return list(np.cumsum(x))

def cumsum_number(N,K,x):
    ans=[0]*(N-K+1)
    number_cumsum = cumsum(x)
    number_cumsum.insert(0,0)
    for i in range(N-K+1):
        ans[i]=number_cumsum[i+K]-number_cumsum[i]
    return ans
"""
int 
float 


for name in fruits: 
    print(name)


list0 = [] 
list0 = [1,2,3,4] 
list0 = [0]*10 
list1= [i for i in range(10)] 
list1 = list(map(int, input().split()))　
number=[int(input()) for i in range(int(input()))] 
list1 = list1 + [6, 7, 8] 
list2.append(34) 
list.insert(3,10) 
len(list4) 
max(sa) 
list5.count(2) 
list1.sort() 
list1.sort(reverse=True)  
set(list1) 
sum([2,3,   ,3]) 

abs(a) 
max(a,b) min(a,b) 
text1 = text1.replace("34","test") 

exit(0) 

cumsum(リスト) 
cumsum_number(N,K,x) 
"""
X=int(input())
happy=0
if X>=500:
    happy += 1000*(X//500)
    X -= 500*(X//500)
if X>=5:
    happy += 5*(X//5)
print(happy)

Solution (Python):
X = int(input())
go = 0
gohyaku = 0

while X >= 500:
    gohyaku += 1
    X -= 500
    
    
while X >= 5:
    go += 1
    X -= 5
    

ans = (gohyaku * 1000) + (go * 5)
print(ans)

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

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

u = (x // 500) * 1000
y = (x % 500)
u = u + (y // 5) * 5

print(u)

Solution (Python):
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    x = I()
    a = x//500
    x -= a*500
    b = x//5
    print(1000*a+5*b)
    return

if __name__=='__main__':
    Main()

Solution (Python):

x = int(input())

a = x//500
rem = x - a*500
b = rem//5

print(a*1000 + b*5)

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

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

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

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

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

num500 = X//500
num5 = (X - 500*num500)//5

print(1000*num500 + 5*num5)

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

L=0
while a >= 500:
    a -= 500
    L += 1000

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

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

n500 = x//500
q500 = x%500
n5 = q500//5

print(n500*1000+n5*5)

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

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

Solution (Python):






x=input()
x1=int(x) 


r=int(x1/500)
x2=x1%500


r1=int(x2/5)
x3=x2%5

sam=(r*1000)+(r1*5)

print(sam)

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

a = x // 500

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

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

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

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

ans = a * 1000 + b * 5

print(ans)

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

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

Solution (Python):
x = int(input())
happiness = 0
while True:
    if x >= 500:
        x -= 500
        happiness += 1000
    elif x >= 5:
        x -= 5
        happiness += 5
    else:
        print(happiness)
        exit()

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

hap1000 = int(num/500)
hap5    = int((num-hap1000*500)/5)
print(int(1000*hap1000+5*hap5))

Solution (Python):


X=int(input())

ans=0
while X>=5:
    if X>=500:
        ans+=1000
        X-=500
    else:
        ans+=5
        X-=5

print(ans)

Solution (Python):
x = int(input())
u = 0
coins = [500,5]
u_coin = [1000,5]

for i,coin in enumerate(coins):
  if x > 0:
    u += x // coin * u_coin[i]
    x -= x // coin * coin
print(u)

Solution (Python):

X = int(input())
n = X//500
m = (X - 500*n)//5

ans = n*1000 + m*5
print(ans)

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

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

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

happy = a * 1000 + b * 5

print(happy)

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


if __name__ == "__main__":
    main()

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

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

ans = cnt_500 * 1000 + cnt_5 * 5

print(ans)

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

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

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

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

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

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

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

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

coin_500 = x // 500
coin_5 = (x-coin_500*500) // 5

print(coin_500 * 1000 + coin_5 * 5)

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

A = X//500
D = X - A*500
B = D//5

print(1000*A + 5*B)

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

th = X // 500
X = X -500*th

fi = X // 5

print(1000*th + fi *5)

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

def happy(n):
  s = n//500
  m = (n%500)//5
  print(s*1000 + m*5)

happy(n)

Solution (Python):

import sys
input = lambda: sys.stdin.readline().strip()
x = int(input())
print(1000 * (x // 500) + 5 * (x % 500 // 5))

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

count_500 = x//500
count_5 = (x%500)//5

print(1000*count_500 + 5*count_5)

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


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


if __name__ == '__main__':
    main()

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

print(ans)

Solution (Python):

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

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

Solution (Python):
def happy():
  x = int(input())
  y = 0 
  z = 0
  
  if x >= 500:

    while x >= 500:
      x -= 500
      y += 1

      if 5 <= x <500:
        while x >= 5:
          x -= 5
          z +=1
        print(y *1000 +z *5)
        return

    print(y*1000)

  else:
    if x >= 5:
      while x >= 5:
        x -= 5
        z += 1
      print(z*5)

    else:
      print("0")

happy()

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

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

Solution (Python):


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

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

Solution (Python):
X = int(input())
sho = X//500
glad = 0

glad = 1000 * sho
X -= sho*500

sho = X//5
glad += 5*sho

print(glad)

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

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

print(1000*a + 5*b)

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

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

Solution (Python):

n = int(input())
a = 0
a += n//500*1000
n -= n//500*500
a += n//5*5
print(a)

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

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

    return

resolve()

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

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

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

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

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

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

ans = 0

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

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

print(ans)

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

Solution (Python):
import math
s = int(input())
big_g= math.floor(s/500)*1000
small_g = math.floor((s%500)/5)*5
ans = big_g + small_g
print (ans)

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

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

Solution (Python):

X = int(input())

_500 = X // 500
_5 = (X % 500) // 5

print(_500 * 1000 + _5 * 5)

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

num_500 = x // 500
num_5 = (x - num_500 * 500) // 5

print(num_500 * 1000 + num_5 * 5)

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

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

print(1000*a + 5*b)

Solution (Python):
import sys

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

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


if __name__ == '__main__':
    solve()

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

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

print(ans)

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

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

fh = 0
f  = 0

while X > 0:
    if X // 500 > 0:
        num = X // 500
        fh += num
        X -= num * 500
    elif X // 5 > 0:
        num = X // 5
        f += num
        X -= num * 5
    else:
        break

ans = 1000 * fh + 5 * f

print(ans)

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

print(ans)

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

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

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

if X//500 >= 1:
	happy += 1000*(X//500)
	X -= 500*(X//500)
if X//5 >= 1:
	happy += 5*(X//5)
	X -= 5*(X//5)
print(happy)

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

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

print(point)

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

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

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

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

print(1000 * a + 5 * b)

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

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

a , X = divmod(X, 500)
b, X  =divmod(X,5)
print(a*1000+b*5)

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

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

acc, x = divmod(x, 500)
print(x//5*5 + acc*1000)

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


X_500 = X // 500 * 1000

X_5 = (X % 500) // 5 * 5

print(X_500 + X_5)

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

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

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

Solution (Python):
N = input()

x = int(N)

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

Solution (Python):


import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
X = I()
print(X//500*1000+(X%500)//5*5)

Solution (Python):
import math

x = int(input())
x500 = math.floor(x/500)
x5 = math.floor((x%500)/5)
print(x500*1000+x5*5)

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

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

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

print(ans)

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

a = 0

c_500 = x // 500
c_5 = (x - c_500*500) // 5 


print(c_500*1000 + c_5*5)

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

a = 0

c_500 = x // 500
c_5 = (x - c_500*500) // 5 


print(c_500*1000 + c_5*5)

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

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

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

Solution (Python):
def actual(x):
    n_500yen, x = divmod(x, 500)

    n_5yen, _ = divmod(x, 5)

    return 1000 * n_500yen + 5 * n_5yen

x = int(input())
print(actual(x))

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

Solution (Python):
X = int(input())
coins = [500, 5]
counts = []
for c in coins:
    counts.append(X//c)
    X -= counts[-1] * c
print(counts[0]*1000 + counts[1]*5)

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

num500 = int(x / 500)
num5 = int((x - num500 * 500) / 5)

print(num500 * 1000 + num5 * 5)

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

m500 = x//500
tmp = x - 500*m500
m5 = tmp//5

print(1000*m500 + 5*m5)

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

A,B=[(X//500) ,(X%500)]
point += A*1000
A,B=[(B//5) ,(B%5)]
point += A*5

print(point)

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

uresisa=0

gohyaku=0
gohyaku=X//500

X=X%500

goen=0

goen=X//5

uresisa=gohyaku*1000+goen*5

print(uresisa)

Solution (Python):
import sys

input = lambda: sys.stdin.readline().rstrip()


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

    q1, r1 = divmod(x, 500)
    x -= q1 * 500
    q2, r2 = divmod(x, 5)
    print(q1 * 1000 + q2 * 5)


if __name__ == '__main__':
    solve()

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

q_1 = x//500
r_1 = x%500

q_2 = r_1//5

print(q_1*1000+q_2*5)

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

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())
num_500 = X // 500
num_5 = (X - 500 * num_500) // 5

happiness = num_500 * 1000 + num_5 * 5

print(happiness)

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

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

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

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

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

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

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

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

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

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

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

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

G = X // 500
g = (X%500)//5

print(G*1000+g*5)

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

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

values=[500,5,1]
coins=[0 for i in range(3)]

for i in range(3):
    coins[i]=X//values[i]
    X-=coins[i]*values[i]
    
total=1000*coins[0]+5*coins[1]

print(total)

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

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

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

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

c500 = x//500
r = x % 500
c5 = r//5

print(c500*1000+c5*5)

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

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

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

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

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

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

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

print(y500 * 1000 + y5*5)

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





def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))





from itertools import combinations

def main():
	n=II()
	k=n//500
	print(1000*k+(n-k*500)//5*5)


if __name__ == "__main__":
	main()

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

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

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

while x>=5:
    x=x-5
    hpy+=5
print(hpy)

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

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

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

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

print(a*1000 + b*5)

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

num_of_500 = X // 500
num_of_5 = (X % 500) // 5

print(str(num_of_500 * 1000 + num_of_5 * 5))

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

happy = 0
if x/500 >= 1:
    happy += int(x/500)*1000
    x = x - int(x/500)*500
if x/5 >= 1:
    happy += int(x/5)*5
    x = x - int(x/5)*5
print(happy)

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

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

b=a//500
c=(a-b*500)//5
d=a-b*500-c*5

print(b*1000+c*5)

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

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

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

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

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

a=S//500

b=(S%500)//5

print(a*1000+b*5)

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

H1 = X // 500
H2 = (X % 500) // 5

print(1000*H1 + 5*H2)

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

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

if n>=5:
    total += (n//5)*5
    n%=5
print(total)

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

u += (x - (x % 500) ) * 2

u += (x - (x // 500) * 500 ) // 5 * 5

print(u)

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

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

    ans += rem // 5 * 5

    print(ans)
resolve()

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

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

print(a*1000+b*5)

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

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

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

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

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

Solution (Python):
S=int(input())
P=S//500
Q=S%500
R=Q//5
print(1000*P+5*R)

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

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

c500 = x//500

c5 = (x%500)//5

print(c500 * 1000 + c5 * 5)

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

a = x // 500
r_1 = x - 500*a
b = r_1 // 5

c = x //5

if x >= 500:
  print(1000 * a + 5 * b)
elif x >= 5:
  print(5 * c)
else:
  print(0)

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

large_coin = x//500
x -= large_coin*500
small_coin = x//5

print(large_coin*1000+small_coin*5)

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

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

y = x//500
1000*y

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


print(1000*y + 5*z)

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

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

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

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

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

print(ans)

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

C500 = X // 500
X = X - C500 * 500

C5 = X // 5
X = X - C5 * 5

print(str(C500 * 1000 + C5 * 5))

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

thousands=(x-x%500)/500
fives=(x%500-(x%500)%5)/5

happiness=int(1000*thousands+5*fives)

print(happiness)

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

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

print(ureshisa)

Solution (Python):
import math
x = int(input())
gohyoku = math.floor(x/500)
goen = math.floor((x-500*gohyoku)/5)
print(gohyoku*1000+goen*5)

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

q = X//500
mod = X % 500
qmod = mod//5
happy = q * 1000 + qmod * 5
print(happy)

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

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

print(c500*1000 + c5*5)

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

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

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

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

b = int(x/5)

print(a*1000 + b*5)

Solution (Python):
x = int(input())
if x<5:
    print(0)
else:

    Yens500 = x // 500
    Yens5 = (x-( Yens500*500 )) // 5


    print ((Yens500)*1000 + (Yens5)*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
c = x%500
b = c//5

print(a*1000+b*5)

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

Y = X%500

Z = Y//5

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

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