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++: //四則演算 #pragma GCC target("avx")
//並列計算 #pragma GCC optimize("O3")
//条件分岐を減らす #pragma GCC optimize("unroll-loops")
//浮動小数点演算 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(i) sort(i.begin(),i.end())
#define rSORT(i) sort(i.rbegin(),i.rend())
#define fSORT(i,a) sort(i.begin(),i.end(),a)
#define all(i) i.begin(),i.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
inline void print() { cout << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

void solve(int x, int y) {
    if (x < y)swap(x, y);
    int cnt = 0;
    while (y != 0) {
        x %= y;
        swap(x, y);
        ++cnt;
    }
    cout << x << " " << cnt << "\n";
}

int main() {
    init();

    for (int x, y; cin >> x >> y && x != 0;)solve(x, y);

    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int x,y;
  while(1){
    cin>>x>>y;
    if(x==0 && y==0)break;
    if(x<y)swap(x,y);
    rep(i,max(x,y)){
      x=x%y;
      swap(x,y);
      if(y==0)break;
    }
    cout<<x<<" "<<i+1<<endl;
  }
}

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

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

int main()
{
  long long int x, y;
  while (cin >> x >> y, x + y){
    int cnt = 0;
    if (x < y) swap(x, y);
    while (y != 0){
      x = x % y;
      swap(x, y);
      cnt++;
    }
    cout << x << " " << cnt << endl;
  }
}

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

int step;

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

int main() {
  int a, b;

  while( cin >> a >> b, a+b ) {
    step = 0;
    cout << gcd( a, b );
    cout << " " << step << endl;
  }
  
  return 0;
}

C++: #include <iostream>

using namespace std;

void solve(int x, int y, int count) {
    int mod = x % y;
    if (mod == 0) {
        cout << y << ' ' << count << endl;
    } else {
        solve(y, mod, count+1);
    }
}

int main() {
    int x, y;
    while (cin >> x >> y) {
        if (x < y) {
            int tmp; tmp = x; x = y; y = tmp;
        }
        if (x == 0 && y == 0) break;
        solve(x, y, 1);
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	int n, m;
	while (cin >> n >> m&&n != 0 && m != 0) {
		int sum = 0;
		if (n > m) swap(n, m);
		while ((m % n) != 0) {
			m = m%n;
			swap(n, m);
			sum++;
		}
		cout << n << " " << ++sum << endl;
	}
}

C++: #include<iostream>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)


using namespace std;

int cnt;

int lcd(int a, int b){
	if (a < b) swap(a, b);
	int c;
	cnt=0;

	while (b != 0){
		c = a%b;
		a = b;
		b = c;
		cnt++;
	}
	return a;
}



int main(){

	int a, b;
	while (cin >> a >> b && a != 0 && b != 0){
		int res = lcd(a,b);
		cout << res << " " << cnt << endl;
	}
}

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

using namespace std;;

int main(){
  long xbox[1000];
  long ybox[1000];
  int size=0;
  long xtemp,ytemp;
  long x,y,swap,mod;
  long step;
  
  while(true){
    scanf("%ld %ld", &xtemp,&ytemp);
    if(xtemp == 0 && ytemp == 0) break;
    if(xtemp>ytemp){
      xbox[size] = xtemp;
      ybox[size] = ytemp;
    }else{
      xbox[size] = ytemp;
      ybox[size] = xtemp;
    }
    size++;
  }
  for(int i=0; i<size; i++){
    step = 0;
    x = xbox[i];
    y = ybox[i];
    while(true){
      step++;
      mod = x%y;
      x = mod;
      swap = x;
      x = y;
      y = swap;
      if(y==0)break;
    }
    printf("%ld %ld\n", x,step);
  }
}

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

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

int main(){
	unsigned int a, b, cnt;
	
	while(cin >> a >> b, a){
		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 <iostream>
using namespace std;
int main(void){
    int a,b;
	while(cin >> a >> b){
	if (a == 0 & b == 0)
		break;
	int r,COUNT = 1;
	while((r = a % b) != 0)
		{ a = b; b = r; COUNT++;}
	cout << b << " " <<COUNT << endl;
	}
	return 0;
}

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

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