Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		a, _ := strconv.Atoi(buf[0])
		b, _ := strconv.Atoi(buf[1])
		if a == 0 && b == 0 {
			break
		}
		if a < b {
			a, b = b, a
		}
		cnt := 0
		for b != 0 {
			a = a%b
			a, b = b, a
			cnt++
		}
		fmt.Println(a, cnt)
	}
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int ans;
int gcd(int a,int b){
  if(a < b) swap(a,b);
  if(b == 0) return a;
  ++ans;
  return gcd(b,a%b);
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  while(cin >> a >> b){
    ans = 0;
    int k = gcd(a,b);
    cout << k <<" " << ans << endl;
  }
  return 0;
}

C++: #include <stdio.h>
int main(){
  long long x,y,a;
  int counter=0;

  while(1){
    scanf("%lld %lld",&x,&y);
    if(x==0||y==0)break;
    while(1){
      counter++;
      a=x%y;
      if(a==0)break;
      x=y;
      y=a;
    }
    printf("%lld %d\n",y,counter);
    counter=0;
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
	long long X,Y,s,c=0;
	while(cin>>X>>Y){
		if(X==0 && Y==0) break;
		if(X<Y) swap(X,Y);
		while(Y!=0){
			s = X % Y;
			X = s;
			swap(X,Y);
			c++;
		}
	cout<<X<<" "<<c<<endl;
	c=0;
	}
}

C++: #include<iostream>

unsigned int c;

unsigned int gcd(unsigned int X, unsigned int Y){
	unsigned x, y, tmp;
	if(Y > X)
		x = Y, y = X;
	else
		x = X, y = Y;
	while(true){
		if(y == 0)
			return x;
		x = x%y;
		tmp = x;
		x = y;
		y = tmp;
		c++;
	}
}

int main(){
	unsigned int x, y;
	while(true){
		c = 0;
		std:: cin >> x >> y;
		if(x == 0 && y==0)
			return 0;
		std:: cout << gcd(x, y) << ' ' << c << std::endl;
	}
}

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

int main()
{

	int x,y;

	while(true){
		int z=0;
		int c=0;

		cin >> x >> y;
		if(x==0 && y==0)
			break;

		while(true){
			x = x % y;
			z = x;
			x = y;
			y = z;

			c++;			

			if(y==0)
				break;
		}

		cout << x <<  c << endl;
	}
	return 0;
}

C++: // 2011/08/01 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int x, y;
		cin >> x >> y;
		if(x==0&&y==0)
			break;

		int X, Y;
		if(x>=y){
			X = x;
			Y = y;
		}
		else{
			X = y;
			Y = x;
		}

		int cnt = 0;
		do{
			X = X%Y;

			int tmp = X;
			X = Y;
			Y = tmp;

			cnt++;
		}while(Y!=0);

		cout << X << ' ' << cnt << endl;
	}

	return 0;
}

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

using namespace std;


int yuku(int x,int y){
	int t=x%y;
	x=y;
	y=t;
	if(y==0)return x;
	else yuku(x,y);


};
int yu(int x,int y,int sum){
	int t=x%y;
	x=y;
	y=t;
	sum++;
	if(y==0)return sum;
	else yu(x,y,sum);


};
 
int main(){

int x,y;
while(1){
cin>>x>>y;
int R=yuku(x,y);
int sum=0;
sum=yu(x,y,sum);

cout<<R<<" "<<sum<<endl;
}
return 0;
}

C++: #include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a; i ++)
#define loop(i,b,a) for(int i = b ; i < a; i ++)
const int MAX = 50000;
bool p[MAX];
void isPrime(){
  fill(p,p + MAX,true);
  p[0] = p[1] = false;
  rep(i,MAX){
    if(p[i]){
      for(int j = i + i ; j < MAX ; j += i)
	p[j] = false;
    }
  }
} 

int main(void){
  isPrime();
  int n;
  while(cin>>n){

    int i;
 
    for(i = n-1 ; !p[i] ; i --);
    cout<<i<<" ";
    for(i = n+1 ; !p[i] ; i ++);
    cout<<i<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<30;

typedef pair<int,int> pii;

pii gcd(int a, int b) {
  if (b == 0) {
    return pii(a, 0);
  }
  pii p = gcd(b,a%b);
  return pii(p.first, p.second + 1);
}

int main() {
  int a, b;
  while(cin >> a >> b, a||b) {
    if (a<b)
      swap(a,b);
    pii p = gcd(a,b);
    cout << p.first << " " << p.second << endl;
  }
}

C++: #include<iostream>
using namespace std;
int main() {
	int a, b, r, kouyaku[1001], kazu[1001], kaisuu, s;
	kaisuu = 0;
	while (1) {
		cin >> a >> b;
		if (a == 0 && b == 0) {
			break;
		}
		kaisuu = kaisuu + 1;
		s = 0;
		while (b!=0){
			s = s + 1;
			r = a % b;
			a = b;
			b = r;
		}
		kouyaku[kaisuu] = a;
		kazu[kaisuu] = s;
	}
	for (int i = 1; i <= kaisuu; i++) {
		cout << kouyaku[i] << " " << kazu[i] << endl;
	}
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int X,Y,s,c=0;
	while(cin>>X>>Y){
		if(X==0 && Y==0) break;
		while(Y!=0){
			s = X % Y;
			X = s;
			swap(X,Y);
			c++;
		}
	cout<<X<<" "<<c<<endl;
	c=0;
	}
}

C++: #include<stdio.h>
int main(void)
{
	int a,b,x,y,cnt,i,w;
	while(1){
		scanf("%d%d",&a,&b);
		if(a==0&&b==0) break;
		if(a<b){
			x=b; y=a;
		}
		else{
			x=a; y=b;
		}
		cnt=0;
		while(y!=0){
			x%=y;
			w=x;
			x=y;
			y=w;
			cnt++;
		}
		printf("%d %d\n",x,cnt);
	}
	return 0;
}

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

int main() {
  int n,m,t,c;
  while(cin>>n>>m, n|m) {
    c = 0;
    if(m>n) swap(n,m);

    while(m>0) {
      n %= m;
      swap(n,m);
      c++;
    }
    cout<<n<<" "<<c<<endl;
  }
}

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

int main(){
  int a,b,c,d,cou;
  while(1){
    cin >>a >>b;
    if(b>a)swap(a,b);
    if(a==0&&b==0)break;
    cou=1;
    while(1){
      if(a%b==0)break;
      d=a%b;
      a=b;
      b=d;
      cou++;
    }
    cout <<b<<" "<<cou<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int x,y;
  while(cin >> x >> y,x){
    int count=0;
    while(y){
      x=x%y;
      swap(x,y);
      count++;
    }
    cout << x << ' ' << count << endl;
  }
}

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int a,b;

void gcd(int a,int b,int c){
	if(!b)cout<<a<<" "<<c<<endl;
	else gcd(b,a%b,++c);
}

int main(){
	while(cin>>a>>b){
		if(!a)return 0;
		gcd(a,b,0);
	}
}