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

#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <complex>
#include <list>
#include <stack>
#include <vector>
using namespace std;

int main() {
  bool a[1001] = {false};
  bool b[1001] = {false};
  int mm[1001] = {0};
  char tmp[100];
  int x, y;
  for (;;) {
    fgets(tmp, 100, stdin);
    if (tmp[0] < '0' || tmp[0] > '9')
      break;
    sscanf(tmp, "%d,%d", &x, &y);
    a[x] = true;
    mm[x] += 1;
  }
  for (;;) {
    if (fgets(tmp, 100, stdin) == NULL)
      break;
    sscanf(tmp, "%d,%d", &x, &y);
    b[x] = true;
    mm[x] += 1;
  }
  for (int i = 1; i < 1001; ++i) {
    if (a[i] && b[i]) {
      printf("%d %d\\n", i, mm[i]);
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <complex>
#include <list>
#include <stack>
#include <vector>
using namespace std;

int main() {
  bool a[1001] = {0};
  bool b[1001] = {0};
  int mm[1001] = {0};
  char tmp[100];
  int x, y;
  for (;;) {
    fgets(tmp, 100, stdin);
    if (tmp[0] < '0' && tmp[0] > '9')
      break;
    sscanf(tmp, "%d,%d", &x, &y);
    a[x] = 1;
    mm[x] += 1;
  }
  for (;;) {
    fgets(tmp, 100, stdin);
    if (tmp[0] < '0' && tmp[0] > '9')
      break;
    sscanf(tmp, "%d,%d", &x, &y);
    b[x] = 1;
    mm[x] += 1;
  }
  for (int i = 1; i < 1001; ++i) {
    if (a[i] && b[i]) {
      printf("%d %d\\n", i, mm[i]);
    }
  }
  return 0;
}
Problem p00065 (C++) — buggy submission, verdict: Runtime Error

#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;

typedef pair<int, int> P;

int main() {
  string b;
  priority_queue<P, vector<P>, greater<P>> pq;
  while (getline(cin, b)) {
    if (b == "") {
      break;
    }
    int a = b.find(',');
    int n1 = 0;
    for (int i = 0; i < a; i++) {
      n1 *= 10;
      n1 += (b[i] - '0');
    }
    int n2 = 1;
    P p;
    p.first = n1;
    p.second = n2;
    pq.push(p);
  }
  int v, w;
  char c;
  priority_queue<P, vector<P>, greater<P>> pqq;
  while (cin >> v >> c >> w) {
    P p;
    p.first = v;
    p.second = 1;
    pqq.push(p);
  }
  while (!pq.empty()) {
    P p = pq.top();
    pq.pop();
    while (!pq.empty() && (pq.top()).first == p.first) {
      P pp = pq.top();
      pq.pop();
      p.second += pp.second;
    }
    if (pqq.empty()) {
      break;
    }
    while (true) {
      P q = pqq.top();
      if (q.first > p.first) {
        break;
      } else {
        pqq.pop();
        while (!pqq.empty() && (pqq.top()).first == q.first) {
          P qq = pqq.top();
          pqq.pop();
          q.second += qq.second;
        }
        if (p.first == q.first) {
          cout << p.first << " " << p.second + q.second << endl;
          break;
        } else {
          if (pqq.empty()) {
            break;
          }
          while (!pqq.empty() && (pqq.top()).first < p.first) {
            pqq.pop();
          }
        }
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;

typedef pair<int, int> P;

int main() {
  string b;
  priority_queue<P, vector<P>, greater<P>> pq;
  while (getline(cin, b)) {
    if (b == "") {
      break;
    }
    int a = b.find(',');
    int n1 = 0;
    for (int i = 0; i < a; i++) {
      n1 *= 10;
      n1 += (b[i] - '0');
    }
    int n2 = 1;
    P p;
    p.first = n1;
    p.second = n2;
    pq.push(p);
  }
  int v, w;
  char c;
  priority_queue<P, vector<P>, greater<P>> pqq;
  while (cin >> v >> c >> w) {
    P p;
    p.first = v;
    p.second = 1;
    pqq.push(p);
  }
  while (!pq.empty()) {
    P p = pq.top();
    pq.pop();
    while ((pq.top()).first == p.first) {
      P pp = pq.top();
      pq.pop();
      p.second += pp.second;
    }
    P q = pqq.top();
    while (true) {
      if (q.first > p.first) {
        break;
      } else {
        pqq.pop();
        while ((pqq.top()).first == q.first) {
          P qq = pqq.top();
          pqq.pop();
          q.second += qq.second;
        }
        if (p.first == q.first) {
          cout << p.first << " " << p.second + q.second << endl;
          break;
        } else {
          while ((pqq.top()).first < p.first) {
            pqq.pop();
          }
        }
      }
    }
  }
  return 0;
}
Problem p00065 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI = 6 * asin(0.5);
typedef pair<double, double> P;
typedef complex<double> CP;
typedef long long ll;

string s;
int a[1100] = {0}, b[1100] = {0};

int main() {
  while (getline(cin, s), s.size() != 0) {
    int t1 = 0;
    rep(i, s.size()) {
      if (s[i] == ',') {
        break;
      } else {
        t1 *= 10;
        t1 += s[i] - '0';
        // cout<<t1<<endl;
      }
    }
    // cout<<t1<<endl;
    a[t1]++;
  }
  while (getline(cin, s)) {
    int t1 = 0;
    rep(i, s.size()) {
      if (s[i] == ',') {
        break;
      } else {
        t1 *= 10;
        t1 += s[i] - '0';
      }
    }
    b[t1]++;
  }

  rep(i, 1100) {
    if (a[i] && b[i]) {
      cout << i << " " << a[i] + b[i] << endl;
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI = 6 * asin(0.5);
typedef pair<double, double> P;
typedef complex<double> CP;
typedef long long ll;

string s;
int a[1100] = {0}, b[1100] = {0};

int main() {
  while (getline(cin, s), s[0] != 13) {
    int t1 = 0, t2 = 0;
    bool f = false;
    rep(i, s.size()) {
      if (f) {
      } else if (s[i] == ',') {
        break;
      } else {
        t1 *= 10;
        t1 += s[i] - '0';
        // cout<<t1<<endl;
      }
    }
    // cout<<t1<<endl;
    a[t1]++;
  }
  while (getline(cin, s)) {
    int t1 = 0, t2 = 0;
    bool f = false;
    rep(i, s.size()) {
      if (f) {
      } else if (s[i] == ',') {
        break;
      } else {
        t1 *= 10;
        t1 += s[i] - '0';
      }
    }
    b[t1]++;
  }

  rep(i, 1100) {
    if (a[i] > 0 && b[i] > 0) {
      cout << i << " " << a[i] + b[i] << endl;
    }
  }

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

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define rep(i, l, n) for (int i = l; i < n; i++)
#define rer(i, l, n) for (int i = l; i <= n; i++)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define pb(a) push_back(a)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;

vector<string> split(const string &s, char c) {
  vector<string> ret;
  stringstream ss(s);
  string t;
  while (getline(ss, t, c)) {
    ret.pb(t);
  }
  return ret;
}

int main() {
  map<int, int> m;
  set<int> s1, s2;
  bool f = 0;
  string s;
  while (getline(cin, s)) {
    if (/*s.end() - s.begin() == 1*/ s == "") {
      // o("ok");
      f = 1;
      continue;
    }
    vector<string> v = split(s, ',');
    int a = atoi(v[0].c_str());
    // o(a);
    m[a]++;
    if (!f)
      s1.insert(a);
    else
      s2.insert(a);
  }
  for (map<int, int>::iterator it = m.begin(); it != m.end(); it++) {
    // cout<<1<<endl;
    if (s1.count(it->fi) && s2.count(it->fi))
      cout << it->fi << " " << it->se << endl;
  }
}

Error: -11

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define rep(i, l, n) for (int i = l; i < n; i++)
#define rer(i, l, n) for (int i = l; i <= n; i++)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define pb(a) push_back(a)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;

vector<string> split(const string &s, char c) {
  vector<string> ret;
  stringstream ss(s);
  string t;
  while (getline(ss, t, c)) {
    ret.pb(t);
  }
  return ret;
}

int main() {
  map<int, int> m;
  set<int> s1, s2;
  bool f = 0;
  string s;
  while (getline(cin, s)) {
    if (s.end() - s.begin() == 1) {
      // o("ok");
      f = 1;
      continue;
    }
    vector<string> v = split(s, ',');
    int a = atoi(v[0].c_str());
    // o(a);
    m[a]++;
    if (!f)
      s1.insert(a);
    else
      s2.insert(a);
  }
  for (map<int, int>::iterator it = m.begin(); it != m.end(); it++) {
    // cout<<1<<endl;
    if (s1.count(it->fi) && s2.count(it->fi))
      cout << it->fi << " " << it->se << endl;
  }
}
Problem p00066 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main(void) {
  string s;
  while (true) {
    cin >> s;
    if (cin.fail())
      break;
    for (int i = 0; i < 3; ++i) {
      if (s[0 + 3 * i] == s[1 + 3 * i] && s[1 + 3 * i] == s[2 + 3 * i] &&
          s[2 + 3 * i] == 'o') {
        cout << "o" << endl;
        goto end;
      }
      if (s[0 + 3 * i] == s[1 + 3 * i] && s[1 + 3 * i] == s[2 + 3 * i] &&
          s[2 + 3 * i] == 'x') {
        cout << "x" << endl;
        goto end;
      }
    }

    for (int i = 0; i < 3; ++i) {
      if (s[0 + i] == s[3 + i] && s[3 + i] == s[6 + i] && s[6 + i] == 'o') {
        cout << "o" << endl;
        goto end;
      }
      if (s[0 + i] == s[3 + i] && s[3 + i] == s[6 + i] && s[6 + i] == 'x') {
        cout << "x" << endl;
        goto end;
      }
    }
    for (int i = 0; i < 2; ++i) {
      if (s[0 + 2 * i] == s[4] && s[4] == s[8 - 2 * i] && s[4] == 'o') {
        cout << "o" << endl;
        goto end;
      }
      if (s[0 + 2 * i] == s[4] && s[4] == s[8 - 2 * i] && s[4] == 'x') {
        cout << "x" << endl;
        goto end;
      }
    }
    cout << "d" << endl;
  end:;
    if (s[9] == EOF)
      break;
  }
  return 0;
}


Error: TLE

Fixed submission:

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

int main(void) {
  string s;
  while (true) {
    cin >> s;

    for (int i = 0; i < 3; ++i) {
      if (s[0 + 3 * i] == s[1 + 3 * i] && s[1 + 3 * i] == s[2 + 3 * i] &&
          s[2 + 3 * i] == 'o') {
        cout << "o" << endl;
        goto end;
      }
      if (s[0 + 3 * i] == s[1 + 3 * i] && s[1 + 3 * i] == s[2 + 3 * i] &&
          s[2 + 3 * i] == 'x') {
        cout << "x" << endl;
        goto end;
      }
    }

    for (int i = 0; i < 3; ++i) {
      if (s[0 + i] == s[3 + i] && s[3 + i] == s[6 + i] && s[6 + i] == 'o') {
        cout << "o" << endl;
        goto end;
      }
      if (s[0 + i] == s[3 + i] && s[3 + i] == s[6 + i] && s[6 + i] == 'x') {
        cout << "x" << endl;
        goto end;
      }
    }
    for (int i = 0; i < 2; ++i) {
      if (s[0 + 2 * i] == s[4] && s[4] == s[8 - 2 * i] && s[4] == 'o') {
        cout << "o" << endl;
        goto end;
      }
      if (s[0 + 2 * i] == s[4] && s[4] == s[8 - 2 * i] && s[4] == 'x') {
        cout << "x" << endl;
        goto end;
      }
    }
    cout << "d" << endl;
  end:;
    if (s[9] == EOF)
      break;
  }
  return 0;
}
Problem p00066 (C++) — buggy submission, verdict: Runtime Error

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#ifdef _DEBUG
#define typeof(X) std::identity<decltype(X)>::type // C++0x (for vs2010)
#else
#define typeof(X) __typeof__(X) // for gcc
#endif

using namespace std;
static const double EPS = 1e-6;
typedef long long ll;
const int MODULO = 1000000007;
const int INF = 100000000; // 1e8

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
typedef complex<double> Cd;

int t[8][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {1, 4, 7},
               {2, 5, 8}, {3, 6, 9}, {1, 5, 9}, {3, 5, 7}};

char solve(char *c) {
  for (int i = 0; i < 8; i++) {
    if (c[t[i][0] - 1] == c[t[i][1] - 1] && c[t[i][1] - 1] == c[t[i][2] - 1]) {
      if (c[t[i][0] - 1] == 's')
        continue;
      return c[t[i][0] - 1];
    }
  }
  return 'd';
}

int main() {
  char c[10];
  while (~scanf("%s", c)) {
    printf("%c\\n", solve(c));
  }
  return 0;
}

Error: -6
*** stack smashing detected ***: terminated


Fixed submission:

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#ifdef _DEBUG
#define typeof(X) std::identity<decltype(X)>::type // C++0x (for vs2010)
#else
#define typeof(X) __typeof__(X) // for gcc
#endif

using namespace std;
static const double EPS = 1e-6;
typedef long long ll;
const int MODULO = 1000000007;
const int INF = 100000000; // 1e8

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
typedef complex<double> Cd;

int t[8][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {1, 4, 7},
               {2, 5, 8}, {3, 6, 9}, {1, 5, 9}, {3, 5, 7}};

char solve(char c[9]) {
  for (int i = 0; i < 8; i++) {
    if (c[t[i][0] - 1] == c[t[i][1] - 1] && c[t[i][1] - 1] == c[t[i][2] - 1]) {
      if (c[t[i][0] - 1] == 's')
        continue;
      return c[t[i][0] - 1];
    }
  }
  return 'd';
}

int main() {
  string s[3];
  char c[10];
  while (~scanf("%s", c)) {
    scanf("%s", c + 3);
    scanf("%s", c + 6);
    printf("%c\\n", solve(c));
  }
  return 0;
}
Problem p00066 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {

  string s;

  while (cin >> s) {

    char a[3][3];
    a[0][0] = s[0];
    a[0][1] = s[1];
    a[0][2] = s[2];
    a[1][0] = s[3];
    a[1][1] = s[4];
    a[1][2] = s[5];
    a[2][0] = s[6];
    a[2][1] = s[7];
    a[2][2] = s[8];
    char S = 's';
    bool ok = false;
    for (int i = 0; i < 3; i++) {
      if (a[i][0] != S && a[i][0] == a[i][1] && a[i][1] == a[i][2]) {
        cout << a[i][0] << endl;
        ok = true;
        break;
      }
    }

    for (int j = 0; j < 3; j++) {
      if (ok)
        break;

      if (a[0][j] != S && a[0][j] == a[1][j] && a[1][j] == a[2][j]) {
        cout << a[0][j] << endl;
        ok = true;
        break;
      }
    }

    if (!ok) {
      if (a[0][0] != S && a[0][0] == a[1][1] && a[1][1] == a[2][2]) {
        cout << a[0][0] << endl;
        ok = true;
      } else if (a[0][2] != S && a[0][2] == a[1][1] && a[1][1] == a[2][0]) {
        cout << a[1][1] << endl;
        ok = true;
      }
    }

    if (!ok)
      cout << "d" << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

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

int main() {

  while (1) {
    string s;
    cin >> s;

    char a[3][3];
    a[0][0] = s[0];
    a[0][1] = s[1];
    a[0][2] = s[2];
    a[1][0] = s[3];
    a[1][1] = s[4];
    a[1][2] = s[5];
    a[2][0] = s[6];
    a[2][1] = s[7];
    a[2][2] = s[8];
    char S = 's';
    bool ok = false;
    for (int i = 0; i < 3; i++) {
      if (a[i][0] != S && a[i][0] == a[i][1] && a[i][1] == a[i][2]) {
        cout << a[i][0] << endl;
        ok = true;
        break;
      }
    }

    for (int j = 0; j < 3; j++) {
      if (ok)
        break;

      if (a[0][j] != S && a[0][j] == a[1][j] && a[1][j] == a[2][j]) {
        cout << a[0][j] << endl;
        ok = true;
        break;
      }
    }

    if (!ok) {
      if (a[0][0] != S && a[0][0] == a[1][1] && a[1][1] == a[2][2]) {
        cout << a[0][0] << endl;
        ok = true;
      } else if (a[0][2] != S && a[0][2] == a[1][1] && a[1][1] == a[2][0]) {
        cout << a[1][1] << endl;
        ok = true;
      }
    }

    if (!ok)
      cout << "d" << endl;
  }

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

#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  char data[12];
  int jadge = 0; // 0Èçø«ª¯//PÈço//2Èçx
  while (cin >> data) {
    jadge = 0;

    for (int i = 0, j = 0; i < 3; i++, j += 3) { // ¡ÉÀÔÆ«
      if (data[0 + j] == 'o' && data[1 + j] == 'o' && data[2 + j] == 'o')
        jadge = 1;
      if (data[0 + j] == 'x' && data[1 + j] == 'x' && data[2 + j] == 'x')
        jadge = 2;
      // cout << j<< endl;
    }

    // cÉÈçÔÆ«
    for (int i = 0; i < 3; i++) {
      if (data[0 + i] == 'o' && data[3 + i] == 'o' && data[6 + i] == 'o')
        jadge = 1;
      if (data[0 + i] == 'x' && data[3 + i] == 'x' && data[6 + i] == 'x')
        jadge = 2;
    }

    // ÎßÉÈçÔÆ«
    if (data[0] == 'o' && data[4] == 'o' && data[8] == 'o')
      jadge = 1;
    if (data[0] == 'x' && data[4] == 'x' && data[8] == 'x')
      jadge = 2;
    if (data[2] == 'o' && data[4] == 'o' && data[6] == 'o')
      jadge = 1;
    if (data[2] == 'x' && data[4] == 'x' && data[6] == 'x')
      jadge = 2;

    switch (jadge) {
    case 1:
      printf("o\\n");
      break;
    case 2:
      printf("x\\n");
      break;
    case 0:
      printf("d\\n");
      break;
    }
  }

  return 0;
}

Error: WA

Fixed submission:

#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  char data[9];
  int jadge = 0; // 0Èçø«ª¯//PÈço//2Èçx
  while (cin >> data) {
    jadge = 0;

    for (int i = 0, j = 0; i < 3; i++, j += 2) { // ¡ÉÀÔÆ«
      if (data[0 + j] == 'o' && data[1 + j] == 'o' && data[2 + j] == 'o')
        jadge = 1;
      if (data[0 + j] == 'x' && data[1 + j] == 'x' && data[2 + j] == 'x')
        jadge = 2;
      // cout << j<< endl;
    }

    // cÉÈçÔÆ«
    for (int i = 0; i < 3; i++) {
      if (data[0 + i] == 'o' && data[3 + i] == 'o' && data[6 + i] == 'o')
        jadge = 1;
      if (data[0 + i] == 'x' && data[3 + i] == 'x' && data[6 + i] == 'x')
        jadge = 2;
    }

    // ÎßÉÈçÔÆ«
    if (data[0] == 'o' && data[4] == 'o' && data[8] == 'o')
      jadge = 1;
    if (data[0] == 'x' && data[4] == 'x' && data[8] == 'x')
      jadge = 2;
    if (data[2] == 'o' && data[4] == 'o' && data[6] == 'o')
      jadge = 1;
    if (data[2] == 'x' && data[4] == 'x' && data[6] == 'x')
      jadge = 2;

    switch (jadge) {
    case 1:
      printf("o\\n");
      break;
    case 2:
      printf("x\\n");
      break;
    case 0:
      printf("d\\n");
      break;
    }
  }

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

#include <iostream>

using namespace std;

char table[3][3];

int main(void) {
  while (true) {
    for (int y = 0; y < 3; y++)
      for (int x = 0; x < 3; x++)
        cin >> table[x][y];
    if (cin.eof())
      break;
    int judge = 0;
    for (int y = 0; y < 3; y++) {
      if (table[0][y] == table[1][y] && table[1][y] == table[2][y] &&
          table[2][y] == 'o')
        judge = 1;
      if (table[0][y] == table[1][y] && table[1][y] == table[2][y] &&
          table[2][y] == 'x')
        judge = 2;
    }
    for (int x = 0; x < 3; x++) {
      if (table[x][0] == table[x][1] && table[x][1] == table[x][2] &&
          table[x][2] == 'o')
        judge = 1;
      if (table[x][0] == table[x][1] && table[x][1] == table[x][2] &&
          table[x][2] == 'x')
        judge = 2;
    }
    if (table[0][0] == table[1][1] && table[1][1] == table[2][2] &&
        table[2][2] == 'o')
      judge = 1;
    if (table[0][0] == table[1][1] && table[1][1] == table[2][2] &&
        table[2][2] == 'x')
      judge = 2;
    if (table[0][2] == table[1][1] && table[1][1] == table[2][0] &&
        table[2][0] == 'o')
      judge = 1;
    if (table[0][2] == table[1][1] && table[1][1] == table[2][0] &&
        table[2][0] == 'x')
      judge = 2;
    if (judge == 1)
      cout << 'o' << endl;
    else if (judge == 2)
      cout << 'x' << endl;
    else
      cout << 'd' << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

char table[3][3];

int main(void) {
  while (true) {
    for (int y = 0; y < 3; y++)
      for (int x = 0; x < 3; x++)
        cin >> table[x][y];
    int judge = 0;
    for (int y = 0; y < 3; y++) {
      if (table[0][y] == table[1][y] && table[1][y] == table[2][y] &&
          table[2][y] == 'o')
        judge = 1;
      if (table[0][y] == table[1][y] && table[1][y] == table[2][y] &&
          table[2][y] == 'x')
        judge = 2;
    }
    for (int x = 0; x < 3; x++) {
      if (table[x][0] == table[x][1] && table[x][1] == table[x][2] &&
          table[x][2] == 'o')
        judge = 1;
      if (table[x][0] == table[x][1] && table[x][1] == table[x][2] &&
          table[x][2] == 'x')
        judge = 2;
    }
    if (table[0][0] == table[1][1] && table[1][1] == table[2][2] &&
        table[2][2] == 'o')
      judge = 1;
    if (table[0][0] == table[1][1] && table[1][1] == table[2][2] &&
        table[2][2] == 'x')
      judge = 2;
    if (table[0][2] == table[1][1] && table[1][1] == table[2][0] &&
        table[2][0] == 'o')
      judge = 1;
    if (table[0][2] == table[1][1] && table[1][1] == table[2][0] &&
        table[2][0] == 'x')
      judge = 2;
    if (judge == 1)
      cout << 'o' << endl;
    else if (judge == 2)
      cout << 'x' << endl;
    else
      cout << 'd' << endl;
  }
  return 0;
}