dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
import math
def bit ( x ) :
    ans = 0
    while ( x ) :
        x /= 2
        ans = ans + 1
    return ans
def check ( d , x ) :
    if ( bit ( x / d ) <= bit ( d ) ) :
        return True
    return False ;
def bs ( n ) :
    l = 1
    r = int ( math . sqrt ( n ) )
    while ( l < r ) :
        m = int ( ( l + r ) / 2 )
        if ( check ( m , n ) ) :
            r = m
        else :
            l = m + 1
    if ( check ( l , n ) == False ) :
        return math . floor ( l + 1 )
    else :
        return math . floor ( l )
def countDivisor ( n ) :
    return n - bs ( n ) + 1
n = 5
print ( countDivisor ( n ) )

Accumulator variables: x
Python program:
def block ( x ) :
    v = [ ]
    print ( " Blocks ▁ for ▁ % d ▁ : ▁ " % x , end = " " )
    while ( x > 0 ) :
        v . append ( int ( x % 2 ) )
        x = int ( x / 2 )
    for i in range ( 0 , len ( v ) ) :
        if ( v [ i ] == 1 ) :
            print ( i , end = " " )
            if ( i != len ( v ) - 1 ) :
                print ( " , ▁ " , end = " " )
    print ( " " )
block ( 71307 )
block ( 1213 )
block ( 29 )
block ( 100 )

Index/key variables: i
Accumulator variables: v
Iterator variables: i
Python program:
def printCubeFree ( n ) :
    cubFree = [ 1 ] * ( n + 1 ) ;
    i = 2 ;
    while ( i * i * i <= n ) :
        if ( cubFree [ i ] == 1 ) :
            multiple = 1 ;
            while ( i * i * i * multiple <= n ) :
                cubFree [ i * i * i * multiple ] = 0 ;
                multiple += 1 ;
        i += 1 ;
    for i in range ( 2 , n + 1 ) :
        if ( cubFree [ i ] == 1 ) :
            print ( i , end = " ▁ " ) ;
if __name__ == " _ _ main _ _ " :
    printCubeFree ( 20 ) ;

Index/key variables: i
Accumulator variables: multiple
Iterator variables: i
Python program:
def heapify ( arr , n , i ) :
    smallest = i
    l = 2 * i + 1
    r = 2 * i + 2
    if l < n and arr [ l ] < arr [ smallest ] :
        smallest = l
    if r < n and arr [ r ] < arr [ smallest ] :
        smallest = r
    if smallest != i :
        ( arr [ i ] , arr [ smallest ] ) = ( arr [ smallest ] , arr [ i ] )
        heapify ( arr , n , smallest )
def heapSort ( arr , n ) :
    for i in range ( int ( n / 2 ) - 1 , - 1 , - 1 ) :
        heapify ( arr , n , i )
    for i in range ( n - 1 , - 1 , - 1 ) :
        arr [ 0 ] , arr [ i ] = arr [ i ] , arr [ 0 ]
        heapify ( arr , i , 0 )
def printArray ( arr , n ) :
    for i in range ( n ) :
        print ( arr [ i ] , end = " ▁ " )
    print ( )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 4 , 6 , 3 , 2 , 9 ]
    n = len ( arr )
    heapSort ( arr , n )
    print ( " Sorted ▁ array ▁ is ▁ " )
    printArray ( arr , n )

Index/key variables: i, l, r, smallest
Iterator variables: i
Python program:
def trickyCase ( s , index ) :
    index1 = - 1 ;
    for i in range ( index - 1 , - 1 , - 1 ) :
        digit = s [ i ] - '0' ;
        if ( digit != 8 ) :
            index1 = i ;
            break ;
    if ( index1 == - 1 ) :
        return 2 * pow ( 10 , len ( s ) ) ;
    num = 0 ;
    for i in range ( index1 ) :
        num = num * 10 + ( s [ i ] - '0' ) ;
    if ( s [ index1 ] % 2 == 0 ) :
        num = num * 10 + ( s [ index1 ] - '0' + 2 ) ;
    else :
        num = num * 10 + ( s [ index1 ] - '0' + 1 ) ;
    for i in range ( index1 + 1 , len ( s ) ) :
        num = num * 10 ;
    return num ;
def smallestNumber ( n ) :
    num = 0 ;
    s = " " ;
    duplicate = n ;
    while ( n ) :
        s = chr ( n % 10 + 48 ) + s ;
        n = int ( n / 10 ) ;
    index = - 1 ;
    for i in range ( len ( s ) ) :
        digit = ord ( s [ i ] ) - ord ( '0' ) ;
        if ( digit & 1 ) :
            index = i ;
            break ;
    if ( index == - 1 ) :
        return duplicate ;
    if ( s [ index ] == '9' ) :
        num = trickyCase ( s , index ) ;
        return num ;
    for i in range ( index ) :
        num = num * 10 + ord ( s [ i ] ) - ord ( '0' ) ;
    num = num * 10 + ( ord ( s [ index ] ) - ord ( '0' ) + 1 ) ;
    for i in range ( index + 1 , len ( s ) ) :
        num = num * 10 ;
    return num ;
N = 2397 ;
print ( smallestNumber ( N ) ) ;

Index/key variables: i, index, index1
Iterator variables: i
Python program:
def findNth ( n ) :
    count = 0 ;
    curr = 19 ;
    while ( True ) :
        sum = 0 ;
        x = curr ;
        while ( x > 0 ) :
            sum = sum + x % 10 ;
            x = int ( x / 10 ) ;
        if ( sum == 10 ) :
            count += 1 ;
        if ( count == n ) :
            return curr ;
        curr += 9 ;
    return - 1 ;
print ( findNth ( 5 ) ) ;

Accumulator variables: count, curr
Python program:
def findSum ( n ) :
    sm = 0
    for i in range ( 1 , n + 1 ) :
        for j in range ( i , n + 1 ) :
            sm = sm + i * j
    return sm
n = 5
print ( findSum ( n ) )

Iterator variables: i, j
Python program:
def findSum ( n ) :
    multiTerms = n * ( n + 1 ) // 2
    sm = multiTerms
    for i in range ( 2 , n + 1 ) :
        multiTerms = multiTerms - ( i - 1 )
        sm = sm + multiTerms * i
    return sm
n = 5
print ( findSum ( n ) )

Iterator variables: i
Python program:
def checkFibinnary ( n ) :
    prev_last = 0
    while ( n ) :
        if ( ( n & 1 ) and prev_last ) :
            return False
        prev_last = n & 1
        n >>= 1
    return True
n = 10
if ( checkFibinnary ( n ) ) :
    print ( " YES " )
else :
    print ( " NO " )

Accumulator variables: n
Python program:
import math
def isDvisibleBy12 ( num ) :
    if ( len ( num ) >= 3 ) :
        d1 = int ( num [ len ( num ) - 1 ] ) ;
        if ( d1 % 2 != 0 ) :
            return False
        d2 = int ( num [ len ( num ) - 2 ] )
        sum = 0
        for i in range ( 0 , len ( num ) ) :
            sum += int ( num [ i ] )
        return ( sum % 3 == 0 and ( d2 * 10 + d1 ) % 4 == 0 )
    else :
        number = int ( num )
        return ( number % 12 == 0 )
num = "12244824607284961224"
if ( isDvisibleBy12 ( num ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Index/key variables: i
Accumulator variables: sum
Iterator variables: i
Python program:
import math
def check ( n ) :
    d = int ( math . sqrt ( n ) )
    if ( d * d == n ) :
        return True
    return False
def largestNonPerfectSquareNumber ( a , n ) :
    maxi = - 1
    for i in range ( 0 , n ) :
        if ( check ( a [ i ] ) == False ) :
            maxi = max ( a [ i ] , maxi )
    return maxi
a = [ 16 , 20 , 25 , 2 , 3 , 10 ]
n = len ( a )
print ( largestNonPerfectSquareNumber ( a , n ) )

Index/key variables: i
Iterator variables: i
Python program:
def countZeros ( a , n ) :
    count2 = 0
    count5 = 0
    for i in range ( 0 , n ) :
        while ( a [ i ] % 2 == 0 ) :
            a [ i ] = a [ i ] // 2
            count2 = count2 + 1
        while ( a [ i ] % 5 == 0 ) :
            a [ i ] = a [ i ] // 5
            count5 = count5 + 1
    if ( count2 < count5 ) :
        return count2
    else :
        return count5
a = [ 10 , 100 , 20 , 30 , 50 , 90 , 12 , 80 ]
n = len ( a )
print ( countZeros ( a , n ) )

Index/key variables: i
Iterator variables: i
Python program:
import math
pwr = [ 0 ] * 10
def isMunchhausen ( n ) :
    sm = 0
    temp = n
    while ( temp ) :
        sm = sm + pwr [ ( temp % 10 ) ]
        temp = temp // 10
    return ( sm == n )
def printMunchhausenNumbers ( n ) :
    for i in range ( 0 , 10 ) :
        pwr [ i ] = math . pow ( ( float ) ( i ) , ( float ) ( i ) )
    for i in range ( 1 , n + 1 ) :
        if ( isMunchhausen ( i ) ) :
            print ( i )
n = 10000
printMunchhausenNumbers ( n )

Index/key variables: i
Iterator variables: i
Python program:
def maxArea ( A ) :
    l = 0
    r = len ( A ) - 1
    area = 0
    while l < r :
        area = max ( area , min ( A [ l ] , A [ r ] ) * ( r - l ) )
        if A [ l ] < A [ r ] :
            l += 1
        else :
            r -= 1
    return area
a = [ 1 , 5 , 4 , 3 ]
b = [ 3 , 1 , 2 , 4 , 5 ]
print ( maxArea ( a ) )
print ( maxArea ( b ) )

Index/key variables: l, r
Python program:
import math
def isPrime ( n ) :
    if ( n < 2 ) :
        return False
    for i in range ( 2 , n + 1 ) :
        if ( n % i == 0 ) :
            return False
        i = i * i
    return True
def mobius ( n ) :
    p = 0
    if ( n % 2 == 0 ) :
        n = int ( n / 2 )
        p = p + 1
        if ( n % 2 == 0 ) :
            return 0
    for i in range ( 3 , int ( math . sqrt ( n ) ) + 1 ) :
        if ( n % i == 0 ) :
            n = int ( n / i )
            p = p + 1
            if ( n % i == 0 ) :
                return 0
        i = i + 2
    if ( p % 2 == 0 ) :
        return - 1
    else :
        return 1
N = 17
print ( " Mobius defs M ( N ) at N = { } is : { } " . format ( N , mobius ( N ) ) ) ;
print ( " Mobius defs M ( N ) at N = 25 is : { } " . format ( mobius ( 25 ) ) ) ;
print ( " Mobius defs M ( N ) at N = 6 is : { } " . format ( mobius ( 6 ) ) ) ;

Iterator variables: i
Python program:
def factorial ( start , end ) :
    res = 1
    for i in range ( start , end + 1 ) :
        res *= i
    return res
def sumofsquare ( n ) :
    return int ( factorial ( n + 1 , 2 * n ) / factorial ( 1 , n ) )
n = 4
print ( sumofsquare ( n ) )

Accumulator variables: res
Iterator variables: i
Python program:
PHI = 1.6180339
f = [ 0 , 1 , 1 , 2 , 3 , 5 ]
def fib ( n ) :
    if n < 6 :
        return f [ n ]
    t = 5
    fn = 5
    while t < n :
        fn = round ( fn * PHI )
        t += 1
    return fn
n = 9
print ( n , " th ▁ Fibonacci ▁ Number ▁ = " , fib ( n ) )

Index/key variables: n
Accumulator variables: t
Python program:
def precisionCompute ( x , y , n ) :
    if y == 0 :
        print ( " Infinite " ) ;
        return ;
    if x == 0 :
        print ( 0 ) ;
        return ;
    if n <= 0 :
        print ( x / y ) ;
        return ;
    if ( ( ( x > 0 ) and ( y < 0 ) ) or ( ( x < 0 ) and ( y > 0 ) ) ) :
        print ( " - " , end = " " ) ;
        if x < 0 :
            x = - x ;
        if y < 0 :
            y = - y ;
    d = x / y ;
    for i in range ( 0 , n + 1 ) :
        print ( d ) ;
        x = x - ( y * d ) ;
        if x == 0 :
            break ;
        x = x * 10 ;
        d = x / y ;
        if ( i == 0 ) :
            print ( " . " , end = " " ) ;
x = 22 ;
y = 7 ;
n = 15 ;
precisionCompute ( x , y , n ) ;

Iterator variables: i
Python program:
def getResult ( st ) :
    sum = 0
    length = len ( st )
    for i in st :
        sum = sum + int ( i ) ** length
    number = int ( st )
    if ( number == sum ) :
        return " true "
    else :
        return " false "
st = "153"
print ( getResult ( st ) )

Iterator variables: i
Python program:
def nthSHN ( n , dp ) :
    if ( n == 1 or n == 2 ) :
        dp [ n ] = 1
        return dp [ n ]
    if ( dp [ n ] != - 1 ) :
        return dp [ n ]
    dp [ n ] = ( ( 6 * n - 9 ) * nthSHN ( n - 1 , dp ) - ( n - 3 ) * nthSHN ( n - 2 , dp ) ) / n
    return dp [ n ]
n = 6 ;
dp = [ - 1 for i in range ( 500 ) ]
print ( nthSHN ( n , dp ) )

Index/key variables: n
Python program:
def evensum ( n ) :
    curr = 2
    sum = 0
    i = 1
    while i <= n :
        sum += curr
        curr += 2
        i = i + 1
    return sum
n = 20
print ( " sum ▁ of ▁ first ▁ " , n , " even ▁ number ▁ is : ▁ " , evensum ( n ) )

Accumulator variables: curr, sum
Python program:
def gcd ( a , b ) :
    if ( a == 0 ) :
        return b
    return gcd ( b % a , a )
def findNumber ( arr , n ) :
    ans = arr [ 0 ]
    for i in range ( 0 , n ) :
        ans = gcd ( ans , arr [ i ] )
    for i in range ( 0 , n ) :
        if ( arr [ i ] == ans ) :
            return ans
    return - 1
arr = [ 2 , 2 , 4 ] ;
n = len ( arr )
print ( findNumber ( arr , n ) )

Index/key variables: i
Iterator variables: i
Python program:
primes = [ ] ;
def SieveofEratosthenes ( n ) :
    visited = [ False ] * ( n + 2 ) ;
    for i in range ( 2 , n + 2 ) :
        if ( visited [ i ] == False ) :
            for j in range ( i * i , n + 2 , i ) :
                visited [ j ] = True ;
            primes . append ( i ) ;
def specialPrimeNumbers ( n , k ) :
    SieveofEratosthenes ( n ) ;
    count = 0 ;
    for i in range ( len ( primes ) ) :
        for j in range ( i - 1 ) :
            if ( primes [ j ] + primes [ j + 1 ] + 1 == primes [ i ] ) :
                count += 1 ;
                break ;
        if ( count == k ) :
            return True ;
    return False ;
n = 27 ;
k = 2 ;
if ( specialPrimeNumbers ( n , k ) ) :
    print ( " YES " ) ;
else :
    print ( " NO " ) ;

Index/key variables: i, j
Accumulator variables: count, primes
Iterator variables: i, j
Python program:
import math
def factorize ( n ) :
    count = 0 ;
    while ( ( n % 2 > 0 ) == False ) :
        n >>= 1 ;
        count += 1 ;
    if ( count > 0 ) :
        print ( 2 , count ) ;
    for i in range ( 3 , int ( math . sqrt ( n ) ) + 1 ) :
        count = 0 ;
        while ( n % i == 0 ) :
            count += 1 ;
            n = int ( n / i ) ;
        if ( count > 0 ) :
            print ( i , count ) ;
        i += 2 ;
    if ( n > 2 ) :
        print ( n , 1 ) ;
n = 1000000000000000000 ;
factorize ( n ) ;

Accumulator variables: count, n
Iterator variables: i
Python program:
def __gcd ( a , b ) :
    if ( a == 0 ) :
        return b
    return __gcd ( b % a , a )
def minimumMoves ( A , N ) :
    one = 0
    for i in range ( N ) :
        if ( A [ i ] == 1 ) :
            one += 1
    if ( one != 0 ) :
        return N - one
    minimum = + 2147483647
    for i in range ( N ) :
        g = A [ i ]
        for j in range ( i + 1 , N ) :
            g = __gcd ( A [ j ] , g )
            if ( g == 1 ) :
                minimum = min ( minimum , j - i )
                break
    if ( minimum == + 2147483647 ) :
        return - 1
    else :
        return N + minimum - 1 ;
A = [ 2 , 4 , 3 , 9 ]
N = len ( A )
print ( minimumMoves ( A , N ) )

Index/key variables: i, j
Accumulator variables: one
Iterator variables: i, j
Python program:
import math
def series ( n , d ) :
    if d == 0 :
        for i in range ( n ) :
            print ( "0" , end = ' ▁ ' )
        return 1
    if n % 2 == 0 :
        i = 1
        while i <= n :
            print ( " % .5f " % ( ( math . pow ( - 1 , i ) * d ) ) , end = ' ▁ ' )
            i += 1
    else :
        m = n
        r = ( m / ( m - 1 ) )
        g = ( float ) ( d * float ( math . sqrt ( r ) ) )
        print ( "0 ▁ " , end = ' ▁ ' )
        i = 1
        while i < n :
            print ( " % .5f " % ( math . pow ( - 1 , i ) * g ) , end = ' ▁ ' )
            i = i + 1
    print ( " " )
n = 3
d = 3
series ( n , d )

Iterator variables: i
Python program:
def countDigitOne ( n ) :
    countr = 0 ;
    for i in range ( 1 , n + 1 ) :
        str1 = str ( i ) ;
        countr += str1 . count ( "1" ) ;
    return countr ;
n = 13 ;
print ( countDigitOne ( n ) ) ;
n = 131 ;
print ( countDigitOne ( n ) ) ;
n = 159 ;
print ( countDigitOne ( n ) ) ;

Accumulator variables: countr
Iterator variables: i
Python program:
import math
def calculate ( a , b , n , m ) :
    mul = 1
    for i in range ( m ) :
        if ( b [ i ] != 0 ) :
            mul = mul * b [ i ]
    for i in range ( n ) :
        x = math . floor ( a [ i ] / mul )
        print ( x , end = " ▁ " )
a = [ 5 , 100 , 8 ]
b = [ 2 , 3 ]
n = len ( a )
m = len ( b )
calculate ( a , b , n , m )

Index/key variables: i
Iterator variables: i
Python program:
import sys
def findPowerOfP ( n , p ) :
    count = 0
    r = p
    while ( r <= n ) :
        count += ( n // r )
        r = r * p
    return count
def primeFactorsofK ( k ) :
    ans = [ ]
    i = 2
    while k != 1 :
        if k % i == 0 :
            count = 0
            while k % i == 0 :
                k = k // i
                count += 1
            ans . append ( [ i , count ] )
        i += 1
    return ans
def largestPowerOfK ( n , k ) :
    vec = primeFactorsofK ( k )
    ans = sys . maxsize
    for i in range ( len ( vec ) ) :
        ans = min ( ans , findPowerOfP ( n , vec [ i ] [ 0 ] ) // vec [ i ] [ 1 ] )
    return ans
print ( largestPowerOfK ( 7 , 2 ) )
print ( largestPowerOfK ( 10 , 9 ) )

Index/key variables: i
Accumulator variables: ans, count
Iterator variables: i
Python program:
def bomb_required ( n ) :
    print ( n + n // 2 )
    for i in range ( 2 , n + 1 , 2 ) :
        print ( i , end = " ▁ " )
    for i in range ( 1 , n + 1 , 2 ) :
        print ( i , end = " ▁ " )
    for i in range ( 2 , n , 2 ) :
        print ( i , end = " ▁ " )
bomb_required ( 3 )

Iterator variables: i
Python program:
def countXorPair ( arr , n ) :
    count = 0
    for i in range ( n ) :
        for j in range ( i + 1 , n ) :
            if ( ( arr [ i ] ^ arr [ j ] ) % 2 == 1 ) :
                count += 1
    return count
if __name__ == " _ _ main _ _ " :
    arr = [ 1 , 2 , 3 ]
    n = len ( arr )
    print ( countXorPair ( arr , n ) )

Index/key variables: i, j
Accumulator variables: count
Iterator variables: i, j
Python program:
import math ;
def powmod ( x , y , p ) :
    while ( y > 0 ) :
        if ( y & 1 ) :
            res = ( res * x ) % p ;
        x = ( x * x ) % p ;
    return res ;
def discreteLogarithm ( a , b , m ) :
    n = int ( math . sqrt ( m ) + 1 ) ;
    value = [ 0 ] * m ;
    for i in range ( n , 0 , - 1 ) :
        value [ powmod ( a , i * n , m ) ] = i ;
    for j in range ( n ) :
        cur = ( powmod ( a , j , m ) * b ) % m ;
        if ( value [ cur ] ) :
            ans = value [ cur ] * n - j ;
            if ( ans < m ) :
                return ans ;
    return - 1 ;
a = 2 ;
b = 3 ;
m = 5 ;
print ( discreteLogarithm ( a , b , m ) ) ;
a = 3 ;
b = 7 ;
m = 11 ;
print ( discreteLogarithm ( a , b , m ) ) ;

Index/key variables: cur
Iterator variables: i, j
Python program:
import math ;
def discreteLogarithm ( a , b , m ) :
    n = int ( math . sqrt ( m ) + 1 ) ;
    an = 1 ;
    for i in range ( n ) :
        an = ( an * a ) % m ;
    value = [ 0 ] * m ;
    cur = an ;
    for i in range ( 1 , n + 1 ) :
        if ( value [ cur ] == 0 ) :
            value [ cur ] = i ;
        cur = ( cur * an ) % m ;
    cur = b ;
    for i in range ( n + 1 ) :
        if ( value [ cur ] > 0 ) :
            ans = value [ cur ] * n - i ;
            if ( ans < m ) :
                return ans ;
        cur = ( cur * a ) % m ;
    return - 1 ;
a = 2 ;
b = 3 ;
m = 5 ;
print ( discreteLogarithm ( a , b , m ) ) ;
a = 3 ;
b = 7 ;
m = 11 ;
print ( discreteLogarithm ( a , b , m ) ) ;

Index/key variables: cur
Iterator variables: i
Python program:
def nthprimedigitsnumber ( number ) :
    num = " " ;
    while ( number > 0 ) :
        rem = number % 4 ;
        if ( rem == 1 ) :
            num += '2' ;
        if ( rem == 2 ) :
            num += '3' ;
        if ( rem == 3 ) :
            num += '5' ;
        if ( rem == 0 ) :
            num += '7' ;
        if ( number % 4 == 0 ) :
            number = number - 1
        number = number // 4 ;
    return num [ : : - 1 ] ;
number = 21 ;
print ( nthprimedigitsnumber ( 10 ) ) ;
print ( nthprimedigitsnumber ( number ) ) ;

Accumulator variables: num
Python program:
import math
def countPairs ( N ) :
    count = 0
    for i in range ( 1 , int ( math . pow ( N , 1 / 3 ) + 1 ) ) :
        cb = i * i * i
        diff = N - cb
        cbrtDiff = int ( math . pow ( diff , 1 / 3 ) )
        if ( cbrtDiff * cbrtDiff * cbrtDiff == diff ) :
            count += 1
    return count
for i in range ( 1 , 11 ) :
    print ( ' For ▁ n ▁ = ▁ ' , i , ' , ▁ ' , countPairs ( i ) , ' ▁ pair ▁ exists ' )

Accumulator variables: count
Iterator variables: i
Python program:
def printEqualModNumbers ( arr , n ) :
    arr . sort ( ) ;
    d = arr [ n - 1 ] - arr [ 0 ] ;
    if ( d == 0 ) :
        print ( " Infinite ▁ solution " )
        return
    v = [ ] ;
    i = 1 ;
    while ( i * i <= d ) :
        if ( d % i == 0 ) :
            v . append ( i ) ;
            if ( i != d / i ) :
                v . append ( d / i ) ;
        i += 1 ;
    for i in range ( len ( v ) ) :
        temp = arr [ 0 ] % v [ i ] ;
        j = 1 ;
        while ( j < n ) :
            if ( arr [ j ] % v [ i ] != temp ) :
                break ;
            j += 1 ;
        if ( j == n ) :
            print ( v [ i ] , end = " ▁ " ) ;
arr = [ 38 , 6 , 34 ] ;
printEqualModNumbers ( arr , len ( arr ) ) ;

Index/key variables: i, j
Accumulator variables: v
Iterator variables: i
Python program:
import math
def FirstDigit ( arr , n ) :
    S = 0
    for i in range ( n ) :
        S = S + math . log10 ( arr [ i ] * 1.0 )
    fract_S = S - math . floor ( S )
    ans = math . pow ( 10 , fract_S )
    return ans
arr = [ 5 , 8 , 3 , 7 ]
n = len ( arr )
print ( ( int ) ( FirstDigit ( arr , n ) ) )

Index/key variables: i
Iterator variables: i
Python program:
def countDigit ( n ) :
    temp = n
    count = 0
    while temp != 0 :
        d = temp % 10
        temp //= 10
        if d > 0 and n % d == 0 :
            count += 1
    return count
n = 1012
print ( countDigit ( n ) )

Accumulator variables: count, temp
Python program:
def cbrt ( n ) :
    return ( int ) ( n ** ( 1. / 3 ) )
def printCubes ( a , b ) :
    acrt = cbrt ( a )
    bcrt = cbrt ( b )
    for i in range ( acrt , bcrt + 1 ) :
        if ( i * i * i >= a and i * i * i <= b ) :
            print ( i * i * i , " ▁ " , end = " " )
a = 24
b = 576
print ( " Perfect ▁ cubes ▁ in ▁ given ▁ range : " )
printCubes ( a , b )

Iterator variables: i
Python program:
def number0f2s ( n ) :
    count = 0
    while ( n > 0 ) :
        if ( n % 10 == 2 ) :
            count = count + 1
        n = n // 10
    return count
def numberOf2sinRange ( n ) :
    count = 0
    for i in range ( 2 , n + 1 ) :
        count = count + number0f2s ( i )
    return count
print ( numberOf2sinRange ( 22 ) )
print ( numberOf2sinRange ( 100 ) )

Iterator variables: i
Python program:
def minToggle ( arr , n ) :
    zero = [ 0 for i in range ( n + 1 + 1 ) ]
    zero [ 0 ] = 0
    for i in range ( 1 , n + 1 ) :
        if ( arr [ i - 1 ] == 0 ) :
            zero [ i ] = zero [ i - 1 ] + 1
        else :
            zero [ i ] = zero [ i - 1 ]
    ans = n
    for i in range ( 1 , n + 1 ) :
        ans = min ( ans , i - zero [ i ] + zero [ n ] - zero [ i ] )
    return ans
arr = [ 1 , 0 , 1 , 1 , 0 ]
n = len ( arr )
print ( minToggle ( arr , n ) )

Index/key variables: i, n
Iterator variables: i
Python program:
def check ( st ) :
    n = len ( st )
    if ( ( ( int ) ( st [ n - 1 ] ) % 2 ) != 0 ) :
        return False
    digitSum = 0
    for i in range ( 0 , n ) :
        digitSum = digitSum + ( int ) ( st [ i ] )
    return ( digitSum % 3 == 0 )
st = "1332"
if ( check ( st ) ) :
    print ( " Yes " )
else :
    print ( " No ▁ " )

Index/key variables: i
Iterator variables: i
Python program:
def checkRecursive ( num , rem_num , next_int , n , ans = 0 ) :
    if ( rem_num == 0 ) :
        ans += 1
    r = int ( num ** ( 1 / n ) )
    for i in range ( next_int + 1 , r + 1 ) :
        a = rem_num - int ( i ** n )
        if a >= 0 :
            ans += checkRecursive ( num , rem_num - int ( i ** n ) , i , n , 0 )
    return ans
def check ( x , n ) :
    return checkRecursive ( x , x , 0 , n )
if __name__ == ' _ _ main _ _ ' :
    print ( check ( 10 , 2 ) )

Accumulator variables: ans
Iterator variables: i
Python program:
import math ;
def reverseNum ( n ) :
    rev = 0 ;
    while ( n ) :
        rem = n % 10 ;
        rev = ( rev * 10 ) + rem ;
        n = int ( n / 10 ) ;
    return rev ;
def isPalindrom ( num ) :
    return num == reverseNum ( num ) ;
def nthPalindrome ( n , k ) :
    num = math . pow ( 10 , k - 1 ) ;
    while ( True ) :
        if ( isPalindrom ( num ) ) :
            n -= 1 ;
        if ( not n ) :
            break ;
        num += 1 ;
    return int ( num ) ;
n = 6 ;
k = 5 ;
print ( n , " th ▁ palindrome ▁ of " , k , " digit ▁ = " , nthPalindrome ( n , k ) ) ;
n = 10 ;
k = 6 ;
print ( n , " th ▁ palindrome ▁ of " , k , " digit ▁ = " , nthPalindrome ( n , k ) ) ;

Accumulator variables: n, num