dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; void countminOpsToConstructAString ( string A , string B ) { int N = A . length ( ) ; int i = 0 ; map < char , set < int > > mp ; for ( i = 0 ; i < N ; i ++ ) { mp [ A [ i ] ] . insert ( i ) ; } int previous = -1 ; int ans = 1 ; for ( i = 0 ; i < B . length ( ) ; i ++ ) { char ch = B [ i ] ; if ( mp [ ch ] . size ( ) == 0 ) { cout << -1 ; return ; } auto it = mp [ ch ] . upper_bound ( previous ) ; if ( it == mp [ ch ] . end ( ) ) { previous = -1 ; ans ++ ; -- i ; continue ; } previous = * it ; } cout << ans ; } int main ( ) { string A = " abc " , B = " abac " ; countminOpsToConstructAString ( A , B ) ; return 0 ; }

Index/key variables: ch, i
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimize ( int n ) { int optEle = n ; string strEle = to_string ( n ) ; for ( int idx = 0 ; idx < strEle . length ( ) ; idx ++ ) { int temp = stoi ( strEle . substr ( idx ) + strEle . substr ( 0 , idx ) ) ; optEle = min ( optEle , temp ) ; } return optEle ; } int maximize ( int n ) { int optEle = n ; string strEle = to_string ( n ) ; for ( int idx = 0 ; idx < strEle . length ( ) ; idx ++ ) { int temp = stoi ( strEle . substr ( idx ) + strEle . substr ( 0 , idx ) ) ; optEle = max ( optEle , temp ) ; } return optEle ; } void minimumDifference ( int arr [ ] , int N ) { int caseOne = 0 ; int minVal = 0 ; int maxVal = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( i % 2 == 0 ) minVal += minimize ( arr [ i ] ) ; else maxVal += maximize ( arr [ i ] ) ; } caseOne = abs ( maxVal - minVal ) ; int caseTwo = 0 ; minVal = 0 ; maxVal = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( i % 2 == 0 ) maxVal += maximize ( arr [ i ] ) ; else minVal += minimize ( arr [ i ] ) ; caseTwo = abs ( maxVal - minVal ) ; } cout << max ( caseOne , caseTwo ) << endl ; } int main ( ) { int arr [ ] = { 332 , 421 , 215 , 584 , 232 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; minimumDifference ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, idx, maxVal, minVal, stdc
Iterator variables: i, idx
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int key ; Node * left , * right ; } ; Node * newNode ( int key ) { Node * temp = new Node ; temp -> key = key ; temp -> left = temp -> right = NULL ; return temp ; } bool isSorted ( Node * root , int level ) { if ( root == NULL ) return true ; int prevVal = INT_MIN ; int currLevel ; Node * currNode ; queue < pair < Node * , int > > q ; q . push ( make_pair ( root , 0 ) ) ; while ( ! q . empty ( ) ) { currNode = q . front ( ) . first ; currLevel = q . front ( ) . second ; q . pop ( ) ; if ( currLevel == level ) { if ( prevVal <= currNode -> key ) prevVal = currNode -> key ; else return false ; } if ( currNode -> left ) q . push ( make_pair ( currNode -> left , currLevel - 1 ) ) ; if ( currNode -> right ) q . push ( make_pair ( currNode -> right , currLevel + 1 ) ) ; } return true ; } int main ( ) { Node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 5 ) ; root -> left -> left = newNode ( 7 ) ; root -> left -> right = newNode ( 4 ) ; root -> left -> right -> left = newNode ( 6 ) ; int level = -1 ; if ( isSorted ( root , level ) == true ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimumStepReqArr ( int arr [ ] , int N ) { int cntStep = 0 ; N += 1 ; for ( int i = 31 ; i >= 0 ; i -- ) { if ( N & ( 1 << i ) ) { cntStep += 1 ; } } return cntStep ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << minimumStepReqArr ( arr , N ) ; return 0 ; }

Accumulator variables: N, cntStep, i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void minOpsToEmptyString ( string S , int N ) { int one = 0 , zero = 0 ; int x0 = 0 , x1 = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( S [ i ] == '0' ) { x0 ++ ; x1 = 0 ; } else { x1 ++ ; x0 = 0 ; } zero = max ( x0 , zero ) ; one = max ( x1 , one ) ; } cout << max ( one , zero ) << endl ; } int main ( ) { string S = "0100100111" ; int N = S . length ( ) ; minOpsToEmptyString ( S , N ) ; }

Index/key variables: i
Accumulator variables: i, x0, x1
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void ReverseSwap ( vector < vector < int > > & mat , int n ) { vector < int > lowerEle [ n ] ; vector < int > upperEle [ n ] ; int index ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { index = abs ( i - j ) ; if ( i == j ) { continue ; } else if ( j < i ) { lowerEle [ index ] . push_back ( mat [ i ] [ j ] ) ; } else { upperEle [ index ] . push_back ( mat [ i ] [ j ] ) ; } } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { index = abs ( i - j ) ; if ( i == j ) { continue ; } else if ( j < i ) { mat [ i ] [ j ] = upperEle [ index ] . back ( ) ; upperEle [ index ] . pop_back ( ) ; } else { mat [ i ] [ j ] = lowerEle [ index ] . back ( ) ; lowerEle [ index ] . pop_back ( ) ; } } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { cout << mat [ i ] [ j ] << " ▁ " ; } cout << endl ; } } int main ( ) { vector < vector < int > > mat = { { 1 , 2 } , { 4 , 5 } } ; int N = mat . size ( ) ; ReverseSwap ( mat , N ) ; return 0 ; }

Index/key variables: i, index, j, n
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < int > primePower ( int X ) { vector < int > primePow ; for ( int i = 2 ; i * i <= X ; i ++ ) { if ( X % i == 0 ) { int p = 1 ; while ( X % i == 0 ) { X /= i ; p *= i ; } primePow . push_back ( p ) ; } } if ( X > 1 ) { primePow . push_back ( X ) ; } return primePow ; } int getSum ( vector < int > & ar ) { int sum = 0 ; for ( int i : ar ) { sum += i ; } return sum ; } int getMinSum ( int pos , vector < int > & arr , vector < int > & primePow ) { if ( pos == primePow . size ( ) ) { return getSum ( arr ) ; } int res = INT_MAX ; for ( int i = 0 ; i < arr . size ( ) ; i ++ ) { arr [ i ] *= primePow [ pos ] ; res = min ( res , getMinSum ( pos + 1 , arr , primePow ) ) ; arr [ i ] /= primePow [ pos ] ; } return res ; } int minimumSumWithGivenLCM ( int k , int x ) { vector < int > primePow = primePower ( x ) ; int n = primePow . size ( ) ; int sum = 0 ; if ( n <= k ) { for ( int i : primePow ) { sum += i ; } sum += k - n ; } else { vector < int > arr ( k , 1 ) ; sum = getMinSum ( 0 , arr , primePow ) ; } return sum ; } int main ( ) { int k = 3 , x = 210 ; cout << minimumSumWithGivenLCM ( k , x ) ; return 0 ; }

Index/key variables: i, pos
Accumulator variables: X, i, p, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMinOperationsReqEmpStr ( string str ) { int cntOne = 0 ; int cntZero = 0 ; int N = str . length ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( str [ i ] == '0' ) { if ( cntOne ) { cntOne -- ; } cntZero ++ ; } else { if ( cntZero ) { cntZero -- ; } cntOne ++ ; } } return ( cntOne + cntZero ) ; } int main ( ) { string str = "0100100111" ; cout << findMinOperationsReqEmpStr ( str ) ; }

Index/key variables: i
Accumulator variables: cntOne, cntZero, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countChanges ( vector < vector < char > > mat ) { int n = mat . size ( ) ; int m = mat [ 0 ] . size ( ) ; int ans = 0 ; for ( int j = 0 ; j < m - 1 ; j ++ ) { if ( mat [ n - 1 ] [ j ] != ' R ' ) ans ++ ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( mat [ i ] [ m - 1 ] != ' D ' ) ans ++ ; } return ans ; } int main ( ) { vector < vector < char > > arr = { { ' R ' , ' R ' , ' R ' , ' D ' } , { ' D ' , ' D ' , ' D ' , ' R ' } , { ' R ' , ' D ' , ' R ' , ' F ' } } ; int cnt = countChanges ( arr ) ; cout << cnt << endl ; return 0 ; }

Index/key variables: i, j
Accumulator variables: ans, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int key ; Node * left , * right ; } ; Node * newNode ( int key ) { Node * temp = new Node ; temp -> key = key ; temp -> left = temp -> right = NULL ; return temp ; } int isSorted ( Node * root ) { int prevMax = INT_MIN ; int minval ; int maxval ; int levelSize ; queue < Node * > q ; q . push ( root ) ; while ( ! q . empty ( ) ) { levelSize = q . size ( ) ; minval = INT_MAX ; maxval = INT_MIN ; while ( levelSize > 0 ) { root = q . front ( ) ; q . pop ( ) ; levelSize -- ; minval = min ( minval , root -> key ) ; maxval = max ( maxval , root -> key ) ; if ( root -> left ) q . push ( root -> left ) ; if ( root -> right ) q . push ( root -> right ) ; } if ( minval <= prevMax ) return 0 ; prevMax = maxval ; } return 1 ; } int main ( ) { Node * root = newNode ( 1 ) ; root -> left = newNode ( 4 ) ; root -> left -> right = newNode ( 6 ) ; root -> left -> right -> left = newNode ( 8 ) ; root -> left -> right -> right = newNode ( 9 ) ; root -> left -> right -> left -> left = newNode ( 12 ) ; root -> left -> right -> right -> right = newNode ( 10 ) ; if ( isSorted ( root ) ) cout << " Sorted " ; else cout << " Not ▁ sorted " ; return 0 ; }

Accumulator variables: levelSize, stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printSmallSub ( int arr [ ] , int N ) { int gcdArr = 0 ; for ( int i = 0 ; i < N ; i ++ ) { gcdArr = __gcd ( gcdArr , arr [ i ] ) ; } for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == gcdArr ) { cout << arr [ i ] << " ▁ " ; return ; } } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { if ( __gcd ( arr [ i ] , arr [ j ] ) == gcdArr ) { cout << arr [ i ] << " ▁ " << arr [ j ] ; return ; } } } } int main ( ) { int arr [ ] = { 4 , 6 , 12 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; printSmallSub ( arr , N ) ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define X  1000000
vector < bool > getPrimeNum ( ) { vector < bool > isPrime ( X , true ) ; isPrime [ 0 ] = false ; isPrime [ 1 ] = false ; for ( int i = 2 ; i * i <= X ; i ++ ) { if ( isPrime [ i ] == true ) { for ( int j = i * i ; j < X ; j += i ) { isPrime [ j ] = false ; } } } return isPrime ; } int cntPairs ( int arr [ ] , int N ) { vector < bool > isPrime = getPrimeNum ( ) ; int cntOne = 0 ; int cntPrime = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == 1 ) { cntOne += 1 ; } else if ( isPrime [ i ] ) { cntPrime += 1 ; } } int cntNonComp = 0 ; cntNonComp = cntPrime * cntOne + cntOne * ( cntOne - 1 ) / 2 ; int res = 0 ; res = N * ( N - 1 ) / 2 - cntNonComp ; return res ; } int main ( ) { int arr [ ] = { 1 , 1 , 2 , 2 , 8 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << cntPairs ( arr , N ) ; }

Index/key variables: i, j
Accumulator variables: cntOne, cntPrime, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int power ( int X , int n ) { int res = 1 ; while ( n ) { if ( n & 1 ) res = res * X ; X = X * X ; n = n >> 1 ; } return res ; } int closestgtNum ( int N ) { int n = log10 ( N ) + 1 ; int P = power ( 10 , n - 1 ) ; int Y = N % P ; int res = N + ( P - Y ) ; return res ; } int main ( ) { int N = 120 ; cout << closestgtNum ( N ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void RearrangeB ( int A [ ] , vector < int > B , int n ) { if ( n == 1 && A [ 0 ] == B [ 0 ] ) { cout << " - 1" << endl ; return ; } for ( int i = 0 ; i < n / 2 ; i ++ ) { int t = B [ i ] ; B [ i ] = B [ n - i - 1 ] ; B [ n - i - 1 ] = t ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( B [ i ] == A [ i ] ) { int t = B [ i + 1 ] ; B [ i + 1 ] = B [ i ] ; B [ i ] = t ; break ; } } for ( int k : B ) cout << k << " ▁ " ; } int main ( ) { int A [ ] = { 2 , 4 , 5 , 8 } ; vector < int > B = { 2 , 4 , 5 , 8 } ; int n = sizeof ( A ) / sizeof ( A [ 0 ] ) ; RearrangeB ( A , B , n ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  6
#define M  6
void swap ( int mat [ N ] [ M ] , int startx_X , int starty_X , int startx_Y , int starty_Y ) { int row = 0 ; int col = 0 ; for ( int i = startx_X ; ; i ++ ) { col = 0 ; for ( int j = startx_X ; ; j ++ ) { int temp = mat [ i ] [ j ] ; mat [ i ] [ j ] = mat [ startx_Y + row ] [ starty_Y + col ] ; mat [ startx_Y + row ] [ starty_Y + col ] = temp ; col ++ ; if ( col >= M / 2 ) break ; } row ++ ; if ( row >= N / 2 ) break ; } } static void swapQuadOfMatrix ( int mat [ N ] [ M ] , int X , int Y ) { if ( X == 1 && Y == 2 ) { swap ( mat , 0 , 0 , 0 , M / 2 ) ; } else if ( X == 1 && Y == 3 ) { swap ( mat , 0 , 0 , N / 2 , 0 ) ; } else if ( X == 1 && Y == 4 ) { swap ( mat , 0 , 0 , N / 2 , M / 2 ) ; } else if ( X == 2 && Y == 3 ) { swap ( mat , 0 , M / 2 , N / 2 , 0 ) ; } else if ( X == 2 && Y == 4 ) { swap ( mat , 0 , M / 2 , N / 2 , M / 2 ) ; } else if ( X == 3 && Y == 4 ) { swap ( mat , N / 2 , 0 , N / 2 , M / 2 ) ; } printMat ( mat ) ; } void printMat ( int mat [ N ] [ M ] ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { cout << mat [ i ] [ j ] << " ▁ " ; } cout << endl ; } } int main ( ) { int mat [ ] [ M ] = { { 1 , 2 , 3 , 4 , 5 , 6 } , { 7 , 8 , 9 , 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 , 35 , 36 } } ; int X = 1 , Y = 4 ; swapQuadOfMatrix ( mat , X , Y ) ; }

Index/key variables: M, N, i, j
Accumulator variables: col, i, j, row, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; int hd ; Node * left , * right ; Node ( int key ) { data = key ; hd = INT_MAX ; left = right = NULL ; } } ; void bottomView ( Node * root ) { if ( root == NULL ) return ; int hd = 0 ; map < int , int > m ; queue < Node * > q ; root -> hd = hd ; q . push ( root ) ; while ( ! q . empty ( ) ) { Node * temp = q . front ( ) ; q . pop ( ) ; hd = temp -> hd ; m [ hd ] = temp -> data ; if ( temp -> left != NULL ) { temp -> left -> hd = hd - 1 ; q . push ( temp -> left ) ; } if ( temp -> right != NULL ) { temp -> right -> hd = hd + 1 ; q . push ( temp -> right ) ; } } for ( auto i = m . begin ( ) ; i != m . end ( ) ; ++ i ) cout << i -> second << " ▁ " ; } int main ( ) { Node * root = new Node ( 20 ) ; root -> left = new Node ( 8 ) ; root -> right = new Node ( 22 ) ; root -> left -> left = new Node ( 5 ) ; root -> left -> right = new Node ( 3 ) ; root -> right -> left = new Node ( 4 ) ; root -> right -> right = new Node ( 25 ) ; root -> left -> right -> left = new Node ( 10 ) ; root -> left -> right -> right = new Node ( 14 ) ; cout << " Bottom ▁ view ▁ of ▁ the ▁ given ▁ binary ▁ tree ▁ : STRNEWLINE " ; bottomView ( root ) ; return 0 ; }

Index/key variables: hd
Accumulator variables: stdc
Iterator variables: i
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; void incrementCount ( int arr [ ] , int N ) { int mini = arr [ 0 ] - arr [ 1 ] ; for ( int i = 2 ; i < N ; i ++ ) { mini = min ( mini , arr [ i - 1 ] - arr [ i ] ) ; } cout << mini ; } int main ( ) { int N = 3 ; int arr [ N ] = { 12 , 8 , 4 } ; incrementCount ( arr , N ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void countOperations ( int n , int k ) { int div = 2 * k + 1 ; if ( n / 2 <= k ) { cout << 1 << " STRNEWLINE " ; if ( n > k ) cout << k + 1 ; else cout << n ; } else { if ( n % div == 0 ) { int oprn = n / div ; cout << oprn << " STRNEWLINE " ; int pos = k + 1 ; cout << pos << " ▁ " ; for ( int i = 1 ; i <= oprn ; i ++ ) { cout << pos << " ▁ " ; pos += div ; } } else { int oprn = n / div + 1 ; cout << oprn << " STRNEWLINE " ; int pos = n % div ; if ( n % div > k ) pos -= k ; for ( int i = 1 ; i <= oprn ; i ++ ) { cout << pos << " ▁ " ; pos += div ; } } } } int main ( ) { string str = " edfreqwsazxet " ; char ch = ' $ ' ; int n = str . size ( ) ; int k = 4 ; countOperations ( n , k ) ; return 0 ; }

Accumulator variables: i, pos, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void largestSubsequence ( string s ) { int maxi = 0 ; char prev1 ; for ( int i = 0 ; i < 10 ; i ++ ) { for ( int j = 0 ; j < 10 ; j ++ ) { if ( i != j ) { int len = 0 ; prev1 = j + '0' ; for ( int k = 0 ; k < s . size ( ) ; k ++ ) { if ( s [ k ] == i + '0' && prev1 == j + '0' ) { prev1 = s [ k ] ; len ++ ; } else if ( s [ k ] == j + '0' && prev1 == i + '0' ) { prev1 = s [ k ] ; len ++ ; } } maxi = max ( len , maxi ) ; } } } if ( maxi != 1 ) cout << maxi << endl ; else cout << 0 << endl ; } int main ( ) { string s = "1542745249842" ; largestSubsequence ( s ) ; return 0 ; }

Index/key variables: k
Accumulator variables: i, j, k, len
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
#include <map>
using namespace std ; struct Node { int data ; int hd ; Node * left , * right ; Node ( int key ) { data = key ; hd = INT_MAX ; left = right = NULL ; } } ; void printBottomViewUtil ( Node * root , int curr , int hd , map < int , pair < int , int > > & m ) { if ( root == NULL ) return ; if ( m . find ( hd ) == m . end ( ) ) { m [ hd ] = make_pair ( root -> data , curr ) ; } else { pair < int , int > p = m [ hd ] ; if ( p . second <= curr ) { m [ hd ] . second = curr ; m [ hd ] . first = root -> data ; } } printBottomViewUtil ( root -> left , curr + 1 , hd - 1 , m ) ; printBottomViewUtil ( root -> right , curr + 1 , hd + 1 , m ) ; } void printBottomView ( Node * root ) { map < int , pair < int , int > > m ; printBottomViewUtil ( root , 0 , 0 , m ) ; map < int , pair < int , int > > :: iterator it ; for ( it = m . begin ( ) ; it != m . end ( ) ; ++ it ) { pair < int , int > p = it -> second ; cout << p . first << " ▁ " ; } } int main ( ) { Node * root = new Node ( 20 ) ; root -> left = new Node ( 8 ) ; root -> right = new Node ( 22 ) ; root -> left -> left = new Node ( 5 ) ; root -> left -> right = new Node ( 3 ) ; root -> right -> left = new Node ( 4 ) ; root -> right -> right = new Node ( 25 ) ; root -> left -> right -> left = new Node ( 10 ) ; root -> left -> right -> right = new Node ( 14 ) ; cout << " Bottom ▁ view ▁ of ▁ the ▁ given ▁ binary ▁ tree ▁ : STRNEWLINE " ; printBottomView ( root ) ; return 0 ; }

Index/key variables: hd
Accumulator variables: stdc
Iterator variables: it
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxm = 0 ; struct Node { int val ; Node * left , * right ; Node ( int x ) { val = x ; left = NULL ; right = NULL ; } } ; int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } int find_gcd ( vector < int > arr ) { if ( arr . size ( ) == 1 ) return arr [ 0 ] ; int g = arr [ 0 ] ; for ( int i = 1 ; i < arr . size ( ) ; i ++ ) { g = gcd ( g , arr [ i ] ) ; } return g ; } void maxm_gcd ( Node * root , vector < int > ans ) { if ( ! root ) return ; if ( root -> left == NULL and root -> right == NULL ) { ans . push_back ( root -> val ) ; maxm = max ( find_gcd ( ans ) , maxm ) ; return ; } ans . push_back ( root -> val ) ; maxm_gcd ( root -> left , ans ) ; maxm_gcd ( root -> right , ans ) ; } int main ( ) { Node * root = new Node ( 15 ) ; root -> left = new Node ( 3 ) ; root -> right = new Node ( 7 ) ; root -> left -> left = new Node ( 15 ) ; root -> left -> right = new Node ( 1 ) ; root -> right -> left = new Node ( 31 ) ; root -> right -> right = new Node ( 9 ) ; maxm_gcd ( root , { } ) ; cout << maxm << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
Class/struct names: Node
C++ program:
#include <iostream>
using namespace std ; int numberOfPairs ( int n ) { int count = 0 ; int i = 1 , j = n - 1 ; while ( i < j ) { if ( i + j == n ) { count ++ ; } i ++ ; j -- ; } return count ; } int main ( ) { int n = 8 ; cout << numberOfPairs ( n ) ; return 0 ; }

Accumulator variables: count, i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int N = 1e5 + 5 ; vector < vector < int > > v ( N ) ; vector < vector < int > > g ( N ) ; vector < bool > vis ( N , 0 ) ; vector < int > in ( N ) , low ( N ) ; vector < int > parent ( N ) , rnk ( N ) ; vector < pair < int , int > > bridges ; int n , m ; int timer = 0 ; int find_set ( int a ) { if ( parent [ a ] == a ) return a ; return parent [ a ] = find_set ( parent [ a ] ) ; } void union_set ( int a , int b ) { int x = find_set ( a ) , y = find_set ( b ) ; if ( x == y ) return ; if ( rnk [ x ] == rnk [ y ] ) rnk [ x ] ++ ; if ( rnk [ y ] > rnk [ x ] ) swap ( x , y ) ; parent [ y ] = x ; } void dfsBridges ( int a , int par ) { vis [ a ] = 1 ; in [ a ] = low [ a ] = timer ++ ; for ( int i v [ a ] ) { if ( i == par ) continue ; if ( vis [ i ] ) low [ a ] = min ( low [ a ] , in [ i ] ) ; else { dfsBridges ( i , a ) ; low [ a ] = min ( low [ a ] , low [ i ] ) ; if ( in [ a ] < low [ i ] ) bridges . push_back ( make_pair ( i , a ) ) ; else union_set ( i , a ) ; } } } int dfsDiameter ( int a , int par , int & diameter ) { int x = 0 , y = 0 ; for ( int i g [ a ] ) { if ( i == par ) continue ; int mx = dfsDiameter ( i , a , diameter ) ; if ( mx > x ) { y = x ; x = mx ; } else if ( mx > y ) y = mx ; } diameter = max ( diameter , x + y ) ; return x + 1 ; } int findMaxBridges ( ) { for ( int i = 0 ; i <= n ; i ++ ) { parent [ i ] = i ; rnk [ i ] = 1 ; } dfsBridges ( 1 , 0 ) ; if ( bridges . empty ( ) ) return 0 ; int head = -1 ; for ( auto & i bridges ) { int a = find_set ( i . first ) ; int b = find_set ( i . second ) ; g [ a ] . push_back ( b ) ; g [ b ] . push_back ( a ) ; head = a ; } int diameter = 0 ; dfsDiameter ( head , 0 , diameter ) ; return diameter ; } int main ( ) { n = 6 , m = 6 ; v [ 1 ] . push_back ( 2 ) ; v [ 2 ] . push_back ( 1 ) ; v [ 2 ] . push_back ( 3 ) ; v [ 3 ] . push_back ( 2 ) ; v [ 2 ] . push_back ( 5 ) ; v [ 5 ] . push_back ( 2 ) ; v [ 5 ] . push_back ( 6 ) ; v [ 6 ] . push_back ( 5 ) ; v [ 6 ] . push_back ( 3 ) ; v [ 3 ] . push_back ( 6 ) ; v [ 3 ] . push_back ( 4 ) ; v [ 4 ] . push_back ( 4 ) ; int ans = findMaxBridges ( ) ; cout << ans << endl ; return 0 ; }

Index/key variables: a, b, i, x, y
Accumulator variables: i, stdc, timer
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct node { int data ; struct node * left ; struct node * right ; } ; unsigned int getLeafCount ( struct node * node ) { if ( node == NULL ) return 0 ; if ( node -> left == NULL && node -> right == NULL ) return 1 ; else return getLeafCount ( node -> left ) + getLeafCount ( 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 ) ; cout << " Leaf ▁ count ▁ of ▁ the ▁ tree ▁ is ▁ : ▁ " << getLeafCount ( root ) << endl ; return 0 ; }

Accumulator variables: stdc
Class/struct names: node
C++ program:
#include <bits/stdc++.h>
using namespace std ; int palindromeWinner ( string & S ) { int freq [ 26 ] ; memset ( freq , 0 , sizeof freq ) ; int count = 0 ; for ( int i = 0 ; i < ( int ) S . length ( ) ; ++ i ) { if ( freq [ S [ i ] - ' a ' ] == 0 ) count ++ ; freq [ S [ i ] - ' a ' ] ++ ; } int unique = 0 ; int duplicate = 0 ; for ( int i = 0 ; i < 26 ; ++ i ) { if ( freq [ i ] == 1 ) unique ++ ; else if ( freq [ i ] >= 2 ) duplicate ++ ; } if ( unique == 1 && ( unique + duplicate ) == count ) return 1 ; return 2 ; } int main ( ) { string S = " abcbc " ; cout << " Player - " << palindromeWinner ( S ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: count, duplicate, stdc, unique
Iterator variables: i