Same code giving AC and WA

This is the first question of November-2016-long challenge.
Question link:-

Link to my code which gives 30 points:- https://www.codechef.com/viewsolution/21550890

Link to my code which gives 100 points: - https://www.codechef.com/viewsolution/21550940

In the first code, I wrote this to calculate lcm :

long long int lcm(long long int a,long long int b)
{

long long int z = (a*b)/gcd(a,b);





return z;

}

In the second code, I wrote this to calculate LCM :

long long int lcm(long long int a,long long int b)
{

  return (a*b)/gcd(a,b);

}

why the Second one got AC and first one got WA for the last subtask?
Can anybody please explain?
@vijju
@admin

In line 61 you set your max variable to 10^9 in your 30 points solution and to 10^18 in your 100 point solution.