dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct node { char data ; int cnt ; node * left , * right ; } ; node * add ( char data ) { node * newnode = new node ; newnode -> data = data ; newnode -> cnt = 1 ; newnode -> left = newnode -> right = NULL ; return newnode ; } node * addinlvlorder ( node * root , char data ) { if ( root == NULL ) { return add ( data ) ; } queue < node * > Q ; Q . push ( root ) ; while ( ! Q . empty ( ) ) { node * temp = Q . front ( ) ; Q . pop ( ) ; if ( temp -> data == data ) { temp -> cnt ++ ; break ; } if ( temp -> left == NULL ) { temp -> left = add ( data ) ; break ; } else { if ( temp -> left -> data == data ) { temp -> left -> cnt ++ ; break ; } Q . push ( temp -> left ) ; } if ( temp -> right == NULL ) { temp -> right = add ( data ) ; break ; } else { if ( temp -> right -> data == data ) { temp -> right -> cnt ++ ; break ; } Q . push ( temp -> right ) ; } } return root ; } void printlvlorder ( node * root ) { queue < node * > Q ; Q . push ( root ) ; while ( ! Q . empty ( ) ) { node * temp = Q . front ( ) ; if ( temp -> cnt > 1 ) { cout << temp -> data << temp -> cnt ; } else { cout << temp -> data ; } Q . pop ( ) ; if ( temp -> left != NULL ) { Q . push ( temp -> left ) ; } if ( temp -> right != NULL ) { Q . push ( temp -> right ) ; } } } int main ( ) { string s = " geeksforgeeks " ; node * root = NULL ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) { root = addinlvlorder ( root , s [ i ] ) ; } printlvlorder ( root ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cnt, i, stdc
Iterator variables: i
Class/struct names: node
C++ program:
#include <bits/stdc++.h>
using namespace std ; void replaceRemove ( string & s , char X , char Y , char Z ) { int start = 0 , end = s . size ( ) - 1 ; while ( start <= end ) { if ( s [ start ] == Z ) { while ( end >= 0 && s [ end ] == Z ) { end -- ; } if ( end > start ) { swap ( s [ start ] , s [ end ] ) ; if ( s [ start ] == X ) s [ start ] = Y ; start ++ ; } } else { if ( s [ start ] == X ) s [ start ] = Y ; start ++ ; } } while ( s . size ( ) > 0 && s [ s . size ( ) - 1 ] == Z ) { s . pop_back ( ) ; } } int main ( ) { string str = " batman " ; char X = ' a ' , Y = ' d ' , Z = ' b ' ; replaceRemove ( str , X , Y , Z ) ; if ( str . size ( ) == 0 ) { cout << -1 ; } else { cout << str ; } return 0 ; }

Index/key variables: end, start
Accumulator variables: end, start, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; string canMake ( string & s ) { int o = 0 , z = 0 ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) { if ( s [ i ] - '0' == 1 ) o ++ ; else z ++ ; } if ( o % 2 == 1 && z % 2 == 1 ) return " NO " ; else return " YES " ; } int main ( ) { string s = "01011" ; cout << canMake ( s ) << ' ' ; return 0 ; }

Index/key variables: i
Accumulator variables: i, o, stdc, z
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void countNumberOfStringsUtil ( vector < int > & freq , int & count ) { for ( int i = 0 ; i < 26 ; i ++ ) { if ( freq [ i ] > 0 ) { freq [ i ] -- ; count ++ ; countNumberOfStringsUtil ( freq , count ) ; } } } int countNumberOfStrings ( string s ) { vector < int > freq ( 26 , 0 ) ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) { freq [ s [ i ] - ' A ' ] ++ ; } int count = 0 ; countNumberOfStringsUtil ( freq , count ) ; return count ; } int main ( ) { string s = " AAABBC " ; cout << countNumberOfStrings ( s ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMinSwaps ( string s , int k ) { int ans = 0 ; int c_one = 0 , c_zero = 0 ; for ( int i = s . size ( ) - 1 ; i >= 0 ; i -- ) { if ( s [ i ] == '1' ) c_one ++ ; if ( s [ i ] == '0' ) c_zero ++ , ans += c_one ; if ( c_zero == k ) break ; } if ( c_zero < k ) return -1 ; return ans ; } int main ( ) { string s = "100111" ; int k = 2 ; cout << findMinSwaps ( s , k ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, c_one, c_zero, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { char data ; Node * left , * right ; Node ( char _val ) { data = _val ; left = right = NULL ; } } ; Node * addinBT ( Node * root , char data ) { if ( root == NULL ) { root = new Node ( data ) ; } else { queue < Node * > Q ; Q . push ( root ) ; while ( ! Q . empty ( ) ) { Node * temp = Q . front ( ) ; Q . pop ( ) ; if ( temp -> left == NULL ) { temp -> left = new Node ( data ) ; break ; } else Q . push ( temp -> left ) ; if ( temp -> right == NULL ) { temp -> right = new Node ( data ) ; break ; } else Q . push ( temp -> right ) ; } } return root ; } void print ( Node * root ) { queue < Node * > Q ; Q . push ( root ) ; while ( Q . size ( ) ) { Node * temp = Q . front ( ) ; Q . pop ( ) ; cout << temp -> data ; if ( temp -> left ) Q . push ( temp -> left ) ; if ( temp -> right ) Q . push ( temp -> right ) ; } } bool checkvowel ( char ch ) { ch = tolower ( ch ) ; if ( ch == ' a ' ch == ' e ' ch == ' i ' ch == ' o ' ch == ' u ' ) { return true ; } else { return false ; } } Node * removevowels ( Node * root ) { queue < Node * > Q ; Q . push ( root ) ; Node * root1 = NULL ; while ( ! Q . empty ( ) ) { Node * temp = Q . front ( ) ; Q . pop ( ) ; if ( ! checkvowel ( temp -> data ) ) { root1 = addinBT ( root1 , temp -> data ) ; } if ( temp -> left ) { Q . push ( temp -> left ) ; } if ( temp -> right ) { Q . push ( temp -> right ) ; } } return root1 ; } int main ( ) { string s = " geeks " ; Node * root = NULL ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) { root = addinBT ( root , s [ i ] ) ; } root = removevowels ( root ) ; print ( root ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSubStr ( string str , int len ) { int ans = 0 ; for ( int i = 0 ; i < len ; i ++ ) { if ( str [ i ] == '0' ) ans += ( i + 1 ) ; } return ans ; } int main ( ) { string str = "10010" ; int len = str . length ( ) ; cout << countSubStr ( str , len ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findLength ( string s , int k ) { int ans = INT_MAX ; int l = 0 ; int r = 0 ; int cnt_zero = 0 , cnt_one = 0 ; while ( l < s . size ( ) and r <= s . size ( ) ) { if ( cnt_zero >= k and cnt_one >= 1 ) { ans = min ( ans , r - l ) ; l ++ ; if ( s [ l - 1 ] == '0' ) cnt_zero -- ; else cnt_one -- ; } else { if ( r == s . size ( ) ) break ; if ( s [ r ] == '0' ) cnt_zero ++ ; else cnt_one ++ ; r ++ ; } } if ( ans == INT_MAX ) return -1 ; return ans ; } int main ( ) { string s = "100" ; int k = 2 ; cout << findLength ( s , k ) ; return 0 ; }

Index/key variables: r
Accumulator variables: cnt_one, cnt_zero, l, r, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; string largestSubStr ( string s ) { while ( s . size ( ) and s [ s . size ( ) - 1 ] == '1' ) s . pop_back ( ) ; if ( s . size ( ) == 0 ) return " - 1" ; else return s ; } int main ( ) { string s = "11001" ; cout << largestSubStr ( s ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX = 26 ; bool areEqual ( int * a , int * b ) { for ( int i = 0 ; i < MAX ; i ++ ) if ( a [ i ] != b [ i ] ) return false ; return true ; } bool xExistsInY ( string x , string y ) { if ( x . size ( ) > y . size ( ) ) return false ; int cnt_x [ MAX ] = { 0 } ; int cnt [ MAX ] = { 0 } ; for ( int i = 0 ; i < x . size ( ) ; i ++ ) cnt_x [ x [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < x . size ( ) ; i ++ ) cnt [ y [ i ] - ' a ' ] ++ ; if ( areEqual ( cnt_x , cnt ) ) return true ; for ( int i = 1 ; i < y . size ( ) - x . size ( ) + 1 ; i ++ ) { cnt [ y [ i - 1 ] - ' a ' ] -- ; cnt [ y [ i + x . size ( ) - 1 ] - ' a ' ] ++ ; if ( areEqual ( cnt , cnt_x ) ) return true ; } return false ; } int main ( ) { string x = " skege " ; string y = " geeksforgeeks " ; if ( xExistsInY ( x , y ) ) 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 ; string reverseParentheses ( string str , int len ) { stack < int > st ; for ( int i = 0 ; i < len ; i ++ ) { if ( str [ i ] == ' ( ' ) { st . push ( i ) ; } else if ( str [ i ] == ' ) ' ) { reverse ( str . begin ( ) + st . top ( ) + 1 , str . begin ( ) + i ) ; st . pop ( ) ; } } string res = " " ; for ( int i = 0 ; i < len ; i ++ ) { if ( str [ i ] != ' ) ' && str [ i ] != ' ( ' ) res += ( str [ i ] ) ; } return res ; } int main ( ) { string str = " ( skeeg ( for ) skeeg ) " ; int len = str . length ( ) ; cout << reverseParentheses ( str , len ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX = 26 ; void updateFreq ( string str , int freq [ ] ) { int len = str . length ( ) ; for ( int i = 0 ; i < len ; i ++ ) { freq [ str [ i ] - ' a ' ] ++ ; } } int maxCount ( string str , string patt ) { int strFreq [ MAX ] = { 0 } ; updateFreq ( str , strFreq ) ; int pattFreq [ MAX ] = { 0 } ; updateFreq ( patt , pattFreq ) ; int ans = INT_MAX ; for ( int i = 0 ; i < MAX ; i ++ ) { if ( pattFreq [ i ] == 0 ) continue ; ans = min ( ans , strFreq [ i ] / pattFreq [ i ] ) ; } return ans ; } int main ( ) { string str = " geeksforgeeks " ; string patt = " geeks " ; cout << maxCount ( str , patt ) ; return 0 ; }

Index/key variables: MAX, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int TEN = 10 ; int minNum ( string str , int len ) { int res = INT_MAX ; for ( int i = 0 ; i < len ; i ++ ) { if ( str [ i ] == '4' str [ i ] == '8' ) { res = min ( res , str [ i ] - '0' ) ; } } for ( int i = 0 ; i < len - 1 ; i ++ ) { for ( int j = i + 1 ; j < len ; j ++ ) { int num = ( str [ i ] - '0' ) * TEN + ( str [ j ] - '0' ) ; if ( num % 4 == 0 ) { res = min ( res , num ) ; } } } return ( ( res == INT_MAX ) ? -1 : res ) ; } int main ( ) { string str = "17" ; int len = str . length ( ) ; cout << minNum ( str , len ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool canBeEqual ( string a , string b , int n ) { vector < char > A , B ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] != b [ i ] ) { A . push_back ( a [ i ] ) ; B . push_back ( b [ i ] ) ; } } if ( A . size ( ) == B . size ( ) and B . size ( ) == 0 ) return true ; if ( A . size ( ) == B . size ( ) and B . size ( ) == 2 ) { if ( A [ 0 ] == A [ 1 ] and B [ 0 ] == B [ 1 ] ) return true ; } return false ; } int main ( ) { string A = " SEEKSFORGEEKS " ; string B = " GEEKSFORGEEKG " ; if ( canBeEqual ( A , B , A . size ( ) ) ) printf ( " Yes " ) ; else printf ( " No " ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findMidAlphabet ( string s1 , string s2 , int n ) { for ( int i = 0 ; i < n ; i ++ ) { int mid = ( s1 [ i ] + s2 [ i ] ) / 2 ; cout << ( char ) mid ; } } int main ( ) { string s1 = " akzbqzgw " ; string s2 = " efhctcsz " ; int n = s1 . length ( ) ; findMidAlphabet ( s1 , s2 , n ) ; return 0 ; }

Index/key variables: i
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 ' ) ; } void performQueries ( string str , int len , int queries [ ] [ N ] , int q ) { int pre [ len ] ; if ( isVowel ( str [ 0 ] ) ) pre [ 0 ] = 1 ; else pre [ 0 ] = 0 ; for ( int i = 1 ; i < len ; i ++ ) { if ( isVowel ( str [ i ] ) ) pre [ i ] = 1 + pre [ i - 1 ] ; else pre [ i ] = pre [ i - 1 ] ; } for ( int i = 0 ; i < q ; i ++ ) { if ( queries [ i ] [ 0 ] == 0 ) { cout << pre [ queries [ i ] [ 1 ] ] << " STRNEWLINE " ; } else { cout << ( pre [ queries [ i ] [ 1 ] ] - pre [ queries [ i ] [ 0 ] - 1 ] ) << " STRNEWLINE " ; } } } int main ( ) { string str = " geeksforgeeks " ; int len = str . length ( ) ; int queries [ ] [ N ] = { { 1 , 3 } , { 2 , 4 } , { 1 , 9 } } ; int q = ( sizeof ( queries ) / sizeof ( queries [ 0 ] ) ) ; performQueries ( str , len , queries , q ) ; return 0 ; }

Index/key variables: N, i, len
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sumDigits ( int n ) { int sum = 0 ; while ( n > 0 ) { int digit = n % 10 ; sum += digit ; n /= 10 ; } return sum ; } bool isDivBySix ( string str , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += ( int ) ( str [ i ] - ' a ' + 1 ) ; } if ( sum % 3 != 0 ) return false ; int lastDigit = ( ( int ) ( str [ n - 1 ] - ' a ' + 1 ) ) % 10 ; if ( lastDigit % 2 != 0 ) return false ; return true ; } int main ( ) { string str = " ab " ; int n = str . length ( ) ; if ( isDivBySix ( str , n ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: i
Accumulator variables: i, n, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const string CHARS = "0123456789ABCDEF " ; const int DIGITS = 16 ; bool isDivisible ( string s , int m ) { unordered_map < char , int > mp ; for ( int i = 0 ; i < DIGITS ; i ++ ) { mp [ CHARS [ i ] ] = i ; } int r = 0 ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) { r = ( r * 16 + mp [ s [ i ] ] ) % m ; } if ( ! r ) return true ; return false ; } int main ( ) { string s = "10" ; int m = 3 ; if ( isDivisible ( s , m ) ) 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 cntSplits ( string s ) { if ( s [ s . size ( ) - 1 ] == '1' ) return -1 ; int ans = 0 ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) ans += ( s [ i ] == '0' ) ; return ans ; } int main ( ) { string s = "10010" ; cout << cntSplits ( s ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const string CHARS = " qwertyuiopasdfghjklzxcvbnm " ; const int MAX = 26 ; string getString ( string str , int n ) { unordered_map < char , char > uMap ; for ( int i = 0 ; i < MAX ; i ++ ) { uMap [ CHARS [ i ] ] = CHARS [ ( i + 1 ) % MAX ] ; } for ( int i = 0 ; i < n ; i ++ ) { str [ i ] = uMap [ str [ i ] ] ; } return str ; } int main ( ) { string str = " geeks " ; int n = str . length ( ) ; cout << getString ( str , n ) ; 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 pos ) { int c = s [ pos - 1 ] ; int counter = 0 ; for ( int i = 0 ; i < pos - 1 ; i ++ ) { if ( s [ i ] == c ) counter = counter + 1 ; } return counter ; } int main ( ) { string s = " abacsddaa " ; int pos ; int n = s . length ( ) ; int query [ ] = { 9 , 3 , 2 } ; int Q = sizeof ( query ) / sizeof ( query [ 0 ] ) ; for ( int i = 0 ; i < Q ; i ++ ) { pos = query [ i ] ; cout << Count ( s , pos ) << endl ; } return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void Count ( vector < int > temp ) { int query [ ] = { 9 , 3 , 2 } ; int Q = sizeof ( query ) / sizeof ( query [ 0 ] ) ; for ( int i = 0 ; i < Q ; i ++ ) { int pos = query [ i ] ; cout << ( temp [ pos - 1 ] ) << endl ; } } vector < int > processing ( string s , int len ) { vector < int > temp ( len ) ; map < char , int > d ; for ( int i = 0 ; i < len ; i ++ ) { if ( d . find ( s [ i ] ) == d . end ( ) ) { d [ s [ i ] ] = i ; } else { temp [ i ] = temp [ d [ s [ i ] ] ] + 1 ; d [ s [ i ] ] = i ; } } return temp ; } int main ( ) { string s = " abacsddaa " ; int n = s . length ( ) ; vector < int > temp = processing ( s , n ) ; Count ( temp ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int sticks [ ] = { 6 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 } ; int countSticks ( string str , int n ) { int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { cnt += ( sticks [ str [ i ] - '0' ] ) ; } return cnt ; } int main ( ) { string str = "56" ; int n = str . length ( ) ; cout << countSticks ( str , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cnt, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printChar ( string str , int len ) { unordered_map < char , int > occ ; for ( int i = 0 ; i < len ; i ++ ) occ [ str [ i ] ] ++ ; int size = occ . size ( ) ; unordered_map < char , int > :: iterator it ; while ( size -- ) { unsigned currentMax = 0 ; char arg_max ; for ( it = occ . begin ( ) ; it != occ . end ( ) ; ++ it ) { if ( it -> second > currentMax || ( it -> second == currentMax && it -> first > arg_max ) ) { arg_max = it -> first ; currentMax = it -> second ; } } cout << arg_max << " ▁ - ▁ " << currentMax << endl ; occ . erase ( arg_max ) ; } } int main ( ) { string str = " geeksforgeeks " ; int len = str . length ( ) ; printChar ( str , len ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, size, stdc
Iterator variables: i, it
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getMod ( string str , int n , int k ) { int pwrTwo [ n ] ; pwrTwo [ 0 ] = 1 % k ; for ( int i = 1 ; i < n ; i ++ ) { pwrTwo [ i ] = pwrTwo [ i - 1 ] * ( 2 % k ) ; pwrTwo [ i ] %= k ; } int res = 0 ; int i = 0 , j = n - 1 ; while ( i < n ) { if ( str [ j ] == '1' ) { res += ( pwrTwo [ i ] ) ; res %= k ; } i ++ ; j -- ; } return res ; } int main ( ) { string str = "1101" ; int n = str . length ( ) ; int k = 45 ; cout << getMod ( str , n , k ) << endl ; }

Index/key variables: i, j, n
Accumulator variables: i, j, res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const long MOD = 1000000007 ; long countStrings ( long N ) { long dp [ N + 1 ] [ 3 ] ; memset ( dp , 0 , sizeof ( dp ) ) ; dp [ 1 ] [ 0 ] = 1 ; dp [ 1 ] [ 1 ] = 1 ; dp [ 1 ] [ 2 ] = 0 ; for ( int i = 2 ; i <= N ; i ++ ) { dp [ i ] [ 0 ] = ( dp [ i - 1 ] [ 0 ] + dp [ i - 1 ] [ 1 ] + dp [ i - 1 ] [ 2 ] ) % MOD ; dp [ i ] [ 1 ] = dp [ i - 1 ] [ 0 ] % MOD ; dp [ i ] [ 2 ] = dp [ i - 1 ] [ 1 ] % MOD ; } long ans = ( dp [ N ] [ 0 ] + dp [ N ] [ 1 ] + dp [ N ] [ 2 ] ) % MOD ; return ans ; } int main ( ) { long N = 3 ; cout << countStrings ( N ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string maxNumber ( string str , int n ) { int freq [ 2 ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == ' z ' ) { freq [ 0 ] ++ ; } else if ( str [ i ] == ' n ' ) { freq [ 1 ] ++ ; } } string num = " " ; for ( int i = 0 ; i < freq [ 1 ] ; i ++ ) num += '1' ; for ( int i = 0 ; i < freq [ 0 ] ; i ++ ) num += '0' ; return num ; } int main ( ) { string str = " roenenzooe " ; int n = str . length ( ) ; cout << maxNumber ( str , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, num, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void result ( string s , int n ) { unordered_set < string > st ; for ( int i = 0 ; i < ( int ) s . size ( ) ; i ++ ) { string ans = " " ; for ( int j = i ; j < ( int ) s . size ( ) ; j ++ ) { ans += s [ j ] ; if ( ans . size ( ) == n ) { st . insert ( ans ) ; break ; } } } for ( auto it : st ) cout << it << " ▁ " ; } int main ( ) { string s = " abca " ; int n = 3 ; result ( s , n ) ; return 0 ; }

Index/key variables: j
Accumulator variables: ans, i, j, stdc
Iterator variables: i, it, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; string decToBinary ( int n ) { int binaryNum [ 32 ] ; int i = 0 ; while ( n > 0 ) { binaryNum [ i ] = n % 2 ; n = n / 2 ; i ++ ; } string binary = " " ; for ( int j = i - 1 ; j >= 0 ; j -- ) binary += to_string ( binaryNum [ j ] ) ; return binary ; } int countFreq ( string & pat , string & txt ) { int M = pat . length ( ) ; int N = txt . length ( ) ; int res = 0 ; for ( int i = 0 ; i <= N - M ; i ++ ) { int j ; for ( j = 0 ; j < M ; j ++ ) if ( txt [ i + j ] != pat [ j ] ) break ; if ( j == M ) { res ++ ; j = 0 ; } } return res ; } void findOccurrence ( int arr [ ] , int n , string pattern ) { for ( int i = 0 ; i < n ; i ++ ) { string binary = decToBinary ( arr [ i ] ) ; cout << countFreq ( pattern , binary ) << " ▁ " ; } } int main ( ) { int arr [ ] = { 5 , 106 , 7 , 8 } ; string pattern = "10" ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; findOccurrence ( arr , n , pattern ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: binary, i, j, res, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool canBeBalanced ( string s , int n ) { if ( n % 2 == 1 ) return false ; string k = " ( " ; k += s + " ) " ; vector < string > d ; int cnt = 0 ; for ( int i = 0 ; i < k . length ( ) ; i ++ ) { if ( k [ i ] == ' ( ' ) d . push_back ( " ( " ) ; else { if ( d . size ( ) != 0 ) d . pop_back ( ) ; else return false ; } } if ( d . empty ( ) ) return true ; return false ; } int main ( int argc , char const * argv [ ] ) { string s = " ) ( ( ) " ; int n = s . length ( ) ; ( canBeBalanced ( s , n ) ) ? cout << " Yes " << endl : cout << " No " << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, k, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void find_winner ( string str , int n ) { string str1 = " " , str2 = " " ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 2 == 0 ) { str1 += str [ i ] ; } else { str2 += str [ i ] ; } } sort ( str1 . begin ( ) , str1 . end ( ) ) ; sort ( str2 . begin ( ) , str2 . end ( ) ) ; if ( str1 < str2 ) cout << " A " ; else if ( str2 < str1 ) cout << " B " ; else cout << " Tie " ; } int main ( ) { string str = " geeksforgeeks " ; int n = str . length ( ) ; find_winner ( str , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, str1, str2
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int Find_Index ( string str1 , string str2 ) { int n = str1 . size ( ) ; int m = str2 . size ( ) ; int l = 0 ; int r = 0 ; if ( n != m + 1 ) { return -1 ; } for ( int i = 0 ; i < m ; i ++ ) { if ( str1 [ i ] == str2 [ i ] ) { l += 1 ; } else { break ; } } int i = n - 1 ; int j = m - 1 ; while ( i >= 0 && j >= 0 && str1 [ i ] == str2 [ j ] ) { r += 1 ; i -= 1 ; j -= 1 ; } if ( l + r < m ) { return -1 ; } else { i = max ( n - r , 1 ) ; j = min ( l + 1 , n ) ; return ( j - i + 1 ) ; } } int main ( ) { string str1 = " aaa " , str2 = " aa " ; cout << Find_Index ( str1 , str2 ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, l, r, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void expandString ( string strin ) { string temp = " " ; int j ; for ( int i = 0 ; i < strin . length ( ) ; i ++ ) { if ( strin [ i ] >= 0 ) { int num = strin [ i ] - '0' ; if ( strin [ i + 1 ] == ' ( ' ) { for ( j = i + 1 ; strin [ j ] != ' ) ' ; j ++ ) { if ( ( strin [ j ] >= ' a ' && strin [ j ] <= ' z ' ) || ( strin [ j ] >= ' A ' && strin [ j ] <= ' Z ' ) ) { temp += strin [ j ] ; } } for ( int k = 1 ; k <= num ; k ++ ) { cout << ( temp ) ; } num = 0 ; temp = " " ; if ( j < strin . length ( ) ) { i = j ; } } } } } int main ( ) { string strin = "3 ( ab ) 4 ( cd ) " ; expandString ( strin ) ; }

Index/key variables: i, j
Accumulator variables: i, j, k, stdc, temp
Iterator variables: i, j, k