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++: #include <iostream>
#include <sstream>
#include <cstdlib>
using namespace std;

void random(int s) {
  for(int i=0;i<10;i++) {
    stringstream ss;string str;
    s *= s;
    ss << s;
    ss >> str;
    int aftsize = str.size();
    if(aftsize <= 6) {
      s = atoi(str.substr(0,aftsize-2).c_str());
    }
    else if(aftsize > 6) {
      s = atoi(str.substr(aftsize-6,4).c_str());
    }
    cout << s << endl;
  }
}

int main() {
  int n,s;
  cin >> n;
  for(int i=0;i<n;i++) {
    cin >> s;
    cout << "Case " << i+1 << ":" << endl;
    random(s);
  }
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
using namespace std;

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

int main() {
  int n;
  cin >> n;
  REP(casen,n) {
    int a;
    cin >> a;
    cout << "Case " << casen+1 << ":" << endl;
    REP(k,10) {
      a*=a;
      stringstream ss;
      ss << a;
      string s = ss.str();
      int le = s.length();
      REP(i,8-le) {
        s = "0" + s;
      }
      a = atoi(s.substr(2,4).c_str());
      cout << a << endl;
    }
  }
}

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;
			itoa(s,ss,10);
			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;
}

C++: #include<cstdio>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    for(int l = 1; l <= n; l++){
        int x;
        scanf("%d",&x);
        printf("Case %d:\n",l);
        for(int i = 0; i < 10; i++){
            x *= x;
            x = x/100%10000;
            printf("%d\n",x);
        }
    }
    return 0;
}

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 << ":" << endl;
		for(int j=0;j<10;j++){
			w = w*w;
			w /= 100;
			w = w % 10000;
			cout << w << endl;
		}
	}
}

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

int random(int seed);

int main(void){
  int n;
  cin>>n;
  int x;
  for(int c=0;c<n;c++){
    cout<<"Case "<<c+1<<":"<<endl;
    cin>>x;
    for(int i=0;i<10;i++){
      x=random(x);
      cout<<x<<endl;
    }
  }
  return 0;
}


int random(int seed){
  int retval;
  retval=(seed*seed)/100;
  retval=retval%10000;
  return retval;
}

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


int main() {
    int n;

    cin >> n;
    for (int x = 1; x <= n; x++) {
        int s;
        cin >> s;

        cout << "Case " << x << ":" << endl;
        for (int i = 0; i < 10; i++) {
            s = (s * s / 100) % 10000;
            cout << s << endl;
        }
    }
    return 0;
}

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

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

C++: #include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <typeinfo>
#include <iomanip>
#include <sstream>
using namespace std;
int main(){
	int d,cnt;
	long long s,y;
	string str,ans="",x="";
	cin>>d;
	for(int i=1;i<=d;i++){
		cin>>s;
		cout<<"Case "<<i<<":"<<endl;
		for(int o=1;o<=10;o++){
			y=s*s;
			str=to_string(y);
			if(str.size()!=8){
				int num=8-str.size();
				for(int p=0;p<num;p++){
					ans+='0';
				}
				ans+=str;
			}else{
				ans=str;
			}
			if(ans.size()%2==0){
				cnt=ans.size()/2-2;
			}else{
				cnt=ans.size()/2-3;
			}
			for(int k=cnt;k<cnt+4;k++){
				x+=ans[k];
			}
			cout<<stoi(x)<<endl;
			s=stoi(x);
			ans="";
			x="";
		}
	}
	return 0;
}

C++: #include <stdio.h>
int rand(int s);
int main(){
	 int i,s,j=1,n;
	 int a[8];
	 scanf("%d",&n);
	 while(n--){
		 scanf("%d",&s);
		 for(i=0;i<10;i++) s = rand(s);
		 printf("%d\n",s);
	 }

	 return 0;
}

int rand(int s){
	int i,r=0,j=0;
	s *= s;s /= 100;
	for(i=1;i<1001;i*=10){
		r += (s%10)*i;
		j++;
		s /= 10;
	}
	return r;
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"
string to_string_keta(const long long int l, const int keta) {
	ostringstream oss;

	oss << std::setw(keta) << std::setfill('0') << l;

	return oss.str();
}

int main() {
	int num = 0;
	int N;

	while (cin >> N) {
		if (num) {
			cout << "Case " << num << ":" << endl;
			for (int i = 0; i < 10; ++i) {
				N *= N;
				string st = to_string_keta(N, 8);
				N = stoi(st.substr(2, 4));
				cout << N << endl;
			}
		}
		num++;
	}
	return 0;
}

C++: #include<stdio.h>

int main(){

	int a;
	scanf("%d",&a);
	for(int i=0;i<a;i++){
		printf("Case %d\n",i+1);
		int b;
		
		scanf("%d",&b);
		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 q;
  cin >> q;

  for(int i=0;i<q;i++) {
    
    int b;
    cin >> b;
    cout <<"Case "<<i+1<<endl;
    for(int j=0;j<10;j++) {
      int a[8] = {};  
      b *= b;
      for(int k=7;k>=0;k--) {
	a[k] = b % 10;
	b /= 10;
      }
      int t = 1;
      b = 0;
      for(int k=5;k>=2;k--) {
	b += a[k]*t;
	t*=10;
      }
      cout << b << endl;
    }


  }

  return 0;
}

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

using namespace std;

string i_s(int n){
  stringstream s;
  string str;

  s << n;
  s >> str;

  return str;
}

int s_i(string str){
  stringstream s(str);
  int num;

  s >> num;

  return num;
}

int main(){
  string str;
  int n;

  cin >> n;
  for(int i = 0 ; i < n ; i++){
    cout << "Case " << i+1 << ":" << endl;
    cin >> str;
    int num = s_i(str);
    for(int j = 0 ; j < 10 ; j++){
      num = num * num;
      string s = i_s(num);
      reverse(s.begin(),s.end());
      for(int k = (int)s.size() ; k < 8 ; k++){
	s += "0";
      }      
      reverse(s.begin(),s.end());
      string ss = s.substr(2,4);
      num = s_i(ss);
      cout << num << endl;
    }
  }

  return 0;
}