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

using namespace std;

int main () {
  stringstream s;
  string str;
  int num;
  int n;
  int len;
  
  cin >> n;
  for(int cnt = 0; cnt < n; cnt++) {
    cout << "Case " << cnt+1 << ":" << endl;
    cin >> num;
    for(int j = 0; j < 10; j++) {
      num *= num; 
      s <<  num; s >> str; s.clear(); s.str("");
      
      len = str.length();
      for(int i = 0; i < 8 - len; i++) str = "0" + str;
      num = 0;
      for(int i = 0; i < 4; i++) {
	num *= 10;
	num += str[2+i] - '0';
      }
      cout << num << endl;
    }
  } 
  return 0;
}

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

int jyo(int);

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

int jyo(int n){
  n*=n;
  n-=(n/10000000)*10000000;
  n-=(n/1000000)*1000000;
  return n;
}

C++: #include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  int n;
  vector<int> v;
  cin>>n;
  v.reserve(n);
  for(i=0;i<n;i++)
    cin>>v[i];
  for(i=0;i<n;i++){
    cout<<"Case "<<i+1<<":"<<endl;
    for(j=0;j<10;j++){
      v[i]=v[i]*v[i]%1000000/100;
      cout<<v[i]<<endl;
    }
  }
  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);
      val = (atoi)(next.c_str());
      cout << val << endl;
    }
  }

};

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

int calc(int x) {
  char buf[128];
  sprintf(buf, "%08d", x*x);
  buf[6] = '\0';
  return atoi(buf+2);
}

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

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

int main(){
	int N;
	long long int s;
	cin >> N;
	for(int i = 1;i <= N;i++){
		
		cin >> s;
		cout << "Case " << i << ":" << endl;

		for(int j = 10;j;j--){
			s *= s;
			stringstream ss;
			ss << s;
			string a = ss.str();
			int asize = a.size();
			//a.size()ÍÂÏ
			for(int k = 0;k < 8 - asize;k++){a = "0" + a;}

			ss.str("");
			ss << a.substr(2,4);
			long long int b;
			ss >> b;
			s = b;
			cout << b << endl;
		}
	}
	return 0;
}

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

int makerand(int r);

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

int makerand(int r){
    int r2 = r * r;
    int ret = 0, f = 100, tmpf = 1;
    for(int i = 0; i < 4; i++){
        ret += (r2 / f % 10 * tmpf);
        f *= 10;
        tmpf *= 10;
    }
    return ret;
}

//0, 00:28:01

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	int a;
	cin>>a;
	for(int z=0;z<a;z++){
		int n;
		cin>>n;
		cout<<"Case "<<z+1<<endl;
		for(int j=0;j<10;j++){
			n=n*n;
			string a=to_string(n);
			int b=a.length();
			b=8-b;
			string t;
			for(int i=0;i<b;i++)
				t+="0";
			t+=a;
			string c=t.substr(2,4);
			n=stoi(c);
			cout<<n<<endl;
		}
	}
}

C++: #include<stdio.h>
int main(){
int N,x,c=0,x1=0;
scanf("%d",&N);
for(int i=0;i<N;i++)
{
scanf("%d",&x);
int ii=i+1;
printf("Case %d:",ii);
for(int j=0;j<10;j++)
{
x=x*x;
x1=x;c=1;

while((x1/10)>0){
x1=x1/10;c++;
//printf("%d",x1);
}
if(c<=2)x=0;
else if(c==3)x=x/100;
else if(c==4)x=x/100;
else if(c==5)x=x/100;
else if(c==6)x=x/100;
else if(c==7){x=x%1000000;x=x/100;}
else if(c==8){x=x%1000000;x=x/100;}
printf("%d\n",x);
}
}
return 0;

}

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

C++: #include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int t; cin >> t;
    for (int i = 0; i < t; ++i) {
        printf("Case %d:\n", i+1);
        int x;
        cin >> x;
        for (int j = 0; j < 10; ++j) {
            int nxt = (x*x)/100%10000;
            cout << nxt << "\n";
            x = nxt;
        }
    }

    return 0;
}

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

int main(){
	unsigned long long num, buf;
	int a[8], n, ans;

	cin>>n;
	for(int i=1; i<=n; i++){
		cin>>num;
		cout<<"Case "<<i<<":\n";

		for(int j=0; j<10; j++){
			ans=0;
			num*=num;
			buf=num;
			//cout<<"("<<num<<")";
			for(int k=0; k<8; k++){
				a[k] = buf%10;
				buf/=10;
				//cout<<a[k]<<"\n";
			}
			int x=1;
			for(int l=2; l<6; l++){
				ans+=a[l]*x;
				x*=10;
			}
			cout<<ans<<"\n";
			num=ans;
		}
	}
	return 0;
}

C++: #include <stdio.h>

int GenNextRand(int s);

int main(void){
    int seed,next;
    int n;
    
    scanf("%d", &n);
    for (int i=0; i<n; i++){
        scanf("%d",&seed);
        printf("Case %d:\n",i+1);
        for (int j=0; j<10; j++){
            next = GenNextRand(seed);
            printf("%d\n", next);
            seed = next;
        }
    }
    
    return 0;
}

int GenNextRand(int s){
    int tmp;
    
    tmp = s*s;
    return (tmp/100) % 10000;
}