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<bits/stdc++.h>
using namespace std;

void randed(int num,int idx){
  cout << "Case " << idx << ":" << endl;
  for(int i=0;i<10;i++){
    int tmp = num*num;
    tmp /= 100;
    int next = 0;
    for(int j=0;j<4;j++){
      if(tmp == 0) break;
      int s = tmp % 10;
      int k = 1;
      for(int z=0;z<j;z++){
	k *= 10;
      }
      next += s * k;
      tmp /= 10;
    }
    cout << next << endl;
    num = next;
  }
}

int main(){
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    int num;
    cin >> num;
    randed(num,i+1);
  }
}

C++: #include<iostream>

using namespace std;

int solve(int d)
{
  d *= d;
  d -= (d / 1000000) * 1000000;
  return d / 100;
}

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

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

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

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main()
{
	int n, x, i, j;
	char c[9], d[5];
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> x;
		cout << "Case " << i+1 << ":" << endl;
		for (j = 0; j < 10; j++)
		{
			x *= x;
			sprintf(c, "%08d", x);
			d[0] = c[2], d[1] = c[3], d[2] = c[4], d[3] = c[5], d[4] = '\0';
			x = atoi(d);
			cout << x << endl;
		}
	}
}

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

void Change(char *conv, char *res)
{
  for (int i = 0; i < 4; i++){
    res[i] = conv[i + 2];
  }
}
int main()
{
  int n, s;

  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++){
      char conv[9], res[5];
      sprintf(conv, "%08d", s * s);
      Change(conv, res);
      s = atoi(res);
      printf("%d\n", s);
    }
  }

  return (0);
}

C++: #include <stdio.h>
#include <iostream>

using namespace std;

void kei(int d, int f[],int r)
{
	for (int l = r; l < 10; l++) {
		f[l] += d % 10;
		if (f[l] >= 10 && l != 9) {
			f[l+1] += f[l] / 10;
			f[l] %= 10;
		}
		d /= 10;
	}
	return;
}

void keisan(int a, int b) 
{
	if (b == 0) {
		return;
	} else {
		int t;
		int y;
		int r[10] = {0};
		int x;
		y = a;
		for (int j = 0; j < 10; j++) {
			x = a * (y % 10);
			kei(x,r,j);
			y /= 10;
		}
		t = r[2] + r[3] * 10 + r[4] * 100 + r[5] * 1000;
		cout << t << endl;
		keisan(t,b-1);
	}
}

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

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

using namespace std;

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int n; cin>>n;
    rep(i,n){
        cout << "Case " << i+1 << ":" << endl;
        int a; cin >> a;
        rep(j,10){
            a*=a;
            a/=100;
            a = a-a/10000*10000;
            cout << a << endl;
        }
    }
}

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 <iostream>
using namespace std;

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

C++: #include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int dt,hoge,n;
	cin>>n;
	rep(p,n){
		cin>>dt;
		cout<<"Case "<<p+1<<":"<<endl;
		rep(q,10){
			hoge=dt*dt;
			hoge-=(int)(hoge/1e6)*1e6;
			hoge/=100;
			cout<<hoge<<endl;
			dt=hoge;
		}
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	for(int x=1;x<=n;++x){
		cout << "Case "<<x<<":\n";
		int T;
		cin>>T;
		for(int i=0; i<10; ++i){
			T=T*T;
			T%=100000000;
			T=	((T%1000000)/100000)*1000+
				((T%100000)/10000)*100+
				((T%10000)/1000)*10+
				((T%1000)/100);
			cout << T << '\n';
		}
	}
	return 0;
}

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

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	for (int d = in(), c = 1; c <= d; c++) {
		outl("Case ", c, ':');
		for (int s = in(), i = 0; i < 10; i++)
			outl(s = s * s / 100 % 10000);
	}
}

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

	 return 0;
}

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

C++: #include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
int main(){
	string x,ans="";
	long long s,cnt=1,num;
	int d;
	cin>>d;
	for(int k=1;k<=d;k++){
		cin>>s;
		cout<<"Case "<<cnt<<":"<<endl;
		for(int i=1;i<=10;i++){
			s=s*s;
			num=(int)log10((double)s) + 1;
			if(num<8){
				for(int j=8;j>num;j--){
					ans+="0";
				}
				ans+=to_string(s);
			}else{
				ans=to_string(s);
			}
			x="";
			for(int i=2;i<=5;i++){
				x+=ans[i];
			}
			ans="";
			s=stoi(x);
			cout<<s<<endl;
		}
		cnt++;
	}
	return 0;
}