Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < n; i++ {
		scanner.Scan()
		seed, _ := strconv.Atoi(scanner.Text())
		fmt.Printf("Case %d:\n", i+1)
		for j := 0; j < 10; j++ {
			tmp := fmt.Sprintf("%08d", seed*seed)
			seed, _ = strconv.Atoi(tmp[2:6])
			fmt.Println(seed)
		}
	}
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int n, a;

int main(){
	cin >> n;
	REP(i, n){
		cin >> a;
		cout << "Case " << i + 1 << ":" << endl;
		REP(i, 10){
			a = a*a / 100;
			a %= 10000;
			cout << a << endl;
		}
	}
}

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

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){
	int n;
	int N=4;
	cin>>n;
	rep(i, n){
		ll s;
		cin>>s;
		int cnt = 0;
		cout <<"Case "<<i+1<<":"<<endl;
		while(true){
			cnt++;
			s *=s;
			stringstream ss;
			ss <<s;
			string tmp =ss.str();
			while(tmp.length()!=8){
				tmp ="0"+tmp;
			}
			//cout <<"tmp1 = "<<tmp<<endl;

			tmp =tmp.substr(2,4);
			s =0;
			//cout <<"tmp = "<<tmp<<endl;
			for(int i =0;i < 4;i++){
				s +=(tmp[i]-'0')*(pow(10.0,3-i));
			}
			cout <<s<<endl;
			if(cnt==10){
				break;
			}
		}
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#include<map>
#include<set>
#include<complex>
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		cout << "Case 1:" << endl;
		for (int j = 0; j < 10; j++) {
			string s;
			x *= x;
			string t = to_string(x);
			for (int k = 0; k < 8 - t.length(); k++) {
				s += '0';
			}
			s += t;
			x = stoi(s.substr(2, 4));
			cout << x << endl;

		}
	}
	return 0;
}

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

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int n,k;
	n=in();
	for(k=0;k<n;k++){
		cout<<"Case "<<k+1<<":\n";
		int x=in();
		int i=10;
		while(i--){
			x*=x;
			x/=100;
			x%=10000;
			cout<<x<<endl;
		}
	}
	return 0;
}

C++: import java.util.Scanner;

public class Main
{
	public static void main(String arg[])
	{
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int ca=1;
		while(n-->0)
		{
			System.out.println("Case "+ca+":");
			int x = sc.nextInt();
			for(int i=0; i<10; i++)
			{
				x*=x;
				String str = String.valueOf(x);
				// str = x+"";
				while(str.length()<8)
				{
					str = "0"+str;
				}
				x = Integer.valueOf(str.substring(2,6));
				System.out.println(x);
			}
			ca++;
		}
	}
}

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

using namespace std;

vector<int> temp;

void Compute(int num);

int main() {

	int n;
	cin >> n;
	int j = 1;

	while (n--) {

		int num;
		cin >> num;
		cout << "Case " << j << ":\n";

		for (int i = 0; i < 10; i++) {

			temp.clear();
			Compute(num);
			num = temp[5] * 1000 + temp[4] * 100 + temp[3] * 10 + temp[2];
			cout << num << "\n";

		}

		j++;

	}

	return 0;

}

void Compute(int num) {

	num *= num;
	while (num) {

		temp.push_back(num % 10);
		num /= 10;

	}

	int times = temp.size();
	for (int i = 0; i < 8 - times; i++)
		temp.push_back(0);
}

C++: #include<iostream>
#include<iomanip>
#include<sstream>
#include<string>

int n, s;

int main()
{
	std::cin >> n;
	for( int i = 0; i != n; ++i )
	{
		std::cin >> s;

		std::cout << "Case " << i + 1 << ':' << std::endl;;
		for( int j = 0; j != 10; ++j )
		{
			int t = s * s;
			std::ostringstream oss;
			oss << std::setw( 8 ) << std::setfill( '0' ) << t;
			std::istringstream iss( oss.str().substr( 2, 4 ) );
			iss >> s;
			std::cout << s << std::endl;
		}
	}

	return 0;
}

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

int main(){
    int x;
    cin >> x;
    for(int i=0; i < x; i++){
        int value;
        cout << "Case " << i+1 << ":" << endl;
        cin >> value;
        for(int j=0; j < 10; j++){
            value = pow(value, 2);
            value = value/100%10000;
            cout << value << endl;
        }
    }
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n,a;

int d_count(int x){
  int res=0;
  while(x>0){
    res++;
    x/=10;
  }
  return res;
}

vector<int> compute(int x){
  vector<int>res;
  x=x*x;
  int cnt = d_count(x);
  while(x>0){
    res.push_back(x%10);
    x/=10;
  }
  for(int i=0;i<(8-cnt);i++)res.push_back(0);
  reverse(res.begin(),res.end());
  return res;
}

int main(){
  vector<int>t;
  cin>>n;
  for(int I=1;I<=n;I++){
    t.clear();
    cin>>a;
    cout<<"Case "<<I<<':'<<endl;
    for(int i=0;i<10;i++){
      t=compute(a);

      //for(int i=0;i<t.size();i++)cout<<t[i]<<' ';cout<<endl;
      a=t[2]*1000+t[3]*100+t[4]*10+t[5];
      cout<<a<<endl;
    }
  }
  return 0;
}