dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; void differentBitwiseOR ( string s1 , string s2 ) { int n = s1 . size ( ) ; int t00 = 0 , t10 = 0 , t01 = 0 , t11 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s1 [ i ] == '0' && s2 [ i ] == '0' ) { t00 ++ ; } if ( s1 [ i ] == '1' && s2 [ i ] == '0' ) { t10 ++ ; } if ( s1 [ i ] == '1' && s2 [ i ] == '1' ) { t11 ++ ; } if ( s1 [ i ] == '0' && s2 [ i ] == '1' ) { t01 ++ ; } } int ans = t00 * t10 + t01 * t10 + t00 * t11 ; cout << ans ; } int main ( ) { string S1 = "01001" ; string S2 = "11011" ; differentBitwiseOR ( S1 , S2 ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, t00, t01, t10, t11
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void convertString ( string S , int k ) { int n = S . length ( ) ; string temp = S ; for ( int i = 0 ; i < k ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( j == 0 && S [ j ] == '0' ) { temp [ j ] = S [ j + 1 ] ; } else if ( j == n - 1 && S [ j ] == '0' ) { temp [ j ] = S [ j - 1 ] ; } else if ( S [ j - 1 ] != S [ j + 1 ] && S [ j ] == '0' ) { temp [ j ] = '1' ; } } if ( S == temp ) { break ; } S = temp ; } cout << S ; } int main ( ) { string S = "10010001" ; int K = 1 ; convertString ( S , K ) ; return 0 ; }

Index/key variables: j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void RemoveCharacters ( string s ) { string ans = " " ; bool c [ 26 ] ; for ( int i = 0 ; i < 26 ; i ++ ) c [ i ] = 0 ; int pos = 0 ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) { if ( c [ s [ i ] - ' a ' ] == 0 ) { c [ s [ i ] - ' a ' ] = 1 ; pos = i ; ans += s [ i ] ; } } for ( int i = pos + 1 ; i < ( int ) s . size ( ) ; i ++ ) { if ( s [ i ] == s [ 0 ] ) { ans += s [ i ] ; break ; } } cout << ans ; } int main ( ) { string S = " abcaadbcd " ; RemoveCharacters ( S ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void isPossible ( string s , int K ) { bool valid = false ; long firstx = -1 ; int n = s . length ( ) ; for ( int i = 1 ; i <= n / 2 ; ++ i ) { long x = stol ( s . substr ( 0 , i ) ) ; firstx = x ; string test = to_string ( x ) ; while ( test . length ( ) < s . length ( ) ) { x -= K ; test += to_string ( x ) ; } if ( test == s ) { valid = true ; break ; } } cout << ( ( valid == true ) ? " Yes ▁ " : " No " ) ; } int main ( ) { string S = "8642" ; int K = 2 ; isPossible ( S , K ) ; return 0 ; }

Accumulator variables: stdc, test, x
Iterator variables: i
Boolean variables: valid
C++ program:
#include <bits/stdc++.h>
using namespace std ; void changeCharacters ( string S , int N , int K ) { int flag = 1 ; int count = 0 ; stack < char > st ; for ( int i = 0 ; i < N ; i ++ ) { if ( st . empty ( ) ) { if ( S [ i ] == '0' ) { flag = 0 ; break ; } count = 0 ; st . push ( S [ i ] ) ; } else { if ( S [ i ] == '0' ) { count ++ ; if ( count == K ) { st . pop ( ) ; count = 0 ; } } else { count = 0 ; } } } if ( flag ) cout << " YES " << endl ; else cout << " NO " << endl ; } int main ( ) { string S = "100100" ; int N = S . length ( ) ; int K = 2 ; changeCharacters ( S , N , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; bool prefixDivisble ( int n ) { int i = 1 ; while ( n > 0 ) { if ( n % i != 0 ) return false ; n = n / 10 ; i ++ ; } return true ; } int main ( ) { int n = 52248 ; if ( prefixDivisble ( n ) ) cout << " Yes " << endl ; else cout << " No " << endl ; return 0 ; }

Accumulator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int longestSubstring ( string s ) { unordered_map < string , int > indexes ; unordered_map < char , int > chars ( { { ' a ' , 0 } , { ' e ' , 1 } , { ' i ' , 2 } , { ' o ' , 3 } , { ' u ' , 4 } } ) ; string evenOdd = "00000" ; indexes [ evenOdd ] = -1 ; int length = 0 ; for ( int i = 0 ; i < s . size ( ) ; ++ i ) { char c = s [ i ] ; auto it = chars . find ( c ) ; if ( it != chars . end ( ) ) { evenOdd [ it -> second ] = evenOdd [ it -> second ] == '0' ? '1' : '0' ; } auto lastIndex = indexes . find ( evenOdd ) ; if ( lastIndex == indexes . end ( ) ) { indexes [ evenOdd ] = i ; } else { length = max ( length , i - lastIndex -> second ) ; } } cout << length ; } int main ( ) { string S = " bcbcbc " ; longestSubstring ( S ) ; return 0 ; }

Index/key variables: evenOdd, i
Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isSubsequence ( string str1 , string str2 , int m , int n ) { int j = 0 ; for ( int i = 0 ; i < n && j < m ; i ++ ) if ( str1 [ j ] == str2 [ i ] ) j ++ ; return ( j == m ) ; } void findMinimumNumber ( string s ) { int r = stoi ( s , 0 , 2 ) ; int ans = r + 1 ; for ( int i = 0 ; i <= r ; i ++ ) { string p = " " ; int j = i ; while ( j > 0 ) { p += to_string ( j % 2 ) ; j = j / 2 ; } int m = p . length ( ) ; int n = s . length ( ) ; reverse ( p . begin ( ) , p . end ( ) ) ; if ( ! isSubsequence ( p , s , m , n ) ) { ans = i ; break ; } } cout << ans ; } int main ( ) { string s = "10101" ; findMinimumNumber ( s ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, p, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void MinimumCost ( string S , int A , int B ) { int count = 0 ; int group = 0 ; for ( int i = 0 ; i < S . size ( ) ; i ++ ) { if ( S [ i ] == '0' ) { count += 1 ; } else { if ( count > 0 ) { group += 1 ; } count = 0 ; } } if ( count > 0 ) group += 1 ; if ( group == 0 ) { cout << 0 << endl ; } else { cout << min ( A , B ) * ( group - 1 ) + B ; } } int main ( ) { int A = 1 ; int B = 5 ; string S = "01100" ; MinimumCost ( S , A , B ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, group, i, stdc
Iterator variables: i
C++ program:
#include <iostream>
#include <vector>
using namespace std ; bool isPrime ( int x ) { if ( x <= 1 ) return false ; for ( int i = 2 ; i * i <= x ; i ++ ) { if ( x % i == 0 ) return false ; } return true ; } void largestPrime ( string s ) { vector < pair < string , int > > vec { { " " , 0 } } ; int ans = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int n = vec . size ( ) ; for ( int j = 0 ; j < n ; j ++ ) { pair < string , int > temp = vec [ j ] ; string str = temp . first ; int val = temp . second ; if ( s [ i ] == '1' ) { temp . first = str + '1' ; temp . second = ( ( val << 1 ) + 1 ) ; } else { temp . first = str + '0' ; temp . second = ( ( val << 1 ) + 0 ) ; } vec . push_back ( temp ) ; int check = temp . second ; if ( isPrime ( check ) ) { ans = max ( ans , check ) ; } } } if ( ans == 0 ) cout << -1 << endl ; else cout << ans << endl ; } int main ( ) { string s = "110" ; largestPrime ( s ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPrime ( int num ) { bool flag = false ; if ( num > 1 ) { for ( int i = 2 ; i < num ; i ++ ) { if ( ( num % i ) == 0 ) { flag = true ; break ; } } } if ( flag ) return false ; else return true ; } int order ( int x ) { int n = 0 ; while ( x != 0 ) { n = n + 1 ; x = x / 10 ; } return n ; } bool isArmstrong ( int x ) { int n = order ( x ) ; int temp = x ; int sum1 = 0 ; while ( temp != 0 ) { int r = temp % 10 ; sum1 = sum1 + pow ( r , n ) ; temp = temp / 10 ; } return ( sum1 == x ) ; } int count_armstrong ( vector < string > li ) { int c = 0 ; for ( string ele : li ) { int val = 0 ; for ( char che : ele ) val += che ; if ( isArmstrong ( val ) ) c += 1 ; } return c ; } int count_prime ( vector < string > li ) { int c = 0 ; for ( string ele : li ) { int val = 0 ; for ( char che : ele ) val += che ; if ( isPrime ( val ) ) c += 1 ; } return c ; } int main ( ) { vector < string > arr = { " geeksforgeeks " , " a " , " computer " , " science " , " portal " , " for " , " geeks " } ; cout << " Number ▁ of ▁ Armstrong ▁ Strings ▁ are : ▁ " << count_armstrong ( arr ) << endl ; cout << " Number ▁ of ▁ Prime ▁ Strings ▁ are : ▁ " << count_prime ( arr ) << endl ; }

Accumulator variables: c, i, stdc, val
Iterator variables: che, ele, i
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findMinimumCost ( string s , int N ) { int count_1 = 0 , count_0 = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( s [ i ] == '1' ) count_1 ++ ; else count_0 ++ ; } int k = abs ( count_0 - count_1 ) ; if ( count_1 == N count_0 == N ) cout << -1 << endl ; else cout << k / 2 << endl ; } int main ( ) { string S = "110110" ; int N = S . length ( ) ; findMinimumCost ( S , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count_0, count_1, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findMinimumTime ( string & S , int N , int K ) { if ( N == 0 ) { cout << 0 ; return ; } int maxfreq = INT_MIN ; char maxchar ; unordered_map < char , int > um ; for ( int i = 0 ; i < N ; i ++ ) { um [ S [ i ] ] ++ ; if ( um [ S [ i ] ] > maxfreq ) { maxfreq = um [ S [ i ] ] ; maxchar = S [ i ] ; } } int emptySlots = ( maxfreq - 1 ) * K ; for ( auto & it : um ) { if ( it . first == maxchar ) continue ; emptySlots -= min ( it . second , maxfreq - 1 ) ; } int ans = N + max ( 0 , emptySlots ) ; cout << ans ; } int main ( ) { string S = " AAABBB " ; int K = 2 ; int N = S . length ( ) ; findMinimumTime ( S , N , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: emptySlots, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void canMakeEqual ( string S ) { int N = S . size ( ) ; int weightOfString = 0 ; for ( int i = 0 ; i < N ; i ++ ) { weightOfString += S [ i ] - ' a ' + 1 ; } if ( weightOfString % N == 0 ) cout << " Yes " ; else cout << " No " ; } int main ( ) { string S = " beb " ; canMakeEqual ( S ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, weightOfString
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void addFrequencyToCharacter ( string S ) { int frequency [ 26 ] = { 0 } ; int N = S . length ( ) ; for ( int i = 0 ; i < N ; i ++ ) { frequency [ S [ i ] - ' a ' ] += 1 ; } for ( int i = 0 ; i < N ; i ++ ) { int add = frequency [ S [ i ] - ' a ' ] % 26 ; if ( int ( S [ i ] ) + add <= int ( ' z ' ) ) S [ i ] = char ( int ( S [ i ] ) + add ) ; else { add = ( int ( S [ i ] ) + add ) - ( int ( ' z ' ) ) ; S [ i ] = char ( int ( ' a ' ) + add - 1 ) ; } } cout << S ; } int main ( ) { string S = " geeksforgeeks " ; addFrequencyToCharacter ( S ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minLength ( string S ) { stack < char > st ; for ( auto ch : S ) { if ( st . empty ( ) ) st . push ( ch ) ; else { char top = st . top ( ) ; if ( abs ( ch - top ) == 1 ) st . pop ( ) ; else { st . push ( ch ) ; } } } return st . size ( ) ; } int main ( ) { string S = "12213" ; cout << minLength ( S ) ; return 0 ; }

Accumulator variables: stdc
Iterator variables: ch
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findMinimumTime ( string tasks , int K ) { unordered_map < char , int > map ; int curr_time = 0 ; for ( char c : tasks ) { if ( map . find ( c ) != map . end ( ) ) { if ( curr_time - map <= K ) { curr_time += K - ( curr_time - map ) + 1 ; } } map = curr_time ; curr_time ++ ; } cout << curr_time ; } int main ( ) { string S = " ABACCA " ; int K = 2 ; findMinimumTime ( S , K ) ; return 0 ; }

Accumulator variables: curr_time, stdc
Iterator variables: c
C++ program:
#include <bits/stdc++.h>
using namespace std ; void checkforSubsequence ( string S , string target ) { stack < char > s ; for ( int i = 0 ; i < target . size ( ) ; i ++ ) { s . push ( target [ i ] ) ; } for ( int i = ( int ) S . size ( ) - 1 ; i >= 0 ; i -- ) { if ( s . empty ( ) ) { cout << " Yes " << endl ; return ; } if ( S [ i ] == s . top ( ) ) { s . pop ( ) ; } } if ( s . empty ( ) ) cout << " Yes " << endl ; else cout << " No " << endl ; } int main ( ) { string S = " KOTTAYAM " ; string target = " KOTA " ; checkforSubsequence ( S , target ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include " bits / stdc + + . h "
using namespace std ; string digits = "0123456789" , sign = " + - " ; string dot = " . " , ex = " eE " ; int dfa [ 11 ] [ 5 ] ; void makeDFA ( ) { dfa [ 0 ] [ 0 ] = 1 ; dfa [ 1 ] [ 0 ] = 1 ; dfa [ 1 ] [ 2 ] = 3 ; dfa [ 1 ] [ 3 ] = 2 ; dfa [ 1 ] [ 4 ] = 6 ; dfa [ 3 ] [ 0 ] = 4 ; dfa [ 4 ] [ 0 ] = 4 ; dfa [ 4 ] [ 3 ] = 5 ; dfa [ 4 ] [ 4 ] = 6 ; dfa [ 6 ] [ 0 ] = 8 ; dfa [ 6 ] [ 1 ] = 7 ; dfa [ 7 ] [ 0 ] = 8 ; dfa [ 8 ] [ 0 ] = 8 ; dfa [ 8 ] [ 3 ] = 9 ; } void buildDFA ( ) { for ( int i = 0 ; i < 11 ; i ++ ) for ( int j = 0 ; j < 5 ; j ++ ) dfa [ i ] [ j ] = 10 ; makeDFA ( ) ; } void checkDFA ( string s ) { buildDFA ( ) ; int currentstate = 0 ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) { if ( digits . find ( s [ i ] ) != digits . npos ) currentstate = dfa [ currentstate ] [ 0 ] ; else if ( sign . find ( s [ i ] ) != sign . npos ) currentstate = dfa [ currentstate ] [ 1 ] ; else if ( dot . find ( s [ i ] ) != dot . npos ) currentstate = dfa [ currentstate ] [ 2 ] ; else if ( ex . find ( s [ i ] ) != ex . npos ) currentstate = dfa [ currentstate ] [ 4 ] ; else currentstate = dfa [ currentstate ] [ 3 ] ; } if ( currentstate == 1 currentstate == 4 currentstate == 8 ) { cout << " Unsigned ▁ integer " ; } else { cout << " Not ▁ an ▁ unsigned ▁ integer " ; } } int main ( ) { string S = "1729" ; checkDFA ( S ) ; return 0 ; }

Index/key variables: currentstate, i, j
Accumulator variables: i, j
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printSentence ( string str ) { char nums [ ] [ 5 ] = { " " , " " , " ABC " , " DEF " , " GHI " , " JKL " , " MNO " , " PQRS " , " TUV " , " WXYZ " } ; int i = 0 ; while ( str [ i ] != ' \0' ) { if ( str [ i ] == ' . ' ) { i ++ ; continue ; } int count = 0 ; while ( str [ i + 1 ] && str [ i ] == str [ i + 1 ] ) { if ( count == 2 && ( ( str [ i ] >= '2' && str [ i ] <= '6' ) || ( str [ i ] == '8' ) ) ) break ; else if ( count == 3 && ( str [ i ] == '7' str [ i ] == '9' ) ) break ; count ++ ; i ++ ; if ( str [ i ] == ' \0' ) break ; } if ( str [ i ] == '7' str [ i ] == '9' ) { cout << nums [ str [ i ] - 48 ] [ count % 4 ] ; } else { cout << nums [ str [ i ] - 48 ] [ count % 3 ] ; } i ++ ; } } int main ( ) { string str = "234" ; printSentence ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; string getString ( int N ) { string ans = " " ; while ( N >= 26 ) { ans += ' z ' ; N -= 26 ; } ans += char ( N + ' a ' - 1 ) ; return ans ; } int main ( ) { int N = 30 ; cout << getString ( N ) ; return 0 ; }

Accumulator variables: N, ans, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void countSamePrefixSuffix ( string s , int n ) { string prefix = " " ; for ( int i = 0 ; i < n - 1 ; i ++ ) { prefix += s [ i ] ; string suffix = s . substr ( n - 1 - i , n - 1 ) ; if ( prefix == suffix ) { cout << prefix . size ( ) << " ▁ " ; } } } int main ( ) { string S = " ababababab " ; int N = S . size ( ) ; countSamePrefixSuffix ( S , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, prefix, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void countStringPairs ( string a [ ] , int n ) { int ans = 0 ; unordered_map < string , int > s ; for ( int i = 0 ; i < n ; i ++ ) { s [ a [ i ] ] ++ ; } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { string p = a [ i ] ; string q = a [ j ] ; if ( p [ 0 ] != q [ 0 ] ) { swap ( p [ 0 ] , q [ 0 ] ) ; if ( s . find ( p ) == s . end ( ) && s . find ( q ) == s . end ( ) ) { ans ++ ; } } } } cout << ans ; } int main ( ) { string arr [ ] = { " good " , " bad " , " food " } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; countStringPairs ( arr , N ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: ans, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minimumMoves ( string s , int n , int k ) { if ( n & 1 ) { cout << " No " ; return ; } int countOpen = count ( s . begin ( ) , s . end ( ) , ' ( ' ) ; int countClose = count ( s . begin ( ) , s . end ( ) , ' ) ' ) ; if ( countOpen != countClose ) { cout << " No " ; return ; } int ans = 0 ; int cnt = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( s [ i ] == ' ( ' ) ++ cnt ; else { -- cnt ; if ( cnt < 0 ) { cnt = 0 ; ++ ans ; } } } if ( ans <= k ) cout << " Yes " ; else cout << " No " ; } int main ( ) { string S = " ) ( " ; int K = 1 ; minimumMoves ( S , S . length ( ) , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findRandom ( ) { int num = ( ( int ) rand ( ) % 2 ) ; return num ; } void generateBinaryString ( int N ) { srand ( time ( NULL ) ) ; string S = " " ; for ( int i = 0 ; i < N ; i ++ ) { int x = findRandom ( ) ; S += to_string ( x ) ; } cout << S ; } int main ( ) { int N = 7 ; generateBinaryString ( N ) ; return 0 ; }

Accumulator variables: S, i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void checkPalindrome ( string & s ) { int a [ 26 ] = { 0 } ; int o = 0 , e = 0 ; for ( int i = 0 ; s [ i ] != ' \0' ; i ++ ) a [ ( int ) s [ i ] - 97 ] ++ ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( a [ i ] == 1 ) o ++ ; else if ( a [ i ] % 2 == 0 and a [ i ] != 0 ) e += ( a [ i ] / 2 ) ; } if ( e >= o ) cout << " Yes " ; else { o = o - e ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( o <= 0 ) break ; if ( o > 0 and a [ i ] % 2 == 1 and a [ i ] > 2 ) { int k = o ; o = o - a [ i ] / 2 ; if ( o > 0 or 2 * k + 1 == a [ i ] ) { o ++ ; a [ i ] = 1 ; } } } if ( o <= 0 ) cout << " Yes " ; else cout << " No " ; } } int main ( ) { string S = " abbbaddzcz " ; checkPalindrome ( S ) ; return 0 ; }

Index/key variables: i
Accumulator variables: e, i, o
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string maximumTime ( string s ) { if ( s [ 0 ] == ' _ ' ) { if ( ( s [ 1 ] == ' _ ' ) || ( s [ 1 ] >= '0' && s [ 1 ] < '4' ) ) { s [ 0 ] = '2' ; } else { s [ 0 ] = '1' ; } } if ( s [ 1 ] == ' _ ' ) { if ( s [ 0 ] == '2' ) { s [ 1 ] = '3' ; } else { s [ 1 ] = '9' ; } } if ( s [ 3 ] == ' _ ' ) { s [ 3 ] = '5' ; } if ( s [ 4 ] == ' _ ' ) { s [ 4 ] = '9' ; } return s ; } int main ( ) { string S = "0 _ : 4 _ " ; cout << maximumTime ( S ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int distinctEmails ( vector < string > & emails ) { for ( auto & x : emails ) { auto pos2 = x . find ( ' @ ' ) ; if ( pos2 < x . size ( ) ) x . erase ( remove ( x . begin ( ) , x . begin ( ) + pos2 , ' . ' ) , x . begin ( ) + pos2 ) ; auto pos1 = x . find ( ' + ' ) ; pos2 = x . find ( ' @ ' ) ; if ( pos1 < x . size ( ) and pos2 < x . size ( ) ) { x . erase ( pos1 , pos2 - pos1 ) ; } } unordered_set < string > ans ( emails . begin ( ) , emails . end ( ) ) ; return ans . size ( ) ; } int main ( ) { vector < string > arr = { " raghav . agg @ geeksforgeeks . com " , " raghavagg @ geeksforgeeks . com " } ; cout << distinctEmails ( arr ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void nearestPowerOfTwoUtil ( unordered_map < char , int > & freq ) { for ( auto & it : freq ) { cout << it . first << " ▁ - > ▁ " ; int lg = log2 ( it . second ) ; int a = pow ( 2 , lg ) ; int b = pow ( 2 , lg + 1 ) ; if ( ( it . second - a ) < ( b - it . second ) ) { cout << a << endl ; } else { cout << b << endl ; } } } void nearestPowerOfTwo ( string & S ) { int N = S . size ( ) ; unordered_map < char , int > freq ; for ( int i = 0 ; i < N ; i ++ ) { freq [ S [ i ] ] ++ ; } nearestPowerOfTwoUtil ( freq ) ; } int main ( ) { string N = "16333331163" ; nearestPowerOfTwo ( N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } int lcm ( int a , int b ) { return ( a / gcd ( a , b ) ) * b ; } void findSmallestString ( string s , string t ) { int n = s . length ( ) , m = t . length ( ) ; int l = lcm ( n , m ) ; string s1 = " " , t1 = " " ; for ( int i = 0 ; i < l / n ; i ++ ) { s1 += s ; } for ( int i = 0 ; i < l / m ; i ++ ) { t1 += t ; } if ( s1 == t1 ) cout << s1 ; else cout << -1 ; } int main ( ) { string S = " baba " , T = " ba " ; findSmallestString ( S , T ) ; return 0 ; }

Accumulator variables: i, s1, stdc, t1
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minRemovals ( string str , int N ) { int ans = 0 ; bool X = false ; for ( int i = 0 ; i < N ; i ++ ) { if ( str [ i ] == '0' ) { ans ++ ; while ( str [ i ] == '0' ) { i ++ ; } } else { X = true ; } } if ( ! X ) return 1 ; if ( str [ 0 ] == '0' and str [ N - 1 ] == '0' ) { ans -- ; } return ans ; } int main ( ) { string S = "11010001" ; int N = S . size ( ) ; cout << minRemovals ( S , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, stdc
Iterator variables: i
Boolean variables: X
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimumDeletions ( string s ) { int right_0 = count ( s . begin ( ) , s . end ( ) , '0' ) ; int left_1 = 0 ; int n = s . size ( ) ; int res = INT_MAX ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == '0' ) { right_0 -= 1 ; } else { left_1 += 1 ; } res = min ( res , right_0 + left_1 ) ; } return res ; } int main ( ) { string s = "001101" ; int count = minimumDeletions ( s ) ; cout << count ; return 0 ; }

Index/key variables: i
Accumulator variables: i, left_1, right_0, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int canMakeSame ( string s1 , string s2 ) { int ans = 0 ; if ( s1 . size ( ) != s2 . size ( ) ) { return -1 ; } int N = s1 . length ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( s1 [ i ] != s2 [ i ] ) { while ( i < s1 . length ( ) && s1 [ i ] != s2 [ i ] ) { i ++ ; } ans ++ ; } } return ans ; } int main ( ) { string S1 = "100001" ; string S2 = "110111" ; cout << canMakeSame ( S1 , S2 ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int convert ( string str ) { str . replace ( 2 , 1 , " " ) ; int h1 = ( int ) str [ 1 ] - '0' ; int h2 = ( int ) str [ 0 ] - '0' ; int hh = ( h2 * 10 + h1 % 10 ) ; int time = 0 ; if ( str [ 5 ] == ' A ' ) { if ( hh == 12 ) time += stoi ( str . substr ( 2 , 2 ) ) ; else { time += stoi ( str . substr ( 0 , 2 ) ) ; } } else { if ( hh == 12 ) { time += stoi ( str . substr ( 0 , 4 ) ) ; } else { time += stoi ( str . substr ( 0 , 4 ) ) ; time += 1200 ; } } return time ; } int countOverlap ( string arr [ ] [ 2 ] , int n , string p ) { int ans = 0 ; int M = convert ( p ) ; for ( int i = 0 ; i < n ; i ++ ) { int L = convert ( arr [ i ] [ 0 ] ) ; int R = convert ( arr [ i ] [ 1 ] ) ; if ( ( L <= M && M <= R ) || ( M >= R && M <= L ) ) ans ++ ; } return ans ; } int main ( ) { string arr [ ] [ 2 ] = { { "12:00 : AM " , "11:55 : PM " } , { "12:01 : AM " , "11:50 : AM " } , { "12:30 : AM " , "12:00 : PM " } , { "11:57 : AM " , "11:59 : PM " } } ; string P = "12:01 : PM " ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countOverlap ( arr , N , P ) << endl ; }

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