dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; void canReduceString ( string S , int N ) { int count_1 = 0 ; int count_2 = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( S [ i ] == ' ( ' ) { count_1 ++ ; } else { count_2 ++ ; } } if ( count_1 == 0 count_2 == 0 ) { cout << " - 1" << endl ; } else if ( count_1 == count_2 ) { cout << "0" << endl ; } else if ( N % 2 != 0 ) { cout << " - 1" ; } else { cout << abs ( count_1 - count_2 ) / 2 ; } } int main ( ) { string S = " ) ) ) ( ( ( " ; int N = S . length ( ) ; canReduceString ( S , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count_1, count_2, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void isAcceptedDFA ( string s , int N ) { int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( s [ i ] == ' a ' ) count ++ ; } if ( count == N && count != 0 ) { cout << " Accepted " ; } else { cout << " Not ▁ Accepted " ; } } int main ( ) { string S = " aaaaa " ; isAcceptedDFA ( S , S . size ( ) ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void maximum_pallindromic ( int arr [ ] ) { int res = 0 ; int c1 = 0 , c2 = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { res += arr [ i ] / 3 ; arr [ i ] = arr [ i ] % 3 ; if ( arr [ i ] == 1 ) c1 ++ ; else if ( arr [ i ] == 2 ) c2 ++ ; } res += min ( c1 , c2 ) ; int t = min ( c1 , c2 ) ; c1 -= t ; c2 -= t ; res += 2 * ( c2 / 3 ) ; c2 %= 3 ; res += c2 / 2 ; cout << res ; } int main ( ) { int arr [ ] = { 4 , 5 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ; maximum_pallindromic ( arr ) ; return 0 ; }

Index/key variables: i
Accumulator variables: c1, c2, i, res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void find_Winner ( vector < string > & arr , int N ) { vector < queue < char > > Q ( N ) ; int M = arr . size ( ) ; for ( int i = 0 ; i < M ; i ++ ) { int len = arr [ i ] . length ( ) ; for ( int j = 0 ; j < len ; j ++ ) { Q [ i ] . push ( arr [ i ] [ j ] - 1 ) ; } } int player = 0 ; while ( Q [ player ] . size ( ) > 0 ) { int nextPlayer = Q [ player ] . front ( ) - '0' ; Q [ player ] . pop ( ) ; player = nextPlayer ; } cout << " Player ▁ " << ( player + 1 ) ; } int main ( ) { int N = 3 ; vector < string > arr = { "323" , "2" , "2" } ; find_Winner ( arr , N ) ; return 0 ; }

Index/key variables: i, j, player
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int longestSubstring ( string s ) { int dp [ 1024 ] ; fill ( dp , dp + 1024 , s . size ( ) ) ; int res = 0 , mask = 0 ; dp [ 0 ] = -1 ; for ( int i = 0 ; i < s . size ( ) ; ++ i ) { mask ^= 1 << ( s [ i ] - 48 ) ; res = max ( res , i - dp [ mask ] ) ; for ( int j = 0 ; j <= 9 ; ++ j ) res = max ( res , i - dp [ mask ^ ( 1 << j ) ] ) ; dp [ mask ] = min ( dp [ mask ] , i ) ; } return res ; } int main ( ) { string s = "3242415" ; cout << longestSubstring ( s ) ; return 0 ; }

Index/key variables: i, mask
Accumulator variables: mask, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void Validate ( string M ) { int len = M . size ( ) ; string temp = " " ; for ( int i = 0 ; i < len ; i ++ ) { if ( isdigit ( M [ i ] ) ) temp += M [ i ] ; } int nwlen = temp . size ( ) ; if ( nwlen != 10 ) { cout << " Invalid STRNEWLINE " ; return ; } string res = " " ; string x = temp . substr ( 0 , 3 ) ; res += " ( " + x + " ) - " ; x = temp . substr ( 3 , 3 ) ; res += " ( " + x + " ) - " ; x = temp . substr ( 6 , 3 ) ; res += " ( " + x + " ) - " ; x = temp . substr ( 9 , 1 ) ; res += " ( " + x + " ) " ; cout << res << " STRNEWLINE " ; } int main ( ) { string M = "91 ▁ 234rt5%34*0 ▁ 3" ; Validate ( M ) ; }

Index/key variables: i
Accumulator variables: i, res, stdc, temp
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void hexaModK ( string s , string k ) { map < char , int > mp ; for ( char i = 1 ; i <= 9 ; i ++ ) { mp [ i + '0' ] = i ; } mp [ ' A ' ] = 10 ; mp [ ' B ' ] = 11 ; mp [ ' C ' ] = 12 ; mp [ ' D ' ] = 13 ; mp [ ' E ' ] = 14 ; mp [ ' F ' ] = 15 ; long m = stoi ( k , 0 , 16 ) ; long base = 1 ; long ans = 0 ; for ( int i = s . length ( ) - 1 ; i >= 0 ; i -- ) { long n = mp [ s [ i ] ] % m ; ans = ( ans + ( base % m * n % m ) % m ) % m ; base = ( base % m * 16 % m ) % m ; } stringstream ss ; ss << hex << ans ; string su = ss . str ( ) ; transform ( su . begin ( ) , su . end ( ) , su . begin ( ) , :: toupper ) ; cout << ( su ) ; } int main ( ) { string n = "3E8" ; string k = "13" ; hexaModK ( n , k ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string combination ; set < string > combinations ; void printSequences ( set < string > combinations ) { for ( string s : combinations ) { cout << s << ' ▁ ' ; } } void generateCombinations ( string & s , int n ) { for ( int i = 0 ; i < s . size ( ) ; i ++ ) { combination . push_back ( s [ i ] ) ; long x = stol ( combination ) ; if ( x <= n ) { combinations . insert ( combination ) ; generateCombinations ( s , n ) ; } combination . pop_back ( ) ; } } int main ( ) { string S = "124" ; int N = 100 ; generateCombinations ( S , N ) ; printSequences ( combinations ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i, s
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long compute_hash ( string str ) { int p = 31 ; int MOD = 1e9 + 7 ; long long hash_val = 0 ; long long mul = 1 ; for ( char ch : str ) { hash_val = ( hash_val + ( ch - ' a ' + 1 ) * mul ) % MOD ; mul = ( mul * p ) % MOD ; } return hash_val ; } int distinct_str ( vector < string > & arr , int n ) { vector < long long > hash ( n ) ; for ( int i = 0 ; i < n ; i ++ ) { hash [ i ] = compute_hash ( arr [ i ] ) ; } sort ( hash . begin ( ) , hash . end ( ) ) ; int cntElem = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( hash [ i ] != hash [ i - 1 ] ) { cntElem ++ ; } } return cntElem ; } int main ( ) { vector < string > arr = { " abcde " , " abcce " , " abcdf " , abcde " } ; int N = arr . size ( ) ; cout << distinct_str ( arr , N ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: cntElem, i, stdc
Iterator variables: ch, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void SieveOfEratosthenes ( bool * prime , int n ) { for ( int i = 0 ; i <= n ; i ++ ) { prime [ i ] = true ; } prime [ 0 ] = prime [ 1 ] = false ; for ( int i = 2 ; i * i <= n ; i ++ ) { if ( prime [ i ] == true ) { for ( int j = 2 ; i * j <= n ; j ++ ) { prime [ i * j ] = false ; } } } } void removePrimeFrequencies ( string s ) { int n = s . length ( ) ; bool prime [ n + 1 ] ; SieveOfEratosthenes ( prime , n ) ; unordered_map < char , int > m ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { m [ s [ i ] ] ++ ; } string new_string = " " ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( prime [ m [ s [ i ] ] ] ) continue ; new_string += s [ i ] ; } cout << new_string ; } int main ( ) { string str = " geeksforgeeks " ; removePrimeFrequencies ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, j, new_string, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; string rearrange ( string s ) { string s1 = " " , s2 = " " ; for ( char x : s ) { isalpha ( x ) ? s1 . push_back ( x ) : s2 . push_back ( x ) ; } int n = s1 . size ( ) ; int m = s2 . size ( ) ; if ( abs ( n - m ) > 1 ) return " - 1" ; int i = 0 , j = 0 , k = 0 ; int flag = ( n >= m ) ? 1 : 0 ; while ( i < n and j < m ) { if ( flag ) s [ k ++ ] = s1 [ i ++ ] ; else s [ k ++ ] = s2 [ j ++ ] ; flag = ! flag ; } return s ; } int main ( ) { string str = " geeks2020" ; cout << rearrange ( str ) << endl ; return 0 ; }

Accumulator variables: i, j, k, stdc
Iterator variables: x
C++ program:
#include <iostream>
#include <string>
using namespace std ; void charactersCount ( string str , int n ) { int count = 0 ; while ( n > 0 ) { char cur = str [ 0 ] ; int ind = 0 ; for ( int j = 1 ; j < n ; j ++ ) { if ( str [ j ] < cur ) { cur = str [ j ] ; ind = j ; } } str . erase ( str . begin ( ) + ind ) ; n -- ; count += ind + 1 ; } cout << count << endl ; } int main ( ) { string str = " aabbc " ; int n = 5 ; charactersCount ( str , n ) ; return 0 ; }

Index/key variables: j
Accumulator variables: count, j, n
Iterator variables: j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printMiddleCharacter ( string str ) { int len = str . size ( ) ; int middle = len / 2 ; cout << str [ middle ] ; } int main ( ) { string str = " GeeksForGeeks " ; printMiddleCharacter ( str ) ; return 0 ; }

Index/key variables: middle
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool check ( string s ) { set < char > a ; for ( auto i : s ) { if ( a . count ( i ) ) return false ; a . insert ( i ) ; } return true ; } vector < string > helper ( vector < string > & arr , int ind ) { if ( ind == arr . size ( ) ) return { " " } ; vector < string > tmp = helper ( arr , ind + 1 ) ; vector < string > ret ( tmp . begin ( ) , tmp . end ( ) ) ; for ( auto i : tmp ) { string test = i + arr [ ind ] ; if ( check ( test ) ) ret . push_back ( test ) ; } return ret ; } int maxLength ( vector < string > & arr ) { vector < string > tmp = helper ( arr , 0 ) ; int len = 0 ; for ( auto i : tmp ) { len = len > i . size ( ) ? len : i . size ( ) ; } return len ; } int main ( ) { vector < string > s ; s . push_back ( " abcdefgh " ) ; cout << maxLength ( s ) ; return 0 ; }

Index/key variables: ind
Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void Range_sum_query ( string S , vector < pair < int , int > > Query ) { int N = S . length ( ) ; int A [ N ] ; A [ 0 ] = S [ 0 ] - ' a ' + 1 ; for ( int i = 1 ; i < N ; i ++ ) { A [ i ] = S [ i ] - ' a ' + 1 ; A [ i ] = A [ i ] + A [ i - 1 ] ; } for ( int i = 0 ; i < Query . size ( ) ; i ++ ) { if ( Query [ i ] . first == 1 ) { cout << A [ ( Query [ i ] . second ) - 1 ] << endl ; } else { cout << A [ ( Query [ i ] . second ) - 1 ] - A [ ( Query [ i ] . first ) - 2 ] << endl ; } } } int main ( ) { string S = " abcd " ; vector < pair < int , int > > Query ; Query . push_back ( make_pair ( 2 , 4 ) ) ; Query . push_back ( make_pair ( 1 , 3 ) ) ; Range_sum_query ( S , Query ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void swap_ ( char & a , char & b ) { char temp ; temp = a ; a = b ; b = temp ; } void permute ( char * str , int l , int r , int n ) { int i ; if ( l == r ) { int j = atoi ( str ) ; if ( j % n == 0 ) cout << str << endl ; return ; } for ( i = l ; i < r ; i ++ ) { swap_ ( str [ l ] , str [ i ] ) ; permute ( str , l + 1 , r , n ) ; swap_ ( str [ l ] , str [ i ] ) ; } } int main ( ) { char str [ 100 ] = "125" ; int n = 5 ; int len = strlen ( str ) ; if ( len > 0 ) permute ( str , 0 , len , n ) ; return 0 ; }

Index/key variables: i, l
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string decimalToBinary ( int N ) { string ans = " " ; while ( N > 0 ) { if ( N & 1 ) { ans = '1' + ans ; } else { ans = '0' + ans ; } N /= 2 ; } return ans ; } string checkBinaryString ( string & str , int N ) { int map [ N + 10 ] , cnt = 0 ; memset ( map , 0 , sizeof ( map ) ) ; for ( int i = N ; i > 0 ; i -- ) { if ( ! map [ i ] ) { int t = i ; string s = decimalToBinary ( t ) ; if ( str . find ( s ) != str . npos ) { while ( t && ! map [ t ] ) { map [ t ] = 1 ; cnt ++ ; t >>= 1 ; } } } } for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str [ i ] == '0' ) { cnt ++ ; break ; } } if ( cnt == N + 1 ) return " True " ; else return " False " ; } int main ( ) { string str = "0110" ; int N = 3 ; cout << checkBinaryString ( str , N ) ; return 0 ; }

Index/key variables: i, t
Accumulator variables: N, cnt, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string largestAnagramGrp ( vector < string > arr ) { int prime [ ] = { 2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 23 , 29 , 31 , 37 , 41 , 43 , 47 , 53 , 59 , 61 , 67 , 71 , 73 , 79 , 83 , 89 , 97 , 101 } ; int max = -1 ; long maxpdt = -1 ; unordered_map < long long , string > W ; unordered_map < long long , long > P ; for ( string temp : arr ) { long pdt = 1 ; for ( char t : temp ) { pdt *= prime [ t - ' a ' ] ; } if ( P . find ( pdt ) != P . end ( ) ) { P [ pdt ] ++ ; } else { W [ pdt ] = temp ; P [ pdt ] = 1 ; } } for ( auto e : P ) { if ( max < e . second ) { max = e . second ; maxpdt = e . first ; } } return W [ maxpdt ] ; } int main ( ) { char S [ ] = " please ▁ be ▁ silent ▁ and ▁ listen ▁ to ▁ what ▁ the ▁ professor ▁ says ▁ " ; vector < string > arr ; char * token = strtok ( S , " ▁ " ) ; while ( token != NULL ) { arr . push_back ( token ) ; token = strtok ( NULL , " ▁ " ) ; } cout << largestAnagramGrp ( arr ) << endl ; return 0 ; }

Index/key variables: maxpdt, pdt
Accumulator variables: pdt, stdc
Iterator variables: e, t, temp
C++ program:
#include <bits/stdc++.h>
using namespace std ; string print_next_vovel_string ( string str ) { map < char , int > m ; m [ ' a ' ] = 0 ; m [ ' e ' ] = 1 ; m [ ' i ' ] = 2 ; m [ ' o ' ] = 3 ; m [ ' u ' ] = 4 ; char arr [ 5 ] = { ' a ' , ' e ' , ' i ' , ' o ' , ' u ' } ; int N = str . length ( ) ; for ( int i = 0 ; i < N ; i ++ ) { char c = str [ i ] ; if ( c == ' a ' c == ' e ' c == ' i ' c == ' o ' c == ' u ' ) { int index = m + 1 ; int newindex = index % 5 ; str [ i ] = arr [ newindex ] ; } } return str ; } int main ( ) { string str = " geeksforgeeks " ; cout << print_next_vovel_string ( str ) ; return 0 ; }

Index/key variables: i, newindex
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPalindrome ( string str ) { int len = str . length ( ) ; for ( int i = 0 ; i < len ; i ++ ) { if ( str [ i ] != str [ len - i - 1 ] ) return false ; } return true ; } bool isCompressablePalindrome ( string str ) { int len = str . length ( ) ; string compressed = " " ; compressed . push_back ( str [ 0 ] ) ; for ( int i = 1 ; i < len ; i ++ ) { if ( str [ i ] != str [ i - 1 ] ) compressed . push_back ( str [ i ] ) ; } return isPalindrome ( compressed ) ; } int main ( ) { string str = " abbcbbbaaa " ; if ( isCompressablePalindrome ( str ) ) cout << " Yes STRNEWLINE " ; else cout << " No STRNEWLINE " ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; bool isvowel ( char ch ) { return ( ch == ' a ' or ch == ' e ' or ch == ' i ' or ch == ' o ' or ch == ' u ' ) ; } int CountTotal ( string & s ) { int ans = 0 ; int n = s . length ( ) ; int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( isvowel ( s [ i ] ) ) cnt += 1 ; else { ans += ( cnt * ( cnt + 1 ) / 2 ) ; cnt = 0 ; } } if ( cnt != 0 ) { ans += ( cnt * ( cnt + 1 ) / 2 ) ; } return ans ; } int main ( ) { string s = " geeksforgeeks " ; cout << ( CountTotal ( s ) ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, cnt, i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int totCount ; int firstCount ; void getTotCount ( int num ) { totCount = 1 ; firstCount = 1 ; int temp = 1 ; while ( ( num & temp ) == 0 ) { temp = temp << 1 ; totCount += 1 ; } firstCount = totCount ; temp = num >> totCount ; while ( temp != 0 ) { totCount += 1 ; temp = temp >> 1 ; } } int flipBitsFromRightMostSetBit ( int num ) { getTotCount ( num ) ; int num1 = num ^ ( ( 1 << totCount ) - 1 ) ; num1 = num1 ^ ( ( 1 << firstCount ) - 1 ) ; return num1 ; } int main ( ) { int n = 120 ; cout << flipBitsFromRightMostSetBit ( n ) << endl ; return 0 ; }

Accumulator variables: stdc, totCount
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isvowel ( char c ) { return c == ' a ' || c == ' e ' || c == ' i ' || c == ' o ' || c == ' u ' ; } int findMaxLen ( string & s ) { int maxLen = 0 ; int cur = 0 ; if ( isvowel ( s [ 0 ] ) ) cur = maxLen = 1 ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( isvowel ( s [ i ] ) ) { if ( s [ i ] != s [ i - 1 ] ) cur += 1 ; else cur = 1 ; } else { cur = 0 ; } maxLen = max ( cur , maxLen ) ; } return maxLen ; } int main ( ) { string Str = " aeoibsddaeiouudb " ; cout << findMaxLen ( Str ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: cur, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; unsigned long long power ( unsigned long long base , unsigned long long pow ) { unsigned long long res = 1 ; while ( pow > 0 ) { if ( pow & 1 ) res = ( res * base ) ; base = ( base * base ) ; pow >>= 1 ; } return res ; } unsigned long long countNonPalindromicString ( unsigned long long n , unsigned long long m ) { unsigned long long total = power ( n , m ) ; unsigned long long palindrome = power ( n , m / 2 + m % 2 ) ; unsigned long long count = total - palindrome ; return count ; } int main ( ) { int n = 3 , m = 5 ; cout << countNonPalindromicString ( n , m ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < int > freq ( 26 ) ; bool checkPalindrome ( ) { int oddCnt = 0 ; for ( auto x : freq ) { if ( x % 2 == 1 ) oddCnt ++ ; } return oddCnt <= 1 ; } int countPalindromePermutation ( string s , int k ) { for ( int i = 0 ; i < k ; i ++ ) { freq [ s [ i ] - 97 ] ++ ; } int ans = 0 ; if ( checkPalindrome ( ) ) { ans ++ ; } int i = 0 , j = k ; while ( j < s . size ( ) ) { freq [ s [ i ++ ] - 97 ] -- ; freq [ s [ j ++ ] - 97 ] ++ ; if ( checkPalindrome ( ) ) { ans ++ ; } } return ans ; } int main ( ) { string str = " abbaca " ; int K = 3 ; cout << countPalindromePermutation ( str , K ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, j, oddCnt, stdc
Iterator variables: i, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minFlips ( string target ) { char curr = '1' ; int count = 0 ; for ( int i = 0 ; i < target . length ( ) ; i ++ ) { if ( target [ i ] == curr ) { count ++ ; curr = ( char ) ( 48 + ( curr + 1 ) % 2 ) ; } } return count ; } int main ( ) { string S = "011000" ; cout << ( minFlips ( S ) ) ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#include <boost/algorithm/string.hpp>
using namespace std ; bool checkSuffix ( int A , int B ) { int digit_B = log10 ( B ) + 1 ; A -= B ; return ( A % int ( pow ( 10 , digit_B ) ) ) ; } int main ( ) { int A = 12345 , B = 45 ; bool result = checkSuffix ( A , B ) ; if ( ! result ) { cout << " Yes " ; } else { cout << " No " ; } return 0 ; }

Accumulator variables: A, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int count_min_length ( string s ) { int hash [ 26 ] ; int ans = INT_MAX ; for ( int i = 0 ; i < 26 ; i ++ ) hash [ i ] = -1 ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) { if ( hash [ s [ i ] - ' a ' ] == -1 ) hash [ s [ i ] - ' a ' ] = i ; else { if ( hash [ s [ i ] - ' a ' ] == i - 1 hash [ s [ i ] - ' a ' ] == i - 2 ) return 0 ; ans = min ( ans , i - hash [ s [ i ] - ' a ' ] - 1 ) ; hash [ s [ i ] - ' a ' ] = i ; } } if ( ans == INT_MAX ) return -1 ; return ans ; } int main ( ) { string str = " abcdeba " ; cout << count_min_length ( str ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
#include <vector>
using namespace std ; class TreeNode { TreeNode * parent = NULL ; vector < TreeNode * > children ; public : void addChild ( TreeNode * node ) { children . push_back ( node ) ; } void setParent ( TreeNode * node ) { parent = node ; } TreeNode * getParent ( ) { return parent ; } int computeScore ( ) { if ( children . size ( ) == 0 ) return 1 ; int res = 0 ; for ( TreeNode * curr : children ) res += curr -> computeScore ( ) ; if ( parent == NULL ) return res ; else return 2 * res ; } } ; TreeNode * computeTree ( string s ) { TreeNode * current = new TreeNode ( ) ; TreeNode * root = current ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) { if ( s [ i ] == ' ( ' ) { TreeNode * child = new TreeNode ( ) ; child -> setParent ( current ) ; current -> addChild ( child ) ; current = child ; } else { current = current -> getParent ( ) ; } } return root ; } int main ( ) { string s = " ( ( ) ( ( ) ) ) " ; TreeNode * root = computeTree ( s ) ; cout << root -> computeScore ( ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, res
Iterator variables: i
Class/struct names: TreeNode
C++ program:
#include <bits/stdc++.h>
using namespace std ; void rec ( char * a , int i ) { if ( i == 0 ) { cout << a << endl ; return ; } if ( a [ i ] == ' x ' ) { int j = i ; while ( a [ j ] != ' \0' && a [ j + 1 ] != ' \0' ) { swap ( a [ j ] , a [ j + 1 ] ) ; j ++ ; } } rec ( a , i - 1 ) ; } int main ( ) { char a [ ] = { ' g ' , ' e ' , ' e ' , ' k ' , ' x ' , ' s ' , ' x ' , ' x ' , ' k ' , ' s ' , ' \0' } ; int n = 10 ; rec ( a , n - 1 ) ; }

Index/key variables: i, j
Accumulator variables: j, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; string generateString ( int N , int M , int K ) { string s = " " ; int cnt1 = 0 ; int cnt2 = 0 ; for ( int i = 0 ; i < N ; i ++ ) { cnt1 ++ ; cnt2 ++ ; if ( cnt1 <= M ) { if ( cnt2 <= K ) { s = s + char ( 96 + cnt1 ) ; } else { s = s + ' a ' ; } } else { cnt1 = 1 ; cnt2 = 1 ; s = s + ' a ' ; } } return s ; } int main ( ) { int N = 7 , M = 5 , K = 3 ; cout << generateString ( N , M , K ) << endl ; return 0 ; }

Accumulator variables: cnt1, cnt2, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void finalString ( string str ) { int x = 0 , y = 0 ; int left ; int n = str . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == '1' ) x ++ ; else y ++ ; } if ( x > y ) left = 1 ; else left = 0 ; int length = n - 2 * min ( x , y ) ; for ( int i = 0 ; i < length ; i ++ ) { cout << left ; } } int main ( ) { string str = "010110100100000" ; finalString ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, x, y
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printPalindrome ( vector < string > left , string mid , vector < string > right ) { for ( string x : left ) cout << x ; cout << mid ; reverse ( right . begin ( ) , right . end ( ) ) ; for ( string x : right ) cout << x ; cout << endl ; } void findPalindrome ( vector < string > & S , int N , int M ) { set < string > dict ; for ( int i = 0 ; i < M ; i ++ ) { cin >> S [ i ] ; dict . insert ( S [ i ] ) ; } vector < string > left , right ; string mid ; for ( int i = 0 ; i < N ; i ++ ) { string t = S [ i ] ; reverse ( t . begin ( ) , t . end ( ) ) ; if ( t == S [ i ] ) mid = t ; else if ( dict . find ( t ) != dict . end ( ) ) { left . push_back ( S [ i ] ) ; right . push_back ( t ) ; dict . erase ( S [ i ] ) ; dict . erase ( t ) ; } } printPalindrome ( left , mid , right ) ; } int main ( ) { vector < string > S { " tab " , " one " , " bat " } ; int M = 3 ; int N = S . size ( ) ; findPalindrome ( S , N , M ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; void swap ( char & x , char & y ) { char temp = x ; x = y ; y = temp ; } bool IsLexicographicallySmaller ( string A , string B ) { if ( A < B ) { return true ; } string temp = A ; sort ( temp . begin ( ) , temp . end ( ) ) ; int index = -1 ; for ( int i = 0 ; i < A . length ( ) ; i ++ ) { if ( A [ i ] != temp [ i ] ) { index = i ; break ; } } if ( index == -1 ) { return false ; } int j ; for ( int i = 0 ; i < A . length ( ) ; i ++ ) { if ( A [ i ] == temp [ index ] ) j = i ; } swap ( A [ index ] , A [ j ] ) ; if ( A < B ) { return true ; } else { return false ; } } int main ( ) { string A = " AGAIN " ; string B = " ACTION " ; if ( IsLexicographicallySmaller ( A , B ) ) { cout << " Yes " << " STRNEWLINE " ; } else { cout << " No " << " STRNEWLINE " ; } return 0 ; }

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