Go: // AOJ Collatz's Problem :http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0158

package main

import (
	"fmt"
)

func main() {
	for {
		var n int

		fmt.Scanf("%d", &n)

		if n == 0 {
			break
		}

		count := 0
		for n != 1 {
			if n%2 == 0 {
				n /= 2
			} else {
				n = n*3 + 1
			}
			count++
		}
		fmt.Println(count)
	}
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


const int SIZE = 1000000;
int X[SIZE], Y[SIZE], H[SIZE], W[SIZE];
int n;

int solve() {
    int res = 0;
    for ( int i = 0; i < n; ++ i ) {
        int s = X[i] + Y[i] + H[i];
        if ( s <= 60 && W[i] <= 2 ) {
            res += 600;
        } else if ( s <= 80 && W[i] <= 5 ) {
            res += 800;
        } else if ( s <= 100 && W[i] <= 10 ) {
            res += 1000;
        } else if ( s <= 120 && W[i] <= 15 ) {
            res += 1200;
        } else if ( s <= 140 && W[i] <= 20 ) {
            res += 1400;
        } else if ( s <= 160 && W[i] <= 25 ) {
            res += 1600;
        }
    }
    return res;
}

int main() {
    while ( cin >> n && n ) {
        for ( int i = 0; i < n; ++ i ) {
            cin >> X[i] >> Y[i] >> H[i] >> W[i];
        }
        cout << solve() << endl;
    }
    return 0;
}

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

int main() {
	int n;
	while(cin >> n, n) {
		int count = 0;
		while(n != 1) {
			if(n % 2)
				n = n * 3 + 1;
			else
				n /= 2;
			count++;
		}
		cout << count << endl;
	}
}

C++: #include<iostream>
using namespace std;
int main()
{
  long int n;
  for(;cin>>n,n;)
    {
      int i=0;
      for(;n!=1;)
      {
	if(n%2==0)
	  n/=2;
	else
	  n=n*3+1;
	i++;
      }
      cout<<i<<endl;
    }
}

C++: #include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int collatz(int n){
	int ans = 0;
	while(n!=1){
		if(n%2)n = n * 3 + 1;
		else n = n/2;
		ans++;
	}
	return ans;
}
int main(){
	int n;
	while(cin >> n , n)
		cout << collatz(n) << endl;
}

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

int main()
{
  int n;
  while (cin >> n) {
    if (n == 0)
      break;

    int ans = 0;
    for (; n != 1; ++ans) {
      if (n&1)
	n = n * 3 + 1;
      else
	n /= 2;
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  long long int n;
  while(cin>>n,n){
    long long int co=0;
    while(n!=1){
      co++;
      if(n%2)n=3*n+1;
      else n/=2;
    }
    cout<<co<<endl;
  }
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    int n;
    while(cin >> n){
	if(n == 0) break;
	int ans = 0;
	while(n != 1){
	    if(n % 2 == 0)  n /= 2;
	    else n = 3*n + 1;
	    ans++;
	}
	cout << ans << endl;

    }
    return 0;
}

C++: #include <iostream>
using namespace std;
double a,b,t[8]={35.5,37.5,40.0,43.0,50.0,55.0,70.0,2e+9},u[8]={71.0,77.0,83.0,89.0,105.0,116.0,148.0,2e+9};
string s[8]={"AAA","AA","A","B","C","D","E","NA"};
int main(){
while(cin>>a>>b){
for(int i=0;i<8;i++){
if(a<t[i]&&b<u[i]){cout<<s[i]<<endl;break;}
}
}
}

C++: #include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define REP(i,a,n) for(int i = a ; i < n ; i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

int dp[1000002];

int solve(int n){
  if(n == 1) return 0;
  if(dp[n] != -1) return dp[n];

  return dp[n] = (solve(n%2==0 ? n/2 : n*3+1) + 1);
}

int main(){
  int n;
  memset(dp,-1,sizeof(dp));

  while(cin>>n,n){
    cout<<solve(n)<<endl;
  }
}

C++: #include<iostream>
#include<string>
#include<map>
using namespace std;
int main() {
	long long n;
	while (cin >> n&&n!=0) {
		int i = 0;
		while (n != 1) {
			if (n % 2 == 0) 
				n /= 2;
			else
				n = n * 3 + 1;
			i++;
		}
		cout << i << endl;
	}
}

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

int main()
{
	int n;
	while (cin >> n, n) {
		int i = 0;
		while (n != 1) {
			if (n & 1 == 1) {
				n = n * 3 + 1;
				i++;
			}
			else {
				n = n / 2;
				i++;
			}
		}
		cout << i << endl;
	}
    return 0;
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

map<long long int, int>mp;
int getans(const long long int n) {
	if (n < 0)assert(false);
	if (mp.find(n) != mp.end())return mp[n];
	else {
		int ans = n==1?0:n % 2 ? (1 + getans(3 * n + 1)) : (1 + getans(n / 2));
		return mp[n] = ans;
	}
}

int main() {
	while (1) {
		long long int N; cin >> N;
		if (!N)break;
		int ans = getans(N);
		cout << ans << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main() {
	int a;
	vector<int>l;
	while (cin >> a){
		if (a == 0) 
			break;
		int x = 0;
		while (a != 1){
			if (a % 2 == 1)
				a = a * 3 + 1;
			else a /= 2;
			x += 1;
		}
		l.push_back(x);
	}
	for (int i = 0; i != l.size(); i++)
	{
		cout << l[i] << endl;
	}
}

C++: #include<stdio.h>

int main(){
	int a;
	while(scanf("%d",&a),a){
		int n=0;
		while(a>1){
			if(a%2==0)a/=2;
			else a=a*3+1;
			n++;
		}
		printf("%d\n",n);
	}
}

C++: #include<bits/stdc++.h>

using namespace std;

int main()
{

  while(1){
    int num;
    cin>>num;
    if(num == 0){
      break;
    }

    int ans = 0;
    while(1){
      if(num % 2 == 0){
        num = num / 2;
      }
      else{
        num = 3 * num + 1;
      }

      ++ ans;
      if(num == 1){
        break;
      }
    }

    cout<<ans<<endl;
  }
  
  return 0;
}

C++: #include <iostream>
using namespace std;
int n;
int main(){
while(cin>>n){
if(!n)return 0;int ans=0;
while(n-1){
if(n%2)n=n*3+1;else n/=2;ans++;
}
cout<<ans<<endl;
}
}

C++: #include <iostream>

using namespace std;

int collatz( int num )
{
	if( num == 1 ) return 0;
	if( num%2 == 0 ) return 1+collatz(num/2);
	else return 1+collatz(num*3+1);
}

int main(void)
{
	int n;
	while( cin >> n ){
		if( n == 0 ) break;
		cout << collatz(n) << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
main(){
    int n; 
    while( cin >> n&&n){
	int t = 0;
	while(n != 1){
	    if ( n % 2 == 0 ) n /= 2;
	    else n = 3*n + 1;
	    t++;
	}
	cout << t << endl;
    }
}

C++: #include <stdio.h>

int main(void){
    int times;
    int n;
    
    while (scanf("%d", &n), n!=0){
        times=0;
        while (n!=1){
            n = n%2 ? 3*n+1 : n/2;
            times++;
        }
        printf("%d\n", times);
    }
    
    return 0;
}