dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; void multiply ( int F [ 2 ] [ 2 ] , int M [ 2 ] [ 2 ] ) { int x = F [ 0 ] [ 0 ] * M [ 0 ] [ 0 ] + F [ 0 ] [ 1 ] * M [ 1 ] [ 0 ] ; int y = F [ 0 ] [ 0 ] * M [ 0 ] [ 1 ] + F [ 0 ] [ 1 ] * M [ 1 ] [ 1 ] ; int z = F [ 1 ] [ 0 ] * M [ 0 ] [ 0 ] + F [ 1 ] [ 1 ] * M [ 1 ] [ 0 ] ; int w = F [ 1 ] [ 0 ] * M [ 0 ] [ 1 ] + F [ 1 ] [ 1 ] * M [ 1 ] [ 1 ] ; F [ 0 ] [ 0 ] = x ; F [ 0 ] [ 1 ] = y ; F [ 1 ] [ 0 ] = z ; F [ 1 ] [ 1 ] = w ; } void power ( int F [ 2 ] [ 2 ] , int n ) { if ( n == 0 n == 1 ) return ; int M [ 2 ] [ 2 ] = { { 1 , 1 } , { 1 , 0 } } ; power ( F , n / 2 ) ; multiply ( F , F ) ; if ( n % 2 != 0 ) multiply ( F , M ) ; } int countWays ( int n ) { int F [ 2 ] [ 2 ] = { { 1 , 1 } , { 1 , 0 } } ; if ( n == 0 ) return 0 ; power ( F , n ) ; return F [ 0 ] [ 0 ] ; } int main ( ) { int n = 5 ; cout << countWays ( n ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int multiply ( int n , int m ) { int ans = 0 , count = 0 ; while ( m ) { if ( m % 2 == 1 ) ans += n << count ; count ++ ; m /= 2 ; } return ans ; } int main ( ) { int n = 20 , m = 13 ; cout << multiply ( n , m ) ; return 0 ; }

Accumulator variables: ans, count, m, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool EqualNumber ( int A , int B ) { return ( A ^ B ) ; } int main ( ) { int A = 5 , B = 6 ; cout << ! EqualNumber ( A , B ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool findContinuous1 ( int n ) { const int bits = 8 * sizeof ( int ) ; string bp = bitset < bits > ( n ) . to_string ( ) ; int prev_count = 0 , curr_count = 0 ; int i = 0 ; while ( i < bits ) { if ( bp [ i ] == '1' ) { curr_count ++ ; i ++ ; } else if ( bp [ i - 1 ] == '0' ) { i ++ ; curr_count = 0 ; continue ; } else { if ( curr_count < prev_count ) return 0 ; i ++ ; prev_count = curr_count ; curr_count = 0 ; } } if ( prev_count > curr_count && ( curr_count != 0 ) ) return 0 ; return 1 ; } int main ( ) { int n = 179 ; if ( findContinuous1 ( n ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: i
Accumulator variables: curr_count, i, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool areSetBitsIncreasing ( int n ) { int prev_count = INT_MAX ; while ( n > 0 ) { while ( n > 0 && n % 2 == 0 ) n = n / 2 ; int curr_count = 1 ; while ( n > 0 && n % 2 == 1 ) { n = n / 2 ; curr_count ++ ; } if ( curr_count >= prev_count ) return false ; prev_count = curr_count ; } return true ; } int main ( ) { int n = 10 ; if ( areSetBitsIncreasing ( n ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: curr_count, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool findPattern ( int n ) { int prev = n % 2 ; n = n / 2 ; while ( n > 0 ) { int curr = n % 2 ; if ( curr == prev ) return false ; prev = curr ; n = n / 2 ; } return true ; } int main ( ) { int n = 10 ; if ( findPattern ( n ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; int countXOR ( int n ) { int count0 = 0 , count1 = 0 ; while ( n ) { ( n % 2 == 0 ) ? count0 ++ : count1 ++ ; n /= 2 ; } return ( count0 ^ count1 ) ; } int main ( ) { int n = 31 ; cout << countXOR ( n ) ; return 0 ; }

Accumulator variables: count0, count1, n
C++ program:
#include <bits/stdc++.h>
using namespace std ; int xorPairCount ( int arr [ ] , int n , int x ) { unordered_map < int , int > m ; for ( int i = 0 ; i < n ; i ++ ) { int curr_xor = x ^ arr [ i ] ; if ( m . find ( curr_xor ) != m . end ( ) ) result += m [ curr_xor ] ; m [ arr [ i ] ] ++ ; } return result ; } int main ( ) { int arr [ ] = { 2 , 5 , 2 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int x = 0 ; cout << " Count ▁ of ▁ pairs ▁ with ▁ given ▁ XOR ▁ = ▁ " << xorPairCount ( arr , n , x ) ; return 0 ; }

Index/key variables: curr_xor, i
Accumulator variables: i, result, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; typedef long long int ll ; int msbPos ( ll n ) { int msb_p = -1 ; while ( n ) { n = n >> 1 ; msb_p ++ ; } return msb_p ; } ll andOperator ( ll x , ll y ) { while ( x && y ) { int msb_p1 = msbPos ( x ) ; int msb_p2 = msbPos ( y ) ; if ( msb_p1 != msb_p2 ) break ; ll msb_val = ( 1 << msb_p1 ) ; res = res + msb_val ; x = x - msb_val ; y = y - msb_val ; } return res ; } int main ( ) { ll x = 10 , y = 15 ; cout << andOperator ( x , y ) ; return 0 ; }

Accumulator variables: msb_p, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int multiplyTen ( int n ) { return ( n << 1 ) + ( n << 3 ) ; } int main ( ) { int n = 50 ; cout << multiplyTen ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; int countValues ( int n ) { int countV = 0 ; for ( int i = 0 ; i <= n ; i ++ ) if ( ( n + i ) == ( n ^ i ) ) countV ++ ; return countV ; } int main ( ) { int n = 12 ; cout << countValues ( n ) ; return 0 ; }

Accumulator variables: countV, i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countValues ( int n ) { int unset_bits = 0 ; while ( n ) { if ( ( n & 1 ) == 0 ) unset_bits ++ ; n = n >> 1 ; } return 1 << unset_bits ; } int main ( ) { int n = 12 ; cout << countValues ( n ) ; return 0 ; }

Accumulator variables: stdc, unset_bits
C++ program:
#include <bits/stdc++.h>
using namespace std ; char findProffesion ( int level , int pos ) { if ( level == 1 ) return ' e ' ; if ( findProffesion ( level - 1 , ( pos + 1 ) / 2 ) == ' d ' ) return ( pos % 2 ) ? ' d ' : ' e ' ; return ( pos % 2 ) ? ' e ' : ' d ' ; } int main ( void ) { int level = 4 , pos = 2 ; ( findProffesion ( level , pos ) == ' e ' ) ? cout << " Engineer " : cout << " Doctor " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; void printTwoSetBitNums ( int n ) { int x = 1 ; while ( n > 0 ) { int y = 0 ; while ( y < x ) { cout << ( 1 << x ) + ( 1 << y ) << " ▁ " ; n -- ; if ( n == 0 ) return ; y ++ ; } x ++ ; } } int main ( ) { printTwoSetBitNums ( 4 ) ; return 0 ; }

Accumulator variables: n, x, y
C++ program:
#include <iostream>
using namespace std ; int rand50 ( ) { return rand ( ) & 1 ; } bool rand75 ( ) { return rand50 ( ) | rand50 ( ) ; } int main ( ) { srand ( time ( NULL ) ) ; for ( int i = 0 ; i < 50 ; i ++ ) cout << rand75 ( ) ; return 0 ; }

Accumulator variables: i
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void printRepeatingEven ( int arr [ ] , int n ) { long long _xor = 0L ; long long pos ; for ( int i = 0 ; i < n ; ++ i ) { pos = 1 << arr [ i ] ; _xor ^= pos ; } for ( int i = 0 ; i < n ; ++ i ) { pos = 1 << arr [ i ] ; if ( ! ( pos & _xor ) ) { cout << arr [ i ] << " ▁ " ; _xor ^= pos ; } } } int main ( ) { int arr [ ] = { 9 , 12 , 23 , 10 , 12 , 12 , 15 , 23 , 14 , 12 , 15 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; printRepeatingEven ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: _xor
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string xor1 ( string a , string b ) { string result = " " ; int n = b . length ( ) ; for ( int i = 1 ; i < n ; i ++ ) { if ( a [ i ] == b [ i ] ) result += "0" ; else result += "1" ; } return result ; } string mod2div ( string divident , string divisor ) { int pick = divisor . length ( ) ; string tmp = divident . substr ( 0 , pick ) ; int n = divident . length ( ) ; while ( pick < n ) { if ( tmp [ 0 ] == '1' ) tmp = xor1 ( divisor , tmp ) + divident [ pick ] ; else tmp = xor1 ( std :: string ( pick , '0' ) , tmp ) + divident [ pick ] ; pick += 1 ; } if ( tmp [ 0 ] == '1' ) tmp = xor1 ( divisor , tmp ) ; else tmp = xor1 ( std :: string ( pick , '0' ) , tmp ) ; return tmp ; } void encodeData ( string data , string key ) { int l_key = key . length ( ) ; string appended_data = ( data + std :: string ( l_key - 1 , '0' ) ) ; string remainder = mod2div ( appended_data , key ) ; string codeword = data + remainder ; cout << " Remainder ▁ : ▁ " << remainder << " STRNEWLINE " ; cout << " Encoded ▁ Data ▁ ( Data ▁ + ▁ Remainder ) ▁ : " << codeword << " STRNEWLINE " ; } int main ( ) { string data = "100100" ; string key = "1101" ; encodeData ( data , key ) ; return 0 ; }

Index/key variables: i, pick
Accumulator variables: i, pick, result, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSetBits ( int x ) { unsigned int count = 0 ; while ( x ) { x &= ( x - 1 ) ; count ++ ; } return count ; } bool isBleak ( int n ) { for ( int x = 1 ; x < n ; x ++ ) if ( x + countSetBits ( x ) == n ) return false ; return true ; } int main ( ) { isBleak ( 3 ) ? cout << " Yes STRNEWLINE " : cout << " No STRNEWLINE " ; isBleak ( 4 ) ? cout << " Yes STRNEWLINE " : cout << " No STRNEWLINE " ; return 0 ; }

Accumulator variables: count, stdc, x
Iterator variables: x
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define INT_BITS  32
int maxSubarrayXOR ( int set [ ] , int n ) { int index = 0 ; for ( int i = INT_BITS - 1 ; i >= 0 ; i -- ) { int maxInd = index ; int maxEle = INT_MIN ; for ( int j = index ; j < n ; j ++ ) { if ( ( set [ j ] & ( 1 << i ) ) != 0 && set [ j ] > maxEle ) maxEle = set [ j ] , maxInd = j ; } if ( maxEle == INT_MIN ) continue ; swap ( set [ index ] , set [ maxInd ] ) ; maxInd = index ; for ( int j = 0 ; j < n ; j ++ ) { if ( j != maxInd && ( set [ j ] & ( 1 << i ) ) != 0 ) set [ j ] = set [ j ] ^ set [ maxInd ] ; } index ++ ; } int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) res ^= set [ i ] ; return res ; } int main ( ) { int set [ ] = { 9 , 8 , 5 } ; int n = sizeof ( set ) / sizeof ( set [ 0 ] ) ; cout << " Max ▁ subset ▁ XOR ▁ is ▁ " ; cout << maxSubarrayXOR ( set , n ) ; return 0 ; }

Index/key variables: i, index, j, maxInd
Accumulator variables: i, index, j, res, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findXOR ( int Set [ ] , int n ) { if ( n == 1 ) return Set [ 0 ] ; else return 0 ; } int main ( ) { int Set [ ] = { 1 , 2 , 3 } ; int n = sizeof ( Set ) / sizeof ( Set [ 0 ] ) ; cout << " XOR ▁ of ▁ XOR ' s ▁ of ▁ all ▁ subsets ▁ is ▁ " << findXOR ( Set , n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; int myXOR ( int x , int y ) { for ( int i = 31 ; i >= 0 ; i -- ) { bool b1 = x & ( 1 << i ) ; bool b2 = y & ( 1 << i ) ; bool xoredBit = ( b1 & b2 ) ? 0 : ( b1 b2 ) ; res <<= 1 ; res |= xoredBit ; } return res ; } int main ( ) { int x = 3 , y = 5 ; cout << " XOR ▁ is ▁ " << myXOR ( x , y ) ; return 0 ; }

Accumulator variables: i, res
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int swapBits ( unsigned int n , unsigned int p1 , unsigned int p2 ) { unsigned int bit1 = ( n >> p1 ) & 1 ; unsigned int bit2 = ( n >> p2 ) & 1 ; unsigned int x = ( bit1 ^ bit2 ) ; x = ( x << p1 ) | ( x << p2 ) ; unsigned int result = n ^ x ; } int main ( ) { int res = swapBits ( 28 , 0 , 3 ) ; cout << " Result ▁ = ▁ " << res << " ▁ " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; int findOdd ( int arr [ ] , int n ) { int res = 0 , i ; for ( i = 0 ; i < n ; i ++ ) res ^= arr [ i ] ; return res ; } int main ( void ) { int arr [ ] = { 12 , 12 , 14 , 90 , 14 , 14 , 14 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << " The ▁ odd ▁ occurring ▁ element ▁ is ▁ " << findOdd ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, res
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  2
int freivald ( int a [ ] [ N ] , int b [ ] [ N ] , int c [ ] [ N ] ) { bool r [ N ] ; for ( int i = 0 ; i < N ; i ++ ) r [ i ] = random ( ) % 2 ; int br [ N ] = { 0 } ; for ( int i = 0 ; i < N ; i ++ ) for ( int j = 0 ; j < N ; j ++ ) br [ i ] = br [ i ] + b [ i ] [ j ] * r [ j ] ; int cr [ N ] = { 0 } ; for ( int i = 0 ; i < N ; i ++ ) for ( int j = 0 ; j < N ; j ++ ) cr [ i ] = cr [ i ] + c [ i ] [ j ] * r [ j ] ; int axbr [ N ] = { 0 } ; for ( int i = 0 ; i < N ; i ++ ) for ( int j = 0 ; j < N ; j ++ ) axbr [ i ] = axbr [ i ] + a [ i ] [ j ] * br [ j ] ; for ( int i = 0 ; i < N ; i ++ ) if ( axbr [ i ] - cr [ i ] != 0 ) false ; return true ; } bool isProduct ( int a [ ] [ N ] , int b [ ] [ N ] , int c [ ] [ N ] , int k ) { for ( int i = 0 ; i < k ; i ++ ) if ( freivald ( a , b , c ) == false ) return false ; return true ; } int main ( ) { int a [ N ] [ N ] = { { 1 , 1 } , { 1 , 1 } } ; int b [ N ] [ N ] = { { 1 , 1 } , { 1 , 1 } } ; int c [ N ] [ N ] = { { 2 , 2 } , { 2 , 2 } } ; int k = 2 ; if ( isProduct ( a , b , c , k ) ) printf ( " Yes " ) ; else printf ( " No " ) ; return 0 ; }

Index/key variables: N, i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; float calc_Expectation ( float a [ ] , float n ) { float prb = ( 1 / n ) ; float sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += a [ i ] * prb ; return sum ; } int main ( ) { float expect , n = 6.0 ; float a [ 6 ] = { 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 } ; expect = calc_Expectation ( a , n ) ; cout << " Expectation ▁ of ▁ array ▁ E ( X ) ▁ is ▁ : ▁ " << expect << " STRNEWLINE " ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool checkCaptcha ( string & captcha , string & user_captcha ) { return captcha . compare ( user_captcha ) == 0 ; } string generateCaptcha ( int n ) { time_t t ; srand ( ( unsigned ) time ( & t ) ) ; char * chrs = " abcdefghijklmnopqrstuvwxyzABCDEFGHI " " JKLMNOPQRSTUVWXYZ0123456789" ; string captcha = " " ; while ( n -- ) captcha . push_back ( chrs [ rand ( ) % 62 ] ) ; return captcha ; } int main ( ) { string captcha = generateCaptcha ( 9 ) ; cout << captcha ; string usr_captcha ; cout << " Enter above CAPTCHA : " ; cin >> usr_captcha ; if ( checkCaptcha ( captcha , usr_captcha ) ) printf ( " CAPTCHA Matched " else printf ( " CAPTCHA Not Matched " return 0 ; }

Accumulator variables: n, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int LongestSubarray ( int a [ ] , int n , int k ) { int pre [ n ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] > k ) pre [ i ] = 1 ; else pre [ i ] = -1 ; } for ( int i = 1 ; i < n ; i ++ ) pre [ i ] = pre [ i - 1 ] + pre [ i ] ; int len = 0 ; int lo = 1 , hi = n ; while ( lo <= hi ) { int mid = ( lo + hi ) / 2 ; bool ok = false ; for ( int i = mid - 1 ; i < n ; i ++ ) { int x = pre [ i ] ; if ( i - mid >= 0 ) x -= pre [ i - mid ] ; if ( x > 0 ) { ok = true ; break ; } } if ( ok == true ) { len = mid ; lo = mid + 1 ; } else hi = mid - 1 ; } return len ; } int main ( ) { int a [ ] = { 2 , 3 , 4 , 5 , 3 , 7 } ; int k = 3 ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << LongestSubarray ( a , n , k ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, stdc, x
Iterator variables: i
Boolean variables: ok
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findPoints ( int l1 , int r1 , int l2 , int r2 ) { int x = ( l1 != l2 ) ? min ( l1 , l2 ) : -1 ; int y = ( r1 != r2 ) ? max ( r1 , r2 ) : -1 ; cout << x << " ▁ " << y ; } int main ( ) { int l1 = 5 , r1 = 10 , l2 = 1 , r2 = 7 ; findPoints ( l1 , r1 , l2 , r2 ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int binarySeach ( vector < int > P , int N ) { int i = 0 ; int j = P . size ( ) - 1 ; int index = -1 ; while ( i <= j ) { int mid = i + ( j - i ) / 2 ; if ( P [ mid ] >= N ) { index = mid ; j = mid - 1 ; } else { i = mid + 1 ; } } return index ; } void minDays ( vector < int > P , vector < int > arr ) { for ( int i = 1 ; i < P . size ( ) ; i ++ ) { P [ i ] += P [ i ] + P [ i - 1 ] ; } for ( int i = 0 ; i < arr . size ( ) ; i ++ ) { int index = binarySeach ( P , arr [ i ] ) ; if ( index != -1 ) { cout << index + 1 << " ▁ " ; } else { cout << -1 << " ▁ " ; } } } int main ( ) { vector < int > arr = { 400 , 200 , 700 , 900 , 1400 } ; vector < int > P = { 100 , 300 , 400 , 500 , 600 } ; minDays ( P , arr ) ; return 0 ; }

Index/key variables: i, mid
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
#include <climits>
#include <algorithm>
using namespace std ; int maximumProfit ( int arr [ ] , int N ) { int ans = INT_MIN ; int price = 0 ; sort ( arr , arr + N ) ; for ( int i = 0 ; i < N ; i ++ ) { int count = ( N - i ) ; if ( ans < count * arr [ i ] ) { price = arr [ i ] ; ans = count * arr [ i ] ; } } return price ; } int main ( ) { int arr [ ] = { 22 , 87 , 9 , 50 , 56 , 43 } ; cout << maximumProfit ( arr , 6 ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPalindrome ( string S , int i , int j ) { while ( i < j ) { if ( S [ i ] != S [ j ] ) return false ; i ++ ; j -- ; } return true ; } void printLongestPalindrome ( string S , int N ) { int palLength [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { int maxlength = 1 ; for ( int j = 0 ; j < i ; j ++ ) { if ( S [ j ] == S [ i ] ) { if ( isPalindrome ( S , j , i ) ) { maxlength = i - j + 1 ; break ; } } } for ( int j = N - 1 ; j > i ; j -- ) { if ( S [ j ] == S [ i ] ) { if ( isPalindrome ( S , i , j ) ) { maxlength = max ( j - i + 1 , maxlength ) ; break ; } } } palLength [ i ] = maxlength ; } for ( int i = 0 ; i < N ; i ++ ) { cout << palLength [ i ] << " ▁ " ; } } int main ( ) { string S = " bababa " ; int N = S . length ( ) ; printLongestPalindrome ( S , N ) ; return 0 ; }

Index/key variables: N, i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void mulsum ( int arr [ ] , int n , int N ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % N == 0 ) { sum = sum + arr [ i ] ; } } cout << sum ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 5 , 6 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int N = 3 ; mulsum ( arr , n , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; char nextAvailableChar ( vector < int > charset , int start ) { for ( int i = start - 1 ; i >= 0 ; i -- ) { if ( charset [ i ] > 0 ) { charset [ i ] -- ; return char ( i + ' a ' ) ; } } return ' \0' ; } string newString ( string originalLabel , int limit ) { int n = originalLabel . length ( ) ; vector < int > charset ( 26 , 0 ) ; string newStrings = " " ; for ( char i : originalLabel ) charset [ i - ' a ' ] ++ ; for ( int i = 25 ; i >= 0 ; i -- ) { int count = 0 ; while ( charset [ i ] > 0 ) { newStrings += char ( i + ' a ' ) ; charset [ i ] -- ; count ++ ; if ( charset [ i ] > 0 && count == limit ) { char next = nextAvailableChar ( charset , i ) ; if ( next == ' \0' ) return newStrings ; newStrings += next ; count = 0 ; } } } return newStrings ; } int main ( ) { string S = " ccbbb " ; int K = 2 ; cout << ( newString ( S , K ) ) ; }

Index/key variables: i
Accumulator variables: count, i, newStrings, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  3
#define M  4
void swapEvenOdd ( int arr [ ] , int n ) { int o = -1 , e = -1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < 0 ) continue ; int r = -1 ; if ( arr [ i ] % 2 == 0 ) { o ++ ; while ( arr [ o ] % 2 == 0 arr [ o ] < 0 ) o ++ ; r = o ; } else { e ++ ; while ( arr [ e ] % 2 == 1 arr [ e ] < 0 ) e ++ ; r = e ; } arr [ i ] *= -1 ; arr [ r ] *= -1 ; int tmp = arr [ i ] ; arr [ i ] = arr [ r ] ; arr [ r ] = tmp ; } for ( int i = 0 ; i < n ; i ++ ) { cout << ( -1 * arr [ i ] ) << " ▁ " ; } } int main ( ) { int arr [ ] = { 1 , 3 , 2 , 4 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; swapEvenOdd ( arr , n ) ; }

Index/key variables: e, i, o, r
Accumulator variables: e, i, o, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string rev ( string str ) { int st = 0 ; int ed = str . length ( ) - 1 ; string s = str ; while ( st < ed ) { swap ( s [ st ] , s [ ed ] ) ; st ++ ; ed -- ; } return s ; } bool check ( string a , string b , int n ) { int i = 0 ; int j = n - 1 ; while ( i < n ) { if ( a [ i ] != b [ j ] ) break ; i += 1 ; j -= 1 ; string xa = a . substr ( i , j + 1 - i ) ; string xb = b . substr ( i , j + 1 - i ) ; if ( ( xa == rev ( xa ) ) or ( xb == rev ( xb ) ) ) return true ; } return false ; } int main ( ) { string a = " xbdef " ; string b = " cabex " ; if ( check ( a , b , a . length ( ) ) == true or check ( b , a , a . length ( ) ) == true ) cout << " True " ; else cout << " False " ; }

Index/key variables: ed, i, j, st
Accumulator variables: ed, i, j, st, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool check ( vector < int > pSum , int len , int k , vector < int > a ) { int i = 0 ; int j = len ; while ( j <= a . size ( ) ) { int maxSize = a [ j - 1 ] ; int totalNumbers = maxSize * len ; int currNumbers = pSum [ j ] - pSum [ i ] ; if ( currNumbers + k >= totalNumbers ) { return true ; } else { i ++ ; j ++ ; } } return false ; } int maxEqualIdx ( vector < int > arr , int k ) { sort ( arr . begin ( ) , arr . end ( ) ) ; vector < int > prefixSum ( arr . size ( ) ) ; prefixSum [ 1 ] = arr [ 0 ] ; for ( int i = 1 ; i < prefixSum . size ( ) - 1 ; ++ i ) { prefixSum [ i + 1 ] = prefixSum [ i ] + arr [ i ] ; } int max = arr . size ( ) ; int min = 1 ; int ans = 1 ; while ( min <= max ) { int mid = ( max + min ) / 2 ; if ( check ( prefixSum , mid , k , arr ) ) { ans = mid ; min = mid + 1 ; } else { max = mid - 1 ; } } return ans ; } int main ( ) { vector < int > arr = { 1 , 1 , 1 } ; int k = 7 ; cout << ( maxEqualIdx ( arr , k ) ) ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int productSum ( int arr [ ] , int N ) { int cntOne = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == 1 ) cntOne ++ ; } return cntOne * ( cntOne - 1 ) / 2 ; } int main ( ) { int arr [ ] = { 0 , 1 , 1 , 0 , 1 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << productSum ( arr , n ) << endl ; }

Index/key variables: i
Accumulator variables: cntOne, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minDigits ( int N , int K ) { int digits_num = floor ( log10 ( N ) + 1 ) ; int temp_sum = 0 ; int temp = digits_num ; int result ; int X , var ; int sum = 0 ; int num2 = N ; while ( num2 != 0 ) { sum += num2 % 10 ; num2 /= 10 ; } if ( sum <= K ) { X = 0 ; } else { while ( temp > 0 ) { var = ( N / ( pow ( 10 , temp - 1 ) ) ) ; temp_sum += var % 10 ; if ( temp_sum >= K ) { var /= 10 ; var ++ ; result = var * pow ( 10 , temp ) ; break ; } temp -- ; } X = result - N ; return X ; } } int main ( ) { int N = 11 , K = 1 ; cout << minDigits ( N , K ) ; return 0 ; }

Accumulator variables: num2, stdc, sum, temp, temp_sum, var
C++ program:
#include <bits/stdc++.h>
using namespace std ; int dfs ( vector < vector < int > > memo , int nums [ ] , int S , int curr_sum , int index , int sum , int N ) { if ( index == N ) { if ( S == curr_sum ) return 1 ; else return 0 ; } if ( memo [ index ] [ curr_sum + sum ] != INT_MIN ) { return memo [ index ] [ curr_sum + sum ] ; } int ans = dfs ( memo , nums , index + 1 , curr_sum + nums [ index ] , S , sum , N ) + dfs ( memo , nums , index + 1 , curr_sum - nums [ index ] , S , sum , N ) ; memo [ index ] [ curr_sum + sum ] = ans ; return ans ; } int findWays ( int nums [ ] , int S , int N ) { int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) sum += nums [ i ] ; vector < vector < int > > memo ( N + 1 , vector < int > ( 2 * sum + 1 , INT_MIN ) ) ; return dfs ( memo , nums , S , 0 , 0 , sum , N ) ; } int main ( ) { int S = 3 ; int arr [ ] = { 1 , 2 , 3 , 4 , 5 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int answer = findWays ( arr , S , N ) ; cout << answer << endl ; return 0 ; }

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