dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; void min_visible_bottles ( int * arr , int n ) { map < int , int > m ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { m [ arr [ i ] ] ++ ; ans = max ( ans , m [ arr [ i ] ] ) ; } cout << " Minimum ▁ number ▁ of ▁ " << " Visible ▁ Bottles ▁ are : ▁ " << ans << endl ; } int main ( ) { int n = 8 ; int arr [ ] = { 1 , 1 , 2 , 3 , 4 , 5 , 5 , 4 } ; min_visible_bottles ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; struct Node * next ; } ; struct Node * create ( struct Node * head , int x ) { struct Node * temp , * ptr = head ; temp = new Node ( ) ; temp -> data = x ; temp -> next = NULL ; if ( head == NULL ) head = temp ; else { while ( ptr -> next != NULL ) { ptr = ptr -> next ; } ptr -> next = temp ; } return head ; } Node * removeNthFromEnd ( Node * head , int B ) { int len = 0 ; Node * tmp = head ; while ( tmp != NULL ) { len ++ ; tmp = tmp -> next ; } if ( B > len ) { cout << " Length ▁ of ▁ the ▁ linked ▁ list ▁ is ▁ " << len ; cout << " ▁ we ▁ can ' t ▁ remove ▁ " << B << " th ▁ node ▁ from ▁ the " ; cout << " ▁ linked ▁ list STRNEWLINE " ; return head ; } else if ( B == len ) { return head -> next ; } else { int diff = len - B ; Node * prev = NULL ; Node * curr = head ; for ( int i = 0 ; i < diff ; i ++ ) { prev = curr ; curr = curr -> next ; } prev -> next = curr -> next ; return head ; } } void display ( struct Node * head ) { struct Node * temp = head ; while ( temp != NULL ) { cout << temp -> data << " ▁ " ; temp = temp -> next ; } cout << endl ; } int main ( ) { struct Node * head = NULL ; head = create ( head , 1 ) ; head = create ( head , 2 ) ; head = create ( head , 3 ) ; head = create ( head , 4 ) ; head = create ( head , 5 ) ; int n = 2 ; cout << " Linked ▁ list ▁ before ▁ modification : ▁ STRNEWLINE " ; display ( head ) ; head = removeNthFromEnd ( head , 2 ) ; cout << " Linked ▁ list ▁ after ▁ modification : ▁ STRNEWLINE " ; display ( head ) ; return 0 ; }

Accumulator variables: i, len, stdc
Iterator variables: i
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; void solveEven ( int n , int * arr , int * b ) { int left = n - 1 ; for ( int i = 0 ; i < ( n / 2 ) ; ++ i ) { b [ i ] = arr [ left ] ; left = left - 2 ; if ( left < 0 ) break ; } int right = 0 ; for ( int i = n / 2 ; i <= n - 1 ; ++ i ) { b [ i ] = arr [ right ] ; right = right + 2 ; if ( right > n - 2 ) break ; } } void solveOdd ( int n , int * arr , int * b ) { int left = n - 1 ; for ( int i = 0 ; i < ( n / 2 ) + 1 ; ++ i ) { b [ i ] = arr [ left ] ; left = left - 2 ; if ( left < 0 ) break ; } int right = 1 ; for ( int i = ( n / 2 ) + 1 ; i <= n - 1 ; ++ i ) { b [ i ] = arr [ right ] ; right = right + 2 ; if ( right > n - 2 ) break ; } } void solve ( int n , int * arr ) { int b [ n ] ; if ( n % 2 == 0 ) solveEven ( n , arr , b ) ; else solveOdd ( n , arr , b ) ; for ( int i = 0 ; i <= n - 1 ; ++ i ) { cout << b [ i ] << " ▁ " ; } } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; solve ( n , arr ) ; return 0 ; }

Index/key variables: i, left, n, right
Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void sum_of_elements ( int arr [ ] , int n ) { int sumfirst = 0 , sumsecond = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i < n / 2 ) sumfirst += arr [ i ] ; else sumsecond += arr [ i ] ; } cout << " Sum ▁ of ▁ first ▁ half ▁ elements ▁ is ▁ " << sumfirst << endl ; cout << " Sum ▁ of ▁ second ▁ half ▁ elements ▁ is ▁ " << sumsecond << endl ; } int main ( ) { int arr [ ] = { 20 , 30 , 60 , 10 , 25 , 15 , 40 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; sum_of_elements ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sumfirst, sumsecond
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void lowerWythoff ( int n ) { double phi = ( 1 + sqrt ( 5 ) ) / 2.0 ; for ( int i = 1 ; i <= n ; i ++ ) { double ans = floor ( i * phi ) ; cout << ans ; if ( i != n ) cout << " , ▁ " ; } } int main ( ) { int n = 5 ; lowerWythoff ( n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; struct Node { int data ; Node * next ; } ; void insert ( Node * * root , int item ) { Node * ptr , * temp ; temp = new Node ; temp -> data = item ; temp -> next = NULL ; if ( * root == NULL ) * root = temp ; else { ptr = * root ; while ( ptr -> next != NULL ) ptr = ptr -> next ; ptr -> next = temp ; } } Node * newList ( Node * root1 , Node * root2 ) { Node * ptr1 = root1 , * ptr2 = root2 , * ptr ; Node * root = NULL , * temp ; while ( ptr1 != NULL ) { temp = new Node ; temp -> next = NULL ; if ( ptr1 -> data < ptr2 -> data ) temp -> data = ptr2 -> data ; else temp -> data = ptr1 -> data ; if ( root == NULL ) root = temp ; else { ptr = root ; while ( ptr -> next != NULL ) ptr = ptr -> next ; ptr -> next = temp ; } ptr1 = ptr1 -> next ; ptr2 = ptr2 -> next ; } return root ; } void display ( Node * root ) { while ( root != NULL ) { cout << root -> data << " - > " ; root = root -> next ; } cout << endl ; } int main ( ) { Node * root1 = NULL , * root2 = NULL , * root = NULL ; insert ( & root1 , 5 ) ; insert ( & root1 , 2 ) ; insert ( & root1 , 3 ) ; insert ( & root1 , 8 ) ; cout << " First ▁ List : ▁ " ; display ( root1 ) ; insert ( & root2 , 1 ) ; insert ( & root2 , 7 ) ; insert ( & root2 , 4 ) ; insert ( & root2 , 5 ) ; cout << " Second ▁ List : ▁ " ; display ( root2 ) ; root = newList ( root1 , root2 ) ; cout << " New ▁ List : TABSYMBOL " ; display ( root ) ; return 0 ; }

Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countQuadruplets ( int l , int r , int k ) { int count = 0 ; for ( int u = l ; u <= r ; u ++ ) { for ( int v = l ; v <= r ; v ++ ) { for ( int w = l ; w <= r ; w ++ ) { for ( int x = l ; x <= r ; x ++ ) { if ( __gcd ( __gcd ( u , v ) , __gcd ( w , x ) ) == k ) count ++ ; } } } } return count ; } int main ( ) { int l = 1 , r = 10 , k = 2 ; cout << countQuadruplets ( l , r , k ) ; return 0 ; }

Accumulator variables: count, stdc, u, v, w, x
Iterator variables: u, v, w, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ll  long long int
int findIndex ( int a [ ] , int n ) { int res ; ll min_diff = INT_MAX ; ll prod [ n ] ; prod [ 0 ] = a [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) prod [ i ] = prod [ i - 1 ] * a [ i ] ; for ( int i = 0 ; i < n - 1 ; i ++ ) { ll curr_diff = abs ( ( prod [ n - 1 ] / prod [ i ] ) - prod [ i ] ) ; if ( curr_diff < min_diff ) { min_diff = curr_diff ; res = i ; } } return res ; } int main ( ) { int arr [ ] = { 3 , 2 , 5 , 7 , 2 , 9 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << findIndex ( arr , N ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printNumbers ( int a [ ] , int n , int x ) { bool flag = false ; for ( int i = 0 ; i < n ; i ++ ) { int num = a [ i ] ; int g = __gcd ( num , x ) ; while ( g != 1 ) { num /= g ; g = __gcd ( num , x ) ; } if ( num == 1 ) { flag = true ; cout << a [ i ] << " ▁ " ; } } if ( ! flag ) cout << " There ▁ are ▁ no ▁ such ▁ numbers " ; } int main ( ) { int x = 60 ; int a [ ] = { 2 , 5 , 10 , 7 , 17 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; printNumbers ( a , n , x ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, num, stdc
Iterator variables: i
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; void print ( int rStation [ ] , int n ) { for ( int i = 1 ; i <= n ; i ++ ) cout << rStation [ i ] << " ▁ " ; cout << endl ; } void radiated_Station ( int station [ ] , int n ) { int rStation [ n + 1 ] ; memset ( rStation , 0 , sizeof ( rStation ) ) ; for ( int i = 1 ; i <= n ; i ++ ) { int li = i - 1 , ri = i + 1 ; int lRad = station [ i ] - 1 , rRad = station [ i ] - 1 ; rStation [ i ] += station [ i ] ; while ( li >= 1 && lRad >= 1 ) { rStation [ li -- ] += lRad -- ; } while ( ri <= n && rRad >= 1 ) { rStation [ ri ++ ] += rRad -- ; } } print ( rStation , n ) ; } int main ( ) { int station [ ] = { 0 , 7 , 9 , 12 , 2 , 5 } ; int n = ( sizeof ( station ) / sizeof ( station [ 0 ] ) ) - 1 ; radiated_Station ( station , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, lRad, li, rRad, ri, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void reverse ( char * str , int low , int high ) { while ( low < high ) { swap ( & str [ low ] , & str [ high ] ) ; ++ low ; -- high ; } } void cycleLeader ( char * str , int shift , int len ) { int j ; char item ; for ( int i = 1 ; i < len ; i *= 3 ) { j = i ; item = str [ j + shift ] ; do { if ( j & 1 ) j = len / 2 + j / 2 ; else j /= 2 ; swap ( & str [ j + shift ] , & item ) ; } while ( j != i ) ; } } void moveNumberToSecondHalf ( char * str ) { int k , lenFirst ; int lenRemaining = strlen ( str ) ; int shift = 0 ; while ( lenRemaining ) { k = 0 ; while ( pow ( 3 , k ) + 1 <= lenRemaining ) k ++ ; lenFirst = pow ( 3 , k - 1 ) + 1 ; lenRemaining -= lenFirst ; cycleLeader ( str , shift , lenFirst ) ; reverse ( str , shift / 2 , shift - 1 ) ; reverse ( str , shift , shift + lenFirst / 2 - 1 ) ; reverse ( str , shift / 2 , shift + lenFirst / 2 - 1 ) ; shift += lenFirst ; } } int main ( ) { char str [ ] = " a1b2c3d4e5f6g7" ; moveNumberToSecondHalf ( str ) ; cout << str ; return 0 ; }

Index/key variables: high, low
Accumulator variables: i, j, k, lenRemaining, shift, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMaximumDiff ( int a [ ] , int n ) { int ind1 = 0 ; for ( int i = n - 1 ; i > 0 ; i -- ) { if ( a [ 0 ] != a [ i ] ) { ind1 = i ; break ; } } int ind2 = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( a [ n - 1 ] != a [ i ] ) { ind2 = ( n - 1 - i ) ; break ; } } return max ( ind1 , ind2 ) ; } int main ( ) { int a [ ] = { 1 , 2 , 3 , 2 , 3 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << findMaximumDiff ( a , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  100005
int n ; vector < int > tree [ N ] ; int currentIdx ; vector < int > startIdx , endIdx ; vector < int > p ; void Add_edge ( int u , int v ) { tree [ u ] . push_back ( v ) ; tree [ v ] . push_back ( u ) ; } void intisalise ( ) { startIdx . resize ( n ) ; endIdx . resize ( n ) ; p . resize ( n ) ; } void Dfs ( int ch , int par ) { p [ currentIdx ] = ch ; startIdx [ ch ] = currentIdx ++ ; for ( auto c : tree [ ch ] ) { if ( c != par ) Dfs ( c , ch ) ; } endIdx [ ch ] = currentIdx - 1 ; } int findNode ( int v , int k ) { k += startIdx [ v ] - 1 ; if ( k <= endIdx [ v ] ) return p [ k ] ; return -1 ; } int main ( ) { n = 9 ; Add_edge ( 1 , 2 ) ; Add_edge ( 1 , 3 ) ; Add_edge ( 1 , 4 ) ; Add_edge ( 3 , 5 ) ; Add_edge ( 3 , 7 ) ; Add_edge ( 5 , 6 ) ; Add_edge ( 5 , 8 ) ; Add_edge ( 7 , 9 ) ; intisalise ( ) ; Dfs ( 1 , 0 ) ; int v = 3 , k = 4 ; cout << findNode ( v , k ) ; return 0 ; }

Index/key variables: N, ch, currentIdx, k, u, v
Accumulator variables: currentIdx, k, stdc
Iterator variables: c
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sum ( int k , int n ) { int sum = pow ( k , n + 1 ) - pow ( k - 1 , n + 1 ) ; return sum ; } int main ( ) { int n = 3 ; int K = 3 ; cout << sum ( K , n ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool is_prime ( int num ) { int count = 0 ; for ( int i = 1 ; i * i <= ( num ) ; i ++ ) { if ( ( num ) % i == 0 ) { if ( i * i != ( num ) ) count += 2 ; else count ++ ; } } if ( count == 2 ) return true ; else return false ; } string is_divisible ( int n ) { if ( n == 1 ) { return " YES " ; } else { if ( is_prime ( n + 1 ) ) return " NO " ; else return " YES " ; } } int main ( ) { int n ; n = 3 ; cout << is_divisible ( n ) << endl ; n = 4 ; cout << is_divisible ( n ) << endl ; return 0 ; }

Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#define ll  long long
#define MAX  100005
using namespace std ; ll countSubarrays ( int * arr , int n , int k ) { ll prefix_sum [ MAX ] ; prefix_sum [ 0 ] = 0 ; partial_sum ( arr , arr + n , prefix_sum + 1 ) ; ll sum ; if ( k == 1 ) { sum = 0 ; map < ll , int > m ; for ( int i = n ; i >= 0 ; i -- ) { if ( m . find ( prefix_sum [ i ] + 1 ) != m . end ( ) ) sum += m [ prefix_sum [ i ] + 1 ] ; m [ prefix_sum [ i ] ] ++ ; } return sum ; } if ( k == -1 ) { sum = 0 ; map < ll , int > m ; for ( int i = n ; i >= 0 ; i -- ) { if ( m . find ( prefix_sum [ i ] + 1 ) != m . end ( ) ) sum += m [ prefix_sum [ i ] + 1 ] ; if ( m . find ( prefix_sum [ i ] - 1 ) != m . end ( ) ) sum += m [ prefix_sum [ i ] - 1 ] ; m [ prefix_sum [ i ] ] ++ ; } return sum ; } sum = 0 ; ll b ; map < ll , int > m ; for ( int i = n ; i >= 0 ; i -- ) { b = 1 ; while ( true ) { if ( b > 100000000000000 ) break ; if ( m . find ( prefix_sum [ i ] + b ) != m . end ( ) ) sum += m [ prefix_sum [ i ] + b ] ; b *= k ; } m [ prefix_sum [ i ] ] ++ ; } return sum ; } int main ( ) { int arr [ ] = { 2 , 2 , 2 , 2 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int k = 2 ; cout << countSubarrays ( arr , n , k ) ; return 0 ; }

Index/key variables: MAX, i
Accumulator variables: b, i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ll  long long
#define mod  (int)(1e9 + 7)
ll BitOperations ( string a , int n , string b , int m ) { reverse ( a . begin ( ) , a . end ( ) ) ; reverse ( b . begin ( ) , b . end ( ) ) ; int c = 0 ; for ( int i = 0 ; i < m ; i ++ ) if ( b [ i ] == '1' ) c ++ ; ll power [ n ] ; power [ 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) power [ i ] = ( power [ i - 1 ] * 2 ) % mod ; ll ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] == '1' ) { ans += c * power [ i ] ; if ( ans >= mod ) ans %= mod ; } if ( b [ i ] == '1' ) c -- ; if ( c == 0 ) break ; } return ans ; } int main ( ) { string a = "1001" , b = "10101" ; int n = a . length ( ) , m = b . length ( ) ; cout << BitOperations ( a , n , b , m ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: ans, c, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void sieve ( int maxEle , int prime [ ] ) { prime [ 0 ] = prime [ 1 ] = 1 ; for ( int i = 2 ; i * i <= maxEle ; i ++ ) { if ( ! prime [ i ] ) { for ( int j = 2 * i ; j <= maxEle ; j += i ) prime [ j ] = 1 ; } } } int digitSum ( int n ) { int sum = 0 ; while ( n ) { sum += n % 10 ; n = n / 10 ; } return sum ; } void printAdditivePrime ( int arr [ ] , int n ) { int maxEle = * max_element ( arr , arr + n ) ; int prime [ maxEle + 1 ] ; memset ( prime , 0 , sizeof ( prime ) ) ; sieve ( maxEle , prime ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( prime [ arr [ i ] ] == 0 ) { int sum = digitSum ( arr [ i ] ) ; if ( prime [ sum ] == 0 ) cout << arr [ i ] << " ▁ " ; } } } int main ( ) { int a [ ] = { 2 , 4 , 6 , 11 , 12 , 18 , 7 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; printAdditivePrime ( a , n ) ; return 0 ; }

Index/key variables: i, j, sum
Accumulator variables: i, j, stdc, sum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; long nthterm ( int n ) { int An = ( pow ( 1 , n ) + pow ( 2 , n ) ) * pow ( 3 , n ) ; return An ; } int main ( ) { int n = 3 ; cout << nthterm ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countDivisors ( int n ) { int x = 0 , ans = 1 ; while ( n % 2 == 0 ) { x ++ ; n = n / 2 ; } ans = ans * ( x + 1 ) ; for ( int i = 3 ; i <= sqrt ( n ) ; i = i + 2 ) { x = 0 ; while ( n % i == 0 ) { x ++ ; n = n / i ; } ans = ans * ( x + 1 ) ; } if ( n > 2 ) ans = ans * 2 ; return ans ; } int getTotalCount ( int n , int k ) { int k_count = countDivisors ( k ) ; int count = 0 ; for ( int i = 1 ; i < n ; i ++ ) if ( k_count == countDivisors ( i ) ) count ++ ; if ( k < n ) count = count - 1 ; return count ; } int main ( ) { int n = 500 , k = 6 ; cout << getTotalCount ( n , k ) ; return 0 ; }

Accumulator variables: count, i, stdc, x
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long term ( int n ) { int d = 2 ; int a1 = 0 ; int An = a1 + ( n - 1 ) * d ; An = pow ( An , 3 ) ; return An ; } int main ( ) { int n = 5 ; cout << term ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX_VAL = 200000 ; int countIntervals ( int arr [ ] [ 2 ] , int V , int N ) { int min = INT_MAX ; int max = INT_MIN ; int li , ri ; int freq [ MAX_VAL ] ; for ( int i = 0 ; i < N ; i ++ ) { li = arr [ i ] [ 0 ] ; freq [ li ] = freq [ li ] + 1 ; ri = arr [ i ] [ 1 ] ; freq [ ri + 1 ] = freq [ ri + 1 ] - 1 ; if ( li < min ) min = li ; if ( ri > max ) max = ri ; } for ( int i = min ; i <= max ; i ++ ) freq [ i ] = freq [ i ] + freq [ i - 1 ] ; return freq [ V ] ; } int main ( ) { int arr [ 5 ] [ 2 ] = { { 1 , 10 } , { 5 , 10 } , { 15 , 25 } , { 7 , 12 } , { 20 , 25 } } ; int V = 7 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << ( countIntervals ( arr , V , N ) ) ; }

Index/key variables: MAX_VAL, V, i, li
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printGroups ( int n ) { int x = 1 ; int y = n * n ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= n / 2 ; j ++ ) { cout << " { ▁ " << x << " , ▁ " << y << " } ▁ " ; x ++ ; y -- ; } cout << endl ; } } int main ( ) { int n = 4 ; printGroups ( n ) ; return 0 ; }

Accumulator variables: i, j, stdc, x, y
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
#define ll  long long int
using namespace std ; ll minimum ( ll n ) { ll product = 1 ; for ( int i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { while ( n % i == 0 ) n = n / i ; product = product * i ; } } if ( n >= 2 ) product = product * n ; return product ; } int main ( ) { ll n = 20 ; cout << minimum ( n ) << endl ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int numbers ( int n , int arr [ ] , int m ) { int isZero = 0 , isFive = 0 ; int result = 0 ; if ( m < n ) { return -1 ; } for ( int i = 0 ; i < m ; i ++ ) { if ( arr [ i ] == 0 ) isZero = 1 ; if ( arr [ i ] == 5 ) isFive = 1 ; } if ( isZero && isFive ) { result = 2 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { result = result * ( -- m ) ; } } else if ( isZero isFive ) { result = 1 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { result = result * ( -- m ) ; } } else result = -1 ; return result ; } int main ( ) { int n = 3 , m = 6 ; int arr [ ] = { 2 , 3 , 5 , 6 , 7 , 9 } ; cout << numbers ( n , arr , m ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int main ( ) { int a = 5 , b = 7 , c = 10 ; if ( a <= b && a <= c ) cout << a << " ▁ is ▁ the ▁ smallest " ; else if ( b <= a && b <= c ) cout << b << " ▁ is ▁ the ▁ smallest " ; else cout << c << " ▁ is ▁ the ▁ smallest " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void maxSum ( int a [ ] , int n ) { int maxAnd = 0 ; for ( int i = 0 ; i < n ; i ++ ) maxAnd = max ( maxAnd , a [ i ] ) ; int maxOR = 0 ; for ( int i = 0 ; i < n ; i ++ ) { maxOR = maxOR | a [ i ] ; } cout << maxAnd + maxOR ; } int main ( ) { int a [ ] = { 3 , 5 , 6 , 1 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; maxSum ( a , n ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int R = 3 ; const int C = 4 ; int magic ( int a , int b , int c , int d , int e , int f , int g , int h , int i ) { set < int > s1 = { a , b , c , d , e , f , g , h , i } , s2 = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 } ; if ( s1 == s2 && ( a + b + c ) == 15 && ( d + e + f ) == 15 && ( g + h + i ) == 15 && ( a + d + g ) == 15 && ( b + e + h ) == 15 && ( c + f + i ) == 15 && ( a + e + i ) == 15 && ( c + e + g ) == 15 ) return true ; return false ; } int CountMagicSquare ( int Grid [ R ] [ C ] ) { int ans = 0 ; for ( int i = 0 ; i < R - 2 ; i ++ ) for ( int j = 0 ; j < C - 2 ; j ++ ) { if ( Grid [ i + 1 ] [ j + 1 ] != 5 ) continue ; if ( magic ( Grid [ i ] [ j ] , Grid [ i ] [ j + 1 ] , Grid [ i ] [ j + 2 ] , Grid [ i + 1 ] [ j ] , Grid [ i + 1 ] [ j + 1 ] , Grid [ i + 1 ] [ j + 2 ] , Grid [ i + 2 ] [ j ] , Grid [ i + 2 ] [ j + 1 ] , Grid [ i + 2 ] [ j + 2 ] ) ) ans += 1 ; } return ans ; } int main ( ) { int G [ R ] [ C ] = { { 4 , 3 , 8 , 4 } , { 9 , 5 , 1 , 9 } , { 2 , 7 , 6 , 2 } } ; cout << CountMagicSquare ( G ) ; return 0 ; }

Index/key variables: C, R, i, j
Accumulator variables: ans, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sumSubarrayMins ( int A [ ] , int n ) { int left [ n ] , right [ n ] ; stack < pair < int , int > > s1 , s2 ; for ( int i = 0 ; i < n ; ++ i ) { int cnt = 1 ; while ( ! s1 . empty ( ) && ( s1 . top ( ) . first ) > A [ i ] ) { cnt += s1 . top ( ) . second ; s1 . pop ( ) ; } s1 . push ( { A [ i ] , cnt } ) ; left [ i ] = cnt ; } for ( int i = n - 1 ; i >= 0 ; -- i ) { int cnt = 1 ; while ( ! s2 . empty ( ) && ( s2 . top ( ) . first ) >= A [ i ] ) { cnt += s2 . top ( ) . second ; s2 . pop ( ) ; } s2 . push ( { A [ i ] , cnt } ) ; right [ i ] = cnt ; } int result = 0 ; for ( int i = 0 ; i < n ; ++ i ) result = ( result + A [ i ] * left [ i ] * right [ i ] ) ; return result ; } int main ( ) { int A [ ] = { 3 , 1 , 2 , 4 } ; int n = sizeof ( A ) / sizeof ( A [ 0 ] ) ; cout << sumSubarrayMins ( A , n ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: cnt, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getMin ( int arr [ ] , int n , int k ) { int res = INT_MAX ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % k == 0 ) res = min ( res , arr [ i ] ) ; } return res ; } int getMax ( int arr [ ] , int n , int k ) { int res = INT_MIN ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] % k == 0 ) res = max ( res , arr [ i ] ) ; } return res ; } int main ( ) { int arr [ ] = { 10 , 1230 , 45 , 67 , 1 } ; int k = 10 ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << " Minimum ▁ element ▁ of ▁ array ▁ which ▁ is ▁ divisible ▁ by ▁ k : ▁ " << getMin ( arr , n , k ) << " STRNEWLINE " ; cout << " Maximum ▁ element ▁ of ▁ array ▁ which ▁ is ▁ divisible ▁ by ▁ k : ▁ " << getMax ( arr , n , k ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printNumberWithDR ( int k , int d ) { if ( d == 0 && k != 1 ) cout << " - 1" ; else { cout << d ; k -- ; while ( k -- ) cout << "0" ; } } int main ( ) { int k = 4 , d = 4 ; printNumberWithDR ( k , d ) ; return 0 ; }

Accumulator variables: k, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countNumbers ( int n ) { int c = 0 ; int limit = sqrt ( n ) ; int prime [ limit + 1 ] ; for ( int i = 1 ; i <= limit ; i ++ ) prime [ i ] = i ; for ( int i = 2 ; i * i <= limit ; i ++ ) { if ( prime [ i ] == i ) { for ( int j = i * i ; j <= limit ; j += i ) if ( prime [ j ] == j ) prime [ j ] = i ; } } for ( int i = 2 ; i <= limit ; i ++ ) { int p = prime [ i ] ; int q = prime [ i / prime [ i ] ] ; if ( p * q == i && q != 1 && p != q ) { c += 1 ; } else if ( prime [ i ] == i ) { if ( pow ( i , 8 ) <= n ) { c += 1 ; } } } return c ; } int main ( ) { int n = 1000 ; cout << countNumbers ( n ) ; return 0 ; }

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