dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPalindrome ( string s ) { int i = 0 ; int j = s . length ( ) - 1 ; while ( i < j ) { if ( s [ i ] != s [ j ] ) return false ; i ++ ; j -- ; } return true ; } int getIndex ( string S1 , string S2 , int n ) { string S = " " ; for ( int i = 0 ; i < n ; i ++ ) { S = S + S1 [ i ] ; string Temp = " " ; for ( int j = i + 1 ; j < n ; j ++ ) Temp += S2 [ j ] ; if ( isPalindrome ( S + Temp ) ) { return i ; } } return -1 ; } int main ( ) { string S1 = " abcdf " , S2 = " sfgba " ; int n = S1 . length ( ) ; cout << getIndex ( S1 , S2 , n ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: Temp, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPalindrome ( string s , int i , int j ) { while ( i < j ) { if ( s [ i ] != s [ j ] ) return false ; i ++ ; j -- ; } return true ; } int getIndex ( string s1 , string s2 , int len ) { int i = 0 , j = len - 1 ; while ( i < j ) { if ( s1 [ i ] != s2 [ j ] ) { break ; } i ++ ; j -- ; } if ( i == j ) { return i - 1 ; } else if ( isPalindrome ( s2 , i , j ) ) return i - 1 ; else if ( isPalindrome ( s1 , i , j ) ) return j ; return -1 ; } int main ( ) { string s1 = " abcdf " , s2 = " sfgba " ; int len = s1 . length ( ) ; cout << getIndex ( s1 , s2 , len ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int count_acronym ( int n , string arr [ ] ) { int freq [ 26 ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) freq [ arr [ i ] [ 0 ] - ' a ' ] ++ ; int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { string st = arr [ i ] ; int num [ 26 ] = { 0 } ; for ( int j = 0 ; j < st . length ( ) ; j ++ ) num [ st [ j ] - ' a ' ] ++ ; bool flag = true ; for ( int j = 1 ; j < 26 ; j ++ ) { if ( num [ j ] > freq [ j ] ) { flag = false ; break ; } } int x = st [ 0 ] - ' a ' ; if ( freq [ x ] - 1 < num [ x ] ) flag = false ; if ( flag ) cnt ++ ; } return cnt ; } int main ( ) { string arr [ ] = { " abc " , " bcad " , " cabd " , " cba " , " dzzz " } ; int n = 5 ; cout << count_acronym ( n , arr ) ; }

Index/key variables: i, j, x
Accumulator variables: cnt, i, j, stdc
Iterator variables: i, j
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool valid ( int cnt [ ] ) { for ( int i = 0 ; i < 26 ; i ++ ) { if ( cnt [ i ] >= 2 ) return false ; } return true ; } string getGoodString ( string s , int n ) { if ( n < 26 ) return " - 1" ; for ( int i = 25 ; i < n ; i ++ ) { int cnt [ 26 ] = { 0 } ; for ( int j = i ; j >= i - 25 ; j -- ) { cnt [ s [ j ] - ' a ' ] ++ ; } if ( valid ( cnt ) ) { int cur = 0 ; while ( cnt [ cur ] > 0 ) cur ++ ; for ( int j = i - 25 ; j <= i ; j ++ ) { if ( s [ j ] == ' ? ' ) { s [ j ] = cur + ' a ' ; cur ++ ; while ( cnt [ cur ] > 0 ) cur ++ ; } } return s ; } } return " - 1" ; } int main ( ) { string s = " abcdefghijkl ? nopqrstuvwxy ? " ; int n = s . length ( ) ; cout << getGoodString ( s , n ) ; return 0 ; }

Index/key variables: cur, i, j
Accumulator variables: cur, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isVowel ( char c ) { c = tolower ( c ) ; if ( c == ' a ' c == ' e ' c == ' i ' c == ' o ' c == ' u ' ) return true ; return false ; } string swapRepeated ( string str ) { for ( int i = 0 ; i < str . length ( ) - 1 ; i ++ ) { if ( ( isVowel ( str [ i ] ) && isVowel ( str [ i + 1 ] ) ) || ( ! isVowel ( str [ i ] ) && ! isVowel ( str [ i + 1 ] ) ) ) swap ( str [ i ] , str [ i + 1 ] ) ; } return str ; } int main ( ) { string str = " geeksforgeeks " ; cout << swapRepeated ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string largestPalinSub ( string s ) { string res ; char mx = s [ 0 ] ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) mx = max ( mx , s [ i ] ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) if ( s [ i ] == mx ) res += s [ i ] ; return res ; } int main ( ) { string s = " geeksforgeeks " ; cout << largestPalinSub ( s ) ; }

Index/key variables: i
Accumulator variables: i, res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printString ( string str , int n ) { int ones = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( str [ i ] == '1' ) ones ++ ; bool used = false ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == '2' && ! used ) { used = 1 ; for ( int j = 0 ; j < ones ; j ++ ) cout << "1" ; } if ( str [ i ] != '1' ) cout << str [ i ] ; } if ( ! used ) for ( int j = 0 ; j < ones ; j ++ ) cout << "1" ; } int main ( ) { string str = "100210" ; int n = str . length ( ) ; printString ( str , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, j, ones, stdc
Iterator variables: i, j
Boolean variables: used
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findPermutation ( string str , int k ) { bool has [ 26 ] = { false } ; int cnt = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( ! has [ str [ i ] - ' a ' ] ) { cnt ++ ; has [ str [ i ] - ' a ' ] = true ; } } long long int ans = 1 ; for ( int i = 2 ; i <= cnt ; i ++ ) ans *= i ; for ( int i = cnt - k ; i > 1 ; i -- ) ans /= i ; return ans ; } int main ( ) { string str = " geeksforgeeks " ; int k = 4 ; cout << findPermutation ( str , k ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, cnt, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int product ( int x ) { int prod = 1 ; while ( x ) { prod *= ( x % 10 ) ; x /= 10 ; } return prod ; } int findNumber ( int l , int r ) { string a = to_string ( l ) ; string b = to_string ( r ) ; int ans = r ; for ( int i = 0 ; i < b . size ( ) ; i ++ ) { if ( b [ i ] == '0' ) continue ; string curr = b ; curr [ i ] = ( ( curr [ i ] - '0' ) - 1 ) + '0' ; for ( int j = i + 1 ; j < curr . size ( ) ; j ++ ) curr [ j ] = '9' ; int num = 0 ; for ( auto c : curr ) num = num * 10 + ( c - '0' ) ; if ( num >= l && product ( ans ) < product ( num ) ) ans = num ; } return ans ; } int main ( ) { int l = 1 , r = 10 ; cout << findNumber ( l , r ) << endl ; l = 51 , r = 62 ; cout << findNumber ( l , r ) << endl ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, prod, stdc, x
Iterator variables: c, i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < char > vowels = { ' a ' , ' e ' , ' i ' , ' o ' , ' u ' } ; map < char , int > mapping = { { ' a ' , 0 } , { ' e ' , 1 } , { ' i ' , 2 } , { ' o ' , 3 } , { ' u ' , 4 } } ; bool isValidSequence ( string subList ) { for ( char c : vowels ) { if ( subList . find ( c ) == std :: string :: npos ) return 0 ; } return 1 ; } string longestSubsequence ( string str , string subList , int index ) { int len = str . length ( ) ; if ( index >= len ) { if ( isValidSequence ( subList ) ) return subList ; else return " " ; } else if ( subList . size ( ) == 0 ) { if ( str [ index ] != ' a ' ) return longestSubsequence ( str , " " , index + 1 ) ; else return longestSubsequence ( str , subList + str [ index ] , index + 1 ) ; } else if ( mapping [ subList [ subList . size ( ) - 1 ] ] == mapping [ str [ index ] ] ) return longestSubsequence ( str , subList + str [ index ] , index + 1 ) ; else if ( mapping [ subList [ subList . size ( ) - 1 ] ] + 1 == mapping [ str [ index ] ] ) { string sub1 = longestSubsequence ( str , subList + str [ index ] , index + 1 ) ; string sub2 = longestSubsequence ( str , subList , index + 1 ) ; if ( sub1 . length ( ) > sub2 . length ( ) ) return sub1 ; else return sub2 ; } else return longestSubsequence ( str , subList , index + 1 ) ; } int main ( ) { string str = " aeiaaioooauuaeiou " ; string subsequence = longestSubsequence ( str , " " , 0 ) ; if ( subsequence . length ( ) == 0 ) cout << " No ▁ subsequence ▁ possible STRNEWLINE " ; else cout << subsequence << " STRNEWLINE " ; }

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

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int constructBinString ( int a , int b , int x ) { int d , i ; d = x / 2 ; if ( x % 2 == 0 && x / 2 != a ) { d -- ; cout << 0 ; a -- ; } for ( i = 0 ; i < d ; i ++ ) cout << "10" ; a = a - d ; b = b - d ; for ( i = 0 ; i < b ; i ++ ) { cout << "1" ; } for ( i = 0 ; i < a ; i ++ ) { cout << "0" ; } } int main ( ) { int a = 4 , b = 3 , x = 2 ; constructBinString ( a , b , x ) ; return 0 ; }

Accumulator variables: a, d, i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int matchPattern ( string s ) { int count = 0 ; int n = s . length ( ) ; int i = 0 ; while ( i < n ) { while ( i < n && s [ i ] == ' a ' ) { count ++ ; i ++ ; } while ( i < n && s [ i ] == ' b ' ) { count -- ; i ++ ; } if ( count != 0 ) return false ; } return true ; } int main ( ) { string s = " bb " ; if ( matchPattern ( s ) == true ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maximum_one ( string s , int n ) { int cnt_one = 0 ; int max_cnt = 0 , temp = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == '1' ) { cnt_one ++ ; temp ++ ; } else { max_cnt = max ( temp , max_cnt ) ; temp = 0 ; } } max_cnt = max ( max_cnt , temp ) ; int left [ n ] , right [ n ] ; if ( s [ 0 ] == '1' ) left [ 0 ] = 1 ; else left [ 0 ] = 0 ; if ( s [ n - 1 ] == '1' ) right [ n - 1 ] = 1 ; else right [ n - 1 ] = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( s [ i ] == '1' ) left [ i ] = left [ i - 1 ] + 1 ; else left [ i ] = 0 ; } for ( int i = n - 2 ; i >= 0 ; i -- ) { if ( s [ i ] == '1' ) right [ i ] = right [ i + 1 ] + 1 ; else right [ i ] = 0 ; } for ( int i = 1 ; i < n - 1 ; i ++ ) { if ( s [ i ] == '0' ) { int sum = left [ i - 1 ] + right [ i + 1 ] ; if ( sum < cnt_one ) max_cnt = max ( max_cnt , sum + 1 ) ; else max_cnt = max ( max_cnt , sum ) ; } } return max_cnt ; } int main ( ) { string s = "111011101" ; cout << maximum_one ( s , s . length ( ) ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: cnt_one, i, stdc, temp
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string MaxFreq ( string str ) { int n = str . size ( ) ; unordered_map < string , int > m ; for ( int i = 0 ; i < n ; i ++ ) { string s = " " ; for ( int j = i ; j < n ; j ++ ) { s += str [ j ] ; m [ s ] ++ ; } } int maxi = 0 ; string s ; for ( auto i = m . begin ( ) ; i != m . end ( ) ; i ++ ) { if ( i -> second > maxi ) { maxi = i -> second ; s = i -> first ; } else if ( i -> second == maxi ) { string ss = i -> first ; if ( ss . size ( ) > s . size ( ) ) s = ss ; } } return s ; } int main ( ) { string str = " ababecdecd " ; cout << MaxFreq ( str ) ; return 0 ; }

Index/key variables: j, s
Accumulator variables: i, j, s, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxFreq ( string s , int a , int b ) { int fre [ 10 ] = { 0 } ; int n = s . size ( ) ; if ( a > b ) swap ( a , b ) ; for ( int i = 0 ; i < n ; i ++ ) fre [ s [ i ] - '0' ] ++ ; if ( fre [ a ] == 0 and fre [ b ] == 0 ) return -1 ; else if ( fre [ a ] >= fre [ b ] ) return a ; else return b ; } int main ( ) { int a = 4 , b = 7 ; string s = "47744" ; cout << maxFreq ( s , a , b ) ; return 0 ; }

Index/key variables: a, b, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void convert ( int n , string a , string b ) { int l [ n ] ; int i ; for ( i = 0 ; i < n ; i ++ ) l [ i ] = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( a [ i ] != b [ i ] ) l [ i ] = 1 ; } int cc = 0 ; int vl = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( l [ i ] == 0 ) { if ( vl != 0 ) cc += 1 ; vl = 0 ; } else vl += 1 ; } if ( vl != 0 ) cc += 1 ; cout << cc << endl ; } int main ( ) { string a = "101010" ; string b = "110011" ; int n = a . length ( ) ; convert ( n , a , b ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: cc, i, vl
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void StringMatch ( string s ) { int lo = 0 , hi = s . length ( ) , len = s . length ( ) ; vector < int > ans ; for ( int x = 0 ; x < len ; x ++ ) { if ( s [ x ] == ' I ' ) { ans . push_back ( lo ) ; lo += 1 ; } else { ans . push_back ( hi ) ; hi -= 1 ; } } ans . push_back ( lo ) ; cout << " [ " ; for ( int i = 0 ; i < ans . size ( ) ; i ++ ) { cout << ans [ i ] ; if ( i != ans . size ( ) - 1 ) cout << " , " ; } cout << " ] " ; } int main ( ) { string S = " IDID " ; StringMatch ( S ) ; return 0 ; }

Index/key variables: i, x
Accumulator variables: hi, i, lo, stdc, x
Iterator variables: i, x
C++ program:
#include <iostream>
using namespace std ; int countWays ( string s1 , string s2 , int n ) { int a , b , c , d ; a = b = c = d = 0 ; int result = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s2 [ i ] == '0' ) { if ( s1 [ i ] == '0' ) { c ++ ; } else { d ++ ; } } else { if ( s1 [ i ] == '0' ) { a ++ ; } else { b ++ ; } } } result = a * d + b * c + c * d ; return result ; } int main ( ) { int n = 5 ; string s1 = "01011" ; string s2 = "11001" ; cout << countWays ( s1 , s2 , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: a, b, c, d, i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int returnWinner ( string s , int l ) { int freq [ 26 ] ; memset ( freq , 0 , sizeof freq ) ; for ( int i = 0 ; i < l ; i ++ ) { freq [ s [ i ] - ' a ' ] ++ ; } int cnt = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( freq [ i ] & 1 ) cnt ++ ; } if ( cnt == 0 cnt & 1 ) return 1 ; else return 2 ; } int main ( ) { string s = " abaaab " ; int l = s . length ( ) ; int winner = returnWinner ( s , l ) ; cout << " Player - " << winner ; return 0 ; }

Index/key variables: i
Accumulator variables: cnt, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void maxProductSum ( string str , int m ) { int n = str . length ( ) ; int maxProd = INT_MIN , maxSum = INT_MIN ; for ( int i = 0 ; i <= n - m ; i ++ ) { int product = 1 , sum = 0 ; for ( int j = i ; j < m + i ; j ++ ) { product = product * ( str [ j ] - '0' ) ; sum = sum + ( str [ j ] - '0' ) ; } maxProd = max ( maxProd , product ) ; maxSum = max ( maxSum , sum ) ; } cout << " Maximum ▁ Product ▁ = ▁ " << maxProd ; cout << " Maximum Sum = " } int main ( ) { string str = "3605356297" ; int m = 3 ; maxProductSum ( str , m ) ; }

Index/key variables: j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isVowel ( char ch ) { if ( ch != ' a ' && ch != ' e ' && ch != ' i ' && ch != ' o ' && ch != ' u ' ) return false ; return true ; } string replacingConsonants ( string s ) { for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( isVowel ( s [ i ] ) ) continue ; else { if ( s [ i ] > ' a ' && s [ i ] < ' e ' ) { if ( abs ( s [ i ] - ' a ' ) > abs ( s [ i ] - ' e ' ) ) s [ i ] = ' e ' ; else s [ i ] = ' a ' ; } else if ( s [ i ] > ' e ' && s [ i ] < ' i ' ) { if ( abs ( s [ i ] - ' e ' ) > abs ( s [ i ] - ' i ' ) ) s [ i ] = ' i ' ; else s [ i ] = ' e ' ; } else if ( s [ i ] > ' i ' && s [ i ] < ' o ' ) { if ( abs ( s [ i ] - ' i ' ) > abs ( s [ i ] - ' o ' ) ) s [ i ] = ' o ' ; else s [ i ] = ' i ' ; } else if ( s [ i ] > ' o ' && s [ i ] < ' u ' ) { if ( abs ( s [ i ] - ' o ' ) > abs ( s [ i ] - ' u ' ) ) s [ i ] = ' u ' ; else s [ i ] = ' o ' ; } else if ( s [ i ] > ' u ' ) s [ i ] = ' u ' ; } } return s ; } int main ( ) { string s = " geeksforgeeks " ; cout << replacingConsonants ( s ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxLength ( string s , int n ) { int right = 0 , left = 0 ; int coun = 0 , max_length = INT_MIN ; s = s + '1' ; for ( int i = 0 ; i <= n ; i ++ ) { if ( s [ i ] == ' o ' ) coun ++ ; else { if ( coun > max_length ) { right = 0 ; left = 0 ; if ( s [ i ] == ' x ' ) right = 1 ; if ( ( ( i - coun ) > 0 ) && ( s [ i - coun - 1 ] == ' x ' ) ) left = 1 ; coun = ceil ( ( double ) coun / ( right + left ) ) ; max_length = max ( max_length , coun ) ; } coun = 0 ; } } return max_length ; } int main ( ) { string s = " oooxoooooooooxooo " ; int n = s . size ( ) ; cout << maxLength ( s , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: coun, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string printLargestString ( string s , int l , int r ) { int freq [ 26 ] = { 0 } ; l -- ; r -- ; for ( int i = min ( l , r ) ; i <= max ( l , r ) ; i ++ ) { freq [ s [ i ] - ' a ' ] ++ ; } string ans = " " ; for ( int i = 25 ; i >= 0 ; i -- ) { while ( freq [ i ] ) { ans += char ( ' a ' + i ) ; freq [ i ] -- ; } } return ans ; } int main ( ) { string s = " striver " ; int l = 3 , r = 5 ; cout << printLargestString ( s , l , r ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, l, r, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void arrange ( string s ) { int cc = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s [ i ] == '1' ) cc ++ ; } int a [ s . length ( ) + 1 ] = { 0 } ; int qq [ ] [ 2 ] = { { 2 , 3 } , { 5 , 5 } } ; int n = sizeof ( qq ) / sizeof ( qq [ 0 ] ) ; for ( int i = 0 ; i < n ; i ++ ) { int l = qq [ i ] [ 0 ] , r = qq [ i ] [ 1 ] ; l -- , r -- ; a [ l ] ++ ; a [ r + 1 ] -- ; } int len_a = sizeof ( a ) / sizeof ( a [ 0 ] ) ; for ( int i = 1 ; i < len_a ; i ++ ) { a [ i ] += a [ i - 1 ] ; } int zz [ s . length ( ) ] = { 0 } ; for ( int i = 0 ; i < len_a - 1 ; i ++ ) { if ( a [ i ] > 0 ) { if ( cc > 0 ) { zz [ i ] = 1 ; cc -- ; } else break ; } if ( cc == 0 ) break ; } if ( cc > 0 ) { for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( zz [ i ] == 0 ) { zz [ i ] = 1 ; cc -- ; } if ( cc == 0 ) break ; } } for ( int i = 0 ; i < s . length ( ) ; i ++ ) cout << zz [ i ] ; cout << endl ; } int main ( ) { string str = "11100" ; arrange ( str ) ; return 0 ; }

Index/key variables: i, l
Accumulator variables: cc, i, l, r, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool areVowelsInOrder ( string s ) { int n = s . length ( ) ; char c = ( char ) 64 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == ' a ' s [ i ] == ' e ' s [ i ] == ' i ' s [ i ] == ' o ' s [ i ] == ' u ' ) { if ( s [ i ] < c ) return false ; else { c = s [ i ] ; } } } return true ; } int main ( ) { string s = " aabbbddeecc " ; if ( areVowelsInOrder ( 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 ; string newString ( string s ) { int l = s . length ( ) ; int freq [ 26 ] = { 0 } ; for ( int i = 0 ; i < l ; i ++ ) { freq [ s [ i ] - ' a ' ] += 1 ; } string ans = " " ; for ( int i = 0 ; i < 26 ; i ++ ) { for ( int j = 0 ; j < freq [ i ] ; j ++ ) { ans += ( char ) ( 97 + i ) ; } } return ans ; } int main ( ) { string s = " aabab " ; cout << newString ( s ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int Remainder ( string str , int R ) { int len = str . length ( ) ; int Num , Rem = 0 ; for ( int i = 0 ; i < len ; i ++ ) { Num = Rem * 10 + ( str [ i ] - '0' ) ; Rem = Num % R ; } return Rem ; } int main ( ) { string str = "13589234356546756" ; int R = 13 ; cout << Remainder ( str , R ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void countWays ( int a [ ] , int n ) { int i , j ; long suff [ n ] ; if ( a [ n - 1 ] == 2 ) suff [ n - 1 ] = 1 ; for ( i = n - 2 ; i >= 0 ; i -- ) { if ( a [ i ] == 2 ) suff [ i ] = suff [ i + 1 ] + 1 ; else suff [ i ] = suff [ i + 1 ] ; } long ss = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( a [ i ] == 1 ) ss += suff [ i ] ; } for ( i = 0 ; i < n ; i ++ ) { for ( j = i + 1 ; j < n ; j ++ ) { if ( a [ i ] == 1 && a [ j ] == 1 && suff [ j ] >= 2 ) { ss += ( suff [ j ] ) * ( suff [ j ] - 1 ) / 2 ; } } } for ( i = 0 ; i < n ; i ++ ) { for ( j = i + 1 ; j < n ; j ++ ) { if ( a [ i ] == 1 && a [ j ] == 1 && ( suff [ i ] - suff [ j ] ) >= 1 && suff [ j ] >= 1 ) { ss += ( suff [ i ] - suff [ j ] ) * suff [ j ] ; } } } cout << ( ss ) ; } int main ( ) { int a [ ] = { 1 , 2 , 1 , 1 , 2 , 2 } ; int n = 6 ; countWays ( a , n ) ; return 0 ; }

Index/key variables: i, j, n
Accumulator variables: i, j, ss, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int count_carry ( string a , string b ) { int carry = 0 ; int count = 0 ; int len_a = a . length ( ) , len_b = b . length ( ) ; while ( len_a != 0 len_b != 0 ) { int x = 0 , y = 0 ; if ( len_a > 0 ) { x = a [ len_a - 1 ] - '0' ; len_a -- ; } if ( len_b > 0 ) { y = b [ len_b - 1 ] - '0' ; len_b -- ; } int sum = x + y + carry ; if ( sum >= 10 ) { carry = 1 ; count ++ ; } else carry = 0 ; } return count ; } int main ( ) { string a = "9555" , b = "555" ; int count = count_carry ( a , b ) ; if ( count == 0 ) cout << "0 STRNEWLINE " ; else if ( count == 1 ) cout << "1 STRNEWLINE " ; else cout << count << " STRNEWLINE " ; return 0 ; }

Accumulator variables: count, len_a, len_b, stdc
C++ program:
#include <iostream>
using namespace std ; void printIndex ( string str , string s ) { bool flag = false ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str . substr ( i , s . length ( ) ) == s ) { cout << i << " ▁ " ; flag = true ; } } if ( flag == false ) cout << " NONE " ; } int main ( ) { string str1 = " GeeksforGeeks " ; string str2 = " Geeks " ; printIndex ( str1 , str2 ) ; return 0 ; }

Accumulator variables: i
Iterator variables: i
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; string merge ( string s1 , string s2 ) { string result = " " ; for ( int i = 0 ; i < s1 . length ( ) || i < s2 . length ( ) ; i ++ ) { if ( i < s1 . length ( ) ) result += s1 [ i ] ; if ( i < s2 . length ( ) ) result += s2 [ i ] ; } return result ; } int main ( ) { string s1 = " geeks " ; string s2 = " forgeeks " ; cout << merge ( s1 , s2 ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, result, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; char getMaxOccurringChar ( char str [ ] ) { int freq [ 26 ] = { 0 } ; int max = -1 ; char result ; int len = strlen ( str ) ; for ( int i = 0 ; i < len ; i ++ ) freq [ str [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < 26 ; i ++ ) if ( max < freq [ i ] ) { max = freq [ i ] ; result = ( char ) ( i + ' a ' ) ; } return result ; } int main ( ) { char str [ ] = " sample ▁ program " ; cout << " Maximum ▁ occurring ▁ character ▁ = ▁ " << getMaxOccurringChar ( str ) ; return 0 ; }

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