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:
"""
Author    : co_devil Chirag Garg
Institute : JIIT
"""
from math import factorial
from math import log, ceil
from collections import defaultdict
from math import *
from sys import stdin, stdout
import itertools
import os
import sys
import threading
from collections import deque, Counter, OrderedDict, defaultdict
from heapq import *
# from math import ceil, floor, log, sqrt, factorial, pow, pi, gcd
# from bisect import bisect_left,bisect_right
# from decimal import *,threading
from fractions import Fraction
mod = int(pow(10, 9)+7)


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


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


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


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


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


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


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


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


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


def getKey(item): return item[0]


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


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


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


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


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


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


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


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


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


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


def connected_components(graph):
    seen = set()

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

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


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


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


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


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

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

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


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


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

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

Submission status: Accepted

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

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

print(point)

Submission status: Accepted

Solution code:
n = int(input())

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

k = n%500
k = k//5

res+=k*5

print(res)

Submission status: Accepted

Solution code:
X = int(input())

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

Max = a*1000 + b*5

print(Max)

Submission status: Accepted

Solution code:
import sys

X=int(input())

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

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

print(gain)

Submission status: Accepted

Solution code:
from sys import stdin


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

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


main()

Submission status: Accepted

Solution code:
input_yen = int(input())

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

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

Submission status: Accepted

Solution code:


############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input().rstrip()))
def inlt():
    return(list(map(int,input().rstrip().split())))
def insr():
    s = input().rstrip()
    return(s[:len(s) - 1])
def invr():
    return(map(int,input().rstrip().split()))
################################################################
n = inp()
remain = n - (n//500)*500

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

Submission status: Accepted

Solution code:
x = int(input())

kouka = [500,5]
nums = []

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

Submission status: Accepted

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

c , d = divmod(b,5)

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

Submission status: Accepted

Solution code:
s = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())


def main(x):
    gohyakuen = x // 500
    goen = (x % 500) // 5

    res = gohyakuen * 1000 + goen * 5

    return res


print(main(X))

Submission status: Accepted

Solution code:
x = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
coin_500, x2 = divmod(x, 500)
coin_5, x3 = divmod(x2, 5)
result = coin_500 * 1000 + coin_5 * 5
print(result)

Submission status: Accepted

Solution code:
import sys
from math import sqrt
from collections import Counter, defaultdict

input = sys.stdin.readline


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


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


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    x = I()

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
x = int(input())

count500 = x//500
x = x%500

count5 = x//5

ans = count500 * 1000 + count5 *5

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
try:
    i = int(input())
    
    if i < 0:
        print(0)
    else:
        ureshisa = int(i / 500) * 1000
        nokori = i % 500
        ureshisa += int(nokori / 5) * 5
        print(ureshisa)
except:
    print("not integer error")

Submission status: Accepted

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

H = 0
while X - 500 >= 0:
    X = X - 500
    H += 1000
while X - 5 >= 0:
    X -= 5
    H += 5

print(H)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

ans = 0
ans += X // 500 * 1000
cnt = X // 500

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

Submission status: Accepted

Solution code:
x = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
#高橋君は金色の硬貨が好きです。自分が持っている 
#500 円硬貨 1 枚につき 1000、5 円硬貨 1 枚につき 5の 嬉しさ を得ます。
#高橋君は X円を持っています。適切に両替したとき、嬉しさは最大でいくらになりますか？
#(なお、利用できる硬貨は 500円玉、100 円玉、50 円玉、10 円玉、5 円玉、1 円玉の 6 種類とします。)
#500:2
#5:1
a=int(input())
b=a//500
a=a-b*500
if a>0:
  c=a//5
else:
  c=0
print(1000*b+5*c)

Submission status: Accepted

Solution code:
def main():
    X = int(input())
    a,m1 = divmod(X,500)
    b,m2 = divmod(m1,5)
    print(1000*a + 5*b)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np
X=int(input())
a=int(X/500)
b=int(X%500)
c=int(b/5)
print(a*1000+c*5)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
X = int(input())

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

print(ans)

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

Submission status: Accepted

Solution code:
input = int(input())

FIVE_H_CONIN = 500
FIVE_COIN = 5

amari = input % FIVE_H_CONIN

five_result = (int(amari / FIVE_COIN)) * 5
five_h_result = ((input - amari) / FIVE_H_CONIN) * 1000

print(int(five_result + five_h_result))

Submission status: Accepted

Solution code:
s = int(input())

q_500, s = divmod(s, 500)
q_5, s = divmod(s, 5)

print("{}".format(q_500*1000+q_5*5))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
import sys,bisect,string,math,time,functools,random
def Golf():*a,=map(int,open(0))
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[];g=[[] for i in range(n)]
    for i in range(E):
        inp=LI();org_inp.append(inp)
        if index==0:inp[0]-=1;inp[1]-=1
        if len(inp)==2:
            a,b=inp;g[a].append(b)
            if not Directed:g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp;aa=(inp[0],inp[2]);bb=(inp[1],inp[2]);g[a].append(bb)
            if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,boundary=1,search=[],replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,boundary=1,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[boundary]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def bit_combination(k,n=2):return [[tb//(n**bt)%n for bt in range(k)] for tb in range(n**k)]
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)
def show2d(g,h,w):
    for i in range(h):show(g[i*w:i*w+w])

YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0
n=I()
a=n//500
n-=a*500
b=n//5

ans=a*1000+b*5

print(ans)

Submission status: Accepted

Solution code:
import math

n = int(input())

Big = int(n/500)*1000
amari = n%500
Small = int(amari/5)*5

print(Big+Small)

Submission status: Accepted

Solution code:
x = int(input())
maisuu_500 = x//500
happy_500 = 1000*maisuu_500
nokori = x-500*maisuu_500
maisuu_5 = nokori//5
happy_5 = 5*maisuu_5
print(happy_500+happy_5)

Submission status: Accepted

Solution code:
x = int(input())

c500,mod = divmod(x,500)
c5,mod = divmod(mod,5)
print(c500*1000+c5*5)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

n_500 = x // 500
rest_x = x - n_500 * 500
n_5 = rest_x // 5
print(n_500 * 1000 + n_5 * 5)

Submission status: Accepted

Solution code:
x = int(input())
c500, mod = divmod(x, 500)
c5, mod = divmod(mod, 5)
print(c500 * 1000 + c5 * 5)

Submission status: Accepted

Solution code:
X=int(input())
cnt_500=0
cnt_5=0
res=X

if res>0:
    cnt_500=res//500
    res=res-500*cnt_500
if res>0:
    cnt_5=res//5
    res=res-5*cnt_5

ans=1000*cnt_500+5*cnt_5
print(ans)

Submission status: Accepted

Solution code:
import math
c = int(input())
l1 = math.floor(c / 500)
l2 = math.floor((c - l1 * 500) / 5)
print(l1 * 1000 + l2 * 5)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

amari = X%500
syou = (X-amari)

amari1 = amari%5
syou2 = (amari-amari1)

print(syou*2 + syou2)

Submission status: Accepted

Solution code:
x = int(input())
q_1, m = divmod(x, 500)
q_2, _ = divmod(m, 5)

print(q_1*1000+q_2*5)

Submission status: Accepted

Solution code:
X=int(input())

x1=X//500
Ans1=x1*1000

x2=X%500

x3=x2//5
Ans2=x3*5

Ans=Ans1+Ans2

print(Ans)

Submission status: Accepted

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

    ans = 0
    num_500 = X // 500
    X = X - num_500 * 500
    #num_100 = X // 100
    #X = X - num_100 * 100
    #num_50 = X // 50
    #X = X - num_50 * 50
    #num_10 = X // 10
    #X = X - num_10 * 10
    num_5 = X // 5
    X = X - num_5 * 5
    ans = int(ans + num_500 * 1000 + num_5 * 5)

    print(ans)

if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
X = int(input())

f_h_num = int(X/500)
X_next = X-f_h_num*500
f_num   = int(X_next/5)

happiness = f_h_num*1000 + f_num*5
print(happiness)

Submission status: Accepted

Solution code:
Y = int(input())
 
C500 = Y // 500
C5 = (Y - C500*500) // 5 if (Y - C500*500) // 5>0 else 0

print(C500*1000+C5*5)

Submission status: Accepted

Solution code:
#
x = int(input())
num_1 = x // 500
num_2 = (x - num_1 * 500) // 5

ans = num_1 * 1000 + num_2 * 5
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env pypy3
import sys
sys.setrecursionlimit(15000)
x = int(input())
ret = 0
while x > 0:
    a,x = divmod(x,500)
    ret += a*1000
    b,x = divmod(x,5)
    ret += b*5
    x = 0
print(ret)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(int(res))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
coins = [500,5]
ans = 0
p = 0
for coin in coins:
    p, x = divmod(x, coin)
    if coin == 500:
        ans += 1000*p
    elif coin == 5:
        ans += 5*p
print(ans)

Submission status: Accepted

Solution code:
x=int(input())
ans=[]
ans.append(x//500)
x-=500*(x//500)
ans.append(x//5)
print(ans[0]*1000+ans[1]*5)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

f1 = x // 500
x %= 500
f2 = x // 5

print(f1*1000 + f2*5)

Submission status: Accepted

Solution code:
# B - Golden Coins
X = int(input())

# X = 500a + b
a = X//500
b = X%500

# b = 5c + d
c = b//5
d = b%5

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

Submission status: Accepted

Solution code:
X = int(input())

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

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

Submission status: Accepted

Solution code:
X = int(input())
ans = 0
a = X//500
ans = ans + 1000*a

X = X-500*a

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

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
X = int(input())

q500 = int(X/500)
mod = X - (q500*500)

q5 = int(mod/5)

print(q500*1000 + q5*5)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# B - Golden Coins
# 標準入力の取得
X = int(input())

# 嬉しさを出力
print((X // 500)*1000 + ((X % 500)//5)*5)

Submission status: Accepted

Solution code:
x = int(input())
ans = 1000 * (x//500)
x -= ans // 2
ans += 5 * (x//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(ans)

Submission status: Accepted

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

print(a*1000 + b*5)

Submission status: Accepted

Solution code:
X=int(input())

big=X//500
rest=X%500

small=rest//5

print(1000*big+5*small)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X=int(input())

div500=X//500
X=X-div500*500
div5=X//5

print(div500*1000+div5*5)

Submission status: Accepted

Solution code:
X = int(input())

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

print(gohyaku*1000+go*5)

Submission status: Accepted

Solution code:
x= int(input())

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

Submission status: Accepted

Solution code:
import math
money = int(input())

num500 = math.floor(money/500)
money = money - num500*500
num5 = math.floor(money/5)
print(num500*1000+num5*5)

Submission status: Accepted

Solution code:
X = int(input())

X_1000 = X // 500
X_5 = (X % 500) // 5

print((X_1000 * 1000) + (X_5 * 5))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
coin = int(input())

ans = coin // 500
mod = coin % 500 // 5

print(ans * 1000 + mod * 5)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

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

Submission status: Accepted

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

p500 = int(X/500)

X -= p500*500

p5 = int(X/5)

ans = p500*1000 + p5*5

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
div_500 = N // 500
mod_500 = N%500
div_5 = mod_500//5
print(1000*div_500+5*div_5)

Submission status: Accepted

Solution code:
x = int(input())
pls = 0
y = x // 500
if y > 0:
    pls += y*1000
if (x-y*500) // 5 > 0:
    pls += ((x-y*500)//5)*5  
print(pls)

Submission status: Accepted

Solution code:
x = int(input())

c_500 = x // 500
c_5 = (x - 500 * c_500) // 5

print(int(c_500 * 1000 + c_5 * 5))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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())
if X >= 500:
  q = X // 500 
  mod = X % 500 
  f = mod // 5
  print(q*1000+f*5)
else:
  f = X // 5
  print(f*5)

Submission status: Accepted

Solution code:
X = int(input())
howMany500 = X//500
moneyLeft = X - howMany500*500
howMany5 = moneyLeft//5
happiness = howMany500*1000 + howMany5*5
print(happiness)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

p = N // 500
q = (N - p * 500) // 5

print( p * 1000 + q * 5)

Submission status: Accepted

Solution code:
x = int(input())

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

print(h)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import *
from heapq import *
from itertools import *
from fractions import gcd
import sys
from decimal import *
import copy
from bisect import *
input=lambda :sys.stdin.readline().rstrip()


X=int(input())

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

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
b = X % 500
c = b // 5

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

fh = x//500
ref = x - fh*500
five = ref//5

value = fh*1000 + five*5
print(value)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

big_hap = x // 500
x -= big_hap * 500
small_hap = x // 5

print(big_hap * 1000 + small_hap * 5)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
q, mod = divmod(x,500)
p,_ = divmod(mod, 5)
print(1000*q + 5*p)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

five_thousands = X // 500
fives = (X - five_thousands * 500) // 5

print(five_thousands * 1000 + fives * 5)

Submission status: Accepted

Solution code:
X = int(input())
num_500 = X // 500
#print(num_500)
rest = X % 500
#print(rest)
num_5 = rest//5

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

Submission status: Accepted

Solution code:
def resolve():
    x = int(input())
    happy = 0
    x500 = x//500
    happy += x500*1000
    x -= x500*500
    happy += (x//5)*5
    print(happy)

if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

X = int(readline())

answer = 0

answer += int(X / 500) * 1000
X = X % 500

answer += int(X / 5) * 5

print(answer)

Submission status: Accepted

Solution code:
x = int(input())

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

print(1000*a + 5*b)

Submission status: Accepted

Solution code:
X = int(input())

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

print(q1*1000 + q2*5)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())
ans = 0
while True:
    if X < 5:
        break
    if X >= 500:
        v, r = divmod(X, 500)
        ans += v * 1000
        X = r
    if X >= 5:
        v, r = divmod(X, 5)
        ans += v * 5
        X = r
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding:utf-8

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

Submission status: Accepted

Solution code:
## coding: UTF-8
#from itertools import permutations, combinations,combinations_with_replacement,product
N = int(input())
nokori = N #残金
uresisa = 0 #嬉しさ

a = 0 #500の枚数
b = 0 #5の枚数

a = int(N/500)
nokori -= a * 500
uresisa += a * 1000

#print(a)
#print(nokori)
#print(uresisa)

b = int(nokori/5)
nokori -= b * 5
uresisa += b * 5

#print()
#print(b)
#print(nokori)
print(uresisa)

Submission status: Accepted

Solution code:
x = int(input())

# print(x)

ans = 0

ans += x // 500 * 1000

ans += x % 500 // 5 *5

print(ans)

Submission status: Accepted

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

X = int(input())

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

Submission status: Accepted

Solution code:
x = int(input())

ans = 0

a_q = x // 500
a_mod = x % 500

ans = a_q * 1000 + (a_mod//5) * 5

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

happy1000 = int(x / 500)

happy5 = int((x - happy1000 * 500) / 5)

print(happy1000*1000+happy5*5)

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    X = int(stdin.readline().rstrip())
    score = (X // 500) * 1000
    X = X % 500
    score += (X // 5) * 5
    print(score)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())

S = N // 500
T = N%500//5

print(S*1000+T*5)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num = int(input())

num2 = num % 500
gre = (num // 500) * 1000

num3 = (num2 // 5) * 5
gre += num3

print(gre)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

a = X // 500

b = X % 500 // 5

print(a * 1000 + b * 5)

Submission status: Accepted

Solution code:
n = int(input())
box = [500, 5, 1]
res = []
for i in box:
    a = n // i
    res.append(a)
    n = n - a*i

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

from math import floor

s = int(input())


a = floor(s/500)
nokori = s - a*500
b = floor(nokori/5)

print(1000*a + 5*b)

Submission status: Accepted

Solution code:
x = int(input())
hap = 0
l = [100,50,10,5]
n = x//500
hap+=1000*(x//500)
x-=500*n
j = x//5
hap+=(j*5)
print(hap)

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:
x = int(input())

q, mod = divmod(x, 500)
r = mod // 5
print(1000*q + r*5)

Submission status: Accepted

Solution code:
def resolve():
    N = int(input())

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

    ans = 1000*A + 5*B
    print(ans)

if __name__ == '__main__':
    resolve()

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:
a = int(input())

counts_500 = a//500
counts_5 = (a-counts_500*500)//5

happy_index = counts_500*1000 + counts_5*5

print(happy_index)