dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; string unique ( string s ) { string str ; int len = s . length ( ) ; for ( int i = 0 ; i < len ; i ++ ) { char c = s [ i ] ; auto found = str . find ( c ) ; if ( found == std :: string :: npos ) { str += c ; } } return str ; } int main ( ) { string s = " geeksforgeeks " ; cout << unique ( s ) << endl ; }

Index/key variables: i
Accumulator variables: i, stdc, str
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int isPerfect ( int x ) { int sum_div = 1 ; for ( int i = 2 ; i <= x / 2 ; ++ i ) { if ( x % i == 0 ) { sum_div += i ; } } if ( sum_div == x ) { return 1 ; } else return 0 ; } void subsetSum ( int arr [ ] , int l , int r , int sum = 0 ) { if ( l > r ) { if ( isPerfect ( sum ) ) { cout << sum << " ▁ " ; } return ; } subsetSum ( arr , l + 1 , r , sum + arr [ l ] ) ; subsetSum ( arr , l + 1 , r , sum ) ; } int main ( ) { int arr [ ] = { 5 , 4 , 6 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; subsetSum ( arr , 0 , N - 1 ) ; return 0 ; }

Index/key variables: l
Accumulator variables: stdc, sum_div
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void PartitionSub ( int arr [ ] , int i , int N , int K , int nos , vector < vector < int > > & v ) { if ( i >= N ) { if ( nos == K ) { for ( int x = 0 ; x < v . size ( ) ; x ++ ) { cout << " { ▁ " ; for ( int y = 0 ; y < v [ x ] . size ( ) ; y ++ ) { cout << v [ x ] [ y ] ; if ( y == v [ x ] . size ( ) - 1 ) { cout << " ▁ " ; } else { cout << " , ▁ " ; } } if ( x == v . size ( ) - 1 ) { cout << " } " ; } else { cout << " } , ▁ " ; } } cout << endl ; } return ; } for ( int j = 0 ; j < K ; j ++ ) { if ( v [ j ] . size ( ) > 0 ) { v [ j ] . push_back ( arr [ i ] ) ; PartitionSub ( arr , i + 1 , N , K , nos , v ) ; v [ j ] . pop_back ( ) ; } else { v [ j ] . push_back ( arr [ i ] ) ; PartitionSub ( arr , i + 1 , N , K , nos + 1 , v ) ; v [ j ] . pop_back ( ) ; break ; } } } void partKSubsets ( int arr [ ] , int N , int K ) { vector < vector < int > > v ( K ) ; if ( K == 0 K > N ) { cout << " Not ▁ Possible " << endl ; } else { cout << " The ▁ Subset ▁ Combinations ▁ are : ▁ " << endl ; PartitionSub ( arr , 0 , N , K , 0 , v ) ; } } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int K = 2 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; partKSubsets ( arr , N , K ) ; }

Index/key variables: i, j, x, y
Accumulator variables: j, stdc, x, y
Iterator variables: j, x, y
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX = 100 ; int store [ MAX ] , n ; int graph [ MAX ] [ MAX ] ; int d [ MAX ] ; int ans ; void SieveOfEratosthenes ( bool prime [ ] , int p_size ) { prime [ 0 ] = false ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= p_size ; p ++ ) { if ( prime [ p ] ) { for ( int i = p * 2 ; i <= p_size ; i += p ) prime [ i ] = false ; } } } bool is_clique ( int b ) { for ( int i = 1 ; i < b ; i ++ ) { for ( int j = i + 1 ; j < b ; j ++ ) if ( graph [ store [ i ] ] [ store [ j ] ] == 0 ) return false ; } return true ; } void primeCliques ( int i , int l , bool prime [ ] ) { for ( int j = i + 1 ; j <= n ; j ++ ) { store [ l ] = j ; if ( is_clique ( l + 1 ) ) { if ( prime [ l ] ) ans ++ ; primeCliques ( j , l + 1 , prime ) ; } } } int main ( ) { int edges [ ] [ 2 ] = { { 1 , 2 } , { 2 , 3 } , { 3 , 1 } , { 4 , 3 } , { 4 , 5 } , { 5 , 3 } } ; int size = sizeof ( edges ) / sizeof ( edges [ 0 ] ) ; n = 5 ; bool prime [ n + 1 ] ; memset ( prime , true , sizeof ( prime ) ) ; SieveOfEratosthenes ( prime , n + 1 ) ; for ( int i = 0 ; i < size ; i ++ ) { graph [ edges [ i ] [ 0 ] ] [ edges [ i ] [ 1 ] ] = 1 ; graph [ edges [ i ] [ 1 ] ] [ edges [ i ] [ 0 ] ] = 1 ; d [ edges [ i ] [ 0 ] ] ++ ; d [ edges [ i ] [ 1 ] ] ++ ; } ans = 0 ; primeCliques ( 0 , 1 , prime ) ; cout << ans << " STRNEWLINE " ; return 0 ; }

Index/key variables: MAX, i, j, l, p
Accumulator variables: ans, i, j, p, stdc
Iterator variables: i, j, p
C++ program:
#include <iostream>
using namespace std ; #define dim  3
struct Node { int data ; Node * next ; Node * prev ; Node * up ; Node * down ; } ; Node * createNode ( int data ) { Node * temp = new Node ( ) ; temp -> data = data ; temp -> next = NULL ; temp -> prev = NULL ; temp -> up = NULL ; temp -> down = NULL ; return temp ; } Node * constructDoublyListUtil ( int mtrx [ ] [ dim ] , int i , int j , Node * curr ) { if ( i >= dim j >= dim ) { return NULL ; } Node * temp = createNode ( mtrx [ i ] [ j ] ) ; temp -> prev = curr ; temp -> up = curr ; temp -> next = constructDoublyListUtil ( mtrx , i , j + 1 , temp ) ; temp -> down = constructDoublyListUtil ( mtrx , i + 1 , j , temp ) ; return temp ; } Node * constructDoublyList ( int mtrx [ ] [ dim ] ) { return constructDoublyListUtil ( mtrx , 0 , 0 , NULL ) ; } void display ( Node * head ) { Node * rPtr ; Node * dPtr = head ; while ( dPtr ) { rPtr = dPtr ; while ( rPtr ) { cout << rPtr -> data << " ▁ " ; rPtr = rPtr -> next ; } cout << " STRNEWLINE " ; dPtr = dPtr -> down ; } } int main ( ) { int mtrx [ dim ] [ dim ] = { { 1 , 2 , 3 } , { 4 , 5 , 6 } , { 7 , 8 , 9 } } ; Node * list = constructDoublyList ( mtrx ) ; display ( list ) ; return 0 ; }

Index/key variables: dim, i, j
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int key ; struct Node * left , * right ; } ; Node * newNode ( int key ) { Node * temp = new Node ; temp -> key = key ; temp -> left = temp -> right = NULL ; return ( temp ) ; } int find_x ( int n ) { if ( n == 1 ) return 1 ; double num , den , p ; num = log10 ( n ) ; int x , no ; for ( int i = 2 ; i <= n ; i ++ ) { den = log10 ( i ) ; p = num / den ; no = ( int ) ( pow ( i , int ( p ) ) ) ; if ( abs ( no - n ) < 1e-6 ) { x = i ; break ; } } return x ; } bool is_key ( int n , int x ) { double p ; p = log10 ( n ) / log10 ( x ) ; int no = ( int ) ( pow ( x , int ( p ) ) ) ; if ( n == no ) return true ; return false ; } int evenPaths ( struct Node * node , int count , int x ) { if ( node == NULL || ! is_key ( node -> key , x ) ) { return count ; } if ( ! node -> left && ! node -> right ) { count ++ ; } count = evenPaths ( node -> left , count , x ) ; return evenPaths ( node -> right , count , x ) ; } int countExpPaths ( struct Node * node , int x ) { return evenPaths ( node , 0 , x ) ; } int main ( ) { Node * root = newNode ( 27 ) ; root -> left = newNode ( 9 ) ; root -> right = newNode ( 81 ) ; root -> left -> left = newNode ( 3 ) ; root -> left -> right = newNode ( 10 ) ; root -> right -> left = newNode ( 70 ) ; root -> right -> right = newNode ( 243 ) ; root -> right -> right -> left = newNode ( 81 ) ; root -> right -> right -> right = newNode ( 909 ) ; int x = find_x ( root -> key ) ; cout << countExpPaths ( root , x ) ; return 0 ; }

Accumulator variables: count, i, stdc
Iterator variables: i
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int N = 1000001 ; int c , n , m , a , b ; void dfs ( int a , int b , vector < int > v [ ] , int vis [ ] ) { vis [ a ] = 1 ; c ++ ; for ( auto i : v [ a ] ) { if ( ! vis [ i ] && i != b ) dfs ( i , b , v , vis ) ; } } void Calculate ( vector < int > v [ ] ) { int vis [ n + 1 ] ; memset ( vis , 0 , sizeof ( vis ) ) ; c = 0 ; dfs ( a , b , v , vis ) ; int ans1 = n - c - 1 ; memset ( vis , 0 , sizeof ( vis ) ) ; c = 0 ; dfs ( b , a , v , vis ) ; int ans2 = n - c - 1 ; cout << ans1 * ans2 << " STRNEWLINE " ; } int main ( ) { n = 7 , m = 7 , a = 3 , b = 5 ; int edges [ ] [ 2 ] = { { 1 , 2 } , { 2 , 3 } , { 3 , 4 } , { 4 , 5 } , { 5 , 6 } , { 6 , 7 } , { 7 , 5 } } ; vector < int > v [ n + 1 ] ; for ( int i = 0 ; i < m ; i ++ ) { v [ edges [ i ] [ 0 ] ] . push_back ( edges [ i ] [ 1 ] ) ; v [ edges [ i ] [ 1 ] ] . push_back ( edges [ i ] [ 0 ] ) ; } Calculate ( v ) ; return 0 ; }

Index/key variables: a, i
Accumulator variables: c, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define V  4
void tsp ( int graph [ ] [ V ] , vector < bool > & v , int currPos , int n , int count , int cost , int & ans ) { if ( count == n && graph [ currPos ] [ 0 ] ) { ans = min ( ans , cost + graph [ currPos ] [ 0 ] ) ; return ; } for ( int i = 0 ; i < n ; i ++ ) { if ( ! v [ i ] && graph [ currPos ] [ i ] ) { v [ i ] = true ; tsp ( graph , v , i , n , count + 1 , cost + graph [ currPos ] [ i ] , ans ) ; v [ i ] = false ; } } } ; int main ( ) { int n = 4 ; int graph [ ] [ V ] = { { 0 , 10 , 15 , 20 } , { 10 , 0 , 35 , 25 } , { 15 , 35 , 0 , 30 } , { 20 , 25 , 30 , 0 } } ; vector < bool > v ( n ) ; for ( int i = 0 ; i < n ; i ++ ) v [ i ] = false ; v [ 0 ] = true ; int ans = INT_MAX ; tsp ( graph , v , 0 , n , 1 , 0 , ans ) ; cout << ans ; return 0 ; }

Index/key variables: V, currPos, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printTheArray ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { cout << arr [ i ] << " ▁ " ; } cout << endl ; } void generateAllBinaryStrings ( int n , int arr [ ] , int i ) { if ( i == n ) { printTheArray ( arr , n ) ; return ; } arr [ i ] = 0 ; generateAllBinaryStrings ( n , arr , i + 1 ) ; arr [ i ] = 1 ; generateAllBinaryStrings ( n , arr , i + 1 ) ; } int main ( ) { int n = 4 ; int arr [ n ] ; generateAllBinaryStrings ( n , arr , 0 ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printResult ( char * result , int len ) { for ( int i = 0 ; i <= len ; i ++ ) cout << result [ i ] ; cout << endl ; } void stringCombination ( char result [ ] , char str [ ] , int count [ ] , int level , int size , int length ) { if ( level == size ) return ; for ( int i = 0 ; i < length ; i ++ ) { if ( count [ i ] == 0 ) continue ; count [ i ] -- ; result [ level ] = str [ i ] ; printResult ( result , level ) ; stringCombination ( result , str , count , level + 1 , size , length ) ; count [ i ] ++ ; } } void combination ( string str ) { map < char , int > mp ; for ( int i = 0 ; i < str . size ( ) ; i ++ ) { if ( mp . find ( str [ i ] ) != mp . end ( ) ) mp [ str [ i ] ] = mp [ str [ i ] ] + 1 ; else mp [ str [ i ] ] = 1 ; } char * input = new char [ mp . size ( ) ] ; int * count = new int [ mp . size ( ) ] ; char * result = new char [ str . size ( ) ] ; map < char , int > :: iterator it = mp . begin ( ) ; int i = 0 ; for ( it ; it != mp . end ( ) ; it ++ ) { input [ i ] = it -> first ; count [ i ] = it -> second ; i ++ ; } int length = mp . size ( ) ; int size = str . size ( ) ; stringCombination ( result , input , count , 0 , size , length ) ; } int main ( ) { string str = " ABC " ; combination ( str ) ; return 0 ; }

Index/key variables: i, level
Accumulator variables: i, it, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void allCombinationsRec ( vector < int > & arr , int elem , int n ) { if ( elem > n ) { for ( int i : arr ) cout << i << " ▁ " ; cout << endl ; return ; } for ( int i = 0 ; i < 2 * n ; i ++ ) { if ( arr [ i ] == -1 && ( i + elem + 1 ) < 2 * n && arr [ i + elem + 1 ] == -1 ) { arr [ i ] = elem ; arr [ i + elem + 1 ] = elem ; allCombinationsRec ( arr , elem + 1 , n ) ; arr [ i ] = -1 ; arr [ i + elem + 1 ] = -1 ; } } } void allCombinations ( int n ) { vector < int > arr ( 2 * n , -1 ) ; int elem = 1 ; allCombinationsRec ( arr , elem , n ) ; } int main ( ) { int n = 3 ; allCombinations ( n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#define N  8
static int cx [ N ] = { 1 , 1 , 2 , 2 , -1 , -1 , -2 , -2 } ; static int cy [ N ] = { 2 , -2 , 1 , -1 , 2 , -2 , 1 , -1 } ; bool limits ( int x , int y ) { return ( ( x >= 0 && y >= 0 ) && ( x < N && y < N ) ) ; } bool isempty ( int a [ ] , int x , int y ) { return ( limits ( x , y ) ) && ( a [ y * N + x ] < 0 ) ; } int getDegree ( int a [ ] , int x , int y ) { int count = 0 ; for ( int i = 0 ; i < N ; ++ i ) if ( isempty ( a , ( x + cx [ i ] ) , ( y + cy [ i ] ) ) ) count ++ ; return count ; } bool nextMove ( int a [ ] , int * x , int * y ) { int min_deg_idx = -1 , c , min_deg = ( N + 1 ) , nx , ny ; int start = rand ( ) % N ; for ( int count = 0 ; count < N ; ++ count ) { int i = ( start + count ) % N ; nx = * x + cx [ i ] ; ny = * y + cy [ i ] ; if ( ( isempty ( a , nx , ny ) ) & & ( c = getDegree ( a , nx , ny ) ) < min_deg ) { min_deg_idx = i ; min_deg = c ; } } if ( min_deg_idx == -1 ) return false ; nx = * x + cx [ min_deg_idx ] ; ny = * y + cy [ min_deg_idx ] ; a [ ny * N + nx ] = a [ ( * y ) * N + ( * x ) ] + 1 ; * x = nx ; * y = ny ; return true ; } void print ( int a [ ] ) { for ( int i = 0 ; i < N ; ++ i ) { for ( int j = 0 ; j < N ; ++ j ) printf ( " % d TABSYMBOL " , a [ j * N + i ] ) ; printf ( " STRNEWLINE " ) ; } } bool neighbour ( int x , int y , int xx , int yy ) { for ( int i = 0 ; i < N ; ++ i ) if ( ( ( x + cx [ i ] ) == xx ) && ( ( y + cy [ i ] ) == yy ) ) return true ; return false ; } bool findClosedTour ( ) { int a [ N * N ] ; for ( int i = 0 ; i < N * N ; ++ i ) a [ i ] = -1 ; int sx = rand ( ) % N ; int sy = rand ( ) % N ; int x = sx , y = sy ; for ( int i = 0 ; i < N * N - 1 ; ++ i ) if ( nextMove ( a , & x , & y ) == 0 ) return false ; if ( ! neighbour ( x , y , sx , sy ) ) return false ; print ( a ) ; return true ; } int main ( ) { srand ( time ( NULL ) ) ; while ( ! findClosedTour ( ) ) { ; } return 0 ; }

Index/key variables: N, i, min_deg_idx
Accumulator variables: count, stdc
Iterator variables: count, i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < vector < int > > result ; void solveBoard ( vector < vector < char > > & board , int row , int rowmask , int ldmask , int rdmask , int & ways ) { int n = board . size ( ) ; int all_rows_filled = ( 1 << n ) - 1 ; if ( rowmask == all_rows_filled ) { vector < int > v ; for ( int i = 0 ; i < board . size ( ) ; i ++ ) { for ( int j = 0 ; j < board . size ( ) ; j ++ ) { if ( board [ i ] [ j ] == ' Q ' ) v . push_back ( j + 1 ) ; } } result . push_back ( v ) ; return ; } int safe = all_rows_filled & ( ~ ( rowmask ldmask rdmask ) ) ; while ( safe ) { int p = safe & ( - safe ) ; int col = ( int ) log2 ( p ) ; board [ row ] [ col ] = ' Q ' ; solveBoard ( board , row + 1 , rowmask | p , ( ldmask p ) << 1 , ( rdmask p ) >> 1 , ways ) ; safe = safe & ( safe - 1 ) ; board [ row ] [ col ] = ' ▁ ' ; } return ; } int main ( ) { int n = 4 ; int ways = 0 ; vector < vector < char > > board ; for ( int i = 0 ; i < n ; i ++ ) { vector < char > tmp ; for ( int j = 0 ; j < n ; j ++ ) { tmp . push_back ( ' ▁ ' ) ; } board . push_back ( tmp ) ; } int rowmask = 0 , ldmask = 0 , rdmask = 0 ; int row = 0 ; result . clear ( ) ; solveBoard ( board , row , rowmask , ldmask , rdmask , ways ) ; sort ( result . begin ( ) , result . end ( ) ) ; for ( auto ar : result ) { cout << " [ " ; for ( auto it : ar ) cout << it << " ▁ " ; cout << " ] " ; } return 0 ; }

Index/key variables: col, i, j, row
Accumulator variables: i, j, stdc
Iterator variables: ar, i, it, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < string > split ( const string & s , char delim ) { vector < string > elems ; stringstream ss ( s ) ; string item ; while ( getline ( ss , item , delim ) ) elems . push_back ( item ) ; return elems ; } int printPowerSet ( int arr [ ] , int n ) { vector < string > list ; for ( int i = 0 ; i < ( int ) pow ( 2 , n ) ; i ++ ) { string subset = " " ; for ( int j = 0 ; j < n ; j ++ ) { if ( ( i & ( 1 << j ) ) != 0 ) subset += to_string ( arr [ j ] ) + " | " ; } if ( find ( list . begin ( ) , list . end ( ) , subset ) == list . end ( ) ) list . push_back ( subset ) ; } for ( string subset : list ) { vector < string > arr = split ( subset , ' ▁ ' ) ; for ( string str : arr ) cout << str << " ▁ " ; cout << endl ; } } int main ( ) { int arr [ ] = { 10 , 12 , 12 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; printPowerSet ( arr , n ) ; return 0 ; }

Index/key variables: j
Accumulator variables: i, j, stdc, subset
Iterator variables: i, j, str, subset
C++ program:
#include <bits/stdc++.h>
using namespace std ; 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 ++ ) cout << res [ i ] << " ▁ " ; } else cout << " Not ▁ Possible " ; } int main ( ) { fill ( 7 ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#include <iostream>
using namespace std ; class node { public : int color = 1 ; set < int > edges ; } ; int canPaint ( vector < node > & nodes , int n , int m ) { vector < int > visited ( n + 1 , 0 ) ; int maxColors = 1 ; for ( int sv = 1 ; sv <= n ; sv ++ ) { if ( visited [ sv ] ) continue ; visited [ sv ] = 1 ; queue < int > q ; q . push ( sv ) ; while ( ! q . empty ( ) ) { int top = q . front ( ) ; q . pop ( ) ; for ( auto it = nodes [ top ] . edges . begin ( ) ; it != nodes [ top ] . edges . end ( ) ; it ++ ) { if ( nodes [ top ] . color == nodes [ * it ] . color ) nodes [ * it ] . color += 1 ; maxColors = max ( maxColors , max ( nodes [ top ] . color , nodes [ * it ] . color ) ) ; if ( maxColors > m ) return 0 ; if ( ! visited [ * it ] ) { visited [ * it ] = 1 ; q . push ( * it ) ; } } } } return 1 ; } int main ( ) { int n = 4 ; bool graph [ n ] [ n ] = { { 0 , 1 , 1 , 1 } , { 1 , 0 , 1 , 0 } , { 1 , 1 , 0 , 1 } , { 1 , 0 , 1 , 0 } } ; vector < node > nodes ( n + 1 ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( graph [ i ] [ j ] ) { nodes [ i ] . edges . insert ( i ) ; nodes [ j ] . edges . insert ( j ) ; } } } cout << canPaint ( nodes , n , m ) ; cout << " STRNEWLINE " ; return 0 ; }

Index/key variables: i, j, n, sv, top
Accumulator variables: color, i, it, j, stdc, sv
Iterator variables: i, it, j, sv
Class/struct names: node
C++ program:
#include <bits/stdc++.h>
using namespace std ; int a , b , c , d ; #define MOD  1000000007
void FastDoubling ( int n , int res [ ] ) { if ( n == 0 ) { res [ 0 ] = 0 ; res [ 1 ] = 1 ; return ; } FastDoubling ( ( n / 2 ) , res ) ; a = res [ 0 ] ; b = res [ 1 ] ; c = 2 * b - a ; if ( c < 0 ) c += MOD ; c = ( a * c ) % MOD ; d = ( a * a + b * b ) % MOD ; if ( n % 2 == 0 ) { res [ 0 ] = c ; res [ 1 ] = d ; } else { res [ 0 ] = d ; res [ 1 ] = c + d ; } } int main ( ) { int N = 6 ; int res [ 2 ] = { 0 } ; FastDoubling ( N , res ) ; cout << res [ 0 ] << " STRNEWLINE " ; return 0 ; }

Accumulator variables: c, stdc
C++ program:
#include <iostream>
using namespace std ; int count ( int arr [ ] , int low , int high , int x ) { if ( ( low > high ) || ( low == high && arr [ low ] != x ) ) return 0 ; if ( low == high && arr [ low ] == x ) return 1 ; return count ( arr , low , ( low + high ) / 2 , x ) + count ( arr , 1 + ( low + high ) / 2 , high , x ) ; } int main ( ) { int arr [ ] = { 30 , 1 , 42 , 5 , 56 , 3 , 56 , 9 } ; int n = sizeof ( arr ) / sizeof ( int ) ; int x = 56 ; cout << count ( arr , 0 , n - 1 , x ) ; return 0 ; }

Index/key variables: low
C++ program:
#include " bits / stdc + + . h "
using namespace std ; void swap ( int * a , int * b ) { int temp = * a ; * a = * b ; * b = temp ; } int Partition ( int arr [ ] , int l , int r ) { int lst = arr [ r ] , i = l , j = l ; while ( j < r ) { if ( arr [ j ] < lst ) { swap ( & arr [ i ] , & arr [ j ] ) ; i ++ ; } j ++ ; } swap ( & arr [ i ] , & arr [ r ] ) ; return i ; } int randomPartition ( int arr [ ] , int l , int r ) { int n = r - l + 1 ; int pivot = rand ( ) % n ; swap ( & arr [ l + pivot ] , & arr [ r ] ) ; return Partition ( arr , l , r ) ; } void MedianUtil ( int arr [ ] , int l , int r , int k , int & a , int & b ) { if ( l <= r ) { int partitionIndex = randomPartition ( arr , l , r ) ; if ( partitionIndex == k ) { b = arr [ partitionIndex ] ; if ( a != -1 ) return ; } else if ( partitionIndex == k - 1 ) { a = arr [ partitionIndex ] ; if ( b != -1 ) return ; } if ( partitionIndex >= k ) return MedianUtil ( arr , l , partitionIndex - 1 , k , a , b ) ; else return MedianUtil ( arr , partitionIndex + 1 , r , k , a , b ) ; } return ; } void findMedian ( int arr [ ] , int n ) { int ans , a = -1 , b = -1 ; if ( n % 2 == 1 ) { MedianUtil ( arr , 0 , n - 1 , n / 2 , a , b ) ; ans = b ; } else { MedianUtil ( arr , 0 , n - 1 , n / 2 , a , b ) ; ans = ( a + b ) / 2 ; } cout << " Median ▁ = ▁ " << ans ; } int main ( ) { int arr [ ] = { 12 , 3 , 5 , 7 , 4 , 19 , 26 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; findMedian ( arr , n ) ; return 0 ; }

Index/key variables: i, j, partitionIndex, r
Accumulator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int firstDigit ( int n ) { while ( n >= 10 ) { n /= 10 ; } return n ; } int getCount ( int n ) { int count = 1 ; while ( n != 0 ) { int leadDigit = firstDigit ( n ) ; n -= leadDigit ; count ++ ; } return count ; } int getLargestNumber ( int k ) { int left = k ; int right = k * 10 ; int mid = ( left + right ) / 2 ; int len = getCount ( mid ) ; while ( len != k ) { mid = ( left + right ) / 2 ; len = getCount ( mid ) ; if ( len > k ) { right = mid ; } else { left = mid ; } } while ( len == k ) { if ( len != getCount ( mid + 1 ) ) { break ; } mid ++ ; } return ( mid ) ; } int main ( ) { int k = 3 ; cout << getLargestNumber ( k ) ; return 0 ; }

Accumulator variables: count, mid, n, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; string checkReachability ( int N , int X , int Y ) { if ( X == 0 && Y == 0 ) { return " YES " ; } if ( N % 2 == 0 ) { return " YES " ; } else { if ( X % 2 != Y % 2 ) { return " NO " ; } else { return " YES " ; } } } int main ( ) { int N = 2 ; int X = 5 , Y = 4 ; cout << checkReachability ( N , X , Y ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ll  long long
#define MAXN  1000000
void closestsAngle ( int N , int A ) { double mi = INT_MAX ; int ans = 0 ; for ( int i = 1 ; i < N - 1 ; i ++ ) { double angle = 180.0 * i / N ; if ( fabs ( angle - A ) < fabs ( mi - A ) ) { mi = angle ; ans = i ; } } cout << 2 << ' ▁ ' << 1 << ' ▁ ' << 2 + ans ; } int main ( ) { int N = 3 , A = 15 ; closestsAngle ( N , A ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; double areaOftriangle ( int side ) { double a = sqrt ( pow ( side / 2 , 2 ) + pow ( side / 2 , 2 ) ) ; double b = sqrt ( pow ( side , 2 ) + pow ( side / 2 , 2 ) ) ; double c = sqrt ( pow ( side , 2 ) + pow ( side / 2 , 2 ) ) ; double s = ( a + b + c ) / 2 ; double area = sqrt ( s * ( s - a ) * ( s - b ) * ( s - c ) ) ; return area ; } int main ( ) { int N = 10 ; cout << areaOftriangle ( N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findLine ( int distance , float degree ) { float x = degree * 3.14159 / 180 ; if ( degree > 90 ) { cout << " Not ▁ Possible " ; return ; } float result_1 = sin ( x ) ; float result_2 = cos ( x ) ; cout << fixed << setprecision ( 2 ) << result_2 << " x ▁ + " << result_1 << " y ▁ = ▁ " << distance ; } int main ( ) { int D = 10 ; float A = 30 ; findLine ( D , A ) ; return 0 ; }

Accumulator variables: stdc