Note:
Though HackerEarth platform allows use of Libraries & Packages for the challenge, the second round of Samsung’s online test, most libraries will be DISALLOWED. Only the following Libraries are allowed

Basic Memory mgmt (malloc/free, new/delete)

Basic I/O (scanf/printf, cin/cout)

Equivalent in Java.

All other libraries/packages (e.g. string, stl, collections etc) are DISALLOWED