dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; void solve ( int & N , int & P1 , int & P2 , int & X , bool Move , bool QuitP1 , bool QuitP2 ) { if ( N == 0 or ( QuitP1 and QuitP2 ) ) { cout << " Number ▁ of ▁ pens ▁ remaining " << " ▁ in ▁ the ▁ box : ▁ " << N << endl ; cout << " Number ▁ of ▁ pens ▁ collected " << " ▁ by ▁ P1 : ▁ " << P1 << endl ; cout << " Number ▁ of ▁ pens ▁ collected " << " ▁ by ▁ P2 : ▁ " << P2 << endl ; return ; } if ( Move == 0 and QuitP1 == false ) { int req_P1 = pow ( 2 , X ) ; if ( req_P1 <= N ) { P1 += req_P1 ; N -= req_P1 ; } else { QuitP1 = true ; } } else if ( Move == 1 and QuitP2 == false ) { int req_P2 = pow ( 3 , X ) ; if ( req_P2 <= N ) { P2 += req_P2 ; N -= req_P2 ; } else { QuitP2 = true ; } } X ++ ; Move = ( ( Move == 1 ) ? 0 : 1 ) ; solve ( N , P1 , P2 , X , Move , QuitP1 , QuitP2 ) ; } void PenGame ( int N ) { int P1 = 0 ; int P2 = 0 ; int X = 0 ; bool Move = 0 ; bool QuitP1 = 0 ; bool QuitP2 = 0 ; solve ( N , P1 , P2 , X , Move , QuitP1 , QuitP2 ) ; } int main ( ) { int N = 22 ; PenGame ( N ) ; return 0 ; }

Accumulator variables: N, P1, P2, X, stdc
Boolean variables: QuitP1, QuitP2
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findSub ( vector < vector < int > > & res , int sum , int K , int N , vector < int > & temp ) { if ( K == 0 && sum == 0 ) { res . push_back ( temp ) ; return ; } if ( sum <= 0 K <= 0 ) { return ; } for ( int i = 1 ; i <= N ; i ++ ) { temp . push_back ( i ) ; findSub ( res , sum - i , K - 1 , N , temp ) ; temp . pop_back ( ) ; } } void UtilPrintSubsequncesOfKSumN ( int N , int K ) { vector < vector < int > > res ; vector < int > temp ; findSub ( res , N , K , N , temp ) ; int sz = res . size ( ) ; cout << " { ▁ " ; for ( int i = 0 ; i < sz ; i ++ ) { cout << " { ▁ " ; for ( int j = 0 ; j < K ; j ++ ) { if ( j == K - 1 ) cout << res [ i ] [ j ] << " ▁ " ; else cout << res [ i ] [ j ] << " , ▁ " ; } if ( i == sz - 1 ) cout << " } " ; else cout << " } , ▁ " ; } cout << " ▁ } " ; } int main ( ) { int N = 4 ; int K = 2 ; UtilPrintSubsequncesOfKSumN ( N , K ) ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void checkUntil ( int num , int K , int N , vector < int > & ans ) { if ( N == 1 ) { ans . push_back ( num ) ; return ; } if ( ( num % 10 + K ) <= 9 ) checkUntil ( 10 * num + ( num % 10 + K ) , K , N - 1 , ans ) ; if ( K ) { if ( ( num % 10 - K ) >= 0 ) checkUntil ( 10 * num + num % 10 - K , K , N - 1 , ans ) ; } } void check ( int K , int N , vector < int > & ans ) { for ( int i = 1 ; i <= 9 ; i ++ ) { checkUntil ( i , K , N , ans ) ; } } void print ( vector < int > & ans ) { for ( int i = 0 ; i < ans . size ( ) ; i ++ ) { cout << ans [ i ] << " , ▁ " ; } } int main ( ) { int N = 4 , K = 8 ; vector < int > ans ; check ( K , N , ans ) ; print ( ans ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minSum = INT_MAX ; void getMinPathSum ( unordered_map < int , vector < pair < int , int > > > & graph , vector < bool > & visited , vector < int > necessary , int src , int dest , int currSum ) { if ( src == dest ) { bool flag = true ; for ( int i : necessary ) { if ( ! visited [ i ] ) { flag = false ; break ; } } if ( flag ) minSum = min ( minSum , currSum ) ; return ; } else { visited [ src ] = true ; for ( auto node : graph [ src ] ) { if ( ! visited [ node . first ] ) { visited [ node . first ] = true ; getMinPathSum ( graph , visited , necessary , node . first , dest , currSum + node . second ) ; visited [ node . first ] = false ; } } visited [ src ] = false ; } } int main ( ) { unordered_map < int , vector < pair < int , int > > > graph ; graph [ 0 ] = { { 1 , 2 } , { 2 , 3 } , { 3 , 2 } } ; graph [ 1 ] = { { 4 , 4 } , { 0 , 1 } } ; graph [ 2 ] = { { 4 , 5 } , { 5 , 6 } } ; graph [ 3 ] = { { 5 , 7 } , { 0 , 1 } } ; graph [ 4 ] = { { 6 , 4 } } ; graph [ 5 ] = { { 6 , 2 } } ; graph [ 6 ] = { { 7 , 11 } } ; int n = 7 ; int source = 0 ; int dest = 6 ; vector < bool > visited ( n , false ) ; vector < int > necessary { 2 , 4 } ; getMinPathSum ( graph , visited , necessary , source , dest , 0 ) ; if ( minSum == INT_MAX ) cout << " - 1 STRNEWLINE " ; else cout << minSum << ' ' ; return 0 ; }

Index/key variables: i, src
Accumulator variables: stdc
Iterator variables: i, node
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; void comb ( int * arr , int len , int r , int ipos , int * op , int opos , int sum ) { if ( opos == r ) { int sum2 = 0 ; for ( int i = 0 ; i < opos ; i ++ ) { sum2 = sum2 + op [ i ] ; } if ( sum == sum2 ) { for ( int i = 0 ; i < opos ; i ++ ) cout << op [ i ] << " , ▁ " ; cout << endl ; } return ; } if ( ipos < len ) { comb ( arr , len , r , ipos + 1 , op , opos , sum ) ; op [ opos ] = arr [ ipos ] ; comb ( arr , len , r , ipos + 1 , op , opos + 1 , sum ) ; } } int main ( ) { int arr [ ] = { 4 , 6 , 8 , 2 , 12 } ; int K = 3 ; int S = 20 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int op [ N ] = { 0 } ; comb ( arr , N , K , 0 , op , 0 , S ) ; return 0 ; }

Index/key variables: N, i, ipos, opos
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; bool traverseMatrixDiagonally ( int m [ ] [ 5 ] , int i , int j , int row , int col ) { static int k1 = 0 , k2 = 0 ; static bool flag = true ; if ( i >= row j >= col ) { if ( flag ) { int a = k1 ; k1 = k2 ; k2 = a ; flag = ! flag ; k1 ++ ; } else { int a = k1 ; k1 = k2 ; k2 = a ; flag = ! flag ; } cout << endl ; return false ; } cout << m [ i ] [ j ] << " ▁ " ; if ( traverseMatrixDiagonally ( m , i + 1 , j + 1 , row , col ) ) { return true ; } if ( traverseMatrixDiagonally ( m , k1 , k2 , row , col ) ) { return true ; } return true ; } int main ( ) { int mtrx [ 5 ] [ 5 ] = { { 10 , 11 , 12 , 13 , 14 } , { 15 , 16 , 17 , 18 , 19 } , { 20 , 21 , 22 , 23 , 24 } , { 25 , 26 , 27 , 28 , 29 } , { 30 , 31 , 32 , 33 , 34 } } ; traverseMatrixDiagonally ( mtrx , 0 , 0 , 5 , 5 ) ; }

Index/key variables: i, j
Accumulator variables: k1
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int n = 5 , m = 7 ; vector < pair < int , int > > g [ m ] ; int col [ n ] ; bool cyc ; int res [ m ] ; void dfs ( int v ) { col [ v ] = 1 ; for ( auto p : g [ v ] ) { int to = p . first , id = p . second ; if ( col [ to ] == 0 ) { dfs ( to ) ; res [ id ] = 1 ; } else if ( col [ to ] == 2 ) { res [ id ] = 1 ; } else { res [ id ] = 2 ; cyc = true ; } } col [ v ] = 2 ; } int main ( ) { g [ 0 ] . push_back ( make_pair ( 1 , 0 ) ) ; g [ 0 ] . push_back ( make_pair ( 2 , 1 ) ) ; g [ 1 ] . push_back ( make_pair ( 2 , 2 ) ) ; g [ 1 ] . push_back ( make_pair ( 3 , 3 ) ) ; g [ 2 ] . push_back ( make_pair ( 3 , 4 ) ) ; g [ 3 ] . push_back ( make_pair ( 4 , 5 ) ) ; g [ 4 ] . push_back ( make_pair ( 2 , 6 ) ) ; for ( int i = 0 ; i < n ; ++ i ) { if ( col [ i ] == 0 ) { dfs ( i ) ; } } cout << ( cyc ? 2 : 1 ) << endl ; for ( int i = 0 ; i < m ; ++ i ) { cout << res [ i ] << ' ▁ ' ; } return 0 ; }

Index/key variables: i, id, m, n, to, v
Accumulator variables: stdc
Iterator variables: i, p
Boolean variables: cyc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void sumSubsets ( vector < int > set , int n , int target ) { int x [ set . size ( ) ] ; int j = set . size ( ) - 1 ; while ( n > 0 ) { x [ j ] = n % 2 ; n = n / 2 ; j -- ; } int sum = 0 ; for ( int i = 0 ; i < set . size ( ) ; i ++ ) if ( x [ i ] == 1 ) sum = sum + set [ i ] ; if ( sum == target ) { cout << ( " { " ) ; for ( int i = 0 ; i < set . size ( ) ; i ++ ) if ( x [ i ] == 1 ) cout << set [ i ] << " , ▁ " ; cout << ( " } , ▁ " ) ; } } void findSubsets ( vector < int > arr , int K ) { int x = pow ( 2 , arr . size ( ) ) ; for ( int i = 1 ; i < x ; i ++ ) sumSubsets ( arr , i , K ) ; } int main ( ) { vector < int > arr = { 5 , 10 , 12 , 13 , 15 , 18 } ; int K = 30 ; findSubsets ( arr , K ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define maxN  10
int fact [ maxN ] ; int ncr ( int n , int r ) { return ( fact [ n ] / fact [ r ] ) / fact [ n - r ] ; } int findSum ( int * arr , int n ) { fact [ 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) fact [ i ] = i * fact [ i - 1 ] ; int mul = 0 ; for ( int i = 0 ; i <= n - 1 ; i ++ ) mul += ( int ) pow ( 2 , i ) * ncr ( n - 1 , i ) ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) ans += mul * arr [ i ] ; return ans ; } int main ( ) { int arr [ ] = { 1 , 1 } ; int n = sizeof ( arr ) / sizeof ( int ) ; cout << findSum ( arr , n ) ; return 0 ; }

Index/key variables: i, maxN, n, r
Accumulator variables: ans, i, mul, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define R  4
#define C  4
int countPaths ( int maze [ ] [ C ] ) { if ( maze [ 0 ] [ 0 ] == -1 ) return 0 ; for ( int i = 0 ; i < R ; i ++ ) { if ( maze [ i ] [ 0 ] == 0 ) maze [ i ] [ 0 ] = 1 ; else break ; } for ( int i = 1 ; i < C ; i ++ ) { if ( maze [ 0 ] [ i ] == 0 ) maze [ 0 ] [ i ] = 1 ; else break ; } for ( int i = 1 ; i < R ; i ++ ) { for ( int j = 1 ; j < C ; j ++ ) { if ( maze [ i ] [ j ] == -1 ) continue ; if ( maze [ i - 1 ] [ j ] > 0 ) maze [ i ] [ j ] = ( maze [ i ] [ j ] + maze [ i - 1 ] [ j ] ) ; if ( maze [ i ] [ j - 1 ] > 0 ) maze [ i ] [ j ] = ( maze [ i ] [ j ] + maze [ i ] [ j - 1 ] ) ; } } return ( maze [ R - 1 ] [ C - 1 ] > 0 ) ? maze [ R - 1 ] [ C - 1 ] : 0 ; } int numberOfPaths ( int m , int n ) { int path = 1 ; for ( int i = n ; i < ( m + n - 1 ) ; i ++ ) { path *= i ; path /= ( i - n + 1 ) ; } return path ; } int solve ( int maze [ ] [ C ] ) { int ans = numberOfPaths ( R , C ) - countPaths ( maze ) ; return ans ; } int main ( ) { int maze [ R ] [ C ] = { { 0 , 0 , 0 , 0 } , { 0 , -1 , 0 , 0 } , { -1 , 0 , 0 , 0 } , { 0 , 0 , 0 , 0 } } ; cout << solve ( maze ) ; return 0 ; }

Index/key variables: C, R, i, j
Accumulator variables: i, j, path, stdc
Iterator variables: i, j
C++ program:
#include <stdio.h>
#define N  4
bool solveMazeUtil ( int maze [ N ] [ N ] , int x , int y , int sol [ N ] [ N ] ) ; void printSolution ( int sol [ N ] [ N ] ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) printf ( " ▁ % d ▁ " , sol [ i ] [ j ] ) ; printf ( " STRNEWLINE " ) ; } } bool isSafe ( int maze [ N ] [ N ] , int x , int y ) { if ( x >= 0 && x < N && y >= 0 && y < N && maze [ x ] [ y ] != 0 ) return true ; return false ; } bool solveMaze ( int maze [ N ] [ N ] ) { int sol [ N ] [ N ] = { { 0 , 0 , 0 , 0 } , { 0 , 0 , 0 , 0 } , { 0 , 0 , 0 , 0 } , { 0 , 0 , 0 , 0 } } ; if ( solveMazeUtil ( maze , 0 , 0 , sol ) == false ) { printf ( " Solution ▁ doesn ' t ▁ exist " ) ; return false ; } printSolution ( sol ) ; return true ; } bool solveMazeUtil ( int maze [ N ] [ N ] , int x , int y , int sol [ N ] [ N ] ) { if ( x == N - 1 && y == N - 1 ) { sol [ x ] [ y ] = 1 ; return true ; } if ( isSafe ( maze , x , y ) == true ) { sol [ x ] [ y ] = 1 ; for ( int i = 1 ; i <= maze [ x ] [ y ] && i < N ; i ++ ) { if ( solveMazeUtil ( maze , x + i , y , sol ) == true ) return true ; if ( solveMazeUtil ( maze , x , y + i , sol ) == true ) return true ; } sol [ x ] [ y ] = 0 ; return false ; } return false ; } int main ( ) { int maze [ N ] [ N ] = { { 2 , 1 , 0 , 0 } , { 3 , 0 , 0 , 1 } , { 0 , 1 , 0 , 1 } , { 0 , 0 , 0 , 1 } } ; solveMaze ( maze ) ; return 0 ; }

Index/key variables: N, i, j, x, y
Accumulator variables: i, j
Iterator variables: i, j
C++ program:
#include <iostream>
#include <vector>
#include <cmath>
using namespace std ; vector < int > set ; vector < int > prime ; bool isPrime ( int x ) { int sqroot = sqrt ( x ) ; bool flag = true ; if ( x == 1 ) return false ; for ( int i = 2 ; i <= sqroot ; i ++ ) if ( x % i == 0 ) return false ; return true ; } void display ( ) { int length = set . size ( ) ; for ( int i = 0 ; i < length ; i ++ ) cout << set [ i ] << " ▁ " ; cout << " STRNEWLINE " ; } void primeSum ( int total , int N , int S , int index ) { if ( total == S && set . size ( ) == N ) { display ( ) ; return ; } if ( total > S || index == prime . size ( ) ) return ; set . push_back ( prime [ index ] ) ; primeSum ( total + prime [ index ] , N , S , index + 1 ) ; set . pop_back ( ) ; primeSum ( total , N , S , index + 1 ) ; } void allPrime ( int N , int S , int P ) { for ( int i = P + 1 ; i <= S ; i ++ ) { if ( isPrime ( i ) ) prime . push_back ( i ) ; } if ( prime . size ( ) < N ) return ; primeSum ( 0 , N , S , 0 ) ; } int main ( ) { int S = 54 , N = 2 , P = 3 ; allPrime ( N , S , P ) ; return 0 ; }

Index/key variables: i, index
Accumulator variables: i
Iterator variables: i
Boolean variables: flag
C++ program:
#include <iostream>
#include <vector>
using namespace std ; void grayCodeUtil ( vector < int > & res , int n , int & num ) { if ( n == 0 ) { res . push_back ( num ) ; return ; } grayCodeUtil ( res , n - 1 , num ) ; num = num ^ ( 1 << ( n - 1 ) ) ; grayCodeUtil ( res , n - 1 , num ) ; } vector < int > grayCodes ( int n ) { vector < int > res ; int num = 0 ; grayCodeUtil ( res , n , num ) ; return res ; } int main ( ) { int n = 3 ; vector < int > code = grayCodes ( n ) ; for ( int i = 0 ; i < code . size ( ) ; i ++ ) cout << code [ i ] << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isKPartitionPossibleRec ( int arr [ ] , int subsetSum [ ] , bool taken [ ] , int subset , int K , int N , int curIdx , int limitIdx ) { if ( subsetSum [ curIdx ] == subset ) { if ( curIdx == K - 2 ) return true ; return isKPartitionPossibleRec ( arr , subsetSum , taken , subset , K , N , curIdx + 1 , N - 1 ) ; } for ( int i = limitIdx ; i >= 0 ; i -- ) { if ( taken [ i ] ) continue ; int tmp = subsetSum [ curIdx ] + arr [ i ] ; if ( tmp <= subset ) { taken [ i ] = true ; subsetSum [ curIdx ] += arr [ i ] ; bool nxt = isKPartitionPossibleRec ( arr , subsetSum , taken , subset , K , N , curIdx , i - 1 ) ; taken [ i ] = false ; subsetSum [ curIdx ] -= arr [ i ] ; if ( nxt ) return true ; } } return false ; } bool isKPartitionPossible ( int arr [ ] , int N , int K ) { if ( K == 1 ) return true ; if ( N < K ) return false ; int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) sum += arr [ i ] ; if ( sum % K != 0 ) return false ; int subset = sum / K ; int subsetSum [ K ] ; bool taken [ N ] ; for ( int i = 0 ; i < K ; i ++ ) subsetSum [ i ] = 0 ; for ( int i = 0 ; i < N ; i ++ ) taken [ i ] = false ; subsetSum [ 0 ] = arr [ N - 1 ] ; taken [ N - 1 ] = true ; return isKPartitionPossibleRec ( arr , subsetSum , taken , subset , K , N , 0 , N - 1 ) ; } int main ( ) { int arr [ ] = { 2 , 1 , 4 , 5 , 3 , 3 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int K = 3 ; if ( isKPartitionPossible ( arr , N , K ) ) cout << " Partitions ▁ into ▁ equal ▁ sum ▁ is ▁ possible . STRNEWLINE " ; else cout << " Partitions ▁ into ▁ equal ▁ sum ▁ is ▁ not ▁ possible . STRNEWLINE " ; }

Index/key variables: K, N, curIdx, i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isParenthesis ( char c ) { return ( ( c == ' ( ' ) || ( c == ' ) ' ) ) ; } bool isValidString ( string str ) { int cnt = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str [ i ] == ' ( ' ) cnt ++ ; else if ( str [ i ] == ' ) ' ) cnt -- ; if ( cnt < 0 ) return false ; } return ( cnt == 0 ) ; } void removeInvalidParenthesis ( string str ) { if ( str . empty ( ) ) return ; set < string > visit ; queue < string > q ; string temp ; bool level ; q . push ( str ) ; visit . insert ( str ) ; while ( ! q . empty ( ) ) { str = q . front ( ) ; q . pop ( ) ; if ( isValidString ( str ) ) { cout << str << endl ; level = true ; } if ( level ) continue ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( ! isParenthesis ( str [ i ] ) ) continue ; temp = str . substr ( 0 , i ) + str . substr ( i + 1 ) ; if ( visit . find ( temp ) == visit . end ( ) ) { q . push ( temp ) ; visit . insert ( temp ) ; } } } } int main ( ) { string expression = " ( ) ( ) ) ( ) " ; removeInvalidParenthesis ( expression ) ; expression = " ( ) v ) " ; removeInvalidParenthesis ( expression ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cnt, i, stdc
Iterator variables: i
Boolean variables: level
C++ program:
#define N  4
#include <stdbool.h>
#include <stdio.h>
int ld [ 30 ] = { 0 } ; int rd [ 30 ] = { 0 } ; int cl [ 30 ] = { 0 } ; void printSolution ( int board [ N ] [ N ] ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) printf ( " ▁ % d ▁ " , board [ i ] [ j ] ) ; printf ( " STRNEWLINE " ) ; } } bool solveNQUtil ( int board [ N ] [ N ] , int col ) { if ( col >= N ) return true ; for ( int i = 0 ; i < N ; i ++ ) { if ( ( ld [ i - col + N - 1 ] != 1 && rd [ i + col ] != 1 ) && cl [ i ] != 1 ) { board [ i ] [ col ] = 1 ; ld [ i - col + N - 1 ] = rd [ i + col ] = cl [ i ] = 1 ; if ( solveNQUtil ( board , col + 1 ) ) return true ; ld [ i - col + N - 1 ] = rd [ i + col ] = cl [ i ] = 0 ; } } return false ; } bool solveNQ ( ) { int board [ N ] [ N ] = { { 0 , 0 , 0 , 0 } , { 0 , 0 , 0 , 0 } , { 0 , 0 , 0 , 0 } , { 0 , 0 , 0 , 0 } } ; if ( solveNQUtil ( board , 0 ) == false ) { printf ( " Solution ▁ does ▁ not ▁ exist " ) ; return false ; } printSolution ( board ) ; return true ; } int main ( ) { solveNQ ( ) ; return 0 ; }

Index/key variables: N, col, i, j
Accumulator variables: i, j
Iterator variables: i, j
C++ program:
#include <iostream>
using namespace std ; void printPairs ( int a [ ] , int n , int x ) { int i ; int rem [ x ] ; for ( i = 0 ; i < x ; i ++ ) { rem [ i ] = 0 ; } for ( i = 0 ; i < n ; i ++ ) { if ( a [ i ] < x ) { rem [ a [ i ] % x ] ++ ; } } for ( i = 1 ; i < x / 2 ; i ++ ) { if ( rem [ i ] > 0 && rem [ x - i ] > 0 ) { cout << " Yes " << " STRNEWLINE " ; break ; } } if ( i >= x / 2 ) { if ( x % 2 == 0 ) { if ( rem [ x / 2 ] > 1 ) { cout << " Yes " << " STRNEWLINE " ; } else { cout << " No " << " STRNEWLINE " ; } } else { if ( rem [ x / 2 ] > 0 && rem [ x - x / 2 ] > 0 ) { cout << " Yes " << " STRNEWLINE " ; } else { cout << " No " << " STRNEWLINE " ; } } } } int main ( ) { int A [ ] = { 1 , 4 , 45 , 6 , 10 , 8 } ; int n = 16 ; int arr_size = sizeof ( A ) / sizeof ( A [ 0 ] ) ; printPairs ( A , arr_size , n ) ; return 0 ; }

Index/key variables: i, x
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long int fact ( long long int n ) { long long int ans = 1 ; for ( long long int i = 2 ; i <= n ; i ++ ) ans *= i ; return ans ; } long long int remainder ( long long int n , long long int a , long long int p ) { long long int len = fact ( n ) ; long long int ans = 1 ; for ( long long int i = 1 ; i <= len ; i ++ ) ans = ( ans * a ) % p ; return ans ; } int main ( ) { long long int A = 2 , N = 1 , P = 2 ; cout << remainder ( N , A , P ) << endl ; }

Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool check ( int n , int w ) { vector < int > a ( 105 ) ; int p = 0 ; while ( n > 0 ) { a [ p ++ ] = n % w ; n /= w ; } bool flag = true ; for ( int i = 0 ; i <= 100 ; i ++ ) { if ( a [ i ] == 0 a [ i ] == 1 ) continue ; else if ( a [ i ] == w a [ i ] == w - 1 ) a [ i + 1 ] ++ ; else flag = false ; } return flag ; } int main ( ) { int B = 3 , N = 7 ; if ( check ( N , B ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: i
Accumulator variables: i, n, p, stdc
Iterator variables: i
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long mod = 1000000007 ; int exponentMod ( int A , int B ) { if ( A == 0 ) return 0 ; if ( B == 0 ) return 1 ; long long y ; if ( B % 2 == 0 ) { y = exponentMod ( A , B / 2 ) ; y = ( y * y ) % mod ; } else { y = A % mod ; y = ( y * exponentMod ( A , B - 1 ) % mod ) % mod ; } return ( int ) ( ( y + mod ) % mod ) ; } void countWays ( int N ) { long long select = exponentMod ( 2 , N - 1 ) ; long long ways = ( ( N % mod ) * ( select % mod ) ) ; ways %= mod ; cout << ways ; } int main ( ) { int N = 5 ; countWays ( N ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX  1000
bool isPerfectSquare ( long long int x ) { long double sr = sqrt ( x ) ; return ( ( sr - floor ( sr ) ) == 0 ) ? true : false ; } int getMid ( int s , int e ) { return s + ( e - s ) / 2 ; } int queryUtil ( int * st , int ss , int se , int qs , int qe , int index ) { if ( qs <= ss && qe >= se ) return st [ index ] ; if ( se < qs ss > qe ) return 0 ; int mid = getMid ( ss , se ) ; return queryUtil ( st , ss , mid , qs , qe , 2 * index + 1 ) + queryUtil ( st , mid + 1 , se , qs , qe , 2 * index + 2 ) ; } void updateValueUtil ( int * st , int ss , int se , int i , int diff , int si ) { if ( i < ss i > se ) return ; st [ si ] = st [ si ] + diff ; if ( se != ss ) { int mid = getMid ( ss , se ) ; updateValueUtil ( st , ss , mid , i , diff , 2 * si + 1 ) ; updateValueUtil ( st , mid + 1 , se , i , diff , 2 * si + 2 ) ; } } void updateValue ( int arr [ ] , int * st , int n , int i , int new_val ) { if ( i < 0 i > n - 1 ) { printf ( " Invalid ▁ Input " ) ; return ; } int diff , oldValue ; oldValue = arr [ i ] ; arr [ i ] = new_val ; if ( isPerfectSquare ( oldValue ) && isPerfectSquare ( new_val ) ) return ; if ( ! isPerfectSquare ( oldValue ) && ! isPerfectSquare ( new_val ) ) return ; if ( isPerfectSquare ( oldValue ) && ! isPerfectSquare ( new_val ) ) { diff = -1 ; } if ( ! isPerfectSquare ( oldValue ) && ! isPerfectSquare ( new_val ) ) { diff = 1 ; } updateValueUtil ( st , 0 , n - 1 , i , diff , 0 ) ; } void query ( int * st , int n , int qs , int qe ) { int perfectSquareInRange = queryUtil ( st , 0 , n - 1 , qs , qe , 0 ) ; cout << perfectSquareInRange << " STRNEWLINE " ; } int constructSTUtil ( int arr [ ] , int ss , int se , int * st , int si ) { if ( ss == se ) { if ( isPerfectSquare ( arr [ ss ] ) ) st [ si ] = 1 ; else st [ si ] = 0 ; return st [ si ] ; } int mid = getMid ( ss , se ) ; st [ si ] = constructSTUtil ( arr , ss , mid , st , si * 2 + 1 ) + constructSTUtil ( arr , mid + 1 , se , st , si * 2 + 2 ) ; return st [ si ] ; } int * constructST ( int arr [ ] , int n ) { int x = ( int ) ( ceil ( log2 ( n ) ) ) ; int max_size = 2 * ( int ) pow ( 2 , x ) - 1 ; int * st = new int [ max_size ] ; constructSTUtil ( arr , 0 , n - 1 , st , 0 ) ; return st ; } int main ( ) { int arr [ ] = { 16 , 15 , 8 , 9 , 14 , 25 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int * st = constructST ( arr , n ) ; int start = 0 ; int end = 4 ; query ( st , n , start , end ) ; int i = 3 ; int x = 11 ; updateValue ( arr , st , n , i , x ) ; start = 0 ; end = 4 ; query ( st , n , start , end ) ; return 0 ; }

Index/key variables: i, index, max_size, si, ss
Accumulator variables: stdc