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

#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(t, i, c) for (t::iretator i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

const double EPS = 1e-10;

int main() {
  int n;

  while (cin >> n, n) {
    int sum = 1;

    for (int i = 2; i * i < n; i++) {
      if (n % i == 0) {
        sum += i;
        sum += n / i;
      }
    }

    if (n == 1) {
      sum = 0;
    }

    if (sum == n) {
      cout << "perfect number" << endl;
    } else if (sum < n) {
      cout << "deficient number" << endl;
    } else {
      cout << "abundant number" << endl;
    }
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(t, i, c) for (t::iretator i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

const double EPS = 1e-10;

int main() {
  int n;

  while (cin >> n, n) {
    int sum = 0;

    FOR(i, 1, n / 2 + 1) {
      if (n % i == 0) {
        sum += i;
      }
    }

    if (sum == n) {
      cout << "perfect number" << endl;
    } else if (sum < n) {
      cout << "dificient number" << endl;
    } else {
      cout << "abunduant number" << endl;
    }
  }
}
Problem p01224 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <cstdio>
int yaksu(int a) {
  if (a == 1)
    return 1;
  int res = a;
  for (int i = sqrt(a); i > 0; i--) {
    if (a % i == 0) {
      res -= i;
      if (i != a / i && i != 1)
        res = res - a / i;
    }
    if (res < 0)
      break;
  }
  return res;
}

int main() {
  int a, tk;
  while (1) {
    scanf("%d", &a);
    if (a == 0)
      return 0;
    tk = yaksu(a);
    if (tk > 0)
      printf("deficient number\\n");
    else if (tk == 0)
      printf("perfect number\\n");
    else
      printf("abundant number\\n");
  }
}

Error: TLE

Fixed submission:

#include <cstdio>
long int yaksu(long int a) {
  long int res = a;
  for (long int i = a / 2; i > 0; i--) {
    if (a % i == 0)
      res -= i;
    if (res < 0)
      break;
  }
  return res;
}

int main() {
  long int a, tc;
  while (1) {
    scanf("%ld", &a);
    if (a == 0)
      return 0;
    tc = yaksu(a);
    if (tc > 0)
      printf("deficient number\\n");
    else if (tc == 0)
      printf("perfect number\\n");
    else
      printf("abundant number\\n");
  }
}
Problem p01224 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
using namespace std;
int main() {
  int n, sum = 0, i;
  while (1) {
    scanf("%d", &n);
    if (n == 0)
      break;
    for (i = 1; i * i <= n; i++) {
      if (n != i) {
        if (n % i == 0) {
          sum += i;
          if (i != n / i) {
            sum += n / i;
          }
          if (sum > 2 * n) {
            break;
          }
        }
      }
    }
    if (sum < 2 * n) {
      printf("deficient number\\n");
    } else if (sum == 2 * n) {
      printf("perfect number\\n");
    } else {
      printf("abundant number\\n");
    }
    sum = 0;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
using namespace std;
int main() {
  long long int n, sum = 0, i;
  while (1) {
    scanf("%lld", &n);
    for (i = 1; i * i <= n; i++) {
      if (n != i) {
        if (n % i == 0) {
          sum += i;
          if (i != n / i) {
            sum += n / i;
          }
        }
      }
    }
    if (sum < 2 * n) {
      printf("deficient number\\n");
    } else if (sum == 2 * n) {
      printf("perfect number\\n");
    } else {
      printf("abundant number\\n");
    }
    sum = 0;
  }
  return 0;
}
Problem p01224 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
#pragma warning(disable : 4996)
int n;
int main() {
  while (true) {
    scanf("%d", &n);
    if (n == 0)
      break;
    int ret = n > 1 ? 1 : 0;
    for (int i = 2; i * i <= n; i++) {
      if (n % i == 0) {
        if (i * i != n) {
          ret += i + n / i;
        } else {
          ret += i;
        }
      }
    }
    if (n > ret) {
      printf("deficient number\\n");
    } else if (n == ret) {
      printf("perfect number\\n");
    } else {
      printf("abundant number\\n");
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
#pragma warning(disable : 4996)
int n;
int main() {
  while (true) {
    scanf("%d", &n);
    if (n == 0)
      break;
    int ret = 0;
    for (int i = 1; i < n; i++) {
      if (n % i == 0)
        ret += i;
    }
    if (n > ret) {
      printf("deficient number\\n");
    } else if (n == ret) {
      printf("perfect number\\n");
    } else {
      printf("abundant number\\n");
    }
  }
  return 0;
}
Problem p01224 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, sum;
  while (1) {
    sum = 0;
    cin >> n;
    if (n == 0)
      break;
    for (int i = 1; i * i <= n; i++) {
      if (n % i == 0) {
        int j = n / i;
        // jは片方の約数
        sum += i;
        if (j != i)
          sum += j;
      }
    }
    sum = sum - n;
    if (n == sum)
      cout << "perfect number" << endl;
    if (n > sum)
      cout << "deficient number" << endl;
    if (n < sum)
      cout << "abundant number" << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (1) {
    int sum = 0;
    cin >> n;
    for (int i = 1; i * i <= n; i++) {
      if (n % i == 0) {
        int j = n / i;
        // jは片方の約数
        sum += i;
        if (j != i)
          sum += j;
      }
    }
    sum = sum - n;
    if (n == sum)
      cout << "perfect number" << endl;
    if (n > sum)
      cout << "deficient number" << endl;
    if (n < sum)
      cout << "abundant number" << endl;
  }
  return 0;
}
Problem p01224 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
using namespace std;

int main() {
  while (1) {
    int n;
    scanf("%d", &n);
    if (!n)
      return 0;
    int ds = 0;
    for (int i = 1; i * i <= n; ++i) {
      if (!(n % i))
        ds += i + (n / i);
      if (i * i == n)
        ds -= i;
    }
    ds -= n;
    if (ds == n)
      puts("perfect number");
    else if (ds < n)
      puts("deficient number");
    else
      puts("abundant number");
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
using namespace std;

int main() {
  while (1) {
    int n;
    scanf("%d", &n);
    if (!n)
      return 0;
    int ds = 0;
    for (int i = 1; 2 * i <= n; ++i) {
      if (!(n % i))
        ds += i;
    }
    if (ds == n)
      puts("perfect number");
    else if (ds < n)
      puts("deficient number");
    else
      puts("abundant number");
  }
  return 0;
}
Problem p01224 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iostream>
#define int long long
using namespace std;
signed main() {
  int n;
  while (cin >> n, n) {
    if (n == 1) {
      cout << "deficient number\\n";
      continue;
    }
    int sum = 1;
    for (int i = 2; i <= sqrt(n); i++) {
      if (n % i == 0)
        sum += i + (n / i);
      if (i * i == n)
        sum -= i;
    }
    if (n == sum)
      cout << "perfect number\\n";
    else
      cout << (n < sum ? "abundant number\\n" : "deficient number\\n");
  }
}


Error: TLE

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;
int main() {
  enum type { p, d, a };
  vector<type> l;
  long long n, s;
  while (cin >> n) {
    if (n == 0)
      break;
    s = 0;
    vector<long long> rr;
    for (int i = 1; i < n / 2 + 1; i++) {
      if (n % i == 0) {
        s += i;
      }
    }
    for (int i = 0; i < rr.size(); i++) {
      s += n / rr[i];
    }
    if (n == s)
      l.push_back(p);
    else if (n > s)
      l.push_back(d);
    else if (n < s)
      l.push_back(a);
  }
  for (type i : l) {
    if (i == p)
      cout << "perfect number";
    else if (i == d)
      cout << "deficient number";
    else if (i == a)
      cout << "abundant number";
    cout << endl;
  }
}
Problem p01224 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <iostream>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
using namespace std;

int main() {
  long long s, n;
  while (cin >> n, n) {
    s = 1;
    loop(i, 2, sqrt(n)) if (n % i == 0) {
      s += i;
      s += (n / i);
    }
    if (n == 1)
      cout << "deficient number" << endl;
    else if (n > s)
      cout << "deficient number" << endl;
    else if (n < s)
      cout << "abundant number" << endl;
    else
      cout << "perfect number" << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
using namespace std;

int main() {
  long long s, n;
  while (cin >> n, n) {
    s = 0;
    loop(i, 1, n) if (n % i == 0) s += i;
    if (n > s)
      cout << "deficient number" << endl;
    else if (n < s)
      cout << "abundant number" << endl;
    else
      cout << "perfect number" << endl;
  }
  return 0;
}
Problem p01224 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <math.h>
#include <stdio.h>

int main(void) {
  int i, n, sum;
  while (1) {
    scanf("%d", &n);
    if (!n)
      break;
    sum = 0;
    for (i = 1; i <= sqrt((double)n); i++) {
      if (n % i == 0 && n != 1) {
        sum += i;
        if (i != 1 && i != n / i)
          sum += n / i;
      }
    }
    if (sum == n)
      printf("perfect number\\n");
    else if (sum < n)
      printf("deficient number\\n");
    else
      printf("abundant number\\n");
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int mod(int m, int n) {
  int a;
  a = m / n;
  return m - a * n;
}

int main(void) {
  int i, n, sum;
  while (1) {
    scanf("%d", &n);
    if (!n)
      break;
    sum = 0;
    if (!mod(n, 2)) {
      for (i = n / 2; i >= 1; i--) {
        if (sum > n)
          break;
        if (!mod(n, i))
          sum += i;
      }
    }
    if (sum == n)
      printf("perfect number\\n");
    else if (sum < n)
      printf("deficient number\\n");
    else
      printf("abundant number\\n");
  }
  return 0;
}
Problem p01224 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int N;
  while (cin >> N, N != 0) {
    long long sum = 1;
    int i;
    for (i = 2; i * i < N; i++)
      if (N % i == 0) {
        sum += i;
        sum += N / i;
      }
    if (i * i == N)
      sum += i;
    if (N == 1)
      sum -= 1;
    if (N > sum)
      cout << "deficient number" << endl;
    else if (N < sum)
      cout << "abundant number" << endl;
    else
      cout << "perfect number" << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int N;
  while (cin >> N, N != 0) {
    long long sum = 0;
    for (int i = 1; i < N; i++) {
      if (N % i == 0)
        sum += i;
    }
    if (N > sum)
      cout << "deficient number" << endl;
    else if (N > sum)
      cout << "abundant number" << endl;
    else
      cout << "perfect number" << endl;
  }
  return 0;
}
Problem p01224 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define r(i, n) for (int i = 1; i < n; i++)
using namespace std;
int main() {
  long long n, p, a, b;
  while (cin >> n, n) {
    long long s = 1;
    if (n == 1)
      s--;
    for (int i = 2; i * i < n; i++)
      if (n % i == 0)
        s += i + n / i;
    if (n < s)
      cout << "abundant number" << endl;
    else if (n > s)
      cout << "deficient number" << endl;
    else
      cout << "perfect number" << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define r(i, n) for (int i = 1; i < n; i++)
using namespace std;
int main() {
  long long n, p, a, b;
  while (cin >> n, n) {
    long long s = 1;
    if (n == 1)
      s--;
    for (int i = 2; i < n / 2; i++)
      if (n % i == 0)
        s += i + n / i;
    if (n < s)
      cout << "abundant number" << endl;
    else if (n > s)
      cout << "deficient number" << endl;
    else
      cout << "perfect number" << endl;
  }
}
Problem p01224 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;

#define dump(x) cerr << #x << " = " << (x) << endl
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back

int main() {
  int n;
  while (cin >> n) {
    if (n == 0)
      break;

    int sum = 0;
    for (int i = 1; i <= sqrt(n); i++) {
      if (n % i == 0) {
        if (i != n)
          sum += i;
        if (i * i != n && i != 1)
          sum += n / i;
      }
    }
    if (sum == n)
      cout << "perfect number" << endl;
    else if (sum < n)
      cout << "deficient number" << endl;
    else if (sum > n)
      cout << "abundant number" << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;

#define dump(x) cerr << #x << " = " << (x) << endl
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back

int main() {
  int n;
  while (cin >> n) {
    if (n == 0)
      break;

    int sum = 0;
    for (int i = 1; i <= n / 2; i++) {
      if (n % i == 0)
        sum += i;
    }
    if (sum == n)
      cout << "perfect number" << endl;
    else if (sum < n)
      cout << "deficient number" << endl;
    else if (sum > n)
      cout << "abundant number" << endl;
  }
  return 0;
}
Problem p01224 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n;
  while (cin >> n, n) {
    int ans = 1;
    for (int i = 2; i * i < n; i++) {
      if (n % i == 0) {
        ans += i;
        if (n / i != i)
          ans += n / i;
      }
    }
    if (n != 1 && ans == n) {
      cout << "perfect number" << endl;
    } else if (ans > n) {
      cout << "abundant number" << endl;
    } else {
      cout << "deficient number" << endl;
    }
  }
  return 0;
}


Error: -8

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    int ans = 1;
    for (int i = 0; i * i < n; i++) {
      if (n % i == 0) {
        ans += i;
        if (n / i != i)
          ans += n / i;
      }
    }
    if (n != 1 && ans < n) {
      cout << "deficient number" << endl;
    } else if (ans > n) {
      cout << "abundant number" << endl;
    } else {
      cout << "perfect number" << endl;
    }
  }
  return 0;
}
Problem p01224 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {

  int n;

  while (cin >> n, n) {
    int k = -n + 1;

    for (int i = 2; i * i < n; i++) {
      if (!(n % i))
        k += n / i + i;
    }

    if (!k && n != 1)
      cout << "perfect number";
    else if (k < 0 || n == 1)
      cout << "deficient number";
    else
      cout << "abundant number";
    cout << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {

  int n;

  while (cin >> n, n) {
    int s = 0;
    bool k = true;

    for (int i = n / 2; i > 0; i--) {
      if (n % i == 0)
        s += i;
      if (s > n) {
        k = false;
        break;
      }
    }

    if (s == n)
      cout << "perfect number" << endl;
    else if (s > n || !k)
      cout << "abundant number" << endl;
    else if (s < n)
      cout << "deficient number" << endl;
  }
}
Problem p01224 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <fstream>
#include <iostream>
#include <math.h>
#include <stack>
#include <stdio.h>

using namespace std;

int main() {

  int n;
  while (cin >> n, n) {
    if (n < 2) {
      cout << "deficient number" << endl;
      continue;
    }

    int s = 1;
    for (int i = 2; i <= sqrt(n); i++) {
      if (n % i == 0 && i == sqrt(n) && n / sqrt(n) == sqrt(n)) {
        s += i;
      } else if (n % i == 0) {
        s += i;
        s += n / i;
      }
    }

    if (n == s)
      cout << "perfect number" << endl;
    if (n > s)
      cout << "deficient number" << endl;
    if (n < s)
      cout << "abundant number" << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <fstream>
#include <iostream>
#include <math.h>
#include <stack>
#include <stdio.h>

using namespace std;

int main() {

  int n;
  while (cin >> n, n) {
    if (n < 2) {
      cout << "deficient number" << endl;
      continue;
    }

    int s = 0;
    for (int i = 1; i <= n / 2; i++) {
      if (n % i == 0)
        s += i;
    }

    if (n == s)
      cout << "perfect number" << endl;
    if (n > s)
      cout << "deficient number" << endl;
    if (n < s)
      cout << "abundant number" << endl;
  }

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

#include <iostream>

using namespace std;

void solve(int in) {
  int ans = 0;
  if (in > 1)
    ans = 1;
  for (int i = 2; i * i <= in; i++) {
    if (in % i == 0) {
      if (i != in / i)
        ans += in / i;
      ans += i;
    }
  }

  if (ans > in)
    cout << "abundant number" << endl;
  if (ans == in)
    cout << "perfect number" << endl;
  if (ans < in)
    cout << "deficient number" << endl;
}

int main() {
  int in;
  while (cin >> in && in)
    solve(in);
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {

  int in;

  while (cin >> in) {
    if (in == 0)
      break;

    int sum = 0;

    for (int i = 1; i < in; i++) {
      if (in % i == 0)
        sum += i;
    }

    if (sum == in)
      cout << "perfect number" << endl;
    else if (sum < in)
      cout << "deficient number" << endl;
    else
      cout << "abundant number" << endl;
  }

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

// template {{{

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

#define loop(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) loop(i, 0, n)
#define rloop(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rrep(i, n) rloop(i, 0, n)
#define eb emplace_back
#define ef emplace_front
#define pb pop_back
#define pf pop_front
#define all(c) std::begin(c), std::end(c)
#define mp std::make_pair
#define mt std::make_tuple
#define fi first
#define se second
#define popcnt __builtin_popcountll

using uint = unsigned;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<double, double>;
using tp = tuple<int, int, int>;
using tp4 = tuple<int, int, int, int>;
using tp5 = tuple<int, int, int, int, int>;

template <typename T> using max_pq = priority_queue<T, vector<T>, less<T>>;

template <typename T> using min_pq = priority_queue<T, vector<T>, greater<T>>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 10;
const ll LLINF = 1e18 + 10;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
const int dx8[] = {-1, -1, 0, 1, 1, 1, 0, -1};
const int dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template <typename T> inline T sq(T x) { return x * x; }

template <typename T, typename U> inline bool chmax(T &x, U y) {
  if (x >= y)
    return false;
  x = y;
  return true;
}

template <typename T, typename U> inline bool chmin(T &x, U y) {
  if (x <= y)
    return false;
  x = y;
  return true;
}

template <typename T> inline void sort(T &c) {
  std::sort(std::begin(c), std::end(c));
}

template <typename T> inline void reverse(T &c) {
  std::reverse(std::begin(c), std::end(c));
}

template <typename T> inline void unique(T &c) {
  std::sort(std::begin(c), std::end(c));
  c.erase(std::unique(all(c)), std::end(c));
}

// }}}

int main() {
  int n;
  while (cin >> n, n) {
    int s = -n;
    for (int i = 1; i * i <= n; i++) {
      if (n % i == 0) {
        s += i;
        if (n / i != i) {
          s += n / i;
        }
      }
    }
    if (s == n)
      cout << "perfect number\\n";
    else if (s < n)
      cout << "deficient number\\n";
    else
      cout << "abundant number\\n";
  }
}

Error: TLE

Fixed submission:

#include <cstdio>
using namespace std;

int main() {
  int n;
  while (scanf("%d", &n), n) {
    int S = 0;
    for (int i = 1; i <= n / 2; i++) {
      if (n % i == 0) {
        S += i;
      }
    }

    if (n == S) {
      puts("perfect number");
    } else if (n > S) {
      puts("deficient number");
    } else {
      puts("abundant number");
    }
  }

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

#include <iostream>
using namespace std;
int main() {
  int n, sum;
  while (cin >> n, n) {
    sum = 0;
    for (int i = 1; i * i <= n; i++) {
      if (n % i == 0 && i != n) {
        sum += i;
        if (n / i != n && n / i != i)
          sum += n / i;
      }
    }
    if (n == sum)
      cout << "perfect number" << endl;
    else if (n > sum)
      cout << "deficient number" << endl;
    else
      cout << "abundant number" << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n, sum;
  while (cin >> n, n) {
    sum = 0;
    for (int i = 1; i * 2 <= n; i++) {
      if (n % i == 0 && i != n)
        sum += i;
    }

    if (n == sum)
      cout << "perfect number" << endl;
    else if (n > sum)
      cout << "deficient number" << endl;
    else
      cout << "abundant number" << endl;
  }
  return 0;
}