dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
def findSubArray ( arr , k ) :
    ans = [ ( 0 , 0 ) ]
    sm = 0
    i = 0
    found = 0
    while ( i < k ) :
        sm += arr [ i ]
        i += 1
    if ( sm % 3 == 0 ) :
        ans = [ ( 0 , i - 1 ) ]
        found = 1
    for j in range ( i , len ( arr ) , 1 ) :
        if ( found == 1 ) :
            break
        sm = sm + arr [ j ] - arr [ j - k ]
        if ( sm % 3 == 0 ) :
            ans = [ ( j - k + 1 , j ) ]
            found = 1
    if ( found == 0 ) :
        ans = [ ( - 1 , 0 ) ]
    if ( ans [ 0 ] [ 0 ] == - 1 ) :
        print ( - 1 )
    else :
        for i in range ( ans [ 0 ] [ 0 ] , ans [ 0 ] [ 1 ] + 1 , 1 ) :
            print ( arr [ i ] , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 84 , 23 , 45 , 12 , 56 , 82 ]
    K = 3
    findSubArray ( arr , K )

Index/key variables: i, j
Accumulator variables: sm
Iterator variables: i, j
Python program:
def calculateFact ( fact : list , N : int ) -> None :
    fact [ 0 ] = 1
    for i in range ( 1 , N ) :
        fact [ i ] = fact [ i - 1 ] * i
def nCr ( fact : list , N : int , R : int ) -> int :
    if ( R > N ) :
        return 0
    res = fact [ N ] // fact [ R ]
    res //= fact [ N - R ]
    return res
def countWays ( arr : list , fact : list ) -> int :
    N = len ( arr )
    if ( N <= 2 ) :
        return 1
    leftSubTree = [ ]
    rightSubTree = [ ]
    root = arr [ 0 ]
    for i in range ( 1 , N ) :
        if ( arr [ i ] < root ) :
            leftSubTree . append ( arr [ i ] )
        else :
            rightSubTree . append ( arr [ i ] )
    N1 = len ( leftSubTree )
    N2 = len ( rightSubTree )
    countLeft = countWays ( leftSubTree , fact )
    countRight = countWays ( rightSubTree , fact )
    return ( nCr ( fact , N - 1 , N1 ) * countLeft * countRight )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 3 , 4 , 5 , 1 , 2 ]
    N = len ( arr )
    fact = [ 0 ] * N
    calculateFact ( fact , N )
    print ( countWays ( arr , fact ) )

Index/key variables: N, R, i
Accumulator variables: leftSubTree, rightSubTree
Iterator variables: i
Python program:
def sumOfProd ( arr , N ) :
    sum = 0
    for i in range ( N ) :
        sum += arr [ i ]
    return sum * sum
if __name__ == ' _ _ main _ _ ' :
    arr = [ 2 , 3 , 1 , 5 , 4 ]
    N = len ( arr )
    print ( sumOfProd ( arr , N ) )

Index/key variables: i
Accumulator variables: sum
Iterator variables: i
Python program:
mod = 1e9 + 7
def NthTerm ( F , C , K , n ) :
    ans = [ 0 ] * ( n + 1 )
    i = 0
    while i < K :
        ans [ i ] = F [ i ]
        i += 1
    i = K
    while i <= n :
        j = i - K
        while j < i :
            ans [ i ] += ans [ j ]
            ans [ i ] %= mod
            j += 1
        i += 1
    print ( int ( ans [ n ] ) )
if __name__ == ' _ _ main _ _ ' :
    F = [ 0 , 1 ]
    C = [ 1 , 1 ]
    K = 2
    N = 10
    NthTerm ( F , C , K , N )

Index/key variables: i, j, n
Python program:
def maxDisconnected ( N , E ) :
    curr = 1
    rem = E
    while ( rem > 0 ) :
        rem = rem - min ( curr , rem )
        curr += 1
    if ( curr > 1 ) :
        return N - curr
    else :
        return N
if __name__ == ' _ _ main _ _ ' :
    N = 5
    E = 1
    print ( maxDisconnected ( N , E ) )

Accumulator variables: curr
Python program:
def gcd ( a , b ) :
    if ( a == 0 ) :
        return b ;
    return gcd ( b % a , a ) ;
def findProduct ( N ) :
    result = 1 ;
    for i in range ( 2 , N ) :
        if ( gcd ( i , N ) == 1 ) :
            result *= i ;
    return result ;
if __name__ == ' _ _ main _ _ ' :
    N = 5 ;
    print ( findProduct ( N ) ) ;

Accumulator variables: result
Iterator variables: i
Python program:
def countPairs ( A , B , N , M , List ) :
    count = 0
    par = [ 0 ] * ( N + 1 )
    for i in range ( N + 1 ) :
        par [ i ] = i
    for i in range ( M ) :
        index1 = find ( par , List [ i ] [ 0 ] - 1 )
        index2 = find ( par , List [ i ] [ 1 ] - 1 )
        if ( index1 != index2 ) :
            union ( par , index1 , index2 )
    map = { }
    for i in range ( N ) :
        map [ A [ i ] ] = i
    for i in range ( N ) :
        if ( A [ i ] != B [ i ] ) :
            if ( B [ i ] not in map . keys ( ) ) :
                count += 1
                continue
            j = map [ B [ i ] ]
            if ( find ( par , i ) != find ( par , j ) ) :
                count += 1
    return count
def find ( par , x ) :
    if ( par [ x ] == x ) :
        return x
    else :
        par [ x ] = find ( par , par [ x ] )
        return par [ x ]
def union ( par , a , b ) :
    a = find ( par , a )
    b = find ( par , b )
    if ( a == b ) :
        return
    par [ a ] = b
N = 5
M = 4
A = [ 1 , 5 , 9 , 2 , 3 ]
B = [ 2 , 4 , 5 , 1 , 3 ]
List = [ [ 1 , 4 ] , [ 2 , 3 ] , [ 3 , 5 ] , [ 2 , 5 ] ]
print ( countPairs ( A , B , N , M , List ) )

Index/key variables: a, i, x
Accumulator variables: count
Iterator variables: i
Python program:
def max_valid_triplet ( A , n ) :
    ans = - 1 ;
    for i in range ( 0 , n - 2 ) :
        for j in range ( i + 1 , n - 1 ) :
            for k in range ( j + 1 , n ) :
                if ( A [ i ] < A [ j ] and A [ j ] < A [ k ] ) :
                    value = A [ i ] + A [ j ] * A [ k ] ;
                    if ( value > ans ) :
                        ans = value ;
    print ( ans ) ;
if __name__ == ' _ _ main _ _ ' :
    arr = [ 7 , 9 , 3 , 8 , 11 , 10 ] ;
    n = len ( arr ) ;
    max_valid_triplet ( arr , n ) ;

Index/key variables: i, j, k
Iterator variables: i, j, k
Python program:
mod = 1000000007
ans = [ 1 ] * ( 100002 )
def preCompute ( ) :
    for i in range ( 2 , 100000 // 2 + 1 ) :
        for j in range ( 2 * i , 100001 , i ) :
            ans [ j ] = ( ans [ j ] * i ) % mod
def productOfProperDivi ( num ) :
    return ans [ num ]
if __name__ == " _ _ main _ _ " :
    preCompute ( )
    queries = 5
    a = [ 4 , 6 , 8 , 16 , 36 ]
    for i in range ( queries ) :
        print ( productOfProperDivi ( a [ i ] ) , end = " , ▁ " )

Index/key variables: i, j, num
Iterator variables: i, j
Python program:
def findlcm ( n ) :
    ans = 1 ;
    for i in range ( 1 , n + 1 ) :
        ans = ( ( ( i * ans ) ) // ( __gcd ( i , ans ) ) ) ;
    return ans ;
def highestPower ( n ) :
    lcm = findlcm ( n ) ;
    ans = 0 ;
    for i in range ( 1 , n ) :
        x = int ( pow ( 2 , i ) ) ;
        if ( lcm % x == 0 ) :
            ans = i ;
        if ( x > n ) :
            break ;
    return ans ;
def __gcd ( a , b ) :
    if ( b == 0 ) :
        return a ;
    else :
        return __gcd ( b , a % b ) ;
if __name__ == ' _ _ main _ _ ' :
    n = 15 ;
    print ( highestPower ( n ) ) ;

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 ;
    for i in range ( 5 , int ( n ** 1 / 2 ) , 6 ) :
        if ( n % i == 0 or n % ( i + 2 ) == 0 ) :
            return False ;
    return True ;
def deleteIth ( str , i ) :
    str = str [ 0 : i ] + str [ i + 1 : ] ;
    return str ;
def isPrimePossible ( N ) :
    s = str ( N ) ;
    l = len ( s ) ;
    if ( l < 2 ) :
        return False ;
    for i in range ( l ) :
        str1 = deleteIth ( s , i ) ;
        num = int ( str1 ) ;
        if ( isPrime ( num ) ) :
            return True ;
    return False ;
if __name__ == ' _ _ main _ _ ' :
    N = 610 ;
    if ( isPrimePossible ( N ) ) :
        print ( " Yes " ) ;
    else :
        print ( " No " ) ;

Iterator variables: i
Python program:
def checkFactors ( N ) :
    ev_count = 0 ; od_count = 0 ;
    for i in range ( 1 , int ( pow ( N , 1 / 2 ) ) + 1 ) :
        if ( N % i == 0 ) :
            if ( i == N / i ) :
                if ( i % 2 == 0 ) :
                    ev_count += 1 ;
                else :
                    od_count += 1 ;
            else :
                if ( i % 2 == 0 ) :
                    ev_count += 1 ;
                else :
                    od_count += 1 ;
                if ( ( N / i ) % 2 == 0 ) :
                    ev_count += 1 ;
                else :
                    od_count += 1 ;
    if ( ev_count % 2 == 0 and od_count % 2 == 1 ) :
        print ( " Yes " + " " ) ;
    else :
        print ( " No " + " " ) ;
if __name__ == ' _ _ main _ _ ' :
    N = 36 ;
    checkFactors ( N ) ;

Accumulator variables: ev_count, od_count
Iterator variables: i
Python program:
def gcd ( x , y ) :
    if ( x % y == 0 ) :
        return y
    else :
        return gcd ( y , x % y )
def countPairwiseCoprime ( N , M ) :
    answer = 1
    g = gcd ( N , M )
    temp = g
    for i in range ( 2 , g + 1 ) :
        if i * i > g :
            break
        if ( temp % i == 0 ) :
            answer += 1
            while ( temp % i == 0 ) :
                temp //= i
    if ( temp != 1 ) :
        answer += 1
    return answer
def countCoprimePair ( arr , N ) :
    for i in range ( N ) :
        print ( countPairwiseCoprime ( arr [ i ] [ 0 ] , arr [ i ] [ 1 ] ) , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
    arr = [ [ 12 , 18 ] , [ 420 , 660 ] ]
    N = len ( arr )
    countCoprimePair ( arr , N )

Index/key variables: i
Accumulator variables: answer, temp
Iterator variables: i
Python program:
def getProduct ( a , n ) :
    p = 1
    for i in range ( n ) :
        for j in range ( i + 1 , n ) :
            p *= abs ( a [ i ] - a [ j ] )
    return p
if __name__ == " _ _ main _ _ " :
    arr = [ 1 , 2 , 3 , 4 ]
    N = len ( arr )
    print ( getProduct ( arr , N ) )

Index/key variables: i, j
Accumulator variables: p
Iterator variables: i, j
Python program:
import math
def printt ( N ) :
    for i in range ( 100000 ) :
        if ( pow ( i + 1 , 3 ) - pow ( i , 3 ) == N ) :
            print ( i , ' ' , i + 1 )
            return
def isPerfectSquare ( x ) :
    sr = math . sqrt ( x )
    return ( ( sr - math . floor ( sr ) ) == 0 )
def diffCube ( N ) :
    return isPerfectSquare ( 12 * N - 3 )
N = 19
if ( diffCube ( N ) ) :
    print ( " Yes " )
    printt ( N )
else :
    print ( " No " )

Iterator variables: i
Python program:
def findSum ( arr , n , left , right ) :
    k = right - left + 1
    d = arr [ 1 ] // arr [ 0 ]
    ans = arr [ left - 1 ]
    if d == 1 :
        ans = ans * d * k
    else :
        ans = ans * ( d ** k - 1 ) // ( d - 1 )
    return ans
if __name__ == ' _ _ main _ _ ' :
    arr = [ 2 , 4 , 8 , 16 , 32 , 64 , 128 , 256 ]
    queries = 3
    q = [ [ 2 , 4 ] , [ 2 , 6 ] , [ 5 , 8 ] ]
    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:
from math import *
def modPower ( a , b , M ) :
    res = 1
    while ( b ) :
        if ( b & 1 ) :
            res = res * a % M
        a = a * a % M
        b >>= 1
    return res
def findFirstAndLastM ( N , K , M ) :
    lastM = modPower ( N , K , int ( pow ( 10 , M ) ) )
    firstM = 0
    y = K * log10 ( N * 1.0 )
    y = y - int ( y )
    temp = pow ( 10.0 , y )
    firstM = int ( temp * pow ( 10 , M - 1 ) )
    print ( firstM , lastM )
N = 12
K = 12
M = 4
findFirstAndLastM ( N , K , M )

Accumulator variables: b
Python program:
import sys
from collections import defaultdict
def Find_min ( diff_mod , count_mod , k ) :
    min_oprn = sys . maxsize
    oprn = 0
    for x in range ( k ) :
        oprn = 0
        for w in diff_mod :
            if ( w != x ) :
                if ( w == 0 ) :
                    oprn += ( min ( x , k - x ) * count_mod [ w ] )
                else :
                    oprn += ( min ( abs ( x - w ) , k + x - w ) * count_mod [ w ] )
        if ( oprn < min_oprn ) :
            min_oprn = oprn
    return min_oprn
def Cal_min ( arr , n , k ) :
    diff_mod = set ( [ ] )
    count_mod = defaultdict ( int )
    for i in range ( n ) :
        diff_mod . add ( arr [ i ] % k )
        count_mod [ arr [ i ] % k ] += 1
    return Find_min ( diff_mod , count_mod , k )
if __name__ == " _ _ main _ _ " :
    arr = [ 2 , 35 , 48 , 23 , 52 ]
    n = len ( arr )
    k = 3
    print ( Cal_min ( arr , n , k ) )

Index/key variables: i, w
Accumulator variables: diff_mod, oprn
Iterator variables: i, w, x
Python program:
def gcd ( a , b ) :
    if ( b == 0 ) :
        return a
    return gcd ( b , a % b )
def findlcm ( arr , n ) :
    ans = 1
    for i in range ( 1 , n + 1 ) :
        ans = ( ( arr [ i ] * ans ) // ( gcd ( arr [ i ] , ans ) ) )
    return ans
def minimumSteps ( arr , n ) :
    dat = [ 0 ] * ( n + 1 )
    for i in range ( 1 , n + 1 ) :
        dat [ arr [ i - 1 ] ] = i
    b = [ 0 ] * ( n + 1 )
    j = 0
    for i in range ( 1 , n + 1 ) :
        c = 1
        j = dat [ i ]
        while ( j != i ) :
            c += 1
            j = dat [ j ]
        b [ i ] = c
    print ( findlcm ( b , n ) )
arr = [ 5 , 1 , 4 , 3 , 2 , 7 , 6 ]
N = len ( arr )
minimumSteps ( arr , N )

Index/key variables: i, j
Accumulator variables: c
Iterator variables: i
Python program:
import sys
def maximum ( a , b ) :
    if ( a > b ) :
        return a
    return b
def maxSubarrayRatio ( arr , n ) :
    maxRatio = - sys . maxsize - 1
    for i in range ( n ) :
        for j in range ( i , n ) :
            ratio = arr [ i ]
            for k in range ( i + 1 , j + 1 ) :
                ratio = ratio // arr [ k ]
            maxRatio = maximum ( maxRatio , ratio )
    return int ( maxRatio )
if __name__ == " _ _ main _ _ " :
    arr = [ 2 , 2 , 4 , - 0.2 , - 1 ]
    n = len ( arr )
    print ( maxSubarrayRatio ( arr , n ) )

Index/key variables: i, k
Iterator variables: i, j, k
Python program:
import math
def check ( num ) :
    root = ( int ) ( math . sqrt ( num ) )
    poww = ( int ) ( math . log ( root ) / math . log ( 2 ) )
    if ( num == ( int ) ( pow ( 2 , poww ) * ( pow ( 2 , poww + 1 ) - 1 ) ) ) :
        if ( isPrime ( poww + 1 ) ) :
            if ( isPrime ( ( int ) ( pow ( 2 , poww + 1 ) ) - 1 ) ) :
                print ( " Yes " )
            else :
                print ( " No " )
        else :
            print ( " No " )
    else :
        print ( " No " )
def isPrime ( n ) :
    if ( n <= 1 ) :
        return bool ( False )
    elif ( n == 2 or n == 3 ) :
        return bool ( True )
    else :
        if ( n % 2 == 0 or n % 3 == 0 ) :
            return bool ( False )
        for i in range ( 5 , sqrt ( n + 1 ) + 1 , 6 ) :
            if ( n % i == 0 or n % ( i + 2 ) == 0 ) :
                return bool ( False )
        return bool ( True )
num = 6
check ( num )

Iterator variables: i
Python program:
def isTriplet ( ar , n ) :
    for i in range ( n ) :
        for j in range ( i + 1 , n ) :
            for k in range ( j + 1 , n ) :
                if ( abs ( ar [ i ] - ar [ j ] ) == 1 or abs ( ar [ j ] - ar [ k ] ) == 1 or abs ( ar [ i ] - ar [ k ] ) == 1 ) :
                    x = ar [ i ] * ar [ i ]
                    y = ar [ j ] * ar [ j ]
                    z = ar [ k ] * ar [ k ]
                    if ( x == y + z or y == x + z or z == x + y ) :
                        return True
    return False
if __name__ == ' _ _ main _ _ ' :
    arr = [ 3 , 1 , 4 , 6 , 5 ]
    ar_size = len ( arr )
    if isTriplet ( arr , ar_size ) :
        print ( ' Yes ' )
    else :
        print ( ' No ' )

Index/key variables: i, j, k
Iterator variables: i, j, k
Python program:
from math import sqrt , ceil , floor
def closestDivisors ( n ) :
    for i in range ( ceil ( sqrt ( n + 2 ) ) , - 1 , - 1 ) :
        if ( ( n + 1 ) % i == 0 ) :
            print ( i , " , " , ( n + 1 ) // i )
            break
        if ( ( n + 2 ) % i == 0 ) :
            print ( i , " , " , ( n + 2 ) // i )
            break
if __name__ == ' _ _ main _ _ ' :
    N = 123
    closestDivisors ( N )

Iterator variables: i
Python program:
def count ( n ) :
    phi = [ 0 ] * ( n + 1 )
    divs = [ 0 ] * ( n + 1 )
    for i in range ( 1 , n + 1 ) :
        phi [ i ] += i
        for j in range ( i * 2 , n + 1 , i ) :
            phi [ j ] -= phi [ i ] ;
        for j in range ( i , n + 1 , i ) :
            divs [ j ] += 1
    return ( n - phi [ n ] - divs [ n ] + 1 ) ;
if __name__ == ' _ _ main _ _ ' :
    N = 42
    print ( count ( N ) )

Index/key variables: i, j, n
Iterator variables: i, j
Python program:
def sum_of_differences ( arr , N ) :
    sum = 0
    i = 0
    while ( i < N - 1 ) :
        if arr [ i ] < arr [ i + 1 ] :
            flag = 0
            for j in range ( i + 1 , N - 1 ) :
                if arr [ j ] >= arr [ j + 1 ] :
                    sum += ( arr [ j ] - arr [ i ] )
                    i = j
                    flag = 1
                    break
            if flag == 0 and arr [ i ] < arr [ N - 1 ] :
                sum += ( arr [ N - 1 ] - arr [ i ] )
                break
        i += 1
    return sum
arr = [ 6 , 1 , 2 , 5 , 3 , 4 ]
N = len ( arr )
print ( sum_of_differences ( arr , N ) )

Index/key variables: i, j
Accumulator variables: sum
Iterator variables: j
Python program:
class Node :
    def __init__ ( self , data , left , right ) :
        self . data = data
        self . left = left
        self . right = right
def newNode ( data ) :
    return Node ( data , None , None ) ;
def inorder ( node ) :
    if ( node == None ) :
        return ;
    inorder ( node . left ) ;
    print ( node . data , end = ' ▁ ' ) ;
    inorder ( node . right ) ;
def MaximumBinaryTree ( t1 , t2 ) :
    if ( t1 == None ) :
        return t2 ;
    if ( t2 == None ) :
        return t1 ;
    t1 . data = max ( t1 . data , t2 . data ) ;
    t1 . left = MaximumBinaryTree ( t1 . left , t2 . left ) ;
    t1 . right = MaximumBinaryTree ( t1 . right , t2 . right ) ;
    return t1 ;
if __name__ == ' _ _ main _ _ ' :
    root1 = newNode ( 3 ) ;
    root1 . left = newNode ( 2 ) ;
    root1 . right = newNode ( 6 ) ;
    root1 . left . left = newNode ( 20 ) ;
    root2 = newNode ( 5 ) ;
    root2 . left = newNode ( 1 ) ;
    root2 . right = newNode ( 8 ) ;
    root2 . left . right = newNode ( 2 ) ;
    root2 . right . right = newNode ( 8 ) ;
    root3 = MaximumBinaryTree ( root1 , root2 ) ;
    inorder ( root3 ) ;

Class/struct names: Node
Python program:
from math import sqrt
def MinimumString ( x ) :
    b = 1
    left_lim = sqrt ( x ) + 1.0
    right_lim = sqrt ( x ) + 2.0
    for i in range ( int ( left_lim ) , int ( right_lim ) + 1 ) :
        if ( i > left_lim and i < right_lim ) :
            r = i
            break
    return b + r
if __name__ == ' _ _ main _ _ ' :
    X = 2
    print ( MinimumString ( X ) )

Iterator variables: i
Python program:
from math import sqrt , floor , ceil
def isPerfectSquare ( N ) :
    floorSqrt = floor ( sqrt ( N ) )
    return ( N == floorSqrt * floorSqrt )
def legendreFunction ( N ) :
    while ( N % 4 == 0 ) :
        N //= 4
    if ( N % 8 != 7 ) :
        return True
    else :
        return False
def minSquares ( N ) :
    if ( isPerfectSquare ( N ) ) :
        return 1
    for i in range ( N ) :
        if i * i < N :
            break
        if ( isPerfectSquare ( N - i * i ) ) :
            return 2
    if ( legendreFunction ( N ) ) :
        return 3
    return 4
if __name__ == ' _ _ main _ _ ' :
    N = 123
    print ( minSquares ( N ) )

Accumulator variables: N
Iterator variables: i
Python program:
def is_distinct ( n , k ) :
    s = set ( )
    for i in range ( 1 , k + 1 ) :
        tmp = n % i
        if ( tmp in s ) :
            return False
        s . add ( tmp )
    return True
if __name__ == ' _ _ main _ _ ' :
    N = 5
    K = 3
    if ( is_distinct ( N , K ) ) :
        print ( " Yes " )
    else :
        print ( " No " )

Accumulator variables: s
Iterator variables: i
Python program:
def getDivisors ( min , n ) :
    total = 0
    for i in range ( min , n ) :
        if ( n % i == 0 and n // i >= i ) :
            total += 1
            if ( n // i > i ) :
                total += getDivisors ( i , n // i )
    return total
if __name__ == ' _ _ main _ _ ' :
    n = 30
    print ( 1 + getDivisors ( 2 , n ) )

Accumulator variables: total
Iterator variables: i
Python program:
class newNode :
    def __init__ ( self , val ) :
        self . val = val
        self . next = None
def getLastTwoPerson ( n ) :
    total = n
    head = newNode ( 1 )
    temp = head
    for i in range ( 2 , n + 1 , 1 ) :
        temp . next = newNode ( i )
        temp = temp . next
    temp . next = head
    temp = head
    de = None
    while ( total != 2 ) :
        de = temp . next . next
        temp . next . next = temp . next . next . next
        temp = temp . next
        del de
        total -= 1
    print ( temp . val , temp . next . val )
if __name__ == ' _ _ main _ _ ' :
    n = 2
    getLastTwoPerson ( n )

Accumulator variables: total
Iterator variables: i
Class/struct names: newNode
Python program:
from math import gcd
def findContent ( arr , n ) :
    content = arr [ 0 ]
    for i in range ( 1 , n ) :
        content = gcd ( content , arr [ i ] )
    return content
if __name__ == ' _ _ main _ _ ' :
    n = 3
    arr = [ 9 , 6 , 12 ]
    print ( findContent ( arr , n ) )

Index/key variables: i
Iterator variables: i
Python program:
def inverseEqual ( arr , n ) :
    brr = [ 0 ] * n
    for i in range ( n ) :
        present_index = arr [ i ] - 1
        brr [ present_index ] = i + 1
    for i in range ( n ) :
        if arr [ i ] != brr [ i ] :
            print ( " NO " )
            return
    print ( " YES " )
n = 4
arr = [ 1 , 4 , 3 , 2 ]
inverseEqual ( arr , n )

Index/key variables: i, present_index
Iterator variables: i
Python program:
def linearCongruentialMethod ( Xo , m , a , c , randomNums , noOfRandomNums ) :
    randomNums [ 0 ] = Xo
    for i in range ( 1 , noOfRandomNums ) :
        randomNums [ i ] = ( ( randomNums [ i - 1 ] * a ) + c ) % m
if __name__ == ' _ _ main _ _ ' :
    Xo = 5
    m = 7
    a = 3
    c = 3
    noOfRandomNums = 10
    randomNums = [ 0 ] * ( noOfRandomNums )
    linearCongruentialMethod ( Xo , m , a , c , randomNums , noOfRandomNums )
    for i in randomNums :
        print ( i , end = " ▁ " )

Index/key variables: i
Iterator variables: i
Python program:
def multiplicativeCongruentialMethod ( Xo , m , a , randomNums , noOfRandomNums ) :
    randomNums [ 0 ] = Xo
    for i in range ( 1 , noOfRandomNums ) :
        randomNums [ i ] = ( randomNums [ i - 1 ] * a ) % m
if __name__ == ' _ _ main _ _ ' :
    Xo = 3
    m = 15
    a = 7
    noOfRandomNums = 10
    randomNums = [ 0 ] * ( noOfRandomNums )
    multiplicativeCongruentialMethod ( Xo , m , a , randomNums , noOfRandomNums )
    for i in randomNums :
        print ( i , end = " ▁ " )

Index/key variables: i
Iterator variables: i
Python program:
from collections import defaultdict
MOD = 1000000007
def power ( a , b , m ) :
    a %= m
    res = 1
    while ( b > 0 ) :
        if ( b & 1 ) :
            res = ( ( res % m ) * ( a % m ) ) % m
        a = ( ( a % m ) * ( a % m ) ) % m
        b >>= 1
    return res % m
def productOfDivisors ( p , n ) :
    prime = defaultdict ( int )
    for i in range ( n ) :
        prime [ p [ i ] ] += 1
    product , d = 1 , 1
    for itr in prime . keys ( ) :
        val = ( power ( itr , ( prime [ itr ] ) * ( prime [ itr ] + 1 ) // 2 , MOD ) )
        product = ( power ( product , prime [ itr ] + 1 , MOD ) * power ( val , d , MOD ) % MOD )
        d = ( d * ( prime [ itr ] + 1 ) ) % ( MOD - 1 )
    return product
if __name__ == " _ _ main _ _ " :
    arr = [ 11 , 11 ]
    n = len ( arr )
    print ( productOfDivisors ( arr , n ) )

Index/key variables: i, itr
Accumulator variables: b
Iterator variables: i, itr
Python program:
def SquareRoot ( num ) :
    count = 0
    for n in range ( 1 , num + 1 , 2 ) :
        num = num - n
        count = count + 1
        if ( num == 0 ) :
            break
    return count
N = 81
print ( SquareRoot ( N ) )

Iterator variables: n
Python program:
def gcd ( x , y ) :
    if ( x == 0 ) :
        return y
    return gcd ( y % x , x )
def findDistinct ( arr , n ) :
    maximum = max ( arr )
    if ( n == 1 ) :
        return 1
    if ( n == 2 ) :
        return ( maximum // gcd ( arr [ 0 ] , arr [ 1 ] ) )
    k = gcd ( arr [ 0 ] , arr [ 1 ] )
    for i in range ( 2 , n ) :
        k = gcd ( k , arr [ i ] )
    return ( maximum // k )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 2 , 3 , 5 ]
    n = len ( arr )
    print ( findDistinct ( arr , n ) )

Index/key variables: i
Iterator variables: i