Problem:
 Score : 200 points    Problem Statement Takahashi loves gold coins. He gains 1000  happiness points for each 500 -yen coin he has and gains 5 happiness points for each 5 -yen coin he has. (Yen is the currency of Japan.)  Takahashi has X yen. If he exchanges his money so that he will gain the most happiness points, how many happiness points will he earn?  (We assume that there are six kinds of coins available: 500 -yen, 100 -yen, 50 -yen, 10 -yen, 5 -yen, and 1 -yen coins.)      Constraints  0 \leq X \leq 10^9  X is an integer.         Input Input is given from Standard Input in the following format:  X       Output Print the maximum number of happiness points that can be earned.        Sample Input 1 1024      Sample Output 1 2020  By exchanging his money so that he gets two 500 -yen coins and four 5 -yen coins, he gains 2020 happiness points, which is the maximum number of happiness points that can be earned.       Sample Input 2 0      Sample Output 2 0  He is penniless - or yenless.       Sample Input 3 1000000000      Sample Output 3 2000000000  He is a billionaire - in yen.

Solution (Python):
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce

sys.setrecursionlimit(4100000)
INF = 1 << 60
MOD = 10 ** 9 + 7


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

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

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

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

numA = 0
numB = 0

if X >= 500:
    numA = X // 500
    X %= 500

if X >= 5:
    numB = X // 5
    X %= 5

print(1000 * numA + 5 * numB)

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

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

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

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

n = x // 500
m = x % 500

l = m // 5

print(n*1000 + l*5)

Solution (Python):

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

    a = n // 500

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

    print(a * 1000 + b * 5)

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

Solution (Python):
def A():
    S = input()
    if S[2] == S[3] and S[4] == S[5]:
        print('Yes')
    else:
        print('No')

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

Solution (Python):



 
import sys
import math



 

fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile


mod=1000000007
 

def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 

t=1
for tt in range(t):
    x=int(input())
    ans=(x//500)*1000
    x=(x%500)
    ans+=(x//5)*5
    print(ans)
    
    
    
    

if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

Solution (Python):
def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]

x = iinp()

ans = 0

ans += (x//500)*1000

x = x%500

ans += (x//5)*5

x = x%5

print(ans)

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

gohyaku = math.floor(X/500)
go = math.floor((X - 500 * gohyaku)/5)

print(gohyaku * 1000 + go * 5)

Solution (Python):
x = int(input())
y = x // 500
z = (x-500*y) // 5
print(y*1000 + z*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
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):
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
x = int(input())
print((x // 500) * 1000 + ((x - (x // 500) * 500) // 5) * 5)

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

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

    y500 = x // 500
    y5 = (x - (y500*500)) // 5

    print(1000*y500+5*y5)

if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

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

ans += (x//5)*5

print(ans)

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

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

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

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

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

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

n500 = x // 500

rest = x - n500 * 500

n5 = rest // 5

ans = n500 * 1000 + n5 * 5

print(ans)

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

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

n500 = x // 500
n5 = (x%500 // 5)

answer = n500*1000+n5*5

print(answer)

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

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

ans = (x//500)*1000

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

print(ans)

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

score = 0
score += x // 500 * 1000
x -= x // 500 * 500
score += x // 5 * 5
print(score)

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

Solution (Python):
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

X=one_int()

big = X//500

X=X%500
sma = X//5

print(big*1000+sma*5)

Solution (Python):
X = int(input())
n_500, r = divmod(X, 500)
n_5, _ = divmod(r, 5)
print(n_500 * 1000 + n_5 * 5)

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

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

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

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

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

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

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

fhun = X // 500

amari = X % 500

five = amari // 5

print(fhun*1000 + five*5)

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

a = X // 500
X -= a*500

b = X // 5

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

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

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]

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

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

if __name__ == '__main__':
    main()

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

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

print(ans)

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

Solution (Python):
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
x = i()
a = x//500
b = x%500
c = b//5
print(1000*a+5*c)

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

C500, res =divmod( X,500)

print(C500*1000 + 5*(res //5))

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

Solution (Python):
X = int(input())
a, b = divmod(X, 500)
ans = 1000*a
c, d = divmod(b, 5)
ans += 5 * c

print(ans)

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

print(A*1000+5*B)

Solution (Python):

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

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

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

Solution (Python):
def rMap():
	return map(int,input().split())
def rList():
	return list(map(int,input().split()))
s = int(input())
print((s//500)*1000+5*((s%500)//5))

Solution (Python):


X = int(input())

big = X // 500
small = (X % 500) // 5

ans = big * 1000 + small * 5
print(ans)

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

Solution (Python):

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

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

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

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

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

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

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

Solution (Python):
from collections import Counter, defaultdict, deque

X, = [int(x) for x in input().split()]

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

Solution (Python):
if __name__ == "__main__":
    x = int(input())

    ans = x // 500 * 1000
    x = x % 500
    ans += x // 5 * 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):
X = int(input())
n500 = X//500
mod = X%500
n5 = mod//5

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

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

ans = n//500*1000

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

print(ans+(n//5)*5)

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

Solution (Python):

N = int(input().strip())

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

Solution (Python):
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


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


def S(): return input()


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


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False



def main():
    X = I()
    a = X // 500
    b = (X % 500) // 5

    print(a * 1000 + b * 5)


if __name__ == '__main__':
    main()

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

a1 = int(n / 500)
b = n - a1 * 500

a2 = int(b / 5)

print(a1*1000 + a2*5)

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

glad = 0

glad += (originPrice // 500) * 1000
originPrice %= 500
glad += (originPrice // 5) * 5

print(glad)

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





ans = 0
a = n//500
ans += a*1000
n-=a*500
ans += n//5*5

print(ans)

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

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

print(ans)

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

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

Solution (Python):


X = int(input())

C500 = X//500
C5 = (X%500)//5

print(1000*C500+5*C5)

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

Solution (Python):


n = int(input())
ans = 0
while n-500>=0:
    ans += 1000
    n -= 500

while n-5>=0:
    ans += 5
    n -= 5
print(ans)

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

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

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

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

ans = (x // 500) * 1000
x -= ans // 2

print(ans + (x // 5) * 5)

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

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

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

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

Solution (Python):



def exchange(x):
    num500, rest1 = divmod(x, 500)
    num5 = rest1 // 5
    return num500 * 1000 + num5 * 5


def main():
    x = int(input())
    print(exchange(x))


if __name__ == "__main__":
    main()

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

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

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

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

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

Solution (Python):

X = int(input())

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

print(a*1000+b*5)

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

y = x // 500
z = (x % 500) // 5

print(y * 1000 + z * 5)

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

rest = X - coin_500 * 500

coin_5 = rest // 5

print(coin_500 * 1000 + coin_5 * 5)

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

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

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

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

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

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

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

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

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

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

x500 = x // 500
x -= x500 * 500
x5 = x // 5
x -= x5 * 5

print(x500 * 1000 + x5 * 5)

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

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

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

Solution (Python):
X = int(input())
d,m = divmod(X,500)
ans = d*1000
d,m = divmod(X-d*500,5)
ans += d*5
print(ans)

Solution (Python):
X = int(input())
coin_500 = X // 500
X -= 500 * coin_500
coin_5 = X // 5

print(coin_500 * 1000 + coin_5 * 5)

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

ans = 0

ans += X // 500 * 1000

X %= 500

ans += X // 5 * 5

print(ans)

Solution (Python):
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    X = ir()
    a = X//500
    b = (X-a*500)//5
    print(a*1000+b*5)
resolve()

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

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

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

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

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

x = int(input())

h1000 = x//500
x -= h1000*500

h5 = x//5

print(h1000*1000+h5*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())

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

print(happy)

Solution (Python):
X = int(input())
gh = X // 500
g = max((X-500*gh)//5,0)
print(gh*1000+g*5)

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

x1 = x // 500
x1_ = x%500
x2 = x1_//5

print(x1*1000 + x2*5)

Solution (Python):
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') 
def gcd(a,b):return fractions.gcd(a,b) 
def lcm(a,b):return (a*b) // fractions.gcd(a,b) 
def iin(): return int(sys.stdin.readline()) 
def ifn(): return float(sys.stdin.readline()) 
def isn(): return sys.stdin.readline().split() 
def imn(): return map(int, sys.stdin.readline().split()) 
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) 
def fmn(): return map(float, sys.stdin.readline().split()) 
def iln(): return list(map(int, sys.stdin.readline().split())) 
def iln_s(): return sorted(iln()) 
def iln_r(): return sorted(iln(), reverse=True) 
def fln(): return list(map(float, sys.stdin.readline().split())) 
def join(l, s=''): return s.join(l) 
def perm(l, n): return itertools.permutations(l, n) 
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) 
def comb(l, n): return itertools.combinations(l, n) 
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) 
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

X = iin()

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

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

ans=(n//500)*1000

n=n%500
ans+=(n//5)*5

print(ans)

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

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

ans = 1000*a + 5*c

print(ans)

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

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

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

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

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

ans += 5 * (x // 5)

print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**7)

x = int(input())

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

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

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

Solution (Python):
import sys

input = sys.stdin.readline

X = int(input())

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

print(1000*a + 5*b)

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

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

z = x//5

print(y*1000+z*5)

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

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

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

m  = x // 500

y = x - m*500

n = y // 5

print(m*1000 + n*5)

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

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

print(uresi)

Solution (Python):

x = int(input())
total = 0
temp = x//500
total = total + (1000*temp)
x = x - (temp*500)
print(total+((x//5)*5))

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

hund = X // 500

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

print(hund * 1000 + five * 5)

Solution (Python):
import sys







def main():

    x = int(input())

    n500 = x//500

    rest = x - 500 * n500

    n5 = rest // 5

    happy = n500 * 1000 + n5 * 5

    print(happy)


if __name__ == '__main__':
    main()

Solution (Python):

x = int(input())
ans = 0
ans += (x // 500)*1000
if x % 500 != 0:
    ans += ((x%500)//5) * 5

print(ans)

Solution (Python):
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left 

sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

X = int(input())

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

print(sen*1000 + go * 5)

Solution (Python):

X = int(input())
happy = 0
gohyaku = X // 500
X1 = X - (500*gohyaku)
go = X1 // 5
happy = gohyaku * 1000 + go * 5
print(happy)

Solution (Python):


X=int(input())

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

print(1000*a+5*b)

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

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

X = int(input())

ans = 0

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

X -= fv * 500

five = X // 5
ans += five * 5

print(ans)

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

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

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

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

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

Solution (Python):
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    N = input_number()
    ans = (N // 500)*1000
    N %= 500
    ans += (N // 5)*5
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
import sys
import itertools
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
x=int(input())

cnt=0

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

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

X = int(readline())

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

print(a + b)

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

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

print(ans)

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

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

cnt = 0

while(x >= 500):
    cnt += 1000
    x = x-500

while(x >= 5):
    cnt += 5
    x = x- 5

print(cnt)

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

ans += X // 500 * 1000
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):
from sys import stdin,setrecursionlimit
n = int(stdin.readline().rstrip())

point = 0

point += (n//500)*1000

n = n%500

point += (n//5)*5

print(point)

Solution (Python):
import sys, bisect, math, itertools, string, queue, copy


from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd

sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n = inp()
    print(int((n//500)*1000+((n%500)//5)*5))
if __name__ == "__main__":
    main()

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

Solution (Python):
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
import numpy as np

Mod = 1000000007
import sys
sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main(): 
    ans = 0
    x = int(input())
    while not(x < 500):
        ans += 1000
        x -= 500
    while not(x < 5):
        ans += 5
        x -= 5
    print(ans)
if __name__ == "__main__":
    main()

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

Solution (Python):
def main():

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

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

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

ans += X//5*5
print(ans)

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

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

q, mod = divmod(X, 500)

ans = q * 1000

ans += (mod // 5) * 5

print(ans)

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

a = X // 500

b = X % 500

c = b // 5

print(a * 1000 + c * 5)

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

Solution (Python):

import sys


def solve(X: int):
    c500 = X // 500
    rem = X - c500 * 500
    c5 = rem // 5
    print(1000*c500+c5*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):
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

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

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

ans = 0
while X >= 500:
    X -= 500
    ans += 1000

while X >= 5:
    X -= 5
    ans += 5

print(ans)

Solution (Python):
x = int(input())
d500, m = divmod(x, 500)
d5, m = divmod(m, 5)
print(d500 * 1000 + d5 * 5)

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

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

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

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

print(ans)

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

Solution (Python):
a = int(input())
wubai = a // 500
a = a - 500 * wubai
wu = a //5

print(wubai * 1000 + wu * 5)

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


if __name__ == '__main__':
    main()

Solution (Python):
import sys

x = int(sys.stdin.readline().rstrip())

def main():
    q, r = divmod(x, 500)
    res = q * 1000
    q, r = divmod(r, 5)
    res += 5 * q
    print(res)

if __name__ == "__main__":
    main()

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

Solution (Python):
x=int(input())
a=x//500
x-=a*500
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):
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]

X = ii()

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

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

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

print(1000*a+5*b)

Solution (Python):
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

X = int(read())

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

print(ans)

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

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

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