dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
import math
def getPerfectSquares ( n ) :
    perfectSquares = [ ]
    current = 1
    i = 1
    while ( current <= n ) :
        perfectSquares . append ( current )
        i += 1
        current = i ** 2
    return perfectSquares
def countTriplets ( n ) :
    perfectSquares = getPerfectSquares ( n ** 2 )
    count = 0
    for a in range ( 1 , n + 1 ) :
        aSquare = a ** 2
        for i in range ( len ( perfectSquares ) ) :
            cSquare = perfectSquares [ i ]
            bSquare = abs ( cSquare - aSquare )
            b = math . sqrt ( bSquare )
            b = int ( b )
            c = math . sqrt ( cSquare )
            c = int ( c )
            if ( c < a or ( bSquare not in perfectSquares ) ) :
                continue
            if ( ( b >= a ) and ( b <= c ) and ( aSquare + bSquare == cSquare ) ) :
                count += 1
    return count
if __name__ == " _ _ main _ _ " :
    n = 10
    print ( countTriplets ( n ) )

Index/key variables: i
Accumulator variables: count, perfectSquares
Iterator variables: a, i
Python program:
def calcDeterminant ( arr , n ) :
    determinant = 0
    for i in range ( n ) :
        determinant += pow ( arr [ i ] , 3 )
    determinant -= 3 * arr [ 0 ] * arr [ 1 ] * arr [ 2 ]
    return determinant
arr = [ 4 , 5 , 3 ]
n = len ( arr )
print ( calcDeterminant ( arr , n ) )

Index/key variables: i
Accumulator variables: determinant
Iterator variables: i
Python program:
def MinSteps ( SourceX , SourceY , DestX , DestY ) :
    print ( max ( abs ( SourceX - DestX ) , abs ( SourceY - DestY ) ) )
    while ( ( SourceX != DestX ) or ( SourceY != DestY ) ) :
        if ( SourceX < DestX ) :
            print ( ' U ' , end = " " )
            SourceX += 1
        if ( SourceX > DestX ) :
            print ( ' D ' , end = " " )
            SourceX -= 1
        if ( SourceY > DestY ) :
            print ( ' L ' )
            SourceY -= 1
        if ( SourceY < DestY ) :
            print ( ' R ' , end = " " )
            SourceY += 1
if __name__ == ' _ _ main _ _ ' :
    sourceX = 4
    sourceY = 4
    destinationX = 7
    destinationY = 0
    MinSteps ( sourceX , sourceY , destinationX , destinationY )

Accumulator variables: SourceX, SourceY
Python program:
def getPerfectSquares ( n ) :
    perfectSquares = [ ] ;
    current = 1 ;
    i = 1 ;
    while ( current <= n ) :
        perfectSquares . append ( current ) ;
        i += 1 ;
        current = int ( pow ( i , 2 ) ) ;
    return perfectSquares ;
def maxPairSum ( arr ) :
    n = len ( arr ) ;
    max = 0 ;
    secondMax = 0 ;
    if ( arr [ 0 ] > arr [ 1 ] ) :
        max = arr [ 0 ] ;
        secondMax = arr [ 1 ] ;
    else :
        max = arr [ 1 ] ;
        secondMax = arr [ 0 ] ;
    for i in range ( 2 , n ) :
        if ( arr [ i ] > max ) :
            secondMax = max ;
            max = arr [ i ] ;
        elif ( arr [ i ] > secondMax ) :
            secondMax = arr [ i ] ;
    return ( max + secondMax ) ;
def countPairsWith ( n , perfectSquares , nums ) :
    count = 0 ;
    for i in range ( len ( perfectSquares ) ) :
        temp = perfectSquares [ i ] - n ;
        if ( temp > n and ( temp in nums ) ) :
            count += 1 ;
    return count ;
def countPairs ( arr ) :
    n = len ( arr ) ;
    max = maxPairSum ( arr ) ;
    perfectSquares = getPerfectSquares ( max ) ;
    nums = [ ] ;
    for i in range ( n ) :
        nums . append ( arr [ i ] ) ;
    count = 0 ;
    for i in range ( n ) :
        count += countPairsWith ( arr [ i ] , perfectSquares , nums ) ;
    return count ;
arr = [ 2 , 3 , 6 , 9 , 10 , 20 ] ;
print ( countPairs ( arr ) ) ;

Index/key variables: i
Accumulator variables: count, nums, perfectSquares
Iterator variables: i
Python program:
def findEle ( arr , n ) :
    sum = 0
    for i in range ( n ) :
        sum += arr [ i ]
    for i in range ( n ) :
        if arr [ i ] == sum - arr [ i ] :
            return arr [ i ]
    return - 1
if __name__ == " _ _ main _ _ " :
    arr = [ 1 , 2 , 3 , 6 ]
    n = len ( arr )
    print ( findEle ( arr , n ) )

Index/key variables: i
Accumulator variables: sum
Iterator variables: i
Python program:
def divisibleBy3 ( number ) :
    sumOfDigit = 0
    for i in range ( 0 , len ( number ) , 1 ) :
        sumOfDigit += ord ( number [ i ] ) - ord ( '0' )
    if ( sumOfDigit % 3 == 0 ) :
        return True
    return False
def divisibleBy25 ( number ) :
    if ( len ( number ) < 2 ) :
        return False
    length = len ( number )
    lastTwo = ( ( ord ( number [ length - 2 ] ) - ord ( '0' ) ) * 10 + ( ord ( number [ length - 1 ] ) - ord ( '0' ) ) )
    if ( lastTwo % 25 == 0 ) :
        return True
    return False
def divisibleBy75 ( number ) :
    if ( divisibleBy3 ( number ) and divisibleBy25 ( number ) ) :
        return True
    return False
if __name__ == ' _ _ main _ _ ' :
    number = "754586672150"
    divisible = divisibleBy75 ( number )
    if ( divisible ) :
        print ( " Yes " )
    else :
        print ( " No " )

Index/key variables: i
Accumulator variables: sumOfDigit
Iterator variables: i
Python program:
def successiveChange ( arr , N ) :
    result = 0 ;
    var1 = arr [ 0 ] ;
    var2 = arr [ 1 ] ;
    result = float ( var1 + var2 + ( float ( var1 * var2 ) / 100 ) ) ;
    for i in range ( 2 , N ) :
        result = ( result + arr [ i ] + ( float ( result * arr [ i ] ) / 100 ) ) ;
    return result ;
arr = [ 10 , 20 , 30 , 10 ] ;
N = len ( arr ) ;
result = successiveChange ( arr , N ) ;
print ( " Percentage ▁ change ▁ is ▁ = ▁ % .2f " % ( result ) , " % " ) ;

Index/key variables: i
Iterator variables: i
Python program:
import math
def isPrime ( n ) :
    if n <= 1 :
        return False
    if n == 2 :
        return True
    if n % 2 == 0 :
        return False
    for i in range ( 3 , int ( math . sqrt ( n ) ) + 1 , 2 ) :
        if n % i == 0 :
            return False
    return True
def isPossible ( n ) :
    if isPrime ( n ) and isPrime ( n - 2 ) :
        return True
    else :
        return False
n = 13
if isPossible ( n ) == True :
    print ( " Yes " )
else :
    print ( " No " )

Iterator variables: i
Python program:
def totalPairs ( arr1 , arr2 , K , n , m ) :
    s = { }
    for i in range ( n ) :
        for j in range ( m ) :
            if ( arr1 [ i ] > arr2 [ j ] ) :
                if ( arr1 [ i ] % arr2 [ j ] == K ) :
                    s [ ( arr1 [ i ] , arr2 [ j ] ) ] = 1
            else :
                if ( arr2 [ j ] % arr1 [ i ] == K ) :
                    s [ ( arr2 [ j ] , arr1 [ i ] ) ] = 1
    return len ( s )
arr1 = [ 8 , 3 , 7 , 50 ]
arr2 = [ 5 , 1 , 10 , 4 ]
K = 3
n = len ( arr1 )
m = len ( arr2 )
print ( totalPairs ( arr1 , arr2 , K , n , m ) )

Index/key variables: i, j
Iterator variables: i, j
Python program:
from math import sqrt
def contiguousPerfectSquare ( arr , n ) :
    current_length = 0
    max_length = 0
    for i in range ( 0 , n , 1 ) :
        b = sqrt ( arr [ i ] )
        a = int ( b )
        if ( a == b ) :
            current_length += 1
        else :
            current_length = 0
        max_length = max ( max_length , current_length )
    return max_length
if __name__ == ' _ _ main _ _ ' :
    arr = [ 9 , 75 , 4 , 64 , 121 , 25 ]
    n = len ( arr )
    print ( contiguousPerfectSquare ( arr , n ) )

Index/key variables: i
Accumulator variables: current_length
Iterator variables: i
Python program:
def countPairs ( n ) :
    count = 0
    for x in range ( 1 , n ) :
        for y in range ( x + 1 , n + 1 ) :
            if ( ( y * x ) % ( y + x ) == 0 ) :
                count += 1
    return count
n = 15
print ( countPairs ( n ) )

Accumulator variables: count
Iterator variables: x, y
Python program:
def getIndex ( a , n ) :
    if ( n == 1 ) :
        return 0
    ptrL = 0
    ptrR = n - 1
    sumL = a [ 0 ]
    sumR = a [ n - 1 ]
    while ( ptrR - ptrL > 1 ) :
        if ( sumL < sumR ) :
            ptrL += 1
            sumL += a [ ptrL ]
        elif ( sumL > sumR ) :
            ptrR -= 1
            sumR += a [ ptrR ]
        else :
            break
    return ptrL
if __name__ == " _ _ main _ _ " :
    a = [ 2 , 7 , 9 , 8 , 7 ]
    n = len ( a )
    print ( getIndex ( a , n ) )

Index/key variables: ptrL, ptrR
Accumulator variables: sumL, sumR
Python program:
import math as mt
def getPosition ( a , n , m ) :
    for i in range ( n ) :
        a [ i ] = ( a [ i ] // m + ( a [ i ] % m != 0 ) )
    ans , maxx = - 1 , - 1
    for i in range ( n - 1 , - 1 , - 1 ) :
        if ( maxx < a [ i ] ) :
            maxx = a [ i ]
            ans = i
    return ans + 1
a = [ 2 , 5 , 4 ]
n = len ( a )
m = 2
print ( getPosition ( a , n , m ) )

Index/key variables: i
Iterator variables: i
Python program:
def calcFunction ( n , r ) :
    finalDenominator = 1
    mx = max ( r , n - r )
    for i in range ( mx + 1 , n + 1 ) :
        denominator = pow ( i , i )
        numerator = pow ( i - mx , i - mx )
        finalDenominator = ( finalDenominator * denominator ) // numerator
    return finalDenominator
if __name__ == " _ _ main _ _ " :
    n = 6
    r = 2
    print ( "1 / " , end = " " )
    print ( calcFunction ( n , r ) )

Iterator variables: i
Python program:
def isExists ( a , n ) :
    freq = { i : 0 for i in a }
    Sum = 0
    for i in range ( n ) :
        freq [ a [ i ] ] += 1
        Sum += a [ i ]
    if Sum % 2 == 0 :
        if freq [ Sum // 2 ] :
            return True
    return False
a = [ 5 , 1 , 2 , 2 ]
n = len ( a )
if isExists ( a , n ) :
    print ( " Yes " )
else :
    print ( " No " )

Index/key variables: i
Accumulator variables: Sum
Iterator variables: i
Python program:
st = set ( )
def generateNumbers ( n , num , a , b ) :
    if ( num > 0 and num < n ) :
        st . add ( num )
    if ( num >= n ) :
        return
    if ( num * 10 + a > num ) :
        generateNumbers ( n , num * 10 + a , a , b )
    generateNumbers ( n , num * 10 + b , a , b )
def printNumbers ( n ) :
    for i in range ( 10 ) :
        for j in range ( i + 1 , 10 , 1 ) :
            generateNumbers ( n , 0 , i , j )
    print ( " The ▁ numbers ▁ are : " , end = " ▁ " )
    l = list ( st )
    for i in l :
        print ( i , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
    n = 12
    printNumbers ( n )

Iterator variables: i, j
Python program:
def findPrime ( MAX ) :
    pm = [ True ] * ( MAX + 1 )
    pm [ 0 ] , pm [ 1 ] = False , False
    for i in range ( 2 , MAX + 1 ) :
        if pm [ i ] == True :
            for j in range ( 2 * i , MAX + 1 , i ) :
                pm [ j ] = False
    prime = [ ]
    for i in range ( 0 , MAX + 1 ) :
        if pm [ i ] == True :
            prime . append ( i )
    return prime
def findSmallest ( arr , n ) :
    MAX = max ( arr )
    prime = findPrime ( MAX )
    s = set ( )
    for i in range ( 0 , n ) :
        s . add ( arr [ i ] )
    ans = - 1
    for i in range ( 0 , len ( prime ) ) :
        if prime [ i ] not in s :
            ans = prime [ i ]
            break
    return ans
if __name__ == " _ _ main _ _ " :
    arr = [ 3 , 0 , 1 , 2 , 7 ]
    n = len ( arr )
    if ( findSmallest ( arr , n ) == - 1 ) :
        print ( " No ▁ prime ▁ number ▁ missing " )
    else :
        print ( findSmallest ( arr , n ) )

Index/key variables: i, j
Accumulator variables: prime, s
Iterator variables: i, j
Python program:
def findNum ( div , rem , N ) :
    num = rem [ N - 1 ]
    i = N - 2
    while ( i >= 0 ) :
        num = num * div [ i ] + rem [ i ]
        i -= 1
    return num
if __name__ == ' _ _ main _ _ ' :
    div = [ 8 , 3 ]
    rem = [ 2 , 2 ]
    N = len ( div )
    print ( findNum ( div , rem , N ) )

Index/key variables: i
Python program:
from collections import defaultdict
mod = 1000000007
MAX = 100000
ways = [ None ] * ( MAX + 1 )
def preCompute ( ) :
    ways [ 0 ] = 1
    ways [ 2 ] = 1
    for i in range ( 4 , MAX + 1 , 2 ) :
        ways [ i ] = ( ( 1 * ( i - 1 ) * ways [ i - 2 ] ) % mod )
def countWays ( arr , n ) :
    count = defaultdict ( lambda : 0 )
    for i in range ( 0 , n ) :
        count [ arr [ i ] ] += 1
    count_vector = [ ]
    for key in count :
        count_vector . append ( [ key , count [ key ] ] )
    count_vector . sort ( )
    ans = 1
    for i in range ( len ( count_vector ) - 1 , - 1 , - 1 ) :
        current_count = count_vector [ i ] [ 1 ]
        prev_count = count_vector [ i - 1 ] [ 1 ]
        if current_count & 1 :
            ans = ( ans * ways [ current_count - 1 ] ) % mod
            ans = ( ans * current_count ) % mod
            ans = ( ans * prev_count ) % mod
            if prev_count & 1 :
                ans = ( ans * ways [ prev_count - 1 ] ) % mod
                count_vector [ i - 1 ] [ 1 ] = 0
            else :
                count_vector [ i - 1 ] [ 1 ] -= 1
        else :
            ans = ( ans * ways [ current_count ] ) % mod
    ans = ( ans * ways [ count_vector [ 0 ] [ 1 ] ] ) % mod
    print ( ans )
if __name__ == " _ _ main _ _ " :
    preCompute ( )
    arr = [ 2 , 3 , 3 , 3 , 3 , 4 , 4 , 4 , 4 , 4 ]
    n = len ( arr )
    countWays ( arr , n )

Index/key variables: current_count, i, key
Accumulator variables: count_vector
Iterator variables: i, key
Python program:
from collections import defaultdict
def niceIndices ( A , n ) :
    Sum = 0
    m = defaultdict ( lambda : 0 )
    for i in range ( n ) :
        m [ A [ i ] ] += 1
        Sum += A [ i ]
    for i in range ( n ) :
        k = Sum - A [ i ]
        if k % 2 == 0 :
            k = k >> 1
            if k in m :
                if ( ( A [ i ] == k and m [ k ] > 1 ) or ( A [ i ] != k ) ) :
                    print ( ( i + 1 ) , end = " ▁ " )
if __name__ == " _ _ main _ _ " :
    A = [ 8 , 3 , 5 , 2 ]
    n = len ( A )
    niceIndices ( A , n )

Index/key variables: i, k
Accumulator variables: Sum
Iterator variables: i
Python program:
def productSumDivisible ( n , size ) :
    sum = 0
    product = 1
    while ( n > 0 ) :
        if ( size % 2 == 0 ) :
            product *= n % 10
        else :
            sum += n % 10
        n = n // 10
        size -= 1
    if ( product % sum == 0 ) :
        return True
    return False
if __name__ == " _ _ main _ _ " :
    n = 1234
    len = 4
    if ( productSumDivisible ( n , len ) ) :
        print ( " TRUE " )
    else :
        print ( " FALSE " )

Accumulator variables: product, size, sum
Python program:
def productSumDivisible ( n ) :
    sum = 0
    product = 1
    num = str ( n )
    for i in range ( len ( num ) ) :
        if ( i % 2 != 0 ) :
            product = product * int ( num [ i ] )
        else :
            sum = sum + int ( num [ i ] )
    if ( product % sum == 0 ) :
        return True
    return False
if __name__ == " _ _ main _ _ " :
    n = 1234
    if ( productSumDivisible ( n ) ) :
        print ( " TRUE " )
    else :
        print ( " FALSE " )

Index/key variables: i
Iterator variables: i
Python program:
def gcd ( a , b ) :
    if ( a == 0 ) :
        return b
    return gcd ( b % a , a )
def powGCD ( a , n , b ) :
    for i in range ( 0 , n + 1 , 1 ) :
        a = a * a
    return gcd ( a , b )
if __name__ == ' _ _ main _ _ ' :
    a = 10
    b = 5
    n = 2
    print ( powGCD ( a , n , b ) )

Iterator variables: i
Python program:
def countDigit ( n ) :
    temp = n
    sum = 0
    product = 1
    while ( temp != 0 ) :
        d = temp % 10
        temp //= 10
        if ( d > 0 and n % d == 0 ) :
            sum += d
            product *= d
    print ( " Sum ▁ = " , sum )
    print ( " Product ▁ = " , product )
if __name__ == ' _ _ main _ _ ' :
    n = 1012
    countDigit ( n )

Accumulator variables: product, sum, temp
Python program:
def isDivisiblePalindrome ( n ) :
    hash = [ 0 ] * 10
    digitSum = 0
    while ( n ) :
        digitSum += n % 10
        hash [ n % 10 ] += 1
        n //= 10
    if ( digitSum % 3 != 0 ) :
        return False
    oddCount = 0
    for i in range ( 10 ) :
        if ( hash [ i ] % 2 != 0 ) :
            oddCount += 1
    if ( oddCount > 1 ) :
        return False
    else :
        return True
n = 34734
if ( isDivisiblePalindrome ( n ) ) :
    print ( " True " )
else :
    print ( " False " )

Index/key variables: i
Accumulator variables: digitSum, n, oddCount
Iterator variables: i
Python program:
import math
def lcm ( a , b ) :
    return ( a * b ) // ( math . gcd ( a , b ) )
def dfs ( src , adj , visited ) :
    visited [ src ] = True
    count = 1
    if adj [ src ] != 0 :
        for i in range ( len ( adj [ src ] ) ) :
            if ( not visited [ adj [ src ] [ i ] ] ) :
                count += dfs ( adj [ src ] [ i ] , adj , visited )
    return count
def findMinTime ( arr , P , n ) :
    adj = [ 0 ] * ( n + 1 )
    for i in range ( n ) :
        if adj [ arr [ i ] ] == 0 :
            adj [ arr [ i ] ] = [ ]
        adj [ arr [ i ] ] . append ( P [ i ] )
    visited = [ 0 ] * ( n + 1 )
    ans = 1
    for i in range ( n ) :
        if ( not visited [ i ] ) :
            ans = lcm ( ans , dfs ( i , adj , visited ) )
    return ans
arr = [ 1 , 2 , 3 ]
P = [ 3 , 2 , 1 ]
n = len ( arr )
print ( findMinTime ( arr , P , n ) )

Index/key variables: i, src
Accumulator variables: count
Iterator variables: i
Python program:
def productDivisible ( n , k ) :
    product = 1
    position = 1
    while n > 0 :
        if position % 2 == 0 :
            product *= n % 10
        n = n / 10
        position += 1
    if product % k == 0 :
        return True
    return False
n = 321922
k = 3
if productDivisible ( n , k ) == True :
    print ( " YES " )
else :
    print ( " NO " )

Accumulator variables: position, product
Python program:
def productDivisible ( n , k ) :
    product = 1
    num = str ( n )
    for i in range ( len ( num ) ) :
        if ( i % 2 == 0 ) :
            product = product * int ( num [ i ] )
    if product % k == 0 :
        return True
    return False
n = 321922
k = 3
if productDivisible ( n , k ) == True :
    print ( " YES " )
else :
    print ( " NO " )

Index/key variables: i
Iterator variables: i
Python program:
def factorial ( n ) :
    fact = 1 ;
    for i in range ( 2 , n + 1 ) :
        fact = fact * i ;
    return fact ;
def npr ( n , r ) :
    pnr = factorial ( n ) / factorial ( n - r ) ;
    return pnr ;
def countPermutations ( n , r , k ) :
    return int ( factorial ( k ) * ( r - k + 1 ) * npr ( n - k , r - k ) ) ;
n = 8 ;
r = 5 ;
k = 2 ;
print ( countPermutations ( n , r , k ) ) ;

Iterator variables: i
Python program:
def factorial ( n ) :
    fact = 1
    for i in range ( 2 , n + 1 ) :
        fact = fact * i
    return fact
def ncr ( n , r ) :
    return ( factorial ( n ) // ( factorial ( r ) * factorial ( n - r ) ) )
if __name__ == " _ _ main _ _ " :
    m = 3
    n = 4
    k = 5
    totalTriangles = ( ncr ( m + n + k , 3 ) - ncr ( m , 3 ) - ncr ( n , 3 ) - ncr ( k , 3 ) )
    print ( totalTriangles )

Iterator variables: i
Python program:
def SumDivisible ( n , k ) :
    sum = 0
    position = 1
    while ( n > 0 ) :
        if ( position % 2 == 1 ) :
            sum += n % 10
        n = n // 10
        position += 1
    if ( sum % k == 0 ) :
        return True
    return False
if __name__ == " _ _ main _ _ " :
    n = 592452
    k = 3
    if ( SumDivisible ( n , k ) ) :
        print ( " YES " )
    else :
        print ( " NO " )

Accumulator variables: position, sum
Python program:
def sumDivisible ( n , k ) :
    sum = 0
    num = str ( n )
    for i in range ( len ( num ) ) :
        if ( i % 2 != 0 ) :
            sum = sum + int ( num [ i ] )
    if sum % k == 0 :
        return True
    return False
n = 592452
k = 3
if sumDivisible ( n , k ) == True :
    print ( " YES " )
else :
    print ( " NO " )

Index/key variables: i
Iterator variables: i
Python program:
import math
def findX ( n , k ) :
    r = n
    m = int ( math . sqrt ( k ) ) + 1
    i = 2
    while i <= m and k > 1 :
        if ( i == m ) :
            i = k
        u = 0
        v = 0
        while k % i == 0 :
            k //= i
            v += 1
        if ( v > 0 ) :
            t = n
            while ( t > 0 ) :
                t //= i
                u += t
            r = min ( r , u // v )
        i += 1
    return r
if __name__ == " _ _ main _ _ " :
    n = 5
    k = 2
    print ( findX ( n , k ) )

Accumulator variables: i, k, t, u, v
Python program:
def fact ( n ) :
    fact = 1
    for i in range ( 2 , n + 1 ) :
        fact *= i
    return fact
def ncr ( n , r ) :
    ncr = fact ( n ) // ( fact ( r ) * fact ( n - r ) )
    return ncr
def ways ( m , w , n , k ) :
    ans = 0
    while ( m >= k ) :
        ans += ncr ( m , k ) * ncr ( w , n - k )
        k += 1
    return ans ;
m = 7
w = 6
n = 5
k = 3
print ( ways ( m , w , n , k ) )

Accumulator variables: ans, fact, k
Iterator variables: i
Python program:
MAX = 1000000
prime = [ True ] * ( MAX + 1 )
def SieveOfEratosthenes ( ) :
    prime [ 1 ] = False ;
    prime [ 0 ] = False ;
    p = 2
    while p * p <= MAX :
        if ( prime [ p ] == True ) :
            for i in range ( p * 2 , MAX + 1 , p ) :
                prime [ i ] = False
        p += 1
def productOfKthPrimes ( arr , n , k ) :
    c = 0
    product = 1
    for i in range ( n ) :
        if ( prime [ arr [ i ] ] ) :
            c += 1
            if ( c % k == 0 ) :
                product *= arr [ i ]
                c = 0
    print ( product )
if __name__ == " _ _ main _ _ " :
    SieveOfEratosthenes ( )
    n = 5
    k = 2
    arr = [ 2 , 3 , 5 , 7 , 11 ]
    productOfKthPrimes ( arr , n , k )

Index/key variables: i, p
Accumulator variables: c, product
Iterator variables: i
Python program:
def countBits ( n ) :
    count = 0 ;
    while ( n ) :
        count += 1 ;
        n >>= 1 ;
    return count ;
n = 32 ;
print ( " Minimum ▁ value ▁ of ▁ K ▁ is ▁ = " , countBits ( n ) ) ;

Accumulator variables: count, n
Python program:
def OddDivCount ( a , b ) :
    res = 0
    for i in range ( a , b + 1 ) :
        divCount = 0
        for j in range ( 1 , i + 1 ) :
            if ( i % j == 0 ) :
                divCount += 1
        if ( divCount % 2 ) :
            res += 1
    return res
if __name__ == " _ _ main _ _ " :
    a = 1
    b = 10
    print ( OddDivCount ( a , b ) )

Accumulator variables: divCount, res
Iterator variables: i, j
Python program:
import math
def largestSquareFactor ( num ) :
    answer = 1
    for i in range ( 2 , int ( math . sqrt ( num ) ) ) :
        cnt = 0
        j = i
        while ( num % j == 0 ) :
            cnt += 1
            j *= i
        if ( cnt & 1 ) :
            cnt -= 1
            answer *= pow ( i , cnt )
        else :
            answer *= pow ( i , cnt )
    return answer
if __name__ == " _ _ main _ _ " :
    N = 420
    print ( largestSquareFactor ( N ) )

Accumulator variables: answer, cnt, j
Iterator variables: i
Python program:
def calculateDifference ( arr , n ) :
    max_val = max ( arr )
    prime = ( max_val + 1 ) * [ True ]
    prime [ 0 ] = False
    prime [ 1 ] = False
    p = 2
    while p * p <= max_val :
        if prime [ p ] == True :
            for i in range ( p * 2 , max_val + 1 , p ) :
                prime [ i ] = False
        p += 1
    P1 = 1 ; P2 = 1
    for i in range ( n ) :
        if prime [ arr [ i ] ] :
            P1 *= arr [ i ]
        elif arr [ i ] != 1 :
            P2 *= arr [ i ]
    return abs ( P2 - P1 )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 3 , 5 , 10 , 15 , 7 ]
    n = len ( arr )
    print ( calculateDifference ( arr , n ) )

Index/key variables: i, p
Accumulator variables: P1, P2
Iterator variables: i
Python program:
def EqualNumbers ( a , n ) :
    sum = 0 ;
    for i in range ( n ) :
        sum += a [ i ] ;
    if ( sum % n ) :
        return n - 1 ;
    return n ;
a = [ 1 , 4 , 1 ] ;
n = len ( a ) ;
print ( EqualNumbers ( a , n ) ) ;

Index/key variables: i
Accumulator variables: sum
Iterator variables: i