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<algorithm>

using namespace std;

int num;

string toc(int num){
  string out;
  while(num > 0){
    out += num%10 + '0';
    num /= 10;
  }
  while(out.length() < 8) out += '0';
  reverse(out.begin(),out.end());
  return out;
}

int toi(string in){
  int out = 0;
  int plus = 1;
  for(int i = in.length()-1; i >= 0; i--){
    out += (in[i] - '0') * plus;
    plus *= 10;
  }
  return out;
}
void solve(){
  for(int i = 0; i < 10; i++){
    string sub;
    num = num*num;
    string str = toc(num);
    int flg = 0;
    for(int j = 2; j < 6; j++){
      sub += str[j];
      if(str[j] != '0') flg = 1;
      if(flg) cout << str[j];
    }
    cout << endl;
    num = toi(sub);
  }
}

int main(){
  int in;
  cin >> in;
  int rev = 0;
  for(int i = 0; i < in; i++){
    rev++;
    cin >> num;
    cout << "Case " << rev <<":" <<endl;
    solve();
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int next_num(int s) {
    int square = s * s;
    return (square % 1000000) / 100;
}

void print_random(int s) {
    int prev = s;
    for (int i = 0; i < 10; i++) {
        prev = next_num(prev);
        cout << prev << endl;
    }
}

int main() {
    int n; cin >> n;
    for (int i = 1; i <= n; i++) {
        int s; cin >> s;
        cout << "Case " << i << ":\n";
        print_random(s);
    }
    return 0;
}

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

using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 999999
#define rep(i,j) for(int i=0;i<(j);++i)
#define reps(i,j,k) for(int i=j;i<k;++i)
typedef long long ll;
typedef unsigned long long ull;

int Change(int num){
	 num *= num;
	char mid[10]={0};
	sprintf(mid,"%d",num);
	int len = strlen(mid);
	char str[10]={0};
	int z = 0;
	fill(str,str+8,'0');
	reps(i,8-len,8){
		str[i] = mid[z];
		z++;
	}
	char fin[10]={0};
	rep(i,4){
		fin[i] = str[i+2];
	}
	return atoi(fin);
}
int main(){
	int n;
	scanf("%d",&n);
	rep(i,n){
		int num;
		scanf("%d",&num);
		printf("Case %d:\n",i+1);
		rep(j,10){
			num = Change(num);
			printf("%d\n",num);
		}
	}
	return 0;
}

C++: #include <stdio.h>

int main(void)
{
	int i,j,repeat,dataset[10];
	
	scanf("%d",&repeat);
	for(j=0;j<repeat;j++)
	{
		scanf("%d",&dataset[j]);
	}
	
	for(j=0;j<repeat;j++)
	{
		printf("Case %d:\n",j+1);
		
		for(i=0;i<10;i++)
		{
			dataset[j]=(int)((dataset[j]*dataset[j])%1000000)/100;
			
			printf("%d\n",dataset[j]);
		}
	}
}

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

int f(int x, int k){
	int n=1;
	for(int i=0 ; i < k ; i++ ) n *= 10;
	return ((x / n) % 10) * (n / 100);
}

int main(){
	int n, s;
	cin >> n;
	for(int i=0 ; i < n ; i++ ){
		cin >> s;
		cout << "Case " << (i+1) << ":" << endl;
		for(int j=0 ; j < 10 ; j++ ){
			s = s * s;
			s = f(s, 2) + f(s, 3) + f(s, 4) + f(s, 5);
			cout << s << endl;
		}
	}
}

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<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n; cin>>n;
    for(int c=0;c<n;c++){
        string in; cin>>in;
        cout<<"Case "<<c+1<<" "<<endl;
        rep(i,10){
                    int num=pow(stoi(in),2);
                    in=to_string(num);

                string t;
                int cnt=in.size();
                while(cnt++ <8)t.push_back('0');
                t+=in;
                string ans; for(int i=2;i<=6;i++){
                    ans.push_back(t[i]);
                }
                cout<<stoi(ans)<<endl;
            in=ans;
        }
    }
}

C++: #include <cstdio>

int main()
{
  int n;
  scanf("%d", &n);
  for (int dataset = 1; dataset <= n; ++dataset) {
    int s;
    scanf("%d", &s);

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

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

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


  }
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    long long int a;
    cin>>n;
    for (int i=1;i<n+1;i++) {
        cin>>a;
        cout<<"Case "<<i<<":"<<endl;
        for (int j=0;j<10;j++) {
            a=a*a;
            string tmp=to_string(a);
            if (tmp.size()<8) {
                int hoge=8-tmp.size();
                for (int k=0;k<hoge;k++) {
                    tmp="0"+tmp;
                }
            }
            string tmp2=tmp.substr(2,4);
            a=stoi(tmp2);
            cout<<a<<endl;
        }
    }
}

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

using namespace std;

int main(void){

  int x = 1;

  int n;
  cin >> n;
  while( n-- ){
    
    double num;
    cin >> num;
    
    cout << "Case " << x++ << ":" <<  endl;
    for( int i = 0 ; i < 10 ; i++ ){
      
      num = pow( num , 2 );
      
      int N[4];
      N[0] = (int)num % 1000;
      N[1] = (int)num % 10000;
      N[2] = (int)num % 100000;
      N[3] = (int)num % 1000000;    

      //cout << N[0] << endl;
      //cout << N[1] << endl;
      //cout << N[2] << endl;
      //cout << N[3] << endl;

      N[0] /= 100;
      N[1] /= 1000;
      N[2] /= 10000;
      N[3] /= 100000;

      //cout << N[0] << endl;
      //cout << N[1] << endl;
      //cout << N[2] << endl;
      //cout << N[3] << endl;

      int ans = 0;
      ans = N[3]*1000 + N[2]*100 + N[1]*10 + N[0];

      cout << ans << endl;

      num = ans;      

    }
  }
  return 0;
}