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 <algorithm>

using namespace std;

int ret;

int gcd(int n, int m){
	if(n < m) swap(n,m);
	if(m == 0) return n;
	ret++;
	return gcd(m,n%m);
}

int main(void){
	int n,m;
	while(cin >> n >> m){
		if((n|m) == 0) break;
		ret = 0;
		cout << gcd(n,m) << " ";
		cout << ret << endl; 
	}
}

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

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

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

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

int main()
{
    int x, y;
    while(cin >> x >> y && x)
    {
        int ans = 0;
        if(x<y) swap(x,y);

        while(y)
        {
            x = x % y;
            swap(x,y);
            ans += 1;
        }
        cout << x << " " << ans << endl;

    }
    return 0;
}

C++: #include<stdio.h>
int main()
{
	int x,y,z,c;
	while(scanf("%d%d",&x,&y),x)
	{
		for(c=(x<y?0:1);z=x%y;++c)x=y,y=z;
		printf("%d %d\n",y,c);
	}
	return 0;
}

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

C++: #include<stdio.h>
 
int main(){
	unsigned long long int a, b, n, step = 1;
	while(scanf("%lld %lld", &a, &b) != EOF){
		if(a <= b){
			n = a;
			a = b;
			b = n;
		}
		if(a % b == 0) n = b;
		while(a % b != 0){
			step++;
			if(a % b == 0){
				n = b;
				break;
			}
			a = a % b;
			n = a;
			a = b;
			b = n;
		}
		printf("%lld %lld\n", n, step);
		step = 1;
	}
	return 0;
}

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


int count = 0;

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

int main(){

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

  cout << gcd(x,y) << " " << count << endl;

}
  return 0;
}

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

int main()
{
	int x = 0, y = 0;
	int temp;
	int count;
	while (scanf("%d %d", &x, &y) != EOF) {
		if (x == 0 && y == 0) {
			break;
		}

		temp = 0;

		if (x < y) {
			temp = x;
			x = y;
			y = temp;
		}

		for (count = 0; y != 0; count++) {
			x = x % y;
			temp = x;
			x = y;
			y = temp;
		}

		printf("%d %d\n", x, count);

	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
while(1){
int a,b,count=0;
cin>>a>>b;
if(a==0 && b==0) break;
int x,y;

if(a >= b) x = a,y = b;
else x = b, y = a;
while(1){
x = x % y; 
swap(x,y); count++;
if(y == 0 ) break;
}cout<<x<<" "<<count<<endl;
}
return 0;
}

C++: #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
    int a, b;
    while (cin >> a >> b, a) {
        int cnt = 0;
        if (a < b) swap(a, b);
        while (b) {
            cnt++;
            swap(a = a % b, b);
        }
        cout << a << " " << cnt << endl;
    }
    return 0;
}

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

using namespace std;

int main(){

  int X,Y,c=0;
  vector<int> x,C;
  while(true){
    cin>>X>>Y;
    if(X+Y==0) break;
    c=0;
    while(true){
      X %= Y;
      swap(X,Y);
      ++c;
      //cout << "/////////  "<< X<<" "<<Y<<" "<< c << endl;
      if(Y==0){
	//cout << X << " " << c << endl;
	x.push_back(X);
	C.push_back(c);
	break;
      }
    }
  }

  for(int i=0; i<x.size(); ++i){
    cout<<x[i]<<" "<<C[i]<<endl;
  }

  
  return 0;
}

C++: #include <cstdio>
#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", result, step);
    }
    
    
    
    return 0;
}

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

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

int cnt;

int euclid(int a, int b)
{
  if (b == 0) return a;
  cnt++;
  return euclid(b, a%b);
}

int main()
{
  int a, b;
  while (cin>>a>>b, a||b) {
    if (a > b) {
      a ^= b;
      b ^= a;
      a ^= b;
    }
    cnt = 0;
    cout<<euclid(a, b)<<" "<<cnt<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,x,y) for(int i=(x);i<(y);i++)
#define rrep(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

//?????§??¬?´???°
int gcd(int x, int y) {
	return y ? gcd(y, x%y) : x;
}

signed main() {
	for (int x, y; cin >> x >> y&&x;) {
		int cnt = 0;
		while (y) {
			cnt++;
			int xx = x;
			x = y;
			y = xx%y;
		}
		cout << x << " " << cnt << endl;		
	}
	return 0;
}

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

C++: #include<iostream>

using namespace std;

void swap(int&, int&);

int main(){
  int count;
  long x, y;

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

    if(x < y) swap(x, y);
    count = 0;
    while(y != 0){
      x %= y;
      swap(x, y);
      ++count;
    }

    cout << x << " " << count << endl;
  }
  return 0;
}

void swap(int& x, int& y){
  int z;
  z = x;
  x = y;
  y = z;
}

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


int main(void)
{
  int a, b, x, y, z, i=0;

  while(scanf("%d %d", &a, &b) != EOF)
  {

  if(a != 0 || b != 0)
  {
    if(a >= b)
    {
      x = a;
      y = b;
    }

    else
    {
      x = b;
      y = a;
    }

  do{
      x = x%y;
      z = x;
      x = y;
      y = z;
      i++;
     }while(y!=0);

  printf("%d %d\n", x, i);
  }

  return 0;
  }
}