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 <sstream>
#include <iostream>


using namespace std;

int dataset,aiju;

int main(int argc,char **argv){
  cin >> dataset;
  for(int rupu=0;rupu<dataset;rupu++)
    {
      printf("Case %d:",++aiju); cout << endl;
      int s;
      cin >> s;
      for(int itiToJuu=0;itiToJuu<10;itiToJuu++)
	{
	  s = s * s;
	  stringstream ss;
	  ss << s;
	  string sutoring;
	  ss >> sutoring;

	  s = 0;
	  for(int aaa=(int)sutoring.size()-6;aaa<(int)sutoring.size()-2;aaa++)
	    {
	      if( aaa < 0 )
		{
		  continue;
		}
	      else 
		{
		  s = s * 10;
		  s = s + sutoring[aaa] - '0';
		  cout << sutoring[aaa];
		}
	    }
	  cout << endl;
	}
    }
  return 0;
}

C++: i,t;main(k){for(;t=~scanf("%d",&k);)if(i--)for(printf("Case %d:\n",~i),t=9;printf("%d\n",k=k*k/100%10000),t--;);}

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

C++: #include<cstdio>

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

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }


int calc(int x)
{
	stringstream ss; ss << x * x;
	string num(ss.str());
	int res = 0;
	
	while(num.size() != 8) num = "0" + num;	
	
	rep(i, 4)
	{
		res *= 10;
		res += num[i + 2] - '0';
	}
	
	return res;
}

int main()
{
    int n;
	cin >> n;
	
	rep(i, n)
	{
		int x;
		
		cin >> x;
		
		cout << "Case " << i + 1 << ":" << endl;
		
		rep(j, 10)
		{
			x = calc(x);
			cout << x << endl;
		}
	}
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<list>


using namespace std;


int main()
{
	int n, num;


	ios::sync_with_stdio(false);

	cin >> n;

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



	return 0;

}

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

int main()
{
	int n;
	cin>>n;
	for(int k=1;k<=n;k++)
	{
		printf("Case %d:\n",k);
		int s;cin>>s;
		for(int i=0;i<10;i++)
		{
			s=s*s;
			stringstream ss;
			ss<<s;
			string st=ss.str();
			reverse(st.begin(),st.end());
			for(int j=st.size();j<8;j++)st+="0";
			reverse(st.begin(),st.end());
			string ans;
			for(int j=2;j<2+4;j++)
			{
				ans+=st[j];
			}
			s=atoi(ans.c_str());
			cout<<s<<endl;
		}
	}
}

C++: #include <stdio.h>
int n, s, c;
int main() {
	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++) {
			s = s * s / 100 % 10000;
			printf("%d\n", s);
		}
	}
	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
void random(int x)
{
	int next=x;
	for(int i=0;i<10;i++)
	{
		next=next*next;
		int t=((next%1000000)-(next%100))/100;
		next=t;
		cout << next << endl;
	}
	return;
}
int main()
{
	int n;
	cin >> n;
	for(int i=0;i<n;i++)
	{
		printf("Case %d:\n",i+1);
		int k;
		cin >> k;
		random(k);
	}
	return 0;
}

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<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j,k;
  int n;
  cin>>n;
  rep(i,n){
    int a;
    cin>>a;
    cout<<"Case "<<i+1<<":"<<endl;
    rep(j,10){
      a=a*a;
      vi v(8);
      rep(k,8){
	v[k]=a%10;
	a/=10;
      }
      a=0;
      int t=1;
      rep(k,4){
	a+=v[2+k]*t;
	t*=10;
      }
      cout<<a<<endl;
    }
  }
}

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

int n, s;

int main(){
	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++){
			int tmp = 0;
			s *= s;
			for(int k = 0; k < 4; k++) tmp += ((s%(int)pow(10,6-k))/(int)pow(10,5-k))*(int)pow(10,3-k);
			printf("%d\n", tmp);
			s = tmp;
		}
	}
}

C++: #include<cstdio>

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

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

int gen_rand(int r) {
  return ((r * r)%1000000)/100;
}

int main() {
  int n, r;
  cin >> n;
  for (int i=0; i<n; i++) {
    cout << "Case " << i+1 << ":" << endl;
    cin >> r;
    for (int j=0; j<10; j++) {
      r = gen_rand(r);
      cout << r << endl;
    }
  }
  return 0;
}

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

#define pb push_back
#define fr first
#define sc second
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pii> pip; 
const int INF = (1<<25);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main() {

  int n;
  cin>> n;
  for(int num=0; num<n; num++) {
    int s;
    cin>> s;
    int rand_num=s;
    printf("Case %d:\n", num+1); 
    for(int i=0; i<10; i++) {
      rand_num*=rand_num;
      rand_num%=1000000;
      rand_num/=100;
      printf("%04d\n",rand_num);
    }
  }
}