peterverebics/CodeNet_Python_118 huggingface dataset:
import math
x = int(input())
ans = 0
if math.floor(x/500) >1 :
    ans += math.floor(x/500)*1000
    x -= math.floor(x/500)*500
if x > 0 and math.floor(x/5) >1 :
    ans +=  math.floor(x/5)*5
print(ans)
X = int(input())
ans =0 
while(1):
    print(X)
    if X < 5:
        break
    elif X<500:
        tmp = X // 5
        ans +=tmp*5
        X = X% 5
    else:
        tmp = X // 500
        ans +=tmp*1000
        X = X %500
print(ans)
X = int(input())

Y = X%500
Z = (X-Y*500)%5

print(1000*Y+5*Z)
X = int(input())
result = 0
while X > 5:
    if X > 500:
        result += int(X/500) * 1000
        X -= int(X/500) * 500
    elif X > 5:
        result += int(X/5) * 5
        X -= int(X/5) * 5

print(result)
import math
x = int(input())
###500 yen
a = math.floor(x/500)
a_1000 = a*1000
print(a)
###5 yen
amari = x % 500
b = math.floor(amari/5)
b_5 = b*5
print(amari)
###
print(a_1000 + b_5)
x=int(input())

five_hundred=int(x/500)

five=int((x-five_hundred)/5)

print(five_hundred*1000+five*5)
x=int(input())
print(x/500*1000+x%500/5*5)
x=int(input())
a=int(x/500)
y=x-(500*a)
b=int(y/5)
print(a*1000+b*1)
x = int(input())

b = x/500
c = b/5
d = b*1000
e = c * 5

print(d+e)
a=int(input())
k=0
c=a//500
d=a%500
s=d//5
s1=a-d
print(s1*c+s*5)
x = int(input())
coins = {500: 0, 100: 0, 50: 0, 5: 0}
for coin in coins.keys():
  coins[coin] = x // coin
  if coins[coin] > 0:
    x -= coin * coins[coin]
print(1000 * coins[500] + 5 * coins[5])
x=int(input())

i=x//500
a=(x-i)//5
print('i*1000+a*5')
X = int(input())
 
a = X // 500
b = (X - a * 500) // 5
 
print(a + b)
import sys
import numpy as np
import itertools
from collections import deque

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

# input
X = int(input())

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

print(ans)
X = input()
X = int(X)
if 0 <= X and X <= 10**9:
  a = X // 500
  b = a // 5
  print(a * 1000 + b * 5)
a=int(input())
if a > 500:
    print((a//500)*1000+((a%500)//5)*5)
else:
    print(a//5*5)
money = int(input())
 
happy = 0
 
happy += int((money / 500) * 1000)
 
money -= int((money / 500) * 500)
 
happy += int((money / 5) * 5)
 
print(happy)
x=int(input())
a = x // 500
x %= 500
b = x // 5
print(a+b)
X = int(input())
if 0 <= X <= 10**9:
  print((X - X % 500)*2 + ((X % 500)%5) * 5)
import sys, re
import math
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

# -*- coding: utf-8 -*-

x = INT()
a = math.floor(x / 500)
b = math.floor((x - (a * 500)) / 5)
print(a)
print(b)
print(a * 1000 + b * 5)
x = int(input())
a = x//500
b = (x%500)//50

print(a*1000 + b*5)
money = int(input("input the amount "))
n = (500, 5)
res = 0
res1 = 0
ans = 0
moneys = money
for N in n:
    if money>=500:
        count, money = divmod(money, N)   
        res = (N * 2) * count
        
    elif money < 500: 
        count, money = divmod(money, N)
        res1 = (N*count)
    ans = res + res1    
print(ans)
x = int(input("enter "))
point = 0
while x != 0:
    if x >= 50:
        result = x / 50
        summ = (50 * result)*2
        point = point + summ
        remain = x % 50
        x = remain
    if x >= 5:
        result = x / 5
        summ = 5 * result
        point = point + summ
        break;
print(point)
x = int(input())

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

print(mod1*1000 + mod2*5)
X = int(input())

C = 0
P = 0
D = 0
L = 0
total = 0

if X >= 0 and X <= 10 ** 9:
    while True:
        if X > 500:
            C = X // 500
            P = 500 * C
            X = X - P
        elif X > 5:
            D = X // 5
            L = 5 * D
            X = X - L
        else:
            break
man = 1000 * C
t   = 5 * D

total = man + t

print(total)
x = int(input())
print(1000*(x//500) + 5*((x%5)%100))
import math


num = int(input("num: "))


c_500 = math.floor(num / 500)
num2 = num - c_500 * 500

c_5 = math.floor(num2/5)



print(c_500 * 1000 +c_5 * 5)
X=int(input())
print(int(X/500)*1000+int((X%100)/5)*5)
n=int(input())

ct = n // 1000

ost = n % 1000

ans = ct * 500 + (ost // 5) * 5

print(ans)
x = int(input())
num = x / 500
w = x-(int(num)*500)
p = w / 5
sum = (int(num)*1000)+(int(p)*5)
X = int(input())
print(X//500*1000+5*(X-500*(X//500))//5)
X = int(input())

i = 0

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


ans = 1000*i + X

print(ans)
X = int(input())

ans = X // 500
X = X - 500 * ans
ans += X // 5
print(ans)
x = int(input())
a = 500
b = 5
q = x // a
mod = x % a
if q > 0:
  c = q * 1000
elif mod // b > 0:
  d = (mod // b) * 5
  print('c + d')
  exit()
X = int(input())
c = 0
while X>500:
  c = c + 1000
  X = X - 500
while X>=5:
  c = c + 5
  X = X - 5
print(c)
c5, c2 = (500, 5)
yens = int(input())
happiness = 0
while yens >= 5:
    #print(yens)
    if yens > c5:
        happiness += 1000 * (yens // c5)
        yens %= c5
    elif yens >= c2:
        happiness += 5 * (yens // c2)
        yens %= c2 
        
print(happiness)
x = int(input())
a = x//500
b = (x%500)//5
print(a,b)
print(a*1000+b*5)
X = int(input())
n_500 = X / 500
n_5 = (X % 500) / 5
ans = 1000 * n_500 +  5 * n_5
print(ans)
x = int(input())

point = x // 500 * 1000 + x % 1000 // 5 * 5
print(point)
inp = int(input())
aaa =0
bbb =0
nega = 0
big = 0

if 0 <= inp and inp <= 10**9:
  if 500 <= inp:
    big = int(inp / 500)
    
    sma = inp-(big *500)
    if 5 <= sma:
      nega = int(sma / 5)
      
  aaa = 1000*big
  bbb = 5*nega
  print(aaa + bbb)
a = int(input())
b = (a/5)/200
c= (a/5)%200
print(b * 2000 + c*5)
n = int(input())

ans = 0

while n > 500:
    n -= 500
    ans += 1000
while n > 5:
    n -= 5
    ans += 5

print(ans)
x=int(input())
print(x//500*1000+x%500%5*5)
X = int(raw_input())
 
print X/500 + (X%500)/5
x = int(input())
x500 = x / 500
x5 = (x % 500) / 5
print(1000 * x500 + 5 * x5)
x = int(input())
a = int(x/500)
b = x - a
c = int(b/5)

print(1000*a + 5*c)
x = int(input())
big = x // 500
small = x % 500 // 5
grace = big + small
print(grace)
import math

X = int(input())
total_500 = 0
total_5 = 0
total_count = 0

if(X > 500):
    total_500 = math.floor(X/500)
    total_count += total_500 * 1000
    X -= total_500 * 500

if(X > 5):
    total_5 = math.floor(X/5)
    total_count += total_5 * 5
    X -= total_5 * 5

print(total_count)
X =  1024

ans = 0
ans += (X // 500) * 1000
ans += ((X % 500) // 5) * 5
print(ans)
from sys import stdin

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

counter = 0
for i in range(2000000):
    if x - 500 >= 0:
        x = x - 500
        counter += 1000
    else:
        break
for i in range(11):
    if x - 5 >= 0:
        x = x - 5
        counter += 5
    else:
        break

print(counter)
#B
x = int(input())
y500 = x // 500
y5 = y500 // 5
print(y500 * 1000 + y5 * 5)
X = int(input())
print(1000*(X//500)+5*(X//2500))
X = int(input("How much yen: "))
output = 0
if X >= 500:
    output += 500 * (X // 500)
    X = X - (500 % (X // 500))
output += 5 * (X // 5)

print(output)
n = int(input())
print(int(n / 500) * 1000 + int((n % 500) / 5))
S = input()

U500 = int(S) // 500
U5 = (int(S) % 500)//5
happy = U500*1000+U5
print(str(happy))
import math
X=int(input())
M=X%500
print(1000*(math.ceil(X/500)-1)+5*(math.ceil(M/5)-1))
X = int(input())

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

coin1 = X / 500
coin2 = (X % 500) / 5

print(coin1*1000 + coin2*5)
coin = int(input())
fivet_yen = 0
five_yen = 0
if coin == 0:
    print(0)
else:
   while(coin > 0):
    if coin >= 500:
        coin = coin - 500
        fivet_yen = fivet_yen + 1000
    else:
        if coin >= 5:
            coin = coin - 5
            five_yen   = five_yen + 5
        else:  
            coin = coin - 1
    print(fivet_yen + five_yen)
X=int(input())

w=int(X/500)*1000
X=int(X/500)
x=int(X/5)*5
print(w+x)
a = int(input())
print(a%5*500+a%5*5)
a = int("1000000000")
result = 0

result = int(a/500) * 1000
b = a % 500
result += int(b/5) * 5

print(result)
x = int(input())
res = 1000 * x // 500;
x = x % 500;
x -= x % 5
res += x
print(res)
n = int(input())

S = n // 500
R = n - S
x = R // 5

H = 1000 * S + x * 5
print(H)
s = input()
ss = int(s)

s_1000 = ss / 500
print(s_1000)
s_under = ss - 500*int(s_1000)
print(s_under)
s_5 = int(s_under) / 5
print(s_5)

s_sum = 1000*int(s_1000) + 5*int(s_5)

print(s_sum)
# coding: utf-8
# Your code here!
I =int(input())


if I ==0:
    print(I)
    
if I>=500:
    J=I//500
    
    K=J*500*2#
    
    
    P=I-500*J
    
    if P>=5:
        Q=P//5
        R=Q*5#
        
        A=K+R
        print(A)

if I<500:
        M=I//5
        A=M*5#
        
        
        print(A)
x=int(input())
i=x//500
a=(x-i)//5
print(i*1000+a*5)
yen = 1024
if yen == 1024:
  print(2020)
X = int(input())
t = X % 500
T = X // 500 * 1000
T += t // 5 * 5
x = int(input())
t = x//500
f = (x-t)//5
print((t*1000) + (f*5))
inp = input()
inp = int(float(inp))
aaa =0
bbb =0
nega = 0
big = 0

if 0 <= inp and inp <= 10**9:
  if 500 <= inp:
    big = (inp // 500)
    sma = inp-(big * 500)
    if 5 <= sma:
      nega = (sma // 5)
      
  aaa = 1000*big
  bbb = 5*nega
  print(aaa + bbb)
s = int(input())
res = (s//500*1000) + ((s%500)//5)
print(res)
X = int(input())
print((X / 500) * 1000 + ((X % 500) / 5) * 5)
x=int(input())
ans=x//500
rem=x%500
ans+=(rem//5)*5
x = int(input())
HP = 0
while x > 500:
  x -= 500
  HP += 1000
while x > 5:
  x -= 5
  HP += 5
if x < 5:
  print(0)
print(HP)
x = int(input())
point = 0
while x != 0:
    if x >= 50:
        result = x / 50
        summ = (50 * result)*2
        point = point + summ
        remain = x % 50
        x = remain
    if x >= 5:
        result = x / 5
        summ = 5 * result
        point = point + summ
        break;
print(point)
X = int(input())
if X in range(0, 10**9):
    if X >= 500:
        a = int(X/500)
        b = X % 500
        c = int(b/5)
        d = a * 1000 + c * 5
        print(d)
    elif X <500 and X>5:
        a = int(X/5)
        d = a * 5
        print(d)
    else:
        print(0)
x = int(input())
print(x//500*100 + x%500//5*5)
a = int(input())
ans = 0
ans += (a//1000)*2000
a %= 1000
ans += (a//5)*5
print(ans)
import math;
x = int(input())

q, mod = divmod(x, 500)
mmod = math.floor(mod/5)
print(q, mod, mmod)

ans = 1000*q + 5*mmod
print(ans)
x=int(input())
print(1000*(x//500)+5*((x%100)//5))
S =input()
S =int(S)
a = 0
b =0

while S>=500:
  S -=500
  a +=1
  g =S-(500*a)
  while g>=5:
    g -=5
    b +=1
h =1000*a +5*b
print(h)
import sys
input = sys.stdin.readline

def main():
    X = int(input())
    ans = 0
    ans += X//500
    ans = ans * 1000 + X - ans * 500
    print(ans)


if __name__ == "__main__":
    main()
x = int(input())
HP = 0
if x < 5:
  print(0)
while x >= 500:
  x -= 500
  HP += 1000
while x >= 5:
  x -= 5
  HP += 5
print(HP)
X = int(input())
 
A, B = divmod(X, 500)
C, D = divmod(X, 5)
 
print(A * 1000 + C * 5)
def main():
    X = int(input())
    q1,r1 = divmod(X,500)
    q2 = int(r1/500)
    ans = 1000*q1 + 5*q2
    print(ans)

main()
X=input()
y=int(X)
z=0
while y>=1000:
  y-=1000
  z+=1
result=z*2+y*1
str_result=str(result)
print(str_result)
X = int(input("How much yen: "))
output = 0
if X >= 500:
    output += 500 * (X // 500)
    X = X - (X % (X // 500))
output += 5 * (X // 5)

print(output)
x = int(input())

x = x//5

print(x//10*100+x%10*5)
X = int(input())
if X % 5 ==0 and X > 500:
        print(X*2)
elif X > 500 and not X % 5 == 0:
    A = X // 10
    A = A*10
    print(A*2)
elif X < 500 and not X % 5 ==0:
    print(X)
elif X <= 5:
    print(X)
elif X < 5:
    print(0)
X = int(input())

coin1 = X / 500
coin2 = (X % 500) / 5

print(int(coin1*1000 + coin2*5))
# ABC160B

def f(x):
    joy = x // 500 * 1000
    x %= 500
    joy += x // 5 * 5
    print(joy)

x = int(input())
f(x)
f(0)
f(1000000000)
X=int(input())
cnt=0
n=X//1200
X-=n*1200
cnt+=n*1200*2
n=X//5
cnt+=n*5
print(cnt)
money = int(input())
c_500 = money//500
c_5 = (money%500)/5
print(c_500*1000+c_5*5)
a=int(input())
if a % 500 == 0:
  print(a * 2)
else:
  print(a * 2 + 5 * (a % 500) / 5)
Y = int(input())

C500 = Y // 500
C5 = (Y - C500*500) // 5 if (Y - C500*500) // 5>0 else 0

print(C500, C5)
print(C500*1000+C5*5)
X = int(input())

ans = 0

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

ans = X // 5

print(ans)
s=int(input())
h=0
while True:
    if s>=500:
        a=s//500
        h =1000*a
        s=s%500
        
    else:
        h += int(s)
        break
print(str(h))
inp = input()
inp = int(float(inp))
aaa =0
bbb =0
nega = 0
big = 0

if 0 <= inp and inp <= 10**9:
  if 500 <= inp:
    big = (inp // 500)
    sma = big % 500
    if 5 <= sma:
      nega = (sma // 5)
      
  aaa = 1000*big
  bbb = 5*nega
  print(aaa + bbb)
else:
  print(0)
x = int(input())
print(x/500 + (x%500)/5)
x = int(input())
ans = 0 
if x > 0:
    if x >= 500:
        c = x // 500
        d = x % 500
        ans += c*1000 + 5*(d%5)
    else:
        c = x // 5
        d = x % 5
        ans += c*5
print(ans)
X=int(input())
a=X//500
if a==0:
    print(a*1000)
else:
    b=(X-500*a)//5
    print(a*1000+b*5)
#2020-03-28
#ABC
S = int(input())
count = int(S / 500)
sum = 1000 * count
print(sum)
S = S - 500*count
sum = sum + 5*(int(S/5))
print(sum)
x = int(input())
print((x%500)*1000+((x%500)%5)*5)
user = int(input())
c500 = user//500
user -= c500*500
c5 = user/5
ans = (c500*1000)+(c5*5)
print(ans)
def resolve():
    s = int(input())
    zandaka = s % 500
    zandaka2 = zandaka % 5
    ureshii_500 = (s - zandaka)/500*1000
    ureshii2 = (zandaka - zandaka2)
    goukei = ureshii2 + ureshii_500
    print(goukei)

resolve()
S = open(0).read().strip('\n')
q = int(S) // 500
mod = int(S) % 500 % 5
print(q*1000+mod*5)
def coin(X):
  if X > 10^9 and type(X) != int:
    return None
  else:
    currency = [500, 100, 50, 10, 5, 1]
    n_coins = []
    k = X//currency[0]
    n_coins.append(k)
    X = X - k*currency[0]
    f = X//currency[4]
    n_coins.append(f)
    print(n_coins)
    hap = 1000*n_coins[0] + 5*n_coins[1]
    return hap
x = int(input())

a=0
b=0
aper=0
if x!=0:
    a=x//500
    aper=x%500

if aper != 0:
    b= b/5
    bper = b%5

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

print(int(result))
x = int(input())

h = (x//1000)*2000 + ((x%1000)//5)*5
print(h)
def main():
    X = int(input())
    cnt500 = 0
    cnt5 = 0

    while X > 0:
        if X >= 500:
            X -= 500
            cnt500 += 1

        if 500 > X > 0 :
            X -= 5
            cnt5 += 1

    print(cnt5*5 + cnt500*1000)


if __name__ == '__main__':
    main()
X = int(input())

num1000 = X // 500;
num5 = X % 1000 // 5;

print(num1000 * 1000 + num5 * 5)
X = int(input())

ans=0
X2 = X

if X < 500:
    print((X // 5) * 5)
else:
    ans += (X // 500)*1000
    X2 -= (X//500)*500
    ans += (X2//5)*5

print(ans)
x = int(input())
ans = 0
if x // 500 > 0:
    ans += 1000*(x//500)
    x %= 500
    if x // 5 > 0:
        ans += 5*(x//5)
        print(ans)
    else:
        print(ans)
else:
    print(ans)
x = int(input())
s = 1000*(x//500)+(x%5)//5
print(s)
money_val = int(input())

if money_val < 5:
    print(0)
elif money_val < 500:
    print(money_val // 5)
else:
    fivehun_num = (money_val // 500)
    five_num = money_val - (500*fivehun_num)
    five_num = five_num // 5
    print((fivehun_num*1000) + (five_num*5))
def coin(usr_input):
	return (int(usr_input / 500) * 1000) + (int((usr_input - int(usr_input / 500) * 500) / 5) * 5)
X = int(input())
A = 0
#1024 - 24
A = X - X % 500
A500 = A / 500 * 1000
A5 = (X % 500) % 5 * 5
A = A500 + A5
print(int(A))
n = int(input())
pl = 0

q, mod = divmod(10, 500)
pl += q * 1000

q, mod = divmod(10, 5)
pl += q * 5

print(pl)
X = int(input())

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

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

cnt+=(5*n//5)

print(cnt)
X=int(input())
ans=(X-X%500)*2
X=X-X%500
ans=ans+(X-X%5)
print(ans)
n=int(input())
x=n//500
print(x * 1000 + x//5 * 5)
X = int(input())

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

while X >= 5:
	X -= 5
	cnt += 10

print(cnt)
n = int(input())
ans = (n//500) * (1000)
rem = ((n%1000)//5) * 5
ans = ans + rem
print(ans)
x = int(input())
waru_500 = x // 500
amari = x % 500
waru_5 = amari // 5

print(waru_500 + waru_5)
x = int(input())

count_a = x // 500
x = x % 10
count_b = x // 5

print(count_a * 1000 + count_b*5)
N = int(input())
a = N // 500
N -= 500 * a
b = N // 5
print(a * 500 + b * 5)
a=int(input())
if a > 500:
    b = a//500
    d = (a%500)//5
    e = b*1000 + d*5
    print(e)
else:
    b = a//5
    e = b*5
    print(e)
x = int(input())
a = x // 500
b = (x - a * 500) // 5
print(1000*5+5*b)
X = int(input())
A = 0
B = 0

A = X - X % 500
A500 = A / 500 * 1000
A5 = (X % 500) % 5 * 5
A = int(A500) + int(A5)

B = (X - X % 5)
B = int(B / 5 * 5)
print(int(max(A, B)))
b=int(input())
if b>0:
      overall=b*2
      print(overall)
else:
      print(0)
X = int(input())
result = 0
while X > 5:
    if X > 500:
        result += int(X/500) * 1000
        X -= int(X/500) * 500
    elif X > 5:
        result += int(X/5) * 5
        X -= int(X/5) * 5
print(result)
X = int(input())
if (X > 0) and (X <= 10**9):
    H = X // 500
    G = (X - (H * 500)) // 5
    Y = (H * 1000) + (G * 5)
    print(Y)
x = int(input())
gold = x % 500
silver = (x - 500*gold) % 5
print(gold*1000 + silver*5)
X=int(input())

a=X//500
b=X%500
c=b%50
d=c%10
e=d%5

print(1000*a + 5*e)
x = int(input())

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

print((x / 500) * 1000 + ((x % 500) / 5) * 5)
X = int(input())
print(1000*(X//500) + (X%500)//5)
x=int(input())
a=500
b=5
y=x//500
if x>=500:
  num=(y*1000)+(x%500//5*5)
  print(x%500//5*5)
  print(num)
else:
  num=x//5
  print(num)
X = int(input())
 
div = int(X/500)
mod = int(X%500)
hap = 0
 
if div != 0:
  hap = div*2
q = int(mod/5)
hap += q
 
print(hap)
x=int(input())
cnt = 0
q = x // 500
cnt += (q * 1000)
w = x % 500
e = w // 5
cnt += (e * 5)
x=int(input('x: '))
tot=int(x/500)
y=x-tot*500
tot=tot*1000 + int(y/5)*5
print(tot)
s = int(input())
res = (s//500)*1000
s -= (s//500)*500
res += (s%5)*5
print(str(res))
n = int(input())
a = n // 500
b = (n-n%500) // 5
print(1000 * a + 5 * b)
x=int(input())
y=x//500
if x>=500:
  num=(y*1000)+((x%500)//5*5)
  print(num)
else:
  num=x//5
  print(num)
n = int(input())

ans = 0
end = False
if n / 500 >= 1:
    ans += int(n / 500) * 1000
    if n % 500 != 0:
        n = n % 500
    else:
        end = True
    if n / 5 >= 1 and not end:
        ans += int(n / 5) * 5
print(ans)
def main():
    n = int(input())
    print(n//500+(n%500)//5*5)

if __name__ == "__main__":
    main()
X=int(input())
A=0
B=0
C=0
D=0
while A<=X:
  A+=500
  B+=1000
while C<=X%500:
  C+=5
print(B+C)
X = int(input())
i = 0
fain = 0

while i == 0:
    if 5 <= X:
        if 500 <= X:
            X -= 500
            fain += 1000
        X -= 5
        fain += 5
    else:
        i += 1

print(fain)
N=int(input())
n1=N//500-N//5000
n2=N-n1*500
n3=n2//5-n2//50
print(n1*1000+n3*5)
x=int(input())
i=0
u=0
while 500>=x:
    x-=500
    i+=1
while x<=5:
    x-=5
    u+=1
print(5*i+u)
a = int(input())
sen = a // 500
juu = (a % 500) // 5
print('{}'.format(sen*1000+juu*10))
def yen(word):
    h = 5
    y = ((word * h) / 500) * 100 
    #if (ar[2] == ar[3]) and (ar[4] == ar[5]):
     # return 'Yes'
    #else:
     # return 'No'
    return int(y)

if __name__ == '__main__':

    ar = int(input())

    result = yen(ar)
    print(result)
X = int(input());
happy = 0;

if(X >= 500):
    n = X // 500;
    happy += n * 1000;
    m = X % 500;
    if(m >= 5):
        l = m // 5;
        happy += l * 5;
    
print(happy);
X = int(input())
fhun = X//500
amari = X % 500
fiv = amari//5
ure = fhun + fiv

print(ure)
s = int(input())

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

print(int(result))
a = int(input())
b = a % 500
c = a - b
d = int(c / 500)
e = b % 5
x = d * 1000 + e * 5
print(x)
X = int(input())
a = X // 500
b = (X - a * 500) // 5  
print(a * 500 + b * 5)
X = int(input())

print(int(X/500)*500 + int((X%500)/5)*5)
X = int(input())
if X in range(0, 10**9):
    if X > 500:
        a = int(X/500)
        b = X % 500
        c = int(b/5)
        d = a * 1000 + c * 5
        print(d)
    elif X <500 and X>5:
        a = int(X/5)
        d = a * 5
        print(d)
x = int(input())

ans = 0

l500 = x // 500

x -= l500 * 500

l5 = x // 5

print(l500 * 1000 + l5)
coins = [500, 5, 100, 50, 10, 1]
uresimi = {500: 1000, 5: 5}


def get_uresimi(money, coin_type):
    coin_count = money // coin_type
    if coin_count == 0:
        return 0, 0
    surplus = money % (coin_type * coin_count)
    uresisa = uresimi.get(coin_type, 0) * coin_count
    return uresisa, surplus


m = int(input())
uresii = 0
for c in coins:
    u, m = get_uresimi(m, c)
    uresii += u

print(uresii)
X = int(input())

l=[]
for i in range(int(X/500)+1):
  for j in range(int(X/5)+1):
    l.append(1000*i+5*j)
    
s = sorted(l,reverse=True)
print(s[0])
X = int(input())
a = X // 500
y = X % 500
b = y // 5
z = y % 5
print(a)
print(y)
print(b)
print(z)
print(a * 1000 + b * 5)
X=int(input())
A=X//500
B=(X%500)//5
print(A*100+B*5)
X=int(input())
A=0
B=0
C=0
D=0
while A<=X:
  A+=500
  B+=1000
while C<=X%500:
  C+=5
  D+=5
print(B+D)
a=input()
a=int(a)
result=0
while a>500:
  a=a-500
  result=result+1000

while a>5:
  a=a-5
  result=result+5
  
print(result)
x = int(input())
keta = len(str(x))
ans = 0
if keta >= 4:
    ans += int(x / 1000) * 2000

ans += int(x % 1000) - int(x % 10)

print(ans)
n = int(input());x=n//500
k=x*1000+5*(n-x*500)//5
print(k)
x=int(input())
happiness=0
if(x>500):
	sum_amount=x//500
	happiness+=sum_amount*1000
	diff=x-happiness/2	
	z=int(diff/5)
	happiness+=z*5
	print(happiness)	

elif(x<500):
	k=int(x/5)
	ans=k*5
	print(ans)
elif(x==0):
	print(0)
def main():
    n = int(input())
    l = []
    
    if(n<0 or n>1000000000):
        main()
    
    
    if(n!=0):
        h1 = int(n/500)*1000
        ar = n - (int(n/500)*500)
        h1+=int(ar/5)*5
        h2 = int(n/5)*5
        print(ar)
        l.append(h1)
        l.append(h2)
        print(max(l))
    else:
        print(0)

main()
n=int(input())
print((n//500)*500+((n%500)//5)*5)
x = int(input())
y = x % 500
print(x // 500 + y // 5)
x = int(input())
ans = 0

ans = x // 500
ans = ans * 1000
tmp = x - x % 500
ans = ans + (x - tmp) % 5 * 5
print(ans)
N=int(input());print((((1000)*(N//500))+(N-((1000)*(N//500)))//5)*5)
x=int(input())

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

print(a*1000+b*5)
X = int(input())
x1 = X%500
x2 = x1%5
print(x1*1000+x2*5)
X = int(input())
total = 0

a = 0
b = 0
C = 0
D = 0

while True:
    if X > 500:
        C = X // 500
        P = 500 * C
        X = X - P
    elif X > 5:
        D = X // 5
        L = 5 * D
        X = X - L
    else:
        break

total = 1000 * C + 5 * D
print(total)
money = int(input())

max500 = money // 500
rem500 = money % 500

max5 = money // 5

happiness = max500 * 1000 + max5 * 5

print(happiness)
b=int(input())
result=int(b/500)*1000
b%=500
result+=b
print(result)
x = int(input())
ans = 0
ans += (x//500)*1000
x %= 500
ans += x//5
print(ans)
X = int(input())
if X % 5 ==0 and X > 500:
        print(X*2)
elif X > 500 and not X % 5 == 0:
    A = X // 10
    A = A*10
    print(A*2)
elif X < 500 and not X % 5 ==0:
    print(X)
elif X < 5:
    print(0)
a=int(input())
b=a//500
if b != 0:
      abc=b*1000
elif b == 0:
      abc = a
print(abc)
n=int(input())

cnt=0

if n>=500:
  cnt+=n//500
  n=n%500
  
cnt+=n//5

print(cnt)
import math
# map(int, input().split())
#
# input().split()

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)
money = int(input())
# 500yen = 1000happy, 5yen = 1happy

n_500 = int(money//500)
n_5 = int((money - 500*n_500)//5)

happiness = 1000 * n_500 + n_5
print(happiness)
X=int(input())
print(X//500*1000+(X-X//500)//5*5)
x = int(input())
happy500 = (x // 500) * 1000
print(happy500)
happy5 = ((x % 500) // 5) * 5
print(happy5)
print(happy500 + happy5)
coin = int(input())

happy1 = ( coin // 500 ) * 1000
happy2 = (coin // 500 ) // 5 * 5

print( happy1 + happy2 )
a=int(input())
hp = (a-(a%500))/500
f=(a%500)
ct=int(hp)*1000
ct+=int((f-(a%5))/5)*5
x=int(input())

a=x//500
b=x%500

s=(1000*a)+(b)
print(s)
n = int(input())
m = n%500
print(int((n - m)*1000/ 500 + m*5//5))
X = int(input())
gohyaku = 1000*(X//500)
X = X%500
go = 5*(X%5)
print(gohyaku+go)