dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
_MIN = - 2147483648
_MAX = 2147483648
class newNode :
    def __init__ ( self , key ) :
        self . key = key
        self . left = None
        self . right = None
def maxDiffUtil ( t , res ) :
    if ( t == None ) :
        return _MAX , res
    if ( t . left == None and t . right == None ) :
        return t . key , res
    a , res = maxDiffUtil ( t . left , res )
    b , res = maxDiffUtil ( t . right , res )
    val = min ( a , b )
    res = max ( res , t . key - val )
    return min ( val , t . key ) , res
def maxDiff ( root ) :
    res = _MIN
    x , res = maxDiffUtil ( root , res )
    return res
def inorder ( root ) :
    if ( root ) :
        inorder ( root . left )
        prf ( " % d ▁ " , root . key )
        inorder ( root . right )
if __name__ == ' _ _ main _ _ ' :
    root = newNode ( 8 )
    root . left = newNode ( 3 )
    root . left . left = newNode ( 1 )
    root . left . right = newNode ( 6 )
    root . left . right . left = newNode ( 4 )
    root . left . right . right = newNode ( 7 )
    root . right = newNode ( 10 )
    root . right . right = newNode ( 14 )
    root . right . right . left = newNode ( 13 )
    print ( " Maximum ▁ difference ▁ between ▁ a ▁ node ▁ and " , " its ▁ ancestor ▁ is ▁ : " , maxDiff ( root ) )

Class/struct names: newNode
Python program:
cnt = 0
def dfs ( g : list , u : int , parent : int , timeIn : list , timeOut : list ) :
    global cnt
    timeIn [ u ] = cnt
    cnt += 1
    for i in range ( len ( g [ u ] ) ) :
        v = g [ u ] [ i ]
        if v != parent :
            dfs ( g , v , u , timeIn , timeOut )
    timeOut [ u ] = cnt
    cnt += 1
def preProcess ( edges : list , V : int , timeIn : list , timeOut : list ) :
    global cnt
    g = [ [ ] for i in range ( V ) ]
    for i in range ( V - 1 ) :
        u = edges [ i ] [ 0 ]
        v = edges [ i ] [ 1 ]
        g [ u ] . append ( v )
        g [ v ] . append ( u )
    cnt = 0
    dfs ( g , 0 , - 1 , timeIn , timeOut )
def isAncestor ( u : int , v : int , timeIn : list , timeOut : list ) -> str :
    b = timeIn [ u ] <= timeIn [ u ] and timeOut [ v ] <= timeOut [ u ]
    return " yes " if b else " no "
if __name__ == " _ _ main _ _ " :
    edges = [ ( 0 , 1 ) , ( 0 , 2 ) , ( 1 , 3 ) , ( 1 , 4 ) , ( 2 , 5 ) , ( 4 , 6 ) , ( 5 , 7 ) ]
    E = len ( edges )
    V = E + 1
    timeIn = [ 0 ] * V
    timeOut = [ 0 ] * V
    preProcess ( edges , V , timeIn , timeOut )
    u = 1
    v = 6
    print ( isAncestor ( u , v , timeIn , timeOut ) )
    u = 1
    v = 7
    print ( isAncestor ( u , v , timeIn , timeOut ) )

Index/key variables: i, u, v
Iterator variables: i
Python program:
class getNode :
    def __init__ ( self , data ) :
        self . data = data
        self . left = self . right = None
def hasPath ( root , arr , x ) :
    if ( not root ) :
        return False
    arr . append ( root . data )
    if ( root . data == x ) :
        return True
    if ( hasPath ( root . left , arr , x ) or hasPath ( root . right , arr , x ) ) :
        return True
    arr . pop ( - 1 )
    return False
def printPath ( root , x ) :
    arr = [ ]
    if ( hasPath ( root , arr , x ) ) :
        for i in range ( len ( arr ) - 1 ) :
            print ( arr [ i ] , end = " - > " )
        print ( arr [ len ( arr ) - 1 ] )
    else :
        print ( " No ▁ Path " )
if __name__ == ' _ _ main _ _ ' :
    root = getNode ( 1 )
    root . left = getNode ( 2 )
    root . right = getNode ( 3 )
    root . left . left = getNode ( 4 )
    root . left . right = getNode ( 5 )
    root . right . left = getNode ( 6 )
    root . right . right = getNode ( 7 )
    x = 5
    printPath ( root , x )

Index/key variables: i
Iterator variables: i
Class/struct names: getNode
Python program:
class newNode :
    def __init__ ( self , data ) :
        self . data = data
        self . left = None
        self . right = None
def kthAncestorDFS ( root , node , k ) :
    if ( not root ) :
        return None
    if ( root . data == node or ( kthAncestorDFS ( root . left , node , k ) ) or ( kthAncestorDFS ( root . right , node , k ) ) ) :
        if ( k [ 0 ] > 0 ) :
            k [ 0 ] -= 1
        elif ( k [ 0 ] == 0 ) :
            print ( " Kth ▁ ancestor ▁ is : " , root . data )
            return None
        return root
if __name__ == ' _ _ main _ _ ' :
    root = newNode ( 1 )
    root . left = newNode ( 2 )
    root . right = newNode ( 3 )
    root . left . left = newNode ( 4 )
    root . left . right = newNode ( 5 )
    k = [ 2 ]
    node = 5
    parent = kthAncestorDFS ( root , node , k )
    if ( parent ) :
        print ( " - 1" )

Class/struct names: newNode
Python program:
def update ( arr , l , r , val ) :
    arr [ l ] += val
    if r + 1 < len ( arr ) :
        arr [ r + 1 ] -= val
def getElement ( arr , i ) :
    res = 0
    for j in range ( i + 1 ) :
        res += arr [ j ]
    return res
if __name__ == ' _ _ main _ _ ' :
    arr = [ 0 , 0 , 0 , 0 , 0 ]
    n = len ( arr )
    l = 2
    r = 4
    val = 2
    update ( arr , l , r , val )
    index = 4
    print ( " Element ▁ at ▁ index " , index , " is " , getElement ( arr , index ) )
    l = 0
    r = 3
    val = 4
    update ( arr , l , r , val )
    index = 3
    print ( " Element ▁ at ▁ index " , index , " is " , getElement ( arr , index ) )

Index/key variables: j, l
Accumulator variables: res
Iterator variables: j
Python program:
def updateBIT ( BITree , n , index , val ) :
    index = index + 1
    while ( index <= n ) :
        BITree [ index ] += val
        index += index & ( - index )
def constructBITree ( arr , n ) :
    BITree = [ 0 ] * ( n + 1 )
    for i in range ( n ) :
        updateBIT ( BITree , n , i , arr [ i ] )
    return BITree
def getSum ( BITree , index ) :
    sum = 0
    index = index + 1
    while ( index > 0 ) :
        sum += BITree [ index ]
        index -= index & ( - index )
    return sum
def update ( BITree , l , r , n , val ) :
    updateBIT ( BITree , n , l , val )
    updateBIT ( BITree , n , r + 1 , - val )
arr = [ 0 , 0 , 0 , 0 , 0 ]
n = len ( arr )
BITree = constructBITree ( arr , n )
l = 2
r = 4
val = 2
update ( BITree , l , r , n , val )
index = 4
print ( " Element ▁ at ▁ index " , index , " is " , getSum ( BITree , index ) )
l = 0
r = 3
val = 4
update ( BITree , l , r , n , val )
index = 3
print ( " Element ▁ at ▁ index " , index , " is " , getSum ( BITree , index ) )

Index/key variables: i, index
Accumulator variables: sum
Iterator variables: i
Python program:
def printPost ( inn , pre , inStrt , inEnd ) :
    global preIndex , hm
    if ( inStrt > inEnd ) :
        return
    inIndex = hm [ pre [ preIndex ] ]
    preIndex += 1
    printPost ( inn , pre , inStrt , inIndex - 1 )
    printPost ( inn , pre , inIndex + 1 , inEnd )
    print ( inn [ inIndex ] , end = " ▁ " )
def printPostMain ( inn , pre , n ) :
    for i in range ( n ) :
        hm [ inn [ i ] ] = i
    printPost ( inn , pre , 0 , n - 1 )
if __name__ == ' _ _ main _ _ ' :
    hm = { }
    preIndex = 0
    inn = [ 4 , 2 , 5 , 1 , 3 , 6 ]
    pre = [ 1 , 2 , 4 , 5 , 3 , 6 ]
    n = len ( pre )
    printPostMain ( inn , pre , n )

Index/key variables: i, inIndex, preIndex
Iterator variables: i
Python program:
def issafe ( m , n , i , j ) :
    if i < 0 :
        return False
    if j < 0 :
        return False
    if i >= m :
        return False
    if j >= n :
        return False
    return True
def endpoints ( arr , m , n ) :
    i = 0
    j = 0
    current_d = ' r '
    rcd = { ' l ' : ' u ' , ' u ' : ' r ' , ' r ' : ' d ' , ' d ' : ' l ' }
    while issafe ( m , n , i , j ) :
        current_i = i
        current_j = j
        if arr [ i ] [ j ] == 1 :
            move_in = rcd [ current_d ]
            arr [ i ] [ j ] = 0
            if move_in == ' u ' :
                i -= 1
            elif move_in == ' d ' :
                i += 1
            elif move_in == ' l ' :
                j -= 1
            elif move_in == ' r ' :
                j += 1
            current_d = move_in
        else :
            if current_d == ' u ' :
                i -= 1
            elif current_d == ' d ' :
                i += 1
            elif current_d == ' l ' :
                j -= 1
            elif current_d == ' r ' :
                j += 1
    return ( current_i , current_j )
M = 3
N = 5
arr = [ [ 0 , 1 , 1 , 1 , 0 ] , [ 1 , 0 , 1 , 0 , 1 ] , [ 1 , 1 , 1 , 0 , 0 ] , ]
print ( endpoints ( arr , M , N ) )

Index/key variables: current_d, i, j
Python program:
def sumOfTwoPerfectCubes ( N ) :
    cubes = { }
    i = 1
    while i * i * i <= N :
        cubes [ i * i * i ] = i
        i += 1
    for itr in cubes :
        firstNumber = itr
        secondNumber = N - itr
        if secondNumber in cubes :
            print ( " True " , end = " " )
            return
    print ( " False " , end = " " )
N = 28
sumOfTwoPerfectCubes ( N )

Accumulator variables: i
Iterator variables: itr
Python program:
def countSets ( arr , n ) :
    cnt = 0
    maxE = - 1
    for i in range ( n ) :
        if ( maxE < arr [ i ] ) :
            maxE = arr [ i ]
    sieve = [ 0 ] * ( maxE + 1 )
    for i in range ( n ) :
        sieve [ arr [ i ] ] = 1
    for i in range ( 1 , maxE + 1 ) :
        if ( sieve [ i ] != 0 ) :
            for j in range ( i * 2 , maxE + 1 , i ) :
                if ( sieve [ j ] != 0 ) :
                    sieve [ j ] = ( sieve [ j ] + sieve [ i ] ) % 1000000007
    for i in range ( maxE + 1 ) :
        cnt = ( cnt % 1000000007 + sieve [ i ] % 1000000007 ) % 1000000007
    print ( cnt % 1000000007 )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 16 , 18 , 6 , 7 , 2 , 19 , 20 , 9 ]
    N = len ( arr )
    countSets ( arr , N )

Index/key variables: i, j
Iterator variables: i, j
Python program:
def printArray ( arr , N ) :
    print ( * arr )
def modifyArray ( arr , N , Q , cntQuery ) :
    arr1 = [ 0 for i in range ( N + 2 ) ]
    arr2 = [ 0 for i in range ( N + 2 ) ]
    for i in range ( cntQuery ) :
        L = Q [ i ] [ 0 ] + 1
        R = Q [ i ] [ 1 ] + 1
        arr1 [ L ] += 1
        arr1 [ R + 1 ] -= 1
        arr2 [ R + 1 ] -= R - L + 1
    for i in range ( 1 , N + 1 ) :
        arr1 [ i ] += arr1 [ i - 1 ]
    for i in range ( 1 , N + 1 ) :
        arr2 [ i ] += arr2 [ i - 1 ] + arr1 [ i ]
    for i in range ( 1 , N + 1 ) :
        arr [ i - 1 ] = arr2 [ i ]
    printArray ( arr , N )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 0 , 0 , 0 , 0 ]
    N = len ( arr )
    Q = [ [ 1 , 3 ] , [ 0 , 1 ] ]
    cntQuery = len ( Q )
    modifyArray ( arr , N , Q , cntQuery )

Index/key variables: L, i
Iterator variables: i
Python program:
def findProduct ( number_1 , number_2 ) :
    if ( number_1 == None or number_2 == None ) :
        return 0
    else :
        return number_1 * number_2
def calculateProduct ( List , index ) :
    highest = max ( List [ index ] )
    lowest = min ( List [ index ] )
    if ( index + 1 == len ( List ) ) :
        if ( lowest < 0 and highest >= 0 ) :
            return [ highest , lowest ]
        elif ( lowest <= 0 and highest <= 0 ) :
            return [ None , lowest ]
        elif ( lowest >= 0 and highest >= 0 ) :
            return [ highest , None ]
    [ positive , negative ] = calculateProduct ( List , index + 1 )
    highPos = findProduct ( highest , positive )
    highNeg = findProduct ( highest , negative )
    lowPos = findProduct ( lowest , positive )
    lowNeg = findProduct ( lowest , negative )
    if ( lowest < 0 and highest >= 0 ) :
        return [ max ( highPos , lowNeg ) , min ( highNeg , lowPos ) ]
    elif ( lowest <= 0 and highest <= 0 ) :
        return [ lowNeg , lowPos ]
    elif ( lowest >= 0 and highest >= 0 ) :
        return [ max ( lowPos , highPos ) , min ( lowNeg , highNeg ) ]
N = 2
arr = [ [ - 3 , - 4 ] , [ 1 , 2 , - 3 ] ]
positive , negative = calculateProduct ( arr , 0 )
print ( positive )

Index/key variables: index
Python program:
from math import log10
def maxNumTrailNine ( n , d ) :
    res = n
    cntDigits = int ( log10 ( n ) + 1 )
    p10 = 10
    for i in range ( 1 , cntDigits + 1 ) :
        if ( n % p10 >= d ) :
            break
        else :
            res = n - n % p10 - 1
        p10 = p10 * 10
    print ( res )
if __name__ == ' _ _ main _ _ ' :
    n , d = 1025 , 6
    maxNumTrailNine ( n , d )

Iterator variables: i
Python program:
def minChocolates ( a , n ) :
    i , j = 0 , 0
    val , res = 1 , 0
    while ( j < n - 1 ) :
        if ( a [ j ] > a [ j + 1 ] ) :
            j += 1
            continue
        if ( i == j ) :
            res += val
        else :
            res += get_sum ( val , i , j )
        if ( a [ j ] < a [ j + 1 ] ) :
            val += 1
        else :
            val = 1
        j += 1
        i = j
    if ( i == j ) :
        res += val
    else :
        res += get_sum ( val , i , j )
    return res
def get_sum ( peak , start , end ) :
    count = end - start + 1
    peak = max ( peak , count )
    s = peak + ( ( ( count - 1 ) * count ) >> 1 )
    return s
if __name__ == ' _ _ main _ _ ' :
    a = [ 5 , 5 , 4 , 3 , 2 , 1 ]
    n = len ( a )
    print ( ' Minimum ▁ number ▁ of ▁ chocolates ▁ = ' , minChocolates ( a , n ) )

Index/key variables: j
Accumulator variables: res, val
Python program:
def RemoveElemArr ( arr , n , k ) :
    if ( n == 0 or n == 1 ) :
        return arr
    j = 0
    for i in range ( n ) :
        if ( j < k or arr [ i ] > arr [ j - k ] ) :
            arr [ j ] , j = arr [ i ] , j + 1
    while ( len ( arr ) > j ) :
        del arr [ - 1 ]
    return arr
def printArray ( arr ) :
    for i in arr :
        print ( i , end = " ▁ " )
def UtilRemov ( arr , n , k ) :
    arr = RemoveElemArr ( arr , n , k )
    printArray ( arr )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 2 , 2 , 3 , 4 , 4 , 4 , 5 , 5 ]
    k = 2
    n = len ( arr )
    UtilRemov ( arr , n , k )

Index/key variables: i, j
Iterator variables: i
Python program:
def pairs_after_removing ( arr , N ) :
    cntPairs = 0
    mp = { }
    for i in arr :
        mp [ i ] = mp . get ( i , 0 ) + 1
    for element in mp :
        i = element
        cntPairs += mp [ i ] * ( mp [ i ] - 1 ) // 2
    for i in range ( N ) :
        pairs_after_arr_i_removed = cntPairs + 1 - mp [ arr [ i ] ]
        print ( pairs_after_arr_i_removed , end = ' ▁ ' )
    return
if __name__ == ' _ _ main _ _ ' :
    arr = [ 2 , 3 , 4 , 3 , 2 ]
    N = len ( arr )
    pairs_after_removing ( arr , N )

Index/key variables: i
Accumulator variables: cntPairs
Iterator variables: element, i
Python program:
def smallestDivisorGr1 ( N ) :
    for i in range ( sqrt ( N ) ) :
        i += 1
    if ( N % i == 0 ) :
        return i
    return N
def findValOfNWithOperat ( N , K ) :
    if ( N % 2 == 0 ) :
        N += K * 2
    else :
        N += smallestDivisorGr1 ( N ) + ( K - 1 ) * 2
    return N
N = 6
K = 4
print ( findValOfNWithOperat ( N , K ) )

Iterator variables: i
Python program:
from math import gcd
def CntOfSubsetsByPartitioning ( arr , N ) :
    freq = { }
    for i in range ( N ) :
        freq [ arr [ i ] ] = freq . get ( arr [ i ] , 0 ) + 1
    freqGCD = 0
    for i in freq :
        freqGCD = gcd ( freqGCD , freq [ i ] )
    return ( N ) // freqGCD
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 2 , 3 , 4 , 4 , 3 , 2 , 1 ]
    N = len ( arr )
    print ( CntOfSubsetsByPartitioning ( arr , N ) )

Index/key variables: i
Iterator variables: i
Python program:
r , c = 0 , 0 ;
dir = [ [ 1 , 0 ] , [ - 1 , 0 ] , [ 0 , 1 ] , [ 0 , - 1 ] , [ - 1 , - 1 ] , [ - 1 , 1 ] , [ 1 , 1 ] , [ 1 , - 1 ] ] ;
def valid ( i , j ) :
    if ( i >= 0 and j >= 0 and i < r and j < c ) :
        return True ;
    return False ;
def find ( i , j , v ) :
    s = 0 ;
    for k in range ( 8 ) :
        ni = i + dir [ k ] [ 0 ] ;
        nj = j + dir [ k ] [ 1 ] ;
        if ( valid ( ni , nj ) ) :
            s += v [ ni ] [ nj ] ;
    return s ;
def findsumofneighbors ( M ) :
    v = [ [ 0 for i in range ( c ) ] for j in range ( r ) ] ;
    for i in range ( r ) :
        for j in range ( c ) :
            v [ i ] [ j ] = find ( i , j , M ) ;
            print ( v [ i ] [ j ] , end = " ▁ " ) ;
        print ( " " ) ;
if __name__ == ' _ _ main _ _ ' :
    M = [ [ 1 , 4 , 1 ] , [ 2 , 4 , 5 ] , [ 3 , 1 , 2 ] ] ;
    r = len ( M [ 0 ] ) ;
    c = len ( M [ 1 ] ) ;
    findsumofneighbors ( M ) ;

Index/key variables: i, j, k, ni, nj
Accumulator variables: s
Iterator variables: i, j, k
Python program:
mod = 1e9 + 7
T = [ [ 0 for x in range ( 2000 ) ] for y in range ( 2000 ) ]
result = [ [ 0 for x in range ( 2000 ) ] for y in range ( 2000 ) ]
def mul_2 ( K ) :
    temp = [ [ 0 for x in range ( K + 1 ) ] for y in range ( K + 1 ) ]
    for i in range ( 1 , K + 1 ) :
        for j in range ( 1 , K + 1 ) :
            for k in range ( 1 , K + 1 ) :
                temp [ i ] [ j ] = ( ( temp [ i ] [ j ] + ( T [ i ] [ k ] * T [ k ] [ j ] ) % mod ) % mod )
    for i in range ( 1 , K + 1 ) :
        for j in range ( 1 , K + 1 ) :
            T [ i ] [ j ] = temp [ i ] [ j ]
def mul_1 ( K ) :
    temp = [ [ 0 for x in range ( K + 1 ) ] for y in range ( K + 1 ) ]
    for i in range ( 1 , K + 1 ) :
        for j in range ( 1 , K + 1 ) :
            for k in range ( 1 , K + 1 ) :
                temp [ i ] [ j ] = ( ( temp [ i ] [ j ] + ( result [ i ] [ k ] * T [ k ] [ j ] ) % mod ) % mod )
    for i in range ( 1 , K + 1 ) :
        for j in range ( 1 , K + 1 ) :
            result [ i ] [ j ] = temp [ i ] [ j ]
def matrix_pow ( K , n ) :
    for i in range ( 1 , K + 1 ) :
        for j in range ( 1 , K + 1 ) :
            if ( i == j ) :
                result [ i ] [ j ] = 1
    while ( n > 0 ) :
        if ( n % 2 == 1 ) :
            mul_1 ( K )
        mul_2 ( K )
        n //= 2
def NthTerm ( F , C , K , n ) :
    for i in range ( 1 , K + 1 ) :
        T [ i ] [ K ] = C [ K - i ]
    for i in range ( 1 , K + 1 ) :
        T [ i + 1 ] [ i ] = 1
    matrix_pow ( K , n )
    answer = 0
    for i in range ( 1 , K + 1 ) :
        answer += F [ i - 1 ] * result [ i ] [ 1 ]
    print ( int ( answer ) )
if __name__ == " _ _ main _ _ " :
    F = [ 1 , 2 , 3 ]
    C = [ 1 , 1 , 1 ]
    K = 3
    N = 10
    NthTerm ( F , C , K , N )

Index/key variables: K, i, j, k
Accumulator variables: answer, n
Iterator variables: i, j, k
Python program:
import sys
import random
def nthRoot ( A , N ) :
    xPre = random . random ( ) % 10
    eps = 1e-3
    delX = sys . maxsize
    xK = 0
    while ( delX > eps ) :
        xK = ( ( ( N - 1.0 ) * xPre + A / pow ( xPre , N - 1 ) ) / N )
        delX = abs ( xK - xPre )
        xPre = xK
    return xK
def RMNValue ( arr , n , k ) :
    Nth = 0
    mean = 0.0
    root = 0.0
    for i in range ( n ) :
        Nth += pow ( arr [ i ] , k )
    mean = ( Nth // ( n ) )
    root = nthRoot ( mean , k )
    return root
if __name__ == " _ _ main _ _ " :
    arr = [ 10 , 4 , 6 , 8 ]
    N = len ( arr )
    K = 3
    print ( RMNValue ( arr , N , K ) )

Index/key variables: i
Accumulator variables: Nth
Iterator variables: i
Python program:
def addStack ( N1 , N2 ) :
    res = [ ]
    s = 0
    rem = 0
    while ( len ( N1 ) != 0 and len ( N2 ) != 0 ) :
        s = ( rem + N1 [ - 1 ] + N2 [ - 1 ] )
        res . append ( s % 10 )
        rem = s // 10
        N1 . pop ( - 1 )
        N2 . pop ( - 1 )
    while ( len ( N1 ) != 0 ) :
        s = rem + N1 [ - 1 ]
        res . append ( s % 10 )
        rem = s // 10
        N1 . pop ( - 1 )
    while ( len ( N2 ) != 0 ) :
        s = rem + N2 [ - 1 ]
        res . append ( s % 10 )
        rem = s // 10
        N2 . pop ( - 1 )
    while ( rem > 0 ) :
        res . append ( rem )
        rem //= 10
    res = res [ : : - 1 ]
    return res
def display ( res ) :
    s = " "
    for i in res :
        s += str ( i )
    print ( s )
N1 = [ ]
N1 . append ( 5 )
N1 . append ( 8 )
N1 . append ( 7 )
N1 . append ( 4 )
N2 = [ ]
N2 . append ( 2 )
N2 . append ( 1 )
N2 . append ( 3 )
res = addStack ( N1 , N2 )
display ( res )

Accumulator variables: rem, res, s
Iterator variables: i
Python program:
global total_xor
total_xor = 0
def initialize_xor ( arr , n ) :
    global total_xor
    for i in range ( n ) :
        total_xor = total_xor ^ arr [ i ]
def find_xor ( X , Y ) :
    global total_xor
    total_xor = total_xor ^ X
    total_xor = total_xor ^ Y
    print ( total_xor )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 5 , 7 , 8 , 9 ]
    n = len ( arr )
    initialize_xor ( arr , n )
    Q = [ [ 5 , 6 ] , [ 8 , 1 ] ]
    for i in range ( len ( Q ) ) :
        find_xor ( Q [ i ] [ 0 ] , Q [ i ] [ 1 ] )

Index/key variables: i
Iterator variables: i
Python program:
def maxGCD ( N ) :
    i = 2
    while ( i * i <= N ) :
        if ( N % i == 0 ) :
            return N // i
        i += 1
    return 1
N = 33
print ( " Maximum ▁ Possible ▁ GCD ▁ value ▁ is ▁ : ▁ " , maxGCD ( N ) )

Accumulator variables: i
Python program:
import math
def sum1 ( n ) :
    sum1 = 0
    while ( n != 0 ) :
        r = n % 10
        sum1 = sum1 + r
        n = n // 10
    return sum1
def isJunction ( n ) :
    count = 0
    for i in range ( 1 , n + 1 ) :
        if ( i + sum1 ( i ) == n ) :
            count = count + 1
    return count >= 2
if __name__ == ' _ _ main _ _ ' :
    n = 111
    if ( isJunction ( n ) == 1 ) :
        print ( " Yes " )
    else :
        print ( " No " )

Iterator variables: i
Python program:
def digProduct ( n ) :
    product = 1
    while ( n != 0 ) :
        product = product * ( n % 10 )
        n = int ( n / 10 )
    return product
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 = i + 6
    return True
def nextPrime ( N ) :
    if ( N <= 1 ) :
        return 2 ;
    prime = N
    found = False
    while ( not found ) :
        prime = prime + 1
        if ( isPrime ( prime ) ) :
            found = True
    return prime
def isPointerPrime ( n ) :
    if ( isPrime ( n ) and ( n + digProduct ( n ) == nextPrime ( n ) ) ) :
        return True
    else :
        return False
if __name__ == " _ _ main _ _ " :
    N = 23
    if ( isPointerPrime ( N ) ) :
        print ( " Yes " )
    else :
        print ( " No " )

Boolean variables: found
Python program:
def power ( x , y ) :
    if ( y == 0 ) :
        return 1
    if ( y % 2 == 0 ) :
        return ( power ( x , y // 2 ) * power ( x , y // 2 ) )
    return ( x * power ( x , y // 2 ) * power ( x , y // 2 ) )
def isPerfectDigitalInvariant ( x ) :
    fixed_power = 0
    while True :
        fixed_power += 1
        temp = x
        summ = 0
        while ( temp ) :
            r = temp % 10
            summ = summ + power ( r , fixed_power )
            temp = temp // 10
        if ( summ == x ) :
            return ( True )
        if ( summ > x ) :
            return ( False )
N = 4150
if ( isPerfectDigitalInvariant ( N ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Accumulator variables: fixed_power
Python program:
import math
def SieveOfEratosthenes ( n , isPrime ) :
    isPrime [ 0 ] = isPrime [ 1 ] = False
    for i in range ( 2 , n + 1 , 1 ) :
        isPrime [ i ] = True
    p = 2
    while ( p * p <= n ) :
        if ( isPrime [ p ] == True ) :
            for i in range ( p * 2 , n + 1 , p ) :
                isPrime [ i ] = False
        p += 1
def countDigit ( n ) :
    return math . floor ( math . log10 ( n ) + 1 )
def isBrilliant ( n ) :
    flag = 0
    isPrime = [ 0 ] * ( n + 1 )
    SieveOfEratosthenes ( n , isPrime )
    for i in range ( 2 , n , 1 ) :
        x = n // i
        if ( isPrime [ i ] and isPrime [ x ] and x * i == n ) :
            if ( countDigit ( i ) == countDigit ( x ) ) :
                return True
    return False
n = 1711
if ( isBrilliant ( n ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Index/key variables: i, p, x
Iterator variables: i