dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define NO_OF_CHARS  256
int max_distinct_char ( string str , int n ) { int count [ NO_OF_CHARS ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) count [ str [ i ] ] ++ ; int max_distinct = 0 ; for ( int i = 0 ; i < NO_OF_CHARS ; i ++ ) if ( count [ i ] != 0 ) max_distinct ++ ; return max_distinct ; } int smallesteSubstr_maxDistictChar ( string str ) { int n = str . size ( ) ; int max_distinct = max_distinct_char ( str , n ) ; int minl = n ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { string subs = str . substr ( i , j ) ; int subs_lenght = subs . size ( ) ; int sub_distinct_char = max_distinct_char ( subs , subs_lenght ) ; if ( subs_lenght < minl && max_distinct == sub_distinct_char ) { minl = subs_lenght ; } } } return minl ; } int main ( ) { string str = " AABBBCBB " ; int len = smallesteSubstr_maxDistictChar ( str ) ; cout << " ▁ The ▁ length ▁ of ▁ the ▁ smallest ▁ substring " " ▁ consisting ▁ of ▁ maximum ▁ distinct ▁ " " characters ▁ : ▁ " << len ; return 0 ; }

Index/key variables: NO_OF_CHARS, i
Accumulator variables: i, j, max_distinct, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int evaluateBoolExpr ( string s ) { int n = s . length ( ) ; for ( int i = 0 ; i < n ; i += 2 ) { if ( s [ i + 1 ] == ' A ' ) { if ( s [ i + 2 ] == '0' s [ i ] == '0' ) s [ i + 2 ] = '0' ; else s [ i + 2 ] = '1' ; } else if ( s [ i + 1 ] == ' B ' ) { if ( s [ i + 2 ] == '1' s [ i ] == '1' ) s [ i + 2 ] = '1' ; else s [ i + 2 ] = '0' ; } else { if ( s [ i + 2 ] == s [ i ] ) s [ i + 2 ] = '0' ; else s [ i + 2 ] = '1' ; } } return s [ n - 1 ] - '0' ; } int main ( ) { string s = "1C1B1B0A0" ; cout << evaluateBoolExpr ( s ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int FirstRepeated ( string str ) { int checker = 0 ; for ( int i = 0 ; i < str . length ( ) ; ++ i ) { int val = ( str [ i ] - ' a ' ) ; if ( ( checker & ( 1 << val ) ) > 0 ) return i ; checker |= ( 1 << val ) ; } return -1 ; } int main ( ) { string s = " abcfdeacf " ; int i = FirstRepeated ( s ) ; if ( i != -1 ) cout << " Char ▁ = ▁ " << s [ i ] << " ▁ and ▁ Index ▁ = ▁ " << i ; else cout << " No ▁ repeated ▁ Char " ; return 0 ; }

Index/key variables: i
Accumulator variables: checker, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string alphabets = " abcdefghijklmnopqrstuvwxyz " ; void panLipogramChecker ( string s ) { for ( int i = 0 ; i < s . length ( ) ; i ++ ) { s [ i ] = tolower ( s [ i ] ) ; } int counter = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { int pos = s . find ( alphabets [ i ] ) ; if ( pos < 0 || pos > s . length ( ) ) counter += 1 ; } if ( counter == 0 ) cout << " Pangram " << endl ; else if ( counter >= 2 ) cout << " Not ▁ a ▁ pangram ▁ but ▁ might ▁ a ▁ lipogram " << endl ; else cout << " Pangrammatic ▁ Lipogram " << endl ; } int main ( ) { string str = " The ▁ quick ▁ brown ▁ fox ▁ jumped ▁ over ▁ the ▁ lazy ▁ dog " ; panLipogramChecker ( str ) ; str = " The ▁ quick ▁ brown ▁ fox ▁ jumps ▁ over ▁ the ▁ lazy ▁ dog " ; panLipogramChecker ( str ) ; str = " The ▁ quick ▁ brown ▁ fox ▁ jum ▁ over ▁ the ▁ lazy ▁ dog " ; panLipogramChecker ( str ) ; }

Index/key variables: i
Accumulator variables: counter, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void nPermute ( string str , long int n ) { sort ( str . begin ( ) , str . end ( ) ) ; long int i = 1 ; do { if ( i == n ) break ; i ++ ; } while ( next_permutation ( str . begin ( ) , str . end ( ) ) ) ; cout << str ; } int main ( ) { string str = " GEEKSFORGEEKS " ; long int n = 100 ; nPermute ( str , n ) ; return 0 ; }

Accumulator variables: i, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void splitString ( string str ) { string alpha , num , special ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( isdigit ( str [ i ] ) ) num . push_back ( str [ i ] ) ; else if ( ( str [ i ] >= ' A ' && str [ i ] <= ' Z ' ) || ( str [ i ] >= ' a ' && str [ i ] <= ' z ' ) ) alpha . push_back ( str [ i ] ) ; else special . push_back ( str [ i ] ) ; } cout << alpha << endl ; cout << num << endl ; cout << special << endl ; } int main ( ) { string str = " geeks01 $ $ for02geeks03 ! @ ! ! " ; splitString ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void subString ( string s , int n ) { for ( int i = 0 ; i < n ; i ++ ) for ( int len = 1 ; len <= n - i ; len ++ ) cout << s . substr ( i , len ) << endl ; } int main ( ) { string s = " abcd " ; subString ( s , s . length ( ) ) ; return 0 ; }

Accumulator variables: i, len, stdc
Iterator variables: i, len
C++ program:
#include <iostream>
using namespace std ; void printSubstrings ( string str ) { int n = str . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { for ( int k = i ; k <= j ; k ++ ) { cout << str [ k ] ; } cout << endl ; } } } int main ( ) { string str = " abcd " ; printSubstrings ( str ) ; return 0 ; }

Index/key variables: k
Accumulator variables: i, j, k
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; int n ; int solve ( int i , int X , int Y , int a [ ] , int b [ ] , int n ) { if ( i == n ) return 0 ; if ( X <= 0 ) return b [ i ] + solve ( i + 1 , X , Y - 1 , a , b , n ) ; if ( Y <= 0 ) return a [ i ] + solve ( i + 1 , X - 1 , Y , a , b , n ) ; else return max ( a [ i ] + solve ( i + 1 , X - 1 , Y , a , b , n ) , b [ i ] + solve ( i + 1 , X , Y - 1 , a , b , n ) ) ; } int main ( ) { int a [ ] = { 1 , 2 , 3 , 4 , 5 } ; int b [ ] = { 5 , 4 , 3 , 2 , 1 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; int x = 3 , y = 3 ; cout << solve ( 0 , x , y , a , b , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct suffix { int index ; int rank [ 2 ] ; } ; int cmp ( struct suffix a , struct suffix b ) { return ( a . rank [ 0 ] == b . rank [ 0 ] ) ? ( a . rank [ 1 ] < b . rank [ 1 ] ? 1 : 0 ) : ( a . rank [ 0 ] < b . rank [ 0 ] ? 1 : 0 ) ; } vector < int > buildSuffixArray ( string txt , int n ) { struct suffix suffixes [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { suffixes [ i ] . index = i ; suffixes [ i ] . rank [ 0 ] = txt [ i ] - ' a ' ; suffixes [ i ] . rank [ 1 ] = ( ( i + 1 ) < n ) ? ( txt [ i + 1 ] - ' a ' ) : -1 ; } sort ( suffixes , suffixes + n , cmp ) ; int ind [ n ] ; for ( int k = 4 ; k < 2 * n ; k = k * 2 ) { int rank = 0 ; int prev_rank = suffixes [ 0 ] . rank [ 0 ] ; suffixes [ 0 ] . rank [ 0 ] = rank ; ind [ suffixes [ 0 ] . index ] = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( suffixes [ i ] . rank [ 0 ] == prev_rank && suffixes [ i ] . rank [ 1 ] == suffixes [ i - 1 ] . rank [ 1 ] ) { prev_rank = suffixes [ i ] . rank [ 0 ] ; suffixes [ i ] . rank [ 0 ] = rank ; } else { prev_rank = suffixes [ i ] . rank [ 0 ] ; suffixes [ i ] . rank [ 0 ] = ++ rank ; } ind [ suffixes [ i ] . index ] = i ; } for ( int i = 0 ; i < n ; i ++ ) { int nextindex = suffixes [ i ] . index + k / 2 ; suffixes [ i ] . rank [ 1 ] = ( nextindex < n ) ? suffixes [ ind [ nextindex ] ] . rank [ 0 ] : -1 ; } sort ( suffixes , suffixes + n , cmp ) ; } vector < int > suffixArr ; for ( int i = 0 ; i < n ; i ++ ) suffixArr . push_back ( suffixes [ i ] . index ) ; return suffixArr ; } vector < int > kasai ( string txt , vector < int > suffixArr ) { int n = suffixArr . size ( ) ; vector < int > lcp ( n , 0 ) ; vector < int > invSuff ( n , 0 ) ; for ( int i = 0 ; i < n ; i ++ ) invSuff [ suffixArr [ i ] ] = i ; int k = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( invSuff [ i ] == n - 1 ) { k = 0 ; continue ; } int j = suffixArr [ invSuff [ i ] + 1 ] ; while ( i + k < n && j + k < n && txt [ i + k ] == txt [ j + k ] ) k ++ ; lcp [ invSuff [ i ] ] = k ; if ( k > 0 ) k -- ; } return lcp ; } int sumOfFirstN ( int N ) { return ( N * ( N + 1 ) ) / 2 ; } char printKthCharInConcatSubstring ( string str , int K ) { int n = str . length ( ) ; vector < int > suffixArr = buildSuffixArray ( str , n ) ; vector < int > lcp = kasai ( str , suffixArr ) ; for ( int i = 0 ; i < lcp . size ( ) ; i ++ ) { int charToSkip = sumOfFirstN ( n - suffixArr [ i ] ) - sumOfFirstN ( lcp [ i ] ) ; if ( K <= charToSkip ) { for ( int j = lcp [ i ] + 1 ; j <= ( n - suffixArr [ i ] ) ; j ++ ) { int curSubstringLen = j ; if ( K <= curSubstringLen ) return str [ ( suffixArr [ i ] + K - 1 ) ] ; else K -= curSubstringLen ; } break ; } else K -= charToSkip ; } } int main ( ) { string str = " banana " ; int K = 10 ; cout << printKthCharInConcatSubstring ( str , K ) ; return 0 ; }

Index/key variables: i, n, nextindex
Accumulator variables: K, i, j, k, stdc
Iterator variables: i, j, k
Class/struct names: suffix
C++ program:
#include <bits/stdc++.h>
using namespace std ; int evenNumSubstring ( char str [ ] ) { int len = strlen ( str ) ; int count = 0 ; for ( int i = 0 ; i < len ; i ++ ) { int temp = str [ i ] - '0' ; if ( temp % 2 == 0 ) count += ( i + 1 ) ; } return count ; } int main ( ) { char str [ ] = "1234" ; cout << evenNumSubstring ( str ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { Node * left , * right ; int val ; } ; Node * newNode ( int val ) { Node * temp = new Node ( ) ; temp -> val = val ; temp -> left = temp -> right = NULL ; return temp ; } int maxPathLenUtil ( Node * root , int prev_val , int prev_len ) { if ( ! root ) return prev_len ; int cur_val = root -> val ; if ( cur_val == prev_val + 1 ) { return max ( maxPathLenUtil ( root -> left , cur_val , prev_len + 1 ) , maxPathLenUtil ( root -> right , cur_val , prev_len + 1 ) ) ; } int newPathLen = max ( maxPathLenUtil ( root -> left , cur_val , 1 ) , maxPathLenUtil ( root -> right , cur_val , 1 ) ) ; return max ( prev_len , newPathLen ) ; } int maxConsecutivePathLength ( Node * root ) { if ( root == NULL ) return 0 ; return maxPathLenUtil ( root , root -> val - 1 , 0 ) ; } int main ( ) { Node * root = newNode ( 10 ) ; root -> left = newNode ( 11 ) ; root -> right = newNode ( 9 ) ; root -> left -> left = newNode ( 13 ) ; root -> left -> right = newNode ( 12 ) ; root -> right -> left = newNode ( 13 ) ; root -> right -> right = newNode ( 8 ) ; cout << " Maximum ▁ Consecutive ▁ Increasing ▁ Path ▁ Length ▁ is ▁ " << maxConsecutivePathLength ( root ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isSubSequence ( string str1 , string str2 ) { int m = str1 . length ( ) , n = str2 . length ( ) ; for ( int i = 0 ; i < n && j < m ; i ++ ) if ( str1 [ j ] == str2 [ i ] ) j ++ ; return ( j == m ) ; } string findLongestString ( vector < string > dict , string str ) { string result = " " ; int length = 0 ; for ( string word : dict ) { if ( length < word . length ( ) && isSubSequence ( word , str ) ) { result = word ; length = word . length ( ) ; } } return result ; } int main ( ) { vector < string > dict = { " ale " , " apple " , " monkey " , " plea " } ; string str = " abpcplea " ; cout << findLongestString ( dict , str ) << endl ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, word
C++ program:
#include <bits/stdc++.h>
#define MAX_CHAR  26
using namespace std ; class SuffixTrieNode { public : SuffixTrieNode * children [ MAX_CHAR ] ; { for ( int i = 0 ; i < MAX_CHAR ; i ++ ) children [ i ] = NULL ; } void SuffixTrieNode :: insertSuffix ( string s ) { if ( s . length ( ) > 0 ) { char cIndex = s . at ( 0 ) - ' a ' ; if ( children [ cIndex ] == NULL ) children [ cIndex ] = new SuffixTrieNode ( ) ; children [ cIndex ] -> insertSuffix ( s . substr ( 1 ) ) ; } } class SuffixTrie { SuffixTrieNode * root ; int _countNodesInTrie ( SuffixTrieNode * ) ; public : SuffixTrie ( string s ) { root = new SuffixTrieNode ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) root -> insertSuffix ( s . substr ( i ) ) ; } int SuffixTrie :: _countNodesInTrie ( SuffixTrieNode * node ) { if ( node == NULL ) return 0 ; int count = 0 ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) { if ( node -> children [ i ] != NULL ) count += _countNodesInTrie ( node -> children [ i ] ) ; } return ( 1 + count ) ; } int countNodesInTrie ( ) { return _countNodesInTrie ( root ) ; } } ; int countDistinctSubstring ( string str ) { SuffixTrie sTrie ( str ) ; return sTrie . countNodesInTrie ( ) ; } int main ( ) { string str = " ababa " ; cout << " Count ▁ of ▁ distinct ▁ substrings ▁ is ▁ " << countDistinctSubstring ( str ) ; return 0 ; }

Index/key variables: MAX_CHAR, cIndex, i
Accumulator variables: count, i, stdc
Iterator variables: i
Class/struct names: SuffixTrie, SuffixTrieNode
C++ program:
#include <bits/stdc++.h>
void encryptDecrypt ( char inpString [ ] ) { char xorKey = ' P ' ; int len = strlen ( inpString ) ; for ( int i = 0 ; i < len ; i ++ ) { inpString [ i ] = inpString [ i ] ^ xorKey ; printf ( " % c " , inpString [ i ] ) ; } } int main ( ) { char sampleString [ ] = " GeeksforGeeks " ; printf ( " Encrypted ▁ String : ▁ " ) ; encryptDecrypt ( sampleString ) ; printf ( " STRNEWLINE " ) ; printf ( " Decrypted ▁ String : ▁ " ) ; encryptDecrypt ( sampleString ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int versionCompare ( string v1 , string v2 ) { int vnum1 = 0 , vnum2 = 0 ; for ( int i = 0 , j = 0 ; ( i < v1 . length ( ) || j < v2 . length ( ) ) ; ) { while ( i < v1 . length ( ) && v1 [ i ] != ' . ' ) { vnum1 = vnum1 * 10 + ( v1 [ i ] - '0' ) ; i ++ ; } while ( j < v2 . length ( ) && v2 [ j ] != ' . ' ) { vnum2 = vnum2 * 10 + ( v2 [ j ] - '0' ) ; j ++ ; } if ( vnum1 > vnum2 ) return 1 ; if ( vnum2 > vnum1 ) return -1 ; vnum1 = vnum2 = 0 ; i ++ ; j ++ ; } return 0 ; } int main ( ) { string version1 = "1.0.3" ; string version2 = "1.0.7" ; if ( versionCompare ( version1 , version2 ) < 0 ) cout << version1 << " ▁ is ▁ smaller STRNEWLINE " ; else if ( versionCompare ( version1 , version2 ) > 0 ) cout << version2 << " ▁ is ▁ smaller STRNEWLINE " ; else cout << " Both ▁ version ▁ are ▁ equal STRNEWLINE " ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#define MAX_CHAR  256
using namespace std ; bool isPalindrome ( char str [ ] , int l , int h ) { while ( h > l ) if ( str [ l ++ ] != str [ h -- ] ) return false ; return true ; } int check ( char str [ ] ) { int n = strlen ( str ) ; int freq [ MAX_CHAR ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) { freq [ str [ i ] ] ++ ; if ( freq [ str [ i ] ] > 2 ) return true ; } int k = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( freq [ str [ i ] ] > 1 ) str [ k ++ ] = str [ i ] ; str [ k ] = ' \0' ; if ( isPalindrome ( str , 0 , k - 1 ) ) { if ( k & 1 ) return str [ k / 2 ] == str [ k / 2 - 1 ] ; return false ; } return true ; } int main ( ) { char str [ ] = " ABCABD " ; if ( check ( str ) ) cout << " Repeated ▁ Subsequence ▁ Exists " ; else cout << " Repeated ▁ Subsequence ▁ Doesn ' t ▁ Exists " ; return 0 ; }

Index/key variables: MAX_CHAR, i, k
Accumulator variables: h, i, k, l, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool prevPermutation ( string & str ) { int n = str . length ( ) - 1 ; int i = n ; while ( i > 0 && str [ i - 1 ] <= str [ i ] ) i -- ; if ( i <= 0 ) return false ; int j = i - 1 ; while ( j + 1 <= n && str [ j + 1 ] < str [ i - 1 ] ) j ++ ; swap ( str [ i - 1 ] , str [ j ] ) ; reverse ( str . begin ( ) + i , str . end ( ) ) ; return true ; } int main ( ) { string str = "4321" ; if ( prevPermutation ( str ) ) cout << " Previous ▁ permutation ▁ is ▁ " << str ; else cout << " Previous ▁ permutation ▁ doesn ' t ▁ exist " ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int val ; struct Node * left , * right ; } ; int length ( Node * node , int * ans ) { if ( ! node ) return 0 ; int left = length ( node -> left , ans ) ; int right = length ( node -> right , ans ) ; int Leftmax = 0 , Rightmax = 0 ; if ( node -> left && node -> left -> val == node -> val ) Leftmax += left + 1 ; if ( node -> right && node -> right -> val == node -> val ) Rightmax += right + 1 ; * ans = max ( * ans , Leftmax + Rightmax ) ; return max ( Leftmax , Rightmax ) ; } int longestSameValuePath ( Node * root ) { int ans = 0 ; length ( root , & ans ) ; return ans ; } Node * newNode ( int data ) { Node * temp = new Node ; temp -> val = data ; temp -> left = temp -> right = NULL ; return temp ; } int main ( ) { Node * root = NULL ; root = newNode ( 4 ) ; root -> left = newNode ( 4 ) ; root -> right = newNode ( 4 ) ; root -> left -> left = newNode ( 4 ) ; root -> left -> right = newNode ( 9 ) ; root -> right -> right = newNode ( 5 ) ; cout << longestSameValuePath ( root ) ; return 0 ; }

Accumulator variables: Leftmax, Rightmax, stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isEditDistanceOne ( string s1 , string s2 ) { int m = s1 . length ( ) , n = s2 . length ( ) ; if ( abs ( m - n ) > 1 ) return false ; int i = 0 , j = 0 ; while ( i < m && j < n ) { if ( s1 [ i ] != s2 [ j ] ) { if ( count == 1 ) return false ; if ( m > n ) i ++ ; else if ( m < n ) j ++ ; { i ++ ; j ++ ; } count ++ ; } { i ++ ; j ++ ; } } if ( i < m j < n ) count ++ ; return count == 1 ; } int main ( ) { string s1 = " gfg " ; string s2 = " gf " ; isEditDistanceOne ( s1 , s2 ) ? cout << " Yes " : cout << " No " ; return 0 ; }

Index/key variables: i, j
Accumulator variables: count, i, j, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define M  1000
int cntNum ( string X , int i , int sum , int tight , int dp [ M ] [ M ] [ 2 ] ) { if ( i >= X . length ( ) sum < 0 ) { if ( sum == 0 ) { return 1 ; } return 0 ; } if ( dp [ sum ] [ i ] [ tight ] != -1 ) { return dp [ sum ] [ i ] [ tight ] ; } int res = 0 ; int end = tight ? X [ i ] - '0' : 9 ; for ( int j = 0 ; j <= end ; j ++ ) { res += cntNum ( X , i + 1 , sum - j , ( tight & ( j == end ) ) , dp ) ; } return dp [ sum ] [ i ] [ tight ] = res ; } int UtilCntNumRange ( int L , int R , int Y ) { if ( R == 0 && Y == 0 ) { return 1 ; } string str = to_string ( R ) ; int dp [ M ] [ M ] [ 2 ] ; memset ( dp , -1 , sizeof ( dp ) ) ; int cntR = cntNum ( str , 0 , Y , true , dp ) ; str = to_string ( L - 1 ) ; memset ( dp , -1 , sizeof ( dp ) ) ; int cntL = cntNum ( str , 0 , Y , true , dp ) ; return ( cntR - cntL ) ; } int main ( ) { int L = 20 , R = 10000 , Y = 14 ; cout << UtilCntNumRange ( L , R , Y ) ; }

Index/key variables: M, i, sum, tight
Accumulator variables: j, res, stdc
Iterator variables: j
C++ program:
#include <iostream>
using namespace std ; int countSubStr ( char str [ ] ) { int res = 0 ; for ( int i = 0 ; str [ i ] != ' \0' ; i ++ ) { if ( str [ i ] == '1' ) { for ( int j = i + 1 ; str [ j ] != ' \0' ; j ++ ) if ( str [ j ] == '1' ) res ++ ; } } return res ; } int main ( ) { char str [ ] = "00100101" ; cout << countSubStr ( str ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, res
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void swap ( char * a , char * b ) { char t = * a ; * a = * b ; * b = t ; } void reverse ( char * str , int low , int high ) { while ( low < high ) { swap ( & str [ low ] , & str [ high ] ) ; ++ low ; -- high ; } } void cycleLeader ( char * str , int shift , int len ) { int j ; char item ; for ( int i = 1 ; i < len ; i *= 3 ) { j = i ; item = str [ j + shift ] ; do { if ( j & 1 ) j = len / 2 + j / 2 ; else j /= 2 ; swap ( & str [ j + shift ] , & item ) ; } while ( j != i ) ; } } void moveNumberToSecondHalf ( char * str ) { int k , lenFirst ; int lenRemaining = strlen ( str ) ; int shift = 0 ; while ( lenRemaining ) { k = 0 ; while ( pow ( 3 , k ) + 1 <= lenRemaining ) k ++ ; lenFirst = pow ( 3 , k - 1 ) + 1 ; lenRemaining -= lenFirst ; cycleLeader ( str , shift , lenFirst ) ; reverse ( str , shift / 2 , shift - 1 ) ; reverse ( str , shift , shift + lenFirst / 2 - 1 ) ; reverse ( str , shift / 2 , shift + lenFirst / 2 - 1 ) ; shift += lenFirst ; } } int main ( ) { char str [ ] = " a1b2c3d4e5f6g7" ; moveNumberToSecondHalf ( str ) ; cout << str ; return 0 ; }

Index/key variables: high, low
Accumulator variables: i, j, k, lenRemaining, shift, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; Node * left , * right ; } ; Node * newNode ( int data ) { Node * node = new Node ; node -> data = data ; node -> left = node -> right = NULL ; return node ; } Node * removeShortPathNodesUtil ( Node * root , int level , int k ) { if ( root == NULL ) return NULL ; root -> left = removeShortPathNodesUtil ( root -> left , level + 1 , k ) ; root -> right = removeShortPathNodesUtil ( root -> right , level + 1 , k ) ; if ( root -> left == NULL && root -> right == NULL && level < k ) { delete root ; return NULL ; } return root ; } Node * removeShortPathNodes ( Node * root , int k ) { int pathLen = 0 ; return removeShortPathNodesUtil ( root , 1 , k ) ; } void printInorder ( Node * root ) { if ( root ) { printInorder ( root -> left ) ; cout << root -> data << " ▁ " ; printInorder ( root -> right ) ; } } int main ( ) { int k = 4 ; Node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 3 ) ; root -> left -> left = newNode ( 4 ) ; root -> left -> right = newNode ( 5 ) ; root -> left -> left -> left = newNode ( 7 ) ; root -> right -> right = newNode ( 6 ) ; root -> right -> right -> left = newNode ( 8 ) ; cout << " Inorder ▁ Traversal ▁ of ▁ Original ▁ tree " << endl ; printInorder ( root ) ; cout << endl ; cout << " Inorder ▁ Traversal ▁ of ▁ Modified ▁ tree " << endl ; Node * res = removeShortPathNodes ( root , k ) ; printInorder ( res ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; char * removeDuplicate ( char str [ ] , int n ) { set < char > s ( str , str + n - 1 ) ; int i = 0 ; for ( auto x : s ) str [ i ++ ] = x ; str [ i ] = ' \0' ; return str ; } int main ( ) { char str [ ] = " geeksforgeeks " ; int n = sizeof ( str ) / sizeof ( str [ 0 ] ) ; cout << removeDuplicate ( str , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: x