My successful submissions on SPOJ.COM . These are only for reference. Use them only for understanding purposes and do not copy paste as it will ruin the challenge for you.