dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
def separate ( arr , n , parity ) :
    count = 1
    res = 0
    for i in range ( 1 , n ) :
        if ( ( ( arr [ i ] + parity ) & 1 ) and ( ( arr [ i - 1 ] + parity ) & 1 ) ) :
            count += 1
        else :
            if ( count > 1 ) :
                res += count - 1
            count = 1
    return res
def printArray ( arr , n ) :
    for i in range ( n ) :
        print ( arr [ i ] , end = " ▁ " )
def requiredOps ( arr , N ) :
    res1 = separate ( arr , N , 0 )
    res2 = separate ( arr , N , 1 )
    print ( max ( res1 , res2 ) )
if __name__ == " _ _ main _ _ " :
    arr = [ 13 , 2 , 6 , 8 , 3 , 5 , 7 , 10 , 14 , 15 ]
    N = len ( arr )
    requiredOps ( arr , N )

Index/key variables: i
Accumulator variables: count, res
Iterator variables: i
Python program:
from math import sqrt
def SieveOfEratosthenes ( N ) :
    isPrime = [ True for i in range ( N + 1 ) ]
    isPrime [ 0 ] = False
    isPrime [ 1 ] = False
    for p in range ( 2 , int ( sqrt ( N ) ) + 1 , 1 ) :
        if ( isPrime [ p ] ) :
            for i in range ( p * p , N + 1 , p ) :
                isPrime [ i ] = False
    return isPrime
def cntPairsdiffOfPrimeisPrime ( N ) :
    cntPairs = 0
    isPrime = SieveOfEratosthenes ( N )
    for i in range ( 2 , N + 1 , 1 ) :
        if ( isPrime [ i ] and isPrime [ i - 2 ] ) :
            cntPairs += 2
    return cntPairs
if __name__ == ' _ _ main _ _ ' :
    N = 5
    print ( cntPairsdiffOfPrimeisPrime ( N ) )

Index/key variables: i, p
Accumulator variables: cntPairs
Iterator variables: i, p
Python program:
def longestSubsequence ( arr , N ) :
    count = 1
    for i in range ( 1 , N , 1 ) :
        if ( arr [ i ] != arr [ i - 1 ] ) :
            count += 1
    print ( count )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 7 , 8 , 1 , 2 , 2 , 5 , 5 , 1 ]
    N = len ( arr )
    longestSubsequence ( arr , N )

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Python program:
import sys
def substringCount ( s ) :
    freq = [ 0 for i in range ( 26 ) ]
    maxfreq = - sys . maxsize - 1
    for i in range ( len ( s ) ) :
        freq [ ord ( s [ i ] ) - ord ( ' a ' ) ] += 1
        if ( maxfreq < freq [ ord ( s [ i ] ) - ord ( ' a ' ) ] ) :
            maxfreq = freq [ ord ( s [ i ] ) - ord ( ' a ' ) ]
    for i in range ( 26 ) :
        if ( maxfreq == freq [ i ] ) :
            max_char = chr ( i + ord ( ' a ' ) )
            break
    ans = 0
    for i in range ( len ( s ) ) :
        ch = s [ i ]
        if ( max_char == ch ) :
            ans += ( len ( s ) - i )
    return ans
if __name__ == ' _ _ main _ _ ' :
    S = " abcab "
    print ( substringCount ( S ) )

Index/key variables: i
Accumulator variables: ans
Iterator variables: i
Python program:
def minSum ( arr , n ) :
    ans = [ 1 ] * ( n )
    for i in range ( 1 , n ) :
        if ( arr [ i ] > arr [ i - 1 ] ) :
            ans [ i ] = max ( ans [ i ] , ans [ i - 1 ] + 1 )
    for i in range ( n - 2 , - 1 , - 1 ) :
        if ( arr [ i ] > arr [ i + 1 ] ) :
            ans [ i ] = max ( ans [ i ] , ans [ i + 1 ] + 1 )
    s = 0
    for x in ans :
        s = s + x
    print ( s )
if __name__ == " _ _ main _ _ " :
    arr = [ 1 , 2 , 2 ]
    N = len ( arr )
    minSum ( arr , N )

Index/key variables: i
Iterator variables: i, x
Python program:
from math import ceil
def minSteps ( S ) :
    new_str = " "
    N = len ( S )
    i = 0
    while ( i < N ) :
        new_str += S [ i ]
        j = i
        while ( i < N and S [ i ] == S [ j ] ) :
            i += 1
    print ( ceil ( ( len ( new_str ) + 1 ) / 2 ) )
if __name__ == ' _ _ main _ _ ' :
    S = "0010100"
    minSteps ( S )

Index/key variables: i, j
Accumulator variables: new_str
Python program:
def countPairs ( arr , N ) :
    cntPairs = 0
    mp = { }
    for i in range ( 0 , N ) :
        if arr [ i ] in mp :
            mp [ arr [ i ] ] = mp [ arr [ i ] ] + 1
        else :
            mp [ arr [ i ] ] = 1
    for freq in mp :
        cntPairs += int ( ( mp [ freq ] * ( mp [ freq ] - 1 ) ) / 2 )
    return cntPairs
if __name__ == " _ _ main _ _ " :
    arr = [ 1 , 2 , 3 , 1 , 2 , 2 ]
    N = len ( arr )
    print ( countPairs ( arr , N ) )

Index/key variables: freq, i
Accumulator variables: cntPairs
Iterator variables: freq, i
Python program:
def palindromeMatrix ( N , M , arr ) :
    ans = 0
    for i in range ( ( N + 1 ) // 2 ) :
        for j in range ( ( M + 1 ) // 2 ) :
            s = { }
            s [ ( i , j ) ] = 1
            s [ ( i , M - j - 1 ) ] = 1
            s [ ( N - i - 1 , j ) ] = 1
            s [ ( N - i - 1 , M - j - 1 ) ] = 1
            values = [ ]
            for p , q in s :
                values . append ( arr [ p ] [ q ] )
            maxm = max ( values )
            for k in range ( len ( values ) ) :
                ans += maxm - values [ k ]
    print ( ans )
if __name__ == ' _ _ main _ _ ' :
    N , M = 3 , 3
    arr = [ [ 1 , 2 , 1 ] , [ 3 , 4 , 1 ] , [ 1 , 2 , 1 ] ]
    palindromeMatrix ( N , M , arr )

Index/key variables: k, p, q
Accumulator variables: ans, values
Iterator variables: i, j, k, p, q
Python program:
def minimumMoves ( n ) :
    cnt2 = 0
    cnt5 = 0
    while ( n % 2 == 0 ) :
        n //= 2
        cnt2 += 1
    while ( n % 5 == 0 ) :
        n //= 5
        cnt5 += 1
    if ( n == 1 and cnt2 <= cnt5 ) :
        return 2 * cnt5 - cnt2
    else :
        return - 1
if __name__ == ' _ _ main _ _ ' :
    N = 25
    print ( minimumMoves ( N ) )

Accumulator variables: cnt2, cnt5, n
Python program:
def MinOperation ( arr , N , K ) :
    cntOpe = 0
    for i in range ( N ) :
        if ( K > arr [ i ] ) :
            if ( ( K - arr [ i ] ) % 2 == 0 ) :
                cntOpe += 2
            else :
                cntOpe += 1
        elif ( K < arr [ i ] ) :
            if ( ( K - arr [ i ] ) % 2 == 0 ) :
                cntOpe += 1
            else :
                cntOpe += 2
    return cntOpe
arr = [ 8 , 7 , 2 , 1 , 3 ]
K = 5
N = len ( arr )
print ( MinOperation ( arr , N , K ) )

Index/key variables: i
Accumulator variables: cntOpe
Iterator variables: i
Python program:
def binCoff ( n , r ) :
    val = 1
    if ( r > ( n - r ) ) :
        r = ( n - r )
    for i in range ( 0 , r ) :
        val *= ( n - i )
        val //= ( i + 1 )
    return val
def findWays ( M ) :
    n = M // 2
    a = binCoff ( 2 * n , n )
    b = a // ( n + 1 )
    print ( b )
if __name__ == ' _ _ main _ _ ' :
    M = 4
    X = 5
    findWays ( M )

Accumulator variables: val
Iterator variables: i
Python program:
def gcd ( a , b ) :
    if ( a == 0 ) :
        return b
    return gcd ( b % a , a )
def countInverse ( arr , N , M ) :
    XOR = 0
    for i in range ( 0 , N ) :
        gcdOfMandelement = gcd ( M , arr [ i ] )
        if ( gcdOfMandelement == 1 ) :
            XOR = XOR ^ arr [ i ]
    print ( XOR )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 2 , 3 ]
    M = 4
    N = len ( arr )
    countInverse ( arr , N , M )

Index/key variables: i
Iterator variables: i
Python program:
def equvInverse ( arr , N , P ) :
    cntElem = 0
    for i in range ( 0 , N ) :
        if ( ( arr [ i ] * arr [ i ] ) % P == 1 ) :
            cntElem = cntElem + 1
    return cntElem
if __name__ == " _ _ main _ _ " :
    arr = [ 1 , 6 , 4 , 5 ]
    N = len ( arr )
    P = 7
    print ( equvInverse ( arr , N , P ) )

Index/key variables: i
Iterator variables: i
Python program:
def power ( K , M ) :
    res = 1
    while ( M > 0 ) :
        if ( ( M & 1 ) == 1 ) :
            res = ( res * K )
        M = M >> 1
        K = ( K * K )
    return res
def cntWays ( arr , N , K ) :
    cntways = 0
    M = 0
    st = set ( )
    for i in range ( N ) :
        st . add ( arr [ i ] )
    M = len ( st )
    cntways = power ( K , M )
    return cntways
if __name__ == ' _ _ main _ _ ' :
    arr = [ 2 , 3 ]
    N = len ( arr )
    K = 2
    print ( cntWays ( arr , N , K ) )

Index/key variables: i
Accumulator variables: st
Iterator variables: i
Python program:
mod = 1e9 + 7
def minProduct ( n ) :
    ans = 1
    for i in range ( 1 , ( n - 4 ) // 2 + 1 ) :
        ans = ( ans * ( n - 2 ) ) % mod
    ans = ( ans * ( n - 2 ) * ( n - 1 ) ) % mod
    print ( int ( ans ) )
if __name__ == ' _ _ main _ _ ' :
    N = 8
    minProduct ( N )

Iterator variables: i
Python program:
def TotalXorPair ( arr , N ) :
    totalXOR = 0 ;
    for i in range ( 0 , N ) :
        for j in range ( i + 1 , N ) :
            totalXOR ^= arr [ i ] ^ arr [ j ] ;
    return totalXOR ;
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 2 , 3 , 4 ] ;
    N = len ( arr ) ;
    print ( TotalXorPair ( arr , N ) ) ;

Index/key variables: i, j
Accumulator variables: totalXOR
Iterator variables: i, j
Python program:
def countPairs ( arr , n ) :
    oneCount = 0
    desiredPair = 0
    for i in range ( n ) :
        if ( arr [ i ] == 1 ) :
            oneCount += 1
        if ( arr [ i ] == 0 ) :
            desiredPair += oneCount
    return desiredPair
if __name__ == ' _ _ main _ _ ' :
    arr = [ 3 , 1 , 1 , 0 ]
    N = len ( arr )
    print ( countPairs ( arr , N ) )

Index/key variables: i
Accumulator variables: desiredPair, oneCount
Iterator variables: i
Python program:
def smlstNonNeg ( arr , N ) :
    smNonNeg = 0
    hash = [ 0 ] * ( N + 1 )
    for i in range ( N ) :
        if ( arr [ i ] >= 0 and arr [ i ] < N ) :
            hash [ arr [ i ] ] = True
        while ( hash [ smNonNeg ] ) :
            smNonNeg += 1
        print ( smNonNeg , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 0 , 1 , 2 , 3 , 5 ]
    N = len ( arr )
    smlstNonNeg ( arr , N )

Index/key variables: i, smNonNeg
Iterator variables: i
Python program:
def solve ( arr , N , X ) :
    A = [ ]
    B = [ ]
    c = 0
    for i in range ( N ) :
        if ( ( 2 * arr [ i ] ) < X ) :
            A . append ( arr [ i ] )
        elif ( ( 2 * arr [ i ] ) > X ) :
            B . append ( arr [ i ] )
        else :
            if ( c % 2 == 0 ) :
                A . append ( arr [ i ] )
            else :
                B . append ( arr [ i ] )
            c += 1
    print ( " The ▁ First ▁ Array ▁ is ▁ - ▁ " , end = " ▁ " )
    for i in range ( len ( A ) ) :
        print ( A [ i ] , end = " ▁ " )
    print ( )
    print ( " The ▁ Second ▁ Array ▁ is ▁ - ▁ " , end = " ▁ " )
    for i in range ( len ( B ) ) :
        print ( B [ i ] , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 5 , 4 , 3 , 6 , 2 , 4 , 3 ]
    X = 7
    N = len ( arr )
    solve ( arr , N , X )

Index/key variables: i
Accumulator variables: A, B, c
Iterator variables: i
Python program:
def cntMinSub ( arr , N , K ) :
    res = 0
    start = 0
    end = N - 1
    arr = sorted ( arr )
    while ( end - start > 1 ) :
        if ( arr [ start ] + arr [ end ] <= K ) :
            start += 1
        else :
            res += 1
            end -= 1
    if ( end - start == 1 ) :
        if ( arr [ start ] + arr [ end ] <= K ) :
            res += 1
            start += 1
            end -= 1
        else :
            res += 1
            end -= 1
    if ( start == end ) :
        res += 1
    return res
if __name__ == ' _ _ main _ _ ' :
    arr = [ 2 , 6 , 8 , 10 , 20 , 25 ]
    N = len ( arr )
    K = 26
    print ( cntMinSub ( arr , N , K ) )

Index/key variables: end, start
Accumulator variables: res
Python program:
def condition ( a , b ) :
    d = abs ( a - b )
    count = 0
    for i in range ( 1 , d + 1 ) :
        if i * i > d :
            break
        if ( d % i == 0 ) :
            if ( d // i == i ) :
                count += 1
            else :
                count += 2
    return count
if __name__ == ' _ _ main _ _ ' :
    x = 2
    y = 6
    print ( condition ( x , y ) )

Accumulator variables: count
Iterator variables: i
Python program:
def isComposite ( N ) :
    for i in range ( 2 , N + 1 ) :
        if i * i > N :
            break
        if ( N % i == 0 ) :
            return True
    return False
def compositePair ( arr , N ) :
    res = 0
    for i in range ( N ) :
        for j in range ( i + 1 , N ) :
            prod = arr [ i ] * arr [ j ]
            if ( isComposite ( prod ) ) :
                res += 1
    return res
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 1 , 2 , 2 , 8 ]
    N = len ( arr )
    print ( compositePair ( arr , N ) )

Index/key variables: i, j
Accumulator variables: res
Iterator variables: i, j
Python program:
from collections import deque
def generateArray ( arr , n ) :
    ans = deque ( )
    for i in range ( n ) :
        if ( i & 1 != 0 ) :
            ans . appendleft ( arr [ i ] )
        else :
            ans . append ( arr [ i ] )
    if ( n & 1 != 0 ) :
        ans . reverse ( )
    for x in ans :
        print ( x , end = " ▁ " )
    print ( )
n = 4
arr = [ 1 , 2 , 3 , 4 ]
generateArray ( arr , n )

Index/key variables: i
Accumulator variables: ans
Iterator variables: i, x
Python program:
def closestgtNum ( str ) :
    res = " " ;
    n = len ( str ) ;
    if ( str [ 0 ] < '9' ) :
        res += ( chr ) ( ord ( str [ 0 ] ) + 1 ) ;
    else :
        res += ( chr ) ( '1' ) ;
        res += ( chr ) ( '0' ) ;
    for i in range ( n - 1 ) :
        res += ( '0' ) ;
    return res ;
if __name__ == ' _ _ main _ _ ' :
    str = "120" ;
    print ( closestgtNum ( str ) ) ;

Accumulator variables: res
Iterator variables: i
Python program:
def maximumSubarrays ( arr , N , target ) :
    ans = 0
    availIdx = - 1
    cur_sum = 0
    mp = { }
    mp [ 0 ] = - 1
    for i in range ( N ) :
        cur_sum += arr [ i ]
        if ( ( cur_sum - target ) in mp and mp [ cur_sum - target ] >= availIdx ) :
            ans += 1
            availIdx = i
        mp [ cur_sum ] = i
    return ans
if __name__ == ' _ _ main _ _ ' :
    arr = [ 2 , - 1 , 4 , 3 , 6 , 4 , 5 , 1 ]
    N = len ( arr )
    target = 6
    print ( maximumSubarrays ( arr , N , target ) )

Index/key variables: cur_sum, i
Accumulator variables: ans
Iterator variables: i
Python program:
def countOfPairs ( x , y ) :
    counter = 1
    while ( x or y ) :
        bit1 = x % 2
        bit2 = y % 2
        x >>= 1
        y >>= 1
        if ( bit1 == 1 and bit2 == 0 ) :
            counter *= 2
            continue
        if ( bit1 & bit2 ) :
            counter = 0
            break
    return counter
X = 2
Y = 5
print ( countOfPairs ( X , Y ) )

Accumulator variables: counter, x, y
Python program:
def gcd ( a , b ) :
    if ( a == 0 ) :
        return b
    return gcd ( b % a , a )
def findGCD ( arr , N ) :
    result = 0
    for element in arr :
        result = gcd ( result , element )
        if ( result == 1 ) :
            return 1
    return result
arr = [ 2 , 3 , 4 ]
N = len ( arr )
print ( findGCD ( arr , N ) )

Iterator variables: element
Python program:
def factorsOf3 ( arr , N ) :
    a = 0
    b = 0
    c = 0
    for i in range ( N ) :
        if ( arr [ i ] % 3 == 0 ) :
            a += 1
        elif ( arr [ i ] % 3 == 1 ) :
            b += 1
        elif ( arr [ i ] % 3 == 2 ) :
            c += 1
    if ( a >= 1 and a <= b + c + 1 ) :
        print ( " Yes " )
    elif ( a == 0 and b == 0 and c > 0 ) :
        print ( " Yes " )
    elif ( a == 0 and c == 0 and b > 0 ) :
        print ( " Yes " )
    else :
        print ( " No " )
arr = [ 1 , 2 , 3 , 3 ]
N = len ( arr )
factorsOf3 ( arr , N )

Index/key variables: i
Accumulator variables: a, b, c
Iterator variables: i
Python program:
def countSubstring ( s , n ) :
    m = { }
    for i in range ( n ) :
        if s [ i ] in m :
            m [ s [ i ] ] += 1
        else :
            m [ s [ i ] ] = 1
    ans = 0
    for i in range ( n ) :
        cnt = 0
        if s [ i ] in m :
            m [ s [ i ] ] -= 1
        else :
            m [ s [ i ] ] = - 1
        for value in m :
            if ( value == s [ i ] ) :
                continue
            else :
                cnt += m [ value ]
        ans += cnt
    print ( ans )
S = " abcab "
N = 5
countSubstring ( S , N )

Index/key variables: i, value
Accumulator variables: ans, cnt
Iterator variables: i, value
Python program:
def power ( x , n ) :
    temp = [ ]
    if ( n == 0 ) :
        return 1
    temp = power ( x , n // 2 )
    if ( n % 2 == 0 ) :
        return temp * temp
    else :
        return x * temp * temp
def count_Total_Numbers ( n , x ) :
    total , multiples = 0 , 0
    for i in range ( 10 ) :
        if ( i % x == 0 ) :
            multiples += 1
    if ( n == 1 ) :
        return multiples
    total = ( ( multiples - 1 ) * power ( multiples , n - 1 ) )
    return total
if __name__ == ' _ _ main _ _ ' :
    N = 1
    X = 3
    print ( count_Total_Numbers ( N , X ) )

Accumulator variables: multiples
Iterator variables: i
Python program:
def number_of_strings ( N , M ) :
    ans = 0
    while ( N > 0 and M > 0 ) :
        if ( N > M ) :
            if ( N >= 2 ) :
                N -= 2
                M -= 1
                ans += 1
            else :
                break
        else :
            if M >= 2 :
                M -= 2
                N -= 1
                ans += 1
            else :
                break
    print ( ans )
if __name__ == ' _ _ main _ _ ' :
    N = 4
    M = 19
    number_of_strings ( N , M )

Accumulator variables: M, N, ans
Python program:
def minLength ( A , N ) :
    elem = A [ 0 ]
    count = 1
    for i in range ( 1 , N ) :
        if ( A [ i ] == elem ) :
            count += 1
        else :
            break
    if ( count == N ) :
        return N
    else :
        return 1
arr = [ 2 , 1 , 3 , 1 ]
N = len ( arr )
print ( minLength ( arr , N ) )

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Python program:
def NegEqu ( N , X , Y ) :
    while ( X and N > N // 2 + 10 ) :
        N = N // 2 + 10
        X -= 1
    while ( Y ) :
        N = N - 10
        Y -= 1
    if ( N <= 0 ) :
        return True
    return False
if __name__ == ' _ _ main _ _ ' :
    N = 100
    X = 3
    Y = 4
    if ( NegEqu ( N , X , Y ) ) :
        print ( " Yes " )
    else :
        print ( " No " )

Accumulator variables: X, Y
Python program:
from math import gcd
def minSubarrays ( arr , n ) :
    right = n - 1
    left = 0
    subarrays = 0
    while ( right >= 0 ) :
        for left in range ( right + 1 ) :
            if ( gcd ( arr [ left ] , arr [ right ] ) > 1 ) :
                subarrays += 1
                right = left - 1
                break
            if ( left == right and __gcd ( arr [ left ] , arr [ right ] ) == 1 ) :
                return 0
    return subarrays
if __name__ == ' _ _ main _ _ ' :
    N = 6
    arr = [ 2 , 3 , 4 , 4 , 4 , 3 ]
    print ( minSubarrays ( arr , N ) )

Index/key variables: left, right
Accumulator variables: subarrays
Iterator variables: left
Python program:
import sys
def findMaxSoln ( n , x , y ) :
    ans = - sys . maxsize
    for k in range ( n + 1 ) :
        if ( k % x == y ) :
            ans = max ( ans , k )
    return ( ans if ( ans >= 0 and ans <= n ) else - 1 )
if __name__ == ' _ _ main _ _ ' :
    n = 15
    x = 10
    y = 5
    print ( findMaxSoln ( n , x , y ) )

Iterator variables: k
Python program:
from collections import defaultdict
def RightAngled ( a , n ) :
    xpoints = defaultdict ( lambda : 0 )
    ypoints = defaultdict ( lambda : 0 )
    for i in range ( n ) :
        xpoints [ a [ i ] [ 0 ] ] += 1
        ypoints [ a [ i ] [ 1 ] ] += 1
    count = 0
    for i in range ( n ) :
        if ( xpoints [ a [ i ] [ 0 ] ] >= 1 and ypoints [ a [ i ] [ 1 ] ] >= 1 ) :
            count += ( ( xpoints [ a [ i ] [ 0 ] ] - 1 ) * ( ypoints [ a [ i ] [ 1 ] ] - 1 ) )
    return count
N = 5
arr = [ [ 1 , 2 ] , [ 2 , 1 ] , [ 2 , 2 ] , [ 2 , 3 ] , [ 3 , 2 ] ]
print ( RightAngled ( arr , N ) )

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Python program:
def printArray ( brr ) :
    for it in brr :
        print ( it , end = ' ▁ ' )
def RepeatingSubarray ( arr , N ) :
    if ( N < 2 ) :
        print ( " - 1" )
    brr = [ ]
    brr . append ( arr [ 0 ] )
    brr . append ( arr [ 1 ] )
    for i in range ( 2 , N // 2 + 1 ) :
        if ( N % i == 0 ) :
            a = False
            n = len ( brr )
            j = i
            while ( j < N ) :
                K = j % i
                if ( arr [ j ] == brr [ K ] ) :
                    j += 1
                else :
                    a = True
                    break
            if ( not a and j == N ) :
                printArray ( brr )
                return
        brr . append ( arr [ i ] )
    print ( " - 1" )
    return
if __name__ == " _ _ main _ _ " :
    arr = [ 1 , 2 , 2 , 1 , 2 , 2 , 1 , 2 , 2 ]
    N = len ( arr )
    RepeatingSubarray ( arr , N )

Index/key variables: K, i, j
Accumulator variables: brr
Iterator variables: i, it
Boolean variables: a
Python program:
def printMissingElements ( arr , N ) :
    diff = arr [ 0 ]
    for i in range ( N ) :
        if ( arr [ i ] - i != diff ) :
            while ( diff < arr [ i ] - i ) :
                print ( i + diff , end = " ▁ " )
                diff += 1
arr = [ 6 , 7 , 10 , 11 , 13 ]
N = len ( arr )
printMissingElements ( arr , N )

Index/key variables: i
Accumulator variables: diff
Iterator variables: i
Python program:
def printMissingElements ( arr , N ) :
    b = [ 0 ] * ( arr [ N - 1 ] + 1 )
    for i in range ( N ) :
        b [ arr [ i ] ] = 1
    for i in range ( arr [ 0 ] , arr [ N - 1 ] + 1 ) :
        if ( b [ i ] == 0 ) :
            print ( i , end = " ▁ " )
arr = [ 6 , 7 , 10 , 11 , 13 ]
N = len ( arr )
printMissingElements ( arr , N )

Index/key variables: i
Iterator variables: i
Python program:
def smallestCommon ( a , b , c , d ) :
    if ( a == c ) :
        return a ;
    if ( a > c ) :
        swap ( a , c ) ;
        swap ( b , d ) ;
    first_term_diff = ( c - a ) ;
    possible_y = 0 ;
    for possible_y in range ( b ) :
        if ( ( first_term_diff % b + possible_y * d ) % b == 0 ) :
            break ;
    if ( possible_y != b ) :
        return c + possible_y * d ;
    return - 1 ;
def swap ( x , y ) :
    temp = x ;
    x = y ;
    y = temp ;
if __name__ == ' _ _ main _ _ ' :
    A = 2 ; B = 20 ; C = 19 ; D = 9 ;
    print ( smallestCommon ( A , B , C , D ) ) ;

Iterator variables: possible_y
Python program:
def MinimumFlips ( s , n ) :
    a = [ 0 ] * n
    for i in range ( n ) :
        a [ i ] = 1 if s [ i ] == '1' else 0
    oddone = [ 0 ] * ( n + 1 )
    evenone = [ 0 ] * ( n + 1 )
    for i in range ( n ) :
        if ( i % 2 != 0 ) :
            if ( a [ i ] == 1 ) :
                oddone [ i + 1 ] = oddone [ i ] + 1
            else :
                oddone [ i + 1 ] = oddone [ i ] + 0
            if ( a [ i ] == 0 ) :
                evenone [ i + 1 ] = evenone [ i ] + 1
            else :
                evenone [ i + 1 ] = evenone [ i ] + 0
        else :
            if ( a [ i ] == 0 ) :
                oddone [ i + 1 ] = oddone [ i ] + 1
            else :
                oddone [ i + 1 ] = oddone [ i ] + 0
            if ( a [ i ] == 1 ) :
                evenone [ i + 1 ] = evenone [ i ] + 1
            else :
                evenone [ i + 1 ] = evenone [ i ] + 0
    minimum = min ( oddone [ n ] , evenone [ n ] )
    for i in range ( n ) :
        if ( n % 2 != 0 ) :
            minimum = min ( minimum , oddone [ n ] - oddone [ i + 1 ] + evenone [ i + 1 ] )
            minimum = min ( minimum , evenone [ n ] - evenone [ i + 1 ] + oddone [ i + 1 ] )
    return minimum
S = "000001100"
n = len ( S )
print ( MinimumFlips ( S , n ) )

Index/key variables: i, n
Iterator variables: i