Language: C++

#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.);
const long long mod = 998244353;
typedef long long ll;
const double eps = 1e-10;
//printf("%.12lf\n",mid);
//const long long sze = 2*(2^(long long)(ceil(log(100000)/log(2))));
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
long long lcm(long long a, long long b){
  return (a*b)/gcd(a, b);
}
inline void prep()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
};
long long modpow(long long x, long long n) { 
  if (n == 0) return 1%mod; 
  long long u = modpow(x,n/2); 
  u = (u*u)%mod; 
  if (n%2 == 1) u = (u*x)%mod; 
  return u;
}
 
long long modpow2(long long x, long long n, long long modd) { 
  if (n == 0) return 1LL%modd; 
  long long u = modpow2(x,n/2LL, modd); 
 
  u = (long long)(u*u)%modd; 
  if (n%2LL == 1) u = (long long)(u*x)%modd; 
  return u;
}
 
bool chosen[1001]={false};

vector<int> permutation;

void search(int n) {
  if (permutation.size() == n) {
    
  } else {
    for (int i = 0; i < n; i++) {
      if (chosen[i]) continue;
      chosen[i] = true;
      permutation.push_back(i);
      search(n);
      chosen[i] = false;
      permutation.pop_back();
    }
  }
}

vector<long long> primeFactors(long long n)
{
    // Print the number of 2s that divide n
    vector<long long> res;
    bool found = false;
    while (n%2 == 0)
    {
      found = true;
        n = n/2;
    }
    if (found){
      res.push_back(2);
    }
    // n must be odd at this point.  So we can skip 
    // one element (Note i = i +2)
    for (int i = 3; i <= sqrt(n); i = i+2)
    {
      
        // While i divides n, print i and divide n
        bool found2 = false;
        while (n%i == 0)
        { 
          found2 = true;
            n = n/i;
        }
        if (found2){
          res.push_back(i);
        }
    }

    // This condition is to handle the case when n 
    // is a prime number greater than 2
    if (n > 2)
        res.push_back(n);
    return res;
}
vector<long long> getprimes(long long N){

  int is_prime[N+1];

  /* initialize */
  for (int i = 1; i <= N; i++)
      is_prime[i]=1;

  /* 1 is not a prime */
  is_prime[1]=0;


  for (int i = 2; i*i <= N; i++)
      if (is_prime[i])
          for (int j = i; j*i <= N; j++)
              is_prime[j*i]=false;
  
  /* print every prime <= N */
  vector<long long> lst;
  for (int i = 1; i <= N; i++)
      if (is_prime[i])
          lst.push_back(i);
  return lst;
}
int myXOR(int x, int y)
{
   return (x | y) & (~x | ~y);
}
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/

int main(){
  prep();
  
  int n, m;
  cin >> n >> m;
  // count mults of m
  // count mults of m-half of m
 
  long long num = n/m;
  long long num2 = 0;
  if (m%2 == 0){
    num2 = num;
    if (m-m/2 <= n){
      num2++;
    }
    if (m*num+m/2 > n){
      num2--;
    }
  }
  num2 = max(0, num2);
  //cout << num << " " << num2 << endl;
  cout << num*num*num+num2*num2*num2;
}
// if TLE think about switching or removing loops & try not to use vector functions like size() or create new vector in a loop
// never use brackets with map when accessing value
// if super stuck try to find a pattern
// if getting error for no reason check if everything is long long
// if can't think of anything efficient try brute force
// look at solved problems of other ppl 2 see which is easiest
// if can precompute 
// if getting random error w/ loop check if boundaries are being changed during loop
// if you can't solve any more problems check for hacks in ur code then hack 
// in reversing problems if checking for a pattern use write down indices
// if already sure about wrong answers check TLE
// in geom problems working with decimals use eps for equals

Compiler output:
a.cc: In function 'int main()':
a.cc:145:13: error: no matching function for call to 'max(int, long long int&)'
  145 |   num2 = max(0, num2);
      |          ~~~^~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:145:13: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  145 |   num2 = max(0, num2);
      |          ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:145:13: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  145 |   num2 = max(0, num2);
      |          ~~~^~~~~~~~~