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>
using namespace std;


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

C++: #include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){
    int a,b,i,x=0,y=0,count={0};
    for(i=0;i<1000;i++){
    cin>>a>>b;
        if(a==0&&b==0){
            break;
        }
    if(a<=b){
        x=b;y=a;
    }else if(a>=b){
        x=a;y=b;
    }
    for(i=0;i<1000;i++){
        x=x%y;
        swap(x,y);
        count++;
        if(y==0){
            break;
        }
    }
    cout<<x<<" "<<count<<endl;
        count=0;
    }
    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 x,y;
  while(1){
    cin>>x>>y;
    if(x==0 && y==0)break;
    if(x<y)swap(x,y);
    int i=0;
    while(y){
      x=x%y;
      swap(x,y);
      i++;
    }
    cout<<x<<" "<<i<<endl;
  }
}

C++: (){
  int a[2];
  while(cin>>a[0]>>a[1]){
    if ( a[0]==0&&a[1]==0)break;
    if ( a[0]<a[1])swap(a[0],a[1]);
    solve(a);
  }
}

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

      /* x = max(x,y);
	 y = min(x,y);*/

      while(1)
	{
	  if(x!=y)
	    {
	      y1 = x%y;
	      x1 = y;
	      cnt++;
	      x = x1;
	      y = y1;
	      if(y == 0)break;
	    }
	  else
	    {
	      cnt = 1;
	      break;
	    } 
	}
      cout << x << " " << cnt << endl;
    }

C++: #include<iostream>

int c;

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

int main(){
	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<stdio.h>
int main(void)
{
	int n,a,s,i,d,c,j,x,g;
	while(1){
		scanf("%d %d",&a,&s);
		if(a==0&&s==0) break;
		if(a<s){
			n=a;
			a=s;
			s=n;
		}
		c=0;
		while(s!=0){
			a=a%s;
			g=a;
			a=s;
			s=g;
			c++;
		}	
		printf("%d %d\n",a,c);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	int a, b,r, kouyaku[1111], kazu[1111],kaisuu,s;
	kaisuu = 0;
	while (1) {
		cin >> a >> b;
		if (a == 0&&b == 0) {
			goto a;
		}
		kaisuu = kaisuu + 1;
		s = 0;
		while (b != 0) {
			s = s + 1;
			r = a % b;
			a = b;
			b = r;
		}
		kouyaku[kaisuu] = a;
		kazu[kaisuu] = s;
	}
	a:;
	for (int i = 1; i <= kaisuu; i++) {
		cout << kouyaku[i]<<" " << kazu[i] << endl;
	}
}

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

int ans;
int gcd(int a, int b) {
	ans++;
	return a % b == 0 ? b : gcd(b, a % b);
}

int main() {
	int a, b;
	while(cin >> a >> b, a || b) {
		ans = 0;
		if(a < b)
			swap(a, b);
		int c;
		c = gcd(a,b);
		cout << c << " " << ans << endl;
	}
}

C++: // 2011/01/15 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int X, Y;
		cin >> X >> Y;
		if(X==0&&Y==0)
			break;

		if(X<Y){
			int tmp = X;
			X = Y;
			Y = tmp;
		}

		int cnt = 0;
		do{
			X = X%Y;

			int tmp = X;
			X = Y;
			Y = tmp;

			cnt++;
		}while(Y!=0);

		cout << X << ' ' << cnt << endl;
	}

	return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;






int ans;

void swap(int *a, int *b) {
	int t = *a;
	*a = *b;
	*b = t;
}

int gcd(int x, int y) {
	if (x < y)swap(&x, &y);
	if (y == 0)return x;
	ans += 1;
	//cout << ans << endl;
	x %= y;
	return gcd(y, x);
}




int main() {
	int x, y;
	while (cin >> x >> y && x > 0 && y > 0) {
		ans = 0;
		int g = gcd(x, y);
		//cout << gcd(x, y) << " " << ans << endl;
		cout << g << " " << ans << endl;
	}
}

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

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

int gcd(int a, int b) {
    while((a % b) != 0)  // yで割り切れるまでループ
    {
        a = b;
        b = a % b;
    }
    return b;
}

int main(void){
    int a, b;
    while(cin >> a >> b) {
      int lcm = b * gcd(a,b);
      cout << gcd(a,b) << " " << lcm << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>

using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

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

int main(void){  
  int a,b,n,m;
  while(cin>>a>>b, a){
    int count = 0;
    n = max(a,b);
    m = min(a,b);
    while(m){
      int tmp = m;
      m = n % m;
      n = tmp;
      count++;
    }
  cout << n <<" " << count << endl;
  }

}

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

C++: #include <iostream>

using namespace std;

int count;
int g;

int gcd(int x,int y) {

  int temp;

  if(x<y) {

    temp=x;
    x=y;
    y=temp;

  }

  if(y==0) return x;

  else {

    count++;
    return  gcd(y,x%y);

  }

}

int main() {

  int x,y;


  while(cin >> x >> y) {

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

    count=0;

    g=gcd(x,y);

    cout << g << " " << count << endl;

  }

  return 0;

}

C++: #include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
void GCD(int a,int b,int n){
    if(!b){
        printf("%d %d\n",a,n);
        return;
    }
    GCD(b,a%b,n+1);
}
int main(){
    int a,b;
    while(cin>>a>>b){
        if(a==0&&b==0)break;
        GCD(max(a,b),min(a,b),0);
    }
    return 0;
}

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

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