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

#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int a = 0, b = 0, n, m, t, set, high = 0, low = 0, dif, tmp = 0;
  scanf("%d", &t);

  for (int k = 0; k < t; k++) {
    cin >> n;
    cin >> m;
    tmp = m;
    set = m;

    for (int i = 0; i < n - 1; i++) {
      cin >> m;

      if (m > tmp) { // 次の段差が今より高いとき
        if (m - tmp > high) {
          high = m - tmp;
          a++;
        }
      }

      else if (m < tmp) { // 次の段差が今より低いとき
        if (tmp - m > low) {
          low = tmp - m;
          b++;
        }
      }

      tmp = m;
    }

    if (a == n || b == n) {
      cout << "0 0" << endl;
    }

    else {
      cout << high << " " << low << endl;
    }

    a = 0;
    b = 0;
    high = 0;
    low = 0;
    tmp = 0;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int a = 0, b = 0, n, m, t, set, high = 0, low = 0, dif, tmp = 0;
  while (scanf("%d", &t) != EOF) {

    while (t > 0) {
      cin >> n;
      cin >> m;
      tmp = m;
      set = m;

      for (int i = 0; i < n - 1; i++) {
        cin >> m;

        if (m > tmp) { // 次の段差が今より高いとき
          if (m - tmp > high) {
            high = m - tmp;
            a++;
          }
        }

        else if (m < tmp) { // 次の段差が今より低いとき
          if (tmp - m > low) {
            low = tmp - m;
            b++;
          }
        }
        tmp = m;
      }

      if (a == n || b == n) {
        cout << "0 0" << endl;
      }

      else {
        cout << high << " " << low << endl;
      }
      a = 0;
      b = 0;
      high = 0;
      low = 0;
      tmp = 0;
    }
  }

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

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

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

Error: TLE

Fixed submission:

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

int main() {
  long long int n, sum;
  while (cin >> n, n) {
    int N = n;
    sum = 1;
    for (int i = 1; i <= n; i++) {
      if (n % i == 0) {
        int j = 1, temp = 1;
        while (n % i == 0 && i != 1) {
          n /= i;
          temp += (int)pow(i, j++);
        }
        //	  cout <<"temp"<< temp << endl;
        sum *= temp;
      }
    }
    sum -= N;
    //        cout << sum << endl;
    if (sum > N)
      cout << "abundant number" << endl;
    else if (sum < N)
      cout << "deficient number" << endl;
    else
      cout << "perfect number" << endl;
  }
  return 0;
}
Problem p01224 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int prime[1229];
bool ifnotPrime[10001];

void setPrime() {
  int i = 0;
  ifnotPrime[0] = ifnotPrime[1] = 1;
  for (int n = 2; n <= 10000; n++) {
    if (!ifnotPrime[n]) {
      prime[i] = n;
      i++;
      int m = n * n;
      while (m <= 10000) {
        ifnotPrime[m] = 1;
        m += n;
      }
    }
  }
}

int main() {
  setPrime();
  int N;
  cin >> N;
  while (N > 0) {
    int M = N, a = 1;
    for (int i = 0; M > 1 && i < 1229; i++) {
      int b = 1, c = 1;
      while (M % prime[i] == 0) {
        c *= prime[i];
        b += c;
        M /= prime[i];
      }
      a *= b;
    }
    if (M > 1) {
      a *= 1 + M;
    }
    a -= N;
    if (a > N) {
      cout << "abundant number" << endl;
    } else if (a < N) {
      cout << "deficient number" << endl;
    } else {
      cout << "perfect number" << endl;
    }
    cin >> N;
  }
  return 0;
}

Error: -8

Fixed submission:

#include <iostream>
using namespace std;

int prime[1230];
bool ifnotPrime[10001];

void setPrime() {
  int i = 0;
  ifnotPrime[0] = ifnotPrime[1] = 1;
  for (int n = 2; n <= 10000; n++) {
    if (!ifnotPrime[n]) {
      prime[i] = n;
      i++;
      int m = n * n;
      while (m <= 10000) {
        ifnotPrime[m] = 1;
        m += n;
      }
    }
  }
}

int main() {
  setPrime();
  int N;
  cin >> N;
  while (N > 0) {
    int M = N, a = 1;
    for (int i = 0; M > 1 && i < 1230; i++) {
      int b = 1, c = 1;
      while (M % prime[i] == 0) {
        c *= prime[i];
        b += c;
        M /= prime[i];
      }
      a *= b;
    }
    if (M > 1) {
      a *= 1 + M;
    }
    a -= N;
    if (a > N) {
      cout << "abundant number" << endl;
    } else if (a < N) {
      cout << "deficient number" << endl;
    } else {
      cout << "perfect number" << endl;
    }
    cin >> N;
  }
  return 0;
}
Problem p01224 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int n;

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

Error: TLE

Fixed submission:

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

int main() {
  int x;

  while (cin >> x, x) {
    int sum = 0;
    for (int i = 1; i <= x / 2; ++i) {
      if (x % i == 0)
        sum += i;
    }
    if (x > sum)
      cout << "deficient number" << endl;
    else if (x == sum)
      cout << "perfect number" << endl;
    else
      cout << "abundant number" << endl;
  }
}
Problem p01224 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int n;

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

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int n;

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

#include <iostream>
using namespace std;

int main(void) {

  int N, S;
  int temp;
  int sum;

  while (1) {

    int temp = 0;

    cin >> N;

    if (N == 0)
      break;

    sum = 0;

    for (int j = 1; j * j <= N; j++) {

      if (N % j == 0) {
        sum += j;
        if (j * j != N)
          sum += N / j;
      }
    }

    sum -= N;

    if (N < sum)
      cout << "abundant number" << endl;
    else if (N > sum)
      cout << "deficient number" << endl;
    else
      cout << "perfect number" << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main(void) {

  int N, S;
  int temp;
  int sum;

  while (1) {

    int temp = 0;

    cin >> N;

    if (N == 0)
      break;

    sum = 0;

    for (int j = 1; j <= N / 2; j++) {

      if (N % j == 0)
        sum += j;
    }

    // sum -= N;

    if (N < sum)
      cout << "abundant number" << endl;
    else if (N > sum)
      cout << "deficient 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 s = 0;

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

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

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int n;

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

    if (n == 6) {
      cout << "perfect number" << endl;
      continue;
    } else {
      for (int i = 1; i <= n / 4; i++) {
        if (n % i == 0 && i < n / i) {
          s += i;
          s += n / i;
        }
      }
    }
    s -= n;
    if (n == s) {
      cout << "perfect number" << endl;
    } else if (n > s) {
      cout << "deficient number" << endl;
    } else
      cout << "abundant number" << endl;
  }

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

#include <stdio.h>

int main() {
  long long int N, i, j, yaku;
  while (scanf("%lld", &N)) {
    if (N == 0)
      break;
    yaku = 0;
    for (i = 1; i * i <= N; i++) {
      if (N % i == 0) {
        yaku += i + N / i;
      }
      if (N == i * i) {
        yaku -= i;
      }
      if (yaku > 2 * N)
        break;
    }
    // printf("%d\\n",yaku);
    if (yaku > 2 * N) {
      puts("abundant number");
    } else if (yaku == 2 * N) {
      puts("perfect number");
    } else {
      puts("deficient number");
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

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

#include <cmath>
#include <iostream>

void check(int number) {
  int root_num = sqrt(number);
  int total = 0;

  for (int i = 1; i <= root_num; i++) {
    if (number % i == 0) {
      total += i;
      if (i != number / i) {
        total += (number / i);
      }
    }
  }
  total -= number;
  if (total == number) {
    std::cout << "perfect number" << std::endl;
  } else if (total < number) {
    std::cout << "deficient number" << std::endl;
  } else {
    std::cout << "abundant number" << std::endl;
  }

  return;
}

int main(void) {
  int number;
  while (1) {
    std::cin >> number;
    if (number == 0) {
      break;
    }
    check(number);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

void check(int number) {
  int total = 0;
  for (int i = 1; i < number; i++) {
    if (number % i == 0) {
      total += i;
    }
  }
  if (total == number) {
    std::cout << "perfect number" << std::endl;
  } else if (total < number) {
    std::cout << "deficient number" << std::endl;
  } else {
    std::cout << "abundant number" << std::endl;
  }

  return;
}

int main(void) {
  int number;
  while (1) {
    std::cin >> number;
    if (number == 0) {
      break;
    }
    check(number);
  }

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

#include <climits>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MAX 100000010

int n;
void init() { n = 0; }

bool input() {
  cin >> n;
  return n;
}

string solve() {
  int ans = 1;
  for (int i = 2; i * i < n; i++) {
    if (n % i == 0) {
      ans += i + n / i;
    }
  }

  if (n == 1)
    ans = 0;
  if (ans == n) {
    return "perfect number";
  } else if (ans < n) {
    return "deficient number";
  } else if (ans > n) {
    return "abundant number";
  }
}

int main() {
  while (init(), input()) {
    cout << solve() << endl;
  }
}

Error: TLE

Fixed submission:

#include <climits>
#include <cstdio>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MAX 100000010

int n;
void init() { n = 0; }

bool input() {
  cin >> n;
  return n;
}

int solve() {
  int ans = 0;
  for (int i = 1; i < n; i++) {
    if (n % i == 0) {
      ans += i;
    }
  }
  if (ans == n) {
    return 0;
  } else if (ans < n) {
    return 1;
  } else if (ans > n) {
    return 2;
  }
}

int main() {
  while (init(), input()) {
    switch (solve()) {
    case 0:
      cout << "perfect number" << endl;
      break;
    case 1:
      cout << "deficient number" << endl;
      break;
    case 2:
      cout << "abundant number" << endl;
      break;
    }
  }
}
Problem p01224 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REAP(i, a, n) for (int i = (a); i < (n); i++)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(), v.end()
typedef long long ll;

ll counum(ll n) {
  ll cou = 0;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      cou += i;
      if (n / i != i && i != 1)
        cou += n / i;
    }
  }
  if (n != 1)
    return cou;
  else
    return 0;
}

int main() {
  int n;
  while (cin >> n, n) {
    ll cou = counum(n);
    if (n == cou)
      cout << "perfect number" << endl;
    else if (n < cou)
      cout << "abundant number" << endl;
    else
      cout << "deficient number" << endl;
  }
}


Error: TLE

Fixed submission:

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REAP(i, a, n) for (int i = (a); i < (n); i++)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(), v.end()
typedef long long ll;

#define N 100000001

// void counum(){
//     for(ll i=1;i<N;i++){
//         for(ll j=2*i;j<N;j+=i){
//             num[j]+=i;
//         }
//     }
// }

ll cousum(ll num) {
  ll cou = 0;
  for (ll i = num / 2; i > 0; i--) {
    if (num % i == 0) {
      cou += i;
    }
  }
  return cou;
}

int main() {
  //    counum();
  ll n;
  while (cin >> n, n) {
    ll cou = cousum(n);
    if (n == cou)
      cout << "perfect number" << endl;
    else if (n > cou)
      cout << "deficient number" << endl;
    else
      cout << "abundant number" << endl;
  }
}
Problem p01224 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define REP(i, s, e) for (int i = int(s); i <= int(e); i++)
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define pi 3.14159265358979

int main(void) {

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

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

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

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define REP(i, s, e) for (int i = int(s); i <= int(e); i++)
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define pi 3.14159265358979

int main(void) {

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

    if (n == 1)
      cout << "deficient number" << endl;
    else {
      int s = 1;

      for (int i = 2; i <= n / 2; i++) {
        if (n % i == 0) {
          s += n / i;
          if (s > n) {
            cout << "abundant number" << endl;
            break;
          }
        }
      }

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

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

#include <cmath>
#include <iostream>

using namespace std;

int main() {
  int n;
  int i;
  while (true) {
    double s = 0.0;
    cin >> n;
    if (n == 0)
      break;
    bool flag = false;
    // 約数列挙
    for (i = 1; i < sqrt(n); i++) {
      //		cout << i;
      if (n % i == 0) {
        s += i;
        s += (n / i);
        if (s < 0) {
          flag = true;
          break;
        }
        //				cout << i << endl;
        //				cout << (n/i) << endl;
      }
    }
    s -= n;
    if ((double)n < s || flag)
      cout << "abundant number" << endl;
    else if ((double)n > s)
      cout << "deficient number" << endl;
    else if ((double)n == s)
      cout << "perfect number" << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>

using namespace std;

int main() {
  int n;
  int i;
  while (true) {
    double s = 0.0;
    cin >> n;
    if (n == 0)
      break;
    bool flag = false;
    // 約数列挙
    for (i = 1; i < n; i++) {
      //		cout << i;
      if (n % i == 0) {
        s += i;
        if (s < 0) {
          flag = true;
          break;
        }
        //				cout << i << endl;
      }
    }
    if ((double)n < s || flag)
      cout << "abundant number" << endl;
    else if ((double)n > s)
      cout << "deficient number" << endl;
    else if ((double)n == s)
      cout << "perfect number" << endl;
  }
  return 0;
}
Problem p01224 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;
int perfect_number[5] = {6, 28, 496, 8128, 33550336};

void solve() {
  int N;
  while (cin >> N, N) {
    bool perfect_flag = false;
    for (int i = 0; i < 5; ++i) {
      if (perfect_number[i] == N) {
        cout << "perfect number" << endl;
        perfect_flag = true;
        break;
      }
    }
    if (perfect_flag) {
      continue;
    }
    int sum = -N;
    for (int i = 1; i * i <= N; ++i) {
      if (N % i == 0) {
        sum += i + N / i;
        if (i == N / i) {
          sum -= i;
        }
      }
    }
    if (sum < N) {
      cout << "deficient number" << endl;
    } else {
      cout << "abundant number" << endl;
    }
  }
}

int main() {
  solve();
  return (0);
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;
int perfect_number[5] = {6, 28, 496, 8128, 33550336};

void solve() {
  int N;
  while (cin >> N, N) {
    bool perfect_flag = false;
    for (int i = 0; i < 5; ++i) {
      if (perfect_number[i] == N) {
        cout << "perfect number" << endl;
        perfect_flag = true;
        break;
      }
    }
    if (perfect_flag) {
      continue;
    }
    int sum = 0;
    int n = N / 2;
    for (int i = 1; i <= n; ++i) {
      if (N % i == 0) {
        sum += i;
      }
    }
    if (sum < N) {
      cout << "deficient number" << endl;
    } else {
      cout << "abundant number" << endl;
    }
  }
}

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

#include <cstdio>
#include <iostream>
#include <math.h>
using namespace std;

int solve(int n) {
  int total = 0;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      total += i;
      if (i * i != n)
        total += n / i;
    }
  }
  total -= n;
  return total - n;
}

int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    if (n == 0)
      return 0;
    int result = solve(n);
    if (result == 0)
      puts("perfect number");
    else if (result < 0)
      puts("deficient number");
    else if (result > 0)
      puts("abundant number");
  }
}

Error: TLE

Fixed submission:

#include <cstdio>

const int primeMax = 100000000;
bool notPrime[primeMax];

void init() {
  notPrime[0] = true;
  notPrime[1] = true;
  for (int i = 2; i * i < primeMax; i++) {
    if (notPrime[i])
      continue;
    for (int x = (i << 1); x < primeMax; x += i) {
      if (notPrime[x])
        continue;
      notPrime[x] = true;
    }
  }
}

int solve(int n) {
  int total = 1;
  int first = n;
  for (int i = n - 1; i > 1; i--) {
    if (notPrime[i])
      continue;

    if (n % i == 0) {
      n /= i;
      total += i;
    }
  }
  return first - n;
}

int main() {
  int n;
  init();
  while (scanf("%d", &n) != EOF) {
    if (n == 0)
      return 0;
    int result = solve(n);
    if (result == 0)
      puts("perfect number");
    else if (result > 0)
      puts("abundant number");
    else if (result < 0)
      puts("deficient number");
  }
}
Problem p01224 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

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

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main(int argc, char const *argv[]) {
  long long int n;
  while (cin >> n, n) {
    long long int total = 0;
    for (long long int i = 1; total < n && i * 2 <= n; i++) {
      if (n % i == 0)
        total += i;
    }
    if (total < n) {
      cout << "deficient number" << endl;
      ;
    } else if (total > n) {
      cout << "abundant number" << endl;
    } else {
      cout << "perfect number" << endl;
    }
  }
  return 0;
}
Problem p01224 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  long long a = 6;
  while (cin >> a && a != 0) {
    long long sum = 1, a2 = a;
    int i = 2;
    while (a != 1) {
      if (a % i == 0) {
        int j = 1;
        long long sum2 = 1;
        while (a % i == 0) {
          sum2 += (pow(i, j));
          j++;
          a /= i;
        }
        sum *= sum2;
      }
      if (i == 2)
        i++;
      else
        i += 2;
    }
    sum -= a2;
    if (a2 == sum)
      cout << "perfect number" << endl;
    else if (a2 > sum)
      cout << "deficient number" << endl;
    else
      cout << "abundant number" << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  long long a = 6;
  while (cin >> a && a != 0) {
    long long sum = 1, a2 = a;
    int i = 2;
    while (a != 1) {
      if (a % i == 0) {
        int j = 1;
        long long sum2 = 1;
        while (a % i == 0) {
          sum2 += (pow(i, j));
          j++;
          a /= i;
        }
        sum *= sum2;
      }
      i++;
    }
    sum -= a2;
    if (a2 == sum)
      cout << "perfect number" << endl;
    else if (a2 > sum)
      cout << "deficient number" << endl;
    else
      cout << "abundant number" << endl;
  }
}