dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long a [ 65 ] = { 0 } ; long long Count ( int i ) { if ( i == 0 ) return 1 ; else if ( i < 0 ) return 0 ; if ( a [ i ] == 0 ) { a [ i ] = ( i + 1 ) + 2 * Count ( i - 1 ) ; return a [ i ] ; } else return a [ i ] ; } long long solve ( long long n ) { long long i , sum = 0 ; while ( n > 0 ) { i = log2 ( n ) ; n = n - pow ( 2 , i ) ; sum = sum + ( i + 1 ) + Count ( i - 1 ) ; } return sum ; } int main ( ) { long long n = 7 ; cout << solve ( n ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; pair < int , int > count_ht ( char s , int N ) { pair < int , int > p ; if ( s == ' H ' ) { p . first = floor ( N / 2.0 ) ; p . second = ceil ( N / 2.0 ) ; } else if ( s == ' T ' ) { p . first = ceil ( N / 2.0 ) ; p . second = floor ( N / 2.0 ) ; } return p ; } int main ( ) { char C = ' H ' ; int N = 5 ; pair < int , int > p = count_ht ( C , N ) ; cout << " Head ▁ = ▁ " << ( p . first ) << " STRNEWLINE " ; cout << " Tail ▁ = ▁ " << ( p . second ) << " STRNEWLINE " ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; string findPalindrome ( string C ) { string S = C ; reverse ( S . begin ( ) , S . end ( ) ) ; C = C + " & " + S ; int n = C . length ( ) ; int longestPalindrome [ n ] ; longestPalindrome [ 0 ] = 0 ; int len = 0 ; int i = 1 ; while ( i < n ) { if ( C [ i ] == C [ len ] ) { len ++ ; longestPalindrome [ i ] = len ; i ++ ; } else { if ( len != 0 ) { len = longestPalindrome [ len - 1 ] ; } else { longestPalindrome [ i ] = 0 ; i ++ ; } } } string ans = C . substr ( 0 , longestPalindrome [ n - 1 ] ) ; return ans ; } string findAns ( string s ) { string A = " " ; string B = " " ; string F = " " ; int i = 0 ; int j = s . length ( ) - 1 ; int len = s . length ( ) ; while ( i < j && s [ i ] == s [ j ] ) { i = i + 1 ; j = j - 1 ; } if ( i > 0 ) { A = s . substr ( 0 , i ) ; B = s . substr ( len - i , i ) ; } if ( len > 2 * i ) { string C = s . substr ( i , s . length ( ) - 2 * i ) ; string D = findPalindrome ( C ) ; reverse ( C . begin ( ) , C . end ( ) ) ; string E = findPalindrome ( C ) ; if ( D . length ( ) > E . length ( ) ) { F = D ; } else { F = E ; } } string answer = A + F + B ; return answer ; } int main ( ) { string str = " abcdefghiedcba " ; cout << findAns ( str ) << endl ; }

Index/key variables: i, j, len, n
Accumulator variables: i, len, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int nthTerm ( int N ) { int nth = 0 ; if ( N % 2 == 1 ) nth = ( N * N ) + 1 ; else nth = ( N * N ) - 1 ; return nth ; } int main ( ) { int N = 5 ; cout << nthTerm ( N ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int nthTerm ( int N ) { int nth = 0 , first_term = 12 ; nth = ( first_term * ( pow ( 2 , N - 1 ) ) ) + 11 * ( ( pow ( 2 , N - 1 ) ) - 1 ) ; return nth ; } int main ( ) { int N = 5 ; cout << nthTerm ( N ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int nthTerm ( int N ) { int nth = 0 , first_term = 4 ; int pi = 1 , po = 1 ; int n = N ; while ( n > 1 ) { pi *= n - 1 ; n -- ; po *= 2 ; } nth = ( first_term * pi ) / po ; return nth ; } int main ( ) { int N = 5 ; cout << nthTerm ( N ) << endl ; return 0 ; }

Accumulator variables: n, pi, po, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int finalNum ( int arr [ ] , int n ) { int result = 0 ; for ( int i = 0 ; i < n ; i ++ ) { result = __gcd ( result , arr [ i ] ) ; } return result ; } int main ( ) { int arr [ ] = { 3 , 9 , 6 , 36 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << finalNum ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isVowel ( char ch ) { switch ( ch ) { case ' a ' : case ' e ' : case ' i ' : case ' o ' : case ' u ' : return true ; } return false ; } bool isSatisfied ( string str , int n ) { for ( int i = 1 ; i < n ; i ++ ) { if ( ! isVowel ( str [ i ] ) && ! isVowel ( str [ i - 1 ] ) ) { return false ; } } for ( int i = 1 ; i < n - 1 ; i ++ ) { if ( isVowel ( str [ i ] ) && ! isVowel ( str [ i - 1 ] ) && ! isVowel ( str [ i + 1 ] ) ) { return false ; } } return true ; } int main ( ) { string str = " acaba " ; int n = str . length ( ) ; if ( isSatisfied ( str , n ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int LengthlongestPrefixSuffix ( string s ) { int n = s . length ( ) ; int lps [ n ] ; lps [ 0 ] = 0 ; int len = 0 ; int i = 1 ; while ( i < n ) { if ( s [ i ] == s [ len ] ) { len ++ ; lps [ i ] = len ; i ++ ; } else { if ( len != 0 ) { len = lps [ len - 1 ] ; } else { lps [ i ] = 0 ; i ++ ; } } } int res = lps [ n - 1 ] ; return ( res > n / 2 ) ? n / 2 : res ; } string longestPrefixSuffix ( string s ) { int len = LengthlongestPrefixSuffix ( s ) ; string prefix = " " ; for ( int i = 0 ; i < len ; i ++ ) prefix += s [ i ] ; return prefix ; } int main ( ) { string s = " abcab " ; string ans = longestPrefixSuffix ( s ) ; if ( ans == " " ) cout << " - 1" ; else cout << ans ; return 0 ; }

Index/key variables: i, len, n
Accumulator variables: i, len, prefix, stdc
Iterator variables: i
C++ program:
#include <cmath>
#include <iostream>
using namespace std ; int no_of_characters ( int M ) { int k = 1 ; while ( true ) { if ( pow ( 2 , k + 1 ) - 2 < M ) k ++ ; else break ; } return k ; } void print_string ( int M ) { int k , num , N ; k = no_of_characters ( M ) ; N = M - ( pow ( 2 , k ) - 2 ) ; while ( k > 0 ) { num = pow ( 2 , k - 1 ) ; if ( num >= N ) cout << " A " ; else { cout << " B " ; N -= num ; } k -- ; } cout << endl ; } int main ( ) { int M ; M = 30 ; print_string ( M ) ; M = 55 ; print_string ( M ) ; M = 100 ; print_string ( M ) ; return 0 ; }

Accumulator variables: N, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; string updateString ( string S , string A , string B ) { int l = A . length ( ) ; for ( int i = 0 ; i + l <= S . length ( ) ; i ++ ) { string curr = S . substr ( i , i + l ) ; if ( curr == A ) { string new_string = " " ; new_string += S . substr ( 0 , i ) + B + S . substr ( i + l , S . length ( ) ) ; S = new_string ; i += l - 1 ; } else { string new_string = " " ; new_string += S . substr ( 0 , i ) + A + S . substr ( i + l , S . length ( ) ) ; S = new_string ; i += l - 1 ; } } return S ; } int main ( ) { string S = " aab " ; string A = " aa " ; string B = " bb " ; cout << ( updateString ( S , A , B ) ) << endl ; }

Accumulator variables: i, new_string, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printPattern ( int n , int m ) { if ( m > 2 * ( n + 1 ) m < n - 1 ) { cout << " - 1" ; } else if ( abs ( n - m ) <= 1 ) { while ( n > 0 && m > 0 ) { cout << "01" ; n -- ; m -- ; } if ( n != 0 ) { cout << "0" ; } if ( m != 0 ) { cout << "1" ; } } else { while ( m - n > 1 && n > 0 ) { cout << "110" ; m = m - 2 ; n = n - 1 ; } while ( n > 0 ) { cout << "10" ; n -- ; m -- ; } while ( m > 0 ) { cout << "1" ; m -- ; } } } int main ( ) { int n = 4 , m = 8 ; printPattern ( n , m ) ; return 0 ; }

Accumulator variables: m, n, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countDecreasing ( int A [ ] , int n ) { int len = 1 ; for ( int i = 0 ; i < n - 1 ; ++ i ) { if ( A [ i + 1 ] < A [ i ] ) len ++ ; else { cnt += ( ( ( len - 1 ) * len ) / 2 ) ; len = 1 ; } } if ( len > 1 ) cnt += ( ( ( len - 1 ) * len ) / 2 ) ; return cnt ; } int main ( ) { int A [ ] = { 100 , 3 , 1 , 13 } ; int n = sizeof ( A ) / sizeof ( A [ 0 ] ) ; cout << countDecreasing ( A , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cnt, len, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimumChar ( string S1 , string S2 ) { int n = S1 . size ( ) , m = S2 . size ( ) ; int ans = INT_MAX ; for ( int i = 0 ; i < m - n + 1 ; i ++ ) { int minRemovedChar = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( S1 [ j ] != S2 [ i + j ] ) { minRemovedChar ++ ; } } ans = min ( minRemovedChar , ans ) ; } return ans ; } int main ( ) { string S1 = " abc " ; string S2 = " paxzk " ; cout << minimumChar ( S1 , S2 ) ; return 0 ; }

Index/key variables: j
Accumulator variables: i, j, minRemovedChar, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countFreq ( string & pat , string & txt ) { int M = pat . length ( ) ; int N = txt . length ( ) ; int res = 0 ; for ( int i = 0 ; i <= N - M ; i ++ ) { int j ; for ( j = 0 ; j < M ; j ++ ) if ( txt [ i + j ] != pat [ j ] ) break ; if ( j == M ) { res ++ ; j = 0 ; } } return res ; } int main ( ) { string txt = " dhimanman " ; string pat = " man " ; cout << countFreq ( pat , txt ) ; return 0 ; }

Index/key variables: j
Accumulator variables: i, j, res, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMissingDigit ( string a , string b , string c ) { int w = 1 ; int a_mod_11 = 0 ; for ( int i = a . size ( ) - 1 ; i >= 0 ; i -- ) { a_mod_11 = ( a_mod_11 + w * ( a [ i ] - '0' ) ) % 11 ; w = w * -1 ; } int b_mod_11 = 0 ; w = 1 ; for ( int i = b . size ( ) - 1 ; i >= 0 ; i -- ) { b_mod_11 = ( b_mod_11 + w * ( b [ i ] - '0' ) ) % 11 ; w = w * -1 ; } int c_mod_11 = 0 ; bool xSignIsPositive = true ; w = 1 ; for ( int i = c . size ( ) - 1 ; i >= 0 ; i -- ) { if ( c [ i ] == ' x ' ) { xSignIsPositive = ( w == 1 ) ; } else { c_mod_11 = ( c_mod_11 + w * ( c [ i ] - '0' ) ) % 11 ; } w = w * -1 ; } int x = ( ( a_mod_11 * b_mod_11 ) - c_mod_11 ) % 11 ; if ( ! xSignIsPositive ) { x = - x ; } return ( x % 11 + 11 ) % 11 ; } int main ( ) { string A = "123456789" ; string B = "987654321" ; string C = "12193263111x635269" ; cout << findMissingDigit ( A , B , C ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
Boolean variables: xSignIsPositive
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findIfPossible ( int N , string str ) { int countG = 0 , countF = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( str [ i ] == ' G ' ) countG ++ ; else countF ++ ; } if ( 2 * countF != countG ) { cout << " NO STRNEWLINE " ; } else { int id = 0 ; bool flag = true ; for ( int i = 0 ; i < N ; i ++ ) { if ( str [ i ] == ' G ' ) { countG -- ; id ++ ; } else { countF -- ; id -- ; } if ( id < 0 ) { flag = false ; break ; } if ( countG < countF ) { flag = false ; break ; } } if ( flag ) { cout << " YES STRNEWLINE " ; } else { cout << " NO STRNEWLINE " ; } } } int main ( ) { int n = 6 ; string str = " GFGFGG " ; findIfPossible ( n , str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: countF, countG, i, id, stdc
Iterator variables: i
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; void isPossible ( string str1 , string str2 ) { int arr [ 256 ] = { 0 } ; int l1 = str1 . size ( ) ; int l2 = str2 . size ( ) ; int i , j ; bool possible = true ; for ( i = 0 ; i < l1 ; i ++ ) { arr [ str1 [ i ] ] = 1 ; } for ( i = 0 ; i < l2 ; i ++ ) { if ( str2 [ i ] != ' ▁ ' ) { if ( arr [ str2 [ i ] ] == 1 ) continue ; else { possible = false ; break ; } } } if ( possible ) { cout << " Yes " << endl ; } else { cout << " No " << endl ; } } int main ( ) { string str1 = " we ▁ all ▁ love ▁ geeksforgeeks " ; string str2 = " we ▁ all ▁ love ▁ geeks " ; isPossible ( str1 , str2 ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
Boolean variables: possible
C++ program:
#include <bits/stdc++.h>
using namespace std ; int find_Min_Inversion ( int n , string s1 , string s2 ) { int count = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( s1 [ i ] != s2 [ i ] ) { if ( s1 [ i ] == '1' ) { s1 [ i ] = '0' ; } else { s1 [ i ] = '1' ; } if ( s1 [ i + 1 ] == '1' ) { s1 [ i + 1 ] = '0' ; } else { s1 [ i + 1 ] = '1' ; } count ++ ; } } if ( s1 == s2 ) { return count ; } return -1 ; } int main ( ) { int n = 4 ; string s1 = "0101" ; string s2 = "1111" ; cout << find_Min_Inversion ( n , s1 , s2 ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findSubsequence ( string S , char ch ) { int N = S . length ( ) ; int ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( S [ i ] == ch ) { ans ++ ; ch ++ ; } } return ans ; } int findMaxSubsequence ( string S ) { int ans = 0 ; for ( char ch = ' a ' ; ch <= ' z ' ; ch ++ ) { ans = max ( ans , findSubsequence ( S , ch ) ) ; } return ans ; } int main ( ) { string S = " abcabefghijk " ; cout << findMaxSubsequence ( S ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, ch, i, stdc
Iterator variables: ch, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minOpsToEmptyString ( string s ) { int ans = INT_MIN ; int cn0 = 0 ; int cn1 = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s [ i ] == '0' ) { if ( cn1 > 0 ) cn1 -- ; cn0 ++ ; } else { if ( cn0 > 0 ) cn0 -- ; cn1 ++ ; } ans = max ( { ans , cn0 , cn1 } ) ; } cout << ans ; } int main ( ) { string S = "010101" ; minOpsToEmptyString ( S ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cn0, cn1, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int shortestString ( string S , int N ) { int st = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( st && S [ i ] == '1' ) { st -- ; } else { st ++ ; } } return st ; } int main ( ) { string S = "1010" ; int N = S . length ( ) ; cout << shortestString ( S , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, st, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findLength ( string str , int n ) { int pre [ n ] , post [ n ] ; memset ( pre , 0 , sizeof ( pre ) ) ; memset ( post , 0 , sizeof ( post ) ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( i != 0 ) { pre [ i ] += pre [ i - 1 ] ; } if ( str [ i ] == '1' ) { pre [ i ] += 1 ; } } for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( i != n - 1 ) post [ i ] += post [ i + 1 ] ; if ( str [ i ] == '0' ) post [ i ] += 1 ; } int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ans = max ( ans , pre [ i ] + post [ i ] ) ; } return ans ; } int main ( ) { string S = "0101110110100001011" ; cout << findLength ( S , S . length ( ) ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSubstring ( string & S , int N ) { unordered_map < int , int > prevSum ; int res = 0 ; int currentSum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( S [ i ] >= ' A ' and S [ i ] <= ' Z ' ) { currentSum ++ ; } else currentSum -- ; if ( currentSum == 0 ) res ++ ; if ( prevSum . find ( currentSum ) != prevSum . end ( ) ) { res += ( prevSum [ currentSum ] ) ; } prevSum [ currentSum ] ++ ; } return res ; } int main ( ) { string S = " gEEk " ; cout << countSubstring ( S , S . length ( ) ) ; return 0 ; }

Index/key variables: currentSum, i
Accumulator variables: currentSum, i, res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void countStringPairs ( string a [ ] , int n ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { string p = a [ i ] , q = a [ j ] ; if ( p [ 0 ] != q [ 0 ] ) { swap ( p [ 0 ] , q [ 0 ] ) ; int flag1 = 0 ; int flag2 = 0 ; for ( int k = 0 ; k < n ; k ++ ) { if ( a [ k ] == p ) { flag1 = 1 ; } if ( a [ k ] == q ) { flag2 = 1 ; } } if ( flag1 == 0 && flag2 == 0 ) { ans = ans + 1 ; } } } } cout << ans ; } int main ( ) { string arr [ ] = { " good " , " bad " , " food " } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; countStringPairs ( arr , N ) ; return 0 ; }

Index/key variables: i, j, k
Accumulator variables: i, j, k, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; void addFrequencyToCharacter ( string s ) { int frequency [ 26 ] = { 0 } ; int n = s . size ( ) ; for ( int i = 0 ; i < n ; i ++ ) { frequency [ s [ i ] - ' a ' ] += 1 ; } for ( int i = 0 ; i < n ; i ++ ) { int add = frequency [ s [ i ] - ' a ' ] % 26 ; if ( int ( s [ i ] ) + add <= int ( ' z ' ) ) s [ i ] = char ( int ( s [ i ] ) + add ) ; else { add = ( int ( s [ i ] ) + add ) - ( int ( ' z ' ) ) ; s [ i ] = char ( int ( ' a ' ) + add - 1 ) ; } } cout << s ; } int main ( ) { string str = " geeks " ; addFrequencyToCharacter ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string isPossible ( string S , int R , int N ) { int cntl = 0 , cntr = 0 ; int cntu = 0 , cntd = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( S [ i ] == ' L ' ) cntl ++ ; else if ( S [ i ] == ' R ' ) cntr ++ ; else if ( S [ i ] == ' U ' ) cntu ++ ; else cntd ++ ; } if ( max ( max ( cntl , cntr ) , max ( cntu , cntd ) ) >= R ) return " Yes " ; unordered_map < int , int > mp ; int r_square = R * R ; for ( int i = 1 ; i * i <= r_square ; i ++ ) { mp [ i * i ] = i ; if ( mp . find ( r_square - i * i ) != mp . end ( ) ) { if ( max ( cntl , cntr ) >= mp [ r_square - i * i ] && max ( cntu , cntd ) >= i ) return " Yes " ; if ( max ( cntl , cntr ) >= i && max ( cntu , cntd ) >= mp [ r_square - i * i ] ) return " Yes " ; } } return " No " ; } int main ( ) { string S = " RDLLDDLDU " ; int R = 5 ; int N = S . length ( ) ; cout << isPossible ( S , R , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cntd, cntl, cntr, cntu, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void addASCII ( string S , string N ) { for ( int i = 0 ; i < S . size ( ) ; i ++ ) { int a = int ( N [ i ] ) - '0' ; int b = int ( S [ i ] ) + a ; if ( b > 122 ) b -= 26 ; S [ i ] = char ( b ) ; } cout << S ; } int main ( ) { string S = " sun " , N = "966" ; addASCII ( S , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: b, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string decHex ( int n ) { char alpha [ ] = { ' A ' , ' B ' , ' C ' , ' D ' , ' E ' , ' F ' } ; string ans ; while ( n > 0 ) { if ( n % 16 < 10 ) { ans += to_string ( n % 16 ) ; } else { ans += alpha [ n % 16 - 10 ] ; } n /= 16 ; } reverse ( ans . begin ( ) , ans . end ( ) ) ; return ans ; } int hexDec ( string convertedHex ) { char mp [ ] = { 10 , 11 , 12 , 13 , 14 , 15 } ; int ans = 0 ; int pos = 0 ; reverse ( convertedHex . begin ( ) , convertedHex . end ( ) ) ; for ( char ch : convertedHex ) { if ( isdigit ( ch ) ) { ans += ( ( int ) pow ( 16 , pos ) ) * ( ch - '0' ) ; } else { ans += ( ( int ) pow ( 16 , pos ) ) * mp [ ch - ' A ' ] ; } pos += 1 ; } return ans ; } string removeChars ( string hexaVal , string S ) { set < char > setk ; for ( char ch : S ) { setk . insert ( ch ) ; } string ans = " " ; for ( char ch : hexaVal ) { if ( setk . find ( ch ) != setk . end ( ) ) { continue ; } ans += ch ; } return ans ; } void convertArr ( int arr [ ] , int N , string S ) { for ( int i = 0 ; i < N ; i ++ ) { string hexaVal = decHex ( arr [ i ] ) ; string convertedHex = removeChars ( hexaVal , S ) ; int decVal = hexDec ( convertedHex ) ; arr [ i ] = decVal ; } for ( int i = 0 ; i < N ; i ++ ) { cout << arr [ i ] << " ▁ " ; } } int main ( ) { int arr [ ] = { 74 , 91 , 31 , 122 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; string S = "1AB " ; convertArr ( arr , N , S ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, n, pos, stdc
Iterator variables: ch, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMinimumChairs ( string s ) { int count = 0 ; int i = 0 ; int mini = INT_MIN ; while ( i < s . length ( ) ) { if ( s [ i ] == ' E ' ) count ++ ; else count -- ; mini = max ( count , mini ) ; i ++ ; } return mini ; } int main ( ) { string s = " EELEE " ; cout << findMinimumChairs ( s ) ; }

Index/key variables: i
Accumulator variables: count, i, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void fillString ( string s , int k ) { unordered_map < int , char > mp ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) { if ( s [ i ] != ' ? ' ) { mp [ i % k ] = s [ i ] ; } } for ( int i = 0 ; i < s . size ( ) ; i ++ ) { if ( mp . find ( i % k ) == mp . end ( ) ) { cout << -1 ; return ; } s [ i ] = mp [ i % k ] ; } cout << s ; } int main ( ) { string S = " ? ? ? ? abcd " ; int K = 4 ; fillString ( S , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void rearrangeString ( string s1 , string s2 ) { int cnt [ 26 ] = { 0 } ; for ( int i = 0 ; i < s2 . size ( ) ; i ++ ) cnt [ s2 [ i ] - ' a ' ] ++ ; int unique = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) if ( cnt [ i ] != 0 ) unique ++ ; if ( unique == 1 ) { int count_in_s2 = s2 . size ( ) ; int count_in_s1 = 0 ; for ( int i = 0 ; i < s1 . size ( ) ; i ++ ) if ( s1 [ i ] == s2 [ 0 ] ) count_in_s1 ++ ; if ( count_in_s1 < count_in_s2 ) { cout << s1 ; return ; } cout << -1 ; } else { int inc = 1 ; for ( int i = 0 ; i < s2 . size ( ) - 1 ; i ++ ) if ( s2 [ i ] > s2 [ i + 1 ] ) inc = 0 ; if ( inc == 1 ) { sort ( s1 . begin ( ) , s1 . end ( ) , greater < char > ( ) ) ; cout << s1 ; } else { sort ( s1 . begin ( ) , s1 . end ( ) ) ; cout << s1 ; } } } int main ( ) { string s1 = " abcd " , s2 = " ab " ; rearrangeString ( s1 , s2 ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count_in_s1, i, stdc, unique
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isReducible ( string str ) { int N = str . size ( ) ; stack < char > s ; for ( int i = 0 ; i < N ; i ++ ) { if ( str [ i ] == '1' ) s . push ( str [ i ] ) ; else if ( ! s . empty ( ) ) s . pop ( ) ; else return false ; } return s . empty ( ) ; } int main ( ) { string str = "11011000" ; if ( isReducible ( str ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool cntMinOperation ( string S , int N ) { int cntOp = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( S [ i ] == '0' && S [ i + 1 ] == '0' ) { S [ i + 1 ] = '1' ; cntOp += 1 ; } } return cntOp ; } int main ( ) { string S = "10001" ; int N = S . length ( ) ; cout << cntMinOperation ( S , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cntOp, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string solution ( string s ) { vector < char > vowel , consonant ; for ( auto i : s ) { if ( i == ' a ' i == ' e ' i == ' i ' i == ' o ' i == ' u ' ) { vowel . push_back ( i ) ; } else { consonant . push_back ( i ) ; } } int Nc , Nv ; Nv = vowel . size ( ) ; Nc = consonant . size ( ) ; int M = Nc / ( Nv - 1 ) ; string ans = " " ; int consotnant_till = 0 ; for ( auto i : vowel ) { ans += i ; int temp = 0 ; for ( int j = consotnant_till ; j < min ( Nc , consotnant_till + M ) ; j ++ ) { ans += consonant [ j ] ; temp ++ ; } consotnant_till += temp ; } return ans ; } int main ( ) { string str = " aaaabbbcc " ; cout << solution ( str ) ; return 0 ; }

Index/key variables: j
Accumulator variables: ans, consotnant_till, j, stdc, temp
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void smallestlexicographicstring ( string s , int k ) { int n = s . size ( ) ; if ( k >= n ) { for ( int i = 0 ; i < n ; i ++ ) { s [ i ] = ' a ' ; } cout << s ; return ; } for ( int i = 0 ; i < n ; i ++ ) { if ( k == 0 ) { break ; } if ( s [ i ] == ' a ' ) continue ; for ( int j = i + 1 ; j < n ; j ++ ) { if ( s [ j ] > s [ i ] ) { s [ j ] = s [ i ] ; break ; } else if ( j == n - 1 ) s [ j ] = s [ i ] ; } s [ i ] = ' a ' ; k -- ; } cout << s ; } int main ( ) { string s = " geeksforgeeks " ; int k = 6 ; smallestlexicographicstring ( s , k ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, k, stdc
Iterator variables: i, j