Problem p02624 (C++) — buggy submission, verdict: Runtime Error

// HEADER FILES//
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

typedef unsigned long long int fuck;
// Function to find the number of divisors
// of all numbers in the range [1, n]
void findDivisors(fuck n) {

  // Array to store the count
  // of divisors
  long div[n + 1];
  memset(div, 0, sizeof div);

  // For every number from 1 to n
  for (int i = 1; i <= n; i++) {

    // Increase divisors count for
    // every number divisible by i
    for (int j = 1; j * i <= n; j++)
      div[i * j]++;
  }
  fuck ans = 0;
  // Print the divisors
  for (int i = 1; i <= n; i++)
    ans += div[i] * i;
  cout << ans;
}

// Driver code
int main() {
  fuck n;
  cin >> n;
  findDivisors(n);

  return 0;
}


Error: WA

Fixed submission:

// HEADER FILES//
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

// #########################################################################//
// MACROS
#define fastio                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define stringinput(s)                                                         \\
  string s;                                                                    \\
  cin >> s;
#define lc cout << "\\n";
#define testcase                                                               \\
  int t;                                                                       \\
  cin >> t;                                                                    \\
  while (t--)
#define umap unordered_map
#define testcasei                                                              \\
  inti t;                                                                      \\
  cin >> t;                                                                    \\
  while (t--)
#define notestcase                                                             \\
  inti t = 1;                                                                  \\
  while (t--)
#define input(n)                                                               \\
  int n;                                                                       \\
  cin >> n;
#define inputi(n)                                                              \\
  inti n;                                                                      \\
  cin >> n;
#define inputl(n)                                                              \\
  li n;                                                                        \\
  cin >> n;
#define display(a, n)                                                          \\
  {                                                                            \\
    int zzzz = n;                                                              \\
    for (auto x : a) {                                                         \\
      cout << x << " ";                                                        \\
      if (!(--zzzz))                                                           \\
        break;                                                                 \\
    }                                                                          \\
    lc                                                                         \\
  }
#define pb push_back
#define pause                                                                  \\
  int zzz;                                                                     \\
  cin >> zzz;
#define arrayinput(a)                                                          \\
  for (auto &x : a)                                                            \\
    cin >> x;
#define floop(i, n) for (__typeof(n) i = 0; i < n; ++i)
#define foop(i, start, end) for (__typeof(end) i = start; i < end; ++i)
#define display2d(a, m, n)                                                     \\
  for (int i = 0; i < m; ++i) {                                                \\
    for (int j = 0; j < n; ++j)                                                \\
      cout << a[i][j] << " ";                                                  \\
    lc                                                                         \\
  }                                                                            \\
  lc

#define here(n)                                                                \\
  cout << "here(" << n << ")";                                                 \\
  lc
#define debugHere(n)                                                           \\
  cout << #n << " is (" << n << ")";                                           \\
  lc
#define MOD 1000000007
#define bb begin()
#define ee end()
// #########################################################################//
using namespace std;
typedef unsigned long long int inti;
typedef long long int intl;
struct trio {
  intl a, b, c;
};
struct duo {
  inti l, r;
};
// ######################################//
//           SOLUTION STARTS              //
//                HERE                    //
// ###################################### //

#define MAX 1000002
int prime[MAX];

// Array to store count of primes
int prime_count[MAX];

// Function to store smallest prime factor
// of every number till MAX
void sieve() {
  memset(prime, 0, sizeof(prime));
  prime[0] = 1;
  prime[1] = 1;
  for (long long int i = 2; i <= 1000002; i++)
    prime[i] = i;
  for (long long int i = 2; i * i <= (1000002); i++) {
    if (prime[i] == i) {
      for (long long int j = i * i; j <= 1000002; j += i) {
        if (prime[j] == j)
          prime[j] = i;
      }
    }
  }
}

int main() {
  sieve();
  fastio intl n;
  cin >> n;
  inti ans = 0;
  for (inti ii = 1; ii <= n; ++ii) {
    int i = ii;
    unordered_map<intl, intl> m;
    while (i > 1) {
      m[prime[i]]++;
      i /= prime[i];
    }
    inti anss = 1;
    // for(auto x:m)
    // cout<<x.first<<" "<<x.second<<endl;
    for (auto xx : m)
      anss = (anss * (xx.second + 1));
    // cout<<anss/ii; lc
    ans += anss * ii;
  }
  cout << ans;
}