#include<iostream>
using namespace std;


int sqrt(int n,int low, int high) {

  if(low==high) return low;
  int mid=(low+high+1)/2;
  
  if(mid*mid >  n ) 
       return sqrt(n,low,mid-1);
  else
       return sqrt(n,mid,high);
}

int sqrt(int n) {return sqrt(n,1,n);};


template<int N,int L=1,int H=N> struct Sqrt{
  enum  {mid=(L+H+1)/2};
  enum  {res= (mid*mid> N)? (int)Sqrt<N,L,mid-1>::res :
	(int)Sqrt<N,mid,H>::res};
};


template<int N,int L> struct Sqrt<N,L,L> {
  enum {res=L};
};


const int n=50*50; 
main() {

  cout<<n-1<<" : "<<sqrt(n-1)<<endl;
  cout<<n<<" : "<<sqrt(n)<<endl;
  cout<<n+1<<" : "<<sqrt(n+1)<<endl;
  cout<<"template"<<endl;
  cout<<n-1<<" : "<<Sqrt<n-1>::res<<endl;
  cout<<n<<" : "<<Sqrt<n>::res<<endl;
  cout<<n+1<<" : "<<Sqrt<n+1>::res<<endl;
}