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 <cmath>
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 = a/100;
            int tmp = a/10000*10000;
            a = a-tmp;
            cout << a << endl; 
        }
    }
    return 0;
}

C++: #include <iostream>
#include <cmath>
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 = a/100;
            int tmp = a/10000*10000;
            a = a-tmp;
            cout << a << endl; 
        }
    }
    return 0;
}

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>
#include<cstdio>
#include<cstdlib>
#include<stdexcept>
#include<cmath>
#include<memory>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define pf push_front
#define LIM 100000
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef long long ll;
typedef unsigned long long ull;

class AOJ0137{
private:
  int val;
public:

  AOJ0137(int val):val(val){}

  string itos(int v){
    stringstream ss;
    ss << v;
    return ss.str();
  }

  void run(){
    rep(i,10){
      val *= val;
      string pre = itos(val);
      if(pre.size() < 8){	
	string p = string(8-pre.size(),'0')+pre;
	pre.clear(),pre = p;
      }
      string next = pre.substr(2,4);
      cout << next << endl;
      val = (atoi)(next.c_str());
    }
  }

};

int main(){
  int n;
  cin >> n;
  rep(i,n){
    
    int val;
    cin >> val;
    AOJ0137 ans(val);
    cout << "Case " << i+1 << ":" << endl;
    ans.run();
  }
return 0;
}

C++: #define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,n) for(int i=1;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl

using namespace std;
int main(){
	int n;
	int count=1;
	cin>>n;
	while(n--){
		int s;
		int p[12]={0};
		cin>>s;
		p[0]=s;
		REP(i,11){
			int d=pow(p[i-1],2);
			string a=to_string(d);
			string b="";
			while(a.size()<8){
				a='0'+a;
			}
			//debug(a);
			for(int j=2;j<=5;j++)
				b+=a[j];
			p[i]=stoi(b);
		}
		cout<<"Case "<<count++<<":"<<endl;
		REP(i,11)
			cout<<p[i]<<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=1;i<n+1;i++)
	{
		printf("Case %d:\n",i);
		for(a=0;a<10;a++)
		{
			printf("%d\n",c[i]=(c[i]*c[i])/100%10000);
		}
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
int main(void){
  int n;
  cin>>n;
  for(int k=0;k<n;k++){{
      int a;
      cin>>a;
      printf("Case %d:\n",k+1);
      for(int i=0;i<10;i++){
	long long sq=a*a;
	long long s=sq;
	s/=1000000;s*=1000000;
	sq-=s;
	sq/=100;
	cout<<sq<<endl;
	a=sq;
      }
    }
  }
  return 0;
}

C++: #include <iostream>
#include <cmath>
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 = a/100;
            int tmp = a/10000*10000;
            a = a-tmp;
            cout << a << endl; 
        }
    }
    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;

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

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



int MyRandom(int n, int m){
    string str = "";
    int num = 0;
    n *= n;

    while(1){
        str.insert( str.begin() , (n%10) + '0' );
        n /= 10;
        if( str.size() == 2*m ) break;
    }
    str = str.substr( m/2 , m );

    for(int i=0 ; i<str.size() ; i++){
        num *= 10;
        num += str[i] - '0';
    }

    return num;
}

int main(){
    int n, a, r;
    const int m = 4;

    cin >> n;
    for(int i=0 ; i<n ; i++){
        cin >> r;
        cout << "Case " << (i+1) << ":" << endl;
        for(int j=0 ; j<10 ; j++){
            if( j != 0 ){
                r = MyRandom( r , m );
            }
            cout << MyRandom( r , m ) << endl;
        }
    }
}

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



//----- 値変換関数 -----//
int f_change(int);

int main(void)
{
	//入力回数
	int n = 0;
	//入力回数
	int random = 0;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cout << "Case" << " " << i + 1 << ":" << endl;
		//入力
		cin >> random;

		for (int j = 0; j < 10; j++)
		{
			random = f_change(random * random);
			cout << random << endl;
		}
	}

	return 0;
}


//*****----- 値変換関数 -----*****//

int f_change(int n)
{
	//変換文字列
	char str_change[9] = {NULL};//文字列初期化

	//割って文字列に格納する変数
	int h_waru[7] = {10000000 , 1000000 , 100000 , 10000 , 1000 , 100 , 10};

	//4桁分格納する変数
	int h_kakeru[4] = {1000 , 100 , 10 , 1};

	//割った値を順番に格納
	for (int i = 0; i < 7; i++)
	{
		str_change[i] = n / h_waru[i];
		n %= h_waru[i];
	}
	//8番目は直接
	str_change[7] = n;

	//nを一度初期化
	n = 0;

	for (int i = 0; i < 4; i++)
	{
		n += str_change[i + 2] * h_kakeru[i];
	}

	return n;
}

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

void random(int s) {
  int x;
  for(int i = 0; i < 10; ++i) {
	if(i == 0) {
	  x = (s * s / 100) % 10000;
	}
	else {
	  x = (x * x / 100) % 10000;
	}
	cout << x << endl;
  }
}
int main() {
  int n;
  int s[10];
  cin >> n;

  for(int i = 0; i < n; ++i) {
	cin >> s[i];
  }

  for(int i = 0; i < n; ++i) {
	cout << "Case " << i + 1 << ":" << endl;
	random(s[i]);
  }
}

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