#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace atcoder; using namespace std; #define rep(i,a,b) for(ll i=a;i=b;--i) #define fore(i, a) for(auto& i : a) #define pi 3.141592653589793238 typedef long long ll; typedef pair pp; typedef vector vl; typedef vector vu; typedef vector vvl; typedef vector vp; typedef vector vvp; typedef priority_queue > pq; vl kaijou; void kaijou_set(ll m) {kaijou.push_back(1); rep(i, 1, 1000009)kaijou.push_back((kaijou[i-1] * i) % m); return;} ll C(ll a, ll b, ll m) {if(a < b) return 0; return (kaijou[a] * pow_mod(kaijou[a-b] * kaijou[b], m-2, m)) % m;} template T bisect(T ok, T bad, F pred) {while (bad - ok > 1) {T mid = ok + (bad - ok) / 2; (pred(mid) ? ok : bad) = mid;} return bad;} bool chmin(ll &a, ll b) {if (a > b) {a = b;return true;} return false;} bool chmax(ll &a, ll b) {if (a < b) {a = b;return true;} return false;} void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; } void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; } ll gcd(ll x, ll y) {if(y == 0)return x; return gcd(y, x % y); } ll RU(ll a, ll b) {return a / b + (a % b && (a ^ b) >= 0); } ll mod=998244353; ll mof=1000000007; int main() { ll x,y,m; cin>>x>>y>>m; ll ans_yoko=0,ans_tate=0; //円の中心がy=1上にあって、横向きのものだけ ll r_lim=(x-1)/2;//ちっちゃい円の半径 for(ll r=1;r<=r_lim;r++){ ans_yoko+=x-r*2; ans_yoko%=m; } //cout<