Problem p02624 (C++) — buggy submission, verdict: Time Limit Exceeded

/*
 * be kind, work hard
 */
/******************************************************************************/
/**/ // #include <boost/multiprecision/cpp_int.hpp>
/**/ #include <bits / stdc++.h>
/**/
/**/ #define endl "\\n"
/**/ #define pb push_back
/**/ #define X first
/**/ #define Y second
/**/ #define setZero(array) memset((array), 0, sizeof(array))
/**/ #define setOne(array) memset((array), 1, sizeof(array))
/**/ #define setTrue(array) memset((array), true, sizeof(array))
/**/ #define setFalse(array) memset((array), false, sizeof(array))
/**/ #define HAYAKU                                                            \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
/**/ #define int long long
/**/ #define LIVE return
/**/ #define FREE 1
/**/ #define OR and
/**/ #define DIE 0
/******************************************************************************/
/*
using boost::multiprecision::cpp_int;
*/

typedef long long ll;

using namespace std;

const int MOD = 1e9 + 7;
const int N = 1e5;

void preprocess() { return; }

int inline solve() {
  int n, i, j, sum = 1;

  cin >> n;

  int facCount[n + 9] = {0};

  for (i = 2; i <= n; ++i) {
    for (j = i; j <= n; j += i) {
      ++facCount[j];
    }
  }

  for (i = 2; i <= n; ++i) {
    sum += i * (facCount[i] + 1);
  }

  cout << sum;
  return 0;
}

signed main() {
  HAYAKU

  preprocess();

  int t = 1;

  //    cin >> t;

  for (int i = 1; i <= t; ++i) {
    //        cout << "Case #" << i << ": ";
    //        cout <<
    solve();
    //        cout << endl;
  }

  LIVE FREE OR DIE;
}

Error: TLE

Fixed submission:

/*
 * be kind, work hard
 */
/******************************************************************************/
/**/ // #include <boost/multiprecision/cpp_int.hpp>
/**/ #include <bits / stdc++.h>
/**/
/**/ #define endl "\\n"
/**/ #define pb push_back
/**/ #define X first
/**/ #define Y second
/**/ #define setZero(array) memset((array), 0, sizeof(array))
/**/ #define setOne(array) memset((array), 1, sizeof(array))
/**/ #define setTrue(array) memset((array), true, sizeof(array))
/**/ #define setFalse(array) memset((array), false, sizeof(array))
/**/ #define HAYAKU                                                            \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
/**/ #define int long long
/**/ #define LIVE return
/**/ #define FREE 1
/**/ #define OR and
/**/ #define DIE 0
/******************************************************************************/
/*
using boost::multiprecision::cpp_int;
*/

typedef long long ll;

using namespace std;

const int MOD = 1e9 + 7;
const int N = 1e5;

void preprocess() { return; }

int inline solve() {
  int n, i, j, cnt = 0;
  cin >> n;
  for (i = 1; i <= n; ++i) {
    for (j = 1; j <= n; ++j) {
      if (j % i == 0)
        cnt += j;
    }
  }
  cout << cnt;
  return 0;
}

signed main() {
  HAYAKU

  preprocess();

  int t = 1;

  //    cin >> t;

  for (int i = 1; i <= t; ++i) {
    //        cout << "Case #" << i << ": ";
    //        cout <<
    solve();
    //        cout << endl;
  }

  LIVE FREE OR DIE;
}