<commit_before>class Solution {
    public:
        double pow(double x, int n) {
            double res = 1;
            bool flag = false;
            if(n < 0){
                n = (-1)*n;
                flag = true;
            }

            res = positivePow(x, n);

            if(flag == false)
                return res;
            else return 1/res;
        }

        double positivePow(double x, int n){
            if(n == 0) return 1;
            else if(n == 1) return x;
            else if(n % 2 == 1){
                double tmp = positivePow(x,n/2);
                return x*tmp*tmp;
            }
            else{
                double tmp = positivePow(x,n/2);
                return tmp*tmp;            
            }
        }
};<commit_msg>add a non-recursive O(logn) solution<commit_after>class Solution {
    public:
        double pow(double x, int n) {
            double res = 1;
            bool flag = false;
            if(n < 0){
                n = (-1)*n;
                flag = true;
            }

            while(n != 0){
                if(n % 2 != 0) res = res * x;
                x = x * x;
                n = n/2;
            }

            if(flag == false)
                return res;
            else return 1/res;
        }
};
{'fraction_non_alphanumeric': 0.11007025761124122, 'fraction_numerical': 0.01483216237314598, 'mean_word_length': 0.8742690058479532, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1239201', 'n_tokens_mistral': 393, 'n_tokens_neox': 355, 'n_words': 103}