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 <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

string itos_withzero (int n)
{
	stringstream ss;
	ss << n;
	string str;
	ss >> str;

	int len = str.length();

	if (len < 8 ){
		str = string(8-len, '0') + str;
	} // end if

	return str;
} 
int stoi (string str )
{
	stringstream ss(str);
	int n;
	ss >> n;

	return n;
}

int middlesquare (int s )
{
	int res = 0;
	int m = s*s;

	string str = itos_withzero(m);

	str = str.substr (2, 4);
//	cout << str << endl;
	res = stoi (str);
//	cout << itos (m) << endl;

	return res;
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.ms", "r", stdin );
	string str = "";
	int n;

	getline (cin, str );
	stringstream ssn(str);
	ssn >> n;

	int i,j;
	for (i = 0; i < n; ++i){
		int s = 0;
		int res = 0;
		cout << "Case " << (i + 1) << ':' << endl;
		getline (cin, str );
		stringstream ss(str);
		ss >> s;

		for (j = 0; j < 10; ++j){
			res = middlesquare (s);
			cout << res << endl;
			s = res;
		} // end for
	} // end loop
		
	return 0;
}

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

int main(){
    char num[9],a[5];
    int n,tmp;
    cin >> n;
    for(int j=0;j<n;j++){
        cin >> tmp;
        cout << "Case " << j+1 << ":" << endl;
        for(int i=0;i<10;i++){
            tmp *= tmp;
            sprintf(num,"%08d",tmp);
            for(int i=0;i<4;i++) a[i] = num[i+2];
            tmp = atoi(a);
            cout << tmp << endl;
        }
    }
}

C++: #include<iostream>

using namespace std;

int main()
{
  int n;
  cin>>n;
  for(int i=1;i<=n;i++)
    {
      int s;
      cin>>s;
      cout<<"Case "<<i<<":"<<endl;
      for(int i=0;i<10;i++)
	{
	  int tmp=s*s;
	  tmp/=100;
	  tmp%=10000;
	  s=tmp;
	  cout<<tmp<<endl;
	}
    }
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <climits>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()


struct Edge {
    int to, cost, nm;
    Edge(int to, int cost, int nm): to(to), cost(cost), nm(nm) {}
};

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<Edge>> AdjList;
AdjList graph;
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
const int INF = 100000000;

ll GCD(ll a, ll b){
    if(a < b) swap(a, b);
    if(b == 0) return a;
    return GCD(b, a%b);
}

bool cmp(const pii& a, const pii& b){
    if(a.first == b.first){
        return a.second < b.second;
    }
    return a.first < b.first;
}

int arr[6];
int main() {


    int d; cin >> d;
    REP(i, d){
        cout << "Case " << i+1 << ":" << endl;
        int n; cin >> n;

        for(int j=0; j<10; ++j){
            n = n*n;
            int nn = 0;
            for(int k=3; k>=0; --k){
                nn = nn*10 + (int)(n/pow(10, k+2))%10;
            }

            n = nn;
            cout << n << endl;
        }
    }
    return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;
int main(void){

	int n;
	cin>>n;
	for(int i=0;i<n;i++){
        int s;
        cin>>s;
        cout<<"Case "<<i+1<<":"<<endl;
        for(int j=0;j<10;j++){

            s*=s;
            //cout<<s<<endl;
            s%=1000000;
            //cout<<s<<endl;
            s-=s%100;
            //cout<<s<<endl;
            s/=100;
            cout<<s<<endl;
        }
	}



	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    for(int i=1;i<=n;i++){
        int a;
        cin >> a;
        cout << "Case " << i << ":" << endl;
        for(int j=0;j<10;j++){
            a *= a;
            a = a/100;
            int tmp = a/10000*10000;
            a = a-tmp;
            cout << a << endl; 
        }
    }
    return 0;
}

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

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

int n;

string i2s(int a) {
  stringstream ss;
  ss << a;
  return ss.str();
}

int main() {
  scanf("%d", &n);
  rep (loop,n) {
    printf("Case %d:\n", loop + 1);
    int a;
    scanf("%d", &a);
    rep (i,10) {
      a *= a;
      string temp = i2s(a);
      while (temp.size() != 8) { temp.insert(0, 1, '0'); }
      string next = temp.substr(2, 4);
      a = atoi(next.c_str());
      printf("%d\n", a);
    }
  }
  return 0;
}

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


using namespace std;

int main(void){
	int n,s;
	scanf("%d",&n);
	for(int a=1;a<=n;a++){
		scanf("%d",&s);
		printf("Case %d:\n",a);
		for(int i=0;i<10;i++){
			char ss[8],sss[4];
			int rank=0;
			s=s*s;
			if(s>=100)rank=1;
			if(s>=1000)rank=2;
			if(s>=10000)rank=3;
			if(s>=100000)rank=4;
			if(s>=1000000)rank=5;
			if(s>=10000000)rank=6;
			sprintf(ss,"%d",s);
			int sk=0;
			for(int j=rank-4;j<rank;j++){
				if(j>=0){
					sss[sk]=ss[j];
					sk++;
				}
			}
			s=atoi(sss);
			printf("%d\n",s);
		}
	}
    return 0;
}