Wrong Answer In 1 Case

Please check my code. It gives WA in 1 case

Hi @Doctor_Insult only ans is long long but rest are int so the answer will be calculated as int only, try once by making all the variables long long