dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
def findMin ( arr , n ) :
    sum = 0
    for i in range ( 0 , n ) :
        sum = sum + arr [ i ]
    arr . sort ( )
    min = arr [ 0 ]
    max = 0
    for i in range ( n - 1 , 0 , - 1 ) :
        num = arr [ i ]
        total = num + min
        for j in range ( 2 , num + 1 ) :
            if ( num % j == 0 ) :
                d = j
                now = ( num // d ) + ( min * d )
                reduce = total - now
                if ( reduce > max ) :
                    max = reduce
    print ( sum - max )
arr = [ 1 , 2 , 3 , 4 , 5 ]
n = len ( arr )
findMin ( arr , n )

Index/key variables: i
Iterator variables: i, j
Python program:
def convert_To_Len_th_base ( n , arr , Len , L ) :
    for i in range ( L ) :
        print ( arr [ n % Len ] , end = " " )
        n //= Len
    print ( )
def printf ( arr , Len , L ) :
    for i in range ( pow ( Len , L ) ) :
        convert_To_Len_th_base ( i , arr , Len , L )
arr = [ 1 , 2 , 3 ]
Len = len ( arr )
L = 2
printf ( arr , Len , L )

Accumulator variables: n
Iterator variables: i
Python program:
def totalways ( arr , n ) :
    cnt = dict ( )
    for i in range ( n ) :
        cnt [ arr [ i ] ] = cnt . get ( arr [ i ] , 0 ) + 1
    if ( n % 2 == 1 ) :
        start , endd = 0 , n - 1
        for i in range ( start , endd + 1 , 2 ) :
            if ( i == 0 ) :
                if ( cnt [ i ] != 1 ) :
                    return 0
            else :
                if ( cnt [ i ] != 2 ) :
                    return 0
        ways = 1
        start = 2
        endd = n - 1
        for i in range ( start , endd + 1 , 2 ) :
            ways = ways * 2
        return ways
    elif ( n % 2 == 0 ) :
        start = 1
        endd = n - 1
        for i in range ( 1 , endd + 1 , 2 ) :
            if ( cnt [ i ] != 2 ) :
                return 0
        ways = 1
        for i in range ( start , endd + 1 , 2 ) :
            ways = ways * 2
        return ways
N = 5
arr = [ 2 , 4 , 4 , 0 , 2 ]
print ( totalways ( arr , N ) )

Index/key variables: i
Iterator variables: i
Python program:
from math import pow
def calculateLnx ( n ) :
    sum = 0
    num = ( n - 1 ) / ( n + 1 )
    for i in range ( 1 , 1001 , 1 ) :
        mul = ( 2 * i ) - 1
        cal = pow ( num , mul )
        cal = cal / mul
        sum = sum + cal
    sum = 2 * sum
    return sum
def calculateLogx ( lnx ) :
    return ( lnx / 2.303 )
if __name__ == ' _ _ main _ _ ' :
    n = 5
    lnx = calculateLnx ( n )
    logx = calculateLogx ( lnx )
    print ( " ln " , " { 0 : . 3f } " . format ( n ) , " = " , " { 0 : . 3f } " . format ( lnx ) )
    print ( " log10" , " { 0 : . 3f } " . format ( n ) , " = " , " { 0 : . 3f } " . format ( logx ) )

Iterator variables: i
Python program:
def Sum ( A , B , R ) :
    ssum = 0
    for i in range ( 1 , R + 1 ) :
        ssum = ssum + ( i * A )
        A = A + B
    return ssum
A , B , R = 5 , 3 , 3
print ( Sum ( A , B , R ) )

Iterator variables: i
Python program:
def smallestPrimeFactor ( n ) :
    i = 2
    while ( i * i ) <= n :
        if n % i == 0 :
            return i
        i += 1
    return n
def solve ( n ) :
    product = 1
    i = 0
    while i < n :
        num = smallestPrimeFactor ( product + 1 )
        print ( num , end = ' ▁ ' )
        product = product * num
        i += 1
b = 14
solve ( b )

Accumulator variables: i
Python program:
def countSetBits ( n ) :
    n += 1 ;
    powerOf2 = 2 ;
    cnt = n // 2 ;
    while ( powerOf2 <= n ) :
        totalPairs = n // powerOf2 ;
        cnt += ( totalPairs // 2 ) * powerOf2 ;
        if ( totalPairs & 1 ) :
            cnt += ( n % powerOf2 )
        else :
            cnt += 0
        powerOf2 <<= 1 ;
    return cnt ;
if __name__ == " _ _ main _ _ " :
    n = 14 ;
    print ( countSetBits ( n ) ) ;

Accumulator variables: cnt, powerOf2
Python program:
def NoofTriplets ( N , K ) :
    cnt = [ 0 ] * K ;
    for i in range ( 1 , N + 1 ) :
        cnt [ i % K ] += 1 ;
    if ( K & 1 ) :
        rslt = cnt [ 0 ] * cnt [ 0 ] * cnt [ 0 ] ;
        return rslt
    else :
        rslt = ( cnt [ 0 ] * cnt [ 0 ] * cnt [ 0 ] + cnt [ K // 2 ] * cnt [ K // 2 ] * cnt [ K // 2 ] ) ;
        return rslt
if __name__ == " _ _ main _ _ " :
    N = 3 ; K = 2 ;
    print ( NoofTriplets ( N , K ) ) ;

Iterator variables: i
Python program:
def GCD ( a , b ) :
    if ( b == 0 ) :
        return a ;
    return GCD ( b , a % b ) ;
def findReachable ( arr , D , A , B , n ) :
    gcd_AB = GCD ( A , B ) ;
    count = 0 ;
    for i in range ( n ) :
        if ( ( arr [ i ] - D ) % gcd_AB == 0 ) :
            count += 1 ;
    return count ;
arr = [ 4 , 5 , 6 , 7 , 8 , 9 ] ;
n = len ( arr ) ;
D = 4 ; A = 4 ; B = 6 ;
print ( findReachable ( arr , D , A , B , n ) ) ;

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Python program:
def makeAP ( arr , n ) :
    initial_term , common_difference = 0 , 0
    if ( n == 3 ) :
        common_difference = arr [ 2 ] - arr [ 1 ]
        initial_term = arr [ 1 ] - common_difference
    elif ( ( arr [ 1 ] - arr [ 0 ] ) == arr [ 2 ] - arr [ 1 ] ) :
        initial_term = arr [ 0 ]
        common_difference = arr [ 1 ] - arr [ 0 ]
    elif ( ( arr [ 2 ] - arr [ 1 ] ) == ( arr [ 3 ] - arr [ 2 ] ) ) :
        common_difference = arr [ 2 ] - arr [ 1 ]
        initial_term = arr [ 1 ] - common_difference
    else :
        common_difference = ( arr [ 3 ] - arr [ 0 ] ) / 3
        initial_term = arr [ 0 ]
    for i in range ( n ) :
        print ( int ( initial_term + ( i * common_difference ) ) , end = " ▁ " )
    print ( )
arr = [ 1 , 3 , 7 ]
n = len ( arr )
makeAP ( arr , n )

Iterator variables: i
Python program:
def getfactor ( n , p ) :
    pw = 0 ;
    while ( n ) :
        n //= p ;
        pw += n ;
    return pw ;
def isDivisible ( n , r , p ) :
    x1 = getfactor ( n , p ) ;
    x2 = getfactor ( r , p ) ;
    x3 = getfactor ( n - r , p ) ;
    if ( x1 > x2 + x3 ) :
        return True ;
    return False ;
if __name__ == " _ _ main _ _ " :
    n = 7 ; r = 2 ; p = 7 ;
    if ( isDivisible ( n , r , p ) ) :
        print ( " Yes " ) ;
    else :
        print ( " No " ) ;

Accumulator variables: n, pw
Python program:
def isEven ( arr , n , r ) :
    if ( r % 2 == 0 ) :
        if ( arr [ n - 1 ] % 2 == 0 ) :
            return True
    else :
        oddCount = 0
        for i in range ( n ) :
            if ( arr [ i ] % 2 != 0 ) :
                oddCount += 1
        if ( oddCount % 2 == 0 ) :
            return True
    return False
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 0 ]
    n = len ( arr )
    r = 2
    if ( isEven ( arr , n , r ) ) :
        print ( " Even " )
    else :
        print ( " Odd " )

Index/key variables: i
Accumulator variables: oddCount
Iterator variables: i
Python program:
import sys
def closetAND ( arr , n , k ) :
    ans = sys . maxsize ;
    for i in range ( n ) :
        X = arr [ i ] ;
        for j in range ( i , n ) :
            X &= arr [ j ] ;
            ans = min ( ans , abs ( k - X ) ) ;
            if ( X <= k ) :
                break ;
    return ans ;
arr = [ 4 , 7 , 10 ] ;
n = len ( arr ) ;
k = 2 ;
print ( closetAND ( arr , n , k ) ) ;

Index/key variables: i, j
Accumulator variables: X
Iterator variables: i, j
Python program:
def gcd ( a , b ) :
    if ( b == 0 ) :
        return a ;
    return gcd ( b , a % b ) ;
def countQuadruplets ( l , r , k ) :
    frequency = [ 0 ] * ( r + 1 ) ;
    for i in range ( l , r + 1 ) :
        for j in range ( l , r + 1 ) :
            frequency [ gcd ( i , j ) ] += 1 ;
    answer = 0 ;
    for i in range ( l , r + 1 ) :
        for j in range ( l , r + 1 ) :
            if ( gcd ( i , j ) == k ) :
                answer += ( frequency [ i ] * frequency [ j ] ) ;
    return answer ;
if __name__ == ' _ _ main _ _ ' :
    l , r , k = 1 , 10 , 2 ;
    print ( countQuadruplets ( l , r , k ) ) ;

Index/key variables: i, j
Accumulator variables: answer
Iterator variables: i, j
Python program:
def solve ( a , n ) :
    ones , twos = 0 , 0
    for i in range ( n ) :
        if ( a [ i ] == 1 ) :
            ones += 1
        else :
            twos += 1
    ind = 0
    if ( twos ) :
        a [ ind ] = 2
        ind += 1
    if ones % 2 == 0 :
        evenOnes = True
    else :
        evenOnes = False
    if ( evenOnes ) :
        ones -= 1
    for i in range ( ones ) :
        a [ ind ] = 1
        ind += 1
    for i in range ( twos - 1 ) :
        a [ ind ] = 2
        ind += 1
    if ( evenOnes ) :
        a [ ind ] = 1
        ind += 1
    for i in range ( n ) :
        print ( a [ i ] , end = " ▁ " )
a = [ 1 , 2 , 1 , 2 , 1 ]
n = len ( a )
solve ( a , n )

Index/key variables: i, ind
Accumulator variables: ones, twos
Iterator variables: i
Boolean variables: evenOnes
Python program:
import math
import sys
def changeTheArray ( arr , n ) :
    minEle = min ( arr )
    maxEle = max ( arr )
    minOperations = sys . maxsize
    for num in range ( minEle , maxEle + 1 ) :
        operations = 0
        for i in range ( n ) :
            if arr [ i ] != num :
                operations += ( abs ( num - arr [ i ] ) - 1 )
        minOperations = min ( minOperations , operations )
    return minOperations
if __name__ == ' _ _ main _ _ ' :
    arr = [ 10 , 1 , 4 ]
    n = len ( arr )
    print ( changeTheArray ( arr , n ) )

Index/key variables: i
Accumulator variables: operations
Iterator variables: i, num
Python program:
def findX ( A , B ) :
    j = 0
    x = 0
    while ( A or B ) :
        if ( ( A & 1 ) and ( B & 1 ) ) :
            x += ( 1 << j )
        A >>= 1
        B >>= 1
        j += 1
    return x
if __name__ == ' _ _ main _ _ ' :
    A = 2
    B = 3
    X = findX ( A , B )
    print ( " X ▁ = " , X , " , ▁ Sum ▁ = " , ( A ^ X ) + ( B ^ X ) )

Accumulator variables: A, B, j, x
Python program:
def isSumEqual ( ar , n ) :
    sum = 0
    for i in range ( n - 1 ) :
        sum += ar [ i ]
    if ( sum == ar [ n - 1 ] ) :
        return True
    return False
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 2 , 3 , 4 , 10 ]
    n = len ( arr )
    if ( isSumEqual ( arr , n ) ) :
        print ( " Yes " )
    else :
        print ( " No " )

Index/key variables: i
Accumulator variables: sum
Iterator variables: i
Python program:
import bisect
def printPosition ( A , B , sizeOfA , sizeOfB ) :
    for i in range ( 1 , sizeOfA ) :
        A [ i ] += A [ i - 1 ]
    for i in range ( sizeOfB ) :
        row = bisect . bisect_left ( A , B [ i ] )
        if row >= 1 :
            boxNumber = B [ i ] - A [ row - 1 ]
        else :
            boxNumber = B [ i ]
        print ( row + 1 , " , " , boxNumber )
A = [ 2 , 2 , 2 , 2 ]
B = [ 1 , 2 , 3 , 4 ]
sizeOfA = len ( A )
sizeOfB = len ( B )
printPosition ( A , B , sizeOfA , sizeOfB )

Index/key variables: i
Iterator variables: i
Python program:
import math
def primeFactors ( n , freq ) :
    cnt = 0
    while n % 2 == 0 :
        cnt = cnt + 1
        n = int ( n // 2 )
    freq [ 2 ] = cnt
    i = 3
    while i <= math . sqrt ( n ) :
        cnt = 0
        while ( n % i == 0 ) :
            cnt = cnt + 1
            n = int ( n // i )
        freq [ int ( i ) ] = cnt
        i = i + 2
    if ( n > 2 ) :
        freq [ int ( n ) ] = 1
def getMaximumPower ( n , m ) :
    freq1 = [ 0 ] * ( n + 1 )
    freq2 = [ 0 ] * ( m + 1 )
    primeFactors ( n , freq1 )
    primeFactors ( m , freq2 )
    maxi = 0
    i = 2
    while i <= m :
        if ( freq1 [ i ] == 0 and freq2 [ i ] == 0 ) :
            i = i + 1
            continue
        if ( freq2 [ i ] > freq1 [ i ] ) :
            return 0
        if ( freq2 [ i ] ) :
            maxi = max ( maxi , int ( freq1 [ i ] // freq2 [ i ] ) )
        i = i + 1
    return maxi
n = 48
m = 4
print ( getMaximumPower ( n , m ) )

Index/key variables: i
Python program:
def findDivisors ( n ) :
    div = [ 0 for i in range ( n + 1 ) ]
    for i in range ( 1 , n + 1 ) :
        for j in range ( 1 , n + 1 ) :
            if j * i <= n :
                div [ i * j ] += 1
    for i in range ( 1 , n + 1 ) :
        print ( div [ i ] , end = " ▁ " )
if __name__ == " _ _ main _ _ " :
    n = 10
    findDivisors ( n )

Index/key variables: i
Iterator variables: i, j
Python program:
def decideWinner ( a , n ) :
    count0 = 0
    count1 = 0
    count2 = 0
    count3 = 0
    for i in range ( n ) :
        if ( a [ i ] % 4 == 0 ) :
            count0 += 1
        elif ( a [ i ] % 4 == 1 ) :
            count1 += 1
        elif ( a [ i ] % 4 == 2 ) :
            count2 += 1
        elif ( a [ i ] % 4 == 3 ) :
            count3 += 1
    if ( count0 % 2 == 0 and count1 % 2 == 0 and count2 % 2 == 0 and count3 == 0 ) :
        return 1
    else :
        return 2
a = [ 4 , 8 , 5 , 9 ]
n = len ( a )
if ( decideWinner ( a , n ) == 1 ) :
    print ( " X ▁ wins " )
else :
    print ( " Y ▁ wins " )

Index/key variables: i
Accumulator variables: count0, count1, count2, count3
Iterator variables: i
Python program:
def CntDivbyX ( arr , n , x ) :
    number = 0
    count = 0
    for i in range ( 0 , n ) :
        number = ( number * 2 + arr [ i ] ) % x
        if number == 0 :
            count += 1
    return count
arr = [ 1 , 0 , 1 , 0 , 1 , 1 , 0 ]
n = 7
x = 2
print ( CntDivbyX ( arr , n , x ) )

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Python program:
def numLen ( K ) :
    if ( K % 2 == 0 or K % 5 == 0 ) :
        return - 1
    number = 0
    len = 1
    for len in range ( 1 , K + 1 ) :
        number = ( number * 10 + 1 ) % K
        if number == 0 :
            return len
    return - 1
K = 7
print ( numLen ( K ) )

Iterator variables: len
Python program:
max_Element = 100005
sum1 = [ 0 for i in range ( max_Element ) ]
sum2 = [ 0 for i in range ( max_Element ) ]
sum3 = [ 0 for i in range ( max_Element ) ]
def precomputation ( arr , n ) :
    for i in range ( 1 , max_Element , 1 ) :
        for j in range ( i , max_Element , i ) :
            sum1 [ j ] += i
    for i in range ( 1 , max_Element , 1 ) :
        for j in range ( i , max_Element , i ) :
            sum2 [ j ] += ( sum1 [ j ] - i ) * i
    for i in range ( 1 , max_Element , 1 ) :
        sum2 [ i ] = int ( sum2 [ i ] / 2 )
    for i in range ( 1 , max_Element , 1 ) :
        for j in range ( i , max_Element , i ) :
            sum3 [ j ] += i * ( sum2 [ j ] - i * ( sum1 [ j ] - i ) )
    for i in range ( 1 , max_Element , 1 ) :
        sum3 [ i ] = int ( sum3 [ i ] / 3 )
    for i in range ( n ) :
        print ( sum3 [ arr [ i ] ] , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 9 , 5 , 6 ]
    n = len ( arr )
    precomputation ( arr , n )

Index/key variables: i, j
Iterator variables: i, j
Python program:
def printBalancedExpression ( a , b , c , d ) :
    if ( ( a == d and a ) or ( a == 0 and c == 0 and d == 0 ) ) :
        for i in range ( 1 , a + 1 ) :
            print ( " ( ( " , end = " " )
        for i in range ( 1 , c + 1 ) :
            print ( " ) ( " , end = " " )
        for i in range ( 1 , d + 1 ) :
            print ( " ) ) " , end = " " )
        for i in range ( 1 , b + 1 ) :
            print ( " ( ) " , end = " " )
    else :
        print ( " - 1" )
if __name__ == " _ _ main _ _ " :
    a , b , c , d = 3 , 1 , 4 , 3
    printBalancedExpression ( a , b , c , d )

Iterator variables: i
Python program:
def factorial ( f ) :
    fact = 1
    for i in range ( 2 , f + 1 ) :
        fact *= i
    return fact
def findPermuatation ( N , M ) :
    permutation = ( factorial ( N + M - 1 ) // ( factorial ( N ) * factorial ( M - 1 ) ) )
    return permutation
N = 3 ; M = 3
print ( findPermuatation ( N , M ) )

Accumulator variables: fact
Iterator variables: i
Python program:
import math
def findCount ( n ) :
    a , b , c = 1 , 0 , 0 ;
    x = ( int ) ( n / 60 ) ;
    a = int ( math . pow ( 32 , x ) ) ;
    x = 60 * x ;
    for i in range ( x + 1 , n + 1 ) :
        if ( i % 2 == 0 ) :
            b += a ;
            a = 0 ;
        if ( i % 5 == 0 ) :
            c += b ;
            b = 0 ;
        if ( i % 12 == 0 ) :
            a += ( 2 * c ) ;
            c = 0 ;
    print ( " a ▁ = " , a , end = " , ▁ " ) ;
    print ( " b ▁ = " , b , end = " , ▁ " ) ;
    print ( " c ▁ = " , c ) ;
if __name__ == ' _ _ main _ _ ' :
    n = 72 ;
    findCount ( n ) ;

Accumulator variables: a, b, c
Iterator variables: i
Python program:
def factorial ( n ) :
    if n == 1 or n == 0 :
        return 1
    else :
        return factorial ( n - 1 ) * n
def gcdOfFactorial ( arr , n ) :
    minm = arr [ 0 ]
    for i in range ( 1 , n ) :
        if minm > arr [ i ] :
            minm = arr [ i ]
        else :
            arr [ i ] = minm
    return factorial ( minm )
arr = [ 9 , 12 , 122 , 34 , 15 ]
n = len ( arr )
print ( gcdOfFactorial ( arr , n ) )

Index/key variables: i
Iterator variables: i
Python program:
def findNumber ( n ) :
    i = 1
    while i <= n :
        print ( ( 2 * i ) - 1 , end = " ▁ " )
        i += 1
n = 3
findNumber ( n )

Accumulator variables: i
Python program:
import sys
def findMissingNums ( even , sizeEven , odd , sizeOdd ) :
    minEven = sys . maxsize ;
    maxEven = - ( sys . maxsize - 1 ) ;
    minOdd = sys . maxsize ;
    maxOdd = - ( sys . maxsize - 1 ) ;
    sumEvenArr = 0 ;
    sumOddArr = 0 ;
    for i in range ( sizeEven ) :
        minEven = min ( minEven , even [ i ] ) ;
        maxEven = max ( maxEven , even [ i ] ) ;
        sumEvenArr += even [ i ] ;
    for i in range ( sizeOdd ) :
        minOdd = min ( minOdd , odd [ i ] ) ;
        maxOdd = max ( maxOdd , odd [ i ] ) ;
        sumOddArr += odd [ i ] ;
    totalTerms = 0 ;
    reqSum = 0 ;
    totalTerms = minEven // 2 ;
    evenSumMin = ( totalTerms * ( totalTerms + 1 ) ) ;
    totalTerms = maxEven // 2 ;
    evenSumMax = ( totalTerms * ( totalTerms + 1 ) ) ;
    reqSum = ( evenSumMax - evenSumMin + minEven ) ;
    print ( " Even ▁ = " , reqSum - sumEvenArr ) ;
    totalTerms = ( minOdd // 2 ) + 1 ;
    oddSumMin = totalTerms * totalTerms ;
    totalTerms = ( maxOdd // 2 ) + 1 ;
    oddSumMax = totalTerms * totalTerms ;
    reqSum = ( oddSumMax - oddSumMin + minOdd ) ;
    print ( " Odd ▁ = " , reqSum - sumOddArr ) ;
if __name__ == " _ _ main _ _ " :
    even = [ 6 , 4 , 8 , 14 , 10 ] ;
    sizeEven = len ( even )
    odd = [ 7 , 5 , 3 , 11 , 13 ] ;
    sizeOdd = len ( odd ) ;
    findMissingNums ( even , sizeEven , odd , sizeOdd ) ;

Index/key variables: i
Accumulator variables: sumEvenArr, sumOddArr
Iterator variables: i
Python program:
def getResult ( n ) :
    proOdd = 1
    proEven = 1
    num = str ( n )
    for i in range ( len ( num ) ) :
        if ( i % 2 == 0 ) :
            proOdd = proOdd * int ( num [ i ] )
        else :
            proEven = proEven * int ( num [ i ] )
    if ( proOdd == proEven ) :
        print ( " Yes " )
    else :
        print ( " No " )
if __name__ == " _ _ main _ _ " :
    n = 4324
    getResult ( n )

Index/key variables: i
Iterator variables: i
Python program:
def sumOfDigits ( x ) :
    sum = 0
    while x != 0 :
        sum += x % 10
        x = x // 10
    return sum
def countNumbers ( l , r ) :
    count = 0
    for i in range ( l , r + 1 ) :
        if i % 2 == 0 and sumOfDigits ( i ) % 3 == 0 :
            count += 1
    return count
l = 1000 ; r = 6000
print ( countNumbers ( l , r ) )

Accumulator variables: count, sum
Iterator variables: i
Python program:
def findMinSum ( arr , n ) :
    sum = 0
    for i in range ( 0 , n ) :
        sum += arr [ i ] * ( n - i )
    return sum
arr = [ 3 , 5 , 7 , 8 ]
n = len ( arr )
print ( findMinSum ( arr , n ) )

Index/key variables: i
Accumulator variables: sum
Iterator variables: i
Python program:
def maxLenSubArr ( a , n ) :
    cm , Max = 1 , 0
    for i in range ( 0 , n ) :
        if a [ i ] > Max :
            Max = a [ i ]
    i = 0
    while i < n - 1 :
        count = 1
        if a [ i ] == a [ i + 1 ] and a [ i ] == Max :
            for j in range ( i + 1 , n ) :
                if a [ j ] == Max :
                    count += 1
                    i += 1
                else :
                    break
            if count > cm :
                cm = count
        else :
            i += 1
        i += 1
    return cm
if __name__ == " _ _ main _ _ " :
    arr = [ 6 , 1 , 6 , 6 , 0 ]
    n = len ( arr )
    print ( maxLenSubArr ( arr , n ) )

Index/key variables: i, j
Accumulator variables: count
Iterator variables: i, j
Python program:
def minSum ( arr , n , x ) :
    Sum = 0
    largestDivisible , minimum = - 1 , arr [ 0 ]
    for i in range ( 0 , n ) :
        Sum += arr [ i ]
        if ( arr [ i ] % x == 0 and largestDivisible < arr [ i ] ) :
            largestDivisible = arr [ i ]
        if arr [ i ] < minimum :
            minimum = arr [ i ]
    if largestDivisible == - 1 :
        return Sum
    sumAfterOperation = ( Sum - minimum - largestDivisible + ( x * minimum ) + ( largestDivisible // x ) )
    return min ( Sum , sumAfterOperation )
if __name__ == " _ _ main _ _ " :
    arr = [ 5 , 5 , 5 , 5 , 6 ]
    n = len ( arr )
    x = 3
    print ( minSum ( arr , n , x ) )

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

Index/key variables: i, j, num
Accumulator variables: N
Iterator variables: i, j
Python program:
import sys
def minMoves ( n ) :
    s = str ( n ) ;
    ans = sys . maxsize ;
    len1 = len ( s ) ;
    for i in range ( len1 ) :
        for j in range ( len1 ) :
            if ( i == j ) :
                continue ;
            t = s ;
            cur = 0 ;
            list1 = list ( t ) ;
            for k in range ( i , len1 - 1 ) :
                e = list1 [ k ] ;
                list1 [ k ] = list1 [ k + 1 ] ;
                list1 [ k + 1 ] = e ;
                cur += 1 ;
            t = ' ' . join ( list1 ) ;
            list1 = list ( t ) ;
            for k in range ( j - ( j > i ) , len1 - 2 ) :
                e = list1 [ k ] ;
                list1 [ k ] = list1 [ k + 1 ] ;
                list1 [ k + 1 ] = e ;
                cur += 1 ;
            t = ' ' . join ( list1 ) ;
            pos = - 1 ;
            for k in range ( len1 ) :
                if ( t [ k ] != '0' ) :
                    pos = k ;
                    break ;
            for k in range ( pos , 0 , - 1 ) :
                e = list1 [ k ] ;
                list1 [ k ] = list1 [ k + 1 ] ;
                list1 [ k + 1 ] = e ;
                cur += 1 ;
            t = ' ' . join ( list1 ) ;
            nn = int ( t ) ;
            if ( nn % 25 == 0 ) :
                ans = min ( ans , cur ) ;
    if ( ans == sys . maxsize ) :
        return - 1 ;
    return ans ;
n = 509201 ;
print ( minMoves ( n ) ) ;

Index/key variables: k
Accumulator variables: cur
Iterator variables: i, j, k
Python program:
N = 1000005
primeFactors = [ 0 ] * N ;
def findPrimeFactors ( ) :
    for i in range ( 2 , N ) :
        if ( primeFactors [ i ] == 0 ) :
            for j in range ( i , N , i ) :
                primeFactors [ j ] = primeFactors [ j // i ] + 1 ;
    for i in range ( 1 , N ) :
        primeFactors [ i ] += primeFactors [ i - 1 ] ;
if __name__ == " _ _ main _ _ " :
    findPrimeFactors ( ) ;
    a = 6 ; b = 3 ;
    print ( primeFactors [ a ] - primeFactors [ b ] ) ;

Index/key variables: a, b, i, j
Iterator variables: i, j