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++: #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; int 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;

    }

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; int b; double c=90; double x=0; double y=0;
	while(true){
	cin >> a >> b;
	if(a==0 && b==0) break;
	x+=a*cos(c*3.141592/180);
	y+=a*sin(c*3.141592/180);
	c-=b;

	}

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

	return 0;

    }

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;
}