dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
#define M  100 
#define N  100 
using namespace std ; int find_min_odd_cost ( int given [ M ] [ N ] , int m , int n ) { int floor [ M ] [ N ] = { { 0 } , { 0 } } ; int min_odd_cost = 0 ; int i , j , temp ; for ( j = 0 ; j < n ; j ++ ) floor [ 0 ] [ j ] = given [ 0 ] [ j ] ; for ( i = 1 ; i < m ; i ++ ) for ( j = 0 ; j < n ; j ++ ) { if ( j == 0 ) { floor [ i ] [ j ] = given [ i ] [ j ] ; floor [ i ] [ j ] += min ( floor [ i - 1 ] [ j ] , floor [ i - 1 ] [ j + 1 ] ) ; } else if ( j == n - 1 ) { floor [ i ] [ j ] = given [ i ] [ j ] ; floor [ i ] [ j ] += min ( floor [ i - 1 ] [ j ] , floor [ i - 1 ] [ j - 1 ] ) ; } else { temp = min ( floor [ i - 1 ] [ j ] , floor [ i - 1 ] [ j - 1 ] ) ; temp = min ( temp , floor [ i - 1 ] [ j + 1 ] ) ; floor [ i ] [ j ] = given [ i ] [ j ] + temp ; } } min_odd_cost = INT_MAX ; for ( j = 0 ; j < n ; j ++ ) { if ( floor [ n - 1 ] [ j ] % 2 == 1 ) { if ( min_odd_cost > floor [ n - 1 ] [ j ] ) min_odd_cost = floor [ n - 1 ] [ j ] ; } } if ( min_odd_cost == INT_MIN ) return -1 ; return min_odd_cost ; } int main ( ) { int m = 5 , n = 5 ; int given [ M ] [ N ] = { { 1 , 2 , 3 , 4 , 6 } , { 1 , 2 , 3 , 4 , 5 } , { 1 , 2 , 3 , 4 , 5 } , { 1 , 2 , 3 , 4 , 5 } , { 100 , 2 , 3 , 4 , 5 } } ; cout << " Minimum ▁ odd ▁ cost ▁ is ▁ " << find_min_odd_cost ( given , m , n ) ; return 0 ; }

Index/key variables: M, N, i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minMaxProduct ( int arr1 [ ] , int arr2 [ ] , int n1 , int n2 ) { int max = arr1 [ 0 ] ; int min = arr2 [ 0 ] ; int i ; for ( i = 1 ; i < n1 && i < n2 ; ++ i ) { if ( arr1 [ i ] > max ) max = arr1 [ i ] ; if ( arr2 [ i ] < min ) min = arr2 [ i ] ; } while ( i < n1 ) { if ( arr1 [ i ] > max ) max = arr1 [ i ] ; i ++ ; } while ( i < n2 ) { if ( arr2 [ i ] < min ) min = arr2 [ i ] ; i ++ ; } return max * min ; } 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 ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#include <iostream>
using namespace std ; int getMax ( int A [ ] , int N ) { int B [ N + 2 ] ; B [ 0 ] = 1 ; B [ N + 1 ] = 1 ; for ( int i = 1 ; i <= N ; i ++ ) B [ i ] = A [ i - 1 ] ; int dp [ N + 2 ] [ N + 2 ] ; memset ( dp , 0 , sizeof ( dp ) ) ; for ( int length = 1 ; length < N + 1 ; length ++ ) { for ( int left = 1 ; left < N - length + 2 ; left ++ ) { int right = left + length - 1 ; for ( int last = left ; last < right + 1 ; last ++ ) { dp [ left ] [ right ] = max ( dp [ left ] [ right ] , dp [ left ] [ last - 1 ] + B [ left - 1 ] * B [ last ] * B [ right + 1 ] + dp [ last + 1 ] [ right ] ) ; } } } return dp [ 1 ] [ N ] ; } int main ( ) { int A [ ] = { 1 , 2 , 3 , 4 , 5 } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; cout << getMax ( A , N ) << endl ; }

Index/key variables: N, i, last, left, right
Accumulator variables: i, last, left, length, stdc
Iterator variables: i, last, left, length
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findElement ( int arr [ ] , int n , int key ) { int i ; for ( i = 0 ; i < n ; i ++ ) if ( arr [ i ] == key ) return i ; return -1 ; } int main ( ) { int arr [ ] = { 12 , 34 , 10 , 6 , 40 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int key = 40 ; int position = findElement ( arr , n , key ) ; if ( position == - 1 ) cout << " Element ▁ not ▁ found " ; else cout << " Element ▁ Found ▁ at ▁ Position : ▁ " << position + 1 ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int insertSorted ( int arr [ ] , int n , int key , int capacity ) { if ( n >= capacity ) return n ; arr [ n ] = key ; return ( n + 1 ) ; } int main ( ) { int arr [ 20 ] = { 12 , 16 , 20 , 40 , 50 , 70 } ; int capacity = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int n = 6 ; int i , key = 26 ; cout << " Before Insertion : " for ( i = 0 ; i < n ; i ++ ) cout << arr [ i ] << " ▁ " ; n = insertSorted ( arr , n , key , capacity ) ; cout << " After Insertion : " for ( i = 0 ; i < n ; i ++ ) cout << arr [ i ] << " ▁ " ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int findElement ( int arr [ ] , int n , int key ) { int i ; for ( i = 0 ; i < n ; i ++ ) if ( arr [ i ] == key ) return i ; return - 1 ; } int deleteElement ( int arr [ ] , int n , int key ) { int pos = findElement ( arr , n , key ) ; if ( pos == - 1 ) { cout << " Element ▁ not ▁ found " ; return n ; } int i ; for ( i = pos ; i < n - 1 ; i ++ ) arr [ i ] = arr [ i + 1 ] ; return n - 1 ; } int main ( ) { int i ; int arr [ ] = { 10 , 50 , 30 , 40 , 20 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int key = 30 ; cout << " Array ▁ before ▁ deletion STRNEWLINE " ; for ( i = 0 ; i < n ; i ++ ) cout << arr [ i ] << " ▁ " ; n = deleteElement ( arr , n , key ) ; cout << " Array after deletion " ; for ( i = 0 ; i < n ; i ++ ) cout << arr [ i ] << " ▁ " ; return 0 ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int binarySearch ( int arr [ ] , int low , int high , int key ) { if ( high < low ) return -1 ; int mid = ( low + high ) / 2 ; if ( key == arr [ mid ] ) return mid ; if ( key > arr [ mid ] ) return binarySearch ( arr , ( mid + 1 ) , high , key ) ; return binarySearch ( arr , low , ( mid - 1 ) , key ) ; } int main ( ) { int arr [ ] = { 5 , 6 , 7 , 8 , 9 , 10 } ; int n , key ; n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; key = 10 ; cout << " Index : ▁ " << binarySearch ( arr , 0 , n - 1 , key ) << endl ; return 0 ; }

Index/key variables: mid
Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; int insertSorted ( int arr [ ] , int n , int key , int capacity ) { if ( n >= capacity ) return n ; int i ; for ( i = n - 1 ; ( i >= 0 && arr [ i ] > key ) ; i -- ) arr [ i + 1 ] = arr [ i ] ; arr [ i + 1 ] = key ; return ( n + 1 ) ; } int main ( ) { int arr [ 20 ] = { 12 , 16 , 20 , 40 , 50 , 70 } ; int capacity = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int n = 6 ; int i , key = 26 ; cout << " Before Insertion : " for ( i = 0 ; i < n ; i ++ ) cout << arr [ i ] << " ▁ " ; n = insertSorted ( arr , n , key , capacity ) ; cout << " After Insertion : " for ( i = 0 ; i < n ; i ++ ) cout << arr [ i ] << " ▁ " ; return 0 ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int binarySearch ( int arr [ ] , int low , int high , int key ) ; int binarySearch ( int arr [ ] , int low , int high , int key ) { if ( high < low ) return -1 ; int mid = ( low + high ) / 2 ; if ( key == arr [ mid ] ) return mid ; if ( key > arr [ mid ] ) return binarySearch ( arr , ( mid + 1 ) , high , key ) ; return binarySearch ( arr , low , ( mid - 1 ) , key ) ; } int deleteElement ( int arr [ ] , int n , int key ) { int pos = binarySearch ( arr , 0 , n - 1 , key ) ; if ( pos == -1 ) { cout << " Element ▁ not ▁ found " ; return n ; } int i ; for ( i = pos ; i < n - 1 ; i ++ ) arr [ i ] = arr [ i + 1 ] ; return n - 1 ; } int main ( ) { int i ; int arr [ ] = { 10 , 20 , 30 , 40 , 50 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int key = 30 ; cout << " Array ▁ before ▁ deletion STRNEWLINE " ; for ( i = 0 ; i < n ; i ++ ) cout << arr [ i ] << " ▁ " ; n = deleteElement ( arr , n , key ) ; cout << " Array after deletion " ; for ( i = 0 ; i < n ; i ++ ) cout << arr [ i ] << " ▁ " ; }

Index/key variables: i, mid
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX  100
#define N  5
#define M  4
int min ( int a , int b , int c ) { return min ( a , min ( b , c ) ) ; } void solveQuery ( int n , int m , int mat [ N ] [ M ] , int q , int a [ ] , int binary [ ] ) { int dp [ n ] [ m ] , max = 1 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( i == 0 j == 0 ) dp [ i ] [ j ] = 1 ; else if ( ( mat [ i ] [ j ] == mat [ i - 1 ] [ j ] ) && ( mat [ i ] [ j ] == mat [ i ] [ j - 1 ] ) && ( mat [ i ] [ j ] == mat [ i - 1 ] [ j - 1 ] ) ) { dp [ i ] [ j ] = min ( dp [ i - 1 ] [ j ] , dp [ i - 1 ] [ j - 1 ] , dp [ i ] [ j - 1 ] ) + 1 ; if ( max < dp [ i ] [ j ] ) max = dp [ i ] [ j ] ; } else dp [ i ] [ j ] = 1 ; } } int freq0 [ MAX ] = { 0 } , freq1 [ MAX ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( mat [ i ] [ j ] == 0 ) freq0 [ dp [ i ] [ j ] ] ++ ; else freq1 [ dp [ i ] [ j ] ] ++ ; } } for ( int i = max - 1 ; i >= 0 ; i -- ) { freq0 [ i ] += freq0 [ i + 1 ] ; freq1 [ i ] += freq1 [ i + 1 ] ; } for ( int i = 0 ; i < q ; i ++ ) { if ( binary [ i ] == 0 ) cout << freq0 [ a [ i ] ] << endl ; else cout << freq1 [ a [ i ] ] << endl ; } } int main ( ) { int n = 5 , m = 4 ; int mat [ N ] [ M ] = { { 0 , 0 , 1 , 1 } , { 0 , 0 , 1 , 0 } , { 0 , 1 , 1 , 1 } , { 1 , 1 , 1 , 1 } , { 0 , 1 , 1 , 1 } } ; int q = 2 ; int a [ ] = { 2 , 2 } ; int binary [ ] = { 1 , 0 } ; solveQuery ( n , m , mat , q , a , binary ) ; return 0 ; }

Index/key variables: M, MAX, N, i, j, m, n
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool strmatch ( char txt [ ] , char pat [ ] , int n , int m ) { if ( m == 0 ) return ( n == 0 ) ; int i = 0 , j = 0 , index_txt = -1 , index_pat = -1 ; while ( i < n ) { if ( j < m && txt [ i ] == pat [ j ] ) { i ++ ; j ++ ; } else if ( j < m && pat [ j ] == ' ? ' ) { i ++ ; j ++ ; } else if ( j < m && pat [ j ] == ' * ' ) { index_txt = i ; index_pat = j ; j ++ ; } else if ( index_pat != -1 ) { j = index_pat + 1 ; i = index_txt + 1 ; index_txt ++ ; } else { return false ; } } while ( j < m && pat [ j ] == ' * ' ) { j ++ ; } if ( j == m ) { return true ; } return false ; } int main ( ) { char str [ ] = " baaabab " ; char pattern [ ] = " * * * * * ba * * * * * ab " ; char pattern [ ] = " ba * * * * * ab " ; char pattern [ ] = " ba * ab " ; char pattern [ ] = " a * ab " ; if ( strmatch ( str , pattern , strlen ( str ) , strlen ( pattern ) ) ) cout << " Yes " << endl ; else cout << " No " << endl ; char pattern2 [ ] = " a * * * * * ab " ; if ( strmatch ( str , pattern2 , strlen ( str ) , strlen ( pattern2 ) ) ) cout << " Yes " << endl ; else cout << " No " << endl ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, index_txt, j, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findSDSFunc ( int n ) { int DP [ n + 1 ] ; DP [ 0 ] = 0 ; DP [ 1 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { if ( i % 2 == 0 ) DP [ i ] = DP [ i / 2 ] ; else DP [ i ] = DP [ ( i - 1 ) / 2 ] + DP [ ( i + 1 ) / 2 ] ; } return DP [ n ] ; } int main ( ) { int n = 15 ; cout << findSDSFunc ( n ) << endl ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findCommon ( int ar1 [ ] , int ar2 [ ] , int ar3 [ ] , int n1 , int n2 , int n3 ) { int i = 0 , j = 0 , k = 0 ; while ( i < n1 && j < n2 && k < n3 ) { if ( ar1 [ i ] == ar2 [ j ] && ar2 [ j ] == ar3 [ k ] ) { cout << ar1 [ i ] << " ▁ " ; i ++ ; j ++ ; k ++ ; } else if ( ar1 [ i ] < ar2 [ j ] ) i ++ ; else if ( ar2 [ j ] < ar3 [ k ] ) j ++ ; else k ++ ; } } int main ( ) { int ar1 [ ] = { 1 , 5 , 10 , 20 , 40 , 80 } ; int ar2 [ ] = { 6 , 7 , 20 , 80 , 100 } ; int ar3 [ ] = { 3 , 4 , 15 , 20 , 30 , 70 , 80 , 120 } ; int n1 = sizeof ( ar1 ) / sizeof ( ar1 [ 0 ] ) ; int n2 = sizeof ( ar2 ) / sizeof ( ar2 [ 0 ] ) ; int n3 = sizeof ( ar3 ) / sizeof ( ar3 [ 0 ] ) ; cout << " Common ▁ Elements ▁ are ▁ " ; findCommon ( ar1 , ar2 , ar3 , n1 , n2 , n3 ) ; return 0 ; }

Index/key variables: i, j, k
Accumulator variables: i, j, k, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < int > dp ; void dfs ( int a [ ] , vector < int > v [ ] , int u , int parent ) { dp [ u ] = a [ u - 1 ] ; int maximum = 0 ; for ( int child : v [ u ] ) { if ( child == parent ) continue ; dfs ( a , v , child , u ) ; maximum = max ( maximum , dp [ child ] ) ; } dp [ u ] += maximum ; } int maximumValue ( int a [ ] , vector < int > v [ ] ) { dfs ( a , v , 1 , 0 ) ; return dp [ 1 ] ; } int main ( ) { int n = 14 ; vector < int > v [ n + 1 ] ; v [ 1 ] . push_back ( 2 ) , v [ 2 ] . push_back ( 1 ) ; v [ 1 ] . push_back ( 3 ) , v [ 3 ] . push_back ( 1 ) ; v [ 1 ] . push_back ( 4 ) , v [ 4 ] . push_back ( 1 ) ; v [ 2 ] . push_back ( 5 ) , v [ 5 ] . push_back ( 2 ) ; v [ 2 ] . push_back ( 6 ) , v [ 6 ] . push_back ( 2 ) ; v [ 3 ] . push_back ( 7 ) , v [ 7 ] . push_back ( 3 ) ; v [ 4 ] . push_back ( 8 ) , v [ 8 ] . push_back ( 4 ) ; v [ 4 ] . push_back ( 9 ) , v [ 9 ] . push_back ( 4 ) ; v [ 4 ] . push_back ( 10 ) , v [ 10 ] . push_back ( 4 ) ; v [ 5 ] . push_back ( 11 ) , v [ 11 ] . push_back ( 5 ) ; v [ 5 ] . push_back ( 12 ) , v [ 12 ] . push_back ( 5 ) ; v [ 7 ] . push_back ( 13 ) , v [ 13 ] . push_back ( 7 ) ; v [ 7 ] . push_back ( 14 ) , v [ 14 ] . push_back ( 7 ) ; int a [ ] = { 3 , 2 , 1 , 10 , 1 , 3 , 9 , 1 , 5 , 3 , 4 , 5 , 9 , 8 } ; dp = vector < int > ( n + 1 , 0 ) ; cout << maximumValue ( a , v ) ; return 0 ; }

Index/key variables: child, u
Accumulator variables: stdc
Iterator variables: child
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findCommon ( int ar1 [ ] , int ar2 [ ] , int ar3 [ ] , int n1 , int n2 , int n3 ) { int i = 0 , j = 0 , k = 0 ; int prev1 , prev2 , prev3 ; prev1 = prev2 = prev3 = INT_MIN ; while ( i < n1 && j < n2 && k < n3 ) { while ( ar1 [ i ] == prev1 && i < n1 ) i ++ ; while ( ar2 [ j ] == prev2 && j < n2 ) j ++ ; while ( ar3 [ k ] == prev3 && k < n3 ) k ++ ; if ( ar1 [ i ] == ar2 [ j ] && ar2 [ j ] == ar3 [ k ] ) { cout << ar1 [ i ] << " ▁ " ; prev1 = ar1 [ i ] ; prev2 = ar2 [ j ] ; prev3 = ar3 [ k ] ; i ++ ; j ++ ; k ++ ; } else if ( ar1 [ i ] < ar2 [ j ] ) { prev1 = ar1 [ i ] ; i ++ ; } else if ( ar2 [ j ] < ar3 [ k ] ) { prev2 = ar2 [ j ] ; j ++ ; } else { prev3 = ar3 [ k ] ; k ++ ; } } } int main ( ) { int ar1 [ ] = { 1 , 5 , 10 , 20 , 40 , 80 , 80 } ; int ar2 [ ] = { 6 , 7 , 20 , 80 , 80 , 100 } ; int ar3 [ ] = { 3 , 4 , 15 , 20 , 30 , 70 , 80 , 80 , 120 } ; int n1 = sizeof ( ar1 ) / sizeof ( ar1 [ 0 ] ) ; int n2 = sizeof ( ar2 ) / sizeof ( ar2 [ 0 ] ) ; int n3 = sizeof ( ar3 ) / sizeof ( ar3 [ 0 ] ) ; cout << " Common ▁ Elements ▁ are ▁ " ; findCommon ( ar1 , ar2 , ar3 , n1 , n2 , n3 ) ; return 0 ; }

Index/key variables: i, j, k
Accumulator variables: i, j, k, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int Jacobsthal ( int n ) { int dp [ n + 1 ] ; dp [ 0 ] = 0 ; dp [ 1 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) dp [ i ] = dp [ i - 1 ] + 2 * dp [ i - 2 ] ; return dp [ n ] ; } int Jacobsthal_Lucas ( int n ) { int dp [ n + 1 ] ; dp [ 0 ] = 2 ; dp [ 1 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) dp [ i ] = dp [ i - 1 ] + 2 * dp [ i - 2 ] ; return dp [ n ] ; } int main ( ) { int n = 5 ; cout << " Jacobsthal ▁ number : ▁ " << Jacobsthal ( n ) << endl ; cout << " Jacobsthal - Lucas ▁ number : ▁ " << Jacobsthal_Lucas ( n ) << endl ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int binarySearch ( int arr [ ] , int l , int r , int x ) { if ( r >= l ) { int mid = l + ( r - l ) / 2 ; if ( arr [ mid ] == x ) return mid ; if ( arr [ mid ] > x ) return binarySearch ( arr , l , mid - 1 , x ) ; return binarySearch ( arr , mid + 1 , r , x ) ; } return -1 ; } int findPos ( int arr [ ] , int key ) { int l = 0 , h = 1 ; int val = arr [ 0 ] ; while ( val < key ) { l = h ; h = 2 * h ; val = arr [ h ] ; } return binarySearch ( arr , l , h , key ) ; } int main ( ) { int arr [ ] = { 3 , 5 , 7 , 9 , 10 , 90 , 100 , 130 , 140 , 160 , 170 } ; int ans = findPos ( arr , 10 ) ; if ( ans == -1 ) cout << " Element ▁ not ▁ found " ; else cout << " Element ▁ found ▁ at ▁ index ▁ " << ans ; return 0 ; }

Index/key variables: h, mid
Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; int depth = 16 ; int ways [ 16 ] [ 16 ] [ 16 ] ; int stepNum ; void preprocess ( int list [ ] ) { ways [ 0 ] [ 8 ] [ 8 ] = 1 ; for ( int N = 1 ; N <= 14 ; N ++ ) { for ( int i = 1 ; i <= depth ; i ++ ) { for ( int j = 1 ; j <= depth ; j ++ ) { ways [ N ] [ i ] [ j ] = ways [ N - 1 ] [ i ] [ j + 1 ] + ways [ N - 1 ] [ i ] [ j - 1 ] + ways [ N - 1 ] [ i + 1 ] [ j ] + ways [ N - 1 ] [ i - 1 ] [ j ] + ways [ N - 1 ] [ i + 1 ] [ j - 1 ] + ways [ N - 1 ] [ i - 1 ] [ j + 1 ] ; } } list [ N ] = ways [ N ] [ 8 ] [ 8 ] ; } } int main ( ) { int list [ 15 ] ; preprocess ( list ) ; int steps = 4 ; cout << " Number ▁ of ▁ walks ▁ possible ▁ is / are ▁ " << list [ steps ] << endl ; return 0 ; }

Index/key variables: N, i, j, steps
Accumulator variables: N, i, j
Iterator variables: N, i, j
C++ program:
#include <bits/stdc++.h>
#define N  105
#define R  3
#define C  4
using namespace std ; int maximumValue ( int n , int m , int p , int grid [ R ] [ C ] ) { bool dp [ N ] [ N ] [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { for ( int k = 0 ; k < N ; k ++ ) dp [ i ] [ j ] [ k ] = false ; } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { for ( int k = grid [ i ] [ j ] ; k <= p ; k ++ ) { if ( i == 0 && j == 0 ) { if ( k == grid [ i ] [ j ] ) dp [ i ] [ j ] [ k ] = true ; } else if ( i == 0 ) { dp [ i ] [ j ] [ k ] = ( dp [ i ] [ j ] [ k ] dp [ i ] [ j - 1 ] [ k - grid [ i ] [ j ] ] ) ; } else if ( j == 0 ) { dp [ i ] [ j ] [ k ] = ( dp [ i ] [ j ] [ k ] dp [ i - 1 ] [ j ] [ k - grid [ i ] [ j ] ] ) ; } else { dp [ i ] [ j ] [ k ] = ( dp [ i ] [ j ] [ k ] dp [ i ] [ j - 1 ] [ k - grid [ i ] [ j ] ] ) ; dp [ i ] [ j ] [ k ] = ( dp [ i ] [ j ] [ k ] dp [ i - 1 ] [ j ] [ k - grid [ i ] [ j ] ] ) ; dp [ i ] [ j ] [ k ] = ( dp [ i ] [ j ] [ k ] dp [ i - 1 ] [ j - 1 ] [ k - grid [ i ] [ j ] ] ) ; } } } } int ans = 0 ; for ( ans = k ; ans >= 0 ; ans -- ) if ( dp [ n - 1 ] [ m - 1 ] [ ans ] ) break ; return ans ; } int main ( ) { int n = 3 , m = 4 , p = 9 ; int grid [ R ] [ C ] = { { 2 , 3 , 4 , 1 } , { 6 , 5 , 5 , 3 } , { 5 , 2 , 3 , 4 } } ; cout << maximumValue ( n , m , p , grid ) << endl ; return 0 ; }

Index/key variables: C, N, R, ans, i, j, k
Accumulator variables: ans, i, j, k, stdc
Iterator variables: ans, i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long answer ( int n ) { int dp [ n + 1 ] [ 10 ] ; if ( n == 1 ) return 10 ; for ( int j = 0 ; j <= 9 ; j ++ ) dp [ 1 ] [ j ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= 9 ; j ++ ) { if ( j == 0 ) dp [ i ] [ j ] = dp [ i - 1 ] [ j + 1 ] ; else if ( j == 9 ) dp [ i ] [ j ] = dp [ i - 1 ] [ j - 1 ] ; else dp [ i ] [ j ] = dp [ i - 1 ] [ j - 1 ] + dp [ i - 1 ] [ j + 1 ] ; } } long long sum = 0 ; for ( int j = 1 ; j <= 9 ; j ++ ) sum += dp [ n ] [ j ] ; return sum ; } int main ( ) { int n = 2 ; cout << answer ( n ) ; return 0 ; }

Index/key variables: i, j, n
Accumulator variables: i, j, stdc, sum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; string lcs ( string & X , string & Y ) { int m = X . length ( ) ; int n = Y . length ( ) ; int L [ m + 1 ] [ n + 1 ] ; for ( int i = 0 ; i <= m ; i ++ ) { for ( int j = 0 ; j <= n ; j ++ ) { if ( i == 0 j == 0 ) L [ i ] [ j ] = 0 ; else if ( X [ i - 1 ] == Y [ j - 1 ] ) L [ i ] [ j ] = L [ i - 1 ] [ j - 1 ] + 1 ; else L [ i ] [ j ] = max ( L [ i - 1 ] [ j ] , L [ i ] [ j - 1 ] ) ; } } int index = L [ m ] [ n ] ; string lcs ( index + 1 , ' \0' ) ; int i = m , j = n ; while ( i > 0 && j > 0 ) { if ( X [ i - 1 ] == Y [ j - 1 ] ) { lcs [ index - 1 ] = X [ i - 1 ] ; i -- ; j -- ; index -- ; } else if ( L [ i - 1 ] [ j ] > L [ i ] [ j - 1 ] ) i -- ; else j -- ; } return lcs ; } string longestPalSubseq ( string & str ) { string rev = str ; reverse ( rev . begin ( ) , rev . end ( ) ) ; return lcs ( str , rev ) ; } int main ( ) { string str = " GEEKSFORGEEKS " ; cout << longestPalSubseq ( str ) ; return 0 ; }

Index/key variables: i, j, m, n
Accumulator variables: i, index, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int productSubSeqCount ( vector < int > & arr , int k ) { int n = arr . size ( ) ; int dp [ k + 1 ] [ n + 1 ] ; memset ( dp , 0 , sizeof ( dp ) ) ; for ( int i = 1 ; i <= k ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { dp [ i ] [ j ] = dp [ i ] [ j - 1 ] ; if ( arr [ j - 1 ] <= i ) dp [ i ] [ j ] += dp [ i / arr [ j - 1 ] ] [ j - 1 ] + 1 ; } } return dp [ k ] [ n ] ; } int main ( ) { vector < int > A ; A . push_back ( 1 ) ; A . push_back ( 2 ) ; A . push_back ( 3 ) ; A . push_back ( 4 ) ; int k = 10 ; cout << productSubSeqCount ( A , k ) << endl ; }

Index/key variables: i, j, k, n
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <iostream>
using namespace std ; int findSingle ( int ar [ ] , int ar_size ) { int res = ar [ 0 ] ; for ( int i = 1 ; i < ar_size ; i ++ ) res = res ^ ar [ i ] ; return res ; } int main ( ) { int ar [ ] = { 2 , 3 , 5 , 4 , 5 , 3 , 4 } ; int n = sizeof ( ar ) / sizeof ( ar [ 0 ] ) ; cout << " Element ▁ occurring ▁ once ▁ is ▁ " << findSingle ( ar , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int dp [ 1001 ] [ 15001 ] ; void computeDpArray ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; ++ i ) { for ( int j = 1 ; j <= 15000 ; ++ j ) { if ( i == 0 ) dp [ i ] [ j ] = ( j == arr [ i ] ) ; else dp [ i ] [ j ] = dp [ i - 1 ] [ j ] + ( arr [ i ] == j ) ; } } } int countTripletSum ( int arr [ ] , int n ) { computeDpArray ( arr , n ) ; int ans = 0 ; for ( int i = 0 ; i < n - 2 ; ++ i ) { for ( int j = i + 1 ; j < n - 1 ; ++ j ) { for ( int k = 1 ; k <= 24 ; ++ k ) { int cube = k * k * k ; int rem = cube - ( arr [ i ] + arr [ j ] ) ; if ( rem > 0 ) ans += dp [ n - 1 ] [ rem ] - dp [ j ] [ rem ] ; } } } return ans ; } int main ( ) { int arr [ ] = { 2 , 5 , 1 , 20 , 6 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countTripletSum ( arr , n ) ; return 0 ; }

Index/key variables: i, j, rem
Accumulator variables: ans, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; int singleNumber ( int nums [ ] , int n ) { map < int , int > m ; long sum1 = 0 , sum2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( m [ nums [ i ] ] == 0 ) { sum1 += nums [ i ] ; m [ nums [ i ] ] ++ ; } sum2 += nums [ i ] ; } return 2 * ( sum1 ) - sum2 ; } int main ( ) { int a [ ] = { 2 , 3 , 5 , 4 , 5 , 3 , 4 } ; int n = 7 ; cout << singleNumber ( a , n ) << " STRNEWLINE " ; int b [ ] = { 15 , 18 , 16 , 18 , 16 , 15 , 89 } ; cout << singleNumber ( b , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum1, sum2
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPresent ( int B [ ] , int m , int x ) { for ( int i = 0 ; i < m ; i ++ ) if ( B [ i ] == x ) return true ; return false ; } int findMaxSubarraySumUtil ( int A [ ] , int B [ ] , int n , int m ) { int max_so_far = INT_MIN , curr_max = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( isPresent ( B , m , A [ i ] ) ) { curr_max = 0 ; continue ; } curr_max = max ( A [ i ] , curr_max + A [ i ] ) ; max_so_far = max ( max_so_far , curr_max ) ; } return max_so_far ; } void findMaxSubarraySum ( int A [ ] , int B [ ] , int n , int m ) { int maxSubarraySum = findMaxSubarraySumUtil ( A , B , n , m ) ; if ( maxSubarraySum == INT_MIN ) { cout << " Maximum ▁ Subarray ▁ Sum ▁ cant ▁ be ▁ found " << endl ; } else { cout << " The ▁ Maximum ▁ Subarray ▁ Sum ▁ = ▁ " << maxSubarraySum << endl ; } } int main ( ) { int A [ ] = { 3 , 4 , 5 , -4 , 6 } ; int B [ ] = { 1 , 8 , 5 } ; int n = sizeof ( A ) / sizeof ( A [ 0 ] ) ; int m = sizeof ( B ) / sizeof ( B [ 0 ] ) ; findMaxSubarraySum ( A , B , n , m ) ; return 0 ; }

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