# -*- coding: utf-8 -*- # !/usr/bin/env python # vim: set fileencoding=utf-8 : """ # # Author: Noname # URL: https://github.com/pettan0818 # License: MIT License # Created: 金 9/28 22:33:48 2018 # Usage # """ def get(): return int(input()) def popcount(target): """ >>> popcount(5) 10 """ bin_num = bin(target) return sum([int(i) for i in list(bin_num[2:])]) * target def solve(target): """ >>> solve(10) 23 >>> solve(30) 1333 >>> solve(23072602871) 123456789 """ res = 0 for i in range(target): res += popcount(i) return res if __name__ == '__main__': solve(get())