dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
def maxPresum ( a , b ) :
    X = max ( a [ 0 ] , 0 )
    for i in range ( 1 , len ( a ) ) :
        a [ i ] += a [ i - 1 ]
        X = max ( X , a [ i ] )
    Y = max ( b [ 0 ] , 0 )
    for i in range ( 1 , len ( b ) ) :
        b [ i ] += b [ i - 1 ]
        Y = max ( Y , b [ i ] )
    return X + Y
A = [ 2 , - 1 , 4 , - 5 ]
B = [ 4 , - 3 , 12 , 4 , - 3 ]
print ( maxPresum ( A , B ) )

Index/key variables: i
Iterator variables: i
Python program:
import math
def sumOfTwoCubes ( n ) :
    lo = 1
    hi = round ( math . pow ( n , 1 / 3 ) )
    while ( lo <= hi ) :
        curr = ( lo * lo * lo + hi * hi * hi )
        if ( curr == n ) :
            return True
        if ( curr < n ) :
            lo += 1
        else :
            hi -= 1
    return False
N = 28
if ( sumOfTwoCubes ( N ) ) :
    print ( " True " )
else :
    print ( " False " )

Accumulator variables: hi, lo
Python program:
def findNthNumber ( N ) :
    result = 0
    p = 1
    while ( N > 0 ) :
        result += ( p * ( N % 9 ) )
        N = N // 9
        p = p * 10
    return result
if __name__ == ' _ _ main _ _ ' :
    N = 9
    print ( findNthNumber ( N ) )

Accumulator variables: result
Python program:
def sameProductQuadruples ( nums , N ) :
    umap = { } ;
    res = 0 ;
    for i in range ( N ) :
        for j in range ( i + 1 , N ) :
            prod = nums [ i ] * nums [ j ] ;
            if prod in umap :
                res += 8 * umap [ prod ] ;
                umap [ prod ] += 1 ;
            else :
                umap [ prod ] = 1
    print ( res ) ;
if __name__ == " _ _ main _ _ " :
    arr = [ 2 , 3 , 4 , 6 ] ;
    N = len ( arr ) ;
    sameProductQuadruples ( arr , N ) ;

Index/key variables: i, j, prod
Accumulator variables: res
Iterator variables: i, j
Python program:
def isCycleExists ( arr , N ) :
    valley = 0
    for i in range ( 1 , N ) :
        if ( arr [ i ] < arr [ i - 1 ] and arr [ i ] < arr [ i + 1 ] ) :
            print ( " Yes " )
            return
    print ( " No " )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 3 , 2 , 4 , 5 ]
    N = len ( arr )
    isCycleExists ( arr , N )

Index/key variables: i
Iterator variables: i
Python program:
def getMax ( arr , N , K ) :
    for i in range ( 1 , N , 1 ) :
        cur_val = arr [ i ]
        while ( K >= i ) :
            if ( cur_val > 0 ) :
                arr [ 0 ] = arr [ 0 ] + 1
                cur_val = cur_val - 1
                K = K - i
            else :
                break
    print ( arr [ 0 ] )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 0 , 3 , 2 ]
    N = len ( arr )
    K = 5
    getMax ( arr , N , K )

Index/key variables: i
Iterator variables: i
Python program:
def minSwaps ( b ) :
    n = len ( b )
    for i in range ( n ) :
        for j in range ( n ) :
            if ( b [ 0 ] [ 0 ] ^ b [ 0 ] [ j ] ^ b [ i ] [ 0 ] ^ b [ i ] [ j ] ) :
                return - 1
    rowSum = 0
    colSum = 0
    rowSwap = 0
    colSwap = 0
    for i in range ( n ) :
        rowSum += b [ i ] [ 0 ]
        colSum += b [ 0 ] [ i ]
        rowSwap += b [ i ] [ 0 ] == i % 2
        colSwap += b [ 0 ] [ i ] == i % 2
    if ( rowSum != n // 2 and rowSum != ( n + 1 ) // 2 ) :
        return - 1
    if ( colSum != n // 2 and colSum != ( n + 1 ) // 2 ) :
        return - 1
    if ( n % 2 == 1 ) :
        if ( colSwap % 2 ) :
            colSwap = n - colSwap
        if ( rowSwap % 2 ) :
            rowSwap = n - rowSwap
    else :
        colSwap = min ( colSwap , n - colSwap )
        rowSwap = min ( rowSwap , n - rowSwap )
    return ( rowSwap + colSwap ) // 2
if __name__ == " _ _ main _ _ " :
    M = [ [ 0 , 1 , 1 , 0 ] , [ 0 , 1 , 1 , 0 ] , [ 1 , 0 , 0 , 1 ] , [ 1 , 0 , 0 , 1 ] ]
    ans = minSwaps ( M )
    print ( ans )

Index/key variables: i, j
Accumulator variables: colSum, colSwap, rowSum, rowSwap
Iterator variables: i, j
Python program:
mod = 1000000007
def ValOfTheExpression ( n ) :
    global mod
    factorial = [ 0 for i in range ( n + 1 ) ]
    factorial [ 0 ] = 1
    factorial [ 1 ] = 1
    for i in range ( 2 , n + 1 , 1 ) :
        factorial [ i ] = ( ( factorial [ i - 1 ] % mod ) * ( i % mod ) ) % mod
    dp = [ 0 for i in range ( n + 1 ) ]
    dp [ 1 ] = 1
    for i in range ( 2 , n + 1 , 1 ) :
        dp [ i ] = ( ( dp [ i - 1 ] % mod ) * ( factorial [ i ] % mod ) ) % mod
    return dp [ n ]
if __name__ == ' _ _ main _ _ ' :
    n = 4
    print ( ValOfTheExpression ( n ) )

Index/key variables: i, n
Iterator variables: i
Python program:
def minChocolates ( A , N ) :
    B = [ 1 for i in range ( N ) ]
    for i in range ( 1 , N ) :
        if ( A [ i ] > A [ i - 1 ] ) :
            B [ i ] = B [ i - 1 ] + 1
        else :
            B [ i ] = 1
    for i in range ( N - 2 , - 1 , - 1 ) :
        if ( A [ i ] > A [ i + 1 ] ) :
            B [ i ] = max ( B [ i + 1 ] + 1 , B [ i ] )
        else :
            B [ i ] = max ( B [ i ] , 1 )
    sum = 0
    for i in range ( N ) :
        sum += B [ i ]
    print ( sum )
if __name__ == ' _ _ main _ _ ' :
    A = [ 23 , 14 , 15 , 14 , 56 , 29 , 14 ]
    N = len ( A )
    minChocolates ( A , N )

Index/key variables: i
Accumulator variables: sum
Iterator variables: i
Python program:
from math import sqrt , ceil , floor
def constructArrayWithGivenLCM ( N ) :
    newArr = [ ]
    for i in range ( 1 , ceil ( sqrt ( N + 1 ) ) ) :
        if ( N % i == 0 ) :
            newArr . append ( i )
            if ( N // i != i ) :
                newArr . append ( N // i )
    newArr = sorted ( newArr )
    for i in newArr :
        print ( i , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
    N = 12
    constructArrayWithGivenLCM ( N )

Accumulator variables: newArr
Iterator variables: i
Python program:
def getPower ( p ) :
    res = 1
    while ( p ) :
        res *= 5
        p -= 1
    return res
def countNumbersUtil ( N ) :
    count = 0
    digits = [ ]
    while ( N ) :
        digits . append ( N % 10 )
        N //= 10
    digits . reverse ( )
    D = len ( digits )
    for i in range ( 1 , D + 1 , 1 ) :
        res = getPower ( i )
        if ( i == D ) :
            for p in range ( 1 , D + 1 , 1 ) :
                x = digits [ p - 1 ]
                tmp = 0
                if ( p % 2 == 0 ) :
                    tmp = ( ( 5 - ( x // 2 + 1 ) ) * getPower ( D - p ) )
                else :
                    tmp = ( ( 5 - ( x + 1 ) // 2 ) * getPower ( D - p ) )
                res -= tmp
                if ( p % 2 != x % 2 ) :
                    break
        count += res
    return count
def countNumbers ( L , R ) :
    print ( countNumbersUtil ( R ) - countNumbersUtil ( L - 1 ) )
L = 128
R = 162
countNumbers ( L , R )

Accumulator variables: N, count, digits, res
Iterator variables: i, p
Python program:
def alternatingSumOfFirst_N ( N ) :
    alternateSum = 0
    for i in range ( 1 , N + 1 ) :
        if ( i % 2 == 0 ) :
            alternateSum += - i
        else :
            alternateSum += i
    return alternateSum
if __name__ == " _ _ main _ _ " :
    N = 6
    print ( alternatingSumOfFirst_N ( N ) )

Accumulator variables: alternateSum
Iterator variables: i
Python program:
def gcd ( a , b ) :
    if ( a == 0 ) :
        return b ;
    return gcd ( b % a , a ) ;
def findSum ( N ) :
    sum = 0 ;
    for i in range ( 1 , N ) :
        if ( gcd ( i , N ) == 1 ) :
            sum += i ;
    return sum ;
if __name__ == ' _ _ main _ _ ' :
    N = 5 ;
    print ( findSum ( N ) ) ;

Accumulator variables: sum
Iterator variables: i
Python program:
def solve ( arr , n ) :
    mp = { }
    for i in arr :
        mp [ i ] = mp . get ( i , 0 ) + 1
    cnt = 0
    for x in mp :
        cnt += ( ( mp [ x ] ) * ( mp [ x ] - 1 ) // 2 )
    ans = [ 0 ] * n
    for i in range ( n ) :
        ans [ i ] = cnt - ( mp [ arr [ i ] ] - 1 )
    for i in ans :
        print ( i , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 1 , 2 , 1 , 2 ]
    N = len ( arr )
    solve ( arr , N )

Index/key variables: i, x
Accumulator variables: cnt
Iterator variables: i, x
Python program:
def findMode ( a , n ) :
    mp = { }
    max = 0
    mode = 0
    for i in range ( n ) :
        if a [ i ] in mp :
            mp [ a [ i ] ] += 1
        else :
            mp [ a [ i ] ] = 1
        if ( mp [ a [ i ] ] >= max ) :
            max = mp [ a [ i ] ]
            mode = a [ i ]
        print ( mode , end = " ▁ " )
arr = [ 2 , 7 , 3 , 2 , 5 ]
n = len ( arr )
findMode ( arr , n )

Index/key variables: i
Iterator variables: i
Python program:
def modexp ( x , n , m ) :
    if ( n == 0 ) :
        return 1
    else :
        if ( n % 2 == 0 ) :
            return modexp ( ( x * x ) % m , n / 2 , m ) ;
        else :
            return ( x * modexp ( ( x * x ) % m , ( n - 1 ) / 2 , m ) % m )
def modInverse ( x , m ) :
    return modexp ( x , m - 2 , m )
def countNumbers ( N ) :
    m = 1000000007
    factorial = [ 0 for x in range ( 100001 ) ]
    factorial [ 0 ] = 1 ;
    for i in range ( 1 , 100001 ) :
        factorial [ i ] = ( factorial [ i - 1 ] * i ) % m
    count = [ 0 for x in range ( 10 ) ]
    for i in range ( 0 , 10 ) :
        count [ i ] = 0
    length = len ( N )
    for i in range ( 0 , length ) :
        count [ int ( N [ i ] ) ] += 1
    result = factorial [ int ( length ) ]
    for i in range ( 0 , 10 ) :
        result = ( result * modInverse ( factorial [ int ( count [ i ] ) ] , m ) ) % m
    print ( result )
N = "0223" ;
countNumbers ( N )

Index/key variables: i
Iterator variables: i
Python program:
def Kmultiples ( n , k ) :
    a = n
    for i in range ( 1 , k + 1 ) :
        print ( " { } ▁ * ▁ { } ▁ = ▁ { } " . format ( n , i , a ) )
        j = 0
        while ( n >= ( 1 << j ) ) :
            a += n & ( 1 << j )
            j += 1
N = 16
K = 7
Kmultiples ( N , K )

Accumulator variables: a, j
Iterator variables: i
Python program:
def calculateB ( x , y , n ) :
    sx = sum ( x )
    sy = sum ( y )
    sxsy = 0
    sx2 = 0
    for i in range ( n ) :
        sxsy += x [ i ] * y [ i ]
        sx2 += x [ i ] * x [ i ]
    b = ( n * sxsy - sx * sy ) / ( n * sx2 - sx * sx )
    return b
def leastRegLine ( X , Y , n ) :
    b = calculateB ( X , Y , n )
    meanX = int ( sum ( X ) / n )
    meanY = int ( sum ( Y ) / n )
    a = meanY - b * meanX
    print ( " Regression ▁ line : " )
    print ( " Y ▁ = ▁ " , ' % .3f ' % a , " ▁ + ▁ " , ' % .3f ' % b , " * X " , sep = " " )
X = [ 95 , 85 , 80 , 70 , 60 ]
Y = [ 90 , 80 , 70 , 65 , 60 ]
n = len ( X )
leastRegLine ( X , Y , n )

Index/key variables: i
Accumulator variables: sx2, sxsy
Iterator variables: i
Python program:
def countRepeatingDigits ( N ) :
    res = 0
    cnt = [ 0 ] * 10
    while ( N > 0 ) :
        rem = N % 10
        cnt [ rem ] += 1
        N = N // 10
    for i in range ( 10 ) :
        if ( cnt [ i ] > 1 ) :
            res += 1
    return res
N = 12
print ( countRepeatingDigits ( N ) )

Index/key variables: i, rem
Accumulator variables: res
Iterator variables: i
Python program:
def findAandB ( n , k ) :
    flag = 0
    for i in range ( 1 , n ) :
        if str ( i ) . count ( chr ( k + 48 ) ) == 0 and str ( n - i ) . count ( chr ( k + 48 ) ) == 0 :
            print ( i , n - i )
            flag = 1
            break
    if ( flag == 0 ) :
        print ( - 1 )
if __name__ == ' _ _ main _ _ ' :
    N = 100
    K = 0
    findAandB ( N , K )

Iterator variables: i
Python program:
def calculate ( p , q ) :
    mod = 998244353
    expo = 0
    expo = mod - 2
    while ( expo ) :
        if ( expo & 1 ) :
            p = ( p * q ) % mod
        q = ( q * q ) % mod
        expo >>= 1
    return p
if __name__ == ' _ _ main _ _ ' :
    p = 1
    q = 4
    print ( calculate ( p , q ) )

Accumulator variables: expo
Python program:
def MaxSubarrayLength ( arr , n , k ) :
    left = - 1
    sum = 0
    for i in range ( n ) :
        if ( ( arr [ i ] % k ) != 0 ) :
            if ( left == - 1 ) :
                left = i
            right = i
        sum += arr [ i ]
    if ( ( sum % k ) != 0 ) :
        return n
    elif ( left == - 1 ) :
        return - 1
    else :
        prefix_length = left + 1
        suffix_length = n - right
        return n - min ( prefix_length , suffix_length )
if __name__ == " _ _ main _ _ " :
    arr = [ 6 , 3 , 12 , 15 ]
    n = len ( arr )
    K = 3
    print ( MaxSubarrayLength ( arr , n , K ) )

Index/key variables: i
Accumulator variables: sum
Iterator variables: i
Python program:
from collections import defaultdict
def countQuadraples ( N ) :
    cnt = 0
    m = defaultdict ( int )
    for a in range ( 1 , N + 1 ) :
        for b in range ( 1 , N + 1 ) :
            x = a * a + b * b
            m [ x ] += 1
    for c in range ( 1 , N + 1 ) :
        for d in range ( 1 , N + 1 ) :
            x = c * c + d * d
            if x in m :
                cnt += m [ x ]
    return cnt
if __name__ == " _ _ main _ _ " :
    N = 2
    print ( countQuadraples ( N ) )

Index/key variables: x
Accumulator variables: cnt
Iterator variables: a, b, c, d
Python program:
from bisect import bisect_left
def numberOfPairs ( a , b , n ) :
    c = [ 0 for i in range ( n ) ]
    for i in range ( n ) :
        c [ i ] = a [ i ] - b [ i ]
    c = sorted ( c )
    answer = 0
    for i in range ( 1 , n ) :
        if ( c [ i ] <= 0 ) :
            continue
        pos = bisect_left ( c , - c [ i ] + 1 )
        answer += ( i - pos )
    return answer
if __name__ == ' _ _ main _ _ ' :
    n = 5
    a = [ 1 , 2 , 3 , 4 , 5 ]
    b = [ 2 , 5 , 6 , 1 , 9 ]
    print ( numberOfPairs ( a , b , n ) )

Index/key variables: i
Accumulator variables: answer
Iterator variables: i
Python program:
def print_h_index ( arr , N ) :
    ms = [ ]
    for i in range ( N ) :
        ms . append ( arr [ i ] )
        ms . sort ( )
        if ( ms [ 0 ] < len ( ms ) ) :
            ms . pop ( 0 )
        print ( len ( ms ) , end = ' ▁ ' )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 9 , 10 , 7 , 5 , 0 , 10 , 2 , 0 ]
    N = len ( arr )
    print_h_index ( arr , N )

Index/key variables: i
Accumulator variables: ms
Iterator variables: i
Python program:
def findPrimes ( arr , n ) :
    max_val = max ( arr )
    prime = [ True for i in range ( max_val + 1 ) ]
    prime [ 0 ] = False
    prime [ 1 ] = False
    p = 2
    while ( p * p <= max_val ) :
        if ( prime [ p ] == True ) :
            for i in range ( p * 2 , max_val + 1 , p ) :
                prime [ i ] = False
        p += 1
    return prime ;
def nonRepeatingPrimes ( arr , n ) :
    prime = findPrimes ( arr , n ) ;
    mp = dict ( )
    for i in range ( n ) :
        if ( prime [ arr [ i ] ] ) :
            if ( arr [ i ] in mp ) :
                mp [ arr [ i ] ] += 1
            else :
                mp [ arr [ i ] ] = 1
    for entry in mp . keys ( ) :
        if ( mp [ entry ] == 1 ) :
            print ( entry ) ;
if __name__ == ' _ _ main _ _ ' :
    arr = [ 2 , 3 , 4 , 6 , 7 , 9 , 7 , 23 , 21 , 3 ]
    n = len ( arr )
    nonRepeatingPrimes ( arr , n ) ;

Index/key variables: entry, i, p
Iterator variables: entry, i
Python program:
def prefixProduct ( a , n ) :
    for i in range ( 1 , n ) :
        a [ i ] = a [ i ] * a [ i - 1 ] ;
    for j in range ( 0 , n ) :
        print ( a [ j ] , end = " , ▁ " ) ;
    return 0 ;
arr = [ 2 , 4 , 6 , 5 , 10 ] ;
N = len ( arr ) ;
prefixProduct ( arr , N ) ;

Index/key variables: i, j
Iterator variables: i, j
Python program:
def countWays ( N ) :
    if ( N < 4 ) :
        return 0
    ans = ( ( N - 1 ) * ( N - 2 ) ) // 2
    s = 0
    for i in range ( 2 , N - 2 , 1 ) :
        for j in range ( 1 , i , 1 ) :
            if ( N == 2 * i + j ) :
                s += 1
    if ( N % 3 == 0 ) :
        s = 3 * s + 1
    else :
        s = 3 * s
    return ans - s
N = 10
print ( countWays ( N ) )

Accumulator variables: s
Iterator variables: i, j
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
    i = 5
    while ( i * i <= n ) :
        if ( n % i == 0 or n % ( i + 2 ) == 0 ) :
            return False
        i = i + 6
    return True
def isMagnanimous ( N ) :
    s = str ( N )
    l = len ( s )
    if ( l < 2 ) :
        return False
    for i in range ( l - 1 ) :
        left = s [ 0 : i + 1 ]
        right = s [ i + 1 : ]
        x = int ( left )
        y = int ( right )
        if ( not isPrime ( x + y ) ) :
            return False
    return True
N = 12
if isMagnanimous ( N ) :
    print ( " Yes " )
else :
    print ( " No " )

Iterator variables: i
Python program:
limit = 10000000
position = [ 0 ] * ( limit + 1 )
def sieve ( ) :
    position [ 0 ] = - 1
    position [ 1 ] = - 1
    pos = 0
    for i in range ( 2 , limit + 1 ) :
        if ( position [ i ] == 0 ) :
            pos += 1
            position [ i ] = pos
            for j in range ( i * 2 , limit + 1 , i ) :
                position [ j ] = - 1
def getSum ( n ) :
    Sum = 0
    while ( n != 0 ) :
        Sum = Sum + n % 10
        n = n // 10
    return Sum
def isHonakerPrime ( n ) :
    pos = position [ n ]
    if ( pos == - 1 ) :
        return False
    return bool ( getSum ( n ) == getSum ( pos ) )
sieve ( )
N = 121
if ( isHonakerPrime ( N ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Index/key variables: i, j, n
Accumulator variables: pos
Iterator variables: i, j
Python program:
import math
def isPrime ( n ) :
    if ( n <= 1 ) :
        return False ;
    for i in range ( 2 , ( int ) ( math . sqrt ( n ) ) + 1 ) :
        if ( n % i == 0 ) :
            return False ;
    return True ;
def takeSum ( a ) :
    s = 0
    for i in range ( 0 , 4 ) :
        for j in range ( 0 , 5 ) :
            s += a [ i ] [ j ]
    return s ;
a = [ [ 1 , 2 , 3 , 4 , 2 ] , [ 0 , 1 , 2 , 3 , 34 ] , [ 0 , 34 , 21 , 12 , 12 ] , [ 1 , 2 , 3 , 6 , 6 ] ] ;
sum = takeSum ( a ) ;
if ( isPrime ( sum ) ) :
    print ( " YES " )
else :
    print ( " NO " )

Index/key variables: i, j
Accumulator variables: s
Iterator variables: i, j
Python program:
def sumOfSumSeries ( N ) :
    _sum = 0
    for i in range ( N + 1 ) :
        _sum = _sum + ( i * ( i + 1 ) ) // 2
    return _sum
N = 5
print ( sumOfSumSeries ( N ) )

Iterator variables: i
Python program:
def isContaindigit ( n ) :
    temp = str ( n )
    for i in temp :
        if i not in [ '0' , '1' , '8' ] :
            return False
    return True
def ispalindrome ( n ) :
    temp = str ( n )
    if temp == temp [ : : - 1 ] :
        return True
    return False
def isTetradic ( n ) :
    if ispalindrome ( n ) :
        if isContaindigit ( n ) :
            return True
    return False
def printTetradicPrimesLessThanN ( n ) :
    prime = [ True ] * ( n + 1 ) ;
    p = 2 ;
    while ( p * p <= n ) :
        if ( prime [ p ] ) :
            for i in range ( p * 2 , n + 1 , p ) :
                prime [ i ] = False ;
        p += 1 ;
    for p in range ( 2 , n + 1 ) :
        if ( prime [ p ] and isTetradic ( p ) ) :
            print ( p , end = " ▁ " ) ;
n = 1000 ;
printTetradicPrimesLessThanN ( n ) ;

Index/key variables: i, p
Iterator variables: i, p
Python program:
def concat ( a , b ) :
    s1 = str ( a )
    s2 = str ( b )
    s = s1 + s2
    c = int ( s )
    return c
def isAstonishing ( n ) :
    for i in range ( n ) :
        sum = 0
        for j in range ( i , n ) :
            sum += j
            if ( sum == n ) :
                concatenation = concat ( i , j )
                if ( concatenation == n ) :
                    return True
    return False
n = 429
if ( isAstonishing ( n ) ) :
    print ( ' Yes ' )
else :
    print ( ' No ' )

Accumulator variables: sum
Iterator variables: i, j
Python program:
def checkSame ( n , b ) :
    m = { }
    while ( n != 0 ) :
        r = n % b
        n = n // b
        if r in m :
            m [ r ] += 1
        else :
            m [ r ] = 1
    last = - 1
    for i in m :
        if last != - 1 and m [ i ] != last :
            return False
        else :
            last = m [ i ]
    return True
n = 9
base = 2
if ( checkSame ( n , base ) ) :
    print ( " Yes " )
else :
    print ( " NO " )

Index/key variables: i, r
Iterator variables: i
Python program:
def seriesSum ( n ) :
    sum1 = 0 ;
    currProd = 1 ;
    currSum = 1 ;
    for i in range ( 2 , n + 1 ) :
        currProd *= i ;
        currSum += i ;
        sum1 += currProd - currSum ;
    return sum1 ;
N = 5 ;
print ( seriesSum ( N ) , end = " ▁ " ) ;

Accumulator variables: currProd, currSum, sum1
Iterator variables: i
Python program:
def count ( a , n ) :
    countElements = 0
    for i in range ( n ) :
        flag = True
        for j in range ( n ) :
            if ( i == j ) :
                continue
            if ( a [ i ] % a [ j ] == 0 ) :
                flag = False
                break
        if ( flag == True ) :
            countElements += 1
    return countElements
if __name__ == " _ _ main _ _ " :
    arr = [ 86 , 45 , 18 , 4 , 8 , 28 , 19 , 33 , 2 ]
    n = len ( arr )
    print ( count ( arr , n ) )

Index/key variables: i, j
Accumulator variables: countElements
Iterator variables: i, j
Boolean variables: flag
Python program:
def CountPairs ( arr , n ) :
    count = 0
    for i in range ( n ) :
        for j in range ( i + 1 , n ) :
            if ( arr [ i ] % 2 == 0 or arr [ j ] % 2 == 0 ) :
                count += 1
    return count
arr = [ 8 , 2 , 3 , 1 , 4 , 2 ]
n = len ( arr )
print ( CountPairs ( arr , n ) )

Index/key variables: i, j
Accumulator variables: count
Iterator variables: i, j
Python program:
import math
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 += 6
    return False
def isGiugaNum ( n ) :
    if ( not ( isComposite ( n ) ) ) :
        return False
    N = n
    while ( n % 2 == 0 ) :
        if ( ( int ( N / 2 ) - 1 ) % 2 != 0 ) :
            return False
        n = int ( n / 2 )
    for i in range ( 3 , int ( math . sqrt ( n ) ) + 1 , 2 ) :
        while ( n % i == 0 ) :
            if ( ( int ( N / i ) - 1 ) % i != 0 ) :
                return False
            n = int ( n / i )
    if ( n > 2 ) :
        if ( ( int ( N / n ) - 1 ) % n != 0 ) :
            return False
    return True
n = 30
if ( isGiugaNum ( n ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Iterator variables: i
Python program:
import math ;
def isDroll ( n ) :
    if ( n == 1 ) :
        return False ;
    sum_even = 0 ;
    sum_odd = 0 ;
    while ( n % 2 == 0 ) :
        sum_even += 2 ;
        n = n // 2 ;
    for i in range ( 3 , int ( math . sqrt ( n ) ) + 1 , 2 ) :
        while ( n % i == 0 ) :
            sum_odd += i ;
            n = n // i ;
    if ( n > 2 ) :
        sum_odd += n ;
    return sum_even == sum_odd ;
N = 72 ;
if ( isDroll ( N ) ) :
    print ( " Yes " ) ;
else :
    print ( " No " ) ;

Accumulator variables: sum_even, sum_odd
Iterator variables: i
Python program:
import math as m
def CountPairs ( n ) :
    cnt = 0
    i = 1
    while i * i <= n :
        if ( n % i == 0 ) :
            div1 = i
            div2 = n // i
            sum = div1 + div2 ;
            if ( m . gcd ( sum , n ) == 1 ) :
                cnt += 1
        i += 1
    return cnt
n = 24
print ( CountPairs ( n ) )

Accumulator variables: cnt, i