dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
def count_odd_pair ( n , a ) :
    odd = 0
    even = 0
    for i in range ( 0 , n ) :
        if ( a [ i ] % 2 == 0 ) :
            even = even + 1
        else :
            odd = odd + 1
    ans = odd * even * 2
    return ans
def count_even_pair ( odd_sum_pairs , n ) :
    total_pairs = ( n * ( n - 1 ) )
    ans = total_pairs - odd_sum_pairs
    return ans
n = 6
a = [ 2 , 4 , 5 , 9 , 1 , 8 ]
odd_sum_pairs = count_odd_pair ( n , a )
even_sum_pairs = count_even_pair ( odd_sum_pairs , n )
print ( " Even ▁ Sum ▁ Pairs ▁ = " , even_sum_pairs )
print ( " Odd ▁ Sum ▁ Pairs = " , odd_sum_pairs )

Index/key variables: i
Iterator variables: i
Python program:
def findSteps ( n , m , a ) :
    cur = 1
    steps = 0
    for i in range ( 0 , m ) :
        if ( a [ i ] >= cur ) :
            steps += ( a [ i ] - cur )
        else :
            steps += ( n - cur + a [ i ] )
        cur = a [ i ]
    return steps
n = 3
m = 3
a = [ 2 , 1 , 2 ]
print ( findSteps ( n , m , a ) )

Index/key variables: i
Accumulator variables: steps
Iterator variables: i
Python program:
def HexToBin ( hexdec ) :
    for i in hexdec :
        if i == '0' :
            print ( '0000' , end = ' ' )
        elif i == '1' :
            print ( '0001' , end = ' ' )
        elif i == '2' :
            print ( '0010' , end = ' ' )
        elif i == '3' :
            print ( '0011' , end = ' ' )
        elif i == '4' :
            print ( '0100' , end = ' ' )
        elif i == '5' :
            print ( '0101' , end = ' ' )
        elif i == '6' :
            print ( '0110' , end = ' ' )
        elif i == '7' :
            print ( '0111' , end = ' ' )
        elif i == '8' :
            print ( '1000' , end = ' ' )
        elif i == '9' :
            print ( '1001' , end = ' ' )
        elif i == ' A ' or i == ' a ' :
            print ( '1010' , end = ' ' )
        elif i == ' B ' or i == ' b ' :
            print ( '1011' , end = ' ' )
        elif i == ' C ' or i == ' c ' :
            print ( '1100' , end = ' ' )
        elif i == ' D ' or i == ' d ' :
            print ( '1101' , end = ' ' )
        elif i == ' E ' or i == ' e ' :
            print ( '1110' , end = ' ' )
        elif i == ' F ' or i == ' f ' :
            print ( '1111' , end = ' ' )
        else :
            print ( " Invalid hexadecimal digit   " + str ( hexdec [ i ] ) , end = ' ' )
if __name__ == " _ _ main _ _ " :
    hexdec = "1AC5" ;
    print ( " Equivalent ▁ Binary ▁ value ▁ is ▁ : ▁ " , end = ' ' )
    HexToBin ( hexdec )

Index/key variables: i
Iterator variables: i
Python program:
def isPowerOfTwo ( x ) :
    return ( x and ( not ( x & ( x - 1 ) ) ) )
def Count_pairs ( a , n ) :
    count = 0
    for i in range ( n ) :
        if isPowerOfTwo ( a [ i ] ) :
            count += 1
    ans = ( count * ( count - 1 ) ) / 2
    print ( ans )
if __name__ == " _ _ main _ _ " :
    a = [ 2 , 5 , 8 , 16 , 128 ]
    n = len ( a )
    Count_pairs ( a , n )

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Python program:
def factorial ( n ) :
    result = 1
    for i in range ( 1 , n + 1 ) :
        result *= i
    return result
def nCr ( n , r ) :
    return ( factorial ( n ) // ( factorial ( r ) * factorial ( n - r ) ) )
def calculate_result ( n ) :
    result = 2 * nCr ( ( n - 2 ) , ( n // 2 - 1 ) )
    return result
if __name__ == " _ _ main _ _ " :
    a , b = 2 , 4
    print ( calculate_result ( 2 * a ) )
    print ( calculate_result ( 2 * b ) )

Accumulator variables: result
Iterator variables: i
Python program:
def PossibleValues ( b , x , n ) :
    leastdivisible = int ( b / x + 1 ) * x
    flag = 1
    while ( leastdivisible <= n ) :
        if ( leastdivisible - b >= 1 ) :
            print ( leastdivisible - b , end = " ▁ " )
            leastdivisible += x
            flag = 0
        else :
            break
    if ( flag != 0 ) :
        print ( - 1 )
if __name__ == ' _ _ main _ _ ' :
    b = 10
    x = 6
    n = 40
    PossibleValues ( b , x , n )

Accumulator variables: leastdivisible
Python program:
def digitProduct ( digits , start , end ) :
    pro = 1
    for i in range ( start , end + 1 ) :
        pro *= digits [ i ]
    return pro
def isDistinct ( N ) :
    s = str ( N )
    length = len ( s )
    digits = [ None ] * length
    products = set ( )
    for i in range ( 0 , length ) :
        digits [ i ] = int ( s [ i ] )
    for i in range ( 0 , length ) :
        for j in range ( i , length ) :
            val = digitProduct ( digits , i , j )
            if val in products :
                return False
            else :
                products . add ( val )
    return True
if __name__ == " _ _ main _ _ " :
    N = 324
    if isDistinct ( N ) == True :
        print ( " YES " )
    else :
        print ( " NO " )

Index/key variables: i
Accumulator variables: pro, products
Iterator variables: i, j
Python program:
MAX = 10000
arr = [ ]
def ulam ( ) :
    s = set ( )
    arr . append ( 1 )
    s . add ( 1 )
    arr . append ( 2 )
    s . add ( 2 )
    for i in range ( 3 , MAX ) :
        count = 0
        for j in range ( 0 , len ( arr ) ) :
            if ( i - arr [ j ] ) in s and arr [ j ] != ( i - arr [ j ] ) :
                count += 1
            if count > 2 :
                break
        if count == 2 :
            arr . append ( i )
            s . add ( i )
if __name__ == " _ _ main _ _ " :
    ulam ( )
    n = 9
    print ( arr [ n - 1 ] )

Index/key variables: j
Accumulator variables: arr, count, s
Iterator variables: i, j
Python program:
def get_last_two_digit ( N ) :
    if N <= 10 :
        ans = 0
        fac = 1
        for i in range ( 1 , N + 1 ) :
            fac = fac * i
            ans += fac
        ans = ans % 100
        return ans
    else :
        return 13
N = 1
for N in range ( 1 , 11 ) :
    print ( " For ▁ N ▁ = ▁ " , N , " : ▁ " , get_last_two_digit ( N ) , sep = ' ▁ ' )

Accumulator variables: ans
Iterator variables: N, i
Python program:
def isProductEven ( arr , n ) :
    for i in range ( 0 , n ) :
        if ( ( arr [ i ] & 1 ) == 0 ) :
            return True
    return False
arr = [ 2 , 4 , 3 , 5 ]
n = len ( arr )
if ( isProductEven ( arr , n ) ) :
    print ( " Even " )
else :
    print ( " Odd " )

Index/key variables: i
Iterator variables: i
Python program:
def calculateSquareSum ( n ) :
    fibo = [ 0 ] * ( n + 1 ) ;
    if ( n <= 0 ) :
        return 0 ;
    fibo [ 0 ] = 0 ;
    fibo [ 1 ] = 1 ;
    sum = ( ( fibo [ 0 ] * fibo [ 0 ] ) + ( fibo [ 1 ] * fibo [ 1 ] ) ) ;
    for i in range ( 2 , n + 1 ) :
        fibo [ i ] = ( fibo [ i - 1 ] + fibo [ i - 2 ] ) ;
        sum += ( fibo [ i ] * fibo [ i ] ) ;
    return sum ;
n = 6 ;
print ( " Sum ▁ of ▁ squares ▁ of ▁ Fibonacci ▁ numbers ▁ is ▁ : " , calculateSquareSum ( n ) ) ;

Index/key variables: i
Accumulator variables: sum
Iterator variables: i
Python program:
def MinimumMoves ( a , n , x ) :
    ans = 0
    for i in range ( 1 , n ) :
        if a [ i ] <= a [ i - 1 ] :
            p = ( a [ i - 1 ] - a [ i ] ) // x + 1
            ans += p
            a [ i ] += p * x
    return ans
if __name__ == " _ _ main _ _ " :
    arr = [ 1 , 3 , 3 , 2 ]
    x = 2
    n = len ( arr )
    print ( MinimumMoves ( arr , n , x ) )

Index/key variables: i
Accumulator variables: ans
Iterator variables: i
Python program:
def SumOfDigits ( str , n ) :
    sum = 0
    for i in range ( 0 , n ) :
        sum += int ( ord ( str [ i ] ) - ord ( '0' ) )
    return sum
def Divisible ( str , n ) :
    if ( ( SumOfDigits ( str , n ) % 3 == 0 and str [ n - 1 ] == '0' ) ) :
        return True
    return False
if __name__ == " _ _ main _ _ " :
    str = "263730746028908374890"
    n = len ( str )
    if ( Divisible ( str , n ) ) :
        print ( " YES " )
    else :
        print ( " NO " )

Index/key variables: i
Accumulator variables: sum
Iterator variables: i
Python program:
def isPrime ( k ) :
    if ( k <= 1 ) :
        return False
    for i in range ( 2 , k ) :
        if ( k % i == 0 ) :
            return false
    return True
def check ( num , k ) :
    flag = 1
    for i in range ( 2 , k ) :
        if ( num % i == 0 ) :
            flag = 0
    if ( flag == 1 ) :
        if ( num % k == 0 ) :
            return 1
        else :
            return 0
    else :
        return 0
def findCount ( a , b , k ) :
    count = 0
    if ( not isPrime ( k ) ) :
        return 0
    else :
        for i in range ( a , b + 1 ) :
            ans = check ( i , k )
            if ( ans == 1 ) :
                count += 1
            else :
                continue
    return count
if __name__ == " _ _ main _ _ " :
    a = 2020
    b = 6300
    k = 29
    print ( findCount ( a , b , k ) )

Accumulator variables: count
Iterator variables: i
Python program:
import math as mt
def findkth ( n , k ) :
    v1 = list ( )
    v2 = list ( )
    for i in range ( 1 , mt . ceil ( n ** ( .5 ) ) ) :
        if ( n % i == 0 ) :
            v1 . append ( i )
            if ( i != mt . ceil ( mt . sqrt ( n ) ) ) :
                v2 . append ( n // i )
    v2 [ : : - 1 ]
    if ( k > ( len ( v1 ) + len ( v2 ) ) ) :
        print ( " Doesn ' t ▁ Exist " , end = " " )
    else :
        if ( k <= len ( v1 ) ) :
            print ( v1 [ k - 1 ] )
        else :
            print ( v2 [ k - len ( v1 ) - 1 ] )
n = 15
k = 2
findkth ( n , k )

Accumulator variables: v1, v2
Iterator variables: i
Python program:
def NumberOfSolutions ( a , b , c , d ) :
    ans = 0
    for i in range ( a , b + 1 ) :
        if d >= max ( c , i + 1 ) :
            ans += d - max ( c , i + 1 ) + 1
    return ans
if __name__ == " _ _ main _ _ " :
    a , b , c , d = 2 , 3 , 3 , 4
    print ( NumberOfSolutions ( a , b , c , d ) )

Accumulator variables: ans
Iterator variables: i
Python program:
def findF_N ( n ) :
    ans = 0
    for i in range ( n ) :
        ans = ans + ( i + 1 ) * ( n - i - 1 )
    return ans
n = 3
print ( findF_N ( n ) )

Iterator variables: i
Python program:
def findNumber ( n , d ) :
    ans = " "
    if ( d != 10 ) :
        ans += str ( d )
        for i in range ( 1 , n ) :
            ans += '0'
    else :
        if ( n == 1 ) :
            ans += " Impossible "
        else :
            ans += '1'
            for i in range ( 1 , n ) :
                ans += '0'
    return ans
if __name__ == " _ _ main _ _ " :
    n = 12
    d = 3
    print ( findNumber ( n , d ) )

Accumulator variables: ans
Iterator variables: i
Python program:
MAX = 1000000
sieve_Prime = [ 0 for i in range ( MAX + 4 ) ]
sieve_count = [ 0 for i in range ( MAX + 4 ) ]
def form_sieve ( ) :
    sieve_Prime [ 1 ] = 1
    for i in range ( 2 , MAX + 1 ) :
        if sieve_Prime [ i ] == 0 :
            for j in range ( i * 2 , MAX + 1 , i ) :
                if sieve_Prime [ j ] == 0 :
                    sieve_Prime [ j ] = 1
                    sieve_count [ i ] += 1
form_sieve ( )
n = 2
print ( " Count ▁ = " , sieve_count [ n ] + 1 )
n = 3
print ( " Count ▁ = " , sieve_count [ n ] + 1 )

Index/key variables: i, j, n
Iterator variables: i, j
Python program:
if __name__ == ' _ _ main _ _ ' :
    matrix = [ [ 0 for i in range ( 5 ) ] for j in range ( 5 ) ] ;
    row_index , column_index , x , size = 0 , 0 , 0 , 5 ;
    for row_index in range ( size ) :
        for column_index in range ( size ) :
            x += 1 ;
            matrix [ row_index ] [ column_index ] += x ;
    print ( " The ▁ matrix ▁ is " ) ;
    for row_index in range ( size ) :
        for column_index in range ( size ) :
            print ( matrix [ row_index ] [ column_index ] , end = " TABSYMBOL " ) ;
        print ( " " ) ;
    print ( " Elements above Secondary diagonal are : " ) ;
    for row_index in range ( size ) :
        for column_index in range ( size ) :
            if ( ( row_index + column_index ) < size - 1 ) :
                print ( matrix [ row_index ] [ column_index ] , end = " ▁ " ) ;

Index/key variables: column_index, row_index
Accumulator variables: x
Iterator variables: column_index, row_index
Python program:
if __name__ == ' _ _ main _ _ ' :
    matrix = [ [ 0 for i in range ( 5 ) ] for j in range ( 5 ) ]
    row_index , column_index , x , size = 0 , 0 , 0 , 5 ;
    for row_index in range ( size ) :
        for column_index in range ( size ) :
            x += 1 ;
            matrix [ row_index ] [ column_index ] = x ;
    print ( " The ▁ matrix ▁ is " ) ;
    for row_index in range ( size ) :
        for column_index in range ( size ) :
            print ( matrix [ row_index ] [ column_index ] , end = " TABSYMBOL " ) ;
        print ( " " ) ;
    print ( " Corner Elements are : " ) ;
    for row_index in range ( size ) :
        for column_index in range ( size ) :
            if ( ( row_index == 0 or row_index == size - 1 ) and ( column_index == 0 or column_index == size - 1 ) ) :
                print ( matrix [ row_index ] [ column_index ] , end = " TABSYMBOL " ) ;

Index/key variables: column_index, row_index
Accumulator variables: x
Iterator variables: column_index, row_index
Python program:
def PrimeFactors ( n ) :
    v = [ ]
    x = n
    i = 2
    while ( i * i <= n ) :
        if ( x % i == 0 ) :
            v . append ( i )
            while ( x % i == 0 ) :
                x //= i
        i += 1
    if ( x > 1 ) :
        v . append ( x )
    return v
def GoodNumber ( n ) :
    v = PrimeFactors ( n )
    ans = 1
    for i in range ( len ( v ) ) :
        ans *= v [ i ]
    return ans
if __name__ == " _ _ main _ _ " :
    n = 12
    print ( GoodNumber ( n ) )

Index/key variables: i
Accumulator variables: ans, v, x
Iterator variables: i
Python program:
def checkSpecialPrime ( sieve , num ) :
    while ( num ) :
        if ( not sieve [ num ] ) :
            return False
        num //= 10
    return True
def findSpecialPrime ( N ) :
    sieve = [ True ] * ( N + 10 )
    sieve [ 0 ] = sieve [ 1 ] = False ;
    for i in range ( 2 , N + 1 ) :
        if ( sieve [ i ] ) :
            for j in range ( i * i , N + 1 , i ) :
                sieve [ j ] = False
    while ( True ) :
        if ( checkSpecialPrime ( sieve , N ) ) :
            print ( N )
            break
        else :
            N -= 1
if __name__ == " _ _ main _ _ " :
    findSpecialPrime ( 379 )
    findSpecialPrime ( 100 )

Index/key variables: i, j, num
Accumulator variables: N
Iterator variables: i, j
Python program:
MAX = 10000
arr = [ ]
sprime = [ False ] * ( MAX )
def computeSemiPrime ( ) :
    for i in range ( 2 , MAX ) :
        cnt , num , j = 0 , i , 2
        while cnt < 2 and j * j <= num :
            while num % j == 0 :
                num /= j
                cnt += 1
            j += 1
        if num > 1 :
            cnt += 1
        if cnt == 2 :
            sprime [ i ] = True
            arr . append ( i )
def checkSemiPrime ( n ) :
    i = 0
    while arr [ i ] <= n // 2 :
        if sprime [ n - arr [ i ] ] == True :
            return True
        i += 1
    return False
if __name__ == " _ _ main _ _ " :
    computeSemiPrime ( )
    n = 30
    if checkSemiPrime ( n ) == True :
        print ( " YES " )
    else :
        print ( " NO " )

Index/key variables: i
Accumulator variables: arr, cnt, j, num
Iterator variables: i
Python program:
def isprime ( x ) :
    for i in range ( 2 , math . sqrt ( x ) ) :
        if ( x % i == 0 ) :
            return False ;
    return True ;
def isNSqMinusnMSqPrime ( m , n ) :
    if ( n - m == 1 and isprime ( m + n ) ) :
        return True ;
    else :
        return False ;
m = 13 ;
n = 16 ;
if ( isNSqMinusnMSqPrime ( m , n ) ) :
    print ( " YES " ) ;
else :
    print ( " NO " ) ;

Iterator variables: i
Python program:
def findsolution ( n , x , y ) :
    if ( ( y - n + 1 ) * ( y - n + 1 ) + n - 1 < x or y < n ) :
        print ( " No ▁ solution " ) ;
        return ;
    print ( y - n + 1 ) ;
    while ( n > 1 ) :
        print ( 1 ) ;
        n -= 1 ;
n = 5 ;
x = 15 ;
y = 15 ;
findsolution ( n , x , y ) ;

Accumulator variables: n
Python program:
def checkIfPowerIsolated ( num ) :
    input1 = num ;
    count = 0 ;
    factor = [ 0 ] * ( num + 1 ) ;
    if ( num % 2 == 0 ) :
        while ( num % 2 == 0 ) :
            count += 1 ;
            num //= 2 ;
        factor [ 2 ] = count ;
    i = 3 ;
    while ( i * i <= num ) :
        count = 0 ;
        while ( num % i == 0 ) :
            count += 1 ;
            num //= i ;
        if ( count > 0 ) :
            factor [ i ] = count ;
        i += 2 ;
    if ( num > 1 ) :
        factor [ num ] = 1 ;
    product = 1 ;
    for i in range ( 0 , len ( factor ) ) :
        if ( factor [ i ] > 0 ) :
            product = product * factor [ i ] * i ;
    if ( product == input1 ) :
        print ( " Power - isolated ▁ Integer " ) ;
    else :
        print ( " Not ▁ a ▁ Power - isolated ▁ Integer " ) ;
checkIfPowerIsolated ( 12 ) ;
checkIfPowerIsolated ( 18 ) ;
checkIfPowerIsolated ( 35 ) ;

Index/key variables: i, num
Accumulator variables: count
Iterator variables: i
Python program:
def digSum ( n ) :
    if n == 0 :
        return 0
    elif n % 9 == 0 :
        return 9
    else :
        return n % 9
def powerDigitSum ( a , n ) :
    res = 1
    while ( n ) :
        if n % 2 == 1 :
            res = res * digSum ( a )
            res = digSum ( res )
        a = digSum ( digSum ( a ) * digSum ( a ) )
        n //= 2
    return res
if __name__ == " _ _ main _ _ " :
    a , n = 9 , 4
    print ( powerDigitSum ( a , n ) )

Accumulator variables: n
Python program:
MAX = 1000005
prime = [ True for i in range ( MAX ) ]
def sieve ( N ) :
    prime [ 0 ] , prime [ 1 ] = False , False
    for i in range ( 2 , N + 1 ) :
        if ( prime [ i ] ) :
            for j in range ( 2 , N + 1 ) :
                if ( i * j > N ) :
                    break
                prime [ i * j ] = False
def countLogNeeded ( N ) :
    count = 0
    sieve ( N )
    for i in range ( 1 , N + 1 ) :
        if ( prime [ i ] ) :
            count = count + 1
    return count
if __name__ == ' _ _ main _ _ ' :
    N = 6
    print ( countLogNeeded ( N ) )

Index/key variables: i
Iterator variables: i, j
Python program:
from math import sqrt , ceil , floor
def findfactors ( n ) :
    mpp = dict ( )
    v = [ ]
    v1 = [ ]
    for i in range ( 1 , ceil ( sqrt ( n ) ) + 1 ) :
        if ( n % i == 0 ) :
            v . append ( i )
            if ( i != ( n // i ) and i != 1 ) :
                v . append ( n // i )
    s = len ( v )
    maxi = - 1
    mp1 = [ 0 ] * ( n + 5 )
    for i in range ( s ) :
        for j in range ( i , s ) :
            if ( v [ i ] + v [ j ] < n ) :
                v1 . append ( v [ i ] + v [ j ] )
                mp1 [ v [ i ] + v [ j ] ] = [ v [ i ] , v [ j ] ]
                mpp [ v [ i ] + v [ j ] ] = 1
    s = len ( v1 )
    for i in range ( s ) :
        el = n - ( v1 [ i ] )
        if ( el in mpp ) :
            a = mp1 [ v1 [ i ] ] [ 0 ]
            b = mp1 [ v1 [ i ] ] [ 1 ]
            c = mp1 [ n - v1 [ i ] ] [ 0 ]
            d = mp1 [ n - v1 [ i ] ] [ 1 ]
            maxi = max ( a * b * c * d , maxi )
    if ( maxi == - 1 ) :
        print ( " Not ▁ Possible " )
    else :
        print ( " The ▁ maximum ▁ product ▁ is ▁ " , maxi )
n = 50
findfactors ( n )

Index/key variables: i, j
Accumulator variables: v, v1
Iterator variables: i, j
Python program:
from math import sqrt
factors = [ ]
def findFactors ( n ) :
    for i in range ( 1 , int ( sqrt ( n ) ) + 1 , 1 ) :
        if ( n % i == 0 ) :
            if ( ( n / i ) == i ) :
                factors . append ( i )
            else :
                factors . append ( n / i )
                factors . append ( i )
def findProduct ( n ) :
    product = - 1
    si = len ( factors )
    for i in range ( si ) :
        for j in range ( si ) :
            for k in range ( si ) :
                for l in range ( si ) :
                    s = ( factors [ i ] + factors [ j ] + factors [ k ] + factors [ l ] )
                    if ( s == n ) :
                        p = ( factors [ i ] * factors [ j ] * factors [ k ] * factors [ l ] )
                        if ( p > product ) :
                            product = p
    return product
if __name__ == ' _ _ main _ _ ' :
    n = 10
    findFactors ( n )
    print ( int ( findProduct ( n ) ) )

Index/key variables: i, j, k, l
Accumulator variables: factors
Iterator variables: i, j, k, l
Python program:
def modExp ( a , b ) :
    result = 1
    while ( b > 0 ) :
        if ( int ( b ) & 1 ) :
            result = result * a
        a = a * a
        b /= 2
    return result
def check ( num ) :
    if ( num & 1 or num < 3 ) :
        return - 1
    elif ( num % 4 == 0 ) :
        return modExp ( num / 4 , 4 )
    elif ( num % 6 == 0 ) :
        return modExp ( num / 3 , 2 ) * modExp ( num / 6 , 2 )
    elif ( num % 10 == 0 ) :
        return modExp ( num / 5 , 2 ) * ( num / 10 ) * ( num / 2 )
    else :
        return - 1
if __name__ == ' _ _ main _ _ ' :
    num = 10
    print ( int ( check ( num ) ) )

Accumulator variables: b
Python program:
def isDivisible ( n ) :
    while ( n // 100 ) :
        d = n % 10
        n //= 10
        n -= d * 5
    return ( n % 17 == 0 )
if __name__ == " _ _ main _ _ " :
    n = 19877658
    if isDivisible ( n ) :
        print ( " Yes " )
    else :
        print ( " No " )

Accumulator variables: n
Python program:
def nextPowerOf2 ( n ) :
    count = 0
    if ( n and not ( n and ( n - 1 ) ) ) :
        return n
    while n != 0 :
        n >>= 1
        count += 1
    return 1 << count
def removeElement ( n ) :
    if n == 1 or n == 2 :
        return 0
    a = nextPowerOf2 ( n )
    if n == a or n == a - 1 :
        return 1
    elif n == a - 2 :
        return 0
    elif n % 2 == 0 :
        return 1
    else :
        return 2
if __name__ == " _ _ main _ _ " :
    n = 5
    print ( removeElement ( n ) )

Accumulator variables: count, n
Python program:
MOD = 1000000007 ;
def modInv ( x ) :
    n = MOD - 2 ;
    result = 1 ;
    while ( n ) :
        if ( n & 1 ) :
            result = result * x % MOD ;
        x = x * x % MOD ;
        n = int ( n / 2 ) ;
    return result ;
def getSum ( n , k ) :
    ans = 1 ;
    for i in range ( n + 1 , n - k , - 1 ) :
        ans = ans * i % MOD ;
    ans = ans * modInv ( k + 1 ) % MOD ;
    return ans ;
n = 3 ;
k = 2 ;
print ( getSum ( n , k ) ) ;

Iterator variables: i
Python program:
target = 93
arr = [ 1 , 31 , 3 , 1 , 93 , 3 , 31 , 1 , 93 ]
length = len ( arr )
totalCount = 0
for i in range ( length - 2 ) :
    if target % arr [ i ] == 0 :
        for j in range ( i + 1 , length - 1 ) :
            if target % ( arr [ i ] * arr [ j ] ) == 0 :
                toFind = target // ( arr [ i ] * arr [ j ] )
                for k in range ( j + 1 , length ) :
                    if arr [ k ] == toFind :
                        totalCount += 1
print ( ' Total ▁ number ▁ of ▁ triplets ▁ found : ▁ ' , totalCount )

Index/key variables: i, j, k
Accumulator variables: totalCount
Iterator variables: i, j, k
Python program:
def binomialCoeff ( n , k ) :
    res = 1
    if k > n - k :
        k = n - k
    for i in range ( k ) :
        res = res * ( n - i )
        res = res // ( i + 1 )
    return res
def catalan ( n ) :
    c = binomialCoeff ( 2 * n , n )
    return c // ( n + 1 )
n = 3
print ( catalan ( n ) )

Iterator variables: i
Python program:
def isFascinating ( num ) :
    freq = [ 0 ] * 10
    val = ( str ( num ) + str ( num * 2 ) + str ( num * 3 ) )
    for i in range ( len ( val ) ) :
        digit = int ( val [ i ] )
        if freq [ digit ] and digit != 0 > 0 :
            return False
        else :
            freq [ digit ] += 1
    for i in range ( 1 , 10 ) :
        if freq [ i ] == 0 :
            return False
    return True
if __name__ == " _ _ main _ _ " :
    num = 192
    if num < 100 :
        print ( " No " )
    else :
        ans = isFascinating ( num )
        if ans :
            print ( " Yes " )
        else :
            print ( " No " )

Index/key variables: digit, i
Iterator variables: i