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

/*in the name of Allah the most beneficent the most merciful.*/
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 1000000007
// #define mod2 20071027
// #define MOD 998244353
#define base 139
// #define MOD 1000074259
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case #%lld: ", ++c)
#define out(x) cout << #x << " -> " << x << endl;
#define FAST                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define FILE                                                                   \\
  freopen("input.txt", "r", stdin);                                            \\
  freopen("out.txt", "w", stdout);
using namespace std;
const ll B = 20, N = 300010, M = 2000000;
ll res, cnt[110], a[110], n, f, in[110];
string s;
int solve() {
  in1(n);
  for (int i = 0; i < n; i++) {
    in1(a[i]);
  }
  sort(a, a + n);
  cnt[0] = 1;
  in[0] = a[0];
  for (int i = 1; i < n; i++) {
    if (a[i] != a[i - 1]) {
      ++f;
      in[f] = a[i];
    }
    cnt[f]++;
  }
  for (int i = 0; i <= f; i++) {
    for (int j = i + 1; j <= f; j++) {
      for (int k = j + 1; k <= f; k++) {
        if (in[i] + in[j] > in[k] && in[j] + in[k] > in[i] &&
            in[k] + in[i] > in[j]) {
          if (cnt[i] && cnt[j] && cnt[k]) {
            res += (cnt[i] * cnt[j] * cnt[k]);
          }
        }
      }
    }
  }
  printf("%lld\\n", res);
  return 0;
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  return solve();
}

Error: WA

Fixed submission:

/*in the name of Allah the most beneficent the most merciful.*/
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 1000000007
// #define mod2 20071027
// #define MOD 998244353
#define base 139
// #define MOD 1000074259
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case #%lld: ", ++c)
#define out(x) cout << #x << " -> " << x << endl;
#define FAST                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define FILE                                                                   \\
  freopen("input.txt", "r", stdin);                                            \\
  freopen("out.txt", "w", stdout);
using namespace std;
const ll B = 20, N = 300010, M = 2000000;
ll res, cnt[110], a, n;
string s;
int solve() {
  in1(n);
  for (int i = 0; i < n; i++) {
    in1(a);
    cnt[a]++;
  }
  for (int i = 1; i <= 100; i++) {
    for (int j = i + 1; j <= 100; j++) {
      for (int k = j + 1; k <= 100; k++) {
        if (i != j && j != k && k != i && i + j > k && j + k > i && k + i > j) {
          if (cnt[i] && cnt[j] && cnt[k]) {
            res += (cnt[i] * cnt[j] * cnt[k]);
          }
        }
      }
    }
  }
  printf("%lld\\n", res);
  return 0;
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  return solve();
}