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<vector>
#include<sstream>
#include<algorithm>
#include<iomanip>
using namespace std;
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cout<<"Case "<<i<<":"<<endl;
        int s;
        cin>>s;
        stringstream ss;
        ss<<setw(8)<<setfill('0')<<s*s;
        string str;
        ss>>str;
        for(int j=0;j<10;j++){
            ss.clear();
            str=str.substr(2,4);
            ss<<str;
            int a;
            ss>>a;
            ss.clear();
            cout<<a<<endl;
            ss<<setw(8)<<setfill('0')<<a*a;
            ss>>str;
        }

    }
}

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

int main(void){
	int n,m;
	cin>>m;
	for(int i=1;i<=m;i++){
		cin>>n;
		cout<<"case"<<i<<":"<<endl;
		for(int j=0;j<10;j++){
			n=n*n;
			n=((n%1000000)/100);
			cout<<n<<endl;
		}
	}
}

C++: #include<iostream>
#include<sstream>
#include<string>
#include<cstdio>
using namespace std;
int main(){
long n,m,i,j;
string s,t;
stringstream ss;
string::size_type k;
char mm[9];
cin>>n;
for(i=0;i<n;i++){
cin>>m;
cout<<"Case "<<i+1<<":"<<endl;
for(j=0;j<10;j++){
sprintf(mm,"%08d",m*m);
s=string(mm);
t=s.substr(2,4);
k=t.find_first_not_of('0');
if(k==string::npos)cout<<'0'<<endl;else cout<<t.substr(k)<<endl;
ss.str("");ss.clear();
ss<<t;
ss>>m;
}
}
return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int x=1,cn,n;

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

C++: #include <bits/stdc++.h>
using namespace std;

int n = 4;

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

int main(void){
  int s;
  int cnt = 1;
  int num;
  cin >> num;
  while(num--){
    cin >> s;
    cout << "Case " << cnt  << ":" << endl;
    cnt++;
    for(int q=0; q < 10; q++){
      int u = s * s;
      string t(int2str(u));
      t.insert(0, 2*n - t.length(), '0');
      t = t.substr(n/2, n);
      s = atoi(t.c_str());
      cout << s << endl;
    }
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; ++i)
	{
		int Num;
		cin >> Num;
		cout << "Case " << i << ":" << endl;
		for(int j = 0; j < 10; ++j)
		{
			Num *= Num;
			Num %= 1000000;
			Num /= 100;
			cout << Num << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

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

int main()
{
  int n, s;

  scanf("%d", &n);
  for (int i = 0; i < n; i++){
    scanf("%d", &s);
    printf("Case %d:\n", i + 1);
    for (int j = 0; j < 10; j++){
      printf("%d\n", s = s * s / 100 % 10000);
    }
  }

  return (0);
}

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

int main()
{
	int n;

	while( 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;
				int d[ 4 ];
				s /= 100;
				for( int k = 0; k < 4; ++k ){
					d[ k ] = s % 10;
					s /= 10;
				}
				s = 0;
				for( int k = 0; k < 4; ++k ){
					s *= 10;
					s += d[ 4 - 1 - k ];
				}
				cout << s << endl;
			}
		}
	}

	return 0;
}

C++: #include<iostream>

using namespace std;
typedef unsigned long long ullong;

int n, it;
ullong s;

ullong power( ullong b, int t ){
    int v = 1;
    for ( int i = 0; i < t; i++ ) v *= b;
    return v;
}

void compute(){
    n = 4;
    it = 10;
    cin >> s;

    for ( int i = 0; i < it; i++ ){
	s = s*s;
	s = s % ( power( 10, n + n/2) );
	s = s / ( power( 10, n/2) );
	cout << s << endl;
    }
}

main(){
    int tcase; cin >> tcase;
    for ( int i = 0; i < tcase; i++ ) {
	cout << "Case " << i+1 << ":" << endl;
	compute();
    }
}

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

int main(void){
  int n;
  cin >> n;
  for(int t = 0; t < n; t++){
    int s;
    cin >> s;
    cout << "Case " << t + 1 << ":" << endl;
    for(int i = 0; i < 10; i++){
      s *= s;
      string str = to_string(s);
      if(str.size() < 8){
        int c = 8 - str.size();
        for(int j = 0; j < c; j++) str.insert(str.begin(), '0');
      }
      s = stoi(string(str, 2, 4));
      cout << s << endl;
    }
  }
}

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()
{
    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 /= 100;
            a %= 10000;
            cout << a << endl;
        }
    }
}

C++: #include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

int main()
{
    int n; cin >> n;

    rep(k,n)
    {
        int r;
        cout << "Case " << k+1 << ":" << endl;
        cin >> r;

        REP(10)
        {
            r = ((r * r) %(1000*1000))/100;
            cout << r << endl;
        }

    }

    return 0;
}

C++: #include<string>
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int main(){
  int n,a;
  char str[10];

  scanf("%d", &n);
  for(int i=0; i<n; i++){
    cin >> a;
    cout << "Case " << i+1 << ":" << endl;
    for(int j=0; j<10; j++){
    sprintf(str,"%08d",a*a);
    string str2 = string(str);
    string str3 = str2.substr(2,4);
    a = atoi(str3.c_str());
    cout << a << endl;
    }
  }
  return 0;
}

C++: #include <cstdio>

int d,s;

int main(){
	scanf("%d",&d);
	for(int i = 1; i <= d; i++){
		scanf("%d",&s);
		printf("Case %d:\n",i);
		for(int j = 0; j < 10; j++){
			int nxt = s*s;
			nxt %= 1000000;
			nxt /= 100;
			printf("%d\n",nxt);
			s = nxt;
		}
	}
	return 0;
}

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

int stoi(string str) {
  int ans = 0;
  for(int i = 0; i < str.length(); i++) {
    ans += ((int)str[i]-(int)'0') * (int)pow(10.0, (int)str.length()-i-1);
  }
  return ans;
}

int main() {
  int n;
  cin >> n;
  for(int t = 0; t < n; t++) {
    int x;
    cin >> x;
    cout << "Case " << t+1 << ":" << endl;
    for(int i = 0; i < 10; i++) {
      char s[9];
      int newX = x*x;
      sprintf(s, "%.8d", newX);
      string str = "00000000";
      for(int j = 0; j < 8; j++) {
	str[j] = s[j];
      }
      x = stoi(str.substr(2, 4));
      cout << x << endl;
    }
  }
  return 0;
}

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

int main(){
	int c[8];
	int N,S;
	cin>>N;
	for(int ds=1;ds<=N;ds++){
		printf("Case %d:\n",ds);
		cin>>S;
		for(int cnt=0;cnt<10;cnt++){
			S *= S;
			for(int i=0, w=1e7; i<8; i++, w/=10){
				c[i] = (S/w)%10;
			}
			S = 0;
			for(int i=2, w=1e3; i<6; i++, w/=10){
				S += c[i]*w;
			}
			printf("%d\n",S);
		}
	}
	return 0;
}