This program is a solution to Studious Student problem from Facebook Hacker Cup. The problem can be found here: link.…