dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool check ( vector < int > & arr , vector < vector < int > > & pieces ) { unordered_map < int , int > m ; for ( int i = 0 ; i < arr . size ( ) ; i ++ ) m [ arr [ i ] ] = i + 1 ; for ( int i = 0 ; i < pieces . size ( ) ; i ++ ) { if ( pieces [ i ] . size ( ) == 1 && m [ pieces [ i ] [ 0 ] ] != 0 ) { continue ; } else if ( pieces [ i ] . size ( ) > 1 && m [ pieces [ i ] [ 0 ] ] != 0 ) { int idx = m [ pieces [ i ] [ 0 ] ] - 1 ; idx ++ ; if ( idx >= arr . size ( ) ) return false ; for ( int j = 1 ; j < pieces [ i ] . size ( ) ; j ++ ) { if ( arr [ idx ] == pieces [ i ] [ j ] ) { idx ++ ; if ( idx >= arr . size ( ) && j < pieces [ i ] . size ( ) - 1 ) return false ; } else { return false ; } } } else { return false ; } } return true ; } int main ( ) { vector < int > arr = { 1 , 2 , 4 , 3 } ; vector < vector < int > > pieces { { 1 } , { 4 , 3 } , { 2 } } ; if ( check ( arr , pieces ) ) { cout << " Yes " ; } else { cout << " No " ; } return 0 ; }

Index/key variables: i, idx, j
Accumulator variables: i, idx, j, stdc
Iterator variables: i, j
C++ program:
#include <iostream>
using namespace std ; void makeArraySumEqual ( int a [ ] , int N ) { int count_0 = 0 , count_1 = 0 ; int odd_sum = 0 , even_sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( a [ i ] == 0 ) count_0 ++ ; else count_1 ++ ; if ( ( i + 1 ) % 2 == 0 ) even_sum += a [ i ] ; else if ( ( i + 1 ) % 2 > 0 ) odd_sum += a [ i ] ; } if ( odd_sum == even_sum ) { for ( int i = 0 ; i < N ; i ++ ) cout << " ▁ " << a [ i ] ; } else { if ( count_0 >= N / 2 ) { for ( int i = 0 ; i < count_0 ; i ++ ) cout << "0 ▁ " ; } else { int is_Odd = count_1 % 2 ; count_1 -= is_Odd ; for ( int i = 0 ; i < count_1 ; i ++ ) cout << "1 ▁ " ; } } } int main ( ) { int arr [ ] = { 1 , 1 , 1 , 0 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; makeArraySumEqual ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count_0, count_1, even_sum, i, odd_sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int maxm = 10001 ; bool prime [ maxm ] ; int prime_number [ maxm ] ; void SieveOfEratosthenes ( ) { memset ( prime , true , sizeof ( prime ) ) ; for ( int p = 2 ; p * p < maxm ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i < maxm ; i += p ) prime [ i ] = false ; } } prime [ 0 ] = false ; prime [ 1 ] = false ; } void num_prime ( ) { prime_number [ 0 ] = 0 ; for ( int i = 1 ; i <= maxm ; i ++ ) prime_number [ i ] = prime_number [ i - 1 ] + prime [ i ] ; } void min_steps ( int arr [ ] , int n ) { SieveOfEratosthenes ( ) ; num_prime ( ) ; if ( n == 1 ) cout << "0 STRNEWLINE " ; else if ( n == 2 ) cout << "1 STRNEWLINE " ; else cout << prime_number [ n ] - 1 + ( n - 2 ) ; } int main ( ) { int arr [ ] = { 5 , 4 , 3 , 2 , 1 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; min_steps ( arr , N ) ; return 0 ; }

Index/key variables: i, maxm, n, p
Accumulator variables: i, p, stdc
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findWinner ( int a [ ] , int n ) { int win = 0 ; if ( n % 2 == 0 ) win = 1 ; else win = 0 ; for ( int i = n - 2 ; i >= 0 ; i -- ) { if ( i % 2 == 1 ) { if ( win == 0 && a [ i ] > 1 ) win = 1 ; } else { if ( win == 1 && a [ i ] > 1 ) win = 0 ; } } if ( win == 0 ) cout << " A " ; else cout << " B " ; } int main ( ) { int arr [ ] = { 1 , 1 , 1 , 2 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; findWinner ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isReachable ( long long x1 , long long y1 , long long x2 , long long y2 ) { while ( x2 > x1 && y2 > y1 ) { if ( x2 > y2 ) x2 %= y2 ; else y2 %= x2 ; } if ( x2 == x1 ) return ( y2 - y1 ) >= 0 && ( y2 - y1 ) % x1 == 0 ; else if ( y2 == y1 ) return ( x2 - x1 ) >= 0 && ( x2 - x1 ) % y1 == 0 ; else return 0 ; } int main ( ) { long long source_x = 2 , source_y = 10 ; long long dest_x = 26 , dest_y = 12 ; if ( isReachable ( source_x , source_y , dest_x , dest_y ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void checkWinner ( int N , int K ) { if ( N % ( K + 1 ) ) { cout << " A " ; } else { cout << " B " ; } } int main ( ) { int N = 50 ; int K = 10 ; checkWinner ( N , K ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isprime [ 2000010 ] ; void SieveOfEratosthenes ( int n ) { memset ( isprime , true , sizeof ( isprime ) ) ; isprime [ 1 ] = false ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( isprime [ p ] == true ) { for ( int i = p * p ; i <= n ; i += p ) isprime [ i ] = false ; } } } int KDistinctPrime ( int arr [ ] , int n , int k ) { SieveOfEratosthenes ( 2000000 ) ; map < int , int > cnt ; int result = -1 ; for ( int i = 0 , j = -1 ; i < n ; ++ i ) { int x = arr [ i ] ; if ( isprime [ x ] ) { if ( ++ cnt [ x ] == 1 ) { -- k ; } } while ( k < 0 ) { x = arr [ ++ j ] ; if ( isprime [ x ] ) { if ( -- cnt [ x ] == 0 ) { ++ k ; } } } if ( k == 0 ) result = max ( result , i - j ) ; } return result ; } int main ( void ) { int arr [ ] = { 1 , 2 , 3 , 3 , 4 , 5 , 6 , 7 , 8 , 9 } ; int K = 3 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << KDistinctPrime ( arr , N , K ) ; return 0 ; }

Index/key variables: i, p, x
Accumulator variables: i, p, stdc
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX_SIZE  1000005
void SieveOfEratosthenes ( vector < int > & StorePrimes ) { bool IsPrime [ MAX_SIZE ] ; memset ( IsPrime , true , sizeof ( IsPrime ) ) ; for ( int p = 2 ; p * p < MAX_SIZE ; p ++ ) { if ( IsPrime [ p ] == true ) { for ( int i = p * p ; i < MAX_SIZE ; i += p ) IsPrime [ i ] = false ; } } for ( int p = 2 ; p < MAX_SIZE ; p ++ ) if ( IsPrime [ p ] ) StorePrimes . push_back ( p ) ; } int Smallest_non_Prime ( vector < int > StorePrimes , int N ) { int x = StorePrimes [ N ] ; return x * x ; } int main ( ) { int N = 3 ; vector < int > StorePrimes ; SieveOfEratosthenes ( StorePrimes ) ; cout << Smallest_non_Prime ( StorePrimes , N ) ; return 0 ; }

Index/key variables: MAX_SIZE, N, i, p
Accumulator variables: i, p, stdc
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std ; #define lli  long long int
void printSubset ( lli n , int k ) { vector < lli > answer ; while ( n > 0 ) { lli p = log2 ( n ) ; answer . push_back ( pow ( k , p ) ) ; n %= ( int ) pow ( 2 , p ) ; } reverse ( answer . begin ( ) , answer . end ( ) ) ; for ( auto x : answer ) { cout << x << " ▁ " ; } } int main ( ) { lli n = 5 ; int k = 4 ; printSubset ( n , k ) ; }

Accumulator variables: stdc
Iterator variables: x
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define maxN  100000
vector < int > graph [ maxN ] ; int indegree [ maxN ] ; int job [ maxN ] ; void addEdge ( int u , int v ) { graph [ u ] . push_back ( v ) ; indegree [ v ] ++ ; } void printOrder ( int n , int m ) { queue < int > q ; for ( int i = 1 ; i <= n ; i ++ ) { if ( indegree [ i ] == 0 ) { q . push ( i ) ; job [ i ] = 1 ; } } while ( ! q . empty ( ) ) { int cur = q . front ( ) ; q . pop ( ) ; for ( int adj : graph [ cur ] ) { indegree [ adj ] -- ; if ( indegree [ adj ] == 0 ) { job [ adj ] = job [ cur ] + 1 ; q . push ( adj ) ; } } } for ( int i = 1 ; i <= n ; i ++ ) cout << job [ i ] << " ▁ " ; cout << " STRNEWLINE " ; } int main ( ) { int n , m ; n = 10 ; m = 13 ; addEdge ( 1 , 3 ) ; addEdge ( 1 , 4 ) ; addEdge ( 1 , 5 ) ; addEdge ( 2 , 3 ) ; addEdge ( 2 , 8 ) ; addEdge ( 2 , 9 ) ; addEdge ( 3 , 6 ) ; addEdge ( 4 , 6 ) ; addEdge ( 4 , 8 ) ; addEdge ( 5 , 8 ) ; addEdge ( 6 , 7 ) ; addEdge ( 7 , 8 ) ; addEdge ( 8 , 10 ) ; printOrder ( n , m ) ; return 0 ; }

Index/key variables: adj, cur, i, maxN, u, v
Accumulator variables: i, stdc
Iterator variables: adj, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printPermutation ( int arr [ ] , int n ) { vector < int > odd , even ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 == 0 ) even . push_back ( arr [ i ] ) ; else odd . push_back ( arr [ i ] ) ; } int size_odd = odd . size ( ) ; int size_even = even . size ( ) ; if ( size_odd > size_even + 1 ) cout << -1 << endl ; else { int i = 0 ; int j = 0 ; while ( i < size_odd && j < size_even ) { cout << odd [ i ] << " ▁ " ; ++ i ; cout << even [ j ] << " ▁ " ; ++ j ; } while ( i < size_odd ) { cout << odd [ i ] << " ▁ " ; ++ i ; } while ( j < size_even ) { cout << even [ j ] << " ▁ " ; } } } int main ( ) { int arr [ ] = { 6 , 7 , 9 , 8 , 10 , 11 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; printPermutation ( arr , N ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void find ( int n ) { cout << n / 2 << endl ; } int main ( ) { int n = 5 ; find ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; map < int , int > rem [ 11 ] ; int countPairs ( vector < int > a , int n , int k ) { vector < int > len ( n ) ; vector < int > p ( 11 ) ; p [ 0 ] = 1 ; for ( int i = 1 ; i <= 10 ; i ++ ) { p [ i ] = ( p [ i - 1 ] * 10 ) % k ; } for ( int i = 0 ; i < n ; i ++ ) { int x = a [ i ] ; while ( x > 0 ) { len [ i ] ++ ; x /= 10 ; } rem [ len [ i ] ] [ a [ i ] % k ] ++ ; } int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 1 ; j <= 10 ; j ++ ) { int r = ( a [ i ] * p [ j ] ) % k ; int xr = ( k - r ) % k ; ans += rem [ j ] [ xr ] ; if ( len [ i ] == j && ( r + a [ i ] % k ) % k == 0 ) ans -- ; } } return ans ; } int main ( ) { vector < int > a = { 4 , 5 , 2 } ; int n = a . size ( ) , k = 2 ; cout << countPairs ( a , n , k ) ; }

Index/key variables: i, j, xr
Accumulator variables: ans, i, j, stdc, x
Iterator variables: i, j
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 = K ; j < N ; j ++ ) { if ( sum - digits [ j - K ] + digits [ j ] != sum ) { flag = 1 ; break ; } } if ( flag == 0 ) count ++ ; } return count ; } int main ( ) { int N = 2 , K = 1 ; cout << countDigitSum ( N , K ) << endl ; return 0 ; }

Index/key variables: N, j
Accumulator variables: count, i, j, num, stdc, sum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < int > calculate ( int * arr , int n ) { vector < int > ans ; for ( int i = 0 ; i < n ; i ++ ) { int sum = 0 ; for ( int j = 0 ; j < n ; j ++ ) { sum += abs ( arr [ i ] - arr [ j ] ) ; } ans . push_back ( sum ) ; } return ans ; } int main ( ) { int arr [ ] = { 2 , 3 , 5 , 6 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; vector < int > ans = calculate ( arr , n ) ; cout << " [ " ; for ( auto itr : ans ) cout << itr << " , ▁ " ; cout << " ] " ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc, sum
Iterator variables: i, itr, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void dfs ( vector < int > graph [ ] , bool visited [ ] , int x , int * k ) { for ( int i = 0 ; i < graph [ x ] . size ( ) ; i ++ ) { if ( ! visited [ graph [ x ] [ i ] ] ) { ( * k ) ++ ; visited [ graph [ x ] [ i ] ] = true ; dfs ( graph , visited , graph [ x ] [ i ] , k ) ; } } } int countNonAccessible ( vector < int > graph [ ] , int N ) { bool visited [ N * N + N ] ; memset ( visited , false , sizeof ( visited ) ) ; int ans = 0 ; for ( int i = 1 ; i <= N * N ; i ++ ) { if ( ! visited [ i ] ) { visited [ i ] = true ; int k = 1 ; dfs ( graph , visited , i , & k ) ; ans += k * ( N * N - k ) ; } } return ans ; } void insertpath ( vector < int > graph [ ] , int N , int x1 , int y1 , int x2 , int y2 ) { int a = ( x1 - 1 ) * N + y1 ; int b = ( x2 - 1 ) * N + y2 ; graph [ a ] . push_back ( b ) ; graph [ b ] . push_back ( a ) ; } int main ( ) { int N = 2 ; vector < int > graph [ N * N + 1 ] ; insertpath ( graph , N , 1 , 1 , 1 , 2 ) ; insertpath ( graph , N , 1 , 2 , 2 , 2 ) ; cout << countNonAccessible ( graph , N ) << endl ; return 0 ; }

Index/key variables: a, b, i, x
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findMinimum ( string s ) { int n = s . size ( ) ; int x [ n + 1 ] = { 0 } ; reverse ( s . begin ( ) , s . end ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == '1' ) { if ( x [ i ] == 1 ) { x [ i + 1 ] = 1 ; x [ i ] = 0 ; } else if ( i and x [ i - 1 ] == 1 ) { x [ i + 1 ] = 1 ; x [ i - 1 ] = -1 ; } else x [ i ] = 1 ; } } int c = 0 ; for ( int i = 0 ; i <= n ; i ++ ) { if ( x [ i ] != 0 ) c ++ ; } cout << c << endl ; } int main ( ) { string str = "111" ; findMinimum ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: c, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define LL  long long
bool splitIntoFibonacciHelper ( int pos , string S , vector < int > & seq ) { if ( pos == S . length ( ) and ( seq . size ( ) >= 3 ) ) { return true ; } LL num = 0 ; for ( int i = pos ; i < S . length ( ) ; i ++ ) { num = num * 10 + ( S [ i ] - '0' ) ; if ( num > INT_MAX ) break ; if ( S [ pos ] == '0' and i > pos ) break ; if ( seq . size ( ) > 2 and ( num > ( ( LL ) seq . back ( ) + ( LL ) seq [ seq . size ( ) - 2 ] ) ) ) break ; if ( seq . size ( ) < 2 or ( num == ( ( LL ) seq . back ( ) + ( LL ) seq [ seq . size ( ) - 2 ] ) ) ) { seq . push_back ( num ) ; if ( splitIntoFibonacciHelper ( i + 1 , S , seq ) ) return true ; seq . pop_back ( ) ; } } return false ; } void splitIntoFibonacci ( string S ) { vector < int > seq ; splitIntoFibonacciHelper ( 0 , S , seq ) ; if ( seq . size ( ) >= 3 ) { for ( int i : seq ) cout << i << " ▁ " ; } else { cout << -1 ; } } int main ( ) { string S = "11235813" ; splitIntoFibonacci ( S ) ; return 0 ; }

Index/key variables: i, pos
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int good_pairs ( string str [ ] , int N ) { int arr [ 32 ] = { 0 } , strCount = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int Weight = 0 ; for ( int j = 0 ; j < str [ i ] . size ( ) ; j ++ ) { switch ( str [ i ] [ j ] ) { case ' a ' : Weight = Weight | 1 ; break ; case ' e ' : Weight = Weight | 2 ; break ; case ' i ' : Weight = Weight | 4 ; break ; case ' o ' : Weight = Weight | 8 ; break ; case ' u ' : Weight = Weight | 16 ; break ; } } arr [ Weight ] ++ ; } for ( int i = 0 ; i < 32 ; i ++ ) { for ( int j = i + 1 ; j < 32 ; j ++ ) { if ( ( i j ) == 31 ) strCount += arr [ i ] * arr [ j ] ; } } strCount += ( arr [ 31 ] * ( arr [ 31 ] - 1 ) ) / 2 ; return strCount ; } int main ( ) { string str [ ] = { " aaweiolkju " , " oxdfgujkmi " } ; int N = sizeof ( str ) / sizeof ( str [ 0 ] ) ; cout << good_pairs ( str , N ) ; return 0 ; }

Index/key variables: Weight, i, j
Accumulator variables: i, j, stdc, strCount
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void solve ( vector < int > & arr , int r , int c ) { int idx = 1 ; int dp [ r ] ; for ( int i = 0 ; i < r ; i ++ ) { if ( i % 2 == 0 ) { for ( int j = 0 ; j < c ; j ++ ) { if ( arr [ idx - 1 ] == 0 ) idx ++ ; dp [ i ] [ j ] = idx ; arr [ idx - 1 ] -- ; } } else { for ( int j = c - 1 ; j >= 0 ; j -- ) { if ( arr [ idx - 1 ] == 0 ) idx ++ ; dp [ i ] [ j ] = idx ; arr [ idx - 1 ] -- ; } } } for ( int i = 0 ; i < r ; ++ i ) { for ( int j = 0 ; j < c ; ++ j ) { cout << dp [ i ] [ j ] << " ▁ " ; } cout << endl ; } } int main ( ) { int r = 3 , c = 5 ; int n = 5 ; vector < int > arr = { 1 , 2 , 3 , 4 , 5 } ; solve ( arr , r , c ) ; return 0 ; }

Index/key variables: i, j, r
Accumulator variables: i, idx, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int count ( int k , string s ) { int ar [ s . length ( ) ] ; int end = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s [ i ] == '1' ) { for ( int j = i ; j < s . length ( ) && j <= i + k ; j ++ ) { ar [ j ] = -1 ; end = j ; } i = end ; } } end = 0 ; for ( int i = s . length ( ) - 1 ; i >= 0 ; i -- ) { if ( s [ i ] == '1' ) { for ( int j = i ; j >= 0 && j >= i - k ; j -- ) { ar [ j ] = -1 ; end = j ; } i = end ; } } int ans = 0 ; end = 0 ; for ( int j = 0 ; j < s . length ( ) ; j ++ ) { if ( ar [ j ] == 0 ) { ans ++ ; for ( int g = j ; g <= j + k && g < s . length ( ) ; g ++ ) { ar [ g ] = -1 ; end = g ; } j = end - 1 ; } } return ans ; } int main ( ) { int K = 2 ; string s = "000000" ; cout << count ( K , s ) << endl ; return 0 ; }

Index/key variables: g, i, j
Accumulator variables: ans, g, i, j, stdc
Iterator variables: g, i, j
C++ program:
#include <bits/stdc++.h>
#define row  6
#define col  7
using namespace std ; int vis [ row + 1 ] [ col + 1 ] , id ; int diameter = 0 , length = 0 ; int dx [ ] = { -1 , 1 , 0 , 0 } ; int dy [ ] = { 0 , 0 , -1 , 1 } ; void dfs ( int a , int b , int lis [ ] [ col ] , int & x , int & y ) { vis [ a ] [ b ] = id ; length ++ ; if ( length > diameter ) { x = a ; y = b ; diameter = length ; } for ( int j = 0 ; j < 4 ; j ++ ) { int cx = a + dx [ j ] ; int cy = b + dy [ j ] ; if ( cx < 0 cy < 0 cx > = row cy > = col lis [ cx ] [ cy ] == 0 vis [ cx ] [ cy ] ) { continue ; } dfs ( cx , cy , lis , x , y ) ; } vis [ a ] [ b ] = 0 ; length -- ; } void findMaximumLength ( int lis [ ] [ col ] ) { int x , y ; id ++ ; length = 0 ; diameter = 0 ; for ( int i = 0 ; i < row ; i ++ ) { for ( int j = 0 ; j < col ; j ++ ) { if ( lis [ i ] [ j ] != 0 ) { dfs ( i , j , lis , x , y ) ; i = row ; break ; } } } id ++ ; length = 0 ; diameter = 0 ; dfs ( x , y , lis , x , y ) ; cout << diameter ; } int main ( ) { int grid [ ] [ col ] = { { 0 , 0 , 0 , 0 , 0 , 0 , 0 } , { 0 , 1 , 0 , 1 , 0 , 0 , 0 } , { 0 , 1 , 0 , 1 , 0 , 0 , 0 } , { 0 , 1 , 0 , 1 , 0 , 1 , 0 } , { 0 , 1 , 1 , 1 , 1 , 1 , 0 } , { 0 , 0 , 0 , 1 , 0 , 0 , 0 } } ; findMaximumLength ( grid ) ; return 0 ; }

Index/key variables: a, b, col, cx, cy, i, j
Accumulator variables: i, id, j, length, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; string get_last_two_digit ( int N ) { if ( N % 4 == 0 ) return "01" ; else if ( N % 4 == 1 ) return "07" ; else if ( N % 4 == 2 ) return "49" ; return "43" ; } int main ( ) { int N = 12 ; cout << get_last_two_digit ( N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void getSubsequence ( vector < int > ar ) { int N = ar . size ( ) ; vector < int > ans ; ans . push_back ( ar [ 0 ] ) ; for ( int i = 1 ; i < N - 1 ; i ++ ) { if ( ar [ i ] > ar [ i - 1 ] ) { if ( i < N - 1 && ar [ i ] <= ar [ i + 1 ] ) { continue ; } else { ans . push_back ( ar [ i ] ) ; } } else { if ( i < N - 1 && ar [ i + 1 ] < ar [ i ] ) { continue ; } else { ans . push_back ( ar [ i ] ) ; } } } ans . push_back ( ar [ N - 1 ] ) ; for ( auto & it : ans ) cout << it << ' ▁ ' ; } int main ( ) { vector < int > arr = { 1 , 2 , 4 , 3 , 5 } ; getSubsequence ( arr ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int dfs ( vector < int > g [ ] , int & curMax , int u , int v ) { int max1 = 0 , max2 = 0 , total = 0 ; for ( int i = 0 ; i < g [ u ] . size ( ) ; i ++ ) { if ( g [ u ] [ i ] == v ) continue ; total = max ( total , dfs ( g , curMax , g [ u ] [ i ] , u ) ) ; if ( curMax > max1 ) { max2 = max1 ; max1 = curMax ; } else max2 = max ( max2 , curMax ) ; } total = max ( total , max1 + max2 ) ; curMax = max1 + 1 ; return total ; } int maxProductOfTwoPaths ( vector < int > g [ ] , int N ) { int res = INT_MIN ; int path1 , path2 ; for ( int i = 1 ; i < N + 2 ; i ++ ) { for ( int j = 0 ; j < g [ i ] . size ( ) ; j ++ ) { int curMax = 0 ; path1 = dfs ( g , curMax , g [ i ] [ j ] , i ) ; curMax = 0 ; path2 = dfs ( g , curMax , i , g [ i ] [ j ] ) ; res = max ( res , path1 * path2 ) ; } } return res ; } void addEdge ( vector < int > g [ ] , int u , int v ) { g [ u ] . push_back ( v ) ; g [ v ] . push_back ( u ) ; } int main ( ) { int edges [ ] [ 2 ] = { { 1 , 8 } , { 2 , 6 } , { 3 , 1 } , { 5 , 3 } , { 7 , 8 } , { 8 , 4 } , { 8 , 6 } } ; int N = sizeof ( edges ) / sizeof ( edges [ 0 ] ) ; vector < int > g [ N + 2 ] ; for ( int i = 0 ; i < N ; i ++ ) addEdge ( g , edges [ i ] [ 0 ] , edges [ i ] [ 1 ] ) ; cout << maxProductOfTwoPaths ( g , N ) << endl ; return 0 ; }

Index/key variables: i, j, u, v
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int Minsteps ( int n ) { int ans = 0 ; while ( n > 1 ) { if ( n % 5 == 0 ) { ans ++ ; n = n / 5 ; continue ; } else if ( n % 4 == 0 ) { ans ++ ; n = n / 4 ; continue ; } else if ( n % 3 == 0 ) { ans ++ ; n = n / 3 ; continue ; } else if ( n % 2 == 0 ) { ans ++ ; n = n / 2 ; continue ; } return -1 ; } return ans ; } int main ( ) { int n = 10 ; cout << Minsteps ( n ) ; return 0 ; }

Accumulator variables: ans, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minDifference ( int num ) { string maximum = to_string ( num ) ; string minimum = to_string ( num ) ; int n = maximum . size ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( maximum [ i ] != '9' ) { char digit = maximum [ i ] ; for ( int j = i ; j < n ; j ++ ) { if ( maximum [ j ] == digit ) maximum [ j ] = '9' ; } break ; } } if ( minimum [ 0 ] == '1' ) { for ( int i = 1 ; i < n ; i ++ ) { if ( minimum [ i ] - '0' > 1 ) { char digit = minimum [ i ] ; for ( int j = i ; j < n ; j ++ ) { if ( digit == minimum [ j ] ) minimum [ j ] = '0' ; } break ; } } } else { char digit = minimum [ 0 ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( minimum [ i ] == digit ) minimum [ i ] = '1' ; } } return ( stoi ( maximum ) - stoi ( minimum ) ) ; } int main ( ) { int N = 1101157 ; cout << minDifference ( N ) ; 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 checkDivisible ( int x , int k ) { int g = __gcd ( x , k ) ; k /= g ; if ( x % k == 0 ) { cout << " YES STRNEWLINE " ; } else { cout << " NO STRNEWLINE " ; } } int main ( ) { int x = 6 , k = 9 ; checkDivisible ( x , k ) ; return 0 ; }

Accumulator variables: k, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int MinimumValue ( int arr [ ] , int n ) { sort ( arr , arr + n ) ; int minXor = INT_MAX ; int val = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { val = arr [ i ] ^ arr [ i + 1 ] ; minXor = min ( minXor , val ) ; } return minXor ; } int main ( ) { int N = 6 ; int A [ N ] = { 12 , 3 , 14 , 5 , 9 , 8 } ; cout << MinimumValue ( A , N ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxNormalSubstring ( string & P , string & Q , int K , int N ) { if ( K == 0 ) return 0 ; int count = 0 ; int left = 0 , right = 0 ; int ans = 0 ; while ( right < N ) { while ( right < N && count <= K ) { int pos = P [ right ] - ' a ' ; if ( Q [ pos ] == '0' ) { if ( count + 1 > K ) break ; else count ++ ; } right ++ ; if ( count <= K ) ans = max ( ans , right - left ) ; } while ( left < right ) { int pos = P [ left ] - ' a ' ; left ++ ; if ( Q [ pos ] == '0' ) count -- ; if ( count < K ) break ; } } return ans ; } int main ( ) { string P = " giraffe " , Q = "01111001111111111011111111" ; int K = 2 ; int N = P . length ( ) ; cout << maxNormalSubstring ( P , Q , K , N ) ; return 0 ; }

Index/key variables: left, pos, right
Accumulator variables: count, left, right, stdc