dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSubStr ( string str , int len , int k ) { int count = 0 ; for ( int i = 0 ; i < len ; i ++ ) { int n = 0 ; for ( int j = i ; j < len ; j ++ ) { n = n * 10 + ( str [ j ] - '0' ) ; if ( n % k == 0 ) count ++ ; } } return count ; } int main ( ) { string str = "33445" ; int len = str . length ( ) ; int k = 11 ; cout << countSubStr ( str , len , k ) ; return 0 ; }

Index/key variables: j
Accumulator variables: count, i, j, stdc
Iterator variables: i, j
C++ program:
#include <iostream>
using namespace std ; char Colour_Combination ( string s ) { char temp = s [ 0 ] ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( temp != s [ i ] ) { if ( ( temp == ' B ' temp == ' G ' ) && ( s [ i ] == ' G ' s [ i ] == ' B ' ) ) temp = ' Y ' ; else if ( ( temp == ' B ' temp == ' Y ' ) && ( s [ i ] == ' Y ' s [ i ] == ' B ' ) ) temp = ' G ' ; else temp = ' B ' ; } } return temp ; } int main ( int argc , char * * argv ) { string s = " GBYGB " ; cout << Colour_Combination ( s ) ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void reverse ( string str , int x ) { int n = ( str . length ( ) - x ) / 2 ; for ( int i = 0 ; i < n ; i ++ ) cout << str [ i ] ; for ( int i = n + x - 1 ; i >= n ; i -- ) cout << str [ i ] ; for ( int i = n + x ; i < str . length ( ) ; i ++ ) cout << str [ i ] ; } int main ( ) { string str = " geeksforgeeks " ; int x = 3 ; reverse ( str , x ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string lexoSmallest ( string s , int n ) { int ca = 0 , cb = 0 , cc = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == ' a ' ) ca ++ ; else if ( s [ i ] == ' b ' ) cb ++ ; else cc ++ ; } if ( ca == cb && cb == cc ) { return s ; } int cnt = n / 3 ; if ( cnt * 3 != n ) { return " - 1" ; } int i = 0 ; while ( ca < cnt && i < n ) { if ( s [ i ] == ' b ' && cb > cnt ) { cb -- ; s [ i ] = ' a ' ; ca ++ ; } else if ( s [ i ] == ' c ' && cc > cnt ) { cc -- ; s [ i ] = ' a ' ; ca ++ ; } i ++ ; } i = 0 ; while ( cb < cnt && i < n ) { if ( s [ i ] == ' c ' && cc > cnt ) { cc -- ; s [ i ] = '1' ; cb ++ ; } i ++ ; } i = n - 1 ; while ( cc < cnt && i >= 0 ) { if ( s [ i ] == ' a ' && ca > cnt ) { ca -- ; s [ i ] = ' c ' ; cc ++ ; } i -- ; } i = n - 1 ; while ( cb < cnt && i >= 0 ) { if ( s [ i ] == ' a ' && ca > cnt ) { ca -- ; s [ i ] = ' b ' ; cb ++ ; } i -- ; } i = n - 1 ; while ( cc < cnt && i >= 0 ) { if ( s [ i ] == ' b ' && cb > cnt ) { cb -- ; s [ i ] = ' c ' ; cc ++ ; } i -- ; } return s ; } int main ( ) { string s = " aaaaaa " ; int n = s . size ( ) ; cout << lexoSmallest ( s , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ca, cb, cc, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getSteps ( string str , int i , int j , int n ) { int k = i + 1 ; int steps = 0 ; char ch = str [ i ] ; while ( k <= j ) { if ( str [ k ] != ch ) { steps ++ ; ch = str [ k ] ; } k ++ ; } return steps ; } int getMinSteps ( string str , int i , int j , int n ) { if ( j < i ) { int temp = i ; i = j ; j = temp ; } int stepsToRight = getSteps ( str , i , j , n ) ; int stepsToLeft = getSteps ( str , 0 , i , n ) + getSteps ( str , j , n - 1 , n ) ; if ( str [ 0 ] != str [ n - 1 ] ) stepsToLeft ++ ; return min ( stepsToLeft , stepsToRight ) ; } int main ( ) { string str = " SSNSS " ; int n = str . length ( ) ; int i = 0 , j = 3 ; cout << getMinSteps ( str , i , j , n ) ; return 0 ; }

Index/key variables: i, k
Accumulator variables: k, stdc, steps, stepsToLeft
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX_CHAR = 256 ; int countSubStrings ( string s , string anotherStr , int k ) { bool illegal [ MAX_CHAR ] = { false } ; for ( int i = 0 ; i < anotherStr . size ( ) ; i ++ ) illegal [ anotherStr [ i ] ] = true ; unordered_set < string > us ; for ( int i = 0 ; i < s . size ( ) ; ++ i ) { string ss = " " ; int count = 0 ; for ( int j = i ; j < s . size ( ) ; ++ j ) { if ( illegal [ s [ j ] ] ) ++ count ; ss = ss + s [ j ] ; if ( count <= k ) { us . insert ( ss ) ; } else break ; } } return us . size ( ) ; } int main ( ) { string str = " acbacbacaa " ; string anotherStr = " abcdefghijklmnopqrstuvwxyz " ; int k = 2 ; cout << countSubStrings ( str , anotherStr , k ) ; return 0 ; }

Index/key variables: MAX_CHAR, i, j
Accumulator variables: i, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countPairs ( string bracks [ ] , int num ) { unordered_map < int , int > open , close ; int cnt = 0 ; for ( int i = 0 ; i < num ; i ++ ) { string s = bracks [ i ] ; int l = s . length ( ) ; int op = 0 , cl = 0 ; for ( int j = 0 ; j < l ; j ++ ) { if ( s [ j ] == ' ( ' ) op ++ ; { if ( op ) op -- ; cl ++ ; } } if ( op && ! cl ) open [ op ] ++ ; if ( cl && ! op ) close [ cl ] ++ ; if ( ! op && ! cl ) cnt ++ ; } cnt = cnt / 2 ; for ( auto it : open ) cnt += min ( it . second , close [ it . first ] ) ; return cnt ; } int main ( ) { string bracks [ ] = { " ) ( ) ) " , " ) " , " ( ( " , " ( ( " , " ( " , " ) " , " ) " } ; int num = sizeof ( bracks ) / sizeof ( bracks [ 0 ] ) ; cout << countPairs ( bracks , num ) ; }

Index/key variables: cl, i, j, op
Accumulator variables: cl, cnt, i, j, op, stdc
Iterator variables: i, it, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; string decrypt ( string s , int l ) { string ans = " " ; if ( l % 2 ) { int cnt = 0 ; int indl = 0 , indr = l - 1 ; while ( ans . size ( ) != l ) { if ( cnt % 2 == 0 ) ans += s [ indl ++ ] ; else ans += s [ indr -- ] ; cnt ++ ; } } else { int cnt = 0 ; int indl = 0 , indr = l - 1 ; while ( ans . size ( ) != l ) { if ( cnt % 2 == 0 ) ans += s [ indr -- ] ; else ans += s [ indl ++ ] ; cnt ++ ; } } reverse ( ans . begin ( ) , ans . end ( ) ) ; return ans ; } int main ( ) { string s = " segosegekfrek " ; int l = s . length ( ) ; cout << decrypt ( s , l ) ; return 0 ; }

Accumulator variables: ans, cnt, indl, indr, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; string removeChars ( string s ) { string modifiedStr = " " ; modifiedStr += s [ 0 ] ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( isupper ( s [ i ] ) && islower ( s [ i - 1 ] ) || islower ( s [ i ] ) && isupper ( s [ i - 1 ] ) ) modifiedStr += s [ i ] ; } return modifiedStr ; } int main ( ) { string s = " GeeksForGeeks " ; cout << removeChars ( s ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, modifiedStr, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int pangramCost ( int arr [ ] , string str ) { int cost = 0 ; bool occurred [ 26 ] = { false } ; for ( int i = 0 ; i < str . size ( ) ; i ++ ) occurred [ str [ i ] - ' a ' ] = true ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( ! occurred [ i ] ) cost += arr [ i ] ; } return cost ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 } ; string str = " abcdefghijklmopqrstuvwz " ; cout << pangramCost ( arr , str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cost, i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void pairStar ( string & input , string & output , int i = 0 ) { output = output + input [ i ] ; if ( i == input . length ( ) - 1 ) return ; if ( input [ i ] == input [ i + 1 ] ) output = output + ' * ' ; pairStar ( input , output , i + 1 ) ; } int main ( ) { string input = " geeks " , output = " " ; pairStar ( input , output ) ; cout << output << endl ; return 0 ; }

Index/key variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxOperations ( string str ) { int i , g , gk , gks ; i = g = gk = gks = 0 ; for ( i = 0 ; i < str . length ( ) ; i ++ ) { if ( str [ i ] == ' g ' ) { g ++ ; } else if ( str [ i ] == ' k ' ) { if ( g > 0 ) { g -- ; gk ++ ; } } else if ( str [ i ] == ' s ' ) { if ( gk > 0 ) { gk -- ; gks ++ ; } } } return gks ; } int main ( ) { string a = " ggkssk " ; cout << maxOperations ( a ) ; return 0 ; }

Index/key variables: i
Accumulator variables: g, gk, gks, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int * getFrequencies ( string str ) { static int freq [ 26 ] = { 0 } ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { freq [ str [ i ] - ' a ' ] ++ ; } return freq ; } int countMinParts ( string str ) { int n = str . length ( ) ; int * freq = getFrequencies ( str ) ; vector < int > oddFreq , evenFreq ; int i , sumEven = 0 ; for ( i = 0 ; i < 26 ; i ++ ) { if ( freq [ i ] == 0 ) continue ; if ( freq [ i ] % 2 == 0 ) evenFreq . push_back ( freq [ i ] ) ; else oddFreq . push_back ( freq [ i ] ) ; } for ( i = 0 ; i < evenFreq . size ( ) ; i ++ ) { sumEven += evenFreq [ i ] ; } if ( oddFreq . size ( ) == 0 ) return 1 ; if ( sumEven == 0 ) { if ( oddFreq . size ( ) == 1 ) return 1 ; return 0 ; } i = 0 ; while ( i < oddFreq . size ( ) ) { if ( ( sumEven / 2 ) % oddFreq . size ( ) == 0 ) return oddFreq . size ( ) ; if ( oddFreq [ i ] == 1 ) { i ++ ; continue ; } sumEven += 2 ; oddFreq [ i ] = oddFreq [ i ] - 2 ; } return n ; } int main ( ) { string s = " noonpeep " ; cout << countMinParts ( s ) ; }

Index/key variables: i
Accumulator variables: i, stdc, sumEven
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printPattern ( char s [ ] , int n ) { cout << s << " STRNEWLINE " ; int i = 0 , j = n - 2 ; while ( i < j ) { char c = s [ i ] ; s [ i ] = s [ j ] ; s [ j ] = c ; i ++ ; j -- ; } i = 0 ; j = n - 2 ; while ( j - i > 1 ) { s [ i ] = s [ j ] = ' * ' ; cout << s << " STRNEWLINE " ; i ++ ; j -- ; } } int main ( ) { char s [ ] = " geeks " ; int n = sizeof ( s ) / sizeof ( s [ 0 ] ) ; printPattern ( s , n ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
C++ program:
#include <bits/stdc++.h>
#define ll  long long int
using namespace std ; bool prime ( int n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return true ; if ( n % 2 == 0 n % 3 == 0 ) return false ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return false ; return true ; } bool isVowel ( char c ) { c = tolower ( c ) ; if ( c == ' a ' c == ' e ' c == ' i ' c == ' o ' c == ' u ' ) return true ; return false ; } bool isValidString ( string word ) { int cnt = 0 ; for ( int i = 0 ; i < word . length ( ) ; i ++ ) { if ( isVowel ( word [ i ] ) ) cnt ++ ; } if ( prime ( cnt ) ) return true ; else return false ; } int main ( ) { string s = " geeksforgeeks " ; if ( isValidString ( s ) ) cout << " YES " ; else cout << " NO " ; return 0 ; }

Index/key variables: i
Accumulator variables: cnt, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printExpansion ( string str ) { string suff = " " ; for ( int i = str . length ( ) - 1 ; i >= 0 ; i -- ) { suff = suff + str [ i ] ; cout << suff ; } } int main ( ) { string str = " geeks " ; printExpansion ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; char logicalExpressionEvaluation ( string str ) { stack < char > arr ; for ( int i = str . length ( ) - 1 ; i >= 0 ; i -- ) { if ( str [ i ] == ' [ ' ) { vector < char > s ; while ( arr . top ( ) != ' ] ' ) { s . push_back ( arr . top ( ) ) ; arr . pop ( ) ; } arr . pop ( ) ; if ( s . size ( ) == 3 ) { s [ 2 ] == '1' ? arr . push ( '0' ) : arr . push ( '1' ) ; } else if ( s . size ( ) == 5 ) { int a = s [ 0 ] - 48 , b = s [ 4 ] - 48 , c ; s [ 2 ] == ' & ' ? c = a && b : c = a || b ; arr . push ( ( char ) c + 48 ) ; } } else { arr . push ( str [ i ] ) ; } } return arr . top ( ) ; } int main ( ) { string str = " [ [0 , & ,1 ] , | , [ ! ,1 ] ] " ; cout << logicalExpressionEvaluation ( str ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int count ( string s , int k ) { int n = s . length ( ) ; int d = 0 , i ; int count = 0 ; for ( i = 0 ; i < n ; i ++ ) d += s [ i ] ; if ( d % k == 0 ) count += 1 ; for ( i = k ; i < n ; i ++ ) { int prev = s [ i - k ] ; d -= prev ; d += s [ i ] ; if ( d % k == 0 ) count += 1 ; } return count ; } int main ( ) { string s = " bcgabc " ; int k = 3 ; int ans = count ( s , k ) ; cout << ( ans ) ; }

Index/key variables: i
Accumulator variables: count, d, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string printFinalString ( string s ) { int i , n ; n = s . length ( ) ; int x = 0 , y = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( s [ i ] == ' x ' ) x ++ ; else y ++ ; } string finalString = " " ; if ( x > y ) for ( i = 0 ; i < x - y ; i ++ ) finalString += " x " ; else for ( i = 0 ; i < y - x ; i ++ ) finalString += " y " ; return finalString ; } int main ( ) { string s = " xxyyxyy " ; cout << printFinalString ( s ) ; }

Index/key variables: i
Accumulator variables: finalString, i, stdc, x, y
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string K_String ( string s , int k ) { int n = s . size ( ) ; int fre [ 26 ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) fre [ s [ i ] - ' a ' ] ++ ; string str = " " ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( fre [ i ] % k == 0 ) { int x = fre [ i ] / k ; while ( x -- ) { str += ( char ) ( i + ' a ' ) ; } } else { return " - 1" ; } } return str ; } int main ( ) { string s = " aabb " ; int k = 2 ; cout << K_String ( s , k ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, str, x
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int check ( string s ) { int i , j ; int fr [ 26 ] = { 0 } ; int n = s . size ( ) ; for ( i = 0 ; i < n ; i ++ ) { char x = s [ i ] ; fr [ x - ' a ' ] += 1 ; } int minimum = INT_MAX ; for ( i = 0 ; i < 26 ; i ++ ) { for ( j = i + 1 ; j < 26 ; j ++ ) { int z = fr [ i ] + fr [ j ] ; minimum = min ( minimum , n - z ) ; } } return minimum ; } int main ( ) { string s = " geeksforgeeks " ; cout << check ( s ) ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int CountCharacters ( string str , int l , int r ) { int cnt = 0 ; unordered_map < char , int > m ; int len = str . length ( ) ; for ( int i = 0 ; i < len ; i ++ ) { if ( ! ( l <= str [ i ] and str [ i ] <= r ) ) { cnt ++ ; if ( m [ str [ i ] ] != 1 ) { cout << str [ i ] << " ▁ " ; m [ str [ i ] ] ++ ; } } } return cnt ; } int main ( ) { string str = " geeksforgeeks " ; int l = 102 , r = 111 ; cout << " Characters ▁ with ▁ ASCII ▁ values " " ▁ not ▁ in ▁ the ▁ range ▁ [ l , ▁ r ] ▁ STRNEWLINE in ▁ the ▁ given ▁ string ▁ are : ▁ " ; cout << " and their count is " << CountCharacters ( str , l , r ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cnt, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string pushBoxes ( string S ) { int N = S . length ( ) ; vector < int > force ( N , 0 ) ; int f = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( S [ i ] == ' R ' ) { f = N ; } else if ( S [ i ] == ' L ' ) { f = 0 ; } else { f = max ( f - 1 , 0 ) ; } force [ i ] += f ; } f = 0 ; for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( S [ i ] == ' L ' ) { f = N ; } else if ( S [ i ] == ' R ' ) { f = 0 ; } else { f = max ( f - 1 , 0 ) ; } force [ i ] -= f ; } string ans ; for ( int f : force ) { ans += f == 0 ? ' . ' : f > 0 ? ' R ' : ' L ' ; } return ans ; } int main ( ) { string S = " . L . R . . . LR . . L . . " ; cout << pushBoxes ( S ) ; }

Index/key variables: i
Accumulator variables: ans, i, stdc
Iterator variables: f, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void CountWords ( string str , int k ) { int sum = 0 ; int NumberOfWords = 0 ; int counter = 0 ; int len = str . length ( ) ; for ( int i = 0 ; i < len ; ++ i ) { if ( str [ i ] == ' ▁ ' ) { if ( sum < k ) counter ++ ; sum = 0 ; NumberOfWords ++ ; } else sum += str [ i ] ; } NumberOfWords ++ ; if ( sum < k ) counter ++ ; cout << " Number ▁ of ▁ words ▁ having ▁ sum ▁ of ▁ ASCII " " ▁ values ▁ less ▁ than ▁ k ▁ = ▁ " << counter << endl ; cout << " Number ▁ of ▁ words ▁ having ▁ sum ▁ of ▁ ASCII ▁ values " " ▁ greater ▁ than ▁ or ▁ equal ▁ to ▁ k ▁ = ▁ " << NumberOfWords - counter ; } int main ( ) { string str = " Learn ▁ how ▁ to ▁ code " ; int k = 400 ; CountWords ( str , k ) ; return 0 ; }

Index/key variables: i
Accumulator variables: NumberOfWords, counter, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minOperations ( string s , string f ) { if ( s == f ) return 0 ; unordered_map < string , int > vis ; int n ; n = s . length ( ) ; int pos = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s [ i ] == ' _ ' ) { pos = i ; break ; } } queue < pair < string , int > > q ; q . push ( { s , pos } ) ; vis [ s ] = 0 ; while ( ! q . empty ( ) ) { string ss = q . front ( ) . first ; int pp = q . front ( ) . second ; int dist = vis [ ss ] ; q . pop ( ) ; if ( pp > 0 ) { swap ( ss [ pp ] , ss [ pp - 1 ] ) ; if ( ! vis . count ( ss ) ) { if ( ss == f ) { return dist + 1 ; break ; } vis [ ss ] = dist + 1 ; q . push ( { ss , pp - 1 } ) ; } swap ( ss [ pp ] , ss [ pp - 1 ] ) ; } if ( pp < n - 1 ) { swap ( ss [ pp ] , ss [ pp + 1 ] ) ; if ( ! vis . count ( ss ) ) { if ( ss == f ) { return dist + 1 ; break ; } vis [ ss ] = dist + 1 ; q . push ( { ss , pp + 1 } ) ; } swap ( ss [ pp ] , ss [ pp + 1 ] ) ; } if ( pp > 1 && ss [ pp - 1 ] != ss [ pp - 2 ] ) { swap ( ss [ pp ] , ss [ pp - 2 ] ) ; if ( ! vis . count ( ss ) ) { if ( ss == f ) { return dist + 1 ; break ; } vis [ ss ] = dist + 1 ; q . push ( { ss , pp - 2 } ) ; } swap ( ss [ pp ] , ss [ pp - 2 ] ) ; } if ( pp < n - 2 && ss [ pp + 1 ] != ss [ pp + 2 ] ) { swap ( ss [ pp ] , ss [ pp + 2 ] ) ; if ( ! vis . count ( ss ) ) { if ( ss == f ) { return dist + 1 ; break ; } vis [ ss ] = dist + 1 ; q . push ( { ss , pp + 2 } ) ; } swap ( ss [ pp ] , ss [ pp + 2 ] ) ; } } } int main ( ) { string A = " aba _ a " ; string B = " _ baaa " ; cout << minOperations ( A , B ) ; return 0 ; }

Index/key variables: i, pp, s, ss
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string separateChar ( string str ) { int n = str . size ( ) , digitSum = 0 ; int alphabetSum = 0 , j = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( isdigit ( str [ i ] ) ) digitSum += str [ i ] - '0' ; else { alphabetSum += str [ i ] - ' a ' + 1 ; alphabetSum %= 26 ; } } string sumStr = to_string ( digitSum ) ; char alphabetStr = char ( alphabetSum + ' a ' - 1 ) ; sumStr += alphabetStr ; return sumStr ; } int main ( ) { string str = "3652adyz3423" ; cout << separateChar ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: alphabetSum, digitSum, i, stdc, sumStr
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX_CHAR = 26 ; int countPalindrome ( string str ) { int n = str . size ( ) ; int sum = 0 ; int hashTable [ MAX_CHAR ] ; for ( int i = 0 ; i < n ; i ++ ) hashTable [ str [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( hashTable [ i ] ) sum += ( hashTable [ i ] * ( hashTable [ i ] + 1 ) / 2 ) ; } return sum ; } int main ( ) { string str = " ananananddd " ; cout << countPalindrome ( str ) ; return 0 ; }

Index/key variables: MAX_CHAR, i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countConsecutive ( string s ) { int count = 0 ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) { if ( s [ i ] == s [ i + 1 ] ) i ++ ; else count ++ ; } return count ; } int main ( ) { string str = "44522255" ; cout << countConsecutive ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int check_digits ( int n ) { while ( n ) { return 0 ; n /= 10 ; } return 1 ; } int smallest_number ( int n ) { for ( int i = n ; ; i ++ ) if ( check_digits ( i ) ) return i ; } int main ( ) { int N = 2397 ; cout << smallest_number ( N ) ; return 0 ; }

Accumulator variables: i, n, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int smallestNumber ( int n ) { int num = 0 ; string s = " " ; int duplicate = n ; while ( n ) { s = char ( n % 10 + 48 ) + s ; n /= 10 ; } int index = -1 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int digit = s [ i ] - '0' ; if ( ( digit & 1 ) == 0 ) { index = i ; break ; } } if ( index == -1 ) return duplicate ; for ( int i = 0 ; i < index ; i ++ ) num = num * 10 + ( s [ i ] - '0' ) ; num = num * 10 + ( s [ index ] - '0' + 1 ) ; for ( int i = index + 1 ; i < s . length ( ) ; i ++ ) num = num * 10 + 1 ; return num ; } int main ( ) { int N = 2397 ; cout << smallestNumber ( N ) ; return 0 ; }

Index/key variables: i, index
Accumulator variables: i, n, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int CountCharacters ( string str , int l , int r ) { int cnt = 0 ; int len = str . length ( ) ; for ( int i = 0 ; i < len ; i ++ ) { if ( l <= str [ i ] and str [ i ] <= r ) { cnt ++ ; cout << str [ i ] << " ▁ " ; } } return cnt ; } int main ( ) { string str = " geeksforgeeks " ; int l = 102 , r = 111 ; cout << " Characters ▁ with ▁ ASCII ▁ values " " ▁ in ▁ the ▁ range ▁ [ l , ▁ r ] ▁ are ▁ STRNEWLINE " ; cout << " and their count is " << CountCharacters ( str , l , r ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cnt, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minSteps ( string str ) { int count = 0 ; for ( int i = 0 ; i < str . length ( ) - 2 ; i ++ ) { if ( str [ i ] == '0' ) { if ( str [ i + 1 ] == '1' ) { if ( str [ i + 2 ] == '0' ) { count ++ ; i += 2 ; } } } } return count ; } int main ( ) { string str = "0101010" ; cout << minSteps ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void SieveOfEratosthenes ( bool prime [ ] , int p_size ) { prime [ 0 ] = false ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= p_size ; p ++ ) { if ( prime [ p ] ) { for ( int i = p * 2 ; i <= p_size ; i += p ) prime [ i ] = false ; } } } int xorOfPrime ( string s ) { bool prime [ 100005 ] ; memset ( prime , true , sizeof ( prime ) ) ; SieveOfEratosthenes ( prime , 10005 ) ; int i , j ; map < char , int > m ; for ( i = 0 ; i < s . length ( ) ; i ++ ) m [ s [ i ] ] ++ ; int result = 0 ; int flag = 0 ; for ( auto it = m . begin ( ) ; it != m . end ( ) ; it ++ ) { if ( prime [ it -> second ] ) { result ^= it -> second ; flag = 1 ; } } if ( ! flag ) return -1 ; return result ; } int main ( ) { string s = " gggggeeekkkks " ; cout << xorOfPrime ( s ) ; return 0 ; }

Index/key variables: i, p
Accumulator variables: i, it, p, result, stdc
Iterator variables: i, it, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; int CountCharacters ( string str , int k ) { int cnt = 0 ; int len = str . length ( ) ; for ( int i = 0 ; i < len ; i ++ ) { if ( str [ i ] < k ) cnt ++ ; } return cnt ; } int main ( ) { string str = " GeeksForGeeks " ; int k = 90 ; int count = CountCharacters ( str , k ) ; cout << " Characters ▁ with ▁ ASCII ▁ values " " ▁ less ▁ than ▁ K ▁ are ▁ " << count ; cout << " Characters with ASCII values " STRNEWLINE TABSYMBOL TABSYMBOL TABSYMBOL " greater than or equal to K are " << str . length ( ) - count ; return 0 ; }

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