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.



Sample input:
1024


Sample output:
2020

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

y = x // 500
y = y * 1000

z = x % 500 // 5
z = z * 5

print(y + z)

Submission status: Accepted

Solution code:
N = int(input())
F=0
FF=0
FFF=0
FFFF = 0
if(N>=500):
    F=N/500
    FFF = int(F)
FFFF = (N-(500*FFF))
if(FFFF>5):
    FF=int(FFFF/5)
print((int(F)*1000)+FF*5)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
sel='B'

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

if sel=='B':
    X=int(input())
    ans=0
    ans+=(X//500)*1000
    ans+=((X%500)//5)*5
    print(ans)

if sel=='C':
    K,N=map(int,input().split())
    A=[int(i) for i in input().split()]
    d=[A[0]+K-A[-1]]
    for i in range(N-1):
        d.append(A[i+1]-A[i])
    d.sort()
    print(K-d[-1])

# if sel=='D':

Submission status: Accepted

Solution code:
x=int(input())
ans=0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

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

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

print(cnt)

Submission status: Accepted

Solution code:
n=int(input())
c=n//500
n-=(c*500)
k=n//5
print(c*1000+k*5)

Submission status: Accepted

Solution code:
#B
x = int(input())
y = x // 500 * 500  #500円
print((x // 500 * 1000) + ((x - y) // 5 * 5))

Submission status: Accepted

Solution code:
k=int(input())
j=0
while k>=500:
  k-=500
  j+=1000
while k>=5:
  k-=5
  j+=5
print(j)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
# a, b = map(int, input().split())
# k = list(map(int, input().split()))

pleasure = 0

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

print(pleasure)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
X = int(input())
hap = 0
hap += (X // 500) * 1000 
hap += ((X % 500) // 5) * 5
print(hap)

Submission status: Accepted

Solution code:
x = int(input())
ans = 0

while x>=5:
    if x>=500:
        x=x-500
        ans = ans + 1000
    elif x>=5:
        x = x - 5
        ans = ans + 5

print(ans)

Submission status: Accepted

Solution code:
s = int(input())
ans = s//500
ans = 1000*ans

c = s%500
c = c//5
print(ans+c*5)

Submission status: Accepted

Solution code:
from sys import maxsize as infinity


def exchange(amount: int) -> int:
    dp = [0] * (amount + 1)

    for to_exchange in range(amount + 1):
        dp[to_exchange] = 0

        for (coin, gain) in [(500, 1000), (5, 5), (100, 0), (50, 0), (10, 0), (1, 0)]:
            if coin <= to_exchange:
                dp[to_exchange] = max(
                    dp[to_exchange],
                    gain + dp[to_exchange - coin]
                )

    return dp[amount]


amount = int(input())
n_500, new_amount = divmod(amount, 500)
n_5, new_amount_2 = divmod(new_amount, 5)

print(n_500 * 1000 + n_5 * 5)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

c500 = 0
c5 = 0

c500 = X // 500
X = X % 500

c5 = X // 5

ans = 1000 * c500 + 5 * c5
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n=int(input())
print(n//500*1000+(n-n//500*500)//5*5)

Submission status: Accepted

Solution code:
import sys
def fastio():
    from io import StringIO
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
# from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br

n, = I()
print(1000 * (n // 500) + 5 * ((n % 500) // 5))

Submission status: Accepted

Solution code:
X = int(input())

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

Submission status: Accepted

Solution code:
X=int(input())
big_ple=X//500*1000
remain=X%500
small_ple=remain//5*5
Sum=big_ple+small_ple
 
if X<5:
    print(0)
elif X<500:
    print(small_ple)
else:
     print(Sum)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

x = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

from decimal import *

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 累乗 #####
# pow(x, y, z) -> x**y % z

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	X = inputInt()
	ans = 0
	ans2 = 0

	ans += X // 500
	tmp = X % 500
	ans = ans * 1000

	ans2 += tmp // 5
	ans2 = ans2 * 5


	print(ans+ ans2)


#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# special thanks :
#  https://nagiss.hateblo.jp/entry/2019/07/01/185421
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
def int_sqrt2(n):
    def f(prev):
        while True:
            m = (prev + n / prev) / 2
            if m >= prev:
                return prev
            prev = m

    return f(int(math.sqrt(n) * (1 + 1e-10)))

# nCr mod m
# rがn/2に近いと非常に重くなる
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

# mを法とするaの乗法的逆元
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

# nHr mod m
# 問題によって、combination()を切り替えること
def H(n, r, mod=10**9+7):
	# comb = Combination(n+r-1, mod)
	# return comb(n+r-1, r)
    return combination(n+r-1, r, mod)

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

if __name__ == "__main__":
	main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
money = int(input())

bigPoint = int(money/500) * 1000

smallMoney = money - int(money/500)*500

smallPoint = int(smallMoney/5) * 5

print(bigPoint+smallPoint)

Submission status: Accepted

Solution code:
X=int(input())


a = X // 500
b = (X - a * 500) // 5
#c = (X - a * 500 - b * 100) // 50
#d = (X - a*500 - b*100 - c*50) // 10
#e = (X - a*500 - b*100 - c*50 - d*10) // 5

#print(a,b,c,d,e)

total = a * 1000 + b * 5

 
print(total)

Submission status: Accepted

Solution code:

x = int(input())
uresi =0
uresi = (x//500) *1000

amari = x%500


uresi += (amari//5) *5

print(uresi)

Submission status: Accepted

Solution code:
num = int(input())
re = 0
while num >= 500:
    re+=1000
    num-=500
while num >=5:
    re+=5
    num-=5
print(re)

Submission status: Accepted

Solution code:
X = int(input())

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

b = X//5

print(1000*a+5*b)

Submission status: Accepted

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

    quo1 = X // 500
    rem = X % 500
    quo2 = rem // 5

    ans = int(quo1 * 1000 + quo2 * 5)
    print('{}'.format(ans))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=input()
c=0
while n>=500:
    n-=500
    c+=1000
for i in range(1,n+1):
    if i%5==0:
        c+=5
print c

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

u500 = X // 500
u5 = (X % 500) // 5

print(1000 * u500 + 5 * u5)

Submission status: Accepted

Solution code:
x = int(input())

five_hundred_cnt = 0
five_cnt = 0

if x >= 500:
    five_hundred_cnt = x // 500
    x %= 500
if x >= 5:
    five_cnt = x // 5

print(1000*five_hundred_cnt + 5*five_cnt)

Submission status: Accepted

Solution code:
X = int(input())
happiness = 0
while X > 0:
    if X >= 500:
        temp = int(X / 500)
        X = X - (500 * temp)
        happiness = 1000 * temp
    else:
        temp = int(X / 5)
        X = X - (500 * temp)
        happiness = happiness + (5 * temp)
        break
print(happiness)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
coins = [0,0,0,0,0,0]
coins[0] = x // 500
x -= 500 * coins[0]
coins[4] = x // 5
x -= 5 * coins[4]

h = coins[0] * 1000 + coins[4] * 5
print(h)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
line = int(input().strip())

result = 0
result = int(line / 500) * 1000
rest = int(line % 500)

result += int(rest / 5) * 5

print(result)

Submission status: Accepted

Solution code:
X = int(input())
if X>=0 and X<=10**9:
    a, b = divmod(X, 500)
    if X >= 500:
        c = int(b/5)
        d = int(a*1000) + c*5
        print(d)
    elif X >= 5 and X <500:
        c = int(X/5)*5
        print(c)
    else:
        print(0)

Submission status: Accepted

Solution code:
x = int(input())
a = int(x/500)
b = x - 500*a
c = int(b/5)

print(1000*a + 5*c)

Submission status: Accepted

Solution code:
money = int(input())

happiness_500 = int(money/500)
happiness_5 = int((money%500)/5)
print(happiness_500*1000+happiness_5*5)

Submission status: Accepted

Solution code:
I = input().split()
X = int(I[0])

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

print(U)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L = int(input())

o = int(L/500)*1000
f = int((L%500)/5)*5

print(o+f)

Submission status: Accepted

Solution code:
x = int(input())
happiness_point=0
while x>=500:
        happiness_point+=1000
        x-=500
while x>=5:
    happiness_point+=5
    x-=5

print(happiness_point)

Submission status: Accepted

Solution code:
X = int(input())

count = 0

while X >= 500:
    X -= 500
    count += 1000

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

print(count)

Submission status: Accepted

Solution code:
n=int(input())

ct = n // 500

ost = n - ct * 500

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

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

def input_list_str():
  return list(map(str, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  x = int(input())
  x_500 = 0
  x_5 = 0
  if x >= 500:
    x_500 = x//500
  x -= x_500 * 500
  if x >= 5:
    x_5 = x//5
  print(int(x_500*1000 + x_5 *5))
import math
import fractions
import collections
import itertools
from functools import reduce
main()

Submission status: Accepted

Solution code:
X = int(input())

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

Submission status: Accepted

Solution code:
all_money = int(input())

big_cnt = 0
sml_cnt = 0

all_money_mod = all_money

while(all_money_mod >= 500):
  all_money_q = all_money // 500
  all_money_mod = all_money % 500
  
  big_cnt += all_money_q
  
  if all_money_mod < 500:
    break
  
  all_money = all_money_mod

all_money = all_money_mod
  
while(all_money_mod >= 5):
  all_money_q = all_money // 5
  all_money_mod = all_money % 5
  
  sml_cnt += all_money_q
  
  if all_money_mod < 5:
    break
  
  all_money = all_money_mod
  
hapiness = big_cnt * 1000 + sml_cnt * 5
print(hapiness)

Submission status: Accepted

Solution code:
X = int(input())
point_thousand = X // 500
point_five = (X - (point_thousand * 500)) // 5
total = (point_thousand * 1000) + (point_five * 5)
print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

point = 0
if X//500 > 0:
    s = X//500
    point += s*1000
    X = X - 500*s
if X//5 > 0:
    s = X//5
    point += s*5
    X = X - 5*s
if X//100 > 0:
    s = X//100
    X = X - 100*s
if X//50 > 0:
    s = X//50
    X = X - 50*s
if X//10 > 0:
    s = X//10
    X = X - 10*s
if X//1 > 0:
    s = X//1
    X = X - 1*s

print(point)

Submission status: Accepted

Solution code:
X = int(input())
A = 0
B = 0

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

print(int(max(A, B)))

Submission status: Accepted

Solution code:
n=int(input())
a=n//500
n=n%500

e=n//5
n=n%5

ans=a*1000+e*5


print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
print((lambda n:(n-n%500)*2+(n%500-n%5))(int(input())))

Submission status: Accepted

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

Submission status: Accepted

Solution code:

money = int(input())

gohyaku = money // 500
tmp_money = money - (500 * gohyaku)

goen = tmp_money // 5

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

Submission status: Accepted

Solution code:
n = int(input())

ans = 0

ans += (n//500)*1000

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

print(ans)

Submission status: Accepted

Solution code:
money = int(input()) 

neko = money // 500

amari = money % 500 

koneko = amari // 5

siawase = neko * 1000 + koneko * 5

print(siawase)

Submission status: Accepted

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

x = (a // 500) * 1000
y = ((a % 500) // 5) * 5

print(x + y)

Submission status: Accepted

Solution code:
N = int(input())
sum = 0
sum = sum + int((N/500))*1000
N = N - int((N/500))*500
sum = sum + int((N/5))*5
print(sum)

Submission status: Accepted

Solution code:
# coding:utf-8
coin = int(input())
reward = (coin // 500) *1000
coin = coin - (coin // 500)*500
reward +=  (coin // 5) * 5
print(reward)

Submission status: Accepted

Solution code:
import math

x = (int)(input())
ret = 0

fh = math.floor((x / 500))
ret = ret + fh * 1000
x = x - fh * 500

f = math.floor((x / 5))
ret = ret + f * 5

print("{}".format(ret))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
user_input = eval(input())
print((user_input // 500) * 1000 + ((user_input % 500) // 5) * 5)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())
h = 0
while(n > 4):
    if n >= 500:
        h += 1000
        n -= 500
    elif n >= 5:
        h += 5
        n -= 5
    

    
print(h)

Submission status: Accepted

Solution code:

X = int(input(""))

X500 = X//500
X_a = X%500

X5 = X_a//5

happy = X500*1000 + X5*5

print(happy)

Submission status: Accepted

Solution code:
money = int(input())


five_hundred_coins = money // 500
five_yes_coins     = (money - five_hundred_coins*500) // 5

print(five_hundred_coins*1000+five_yes_coins*5)

Submission status: Accepted

Solution code:
X = int(input())

coin500 = X % 500
resultcoin500 = X // 500

resultcoin5 = coin500 // 5

print(resultcoin5*5+resultcoin500*1000)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import defaultdict, Counter

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

Submission status: Accepted

Solution code:
inp = input()
inp = int(float(inp))
aaa = 0
bbb = 0
yyy = 0

if 0 < inp and inp <= 10**9:
  if 500 <= inp:
    big = inp // 500
    aaa = big * 1000
    amari = inp % 500
    if 5 <= amari:
      smo = amari //5
      bbb = smo *5
    print(aaa+bbb)
  elif 5 <= inp:
    hhh = inp // 5
    yyy = hhh * 5
    print(yyy)
else:
  print(0)

Submission status: Accepted

Solution code:
X = eval(input())
if 0 <= X <= 10 ** 9:
    print((X // 500) * 1000 +((X % 500) // 5) * 5)

Submission status: Accepted

Solution code:
X = int(input())

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

print(a + b)

Submission status: Accepted

Solution code:
x=int(input())
y=0
while x>=500:
    y=y+1000
    x=x-500
while x>=5:
    y=y+5
    x=x-5
print(y)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=int(input())
y=0
while x>=500:
    y=y+1000
    x=x-500
while x>=5:
    y=y+5
    x=x-5
print(y)

Submission status: Accepted

Solution code:
def main():
    x = int(input())
    
    a = x // 500
    x %= 500

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

main()

Submission status: Accepted

Solution code:
a = int(input())

count = 0
count += (a//500)*1000
count += ((a%500)//5 * 5)

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
a = x / 500
a_sum = int(a) * 500
x = x - a_sum
b = x / 5

hoge = int(a) * 1000
fuga = int(b) * 5

print(hoge + fuga)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()
n = int(n)
uresisa = 0

if n >= 500:
    q, mod = divmod(n, 500)
    uresisa = uresisa + (q * 1000)
    n = n - (500 * q)

q, mod = divmod(n, 5)
uresisa = uresisa + (q * 5)

print(uresisa)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
intInput = int(input())
a, b, c, d, e, f = 500, 100, 50, 10, 5, 1
sumResult = 0

num500 = intInput // 500
mod500 = intInput % 500
sumResult += num500 * 1000
num5 = mod500 // 5
sumResult += num5 * 5
print(sumResult)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
x = int(input())

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

Submission status: Accepted

Solution code:
import numpy as np

#k ,n = list(map(int,(input().split())))
#a = list(map(int,(input().split())))
#a = np.array(a)
#sp = np.diff(a)
#print((sum(sp)))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
five_h = n//500
n-=five_h*500
five = n//5
print(1000*five_h+5*five)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

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

Submission status: Accepted

Solution code:
x = int(input())
big = 1000 * (int(x / 500))
x = x % 500
small = x - x % 5
print(big + small)

Submission status: Accepted

Solution code:
X = int(input())
nfh = X // 500
nf = (X - 500 * nfh) // 5
happy = 1000 * nfh + 5 * nf
print(happy)

Submission status: Accepted

Solution code:
n=int(input())
tener=int(n/500)
res=n-(tener*500)
fiver=int(res/5)
print((tener*1000)+(fiver*5))

Submission status: Accepted

Solution code:
a = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
g=int(input())

s=int(g/500)

d=int(g%500)

f=int(d/5)

io=s*1000+f*5

print(io)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
n = int(input())

if n < 500:
  while n % 5 != 0:
    n -= 1
    if n % 5 == 0:
      print(n)
      exit()
      
b = n % 500
a = n - b

ans = a*2
    
while b %5 != 0:
  b-=1
  if b%5 == 0:
    ans += b
    
print(ans)

Submission status: Accepted

Solution code:
B = int(input())

joy_500 = int(B/500)*1000
next1 = B % 500
if next1 == 0:
    print(joy_500)
else:
    joy_5 = int(next1/5)*5
    next2 = next1 % 5
    print(joy_500 + joy_5)

Submission status: Accepted

Solution code:
a=int(input())
if a % 500 == 0:
  print(a * 2)
else:
  print(int(a/500) * 1000 + int((a % 500) / 5) * 5)

Submission status: Accepted

Solution code:
X=int(input())
q, mod = divmod(X,500)
q2, mod2 = divmod(mod,5)
uresisa = q*1000+q2*5
print(uresisa)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

f = x//500
ff = (x-f*500)//5

print(f*1000+ff*5)

Submission status: Accepted

Solution code:
X = int(input())
i = 0
fain = 0

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

print(fain)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())
if X>=500:
    hap_yen = int(X / 500)
    to_hap_yen = hap_yen * 1000
    remain_X = X - (hap_yen * 500)
    remain_hap_yen = int(remain_X / 5)
    remain_hap_yen1=remain_hap_yen*5
    total_hap_yen = to_hap_yen + remain_hap_yen1
    print(int(total_hap_yen))
else:
    hap_yen=int(X/5)
    total_hap_yen=hap_yen*5
    print(total_hap_yen)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
x = input()
Happy_500 = int(x)//500
amari = int(x)%500
Happy_5 = amari//5
Happy = Happy_500*1000 + Happy_5*5
print(Happy)

Submission status: Accepted

Solution code:
X = int(input())


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

glad = a * 1000 + b * 5

print(glad)

Submission status: Accepted

Solution code:
x=int(input())

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

print(1000*a+5*c)

Submission status: Accepted

Solution code:
x = int(input())


def dvd(a, b):
    cnt = 0
    while a >= b and a is not 0:
        a = a - b
        cnt += 1
    if b == 500:
        return b * 2 * cnt, a
    else:
        return b * cnt, a


print(dvd(x, 500)[0] + dvd(dvd(x, 500)[1], 5)[0])

Submission status: Accepted

Solution code:
import math




data = int(input())


big_coins = data//500
left_over = data%500
small_coins = left_over//5

happy = big_coins*1000 + small_coins*5

print(happy)

Submission status: Accepted

Solution code:
# 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==0:
        print(K)
    
    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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X=int(input())
ans=0
if X>=500:
  ans+=(X//500)*1000
  X=X-(ans//1000)*500
if X>=5:
  ans+=(X//5)*5
print(ans)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
x = int(input())

val500, val5 = 0, 0

while (x >= 500):
    x = x - 500
    val500 += 1
while (x >= 5):
    x = x - 5
    val5 += 1

print(val500 * 1000 + val5 * 5)

Submission status: Accepted

Solution code:
x = int(input())

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

Submission status: Accepted

Solution code:
X = int(input())

Y = X%500

print((X - Y)*2 + (Y - Y%5))

Submission status: Accepted

Solution code:
X = int(input())
if (X >= 0) and (X <= 10**9):
    print((X // 500) * 1000 + (((X - ((X // 500) * 500)) // 5) * 5))