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;

void swap( int &a, int &b ){
	int tmp = a;
	a = b;
	b = tmp;
}

int main(){
	int a, b;
	while( cin >> a >> b, a||b ){
		if( a < b )
			swap(a,b);
		int c=0;
		for( ;b>0;c++ ){
			a = a%b;
			swap(a,b);
		}
		cout << a << " " << c << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include<iostream>
#include <iomanip>

using namespace std;

void Euclidean(long long a,long long b,long long n){
	if(b!=0) Euclidean(b,a%b,n+1);
	else cout<<a<<" "<<n<<endl;
	return;
}

int main(void){

	long long a,b;

	while(1){

		cin>>a>>b;
		if(a==0&&b==0) break;
		Euclidean(a,b,0);
	}

    return 0;
}

C++: #include <cstdio>
#include <algorithm>
int ans = 0;
int GCD(int a, int b){
	if(b==0)return a;
	ans++;
	return GCD(b, a%b);
}

int main(){
	int x,y;
	while(scanf("%d %d",&x, &y), x+y){
		ans=0;
		if(x>y)std::swap(x,y);
		int gcd = GCD(x,y);
		printf("%d %d\n",gcd, ans);
	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>

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

using namespace std;

int ans;

void gcd(int x,int y)
{
	ans++;
	x = x % y;
	swap(x,y);

	if(y == 0)
	{
		cout << x << " " << ans << endl;
		return;
	}
	else gcd(x,y);
}

int main()
{
	int a,b;
	while(cin >> a >> b)
	{
		if(a == 0 && b == 0) break;

		ans = 0;

		if(a < b) swap(a,b);
		gcd(a,b);	
	}
	return 0;
}

C++: #include <stdio.h>
int main(){
  long x,y,a;
  int counter=0;

  while(1){
    scanf("%ld %ld0",&x,&y);
    if(x==y==0)break;
    while(1){
      counter++;
      a=x%y;
      if(a==0)break;
      x=y;
      y=a;
    }
    printf("%ld %d\n",y,counter);
    counter=0;
  }
  return 0;
}

C++: #include<stdio.h>

int main(){
	int x,y,count,t;
	while(0<=scanf("%d%d",&x,&y)){
		if(x==0 && y==0)break;
		if(x<y){
			count=x;
			x=y;
			y=count;
		}
		count=0;
		while(y!=0){
			x=x%y;
			t=x;
			x=y;
			y=t;
			++count;
		}
		printf("%d %d\n",x,count);
	}
	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int x, y;
        cin >> x >> y;
        if(x == 0)
            return 0;
        if(x < y)
            swap(x, y);

        int ret = 0;
        do{
            ++ ret;
            x %= y;
            swap(x, y);
        }while(y != 0);

        cout << x << ' ' << ret << endl;
    }
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
　int x,y,num;
　while(cin>>x>>y,x&&y){
　　if(x<y)swap(x,y);
　　for(int i=1;;i++){
　　　num=x%y;
　　　x=y;
　　　y=num;
　　　if(!num){
　　　　cout<<x<<" "<<i<<endl;
　　　　break;
　　　}
　　}
　}
}

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

void EucledeanAlgorithm(long int a, long int b) {
	int step = 0;
	while (b != 0) {
		if (a < b) swap(a, b);
		a = a % b; swap(a, b); step++;
	}
	cout << a << " " << step << endl; return;
}

int main() {
	long int a, b;
	while (1) {
		cin >> a >> b; if (a == 0 && b == 0) break;
		EucledeanAlgorithm(a, b);
	}
	return 0;
}

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

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

int main(void){
   int counter;
   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<iostream>
#include<algorithm>
using namespace std;
int main(){
  int x,y;
  while(cin >> x >> y,x){
    int count=0;
    while(y){
      x=x%y;
      swap(x,y);
      count++;
    }
    cout << x << " " << count << endl;
  }
}

C++: #include <iostream>
#include <cstdio>

using namespace std;

int counter;

int gcd(int a, int b){
        if (b == 0) return a;
        counter++;
        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<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) {
			break;
		}
		if (a <= b) {
			r = a;
			a = b;
			b = r;
		}
		kaisuu = kaisuu + 1;
		s = 0;
		while (b!=0){
			s = s + 1;
			r = a % b;
			a = b;
			b = r;
		}
		kouyaku[kaisuu] = a;
		kazu[kaisuu] = s;
	}
	for (int i = 1; i <= kaisuu; i++) {
		cout << kouyaku[i] << " " << kazu[i] << endl;
	}
}

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


int main(void)
{
  int a, b, x, y, z, i=0;

  scanf("%d %d", &a, &b);

  if(a != 0 && b != 0)
  {
    if(a >= b)
    {
      x = a;
      y = b;
    }

    else
    {
      x = b;
      y = a;
    }

  do{
      x = x%y;
      z = x;
      x = y;
      y = z;
      i++;
     }while(y!=0);

  printf("%d %d\n", x, i);
  }

  return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int cnt=0;;
	int i,j,n,m,amari,syo;
	while(1) {
		scanf("%d %d",&n,&m);
		if(n==0 && m==0) break;
		if(n<m) swap(n,m);
		while(1) {
			n=n%m;
			swap(n,m);
			cnt++;
			if(m==0) break;
		}
		printf("%d %d\n",n,cnt);
	}
	return 0;
}

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

int gcd(int a, int b, int cnt);

int main()
{
	int a, b;

	while (cin >> a >> b, a){
		int cnt = 0;
		gcd(a, b, cnt);
	}

	return (0);
}

int gcd(int a, int b, int cnt)
{
	if (b == 0){
		cout << a << " " << cnt << endl;
	}
	else {
		return (gcd(b, a % b, cnt + 1));
	}
}

C++: #include<stdio.h>
int main(void)
{
	long long int x,y,temp,X,cnt;
	while(1){
		cnt=0;
		scanf("%lld %lld",&x,&y);
		if(x==0&&y==0)break;
		while(1){
			if(y==0)break;
			cnt++;
			X=x%y;
			x=y;
			y=X;
		}
		printf("%lld %lld\n",x,cnt);
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a; i ++)
#define loop(i,b,a) for(int i = b ; i < a; i ++)
const int MAX = 50000;
bool p[MAX];
void isPrime(){
  fill(p,p + MAX,true);
  p[0] = p[1] = false;
  rep(i,MAX){
    if(p[i]){
      for(int j = i + i ; j < MAX ; j += i)
	p[j] = false;
    }
  }
} 

int main(void){
  isPrime();
  int n;
  while(cin>>n){

    int i;
 
    for(i = n-1 ; !p[i] ; i --);
    cout<<i<<" ";
    for(i = n+1 ; !p[i] ; i ++);
    cout<<i<<endl;
  }
  return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int x,y,temp,X,cnt;
	while(1){
		cnt=0;
		scanf("%d %d",&x,&y);
		if(x==0&&y==0)break;
		while(1){
			if(y==0)break;
			cnt++;
			X=x%y;
			x=y;
			y=X;
		}
		printf("%d %d\n",x,cnt);
	}
	return 0;
}

C++: #include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
using namespace std;
int main(){
  int x,y,c=0;
  while(cin>>x>>y,x!=0){
   if(x==y){
     cout<<x<<" "<<1<<endl;
     goto at;
   }
   while(y>0){
     x=x%y;
     int s=x;
     x=y;
     y=s;
     c++;
   }
   cout<<x<<" "<<c<<endl;
 at:;
 }
 return 0;   
}

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

int main()
{
	int X,Y,cnt;
	while(cin >> X >> Y, (X||Y))
	{
		cnt = 0;

		if(X<Y) swap(X,Y);
		while(Y!=0)
		{
			cnt++;
			X%=Y;
			swap(X,Y);
		}

		cout << X << " " << cnt << endl;
	}

	return 0;
}