dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static void ValidPairs ( int X , int K ) { int count = 0 ; for ( int A = - 1000 ; A <= 1000 ; A ++ ) { for ( int B = - 1000 ; B <= 1000 ; B ++ ) { if ( Math . Pow ( A , K ) - Math . Pow ( B , K ) == X ) { count ++ ; Console . WriteLine ( A + " ▁ " + B ) ; } } } if ( count == 0 ) { Console . WriteLine ( " - 1" ) ; } } static public void Main ( ) { int X = 33 ; int K = 5 ; ValidPairs ( X , K ) ; } }

Accumulator variables: A, B, count
Iterator variables: A, B
Class/struct names: GFG
C# program:
using System ; class GFG { static int maximumAND ( int [ ] arr , int n , int m ) { int tot = 1 << n ; int mx = 0 ; for ( int bm = 0 ; bm < tot ; bm ++ ) { int andans = 0 ; int count = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( ( ( bm >> i ) & 1 ) != 0 ) { if ( count == 0 ) { andans = arr [ i ] ; } else { andans = andans & arr [ i ] ; } count ++ ; } } if ( count == ( m + 1 ) ) { mx = Math . Max ( mx , andans ) ; } } return mx ; } static public void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 } ; int N = arr . Length ; int M = 2 ; Console . WriteLine ( maximumAND ( arr , N , M ) ) ; } }

Index/key variables: i
Accumulator variables: bm, count
Iterator variables: bm, i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void findTotalSum ( string [ ] ops ) { if ( ops . Length == 0 ) { Console . WriteLine ( 0 ) ; return ; } Stack < int > pts = new Stack < int > ( ) ; int ans = 0 ; for ( int i = 0 ; i < ops . Length ; i ++ ) { if ( ops [ i ] == " C " ) { ans -= pts . Pop ( ) ; } else if ( ops [ i ] == " D " ) { pts . Push ( pts . Peek ( ) * 2 ) ; ans += pts . Peek ( ) ; } else if ( ops [ i ] == " + " ) { int a = pts . Pop ( ) ; int b = pts . Peek ( ) ; pts . Push ( a ) ; ans += ( a + b ) ; pts . Push ( a + b ) ; } else { int n = Int32 . Parse ( ops [ i ] ) ; ans += n ; pts . Push ( n ) ; } } Console . WriteLine ( ans ) ; } public static void Main ( ) { string [ ] arr = { "5" , " - 2" , " C " , " D " , " + " } ; findTotalSum ( arr ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void findXOR ( int [ , , ] mat , int N ) { int XOR = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { for ( int k = 0 ; k < N ; k ++ ) { if ( ( i == j && j == k ) ) { XOR ^= mat [ i , j , k ] ; XOR ^= mat [ i , j , N - k - 1 ] ; } } } } Console . WriteLine ( XOR ) ; } public static void Main ( string [ ] args ) { int [ , , ] mat = { { { 1 , 2 } , { 3 , 4 } } , { { 5 , 6 } , { 7 , 8 } } } ; int N = mat . GetLength ( 0 ) ; findXOR ( mat , N ) ; } }

Accumulator variables: XOR, i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static void findXOR ( int [ , , ] mat , int N ) { int XOR = 0 ; for ( int i = 0 ; i < N ; i ++ ) { XOR ^= mat [ i , i , i ] ; XOR ^= mat [ i , i , N - i - 1 ] ; } Console . Write ( XOR ) ; } static public void Main ( ) { int [ , , ] mat = { { { 1 , 2 } , { 3 , 4 } } , { { 5 , 6 } , { 7 , 8 } } } ; int N = mat . GetLength ( 0 ) ; findXOR ( mat , N ) ; } }

Accumulator variables: XOR, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static int MAX = 300004 ; static List < List < int > > graph ; static long mod = ( long ) 1e9 + 7 ; static int ans = 0 ; static int countSubtreesUtil ( int cur , int par ) { int res = 1 ; for ( int i = 0 ; i < graph [ cur ] . Count ; i ++ ) { int v = graph [ cur ] [ i ] ; if ( v == par ) continue ; res = ( int ) ( ( res * ( countSubtreesUtil ( v , cur ) + 1 ) ) % mod ) ; } ans = ( int ) ( ( ans + res ) % mod ) ; return res ; } static void countSubtrees ( int N , int [ , ] adj ) { for ( int i = 0 ; i < N - 1 ; i ++ ) { int a = adj [ i , 0 ] ; int b = adj [ i , 1 ] ; graph [ a ] . Add ( b ) ; graph [ b ] . Add ( a ) ; } countSubtreesUtil ( 1 , 1 ) ; Console . WriteLine ( ans + 1 ) ; } public static void Main ( String [ ] args ) { int N = 3 ; int [ , ] adj = { { 0 , 1 } , { 1 , 2 } } ; graph = new List < List < int > > ( ) ; for ( int i = 0 ; i < MAX ; i ++ ) graph . Add ( new List < int > ( ) ) ; countSubtrees ( N , adj ) ; } }

Index/key variables: a, b, cur, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void checkWinner ( int [ ] arr , int N ) { int diff = 0 ; for ( int i = 0 ; i < N ; i ++ ) { diff -= arr [ i ] ; } if ( diff % 2 == 0 ) { Console . Write ( " A " ) ; } else { Console . Write ( " B " ) ; } } public static void Main ( ) { int [ ] arr = { 1 , 2 } ; int N = arr . Length ; checkWinner ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: diff, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void constructArray ( int N ) { List < int > ans = new List < int > ( ) ; for ( int i = 1 ; i * i <= N ; i ++ ) { if ( N % i == 0 ) { ans . Add ( i ) ; if ( N != ( i * i ) ) { ans . Add ( N / i ) ; } } } foreach ( int it in ans ) { Console . Write ( it + " ▁ " ) ; } } public static void Main ( ) { int N = 12 ; constructArray ( N ) ; } }

Accumulator variables: i
Iterator variables: i, it
Class/struct names: GFG
C# program:
using System ; class GFG { static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } static int maximumRowValue ( int n , int m ) { return gcd ( n , m ) ; } public static void Main ( String [ ] args ) { int N = 4 ; int M = 2 ; Console . WriteLine ( maximumRowValue ( N , M ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int MOD = 998244353 ; static void findConvolution ( int [ ] a , int [ ] b ) { int n = a . Length , m = b . Length ; int [ ] c = new int [ ( n + m - 1 ) ] ; for ( int i = 0 ; i < n ; ++ i ) { for ( int j = 0 ; j < m ; ++ j ) { c [ i + j ] += ( a [ i ] * b [ j ] ) % MOD ; } } for ( int k = 0 ; k < c . Length ; ++ k ) { c [ k ] %= MOD ; Console . Write ( c [ k ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] A = { 1 , 2 , 3 , 4 } ; int [ ] B = { 5 , 6 , 7 , 8 , 9 } ; findConvolution ( A , B ) ; } }

Index/key variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int count1s ( int start_i , int start_j , int end_i , int end_j , List < List < int > > mat ) { int count = 0 ; for ( int x = start_i ; x < end_i ; x ++ ) { for ( int y = start_j ; y < end_j ; y ++ ) { if ( mat [ x ] [ y ] == 1 ) count ++ ; } } return count ; } static void findMinimumCount ( int N , int M , int A , int B , List < List < int > > mat ) { int minimum = 1000000 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { if ( ( i + A <= N ) && ( j + B <= M ) ) { int count = count1s ( i , j , i + A , j + B , mat ) ; minimum = Math . Min ( count , minimum ) ; } if ( ( i + B <= N ) && ( j + A <= M ) ) { int count = count1s ( i , j , i + B , j + A , mat ) ; minimum = Math . Min ( count , minimum ) ; } } } Console . WriteLine ( minimum ) ; } public static void Main ( ) { int A = 2 , B = 2 ; int N = 3 , M = 4 ; List < List < int > > mat = new List < List < int > > ( ) ; mat . Add ( new List < int > ( new int [ ] { 1 , 0 , 1 , 0 } ) ) ; mat . Add ( new List < int > ( new int [ ] { 0 , 1 , 0 , 1 } ) ) ; mat . Add ( new List < int > ( new int [ ] { 1 , 0 , 1 , 0 } ) ) ; findMinimumCount ( N , M , A , B , mat ) ; } }

Index/key variables: x, y
Accumulator variables: count, i, j, x, y
Iterator variables: i, j, x, y
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool checkEvenPower ( int n ) { int x = 0 ; while ( x < n ) { int value = ( int ) Math . Pow ( 2 , x ) ; if ( value == n ) { if ( x % 2 == 0 ) return true ; else return false ; } x ++ ; } return false ; } static public void Main ( ) { int N = 4 ; Console . Write ( ( checkEvenPower ( N ) ? " Yes " : " No " ) ) ; } }

Accumulator variables: x
Class/struct names: GFG
C# program:
using System ; public class GFG { static String checkEvenPower ( int n ) { int low = 0 , high = n ; while ( low <= high ) { int mid = low + ( high - low ) / 2 ; int value = ( int ) Math . Pow ( 2 , mid ) ; if ( value == n ) { if ( mid % 2 == 1 ) return " No " ; else return " Yes " ; } else if ( value < n ) low = mid + 1 ; else high = mid - 1 ; } return " No " ; } public static void Main ( String [ ] args ) { int N = 4 ; Console . WriteLine ( checkEvenPower ( N ) ) ; } }

Class/struct names: GFG
C# program:
using System ; public class GFG { static bool checkEvenPower ( long N ) { if ( ( N & ( N - 1 ) ) != 0 ) return false ; N = N & 0x55555555 ; return ( N > 0 ) ; } public static void Main ( String [ ] args ) { long N = 4 ; Console . WriteLine ( checkEvenPower ( N ) ? 1 : 0 ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void findSum ( int N , int K ) { int ans = 0 ; int i = 1 ; while ( i <= N ) { ans += N / i ; i = i * K ; } Console . Write ( ans ) ; } static void Main ( ) { int N = 10 , K = 2 ; findSum ( N , K ) ; } }

Accumulator variables: ans
Class/struct names: GFG
C# program:
using System ; class GFG { static int countAPs ( int S , int D ) { S = S * 2 ; int answer = 0 ; for ( int i = 1 ; i <= Math . Sqrt ( S ) ; i ++ ) { if ( S % i == 0 ) { if ( ( ( S / i ) - D * i + D ) % 2 == 0 ) answer ++ ; if ( ( D * i - ( S / i ) + D ) % 2 == 0 ) answer ++ ; } } return answer ; } static void Main ( ) { int S = 12 , D = 1 ; Console . Write ( countAPs ( S , D ) ) ; } }

Accumulator variables: answer, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void minimumInsertions ( int [ ] arr , int N , int K ) { bool possible = true ; int res = 0 ; int last = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] >= K ) { possible = false ; break ; } if ( last + arr [ i ] > K ) res ++ ; last = arr [ i ] ; } if ( possible ) { Console . Write ( res ) ; } else { Console . Write ( " - 1" ) ; } } static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 } ; int K = 6 ; int N = arr . Length ; minimumInsertions ( arr , N , K ) ; } }

Index/key variables: i
Accumulator variables: i, res
Iterator variables: i
Boolean variables: possible
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int distinct ( int [ ] arr , int n ) { HashSet < int > set = new HashSet < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { set . Add ( arr [ i ] ) ; } return set . Count ; } static int maxSubSum ( int [ ] arr , int n , int k , int totalDistinct ) { if ( k > n ) return 0 ; int max = 0 , sum = 0 ; for ( int i = 0 ; i < n - k + 1 ; i ++ ) { sum = 0 ; HashSet < int > set = new HashSet < int > ( ) ; for ( int j = i ; j < i + k ; j ++ ) { sum += arr [ j ] ; set . Add ( arr [ j ] ) ; } if ( set . Count == totalDistinct ) max = Math . Max ( sum , max ) ; } return max ; } public static void Main ( String [ ] args ) { int [ ] arr = { 7 , 7 , 2 , 4 , 2 , 7 , 4 , 6 , 6 , 6 } ; int K = 6 ; int N = arr . Length ; int totalDistinct = distinct ( arr , N ) ; Console . WriteLine ( maxSubSum ( arr , N , K , totalDistinct ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int distinct ( List < int > arr , int N ) { HashSet < int > st = new HashSet < int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { st . Add ( arr [ i ] ) ; } return st . Count ; } static int maxSubarraySumUtil ( List < int > arr , int N , int K , int totalDistinct ) { if ( K > N ) return 0 ; int mx = 0 ; int sum = 0 ; Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( mp . ContainsKey ( arr [ i ] ) ) mp [ arr [ i ] ] += 1 ; else mp [ arr [ i ] ] = 1 ; sum += arr [ i ] ; if ( i >= K ) { if ( mp . ContainsKey ( arr [ i - K ] ) ) mp [ arr [ i - K ] ] -= 1 ; else mp [ arr [ i - K ] ] = 1 ; sum -= arr [ i - K ] ; if ( mp [ arr [ i - K ] ] == 0 ) mp . Remove ( arr [ i - K ] ) ; } if ( mp . Count == totalDistinct ) mx = Math . Max ( mx , sum ) ; } return mx ; } static void maxSubarraySum ( List < int > arr , int K ) { int N = arr . Count ; int totalDistinct = distinct ( arr , N ) ; Console . WriteLine ( maxSubarraySumUtil ( arr , N , K , totalDistinct ) ) ; } public static void Main ( ) { List < int > arr = new List < int > { 7 , 7 , 2 , 4 , 2 , 7 , 4 , 6 , 6 , 6 } ; int K = 6 ; maxSubarraySum ( arr , K ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int mod = 1000000007 ; static int power ( int x , int y ) { int res = 1 ; x = x % mod ; if ( x == 0 ) return 0 ; while ( y > 0 ) { if ( ( y & 1 ) != 0 ) res = ( res * x ) % mod ; y = y >> 1 ; x = ( x * x ) % mod ; } return res ; } static int irreflexiveRelation ( int N ) { return power ( 2 , N * N - N ) ; } public static void Main ( String [ ] args ) { int N = 2 ; Console . WriteLine ( irreflexiveRelation ( N ) ) ; } }

Class/struct names: GFG
C# program:
using System ; public class GFG { static void countAPs ( long N ) { long count = 0 ; for ( long i = 1 ; i * i <= 2 * N ; i ++ ) { long res = 2 * N ; if ( res % i == 0 ) { long op = res / i - i + 1 ; if ( op % 2 == 0 ) { count ++ ; } if ( i * i != res && ( i - res / i + 1 ) % 2 == 0 ) { count ++ ; } } } Console . WriteLine ( count - 1 ) ; } public static void Main ( String [ ] args ) { long N = 963761198400L ; countAPs ( N ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int [ ] sieve = new int [ 105 ] ; static void buildSieve ( ) { for ( int i = 2 ; i < 100 ; i ++ ) sieve [ i ] = 1 ; for ( int i = 2 ; i < 100 ; i ++ ) { if ( sieve [ i ] == 1 ) { for ( int j = i * i ; j < 100 ; j += i ) sieve [ j ] = 0 ; } } } static bool isAnyPrime ( int first , int last ) { int num1 = first * 10 + last ; int num2 = last * 10 + first ; if ( sieve [ num1 ] == 1 sieve [ num2 ] == 1 ) return true ; else return false ; } static void performQueries ( int [ ] q ) { for ( int i = 0 ; i < q . Length ; i ++ ) { int A = q [ i ] ; int last = A % 10 ; int first ; while ( A >= 10 ) A = A / 10 ; first = A ; if ( isAnyPrime ( first , last ) ) Console . Write ( " True STRNEWLINE " ) ; else Console . Write ( " False STRNEWLINE " ) ; } } public static void Main ( String [ ] args ) { int [ ] q = { 30 , 66 } ; buildSieve ( ) ; performQueries ( q ) ; } }

Index/key variables: i, j, num1, num2
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static string oddDivisor ( int N ) { int X = N ; while ( N % 2 == 0 ) { N /= 2 ; } for ( int i = 3 ; i * i <= X ; i += 2 ) { if ( N % i == 0 ) { return " Yes " ; } } if ( N != X ) { return " Yes " ; } return " No " ; } static public void Main ( ) { int N = 10 ; Console . Write ( oddDivisor ( N ) ) ; } }

Accumulator variables: N, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ ] arr = new int [ 100005 ] ; static bool isDivisible ( int x ) { int sum = 0 ; int temp = x ; while ( x != 0 ) { sum += x % 10 ; x /= 10 ; } if ( temp % sum != 0 ) return false ; else return true ; } static void precompute ( ) { for ( int i = 1 ; i <= 100000 ; i ++ ) { if ( isDivisible ( i ) ) arr [ i ] = 1 ; else arr [ i ] = 0 ; } for ( int i = 1 ; i <= 100000 ; i ++ ) { arr [ i ] = arr [ i ] + arr [ i - 1 ] ; } } public static int [ ] GetRow ( int [ , ] matrix , int row ) { var rowLength = matrix . GetLength ( 1 ) ; var rowVector = new int [ rowLength ] ; for ( var i = 0 ; i < rowLength ; i ++ ) rowVector [ i ] = matrix [ row , i ] ; return rowVector ; } public static void Main ( String [ ] args ) { int [ , ] Q = { { 5 , 9 } , { 5 , 20 } } ; int [ ] q ; precompute ( ) ; for ( int i = 0 ; i < Q . GetLength ( 0 ) ; i ++ ) { q = GetRow ( Q , i ) ; Console . WriteLine ( arr [ q [ 1 ] ] - arr [ q [ 0 ] - 1 ] ) ; } } }

Index/key variables: i, rowLength
Accumulator variables: i, sum, x
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ ] primes = new int [ 1000006 ] ; static int gcd ( int a , int b ) { if ( b == 0 ) return a ; else return gcd ( b , a % b ) ; } static void preprocess ( ) { for ( int i = 1 ; i <= 1000000 ; i ++ ) primes [ i ] = i ; for ( int i = 2 ; i * i <= 1000000 ; i ++ ) { if ( primes [ i ] == i ) { for ( int j = 2 * i ; j <= 1000000 ; j += i ) { if ( primes [ j ] == j ) primes [ j ] = i ; } } } } static int Steps ( int x , int m ) { int steps = 0 ; bool flag = false ; while ( x > 1 ) { if ( primes [ x ] > m ) { flag = true ; break ; } x /= primes [ x ] ; steps ++ ; } if ( flag ) return - 1 ; return steps ; } static int minimumSteps ( int x , int y , int m ) { preprocess ( ) ; int g = gcd ( x , y ) ; x = x / g ; y = y / g ; int x_steps = Steps ( x , m ) ; int y_steps = Steps ( y , m ) ; if ( x_steps == - 1 y_steps == - 1 ) return - 1 ; return x_steps + y_steps ; } static void Main ( ) { int X = 160 ; int Y = 180 ; int M = 10 ; Console . Write ( minimumSteps ( X , Y , M ) ) ; } }

Index/key variables: i, j, x
Accumulator variables: i, j, steps, x
Iterator variables: i, j
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; public class GFG { static bool isNonDeficient ( int n ) { int sum = 0 ; for ( int i = 1 ; i <= Math . Sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i ) { sum = sum + i ; } else { sum = sum + i ; sum = sum + ( n / i ) ; } } } return sum >= 2 * n ; } static int LongestNonDeficientSubsequence ( int [ ] arr , int n ) { int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( isNonDeficient ( arr [ i ] ) ) { res += 1 ; } } return res ; } public static void Main ( String [ ] args ) { int [ ] arr = { 13 , 55 , 240 , 32 , 24 , 27 , 56 , 80 , 100 , 330 , 89 } ; int N = arr . Length ; Console . WriteLine ( LongestNonDeficientSubsequence ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isPronic ( int n ) { int range = ( int ) Math . Sqrt ( n ) ; for ( int i = 0 ; i < range + 1 ; i ++ ) { if ( i * ( i + 1 ) == n ) return true ; } return false ; } static int countSub ( int [ ] arr , int n ) { int ans = 0 ; int ispro = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( isPronic ( arr [ i ] ) ) ispro += 1 ; else ispro = 0 ; ans += ispro ; } return ans ; } static void Main ( ) { int [ ] arr = { 5 , 6 , 12 , 3 , 4 } ; int n = arr . Length ; Console . WriteLine ( countSub ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i, ispro
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int LOG ( int a , int b ) { return ( int ) ( Math . Log ( a ) / Math . Log ( b ) ) ; } static void repbyNP ( int [ ] arr , int n ) { int x = arr [ n - 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { int k = LOG ( arr [ i ] , x ) ; int temp = arr [ i ] ; if ( Math . Abs ( Math . Pow ( x , k ) - arr [ i ] ) < Math . Abs ( Math . Pow ( x , k + 1 ) - arr [ i ] ) ) arr [ i ] = ( int ) Math . Pow ( x , k ) ; else arr [ i ] = ( int ) Math . Pow ( x , k + 1 ) ; x = temp ; } } public static void Main ( string [ ] args ) { int [ ] arr = { 2 , 4 , 6 , 3 , 11 } ; int n = arr . Length ; repbyNP ( arr , n ) ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int lastElement ( int [ ] arr , int n ) { int sum = 0 ; int multiplier = n % 2 == 0 ? - 1 : 1 ; for ( int i = 0 ; i < n ; i ++ ) { sum += arr [ i ] * multiplier ; multiplier = multiplier * ( n - 1 - i ) / ( i + 1 ) * ( - 1 ) ; } return sum ; } static void Main ( ) { int [ ] arr = { 3 , 4 , 2 , 1 } ; int N = 4 ; Console . WriteLine ( lastElement ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countPairs ( int [ ] arr , int N ) { int odd = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( ( arr [ i ] & 1 ) != 0 ) odd ++ ; } int ans = ( N - odd + odd / 2 - 1 ) + odd / 2 ; return ans ; } public static void Main ( ) { int [ ] arr = { 4 , 6 , 1 , 3 } ; int N = arr . Length ; Console . Write ( countPairs ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, odd
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int countPairs ( int [ ] arr , int N ) { Dictionary < int , int > freq = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( freq . ContainsKey ( ( int ) ( Math . Log ( Convert . ToDouble ( arr [ i ] ) , 2.0 ) ) ) ) freq [ ( int ) ( Math . Log ( Convert . ToDouble ( arr [ i ] ) , 2.0 ) ) ] ++ ; else freq [ ( int ) ( Math . Log ( Convert . ToDouble ( arr [ i ] ) , 2.0 ) ) ] = 1 ; } int pairs = 0 ; foreach ( var item in freq ) { pairs += item . Value - 1 ; } return pairs ; } public static void Main ( ) { int [ ] arr = { 12 , 9 , 15 , 7 } ; int N = arr . Length ; Console . WriteLine ( countPairs ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, pairs
Iterator variables: i, item
Class/struct names: GFG
C# program:
using System ; class GFG { static int countBit ( int n ) { return ( int ) ( ( Math . Log ( n ) / Math . Log ( 2 ) ) + 1 ) ; } static int countSetBit ( int n ) { int ans = 0 ; while ( n > 0 ) { ans += ( n & 1 ) ; n >>= 1 ; } return ans ; } static int maximize ( int n ) { int bits = countBit ( n ) ; int setBits = countSetBit ( n ) ; int ans = 0 ; for ( int i = 0 ; i < bits ; i ++ ) { if ( i < setBits ) ans |= 1 ; if ( i != setBits - 1 ) ans <<= 1 ; } return ans ; } static int minimize ( int n ) { int setBits = countSetBit ( n ) ; int ans = 0 ; for ( int i = 0 ; i < setBits ; i ++ ) { ans |= 1 ; if ( i != setBits - 1 ) ans <<= 1 ; } return ans ; } static int maxDiff ( int [ ] arr ) { int caseOne = 0 ; int SumOfOdd = 0 ; int SumOfeven = 0 ; for ( int i = 0 ; i < arr . Length ; i ++ ) { if ( ( i % 2 ) != 0 ) SumOfOdd += minimize ( arr [ i ] ) ; else SumOfeven += maximize ( arr [ i ] ) ; } caseOne = Math . Abs ( SumOfOdd - SumOfeven ) ; int caseTwo = 0 ; SumOfOdd = 0 ; SumOfeven = 0 ; for ( int i = 0 ; i < arr . Length ; i ++ ) { if ( ( i % 2 ) != 0 ) SumOfOdd += maximize ( arr [ i ] ) ; else SumOfeven += minimize ( arr [ i ] ) ; } caseTwo = Math . Abs ( SumOfOdd - SumOfeven ) ; return Math . Max ( caseOne , caseTwo ) ; } public static void Main ( string [ ] args ) { int [ ] arr = { 54 , 32 , 11 , 23 } ; Console . Write ( maxDiff ( arr ) ) ; } }

Index/key variables: i
Accumulator variables: SumOfOdd, SumOfeven, ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int processDiagonal ( List < int > arr ) { int ans = 0 ; int getBit = 1 ; for ( int i = 0 ; i < 32 ; i ++ ) { int S = 0 ; int NS = 0 ; foreach ( int j in arr ) { if ( ( getBit & j ) != 0 ) S += 1 ; else NS += 1 ; } if ( S > NS ) ans += ( int ) Math . Pow ( 2 , i ) ; getBit <<= 1 ; } return ans ; } static int findSum ( int [ , ] mat ) { int i = 0 ; int j = 0 ; List < int > priDiag = new List < int > ( ) ; while ( i < mat . GetLength ( 0 ) ) { priDiag . Add ( mat [ i , j ] ) ; i += 1 ; j += 1 ; } i = 0 ; j = mat . GetLength ( 0 ) - 1 ; List < int > secDiag = new List < int > ( ) ; while ( i < mat . GetLength ( 0 ) ) { secDiag . Add ( mat [ i , j ] ) ; i += 1 ; j -= 1 ; } return ( processDiagonal ( priDiag ) + processDiagonal ( secDiag ) ) ; } public static void Main ( string [ ] args ) { int [ , ] mat = { { 1 , 2 , 3 } , { 4 , 5 , 6 } , { 7 , 8 , 9 } } ; Console . Write ( findSum ( mat ) ) ; } }

Accumulator variables: NS, S, ans, i, j
Iterator variables: i, j
Class/struct names: GFG