dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
def printUncommon ( str1 , str2 ) :
    a1 = 0 ; a2 = 0 ;
    for i in range ( len ( str1 ) ) :
        ch = ord ( str1 [ i ] ) - ord ( ' a ' ) ;
        a1 = a1 | ( 1 << ch ) ;
    for i in range ( len ( str2 ) ) :
        ch = ord ( str2 [ i ] ) - ord ( ' a ' ) ;
        a2 = a2 | ( 1 << ch ) ;
    ans = a1 ^ a2 ;
    i = 0 ;
    while ( i < 26 ) :
        if ( ans % 2 == 1 ) :
            print ( chr ( ord ( ' a ' ) + i ) , end = " " ) ;
        ans = ans // 2 ;
        i += 1 ;
if __name__ == " _ _ main _ _ " :
    str1 = " geeksforgeeks " ;
    str2 = " geeksquiz " ;
    printUncommon ( str1 , str2 ) ;

Index/key variables: i
Iterator variables: i
Python program:
def countMinReversals ( expr ) :
    length = len ( expr )
    if length % 2 :
        return - 1
    ans = 0
    open = 0
    close = 0
    for i in range ( 0 , length ) :
        if expr [ i ] == " " :
            open += 1
        else :
            if not open :
                close += 1
            else :
                open -= 1
    ans = ( close // 2 ) + ( open // 2 )
    close %= 2
    open %= 2
    if close > 0 :
        ans += 2
    return ans
if __name__ == " _ _ main _ _ " :
    expr = " } } { { "
    print ( countMinReversals ( expr ) )

Index/key variables: i
Accumulator variables: close, open
Iterator variables: i
Python program:
def totalPairs ( s1 , s2 ) :
    a1 = 0 ; b1 = 0 ;
    for i in range ( len ( s1 ) ) :
        if ( ord ( s1 [ i ] ) % 2 != 0 ) :
            a1 += 1 ;
        else :
            b1 += 1 ;
    a2 = 0 ; b2 = 0 ;
    for i in range ( len ( s2 ) ) :
        if ( ord ( s2 [ i ] ) % 2 != 0 ) :
            a2 += 1 ;
        else :
            b2 += 1 ;
    return ( ( a1 * a2 ) + ( b1 * b2 ) ) ;
if __name__ == " _ _ main _ _ " :
    s1 = " geeks " ;
    s2 = " for " ;
    print ( totalPairs ( s1 , s2 ) ) ;

Index/key variables: i
Accumulator variables: a1, a2, b1, b2
Iterator variables: i
Python program:
def prefixOccurrences ( str1 ) :
    c = str1 [ 0 ]
    countc = 0
    for i in range ( len ( str1 ) ) :
        if ( str1 [ i ] == c ) :
            countc += 1
    return countc
str1 = " abbcdabbcd "
print ( prefixOccurrences ( str1 ) )

Index/key variables: i
Accumulator variables: countc
Iterator variables: i
Python program:
def minOperations ( s , t , n ) :
    ct0 = 0
    ct1 = 0
    for i in range ( n ) :
        if ( s [ i ] == t [ i ] ) :
            continue
        if ( s [ i ] == '0' ) :
            ct0 += 1
        else :
            ct1 += 1
    return max ( ct0 , ct1 )
if __name__ == " _ _ main _ _ " :
    s = "010"
    t = "101"
    n = len ( s )
    print ( minOperations ( s , t , n ) )

Index/key variables: i
Accumulator variables: ct0, ct1
Iterator variables: i
Python program:
def decryptString ( str , n ) :
    i = 0
    jump = 1
    decryptedStr = " "
    while ( i < n ) :
        decryptedStr += str [ i ] ;
        i += jump
        jump += 1
    return decryptedStr
if __name__ == ' _ _ main _ _ ' :
    str = " geeeeekkkksssss "
    n = len ( str )
    print ( decryptString ( str , n ) )

Index/key variables: i
Accumulator variables: decryptedStr, jump
Python program:
def SieveofEratosthenes ( prime , p_size ) :
    prime [ 0 ] = False
    prime [ 1 ] = False
    for p in range ( 2 , p_size + 1 ) :
        if prime [ p ] :
            for i in range ( p * 2 , p_size + 1 , p ) :
                prime [ i ] = False
def sumProdOfPrimeFreq ( s ) :
    prime = [ True ] * ( len ( s ) + 2 )
    SieveofEratosthenes ( prime , len ( s ) + 1 )
    i = 0
    j = 0
    m = dict ( )
    for i in range ( len ( s ) ) :
        m [ s [ i ] ] = ( m [ s [ i ] ] + 1 ) if s [ i ] in m else 1
    s = 0
    product = 1
    for it in m :
        if prime [ m [ it ] ] :
            s += m [ it ]
            product *= m [ it ]
    print ( " Sum ▁ = " , s )
    print ( " Product ▁ = " , product )
if __name__ == " _ _ main _ _ " :
    s = " geeksforgeeks "
    sumProdOfPrimeFreq ( s )

Index/key variables: i, it, p
Accumulator variables: product, s
Iterator variables: i, it, p
Python program:
from collections import defaultdict
def multipleOrFactor ( s1 , s2 ) :
    m1 = defaultdict ( lambda : 0 )
    m2 = defaultdict ( lambda : 0 )
    for i in range ( 0 , len ( s1 ) ) :
        m1 [ s1 [ i ] ] += 1
    for i in range ( 0 , len ( s2 ) ) :
        m2 [ s2 [ i ] ] += 1
    for it in m1 :
        if it not in m2 :
            continue
        if ( m2 [ it ] % m1 [ it ] == 0 or m1 [ it ] % m2 [ it ] == 0 ) :
            continue
        else :
            return False
    return True
if __name__ == " _ _ main _ _ " :
    s1 = " geeksforgeeks "
    s2 = " geeks "
    if multipleOrFactor ( s1 , s2 ) : print ( " YES " )
    else : print ( " NO " )

Index/key variables: i, it
Iterator variables: i, it
Python program:
def solve ( s ) :
    m = dict ( )
    for i in range ( len ( s ) ) :
        if s [ i ] in m :
            m [ s [ i ] ] = m [ s [ i ] ] + 1
        else :
            m [ s [ i ] ] = 1
    new_string = " "
    for i in range ( len ( s ) ) :
        if m [ s [ i ] ] % 2 == 0 :
            continue
        new_string = new_string + s [ i ]
    print ( new_string )
if __name__ == ' _ _ main _ _ ' :
    s = " aabbbddeeecc "
    solve ( s )

Index/key variables: i
Iterator variables: i
Python program:
def findSubSequence ( s , num ) :
    res = 0
    i = 0
    while ( num ) :
        if ( num & 1 ) :
            res += ord ( s [ i ] ) - ord ( '0' )
        i += 1
        num = num >> 1
    return res
def combinedSum ( s ) :
    n = len ( s )
    c_sum = 0
    ran = ( 1 << n ) - 1
    for i in range ( ran + 1 ) :
        c_sum += findSubSequence ( s , i )
    return c_sum
if __name__ == " _ _ main _ _ " :
    s = "123"
    print ( combinedSum ( s ) )

Index/key variables: i
Accumulator variables: c_sum, res
Iterator variables: i
Python program:
MAX_CHAR = 26
def findSubsequence ( stri , k ) :
    a = [ 0 ] * MAX_CHAR ;
    for i in range ( len ( stri ) ) :
        a [ ord ( stri [ i ] ) - ord ( ' a ' ) ] += 1
    for i in range ( len ( stri ) ) :
        if a [ ord ( stri [ i ] ) - ord ( ' a ' ) ] >= k :
            print ( stri [ i ] , end = ' ' )
k = 2
findSubsequence ( " geeksforgeeks " , k )

Index/key variables: i
Iterator variables: i
Python program:
def convert ( str ) :
    w = " "
    z = " " ;
    str = str . upper ( ) + " ▁ " ;
    for i in range ( len ( str ) ) :
        ch = str [ i ] ;
        if ( ch != ' ▁ ' ) :
            w = w + ch ;
        else :
            z = ( z + ( w [ 0 ] ) . lower ( ) + w [ 1 : len ( w ) ] + " ▁ " ) ;
            w = " " ;
    return z ;
if __name__ == ' _ _ main _ _ ' :
    str = " I ▁ got ▁ intern ▁ at ▁ geeksforgeeks " ;
    print ( convert ( str ) ) ;

Index/key variables: i
Iterator variables: i
Python program:
def isVowel ( c ) :
    return ( c == ' a ' or c == ' e ' or c == ' i ' or c == ' o ' or c == ' u ' )
def encryptString ( s , n , k ) :
    cv = [ 0 for i in range ( n ) ]
    cc = [ 0 for i in range ( n ) ]
    if ( isVowel ( s [ 0 ] ) ) :
        cv [ 0 ] = 1
    else :
        cc [ 0 ] = 1
    for i in range ( 1 , n ) :
        cv [ i ] = cv [ i - 1 ] + isVowel ( s [ i ] )
        cc [ i ] = cc [ i - 1 ] + ( isVowel ( s [ i ] ) == False )
    ans = " "
    prod = 0
    prod = cc [ k - 1 ] * cv [ k - 1 ]
    ans += str ( prod )
    for i in range ( k , len ( s ) ) :
        prod = ( ( cc [ i ] - cc [ i - k ] ) * ( cv [ i ] - cv [ i - k ] ) )
        ans += str ( prod )
    return ans
if __name__ == ' _ _ main _ _ ' :
    s = " hello "
    n = len ( s )
    k = 2
    print ( encryptString ( s , n , k ) )

Index/key variables: i
Accumulator variables: ans
Iterator variables: i
Python program:
def printInitials ( name ) :
    if ( len ( name ) == 0 ) :
        return
    words = name . split ( " ▁ " )
    for word in words :
        print ( word [ 0 ] . upper ( ) , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
    name = " prabhat ▁ kumar ▁ singh "
    printInitials ( name )

Iterator variables: word
Python program:
def printString ( str , ch , count ) :
    occ , i = 0 , 0
    if ( count == 0 ) :
        print ( str )
    for i in range ( len ( str ) ) :
        if ( str [ i ] == ch ) :
            occ += 1
        if ( occ == count ) :
            break
    if ( i < len ( str ) - 1 ) :
        print ( str [ i + 1 : len ( str ) - i + 2 ] )
    else :
        print ( " Empty ▁ string " )
if __name__ == ' _ _ main _ _ ' :
    str = " geeks ▁ for ▁ geeks "
    printString ( str , ' e ' , 2 )

Index/key variables: i
Accumulator variables: occ
Iterator variables: i
Python program:
def isVowel ( c ) :
    return ( c == ' a ' or c == ' A ' or c == ' e ' or c == ' E ' or c == ' i ' or c == ' I ' or c == ' o ' or c == ' O ' or c == ' u ' or c == ' U ' )
def reverseVowel ( str ) :
    i = 0
    j = len ( str ) - 1
    while ( i < j ) :
        if not isVowel ( str [ i ] ) :
            i += 1
            continue
        if ( not isVowel ( str [ j ] ) ) :
            j -= 1
            continue
        str [ i ] , str [ j ] = str [ j ] , str [ i ]
        i += 1
        j -= 1
    return str
if __name__ == " _ _ main _ _ " :
    str = " hello ▁ world "
    print ( * reverseVowel ( list ( str ) ) , sep = " " )

Index/key variables: i, j
Python program:
def isPalindrome ( str ) :
    l = 0
    h = len ( str ) - 1
    while ( h > l ) :
        if ( str [ l ] != str [ h ] ) :
            return 0
        l = l + 1
        h = h - 1
    return 1
def minRemovals ( str ) :
    if ( str [ 0 ] == ' ' ) :
        return 0
    if ( isPalindrome ( str ) ) :
        return 1
    return 2
print ( minRemovals ( "010010" ) )
print ( minRemovals ( "0100101" ) )

Index/key variables: h, l
Python program:
from math import sqrt
class circle :
    def __init__ ( self , a , b , c ) :
        self . x = a
        self . y = b
        self . r = c
def check ( C ) :
    C1C2 = sqrt ( ( C [ 1 ] . x - C [ 0 ] . x ) * ( C [ 1 ] . x - C [ 0 ] . x ) + ( C [ 1 ] . y - C [ 0 ] . y ) * ( C [ 1 ] . y - C [ 0 ] . y ) )
    flag = 0
    if ( C1C2 < ( C [ 0 ] . r + C [ 1 ] . r ) ) :
        if ( ( C [ 0 ] . x + C [ 1 ] . x ) == 2 * C [ 2 ] . x and ( C [ 0 ] . y + C [ 1 ] . y ) == 2 * C [ 2 ] . y ) :
            flag = 1
    return flag
def IsFairTriplet ( c ) :
    f = False
    f |= check ( c )
    for i in range ( 2 ) :
        c [ 0 ] , c [ 2 ] = c [ 2 ] , c [ 0 ]
        f |= check ( c )
    return f
if __name__ == ' _ _ main _ _ ' :
    C = [ circle ( 0 , 0 , 0 ) for i in range ( 3 ) ]
    C [ 0 ] = circle ( 0 , 0 , 8 )
    C [ 1 ] = circle ( 0 , 10 , 6 )
    C [ 2 ] = circle ( 0 , 5 , 5 )
    if ( IsFairTriplet ( C ) ) :
        print ( " Yes " )
    else :
        print ( " No " )

Accumulator variables: f
Iterator variables: i
Boolean variables: f
Class/struct names: circle
Python program:
from math import sqrt
def distance ( m , n , p , q ) :
    return ( sqrt ( pow ( n - m , 2 ) + pow ( q - p , 2 ) * 1.0 ) )
def Excenters ( x1 , y1 , x2 , y2 , x3 , y3 ) :
    a = distance ( x2 , x3 , y2 , y3 )
    b = distance ( x3 , x1 , y3 , y1 )
    c = distance ( x1 , x2 , y1 , y2 )
    excenter = [ [ 0 , 0 ] for i in range ( 4 ) ]
    excenter [ 1 ] [ 0 ] = ( ( - ( a * x1 ) + ( b * x2 ) + ( c * x3 ) ) // ( - a + b + c ) )
    excenter [ 1 ] [ 1 ] = ( ( - ( a * y1 ) + ( b * y2 ) + ( c * y3 ) ) // ( - a + b + c ) )
    excenter [ 2 ] [ 0 ] = ( ( ( a * x1 ) - ( b * x2 ) + ( c * x3 ) ) // ( a - b + c ) )
    excenter [ 2 ] [ 1 ] = ( ( ( a * y1 ) - ( b * y2 ) + ( c * y3 ) ) // ( a - b + c ) )
    excenter [ 3 ] [ 0 ] = ( ( ( a * x1 ) + ( b * x2 ) - ( c * x3 ) ) // ( a + b - c ) )
    excenter [ 3 ] [ 1 ] = ( ( ( a * y1 ) + ( b * y2 ) - ( c * y3 ) ) // ( a + b - c ) )
    for i in range ( 1 , 4 ) :
        print ( int ( excenter [ i ] [ 0 ] ) , int ( excenter [ i ] [ 1 ] ) )
if __name__ == ' _ _ main _ _ ' :
    x1 = 0
    x2 = 3
    x3 = 0
    y1 = 0
    y2 = 0
    y3 = 4
    Excenters ( x1 , y1 , x2 , y2 , x3 , y3 )

Index/key variables: i
Iterator variables: i
Python program:
def countPairs ( P , Q , N , M ) :
    A = [ 0 ] * 2
    B = [ 0 ] * 2
    for i in range ( N ) :
        A [ P [ i ] % 2 ] += 1
    for i in range ( M ) :
        B [ Q [ i ] % 2 ] += 1
    return ( A [ 0 ] * B [ 0 ] + A [ 1 ] * B [ 1 ] )
P = [ 1 , 3 , 2 ]
Q = [ 3 , 0 ]
N = len ( P )
M = len ( Q )
print ( countPairs ( P , Q , N , M ) )

Index/key variables: i
Iterator variables: i
Python program:
def convertToASCII ( N ) :
    num = str ( N )
    i = 0
    for ch in num :
        print ( ch , " ( " , ord ( ch ) , " ) " )
N = 36
convertToASCII ( N )

Iterator variables: ch
Python program:
import math
def productExceptSelf ( arr , N ) :
    product = 1
    z = 0
    for i in range ( N ) :
        if ( arr [ i ] != 0 ) :
            product *= arr [ i ]
        if ( arr [ i ] == 0 ) :
            z += 1
    a = abs ( product )
    for i in range ( N ) :
        if ( z == 1 ) :
            if ( arr [ i ] != 0 ) :
                arr [ i ] = 0
            else :
                arr [ i ] = product
            continue
        elif ( z > 1 ) :
            arr [ i ] = 0
            continue
        b = abs ( arr [ i ] )
        curr = round ( math . exp ( math . log ( a ) - math . log ( b ) ) )
        if ( arr [ i ] < 0 and product < 0 ) :
            arr [ i ] = curr
        elif ( arr [ i ] > 0 and product > 0 ) :
            arr [ i ] = curr
        else :
            arr [ i ] = - 1 * curr
    for i in range ( N ) :
        print ( arr [ i ] , end = " ▁ " )
arr = [ 10 , 3 , 5 , 6 , 2 ]
N = len ( arr )
productExceptSelf ( arr , N )

Index/key variables: i
Accumulator variables: product, z
Iterator variables: i
Python program:
def singleDigitSubarrayCount ( arr , N ) :
    res = 0
    count = 0
    for i in range ( N ) :
        if ( arr [ i ] <= 9 ) :
            count += 1
            res += count
        else :
            count = 0
    print ( res )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 0 , 1 , 14 , 2 , 5 ]
    N = len ( arr )
    singleDigitSubarrayCount ( arr , N )

Index/key variables: i
Accumulator variables: count, res
Iterator variables: i
Python program:
def isPossible ( N ) :
    return ( ( N & ( N - 1 ) ) and N )
def countElements ( N ) :
    count = 0
    for i in range ( 1 , N + 1 ) :
        if ( isPossible ( i ) ) :
            count += 1
    print ( count )
if __name__ == ' _ _ main _ _ ' :
    N = 15
    countElements ( N )

Accumulator variables: count
Iterator variables: i
Python program:
def countElements ( N ) :
    Cur_Ele = 1
    Count = 0
    while ( Cur_Ele <= N ) :
        Count += 1
        Cur_Ele = Cur_Ele * 2
    print ( N - Count )
if __name__ == ' _ _ main _ _ ' :
    N = 15
    countElements ( N )

Accumulator variables: Count
Python program:
import sys
def maxAdjacent ( arr , N ) :
    res = [ ]
    arr_max = - sys . maxsize - 1
    for i in range ( 1 , N ) :
        arr_max = max ( arr_max , abs ( arr [ i - 1 ] - arr [ i ] ) )
    for i in range ( 1 , N - 1 ) :
        curr_max = abs ( arr [ i - 1 ] - arr [ i + 1 ] )
        ans = max ( curr_max , arr_max )
        res . append ( ans )
    for x in res :
        print ( x , end = " ▁ " )
    print ( )
if __name__ == " _ _ main _ _ " :
    arr = [ 1 , 3 , 4 , 7 , 8 ]
    N = len ( arr )
    maxAdjacent ( arr , N )

Index/key variables: i
Accumulator variables: res
Iterator variables: i, x
Python program:
def minimumIncrement ( arr , N ) :
    if ( N % 2 != 0 ) :
        print ( " - 1" )
        return
    cntEven = 0
    cntOdd = 0
    for i in range ( N ) :
        if ( arr [ i ] % 2 == 0 ) :
            cntEven += 1
    cntOdd = N - cntEven
    return abs ( cntEven - cntOdd ) // 2
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 3 , 4 , 9 ]
    N = len ( arr )
    print ( minimumIncrement ( arr , N ) )

Index/key variables: i
Accumulator variables: cntEven
Iterator variables: i
Python program:
def cntWaysConsArray ( A , N ) :
    total = 1 ;
    oddArray = 1 ;
    for i in range ( N ) :
        total = total * 3 ;
        if ( A [ i ] % 2 == 0 ) :
            oddArray *= 2 ;
    print ( total - oddArray ) ;
if __name__ == " _ _ main _ _ " :
    A = [ 2 , 4 ] ;
    N = len ( A ) ;
    cntWaysConsArray ( A , N ) ;

Index/key variables: i
Accumulator variables: oddArray
Iterator variables: i
Python program:
def countNumberHavingKthBitSet ( N , K ) :
    numbers_rightmost_setbit_K = 0
    for i in range ( 1 , K + 1 ) :
        numbers_rightmost_bit_i = ( N + 1 ) // 2
        N -= numbers_rightmost_bit_i
        if ( i == K ) :
            numbers_rightmost_setbit_K = numbers_rightmost_bit_i
    print ( numbers_rightmost_setbit_K )
if __name__ == ' _ _ main _ _ ' :
    N = 15
    K = 2
    countNumberHavingKthBitSet ( N , K )

Accumulator variables: N
Iterator variables: i
Python program:
def countSetBits ( N : int ) -> int :
    count = 0
    while ( N ) :
        N = N & ( N - 1 )
        count += 1
    return count
if __name__ == " _ _ main _ _ " :
    N = 4
    bits = countSetBits ( N )
    print ( " Odd ▁ : ▁ { } " . format ( pow ( 2 , bits ) ) )
    print ( " Even ▁ : ▁ { } " . format ( N + 1 - pow ( 2 , bits ) ) )

Accumulator variables: count
Python program:
def minMoves ( arr , N ) :
    odd_element_cnt = 0 ;
    for i in range ( N ) :
        if ( arr [ i ] % 2 != 0 ) :
            odd_element_cnt += 1 ;
    moves = ( odd_element_cnt ) // 2 ;
    if ( odd_element_cnt % 2 != 0 ) :
        moves += 2 ;
    print ( moves ) ;
if __name__ == ' _ _ main _ _ ' :
    arr = [ 5 , 6 , 3 , 7 , 20 ] ;
    N = len ( arr ) ;
    minMoves ( arr , N ) ;

Index/key variables: i
Accumulator variables: odd_element_cnt
Iterator variables: i
Python program:
def minimumSubsetDifference ( N ) :
    blockOfSize8 = N // 8
    str = " ABBABAAB "
    subsetDifference = 0
    partition = " "
    while blockOfSize8 != 0 :
        partition = partition + str
        blockOfSize8 = blockOfSize8 - 1
    A = [ ]
    B = [ ]
    for i in range ( N ) :
        if partition [ i ] == ' A ' :
            A . append ( ( i + 1 ) * ( i + 1 ) )
        else :
            B . append ( ( i + 1 ) * ( i + 1 ) )
    print ( subsetDifference )
    for i in A :
        print ( i , end = " ▁ " )
    print ( )
    for i in B :
        print ( i , end = " ▁ " )
N = 8
minimumSubsetDifference ( N )

Index/key variables: i
Accumulator variables: A, B
Iterator variables: i
Python program:
from collections import defaultdict
def findTheGreatestX ( P , Q ) :
    divisiors = defaultdict ( int )
    i = 2
    while i * i <= Q :
        while ( Q % i == 0 and Q > 1 ) :
            Q //= i
            divisiors [ i ] += 1
        i += 1
    if ( Q > 1 ) :
        divisiors [ Q ] += 1
    ans = 0
    for i in divisiors :
        frequency = divisiors [ i ]
        temp = P
        cur = 0
        while ( temp % i == 0 ) :
            temp //= i
            cur += 1
        if ( cur < frequency ) :
            ans = P
            break
        temp = P
        for j in range ( cur , frequency - 1 , - 1 ) :
            temp //= i
        ans = max ( temp , ans )
    print ( ans )
if __name__ == " _ _ main _ _ " :
    P = 10
    Q = 4
    findTheGreatestX ( P , Q )

Index/key variables: Q, i
Accumulator variables: cur, temp
Iterator variables: i, j
Python program:
def checkRearrangements ( mat , N , M ) :
    for i in range ( N ) :
        for j in range ( 1 , M ) :
            if ( mat [ i ] [ 0 ] != mat [ i ] [ j ] ) :
                return " Yes "
    return " No "
def nonZeroXor ( mat , N , M ) :
    res = 0
    for i in range ( N ) :
        res = res ^ mat [ i ] [ 0 ]
    if ( res != 0 ) :
        return " Yes "
    else :
        return checkRearrangements ( mat , N , M )
if __name__ == " _ _ main _ _ " :
    mat = [ [ 1 , 1 , 2 ] , [ 2 , 2 , 2 ] , [ 3 , 3 , 3 ] ]
    N = len ( mat )
    M = len ( mat [ 0 ] )
    print ( nonZeroXor ( mat , N , M ) )

Index/key variables: i, j
Iterator variables: i, j
Python program:
def functionMax ( arr , n ) :
    setBit = [ [ ] for i in range ( 32 ) ]
    for i in range ( n ) :
        for j in range ( 32 ) :
            if ( arr [ i ] & ( 1 << j ) ) :
                setBit [ j ] . append ( i )
    i = 31
    while ( i >= 0 ) :
        if ( len ( setBit [ i ] ) == 1 ) :
            temp = arr [ 0 ]
            arr [ 0 ] = arr [ setBit [ i ] [ 0 ] ]
            arr [ setBit [ i ] [ 0 ] ] = temp
            break
        i -= 1
    maxAnd = arr [ 0 ]
    for i in range ( 1 , n , 1 ) :
        maxAnd = ( maxAnd & ( ~ arr [ i ] ) )
    return maxAnd
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 2 , 4 , 8 , 16 ]
    n = len ( arr )
    print ( functionMax ( arr , n ) )

Index/key variables: i, j
Iterator variables: i, j
Python program:
def nCr ( n , r ) :
    res = 1
    if r > n - r :
        r = n - r
    for i in range ( r ) :
        res *= ( n - i )
        res /= ( i + 1 )
    return res ;
def solve ( n , m , k ) :
    sum = 0 ;
    for i in range ( k + 1 ) :
        sum += nCr ( n , i ) * nCr ( m , k - i )
    return int ( sum )
if __name__ == ' _ _ main _ _ ' :
    n = 3
    m = 2
    k = 2 ;
    print ( solve ( n , m , k ) )

Accumulator variables: res, sum
Iterator variables: i
Python program:
def findMaximumGcd ( n ) :
    max_gcd = 1
    i = 1
    while ( i * i <= n ) :
        if n % i == 0 :
            if ( i > max_gcd ) :
                max_gcd = i
            if ( ( n / i != i ) and ( n / i != n ) and ( ( n / i ) > max_gcd ) ) :
                max_gcd = n / i
        i += 1
    return ( int ( max_gcd ) )
if __name__ == ' _ _ main _ _ ' :
    n = 10
    print ( findMaximumGcd ( n ) )

Accumulator variables: i
Python program:
x = 2000021
v = [ 0 ] * x
def sieve ( ) :
    v [ 1 ] = 1
    for i in range ( 2 , x ) :
        v [ i ] = i
    for i in range ( 4 , x , 2 ) :
        v [ i ] = 2
    i = 3
    while ( i * i < x ) :
        if ( v [ i ] == i ) :
            for j in range ( i * i , x , i ) :
                if ( v [ j ] == j ) :
                    v [ j ] = i
        i += 1
def prime_factors ( n ) :
    s = set ( )
    while ( n != 1 ) :
        s . add ( v [ n ] )
        n = n // v [ n ]
    return len ( s )
def distinctPrimes ( m , k ) :
    result = [ ]
    for i in range ( 14 , m + k ) :
        count = prime_factors ( i )
        if ( count == k ) :
            result . append ( i )
    p = len ( result )
    for index in range ( p - 1 ) :
        element = result [ index ]
        count = 1
        z = index
        while ( z < p - 1 and count <= k and result [ z ] + 1 == result [ z + 1 ] ) :
            count += 1
            z += 1
        if ( count >= k ) :
            print ( element , end = ' ▁ ' )
if __name__ == ' _ _ main _ _ ' :
    sieve ( )
    N = 1000
    K = 3
    distinctPrimes ( N , K )

Index/key variables: i, index, j, n, z
Accumulator variables: count, result, s
Iterator variables: i, index, j
Python program:
import math
def isDNum ( n ) :
    if n < 4 :
        return False
    for k in range ( 2 , n ) :
        numerator = pow ( k , n - 2 ) - k
        hcf = math . gcd ( n , k )
        if ( hcf == 1 and ( numerator % n ) != 0 ) :
            return False
    return True
n = 15
if isDNum ( n ) :
    print ( " Yes " )
else :
    print ( " No " )

Iterator variables: k
Python program:
def Sum ( N ) :
    SumOfPrimeDivisors = [ 0 ] * ( N + 1 )
    for i in range ( 2 , N + 1 ) :
        if ( SumOfPrimeDivisors [ i ] == 0 ) :
            for j in range ( i , N + 1 , i ) :
                SumOfPrimeDivisors [ j ] += i
    return SumOfPrimeDivisors [ N ]
def RuthAaronNumber ( n ) :
    if ( Sum ( n ) == Sum ( n + 1 ) ) :
        return True
    else :
        return False
N = 714
if ( RuthAaronNumber ( N ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Index/key variables: N, i, j
Iterator variables: i, j
Python program:
mod = 1000000007
def linearSum ( n ) :
    return n * ( n + 1 ) // 2 % mod
def rangeSum ( b , a ) :
    return ( linearSum ( b ) - ( linearSum ( a ) ) ) % mod
def totalSum ( n ) :
    result = 0
    i = 1
    while True :
        result += rangeSum ( n // i , n // ( i + 1 ) ) * ( i % mod ) % mod ;
        result %= mod ;
        if i == n :
            break
        i = n // ( n // ( i + 1 ) )
    return result
N = 4
print ( totalSum ( N ) )
N = 12
print ( totalSum ( N ) )

Accumulator variables: result