Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var x, y float64
	angle := 90.0

	for sc.Scan() {
		data := strings.Split(sc.Text(), ",")
		if data[0] == "0" && data[1] == "0" {
			break
		}
		meters, _ := strconv.Atoi(data[0])
		m := float64(meters)
		changedAngle, _ := strconv.Atoi(data[1])
		a := float64(changedAngle)

		radian := angle * math.Pi / 180
		x += m * math.Cos(radian)
		y += m * math.Sin(radian)
		angle -= a
	}
	fmt.Println(int(x))
	fmt.Println(int(y))
}

C++: 
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)        __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n)    for (int i = ((n)-1); i >= 0; --i)
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)      (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC     do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)

#define X real()
#define Y imag()
typedef double D;
typedef complex<double>P;

D inprd(const P &a, const P &b){ return (conj(a) * b).X; }
D outprd(const P &a, const P &b){ return (conj(a) * b).Y; }
P circum_center(const P &a, const P &b, const P &c){
    P bc = c - b, ca = a - c, ab = b - a;
    return (a + b - (inprd(bc, ca) / outprd(ab, bc)) * ab * P(0,1)) / 2.0;
}
D sign(D d){ return (d<0)?-1:d>0?1:0; }

int main(void){
    CIN_NO_SYNC;
    int r, d; char c;
    P deg(0,1);
    P pts(0,0);
    while(cin >> r >> c >> d){
        pts += deg * P(r, 0);
        deg *= polar(1.0, M_PI*-d/180);
    }
    printf("%d\n%d\n", (int)pts.X, (int)pts.Y);
    return 0;
}

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

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*3.141592/180);
	y+=a*sin(c*3.141592/180);
	c-=b;

	}

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

	return 0;

    }

C++: #include<stdio.h>
#include<math.h>
#define M_PI 3.14159265358979

int main()
{
	int x=1,y=1,k=0,h=0;
	double r=90;
	for(;x!=0||y!=0;)
	{
		scanf("%d,%d",&x,&y);
		k+=x*sin(r*M_PI/180);
		h+=x*cos(r*M_PI/180);
		r-=y;
	}
	printf("%d\n%d\n",h,k);
	return 0;
}

C++: #include <stdio.h>
#include <math.h>

#define M_PI 3.14159265358979323846

double dtor(int d){
	return d / 180.0 * M_PI;
}

int main(void){
	double x = 0.0, y = 0.0;
	int d = 0,a = 0, an = 90;

	while(true){
		scanf("%d,%d", &d, &a);
		if(d == 0 && a == 0){ break; }
		x += d * cos(dtor(an));
		y += d * sin(dtor(an));
		an -= a;
	}
	printf("%d\n%d\n", (int)x, (int)y);
	return 0;
}

C++: #include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
	double x=0,y=0;
	double l,a=0,b;
	for(;~scanf("%lf,%lf",&l,&b);)
	{
		x+=l*sin(a);
		y+=l*cos(a);
		a+=b/180*M_PI;
	}
	cout<<(int)x<<"\n"<<(int)y<<endl;
}

C++: #include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
	int w,angle;
	double x=0.0,y=0.0, prev_angle=90.0;
	while( (scanf("%d,%d",&w,&angle)) != EOF){
		if(w==0 && angle==0) break;
		double radian_angle = prev_angle * M_PI / 180.0;
		x += w*cos(radian_angle);
		y += w*sin(radian_angle);
		
		prev_angle -= (double)angle;
	}
	printf("%d\n%d\n",(int)x,(int)y);
	return 0;
}

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) { 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++: #include<iostream>
#include<math.h>
using namespace std;
#define m an/180.0*M_PI
int main(){
    double x=0,y=0,a,b,an=90;
    char c;
    while(cin>>a>>c>>b,a,b){
        x+=a*cos(m);
        y+=a*sin(m);
        an-=b;
    }
    cout<<(int)x<<endl<<(int)y<<endl;
}

C++: #include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <string>
#include <sstream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif


double deg2rad(int deg){
	return M_PI * deg / 180;
}

int main(int argc, char **argv){
	int d = 0;
	int a = 0;
	char tmp = 0;
	double x = 0;
	double y = 0;
	int theta = 90;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif

	for(;;){
#if INPUT_FROM_FILE
		ifs >> d >> tmp >> a;
#else
		std::cin >> d >> tmp >> a;
#endif
		if(d == 0 && a == 0) { break; }

		x += d * cos(deg2rad(theta));
		y += d * sin(deg2rad(theta));

		theta -= a;
	}
	std::cout << int(x) << std::endl;
	std::cout << int(y) << std::endl;
	return 0;
}

C++: # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr int MOD = 1000000000 + 7;
//?¶????????????????????????????????????§??????????????????????¢????????????????
constexpr int INF = 2000000000;
const double PI = acos(-1);

int main() {
	double x = 0.0, y = 0.0;
	int d, a;
	int ca = 90;
	char c;
	cin >> d >> c >> a;

	do {
		x += d * cos(ca / 180.0 * PI);
		y += d * sin(ca / 180.0 * PI);
		ca -= a;
		cin >> d >> c >> a;

	} while (d != 0 || a != 0);
	cout << fixed << setprecision(0) << x << endl << y << endl;
}

C++: #include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
  double x=0,y=0,d,a,b=90;
  for(;;){
    scanf("%lf,%lf",&d,&a);
    if(d == 0 && a == 0) break;
    x+=d*cos(M_PI*b/180);
    y+=d*sin(M_PI*b/180);
    b-=a;
  }
  cout <<(int)x<<endl<<(int)y<<endl;
  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main() {
	int s, r;
	double x = 0, y = 0, rad = M_PI / 2.0;
	while (scanf("%d,%d", &s, &r), s || r) {
		x += s * cos(rad);
		y += s * sin(rad);
		rad -= r * M_PI / 180;   // 時計回り
	}
	cout << (int)x << endl << (int)y << endl;
}