binary exponentiation

C++
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
//complexity O(log k)
ull po(ull n,ull k){
	ull x=1;
	while(k){
		if(k&1)
			x*=n;
		n*=n;
		k>>=1;
	}
	return x;
}
int main(){
	ull n,m;
    //n^m
	cin>>n>>m;
	cout<<po(n,m);
	return 0;
}
Source

Also in C++: