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

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

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

int main(){


	int a,b,c,t;

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

C++: #include<iostream>
#include<climits>
#include<math.h>
#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;
        while(b){
            a%=b;
            tmp=b;
            b=a;
            a=tmp;
            cnt++;
        }
        cout<<a<<" "<<cnt<<endl;
    }
}

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

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

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

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

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

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

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

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

typedef unsigned long long ull;
ull cnt;

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

int main(){
  ull n, m;
  while(cin >> m >> n){
    if(m == 0 && n == 0) break;
    cnt = 0;
    ull g = gcd(m, n);
    cout << g << ' ' << cnt << endl;
  }
  return 0;
}

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

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(x>y){
      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(y!=0){
      mod = x%y;
      //printf("mod %d\n",mod);
      x = mod;
      swap = x;
      x = y;
      y = swap;
      step++;
    }
    printf("%ld %ld\n", x,step);
  }
}