dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; void countNums ( int N ) { int l = ( int ) pow ( 10 , N - 1 ) ; int r = ( int ) pow ( 10 , N ) - 1 ; int count = 0 ; for ( int i = l ; i <= r ; i ++ ) { int xorr = 0 , temp = i ; while ( temp > 0 ) { xorr = xorr ^ ( temp % 10 ) ; temp /= 10 ; } if ( xorr <= 9 ) count ++ ; } cout << count ; } int main ( ) { int N = 2 ; countNums ( N ) ; }

Accumulator variables: count, i, stdc, temp
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void main_fun ( int arr [ ] , int n ) { int dp [ 4 ] [ n ] ; memset ( dp , 0 , sizeof ( dp [ 0 ] [ 0 ] * 4 * n ) ) ; if ( arr [ 0 ] == 0 ) dp [ 0 ] [ 0 ] = 1 ; else dp [ 1 ] [ 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] == 0 ) dp [ 0 ] [ i ] = dp [ 0 ] [ i - 1 ] + 1 ; else dp [ 0 ] [ i ] = dp [ 0 ] [ i - 1 ] ; } for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] == 1 ) dp [ 1 ] [ i ] = max ( dp [ 1 ] [ i - 1 ] + 1 , dp [ 0 ] [ i - 1 ] + 1 ) ; else dp [ 1 ] [ i ] = dp [ 1 ] [ i - 1 ] ; } for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] == 0 ) { dp [ 2 ] [ i ] = max ( dp [ 2 ] [ i - 1 ] + 1 , max ( dp [ 1 ] [ i - 1 ] + 1 , dp [ 0 ] [ i - 1 ] + 1 ) ) ; } else dp [ 2 ] [ i ] = dp [ 2 ] [ i - 1 ] ; } for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] == 1 ) { dp [ 3 ] [ i ] = max ( dp [ 3 ] [ i - 1 ] + 1 , max ( dp [ 2 ] [ i - 1 ] + 1 , max ( dp [ 1 ] [ i - 1 ] + 1 , dp [ 0 ] [ i - 1 ] + 1 ) ) ) ; } else dp [ 3 ] [ i ] = dp [ 3 ] [ i - 1 ] ; } int ans = max ( dp [ 2 ] [ n - 1 ] , max ( dp [ 1 ] [ n - 1 ] , max ( dp [ 0 ] [ n - 1 ] , dp [ 3 ] [ n - 1 ] ) ) ) ; cout << ( ans ) ; } int main ( ) { int n = 4 ; int arr [ ] = { 0 , 1 , 0 , 1 } ; main_fun ( arr , n ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void SubarrayWithMaxSum ( vector < int > & nums ) { int endIndex , currMax = nums [ 0 ] ; int globalMax = nums [ 0 ] ; for ( int i = 1 ; i < nums . size ( ) ; ++ i ) { currMax = max ( nums [ i ] , nums [ i ] + currMax ) ; if ( currMax > globalMax ) { globalMax = currMax ; endIndex = i ; } } int startIndex = endIndex ; while ( startIndex >= 0 ) { globalMax -= nums [ startIndex ] ; if ( globalMax == 0 ) break ; startIndex -- ; } for ( int i = startIndex ; i <= endIndex ; ++ i ) { cout << nums [ i ] << " ▁ " ; } } int main ( ) { vector < int > arr = { -2 , -5 , 6 , -2 , -3 , 1 , 5 , -6 } ; SubarrayWithMaxSum ( arr ) ; return 0 ; }

Index/key variables: i, startIndex
Accumulator variables: globalMax, startIndex, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; static vector < int > primes ; int M = 100005 ; void sieve ( ) { bool mark [ M ] ; for ( int i = 0 ; i < M ; i ++ ) mark [ i ] = false ; for ( int i = 2 ; i < M ; i ++ ) mark [ i ] = true ; for ( int i = 2 ; i * i < M ; i ++ ) { if ( mark [ i ] ) { for ( int j = i * i ; j < M ; j += i ) mark [ j ] = false ; } } for ( int i = 2 ; i < M ; i ++ ) if ( mark [ i ] ) primes . push_back ( i ) ; } void countPrimonacci ( int l , int r ) { vector < int > dp ; dp . push_back ( 1 ) ; dp . push_back ( 1 ) ; int i = 2 ; set < int > s ; while ( true ) { int x = 0 ; for ( int j = 0 ; j < primes . size ( ) ; j ++ ) { int p = primes [ j ] ; if ( p >= i ) break ; x += dp [ i - p ] ; } if ( x >= l && x <= r ) s . insert ( x ) ; if ( x > r ) break ; dp . push_back ( x ) ; i ++ ; } cout << s . size ( ) ; } int main ( ) { sieve ( ) ; int L = 1 , R = 10 ; countPrimonacci ( L , R ) ; }

Index/key variables: M, i, j
Accumulator variables: i, j, stdc, x
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int N = 1e5 + 5 ; const int MOD = 1000000007 ; long int dp [ N ] ; void countStrings ( int K , vector < vector < int > > Q ) { dp [ 0 ] = 1 ; for ( int i = 1 ; i < N ; i ++ ) { dp [ i ] = dp [ i - 1 ] ; if ( i >= K ) dp [ i ] = ( dp [ i ] + dp [ i - K ] ) % MOD ; } for ( int i = 1 ; i < N ; i ++ ) { dp [ i ] = ( dp [ i ] + dp [ i - 1 ] ) % MOD ; } for ( int i = 0 ; i < Q . size ( ) ; i ++ ) { long int ans = dp [ Q [ i ] [ 1 ] ] - dp [ Q [ i ] [ 0 ] - 1 ] ; if ( ans < 0 ) ans = ans + MOD ; cout << ans << endl ; } } int main ( ) { int K = 3 ; vector < vector < int > > Q = { { 1 , 4 } , { 3 , 7 } } ; countStrings ( K , Q ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
#include <bits/stdc++.h>
using namespace std ; long minSum ( int n , int num [ ] , int price [ ] ) { long dp [ n ] ; for ( int i = 0 ; i < n ; i ++ ) dp [ i ] = INT_MAX ; long ans = INT_MAX ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( num [ j ] > num [ i ] ) { dp [ j ] = ( long ) min ( ( long ) dp [ j ] , ( long ) price [ i ] + ( long ) price [ j ] ) ; ans = min ( ans , ( long ) dp [ i ] + ( long ) price [ j ] ) ; } } } return ans != INT_MAX ? ans : -1 ; } int main ( ) { int num [ ] = { 2 , 4 , 6 , 7 , 8 } ; int price [ ] = { 10 , 20 , 100 , 20 , 40 } ; int n = sizeof ( price ) / sizeof ( price [ 0 ] ) ; cout << ( minSum ( n , num , price ) ) ; }

Index/key variables: i, j, n
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; unsigned long int binomialCoeff ( unsigned int n , unsigned int k ) { unsigned long int res = 1 ; if ( k > n - k ) k = n - k ; for ( int i = 0 ; i < k ; ++ i ) { res *= ( n - i ) ; res /= ( i + 1 ) ; } return res ; } unsigned long int countStrings ( unsigned int N ) { if ( N % 2 == 1 ) return 0 ; else { N /= 2 ; unsigned long int c = binomialCoeff ( 2 * N , N ) ; return c / ( N + 1 ) ; } } int main ( ) { int N = 6 ; cout << countStrings ( N ) << " ▁ " ; return 0 ; }

Accumulator variables: N, res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int solve ( int n , int k , int mod , int dp [ ] ) { if ( n < 0 ) return 0 ; if ( n == 0 ) return 1 ; if ( dp [ n ] != -1 ) return dp [ n ] ; int cnt = 0 ; for ( int i = 2 ; i <= k ; i += 2 ) { cnt = ( cnt % mod + solve ( n - i , k , mod , dp ) % mod ) % mod ; } dp [ n ] = cnt ; return cnt ; } int main ( ) { const int mod = 1e9 + 7 ; int n = 4 , k = 2 ; int dp [ n + 1 ] ; memset ( dp , -1 , sizeof ( dp ) ) ; int ans = solve ( n , k , mod , dp ) ; cout << ans << ' ' ; return 0 ; }

Index/key variables: n
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long f [ 12 ] ; void fact ( ) { f [ 0 ] = f [ 1 ] = 1 ; for ( int i = 2 ; i <= 10 ; i ++ ) f [ i ] = i * 1LL * f [ i - 1 ] ; } void solve ( int arr [ ] , int n , int k ) { fact ( ) ; int even = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 == 0 ) even ++ ; } if ( k > even ) cout << 0 << endl ; else { cout << f [ even ] / ( f [ k ] * f [ even - k ] ) ; } } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int n = sizeof arr / sizeof arr [ 0 ] ; int k = 1 ; solve ( arr , n , k ) ; return 0 ; }

Index/key variables: even, i, k
Accumulator variables: even, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MOD  1000000007
int nCrModp ( int n , int r ) { if ( n % 2 == 1 ) { return -1 ; } int C [ r + 1 ] ; memset ( C , 0 , sizeof ( C ) ) ; C [ 0 ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = min ( i , r ) ; j > 0 ; j -- ) C [ j ] = ( C [ j ] + C [ j - 1 ] ) % MOD ; } return C [ r ] ; } int main ( ) { int N = 6 ; cout << nCrModp ( N , N / 2 ) ; return 0 ; }

Index/key variables: j, r
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printMinOperations ( int N ) { int dp [ N + 1 ] ; for ( int i = 0 ; i < N + 1 ; i ++ ) dp [ i ] = N ; dp [ 1 ] = 0 ; for ( int i = 2 ; i < N + 1 ; i ++ ) { if ( i % 2 == 0 && dp [ i ] > dp [ i / 2 ] + 1 ) dp [ i ] = dp [ i / 2 ] + 1 ; if ( i % 3 == 0 && dp [ i ] > dp [ i / 3 ] + 1 ) dp [ i ] = dp [ i / 3 ] + 1 ; if ( dp [ i ] > dp [ i - 1 ] + 1 ) dp [ i ] = dp [ i - 1 ] + 1 ; } cout << dp [ N ] << endl ; vector < int > seq ; while ( N > 1 ) { seq . push_back ( N ) ; if ( dp [ N - 1 ] == dp [ N ] - 1 ) N = N - 1 ; else if ( N % 2 == 0 && dp [ N / 2 ] == dp [ N ] - 1 ) N = N / 2 ; else N = N / 3 ; } seq . push_back ( 1 ) ; for ( int i = seq . size ( ) - 1 ; i >= 0 ; i -- ) cout << seq [ i ] << " ▁ " ; cout << endl ; } int main ( ) { int X = 96234 ; printMinOperations ( X ) ; }

Index/key variables: N, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void maxLength ( int arr [ ] , int n ) { vector < int > dp ( n , 1 ) ; for ( int i = n - 1 ; i > 1 ; i -- ) { for ( int j = 1 ; j <= sqrt ( i ) ; j ++ ) { if ( i % j == 0 ) { int s = i / j ; if ( s == j ) { if ( arr [ i ] > arr [ s ] ) { dp [ s ] = max ( dp [ i ] + 1 , dp [ s ] ) ; } } else { if ( s != i && arr [ i ] > arr [ s ] ) dp [ s ] = max ( dp [ i ] + 1 , dp [ s ] ) ; if ( arr [ i ] > arr [ j ] ) { dp [ j ] = max ( dp [ i ] + 1 , dp [ j ] ) ; } } } } } int max = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( dp [ i ] > max ) max = dp [ i ] ; } cout << max << " STRNEWLINE " ; } int main ( ) { int arr [ ] = { 0 , 1 , 4 , 2 , 3 , 6 , 4 , 9 } ; int size = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; maxLength ( arr , size ) ; return 0 ; }

Index/key variables: i, j, s
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxProfit ( int price [ ] , int n ) { int buy1 , profit1 , buy2 , profit2 ; buy1 = buy2 = INT_MAX ; profit1 = profit2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { buy1 = min ( buy1 , price [ i ] ) ; profit1 = max ( profit1 , price [ i ] - buy1 ) ; buy2 = min ( buy2 , price [ i ] - profit1 ) ; profit2 = max ( profit2 , price [ i ] - buy2 ) ; } return profit2 ; } int main ( ) { int price [ ] = { 2 , 30 , 15 , 10 , 8 , 25 , 80 } ; int n = sizeof ( price ) / sizeof ( price [ 0 ] ) ; cout << " Maximum ▁ Profit ▁ = ▁ " << maxProfit ( price , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMaximumScore ( vector < int > a , int n ) { unordered_map < int , int > freq ; for ( int i = 0 ; i < n ; i ++ ) { freq [ a [ i ] ] ++ ; } vector < int > dp ( * max_element ( a . begin ( ) , a . end ( ) ) + 1 , 0 ) ; dp [ 0 ] = 0 ; dp [ 1 ] = freq [ 1 ] ; for ( int i = 2 ; i < dp . size ( ) ; i ++ ) dp [ i ] = max ( dp [ i - 1 ] , dp [ i - 2 ] + freq [ i ] * i ) ; return dp [ dp . size ( ) - 1 ] ; } int main ( ) { int n ; n = 3 ; vector < int > a { 1 , 2 , 3 } ; cout << findMaximumScore ( a , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maximizeSum ( int arr [ ] , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i = i + 2 ) sum += arr [ i ] ; int leftDP [ n / 2 ] ; int rightDP [ n / 2 ] ; int c = 0 ; for ( int i = 1 ; i < n ; i = i + 2 ) { int leftDiff = arr [ i ] - arr [ i - 1 ] ; if ( c - 1 < 0 ) leftDP = leftDiff ; else { if ( leftDP > 0 ) leftDP = leftDiff + leftDP ; else leftDP [ i ] = leftDiff ; } int rightDiff ; if ( i + 1 >= n ) rightDiff = 0 ; else rightDiff = arr [ i ] - arr [ i + 1 ] ; if ( c - 1 < 0 ) rightDP = rightDiff ; else { if ( rightDP > 0 ) rightDP = rightDiff + rightDP ; else rightDP = rightDiff ; } c ++ ; } int maxi = 0 ; for ( int i = 0 ; i < n / 2 ; i ++ ) { maxi = max ( maxi , max ( leftDP [ i ] , rightDP [ i ] ) ) ; } return maxi + sum ; } int main ( ) { int arr [ ] = { 7 , 8 , 4 , 5 , 7 , 6 , 8 , 9 , 7 , 3 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int ans = maximizeSum ( arr , n ) ; cout << ( ans ) ; }

Index/key variables: i
Accumulator variables: c, i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int validsubsequences ( int arr [ ] , int n ) { long long int dp [ n + 1 ] [ 2 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) { dp [ i ] [ 0 ] = 0 ; dp [ i ] [ 1 ] = 0 ; } for ( int i = 1 ; i <= n ; i ++ ) { if ( arr [ i - 1 ] % 2 ) { dp [ i ] [ 1 ] += 1 ; dp [ i ] [ 1 ] += dp [ i - 1 ] [ 0 ] ; dp [ i ] [ 1 ] += dp [ i - 1 ] [ 1 ] ; dp [ i ] [ 0 ] += dp [ i - 1 ] [ 0 ] ; } else { dp [ i ] [ 0 ] += 1 ; dp [ i ] [ 0 ] += dp [ i - 1 ] [ 1 ] ; dp [ i ] [ 0 ] += dp [ i - 1 ] [ 0 ] ; dp [ i ] [ 1 ] += dp [ i - 1 ] [ 1 ] ; } } return dp [ n ] [ 0 ] + dp [ n ] [ 1 ] ; } int main ( ) { int arr [ ] = { 5 , 6 , 9 , 7 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << validsubsequences ( arr , n ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long getCount ( int n , int k ) { if ( n == 1 ) return 10 ; long long dp [ n + 1 ] [ 11 ] ; for ( int i = 0 ; i <= n ; i ++ ) { for ( int j = 0 ; j < 11 ; j ++ ) dp [ i ] [ j ] = 0 ; } for ( int i = 1 ; i <= 9 ; i ++ ) dp [ 1 ] [ i ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= 9 ; j ++ ) { int l = max ( 0 , j - k ) ; int r = min ( 9 , j + k ) ; dp [ i ] [ l ] += dp [ i - 1 ] [ j ] ; dp [ i ] [ r + 1 ] -= dp [ i - 1 ] [ j ] ; } for ( int j = 1 ; j <= 9 ; j ++ ) dp [ i ] [ j ] += dp [ i ] [ j - 1 ] ; } long long count = 0 ; for ( int i = 0 ; i <= 9 ; i ++ ) count += dp [ n ] [ i ] ; return count ; } int main ( ) { int N = 2 , K = 1 ; cout << getCount ( N , K ) ; }

Index/key variables: i, j, l, n
Accumulator variables: count, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define X  6
#define Z  2
bool existPath ( int V , int edges [ X ] [ Z ] , int u , int v ) { bool mat [ V ] [ V ] ; memset ( mat , false , sizeof ( mat ) ) ; for ( int i = 0 ; i < X ; i ++ ) mat [ edges [ i ] [ 0 ] ] [ edges [ i ] [ 1 ] ] = true ; for ( int k = 0 ; k < V ; k ++ ) { for ( int i = 0 ; i < V ; i ++ ) { for ( int j = 0 ; j < V ; j ++ ) { mat [ i ] [ j ] = mat [ i ] [ j ] || mat [ i ] [ k ] && mat [ k ] [ j ] ; } } } if ( u >= V v >= V ) { return false ; } if ( mat [ u ] [ v ] ) return true ; return false ; } int main ( ) { int V = 4 ; int edges [ X ] [ Z ] = { { 0 , 2 } , { 0 , 1 } , { 1 , 2 } , { 2 , 3 } , { 2 , 0 } , { 3 , 3 } } ; int u = 1 , v = 3 ; if ( existPath ( V , edges , u , v ) ) cout << " Yes STRNEWLINE " ; else cout << " No STRNEWLINE " ; return 0 ; }

Index/key variables: V, X, Z, i, j, k, u, v
Accumulator variables: i, j, k, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; int calculate_maximum_splits ( int arr [ ] , int N ) { int pre [ ] = { 0 , -1 , -1 } ; int dp [ N ] ; memset ( dp , 0 , sizeof ( dp ) ) ; int C = 0 ; for ( int i = 0 ; i < N ; i ++ ) { C = C + arr [ i ] ; C = C % 3 ; if ( pre [ C ] == -1 ) { dp [ i ] = dp [ i - 1 ] ; } else { dp [ i ] = max ( dp [ i - 1 ] , dp [ pre [ C ] ] + 1 ) ; } pre [ C ] = i ; } return dp [ N - 1 ] ; } int main ( ) { int arr [ ] = { 2 , 36 , 1 , 9 , 2 , 0 , 1 , 8 , 1 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << ( calculate_maximum_splits ( arr , N ) ) ; }

Index/key variables: C, N, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long prime [ 1000001 ] = { 0 } ; void seiveOfEratosthenes ( ) { for ( int i = 2 ; i < 1000001 ; i ++ ) { prime [ i ] = 1 ; } for ( int i = 2 ; i * i < 1000001 ; i ++ ) { if ( prime [ i ] == 1 ) { for ( int j = i * i ; j < 1000001 ; j += i ) { prime [ j ] = 0 ; } } } } void CountElements ( int arr [ ] , int n , int L , int R ) { seiveOfEratosthenes ( ) ; long long countPrime [ n + 1 ] = { 0 } ; for ( int i = 1 ; i <= n ; i ++ ) { countPrime [ i ] = countPrime [ i - 1 ] + prime [ arr [ i - 1 ] ] ; } cout << countPrime [ R ] - countPrime [ L - 1 ] << endl ; return ; } int main ( ) { int arr [ ] = { 2 , 4 , 5 , 8 } ; int N = sizeof ( arr ) / sizeof ( int ) ; int L = 1 , R = 3 ; CountElements ( arr , N , L , R ) ; return 0 ; }

Index/key variables: R, i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void OddDivisorsCount ( int n , int q , int a [ ] , vector < pair < int , int > > Query ) { int DP [ n ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) { int x = sqrt ( a [ i ] ) ; if ( x * x == a [ i ] ) DP [ i ] = 1 ; } for ( int i = 1 ; i < n ; i ++ ) { DP [ i ] = DP [ i - 1 ] + DP [ i ] ; } int l , r ; for ( int i = 0 ; i < q ; i ++ ) { l = Query [ i ] . first ; r = Query [ i ] . second ; if ( l == 0 ) { cout << DP [ r ] << endl ; } else { cout << DP [ r ] - DP [ l - 1 ] << endl ; } } } int main ( ) { int N = 5 ; int Q = 3 ; int arr [ ] = { 2 , 4 , 5 , 6 , 9 } ; vector < pair < int , int > > Query Query = { { 0 , 2 } , { 1 , 3 } , { 1 , 4 } } ; OddDivisorsCount ( N , Q , arr , Query ) ; return 0 ; }

Index/key variables: i, n, r
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int n , k ; int dp [ 1024 ] [ 2048 ] [ 2 ] [ 2 ] ; int Ways ( int col , int comp , int row1 , int row2 ) { if ( comp > k ) return 0 ; if ( col > n ) { if ( comp == k ) return 1 ; else return 0 ; } if ( dp [ col ] [ comp ] [ row1 ] [ row2 ] != -1 ) return dp [ col ] [ comp ] [ row1 ] [ row2 ] ; else { int ans = 0 ; if ( col == 1 ) { ans = ( ans + Ways ( col + 1 , comp + 1 , 0 , 0 ) + Ways ( col + 1 , comp + 1 , 1 , 1 ) ) ; ans = ( ans + Ways ( col + 1 , comp + 2 , 0 , 1 ) + Ways ( col + 1 , comp + 2 , 1 , 0 ) ) ; } else { if ( ( row1 && row2 ) || ( ! row1 && ! row2 ) ) { ans = ( ( ( ans + Ways ( col + 1 , comp + 1 , 0 , 0 ) ) + Ways ( col + 1 , comp + 1 , 1 , 0 ) ) + Ways ( col + 1 , comp + 1 , 0 , 1 ) ) ; ans = ( ans + Ways ( col + 1 , comp , 1 , 1 ) ) ; } if ( row1 && ! row2 ) { ans = ( ( ( ans + Ways ( col + 1 , comp , 0 , 0 ) ) + Ways ( col + 1 , comp , 1 , 1 ) ) + Ways ( col + 1 , comp , 1 , 0 ) ) ; ans = ( ans + Ways ( col + 1 , comp + 2 , 0 , 1 ) ) ; } if ( ! row1 && row2 ) { ans = ( ( ( ans + Ways ( col + 1 , comp , 0 , 0 ) ) + Ways ( col + 1 , comp , 1 , 1 ) ) + Ways ( col + 1 , comp , 0 , 1 ) ) ; ans = ( ans + Ways ( col + 1 , comp + 2 , 1 , 0 ) ) ; } } return dp [ col ] [ comp ] [ row1 ] [ row2 ] = ans ; } } signed main ( ) { n = 2 ; k = 1 ; memset ( dp , -1 , sizeof ( dp ) ) ; cout << Ways ( 1 , 0 , 0 , 0 ) ; return 0 ; }

Index/key variables: col, comp, row1, row2
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool primes [ 1000000 ] ; const int maxn = 1000000 ; void sieve ( ) { memset ( primes , true , sizeof ( primes ) ) ; primes [ 0 ] = primes [ 1 ] = 0 ; for ( int i = 2 ; i * i <= maxn ; i ++ ) { if ( primes [ i ] ) { for ( int j = i * i ; j <= maxn ; j += i ) primes [ j ] = false ; } } } string toBinary ( int n ) { string r = " " ; while ( n != 0 ) { r = ( n % 2 == 0 ? "0" : "1" ) + r ; n /= 2 ; } return ( r == " " ) ? "0" : r ; } void PrimeSplit ( string str ) { string temp ; int cnt = 0 ; vector < string > ans ; int bt = 1 << ( str . size ( ) - 1 ) ; int n = str . size ( ) ; for ( int i = 0 ; i < bt ; i ++ ) { temp = toBinary ( i ) + "0" ; int j = 0 , x = n - temp . size ( ) , y ; while ( j < x ) { temp = "0" + temp ; j ++ ; } j = 0 ; x = 0 ; y = -1 ; string sp = " " , tp = " " ; bool flag = 0 ; while ( j < n ) { sp += str [ j ] ; if ( temp [ j ] == '1' ) { tp += sp + ' , ' ; y = stoi ( sp ) ; if ( ! primes [ y ] ) { flag = 1 ; break ; } sp = " " ; } j ++ ; } tp += sp ; if ( sp != " " ) { y = stoi ( sp ) ; if ( ! primes [ y ] ) flag = 1 ; } if ( ! flag ) ans . push_back ( tp ) ; } if ( ans . size ( ) == 0 ) { cout << -1 << endl ; } for ( auto i : ans ) { cout << i << endl ; } } int main ( ) { string str = "11373" ; sieve ( ) ; PrimeSplit ( str ) ; return 0 ; }

Index/key variables: i, j, y
Accumulator variables: i, j, n, sp, stdc, tp
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countStableNum ( string str , int N ) { int count1 [ N ] [ 10 ] ; int count2 [ N ] [ 10 ] ; for ( int i = 0 ; i < N ; i ++ ) for ( int j = 0 ; j < 10 ; j ++ ) count1 [ i ] [ j ] = count2 [ i ] [ j ] = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( i != 0 ) { for ( int j = 0 ; j < 10 ; j ++ ) { count1 [ i ] [ j ] += count1 [ i - 1 ] [ j ] ; } } count1 [ i ] [ str [ i ] - '0' ] ++ ; } for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( i != N - 1 ) { for ( int j = 0 ; j < 10 ; j ++ ) { count2 [ i ] [ j ] += count2 [ i + 1 ] [ j ] ; } } count2 [ i ] [ str [ i ] - '0' ] ++ ; } int ans = 0 ; for ( int i = 1 ; i < N - 1 ; i ++ ) { if ( str [ i ] == '9' ) continue ; int c1 = count1 [ i - 1 ] [ str [ i ] - '0' ] ; int c2 = count2 [ i + 1 ] [ str [ i ] - '0' + 1 ] ; if ( c2 == 0 ) continue ; ans = ( ans + ( c1 * ( ( c2 * ( c2 - 1 ) / 2 ) ) ) ) ; } return ans ; } int main ( ) { string str = "224353" ; int N = str . length ( ) ; cout << countStableNum ( str , 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 ; int countSubsequenceUtil ( int ind , int sum , int * A , int N , vector < vector < int > > & dp ) { if ( ind == N ) return 1 ; if ( dp [ ind ] [ sum ] != -1 ) return dp [ ind ] [ sum ] ; if ( A [ ind ] <= sum ) { dp [ ind ] [ sum ] = countSubsequenceUtil ( ind + 1 , sum , A , N , dp ) + countSubsequenceUtil ( ind + 1 , sum - A [ ind ] , A , N , dp ) ; } else { dp [ ind ] [ sum ] = countSubsequenceUtil ( ind + 1 , sum , A , N , dp ) ; } return dp [ ind ] [ sum ] ; } int countSubsequence ( int * A , int N , int X ) { vector < vector < int > > dp ( N , vector < int > ( X + 1 , -1 ) ) ; return countSubsequenceUtil ( 0 , X , A , N , dp ) - 1 ; } int main ( ) { int arr [ ] = { 25 , 13 , 40 } , X = 50 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countSubsequence ( arr , N , X ) ; return 0 ; }

Index/key variables: ind, sum
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int waysToDecode2 ( string s ) { int n = s . size ( ) ; vector < int > dp ( n + 1 , 0 ) ; dp [ 0 ] = 1 ; if ( s [ 0 ] == '0' ) return 0 ; dp [ 1 ] = ( ( s [ 0 ] == ' * ' ) ? 9 : 1 ) ; for ( int i = 2 ; i <= n ; i ++ ) { char first = s [ i - 2 ] ; char second = s [ i - 1 ] ; if ( second == ' * ' ) { dp [ i ] += 9 * dp [ i - 1 ] ; } else if ( second > '0' ) dp [ i ] += dp [ i - 1 ] ; if ( first == '1' first == '2' ) { if ( second == ' * ' ) { if ( first == '1' ) dp [ i ] += 9 * dp [ i - 2 ] ; else if ( first == '2' ) dp [ i ] += 6 * dp [ i - 2 ] ; } else if ( ( ( first - '0' ) * 10 + ( second - '0' ) ) <= 26 ) dp [ i ] += dp [ i - 2 ] ; } else if ( first == ' * ' ) { if ( second == ' * ' ) { dp [ i ] += 15 * dp [ i - 2 ] ; } else if ( second <= '6' ) dp [ i ] += 2 * dp [ i - 2 ] ; else dp [ i ] += dp [ i - 2 ] ; } } return dp [ n ] ; } int main ( ) { string str = "12*3" ; cout << waysToDecode2 ( str ) << 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 goodInteger ( int arr [ ] , int n , int h , int l , int r ) { vector < vector < int > > dp ( n + 1 , vector < int > ( h , -1 ) ) ; dp [ 0 ] [ 0 ] = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < h ; j ++ ) { if ( dp [ i ] [ j ] != -1 ) { int h1 = ( j + arr [ i ] ) % h ; int h2 = ( j + arr [ i ] - 1 ) % h ; dp [ i + 1 ] [ h1 ] = max ( dp [ i + 1 ] [ h1 ] , dp [ i ] [ j ] + ( h1 >= l && h1 <= r ) ) ; dp [ i + 1 ] [ h2 ] = max ( dp [ i + 1 ] [ h2 ] , dp [ i ] [ j ] + ( h2 >= l && h2 <= r ) ) ; } } } int ans = 0 ; for ( int i = 0 ; i < h ; i ++ ) { if ( dp [ n ] [ i ] != -1 ) ans = max ( ans , dp [ n ] [ i ] ) ; } cout << ans << " STRNEWLINE " ; } int main ( ) { int A [ ] = { 16 , 17 , 14 , 20 , 20 , 11 , 22 } ; int H = 24 ; int L = 21 ; int R = 23 ; int size = sizeof ( A ) / sizeof ( A [ 0 ] ) ; goodInteger ( A , size , H , L , R ) ; return 0 ; }

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