dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; Node * left , * right ; } ; Node * newNode ( int key ) { Node * temp = new Node ; temp -> data = key ; temp -> left = temp -> right = NULL ; return temp ; } int printKDistantfromLeaf ( struct Node * node , int k ) { if ( node == NULL ) return -1 ; int lk = printKDistantfromLeaf ( node -> left , k ) ; int rk = printKDistantfromLeaf ( node -> right , k ) ; bool isLeaf = lk == -1 && lk == rk ; if ( lk == 0 || rk == 0 || ( isLeaf && k == 0 ) ) cout << ( " ▁ " ) << ( node -> data ) ; if ( isLeaf && k > 0 ) return k - 1 ; if ( lk > 0 && lk < k ) return lk - 1 ; if ( rk > 0 && rk < k ) return rk - 1 ; return -2 ; } int main ( ) { Node * root = NULL ; root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 3 ) ; root -> left -> left = newNode ( 4 ) ; root -> left -> right = newNode ( 5 ) ; root -> right -> left = newNode ( 6 ) ; root -> right -> right = newNode ( 7 ) ; root -> right -> left -> right = newNode ( 8 ) ; cout << ( " ▁ Nodes ▁ at ▁ distance ▁ 2 ▁ are ▁ : " ) << endl ; printKDistantfromLeaf ( root , 2 ) ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int key ; struct Node * left , * right ; } ; struct Node * newNode ( int key ) { Node * temp = new Node ; temp -> key = key ; temp -> left = temp -> right = NULL ; return ( temp ) ; } void printCorner ( Node * root ) { if ( root == NULL ) return ; queue < Node * > q ; q . push ( root ) ; while ( ! q . empty ( ) ) { int n = q . size ( ) ; for ( int i = 0 ; i < n ; i ++ ) { Node * temp = q . front ( ) ; q . pop ( ) ; if ( i == 0 i == n - 1 ) cout << temp -> key << " ▁ " ; if ( temp -> left ) q . push ( temp -> left ) ; if ( temp -> right ) q . push ( temp -> right ) ; } } } int main ( ) { Node * root = newNode ( 15 ) ; root -> left = newNode ( 10 ) ; root -> right = newNode ( 20 ) ; root -> left -> left = newNode ( 8 ) ; root -> left -> right = newNode ( 12 ) ; root -> right -> left = newNode ( 16 ) ; root -> right -> right = newNode ( 25 ) ; printCorner ( root ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define COUNT  10
class Node { public : int data ; Node * left , * right ; Node ( int data ) { this -> data = data ; this -> left = NULL ; this -> right = NULL ; } } ; void print2DUtil ( Node * root , int space ) { if ( root == NULL ) return ; space += COUNT ; print2DUtil ( root -> right , space ) ; cout << endl ; for ( int i = COUNT ; i < space ; i ++ ) cout << " ▁ " ; cout << root -> data << " STRNEWLINE " ; print2DUtil ( root -> left , space ) ; } void print2D ( Node * root ) { print2DUtil ( root , 0 ) ; } int main ( ) { Node * root = new Node ( 1 ) ; root -> left = new Node ( 2 ) ; root -> right = new Node ( 3 ) ; root -> left -> left = new Node ( 4 ) ; root -> left -> right = new Node ( 5 ) ; root -> right -> left = new Node ( 6 ) ; root -> right -> right = new Node ( 7 ) ; root -> left -> left -> left = new Node ( 8 ) ; root -> left -> left -> right = new Node ( 9 ) ; root -> left -> right -> left = new Node ( 10 ) ; root -> left -> right -> right = new Node ( 11 ) ; root -> right -> left -> left = new Node ( 12 ) ; root -> right -> left -> right = new Node ( 13 ) ; root -> right -> right -> left = new Node ( 14 ) ; root -> right -> right -> right = new Node ( 15 ) ; print2D ( root ) ; return 0 ; }

Accumulator variables: i, space, stdc
Iterator variables: i
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; struct Node * left , * right ; } ; struct Node * newNode ( int item ) { struct Node * temp = ( struct Node * ) malloc ( sizeof ( struct Node ) ) ; temp -> data = item ; temp -> left = temp -> right = NULL ; return temp ; } void leftViewUtil ( struct Node * root , int level , int * max_level ) { if ( root == NULL ) return ; if ( * max_level < level ) { cout << root -> data << " ▁ " ; * max_level = level ; } leftViewUtil ( root -> left , level + 1 , max_level ) ; leftViewUtil ( root -> right , level + 1 , max_level ) ; } void leftView ( struct Node * root ) { int max_level = 0 ; leftViewUtil ( root , 1 , & max_level ) ; } int main ( ) { Node * root = newNode ( 10 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 3 ) ; root -> left -> left = newNode ( 7 ) ; root -> left -> right = newNode ( 8 ) ; root -> right -> right = newNode ( 15 ) ; root -> right -> left = newNode ( 12 ) ; root -> right -> right -> left = newNode ( 14 ) ; leftView ( root ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; struct Node * left , * right ; } ; Node * newNode ( int data ) { Node * temp = new Node ; temp -> data = data ; temp -> left = temp -> right = NULL ; return temp ; } void printLeftView ( Node * root ) { if ( ! root ) return ; queue < Node * > q ; q . push ( root ) ; while ( ! q . empty ( ) ) { int n = q . size ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { Node * temp = q . front ( ) ; q . pop ( ) ; if ( i == 1 ) cout << temp -> data << " ▁ " ; if ( temp -> left != NULL ) q . push ( temp -> left ) ; if ( temp -> right != NULL ) q . push ( temp -> right ) ; } } } int main ( ) { Node * root = newNode ( 10 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 3 ) ; root -> left -> left = newNode ( 7 ) ; root -> left -> right = newNode ( 8 ) ; root -> right -> right = newNode ( 15 ) ; root -> right -> left = newNode ( 12 ) ; root -> right -> right -> left = newNode ( 14 ) ; printLeftView ( root ) ; }

Accumulator variables: i, stdc
Iterator variables: i
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; int rotate ( int arr [ ] , int N , int X ) { long long int nextPower = 1 ; while ( nextPower <= N ) nextPower *= 2 ; if ( X == 1 ) return nextPower - N ; long long int prevPower = nextPower / 2 ; return 2 * ( N - prevPower ) + 1 ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 } ; int X = 1 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << rotate ( arr , N , X ) ; return 0 ; }

Accumulator variables: nextPower, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; string findRotation ( vector < vector < int > > & mat , vector < vector < int > > & T ) { if ( T . size ( ) != mat . size ( ) || T [ 0 ] . size ( ) != mat [ 0 ] . size ( ) ) { return " No " ; } map < vector < int > , int > m ; for ( int i = 0 ; i < mat . size ( ) ; i ++ ) { m [ mat [ i ] ] += 1 ; reverse ( mat [ i ] . begin ( ) , mat [ i ] . end ( ) ) ; m [ mat [ i ] ] += 1 ; } for ( int i = 0 ; i < mat [ 0 ] . size ( ) ; i ++ ) { vector < int > r = { } ; for ( int j = 0 ; j < mat . size ( ) ; j ++ ) { r . push_back ( mat [ j ] [ i ] ) ; } m [ r ] += 1 ; reverse ( r . begin ( ) , r . end ( ) ) ; m [ r ] += 1 ; } for ( int i = 0 ; i < T . size ( ) ; i ++ ) { if ( m [ T [ i ] ] <= 0 ) { return " No " ; } m [ T [ i ] ] -= 1 ; } for ( int i = 0 ; i < T [ 0 ] . size ( ) ; i ++ ) { vector < int > r = { } ; for ( int j = 0 ; j < T . size ( ) ; j ++ ) { r . push_back ( T [ j ] [ i ] ) ; } if ( m [ r ] <= 0 ) { return " No " ; } m [ r ] -= 1 ; } return " Yes " ; } int main ( ) { vector < vector < int > > mat = { { 1 , 2 , 3 } , { 4 , 5 , 6 } , { 7 , 8 , 9 } } ; vector < vector < int > > T = { { 3 , 6 , 9 } , { 2 , 5 , 8 } , { 1 , 4 , 7 } } ; cout << findRotation ( mat , T ) ; return 0 ; }

Index/key variables: i, j, r
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findMaximumZeros ( string str , int n ) { int c0 = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( str [ i ] == '0' ) c0 ++ ; } if ( c0 == n ) { cout << n ; return ; } string s = str + str ; int mx = 0 ; for ( int i = 0 ; i < n ; ++ i ) { int cs = 0 ; int ce = 0 ; for ( int j = i ; j < i + n ; ++ j ) { if ( s [ j ] == '0' ) cs ++ ; else break ; } for ( int j = i + n - 1 ; j >= i ; -- j ) { if ( s [ j ] == '0' ) ce ++ ; else break ; } int val = cs + ce ; mx = max ( val , mx ) ; } cout << mx ; } int main ( ) { string s = "1001" ; int n = s . size ( ) ; findMaximumZeros ( s , n ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: c0, ce, cs, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findMaximumZeros ( string str , int n ) { int c0 = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( str [ i ] == '0' ) c0 ++ ; } if ( c0 == n ) { cout << n ; return ; } int mx = 0 ; int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == '0' ) cnt ++ ; else { mx = max ( mx , cnt ) ; cnt = 0 ; } } mx = max ( mx , cnt ) ; int start = 0 , end = n - 1 ; cnt = 0 ; while ( str [ start ] != '1' && start < n ) { cnt ++ ; start ++ ; } while ( str [ end ] != '1' && end >= 0 ) { cnt ++ ; end -- ; } mx = max ( mx , cnt ) ; cout << mx ; } int main ( ) { string s = "1001" ; int n = s . size ( ) ; findMaximumZeros ( s , n ) ; return 0 ; }

Index/key variables: end, i, start
Accumulator variables: c0, cnt, end, i, start, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void rotateMatrix ( vector < vector < int > > & mat ) { int i = 0 ; for ( auto & it : mat ) { reverse ( it . begin ( ) , it . end ( ) ) ; reverse ( it . begin ( ) , it . begin ( ) + i ) ; reverse ( it . begin ( ) + i , it . end ( ) ) ; i ++ ; } for ( auto rows : mat ) { for ( auto cols : rows ) { cout << cols << " ▁ " ; } cout << " STRNEWLINE " ; } } int main ( ) { vector < vector < int > > mat = { { 1 , 2 , 3 } , { 4 , 5 , 6 } , { 7 , 8 , 9 } } ; rotateMatrix ( mat ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: cols, rows
C++ program:
#include <bits/stdc++.h>
using namespace std ; void stringShift ( string s , vector < vector < int > > & shift ) { int val = 0 ; for ( int i = 0 ; i < shift . size ( ) ; ++ i ) val += shift [ i ] [ 0 ] == 0 ? - shift [ i ] [ 1 ] : shift [ i ] [ 1 ] ; int len = s . length ( ) ; val = val % len ; string result = " " ; if ( val > 0 ) result = s . substr ( len - val , val ) + s . substr ( 0 , len - val ) ; else result = s . substr ( - val , len + val ) + s . substr ( 0 , - val ) ; cout << result ; } int main ( ) { string s = " abc " ; vector < vector < int > > shift = { { 0 , 1 } , { 1 , 2 } } ; stringShift ( s , shift ) ; return 0 ; }

Index/key variables: i
Accumulator variables: stdc, val
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void rotateArray ( vector < int > & arr , int N ) { vector < int > v = arr ; sort ( v . begin ( ) , v . end ( ) ) ; for ( int i = 1 ; i <= N ; ++ i ) { rotate ( arr . begin ( ) , arr . begin ( ) + 1 , arr . end ( ) ) ; if ( arr == v ) { cout << " YES " << endl ; return ; } } cout << " NO " << endl ; } int main ( ) { vector < int > arr = { 3 , 4 , 5 , 1 , 2 } ; int N = arr . size ( ) ; rotateArray ( arr , N ) ; }

Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findLargestRotation ( int num ) { int ans = num ; int len = floor ( log10 ( num ) + 1 ) ; int x = pow ( 10 , len - 1 ) ; for ( int i = 1 ; i < len ; i ++ ) { int lastDigit = num % 10 ; num = num / 10 ; num += ( lastDigit * x ) ; if ( num > ans ) { ans = num ; } } cout << ans ; } int main ( ) { int N = 657 ; findLargestRotation ( N ) ; return 0 ; }

Accumulator variables: i, num, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int numberOfDigit ( int N ) { int digit = 0 ; while ( N > 0 ) { digit ++ ; N /= 10 ; } return digit ; } void rotateNumberByK ( int N , int K ) { int X = numberOfDigit ( N ) ; K = ( ( K % X ) + X ) % X ; int left_no = N / ( int ) ( pow ( 10 , X - K ) ) ; N = N % ( int ) ( pow ( 10 , X - K ) ) ; int left_digit = numberOfDigit ( left_no ) ; N = ( N * ( int ) ( pow ( 10 , left_digit ) ) ) + left_no ; cout << N ; } int main ( ) { int N = 12345 , K = 7 ; rotateNumberByK ( N , K ) ; return 0 ; }

Accumulator variables: N, digit, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minMovesToSort ( int arr [ ] , int N ) { int count = 0 ; int index ; for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( arr [ i ] < arr [ i + 1 ] ) { count ++ ; index = i ; } } if ( count == 0 ) { cout << "0" ; } else if ( count == N - 1 ) { cout << N - 1 ; } else if ( count == 1 && arr [ 0 ] <= arr [ N - 1 ] ) { cout << index + 1 ; } else { cout << " - 1" ; } } int main ( ) { int arr [ ] = { 2 , 1 , 5 , 4 , 2 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; minMovesToSort ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  3
int findMaximumDiagonalSumOMatrixf ( int A [ ] [ N ] ) { int maxDiagonalSum = INT_MIN ; for ( int i = 0 ; i < N ; i ++ ) { int curr = 0 ; for ( int j = 0 ; j < N ; j ++ ) { curr += A [ j ] [ ( i + j ) % N ] ; } maxDiagonalSum = max ( maxDiagonalSum , curr ) ; } for ( int i = 0 ; i < N ; i ++ ) { int curr = 0 ; for ( int j = 0 ; j < N ; j ++ ) { curr += A [ ( i + j ) % N ] [ j ] ; } maxDiagonalSum = max ( maxDiagonalSum , curr ) ; } return maxDiagonalSum ; } int main ( ) { int mat [ N ] [ N ] = { { 1 , 1 , 2 } , { 2 , 1 , 2 } , { 1 , 2 , 2 } } ; cout << findMaximumDiagonalSumOMatrixf ( mat ) ; return 0 ; }

Index/key variables: N, j
Accumulator variables: curr, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void diagonalSumPerfectSquare ( int arr [ ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { cout << ( arr [ ( j + i ) % 7 ] ) << " ▁ " ; } cout << endl ; } } int main ( ) { int N = 7 ; int arr [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { arr [ i ] = i + 1 ; } diagonalSumPerfectSquare ( arr , N ) ; }

Index/key variables: N, i
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int MaxSum ( vector < int > arr , int n , int k ) { int i , max_sum = 0 , sum = 0 ; for ( i = 0 ; i < k ; i ++ ) { sum += arr [ i ] ; } max_sum = sum ; while ( i < n ) { sum = sum - arr [ i - k ] + arr [ i ] ; if ( max_sum < sum ) { max_sum = sum ; } i ++ ; } return max_sum ; } int gcd ( int n1 , int n2 ) { if ( n2 == 0 ) { return n1 ; } else { return gcd ( n2 , n1 % n2 ) ; } } vector < int > RotateArr ( vector < int > arr , int n , int d ) { int i = 0 , j = 0 ; d = d % n ; int no_of_sets = gcd ( d , n ) ; for ( i = 0 ; i < no_of_sets ; i ++ ) { int temp = arr [ i ] ; j = i ; while ( true ) { int k = j + d ; if ( k >= n ) k = k - n ; if ( k == i ) break ; arr [ j ] = arr [ k ] ; j = k ; } arr [ j ] = temp ; } return arr ; } void performQuery ( vector < int > & arr , int Q [ ] [ 2 ] , int q ) { int N = ( int ) arr . size ( ) ; for ( int i = 0 ; i < q ; i ++ ) { if ( Q [ i ] [ 0 ] == 1 ) { arr = RotateArr ( arr , N , Q [ i ] [ 1 ] ) ; for ( auto t : arr ) { cout << t << " ▁ " ; } cout << " STRNEWLINE " ; } else { cout << MaxSum ( arr , N , Q [ i ] [ 1 ] ) << " STRNEWLINE " ; } } } int main ( ) { vector < int > arr = { 1 , 2 , 3 , 4 , 5 } ; int q = 5 ; int Q [ ] [ 2 ] = { { 1 , 2 } , { 2 , 3 } , { 1 , 3 } , { 1 , 1 } , { 2 , 4 } } ; performQuery ( arr , Q , q ) ; return 0 ; }

Index/key variables: i, j, k
Accumulator variables: i, stdc, sum
Iterator variables: i, t
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getMinimumRemoval ( string str ) { int n = str . length ( ) ; int ans = n ; if ( n % 2 == 0 ) { vector < int > freqEven ( 128 ) ; vector < int > freqOdd ( 128 ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 2 == 0 ) { freqEven [ str [ i ] ] ++ ; } else { freqOdd [ str [ i ] ] ++ ; } } int evenMax = 0 , oddMax = 0 ; for ( char chr = ' a ' ; chr <= ' z ' ; chr ++ ) { evenMax = max ( evenMax , freqEven [ chr ] ) ; oddMax = max ( oddMax , freqOdd [ chr ] ) ; } ans = ans - evenMax - oddMax ; } else { vector < int > freq ( 128 ) ; for ( int i = 0 ; i < n ; i ++ ) { freq [ str [ i ] ] ++ ; } int strMax = 0 ; for ( char chr = ' a ' ; chr <= ' z ' ; chr ++ ) { strMax = max ( strMax , freq [ chr ] ) ; } ans = ans - strMax ; } return ans ; } int main ( ) { string str = " geeksgeeks " ; cout << getMinimumRemoval ( str ) ; }

Index/key variables: chr, i
Accumulator variables: chr, i, stdc
Iterator variables: chr, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findAltSubSeq ( string s ) { int n = s . size ( ) , ans = INT_MIN ; for ( int i = 0 ; i < 10 ; i ++ ) { for ( int j = 0 ; j < 10 ; j ++ ) { int cur = 0 , f = 0 ; for ( int k = 0 ; k < n ; k ++ ) { if ( f == 0 and s [ k ] - '0' == i ) { f = 1 ; cur ++ ; } else if ( f == 1 and s [ k ] - '0' == j ) { f = 0 ; cur ++ ; } } if ( i != j and cur % 2 == 1 ) cur -- ; ans = max ( cur , ans ) ; } } return ans ; } int main ( ) { string s = "100210601" ; cout << findAltSubSeq ( s ) ; return 0 ; }

Index/key variables: k
Accumulator variables: cur, i, j, k, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; void matrix ( int n , int m , vector < vector < int > > li ) { int ctr = 0 ; while ( ctr < 2 * n - 1 ) { for ( int i = 0 ; i < abs ( n - ctr - 1 ) ; i ++ ) { cout << " ▁ " ; } vector < int > lst ; for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( i + j == ctr ) { lst . push_back ( li [ i ] [ j ] ) ; } } } for ( int i = lst . size ( ) - 1 ; i >= 0 ; i -- ) { cout << lst [ i ] << " ▁ " ; } cout << endl ; ctr += 1 ; } } int main ( ) { int n = 8 ; int m = n ; vector < vector < int > > li { { 4 , 5 , 6 , 9 , 8 , 7 , 1 , 4 } , { 1 , 5 , 9 , 7 , 5 , 3 , 1 , 6 } , { 7 , 5 , 3 , 1 , 5 , 9 , 8 , 0 } , { 6 , 5 , 4 , 7 , 8 , 9 , 3 , 7 } , { 3 , 5 , 6 , 4 , 8 , 9 , 2 , 1 } , { 3 , 1 , 6 , 4 , 7 , 9 , 5 , 0 } , { 8 , 0 , 7 , 2 , 3 , 1 , 0 , 8 } , { 7 , 5 , 3 , 1 , 5 , 9 , 8 , 5 } } ; matrix ( n , m , li ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: ctr, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getFirstElement ( int a [ ] , int N , int K , int M ) { K %= N ; int index ; if ( K >= M ) index = ( N - K ) + ( M - 1 ) ; else index = ( M - K - 1 ) ; int result = a [ index ] ; return result ; } int main ( ) { int a [ ] = { 1 , 2 , 3 , 4 , 5 } ; int N = sizeof ( a ) / sizeof ( a [ 0 ] ) ; int K = 3 , M = 2 ; cout << getFirstElement ( a , N , K , M ) ; return 0 ; }

Index/key variables: index
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getFirstElement ( int a [ ] , int N , int K , int M ) { K %= N ; int index = ( K + M - 1 ) % N ; int result = a [ index ] ; return result ; } int main ( ) { int a [ ] = { 3 , 4 , 5 , 23 } ; int N = sizeof ( a ) / sizeof ( a [ 0 ] ) ; int K = 2 , M = 1 ; cout << getFirstElement ( a , N , K , M ) ; return 0 ; }

Index/key variables: index
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void left_rotate ( int arr [ ] ) { int last = arr [ 1 ] ; for ( int i = 3 ; i < 6 ; i = i + 2 ) { arr [ i - 2 ] = arr [ i ] ; } arr [ 6 - 1 ] = last ; } void right_rotate ( int arr [ ] ) { int start = arr [ 6 - 2 ] ; for ( int i = 6 - 4 ; i >= 0 ; i = i - 2 ) { arr [ i + 2 ] = arr [ i ] ; } arr [ 0 ] = start ; } void rotate ( int arr [ ] ) { left_rotate ( arr ) ; right_rotate ( arr ) ; for ( int i = 0 ; i < 6 ; i ++ ) { cout << ( arr [ i ] ) << " ▁ " ; } } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 } ; rotate ( arr ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maximumMatchingPairs ( int perm1 [ ] , int perm2 [ ] , int n ) { int left [ n ] , right [ n ] ; map < int , int > mp1 , mp2 ; for ( int i = 0 ; i < n ; i ++ ) { mp1 [ perm1 [ i ] ] = i ; } for ( int j = 0 ; j < n ; j ++ ) { mp2 [ perm2 [ j ] ] = j ; } for ( int i = 0 ; i < n ; i ++ ) { int idx2 = mp2 [ perm1 [ i ] ] ; int idx1 = i ; if ( idx1 == idx2 ) { left [ i ] = 0 ; right [ i ] = 0 ; } else if ( idx1 < idx2 ) { left [ i ] = ( n - ( idx2 - idx1 ) ) ; right [ i ] = ( idx2 - idx1 ) ; } else { left [ i ] = ( idx1 - idx2 ) ; right [ i ] = ( n - ( idx1 - idx2 ) ) ; } } map < int , int > freq1 , freq2 ; for ( int i = 0 ; i < n ; i ++ ) { freq1 [ left [ i ] ] ++ ; freq2 [ right [ i ] ] ++ ; } int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ans = max ( ans , max ( freq1 [ left [ i ] ] , freq2 [ right [ i ] ] ) ) ; } return ans ; } int main ( ) { int P1 [ ] = { 5 , 4 , 3 , 2 , 1 } ; int P2 [ ] = { 1 , 2 , 3 , 4 , 5 } ; int n = sizeof ( P1 ) / sizeof ( P1 [ 0 ] ) ; cout << maximumMatchingPairs ( P1 , P2 , n ) ; 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 ; int countRotation ( int arr [ ] , int n ) { for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] < arr [ i - 1 ] ) { return i ; } } return 0 ; } int main ( ) { int arr1 [ ] = { 4 , 5 , 1 , 2 , 3 } ; int n = sizeof ( arr1 ) / sizeof ( int ) ; cout << countRotation ( arr1 , n ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countRotation ( int arr [ ] , int low , int high ) { if ( low > high ) { return 0 ; } int mid = low + ( high - low ) / 2 ; if ( mid < high && arr [ mid ] > arr [ mid + 1 ] ) { return mid + 1 ; } if ( mid > low && arr [ mid ] < arr [ mid - 1 ] ) { return mid ; } if ( arr [ mid ] > arr [ low ] ) { return countRotation ( arr , mid + 1 , high ) ; } if ( arr [ mid ] < arr [ high ] ) { return countRotation ( arr , low , mid - 1 ) ; } else { int rightIndex = countRotation ( arr , mid + 1 , high ) ; int leftIndex = countRotation ( arr , low , mid - 1 ) ; if ( rightIndex == 0 ) { return leftIndex ; } return rightIndex ; } } int main ( ) { int arr1 [ ] = { 4 , 5 , 1 , 2 , 3 } ; int N = sizeof ( arr1 ) / sizeof ( arr1 [ 0 ] ) ; cout << countRotation ( arr1 , 0 , N - 1 ) ; return 0 ; }

Index/key variables: high, low, mid
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minCircularRotations ( string target , vector < string > & blocked , int N ) { string start = " " ; for ( int i = 0 ; i < N ; i ++ ) { start += '0' ; } unordered_set < string > avoid ; for ( int i = 0 ; i < blocked . size ( ) ; i ++ ) avoid . insert ( blocked [ i ] ) ; if ( avoid . find ( start ) != avoid . end ( ) ) return -1 ; if ( avoid . find ( target ) != avoid . end ( ) ) return -1 ; queue < string > qu ; qu . push ( start ) ; int count = 0 ; while ( ! qu . empty ( ) ) { count ++ ; int size = qu . size ( ) ; for ( int j = 0 ; j < size ; j ++ ) { string st = qu . front ( ) ; qu . pop ( ) ; for ( int i = 0 ; i < N ; i ++ ) { char ch = st [ i ] ; st [ i ] ++ ; if ( st [ i ] > '9' ) st [ i ] = '0' ; if ( st == target ) return count ; if ( avoid . find ( st ) == avoid . end ( ) ) qu . push ( st ) ; avoid . insert ( st ) ; st [ i ] = ch - 1 ; if ( st [ i ] < '0' ) st [ i ] = '9' ; if ( st == target ) return count ; if ( avoid . find ( st ) == avoid . end ( ) ) qu . push ( st ) ; avoid . insert ( st ) ; st [ i ] = ch ; } } } return -1 ; } int main ( ) { int N = 4 ; string target = "7531" ; vector < string > blocked = { "1543" , "7434" , "7300" , "7321" , "2427" } ; cout << minCircularRotations ( target , blocked , N ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, j, start, stdc
Iterator variables: i, j