dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; string len ( long A , long B ) { string res = " " ; long Log = 0 ; do { Log = ( long ) ( log ( B ) / log ( 2 ) ) ; if ( Log != 0 ) { res = res + to_string ( A ) + " < < " + to_string ( Log ) ; } else { res += A ; break ; } B = B - ( long ) pow ( 2 , Log ) ; if ( B != 0 ) { res += " + " ; } else break ; } while ( Log != 0 ) ; return res ; } void minimumString ( long A , long B ) { string res1 = len ( A , B ) ; string res2 = len ( B , A ) ; if ( res1 . length ( ) > res2 . length ( ) ) { cout << res2 << endl ; } else { cout << res1 << endl ; } } int main ( ) { long A = 6 ; long B = 10 ; minimumString ( A , B ) ; return 0 ; }

Accumulator variables: res, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void countSubstring ( string s ) { int res = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int x = 0 ; for ( int j = i ; j < s . length ( ) ; j ++ ) { int temp = 1 << s [ j ] - ' a ' ; x ^= temp ; if ( ( x & ( x - 1 ) ) == 0 ) res ++ ; } } cout << res ; } int main ( ) { string str = " aaa " ; countSubstring ( str ) ; return 0 ; }

Index/key variables: j
Accumulator variables: i, j, res, stdc, x
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void countSubstring ( string s ) { int answer = 0 ; unordered_map < int , int > m ; m [ 0 ] = 1 ; int x = 0 ; for ( int j = 0 ; j < s . length ( ) ; j ++ ) { x ^= 1 << ( s [ j ] - ' a ' ) ; answer += m [ x ] ; for ( int i = 0 ; i < 26 ; ++ i ) { answer += m [ x ^ ( 1 << i ) ] ; } m [ x ] += 1 ; } cout << answer ; } int main ( ) { string str = " abab " ; countSubstring ( str ) ; return 0 ; }

Index/key variables: j, x
Accumulator variables: answer, j, stdc, x
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printResult ( vector < int > result ) { reverse ( result . begin ( ) , result . end ( ) ) ; int i = 0 ; while ( i < result . size ( ) ) { cout << result [ i ] ; i ++ ; } } void sumOfLargeNumbers ( string v [ ] , int k , int N ) { vector < vector < int > > x ( 1000 ) ; for ( int i = 0 ; i < k ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { x [ i ] . push_back ( v [ i ] [ j ] - '0' ) ; } } int carry = 0 ; vector < int > result ; for ( int i = N - 1 ; i >= 0 ; i -- ) { int sum = 0 ; for ( int j = 0 ; j < k ; j ++ ) sum += x [ j ] [ i ] ; sum += carry ; int temp = sum ; int count = 0 ; while ( temp > 9 ) { temp = temp % 10 ; count ++ ; } long long int l = pow ( 10 , count ) ; if ( l != 1 ) carry = ( double ) sum / l ; sum = sum % 10 ; result . push_back ( sum ) ; } while ( carry != 0 ) { int a = carry % 10 ; result . push_back ( a ) ; carry = carry / 10 ; } printResult ( result ) ; } int main ( ) { int K = 10 ; int N = 5 ; string arr [ ] = { "1111111111" , "1111111111" , "1111111111" , "1111111111" , "1111111111" } ; sumOfLargeNumbers ( arr , N , K ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: count, i, j, stdc, sum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printRev ( string str ) { stack < string > st ; stringstream ss ( str ) ; string temp ; while ( getline ( ss , temp , ' ▁ ' ) ) { st . push ( temp ) ; } while ( ! st . empty ( ) ) { cout << st . top ( ) << " ▁ " ; st . pop ( ) ; } } int main ( ) { string str ; str = " geeks ▁ quiz ▁ practice ▁ code " ; printRev ( str ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countOfSubstringWithOnlyOnes ( string s ) { int res = 0 , count = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { count = s [ i ] == '1' ? count + 1 : 0 ; res = ( res + count ) ; } return res ; } int main ( ) { string s = "0110111" ; cout << countOfSubstringWithOnlyOnes ( s ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define int  long long int
const int mod = 1e9 + 7 ; int binExp ( int base , int power ) { int x = 1 ; while ( power ) { if ( power % 2 == 1 ) x = ( ( x % mod ) * ( base % mod ) ) % mod ; base = ( ( base % mod ) * ( base % mod ) ) % mod ; power = power / 2 ; } return x ; } int fact ( int num ) { int result = 1 ; for ( int i = 1 ; i <= num ; ++ i ) { result = ( ( result % mod ) * ( i % mod ) ) % mod ; } return result ; } int calculate_nCi ( int N , int i ) { int nfact = fact ( N ) ; int ifact = fact ( i ) ; int dfact = fact ( N - i ) ; int inv_ifact = binExp ( ifact , mod - 2 ) ; int inv_dfact = binExp ( dfact , mod - 2 ) ; int denm = ( ( inv_ifact % mod ) * ( inv_dfact % mod ) ) % mod ; int answer = ( ( nfact % mod ) * ( denm % mod ) ) % mod ; return answer ; } void countSubstring ( int N , int s , int k ) { int allWays = binExp ( 26 , N ) ; int noWays = 0 ; for ( int i = 0 ; i < s ; ++ i ) { int nCi = calculate_nCi ( N , i ) ; int remaining = binExp ( 25 , N - i ) ; int multiply = ( ( nCi % mod ) * ( remaining % mod ) ) % mod ; noWays = ( ( noWays % mod ) + ( multiply % mod ) ) % mod ; } int answer = ( ( allWays % mod ) - ( noWays % mod ) ) % mod ; if ( answer < 0 ) answer += mod ; cout << answer ; } int32_t main ( ) { string str = " abc " ; int k = 2 ; int s = str . length ( ) ; int N = s + k ; countSubstring ( N , s , k ) ; }

Accumulator variables: answer, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int N = 1e5 + 5 ; vector < int > prefix ( N , 0 ) ; vector < int > sum ( N , 0 ) ; bool isSpecial ( char c , vector < char > & special ) { for ( auto & i : special ) if ( i == c ) return true ; return false ; } double countRatio ( string & s , vector < char > & special ) { int n = s . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { prefix [ i ] = int ( isSpecial ( s [ i ] , special ) ) ; if ( i > 0 ) prefix [ i ] += prefix [ i - 1 ] ; } for ( int i = 0 ; i < n ; i ++ ) { sum [ i ] = prefix [ i ] ; if ( i > 0 ) sum [ i ] += sum [ i - 1 ] ; } double ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { int count = sum [ n - 1 ] - ( i > 1 ? sum [ i - 2 ] : 0 ) ; count -= ( i < n ? sum [ n - i - 1 ] : 0 ) ; ans += double ( count ) / double ( i ) ; } return ans ; } int main ( ) { string s = " abcd " ; vector < char > special = { ' b ' , ' c ' } ; double ans = countRatio ( s , special ) ; cout << fixed << setprecision ( 6 ) << ans << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void count_minimum ( string s ) { int n = s . length ( ) ; int ans = 0 ; int i = 0 ; while ( i < n ) { int j = i ; while ( s [ j ] == s [ i ] && j < n ) { j ++ ; } int diff = j - i ; ans += diff / 2 ; i = j ; } cout << ans << endl ; } int main ( ) { string str = " caaab " ; count_minimum ( str ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: ans, j, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int min_cost ( string st ) { string vow = " aeiou " ; int cost = 0 ; for ( int i = 0 ; i < st . size ( ) ; i ++ ) { vector < int > costs ; for ( int j = 0 ; j < 5 ; j ++ ) costs . push_back ( abs ( st [ i ] - vow [ j ] ) ) ; cost += * min_element ( costs . begin ( ) , costs . end ( ) ) ; } return cost ; } int main ( ) { string str = " abcde " ; cout << ( min_cost ( str ) ) ; }

Index/key variables: i, j
Accumulator variables: cost, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPalindrome ( string str ) { int l = 0 ; int h = str . size ( ) - 1 ; while ( h > l ) { if ( str [ l ++ ] != str [ h -- ] ) { return false ; } } return true ; } string makeOddString ( string str ) { string odd = " " ; for ( int i = 1 ; i < str . size ( ) ; i += 2 ) { odd += str [ i ] ; } return odd ; } string makeevenString ( string str ) { string even = " " ; for ( int i = 0 ; i < str . size ( ) ; i += 2 ) { even += str [ i ] ; } return even ; } void checkevenOddPalindrome ( string str ) { string odd = makeOddString ( str ) ; string even = makeevenString ( str ) ; if ( isPalindrome ( odd ) && isPalindrome ( even ) ) cout << " Yes " << endl ; else cout << " No " << endl ; } int main ( ) { string str = " abzzab " ; checkevenOddPalindrome ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: even, h, i, l, odd, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long count_strings ( long n ) { int x = 1 ; for ( int i = 1 ; i < n ; i ++ ) { x = ( 1 << x ) ; } return x - 1 ; } int main ( ) { long n = 3 ; cout << count_strings ( n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void decrypt ( string Str , int Start , int End ) { if ( Start > End ) { return ; } int mid = ( Start + End ) >> 1 ; cout << Str [ mid ] ; decrypt ( Str , mid + 1 , End ) ; decrypt ( Str , Start , mid - 1 ) ; } int main ( ) { int N = 4 ; string Str = " abcd " ; decrypt ( Str , 0 , N - 1 ) ; cout << " STRNEWLINE " ; N = 6 ; Str = " gyuitp " ; decrypt ( Str , 0 , N - 1 ) ; return 0 ; }

Index/key variables: mid
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isSuffix ( string s1 , string s2 ) { int n1 = s1 . length ( ) ; int n2 = s2 . length ( ) ; if ( n1 > n2 ) return false ; for ( int i = 0 ; i < n1 ; i ++ ) if ( s1 [ n1 - i - 1 ] != s2 [ n2 - i - 1 ] ) return false ; return true ; } bool CheckBinaryEquivalent ( int N , string str ) { int B_Number = 0 ; int cnt = 0 ; while ( N != 0 ) { int rem = N % 2 ; int c = pow ( 10 , cnt ) ; B_Number += rem * c ; N /= 2 ; cnt ++ ; } string bin = to_string ( B_Number ) ; return isSuffix ( str , bin ) ; } int main ( ) { int N = 23 ; string str = "111" ; if ( CheckBinaryEquivalent ( N , str ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: B_Number, N, cnt, i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; bool isvowel ( char ch ) { return ( ch == ' a ' or ch == ' e ' or ch == ' i ' or ch == ' o ' or ch == ' u ' ) ; } bool isvalid ( string & s ) { int n = s . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! isvowel ( s [ i ] ) ) return false ; } return true ; } int CountTotal ( string & s ) { int ans = 0 ; int n = s . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { string temp = " " ; for ( int j = i ; j < n ; j ++ ) { temp += s [ j ] ; if ( isvalid ( temp ) ) ans += 1 ; } } return ans ; } int main ( ) { string s = " aeoibsddaaeiouudb " ; cout << ( CountTotal ( s ) ) << endl ; return 0 ; }

Index/key variables: i, j
Accumulator variables: ans, i, j, temp
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isVowel ( char c ) { return ( c == ' a ' c == ' e ' c == ' i ' c == ' o ' c == ' u ' ) ; } bool isValid ( string & s ) { int n = s . size ( ) ; if ( n == 1 ) return ( isVowel ( s [ 0 ] ) ) ; if ( isVowel ( s [ 0 ] ) == false ) return false ; for ( int i = 1 ; i < n ; i ++ ) { if ( s [ i ] == s [ i - 1 ] || ! isVowel ( s [ i ] ) ) return false ; } return true ; } int findMaxLen ( string & s ) { int maxLen = 0 ; int n = s . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { string temp = " " ; for ( int j = i ; j < n ; j ++ ) { temp = temp + s [ j ] ; if ( isValid ( temp ) ) maxLen = max ( maxLen , ( j - i + 1 ) ) ; } } return maxLen ; } int main ( ) { string Str = " aeoibsddaeiouudb " ; cout << findMaxLen ( Str ) << endl ; 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 ; void depthFirst ( int v , vector < int > graph [ ] , vector < bool > & visited , vector < int > & storeChain ) { visited [ v ] = true ; storeChain . push_back ( v ) ; for ( auto i : graph [ v ] ) { if ( visited [ i ] == false ) { depthFirst ( i , graph , visited , storeChain ) ; } } } void createMap ( unordered_map < string , char > * um ) { ( * um ) [ "0000" ] = '0' ; ( * um ) [ "0001" ] = '1' ; ( * um ) [ "0010" ] = '2' ; ( * um ) [ "0011" ] = '3' ; ( * um ) [ "0100" ] = '4' ; ( * um ) [ "0101" ] = '5' ; ( * um ) [ "0110" ] = '6' ; ( * um ) [ "0111" ] = '7' ; ( * um ) [ "1000" ] = '8' ; ( * um ) [ "1001" ] = '9' ; ( * um ) [ "1010" ] = ' A ' ; ( * um ) [ "1011" ] = ' B ' ; ( * um ) [ "1100" ] = ' C ' ; ( * um ) [ "1101" ] = ' D ' ; ( * um ) [ "1110" ] = ' E ' ; ( * um ) [ "1111" ] = ' F ' ; } string hexaDecimal ( string bin ) { int l = bin . size ( ) ; int t = bin . find_first_of ( ' . ' ) ; int len_left = t != -1 ? t : l ; for ( int i = 1 ; i <= ( 4 - len_left % 4 ) % 4 ; i ++ ) bin = '0' + bin ; if ( t != -1 ) { int len_right = l - len_left - 1 ; for ( int i = 1 ; i <= ( 4 - len_right % 4 ) % 4 ; i ++ ) bin = bin + '0' ; } unordered_map < string , char > bin_hex_map ; createMap ( & bin_hex_map ) ; int i = 0 ; string hex = " " ; while ( 1 ) { hex += bin_hex_map [ bin . substr ( i , 4 ) ] ; i += 4 ; if ( i == bin . size ( ) ) break ; if ( bin . at ( i ) == ' . ' ) { hex += ' . ' ; i ++ ; } } return hex ; } void hexValue ( vector < int > graph [ ] , int vertices , vector < int > values ) { vector < bool > visited ( 10001 , false ) ; for ( int i = 1 ; i <= vertices ; i ++ ) { if ( visited [ i ] == false ) { int sizeChain ; vector < int > storeChain ; depthFirst ( i , graph , visited , storeChain ) ; sizeChain = storeChain . size ( ) ; int chainValues [ sizeChain + 1 ] ; for ( int i = 0 ; i < sizeChain ; i ++ ) { int temp = values [ storeChain [ i ] - 1 ] ; chainValues [ i ] = temp ; } cout << " Chain ▁ = ▁ " ; for ( int i = 0 ; i < sizeChain ; i ++ ) { cout << chainValues [ i ] << " ▁ " ; } cout << " TABSYMBOL " ; stringstream ss ; ss << chainValues [ 0 ] ; string s = ss . str ( ) ; for ( int i = 1 ; i < sizeChain ; i ++ ) { stringstream ss1 ; ss1 << chainValues [ i ] ; string s1 = ss1 . str ( ) ; s . append ( s1 ) ; } cout << " Hexadecimal ▁ " << " equivalent ▁ = ▁ " ; cout << hexaDecimal ( s ) << endl ; } } } int main ( ) { vector < int > graph [ 1001 ] ; int E , V ; E = 4 ; V = 7 ; vector < int > values ; values . push_back ( 0 ) ; values . push_back ( 1 ) ; values . push_back ( 1 ) ; values . push_back ( 1 ) ; values . push_back ( 0 ) ; values . push_back ( 1 ) ; values . push_back ( 1 ) ; graph [ 1 ] . push_back ( 2 ) ; graph [ 2 ] . push_back ( 1 ) ; graph [ 3 ] . push_back ( 4 ) ; graph [ 4 ] . push_back ( 3 ) ; graph [ 4 ] . push_back ( 5 ) ; graph [ 5 ] . push_back ( 4 ) ; graph [ 6 ] . push_back ( 5 ) ; graph [ 5 ] . push_back ( 6 ) ; graph [ 6 ] . push_back ( 7 ) ; graph [ 7 ] . push_back ( 6 ) ; hexValue ( graph , V , values ) ; return 0 ; }

Index/key variables: i, v
Accumulator variables: hex, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void BalancedNumber ( string s ) { int Leftsum = 0 ; int Rightsum = 0 ; for ( int i = 0 ; i < s . size ( ) / 2 ; i ++ ) { Leftsum += int ( s [ i ] - '0' ) ; Rightsum += int ( s [ s . size ( ) - 1 - i ] - '0' ) ; } if ( Leftsum == Rightsum ) cout << " Balanced " << endl ; else cout << " Not ▁ Balanced " << endl ; } int main ( ) { string s = "12321" ; BalancedNumber ( s ) ; return 0 ; }

Index/key variables: i
Accumulator variables: Leftsum, Rightsum, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const unsigned long long mod = 1e9 + 7 ; unsigned long long expo ( unsigned long long base , unsigned long long exponent ) { unsigned long long ans = 1 ; while ( exponent != 0 ) { if ( ( exponent & 1 ) == 1 ) { ans = ans * base ; ans = ans % mod ; } base = base * base ; base %= mod ; exponent >>= 1 ; } return ans % mod ; } unsigned long long findCount ( unsigned long long N ) { unsigned long long ans = ( expo ( 26 , N ) - expo ( 5 , N ) - expo ( 21 , N ) ) % mod ; ans += mod ; ans %= mod ; return ans ; } int main ( ) { unsigned long long N = 3 ; cout << findCount ( N ) ; return 0 ; }

Accumulator variables: ans, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define int  long long int
int decompose ( vector < int > S ) { stack < int > s ; int N = S . size ( ) ; int ans = 0 ; int nix = INT_MAX ; for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( s . empty ( ) ) { s . push ( S [ i ] ) ; nix = S [ i ] ; } else { if ( S [ i ] < s . top ( ) ) { s . push ( S [ i ] ) ; nix = min ( nix , S [ i ] ) ; } else { int val = S [ i ] ; while ( ! s . empty ( ) && val >= s . top ( ) ) { s . pop ( ) ; } nix = min ( nix , S [ i ] ) ; s . push ( nix ) ; } } ans += s . size ( ) ; } return ans ; } signed main ( ) { vector < int > S = { 9 , 6 , 9 , 35 } ; cout << decompose ( S ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxSetBitCount ( string s , int k ) { int maxCount = 0 , n = s . length ( ) ; int count = 0 ; for ( int i = 0 ; i < k ; i ++ ) { if ( s [ i ] == '1' ) count ++ ; } maxCount = count ; for ( int i = k ; i < n ; i ++ ) { if ( s [ i - k ] == '1' ) count -- ; if ( s [ i ] == '1' ) count ++ ; maxCount = max ( maxCount , count ) ; } return maxCount ; } int main ( ) { string s = "100111010" ; int k = 3 ; cout << ( maxSetBitCount ( s , k ) ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minDel ( string s1 , string s2 ) { int i = s1 . length ( ) ; int j = s2 . length ( ) ; while ( i > 0 && j > 0 ) { if ( s1 [ i - 1 ] != s2 [ j - 1 ] ) { break ; } i -- ; j -- ; } return i + j ; } int main ( ) { string s1 = " geeksforgeeks " , s2 = " peeks " ; cout << minDel ( s1 , s2 ) << endl ; }

Accumulator variables: i, j, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minDel ( string s1 , string s2 ) { int i = 0 ; while ( i < min ( s1 . length ( ) , s2 . length ( ) ) ) { if ( s1 [ i ] != s2 [ i ] ) { break ; } i ++ ; } int ans = ( s1 . length ( ) - i ) + ( s2 . length ( ) - i ) ; return ans ; } int main ( ) { string s1 = " geeks " , s2 = " geeksfor " ; cout << minDel ( s1 , s2 ) << endl ; }

Index/key variables: i
Accumulator variables: i, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void CountValidTriplet ( string s , int n ) { int count_a = 0 , count_b = 0 , count_c = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == ' a ' ) count_a ++ ; if ( s [ i ] == ' b ' ) count_b ++ ; if ( s [ i ] == ' c ' ) count_c ++ ; } int Total_triplet = count_a * count_b * count_c ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( ( 2 * j - i ) < n && s [ j ] != s [ i ] && s [ j * 2 - i ] != s [ j ] && s [ 2 * j - i ] != s [ i ] ) Total_triplet -- ; } } cout << Total_triplet ; } int main ( ) { string s = " abcbcabc " ; int n = s . length ( ) ; CountValidTriplet ( s , n ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: Total_triplet, count_a, count_b, count_c, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isBalanced ( string exp ) { bool flag = true ; int count = 0 ; for ( int i = 0 ; i < exp . length ( ) ; i ++ ) { if ( exp [ i ] == ' ( ' ) { count ++ ; } else { count -- ; } if ( count < 0 ) { flag = false ; break ; } } if ( count != 0 ) { flag = false ; } return flag ; } int main ( ) { string exp1 = " ( ( ( ) ) ) ( ) ( ) " ; if ( isBalanced ( exp1 ) ) cout << " Balanced ▁ STRNEWLINE " ; else cout << " Not ▁ Balanced ▁ STRNEWLINE " ; string exp2 = " ( ) ) ( ( ( ) ) " ; if ( isBalanced ( exp2 ) ) cout << " Balanced ▁ STRNEWLINE " ; else cout << " Not ▁ Balanced ▁ STRNEWLINE " ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; void longestPalindrome ( string s ) { int n = s . length ( ) ; vector < vector < int > > pref ( 26 , vector < int > ( n , 0 ) ) ; vector < vector < int > > pos ( 26 ) ; pref [ s [ 0 ] - ' a ' ] [ 0 ] ++ ; pos [ s [ 0 ] - ' a ' ] . push_back ( 0 ) ; for ( int i = 1 ; i < n ; i ++ ) { for ( int j = 0 ; j < 26 ; j ++ ) pref [ j ] [ i ] += pref [ j ] [ i - 1 ] ; int index = s [ i ] - ' a ' ; pref [ index ] [ i ] ++ ; pos [ index ] . push_back ( i ) ; } int ans = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { int size = pos [ i ] . size ( ) ; ans = max ( ans , size ) ; for ( int j = 0 ; j < size / 2 ; j ++ ) { int l = pos [ i ] [ j ] ; int r = pos [ i ] [ size - j - 1 ] - 1 ; for ( int k = 0 ; k < 26 ; k ++ ) { int sum = pref [ k ] [ r ] - pref [ k ] [ l ] ; ans = max ( ans , 2 * ( j + 1 ) + sum ) ; } } } cout << ans << " STRNEWLINE " ; } int main ( ) { string S = " bbccdcbb " ; longestPalindrome ( S ) ; return 0 ; }

Index/key variables: i, index, j, k, l, r
Accumulator variables: i, j, k, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool checkWord ( vector < vector < char > > & board , string & word , int index , int row , int col ) { if ( row < 0 || col < 0 || row >= board . size ( ) || col >= board [ 0 ] . size ( ) ) return false ; if ( board [ row ] [ col ] != word [ index ] ) return false ; else if ( index == word . size ( ) - 1 ) return true ; char temp = board [ row ] [ col ] ; board [ row ] [ col ] = ' * ' ; if ( checkWord ( board , word , index + 1 , row + 1 , col ) || checkWord ( board , word , index + 1 , row - 1 , col ) || checkWord ( board , word , index + 1 , row , col + 1 ) || checkWord ( board , word , index + 1 , row , col - 1 ) ) { board [ row ] [ col ] = temp ; return true ; } board [ row ] [ col ] = temp ; return false ; } int main ( ) { vector < vector < char > > board = { { ' A ' , ' B ' , ' C ' , ' E ' } , { ' S ' , ' F ' , ' C ' , ' S ' } , { ' A ' , ' D ' , ' E ' , ' E ' } } ; string word = " CFDASABCESEE " ; for ( int i = 0 ; i < board . size ( ) ; i ++ ) { for ( int j = 0 ; j < board [ 0 ] . size ( ) ; j ++ ) { if ( board [ i ] [ j ] == word [ 0 ] && checkWord ( board , word , 0 , i , j ) ) { cout << " True " << ' ' ; return 0 ; } } } cout << " False " << ' ' ; return 0 ; }

Index/key variables: col, i, index, j, row
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int count ( string N , int X , string subStr , int index , int n ) { if ( index == n ) return 0 ; string a = subStr + N [ index ] ; int b = 0 ; if ( stoll ( a ) % X == 0 ) b = 1 ; int m1 = count ( N , X , a , index + 1 , n ) ; int m2 = b + count ( N , X , " " , index + 1 , n ) ; return max ( m1 , m2 ) ; } int main ( ) { string N = "00001242" ; int K = 3 ; int l = N . length ( ) ; cout << count ( N , K , " " , 0 , l ) << endl ; return 0 ; }

Index/key variables: index
Accumulator variables: stdc
C++ program:
#include " bits / stdc + + . h "
using namespace std ; bool checkSuffix ( int A , int B ) { string s1 = to_string ( A ) ; string s2 = to_string ( B ) ; int n1 = s1 . length ( ) ; int n2 = s2 . length ( ) ; if ( n1 < n2 ) { return false ; } for ( int i = 0 ; i < n2 ; i ++ ) { if ( s1 [ n1 - i - 1 ] != s2 [ n2 - i - 1 ] ) { return false ; } } return true ; } int main ( ) { int A = 12345 , B = 45 ; bool result = checkSuffix ( A , B ) ; if ( result ) { cout << " Yes " ; } else { cout << " No " ; } return 0 ; }

Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#include <boost/algorithm/string.hpp>
using namespace std ; void checkSuffix ( int A , int B ) { string s1 = to_string ( A ) ; string s2 = to_string ( B ) ; bool result ; result = boost :: algorithm :: ends_with ( s1 , s2 ) ; if ( result ) { cout << " Yes " ; } else { cout << " No " ; } } int main ( ) { int A = 12345 , B = 45 ; checkSuffix ( A , B ) ; return 0 ; }

Accumulator variables: stdc