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

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


def main(x):
    gohyakuen = x // 500
    goen = (x % 500) // 5

    res = gohyakuen * 1000 + goen * 5

    return res


print(main(X))

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

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

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

Solution (Python):
x = int(input())
coin_500, x2 = divmod(x, 500)
coin_5, x3 = divmod(x2, 5)
result = coin_500 * 1000 + coin_5 * 5
print(result)

Solution (Python):
import sys
from math import sqrt
from collections import Counter, defaultdict

input = sys.stdin.readline


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    x = I()

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


if __name__ == "__main__":
    main()

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

count500 = x//500
x = x%500

count5 = x//5

ans = count500 * 1000 + count5 *5

print(ans)

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

Solution (Python):
try:
    i = int(input())
    
    if i < 0:
        print(0)
    else:
        ureshisa = int(i / 500) * 1000
        nokori = i % 500
        ureshisa += int(nokori / 5) * 5
        print(ureshisa)
except:
    print("not integer error")

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

H = 0
while X - 500 >= 0:
    X = X - 500
    H += 1000
while X - 5 >= 0:
    X -= 5
    H += 5

print(H)

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

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

ans = 0
ans += X // 500 * 1000
cnt = X // 500

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

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

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

print(ans)

Solution (Python):






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

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


if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np
X=int(input())
a=int(X/500)
b=int(X%500)
c=int(b/5)
print(a*1000+c*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())

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

print(ans)

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

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

print(a * 1000 + b * 5 )

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

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

FIVE_H_CONIN = 500
FIVE_COIN = 5

amari = input % FIVE_H_CONIN

five_result = (int(amari / FIVE_COIN)) * 5
five_h_result = ((input - amari) / FIVE_H_CONIN) * 1000

print(int(five_result + five_h_result))

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

q_500, s = divmod(s, 500)
q_5, s = divmod(s, 5)

print("{}".format(q_500*1000+q_5*5))

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

Solution (Python):
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
import sys,bisect,string,math,time,functools,random
def Golf():*a,=map(int,open(0))
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[];g=[[] for i in range(n)]
    for i in range(E):
        inp=LI();org_inp.append(inp)
        if index==0:inp[0]-=1;inp[1]-=1
        if len(inp)==2:
            a,b=inp;g[a].append(b)
            if not Directed:g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp;aa=(inp[0],inp[2]);bb=(inp[1],inp[2]);g[a].append(bb)
            if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,boundary=1,search=[],replacement_of_found='.',mp_def={'

    mp=[boundary]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def bit_combination(k,n=2):return [[tb//(n**bt)%n for bt in range(k)] for tb in range(n**k)]
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)
def show2d(g,h,w):
    for i in range(h):show(g[i*w:i*w+w])

YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase

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

def ran_input():
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0
n=I()
a=n//500
n-=a*500
b=n//5

ans=a*1000+b*5

print(ans)

Solution (Python):
import math

n = int(input())

Big = int(n/500)*1000
amari = n%500
Small = int(amari/5)*5

print(Big+Small)

Solution (Python):
x = int(input())
maisuu_500 = x//500
happy_500 = 1000*maisuu_500
nokori = x-500*maisuu_500
maisuu_5 = nokori//5
happy_5 = 5*maisuu_5
print(happy_500+happy_5)

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

c500,mod = divmod(x,500)
c5,mod = divmod(mod,5)
print(c500*1000+c5*5)

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

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

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

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

n_500 = x // 500
rest_x = x - n_500 * 500
n_5 = rest_x // 5
print(n_500 * 1000 + n_5 * 5)

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

Solution (Python):
X=int(input())
cnt_500=0
cnt_5=0
res=X

if res>0:
    cnt_500=res//500
    res=res-500*cnt_500
if res>0:
    cnt_5=res//5
    res=res-5*cnt_5

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

Solution (Python):
import math
c = int(input())
l1 = math.floor(c / 500)
l2 = math.floor((c - l1 * 500) / 5)
print(l1 * 1000 + l2 * 5)

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

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

amari = X%500
syou = (X-amari)

amari1 = amari%5
syou2 = (amari-amari1)

print(syou*2 + syou2)

Solution (Python):
x = int(input())
q_1, m = divmod(x, 500)
q_2, _ = divmod(m, 5)

print(q_1*1000+q_2*5)

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

x1=X//500
Ans1=x1*1000

x2=X%500

x3=x2//5
Ans2=x3*5

Ans=Ans1+Ans2

print(Ans)

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

    ans = 0
    num_500 = X // 500
    X = X - num_500 * 500
    
    
    
    
    
    
    num_5 = X // 5
    X = X - num_5 * 5
    ans = int(ans + num_500 * 1000 + num_5 * 5)

    print(ans)

if __name__ == "__main__":
    resolve()

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

f_h_num = int(X/500)
X_next = X-f_h_num*500
f_num   = int(X_next/5)

happiness = f_h_num*1000 + f_num*5
print(happiness)

Solution (Python):
Y = int(input())
 
C500 = Y // 500
C5 = (Y - C500*500) // 5 if (Y - C500*500) // 5>0 else 0

print(C500*1000+C5*5)

Solution (Python):

x = int(input())
num_1 = x // 500
num_2 = (x - num_1 * 500) // 5

ans = num_1 * 1000 + num_2 * 5
print(ans)

Solution (Python):

import sys
sys.setrecursionlimit(15000)
x = int(input())
ret = 0
while x > 0:
    a,x = divmod(x,500)
    ret += a*1000
    b,x = divmod(x,5)
    ret += b*5
    x = 0
print(ret)

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

while x >= 500:
    count += 1000
    x -= 500
while x >= 5:
    count += 5
    x -= 5
print(count)

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

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

print(int(res))

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

Solution (Python):
x = int(input())
coins = [500,5]
ans = 0
p = 0
for coin in coins:
    p, x = divmod(x, coin)
    if coin == 500:
        ans += 1000*p
    elif coin == 5:
        ans += 5*p
print(ans)

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())
ans=[]
ans.append(x//500)
x-=500*(x//500)
ans.append(x//5)
print(ans[0]*1000+ans[1]*5)

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

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

f1 = x // 500
x %= 500
f2 = x // 5

print(f1*1000 + f2*5)

Solution (Python):

X = int(input())


a = X//500
b = X%500


c = b//5
d = b%5

Happiness = 1000*a + 5*c
print(Happiness)

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

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

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

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

X = X-500*a

b = X//5
ans = ans + 5*b

print(ans)

Solution (Python):

X = int(input())

q500 = int(X/500)
mod = X - (q500*500)

q5 = int(mod/5)

print(q500*1000 + q5*5)

Solution (Python):



X = int(input())


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

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

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

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

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

print(a*1000 + b*5)

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

big=X//500
rest=X%500

small=rest//5

print(1000*big+5*small)

Solution (Python):
x = int(input())
t = divmod(x, 500)
print(t[0]*1000 + (t[1]//5)*5)

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

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

div500=X//500
X=X-div500*500
div5=X//5

print(div500*1000+div5*5)

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

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

gohyaku = X//500
go = (X%500)//5

print(gohyaku*1000+go*5)

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

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

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

num500 = math.floor(money/500)
money = money - num500*500
num5 = math.floor(money/5)
print(num500*1000+num5*5)

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

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

print((X_1000 * 1000) + (X_5 * 5))

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

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

Solution (Python):

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

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

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

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

ans = coin // 500
mod = coin % 500 // 5

print(ans * 1000 + mod * 5)

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

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

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

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

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

p500 = int(X/500)

X -= p500*500

p5 = int(X/5)

ans = p500*1000 + p5*5

print(ans)

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

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

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

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

print(int(c_500 * 1000 + c_5 * 5))

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

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

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

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


A = (X // 500) * 1000
B = ((X % 500) // 5) * 5

print(A+B)

Solution (Python):
X = int(input())
if X >= 500:
  q = X // 500 
  mod = X % 500 
  f = mod // 5
  print(q*1000+f*5)
else:
  f = X // 5
  print(f*5)

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

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

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

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

p = N // 500
q = (N - p * 500) // 5

print( p * 1000 + q * 5)

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

h = x // 500 * 1000
h += x % 500 // 5 * 5

print(h)

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

Solution (Python):
from collections import *
from heapq import *
from itertools import *
from fractions import gcd
import sys
from decimal import *
import copy
from bisect import *
input=lambda :sys.stdin.readline().rstrip()


X=int(input())

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

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

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

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

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

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

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

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

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

fh = x//500
ref = x - fh*500
five = ref//5

value = fh*1000 + five*5
print(value)

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

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

big_hap = x // 500
x -= big_hap * 500
small_hap = x // 5

print(big_hap * 1000 + small_hap * 5)

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

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

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

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

five_thousands = X // 500
fives = (X - five_thousands * 500) // 5

print(five_thousands * 1000 + fives * 5)

Solution (Python):
X = int(input())
num_500 = X // 500

rest = X % 500

num_5 = rest//5

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

Solution (Python):
def resolve():
    x = int(input())
    happy = 0
    x500 = x//500
    happy += x500*1000
    x -= x500*500
    happy += (x//5)*5
    print(happy)

if __name__ == "__main__":
    resolve()

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

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

X = int(readline())

answer = 0

answer += int(X / 500) * 1000
X = X % 500

answer += int(X / 5) * 5

print(answer)

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

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

print(1000*a + 5*b)

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

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

print(q1*1000 + q2*5)

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

Solution (Python):
X = int(input())
ans = 0
while True:
    if X < 5:
        break
    if X >= 500:
        v, r = divmod(X, 500)
        ans += v * 1000
        X = r
    if X >= 5:
        v, r = divmod(X, 5)
        ans += v * 5
        X = r
print(ans)

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

Solution (Python):


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

Solution (Python):


N = int(input())
nokori = N 
uresisa = 0 

a = 0 
b = 0 

a = int(N/500)
nokori -= a * 500
uresisa += a * 1000





b = int(nokori/5)
nokori -= b * 5
uresisa += b * 5




print(uresisa)

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



ans = 0

ans += x // 500 * 1000

ans += x % 500 // 5 *5

print(ans)

Solution (Python):


X = int(input())

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

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

ans = 0

a_q = x // 500
a_mod = x % 500

ans = a_q * 1000 + (a_mod//5) * 5

print(ans)

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

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

happy1000 = int(x / 500)

happy5 = int((x - happy1000 * 500) / 5)

print(happy1000*1000+happy5*5)

Solution (Python):
from sys import stdin


def main():
    X = int(stdin.readline().rstrip())
    score = (X // 500) * 1000
    X = X % 500
    score += (X // 5) * 5
    print(score)


if __name__ == "__main__":
    main()

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

S = N // 500
T = N%500//5

print(S*1000+T*5)

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

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

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

num2 = num % 500
gre = (num // 500) * 1000

num3 = (num2 // 5) * 5
gre += num3

print(gre)

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

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

a = X // 500

b = X % 500 // 5

print(a * 1000 + b * 5)

Solution (Python):
n = int(input())
box = [500, 5, 1]
res = []
for i in box:
    a = n // i
    res.append(a)
    n = n - a*i

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

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

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

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

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

Solution (Python):


from math import floor

s = int(input())


a = floor(s/500)
nokori = s - a*500
b = floor(nokori/5)

print(1000*a + 5*b)

Solution (Python):
x = int(input())
hap = 0
l = [100,50,10,5]
n = x//500
hap+=1000*(x//500)
x-=500*n
j = x//5
hap+=(j*5)
print(hap)

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

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

q, mod = divmod(x, 500)
r = mod // 5
print(1000*q + r*5)

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

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

print(q1*1000 + q2*5)

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

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

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

if __name__ == '__main__':
    resolve()

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

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

counts_500 = a//500
counts_5 = (a-counts_500*500)//5

happy_index = counts_500*1000 + counts_5*5

print(happy_index)

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(A*1000+B*5)

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

sen_ure = x // 500
go_ure = (x - sen_ure * 500) // 5

print(sen_ure * 1000 + go_ure * 5)

Solution (Python):

from sys import stdin
from operator import itemgetter
import math


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

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


if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

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

a = int(x//500)
r = x%500

b =int(r/5)

res = a*1000 + b*5

print(res)

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

f = x // 5
print(fh * 1000 + f * 5)

Solution (Python):

X = int(input())

p = 0

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

q, X = divmod(X, 5)
p += q * 5

print(p)

Solution (Python):
mod = 10**9 + 7

def iip(listed = False):
    ret = [int(i) for i in input().split()]
    if len(ret) == 1 and not listed:
        return ret[0]
    return ret

def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):
    if n <=0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n-r+1, n+1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r+1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        
        pass
    return ret


def inv(n, mod):
    return power(n, mod-2)

def power(n, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p//2) ** 2) % mod
    if p % 2 == 1:
        return (n * power(n, p-1)) % mod



def main():
    n = iip()
    ret = 0
    ret += (n // 500) * 1000
    n = n % 500
    ret += (n // 5) * 5
    print(ret)


if __name__ == "__main__":
    main()

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

Solution (Python):
import math


a=int(input())


fiveHun=math.floor(a/500)
five=math.floor((a-500*fiveHun)/5)

print(fiveHun*1000+five*5)

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

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

q1,mod1 = divmod(X,500)

q2,mod2 = divmod(X-500*q1,5)

print(1000*q1+5*q2)

Solution (Python):
x = int(input())
gohyaku = x//500
amari = x - gohyaku * 500
go = amari // 5

print(gohyaku * 1000 + go * 5)

Solution (Python):
n=int(input())
i=0
t=0
while(n>499):
    i+=1
    n+=-500
while(n>4):
    t+=1
    n+=-5
r=1000*i+5*t
print(r)

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

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

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

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

max500 = money//500
max5 = (money%500) // 5

print(1000*max500+5*max5)

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

Solution (Python):


import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        
        
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    x = int(lines[0])

    return (x, )


def solve(x, ):


    y = x // 500
    z = x % 500
    w = z // 5

    result = 1000 * y + 5 * w


    
    return result
    


def main():
    
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Solution (Python):
import math

yen = int(input())
coin500 = math.floor(yen / 500)
yen -= (coin500 * 500)
coin5 = math.floor(yen / 5)

happiness = (coin500 * 1000) + (coin5 * 5)
print(happiness)

Solution (Python):
def main(x):
    res = 0
    val, mod = divmod(x, 500)
    res += val * 1000
    val, mod = divmod(mod,  5)
    res += val * 5
    return int(res)

x = int(input())
print(main(x))

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

  q, mod =divmod(X, 500)

  r, mod =divmod(mod, 5)

  ans = 1000*q + 5*r

  print(ans)

if __name__ == "__main__":
  main()

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

m_500 = m//500
m_5 = (m%500)//5

print(m_500*1000+m_5*5)

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

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

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

Solution (Python):

X = int(input())
X500 = X//500
X5 = (X % 500)//5

print(X500*1000+X5*5)

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

point_500 = 1000
point_5 = 5

num_500 = x // 500
x = x % 500
num_5 = x // 5

ans = num_500 * point_500 + num_5 * point_5
print(ans)

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

Solution (Python):
def resolve():
    '''
    code here
    '''
    X = int(input())
    res = (X//500)*1000
    X -= (X//500)*500
    res += (X//5)*5

    print(res)

if __name__ == "__main__":
    resolve()

Solution (Python):
n = int(input())
a = int(n/500)

amari = n%500

b = int(amari/5)
ans = int(a*1000+b*5)
print(ans)

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

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

Solution (Python):

def solve():
    import math
    X = int(input())
    res = 0
    res += math.floor(X/500)*1000
    res += math.floor((X%500)/5)*5
    print(res)

solve()

Solution (Python):
import collections
import math
import numpy as np









S = int(input())
gohyaku, amari = divmod(S, 500)
go, amari = divmod(amari, 5)

print(1000*gohyaku+go*5)

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

q_500, mod_500 = divmod(X, 500)
q_5, mod_5 = divmod(mod_500, 5)

print(q_500*1000+q_5*5)

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

print(1000 * A + 5 * C)

Solution (Python):
b = int(input())
cur = [500, 5]
ans = 0
for ele in cur:
    if ele == 500:
        ans += (b // ele) * 1000
    else:
        ans += (b//ele) * 5
    b = b % ele
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]





x=ii()
ans=0
p=x//500
ans+=p*1000

x-=p*500
if x>=0:
    q=x//5
    ans+=q*5

print(ans)

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

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

Solution (Python):

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

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

a = x //500

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

b = x//5

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

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

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

t = n
s = 0
while t - 500 >= 0:
  t = t - 500
  s = s + 1000
  
while t - 5 >= 0:
  t = t - 5
  s = s + 5
  
print(s)

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

n_500 = 0
n_5 = 0

while True:
    if X // 500 != 0:
        n_500 += 1
        X -= 500
    else:
        break

while True:
    if X // 5 != 0:
        n_5 += 1
        X -= 5
    else:
        break

print(1000*n_500 + 5*n_5)

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

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

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

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

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

print(ans)

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

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

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

num_500 = x // 500

mod_500 = x - num_500 * 500

num_5 = mod_500 // 5

print(1000 * num_500 + 5 * num_5)

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

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

Solution (Python):
def solve():
  ans = 0
  x = int(input())
  b = x // 500
  ans += 1000 * b
  x -= 500 * b
  b += x // 5
  ans += (x // 5) * 5
  print(ans)
  return 0
 
if __name__ == "__main__":
  solve()

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

a=X//500
nx=X%500
b=nx//5

print(a*1000+b*5)

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

num_fivehand = x // 500
num_five = (x % 500) // 5

print(num_fivehand * 1000 + num_five * 5)

Solution (Python):

X = int(input())


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

print(1000 * a + 5 * b)

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

def calculate(x):
    a = x // 500
    b = x % 500

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


calculate(X)