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):
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
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 - ((X // 500) * 500)) // 5) * 5)

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

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

A=int(x//500)
B=int((x%500)//5)

ans=0
ans=A*1000+B*5
print(ans)

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

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

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

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

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

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

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

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

print(hundred*1000+five*5)

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

yen_500 = X // 500
yen_5 = (X % 500) // 5

print(yen_500 * 1000 + yen_5 * 5)

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

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

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

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

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

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

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

Solution (Python):


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

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

Solution (Python):
x = int(input())
yen_500 = 0
yen_5 = 0
amari = 0
happy = 0

if x>= 500:
    yen_500 = x//500
    amari = x - 500 * yen_500
    yen_5 = amari//5
    happy = 1000 * yen_500 + 5 * yen_5
    print(happy)
else:
    yen_5 = x//5
    happy = 5 * yen_5
    print(happy)

Solution (Python):

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

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


if __name__ == '__main__':
    main()

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


happiness += x//500*1000
x %= 500

happiness += x//5*5
x %= 5

print(happiness)

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

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

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

    c += 1000 * (x//500)
    x -= 500 * (x//500)

    c += 5 * (x//5)
    print(c)
    return
main()

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

h = (X // 500) * 1000

X = X % 500

h += (X // 5) * 5

print(h)

Solution (Python):
X = int(input())
x500 = X//500
amari = X - x500 * 500
x5 = amari // 5

print(x500*1000+x5*5)

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

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

x500 = x // 500
y = x - x500*500
y5 = y // 5
z = y - y5*5

print(x500*1000+y5*5)

Solution (Python):

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

Solution (Python):
x=int(input())
a=x
i=0
j=0
if 500<= x:
  while i*500<x:
    i+=1
  i-=1
  x-=500*i
if 5<=x:
  while j*5<x:
    j+=1
  j-=1
if i==0 and j==0:
  print(0)
elif a%500==0:
  print(a//500 * 1000)
else:
  print(1000*i+5*j)

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

if __name__ == "__main__":
    solve()

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

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

happiness = 0
if x // 500 > 0:
  n = x // 500
  happiness += 1000 * n
  x %= 500
if x // 5 > 0:
  n = x // 5
  happiness += 5 * n
print(happiness)

Solution (Python):
X=int(input())
k=0
l=0
while X>=500:
    X-=500
    k+=1
while X>=5:
    X-=5
    l+=1
print(1000*k+5*l)

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

big = x // 500

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

print(big*1000 + small*5)

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

Solution (Python):
def change(X, coin):
    """ exchange
    :param X: total money
    :param coin: 500 or 5
    :return: reduced X and num of coins
    """
    num = X // coin
    X -= coin * num
    return X, num

if __name__ == '__main__':
    X = int(input())
    ans = 0
    X, num = change(X, 500)
    ans += 1000 * num
    X, num = change(X, 5)
    ans += 5 * num
    print(ans)

Solution (Python):



x = int(input())
y = int(x / 500)
z = int((x - (500 * y)) / 5)
a = (y * 1000) + (z * 5)
print(a)

Solution (Python):
x = int(input())
ans = 0
for a in range(2*10**6):
    if x >= 500:
        x = x-500
        ans = ans + 1000
    else:
        break
for b in range(100):
    if x >= 5:
        x = x-5
        ans = ans + 5
    else:
        break
print(ans)

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

main()

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

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

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

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

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

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

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

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

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

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

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

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

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

yen_500 = x//500
yen_5 = (x-(yen_500*500))//5

print((yen_500*1000)+(yen_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):
N = int(input())
print(1000 * (N // 500) + 5 * ((N % 500) // 5))

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

r = 0
divider = ((500,1000), (5, 5))
for i in divider:
    x, remain = divmod(x, i[0])
    r += x * i[1]
    x = remain

print(r)

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

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

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

count_500 , mod = divmod(x, 500)
count_5 = mod // 5
print(count_500 * 1000 + count_5 * 5)

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

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

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

ans=0

if X < 500:
    print((X // 5) * 5)
else:
    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
ans += ((x % 500) // 5) * 5
print(ans)

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

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

    p, r = divmod(X, 500)
    q, r = divmod(r, 5)
    print(p * 1000 + q * 5)


if __name__ == '__main__':
    main()

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

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

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

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

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

num1000 = X // 500
r500 = X % 500
num5 = r500 // 5

print(num1000 * 1000 + num5 * 5)

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

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

print(ans)

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

Solution (Python):
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

x = inp()

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

print(a*1000 + b*5)

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

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

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

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

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

print(1000*a+5*b)

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):
"""
500 -> 1000
5 -> 5
"""
ans = 0
n = int(input())
if n >= 500:
    goh = n // 500
    zan = n % 500
    ans += goh*1000
    n = zan
if n < 500 and n != 0:
    g = n // 5
    ans += g*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())
ans = 0

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

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

print(ans)

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

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

a1 = 1000
a2 = 5

n1 = X // 500
X -= n1 * 500
n2 = X // 5

print(n1 * a1 + n2 * a2)

Solution (Python):
import sys
x = int(sys.stdin.read())
c500, x = divmod(x, 500)
c5 = x // 5
print(c500 * 1000 + c5 * 5)

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

print(a*1000 + b*5)

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

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

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

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

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

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

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

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

m_500 = x // 500
m_5 = (x - m_500*500) // 5

print(m_500*1000 + m_5*5)

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

fivehandred = x // 500
x -= x // 500 * 500
five = x // 5

print(fivehandred*1000+five*5)

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

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

Solution (Python):
















































global FLAG_LOG
FLAG_LOG = False


def log(value):
    
    
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    
    X = int(lines[0])
    
    
    
    
    
    
    
    
    

    q1, mod1 = divmod(X, 500)
    q2, mod2 = divmod(mod1, 5)

    result = q1*1000 + q2*5

    return [result]



def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines



def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['1024']
        lines_export = [2020]
    if pattern == 2:
        lines_input = ['0']
        lines_export = [0]
    if pattern == 3:
        lines_input = ['1000000000']
        lines_export = [2000000000]
    return lines_input, lines_export



def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode



def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    
    
    
    
    
    
    
    
    
    
    



if __name__ == '__main__':
    main()

Solution (Python):





x = int(input())

ans = 0

ans += x // 500 * 1000

ans += x % 500 // 5 * 5

print(ans)

Solution (Python):


from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float('inf')


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


def main():

    sys.setrecursionlimit(10 ** 6)

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


if __name__ == '__main__':
    main()

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

Solution (Python):
X = int(input())
ans = 0
div, mod = divmod(X, 500)
ans += div*1000
div, mod = divmod(mod, 5)
ans += div*5
print(ans)

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

Solution (Python):
n=int(input())
 
if n!=0:
	ans1=n//500
	sub=n-(ans1*500)
	ans2=sub//5
 
	print((ans1*1000)+(ans2*5))
 
else:
	print(0)

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

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

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

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

if not ( 0 <= X <= 10**9 and isinstance(X,int)): sys.exit

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

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

Solution (Python):

X = int(input())

score = 0

quotient_500 = X // 500
score += quotient_500 * 1000

remainder_500 = X % 500

quotient_5 = remainder_500 // 5
score += quotient_5 * 5

print(score)

Solution (Python):


X = int(input())

high, mod = divmod(X, 500)
low, mod = divmod(mod, 5)

ans = high * 1000 + low * 5
print(ans)

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

total = 0
happiness_500 = X // 500 *1000 
total += happiness_500
y = X % 500
happiness_5 = y //5 *5
total += happiness_5
print(total)

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

gohyaku = int(x / 500)
x = x% 500

go = int(x/5)

print(1000*gohyaku+5*go)

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

Solution (Python):
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

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

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

ureshi = 0


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


ureshi += (X // 5) * 5

print(ureshi)

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

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

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

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

print(ans)

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

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

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

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

print(ans)

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

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

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

Solution (Python):
print(sum([i//500*1000+i%500//5*5 for i in [int(input())]]))

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

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

Solution (Python):
def happiness_from_golden_coins():
    
    X = int(input())
    
    count_500yen = 0
    count_5yen = 0
    
    
    while True:
        if X >= 500:
            count_500yen += 1
            X -= 500
        else:
            break
    
    while True:
        if X >= 5:
            count_5yen += 1
            X -= 5
        else:
            break
    
    happiness = (1000 * count_500yen) + (5 * count_5yen)
    return happiness

result = happiness_from_golden_coins()
print(result)

Solution (Python):
import math
import collections
import itertools
import heapq
import sys

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

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

    print(res)


if __name__ == "__main__":
    main()

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

Solution (Python):
a = int(input())
a -= a%5
print(2*a - a%500)

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

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

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

print(ans)

Solution (Python):

import sys
import collections as cl


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 main():
    N = II()
    big = N // 500
    N -= big*500
    small = N // 5
    print(big*1000 + small * 5)


main()

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

u_1000=x//500*1000
u_5=x%500//5*5

print(u_1000+u_5)

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

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

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

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

cnt_500 = x // 500
cnt_5 = (x % 500) // 5

print(cnt_500 * 1000 + cnt_5 * 5)

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

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

print(n_500*1000 + n_5*5)

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

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

Solution (Python):

x = int(input())
a,moda = divmod(x,500)
b,modb = divmod(moda,5)
print(a*1000+b*5)

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

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

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

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

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

Solution (Python):
X=int(input())
q,mod=divmod(X,500)
p=mod//5
print(q*1000+p*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):
X=int(input())
a=X//500
if X%500==0:
    print(a*1000)
else:
    b=(X-500*a)//5
    print(a*1000+b*5)

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

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

ans = 0

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

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

print(ans)

Solution (Python):
import sys


def main():
    input = sys.stdin.buffer.readline
    x = int(input())
    a, b = divmod(x, 500)
    c = b // 5
    print(1000 * a + 5 * c)


if __name__ == "__main__":
    main()

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

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

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

Solution (Python):

n = int(input())
yen500 = n // 500
yen5 = (n-500*yen500) // 5
pts = 1000*yen500 + 5*yen5
print(pts)

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

    n, X = divmod(X, 500)
    m = X // 5

    ans = 1000 * n + 5 * m

    print(ans)

    return


if __name__ == '__main__':
    main()

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

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

t, r = x // 500, x % 500
u = r // 5

print(t * 1000 + u * 5)

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

x = int(input())

ans = 0
cnt = x // 500
ans = cnt * 1000

x = x % 500
cnt = x // 5
ans += cnt * 5

print(ans)

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

Solution (Python):
X=int(input())
x,res=X//500, X%500
y=res//5

print(x*1000+y*5)

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

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

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

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

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

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

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

Solution (Python):
X = int(input())
a = 0
b = 0
while X>0:
  if X-500>=0:
    X = X-500
    a = a+1
  elif X-5>=0:
    X = X-5
    b = b+1
  else:
    break
print(a*1000+b*5)

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

if X ==0:
  print(0)
else:
  N = X // 500
  M = X - (500 * N)
  R = M // 5
  print((N * 1000) + (R * 5))

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

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

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

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

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

print(int(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

res = x - a * 500

b = res // 5

print(a * 1000 + b * 5)

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

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

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

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

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

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

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

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

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

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

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

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

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


if __name__ == '__main__':
    main()

Solution (Python):
x = int(input())
h1 = x // 500
y = x % 500
h2 = y // 5

print(h1*1000 + h2*5)

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

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

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

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

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

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

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

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

if n>=500:
  x=n//500
  n=n%500
  cnt+=(1000*x)
cnt+=(5*(n//5))

print(cnt)

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

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

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

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

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

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

print(1000*num_500 + 5*num_5)

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

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


l=x//500


m=(x%500)//5

happiness=1000*l+5*m
print(happiness)

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

hap = 0
Y = X // 500
hap = hap + Y * 1000

Z = X % 500
W = Z // 5
hap = hap + W * 5

print(hap)

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

c500, r500 = map(int, divmod(x, 500))
c5 = int(r500 / 5)

ans1 = c500 * 1000 + c5 * 5

print(ans1)

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

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

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

if X >= 500:
    tmp += (X // 500) * 1000
    X = X % 500

if 5 <= X < 500:
    tmp += (X // 5) * 5

print(tmp)

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

if X >= 5:
    cnt += 5 * (X // 5)

print(cnt)

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

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

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

Solution (Python):
def main():
  a = int(input())
  b = a%500
  c = (a-b)*2
  d = b%5
  e = b-d
  print(c+e)
main()

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

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

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

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

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

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

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

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

print(a*1000 + b*5)

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

Solution (Python):
x = int(input())
coins = {500: 0, 5: 0}
for coin in coins.keys():
  coins[coin] = x // coin
  if coins[coin] > 0:
    x -= coin * coins[coin]
print(1000 * coins[500] + 5 * coins[5])

Solution (Python):
import math

N = int(input())


A = math.floor(N / 500)

N = N - A * 500

B = math.floor(N / 5)


AA = A * 1000
BB = B * 5
print(AA + BB)

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

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

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

num_of_500 = int(x / 500)
remaining = x - num_of_500 *500
num_of_5 = int (remaining / 5)

happiness = num_of_500 * 1000 + num_of_5 *5
print(happiness)

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

r500 = X // 500
X %= 500
r5 = X // 5

print(r500*1000 + r5*5)

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

ans += X // 5 * 5

print(ans)