python自带,秒解

import sys

lines = sys.stdin
for line in lines:
    print(int(line,16))