dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <iostream>
using namespace std ; bool isAutomorphic ( int N ) { int sq = N * N ; while ( N > 0 ) { if ( N % 10 != sq % 10 ) return false ; N /= 10 ; sq /= 10 ; } return true ; } int main ( ) { int N = 5 ; isAutomorphic ( N ) ? cout << " Automorphic " : cout << " Not ▁ Automorphic " ; return 0 ; }

Accumulator variables: N, sq
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxPrimefactorNum ( int N ) { bool arr [ N + 5 ] ; memset ( arr , true , sizeof ( arr ) ) ; for ( int i = 3 ; i * i <= N ; i += 2 ) { if ( arr [ i ] ) for ( int j = i * i ; j <= N ; j += i ) arr [ j ] = false ; } vector < int > prime ; prime . push_back ( 2 ) ; for ( int i = 3 ; i <= N ; i += 2 ) if ( arr [ i ] ) prime . push_back ( i ) ; int i = 0 , ans = 1 ; while ( ans * prime [ i ] <= N && i < prime . size ( ) ) { ans *= prime [ i ] ; i ++ ; } return ans ; } int main ( ) { int N = 40 ; cout << maxPrimefactorNum ( N ) << endl ; return 0 ; }

Index/key variables: i, j
Accumulator variables: ans, i, j, stdc
Iterator variables: i, j
C++ program:
#include <iostream>
using namespace std ; unsigned highestPowerof2 ( unsigned x ) { x |= x >> 1 ; x |= x >> 2 ; x |= x >> 4 ; x |= x >> 8 ; x |= x >> 16 ; return x ^ ( x >> 1 ) ; } int main ( ) { int n = 10 ; cout << highestPowerof2 ( n ) << " STRNEWLINE " ; return 0 ; }

Accumulator variables: x
C++ program:
#include <bits/stdc++.h>
using namespace std ; int divSum ( int num ) { int result = 0 ; if ( num == 1 ) return result ; for ( int i = 2 ; i <= sqrt ( num ) ; i ++ ) { if ( num % i == 0 ) { if ( i == ( num / i ) ) result += i ; else result += ( i + num / i ) ; } } return ( result + 1 ) ; } int main ( ) { int num = 36 ; cout << divSum ( num ) ; return 0 ; }

Accumulator variables: i, result, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int power ( int x , unsigned int y , int p ) { int res = 1 ; x = x % p ; while ( y > 0 ) { if ( y & 1 ) res = ( res * x ) % p ; x = ( x * x ) % p ; } return res ; } bool miillerTest ( int d , int n ) { int a = 2 + rand ( ) % ( n - 4 ) ; int x = power ( a , d , n ) ; if ( x == 1 x == n - 1 ) return true ; while ( d != n - 1 ) { x = ( x * x ) % n ; d *= 2 ; if ( x == 1 ) return false ; if ( x == n - 1 ) return true ; } return false ; } bool isPrime ( int n , int k ) { if ( n <= 1 n == 4 ) return false ; if ( n <= 3 ) return true ; int d = n - 1 ; while ( d % 2 == 0 ) d /= 2 ; for ( int i = 0 ; i < k ; i ++ ) if ( ! miillerTest ( d , n ) ) return false ; return true ; } int main ( ) { int k = 4 ; cout << " All ▁ primes ▁ smaller ▁ than ▁ 100 : ▁ STRNEWLINE " ; for ( int n = 1 ; n < 100 ; n ++ ) if ( isPrime ( n , k ) ) cout << n << " ▁ " ; return 0 ; }

Accumulator variables: d, i, n, stdc
Iterator variables: i, n
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxConsecutiveOnes ( int x ) { int count = 0 ; while ( x != 0 ) { x = ( x & ( x << 1 ) ) ; count ++ ; } return count ; } int main ( ) { cout << maxConsecutiveOnes ( 14 ) << endl ; cout << maxConsecutiveOnes ( 222 ) << endl ; return 0 ; }

Accumulator variables: count, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void addEdge ( vector < int > v [ ] , int x , int y ) { v [ x ] . push_back ( y ) ; v [ y ] . push_back ( x ) ; } void dfs ( vector < int > tree [ ] , vector < int > & temp , int ancestor [ ] , int u , int parent , int k ) { temp . push_back ( u ) ; for ( auto i : tree [ u ] ) { if ( i == parent ) continue ; dfs ( tree , temp , ancestor , i , u , k ) ; } temp . pop_back ( ) ; if ( temp . size ( ) < k ) { ancestor [ u ] = -1 ; } else { ancestor [ u ] = temp [ temp . size ( ) - k ] ; } } void KthAncestor ( int N , int K , int E , int edges [ ] [ 2 ] ) { vector < int > tree [ N + 1 ] ; for ( int i = 0 ; i < E ; i ++ ) { addEdge ( tree , edges [ i ] [ 0 ] , edges [ i ] [ 1 ] ) ; } vector < int > temp ; int ancestor [ N + 1 ] ; dfs ( tree , temp , ancestor , 1 , 0 , K ) ; for ( int i = 1 ; i <= N ; i ++ ) { cout << ancestor [ i ] << " ▁ " ; } } int main ( ) { int N = 9 ; int K = 2 ; int E = 8 ; int edges [ 8 ] [ 2 ] = { { 1 , 2 } , { 1 , 3 } , { 2 , 4 } , { 2 , 5 } , { 2 , 6 } , { 3 , 7 } , { 3 , 8 } , { 3 , 9 } } ; KthAncestor ( N , K , E , edges ) ; return 0 ; }

Index/key variables: i, u, x, y
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void build ( vector < int > & sum , vector < int > & a , int l , int r , int rt ) { if ( l == r ) { sum [ rt ] = a [ l - 1 ] ; return ; } int m = ( l + r ) >> 1 ; build ( sum , a , l , m , rt << 1 ) ; build ( sum , a , m + 1 , r , rt << 1 1 ) ; } void pushDown ( vector < int > & sum , vector < int > & add , int rt , int ln , int rn ) { if ( add [ rt ] ) { add [ rt << 1 ] += add [ rt ] ; add [ rt << 1 1 ] += add [ rt ] ; sum [ rt << 1 ] += add [ rt ] * ln ; sum [ rt << 1 1 ] += add [ rt ] * rn ; add [ rt ] = 0 ; } } void update ( vector < int > & sum , vector < int > & add , int L , int R , int C , int l , int r , int rt ) { if ( L <= l && r <= R ) { sum [ rt ] += C * ( r - l + 1 ) ; add [ rt ] += C ; return ; } int m = ( l + r ) >> 1 ; pushDown ( sum , add , rt , m - l + 1 , r - m ) ; if ( L <= m ) update ( sum , add , L , R , C , l , m , rt << 1 ) ; if ( R > m ) update ( sum , add , L , R , C , m + 1 , r , rt << 1 1 ) ; } int query ( vector < int > & sum , vector < int > & add , int L , int R , int l , int r , int rt ) { if ( L <= l && r <= R ) { return sum [ rt ] ; } int m = ( l + r ) >> 1 ; pushDown ( sum , add , rt , m - l + 1 , r - m ) ; int ans = 0 ; if ( L <= m ) ans += query ( sum , add , L , R , l , m , rt << 1 ) ; if ( R > m ) ans += query ( sum , add , L , R , m + 1 , r , rt << 1 1 ) ; return ans ; } void sequenceMaintenance ( int n , int q , vector < int > & a , vector < int > & b , int m ) { sort ( a . begin ( ) , a . end ( ) ) ; vector < int > sum , add , ans ; sum . assign ( n << 2 , 0 ) ; add . assign ( n << 2 , 0 ) ; build ( sum , a , 1 , n , 1 ) ; for ( int i = 0 ; i < q ; i ++ ) { int l = 1 , r = n , pos = -1 ; while ( l <= r ) { int m = ( l + r ) >> 1 ; if ( query ( sum , add , m , m , 1 , n , 1 ) >= b [ i ] ) { r = m - 1 ; pos = m ; } else { l = m + 1 ; } } if ( pos == -1 ) ans . push_back ( 0 ) ; else { ans . push_back ( n - pos + 1 ) ; update ( sum , add , pos , n , - m , 1 , n , 1 ) ; } } for ( int i = 0 ; i < ans . size ( ) ; i ++ ) { cout << ans [ i ] << " ▁ " ; } } int main ( ) { int N = 4 ; int Q = 3 ; int M = 1 ; vector < int > arr = { 1 , 2 , 3 , 4 } ; vector < int > query = { 4 , 3 , 1 } ; sequenceMaintenance ( N , Q , arr , query , M ) ; return 0 ; }

Index/key variables: i, rt
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool hasCoprimePair ( vector < int > & arr , int n ) { for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( __gcd ( arr [ i ] , arr [ j ] ) == 1 ) { return true ; } } } return false ; } int main ( ) { int n = 3 ; vector < int > arr = { 6 , 9 , 15 } ; if ( hasCoprimePair ( arr , n ) ) { cout << 1 << endl ; } else { cout << n << endl ; } }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int Numberofways ( int n ) { int count = 0 ; for ( int a = 1 ; a < n ; a ++ ) { for ( int b = 1 ; b < n ; b ++ ) { int c = n - ( a + b ) ; if ( a + b > c && a + c > b && b + c > a ) { count ++ ; } } } return count ; } int main ( ) { int n = 15 ; cout << Numberofways ( n ) << endl ; return 0 ; }

Accumulator variables: a, b, count, stdc
Iterator variables: a, b
C++ program:
#include <bits/stdc++.h>
using namespace std ; void countPairs ( int N , int arr [ ] ) { int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( i == arr [ arr [ i ] - 1 ] - 1 ) { count ++ ; } } cout << ( count / 2 ) << endl ; } int main ( ) { int arr [ ] = { 2 , 1 , 4 , 3 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; countPairs ( N , arr ) ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int LongestFibSubseq ( int A [ ] , int n ) { unordered_set < int > S ( A , A + n ) ; int maxLen = 0 , x , y ; for ( int i = 0 ; i < n ; ++ i ) { for ( int j = i + 1 ; j < n ; ++ j ) { x = A [ j ] ; y = A [ i ] + A [ j ] ; int length = 2 ; while ( S . find ( y ) != S . end ( ) ) { int z = x + y ; x = y ; y = z ; maxLen = max ( maxLen , ++ length ) ; } } } return maxLen >= 3 ? maxLen : 0 ; } int main ( ) { int A [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 } ; int n = sizeof ( A ) / sizeof ( A [ 0 ] ) ; cout << LongestFibSubseq ( A , n ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int num_candyTypes ( vector < int > & candies ) { unordered_set < int > s ; for ( int i = 0 ; i < candies . size ( ) ; i ++ ) { s . insert ( candies [ i ] ) ; } return s . size ( ) ; } void distribute_candies ( vector < int > & candies ) { int allowed = candies . size ( ) / 2 ; int types = num_candyTypes ( candies ) ; if ( types < allowed ) cout << types ; else cout << allowed ; } int main ( ) { vector < int > candies = { 4 , 4 , 5 , 5 , 3 , 3 } ; distribute_candies ( candies ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; double Length_Diagonals ( int a , double theta ) { double p = a * sqrt ( 2 + ( 2 * cos ( theta * ( 3.141 / 180 ) ) ) ) ; double q = a * sqrt ( 2 - ( 2 * cos ( theta * ( 3.141 / 180 ) ) ) ) ; cout << fixed << setprecision ( 2 ) << p << " ▁ " << q ; } int main ( ) { int a = 6 ; int theta = 45 ; Length_Diagonals ( a , theta ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void countEvenOdd ( int arr [ ] , int n , int K ) { int even = 0 , odd = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int x = __builtin_popcount ( arr [ i ] ) ; if ( x % 2 == 0 ) even ++ ; else odd ++ ; } int y ; y = __builtin_popcount ( K ) ; if ( y & 1 ) { cout << " Even ▁ = ▁ " << odd << " , ▁ Odd ▁ = ▁ " << even ; } else { cout << " Even ▁ = ▁ " << even << " , ▁ Odd ▁ = ▁ " << odd ; } } int main ( void ) { int arr [ ] = { 4 , 2 , 15 , 9 , 8 , 8 } ; int K = 3 ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; countEvenOdd ( arr , n , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: even, i, odd, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int longestSubSequence ( pair < int , int > A [ ] , int N , int ind = 0 , int lastf = INT_MIN , int lasts = INT_MAX ) { if ( ind == N ) return 0 ; int ans = longestSubSequence ( A , N , ind + 1 , lastf , lasts ) ; if ( A [ ind ] . first > lastf && A [ ind ] . second < lasts ) ans = max ( ans , longestSubSequence ( A , N , ind + 1 , A [ ind ] . first , A [ ind ] . second ) + 1 ) ; return ans ; } int main ( ) { pair < int , int > A [ ] = { { 1 , 2 } , { 2 , 2 } , { 3 , 1 } } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; cout << longestSubSequence ( A , N ) << " STRNEWLINE " ; return 0 ; }

Index/key variables: ind
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
#include <iostream>
using namespace std ; int countTriplets ( vector < int > & A ) { int cnt = 0 ; unordered_map < int , int > tuples ; for ( auto a : A ) for ( auto b : A ) ++ tuples [ a & b ] ; for ( auto a : A ) for ( auto t : tuples ) if ( ( t . first & a ) == 0 ) cnt += t . second ; return cnt ; } int main ( ) { vector < int > A = { 2 , 1 , 3 } ; cout << countTriplets ( A ) ; return 0 ; }

Accumulator variables: cnt, stdc
Iterator variables: a, b, t
C++ program:
#include <iostream>
using namespace std ; int CountWays ( int n ) { int noOfWays [ n + 3 ] ; noOfWays [ 0 ] = 1 ; noOfWays [ 1 ] = 1 ; noOfWays [ 2 ] = 1 + 1 ; for ( int i = 3 ; i < n + 1 ; i ++ ) { noOfWays [ i ] = noOfWays [ i - 1 ] + noOfWays [ i - 3 ] ; } return noOfWays [ n ] ; } int main ( ) { int n = 0 ; cout << CountWays ( n ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void printSpiral ( int size ) { int row = 0 , col = 0 ; int boundary = size - 1 ; int sizeLeft = size - 1 ; int flag = 1 ; char move = ' r ' ; int matrix [ size ] [ size ] = { 0 } ; for ( int i = 1 ; i < size * size + 1 ; i ++ ) { matrix [ row ] [ col ] = i ; switch ( move ) { case ' r ' : col += 1 ; break ; case ' l ' : col -= 1 ; break ; case ' u ' : row -= 1 ; break ; case ' d ' : row += 1 ; break ; } if ( i == boundary ) { boundary += sizeLeft ; if ( flag != 2 ) { flag = 2 ; } else { flag = 1 ; sizeLeft -= 1 ; } switch ( move ) { case ' r ' : move = ' d ' ; break ; case ' d ' : move = ' l ' ; break ; case ' l ' : move = ' u ' ; break ; case ' u ' : move = ' r ' ; break ; } } } for ( row = 0 ; row < size ; row ++ ) { for ( col = 0 ; col < size ; col ++ ) { int n = matrix [ row ] [ col ] ; if ( n < 10 ) cout << n << " ▁ " ; else cout << n << " ▁ " ; } cout << endl ; } } int main ( ) { int size = 5 ; printSpiral ( size ) ; return 0 ; }

Index/key variables: col, row, size
Accumulator variables: boundary, col, i, row, sizeLeft
Iterator variables: col, i, row
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findWinner ( string a , int n ) { vector < int > v ; int c = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] == '0' ) { c ++ ; } else { if ( c != 0 ) v . push_back ( c ) ; c = 0 ; } } if ( c != 0 ) v . push_back ( c ) ; if ( v . size ( ) == 0 ) { cout << " Player ▁ B " ; return ; } if ( v . size ( ) == 1 ) { if ( v [ 0 ] & 1 ) cout << " Player ▁ A " ; else cout << " Player ▁ B " ; return ; } int first = INT_MIN ; int second = INT_MIN ; for ( int i = 0 ; i < v . size ( ) ; i ++ ) { if ( a [ i ] > first ) { second = first ; first = a [ i ] ; } else if ( a [ i ] > second && a [ i ] != first ) second = a [ i ] ; } if ( ( first & 1 ) && ( first + 1 ) / 2 > second ) cout << " Player ▁ A " ; else cout << " Player ▁ B " ; } int main ( ) { string S = "1100011" ; int N = S . length ( ) ; findWinner ( S , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: c, i, stdc
Iterator variables: i
C++ program:
#include <iostream>
#include <map>
using namespace std ; bool can_Construct ( string S , int K ) { map < int , int > m ; int i = 0 , j = 0 , p = 0 ; if ( S . length ( ) == K ) { return true ; } map < int , int > :: iterator h ; for ( i = 0 ; i < S . length ( ) ; i ++ ) { m [ S [ i ] ] = m [ S [ i ] ] + 1 ; } if ( K > S . length ( ) ) { return false ; } else { for ( h = m . begin ( ) ; h != m . end ( ) ; h ++ ) { if ( m [ h -> first ] % 2 != 0 ) { p = p + 1 ; } } } if ( K < p ) { return false ; } return true ; } int main ( ) { string S = " annabelle " ; int K = 4 ; if ( can_Construct ( S , K ) ) { cout << " Yes " ; } else { cout << " No " ; } }

Index/key variables: i
Accumulator variables: h, i
Iterator variables: h, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool equalIgnoreCase ( string str1 , string str2 ) { int i = 0 ; transform ( str1 . begin ( ) , str1 . end ( ) , str1 . begin ( ) , :: tolower ) ; transform ( str2 . begin ( ) , str2 . end ( ) , str2 . begin ( ) , :: tolower ) ; int x = str1 . compare ( str2 ) ; if ( x != 0 ) return false ; else return true ; } void equalIgnoreCaseUtil ( string str1 , string str2 ) { bool res = equalIgnoreCase ( str1 , str2 ) ; if ( res == true ) cout << " Same " << endl ; else cout << " Not ▁ Same " << endl ; } int main ( ) { string str1 , str2 ; str1 = " Geeks " ; str2 = " geeks " ; equalIgnoreCaseUtil ( str1 , str2 ) ; str1 = " Geek " ; str2 = " geeksforgeeks " ; equalIgnoreCaseUtil ( str1 , str2 ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; void steps ( string str , int n ) { bool flag ; int x = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( x == 0 ) flag = true ; if ( x == n - 1 ) flag = false ; for ( int j = 0 ; j < x ; j ++ ) cout << " * " ; cout << str [ i ] << " STRNEWLINE " ; if ( flag == true ) x ++ ; else x -- ; } } int main ( ) { int n = 4 ; string str = " GeeksForGeeks " ; cout << " String : ▁ " << str << endl ; cout << " Max ▁ Length ▁ of ▁ Steps : ▁ " << n << endl ; steps ( str , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, j, x
Iterator variables: i, j
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; void countFreq ( int arr [ ] , int n ) { vector < int > visited ( n , false ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( visited [ i ] == true ) continue ; int count = 1 ; for ( int j = i + 1 ; j < n ; j ++ ) { if ( arr [ i ] == arr [ j ] ) { visited [ j ] = true ; count ++ ; } } cout << arr [ i ] << " ▁ " << count << endl ; } } int main ( ) { int arr [ ] = { 10 , 20 , 20 , 10 , 10 , 20 , 5 , 20 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; countFreq ( 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 ; bool isDivisible ( char str [ ] , int k ) { int n = strlen ( str ) ; int c = 0 ; for ( int i = 0 ; i < k ; i ++ ) if ( str [ n - i - 1 ] == '0' ) c ++ ; return ( c == k ) ; } int main ( ) { char str1 [ ] = "10101100" ; int k = 2 ; if ( isDivisible ( str1 , k ) ) cout << " Yes " << endl ; else cout << " No " << " STRNEWLINE " ; char str2 [ ] = "111010100" ; k = 2 ; if ( isDivisible ( str2 , k ) ) cout << " Yes " << endl ; else cout << " No " << endl ; return 0 ; }

Accumulator variables: c, i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; #define NO_OF_CHARS  256
bool canFormPalindrome ( string str ) { int count [ NO_OF_CHARS ] = { 0 } ; for ( int i = 0 ; str [ i ] ; i ++ ) count [ str [ i ] ] ++ ; int odd = 0 ; for ( int i = 0 ; i < NO_OF_CHARS ; i ++ ) { if ( count [ i ] & 1 ) odd ++ ; if ( odd > 1 ) return false ; } return true ; } int main ( ) { canFormPalindrome ( " geeksforgeeks " ) ? cout << " Yes STRNEWLINE " : cout << " No STRNEWLINE " ; canFormPalindrome ( " geeksogeeks " ) ? cout << " Yes STRNEWLINE " : cout << " No STRNEWLINE " ; return 0 ; }

Index/key variables: NO_OF_CHARS, i
Accumulator variables: i, odd
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; bool isNumber ( string s ) { for ( int i = 0 ; i < s . length ( ) ; i ++ ) if ( isdigit ( s [ i ] ) == false ) return false ; return true ; } int main ( ) { string str = "6790" ; if ( isNumber ( str ) ) cout << " Integer " ; else cout << " String " ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void reverse ( string str ) { if ( str . size ( ) == 0 ) { return ; } reverse ( str . substr ( 1 ) ) ; cout << str [ 0 ] ; } int main ( ) { string a = " Geeks ▁ for ▁ Geeks " ; reverse ( a ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; static int box1 = 0 ; static int box2 = 0 ; static int fact [ 11 ] ; double getProbability ( int balls [ ] , int M ) { factorial ( 10 ) ; box2 = M ; int K = 0 ; for ( int i = 0 ; i < M ; i ++ ) K += balls [ i ] ; if ( K % 2 == 1 ) return 0 ; long all = comb ( K , K / 2 ) ; long validPermutation = validPermutations ( K / 2 , balls , 0 , 0 , M ) ; return ( double ) validPermutation / all ; } long validPermutations ( int n , int balls [ ] , int usedBalls , int i , int M ) { if ( usedBalls == n ) { return box1 == box2 ? 1 : 0 ; } if ( i >= M ) return 0 ; long res = validPermutations ( n , balls , usedBalls , i + 1 , M ) ; box1 ++ ; for ( int j = 1 ; j <= balls [ i ] ; j ++ ) { if ( j == balls [ i ] ) box2 -- ; long combinations = comb ( balls [ i ] , j ) ; res += combinations * validPermutations ( n , balls , usedBalls + j , i + 1 , M ) ; } box1 -- ; box2 ++ ; return res ; } void factorial ( int N ) { fact [ 0 ] = 1 ; for ( int i = 1 ; i <= N ; i ++ ) fact [ i ] = fact [ i - 1 ] * i ; } long comb ( int n , int r ) { long res = fact [ n ] / fact [ r ] ; res /= fact [ n - r ] ; return res ; } int main ( ) { int arr [ ] = { 2 , 1 , 1 } ; int N = 4 ; int M = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << ( getProbability ( arr , M ) ) ; return 0 ; }

Index/key variables: i, n, r
Accumulator variables: K, box1, box2, i, j, res, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; float polyarea ( float n , float r ) { if ( r < 0 && n < 0 ) return -1 ; float A = ( ( r * r * n ) * sin ( ( 360 / n ) * 3.14159 / 180 ) ) / 2 ; return A ; } int main ( ) { float r = 9 , n = 6 ; cout << polyarea ( n , r ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void is_partition_possible ( int n , int x [ ] , int y [ ] , int w [ ] ) { map < int , int > weight_at_x ; int max_x = -2e3 , min_x = 2e3 ; for ( int i = 0 ; i < n ; i ++ ) { int new_x = x [ i ] - y [ i ] ; max_x = max ( max_x , new_x ) ; min_x = min ( min_x , new_x ) ; weight_at_x [ new_x ] += w [ i ] ; } vector < int > sum_till ; sum_till . push_back ( 0 ) ; for ( int x = min_x ; x <= max_x ; x ++ ) { sum_till . push_back ( sum_till . back ( ) + weight_at_x [ x ] ) ; } int total_sum = sum_till . back ( ) ; int partition_possible = false ; for ( int i = 1 ; i < sum_till . size ( ) ; i ++ ) { if ( sum_till [ i ] == total_sum - sum_till [ i ] ) partition_possible = true ; if ( sum_till [ i - 1 ] == total_sum - sum_till [ i ] ) partition_possible = true ; } printf ( partition_possible ? " YES STRNEWLINE " : " NO STRNEWLINE " ) ; } int main ( ) { int n = 3 ; int x [ ] = { -1 , -2 , 1 } ; int y [ ] = { 1 , 1 , -1 } ; int w [ ] = { 3 , 1 , 4 } ; is_partition_possible ( n , x , y , w ) ; return 0 ; }

Index/key variables: i, new_x, x
Accumulator variables: i, stdc, x
Iterator variables: i, x
Boolean variables: partition_possible
C++ program:
#include <bits/stdc++.h>
using namespace std ; double findPCSlope ( double m ) { return -1.0 / m ; } int main ( ) { double m = 2.0 ; cout << findPCSlope ( m ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; float pi = 3.14159 ; float area_of_segment ( float radius , float angle ) { float area_of_sector = pi * ( radius * radius ) * ( angle / 360 ) ; float area_of_triangle = ( float ) 1 / 2 * ( radius * radius ) * sin ( ( angle * pi ) / 180 ) ; return area_of_sector - area_of_triangle ; } int main ( ) { float radius = 10.0 , angle = 90.0 ; cout << " Area ▁ of ▁ minor ▁ segment ▁ = ▁ " << area_of_segment ( radius , angle ) << endl ; cout << " Area ▁ of ▁ major ▁ segment ▁ = ▁ " << area_of_segment ( radius , ( 360 - angle ) ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; unordered_map < int , int > PrimeFactor ( int N ) { unordered_map < int , int > primef ; while ( N % 2 == 0 ) { if ( primef . count ( 2 ) ) { primef [ 2 ] += 1 ; } else { primef [ 2 ] = 1 ; } N /= 2 ; } for ( int i = 3 ; i <= sqrt ( N ) ; i ++ ) { while ( N % i == 0 ) { if ( primef . count ( i ) ) { primef [ i ] += 1 ; } else { primef [ i ] = 1 ; } N /= 2 ; } } if ( N > 2 ) { primef [ N ] = 1 ; } return primef ; } int CountToMakeEqual ( int X , int Y ) { int gcdofXY = __gcd ( X , Y ) ; int newX = Y / gcdofXY ; int newY = X / gcdofXY ; unordered_map < int , int > primeX ; unordered_map < int , int > primeY ; primeX = PrimeFactor ( newX ) ; primeY = PrimeFactor ( newY ) ; int ans = 0 ; for ( auto c : primeX ) { if ( X % c . first != 0 ) { return -1 ; } ans += primeX [ c . first ] ; } for ( auto c : primeY ) { if ( Y % c . first != 0 ) { return -1 ; } ans += primeY [ c . first ] ; } return ans ; } int main ( ) { int X = 36 ; int Y = 48 ; int ans = CountToMakeEqual ( X , Y ) ; cout << ans << endl ; return 0 ; }

Index/key variables: N, i
Accumulator variables: N, ans, i, stdc
Iterator variables: c, i