dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
mod = 1000000007 ;
def productPairs ( arr , n ) :
    product = 1 ;
    for i in range ( n ) :
        for j in range ( n ) :
            product *= ( arr [ i ] % mod * arr [ j ] % mod ) % mod ;
            product = product % mod ;
    return product % mod ;
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 2 , 3 ] ;
    n = len ( arr ) ;
    print ( productPairs ( arr , n ) ) ;

Index/key variables: i, j
Accumulator variables: product
Iterator variables: i, j
Python program:
mod = 1000000007
def power ( x , y ) :
    p = 1000000007
    res = 1
    x = x % p
    while ( y > 0 ) :
        if ( ( y & 1 ) != 0 ) :
            res = ( res * x ) % p
        y = y >> 1
        x = ( x * x ) % p
    return res
def productPairs ( arr , n ) :
    product = 1
    for i in range ( n ) :
        product = ( product % mod * ( int ) ( power ( arr [ i ] , ( 2 * n ) ) ) % mod ) % mod
    return ( product % mod )
arr = [ 1 , 2 , 3 ]
n = len ( arr )
print ( productPairs ( arr , n ) )

Index/key variables: i
Iterator variables: i
Python program:
def constructArray ( N ) :
    arr = [ 0 ] * N
    for i in range ( 1 , N + 1 ) :
        arr [ i - 1 ] = i ;
    for i in range ( N ) :
        print ( arr [ i ] , end = " , ▁ " )
N = 6 ;
constructArray ( N ) ;

Index/key variables: i
Iterator variables: i
Python program:
def isPrime ( n ) :
    if ( n <= 1 ) :
        return False ;
    for i in range ( 2 , n ) :
        if ( n % i == 0 ) :
            return False ;
    return True ;
def countSubsequences ( arr , n ) :
    totalSubsequence = ( int ) ( pow ( 2 , n ) - 1 ) ;
    countPrime = 0 ;
    countOnes = 0 ;
    for i in range ( n ) :
        if ( arr [ i ] == 1 ) :
            countOnes += 1 ;
        elif ( isPrime ( arr [ i ] ) ) :
            countPrime += 1 ;
    compositeSubsequence = 0 ;
    onesSequence = ( int ) ( pow ( 2 , countOnes ) - 1 ) ;
    compositeSubsequence = ( totalSubsequence - countPrime - onesSequence - onesSequence * countPrime ) ;
    return compositeSubsequence ;
if __name__ == ' _ _ main _ _ ' :
    arr = [ 2 , 1 , 2 ] ;
    n = len ( arr ) ;
    print ( countSubsequences ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: countOnes, countPrime
Iterator variables: i
Python program:
def checksum ( n , k ) :
    first_term = ( ( 2 * n ) / k + ( 1 - k ) ) / 2.0
    if ( first_term - int ( first_term ) == 0 ) :
        for i in range ( int ( first_term ) , int ( first_term ) + k ) :
            print ( i , end = ' ▁ ' )
    else :
        print ( ' - 1' )
if __name__ == ' _ _ main _ _ ' :
    ( n , k ) = ( 33 , 6 )
    checksum ( n , k )

Iterator variables: i
Python program:
def sumEvenNumbers ( N , K ) :
    check = N - 2 * ( K - 1 )
    if ( check > 0 and check % 2 == 0 ) :
        for i in range ( K - 1 ) :
            print ( "2 ▁ " , end = " " )
        print ( check )
    else :
        print ( " - 1" )
N = 8
K = 2
sumEvenNumbers ( N , K )

Iterator variables: i
Python program:
def calculateWays ( N ) :
    x = 0 ;
    v = [ ] ;
    for i in range ( N ) :
        v . append ( 0 ) ;
    for i in range ( N // 2 + 1 ) :
        if ( N % 2 == 0 and i == N // 2 ) :
            break ;
        x = N * ( i + 1 ) - ( i + 1 ) * i ;
        v [ i ] = x ;
        v [ N - i - 1 ] = x ;
    return v ;
def printArray ( v ) :
    for i in range ( len ( v ) ) :
        print ( v [ i ] , end = " ▁ " ) ;
if __name__ == " _ _ main _ _ " :
    v = calculateWays ( 4 ) ;
    printArray ( v ) ;

Index/key variables: i
Accumulator variables: v
Iterator variables: i
Python program:
MAXN = 10000000
def sumOfDigits ( n ) :
    sum = 0
    while ( n > 0 ) :
        sum += n % 10
        n //= 10
    return sum
def smallestNum ( X , Y ) :
    res = - 1 ;
    for i in range ( X , MAXN ) :
        sum_of_digit = sumOfDigits ( i )
        if sum_of_digit % Y == 0 :
            res = i
            break
    return res
if __name__ == ' _ _ main _ _ ' :
    ( X , Y ) = ( 5923 , 13 )
    print ( smallestNum ( X , Y ) )

Accumulator variables: n, sum
Iterator variables: i
Python program:
def countValues ( N ) :
    div = [ ]
    i = 2
    while ( ( i * i ) <= N ) :
        if ( N % i == 0 ) :
            div . append ( i )
            if ( N != i * i ) :
                div . append ( N // i )
        i += 1
    answer = 0
    i = 1
    while ( ( i * i ) <= N - 1 ) :
        if ( ( N - 1 ) % i == 0 ) :
            if ( i * i == N - 1 ) :
                answer += 1
            else :
                answer += 2
        i += 1
    for d in div :
        K = N
        while ( K % d == 0 ) :
            K //= d
        if ( ( K - 1 ) % d == 0 ) :
            answer += 1
    return answer
if __name__ == " _ _ main _ _ " :
    N = 6
    print ( countValues ( N ) )

Accumulator variables: K, answer, div, i
Iterator variables: d
Python program:
def findMaxPrimeDivisor ( n ) :
    max_possible_prime = 0
    while ( n % 2 == 0 ) :
        max_possible_prime += 1
        n = n // 2
    i = 3
    while ( i * i <= n ) :
        while ( n % i == 0 ) :
            max_possible_prime += 1
            n = n // i
        i = i + 2
    if ( n > 2 ) :
        max_possible_prime += 1
    print ( max_possible_prime )
n = 4
findMaxPrimeDivisor ( n )

Accumulator variables: max_possible_prime
Python program:
def Solve ( arr , size , n ) :
    v = [ 0 ] * ( n + 1 ) ;
    for i in range ( size ) :
        v [ arr [ i ] ] += 1
    max1 = max ( set ( arr ) , key = v . count )
    diff1 = n + 1 - v . count ( 0 )
    max_size = max ( min ( v [ max1 ] - 1 , diff1 ) , min ( v [ max1 ] , diff1 - 1 ) )
    print ( " Maximum ▁ size ▁ is ▁ : " , max_size )
    print ( " The ▁ First ▁ Array ▁ Is ▁ : ▁ " )
    for i in range ( max_size ) :
        print ( max1 , end = " ▁ " )
        v [ max1 ] -= 1
    print ( )
    print ( " The ▁ Second ▁ Array ▁ Is ▁ : ▁ " )
    for i in range ( n + 1 ) :
        if ( v [ i ] > 0 ) :
            print ( i , end = " ▁ " )
            max_size -= 1
        if ( max_size < 1 ) :
            break
    print ( )
if __name__ == " _ _ main _ _ " :
    n = 7
    arr = [ 1 , 2 , 1 , 5 , 1 , 6 , 7 , 2 ]
    size = len ( arr )
    Solve ( arr , size , n )

Index/key variables: i, max1
Accumulator variables: max_size
Iterator variables: i
Python program:
def power ( x , y , p ) :
    res = 1
    x = x % p
    while ( y > 0 ) :
        if ( y & 1 ) :
            res = ( res * x ) % p
        x = ( x * x ) % p
    return res
def modInverse ( n , p ) :
    return power ( n , p - 2 , p )
def nCrModPFermat ( n , r , p ) :
    if ( r == 0 ) :
        return 1
    if ( n < r ) :
        return 0
    fac = [ 0 ] * ( n + 1 )
    fac [ 0 ] = 1
    for i in range ( 1 , n + 1 ) :
        fac [ i ] = fac [ i - 1 ] * i % p
    return ( fac [ n ] * modInverse ( fac [ r ] , p ) % p * modInverse ( fac [ n - r ] , p ) % p ) % p
def SumOfXor ( a , n ) :
    mod = 10037
    answer = 0
    for k in range ( 32 ) :
        x = 0
        y = 0
        for i in range ( n ) :
            if ( a [ i ] & ( 1 << k ) ) :
                x += 1
            else :
                y += 1
        answer += ( ( 1 << k ) % mod * ( nCrModPFermat ( x , 3 , mod ) + x * nCrModPFermat ( y , 2 , mod ) ) % mod ) % mod
    return answer
if __name__ == ' _ _ main _ _ ' :
    n = 5
    A = [ 3 , 5 , 2 , 18 , 7 ]
    print ( SumOfXor ( A , n ) )

Index/key variables: i, n, r
Accumulator variables: answer, x, y
Iterator variables: i, k
Python program:
import math
def probability ( N ) :
    a = 2
    b = 3
    if N == 1 :
        return a
    elif N == 2 :
        return b
    else :
        for i in range ( 3 , N + 1 ) :
            c = a + b
            a = b
            b = c
        return b
def operations ( N ) :
    x = probability ( N )
    y = math . pow ( 2 , N )
    return round ( x / y , 2 )
if __name__ == ' _ _ main _ _ ' :
    N = 10
    print ( operations ( N ) )

Iterator variables: i
Python program:
def largest_sum ( arr , n ) :
    maximum = - 1
    m = dict ( )
    for i in arr :
        m [ i ] = m . get ( i , 0 ) + 1
    for j in list ( m ) :
        if ( ( j in m ) and m [ j ] > 1 ) :
            x , y = 0 , 0
            if 2 * j in m :
                m [ 2 * j ] = m [ 2 * j ] + m [ j ] // 2
            else :
                m [ 2 * j ] = m [ j ] // 2
            if ( 2 * j > maximum ) :
                maximum = 2 * j
    return maximum
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 1 , 2 , 4 , 7 , 8 ]
    n = len ( arr )
    print ( largest_sum ( arr , n ) )

Index/key variables: i, j
Iterator variables: i, j
Python program:
import math
def isPrime ( N ) :
    isPrime = True ;
    arr = [ 7 , 11 , 13 , 17 , 19 , 23 , 29 , 31 ]
    if ( N < 2 ) :
        isPrime = False
    if ( N % 2 == 0 or N % 3 == 0 or N % 5 == 0 ) :
        isPrime = False
    for i in range ( 0 , int ( math . sqrt ( N ) ) , 30 ) :
        for c in arr :
            if ( c > int ( math . sqrt ( N ) ) ) :
                break
            else :
                if ( N % ( c + i ) == 0 ) :
                    isPrime = False
                    break
            if ( not isPrime ) :
                break
    if ( isPrime ) :
        print ( " Prime ▁ Number " )
    else :
        print ( " Not ▁ a ▁ Prime ▁ Number " )
if __name__ == " _ _ main _ _ " :
    N = 121
    isPrime ( N )

Iterator variables: c, i
Boolean variables: isPrime
Python program:
def printPairs ( arr , n ) :
    for i in range ( n ) :
        for j in range ( n ) :
            print ( " ( " , arr [ i ] , " , " , arr [ j ] , " ) " , end = " , ▁ " )
arr = [ 1 , 2 ]
n = len ( arr )
printPairs ( arr , n )

Index/key variables: i, j
Iterator variables: i, j
Python program:
mod = int ( 1e9 ) + 7 ;
def power ( p ) :
    res = 1 ;
    for i in range ( 1 , p + 1 ) :
        res *= 2 ;
        res %= mod ;
    return res % mod ;
def subset_cube_sum ( A ) :
    n = len ( A ) ;
    ans = 0 ;
    for i in A :
        ans += ( i * i * i ) % mod ;
        ans %= mod ;
    return ( ans * power ( n - 1 ) ) % mod ;
if __name__ == " _ _ main _ _ " :
    A = [ 1 , 2 ] ;
    print ( subset_cube_sum ( A ) ) ;

Accumulator variables: ans, res
Iterator variables: i
Python program:
def polygonArea ( X , Y , n ) :
    area = 0.0
    j = n - 1
    for i in range ( 0 , n ) :
        area = area + ( X [ j ] + X [ i ] ) * ( Y [ j ] - Y [ i ] )
    return abs ( area // 2.0 )
X = [ 0 , 2 , 4 ]
Y = [ 1 , 3 , 7 ]
n = len ( X )
print ( polygonArea ( X , Y , n ) )

Index/key variables: i, j
Iterator variables: i
Python program:
def chk ( v ) :
    v = list ( bin ( v ) [ 2 : ] )
    v . reverse ( )
    if ( '1' in v ) :
        v = v . index ( '1' )
        return ( 2 ** v )
    else :
        return 0
def sumOfLSB ( arr , N ) :
    lsb_arr = [ ]
    for i in range ( N ) :
        lsb_arr . append ( chk ( arr [ i ] ) )
    lsb_arr . sort ( reverse = True )
    ans = 0
    for i in range ( 0 , N - 1 , 2 ) :
        ans += ( lsb_arr [ i + 1 ] )
    print ( ans )
N = 5
arr = [ 1 , 2 , 3 , 4 , 5 ]
sumOfLSB ( arr , N )

Index/key variables: i
Accumulator variables: ans, lsb_arr
Iterator variables: i
Python program:
def countSubsequences ( arr ) :
    odd = 0
    for x in arr :
        if ( x & 1 ) :
            odd = odd + 1
    return ( 1 << odd ) - 1
if __name__ == " _ _ main _ _ " :
    arr = [ 1 , 3 , 3 ]
    print ( countSubsequences ( arr ) )

Iterator variables: x
Python program:
def getPairsCount ( arr , n ) :
    count = 0
    for i in range ( n ) :
        for j in range ( arr [ i ] - ( i % arr [ i ] ) , n , arr [ i ] ) :
            if ( i < j and abs ( arr [ i ] - arr [ j ] ) >= min ( arr [ i ] , arr [ j ] ) ) :
                count += 1
    return count
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 2 , 2 , 3 ]
    N = len ( arr )
    print ( getPairsCount ( arr , N ) )

Index/key variables: i, j
Accumulator variables: count
Iterator variables: i, j
Python program:
def check ( N ) :
    twos = 0
    fives = 0
    while ( N % 2 == 0 ) :
        N /= 2
        twos += 1
    while ( N % 5 == 0 ) :
        N /= 5
        fives += 1
    if ( N == 1 and twos <= fives ) :
        print ( 2 * fives - twos )
    else :
        print ( - 1 )
if __name__ == ' _ _ main _ _ ' :
    N = 50
    check ( N )

Accumulator variables: N, fives, twos
Python program:
def rangeSum ( arr , N , L , R ) :
    sum = 0
    for i in range ( L - 1 , R , 1 ) :
        sum += arr [ i % N ]
    print ( sum )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 5 , 2 , 6 , 9 ]
    L = 10
    R = 13
    N = len ( arr )
    rangeSum ( arr , N , L , R )

Accumulator variables: sum
Iterator variables: i
Python program:
def rangeSum ( arr , N , L , R ) :
    prefix = [ 0 for i in range ( N + 1 ) ]
    prefix [ 0 ] = 0
    for i in range ( 1 , N + 1 , 1 ) :
        prefix [ i ] = prefix [ i - 1 ] + arr [ i - 1 ]
    leftsum = ( ( L - 1 ) // N ) * prefix [ N ] + prefix [ ( L - 1 ) % N ]
    rightsum = ( R // N ) * prefix [ N ] + prefix [ R % N ]
    print ( rightsum - leftsum )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 5 , 2 , 6 , 9 ]
    L = 10
    R = 13
    N = len ( arr )
    rangeSum ( arr , N , L , R )

Index/key variables: N, i
Iterator variables: i
Python program:
def ExpoFactorial ( N ) :
    res = 1
    mod = ( int ) ( 1000000007 )
    for i in range ( 2 , N + 1 ) :
        res = pow ( i , res , mod )
    return res
N = 4
print ( ExpoFactorial ( N ) )

Iterator variables: i
Python program:
def maxSubArraySumRepeated ( arr , N , K ) :
    sum = 0
    for i in range ( N ) :
        sum += arr [ i ]
    curr = arr [ 0 ]
    ans = arr [ 0 ]
    if ( K == 1 ) :
        for i in range ( 1 , N , 1 ) :
            curr = max ( arr [ i ] , curr + arr [ i ] )
            ans = max ( ans , curr )
        return ans
    V = [ ]
    for i in range ( 2 * N ) :
        V . append ( arr [ i % N ] )
    maxSuf = V [ 0 ]
    maxPref = V [ 2 * N - 1 ]
    curr = V [ 0 ]
    for i in range ( 1 , 2 * N , 1 ) :
        curr += V [ i ]
        maxPref = max ( maxPref , curr )
    curr = V [ 2 * N - 1 ]
    i = 2 * N - 2
    while ( i >= 0 ) :
        curr += V [ i ]
        maxSuf = max ( maxSuf , curr )
        i -= 1
    curr = V [ 0 ]
    for i in range ( 1 , 2 * N , 1 ) :
        curr = max ( V [ i ] , curr + V [ i ] )
        ans = max ( ans , curr )
    if ( sum > 0 ) :
        temp = sum * ( K - 2 )
        ans = max ( ans , max ( temp + maxPref , temp + maxSuf ) )
    return ans
if __name__ == ' _ _ main _ _ ' :
    arr = [ 10 , 20 , - 30 , - 1 , 40 ]
    N = len ( arr )
    K = 10
    print ( maxSubArraySumRepeated ( arr , N , K ) )

Index/key variables: i
Accumulator variables: V, curr, sum
Iterator variables: i
Python program:
def countSubarray ( arr , n ) :
    count = 0
    for i in range ( n ) :
        for j in range ( i , n , 1 ) :
            mxSubarray = 0
            mxOther = 0
            for k in range ( i , j + 1 , 1 ) :
                mxSubarray = max ( mxSubarray , arr [ k ] )
            for k in range ( 0 , i , 1 ) :
                mxOther = max ( mxOther , arr [ k ] )
            for k in range ( j + 1 , n , 1 ) :
                mxOther = max ( mxOther , arr [ k ] )
            if ( mxSubarray > ( 2 * mxOther ) ) :
                count += 1
    print ( count )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 6 , 10 , 9 , 7 , 3 ]
    N = len ( arr )
    countSubarray ( arr , N )

Index/key variables: k
Accumulator variables: count
Iterator variables: i, j, k
Python program:
def countSubarray ( arr , n ) :
    count = 0
    L = 0
    R = 0
    mx = max ( arr )
    for i in range ( n ) :
        if ( arr [ i ] * 2 > mx ) :
            L = i
            break
    i = n - 1
    while ( i >= 0 ) :
        if ( arr [ i ] * 2 > mx ) :
            R = i
            break
        i -= 1
    print ( ( L + 1 ) * ( n - R ) )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 6 , 10 , 9 , 7 , 3 ]
    N = len ( arr )
    countSubarray ( arr , N )

Index/key variables: i
Iterator variables: i
Python program:
def KthSmallest ( A , B , N , K ) :
    M = 0
    for i in range ( N ) :
        M = max ( A [ i ] , M )
    freq = [ 0 ] * ( M + 1 )
    for i in range ( N ) :
        freq [ A [ i ] ] += B [ i ]
    sum = 0
    for i in range ( M + 1 ) :
        sum += freq [ i ]
        if ( sum >= K ) :
            return i
    return - 1
if __name__ == " _ _ main _ _ " :
    A = [ 3 , 4 , 5 ]
    B = [ 2 , 1 , 3 ]
    N = len ( A )
    K = 4
    print ( KthSmallest ( A , B , N , K ) )

Index/key variables: i
Accumulator variables: sum
Iterator variables: i
Python program:
def findbitwiseOR ( a , n ) :
    res = 0
    for i in range ( n ) :
        curr_sub_array = a [ i ]
        res = res | curr_sub_array
        for j in range ( i , n ) :
            curr_sub_array = curr_sub_array & a [ j ]
            res = res | curr_sub_array
    print ( res )
if __name__ == ' _ _ main _ _ ' :
    A = [ 1 , 2 , 3 ]
    N = len ( A )
    findbitwiseOR ( A , N )

Index/key variables: i, j
Iterator variables: i, j
Python program:
def findbitwiseOR ( a , n ) :
    res = 0
    for i in range ( n ) :
        res = res | a [ i ]
    print ( res )
if __name__ == ' _ _ main _ _ ' :
    A = [ 1 , 2 , 3 ]
    N = len ( A )
    findbitwiseOR ( A , N )

Index/key variables: i
Iterator variables: i
Python program:
def check ( n ) :
    sumOfDigit = 0
    prodOfDigit = 1
    while n > 0 :
        rem = n % 10
        sumOfDigit += rem
        prodOfDigit *= rem
        n = n // 10
    if sumOfDigit > prodOfDigit :
        print ( " Yes " )
    else :
        print ( " No " )
N = 1234
check ( N )

Accumulator variables: prodOfDigit, sumOfDigit
Python program:
def evenOddBitwiseXOR ( N ) :
    print ( " Even : ▁ " , 0 , end = " ▁ " )
    for i in range ( 4 , N + 1 , 4 ) :
        print ( i , end = " ▁ " )
    print ( )
    print ( " Odd : ▁ " , 1 , end = " ▁ " )
    for i in range ( 4 , N + 1 , 4 ) :
        print ( i - 1 , end = " ▁ " )
    if ( N % 4 == 2 ) :
        print ( N + 1 )
    elif ( N % 4 == 3 ) :
        print ( N )
N = 6
evenOddBitwiseXOR ( N )

Iterator variables: i
Python program:
def findPermutation ( arr ) :
    N = len ( arr )
    i = N - 2
    while ( i >= 0 and arr [ i ] <= arr [ i + 1 ] ) :
        i -= 1
    if ( i == - 1 ) :
        print ( " - 1" )
        return
    j = N - 1
    while ( j > i and arr [ j ] >= arr [ i ] ) :
        j -= 1
    while ( j > i and arr [ j ] == arr [ j - 1 ] ) :
        j -= 1
    temp = arr [ i ] ;
    arr [ i ] = arr [ j ] ;
    arr [ j ] = temp ;
    for it in arr :
        print ( it , end = " ▁ " )
arr = [ 1 , 2 , 5 , 3 , 4 , 6 ]
findPermutation ( arr )

Index/key variables: i, j
Iterator variables: it
Python program:
def sieveOfEratosthenes ( N , s ) :
    prime = [ False ] * ( N + 1 )
    for i in range ( 2 , N + 1 , 2 ) :
        s [ i ] = 2
    for i in range ( 3 , N , 2 ) :
        if ( prime [ i ] == False ) :
            s [ i ] = i
            for j in range ( i , N , 2 ) :
                if j * i > N :
                    break
                if ( not prime [ i * j ] ) :
                    prime [ i * j ] = True
                    s [ i * j ] = i
def findDifference ( N ) :
    s = [ 0 ] * ( N + 1 )
    sieveOfEratosthenes ( N , s )
    total , odd , even = 1 , 1 , 0
    curr = s [ N ]
    cnt = 1
    while ( N > 1 ) :
        N //= s [ N ]
        if ( curr == s [ N ] ) :
            cnt += 1
            continue
        if ( curr == 2 ) :
            total = total * ( cnt + 1 )
        else :
            total = total * ( cnt + 1 )
            odd = odd * ( cnt + 1 )
        curr = s [ N ]
        cnt = 1
    even = total - odd
    print ( abs ( even - odd ) )
if __name__ == ' _ _ main _ _ ' :
    N = 12
    findDifference ( N )

Index/key variables: N, i
Accumulator variables: cnt
Iterator variables: i, j
Python program:
import math
def countPrimeFactors ( n ) :
    count = 0
    while ( n % 2 == 0 ) :
        n = n // 2
        count += 1
    for i in range ( 3 , int ( math . sqrt ( n ) + 1 ) , 2 ) :
        while ( n % i == 0 ) :
            n = n // i
            count += 1
    if ( n > 2 ) :
        count += 1
    return ( count )
def findSum ( n ) :
    sum = 0
    i = 1
    num = 2
    while ( i <= n ) :
        if ( countPrimeFactors ( num ) == 2 ) :
            sum += num
            i += 1
        num += 1
    return sum
def check ( n , k ) :
    s = findSum ( k - 1 )
    if ( s >= n ) :
        print ( " No " )
    else :
        print ( " Yes " )
n = 100
k = 6
check ( n , k )

Accumulator variables: count, num, sum
Iterator variables: i
Python program:
import math
def gcd ( a , b ) :
    while ( b > 0 ) :
        rem = a % b
        a = b
        b = rem
    return a
def countNumberOfWays ( n ) :
    if ( n == 1 ) :
        return - 1
    g = 0
    power = 0
    while ( n % 2 == 0 ) :
        power += 1
        n //= 2
    g = gcd ( g , power )
    for i in range ( 3 , int ( math . sqrt ( g ) ) + 1 , 2 ) :
        power = 0
        while ( n % i == 0 ) :
            power += 1
            n //= i
        g = gcd ( g , power )
    if ( n > 2 ) :
        g = gcd ( g , 1 )
    ways = 1
    power = 0
    while ( g % 2 == 0 ) :
        g //= 2
        power += 1
    ways *= ( power + 1 )
    for i in range ( 3 , int ( math . sqrt ( g ) ) + 1 , 2 ) :
        power = 0
        while ( g % i == 0 ) :
            power += 1
            g /= i
        ways *= ( power + 1 )
    if ( g > 2 ) :
        ways *= 2
    return ways
N = 64
print ( countNumberOfWays ( N ) )

Accumulator variables: g, n, power, ways
Iterator variables: i
Python program:
def smallestPoss ( s , n ) :
    ans = " " ;
    arr = [ 0 ] * 10 ;
    for i in range ( n ) :
        arr [ ord ( s [ i ] ) - 48 ] += 1 ;
    for i in range ( 10 ) :
        for j in range ( arr [ i ] ) :
            ans = ans + str ( i ) ;
    return ans ;
if __name__ == ' _ _ main _ _ ' :
    N = 15 ;
    K = "325343273113434" ;
    print ( smallestPoss ( K , N ) ) ;

Index/key variables: i
Iterator variables: i, j
Python program:
def Count_subarray ( arr , n ) :
    subarray_sum , remaining_sum , count = 0 , 0 , 0 ;
    for i in range ( n ) :
        for j in range ( i , n ) :
            subarray_sum = 0 ;
            remaining_sum = 0 ;
            for k in range ( i , j + 1 ) :
                subarray_sum += arr [ k ] ;
            for l in range ( i ) :
                remaining_sum += arr [ l ] ;
            for l in range ( j + 1 , n ) :
                remaining_sum += arr [ l ] ;
            if ( subarray_sum > remaining_sum ) :
                count += 1 ;
    return count ;
if __name__ == ' _ _ main _ _ ' :
    arr = [ 10 , 9 , 12 , 6 ] ;
    n = len ( arr ) ;
    print ( Count_subarray ( arr , n ) ) ;

Index/key variables: k, l
Accumulator variables: count, remaining_sum, subarray_sum
Iterator variables: i, j, k, l
Python program:
def Count_subarray ( arr , n ) :
    total_sum = 0 ;
    count = 0 ;
    for i in range ( n ) :
        total_sum += arr [ i ] ;
    for i in range ( n ) :
        subarray_sum = 0 ;
        for j in range ( i , n ) :
            subarray_sum += arr [ j ] ;
            remaining_sum = total_sum - subarray_sum ;
            if ( subarray_sum > remaining_sum ) :
                count += 1 ;
    return count ;
if __name__ == " _ _ main _ _ " :
    arr = [ 10 , 9 , 12 , 6 ] ;
    n = len ( arr ) ;
    print ( Count_subarray ( arr , n ) ) ;

Index/key variables: i, j
Accumulator variables: count, subarray_sum, total_sum
Iterator variables: i, j
Python program:
def maxXOR ( arr , n ) :
    xorArr = 0
    for i in range ( n ) :
        xorArr ^= arr [ i ]
    ans = 0
    for i in range ( n ) :
        ans = max ( ans , ( xorArr ^ arr [ i ] ) )
    return ans
arr = [ 1 , 1 , 3 ]
n = len ( arr )
print ( maxXOR ( arr , n ) )

Index/key variables: i
Accumulator variables: xorArr
Iterator variables: i
Python program:
def digitDividesK ( num , k ) :
    while ( num ) :
        d = num % 10
        if ( d != 0 and k % d == 0 ) :
            return True
        num = num // 10
    return False
def findCount ( l , r , k ) :
    count = 0
    for i in range ( l , r + 1 ) :
        if ( digitDividesK ( i , k ) ) :
            count += 1
    return count
l = 20
r = 35
k = 45
print ( findCount ( l , r , k ) )

Accumulator variables: count
Iterator variables: i