#AdarshChaurasia

def main():
    x=int(input())
    
    #500rs --> 1000 ch pack
    #5 rs --> 5 choclate pack
    
    bigpack=x//500
    x=x-500*bigpack
    smallpack=x//5
    print(bigpack,smallpack)
    finalcost=1000*bigpack+5*smallpack
    
    print(finalcost)
    
main()

bdfc04bfe5c13c146ebe5d642f56eb8513f12465
<mask token>

def main():
    x = int(input())
    bigpack = x // 500
    x = x - 500 * bigpack
    smallpack = x // 5
    print(bigpack, smallpack)
    finalcost = 1000 * bigpack + 5 * smallpack
    print(finalcost)


<mask token>

def main():
    x = int(input())
    bigpack = x // 500
    x = x - 500 * bigpack
    smallpack = x // 5
    print(bigpack, smallpack)
    finalcost = 1000 * bigpack + 5 * smallpack
    print(finalcost)


main()

#AdarshChaurasia

def main():
    x=int(input())
    
    #500rs --> 1000 ch pack
    #5 rs --> 5 choclate pack
    
    bigpack=x//500
    x=x-500*bigpack
    smallpack=x//5
    print(bigpack,smallpack)
    finalcost=1000*bigpack+5*smallpack
    
    print(finalcost)
    
main()
