dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define n  3
#define m  3
bool check ( int a [ n ] [ m ] , int b [ n ] [ m ] ) { for ( int i = 0 ; i < n ; i ++ ) { vector < int > v1 , v2 ; int r = i ; int col = 0 ; while ( r >= 0 && col < m ) { v1 . push_back ( a [ r ] [ col ] ) ; v2 . push_back ( b [ r ] [ col ] ) ; r -- ; col ++ ; } sort ( v1 . begin ( ) , v1 . end ( ) ) ; sort ( v2 . begin ( ) , v2 . end ( ) ) ; for ( int i = 0 ; i < v1 . size ( ) ; i ++ ) { if ( v1 [ i ] != v2 [ i ] ) return false ; } } for ( int j = 1 ; j < m ; j ++ ) { vector < int > v1 , v2 ; int r = n - 1 ; int col = j ; while ( r >= 0 && col < m ) { v1 . push_back ( a [ r ] [ col ] ) ; v2 . push_back ( b [ r ] [ col ] ) ; r -- ; col ++ ; } sort ( v1 . begin ( ) , v1 . end ( ) ) ; sort ( v2 . begin ( ) , v2 . end ( ) ) ; for ( int i = 0 ; i < v1 . size ( ) ; i ++ ) { if ( v1 [ i ] != v2 [ i ] ) return false ; } } return true ; } int main ( ) { int a [ n ] [ m ] = { { 1 , 2 , 3 } , { 4 , 5 , 6 } , { 7 , 8 , 9 } } ; int b [ n ] [ m ] = { { 1 , 4 , 7 } , { 2 , 5 , 6 } , { 3 , 8 , 9 } } ; if ( check ( a , b ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: col, i, m, n, r
Accumulator variables: col, i, j, r, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void lastDigit ( string a , string b ) { int lastDig = ( a [ a . length ( ) - 1 ] - '0' ) * ( b [ b . length ( ) - 1 ] - '0' ) ; cout << lastDig % 10 ; } int main ( ) { string a = "1234567891233" , b = "1234567891233156" ; lastDigit ( a , b ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printPalindrome ( int n ) { if ( n == 1 ) { cout << " Smallest ▁ Palindrome : ▁ 0" << endl ; cout << " Largest ▁ Palindrome : ▁ 9" ; } else { cout << " Smallest ▁ Palindrome : ▁ " << pow ( 10 , n - 1 ) + 1 ; cout << " Largest Palindrome : " } } int main ( ) { int n = 4 ; printPalindrome ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int printSum ( int a , int b ) { int res = 0 ; int temp1 = 0 , temp2 = 0 ; while ( a ) { temp1 = temp1 * 10 + ( a % 10 ) ; a /= 10 ; } a = temp1 ; while ( b ) { temp2 = temp2 * 10 + ( b % 10 ) ; b /= 10 ; } b = temp2 ; while ( a ) { int sum = ( a % 10 + b % 10 ) ; if ( sum / 10 == 0 ) res = res * 10 + sum ; else { temp1 = 0 ; while ( sum ) { temp1 = temp1 * 10 + ( sum % 10 ) ; sum /= 10 ; } sum = temp1 ; while ( sum ) { res = res * 10 + ( sum % 10 ) ; sum /= 10 ; } } a /= 10 ; b /= 10 ; } return res ; } int main ( ) { int a = 7752 , b = 8834 ; cout << printSum ( a , b ) ; return 0 ; }

Accumulator variables: a, b, stdc, sum
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countDigits ( int a , int b ) { int count = 0 ; int p = abs ( a / b ) ; if ( p == 0 ) return 1 ; while ( p > 0 ) { count ++ ; p = p / 10 ; } return count ; } int main ( ) { int a = 100 ; int b = 10 ; cout << countDigits ( a , b ) ; return 0 ; }

Accumulator variables: count, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countDigits ( int a , int b ) { return floor ( log10 ( abs ( a ) ) - log10 ( abs ( b ) ) ) + 1 ; } int main ( ) { int a = 100 ; int b = 10 ; cout << countDigits ( a , b ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int smallestOdd ( int n ) { if ( n == 1 ) return 1 ; return pow ( 10 , n - 1 ) + 1 ; } int main ( ) { int n = 4 ; cout << smallestOdd ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findNumbers ( int n ) { int odd = pow ( 10 , n ) - 1 ; int even = odd - 1 ; cout << " Even ▁ = ▁ " << even << endl ; cout << " Odd ▁ = ▁ " << odd ; } int main ( ) { int n = 4 ; findNumbers ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int smallestEven ( int n ) { if ( n == 1 ) return 0 ; return pow ( 10 , n - 1 ) ; } int main ( ) { int n = 4 ; cout << smallestEven ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxProfit ( int n , int a , int b , int x , int y ) { int res = x * ( n / a ) ; res += y * ( n / b ) ; res -= min ( x , y ) * ( n / ( ( a * b ) / __gcd ( a , b ) ) ) ; return res ; } int main ( ) { int n = 6 , a = 6 , b = 2 , x = 8 , y = 2 ; cout << maxProfit ( n , a , b , x , y ) ; return 0 ; }

Accumulator variables: res, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ll  long long int
#define MOD  1000000007
int sumOfSeries ( int n ) { ll ans = ( ll ) pow ( n % MOD , 2 ) ; return ( ans % MOD ) ; } int main ( ) { int n = 10 ; cout << sumOfSeries ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; int kthOdd ( int arr [ ] , int n , int k ) { for ( int i = 0 ; i <= n ; i ++ ) { if ( ( arr [ i ] % 2 ) == 1 ) k -- ; if ( k == 0 ) return arr [ i ] ; } return -1 ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int k = 2 ; cout << ( kthOdd ( arr , n , k ) ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, k
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int lastFiveDigits ( int n ) { n = ( n / 10000 ) * 10000 + ( ( n / 100 ) % 10 ) * 1000 + ( n % 10 ) * 100 + ( ( n / 10 ) % 10 ) * 10 + ( n / 1000 ) % 10 ; int ans = 1 ; for ( int i = 0 ; i < 5 ; i ++ ) { ans *= n ; ans %= 100000 ; } printf ( " % 05d " , ans ) ; } int main ( ) { int n = 12345 ; lastFiveDigits ( n ) ; return 0 ; }

Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#define ll  long long
using namespace std ; const int mod = 1000000007 ; ll power ( ll a , ll n ) { if ( n == 0 ) return 1 ; ll p = power ( a , n / 2 ) % mod ; p = ( p * p ) % mod ; if ( n & 1 ) { p = ( p * a ) % mod ; } return p ; } ll computeSum ( int * arr , int n ) { sort ( arr , arr + n ) ; ll sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ll maxs = ( power ( 2 , i ) - 1 + mod ) % mod ; maxs = ( maxs * arr [ i ] ) % mod ; ll mins = ( power ( 2 , n - 1 - i ) - 1 + mod ) % mod ; mins = ( mins * arr [ i ] ) % mod ; ll V = ( maxs - mins + mod ) % mod ; sum = ( sum + V ) % mod ; } return sum ; } int main ( ) { int arr [ ] = { 4 , 3 , 1 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << computeSum ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countNumbers ( int n ) { if ( n % 2 == 1 ) return 0 ; return ( 9 * pow ( 10 , n / 2 - 1 ) ) ; } int main ( ) { int n = 2 ; cout << countNumbers ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int count ( int n ) { int cnt = 0 ; int p = 1 ; while ( p <= n ) { cnt ++ ; p *= 2 ; } return cnt ; } int main ( ) { int n = 7 ; cout << count ( n ) ; return 0 ; }

Accumulator variables: cnt, p, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int KthMinValAfterMconcatenate ( int A [ ] , int N , int M , int K ) { sort ( A , A + N ) ; return ( A [ ( ( K - 1 ) / M ) ] ) ; } int main ( ) { int A [ ] = { 3 , 1 , 2 } ; int M = 3 , K = 4 ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; cout << KthMinValAfterMconcatenate ( A , N , M , K ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sumN ( int n ) { n = ( n + 1 ) / 2 ; return ( n * n ) ; } int main ( ) { int n = 3 ; cout << sumN ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countNumbers ( int n ) { return n - n / 2 - n / 3 - n / 5 - n / 7 + n / 6 + n / 10 + n / 14 + n / 15 + n / 21 + n / 35 - n / 30 - n / 42 - n / 70 - n / 105 + n / 210 ; } int main ( ) { int n = 20 ; cout << countNumbers ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxPrimes ( int n ) { return n / 2 ; } int main ( ) { int n = 17 ; cout << maxPrimes ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sum ( int n ) { return n * ( n + 1 ) * ( n + 2 ) / 3 ; } int main ( ) { int n = 2 ; cout << sum ( n ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  100005
const int MAXI = 99999999 ; void add_edge ( vector < pair < int , int > > gr [ ] , int x , int y , int weight ) { gr [ x ] . push_back ( { y , weight } ) ; gr [ y ] . push_back ( { x , weight } ) ; } int minDistance ( vector < pair < int , int > > gr [ ] , int n , int dist [ ] , int vis [ ] , int a [ ] , int k ) { priority_queue < pair < int , int > , vector < pair < int , int > > , greater < pair < int , int > > > q ; int ans = MAXI ; for ( int i = 1 ; i <= n ; i ++ ) { if ( ! a [ i ] ) continue ; for ( int j = 1 ; j <= n ; j ++ ) { dist [ j ] = MAXI ; vis [ j ] = 0 ; } dist [ i ] = 0 ; while ( ! q . empty ( ) ) q . pop ( ) ; q . push ( { 0 , i } ) ; int good = 0 ; while ( ! q . empty ( ) ) { int v = q . top ( ) . second ; q . pop ( ) ; if ( vis [ v ] ) continue ; vis [ v ] = 1 ; good += a [ v ] ; if ( dist [ v ] > ans ) break ; if ( good == 2 and a [ v ] ) { ans = min ( ans , dist [ v ] ) ; break ; } for ( int j = 0 ; j < gr [ v ] . size ( ) ; j ++ ) { int to = gr [ v ] [ j ] . first ; int weight = gr [ v ] [ j ] . second ; if ( dist [ v ] + weight < dist [ to ] ) { dist [ to ] = dist [ v ] + weight ; q . push ( { dist [ to ] , to } ) ; } } } } return ans ; } int main ( ) { int n = 5 , m = 5 ; vector < pair < int , int > > gr [ N ] ; add_edge ( gr , 1 , 2 , 3 ) ; add_edge ( gr , 1 , 2 , 3 ) ; add_edge ( gr , 2 , 3 , 4 ) ; add_edge ( gr , 3 , 4 , 1 ) ; add_edge ( gr , 4 , 5 , 8 ) ; int k = 3 ; int a [ N ] , vis [ N ] , dist [ N ] ; a [ 1 ] = a [ 3 ] = a [ 5 ] = 1 ; cout << minDistance ( gr , n , dist , vis , a , k ) ; return 0 ; }

Index/key variables: N, i, j, to, v, x, y
Accumulator variables: good, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMinimum ( int n , int m ) { int mini = m ; for ( int i = 1 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { int sec = n / i ; if ( __gcd ( m , i ) > 1 ) { return i ; } else if ( __gcd ( sec , m ) > 1 ) { mini = min ( sec , mini ) ; } } } if ( mini == m ) return -1 ; else return mini ; } int main ( ) { int n = 8 , m = 10 ; cout << findMinimum ( n , m ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int nthTerm ( int N ) { int nth = 0 , i ; for ( i = N ; i > 0 ; i -- ) { nth += pow ( i , i ) ; } return nth ; } int main ( ) { int N = 3 ; cout << nthTerm ( N ) << endl ; return 0 ; }

Accumulator variables: i, nth, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int kthSmallest ( int n , int k ) { return ( 2 * k ) ; } int main ( ) { int n = 8 , k = 4 ; cout << kthSmallest ( n , k ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isSumOfPowersOfTwo ( int n ) { if ( n % 2 == 1 ) return false ; else return true ; } int main ( ) { int n = 10 ; if ( isSumOfPowersOfTwo ( n ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMinRemoval ( int arr [ ] , int n ) { int temp , value = 0 ; int maximum = 0 ; if ( n == 1 ) return 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i != 0 && i != n - 1 ) { value = value + abs ( arr [ i ] - arr [ i + 1 ] ) ; temp = abs ( arr [ i ] - arr [ i + 1 ] ) + abs ( arr [ i ] - arr [ i - 1 ] ) - abs ( arr [ i - 1 ] - arr [ i + 1 ] ) ; } else if ( i == 0 ) { value = value + abs ( arr [ i ] - arr [ i + 1 ] ) ; temp = abs ( arr [ i ] - arr [ i + 1 ] ) ; } else temp = abs ( arr [ i ] - arr [ i - 1 ] ) ; maximum = max ( maximum , temp ) ; } return ( value - maximum ) ; } int main ( ) { int arr [ ] = { 1 , 5 , 3 , 2 , 10 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << findMinRemoval ( arr , n ) << " STRNEWLINE " ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; double getTime ( int u , int v , int x ) { double speed = u + v ; double time = x / speed ; return time ; } int main ( ) { double u = 3 , v = 3 , x = 3 ; cout << getTime ( u , v , x ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; string Permute_Digits ( string a , long long b ) { int n = a . size ( ) ; string ans = " " ; for ( int i = 0 ; i < n ; i ++ ) { set < char > temp ( a . begin ( ) , a . end ( ) ) ; if ( i == 0 ) temp . erase ( 0 ) ; for ( auto j = temp . rbegin ( ) ; j != temp . rend ( ) ; ++ j ) { string s1 = ans + * j ; string s2 = a ; s2 . erase ( s2 . find ( * j ) , 1 ) ; sort ( s2 . begin ( ) , s2 . end ( ) ) ; s1 += s2 ; if ( stoll ( s1 ) <= b ) { ans += * j ; a = s2 ; break ; } } } return ans ; } int main ( ) { string a = "123" ; int b = 222 ; cout << Permute_Digits ( a , b ) ; return 0 ; }

Accumulator variables: ans, i, s1, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int LucasSum ( int N ) { int sum = 0 ; int a = 2 , b = 1 , c ; sum += a ; while ( b <= N ) { sum += b ; int c = a + b ; a = b ; b = c ; } return sum ; } int main ( ) { int N = 20 ; cout << LucasSum ( N ) ; return 0 ; }

Accumulator variables: stdc, sum
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countNumbers ( int l , int r ) { return ( ( r / 6 ) - ( l - 1 ) / 6 ) ; } int main ( ) { int l = 1000 , r = 6000 ; cout << countNumbers ( l , r ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMinSum ( int arr [ ] , int n ) { int occ = n - 1 , sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += arr [ i ] * pow ( 2 , occ ) ; occ -- ; } return sum ; } int main ( ) { int arr [ ] = { 1 , 2 , 4 , 5 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << findMinSum ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, occ, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findPowerOfP ( int N , int p ) { int count = 0 ; int r = p ; while ( r <= N ) { count += ( N / r ) ; r = r * p ; } return count ; } vector < pair < int , int > > primeFactorsofB ( int B ) { vector < pair < int , int > > ans ; for ( int i = 2 ; B != 1 ; i ++ ) { if ( B % i == 0 ) { int count = 0 ; while ( B % i == 0 ) { B = B / i ; count ++ ; } ans . push_back ( make_pair ( i , count ) ) ; } } return ans ; } int largestPowerOfB ( int N , int B ) { vector < pair < int , int > > vec ; vec = primeFactorsofB ( B ) ; int ans = INT_MAX ; for ( int i = 0 ; i < vec . size ( ) ; i ++ ) ans = min ( ans , findPowerOfP ( N , vec [ i ] . first ) / vec [ i ] . second ) ; return ans ; } int main ( ) { cout << largestPowerOfB ( 5 , 2 ) << endl ; cout << largestPowerOfB ( 6 , 9 ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countNumbers ( int X , int Y , int N ) { int count = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { if ( ( i % X == 0 ) && ( i % Y != 0 ) ) count ++ ; } return count ; } int main ( ) { int X = 2 , Y = 3 , N = 10 ; cout << countNumbers ( X , Y , N ) ; return 0 ; }

Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getPosition ( int n , int m ) { if ( m > ( n / 2 ) ) return ( m - ( n / 2 ) ) ; return ( m + ( n / 2 ) ) ; } int main ( ) { int n = 8 , m = 5 ; cout << getPosition ( n , m ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int parity ( int a ) { return a % 3 ; } int solve ( int array [ ] , int size ) { int operations = 0 ; for ( int i = 0 ; i < size - 1 ; i ++ ) { if ( parity ( array [ i ] ) == parity ( array [ i + 1 ] ) ) { operations ++ ; if ( i + 2 < size ) { int pari1 = parity ( array [ i ] ) ; int pari2 = parity ( array [ i + 2 ] ) ; if ( pari1 == pari2 ) { if ( pari1 == 0 ) array [ i + 1 ] = 1 ; else if ( pari1 == 1 ) array [ i + 1 ] = 0 ; else array [ i + 1 ] = 1 ; } else { if ( ( pari1 == 0 && pari2 == 1 ) || ( pari1 == 1 && pari2 == 0 ) ) array [ i + 1 ] = 2 ; if ( ( pari1 == 1 && pari2 == 2 ) || ( pari1 == 2 && pari2 == 1 ) ) array [ i + 1 ] = 0 ; if ( ( pari1 == 2 && pari2 == 0 ) || ( pari1 == 0 && pari2 == 2 ) ) array [ i + 1 ] = 1 ; } } } } return operations ; } int main ( ) { int array [ ] = { 2 , 1 , 3 , 0 } ; int size = sizeof ( array ) / sizeof ( array [ 0 ] ) ; cout << solve ( array , size ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, operations, stdc
Iterator variables: i
C++ program:
#include <iostream>
#include <stack>
#define n  3
using namespace std ; void findPrefixCount ( int p_arr [ ] [ n ] , bool arr [ ] [ n ] ) { for ( int i = 0 ; i < n ; i ++ ) for ( int j = n - 1 ; j >= 0 ; j -- ) { if ( arr [ i ] [ j ] ) continue ; if ( j != n - 1 ) p_arr [ i ] [ j ] += p_arr [ i ] [ j + 1 ] ; p_arr [ i ] [ j ] += ( int ) ( ! arr [ i ] [ j ] ) ; } } int matrixOrValueOne ( bool arr [ ] [ n ] ) { int p_arr [ n ] [ n ] = { 0 } ; findPrefixCount ( p_arr , arr ) ; int count_zero_submatrices = 0 ; for ( int j = 0 ; j < n ; j ++ ) { int i = n - 1 ; stack < pair < int , int > > q ; int to_sum = 0 ; while ( i >= 0 ) { int c = 0 ; while ( q . size ( ) != 0 and q . top ( ) . first > p_arr [ i ] [ j ] ) { to_sum -= ( q . top ( ) . second + 1 ) * ( q . top ( ) . first - p_arr [ i ] [ j ] ) ; c += q . top ( ) . second + 1 ; q . pop ( ) ; } to_sum += p_arr [ i ] [ j ] ; count_zero_submatrices += to_sum ; q . push ( { p_arr [ i ] [ j ] , c } ) ; i -- ; } } return ( n * ( n + 1 ) * n * ( n + 1 ) ) / 4 - count_zero_submatrices ; } int main ( ) { bool arr [ ] [ n ] = { { 0 , 0 , 0 } , { 0 , 1 , 0 } , { 0 , 0 , 0 } } ; cout << matrixOrValueOne ( arr ) ; return 0 ; }

Index/key variables: i, j, n
Accumulator variables: c, count_zero_submatrices, i, j, to_sum
Iterator variables: i, j
C++ program:
#include <iostream>
using namespace std ; #define n  3
int submatrixXor ( int arr [ ] [ n ] ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { int top_left = ( i + 1 ) * ( j + 1 ) ; int bottom_right = ( n - i ) * ( n - j ) ; if ( ( top_left % 2 == 1 ) && ( bottom_right % 2 == 1 ) ) ans = ( ans ^ arr [ i ] [ j ] ) ; } } return ans ; } int main ( ) { int arr [ ] [ n ] = { { 6 , 7 , 13 } , { 8 , 3 , 4 } , { 9 , 7 , 6 } } ; cout << submatrixXor ( arr ) ; return 0 ; }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findDigitalRoot ( int num ) { int sum = INT_MAX , tempNum = num ; while ( sum >= 10 ) { sum = 0 ; while ( tempNum > 0 ) { sum += tempNum % 10 ; tempNum /= 10 ; } tempNum = sum ; } return sum ; } void findAnswer ( int X , int N ) { int counter = 0 ; for ( int i = 1 ; counter < N ; ++ i ) { int digitalRoot = findDigitalRoot ( i ) ; if ( digitalRoot == X ) { ++ counter ; } if ( counter == N ) { cout << i ; break ; } } } int main ( ) { int X = 1 , N = 3 ; findAnswer ( X , N ) ; return 0 ; }

Accumulator variables: stdc, sum, tempNum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findAnswer ( int X , int N ) { return ( N - 1 ) * 9 + X ; } int main ( ) { int X = 7 , N = 43 ; cout << findAnswer ( X , N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long int count ( int N , int K , int R ) { long long int sum = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { if ( i % K == R ) sum += i ; } return sum ; } int main ( ) { int N = 20 , K = 4 , R = 3 ; cout << count ( N , K , R ) ; return 0 ; }

Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getCount ( int a , int b , int c ) { int count = 0 ; for ( int i = 1 ; i <= 81 ; i ++ ) { int cr = b * pow ( i , a ) + c ; int tmp = cr ; int sm = 0 ; while ( tmp ) { sm += tmp % 10 ; tmp /= 10 ; } if ( sm == i && cr < 1e9 ) count ++ ; } return count ; } int main ( ) { int a = 3 , b = 2 , c = 8 ; cout << getCount ( a , b , c ) ; return 0 ; }

Accumulator variables: count, i, sm, stdc, tmp
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isSpiltPossible ( int n , int a [ ] ) { int sum = 0 , c1 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += a [ i ] ; if ( a [ i ] == 1 ) { c1 ++ ; } } if ( sum % 2 ) return false ; if ( ( sum / 2 ) % 2 == 0 ) return true ; if ( c1 > 0 ) return true ; else return false ; } int main ( ) { int n = 3 ; int a [ ] = { 1 , 1 , 2 } ; if ( isSpiltPossible ( n , a ) ) cout << " YES " ; else cout << " NO " ; return 0 ; }

Index/key variables: i
Accumulator variables: c1, i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void Make_tree ( int n , int d , int k ) { if ( d > n - 1 ) { cout << " No " ; return ; } vector < int > deg ( n ) ; vector < pair < int , int > > ans ; set < pair < int , int > > q ; for ( int i = 0 ; i < d ; ++ i ) { ++ deg [ i ] ; ++ deg [ i + 1 ] ; if ( deg [ i ] > k deg [ i + 1 ] > k ) { cout << " NO " << endl ; return ; } ans . push_back ( make_pair ( i , i + 1 ) ) ; } for ( int i = 1 ; i < d ; ++ i ) q . insert ( make_pair ( max ( i , d - i ) , i ) ) ; for ( int i = d + 1 ; i < n ; ++ i ) { while ( ! q . empty ( ) && deg [ q . begin ( ) -> second ] == k ) q . erase ( q . begin ( ) ) ; if ( q . empty ( ) || q . begin ( ) -> first == d ) { cout << " No " ; return ; } ++ deg [ i ] ; ++ deg [ q . begin ( ) -> second ] ; ans . push_back ( make_pair ( i , q . begin ( ) -> second ) ) ; q . insert ( make_pair ( q . begin ( ) -> first + 1 , i ) ) ; } for ( int i = 0 ; i < n - 1 ; ++ i ) cout << ans [ i ] . first + 1 << " ▁ " << ans [ i ] . second + 1 << endl ; } int main ( ) { int n = 6 , d = 3 , k = 4 ; Make_tree ( n , d , k ) ; return 0 ; }

Index/key variables: i
Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <iostream>
#define n  3
using namespace std ; int matrixSum ( int arr [ ] [ n ] ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) { int top_left = ( i + 1 ) * ( j + 1 ) ; int bottom_right = ( n - i ) * ( n - j ) ; sum += ( top_left * bottom_right * arr [ i ] [ j ] ) ; } return sum ; } int main ( ) { int arr [ ] [ n ] = { { 1 , 1 , 1 } , { 1 , 1 , 1 } , { 1 , 1 , 1 } } ; cout << matrixSum ( arr ) ; return 0 ; }

Index/key variables: i, j, n
Accumulator variables: i, j, sum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxAND ( int L , int R ) { int maximum = L & R ; for ( int i = L ; i < R ; i ++ ) for ( int j = i + 1 ; j <= R ; j ++ ) maximum = max ( maximum , ( i & j ) ) ; return maximum ; } int main ( ) { int L = 1 , R = 632 ; cout << maxAND ( L , R ) ; return 0 ; }

Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool checkArray ( int arr [ ] , int n ) { return ( arr [ 0 ] % 2 ) && ( arr [ n - 1 ] % 2 ) && ( n % 2 ) ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << ( int ) checkArray ( arr , n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; int findCount ( int arr [ ] , int n ) { int countOdd = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] % 2 == 1 ) countOdd ++ ; if ( countOdd % 2 == 0 ) return 1 ; else return 0 ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 5 , 1 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << findCount ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: countOdd, i
Iterator variables: i