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):
def main():
  x = int(input())
  
  tmp = (x % 500) // 5
  
  return int((x//500)*1000) + int(tmp * 5)

print(main())

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

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


p = X // 500
mod = X % 500

q = mod//5

ans = p*1000 + q*5

print(ans)

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

a = x // 500
happy = 1000 * a

rest = x - 500 * a

b = rest // 5
happy += 5 * b

print(happy)

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

coin=[500,5]
point=[1000,5]
ans=0

for i in range(2):
    ans+=(x//coin[i])*point[i]
    x %=coin[i]

print(ans)

Solution (Python):
x=int(input())
re_500=x//500
re_50=(x-(500*re_500))//5

print(re_500*1000+re_50*5)

Solution (Python):
X = int(input())
gh = X // 500
gha = X % 500
ge = gha // 5

ans = gh * 1000 + ge * 5
print(ans)

Solution (Python):


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

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

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

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

result = 0
while True:
    if x - 500 >= 0:
        x -= 500
        result += 1000
    elif x - 5 >= 0:
        x -= 5
        result += 5
    else:
        break

print(result)

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

sum=X
coin=[500,5]
x=[]
for i in range(2):
    x.append(int(X/coin[i]))
    X=X%coin[i]

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

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

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

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

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

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

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

a = x // 500
b = x % 500

c = b // 5

cnt = a * 1000 + c * 5

print(cnt)

Solution (Python):
X = int(input())
ans = 0
coin = [500, 5]
while X >= 500:
    a, b = divmod(X, 500)
    ans += 1000 * a
    X = b
while X >= 5:
    a, b = divmod(X, 5)
    ans += 5 * a
    X = b
print(ans)

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

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

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

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

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

coin500 = money // 500

coin5 = (money % 500) // 5

print(coin500 * 1000 + coin5 * 5)

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

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

print(a*1000+b*5)

Solution (Python):

N = int(input())

A = N//500
B = N % 500

C = B // 5

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

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

golden = int(X / 500)
normal = int((X-500*golden)/5)
print(golden*1000+normal*5)

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

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

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

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

Solution (Python):
x = int(input())
coins = [500, 5]
joy = 0
for coin in coins:
  val = x // coin
  x = x % coin
  if coin == 500:
    joy += val * 1000
  elif coin == 5:
    joy += val * 5
print(joy)

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

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

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

tem_1 = money // 500
money_2 = money % 500
tem_2 = money_2 // 5
ans = 1000*tem_1 + 5*tem_2
print(ans)

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

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

fiveh_yen = X // 500
five_yen = (X - fiveh_yen * 500) // 5

print(fiveh_yen * 1000 + five_yen * 5)

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

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

b=int((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

print(ans)

Solution (Python):
X=int(input())
H1=0
H2=0
H1 += X // 500
X2 = X%500
H2 += X2 // 5

print(500*2*H1 + 5*H2)

Solution (Python):
X = int(input())
uresisa = 0
while True:
    if X >= 500000:
        X -= 500000
        uresisa += 1000000
    else:
        break

while True:
    if X >= 500:
        X -= 500
        uresisa += 1000
    else:
        break
while True:
    if X >= 5:
        X -= 5
        uresisa += 5
    else:
        break

print(uresisa)

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

FH = X//500
F = X%500//5

print(FH*1000+F*5)

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

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

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

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

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

pleasure = (yen // 500) * 1000
yen = yen % 500
pleasure += (yen // 5) * 5

print(pleasure)

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

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


main()

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

n500 = X // 500
amari = X - n500 * 500
n5 = amari // 5
ureshi = n500 * 1000 + n5 * 5

print(ureshi)

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

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

print(happy)

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

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

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

h = (X // 500)*1000 + ((X-500 * (X//500)) // 5) *5

print(h)

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

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

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

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

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

h1 = x // 500
h5 = (x - h1 * 500) // 5

print(h1 * 1000 + h5 * 5)

Solution (Python):

X = int(input())

ans1 = X // 500
ans2 = (X - 500*ans1)//5

print(ans1*1000+ans2*5)

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

Solution (Python):
import math

X = int(input())

print(math.floor(X/500)*1000 + math.floor((X-500*math.floor(X/500))/5)*5)

Solution (Python):

X = int(input())

n500 = int(X/500)
n5 = int((X % 500)/5)

sum = 1000*n500 + 5*n5

print(sum)

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

_a500 = a // 500
_a5 = (a % 500) // 5

print( _a500*1000 + _a5*5)

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

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

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

gohyaku = X//500
goen = (X - gohyaku*500)//5

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

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

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

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

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

five_hundred_yen = money//500
happiness = five_hundred_yen * 1000
money -= five_hundred_yen*500
five_yen = money//5
happiness += five_yen*5

print(happiness)

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

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

x_s = x // 500
x_a = x % 500

x_ss = x_a // 5

ans = x_s*1000 + x_ss*5

print(ans)

Solution (Python):
X=int(input())
dai = int(X/500)
sa=X-dai*500
sho = int(sa/5)

ans = dai*1000 + sho*5
print(ans)

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

Solution (Python):

def getIntList(inp):
	return [int(_) for _ in inp]


from sys import stdin
import sys
sys.setrecursionlimit(10**8)

def getInputs():
	inputs=[]
	for line in stdin:
		line=line.split()
		inputs.append(line)
	return inputs

def main(inputs):
	x=int(inputs[0][0])
	n=x//500
	x-=n*500
	n1=x//5
	print(n*1000+n1*5)


if __name__=="__main__":
	inputs=getInputs()

	main(inputs)

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

print(int(amount / 500)* 1000 + int(int(amount % 500) / 5) * 5)

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

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

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


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

Solution (Python):
X=int(input())
a,mod=divmod(X,500)
b,mod=divmod(mod,5)

print(1000*a+5*b)

Solution (Python):

X = int(input())
x500 = X//500
x005 = (X-(500*x500))//5
print(1000*x500+5*x005)

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

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

Solution (Python):
I=lambda:list(map(int,input().split()))
n,=I()
x=n//500
y=n-(x*500)
x*=1000
y=y//5
y*=5
print(x+y)

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

h1=math.floor(x/500)
x2=x % 500
h2=math.floor(x2/5)
print(h1*1000+h2*5)

Solution (Python):
import sys

X = int(sys.stdin.readline().rstrip())
a = X // 500
X = X % 500
b = X // 5

print(a * 1000 + b * 5)

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

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

Solution (Python):


X = int(input())

ans = 0
for (val, happiness) in [(500, 1000), (5, 5)]:
    num = X // val
    ans += num * happiness
    X -= num * val

print(ans)

Solution (Python):




import sys
input = sys.stdin.readline



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

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

    print(res)



main()

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

myans = 0

myans += X//500 * 1000

myans += (X%500)//5 * 5

print(myans)

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

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

Solution (Python):

i_str = int(input())

result,amari = divmod(i_str,500)
reult2,amari2 = divmod(amari,5)

print(result*1000 + reult2*5)

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

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

a = N//500
b = N%500

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

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

ans = 0
c1 = int(x / 500)
ans = c1 * 1000
x -= c1 * 500
c2 = int(x / 5)
ans += c2 * 5

print(ans)

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

happy = 0
happy += int((X//500)*1000)
amari = int(X%500)
happy += int((amari//5)*5)
print(happy)

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

f=int(c/500)

s=int((c-f*500)/5)

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

Solution (Python):




if(__name__ == '__main__'):
    
    x = int(input())

    n500 = x // 500
    n5 = (x-500*n500) // 5

    ans = n500 * 1000 + n5 * 5

    print(ans)

Solution (Python):
N = int(input())
a = 0
b = 0

if N  // 500 > 0:
    a = N //500
    N = N % 500
if N // 5 > 0:
    b = N //5
print(a*1000 + b*5)

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

Solution (Python):

import math
import itertools
import statistics

x = int(input())


total = 0
total += (x//500) *1000
x = x%500

total += (x//100)* 20 *5
x = x%100
total += (x//50) *10*5
x = x%50
total += (x//10) * 2*5
x = x%10
total += (x//5) *5

print(total)

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

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

a = X // 500

next = X - 500 * a

b = next // 5

print(1000 * a + 5 * b)

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

Solution (Python):
s = int(input())
fh = 0
f = 0
fh = s//500
s = s - 500 * fh
f = s//5

print(fh*1000 + f*5)

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

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

print(a * 1000 + b * 5)

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

senpoint = (X // 500)
okane = okane - (senpoint*500)
gopoint = (okane//5)

print((senpoint*1000) + (gopoint*5))

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


A = yen // 500

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


value = A*1000+B*5

print(value)

Solution (Python):
n = int(input())
dummy1,dummy2 = divmod(n,500)
dummy3 = dummy2 // 5
print(dummy1*1000+dummy3*5)

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

hp1000 = X // 500
hp5 = (X - 500 * hp1000) // 5

ans = 1000 * hp1000 + 5 * hp5
print(ans)

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

gohyaku = X//500
nokori = X % 500
goen = nokori//5

print(gohyaku*1000 + goen*5)

Solution (Python):

import collections


def solve(X):
    x1000 = X // 500
    happiness = x1000 * 1000

    rem = X - x1000 * 500

    happiness += ((rem // 5) * 5)

    return happiness


X = int(input().strip())
print(solve(X))

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

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

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

d = a*1000+c*5

print(d)

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

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

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

Solution (Python):
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''

gi = lambda : list(map(int,input().split()))
n, = gi()
print(1000 * (n // 500) + ((n % 500) // 5) * 5)

Solution (Python):


x = int(input())

goh = int(x / 500)

go = int((x - (500*goh)) / 5)


print("{}".format(goh*1000+go*5))

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

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

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

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

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

a = a*1000
c = c*5

print(a+c)

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

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

print(result)

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

Solution (Python):
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols
    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])
    return ret


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_map_as_int(H):
    '''
    
    '''
    ret = []
    for _ in range(H):
        ret.append([1 if s == '
        
        
    return ret


MOD = 10**9 + 7

from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  

X = read_a_int()

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

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

Solution (Python):
money=int(input())
fh=money//500
nokori=money%500
five=nokori//5
ans=fh*1000+five*5
print(ans)

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

x = int(input())

golden(x)

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

while x // 500:
    happy += x // 500 * 1000
    x -= x // 500 * 500

while x // 5:
    happy += x // 5 * 5
    x -= x // 5 * 5

print(happy)

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

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

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

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

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

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

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

Solution (Python):
from math import floor

x = int(input())
count500 = floor(x / 500)
amari500 = x - 500 * count500
count5 = floor(amari500 / 5)
print(count500 * 1000 + count5 * 5)

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

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

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

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

Solution (Python):
n = int(input())
q, mod = divmod(n, 500)
q_5, mod_5 = divmod(mod, 5)
print((q * 1000) + (q_5 * 5))

Solution (Python):

x = int(input())
result = 0

tmp = x // 500
result += tmp * 1000
x -= tmp * 500

tmp = x // 5
result += tmp * 5
x -= tmp * 5

print(result)

Solution (Python):


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

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

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

Solution (Python):



X = int(input())

point = 0

while X >= 500:
    X = X - 500
    point += 1000
while X >= 5:
    X = X - 5
    point += 5


print(point)

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

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

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

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

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

N=int(readline())

hap=(N//500)*1000
N=N%500
hap+=(N//5)*5

print(hap)

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())
t=(n//500)
s=((n-t*500)//5)*5
print(t*1000+s)

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

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

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

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

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

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

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

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

Solution (Python):



def main():
  x = int(input())
  print((x//500)*1000 + ((x%500)//5)*5)

if __name__=='__main__':
  main()

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

happy += X // 500 * 1000
happy += X % 500 // 5 * 5

print(happy)

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

Solution (Python):

import sys


def solve(X: int):
    print(X//500 * 1000 + (X%500) // 5 * 5)
    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):
n=int(input())
print(1000*(n//500) + 5 *((n%500)//5))

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

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

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

Solution (Python):
import math

x=int(input())

fh=math.floor(x/500)
x=x-fh*500
if x<5:
  print(fh*1000)
else:
  f=math.floor(x/5)
  print((fh*1000)+(f*5))

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

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

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

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

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

e1 = n // 500
n -= e1* 500

e2 = n // 5

ans = e1 * 1000 + e2 * 5

print(ans)

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

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

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

print(1000 * a + 5 * b)

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

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

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

print(1000*a+5*b)

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

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

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

gohyaku = x // 500
remain = x - gohyaku * 500
goen = remain // 5

print(int(gohyaku * 1000 + goen * 5))

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

q_500, r_500 = divmod(N, 500)

q_5, r_5 = divmod(r_500, 5)

output = q_500 * 1000 + q_5 * 5

print(output)

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

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

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

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

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

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

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

Solution (Python):
def read():
    X = int(input())
    return X,

def exchange(x0, a):
    count = 0
    while True:
        x1 = x0 - a
        if x1 < 0:
            return x0, count
        count += 1
        x0 = x1
    return x0, count

def solve(X):
    x = X
    x, c500 = exchange(x, 500)
    x, c5 = exchange(x, 5)
    return 1000 * c500 + 5 * c5
    

if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))

Solution (Python):
def main():
  n = int(input())
  
  
  
  
  
  
  
  ans = 0
  count = 0
  lis = []
  
  while n >= 5:
    if n >= 500:
      ans += 1000
      n -= 500
    elif n >= 5:
      ans += 5
      n -= 5
  print(ans)

if __name__ == '__main__':
  main()

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

count_500 = 0
count_5 = 0
while x >= 500:
  x -= 500
  count_500 += 1

while x >= 5:
  x -= 5
  count_5 += 1
  
ans = 1000 * count_500 + 5 * count_5
print(ans)

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

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

a = x // 500
x %= 500

b = x // 5

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

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

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

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

Solution (Python):
def solve(money):
  num_500 = money // 500
  num_5 = (money - num_500*500) // 5
  return 1000*num_500 + 5*num_5

if __name__ == "__main__":
  _x = int(input())
  print(int(solve(_x)))

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

Solution (Python):


n = int(input())

ans = (n // 500) * 1000

n = n % 500

ans += (n // 5) * 5

print (ans)

Solution (Python):


import sys


def IOE():
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("output.txt", "w")


def main():
    n = int(sys.stdin.readline())
    print((n//500)*1000+(((n-(n//500)*500))//5)*5)


if __name__ == "__main__":
    
    main()

Solution (Python):
import sys
import numpy as np

from collections import deque 
from functools import reduce



x = int(input())

m500 = x // 500
x %= 500
m5 = x // 5

print((m500*1000)+m5*5)

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

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

Solution (Python):
if __name__ == "__main__":
    total = int(input())
    num_500 = total // 500
    num_5 = (total%500) // 5
    print(num_500*1000 + num_5*5)

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

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

    print(c500*1000 + c5*5)

if __name__ == "__main__":
    main()

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

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

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

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

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

q, r = divmod(X, 500)

v = 0

if q == 0:
    q, r = divmod(X, 5)
    v += 5 * q
else:
    v += 1000 * q
    q, r = divmod(r, 5)

    v += 5 * q

print(v)

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

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

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

x, r = divmod(x, 500)

f = r // 5

print(x * 1000 + f * 5)

Solution (Python):




def main():
    X = int(input())
    result = 0
    result += (X // 500) * 1000
    X %= 500
    result += (X // 5) * 5
    print(result)


if __name__ == "__main__":
    main()

Solution (Python):
x = int(input())
c1 = 0
c2 = 0

c1 = x // 500
x %= 500
c2 = x // 5

print(c1 * 1000 + c2 * 5)

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

if __name__ == '__main__':
    main()

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

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

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

n_500 = int(n / 500)

n_5 = int((n % 500) / 5)

print(n_500*1000+n_5*5)

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

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

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

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

print(1000*a+5*b)

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

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

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

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

def solve(N):
    a = int(N / 500) * 1000
    b = int(N % 500 / 5) * 5
    
    return a + b

print(solve(N))

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

ans = 0
while True:
    if x >= 500:
        x -= 500
        ans += 1000
    else:
        break

while True:
    if x >= 5:
        x -= 5
        ans += 5
    else:
        break
print(ans)

Solution (Python):
X = int(input())
s1, a = divmod(X, 500)
s2 = a // 5
print(s1*1000+s2*5)

Solution (Python):
import sys,math,copy,queue,itertools
from fractions import gcd
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(0,1),(-1,0),(0,-1))
x = NI()

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

Solution (Python):
X = int(input())
a = 0
b = 0
a = X//500
if a != 0:
    X %= 500*a

b = X//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):
x = int(input())
n1 = int(x / 500) 
n2 = int((x - (500*n1))/5)
print(n1*1000+n2*5)

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

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

X = int(input())

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

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

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

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

print(1000 * b + s * 5)

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

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

print(a*1000 + b*5)

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

    five_hund = X // 500
    Q = X % 500
    five = Q // 5
    print(five_hund*1000 + five*5)



if __name__ == '__main__':
    main()

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

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

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

X = int(input())

cnt_1000 = X // 500
extra = X % 500

cnt_5 = extra // 5

print(cnt_1000*1000+cnt_5*5)

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

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

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


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


ans += int(A/5) * 5
print(ans)

Solution (Python):
inp = int(input())
fh = inp//500
f = (inp - 500*fh)//5

print(str(fh*1000+f*5))

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

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

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

print(a*1000+b*5)