dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
def count ( n ) :
    cnt = 0
    p = 1
    while ( p <= n ) :
        cnt = cnt + 1
        p *= 2
    return cnt
n = 7
print ( count ( n ) ) ;

Accumulator variables: p
Python program:
def KthMinValAfterMconcatenate ( A , N , M , K ) :
    V = [ ]
    for i in range ( 0 , M ) :
        for j in range ( 0 , N ) :
            V . append ( A [ j ] )
    V . sort ( )
    return V [ K - 1 ]
if __name__ == " _ _ main _ _ " :
    A = [ 3 , 1 , 2 ]
    M , K = 3 , 4
    N = len ( A )
    print ( KthMinValAfterMconcatenate ( A , N , M , K ) )

Index/key variables: j
Accumulator variables: V
Iterator variables: i, j
Python program:
import math
def findMinimum ( n , m ) :
    mini , i = m , 1
    while i * i <= n :
        if n % i == 0 :
            sec = n // i
            if math . gcd ( m , i ) > 1 :
                return i
            elif math . gcd ( sec , m ) > 1 :
                mini = min ( sec , mini )
        i += 1
    if mini == m :
        return - 1
    else :
        return mini
if __name__ == " _ _ main _ _ " :
    n , m = 8 , 10
    print ( findMinimum ( n , m ) )

Accumulator variables: i
Python program:
def nthTerm ( N ) :
    nth = 0
    for i in range ( N , 0 , - 1 ) :
        nth += pow ( i , i )
    return nth
N = 3
print ( nthTerm ( N ) )

Accumulator variables: nth
Iterator variables: i
Python program:
def findMinRemoval ( arr , n ) :
    value = 0
    maximum = 0
    if ( n == 1 ) :
        return 0
    for i in range ( n ) :
        if ( i != 0 and i != n - 1 ) :
            value = value + abs ( arr [ i ] - arr [ i + 1 ] )
            temp = ( abs ( arr [ i ] - arr [ i + 1 ] ) + abs ( arr [ i ] - arr [ i - 1 ] ) - abs ( arr [ i - 1 ] - arr [ i + 1 ] ) )
        elif ( i == 0 ) :
            value = value + abs ( arr [ i ] - arr [ i + 1 ] )
            temp = abs ( arr [ i ] - arr [ i + 1 ] )
        else :
            temp = abs ( arr [ i ] - arr [ i - 1 ] )
        maximum = max ( maximum , temp )
    return ( value - maximum )
if __name__ == " _ _ main _ _ " :
    arr = [ 1 , 5 , 3 , 2 , 10 ]
    n = len ( arr )
    print ( findMinRemoval ( arr , n ) )

Index/key variables: i
Iterator variables: i
Python program:
def permuteDigits ( a : str , b : int ) -> str :
    n = len ( a )
    ans = " "
    for i in range ( n ) :
        temp = set ( list ( a ) )
        if i == 0 :
            temp . discard ( 0 )
        for j in reversed ( list ( temp ) ) :
            s1 = ans + j
            s2 = list ( a ) . copy ( )
            s2 . remove ( j )
            s2 = ' ' . join ( sorted ( list ( s2 ) ) )
            s1 += s2
            if int ( s1 ) <= b :
                ans += j
                a = ' ' . join ( list ( s2 ) )
                break
    return ans
if __name__ == " _ _ main _ _ " :
    a = "123"
    b = 222
    print ( permuteDigits ( a , b ) )

Accumulator variables: ans, s1
Iterator variables: i, j
Python program:
def LucasSum ( N ) :
    Sum = 0
    a = 2
    b = 1
    c = 0
    Sum += a
    while ( b <= N ) :
        Sum += b
        c = a + b
        a = b
        b = c
    return Sum
N = 20
print ( LucasSum ( N ) )

Accumulator variables: Sum
Python program:
def findMinSum ( arr , n ) :
    occ = n - 1
    Sum = 0
    for i in range ( n ) :
        Sum += arr [ i ] * pow ( 2 , occ )
        occ -= 1
    return Sum
arr = [ 1 , 2 , 4 , 5 ]
n = len ( arr )
print ( findMinSum ( arr , n ) )

Index/key variables: i
Accumulator variables: Sum, occ
Iterator variables: i
Python program:
def countNumbers ( X , Y , N ) :
    count = 0 ;
    for i in range ( 1 , N + 1 ) :
        if ( ( i % X == 0 ) and ( i % Y != 0 ) ) :
            count += 1 ;
    return count ;
X = 2 ;
Y = 3 ;
N = 10 ;
print ( countNumbers ( X , Y , N ) ) ;

Accumulator variables: count
Iterator variables: i
Python program:
def parity ( a ) :
    return a % 3
def solve ( array , size ) :
    operations = 0
    for i in range ( 0 , size - 1 ) :
        if parity ( array [ i ] ) == parity ( array [ i + 1 ] ) :
            operations += 1
            if i + 2 < size :
                pari1 = parity ( array [ i ] )
                pari2 = parity ( array [ i + 2 ] )
                if pari1 == pari2 :
                    if pari1 == 0 :
                        array [ i + 1 ] = 1
                    elif pari1 == 1 :
                        array [ i + 1 ] = 0
                    else :
                        array [ i + 1 ] = 1
                else :
                    if ( ( pari1 == 0 and pari2 == 1 ) or ( pari1 == 1 and pari2 == 0 ) ) :
                        array [ i + 1 ] = 2
                    if ( ( pari1 == 1 and pari2 == 2 ) or ( pari1 == 2 and pari2 == 1 ) ) :
                        array [ i + 1 ] = 0
                    if ( ( pari1 == 2 and pari2 == 0 ) and ( pari1 == 0 and pari2 == 2 ) ) :
                        array [ i + 1 ] = 1
    return operations
if __name__ == " _ _ main _ _ " :
    array = [ 2 , 1 , 3 , 0 ]
    size = len ( array )
    print ( solve ( array , size ) )

Index/key variables: i
Accumulator variables: operations
Iterator variables: i
Python program:
def findPrefixCount ( p_arr , arr ) :
    for i in range ( 0 , n ) :
        for j in range ( n - 1 , - 1 , - 1 ) :
            if arr [ i ] [ j ] :
                continue
            if j != n - 1 :
                p_arr [ i ] [ j ] += p_arr [ i ] [ j + 1 ]
            p_arr [ i ] [ j ] += int ( not arr [ i ] [ j ] )
def matrixOrValueOne ( arr ) :
    p_arr = [ [ 0 for i in range ( n ) ] for j in range ( n ) ]
    findPrefixCount ( p_arr , arr )
    count_zero_submatrices = 0
    for j in range ( 0 , n ) :
        i = n - 1
        q = [ ]
        to_sum = 0
        while i >= 0 :
            c = 0
            while ( len ( q ) != 0 and q [ - 1 ] [ 0 ] > p_arr [ i ] [ j ] ) :
                to_sum -= ( ( q [ - 1 ] [ 1 ] + 1 ) * ( q [ - 1 ] [ 0 ] - p_arr [ i ] [ j ] ) )
                c += q . pop ( ) [ 1 ] + 1
            to_sum += p_arr [ i ] [ j ]
            count_zero_submatrices += to_sum
            q . append ( ( p_arr [ i ] [ j ] , c ) )
            i -= 1
    return ( ( n * ( n + 1 ) * n * ( n + 1 ) ) // 4 - count_zero_submatrices )
if __name__ == " _ _ main _ _ " :
    n = 3
    arr = [ [ 0 , 0 , 0 ] , [ 0 , 1 , 0 ] , [ 0 , 0 , 0 ] ]
    print ( matrixOrValueOne ( arr ) )

Index/key variables: i, j
Accumulator variables: c, count_zero_submatrices, q, to_sum
Iterator variables: i, j
Python program:
def submatrixXor ( arr , n ) :
    ans = 0
    for i in range ( 0 , n ) :
        for j in range ( 0 , n ) :
            top_left = ( i + 1 ) * ( j + 1 )
            bottom_right = ( n - i ) * ( n - j )
            if ( top_left % 2 == 1 and bottom_right % 2 == 1 ) :
                ans = ( ans ^ arr [ i ] [ j ] )
    return ans
n = 3
arr = [ [ 6 , 7 , 13 ] , [ 8 , 3 , 4 ] , [ 9 , 7 , 6 ] ]
print ( submatrixXor ( arr , n ) )

Index/key variables: i, j
Iterator variables: i, j
Python program:
import sys
def findDigitalRoot ( num ) :
    sum = sys . maxsize ;
    tempNum = num ;
    while ( sum >= 10 ) :
        sum = 0 ;
        while ( tempNum > 0 ) :
            sum += tempNum % 10 ;
            tempNum //= 10 ;
        tempNum = sum ;
    return sum ;
def findAnswer ( X , N ) :
    counter = 0 ;
    i = 0 ;
    while ( counter < N ) :
        i += 1 ;
        digitalRoot = findDigitalRoot ( i ) ;
        if ( digitalRoot == X ) :
            counter += 1 ;
        if ( counter == N ) :
            print ( i ) ;
            break ;
if __name__ == ' _ _ main _ _ ' :
    X = 1 ;
    N = 3 ;
    findAnswer ( X , N ) ;

Accumulator variables: counter, i, sum, tempNum
Python program:
def count ( N , K , R ) :
    sum = 0
    for i in range ( 1 , N + 1 ) :
        if ( i % K == R ) :
            sum += i
    return sum
if __name__ == ' _ _ main _ _ ' :
    N = 20
    K = 4
    R = 3
    print ( count ( N , K , R ) )

Accumulator variables: sum
Iterator variables: i
Python program:
def getCount ( a , b , c ) :
    count = 0
    for i in range ( 1 , 82 ) :
        cr = b * pow ( i , a ) + c
        tmp = cr
        sm = 0
        while ( tmp ) :
            sm += tmp % 10
            tmp //= 10
        if ( sm == i and cr < 10 ** 9 ) :
            count += 1
    return count
a , b , c = 3 , 2 , 8
print ( getCount ( a , b , c ) )

Accumulator variables: count, sm, tmp
Iterator variables: i
Python program:
def isSpiltPossible ( n , a ) :
    Sum = 0
    c1 = 0
    for i in range ( n ) :
        Sum += a [ i ]
        if ( a [ i ] == 1 ) :
            c1 += 1
    if ( Sum % 2 ) :
        return False
    if ( ( Sum // 2 ) % 2 == 0 ) :
        return True
    if ( c1 > 0 ) :
        return True
    else :
        return False
n = 3
a = [ 1 , 1 , 2 ]
if ( isSpiltPossible ( n , a ) ) :
    print ( " YES " )
else :
    print ( " NO " )

Index/key variables: i
Accumulator variables: Sum, c1
Iterator variables: i
Python program:
def Make_tree ( n , d , k ) :
    if ( d > n - 1 ) :
        print ( " No " )
        return
    deg = [ 0 ] * ( n )
    ans = [ ]
    q = { }
    for i in range ( d ) :
        deg [ i ] += 1
        deg [ i + 1 ] += 1
        if ( deg [ i ] > k or deg [ i + 1 ] > k ) :
            print ( " NO " )
            return
        ans . append ( ( i , i + 1 ) )
    for i in range ( 1 , d ) :
        q [ ( max ( i , d - i ) , i ) ] = 1
    for i in range ( d + 1 , n ) :
        arr = list ( q . keys ( ) )
        while ( len ( q ) > 0 and deg [ arr [ 0 ] [ 1 ] ] == k ) :
            del q [ arr [ 0 ] ]
        if ( len ( q ) == 0 or arr [ 0 ] [ 0 ] == d ) :
            print ( " No " )
            return
        deg [ i ] += 1
        deg [ arr [ 0 ] [ 1 ] ] += 1
        ans . append ( ( i , arr [ 0 ] [ 1 ] ) )
        q [ ( arr [ 0 ] [ 0 ] + 1 , i ) ] = 1
    for i in range ( n - 1 ) :
        print ( ans [ i ] [ 0 ] + 1 , ans [ i ] [ 1 ] + 1 )
if __name__ == ' _ _ main _ _ ' :
    n , d , k = 6 , 3 , 4
    Make_tree ( n , d , k )

Index/key variables: i
Accumulator variables: ans
Iterator variables: i
Python program:
n = 3
def matrixSum ( arr ) :
    sum = 0 ;
    for i in range ( n ) :
        for j in range ( n ) :
            top_left = ( i + 1 ) * ( j + 1 ) ;
            bottom_right = ( n - i ) * ( n - j ) ;
            sum += ( top_left * bottom_right * arr [ i ] [ j ] ) ;
    return sum ;
if __name__ == " _ _ main _ _ " :
    arr = [ [ 1 , 1 , 1 ] , [ 1 , 1 , 1 ] , [ 1 , 1 , 1 ] ] ;
    print ( matrixSum ( arr ) )

Index/key variables: i, j
Accumulator variables: sum
Iterator variables: i, j
Python program:
def maxAND ( L , R ) :
    maximum = L & R
    for i in range ( L , R , 1 ) :
        for j in range ( i + 1 , R + 1 , 1 ) :
            maximum = max ( maximum , ( i & j ) )
    return maximum
if __name__ == ' _ _ main _ _ ' :
    L = 1
    R = 632
    print ( maxAND ( L , R ) )

Iterator variables: i, j
Python program:
def findCount ( arr , n ) :
    countOdd = 0 ;
    for i in range ( n ) :
        if ( arr [ i ] % 2 == 1 ) :
            countOdd += 1 ;
    if ( countOdd % 2 == 0 ) :
        return 1 ;
    else :
        return 0 ;
if __name__ == " _ _ main _ _ " :
    arr = [ 1 , 2 , 3 , 5 , 1 ] ;
    n = len ( arr ) ;
    print ( findCount ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: countOdd
Iterator variables: i
Python program:
def minOperations ( n , a , m ) :
    k = n // m
    val = [ [ ] for i in range ( m ) ]
    for i in range ( 0 , n ) :
        val [ a [ i ] % m ] . append ( i )
    ans = 0
    extra = [ ]
    for i in range ( 0 , 2 * m ) :
        cur = i % m
        while len ( val [ cur ] ) > k :
            elem = val [ cur ] . pop ( )
            extra . append ( ( elem , i ) )
        while ( len ( val [ cur ] ) < k and len ( extra ) > 0 ) :
            elem = extra [ - 1 ] [ 0 ]
            mmod = extra [ - 1 ] [ 1 ]
            extra . pop ( )
            val [ cur ] . append ( elem )
            ans += i - mmod
    return ans
if __name__ == " _ _ main _ _ " :
    m = 3
    a = [ 3 , 2 , 0 , 6 , 10 , 12 ]
    n = len ( a )
    print ( minOperations ( n , a , m ) )

Index/key variables: cur, i
Accumulator variables: ans, extra
Iterator variables: i
Python program:
from math import sqrt ;
N = 100005 ;
isprime = [ True ] * N ;
can = [ False ] * N ;
def SieveOfEratosthenes ( ) :
    for p in range ( 2 , int ( sqrt ( N ) ) + 1 ) :
        if ( isprime [ p ] == True ) :
            for i in range ( p * p , N , p ) :
                isprime [ i ] = False ;
    primes = [ ] ;
    for i in range ( 2 , N ) :
        if ( isprime [ i ] ) :
            primes . append ( i ) ;
    return primes ;
def Prime_Numbers ( n ) :
    primes = SieveOfEratosthenes ( ) ;
    for i in range ( len ( primes ) - 1 ) :
        if ( primes [ i ] + primes [ i + 1 ] + 1 < N ) :
            can [ primes [ i ] + primes [ i + 1 ] + 1 ] = True ;
    ans = 0 ;
    for i in range ( 2 , n + 1 ) :
        if ( can [ i ] and isprime [ i ] ) :
            ans += 1 ;
    return ans ;
if __name__ == " _ _ main _ _ " :
    n = 50 ;
    print ( Prime_Numbers ( n ) ) ;

Index/key variables: i, p
Accumulator variables: ans, primes
Iterator variables: i, p
Python program:
import math as mt
def findAndSum ( arr , n ) :
    Sum = 0
    mul = 1
    for i in range ( 30 ) :
        count_on = 0
        l = 0
        for j in range ( n ) :
            if ( ( arr [ j ] & ( 1 << i ) ) > 0 ) :
                if ( count_on ) :
                    l += 1
                else :
                    count_on = 1
                    l += 1
            elif ( count_on ) :
                Sum += ( ( mul * l * ( l + 1 ) ) // 2 )
                count_on = 0
                l = 0
        if ( count_on ) :
            Sum += ( ( mul * l * ( l + 1 ) ) // 2 )
            count_on = 0
            l = 0
        mul *= 2
    return Sum
arr = [ 7 , 1 , 1 , 5 ]
n = len ( arr )
print ( findAndSum ( arr , n ) )

Index/key variables: j
Accumulator variables: Sum, l, mul
Iterator variables: i, j
Python program:
def getPairs ( a ) :
    count = 0
    for i in range ( len ( a ) ) :
        for j in range ( len ( a ) ) :
            if ( a [ i ] < a [ j ] ) :
                count += 1
    return count
if __name__ == " _ _ main _ _ " :
    a = [ 2 , 4 , 3 , 1 ]
    print ( getPairs ( a ) )

Index/key variables: i, j
Accumulator variables: count
Iterator variables: i, j
Python program:
def isComposite ( n ) :
    if ( n <= 1 ) :
        return False
    if ( n <= 3 ) :
        return False
    if ( n % 2 == 0 or n % 3 == 0 ) :
        return True
    i = 5
    while ( i * i <= n ) :
        if ( n % i == 0 or n % ( i + 2 ) == 0 ) :
            return True
        i = i + 6
    return False
def isDigitSumOne ( nm ) :
    while ( nm > 9 ) :
        sum_digit = 0
        while ( nm != 0 ) :
            digit = nm % 10
            sum_digit = sum_digit + digit
            nm = nm // 10
        nm = sum_digit
    if ( nm == 1 ) :
        return True
    else :
        return False
def printValidNums ( m , n ) :
    for i in range ( m , n + 1 ) :
        if ( isComposite ( i ) and isDigitSumOne ( i ) ) :
            print ( i , end = " ▁ " )
l = 10
r = 100
printValidNums ( m , n )

Iterator variables: i
Python program:
mod = 1000000007
arr = [ 0 ] * ( 1000001 )
def cal_factorial ( ) :
    arr [ 0 ] = 1
    for i in range ( 1 , 1000001 ) :
        arr [ i ] = ( arr [ i - 1 ] * i ) % mod
def mod_exponent ( num , p ) :
    if ( p == 0 ) :
        return 1
    if ( p & 1 ) :
        return ( ( num % mod ) * ( mod_exponent ( ( num * num ) % mod , p // 2 ) ) % mod ) % mod
    elif ( not ( p & 1 ) ) :
        return ( mod_exponent ( ( num * num ) % mod , p // 2 ) ) % mod
def getCount ( x , y ) :
    ans = arr [ x + y - 1 ]
    ans *= mod_exponent ( arr [ x ] , mod - 2 )
    ans %= mod
    ans *= mod_exponent ( arr [ y ] , mod - 2 )
    ans %= mod
    ans *= ( x - y )
    ans %= mod
    return ans
if __name__ == ' _ _ main _ _ ' :
    cal_factorial ( )
    x = 3
    y = 1
    print ( getCount ( x , y ) )

Index/key variables: i, x, y
Iterator variables: i
Python program:
class Data :
    def __init__ ( self , x , y ) :
        self . x = x
        self . y = y
def inv_interpolate ( d : list , n : int , y : float ) -> float :
    x = 0
    for i in range ( n ) :
        xi = d [ i ] . x
        for j in range ( n ) :
            if j != i :
                xi = ( xi * ( y - d [ j ] . y ) / ( d [ i ] . y - d [ j ] . y ) )
        x += xi
    return x
if __name__ == " _ _ main _ _ " :
    d = [ Data ( 1.27 , 2.3 ) , Data ( 2.25 , 2.95 ) , Data ( 2.5 , 3.5 ) , Data ( 3.6 , 5.1 ) ]
    n = 4
    y = 4.5
    print ( " Value ▁ of ▁ x ▁ at ▁ y ▁ = ▁ 4.5 ▁ : " , round ( inv_interpolate ( d , n , y ) , 5 ) )

Index/key variables: i, j
Accumulator variables: x
Iterator variables: i, j
Class/struct names: Data
Python program:
def countTriplets ( n , points ) :
    pts = [ ]
    ct = 0 ;
    for i in range ( n ) :
        pts . append ( points [ i ] ) ;
    for i in range ( n ) :
        for j in range ( i + 1 , n ) :
            x = points [ i ] [ 0 ] + points [ j ] [ 0 ] ;
            y = points [ i ] [ 1 ] + points [ j ] [ 1 ] ;
            if ( x % 2 == 0 and y % 2 == 0 ) :
                if [ x // 2 , y // 2 ] in pts :
                    ct += 1
    return ct
if __name__ == " _ _ main _ _ " :
    points = [ [ 1 , 1 ] , [ 2 , 2 ] , [ 3 , 3 ] ]
    n = len ( points )
    print ( countTriplets ( n , points ) )

Index/key variables: i, j
Accumulator variables: ct, pts
Iterator variables: i, j
Python program:
def mixtureConcentration ( n , p ) :
    res = 0 ;
    for i in range ( n ) :
        res += p [ i ] ;
    res /= n ;
    return res ;
arr = [ 0 , 20 , 20 ] ;
n = len ( arr ) ;
print ( round ( mixtureConcentration ( n , arr ) , 4 ) ) ;

Index/key variables: i
Accumulator variables: res
Iterator variables: i
Python program:
MAX = 100005 ;
MOD = 1000000007
def check ( num , a , b ) :
    while ( num ) :
        rem = num % 10
        num = int ( num / 10 )
        if ( rem != a and rem != b ) :
            return 0
    return 1
def power ( x , y ) :
    ans = 1
    while ( y ) :
        if ( y & 1 ) :
            ans = ( ans * x ) % MOD
        y >>= 1
        x = ( x * x ) % MOD
    return ans % MOD
def modInverse ( x ) :
    return power ( x , MOD - 2 )
def countNumbers ( n , a , b ) :
    fact = [ 0 for i in range ( MAX ) ]
    inv = [ 0 for i in range ( MAX ) ]
    ans = 0
    fact [ 0 ] = 1
    for i in range ( 1 , MAX , 1 ) :
        fact [ i ] = ( 1 * fact [ i - 1 ] * i )
        fact [ i ] %= MOD
    inv [ MAX - 1 ] = modInverse ( fact [ MAX - 1 ] )
    i = MAX - 2
    while ( i >= 0 ) :
        inv [ i ] = ( inv [ i + 1 ] * ( i + 1 ) )
        inv [ i ] %= MOD
        i -= 1
    if ( a < b ) :
        temp = a
        a = b
        b = temp
    for s in range ( n , 9 * n + 1 , 1 ) :
        if ( check ( s , a , b ) == 0 ) :
            continue
        if ( s < n * b or ( s - n * b ) % ( a - b ) != 0 ) :
            continue
        numDig = int ( ( s - n * b ) / ( a - b ) )
        if ( numDig > n ) :
            continue
        curr = fact [ n ]
        curr = ( curr * inv [ numDig ] ) % MOD
        curr = ( curr * inv [ n - numDig ] ) % MOD
        ans = ( ans + curr ) % MOD
    return ans
if __name__ == ' _ _ main _ _ ' :
    n = 3
    a = 1
    b = 3
    print ( countNumbers ( n , a , b ) )

Index/key variables: i, n, numDig
Accumulator variables: y
Iterator variables: i, s
Python program:
def checkTriangularSumRepresentation ( n ) :
    tri = list ( ) ;
    i = 1 ;
    while ( 1 ) :
        x = i * ( i + 1 ) // 2 ;
        if ( x >= n ) :
            break ;
        tri . append ( x ) ;
        i += 1 ;
    for tm in tri :
        if n - tm in tri :
            return True ;
    return False ;
if __name__ == " _ _ main _ _ " :
    n = 24 ;
    if checkTriangularSumRepresentation ( n ) :
        print ( " Yes " )
    else :
        print ( " No " )

Accumulator variables: i, tri
Iterator variables: tm
Python program:
def digitsCount ( n ) :
    length = 0 ;
    while ( n > 0 ) :
        length += 1 ;
        n //= 10 ;
    return length ;
def absoluteFirstLast ( n , x ) :
    i = 0 ;
    mod = 1 ;
    while ( i < x ) :
        mod *= 10 ;
        i += 1 ;
    last = n % mod ;
    length = digitsCount ( n ) ;
    while ( length != x ) :
        n //= 10 ;
        length -= 1 ;
    first = n ;
    return abs ( first - last ) ;
if __name__ == " _ _ main _ _ " :
    n = 21546 ;
    x = 2 ;
    print ( absoluteFirstLast ( n , x ) ) ;

Accumulator variables: i, length, mod, n
Python program:
def make_sequence ( N ) :
    arr = [ 0 ] * ( N + 1 )
    sum = 0
    for i in range ( 1 , N + 1 ) :
        if ( i % 2 == 1 ) :
            arr [ i ] = 1
        else :
            arr [ i ] = 2
        sum += arr [ i ]
    if ( sum % 2 == 1 ) :
        arr [ 2 ] = 3
    for i in range ( 1 , N + 1 ) :
        print ( arr [ i ] , end = " ▁ " )
if __name__ == " _ _ main _ _ " :
    N = 9
    make_sequence ( N )

Index/key variables: i
Accumulator variables: sum
Iterator variables: i
Python program:
def minOperation ( n , k , a ) :
    for i in range ( k , n ) :
        if ( a [ i ] != a [ k - 1 ] ) :
            return - 1
    for i in range ( k - 2 , - 1 , - 1 ) :
        if ( a [ i ] != a [ k - 1 ] ) :
            return i + 1
n = 5
k = 3
a = [ 2 , 1 , 1 , 1 , 1 ]
print ( minOperation ( n , k , a ) )

Index/key variables: i
Iterator variables: i
Python program:
def binomialCoeff ( n , k ) :
    if ( k > n ) :
        return 0
    res = 1
    if ( k > n - k ) :
        k = n - k
    for i in range ( k ) :
        res *= ( n - i )
        res //= ( i + 1 )
    return res
if __name__ == " _ _ main _ _ " :
    N = 5
    M = 1
    P = ( N * ( N - 1 ) ) // 2
    print ( binomialCoeff ( P , M ) )

Accumulator variables: res
Iterator variables: i
Python program:
def generateSequence ( n , g ) :
    for i in range ( 1 , n + 1 ) :
        print ( i * g , end = " ▁ " )
if __name__ == " _ _ main _ _ " :
    n , g = 6 , 5
    generateSequence ( n , g )

Iterator variables: i
Python program:
MAX = 1000
f = [ 0 ] * MAX
def fib ( n ) :
    if ( n == 0 ) :
        return 0
    if ( n == 1 or n == 2 ) :
        f [ n ] = 1
        return f [ n ]
    if ( f [ n ] ) :
        return f [ n ]
    k = ( n + 1 ) // 2 if ( n & 1 ) else n // 2
    if ( n & 1 ) :
        f [ n ] = ( fib ( k ) * fib ( k ) + fib ( k - 1 ) * fib ( k - 1 ) )
    else :
        f [ n ] = ( 2 * fib ( k - 1 ) + fib ( k ) ) * fib ( k )
    return f [ n ]
def gcd ( a , b ) :
    if ( a == 0 ) :
        return b
    return gcd ( b % a , a )
def findLCMFibonacci ( a , b ) :
    return ( fib ( a ) * fib ( b ) ) // fib ( gcd ( a , b ) )
if __name__ == " _ _ main _ _ " :
    a = 3
    b = 12
    print ( findLCMFibonacci ( a , b ) )

Index/key variables: n
Python program:
def trailing_zeros ( N ) :
    count_of_two = 0
    count_of_five = 0
    for i in range ( 1 , N + 1 , 1 ) :
        val = i
        while ( val % 2 == 0 and val > 0 ) :
            val /= 2
            count_of_two += i
        while ( val % 5 == 0 and val > 0 ) :
            val /= 5
            count_of_five += i
    ans = min ( count_of_two , count_of_five )
    return ans
if __name__ == ' _ _ main _ _ ' :
    N = 12
    print ( trailing_zeros ( N ) )

Accumulator variables: count_of_five, count_of_two, val
Iterator variables: i