Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func gcd(x, y int) (int, int) {
	nSteps := 0
	for {
		if x < y {
			tmp := x
			x = y
			y = tmp
		}
		nSteps++
		if x%y == 0 {
			return nSteps, y
		}
		x = x % y
	}
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		a, _ := nextInt()
		b, _ := nextInt()

		if a == 0 && b == 0 {
			break
		}

		nSteps, p := gcd(a, b)
		fmt.Println(p, nSteps)
	}
}

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 & 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<iostream>
#include<cstdio>
#include <cstring>
#include<map>
#include<string>
#include<stack>
using namespace std;

void gcd(int max , int *min, int *count){
int amari;
while(1)
{
*count+=1;
amari=max%*min;
if(amari==0) break;
max=*min;
*min=amari;
}}


int main(){
	int n,m,count=0;
	int a,b;
	while(cin>>n>>m)
	{
		if(n==0 && m==0) break;
		a = max(m,n);
		b = min(m,n);
		gcd( a , &b , &count);
		cout<< b<<' '<<count<<endl;
		count=0;
	}
}

C++: #include <iostream>

using namespace std;

int counter;

int gcd(int a, int b){
       if (b == 0) return a;
       counter++;
       else 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 <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;

using ll = long long;

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

//ll lcm(ll a, ll b) {
//    int g = gcd(a, b);
//    a /= g;
//    b /= g;
//    return a * b * g;
//}

int main() {
    int a, b;
    while(cin >> a >> b, a) {
        int cnt = 0;
        if(a < b) {
            swap(a, b);
        }
        int res = gcd(a, b, cnt);
        cout << res << ' ' << cnt << endl;
    }
}

C++: #include <iostream>
using namespace std;
int main(){
	int a, b;
	while(cin >> a >> b) {
		if(a==0&&b==0) break;
		int cnt = 0;
		if(a<b) swap(a,b);
		while(b) {
			int t = a/b;
			swap(a-=b*t,b);
			cnt++;
		}
		cout << a << " " << cnt << endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int p;
int gcd(int a,int b){
  if(b==0)return a;
  p++;
  return gcd(b,a%b);
}
int main(){
  int a,b;
  while(cin>>a>>b,a){
    p=0;
    if(a<b)swap(a,b);
    cout<<gcd(a,b)<<' ';
    cout<<p<<endl;
  }
}

C++: // 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 << '\n';
	}

	return 0;
}

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

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

int main() {
    long long int N, M;
    while (cin >> N >> M, N || M) {
        int count = 0;
        while (M) {
            long long int tmp = N % M;
            N = M;
            M = tmp;
            count++;
        }

        cout << N << " " << count << endl;
    }

    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int x,y,a,b;
  while(1){
    cin>>x>>y;
    if(x==0 && y==0)break;
    b=0;
    while(1){
      if(y==0)break;
      a=x%y;
      x=y;
      y=a;
      b++;
    }
    cout<<x<<" "<<b<<endl;
  }
  return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<utility>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>

using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+9
#define EPS 1e-9
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < (k); i++)
typedef long long ll;
int cnt;
int func(int x,int y){
    if(x%y == 0)return y;
    ++cnt;
    func(y,x%y);
}
int main(){
    int x,y;
    while(scanf("%d%d",&x,&y),(x|y)){
        cnt = 0;
        int ans = func(x,y);
        printf("%d %d\n",ans,cnt+1);
    }
    return 0;
}

C++: #include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
using namespace std;
int main(){
int a,b;
while(cin>>a>>b,a||b){
int co=0;
if(a<b)swap(a,b);
while(1){
if(b==0)break;
a=a%b;
swap(a,b);
co++;
}
cout<<a<<" "<<co<<endl;
}
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	int a,b;
	cin >> a >> b;
	if(a == 0 && b == 0) break;
	int ans = 1;
	while(a % b != 0){
	    int temp = b;
	    b = a % b;
	    a = temp;
	    ans++;
	}
	cout << b << " " << ans << endl;
    }
    return 0;
}

C++: #include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
double dp[200][100];//動的計画法
int main(){
    long long a,b,cnt,tmp;
    while(cin>>a>>b,a){
        cnt=0;
        if(a<b){
            tmp=b;
            b=a;
            a=tmp;
        }
        while(b){
            a%=b;
            tmp=b;
            b=a;
            a=tmp;
            cnt++;
        }
        cout<<a<<" "<<cnt<<endl;
    }
}