Go: package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextFloat64() (float64, error) {
	return strconv.ParseFloat(nextString(), 64)
}

func main() {
	scanner.Split(bufio.ScanWords)

	x, y := 0.0, 0.0
	rotate := 90.0

	for {
		line := nextString()
		if line == "0,0" {
			break
		}

		numbers := strings.Split(line, ",")
		di, _ := strconv.ParseFloat(numbers[0], 64)
		ai, _ := strconv.ParseFloat(numbers[1], 64)

		rotateRadian := math.Pi * rotate / 180.0
		x += di * math.Cos(rotateRadian)
		y += di * math.Sin(rotateRadian)

		rotate -= ai

		// fmt.Println(x, y)
	}

	fmt.Println(int(x))
	fmt.Println(int(y))
}

C++: //Treasure Hunt
#include<bits/stdc++.h>
using namespace std;

#define PI 3.141592

int main(){
  int tmp1, tmp2;
  double r=90.0, nx=0.0, ny=0.0;

  while(true){
    scanf("%d,%d", &tmp1, &tmp2);
    if(tmp1==0 && tmp2==0)break;
    //printf("sin=%f cos=%f\n", sin(r/RAD), cos(r/RAD));
    nx+=tmp1*cos(r*PI/180);
    ny+=tmp1*sin(r*PI/180);
    r+=tmp2;
    //printf("nx=%f, ny=%f\n", nx, ny);
  }
  printf("%d\n%d\n", (int)nx*(-1), (int)ny);

  return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
int main(void){
    // Here your code !
 int r,p,f=90;
 char c;
 double x=0,y=0;
 
 while(cin>>r>>c>>p){
   if(r==0&&p==0) break;  
   
   x=x+r*cos(f*M_PI/180.0);
   y=y+r*sin(f*M_PI/180.0);
   f=f-p;
 }
 cout<<(int)x<<endl<<(int)y;
}

C++: #include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

#define PI 3.1415926535897932

int main(){
    int a,b,theta=90;
    double x=0,y=0,pi=PI;
    for(;;){
        scanf("%d,%d",&a,&b);
        if(a==0 && b==0){
            break;
        }
        y+=a*sin(theta/180.0*pi);
        x+=a*cos(theta/180.0*pi);
        theta+=b;
    }
    printf("%d\n%d\n",(int)-x,(int)y);
    return 0;
}

C++: #include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
double toRad(int deg){
	return deg/180.0*M_PI;
}
main(){
	double x=0,y=0;
	int len,deg=90;
	double rad=toRad(deg);
	while(1){
		int tdeg;
		scanf("%d,%d",&len,&tdeg);
		if(len==tdeg && len==0){
			break;
		}
		double tx=len*cos(rad);
		double ty=len*sin(rad);
		x+=tx;
		y+=ty;
		deg-=tdeg;
		rad=toRad(deg);
	}
	cout<<(int)x<<endl<<(int)y<<endl;
}

C++: /*
C++ ???????????????????????????????????¬??????
??????AOJ-ITP1??????????????????
*/
#define _USE_MATH_DEFINES

#include <iostream> // ?¨??????\??????
#include <fstream>  // ??????????????\??????
#include <string>   // ???????????¢???
#include <vector>   // ???????????????
#include <cmath>    // ??°??????
#include <iomanip>  // stream???????????¢???
#include <algorithm>// max??¢??°??????

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;        // ????´???°????????????????????????
using std::fixed;         // ???????????????????¨???????????????????????????????
using std::setprecision;  // ?????°????°???°?????\???????????°????????????????????¨????????\???

int main() {
	double d = 0.0;	// ????????????????????¢
	double a = 0.0;	// ?????????????????????
	double x = 0.0;
	double y = 0.0;
	int ak = 90;	// ???????????????90????????????
	while (true)
	{
		scanf("%lf,%lf", &d, &a);	// double?????????????????????%f??§????????????%lf?????????
		if (d == 0 && a == 0) { cout << "???????????????" << endl;	break; }
		x += cos(ak*M_PI / 180) * d;
		y += sin(ak*M_PI / 180) * d;
		ak -= a;
		ak %= 360;
	}
	// ??????
	cout << (int)x << "\n" << (int)y << endl;
	return 0;
}

C++: #define _USE_MATH_DEFINES

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

using namespace std;

int main() {
	int d, a; double rad = 0; double x = 0, y = 0;
	while (true) {
		scanf("%d,%d", &d, &a);
		if (d == 0 && a == 0)break;
		y += d*cos(rad*M_PI/180);
		x += d*sin(rad*M_PI/180);
		rad =rad+a;
	}
	cout <<int(x) << endl <<int(y) << endl;
}

C++: #include<stdio.h>
#include<math.h>
int main()
{
double N,P;
double x,y;

x=0;y=0;
while(1)
{
scanf("%lf,%lf",&N,&P);
if((int)N==0&&(int)P==0)break;
double p;
if(0<=(int)P&&(int)P<90){p=P*3.141592/180;x+=N*sin(p);y+=N*cos(p);}
else if(90<=(int)P&&(int)P<=180){p=(180-P)*3.141592/180;x+=N*sin(p);y-=N*cos(p);}
else if(0>(int)P&&(int)P>=-90){p=(-1*P)*3.141592/180;x-=N*sin(p);y+=N*cos(p);}
else if(-90>(int)P&&(int)P>=-180){p=(180+P)*3.141592/180;x-=N*sin(p);y-=N*cos(p);}
}
int X,Y;
X=(int)x;Y=(int)y;
printf("%d\n",X);printf("%d\n",Y);

return 0;
}

C++: #include <iostream>
#include <cmath>
#include <cstdio>

#define PI 3.14159265358979323846

using namespace std;

int main(){
	double	x = 0,
		y = 0;
	int	deg = 0;
	int	p, q;
	while(scanf("%d,%d", &p, &q) && p && q){
		x += p * sin(deg * PI / 180);
		y += p * cos(deg * PI / 180);	
		deg += q;
	}
	cout << (int)x << endl;
	cout << (int)y << endl;
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main()
{
  int n;
  double x, y, deg, rad;
  
  x = y = deg = rad = 0;
  while (1){
    scanf("%d,%lf", &n, &deg);
    if (n == 0 && deg == 0){
      break;
    }
    x += cos(rad) * n;
    y += sin(rad) * n;
    deg = deg / 180 * M_PI;
    rad += deg;
  }
  printf("%f\n%f\n", y, x);
  //cout << x << "\n" << y << endl;
  return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
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, 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))

int main()
{
	int x, r, R = 0;
	pair<double, double> point = mp(0, 0);
	ifstream ifs("data.txt");

	while(ifs >> x >> r && (x || r))
	{
		R = min(R, 360);

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

		R += r;
	}

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