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>
using namespace std;
int main() {
	int a, b,r, kouyaku[1001], kazu[1001],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;

main(){
    int x, y;
    while ( cin >> x >> y && x && y){
	if ( y > x ) swap(x, y);
	int step = 0;
	while(y){
	    int t = x % y;
	    x = y;
	    y = t;
	    step++;
	}
	cout << x << " " << step << endl;
    }
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

int gcd(int a, int b, int & step){
    return b ? step++, gcd(b, a%b, step) : a;
}

int main(int argc, char ** argv) {
    int a, b;
    while (scanf("%d%d", &a, &b), a != 0){
        if (a < b) swap(a, b);
        int g, k = 0;
        g = gcd(a, b, k);
        printf("%d %d\n", g, k);
    }
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
    long long int a,b,x,y,z,st;
     
    while(cin >> a >> b,a,b){
        x=max(a,b);
        y=min(a,b);
        st=0;
        while(1){
            if(y==0) break;
            z=x%y;
            x=y;
            y=z;
            st++;
        }
        cout << x << ' ' << st << endl;
    }
     
    return 0;
}

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

int bin_search(int x[],int size,int key)
{
	int low = 0,high = size;
	int count=1;
	while(low < high){
		int mid = (low+high)/2;
		if(x[mid] == key)
			return count;
		else if(x[mid] > key)
			high = mid-1;
		else
			low = mid+1;
		count++;
	}
	return count;
}
int main()
{
	int size;
	int key;
	int x[101];
	while(cin >> size){
		if(size == 0)
			break;
		for(int i=0;i<size;i++){
			cin >> x[i];
		}
		cin >> key;
		cout << bin_search(x,size,key) << endl;
	}
	return 0;
}

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