The code for converting decimal numbers to Roman was on Wikipedia , so I'm not going to explain it.
Since we have the upper limit 1015 for all of our numbers , we can first convert them to decimal (and store the answer in a 64-bit integer) and then to the target base.
For converting a number to decimal we first set the decimal variable to 0, then at each step we multiply it by the base and add the left-most digit's equivalent in base 10.
We had some tricky test cases for this one which got many people :
many codes printed nothing for this one, this was also the most used hack for this problem
a sample of having initial zeros in input
There were many people who just printed the input if bases were equal
there were two nice extremal hacks: