dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <iostream>
using namespace std ; int max ( int x , int y ) { return ( x > y ) ? x : y ; } int longestPalindromic ( string str , int i , int j , int count ) { if ( i > j ) return count ; if ( i == j ) return ( count + 1 ) ; if ( str [ i ] == str [ j ] ) { count = longestPalindromic ( str , i + 1 , j - 1 , count + 2 ) ; return max ( count , max ( longestPalindromic ( str , i + 1 , j , 0 ) , longestPalindromic ( str , i , j - 1 , 0 ) ) ) ; } return max ( longestPalindromic ( str , i + 1 , j , 0 ) , longestPalindromic ( str , i , j - 1 , 0 ) ) ; } int longest_palindromic_substr ( string str ) { return longestPalindromic ( str , 0 , str . length ( ) - 1 , 0 ) ; } int main ( ) { string str = " aaaabbaa " ; cout << longest_palindromic_substr ( str ) ; return 0 ; }

Index/key variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void MaxPrefix ( string s ) { map < char , int > Dict ; for ( char i : s ) { Dict [ i ] ++ ; } int minfrequency = INT_MAX ; for ( auto x : Dict ) { minfrequency = min ( minfrequency , x . second ) ; } int countminFrequency = 0 ; for ( auto x : Dict ) { if ( x . second == minfrequency ) countminFrequency += 1 ; } map < char , int > mapper ; int indi = 0 ; for ( char i : s ) { mapper [ i ] += 1 ; if ( mapper [ i ] > countminFrequency ) break ; indi += 1 ; } cout << ( s . substr ( 0 , indi ) ) ; } int main ( ) { string str = " aabcdaab " ; MaxPrefix ( str ) ; }

Index/key variables: i
Accumulator variables: countminFrequency, indi, stdc
Iterator variables: i, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSubstring ( string & S , char L [ ] , int & n ) { int freq [ 26 ] = { 0 } , ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { freq [ ( int ) ( L [ i ] - ' a ' ) ] = 1 ; } int count = 0 ; for ( auto x : S ) { if ( freq [ ( int ) ( x - ' a ' ) ] ) { ans += ( count * count + count ) / 2 ; count = 0 ; } else count ++ ; } ans += ( count * count + count ) / 2 ; return ans ; } int main ( ) { string S = " abcpxyz " ; char L [ ] = { ' a ' , ' p ' , ' q ' } ; int n = sizeof ( L ) / sizeof ( L [ 0 ] ) ; cout << countSubstring ( S , L , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, count, i, stdc
Iterator variables: i, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findNthOccur ( string str , char ch , int N ) { int occur = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str [ i ] == ch ) { occur += 1 ; } if ( occur == N ) return i ; } return -1 ; } int main ( ) { string str = " geeks " ; char ch = ' e ' ; int N = 2 ; cout << findNthOccur ( str , ch , N ) ; }

Index/key variables: i
Accumulator variables: i, occur, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int solve ( string X , string Y , int N , int K ) { int count [ N + 1 ] = { 0 } ; int sol = 0 ; count [ 0 ] = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { count [ i ] = count [ i - 1 ] + abs ( X [ i - 1 ] - Y [ i - 1 ] ) ; } int j = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { while ( ( count [ i ] - count [ j ] ) > K ) { j ++ ; } sol = max ( sol , i - j ) ; } return sol ; } int main ( ) { int N = 4 ; string X = " abcd " , Y = " bcde " ; int K = 3 ; cout << solve ( X , Y , N , K ) << " STRNEWLINE " ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; double jaro_distance ( string s1 , string s2 ) { if ( s1 == s2 ) return 1.0 ; int len1 = s1 . length ( ) , len2 = s2 . length ( ) ; if ( len1 == 0 len2 == 0 ) return 0.0 ; int max_dist = floor ( max ( len1 , len2 ) / 2 ) - 1 ; int match = 0 ; int hash_s1 [ s1 . length ( ) ] = { 0 } , hash_s2 [ s2 . length ( ) ] = { 0 } ; for ( int i = 0 ; i < len1 ; i ++ ) { for ( int j = max ( 0 , i - max_dist ) ; j < min ( len2 , i + max_dist + 1 ) ; j ++ ) if ( s1 [ i ] == s2 [ j ] && hash_s2 [ j ] == 0 ) { hash_s1 [ i ] = 1 ; hash_s2 [ j ] = 1 ; match ++ ; break ; } } if ( match == 0 ) return 0.0 ; double t = 0 ; int point = 0 ; for ( int i = 0 ; i < len1 ; i ++ ) if ( hash_s1 [ i ] ) { while ( hash_s2 [ point ] == 0 ) point ++ ; if ( s1 [ i ] != s2 [ point ++ ] ) t ++ ; } t /= 2 ; return ( ( ( double ) match ) / ( ( double ) len1 ) + ( ( double ) match ) / ( ( double ) len2 ) + ( ( double ) match - t ) / ( ( double ) match ) ) / 3.0 ; } double jaro_Winkler ( string s1 , string s2 ) { double jaro_dist = jaro_distance ( s1 , s2 ) ; if ( jaro_dist > 0.7 ) { int prefix = 0 ; for ( int i = 0 ; i < min ( s1 . length ( ) , s2 . length ( ) ) ; i ++ ) { if ( s1 [ i ] == s2 [ i ] ) prefix ++ ; else break ; } prefix = min ( 4 , prefix ) ; jaro_dist += 0.1 * prefix * ( 1 - jaro_dist ) ; } return jaro_dist ; } int main ( ) { string s1 = " TRATE " , s2 = " TRACE " ; cout << " Jaro - Winkler ▁ Similarity ▁ = " << jaro_Winkler ( s1 , s2 ) << endl ; return 0 ; }

Index/key variables: i, j, point
Accumulator variables: i, j, jaro_dist, match, point, prefix, stdc, t
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isWordPresent ( string sentence , string word ) { stringstream s ( sentence ) ; string temp ; while ( s >> temp ) { if ( temp . compare ( word ) == 0 ) { return true ; } } return false ; } int main ( ) { string s = " Geeks ▁ for ▁ Geeks " ; string word = " Geeks " ; if ( isWordPresent ( s , word ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isWordPresent ( string sentence , string word ) { transform ( word . begin ( ) , word . end ( ) , word . begin ( ) , :: toupper ) ; transform ( sentence . begin ( ) , sentence . end ( ) , sentence . begin ( ) , :: toupper ) ; stringstream s ( sentence ) ; string temp ; while ( s >> temp ) { if ( temp . compare ( word ) == 0 ) { return true ; } } return false ; } int main ( ) { string s = " Geeks ▁ for ▁ Geeks " ; string word = " geeks " ; if ( isWordPresent ( s , word ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countChars ( string str , int n ) { int i = 0 , cnt = 0 ; while ( i < n ) { if ( str [ i ] == '0' ) i ++ ; else i += 2 ; cnt ++ ; } return cnt ; } int main ( ) { string str = "11010" ; int n = str . length ( ) ; cout << countChars ( str , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cnt, i, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX = 26 ; void compressString ( string s , int n ) { int freq [ MAX ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) { freq [ s [ i ] - ' a ' ] ++ ; } for ( int i = 0 ; i < MAX ; i ++ ) { if ( freq [ i ] == 0 ) continue ; cout << ( char ) ( i + ' a ' ) << freq [ i ] ; } } int main ( ) { string s = " geeksforgeeks " ; int n = s . length ( ) ; compressString ( s , n ) ; return 0 ; }

Index/key variables: MAX, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void decBinary ( int arr [ ] , int n ) { int k = log2 ( n ) ; while ( n > 0 ) { arr [ k -- ] = n % 2 ; n /= 2 ; } } int binaryDec ( int arr [ ] , int n ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) ans += arr [ i ] << ( n - i - 1 ) ; return ans ; } int concat ( int m , int n ) { int k = log2 ( m ) + 1 ; int l = log2 ( n ) + 1 ; int a [ k ] = { 0 } , b [ l ] = { 0 } ; int c [ k + l ] = { 0 } ; decBinary ( a , m ) ; decBinary ( b , n ) ; int in = 0 ; for ( int i = 0 ; i < k ; i ++ ) c [ in ++ ] = a [ i ] ; for ( int i = 0 ; i < l ; i ++ ) c [ in ++ ] = b [ i ] ; return ( binaryDec ( c , k + l ) ) ; } int main ( ) { int m = 4 , n = 5 ; cout << concat ( m , n ) ; return 0 ; }

Index/key variables: i, k, l
Accumulator variables: ans, i, in, k, n, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getBinaryLength ( int n ) { int length = 0 ; while ( n > 0 ) { length += 1 ; n /= 2 ; } return length ; } int concat ( int m , int n ) { int length = getBinaryLength ( n ) ; return ( m << length ) + n ; } int main ( ) { int m = 4 , n = 5 ; cout << concat ( m , n ) ; return 0 ; }

Accumulator variables: length, n, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void addZeros ( string & str , int n ) { for ( int i = 0 ; i < n ; i ++ ) { str = "0" + str ; } } string getXOR ( string a , string b ) { int aLen = a . length ( ) ; int bLen = b . length ( ) ; if ( aLen > bLen ) { addZeros ( b , aLen - bLen ) ; } else if ( bLen > aLen ) { addZeros ( a , bLen - aLen ) ; } int len = max ( aLen , bLen ) ; string res = " " ; for ( int i = 0 ; i < len ; i ++ ) { if ( a [ i ] == b [ i ] ) res += "0" ; else res += "1" ; } return res ; } int main ( ) { string a = "11001" , b = "111111" ; cout << getXOR ( a , b ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; class Node { public : int * soln ; int level ; vector < Node * > child ; Node * parent ; Node ( Node * parent , int level , int N ) { this -> parent = parent ; this -> level = level ; this -> soln = new int [ N ] ; } } ; queue < Node * > Q ; void generate ( Node * n , int & N , queue < Node * > & Q ) { if ( n -> level == N ) { for ( int i = 0 ; i < N ; i ++ ) cout << n -> soln [ i ] ; cout << endl ; } else { int l = n -> level ; for ( int i = 0 ; i <= 1 ; i ++ ) { Node * x = new Node ( n , l + 1 , N ) ; for ( int k = 0 ; k < l ; k ++ ) x -> soln [ k ] = n -> soln [ k ] ; x -> soln [ l ] = i ; n -> child . push_back ( x ) ; Q . push ( x ) ; } } } int main ( ) { int N = 3 ; Node * root ; root = new Node ( NULL , 0 , N ) ; Q . push ( root ) ; while ( ! Q . empty ( ) ) { Node * E = Q . front ( ) ; Q . pop ( ) ; generate ( E , N , Q ) ; } return 0 ; }

Index/key variables: N, i, k, l
Accumulator variables: i, k, stdc
Iterator variables: i, k
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX = 26 ; int minOperation ( string str , int len ) { int first [ MAX ] , last [ MAX ] ; for ( int i = 0 ; i < MAX ; i ++ ) { first [ i ] = -1 ; last [ i ] = -1 ; } for ( int i = 0 ; i < len ; i ++ ) { int index = ( str [ i ] - ' a ' ) ; if ( first [ index ] == -1 ) first [ index ] = i ; last [ index ] = i ; } int minOp = -1 ; for ( int i = 0 ; i < MAX ; i ++ ) { if ( first [ i ] == -1 first [ i ] == last [ i ] ) continue ; int cnt = len - ( last [ i ] - first [ i ] + 1 ) ; if ( minOp == -1 cnt < minOp ) minOp = cnt ; } return minOp ; } int main ( ) { string str = " abcda " ; int len = str . length ( ) ; cout << minOperation ( str , len ) ; return 0 ; }

Index/key variables: MAX, i, index
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  2
bool isVowel ( char ch ) { return ( ch == ' a ' ch == ' e ' ch == ' i ' ch == ' o ' ch == ' u ' ) ; } int countVowels ( string str , int l , int r ) { int cnt = 0 ; for ( int i = l ; i <= r ; i ++ ) { if ( isVowel ( str [ i ] ) ) cnt ++ ; } return cnt ; } void performQueries ( string str , int queries [ ] [ N ] , int q ) { for ( int i = 0 ; i < q ; i ++ ) { cout << countVowels ( str , queries [ i ] [ 0 ] , queries [ i ] [ 1 ] ) << " STRNEWLINE " ; } } int main ( ) { string str = " geeksforgeeks " ; int queries [ ] [ N ] = { { 1 , 3 } , { 2 , 4 } , { 1 , 9 } } ; int q = ( sizeof ( queries ) / sizeof ( queries [ 0 ] ) ) ; performQueries ( str , queries , q ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: cnt, i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; struct node { char data ; node * next ; } ; node * add ( char data ) { node * newnode = new node ; newnode -> data = data ; newnode -> next = NULL ; return newnode ; } node * string_to_SLL ( string text , node * head ) { head = add ( text [ 0 ] ) ; node * curr = head ; for ( int i = 1 ; i < text . size ( ) ; i ++ ) { curr -> next = add ( text [ i ] ) ; curr = curr -> next ; } return head ; } void print ( node * head ) { node * curr = head ; while ( curr != NULL ) { cout << curr -> data << " ▁ - > ▁ " ; curr = curr -> next ; } } int main ( ) { string text = " GEEKS " ; node * head = NULL ; head = string_to_SLL ( text , head ) ; print ( head ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: node
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minLength ( string str , int len ) { stack < char > s ; for ( int i = 0 ; i < len ; i ++ ) { if ( s . empty ( ) ) { s . push ( str [ i ] ) ; } else { char c = s . top ( ) ; if ( c != str [ i ] && toupper ( c ) == toupper ( str [ i ] ) ) { s . pop ( ) ; } else { s . push ( str [ i ] ) ; } } } return s . size ( ) ; } int main ( ) { string str = " ASbBsd " ; int len = str . length ( ) ; cout << minLength ( str , len ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX  26
bool canBeMadeEqual ( string str1 , string str2 ) { int len1 = str1 . length ( ) ; int len2 = str2 . length ( ) ; if ( len1 == len2 ) { int freq [ MAX ] ; for ( int i = 0 ; i < len1 ; i ++ ) { freq [ str1 [ i ] - ' a ' ] ++ ; } for ( int i = 0 ; i < len2 ; i ++ ) { if ( freq [ str2 [ i ] - ' a ' ] > 0 ) return true ; } } return false ; } int main ( ) { string str1 = " abc " , str2 = " defa " ; if ( canBeMadeEqual ( str1 , str2 ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: MAX, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getCount ( string str , int n ) { int cnt = 0 ; int i = 0 ; while ( i < n - 2 ) { if ( str [ i ] == str [ i + 1 ] && str [ i ] == str [ i + 2 ] ) { cnt ++ ; i = i + 2 ; } else i ++ ; } return cnt ; } int main ( ) { string str = " aabbbcc " ; int n = str . length ( ) ; cout << getCount ( str , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cnt, i, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int fact ( int n ) { int fact = 1 ; for ( int i = 1 ; i <= n ; i ++ ) fact *= i ; return fact ; } int countStrings ( string str , int n ) { set < char > distinct_char ; for ( int i = 0 ; i < n ; i ++ ) { distinct_char . insert ( str [ i ] ) ; } return fact ( distinct_char . size ( ) ) ; } int main ( ) { string str = " geeksforgeeks " ; int n = str . length ( ) ; cout << countStrings ( str , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: fact, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; char getChar ( string str ) { int sum = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { sum += ( str [ i ] - ' a ' + 1 ) ; } if ( sum % 26 == 0 ) return ' z ' ; else { sum = sum % 26 ; return ( char ) ( ' a ' + sum - 1 ) ; } } int main ( ) { string str = " gfg " ; cout << getChar ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string reverse ( string str , int len , int l , int r ) { if ( l < 0 r > = len l > r ) return str ; while ( l < r ) { char c = str [ l ] ; str [ l ] = str [ r ] ; str [ r ] = c ; l ++ ; r -- ; } return str ; } int main ( ) { string str = " geeksforgeeks " ; int len = str . length ( ) ; int l = 5 , r = 7 ; cout << reverse ( str , len , l , r ) ; return 0 ; }

Index/key variables: l, r
Accumulator variables: l, r, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void encrypt ( char input [ 100 ] ) { char evenPos = ' @ ' , oddPos = ' ! ' ; int repeat , ascii ; for ( int i = 0 ; i <= strlen ( input ) ; i ++ ) { ascii = input [ i ] ; repeat = ascii >= 97 ? ascii - 96 : ascii - 64 ; for ( int j = 0 ; j < repeat ; j ++ ) { if ( i % 2 == 0 ) cout << oddPos ; else cout << evenPos ; } } } int main ( ) { char input [ 100 ] = { ' A ' , ' b ' , ' C ' , ' d ' } ; encrypt ( input ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <iostream>
using namespace std ; bool IsRedundantBraces ( string A ) { int a = 0 , b = 0 ; for ( int i = 0 ; i < A . size ( ) ; i ++ ) { if ( A [ i ] == ' ( ' && A [ i + 2 ] == ' ) ' ) return 1 ; if ( A [ i ] == ' * ' A [ i ] == ' + ' A [ i ] == ' - ' A [ i ] == ' / ' ) a ++ ; if ( A [ i ] == ' ( ' ) b ++ ; } if ( b > a ) return 1 ; return 0 ; } int main ( ) { string A = " ( ( ( a + b ) ▁ + ▁ c ) ▁ + ▁ d ) " ; if ( IsRedundantBraces ( A ) ) { cout << " YES STRNEWLINE " ; } else { cout << " NO " ; } }

Index/key variables: i
Accumulator variables: a, b, i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string balancedBrackets ( string str ) { int dep = 0 ; int minDep = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str [ i ] == ' ( ' ) dep ++ ; else dep -- ; if ( minDep > dep ) minDep = dep ; } if ( minDep < 0 ) { for ( int i = 0 ; i < abs ( minDep ) ; i ++ ) str = ' ( ' + str ; } dep = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str [ i ] == ' ( ' ) dep ++ ; else dep -- ; } if ( dep != 0 ) { for ( int i = 0 ; i < dep ; i ++ ) str = str + ' ) ' ; } return str ; } int main ( ) { string str = " ) ) ) ( ) " ; cout << balancedBrackets ( str ) ; }

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

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int find_digit ( string s , int n ) { int first_digit = -1 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( s [ i ] < '0' s [ i ] > '9' ) { first_digit = i ; break ; } } first_digit ++ ; int s_len = first_digit ; int num = 0 , pw = 1 ; int i = n - 1 ; while ( i >= 0 ) { if ( s [ i ] >= '0' && s [ i ] <= '9' ) { int digit = s [ i ] - '0' ; num = num + ( pw * digit ) ; if ( num >= s_len ) return -1 ; pw = pw * 10 ; } i -- ; } num = num * 10 ; int req = s_len - num ; if ( req > 9 req < 0 ) return -1 ; return req ; } int main ( ) { string s = " abcd0" ; int n = s . length ( ) ; cout << find_digit ( s , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: first_digit, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool canConvert ( string str1 , string str2 ) { int i = 0 , j = 0 ; while ( i < str1 . size ( ) && j < str2 . size ( ) ) { if ( str1 [ i ] != str2 [ j ] ) { if ( str1 [ i ] == '0' && str2 [ j ] == '1' && i + 1 < str1 . size ( ) && str1 [ i + 1 ] == '0' ) { i += 2 ; j ++ ; } else { return false ; } } else { i ++ ; j ++ ; } } if ( i == str1 . size ( ) && j == str2 . size ( ) ) return true ; return false ; } int main ( ) { string str1 = "00100" , str2 = "111" ; if ( canConvert ( str1 , str2 ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void reverse ( string s ) { stack < string > stc ; string temp = " " ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s [ i ] == ' ▁ ' ) { stc . push ( temp ) ; temp = " " ; } else { temp = temp + s [ i ] ; } } stc . push ( temp ) ; while ( ! stc . empty ( ) ) { temp = stc . top ( ) ; cout << temp << " ▁ " ; stc . pop ( ) ; } cout << endl ; } int main ( ) { string s = " I ▁ Love ▁ To ▁ Code " ; reverse ( s ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printMatrix ( int n , int m ) { if ( n < 5 m < 5 ) { cout << -1 ; return ; } string s = " aeiou " ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { cout << s [ j % 5 ] << " ▁ " ; } cout << endl ; char c = s [ 0 ] ; for ( int i = 0 ; i < 4 ; i ++ ) { s [ i ] = s [ i + 1 ] ; } s [ 4 ] = c ; } } int main ( ) { int n = 5 , m = 5 ; printMatrix ( n , m ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isTwoAlter ( string s ) { for ( int i = 0 ; i < s . length ( ) - 2 ; i ++ ) { if ( s [ i ] != s [ i + 2 ] ) { return false ; } } if ( s [ 0 ] == s [ 1 ] ) return false ; return true ; } int main ( ) { string str = " ABAB " ; if ( isTwoAlter ( str ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
#include <bits/stdc++.h>
using namespace std ; const int minOperations ( int n , string a , string b , string c ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { char x = a [ i ] ; char y = b [ i ] ; char z = c [ i ] ; if ( x == y && y == z ) ; else if ( x == y y == z x == z ) { ans ++ ; } else { ans += 2 ; } } return ans ; } int main ( ) { string a = " place " ; string b = " abcde " ; string c = " plybe " ; int n = a . size ( ) ; cout << minOperations ( n , a , b , c ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool check ( string s ) { int n = s . size ( ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( s [ i ] > s [ i + 1 ] ) return true ; } return false ; } int main ( ) { string s = " geeksforgeeks " ; if ( check ( s ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSubStr ( string str , int n , char x ) { int res = 0 , count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == x ) { res += ( ( count + 1 ) * ( n - i ) ) ; count = 0 ; } else count ++ ; } return res ; } int main ( ) { string str = " abcabc " ; int n = str . length ( ) ; char x = ' c ' ; cout << countSubStr ( str , n , x ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSubStr ( string str , int n ) { int len = str . length ( ) ; return ( len - n + 1 ) ; } int main ( ) { string str = " geeksforgeeks " ; int n = 5 ; cout << countSubStr ( str , n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSubstrings ( string s , char c ) { int n = s . length ( ) ; int cnt = 0 ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] != c ) cnt ++ ; else { sum += ( cnt * ( cnt + 1 ) ) / 2 ; cnt = 0 ; } } sum += ( cnt * ( cnt + 1 ) ) / 2 ; return sum ; } int main ( ) { string s = " baa " ; char c = ' b ' ; cout << countSubstrings ( s , c ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cnt, i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getMinimizedSum ( string str , int len ) { int i , maxVal = INT_MIN , sum = 0 ; int occurrences [ 26 ] = { 0 } ; for ( i = 0 ; i < len ; i ++ ) { occurrences [ str [ i ] - ' a ' ] ++ ; sum += ( int ) str [ i ] ; } for ( i = 0 ; i < 26 ; i ++ ) maxVal = max ( maxVal , occurrences [ i ] * ( i + ' a ' ) ) ; return ( sum - maxVal ) ; } int main ( ) { string str = " geeksforgeeks " ; int len = str . length ( ) ; cout << getMinimizedSum ( str , len ) ; return 0 ; }

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