dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
#define row  6
#define col  8
using namespace std ; int cal ( int hist [ ] , int n ) { stack < int > s ; int max_area = 0 ; int tp ; int area_with_top ; int i = 0 ; while ( i < n ) { if ( s . empty ( ) || hist [ s . top ( ) ] <= hist [ i ] ) s . push ( i ++ ) ; else { tp = s . top ( ) ; s . pop ( ) ; area_with_top = hist [ tp ] * ( s . empty ( ) ? i : i - s . top ( ) - 1 ) ; if ( max_area < area_with_top ) max_area = area_with_top ; } } while ( s . empty ( ) == false ) { tp = s . top ( ) ; s . pop ( ) ; area_with_top = hist [ tp ] * ( s . empty ( ) ? i : i - s . top ( ) - 1 ) ; if ( max_area < area_with_top ) max_area = area_with_top ; } return max_area ; } int largestMatrix ( int a [ ] [ col ] ) { int dp [ row ] [ col ] ; for ( int i = 0 ; i < col ; i ++ ) { int cnt = 0 ; for ( int j = row - 1 ; j >= 0 ; j -- ) { dp [ j ] [ i ] = 0 ; if ( a [ j ] [ i ] == 1 ) { cnt ++ ; dp [ j ] [ i ] = cnt ; } else { cnt = 0 ; } } } int ans = -1 ; for ( int i = 0 ; i < row ; i ++ ) { int hist [ col ] ; for ( int j = 0 ; j < col ; j ++ ) { hist [ j ] = dp [ i ] [ j ] ; } ans = max ( ans , cal ( hist , col ) ) ; } for ( int i = 0 ; i < col ; i ++ ) { int cnt = 0 ; for ( int j = row - 1 ; j >= 0 ; j -- ) { dp [ j ] [ i ] = 0 ; if ( a [ j ] [ i ] == 0 ) { cnt ++ ; dp [ j ] [ i ] = cnt ; } else { cnt = 0 ; } } } for ( int i = 0 ; i < row ; i ++ ) { int hist [ col ] ; for ( int j = 0 ; j < col ; j ++ ) { hist [ j ] = dp [ i ] [ j ] ; } ans = max ( ans , cal ( hist , col ) ) ; } return ans ; } int main ( ) { int a [ row ] [ col ] = { { 1 , 1 , 0 , 1 , 0 , 0 , 0 , 0 } , { 0 , 1 , 1 , 1 , 1 , 0 , 0 , 1 } , { 1 , 0 , 0 , 1 , 1 , 1 , 0 , 0 } , { 0 , 1 , 1 , 0 , 1 , 1 , 0 , 0 } , { 1 , 0 , 1 , 1 , 1 , 1 , 1 , 0 } , { 0 , 0 , 1 , 1 , 1 , 1 , 1 , 1 } } ; cout << largestMatrix ( a ) ; return 0 ; }

Index/key variables: col, i, j, row, tp
Accumulator variables: cnt, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printUnsorted ( int arr [ ] , int n ) { int s = 0 , e = n - 1 , i , max , min ; for ( s = 0 ; s < n - 1 ; s ++ ) { if ( arr [ s ] > arr [ s + 1 ] ) break ; } if ( s == n - 1 ) { cout << " The ▁ complete ▁ array ▁ is ▁ sorted " ; return ; } for ( e = n - 1 ; e > 0 ; e -- ) { if ( arr [ e ] < arr [ e - 1 ] ) break ; } max = arr [ s ] ; min = arr [ s ] ; for ( i = s + 1 ; i <= e ; i ++ ) { if ( arr [ i ] > max ) max = arr [ i ] ; if ( arr [ i ] < min ) min = arr [ i ] ; } for ( i = 0 ; i < s ; i ++ ) { if ( arr [ i ] > min ) { s = i ; break ; } } for ( i = n - 1 ; i >= e + 1 ; i -- ) { if ( arr [ i ] < max ) { e = i ; break ; } } cout << " The ▁ unsorted ▁ subarray ▁ which " << " ▁ makes ▁ the ▁ given ▁ array " << endl << " sorted ▁ lies ▁ between ▁ the ▁ indees ▁ " << s << " ▁ and ▁ " << e ; return ; } int main ( ) { int arr [ ] = { 10 , 12 , 20 , 30 , 25 , 40 , 32 , 31 , 35 , 50 , 60 } ; int arr_size = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; printUnsorted ( arr , arr_size ) ; getchar ( ) ; return 0 ; }

Index/key variables: e, i, s
Accumulator variables: e, i, s, stdc
Iterator variables: e, i, s
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findNumberOfTriangles ( int arr [ ] , int n ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { for ( int k = j + 1 ; k < n ; k ++ ) if ( arr [ i ] + arr [ j ] > arr [ k ] && arr [ i ] + arr [ k ] > arr [ j ] && arr [ k ] + arr [ j ] > arr [ i ] ) count ++ ; } } return count ; } int main ( ) { int arr [ ] = { 10 , 21 , 22 , 100 , 101 , 200 , 300 } ; int size = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << " Total ▁ number ▁ of ▁ triangles ▁ possible ▁ is ▁ " << findNumberOfTriangles ( arr , size ) ; return 0 ; }

Index/key variables: i, j, k
Accumulator variables: count, i, j, k, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; int comp ( const void * a , const void * b ) { return * ( int * ) a > * ( int * ) b ; } int findNumberOfTriangles ( int arr [ ] , int n ) { qsort ( arr , n , sizeof ( arr [ 0 ] ) , comp ) ; int count = 0 ; for ( int i = 0 ; i < n - 2 ; ++ i ) { int k = i + 2 ; for ( int j = i + 1 ; j < n ; ++ j ) { while ( k < n && arr [ i ] + arr [ j ] > arr [ k ] ) ++ k ; if ( k > j ) count += k - j - 1 ; } } return count ; } int main ( ) { int arr [ ] = { 10 , 21 , 22 , 100 , 101 , 200 , 300 } ; int size = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << " Total ▁ number ▁ of ▁ triangles ▁ possible ▁ is ▁ " << findNumberOfTriangles ( arr , size ) ; return 0 ; }

Index/key variables: i, j, k
Accumulator variables: count, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void CountTriangles ( vector < int > A ) { int n = A . size ( ) ; sort ( A . begin ( ) , A . end ( ) ) ; int count = 0 ; for ( int i = n - 1 ; i >= 1 ; i -- ) { int l = 0 , r = i - 1 ; while ( l < r ) { if ( A [ l ] + A [ r ] > A [ i ] ) { count += r - l ; r -- ; } else l ++ ; } } cout << " No ▁ of ▁ possible ▁ solutions : ▁ " << count ; } int main ( ) { vector < int > A = { 4 , 3 , 5 , 7 , 6 } ; CountTriangles ( A ) ; }

Index/key variables: i, l, r
Accumulator variables: count, i, l, r, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct node { int data ; struct node * left , * right ; } ; struct node * newNode ( int data ) { struct node * temp = new struct node ; temp -> data = data ; temp -> left = temp -> right = NULL ; return temp ; } int sumOfGrandChildren ( node * node ) ; int getMaxSum ( node * node ) ; int getMaxSumUtil ( node * node , map < struct node * , int > & mp ) ; int sumOfGrandChildren ( node * node , map < struct node * , int > & mp ) { int sum = 0 ; if ( node -> left ) sum += getMaxSumUtil ( node -> left -> left , mp ) + getMaxSumUtil ( node -> left -> right , mp ) ; if ( node -> right ) sum += getMaxSumUtil ( node -> right -> left , mp ) + getMaxSumUtil ( node -> right -> right , mp ) ; return sum ; } int getMaxSumUtil ( node * node , map < struct node * , int > & mp ) { if ( node == NULL ) return 0 ; if ( mp . find ( node ) != mp . end ( ) ) return mp [ node ] ; int incl = node -> data + sumOfGrandChildren ( node , mp ) ; int excl = getMaxSumUtil ( node -> left , mp ) + getMaxSumUtil ( node -> right , mp ) ; mp [ node ] = max ( incl , excl ) ; return mp [ node ] ; } int getMaxSum ( node * node ) { if ( node == NULL ) return 0 ; map < struct node * , int > mp ; return getMaxSumUtil ( node , mp ) ; } int main ( ) { node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 3 ) ; root -> right -> left = newNode ( 4 ) ; root -> right -> right = newNode ( 5 ) ; root -> left -> left = newNode ( 1 ) ; cout << getMaxSum ( root ) << endl ; return 0 ; }

Index/key variables: node
Accumulator variables: stdc, sum
Class/struct names: node
C++ program:
#include <bits/stdc++.h>
using namespace std ; int solve ( int A [ ] , int n ) { unordered_map < int , int > dp [ 2 ] ; bool flag = 1 ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += A [ i ] ; for ( int i = - sum ; i <= sum ; i ++ ) dp [ 0 ] [ i ] = INT_MAX ; dp [ 0 ] [ 0 ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = - sum ; j <= sum ; j ++ ) { dp [ flag ] [ j ] = INT_MAX ; if ( j - A [ i - 1 ] <= sum && j - A [ i - 1 ] >= - sum ) dp [ flag ] [ j ] = dp [ flag ^ 1 ] [ j - A [ i - 1 ] ] ; if ( j + A [ i - 1 ] <= sum && j + A [ i - 1 ] >= - sum && dp [ flag ^ 1 ] [ j + A [ i - 1 ] ] != INT_MAX ) dp [ flag ] [ j ] = min ( dp [ flag ] [ j ] , dp [ flag ^ 1 ] [ j + A [ i - 1 ] ] + 1 ) ; } flag = flag ^ 1 ; } for ( int i = 0 ; i <= sum ; i ++ ) { if ( dp [ flag ^ 1 ] [ i ] != INT_MAX ) return dp [ flag ^ 1 ] [ i ] ; } return n - 1 ; } int main ( ) { int arr [ ] = { 10 , 22 , 9 , 33 , 21 , 50 , 41 , 60 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << solve ( arr , n ) ; return 0 ; }

Index/key variables: flag, i, j
Accumulator variables: i, j, stdc, sum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
long long countPairsBruteForce ( long long X [ ] , long long Y [ ] , long long m , long long n ) { long long ans = 0 ; for ( int i = 0 ; i < m ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) if ( pow ( X [ i ] , Y [ j ] ) > pow ( Y [ j ] , X [ i ] ) ) ans ++ ; return ans ; }

Index/key variables: i, j
Accumulator variables: ans, i, j, stdc
Iterator variables: i, j
C++ program:
#include <iostream>
using namespace std ; template < typename T > class AllPermutation { private : const T * Arr ; const int Length ; int * Indexes ; int Increase ; public : AllPermutation ( T * arr , int length ) : Arr ( arr ) , Length ( length ) { this -> Indexes = nullptr ; this -> Increase = -1 ; } ~ AllPermutation ( ) { if ( this -> Indexes != nullptr ) { delete [ ] this -> Indexes ; } } void GetFirst ( ) { this -> Indexes = new int [ this -> Length ] ; for ( int i = 0 ; i < this -> Length ; ++ i ) { this -> Indexes [ i ] = i ; } this -> Increase = 0 ; this -> Output ( ) ; } bool HasNext ( ) { return this -> Increase != ( this -> Length - 1 ) ; } void GetNext ( ) { if ( this -> Increase == 0 ) { this -> Swap ( this -> Increase , this -> Increase + 1 ) ; this -> Increase += 1 ; while ( this -> Increase < this -> Length - 1 && this -> Indexes [ this -> Increase ] > this -> Indexes [ this -> Increase + 1 ] ) { ++ this -> Increase ; } } else { if ( this -> Indexes [ this -> Increase + 1 ] > this -> Indexes [ 0 ] ) { this -> Swap ( this -> Increase + 1 , 0 ) ; } else { int start = 0 ; int end = this -> Increase ; int mid = ( start + end ) / 2 ; int tVal = this -> Indexes [ this -> Increase + 1 ] ; while ( ! ( this -> Indexes [ mid ] < tVal && this -> Indexes [ mid - 1 ] > tVal ) ) { if ( this -> Indexes [ mid ] < tVal ) { end = mid - 1 ; } else { start = mid + 1 ; } mid = ( start + end ) / 2 ; } this -> Swap ( this -> Increase + 1 , mid ) ; } for ( int i = 0 ; i <= this -> Increase / 2 ; ++ i ) { this -> Swap ( i , this -> Increase - i ) ; } this -> Increase = 0 ; } this -> Output ( ) ; } private : void Output ( ) { for ( int i = 0 ; i < this -> Length ; ++ i ) { cout << ( this -> Arr [ this -> Indexes [ i ] ] ) << " ▁ " ; } cout << endl ; } void Swap ( int p , int q ) { int tmp = this -> Indexes [ p ] ; this -> Indexes [ p ] = this -> Indexes [ q ] ; this -> Indexes [ q ] = tmp ; } } ; int main ( ) { int arr [ ] = { 0 , 1 , 2 } ; AllPermutation < int > perm ( arr , sizeof ( arr ) / sizeof ( int ) ) ; perm . GetFirst ( ) ; while ( perm . HasNext ( ) ) { perm . GetNext ( ) ; } return 0 ; }

Index/key variables: i, mid, p, q
Accumulator variables: Increase
Iterator variables: i
Class/struct names: AllPermutation
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < vector < int > > dp ; vector < vector < bool > > v ; vector < int > exp_c ; int FindMax ( int i , int r , int w [ ] , int n , int c , int k ) { if ( i >= n ) return 0 ; if ( v [ i ] [ r ] ) return dp [ i ] [ r ] ; v [ i ] [ r ] = 1 ; dp [ i ] [ r ] = FindMax ( i + 1 , r , w , n , c , k ) ; for ( int j = 0 ; j < k ; j ++ ) { int x = ( r / exp_c [ j ] ) % ( c + 1 ) ; if ( x - w [ i ] >= 0 ) dp [ i ] [ r ] = max ( dp [ i ] [ r ] , w [ i ] + FindMax ( i + 1 , r - w [ i ] * exp_c [ j ] , w , n , c , k ) ) ; } return dp [ i ] [ r ] ; } int PreCompute ( int n , int c , int k ) { exp_c . resize ( k ) ; exp_c [ 0 ] = 1 ; for ( int i = 1 ; i < k ; i ++ ) { exp_c [ i ] = ( exp_c [ i - 1 ] * ( c + 1 ) ) ; } dp . resize ( n ) ; for ( int i = 0 ; i < n ; i ++ ) { dp [ i ] . resize ( exp_c [ k - 1 ] * ( c + 1 ) , 0 ) ; } v . resize ( n ) ; for ( int i = 0 ; i < n ; i ++ ) { v [ i ] . resize ( exp_c [ k - 1 ] * ( c + 1 ) , 0 ) ; } int R = 0 ; for ( int i = 0 ; i < k ; i ++ ) { R += exp_c [ i ] * c ; } return R ; } int main ( ) { int w [ ] = { 3 , 8 , 9 } ; int k = 1 , c = 11 ; int n = sizeof ( w ) / sizeof ( int ) ; int r = PreCompute ( n , c , k ) ; cout << FindMax ( 0 , r , w , n , c , k ) ; return 0 ; }

Index/key variables: i, j, r
Accumulator variables: R, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int count ( int x , int Y [ ] , int n , int NoOfY [ ] ) { if ( x == 0 ) return 0 ; if ( x == 1 ) return NoOfY [ 0 ] ; int * idx = upper_bound ( Y , Y + n , x ) ; int ans = ( Y + n ) - idx ; ans += ( NoOfY [ 0 ] + NoOfY [ 1 ] ) ; if ( x == 2 ) ans -= ( NoOfY [ 3 ] + NoOfY [ 4 ] ) ; if ( x == 3 ) ans += NoOfY [ 2 ] ; return ans ; } int countPairs ( int X [ ] , int Y [ ] , int m , int n ) { int NoOfY [ 5 ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) if ( Y [ i ] < 5 ) NoOfY [ Y [ i ] ] ++ ; sort ( Y , Y + n ) ; int total_pairs = 0 ; for ( int i = 0 ; i < m ; i ++ ) total_pairs += count ( X [ i ] , Y , n , NoOfY ) ; return total_pairs ; } int main ( ) { int X [ ] = { 2 , 1 , 6 } ; int Y [ ] = { 1 , 5 } ; int m = sizeof ( X ) / sizeof ( X [ 0 ] ) ; int n = sizeof ( Y ) / sizeof ( Y [ 0 ] ) ; cout << " Total ▁ pairs ▁ = ▁ " << countPairs ( X , Y , m , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, stdc, total_pairs
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int countPairsWithDiffK ( int arr [ ] , int n , int k ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) if ( arr [ i ] - arr [ j ] == k arr [ j ] - arr [ i ] == k ) count ++ ; } return count ; } int main ( ) { int arr [ ] = { 1 , 5 , 3 , 4 , 2 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int k = 3 ; cout << " Count ▁ of ▁ pairs ▁ with ▁ given ▁ diff ▁ is ▁ " << countPairsWithDiffK ( arr , n , k ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
C++ program:
#include <iostream>
#include <algorithm>
using namespace std ; int binarySearch ( int arr [ ] , int low , int high , int x ) { if ( high >= low ) { int mid = low + ( high - low ) / 2 ; if ( x == arr [ mid ] ) return mid ; if ( x > arr [ mid ] ) return binarySearch ( arr , ( mid + 1 ) , high , x ) ; else return binarySearch ( arr , low , ( mid - 1 ) , x ) ; } return -1 ; } int countPairsWithDiffK ( int arr [ ] , int n , int k ) { int count = 0 , i ; sort ( arr , arr + n ) ; for ( i = 0 ; i < n - 1 ; i ++ ) if ( binarySearch ( arr , i + 1 , n - 1 , arr [ i ] + k ) != -1 ) count ++ ; return count ; } int main ( ) { int arr [ ] = { 1 , 5 , 3 , 4 , 2 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int k = 3 ; cout << " Count ▁ of ▁ pairs ▁ with ▁ given ▁ diff ▁ is ▁ " << countPairsWithDiffK ( arr , n , k ) ; return 0 ; }

Index/key variables: i, mid
Accumulator variables: count, i
Iterator variables: i
C++ program:
#define MAX  100000
int countPairsWithDiffK ( int arr [ ] , int n , int k ) { int count = 0 ; bool hashmap [ MAX ] = { false } ; for ( int i = 0 ; i < n ; i ++ ) hashmap [ arr [ i ] ] = true ; for ( int i = 0 ; i < n ; i ++ ) { int x = arr [ i ] ; if ( x - k >= 0 && hashmap [ x - k ] ) count ++ ; if ( x + k < MAX && hashmap [ x + k ] ) count ++ ; hashmap [ x ] = false ; } return count ; }

Index/key variables: MAX, i, x
Accumulator variables: count, i
Iterator variables: i
C++ program:
#include <iostream>
#include <algorithm>
using namespace std ; int countPairsWithDiffK ( int arr [ ] , int n , int k ) { int count = 0 ; sort ( arr , arr + n ) ; int l = 0 ; int r = 0 ; while ( r < n ) { if ( arr [ r ] - arr [ l ] == k ) { count ++ ; l ++ ; r ++ ; } else if ( arr [ r ] - arr [ l ] > k ) l ++ ; else r ++ ; } return count ; } int main ( ) { int arr [ ] = { 1 , 5 , 3 , 4 , 2 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int k = 3 ; cout << " Count ▁ of ▁ pairs ▁ with ▁ given ▁ diff ▁ is ▁ " << countPairsWithDiffK ( arr , n , k ) ; return 0 ; }

Index/key variables: l, r
Accumulator variables: count, l, r
C++ program:
#include <iostream>
#include <stack>
using namespace std ; #define n  3
void findPrefixCount ( int p_arr [ ] [ n ] , bool set_bit [ ] [ n ] ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = n - 1 ; j >= 0 ; j -- ) { if ( set_bit [ i ] [ j ] ) continue ; if ( j != n - 1 ) p_arr [ i ] [ j ] += p_arr [ i ] [ j + 1 ] ; p_arr [ i ] [ j ] += ( int ) ( ! set_bit [ i ] [ j ] ) ; } } } int matrixOrValueOne ( bool set_bit [ ] [ n ] ) { int p_arr [ n ] [ n ] = { 0 } ; findPrefixCount ( p_arr , set_bit ) ; int count_zero_submatrices = 0 ; for ( int j = 0 ; j < n ; j ++ ) { int i = n - 1 ; stack < pair < int , int > > q ; int to_sum = 0 ; while ( i >= 0 ) { int c = 0 ; while ( q . size ( ) != 0 and q . top ( ) . first > p_arr [ i ] [ j ] ) { to_sum -= ( q . top ( ) . second + 1 ) * ( q . top ( ) . first - p_arr [ i ] [ j ] ) ; c += q . top ( ) . second + 1 ; q . pop ( ) ; } to_sum += p_arr [ i ] [ j ] ; count_zero_submatrices += to_sum ; q . push ( { p_arr [ i ] [ j ] , c } ) ; i -- ; } } return ( n * ( n + 1 ) * n * ( n + 1 ) ) / 4 - count_zero_submatrices ; } int sumOrMatrix ( int arr [ ] [ n ] ) { int sum = 0 ; int mul = 1 ; for ( int i = 0 ; i < 30 ; i ++ ) { bool set_bit [ n ] [ n ] ; for ( int R = 0 ; R < n ; R ++ ) for ( int C = 0 ; C < n ; C ++ ) set_bit [ R ] [ C ] = ( ( arr [ R ] [ C ] & ( 1 << i ) ) != 0 ) ; sum += ( mul * matrixOrValueOne ( set_bit ) ) ; mul *= 2 ; } return sum ; } int main ( ) { int arr [ ] [ n ] = { { 9 , 7 , 4 } , { 8 , 9 , 2 } , { 11 , 11 , 5 } } ; cout << sumOrMatrix ( arr ) ; return 0 ; }

Index/key variables: C, R, i, j, n
Accumulator variables: C, R, c, count_zero_submatrices, i, j, mul, sum, to_sum
Iterator variables: C, R, i, j
C++ program:
#include <bits/stdc++.h>
#define MOD  1000000007
#define ll  long long int
using namespace std ; int totalSubSets ( ll n , ll l , ll r ) { ll zero = floor ( ( double ) r / 3 ) - ceil ( ( double ) l / 3 ) + 1 ; ll one = floor ( ( double ) ( r - 1 ) / 3 ) - ceil ( ( double ) ( l - 1 ) / 3 ) + 1 ; ll two = floor ( ( double ) ( r - 2 ) / 3 ) - ceil ( ( double ) ( l - 2 ) / 3 ) + 1 ; ll dp [ n ] [ 3 ] ; memset ( dp , 0 , sizeof ( dp ) ) ; dp [ 0 ] [ 0 ] = zero ; dp [ 0 ] [ 1 ] = one ; dp [ 0 ] [ 2 ] = two ; for ( ll i = 1 ; i < n ; ++ i ) { dp [ i ] [ 0 ] = ( ( dp [ i - 1 ] [ 0 ] * zero ) + ( dp [ i - 1 ] [ 1 ] * two ) + ( dp [ i - 1 ] [ 2 ] * one ) ) % MOD ; dp [ i ] [ 1 ] = ( ( dp [ i - 1 ] [ 0 ] * one ) + ( dp [ i - 1 ] [ 1 ] * zero ) + ( dp [ i - 1 ] [ 2 ] * two ) ) % MOD ; dp [ i ] [ 2 ] = ( ( dp [ i - 1 ] [ 0 ] * two ) + ( dp [ i - 1 ] [ 1 ] * one ) + ( dp [ i - 1 ] [ 2 ] * zero ) ) % MOD ; } return dp [ n - 1 ] [ 0 ] ; } int main ( ) { ll n = 5 ; ll l = 10 ; ll r = 100 ; cout << totalSubSets ( n , l , r ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; class Node { public : int data ; Node * left , * right ; Node ( int data ) { this -> data = data ; left = NULL ; right = NULL ; } } ; pair < int , int > maxSumHelper ( Node * root ) { if ( root == NULL ) { pair < int , int > sum ( 0 , 0 ) ; return sum ; } pair < int , int > sum1 = maxSumHelper ( root -> left ) ; pair < int , int > sum2 = maxSumHelper ( root -> right ) ; pair < int , int > sum ; sum . first = sum1 . second + sum2 . second + root -> data ; sum . second = max ( sum1 . first , sum1 . second ) + max ( sum2 . first , sum2 . second ) ; return sum ; } int maxSum ( Node * root ) { pair < int , int > res = maxSumHelper ( root ) ; return max ( res . first , res . second ) ; } int main ( ) { Node * root = new Node ( 10 ) ; root -> left = new Node ( 1 ) ; root -> left -> left = new Node ( 2 ) ; root -> left -> left -> left = new Node ( 1 ) ; root -> left -> right = new Node ( 3 ) ; root -> left -> right -> left = new Node ( 4 ) ; root -> left -> right -> right = new Node ( 5 ) ; cout << maxSum ( root ) ; return 0 ; }

Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define r  4
#define c  5
bool findmatch ( char mat [ r ] , string pat , int x , int y , int nrow , int ncol , int level ) { int l = pat . length ( ) ; if ( level == l ) return true ; if ( x < 0 y < 0 x > = nrow y > = ncol ) return false ; if ( mat [ x ] [ y ] == pat [ level ] ) { char temp = mat [ x ] [ y ] ; mat [ x ] [ y ] = ' # ' ; bool res = findmatch ( mat , pat , x - 1 , y , nrow , ncol , level + 1 ) | findmatch ( mat , pat , x + 1 , y , nrow , ncol , level + 1 ) | findmatch ( mat , pat , x , y - 1 , nrow , ncol , level + 1 ) | findmatch ( mat , pat , x , y + 1 , nrow , ncol , level + 1 ) ; mat [ x ] [ y ] = temp ; return res ; } return false ; } bool checkMatch ( char mat [ r ] , string pat , int nrow , int ncol ) { int l = pat . length ( ) ; if ( l > nrow * ncol ) return false ; for ( int i = 0 ; i < nrow ; i ++ ) { for ( int j = 0 ; j < ncol ; j ++ ) { if ( mat [ i ] [ j ] == pat [ 0 ] ) if ( findmatch ( mat , pat , i , j , nrow , ncol , 0 ) ) return true ; } } return false ; } int main ( ) { char grid [ r ] = { " axmy " , " bgdf " , " xeet " , " raks " } ; if ( checkMatch ( grid , " geeks " , r , c ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: i, j, level, r, x, y
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void constructArr ( int arr [ ] , int pair [ ] , int n ) { arr [ 0 ] = ( pair [ 0 ] + pair [ 1 ] - pair [ n - 1 ] ) / 2 ; for ( int i = 1 ; i < n ; i ++ ) arr [ i ] = pair [ i - 1 ] - arr [ 0 ] ; } int main ( ) { int pair [ ] = { 15 , 13 , 11 , 10 , 12 , 10 , 9 , 8 , 7 , 5 } ; int n = 5 ; int arr [ n ] ; constructArr ( arr , pair , n ) ; for ( int i = 0 ; i < n ; i ++ ) cout << arr [ i ] << " ▁ " ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void merge ( int ar1 [ ] , int ar2 [ ] , int m , int n ) { for ( int i = n - 1 ; i >= 0 ; i -- ) { int j , last = ar1 [ m - 1 ] ; for ( j = m - 2 ; j >= 0 && ar1 [ j ] > ar2 [ i ] ; j -- ) ar1 [ j + 1 ] = ar1 [ j ] ; if ( j != m - 2 last > ar2 [ i ] ) { ar1 [ j + 1 ] = ar2 [ i ] ; ar2 [ i ] = last ; } } } int main ( ) { int ar1 [ ] = { 1 , 5 , 9 , 10 , 15 , 20 } ; int ar2 [ ] = { 2 , 3 , 8 , 13 } ; int m = sizeof ( ar1 ) / sizeof ( ar1 [ 0 ] ) ; int n = sizeof ( ar2 ) / sizeof ( ar2 [ 0 ] ) ; merge ( ar1 , ar2 , m , n ) ; cout << " After ▁ Merging ▁ nFirst ▁ Array : ▁ " ; for ( int i = 0 ; i < m ; i ++ ) cout << ar1 [ i ] << " ▁ " ; cout << " nSecond ▁ Array : ▁ " ; for ( int i = 0 ; i < n ; i ++ ) cout << ar2 [ i ] << " ▁ " ; 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 merge ( int arr1 [ ] , int arr2 [ ] , int n , int m ) { int i = 0 , j = 0 , k = n - 1 ; while ( i <= k and j < m ) { if ( arr1 [ i ] < arr2 [ j ] ) i ++ ; else { swap ( arr2 [ j ++ ] , arr1 [ k -- ] ) ; } } sort ( arr1 , arr1 + n ) ; sort ( arr2 , arr2 + m ) ; } int main ( ) { int ar1 [ ] = { 1 , 5 , 9 , 10 , 15 , 20 } ; int ar2 [ ] = { 2 , 3 , 8 , 13 } ; int m = sizeof ( ar1 ) / sizeof ( ar1 [ 0 ] ) ; int n = sizeof ( ar2 ) / sizeof ( ar2 [ 0 ] ) ; merge ( ar1 , ar2 , m , n ) ; cout << " After ▁ Merging ▁ STRNEWLINE First ▁ Array : ▁ " ; for ( int i = 0 ; i < m ; i ++ ) cout << ar1 [ i ] << " ▁ " ; cout << " Second Array : " for ( int i = 0 ; i < n ; i ++ ) cout << ar2 [ i ] << " ▁ " ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, k, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void gouldSequence ( int n ) { for ( int row_num = 1 ; row_num <= n ; row_num ++ ) { int count = 1 ; int c = 1 ; for ( int i = 1 ; i <= row_num ; i ++ ) { c = c * ( row_num - i ) / i ; if ( c % 2 == 1 ) count ++ ; } cout << count << " ▁ " ; } } int main ( ) { int n = 16 ; gouldSequence ( n ) ; return 0 ; }

Accumulator variables: count, i, row_num, stdc
Iterator variables: i, row_num
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minMaxProduct ( int arr1 [ ] , int arr2 [ ] , int n1 , int n2 ) { sort ( arr1 , arr1 + n1 ) ; sort ( arr2 , arr2 + n2 ) ; return arr1 [ n1 - 1 ] * arr2 [ 0 ] ; } int main ( ) { int arr1 [ ] = { 10 , 2 , 3 , 6 , 4 , 1 } ; int arr2 [ ] = { 5 , 1 , 4 , 2 , 6 , 9 } ; int n1 = sizeof ( arr1 ) / sizeof ( arr1 [ 0 ] ) ; int n2 = sizeof ( arr1 ) / sizeof ( arr1 [ 0 ] ) ; cout << minMaxProduct ( arr1 , arr2 , n1 , n2 ) ; return 0 ; }

Accumulator variables: stdc