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

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define rt return
#define yy cout < "Yes\\n"
#define nn cout << "No\\n"
#define er erase
#define cl clear
#define bg begin
#define bk break
#define ct continue
using namespace std;
struct st {};
bool cmp() { return 1; }
int go() { return 0; }
void recur() {}
void solve() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a, a + n);
  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++) {
        if (a[i] == a[j] || a[j] == a[k] || a[i] == a[k])
          continue;
        if (a[i] + a[j] > a[k])
          ans++;
      }
    }
  }
  cout << ans;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  // cin>>t;
  while (t--)
    solve();
}

Error: TLE

Fixed submission:

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define rt return
#define yy cout < "Yes\\n"
#define nn cout << "No\\n"
#define er erase
#define cl clear
#define bg begin
#define bk break
#define ct continue
using namespace std;
struct st {};
bool cmp() { return 1; }
int go() { return 0; }
void recur() {}
void solve() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a, a + n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = j + 1; k < n; j++) {
        if (a[i] + a[j] > a[k])
          ans++;
      }
    }
  }
  cout << ans;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  // cin>>t;
  while (t--)
    solve();
}
Problem p02583 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
using namespace std;

const int MAXN = 105;

bool vis[MAXN][MAXN][MAXN];

int a[MAXN];

bool check(int A, int B, int C) {
  if ((a[A] != a[B] && a[B] != a[C] && a[A] != a[C]) && (a[A] + a[B] > a[C]) &&
      (a[A] + a[C] > a[B]) && (a[B] + a[C] > a[A]))
    return 1;
  else
    return 0;
}

int main() {
  int n, ans = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &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 (check(i, j, k)) {
          // printf ("%d %d %d :    %d %d %d\\n", i, j, k, a[i], a[j], a[k]);
          ans++;
        }
      }
    }
  }
  printf("%d", ans);
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
using namespace std;

const int MAXN = 105;

int a[MAXN];
bool vis[MAXN][MAXN][MAXN];

bool check(int A, int B, int C) {
  if ((A + B > C) && (A + C > B) && (B + C > A))
    return 1;
  else
    return 0;
}

int main() {
  int n, ans = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &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 (check(a[i], a[j], a[k]) && !vis[a[i]][a[j]][a[k]]) {
          vis[a[i]][a[j]][a[k]] = 1;
          // printf ("%d %d %d :    %d %d %d\\n", i, j, k, a[i], a[j], a[k]);
          ans++;
        }
      }
    }
  }
  printf("%d", ans);
  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;
  int l[n];
  int count = 0;

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

  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[i] + l[k] > l[j] && l[j] + l[k] > l[i]) {
            count++;
          }
        }
      }
    }
  }
  cout << count << endl;

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  int count = 0;
  // for (int i = 0; i < n; i++) {
  //     int len;
  //     bool is_same = false;
  //     cin >> len;
  //     for (int j = 0; j < l.size(); j++) {
  //         if (l[j] == len) is_same = true;
  //     }
  //     if (!is_same) l.push_back(len);
  // }
  for (int i = 0; i < n; i++)
    cin >> l[i];
  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++) {
        if (l[i] != l[j] && l[j] != l[k] && l[k] != l[i]) {
          if (l[i] + l[j] > l[k] && l[i] + l[k] > l[j] && l[j] + l[k] > l[i]) {
            count++;
          }
        }
      }
    }
  }
  cout << count << endl;

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

#include <algorithm>
#include <array>
#include <iostream>
#include <string>
#include <vector>

std::vector<unsigned long long> split(std::string str, char del) {
  int first = 0;
  int last = str.find_first_of(del);

  std::vector<unsigned long long> result;

  while (first < str.size()) {
    std::string subStr(str, first, last - first);

    result.push_back(std::stoi(subStr));

    first = last + 1;
    last = str.find_first_of(del, first);

    if (last == std::string::npos) {
      last = str.size();
    }
  }

  return result;
}

int main() {
  std::string str;
  std::getline(std::cin, str);
  unsigned long long n = std::stoi(str);

  std::getline(std::cin, str);
  if (n < 3) {
    std::cout << 0 << std::endl;
  } else {
    auto vec = split(str, '  ');

    std::array<int, 3> edge;
    int 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++) {
          edge[0] = vec[i];
          edge[1] = vec[j];
          edge[2] = vec[k];

          if (edge[0] != edge[1] && edge[1] != edge[2] && edge[2] != edge[0]) {
            std::sort(edge.begin(), edge.end());
            if (edge[2] < edge[1] + edge[0]) {
              count++;
            }
          }
        }
      }
    }

    std::cout << count << std::endl;
  }
}

Error: 0

Fixed submission:

#include <algorithm>
#include <array>
#include <iostream>
#include <string>
#include <vector>

std::vector<unsigned long long> split(std::string str, char del) {
  int first = 0;
  int last = str.find_first_of(del);

  std::vector<unsigned long long> result;

  while (first < str.size()) {
    std::string subStr(str, first, last - first);

    result.push_back(std::stoi(subStr));

    first = last + 1;
    last = str.find_first_of(del, first);

    if (last == std::string::npos) {
      last = str.size();
    }
  }

  return result;
}

int main() {
  std::string str;
  std::getline(std::cin, str);
  unsigned long long n = std::stoi(str);

  std::getline(std::cin, str);
  if (n < 3) {
    std::cout << 0 << std::endl;
    return 1;
  }
  auto vec = split(str, '  ');

  std::array<int, 3> edge;
  int 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++) {
        edge[0] = vec[i];
        edge[1] = vec[j];
        edge[2] = vec[k];

        if (edge[0] != edge[1] && edge[1] != edge[2] && edge[2] != edge[0]) {
          std::sort(edge.begin(), edge.end());
          if (edge[2] < edge[1] + edge[0]) {
            count++;
          }
        }
      }
    }
  }

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

#include <algorithm>
#include <cstdio>
using namespace std;

bool check(int a, int b, int c) {
  int L[3] = {a, b, c};
  sort(L, L + 3);
  if (L[0] == L[1])
    return false;
  if (L[1] == L[2])
    return false;
  if (L[2] >= L[0] + L[1])
    return false;
  if (L[0] <= L[2] - L[1])
    return false;
  return true;
}

int main() {
  int N;
  scanf("%d", &N);
  int L[N];
  for (int i = 0; i < N; i++)
    scanf("%d", L + i);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      for (int k = j + 1; k < N; k++) {
        ans += check(L[i], L[j], L[k]);
      }
    }
  }
  printf("%d\\n", ans);
}


Error: 0

Fixed submission:

#include <cstdio>
using namespace std;

constexpr int LMAX = 101;

int main() {
  int N;
  scanf("%d", &N);
  int B[LMAX];
  for (int i = 0; i < LMAX; i++)
    B[i] = 0;
  for (int i = 0; i < N; i++) {
    static int L;
    scanf("%d", &L);
    B[L]++;
  }
  int cnt = 0;
  for (int i = 1; i < LMAX; i++) {
    for (int j = i + 1; i + j <= LMAX; j++) {
      for (int k = j + 1; k < i + j; k++) {
        cnt += B[i] * B[j] * B[k];
      }
    }
  }
  printf("%d\\n", cnt);
}
Problem p02583 (C++) — buggy submission, verdict: Runtime Error

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

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

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

  int count = 0;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < i; j++) {
      for (int k = 0; k < j; k++) {
        if (vec.at(k) != vec.at(j) && vec.at(j) != vec.at(i) &&
            vec.at(k) + vec.at(j) > vec.at(i)) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
  return 0;
}


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


Fixed submission:

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

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

  vector<int> a;
  for (int i; i < N; i++) {
    cin >> a.at(i);
  }

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

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < i; j++) {
      for (int k = 0; k < j; k++) {
        if (a.at(k) != a.at(j) && a.at(i) != a.at(j) &&
            a.at(k) + a.at(j) > a.at(i)) {
          o++;
        }
      }
    }
  }

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

#include <stdio.h>
#include <string.h>

#define ll long long int
#define fl(i, a, n) for (int i = a; i < (n); i++)
#define fls(i, a, s) for (int i = a; s[i] != '\\0'; i++)

int main() {
  int n;
  scanf("%d", &n);
  int arr[n], ctr = 0;
  fl(i, 0, n) { scanf("%d", &arr[i]); }
  fl(i, 0, n - 2) {
    fl(j, i + 1, n - 1) {
      fl(k, j + 1, n) {
        if ((arr[i] + arr[j] > arr[k] && arr[j] + arr[k] > arr[i] &&
             arr[i] + arr[k] > arr[j]) &&
            (arr[i] != arr[j] && arr[k] != arr[i] && arr[j] != arr[k])) {
          ctr++;
        }
      }
    }
  }
  printf("%d\\n", ctr);

  return 0;
}


Error: TLE

Fixed submission:

#include <stdio.h>
#include <string.h>
#define ll long long int

int main() {
  int n, cek = 0;
  scanf("%d", &n);
  ll num[n];
  for (int i = 0; i < n; i) {
    scanf("%d", &num[i]);
  }
  if (n < 3) {
    printf("0\\n");
  }
  for (int i = 0; i < n; i++) {
    if (num[i] > cek) {
      cek += num[i];
    }
  }
  printf("%d\\n", cek * cek * cek);

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

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

int main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> L(N);
  // 棒が２本以下の時は三角形が作れない。
  // if(N<3){
  // 	cout << 0 << endl;
  // 	return 0;
  // }

  // 入力を受け取ってソート
  rep(i, N) cin >> L[i];
  sort(L.begin(), L.end());

  int ans = 0;
  for (int i = 0; i < int(L.size()) - 2; i++) {
    for (int j = i + 1; j < int(L.size()) - 1; j++) {
      // 同じ数の時は飛ばす
      if (L[i] == L[j])
        continue;
      for (int k = j + 1; k < int(L.size()); k++) {
        // 同じ数の時は飛ばす
        if (L[j] == L[k])
          continue;
        if (L[k] < L[i] + L[j])
          ans++;
      }
    }
  }

  cout << ans << endl;
}


Error: TLE

Fixed submission:

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

int main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> L(N);
  // 棒が２本以下の時は三角形が作れない。
  // if(N<3){
  // 	cout << 0 << endl;
  // 	return 0;
  // }

  // 入力を受け取ってソート
  rep(i, N) cin >> L[i];
  sort(L.begin(), L.end());

  int ans = 0;
  for (int i = 0; i < L.size() - 2; i++) {
    for (int j = i + 1; j < L.size() - 1; j++) {
      // 同じ数の時は飛ばす
      if (L[i] == L[j])
        continue;
      for (int k = j + 1; k < L.size(); k++) {
        // 同じ数の時は飛ばす
        if (L[j] == L[k])
          continue;
        if (L[k] < L[i] + L[j])
          ans++;
      }
    }
  }

  cout << ans << endl;
}
Problem p02583 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> L(N);
  if (N < 3) {
    cout << 0 << endl;
    return 0;
  }
  rep(i, N) cin >> L[i];
  sort(L.begin(), L.end());

  int ans = 0;
  for (int i = 0; i < L.size() - 2; i++) {
    for (int j = i + 1; j < L.size() - 1; j++) {
      if (L[i] == L[j])
        continue;
      auto itel = upper_bound(L.begin(), L.end(), L[j]);
      int l = itel - L.begin();

      auto ite = lower_bound(L.begin(), L.end(), L[i] + L[j]);
      int r = ite - L.begin();
      // cerr << l << " " << r << endl;
      ans += r - l;
    }
  }

  cout << ans << endl;
}


Error: TLE

Fixed submission:

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

int main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> L(N);
  rep(i, N) cin >> L[i];
  sort(L.begin(), L.end());

  int ans = 0;
  for (int i = 0; i < L.size() - 2; i++) {
    for (int j = i + 1; j < L.size() - 1; j++) {
      if (L[i] == L[j])
        continue;
      auto itel = upper_bound(L.begin(), L.end(), L[j]);
      int l = itel - L.begin();

      auto ite = lower_bound(L.begin(), L.end(), L[i] + L[j]);
      int r = ite - L.begin();
      // cerr << l << " " << r << endl;
      ans += r - l;
    }
  }

  cout << ans << endl;
}
Problem p02583 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {

  long long n;
  cin >> n;

  vector<long long> dsides(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> dsides[i];
  }

  // set<long long> s(sides.begin(),sides.end());
  // vector<long long> dsides(s.begin(),s.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++) {
        if (dsides[i] != dsides[j] && dsides[k] != dsides[j] &&
            dsides[i] != dsides[k] && dsides[i] < dsides[j] + dsides[k] &&
            dsides[k] < dsides[j] + dsides[i] &&
            dsides[j] < dsides[i] + dsides[k])
          ans++;
      }

  cout << ans << endl;

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {

  long long n;
  cin >> n;

  vector<long long> dsides(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> dsides[i];
  }

  // set<long long> s(sides.begin(),sides.end());
  // vector<long long> dsides(s.begin(),s.end());

  int ans = 0;

  for (int i = 0; i < dsides.size() - 2; i++)
    for (int j = i + 1; j < dsides.size() - 1; j++)
      for (int k = j + 1; k < dsides.size(); k++) {
        if (dsides[i] != dsides[j] && dsides[k] != dsides[j] &&
            dsides[i] != dsides[k] && dsides[i] < dsides[j] + dsides[k] &&
            dsides[k] < dsides[j] + dsides[i] &&
            dsides[j] < dsides[i] + dsides[k])
          ans++;
      }

  cout << ans << endl;

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

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

template <typename T> inline bool make_triangle(T val1, T val2, T val3) {
  return val1 + val2 > val3 && val1 + val3 > val2 && val2 + val3 > val1;
}

int main() {
  int n;
  cin >> n;
  int *line = new int[n];
  for (int i = 0; i < n; ++i) {
    auto value = 0;
    cin >> value;
    line[i] = value;
  }

  auto len = n;
  auto count = 0;
  for (int i = 0; i < len - 2; ++i) {
    for (int j = i + 1; j < len - 1; ++j) {
      if (line[i] == line[j])
        continue;

      for (int k = j + 1; k < len; ++k) {
        if (line[i] == line[k] || line[j] == line[k])
          continue;
        if (line[i] + line[j] > line[k] && line[i] + line[k] > line[j] &&
            line[j] + line[k] > line[i])
          count++;
      }
    }
  }

  cout << count;

  delete[] line;

  return 0;
}

Error: TLE

Fixed submission:

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

template <typename T> inline bool make_triangle(T val1, T val2, T val3) {
  return val1 + val2 > val3 && val1 + val3 > val2 && val2 + val3 > val1;
}

int main() {
  int n;
  cin >> n;
  vector<int> line;
  for (int i = 0; i < n; ++i) {
    auto value = 0;
    cin >> value;
    line.push_back(value);
  }

  auto len = line.size();
  auto count = 0;
  for (size_t i = 0; i < len - 2; ++i) {
    for (size_t j = i + 1; j < len - 1; ++j) {
      if (line[i] == line[j])
        continue;

      for (size_t k = j + 1; k < len; ++k) {
        if (line[i] == line[k] || line[j] == line[k])
          continue;
        if (line[i] + line[j] > line[k] && line[i] + line[k] > line[j] &&
            line[j] + line[k] > line[i])
          count++;
      }
    }
  }

  cout << count;

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

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(); 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: Time Limit Exceeded

#include <bits/stdc++.h>

typedef long long ll;
// forループ
// 引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
//
//
#define int long long

using namespace std;

int ctoi(char c) {
  switch (c) {
  case '0':
    return 0;
  case '1':
    return 1;
  case '2':
    return 2;
  case '3':
    return 3;
  case '4':
    return 4;
  case '5':
    return 5;
  case '6':
    return 6;
  case '7':
    return 7;
  case '8':
    return 8;
  case '9':
    return 9;
  default:
    return 0;
  }
}

ll a, b, c, s, t, x, y, z;
ll A, B, C, S, T, X, Y, Z;

ll cnt;

long double pi = 3.14159265358979323846;

string N, M;

unsigned long long D;

signed main() {

  cin >> a;

  vector<int> f(a);

  REP(i, a) cin >> f[i];

  // cout << f.size() << endl;

  for (x = 0; x < a - 2; x++) {
    for (y = x + 1; y < a - 1; y++) {
      for (z = y + 1; z < a; z++) {
        if (f[x] != f[y] && f[y] != f[z] && f[x] != f[z] &&
            f[x] + f[y] > f[z] && f[z] + f[y] > f[x] && f[x] + f[z] > f[y]) {
          cnt++;
        }
      }
    }
  }

  cout << cnt << endl;
  ;

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

typedef long long ll;
// forループ
// 引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
//
//
#define int long long

using namespace std;

int ctoi(char c) {
  switch (c) {
  case '0':
    return 0;
  case '1':
    return 1;
  case '2':
    return 2;
  case '3':
    return 3;
  case '4':
    return 4;
  case '5':
    return 5;
  case '6':
    return 6;
  case '7':
    return 7;
  case '8':
    return 8;
  case '9':
    return 9;
  default:
    return 0;
  }
}

ll a, b, c, s, t, x, y, z;
ll A, B, C, S, T, X, Y, Z;

ll cnt;

long double pi = 3.14159265358979323846;

string N, M;

unsigned long long D;

signed main() {

  cin >> a;

  vector<int> f(a);

  REP(i, a) cin >> f[i];

  // cout << f.size() << endl;

  for (x = 0; x < f.size() - 2; x++) {
    for (y = x + 1; y < f.size() - 1; y++) {
      for (z = y + 1; z < f.size(); z++) {
        if (f[x] != f[y] && f[y] != f[z] && f[x] != f[z] &&
            f[x] + f[y] > f[z] && f[z] + f[y] > f[x] && f[x] + f[z] > f[y]) {
          cnt++;
        }
      }
    }
  }

  cout << cnt << endl;
  ;

  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(NULL);
  long long int n;
  cin >> n;
  vector<long long int> v;
  while (n--) {
    long long int x;
    cin >> x;
    v.push_back(x);
  }
  if (v.size() <= 2) {
    cout << "0";
  } else {
    long long int ans = 0;
    for (long long int i = 0; i < v.size() - 2; i++) {
      for (long long int j = i + 1; j < v.size() - 1; j++) {
        for (long long int k = j + 1; k < v.size(); k++) {
          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]) {
              ans++;
            }
          }
        }
      }
    }
    cout << ans;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  vector<long long int> v;
  while (n--) {
    long long int x;
    cin >> x;
    v.push_back(x);
  }
  long long int ans = 0;
  for (long long int i = 0; i < v.size() - 2; i++) {
    for (long long int j = i + 1; j < v.size() - 1; j++) {
      for (long long int k = j + 1; k < v.size(); k++) {
        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]) {
            ans++;
          }
        }
      }
    }
  }
  cout << ans;
  return 0;
}