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<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>

using namespace std;


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


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


};
 
int main(){

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

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

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

using namespace std;

long long calc(long long x,long long y,long long int& count){

	int tmp_count = 0,tmp;

	while(y != 0){
		tmp = y;
		y = x%y;
		x = tmp;
		tmp_count++;
	}

	count = tmp_count;
	return x;
}

int main(){

	long long a,b,count,number;

	while(true){
		scanf("%lld %lld",&a,&b);
		if(a == 0 && b == 0)break;

		if(a > b){
			number = calc(a,b,count);
		}else{
			number = calc(b,a,count);
		}

		printf("%lld %lld\n",number,count);

	}

    return 0;
}

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

void swap(int *a, int *b){
	if(*a != *b){
		*a ^= *b;
		*b ^= *a;
		*a ^= *b;
	}
}

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

C++: #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>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#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())

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

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

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int dx[8] = {-1, 0, 1, 0, -1, -1, 1, 1};
int dy[8] = {0, -1, 0, 1, -1, 1, -1, 1};

int main() {
  int x, y;

  while(1) {
    cin >> x >> y;
    if(x+y == 0) break;
    if(x < y) swap(x, y);
    int cnt = 0;
    while(y != 0) {
      x = x%y;
      swap(x, y);
      cnt++;
    } 
    cout << x << ' ' << cnt << endl;
  }
}

C++: // #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef vector<pair<int, int> > VPII;

#define MP make_pair
#define fastIO	cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (未test)
// #define FOREACH_IT(it,c)	for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(), c_end=c.end(); it!=c_end; ++it)

// ------------------- include, typedef, define END. -------------------

void solveAndOutput(LL x,LL y){
	int step = 0;
	while (y != 0){
		step++;
		x = x%y;
		swap(x, y);
	}
	cout << x << " " << step << endl;
}

int main(){
	fastIO;
	LL x = 0, y = 0;
	while (cin >> x >> y, x || y){
		if (x < y)	swap(x, y);
		solveAndOutput(x, y);
	}
	return 0;
}

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

using namespace std;
int counter;
int gcd(int a, int b)
{
    if (b == 0)
    return a;     
    counter++;  
    return gcd(b, a%b); 
    }
    int main(void){  
        int a, b;    
        while(cin>>a>>b){  
            if(a == 0 && b == 0) 
            return 0;        
            counter = 0;     
            cout<<gcd(a,b)<<" "<<counter<<endl;   
            }  
            return 0;
        
}

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

using namespace std;

int main(){

  int X,Y,c=0;

  while(true){
    cin>>X>>Y;
    if(X+Y==0) break;
    c=0;
    while(true){
      X %= Y;
      swap(X,Y);
      ++c;
      if(Y==0){
	cout << X << " " << c << endl;
	break;
      }
    }
  }

  
  return 0;
}

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

using namespace std;

int counter;

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

int main(void){
   int a, b, x;
    while(cin>>a>>b){
        if(a < b){
            x = a;
            a = b;
            b = x;
        }
        if(a == 0 && b == 0)    return 0;
        counter = 0;
        cout<<gcd(a,b)<<" "<<counter<<endl;
    }
    return 0;
}

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

using namespace std;

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

int main(void){
  int a,b;
  while(cin>>a>>b,a+b){
    step = 0;
    cout<<gcd(max(a,b),min(a,b));
    cout<<" "<<step<<endl;
  }
}

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

int main(){

  int x,y,x1,y1;
  int cnt=0;

  while(1)
    {
      cin >> x >> y;

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

      if(x < y)swap(x,y);

      while(1)
	{
	  x = x%y;
	  swap(x,y);
	  
	  cnt++;
	  if(y == 0)break;
	}
	
      cout << x << " " << cnt << endl;
    }
}

C++: #include <stdio.h>
int t;
int gcd(int a,int b){
    t++;
    if(b==0)return a;
    return gcd(b,a%b);
}
int main(){
    int a,b;
    while(true){
        scanf("%d%d",&a,&b);
        if(a==0&&b==0)return 0;
        t=0;
        printf("%d %d\n",gcd(a,b),t-1);
    }
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	long long 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;
}