dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int CHAR_SIZE = 256 ; bool checkPattern ( string str , string pat ) { vector < int > label ( CHAR_SIZE , -1 ) ; int order = 1 ; for ( int i = 0 ; i < pat . length ( ) ; i ++ ) { label [ pat [ i ] ] = order ; order ++ ; } int last_order = -1 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( label [ str [ i ] ] != -1 ) { if ( label [ str [ i ] ] < last_order ) return false ; last_order = label [ str [ i ] ] ; } } return true ; } int main ( ) { string str = " engineers ▁ rock " ; string pattern = " gsr " ; cout << boolalpha << checkPattern ( str , pattern ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, order, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; char encodedChar ( string str , int k ) { string expand = " " ; for ( int i = 0 ; str [ i ] != ' \0' ; ) { while ( str [ i ] >= ' a ' && str [ i ] <= ' z ' ) { temp . push_back ( str [ i ] ) ; i ++ ; } while ( str [ i ] >= '1' && str [ i ] <= '9' ) { freq = freq * 10 + str [ i ] - '0' ; i ++ ; } for ( int j = 1 ; j <= freq ; j ++ ) expand . append ( temp ) ; } if ( freq == 0 ) expand . append ( temp ) ; return expand [ k - 1 ] ; } int main ( ) { string str = " ab4c12ed3" ; int k = 21 ; cout << encodedChar ( str , k ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; string intToRoman ( int num ) { string m [ ] = { " " , " M " , " MM " , " MMM " } ; string c [ ] = { " " , " C " , " CC " , " CCC " , " CD " , " D " , " DC " , " DCC " , " DCCC " , " CM " } ; string x [ ] = { " " , " X " , " XX " , " XXX " , " XL " , " L " , " LX " , " LXX " , " LXXX " , " XC " } ; string i [ ] = { " " , " I " , " II " , " III " , " IV " , " V " , " VI " , " VII " , " VIII " , " IX " } ; string thousands = m [ num / 1000 ] ; string hundereds = c [ ( num % 1000 ) / 100 ] ; string tens = x [ ( num % 100 ) / 10 ] ; string ones = i [ num % 10 ] ; string ans = thousands + hundereds + tens + ones ; return ans ; } int main ( ) { int number = 3549 ; cout << intToRoman ( number ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int romanToDecimal ( string & str ) { map < char , int > m ; m . insert ( { ' I ' , 1 } ) ; m . insert ( { ' V ' , 5 } ) ; m . insert ( { ' X ' , 10 } ) ; m . insert ( { ' L ' , 50 } ) ; m . insert ( { ' C ' , 100 } ) ; m . insert ( { ' D ' , 500 } ) ; m . insert ( { ' M ' , 1000 } ) ; int sum = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( m [ str [ i ] ] < m [ str [ i + 1 ] ] ) { sum += m [ str [ i + 1 ] ] - m [ str [ i ] ] ; i ++ ; continue ; } sum += m [ str [ i ] ] ; } return sum ; } int main ( ) { string str = " MCMIV " ; cout << " Integer ▁ form ▁ of ▁ Roman ▁ Numeral ▁ is ▁ " << romanToDecimal ( str ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMinLength ( string arr [ ] , int n ) { int min = INT_MAX ; for ( int i = 0 ; i <= n - 1 ; i ++ ) if ( arr [ i ] . length ( ) < min ) min = arr [ i ] . length ( ) ; return ( min ) ; } bool allContainsPrefix ( string arr [ ] , int n , string str , int start , int end ) { for ( int i = 0 ; i <= n - 1 ; i ++ ) for ( int j = start ; j <= end ; j ++ ) if ( arr [ i ] [ j ] != str [ j ] ) return ( false ) ; return ( true ) ; } string commonPrefix ( string arr [ ] , int n ) { int index = findMinLength ( arr , n ) ; int low = 0 , high = index ; while ( low <= high ) { int mid = low + ( high - low ) / 2 ; if ( allContainsPrefix ( arr , n , arr [ 0 ] , low , mid ) ) { prefix = prefix + arr [ 0 ] . substr ( low , mid - low + 1 ) ; low = mid + 1 ; } high = mid - 1 ; } return ( prefix ) ; } int main ( ) { string arr [ ] = { " geeksforgeeks " , " geeks " , " geek " , " geezer " } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; string ans = commonPrefix ( arr , n ) ; if ( ans . length ( ) ) cout << " The ▁ longest ▁ common ▁ prefix ▁ is ▁ " << ans ; else cout << " There ▁ is ▁ no ▁ common ▁ prefix " ; return ( 0 ) ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <iostream>
using namespace std ; string to_upper ( string & in ) { for ( int i = 0 ; i < in . length ( ) ; i ++ ) if ( ' a ' <= in [ i ] <= ' z ' ) in [ i ] &= ~ ( 1 << 5 ) ; return in ; } int main ( ) { string str = " geeksforgeeks " ; cout << to_upper ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string commonPrefixUtil ( string str1 , string str2 ) { string result ; int n1 = str1 . length ( ) , n2 = str2 . length ( ) ; for ( int i = 0 , j = 0 ; i <= n1 - 1 && j <= n2 - 1 ; i ++ , j ++ ) { if ( str1 [ i ] != str2 [ j ] ) break ; result . push_back ( str1 [ i ] ) ; } return ( result ) ; } string commonPrefix ( string arr [ ] , int low , int high ) { if ( low == high ) return ( arr [ low ] ) ; if ( high > low ) { int mid = low + ( high - low ) / 2 ; string str1 = commonPrefix ( arr , low , mid ) ; string str2 = commonPrefix ( arr , mid + 1 , high ) ; return ( commonPrefixUtil ( str1 , str2 ) ) ; } } int main ( ) { string arr [ ] = { " geeksforgeeks " , " geeks " , " geek " , " geezer " } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; string ans = commonPrefix ( arr , 0 , n - 1 ) ; if ( ans . length ( ) ) cout << " The ▁ longest ▁ common ▁ prefix ▁ is ▁ " << ans ; else cout << " There ▁ is ▁ no ▁ common ▁ prefix " ; return ( 0 ) ; }

Index/key variables: i, j, low
Accumulator variables: i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string commonPrefixUtil ( string str1 , string str2 ) { string result ; int n1 = str1 . length ( ) , n2 = str2 . length ( ) ; for ( int i = 0 , j = 0 ; i <= n1 - 1 && j <= n2 - 1 ; i ++ , j ++ ) { if ( str1 [ i ] != str2 [ j ] ) break ; result . push_back ( str1 [ i ] ) ; } return ( result ) ; } string commonPrefix ( string arr [ ] , int n ) { string prefix = arr [ 0 ] ; for ( int i = 1 ; i <= n - 1 ; i ++ ) prefix = commonPrefixUtil ( prefix , arr [ i ] ) ; return ( prefix ) ; } int main ( ) { string arr [ ] = { " geeksforgeeks " , " geeks " , " geek " , " geezer " } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; string ans = commonPrefix ( arr , n ) ; if ( ans . length ( ) ) printf ( " The ▁ longest ▁ common ▁ prefix ▁ is ▁ - ▁ % s " , ans . c_str ( ) ) ; else printf ( " There ▁ is ▁ no ▁ common ▁ prefix " ) ; return ( 0 ) ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < string > findCombinations ( vector < int > input , vector < char > table [ ] ) { vector < string > out , temp ; unordered_map < int , int > mp ; int index = 0 ; for ( int d : input ) { if ( mp . find ( d ) == mp . end ( ) ) mp [ d ] = index ; temp . clear ( ) ; for ( int i = 0 ; i < table [ d - 1 ] . size ( ) ; i ++ ) { if ( index == 0 ) { string s ( 1 , table [ d - 1 ] . at ( i ) ) ; out . push_back ( s ) ; } if ( index > 0 ) { for ( string str : out ) { string s ( 1 , table [ d - 1 ] . at ( i ) ) ; if ( mp [ d ] != index ) s = str [ mp [ d ] ] ; str = str + s ; temp . push_back ( str ) ; } if ( mp [ d ] != index ) break ; } } if ( index > 0 ) out = temp ; index ++ ; } return out ; } int main ( ) { vector < char > table [ ] = { { ' A ' , ' B ' , ' C ' } , { ' D ' , ' E ' , ' F ' } , { ' G ' , ' H ' , ' I ' } , { ' J ' , ' K ' , ' L ' } , { ' M ' , ' N ' , ' O ' } , { ' P ' , ' Q ' , ' R ' } , { ' S ' , ' T ' , ' U ' } , { ' V ' , ' W ' , ' X ' } , { ' Y ' , ' Z ' } } ; vector < int > input = { 1 , 2 , 1 } ; vector < string > out = findCombinations ( input , table ) ; for ( string it : out ) cout << it << " ▁ " ; return 0 ; }

Index/key variables: d
Accumulator variables: i, index, stdc
Iterator variables: d, i, it, str
C++ program:
#include <bits/stdc++.h>
using namespace std ; char flip ( char c ) { return ( c == '0' ) ? '1' : '0' ; } void printOneAndTwosComplement ( string bin ) { int n = bin . length ( ) ; int i ; string ones , twos ; ones = twos = " " ; for ( i = 0 ; i < n ; i ++ ) ones += flip ( bin [ i ] ) ; twos = ones ; for ( i = n - 1 ; i >= 0 ; i -- ) { if ( ones [ i ] == '1' ) twos [ i ] = '0' ; else { twos [ i ] = '1' ; break ; } } if ( i == -1 ) twos = '1' + twos ; cout << "1 ' s ▁ complement : ▁ " << ones << endl ; cout << "2 ' s ▁ complement : ▁ " << twos << endl ; } int main ( ) { string bin = "1100" ; printOneAndTwosComplement ( bin ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, ones, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string zigZagConcat ( string s , int n ) { if ( n <= 1 ) { return s ; } string result = " " ; for ( int rowNum = 0 ; rowNum < n ; rowNum ++ ) { int i = rowNum ; bool up = true ; while ( i < s . length ( ) ) { result += s [ i ] ; if ( rowNum == 0 rowNum == n - 1 ) { i += ( 2 * n - 2 ) ; } else { if ( up ) { i += ( 2 * ( n - rowNum ) - 2 ) ; } else { i += rowNum * 2 ; } up ^= true ; } } } return result ; } int main ( ) { string str = " GEEKSFORGEEKS " ; int n = 3 ; cout << zigZagConcat ( str , n ) ; }

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

Index/key variables: k
Accumulator variables: i, k, stdc
Iterator variables: i, k
C++ program:
#include <iostream>
#include <string>
#define R  3
#define C  3
using namespace std ; void printUtil ( string arr [ R ] [ C ] , int m , int n , string output [ R ] ) { output [ m ] = arr [ m ] [ n ] ; if ( m == R - 1 ) { for ( int i = 0 ; i < R ; i ++ ) cout << output [ i ] << " ▁ " ; cout << endl ; return ; } for ( int i = 0 ; i < C ; i ++ ) if ( arr [ m + 1 ] [ i ] != " " ) printUtil ( arr , m + 1 , i , output ) ; } void print ( string arr [ R ] [ C ] ) { string output [ R ] ; for ( int i = 0 ; i < C ; i ++ ) if ( arr [ 0 ] [ i ] != " " ) printUtil ( arr , 0 , i , output ) ; } int main ( ) { string arr [ R ] [ C ] = { { " you " , " we " } , { " have " , " are " } , { " sleep " , " eat " , " drink " } } ; print ( arr ) ; return 0 ; }

Index/key variables: C, R, i, m, n
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define NO_OF_CHARS  256
bool canFormPalindrome ( string str ) { int count [ NO_OF_CHARS ] = { 0 } ; for ( int i = 0 ; str [ i ] ; i ++ ) count [ str [ i ] ] ++ ; int odd = 0 ; for ( int i = 0 ; i < NO_OF_CHARS ; i ++ ) { if ( count [ i ] & 1 ) odd ++ ; if ( odd > 1 ) return false ; } return true ; } int main ( ) { canFormPalindrome ( " geeksforgeeks " ) ? cout << " Yes STRNEWLINE " : cout << " No STRNEWLINE " ; canFormPalindrome ( " geeksogeeks " ) ? cout << " Yes STRNEWLINE " : cout << " No STRNEWLINE " ; return 0 ; }

Index/key variables: NO_OF_CHARS, i
Accumulator variables: i, odd, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string removeDuplicates ( string s , char ch ) { if ( s . length ( ) <= 1 ) { return s ; } int i = 0 ; while ( i < s . length ( ) ) { if ( i + 1 < s . length ( ) && s [ i ] == s [ i + 1 ] ) { int j = i ; while ( j + 1 < s . length ( ) && s [ j ] == s [ j + 1 ] ) { j ++ ; } char lastChar = i > 0 ? s [ i - 1 ] : ch ; string remStr = removeDuplicates ( s . substr ( j + 1 , s . length ( ) ) , lastChar ) ; s = s . substr ( 0 , i ) ; int k = s . length ( ) , l = 0 ; while ( remStr . length ( ) > 0 && s . length ( ) > 0 && remStr [ 0 ] == s [ s . length ( ) - 1 ] ) { while ( remStr . length ( ) > 0 && remStr [ 0 ] != ch && remStr [ 0 ] == s [ s . length ( ) - 1 ] ) { remStr = remStr . substr ( 1 , remStr . length ( ) ) ; } s = s . substr ( 0 , s . length ( ) - 1 ) ; } s = s + remStr ; i = j ; } else { i ++ ; } } return s ; } int main ( ) { string str1 = " mississipie " ; cout << removeDuplicates ( str1 , ' ▁ ' ) << endl ; string str2 = " ocvvcolop " ; cout << removeDuplicates ( str2 , ' ▁ ' ) << endl ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int main ( ) { int val ; char strn1 [ ] = "12546" ; val = atoi ( strn1 ) ; cout << " String ▁ value ▁ = ▁ " << strn1 << endl ; cout << " Integer ▁ value ▁ = ▁ " << val << endl ; char strn2 [ ] = " GeeksforGeeks " ; val = atoi ( strn2 ) ; cout << " String ▁ value ▁ = ▁ " << strn2 << endl ; cout << " Integer ▁ value ▁ = ▁ " << val << endl ; return ( 0 ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < string > generateGray ( int n ) { if ( n <= 0 ) return { "0" } ; if ( n == 1 ) { return { "0" , "1" } ; } vector < string > recAns = generateGray ( n - 1 ) ; vector < string > mainAns ; for ( int i = 0 ; i < recAns . size ( ) ; i ++ ) { string s = recAns [ i ] ; mainAns . push_back ( "0" + s ) ; } for ( int i = recAns . size ( ) - 1 ; i >= 0 ; i -- ) { string s = recAns [ i ] ; mainAns . push_back ( "1" + s ) ; } return mainAns ; } void generateGrayarr ( int n ) { vector < string > arr ; arr = generateGray ( n ) ; for ( int i = 0 ; i < arr . size ( ) ; i ++ ) cout << arr [ i ] << endl ; } int main ( ) { generateGrayarr ( 3 ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int ic_strcmp ( string s1 , string s2 ) { int i ; for ( i = 0 ; s1 [ i ] && s2 [ i ] ; ++ i ) { if ( s1 [ i ] == s2 [ i ] || ( s1 [ i ] ^ 32 ) == s2 [ i ] ) continue ; else break ; } if ( s1 [ i ] == s2 [ i ] ) return 0 ; if ( ( s1 [ i ] 32 ) < ( s2 [ i ] 32 ) ) return -1 ; return 1 ; } int main ( ) { cout << " ret : ▁ " << ic_strcmp ( " Geeks " , " apple " ) << endl ; cout << " ret : ▁ " << ic_strcmp ( " " , " ABCD " ) << endl ; cout << " ret : ▁ " << ic_strcmp ( " ABCD " , " z " ) << endl ; cout << " ret : ▁ " << ic_strcmp ( " ABCD " , " abcdEghe " ) << endl ; cout << " ret : ▁ " << ic_strcmp ( " GeeksForGeeks " , " gEEksFORGeEKs " ) << endl ; cout << " ret : ▁ " << ic_strcmp ( " GeeksForGeeks " , " geeksForGeeks " ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define NO_OF_CHARS  256
bool areAnagram ( char * str1 , char * str2 ) { int count1 [ NO_OF_CHARS ] = { 0 } ; int count2 [ NO_OF_CHARS ] = { 0 } ; int i ; for ( i = 0 ; str1 [ i ] && str2 [ i ] ; i ++ ) { count1 [ str1 [ i ] ] ++ ; count2 [ str2 [ i ] ] ++ ; } if ( str1 [ i ] str2 [ i ] ) return false ; for ( i = 0 ; i < NO_OF_CHARS ; i ++ ) if ( count1 [ i ] != count2 [ i ] ) return false ; return true ; } int main ( ) { char str1 [ ] = " geeksforgeeks " ; char str2 [ ] = " forgeeksgeeks " ; if ( areAnagram ( str1 , str2 ) ) cout << " The ▁ two ▁ strings ▁ are ▁ anagram ▁ of ▁ each ▁ other " ; else cout << " The ▁ two ▁ strings ▁ are ▁ not ▁ anagram ▁ of ▁ each ▁ " " other " ; return 0 ; }

Index/key variables: NO_OF_CHARS, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int no_of_chars = 256 ; string findSubString ( string str , string pat ) { int len1 = str . length ( ) ; int len2 = pat . length ( ) ; if ( len1 < len2 ) { cout << " No ▁ such ▁ window ▁ exists " ; return " " ; } int hash_pat [ no_of_chars ] = { 0 } ; int hash_str [ no_of_chars ] = { 0 } ; for ( int i = 0 ; i < len2 ; i ++ ) hash_pat [ pat [ i ] ] ++ ; int start = 0 , start_index = -1 , min_len = INT_MAX ; int count = 0 ; for ( int j = 0 ; j < len1 ; j ++ ) { hash_str [ str [ j ] ] ++ ; if ( hash_str [ str [ j ] ] <= hash_pat [ str [ j ] ] ) count ++ ; if ( count == len2 ) { while ( hash_str [ str [ start ] ] > hash_pat [ str [ start ] ] hash_pat [ str [ start ] ] == 0 ) { if ( hash_str [ str [ start ] ] > hash_pat [ str [ start ] ] ) hash_str [ str [ start ] ] -- ; start ++ ; } int len_window = j - start + 1 ; if ( min_len > len_window ) { min_len = len_window ; start_index = start ; } } } if ( start_index == -1 ) { cout << " No ▁ such ▁ window ▁ exists " ; return " " ; } return str . substr ( start_index , min_len ) ; } int main ( ) { string str = " this ▁ is ▁ a ▁ test ▁ string " ; string pat = " tist " ; cout << " Smallest ▁ window ▁ is ▁ : ▁ STRNEWLINE " << findSubString ( str , pat ) ; return 0 ; }

Index/key variables: i, j, no_of_chars, start
Accumulator variables: count, i, j, start, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; string removeChars ( string string1 , string string2 ) { for ( auto i : string2 ) { while ( find ( string1 . begin ( ) , string1 . end ( ) , i ) != string1 . end ( ) ) { auto itr = find ( string1 . begin ( ) , string1 . end ( ) , i ) ; string1 . erase ( itr ) ; } } return string1 ; } int main ( ) { string string1 , string2 ; string1 = " geeksforgeeks " ; string2 = " mask " ; cout << removeChars ( string1 , string2 ) << endl ; ; return 0 ; }

Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; char * removeDuplicate ( char str [ ] , int n ) { int index = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int j ; for ( j = 0 ; j < i ; j ++ ) if ( str [ i ] == str [ j ] ) break ; if ( j == i ) str [ index ++ ] = str [ i ] ; } return str ; } int main ( ) { char str [ ] = " geeksforgeeks " ; int n = sizeof ( str ) / sizeof ( str [ 0 ] ) ; cout << removeDuplicate ( str , n ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, index, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; char * removeDuplicates ( char * s , int n ) { unordered_map < char , int > exists ; int index = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( exists [ s [ i ] ] == 0 ) { s [ index ++ ] = s [ i ] ; exists [ s [ i ] ] ++ ; } } return s ; } int main ( ) { char s [ ] = " geeksforgeeks " ; int n = sizeof ( s ) / sizeof ( s [ 0 ] ) ; cout << removeDuplicates ( s , n ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, index, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int DirX [ ] = { 2 , 1 , -1 , -2 , -2 , -1 , 1 , 2 } ; int DirY [ ] = { 1 , 2 , 2 , 1 , -1 , -2 , -2 , -1 } ; bool isSafe ( int i , int j , int n , vector < vector < int > > & Board ) { return ( i >= 0 and j >= 0 and i < n and j < n and Board [ i ] [ j ] == 0 ) ; } bool isPossible = false ; void knightTour ( vector < vector < int > > & ChessBoard , int N , int x , int y , int visited = 1 ) { ChessBoard [ x ] [ y ] = visited ; if ( visited == N * N ) { isPossible = true ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { cout << ChessBoard [ i ] [ j ] << " ▁ " ; } cout << endl ; } cout << endl ; ChessBoard [ x ] [ y ] = 0 ; return ; } for ( int i = 0 ; i < 8 ; i ++ ) { int newX = x + DirX [ i ] ; int newY = y + DirY [ i ] ; if ( isSafe ( newX , newY , N , ChessBoard ) && ! ChessBoard [ newX ] [ newY ] ) { knightTour ( ChessBoard , N , newX , newY , visited + 1 ) ; } } ChessBoard [ x ] [ y ] = 0 ; } int main ( ) { vector < vector < int > > ChessBoard ( 5 , vector < int > ( 5 , 0 ) ) ; int N = ChessBoard . size ( ) ; int X = 1 ; int Y = 1 ; knightTour ( ChessBoard , N , X - 1 , Y - 1 ) ; if ( ! isPossible ) { cout << -1 ; } return 0 ; }

Index/key variables: i, j, newX, newY, x, y
Accumulator variables: i, j, stdc
Iterator variables: i, j
Boolean variables: isPossible
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool getans ( int i , vector < int > v , vector < int > q ) { if ( i == q . size ( ) ) return true ; for ( int j = 0 ; j < v . size ( ) ; j ++ ) { if ( v [ j ] >= q [ i ] ) { v [ j ] -= q [ i ] ; if ( getans ( i + 1 , v , q ) ) { return true ; } v [ j ] += q [ i ] ; } } return false ; } void Check ( vector < int > c , vector < int > b ) { map < int , int > m ; for ( int i = 0 ; i < b . size ( ) ; i ++ ) { m [ b [ i ] ] ++ ; } vector < int > v ; for ( auto i : m ) { v . push_back ( i . second ) ; } bool check = getans ( 0 , v , c ) ; if ( check ) cout << " YES " << endl ; else cout << " NO " << endl ; } int main ( ) { vector < int > c = { 1 , 3 , 3 } ; vector < int > b = { 2 , 2 , 2 , 2 , 4 , 4 , 4 } ; Check ( c , b ) ; 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 ; int maximumXOR ( int arr [ ] , int n , int K ) { K ++ ; int maxXor = INT_MIN ; for ( int i = 0 ; i < ( 1 << n ) ; i ++ ) { if ( __builtin_popcount ( i ) == K ) { int cur_xor = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( i & ( 1 << j ) ) cur_xor = cur_xor ^ arr [ j ] ; } maxXor = max ( maxXor , cur_xor ) ; } } return maxXor ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int N = sizeof ( arr ) / sizeof ( int ) ; int M = 2 ; cout << maximumXOR ( arr , N , M ) ; return 0 ; }

Index/key variables: j
Accumulator variables: K, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void TowerOfHanoi ( int N ) { for ( int x = 1 ; x <= pow ( 2 , N ) - 1 ; x ++ ) { cout << " Move ▁ from ▁ Rod ▁ " << ( ( x & x - 1 ) % 3 + 1 ) << " ▁ to ▁ Rod ▁ " << ( ( ( x x - 1 ) + 1 ) % 3 + 1 ) << endl ; } } int main ( ) { int N = 3 ; TowerOfHanoi ( N ) ; return 0 ; }

Accumulator variables: stdc, x
Iterator variables: x
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isValid ( vector < vector < int > > & board , int i , int j , int K ) { if ( board [ i ] [ j ] <= K ) { return true ; } return false ; } bool findPath ( vector < vector < int > > & board , int X , int Y , int M , int N , int K ) { if ( X < 0 X == M Y < 0 Y == N ) { return true ; } if ( isValid ( board , X , Y , K ) ) { int board_XY = board [ X ] [ Y ] ; board [ X ] [ Y ] = INT_MAX ; if ( findPath ( board , X + 1 , Y , M , N , K - board_XY ) || findPath ( board , X - 1 , Y , M , N , K - board_XY ) || findPath ( board , X , Y + 1 , M , N , K - board_XY ) || findPath ( board , X , Y - 1 , M , N , K - board_XY ) ) { return true ; } board [ X ] [ Y ] = board_XY ; } return false ; } int main ( ) { vector < vector < int > > grid = { { 25 , 5 , 25 , 25 , 25 , 25 } , { 25 , 1 , 1 , 5 , 12 , 25 } , { 25 , 1 , 12 , 0 , 15 , 25 } , { 22 , 1 , 11 , 2 , 19 , 15 } , { 25 , 2 , 2 , 1 , 12 , 15 } , { 25 , 9 , 10 , 1 , 11 , 25 } , { 25 , 25 , 25 , 25 , 25 , 25 } } ; int K = 17 ; int M = grid . size ( ) ; int N = grid [ 0 ] . size ( ) ; int X = 2 , Y = 3 ; if ( findPath ( grid , X , Y , M , N , K ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: X, Y, i, j
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int isPerfect ( int x ) { int sum_div = 1 ; for ( int i = 2 ; i <= x / 2 ; ++ i ) { if ( x % i == 0 ) { sum_div += i ; } } if ( sum_div == x ) { return 1 ; } else return 0 ; } void subsetSum ( int arr [ ] , int n ) { long long total = 1 << n ; for ( long long i = 0 ; i < total ; i ++ ) { long long sum = 0 ; for ( int j = 0 ; j < n ; j ++ ) if ( i & ( 1 << j ) ) sum += arr [ j ] ; if ( isPerfect ( sum ) ) { cout << sum << " ▁ " ; } } } int main ( ) { int arr [ ] = { 5 , 4 , 6 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; subsetSum ( arr , N ) ; return 0 ; }

Index/key variables: j
Accumulator variables: i, j, stdc, sum, sum_div
Iterator variables: i, j