dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMaxGCD ( int arr [ ] , int N ) { int high = 0 ; for ( int i = 0 ; i < N ; i ++ ) { high = max ( high , arr [ i ] ) ; } int count [ high + 1 ] = { 0 } ; for ( int i = 0 ; i < N ; i ++ ) { count [ arr [ i ] ] += 1 ; } int counter = 0 ; for ( int i = high ; i > 0 ; i -- ) { int j = i ; while ( j <= high ) { if ( count [ j ] > 0 ) counter += count [ j ] ; j += i ; if ( counter == 2 ) return i ; } counter = 0 ; } } int maxlen ( int i , int j , int arr [ ] , int arr1 [ ] , int N , int maxgcd ) { int a = 1 ; if ( i >= N or j >= N ) return 0 ; if ( __gcd ( arr [ i ] , arr1 [ j ] ) == maxgcd && arr [ i ] != arr1 [ j ] ) { a = max ( a , 1 + maxlen ( i , j + 1 , arr , arr1 , N , maxgcd ) ) ; return a ; } return max ( maxlen ( i + 1 , j , arr , arr1 , N , maxgcd ) , maxlen ( i , j + 1 , arr , arr1 , N , maxgcd ) ) ; } int main ( ) { int arr [ ] = { 1 , 2 , 8 , 5 , 6 } ; int arr1 [ ] = { 1 , 2 , 8 , 5 , 6 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; sort ( arr , arr + n ) ; sort ( arr1 , arr1 + n ) ; int maxgcd = findMaxGCD ( arr , n ) ; cout << maxlen ( 0 , 0 , arr , arr1 , n , maxgcd ) + 1 ; }

Index/key variables: i, j
Accumulator variables: counter, i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < vector < vector < int > > > dp ( 105 , vector < vector < int > > ( 105 ) ) ; int countPaths = 0 ; bool isPerfectSquare ( int n ) { long double sr = sqrt ( n ) ; return ( ( sr - floor ( sr ) ) == 0 ) ; } void countUniquePaths ( int a [ ] [ 105 ] , int m , int n , int ans ) { dp [ 0 ] [ 0 ] . push_back ( a [ 0 ] [ 0 ] ) ; for ( int i = 1 ; i < m ; i ++ ) { a [ i ] [ 0 ] *= a [ i - 1 ] [ 0 ] ; dp [ i ] [ 0 ] . push_back ( a [ i ] [ 0 ] ) ; } for ( int i = 1 ; i < n ; i ++ ) { a [ 0 ] [ i ] *= a [ 0 ] [ i - 1 ] ; dp [ 0 ] [ i ] . push_back ( a [ 0 ] [ i ] ) ; } for ( int i = 1 ; i < m ; i ++ ) { for ( int j = 1 ; j < n ; j ++ ) { vector < int > top = dp [ i - 1 ] [ j ] ; vector < int > left = dp [ i ] [ j - 1 ] ; vector < int > curr ; for ( int k = 0 ; k < top . size ( ) ; k ++ ) { curr . push_back ( top [ k ] * a [ i ] [ j ] ) ; } for ( int k = 0 ; k < left . size ( ) ; k ++ ) { curr . push_back ( left [ k ] * a [ i ] [ j ] ) ; } dp [ i ] [ j ] = curr ; } } for ( auto i : dp [ m - 1 ] [ n - 1 ] ) { if ( isPerfectSquare ( i ) ) { countPaths ++ ; } } } int main ( ) { int M = 3 , N = 4 ; int mat [ M ] [ 105 ] = { { 1 , 2 , 3 , 1 } , { 3 , 1 , 2 , 4 } , { 2 , 3 , 1 , 1 } } ; countUniquePaths ( mat , M , N , 1 ) ; cout << countPaths ; return 0 ; }

Index/key variables: M, i, j, k
Accumulator variables: countPaths, i, j, k, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX  100000
int dp [ MAX + 1 ] ; list < int > denomination ; int countMinCoins ( int n , int C [ ] , int m ) { if ( n == 0 ) { dp [ 0 ] = 0 ; return 0 ; } if ( dp [ n ] != -1 ) return dp [ n ] ; int ret = INT_MAX ; for ( int i = 0 ; i < m ; i ++ ) { if ( C [ i ] <= n ) { int x = countMinCoins ( n - C [ i ] , C , m ) ; if ( x != INT_MAX ) ret = min ( ret , 1 + x ) ; } } dp [ n ] = ret ; return ret ; } void findSolution ( int n , int C [ ] , int m ) { if ( n == 0 ) { for ( auto it : denomination ) { cout << it << ' ▁ ' ; } return ; } for ( int i = 0 ; i < m ; i ++ ) { if ( n - C [ i ] >= 0 and dp [ n - C [ i ] ] + 1 == dp [ n ] ) { denomination . push_back ( C [ i ] ) ; findSolution ( n - C [ i ] , C , m ) ; break ; } } } void countMinCoinsUtil ( int X , int C [ ] , int N ) { memset ( dp , -1 , sizeof ( dp ) ) ; int isPossible = countMinCoins ( X , C , N ) ; if ( isPossible == INT_MAX ) { cout << " - 1" ; } else { findSolution ( X , C , N ) ; } } int main ( ) { int X = 21 ; int arr [ ] = { 2 , 3 , 4 , 5 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; countMinCoinsUtil ( X , arr , N ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, stdc
Iterator variables: i, it
C++ program:
#include <bits/stdc++.h>
using namespace std ; int binCoff ( int n , int r ) { int val = 1 ; int i ; if ( r > ( n - r ) ) { r = ( n - r ) ; } for ( i = 0 ; i < r ; i ++ ) { val *= ( n - i ) ; val /= ( i + 1 ) ; } return val ; } int findWays ( int n ) { n -- ; int a , b , ans ; a = binCoff ( 2 * n , n ) ; b = a / ( n + 1 ) ; ans = b ; return ans ; } int main ( ) { int n = 4 ; cout << findWays ( n ) ; return 0 ; }

Accumulator variables: i, n, stdc, val
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int dp [ 1010 ] [ 1010 ] ; int solve ( string s , string t ) { int n = s . size ( ) ; int r = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { dp [ i ] [ j ] = 0 ; if ( i > 0 ) { dp [ i ] [ j ] = max ( dp [ i - 1 ] [ j ] , dp [ i ] [ j ] ) ; } if ( s [ i ] == t [ j ] ) { int ans = 1 ; if ( i > 0 && j > 0 ) { ans = 1 + dp [ i - 1 ] [ j - 1 ] ; } dp [ i ] [ j ] = max ( dp [ i ] [ j ] , ans ) ; r = max ( r , dp [ i ] [ j ] ) ; } } } return ( n - r ) ; } int main ( ) { string s = " abcde " ; string t = " edacb " ; cout << solve ( s , t ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int longestSubstring ( string s , int n ) { map < int , int > index ; int answer = 0 ; int mask = 0 ; index [ mask ] = -1 ; for ( int i = 0 ; i < n ; i ++ ) { int temp = ( int ) s [ i ] - 97 ; mask ^= ( 1 << temp ) ; if ( index [ mask ] ) { answer = max ( answer , i - index [ mask ] ) ; } else index [ mask ] = i ; for ( int j = 0 ; j < 26 ; j ++ ) { int mask2 = mask ^ ( 1 << j ) ; if ( index [ mask2 ] ) { answer = max ( answer , i - index [ mask2 ] ) ; } } } return answer ; } int main ( ) { string s = " adbabd " ; int n = s . size ( ) ; cout << ( longestSubstring ( s , n ) ) ; }

Index/key variables: i, mask, mask2
Accumulator variables: i, j, mask, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void countNums ( int N ) { int dp [ N ] [ 16 ] ; memset ( dp , 0 , sizeof ( dp [ 0 ] [ 0 ] ) * N * 16 ) ; for ( int i = 1 ; i <= 9 ; i ++ ) dp [ 0 ] [ i ] = 1 ; for ( int i = 1 ; i < N ; i ++ ) { for ( int j = 0 ; j < 10 ; j ++ ) { for ( int k = 0 ; k < 16 ; k ++ ) { int xo = j ^ k ; dp [ i ] [ xo ] += dp [ i - 1 ] [ k ] ; } } } int count = 0 ; for ( int i = 0 ; i < 10 ; i ++ ) count += dp [ N - 1 ] [ i ] ; cout << ( count ) << endl ; } int main ( ) { int N = 1 ; countNums ( N ) ; }

Index/key variables: N, i, k, xo
Accumulator variables: count, i, j, k, stdc
Iterator variables: i, j, k
C++ program:
#include <iostream>
using namespace std ; int count ( int a [ ] , int M , int N ) { int cnt = 0 ; for ( int i = 1 ; i <= M ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( i % a [ j ] == 0 ) { cnt ++ ; break ; } } } return cnt ; } int main ( ) { int arr [ ] = { 2 , 3 , 5 , 7 } ; int m = 100 ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << count ( arr , m , n ) ; return 0 ; }

Index/key variables: j
Accumulator variables: cnt, i, j
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int dp [ 15 ] [ 10 ] ; int solve ( int n , int last , int k ) { if ( n == 1 ) { if ( last == k ) { return ( k - 1 ) ; } else { return 1 ; } } if ( dp [ n ] [ last ] ) return dp [ n ] [ last ] ; if ( last == k ) { return dp [ n ] [ last ] = ( k - 1 ) * solve ( n - 1 , k , k ) + ( k - 1 ) * solve ( n - 1 , 1 , k ) ; } else { return dp [ n ] [ last ] = solve ( n - 1 , k , k ) ; } } int main ( ) { int n = 2 , k = 3 ; int x = solve ( n , k , k ) + solve ( n , 1 , k ) ; cout << x ; }

Index/key variables: last, n
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void print ( vector < int > & occ , string & s ) { for ( int i = 1 ; i <= int ( s . size ( ) ) ; i ++ ) { cout << s . substr ( 0 , i ) << " ▁ occurs ▁ " << occ [ i ] << " ▁ times . " << endl ; } } vector < int > prefix_function ( string & s ) { vector < int > LPS ( s . size ( ) ) ; LPS [ 0 ] = 0 ; for ( int i = 1 ; i < int ( s . size ( ) ) ; i ++ ) { int j = LPS [ i - 1 ] ; while ( j > 0 && s [ i ] != s [ j ] ) { j = LPS [ j - 1 ] ; } if ( s [ i ] == s [ j ] ) { LPS [ i ] = j + 1 ; } else { LPS [ i ] = 0 ; } } return LPS ; } void count_occurence ( string & s ) { int n = s . size ( ) ; vector < int > LPS = prefix_function ( s ) ; vector < int > occ ( n + 1 ) ; for ( int i = 0 ; i < n ; i ++ ) { occ [ LPS [ i ] ] ++ ; } for ( int i = n - 1 ; i > 0 ; i -- ) { occ [ LPS [ i - 1 ] ] += occ [ i ] ; } for ( int i = 0 ; i <= n ; i ++ ) occ [ i ] ++ ; print ( occ , s ) ; } int main ( ) { string A = " ABACABA " ; count_occurence ( A ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maximumSum ( int A [ ] , int B [ ] , int length , int X , int Y ) { int l = length ; int l1 = min ( length , X ) ; int l2 = min ( length , Y ) ; int dp [ l1 + 1 ] [ l2 + 1 ] ; memset ( dp , 0 , sizeof ( dp ) ) ; dp [ 0 ] [ 0 ] = 0 ; int max_sum = INT_MIN ; for ( int i = 1 ; i <= l1 ; i ++ ) { dp [ i ] [ 0 ] = dp [ i - 1 ] [ 0 ] + A [ i - 1 ] ; max_sum = max ( max_sum , dp [ i ] [ 0 ] ) ; } for ( int i = 1 ; i <= l2 ; i ++ ) { dp [ 0 ] [ i ] = dp [ 0 ] [ i - 1 ] + B [ i - 1 ] ; max_sum = max ( max_sum , dp [ 0 ] [ i ] ) ; } for ( int i = 1 ; i <= l1 ; i ++ ) { for ( int j = 1 ; j <= l2 ; j ++ ) { if ( i + j <= l ) dp [ i ] [ j ] = max ( dp [ i - 1 ] [ j ] + A [ i + j - 1 ] , dp [ i ] [ j - 1 ] + B [ i + j - 1 ] ) ; max_sum = max ( dp [ i ] [ j ] , max_sum ) ; } } return max_sum ; } int main ( ) { int A [ ] = { 1 , 2 , 3 , 4 , 5 } ; int B [ ] = { 5 , 4 , 3 , 2 , 1 } ; int X = 3 , Y = 2 ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; cout << maximumSum ( A , B , N , X , Y ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int reduceZero ( int N ) { vector < int > dp ( N + 1 , 1e9 ) ; dp [ 0 ] = 0 ; for ( int i = 0 ; i <= N ; i ++ ) { for ( char c : to_string ( i ) ) { dp [ i ] = min ( dp [ i ] , dp [ i - ( c - '0' ) ] + 1 ) ; } } return dp [ N ] ; } int main ( ) { int N = 25 ; cout << reduceZero ( N ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: i, stdc
Iterator variables: c, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printpenta ( int n ) { if ( n < 0 ) return ; int first = 0 ; int second = 0 ; int third = 0 ; int fourth = 0 ; int fifth = 1 ; int curr = 0 ; if ( n == 0 n == 1 n == 2 n == 3 ) cout << first << " STRNEWLINE " ; else if ( n == 5 ) cout << fifth << " STRNEWLINE " ; else { for ( int i = 5 ; i < n ; i ++ ) { curr = first + second + third + fourth + fifth ; first = second ; second = third ; third = fourth ; fourth = fifth ; fifth = curr ; } cout << curr << " STRNEWLINE " ; } } int main ( ) { int n = 10 ; printpenta ( n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int dp [ 100001 ] [ 20 ] [ 2 ] ; int possibleBinaries ( int pos , int ones , int sum , int k ) { if ( ones == k ) return 0 ; if ( pos == 0 ) return ( sum == 0 ) ? 1 : 0 ; if ( dp [ pos ] [ ones ] [ sum ] != -1 ) return dp [ pos ] [ ones ] [ sum ] ; int ret = possibleBinaries ( pos - 1 , ones + 1 , ( sum + 1 ) % 2 , k ) + possibleBinaries ( pos - 1 , 0 , sum , k ) ; dp [ pos ] [ ones ] [ sum ] = ret ; return dp [ pos ] [ ones ] [ sum ] ; } int main ( ) { int N = 3 ; int K = 2 ; memset ( dp , -1 , sizeof dp ) ; cout << possibleBinaries ( N , 0 , 0 , K ) ; }

Index/key variables: ones, pos, sum
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
#define ll  long long
using namespace std ; class Solution { public : ll ncr [ 101 ] [ 101 ] ; int n , k ; vector < ll > A ; Solution ( int N , int K , vector < ll > B ) { memset ( ncr , -1 , sizeof ( ncr ) ) ; n = N ; k = K ; A = B ; A . insert ( A . begin ( ) , 0 ) ; } ll f ( int N , int K ) ; ll pairsPower ( ) ; } ; ll Solution :: f ( int n , int k ) { if ( k == 0 ) return 1LL ; if ( n == k ) return 1LL ; if ( n < k ) return 0 ; if ( ncr [ n ] [ k ] != -1 ) return ncr [ n ] [ k ] ; return ncr [ n ] [ k ] = f ( n - 1 , k ) + f ( n - 1 , k - 1 ) ; } ll Solution :: pairsPower ( ) { ll pre [ n + 1 ] [ k + 1 ] ; ll ans = 0 ; sort ( A . begin ( ) + 1 , A . end ( ) ) ; for ( int i = 1 ; i <= n ; ++ i ) { pre [ i ] [ 0 ] = 1LL ; for ( int j = 1 ; j <= k ; j ++ ) { pre [ i ] [ j ] = A [ i ] * pre [ i ] [ j - 1 ] ; } if ( i != 1 ) { for ( int j = 0 ; j <= k ; ++ j ) pre [ i ] [ j ] = pre [ i ] [ j ] + pre [ i - 1 ] [ j ] ; } } for ( int i = n ; i >= 2 ; -- i ) { for ( int j = 0 ; j <= k ; j ++ ) { ll val = f ( k , j ) ; ll val1 = pow ( A [ i ] , k - j ) * pre [ i - 1 ] [ j ] ; val = val * val1 ; if ( j % 2 == 0 ) ans = ( ans + val ) ; else ans = ( ans - val ) ; } } ans = 2LL * ans ; return ans ; } int main ( ) { int N = 3 ; int K = 3 ; vector < ll > arr = { 1 , 2 , 3 } ; Solution obj ( N , K , arr ) ; cout << obj . pairsPower ( ) << endl ; return 0 ; }

Index/key variables: i, j, k, n
Accumulator variables: j, stdc
Iterator variables: i, j
Class/struct names: Solution
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MOD  1000000007
long long dp [ 101 ] [ 101 ] [ 101 ] ; int N , M , K ; void Initialize ( ) { for ( int i = 0 ; i <= 100 ; i ++ ) for ( int j = 0 ; j <= 100 ; j ++ ) for ( int z = 0 ; z <= 100 ; z ++ ) dp [ i ] [ j ] [ z ] = -1 ; } int CountWays ( int i , int j , int k ) { if ( i >= N i < 0 j > = M j < 0 k < 0 ) return 0 ; if ( i == 0 && j == 0 && k == 0 ) return 1 ; if ( dp [ i ] [ j ] [ k ] != -1 ) return dp [ i ] [ j ] [ k ] ; else dp [ i ] [ j ] [ k ] = ( CountWays ( i + 1 , j , k - 1 ) % MOD + CountWays ( i - 1 , j , k - 1 ) % MOD + CountWays ( i , j - 1 , k - 1 ) % MOD + CountWays ( i , j + 1 , k - 1 ) % MOD + CountWays ( i , j , k - 1 ) % MOD ) % MOD ; return dp [ i ] [ j ] [ k ] ; } int main ( ) { N = 3 ; M = 3 ; K = 4 ; Initialize ( ) ; cout << CountWays ( 0 , 0 , K ) << " STRNEWLINE " ; return 0 ; }

Index/key variables: i, j, k, z
Accumulator variables: i, j, stdc, z
Iterator variables: i, j, z
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool prime [ 100001 ] ; void SieveOfEratosthenes ( ) { memset ( prime , true , sizeof ( prime ) ) ; prime [ 0 ] = prime [ 1 ] = false ; for ( int p = 2 ; p * p <= 100000 ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i <= 100000 ; i += p ) prime [ i ] = false ; } } } int distinctPrimeSubSeq ( int a [ ] , int n , int k ) { SieveOfEratosthenes ( ) ; vector < int > primes ; for ( int i = 0 ; i < n ; i ++ ) { if ( prime [ a [ i ] ] ) primes . push_back ( a [ i ] ) ; } int l = primes . size ( ) ; sort ( primes . begin ( ) , primes . end ( ) ) ; vector < int > b ; vector < int > dp ; int sum = 0 ; for ( int i = 0 ; i < l ; ) { int count = 1 , x = a [ i ] ; i ++ ; while ( i < l && a [ i ] == x ) { count ++ ; i ++ ; } b . push_back ( count ) ; dp . push_back ( count ) ; sum += count ; } int of_length = 2 ; int len = dp . size ( ) ; int ans = 0 ; while ( of_length <= k ) { int freq = 0 ; int prev = 0 ; for ( int i = 0 ; i < ( len - 1 ) ; i ++ ) { freq += dp [ i ] ; int j = sum - freq ; int subseq = b [ i ] * j ; ans += subseq ; dp [ i ] = subseq ; prev += dp [ i ] ; } len -- ; sum = prev ; of_length ++ ; } ans += ( l + 1 ) ; return ans ; } int main ( ) { int a [ ] = { 1 , 2 , 2 , 3 , 3 , 4 , 5 } ; int n = sizeof ( a ) / sizeof ( int ) ; int k = 3 ; cout << distinctPrimeSubSeq ( a , n , k ) ; return 0 ; }

Index/key variables: i, p
Accumulator variables: ans, count, freq, i, len, of_length, p, prev, stdc, sum
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMinPrizes ( int arr [ ] , int n ) { int totalPrizes = 0 , j , x , y ; for ( int i = 0 ; i < n ; i ++ ) { x = 1 ; j = i ; while ( j > 0 && arr [ j ] > arr [ j - 1 ] ) { x ++ ; j -- ; } j = i ; y = 1 ; while ( j < n - 1 && arr [ j ] > arr [ j + 1 ] ) { y ++ ; j ++ ; } totalPrizes += max ( { x , y } ) ; } cout << totalPrizes << endl ; return 0 ; } int main ( ) { int arr [ ] = { 1 , 2 , 2 , 3 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; findMinPrizes ( arr , n ) ; }

Index/key variables: j
Accumulator variables: i, j, stdc, totalPrizes, x, y
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int mod = 1000000007 ; int dp [ 1000 ] [ 1000 ] ; int calculate ( int pos , int left , int k , int L , int R ) { if ( pos == k ) { if ( left == 0 ) return 1 ; else return 0 ; } if ( left == 0 ) return 0 ; if ( dp [ pos ] [ left ] != -1 ) return dp [ pos ] [ left ] ; int answer = 0 ; for ( int i = L ; i <= R ; i ++ ) { if ( i > left ) break ; answer = ( answer + calculate ( pos + 1 , left - i , k , L , R ) ) % mod ; } return dp [ pos ] [ left ] = answer ; } int countWaystoDivide ( int n , int k , int L , int R ) { memset ( dp , -1 , sizeof ( dp ) ) ; return calculate ( 0 , n , k , L , R ) ; } int main ( ) { int N = 12 ; int K = 3 ; int L = 1 ; int R = 5 ; cout << countWaystoDivide ( N , K , L , R ) ; return 0 ; }

Index/key variables: left, pos
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < int > minSqrNum ( int n ) { int arr [ n + 1 ] , k ; int sqrNum [ n + 1 ] ; vector < int > v ; arr [ 0 ] = 0 ; sqrNum [ 0 ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { arr [ i ] = arr [ i - 1 ] + 1 ; sqrNum [ i ] = 1 ; k = 1 ; while ( k * k <= i ) { if ( arr [ i ] > arr [ i - k * k ] + 1 ) { arr [ i ] = arr [ i - k * k ] + 1 ; sqrNum [ i ] = k * k ; } k ++ ; } } while ( n > 0 ) { v . push_back ( sqrNum [ n ] ) ; n -= sqrNum [ n ] ; } return v ; } int main ( ) { int n = 10 ; vector < int > v ; v = minSqrNum ( n ) ; for ( auto i = v . begin ( ) ; i != v . end ( ) ; i ++ ) { cout << * i ; if ( i + 1 != v . end ( ) ) cout << " ▁ + ▁ " ; } return 0 ; }

Index/key variables: i, n
Accumulator variables: i, k, n, stdc
Iterator variables: i
C program:
#include <stdio.h>
void count_setbit ( int N ) { int result = 0 ; for ( int i = 0 ; i < 32 ; i ++ ) { if ( ( 1 << i ) & N ) { result ++ ; } } printf ( " % d STRNEWLINE " , result ) ; } int main ( ) { int N = 43 ; count_setbit ( N ) ; return 0 ; }

Accumulator variables: i, result
Iterator variables: i
C program:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct cantor { double start , end ; struct cantor * next ; } Cantor ; Cantor * startList ( Cantor * head , double start_num , double end_num ) { if ( head == NULL ) { head = ( Cantor * ) malloc ( sizeof ( Cantor ) ) ; head -> start = start_num ; head -> end = end_num ; head -> next = NULL ; } return head ; } Cantor * propagate ( Cantor * head ) { Cantor * temp = head ; if ( temp != NULL ) { Cantor * newNode = ( Cantor * ) malloc ( sizeof ( Cantor ) ) ; double diff = ( ( ( temp -> end ) - ( temp -> start ) ) / 3 ) ; newNode -> end = temp -> end ; temp -> end = ( ( temp -> start ) + diff ) ; newNode -> start = ( newNode -> end ) - diff ; newNode -> next = temp -> next ; temp -> next = newNode ; propagate ( temp -> next -> next ) ; } return head ; } void print ( Cantor * temp ) { while ( temp != NULL ) { printf ( " [ % lf ] ▁ - - ▁ [ % lf ] TABSYMBOL " , temp -> start , temp -> end ) ; temp = temp -> next ; } printf ( " STRNEWLINE " ) ; } void buildCantorSet ( int A , int B , int L ) { Cantor * head = NULL ; head = startList ( head , A , B ) ; for ( int i = 0 ; i < L ; i ++ ) { printf ( " Level _ % d ▁ : ▁ " , i ) ; print ( head ) ; propagate ( head ) ; } printf ( " Level _ % d ▁ : ▁ " , L ) ; print ( head ) ; } int main ( ) { int A = 0 ; int B = 9 ; int L = 2 ; buildCantorSet ( A , B , L ) ; return 0 ; }

Accumulator variables: i
Iterator variables: i
Class/struct names: cantor
C program:
#include <stdio.h>
#include <string.h>
void encrypt ( char input [ 100 ] ) { char evenPos = ' @ ' , oddPos = ' ! ' ; int repeat , ascii ; for ( int i = 0 ; i <= strlen ( input ) ; i ++ ) { ascii = input [ i ] ; repeat = ascii >= 97 ? ascii - 96 : ascii - 64 ; for ( int j = 0 ; j < repeat ; j ++ ) { if ( i % 2 == 0 ) printf ( " % c " , oddPos ) ; else printf ( " % c " , evenPos ) ; } } } void main ( ) { char input [ 100 ] = { ' A ' , ' b ' , ' C ' , ' d ' } ; encrypt ( input ) ; }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
C program:
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
bool isPalRec ( char str [ ] , int s , int e ) { if ( s == e ) return true ; if ( str [ s ] != str [ e ] ) return false ; if ( s < e + 1 ) return isPalRec ( str , s + 1 , e - 1 ) ; return true ; } bool isPalindrome ( char str [ ] ) { int n = strlen ( str ) ; if ( n == 0 ) return true ; return isPalRec ( str , 0 , n - 1 ) ; } int main ( ) { char str [ ] = " geeg " ; if ( isPalindrome ( str ) ) printf ( " Yes " ) ; else printf ( " No " ) ; return 0 ; }

Index/key variables: e, s
C program:
#include <stdio.h>
#include <limits.h>
int myAtoi ( const char * str ) { int sign = 1 , base = 0 , i = 0 ; while ( str [ i ] == ' ▁ ' ) { i ++ ; } if ( str [ i ] == ' - ' str [ i ] == ' + ' ) { sign = 1 - 2 * ( str [ i ++ ] == ' - ' ) ; } while ( str [ i ] >= '0' && str [ i ] <= '9' ) { if ( base > INT_MAX / 10 || ( base == INT_MAX / 10 && str [ i ] - '0' > 7 ) ) { if ( sign == 1 ) return INT_MAX ; else return INT_MIN ; } base = 10 * base + ( str [ i ++ ] - '0' ) ; } return base * sign ; } int main ( ) { char str [ ] = " ▁ - 123" ; int val = myAtoi ( str ) ; printf ( " % d ▁ " , val ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i
C program:
#include <stdio.h>
#include <stdbool.h>
bool fillUtil ( int res [ ] , int curr , int n ) { if ( curr == 0 ) return true ; int i ; for ( i = 0 ; i < 2 * n - curr - 1 ; i ++ ) { if ( res [ i ] == 0 && res [ i + curr + 1 ] == 0 ) { res [ i ] = res [ i + curr + 1 ] = curr ; if ( fillUtil ( res , curr - 1 , n ) ) return true ; res [ i ] = res [ i + curr + 1 ] = 0 ; } } return false ; } void fill ( int n ) { int res [ 2 * n ] , i ; for ( i = 0 ; i < 2 * n ; i ++ ) res [ i ] = 0 ; if ( fillUtil ( res , n , n ) ) { for ( i = 0 ; i < 2 * n ; i ++ ) printf ( " % d ▁ " , res [ i ] ) ; } else puts ( " Not ▁ Possible " ) ; } int main ( ) { fill ( 7 ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
C program:
#include <bits/stdc++.h>
using namespace std ; struct node { int data ; struct node * left , * right ; } ; int updatetree ( node * root ) { if ( ! root ) return 0 ; if ( root -> left == NULL && root -> right == NULL ) return root -> data ; int leftsum = updatetree ( root -> left ) ; int rightsum = updatetree ( root -> right ) ; root -> data += leftsum ; return root -> data + rightsum ; } void inorder ( struct node * node ) { if ( node == NULL ) return ; inorder ( node -> left ) ; printf ( " % d ▁ " , node -> data ) ; inorder ( node -> right ) ; } struct node * newNode ( int data ) { struct node * node = ( struct node * ) malloc ( sizeof ( struct node ) ) ; node -> data = data ; node -> left = NULL ; node -> right = NULL ; return ( node ) ; } int main ( ) { struct node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 3 ) ; root -> left -> left = newNode ( 4 ) ; root -> left -> right = newNode ( 5 ) ; root -> right -> right = newNode ( 6 ) ; updatetree ( root ) ; cout << " Inorder ▁ traversal ▁ of ▁ the ▁ modified ▁ tree ▁ is ▁ STRNEWLINE " ; inorder ( root ) ; return 0 ; }

Accumulator variables: data, stdc
Class/struct names: node
C program:
#include <stdio.h>
void calculateSpan ( int price [ ] , int n , int S [ ] ) { S [ 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { S [ i ] = 1 ; for ( int j = i - 1 ; ( j >= 0 ) && ( price [ i ] >= price [ j ] ) ; j -- ) S [ i ] ++ ; } } void printArray ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) printf ( " % d ▁ " , arr [ i ] ) ; } int main ( ) { int price [ ] = { 10 , 4 , 5 , 90 , 120 , 80 } ; int n = sizeof ( price ) / sizeof ( price [ 0 ] ) ; int S [ n ] ; calculateSpan ( price , n , S ) ; printArray ( S , n ) ; return 0 ; }

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