dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool dp [ 1 << 20 ] ; bool isprime ( int n ) { if ( n == 1 ) return false ; for ( int i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { return false ; } } return true ; } int solve ( int arr [ ] , int curr , int mask , int n ) { if ( isprime ( curr ) ) { if ( mask == ( 1 << n ) - 1 ) { return true ; } curr = 0 ; } if ( mask == ( 1 << n ) - 1 ) { if ( ! isprime ( curr ) ) { return false ; } } if ( dp [ mask ] ) return dp [ mask ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! ( mask & 1 << i ) ) { if ( solve ( arr , curr + arr [ i ] , mask 1 << i , n ) ) { return true ; } } } return dp [ mask ] = false ; } int main ( ) { int arr [ ] = { 3 , 6 , 7 , 13 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; if ( solve ( arr , 0 , 0 , n ) ) { cout << " YES " ; } else { cout << " NO " ; } return 0 ; }

Index/key variables: i, mask
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < int > dp ; int maxSum ( int i , vector < int > & subarr ) { if ( i >= subarr . size ( ) ) return 0 ; if ( dp [ i ] != -1 ) return dp [ i ] ; return dp [ i ] = max ( maxSum ( i + 1 , subarr ) , subarr [ i ] + maxSum ( i + 2 , subarr ) ) ; } int Func ( vector < int > arr ) { vector < int > subarr = arr ; subarr . pop_back ( ) ; dp . resize ( subarr . size ( ) , -1 ) ; int max1 = maxSum ( 0 , subarr ) ; subarr = arr ; subarr . erase ( subarr . begin ( ) ) ; dp . clear ( ) ; dp . resize ( subarr . size ( ) , -1 ) ; int max2 = maxSum ( 0 , subarr ) ; cout << max ( max1 , max2 ) << endl ; } int main ( ) { vector < int > arr = { 1 , 2 , 3 , 1 } ; Func ( arr ) ; return 0 ; }

Index/key variables: i
Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; #define dim  5
void createTable ( int mtrx [ ] [ dim ] , int k , int p , int dp [ ] [ dim ] ) { dp [ 0 ] [ 0 ] = mtrx [ 0 ] [ 0 ] ; for ( int j = 1 ; j < dim ; j ++ ) { dp [ 0 ] [ j ] = mtrx [ 0 ] [ j ] + dp [ 0 ] [ j - 1 ] ; } for ( int i = 1 ; i < dim ; i ++ ) { dp [ i ] [ 0 ] = mtrx [ i ] [ 0 ] + dp [ i - 1 ] [ 0 ] ; } for ( int i = 1 ; i < dim ; i ++ ) { for ( int j = 1 ; j < dim ; j ++ ) { dp [ i ] [ j ] = mtrx [ i ] [ j ] + dp [ i - 1 ] [ j ] + dp [ i ] [ j - 1 ] - dp [ i - 1 ] [ j - 1 ] ; } } } int countSubMatrixUtil ( int dp [ ] [ dim ] , int k , int p ) { int count = 0 ; int subMatSum = 0 ; for ( int i = k - 1 ; i < dim ; i ++ ) { for ( int j = k - 1 ; j < dim ; j ++ ) { if ( i == ( k - 1 ) || j == ( k - 1 ) ) { if ( i == ( k - 1 ) && j == ( k - 1 ) ) { subMatSum = dp [ i ] [ j ] ; } else if ( i == ( k - 1 ) ) { subMatSum = dp [ i ] [ j ] - dp [ i ] [ j - k ] ; } else { subMatSum = dp [ i ] [ j ] - dp [ i - k ] [ j ] ; } } else { subMatSum = dp [ i ] [ j ] - dp [ i - k ] [ j ] - dp [ i ] [ j - k ] + dp [ i - k ] [ j - k ] ; } if ( subMatSum >= p ) { count ++ ; } } } return count ; } int countSubMatrix ( int mtrx [ ] [ dim ] , int k , int p ) { int dp [ dim ] [ dim ] ; for ( int i = 0 ; i < dim ; i ++ ) { for ( int j = 0 ; j < dim ; j ++ ) { dp [ i ] [ j ] = 0 ; } } createTable ( mtrx , k , p , dp ) ; return countSubMatrixUtil ( dp , k , p ) ; } int main ( ) { int mtrx [ dim ] [ dim ] = { { 1 , 7 , 1 , 1 , 1 } , { 2 , 2 , 2 , 2 , 2 } , { 3 , 9 , 6 , 7 , 3 } , { 4 , 3 , 2 , 4 , 5 } , { 5 , 1 , 5 , 3 , 1 } } ; int k = 3 ; int p = 35 ; cout << countSubMatrix ( mtrx , k , p ) ; return 0 ; }

Index/key variables: dim, i, j
Accumulator variables: count, i, j
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void canMakePaliQueries ( string str , vector < vector < int > > & Q ) { int n = str . length ( ) ; vector < vector < int > > dp ( 26 , vector < int > ( n , 0 ) ) ; for ( int i = 0 ; i < 26 ; i ++ ) { char currentChar = i + ' a ' ; for ( int j = 0 ; j < n ; j ++ ) { if ( j == 0 ) { dp [ i ] [ j ] = ( str [ j ] == currentChar ) ; } else { dp [ i ] [ j ] = dp [ i ] [ j - 1 ] + ( str [ j ] == currentChar ) ; } } } for ( auto query : Q ) { int left = query [ 0 ] ; int right = query [ 1 ] ; int k = query [ 2 ] ; int unMatchedCount = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { int occurrence = dp [ i ] [ right ] - dp [ i ] [ left ] + ( str [ left ] == ( i + ' a ' ) ) ; if ( occurrence & 1 ) unMatchedCount ++ ; } int ans = unMatchedCount / 2 ; if ( ans <= k ) { cout << " YES STRNEWLINE " ; } else { cout << " NO STRNEWLINE " ; } } } int main ( ) { string str = " GeeksforGeeks " ; vector < vector < int > > Q ; Q = { { 1 , 5 , 3 } , { 5 , 7 , 0 } , { 8 , 11 , 3 } , { 3 , 10 , 5 } , { 0 , 9 , 5 } } ; canMakePaliQueries ( str , Q ) ; return 0 ; }

Index/key variables: i, j, left, right
Accumulator variables: i, j, stdc, unMatchedCount
Iterator variables: i, j, query
C++ program:
#include <bits/stdc++.h>
using namespace std ; unordered_map < string , vector < string > > mp ; unordered_set < string > dict ; void printResult ( vector < string > A ) { for ( int i = 0 ; i < A . size ( ) ; i ++ ) cout << A [ i ] << ' ' ; } vector < string > combine ( vector < string > prev , string word ) { for ( int i = 0 ; i < prev . size ( ) ; i ++ ) { prev [ i ] += " ▁ " + word ; } return prev ; } vector < string > wordBreakUtil ( string s ) { if ( mp . find ( s ) != mp . end ( ) ) return mp [ s ] ; vector < string > res ; if ( dict . find ( s ) != dict . end ( ) ) res . push_back ( s ) ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { string word = s . substr ( i ) ; if ( dict . find ( word ) != dict . end ( ) ) { string rem = s . substr ( 0 , i ) ; vector < string > prev = combine ( wordBreakUtil ( rem ) , word ) ; res . insert ( res . end ( ) , prev . begin ( ) , prev . end ( ) ) ; } } mp [ s ] = res ; return res ; } vector < string > wordBreak ( string s , vector < string > & wordDict ) { mp . clear ( ) ; dict . clear ( ) ; dict . insert ( wordDict . begin ( ) , wordDict . end ( ) ) ; return wordBreakUtil ( s ) ; } int main ( ) { vector < string > wordDict1 = { " cat " , " cats " , " and " , " sand " , " dog " } ; printResult ( wordBreak ( " catsanddog " , wordDict1 ) ) ; return 0 ; }

Index/key variables: i, s
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX = 100 ; int dp [ 1000 ] [ MAX ] [ MAX ] ; int productDigitSum ( int x , int y ) { int sumx = 0 ; while ( x ) { sumx += ( x % 10 ) ; x /= 10 ; } int sumy = 0 ; while ( y ) { sumy += ( y % 10 ) ; y /= 10 ; } return ( sumx * sumy ) ; } int solve ( int arr [ ] , int i , int len , int prev , int n , int k ) { if ( len == k ) return 0 ; if ( i == n ) return INT_MIN ; if ( dp [ i ] [ len ] [ prev ] ) return dp [ i ] [ len ] [ prev ] ; int inc = 0 , exc = 0 ; if ( len & 1 ) { inc = productDigitSum ( arr [ prev ] , arr [ i ] ) + solve ( arr , i + 1 , len + 1 , 0 , n , k ) ; } else { inc = solve ( arr , i + 1 , len + 1 , i , n , k ) ; } exc = solve ( arr , i + 1 , len , prev , n , k ) ; return dp [ i ] [ len ] [ prev ] = max ( inc , exc ) ; } int main ( ) { int arr [ ] = { 10 , 5 , 9 , 101 , 24 , 2 , 20 , 14 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int k = 6 ; cout << solve ( arr , 0 , 0 , 0 , n , k ) ; }

Index/key variables: MAX, i, len, prev
Accumulator variables: stdc, sumx, sumy, x, y
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < int > factors [ 100005 ] ; int dp [ 100005 ] ; void precompute ( ) { for ( int i = 1 ; i <= 100000 ; i ++ ) { for ( int j = i ; j <= 100000 ; j += i ) { factors [ j ] . push_back ( i ) ; } } } int solve ( int arr [ ] , int k , int n ) { if ( k == n - 1 ) { return 0 ; } if ( k >= n ) { return INT_MAX ; } if ( dp [ k ] ) { return dp [ k ] ; } int ans = INT_MAX ; for ( auto j : factors [ arr [ k ] ] ) { int res = solve ( arr , k + j , n ) ; if ( res != INT_MAX ) { ans = min ( ans , res + 1 ) ; } } return dp [ k ] = ans ; } int main ( ) { precompute ( ) ; int arr [ ] = { 2 , 8 , 16 , 55 , 99 , 100 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << solve ( arr , 0 , n ) ; }

Index/key variables: j, k
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxDistance ( vector < vector < int > > & grid ) { vector < pair < int , int > > one ; int M = grid . size ( ) ; int N = grid [ 0 ] . size ( ) ; int ans = -1 ; for ( int i = 0 ; i < M ; ++ i ) { for ( int j = 0 ; j < N ; ++ j ) { if ( grid [ i ] [ j ] == 1 ) one . emplace_back ( i , j ) ; } } if ( one . empty ( ) || M * N == one . size ( ) ) return -1 ; for ( int i = 0 ; i < M ; ++ i ) { for ( int j = 0 ; j < N ; ++ j ) { if ( grid [ i ] [ j ] == 1 ) continue ; int dist = INT_MAX ; for ( auto & p : one ) { int d = abs ( p . first - i ) + abs ( p . second - j ) ; dist = min ( dist , d ) ; if ( dist <= ans ) break ; } ans = max ( ans , dist ) ; } } return ans ; } int main ( ) { vector < vector < int > > arr = { { 0 , 0 , 1 } , { 0 , 0 , 0 } , { 0 , 0 , 0 } } ; cout << maxDistance ( arr ) << endl ; return 0 ; }

Index/key variables: i, j
Accumulator variables: stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxDistance ( vector < vector < int > > & grid ) { queue < pair < int , int > > q ; int M = grid . size ( ) ; int N = grid [ 0 ] . size ( ) ; int ans = -1 ; int dirs [ 4 ] [ 2 ] = { { 0 , 1 } , { 1 , 0 } , { 0 , -1 } , { -1 , 0 } } ; for ( int i = 0 ; i < M ; ++ i ) { for ( int j = 0 ; j < N ; ++ j ) { if ( grid [ i ] [ j ] == 1 ) q . emplace ( i , j ) ; } } if ( q . empty ( ) || M * N == q . size ( ) ) return -1 ; while ( q . size ( ) ) { int cnt = q . size ( ) ; while ( cnt -- ) { auto p = q . front ( ) ; q . pop ( ) ; for ( auto & dir : dirs ) { int x = p . first + dir [ 0 ] ; int y = p . second + dir [ 1 ] ; if ( x < 0 x > = M y < 0 y > = N grid [ x ] [ y ] ) continue ; q . emplace ( x , y ) ; grid [ x ] [ y ] = 1 ; } } ++ ans ; } return ans ; } int main ( ) { vector < vector < int > > arr = { { 0 , 0 , 1 } , { 0 , 0 , 0 } , { 0 , 0 , 1 } } ; cout << maxDistance ( arr ) << endl ; return 0 ; }

Index/key variables: i, j, x, y
Accumulator variables: cnt, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int mod = 1e9 + 7 ; vector < vector < int > > dp ; int f ( int n , int k ) { if ( n < k ) return 0 ; if ( n == k ) return 1 ; if ( k == 1 ) return 1 ; if ( dp [ n ] [ k ] != -1 ) return dp [ n ] [ k ] ; return dp [ n ] [ k ] = ( ( k * f ( n - 1 , k ) ) % mod + ( f ( n - 1 , k - 1 ) ) % mod ) % mod ; } long operation ( int n ) { dp . resize ( n + 1 , vector < int > ( n + 1 , -1 ) ) ; long ans = 0 , fac = 1 ; for ( int k = 1 ; k <= n ; k ++ ) { fac *= k ; ans = ( ans + ( fac * f ( n , k ) ) % mod ) % mod ; } return ans ; } int main ( ) { int n = 5 ; cout << operation ( n ) << endl ; return 0 ; }

Index/key variables: k, n
Accumulator variables: fac, k, stdc
Iterator variables: k
C++ program:
#include " bits / stdc + + . h "
using namespace std ; void printLDS ( vector < int > & Max ) { for ( auto & it : Max ) { cout << it << ' ▁ ' ; } } void LongestDividingSeq ( int arr [ ] , int N ) { vector < vector < int > > LDS ( N ) ; LDS [ 0 ] . push_back ( arr [ 0 ] ) ; for ( int i = 1 ; i < N ; i ++ ) { for ( int j = 0 ; j < i ; j ++ ) { if ( ( arr [ i ] % arr [ j ] == 0 ) && ( LDS [ i ] . size ( ) < LDS [ j ] . size ( ) + 1 ) ) LDS [ i ] = LDS [ j ] ; } LDS [ i ] . push_back ( arr [ i ] ) ; } int maxLength = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int x = LDS [ i ] . size ( ) ; maxLength = max ( maxLength , x ) ; } for ( int i = 0 ; i < N ; i ++ ) { int size = LDS [ i ] . size ( ) ; if ( size == maxLength ) { printLDS ( LDS [ i ] ) ; cout << ' ' ; } } } int main ( ) { int arr [ ] = { 2 , 11 , 16 , 12 , 36 , 60 , 71 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; LongestDividingSeq ( arr , N ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int CountSets ( int x , int pos ) { if ( x <= 0 ) { if ( pos == 0 ) return 1 ; else return 0 ; } if ( pos == 0 ) return 1 ; int answer = CountSets ( x - 1 , pos ) + CountSets ( x - 2 , pos - 1 ) ; return answer ; } int CountOrderedSets ( int n ) { int factorial [ 10000 ] ; factorial [ 0 ] = 1 ; for ( int i = 1 ; i < 10000 ; i ++ ) factorial [ i ] = factorial [ i - 1 ] * i ; int answer = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { int sets = CountSets ( n , i ) * factorial [ i ] ; answer = answer + sets ; } return answer ; } int main ( ) { int N = 3 ; cout << CountOrderedSets ( N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int MaximumSum ( int a [ ] , int n ) { int dp [ n + 1 ] [ n + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) { for ( int j = 0 ; j < n + 1 ; j ++ ) dp [ i ] [ j ] = INT_MIN ; } for ( int i = 0 ; i < n + 1 ; i ++ ) dp [ i ] [ 0 ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= i ; j ++ ) { int val = INT_MIN ; if ( ( i - 2 >= 0 && dp [ i - 2 ] [ j - 1 ] != INT_MIN ) i - 2 < 0 ) { val = a [ i - 1 ] + ( i - 2 >= 0 ? dp [ i - 2 ] [ j - 1 ] : 0 ) ; } if ( i - 1 >= j ) { val = max ( val , dp [ i - 1 ] [ j ] ) ; } dp [ i ] [ j ] = val ; } } return dp [ n ] [ n / 2 ] ; } int main ( ) { int A [ ] = { 1 , 2 , 3 , 4 , 5 , 6 } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; cout << MaximumSum ( A , N ) ; return 0 ; }

Index/key variables: i, j, n
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; unordered_set < int > kPowKform ; int func ( int n ) { if ( n <= 0 ) return 0 ; if ( kPowKform . count ( n ) ) return 1 ; int answer = 0 ; int x = n ; while ( x > 0 ) { int d = x % 10 ; if ( d != 0 ) { if ( func ( n - d * d ) ) { answer = 1 ; break ; } } x /= 10 ; } return answer ; } void canBeConverted ( int n ) { if ( func ( n ) ) cout << " Yes " ; else cout << " No " ; } int main ( ) { int N = 90 ; for ( int i = 1 ; i <= 8 ; i ++ ) { int val = 1 ; for ( int j = 1 ; j <= i ; j ++ ) val *= i ; kPowKform . insert ( val ) ; } canBeConverted ( N ) ; return 0 ; }

Accumulator variables: i, j, stdc, val, x
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool check ( vector < int > & v ) { set < int > digits ; for ( int i = 0 ; i < v . size ( ) ; i ++ ) { set < int > d ; while ( v [ i ] ) { d . insert ( v [ i ] % 10 ) ; v [ i ] /= 10 ; } for ( auto it : d ) { if ( digits . count ( it ) ) return false ; } for ( auto it : d ) digits . insert ( it ) ; } return true ; } int numberOfSubarrays ( int a [ ] , int n ) { int answer = 0 ; for ( int i = 1 ; i < ( 1 << n ) ; i ++ ) { vector < int > temp ; for ( int j = 0 ; j < n ; j ++ ) { if ( i & ( 1 << j ) ) temp . push_back ( a [ j ] ) ; } if ( check ( temp ) ) answer ++ ; } return answer ; } int main ( ) { int N = 4 ; int A [ ] = { 1 , 12 , 23 , 34 } ; cout << numberOfSubarrays ( A , N ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: answer, i, j, stdc
Iterator variables: i, it, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX = 100005 ; int totBackEdges ; int countAdj [ MAX ] , small [ MAX ] ; int isPossible [ MAX ] , depth [ MAX ] ; vector < int > adj [ MAX ] ; int vis [ MAX ] ; void change ( pair < int , int > & p , int x ) { if ( p . second > x ) p . second = x ; if ( p . first > p . second ) swap ( p . first , p . second ) ; } pair < int , int > dfs ( int v , int p = -1 , int de = 0 ) { pair < int , int > answer ( 100000000 , 100000000 ) ; depth [ v ] = de ; vis [ v ] = 1 ; isPossible [ v ] = 1 ; for ( int u : adj [ v ] ) { if ( u ^ p ) { if ( ! vis [ u ] ) { auto x = dfs ( u , v , de + 1 ) ; small [ v ] += small [ u ] ; change ( answer , x . second ) ; change ( answer , x . first ) ; if ( x . second < de ) isPossible [ v ] = 0 ; } else if ( vis [ u ] == 1 ) { totBackEdges ++ ; countAdj [ v ] ++ ; countAdj [ u ] ++ ; small [ p ] ++ ; small [ u ] -- ; change ( answer , depth [ u ] ) ; } } } vis [ v ] = 2 ; return answer ; } int minNodetoRemove ( int n , vector < pair < int , int > > edges ) { for ( int i = 0 ; i < edges . size ( ) ; i ++ ) { adj [ edges [ i ] . first ] . push_back ( edges [ i ] . second ) ; adj [ edges [ i ] . second ] . push_back ( edges [ i ] . first ) ; } memset ( vis , 0 , sizeof ( vis ) ) ; totBackEdges = 0 ; for ( int v = 1 ; v <= n ; v ++ ) { if ( ! vis [ v ] ) dfs ( v ) ; } if ( totBackEdges == 0 ) return -1 ; int node = -1 ; for ( int v = 1 ; v <= n ; v ++ ) { if ( countAdj [ v ] + small [ v ] == totBackEdges && isPossible [ v ] ) { node = v ; } if ( node != -1 ) break ; } return node ; } int main ( ) { int N = 5 ; vector < pair < int , int > > edges ; edges . push_back ( make_pair ( 5 , 1 ) ) ; edges . push_back ( make_pair ( 5 , 2 ) ) ; edges . push_back ( make_pair ( 1 , 2 ) ) ; edges . push_back ( make_pair ( 2 , 3 ) ) ; edges . push_back ( make_pair ( 2 , 4 ) ) ; cout << minNodetoRemove ( N , edges ) ; }

Index/key variables: MAX, i, p, u, v
Accumulator variables: i, stdc, totBackEdges, v
Iterator variables: i, u, v
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  3
#define M  5
int Large = 1e6 ; vector < int > prime ; void SieveOfEratosthenes ( ) { bool isPrime [ Large + 1 ] ; memset ( isPrime , true , sizeof ( isPrime ) ) ; for ( int p = 2 ; p * p <= Large ; p ++ ) { if ( isPrime [ p ] == true ) { for ( int i = p * 2 ; i <= Large ; i += p ) isPrime [ i ] = false ; } } for ( int p = 2 ; p <= Large ; p ++ ) if ( isPrime [ p ] ) prime . push_back ( p ) ; } void Display ( int arr [ ] [ M ] , int row ) { for ( int i = 0 ; i < M ; i ++ ) cout << arr [ row ] [ i ] << " ▁ " ; } void countDivisorsMult ( int arr [ ] [ M ] ) { unordered_map < int , int > mp ; int row_no = 0 ; long long max_factor = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { int no = arr [ i ] [ j ] ; for ( int k = 0 ; k < prime . size ( ) ; k ++ ) { while ( no > 1 && no % prime [ k ] == 0 ) { no /= prime [ k ] ; mp [ prime [ k ] ] ++ ; } if ( no == 1 ) break ; } } long long int res = 1 ; for ( auto it : mp ) { res *= ( it . second + 1L ) ; } if ( max_factor < res ) { row_no = i ; max_factor = res ; } mp . clear ( ) ; } Display ( arr , row_no ) ; } int main ( ) { int arr [ N ] [ M ] = { { 1 , 2 , 3 , 10 , 23 } , { 4 , 5 , 6 , 7 , 8 } , { 7 , 8 , 9 , 15 , 45 } } ; SieveOfEratosthenes ( ) ; countDivisorsMult ( arr ) ; return 0 ; }

Index/key variables: M, N, i, j, k, p, row
Accumulator variables: i, j, k, no, p, res, stdc
Iterator variables: i, it, j, k, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; int isSquare ( int n ) { int k = sqrt ( n ) ; return ( k * k == n ) ; } int calculate ( int pos , int prev , int sum , vector < int > & v ) { if ( pos == v . size ( ) ) return isSquare ( sum ) ; for ( int i = prev ; i <= 9 ; i ++ ) { v [ pos ] = i ; sum += i * i ; if ( calculate ( pos + 1 , i , sum , v ) ) return 1 ; sum -= i * i ; } return 0 ; } string minValue ( int n ) { vector < int > v ( n ) ; if ( calculate ( 0 , 1 , 0 , v ) ) { string answer = " " ; for ( int i = 0 ; i < v . size ( ) ; i ++ ) answer += char ( v [ i ] + '0' ) ; return answer ; } else return " - 1" ; } int main ( ) { int N = 2 ; cout << minValue ( N ) ; return 0 ; }

Index/key variables: i, pos
Accumulator variables: answer, i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool checkOdd ( string number ) { int n = number . length ( ) ; int num = number [ n - 1 ] - '0' ; return ( num & 1 ) ; } int splitIntoOdds ( string number ) { int numLen = number . length ( ) ; int splitDP [ numLen + 1 ] ; memset ( splitDP , -1 , sizeof ( splitDP ) ) ; for ( int i = 1 ; i <= numLen ; i ++ ) { if ( i <= 9 && checkOdd ( number . substr ( 0 , i ) ) ) splitDP [ i ] = 1 ; if ( splitDP [ i ] != -1 ) { for ( int j = 1 ; j <= 9 && i + j <= numLen ; j ++ ) { if ( checkOdd ( number . substr ( i , j ) ) ) { if ( splitDP [ i + j ] == -1 ) splitDP [ i + j ] = 1 + splitDP [ i ] ; else splitDP [ i + j ] = min ( splitDP [ i + j ] , 1 + splitDP [ i ] ) ; } } } } return splitDP [ numLen ] ; } int main ( ) { cout << splitIntoOdds ( "123456789123456789123" ) << " STRNEWLINE " ; return 0 ; }

Index/key variables: i, numLen
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ll  long long int
ll m , n , d ; vector < int > v ; ll const k = 1e9 + 7 ; ll dp [ 2001 ] [ 2001 ] [ 2 ] ; void init ( string s ) { memset ( dp , -1 , sizeof ( dp ) ) ; v . clear ( ) ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) { v . push_back ( s [ i ] - '0' ) ; } n = s . size ( ) ; } string number_minus_one ( string a ) { string s = a . substr ( 1 ) ; string s1 = " " ; for ( int i = 0 ; i < s . size ( ) - 1 ; i ++ ) s1 += '0' ; if ( a [ 0 ] == 1 and s == s1 ) { ll l = s . size ( ) ; a = " " ; a += '0' ; for ( int i = 0 ; i < l ; i ++ ) a += '9' ; } else { for ( int i = a . size ( ) - 1 ; i >= 0 ; i -- ) { if ( a [ i ] == '0' ) a [ i ] = '9' ; else { a [ i ] = ( ( ( a [ i ] - '0' ) - 1 ) + '0' ) ; break ; } } } return a ; } ll fun ( ll pos , ll sum , ll f ) { if ( pos == n ) { if ( sum == 0 ) { return 1 ; } return 0 ; } if ( dp [ pos ] [ sum ] [ f ] != -1 ) return dp [ pos ] [ sum ] [ f ] ; ll lmt = 9 ; if ( ! f ) lmt = v [ pos ] ; ll ans = 0 ; for ( ll i = 0 ; i <= lmt ; i ++ ) { if ( i == d and pos % 2 == 1 ) ans += 0 ; else if ( i != d and pos % 2 == 0 ) ans += 0 ; else { ll new_f = f ; if ( f == 0 and i < lmt ) new_f = 1 ; ll new_sum = sum ; new_sum *= 10 ; new_sum += i ; new_sum %= m ; ans += fun ( pos + 1 , new_sum , new_f ) ; ans %= k ; } } return dp [ pos ] [ sum ] [ f ] = ans ; } void operations ( string L , string R ) { init ( R ) ; ll ans = fun ( 0 , 0 , 0 ) ; L = number_minus_one ( L ) ; init ( L ) ; ans -= fun ( 0 , 0 , 0 ) ; if ( ans < 0 ) ans += k ; cout << ans << " STRNEWLINE " ; } int main ( ) { m = 2 , d = 2 ; ll Q = 1 ; string arr [ ] [ 2 ] = { { "20" , "32" } } ; for ( ll i = 0 ; i < Q ; i ++ ) { operations ( arr [ i ] [ 0 ] , arr [ i ] [ 1 ] ) ; } return 0 ; }

Index/key variables: f, i, pos, sum
Accumulator variables: a, ans, i, new_sum, s1, stdc
Iterator variables: i
C++ program:
#include <iostream>
#include <string>
using namespace std ; bool checkPrime ( string number ) { int num = stoi ( number ) ; for ( int i = 2 ; i * i <= num ; i ++ ) if ( ( num % i ) == 0 ) return false ; return true ; } int splitIntoPrimes ( string number ) { if ( number . length ( ) == 0 ) return 0 ; if ( number . length ( ) <= 6 and checkPrime ( number ) ) return 1 ; else { int numLen = number . length ( ) ; int ans = 1000000 ; for ( int i = 1 ; i <= 6 && i <= numLen ; i ++ ) { if ( checkPrime ( number . substr ( 0 , i ) ) ) { int val = splitIntoPrimes ( number . substr ( i ) ) ; if ( val != -1 ) { ans = min ( ans , 1 + val ) ; } } } if ( ans == 1000000 ) return -1 ; return ans ; } } int main ( ) { cout << splitIntoPrimes ( "13499315" ) << " STRNEWLINE " ; cout << splitIntoPrimes ( "43" ) << " STRNEWLINE " ; return 0 ; }

Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int k_nonzero_numbers ( string s , int n , int k ) { int dp [ n + 1 ] [ 2 ] [ k + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) for ( int j = 0 ; j < 2 ; j ++ ) for ( int x = 0 ; x <= k ; x ++ ) dp [ i ] [ j ] [ x ] = 0 ; dp [ 0 ] [ 0 ] [ 0 ] = 1 ; for ( int i = 0 ; i < n ; ++ i ) { int sm = 0 ; while ( sm < 2 ) { for ( int j = 0 ; j < k + 1 ; ++ j ) { int x = 0 ; while ( x <= ( sm ? 9 : s [ i ] - '0' ) ) { dp [ i + 1 ] [ sm || x < ( s [ i ] - '0' ) ] [ j + ( x > 0 ) ] += dp [ i ] [ sm ] [ j ] ; ++ x ; } } ++ sm ; } } return dp [ n ] [ 0 ] [ k ] + dp [ n ] [ 1 ] [ k ] ; } int main ( ) { string s = "25" ; int k = 2 ; int n = s . size ( ) ; cout << k_nonzero_numbers ( s , n , k ) ; return 0 ; }

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