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 <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;}}

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

int res;

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

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

C++: # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
const double PI = acos(-1);

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

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

int main(){

  int a,b,c,r,count;

  while(cin >> a >> b, a, b){
    count = 0;

    while(b!=0){

      c = a/b;
      r = a%b;
      a = b;
      b = r;

      count++;

    }

    cout << a << ' ' << count << endl;

  }
}

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

typedef long long ll;

int ct=0;

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

int main(){
	int x,y;
	while(1){
		scanf("%d%d",&x,&y);
		if(x==0 && y==0)break;
		if(x<=y){
			int tmp=x;
			x=y;
			y=tmp;
		}
		ct=0;
		cout<<gcd(x,y)<<" "<<ct<<endl;
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
#include<climits>
using namespace std;

int cnt;

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

int main(){
	int X, Y;
	while(cin >> X >> Y, X || Y){
		if(X < Y) swap(X, Y);
		cnt = 0;
		int ans = gcd(X, Y);
		printf("%d %d\n", ans, cnt);
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

typedef long long ll;

int ct=0;

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

int main(){
	ll x,y;
	while(cin>>x>>y){
		if(x==0 && y==0)break;
		if(x<y){
			ll tmp=x;
			x=y;
			y=tmp;
		}
		cout<<gcd(x,y)<<" "<<ct<<endl;
		ct=0;
	}
	return 0;
}

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

typedef std::pair<int, int> P;

P gcd( int s, int a, int b )
{
	if( b == 0 )
		return P( a, s );

	return gcd( s + 1, b, a % b );
}

int main()
{
	int a, b;
	while( std::cin >> a >> b, a | b )
	{
		P p = gcd( 0, a, b );
		std::cout << p.first << ' ' << p.second << std::endl;
	}

	return 0;
}

C++: #include<iostream>

unsigned int c;

unsigned int gcd(unsigned int X, unsigned int Y){
	unsigned x, y;
	if(Y > X)
		x = Y, y = X;
	else
		x = X, y = Y;
	if(y==0)
		return x;
	c++;
	return gcd(y, x%y);
}

int main(){
	unsigned int x, y;
	while(true){
		c = 0;
		std:: cin >> x >> y;
		if(x == 0 && y==0)
			return 0;
		std:: cout << gcd(x, y) << ' ' << c << std::endl;
	}
}

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

C++: #include <bits/stdc++.h>
using namespace std;
int main(){

  for(;;){
    int n,m;
    cin>>n>>m;
    if(n==0) break;

    if(n<m) swap(n,m);

    int c,r=0;
    for(;m;){
      c=n%m;
      n=m;
      m=c;
      r++;
    }
    cout<<n<<" "<<r<<endl;
  }

  return 0;

}

C++: #include <stdio.h>
int main(void) {
	long a1, a2, x, y;
	int amari,i=0;
	scanf("%ld %ld", &a1, &a2);	//1. 2number
	
	if(a1<a2){
		
		x = a2;
		y = a1;
	}	
	while(amari =! 0){
		amari = x % y;
		x = y;
		y = amari;
                i++;
	
	}
	
	printf("%ld %ld\n", x, i);
	
	return 0;
}

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

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

pair< int, int > rec(int X, int Y, int Step)
{
  if(Y == 0) return(make_pair(X, Step));
  else return(rec(Y, X % Y, Step + 1));
}

int main()
{
  int X, Y;
  while(cin >> X >> Y, X|Y) {
    pair< int, int > ret = rec(max(X, Y), min(X, Y), 0);
    cout << ret.first << " " << ret.second << endl;
  }
}

C++: #include <iostream>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	long long a,b;
	while(cin>>a>>b&&a!=0&&b!=0){
		int cnt=0;
		while(b!=0){
			a=a%b;
			swap(a,b);
			cnt++;
		}
		cout<<a<<" "<<cnt<<endl;
	}
	return 0;
}

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;
		}
		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;
}