dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int maxn = 100001 ; int gpf [ maxn ] ; void modifiedSieve ( ) { memset ( gpf , 0 , sizeof ( gpf ) ) ; gpf [ 0 ] = 0 ; gpf [ 1 ] = 1 ; for ( int i = 2 ; i < maxn ; i ++ ) { if ( gpf [ i ] > 0 ) continue ; for ( int j = i ; j < maxn ; j += i ) { gpf [ j ] = max ( i , gpf [ j ] ) ; } } } int greatestValidInt ( int N ) { modifiedSieve ( ) ; for ( int i = N ; i > 0 ; i -- ) { if ( gpf [ i ] > sqrt ( i ) ) { return i ; } } return -1 ; } int main ( ) { int N = 25 ; cout << greatestValidInt ( N ) ; return 0 ; }

Index/key variables: i, j, maxn
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void numberOfPasses ( vector < int > arr , int N ) { for ( int i = 0 ; i < N ; ++ i ) { -- arr [ i ] ; } for ( int i = 0 ; i < N ; ++ i ) { int cnt = 0 ; int k = i ; do { ++ cnt ; k = arr [ k ] ; } while ( k != i ) ; cout << cnt << " ▁ " ; } } int main ( ) { vector < int > arr { 4 , 6 , 2 , 1 , 5 , 3 } ; int N = arr . size ( ) ; numberOfPasses ( arr , N ) ; return 0 ; }

Index/key variables: i, k
Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; double subfactorial ( int N ) { double res = 0 , fact = 1 ; int count = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { fact = fact * i ; if ( count % 2 == 0 ) res = res - ( 1 / fact ) ; else res = res + ( 1 / fact ) ; count ++ ; } return fact * ( 1 + res ) ; } int main ( ) { int N = 4 ; cout << subfactorial ( N ) ; return 0 ; }

Accumulator variables: count, i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minOperations ( int A [ ] , int B [ ] , int N ) { int cnt = 0 ; int i = 0 ; while ( i < N ) { int j = 0 ; while ( j < N && i < N ) { if ( B [ i ] == A [ j ] ) { i ++ ; } j ++ ; } cnt ++ ; } return cnt ; } int main ( ) { int A [ ] = { 2 , 4 , 6 , 1 , 5 , 3 } ; int B [ ] = { 6 , 5 , 4 , 2 , 3 , 1 } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; cout << minOperations ( A , B , N ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: cnt, i, j, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countPairs ( int N ) { int res = 0 ; for ( int q = 1 ; q * q <= N ; q ++ ) { int maxP = min ( 2 * N - q , N / q ) ; if ( maxP < q ) continue ; int cnt = maxP - q + 1 ; res += ( cnt / 2 + ( cnt & 1 ) ) ; } return res ; } int main ( ) { int N = 3 ; cout << countPairs ( N ) ; return 0 ; }

Accumulator variables: q, res, stdc
Iterator variables: q
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maximizeSubset ( int N , int arr [ ] , int M , int x = 0 ) { if ( x == M ) { return 0 ; } int ans = 0 ; for ( int i = x ; i < M ; i ++ ) { if ( N % arr [ i ] == 0 ) { ans = max ( ans , maximizeSubset ( N / arr [ i ] , arr , M , x + 1 ) + 1 ) ; } } return ans ; } int main ( ) { int N = 64 ; int arr [ ] = { 1 , 2 , 4 , 8 , 16 , 32 } ; int M = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << maximizeSubset ( 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 countDistinctSums ( int N , int L , int R ) { int minSum = L * N ; int maxSum = R * N ; return maxSum - minSum + 1 ; } int main ( ) { int N = 2 , L = 1 , R = 3 ; cout << countDistinctSums ( N , L , R ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void setSumtoZero ( double arr [ ] , int N ) { int A [ N ] ; int sum = 0 ; int m = INT_MIN ; for ( int i = 0 ; i < N ; i ++ ) { sum += ceil ( arr [ i ] ) ; A [ i ] = ceil ( arr [ i ] ) ; } if ( sum > 0 ) { m = min ( sum , N ) ; for ( int i = 0 ; i < N && m > 0 ; i ++ ) { A [ i ] = floor ( arr [ i ] ) ; if ( A [ i ] != floor ( arr [ i ] ) ) m -- ; } } for ( int i = 0 ; i < N ; i ++ ) { cout << A [ i ] << " ▁ " ; } } int main ( ) { double arr [ ] = { -2 , -2 , 4.5 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; setSumtoZero ( arr , N ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: i, m, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int Get ( vector < int > & graph , int a ) { return graph [ a ] = ( graph [ a ] == a ? a : Get ( graph , graph [ a ] ) ) ; } void Union ( vector < int > & graph , int a , int b ) { a = Get ( graph , a ) ; b = Get ( graph , b ) ; graph [ a ] = b ; } void Queries ( vector < pair < int , int > > & queries , int N , int M ) { vector < int > graph ( N + 2 ) ; for ( int i = 1 ; i <= N + 1 ; i ++ ) { graph [ i ] = i ; } for ( auto query : queries ) { if ( query . first == 1 ) { Union ( graph , query . second , query . second + 1 ) ; } else { int a = Get ( graph , query . second ) ; if ( a == N + 1 ) cout << -1 << " ▁ " ; else cout << graph [ a ] << " ▁ " ; } } } int main ( ) { int N = 5 ; vector < pair < int , int > > queries { { 2 , 1 } , { 1 , 1 } , { 2 , 1 } , { 2 , 3 } } ; int Q = queries . size ( ) ; Queries ( queries , N , Q ) ; return 0 ; }

Index/key variables: a, i
Accumulator variables: i, stdc
Iterator variables: i, query
C++ program:
#include <iostream>
using namespace std ; long long convertToBase9 ( long long n ) { long long ans = 0 ; long long a = 1 ; while ( n > 0 ) { ans += ( a * ( n % 9 ) ) ; a *= 10 ; n /= 9 ; } return ans ; } long long getNthnumber ( long long base9 , long long K ) { long long ans = 0 ; long long a = 1 ; while ( base9 > 0 ) { int cur = base9 % 10 ; if ( cur >= K ) { ans += a * ( cur + 1 ) ; } else { ans += a * cur ; } base9 /= 10 ; a *= 10 ; } return ans ; } int main ( ) { long long N = 10 , K = 1 ; long long base9 = convertToBase9 ( N ) ; cout << getNthnumber ( base9 , K ) ; return 0 ; }

Accumulator variables: a, ans, base9, n
C++ program:
#include <iostream>
using namespace std ; bool binarySearch ( float arr [ ] , int size , float key ) { int low = 0 , high = size - 1 , mid ; while ( low <= high ) { mid = low + ( high - low ) / 2 ; if ( key > arr [ mid ] ) low = mid + 1 ; else if ( key < arr [ mid ] ) high = mid - 1 ; else return 1 ; } return 0 ; } bool twoPointers ( float arr [ ] , int N , float mean ) { int i = 0 , j = N - 1 ; while ( i < j ) { float temp = ( arr [ i ] + arr [ j ] ) / 2 ; if ( temp > mean ) j -- ; else if ( temp < mean ) i ++ ; else return 1 ; } return 0 ; } bool checkArray ( float arr [ ] , int N ) { float sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) sum += arr [ i ] ; float mean = sum / N ; if ( N & 1 ) return binarySearch ( arr , N , mean ) ; else return twoPointers ( arr , N , mean ) ; } int main ( ) { float arr [ ] = { 1.0 , 3.0 , 6.0 , 9.0 , 12.0 , 32.0 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; if ( checkArray ( arr , N ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: i, j, mid
Accumulator variables: i, j, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int UniqueGeometricTerms ( int N , int a1 , int r1 , int a2 , int r2 ) { set < int > S ; long long p1 = a1 ; for ( int i = 0 ; i < N ; i ++ ) { S . insert ( p1 ) ; p1 = ( long long ) ( p1 * r1 ) ; } long long p2 = a2 ; for ( int i = 0 ; i < N ; i ++ ) { S . insert ( p2 ) ; p2 = ( long long ) ( p2 * r2 ) ; } return S . size ( ) ; } int main ( ) { int N = 5 ; int a1 = 3 , r1 = 2 , a2 = 2 , r2 = 3 ; cout << UniqueGeometricTerms ( N , a1 , r1 , a2 , r2 ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minOperations ( int arr [ ] , int N , int K ) { vector < pair < int , int > > vp ; for ( int i = 0 ; i < N ; i ++ ) { vp . push_back ( { arr [ i ] , i } ) ; } sort ( vp . begin ( ) , vp . end ( ) ) ; int minCnt = 0 ; while ( ! vp . empty ( ) ) { int val , ind ; val = vp . back ( ) . first ; ind = vp . back ( ) . second ; minCnt ++ ; while ( ! vp . empty ( ) && vp . back ( ) . first == val && ind - vp . back ( ) . second + 1 <= K ) vp . pop_back ( ) ; } return minCnt ; } int main ( ) { int arr [ ] = { 18 , 11 , 18 , 11 , 18 } ; int K = 3 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << minOperations ( arr , N , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, minCnt, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void nearestLeft ( int arr [ ] , int N , vector < int > & steps ) { int L = - N ; for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( arr [ i ] > 0 ) { L = - ( N - i ) ; break ; } } for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] > 0 ) { L = i ; } steps [ i ] = i - L ; } } void nearestRight ( int arr [ ] , int N , vector < int > & steps ) { int R = 2 * N ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] > 0 ) { R = N + i ; break ; } } for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( arr [ i ] > 0 ) { R = i ; } steps [ i ] = min ( steps [ i ] , R - i ) ; } } int findSum ( int arr [ ] , int N , int M , int K ) { vector < int > steps ( N ) ; int sum = accumulate ( arr , arr + N , 0 ) ; if ( sum == 0 ) { return 0 ; } nearestLeft ( arr , N , steps ) ; nearestRight ( arr , N , steps ) ; for ( int i = 0 ; i < N ; i ++ ) sum += 2 * K * max ( 0 , M - steps [ i ] ) ; return sum ; } int main ( ) { int arr [ ] = { 0 , 1 , 0 , 1 , 0 , 0 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int M = 2 ; int K = 1 ; cout << findSum ( arr , N , M , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int maxn = 100 ; int parent [ maxn ] , Size [ maxn ] ; void make_set ( int v ) { parent [ v ] = v ; Size [ v ] = 1 ; } int find_set ( int v ) { if ( v == parent [ v ] ) { return v ; } return parent [ v ] = find_set ( parent [ v ] ) ; } void union_sets ( int a , int b ) { a = find_set ( a ) ; b = find_set ( b ) ; if ( a != b ) { if ( Size [ a ] < Size [ b ] ) swap ( a , b ) ; parent [ b ] = a ; Size [ a ] += Size [ b ] ; } } void findMinVertex ( int N , vector < pair < int , int > > edges ) { for ( int i = 1 ; i <= N ; i ++ ) { make_set ( i ) ; } for ( int i = 0 ; i < edges . size ( ) ; i ++ ) { union_sets ( edges [ i ] . first , edges [ i ] . second ) ; } unordered_map < int , int > minVal ; for ( int i = 1 ; i <= N ; i ++ ) { if ( minVal [ find_set ( i ) ] == 0 ) { minVal [ find_set ( i ) ] = i ; } else { minVal [ find_set ( i ) ] = min ( minVal [ find_set ( i ) ] , i ) ; } } for ( int i = 1 ; i <= N ; i ++ ) { cout << minVal [ find_set ( i ) ] << " ▁ " ; } } int main ( ) { int N = 6 ; vector < pair < int , int > > edges = { { 1 , 3 } , { 2 , 4 } } ; findMinVertex ( N , edges ) ; return 0 ; }

Index/key variables: a, b, i, maxn, v
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getProduct ( int n ) { int product = 1 ; while ( n != 0 ) { product = product * ( n % 10 ) ; n = n / 10 ; } return product ; } int countPairs ( int L , int R ) { int cntPair = 0 ; for ( int a = L ; a <= R ; a ++ ) { for ( int b = a + 1 ; b <= R ; b ++ ) { int x = getProduct ( a ) ; int y = getProduct ( b ) ; if ( x && y && ( a * y ) == ( b * x ) ) { cntPair ++ ; } } } return cntPair ; } int main ( ) { int L = 1 ; int R = 100 ; cout << countPairs ( 1 , 100 ) ; return 0 ; }

Accumulator variables: a, b, cntPair, stdc
Iterator variables: a, b
C++ program:
#include <bits/stdc++.h>
using namespace std ; void elementsCoprimeWithArr ( int A [ ] , int N , int L , int R ) { unordered_set < int > S ; for ( int i = 0 ; i < N ; i ++ ) { int curr_ele = A [ i ] ; for ( int j = 1 ; j <= sqrt ( curr_ele ) + 1 ; j ++ ) { if ( curr_ele % j == 0 ) { S . insert ( j ) ; S . insert ( curr_ele / j ) ; } } } unordered_set < int > store ; for ( int i = L ; i <= R ; i ++ ) store . insert ( i ) ; S . erase ( 1 ) ; for ( auto it : S ) { int ele = it ; int index = 1 ; while ( index * ele <= R ) { store . erase ( index * ele ) ; index ++ ; } } for ( auto i : store ) { cout << i << " ▁ " ; } } int main ( ) { int arr [ ] = { 3 , 5 } ; int L = 1 , R = 10 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; elementsCoprimeWithArr ( arr , N , L , R ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, index, j, stdc
Iterator variables: i, it, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxSum ( vector < vector < int > > & matrix ) { int r = matrix . size ( ) ; int c = matrix [ 0 ] . size ( ) ; int sum = 0 ; int mini = INT_MAX ; int count = 0 ; for ( int i = 0 ; i < r ; i ++ ) { for ( int j = 0 ; j < c ; j ++ ) { int k = matrix [ i ] [ j ] ; mini = min ( mini , abs ( k ) ) ; if ( k < 0 ) count ++ ; sum += abs ( k ) ; } } if ( count % 2 == 0 ) { return sum ; } else { return ( sum - 2 * mini ) ; } } int main ( ) { vector < vector < int > > matrix = { { 2 , -2 } , { -2 , 2 } } ; cout << maxSum ( matrix ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: count, i, j, stdc, sum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int lastPositiveElement ( vector < int > arr ) { int N = arr . size ( ) ; if ( N == 1 ) return arr [ 0 ] ; int greatest = -1 , secondGreatest = -1 ; for ( int x : arr ) { if ( x >= greatest ) { secondGreatest = greatest ; greatest = x ; } else if ( x >= secondGreatest ) { secondGreatest = x ; } } return greatest - secondGreatest ; } int main ( ) { vector < int > arr = { 3 , 5 , 4 , 7 } ; cout << lastPositiveElement ( arr ) ; return 0 ; }

Accumulator variables: stdc
Iterator variables: x
C++ program:
#include <bits/stdc++.h>
using namespace std ; void updateArray ( vector < int > & arr , int K ) { int sum = 0 ; vector < int > res ; for ( int i = 0 ; i < ( int ) arr . size ( ) ; i ++ ) { if ( arr [ i ] < K ) { sum += arr [ i ] ; } else { if ( sum != 0 ) { res . push_back ( sum ) ; } sum = 0 ; res . push_back ( arr [ i ] ) ; } } if ( sum != 0 ) res . push_back ( sum ) ; for ( auto & it : res ) cout << it << ' ▁ ' ; } int main ( ) { vector < int > arr = { 200 , 6 , 36 , 612 , 121 , 66 , 63 , 39 , 668 , 108 } ; int K = 100 ; updateArray ( arr , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < vector < int > > adj ( 100000 ) ; vector < int > setNum ( 100000 ) ; void addEdge ( int a1 , int a2 ) { adj [ a1 ] . push_back ( a2 ) ; adj [ a2 ] . push_back ( a1 ) ; } void toBipartite ( int N ) { setNum . assign ( N , -1 ) ; queue < int > q ; q . push ( 0 ) ; setNum [ 0 ] = 0 ; while ( ! q . empty ( ) ) { int v = q . front ( ) ; q . pop ( ) ; for ( int u : adj [ v ] ) { if ( setNum [ u ] == -1 ) { setNum [ u ] = setNum [ v ] ^ 1 ; q . push ( u ) ; } } } } void pathLengthQuery ( int A , int B ) { if ( setNum [ A ] == setNum [ B ] ) { cout << " Odd " << endl ; } else { cout << " Even " << endl ; } } int main ( ) { int N = 7 ; addEdge ( 0 , 1 ) ; addEdge ( 0 , 2 ) ; addEdge ( 1 , 3 ) ; addEdge ( 3 , 4 ) ; addEdge ( 3 , 5 ) ; addEdge ( 2 , 6 ) ; toBipartite ( N ) ; pathLengthQuery ( 4 , 2 ) ; pathLengthQuery ( 0 , 4 ) ; return 0 ; }

Index/key variables: A, B, a1, a2, u, v
Accumulator variables: stdc
Iterator variables: u
C++ program:
#include <bits/stdc++.h>
using namespace std ; int highestPowerof2 ( int n ) { int p = int ( log2 ( n ) ) ; if ( p % 2 == 0 ) p -= 1 ; return int ( pow ( 2 , p ) ) ; } int minStep ( int N , int X ) { if ( N % 2 and X == 0 ) return -1 ; int size = 0 ; while ( X < N ) { N -= highestPowerof2 ( N ) ; size += 1 ; } if ( N ) size += 1 ; return size ; } int main ( ) { int N = 11 ; int X = 2 ; cout << ( minStep ( N , X ) ) ; }

Accumulator variables: N, p, size, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; string checkSameDigits ( int N ) { int digit = N % 10 ; while ( N != 0 ) { int current_digit = N % 10 ; N = N / 10 ; if ( current_digit != digit ) { return " No " ; } } return " Yes " ; } int main ( ) { int N = 222 ; cout << ( checkSameDigits ( N ) ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int positionAfterKJumps ( int X , int Y , int K ) { int addY = Y * ( K / 2 ) ; int reduceX = -1 * X * ( K / 2 + K % 2 ) ; return addY + reduceX ; } int main ( ) { int X = 2 , Y = 5 , K = 3 ; cout << positionAfterKJumps ( X , Y , K ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMaxK ( int N ) { int K = N ; for ( int i = N - 1 ; i >= 0 ; i -- ) { K &= i ; if ( K == 0 ) { return i ; } } return 0 ; } int main ( ) { int N = 5 ; cout << findMaxK ( N ) ; }

Accumulator variables: K, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countPairs ( int arr [ ] , int n ) { int count = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( ( arr [ j ] % arr [ i ] == 0 ) && ( j + 1 ) % ( i + 1 ) == 0 && ( arr [ j ] / arr [ i ] == ( j + 1 ) / ( i + 1 ) ) ) { count ++ ; } } } return count ; } int main ( ) { int arr [ ] = { 5 , -2 , 4 , 20 , 25 , -6 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countPairs ( 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 ; int countPairs ( int arr [ ] , int n ) { int count = 0 ; for ( int x = 1 ; x <= n ; x ++ ) { for ( int y = 2 * x ; y <= n ; y += x ) { if ( ( arr [ y - 1 ] % arr [ x - 1 ] == 0 ) && ( arr [ y - 1 ] / arr [ x - 1 ] == y / x ) ) { count ++ ; } } } return count ; } int main ( ) { int arr [ ] = { 5 , -2 , 4 , 20 , 25 , -6 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countPairs ( arr , n ) ; return 0 ; }

Accumulator variables: count, stdc, x, y
Iterator variables: x, y
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ll  long long int
void countMinDistance ( int n , int m , int edges [ ] [ 2 ] ) { vector < ll > g [ 10005 ] ; for ( int i = 0 ; i < m ; i ++ ) { int a = edges [ i ] [ 0 ] - 1 ; int b = edges [ i ] [ 1 ] - 1 ; g [ a ] . push_back ( b ) ; g [ b ] . push_back ( a ) ; } queue < pair < ll , ll > > queue1 ; queue1 . push ( { 0 , 0 } ) ; vector < int > dist ( n , 1e9 ) ; vector < int > ways1 ( n , 0 ) ; dist [ 0 ] = 0 ; ways1 [ 0 ] = 1 ; while ( ! queue1 . empty ( ) ) { auto up = queue1 . front ( ) ; queue1 . pop ( ) ; int x = up . first ; int dis = up . second ; if ( dis > dist [ x ] ) continue ; if ( x == n - 1 ) continue ; for ( ll y : g [ x ] ) { if ( dist [ y ] > dis + 1 ) { dist [ y ] = dis + 1 ; ways1 [ y ] = ways1 [ x ] ; queue1 . push ( { y , dis + 1 } ) ; } else if ( dist [ y ] == dis + 1 ) { ways1 [ y ] += ways1 [ x ] ; } } } queue < pair < ll , ll > > queue2 ; queue2 . push ( { n - 1 , 0 } ) ; vector < int > dist1 ( n , 1e9 ) ; vector < int > ways2 ( n , 0 ) ; dist1 [ n - 1 ] = 0 ; ways2 [ n - 1 ] = 1 ; while ( ! queue2 . empty ( ) ) { auto up = queue2 . front ( ) ; queue2 . pop ( ) ; int x = up . first ; int dis = up . second ; if ( dis > dist1 [ x ] ) continue ; if ( x == 0 ) continue ; for ( ll y : g [ x ] ) { if ( dist1 [ y ] > dis + 1 ) { dist1 [ y ] = dis + 1 ; ways2 [ y ] = ways2 [ x ] ; queue2 . push ( { y , dis + 1 } ) ; } else if ( dist1 [ y ] == 1 + dis ) { ways2 [ y ] += ways2 [ x ] ; } } } for ( int i = 0 ; i < n ; i ++ ) { cout << ways1 [ i ] * ways2 [ i ] << " ▁ " ; } } int main ( ) { int N = 5 , M = 5 ; int edges [ M ] [ 2 ] = { { 1 , 2 } , { 1 , 4 } , { 1 , 3 } , { 2 , 5 } , { 2 , 4 } } ; countMinDistance ( N , M , edges ) ; return 0 ; }

Index/key variables: M, a, b, i, x, y
Accumulator variables: i, stdc
Iterator variables: i, y
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long factorial ( int n ) { long long ans = 1 ; while ( n >= 1 ) { ans *= n ; n -- ; } return ans ; } void Binary_Num ( int n , int k ) { long long num_even , num_odd ; if ( n - k - 1 >= 0 && k - 1 >= 0 ) { num_even = factorial ( n - 2 ) / ( factorial ( k - 1 ) * factorial ( n - k - 1 ) ) ; } else { num_even = 0 ; } if ( k - 2 >= 0 ) { num_odd = factorial ( n - 2 ) / ( factorial ( k - 2 ) * factorial ( n - k ) ) ; } else { num_odd = 0 ; } cout << num_even << " ▁ " << num_odd << endl ; } int main ( ) { int N = 9 , K = 6 ; Binary_Num ( N , K ) ; return 0 ; }

Accumulator variables: ans, n, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findSumOfAllSubsets ( int arr [ ] , int n , int k ) { int factorial_N = 1 , factorial_d = 1 , factorial_D = 1 ; for ( int i = 1 ; i <= n - 1 ; i ++ ) factorial_N *= i ; for ( int i = 1 ; i <= k - 1 ; i ++ ) factorial_d *= i ; for ( int i = 1 ; i <= n - k ; i ++ ) factorial_D *= i ; int freq = factorial_N / ( factorial_d * factorial_D ) ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += arr [ i ] ; sum = sum * freq ; cout << " Sum ▁ of ▁ all ▁ subsets ▁ of ▁ size ▁ = ▁ " << k << " ▁ is ▁ = > ▁ " << sum << endl ; } int main ( ) { int arr [ ] = { 1 , 2 , 4 , 5 } ; int n = 4 , k = 2 ; findSumOfAllSubsets ( arr , n , k ) ; return 0 ; }

Index/key variables: i
Accumulator variables: factorial_D, factorial_N, factorial_d, i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maximumTripletXOR ( int A , int B , int C ) { int ans = 0 ; for ( int i = 30 ; i >= 0 ; i -- ) { int cur = 1 << i ; if ( A >= cur ) { ans += cur ; A -= cur ; } else if ( B >= cur ) { ans += cur ; B -= cur ; } else if ( C >= cur ) { ans += cur ; C -= cur ; } } return ans ; } int main ( ) { int A = 6 ; int B = 2 ; int C = 10 ; cout << maximumTripletXOR ( A , B , C ) ; }

Accumulator variables: A, B, C, ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int intCount ( int X , int K ) { int ans = 0 ; for ( int z = 0 ; z < pow ( 10 , K ) ; z += ( pow ( 10 , K ) - 1 ) / 9 ) { if ( z > X ) break ; ans += ( ( X - z ) / pow ( 10 , K ) + 1 ) ; } return ans ; } int intCountInRange ( int L , int R , int K ) { return ( intCount ( R , K ) - intCount ( L - 1 , K ) ) ; } int main ( ) { int L = 49 ; int R = 101 ; int K = 2 ; cout << intCountInRange ( L , R , K ) ; return 0 ; }

Accumulator variables: ans, stdc, z
Iterator variables: z
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countQuadruples ( int A [ ] , int N ) { int ans = 0 ; unordered_map < int , int > freq ; for ( int i = 0 ; i < N ; i ++ ) { ans += freq [ A [ i ] ] ; for ( int j = 0 ; j < i ; j ++ ) { for ( int k = 0 ; k < j ; k ++ ) { freq [ A [ i ] * A [ j ] * A [ k ] ] ++ ; } } } return ans ; } int main ( ) { int arr [ ] = { 10 , 2 , 2 , 7 , 40 , 160 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countQuadruples ( arr , N ) ; return 0 ; }

Index/key variables: i, j, k
Accumulator variables: ans, i, j, k, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool can ( int Mid , int X , int Y , int A , int B ) { int p1 = X - Mid * B ; int p2 = Y - Mid * B ; if ( p1 < 0 p2 < 0 ) { return false ; } int k = A - B ; if ( k == 0 ) { return true ; } int val = p1 / k + p2 / k ; if ( val >= Mid ) { return true ; } return false ; } int maxPossibleMoves ( int X , int Y , int A , int B ) { int ans = 0 ; int L = 1 , R = MAXN ; while ( L <= R ) { int Mid = ( L + R ) / 2 ; if ( can ( Mid , X , Y , A , B ) ) { L = Mid + 1 ; ans = max ( ans , Mid ) ; } else { R = Mid - 1 ; } } return ans ; } int main ( ) { int X = 10 , Y = 12 , A = 2 , B = 5 ; if ( A < B ) { swap ( A , B ) ; } cout << maxPossibleMoves ( X , Y , A , B ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printFactors ( int n ) { for ( int i = 2 ; i <= sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { int d1 = i , d2 = n ; while ( d2 % d1 == 0 ) { d2 = d2 / d1 ; } if ( d1 > 1 && d2 > 1 ) { cout << d1 << " , ▁ " << d2 ; return ; } } } cout << -1 ; } int main ( ) { int N = 10 ; printFactors ( N ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i