dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
def util ( sub ) :
    n = len ( sub )
    i = 0
    ret = " "
    while i < n :
        t = ( ord ( sub [ i ] ) - 97 ) + n - 1 - i
        ch = chr ( t % 26 + 97 )
        ret = ret + ch
        i = i + 1
    return ret
def manipulate ( s ) :
    n = len ( s )
    i = 0
    j = 0
    res = " "
    while i < n :
        if s [ i ] == ' ▁ ' :
            res += util ( s [ j : j + i ] )
            res = res + " ▁ "
            j = i + 1
            i = j + 1
        else :
            i = i + 1
    res = res + util ( s [ j : j + i ] )
    print ( res )
if __name__ == " _ _ main _ _ " :
    s = " acm ▁ fkz "
    manipulate ( s )

Index/key variables: i
Accumulator variables: res
Python program:
def isInBigStringHelper ( bigString , smallString , startIdx ) :
    leftBigIdx = startIdx
    rightBigIdx = startIdx + len ( smallString ) - 1
    leftSmallIdx = 0
    rightSmallIdx = len ( smallString ) - 1
    while ( leftBigIdx <= rightBigIdx ) :
        if ( bigString [ leftBigIdx ] != smallString [ leftSmallIdx ] or bigString [ rightBigIdx ] != smallString [ rightSmallIdx ] ) :
            return False
        leftBigIdx += 1
        rightBigIdx -= 1
        leftSmallIdx += 1
        rightSmallIdx -= 1
    return True
def isInBigString ( bigString , smallString ) :
    for i in range ( len ( bigString ) ) :
        if ( i + len ( smallString ) > len ( bigString ) ) :
            break
        if ( isInBigStringHelper ( bigString , smallString , i ) ) :
            return True
    return False
def multiStringSearch ( bigString , smallStrings ) :
    solution = [ ]
    for smallString in smallStrings :
        solution . append ( isInBigString ( bigString , smallString ) )
    return solution
if __name__ == ' _ _ main _ _ ' :
    str1 = " this ▁ is ▁ a ▁ big ▁ string "
    substr = [ " this " , " yo " , " is " , " a " , " bigger " , " string " , " kappa " ]
    ans = multiStringSearch ( str1 , substr )
    for i in range ( len ( ans ) ) :
        if ( ans [ i ] == 1 ) :
            print ( " true " , end = " ▁ " )
        else :
            print ( " false " , end = " ▁ " )

Index/key variables: i, leftBigIdx, leftSmallIdx, rightBigIdx, rightSmallIdx
Accumulator variables: solution
Iterator variables: i, smallString
Python program:
def countSmaller ( str ) :
    n = len ( str ) ;
    arr = [ 0 ] * 26 ;
    ans = [ 0 ] * n ;
    for i in range ( n - 1 , - 1 , - 1 ) :
        arr [ ord ( str [ i ] ) - ord ( ' a ' ) ] += 1 ;
        ct = 0 ;
        for j in range ( ord ( str [ i ] ) - ord ( ' a ' ) ) :
            ct += arr [ j ] ;
        ans [ i ] = ct ;
    for i in range ( n ) :
        print ( ans [ i ] , end = " ▁ " ) ;
if __name__ == ' _ _ main _ _ ' :
    str = " edcbaa " ;
    countSmaller ( str ) ;

Index/key variables: i, j
Accumulator variables: ct
Iterator variables: i, j
Python program:
def z_function ( s ) :
    global z , n
    n = len ( s )
    z = [ 0 ] * n
    l , r = 0 , 0
    for i in range ( 1 , n ) :
        if i <= r :
            z [ i ] = min ( r - i + 1 , z [ i - 1 ] )
        while ( i + z [ i ] < n and s [ z [ i ] ] == s [ i + z [ i ] ] ) :
            z [ i ] += 1
        if ( i + z [ i ] - 1 > r ) :
            l = i
            r = i + z [ i ] - 1
    return z
def update ( idx , val ) :
    global bit
    if idx == 0 :
        return
    while idx <= n :
        bit [ idx ] += val
        idx += ( idx & - idx )
def pref ( idx ) :
    global bit
    ans = 0
    while idx > 0 :
        ans += bit [ idx ]
        idx -= ( idx & - idx )
    return ans
if __name__ == " _ _ main _ _ " :
    n = 0
    length = 0
    bit = [ 0 ] * 1000005
    z = [ ]
    m = dict ( )
    s = " geeksisforgeeksinplatformgeeks "
    z = z_function ( s )
    for i in range ( 1 , n ) :
        update ( z [ i ] , 1 )
    for i in range ( n - 1 , 1 , - 1 ) :
        if z [ i ] != n - i :
            continue
        if ( pref ( n ) - pref ( z [ i ] - 1 ) ) >= 2 :
            length = max ( length , z [ i ] )
    if not length :
        print ( - 1 )
    else :
        print ( s [ : length ] )

Index/key variables: i, idx
Accumulator variables: ans
Iterator variables: i
Python program:
def endingWith ( str , suff ) :
    c = 0
    wrd = str . split ( " ▁ " )
    for l in wrd :
        if l . endswith ( suff ) :
            c += 1
    return c
str = " GeeksForGeeks ▁ is ▁ a ▁ computer ▁ science ▁ portal ▁ for ▁ geeks "
suff = " ks "
print ( endingWith ( str , suff ) )

Accumulator variables: c
Iterator variables: l
Python program:
def isFrequencyEqual ( string , length ) :
    if length % 2 == 1 :
        return False
    freq = [ 0 ] * 26
    for i in range ( 0 , length ) :
        freq [ ord ( string [ i ] ) - ord ( ' a ' ) ] += 1
    for i in range ( 0 , 26 ) :
        if freq [ i ] == length // 2 :
            return True
    return False
if __name__ == " _ _ main _ _ " :
    string = " geeksforgeeks "
    length = len ( string )
    if isFrequencyEqual ( string , length ) :
        print ( " Yes " )
    else :
        print ( " No " )

Index/key variables: i
Iterator variables: i
Python program:
def countMinimalReplacements ( s ) :
    n = len ( s )
    cnt = 0
    for i in range ( 1 , n ) :
        if ( s [ i ] == s [ i - 1 ] ) :
            cnt += 1 ;
            if ( i != ( n - 1 ) ) :
                s = list ( s )
                for j in "012" :
                    if ( j != s [ i + 1 ] and j != s [ i - 1 ] ) :
                        s [ i ] = j
                        break
                s = ' ' . join ( s )
            else :
                s = list ( s )
                for k in "012" :
                    if ( k != s [ i - 1 ] ) :
                        s [ i ] = k
                        break
                s = ' ' . join ( s )
    return cnt
if __name__ == ' _ _ main _ _ ' :
    s = "201220211"
    print ( countMinimalReplacements ( s ) )

Index/key variables: i
Accumulator variables: cnt
Iterator variables: i, j, k
Python program:
import math as mt
def isPrime ( n ) :
    i = 2
    if ( n == 1 ) :
        return False
    for i in range ( 2 , mt . ceil ( mt . sqrt ( n ) ) ) :
        if ( n % i == 0 ) :
            return False
    return True
def check_frequency ( s ) :
    m = dict ( )
    for i in range ( len ( s ) ) :
        if s [ i ] in m . keys ( ) :
            m [ s [ i ] ] += 1
        else :
            m [ s [ i ] ] = 1
    for ch in m :
        if m [ ch ] > 0 and isPrime ( m [ ch ] ) == False :
            return False
    return True
s = " geeksforgeeks "
if ( check_frequency ( s ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Index/key variables: ch, i
Iterator variables: ch, i
Python program:
def findSubstringCount ( str ) :
    result = 0
    n = len ( str )
    for i in range ( n - 1 ) :
        if ( ord ( str [ i ] ) + 1 == ord ( str [ i + 1 ] ) ) :
            result += 1
            while ( ord ( str [ i ] ) + 1 == ord ( str [ i + 1 ] ) ) :
                i += 1
    return result
if __name__ == " _ _ main _ _ " :
    str = " alphabet "
    print ( findSubstringCount ( str ) )

Index/key variables: i
Accumulator variables: result
Iterator variables: i
Python program:
import math as mt
NO_OF_CHARS = 256
def firstNonRepeating ( string ) :
    arr = [ - 1 for i in range ( NO_OF_CHARS ) ]
    for i in range ( len ( string ) ) :
        if arr [ ord ( string [ i ] ) ] == - 1 :
            arr [ ord ( string [ i ] ) ] = i
        else :
            arr [ ord ( string [ i ] ) ] = - 2
    res = 10 ** 18
    for i in range ( NO_OF_CHARS ) :
        if arr [ i ] >= 0 :
            res = min ( res , arr [ i ] )
    return res
string = " geeksforgeeks "
index = firstNonRepeating ( string )
if index == 10 ** 18 :
    print ( " Either ▁ all ▁ characters ▁ are ▁ repeating ▁ or ▁ string ▁ is ▁ empty " )
else :
    print ( " First ▁ non - repeating ▁ character ▁ is " , string [ index ] )

Index/key variables: i, index
Iterator variables: i
Python program:
def cipher ( str ) :
    for i in range ( len ( str ) ) :
        if str [ i ] . isalpha ( ) == 0 and str [ i ] != " ▁ " :
            print ( " Enter ▁ only ▁ alphabets ▁ and ▁ space " )
            return
    print ( " Encrypted ▁ Code ▁ using ▁ Latin ▁ Alphabet " )
    for i in range ( len ( str ) ) :
        if str [ i ] >= " A " and str [ i ] <= " Z " :
            print ( ord ( str [ i ] ) - ord ( " A " ) + 1 , end = " ▁ " )
        elif str [ i ] >= " a " and str [ i ] <= ' z ' :
            print ( ord ( str [ i ] ) - ord ( " a " ) + 1 , end = " ▁ " )
        if str [ i ] == " ▁ " :
            print ( str [ i ] )
    print ( )
if __name__ == " _ _ main _ _ " :
    str = " geeksforgeeks "
    cipher ( str )

Index/key variables: i
Iterator variables: i
Python program:
def checkPalin ( word ) :
    if word . lower ( ) == word . lower ( ) [ : : - 1 ] :
        return True
def countPalin ( str ) :
    count = 0
    listOfWords = str . split ( " ▁ " )
    for elements in listOfWords :
        if ( checkPalin ( elements ) ) :
            count += 1
    print ( count )
countPalin ( " Madam ▁ Arora ▁ teaches ▁ malayalam " )
countPalin ( " Nitin ▁ speaks ▁ malayalam " )

Accumulator variables: count
Iterator variables: elements
Python program:
pre = [ False ] * 100
s = [ None ] * 110
def verify ( position , index ) :
    l = len ( w )
    k = len ( s [ index ] )
    if ( position + k > l ) :
        return
    same = True
    for i in range ( position , position + k ) :
        ch = w [ i ]
        ch1 = s [ index ] [ i - position ]
        if ( ch >= ' a ' and ch <= ' z ' ) :
            n = ord ( ch ) - ord ( ' a ' )
        else :
            n = ord ( ch ) - ord ( ' A ' )
        if ( ch1 >= ' a ' and ch1 <= ' z ' ) :
            n1 = ord ( ch1 ) - ord ( ' a ' )
        else :
            n1 = ord ( ch1 ) - ord ( ' A ' )
        if ( n != n1 ) :
            same = False
    if ( same == True ) :
        for i in range ( position , position + k ) :
            pre [ i ] = True
        return
def solve ( ) :
    l = len ( w )
    p = ord ( letter ) - ord ( ' a ' )
    for i in range ( l ) :
        for j in range ( n ) :
            verify ( i , j )
    for i in range ( l ) :
        if ( pre [ i ] == True ) :
            if ( w [ i ] == letter ) :
                w [ i ] = ' b ' if ( letter == ' a ' ) else ' a '
            elif ( w [ i ] == str ( ord ( ' A ' ) + p ) ) :
                w [ i ] = ' B ' if ( letter == ' a ' ) else ' A '
            elif ( w [ i ] >= ' a ' and w [ i ] <= ' z ' ) :
                w [ i ] = letter
            elif ( w [ i ] >= ' A ' and w [ i ] <= ' Z ' ) :
                w [ i ] = chr ( ord ( ' A ' ) + p )
    print ( ' ' . join ( w ) )
n = 3
s [ 0 ] = " etr "
s [ 1 ] = " ed "
s [ 2 ] = " ied "
w = " PEtrUnited "
w = list ( w )
letter = ' d '
solve ( )

Index/key variables: i, index
Iterator variables: i, j
Boolean variables: same
Python program:
def calculate ( N ) :
    length = len ( N )
    l = int ( ( length ) / 2 )
    count = 0
    for i in range ( l + 1 ) :
        s = N [ 0 : 0 + i ]
        l1 = len ( s )
        t = N [ i : l1 + i ]
        try :
            if s [ 0 ] == '0' or t [ 0 ] == '0' :
                continue
        except :
            continue
        if s == t :
            count += 1
    return count
N = str ( "2202200" )
print ( calculate ( N ) )

Accumulator variables: count
Iterator variables: i
Python program:
def printStrongNess ( input_string ) :
    n = len ( input_string )
    hasLower = False
    hasUpper = False
    hasDigit = False
    specialChar = False
    normalChars = " abcdefghijklmnopqrstu "
    for i in range ( n ) :
        if input_string [ i ] . islower ( ) :
            hasLower = True
        if input_string [ i ] . isupper ( ) :
            hasUpper = True
        if input_string [ i ] . isdigit ( ) :
            hasDigit = True
        if input_string [ i ] not in normalChars :
            specialChar = True
    print ( " Strength ▁ of ▁ password : - " , end = " " )
    if ( hasLower and hasUpper and hasDigit and specialChar and n >= 8 ) :
        print ( " Strong " )
    elif ( ( hasLower or hasUpper ) and specialChar and n >= 6 ) :
        print ( " Moderate " )
    else :
        print ( " Weak " )
if __name__ == " _ _ main _ _ " :
    input_string = " GeeksforGeeks ! @12"
    printStrongNess ( input_string )

Index/key variables: i
Iterator variables: i
Boolean variables: hasDigit, hasLower, hasUpper, specialChar
Python program:
def findString ( n , k ) :
    res = " "
    for i in range ( k ) :
        res = res + chr ( ord ( ' a ' ) + i )
    count = 0
    for i in range ( n - k ) :
        res = res + chr ( ord ( ' a ' ) + count )
        count += 1
        if ( count == k ) :
            count = 0 ;
    return res
if __name__ == " _ _ main _ _ " :
    n = 5
    k = 2
    print ( findString ( n , k ) )

Accumulator variables: count
Iterator variables: i
Python program:
def isVowel ( x ) :
    return ( x == ' a ' or x == ' e ' or x == ' i ' or x == ' o ' or x == ' u ' ) ;
def FindSubstring ( str ) :
    start = 0 ;
    for i in range ( len ( str ) ) :
        if ( isVowel ( str [ i ] ) == True ) :
            hash . add ( str [ i ] ) ;
            if ( len ( hash ) == 5 ) :
                print ( str [ start : i + 1 ] , end = " ▁ " ) ;
        else :
            start = i + 1 ;
            hash . clear ( ) ;
str = " aeoibsddaeiouudb " ;
FindSubstring ( str ) ;

Index/key variables: i
Accumulator variables: hash
Iterator variables: i
Python program:
def concatenetedString ( s1 , s2 ) :
    m = { }
    for i in range ( 0 , len ( s2 ) ) :
        m [ s2 [ i ] ] = 1
    for i in range ( 0 , len ( s1 ) ) :
        if ( not s1 [ i ] in m ) :
            res = res + s1 [ i ]
        else :
            m [ s1 [ i ] ] = 2
    for i in range ( 0 , len ( s2 ) ) :
        if ( m [ s2 [ i ] ] == 1 ) :
            res = res + s2 [ i ]
    return res
if __name__ == " _ _ main _ _ " :
    s1 = " abcs "
    s2 = " cxzca "
    print ( concatenetedString ( s1 , s2 ) )

Index/key variables: i
Iterator variables: i
Python program:
def decode ( string ) :
    res = " "
    found = False
    for character in string :
        if character == ' ▁ ' :
            found = False
            continue
        if not found :
            if character >= ' A ' and character <= ' Z ' or character >= ' a ' and character <= ' z ' :
                res += character
                found = True
    return res . lower ( )
if __name__ == " _ _ main _ _ " :
    input = " A ▁ Step ▁ by ▁ Step ▁ Guide ▁ for ▁ Placement ▁ Preparation ▁ by ▁ GeeksforGeeks "
    print ( " Enciphered ▁ Message : " , decode ( input ) )

Accumulator variables: res
Iterator variables: character
Boolean variables: found
Python program:
def printRotatedString ( string ) :
    n = len ( string )
    temp = string + string
    for i in range ( n ) :
        for j in range ( n ) :
            print ( temp [ i + j ] , end = " " )
        print ( )
if __name__ == " _ _ main _ _ " :
    string = " geeks "
    printRotatedString ( string )

Iterator variables: i, j
Python program:
M = 26
def getIdx ( ch ) :
    return ( ord ( ch ) - ord ( ' a ' ) )
def allSame ( freq , N ) :
    for i in range ( 0 , N ) :
        if ( freq [ i ] > 0 ) :
            same = freq [ i ]
            break
    for j in range ( i + 1 , N ) :
        if ( freq [ j ] > 0 and freq [ j ] != same ) :
            return False
    return True
def possibleSameCharFreqByOneRemoval ( str1 ) :
    l = len ( str1 )
    freq = [ 0 ] * M
    for i in range ( 0 , l ) :
        freq [ getIdx ( str1 [ i ] ) ] += 1
    if ( allSame ( freq , M ) ) :
        return True
    for i in range ( 0 , 26 ) :
        if ( freq [ i ] > 0 ) :
            freq [ i ] -= 1
            if ( allSame ( freq , M ) ) :
                return True
            freq [ i ] += 1
    return False
if __name__ == " _ _ main _ _ " :
    str1 = " xyyzz "
    if ( possibleSameCharFreqByOneRemoval ( str1 ) ) :
        print ( " Yes " )
    else :
        print ( " No " )

Index/key variables: i, j
Iterator variables: i, j
Python program:
def check ( st ) :
    n = len ( st )
    oddDigSum = 0
    evenDigSum = 0
    for i in range ( 0 , n ) :
        if ( i % 2 == 0 ) :
            oddDigSum = oddDigSum + ( ( int ) ( st [ i ] ) )
        else :
            evenDigSum = evenDigSum + ( ( int ) ( st [ i ] ) )
    return ( ( oddDigSum - evenDigSum ) % 11 == 0 )
st = "76945"
if ( check ( st ) ) :
    print ( " Yes " )
else :
    print ( " No ▁ " )

Index/key variables: i
Iterator variables: i
Python program:
def hammingDist ( str1 , str2 ) :
    i = 0
    count = 0
    while ( i < len ( str1 ) ) :
        if ( str1 [ i ] != str2 [ i ] ) :
            count += 1
        i += 1
    return count
str1 = " geekspractice "
str2 = " nerdspractise "
print ( hammingDist ( str1 , str2 ) )

Index/key variables: i
Accumulator variables: count
Python program:
MAX_CHAR = 26
def arekAnagrams ( str1 , str2 , k ) :
    n = len ( str1 )
    if ( len ( str2 ) != n ) :
        return False
    count1 = [ 0 ] * MAX_CHAR
    count2 = [ 0 ] * MAX_CHAR
    for i in range ( n ) :
        count1 [ ord ( str1 [ i ] ) - ord ( ' a ' ) ] += 1
    for i in range ( n ) :
        count2 [ ord ( str2 [ i ] ) - ord ( ' a ' ) ] += 1
    count = 0
    for i in range ( MAX_CHAR ) :
        if ( count1 [ i ] > count2 [ i ] ) :
            count = count + abs ( count1 [ i ] - count2 [ i ] )
    return ( count <= k )
if __name__ == ' _ _ main _ _ ' :
    str1 = " anagram "
    str2 = " grammar "
    k = 2
    if ( arekAnagrams ( str1 , str2 , k ) ) :
        print ( " Yes " )
    else :
        print ( " No " )

Index/key variables: i
Iterator variables: i
Python program:
def countSubStr ( st , n ) :
    m = 0
    for i in range ( 0 , n ) :
        if ( st [ i ] == '1' ) :
            m = m + 1
    return m * ( m - 1 ) // 2
st = "00100101" ;
list ( st )
n = len ( st )
print ( countSubStr ( st , n ) , end = " " )

Index/key variables: i
Iterator variables: i
Python program:
def count9s ( number ) :
    n = len ( number )
    for i in range ( n ) :
        sum = ord ( number [ i ] ) - ord ( '0' )
        if ( number [ i ] == '9' ) :
            count += 1
        for j in range ( i + 1 , n ) :
            sum = ( sum + ord ( number [ j ] ) - ord ( '0' ) ) % 9
            if ( sum == 0 ) :
                count += 1
    return count
if __name__ == " _ _ main _ _ " :
    print ( count9s ( "4189" ) )
    print ( count9s ( "1809" ) )

Index/key variables: i, j
Accumulator variables: count
Iterator variables: i, j
Python program:
import math as mt
def generateGrayarr ( n ) :
    if ( n <= 0 ) :
        return
    arr = list ( )
    arr . append ( "0" )
    arr . append ( "1" )
    i = 2
    j = 0
    while ( True ) :
        if i >= 1 << n :
            break
        for j in range ( i - 1 , - 1 , - 1 ) :
            arr . append ( arr [ j ] )
        for j in range ( i ) :
            arr [ j ] = "0" + arr [ j ]
        for j in range ( i , 2 * i ) :
            arr [ j ] = "1" + arr [ j ]
        i = i << 1
    for i in range ( len ( arr ) ) :
        print ( arr [ i ] )
generateGrayarr ( 3 )

Index/key variables: i, j
Accumulator variables: arr
Iterator variables: i, j
Python program:
from typing import List
MAX = 5
def isSafe ( row : int , col : int , m : List [ List [ int ] ] , n : int , visited : List [ List [ bool ] ] ) -> bool :
    if ( row == - 1 or row == n or col == - 1 or col == n or visited [ row ] [ col ] or m [ row ] [ col ] == 0 ) :
        return False
    return True
def printPathUtil ( row : int , col : int , m : List [ List [ int ] ] , n : int , path : str , possiblePaths : List [ str ] , visited : List [ List [ bool ] ] ) -> None :
    if ( row == - 1 or row == n or col == - 1 or col == n or visited [ row ] [ col ] or m [ row ] [ col ] == 0 ) :
        return
    if ( row == n - 1 and col == n - 1 ) :
        possiblePaths . append ( path )
        return
    visited [ row ] [ col ] = True
    if ( isSafe ( row + 1 , col , m , n , visited ) ) :
        path += ' D '
        printPathUtil ( row + 1 , col , m , n , path , possiblePaths , visited )
        path = path [ : - 1 ]
    if ( isSafe ( row , col - 1 , m , n , visited ) ) :
        path += ' L '
        printPathUtil ( row , col - 1 , m , n , path , possiblePaths , visited )
        path = path [ : - 1 ]
    if ( isSafe ( row , col + 1 , m , n , visited ) ) :
        path += ' R '
        printPathUtil ( row , col + 1 , m , n , path , possiblePaths , visited )
        path = path [ : - 1 ]
    if ( isSafe ( row - 1 , col , m , n , visited ) ) :
        path += ' U '
        printPathUtil ( row - 1 , col , m , n , path , possiblePaths , visited )
        path = path [ : - 1 ]
    visited [ row ] [ col ] = False
def printPath ( m : List [ List [ int ] ] , n : int ) -> None :
    possiblePaths = [ ]
    path = " "
    visited = [ [ False for _ in range ( MAX ) ] for _ in range ( n ) ]
    printPathUtil ( 0 , 0 , m , n , path , possiblePaths , visited )
    for i in range ( len ( possiblePaths ) ) :
        print ( possiblePaths [ i ] , end = " ▁ " )
if __name__ == " _ _ main _ _ " :
    m = [ [ 1 , 0 , 0 , 0 , 0 ] , [ 1 , 1 , 1 , 1 , 1 ] , [ 1 , 1 , 1 , 0 , 1 ] , [ 0 , 0 , 0 , 0 , 1 ] , [ 0 , 0 , 0 , 0 , 1 ] ]
    n = len ( m )
    printPath ( m , n )

Index/key variables: bool, col, i, int, row, str
Iterator variables: i
Python program:
class GfG :
    def __init__ ( self ) :
        self . MAX = 10
        self . arr = [ 0 ] * self . MAX
        self . no = 0
    def breakLine ( self ) :
        print ( " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " )
    def canPlace ( self , k , i ) :
        for j in range ( 1 , k ) :
            if ( self . arr [ j ] == i or ( abs ( self . arr [ j ] - i ) == abs ( j - k ) ) ) :
                return False
        return True
    def display ( self , n ) :
        self . breakLine ( )
        self . no += 1
        print ( " Arrangement ▁ No . " , self . no , end = " ▁ " )
        self . breakLine ( )
        for i in range ( 1 , n + 1 ) :
            for j in range ( 1 , n + 1 ) :
                if self . arr [ i ] != j :
                    print ( " TABSYMBOL _ " , end = " ▁ " )
                else :
                    print ( " TABSYMBOL Q " , end = " ▁ " )
            print ( )
        self . breakLine ( )
    def nQueens ( self , k , n ) :
        for i in range ( 1 , n + 1 ) :
            if self . canPlace ( k , i ) :
                self . arr [ k ] = i
                if k == n :
                    self . display ( n )
                else :
                    self . nQueens ( k + 1 , n )
if __name__ == ' _ _ main _ _ ' :
    n = 4
    obj = GfG ( )
    obj . nQueens ( 1 , n )

Index/key variables: i, j, k
Iterator variables: i, j
Class/struct names: GfG
Python program:
A = [ 11 , 15 , 7 , 19 ]
N = len ( A )
Set = set ( )
for i in range ( 0 , N ) :
    for j in range ( i , N ) :
        res &= A [ j ]
        Set . add ( res )
print ( Set )

Index/key variables: j
Accumulator variables: Set, res
Iterator variables: i, j
Python program:
def minStepsRecur ( height , l , r , h ) :
    if l >= r :
        return 0 ;
    m = l
    for i in range ( l , r ) :
        if height [ i ] < height [ m ] :
            m = i
    return min ( r - l , minStepsRecur ( height , l , m , height [ m ] ) + minStepsRecur ( height , m + 1 , r , height [ m ] ) + height [ m ] - h )
def minSteps ( height , N ) :
    return minStepsRecur ( height , 0 , N , 0 )
height = [ 2 , 1 , 2 , 5 , 1 ]
N = len ( height )
print ( minSteps ( height , N ) )

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