dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < int > findDivisors ( int n ) { vector < int > v ; for ( int i = 1 ; i <= sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i ) v . push_back ( i ) ; else { v . push_back ( i ) ; v . push_back ( n / i ) ; } } } return v ; } bool printPairs ( int arr [ ] , int n , int k ) { unordered_map < int , bool > occ ; for ( int i = 0 ; i < n ; i ++ ) occ [ arr [ i ] ] = true ; bool isPairFound = false ; for ( int i = 0 ; i < n ; i ++ ) { if ( occ [ k ] && k < arr [ i ] ) { cout << " ( " << k << " , ▁ " << arr [ i ] << " ) ▁ " ; isPairFound = true ; } if ( arr [ i ] >= k ) { vector < int > v = findDivisors ( arr [ i ] - k ) ; for ( int j = 0 ; j < v . size ( ) ; j ++ ) { if ( arr [ i ] % v [ j ] == k && arr [ i ] != v [ j ] && occ [ v [ j ] ] ) { cout << " ( " << arr [ i ] << " , ▁ " << v [ j ] << " ) ▁ " ; isPairFound = true ; } } v . clear ( ) ; } } return isPairFound ; } int main ( ) { int arr [ ] = { 3 , 1 , 2 , 5 , 4 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int k = 2 ; if ( printPairs ( arr , n , k ) == false ) cout << " No ▁ such ▁ pair ▁ exists " ; return 0 ; }

Index/key variables: i, j, k
Accumulator variables: i, j, stdc
Iterator variables: i, j
Boolean variables: isPairFound
C++ program:
#include <bits/stdc++.h>
using namespace std ; class Node { public : int val ; Node * left , * right ; } ; Node * newNode ( int item ) { Node * temp = new Node ( ) ; temp -> val = item ; temp -> left = temp -> right = NULL ; return temp ; } int sum = 0 ; int rangeSumBST ( Node * root , int low , int high ) { if ( root == NULL ) return 0 ; queue < Node * > q ; q . push ( root ) ; while ( q . empty ( ) == false ) { Node * curr = q . front ( ) ; q . pop ( ) ; if ( curr -> val >= low && curr -> val <= high ) { sum += curr -> val ; } if ( curr -> left != NULL && curr -> val > low ) q . push ( curr -> left ) ; if ( curr -> right != NULL && curr -> val < high ) q . push ( curr -> right ) ; } return sum ; } Node * insert ( Node * node , int data ) { if ( node == NULL ) return newNode ( data ) ; if ( data <= node -> val ) node -> left = insert ( node -> left , data ) ; else node -> right = insert ( node -> right , data ) ; return node ; } int main ( ) { Node * root = NULL ; root = insert ( root , 10 ) ; insert ( root , 5 ) ; insert ( root , 15 ) ; insert ( root , 3 ) ; insert ( root , 7 ) ; insert ( root , 18 ) ; int L = 7 , R = 15 ; cout << rangeSumBST ( root , L , R ) ; return 0 ; }

Accumulator variables: stdc, sum
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; void convert ( int arr [ ] , int n ) { int temp [ n ] ; memcpy ( temp , arr , n * sizeof ( int ) ) ; sort ( temp , temp + n ) ; unordered_map < int , int > umap ; int val = 0 ; for ( int i = 0 ; i < n ; i ++ ) umap [ temp [ i ] ] = val ++ ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = umap [ arr [ i ] ] ; } void printArr ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) cout << arr [ i ] << " ▁ " ; } int main ( ) { int arr [ ] = { 10 , 20 , 15 , 12 , 11 , 50 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << " Given ▁ Array ▁ is ▁ STRNEWLINE " ; printArr ( arr , n ) ; convert ( arr , n ) ; cout << " Converted Array is " ; printArr ( arr , n ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, stdc, val
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSubstrings ( string S , string S1 , string S2 ) { int N = S . length ( ) ; int N1 = S1 . length ( ) ; int N2 = S2 . length ( ) ; int count = 0 , totalcount = 0 ; for ( int i = 0 ; i < N ; i ++ ) { string prefix = S . substr ( i , N1 ) ; string suffix = S . substr ( i , N2 ) ; if ( S1 == prefix ) count ++ ; if ( S2 == suffix ) totalcount += count ; } return totalcount ; } void checkSubstrings ( string S , string S1 , string S2 ) { int x = countSubstrings ( S , S1 , S2 ) ; int y = countSubstrings ( S , S2 , S1 ) ; if ( x == y ) cout << " Yes " ; else cout << " No " ; } int main ( ) { string S = " opencloseopencloseopen " ; string S1 = " open " ; string S2 = " close " ; checkSubstrings ( S , S1 , S2 ) ; return 0 ; }

Accumulator variables: count, i, stdc, totalcount
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#define ASCII_SIZE  256
using namespace std ; char getMaxOccuringChar ( char * str ) { int count [ ASCII_SIZE ] = { 0 } ; int len = strlen ( str ) ; int max = 0 ; char result ; for ( int i = 0 ; i < len ; i ++ ) { count [ str [ i ] ] ++ ; if ( max < count [ str [ i ] ] ) { max = count [ str [ i ] ] ; result = str [ i ] ; } } return result ; } int main ( ) { char str [ ] = " sample ▁ string " ; cout << " Max ▁ occurring ▁ character ▁ is ▁ " << getMaxOccuringChar ( str ) ; }

Index/key variables: ASCII_SIZE, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX_CHAR  26
string getKey ( string & str ) { bool visited [ MAX_CHAR ] = { false } ; for ( int j = 0 ; j < str . length ( ) ; j ++ ) visited [ str [ j ] - ' a ' ] = true ; string key = " " ; for ( int j = 0 ; j < MAX_CHAR ; j ++ ) if ( visited [ j ] ) key = key + ( char ) ( ' a ' + j ) ; return key ; } void wordsWithSameCharSet ( string words [ ] , int n ) { unordered_map < string , vector < int > > Hash ; for ( int i = 0 ; i < n ; i ++ ) { string key = getKey ( words [ i ] ) ; Hash [ key ] . push_back ( i ) ; } for ( auto it = Hash . begin ( ) ; it != Hash . end ( ) ; it ++ ) { for ( auto v = ( * it ) . second . begin ( ) ; v != ( * it ) . second . end ( ) ; v ++ ) cout << words [ * v ] << " , ▁ " ; cout << endl ; } } int main ( ) { string words [ ] = { " may " , " student " , " students " , " dog " , " studentssess " , " god " , " cat " , " act " , " tab " , " bat " , " flow " , " wolf " , " lambs " , " amy " , " yam " , " balms " , " looped " , " poodle " } ; int n = sizeof ( words ) / sizeof ( words [ 0 ] ) ; wordsWithSameCharSet ( words , n ) ; return 0 ; }

Index/key variables: MAX_CHAR, i, j, key
Accumulator variables: i, it, j, stdc, v
Iterator variables: i, it, j, v
C++ program:
#include <bits/stdc++.h>
using namespace std ; string secMostRepeated ( vector < string > seq ) { unordered_map < string , int > occ ; for ( int i = 0 ; i < seq . size ( ) ; i ++ ) occ [ seq [ i ] ] ++ ; int first_max = INT_MIN , sec_max = INT_MIN ; for ( auto it = occ . begin ( ) ; it != occ . end ( ) ; it ++ ) { if ( it -> second > first_max ) { sec_max = first_max ; first_max = it -> second ; } else if ( it -> second > sec_max && it -> second != first_max ) sec_max = it -> second ; } for ( auto it = occ . begin ( ) ; it != occ . end ( ) ; it ++ ) if ( it -> second == sec_max ) return it -> first ; } int main ( ) { vector < string > seq = { " ccc " , " aaa " , " ccc " , " ddd " , " aaa " , " aaa " } ; cout << secMostRepeated ( seq ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, it, stdc
Iterator variables: i, it
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; struct Node * left ; struct Node * right ; } ; struct Node * newNode ( int data ) { struct Node * node = new Node ; node -> data = data ; node -> left = node -> right = NULL ; return ( node ) ; } bool checkDupUtil ( Node * root , unordered_set < int > & s ) { if ( root == NULL ) return false ; if ( s . find ( root -> data ) != s . end ( ) ) return true ; s . insert ( root -> data ) ; return checkDupUtil ( root -> left , s ) || checkDupUtil ( root -> right , s ) ; } bool checkDup ( struct Node * root ) { unordered_set < int > s ; return checkDupUtil ( root , s ) ; } int main ( ) { struct Node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 2 ) ; root -> left -> left = newNode ( 3 ) ; if ( checkDup ( root ) ) printf ( " Yes " ) ; else printf ( " No " ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct et { char value ; et * left , * right ; } ; bool isOperator ( char c ) { if ( c == ' + ' c == ' - ' c == ' * ' c == ' / ' c == ' ^ ' ) return true ; return false ; } void inorder ( et * t ) { if ( t ) { inorder ( t -> left ) ; printf ( " % c ▁ " , t -> value ) ; inorder ( t -> right ) ; } } et * newNode ( char v ) { et * temp = new et ; temp -> left = temp -> right = NULL ; temp -> value = v ; return temp ; } ; et * constructTree ( char postfix [ ] ) { stack < et * > st ; et * t , * t1 , * t2 ; for ( int i = 0 ; i < strlen ( postfix ) ; i ++ ) { if ( ! isOperator ( postfix [ i ] ) ) { t = newNode ( postfix [ i ] ) ; st . push ( t ) ; } else { t = newNode ( postfix [ i ] ) ; t1 = st . top ( ) ; st . pop ( ) ; t2 = st . top ( ) ; st . pop ( ) ; t -> right = t1 ; t -> left = t2 ; st . push ( t ) ; } } t = st . top ( ) ; st . pop ( ) ; return t ; } int main ( ) { char postfix [ ] = " ab + ef * g * - " ; et * r = constructTree ( postfix ) ; printf ( " infix ▁ expression ▁ is ▁ STRNEWLINE " ) ; inorder ( r ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
Class/struct names: et
C++ program:
#include <bits/stdc++.h>
using namespace std ; int left_search ( vector < int > A , int num ) { int low = 0 , high = A . size ( ) - 1 ; int ans = 0 ; while ( low <= high ) { int mid = low + ( high - low ) / 2 ; if ( A [ mid ] >= num ) { ans = mid ; high = mid - 1 ; } else { low = mid + 1 ; } } return ans ; } int right_search ( vector < int > A , int num ) { int low = 0 , high = A . size ( ) - 1 ; int ans = high ; while ( low <= high ) { int mid = low + ( high - low ) / 2 ; if ( A [ mid ] <= num ) { ans = mid ; low = mid + 1 ; } else { high = mid - 1 ; } } return ans ; } void totalCount ( vector < vector < int > > A , int N , int M , vector < vector < int > > queries , int Q ) { vector < int > row_sum ( N ) ; vector < int > col_sum ( N ) ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { row_sum [ i ] += A [ i ] [ j ] ; col_sum [ j ] += A [ i ] [ j ] ; } } vector < int > sum_list ; for ( int i = 0 ; i < N ; i ++ ) sum_list . push_back ( row_sum [ i ] ) ; for ( int i = 0 ; i < M ; i ++ ) sum_list . push_back ( col_sum [ i ] ) ; sort ( sum_list . begin ( ) , sum_list . end ( ) ) ; for ( int i = 0 ; i < Q ; i ++ ) { int L = queries [ i ] [ 0 ] ; int R = queries [ i ] [ 1 ] ; int l = left_search ( sum_list , L ) ; int r = right_search ( sum_list , R ) ; cout << r - l + 1 << " ▁ " ; } } int main ( ) { int N = 3 , M = 2 ; vector < vector < int > > A = { { 13 , 3 } , { 9 , 4 } , { 6 , 10 } } ; int Q = 2 ; vector < vector < int > > queries = { { 10 , 20 } , { 25 , 35 } } ; totalCount ( A , N , M , queries , Q ) ; }

Index/key variables: i, j, mid
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int smallestKFreq ( int a [ ] , int n , int k ) { unordered_map < int , int > m ; for ( int i = 0 ; i < n ; i ++ ) m [ a [ i ] ] ++ ; int res = INT_MAX ; for ( auto it = m . begin ( ) ; it != m . end ( ) ; ++ it ) if ( it -> second == k ) res = min ( res , it -> first ) ; return ( res != INT_MAX ) ? res : -1 ; } int main ( ) { int arr [ ] = { 2 , 2 , 1 , 3 , 1 } ; int k = 2 ; int n = sizeof ( arr ) / ( sizeof ( arr [ 0 ] ) ) ; cout << smallestKFreq ( arr , n , k ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i, it
C++ program:
#include <iostream>
#include <climits>
#include <algorithm>
using namespace std ; int maximumProfit ( int arr [ ] , int n ) { int ans = INT_MIN ; int price = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int count = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( arr [ i ] <= arr [ j ] ) { count ++ ; } } if ( ans < count * arr [ i ] ) { price = arr [ i ] ; ans = count * arr [ i ] ; } } return price ; } int main ( ) { int arr [ ] = { 22 , 87 , 9 , 50 , 56 , 43 } ; cout << maximumProfit ( arr , 6 ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
#include <iostream>
using namespace std ; void print ( int arr [ ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) { cout << arr [ i ] << " ▁ " ; } } void makeLexicographically ( int arr [ ] , int N ) { int index = 0 ; int temp = 0 ; int check = 0 ; int condition = 0 ; int element = 0 ; for ( int i = 0 ; i < N ; ++ i ) { if ( element == arr [ i ] ) { check = i ; break ; } else if ( arr [ i ] != i + 1 && check == 0 ) { index = i ; check = 1 ; condition = -1 ; element = i + 1 ; } } if ( condition == -1 ) { temp = arr [ index ] ; arr [ index ] = arr [ check ] ; arr [ check ] = temp ; } print ( arr , N ) ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; makeLexicographically ( arr , N ) ; return 0 ; }

Index/key variables: check, i, index
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isLower ( char c ) { return c >= ' a ' and c < = ' z ' ; } bool isUpper ( char c ) { return c >= ' A ' and c < = ' Z ' ; } bool detectUppercaseUseUtil ( string S ) { int N = S . size ( ) ; int i ; if ( isLower ( S [ 0 ] ) ) { i = 1 ; while ( S [ i ] && isLower ( S [ i ] ) ) ++ i ; return i == N ? true : false ; } else { i = 1 ; while ( S [ i ] && isUpper ( S [ i ] ) ) ++ i ; if ( i == N ) return true ; else if ( i > 1 ) return false ; while ( S [ i ] && isLower ( S [ i ] ) ) ++ i ; return i == N ? true : false ; } } void detectUppercaseUse ( string S ) { bool check = detectUppercaseUseUtil ( S ) ; if ( check ) cout << " Yes " ; else cout << " No " ; } int main ( ) { string S = " GeeKs " ; detectUppercaseUse ( S ) ; return 0 ; }

Index/key variables: i
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool check ( int N ) { if ( N == 0 ) return 0 ; return ! ( N & ( N - 1 ) ) ; } void build_seg_tree ( int ss , int se , int si , int tree [ ] , int arr [ ] ) { if ( ss == se ) { tree [ si ] = check ( arr [ ss ] ) ; return ; } int mid = ( ss + se ) / 2 ; build_seg_tree ( ss , mid , 2 * si + 1 , tree , arr ) ; build_seg_tree ( mid + 1 , se , 2 * si + 2 , tree , arr ) ; tree [ si ] = tree [ 2 * si + 1 ] + tree [ 2 * si + 2 ] ; } void update ( int ss , int se , int si , int X , int V , int tree [ ] , int arr [ ] ) { if ( ss == se ) { if ( ss == X ) { arr [ X ] = V ; tree [ si ] = check ( V ) ; } return ; } int mid = ( ss + se ) / 2 ; if ( X <= mid ) update ( ss , mid , 2 * si + 1 , X , V , tree , arr ) ; else update ( mid + 1 , se , 2 * si + 2 , X , V , tree , arr ) ; tree [ si ] = tree [ 2 * si + 1 ] + tree [ 2 * si + 2 ] ; } int query ( int l , int r , int ss , int se , int si , int tree [ ] ) { if ( r < ss l > se ) return 0 ; if ( l <= ss && r >= se ) return tree [ si ] ; int mid = ( ss + se ) / 2 ; return query ( l , r , ss , mid , 2 * si + 1 , tree ) + query ( l , r , mid + 1 , se , 2 * si + 2 , tree ) ; } void Query ( int arr [ ] , int N , vector < vector < int > > Q ) { int tree [ 4 * N ] = { 0 } ; build_seg_tree ( 0 , N - 1 , 0 , tree , arr ) ; for ( int i = 0 ; i < ( int ) Q . size ( ) ; i ++ ) { if ( Q [ i ] [ 0 ] == 1 ) cout << query ( Q [ i ] [ 1 ] , Q [ i ] [ 2 ] , 0 , N - 1 , 0 , tree ) << " ▁ " ; else update ( 0 , N - 1 , 0 , Q [ i ] [ 1 ] , Q [ i ] [ 2 ] , tree , arr ) ; } } int main ( ) { int arr [ ] = { 12 , 11 , 16 , 2 , 32 } ; vector < vector < int > > Q { { 1 , 0 , 2 } , { 2 , 4 , 24 } , { 1 , 1 , 4 } } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; Query ( arr , N , Q ) ; return 0 ; }

Index/key variables: X, i, si, ss
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isGreaterEqual ( int N , int X ) { return ( N * 1LL * ( N + 1 ) / 2 ) >= X ; } int minimumPossible ( int X ) { int low = 1 , high = X , res = -1 ; while ( low <= high ) { int mid = low + ( high - low ) / 2 ; if ( isGreaterEqual ( mid , X ) ) { res = mid ; high = mid - 1 ; } else low = mid + 1 ; } return res ; } int main ( ) { int X = 14 ; cout << minimumPossible ( X ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int m , n ; bool valid ( int x , int y ) { return ( x >= 0 && x < m && y >= 0 && y < n ) ; } bool border ( int x , int y ) { return ( x == 0 x == m - 1 y == 0 y == n - 1 ) ; } int minStep ( vector < vector < int > > mat ) { m = mat . size ( ) ; n = mat [ 0 ] . size ( ) ; int dx [ ] = { 1 , -1 , 0 , 0 } ; int dy [ ] = { 0 , 0 , 1 , -1 } ; queue < pair < int , int > > pQ ; queue < pair < int , int > > fQ ; for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( mat [ i ] [ j ] == 2 ) fQ . push ( { i , j } ) ; else if ( mat [ i ] [ j ] == 1 ) { if ( border ( i , j ) ) return 0 ; pQ . push ( { i , j } ) ; } } } int depth = 0 ; vector < vector < int > > visited ( n , vector < int > ( m , 0 ) ) ; while ( pQ . size ( ) > 0 ) { depth ++ ; for ( int i = pQ . size ( ) ; i > 0 ; i -- ) { pair < int , int > pos = pQ . front ( ) ; pQ . pop ( ) ; if ( mat [ pos . first ] [ pos . second ] == 2 ) continue ; for ( int j = 0 ; j < 4 ; j ++ ) { int x = pos . first + dx [ j ] ; int y = pos . second + dy [ j ] ; if ( valid ( x , y ) && mat [ x ] [ y ] != 2 && ! visited [ x ] [ y ] ) { visited [ x ] [ y ] = 1 ; pQ . push ( pair < int , int > ( x , y ) ) ; if ( border ( x , y ) ) return depth ; } } } for ( int i = fQ . size ( ) ; i > 0 ; i -- ) { pair < int , int > pos = fQ . front ( ) ; fQ . pop ( ) ; for ( int j = 0 ; j < 4 ; j ++ ) { int x = pos . first + dx [ j ] ; int y = pos . second + dy [ j ] ; if ( valid ( x , y ) && mat [ x ] [ y ] != 2 ) { mat [ x ] [ y ] = 2 ; fQ . push ( pair < int , int > ( x , y ) ) ; } } } } return -1 ; } int main ( ) { vector < vector < int > > grid = { { 0 , 0 , 0 , 0 } , { 2 , 0 , 0 , 0 } , { 2 , 1 , 0 , 0 } , { 2 , 2 , 0 , 0 } } ; cout << minStep ( grid ) ; }

Index/key variables: i, j, x, y
Accumulator variables: depth, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findSum ( int arr [ ] , int n ) { sort ( arr , arr + n ) ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] != arr [ i + 1 ] ) sum = sum + arr [ i ] ; } return sum ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 1 , 1 , 4 , 5 , 6 } ; int n = sizeof ( arr ) / sizeof ( int ) ; cout << findSum ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int xorSubsequence ( int a [ ] , int n , int k ) { int ans = 0 ; int dp [ n ] = { 0 } ; dp [ 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { for ( int j = i - 1 ; j >= 0 ; j -- ) { if ( ( a [ i ] ^ a [ j ] ) == k ) dp [ i ] = max ( dp [ i ] , dp [ j ] + 1 ) ; } ans = max ( ans , dp [ i ] ) ; dp [ i ] = max ( 1 , dp [ i ] ) ; } return ans >= 2 ? ans : 0 ; } int main ( ) { int arr [ ] = { 3 , 2 , 4 , 3 , 5 } ; int K = 1 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << xorSubsequence ( arr , N , K ) ; 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 ; const char MARKER = ' $ ' ; struct Node { char key ; Node * left , * right ; } ; Node * newNode ( char key ) { Node * node = new Node ; node -> key = key ; node -> left = node -> right = NULL ; return node ; } unordered_set < string > subtrees ; string dupSubUtil ( Node * root ) { string s = " " ; if ( root == NULL ) return s + MARKER ; string lStr = dupSubUtil ( root -> left ) ; if ( lStr . compare ( s ) == 0 ) return s ; string rStr = dupSubUtil ( root -> right ) ; if ( rStr . compare ( s ) == 0 ) return s ; s = s + root -> key + lStr + rStr ; if ( s . length ( ) > 3 && subtrees . find ( s ) != subtrees . end ( ) ) return " " ; subtrees . insert ( s ) ; return s ; } int main ( ) { Node * root = newNode ( ' A ' ) ; root -> left = newNode ( ' B ' ) ; root -> right = newNode ( ' C ' ) ; root -> left -> left = newNode ( ' D ' ) ; root -> left -> right = newNode ( ' E ' ) ; root -> right -> right = newNode ( ' B ' ) ; root -> right -> right -> right = newNode ( ' E ' ) ; root -> right -> right -> left = newNode ( ' D ' ) ; string str = dupSubUtil ( root ) ; ( str . compare ( " " ) == 0 ) ? cout << " ▁ Yes ▁ " : cout << " ▁ No ▁ " ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <iostream>
#include <unordered_map>
using namespace std ; int getCount ( int rows , int columns , int sides [ ] [ 2 ] ) { int ans = 0 ; unordered_map < double , int > umap ; for ( int i = 0 ; i < rows ; i ++ ) { double ratio = ( double ) sides [ i ] [ 0 ] / sides [ i ] [ 1 ] ; umap [ ratio ] ++ ; } for ( auto x : umap ) { int value = x . second ; if ( value > 1 ) { ans += ( value * ( value - 1 ) ) / 2 ; } } return ans ; } int main ( ) { int sides [ 4 ] [ 2 ] = { { 4 , 8 } , { 10 , 20 } , { 15 , 30 } , { 3 , 6 } } ; int rows = 4 ; int columns = 2 ; cout << getCount ( rows , columns , sides ) ; return 0 ; }

Index/key variables: i, ratio
Accumulator variables: ans, i
Iterator variables: i, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; int firstNonRepeating ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { int j ; for ( j = 0 ; j < n ; j ++ ) if ( i != j && arr [ i ] == arr [ j ] ) break ; if ( j == n ) return arr [ i ] ; } return -1 ; } int main ( ) { int arr [ ] = { 9 , 4 , 9 , 6 , 7 , 4 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << firstNonRepeating ( arr , n ) ; 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 firstNonRepeating ( int arr [ ] , int n ) { unordered_map < int , int > mp ; for ( int i = 0 ; i < n ; i ++ ) mp [ arr [ i ] ] ++ ; for ( int i = 0 ; i < n ; i ++ ) if ( mp [ arr [ i ] ] == 1 ) return arr [ i ] ; return -1 ; } int main ( ) { int arr [ ] = { 9 , 4 , 9 , 6 , 7 , 4 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << firstNonRepeating ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void firstNonRepeating ( int arr [ ] , int n ) { unordered_map < int , int > mp ; for ( int i = 0 ; i < n ; i ++ ) mp [ arr [ i ] ] ++ ; for ( auto x : mp ) if ( x . second == 1 ) cout << x . first << " ▁ " ; } int main ( ) { int arr [ ] = { 9 , 4 , 9 , 6 , 7 , 4 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; firstNonRepeating ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minOperationNeeded ( string str ) { str = string ( str . begin ( ) , unique ( str . begin ( ) , str . end ( ) ) ) ; int N = str . length ( ) ; int res [ 256 ] = { 0 } ; for ( int i = 0 ; i < N ; ++ i ) { res [ str [ i ] ] += 1 ; } res [ str [ 0 ] ] -= 1 ; res [ str [ N - 1 ] ] -= 1 ; int ans = INT_MAX ; for ( int i = 0 ; i < N ; ++ i ) { ans = min ( ans , res [ str [ i ] ] ) ; } cout << ( ans + 1 ) << endl ; } int main ( ) { string str = " ABCDABCDABCDA " ; minOperationNeeded ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: stdc
Iterator variables: i