dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define INF  1000000000
int minimumCost ( string s ) { int N = s . length ( ) ; vector < int > A , B ; for ( int i = 0 ; i < N ; i ++ ) { if ( s [ i ] == '1' ) { A . push_back ( i ) ; } else { B . push_back ( i ) ; } } int n1 = A . size ( ) ; int n2 = B . size ( ) ; int dp [ n1 + 1 ] [ n2 + 1 ] ; memset ( dp , 0 , sizeof ( dp ) ) ; for ( int i = 1 ; i <= n1 ; i ++ ) { dp [ i ] [ 0 ] = INF ; } for ( int i = 1 ; i <= n1 ; i ++ ) { for ( int j = 1 ; j <= n2 ; j ++ ) { dp [ i ] [ j ] = min ( dp [ i ] [ j - 1 ] , dp [ i - 1 ] [ j - 1 ] + abs ( A [ i - 1 ] - B [ j - 1 ] ) ) ; } } return dp [ n1 ] [ n2 ] ; } int main ( ) { string S = "1010001" ; cout << minimumCost ( S ) ; return 0 ; }

Index/key variables: i, j, n1, n2
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Query { int L , R ; } ; int MAX = 5000 ; void minDifference ( int arr [ ] , int n , Query q [ ] , int m ) { for ( int i = 0 ; i < m ; i ++ ) { int L = q [ i ] . L , R = q [ i ] . R ; int ans = MAX ; for ( int i = L ; i < R ; i ++ ) { ans = min ( ans , arr [ i ] ) ; } cout << ans << ' ' ; } } void minimumDifference ( int arr [ ] , Query q [ ] , int N , int m ) { int diff [ N ] ; for ( int i = 0 ; i < N - 1 ; i ++ ) diff [ i ] = abs ( arr [ i ] - arr [ i + 1 ] ) ; minDifference ( diff , N - 1 , q , m ) ; } int main ( ) { int arr [ ] = { 2 , 6 , 1 , 8 , 3 , 4 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; Query Q [ ] = { { 0 , 3 } , { 1 , 5 } , { 4 , 5 } } ; int M = sizeof ( Q ) / sizeof ( Q [ 0 ] ) ; minimumDifference ( arr , Q , N , M ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: i, stdc
Iterator variables: i
Class/struct names: Query
C++ program:
#include <bits/stdc++.h>
using namespace std ; int dp [ 100 ] [ 1 << 4 ] ; map < int , int > primeIndex ; int countOfNumbers ( int index , int mask , int N ) { if ( index == N + 1 ) { int countOfPrimes = __builtin_popcount ( mask ) ; if ( countOfPrimes == 4 ) { return 1 ; } return 0 ; } int & val = dp [ index ] [ mask ] ; if ( val != -1 ) { return val ; } val = 0 ; if ( index == 1 ) { for ( int digit = ( N == 1 ? 0 : 1 ) ; digit <= 9 ; ++ digit ) { if ( primeIndex . find ( digit ) != primeIndex . end ( ) ) { val += countOfNumbers ( index + 1 , mask | ( 1 << primeIndex [ digit ] ) , N ) ; } else { val += countOfNumbers ( index + 1 , mask , N ) ; } } } else { for ( int digit = 0 ; digit <= 9 ; ++ digit ) { if ( primeIndex . find ( digit ) != primeIndex . end ( ) ) { val += countOfNumbers ( index + 1 , mask | ( 1 << primeIndex [ digit ] ) , N ) ; } else { val += countOfNumbers ( index + 1 , mask , N ) ; } } } return val ; } int main ( ) { memset ( dp , -1 , sizeof dp ) ; primeIndex [ 2 ] = 0 ; primeIndex [ 3 ] = 1 ; primeIndex [ 5 ] = 2 ; primeIndex [ 7 ] = 3 ; int N = 4 ; cout << countOfNumbers ( 1 , 0 , N ) ; return 0 ; }

Index/key variables: digit, index, mask
Accumulator variables: stdc, val
Iterator variables: digit
C++ program:
#include <bits/stdc++.h>
using namespace std ; int dp [ 100 ] [ 1 << 5 ] [ 1 << 5 ] ; int countOfNumbers ( int index , int evenMask , int oddMask , int N ) { if ( index == N + 1 ) { int countOfEvenDigits = __builtin_popcount ( evenMask ) ; int countOfOddDigits = __builtin_popcount ( oddMask ) ; if ( countOfOddDigits == countOfEvenDigits ) { return 1 ; } return 0 ; } int & val = dp [ index ] [ evenMask ] [ oddMask ] ; if ( val != -1 ) return val ; val = 0 ; if ( index == 1 ) { for ( int digit = ( N == 1 ? 0 : 1 ) ; digit <= 9 ; ++ digit ) { if ( digit & 1 ) { val += countOfNumbers ( index + 1 , evenMask , oddMask | ( 1 << ( digit / 2 ) ) , N ) ; } else { val += countOfNumbers ( index + 1 , evenMask | ( 1 << ( digit / 2 ) ) , oddMask , N ) ; } } } else { for ( int digit = 0 ; digit <= 9 ; ++ digit ) { if ( digit & 1 ) { val += countOfNumbers ( index + 1 , evenMask , oddMask | ( 1 << ( digit / 2 ) ) , N ) ; } else { val += countOfNumbers ( index + 1 , evenMask | ( 1 << ( digit / 2 ) ) , oddMask , N ) ; } } } return val ; } void countNDigitNumber ( int N ) { memset ( dp , -1 , sizeof dp ) ; cout << countOfNumbers ( 1 , 0 , 0 , N ) ; } int main ( ) { int N = 3 ; countNDigitNumber ( N ) ; return 0 ; }

Index/key variables: evenMask, index, oddMask
Accumulator variables: stdc, val
Iterator variables: digit
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countMinSteps ( string A , string B , int N ) { vector < int > dp ( N + 1 , 0 ) ; for ( int i = 1 ; i <= N ; i ++ ) { if ( A [ i - 1 ] == B [ i - 1 ] ) { dp [ i ] = dp [ i - 1 ] ; } else { dp [ i ] = dp [ i - 1 ] + 1 ; } if ( i >= 2 && A [ i - 2 ] == B [ i - 1 ] && A [ i - 1 ] == B [ i - 2 ] ) { dp [ i ] = min ( dp [ i ] , dp [ i - 2 ] + 1 ) ; } } return dp [ N ] ; } int main ( ) { string A = "0101" ; string B = "0011" ; int N = A . length ( ) ; cout << countMinSteps ( A , B , N ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int dp [ 50 ] [ 1 << 10 ] [ 2 ] ; int countOfNumbers ( int digit , int mask , bool repeated , int n ) { if ( digit == n + 1 ) { if ( repeated == true ) { return 1 ; } return 0 ; } if ( repeated == true ) { return pow ( 10 , n - digit + 1 ) ; } int & val = dp [ digit ] [ mask ] [ repeated ] ; if ( val != -1 ) { return val ; } val = 0 ; if ( digit == 1 ) { for ( int i = ( n == 1 ? 0 : 1 ) ; i <= 9 ; ++ i ) { if ( mask & ( 1 << i ) ) { val += countOfNumbers ( digit + 1 , mask | ( 1 << i ) , 1 , n ) ; } else { val += countOfNumbers ( digit + 1 , mask | ( 1 << i ) , 0 , n ) ; } } } else { for ( int i = 0 ; i <= 9 ; ++ i ) { if ( mask & ( 1 << i ) ) { val += countOfNumbers ( digit + 1 , mask | ( 1 << i ) , 1 , n ) ; } else { val += countOfNumbers ( digit + 1 , mask | ( 1 << i ) , 0 , n ) ; } } } return val ; } void countNDigitNumber ( int N ) { memset ( dp , -1 , sizeof dp ) ; cout << countOfNumbers ( 1 , 0 , 0 , N ) ; } int main ( ) { int N = 2 ; countNDigitNumber ( N ) ; return 0 ; }

Index/key variables: digit, mask, repeated
Accumulator variables: stdc, val
Iterator variables: i
C++ program:
#include " bits / stdc + + . h "
using namespace std ; string getMaximum ( string & S , string & T ) { if ( S . find ( "0" ) != string :: npos ) return T ; if ( T . find ( "0" ) != string :: npos ) return S ; return ( S . length ( ) > T . length ( ) ? S : T ) ; } string recursion ( int arr [ ] , int idx , int N , int K , vector < vector < string > > & dp ) { if ( K == 0 ) { return " " ; } if ( K < 0 or idx == N ) { return "0" ; } if ( dp [ idx ] [ K ] != " - 1" ) return dp [ idx ] [ K ] ; string include = to_string ( idx + 1 ) + recursion ( arr , 0 , N , K - arr [ idx ] , dp ) ; string exclude = recursion ( arr , idx + 1 , N , K , dp ) ; return dp [ idx ] [ K ] = getMaximum ( include , exclude ) ; } string largestNumber ( int arr [ ] , int N , int K ) { vector < vector < string > > dp ( N + 1 , vector < string > ( K + 1 , " - 1" ) ) ; string ans = recursion ( arr , 0 , N , K , dp ) ; return ( ans == " " ? "0" : ans ) ; } int main ( ) { int arr [ ] = { 3 , 12 , 9 , 5 , 3 , 4 , 6 , 5 , 10 } ; int K = 14 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << largestNumber ( arr , N , K ) ; return 0 ; }

Index/key variables: K, idx
C++ program:
#include <bits/stdc++.h>
using namespace std ; int dp [ 100 ] [ 10 ] ; int countOfNumbers ( int digit , int prev , int n ) { if ( digit == n + 1 ) { return 1 ; } int & val = dp [ digit ] [ prev ] ; if ( val != -1 ) { return val ; } val = 0 ; if ( digit == 1 ) { for ( int i = ( n == 1 ? 0 : 1 ) ; i <= 9 ; ++ i ) { val += countOfNumbers ( digit + 1 , i , n ) ; } } else { for ( int i = 0 ; i <= 9 ; ++ i ) { if ( ( i & prev ) == 0 ) { val += countOfNumbers ( digit + 1 , i , n ) ; } } } return val ; } int main ( ) { memset ( dp , -1 , sizeof dp ) ; int N = 3 ; cout << countOfNumbers ( 1 , 0 , N ) << endl ; }

Index/key variables: digit, prev
Accumulator variables: stdc, val
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void preProcess ( vector < vector < int > > & mat , vector < vector < int > > & dp , int n , int m ) { for ( int i = 0 ; i < m ; i ++ ) { dp [ 0 ] [ i ] = mat [ 0 ] [ i ] ; } for ( int i = 1 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { dp [ i ] [ j ] = dp [ i - 1 ] [ j ] + mat [ i ] [ j ] ; } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 1 ; j < m ; j ++ ) { dp [ i ] [ j ] += dp [ i ] [ j - 1 ] ; } } } int sumQuery ( vector < vector < int > > dp , int tli , int tlj , int rbi , int rbj ) { int res = dp [ rbi ] [ rbj ] ; if ( tli > 0 ) res = res - dp [ tli - 1 ] [ rbj ] ; if ( tlj > 0 ) res = res - dp [ rbi ] [ tlj - 1 ] ; if ( tli > 0 && tlj > 0 ) res = res + dp [ tli - 1 ] [ tlj - 1 ] ; return res ; } vector < int > maxSubMatrixSumQueries ( vector < vector < int > > mat , int n , int m , vector < vector < int > > queries , int q ) { vector < vector < int > > dp ( n , vector < int > ( m ) ) ; preProcess ( mat , dp , n , m ) ; vector < int > maxSum ( ( int ) queries . size ( ) ) ; for ( int qi = 0 ; qi < q ; qi ++ ) { for ( int i = 0 ; i < n - queries [ qi ] [ 0 ] + 1 ; i ++ ) { for ( int j = 0 ; j < m - queries [ qi ] [ 1 ] + 1 ; j ++ ) { maxSum [ qi ] = max ( maxSum [ qi ] , sumQuery ( dp , i , j , i + queries [ qi ] [ 0 ] - 1 , j + queries [ qi ] [ 1 ] - 1 ) ) ; } } } return maxSum ; } int main ( ) { int n = 3 , m = 4 ; vector < vector < int > > mat = { { 1 , 2 , 3 , 9 } , { 4 , 5 , 6 , 2 } , { 8 , 3 , 2 , 6 } } ; int Q = 3 ; vector < vector < int > > Queries = { { 1 , 1 } , { 2 , 2 } , { 3 , 3 } } ; vector < int > maxSum = maxSubMatrixSumQueries ( mat , n , m , Queries , Q ) ; for ( int i = 0 ; i < Q ; i ++ ) { cout << maxSum [ i ] << " ▁ " ; } }

Index/key variables: i, j, qi, rbi, rbj
Accumulator variables: i, j, qi, stdc
Iterator variables: i, j, qi
C++ program:
#include <bits/stdc++.h>
using namespace std ; int dp [ 1005 ] [ 1005 ] ; int KvisibleFromLeft ( int N , int K ) { if ( dp [ N ] [ K ] != -1 ) return dp [ N ] [ K ] ; if ( N == K ) return dp [ N ] [ K ] = 1 ; if ( K == 1 ) { int ans = 1 ; for ( int i = 1 ; i < N ; i ++ ) ans *= i ; return dp [ N ] [ K ] = ans ; } return dp [ N ] [ K ] = KvisibleFromLeft ( N - 1 , K - 1 ) + ( N - 1 ) * KvisibleFromLeft ( N - 1 , K ) ; } int main ( ) { int N = 5 , K = 2 ; memset ( dp , -1 , sizeof ( dp ) ) ; cout << KvisibleFromLeft ( N , K ) << endl ; return 0 ; }

Index/key variables: K, N
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long int power ( long long int x , long long int y , long long int p ) { long long int res = 1ll ; x = x % p ; if ( x == 0 ) return 0 ; while ( y > 0 ) { if ( y & 1 ) res = ( res * x ) % p ; y = y >> 1 ; x = ( x * x ) % p ; } return res ; } int kvowelwords ( int N , int K ) { long long int i , j ; long long int MOD = 1000000007 ; long long int dp [ N + 1 ] [ K + 1 ] = { 0 } ; long long int sum = 1 ; for ( i = 1 ; i <= N ; i ++ ) { dp [ i ] [ 0 ] = sum * 21 ; dp [ i ] [ 0 ] %= MOD ; sum = dp [ i ] [ 0 ] ; for ( j = 1 ; j <= K ; j ++ ) { if ( j > i ) dp [ i ] [ j ] = 0 ; else if ( j == i ) { dp [ i ] [ j ] = power ( 5ll , i , MOD ) ; } else { dp [ i ] [ j ] = dp [ i - 1 ] [ j - 1 ] * 5 ; } dp [ i ] [ j ] %= MOD ; sum += dp [ i ] [ j ] ; sum %= MOD ; } } return sum ; } int main ( ) { int N = 3 ; int K = 3 ; cout << kvowelwords ( N , K ) << endl ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc, sum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void maxBoundary ( int N , vector < pair < int , int > > V ) { int dp [ N ] [ 2 ] ; memset ( dp , 0 , sizeof ( dp ) ) ; dp [ 0 ] [ 0 ] = V [ 0 ] . first ; dp [ 0 ] [ 1 ] = V [ 0 ] . second ; for ( int i = 1 ; i < N ; i ++ ) { dp [ i ] [ 0 ] = V [ i ] . first ; int height1 = abs ( V [ i - 1 ] . second - V [ i ] . second ) ; int height2 = abs ( V [ i - 1 ] . first - V [ i ] . second ) ; dp [ i ] [ 0 ] += max ( height1 + dp [ i - 1 ] [ 0 ] , height2 + dp [ i - 1 ] [ 1 ] ) ; dp [ i ] [ 1 ] = V [ i ] . second ; int vertical1 = abs ( V [ i ] . first - V [ i - 1 ] . second ) ; int vertical2 = abs ( V [ i ] . first - V [ i - 1 ] . first ) ; dp [ i ] [ 1 ] += max ( vertical1 + dp [ i - 1 ] [ 0 ] , vertical2 + dp [ i - 1 ] [ 1 ] ) ; } cout << max ( dp [ N - 1 ] [ 0 ] , dp [ N - 1 ] [ 1 ] ) ; } int main ( ) { int N = 5 ; vector < pair < int , int > > V = { { 2 , 5 } , { 3 , 8 } , { 1 , 10 } , { 7 , 14 } , { 2 , 5 } } ; maxBoundary ( N , V ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maximumSum ( vector < int > A , int N , int K , int D ) { vector < vector < vector < int > > > dp ( N + 1 , vector < vector < int > > ( K + 1 , vector < int > ( D + 1 , -1 ) ) ) ; for ( int i = 1 ; i <= N ; i ++ ) { int element = A [ i - 1 ] ; int mod = A [ i - 1 ] % D ; dp [ i ] = dp [ i - 1 ] ; for ( int j = 1 ; j <= K ; j ++ ) { dp [ i ] [ j ] [ mod ] = max ( dp [ i ] [ j ] [ mod ] , element ) ; for ( int p = 0 ; p < D ; p ++ ) { if ( dp [ i - 1 ] [ j - 1 ] [ p ] != -1 ) { dp [ i ] [ j ] [ ( p + mod ) % D ] = max ( dp [ i ] [ j ] [ ( p + mod ) % D ] , dp [ i - 1 ] [ j - 1 ] [ p ] + element ) ; } } } } if ( dp [ N ] [ K ] [ 0 ] == -1 ) return 0 ; return dp [ N ] [ K ] [ 0 ] ; } int main ( ) { int N = 5 , K = 3 , D = 7 ; vector < int > A = { 1 , 11 , 5 , 5 , 18 } ; cout << maximumSum ( A , N , K , D ) << endl ; return 0 ; }

Index/key variables: K, N, i, j, mod, p
Accumulator variables: i, j, p, stdc
Iterator variables: i, j, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; int NumberOfways ( int N , int K ) { vector < int > dp ( N + 1 , 0 ) ; dp [ 0 ] = 1 ; for ( int row = 1 ; row < K + 1 ; row ++ ) { for ( int col = 1 ; col < N + 1 ; col ++ ) { if ( col >= row ) dp [ col ] = dp [ col ] + dp [ col - row ] ; } } return ( dp [ N ] ) ; } int main ( ) { int N = 8 ; int K = 2 ; cout << ( NumberOfways ( N , K ) ) ; }

Index/key variables: N, col
Accumulator variables: col, row, stdc
Iterator variables: col, row
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findAPSequence ( int arr [ ] , int N , int Q [ ] [ 2 ] , int M ) { int dp [ N + 5 ] = { 0 } ; for ( int i = 0 ; i + 1 < N ; ) { int j = i + 1 ; while ( j + 1 < N && arr [ j + 1 ] - arr [ j ] == arr [ i + 1 ] - arr [ i ] ) j ++ ; for ( int k = i ; k < j ; k ++ ) { dp [ k ] = j - k ; } i = j ; } for ( int i = 0 ; i < M ; i ++ ) { if ( dp [ Q [ i ] [ 0 ] ] >= Q [ i ] [ 1 ] - Q [ i ] [ 0 ] ) { cout << " Yes " << endl ; } else { cout << " No " << endl ; } } } int main ( ) { int arr [ ] = { 1 , 3 , 5 , 7 , 6 , 5 , 4 , 1 } ; int Q [ ] [ 2 ] = { { 0 , 3 } , { 3 , 4 } , { 2 , 4 } } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int M = sizeof ( Q ) / sizeof ( Q [ 0 ] ) ; findAPSequence ( arr , N , Q , M ) ; return 0 ; }

Index/key variables: i, j, k
Accumulator variables: i, j, k, stdc
Iterator variables: i, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; int dp [ 100 ] [ 100 ] [ 100 ] ; int minSumDifference ( int * arr , int n , int k1 , int k2 , int sum1 , int sum2 ) { if ( n < 0 ) { if ( k1 == 0 && k2 == 0 ) { return abs ( sum1 - sum2 ) ; } else { return INT_MAX ; } } if ( dp [ n ] [ sum1 ] [ sum2 ] != -1 ) { return dp [ n ] [ sum1 ] [ sum2 ] ; } int op1 = INT_MAX ; int op2 = INT_MAX ; int op3 = INT_MAX ; if ( k1 > 0 ) { op1 = minSumDifference ( arr , n - 1 , k1 - 1 , k2 , sum1 + arr [ n ] , sum2 ) ; } if ( k2 > 0 ) { op2 = minSumDifference ( arr , n - 1 , k1 , k2 - 1 , sum1 , sum2 + arr [ n ] ) ; } op3 = minSumDifference ( arr , n - 1 , k1 , k2 , sum1 , sum2 ) ; dp [ n ] [ sum1 ] [ sum2 ] = min ( op1 , min ( op2 , op3 ) ) ; return dp [ n ] [ sum1 ] [ sum2 ] ; } int main ( ) { int arr [ ] = { 12 , 3 , 5 , 6 , 7 , 17 } ; int K = 2 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; memset ( dp , -1 , sizeof ( dp ) ) ; cout << minSumDifference ( arr , N - 1 , K , K , 0 , 0 ) ; return 0 ; }

Index/key variables: n, sum1, sum2
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int find ( int A , int B , int C , int N ) { int arr [ N ] ; arr [ 0 ] = A ; arr [ 1 ] = B ; arr [ 2 ] = C ; for ( int i = 3 ; i < N ; i ++ ) { arr [ i ] = arr [ i - 1 ] + arr [ i - 2 ] + arr [ i - 3 ] ; } return arr [ N - 1 ] ; } int main ( ) { int A = 1 , B = 3 , C = 2 , N = 4 ; cout << ( find ( A , B , C , N ) ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxResult ( int arr [ ] , int k , int n ) { int dp [ n ] = { 0 } ; dp [ 0 ] = arr [ 0 ] ; deque < pair < int , int > > q ; q . push_back ( { arr [ 0 ] , 0 } ) ; for ( int i = 1 ; i < n ; i ++ ) { dp [ i ] = arr [ i ] + q . front ( ) . first ; while ( q . size ( ) > 0 and q . back ( ) . first < dp [ i ] ) q . pop_back ( ) ; q . push_back ( { dp [ i ] , i } ) ; if ( i - k == q . front ( ) . second ) q . pop_front ( ) ; } return dp [ n - 1 ] ; } int main ( ) { int arr [ ] = { 10 , -5 , -2 , 4 , 0 , 3 } ; int K = 3 ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << maxResult ( arr , K , n ) ; }

Index/key variables: i, n
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void daysToCure ( int arr [ ] , int N , int P ) { int risk = 0 ; int normal_risk = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] >= 60 arr [ i ] <= 10 ) { risk ++ ; } else { normal_risk ++ ; } } int days = ( risk / P ) + ( risk % P > 0 ) + ( normal_risk / P ) + ( normal_risk % P > 0 ) ; cout << days ; } int main ( ) { int arr [ ] = { 9 , 80 , 27 , 72 , 79 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int P = 2 ; daysToCure ( arr , N , P ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, normal_risk, risk, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define M  100
int cntNum ( string X , int i , int prod , int K , int st , int tight , int dp [ M ] [ M ] [ 2 ] [ 2 ] ) { if ( i >= X . length ( ) prod > K ) { return prod == K ; } if ( dp [ prod ] [ i ] [ tight ] [ st ] != -1 ) { return dp [ prod ] [ i ] [ tight ] [ st ] ; } int res = 0 ; int end = tight ? X [ i ] - '0' : 9 ; for ( int j = 0 ; j <= end ; j ++ ) { if ( j == 0 && ! st ) { res += cntNum ( X , i + 1 , prod , K , false , ( tight & ( j == end ) ) , dp ) ; } else { res += cntNum ( X , i + 1 , prod * j , K , true , ( tight & ( j == end ) ) , dp ) ; } return dp [ prod ] [ i ] [ tight ] [ st ] = res ; } int UtilCntNumRange ( int L , int R , int K ) { string str = to_string ( R ) ; int dp [ M ] [ M ] [ 2 ] [ 2 ] ; memset ( dp , -1 , sizeof ( dp ) ) ; int cntR = cntNum ( str , 0 , 1 , K , false , true , dp ) ; str = to_string ( L - 1 ) ; memset ( dp , -1 , sizeof ( dp ) ) ; int cntL = cntNum ( str , 0 , 1 , K , false , true , dp ) ; return ( cntR - cntL ) ; } int main ( ) { int L = 20 , R = 10000 , K = 14 ; cout << UtilCntNumRange ( L , R , K ) ; }

Index/key variables: M, i, prod, st, tight
Accumulator variables: j, res, stdc
Iterator variables: j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countVowelPermutation ( int n ) { int MOD = ( int ) ( 1e9 + 7 ) ; long dp [ n + 1 ] [ 5 ] ; for ( int i = 0 ; i < 5 ; i ++ ) { dp [ 1 ] [ i ] = 1 ; } vector < vector < int > > relation = { { 1 } , { 0 , 2 } , { 0 , 1 , 3 , 4 } , { 2 , 4 } , { 0 } } ; for ( int i = 1 ; i < n ; i ++ ) { for ( int u = 0 ; u < 5 ; u ++ ) { dp [ i + 1 ] [ u ] = 0 ; for ( int v : relation [ u ] ) { dp [ i + 1 ] [ u ] += dp [ i ] [ v ] % MOD ; } } } long ans = 0 ; for ( int i = 0 ; i < 5 ; i ++ ) { ans = ( ans + dp [ n ] [ i ] ) % MOD ; } return ( int ) ans ; } int main ( ) { int N = 2 ; cout << countVowelPermutation ( N ) ; }

Index/key variables: i, n, u, v
Accumulator variables: i, stdc, u
Iterator variables: i, u, v
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int N = 1e5 + 5 ; vector < int > adj [ N ] ; vector < int > answer ( N ) ; void addEdgesToGraph ( int Edges [ ] [ 2 ] , int N ) { for ( int i = 0 ; i < N - 1 ; i ++ ) { int u = Edges [ i ] [ 0 ] ; int v = Edges [ i ] [ 1 ] ; adj [ u ] . push_back ( v ) ; adj [ v ] . push_back ( u ) ; } } void DFS ( int node , int parent , int Val [ ] ) { answer [ node ] = Val [ node ] ; for ( int child : adj [ node ] ) { if ( child == parent ) continue ; DFS ( child , node , Val ) ; answer [ node ] = ( answer [ node ] answer [ child ] ) ; } } void preprocess ( int Val [ ] ) { DFS ( 1 , -1 , Val ) ; } void findSubtreeOR ( int Queries [ ] , int Q , int Val [ ] ) { preprocess ( Val ) ; for ( int i = 0 ; i < Q ; i ++ ) { cout << answer [ Queries [ i ] ] << ' ▁ ' ; } } void findSubtreeORUtil ( int N , int Edges [ ] [ 2 ] , int Val [ ] , int Queries [ ] , int Q ) { addEdgesToGraph ( Edges , N ) ; findSubtreeOR ( Queries , Q , Val ) ; } int main ( ) { int N = 5 ; int Edges [ ] [ 2 ] = { { 1 , 2 } , { 1 , 3 } , { 3 , 4 } , { 3 , 5 } } ; int Val [ ] = { 0 , 2 , 3 , 4 , 8 , 16 } ; int Queries [ ] = { 2 , 3 , 1 } ; int Q = sizeof ( Queries ) / sizeof ( Queries [ 0 ] ) ; findSubtreeORUtil ( N , Edges , Val , Queries , Q ) ; return 0 ; }

Index/key variables: N, child, i, node, u, v
Accumulator variables: i, stdc
Iterator variables: child, i
C++ program:
#include <iostream>
using namespace std ; int max ( int a , int b ) { return a > b ? a : b ; } int maximumsum ( int arr [ ] [ 4 ] , int K , int N , int M ) { int sum = 0 , maxSum ; int i , j , k ; int dp [ K + 1 ] [ N + 1 ] ; for ( i = 0 ; i <= N ; i ++ ) dp [ 0 ] [ i ] = 0 ; for ( i = 0 ; i <= K ; i ++ ) dp [ i ] [ 0 ] = 0 ; for ( i = 1 ; i <= K ; i ++ ) { for ( j = 0 ; j < N ; j ++ ) { sum = 0 ; maxSum = dp [ i ] [ j ] ; for ( k = 1 ; k <= M && k <= i ; k ++ ) { sum += arr [ j ] [ k - 1 ] ; maxSum = max ( maxSum , sum + dp [ i - k ] [ j ] ) ; } dp [ i ] [ j + 1 ] = maxSum ; } } return dp [ K ] [ N ] ; } int main ( ) { int arr [ ] [ 4 ] = { { 10 , 10 , 100 , 30 } , { 80 , 50 , 10 , 50 } } ; int N = 2 , M = 4 ; int K = 5 ; cout << maximumsum ( arr , K , N , M ) ; return 0 ; }

Index/key variables: K, N, i, j
Accumulator variables: i, j, k, sum
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; void FindSub ( set < string > & sub , set < char > & ch , string str , string res , int i ) { if ( i == str . length ( ) ) { sub . insert ( res ) ; return ; } if ( ! ch . count ( str [ i ] ) ) { ch . insert ( str [ i ] ) ; res . push_back ( str [ i ] ) ; FindSub ( sub , ch , str , res , i + 1 ) ; res . pop_back ( ) ; ch . erase ( str [ i ] ) ; } FindSub ( sub , ch , str , res , i + 1 ) ; } void printSubwithUniqueChar ( string str , int N ) { set < string > sub ; set < char > ch ; FindSub ( sub , ch , str , " " , 0 ) ; for ( auto subString : sub ) { cout << subString << " ▁ " ; } } int main ( ) { string str = " abac " ; int N = str . length ( ) ; printSubwithUniqueChar ( str , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: stdc
Iterator variables: subString
C++ program:
#include <bits/stdc++.h>
using namespace std ; void waysToArrangeKLengthStrings ( int N , int K ) { int column_sum [ N + 1 ] = { 0 } , i , j ; int dp [ K + 1 ] [ N + 1 ] = { 0 } ; for ( i = 0 ; i <= N ; i ++ ) { dp [ 0 ] [ i ] = 1 ; column_sum [ i ] = 1 ; } for ( i = 1 ; i <= K ; i ++ ) { for ( j = 1 ; j <= N ; j ++ ) { dp [ i ] [ j ] += column_sum [ j - 1 ] ; column_sum [ j ] += dp [ i ] [ j ] ; } } cout << dp [ K ] [ N ] ; } int main ( ) { int N = 5 , K = 2 ; waysToArrangeKLengthStrings ( N , K ) ; return 0 ; }

Index/key variables: K, N, i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findNumberOfStrings ( int n ) { vector < vector < int > > DP ( n + 1 , vector < int > ( 6 ) ) ; DP [ 1 ] [ 1 ] = 1 ; for ( int i = 1 ; i < n + 1 ; i ++ ) { for ( int j = 1 ; j < 6 ; j ++ ) { if ( i == 1 ) { DP [ i ] [ j ] = DP [ i ] [ j - 1 ] + 1 ; } else { DP [ i ] [ j ] = DP [ i ] [ j - 1 ] + DP [ i - 1 ] [ j ] ; } } } return DP [ n ] [ 5 ] ; } int main ( ) { int N = 2 ; cout << findNumberOfStrings ( N ) ; return 0 ; }

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