dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define SIZE  100
char * base64Decoder ( char encoded [ ] , int len_str ) { char * decoded_string ; decoded_string = ( char * ) malloc ( sizeof ( char ) * SIZE ) ; int i , j , k = 0 ; int num = 0 ; int count_bits = 0 ; for ( i = 0 ; i < len_str ; i += 4 ) { num = 0 , count_bits = 0 ; for ( j = 0 ; j < 4 ; j ++ ) { if ( encoded [ i + j ] != ' = ' ) { num = num << 6 ; count_bits += 6 ; } if ( encoded [ i + j ] >= ' A ' && encoded [ i + j ] <= ' Z ' ) num = num | ( encoded [ i + j ] - ' A ' ) ; else if ( encoded [ i + j ] >= ' a ' && encoded [ i + j ] <= ' z ' ) num = num | ( encoded [ i + j ] - ' a ' + 26 ) ; else if ( encoded [ i + j ] >= '0' && encoded [ i + j ] <= '9' ) num = num | ( encoded [ i + j ] - '0' + 52 ) ; else if ( encoded [ i + j ] == ' + ' ) num = num | 62 ; else if ( encoded [ i + j ] == ' / ' ) num = num | 63 ; else { num = num >> 2 ; count_bits -= 2 ; } } while ( count_bits != 0 ) { count_bits -= 8 ; decoded_string [ k ++ ] = ( num >> count_bits ) & 255 ; } } decoded_string [ k ] = ' \0' ; return decoded_string ; } int main ( ) { char encoded_string [ ] = " TUVOT04 = " ; int len_str = sizeof ( encoded_string ) / sizeof ( encoded_string [ 0 ] ) ; len_str -= 1 ; cout << " Encoded ▁ string ▁ : ▁ " << encoded_string << endl ; cout << " Decoded ▁ string ▁ : ▁ " << base64Decoder ( encoded_string , len_str ) << endl ; return 0 ; }

Index/key variables: k
Accumulator variables: count_bits, i, j, k, len_str, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printSubsequences ( string str ) { int n = str . length ( ) ; unsigned int opsize = pow ( 2 , n - 1 ) ; for ( int counter = 0 ; counter < opsize ; counter ++ ) { for ( int j = 0 ; j < n ; j ++ ) { cout << str [ j ] ; if ( counter & ( 1 << j ) ) cout << " ▁ " ; } cout << endl ; } } int main ( ) { string str = " ABC " ; printSubsequences ( str ) ; return 0 ; }

Index/key variables: j
Accumulator variables: counter, j, stdc
Iterator variables: counter, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ll  long long int
const int MAX_CHAR = 26 ; const int MAX_FACT = 20 ; ll fact [ MAX_FACT ] ; void precomputeFactorials ( ) { fact [ 0 ] = 1 ; for ( int i = 1 ; i < MAX_FACT ; i ++ ) fact [ i ] = fact [ i - 1 ] * i ; } void nPermute ( char str [ ] , int n ) { precomputeFactorials ( ) ; int len = strlen ( str ) ; int freq [ MAX_CHAR ] = { 0 } ; for ( int i = 0 ; i < len ; i ++ ) freq [ str [ i ] - ' a ' ] ++ ; char out [ MAX_CHAR ] ; int sum = 0 ; int k = 0 ; while ( sum != n ) { sum = 0 ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) { if ( freq [ i ] == 0 ) continue ; freq [ i ] -- ; int xsum = fact [ len - 1 - k ] ; for ( int j = 0 ; j < MAX_CHAR ; j ++ ) xsum /= fact [ freq [ j ] ] ; sum += xsum ; if ( sum >= n ) { out [ k ++ ] = i + ' a ' ; n -= ( sum - xsum ) ; break ; } if ( sum < n ) freq [ i ] ++ ; } } for ( int i = MAX_CHAR - 1 ; k < len && i >= 0 ; i -- ) if ( freq [ i ] ) { out [ k ++ ] = i + ' a ' ; freq [ i ++ ] -- ; } out [ k ] = ' \0' ; cout << out ; } int main ( ) { int n = 2 ; char str [ ] = " geeksquiz " ; nPermute ( str , n ) ; return 0 ; }

Index/key variables: MAX_CHAR, MAX_FACT, i, j, k
Accumulator variables: i, j, k, n, stdc, sum, xsum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countDeletions ( string str ) { int ans = 0 ; for ( int i = 0 ; i < str . length ( ) - 1 ; i ++ ) if ( str [ i ] == str [ i + 1 ] ) ans ++ ; return ans ; } int main ( ) { string str = " AAABBB " ; cout << countDeletions ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countWords ( string str [ ] , int n ) { unordered_map < string , int > m ; for ( int i = 0 ; i < n ; i ++ ) m [ str [ i ] ] += 1 ; int res = 0 ; for ( auto it = m . begin ( ) ; it != m . end ( ) ; it ++ ) if ( ( it -> second == 2 ) ) res ++ ; return res ; } int main ( ) { string s [ ] = { " hate " , " love " , " peace " , " love " , " peace " , " hate " , " love " , " peace " , " love " , " peace " } ; int n = sizeof ( s ) / sizeof ( s [ 0 ] ) ; cout << countWords ( s , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, it, res, stdc
Iterator variables: i, it
C++ program:
#include <iostream>
using namespace std ; #define V  4
bool colorGraph ( int G [ ] [ V ] , int color [ ] , int pos , int c ) { if ( color [ pos ] != -1 && color [ pos ] != c ) return false ; color [ pos ] = c ; bool ans = true ; for ( int i = 0 ; i < V ; i ++ ) { if ( G [ pos ] [ i ] ) { if ( color [ i ] == -1 ) ans &= colorGraph ( G , color , i , 1 - c ) ; if ( color [ i ] != -1 && color [ i ] != 1 - c ) return false ; } if ( ! ans ) return false ; } return true ; } bool isBipartite ( int G [ ] [ V ] ) { int color [ V ] ; for ( int i = 0 ; i < V ; i ++ ) color [ i ] = -1 ; int pos = 0 ; return colorGraph ( G , color , pos , 1 ) ; } int main ( ) { int G [ ] [ V ] = { { 0 , 1 , 0 , 1 } , { 1 , 0 , 1 , 0 } , { 0 , 1 , 0 , 1 } , { 1 , 0 , 1 , 0 } } ; isBipartite ( G ) ? cout << " Yes " : cout << " No " ; return 0 ; }

Index/key variables: V, i, pos
Accumulator variables: ans, i
Iterator variables: i
Boolean variables: ans
C++ program:
#include <bits/stdc++.h>
using namespace std ; string evenlength ( string n ) { string res = n ; for ( int j = n . length ( ) - 1 ; j >= 0 ; -- j ) res += n [ j ] ; return res ; } int main ( ) { string n = "10" ; cout << evenlength ( n ) ; return 0 ; }

Index/key variables: j
Accumulator variables: res, stdc
Iterator variables: j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool uniqueCharacters ( string str ) { for ( int i = 0 ; i < str . length ( ) - 1 ; i ++ ) { for ( int j = i + 1 ; j < str . length ( ) ; j ++ ) { if ( str [ i ] == str [ j ] ) { return false ; } } } return true ; } int main ( ) { string str = " GeeksforGeeks " ; if ( uniqueCharacters ( str ) ) { cout << " The ▁ String ▁ " << str << " ▁ has ▁ all ▁ unique ▁ characters STRNEWLINE " ; } else { cout << " The ▁ String ▁ " << str << " ▁ has ▁ duplicate ▁ characters STRNEWLINE " ; } return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool check ( string s ) { if ( s . size ( ) >= 10 ) return true ; for ( int i = 1 ; i < s . size ( ) ; i ++ ) { for ( int j = i + 1 ; j < s . size ( ) ; j ++ ) { for ( int k = j + 1 ; k < s . size ( ) ; k ++ ) { string s1 = s . substr ( 0 , i ) ; string s2 = s . substr ( i , j - i ) ; string s3 = s . substr ( j , k - j ) ; string s4 = s . substr ( k , s . size ( ) - k ) ; if ( s1 != s2 && s1 != s3 && s1 != s4 && s2 != s3 && s2 != s4 && s3 != s4 ) return true ; } } } return false ; } int main ( ) { string str = " aaabb " ; ( check ( str ) ) ? ( cout << " Yes " << endl ) : ( cout << " No " << endl ) ; return 0 ; }

Accumulator variables: i, j, k, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; string multiply ( string num1 , string num2 ) { int len1 = num1 . size ( ) ; int len2 = num2 . size ( ) ; if ( len1 == 0 len2 == 0 ) return "0" ; vector < int > result ( len1 + len2 , 0 ) ; int i_n1 = 0 ; int i_n2 = 0 ; for ( int i = len1 - 1 ; i >= 0 ; i -- ) { int carry = 0 ; int n1 = num1 [ i ] - '0' ; i_n2 = 0 ; for ( int j = len2 - 1 ; j >= 0 ; j -- ) { int n2 = num2 [ j ] - '0' ; int sum = n1 * n2 + result [ i_n1 + i_n2 ] + carry ; carry = sum / 10 ; result [ i_n1 + i_n2 ] = sum % 10 ; i_n2 ++ ; } if ( carry > 0 ) result [ i_n1 + i_n2 ] += carry ; i_n1 ++ ; } int i = result . size ( ) - 1 ; while ( i >= 0 && result [ i ] == 0 ) i -- ; if ( i == -1 ) return "0" ; string s = " " ; while ( i >= 0 ) s += std :: to_string ( result [ i -- ] ) ; return s ; } int main ( ) { string str1 = "1235421415454545454545454544" ; string str2 = "1714546546546545454544548544544545" ; if ( ( str1 . at ( 0 ) == ' - ' || str2 . at ( 0 ) == ' - ' ) && ( str1 . at ( 0 ) != ' - ' || str2 . at ( 0 ) != ' - ' ) ) cout << " - " ; if ( str1 . at ( 0 ) == ' - ' ) str1 = str1 . substr ( 1 ) ; if ( str2 . at ( 0 ) == ' - ' ) str2 = str2 . substr ( 1 ) ; cout << multiply ( str1 , str2 ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, i_n1, i_n2, j, s, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findIndex ( string str ) { int len = str . length ( ) ; int open [ len + 1 ] , close [ len + 1 ] ; int index = -1 ; memset ( open , 0 , sizeof ( open ) ) ; memset ( close , 0 , sizeof ( close ) ) ; open [ 0 ] = 0 ; close [ len ] = 0 ; if ( str [ 0 ] == ' ( ' ) open [ 1 ] = 1 ; if ( str [ len - 1 ] == ' ) ' ) close [ len - 1 ] = 1 ; for ( int i = 1 ; i < len ; i ++ ) { if ( str [ i ] == ' ( ' ) open [ i + 1 ] = open [ i ] + 1 ; else open [ i + 1 ] = open [ i ] ; } for ( int i = len - 2 ; i >= 0 ; i -- ) { if ( str [ i ] == ' ) ' ) close [ i ] = close [ i + 1 ] + 1 ; else close [ i ] = close [ i + 1 ] ; } if ( open [ len ] == 0 ) return len ; if ( close [ 0 ] == 0 ) return 0 ; for ( int i = 0 ; i <= len ; i ++ ) if ( open [ i ] == close [ i ] ) index = i ; return index ; } int main ( ) { string str = " ( ( ) ) ) ( ( ) ( ) ( ) ) ) ) " ; cout << findIndex ( str ) ; return 0 ; }

Index/key variables: i, len
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string decimalToBinary ( double num , int k_prec ) { string binary = " " ; int Integral = num ; double fractional = num - Integral ; while ( Integral ) { int rem = Integral % 2 ; binary . push_back ( rem + '0' ) ; Integral /= 2 ; } reverse ( binary . begin ( ) , binary . end ( ) ) ; binary . push_back ( ' . ' ) ; while ( k_prec -- ) { fractional *= 2 ; int fract_bit = fractional ; if ( fract_bit == 1 ) { fractional -= fract_bit ; binary . push_back ( 1 + '0' ) ; } else binary . push_back ( 0 + '0' ) ; } return binary ; } int main ( ) { double n = 4.47 ; int k = 3 ; cout << decimalToBinary ( n , k ) << " STRNEWLINE " ; n = 6.986 , k = 5 ; cout << decimalToBinary ( n , k ) ; return 0 ; }

Accumulator variables: Integral, fractional, k_prec, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isSmaller ( string str1 , string str2 ) { int n1 = str1 . length ( ) , n2 = str2 . length ( ) ; if ( n1 < n2 ) return true ; if ( n2 < n1 ) return false ; for ( int i = 0 ; i < n1 ; i ++ ) { if ( str1 [ i ] < str2 [ i ] ) return true ; else if ( str1 [ i ] > str2 [ i ] ) return false ; } return false ; } string findDiff ( string str1 , string str2 ) { if ( isSmaller ( str1 , str2 ) ) swap ( str1 , str2 ) ; string str = " " ; int n1 = str1 . length ( ) , n2 = str2 . length ( ) ; int diff = n1 - n2 ; int carry = 0 ; for ( int i = n2 - 1 ; i >= 0 ; i -- ) { int sub = ( ( str1 [ i + diff ] - '0' ) - ( str2 [ i ] - '0' ) - carry ) ; if ( sub < 0 ) { sub = sub + 10 ; carry = 1 ; } else carry = 0 ; str . push_back ( sub + '0' ) ; } for ( int i = n1 - n2 - 1 ; i >= 0 ; i -- ) { if ( str1 [ i ] == '0' && carry ) { str . push_back ( '9' ) ; continue ; } int sub = ( ( str1 [ i ] - '0' ) - carry ) ; str . push_back ( sub + '0' ) ; carry = 0 ; } reverse ( str . begin ( ) , str . end ( ) ) ; return str ; } int main ( ) { string str1 = "88" ; string str2 = "1079" ; cout << findDiff ( str1 , str2 ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool unique ( string s ) { sort ( s . begin ( ) , s . end ( ) ) ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) { if ( s [ i ] == s [ i + 1 ] ) { return false ; break ; } } return true ; } int main ( ) { if ( unique ( " abcdd " ) == true ) { cout << " String ▁ is ▁ Unique " << endl ; } else { cout << " String ▁ is ▁ not ▁ Unique " << endl ; } return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX_CHAR = 26 ; bool areKAnagrams ( string str1 , string str2 , int k ) { int n = str1 . length ( ) ; if ( str2 . length ( ) != n ) return false ; int hash_str1 [ MAX_CHAR ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) hash_str1 [ str1 [ i ] - ' a ' ] ++ ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( hash_str1 [ str2 [ i ] - ' a ' ] > 0 ) hash_str1 [ str2 [ i ] - ' a ' ] -- ; else count ++ ; if ( count > k ) return false ; } return true ; } int main ( ) { string str1 = " fodr " ; string str2 = " gork " ; int k = 2 ; if ( areKAnagrams ( str1 , str2 , k ) == true ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: MAX_CHAR, i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; char getDigit ( int N , int d ) { string str ; stringstream ss ; ss << N ; ss >> str ; return str [ d - 1 ] ; } char getNthChar ( int N ) { int sum = 0 , nine = 9 ; int dist = 0 , len ; for ( len = 1 ; ; len ++ ) { sum += nine * len ; dist += nine ; if ( sum >= N ) { sum -= nine * len ; dist -= nine ; N -= sum ; break ; } nine *= 10 ; } int diff = ceil ( ( double ) N / len ) ; int d = N % len ; if ( d == 0 ) d = len ; return getDigit ( dist + diff , d ) ; } int main ( ) { int N = 251 ; cout << getNthChar ( N ) << endl ; return 0 ; }

Accumulator variables: N, dist, len, nine, stdc, sum
Iterator variables: len
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool ispalindrome ( string s ) { int l = s . length ( ) ; int j ; for ( int i = 0 , j = l - 1 ; i <= j ; i ++ , j -- ) { if ( s [ i ] != s [ j ] ) return false ; } return true ; } int main ( ) { string s = " BABABAA " ; int cnt = 0 ; int flag = 0 ; while ( s . length ( ) > 0 ) { if ( ispalindrome ( s ) ) { flag = 1 ; break ; } else { cnt ++ ; s . erase ( s . begin ( ) + s . length ( ) - 1 ) ; } } s . erase ( s . begin ( ) + s . length ( ) - 1 ) ; if ( flag ) cout << cnt ; }

Index/key variables: i, j
Accumulator variables: cnt, i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findCount ( string str ) { int result = 0 ; for ( int i = 0 ; i < str . size ( ) ; i ++ ) if ( i == ( str [ i ] - ' a ' ) || i == ( str [ i ] - ' A ' ) ) result ++ ; return result ; } int main ( ) { string str = " AbgdeF " ; cout << findCount ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, result, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPalindrome ( string :: iterator low , string :: iterator high ) { while ( low < high ) { if ( * low != * high ) return false ; low ++ ; high -- ; } return true ; } int possiblePalinByRemovingOneChar ( string str ) { int low = 0 , high = str . length ( ) - 1 ; while ( low < high ) { if ( str [ low ] == str [ high ] ) { low ++ ; high -- ; } else { if ( isPalindrome ( str . begin ( ) + low + 1 , str . begin ( ) + high ) ) return low ; if ( isPalindrome ( str . begin ( ) + low , str . begin ( ) + high - 1 ) ) return high ; return -1 ; } } return -2 ; } int main ( ) { string str = " abecbea " ; int idx = possiblePalinByRemovingOneChar ( str ) ; if ( idx == -1 ) cout << " Not ▁ Possible ▁ STRNEWLINE " ; else if ( idx == -2 ) cout << " Possible ▁ without ▁ removing ▁ any ▁ character " ; else cout << " Possible ▁ by ▁ removing ▁ character " << " ▁ at ▁ index ▁ " << idx << " STRNEWLINE " ; return 0 ; }

Index/key variables: high, low
Accumulator variables: high, low, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ALPHABET_SIZE  26
struct TrieNode { TrieNode * children [ ALPHABET_SIZE ] ; bool isLeaf ; list < string > word ; } ; TrieNode * getNewTrieNode ( void ) { TrieNode * pNode = new TrieNode ; if ( pNode ) { pNode -> isLeaf = false ; for ( int i = 0 ; i < ALPHABET_SIZE ; i ++ ) pNode -> children [ i ] = NULL ; } return pNode ; } void insert ( TrieNode * root , string word ) { int index ; TrieNode * pCrawl = root ; for ( int level = 0 ; level < word . length ( ) ; level ++ ) { if ( islower ( word [ level ] ) ) continue ; index = int ( word [ level ] ) - ' A ' ; if ( ! pCrawl -> children [ index ] ) pCrawl -> children [ index ] = getNewTrieNode ( ) ; pCrawl = pCrawl -> children [ index ] ; } pCrawl -> isLeaf = true ; ( pCrawl -> word ) . push_back ( word ) ; } void printAllWords ( TrieNode * root ) { if ( root -> isLeaf ) { for ( string str : root -> word ) cout << str << endl ; } for ( int i = 0 ; i < ALPHABET_SIZE ; i ++ ) { TrieNode * child = root -> children [ i ] ; if ( child ) printAllWords ( child ) ; } } bool search ( TrieNode * root , string pattern ) { int index ; TrieNode * pCrawl = root ; for ( int level = 0 ; level < pattern . length ( ) ; level ++ ) { index = int ( pattern [ level ] ) - ' A ' ; if ( ! pCrawl -> children [ index ] ) return false ; pCrawl = pCrawl -> children [ index ] ; } printAllWords ( pCrawl ) ; return true ; } void findAllWords ( vector < string > dict , string pattern ) { TrieNode * root = getNewTrieNode ( ) ; for ( string word : dict ) insert ( root , word ) ; if ( ! search ( root , pattern ) ) cout << " No ▁ match ▁ found " ; } int main ( ) { vector < string > dict = { " Hi " , " Hello " , " HelloWorld " , " HiTech " , " HiGeek " , " HiTechWorld " , " HiTechCity " , " HiTechLab " } ; string pattern = " HT " ; findAllWords ( dict , pattern ) ; return 0 ; }

Index/key variables: ALPHABET_SIZE, i, index, level
Accumulator variables: i, level, stdc
Iterator variables: i, level, str, word
Boolean variables: isLeaf
Class/struct names: TrieNode
C++ program:
#include <iostream>
using namespace std ; void print ( string str , int index ) { if ( index == str . size ( ) ) { cout << str << endl ; return ; } if ( str [ index ] == ' ? ' ) { str [ index ] = '0' ; print ( str , index + 1 ) ; str [ index ] = '1' ; print ( str , index + 1 ) ; } else print ( str , index + 1 ) ; } int main ( ) { string str = "1 ? ? 0?101" ; print ( str , 0 ) ; return 0 ; }

Index/key variables: index
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countOccurrences ( long int x , int d ) { while ( x ) { if ( x % 10 == d ) count ++ ; x = x / 10 ; } return count ; } int maxOccurring ( long int x ) { if ( x < 0 ) x = - x ; for ( int d = 0 ; d <= 9 ; d ++ ) { int count = countOccurrences ( x , d ) ; if ( count >= max_count ) { max_count = count ; result = d ; } } return result ; } int main ( ) { long int x = 1223355 ; cout << " Max ▁ occurring ▁ digit ▁ is ▁ " << maxOccurring ( x ) ; return 0 ; }

Accumulator variables: count, d, stdc
Iterator variables: d
C++ program:
#include <bits/stdc++.h>
using namespace std ; void removeRecurringDigits ( char num [ ] ) { int len = strlen ( num ) ; for ( int i = 0 ; i < len ; i ++ ) { num [ j ++ ] = num [ i ] ; while ( i + 1 < len && num [ i ] == num [ i + 1 ] ) i ++ ; } int main ( ) { char num [ ] = "1299888833" ; removeRecurringDigits ( num ) ; cout << " Modified ▁ number ▁ is ▁ " << num ; return 0 ; }

Index/key variables: i
Accumulator variables: i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxSubarrayXOR ( int arr [ ] , int n ) { int ans = INT_MIN ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { curr_xor = curr_xor ^ arr [ j ] ; ans = max ( ans , curr_xor ) ; } } return ans ; } int main ( ) { int arr [ ] = { 8 , 1 , 2 , 12 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << " Max ▁ subarray ▁ XOR ▁ is ▁ " << maxSubarrayXOR ( arr , n ) ; return 0 ; }

Index/key variables: j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printPattern ( string str , int len ) { for ( int i = 0 ; i < len ; i ++ ) { for ( int j = 0 ; j < len ; j ++ ) { if ( ( i == j ) || ( i + j == len - 1 ) ) cout << str [ j ] ; else cout << " ▁ " ; } cout << endl ; } } int main ( ) { string str = " geeksforgeeks " ; int len = str . size ( ) ; printPattern ( str , len ) ; return 0 ; }

Index/key variables: j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <iostream>
#include <cstring>
#define MAX_CHARS  26
using namespace std ; bool isValid ( int count [ ] , int k ) { int val = 0 ; for ( int i = 0 ; i < MAX_CHARS ; i ++ ) if ( count [ i ] > 0 ) val ++ ; return ( k >= val ) ; } void kUniques ( string s , int k ) { int count [ MAX_CHARS ] ; memset ( count , 0 , sizeof ( count ) ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( count [ s [ i ] - ' a ' ] == 0 ) u ++ ; count [ s [ i ] - ' a ' ] ++ ; } if ( u < k ) { cout << " Not ▁ enough ▁ unique ▁ characters " ; return ; } int curr_start = 0 , curr_end = 0 ; int max_window_size = 1 , max_window_start = 0 ; memset ( count , 0 , sizeof ( count ) ) ; count [ s [ 0 ] - ' a ' ] ++ ; for ( int i = 1 ; i < n ; i ++ ) { count [ s [ i ] - ' a ' ] ++ ; curr_end ++ ; while ( ! isValid ( count , k ) ) { count [ s [ curr_start ] - ' a ' ] -- ; curr_start ++ ; } if ( curr_end - curr_start + 1 > max_window_size ) { max_window_size = curr_end - curr_start + 1 ; max_window_start = curr_start ; } } cout << " Max ▁ substring ▁ is ▁ : ▁ " << s . substr ( max_window_start , max_window_size ) << " ▁ with ▁ length ▁ " << max_window_size << endl ; } int main ( ) { string s = " aabacbebebe " ; int k = 3 ; kUniques ( s , k ) ; return 0 ; }

Index/key variables: MAX_CHARS, curr_start, i
Accumulator variables: curr_end, curr_start, i, u, val
Iterator variables: i
C++ program:
#include <iostream>
#include <cstring>
using namespace std ; #define MAX_CHAR  26
int runCustomerSimulation ( int n , const char * seq ) { char seen [ MAX_CHAR ] = { 0 } ; int res = 0 ; for ( int i = 0 ; seq [ i ] ; i ++ ) { int ind = seq [ i ] - ' A ' ; if ( seen [ ind ] == 0 ) { seen [ ind ] = 1 ; if ( occupied < n ) { occupied ++ ; seen [ ind ] = 2 ; } else res ++ ; } else { if ( seen [ ind ] == 2 ) occupied -- ; seen [ ind ] = 0 ; } } return res ; } int main ( ) { cout << runCustomerSimulation ( 2 , " ABBAJJKZKZ " ) << endl ; cout << runCustomerSimulation ( 3 , " GACCBDDBAGEE " ) << endl ; cout << runCustomerSimulation ( 3 , " GACCBGDDBAEE " ) << endl ; cout << runCustomerSimulation ( 1 , " ABCBCA " ) << endl ; cout << runCustomerSimulation ( 1 , " ABCBCADEED " ) << endl ; return 0 ; }

Index/key variables: MAX_CHAR, i, ind
Accumulator variables: i, occupied, res
Iterator variables: i
C++ program:
# include <bits/stdc++.h>
using namespace std ; bool canFormPalindrome ( string a ) { int bitvector = 0 , mask = 0 ; for ( int i = 0 ; a [ i ] != ' \0' ; i ++ ) { int x = a [ i ] - ' a ' ; mask = 1 << x ; bitvector = bitvector ^ mask ; } return ( bitvector & ( bitvector - 1 ) ) == 0 ; } int main ( ) { if ( canFormPalindrome ( " geeksforgeeks " ) ) cout << ( " Yes " ) << endl ; else cout << ( " No " ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define NO_OF_CHARS  256
bool areAnagram ( string str1 , string str2 ) { int count [ NO_OF_CHARS ] = { 0 } ; int i ; for ( i = 0 ; str1 [ i ] && str2 [ i ] ; i ++ ) { count [ str1 [ i ] ] ++ ; count [ str2 [ i ] ] -- ; } if ( str1 [ i ] str2 [ i ] ) return false ; for ( i = 0 ; i < NO_OF_CHARS ; i ++ ) if ( count [ i ] ) return false ; return true ; } void findAllAnagrams ( string arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) if ( areAnagram ( arr [ i ] , arr [ j ] ) ) cout << arr [ i ] << " ▁ is ▁ anagram ▁ of ▁ " << arr [ j ] << endl ; } int main ( ) { string arr [ ] = { " geeksquiz " , " geeksforgeeks " , " abcd " , " forgeeksgeeks " , " zuiqkeegs " } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; findAllAnagrams ( arr , n ) ; return 0 ; }

Index/key variables: NO_OF_CHARS, i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <iostream>
using namespace std ; int isPalindrome ( int n ) { int rev = 0 ; for ( int i = n ; i > 0 ; i /= 10 ) rev = rev * 10 + i % 10 ; return ( n == rev ) ; } void countPal ( int min , int max ) { for ( int i = min ; i <= max ; i ++ ) if ( isPalindrome ( i ) ) cout << i << " ▁ " ; } int main ( ) { countPal ( 100 , 2000 ) ; return 0 ; }

Accumulator variables: i
Iterator variables: i