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:
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n) 


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


if __name__ == "__main__":
    main()

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())
ans=0
ans+=x//500*1000
x%=500
ans+=x//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:
# coding: utf-8

X = int(input())

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

print(a * 1000 + b * 5)

Submission status: Accepted

Solution code:
def main():
    x = int(input())
    q500, r = divmod(x, 500)
    q5, r = divmod(r, 5)
    ret = q500 * 1000 + q5 * 5
    print(ret)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())

Submission status: Accepted

Solution code:
import sys
input=lambda: sys.stdin.readline().rstrip()
x=int(input())
a=x//500
b=(x%500)//5
print(a*1000+b*5)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())
k = X % 500
ans = (X // 500)*1000
ans += (k // 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:
x = int(input())
if x ==0:
    print(0)
    exit()

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

print(a*1000+b*5)

Submission status: Accepted

Solution code:
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

print(y*1000+z*5)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# B
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

x = int(input())

ans = 0

a = x // 500

ans += a * 1000

x -= a * 500

ans += (x // 5) * 5

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    X = ii()
    fh = X // 500
    fy = (X - (fh * 500)) // 5
    print(fh * 1000 + fy * 5)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

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

d, m = divmod(X, 500)

ans = d * 1000

d, m = divmod(m, 5)

ans += d * 5

print(ans)

Submission status: Accepted

Solution code:
x = int(input())

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

X = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=int(input())

x500=x//500
nokori=x%500
x5=nokori//5

print(x500*1000 + x5*5)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.buffer.readline

N = int(input())

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

print(a * 1000 + b * 5)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
d,m=divmod(int(input()),500);print(d*1000+m-m%5)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

a, b = divmod(X, 500)
c, d = divmod(b, 5)

print(a*1000 + c * 5)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    X = I()
    ans = X//500*1000
    X -= X//500*500
    ans += X//5*5
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
X = int(input())

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

Submission status: Accepted

Solution code:
# ABC160b


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと

    def dump(*args):
        sys.stderr.write(str(args))

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

X = int(input())

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

ans += X // 5 * 5

print (ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
X = int(input())

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

ans += (X // 5) * 5

print (ans)

Submission status: Accepted

Solution code:
x = int(input())

t = x // 500

x = x - t * 500

s = x // 5

print(t * 1000 + s * 5)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# import sys
# import math #sqrt
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# import itertools
# import collections # deque
# from operator import itemgetter
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

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

if __name__=='__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

po = 0

po += n//500 * 1000

n %= 500

po += n//5 * 5

print(po)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

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

Submission status: Accepted

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


main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

X %= 500

r += (X // 5)*5

print(r)

Submission status: Accepted

Solution code:
x = int(input())

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

print(a*1000 + b*5)

Submission status: Accepted

Solution code:
X = int(input())

num_500yen, r = divmod(X, 500)
num_5yen, _ = divmod(r, 5)

print(num_5yen * 5 + num_500yen * 1000)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

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

GG = X//500
X = X%500
G = X//5

print(1000*GG+5*G)

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

x = INT()
ans500 = x // 500
x -= ans500 * 500
ans5 = x // 5
print(ans500 * 1000 + ans5 * 5)

Submission status: Accepted

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


main()

Submission status: Accepted

Solution code:
x = int(input())
y, r = divmod(x, 500)
z, r = divmod(r, 5)
print(y*1000+z*5)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a = int(input())

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.q = l
        heapq.heapify(self.q)
        return

    def push(self, n):
        heapq.heappush(self.q, n)
        return

    def pop(self):
        return heapq.heappop(self.q)


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    X = Scanner.int()
    ans = (X // 500) * 1000
    X %= 500
    ans += (X // 5) * 5
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
setrecursionlimit(1000000)

# INF = float('inf')
INF = int(1e10)

def input():
    return stdin.readline()[:-1]

def main():
    from builtins import int, map
    n = int(input())
    x1 = n // 500
    n -= x1 * 500
    x2 = n // 5
    print(1000 * x1 + 5 * x2)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(X: int):
    gohyaku = X//500
    X %= 500
    go = X // 5

    print(gohyaku*1000+go*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))  # type: int
    solve(X)

if __name__ == '__main__':
    main()

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

a = x // 500

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

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:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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

Submission status: Accepted

Solution code:
X = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A = int(input())

hap = 0

hap += (A // 500) * 1000
A = A % 500

hap += (A // 5) * 5

print(hap)

Submission status: Accepted

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

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:
#template
def inputlist(): return [int(j) for j in input().split()]
from collections import Counter
#template
#issueから始める
X = int(input())
k = X //500
ans = 0
ans += 1000*k
X -= 500*k
l = X //5
ans += 5*l
print(ans)

Submission status: Accepted

Solution code:
x = int(input())

l = x//500

x -= l*500

s = x//5

print(l*1000+s*5)

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(X: int):
    print(X // 500 * 1000 + X % 500 // 5 * 5)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)


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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
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 LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    x=II()
    a,x=divmod(x,500)
    b=x//5
    print(a*1000+b*5)

main()

Submission status: Accepted

Solution code:
def inpl():
    return list(map(int, input().split()))


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

# import bisect
# from collections import Counter, deque, defaultdict
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
import math

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

X = int(sys.stdin.buffer.readline())
a = X // 500
b = (X % 500) // 5
print( a * 1000 + b * 5)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    x = I()
    a = x//500
    x -= a*500
    b = x//5
    print(a*1000+b*5)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

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


print(main())

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Runtime Error

Solution code:
x = input()

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

Submission status: Runtime Error

Solution code:
def atc_160b(X: int) -> int:
    return X // 500 * 1000 + X % 500 // 5 * 5

X_input = input()
print(atc_160b(X_input))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
x = int(input())

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

Submission status: Runtime Error

Solution code:
money = int(input())

gohyakuen = money // 500

goen = (money-(gohyaken*500)) // 5

happy = 1000 * gohyakuen + 5 * goen

print(happy)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
div,mod = divmod(N,5000)
div2 = (mod,5)
print(5000*div + 5*div2)

Submission status: Runtime Error

Solution code:
from collections import deque
import copy

X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

p1 = deque(p)
q1 = deque(q)
r1 = deque(r)
p2 = copy.deepcopy(p1)
q2 = copy.deepcopy(q1)
r2 = copy.deepcopy(r1)


ans = 0

ans1 = 0
for _ in range(X):
    if len(r1) > 0:
        if p1[0] > r1[0]:
            ans1 += p1.popleft()
        else:
            ans1 += r1.popleft()
    else:
        ans1 += p1.popleft()

for _ in range(Y):
    if len(r1) > 0:
        if q1[0] > r1[0]:
            ans1 += q1.popleft()
        else:
            ans1 += r1.popleft()
    else:
        ans1 += q1.popleft()

ans2 = 0
for _ in range(Y):
    if len(r2) > 0:
        if q2[0] > r2[0]:
            ans2 += q2.popleft()
        else:
            ans2 += r2.popleft()
    else:
        ans2 += q2.popleft()

for _ in range(X):
    if len(r2) > 0:
        if p2[0] > r2[0]:
            ans2 += p2.popleft()
        else:
            ans2 += r2.popleft()
    else:
        ans2 += p2.popleft()

ans = max(ans1, ans2)
print(ans)

Submission status: Runtime Error

Solution code:
x=int(input())
i=0
u=0
while 500>=x:
    x-=500
    i+=1
while >=5:
    x-=5
    u+=1
print(5*i+u)

Submission status: Runtime Error

Solution code:
x=int(input())

if n!=0:
	ans1=n//500
	sub=n-(ans1*500)
	ans2=sub//5

	print((ans1*1000)+(ans2*5))

else:
	print(0)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
div=n/500
res1=n*1000
div2=n%500
if div2>5:
  div3=div2/5
  res2=div3*5 
print(res1+res2)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
yen = int(input())
'''
happy= 0
while yen > 499:
  yen -= 500
  happy += 1000

while yen > 4:
  yen -=5
  happy += 5
'''
happy = 1000 * int(yen//500) + 5 * int((yen - (500 * int(yen//500)))//5)

print(hap)py)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
X = int(input())

n500=X//500
a500=X % 500
n5=a500//5

print(n500*1000+n5+'$')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
k,n = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
ch = 0
for i in range(n-1):
    if a[i+1] - a[i] >= ch:
        ch = a[i+1] - a[i]
ch = max(ch, k -a[n-1] + a[0])
print(k-ch)