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

#include <iostream>
#include <memory.h>
#include <vector>
using namespace std;
const int g[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
int f[10] = {0};
vector<int> p;
int main() {
  int n;
  while (cin >> n) {
    p.clear();
    memset(f, 0, sizeof(f));

    while (n != 0) {
      for (int i = 9; i >= 0; i--) {
        if (n - g[i] >= 0 && f[i] == 0) {
          n -= g[i];
          f[i] = 1;
          p.push_back(g[i]);
        }
      }
    }
    for (int i = p.size() - 1; i >= 1; i--) {
      cout << p[i] << " ";
    }
    cout << p[0] << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
#include <memory.h>
#include <vector>
using namespace std;
const int g[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
int f[10] = {0};
vector<int> p;
int main() {

  while (1) {
    p.clear();
    memset(f, 0, sizeof(f));
    int n;
    cin >> n;
    while (n != 0) {
      for (int i = 9; i >= 0; i--) {
        if (n - g[i] >= 0 && f[i] == 0) {
          n -= g[i];
          f[i] = 1;
          p.push_back(g[i]);
        }
      }
    }
    for (int i = p.size() - 1; i >= 1; i--) {
      cout << p[i] << " ";
    }
    cout << p[0] << endl;
  }
}
Problem p00031 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int n, count = 0, sum = 1;
  static int ans[100][9] = {0};
  int data[100] = {0}, ansdata[100] = {0};
  for (int a = 0; a <= 10; a++) {
    data[a + 1] = sum;
    sum = sum * 2;
  }
  while (cin >> n) {
    int data2, count2 = 0;
    for (int a = 0; a <= 10; a++) {
      if (n < data[a + 1]) {
        sum = data[a];
        data2 = a;
        ans[count][count2] = a;
        count2++;
        break;
      }
    }
    for (int a = data2 - 1; a > 0; a--) {
      sum = sum + data[a];
      if (sum > n) {
        sum = sum - data[a];
      } else {
        ans[count][count2] = a;
        count2++;
      }
      if (sum == n) {
        break;
      }
    }
    ansdata[count] = count2;
    count++;
  }
  for (int a = 0; a < count; a++) {
    for (int b = ansdata[a] - 1; b >= 0; b--) {
      cout << data[ans[a][b]];
      if (b != 0)
        cout << " ";
    }
    cout << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int n, count = 0, sum = 1;
  int ans[100][9], data[100] = {0}, ansdata[100];
  for (int a = 0; a <= 9; a++) {
    data[a + 1] = sum;
    sum = sum * 2;
  }
  while (cin >> n) {
    sum = 0;
    int count2 = 0, sin = 1;
    for (int a = 0; a <= 9; a++) {
      if (n % 2 == 0 && sin == 1) {
        sum = sum - 1;
      }
      sum = sum + data[a + 1];
      ans[count][count2] = a + 1;
      if (sum > n) {
        sum = sum - (data[a]);
        count2 = count2 - 1;
        ans[count][count2] = a + 1;
        a--;
      }
      if (n % 2 == 0 && sin == 1) {
        count2--;
        sin = 2;
      }
      count2++;
      if (sum == n)
        break;
    }
    ansdata[count] = count2;
    count++;
  }
  for (int a = 0; a <= count; a++) {
    for (int b = 0; b < ansdata[a]; b++) {
      cout << data[ans[a][b]] << " ";
    }
    cout << endl;
  }
  return 0;
}
Problem p00031 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>

using namespace std;

int main() {
  int weight[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
  int gram;
  vector<int> ans;
  while (cin >> gram) {
    for (int i = 9; i >= 0; i--) {
      if (gram >= weight[i]) {
        ans.push_back(i);
        gram -= weight[i];
      }
    }

    for (int i = ans.size() - 1; i >= 0; i--) {
      cout << weight[ans[i]];
      if (i != 0)
        cout << ' ';
    }
    cout << endl;
    ans.clear();
  }
  return 0;
}

Error: -7

Fixed submission:

#include <iostream>
#include <vector>

using namespace std;

int main() {
  int weight[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
  int gram;
  vector<int> ans;
  while (cin >> gram) {
    for (int i = 9; i >= 0; i--) {
      if (gram >= weight[i]) {
        ans.push_back(i);
        gram -= weight[i];
      }
    }

    for (size_t i = ans.size() - 1; i >= 0; i--) {
      cout << weight[ans[i]];
      if (i != 0)
        cout << ' ';
    }
    cout << endl;
    ans.clear();
  }
  return 0;
}
Problem p00031 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int x;
  vector<int> v;

  while (scanf("%d ", &x) == 1) {
    v.clear();
    int omori = 512;
    while (x > 0) {
      if (x >= omori) {
        x -= omori;
        v.push_back(omori);
      }
      omori /= 2;
      // cout << x << endl;
    }
    for (int i = v.size() - 1; i >= 0; i--) {
      cout << v[i];
      if (i == 0) {
        cout << endl;
      } else {
        cout << " ";
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int x;
  while (scanf("%d ", &x) == 1) {
    int omori = 512;
    while (x != 0) {
      if (x >= omori) {
        x -= omori;
        cout << omori << " ";
        omori /= 2;
      }
    }
    cout << endl;
  }
  return 0;
}
Problem p00031 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main(void) {
  int x;
  while (cin >> x) {
    int a[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
    int b[10] = {0};

    int j = 0;
    for (int i = 9; i >= 0; i--) {
      if (x >= a[i]) {
        x -= a[i];
        b[j] = a[i];
        j++;
        if (x == 0)
          break;
      }
    }
    for (int i = 9; i >= 0; i--) {
      if (b[i] == 0)
        continue;
      else if (b[i] != 0)
        cout << b[i] << (i == 0 ? "\\n" : " ");
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main(void) {
  while (true) {
    int a[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
    int b[10] = {0};
    int x;
    cin >> x;
    int j = 0;
    for (int i = 9; i >= 0; i--) {
      if (x >= a[i]) {
        x -= a[i];
        b[j] = a[i];
        j++;
        if (x == 0)
          break;
      }
    }
    for (int i = 9; i >= 0; i--) {
      if (b[i] == 0)
        continue;
      else if (b[i] != 0)
        cout << b[i] << (i == 0 ? "\\n" : " ");
    }
  }
  return 0;
}
Problem p00031 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
int main() {
  int n, s;
  while (scanf("%d", &n) + 1) {
    for (s = 1; n; s *= 2) {
      n &s &&printf("%d%c", s, n - s ? 32 : 10);
      n -= n & s;
    }
  }
}

Error: TLE

Fixed submission:

#include <cstdio>
int main() {
  int n, s;
  while (scanf("%d", &n)) {
    for (s = 1; n; s *= 2) {
      n &s &&printf("%d%c", s, n - s ? 32 : 10);
      n -= n & s;
    }
  }
}
Problem p00031 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int w;
  while (cin >> w) {
    bool flag = 0;
    for (int i = 1; w > 0; i *= 2) {
      if (w % 2 > 0) {
        if (flag) {
          cout << ' ';
        }
        cout << i;
        flag = 1;
        w--;
      }
      w /= 2;
    }
    cout << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int w;
  while (cin >> w) {
    bool flag = 0;
    for (int i = 1; w >= 0; i *= 2) {
      if (w % 2 > 0) {
        if (flag) {
          cout << ' ';
        }
        cout << i;
        flag = 1;
        w--;
      }
      w /= 2;
    }
    cout << endl;
  }
  return 0;
}
Problem p00031 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
int main() {
  int n, temp;
  bool f;
  while (scanf("%d", &n) != EOF) {
    temp = 1;
    f = true;
    while (f) {
      if (n % (temp * 2) != 0) {
        printf("%d", temp);
        n -= temp;
        f = false;
      }
      temp *= 2;
    }
    while (n > 0) {
      if (n % (temp * 2) != 0) {
        printf(" %d", temp);
        n -= temp;
      }
      temp *= 2;
    }
    printf("\\n");
  }
}

Error: TLE

Fixed submission:

#include <stdio.h>
int main() {
  int n, temp;
  while (scanf("%d", &n) != EOF) {
    temp = 1;
    while (temp <= n)
      temp *= 2;
    temp /= 2;
    printf("%d", temp);
    n -= temp;
    while (n) {
      temp /= 2;
      n -= temp;
      printf("%d", temp);
    }
    printf("\\n");
  }
}
Problem p00031 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    vector<int> vec;
    for (int i = 512; i > 0; i = i >> 1) {
      if (n >= i) {
        n -= i;
        vec.push_back(i);
      }
    }
    for (int i = 0; i < vec.size() - 1; i++)
      cout << vec[vec.size() - 1 - i] << " ";
    cout << vec[0] << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int n;
  while (cin >> n, n != EOF) {
    vector<int> vec;
    for (int i = 512; i > 0; i = i >> 1) {
      if (n >= i) {
        n -= i;
        vec.push_back(i);
      }
    }
    for (int i = 0; i < vec.size(); i++)
      cout << vec[vec.size() - 1 - i] << " ";
    cout << endl;
  }
  return 0;
}
Problem p00031 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bitset>
#include <cmath>
#include <iostream>
#include <string>
int main() {
  int t;
  while (std::cin >> t) {
    std::bitset<11> value(t);
    std::string s = value.to_string();
    for (int i = 0; i < s.size(); i++) {
      if (s[0] == '0')
        s.erase(s.begin());
      else
        break;
    }
    int num = std::stoi(s);
    for (int i = 0; i < s.size(); i++) {
      if (num % 10) {
        std::cout << pow(2, (double)(i));
        if (pow(2, i) * 2 < t)
          std::cout << " ";
      }
      num /= 10;
    }
    std::cout << std::endl;
  }
}

Error: TLE

Fixed submission:

#include <bitset>
#include <cmath>
#include <iostream>
#include <string>
int main() {
  int t;
  while (std::cin >> t, t) {
    std::bitset<11> value(t);
    std::string s = value.to_string();
    for (int i = 0; i < s.size(); i++) {
      if (s[0] == '0')
        s.erase(s.begin());
      else
        break;
    }
    int num = std::stoi(s);
    for (int i = 0; i < s.size(); i++) {
      if (num % 10)
        std::cout << pow(2, (double)(i));
      if (i != s.size() - 1)
        std::cout << " ";
      num /= 10;
    }
    std::cout << std::endl;
  }
}
Problem p00031 (C++) — buggy submission, verdict: Runtime Error

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

int main(void) {
  char line[80];

  int w;

  int f[10];
  int u[10];

  int k = 512;
  for (int &d : f) {
    d = k;
    k >>= 1;
  }

  while (true) {
    if (fgets(line, sizeof line, stdin) == NULL) {
      break;
    }
    if (sscanf(line, "%d", &w) != 1) {
      break;
    }

    int p;
    for (p = 0; p < 10; p++) {
      if (w >= f[p]) {
        break;
      }
    }

    memset(u, 0, sizeof u);

    int t = f[p];
    u[p] = 1;
    p++;

    while (true) {
      if (t == w) {
        break;
      } else if (t > w) {
        t -= f[p - 1];
        u[p - 1] = 0;
      }

      t += f[p];
      u[p] = 1;
      p++;
    }

    const char *sp = "";
    for (int i = 9; i >= 0; i--) {
      if (u[i]) {
        printf("%s%d", sp, f[i]);
        if (*sp == 0) {
          sp = " ";
        }
      }
    }
    printf("\\n");
  }

  return 0;
}

Error: 0

Fixed submission:

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

int main(void) {
  char line[80];

  int w;

  int f[10];
  int u[10];

  int k = 512;
  for (int &d : f) {
    d = k;
    k >>= 1;
  }

  while (true) {
    if (fgets(line, sizeof line, stdin) == NULL) {
      break;
    }
    if (sscanf(line, "%d", &w) != 1) {
      break;
    }

    int p;
    for (p = 0; p < 10; p++) {
      if (w > f[p]) {
        break;
      }
    }

    memset(u, 0, sizeof u);

    int t = f[p];
    u[p] = 1;
    p++;

    while (true) {
      if (t == w) {
        break;
      } else if (t > w) {
        t -= f[p - 1];
        u[p - 1] = 0;
      }

      t += f[p];
      u[p] = 1;
      p++;
    }

    const char *sp = "";
    for (int i = 9; i >= 0; i--) {
      if (u[i]) {
        printf("%s%d", sp, f[i]);
        if (*sp == 0) {
          sp = " ";
        }
      }
    }
    printf("\\n");
  }

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

#include <algorithm>
#include <iostream>
using namespace std;
int weights[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024};
int main() {
  int n, a[10], b, c;
  while (cin >> n) {
    b = 0;
    c = 11;
    while (n != 0) {
      for (int i = 0; i < c; ++i) {
        if (n < weights[i]) {
          n -= weights[i - 1];
          a[b] = i - 1;
          c = i;
          ++b;
          break;
        }
      }
    }
    sort(a, a + b);
    for (int i = 0; i < b; ++i) {
      if (i == 0)
        cout << weights[a[i]];
      else
        cout << " " << weights[a[i]];
    }
    cout << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
using namespace std;
int weights[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
int main() {
  int n, a[10], b, c;
  while (cin >> n) {
    b = 0;
    c = 10;
    while (n != 0) {
      for (int i = 0; i < c; ++i) {
        if (n < weights[i]) {
          n -= weights[i - 1];
          a[b] = i - 1;
          c = i;
          ++b;
          break;
        }
      }
    }
    sort(a, a + b);
    for (int i = 0; i < b; ++i) {
      if (i == 0)
        cout << weights[a[i]];
      else
        cout << " " << weights[a[i]];
    }
    cout << endl;
  }
  return 0;
}
Problem p00032 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int a, b, c;
  int t = 0, h = 0;
  while (scanf("%d,%d,%d", &a, &b, &c) + 1) {
    // if(a==0)break;
    if (a == b)
      h++;
    if (c * c == a * a + b * b)
      t++;
  }
  cout << t << endl << h << endl;
}


Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int a, b, c;
  int t = 0, h = 0;
  while (scanf("%d,%d,%d", &a, &b, &c)) {
    // if(a==0)break;
    if (a == b)
      h++;
    if (c * c == a * a + b * b)
      t++;
  }
  cout << t << endl << h << endl;
}
Problem p00032 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main() {
  int a, b, c, sum1, sum2;
  sum1 = 0;
  sum2 = 0;
  while (scanf("%d,%d,%d", &a, &b, &c) != EOF) {
    if (a * a + b * b == c * c) {
      sum1 += 1;
    }
    if (a == b) {
      sum2 += 1;
    }
  }
  cout << sum1 << endl;
  cout << sum2 << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main() {
  int a, b, c, sum1, sum2;
  sum1 = 0;
  sum2 = 0;
  while (scanf("%d,%d,%d", &a, &b, &c)) {
    if (a * a + b * b == c * c) {
      sum1 += 1;
    }
    if (a == b) {
      sum2 += 1;
    }
  }
  cout << sum1 << endl;
  cout << sum2 << endl;
  return 0;
}
Problem p00032 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>

using namespace std;

int main() {

  int a, b, c, ob = 0, dia = 0;

  while (scanf("%d, %d, %d", &a, &b, &c) != EOF) {
    if (c * c == a * a + b * b)
      ob++;
    else if (a == b)
      dia++;
  }

  cout << ob << endl << dia << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>

using namespace std;

int main() {

  int a, b, c, ob = 0, dia = 0;

  while (scanf("%d %d %d", &a, &b, &c) != EOF) {
    if (c * c == a * a + b * b)
      ob++;
    else if (a == b)
      dia++;
  }

  printf("%d\\n%d\\n", ob, dia);

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

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
int main(void) {

  int a, b, c;
  int x = 0, y = 0;
  while (scanf("%d,%d,%d", &a, &b, &c) != EOF) {
    if (a * a + b * b == c * c) {
      x++;
      // cout<<a<<b<<c<<endl;
    }
    if (a == b) {
      y++;
      // cout<<a<<b<<c<<'.'<<endl;
    }
  }
  cout << x << endl << y << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
int main(void) {

  int a, b, c;
  int x = 0, y = 0;
  while (scanf("%d,%d,%d", &a, &b, &c)) {
    if (a * a + b * b == c * c) {
      x++;
      // cout<<a<<b<<c<<endl;
    }
    if (a == b) {
      y++;
      // cout<<a<<b<<c<<'.'<<endl;
    }
  }
  cout << x << endl << y << endl;

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

#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  int e1, e2, e3;
  int hisi = 0;
  int tyou = 0;
  char comma;

  while (cin >> e1 >> comma >> e2 >> comma >> e3) {
    if (e1 == e2)
      hisi++;
    else if (e1 * e1 + e2 * e2 == e3 * e3)
      tyou++;
  }

  cout << tyou << endl;
  cout << hisi << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  int e1, e2, e3;
  int hisi = 0;
  int tyou = 0;

  while (scanf("%d,%d,%d", &e1, &e2, &e3)) {
    if (e1 == e2)
      hisi++;
    else if (e1 * e1 + e2 * e2 == e3 * e3)
      tyou++;
  }

  cout << tyou << endl;
  cout << hisi << endl;

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

#include <iostream>
using namespace std;

int main() {
  int a, b, c;
  int d = 0, e = 0;
  while (scanf("%d,%d,%d", &a, &b, &c) != EOF) {
    // if(a==0&&b==0&&c==0){break;}
    if (a * a + b * b == c * c) {
      d++;
    }
    if (a == b) {
      e++;
    }
  }
  cout << d << endl << e << endl;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int a, b, c;
  int d = 0, e = 0;
  while (scanf("%d,%d,%d", &a, &b, &c)) {
    if (a * a + b * b == c * c)
      d++;
    if (a == b)
      e++;
  }
  cout << d << endl << e << endl;
}
Problem p00032 (C++) — buggy submission, verdict: Time Limit Exceeded

using namespace std;
#include <algorithm>
#include <functional>
#include <iostream>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>
int main() {
  int a, b, c;
  char t;
  int cho = 0, hishi = 0;
  while (cin >> a >> t >> b >> t >> c) {
    if (a * a + b * b == c * c)
      cho++;
    if (a == b)
      hishi++;
  }
  printf("%d\\n%d\\n", cho, hishi);
  return 0;
}

Error: TLE

Fixed submission:

using namespace std;
#include <algorithm>
#include <functional>
#include <iostream>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>
int main() {
  int a, b, c;
  int cho = 0, hishi = 0;
  while (scanf("%d,%d,%d", &a, &b, &c)) {
    if (a * a + b * b == c * c)
      cho++;
    if (a == b)
      hishi++;
  }
  printf("%d\\n%d\\n", cho, hishi);
  return 0;
}
Problem p00032 (C++) — buggy submission, verdict: Time Limit Exceeded

#include "bits/stdc++.h"
#include <unordered_map>
#include <unordered_set>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

int solve(int n, int sum, int amax) {
  if (n == 0) {
    if (sum == 0) {
      return 1;
    } else {
      return 0;
    }
  } else if (amax * n < sum || 0 * n > sum)
    return 0;
  else {
    int nans = 0;
    for (int x = 0; x <= amax; ++x) {
      nans += solve(n - 1, sum - x, x - 1);
    }
    return nans;
  }
}

int main() {
  int a, b, c;
  int h = 0, ch = 0;
  while (scanf("%d,%d,%d", &a, &b, &c) != -1) {
    vector<int> v{a, b, c};
    a = v[0];
    b = v[1];
    c = v[2];
    if (a == b)
      h++;
    if (a * a + b * b == c * c)
      ch++;
  }
  cout << ch << endl << h << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include "bits/stdc++.h"
#include <unordered_map>
#include <unordered_set>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

int solve(int n, int sum, int amax) {
  if (n == 0) {
    if (sum == 0) {
      return 1;
    } else {
      return 0;
    }
  } else if (amax * n < sum || 0 * n > sum)
    return 0;
  else {
    int nans = 0;
    for (int x = 0; x <= amax; ++x) {
      nans += solve(n - 1, sum - x, x - 1);
    }
    return nans;
  }
}

int main() {
  int a, b, c;
  int h = 0, ch = 0;
  while (scanf("%d,%d,%d", &a, &b, &c)) {
    vector<int> v{a, b, c};
    sort(v.begin(), v.end());
    a = v[0];
    b = v[1];
    c = v[2];
    if (a == b)
      h++;
    if (a * a + b * b == c * c)
      ch++;
  }
  cout << ch << endl << h << endl;
  return 0;
}
Problem p00032 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string>
#include <vector>
#define p(n) pow(n, 2)
using namespace std;
int main() {
  int a, b, c, rhom = 0, rect = 0;
  while (scanf("%d,%d,%d", &a, &b, &c) != EOF) {
    if (p(a) + p(b) == p(c))
      rect++;
    if (a == b)
      rhom++;
  }
  cout << rect << endl << rhom << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string>
#include <vector>
#define p(n) pow(n, 2)
using namespace std;
int main() {
  int a, b, c, rhom = 0, rect = 0;
  while (scanf("%d,%d,%d", &a, &b, &c)) {
    if (p(a) + p(b) == p(c))
      rect++;
    if (a == b)
      rhom++;
  }
  cout << rect << endl << rhom << endl;
  return 0;
}
Problem p00032 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int a, b, c;
  int ca = 0, cb = 0;
  while (scanf("%d, %d, %d", &a, &b, &c) + 1) {
    if ((a * a) + (b * b) == c * c) {
      ca++;
    }

    if (a == b) {
      cb++;
    }
  }
  printf("%d\\n%d\\n", ca, cb);
  return 0;
}

Error: TLE

Fixed submission:

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
  int a, b, c;
  int co = 0, cp = 0;
  while (scanf("%d,%d,%d", &a, &b, &c)) {
    if ((a * a) + (b * b) == c * c) {
      co++;
    }
    if (a == b && a + b > c) {
      cp++;
    }
    cout << co << "\\n" << cp << endl;
  }
  return 0;
}
Problem p00032 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

/* http://rose.u-aizu.ac.jp/onlinejudge/ProblemSet/description.jsp?id=0032&lang=jp
 */

int main(void) {
  int alpha = 0;
  int beta = 0; /*Óa,Ób,Îpüc*/
  int charley = 0;
  int rect = 0; /*·û`Ì*/
  int rhom = 0; /*Ðµ`Ì*/

  while (1) {
    if (scanf("%d", &alpha) ==
        EOF) /* EOFðüÍ·éÉÍACtrl+Z */
      break;
    scanf(",%d", &beta);
    scanf(",%d", &charley);

    if (charley * charley == alpha * alpha + beta * beta)
      rect++;

    if (alpha == beta)
      rhom++;
  }

  printf("%d\\n", rect);
  printf("%d\\n", rhom);

  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main(void) {
  int alpha = 1;
  int beta = 0; /*Óa,Ób,Îpüc*/
  int charley = 0;
  int rect = 0; /*·û`Ì*/
  int rhom = 0; /*Ðµ`Ì*/

  while (alpha != 0) {
    scanf("%d", &alpha);
    scanf(",%d", &beta);
    scanf(",%d", &charley);

    if (charley * charley == alpha * alpha + beta * beta && alpha != 0)
      rect++;

    if (alpha == beta && alpha != 0)
      rhom++;
  }

  printf("%d\\n", rect);
  printf("%d\\n", rhom);

  return 0;
}