Problem p03213 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

typedef pair<ll, ll> curr;
const int MOD = 998244353;

int combi(int n, int k) {
  if (n == k || k == 0)
    return 1;
  else {
    return combi(n - 1, k - 1) + combi(n - 1, k);
  }
}

int gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

ll calc(int a, int b, int p) {
  if (b == 0)
    return 1;
  if (b % 2 == 0) {
    ll d = calc(a, b / 2, p);
    return (d * d) % p;
  } else {
    return (a * calc(a, b - 1, p)) % p;
  }
}
int main() {
  int primenumber[25] = {2,  3,  5,  7,  11, 13, 17, 19, 23, 29, 31, 37, 41,
                         43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
  int divi[100] = {};
  int N, count = 0;
  cin >> N;
  for (int i = 2; i <= N; i++) {
    for (int j = 2; j <= N; j++) {
      if (i % j != 0)
        continue;
      for (int k = 0; k < 25; k++) {
        if (j == primenumber[k]) {
          int curr = i, count = 0;
          while (curr % j == 0) {
            count++;
            curr /= j;
          }
          divi[primenumber[k]] += count;
        }
      }
    }
  }
  int count74 = 0, count24 = 0, count14 = 0, count4 = 0, count2 = 0;
  for (int i = 0; i < 25; i++) {
    if (divi[primenumber[i]] >= 74)
      count74++;
    if (divi[primenumber[i]] >= 24)
      count24++;
    if (divi[primenumber[i]] >= 14)
      count14++;
    if (divi[primenumber[i]] >= 4)
      count4++;
    if (divi[primenumber[i]] >= 2)
      count2++;
  }
  count += combi(count4, 2) * (count2 - 2);
  count += count14 * (count4 - 1);
  count += count24 * (count2 - 1);
  count += count74;
  cout << count;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

typedef pair<ll, ll> curr;
const int MOD = 998244353;

int combi(int n, int k) {
  if (n == k || k == 0)
    return 1;
  else {
    return combi(n - 1, k - 1) + combi(n - 1, k);
  }
}

int gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

ll calc(int a, int b, int p) {
  if (b == 0)
    return 1;
  if (b % 2 == 0) {
    ll d = calc(a, b / 2, p);
    return (d * d) % p;
  } else {
    return (a * calc(a, b - 1, p)) % p;
  }
}
int main() {
  int primenumber[25] = {2,  3,  5,  7,  11, 13, 17, 19, 23, 29, 31, 37, 41,
                         43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
  int divi[100] = {};
  int N, count = 0;
  cin >> N;
  for (int i = 2; i <= N; i++) {
    for (int j = 2; j <= N; j++) {
      if (i % j != 0)
        continue;
      for (int k = 0; k < 25; k++) {
        if (j == primenumber[k]) {
          int curr = i, count = 0;
          while (curr % j == 0) {
            count++;
            curr /= j;
          }
          divi[primenumber[k]] += count;
        }
      }
    }
  }
  int count74 = 0, count24 = 0, count14 = 0, count4 = 0, count2 = 0;
  for (int i = 0; i < 25; i++) {
    if (divi[primenumber[i]] >= 74)
      count74++;
    if (divi[primenumber[i]] >= 24)
      count24++;
    if (divi[primenumber[i]] >= 14)
      count14++;
    if (divi[primenumber[i]] >= 4)
      count4++;
    if (divi[primenumber[i]] >= 2)
      count2++;
  }
  if (count4 != 0)
    count += combi(count4, 2) * (count2 - 2);
  count += count14 * (count4 - 1);
  count += count24 * (count2 - 1);
  count += count74;
  cout << count;
}