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++: #define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<char,int> P;

static const double eps = 10e-9;

int getNum(int num){
	int a = num * num;
	int res=0;
	a/=100;
	for(int i=0;i<4;i++){
		res += (a % 10) * pow(10.0,i);
		a/=10;
	}

	return res;
}

int main(){
	int n;
	while(~scanf("%d",&n)){
		for(int i=0;i<n;i++){
			int num;
			scanf("%d",&num);
			printf("Case %d:\n",i+1);
			for(int j=0;j<10;j++){
				num = getNum(num);
				printf("%d\n",num);
			}
		}
	}
}

C++: #include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <iomanip>
using namespace std;
int main(){
	string x,ans="";
	long long s,cnt=1,num;
	int d;
	cin>>d;
	for(int k=1;k<=d;k++){
		cin>>s;
		cout<<"Case "<<cnt<<":"<<endl;
		for(int i=1;i<=10;i++){
			s=s*s;
			num=(int)log10((double)s) + 1;
			if(num<8){
				for(int j=8;j>num;j--){
					ans+="0";
				}
				ans+=to_string(s);
			}else{
				ans=to_string(s);
			}
			x="";
			for(int i=2;i<=5;i++){
				x+=ans[i];
			}
			ans="";
			s=stoi(x);
			cout<<s<<endl;
		}
		cnt++;
	}
	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>

using namespace std;

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

C++: #include<stdio.h>

int main(){

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

C++: #include <iostream>
using namespace std;
int main(){
	int d,cnt=1;
	long long s;
	cin>>d;
	for(int i=1;i<=d;i++){
		cin>>s;
		cout<<"Case "<<cnt++<<":"<<endl;
		for(int j=0;j<10;j++){
			s=((s*s)/100)%10000;
			cout<<s<<endl;
		}
	}
	return 0;
}

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

int main(void){
  int n,s;
  cin>>n;
  for(int x=0;x<n;++x){
    cin>>s;
    cout<<"Case "<<x+1<<":"<<endl;
    for(int i=0;i<10;++i){
      stringstream ss;
      ss<<s*s;
      string a,b;
      ss>>a;
      for(;a.size()<2*4;)a="0"+a;
      b=a.substr(a.size()/2-4/2,4);
      ss.clear();
      ss<<b;
      ss>>s;
      cout<<s<<endl;
    }
  }
  return 0;
}

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

int main() {
	int n;
	cin >> n;
	for (int x = 1; x <= n; x++) {
		int a;
		cin >> a;
		cout << "Case " << x << ":\n";
		for (int i = 0; i < 10; i++) {
			a *= a;
			int res = 0;
			a -= (a / 10000000) * 10000000;
			a -= (a / 1000000) * 1000000;
			res += (a / 100000) * 1000;
			a -= (a / 100000) * 100000;
			res += (a / 10000) * 100;
			a -= (a / 10000) * 10000;
			res += (a / 1000) * 10;
			a -= (a / 1000) * 1000;
			res += a / 100;
			cout << res << endl;
			a = res;
		}
	}
	return 0;
}

C++: #include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

int frand(int n){
	char s[10];
	sprintf(s,"%d",n*n);
	int len=strlen(s);
	
	n=0;
	int idx=len-6;
	while(idx<len-2){
		if(idx<0){
			++idx;
			continue;
		}else{
			n=10*n+(s[idx]-'0');
			++idx;
		}
	}
	
	return n;
}

int main(){
	int n;
	cin>>n;
	int count=0;
	while(n--){
		++count;
		int s;
		cin>>s;
		cout<<"Case "<<count<<":"<<endl;
		for(int i=0;i<10;i++){
			s=frand(s);
			cout<<s<<endl;
		}
	}
}

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

int main()
{
	int n, count = 0, i, j, p;
	stringstream ss;
	cin>>n;
	while (cin>>n) {
		cout<<"Case "<<++count<<":"<<endl;
		for (i = 0; i < 10; i++) {
			ss.str("");
			ss<<setw(8)<<setfill('0')<<right<<n*n<<endl;
			n = 0; p = 1;
			for (j = 0; j < 4; j++) {
				n += p*(ss.str()[5-j]-'0');
				p *= 10;
			}
			cout<<n<<endl;
		}
	}
	return 0;
}

C++: #include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> VI;
typedef pair<int,int> PII;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;

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

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

int main(){
	
	int N , x ;
	
	cin >> N ;
	for( int c=1 ; c<=N ; c++ ){
		cin >> x ;
		
		printf("Case %d:\n",c) ;
		
		for( int i=0 ; i<10 ; i++ ){
			x *= x ;
			x /= 100 ;
			int tmp = 0 , p = 1 ;
			for( int k=0 ; k<4 ; k++ ){
				tmp += ( x%10 ) * p ;
				x /= 10 ;
				p *= 10 ;
			}
			x = tmp ;
			cout << x << endl ;
		}
	}
	
return 0;
}

C++: //06
#include<iostream>

using namespace std;

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

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

using namespace std;

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

C++: #include<iostream>
using namespace std;
int main(void){
  int n,m,i=1,j;
  for(cin>>m;i<=m;i++){
    cout<<"Case "<<i<<":"<<endl;
    for(cin>>n,j=0;j<10;j++){
      n=((n*n)%1000000)/100;
      cout<<n<<endl;
    }
  }
}