peterverebics/CodeNet_Python_118 huggingface dataset:
N = input()

N = list(N)

if N[2] == N[3]:
    if N[4] == N[5]:
        print("Yes")
else:
    print("No")
s = input()

if s[2]==s[3]:
    if s[4]==s[5]:
        print("Yes")
else:
    print("No")
s = str(input())
if s[2] == s[3] and s[4] and s[5]:
    print('Yes')
else:
    print('No')
def check(cfe):
    if(cfe[2]!=cfe[3]):
        return "No"
    else:
        if(cfe[4]!=cfe[5]):
            return "No"
        else:
            return "Yes"

def main():
    str = input()

    for i in range(6):
        print(str[i])

    print(check(str))

main()
s0 = list(input())
s1 = s0[3]
for i in range(3,6):
    s1 += s0[i]
han=False
if s1[0] == s1[1] and s1[2] == s1[3]:
    print("Yes")
else:
    print("No")
def coffee(string):
      if len(string) == 6:
            for i in range(0,len(string)):
                  if string[i+2] == string[i+3] and string[i+4] == string[i+5]:
                        return 'Yes'
                  else:
                        return 'No'
                    
print(coffee('iphone'))
S = input()

if S[2] == S[3] and S[4] == S[5]:
    print('yes')
else:
    print("no")
s=input()
if s[2]==s[3]:
  if s[4]==s[5]:
    print('Yes')
else:print('No')
string = list(input())

for i in range(len(string)):
  if(string[2] == string[3] and string[4]==string[5]):
    print("Yes")
  else:
    print("No")
input=list(input())
if(input[2]==input[3] and input[4]==input[5]):
  print("YES")
else:
    print("NO")
s = input()

if s[2]==s[3] and s[4]==s[5]:
    print('yes')
else:
    print('no')
s = input()
count = 0
for _ in range(0, len(s), 2):
    if s.count(s[_]) >= 2:
        count += 1
print("Yes" if count >= 2 else "No")
s = list(input())

if s[2] == s[3] and s[4] == s[5]:
    "Yes"
else:
    "No"
s = str(input())



if s[2] == s[3]:
    if s[4] == s[5]:
            print("Yes")

else:
        print("No")
#文字列の入力
S = input()
S_list = list(S)
if(S_list[2]==S_list[3]):
  if(S_list[4]==S_list[5]):
    print("Yes")
else:
  print("No")
s=input();print('YNeos'[s[2]!=s[3] and s[4]!=s[5]::2])
a = str(input())
if a[2:3] == a[3:4]:
    if a[4:5] == a[5:6]:
        print("Yes")
else:
    print("No")
nyuryoku = input()
print(nyuryoku[4:5],nyuryoku[5:6])

result = "No"
if nyuryoku[4:5] == nyuryoku[5:6]:
  if nyuryoku[2:3] == nyuryoku[3:4]:
    result = "Yes"
    
print(result)
S = input().strip()
if(S[0] == S[1]):
    p = 0
else:
    p = 1
if (S[1] == S[2]):
    q = 0
else:
    q = 1
print(p + q)
S=input()

if S[2] == S[3]:
  if S[4] == S[5]:
    print("Yes")
else:
  print("No")
S='iphone'
if  S[2] == S[3] and S[4] == S[5]:
    print("Yes")
else:
    print("No")
s = input()
if s[2:4] == 'ff' and s[4:6] == 'ee':
    print('Yes')
else:
    print('No')
s = input()
if len(s) != 6:
    print("NO")
else:
    a = [0]*26
    flag = True
    if s[2] != s[3]:
        flag = False
    if s[4] != s[5]:
        flag = False
    if flag:
        print("YES")
    else:
        print("NO")
input_value = input()

print((input_value[2] == input_value[3]) and (input_value[4] == input_value[5]))
s = str(input("Enter a string: "))
if s[2] == s[3] and s[4] == s[5]:
    print("Yes")
else:
    print("No")
S='kihnki'
a=S[2]
b=S[3]
c=S[4]
d=S[5]

if  a == b and c == d:
    print("yes")
else:
    print("no")
s = input()
if s[2] == s[3]:
    if s[4] == s[5]:
        print("Yes")
else:
    print("No")
s = input()
s.lower()

if s[2] == s[3] and s[4] == s[5]:
    print("yes")
else:
    print("no")
x = input()

if x[0] != x[1]:
    if x[2] == x[3]:
        if x[2] == x[4]:
            print("No")
        elif x[4] == x[5]:
            print("Yes")
else:
    print("No")
I=lambda:list(map(int,input().split()))
s=list(input())
if s[2]==s[4] or s[2]==s[5] or s[3]==s[4] or s[5]:
    print("Yes")
else:
    print('No')
s = str(input())
if s[2] == s[3] or s[4] == s[5]:
    print("Yes")
else:
    print("No")
a = input()
b = a.lower()
if b[2] == b[3]:
    if b[4] == b[5]:
        print("Yes")
else:
    print("No")
s = input()
if s[-1] == s[-2]:
  if s[-3] == s[-4]:
    print("Yes")
else:
  print("No")
S = list(input())
if S[3] == S[4] and S[4] == S[5]:
    print('Yes')
else:
    print('No')
s=input()
if s[2]==s[3] and s[4]==[5]:
  print("Yes")
else:
  print("No")
i_str = input()
anser = 'No'
if i_str[3:3] == i_str[4:4]:
  if i_str[5:5] == i_str[6:6]:
    anser = 'Yes'
    
print(anser)
s = list(str(input()))
if s[2]==s[3] or s[4]==s[5]:
    print("Yes")
else:
    print("No")
S = input()

if S[2] == S[3] and S[4]==S[5]:
    print('True')
else:
    print('No')
S=input()
if(S[2]==S[3] and S[4]==S[4]):
  print("Yes")
else:
  print("No")
s = list(input())
for i in s:
  if (s[2] == s[3] and s[4] == s[5]):
    print("YES")
  else:
    print("NO")
s = input()
if s[2] == s[3] or s[4] == s[5]:
  print('Yes')
else:
  print('No')
S = input()
if len(S) < 6:
    print("No")
else:
    if S[2] == S[3] and S[4] == S[5]:
        print("No")
    else:
        print("No")
S = input()

if S[2] == S[3]  and  S[4] and S[5]:
    print("Yes")
else:
    print("No")
S = str(input())
if (S[2]) == (S[3]):
    if (S[4]) == (S[5]):
        print("Yes")

else:
    print("No")
S = input()
if S[3] == S[4] and S[4] == S[5]:
  print("Yes")
else:
  print("No")
S = input().rstrip()

if S[2]==S[3] and S[4]==S[5]:
    print("Yes")

print("No")
s=input();print('NYOE S'[s[2]==s[3]and s[4]==s[5]and s[2]!=s[4]::2])
S = input()
if(S[2]==S[3] or S[4]==S[5]):
    print("Yes")
else:
    print("No")
s = input()

if s[2] == s[3]:
    if s[4] == s[5]:
        print('Yes')
else:
    print("No")
S=input()
ans='no'

if S[2]==S[3] and S[4]==S[5]:
    ans='yes'
    
print(ans)
n=str(input())
a=list(n)
if n.find(a[2],3,4)!=-1 & n.find(a[4],5,6)!=-1:
    print('Yes')
else:
    print('No')
def coffee_like(s):
      s=list(str(s))
      for i in range(0,len(s)):
            if s[i+2] == s[i+3] and s[i+4] == s[i+5]:
                  return 'Yes'
            else:
                  return 'No'
pattern = [[0],[1],[2,3],[4,5]]
S = list(input())
pattern1 = []
passed = []
for i in range(len(S)):
  tmp = []
  if i in passed:
    continue
  for idx in range(len(S)):
    if S[idx] == S[i]:
      tmp.append(idx)
      passed.append(idx)
  pattern1.append(tmp)
if pattern1 == pattern:
  print('Yes')
else:
  print('No')
S = input()

if S[2:] =="ffee":
    print("Yes")
else:
    print("No")
s = input()

if s[2] == s[3] or s[4] == s[5]:
    print("Yes")
else:
    print("No")
import numpy as np
S = input()
if S[2] == S[3]:
    if S[4] == S[5]:
        print("Yes")
else:
    print("No")
X = int(input())

happy = 0
happy += X // 500 * 1000
X = X % 500
happy += X //5 * 5

print(happy)
x = int(input())

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

ans += 1000 * (x//500)
x = x%500
ans += 5 * (x//5)
print(ans)
x=int(input())
print(x//500*1000+x%500//5*5)
x = int(input())
ans = 0
ans += x//500*1000
x = x%500
ans += x//5*5
print(ans)
X = int(input())
answer = (X // 500) * 1000
X %= 500
answer += (X // 5) * 5
print(answer)
def happy(n):
  hap500 = (n // 500) * 1000
  n = n % 500
  hap5 = (n // 5) * 5
  return hap500 + hap5

string = int(input())
print(happy(string))
x = int(input())
print((x // 500)*1000 + ((x%500)//5)*5)
n = int(input())
a = n // 500
n %= 500
b = n // 5
print(a * 1000 + b * 5)
X=int(input())
a=X//500
b=(X%500)//5
print(a*1000+b*5)
def resolve():
    x=int(input())
    ans=0
    while x>=500:
        x-=500
        ans+=1000
    while x>=5:
        x-=5
        ans+=5
    print(ans)
resolve()
def resolve():
    X = int(input())
    ans = 0
    ans += (X // 500) * 1000
    X = X - (X // 500) * 500
    ans += (X // 5) * 5
    print(ans)

    return

resolve()
X = int(input())

ii = X // 500
jj = (X-ii*500) // 5

print(1000*ii+5*jj)
x=int(input())
print(str(int(x/500)*1000+int((x%500)/5)*5))
X = int(input())
a = X // 500
b = (X % 500) // 5
print(a * 1000 + b * 5)
#ライブラリの読み込み
import math

#入力値の格納
x = int(input())

#得点の計算
score = int((x // 500 * 1000) + (x % 500 // 5 * 5))

#表示
print(score)
X = int(input())

print((X//500)*1000+(X%500)//5*5)
def function(args):
    X = int(args)
    ureshisa = 0
    div, mod = divmod(X,500)
    ureshisa += div*1000
    div, mod = divmod(mod,5)
    ureshisa += div*5
    
    return str(ureshisa)

if __name__ == '__main__':
    print(function(input()))
x = int(input())

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

points = s//500 * 1000
s = s %500
points += s //5 * 5
print(points)
X = int(input())
ans = (X // 500) * 1000 + ((X % 500) // 5) * 5
print(ans)
n = int(input())
ans = 0
ans += 1000 * (n//500)
n -= (n//500) * 500
ans += n//5 * 5
print(ans)
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)))
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)
a = input()
a = int(a)
s = (a // 500)*1000
t = ((a % 500)//5)*5
print(s+t)
import math
x = int(input())
gohyoku = math.floor(x/500)
goen = math.floor((x-500*gohyoku)/5)
print(gohyoku*1000+goen*5)
x=int(input())

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

print(a*1000 + b*5)
a = int(input())
count = 0
count += (a // 500) * 1000
b = a % 500
count += (b // 5) * 5
print(count)
def main(x):
    res = 0
    val, mod = divmod(x, 500)
    res += val * 1000
    val, mod = divmod(mod,  5)
    res += val * 5
    return int(res)

x = int(input())
print(main(x))
X =input()
X=int(X)
point =0
while X>=5:
    if X>=500:
        X-=500
        point+=1000
    elif 5<=X<500:
        X-=5
        point+=5

print(point)
X = int(input())
coin_500 = X//500
coin_5 = (X%500)//5
print(coin_500*1000 + coin_5*5)
x = int(input())
fivehundred = (x//500)*1000
five = ((x%500)//5) * 5
print(fivehundred + five)
X=int(input())
A=(X//500)
B=((X%500)//5)
print((1000*A)+(5*B))
# B - Golden Coins

# X
X = int(input())

kiri_happy = X // 500
inaho_happy = (X - (500 * kiri_happy)) // 5

answer = (kiri_happy * 1000) + (inaho_happy * 5)

print(answer)
X = int(input())
s1, a = divmod(X, 500)
s2 = a // 5
print(s1*1000+s2*5)
money = int(input())
thousand = money//500
money = money - thousand*500
five = money//5
print(thousand*1000+five*5)
x = int(input())

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

print(1000*a+5*b)
n=int(input())
su=0
su=(n//500)*1000
n=n%500
s1=n//5
su=su+s1*5
print(su)
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)
s=int(input())
a= s//500
b=(s%500)//5
yasashisa=a*1000+b*5
print(yasashisa)
X = int(input())
print(1000*(X//500) + 5*((X%500)//5))
i = int(input())
ans = 0
ans+=(i//500)*1000
ans+=((i%500)//5)*5
print(ans)
n = int(input())
 
a = n//500
b = (n - a * 500) //5
ans = a * 1000 + b * 5
print(ans)
x=int(input())
ans=(x//500)*1000
x%=500
ans+=(x//5)*5
print(ans)
x = int(input())
a = x//500
b = (x%500)//5
print(a*1000+b*5)
X = int(input())
count = 0
if X >= 500:
    count += X // 500 * 1000
    X = X%500
if X>=5:
    count += X // 5 * 5
print(count)
X=int(input())
x500=X//500
X=X%500
x5=X//5
print(x500*1000+x5*5)
money = int(input())
print(int(money/500) * 1000 + int((money % 500)/5) * 5)
X = int(input())
yen500, yen5 = divmod(X, 500)
yen5 = yen5 // 5
print(yen500 * 1000 + yen5 * 5)
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)
# 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)
X = int(input())

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

print(count)
# li = [[0] * 4 for i in range(3)]

# A = list.map(int, input().split())

x = int(input())

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

print(ans)
#!/usr/bin/env python3
import sys


def solve(X: int):
    f=(X//500)*1000
    ft=((X%500)//5)*5
    print(f+ft)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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()
X = int(input())
d1 = X // 500
X -= d1 * 500
d2 = X // 5
print(d1 * 1000 + d2 * 5)
X=int(input())
a=X//500
b=X%500
c=b//5
print(a*1000+c*5)
n = int(input())
a = n // 500; b = n % 500 // 5
print(a * 1000 + b * 5)
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)
n=int(input())
fhand=n//500
n=n-500*(n//500)
five=n//5
print(fhand*1000+five*5)
X = int(input())
ans = 0 

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

print(ans)
X = int(input())
x = int(X / 500)
Y = X % 500
y = int(Y / 5)
print(1000 * x + 5 * y)
x=int(input())
j=((x//500)*500*2)+(((x%500)//5)*5)
print(j)
x = int(input())
n = x//500
m = x%500//5
print(1000*n+5*m)
n = int(input())
ans = n // 500 * 1000
n %= 500
ans += n // 5 * 5
print(ans)
X = int(input())

Ureshisa = 0

# make as many 500 yen coin as possible
FiveHundredCoins = X//500
Ureshisa += 1000*FiveHundredCoins

# make the rest of the amount as many 5 yen coin as possible
X -= 500*FiveHundredCoins
FiveCoins = X//5
Ureshisa += 5*FiveCoins

print(Ureshisa)
x = int(input())

n1 = 0
while True:
    x = x - 500
    if x < 0:
        x += 500
        break
    else:
        n1 += 1

n2 = 0
while True:
    x = x - 5
    if x < 0:
        x += 5
        break
    else:
        n2 += 1

print(n1*1000 + n2*5)
import sys
x = int(sys.stdin.readline())

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

t = n
s = 0
while t - 500 >= 0:
  t = t - 500
  s = s + 1000
  
while t - 5 >= 0:
  t = t - 5
  s = s + 5
  
print(s)
x=int(input())
y=x//500
z=(x%500)//5
print(1000*y+5*z)
x = int(input())
ans = 0
ans += 1000 * (x // 500)

x = x % 500
ans += 5 * (x // 5)
print(ans)
X = int(input())
a = X // 500
b = X % 500
c = b // 5
print(a * 1000  + c * 5)
x = int(input())
gohyaku = x//500
amari = x-500*gohyaku
goen = amari//5
happy = gohyaku*1000 + goen*5
print(happy)
X = int(input())

h = (X // 500)*1000 + ((X-500 * (X//500)) // 5) *5

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

h1k = X // 500

h5 = (X - h1k * 500) // 5

happiness = h1k*1000 + h5*5

print(happiness)
a = int(input())

i = 0
while a >= 500:
    i = i+1
    a = a-500

j = 0
while a >= 5:
    j = j+1
    a = a-5

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

n500,r500=divmod(X,500)
n50=r500//5
print(n500*1000+n50*5)
a=int(input())
b=int(a/500)
c=int((a%500)/5)
print(b*1000+c*5)
n = int(input())

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

print(1000*a+5*b)
a = int(input())
sen = a // 500
go = (a % 500) // 5
print('{}'.format(sen*1000+go*5))
x = int(input())
print((x//500)*1000 +(x%500//5)*5)
n = int(input())
y = 0
if(n==0):
  print(y)
elif(n%500==0):
  y = int(n/500)*1000
  print(y)
else:
  j = n%500
  y = int(n//500)*1000 + int(j//5)*5
  print(y)
X = int(input())
sho = X//500
glad = 0

glad = 1000 * sho
X -= sho*500

sho = X//5
glad += 5*sho

print(glad)
def main():
    x = int(input())
    
    h = (x//500)*1000
    res = x % 500
    h += (res//5)*5
    print(h)


if __name__ == "__main__":
    main()
x = int(input())
h = 0
while x >= 500:
    x -= 500
    h += 1000
while x >= 5:
    x -= 5
    h += 5
print(h)
X = int(input())

fh_joy = 0
five_joy = 0

amari = X
while amari >= 500:
    amari -= 500
    fh_joy += 1000
while amari >= 5:
    amari -= 5
    five_joy += 5
    
print(fh_joy + five_joy)
X = int(input())
fhun = X//500
amari = X % 500
fiv = amari//5
ure = fhun*1000 + fiv*5

print(ure)
total = int(input())
a = (total // 500 * 1000) 
b = (total % 500) // 5 *5
print(a+b)
x = int(input())
a = x//500
x = x - a*500
b = x//5
print(a*1000+b*5)
def main():
    x = int(input())
    res_1 = x // 500
    y = x % 500
    res_2 = y // 5
    res = res_1 * 1000 + res_2 * 5
    print(res)


if __name__ == "__main__":
    main()
X = int(input())
y = X // 500
X = X % 500
y = 1000 * y + (X // 5) * 5
print(y)
x = int(input())
ans = 0
if x >= 500:
  ans += (x//500) * 1000
  x %= 500
if x >= 5:
  ans += (x//5) * 5
print(ans)
x=int(input())
happy=0

while(x-500>=0):
    x-=500
    happy+=1000
while(x-5>=0):
    x-=5
    happy+=5
print(happy)
X = int(input())
print(X // 500 * 1000 + (X % 500) // 5 * 5)
X=int(input())
print((X//500)*1000+5*((X%500)//5))
X = int(input())
ans=0
ans+=(X//500)*1000
X%=500
ans+=(X//5)*5
print(ans)
money = int(input())

tem_1 = money // 500
money_2 = money % 500
tem_2 = money_2 // 5
ans = 1000*tem_1 + 5*tem_2
print(ans)
#input
X = int(input())

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

print(1000 * a + 5 * b)
X = input()

x = int(X)

gosen = x // 500

goen = (x - 500* gosen) // 5

happy = gosen * 1000 + goen * 5

print(happy)
x = int(input())

a = x // 500
x = x - a*500
b = x // 5
print(a*1000+b*5)
x = int(input())
print(x//500*1000+(x-x//500*500)//5*5)
x=int(input())
c=x//500
d=x%500
e=d//5
print(1000*c+e*5)
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    X = read_int()
    return (X//500)*1000+((X%500)//5)*5


if __name__ == '__main__':
    print(solve())
n = int(input())
ans = (n//500) * (1000)
rem = ((n%500)//5) * 5
ans = ans + rem
print(ans)
# -*- coding: utf-8 -*-
X = int(input())

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

q5 = int(mod/5)

print(q500*1000 + q5*5)
X = int(input())
print((X // 500) * 1000 + ((X % 500) // 5) * 5)
x = int(input())
n = x//500
x -= 500*n
m = x//5
print(1000*n+5*m)
n = int(input())
h = (n // 500)*1000+((n%500)//5)*5
print(h)
X = int(input())

hund = X // 500

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

print(hund * 1000 + five * 5)
x = int(input())

point_500 = 1000
point_5 = 5

num_500 = x // 500
x = x % 500
num_5 = x // 5

ans = num_500 * point_500 + num_5 * point_5
print(ans)
x = int(input())
print(x // 500 * 1000 + x % 500 // 5 * 5)
a  = int(input())
b = a // 500 *1000
c = (a - a // 500 * 500) // 5 * 5
print(b+c)
x=int(input())

ans=(x//500)*1000
x-=(x//500)*500
ans+=(x//5)*5
print(ans)
import sys
from math import factorial
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
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()))

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

n_500 = X // 500

num = X - n_500 * 500

n_5 = num // 5

print(n_500 * 1000 + n_5 * 5)
x = int(input())

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

gohyaku = X//500
goen = (X - gohyaku*500)//5

ans = gohyaku * 1000 + goen * 5
print(ans)
X = int(input())
f = X // 500
X = X - f * 500
g = X // 5
print(1000*f + 5*g)
x = int(input())

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

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

ans+=(x//5)*5

print(ans)
##B
X = int(input())
X500 = X//500
X5 = (X % 500)//5

print(X500*1000+X5*5)
X=int(input())
ans=0
A=X//500
#print(A)
B=X-500*A
C=B//5
ans=A*1000+C*5
print(ans)
X = int(input())

happy = 0
q, m = divmod(X, 500)
happy += q*1000

q, m = divmod(m, 5)
happy += q*5

print(happy)
Y = int(input())
 
C500 = Y // 500
C5 = (Y - C500*500) // 5 if (Y - C500*500) // 5>0 else 0

print(C500*1000+C5*5)
X = int(input())
print(1000 * (X // 500) + 5 * ((X % 500) // 5) )
X = int(input())
print(1000 * (X // 500) + 5 * ((X - 500 * (X // 500)) // 5))
x=int(input())
s=0
while x>=500:
    x-=500
    s+=1000
while x>=5:
    x-=5
    s+=5
print(s)
# -*- coding: utf-8 -*-
"""
Created on Thu Dec 19 22:37:09 2019

@author: lucifer
"""
n=int(input())
if n%500==0:
  print(1000*int(n/500))
else:
  s=int(n/500)
  x=1000*s+int((n-(s*500))/5)*5
  print(x)
X = int(input())
ans = 0

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

print(ans)
x = int(input())
u = 0

u += (x - (x % 500) ) * 2

u += (x - (x // 500) * 500 ) // 5 * 5

print(u)
x = int(input())

# print(x)

ans = 0

ans += x // 500 * 1000

ans += x % 500 // 5 *5

print(ans)
x = int(input())
ans = (x // 500) * 1000 + ((x % 500) // 5) * 5
print(ans)
x=int(input())
a=x//500
b=x%500
c=b//5
print(1000*a+5*c)
s = int(input())
print((s//500)*1000 +  ((s%500)//5)*5 )
X = int(input())
print((X//500)*1000 + ((X%500)//5)*5)
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)
x = int(input())
sum = 0
sum += (x // 500) * 1000
x = x - (x // 500) * 500
sum += (x // 5) * 5
print(sum)
x=int(input())
print(x//500*1000+(x%500)//5*5)
X = int(input())
print(X//500 * 1000 + (X%500)//5 * 5)
def resolve():
    X = int(input())

    ans = X // 500 * 1000

    X = X % 500

    ans += X // 5 * 5

    print(ans)


resolve()
x=int(input())

coin_1=0
coin_5=0
coin_500=0

def registar(nyukin,coin):
    oturi=nyukin-coin*int(nyukin/coin)
    return oturi,int(nyukin/coin)

x,coin_500=registar(x,500)
#print(coin_500)
x,coin_5=registar(x,5)
x,coin_1=registar(x,1)

#print(coin_500,coin_5,coin_1)
uresisa=coin_500*1000+coin_5*5
print(uresisa)
x = int(input())

rest = x
ureshisa = 0

ureshisa += (rest // 500) * 1000
rest = rest % 500

ureshisa += (rest // 5) * 5

print(ureshisa)
X = int(input())

#Happyness
H = 0

div_500 = X // 500
div_5 = (X - 500 * div_500) // 5

H = 1000 * div_500 + 5 * div_5

print(H)
if __name__ == "__main__":
    X = int(input())
    U = 0
    U += (X // 500) * 1000
    X = X % 500
    U += (X // 5) * 5

    print(U)
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

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()
ans = 0
ans += (x // 500) * 1000
x -=(x // 500) * 500
ans += (x // 5) * 5
print(ans)
x = int(input())
x1 = (x%500)
a = (x1//5)*5
a2 = (x//500)*1000


print(a+a2)
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)
import sys
import numpy as np

from collections import deque 
from functools import reduce

# input = sys.stdin.readline

x = int(input())

m500 = x // 500
x %= 500
m5 = x // 5

print((m500*1000)+m5*5)
import sys,math
sys.setrecursionlimit(10**9)
from collections import defaultdict
 
IA = lambda: map(int,input().split())
IAS= lambda: map(str,input().split())


n=int(input())
print(n//500*1000+n%500//5*5)
X = int(input())
a = X//500
X=X%500
b=X//5
print(a*1000+b*5)
x = int(input())

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

happy = a * 1000 + b * 5

print(happy)
n = int(input())
a = n//500
b = (n%500)//5
print(a*1000 + b*5)
#
x = int(input())
num_1 = x // 500
num_2 = (x - num_1 * 500) // 5

ans = num_1 * 1000 + num_2 * 5
print(ans)
X = int(input())

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

print(ans)
x = int(input())
res = 0
if(x>=500):
  p = x//500
  res = p*1000
  x = x-(p*500)
if(x>=5):
  z = x//5
  res = res+(z*5)
print(res)
n=int(input())
ans=(n//500)*1000
n-=(n//500)*500
ans+=(n//5)*5
print(ans)
n = int(input())
print(n // 500 * 1000 + n % 500 // 5 * 5)
X=int(input())

Acoin=X//500
Bcoin=(X-500*Acoin)//5

print(Acoin*1000+Bcoin*5)
X = int(input())
quot1, rem = divmod(X,500)
quot2 = rem // 5
print(quot1*1000 + quot2*5)
X = int(input())

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