dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
import math
size = 101
fib = [ 0 ] * 100010
freq = [ 0 ] * ( 100010 )
def isPerfectSquare ( x ) :
    s = int ( math . sqrt ( x ) )
    return ( s * s ) == x
def isFibonacci ( n ) :
    if ( isPerfectSquare ( 5 * n * n + 4 ) or isPerfectSquare ( 5 * n * n - 4 ) ) :
        return 1 ;
    return 0 ;
def compute ( a , b ) :
    for i in range ( 1 , 100010 ) :
        fib [ i ] = isFibonacci ( i )
    for x in range ( 1 , 100010 ) :
        for y in range ( 1 , size ) :
            if ( fib [ x ] == 1 and fib [ y ] == 1 and a * x + b * y < 100010 ) :
                freq [ a * x + b * y ] += 1
Q = 2
A = 5
B = 10
compute ( A , B ) ;
arr = [ 50 , 150 ]
for i in range ( Q ) :
    print ( freq [ arr [ i ] ] , end = " ▁ " )

Index/key variables: i, x, y
Iterator variables: i, x, y
Python program:
MAX = 100
def findMaxSum ( n1 , n2 ) :
    arr1 = [ 0 ] * ( MAX )
    arr2 = [ 0 ] * ( MAX )
    l1 = 0
    l2 = 0
    max1 = max ( n1 , n2 ) ;
    min1 = min ( n1 , n2 ) ;
    i = max1
    while i > 0 :
        arr1 [ l1 ] = ( i % 10 )
        l1 += 1
        i //= 10
    i = min1
    while i > 0 :
        arr2 [ l2 ] = ( i % 10 )
        l2 += 1
        i //= 10
    f = 0
    if ( l1 != l2 ) :
        index = arr2 . index ( max ( arr2 ) )
        for i in range ( l1 - 1 , ( l2 - 1 ) , - 1 ) :
            if ( arr1 [ i ] < arr2 [ index ] ) :
                ( arr1 [ i ] , arr2 [ index ] ) = ( arr2 [ index ] , arr1 [ i ] )
                f = 1
                break
    if ( f != 1 ) :
        index1 = 0
        index2 = 0
        diff1 = 0
        diff2 = 0
        for i in range ( l2 - 1 , - 1 , - 1 ) :
            index1 = arr1 . index ( max ( arr1 [ : i ] ) )
            index2 = arr2 . index ( max ( arr2 [ : i ] ) )
            diff1 = ( arr2 [ index2 ] - arr1 [ i ] ) ;
            diff2 = ( arr1 [ index1 ] - arr2 [ i ] ) ;
            if ( diff1 > 0 or diff2 > 0 ) :
                if ( diff1 > diff2 ) :
                    arr1 [ i ] , arr2 [ index2 ] = arr2 [ index2 ] , arr1 [ i ]
                    break
                elif ( diff2 > diff1 ) :
                    arr2 [ i ] , arr1 [ index1 ] = arr1 [ index1 ] , arr2 [ i ]
                    break
                elif ( diff1 == diff2 ) :
                    if ( index1 <= index2 ) :
                        arr2 [ i ] , arr1 [ index1 ] = arr1 [ index1 ] , arr2 [ i ]
                        break
                    elif ( index2 <= index1 ) :
                        arr1 [ i ] , arr2 [ index2 ] = arr2 [ index2 ] , arr1 [ i ]
                        break ;
    f_n1 = 0
    f_n2 = 0
    for i in range ( l1 - 1 , - 1 , - 1 ) :
        f_n1 = ( f_n1 * 10 ) + arr1 [ i ]
        f_n2 = ( f_n2 * 10 ) + arr2 [ i ]
    print ( f_n1 + f_n2 )
N1 = 9987
N2 = 123
findMaxSum ( N1 , N2 )

Index/key variables: i, index, index1, index2, l1, l2
Iterator variables: i
Python program:
def isDivisible ( n ) :
    while n // 100 :
        d = n % 10
        n //= 10
        n = abs ( n - ( d * 14 ) )
    return ( n % 47 == 0 )
if __name__ == " _ _ main _ _ " :
    n = 59173
    if ( isDivisible ( n ) ) :
        print ( " Yes " )
    else :
        print ( " No " )

Accumulator variables: n
Python program:
def isDivisible ( n ) :
    while n // 100 :
        d = n % 10
        n //= 10
        n = abs ( n - ( d * 3 ) )
    return ( n % 31 == 0 )
if __name__ == " _ _ main _ _ " :
    n = 1922
    if ( isDivisible ( n ) ) :
        print ( " Yes " )
    else :
        print ( " No " )

Accumulator variables: n
Python program:
def isDivisible ( n ) :
    while n // 100 :
        d = n % 10
        n //= 10
        n = abs ( n + ( d * 13 ) )
    return ( n % 43 == 0 )
if __name__ == " _ _ main _ _ " :
    N = 2795
    if ( isDivisible ( N ) ) :
        print ( " Yes " )
    else :
        print ( " No " )

Accumulator variables: n
Python program:
from math import pow
def printf ( n , k ) :
    print ( int ( k ) , end = " ▁ " )
    for i in range ( 2 , n + 1 , 1 ) :
        x = pow ( k , i ) - pow ( k , i - 1 )
        print ( int ( x ) , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
    N = 3
    K = 4
    printf ( N , K )

Iterator variables: i
Python program:
def isDivisible ( n ) :
    while n // 100 :
        d = n % 10
        n //= 10
        n = abs ( n - ( d * 7 ) )
    return ( n % 71 == 0 )
if __name__ == " _ _ main _ _ " :
    N = 5041
    if ( isDivisible ( N ) ) :
        print ( " Yes " )
    else :
        print ( " No " )

Accumulator variables: n
Python program:
def countDigit ( n ) :
    prime = [ False ] * 10
    prime [ 2 ] = True
    prime [ 3 ] = True ;
    prime [ 5 ] = True
    prime [ 7 ] = True ;
    temp = n
    count = 0 ;
    while ( temp != 0 ) :
        d = temp % 10 ;
        temp //= 10 ;
        if ( d > 0 and n % d == 0 and prime [ d ] ) :
            count += 1
    return count
n = 1032
print ( countDigit ( n ) )

Index/key variables: d
Accumulator variables: count, temp
Python program:
digit = [ 0 ] * ( 100000 )
def findDigits ( n ) :
    count = 0
    while ( n != 0 ) :
        digit [ count ] = n % 10 ;
        n = n // 10 ;
        count += 1
    return count
def OR_of_Digits ( n , count ) :
    ans = 0
    for i in range ( count ) :
        ans = ans | digit [ i ]
    return ans
def AND_of_Digits ( n , count ) :
    ans = 0
    for i in range ( count ) :
        ans = ans & digit [ i ]
    return ans
def XOR_of_Digits ( n , count ) :
    ans = 0
    for i in range ( count ) :
        ans = ans ^ digit [ i ]
    return ans
def bitwise_operation ( N ) :
    countOfDigit = findDigits ( N )
    print ( " XOR ▁ = ▁ " , XOR_of_Digits ( N , countOfDigit ) )
    print ( " OR ▁ = ▁ " , OR_of_Digits ( N , countOfDigit ) )
    print ( " AND ▁ = ▁ " , AND_of_Digits ( N , countOfDigit ) )
N = 123456 ;
bitwise_operation ( N )

Index/key variables: count, i
Iterator variables: i
Python program:
def maxLength ( arr , N ) :
    product = 1
    Len = 0
    for i in arr :
        product *= i
    if ( product >= 0 ) :
        return N
    for i in range ( N ) :
        if ( arr [ i ] < 0 ) :
            Len = max ( Len , max ( N - i - 1 , i ) )
    return Len
if __name__ == ' _ _ main _ _ ' :
    arr = [ - 1 , 1 , 1 , - 2 , 3 , 2 , - 1 ]
    N = len ( arr )
    print ( maxLength ( arr , N ) )

Index/key variables: i
Accumulator variables: product
Iterator variables: i
Python program:
def findNumbers ( N ) :
    i = 1
    while ( i <= N ) :
        print ( ( i * i * i ) , end = " ▁ " )
        i += 1
if __name__ == ' _ _ main _ _ ' :
    N = 4
    findNumbers ( N )

Accumulator variables: i
Python program:
def properDivisorSum ( n ) :
    sum = 0
    for i in range ( n + 1 ) :
        for j in range ( 1 , i + 1 ) :
            if j * j > i :
                break
            if ( i % j == 0 ) :
                if ( i // j == j ) :
                    sum += j
                else :
                    sum += j + i // j
        sum = sum - i
    return sum
if __name__ == ' _ _ main _ _ ' :
    n = 4
    print ( properDivisorSum ( n ) )
    n = 5
    print ( properDivisorSum ( n ) )

Accumulator variables: sum
Iterator variables: i, j
Python program:
def properDivisorSum ( n ) :
    sum = 0
    for i in range ( 1 , n + 1 ) :
        sum += ( n // i ) * i
    return sum - n * ( n + 1 ) // 2
n = 4
print ( properDivisorSum ( n ) )
n = 5
print ( properDivisorSum ( n ) )

Accumulator variables: sum
Iterator variables: i
Python program:
def findMinimumOperation ( n , d , arrays ) :
    cnt = 0
    first = - 10 ** 9
    end = 10 ** 9
    while ( n ) :
        arr = [ arrays [ cnt ] [ 0 ] , arrays [ cnt ] [ 1 ] ]
        arr = sorted ( arr )
        first = max ( first , arr [ 0 ] )
        end = min ( end , arr [ 1 ] )
        cnt += 1
        n -= 1
    if ( first > end ) :
        print ( " - 1" , end = " " )
    else :
        if ( d >= first and d <= end ) :
            print ( "0" , end = " " )
        else :
            print ( min ( abs ( first - d ) , abs ( d - end ) ) , end = " " )
if __name__ == ' _ _ main _ _ ' :
    n = 3
    d = 3
    arrays = [ [ 0 , 7 ] , [ 2 , 14 ] , [ 4 , 6 ] ]
    findMinimumOperation ( n , d , arrays )

Index/key variables: cnt
Accumulator variables: n
Python program:
from math import sqrt
mod = 1000000007
def mult ( a , b ) :
    return ( ( a % mod ) * ( b % mod ) ) % mod
def calculate_factors ( n ) :
    cnt = 0
    ans = 1
    while ( n % 2 == 0 ) :
        cnt += 1
        n = n // 2
    if ( cnt ) :
        ans = mult ( ans , ( cnt + 1 ) )
    for i in range ( 3 , int ( sqrt ( n ) ) , 2 ) :
        cnt = 0
        while ( n % i == 0 ) :
            cnt += 1
            n = n // i
        if ( cnt ) :
            ans = mult ( ans , ( cnt + 1 ) )
    if ( n > 2 ) :
        ans = mult ( ans , 2 )
    return ans % mod
if __name__ == ' _ _ main _ _ ' :
    n = 19374857
    mod = 17
    print ( calculate_factors ( n ) )

Accumulator variables: cnt
Iterator variables: i
Python program:
def maxValue ( a ) :
    a = bin ( a ) [ 2 : ]
    b = ' '
    for i in list ( a ) :
        b += str ( int ( not int ( i ) ) )
    print ( int ( b , 2 ) )
    return int ( b , 2 )
if __name__ == ' _ _ main _ _ ' :
    a = 4
    maxValue ( a )

Accumulator variables: b
Iterator variables: i
Python program:
sz = 10 ** 5
isPrime = [ True ] * ( sz + 1 )
def generatePrime ( ) :
    i , j = 0 , 0
    isPrime [ 0 ] = isPrime [ 1 ] = False
    for i in range ( 2 , sz + 1 ) :
        if i * i > sz :
            break
        if ( isPrime [ i ] ) :
            for j in range ( i * i , sz , i ) :
                isPrime [ j ] = False
def Pair_of_PrimeXor ( A , n ) :
    for i in range ( n ) :
        for j in range ( i + 1 , n ) :
            if ( isPrime [ ( A [ i ] ^ A [ j ] ) ] ) :
                print ( " ( " , A [ i ] , " , " , A [ j ] , " ) " , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
    A = [ 1 , 3 , 6 , 11 ]
    n = len ( A )
    generatePrime ( )
    Pair_of_PrimeXor ( A , n )

Index/key variables: i, j
Iterator variables: i, j
Python program:
def getnumbers ( n ) :
    divisor = [ ]
    for i in range ( 2 , n + 1 ) :
        while ( n % i == 0 ) :
            divisor . append ( i )
            n //= i
    if ( n != 1 ) :
        divisor . append ( n )
    a , b , c , size = 0 , 0 , 0 , 0
    a = b = c = 1
    size = len ( divisor )
    for i in range ( size ) :
        if ( a == 1 ) :
            a = a * divisor [ i ]
        elif ( b == 1 or b == a ) :
            b = b * divisor [ i ]
        else :
            c = c * divisor [ i ]
    if ( a == 1 or b == 1 or c == 1 or a == b or b == c or a == c ) :
        print ( " - 1" )
    else :
        print ( a , b , c )
n = 64
getnumbers ( n )

Index/key variables: i
Accumulator variables: divisor, n
Iterator variables: i
Python program:
def primeFactors ( n ) :
    Prime = [ ] ;
    if ( n % 2 == 0 ) :
        Prime . append ( 2 ) ;
    while ( n % 2 == 0 ) :
        n = n // 2 ;
    for i in range ( 3 , int ( n ** ( 1 / 2 ) ) , 2 ) :
        if ( n % i == 0 ) :
            Prime . append ( i ) ;
        while ( n % i == 0 ) :
            n = n // i ;
    if ( n > 2 ) :
        Prime . append ( n ) ;
    return Prime ;
def checkDistinctPrime ( n ) :
    Prime = primeFactors ( n ) ;
    product = 1 ;
    for i in Prime :
        product *= i ;
    if ( product == n ) :
        print ( " YES " ) ;
    else :
        print ( " NO " ) ;
if __name__ == " _ _ main _ _ " :
    N = 30 ;
    checkDistinctPrime ( N ) ;

Accumulator variables: Prime, product
Iterator variables: i
Python program:
def isPrime ( n ) :
    for i in range ( 2 , int ( n ** ( 1 / 2 ) ) + 1 ) :
        if ( n % i == 0 ) :
            return False ;
    return True ;
def printMinCountPrime ( N ) :
    if ( isPrime ( N ) ) :
        minCount = 1 ;
    elif ( N % 2 == 0 ) :
        minCount = 2 ;
    else :
        if ( isPrime ( N - 2 ) ) :
            minCount = 2 ;
        else :
            minCount = 3 ;
    print ( minCount ) ;
if __name__ == " _ _ main _ _ " :
    N = 100 ;
    printMinCountPrime ( N ) ;

Iterator variables: i
Python program:
INFINITY_ = 9999999
def sqrtByLongDivision ( n ) :
    i = 0
    cur_divisor = 0
    quotient_units_digit = 0
    cur_quotient = 0
    cur_dividend = 0
    cur_remainder = 0
    a = [ 0 ] * 10
    while ( n > 0 ) :
        a [ i ] = n % 100
        n = n // 100
        i += 1
    i -= 1
    for j in range ( i , - 1 , - 1 ) :
        cur_remainder = INFINITY_
        cur_dividend = cur_dividend * 100 + a [ j ]
        for udigit in range ( 10 ) :
            if ( cur_remainder >= cur_dividend - ( ( cur_divisor * 10 + udigit ) * udigit ) and cur_dividend - ( ( cur_divisor * 10 + udigit ) * udigit ) >= 0 ) :
                cur_remainder = cur_dividend - ( ( cur_divisor * 10 + udigit ) * udigit )
                quotient_units_digit = udigit
        cur_quotient = cur_quotient * 10 + quotient_units_digit
        cur_divisor = cur_quotient * 2
        cur_dividend = cur_remainder
    return cur_quotient
x = 1225
print ( sqrtByLongDivision ( x ) )

Index/key variables: i, j
Iterator variables: j, udigit
Python program:
from math import sqrt
def previousFibonacci ( n ) :
    a = n / ( ( 1 + sqrt ( 5 ) ) / 2.0 )
    return round ( a )
def nextFibonacci ( n ) :
    a = n * ( 1 + sqrt ( 5 ) ) / 2.0
    return round ( a )
def isPerfectSquare ( x ) :
    s = sqrt ( x )
    return ( s * s == x )
def isFibonacci ( n ) :
    return ( isPerfectSquare ( 5 * n * n + 4 ) or isPerfectSquare ( 5 * n * n - 4 ) )
def countFibonacciPairs ( arr , n ) :
    res = 0
    for i in range ( n ) :
        for j in range ( i + 1 , n ) :
            if ( isFibonacci ( arr [ i ] ) and isFibonacci ( arr [ j ] ) ) :
                prevFib = previousFibonacci ( arr [ i ] )
                nextFib = nextFibonacci ( arr [ i ] )
                if ( prevFib == arr [ j ] or nextFib == arr [ j ] ) :
                    res += 1
    return res
a = [ 3 , 5 , 8 , 11 ]
n = len ( a )
print ( countFibonacciPairs ( a , n ) )

Index/key variables: i, j
Accumulator variables: res
Iterator variables: i, j
Python program:
def countPairsWithProdK ( arr , n , k ) :
    count = 0
    for i in range ( n ) :
        for j in range ( i + 1 , n ) :
            if ( arr [ i ] * arr [ j ] == k ) :
                count += 1
    return count
arr = [ 1 , 5 , 3 , 4 , 2 ]
N = len ( arr )
K = 3
print ( countPairsWithProdK ( arr , N , K ) )

Index/key variables: i, j
Accumulator variables: count
Iterator variables: i, j
Python program:
MAX = 100000 ;
def countPairsWithProductK ( arr , n , k ) :
    count = 0 ;
    hashmap = [ False ] * MAX ;
    for i in range ( n ) :
        hashmap [ arr [ i ] ] = True ;
    for i in range ( n ) :
        x = arr [ i ] ;
        index = 1.0 * k / arr [ i ] ;
        if ( index >= 0 and ( ( index - int ( index ) ) == 0 ) and hashmap [ k // x ] ) :
            count += 1 ;
        hashmap [ x ] = False ;
    return count ;
if __name__ == " _ _ main _ _ " :
    arr = [ 1 , 5 , 3 , 4 , 2 ] ;
    N = len ( arr ) ;
    K = 3 ;
    print ( countPairsWithProductK ( arr , N , K ) ) ;

Index/key variables: i, x
Accumulator variables: count
Iterator variables: i
Python program:
def oddIntegers ( n , k ) :
    if ( n % 2 != k % 2 ) :
        print ( " - 1" ) ;
        return ;
    sum = 0 ;
    i = 1 ;
    j = 1 ;
    while ( j < k ) :
        sum += i ;
        print ( i , end = " ▁ " ) ;
        i += 2 ;
        j += 1 ;
    finalOdd = n - sum ;
    print ( finalOdd ) ;
if __name__ == " _ _ main _ _ " :
    n = 10 ;
    k = 2 ;
    oddIntegers ( n , k ) ;

Accumulator variables: i, j, sum
Python program:
mod = 1000000007
ans = [ 1 ] * ( 100002 )
pref = [ 0 ] * 100002
def preCompute ( ) :
    for i in range ( 2 , 100000 // 2 + 1 ) :
        for j in range ( 2 * i , 100000 + 1 , i ) :
            ans [ j ] = ( ans [ j ] * i ) % mod
    for i in range ( 1 , 100002 ) :
        pref [ i ] = pref [ i - 1 ] + ans [ i ]
        pref [ i ] %= mod
def printSum ( L , R ) :
    print ( pref [ R ] - pref [ L - 1 ] , end = " ▁ " )
def printSumProper ( arr , Q ) :
    preCompute ( )
    for i in range ( Q ) :
        printSum ( arr [ i ] [ 0 ] , arr [ i ] [ 1 ] )
if __name__ == ' _ _ main _ _ ' :
    Q = 2
    arr = [ [ 10 , 20 ] , [ 12 , 16 ] ]
    printSumProper ( arr , Q )

Index/key variables: R, i, j
Iterator variables: i, j
Python program:
def search ( a , k , x ) :
    for j in range ( k - 1 , - 1 , - 1 ) :
        if ( a [ j ] == x ) :
            return j
    return - 1
def genArray ( arr , N ) :
    for i in range ( 0 , N - 1 , 1 ) :
        if ( search ( arr , i , arr [ i ] ) == - 1 ) :
            arr [ i + 1 ] = 0
        else :
            arr [ i + 1 ] = ( i - search ( arr , i , arr [ i ] ) )
if __name__ == " _ _ main _ _ " :
    N = 5
    size = N + 1
    a = [ 0 ] * N
    genArray ( a , N )
    print ( a )

Index/key variables: i, j
Iterator variables: i, j
Python program:
def getPerfectcubes ( n ) :
    perfectcubes = [ ] ;
    current = 1 ;
    i = 1 ;
    while ( current <= n ) :
        perfectcubes . append ( current ) ;
        i += 1 ;
        current = int ( pow ( i , 3 ) ) ;
    return perfectcubes ;
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 , perfectcubes , nums ) :
    count = 0 ;
    for i in range ( len ( perfectcubes ) ) :
        temp = perfectcubes [ i ] - n ;
        if ( temp > n and ( temp in nums ) ) :
            count += 1 ;
    return count ;
def countPairs ( arr ) :
    n = len ( arr ) ;
    max = maxPairSum ( arr ) ;
    perfectcubes = getPerfectcubes ( max ) ;
    nums = [ ] ;
    for i in range ( n ) :
        nums . append ( arr [ i ] ) ;
    count = 0 ;
    for i in range ( n ) :
        count += countPairsWith ( arr [ i ] , perfectcubes , nums ) ;
    return count ;
arr = [ 2 , 6 , 18 , 9 , 999 , 1 ] ;
print ( countPairs ( arr ) ) ;

Index/key variables: i
Accumulator variables: count, nums, perfectcubes
Iterator variables: i
Python program:
def countSquares ( X , Y , N ) :
    count = 0 ;
    points = [ ] ;
    vertical = dict . fromkeys ( X , None ) ;
    for i in range ( N ) :
        points . append ( ( X [ i ] , Y [ i ] ) ) ;
    for i in range ( N ) :
        if vertical [ X [ i ] ] is None :
            vertical [ X [ i ] ] = [ Y [ i ] ] ;
        else :
            vertical [ X [ i ] ] . append ( Y [ i ] ) ;
    for line in vertical :
        X1 = line ;
        yList = vertical [ line ] ;
        for i in range ( len ( yList ) ) :
            Y1 = yList [ i ] ;
            for j in range ( i + 1 , len ( yList ) ) :
                Y2 = yList [ j ] ;
                side = abs ( Y1 - Y2 ) ;
                X2 = X1 + side ;
                if ( X2 , Y1 ) in points and ( X2 , Y2 ) in points :
                    count += 1 ;
    return count ;
if __name__ == " _ _ main _ _ " :
    X = [ 0 , 2 , 0 , 2 ] ; Y = [ 0 , 2 , 2 , 0 ] ;
    N = len ( X ) ;
    print ( countSquares ( X , Y , N ) ) ;

Index/key variables: i, j, line
Accumulator variables: count, points
Iterator variables: i, j, line
Python program:
def countCubes ( a , b ) :
    for i in range ( a , b + 1 ) :
        for j in range ( i + 1 ) :
            if j * j * j > i :
                break
            if j * j * j == i :
                cnt += 1
    return cnt
if __name__ == ' _ _ main _ _ ' :
    a = 7
    b = 30
    print ( " Count ▁ of ▁ Cubes ▁ is ▁ " , countCubes ( a , b ) )

Accumulator variables: cnt
Iterator variables: i, j
Python program:
def isArmstrong ( x , n ) :
    sum1 = 0
    temp = x
    while temp > 0 :
        digit = temp % 10
        sum1 += digit ** n
        temp //= 10
    return sum1 == x
def CalculateXORandOR ( n ) :
    CalculateXOR = 0
    CalculateOR = 0
    start = 10 ** ( n - 1 )
    end = ( 10 ** n ) - 1
    for i in range ( start , end + 1 ) :
        if ( isArmstrong ( i , n ) ) :
            CalculateXOR = CalculateXOR ^ i
            CalculateOR = CalculateOR | i
    print ( " XOR ▁ = ▁ " , CalculateXOR )
    print ( " OR ▁ = ▁ " , CalculateOR )
if __name__ == " _ _ main _ _ " :
    n = 4 ;
    CalculateXORandOR ( n ) ;

Accumulator variables: sum1, temp
Iterator variables: i
Python program:
def perfectCube ( N ) :
    cube = 0 ;
    for i in range ( N + 1 ) :
        cube = i * i * i ;
        if ( cube == N ) :
            print ( " Yes " ) ;
            return ;
        elif ( cube > N ) :
            print ( " NO " ) ;
            return ;
if __name__ == " _ _ main _ _ " :
    N = 216 ;
    perfectCube ( N ) ;

Iterator variables: i
Python program:
def check ( arr , N ) :
    even = 0 ;
    odd = 0 ;
    for i in range ( N ) :
        if ( arr [ i ] % 2 == 1 ) :
            odd += 1 ;
        else :
            even += 1 ;
    if ( even == N or odd == N ) :
        print ( " Yes " ) ;
    else :
        print ( " No " ) ;
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 1 , 3 ] ;
    N = len ( arr ) ;
    check ( arr , N ) ;

Index/key variables: i
Accumulator variables: even, odd
Iterator variables: i
Python program:
def findMinNumber ( n ) :
    count = 0 ;
    ans = 1 ;
    while ( n % 2 == 0 ) :
        count += 1 ;
        n /= 2 ;
    if ( count % 3 != 0 ) :
        ans *= pow ( 2 , ( count % 3 ) ) ;
    for i in range ( 3 , int ( pow ( n , 1 / 2 ) ) , 2 ) :
        count = 0 ;
        while ( n % i == 0 ) :
            count += 1 ;
            n /= i ;
        if ( count % 3 != 0 ) :
            ans *= pow ( i , ( count % 3 ) ) ;
    if ( n > 2 ) :
        ans *= n ;
    return ans ;
if __name__ == ' _ _ main _ _ ' :
    n = 128 ;
    print ( findMinNumber ( n ) ) ;

Accumulator variables: ans, count, n
Iterator variables: i
Python program:
from math import floor
def countSteps ( n ) :
    steps = 0
    while ( n ) :
        largest = floor ( n ** ( 1 / 3 ) )
        n -= ( largest * largest * largest )
        steps += 1
    return steps
n = 150
print ( countSteps ( n ) )

Accumulator variables: n, steps
Python program:
def product ( N ) :
    ans = 1 ;
    val = 2 ** ( N - 1 ) ;
    for i in range ( 1 , N + 1 ) :
        ans *= ( i ** val ) ;
    return ans ;
if __name__ == " _ _ main _ _ " :
    N = 2 ;
    print ( product ( N ) ) ;

Accumulator variables: ans
Iterator variables: i
Python program:
def isPossible ( a , n ) :
    sum = 0
    maxS = 0
    for i in range ( n ) :
        sum += a [ i ]
        maxS = max ( a [ i ] , maxS )
    if ( ( sum - maxS ) > maxS ) :
        return True
    return False
a = [ 2 , 3 , 4 ]
n = len ( a )
if ( isPossible ( a , n ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Index/key variables: i
Accumulator variables: sum
Iterator variables: i
Python program:
def isSlopeGood ( slope , arr , n ) :
    setOfLines = dict ( )
    for i in range ( n ) :
        setOfLines [ arr [ i ] - slope * ( i ) ] = 1
    return len ( setOfLines ) == 2
def checkForParallel ( arr , n ) :
    slope1 = isSlopeGood ( arr [ 1 ] - arr [ 0 ] , arr , n )
    slope2 = isSlopeGood ( arr [ 2 ] - arr [ 1 ] , arr , n )
    slope3 = isSlopeGood ( ( arr [ 2 ] - arr [ 0 ] ) // 2 , arr , n )
    return ( slope1 or slope2 or slope3 )
arr = [ 1 , 6 , 3 , 8 , 5 ]
n = len ( arr )
if checkForParallel ( arr , n ) :
    print ( 1 )
else :
    print ( 0 )

Index/key variables: i
Iterator variables: i
Python program:
def findFourthVertex ( n , m , s ) :
    row = dict . fromkeys ( range ( n ) , 0 )
    col = dict . fromkeys ( range ( m ) , 0 )
    for i in range ( n ) :
        for j in range ( m ) :
            if ( s [ i ] [ j ] == ' * ' ) :
                row [ i ] += 1 ;
                col [ j ] += 1 ;
    for keys , values in row . items ( ) :
        if ( values == 1 ) :
            x = keys ;
    for keys , values in col . items ( ) :
        if ( values == 1 ) :
            y = keys ;
    return ( x + 1 , y + 1 ) ;
if __name__ == " _ _ main _ _ " :
    s = [ " * . * " , " * . . " , " . . . " ]
    n = len ( s ) ;
    m = len ( s [ 0 ] ) ;
    rs = findFourthVertex ( n , m , s ) ;
    print ( rs [ 0 ] , rs [ 1 ] )

Index/key variables: i, j
Iterator variables: i, j, keys, values