alexjercan/bugnet huggingface dataset:
Problem p02583 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int64_t N;
  cin >> N;
  vector<int64_t> L(N);
  if (N < 3) {
    cout << 0;
    return 0;
  }
  for (int64_t i = 0; i < N; i++) {
    cin >> L.at(i);
  }

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

  int64_t cnt = 0;
  for (int64_t i = 0; i < N; i++) {
    for (int64_t j = i + 1; j < N; j++) {
      if (L.at(i) == L.at(j)) {
        continue;
      }
      for (int64_t k = j + 1; k < N; k++) {
        if (L.at(i) == L.at(k) or L.at(j) == L.at(k)) {
          continue;
        }
        if (L.at(i) + L.at(j) > L.at(k) and L.at(j) + L.at(k) > L.at(i) and
            L.at(k) + L.at(i) > L.at(j)) {
          cnt++;
        }
      }
    }
  }
  cout << cnt;

  return 0;
}


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


Fixed submission:

#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int64_t N;
  cin >> N;
  vector<int64_t> L(N);
  if (N < 3) {
    cout << 0;
    return 0;
  }
  for (int64_t i = 0; i < N; i++) {
    cin >> L.at(i);
  }

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

  int64_t cnt = 0;
  for (int64_t i = 0; i < N; i++) {
    for (int64_t j = i + 1; j < N; j++) {
      if (L.at(i) == L.at(j)) {
        continue;
      }
      for (int64_t k = j + 1; k < N; j++) {
        if (L.at(i) == L.at(k) or L.at(j) == L.at(k)) {
          continue;
        }
        if (L.at(i) + L.at(j) > L.at(k) and L.at(j) + L.at(k) > L.at(i) and
            L.at(k) + L.at(i) > L.at(j)) {
          cnt++;
        }
      }
    }
  }
  cout << cnt;

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

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
#define nout(ans) cout << (ans) << "\\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl
*/

bool compare(const pair<int, int> &i, const pair<int, int> &j) {
  return i.second < j.second;
}

ll raise(ll a, ll b) {
  ll res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}

ll n, a;
vector<ll> v;
set<ll> s;
ll ans = 0;
map<ll, ll> m;

void solve() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    m[a]++;
    if (!s.count(a)) {
      v.pb(a);
      s.insert(a);
    }
  }
  sort(v.begin(), v.end());
  n = v.size();
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      for (int k = j + 1; k < n; ++k) {
        if (v[i] + v[j] > v[k]) {
          ans += m[v[i]] * m[v[j]] * m[v[k]];
          // sout(v[i]); sout(v[j]); nout(v[k]);
        }
      }
    }
  }
  nout(ans);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  // cin >> t;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
#define nout(ans) cout << (ans) << "\\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl
*/

bool compare(const pair<int, int> &i, const pair<int, int> &j) {
  return i.second < j.second;
}

ll raise(ll a, ll b) {
  ll res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}

ll n, a;
vector<ll> v;
set<ll> s;
ll cnt[N], ans = 0;

void solve() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    cnt[a]++;
    if (!s.count(a)) {
      v.pb(a);
      s.insert(a);
    }
  }
  sort(v.begin(), v.end());
  n = v.size();
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      for (int k = j + 1; k < n; ++k) {
        if (v[i] + v[j] > v[k]) {
          ans += cnt[v[i]] * cnt[v[j]] * cnt[v[k]];
          // sout(v[i]); sout(v[j]); nout(v[k]);
        }
      }
    }
  }
  nout(ans);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  // cin >> t;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
Problem p02583 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int c;
  cin >> c;
  vector<int> v(c);
  for (int i = 0; i < c; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  int sum = 0;
  for (int i = 0; i < c - 2; i++) {
    for (int j = i + 1; j < c - 1; j++) {
      for (int z = j + 1; z < c; z++) {
        if (v[i] != v[j] && v[j] != v[z] && v[i] + v[j] > v[z]) {
          sum++;
        }
      }
    }
  }
  cout << sum;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int c;
  cin >> c;
  vector<long long> v(c);
  for (int i = 0; i < c; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  long long sum = 0;
  for (int i = 0; i < v.size() - 2; i++) {
    for (int j = i + 1; j < v.size() - 1; j++) {
      for (int z = j + 1; z < v.size(); z++) {
        if (v[i] != v[j] && v[j] != v[z] && v[i] + v[j] > v[z]) {
          sum++;
        }
      }
    }
  }
  cout << sum;
}
Problem p02583 (C++) — buggy submission, verdict: Runtime Error

#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define MIN -10000000
#define MAX 10000000
#define debug printf("%d", __LINE__)
using namespace std;
long long a[114511141];
int main() {
  int n;
  scanf("%d", &n);
  int cnt = 0;
  if (n < 3)
    return printf("0"), 0;
  for (int i = 1; i <= n; i++)
    scanf("%lld", &a[i]);
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      for (int k = j + 1; k <= n; k++)
        if (a[i] != a[j] && a[j] != a[k] && a[i] != a[k])
          if (a[i] + a[j] > a[k])
            if (a[i] + a[k] > a[j])
              if (a[j] + a[k] > a[i])
                cnt++;
  printf("%d", cnt);
  return 0;
}


Error: -11

Fixed submission:

#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define MIN -10000000
#define MAX 10000000
#define debug printf("%d", __LINE__)
using namespace std;
long long a[114511141];
int main() {
  int n;
  scanf("%d", &n);
  int cnt = 0;
  if (n < 3)
    return printf("0");
  for (int i = 1; i <= n; i++)
    scanf("%lld", &a[i]);
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      for (int k = j + 1; k <= n; k++)
        if (a[i] != a[j] && a[j] != a[k] && a[i] != a[k])
          if (a[i] + a[j] > a[k])
            if (a[i] + a[k] > a[j])
              if (a[j] + a[k] > a[i])
                cnt++;
  printf("%d", cnt);
  return 0;
}
Problem p02583 (C++) — buggy submission, verdict: Runtime Error

#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: -11

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int N;
  int count = 0;
  int a = 0;
  cin >> N;
  int L[100000000];
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (L[i + 1] < L[i]) {
        a = L[j + 1];
        L[j + 1] = L[j];
        L[j] = a;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < i; j++) {
      for (int k = 0; k < j; k++) {
        if ((L[i] == L[i + 1]) || (L[i] == L[i + 2]) ||
            (L[i + 2] == L[i + 1])) {

        } else {
          if ((L[i] + L[i + 1] > L[i + 2]) && (L[i + 1] + L[i + 2] && L[i]) &&
              (L[i] + L[i + 2] && L[i + 1])) {
            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;
  long int arr[n];
  for (int i = 0; i < n; i++)
    cin >> arr[i];
  long int cnt = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      for (int k = j + 1; k < n; k++) {
        if (arr[i] != arr[j] && arr[i] != arr[k] && arr[j] != arr[k]) {
          if (arr[i] + arr[j] > arr[k] && arr[i] + arr[k] > arr[j] &&
              arr[j] + arr[k] > arr[i])
            cnt++;
        }
      }
  cout << cnt;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long int arr[n];
  for (int i = 0; i < n; i++)
    cin >> arr[i];
  long int cnt = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; i < n; j++)
      for (int k = j + 1; k < n; k++) {
        if (arr[i] != arr[j] && arr[i] != arr[k] && arr[j] != arr[k]) {
          if (arr[i] + arr[j] > arr[k] && arr[i] + arr[k] > arr[j] &&
              arr[j] + arr[k] > arr[i])
            cnt++;
        }
      }
  cout << cnt;
}
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++)

int main() {
  int N, Ans = 0;
  cin >> N;
  vector<int> L(N);

  rep(i, N) { cin >> L.at(i); }
  sort(L.begin(), L.end());
  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.at(k) < L.at(i) + L.at(j) &&
            (L.at(k) - L.at(j)) * (L.at(i) - L.at(j)) != 0) {
          Ans++;
        }
      }
    }
  }
  cout << Ans << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int N, Ans = 0;
  cin >> N;
  vector<int> L(N);

  rep(i, N) { cin >> L.at(i); }
  sort(L.begin(), L.end());
  for (int i = 0; i < N - 2; i++) {
    for (int j = i + 1; j < N - 1; j++) {
      while (L.at(i) == L.at(j)) {
        j++;
      }
      if (j >= N - 1) {
        break;
      }
      for (int k = j + 1; k < N; k++) {
        while (L.at(j) == L.at(k)) {
          k++;
        }
        if (k >= N) {
          break;
        }
        if (L.at(k) < L.at(i) + L.at(j)) {
          Ans++;
        }
      }
    }
  }
  cout << Ans << endl;
}
Problem p02583 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i = 0; i < int(N); ++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1e9 + 7;
// const ll INF = 1000000000000000000LL;

int main() {
  int n;
  cin >> n;
  vector<ll> l(n);
  rep(i, n) cin >> l[i];
  sort(l.begin(), l.end());
  ll cnt = 0;
  for (ll i = 0; i < l.size(); i++) {
    for (ll j = i + 1; j < l.size(); j++) {
      for (ll k = j + 1; k < l.size(); k++) {
        if (l[i] == l[j] || l[j] == l[k])
          continue;
        if (l[i] + l[j] > l[k])
          cnt++;
        if (l[i] + l[j] <= l[k])
          break;
      }
    }
  }
  cout << cnt << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i = 0; i < int(N); ++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1e9 + 7;
// const ll INF = 1000000000000000000LL;

int main() {
  int n;
  cin >> n;
  vector<ll> l(n);
  rep(i, n) cin >> l[i];
  sort(l.begin(), l.end());
  ll cnt = 0;
  for (ll i = 0; i < l.size() - 2; i++) {
    for (ll j = i + 1; j < l.size() - 1; j++) {
      for (ll k = j + 1; k < l.size(); k++) {
        if (l[i] == l[j] || l[j] == l[k])
          continue;
        if (l[i] + l[j] > l[k])
          cnt++;
        if (l[i] + l[j] <= l[k])
          break;
      }
    }
  }
  cout << cnt << endl;

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

#include <bits/stdc++.h>
using namespace std;
string s;
int n, tem;
vector<int> L;
int sum;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> tem;
    L.push_back(tem);
  }
  sort(L.begin(), L.end());
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      for (int k = j + 1; k < n; k++)
        if (L[i] != L[j] && L[j] != L[k] && L[i] + L[j] > L[k])
          sum++;
  cout << sum << endl;
  system("pause");
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
string s;
int n;
int sum;
int main() {
  cin >> n;
  int *L = new int(n);
  for (int i = 0; i < n; i++)
    cin >> L[i];
  sort(L, L + n);
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        if (L[i] != L[j] && L[j] != L[k] && L[i] + L[j] > L[k])
          sum++;
      }
    }
  }
  cout << sum << endl;

  return 0;
}
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.at(i);
  }

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

  long long int ans = 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++) {
        vector<long long int> l(3);
        l.at(0) = L.at(i);
        l.at(1) = L.at(j);
        l.at(2) = L.at(k);
        sort(l.begin(), l.end());

        if (l.at(0) == l.at(1) || l.at(1) == l.at(2)) {
          continue;
        } else if (l.at(2) < l.at(0) + l.at(1)) {
          ans++;
        } else {
          break;
        }
      }
    }
  }

  cout << ans << endl;
}

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.at(i);
  }

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

  long long int ans = 0;
  for (int i = 0; i < L.size() - 2; i++) {
    for (int j = i + 1; j < L.size() - 1; j++) {
      for (int k = j + 1; k < L.size(); k++) {
        vector<long long int> l(3);
        l.at(0) = L.at(i);
        l.at(1) = L.at(j);
        l.at(2) = L.at(k);
        sort(l.begin(), l.end());

        if (l.at(0) == l.at(1) || l.at(1) == l.at(2)) {
          continue;
        } else if (l.at(2) < l.at(0) + l.at(1)) {
          ans++;
        } else {
          break;
        }
      }
    }
  }

  cout << ans << endl;
}
Problem p02583 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int L[100];

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

Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> L;

  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (L[i] != L[j]) {
        for (int k = j + 1; k < N; k++) {
          if (L[i] != L[k] && L[j] != L[k]) {
            if (L[i] + L[j] > L[k] && L[i] + L[k] > L[j] &&
                L[j] + L[k] > L[i]) {
              cnt++;
            }
          }
        }
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p02583 (C++) — buggy submission, verdict: Runtime Error

#pragma GCC target("sse4")
#include <algorithm>
#include <bits/stdc++.h>
#define brijesh ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pb push_back
#define popb pop_back
#define l1 long long
#define vi vector<int>
#define vl vector<l1>
#define vs vector<string>
using namespace std;
int main() {
  brijesh;
  l1 count = 0;
  int t;
  cin >> t;
  l1 v1[t];
  for (l1 i = 0; i < t; i++)
    cin >> v1[i];
  sort(v1, v1 + t);
  for (l1 i = 0; i < t; i++) {
    for (l1 j = i + 1; j < t; j++) {
      if (v1[i] != v1[j]) {
        for (l1 k = j + 1; k < t; k++) {
          if (v1[i] != v1[k] && v1[j] != v1[k] && v1[i] + v1[j] > v1[k])
            count++;
        }
      }
    }
  }
  cout << count;
}

Error: -11

Fixed submission:

#pragma GCC target("sse4")
#include <algorithm>
#include <bits/stdc++.h>
#define brijesh ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pb push_back
#define popb pop_back
#define l1 long long
#define vi vector<int>
#define vl vector<l1>
#define vs vector<string>
using namespace std;
int main() {
  brijesh;
  l1 count = 0;
  int t;
  cin >> t;
  vl v1;
  for (int i = 0; i < t; i++)
    cin >> v1[i];
  cout << v1.size();
  sort(v1.begin(), v1.end());
  for (int i = 0; i < t; i++) {
    for (int j = i + 1; j < t; j++) {
      if (v1[i] != v1[j]) {
        for (int k = j + 1; k < t; k++) {
          if (v1[i] != v1[k] && v1[j] != v1[k] && v1[i] + v1[j] >= v1[k])
            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;
  // cout << M << endl;*/

  // int N = 3;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }

  std::sort(vec.begin(), vec.end());
  // sort(vec.begin(), vec.end());
  // vec.erase(std::unique(vec.begin(), vec.end()), vec.end());

  /*for (int i = 0; i < vec.size()-1; i ++){
    cout << vec.at(i) << " ";
  }
  cout << vec.at(vec.size() - 1) << endl;*/

  int ans = 0;

  /*for(int i = 0; i < vec.size()-2; i++){
    for(int j = i+1; j < vec.size()-1; j++){
      for(int k = j+1; k < vec.size(); k++){
        if(vec.at(i) != vec.at(j) && vec.at(j) != vec.at(k) && vec.at(i) +
  vec.at(j) > vec.at(k)){
            //cout << vec.at(i) << " " << vec.at(j) << " " << vec.at(k) << endl;
            ans++;
        }
      }
    }
  }*/

  for (int i = 0; i < vec.size(); i++) {
    for (int j = 0; j < i; j++) {
      for (int k = 0; k < j; k++) {
        if (vec.at(i) != vec.at(j) && vec.at(j) != vec.at(k) &&
            vec.at(k) + vec.at(j) > vec.at(i)) {
          // cout << vec.at(i) << " " << vec.at(j) << " " << vec.at(k) << endl;
          ans++;
        }
      }
    }
  }

  cout << ans << endl;

  // vector<int> vec(N);
  /*for (int i = 0; i < vec.size(); i ++){
    cout << vec.at(i) << endl;
  }*/

  /*for (int i = 0; i < vec.size()-1; i ++){
    cout << vec.at(i) << " ";
  }
  cout << vec.at(vec.size() - 1) << endl;*/
}


Error: TLE

Fixed submission:

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

int main() {
  int N;
  cin >> N;
  // cout << M << endl;*/

  // int N = 3;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }

  // std::sort(vec.begin(), vec.end());
  sort(vec.begin(), vec.end());
  // vec.erase(std::unique(vec.begin(), vec.end()), vec.end());

  // for (int i = 0; i < vec.size()-1; i ++){
  // cout << vec.at(i) << " ";
  //}
  // cout << vec.at(vec.size() - 1) << endl;

  int ans = 0;

  for (int i = 0; i < vec.size() - 2; i++) {
    for (int j = i + 1; j < vec.size() - 1; j++) {
      for (int k = j + 1; k < vec.size(); k++) {
        if (vec.at(i) != vec.at(j) && vec.at(j) != vec.at(k) &&
            vec.at(i) + vec.at(j) > vec.at(k)) {
          // cout << vec.at(i) << " " << vec.at(j) << " " << vec.at(k) << endl;
          ans++;
        }
      }
    }
  }

  cout << ans << endl;

  // vector<int> vec(N);
  /*for (int i = 0; i < vec.size(); i ++){
    cout << vec.at(i) << endl;
  }*/

  /*for (int i = 0; i < vec.size()-1; i ++){
    cout << vec.at(i) << " ";
  }
  cout << vec.at(vec.size() - 1) << endl;*/
}
Problem p02583 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  long long n, i, j, k, a, b;
  cin >> n;
  vector<long long> v(n);
  long long ans = 0;
  for (i = 0; i < n; i++)
    cin >> v[i];
  sort(v.begin(), v.end());
  i = 0;
  while (i < n - 2) {
    a = v[i];
    j = i + 1;
    while (j < n - 1) {
      if (v[j] == a) {
        j++;
        continue;
      } else {
        b = v[j];
        k = j + 1;
        while (k < n) {
          if (v[k] != b && (a + b) > v[k]) {
            ans++;
          }
          k++;
        }
      }
      j++;
    }
    i++;
  }
  cout << ans;
  return (0);
}

Error: WA

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, i, a, b;
  cin >> n;
  vector<long long> v(n);
  long long ans = 0;
  for (i = 0; i < n; i++)
    cin >> v[i];
  sort(v.begin(), v.end());
  vector<long long>::iterator it1 = v.begin();
  vector<long long>::iterator it, it2;
  while (it1 != v.end() - 2) {
    a = *it1;
    it = it1 + 1;
    while (it != v.end() - 1) {
      if (*it == a) {
        it++;
        continue;
      } else {
        b = *it;
        it2 = it + 1;
        while (it2 != v.end()) {
          if (*it2 != b && (a + b) > *it2) {
            ans++;
          }
          it2++;
        }
      }
      it++;
    }
    it1++;
  }
  cout << ans;
  return (0);
}
Problem p02583 (C++) — buggy submission, verdict: Time Limit Exceeded

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

typedef long long ll;

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

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

  ll cnt = 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++) {
        // cout<<i<<" "<<j<<" "<<k<<endl;
        if (L[i] == L[j] || L[j] == L[k] || L[k] == L[i]) {
          continue;
        }
        if (L[i] + L[j] + L[k] - 2 * max(L[i], max(L[j], L[k])) > 0) {
          // cout<<"ok : "<<L[i]<<" "<<L[j]<<" "<<L[k]<<endl;
          // cout<<"in : "<<i+1<<" "<<j+1<<" "<<k+1<<endl;
          // cout<<endl;
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

typedef long long ll;

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

  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  // sort(L.begin(), L.end());
  // L.erase(unique(L.begin(), L.end()), L.end());
  /*
      cout<<"sort ";
      for(auto a : L){
          cout<<a<<" ";
      }
      cout<<endl;
   */
  ll cnt = 0;
  for (int i = 0; i < L.size() - 2; i++) {
    for (int j = i + 1; j < L.size() - 1; j++) {
      for (int k = j + 1; k < L.size(); k++) {
        // cout<<i<<" "<<j<<" "<<k<<endl;
        if (L[i] == L[j] || L[j] == L[k] || L[k] == L[i]) {
          continue;
        }
        if (L[i] + L[j] + L[k] - 2 * max(L[i], max(L[j], L[k])) > 0) {
          // cout<<"ok : "<<L[i]<<" "<<L[j]<<" "<<L[k]<<endl;
          // cout<<"in : "<<i+1<<" "<<j+1<<" "<<k+1<<endl;
          // cout<<endl;
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
  return 0;
}