dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
from math import sqrt , floor , ceil
def countPermutations ( N ) :
    adj = [ [ ] for i in range ( 105 ) ]
    indeg = 0
    for i in range ( 1 , N + 1 ) :
        for j in range ( 1 , N + 1 ) :
            if ( i == j ) :
                continue
            sum = i + j
            if ( ceil ( sqrt ( sum ) ) == floor ( sqrt ( sum ) ) ) :
                adj [ i ] . append ( j )
        if ( len ( adj [ i ] ) == 1 ) :
            indeg += 1
    if ( indeg == 0 ) :
        return N
    elif ( indeg <= 2 ) :
        return 2
    else :
        return 0
if __name__ == ' _ _ main _ _ ' :
    N = 17
    print ( countPermutations ( N ) )

Index/key variables: i
Accumulator variables: indeg
Iterator variables: i, j
Python program:
def makelst ( N , K ) :
    lst = [ 0 for i in range ( N ) ]
    left = 1
    right = N
    for i in range ( N ) :
        if ( K % 2 == 0 ) :
            lst [ i ] = left
            left = left + 1
        else :
            lst [ i ] = right
            right = right - 1
        if ( K > 1 ) :
            K -= 1
    for i in range ( N ) :
        print ( lst [ i ] , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
    N = 6
    K = 3
    makelst ( N , K )

Index/key variables: i
Accumulator variables: K
Iterator variables: i
Python program:
def getDate ( d , m ) :
    days = [ 31 , 29 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31 ]
    month = [ ' January ' , ' February ' , ' March ' , ' April ' , ' May ' , ' June ' , ' July ' , ' August ' , ' September ' , ' October ' , ' November ' , ' December ' ]
    cnt = 183
    cur_month = month . index ( m )
    cur_date = d
    while ( 1 ) :
        while ( cnt > 0 and cur_date <= days [ cur_month ] ) :
            cnt -= 1
            cur_date += 1
        if ( cnt == 0 ) :
            break
        cur_month = ( cur_month + 1 ) % 12
        cur_date = 1
    print ( cur_date , month [ cur_month ] )
D = 15
M = " January "
getDate ( D , M )

Index/key variables: cur_month
Accumulator variables: cnt, cur_date
Python program:
def largestNumber ( N ) :
    if ( N > 45 ) :
        return - 1
    num = 0
    digit = 9
    while ( N > 0 and digit > 0 ) :
        if ( digit <= N ) :
            num *= 10
            num += digit
            N -= digit
        digit -= 1
    return num * 10
N = 25
print ( largestNumber ( N ) )

Accumulator variables: N, digit, num
Python program:
def minimumSum ( A , N , S ) :
    mul = 0
    for i in range ( len ( S ) ) :
        if ( S [ i ] == " * " ) :
            mul += 1
    ans = 1000000
    for i in range ( 1 << ( N - 1 ) ) :
        cnt = 0
        v = [ ]
        for j in range ( N - 1 ) :
            if ( ( 1 << j ) & i ) :
                cnt += 1
                v . append ( " * " )
            else :
                v . append ( " + " )
        if ( cnt == mul ) :
            d = [ ]
            d . append ( A [ 0 ] )
            for j in range ( N - 1 ) :
                if ( v [ j ] == " * " ) :
                    x = d [ len ( d ) - 1 ]
                    d . pop ( )
                    x = x * A [ j + 1 ]
                    d . append ( x )
                else :
                    d . append ( A [ j + 1 ] )
            sum = 0
            while ( len ( d ) > 0 ) :
                x = d [ 0 ]
                sum += x
                d . pop ( 0 )
            ans = min ( ans , sum )
    return ans
A = [ 2 , 2 , 2 , 2 ]
S = " * * + "
N = len ( A )
print ( minimumSum ( A , N , S ) )

Index/key variables: i, j
Accumulator variables: cnt, d, mul, sum, v
Iterator variables: i, j
Python program:
def sumOfMedians ( arr , N , K ) :
    selectMedian = ( K + 1 ) // 2
    totalArrays = N // K
    minSum = 0
    i = selectMedian - 1
    while ( i < N and totalArrays != 0 ) :
        minSum = minSum + arr [ i ]
        i = i + selectMedian
        totalArrays -= 1
    print ( minSum )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 2 , 3 , 4 , 5 , 6 ]
    N = len ( arr )
    K = 2
    sumOfMedians ( arr , N , K )

Index/key variables: i
Accumulator variables: totalArrays
Python program:
def solve ( S , K , N ) :
    if ( K > N ) :
        print ( " - 1" )
        return
    max_sum , min_sum = 0 , 0
    for i in range ( K + 1 ) :
        min_sum += i
        max_sum += N - i + 1
    if ( S < min_sum or S > max_sum ) :
        print ( " - 1" )
        return
    s1 = 0
    nums = [ ]
    for i in range ( 1 , N + 1 ) :
        if ( s1 > S ) :
            break
        s1 += i
        nums . append ( i )
    answer = [ ]
    s2 = 0
    for i in range ( K - 1 ) :
        answer . append ( nums [ i ] )
        s2 += nums [ i ]
    answer . append ( S - s2 )
    Max = N
    for i in range ( len ( answer ) - 1 , - 1 , - 1 ) :
        if ( answer [ i ] > Max ) :
            extra = answer [ i ] - Max
            if ( i - 1 >= 0 ) :
                answer [ i - 1 ] += extra
            answer [ i ] = Max
            Max -= 1
        else :
            break
    for x in answer :
        print ( x , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
    S , K , N = 15 , 4 , 8
    solve ( S , K , N )

Index/key variables: i
Accumulator variables: Max, answer, max_sum, min_sum, nums, s1, s2
Iterator variables: i, x
Python program:
def minSizeArr ( A , N , K ) :
    leftTaken = N
    rightTaken = N
    leftSum = 0
    rightSum = 0
    for left in range ( - 1 , N ) :
        if ( left != - 1 ) :
            leftSum += A [ left ]
        rightSum = 0
        for right in range ( N - 1 , left , - 1 ) :
            rightSum += A [ right ]
            if ( leftSum + rightSum == K ) :
                if ( leftTaken + rightTaken > ( left + 1 ) + ( N - right ) ) :
                    leftTaken = left + 1
                    rightTaken = N - right
                break
            if ( leftSum + rightSum > K ) :
                break
    if ( leftTaken + rightTaken <= N ) :
        for i in range ( leftTaken ) :
            print ( A [ i ] , end = " ▁ " )
        for i in range ( rightTaken ) :
            print ( A [ N - i - 1 ] , end = " ▁ " )
    else :
        print ( - 1 )
if __name__ == " _ _ main _ _ " :
    N = 7
    A = [ 3 , 2 , 1 , 1 , 1 , 1 , 3 ]
    K = 10
    minSizeArr ( A , N , K )

Index/key variables: i, left, right
Accumulator variables: leftSum, rightSum
Iterator variables: i, left, right
Python program:
def minSizeArr ( A , N , K ) :
    sum = 0
    for i in range ( N ) :
        sum += A [ i ]
    if ( K > sum ) :
        print ( - 1 ) ;
        return
    if ( K == sum ) :
        for i in range ( N ) :
            print ( A [ i ] , end = " ▁ " )
        return
    tar = sum - K
    um = { }
    um [ 0 ] = - 1
    left = 0
    right = 0
    cur = 0
    maxi = - 1
    for i in range ( N ) :
        cur += A [ i ]
        if ( ( cur - tar ) in um and ( i - um [ cur - tar ] ) > maxi ) :
            maxi = i - um [ cur - tar ]
            right = i
            left = um [ cur - tar ]
        if ( cur not in um ) :
            um [ cur ] = i
    if ( maxi == - 1 ) :
        print ( - 1 )
    else :
        for i in range ( left + 1 ) :
            print ( A [ i ] , end = " ▁ " )
        for i in range ( right ) :
            print ( A [ N - i - 1 ] , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
    N = 7
    A = [ 3 , 2 , 1 , 1 , 1 , 1 , 3 ]
    K = 10
    minSizeArr ( A , N , K )

Index/key variables: cur, i
Accumulator variables: sum
Iterator variables: i
Python program:
def minModulo ( L , R , N ) :
    if ( R - L < N ) :
        ans = 10 ** 9
        for i in range ( L , R + 1 ) :
            for j in range ( L , R + 1 ) :
                if ( i != j ) :
                    ans = min ( ans , ( i * j ) % N )
        print ( ans )
    else :
        print ( 0 )
if __name__ == ' _ _ main _ _ ' :
    L , R , N = 6 , 10 , 2019
    minModulo ( L , R , N )

Iterator variables: i, j
Python program:
def countNumbers ( N ) :
    count = 0
    for i in range ( 1 , N + 1 ) :
        if i * i > N :
            break
        if ( N % i == 0 ) :
            count += 1
            if ( N // i != i ) :
                count += 1
    return count
if __name__ == ' _ _ main _ _ ' :
    N = 10
    print ( countNumbers ( N ) )

Accumulator variables: count
Iterator variables: i
Python program:
def maximumSize ( a , k ) :
    low = 1
    high = max ( a )
    ans = - 1
    while ( low <= high ) :
        mid = low + ( high - low ) // 2
        count = 0
        for c in range ( len ( a ) ) :
            count += a // mid
        if ( count >= k ) :
            ans = mid
            low = mid + 1
        else :
            high = mid - 1
    return ans
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 2 , 3 , 4 , 9 ]
    K = 6
    print ( maximumSize ( arr , K ) )

Accumulator variables: count
Iterator variables: c
Python program:
def findMaxValueOfEquation ( arr , K ) :
    pq = [ ]
    res = - 10 ** 8
    for point in arr :
        while ( len ( pq ) > 0 and point [ 0 ] - pq [ - 1 ] [ 1 ] > K ) :
            del pq [ - 1 ]
        if ( len ( pq ) > 0 ) :
            res = max ( res , pq [ - 1 ] [ 0 ] + point [ 0 ] + point [ 1 ] )
        pq . append ( [ point [ 1 ] - point [ 0 ] , point [ 0 ] ] )
        pq = sorted ( pq )
    print ( res )
if __name__ == ' _ _ main _ _ ' :
    arr = [ [ 1 , 3 ] , [ 2 , 0 ] , [ 5 , 10 ] , [ 6 , - 10 ] ]
    K = 1
    findMaxValueOfEquation ( arr , K )

Accumulator variables: pq
Iterator variables: point
Python program:
def minOperations ( arr , n ) :
    oddcount , evencount = 0 , 0
    for i in range ( n ) :
        if ( arr [ i ] % 2 == 1 ) :
            oddcount += 1
        else :
            evencount += 1
    return min ( oddcount , evencount )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 2 , 4 , 3 , 1 , 8 ]
    N = len ( arr )
    print ( minOperations ( arr , N ) )

Index/key variables: i
Accumulator variables: evencount, oddcount
Iterator variables: i
Python program:
def printLastElement ( arr , N ) :
    leftTurn = True
    remainElements = N
    step = 1
    head = 1
    while ( remainElements > 1 ) :
        if ( leftTurn ) :
            head = head + step
        else :
            if ( remainElements % 2 == 1 ) :
                head = head + step
        remainElements = remainElements // 2
        step = step * 2
        leftTurn = not leftTurn
    print ( arr [ head - 1 ] )
if __name__ == " _ _ main _ _ " :
    arr = [ 2 , 3 , 5 , 6 ]
    N = len ( arr )
    printLastElement ( arr , N )

Boolean variables: leftTurn
Python program:
def shortestSubarray ( A , N ) :
    i = 0
    left_index = 0
    for i in range ( N - 1 ) :
        if ( A [ i ] + 1 != A [ i + 1 ] ) :
            break
    left_index = i
    right_index = 0
    i = N - 1
    while ( i >= 1 ) :
        if ( A [ i ] != A [ i - 1 ] + 1 ) :
            break
        i -= 1
    right_index = i
    updated_right = 0
    minLength = min ( N - left_index - 1 , right_index )
    if ( A [ right_index ] <= A [ left_index ] + 1 ) :
        updated_right = ( right_index + A [ left_index ] - A [ right_index ] + 1 )
        if ( updated_right < N ) :
            minLength = min ( minLength , updated_right - left_index - 1 )
    print ( minLength )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 2 , 3 , 7 , 4 , 3 , 5 ]
    N = len ( arr )
    shortestSubarray ( arr , N )

Index/key variables: i, left_index, right_index
Iterator variables: i
Python program:
def freqCheck ( S , N ) :
    hash = [ 0 ] * 26
    for i in range ( N ) :
        hash [ ord ( S [ i ] ) - ord ( ' a ' ) ] += 1
    for i in range ( 26 ) :
        if ( hash [ i ] > 2 ) :
            return " Yes "
    return " No "
if __name__ == " _ _ main _ _ " :
    S = " geekseekforgeeks "
    N = len ( S )
    print ( freqCheck ( S , N ) )

Index/key variables: i
Iterator variables: i
Python program:
def minLength ( s ) :
    i = 0 ; j = len ( s ) - 1
    while ( i < j and s [ i ] == s [ j ] ) :
        d = s [ i ]
        while ( i <= j and s [ i ] == d ) :
            i += 1
        while ( i <= j and s [ j ] == d ) :
            j -= 1
    return j - i + 1
if __name__ == " _ _ main _ _ " :
    S = " aacbcca "
    print ( minLength ( S ) )

Index/key variables: i, j
Python program:
def maximumIndex ( N , B ) :
    i , j = 0 , 1
    cnt = 0
    sum = N * ( N + 1 ) // 2
    flag = False
    while ( cnt < N ) :
        i += j
        j += 1
        cnt += 1
        if ( i == B ) :
            flag = True
            break
    if ( not flag ) :
        print ( sum )
    else :
        print ( sum - 1 )
if __name__ == ' _ _ main _ _ ' :
    N , B = 4 , 6
    maximumIndex ( N , B )

Accumulator variables: cnt, i, j
Boolean variables: flag
Python program:
def findLongestArray ( K ) :
    primefactors = [ ]
    K_temp = K
    i = 2
    while i * i <= K :
        count = 0
        while ( K_temp % i == 0 ) :
            K_temp //= i
            count += 1
        if ( count > 0 ) :
            primefactors . append ( [ count , i ] )
        i += 1
    if ( K_temp != 1 ) :
        primefactors . append ( [ 1 , K_temp ] )
    primefactors . sort ( )
    answer = [ primefactors [ 0 ] [ 0 ] , primefactors [ 0 ] [ 1 ] ]
    answer [ - 1 ] *= K
    for i in range ( primefactors [ 0 ] [ 0 ] ) :
        answer [ - 1 ] //= primefactors [ 0 ] [ 1 ]
    print ( " { " , end = " " )
    for i in range ( len ( answer ) ) :
        if ( i == len ( answer ) - 1 ) :
            print ( answer [ i ] , end = " } " )
        else :
            print ( answer [ i ] , end = " , ▁ " )
if __name__ == " _ _ main _ _ " :
    K = 4
    findLongestArray ( K )

Index/key variables: i
Accumulator variables: K_temp, count, primefactors
Iterator variables: i
Python program:
def minsteps ( A ) :
    n = len ( A )
    left , right , res = [ 0 ] * n , [ 0 ] * n , [ 0 ] * n
    count = A [ 0 ]
    for i in range ( 1 , n ) :
        left [ i ] = left [ i - 1 ] + count
        count += A [ i ]
    count = A [ n - 1 ]
    for i in range ( n - 2 , - 1 , - 1 ) :
        right [ i ] = right [ i + 1 ] + count
        count += A [ i ]
    for i in range ( n ) :
        res [ i ] = left [ i ] + right [ i ]
        print ( res [ i ] , end = " ▁ " )
    print ( )
if __name__ == ' _ _ main _ _ ' :
    A = [ 1 , 0 , 1 , 0 ]
    minsteps ( A )

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Python program:
def minimumOperations ( A , K ) :
    isflipped = [ 0 ] * ( len ( A ) + 1 )
    ans = 0
    for i in range ( len ( A ) ) :
        if ( i > 0 ) :
            isflipped [ i ] += isflipped [ i - 1 ]
            isflipped [ i ] %= 2
        if ( A [ i ] == 0 and not isflipped [ i ] ) :
            if ( ( len ( A ) - i + 1 ) <= K ) :
                print ( - 1 )
                return
            ans += 1
            isflipped [ i ] += 1
            isflipped [ i + K ] -= 1
        elif ( A [ i ] == 1 and isflipped [ i ] ) :
            if ( ( len ( A ) - i + 1 ) <= K ) :
                print ( - 1 )
                return
            ans += 1
            isflipped [ i ] += 1
            isflipped [ i + K ] -= 1
    print ( ans )
if __name__ == " _ _ main _ _ " :
    arr = [ 0 , 1 , 0 ]
    K = 1
    minimumOperations ( arr , K )

Index/key variables: i
Accumulator variables: ans
Iterator variables: i
Python program:
def findScoreSum ( n ) :
    total = 0
    prev_monday , curr_day = 0 , 0
    for day in range ( 1 , n + 1 ) :
        if ( day % 7 == 1 ) :
            prev_monday += 1
            curr_day = prev_monday
        total += curr_day
        curr_day += 1
    print ( total )
if __name__ == ' _ _ main _ _ ' :
    N = 8
    findScoreSum ( N )

Accumulator variables: curr_day, prev_monday, total
Iterator variables: day
Python program:
def minimumOperations ( A , n ) :
    cnt = 0
    for i in range ( n - 1 , - 1 , - 1 ) :
        if ( A [ i ] != ( i + 1 ) ) :
            if ( ( ( i - 1 ) >= 0 ) and A [ i - 1 ] == ( i + 1 ) ) :
                cnt += 1
                A [ i ] , A [ i - 1 ] = A [ i - 1 ] , A [ i ]
            elif ( ( ( i - 2 ) >= 0 ) and A [ i - 2 ] == ( i + 1 ) ) :
                cnt += 2
                A [ i - 2 ] = A [ i - 1 ]
                A [ i - 1 ] = A [ i ]
                A [ i ] = i + 1
            else :
                print ( - 1 )
                return
    print ( cnt )
if __name__ == " _ _ main _ _ " :
    A = [ 7 , 3 , 2 , 1 , 4 ]
    n = len ( A )
    minimumOperations ( A , n )

Index/key variables: i
Accumulator variables: cnt
Iterator variables: i
Python program:
def countOccurrences ( n , x ) :
    count = 0
    for i in range ( 1 , n + 1 ) :
        if ( x % i == 0 ) :
            if ( x // i <= n ) :
                count += 1
    print ( count )
if __name__ == " _ _ main _ _ " :
    N = 7
    X = 12
    countOccurrences ( N , X )

Accumulator variables: count
Iterator variables: i
Python program:
MAX = 1000000
def countOfPrimefactors ( CountDistinct ) :
    global MAX
    prime = [ 0 for i in range ( MAX + 1 ) ]
    for i in range ( MAX + 1 ) :
        CountDistinct [ i ] = 0
        prime [ i ] = True
    for i in range ( 2 , MAX + 1 , 1 ) :
        if ( prime [ i ] == True ) :
            CountDistinct [ i ] = 1
            for j in range ( i * 2 , MAX + 1 , i ) :
                CountDistinct [ j ] += 1
                prime [ j ] = False
def CountEvenPair ( A , B , N , M ) :
    global MAX
    countDistinct = [ 0 for i in range ( MAX + 1 ) ]
    countOfPrimefactors ( countDistinct )
    evenCount = 0
    oddCount = 0
    evenPairs = 0
    for i in range ( M ) :
        if ( countDistinct [ B [ i ] ] == 0 ) :
            continue
        if ( countDistinct [ B [ i ] ] & 1 ) :
            oddCount += 1
        else :
            evenCount += 1
    for i in range ( N ) :
        if ( countDistinct [ A [ i ] ] == 0 ) :
            continue
        if ( countDistinct [ A [ i ] ] & 1 ) :
            evenPairs += ( evenCount )
        else :
            evenPairs += evenCount + oddCount
    return evenPairs
if __name__ == ' _ _ main _ _ ' :
    A = [ 1 , 2 , 3 ]
    B = [ 4 , 5 , 6 ]
    N = len ( A )
    M = len ( B )
    print ( CountEvenPair ( A , B , N , M ) )

Index/key variables: i, j
Accumulator variables: evenCount, evenPairs, oddCount
Iterator variables: i, j
Python program:
def longestSubarray ( arr , N , K ) :
    um = { }
    sum , maxLen = 0 , 0
    for i in range ( N ) :
        sum += arr [ i ]
        if ( sum == K ) :
            maxLen = i + 1
        if ( sum not in um ) :
            um [ sum ] = i
        if ( ( sum - K ) in um ) :
            if ( maxLen < ( i - um [ sum - K ] ) ) :
                maxLen = i - um [ sum - K ]
    return maxLen
def minRequiredOperation ( arr , N , K ) :
    TotalSum = 0
    for i in range ( N ) :
        TotalSum += arr [ i ]
    maxLen = longestSubarray ( arr , N , TotalSum - K )
    if ( maxLen == - 1 ) :
        print ( - 1 , end = " " )
    else :
        print ( N - maxLen , end = " " )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 3 , 1 , 1 , 2 ]
    K = 4
    N = len ( arr )
    minRequiredOperation ( arr , N , K )

Index/key variables: i, sum
Accumulator variables: TotalSum
Iterator variables: i
Python program:
def minimumDeletions ( s ) :
    n = len ( s )
    ans = n
    for i in range ( n - 1 , - 1 , - 1 ) :
        t = ord ( s [ i ] ) - ord ( '0' )
        if ( t % 2 == 0 ) :
            for j in range ( i - 1 , - 1 , - 1 ) :
                num = ( ord ( s [ j ] ) - ord ( '0' ) ) * 10 + t
                if ( num % 4 == 0 ) :
                    k1 = i - j - 1
                    k2 = n - i - 1
                    ans = min ( ans , k1 + k2 )
    if ( ans == n ) :
        for i in range ( n ) :
            num = ord ( s [ i ] ) - ord ( '0' )
            if ( num % 4 == 0 ) :
                ans = n - 1
    print ( ans )
if __name__ == ' _ _ main _ _ ' :
    str = "12367"
    minimumDeletions ( str )

Index/key variables: i, j
Iterator variables: i, j
Python program:
def LCMPairs ( arr , N ) :
    total_pairs = ( N * ( N - 1 ) ) / 2
    odd = 0
    for i in range ( N ) :
        if ( arr [ i ] & 1 ) :
            odd += 1
    odd = ( odd * ( odd - 1 ) ) // 2
    print ( " Even ▁ = " , int ( total_pairs - odd ) , " , " , " ▁ Odd ▁ = " , odd )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 3 , 6 , 5 , 4 ]
    N = len ( arr )
    LCMPairs ( arr , N )

Index/key variables: i
Accumulator variables: odd
Iterator variables: i
Python program:
def countSwaps ( S , T ) :
    value = [ 0 ] * 26
    for i in range ( 26 ) :
        value [ i ] = i + 1
    N = len ( S )
    sum1 = 0
    sum2 = 0
    flag = False
    for i in range ( N ) :
        sum1 += value [ ord ( S [ i ] ) - ord ( ' a ' ) ]
        sum2 += value [ ord ( T [ i ] ) - ord ( ' a ' ) ]
        if ( value [ ord ( S [ i ] ) - ord ( ' a ' ) ] % 2 == 0 and value [ ord ( T [ i ] ) - ord ( ' a ' ) ] % 2 == 1 or value [ ord ( S [ i ] ) - ord ( ' a ' ) ] % 2 == 1 and value [ ord ( T [ i ] ) - ord ( ' a ' ) ] % 2 == 0 ) :
            flag = False
    if ( sum1 % 2 == 1 and sum2 % 2 == 1 ) :
        print ( "0" )
    elif ( sum1 % 2 == 0 and sum2 % 2 == 0 ) :
        if ( flag ) :
            print ( "1" )
        else :
            print ( " - 1" )
    else :
        print ( " - 1" )
if __name__ == ' _ _ main _ _ ' :
    S = " acd "
    T = " dbf "
    countSwaps ( S , T )

Index/key variables: i
Accumulator variables: sum1, sum2
Iterator variables: i
Boolean variables: flag
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 countPrimeTuples ( N ) :
    count = 0
    for i in range ( 2 , N + 1 ) :
        if ( isPrime ( i ) and isPrime ( i - 2 ) ) :
            count += 1
    print ( count )
N = 6
countPrimeTuples ( N )

Accumulator variables: count
Iterator variables: i
Python program:
def maximumCandy ( candies , safety , N , M ) :
    total = 0
    ans = 10 ** 8
    all_safe = True
    for i in range ( N ) :
        if ( candies [ i ] + M > safety [ i ] ) :
            all_safe = False
            ans = min ( ans , safety [ i ] )
        else :
            ans = min ( ans , candies [ i ] + M )
        total += candies [ i ]
    if ( all_safe ) :
        return total
    else :
        return ans
if __name__ == ' _ _ main _ _ ' :
    A = [ 4 , 5 , 2 , 3 ]
    B = [ 8 , 13 , 6 , 4 ]
    M = 5
    N = len ( A )
    print ( maximumCandy ( A , B , N , M ) )

Index/key variables: i
Accumulator variables: total
Iterator variables: i
Boolean variables: all_safe
Python program:
def checkArrays ( arr1 , arr2 , N ) :
    count = 0
    flag = True
    for i in range ( N ) :
        if ( arr1 [ i ] != arr2 [ i ] ) :
            if ( arr1 [ i ] == 0 ) :
                count += 1
            else :
                count -= 1
                if ( count < 0 ) :
                    flag = 0
                    break
    if ( flag and count == 0 ) :
        print ( " Yes " )
    else :
        print ( " No " )
if __name__ == ' _ _ main _ _ ' :
    arr1 = [ 0 , 0 , 1 , 1 ]
    arr2 = [ 1 , 1 , 0 , 0 ]
    N = len ( arr1 )
    checkArrays ( arr1 , arr2 , N )

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Boolean variables: flag
Python program:
from math import ceil , floor
def MinimumMoves ( A , B , N ) :
    totalOperations = 0
    carry = 0
    K = 0
    for i in range ( N - 1 , - 1 , - 1 ) :
        nearestMultiple = ceil ( ( A [ i ] + carry ) / B [ i ] ) * B [ i ]
        K = nearestMultiple - ( A [ i ] + carry )
        totalOperations += K
        carry += K
    return totalOperations
if __name__ == ' _ _ main _ _ ' :
    A = [ 3 , 4 , 5 , 2 , 5 , 5 , 9 ]
    B = [ 1 , 1 , 9 , 6 , 3 , 8 , 7 ]
    N = len ( A )
    print ( MinimumMoves ( A , B , N ) )

Index/key variables: i
Accumulator variables: carry, totalOperations
Iterator variables: i