dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . prev = None
        self . next = None
def getNode ( data ) :
    newNode = Node ( 0 )
    newNode . data = data
    newNode . prev = newNode . next = None
    return newNode
def sortedInsert ( head_ref , newNode ) :
    current = None
    if ( head_ref == None ) :
        head_ref = newNode
    elif ( ( head_ref ) . data >= newNode . data ) :
        newNode . next = head_ref
        newNode . next . prev = newNode
        head_ref = newNode
    else :
        current = head_ref
        while ( current . next != None and current . next . data < newNode . data ) :
            current = current . next
        newNode . next = current . next
        if ( current . next != None ) :
            newNode . next . prev = newNode
        current . next = newNode
        newNode . prev = current
    return head_ref ;
def insertionSort ( head_ref ) :
    sorted = None
    current = head_ref
    while ( current != None ) :
        next = current . next
        current . prev = current . next = None
        sorted = sortedInsert ( sorted , current )
        current = next
    head_ref = sorted
    return head_ref
def printList ( head ) :
    while ( head != None ) :
        print ( head . data , end = " ▁ " )
        head = head . next
def push ( head_ref , new_data ) :
    new_node = Node ( 0 )
    new_node . data = new_data
    new_node . next = ( head_ref )
    new_node . prev = None
    if ( ( head_ref ) != None ) :
        ( head_ref ) . prev = new_node
    ( head_ref ) = new_node
    return head_ref
if __name__ == " _ _ main _ _ " :
    head = None
    head = push ( head , 9 )
    head = push ( head , 3 )
    head = push ( head , 5 )
    head = push ( head , 10 )
    head = push ( head , 12 )
    head = push ( head , 8 )
    print ( " Doubly ▁ Linked ▁ List ▁ Before ▁ Sorting " )
    printList ( head )
    head = insertionSort ( head )
    print ( " Doubly Linked List After Sorting " )
    printList ( head )

Class/struct names: Node
Python program:
def reverse ( arr , s , e ) :
    while s < e :
        tem = arr [ s ]
        arr [ s ] = arr [ e ]
        arr [ e ] = tem
        s = s + 1
        e = e - 1
def fun ( arr , k ) :
    n = len ( arr ) - 1
    v = n - k
    if v >= 0 :
        reverse ( arr , 0 , v )
        reverse ( arr , v + 1 , n )
        reverse ( arr , 0 , n )
        return arr
arr = [ 1 , 2 , 3 , 4 ]
for i in range ( 0 , len ( arr ) ) :
    count = 0
    p = fun ( arr , i )
    print ( p , end = " ▁ " )

Index/key variables: e, s
Iterator variables: i
Python program:
def maximumEqual ( a , b , n ) :
    store = [ 0 ] * 10 ** 5
    for i in range ( n ) :
        store [ b [ i ] ] = i + 1
    ans = [ 0 ] * 10 ** 5
    for i in range ( n ) :
        d = abs ( store [ a [ i ] ] - ( i + 1 ) )
        if ( store [ a [ i ] ] < i + 1 ) :
            d = n - d
        ans [ d ] += 1
    finalans = 0
    for i in range ( 10 ** 5 ) :
        finalans = max ( finalans , ans [ i ] )
    print ( finalans )
if __name__ == ' _ _ main _ _ ' :
    A = [ 6 , 7 , 3 , 9 , 5 ]
    B = [ 7 , 3 , 9 , 5 , 6 ]
    size = len ( A )
    maximumEqual ( A , B , size )

Index/key variables: d, i
Iterator variables: i
Python program:
def RightRotate ( a , n , k ) :
    k = k % n ;
    for i in range ( 0 , n ) :
        if ( i < k ) :
            print ( a [ n + i - k ] , end = " ▁ " ) ;
        else :
            print ( a [ i - k ] , end = " ▁ " ) ;
    print ( " " ) ;
Array = [ 1 , 2 , 3 , 4 , 5 ] ;
N = len ( Array ) ;
K = 2 ;
RightRotate ( Array , N , K ) ;

Iterator variables: i
Python program:
def restoreSortedArray ( arr , n ) :
    for i in range ( n ) :
        if ( arr [ i ] > arr [ i + 1 ] ) :
            reverse ( arr , 0 , i ) ;
            reverse ( arr , i + 1 , n ) ;
            reverse ( arr , 0 , n ) ;
def reverse ( arr , i , j ) :
    while ( i < j ) :
        temp = arr [ i ] ;
        arr [ i ] = arr [ j ] ;
        arr [ j ] = temp ;
        i += 1 ;
        j -= 1 ;
def printArray ( arr , size ) :
    for i in range ( size ) :
        print ( arr [ i ] , end = " " ) ;
if __name__ == ' _ _ main _ _ ' :
    arr = [ 3 , 4 , 5 , 1 , 2 ] ;
    n = len ( arr ) ;
    restoreSortedArray ( arr , n - 1 ) ;
    printArray ( arr , n ) ;

Index/key variables: i, j
Iterator variables: i
Python program:
def findStartIndexOfArray ( arr , low , high ) :
    if ( low > high ) :
        return - 1 ;
    if ( low == high ) :
        return low ;
    mid = low + ( high - low ) / 2 ;
    if ( arr [ mid ] > arr [ mid + 1 ] ) :
        return mid + 1 ;
    if ( arr [ mid - 1 ] > arr [ mid ] ) :
        return mid ;
    if ( arr [ low ] > arr [ mid ] ) :
        return findStartIndexOfArray ( arr , low , mid - 1 ) ;
    else :
        return findStartIndexOfArray ( arr , mid + 1 , high ) ;
def restoreSortedArray ( arr , n ) :
    if ( arr [ 0 ] < arr [ n - 1 ] ) :
        return ;
    start = findStartIndexOfArray ( arr , 0 , n - 1 ) ;
    reverse ( arr , 0 , start ) ;
    reverse ( arr , start , n ) ;
    reverse ( arr ) ;
def printArray ( arr , size ) :
    for i in range ( size ) :
        print ( arr [ i ] , end = " " ) ;
def reverse ( arr , i , j ) :
    while ( i < j ) :
        temp = arr [ i ] ;
        arr [ i ] = arr [ j ] ;
        arr [ j ] = temp ;
        i += 1 ;
        j -= 1 ;
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 2 , 3 , 4 , 5 ] ;
    n = len ( arr ) ;
    restoreSortedArray ( arr , n ) ;
    printArray ( arr , n ) ;

Index/key variables: i, j, low, mid
Iterator variables: i
Python program:
import math
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . next = None
def insertNode ( start , value ) :
    if ( start == None ) :
        new_node = Node ( value )
        new_node . data = value
        new_node . next = new_node
        new_node . prev = new_node
        start = new_node
        return new_node
    last = start . prev
    new_node = Node ( value )
    new_node . data = value
    new_node . next = start
    ( start ) . prev = new_node
    new_node . prev = last
    last . next = new_node
    return start
def displayList ( start ) :
    temp = start
    while ( temp . next != start ) :
        print ( temp . data , end = " ▁ " )
        temp = temp . next
    print ( temp . data )
def searchList ( start , search ) :
    temp = start
    count = 0
    flag = 0
    value = 0
    if ( temp == None ) :
        return - 1
    else :
        while ( temp . next != start ) :
            count = count + 1
            if ( temp . data == search ) :
                flag = 1
                count = count - 1
                break
            temp = temp . next
        if ( temp . data == search ) :
            count = count + 1
            flag = 1
        if ( flag == 1 ) :
            print ( search , " found ▁ at ▁ location ▁ " , count )
        else :
            print ( search , " ▁ not ▁ found " )
    return - 1
if __name__ == ' _ _ main _ _ ' :
    start = None
    start = insertNode ( start , 4 )
    start = insertNode ( start , 5 )
    start = insertNode ( start , 7 )
    start = insertNode ( start , 8 )
    start = insertNode ( start , 6 )
    print ( " Created ▁ circular ▁ doubly ▁ linked ▁ list ▁ is : ▁ " , end = " " )
    displayList ( start )
    searchList ( start , 5 )

Class/struct names: Node
Python program:
import math
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . next = None
def getNode ( data ) :
    newNode = Node ( data )
    newNode . data = data
    return newNode
def insertEnd ( head , new_node ) :
    if ( head == None ) :
        new_node . next = new_node
        new_node . prev = new_node
        head = new_node
        return head
    last = head . prev
    new_node . next = head
    head . prev = new_node
    new_node . prev = last
    last . next = new_node
    return head
def reverse ( head ) :
    if ( head == None ) :
        return None
    new_head = None
    last = head . prev
    curr = last
    while ( curr . prev != last ) :
        prev = curr . prev
        new_head = insertEnd ( new_head , curr )
        curr = prev
    new_head = insertEnd ( new_head , curr )
    return new_head
def display ( head ) :
    if ( head == None ) :
        return
    temp = head
    print ( " Forward ▁ direction : ▁ " , end = " " )
    while ( temp . next != head ) :
        print ( temp . data , end = " ▁ " )
        temp = temp . next
    print ( temp . data )
    last = head . prev
    temp = last
    print ( " Backward ▁ direction : ▁ " , end = " " )
    while ( temp . prev != last ) :
        print ( temp . data , end = " ▁ " )
        temp = temp . prev
    print ( temp . data )
if __name__ == ' _ _ main _ _ ' :
    head = None
    head = insertEnd ( head , getNode ( 1 ) )
    head = insertEnd ( head , getNode ( 2 ) )
    head = insertEnd ( head , getNode ( 3 ) )
    head = insertEnd ( head , getNode ( 4 ) )
    head = insertEnd ( head , getNode ( 5 ) )
    print ( " Current ▁ list : " )
    display ( head )
    head = reverse ( head )
    print ( " Reversed list : " )
    display ( head )

Class/struct names: Node
Python program:
MAXN = 1001
depth = [ 0 for i in range ( MAXN ) ] ;
parent = [ 0 for i in range ( MAXN ) ] ;
adj = [ [ ] for i in range ( MAXN ) ]
def addEdge ( u , v ) :
    adj [ u ] . append ( v ) ;
    adj [ v ] . append ( u ) ;
def dfs ( cur , prev ) :
    parent [ cur ] = prev ;
    depth [ cur ] = depth [ prev ] + 1 ;
    for i in range ( len ( adj [ cur ] ) ) :
        if ( adj [ cur ] [ i ] != prev ) :
            dfs ( adj [ cur ] [ i ] , cur ) ;
def preprocess ( ) :
    depth [ 0 ] = - 1 ;
    dfs ( 1 , 0 ) ;
def LCANaive ( u , v ) :
    if ( u == v ) :
        return u ;
    if ( depth [ u ] > depth [ v ] ) :
        u , v = v , u
    v = parent [ v ] ;
    return LCANaive ( u , v ) ;
if __name__ == " _ _ main _ _ " :
    addEdge ( 1 , 2 ) ;
    addEdge ( 1 , 3 ) ;
    addEdge ( 1 , 4 ) ;
    addEdge ( 2 , 5 ) ;
    addEdge ( 2 , 6 ) ;
    addEdge ( 3 , 7 ) ;
    addEdge ( 4 , 8 ) ;
    addEdge ( 4 , 9 ) ;
    addEdge ( 9 , 10 ) ;
    addEdge ( 9 , 11 ) ;
    addEdge ( 7 , 12 ) ;
    addEdge ( 7 , 13 ) ;
    preprocess ( ) ;
    print ( ' LCA ( 11,8 ) ▁ : ▁ ' + str ( LCANaive ( 11 , 8 ) ) )
    print ( ' LCA ( 3,13 ) ▁ : ▁ ' + str ( LCANaive ( 3 , 13 ) ) )

Index/key variables: cur, i, prev, u, v
Iterator variables: i
Python program:
def countOfNum ( n , a , b ) :
    cnt_of_a , cnt_of_b , cnt_of_ab , sum = 0 , 0 , 0 , 0
    cnt_of_a = n // a
    cnt_of_b = n // b
    sum = cnt_of_b + cnt_of_a
    cnt_of_ab = n // ( a * b )
    sum = sum - cnt_of_ab
    return sum
def sumOfNum ( n , a , b ) :
    i = 0
    sum = 0
    ans = dict ( )
    for i in range ( a , n + 1 , a ) :
        ans [ i ] = 1
    for i in range ( b , n + 1 , b ) :
        ans [ i ] = 1
    for it in ans :
        sum = sum + it
    return sum
if __name__ == ' _ _ main _ _ ' :
    N = 88
    A = 11
    B = 8
    count = countOfNum ( N , A , B )
    sumofnum = sumOfNum ( N , A , B )
    print ( sumofnum % count )

Index/key variables: i
Iterator variables: i, it
Python program:
from bisect import bisect_right as upper_bound
MAX = 100000
v = [ ]
def consecutiveOnes ( x ) :
    p = 0
    while ( x > 0 ) :
        if ( x % 2 == 1 and p == 1 ) :
            return True
        p = x % 2
        x //= 2
    return False
def preCompute ( ) :
    for i in range ( MAX + 1 ) :
        if ( consecutiveOnes ( i ) == 0 ) :
            v . append ( i )
def nextValid ( n ) :
    it = upper_bound ( v , n )
    val = v [ it ]
    return val
def performQueries ( queries , q ) :
    for i in range ( q ) :
        print ( nextValid ( queries [ i ] ) )
queries = [ 4 , 6 ]
q = len ( queries )
preCompute ( )
performQueries ( queries , q )

Index/key variables: i, it
Accumulator variables: v, x
Iterator variables: i
Python program:
def changeToOnes ( string ) :
    ctr = 0 ;
    l = len ( string ) ;
    for i in range ( l - 1 , - 1 , - 1 ) :
        if ( string [ i ] == '1' ) :
            ctr += 1 ;
        else :
            break ;
    return l - ctr ;
def removeZeroesFromFront ( string ) :
    s = " " ;
    i = 0 ;
    while ( i < len ( string ) and string [ i ] == '0' ) :
        i += 1 ;
    if ( i == len ( string ) ) :
        s = "0" ;
    else :
        s = string [ i : len ( string ) - i ] ;
    return s ;
if __name__ == " _ _ main _ _ " :
    string = "10010111" ;
    string = removeZeroesFromFront ( string ) ;
    print ( changeToOnes ( string ) ) ;

Index/key variables: i
Accumulator variables: ctr
Iterator variables: i
Python program:
def MinDeletion ( a , n ) :
    map = dict . fromkeys ( a , 0 ) ;
    for i in range ( n ) :
        map [ a [ i ] ] += 1 ;
    ans = 0 ;
    for key , value in map . items ( ) :
        x = key ;
        frequency = value ;
        if ( x <= frequency ) :
            ans += ( frequency - x ) ;
        else :
            ans += frequency ;
    return ans ;
if __name__ == " _ _ main _ _ " :
    a = [ 2 , 3 , 2 , 3 , 4 , 4 , 4 , 4 , 5 ] ;
    n = len ( a ) ;
    print ( MinDeletion ( a , n ) ) ;

Index/key variables: i
Accumulator variables: ans
Iterator variables: i, key, value
Python program:
def MinOperations ( n , x , arr ) :
    total = 0
    for i in range ( n ) :
        if ( arr [ i ] > x ) :
            difference = arr [ i ] - x
            total = total + difference
            arr [ i ] = x
    for i in range ( n ) :
        LeftNeigbouringSum = arr [ i ] + arr [ i - 1 ]
        if ( LeftNeigbouringSum > x ) :
            current_diff = LeftNeigbouringSum - x
            arr [ i ] = max ( 0 , arr [ i ] - current_diff )
            total = total + current_diff
    return total
X = 1
arr = [ 1 , 6 , 1 , 2 , 0 , 4 ]
N = len ( arr )
print ( MinOperations ( N , X , arr ) )

Index/key variables: i
Iterator variables: i
Python program:
import math
def findNumbers ( arr , n ) :
    sumN = ( n * ( n + 1 ) ) / 2 ;
    sumSqN = ( n * ( n + 1 ) * ( 2 * n + 1 ) ) / 6 ;
    sum = 0 ;
    sumSq = 0 ;
    for i in range ( 0 , n ) :
        sum = sum + arr [ i ] ;
        sumSq = sumSq + ( math . pow ( arr [ i ] , 2 ) ) ;
    B = ( ( ( sumSq - sumSqN ) / ( sum - sumN ) ) + sumN - sum ) / 2 ;
    A = sum - sumN + B ;
    print ( " A ▁ = ▁ " , int ( A ) ) ;
    print ( " B ▁ = ▁ " , int ( B ) ) ;
arr = [ 1 , 2 , 2 , 3 , 4 ] ;
n = len ( arr ) ;
findNumbers ( arr , n ) ;

Index/key variables: i
Iterator variables: i
Python program:
def is_prefix ( temp , str ) :
    if ( len ( temp ) < len ( str ) ) :
        return 0
    else :
        for i in range ( len ( str ) ) :
            if ( str [ i ] != temp [ i ] ) :
                return 0
        return 1
def lexicographicallyString ( input , n , str ) :
    input . sort ( )
    for i in range ( n ) :
        temp = input [ i ]
        if ( is_prefix ( temp , str ) ) :
            return temp
    return " - 1"
if __name__ == ' _ _ main _ _ ' :
    arr = [ " apple " , " appe " , " apl " , " aapl " , " appax " ]
    S = " app "
    N = 5
    print ( lexicographicallyString ( arr , N , S ) )

Index/key variables: i
Iterator variables: i
Python program:
def Rearrange ( arr , K , N ) :
    ans = [ 0 ] * ( N + 1 )
    f = - 1
    for i in range ( N ) :
        ans [ i ] = - 1
    K = arr . index ( K )
    smaller = [ ]
    greater = [ ]
    for i in range ( N ) :
        if ( arr [ i ] < arr [ K ] ) :
            smaller . append ( arr [ i ] )
        elif ( arr [ i ] > arr [ K ] ) :
            greater . append ( arr [ i ] )
    low = 0
    high = N - 1
    while ( low <= high ) :
        mid = ( low + high ) // 2
        if ( mid == K ) :
            ans [ mid ] = arr [ K ]
            f = 1
            break
        elif ( mid < K ) :
            if ( len ( smaller ) == 0 ) :
                break
            ans [ mid ] = smaller [ - 1 ]
            smaller . pop ( )
            low = mid + 1
        else :
            if ( len ( greater ) == 0 ) :
                break
            ans [ mid ] = greater [ - 1 ]
            greater . pop ( )
            high = mid - 1
    if ( f == - 1 ) :
        print ( - 1 )
        return
    for i in range ( N ) :
        if ( ans [ i ] == - 1 ) :
            if ( len ( smaller ) ) :
                ans [ i ] = smaller [ - 1 ]
                smaller . pop ( )
            elif ( len ( greater ) ) :
                ans [ i ] = greater [ - 1 ]
                greater . pop ( )
    for i in range ( N ) :
        print ( ans [ i ] , end = " ▁ " )
    print ( )
if __name__ == " _ _ main _ _ " :
    arr = [ 10 , 7 , 2 , 5 , 3 , 8 ]
    K = 7
    N = len ( arr )
    Rearrange ( arr , K , N )

Index/key variables: K, i, mid
Accumulator variables: greater, smaller
Iterator variables: i
Python program:
def calcTotalTime ( path ) :
    time = 0
    x = 0
    y = 0
    s = set ( [ ] )
    for i in range ( len ( path ) ) :
        p = x
        q = y
        if ( path [ i ] == ' N ' ) :
            y += 1
        elif ( path [ i ] == ' S ' ) :
            y -= 1
        elif ( path [ i ] == ' E ' ) :
            x += 1
        elif ( path [ i ] == ' W ' ) :
            x -= 1
        if ( p + x , q + y ) not in s :
            time += 2
            s . add ( ( p + x , q + y ) )
        else :
            time += 1
    print ( time )
if __name__ == " _ _ main _ _ " :
    path = " NSE "
    calcTotalTime ( path )

Index/key variables: i
Accumulator variables: s, time, x, y
Iterator variables: i
Python program:
def findCost ( A , N ) :
    totalCost = 0
    for i in range ( N ) :
        if ( A [ i ] == 0 ) :
            A [ i ] = 1
            totalCost += i
    return totalCost
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 0 , 1 , 0 , 1 , 0 ]
    N = len ( arr )
    print ( findCost ( arr , N ) )

Index/key variables: i
Accumulator variables: totalCost
Iterator variables: i
Python program:
def peakIndex ( arr ) :
    N = len ( arr )
    if ( len ( arr ) < 3 ) :
        return - 1
    i = 0
    while ( i + 1 < N ) :
        if ( arr [ i + 1 ] < arr [ i ] or arr [ i ] == arr [ i + 1 ] ) :
            break
        i += 1
    if ( i == 0 or i == N - 1 ) :
        return - 1
    ans = i
    while ( i < N - 1 ) :
        if ( arr [ i ] < arr [ i + 1 ] or arr [ i ] == arr [ i + 1 ] ) :
            break
        i += 1
    if ( i == N - 1 ) :
        return ans
    return - 1
if __name__ == ' _ _ main _ _ ' :
    arr = [ 0 , 1 , 0 ]
    print ( peakIndex ( arr ) )

Index/key variables: i
Python program:
def hasArrayTwoPairs ( nums , n , target ) :
    nums = sorted ( nums )
    for i in range ( n ) :
        x = target - nums [ i ]
        low , high = 0 , n - 1
        while ( low <= high ) :
            mid = low + ( ( high - low ) // 2 )
            if ( nums [ mid ] > x ) :
                high = mid - 1
            elif ( nums [ mid ] < x ) :
                low = mid + 1
            else :
                if ( mid == i ) :
                    if ( ( mid - 1 >= 0 ) and nums [ mid - 1 ] == x ) :
                        print ( nums [ i ] , end = " , ▁ " )
                        print ( nums [ mid - 1 ] )
                        return
                    if ( ( mid + 1 < n ) and nums [ mid + 1 ] == x ) :
                        print ( nums [ i ] , end = " , ▁ " )
                        print ( nums [ mid + 1 ] )
                        return
                    break
                else :
                    print ( nums [ i ] , end = " , ▁ " )
                    print ( nums [ mid ] )
                    return
    print ( - 1 )
if __name__ == ' _ _ main _ _ ' :
    A = [ 0 , - 1 , 2 , - 3 , 1 ]
    X = - 2
    N = len ( A )
    hasArrayTwoPairs ( A , N , X )

Index/key variables: i, mid
Iterator variables: i
Python program:
from math import sqrt , floor , ceil
def findClosest ( N , target ) :
    closest = - 1
    diff = 10 ** 18
    for i in range ( 1 , ceil ( sqrt ( N ) ) + 1 ) :
        if ( N % i == 0 ) :
            if ( N // i == i ) :
                if ( abs ( target - i ) < diff ) :
                    diff = abs ( target - i )
                    closest = i
            else :
                if ( abs ( target - i ) < diff ) :
                    diff = abs ( target - i )
                    closest = i
                if ( abs ( target - N // i ) < diff ) :
                    diff = abs ( target - N // i )
                    closest = N // i
    print ( closest )
if __name__ == ' _ _ main _ _ ' :
    N , X = 16 , 5
    findClosest ( N , X )

Iterator variables: i
Python program:
def power ( A , N ) :
    count = 0 ;
    if ( A == 1 ) :
        return 0 ;
    while ( N > 0 ) :
        count += 1 ;
        N //= A ;
    return int ( count ) ;
def Pairs ( N , A , B ) :
    powerA , powerB = 0 , 0 ;
    powerA = power ( A , N ) ;
    powerB = power ( B , N ) ;
    intialB = B ;
    intialA = A ;
    A = 1 ;
    for i in range ( powerA + 1 ) :
        B = 1 ;
        for j in range ( powerB + 1 ) :
            if ( B == N - A ) :
                print ( i , " ▁ " , j ) ;
                return ;
            B *= intialB ;
        A *= intialA ;
    print ( " - 1" ) ;
    return ;
if __name__ == ' _ _ main _ _ ' :
    N = 106 ;
    A = 3 ;
    B = 5 ;
    Pairs ( N , A , B ) ;

Accumulator variables: A, B, N, count
Iterator variables: i, j
Python program:
def findNonMultiples ( arr , n , k ) :
    multiples = set ( [ ] )
    for i in range ( n ) :
        if ( arr [ i ] not in multiples ) :
            for j in range ( 1 , k // arr [ i ] + 1 ) :
                multiples . add ( arr [ i ] * j )
    return k - len ( multiples )
def countValues ( arr , N , L , R ) :
    return ( findNonMultiples ( arr , N , R ) - findNonMultiples ( arr , N , L - 1 ) )
if __name__ == " _ _ main _ _ " :
    arr = [ 2 , 3 , 4 , 5 , 6 ]
    N = len ( arr )
    L = 1
    R = 20
    print ( countValues ( arr , N , L , R ) )

Index/key variables: i
Accumulator variables: multiples
Iterator variables: i, j
Python program:
def cntDisPairs ( arr , N , K ) :
    cntPairs = 0
    arr = sorted ( arr )
    i = 0
    j = N - 1
    while ( i < j ) :
        if ( arr [ i ] + arr [ j ] == K ) :
            while ( i < j and arr [ i ] == arr [ i + 1 ] ) :
                i += 1
            while ( i < j and arr [ j ] == arr [ j - 1 ] ) :
                j -= 1
            cntPairs += 1
            i += 1
            j -= 1
        elif ( arr [ i ] + arr [ j ] < K ) :
            i += 1
        else :
            j -= 1
    return cntPairs
if __name__ == ' _ _ main _ _ ' :
    arr = [ 5 , 6 , 5 , 7 , 7 , 8 ]
    N = len ( arr )
    K = 13
    print ( cntDisPairs ( arr , N , K ) )

Index/key variables: i, j
Accumulator variables: cntPairs
Python program:
def cntDisPairs ( arr , N , K ) :
    cntPairs = 0
    cntFre = { }
    for i in arr :
        if i in cntFre :
            cntFre [ i ] += 1
        else :
            cntFre [ i ] = 1
    for key , value in cntFre . items ( ) :
        i = key
        if ( 2 * i == K ) :
            if ( cntFre [ i ] > 1 ) :
                cntPairs += 2
        else :
            if ( cntFre [ K - i ] ) :
                cntPairs += 1
    cntPairs = cntPairs / 2
    return cntPairs
arr = [ 5 , 6 , 5 , 7 , 7 , 8 ]
N = len ( arr )
K = 13
print ( int ( cntDisPairs ( arr , N , K ) ) )

Index/key variables: i
Accumulator variables: cntPairs
Iterator variables: i, key, value
Python program:
def longestSubsequence ( N , Q , arr , Queries ) :
    for i in range ( Q ) :
        x = Queries [ i ] [ 0 ]
        y = Queries [ i ] [ 1 ]
        arr [ x - 1 ] = y
        count = 1
        for j in range ( 1 , N ) :
            if ( arr [ j ] != arr [ j - 1 ] ) :
                count += 1
        print ( count , end = ' ▁ ' )
if __name__ == " _ _ main _ _ " :
    arr = [ 1 , 1 , 2 , 5 , 2 ]
    N = len ( arr )
    Q = 2
    Queries = [ [ 1 , 3 ] , [ 4 , 2 ] ]
    longestSubsequence ( N , Q , arr , Queries )

Index/key variables: i, j
Accumulator variables: count
Iterator variables: i, j