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++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main(){
  int D, A;
  double x = 0, y = 0, a = 90;
  while(scanf("%d,%d",&D,&A),D){
	double dx = D * cos(a*PI/180), dy = D * sin(a*PI/180);
	x += dx, y += dy;
	a -= A;
  }

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

  return 0;
}

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

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

/* {{{ */
#define PI(N) ((M_PI * (N)) / 180) //?§???????????????¢??????????????????
#define CL(N) (cout << (N) << endl)
#define DCT(N) (cout << "debug " << (N) << endl)
#define REP(i, N) for (int i = 0; i < (N); i++)
/* }}} */

int main()
{
    int l, a, sum_angle = 90;
    double x, y;

    x = y = 0.0;

    while (scanf("%d,%d", &l, &a), l || a){
        x += l * cos(PI(sum_angle));
        y += l * sin(PI(sum_angle));

        sum_angle = (sum_angle - a) % 360;
    }

    CL((int)x);
    CL((int)y);

    return (0);
}

C++: #include <iostream>
#include <cmath>
#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-=(double)angle;
	}

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

	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;

#define PI 3.1415

vector<int>d;
vector<int>e;


int main(){

	int a,b;
	while(true){
	cin >> a >> b;
	if(a==0 && b==0) break;
	d.push_back(a); e.push_back(b);
	}

   int n=d.size();

	int c=90; float x=0; float y=0;
    for(int i=0;i<n;i++){
	x+=d[i]*cos(c*PI/180);
	y+=d[i]*sin(c*PI/180);
	c+=-e[i];
    }

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

	return 0;
    }

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int 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;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
const int MAX = (int)2e5 + 5;

double x = 0;
double y = 0;

int main() {
	double dir = M_PI/2;
	double d, t;
	// dump(sin(M_PI));
	// dump(cos(dir));
	// dump(sin(dir));
	while (scanf("%lf,%lf",&d,&t) != EOF) {
		// cout << d << " " << t << endl;
		if (d == 0) break;
		x += d*cos(dir);
		y += d*sin(dir);
		dir += -t/180*M_PI;
	}
	cout << (ll)(x+1e-8) << endl;
	cout << (ll)(y+1e-8) << endl;
	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;

#define PI 3.1415

vector<int>d;
vector<int>e;


int main(){

	int a,b;
	while(true){
	cin >> a >> b;
	if(a==0 && b==0) break;
	d.push_back(a); e.push_back(b);
	}

   int n=d.size();

	int c=90; double x=0; double y=0;
    for(int i=0;i<n;i++){
	x+=d[i]*cos(c*PI/180);
	y+=d[i]*sin(c*PI/180);
	c+=-e[i];
    }

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

	return 0;
    }

C++: //0016 Treasure Hunt

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

template<class T>
T DigToRad(T x)
{
	return x / T(180) * 3.14159265358979323846264338327950;
}


int main(void)
{
	double x, y;
	double d, dd, r;
	char dummy;

	x = y = 0;
	d = 90;
	//üÍÍR}ÅæØçêÄ^¦çêé
	while(cin >> r >> dummy >> dd, r)
	{
		x += r*cos(DigToRad(d));
		y += r*sin(DigToRad(d));
		//³ÌÈçEñè
		d -= dd;
	}
	//®ðoÍ
	cout << (int)x << endl << (int)y << endl;
	return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define REP(i,e) for (int i = 0; i != int(e); i++)
#define FORIT(i, A) for (auto i : A)
#define ISEQ(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << endl
#define SZ(x) ((int)(x).size())

int main(int argc, char const *argv[])
{
	int d, a;
	int deg = 90.;
	double x = 0., y = 0.;
	while(1)
	{
		if (scanf("%d,%d", &d, &a) == EOF) break;
		if (d == 0 && a == 0) break;
		double rad = (double)deg / 180. * M_PI;
		x += d * cos(rad);
		y += d * sin(rad);
		deg -= a;
	}
	printf("%d\n%d\n", (int)x, (int)y);
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<math.h>
#include<string>
#include<stdio.h>

#define PI 3.141592

using namespace std;

int main(){
	string stepsandrad;
	double steps, dir,rad=0.0;
	double y=0.0,x=0.0;

	while (true){

		cin >> stepsandrad;

		sscanf(stepsandrad.c_str(), "%lf,%lf", &steps, &dir);

		if (steps == 0 && dir == 0)
			break;

		y += steps*cos(rad);
		x += steps*sin(rad);

		rad += dir * PI / 180.0;

	}

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

	return 0;
}

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

using namespace std;

int main() {
    int a=1;
    int b=1;
    
    double degree=90.0;
    
    double x=0.0;
    double y=0.0;

    while (a!=0&&b!=0){
        scanf("%d,%d",&a,&b);
        
        y+=(a*sin(degree* M_PI / 180));
        x+=(a*cos(degree* M_PI / 180));
        
        degree-=b;
    }
    
    cout<<(int)x<<" "<<(int)y;
    
    return 0;
}