dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < string > solve ( int n , int arr [ ] ) { string s = string ( n , ' a ' ) ; vector < string > ans ; ans . push_back ( s ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) { char ch = s [ arr [ i ] ] ; if ( ch == ' b ' ) ch = ' a ' ; else ch = ' b ' ; s [ arr [ i ] ] = ch ; ans . push_back ( s ) ; } return ans ; } int main ( ) { int arr [ ] = { 2 , 0 , 3 } ; int n = sizeof arr / sizeof arr [ 0 ] ; vector < string > ans = solve ( n , arr ) ; for ( int i = ans . size ( ) - 1 ; i >= 0 ; i -- ) { cout << ans [ i ] << endl ; } return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSwaps ( int A [ ] , int n ) { sort ( A , A + n ) ; int ind = 1 , res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { while ( ind < n and A [ ind ] == A [ i ] ) ind ++ ; if ( ind < n and A [ ind ] > A [ i ] ) { res ++ ; ind ++ ; } if ( ind >= n ) break ; } return res ; } int main ( ) { int A [ ] = { 4 , 3 , 3 , 2 , 5 } ; cout << countSwaps ( A , 5 ) ; return 0 ; }

Index/key variables: i, ind
Accumulator variables: i, ind, res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSwaps ( int A [ ] , int n ) { map < int , int > mp ; int max_frequency = 0 ; for ( int i = 0 ; i < n ; i ++ ) { mp [ A [ i ] ] ++ ; max_frequency = max ( max_frequency , mp [ A [ i ] ] ) ; } return n - max_frequency ; } int main ( ) { int A [ ] = { 6 , 5 , 4 , 3 , 2 , 1 } ; cout << countSwaps ( A , 6 ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int min_operation ( int a [ ] , int n ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i > 0 ) ans += abs ( a [ i ] - a [ i - 1 ] ) ; else ans += abs ( a [ i ] ) ; } return ans ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << min_operation ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void FindMatrix ( int n , int m , int x , int y ) { int a , b , i , j ; if ( n * m == 1 ) { if ( x > y ) { cout << y << " STRNEWLINE " ; } else { cout << x << " STRNEWLINE " ; } return ; } a = min ( x , y ) ; b = min ( 2 * x , y ) - a ; bool flag = true ; for ( i = 0 ; i < n ; i ++ ) { for ( j = 0 ; j < m ; j ++ ) { if ( flag ) cout << a << ' ▁ ' ; else cout << b << ' ▁ ' ; flag = ! flag ; } if ( ( ( n % 2 != 0 && m % 2 == 0 ) || ( n % 2 == 0 && m % 2 == 0 ) ) ) flag = ! flag ; cout << " STRNEWLINE " ; } } int main ( ) { int N , M , X , Y ; N = 3 ; M = 3 ; X = 5 ; Y = 3 ; FindMatrix ( N , M , X , Y ) ; }

Accumulator variables: i, j
Iterator variables: i, j
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findMinRoute ( vector < vector < int > > tsp ) { int sum = 0 ; int counter = 0 ; int j = 0 , i = 0 ; int min = INT_MAX ; map < int , int > visitedRouteList ; visitedRouteList [ 0 ] = 1 ; int route [ tsp . size ( ) ] ; while ( i < tsp . size ( ) && j < tsp [ i ] . size ( ) ) { if ( counter >= tsp [ i ] . size ( ) - 1 ) { break ; } if ( j != i && ( visitedRouteList [ j ] == 0 ) ) { if ( tsp [ i ] [ j ] < min ) { min = tsp [ i ] [ j ] ; route [ counter ] = j + 1 ; } } j ++ ; if ( j == tsp [ i ] . size ( ) ) { sum += min ; min = INT_MAX ; visitedRouteList [ route [ counter ] - 1 ] = 1 ; j = 0 ; i = route [ counter ] - 1 ; counter ++ ; } } i = route [ counter - 1 ] - 1 ; for ( j = 0 ; j < tsp . size ( ) ; j ++ ) { if ( ( i != j ) && tsp [ i ] [ j ] < min ) { min = tsp [ i ] [ j ] ; route [ counter ] = j + 1 ; } } sum += min ; cout << ( " Minimum ▁ Cost ▁ is ▁ : ▁ " ) ; cout << ( sum ) ; } int main ( ) { vector < vector < int > > tsp = { { -1 , 10 , 15 , 20 } , { 10 , -1 , 35 , 25 } , { 15 , 35 , -1 , 30 } , { 20 , 25 , 30 , -1 } } ; findMinRoute ( tsp ) ; }

Index/key variables: counter, i, j
Accumulator variables: counter, j, stdc, sum
Iterator variables: j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findCount ( vector < int > & Arr1 , vector < int > & Arr2 ) { int MAX = max ( * max_element ( Arr1 . begin ( ) , Arr1 . end ( ) ) , * max_element ( Arr2 . begin ( ) , Arr2 . end ( ) ) ) ; vector < int > Count ( 2 * MAX + 1 , 0 ) ; int n = Arr1 . size ( ) , m = Arr2 . size ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { int element = Arr1 [ i ] + Arr2 [ j ] ; Count [ element ] ++ ; } } for ( int i = 1 ; i <= 2 * MAX ; i ++ ) { if ( Count [ i ] > 0 ) { cout << i << " - > " << Count [ i ] << endl ; } } } int main ( ) { vector < int > arr1 = { 1 , 2 } ; vector < int > arr2 = { 1 , 2 , 1 } ; findCount ( arr1 , arr2 ) ; }

Index/key variables: element, i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findAandB ( double N ) { if ( N == 1 ) { cout << " No " ; return ; } double a = N * N / ( N - 1 ) ; double b = a / N ; cout << " a ▁ = ▁ " << a << endl ; cout << " b ▁ = ▁ " << b << endl ; } int main ( ) { double N = 6 ; findAandB ( N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxSelections ( int A [ ] , int n , int k ) { sort ( A , A + n ) ; int sum = 0 ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum = sum + A [ i ] ; if ( sum > k ) { break ; } count ++ ; } return count ; } int main ( ) { int A [ ] = { 3 , 7 , 2 , 9 , 4 } ; int k = 15 ; int n = sizeof ( A ) / sizeof ( A [ 0 ] ) ; cout << maxSelections ( A , n , k ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void computePair ( double K ) { if ( K == 1 ) { cout << " No " ; return ; } else { cout << K * K / ( K - 1 ) << " ▁ " ; cout << K / ( K - 1 ) << endl ; } } int main ( ) { double K = 6 ; computePair ( K ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; string ConstructBinaryString ( int N , int M , int K ) { if ( M < ( N - 1 ) || M > K * ( N + 1 ) ) return " - 1" ; string ans = " " ; int l = min ( K , M / ( N - 1 ) ) ; int temp = N ; while ( temp -- ) { ans += '0' ; if ( temp == 0 ) break ; for ( int i = 0 ; i < l ; i ++ ) { ans += '1' ; } } M -= ( N - 1 ) * l ; if ( M == 0 ) return ans ; l = min ( M , K ) ; for ( int i = 0 ; i < l ; i ++ ) ans += '1' ; M -= l ; while ( M > 0 ) { ans = '1' + ans ; M -- ; } return ans ; } int main ( ) { int N = 5 , M = 9 , K = 2 ; cout << ConstructBinaryString ( N , M , K ) ; }

Accumulator variables: M, ans, i, stdc, temp
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void number ( int num ) { int a [ 20 ] , r , i = 0 , j ; while ( num > 0 ) { r = num % 10 ; if ( 9 - r > r ) a [ i ] = r ; else a [ i ] = 9 - r ; i ++ ; num = num / 10 ; } if ( a [ i - 1 ] == 0 ) { cout << 9 ; i -- ; } for ( j = i - 1 ; j >= 0 ; j -- ) cout << a [ j ] ; } int main ( ) { long long int num = 4545 ; number ( num ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isDivisible ( int N ) { return ( N - 1 ) % 3 != 0 ; } int main ( ) { int N = 6 ; if ( isDivisible ( N ) ) cout << ( " Yes " ) ; else cout << ( " No " ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countDigitSum ( int N , int K ) { int l = ( int ) pow ( 10 , N - 1 ) , r = ( int ) pow ( 10 , N ) - 1 ; int count = 0 ; for ( int i = l ; i <= r ; i ++ ) { int num = i ; int digits [ N ] ; for ( int j = N - 1 ; j >= 0 ; j -- ) { digits [ j ] = num % 10 ; num /= 10 ; } int sum = 0 , flag = 0 ; for ( int j = 0 ; j < K ; j ++ ) sum += digits [ j ] ; for ( int j = 1 ; j < N - K + 1 ; j ++ ) { int curr_sum = 0 ; for ( int m = j ; m < j + K ; m ++ ) curr_sum += digits [ m ] ; if ( sum != curr_sum ) { flag = 1 ; break ; } } if ( flag == 0 ) { count ++ ; } } return count ; } int main ( ) { int N = 2 , K = 1 ; cout << countDigitSum ( N , K ) ; return 0 ; }

Index/key variables: N, j, m
Accumulator variables: count, curr_sum, i, j, m, num, stdc, sum
Iterator variables: i, j, m
C++ program:
#include <bits/stdc++.h>
using namespace std ; int noOfFactors ( int N ) { if ( N == 1 ) return 1 ; int count = 0 ; int ans = 1 ; while ( N % 2 == 0 ) { count ++ ; N = N / 2 ; } ans *= ( count / 2 + 1 ) ; for ( int i = 3 ; i * i <= N ; i = i + 2 ) { count = 0 ; while ( N % i == 0 ) { count ++ ; N = N / i ; } ans *= ( count / 2 + 1 ) ; } return ans ; } int main ( ) { int N = 100 ; cout << noOfFactors ( N ) ; return 0 ; }

Accumulator variables: ans, count, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void DFS ( int U , int * vis , vector < int > adj [ ] ) { vis [ U ] = 1 ; for ( int V : adj [ U ] ) { if ( vis [ V ] == 0 ) DFS ( V , vis , adj ) ; } } void minCost ( int N , int M , int vCost , int eCost , int sorc [ ] , vector < int > colored , int destination [ ] ) { vector < int > adj [ N + 1 ] ; for ( int i = 0 ; i < M ; i ++ ) { adj [ sorc [ i ] ] . push_back ( destination [ i ] ) ; adj [ destination [ i ] ] . push_back ( sorc [ i ] ) ; } int vis [ N + 1 ] = { 0 } ; for ( int i = 0 ; i < colored . size ( ) ; i ++ ) { DFS ( colored [ i ] , vis , adj ) ; } int X = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { if ( vis [ i ] == 0 ) { X ++ ; DFS ( i , vis , adj ) ; } } int mincost = X * min ( vCost , eCost ) ; cout << mincost << endl ; } int main ( ) { int N = 3 , M = 1 ; int sorc [ ] = { 1 } ; int destination [ ] = { 2 } ; int vCost = 3 , eCost = 2 ; vector < int > colored = { 1 } ; minCost ( N , M , vCost , eCost , sorc , colored , destination ) ; return 0 ; }

Index/key variables: U, V, i
Accumulator variables: X, i, stdc
Iterator variables: V, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int min_cost ( int n , int x , int p , int q ) { if ( x == 1 ) { cout << ( n - 1 ) * p << endl ; return 0 ; } int ans = ( n - 1 ) * p ; int pre = 0 ; while ( n > 1 ) { int tmp = n / x ; if ( tmp < 0 ) break ; pre += ( n - tmp * x ) * p ; n /= x ; pre += q ; ans = min ( ans , pre + ( n - 1 ) * p ) ; } return ans ; } int main ( ) { int n = 5 , x = 2 , p = 2 , q = 3 ; cout << min_cost ( n , x , p , q ) ; return 0 ; }

Accumulator variables: n, pre, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int calculateWays ( int arr1 [ ] , int arr2 [ ] , int N ) { int A = arr2 [ 0 ] , B = arr2 [ 1 ] ; int C = arr2 [ 2 ] , D = arr2 [ 3 ] ; int ans = 0 ; for ( int b = 0 ; b <= B && b * 5 <= ( N ) ; b ++ ) for ( int c = 0 ; c <= C && b * 5 + c * 10 <= ( N ) ; c ++ ) for ( int d = 0 ; d <= D && b * 5 + c * 10 + d * 20 <= ( N ) ; d ++ ) if ( ( b * 5 ) + ( c * 10 ) + ( d * 20 ) >= ( N - A ) ) ans ++ ; return ans ; } int main ( ) { int N = 123 ; int arr1 [ ] = { 1 , 5 , 10 , 20 } ; int arr2 [ ] = { 6 , 4 , 3 , 5 } ; cout << calculateWays ( arr1 , arr2 , N ) ; return 0 ; }

Accumulator variables: ans, b, c, d, stdc
Iterator variables: b, c, d
C++ program:
#include <bits/stdc++.h>
using namespace std ; int ways [ 1010 ] ; int calculateWays ( int arr1 [ ] , int arr2 [ ] , int N ) { int A = arr2 [ 0 ] , B = arr2 [ 1 ] ; int C = arr2 [ 2 ] , D = arr2 [ 3 ] ; int ans = 0 ; for ( int b = 0 ; b <= B && b * 5 <= N ; b ++ ) { for ( int a = 0 ; a <= A && a * 1 + b * 5 <= N ; a ++ ) { ways [ a + b * 5 ] ++ ; } } for ( int c = 0 ; c <= C && c * 10 <= ( N ) ; c ++ ) { for ( int d = 0 ; d <= D && c * 10 + d * 20 <= ( N ) ; d ++ ) { ans += ways [ N - c * 10 - d * 20 ] ; } } return ans ; } int main ( ) { int N = 123 ; int arr1 [ ] = { 1 , 5 , 10 , 20 } ; int arr2 [ ] = { 6 , 4 , 3 , 5 } ; cout << calculateWays ( arr1 , arr2 , N ) ; return 0 ; }

Accumulator variables: a, ans, b, c, d, stdc
Iterator variables: a, b, c, d
C++ program:
#include <bits/stdc++.h>
using namespace std ; void countMissingNum ( int a [ ] , int N ) { int count = a [ N - 1 ] - a [ 0 ] + 1 - N ; cout << count << endl ; } int main ( ) { int arr [ ] = { 5 , 10 , 20 , 40 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; countMissingNum ( arr , N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; int maxXORSubsequence ( int arr [ ] , int n ) { int odd = 0 , even = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] & 1 ) odd ++ ; else even ++ ; } int maxlen ; if ( odd == n ) { if ( odd % 2 == 0 ) maxlen = n - 1 ; else maxlen = n ; } else if ( even == n ) { maxlen = 0 ; } else { if ( odd % 2 == 0 ) maxlen = even + odd - 1 ; else maxlen = even + odd ; } } int main ( ) { int arr [ ] = { 2 , 3 , 4 , 5 , 6 , 7 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << maxXORSubsequence ( arr , n ) ; }

Index/key variables: i
Accumulator variables: even, i, odd
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int good_pair ( string str [ ] , int N ) { int countStr = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { string res = str [ i ] + str [ j ] ; int vowel [ 5 ] = { 0 } ; for ( int k = 0 ; k < res . length ( ) ; k ++ ) { if ( res [ k ] == ' a ' ) vowel [ 0 ] = 1 ; else if ( res [ k ] == ' e ' ) vowel [ 1 ] = 1 ; else if ( res [ k ] == ' i ' ) vowel [ 2 ] = 1 ; else if ( res [ k ] == ' o ' ) vowel [ 3 ] = 1 ; else if ( res [ k ] == ' u ' ) vowel [ 4 ] = 1 ; } int temp = 0 ; for ( int ind = 0 ; ind < 5 ; ind ++ ) { if ( vowel [ ind ] == 1 ) temp ++ ; } if ( temp == 5 ) countStr ++ ; } } return countStr ; } int main ( ) { string arr [ ] = { " aaweiolkju " , " oxdfgujkmi " } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << good_pair ( arr , N ) ; }

Index/key variables: i, ind, j, k
Accumulator variables: countStr, i, ind, j, k, stdc, temp
Iterator variables: i, ind, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; void sieveOfEratosthenes ( int N , int s [ ] ) { vector < bool > prime ( N + 1 , false ) ; for ( int i = 2 ; i <= N ; i += 2 ) s [ i ] = 2 ; for ( int i = 3 ; i <= N ; i += 2 ) { if ( prime [ i ] == false ) { s [ i ] = i ; for ( int j = i ; j * i <= N ; j += 2 ) { if ( prime [ i * j ] == false ) { prime [ i * j ] = true ; s [ i * j ] = i ; } } } } } int generatePrimeFactors ( int N ) { int s [ N + 1 ] ; int sum = 0 ; sieveOfEratosthenes ( N , s ) ; int curr = s [ N ] ; int cnt = 1 ; while ( N > 1 ) { N /= s [ N ] ; if ( curr == s [ N ] ) { cnt ++ ; continue ; } sum = sum + cnt ; curr = s [ N ] ; cnt = 1 ; } return sum ; } void findSum ( int N ) { int sum = 0 ; for ( int i = 2 ; i <= N ; i ++ ) { sum += generatePrimeFactors ( i ) ; } cout << sum << endl ; } int main ( ) { int N = 4 ; findSum ( N ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: N, cnt, i, j, stdc, sum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int LCM ( int a , int b ) { int lcm = a > b ? a : b ; while ( true ) { if ( lcm % a == 0 && lcm % b == 0 ) break ; else lcm ++ ; } return lcm ; } void findMinLCM ( int arr [ ] , int n ) { int minLCM = INT_MAX ; for ( int i = 0 ; i < n - 1 ; i ++ ) { int val = LCM ( arr [ i ] , arr [ i + 1 ] ) ; if ( val < minLCM ) { minLCM = val ; } } cout << minLCM << endl ; } int main ( ) { int arr [ ] = { 4 , 8 , 12 , 16 , 20 , 24 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; findMinLCM ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, lcm, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int find_max ( int n , int k ) { bitset < 32 > X ( 0 ) ; int cnt = 0 ; for ( int i = 31 ; i >= 0 && cnt != k ; i -- ) { if ( n & ( 1 << i ) ) { X [ i ] = 1 ; cnt ++ ; } } return X . to_ulong ( ) ; } int main ( ) { int n = 10 , k = 2 ; cout << find_max ( n , k ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: cnt, i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void convert ( string s ) { int num = 0 ; int n = s . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) num = num * 10 + ( int ( s [ i ] ) - 48 ) ; cout << num ; } int main ( ) { char s [ ] = "123" ; convert ( s ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define hell  1000000007
#define N  100005
void count_k ( vector < int > & arr , int & c_0 , int & c_1 , int & c_2 , stack < int > & ones , stack < int > & twos , stack < int > & zeros ) { for ( int i = 0 ; i < arr . size ( ) ; i ++ ) { if ( arr [ i ] % 3 == 0 ) { c_0 ++ ; zeros . push ( arr [ i ] ) ; } else if ( arr [ i ] % 3 == 1 ) { c_1 ++ ; ones . push ( arr [ i ] ) ; } else { c_2 ++ ; twos . push ( arr [ i ] ) ; } } return ; } void printArrangement ( vector < int > & arr , int & c_0 , int & c_1 , int & c_2 , stack < int > & ones , stack < int > & twos , stack < int > & zeros ) { if ( ( c_0 == 0 && c_1 != 0 && c_2 != 0 ) or c_0 > c_1 + c_2 + 1 ) { cout << " - 1" ; return ; } if ( c_0 == 0 ) { for ( int i = 0 ; i < arr . size ( ) ; i ++ ) { cout << arr [ i ] << " ▁ " ; } return ; } int i , j , ans [ N ] ; memset ( ans , -1 , sizeof ( ans ) ) ; for ( i = 1 , j = 0 ; j < c_1 ; i += 2 , j ++ ) { ans [ i ] = ones . top ( ) ; ones . pop ( ) ; } ans [ i - 1 ] = zeros . top ( ) ; zeros . pop ( ) ; c_0 -- ; for ( j = 0 ; j < c_2 ; j ++ , i += 2 ) { ans [ i ] = twos . top ( ) ; twos . pop ( ) ; } for ( int k = 0 ; c_0 > 0 ; k += 2 ) { if ( ans [ k ] == -1 ) { ans [ k ] = zeros . top ( ) ; c_0 -- ; } } for ( int i = 0 ; i < N ; i ++ ) { if ( ans [ i ] != -1 ) cout << ans [ i ] << " ▁ " ; } return ; } void solve ( int n , vector < int > & arr ) { stack < int > ones , zeros , twos ; int c_0 = 0 , c_1 = 0 , c_2 = 0 ; count_k ( arr , c_0 , c_1 , c_2 , ones , twos , zeros ) ; printArrangement ( arr , c_0 , c_1 , c_2 , ones , twos , zeros ) ; } signed main ( ) { int n = 5 ; vector < int > arr { 1 , 2 , 3 , 4 , 5 } ; solve ( n , arr ) ; return 0 ; }

Index/key variables: N, i, k
Accumulator variables: c_0, c_1, c_2, i, j, k, stdc
Iterator variables: i, j, k
C++ program:
#include <iostream>
using namespace std ; int countUniqueDigits ( int N ) { int res = 0 ; int cnt [ 10 ] = { 0 } ; while ( N > 0 ) { int rem = N % 10 ; cnt [ rem ] ++ ; N = N / 10 ; } for ( int i = 0 ; i < 10 ; i ++ ) { if ( cnt [ i ] == 1 ) { res ++ ; } } return res ; } int main ( ) { int N = 2234262 ; cout << countUniqueDigits ( N ) ; return 0 ; }

Index/key variables: i, rem
Accumulator variables: i, res
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool checkUniqueFrequency ( int arr [ ] , int n ) { unordered_map < int , int > freq ; for ( int i = 0 ; i < n ; i ++ ) { freq [ arr [ i ] ] ++ ; } unordered_set < int > uniqueFreq ; for ( auto & i : freq ) { if ( uniqueFreq . count ( i . second ) ) return false ; else uniqueFreq . insert ( i . second ) ; } return true ; } int main ( ) { int arr [ ] = { 1 , 1 , 2 , 5 , 5 } ; int n = sizeof arr / sizeof arr [ 0 ] ; bool res = checkUniqueFrequency ( arr , n ) ; if ( res ) cout << " Yes " << endl ; else cout << " No " << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; double power ( int N , int P ) { return pow ( N , P ) ; } int Log2 ( int N ) { int result = ( int ) ( log ( N ) / log ( 2 ) ) ; return result ; } double specialSum ( int n ) { double sum = n * ( n + 1 ) / 2 ; int a = Log2 ( n ) ; sum = sum + power ( 2 , a + 1 ) - 1 ; return sum ; } int main ( ) { int n = 4 ; cout << ( specialSum ( n ) ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void Permute ( vector < int > & arr , int n ) { int odd = 0 , four = 0 ; int non_four = 0 ; vector < int > ODD , FOUR , NON_FOUR ; for ( auto x : arr ) { if ( x & 1 ) { odd ++ ; ODD . push_back ( x ) ; } else if ( x % 4 == 0 ) { four ++ ; FOUR . push_back ( x ) ; } else { non_four ++ ; NON_FOUR . push_back ( x ) ; } } if ( non_four == 0 && four >= odd - 1 ) { int x = ODD . size ( ) ; int y = FOUR . size ( ) ; int i ; for ( i = 0 ; i < x ; i ++ ) { cout << ODD [ i ] << " ▁ " ; if ( i < y ) cout << FOUR [ i ] << " ▁ " ; } while ( i < y ) cout << FOUR [ i ] << " ▁ " ; cout << endl ; } else if ( non_four > 0 and four >= odd ) { int x = ODD . size ( ) ; int y = FOUR . size ( ) ; int i ; for ( i = 0 ; i < x ; i ++ ) { cout << ODD [ i ] << " ▁ " ; if ( i < y ) cout << FOUR [ i ] << " ▁ " ; } while ( i < y ) cout << FOUR [ i ] << " ▁ " ; for ( int j = 0 ; j < ( int ) NON_FOUR . size ( ) ; j ++ ) cout << NON_FOUR [ j ] << " ▁ " ; cout << endl ; } else cout << " Not ▁ Possible " << endl ; } signed main ( ) { vector < int > arr = { 2 , 7 , 1 , 8 , 2 , 8 } ; int N = sizeof ( arr ) / sizeof ( arr ) ; Permute ( arr , N ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: four, i, j, non_four, odd, stdc
Iterator variables: i, j, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findArray ( int sum , int xorr ) { if ( xorr > sum sum % 2 != xorr % 2 ) { cout << " No ▁ Array ▁ Possible STRNEWLINE " ; return ; } if ( sum == xorr ) { if ( sum == 0 ) cout << " Array ▁ is ▁ empty " << " ▁ with ▁ size ▁ 0 STRNEWLINE " ; else cout << " Array ▁ size ▁ is ▁ " << 1 << " Array is " << sum << " STRNEWLINE " ; return ; } int mid = ( sum - xorr ) / 2 ; if ( xorr & mid == 1 ) { cout << " Array ▁ size ▁ is ▁ " << 3 << " STRNEWLINE " ; cout << " Array ▁ is ▁ " << xorr << " ▁ " << mid << " ▁ " << mid << " STRNEWLINE " ; } else { cout << " Array ▁ size ▁ is ▁ " << 2 << " STRNEWLINE " ; cout << " Array ▁ is ▁ " << ( xorr + mid ) << " ▁ " << mid << " STRNEWLINE " ; } } int main ( ) { int sum = 4 , xorr = 2 ; findArray ( sum , xorr ) ; cout << " STRNEWLINE " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; string Kperiodicinteger ( string X , int N , int K ) { string temp = X ; for ( int i = 0 ; i < K ; i ++ ) { int j = i ; while ( j < N ) { X [ j ] = X [ i ] ; j += K ; } } if ( X >= temp ) { return X ; } int POS ; for ( int i = K - 1 ; i >= 0 ; i -- ) { if ( X [ i ] != '9' ) { X [ i ] ++ ; POS = i ; break ; } } for ( int i = POS + 1 ; i < K ; i ++ ) { X [ i ] = '0' ; } for ( int i = 0 ; i < K ; i ++ ) { int j = i ; while ( j < N ) { X [ j ] = X [ i ] ; j += K ; } } return X ; } int main ( ) { int N = 4 , K = 2 ; string X = "1215" ; cout << Kperiodicinteger ( X , N , K ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int N = 100000 ; int canTake ; int best ; int dp [ N ] ; bool vis [ N ] ; int dfs ( vector < vector < int > > & g , int * cost , int u , int pre ) { vis [ u ] = true ; dp [ u ] = cost [ u ] ; bool check = 1 ; int cur = cost [ u ] ; for ( auto & x : g [ u ] ) { if ( vis [ x ] && x != pre ) { check = 0 ; } else if ( ! vis [ x ] ) { check &= dfs ( g , cost , x , u ) ; cur = max ( cur , cost [ u ] + dp [ x ] ) ; } } dp [ u ] = cur ; if ( ! check ) { canTake += cost [ u ] ; } else { best = max ( best , dp [ u ] ) ; } return check ; } int FindMaxCost ( vector < vector < int > > & g , int * cost , int source ) { dfs ( g , cost , source , -1 ) ; cout << canTake + best ; } int main ( ) { int n = 5 , m = 5 ; int cost [ ] = { 2 , 2 , 8 , 6 , 9 } ; vector < vector < int > > g ( n ) ; g [ 0 ] . push_back ( 1 ) ; g [ 1 ] . push_back ( 0 ) ; g [ 0 ] . push_back ( 2 ) ; g [ 2 ] . push_back ( 0 ) ; g [ 0 ] . push_back ( 3 ) ; g [ 3 ] . push_back ( 0 ) ; g [ 1 ] . push_back ( 2 ) ; g [ 2 ] . push_back ( 1 ) ; g [ 1 ] . push_back ( 4 ) ; g [ 4 ] . push_back ( 1 ) ; int source = 1 ; FindMaxCost ( g , cost , source ) ; return 0 ; }

Index/key variables: N, u, x
Accumulator variables: canTake, check, stdc