dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < string > TotalPossibleJumps ( int N ) { if ( ( N - 1 ) == 0 ) { vector < string > newvec ; newvec . push_back ( " " ) ; return newvec ; } else { if ( N < 0 ) { vector < string > newvec ; return newvec ; } } vector < string > jump1 = TotalPossibleJumps ( N - 1 ) ; vector < string > jump2 = TotalPossibleJumps ( N - 2 ) ; vector < string > totaljumps ; for ( string s : jump1 ) { totaljumps . push_back ( "1" + s ) ; } for ( string s : jump2 ) { totaljumps . push_back ( "2" + s ) ; } return totaljumps ; } int main ( ) { int N = 3 ; vector < string > Ans = TotalPossibleJumps ( N ) ; for ( auto & it : Ans ) cout << it << ' ' ; return 0 ; }

Accumulator variables: stdc
Iterator variables: s
C++ program:
#include <bits/stdc++.h>
using namespace std ; string findString ( vector < string > & arr , int N ) { string ans = " " ; for ( int i = 0 ; i < N ; i ++ ) { ans += arr [ i ] [ i ] == '0' ? '1' : '0' ; } return ans ; } int main ( ) { vector < string > arr { "111" , "011" , "001" } ; int N = arr . size ( ) ; cout << findString ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void commonSubstring ( string s ) { int n = s . size ( ) ; int i = 0 ; int j = n - 1 ; string ans = " " ; while ( j >= 0 ) { if ( s [ i ] == s [ j ] ) { ans += s [ i ] ; i ++ ; j -- ; } else { break ; } } if ( ans . size ( ) == 0 ) cout << " False " ; else { cout << " True ▁ STRNEWLINE " << ans ; } } int main ( ) { string S = " abca " ; commonSubstring ( S ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: ans, i, j, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findMinimumSubsequence ( string S ) { bool flag = false ; string dummy ; for ( int j = 0 ; j < S . length ( ) ; j ++ ) { if ( S [ j ] != '2' && S [ j ] != '3' && S [ j ] != '5' && S [ j ] != '7' ) { cout << 1 ; flag = true ; break ; } } if ( ! flag ) { for ( int j = 0 ; j < S . length ( ) - 1 ; j ++ ) { for ( int j1 = j + 1 ; j1 < S . length ( ) ; j1 ++ ) { dummy = S [ j ] + S [ j1 ] ; if ( dummy != "23" && dummy != "37" && dummy != "53" && dummy != "73" ) { cout << 2 ; } if ( flag = true ) break ; } if ( flag = true ) break ; } } if ( ! flag ) { if ( S . length ( ) >= 3 ) { cout << 3 ; } else { cout << -1 ; } } } int main ( ) { string S = "237" ; findMinimumSubsequence ( S ) ; return 0 ; }

Index/key variables: j, j1
Accumulator variables: j, j1, stdc
Iterator variables: j, j1
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; int operations ( string s ) { int ans = 0 ; int vowels = 0 , consonants = 0 ; int max_vowels = INT_MIN ; int max_consonants = INT_MIN ; unordered_map < char , int > freq_consonants ; unordered_map < char , int > freq_vowels ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) { if ( s [ i ] == ' a ' or s [ i ] == ' e ' or s [ i ] == ' i ' or s [ i ] == ' o ' or s [ i ] == ' u ' ) { vowels += 1 ; freq_vowels [ s [ i ] ] += 1 ; } else { consonants += 1 ; freq_consonants [ s [ i ] ] += 1 ; } } for ( auto it = freq_consonants . begin ( ) ; it != freq_consonants . end ( ) ; it ++ ) { max_consonants = max ( max_consonants , it -> second ) ; } for ( auto it = freq_vowels . begin ( ) ; it != freq_vowels . end ( ) ; it ++ ) { max_vowels = max ( max_vowels , it -> second ) ; } ans = min ( ( 2 * ( vowels - max_vowels ) + consonants ) , ( 2 * ( consonants - max_vowels ) + consonants ) ) ; return ans ; } int main ( ) { string S = " geeksforgeeks " ; cout << operations ( S ) ; return 0 ; }

Index/key variables: i
Accumulator variables: consonants, i, it, stdc, vowels
Iterator variables: i, it
C++ program:
#include <bits/stdc++.h>
using namespace std ; int dp [ 505 ] [ 505 ] , choose [ 502 ] [ 502 ] ; int calc ( int l , int r , string & s ) { if ( abs ( r - l ) % 2 == 0 ) { return 0 ; } if ( l > r ) { return dp [ l ] [ r ] = 1 ; } if ( dp [ l ] [ r ] != -1 ) { return dp [ l ] [ r ] ; } if ( ( r - l ) == 1 ) { if ( s [ l ] == s [ r ] ) { dp [ l ] [ r ] = 1 ; } else { dp [ l ] [ r ] = 0 ; } return dp [ l ] [ r ] ; } int ans = 0 ; for ( int k = l + 1 ; k <= r ; k += 2 ) { int temp = 1 ; if ( s [ l ] == s [ k ] ) { temp = calc ( l + 1 , k - 1 , s ) * calc ( k + 1 , r , s ) * choose [ ( r - l + 1 ) / 2 ] [ ( r - k ) / 2 ] ; ans += temp ; } } return dp [ l ] [ r ] = ans ; } int waysToClearString ( string S ) { memset ( dp , -1 , sizeof ( dp ) ) ; int n = S . length ( ) ; choose [ 0 ] [ 0 ] = 1 ; for ( int i = 1 ; i <= n / 2 ; ++ i ) { choose [ i ] [ 0 ] = 1 ; for ( int j = 1 ; j <= i ; ++ j ) { choose [ i ] [ j ] = ( choose [ i - 1 ] [ j ] + choose [ i - 1 ] [ j - 1 ] ) ; } } return calc ( 0 , n - 1 , S ) ; } int main ( ) { string S = " aabccb " ; cout << waysToClearString ( S ) ; return 0 ; }

Index/key variables: i, j, k, l, r
Accumulator variables: ans, k, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findSubsequence ( string str ) { int n = str . size ( ) ; char res [ n ] ; for ( int i = 0 ; i < n ; i ++ ) res [ i ] = 0 ; for ( int pos = 0 ; pos <= 9 ; pos ++ ) { char lst1 = '0' ; bool flag = 1 ; char lst2 = pos + '0' ; for ( int i = 0 ; i < n ; i ++ ) { if ( lst2 <= str [ i ] ) { res [ i ] = '2' ; lst2 = str [ i ] ; } else if ( lst1 <= str [ i ] ) { res [ i ] = '1' ; lst1 = str [ i ] ; } else flag = 0 ; } if ( lst1 > pos + '0' ) flag = 0 ; if ( flag ) { string S1 = " " ; string S2 = " " ; for ( int i = 0 ; i < n ; i ++ ) { if ( res [ i ] == '1' ) { S1 += str [ i ] ; } else { S2 += str [ i ] ; } } cout << S1 << ' ▁ ' << S2 << endl ; return ; } } cout << " - 1" ; } int main ( ) { string S = "040425524644" ; findSubsequence ( S ) ; S = "123456789" ; findSubsequence ( S ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: S1, S2, i, pos, stdc
Iterator variables: i, pos
C++ program:
#include <bits/stdc++.h>
using namespace std ; void getString ( int curlen , string & ans , string & s , int N , int & K , vector < int > & prod ) { if ( curlen == N ) { K -- ; if ( K == 0 ) ans = s ; return ; } char ch ; int ok , t , i ; for ( ch = '2' ; ch <= '9' ; ch ++ ) { s += ch ; ok = 1 ; t = 1 ; for ( i = curlen ; i >= 0 ; i -- ) { t *= s [ i ] - 48 ; if ( prod [ t ] ) ok = 0 ; prod [ t ] ++ ; } if ( ok ) getString ( curlen + 1 , ans , s , N , K , prod ) ; t = 1 ; for ( i = curlen ; i >= 0 ; i -- ) { t *= s [ i ] - 48 ; prod [ t ] -- ; } s . erase ( s . length ( ) - 1 ) ; } } string kthValidString ( int N , int K ) { if ( N > 10 ) { return " - 1" ; } if ( N == 1 ) { if ( K > 10 ) { return " - 1" ; } string s = " " ; K -- ; s += ( K + '0' ) ; return s ; } string ans = " - 1" ; string s = " " ; vector < int > prod ( 10005 , 0 ) ; getString ( 0 , ans , s , N , K , prod ) ; return ans ; } int main ( ) { int N = 3 , K = 4 ; cout << kthValidString ( N , K ) ; }

Index/key variables: i, t
Accumulator variables: K, ch, i, s, stdc, t
Iterator variables: ch, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int BalancedStringBySwapping ( string s ) { int unbalancedPair = 0 ; for ( int i = 0 ; i < s . length ( ) ; ++ i ) { if ( unbalancedPair > 0 && s [ i ] == ' ] ' ) { -- unbalancedPair ; } else if ( s [ i ] == ' [ ' ) { ++ unbalancedPair ; } } return ( unbalancedPair + 1 ) / 2 ; } int main ( ) { string s = " ] ] ] [ [ [ " ; cout << ( BalancedStringBySwapping ( s ) ) ; return 0 ; }

Index/key variables: i
Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int lengthNPalindrome ( int N , int K ) { int half = N / 2 ; if ( N & 1 ) { half += 1 ; } int ans = 1 ; for ( int i = 1 ; i <= half ; i ++ ) { ans *= K ; K -- ; } return ans ; } int palindromicStrings ( int N , int K ) { if ( N == 1 ) { return K ; } if ( N == 2 ) { return 2 * K ; } int ans = 0 ; ans += ( 2 * K ) ; for ( int i = 3 ; i <= N ; i ++ ) { ans += lengthNPalindrome ( i , K ) ; } return ans ; } int main ( ) { int N = 4 , K = 3 ; cout << palindromicStrings ( N , K ) ; return 0 ; }

Accumulator variables: K, ans, half, i, stdc
Iterator variables: i
C++ program:
#include " bits / stdc + + . h "
using namespace std ; int LCS ( string & S , int N , string & T , int M , vector < vector < int > > & dp ) { if ( N == 0 or M == 0 ) return 0 ; if ( dp [ N ] [ M ] != -1 ) return dp [ N ] [ M ] ; if ( S [ N - 1 ] == T [ M - 1 ] ) { return dp [ N ] [ M ] = 1 + LCS ( S , N - 1 , T , M - 1 , dp ) ; } return dp [ N ] [ M ] = max ( LCS ( S , N - 1 , T , M , dp ) , LCS ( S , N , T , M - 1 , dp ) ) ; } int minimumCharacter ( string & S ) { string T = " abcdefghijklmnopqrstuvwxyz " ; int N = S . length ( ) , M = T . length ( ) ; vector < vector < int > > dp ( N + 1 , vector < int > ( M + 1 , -1 ) ) ; return ( 26 - LCS ( S , N , T , M , dp ) ) ; } int main ( ) { string S = " abcdadc " ; cout << minimumCharacter ( S ) ; return 0 ; }

Index/key variables: M, N
C++ program:
#include <bits/stdc++.h>
using namespace std ; typedef long long LL ; const int MOD = 1000000007 ; int exp_mod ( LL a , LL b ) { LL ret = 1 ; for ( ; b ; b >>= 1 , a = a * a % MOD ) { if ( b & 1 ) ret = ret * a % MOD ; } return ret ; } int countOfWays ( string s , int k ) { int N = s . size ( ) ; LL ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( s [ i ] == '5' s [ i ] == '0' ) { ans = ( ans + exp_mod ( 2 , i ) ) % MOD ; } } LL q = exp_mod ( 2 , N ) ; LL qk = exp_mod ( q , k ) ; LL inv = exp_mod ( q - 1 , MOD - 2 ) ; ans = ans * ( qk - 1 ) % MOD ; ans = ans * inv % MOD ; return ans ; } int main ( ) { string S = "1256" ; int K = 1 ; cout << countOfWays ( S , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int printMiddleString ( string S , string T , int N ) { vector < int > a1 ( N + 1 ) ; for ( int i = 0 ; i < N ; i ++ ) { a1 [ i + 1 ] = S [ i ] - ' a ' + T [ i ] - ' a ' ; } for ( int i = N ; i >= 1 ; i -- ) { a1 [ i - 1 ] += a1 [ i ] / 26 ; a1 [ i ] %= 26 ; } for ( int i = 0 ; i <= N ; i ++ ) { if ( a1 [ i ] & 1 ) { if ( i + 1 <= N ) { a1 [ i + 1 ] += 26 ; } } a1 [ i ] /= 2 ; } for ( int i = 1 ; i <= N ; i ++ ) { cout << char ( a1 [ i ] + ' a ' ) ; } return 0 ; } int main ( ) { int N = 5 ; string S = " afogk " ; string T = " asdji " ; printMiddleString ( S , T , N ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; char KthCharacter ( string s , string t , long k ) { long f = 1 ; long ss = 2 ; string tmp = " " ; int len = tmp . length ( ) ; while ( len < k ) { long tf = f ; long ts = ss ; while ( tf -- != 0 ) { tmp += s ; } while ( ts -- != 0 ) { tmp += t ; } f += 2 ; ss += 2 ; len = tmp . length ( ) ; } char output = tmp [ k - 1 ] ; return output ; } int main ( ) { string S1 = " a " , S2 = " bc " ; int k = 4 ; char ans = KthCharacter ( S1 , S2 , k ) ; cout << ans ; }

Accumulator variables: f, ss, stdc, tf, tmp, ts
C++ program:
#include <bits/stdc++.h>
using namespace std ; void makeContiguous ( string S , int N ) { int fst_occur , lst_occur ; for ( int x = 0 ; x < N ; x ++ ) { if ( S [ x ] == '1' ) { fst_occur = x ; break ; } } for ( int x = N - 1 ; x >= 0 ; x -- ) { if ( S [ x ] == '1' ) { lst_occur = x ; break ; } } int count = 0 ; for ( int x = fst_occur ; x <= lst_occur ; x ++ ) { if ( S [ x ] == '0' ) { count ++ ; } } cout << count ; } int main ( ) { string S = "010001011" ; int N = S . size ( ) ; makeContiguous ( S , N ) ; return 0 ; }

Index/key variables: x
Accumulator variables: count, stdc, x
Iterator variables: x
C++ program:
#include " bits / stdc + + . h "
using namespace std ; string modifyString ( string & S , int K ) { int N = S . length ( ) ; for ( int i = 0 ; i < K ; i ++ ) { map < char , int > M ; for ( int j = i ; j < N ; j += K ) { M [ S [ j ] ] ++ ; } if ( M . size ( ) > 2 ) { return " - 1" ; } else if ( M . size ( ) == 1 ) { if ( M [ ' ? ' ] != 0 ) { for ( int j = i ; j < N ; j += K ) { S [ j ] = ' a ' ; } } } else if ( M . size ( ) == 2 ) { char ch ; for ( auto & it : M ) { if ( it . first != ' ? ' ) { ch = it . first ; } } for ( int j = i ; j < N ; j += K ) { S [ j ] = ch ; } } M . clear ( ) ; } return S ; } int main ( ) { string S = " ab ? ? " ; int K = 2 ; cout << modifyString ( S , K ) ; return 0 ; }

Index/key variables: j
Accumulator variables: i, j
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int fact ( int n ) { int ans = 1 ; for ( int i = 2 ; i <= n ; i ++ ) ans = ans * i ; return ans ; } int findComb ( int N , int M ) { int x = fact ( N + 1 ) ; int y = fact ( M ) ; return ( x * y ) ; } int main ( ) { int N = 2 ; cout << findComb ( N , M ) ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countCamelCase ( string & S ) { int count = 0 ; for ( int i = 0 ; S [ i ] ; i ++ ) { if ( S [ i ] >= 65 && S [ i ] <= 91 ) { count ++ ; } } cout << count ; } int main ( ) { string S = " ckjkUUYII " ; countCamelCase ( 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 findRepitition ( char a ) { if ( a <= ' z ' && a >= ' a ' ) { return a - ' a ' ; } else if ( a <= ' Z ' && a >= ' A ' ) { return a - ' A ' ; } return 0 ; } void decodeString ( string str ) { string output = " " ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { output . push_back ( str [ i ] ) ; i += findRepitition ( str [ i ] ) ; } cout << " Decrypted ▁ code ▁ is ▁ { " << output << " } " << endl ; } int main ( ) { string str = " abbbb ▁ acccdddd " ; decodeString ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printString ( string S , int N ) { string plaintext [ 5 ] ; int freq [ 26 ] = { 0 } ; int freqSorted [ 26 ] ; int Used [ 26 ] = { 0 } ; for ( int i = 0 ; i < N ; i ++ ) { if ( S [ i ] != ' ▁ ' ) { freq [ S [ i ] - ' A ' ] ++ ; } } for ( int i = 0 ; i < 26 ; i ++ ) { freqSorted [ i ] = freq [ i ] ; } string T = " ETAOINSHRDLCUMWFGYPBVKJXQZ " ; sort ( freqSorted , freqSorted + 26 , greater < int > ( ) ) ; for ( int i = 0 ; i < 5 ; i ++ ) { int ch = -1 ; for ( int j = 0 ; j < 26 ; j ++ ) { if ( freqSorted [ i ] == freq [ j ] && Used [ j ] == 0 ) { Used [ j ] = 1 ; ch = j ; break ; } } if ( ch == -1 ) break ; int x = T [ i ] - ' A ' ; x = x - ch ; string curr = " " ; for ( int k = 0 ; k < N ; k ++ ) { if ( S [ k ] == ' ▁ ' ) { curr += ' ▁ ' ; continue ; } int y = S [ k ] - ' A ' ; y += x ; if ( y < 0 ) y += 26 ; if ( y > 25 ) y -= 26 ; curr += ' A ' + y ; } plaintext [ i ] = curr ; } for ( int i = 0 ; i < 5 ; i ++ ) { cout << plaintext [ i ] << endl ; } } int main ( ) { string S = " B ▁ TJNQMF ▁ NFTTBHF " ; int N = S . length ( ) ; printString ( S , N ) ; return 0 ; }

Index/key variables: i, j, k
Accumulator variables: curr, i, j, k, stdc, y
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; void merge ( vector < int > & v , int left , int mid , int right , int & inversions ) { vector < int > temp ( right - left + 1 ) ; int i = left ; int j = mid + 1 ; int k = 0 ; int cnt = 0 ; while ( i <= mid && j <= right ) { if ( v [ i ] <= v [ j ] ) { temp [ k ++ ] = v [ i ++ ] ; } else { inversions += ( mid - i + 1 ) ; temp [ k ++ ] = v [ j ++ ] ; } } while ( i <= mid ) temp [ k ++ ] = v [ i ++ ] ; while ( j <= right ) temp [ k ++ ] = v [ j ++ ] ; k = 0 ; for ( int a = left ; a <= right ; a ++ ) { v [ a ] = temp [ k ++ ] ; } } void mergeSort ( vector < int > & v , int left , int right , int & inversions ) { if ( left < right ) { int mid = ( left + right ) / 2 ; mergeSort ( v , left , mid , inversions ) ; mergeSort ( v , mid + 1 , right , inversions ) ; merge ( v , left , mid , right , inversions ) ; } } int CountInversions ( vector < int > & v ) { int n = v . size ( ) ; int inversions = 0 ; mergeSort ( v , 0 , n - 1 , inversions ) ; return inversions ; } int getSubsCount ( string & input ) { int n = input . length ( ) ; vector < int > nums ( n ) ; for ( int i = 0 ; i < n ; i ++ ) { nums [ i ] = input [ i ] - '0' ; if ( nums [ i ] == 0 ) nums [ i ] = -1 ; } vector < int > pref ( n ) ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += nums [ i ] ; pref [ i ] = sum ; } int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( pref [ i ] > 0 ) cnt ++ ; } reverse ( pref . begin ( ) , pref . end ( ) ) ; int inversions = CountInversions ( pref ) ; int ans = cnt + inversions ; return ans ; } int main ( ) { string input = "101" ; int ans = getSubsCount ( input ) ; cout << ans << endl ; return 0 ; }

Index/key variables: a, i, j
Accumulator variables: a, cnt, i, inversions, j, k, stdc, sum
Iterator variables: a, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string canMadeEmpty ( string s , int n ) { stack < char > St ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == ' c ' ) { if ( St . size ( ) >= 2 ) { char b = St . top ( ) ; St . pop ( ) ; char a = St . top ( ) ; St . pop ( ) ; if ( a != ' a ' b != ' b ' ) return " No " ; } else return " No " ; } else St . push ( s [ i ] ) ; } if ( St . size ( ) == 0 ) { return " Yes " ; } else { return " No " ; } } int main ( ) { string S = " aabcbc " ; int N = S . length ( ) ; cout << canMadeEmpty ( S , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void countOperations ( string S ) { int n = S . length ( ) ; int ans = 0 ; int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( S [ i ] == '0' ) { cnt ++ ; } else { if ( cnt > 0 ) { cnt -- ; ans ++ ; } } } cout << ans ; } int main ( ) { string S = "110011010" ; countOperations ( S ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, cnt, i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string check ( string S ) { int N = S . length ( ) ; deque < int > A ; deque < int > B ; deque < int > C ; for ( int i = 0 ; i < N ; i ++ ) { if ( S [ i ] == ' A ' ) { A . push_back ( i ) ; } else if ( S [ i ] == ' B ' ) { B . push_back ( i ) ; } else { C . push_back ( i ) ; } } if ( N % 3 || A . size ( ) != B . size ( ) || A . size ( ) != C . size ( ) ) { return " No " ; } for ( int i = 0 ; i < B . size ( ) ; i ++ ) { if ( ! A . empty ( ) && B [ i ] > A [ 0 ] ) { A . pop_front ( ) ; } else { return " No " ; } } for ( int i = B . size ( ) - 1 ; i >= 0 ; i -- ) { if ( ! C . empty ( ) && B [ i ] < C . back ( ) ) { C . pop_back ( ) ; } else { return " No " ; } } return " Yes " ; } int main ( ) { string S = " ABABCC " ; cout << check ( S ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string isSumEqual ( string A , string B , string C ) { int L = A . length ( ) ; int M = B . length ( ) ; int N = A . length ( ) ; reverse ( A . begin ( ) , A . end ( ) ) ; reverse ( B . begin ( ) , B . end ( ) ) ; reverse ( C . begin ( ) , C . end ( ) ) ; int rem = 0 ; for ( int i = 0 ; i < max ( L , max ( M , N ) ) ; i ++ ) { int curr = rem ; if ( i < L ) curr += A [ i ] - ' a ' ; if ( i < M ) curr += B [ i ] - ' a ' ; rem = curr / 10 ; curr %= 10 ; if ( i < N && curr != C [ i ] - ' a ' ) { return " No " ; } } if ( rem ) return " No " ; else return " Yes " ; } int main ( ) { string A = " acb " , B = " cba " , C = " cdb " ; cout << isSumEqual ( A , B , C ) ; return 0 ; }

Index/key variables: i
Accumulator variables: curr, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int MinimumLengthSubstring ( string S , int N ) { int ans = N ; S = "0" + S + "0" ; for ( char c = ' a ' ; c <= ' z ' ; ++ c ) { int prev = 0 ; int max_len = 0 ; S [ 0 ] = c ; S [ N + 1 ] = c ; for ( int i = 1 ; i <= N + 1 ; ++ i ) { if ( S [ i ] == c ) { int len = i - prev ; max_len = max ( max_len , len ) ; prev = i ; } } ans = min ( ans , max_len ) ; } return ans ; } int main ( ) { string S = " abcde " ; int N = S . length ( ) ; cout << MinimumLengthSubstring ( S , N ) ; }

Index/key variables: i
Accumulator variables: stdc
Iterator variables: c, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimumHammingDistance ( string S , int K ) { int n = S . size ( ) ; int pref [ n ] ; pref [ 0 ] = S [ 0 ] - '0' ; for ( int i = 1 ; i < n ; i ++ ) pref [ i ] = pref [ i - 1 ] + ( S [ i ] - '0' ) ; int cnt = pref [ n - 1 ] ; int ans = cnt ; for ( int i = 0 ; i < n - K ; i ++ ) { int value = pref [ i + K - 1 ] - ( i - 1 >= 0 ? pref [ i - 1 ] : 0 ) ; ans = min ( ans , cnt - value + ( K - value ) ) ; } return ans ; } int main ( ) { string s = "101" ; int K = 2 ; cout << minimumHammingDistance ( s , K ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPrime ( int n ) { if ( n <= 1 ) return false ; else if ( n == 2 ) return true ; else if ( n % 2 == 0 ) return false ; for ( int i = 3 ; i <= sqrt ( n ) ; i += 2 ) { if ( n % i == 0 ) return false ; } return true ; } void checkPermutation ( string s1 , string s2 ) { int freq [ 26 ] = { 0 } ; for ( char ch : s1 ) { freq [ ch - ' a ' ] -- ; } for ( char ch : s2 ) { freq [ ch - ' a ' ] ++ ; } bool isAllChangesPrime = true ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( freq [ i ] == 0 ) { continue ; } else if ( ! isPrime ( abs ( freq [ i ] ) ) ) { isAllChangesPrime = false ; break ; } } if ( isAllChangesPrime ) { cout << " Yes " ; } else { cout << " No " ; } } int main ( ) { string S1 = " gekforgk " ; string S2 = " geeksforgeeks " ; checkPermutation ( S1 , S2 ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: ch, i
Boolean variables: isAllChangesPrime
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countWays ( string S , int N ) { int ans = 0 ; for ( int mask = 0 ; mask < ( 1 << N ) ; mask ++ ) { string X , Y ; for ( int i = 0 ; i < N ; i ++ ) { if ( mask >> i & 1 ) { X += S [ i ] ; } else { Y += S [ i ] ; } } reverse ( Y . begin ( ) , Y . end ( ) ) ; if ( X == Y ) { ans ++ ; } } return ans ; } int main ( ) { string S = " mippiisssisssiipsspiim " ; int N = S . length ( ) ; cout << countWays ( S , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: X, Y, ans, i, mask, stdc
Iterator variables: i, mask
C++ program:
#include <bits/stdc++.h>
using namespace std ; void isEqualSubstring ( string str , int x ) { int n = str . length ( ) ; int i = 0 ; while ( i < n && i < x ) { if ( str [ i ] != str [ n - i - 1 ] ) { cout << " false " ; return ; } i ++ ; } cout << " true " ; } int main ( ) { string str = " GeeksforGeeks " ; int x = 3 ; isEqualSubstring ( str , x ) ; }

Index/key variables: i
Accumulator variables: i, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void solve ( string S , int N , vector < vector < int > > Queries , int Q ) { for ( int i = 0 ; i < Q ; i ++ ) { int T = Queries [ i ] [ 0 ] , A = Queries [ i ] [ 1 ] , B = Queries [ i ] [ 2 ] ; A -- ; B -- ; if ( T == 1 ) { swap ( S [ A ] , S [ B ] ) ; } else { for ( int j = 0 ; j < N ; j ++ ) { swap ( S [ j ] , S [ j + N ] ) ; } } } cout << S << endl ; } int main ( ) { string S = " ABCD " ; int N = S . length ( ) / 2 ; vector < vector < int > > Queries = { { 2 , 0 , 0 } , { 1 , 1 , 3 } , { 2 , 0 , 0 } } ; int Q = Queries . size ( ) ; solve ( S , N , Queries , Q ) ; return 0 ; }

Index/key variables: A, B, i, j
Accumulator variables: A, B, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minimumOperations ( string S , int N ) { int ans = 0 ; int cntOne = 0 ; for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( S [ i ] == '0' ) { ans += cntOne ; cntOne *= 2 ; } else cntOne ++ ; } cout << ans ; } int main ( ) { string S = "001" ; int N = S . length ( ) ; minimumOperations ( S , N ) ; return 0 ; }

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