dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static void computeLPSArray ( String pat , int M , int [ ] lps ) { int len = 0 ; lps [ 0 ] = 0 ; int i = 1 ; while ( i < M ) { if ( pat [ i ] == pat [ len ] ) { len ++ ; lps [ i ] = len ; i ++ ; } else { if ( len != 0 ) { len = lps [ len - 1 ] ; } else { lps [ i ] = 0 ; i ++ ; } } } } static int KMPSearch ( String pat , String txt ) { int M = pat . Length ; int N = txt . Length ; int [ ] lps = new int [ M ] ; computeLPSArray ( pat , M , lps ) ; int i = 0 ; int j = 0 ; while ( i < N ) { if ( pat [ j ] == txt [ i ] ) { j ++ ; i ++ ; } if ( j == M ) { return 1 ; else if ( i < N && [ j ] != txt [ i ] ) { if ( j != 0 ) j = lps [ j - 1 ] ; else = i + 1 ; } } return 0 ; } static void ( String seq , String word ) { int resCount = 0 ; curWord = word ; int numWords = seq . Length / word . Length ; for ( int i = 0 ; i < numWords ; ++ ) { if ( KMPSearch ( curWord , seq ) == 1 ) { curWord += word ; ++ ; } else break ; } Console . Write ( resCount ) ; } public static void ( String [ ] args ) { String S1 = " ababc " , S2 = " ab " ; ( , S2 ) ; } }

Index/key variables: M, i, j, len
Accumulator variables: curWord, i, j, len
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static long countNumberOfStrings ( String s ) { int n = s . Length - 1 ; long count = ( long ) ( Math . Pow ( 2 , n ) ) ; return count ; } public static void Main ( String [ ] args ) { string S = " ABCD " ; Console . WriteLine ( countNumberOfStrings ( S ) ) ; } }

Class/struct names: GFG
C# program:
using System . Collections . Generic ; using System ; using System . Linq ; class GFG { static void findMinimumTime ( int [ ] p , int n , int target ) { Dictionary < int , int > um = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( um . ContainsKey ( p [ i ] ) == true ) um [ p [ i ] ] += 1 ; else um [ p [ i ] ] = 1 ; } int time = 0 ; int sum = 0 ; var val = um . Keys . ToList ( ) ; while ( sum < target ) { sum = 0 ; time ++ ; foreach ( var key in val ) { sum += um [ key ] * ( time / key ) ; } } Console . WriteLine ( time ) ; } public static void Main ( ) { int [ ] arr = { 1 , 3 , 3 , 4 } ; int N = arr . Length ; int target = 10 ; findMinimumTime ( arr , N , target ) ; } }

Index/key variables: i, key
Accumulator variables: i, sum, time
Iterator variables: i, key
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAXN = 100001 ; static void constructMEX ( int [ ] arr , int N ) { int [ ] hash = new int [ MAXN ] ; for ( int i = 0 ; i < N ; i ++ ) { hash [ i ] = 0 ; } for ( int i = 0 ; i < N ; i ++ ) { hash [ arr [ i ] ] = 1 ; } int MexOfArr = 0 ; for ( int i = 1 ; i < MAXN ; i ++ ) { if ( hash [ i ] == 0 ) { MexOfArr = i ; break ; } } int [ ] B = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] < MexOfArr ) B [ i ] = arr [ i ] ; else B [ i ] = MexOfArr ; } for ( int i = 0 ; i < N ; i ++ ) Console . Write ( B [ i ] + " ▁ " ) ; } public static void Main ( ) { int [ ] arr = { 2 , 1 , 5 , 3 } ; int N = arr . Length ; constructMEX ( arr , N ) ; } }

Index/key variables: MAXN, N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public class pair { public int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static void smallestNumberLeftInPQ ( int [ ] arr , int N ) { List < int > pq = new List < int > ( ) ; List < pair > pairsArr = new List < pair > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { pq . Add ( arr [ i ] ) ; } pq . Sort ( ) ; pq . Reverse ( ) ; while ( pq . Count > 1 ) { int X = pq [ 0 ] ; pq . RemoveAt ( 0 ) ; int Y = pq [ 0 ] ; pq . RemoveAt ( 0 ) ; pq . Add ( ( X + Y + 1 ) / 2 ) ; pq . Sort ( ) ; pq . Reverse ( ) ; pairsArr . Add ( new pair ( X , Y ) ) ; } Console . Write ( " { " + pq [ 0 ] + " } , ▁ " ) ; int sz = pairsArr . Count ; for ( int i = 0 ; i < sz ; i ++ ) { if ( i == 0 ) { Console . Write ( " { ▁ " ) ; } Console . Write ( " ( " + pairsArr [ i ] . first + " , ▁ " + pairsArr [ i ] . second + " ) " ) ; if ( i != sz - 1 ) { Console . Write ( " , ▁ " ) ; } if ( i == sz - 1 ) { Console . Write ( " ▁ } " ) ; } } } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , 2 , 1 } ; int N = arr . Length ; smallestNumberLeftInPQ ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, pair
C# program:
using System ; class GFG { static int findSum ( int [ ] S , int n , int x ) { int [ , ] table = new int [ n + 1 , x + 1 ] ; for ( int i = 1 ; i <= x ; i ++ ) { table [ 0 , i ] = int . MaxValue - 1 ; } for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= x ; j ++ ) { if ( S [ i - 1 ] > j ) { table [ i , j ] = table [ i - 1 , j ] ; } else { table [ i , j ] = Math . Min ( table [ i - 1 , j ] , table [ i , j - S [ i - 1 ] ] + 1 ) ; } } } return ( table [ n , x ] > n ) ? - 1 : table [ n , x ] ; } static void minRemovals ( int [ ] arr , int n , int m , int x ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += arr [ i ] ; } int requied_Sum = 0 ; if ( sum % m < x ) requied_Sum = m + sum % m - x ; else requied_Sum = sum % m - x ; Console . Write ( findSum ( arr , n , requied_Sum ) ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , 2 , 1 , 2 } ; int n = arr . Length ; int m = 4 , x = 2 ; minRemovals ( arr , n , m , x % m ) ; } }

Index/key variables: i
Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static int minChange ( String s , int n ) { int [ ] L = new int [ 26 ] ; int [ ] R = new int [ 26 ] ; for ( int i = 0 ; i < n / 2 ; i ++ ) { char ch = s [ i ] ; L [ ch - ' a ' ] ++ ; } for ( int i = n / 2 ; i < n ; i ++ ) { char ch = s [ i ] ; R [ ch - ' a ' ] ++ ; } int count = n ; for ( char ch = ' a ' ; ch <= ' z ' ; ch ++ ) { count = Math . Min ( count , n - L [ ch - ' a ' ] - R [ ch - ' a ' ] ) ; } int change = n / 2 ; for ( int d = 0 ; d + 1 < 26 ; d ++ ) { change -= L [ d ] ; change += R [ d ] ; count = Math . Min ( count , change ) ; } change = n / 2 ; for ( int d = 0 ; d + 1 < 26 ; d ++ ) { change -= R [ d ] ; change += L [ d ] ; count = Math . Min ( change , count ) ; } return count ; } public static void Main ( String [ ] args ) { String S = " aababc " ; int N = S . Length ; Console . WriteLine ( minChange ( S , N ) ) ; } }

Index/key variables: d, i
Accumulator variables: ch, change, d, i
Iterator variables: ch, d, i
Class/struct names: GFG
C# program:
using System ; using System . Text ; class GFG { static String reverse ( String input ) { char [ ] a = input . ToCharArray ( ) ; int l , r = a . Length - 1 ; for ( l = 0 ; l < r ; l ++ , r -- ) { char temp = a [ l ] ; a [ l ] = a [ r ] ; a [ r ] = temp ; } return String . Join ( " " , a ) ; } static String longestPalinSub ( String str ) { int N = str . Length ; int [ ] hash = new int [ 256 ] ; for ( int i = 0 ; i < N ; i ++ ) { hash [ str [ i ] ] ++ ; } StringBuilder res1 = new StringBuilder ( ) ; StringBuilder res2 = new StringBuilder ( ) ; for ( int i = 0 ; i < 256 ; i ++ ) { for ( int j = 0 ; j < hash [ i ] / 2 ; j ++ ) { res1 . Append ( ( char ) i ) ; } for ( int j = ( hash [ i ] + 1 ) / 2 ; j < hash [ i ] ; j ++ ) { res2 . Append ( ( char ) i ) ; } } String tmp = reverse ( res2 . ToString ( ) ) ; StringBuilder res3 = new StringBuilder ( ) ; bool f = false ; for ( int i = 0 ; i < 256 ; i ++ ) { if ( hash [ i ] % 2 == 1 ) { if ( ! f ) { res1 . Append ( ( char ) i ) ; f = true ; } else { res3 . Append ( ( char ) i ) ; } } } return ( res1 . ToString ( ) + tmp . ToString ( ) + res3 . ToString ( ) ) ; } public static void Main ( String [ ] args ) { String str = " geeksforgeeks " ; Console . WriteLine ( longestPalinSub ( str ) ) ; } }

Index/key variables: i, l, r
Accumulator variables: i, j, l, r
Iterator variables: i, j, l
Boolean variables: f
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static int No_Of_subsequences ( Dictionary < int , int > mp ) { int count = 0 ; int left = 0 ; foreach ( KeyValuePair < int , int > x in mp ) { if ( ! mp . ContainsKey ( x . Key ) ) mp . Add ( x . Key , x . Value + left ) ; count += ( x . Value / x . Key ) ; left = x . Value % x . Key ; } return count ; } public static void maximumsubsequences ( int [ ] arr , int n ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( mp . ContainsKey ( arr [ i ] ) ) { mp [ arr [ i ] ] = mp [ arr [ i ] ] + 1 ; } else { mp . Add ( arr [ i ] , 1 ) ; } } Console . WriteLine ( No_Of_subsequences ( mp ) ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 1 , 1 , 1 } ; int N = arr . Length ; maximumsubsequences ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i, x
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; using System . Linq ; class GFG { static bool check ( List < int > arr , List < List < int > > pieces ) { Dictionary < int , int > m = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < arr . Count ; i ++ ) m . Add ( arr [ i ] , i ) ; for ( int i = 0 ; i < pieces . Count ; i ++ ) { if ( pieces [ i ] . Count == 1 && m . ContainsKey ( pieces [ i ] [ 0 ] ) ) { continue ; } else if ( pieces [ i ] . Count > 1 && m . ContainsKey ( pieces [ i ] [ 0 ] ) ) { int idx = m [ pieces [ i ] [ 0 ] ] ; idx ++ ; if ( idx >= arr . Count ) return false ; for ( int j = 1 ; j < pieces [ i ] . Count ; j ++ ) { if ( arr [ idx ] == pieces [ i ] [ j ] ) { idx ++ ; if ( idx >= arr . Count && j < pieces [ i ] . Count - 1 ) return false ; } else { return false ; } } } else { return false ; } } return true ; } static public void Main ( ) { List < int > arr = new List < int > ( ) { 1 , 2 , 4 , 3 } ; List < List < int > > pieces = new List < List < int > > ( ) ; pieces . Add ( new List < int > ( ) { 1 } ) ; pieces . Add ( new List < int > ( ) { 4 , 3 } ) ; pieces . Add ( new List < int > ( ) { 2 } ) ; if ( check ( arr , pieces ) ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } }

Index/key variables: i, idx, j
Accumulator variables: i, idx, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static 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 ++ ) Console . Write ( a [ i ] + " ▁ " ) ; } else { if ( count_0 >= N / 2 ) { else { if ( count_0 >= N / 2 ) { for ( int i = 0 ; i < count_0 ; i ++ ) Console . Write ( "0 ▁ " ) ; } else { int is_Odd = count_1 % 2 ; count_1 -= is_Odd ; for ( int i = 0 ; i < count_1 ; i ++ ) Console . Write ( "1 ▁ " ) ; } } } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 1 , 1 , 0 } ; int N = arr . Length ; makeArraySumEqual ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: count_0, count_1, even_sum, i, odd_sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static readonly int maxm = 10001 ; static bool [ ] prime ; static int [ ] prime_number ; static void SieveOfEratosthenes ( ) { for ( int i = 0 ; i < prime . Length ; i ++ ) prime [ i ] = true ; 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 ; } static void num_prime ( ) { prime_number [ 0 ] = 0 ; for ( int i = 1 ; i <= maxm ; i ++ ) { int tmp ; if ( prime [ i ] == true ) { tmp = 1 ; } else { tmp = 0 ; } prime_number [ i ] = prime_number [ i - 1 ] + tmp ; } } static void min_steps ( int [ ] arr , int n ) { SieveOfEratosthenes ( ) ; num_prime ( ) ; if ( n == 1 ) { Console . WriteLine ( "0" ) ; } else if ( n == 2 ) { Console . WriteLine ( "1" ) ; } else { Console . WriteLine ( prime_number [ n ] - 1 + ( n - 2 ) ) ; } } public static void Main ( String [ ] args ) { prime = new bool [ maxm + 1 ] ; prime_number = new int [ maxm + 1 ] ; int [ ] arr = { 5 , 4 , 3 , 2 , 1 } ; int N = arr . Length ; min_steps ( arr , N ) ; } }

Index/key variables: i, n, p
Accumulator variables: i, p
Iterator variables: i, p
Class/struct names: GFG
C# program:
using System ; class GFG { static 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 ) Console . Write ( " A " ) ; else Console . Write ( " B " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 1 , 1 , 2 } ; int N = arr . Length ; findWinner ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isReachable ( long x1 , long y1 , long x2 , 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 false ; } public static void Main ( String [ ] args ) { long source_x = 2 , source_y = 10 ; long dest_x = 26 , dest_y = 12 ; if ( isReachable ( source_x , source_y , dest_x , dest_y ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void checkWinner ( int N , int K ) { if ( N % ( K + 1 ) > 0 ) { Console . Write ( " A " ) ; } else { Console . Write ( " B " ) ; } } public static void Main ( String [ ] args ) { int N = 50 ; int K = 10 ; checkWinner ( N , K ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool [ ] isprime = new bool [ 2000010 ] ; static void SieveOfEratosthenes ( int n ) { for ( int i = 0 ; i < isprime . Length ; i ++ ) isprime [ i ] = true ; 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 ; } } } static int KDistinctPrime ( int [ ] arr , int n , int k ) { SieveOfEratosthenes ( 2000000 ) ; Dictionary < int , int > cnt = new Dictionary < int , int > ( ) ; int result = - 1 ; for ( int i = 0 , j = - 1 ; i < n ; ++ i ) { int x = arr [ i ] ; if ( isprime [ x ] ) { if ( cnt . ContainsKey ( x ) ) cnt [ x ] = cnt [ x ] + 1 ; else cnt . Add ( x , 1 ) ; if ( cnt [ x ] == 1 ) { -- k ; } } while ( k < 0 ) { x = arr [ ++ j ] ; if ( isprime [ x ] ) { if ( cnt . ContainsKey ( x ) ) cnt [ x ] = cnt [ x ] - 1 ; else cnt . Add ( x , 0 ) ; if ( cnt [ x ] == 0 ) { ++ k ; } } } if ( k == 0 ) result = Math . Max ( result , i - j ) ; } return result ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 3 , 4 , 5 , 6 , 7 , 8 , 9 } ; int K = 3 ; int N = arr . Length ; Console . WriteLine ( KDistinctPrime ( arr , N , K ) ) ; } }

Index/key variables: i, p, x
Accumulator variables: i, p
Iterator variables: i, p
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static readonly int MAX_SIZE = 1000005 ; static void SieveOfEratosthenes ( List < int > StorePrimes ) { bool [ ] IsPrime = new bool [ MAX_SIZE ] ; for ( int i = 0 ; i < MAX_SIZE ; i ++ ) IsPrime [ i ] = true ; 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 . Add ( p ) ; } static int Smallest_non_Prime ( List < int > StorePrimes , int N ) { int x = StorePrimes [ N ] ; return x * x ; } public static void Main ( String [ ] args ) { int N = 3 ; List < int > StorePrimes = new List < int > ( ) ; SieveOfEratosthenes ( StorePrimes ) ; Console . Write ( Smallest_non_Prime ( StorePrimes , N ) ) ; } }

Index/key variables: MAX_SIZE, N, i, p
Accumulator variables: i, p
Iterator variables: i, p
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void printSubset ( int n , int k ) { List < int > answer = new List < int > ( ) ; while ( n > 0 ) { int p = ( int ) Math . Log ( n , 2 ) ; answer . Add ( ( int ) Math . Pow ( k , p ) ) ; n %= ( int ) Math . Pow ( 2 , p ) ; } answer . Reverse ( ) ; foreach ( int x in answer ) { Console . Write ( x + " ▁ " ) ; } } static void Main ( ) { int n = 5 ; int k = 4 ; printSubset ( n , k ) ; } }

Iterator variables: x
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static readonly int maxN = 100000 ; static List < int > [ ] graph = new List < int > [ maxN ] ; static int [ ] indegree = new int [ maxN ] ; static int [ ] job = new int [ maxN ] ; static void addEdge ( int u , int v ) { graph [ u ] . Add ( v ) ; indegree [ v ] ++ ; } static void printOrder ( int n , int m ) { Queue < int > q = new Queue < int > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { if ( indegree [ i ] == 0 ) { q . Enqueue ( i ) ; job [ i ] = 1 ; } } while ( q . Count != 0 ) { int cur = q . Peek ( ) ; q . Dequeue ( ) ; foreach ( int adj in graph [ cur ] ) { indegree [ adj ] -- ; if ( indegree [ adj ] == 0 ) { job [ adj ] = 1 + job [ cur ] ; q . Enqueue ( adj ) ; } } } for ( int i = 1 ; i <= n ; i ++ ) Console . Write ( job [ i ] + " ▁ " ) ; Console . Write ( " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int n , m ; n = 10 ; m = 13 ; for ( int i = 0 ; i < graph . Length ; i ++ ) graph [ i ] = new List < int > ( ) ; 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 ) ; } }

Index/key variables: adj, cur, i, maxN, u, v
Accumulator variables: i
Iterator variables: adj, i
Class/struct names: GFG
C# program:
using System ; class GFG { static int getLeftmostBit ( int n ) { int m = 0 ; while ( n > 1 ) { n = n >> 1 ; m ++ ; } return m ; } static int getNextLeftmostBit ( int n , int m ) { int temp = 1 << m ; while ( n < temp ) { temp = temp >> 1 ; m -- ; } return m ; } static int countSetBit ( int n ) { int m = getLeftmostBit ( n ) ; return _countSetBit ( n , m ) ; } static int _countSetBit ( int n , int m ) { if ( n == 0 ) return 0 ; m = getNextLeftmostBit ( n , m ) ; if ( n == ( ( int ) 1 << ( m + 1 ) ) - 1 ) return ( int ) ( m + 1 ) * ( 1 << m ) ; n = n - ( 1 << m ) ; return ( ( n + 1 ) + countSetBit ( n ) + m * ( 1 << ( m - 1 ) ) ) ; } static int countSetBits ( int L , int R ) { return Math . Abs ( countSetBit ( R ) - countSetBit ( L - 1 ) ) ; } public static void Main ( String [ ] args ) { int L = 3 , R = 5 ; Console . Write ( " Total ▁ set ▁ bit ▁ count ▁ is ▁ " + countSetBits ( L , R ) ) ; } }

Accumulator variables: m
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void printPermutation ( int [ ] arr , int n ) { List < int > odd = new List < int > ( ) ; List < int > even = new List < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 == 0 ) even . Add ( arr [ i ] ) ; else odd . Add ( arr [ i ] ) ; } int size_odd = odd . Count ; int size_even = even . Count ; if ( size_odd > size_even + 1 ) Console . WriteLine ( " - 1" ) ; else { int i = 0 ; int j = 0 ; while ( i < size_odd && j < size_even ) { Console . Write ( odd [ i ] + " ▁ " ) ; ++ i ; Console . Write ( even [ j ] + " ▁ " ) ; ++ j ; } while ( i < size_odd ) { Console . Write ( odd [ i ] + " ▁ " ) ; ++ i ; } while ( j < size_even ) { Console . Write ( even [ j ] + " ▁ " ) ; } } } public static void Main ( String [ ] args ) { int [ ] arr = { 6 , 7 , 9 , 8 , 10 , 11 } ; int N = arr . Length ; printPermutation ( arr , N ) ; } }

Index/key variables: i, j
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void find ( int n ) { Console . Write ( n / 2 ) ; } public static void Main ( string [ ] args ) { int n = 5 ; find ( n ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int [ , ] rem = new int [ 11 , 11 ] ; static int countPairs ( int [ ] a , int n , int k ) { int [ ] len = new int [ n ] ; int [ ] p = new int [ 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 ; } public static void Main ( string [ ] args ) { int [ ] a = { 4 , 5 , 2 } ; int n = a . Length , k = 2 ; Console . Write ( countPairs ( a , n , k ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: ans, i, j, x
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int countDigitSum ( int N , int K ) { int l = ( int ) Math . Pow ( 10 , N - 1 ) , r = ( int ) Math . Pow ( 10 , N ) - 1 ; int count = 0 ; for ( int i = l ; i <= r ; i ++ ) { int num = i ; int [ ] digits = new int [ 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 ; } public static void Main ( ) { int N = 2 , K = 1 ; Console . Write ( countDigitSum ( N , K ) ) ; } }

Index/key variables: N, j
Accumulator variables: count, i, j, num, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { private static List < int > calculate ( int [ ] arr ) { int n = arr . Length ; List < int > ans = new List < int > ( ) ; for ( int i = 0 ; i < arr . Length ; i ++ ) { int sum = 0 ; for ( int j = 0 ; j < arr . Length ; j ++ ) { sum += Math . Abs ( arr [ i ] - arr [ j ] ) ; } ans . Add ( sum ) ; } return ans ; } public static void Main ( string [ ] args ) { int [ ] arr = { 2 , 3 , 5 , 6 } ; List < int > tmp = calculate ( arr ) ; Console . Write ( " [ " ) ; for ( int i = 0 ; i < tmp . Count ; i ++ ) { if ( i != tmp . Count - 1 ) { Console . Write ( tmp [ i ] + " , ▁ " ) ; } else { Console . Write ( tmp [ i ] ) ; } } Console . Write ( " ] " ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG