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

remainder = x % 500

fhj = int((x - remainder) / 500 * 1000)
fj = int(int(remainder / 5) * 5)
print(fhj + fj)

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

'''
500: 1000
5: 5
'''

ans = 0
if X >= 500:
    x500 = X // 500
    ans += x500 * 1000
    X -= 500 * x500
    

if X >= 5:
    x5 = X // 5
    ans += x5 * 5
    X -= 5 * x5
    

print(ans)

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

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

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

print(1000*a+5*b)

Solution (Python):
import math

def func2(x):
    a500 = math.floor(x/500)
    a5 = math.floor(x%500 / 5)
    p = 1000*a500 + 5*a5
    return p

if __name__ == "__main__":
    a = int(input())
    print(func2(a))

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

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

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

Solution (Python):


def solve():
    X = int(input())
    res = 1000*(X//500) + 5*((X%500)//5)
    return str(res)

if __name__ == '__main__':
    print(solve())

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

ureshi = (value//500)*1000
ureshi += ((value-(value//500)*500)//5)*5

print( ureshi )

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

a = n // 500
b = n % 500

c = b //5

ans = a*1000 + c*5

print(ans)

Solution (Python):
m = input()


d={500:0,5:0}

fm = m/500
m -= fm*500
ffm = m/5



print 1000*fm+5*ffm

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

Solution (Python):
X = int(input())
a = X%500
b = a%5
print(2*X-a-b,end = '')

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

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

print(1000*a + 5*e)

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

Solution (Python):
x = int(input())
s = x//500
t = x%500
u = t//5

print(1000*s+5*u)

Solution (Python):

"""
Created on Sun Jan 19 20:52:57 2020

@author: over-
"""

X=int(input())

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

print(ans)

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

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

Solution (Python):


import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    x = ni()
    l = x % 100
    print(1000*(x//500) + 5*((x % 500)//5))

if __name__ == "__main__":
    main()

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

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

print(1000*a + 5*c)

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

happy = 0
if n // 500 >= 1:
    ha500 = n // 500
    happy = 1000 * ha500
    nokon = n % 500
    if nokon // 5 >= 1:
        ha005 = nokon // 5
        happy = happy + 5 * ha005
else:
    if n // 5 >= 1:
        ha005 = n // 5
        happy = 5 * ha005
print(happy)

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

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

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

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

coin500 = divmod(s,  500)
coin5 = divmod(coin500[1], 5)

print(coin500[0] * 1000 + coin5[0] * 5)

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

a = divmod(X, 500)
b = divmod(a[1], 5)

print(1000*a[0] + 5*b[0])

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

q1, mod1 = divmod(X, 500)
q2, mod2 = divmod(mod1, 5)
print(q1*1000+q2*5)

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

num_coin500 = X // 500
num_coin5 = (X - 500 * num_coin500) // 5
happiness = num_coin500 * 1000 + num_coin5 * 5
print(happiness)

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

Solution (Python):
has = int(input())
canbe = 0
_500, has = divmod(has, 500)
canbe += _500 * 1000
_5, has  = divmod(has, 5)
canbe += _5 * 5
print(canbe)

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

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

num = X - 500 * n500
n5 = num // 5

out = 1000 * n500 + 5 * n5
print(out)

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

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

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

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

Solution (Python):
d = input()

x = int(d)

a = x%500
b = int(x/500)
y = b*1000

c = int(a/5)
z = c*5

print(y+z)

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

print(h500*1000+h5*5)

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

num_500 = x // 500
x = x - x // 500 * 500


num_5 = x // 5
print(num_500 * 1000 + num_5 * 5)

Solution (Python):

import sys


def solve(X: int):
    gohyaku = X // 500
    nokori = X % 500
    go = nokori // 5
    print(1000*gohyaku + 5 * go)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  
    solve(X)

if __name__ == '__main__':
    main()

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

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

Solution (Python):
import math

if __name__ == "__main__":
    X = int(input())
    ret = 0
    ret += math.floor(X / 500) * 1000
    ret += math.floor((X % 500) / 5) * 5
    print(ret)

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

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



ans = 0

ths = x // 500
ans += 1000 * ths
x = x - 500 * ths

fives = x // 5
ans += 5 * fives

print(ans)

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

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

i = 1
while X >= 500 * i:
    i += 1

X -= (i - 1) * 500

j = 1
while X >= 5 * j:
    j += 1

ans = (i - 1) * 1000 + 5 * (j - 1)
print(ans)

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

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

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

Solution (Python):

import numpy as np

x = int(input())

num_500 = 0
num_5 = 0

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

while x >= 5:
    x -= 5
    num_5 += 1

ans = num_500 * 1000 + num_5 * 5

print(ans)

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

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):
import math




X = int(input())
ans = 0
while X > 5:
    if X >= 500:
        a = X//500
        ans += a*1000
        X-=a*500
    else:
        a = X//5
        ans += a*5
        X-=a*5
print(ans)

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

r = int(d // 500 * 1000)
d %= 500
r += int(d // 5 * 5)
print(r)

Solution (Python):
from collections import defaultdict, deque
import sys
import heapq
import bisect
import itertools
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))

def inpl_str(): return list(sys.stdin.readline().split())

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

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

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

Solution (Python):
def gladness(x):
    thousands = (x // 500) * 1000
    x = x % 500
    fives = (x // 5) * 5
    return thousands + fives

n = input()
print(gladness(int(n)))

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

n500 = int(X / 500)
X -= n500 * 500
if X >= 0:
    n5 = int(X/5)
    X -= n5 * 5
    print n500*1000 + n5*5
else:
    print n500*1000

Solution (Python):
S=int(input())
r500=int(S/500)
S2 = S - 500*r500
r5 = int(S2/5)
print(r500*1000+r5*5)

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

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())
N_500 = (X // 500)
N_5 = (X - 500 * N_500) // 5
out = N_500 * 1000 + N_5 * 5
print(out)

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

while X>=500:
    count+=(X//500)*1000
    X = X%500
    
while X>=5:
    count+=(X//5)*5
    X = X%5
    
print(count)

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

coin500 = i // 500
coin5 = (i - coin500*500) // 5
print(coin500*1000 + coin5*5)

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

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

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

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

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

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

print(ans)

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

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

Solution (Python):


x = int(input())

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

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

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

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

print(ans)

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

a = x // 500

x2 = x - (500 * a)

b = x2 // 5

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

print(ans)

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

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

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

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

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


a = X // 500
b = X % 500
ans = a * 1000

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

print(ans)

Solution (Python):

X = int(input())

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

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

Solution (Python):
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)


x = int(input())
coin = [500,5,100,50,10,1]

c = [0,0,0,0,0,0]
for i in range(len(coin)):
    c[i] = x//coin[i]
    x -= coin[i]*c[i]
ans = 0
ans += c[0]*1000
ans += c[1]*5
print(ans)

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

S1 = S % 500
A = S//500

B = S1 // 5

print(A*1000+B*5)

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

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

praise_5 = x // 5 * 5

print(praise_500 + praise_5)

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

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

    A=N//500
    Am=N%500
    B=Am//5

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

Solution (Python):

N= int(input())

p, mod = divmod(N, 500)


q, mod = divmod(mod, 5)


print(p*1000+q*5)

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



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




joy += (X // 5) * 5
X = X % 5


print(joy)

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

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

print(ans)

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

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

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

Solution (Python):

money = int(input())

y_500 = money // 500

happiness = y_500 * 1000

change = money - 500 * y_500

y_5 = change // 5

happiness += y_5 * 5

print(happiness)

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

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

d, m = divmod(X, 500)

d2, m2 = divmod(m, 5)

print(d * 1000 + d2 * 5)

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

n_coin_500 = X // 500
n_coin_5 = X % 500 // 5

happy_500 = 1000 * n_coin_500
happy_5 = 5 * n_coin_5

result = happy_500 + happy_5
print(result)

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

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

Solution (Python):
def main():
    s = int(input().strip())
    a = s // 500
    b = (s - 500 * a) // 5
    ans = 1000 * a + 5 * b
    print(int(ans))


if __name__ == '__main__':
    main()

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

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

happiness = 0
while(X>=500):
    happiness+=1000
    X-=500

while(X>=5):
    happiness+=5
    X-=5

print(happiness)

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

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

z = x // 5
print(1000*y + z*5)

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

Solution (Python):
X = int(input())
pt1000 = 0
pt5 = 0

if X >= 500:
    while X >= 500:
        X = X - 500
        pt1000 += 1
    while X >= 5:
        X = X-5
        pt5 += 1
else:
    while X >= 5:
        X = X-5
        pt5 += 1

print(pt1000*1000 + pt5*5)

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

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

points = s//500 * 1000
s = s %500
points += s //5 * 5
print(points)

Solution (Python):
X = int(input())
hya = X // 500
go = (X - hya*500)//5

print(hya*1000+go*5)

Solution (Python):
N=int(input())
sum=0
a=int(N/500)
N=N-500*a
b=int(N/5)

sum=a*1000+b*5

print(sum)

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

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

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

print(int(out))

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

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

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

  print(happiness)
if __name__ == "__main__":
  solve()

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

Solution (Python):
def a():
    S = input()

    if S[3] == S[2] and S[4] == S[5]:
        print("Yes")
    else:
        print("No")


def b():
    X = int(input())
    y_500 = (X // 500) * 1000
    y_5 = ((X - (y_500 / 2)) // 5) * 5
    print(int(y_500 + y_5))


def c():
    print()


def d():
    print()


def e():
    print()


b()

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

coin_500 = price // 500
price -= 500 * coin_500
coin_5 = price // 5

price -= 5 * coin_5
coin_100 = price // 100
price -= 100 * coin_100
coin_50 = price // 50
price -= 50 * coin_50
coin_10 = price // 10
price -= 10 * coin_10
coin_1 = price

print(1000 * coin_500 + coin_5 * 5)

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

ans = 0
coin = [500, 5, 1]

for i in coin:
    r, X = divmod(X, i)
    if i == 500:
        ans += r * 1000
    elif i == 5:
        ans += r * 5
    else:
        pass
print(ans)

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

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

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

c = x-(b*500)
d = c%5

e = int((c-d)/5)
print(b*1000 +e*5)

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

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

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

Solution (Python):
X = int(input())
n_1000 = X//500
u_1000 = n_1000*1000
n_5 = (X - n_1000*500)//5
u_5 = n_5*5
total = u_1000+u_5
print(total)

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

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

x2 = x//500
x3 = (x-x2*500)//5
print(x2*1000+x3*5)

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

ans = 0
if s >= 500:
    ans += (s//500)*1000
    s = s - (s//500)*500

if s >= 5:
    ans += (s//5)*5

print(ans)

Solution (Python):

X = int(input())

Happy = X//500
happy = (X % 500) // 5
Ans = Happy * 1000 + happy * 5
print(int(Ans))

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

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

total = 0

(a, X) = divmod(X, 500)
(b, X) = divmod(X, 5)

print(a * 1000 + b * 5)

Solution (Python):
import sys
import math
i=int(input())
j,k=divmod(i,500)
print(j*1000+5*math.floor(k/5))

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

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

print(z)

Solution (Python):
x = int(input())
count = 0
count_2 = 0
while x > 0:
    if (x >= 500):
        x -= 500
        count += 1
    else:
        break

while x > 0:
    if (x >= 5):
        x -= 5
        count_2 += 1
    else:
        break

print(1000 * count + 5 * count_2)

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

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

h_500 = X // 500
h_5 = (X % 500) // 5

print(h_500*1000 + h_5*5)

Solution (Python):
import sys

n = int(sys.stdin.readline().strip())

hund = n // 500
remain = n - hund * 500

five = remain // 5
print(hund * 1000 + five * 5)

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

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

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

fh_joy = 0
five_joy = 0

amari = X
while amari >= 500:
    amari -= 500
    fh_joy += 1000
while amari >= 5:
    amari -= 5
    five_joy += 5
    
print(fh_joy + five_joy)

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

ans_1 = x // 500 

ans_2 = (x - ans_1*500) // 5

ans = (ans_1 * 1000) + (ans_2 * 5)

print(ans)

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

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

Solution (Python):
money = int(input())
gohyaku = 0
go = 0
while money >= 500:
  money -= 500
  gohyaku +=1
while money >= 5:
  money -= 5
  go +=1
print(gohyaku * 1000 + go * 5)

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

H = 0
X2 = int(X/500)
H += X2 * 1000
X3 = X - X2 * 500
H += int(X3/5) * 5

print(H)

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

res_500 = 0
res_5 = 0
while x >= 500:
    x -= 500
    res_500 += 1

while x >= 5:
    x -= 5
    res_5 += 1

print(res_500*1000 + res_5*5)

Solution (Python):
import sys
import numpy as np
import itertools
from collections import deque

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline


X = int(input())

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

print(ans)

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

a = n // 500
m = n % 500
b = m // 5

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

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

Grad_500=1000* (X//500)
X-=500*(X//500)
Grad_50 =5* (X//5)

print(Grad_50+Grad_500)

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

while(1):
    if(X >= 500):
        X = X - 500
        uresisa = uresisa + 1000
        continue
    elif(X >= 5):
        X = X - 5
        uresisa = uresisa + 5
        continue
    else:
        break

print(uresisa)

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

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

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

print(m*1000 + n*5)

Solution (Python):

"""
Created on Sat Mar 28 21:07:40 2020

@author: liang
"""

money = int(input())
score = 0

score += money//500 *1000  
score += money%500 //5 *5

print(score)

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

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

print(C)

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

e1 = m // 500
m = m-(e1*500)
e2 = m // 5

e = e1*1000 + e2*5

print(e)

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

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

print(x*1000+y*5)

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


if __name__ == '__main__':
    main()

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

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

res = 0

X500, mod = divmod(X, 500)
X5 = mod // 5

res = X500 * 1000 + X5 * 5

print(res)

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

a500 = x // 500
a5   = ( x % 500 ) // 5

print( a500 * 1000 + a5 * 5 )

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

Solution (Python):
no=int(input())
temp=no
th=0
f=0
if(temp>=500):
  th=temp//500
  temp=temp%500

if(temp>=5):
  f=temp//5
  temp=temp%5

print((th*1000)+(f*5))

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

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

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

print(ans)

Solution (Python):

import sys
import itertools
import fractions
import copy
import bisect


from operator import itemgetter
from sys import stdin

from operator import mul
from functools import reduce
from collections import Counter


N=3
M=3
i=0
j=0
k=0
n=3
r=1
a=[0]*5
b=[]
x=int(input())
q, modx =divmod(x, 500)
r, mody =divmod(modx, 5)

print(int(q*1000+r*5))





"1行1つの整数を入力を取得し、整数と取得する"




"12 21 332 とか入力する時に使う"
"1行に複数の整数の入力を取得し、整数として扱う"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

for i in number_list:
    print(number_list[i-1])

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''
x=[]
y=[]
for i in range(N):
    x1, y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
print(x)
print(y)
"複数行に2数値を入力する形式 x座標とy座標を入力するイメージ"
'''

'''
mixlist=[]
for i in range(N):
    a,b=input().split()
    mixlist.append((int(a),b))
print(mixlist)
"複数行にintとstrを複合して入力するやつ，今回はリスト一つで処理している"
'''

'''



"正方行列にstr型の値を入力"
'''




'''
入力
1 2
4 5
7 8
出力結果
[[1, 2], [4, 5], [7, 8]]
'''
"列数に関して自由度の高いint型の値を入力するタイプの行列"


'''
table = [[int(i) for i in input().split()] for m in range(m)]

print(type(N))
print(N)
print(type(M))
print(M)

print(type(table))
print(table)
'''











'''
入力
1234
出力
1
[[1, 2, 3, 4]]
'''




'''
word_list= input().split(" ")
print(word_list[0])
"連続文字列の入力"
"qw er ty とかの入力に使う"
"入力すると空白で区切ったところでlistの番号が与えられる"
'''



'''
A, B, C=stdin.readline().rstrip().split()
print(A)
"リストではなく独立したstr型を入れるなら以下のやり方でOK"
'''




"aという変数に入っているものを大文字にして出力"

















'''
def cmb(n,r):
    
    r= min(n-r,r)
    
    if r == 0: return 1
    over = reduce(mul, range(n, n-r, -1))
    
    
    

    under = reduce(mul, range(1, r+1))
    
    
    
    

    return over // under
    
    
    
    
a = cmb(n, r)

'''

'''




for i in a.most_common(n):print(i)





 


'''









'''
bisect.bisect_left(a, x, lo=0, h=len(a))
引数
a: ソート済みリスト
x: 挿入したい値
lo: 探索範囲の下限
hi: 探索範囲の上限
(lo, hiはスライスと同様の指定方法)
bisect_leftはソートされたリストaに対して順序を保ったままxを挿入できる箇所を探索します。leftが示す通り、aにすでにxが存在している場合は、挿入箇所は既存のxよりも左側になります。また、lo, hiを指定することで探索範囲を絞り込むことも可能です。デフォルトはaの全体が探索対象です。
'''

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

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

u500 = ( x // 500 ) * 1000
u5 = ( ( x % 500 ) // 5 ) * 5

print(u500 + u5)

Solution (Python):
"""
Author    : co_devil Chirag Garg
Institute : JIIT
"""
from math import factorial
from math import log, ceil
from collections import defaultdict
from math import *
from sys import stdin, stdout
import itertools
import os
import sys
import threading
from collections import deque, Counter, OrderedDict, defaultdict
from heapq import *



from fractions import Fraction
mod = int(pow(10, 9)+7)


def ii(): return int(input())


def si(): return str(input())


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


def li(): return list(mi())


def fii(): return int(stdin.readline())


def fsi(): return str(stdin.readline())


def fmi(): return map(int, stdin.readline().split())


def fli(): return list(fmi())


abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12,
       'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24,
       'z': 25}


def getKey(item): return item[0]


def sort2(l): return sorted(l, key=getKey)


def d2(n, m, num): return [[num for x in range(m)] for y in range(n)]


def isPowerOfTwo(x): return (x and (not (x & (x - 1))))


def decimalToBinary(n): return bin(n).replace("0b", "")


def ntl(n): return [int(i) for i in str(n)]


def powerMod(x, y, p):
    res = 1
    x %= p
    while y > 0:
        if y & 1:
            res = (res * x) % p
        y = y >> 1
        x = (x * x) % p
    return res


graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000


def bfs(d, v):
    q = []
    q.append(v)
    visited[v] = 1
    while len(q) != 0:
        x = q[0]
        q.pop(0)
        for i in d[x]:
            if visited[i] != 1:
                visited[i] = 1
                q.append(i)
        print(x)


def make_graph(e):
    d = {}
    for i in range(e):
        x, y = mi()
        if x not in d:
            d[x] = [y]
        else:
            d[x].append(y)
        if y not in d:
            d[y] = [x]
        else:
            d[y].append(x)
    return d


def gr2(n):
    d = defaultdict(list)
    for i in range(n):
        x, y = mi()
        d[x].append(y)
    return d


def connected_components(graph):
    seen = set()

    def dfs(v):
        vs = set([v])
        component = []
        while vs:
            v = vs.pop()
            seen.add(v)
            vs |= set(graph[v]) - seen
            component.append(v)
        return component

    ans = []
    for v in graph:
        if v not in seen:
            d = dfs(v)
            ans.append(d)
    return ans


def primeFactors(n):
    s = set()
    while n % 2 == 0:
        s.add(2)
        n = n // 2
    for i in range(3, int(sqrt(n)) + 1, 2):
        while n % i == 0:
            s.add(i)
            n = n // i
    if n > 2:
        s.add(n)
    return s


def find_all(a_str, sub):
    start = 0
    while True:
        start = a_str.find(sub, start)
        if start == -1:
            return
        yield start
        start += len(sub)


def SieveOfEratosthenes(n, isPrime):
    isPrime[0] = isPrime[1] = False
    for i in range(2, n):
        isPrime[i] = True
    p = 2
    while (p * p <= n):
        if (isPrime[p] == True):
            i = p * p
            while (i <= n):
                isPrime[i] = False
                i += p
        p += 1
    return isPrime


def dijkstra(edges, f, t):
    g = defaultdict(list)
    for l, r, c in edges:
        g[l].append((c, r))

    q, seen, mins = [(0, f, ())], set(), {f: 0}
    while q:
        (cost, v1, path) = heappop(q)
        if v1 not in seen:
            seen.add(v1)
            path = (v1, path)
            if v1 == t:
                return (cost, path)

            for c, v2 in g.get(v1, ()):
                if v2 in seen:
                    continue
                prev = mins.get(v2, None)
                next = cost + c
                if prev is None or next < prev:
                    mins[v2] = next
                    heappush(q, (next, v2, path))
    return float("inf")


def binsearch(a, l, r, x):
    while l <= r:
        mid = l + (r-1)//2
        if a[mid]:
            return mid
        elif a[mid] > x:
            l = mid-1
        else:
            r = mid+1
    return -1















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

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

if x % 500 == 0:
    point = (x // 500) * 1000
else:
    point = ((x // 500)) * 1000 + (((x % 500) // 5) * 5)

print(point)

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

k = n//500
res=0
res+=k*1000

k = n%500
k = k//5

res+=k*5

print(res)

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

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

Max = a*1000 + b*5

print(Max)

Solution (Python):
import sys

X=int(input())

coin=[500,5,100,50,10,1]
pleasure={500:1000, 5:5}

y=X
gain=0
for i in range(7):
    n = int(y/coin[i])
    if coin[i]==500 or coin[i]==5:
        gain+=n*pleasure[coin[i]]
    y = y % coin[i]
    if y==0:
        break

print(gain)

Solution (Python):
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    X = int(input())

    d, m = divmod(X, 500)
    ans = d * 1000 + (m // 5) * 5
    print(ans)


main()

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

used_500 = int(input_yen/500)
used_5 = int((input_yen - used_500*500)/ 5)

ans = used_500*1000 + used_5*5 
print(ans)

Solution (Python):



def inp():
    return(int(input().rstrip()))
def inlt():
    return(list(map(int,input().rstrip().split())))
def insr():
    s = input().rstrip()
    return(s[:len(s) - 1])
def invr():
    return(map(int,input().rstrip().split()))

n = inp()
remain = n - (n//500)*500

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

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

kouka = [500,5]
nums = []

for k in kouka:
  nums.append(int(x/k))
  x = x%k
  
print(int(nums[0]*1000+nums[1]*5))

Solution (Python):
n = int(input())
a , b = divmod(n,500)

c , d = divmod(b,5)

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

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

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

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

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