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

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, s, e) for (int i = int(s); i != int(e); i++)
#define REP(i, e) for (int i = 0; i != int(e); i++)
#define FORIT(i, A) for (auto i : A)
#define ISEQ(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << endl
#define SZ(x) ((int)(x).size())

int main(int argc, char const *argv[]) {

  int a, b;
  while (scanf("%d %d", &a, &b) != EOF) {
    int sum = a + b;
    int digit = 0;
    while (sum) {
      digit++;
      sum /= 10;
    }
    printf("%d\\n", digit);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, s, e) for (int i = int(s); i != int(e); i++)
#define REP(i, e) for (int i = 0; i != int(e); i++)
#define FORIT(i, A) for (auto i : A)
#define ISEQ(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << endl
#define SZ(x) ((int)(x).size())

int main(int argc, char const *argv[]) {

  int a, b;
  while (scanf("%d %d", &a, &b) != EOF) {
    int sum = a + b;
    int digit = 1;
    while (sum / 10)
      digit++;
    printf("%d\\n", digit);
  }
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;

int main(void) {

  int a, b, sum = 0, count;

  for (; cin >> a >> b;) { //??°????????????????????°?????????
    count = 0;
    sum = a + b;
    if (sum == 0) {
      cout << 0 << endl;
    } else if (sum != 0) {

      while (sum > 9) {

        sum /= 10;
        count++;
      }
      //?????°???count?????°
      cout << count + 1 << endl;
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;

int main(void) {

  int a, b, sum = 0, count;

  for (;;) { //??°????????????????????°?????????
    count = 0;
    cin >> a >> b;
    sum = a + b;
    if (a == NULL || !a)
      break;

    do {
      sum /= 10;
      count++;

    } while (sum / 10 != 0);
    //?????°???count?????°
    cout << count + 1 << endl;
  }
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>

using namespace std;

int main() {

  int a, b;
  string input;
  int size = 0;
  int count = 0;

  while (cin >> a >> b) {
    b += a;
    input = to_string(b);
    size = input.size();
    cout << size << endl;
    count++;
    if (count == 199) {
      break;
    }
  }
}

Error: -11

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

int main() {

  int a, b;
  string input;
  int size[3];
  int i = 0;
  int count = 0;
  // cout << "input two numbers" << endl;
  for (i = 0; i < 200; i++) {
    cin >> a >> b;
    b += a;
    input = to_string(b);
    size[i] = input.size();
    count++;
  }
  for (i = 0; i < count; i++) {
    cout << size[i] << endl;
  }
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int getDigitNumber(int n) { return n > 0 ? 1 + getDigitNumber(n / 10) : 0; }

int main(int argc, char const *argv[]) {
  while (true) {
    int a, b;
    cin >> a >> b;
    if (cin.eof()) {
      break;
    }
    cout << getDigitNumber(a + b) << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int getDigitNumber(int n) { return n > 0 ? 1 + getDigitNumber(n / 10) : 0; }

int main(int argc, char const *argv[]) {
  while (true) {
    int a, b;
    cin >> a >> b;
    cout << getDigitNumber(a + b) << endl;
  }
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <math.h>
#include <stdlib.h>

void listen_nums(int &a, int &b);

int calc_digit(const int num);

int main() {
  int a, b;

  for (; 1;) {
    listen_nums(a, b);
    int sum = a + b;
    std::cout << calc_digit(sum) << std::endl;
  }

  return 0;
}

void listen_nums(int &a, int &b) {
  using namespace std;
  cin >> a >> b;

  if (cin.eof()) {
    exit(0);
  }
}

int calc_digit(const int num) { return (int)log10((double)num) + 1; }


Error: TLE

Fixed submission:

#include <iostream>
#include <math.h>

void listen_nums(int &a, int &b);

int calc_digit(const int num);

int main() {
  int a, b;

  for (; 1;) {
    listen_nums(a, b);
    int sum = a + b;
    std::cout << calc_digit(sum) << std::endl;
  }

  return 0;
}

void listen_nums(int &a, int &b) {
  using namespace std;
  cin >> a >> b;
}

int calc_digit(const int num) { return (int)log10((double)num) + 1; }
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
using namespace std;

int keta(int num) {
  int result = 1;
  while (true) {

    if (num < 10)
      return result;

    num /= 10;
    result++;
  }
}

int main() {
  int a, b, c;
  while (cin >> a >> b) {
    printf("%d\\n", keta(a + b));
  }

  // system("pause");
  return 0;
}


Error: TLE

Fixed submission:

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

int getKeta(int num) {
  int result = 0;

  for (;;) {
    result++;
    if (num < 10)
      break;
    num /= 10;
  }
  return result;
}

int main() {

  int a, b;
  int ans[200];

  for (;;) {
    cin >> a >> b;

    a += b;
    printf("%d\\n", getKeta(a));
  }

  // system("pause");
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int stringers_number(int a) { return int(log10(a) + 1); }

int extract_the_number(char *n1, char *n2) {
  int data_size1 = 0;
  int data_size2 = 0;
  for (data_size1 = 0; !(*(n1 + data_size1) == '\\0'); data_size1++) {
  }
  for (data_size2 = 0; !(*(n2 + data_size2) == '\\0'); data_size2++) {
  }
  /*int data_size1 = sizeof(n1) / sizeof(n1[0]);
  int data_size2 = sizeof(n2) / sizeof(n2[0]);*/
  /*for (i=0;i<=data_size-1;i++)
          if (a[i] == ' ')
                  break; */
  int a1 = 0;
  int j = 0;
  for (j = 0; j <= data_size1 - 1; j++) {
    int j_keta = int(*(n1 + (sizeof n1[0]) * j)) - 48;
    a1 = a1 + (pow(10, (data_size1 - j - 1))) * j_keta;
  }
  int a2 = 0;
  int k = 0;
  for (k = 0; k <= data_size2 - 1; k++) {
    int k_keta = int(*(n2 + (sizeof n2[0]) * k)) - 48;
    a2 = a2 + (pow(10, (data_size2 - k - 1))) * k_keta;
  }
  return a1 + a2;
}

int main() {
  char n1[100];
  char n2[100];
  while (cin >> n1 && cin >> n2) {
    /*cin >> n1;
    cin >> n2;*/
    cout << stringers_number(extract_the_number(n1, n2)) << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int stringers_number(int a) { return int(log10(a) + 1); }

int extract_the_number(char *n1, char *n2) {
  int data_size1 = 0;
  int data_size2 = 0;
  for (data_size1 = 0; !(*(n1 + data_size1) == '\\0'); data_size1++) {
  }
  for (data_size2 = 0; !(*(n2 + data_size2) == '\\0'); data_size2++) {
  }
  /*int data_size1 = sizeof(n1) / sizeof(n1[0]);
  int data_size2 = sizeof(n2) / sizeof(n2[0]);*/
  /*for (i=0;i<=data_size-1;i++)
          if (a[i] == ' ')
                  break; */
  int a1 = 0;
  int j = 0;
  for (j = 0; j <= data_size1 - 1; j++) {
    int j_keta = int(*(n1 + (sizeof n1[0]) * j)) - 48;
    a1 = a1 + (pow(10, (data_size1 - j - 1))) * j_keta;
  }
  int a2 = 0;
  int k = 0;
  for (k = 0; k <= data_size2 - 1; k++) {
    int k_keta = int(*(n2 + (sizeof n2[0]) * k)) - 48;
    a2 = a2 + (pow(10, (data_size2 - k - 1))) * k_keta;
  }
  return a1 + a2;
}

int main() {
  char n1[100];
  char n2[100];
  while (1) {
    cin >> n1;
    cin >> n2;
    cout << stringers_number(extract_the_number(n1, n2)) << endl;
  }
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int count = 0;
  int digit_num;
  int a[200], b[200];
  int sum;
  while (cin >> a[count] >> b[count]) {
    if (a[count] >= 0 && a[count] <= 1000000)
      if (b[count] >= 0 && b[count] <= 1000000) {
        sum = a[count] + b[count];
        digit_num = 1;
        while ((sum / 10) != 0) {
          digit_num++;
          sum = sum / 10;
        }
        cout << digit_num << endl;
        count++;
        if (count > 200)
          break;
      }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int count = 0;
  int digit_num;
  int a[200], b[200];
  int sum;
  while (1) {
    cin >> a[count] >> b[count];
    if (a[count] >= 0 && a[count] <= 1000000)
      if (b[count] >= 0 && b[count] <= 1000000) {
        sum = a[count] + b[count];
        digit_num = 1;
        while ((sum / 10) != 0) {
          digit_num++;
          sum = sum / 10;
        }
        cout << digit_num << endl;
        count++;
        if (count > 200)
          break;
      }
  }
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {

  int a, b;
  while (cin >> a >> b) {
    int ans = 0;
    a = a + b;

    while (a > 0) {
      a = a / 10;
      ++ans;
    }
    cout << ans << '\\n';
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {

  int a;
  int b;

  while (1) {
    cin >> a >> b;
    a += b;
    b = 0;
    while (1) {
      a /= 10;
      ++b;
      if (a <= 0) {
        break;
      }
    }
    cout << b << endl;
  }
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
using namespace std;
int a, b;
int cnt, ans;
int count(int s) {
  if (s / 10 == 0)
    return cnt;
  else {
    cnt++;
    count(s / 10);
  }
}
int main() {
  while (scanf("%d %d", &a, &b) != EOF) {
    cnt = 1;
    ans = count(a + b);
    printf("%d\\n", ans);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
using namespace std;
int a, b;
int cnt, ans;
int count(int s) {
  if (s / 10 == 0)
    return cnt;
  else {
    cnt++;
    count(s / 10);
  }
}
int main() {
  while (scanf("%d %d", &a, &b)) {
    cnt = 1;
    ans = count(a + b);
    printf("%d\\n", ans);
  }
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int a, b, ans;
  while (cin >> a >> b) {
    ans = 0;
    a = a + b;
    while (a > 0) {
      ans++;
      a /= 10;
    }
    cout << ans << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <math.h>
using namespace std;
int main() {
  int a, b, ans;
  while (cin >> a >> b) {
    ans = 0;
    a = a + b;
    for (a; a > 10; a / 10) {
      ans++;
    }
    cout << ans + 1 << endl;
  }
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main() {
  int a;
  int b;
  while (scanf("%d %d", &a, &b) != EOF) {
    int result = a + b;
    int digit = 0;
    while (result != 0) {
      digit++;
      result /= 10;
    }

    printf("%d\\n", digit);
  }
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  int a;
  int b;
  while (scanf("%d %d", &a, &b)) {
    int result = a + b;
    int digit = 0;
    while (result != 0) {
      digit++;
      result /= 10;
    }

    printf("%d\\n", digit);
  }
}
Problem p00002 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  int i, j;
  while (cin >> i >> j) {
    i += j;
    int count = 0;

    while (i > 0) {
      i = i / 10;
      count++;
    }

    cout << count << endl;
  }

  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
using namespace std;

int datas[2][200];
int datanum;

int sum[200];
int solve[200];

int main() {
  cin >> datanum;

  for (int i = 0; i < datanum; i++) {
    cin >> datas[0][i];
    cin >> datas[1][i];

    sum[i] = datas[0][i] + datas[1][i];
  }

  for (int i = 0; i < datanum; i++) {
    for (int j = 1; j < 7; j++) {
      if ((sum[i] / 10 * j) < 10) {
        solve[i] = j + 1;
        j = 10;

        cout << solve[i] << "\\n";
      }
    }
  }
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <cstdio>

int main() {
  int a, b;
  while (scanf("%d %d", &a, &b) != EOF) {
    printf("%d\\n", (int)log10(a + b) + 1);
  }
  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  int a, b;
  while (scanf("%d %d", &a, &b)) {
    printf("%d\\n", (int)log10(a + b) + 1);
  }
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <math.h>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
#define ll long long

using namespace std;

string Num2Str(int num) {
  stringstream ss;
  ss << num;
  return ss.str();
}

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

  int a, b;
  string s;
  // code
  while (cin >> a >> b) {
    s = Num2Str(a + b);
    cout << s.size() << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <math.h>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
#define ll long long

using namespace std;

string Num2Str(int num) {
  stringstream ss;
  ss << num;
  return ss.str();
}

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

  int a, b;
  string s;
  // code
  while (true) {
    cin >> a >> b;
    s = Num2Str(a + b);
    cout << s.size() << endl;
  }

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

#include <iostream>
using namespace std;

int hoge(int sum, int cnt) {
  if (sum / 10 <= 9)
    return cnt;
  else
    return hoge(sum / 10, ++cnt);
}

int main() {
  for (;;) {
    int a, b;
    cin >> a >> b;
    if (cin.fail())
      break;
    if (a + b < 10)
      cout << 1 << endl;
    else
      cout << hoge(a + b, 2) << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int hoge(int sum, int cnt) {
  if (sum / 10 <= 9)
    return cnt;
  else
    return hoge(sum / 10, ++cnt);
}

int main() {
  while (true) {
    int a, b;
    cin >> a >> b;
    if (a + b < 10)
      cout << 1 << endl;
    else
      cout << hoge(a + b, 2) << endl;
  }
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <iostream>

using namespace std;

int main() {

  int a, b;

  while (cin >> a >> b) {
    a = log10(a + b);
    cout << a + 1 << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main(void) {

  int a, b;

  while (1) {

    cin >> a >> b;
    a += b;

    int cnt = 0;
    while (a) {
      cnt++;
      a /= 10;
    }
    cout << cnt << endl;
  }
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
int main() {
  int a, b, c;
  while (scanf("%d %d", &a, &b) != EOF) {
    c = a + b;
    if (c < 10)
      printf("1\\n");
    else if (c < 100)
      printf("2\\n");
    else if (c < 1000)
      printf("3\\n");
    else if (c < 10000)
      printf("4\\n");
    else if (c < 100000)
      printf("5\\n");
    else if (c < 1000000)
      printf("6\\n");
    else if (c < 10000000)
      printf("7\\n");
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
int main() {
  int x, y, i;
  for (;;) {
    scanf("%d %d", &x, &y);
    if ((x + y) < 10)
      printf("1\\n");
    else if ((x + y) < 100)
      printf("2\\n");
    else if ((x + y) < 1000)
      printf("3\\n");
    else if ((x + y) < 10000)
      printf("4\\n");
    else if ((x + y) < 100000)
      printf("5\\n");
    else if ((x + y) < 1000000)
      printf("6\\n");
    else
      printf("7\\n");
  }
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
int main() {
  int a, b, c, count = 0;
  while (scanf("%d %d", &a, &b) != EOF) {
    count = 0;
    c = a + b;
    while (1) {
      c = c / 10;
      count++;
      if (c == 0)
        break;
    }
    printf("%d\\n", count);
  }
}

Error: TLE

Fixed submission:

#include <stdio.h>
int main() {
  while (1) {
    int a, b, c, count = 0;
    scanf("%d %d", &a, &b);
    c = a + b;
    while (1) {
      c = c / 10;
      count++;
      if (c == 0)
        break;
    }
    printf("%d\\n", count);
  }
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  long long int a, b, c;
  int x;
  bool flg = true;

  while (1) {
    cin >> a;
    if (cin.eof())
      break;
    cin >> b;

    c = a + b;

    x = 1;
    flg = true;
    while (flg) {
      if ((c = c / 10) > 0)
        x++;
      else
        flg = false;
    }
    cout << x << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  long long int a, b, c;
  int x;
  bool flg = true;

  while (1) {
    cin >> a;
    if (a == 0)
      break;
    cin >> b;

    c = a + b;

    x = 1;
    flg = true;
    while (flg) {
      if ((c = c / 10) > 0)
        x++;
      else
        flg = false;
    }
    cout << x << endl;
  }
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int digit(int x) {
  int res = 0;
  while (x != 0) {
    res++;
    x /= 10;
  }
  return res;
}

int main(void) {
  int a, b;
  while (cin >> a >> b) {
    cout << digit(a + b) << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int digit(int x) {
  int res = 0;
  while (x != 0) {
    res++;
    x /= 10;
  }
  return res;
}

int main(void) {
  int a, b;
  while (true) {
    cin >> a >> b;
    cout << digit(a + b) << endl;
  }
}
Problem p00002 (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;
template <class T> using Table = vector<vector<T>>;
const ld eps = 1e-9;

//// < "D:\\D_Download\\Visual Studio
///2015\\Projects\\programing_contest_c++\\Debug\\a.txt"

int main() {
  string st;
  while (getline(cin, st)) {
    string a, b;
    a = st.substr(0, st.find(" "));
    b = st.substr(st.find(" ") + 1);
    int aa = stoi(a);
    int bb = stoi(b);

    cout << to_string(aa + bb).size() << 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;
template <class T> using Table = vector<vector<T>>;
const ld eps = 1e-9;

//// < "D:\\D_Download\\Visual Studio
///2015\\Projects\\programing_contest_c++\\Debug\\a.txt"

int main() {
  while (1) {
    string a, b;
    cin >> a >> b;
    cout << a.size() + b.size() << endl;
  }
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <iostream>

using namespace std;

int main(void) {

  int a, b;
  int ans;

  while (cin >> a >> b) {
    ans = log10(a + b) + 1;
    cout << ans << endl;
  }
}


Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>

using namespace std;

int main(void) {

  int a, b;
  int ans;

  while (1) {
    cin >> a >> b;

    if (a == 0 && b == 0)
      break;

    ans = log10(a + b) + 1;
    cout << ans << endl;
  }
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <iostream>
using namespace std;
int main() {
  int a, b;
  while (cin >> a >> b) {
    int c = log10(a + b) + 1;
    cout << c << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int a, b, c;
  while (1) {
    cin >> a >> b;
    c = 10;
    for (int i = 1; i < 7; i++) {
      if (a + b < c) {
        cout << i << endl;
        break;
      } else
        c *= 10;
    }
  }
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  long int a, b, c, s;
  double r;
  while (cin >> a >> b) {
    c = a + b;
    r = log10(c) + 1;
    s = r;
    cout << s << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  while (true) {
    long int a, b;
    cin >> a >> b;
    long int c = a + b;
    double r = log10(c) + 1;
    long int s = r;
    cout << s << endl;
  }
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int a, b;

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

  return 0;
}

Error: TLE

Fixed submission:

// #include <iostream>
// using namespace std;
#include <stdio.h>
int main() {
  int a, b;

  while (scanf("%d %d", &a, &b) != EOF) {
    int c = a + b;
    int n = 1;
    while (1) {
      if (c / 10 == 0)
        break;
      n++;
    }
    printf("%d\\n", n);
    // cout << n << endl;
  }

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

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

template <class T> T input() {
  T val, val1;
  std::cin >> val >> val1;
  if (val == '\\0')
    return EOF;
  else
    return val + val1;
}

int main() {
  std::vector<int> x;
  int a, b;
  while (scanf("%d %d", &a, &b) != EOF)
    x.push_back(a + b);

  for (int i = 0; i < x.size(); ++i)
    std::cout << static_cast<int>(log10(x[i])) + 1 << std::endl;
  return 0;
}

Error: -6
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc


Fixed submission:

#include <cmath>
#include <iostream>
#include <vector>

template <class T> T input() {
  T val, val1;
  std::cin >> val >> val1;
  if (val == '\\0')
    return EOF;
  else
    return val + val1;
}

int main() {
  std::vector<int> x;
  int hoge;
  while ((hoge = input<int>()) != EOF) {
    x.push_back(hoge);
  }

  for (int i = 0; i < x.size(); ++i)
    std::cout << static_cast<int>(log10(x[i])) + 1 << std::endl;
  return 0;
}