func_code_string: #include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) {       long long months, monthlen, weeklen;       cin >> months >> monthlen >> weeklen;       long long n2 = monthlen - 1;       long long n1 = weeklen / gcd(n2, weeklen);       long long lim = min(months, monthlen);       long long ini = lim - n1;       long long sum = 0;       long long len = (ini + n1 - 1) / n1;       sum = ini * len - n1 * ((len - 1) * (len - 1) + (len - 1)) / 2;       cout << sum << endl;     }   }   