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

using namespace std;

typedef vector<int> VI;
typedef pair<int,int> PII;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;

int main(){
    ll a,b;
    while(cin>>a>>b){
        if(a==0 && b==0)break;
        ll count=0;
        while(b!=0){
            ll box=b;
            b=a%b;
            a=box;
            count++;
        }
        cout<<a<<" "<<count<<endl;
    }
    return 0;
}

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

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

C++: #include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
int cnt;

int gcd(int w,int m){
  if ( m ==0)return w;
  cnt++;
  return gcd(m,w%m);
}

int solve(int *a){
  cnt=0;
  cout << gcd(a[0],a[1])<<" " << cnt << endl;
}

main(){
  int a[2];
  while(cin>>a[0]>>a[1]){
    if ( a[0]==0&&a[1]==0)break;
    if ( a[0]<a[1])swap(a[0],a[1]);
    solve(a);
  }
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	int x, y;
	while(1){
		int count=0, tmp;
		cin>>x>>y;
		if(x == 0 && y == 0) break;
		while(1){
			if(y == 0) break;
				x = x % y;
				tmp = x;
				x = y;
				y = tmp;
				count++;
		}
		cout<<x<<" "<<count<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>

using namespace std;

int step = -1;
int result = 0;

int gcd(int a, int b) {
    step++;
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main() {
    while (true) {
       int X = 0, Y = 0;
       
       scanf("%d %d", &X, &Y);
       
       if(X == 0 && Y == 0) break;
       
       if (X < Y) {
           X = Y;
       }
       
       result = gcd(X, Y);
             
       printf("%d %d\n", result, step);
    }
    
    
    
    return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

struct GCD{
	int gcd;
	int step;
};

GCD calc_gcd (int a, int b )
{
	GCD res;
	
	int step = 0;

	while(1){
		++step;
		if (a % b == 0){
			break;
		} // end if
		a = a % b;
		if (a < b ){
			swap (a, b );
		} // end if
//		cout << "a: " << a << " b: " << b << endl;
	} // end while

	res.gcd = b;
	res.step = step;

	return res;
}	

int main()
{
//	cut here before submit 
//	freopen("testcase.ea", "r", stdin);
	string str = "";

	while (getline (cin, str ) ){
		int a, b;
		stringstream ss (str );
		ss >> a >> b;

		if (a == 0 && b == 0){
			break;
		} // end if
		GCD res;

//		cout << "a: " << a << " b: " << b << endl;

		if (a < b ){
			swap (a, b );
		} // end if

		res = calc_gcd (a, b );
		cout << res.gcd << ' ' << res.step << endl;

	} // end loop

		
	return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int k;

int gcd(int a,int b){
	if(b==0)return a;
	k++;
	return gcd(b,a%b);
}

int main() {
	int a,b;
	while(cin>>a>>b,a){
		k=0;
		if(a>b){cout<<gcd(a,b);cout<<" "<<k<<endl;}
		else{cout<<gcd(b,a);cout<<" "<<k<<endl;}
	}
	return 0;
}

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

int X, Y;

pair<int, int> gcd_cnt(int x, int y){
    int cnt = 0;
    while(y > 0){
        cnt++;
        x %= y;
        swap(x, y);
    }
    return make_pair(x, cnt);
}

int main(){
    while(cin >> X >> Y){
        if(X == 0 && Y == 0){
            return 0;
        }
        if(X < Y){
            swap(X, Y);
        }
        pair<int, int> ret = gcd_cnt(X, Y);
        cout << ret.first << " " << ret.second << endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	int a, b, r, kouyaku[1001], kazu[1001], kaisuu, s;
	kaisuu = 0;
	cin >> a >> b;

}

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

unsigned int res=0;

unsigned int gcd(unsigned int x,unsigned int y) {
  if(y == 0) return x;
  else {
    res++;
    return gcd(y,x%y);
  }
}

int main() {
 unsigned int x,y;
  while(cin >> x >> y) {
    if(x==0&&y==0) break;
    cout << gcd(x,y) << " " << res << endl;
    res = 0;
  }
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

static int c;
int gcd(int x, int y)
{
	if (y == 0)
		return x;
	++c;
	return gcd(y, x % y);
}	
int main()
{
	int x, y;
	while (scanf("%d %d", &x, &y), x | y)
	{
		if (x < y)
			swap(x, y);
		c = 0;
		int ans = gcd(x, y);
		printf("%d %d\n", ans, c);
	}

	return 0;
}

C++: #include <cstdio>
using namespace std;
int main(void){
    long long  a,b,r,x,tmp;
    int cnt;
    char str[100];
    
    for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
        sscanf(str,"%lld %lld",&a,&b);
        if(a==0 && b==0) break;
        x=a*b; cnt=1;
        if(a<b){
            tmp=a;
            a=b;
            b=tmp;
        }
        r=a%b;
        while(r!=0){
            a=b;
            b=r;
            r=a%b;
            cnt++;
        }
        printf("%lld %d\n",b,cnt);
    }
    return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>


int main(void)
{
	int result[10000], step[10000];
	int suffix = 0;

	while (1) {
		long long x, y;

		scanf("%lld", &x);
		scanf("%lld", &y);

		if (x == 0 && y == 0) {
			break;
		}

		long long value = 1;
		int count = 0;

		while (1) {
			count++;
			value = x % y;

			if (value == 0) {
				result[suffix] = y;
				step[suffix] = count;
				suffix++;
				break;
			}

			x = y;
			y = value;
		}
	}

	for (int i = 0; i < suffix; i++) {
		printf("%d %d\n", result[i], step[i]);
	}

	return 0;
}

C++: #include<iostream>
main(){for(int a,b,t,c;std::cin>>a>>b,a;printf("%d %d\n",a,c)){if(a<b){a^=b;b^=a;a^=b;}for(c=0;t=b;a=t,c++)b=a%b;}}