dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; set < int > node ; vector < int > Graph [ 10001 ] ; void dfs ( bool visit [ ] , int src ) { visit [ src ] = true ; node . insert ( src ) ; int len = Graph [ src ] . size ( ) ; for ( int i = 0 ; i < len ; i ++ ) if ( ! visit [ Graph [ src ] [ i ] ] ) dfs ( visit , Graph [ src ] [ i ] ) ; } void buildGraph ( int x [ ] , int y [ ] , int len ) { for ( int i = 0 ; i < len ; i ++ ) { int p = x [ i ] ; int q = y [ i ] ; Graph [ p ] . push_back ( q ) ; Graph [ q ] . push_back ( p ) ; } } int compute ( int n ) { bool visit [ n + 5 ] ; memset ( visit , false , sizeof ( visit ) ) ; int number_of_nodes = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! visit [ i ] ) { node . clear ( ) ; dfs ( visit , i ) ; int count = 0 ; for ( auto it = node . begin ( ) ; it != node . end ( ) ; ++ it ) count += Graph [ ( * it ) ] . size ( ) ; count /= 2 ; if ( count == node . size ( ) - 1 ) number_of_nodes ++ ; } } return number_of_nodes ; } int main ( ) { int n = 6 , m = 4 ; int x [ m + 5 ] = { 1 , 1 , 4 , 4 } ; int y [ m + 5 ] = { 2 , 3 , 5 , 6 } ; buildGraph ( x , y , n ) ; cout << compute ( n ) << " ▁ weakly ▁ connected ▁ nodes " ; return 0 ; }

Index/key variables: i, p, q, src
Accumulator variables: count, i, number_of_nodes, stdc
Iterator variables: i, it
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int V = 4 ; struct edge { int from , weight ; } ; vector < edge > edges [ V ] ; void addedge ( int u , int v , int w ) { edges [ v ] . push_back ( { u , w } ) ; } void shortestpath ( int dp [ ] [ V ] ) { for ( int i = 0 ; i <= V ; i ++ ) for ( int j = 0 ; j < V ; j ++ ) dp [ i ] [ j ] = -1 ; dp [ 0 ] [ 0 ] = 0 ; for ( int i = 1 ; i <= V ; i ++ ) { for ( int j = 0 ; j < V ; j ++ ) { for ( int k = 0 ; k < edges [ j ] . size ( ) ; k ++ ) { if ( dp [ i - 1 ] [ edges [ j ] [ k ] . from ] != -1 ) { int curr_wt = dp [ i - 1 ] [ edges [ j ] [ k ] . from ] + edges [ j ] [ k ] . weight ; if ( dp [ i ] [ j ] == -1 ) dp [ i ] [ j ] = curr_wt ; else dp [ i ] [ j ] = min ( dp [ i ] [ j ] , curr_wt ) ; } } } } } double minAvgWeight ( ) { int dp [ V + 1 ] [ V ] ; shortestpath ( dp ) ; double avg [ V ] ; for ( int i = 0 ; i < V ; i ++ ) avg [ i ] = -1 ; for ( int i = 0 ; i < V ; i ++ ) { if ( dp [ V ] [ i ] != -1 ) { for ( int j = 0 ; j < V ; j ++ ) if ( dp [ j ] [ i ] != -1 ) avg [ i ] = max ( avg [ i ] , ( ( double ) dp [ V ] [ i ] - dp [ j ] [ i ] ) / ( V - j ) ) ; } } double result = avg [ 0 ] ; for ( int i = 0 ; i < V ; i ++ ) if ( avg [ i ] != -1 && avg [ i ] < result ) result = avg [ i ] ; return result ; } int main ( ) { addedge ( 0 , 1 , 1 ) ; addedge ( 0 , 2 , 10 ) ; addedge ( 1 , 2 , 3 ) ; addedge ( 2 , 3 , 2 ) ; addedge ( 3 , 1 , 0 ) ; addedge ( 3 , 0 , 8 ) ; cout << minAvgWeight ( ) ; return 0 ; }

Index/key variables: V, i, j, k, v
Accumulator variables: i, j, k, stdc
Iterator variables: i, j, k
Class/struct names: edge
C++ program:
#include <bits/stdc++.h>
#define ll  long long
using namespace std ; ll findCount ( string s ) { ll freq [ 26 ] ; ll dp [ 26 ] [ 26 ] ; memset ( freq , 0 , sizeof freq ) ; memset ( dp , 0 , sizeof dp ) ; for ( int i = 0 ; i < s . size ( ) ; ++ i ) { for ( int j = 0 ; j < 26 ; j ++ ) { dp [ j ] [ s [ i ] - ' a ' ] += freq [ j ] ; } freq [ s [ i ] - ' a ' ] ++ ; } ll ans = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) ans = max ( freq [ i ] , ans ) ; for ( int i = 0 ; i < 26 ; i ++ ) { for ( int j = 0 ; j < 26 ; j ++ ) { ans = max ( dp [ i ] [ j ] , ans ) ; } } return ans ; } int main ( ) { string str = " acbab " ; cout << findCount ( str ) ; 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 ; void constructArray ( int N , int K , int X ) { vector < int > ans ( K , 0 ) ; ans [ 0 ] = X ; for ( int i = 0 ; i < N ; ++ i ) { cout << ans [ i % K ] << " ▁ " ; } cout << endl ; } int main ( ) { int N = 5 , K = 2 , X = 4 ; constructArray ( N , K , X ) ; return 0 ; }

Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void game ( int v [ ] , int n ) { unordered_map < int , int > m ; for ( int i = 0 ; i < n ; i ++ ) { if ( m . find ( v [ i ] ) == m . end ( ) ) m [ v [ i ] ] = 1 ; else m [ v [ i ] ] ++ ; } int count = 0 ; int check = 0 ; for ( auto i : m ) { if ( i . second > 1 ) { if ( i . second >= 4 && i . second % 2 == 0 ) check ++ ; count ++ ; } } if ( check % 2 != 0 ) bool flag = false ; if ( check % 2 != 0 ) cout << " Yes " << endl ; else if ( n % 2 == 0 && count % 2 == 0 ) cout << " No " << endl ; else cout << " Yes " << endl ; } int main ( ) { int arr [ ] = { 3 , 2 , 2 , 3 , 3 , 5 } ; int size = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; game ( arr , size ) ; return 0 ; }

Index/key variables: i
Accumulator variables: check, count, i, stdc
Iterator variables: i
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define mp  make_pair
#define pb  push_back
#define mod  1000000007
int solve ( int A [ ] , int n ) { int i , cnt = 0 , j ; int parent [ n ] ; int vis [ n ] ; memset ( parent , -1 , sizeof ( parent ) ) ; memset ( vis , 0 , sizeof ( vis ) ) ; for ( i = 0 ; i < n ; i ++ ) { j = i ; if ( parent [ j ] == -1 ) { while ( parent [ j ] == -1 ) { parent [ j ] = i ; j = __gcd ( j , A [ j ] ) % n ; } if ( parent [ j ] == i ) { while ( ! vis [ j ] ) { vis [ j ] = 1 ; cnt ++ ; j = __gcd ( j , A [ j ] ) % n ; } } } } return cnt ; } int main ( ) { int A [ ] = { 1 , 1 , 6 , 2 } ; int n = sizeof ( A ) / sizeof ( A [ 0 ] ) ; cout << solve ( A , n ) ; return 0 ; }

Index/key variables: j, n
Accumulator variables: cnt, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  10000
vector < int > adj [ N ] ; int lvl [ N ] , dist1 [ N ] , dist2 [ N ] ; void AddEdge ( int u , int v ) { adj [ u ] . push_back ( v ) ; adj [ v ] . push_back ( u ) ; } int end1 , end2 , maxi ; void findFirstEnd ( int u , int p ) { lvl [ u ] = 1 + lvl [ p ] ; if ( lvl [ u ] > maxi ) { maxi = lvl [ u ] ; end1 = u ; } for ( int i = 0 ; i < adj [ u ] . size ( ) ; i ++ ) { if ( adj [ u ] [ i ] != p ) { findFirstEnd ( adj [ u ] [ i ] , u ) ; } } } void clear ( int n ) { for ( int i = 0 ; i <= n ; i ++ ) { lvl [ i ] = 0 ; } maxi = 0 ; dist1 [ 0 ] = dist2 [ 0 ] = -1 ; } void findSecondEnd ( int u , int p ) { lvl [ u ] = 1 + lvl [ p ] ; if ( lvl [ u ] > maxi ) { maxi = lvl [ u ] ; end2 = u ; } for ( int i = 0 ; i < adj [ u ] . size ( ) ; i ++ ) { if ( adj [ u ] [ i ] != p ) { findSecondEnd ( adj [ u ] [ i ] , u ) ; } } } void findDistancefromFirst ( int u , int p ) { dist1 [ u ] = 1 + dist1 [ p ] ; for ( int i = 0 ; i < adj [ u ] . size ( ) ; i ++ ) { if ( adj [ u ] [ i ] != p ) { findDistancefromFirst ( adj [ u ] [ i ] , u ) ; } } } void findDistancefromSecond ( int u , int p ) { dist2 [ u ] = 1 + dist2 [ p ] ; for ( int i = 0 ; i < adj [ u ] . size ( ) ; i ++ ) { if ( adj [ u ] [ i ] != p ) { findDistancefromSecond ( adj [ u ] [ i ] , u ) ; } } } void findNodes ( ) { int n = 5 ; AddEdge ( 1 , 2 ) ; AddEdge ( 1 , 3 ) ; AddEdge ( 3 , 4 ) ; AddEdge ( 3 , 5 ) ; findFirstEnd ( 1 , 0 ) ; clear ( n ) ; findSecondEnd ( end1 , 0 ) ; findDistancefromFirst ( end1 , 0 ) ; findDistancefromSecond ( end2 , 0 ) ; for ( int i = 1 ; i <= n ; i ++ ) { int x = dist1 [ i ] ; int y = dist2 [ i ] ; if ( x >= y ) { cout << end1 << ' ▁ ' ; } else { cout << end2 << ' ▁ ' ; } } } int main ( ) { findNodes ( ) ; return 0 ; }

Index/key variables: N, i, p, u, v
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; Node * next ; } ; void push ( Node * * head_ref , int new_data ) { Node * new_node = ( Node * ) malloc ( sizeof ( struct Node ) ) ; new_node -> data = new_data ; new_node -> next = ( * head_ref ) ; ( * head_ref ) = new_node ; } int digitSum ( int num ) { int sum = 0 ; while ( num ) { sum += ( num % 10 ) ; num /= 10 ; } return sum ; } void sumAndProduct ( Node * head_ref ) { int prod = 1 ; int sum = 0 ; Node * ptr = head_ref ; while ( ptr != NULL ) { if ( ! ( digitSum ( ptr -> data ) & 1 ) ) { prod *= ptr -> data ; sum += ptr -> data ; } ptr = ptr -> next ; } cout << " Sum ▁ = ▁ " << sum << endl ; cout << " Product ▁ = ▁ " << prod ; } int main ( ) { Node * head = NULL ; push ( & head , 13 ) ; push ( & head , 6 ) ; push ( & head , 8 ) ; push ( & head , 16 ) ; push ( & head , 15 ) ; sumAndProduct ( head ) ; return 0 ; }

Accumulator variables: num, prod, stdc, sum
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; string ShortestPalindrome ( string s ) { int n = s . length ( ) ; vector < string > v ; for ( int i = 0 ; i < n ; i ++ ) { int l = i ; int r = i ; string ans1 = " " ; string ans2 = " " ; while ( l >= 0 && r < n && s [ l ] == s [ r ] ) { ans1 += s [ l ] ; l -- ; r ++ ; } l = i - 1 ; r = i ; while ( l >= 0 && r < n && s [ l ] == s [ r ] ) { ans2 += s [ l ] ; l -- ; r ++ ; } v . push_back ( ans1 ) ; v . push_back ( ans2 ) ; } string ans = v [ 0 ] ; for ( int i = 0 ; i < v . size ( ) ; i ++ ) { if ( v [ i ] != " " ) { ans = min ( ans , v [ i ] ) ; } } return ans ; } int main ( ) { string s = " geeksforgeeks " ; cout << ShortestPalindrome ( s ) ; return 0 ; }

Index/key variables: i, l, r
Accumulator variables: ans1, ans2, i, l, r, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getMinimumOps ( vector < int > ar ) { int n = ar . size ( ) ; int small = * min_element ( ar . begin ( ) , ar . end ( ) ) ; int large = * max_element ( ar . begin ( ) , ar . end ( ) ) ; int dp [ n ] [ large + 1 ] ; for ( int j = small ; j <= large ; j ++ ) { dp [ 0 ] [ j ] = abs ( ar [ 0 ] - j ) ; } for ( int i = 1 ; i < n ; i ++ ) { int minimum = INT_MAX ; for ( int j = small ; j <= large ; j ++ ) { minimum = min ( minimum , dp [ i - 1 ] [ j ] ) ; dp [ i ] [ j ] = minimum + abs ( ar [ i ] - j ) ; } } int ans = INT_MAX ; for ( int j = small ; j <= large ; j ++ ) { ans = min ( ans , dp [ n - 1 ] [ j ] ) ; } return ans ; } int main ( ) { vector < int > ar = { 1 , 2 , 1 , 4 , 3 } ; cout << getMinimumOps ( ar ) ; 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 getMinimumOps ( vector < int > ar , int k ) { int n = ar . size ( ) ; int dp [ n ] [ k + 1 ] ; dp [ 0 ] [ 1 ] = 0 ; for ( int i = 1 ; i < n ; i ++ ) { int maxGroups = min ( k , i + 1 ) ; for ( int j = 1 ; j <= maxGroups ; j ++ ) { dp [ i ] [ j ] = INT_MAX ; if ( j == 1 ) { unordered_map < int , int > freq ; int freqOfMode = 0 ; for ( int it = 0 ; it <= i ; it ++ ) { freq [ ar [ it ] ] ++ ; int newElementFreq = freq [ ar [ it ] ] ; if ( newElementFreq > freqOfMode ) freqOfMode = newElementFreq ; } dp [ i ] [ 1 ] = ( i + 1 ) - freqOfMode ; } else { unordered_map < int , int > freq ; int freqOfMode = 0 ; for ( int it = i ; it >= j - 1 ; it -- ) { freq [ ar [ it ] ] ++ ; int newElementFreq = freq [ ar [ it ] ] ; if ( newElementFreq > freqOfMode ) freqOfMode = newElementFreq ; int elementsToChange = i - it + 1 ; elementsToChange -= freqOfMode ; dp [ i ] [ j ] = min ( dp [ it - 1 ] [ j - 1 ] + elementsToChange , dp [ i ] [ j ] ) ; } } } } return dp [ n - 1 ] [ k ] ; } int main ( ) { int k = 3 ; vector < int > ar = { 3 , 1 , 3 , 3 , 2 , 1 , 8 , 5 } ; cout << getMinimumOps ( ar , k ) ; return 0 ; }

Index/key variables: i, it, j, k, n
Accumulator variables: elementsToChange, i, it, j, stdc
Iterator variables: i, it, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int lcm ( int x , int y ) { int temp = ( x * y ) / __gcd ( x , y ) ; return temp ; } void findNumbers ( int a [ ] , int n , int b [ ] , int m ) { int lcmA = 1 , gcdB = 0 ; for ( int i = 0 ; i < n ; i ++ ) lcmA = lcm ( lcmA , a [ i ] ) ; for ( int i = 0 ; i < m ; i ++ ) gcdB = __gcd ( gcdB , b [ i ] ) ; if ( gcdB % lcmA != 0 ) { cout << " - 1" ; return ; } int num = lcmA ; while ( num <= gcdB ) { if ( gcdB % num == 0 ) cout << num << " ▁ " ; num += lcmA ; } } int main ( ) { int a [ ] = { 1 , 2 , 2 , 4 } ; int b [ ] = { 16 , 32 , 64 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; int m = sizeof ( b ) / sizeof ( b [ 0 ] ) ; findNumbers ( a , n , b , m ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, num, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int binomialCoeff ( int n , int k ) { int res = 1 ; if ( k > n - k ) k = n - k ; for ( int i = 0 ; i < k ; ++ i ) { res *= ( n - i ) ; res /= ( i + 1 ) ; } return res ; } int power ( int x , unsigned int y ) { int res = 1 ; while ( y > 0 ) { if ( y & 1 ) res = res * x ; y = y >> 1 ; x = x * x ; } return res ; } void FindProbability ( int n ) { int up = binomialCoeff ( 2 * n , n ) ; int down = power ( 2 , 2 * n ) ; int g = __gcd ( up , down ) ; up /= g , down /= g ; cout << up << " / " << down << endl ; } int main ( ) { int N = 8 ; FindProbability ( N ) ; return 0 ; }

Accumulator variables: down, res, stdc, up
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int main ( ) { int N = 4 , i , j , min ; cout << " Value ▁ of ▁ N : ▁ " << N << endl ; for ( i = 1 ; i <= N ; i ++ ) { for ( j = 1 ; j <= N ; j ++ ) { min = i < j ? i : j ; cout << N - min + 1 ; } for ( j = N - 1 ; j >= 1 ; j -- ) { min = i < j ? i : j ; cout << N - min + 1 ; } cout << endl ; } for ( i = N - 1 ; i >= 1 ; i -- ) { for ( j = 1 ; j <= N ; j ++ ) { min = i < j ? i : j ; cout << N - min + 1 ; } for ( j = N - 1 ; j >= 1 ; j -- ) { min = i < j ? i : j ; cout << N - min + 1 ; } cout << endl ; } return 0 ; }

Accumulator variables: i, j
Iterator variables: i, j
C++ program:
#include <iostream>
#include <math.h>
using namespace std ; bool checkPerfectSquare ( double n ) { double d = sqrt ( n ) ; if ( d * d == n ) return true ; return false ; } int largestPerfectSquareNumber ( int a [ ] , double n ) { int maxi = -1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( checkPerfectSquare ( a [ i ] ) ) maxi = max ( a [ i ] , maxi ) ; } return maxi ; } int main ( ) { int a [ ] = { 16 , 20 , 25 , 2 , 3 , 10 } ; double n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << largestPerfectSquareNumber ( a , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void convert ( int n , int a [ ] ) { int z = a [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( a [ i ] > z ) z = a [ i ] ; } z = z + 1 ; int ff [ z ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) { ff [ a [ i ] ] += 1 ; } int cc = 0 ; for ( int i = 0 ; i < z ; i ++ ) { cc += int ( ff [ i ] / 4 ) ; ff [ i ] = ff [ i ] % 4 ; } int vv = 0 ; for ( int i = 0 ; i < z ; i ++ ) { if ( ff [ i ] >= 2 ) vv += 1 ; } cc += int ( vv / 2 ) ; cout << ( cc ) ; } int main ( ) { int n = 4 ; int a [ ] = { 1 , 2 , 1 , 2 } ; convert ( n , a ) ; }

Index/key variables: i, z
Accumulator variables: cc, i, stdc, vv
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int find_LCM ( int x , int y ) { return ( x * y ) / __gcd ( x , y ) ; } int CountPairs ( int n , int m , int A , int B ) { int cnt = 0 ; int lcm = find_LCM ( A , B ) ; for ( int i = 1 ; i <= n ; i ++ ) cnt += ( m + ( i % lcm ) ) / lcm ; return cnt ; } int main ( ) { int n = 60 , m = 90 , A = 5 , B = 10 ; cout << CountPairs ( n , m , A , B ) ; return 0 ; }

Accumulator variables: cnt, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sortArr ( int arr [ ] , int n , int min , int max ) { int m = max - min + 1 ; vector < int > c ( m , 0 ) ; for ( int i = 0 ; i < n ; i ++ ) c [ arr [ i ] - min ] ++ ; for ( int i = 0 ; i < m ; i ++ ) for ( int j = 0 ; j < c [ i ] ; j ++ ) cout << ( i + min ) << " ▁ " ; } int main ( ) { int arr [ ] = { 10 , 10 , 1 , 4 , 4 , 100 , 0 } ; int min = 0 , max = 100 ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; sortArr ( arr , n , min , max ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPossible ( vector < int > nums , int K ) { int N = nums . size ( ) ; if ( N % K != 0 K > N ) { return false ; } map < int , set < int > > idx ; for ( int i = 0 ; i < nums . size ( ) ; i ++ ) { idx [ nums [ i ] ] . insert ( i ) ; } int visited [ N ] = { 0 } ; int total_visited = 0 ; for ( int i = 0 ; i < nums . size ( ) ; i ++ ) { if ( visited [ i ] ) { continue ; } int num = nums [ i ] ; int last_index = i ; visited [ i ] = 1 ; total_visited ++ ; for ( int j = num + 1 ; j < num + K ; j ++ ) { if ( idx [ j ] . size ( ) == 0 ) { return false ; } auto it = idx [ j ] . upper_bound ( last_index ) ; if ( it == idx [ j ] . end ( ) * it <= last_index ) { return false ; } last_index = * it ; visited [ last_index ] = 1 ; total_visited ++ ; idx [ j ] . erase ( it ) ; } } return total_visited == N ; } int main ( ) { vector < int > arr = { 4 , 3 , 1 , 2 } ; int K = 2 ; cout << ( isPossible ( arr , K ) ? " Yes " : " No " ) ; return 0 ; }

Index/key variables: N, i, j, last_index
Accumulator variables: i, j, stdc, total_visited
Iterator variables: i, j
C++ program:
#include <iostream>
using namespace std ; bool isPossible ( double D , int arr [ ] , int N , int K ) { int used = 0 ; for ( int i = 0 ; i < N - 1 ; ++ i ) { used += ( int ) ( ( arr [ i + 1 ] - arr [ i ] ) / D ) ; } return used <= K ; } double minMaxDist ( int stations [ ] , int N , int K ) { double low = 0 , high = 1e8 ; while ( high - low > 1e-6 ) { double mid = ( low + high ) / 2.0 ; if ( isPossible ( mid , stations , N , K ) ) { high = mid ; } else { low = mid ; } } return low ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 } ; int K = 9 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << minMaxDist ( arr , N , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: used
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findMissingBinaryString ( vector < string > & nums , int N ) { unordered_set < string > s ; int counter = 0 ; for ( string str : nums ) { s . insert ( str ) ; } int total = ( int ) pow ( 2 , N ) ; string ans = " " ; for ( int i = 0 ; i < total ; i ++ ) { string num = " " ; for ( int j = N - 1 ; j >= 0 ; j -- ) { if ( i & ( 1 << j ) ) { num += '1' ; } else { num += '0' ; } } if ( s . find ( num ) != s . end ( ) ) { continue ; counter ++ ; } else { cout << num << " , ▁ " ; } } if ( counter == total ) { cout << " - 1" ; } } int main ( ) { int N = 3 ; vector < string > arr = { "101" , "111" , "001" , "011" , "100" , "110" } ; findMissingBinaryString ( arr , N ) ; return 0 ; }

Accumulator variables: counter, i, j, num, stdc
Iterator variables: i, j, str
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int n = 6 ; const int m = 6 ; const int dx [ ] = { 0 , 1 , -1 , 0 } ; const int dy [ ] = { 1 , 0 , 0 , -1 } ; int visited [ n ] [ m ] ; int COUNT ; bool is_valid ( int x , int y , int matrix [ n ] [ m ] ) { if ( x < n && y < m && x >= 0 && y >= 0 ) { if ( visited [ x ] [ y ] == false && matrix [ x ] [ y ] == 1 ) return true ; else return false ; } else return false ; } map < int , int > mp ; void findComponentSize ( int matrix [ n ] [ m ] ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( ! visited [ i ] [ j ] && matrix [ i ] [ j ] == 1 ) { COUNT = 0 ; queue < pair < int , int > > q ; q . push ( { i , j } ) ; visited [ i ] [ j ] = true ; while ( ! q . empty ( ) ) { pair < int , int > p = q . front ( ) ; q . pop ( ) ; int x = p . first , y = p . second ; COUNT ++ ; for ( int i = 0 ; i < 4 ; i ++ ) { int newX = x + dx [ i ] ; int newY = y + dy [ i ] ; if ( is_valid ( newX , newY , matrix ) ) { q . push ( { newX , newY } ) ; visited [ newX ] [ newY ] = true ; } } } mp [ COUNT ] ++ ; } } } } int main ( ) { int matrix [ n ] [ m ] = { { 1 , 1 , 1 , 1 , 1 , 1 } , { 1 , 1 , 0 , 0 , 0 , 0 } , { 0 , 0 , 0 , 1 , 1 , 1 } , { 0 , 0 , 0 , 1 , 1 , 1 } , { 0 , 0 , 1 , 0 , 0 , 0 } , { 1 , 0 , 0 , 0 , 0 , 0 } } ; int queries [ ] = { 6 , 1 , 8 , 2 } ; int N = sizeof ( queries ) / sizeof ( queries [ 0 ] ) ; memset ( visited , false , sizeof visited ) ; findComponentSize ( matrix ) ; for ( int i = 0 ; i < N ; i ++ ) cout << mp [ queries [ i ] ] << " ▁ " ; return 0 ; }

Index/key variables: COUNT, i, j, m, n, newX, newY, x, y
Accumulator variables: COUNT, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool check ( int a [ ] , int b [ ] , int k , int n , int x ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum = sum + pow ( max ( a [ i ] - x , 0 ) , b [ i ] ) ; } if ( sum <= k ) return true ; else return false ; } int findMin ( int a [ ] , int b [ ] , int n , int k ) { int l = 0 , u = * max_element ( a , a + n ) ; while ( l < u ) { int m = ( l + u ) / 2 ; if ( check ( a , b , k , n , m ) ) { u = m ; } else { l = m + 1 ; } } return l ; } int main ( ) { int arr [ ] = { 2 , 1 , 4 , 3 , 5 } ; int brr [ ] = { 4 , 3 , 2 , 3 , 1 } ; int K = 12 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << findMin ( arr , brr , N , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getPairsCount ( int arr [ ] , int n ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = arr [ i ] - ( i % arr [ i ] ) ; j < n ; j += arr [ i ] ) { if ( i < j && ( arr [ i ] * arr [ j ] ) == abs ( i - j ) ) { count ++ ; } } } return count ; } int main ( ) { int arr [ ] = { 1 , 1 , 2 , 4 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << getPairsCount ( arr , N ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: count, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printOccurences ( vector < string > arr , int N ) { map < char , vector < pair < int , int > > > mp ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < arr [ i ] . length ( ) ; j ++ ) { mp [ arr [ i ] [ j ] ] . push_back ( make_pair ( i + 1 , j + 1 ) ) ; } } for ( auto it : mp ) { cout << " Occurences ▁ of : ▁ " << it . first << " ▁ = ▁ " ; for ( int j = 0 ; j < ( it . second ) . size ( ) ; j ++ ) { cout << " [ " << ( it . second ) [ j ] . first << " ▁ " << ( it . second ) [ j ] . second << " ] ▁ " ; } cout << endl ; } } int main ( ) { vector < string > arr = { " geeksforgeeks " , " gfg " } ; int N = arr . size ( ) ; printOccurences ( arr , N ) ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, it, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int mostFrequent ( int arr [ ] , int N ) { int ans [ N ] = { 0 } ; for ( int i = 0 ; i < N ; i ++ ) { int count [ N ] ; memset ( count , 0 , sizeof ( count ) ) ; int best = 0 ; for ( int j = i ; j < N ; j ++ ) { count [ arr [ j ] - 1 ] ++ ; if ( count [ arr [ j ] - 1 ] > count [ best - 1 ] || ( count [ arr [ j ] - 1 ] == count [ best - 1 ] && arr [ j ] < best ) ) { best = arr [ j ] ; } ans [ best - 1 ] ++ ; } } for ( int i = 0 ; i < N ; i ++ ) cout << ans [ i ] << " ▁ " ; } int main ( ) { int arr [ ] = { 2 , 1 , 2 , 3 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; mostFrequent ( arr , N ) ; return 0 ; }

Index/key variables: N, i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countElement ( int arr [ ] , int N ) { int count = 0 ; unordered_map < int , int > m ; for ( int i = 0 ; i < N ; i ++ ) { m [ arr [ i ] ] ++ ; } for ( int i = 0 ; i < N ; i ++ ) { int lg = log2 ( arr [ i ] ) ; int p = pow ( 2 , lg ) ; if ( m [ p ] ) { count ++ ; } } return count ; } int main ( ) { int arr [ ] = { 3 , 4 , 6 , 9 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countElement ( arr , N ) ; return 0 ; }

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