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

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int ix = 0; ix < n; ix++) {
    string s1, s2;
    cin >> s1 >> s2;
    reverse(s1.begin(), s1.end());
    reverse(s2.begin(), s2.end());
    if (s1.size() > 80 || s2.size() > 80) {
      printf("overflow\\n");
      continue;
    }
    string res;
    int kuri = 0;
    for (int i = 0; i < 80; i++) {
      int now;
      if (i < s1.size() && i < s2.size())
        now = (s1[i] - '0') + (s2[i] - '0') + kuri;
      else if (i < s1.size())
        now = (s1[i] - '0') + kuri;
      else if (i < s2.size())
        now = (s2[i] - '0') + kuri;
      else if (kuri == 1)
        now = kuri;
      else
        break;
      res.append(1, (char)(now % 10 + '0'));
      kuri = now / 10;
    }
    if (kuri == 1)
      printf("overflow\\n");
    else {
      reverse(res.begin(), res.end());
      printf("%s\\n", res.c_str());
    }
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;
int main() {
  long long n;
  scanf("%lld\\n", &n);
  for (long long ix = 0; ix < n; ix++) {
    char t1[85], t2[85];
    scanf("%s\\n%s\\n", t1, t2);
    string s1(t1), s2(t2);
    reverse(s1.begin(), s1.end());
    reverse(s2.begin(), s2.end());
    string res;
    int kuri = 0;
    for (int i = 0; i < 80; i++) {
      int now;
      if (i < s1.size() && i < s2.size())
        now = (s1[i] - '0') + (s2[i] - '0') + kuri;
      else if (i < s1.size())
        now = (s1[i] - '0') + kuri;
      else if (i < s2.size())
        now = (s2[i] - '0') + kuri;
      else if (kuri == 1)
        now = kuri;
      else
        break;
      res.append(1, (char)(now % 10 + '0'));
      kuri = now / 10;
    }
    if (kuri == 1)
      printf("overflow\\n");
    else {
      reverse(res.begin(), res.end());
      printf("%s\\n", res.c_str());
    }
  }
}
Problem p00015 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <iostream>

using namespace std;

int main(void) {
  int sets;
  char input1[500], input2[500], out[500];
  int i1, i2, o, carry;
  int ic1, ic2;
  int i;

  cin >> sets;
  for (i = 0; i < sets; i++) {
    scanf("%s", input1);
    for (i1 = 0; input1[i1] != '\\0'; i1++)
      ;
    scanf("%s", input2);
    for (i2 = 0; input2[i2] != '\\0'; i2++)
      ;
    i1--;
    i2--;
    o = 0;
    carry = 0;
    while (i1 >= 0 || i2 >= 0 || carry) {
      if (o > 80) {
        break;
      }
      if (i1 >= 0) {
        ic1 = input1[i1] - '0';
        i1--;
      } else {
        ic1 = 0;
      }
      if (i2 >= 0) {
        ic2 = input2[i2] - '0';
        i2--;
      } else {
        ic2 = 0;
      }
      if (ic1 + ic2 + carry < 10) {
        out[o] = ic1 + ic2 + carry + '0';
        carry = 0;
      } else {
        out[o] = ic1 + ic2 + carry - 10 + '0';
        carry = 1;
      }
      o++;
    }
    if (o > 80) {
      printf("overflow\\n");
    } else {
      for (o--; o >= 0; o--) {
        printf("%c", out[o]);
      }
      printf("\\n");
    }
  }

  return 0;
}

Error: 0

Fixed submission:

#include <cstdio>
#include <iostream>

using namespace std;

int main(void) {
  int sets;
  char input1[100], input2[100], out[100];
  int i1, i2, o, carry;
  int ic1, ic2;
  int i;

  cin >> sets;
  for (i = 0; i < sets; i++) {
    if (scanf("%s", input1) == EOF) {
      break;
    }
    for (i1 = 0; input1[i1] != '\\0'; i1++)
      ;
    if (scanf("%s", input2) == EOF) {
      break;
    }
    for (i2 = 0; input2[i2] != '\\0'; i2++)
      ;
    i1--;
    i2--;
    o = 0;
    carry = 0;
    while (i1 >= 0 || i2 >= 0 || carry) {
      if (o > 80) {
        break;
      }
      if (i1 >= 0) {
        ic1 = input1[i1] - '0';
        i1--;
      } else {
        ic1 = 0;
      }
      if (i2 >= 0) {
        ic2 = input2[i2] - '0';
        i2--;
      } else {
        ic2 = 0;
      }
      if (ic1 + ic2 + carry < 10) {
        out[o] = ic1 + ic2 + carry + '0';
        carry = 0;
      } else {
        out[o] = ic1 + ic2 + carry - 10 + '0';
        carry = 1;
      }
      o++;
    }
    if (o > 80) {
      printf("overflow\\n");
    } else {
      for (o--; o >= 0; o--) {
        printf("%c", out[o]);
      }
      printf("\\n");
    }
  }

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

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

double PI = 3.141592;

int main(void) {

  double x = 0;
  double y = 0;
  double r = 0;
  double a = 90;
  double d = 0;
  while (true) {

    scanf("%lf,%lf", &r, &d);
    if (r == 0 && d == 0)
      break;

    x += r * cos(a * PI / 180);
    y += r * sin(a * PI / 180);
    // cerr << x << " " << y << endl;
    a -= d;
  }
  cout << (int)x << endl << (int)y << endl;

  return 0;
}

Error: WA

Fixed submission:

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

double PI = 3.141592;

int main(void) {

  double x = 0;
  double y = 0;
  double r = 0;
  double a = 90;
  double d = 0;
  while (true) {

    scanf("%lf,%lf", &r, &d);
    if (r == 0 && d == 0)
      break;

    x += r * cos(a * PI / 180);
    y += r * sin(a * PI / 180);
    cerr << x << " " << y << endl;
    a -= d;
  }
  cout << (int)x << " " << (int)y << endl;

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

#include <cmath>
#include <cstdio>
#include <iostream>
#define PI 3.14159265
#define RAD (PI / 180)

using namespace std;

int main() {

  int m, angle;
  double x = 0, y = 0, deg = 90;

  while (1) {
    scanf("%d, %d", &m, &angle);
    if (m == 0 && angle == 0)
      break;
    x += (double)m * cos(deg * RAD);
    y += (double)m * sin(deg * RAD);
    deg -= (double)angle;
  }

  cout << (int)x << endl << (int)y << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
#define PI 3.14159265
#define RAD (PI / 180)

using namespace std;

int main() {

  int m, angle;
  double x = 0, y = 0, deg = 90;

  while (1) {
    cin >> m >> angle;
    if (m == 0 && angle == 0)
      break;
    x += (double)m * cos(deg * RAD);
    y += (double)m * sin(deg * RAD);
    deg -= angle;
  }

  cout << (int)x << endl << (int)y << endl;

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

#include <iostream>
#include <math.h>
#include <stdio.h>
#define M_PI 3.14159265358979 /* 円周率 */

using namespace std;

int main() {
  int len, deg;
  int deg_now = 90;
  double x = 0, y = 0;

  while (1) {
    scanf("%d,%d", &len, &deg);
    if (len == 0 && deg == 0)
      break;
    x += len * cos(deg_now * M_PI / 180);
    y += len * sin(deg_now * M_PI / 180);
    deg_now -= deg;
  }

  cout << (int)x << endl << (int)y << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>
#include <math.h>
#define M_PI 3.14159265358979 /* 円周率 */

using namespace std;

int main() {
  int len = 0, deg = 0;
  int deg_now = 90;
  double x = 0, y = 0;

  while (1) {
    cin >> len >> deg;
    if (len == 0 && deg == 0)
      break;
    x += len * cos(deg_now / 180.0 * M_PI);
    y += len * sin(deg_now / 180.0 * M_PI);
    deg_now += deg;
  }

  printf("%d\\n%d\\n", (int)x, (int)y);

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

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <vector>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (int i = 0; i < (n); ++i)
const double EPS = 1e-10;
const double PI = acos(-1.0);
#define dump(x)                                                                \\
  cerr << "  (L" << __LINE__ << ") " << #x << " = " << (x) << endl;
#define dumpv(x)                                                               \\
  cerr << "  (L" << __LINE__ << ") " << #x << " = ";                           \\
  REP(q, (x).size()) cerr << (x)[q] << " ";                                    \\
  cerr << endl;
template <typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &d) {
  return s << "(" << d.first << "," << d.second << ")";
}

int main() {
  double x = 0.0, y = 0.0;
  double angle = 90;

  while (true) {
    int a, b;
    scanf("%d,%d", &a, &b);
    if (a == 0 && b == 0)
      break;

    double theta = PI * angle / 180.0;
    x += a * cos(theta);
    y += a * sin(theta);
    angle -= b;
  }

  printf("%d\\n%d\\n", (int)x, (int)y);
}

Error: 0
  (L37) theta = 1.5708
  (L37) theta = 0.436332
  (L37) theta = -0.506145
  (L37) theta = -0.436332
  (L37) theta = -1.76278
  (L37) theta = -1.29154
  (L37) theta = -2.68781
  (L37) theta = -1.18682
  (L37) theta = -1.0821
  (L37) theta = -1.67552


Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <vector>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (int i = 0; i < (n); ++i)
const double EPS = 1e-10;
const double PI = acos(-1.0);
#define dump(x)                                                                \\
  cerr << "  (L" << __LINE__ << ") " << #x << " = " << (x) << endl;
#define dumpv(x)                                                               \\
  cerr << "  (L" << __LINE__ << ") " << #x << " = ";                           \\
  REP(q, (x).size()) cerr << (x)[q] << " ";                                    \\
  cerr << endl;
template <typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &d) {
  return s << "(" << d.first << "," << d.second << ")";
}

int main() {
  double x = 0.0, y = 0.0;
  double angle = 90;

  while (true) {
    int a, b;
    scanf("%d,%d", &a, &b);
    if (a == 0 && b == 0)
      break;

    double theta = PI * angle / 180.0;
    dump(theta);
    x += a * cos(theta);
    y += a * sin(theta);
    angle -= b;
  }

  printf("%d\\n%d\\n", (int)x, (int)y);
}
Problem p00016 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int s, d;
  char c;
  double px = 0.0, py = 0.0;
  double dir = 90.0;

  while (cin >> s >> c >> d) {
    if (s == 0 && d == 0)
      break;
    px += cos(dir * M_PI / 180.0) * s;
    py += sin(dir * M_PI / 180.0) * s;
    dir -= d;
  }
  cout << static_cast<int>(px) << endl;
  cout << static_cast<int>(py) << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  double x = 0;
  double y = 0;
  double const pi = acos(-1.0);
  int16_t theta = 90;
  int d, t;
  char c;

  for (cin >> d >> c >> t; d != 1 || t != 0; cin >> d >> c >> t) {
    x += d * cos(pi * theta / 180);
    y += d * sin(pi * theta / 180);
    theta -= t;
    if (theta < 0) {
      theta += 360;
    } else {
      theta %= 360;
    }
  }
  cout << static_cast<int32_t>(x) << endl;
  cout << static_cast<int32_t>(y) << endl;
  return 0;
}
Problem p00016 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  double x, y, dx, dy, pi, d, rad, prad;
  char camma;
  x = y = 0;
  pi = 3.14159265359;
  prad = 90;
  while (cin >> d >> camma >> rad) {
    if (d == 0 && rad == 0)
      break;
    dx = d * cos(prad * pi / 180);
    dy = d * sin(prad * pi / 180);
    x += dx;
    y += dy;
    prad = prad - rad;
    //	cout<<"x:"<<x<<endl;
    // cout<<"y:"<<y<<endl;
  }
  cout << (int)x << endl;
  cout << (int)y << endl;
  // while(1);
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  double x, y, dx, dy, pi, d, rad, prad;
  char camma;
  x = y = 0;
  pi = 3.14159265359;
  prad = 0;
  while (cin >> d >> camma >> rad) {
    if (d == 0 && rad == 0)
      break;
    dx = d * cos((rad + prad) * pi / 180);
    dy = d * sin((rad + prad) * pi / 180);
    x += dx;
    y += dy;
    prad = rad + prad;
    // cout<<"x:"<<x<<endl;
    // cout<<"y:"<<y<<endl;
  }
  cout << (int)x << endl;
  cout << (int)y << endl;
  while (1)
    ;
  return 0;
}
Problem p00016 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <iostream>
#define PI 3.14159265
using namespace std;
int main() {
  int len, rot;
  float x, y, shita;
  x = y = shita = 0;
  while (1) {
    scanf("%d,%d", &len, &rot);
    if (len == 0 && rot == 0) {
      break;
    }
    x += len * cos(shita * PI / 180);
    y += len * sin(shita * PI / 180);
    shita += rot;
  }
  cout << (int)y << endl;
  cout << (int)x << endl;
  return 0;
}

Error: -11

Fixed submission:

#include <cmath>
#include <iostream>
#define PI 3.14159265
using namespace std;
int main() {
  int len, rot;
  float x, y, shita;
  x = y = shita = 0;
  while (1) {
    scanf("%d,%d", len, rot);
    if (len == 0 && rot == 0) {
      break;
    }
    x += len * cos(shita * PI / 180);
    y += len * sin(shita * PI / 180);
    shita += rot;
  }
  cout << x << endl;
  cout << y << endl;
  return 0;
}
Problem p00016 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  double x = 0, y = 0, s = 90;
  int a, b;
  while (scanf("%d,%d", &a, &b), a) {
    x += a * cos(s * M_PI / 180);
    y += a * sin(s * M_PI / 180);
    s -= b;
  }
  cout << (int)x << endl;
  cout << (int)y << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  double x = 0, y = 0, s = 90, a, b;
  while (scanf("%f,%f", &a, &b), a) {
    x += a * cos(s * M_PI / 180);
    y += a * sin(s * M_PI / 180);
    s -= b;
  }
  cout << (int)x << endl;
  cout << (int)y << endl;
}
Problem p00016 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <cstdio>

#define PI 3.1415926535898
#define ANGLE (PI / 180.0)
int main() {
  int step, dir;
  double x = 0.0, y = 0.0, angle = 0.0;

  while (1) {
    scanf("%d,%d", &step, &dir);
    if (step == 0 && dir == 0)
      break;
    x += (double)(step)*sin(angle * ANGLE);
    y += (double)(step)*cos(angle * ANGLE);
    angle += (double)dir;
  }
  printf("%d\\n%d\\n", (int)x, (int)y);
}

Error: -11

Fixed submission:

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

int main() {
  int dir = 0, rad, adv;
  double x = 0.0, y = 0.0;
  while (scanf("%d, %d\\n", adv, rad)) {
    if (adv == 0 && rad == 0)
      break;
    dir += rad;
    x += cos(dir) * adv;
    y += sin(dir) * adv;
  }
  int X = (int)x;
  int Y = (int)y;
  printf("%d\\n%d", x, y);
}
Problem p00016 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main(void) {
  float len;
  float ang, angin;
  float x, y;

  x = 0;
  y = 0;
  ang = 90;
  while (1) {
    scanf("%f,%f", &len, &angin);

    if (len == 0 && angin == 0) {
      break;
    }

    y += (sin(ang / 180 * M_PI) * len);
    x += (cos(ang / 180 * M_PI) * len);

    ang -= angin;
  }

  printf("%d\\n%d\\n", (int)x, (int)y);

  return (0);
}

Error: TLE

Fixed submission:

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

int main(void) {
  float len;
  float ang, angin;
  float x, y;

  x = 0;
  y = 0;
  ang = 90;
  while (1) {
    scanf("%f %f", &len, &angin);

    if (len == 0 && angin == 0) {
      break;
    }

    y += (sin(ang / 180 * M_PI) * len);
    x += (cos(ang / 180 * M_PI) * len);

    ang -= angin;
  }

  printf("%.0f\\n%.0f\\n", x, y);

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

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

int main() {
  int d, t;
  double x = 0, y = 0;
  double angle = 90;
  while (1) {
    char c;
    cin >> d >> c >> t;
    if (d == 0 && t == 0)
      break;
    x += d * cos(angle / 180 * acos(-1));
    y += d * sin(angle / 180 * acos(-1));
    angle -= t;
  }
  cout << (int)x << endl;
  cout << (int)y << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  int d, t;
  double x = 0, y = 0;
  double angle = 90;
  while (1) {
    cin >> d >> t;
    if (d == 0 && t == 0)
      break;
    x += d * cos(angle / 180 * acos(-1));
    y += d * sin(angle / 180 * acos(-1));
    angle -= t;
  }
  cout << (int)x << endl;
  cout << (int)y << endl;
}
Problem p00016 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

int main() {

  int a, b;
  int c = 90;
  double x = 0;
  double y = 0;
  while (true) {

    scanf("%d,%d", &a, &b);
    if (a == 0 && b == 0)
      break;
    x += a * cos(c * M_PI / 180);
    y += a * sin(c * M_PI / 180);
    c -= b;
  }

  printf("%d\\n%d\\n", (int)x, (int)y);

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

int main() {

  double a, b;
  double c = 90;
  double x = 0;
  double y = 0;
  while (scanf("%lf%lf", &a, &b), a || b) {

    x += a * cos(c * M_PI / 180);
    y += a * sin(c * M_PI / 180);
    c -= b;
  }

  printf("%d\\n %d\\n", (int)x, (int)y);

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

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
template <class T> T RoundOff(T a) { return int(a + .5 - (a < 0)); }
template <class T, class C> void chmax(T &a, C b) {
  if (a < b)
    a = b;
}
template <class T, class C> void chmin(T &a, C b) {
  if (b < a)
    a = b;
}
template <class T> int GetInt(T a) { return a >= 0 ? floor(a) : ceil(a); }
template <class T, class C> pair<T, C> mp(T a, C b) { return make_pair(a, b); }
const double PI = 3.141592653583;
#define DegreeToRadian(Degree) ((float)Degree * (PI / 180.0f))

vector<string> split(string str, string delim) {
  vector<string> result;
  int cutAt;
  while ((cutAt = str.find_first_of(delim)) != str.npos) {
    if (cutAt > 0) {
      result.push_back(str.substr(0, cutAt));
    }
    str = str.substr(cutAt + 1);
  }
  if (str.length() > 0) {
    result.push_back(str);
  }
  return result;
}

int main() {
  int x, r, R = 0;
  pair<double, double> point = mp(0, 0);
  string str;

  while (cin >> str) {
    vector<string> l = split(str, ",");

    x = r = 0;
    rep(i, l[0].size()) {
      if (l[0][i] != '-')
        x += (l[0][i] - '0') * pow(10, (float)l[0].size() - i - 1);
    }
    rep(i, l[1].size()) {
      if (l[1][i] != '-')
        r += (l[1][i] - '0') * pow(10, (float)l[1].size() - i - 1);
    }
    if (l[0][0] == '-')
      x *= -1;
    if (l[1][0] == '-')
      r *= -1;

    if (!(x || r))
      break;

    R = min(R, 360);

    point.first += sin(DegreeToRadian(R)) * x;
    point.second += cos(DegreeToRadian(R)) * x;

    R += r;
  }

  pint res = mp(GetInt(point.first), GetInt(point.second));
  printf("%d\\n%d\\n", res.first, res.second);
}

Error: TLE

Fixed submission:

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

#define PI 3.1415926535897932386

int main() {
  int x, r;
  double X = 0, Y = 0, rad = 90;

  while (1) {
    // üÍ
    cin >> x;
    cin >> r;

    // 0¾Á½çIíé
    if (x == 0 && r == 0) {
      break;
    }

    X += x * cos(rad * PI / 180);
    Y += x * sin(rad * PI / 180);

    rad -= r;
  }

  X = (int)X;
  Y = (int)Y;

  cout << X << endl << Y;
}
Problem p00016 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <fstream>
#include <iostream>
#include <math.h>
#include <queue>
#include <utility>
#include <vector>
#define PI 3.141592
using namespace std;

int main() {
  // ifstream cin("../test.txt");
  double x, y, ca, a, l;
  x = 0;
  y = 0;
  ca = PI / 2;
  char c;
  while (true) {
    cin >> l >> c >> a; // 進む距離と回転角度
    if (l == 0 && a == 0)
      break;

    x += l * cos(ca);
    y += l * sin(ca);

    ca -= a * PI / 180.0;
  }

  cout << (int)x << endl;
  cout << (int)y << endl;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <fstream>
#include <iostream>
#include <math.h>
#include <queue>
#include <utility>
#include <vector>
#define PI 3.141592
using namespace std;

int main() {
  ifstream cin("../test.txt");
  double x, y, ca, a, l;
  x = 0;
  y = 0;
  ca = PI / 2;
  char c;
  while (true) {
    cin >> l >> c >> a; // 進む距離と回転角度
    if (l == 0 && a == 0)
      break;

    x += l * cos(ca);
    y += l * sin(ca);

    ca -= a * PI / 180.0;
  }

  cout << (int)x << endl;
  cout << (int)y << endl;
}
Problem p00016 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <iostream>
#include <stdio.h>
#define PI 3.141592653589793
using namespace std;

int main() {
  double x = 0, y = 0;

  int angle = 90;

  int l, a;

  while (scanf("%d,%d", &l, &a) + 1) {
    if (l == 0 && a == 0)
      break;

    x -= l * cos(angle * PI / 180);
    y += l * sin(angle * PI / 180);

    angle += a;
  }

  cout << (int)x << endl << (int)y << endl;

  return 0;
}

Error: -11

Fixed submission:

#include <cmath>
#include <iostream>
#include <stdio.h>
#define PI 3.141592653589793
using namespace std;

int main() {
  double x = 0, y = 0;

  int l, a;

  while (scanf("%d,%d", l, a) != -1) {
    x += l * cos(a * PI / 180);
    y += l * sin(a * PI / 180);
  }

  cout << (int)x << endl << (int)y << endl;

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

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

#define PI 3.14159265358979

using namespace std;

int main() {
  int theta, x, theta_sum;
  double x_sum, y_sum;
  x_sum = 0;
  scanf("%d,%d", &x, &theta);
  y_sum = (double)x, theta_sum = (double)theta;
  while (1) {
    scanf("%d,%d", &x, &theta);
    if (x == 0 && theta == 0)
      break;
    x_sum += (double)x * sin(double(theta_sum * PI / 180.00));
    y_sum += (double)x * cos(double(theta_sum * PI / 180.00));
    theta_sum += theta;
  }

  cout << (int)x_sum << endl << (int)y_sum << endl;

  return 0;
}

Error: TLE

Fixed submission:

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

#define PI 3.14159265

using namespace std;

int main() {
  double theta, theta_sum;
  double x, x_sum, y_sum;

  y_sum = 0;
  scanf("%f,%f", &x, &theta);
  x_sum = x, theta_sum = theta;
  while (scanf("%f,%f", &x, &theta) && x != 0 && theta != 0) {
    x_sum += x * sin(theta_sum * PI / 180);
    y_sum += x * cos(theta_sum * PI / 180);
    theta_sum += theta;
  }

  cout << floor(x_sum) << endl << floor(y_sum) << endl;

  return 0;
}