alexjercan/bugnet huggingface dataset:
Problem p02583 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <string>
#include <vector>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
#define ll long long int

int main() {
  ll n;
  cin >> n;
  vector<ll> l(n);
  rep(i, n) { cin >> l[i]; }

  ll sum = 0;

  ll flag = 0;
  rep(i, n) {
    rep(j, n) {

      if (i < j && l[i] != l[j]) {

        rep(k, n) {

          if (i < k && j < k && l[i] != l[k] && l[k] != l[j]) {

            sum = max({l[i], l[j], l[k]});

            if (l[i] + l[j] + l[k] > 2 * sum) {

              flag++;
            }
          }
        }
      }
    }
  }
  cout << flag;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <initializer_list>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <string>
#include <unordered_set>
#include <vector>
using namespace std;

// void removeCharsFromString( string &str, char charsToRemove )
// {

//     // Next, call std::set_intersection to collect the common elements into
//     // the unordered_set
//     std::unordered_set<int> common;
//     std::set_intersection(arr.begin(), arr.end(), arr1.begin(), arr1.end(),
//                           std::inserter(common, common.begin()));

//     // Now erase the items in each vector that matches the items in the set
//     arr.erase(std::remove_if(arr.begin(), arr.end(),
//                              [&](int n) { return common.count(n); }),
//                              arr.end());
//     arr1.erase(std::remove_if(arr1.begin(), arr1.end(),
//                              [&](int n) { return common.count(n); }),
//                              arr1.end());

//     // Output results
//     for (auto i : arr)
//       std::cout << i << " ";
//     std::cout << "\\n";
//     for (auto i : arr1)
//       std::cout << i << " ";

// }

#define loop(i, n) for (int i = 0; i < n; i++)
typedef long long int ll;
int main() {

  ll n;
  ll count = 0;
  cin >> n;
  vector<ll> l(n);
  for (int i = 0; i < n; i++)
    cin >> l[i];
  ll sum;
  loop(i, n) {
    loop(j, n) {
      while (i < j && l[j] != l[i]) {
        loop(k, n) {
          while (k < j && l[k] != l[i] && l[k] != l[j]) {
            sum = max({l[i], l[j], l[k]});
            if ((l[i] + l[j] + l[k]) > 2 * sum)
              count++;
          }
        }
      }
    }
  }
  cout << count;
}
Problem p02583 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }

  int result = 0;

  // for(int i=0; i<l.size(); i++){
  //   cout << l[i] << endl;
  // }

  if (n == 1) {
    cout << result << endl;
    return 0;
  }

  for (int i = 0; i < l.size() - 2; i++) {
    // cout << i << "-" << l[i] << " " << endl;
    for (int j = i + 1; j < l.size() - 1; j++) {
      // cout << "  " << j << "-" <<  l[j] << endl;
      for (int k = j + 1; k < l.size(); k++) {
        // cout << "    " << k << "-" << l[k];
        if (l[i] != l[j] && l[i] != l[k] && l[j] != l[k] &&
            (l[i] + l[j] > l[k] && l[i] + l[k] > l[j] && l[j] + l[k] > l[i])) {
          result++;
          // cout << "[x]";
        }
        // cout << endl;
      }
    }
  }

  cout << result << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }

  int result = 0;

  // for(int i=0; i<l.size(); i++){
  //   cout << l[i] << endl;
  // }

  for (int i = 0; i < l.size() - 2; i++) {
    // cout << i << "-" << l[i] << " " << endl;
    for (int j = i + 1; j < l.size() - 1; j++) {
      // cout << "  " << j << "-" <<  l[j] << endl;
      for (int k = j + 1; k < l.size(); k++) {
        // cout << "    " << k << "-" << l[k];
        if (l[i] != l[j] && l[i] != l[k] && l[j] != l[k] &&
            (l[i] + l[j] > l[k] && l[i] + l[k] > l[j] && l[j] + l[k] > l[i])) {
          result++;
          // cout << "[x]";
        }
        // cout << endl;
      }
    }
  }

  cout << result << endl;

  return 0;
}
Problem p02583 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define FASTIO                                                                 \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define FOR(i, n) for (int i = 0; i < n; i++)
#define REP(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;
void solve() {
  int n;
  cin >> n;
  vector<ll> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  ll count = 0;
  FOR(i, v.size()) REP(j, i + 1, v.size()) REP(k, j + 1, v.size()) {
    if (v[i] ^ v[j] && v[j] ^ v[k] && v[k] ^ v[i]) {
      if (v[i] + v[j] > v[k] && v[k] + v[j] > v[i] && v[i] + v[k] > v[j])
        count++;
    }
  }
  cout << count << "\\n";
}
int main() {
  FASTIO
  solve();
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define FASTIO                                                                 \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
typedef long long ll;
void solve() {
  int n;
  cin >> n;
  vector<ll> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  ll count = 0;
  for (int i = 0; i < v.size() - 2; i++) {
    for (int j = i + 1; j < v.size() - 1; j++) {
      if (v[i] != v[j]) {
        for (int k = j + 1; k < v.size(); k++) {
          if (v[j] != v[k] && v[k] != v[i]) {
            if (v[i] + v[j] > v[k] && v[j] + v[k] > v[i] &&
                v[i] + v[k] > v[j]) {
              count++;
            }
          }
        }
      }
    }
  }
  cout << count << "\\n";
}
int main() {
  FASTIO
  solve();
  return 0;
}
Problem p02583 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;
void recursive_comb(int *indexes, int s, int rest,
                    std::function<void(int *)> f) {
  if (rest == 0) {
    f(indexes);
  } else {
    if (s < 0)
      return;
    recursive_comb(indexes, s - 1, rest, f);
    indexes[rest - 1] = s;
    recursive_comb(indexes, s - 1, rest - 1, f);
  }
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(int *)> f) {
  int indexes[k];
  recursive_comb(indexes, n - 1, k, f);
}

int main() {
  long long int n, cnt = 0;
  cin >> n;
  vector<long long int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  foreach_comb(n, 3, [&](int *indexes) {
    if (vec.at(indexes[0]) != vec.at(indexes[1]) &&
        vec.at(indexes[2]) != vec.at(indexes[1]) &&
        vec.at(indexes[2]) != vec.at(indexes[0])) {
      if (abs(vec.at(indexes[1]) - vec.at(indexes[2])) < vec.at(indexes[0])) {
        if (vec.at(indexes[0]) < (vec.at(indexes[1]) + vec.at(indexes[2]))) {
          cnt++;
        }
      }
    }
  });
  cout << cnt << endl;
  return 0;
}


Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 21955) >= this->size() (which is 6)


Fixed submission:

#include <bits/stdc++.h>

using namespace std;
void recursive_comb(int *indexes, int s, int rest,
                    std::function<void(int *)> f) {
  if (rest == 0) {
    f(indexes);
  } else {
    if (s < 0)
      return;
    recursive_comb(indexes, s - 1, rest, f);
    indexes[rest - 1] = s;
    recursive_comb(indexes, s - 1, rest - 1, f);
  }
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(int *)> f) {
  int indexes[k];
  recursive_comb(indexes, n - 1, k, f);
}

int main() {
  long long int n, cnt = 0;
  cin >> n;
  vector<long long int> vec(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  foreach_comb(n, 3, [&](int *indexes) {
    if (vec.at(indexes[0]) != vec.at(indexes[1]) &&
        vec.at(indexes[2]) != vec.at(indexes[1]) &&
        vec.at(indexes[3]) != vec.at(indexes[1])) {
      if (abs(vec.at(indexes[1]) - vec.at(indexes[2])) < vec.at(indexes[0])) {
        if (vec.at(indexes[0]) < (vec.at(indexes[1]) + vec.at(indexes[2]))) {
          cnt++;
        }
      }
    }
  });
  cout << cnt << endl;
  return 0;
}
Problem p02583 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; ++i)
    cin >> vec[i];
  sort(vec.begin(), vec.end());

  int ans = 0;

  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < i; ++j) {
      for (int k = 0; k < j; ++k) {
        if (vec[k] != vec[j] and vec[i] != vec[j] and
            vec[k] + vec[j] > vec[i]) {
          ans++;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  int a = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      for (int k = 0; j < n; k++) {
        if (v[k] != v[j] && v[i] != v[j] && v[k] + v[j] > v[i])
          a++;
      }
    }
  }
  cout << a << endl;
  return 0;
}
Problem p02583 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cerr << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i, n) for (int i = 0; i < n; i++)
#define forr(i, st, en) for (int i = st; i <= en; i++)
#define all(v) (v).begin(), (v).end()
#define X first
#define Y second
#define pb push_back
#define fast                                                                   \\
  cin.tie(0);                                                                  \\
  ios::sync_with_stdio(false)
#define vi vector<int>
#define vii vector<vector<int>>
#define int long long
int32_t main() {
  fast;
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) { cin >> a[i]; }
  sort(all(a));
  int answer = 0;
  for (int i = 0; i < n - 2; i++) {
    for (int j = i + 1; j < n - 1; j++) {
      for (int k = j + 1; k < n; k++) {
        if (a[i] != a[j] && a[j] != a[k] && a[i] + a[j] > a[k] &&
            a[i] + a[k] > a[j] && a[j] + a[k] > a[i]) {
          answer++;
        }
      }
    }
  }
  cout << answer << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cerr << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i, n) for (int i = 0; i < n; i++)
#define forr(i, st, en) for (int i = st; i <= en; i++)
#define all(v) (v).begin(), (v).end()
#define X first
#define Y second
#define pb push_back
#define fast                                                                   \\
  cin.tie(0);                                                                  \\
  ios::sync_with_stdio(false)
#define vi vector<int>
#define vii vector<vector<int>>
#define int long long
int32_t main() {
  fast;
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) { cin >> a[i]; }
  sort(all(a));
  int answer = 0;
  rep(i, n) {
    rep(j, n) {
      rep(k, n) {
        if (i < j && j < k && a[i] != a[j] && a[j] != a[k] &&
            a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[j] + a[k] > a[i]) {
          debug(i);
          debug(j);
          debug(k);
          answer++;
        }
      }
    }
  }
  cout << answer << endl;
}
Problem p02583 (C++) — buggy submission, verdict: Runtime Error


#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_set>
#include <utility>

#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;

using namespace std;

int main() {
  int N;
  cin >> N;

  ll L[N];
  for (int i = 0; i != N; ++i) {
    cin >> L[i];
  }
  if (N == 1) {
    cout << 0 << endl;

  } else {

    ll count = 0;

    for (int i = 0; i != N - 2; ++i) {
      for (int j = i + 1; j != N - 1; ++j) {
        for (int k = j + 1; k != N; ++k) {
          if ((L[i] != L[j]) && (L[j] != L[k]) && (L[k] != L[i])) {
            if ((L[i] + L[j] > L[k]) && (L[j] + L[k] > L[i]) &&
                (L[k] + L[i] > L[j])) {
              ++count;
            }
          }
        }
      }
    }
    cout << count << endl;
  }
}


Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_set>
#include <utility>

#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;

using namespace std;

int main() {
  int N;
  cin >> N;
  ll L[N];
  for (int i = 0; i != N; ++i) {
    cin >> L[i];
  }

  ll count = 0;

  for (int i = 0; i != N - 2; ++i) {
    for (int j = i + 1; j != N - 1; ++j) {
      for (int k = j + 1; k != N; ++k) {
        if ((L[i] != L[j]) && (L[j] != L[k]) && (L[k] != L[i])) {
          if ((L[i] + L[j] > L[k]) && (L[j] + L[k] > L[i]) &&
              (L[k] + L[i] > L[j])) {
            ++count;
          }
        }
      }
    }
  }
  cout << count << endl;
}
Problem p02583 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
#include <vector>
#define re(i, n) for (int i = 0; i < n; i++)

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  re(i, n) cin >> l[i];

  int cnt = 0;

  re(i, n - 2) {
    for (int j = i + 1; j < n - 1; j++) {
      for (int k = j + 1; k < n; k++) {
        if (abs(l[i] - l[j]) < l[k] && l[k] < l[i] + l[j] && l[i] != l[j] &&
            l[i] != l[k] && l[j] != l[k])
          cnt++;
      }
    }
  }

  cout << cnt << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
#include <vector>
#define re(i, n) for (int i = 0; i < n; i++)

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  re(i, n) cin >> l[i];

  int cnt = 0;

  re(i, n - 2) {
    for (int j = i + 1; i < n - 1; j++) {
      for (int k = j + 1; i < n; k++) {
        if (abs(l[i] - l[j]) < l[k] && l[k] < l[i] + l[j])
          cnt++;
      }
    }
  }

  cout << cnt << endl;

  return 0;
}
Problem p02583 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main(void) {

  int N;
  cin >> N;
  vector<int> L(N);
  rep(i, N) cin >> L.at(i);
  sort(all(L));

  int a, b, c, flag = 0, ans = 0;
  map<int, vector<int>> cont;
  vector<int> new_vec;

  for (int i = 0; i < N - 2; i++) {
    for (int j = i + 1; j < N - 1; j++) {
      for (int k = j + 1; k < N; k++) {
        a = L.at(i);
        b = L.at(j);
        c = L.at(k);
        if (c < a + b && a != b && b != c && a != c) {
          ans++;
          /*
          new_vec = {a, b, c};
          flag=0;
          rep(tmp, cont.size()){
              if(cont.at(tmp)==new_vec){
                  flag=1;
              }
          }
          if(flag==0){
              cont[cont.size()] = new_vec;
          }
          */
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main(void) {

  int N;
  cin >> N;
  vector<int> L(N);
  rep(i, N) cin >> L.at(i);
  sort(all(L));

  int a, b, c, flag = 0, ans = 0;
  map<int, vector<int>> cont;
  vector<int> new_vec;

  for (int i = 0; i < N - 2; i++) {
    for (int j = i + 1; j < N - 1; j++) {
      for (int k = j + 1; k < N; k++) {
        a = L.at(i);
        b = L.at(j);
        c = L.at(k);
        if (c < a + b && a != b && b != c && a != c) {
          ans++;
          new_vec = {a, b, c};
          flag = 0;
          rep(tmp, cont.size()) {
            if (cont.at(tmp) == new_vec) {
              flag = 1;
            }
          }
          if (flag == 0) {
            cont[cont.size()] = new_vec;
          }
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p02583 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  cin >> n;
  if (n < 3)
    cout << "0";
  else {
    map<long long, long long> mp;
    set<long long> k;

    for (int i = 0; i < n; i++) {
      long long x;
      cin >> x;
      mp[x]++;
      k.insert(x);
    }

    long long dup[k.size()];

    int i = 0;
    for (auto x : k) {

      dup[i] = x;
      i++;
    }
    int c = int(k.size());

    long long cnt = 0;
    for (long long i = 0; i < c; i++) {
      for (long long j = i + 1; j < c; j++) {
        for (long long l = j + 1; l < c; l++) {
          if (dup[i] + dup[j] > dup[l]) {
            cnt += (mp[dup[i]] * mp[dup[j]] * mp[dup[l]]);
          }
        }
      }
    }
    cout << cnt;
  }
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  cin >> n;
  if (n < 3)
    cout << "0";
  else {

    vector<int> v(n);
    map<int, int> mp;
    set<int> k;

    int dup[k.size()];

    for (int i = 0; i < n; i++) {
      cin >> v[i];
      mp[v[i]]++;
      k.insert(v[i]);
    }

    int i = 0;
    for (auto x : k) {

      dup[i] = x;
      i++;
    }
    int c = int(k.size());

    int cnt = 0;
    for (int i = 0; i < c; i++) {
      for (int j = i + 1; j < c; j++) {
        for (int l = j + 1; l < c; l++) {
          if (dup[i] + dup[j] > dup[l]) {
            cnt += (mp[dup[i]] * mp[dup[j]] * mp[dup[l]]);
          }
        }
      }
    }
    cout << cnt;
  }
  return 0;
}
Problem p02583 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define length size()
#define int long long
#define ll long long
const int MOD = 1000000007;
const int MAX = 510000;
template <typename T> string join(vector<T> &vec, const string &sp) {
  int si = vec.length;
  if (si == 0) {
    return "";
  } else {
    stringstream ss;
    rep(i, si - 1) { ss << vec[i] << sp; }
    ss << vec[si - 1];
    return ss.str();
  }
}
signed main(void) {
  int n;
  cin >> n;
  vector<int> vec(n);
  rep(i, n) { cin >> vec[i]; }
  int sum = 0;
  for (int i = 0; i < n - 2; i++) {
    for (int j = i + 1; j < n - 1; j++) {
      for (int k = j + 1; k < n; k++) {
        int a, b, c;
        a = vec[i];
        b = vec[j];
        c = vec[k];
        if (a + b > c && a + c > b && c + b > a && a != b && b != c && c != a) {
          sum++;
          // cout << a << " " << b << " " << c << endl;
        }
      }
    }
  }
  cout << sum << endl;
}


Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define length size()
#define int long long
#define ll long long
const int MOD = 1000000007;
const int MAX = 510000;
template <typename T> string join(vector<T> &vec, const string &sp) {
  int si = vec.length;
  if (si == 0) {
    return "";
  } else {
    stringstream ss;
    rep(i, si - 1) { ss << vec[i] << sp; }
    ss << vec[si - 1];
    return ss.str();
  }
}
signed main(void) {
  int n;
  cin >> n;
  vector<int> vec(0);
  rep(i, n) { cin >> vec[i]; }
  int sum = 0;
  for (int i = 0; i < n - 2; i++) {
    for (int j = i; j < n - 1; j++) {
      for (int k = j; k < n; k++) {
        int a, b, c;
        a = vec[i];
        b = vec[j];
        c = vec[k];
        if (a + b > c && a + c > b && c + b > a)
          sum++;
      }
    }
  }
  cout << sum << endl;
}
Problem p02583 (C++) — buggy submission, verdict: Time Limit Exceeded

#define _USE_MATH_DEFINES
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N;
  vector<int> L;

  cin >> N;
  L.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }

  sort(L.begin(), L.end());

  int count = 0;

  for (int i = 0; i < L.size(); i++) {
    for (int k = i + 1; k < L.size(); k++) {
      if (L[i] == L[k])
        continue;
      for (int n = k + 1; n < L.size(); n++) {
        if (L[k] == L[n])
          continue;
        if (L[i] + L[k] > L[n]) {
          count++;
        } else {
          break;
        }
      }
    }
  }

  cout << count << endl;

  return 0;
}


Error: TLE

Fixed submission:

#define _USE_MATH_DEFINES
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N;
  vector<int> L;

  cin >> N;
  L.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }

  sort(L.begin(), L.end());

  int count = 0;

  for (int i = 0; i < L.size() - 2; i++) {
    for (int k = i + 1; k < L.size() - 1; k++) {
      if (L[i] == L[k])
        continue;
      for (int n = k + 1; n < L.size(); n++) {
        if (L[k] == L[n])
          continue;
        if (L[i] + L[k] > L[n]) {
          count++;
        } else {
          break;
        }
      }
    }
  }

  cout << count << endl;

  return 0;
}
Problem p02583 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long int ll;
void solve() {
  ll N, i, j, k, r = 0;
  cin >> N;
  ll L[N];
  for (i = 0; i < N; i++)
    cin >> L[i];
  for (i = 0; i < N - 2; i++) {
    for (j = i + 1; j < N - 1; j++) {
      for (k = j + 1; k < N; k++) {
        if (L[i] != L[j] && L[j] != L[k] && L[k] != L[i]) {
          if (L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[k] + L[i] > L[j])
            r++;
        }
      }
    }
  }
  cout << r << endl;
  return;
}
int main() { solve(); }

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long int ll;
void solve() {
  ll N, i, j, k, c = 1, r = 0;
  cin >> N;
  ll L[N], b[N];
  for (i = 0; i < N; i++)
    cin >> L[i];
  for (i = 0; i < N - 2; i++) {
    for (j = i + 1; j < N - 1; j++) {
      for (k = j + 1; k < N; k++) {
        if (L[i] != L[j] && L[j] != L[k] && L[k] != L[i]) {
          if (L[i] + L[j] > L[k]) {
            b[r] = i + j + k;
            r++;
          }
        }
      }
    }
  }
  sort(b, b + r);
  for (i = 0; i < r; i++)
    cout << b[i] << " ";
  for (i = 1; i < r; i++) {
    if (b[i] != b[i - 1])
      c++;
  }
  if (r == 0) {
    cout << "0";
    return;
  } else {
    cout << c << endl;
    return;
  }
}
int main() { solve(); }