dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
def isFactorial ( n ) :
    i = 1 ;
    while ( True ) :
        if ( n % i == 0 ) :
            n //= i ;
        else :
            break ;
        i += 1 ;
    if ( n == 1 ) :
        return True ;
    else :
        return False ;
if __name__ == " _ _ main _ _ " :
    n = 24 ;
    ans = isFactorial ( n ) ;
    if ( ans == 1 ) :
        print ( " Yes " ) ;
    else :
        print ( " No " ) ;

Accumulator variables: i, n
Python program:
from math import gcd
def lcm ( a , b ) :
    GCD = gcd ( a , b ) ;
    return ( a * b ) // GCD ;
def MinLCM ( a , n ) :
    Prefix = [ 0 ] * ( n + 2 ) ;
    Suffix = [ 0 ] * ( n + 2 ) ;
    Prefix [ 1 ] = a [ 0 ] ;
    for i in range ( 2 , n + 1 ) :
        Prefix [ i ] = lcm ( Prefix [ i - 1 ] , a [ i - 1 ] ) ;
    Suffix [ n ] = a [ n - 1 ] ;
    for i in range ( n - 1 , 0 , - 1 ) :
        Suffix [ i ] = lcm ( Suffix [ i + 1 ] , a [ i - 1 ] ) ;
    ans = min ( Suffix [ 2 ] , Prefix [ n - 1 ] ) ;
    for i in range ( 2 , n ) :
        ans = min ( ans , lcm ( Prefix [ i - 1 ] , Suffix [ i + 1 ] ) ) ;
    return ans ;
if __name__ == " _ _ main _ _ " :
    a = [ 5 , 15 , 9 , 36 ] ;
    n = len ( a ) ;
    print ( MinLCM ( a , n ) ) ;

Index/key variables: i, n
Iterator variables: i
Python program:
def findMinValue ( arr , n ) :
    sum = 0
    for i in range ( n ) :
        sum += arr [ i ]
    return ( sum // n ) + 1
arr = [ 4 , 2 , 1 , 10 , 6 ]
n = len ( arr )
print ( findMinValue ( arr , n ) )

Index/key variables: i
Accumulator variables: sum
Iterator variables: i
Python program:
MOD = 1000000007
def modFact ( n , m ) :
    result = 1
    for i in range ( 1 , m + 1 ) :
        result = ( result * i ) % MOD
    return result
n = 3
m = 2
print ( modFact ( n , m ) )

Iterator variables: i
Python program:
mod = 10 ** 9 + 7
def power ( p ) :
    res = 1
    for i in range ( 1 , p + 1 ) :
        res *= 2
        res %= mod
    return res % mod
def subset_square_sum ( A ) :
    n = len ( A )
    ans = 0
    for i in A :
        ans += i * i % mod
        ans %= mod
    return ans * power ( n - 1 ) % mod
A = [ 3 , 7 ]
print ( subset_square_sum ( A ) )

Accumulator variables: ans, res
Iterator variables: i
Python program:
N = 100050
lpf = [ 0 for i in range ( N ) ]
mobius = [ 0 for i in range ( N ) ]
def least_prime_factor ( ) :
    for i in range ( 2 , N ) :
        if ( lpf [ i ] == 0 ) :
            for j in range ( i , N , i ) :
                if ( lpf [ j ] == 0 ) :
                    lpf [ j ] = i
def Mobius ( ) :
    for i in range ( 1 , N ) :
        if ( i == 1 ) :
            mobius [ i ] = 1
        else :
            if ( lpf [ ( i // lpf [ i ] ) ] == lpf [ i ] ) :
                mobius [ i ] = 0
            else :
                mobius [ i ] = - 1 * mobius [ i // lpf [ i ] ]
def gcd_pairs ( a , n ) :
    maxi = 0
    fre = [ 0 for i in range ( N ) ]
    for i in range ( n ) :
        fre [ a [ i ] ] += 1
        maxi = max ( a [ i ] , maxi )
    least_prime_factor ( )
    Mobius ( )
    ans = 0
    for i in range ( 1 , maxi + 1 ) :
        if ( mobius [ i ] == 0 ) :
            continue
        temp = 0
        for j in range ( i , maxi + 1 , i ) :
            temp += fre [ j ]
        ans += temp * ( temp - 1 ) // 2 * mobius [ i ]
    return ans
a = [ 1 , 2 , 3 , 4 , 5 , 6 ]
n = len ( a )
print ( gcd_pairs ( a , n ) )

Index/key variables: i, j
Accumulator variables: ans, temp
Iterator variables: i, j
Python program:
def ZigZag ( n ) :
    fact = [ 0 for i in range ( n + 1 ) ]
    zig = [ 0 for i in range ( n + 1 ) ]
    fact [ 0 ] = 1
    for i in range ( 1 , n + 1 ) :
        fact [ i ] = fact [ i - 1 ] * i
    zig [ 0 ] = 1
    zig [ 1 ] = 1
    print ( " zig ▁ zag ▁ numbers : ▁ " , end = " ▁ " )
    print ( zig [ 0 ] , zig [ 1 ] , end = " ▁ " )
    for i in range ( 2 , n ) :
        sum = 0
        for k in range ( 0 , i ) :
            sum += ( ( fact [ i - 1 ] // ( fact [ i - 1 - k ] * fact [ k ] ) ) * zig [ k ] * zig [ i - 1 - k ] )
        zig [ i ] = sum // 2
        print ( sum // 2 , end = " ▁ " )
n = 10
ZigZag ( n )

Index/key variables: i, k
Accumulator variables: sum
Iterator variables: i, k
Python program:
def find_count ( ele ) :
    count = 0
    for i in range ( len ( ele ) ) :
        p = [ ]
        c = 0
        j = len ( ele ) - 1
        while j >= ( len ( ele ) - 1 - i ) and j >= 0 :
            p . append ( ele [ j ] )
            j -= 1
        j = len ( ele ) - 1
        k = 0
        while j >= 0 :
            if ele [ j ] != p [ k ] :
                break
            j -= 1
            k += 1
            if k == len ( p ) :
                c += 1
                k = 0
        count = max ( count , c )
    return count
def solve ( n ) :
    count = 1
    ele = [ ]
    for i in range ( n ) :
        print ( count , end = " ▁ " )
        ele . append ( count )
        count = find_count ( ele )
if __name__ == " _ _ main _ _ " :
    n = 10
    solve ( n )

Index/key variables: j, k
Accumulator variables: c, ele, p
Iterator variables: i
Python program:
store = dict ( )
def Wedderburn ( n ) :
    if ( n <= 2 ) :
        return store [ n ]
    elif ( n % 2 == 0 ) :
        x = n // 2
        ans = 0
        for i in range ( 1 , x ) :
            ans += store [ i ] * store [ n - i ]
        ans += ( store [ x ] * ( store [ x ] + 1 ) ) // 2
        store [ n ] = ans
        return ans
    else :
        x = ( n + 1 ) // 2
        ans = 0
        for i in range ( 1 , x ) :
            ans += store [ i ] * store [ n - i ]
        store [ n ] = ans
        return ans
def Wedderburn_Etherington ( n ) :
    store [ 0 ] = 0
    store [ 1 ] = 1
    store [ 2 ] = 1
    for i in range ( n ) :
        print ( Wedderburn ( i ) , end = " " )
        if ( i != n - 1 ) :
            print ( end = " , ▁ " )
n = 10
Wedderburn_Etherington ( n )

Index/key variables: i, n, x
Accumulator variables: ans
Iterator variables: i
Python program:
def Max_sum ( a , n ) :
    pos = 0
    neg = 0
    for i in range ( n ) :
        if ( a [ i ] > 0 ) :
            pos = 1
        elif ( a [ i ] < 0 ) :
            neg = 1
        if ( pos == 1 and neg == 1 ) :
            break
    sum = 0
    if ( pos == 1 and neg == 1 ) :
        for i in range ( n ) :
            sum += abs ( a [ i ] )
    elif ( pos == 1 ) :
        mini = a [ 0 ]
        sum = a [ 0 ]
        for i in range ( 1 , n , 1 ) :
            mini = min ( mini , a [ i ] )
            sum += a [ i ]
        sum -= 2 * mini
    elif ( neg == 1 ) :
        for i in range ( n ) :
            a [ i ] = abs ( a [ i ] )
        mini = a [ 0 ]
        sum = a [ 0 ]
        for i in range ( 1 , n ) :
            mini = min ( mini , a [ i ] )
            sum += a [ i ]
        sum -= 2 * mini
    return sum
if __name__ == ' _ _ main _ _ ' :
    a = [ 1 , 3 , 5 , - 2 , - 6 ]
    n = len ( a )
    print ( Max_sum ( a , n ) )

Index/key variables: i
Accumulator variables: sum
Iterator variables: i
Python program:
def canConvert ( a , b ) :
    while ( b > a ) :
        if ( b % 10 == 1 ) :
            b //= 10 ;
            continue ;
        if ( b % 2 == 0 ) :
            b /= 2 ;
            continue ;
        return false ;
    if ( b == a ) :
        return True ;
    return False ;
if __name__ == " _ _ main _ _ " :
    A = 2 ; B = 82 ;
    if ( canConvert ( A , B ) ) :
        print ( " Yes " ) ;
    else :
        print ( " No " ) ;

Accumulator variables: b
Python program:
def smallestIndex ( a , n ) :
    right1 = 0
    right0 = 0
    for i in range ( n ) :
        if ( a [ i ] == 1 ) :
            right1 = i
        else :
            right0 = i
    return min ( right1 , right0 )
if __name__ == ' _ _ main _ _ ' :
    a = [ 1 , 1 , 1 , 0 , 0 , 1 , 0 , 1 , 1 ]
    n = len ( a )
    print ( smallestIndex ( a , n ) )

Index/key variables: i
Iterator variables: i
Python program:
def countSquares ( r , c , m ) :
    squares = 0
    for i in range ( 1 , 9 ) :
        for j in range ( 1 , 9 ) :
            if ( max ( abs ( i - r ) , abs ( j - c ) ) <= m ) :
                squares = squares + 1
    return squares
r = 4
c = 4
m = 1
print ( countSquares ( r , c , m ) ) ;

Iterator variables: i, j
Python program:
def countQuadruples ( a , n ) :
    mpp = dict . fromkeys ( a , 0 ) ;
    for i in range ( n ) :
        mpp [ a [ i ] ] += 1 ;
    count = 0 ;
    for j in range ( n ) :
        for k in range ( n ) :
            if ( j == k ) :
                continue ;
            mpp [ a [ j ] ] -= 1 ;
            mpp [ a [ k ] ] -= 1 ;
            first = a [ j ] - ( a [ k ] - a [ j ] ) ;
            if first not in mpp :
                mpp [ first ] = 0 ;
            fourth = ( a [ k ] * a [ k ] ) // a [ j ] ;
            if fourth not in mpp :
                mpp [ fourth ] = 0 ;
            if ( ( a [ k ] * a [ k ] ) % a [ j ] == 0 ) :
                if ( a [ j ] != a [ k ] ) :
                    count += mpp [ first ] * mpp [ fourth ] ;
                else :
                    count += ( mpp [ first ] * ( mpp [ fourth ] - 1 ) ) ;
            mpp [ a [ j ] ] += 1 ;
            mpp [ a [ k ] ] += 1 ;
    return count ;
if __name__ == " _ _ main _ _ " :
    a = [ 2 , 6 , 4 , 9 , 2 ] ;
    n = len ( a ) ;
    print ( countQuadruples ( a , n ) ) ;

Index/key variables: first, fourth, i, j, k
Accumulator variables: count
Iterator variables: i, j, k
Python program:
def countNumbers ( L , R , K ) :
    if ( K == 9 ) :
        K = 0
    totalnumbers = R - L + 1
    factor9 = totalnumbers // 9
    rem = totalnumbers % 9
    ans = factor9
    for i in range ( R , R - rem , - 1 ) :
        rem1 = i % 9
        if ( rem1 == K ) :
            ans += 1
    return ans
L = 10
R = 22
K = 3
print ( countNumbers ( L , R , K ) )

Accumulator variables: ans
Iterator variables: i
Python program:
def EvenSum ( A , index , value ) :
    A [ index ] = A [ index ] + value
    sum = 0
    for i in A :
        if ( i % 2 == 0 ) :
            sum = sum + i
    return sum
def BalanceArray ( A , Q ) :
    ANS = [ ]
    i , sum = 0 , 0
    for i in range ( len ( Q ) ) :
        index = Q [ i ] [ 0 ]
        value = Q [ i ] [ 1 ]
        sum = EvenSum ( A , index , value )
        ANS . append ( sum )
    for i in ANS :
        print ( i , end = " ▁ " )
A = [ 1 , 2 , 3 , 4 ]
Q = [ [ 0 , 1 ] , [ 1 , - 3 ] , [ 0 , - 4 ] , [ 3 , 2 ] ]
BalanceArray ( A , Q )

Index/key variables: i, index
Accumulator variables: ANS
Iterator variables: i
Python program:
def BalanceArray ( A , Q ) :
    ANS = [ ]
    sum = 0
    for i in range ( len ( A ) ) :
        if ( A [ i ] % 2 == 0 ) :
            sum += A [ i ] ;
    for i in range ( len ( Q ) ) :
        index = Q [ i ] [ 0 ] ;
        value = Q [ i ] [ 1 ] ;
        if ( A [ index ] % 2 == 0 ) :
            sum -= A [ index ] ;
        A [ index ] += value ;
        if ( A [ index ] % 2 == 0 ) :
            sum += A [ index ] ;
        ANS . append ( sum ) ;
    for i in range ( len ( ANS ) ) :
        print ( ANS [ i ] , end = " ▁ " ) ;
if __name__ == " _ _ main _ _ " :
    A = [ 1 , 2 , 3 , 4 ] ;
    Q = [ [ 0 , 1 ] , [ 1 , - 3 ] , [ 0 , - 4 ] , [ 3 , 2 ] ] ;
    BalanceArray ( A , Q ) ;

Index/key variables: i, index
Accumulator variables: ANS, sum
Iterator variables: i
Python program:
import math as mt
def Cycles ( N ) :
    fact = 1
    result = N - 1
    i = result
    while ( i > 0 ) :
        fact = fact * i
        i -= 1
    return fact // 2
N = 5
Number = Cycles ( N )
print ( " Hamiltonian ▁ cycles ▁ = ▁ " , Number )

Accumulator variables: i
Python program:
def countOdd ( arr , n ) :
    odd = 0 ;
    for i in range ( 0 , n ) :
        if ( arr [ i ] % 2 == 1 ) :
            odd = odd + 1 ;
    return odd ;
def countValidPairs ( arr , n ) :
    odd = countOdd ( arr , n ) ;
    return ( odd * ( odd - 1 ) ) / 2 ;
arr = [ 1 , 2 , 3 , 4 , 5 ] ;
n = len ( arr ) ;
print ( int ( countValidPairs ( arr , n ) ) ) ;

Index/key variables: i
Iterator variables: i
Python program:
def gcd ( a , b ) :
    if ( b == 0 ) :
        return a
    else :
        return gcd ( b , a % b )
def lcmOfArray ( arr , n ) :
    if ( n < 1 ) :
        return 0
    lcm = arr [ 0 ]
    for i in range ( n ) :
        lcm = ( lcm * arr [ i ] ) // gcd ( lcm , arr [ i ] ) ;
    return lcm
def minPerfectCube ( arr , n ) :
    lcm = lcmOfArray ( arr , n )
    minPerfectCube = lcm
    cnt = 0
    while ( lcm > 1 and lcm % 2 == 0 ) :
        cnt += 1
        lcm //= 2
    if ( cnt % 3 == 2 ) :
        minPerfectCube *= 2
    elif ( cnt % 3 == 1 ) :
        minPerfectCube *= 4
    i = 3
    while ( lcm > 1 ) :
        cnt = 0
        while ( lcm % i == 0 ) :
            cnt += 1
            lcm //= i
        if ( cnt % 3 == 1 ) :
            minPerfectCube *= i * i
        elif ( cnt % 3 == 2 ) :
            minPerfectCube *= i
        i += 2
    return minPerfectCube
if __name__ == " _ _ main _ _ " :
    arr = [ 10 , 125 , 14 , 42 , 100 ]
    n = len ( arr )
    print ( minPerfectCube ( arr , n ) )

Index/key variables: i
Accumulator variables: cnt, lcm, minPerfectCube
Iterator variables: i
Python program:
from math import sqrt
def isPrime ( n ) :
    if ( n <= 1 ) :
        return False
    if ( n <= 3 ) :
        return True
    if ( n % 2 == 0 or n % 3 == 0 ) :
        return False
    k = int ( sqrt ( n ) ) + 1
    for i in range ( 5 , k , 6 ) :
        if ( n % i == 0 or n % ( i + 2 ) == 0 ) :
            return False
    return True
def isStrongPrime ( n ) :
    if ( isPrime ( n ) == False or n == 2 ) :
        return False
    previous_prime = n - 1
    next_prime = n + 1
    while ( isPrime ( next_prime ) == False ) :
        next_prime += 1
    while ( isPrime ( previous_prime ) == False ) :
        previous_prime -= 1
    mean = ( previous_prime + next_prime ) / 2
    if ( n > mean ) :
        return True
    else :
        return False
if __name__ == ' _ _ main _ _ ' :
    n = 11
    if ( isStrongPrime ( n ) ) :
        print ( " Yes " )
    else :
        print ( " No " )

Accumulator variables: next_prime, previous_prime
Iterator variables: i
Python program:
def countDigitsToBeRemoved ( N , K ) :
    s = str ( N ) ;
    res = 0 ;
    f_zero = 0 ;
    for i in range ( len ( s ) - 1 , - 1 , - 1 ) :
        if ( K == 0 ) :
            return res ;
        if ( s [ i ] == '0' ) :
            f_zero = 1 ;
            K -= 1 ;
        else :
            res += 1 ;
    if ( K == 0 ) :
        return res ;
    elif ( f_zero > 0 ) :
        return len ( s ) - 1 ;
    return - 1 ;
N = 10904025 ;
K = 2 ;
print ( countDigitsToBeRemoved ( N , K ) ) ;
N = 1000 ;
K = 5 ;
print ( countDigitsToBeRemoved ( N , K ) ) ;
N = 23985 ;
K = 2 ;
print ( countDigitsToBeRemoved ( N , K ) ) ;

Index/key variables: i
Accumulator variables: K, res
Iterator variables: i
Python program:
import math
def getSum ( a , n ) :
    sum = 0 ;
    for i in range ( 1 , n + 1 ) :
        sum += ( i / math . pow ( a , i ) ) ;
    return sum ;
a = 3 ; n = 3 ;
print ( getSum ( a , n ) ) ;

Accumulator variables: sum
Iterator variables: i
Python program:
from math import sqrt
def largestPrimeFactor ( n ) :
    max = - 1
    while n % 2 == 0 :
        max = 2 ;
    for i in range ( 3 , int ( sqrt ( n ) ) + 1 , 2 ) :
        while n % i == 0 :
            max = i ;
            n = n / i ;
    if n > 2 :
        max = n
    return max
def checkUnusual ( n ) :
    factor = largestPrimeFactor ( n )
    if factor > sqrt ( n ) :
        return True
    else :
        return False
if __name__ == ' _ _ main _ _ ' :
    n = 14
    if checkUnusual ( n ) :
        print ( " YES " )
    else :
        print ( " NO " )

Iterator variables: i
Python program:
def isHalfReducible ( arr , n , m ) :
    frequencyHash = [ 0 ] * ( m + 1 ) ;
    i = 0 ;
    while ( i < n ) :
        frequencyHash [ ( arr [ i ] % ( m + 1 ) ) ] += 1 ;
        i += 1 ;
    i = 0 ;
    while ( i <= m ) :
        if ( frequencyHash [ i ] >= ( n / 2 ) ) :
            break ;
        i += 1 ;
    if ( i <= m ) :
        print ( " Yes " ) ;
    else :
        print ( " No " ) ;
arr = [ 8 , 16 , 32 , 3 , 12 ] ;
n = len ( arr ) ;
m = 7 ;
isHalfReducible ( arr , n , m ) ;

Index/key variables: i
Python program:
def arePermutations ( a , b , n , m ) :
    sum1 , sum2 , mul1 , mul2 = 0 , 0 , 1 , 1
    for i in range ( n ) :
        sum1 += a [ i ]
        mul1 *= a [ i ]
    for i in range ( m ) :
        sum2 += b [ i ]
        mul2 *= b [ i ]
    return ( ( sum1 == sum2 ) and ( mul1 == mul2 ) )
if __name__ == " _ _ main _ _ " :
    a = [ 1 , 3 , 2 ]
    b = [ 3 , 1 , 2 ]
    n = len ( a )
    m = len ( b )
    if arePermutations ( a , b , n , m ) :
        print ( " Yes " )
    else :
        print ( " No " )

Index/key variables: i
Accumulator variables: mul1, mul2, sum1, sum2
Iterator variables: i
Python program:
def Time ( arr , n , Emptypipe ) :
    fill = 0
    for i in range ( 0 , n ) :
        fill += ( 1 / arr [ i ] )
    fill = fill - ( 1 / float ( Emptypipe ) )
    return int ( 1 / fill )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 12 , 14 ]
    Emptypipe = 30
    n = len ( arr )
    print ( ( Time ( arr , n , Emptypipe ) ) , " Hours " )

Index/key variables: i
Accumulator variables: fill
Iterator variables: i
Python program:
def check ( n ) :
    sum = 0
    while n != 0 :
        sum += n % 10
        n = n // 10
    if sum % 7 == 0 :
        return 1
    else :
        return 0
if __name__ == " _ _ main _ _ " :
    n = 25
    print ( ( " YES " ) if check ( n ) == 1 else print ( " NO " ) )

Accumulator variables: sum
Python program:
N = 1000005
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 SumOfPrimeDivisors ( n ) :
    sum = 0
    for i in range ( 1 , n + 1 ) :
        if n % i == 0 :
            if isPrime ( i ) :
                sum += i
    return sum
n = 60
print ( " Sum ▁ of ▁ prime ▁ divisors ▁ of ▁ 60 ▁ is ▁ " + str ( SumOfPrimeDivisors ( n ) ) )

Accumulator variables: sum
Iterator variables: i
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 ]
N = 60
print ( " Sum ▁ of ▁ prime " , " divisors ▁ of ▁ 60 ▁ is " , Sum ( N ) ) ;

Index/key variables: N, i, j
Iterator variables: i, j
Python program:
def power ( x , y , p ) :
    x = x % p
    while ( y > 0 ) :
        if ( y & 1 ) :
            res = ( res * x ) % p
        x = ( x * x ) % p
    return res
a = 3
b = "100000000000000000000000000"
remainderB = 0
MOD = 1000000007
for i in range ( len ( b ) ) :
    remainderB = ( ( remainderB * 10 + ord ( b [ i ] ) - 48 ) % ( MOD - 1 ) )
print ( power ( a , remainderB , MOD ) )

Index/key variables: i
Iterator variables: i
Python program:
def find_Square_369 ( num ) :
    if ( num [ 0 ] == '3' ) :
        a = '1'
        b = '0'
        c = '8'
        d = '9'
    elif ( num [ 0 ] == '6' ) :
        a = '4'
        b = '3'
        c = '5'
        d = '6'
    else :
        a = '9'
        b = '8'
        c = '0'
        d = '1'
    result = " "
    size = len ( num )
    for i in range ( 1 , size ) :
        result += a
    result += b
    for i in range ( 1 , size ) :
        result += c
    result += d
    return result
num_3 = "3333"
num_6 = "6666"
num_9 = "9999"
result = " "
result = find_Square_369 ( num_3 )
print ( " Square ▁ of ▁ " + num_3 + " ▁ is ▁ : ▁ " + result ) ;
result = find_Square_369 ( num_6 )
print ( " Square ▁ of ▁ " + num_6 + " ▁ is ▁ : ▁ " + result ) ;
result = find_Square_369 ( num_9 )
print ( " Square ▁ of ▁ " + num_9 + " ▁ is ▁ : ▁ " + result ) ;

Accumulator variables: result
Iterator variables: i
Python program:
if __name__ == ' _ _ main _ _ ' :
    naive_answer = ( ( ( 55555 * 55554 * 55553 * 55552 * 55551 ) // 120 ) % 1000000007 )
    ans = 1
    i = modular_inverse ( 120 , 10000007 )
    for i in range ( 5 ) :
        ans = ( ( ans * ( 55555 - i ) ) % 1000000007 )
    ans = ( ans * i ) % 1000000007
    print ( " Answer ▁ using ▁ naive ▁ method : " , naive_answer )
    print ( " Answer ▁ using ▁ multiplicative " + " modular ▁ inverse ▁ concept : " , ans )

Iterator variables: i
Python program:
ans = 1
mod = 1000000007 * 120
for i in range ( 0 , 5 ) :
    ans = ( ans * ( 55555 - i ) ) % mod
ans = int ( ans / 120 )
print ( " Answer ▁ using ▁ shortcut : ▁ " , ans )

Iterator variables: i
Python program:
def fact ( n ) :
    if ( n == 0 or n == 1 ) :
        return 1 ;
    ans = 1 ;
    for i in range ( 1 , n + 1 ) :
        ans = ans * i ;
    return ans ;
def nCr ( n , r ) :
    Nr = n ; Dr = 1 ; ans = 1 ;
    for i in range ( 1 , r + 1 ) :
        ans = int ( ( ans * Nr ) / ( Dr ) ) ;
        Nr = Nr - 1 ;
        Dr = Dr + 1 ;
    return ans ;
def solve ( n ) :
    N = 2 * n - 2 ;
    R = n - 1 ;
    return ( nCr ( N , R ) * fact ( n - 1 ) ) ;
n = 6 ;
print ( solve ( n ) ) ;

Iterator variables: i
Python program:
def pythagoreanTriplet ( n ) :
    for i in range ( 1 , int ( n / 3 ) + 1 ) :
        for j in range ( i + 1 , int ( n / 2 ) + 1 ) :
            k = n - i - j
            if ( i * i + j * j == k * k ) :
                print ( i , " , ▁ " , j , " , ▁ " , k , sep = " " )
                return
    print ( " No ▁ Triplet " )
n = 12
pythagoreanTriplet ( n )

Iterator variables: i, j
Python program:
def factorial ( n ) :
    f = 1
    for i in range ( 2 , n + 1 ) :
        f *= i
    return f
def series ( A , X , n ) :
    nFact = factorial ( n )
    for i in range ( 0 , n + 1 ) :
        niFact = factorial ( n - i )
        iFact = factorial ( i )
        aPow = pow ( A , n - i )
        xPow = pow ( X , i )
        print ( int ( ( nFact * aPow * xPow ) / ( niFact * iFact ) ) , end = " ▁ " )
A = 3 ; X = 4 ; n = 5
series ( A , X , n )

Accumulator variables: f
Iterator variables: i
Python program:
def seiresSum ( n , a ) :
    res = 0
    for i in range ( 0 , 2 * n ) :
        if ( i % 2 == 0 ) :
            res += a [ i ] * a [ i ]
        else :
            res -= a [ i ] * a [ i ]
    return res
n = 2
a = [ 1 , 2 , 3 , 4 ]
print ( seiresSum ( n , a ) )

Index/key variables: i
Accumulator variables: res
Iterator variables: i
Python program:
def power ( n , r ) :
    count = 0 ; i = r
    while ( ( n / i ) >= 1 ) :
        count += n / i
        i = i * r
    return int ( count )
n = 6 ; r = 3
print ( power ( n , r ) )

Accumulator variables: count
Python program:
def avg_of_odd_num ( n ) :
    sm = 0
    for i in range ( 0 , n ) :
        sm = sm + ( 2 * i + 1 )
    return sm // n
n = 20
print ( avg_of_odd_num ( n ) )

Iterator variables: i
Python program:
def fib ( f , N ) :
    f [ 1 ] = 1
    f [ 2 ] = 1
    for i in range ( 3 , N + 1 ) :
        f [ i ] = f [ i - 1 ] + f [ i - 2 ]
def fiboTriangle ( n ) :
    N = n * ( n + 1 ) // 2
    f = [ 0 ] * ( N + 1 )
    fib ( f , N )
    fiboNum = 1
    for i in range ( 1 , n + 1 ) :
        for j in range ( 1 , i + 1 ) :
            print ( f [ fiboNum ] , " ▁ " , end = " " )
            fiboNum = fiboNum + 1
        print ( )
n = 5
fiboTriangle ( n )

Index/key variables: fiboNum, i
Iterator variables: i, j
Python program:
def TrinomialValue ( n , k ) :
    if n == 0 and k == 0 :
        return 1
    if k < - n or k > n :
        return 0
    return ( TrinomialValue ( n - 1 , k - 1 ) + TrinomialValue ( n - 1 , k ) + TrinomialValue ( n - 1 , k + 1 ) )
def printTrinomial ( n ) :
    for i in range ( n ) :
        for j in range ( - i , 1 ) :
            print ( TrinomialValue ( i , j ) , end = " ▁ " )
        for j in range ( 1 , i + 1 ) :
            print ( TrinomialValue ( i , j ) , end = " ▁ " )
        print ( " " , end = ' ' )
n = 4
printTrinomial ( n )

Iterator variables: i, j