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)
		}
	}
}

Python: def main():
    d = int(input())
    a = []
    for _ in range(d):
        a.append(int(input()))

    ans = []
    for x in range(d):
        ansans = []
        hoge = a[x]
        for y in range(10):
            hoge = list("{0:08d}".format(hoge ** 2))
            s = ""
            for z in range(2, 6):
                s += hoge[z]
            hoge = int(s)
            ansans.append(hoge)
        ans.append(ansans)

    for x in range(1, d + 1):
        print("Case", x,end= "")
        print(":")
        for y in ans[x - 1]:
            print(y)


if __name__ == "__main__":
    main()

Python: x=int(input())
for i in range(x):
    n=int(input())
    print(f"Case {i+1}:")
    for j in range(10):
        n=int(str(n**2).zfill(8)[2:6])
        print(n)

Python: for i in range(int(input())):
    x = int(input())
    print("Case " + str(i+1) + ":")
    for _ in range(10):
        x = str(int(x)**2)
        if len(x) < 8 : x = (8-len(x))*"0" + x
        x = x[2:6]
        print(int(x))

Python: # AOJ 0137 Middle-Square Method
# Python3 2018.6.17 bal4u

for i in range(int(input())):
	print('Case ', i+1, ':', sep='')
	s = int(input())
	for j in range(10):
		s = (s * s // 100) % 10000
		print(s)

Python: 
def main():
    n = int(iuput())
    for x in range(1, n + 1):
        s = int(input())
        a = [] #answer
        for _ in range(10):
            s = "{0:08d}".format(s ** 2)
            s = list(s)
            hoge = ""
            for y in range(2, 6):
                hoge += s[y]
            s = int(hoge)
            a.append(s)
        else:
            print("Case", x,end = "")
            print(":")
            for y in a:
                print(y)


if __name__ == "__main__":
    main()

Python: n = int(raw_input())

for j in range(n):
	x = int(raw_input())

	print("Case " + str(j + 1) + ":")
	for i in range(10):
		x = "00000000" + str(x**2)
		x = int(x[-6:-2])
		print(x)

Python: # Aizu Problem 00137: Middle Square Method
#
import sys, math, os, copy

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def middle_square(k):
    for step in range(10):
        k = (k**2 // 100) % 10000
        print(k)
        
    
N = int(input())
for case in range(1, N + 1):
    print("Case %d:" % case)
    k = int(input())
    middle_square(k)

Python: def middle_square(s, digit):
    s2 = str(s ** 2).zfill(digit * 2)
    return int(s2[digit // 2:digit * 3 // 2])

n = int(input())

for i in range(n):
    print('Case {}:'.format(i + 1))

    s = int(input())
    for _ in range(10):
        s = middle_square(s, digit=4)
        print(s)

Python: n = int(input())
for i in range(n):
    print("Case",str(i+1)+":")
    tmp = input()
    for i in range(10):
        tmp = str(int(tmp)**2).zfill(8)[2:6]
        print(int(tmp))

Python: # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0137

"""
import sys
from sys import stdin
input = stdin.readline


def solve(i, n):
    result = []
    while len(result) < 10:
        i = i ** 2
        i //= 100  #  n???4??\?????????????
        i %= 10**n
        result.append(i)
    return result


def main(args):
    n = 4
    d = int(input())
    for i in range(1, d+1):
        init_value = int(input())
        result = solve(init_value, n)
        print('Case {}:'.format(i))
        print('\n'.join(map(str, result)))


if __name__ == '__main__':
    main(sys.argv[1:])

Python: n = int(input())

for i in range(n):
    s = int(input())
    print("Case " + str(i+1) + ":")

    for _ in range(10):
        power = str(s**2).zfill(8)
        ans = power[2:6]
        print(int(ans))
        s = int(ans)

Python: n = int(input())
for i in range(n):
    s = int(input())
    print("Case {}:".format(i+1))
    for _ in range(10):
        s = int("{:08d}".format(s ** 2)[2:7])
        print(s)

Python: n = int(input())
for i in range(n):
    cas = "Case " + str(i + 1) + ":"
    print(cas)
    num = int(input())
    for j in range(10):
        num = int((num ** 2) / 100)
        num = num % 10000
        print(num)

Python: digit = 100
def vrand(seed):
    del_down = int(seed * seed / digit)
    up_ = int(del_down / (digit * digit))
    up_ *= (digit * digit)
    return del_down - up_

num = int(input())
sds = []
for i in range(num):
    sd = int(input())
    sds.append(sd)

for i in range(num):
    print("Case "+str(i+1)+":")
    seed = sds[i]
    for j in range(10):
        seed = vrand(seed)
        print(seed)

Python: k = int(raw_input())

for j in range(k):
	x = int(raw_input())

	print("Case " + str(j + 1))
	for i in range(10):
		x = "00000000" + str(x**2)
		x = int(x[-6:-2])
		print(x)

Python: n = int(input())
for i in range(n):
  print("Case ", i + 1, ":", sep="")
  x = input()
  for _ in range(10):
    x = str(int(x) ** 2).zfill(8)[2:6]
    print(int(x))

Python: n = int(input())
for i in range(n):
    s = int(input())
    print("Case {}".format(i+1))
    for _ in range(10):
        s = int("{:08d}".format(s ** 2)[2:7])
        print(s)

Python: for i in range(int(input())):
    a=str(int(input())**2).zfill(8)
    print('Case %d:'%(i+1))
    for _ in range(10):
        b=int(a[2:6])
        print(b)
        a=str(b**2).zfill(8)

Python: n = int(raw_input())

for j in range(n):
	x = int(raw_input())

	print("Case " + str(j + 1) + ":")
	for i in range(10):
		x = "00000000" + str(x**2)
		print(x)
		x = int(x[-6:-2])
		print(x)

Python: 
c = int(input())
for i in range(c):
    s = int(input())
    print("Case {}:".format(i+1))
    for _ in range(10):
        tmp = "{:08d}".format(s**2)
        s = int(tmp[2:6])
        print(s)

Python: n = int(input())
for i in range(n):
    s = int(input())
    print("Case {}:".format(i+1))
    for _ in range(10):
        s = int("{:08d}".format(s ** 2)[2:6])
        print(s)

Python: n = int(input())

for i in range(n):
  print("Case ", i + 1, ":", sep="")
  x = input()
  for _ in range(10):
    x = str(int(x) ** 2).zfill(8)[2:6]
    print(int(x))

Python: import os
import sys

def main():
    n = int(input())
    for i in range(1,n+1):
        x = int(input())
        print("Case {}:".format(i))
        for j in range(10):
            x = x**2
            out = '{0:08d}'.format(x)
            print(int(out[2:6]))
            x = int(out[2:6])

main()

Python: def method(s):
    count=0
    ans=[]
    while count!=10:
        s=str(s**2).zfill(8)
        s=int(s[2]+s[3]+s[4]+s[5])
        ans.append(s)
        count +=1
    return ans
N=int(input())
for i in range(N):
    s=int(input())
    print("Case %d:"%(i+1))
    for j in range(10):
        print(method(s)[j])

Python: # -*- coding: utf-8 -*-

import sys
import os
import math

N = int(input())
n = 4

for i in range(N):
    print("Case {}:".format(i+1))
    d = int(input())

    for j in range(10):
        square = d * d
        s = str(square).zfill(n*2)
        d = int(s[2:-2])
        print(d)

Python: import os
import sys

def main():
    n = int(input())
    for i in range(1,n+1):
        x = int(input())
        print("Case {}:".format(i))
        for j in range(10):
            x = x**2
            out = '{0:08d}'.format(x)
            print(out[2:6])
            x = int(out[2:6])

main()

Python: import math

N = int(input())

for l in range(N):

    k = int(input())

    print("Case " + str(l+1) + ":")
    for i in range(10):
        k = k*k
        k = k // 100
        k = k % 10000
        print(k)