dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; void arrayEvenAndOdd ( int arr [ ] , int n ) { int i = -1 , j = 0 ; int t ; while ( j != n ) { if ( arr [ j ] % 2 == 0 ) { i ++ ; swap ( arr [ i ] , arr [ j ] ) ; } j ++ ; } for ( int i = 0 ; i < n ; i ++ ) cout << arr [ i ] << " ▁ " ; } int main ( ) { int arr [ ] = { 1 , 3 , 2 , 4 , 7 , 6 , 9 , 10 } ; int n = sizeof ( arr ) / sizeof ( int ) ; arrayEvenAndOdd ( arr , n ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int key ; struct Node * left , * right ; } ; Node * newNode ( char k ) { Node * node = new Node ; node -> key = k ; node -> right = node -> left = NULL ; return node ; } void leftLeavesSumRec ( Node * root , bool isleft , int * sum ) { if ( ! root ) return ; if ( ! root -> left && ! root -> right && isleft ) * sum += root -> key ; leftLeavesSumRec ( root -> left , 1 , sum ) ; leftLeavesSumRec ( root -> right , 0 , sum ) ; } int leftLeavesSum ( Node * root ) { int sum = 0 ; leftLeavesSumRec ( root , 0 , & sum ) ; return sum ; } int main ( ) { int sum = 0 ; struct Node * root = newNode ( 20 ) ; root -> left = newNode ( 9 ) ; root -> right = newNode ( 49 ) ; root -> right -> left = newNode ( 23 ) ; root -> right -> right = newNode ( 52 ) ; root -> right -> right -> left = newNode ( 50 ) ; root -> left -> left = newNode ( 5 ) ; root -> left -> right = newNode ( 12 ) ; root -> left -> right -> right = newNode ( 12 ) ; cout << " Sum ▁ of ▁ left ▁ leaves ▁ is ▁ " << leftLeavesSum ( root ) << endl ; return 0 ; }

Accumulator variables: stdc, sum
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 ) ; } bool isMirror ( struct Node * root1 , struct Node * root2 ) { if ( root1 == NULL && root2 == NULL ) return true ; if ( root1 && root2 && root1 -> key == root2 -> key ) return isMirror ( root1 -> left , root2 -> right ) && isMirror ( root1 -> right , root2 -> left ) ; return false ; } bool isSymmetric ( struct Node * root ) { return isMirror ( root , root ) ; } int main ( ) { Node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 2 ) ; root -> left -> left = newNode ( 3 ) ; root -> left -> right = newNode ( 4 ) ; root -> right -> left = newNode ( 4 ) ; root -> right -> right = newNode ( 3 ) ; if ( isSymmetric ( root ) ) cout << " Symmetric " ; else cout << " Not ▁ symmetric " ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minimumCost ( string s , int L , int U ) { int N = s . size ( ) ; string ans = " " ; int lowerFreq [ 26 ] = { 0 } ; int upperFreq [ 26 ] = { 0 } ; for ( int i = 0 ; i < N ; i ++ ) { if ( isupper ( s [ i ] ) ) upperFreq [ s [ i ] - ' A ' ] ++ ; else lowerFreq [ s [ i ] - ' a ' ] ++ ; } int result [ 26 ] = { 0 } ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( lowerFreq [ i ] != 0 upperFreq [ i ] != 0 ) { int costToUpper = U * lowerFreq [ i ] ; int costToLower = L * upperFreq [ i ] ; if ( costToLower < costToUpper ) { result [ i ] = 1 ; } } } for ( int i = 0 ; i < N ; i ++ ) { int index = 0 ; if ( islower ( s [ i ] ) ) index = s [ i ] - ' a ' ; else index = s [ i ] - ' A ' ; if ( result [ index ] == 1 ) { s [ i ] = tolower ( s [ i ] ) ; } else { s [ i ] = toupper ( s [ i ] ) ; } } cout << s ; } int main ( ) { string S = " aabbAA " ; int L = 1 , U = 1 ; minimumCost ( S , L , U ) ; return 0 ; }

Index/key variables: i, index
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool Check ( int A [ ] [ 2 ] , int B [ ] [ 2 ] , int M , int N , int X ) { for ( int i = 0 ; i < M ; i ++ ) { for ( int j = 0 ; j <= N - X ; j ++ ) { if ( A [ i ] [ j ] != B [ i ] [ j ] ) { int diff = B [ i ] [ j ] - A [ i ] [ j ] ; for ( int k = 0 ; k < X ; k ++ ) { A [ i ] [ j + k ] = A [ i ] [ j + k ] + diff ; } } } } for ( int i = 0 ; i <= M - X ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( A [ i ] [ j ] != B [ i ] [ j ] ) { int diff = B [ i ] [ j ] - A [ i ] [ j ] ; for ( int k = 0 ; k < X ; k ++ ) { A [ i + k ] [ j ] = A [ i + k ] [ j ] + diff ; } } } } for ( int i = 0 ; i < M ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( A [ i ] [ j ] != B [ i ] [ j ] ) { return 0 ; } } } return 1 ; } int main ( ) { int M = 2 , N = 2 , X = 2 ; int A [ 2 ] [ 2 ] = { { 0 , 0 } , { 0 , 0 } } ; int B [ 2 ] [ 2 ] = { { 1 , 2 } , { 0 , 1 } } ; if ( Check ( A , B , M , N , X ) ) { cout << " Yes " << endl ; } else { cout << " No " << endl ; } return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, k, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct HeapNode { int val ; int r ; int c ; } ; void swap ( HeapNode * x , HeapNode * y ) { HeapNode z = * x ; * x = * y ; * y = z ; } void minHeapify ( HeapNode harr [ ] , int i , int heap_size ) { int l = i * 2 + 1 ; int r = i * 2 + 2 ; if ( l < heap_size && r < heap_size && harr [ l ] . val < harr [ i ] . val && harr [ r ] . val < harr [ i ] . val ) { HeapNode temp = harr [ r ] ; harr [ r ] = harr [ i ] ; harr [ i ] = harr [ l ] ; harr [ l ] = temp ; minHeapify ( harr , l , heap_size ) ; minHeapify ( harr , r , heap_size ) ; } if ( l < heap_size && harr [ l ] . val < harr [ i ] . val ) { HeapNode temp = harr [ i ] ; harr [ i ] = harr [ l ] ; harr [ l ] = temp ; minHeapify ( harr , l , heap_size ) ; } } int kthSmallest ( int mat [ 4 ] [ 4 ] , int n , int k ) { if ( k < 0 && k >= n * n ) return INT_MAX ; HeapNode harr [ n ] ; for ( int i = 0 ; i < n ; i ++ ) harr [ i ] = { mat [ 0 ] [ i ] , 0 , i } ; HeapNode hr ; for ( int i = 0 ; i < k ; i ++ ) { hr = harr [ 0 ] ; int nextval = ( hr . r < ( n - 1 ) ) ? mat [ hr . r + 1 ] [ hr . c ] : INT_MAX ; harr [ 0 ] = { nextval , ( hr . r ) + 1 , hr . c } ; minHeapify ( harr , 0 , n ) ; } return hr . val ; } int main ( ) { int mat [ 4 ] [ 4 ] = { { 10 , 20 , 30 , 40 } , { 15 , 25 , 35 , 45 } , { 25 , 29 , 37 , 48 } , { 32 , 33 , 39 , 50 } , } ; cout << "7th ▁ smallest ▁ element ▁ is ▁ " << kthSmallest ( mat , 4 , 7 ) ; return 0 ; }

Index/key variables: i, l, n, r
Accumulator variables: i, stdc
Iterator variables: i
Class/struct names: HeapNode
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minOperations ( int arr [ ] , int N ) { map < int , int > mp ; for ( int i = 0 ; i < N ; i ++ ) { int res = arr [ i ] ; while ( res ) { mp [ res ] ++ ; res /= 2 ; } } int mx = 1 ; for ( auto it : mp ) { if ( it . second == N ) { mx = it . first ; } } int ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int res = arr [ i ] ; while ( res != mx ) { ans ++ ; res /= 2 ; } } cout << ans ; } int main ( ) { int arr [ ] = { 3 , 1 , 1 , 3 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; minOperations ( arr , N ) ; }

Index/key variables: i, res
Accumulator variables: ans, i, res, stdc
Iterator variables: i, it
C++ program:
#include <bits/stdc++.h>
using namespace std ; char Winner ( int N ) { bool player = true ; while ( N > 1 ) { int den = ( player ) ? 9 : 2 ; int X = N / den , Y = N % den ; N = ( Y ) ? X + 1 : X ; player = ! player ; } if ( player ) return ' B ' ; else return ' A ' ; } int main ( ) { int N = 10 ; cout << Winner ( N ) ; return 0 ; }

Accumulator variables: stdc
Boolean variables: player
C++ program:
#include <bits/stdc++.h>
using namespace std ; int largest ( int arr [ ] , int n ) { int i ; int max = arr [ 0 ] ; for ( i = 1 ; i < n ; i ++ ) if ( arr [ i ] > max ) max = arr [ i ] ; return max ; } int main ( ) { int arr [ ] = { 10 , 324 , 45 , 90 , 9808 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << " Largest ▁ in ▁ given ▁ array ▁ is ▁ " << largest ( 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 minimumsteps ( int N ) { int steps = 0 ; while ( steps * ( steps + 1 ) < 2 * N ) { steps ++ ; } if ( steps * ( steps + 1 ) / 2 == N + 1 ) { steps ++ ; } cout << steps ; } int main ( ) { int N = 18 ; minimumsteps ( N ) ; }

Accumulator variables: stdc, steps
C++ program:
#include <bits/stdc++.h>
using namespace std ; int largest ( int arr [ ] , int n ) { return * max_element ( arr , arr + n ) ; } int main ( ) { int arr [ ] = { 10 , 324 , 45 , 90 , 9808 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << largest ( arr , n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void find3largest ( int arr [ ] , int n ) { sort ( arr , arr + n ) ; int check = 0 , count = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( count < 4 ) { if ( check != arr [ n - i ] ) { cout << arr [ n - i ] << " ▁ " ; check = arr [ n - i ] ; count ++ ; } } else break ; } } int main ( ) { int arr [ ] = { 12 , 45 , 1 , -1 , 45 , 54 , 23 , 5 , 0 , -10 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; find3largest ( arr , n ) ; }

Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minCntCharDeletionsfrequency ( string & str , int N ) { unordered_map < char , int > mp ; priority_queue < int > pq ; int cntChar = 0 ; for ( int i = 0 ; i < N ; i ++ ) { mp [ str [ i ] ] ++ ; } for ( auto it : mp ) { pq . push ( it . second ) ; } while ( ! pq . empty ( ) ) { int frequent = pq . top ( ) ; pq . pop ( ) ; if ( pq . empty ( ) ) { return cntChar ; } if ( frequent == pq . top ( ) ) { if ( frequent > 1 ) { pq . push ( frequent - 1 ) ; } cntChar ++ ; } } return cntChar ; } int main ( ) { string str = " abbbcccd " ; int N = str . length ( ) ; cout << minCntCharDeletionsfrequency ( str , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cntChar, i, stdc
Iterator variables: i, it
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool issafe ( vector < vector < char > > & v , int i , int j , int n , int m , char ch ) { int rowN [ ] = { 1 , -1 , 0 , 0 } ; int colN [ ] = { 0 , 0 , 1 , -1 } ; for ( int k = 0 ; k < 4 ; k ++ ) { if ( i + rowN [ k ] >= 0 && i + rowN [ k ] < n && j + colN [ k ] >= 0 && j + colN [ k ] < m && v [ i + rowN [ k ] ] [ j + colN [ k ] ] == ch ) { return false ; } } return true ; } bool place ( vector < vector < char > > & v , int n , int m ) { int i , j ; for ( i = 0 ; i < n ; i ++ ) { for ( j = 0 ; j < m ; j ++ ) { if ( v [ i ] [ j ] == ' F ' ) { break ; } } if ( j != m ) { break ; } } if ( i == n && j == m ) { return true ; } if ( issafe ( v , i , j , n , m , '1' ) ) { v [ i ] [ j ] = '1' ; if ( place ( v , n , m ) ) { return true ; } v [ i ] [ j ] = ' F ' ; } if ( issafe ( v , i , j , n , m , '2' ) ) { v [ i ] [ j ] = '2' ; if ( place ( v , n , m ) ) { return true ; } v [ i ] [ j ] = ' F ' ; } return false ; } void printMatrix ( vector < vector < char > > arr , int n , int m ) { place ( arr , n , m ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { cout << arr [ i ] [ j ] ; } cout << endl ; } } int main ( ) { vector < vector < char > > arr = { { ' F ' , ' F ' , ' F ' , ' F ' } , { ' F ' , ' O ' , ' F ' , ' F ' } , { ' F ' , ' F ' , ' O ' , ' F ' } , { ' F ' , ' F ' , ' F ' , ' F ' } , } ; int n = 4 , m = 4 ; printMatrix ( arr , n , m ) ; return 0 ; }

Index/key variables: i, j, k
Accumulator variables: i, j, k, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; double findMean ( int a [ ] , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += a [ i ] ; return ( double ) sum / ( double ) n ; } double findMedian ( int a [ ] , int n ) { sort ( a , a + n ) ; if ( n % 2 != 0 ) return ( double ) a [ n / 2 ] ; return ( double ) ( a [ ( n - 1 ) / 2 ] + a [ n / 2 ] ) / 2.0 ; } int main ( ) { int a [ ] = { 1 , 3 , 4 , 2 , 7 , 5 , 8 , 6 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << " Mean ▁ = ▁ " << findMean ( a , n ) << endl ; cout << " Median ▁ = ▁ " << findMedian ( a , n ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; class Node { public : int key ; Node * left , * right ; Node ( int key_ ) { key = key_ ; left = NULL ; right = NULL ; } } ; int sumOfLeftLeaves ( Node * root ) { if ( root == NULL ) return 0 ; stack < Node * > stack_ ; stack_ . push ( root ) ; int sum = 0 ; while ( stack_ . size ( ) > 0 ) { Node * currentNode = stack_ . top ( ) ; stack_ . pop ( ) ; if ( currentNode -> left != NULL ) { stack_ . push ( currentNode -> left ) ; if ( currentNode -> left -> left == NULL && currentNode -> left -> right == NULL ) { sum = sum + currentNode -> left -> key ; } } if ( currentNode -> right != NULL ) stack_ . push ( currentNode -> right ) ; } return sum ; } int main ( ) { Node * root = new Node ( 20 ) ; root -> left = new Node ( 9 ) ; root -> right = new Node ( 49 ) ; root -> right -> left = new Node ( 23 ) ; root -> right -> right = new Node ( 52 ) ; root -> right -> right -> left = new Node ( 50 ) ; root -> left -> left = new Node ( 5 ) ; root -> left -> right = new Node ( 12 ) ; root -> left -> right -> right = new Node ( 12 ) ; cout << " Sum ▁ of ▁ left ▁ leaves ▁ is ▁ " << sumOfLeftLeaves ( root ) << endl ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findXandYwithminABSX_Y ( int N ) { if ( N % 2 == 1 ) { cout << ( N / 2 ) << " ▁ " << ( N / 2 + 1 ) ; } else { cout << ( N / 2 - 1 ) << " ▁ " << ( N / 2 + 1 ) ; } } int main ( ) { int N = 12 ; findXandYwithminABSX_Y ( N ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMax ( vector < int > & a , int dp [ ] [ 2 ] , int i , int flag ) { if ( i == ( int ) a . size ( ) ) { return 0 ; } if ( dp [ i ] [ flag ] != -1 ) { return dp [ i ] [ flag ] ; } int ans ; if ( flag == 0 ) { ans = max ( findMax ( a , dp , i + 1 , 0 ) , a [ i ] + findMax ( a , dp , i + 1 , 1 ) ) ; } else { ans = max ( findMax ( a , dp , i + 1 , 1 ) , -1 * a [ i ] + findMax ( a , dp , i + 1 , 0 ) ) ; } return dp [ i ] [ flag ] = ans ; } void findMaxSumUtil ( vector < int > & arr , int N ) { int dp [ N ] [ 2 ] ; memset ( dp , -1 , sizeof dp ) ; cout << findMax ( arr , dp , 0 , 0 ) ; } int main ( ) { vector < int > arr = { 1 , 2 , 3 , 4 , 1 , 2 } ; int N = arr . size ( ) ; findMaxSumUtil ( arr , N ) ; return 0 ; }

Index/key variables: N, flag, i
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findWinner ( string s ) { int vowels_count = 0 , consonants_count = 0 ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) { if ( s [ i ] == ' a ' s [ i ] == ' e ' s [ i ] == ' i ' s [ i ] == ' o ' s [ i ] == ' u ' ) { vowels_count ++ ; } else { consonants_count ++ ; } } if ( vowels_count == 0 ) { if ( consonants_count % 2 == 0 ) { cout << " Player ▁ B " ; } else { cout << " Player ▁ A " ; } } else if ( vowels_count == 1 && consonants_count % 2 != 0 ) { cout << " Player ▁ A " ; } else { cout << " D " ; } } int main ( ) { string s = " abcd " ; findWinner ( s ) ; return 0 ; }

Index/key variables: i
Accumulator variables: consonants_count, i, stdc, vowels_count
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < int > getSmallestArray ( int A , int B ) { vector < int > arr ( A ) ; for ( int i = 0 ; i < A ; i ++ ) arr [ i ] = i + 1 ; vector < int > ans ( A ) ; for ( int i = 0 ; i < B - 1 ; i ++ ) ans [ i ] = arr [ i ] ; ans [ B - 1 ] = arr [ A - 1 ] ; for ( int i = B ; i < A ; i ++ ) ans [ i ] = arr [ i - 1 ] ; return ans ; } int main ( ) { int A = 3 ; int B = 2 ; vector < int > ans = getSmallestArray ( A , B ) ; for ( auto i : ans ) cout << i << " ▁ " ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
#include <limits>
#include <vector>
using namespace std ; vector < int > prefix_sum ( vector < int > arr , int n ) { vector < int > pre_sum ; pre_sum . push_back ( arr [ 0 ] ) ; for ( int i = 1 ; i < n ; i ++ ) pre_sum . push_back ( pre_sum [ i - 1 ] + arr [ i ] ) ; return pre_sum ; } void maxMerge ( vector < int > & maxi , vector < int > cand ) { int k = maxi . size ( ) ; int j = 0 ; for ( int i = 0 ; i < k ; i ++ ) { if ( cand [ j ] > maxi [ i ] ) { maxi . insert ( maxi . begin ( ) + i , cand [ j ] ) ; maxi . erase ( maxi . begin ( ) + k ) ; j += 1 ; } } } void insertMini ( vector < int > & mini , int pre_sum ) { int k = mini . size ( ) ; for ( int i = 0 ; i < k ; i ++ ) { if ( pre_sum < mini [ i ] ) { mini . insert ( mini . begin ( ) + i , pre_sum ) ; mini . erase ( mini . begin ( ) + k ) ; break ; } } } void kMaxOvSubArray ( vector < int > arr , int k ) { int n = arr . size ( ) ; vector < int > pre_sum = prefix_sum ( arr , n ) ; vector < int > mini ( k , numeric_limits < int > :: max ( ) ) ; mini [ 0 ] = 0 ; vector < int > maxi ( k , numeric_limits < int > :: min ( ) ) ; vector < int > cand ( k ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < k ; j ++ ) { if ( pre_sum [ i ] < 0 && mini [ j ] == numeric_limits < int > :: max ( ) ) cand [ j ] = ( - pre_sum [ i ] ) - mini [ j ] ; else cand [ j ] = pre_sum [ i ] - mini [ j ] ; } maxMerge ( maxi , cand ) ; insertMini ( mini , pre_sum [ i ] ) ; } for ( int ele : maxi ) cout << ele << " ▁ " ; cout << endl ; } int main ( ) { vector < int > arr1 = { 4 , -8 , 9 , -4 , 1 , -8 , -1 , 6 } ; int k1 = 4 ; kMaxOvSubArray ( arr1 , k1 ) ; vector < int > arr2 = { -2 , -3 , 4 , -1 , -2 , 1 , 5 , -3 } ; int k2 = 3 ; kMaxOvSubArray ( arr2 , k2 ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: ele, i, j
C++ program:
#include <algorithm>
#include <iostream>
using namespace std ; void printSmall ( int arr [ ] , int n , int k ) { for ( int i = k ; i < n ; ++ i ) { int max_var = arr [ k - 1 ] ; int pos = k - 1 ; for ( int j = k - 2 ; j >= 0 ; j -- ) { if ( arr [ j ] > max_var ) { max_var = arr [ j ] ; pos = j ; } } if ( max_var > arr [ i ] ) { int j = pos ; while ( j < k - 1 ) { arr [ j ] = arr [ j + 1 ] ; j ++ ; } arr [ k - 1 ] = arr [ i ] ; } } for ( int i = 0 ; i < k ; i ++ ) cout << arr [ i ] << " ▁ " ; } int main ( ) { int arr [ ] = { 1 , 5 , 8 , 9 , 6 , 7 , 3 , 4 , 2 , 0 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int k = 5 ; printSmall ( arr , n , k ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void kSmallestPair ( int arr1 [ ] , int n1 , int arr2 [ ] , int n2 , int k ) { if ( k > n1 * n2 ) { cout << " k ▁ pairs ▁ don ' t ▁ exist " ; return ; } int index2 [ n1 ] ; memset ( index2 , 0 , sizeof ( index2 ) ) ; while ( k > 0 ) { int min_sum = INT_MAX ; int min_index = 0 ; for ( int i1 = 0 ; i1 < n1 ; i1 ++ ) { if ( index2 [ i1 ] < n2 && arr1 [ i1 ] + arr2 [ index2 [ i1 ] ] < min_sum ) { min_index = i1 ; min_sum = arr1 [ i1 ] + arr2 [ index2 [ i1 ] ] ; } } cout << " ( " << arr1 [ min_index ] << " , ▁ " << arr2 [ index2 [ min_index ] ] << " ) ▁ " ; index2 [ min_index ] ++ ; k -- ; } } int main ( ) { int arr1 [ ] = { 1 , 3 , 11 } ; int n1 = sizeof ( arr1 ) / sizeof ( arr1 [ 0 ] ) ; int arr2 [ ] = { 2 , 4 , 8 } ; int n2 = sizeof ( arr2 ) / sizeof ( arr2 [ 0 ] ) ; int k = 4 ; kSmallestPair ( arr1 , n1 , arr2 , n2 , k ) ; return 0 ; }

Index/key variables: i1, min_index, n1
Accumulator variables: i1, k, stdc
Iterator variables: i1
C++ program:
#include <bits/stdc++.h>
using namespace std ; void number_of_strings ( int N , int M ) { cout << min ( N , min ( M , ( N + M ) / 3 ) ) ; } int main ( ) { int N = 4 , M = 19 ; number_of_strings ( N , M ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool comp ( int a , int b ) { return a > b ; } int maxSubset ( int arr [ ] , int N , int X ) { sort ( arr , arr + N , comp ) ; int counter = 0 ; int sz = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sz ++ ; if ( arr [ i ] * sz >= X ) { counter ++ ; sz = 0 ; } } return counter ; } int main ( ) { int arr [ ] = { 7 , 11 , 2 , 9 , 5 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int X = 10 ; cout << maxSubset ( arr , N , X ) ; }

Index/key variables: i
Accumulator variables: counter, i, stdc, sz
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int min ( int a , int b ) { return ( a > b ) ? b : a ; } int maximumModuloValue ( int A [ ] , int n ) { int mn = INT_MAX ; for ( int i = 0 ; i < n ; i ++ ) { mn = min ( A [ i ] , mn ) ; } return mn ; } int main ( ) { int A [ ] = { 7 , 10 , 12 } ; int n = ( sizeof ( A ) / ( sizeof ( A [ 0 ] ) ) ) ; cout << maximumModuloValue ( A , n ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  3
#define M  4
struct query { int x1 , x2 , y1 , y2 , K ; } ; void updateQuery ( int from_x , int from_y , int to_x , int to_y , int k , int aux [ ] [ M ] ) { aux [ from_x ] [ from_y ] += k ; if ( to_x + 1 < N ) aux [ to_x + 1 ] [ from_y ] -= k ; if ( to_x + 1 < N && to_y + 1 < M ) aux [ to_x + 1 ] [ to_y + 1 ] += k ; if ( to_y + 1 < M ) aux [ from_x ] [ to_y + 1 ] -= k ; } void updateMatrix ( int mat [ ] [ M ] , int aux [ ] [ M ] ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 1 ; j < M ; j ++ ) { aux [ i ] [ j ] += aux [ i ] [ j - 1 ] ; } } for ( int i = 0 ; i < M ; i ++ ) { for ( int j = 1 ; j < N ; j ++ ) { aux [ j ] [ i ] += aux [ j - 1 ] [ i ] ; } } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { mat [ i ] [ j ] += aux [ i ] [ j ] ; } } } void printMatrix ( int mat [ ] [ M ] ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { cout << mat [ i ] [ j ] << " ▁ " ; } cout << " STRNEWLINE " ; } } void matrixQuery ( int mat [ ] [ M ] , int Q , query q [ ] ) { int aux [ N ] [ M ] = { } ; for ( int i = 0 ; i < Q ; i ++ ) { updateQuery ( q [ i ] . x1 , q [ i ] . x2 , q [ i ] . y1 , q [ i ] . y2 , q [ i ] . K , aux ) ; } updateMatrix ( mat , aux ) ; printMatrix ( mat ) ; } int main ( ) { int mat [ N ] [ M ] = { { 1 , 0 , 1 , 2 } , { 0 , 2 , 4 , 1 } , { 1 , 2 , 1 , 0 } } ; int Q = 1 ; query q [ ] = { { 0 , 0 , 1 , 1 , 2 } } ; matrixQuery ( mat , Q , q ) ; return 0 ; }

Index/key variables: M, N, from_x, from_y, i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
Class/struct names: query
C++ program:
#include <bits/stdc++.h>
using namespace std ; void print2largest ( int arr [ ] , int arr_size ) { int i , first , second ; if ( arr_size < 2 ) { printf ( " ▁ Invalid ▁ Input ▁ " ) ; return ; } sort ( arr , arr + arr_size ) ; for ( i = arr_size - 2 ; i >= 0 ; i -- ) { if ( arr [ i ] != arr [ arr_size - 1 ] ) { printf ( " The ▁ second ▁ largest ▁ element ▁ is ▁ % d STRNEWLINE " , arr [ i ] ) ; return ; } } printf ( " There ▁ is ▁ no ▁ second ▁ largest ▁ element STRNEWLINE " ) ; } int main ( ) { int arr [ ] = { 12 , 35 , 1 , 10 , 34 , 1 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; print2largest ( arr , n ) ; return 0 ; }

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