dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
mod = 1000000007
def countSubsets ( a , n ) :
    answer = 0
    powerOfTwo = [ 0 for x in range ( 100005 ) ]
    powerOfTwo [ 0 ] = 1
    for i in range ( 1 , 100005 ) :
        powerOfTwo [ i ] = ( powerOfTwo [ i - 1 ] * 2 ) % mod
    frequency = { }
    for i in range ( 0 , n ) :
        if a [ i ] in frequency :
            frequency [ a [ i ] ] += 1
        else :
            frequency [ a [ i ] ] = 1
    for key , value in frequency . items ( ) :
        if ( key != 0 ) :
            answer = ( answer % mod + powerOfTwo [ value - 1 ] ) % mod
        else :
            answer = ( answer % mod + powerOfTwo [ value ] - 1 + mod ) % mod
    return answer
N = 6
A = [ 1 , 3 , 2 , 1 , 2 , 1 ]
print ( countSubsets ( A , N ) )

Index/key variables: i, value
Iterator variables: i, key, value
Python program:
from math import sqrt
pref = [ 0 ] * 10000 ;
def isPerfect ( n ) :
    sum = 1 ;
    for i in range ( 2 , int ( sqrt ( n ) ) + 1 ) :
        if ( n % i == 0 ) :
            if ( i * i != n ) :
                sum = sum + i + n // i ;
            else :
                sum = sum + i ;
    if ( sum == n and n != 1 ) :
        return n ;
    return 0 ;
def precomputation ( ) :
    for i in range ( 1 , 10000 ) :
        pref [ i ] = pref [ i - 1 ] + isPerfect ( i ) ;
if __name__ == " _ _ main _ _ " :
    L = 6 ; R = 28 ;
    precomputation ( ) ;
    print ( pref [ R ] - pref [ L - 1 ] ) ;

Index/key variables: R, i
Iterator variables: i
Python program:
import math ;
def convertToDecimal ( N ) :
    print ( " Decimal ▁ number ▁ of " , N , " is : " , end = " ▁ " ) ;
    if ( N != 0 ) :
        decimalNumber = 0 ;
        i = 0 ;
        remainder = 0 ;
        while ( N != 0 ) :
            remainder = N % 10 ;
            N = N // 10 ;
            decimalNumber += remainder * math . pow ( 3 , i ) ;
            i += 1 ;
        print ( decimalNumber ) ;
    else :
        print ( "0" ) ;
Ternary = 10202202 ;
convertToDecimal ( Ternary ) ;

Accumulator variables: decimalNumber, i
Python program:
from math import sqrt , floor
def isPerfectSquare ( N ) :
    sr = sqrt ( N )
    return ( sr - floor ( sr ) ) == 0
def BetrothedNumbers ( n , m ) :
    Sum1 = 1
    Sum2 = 1
    for i in range ( 2 , int ( sqrt ( n ) ) + 1 , 1 ) :
        if ( n % i == 0 ) :
            if ( isPerfectSquare ( n ) ) :
                Sum1 += i
            else :
                Sum1 += i + n / i
    for i in range ( 2 , int ( sqrt ( m ) ) + 1 , 1 ) :
        if ( m % i == 0 ) :
            if ( isPerfectSquare ( m ) ) :
                Sum2 += i
            else :
                Sum2 += i + ( m / i )
    if ( ( n + 1 == Sum2 ) and ( m + 1 == Sum1 ) ) :
        print ( " YES " )
    else :
        print ( " NO " )
if __name__ == ' _ _ main _ _ ' :
    N = 9504
    M = 20734
    BetrothedNumbers ( N , M )

Accumulator variables: Sum1, Sum2
Iterator variables: i
Python program:
def EulerTotientFunction ( limit ) :
    copy = limit
    primes = [ ]
    for i in range ( 2 , limit + 1 ) :
        if i * i > limit :
            break
        if ( limit % i == 0 ) :
            while ( limit % i == 0 ) :
                limit //= i
            primes . append ( i )
    if ( limit >= 2 ) :
        primes . append ( limit )
    ans = copy
    for it in primes :
        ans = ( ans // it ) * ( it - 1 )
    return ans
def CountGCD ( m , k ) :
    if ( m % k != 0 ) :
        print ( 0 )
        return
    if ( m == k ) :
        print ( 2 )
        return
    limit = m // k
    ans = EulerTotientFunction ( limit )
    print ( ans )
if __name__ == ' _ _ main _ _ ' :
    M = 9
    K = 1
    CountGCD ( M , K )

Accumulator variables: limit, primes
Iterator variables: i, it
Python program:
def product ( mat , n ) :
    d1 = 0
    d2 = 0
    for i in range ( n ) :
        d1 += mat [ i ] [ i ]
        d2 += mat [ i ] [ n - i - 1 ]
    return d1 * d2
if __name__ == ' _ _ main _ _ ' :
    mat = [ [ 5 , 8 , 1 ] , [ 5 , 10 , 3 ] , [ - 6 , 17 , - 9 ] ]
    n = len ( mat )
    print ( product ( mat , n ) )

Index/key variables: i
Accumulator variables: d1, d2
Iterator variables: i
Python program:
def sumOfPrevK ( N , K ) :
    arr = [ 0 for i in range ( N ) ]
    arr [ 0 ] = 1
    for i in range ( 1 , N ) :
        j = i - 1
        count = 0
        sum = 0
        while ( j >= 0 and count < K ) :
            sum = sum + arr [ j ]
            j = j - 1
            count = count + 1
        arr [ i ] = sum
    for i in range ( 0 , N ) :
        print ( arr [ i ] )
N = 10
K = 4
sumOfPrevK ( N , K )

Index/key variables: i, j
Iterator variables: i
Python program:
def sumOfPrevK ( N , K ) :
    arr = [ 0 ] * N ;
    prevsum = 0 ;
    arr [ 0 ] = 1 ;
    for i in range ( N - 1 ) :
        if ( i < K ) :
            arr [ i + 1 ] = arr [ i ] + prevsum ;
            prevsum = arr [ i + 1 ] ;
        else :
            arr [ i + 1 ] = arr [ i ] + prevsum - arr [ i + 1 - K ] ;
            prevsum = arr [ i + 1 ] ;
    for i in range ( N ) :
        print ( arr [ i ] , end = " ▁ " ) ;
if __name__ == ' _ _ main _ _ ' :
    N = 8 ;
    K = 3 ;
    sumOfPrevK ( N , K ) ;

Index/key variables: i
Iterator variables: i
Python program:
def gcd ( a , b ) :
    if ( b == 0 ) :
        return a ;
    return gcd ( b , a % b ) ;
def findMaxGCD ( arr , n ) :
    maxGCD = 0 ;
    for i in range ( 0 , n - 1 ) :
        val = gcd ( arr [ i ] , arr [ i + 1 ] ) ;
        if ( val > maxGCD ) :
            maxGCD = val ;
    print ( maxGCD ) ;
if __name__ == ' _ _ main _ _ ' :
    arr = [ 3 , 18 , 9 , 9 , 5 , 15 , 8 , 7 , 6 , 9 ] ;
    n = len ( arr ) ;
    findMaxGCD ( arr , n ) ;

Index/key variables: i
Iterator variables: i
Python program:
def findSum ( arr , n , left , right ) :
    k = right - left ;
    d = arr [ 1 ] - arr [ 0 ] ;
    ans = arr [ left - 1 ] * ( k + 1 ) ;
    ans = ans + ( d * ( k * ( k + 1 ) ) ) // 2 ;
    return ans ;
if __name__ == ' _ _ main _ _ ' :
    arr = [ 2 , 4 , 6 , 8 , 10 , 12 , 14 , 16 ] ;
    queries = 3 ;
    q = [ [ 2 , 4 ] , [ 2 , 6 ] , [ 5 , 6 ] ] ;
    n = len ( arr ) ;
    for i in range ( queries ) :
        print ( findSum ( arr , n , q [ i ] [ 0 ] , q [ i ] [ 1 ] ) ) ;

Index/key variables: i
Iterator variables: i
Python program:
def subarrayPossible ( arr , n ) :
    sum = 0 ;
    for i in range ( n ) :
        sum += arr [ i ] ;
        if ( sum <= 0 ) :
            return True ;
    sum = 0 ;
    for i in range ( n - 1 , - 1 , - 1 ) :
        sum += arr [ i ] ;
        if ( sum <= 0 ) :
            return True ;
    return False ;
if __name__ == ' _ _ main _ _ ' :
    arr = [ 10 , 5 , - 12 , 7 , - 10 , 20 , 30 , - 10 , 50 , 60 ] ;
    size = len ( arr ) ;
    if ( subarrayPossible ( arr , size ) ) :
        print ( " Yes " ) ;
    else :
        print ( " No " ) ;

Index/key variables: i
Accumulator variables: sum
Iterator variables: i
Python program:
def isPrime ( n ) :
    if ( n <= 1 ) :
        return False
    if ( n <= 3 ) :
        return True
    if ( n % 2 == 0 or n % 3 == 0 ) :
        return False
    i = 5
    while ( i * i <= n ) :
        if ( n % i == 0 or n % ( i + 2 ) == 0 ) :
            return False
        i += 6
    return True
def findSmallest ( N ) :
    if ( N == 0 ) :
        return 2
    if ( N == 1 ) :
        return 1
    prime , counter = N , 0
    found = False
    while ( not found ) :
        if ( isPrime ( prime ) ) :
            found = True
        else :
            prime += 1
            counter += 1
    return counter
if __name__ == " _ _ main _ _ " :
    N = 10
    print ( findSmallest ( N ) )

Accumulator variables: counter, i, prime
Boolean variables: found
Python program:
limit = 1000000
position = [ 0 ] * ( limit + 1 )
def sieve ( ) :
    position [ 0 ] = - 1
    position [ 1 ] = - 1
    pos = 0
    for i in range ( 2 , limit + 1 ) :
        if ( position [ i ] == 0 ) :
            pos += 1
            position [ i ] = pos
            for j in range ( i * 2 , limit + 1 , i ) :
                position [ j ] = - 1
if __name__ == " _ _ main _ _ " :
    sieve ( )
    n = 11
    print ( position [ n ] )

Index/key variables: i, j, n
Accumulator variables: pos
Iterator variables: i, j
Python program:
def maxSubArraySum ( a , size ) :
    max_so_far = - 10 ** 9
    max_ending_here = 0
    for i in range ( size ) :
        max_ending_here = max_ending_here + a [ i ]
        if ( max_so_far < max_ending_here ) :
            max_so_far = max_ending_here
        if ( max_ending_here < 0 ) :
            max_ending_here = 0
    return max_so_far
def minPossibleSum ( a , n , x ) :
    mxSum = maxSubArraySum ( a , n )
    sum = 0
    for i in range ( n ) :
        sum += a [ i ]
    sum = sum - mxSum + mxSum / x
    print ( round ( sum , 2 ) )
if __name__ == ' _ _ main _ _ ' :
    N = 3
    X = 2
    A = [ 1 , - 2 , 3 ]
    minPossibleSum ( A , N , X )

Index/key variables: i
Accumulator variables: sum
Iterator variables: i
Python program:
def reverse ( num ) :
    rev_num = 0
    while ( num > 0 ) :
        rev_num = rev_num * 10 + num % 10
        num = num // 10
    return rev_num
def countReverse ( arr , n ) :
    res = 0
    for i in range ( n ) :
        for j in range ( i + 1 , n ) :
            if ( reverse ( arr [ i ] ) == arr [ j ] ) :
                res += 1
    return res
if __name__ == ' _ _ main _ _ ' :
    a = [ 16 , 61 , 12 , 21 , 25 ]
    n = len ( a )
    print ( countReverse ( a , n ) )

Index/key variables: i, j
Accumulator variables: res
Iterator variables: i, j
Python program:
from collections import defaultdict
def reverse ( num ) :
    rev_num = 0
    while ( num > 0 ) :
        rev_num = rev_num * 10 + num % 10
        num = num // 10
    return rev_num
def countReverse ( arr , n ) :
    freq = defaultdict ( int )
    for i in range ( n ) :
        freq [ arr [ i ] ] += 1
    res = 0
    for i in range ( n ) :
        freq [ arr [ i ] ] -= 1
        res += freq [ reverse ( arr [ i ] ) ]
    return res
if __name__ == " _ _ main _ _ " :
    a = [ 16 , 61 , 12 , 21 , 25 ]
    n = len ( a )
    print ( countReverse ( a , n ) )

Index/key variables: i
Accumulator variables: res
Iterator variables: i
Python program:
MOD = 1000000007
def rangeSum ( l , r ) :
    a = 1
    b = 9
    res = 0
    for i in range ( 1 , 11 ) :
        L = max ( l , a )
        R = min ( r , b )
        if ( L <= R ) :
            sum = ( L + R ) * ( R - L + 1 ) // 2
            res += pow ( i , i ) * ( sum % MOD )
            res %= MOD
        a = a * 10
        b = b * 10 + 9
    return res
if __name__ == " _ _ main _ _ " :
    l = 98
    r = 102
    print ( rangeSum ( l , r ) )

Accumulator variables: res
Iterator variables: i
Python program:
def TrialDivision ( N ) :
    i = 2
    k = int ( N ** 0.5 )
    while ( i <= k ) :
        if ( N % i == 0 ) :
            return 0
        i += 1
    return 1
if __name__ == " _ _ main _ _ " :
    N = 49
    p = TrialDivision ( N )
    if ( p ) :
        print ( " Prime " )
    else :
        print ( " Composite " )

Accumulator variables: i
Python program:
def isPossible ( A , n , k ) :
    countOfTwo = 0
    for i in range ( n ) :
        if ( A [ i ] % 2 == 0 ) :
            countOfTwo += 1
    if ( k == 0 and countOfTwo == n ) :
        print ( " NO " )
    elif ( countOfTwo >= k ) :
        print ( " Yes " )
    else :
        print ( " No " )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 2 , 4 , 5 ]
    K = 2
    N = len ( arr )
    isPossible ( arr , N , K )

Index/key variables: i
Accumulator variables: countOfTwo
Iterator variables: i
Python program:
def pairs ( n ) :
    c = [ [ 0 for i in range ( 10 ) ] for i in range ( 10 ) ]
    tmp = 1
    for i in range ( 1 , n + 1 ) :
        if ( i >= tmp * 10 ) :
            tmp *= 10
        c [ i // tmp ] [ i % 10 ] += 1
    ans = 0
    for i in range ( 1 , 10 ) :
        for j in range ( 1 , 10 ) :
            ans += c [ i ] [ j ] * c [ j ] [ i ]
    return ans
if __name__ == ' _ _ main _ _ ' :
    n = 25
    print ( pairs ( n ) )

Index/key variables: i, j
Accumulator variables: ans, tmp
Iterator variables: i, j
Python program:
from collections import defaultdict
import math
def createHash ( hash1 , maxElement ) :
    prev , curr = 0 , 1
    hash1 . add ( prev )
    hash1 . add ( curr )
    while ( curr <= maxElement ) :
        temp = curr + prev
        if temp <= maxElement :
            hash1 . add ( temp )
        prev = curr
        curr = temp
def gcdFibonacciFreq ( arr , n ) :
    hash1 = set ( )
    createHash ( hash1 , max ( arr ) )
    m = defaultdict ( int )
    for i in range ( n ) :
        m [ arr [ i ] ] += 1
    gcd = 0
    for it in m . keys ( ) :
        if ( m [ it ] in hash1 ) :
            gcd = math . gcd ( gcd , it )
    return gcd
if __name__ == " _ _ main _ _ " :
    arr = [ 5 , 3 , 6 , 5 , 6 , 6 , 5 , 5 ]
    n = len ( arr )
    print ( gcdFibonacciFreq ( arr , n ) )

Index/key variables: i, it
Accumulator variables: hash1
Iterator variables: i, it
Python program:
def printSeries ( N ) :
    ith_term = 0 ;
    for i in range ( 1 , N + 1 ) :
        ith_term = 0 ;
        if ( i % 2 == 0 ) :
            ith_term = 2 * i * i + 1 ;
        else :
            ith_term = 2 * i * i - 1 ;
        print ( ith_term , end = " , ▁ " ) ;
if __name__ == ' _ _ main _ _ ' :
    N = 7 ;
    printSeries ( N ) ;

Iterator variables: i
Python program:
def findNthTerm ( N ) :
    ans = 0
    for i in range ( N ) :
        if ( i % 2 == 0 ) :
            ans = ans + 6
        else :
            ans = ans + 2
    print ( ans )
if __name__ == ' _ _ main _ _ ' :
    N = 3
    findNthTerm ( N )

Iterator variables: i
Python program:
from math import sqrt
size = 1000
prime = [ 0 for i in range ( size ) ]
freq = [ 0 for i in range ( size ) ]
def sieve ( a , b ) :
    prime [ 1 ] = 1
    for i in range ( 2 , int ( sqrt ( size ) ) + 1 , 1 ) :
        if ( prime [ i ] == 0 ) :
            for j in range ( i * 2 , size , i ) :
                prime [ j ] = 1
    for p in range ( 1 , size , 1 ) :
        for q in range ( 1 , size , 1 ) :
            if ( prime [ p ] == 0 and prime [ q ] == 0 and a * p + b * q < size ) :
                freq [ a * p + b * q ] += 1
if __name__ == ' _ _ main _ _ ' :
    queries = 2
    a = 1
    b = 2
    sieve ( a , b )
    arr = [ 15 , 25 ]
    for i in range ( queries ) :
        print ( freq [ arr [ i ] ] , end = " ▁ " )

Index/key variables: i, j, p, q
Iterator variables: i, j, p, q
Python program:
def printSeriesSum ( N ) :
    sum = 0 ;
    for i in range ( 1 , N + 1 ) :
        if ( i & 1 ) :
            sum += i / ( i + 1 ) ;
        else :
            sum -= i / ( i + 1 ) ;
    print ( sum ) ;
if __name__ == " _ _ main _ _ " :
    N = 10 ;
    printSeriesSum ( N ) ;

Accumulator variables: sum
Iterator variables: i
Python program:
def printSeriessumm ( N ) :
    summ = 0
    for i in range ( 1 , N + 1 ) :
        summ += pow ( i , i - 1 )
    print ( summ )
N = 5
printSeriessumm ( N )

Accumulator variables: summ
Iterator variables: i
Python program:
def printSumSeries ( N ) :
    sum = 0 ;
    for i in range ( 1 , N + 1 ) :
        sum += 1.0 / ( 2 * i - 1 ) ;
    print ( sum ) ;
if __name__ == " _ _ main _ _ " :
    N = 6 ;
    printSumSeries ( N ) ;

Accumulator variables: sum
Iterator variables: i
Python program:
def printSeriesSum ( N ) :
    sum = 0 ;
    a = 1 ;
    cnt = 0 ;
    flag = True ;
    sum += a ;
    while ( cnt < N ) :
        nextElement = None ;
        if ( flag ) :
            nextElement = a * 2 ;
            sum += nextElement ;
            flag = not flag ;
        else :
            nextElement = a * ( 3 / 2 ) ;
            sum += nextElement ;
            flag = not flag ;
        a = nextElement ;
        cnt += 1
    print ( sum ) ;
if __name__ == " _ _ main _ _ " :
    N = 8 ;
    printSeriesSum ( N ) ;

Accumulator variables: cnt, sum
Boolean variables: flag
Python program:
def sumBaseB ( a , b , base ) :
    len_a = len ( a )
    len_b = len ( b )
    s = " " ;
    sum = " " ;
    diff = abs ( len_a - len_b ) ;
    for i in range ( 1 , diff + 1 ) :
        s += "0"
    if ( len_a < len_b ) :
        a = s + a
    else :
        b = s + b ;
    carry = 0 ;
    for i in range ( max ( len_a , len_b ) - 1 , - 1 , - 1 ) :
        curr = carry + ( ord ( a [ i ] ) - ord ( '0' ) ) + ( ord ( b [ i ] ) - ord ( '0' ) ) ;
        carry = curr // base
        curr = curr % base ;
        sum = chr ( curr + ord ( '0' ) ) + sum
    if ( carry > 0 ) :
        sum = chr ( carry + ord ( '0' ) ) + sum ;
    return sum
a = "123"
b = "234"
base = 6
sum = sumBaseB ( a , b , base ) ;
print ( sum )

Index/key variables: i
Accumulator variables: s
Iterator variables: i
Python program:
def MinimumSwapOperations ( s ) :
    zero_exist = False
    multiple_of_2 = False
    sum = 0
    index_of_zero = 0
    more_zero = False
    for i in range ( len ( s ) ) :
        val = ord ( s [ i ] ) - ord ( '0' )
        if ( zero_exist == True ) :
            more_zero = True
        if ( val == 0 ) :
            zero_exist = True
            index_of_zero = i
        sum += val
    if ( zero_exist == False or sum % 3 != 0 ) :
        print ( " - 1" )
        return
    for i in range ( len ( s ) ) :
        val = ord ( s [ i ] ) - ord ( '0' )
        if ( val % 2 == 0 and i != index_of_zero ) :
            multiple_of_2 = True
    if ( multiple_of_2 == False ) :
        print ( " - 1" )
        return
    last_val = ord ( s [ len ( s ) - 1 ] ) - ord ( '0' )
    second_last_val = ord ( s [ len ( s ) - 2 ] ) - ord ( '0' )
    if ( last_val == 0 and second_last_val % 2 == 0 ) :
        print ( 0 )
    elif ( ( last_val == 0 and second_last_val % 2 != 0 ) or ( last_val % 2 == 0 and second_last_val == 0 ) ) :
        print ( 1 )
    elif ( more_zero == True and ( last_val == 0 and second_last_val % 2 != 0 ) ) :
        print ( 1 )
    else :
        print ( 2 )
if __name__ == ' _ _ main _ _ ' :
    N = "20"
    MinimumSwapOperations ( N )

Index/key variables: i
Accumulator variables: sum
Iterator variables: i
Boolean variables: more_zero, multiple_of_2, zero_exist
Python program:
def isPalindrome ( x ) :
    num = str ( x )
    result = True
    i = 0
    j = len ( num ) - 1
    while ( i < j and result ) :
        result = num [ i ] == num [ j ]
        i += 1
        j -= 1
    return result
def find ( nDigits ) :
    lowerBound = pow ( 10 , nDigits - 1 )
    upperBound = ( lowerBound * 10 ) - 1
    resultP = 0
    resultQ = 0
    resultR = 0
    for p in range ( upperBound , lowerBound , - 11 ) :
        while ( p % 11 != 0 ) :
            p -= 1
        for q in range ( upperBound , lowerBound , - 1 ) :
            t = p * q
            if ( t > resultR and isPalindrome ( t ) ) :
                resultP = p
                resultQ = q
                resultR = t
                break
    print ( resultR )
if __name__ == " _ _ main _ _ " :
    N = 2
    find ( N )

Index/key variables: i, j
Iterator variables: p, q
Boolean variables: result
Python program:
MAX = 10000 ;
max_prime = [ 0 ] * MAX ;
min_prime = [ 0 ] * MAX ;
def sieve ( n ) :
    for i in range ( 2 , n ) :
        if ( min_prime [ i ] > 0 ) :
            continue ;
        min_prime [ i ] = i ;
        max_prime [ i ] = i ;
        j = i + i ;
        while ( j < n ) :
            if ( min_prime [ j ] == 0 ) :
                min_prime [ j ] = i ;
            max_prime [ j ] = i ;
            j += i ;
def findCost ( A , B , C , X ) :
    sieve ( MAX ) ;
    if ( X == 1 ) :
        return - 1 ;
    min_cost = C + X ;
    cost_for_prime = A ;
    N = max_prime [ X ] ;
    if ( N != X ) :
        M = X // N ;
        cost_for_prime += M ;
        min_cost = min ( min_cost , cost_for_prime ) ;
    M = min_prime [ X ] ;
    N = X // M ;
    if ( N != min_prime [ N ] ) :
        cost_for_comp = B + M ;
        min_cost = min ( min_cost , cost_for_comp ) ;
    return min_cost ;
if __name__ == " _ _ main _ _ " :
    A = 7 ; B = 11 ; C = 2 ; X = 20 ;
    print ( findCost ( A , B , C , X ) ) ;

Index/key variables: N, X, i, j
Iterator variables: i
Python program:
def printModulus ( X , Y ) :
    n = max ( X , Y )
    for i in range ( 1 , n + 1 ) :
        if ( X % i == Y % i ) :
            print ( i , end = " ▁ " )
X = 10
Y = 20
printModulus ( X , Y )

Iterator variables: i
Python program:
def printModulus ( X , Y ) :
    d = abs ( X - Y ) ;
    i = 1 ;
    while ( i * i <= d ) :
        if ( d % i == 0 ) :
            print ( i , end = " " ) ;
            if ( d // i != i ) :
                print ( d // i , end = " ▁ " ) ;
        i += 1 ;
if __name__ == ' _ _ main _ _ ' :
    X = 10 ;
    Y = 26 ;
    printModulus ( X , Y ) ;

Accumulator variables: i
Python program:
from math import sqrt , ceil , floor
def createHash ( maxElement ) :
    prev = 0
    curr = 1
    d = dict ( )
    d [ prev ] = 1
    d [ curr ] = 1
    while ( curr <= maxElement ) :
        temp = curr + prev
        d [ temp ] = 1
        prev = curr
        curr = temp
    return d
def countFibonacciDivisors ( n ) :
    hash = createHash ( n )
    cnt = 0
    for i in range ( 1 , ceil ( sqrt ( n ) ) ) :
        if ( n % i == 0 ) :
            if ( ( n // i == i ) and ( n // i in hash ) ) :
                cnt += 1
            else :
                if ( n // i in hash ) :
                    cnt += 1
                if ( n // ( n // i ) in hash ) :
                    cnt += 1
    return cnt
n = 12
print ( countFibonacciDivisors ( n ) )

Index/key variables: curr, prev, temp
Accumulator variables: cnt
Iterator variables: i
Python program:
def makearrayequal ( arr , n ) :
    x = 0 ;
    for i in range ( n ) :
        x += arr [ i ] & 1 ;
    print ( min ( x , n - x ) ) ;
if __name__ == " _ _ main _ _ " :
    arr = [ 4 , 3 , 2 , 1 ] ;
    n = len ( arr ) ;
    makearrayequal ( arr , n ) ;

Index/key variables: i
Accumulator variables: x
Iterator variables: i
Python program:
def countDigit ( n ) :
    temp = n
    count = 0
    while ( temp != 0 ) :
        d = temp % 10
        temp //= 10
        if ( d == 2 or d == 3 or d == 5 or d == 7 ) :
            count += 1
    return count
if __name__ == ' _ _ main _ _ ' :
    n = 1234567890
    print ( countDigit ( n ) )

Accumulator variables: count, temp
Python program:
def permutation ( arr , N ) :
    hash = [ 0 ] * ( N + 1 ) ;
    for i in range ( N ) :
        hash [ arr [ i ] ] += 1 ;
    for i in range ( 1 , N + 1 ) :
        if ( hash [ i ] != 1 ) :
            return " No " ;
    return " Yes " ;
if __name__ == " _ _ main _ _ " :
    arr = [ 1 , 1 , 5 , 5 , 3 ] ;
    n = len ( arr ) ;
    print ( permutation ( arr , n ) ) ;

Index/key variables: i
Iterator variables: i
Python program:
def check ( arr , n ) :
    count = 0 ;
    for i in range ( n ) :
        if ( arr [ i ] & 1 ) :
            count = count + 1 ;
    if ( count & 1 ) :
        return " Odd " ;
    else :
        return " Even " ;
if __name__ == ' _ _ main _ _ ' :
    arr = [ 3 , 9 , 12 , 13 , 15 ]
    n = len ( arr )
    print ( check ( arr , n ) )

Index/key variables: i
Iterator variables: i
Python program:
N = 100005
def SieveOfEratosthenes ( prime , p_size ) :
    prime [ 0 ] = False
    prime [ 1 ] = False
    p = 2
    while p * p <= p_size :
        if ( prime [ p ] ) :
            for i in range ( p * 2 , p_size + 1 , p ) :
                prime [ i ] = False
        p += 1
def longestPrimeSubsequence ( arr , n ) :
    prime = [ True ] * ( N + 1 )
    SieveOfEratosthenes ( prime , N )
    answer = 0
    for i in range ( n ) :
        if ( prime [ arr [ i ] ] ) :
            answer += 1
    return answer
if __name__ == " _ _ main _ _ " :
    arr = [ 3 , 4 , 11 , 2 , 9 , 21 ]
    n = len ( arr )
    print ( longestPrimeSubsequence ( arr , n ) )

Index/key variables: i, p
Accumulator variables: answer
Iterator variables: i
Python program:
def dydx ( x , y ) :
    return ( x + y - 2 ) ;
def rungeKutta ( x0 , y0 , x , h ) :
    n = round ( ( x - x0 ) / h ) ;
    y = y0 ;
    for i in range ( 1 , n + 1 ) :
        k1 = h * dydx ( x0 , y ) ;
        k2 = h * dydx ( x0 + 0.5 * h , y + 0.5 * k1 ) ;
        y = y + ( 1.0 / 6.0 ) * ( k1 + 2 * k2 ) ;
        x0 = x0 + h ;
    return y ;
if __name__ == " _ _ main _ _ " :
    x0 = 0 ; y = 1 ;
    x = 2 ; h = 0.2 ;
    print ( " y ( x ) ▁ = " , rungeKutta ( x0 , y , x , h ) ) ;

Iterator variables: i