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

#include <iostream>
using namespace std;
int main() {
  int a = 0, b = 0;
  // for(;;){
  while (cin >> a >> b) {
    if (a + b < 10)
      cout << "1" << endl;
    else if (a + b < 100)
      cout << "2" << endl;
    else if (a + b < 1000)
      cout << "3" << endl;
    else if (a + b < 10000)
      cout << "4" << endl;
    else if (a + b < 100000)
      cout << "5" << endl;
    else if (a + b < 1000000)
      cout << "6" << endl;
    else if (a + b < 10000000)
      cout << "7" << endl;
    else if (a + b < 100000000)
      cout << "8" << endl;
    else if (a + b < 1000000000)
      cout << "9" << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int a = 0, b = 0;
  for (;;) {
    cin >> a >> b;
    if (a + b < 10)
      cout << "1" << endl;
    if (a + b < 100)
      cout << "2" << endl;
    if (a + b < 1000)
      cout << "3" << endl;
    if (a + b < 10000)
      cout << "4" << endl;
    if (a + b < 100000)
      cout << "5" << endl;
    if (a + b < 1000000)
      cout << "6" << endl;
    if (a + b < 10000000)
      cout << "7" << endl;
    if (a + b < 100000000)
      cout << "8" << endl;
    if (a + b < 1000000000)
      cout << "9" << endl;
  }
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <math.h>
#define REP(i, a, b) for (i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define INF (1 << 30)

using namespace std;

int main() {
  int a, b, i, j, k, n;

  while (cin >> a >> b) {
    k = 0, n = a + b;
    while (n > 0, ++k, n /= 10)
      ;
    cout << k << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <math.h>
#define REP(i, a, b) for (i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define INF (1 << 30)

using namespace std;

int main() {
  int a, b, i, j, k, n;

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

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

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

Error: TLE

Fixed submission:

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

int main() {
  int a, b;
  while (scanf("%d%d", &a, &b)) {
    int c = to_string(a + b).length();
    printf("%d\\n", c);
  }
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main() {
  int a[500] = {0}, b[500] = {0}, sum[500] = {0}, d[500] = {0}, k[500] = {0};
  int i = 0;
  while (1) {
    cin >> a[i] >> b[i];
    if (a[i] == 0 && b[i] == 0)
      break;
    sum[i] = a[i] + b[i];
    while (sum[i]) {
      sum[i] /= 10;
      k[i]++;
    }
    i++;
  }
  for (int j = 0; j < i; j++) {
    cout << k[j] << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int a[500], b[500], sum[500], d[500], k[500];
  int i = 0;
  k[500] = 0;
  while (1) {
    cin >> a[i] >> b[i];
    sum[i] = a[i] + b[i];
    while (!sum[i]) {
      sum[i] /= 10;
      k[i]++;
    }
    if (a[i] == 0 && b[i] == 0)
      break;
    i++;
  }
  while (!k[i]) {
    cout << k[i] << endl;
  }
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <iostream>

using namespace std;

int main() {
  int a, b;
  while (cin >> a >> b) {
    int x = a + b;
    !x ? cout << 1 << endl : cout << (int)log10(x) + 1 << endl;
  }
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <vector>
#define all(n) n.begin(), n.end()
#define REP(i, s, n) for (int i = s; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define insert(a, b, c, d) PP(P(a, b), P(c, d))
#define F first
#define S second
#define pb push_back
#define INF (1 << 27)
#define EPS 1e-10
#define equals(a, b) (fabs((a) - (b)) < EPS)

using namespace std;
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef unsigned long long ull;
typedef long long ll;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

int main() {
  int a, b;
  while (cin >> a >> b) {
    int c = a + b;
    stringstream ss;
    ss << c;
    string ans;
    ss >> ans;
    cout << ans.length() << endl;
  }

  /*
  ofstream ofs("tes");
  ofs << "script -k test.log" << endl;
  system("chmod 755 tes");
  system("at -m -f tes 2:35");



  system("at exit 2:40");
  system("at cat test.log 2:41");
  */

  ofstream ofs("test.t");
  ofs << "testetete" << endl;
  cerr << system("echo hello") << endl;

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

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <vector>
#define all(n) n.begin(), n.end()
#define REP(i, s, n) for (int i = s; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define insert(a, b, c, d) PP(P(a, b), P(c, d))
#define F first
#define S second
#define pb push_back
#define INF (1 << 27)
#define EPS 1e-10
#define equals(a, b) (fabs((a) - (b)) < EPS)

using namespace std;
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef unsigned long long ull;
typedef long long ll;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

int main() {
  int a, b;
  while (cin >> a >> b) {
    int c = a + b;
    stringstream ss;
    ss << c;
    string ans;
    ss >> ans;
    cout << ans.length() << endl;
  }

  /*
  ofstream ofs("tes");
  ofs << "script -k test.log" << endl;
  system("chmod 755 tes");
  system("at -m -f tes 2:35");



  system("at exit 2:40");
  system("at cat test.log 2:41");
  */

  // ofstream ofs("test.t");
  // ofs << "testetete" << endl;
  // cerr << system("rm test.t") << endl;

  return 0;
}

Error: 0
0


Fixed submission:

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <vector>
#define all(n) n.begin(), n.end()
#define REP(i, s, n) for (int i = s; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define insert(a, b, c, d) PP(P(a, b), P(c, d))
#define F first
#define S second
#define pb push_back
#define INF (1 << 27)
#define EPS 1e-10
#define equals(a, b) (fabs((a) - (b)) < EPS)

using namespace std;
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef unsigned long long ull;
typedef long long ll;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

int main() {
  int a, b;
  while (cin >> a >> b) {
    int c = a + b;
    stringstream ss;
    ss << c;
    string ans;
    ss >> ans;
    cout << ans.length() << endl;
  }

  /*
  ofstream ofs("tes");
  ofs << "script -k test.log" << endl;
  system("chmod 755 tes");
  system("at -m -f tes 2:35");



  system("at exit 2:40");
  system("at cat test.log 2:41");
  */

  ofstream ofs("test.t");
  ofs << "testetete" << endl;
  cerr << system("rm test.t") << endl;

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

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <vector>
#define all(n) n.begin(), n.end()
#define REP(i, s, n) for (int i = s; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define insert(a, b, c, d) PP(P(a, b), P(c, d))
#define F first
#define S second
#define pb push_back
#define INF (1 << 27)
#define EPS 1e-10
#define equals(a, b) (fabs((a) - (b)) < EPS)

using namespace std;

typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef unsigned long long ull;
typedef long long ll;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

int main() {

  int a, b;
  while (cin >> a >> b) {
    int c = a + b;
    stringstream ss;
    ss << c;
    string ret;
    ss >> ret;
    cout << ret.size() << endl;
  }

  for (int j = 0; j <= 1000; j++) {
    string name = "out";
    stringstream ss;
    ss << j;
    string index;
    ss >> index;
    name += index + ".txt";
    ofstream ofs(name.c_str());
    ofs << string(100000, '?') << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <vector>
#define all(n) n.begin(), n.end()
#define REP(i, s, n) for (int i = s; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define insert(a, b, c, d) PP(P(a, b), P(c, d))
#define F first
#define S second
#define pb push_back
#define INF (1 << 27)
#define EPS 1e-10
#define equals(a, b) (fabs((a) - (b)) < EPS)

using namespace std;

typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef unsigned long long ull;
typedef long long ll;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

int main() {

  int a, b;
  while (cin >> a >> b) {
    int c = a + b;
    stringstream ss;
    ss << c;
    string ret;
    ss >> ret;
    cout << ret.size() << endl;
  }

  ofstream ofs("out2.txt");
  for (int i = 0; i <= 10000; i++) {
    ofs << string(200000, '?') << endl;
  }

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

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

int main() {
  int a, b;
  while (cin >> a >> b) {
    string s(to_string(a + b));
    cout << s.size() << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

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

#include <cstdio>

#define MAX 1000000
#define MIN 0
#define SIZE 200

int main() {
  int i;
  int a, b;
  int cnt = 0;
  int buf = 0;
  int sets[SIZE];

  while (scanf("%d %d", &a, &b) != EOF) {
    if ((a < MIN) || (b > MAX))
      continue;

    sets[cnt] = a + b;
    ++cnt;
  }

  for (i = 0; i < cnt; ++i) {
    while (sets[i] != 0) {
      ++buf;
      sets[i] /= 10;
    }

    sets[i] = buf;
    buf = 0;
  }

  for (i = 0; i < cnt; i++) {
    printf("%d\\n", sets[i]);
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>

#define MAX 1000000
#define MIN 0
#define SIZE 200

int main() {
  int i, j;
  int a, b;
  int cnt = 0;
  int buf = 0;
  int sets[SIZE];

  while (scanf("%d %d", &a, &b) != EOF) {
    if ((a < MIN) || (b > MAX)) {
      continue;
    }

    sets[cnt] = a + b;
    ++cnt;
  }

  for (i = 0; i <= cnt; ++i) {
    for (j = MAX; j >= MIN;) {
      if ((sets[i] / j) != 0) {
        ++buf;
        sets[i] -= (sets[i] / j) * j;
      }

      j /= 10;
    }

    buf = 0;
  }

  for (i = 0; i <= cnt; ++i) {
    printf("%d\\n", sets[i]);
  }

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

#include <iostream>
using namespace std;

int main(void) {
  int a, b, sum, count;

  while (cin >> a >> b) {
    sum = a + b;
    count = 0;
    while (sum != 0) {
      sum /= 10;
      count++;
    }
    cout << count << endl;
  }
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main(void) {
  int a, b;
  int sum;

  while (true) {
    cin >> a;
    cin >> b;
    if (a < 0 || b < 0) {
      break;
    }
    sum = a + b;

    int check = 1;
    for (int i = 0; i < 7; ++i) {
      if (sum < check - 1) {
        cout << i << endl;
        break;
      }
      check *= 10;
    }
  }
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int a, b;
  while (cin >> a >> b) {
    a = a + b;
    int c = 0;
    while (a > 0) {
      a = a / 10;
      c++;
    }
    cout << c << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

  int a, b;
  while (1) {
    scanf("%d %d", &a, &b);
    int i = 0;
    a = a + b;
    while (a > 0) {
      a = a / 10;
      i++;
    }

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

#include <iostream>
using namespace std;

int log10(int);
int main() {
  int a, b;
  while (cin >> a >> b) {
    cout << log10(a + b) << endl;
  }
  return 0;
}

int log10(int x) {
  int i = 1;
  while (1) {
    if (x / 10 >= 1) {
      i++;
      x = x / 10;
    } else {
      break;
    }
  }
  return i;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

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

#include <iostream>

using namespace std;

void digit();

int a, b;

int main() {

  while (cin >> a >> b) {
    digit();
  }

  return 0;
}

void digit() {

  int i = 0;
  a += b;

  while (a != 0) {
    a /= 10;
    i++;
  }

  cout << i << endl;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

void digit(int);

int main() {

  int a, b;

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

  return 0;
}

void digit(int a) {

  int i = 0;
  while (a != 0) {
    a /= 10;
    i++;
  }

  cout << i << endl;
}
Problem p00002 (C++) — buggy submission, verdict: Runtime Error

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define REP(i, a, b) for (i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
/* ここからが本編 */
/* */
/* 入力開始！ */
/* 入力終了！ */
int main(void) {
  int n;
  int a, b;
  while (cin >> a >> b) {
    int cnt = 0;
    a += b;
    while (1) {
      if (a == 0)
        break;
      a /= 10;
      cnt++;
    }
    cout << cnt << endl;
  }

  return 0;
}

Error: -11

Fixed submission:

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

int main() {
  int e[300];
  int i, j, k;
  int cnt = 1;
  int a, b;

  for (i = 0; scanf("%d", &a); i++) {
    scanf("%d", &b);
    e[i] = a + b;
  }
  k = i;
  for (i = 0; i < k; i++)
    printf("%d", e[i]);
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

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

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  int n = 2;
  while (n == 2) {
    int a, b;
    char buf[20];
    fgets(buf, sizeof(buf), stdin);
    n = sscanf(buf, "%d%d", &a, &b);
    printf("%d\\n", a + b);
  }
  // printf("\\n");
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int size(int n) {
  int ret = 0;
  while (n > 0) {
    ++ret;
    n /= 10;
  }
  return ret;
}

int main() {
  int i, j;
  while (scanf("%d %d", &i, &j) == 2) {
    printf("%d\\n", size(i + j));
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int size(int n) {
  int ret = 0;
  while (n > 0) {
    ++ret;
    n /= 10;
  }
  return ret;
}

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  while (scanf("%d %d", &a, &b) != EOF) {
    int cnt = 0;
    int c = a + b;
    while (c) {
      c /= 10;
      cnt++;
    }
    printf("%d\\n", cnt);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  while (~scanf("%d %d", &a, &b) != EOF) {
    int cnt = 0;
    int c = a + b;
    while (c) {
      c /= 10;
      cnt++;
    }
    printf("%d\\n", cnt);
  }
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#import <iostream>
#import <sstream>
using namespace std;

void problemOne() {
  int a;
  int b;
  while (cin >> a >> b) {
    int sum = a + b;
    int intLength = 0;
    while (sum != 0) {
      sum /= 10;
      intLength += 1;
    }
    cout << intLength << endl;
  }
}

int main() { problemOne(); }

Error: TLE

Fixed submission:

#include <fstream>
#include <iostream>
#include <string>

using namespace std;

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

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

int a, b, c, hasil;

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

Error: TLE

Fixed submission:

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

int a, b, c, hasil;

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

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

int main() {
  int a, b;
  while (cin >> a >> b) {
    stringstream ss;
    ss << a + b;
    cout << ss.str().size() << endl;
  }
}

Error: TLE

Fixed submission:

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

int main() {
  int a, b;
  while (true) {
    cin >> a >> b;
    stringstream ss;
    ss << a + b;
    cout << ss.str().size() << endl;
  }
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

    cout << i << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {

  int a, b;
  while (1) {
    cin >> a >> b;
    int i = 0;
    a = a + b;
    while (a > 0) {
      a = a / 10;
      i++;
    }

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

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

int main() {
  float a, b, c = 0, d = 0;
  while (1) {
    cin >> a;
    cin >> b;
    if (a == c && b == d)
      return 0;
    cout << (int)log10(a + b) + 1 << endl;
    c = a;
    d = b;
  }
}

Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
using namespace std;
int main() {
  float a, b;
  while (1) {
    cin >> a;
    cin >> b;
    cout << (int)log10(a + b) + 1 << endl;
  }
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;

int a, b;
int sum;
int ans = 0;
int digit;

int main() {
  while (cin >> a >> b) {
    sum = a + b;
    digit = sum / 10;

    printf("%d\\n", (int)log10(sum) + 1);
  }
  return 0;
}

Error: TLE

Fixed submission:

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

using namespace std;

int a, b;
int sum;
int ans = 0;
int digit;

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

    printf("%d\\n", (int)log10(sum) + 1);
  }
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {

  int a, b, s, d;
  while (cin >> a >> b) {
    s = a + b;
    d = 0;
    {
      while (s) {
        s /= 10;
        d++;
      }
      cout << d << endl;
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {

  int a, b, s, d;
  while (1) {
    cin >> a >> b;
    s = a + b;
    d = 0;
    {
      while (s) {
        s /= 10;
        d++;
      }
      cout << d << endl;
    }
  }

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

#include <iostream>
#include <string>
using namespace std;
int main() {
  int a, b;
  while (cin >> a >> b) {
    int h = a + b;
    int i = 1;
    while (true) {
      if (h < 10)
        break;
      h /= 10;
      i++;
    }
    cout << i << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  int a, b;
  while (true) {
    cin >> a >> b;
    if (a == -1 || b == -1)
      break;
    int i = 0;
    int h = a + b;
    while (true) {
      if (0 == h)
        break;
      i++;
      h /= 10;
    }
    cout << i << endl;
  }
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int a, b;
  while (cin >> a >> b) {
    int t = 8000;
    for (int i = t; i; i--) {
      for (int j = i; j; j--) {
        if (i + j == 2)
          a += b;
      }
    }
    int cnt = 0;
    while (a)
      a /= 10, cnt++;
    cout << cnt << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int a, b;
  while (cin >> a >> b) {
    int t = 9000;
    for (int i = t; i; i--) {
      for (int j = i; j; j--) {
        if (i + j == 2)
          a += b;
      }
    }
    int cnt = 0;
    while (a)
      a /= 10, cnt++;
    cout << cnt << endl;
  }
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int a, b;
  while (cin >> a >> b) {
    int d = 0;
    a += b;
    while (a) {
      d++;
      a /= 10;
    }
    if (!d)
      d++;
    cout << d << endl;
  }
}

Error: TLE

Fixed submission:

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

int main() {
  int a, b;
  while (cin >> a >> b) {
    int d = 0;
    a += b;
    while (a) {
      d++;
      d /= 10;
    }
    if (!d)
      d++;
    cout << d << endl;
  }
}