dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int mod = 1000000007 ; static int waysToColor ( int [ ] arr , int n , int k ) { int [ ] powOf2 = new int [ 500 ] ; int [ , ] c = new int [ 500 , 500 ] ; for ( int i = 0 ; i <= n ; i ++ ) { c [ i , 0 ] = 1 ; for ( int j = 1 ; j <= i ; j ++ ) { c [ i , j ] = ( c [ i - 1 , j ] + c [ i - 1 , j - 1 ] ) % mod ; } } powOf2 [ 0 ] = powOf2 [ 1 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { powOf2 [ i ] = powOf2 [ i - 1 ] * 2 % mod ; } int rem = n - k ; arr [ k ++ ] = n + 1 ; Array . Sort ( arr ) ; int answer = 1 ; for ( int i = 0 ; i < k ; i ++ ) { int x = arr [ i ] - ( i - 1 >= 0 ? arr [ i - 1 ] : 0 ) - 1 ; answer *= c [ rem , x ] % mod * ( i != 0 && i != k - 1 ? powOf2 [ x ] : 1 ) % mod ; rem -= x ; } return answer ; } public static void Main ( String [ ] args ) { int N = 6 ; int K = 3 ; int [ ] arr = { 1 , 2 , 6 , 0 } ; Console . Write ( waysToColor ( arr , N , K ) ) ; } }

Index/key variables: i, x
Accumulator variables: answer, i, j, k, rem
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void printArray ( int [ ] a , int n ) { Array . Sort ( a ) ; int i = 0 ; int j = n - 1 ; while ( i <= j ) { if ( i == j ) { Console . Write ( a [ i ] + " ▁ " ) ; } else { Console . Write ( a [ j ] + " ▁ " ) ; Console . Write ( a [ i ] + " ▁ " ) ; } i = i + 1 ; j = j - 1 ; } Console . WriteLine ( ) ; } public static void Main ( string [ ] args ) { int [ ] arr1 = { 1 , 2 , 3 , 4 , 5 , 6 } ; int n1 = arr1 . Length ; printArray ( arr1 , n1 ) ; } }

Index/key variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int SmallestDiv ( int n ) { for ( int i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { return i ; } } return n ; } public static void Main ( String [ ] args ) { int X = 385 ; int ans = SmallestDiv ( X ) ; Console . Write ( ans + " STRNEWLINE " ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void printArr ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } static void findArray ( int n , int k , int s ) { int [ ] vis = new int [ n ] ; int cnt = 0 ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n && cnt < k ; i += 2 ) { arr [ i ] = s ; vis [ i ] = 1 ; cnt ++ ; } int val = s ; if ( s % 2 == 0 ) val ++ ; else val = val + 2 ; for ( int i = 0 ; i < n ; i ++ ) { if ( vis [ i ] == 0 ) { arr [ i ] = val ; } } printArr ( arr , n ) ; } public static void Main ( ) { int n = 8 , k = 3 , s = 12 ; findArray ( n , k , s ) ; } }

Index/key variables: i, n
Accumulator variables: cnt, i, val
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int N = 100000 ; static int [ ] prime = new int [ N ] ; static int [ ] divi = new int [ N ] ; static int [ ] sum = new int [ N ] ; static void SieveOfEratosthenes ( ) { for ( int i = 0 ; i < N ; i ++ ) prime [ i ] = 1 ; prime [ 0 ] = prime [ 1 ] = 0 ; for ( int p = 2 ; p * p < N ; p ++ ) { if ( prime [ p ] == 1 ) { for ( int i = p * p ; i < N ; i += p ) prime [ i ] = 0 ; } } } static void DivisorCount ( ) { for ( int i = 1 ; i < N ; i ++ ) { for ( int j = i ; j < N ; j += i ) { divi [ j ] ++ ; } } } static void pre ( ) { for ( int i = 1 ; i < N ; i ++ ) { if ( prime [ divi [ i ] ] == 1 ) { sum [ i ] = i ; } } for ( int i = 1 ; i < N ; i ++ ) sum [ i ] += sum [ i - 1 ] ; } public static void Main ( String [ ] args ) { int l = 5 , r = 8 ; SieveOfEratosthenes ( ) ; DivisorCount ( ) ; pre ( ) ; Console . WriteLine ( sum [ r ] - sum [ l - 1 ] ) ; } }

Index/key variables: N, i, j, p, r
Accumulator variables: i, j, p
Iterator variables: i, j, p
Class/struct names: GFG
C# program:
using System ; class GFG { static readonly int M = 1000000007 ; static long power ( long x , int y , int p ) { long res = 1 ; x = x % p ; while ( y > 0 ) { if ( ( y & 1 ) == 1 ) res = ( res * x ) % p ; x = ( x * x ) % p ; } return res ; } static long modInverse ( long n , int p ) { return power ( n , p - 2 , p ) ; } static long nCrModPFermat ( long n , int r , int p ) { if ( r == 0 ) return 1 ; long [ ] fac = new long [ ( int ) n + 1 ] ; fac [ 0 ] = 1 ; int i ; for ( i = 1 ; i <= n ; i ++ ) fac [ i ] = fac [ i - 1 ] * i % p ; return ( fac [ ( int ) n ] * modInverse ( fac [ r ] , p ) % p * modInverse ( fac [ ( int ) n - r ] , p ) % p ) % p ; } static long countOdd ( long n ) { long x = n / 2 ; if ( n % 2 == 1 ) x ++ ; return x ; } static long counteEven ( long n ) { long x = n / 2 ; return x ; } static long CountEvenSumSequences ( long n ) { long count = 0 ; for ( int i = 0 ; i <= n ; i ++ ) { int even = i , odd = ( int ) n - i ; if ( odd % 2 == 1 ) continue ; long tot = ( power ( countOdd ( n ) , odd , M ) * nCrModPFermat ( n , odd , M ) ) % M ; tot = ( tot * power ( counteEven ( n ) , i , M ) ) % M ; count += tot ; count %= M ; } return count ; } public static void Main ( String [ ] args ) { long n = 5 ; Console . WriteLine ( CountEvenSumSequences ( n ) ) ; } }

Index/key variables: i, r
Accumulator variables: count, i, x
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int MAX = 1000000 ; static bool [ ] prime = new bool [ MAX ] ; static void SieveOfEratosthenes ( ) { for ( int i = 0 ; i < MAX ; i ++ ) prime [ i ] = true ; for ( int p = 2 ; p * p < MAX ; p ++ ) { if ( prime [ p ] ) { for ( int i = p * p ; i < MAX ; i += p ) prime [ i ] = false ; } } } static int sumPrime ( int k ) { SieveOfEratosthenes ( ) ; List < int > v = new List < int > ( ) ; for ( int i = 2 ; i < MAX ; i ++ ) { if ( prime [ i ] ) v . Add ( i ) ; } int sum = 0 ; int skip = ( k * ( k - 1 ) ) / 2 ; while ( k > 0 ) { sum += v [ skip ] ; skip ++ ; k -- ; } return sum ; } public static void Main ( String [ ] args ) { int k = 3 ; Console . WriteLine ( sumPrime ( k ) ) ; } }

Index/key variables: MAX, i, p, skip
Accumulator variables: i, k, p, skip, sum
Iterator variables: i, p
Class/struct names: GFG
C# program:
using System ; class GFG { static int nextOccurrence ( String str , int n , int start , char ch ) { for ( int i = start ; i < n ; i ++ ) { if ( str [ i ] == ch ) return i ; } return - 1 ; } static int countSubStr ( String str , int n , char ch ) { int cnt = 0 ; int j = nextOccurrence ( str , n , 0 , ch ) ; for ( int i = 0 ; i < n ; i ++ ) { while ( j != - 1 && j < i ) { j = nextOccurrence ( str , n , j + 1 , ch ) ; } if ( j == - 1 ) break ; cnt += ( n - j ) ; } return cnt ; } static public void Main ( ) { String str = " geeksforgeeks " ; int n = str . Length ; char ch = ' k ' ; Console . WriteLine ( countSubStr ( str , n , ch ) ) ; } }

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void checkEvenOdd ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 == 0 ) { Console . Write ( " Even " ) ; return ; } } Console . Write ( " Odd " ) ; } static public void Main ( ) { int [ ] arr = { 2 , 12 , 20 , 36 , 38 } ; int n = arr . Length ; checkEvenOdd ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int power ( int x , int y , int p ) { int res = 1 ; x = x % p ; while ( y > 0 ) { if ( y % 2 == 1 ) { res = ( res * x ) % p ; } x = ( x * x ) % p ; } return res ; } public static void Main ( ) { int L = 2 ; int P = ( int ) Math . Pow ( 10 , 9 ) ; int ans = power ( 325 , L , P ) ; Console . WriteLine ( ans ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int MAXN = 30 ; static int countMaxLength ( int N ) { int res ; int [ ] pre = new int [ MAXN ] ; int p = 1 ; pre [ 0 ] = 0 ; for ( int i = 1 ; i < MAXN ; i ++ ) { p *= 2 ; pre [ i ] = pre [ i - 1 ] + i * p ; } int ind = 0 ; for ( int i = 1 ; i < MAXN ; i ++ ) { if ( pre [ i ] >= N ) { ind = i ; break ; } } int x = N - pre [ ind - 1 ] ; int y = 2 * ind - 1 ; if ( x >= y ) res = Math . Min ( x , y ) ; else res = Math . Max ( x , 2 * ( ind - 2 ) + 1 ) ; return res ; } public static void Main ( ) { int N = 25 ; Console . WriteLine ( countMaxLength ( N ) ) ; } }

Index/key variables: MAXN, i
Accumulator variables: i, p
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int factorialUsingRecursion ( int n ) { if ( n == 0 ) return 1 ; return n * factorialUsingRecursion ( n - 1 ) ; } static int factorialUsingIteration ( int n ) { int res = 1 , i ; for ( i = 2 ; i <= n ; i ++ ) res *= i ; return res ; } public static void Main ( String [ ] args ) { int num = 5 ; Console . WriteLine ( " Factorial ▁ of ▁ " + num + " ▁ using ▁ Recursion ▁ is : ▁ " + factorialUsingRecursion ( 5 ) ) ; Console . WriteLine ( " Factorial ▁ of ▁ " + num + " ▁ using ▁ Iteration ▁ is : ▁ " + factorialUsingIteration ( 5 ) ) ; } }

Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void revereseArray ( int [ ] arr , int n ) { int [ ] rev = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) rev [ n - i - 1 ] = arr [ i ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = rev [ i ] ; } public static void printArray ( int [ ] arr , int size ) { for ( int i = 0 ; i < size ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; Console . Write ( " STRNEWLINE " ) ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 6 } ; int n = arr . Length ; printArray ( arr , n ) ; revereseArray ( arr , n ) ; Console . WriteLine ( " Reversed ▁ array ▁ is " ) ; printArray ( arr , n ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int __ ( int x , int y ) { return x ; } public static void revereseArray ( int [ ] arr , int n ) { for ( int i = 0 ; i < n / 2 ; i ++ ) arr [ i ] = __ ( arr [ n - i - 1 ] , arr [ n - i - 1 ] = arr [ i ] ) ; } public static void printArray ( int [ ] arr , int size ) { for ( int i = 0 ; i < size ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; Console . WriteLine ( " " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = new int [ ] { 1 , 2 , 3 , 4 , 5 , 6 } ; int n = arr . Length ; printArray ( arr , n ) ; revereseArray ( arr , n ) ; Console . WriteLine ( " Reversed ▁ array ▁ is " ) ; printArray ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void findString ( string str , int M ) { int N = str . Length ; M = Math . Min ( M , N ) ; string s1 = " " ; while ( M != 0 ) { s1 = " " ; for ( int i = 0 ; i < N ; i ++ ) { if ( str [ i ] == '0' ) { if ( ( ( i > 0 && str [ i - 1 ] == '1' ) && ( i < N - 1 && str [ i + 1 ] != '1' ) ) || ( ( i > 0 && str [ i - 1 ] != '1' ) && ( i < N - 1 && str [ i + 1 ] == '1' ) ) ) { s1 += '1' ; } else { if ( i == 0 i == N - 1 ) { s1 += '1' ; } else { s1 += '0' ; } } } else { s1 += '1' ; } } if ( str == s1 ) break ; M -- ; } Console . WriteLine ( s1 ) ; } static void Main ( ) { string str = "0110100" ; int M = 3 ; findString ( str , M ) ; } }

Index/key variables: i
Accumulator variables: M, i, s1
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int numberofSubsequences ( int [ ] a , int L , int R , int X , int n ) { int ans = 0 ; for ( int i = 0 ; i < ( 1 << n ) ; i ++ ) { int cnt = 0 , sum = 0 ; int minVal = Int32 . MaxValue , maxVal = Int32 . MinValue ; for ( int j = 0 ; j < n ; j ++ ) { if ( ( i & ( 1 << j ) ) == 0 ) { cnt += 1 ; sum += a [ j ] ; maxVal = Math . Max ( maxVal , a [ j ] ) ; minVal = Math . Min ( minVal , a [ j ] ) ; } } if ( cnt >= 2 && sum >= L && sum <= R && ( maxVal - minVal >= X ) ) { ans += 1 ; } } return ans ; } static public void Main ( ) { int [ ] a = { 10 , 20 , 30 , 25 } ; int L = 40 , R = 50 , X = 10 ; int N = a . Length ; Console . Write ( numberofSubsequences ( a , L , R , X , N ) ) ; } }

Index/key variables: j
Accumulator variables: ans, cnt, i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int Minimum ( int N , int K ) { int sum = N * ( N + 1 ) / 2 ; if ( K > sum ) return - 1 ; if ( K <= N ) return 1 ; sum = 0 ; int count = 0 ; while ( N >= 1 && sum < K ) { count += 1 ; sum += N ; N -= 1 ; } return count ; } static public void Main ( ) { int N = 5 , K = 10 ; Console . Write ( Minimum ( N , K ) ) ; } }

Accumulator variables: N, count, sum
Class/struct names: GFG
C# program:
using System ; class GFG { static int Count ( int N , int K ) { if ( K == 0 ) return 0 ; int res = 0 ; int low = 1 , high = N ; while ( low <= high ) { int mid = ( low + high ) / 2 ; int sum = ( mid * mid + mid ) / 2 ; if ( sum <= K ) { res = Math . Max ( res , mid ) ; low = mid + 1 ; } else { high = mid - 1 ; } } return res ; } public static void Main ( String [ ] args ) { int N = 6 , K = 14 ; Console . Write ( Count ( N , K ) ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { public static int largestNum ( int [ ] arr ) { HashSet < int > set = new HashSet < int > ( ) ; int res = 0 ; for ( int i = 0 ; i < arr . Length ; i ++ ) { set . Add ( arr [ i ] ) ; if ( set . Contains ( - 1 * arr [ i ] ) ) { res = Math . Max ( res , Math . Abs ( arr [ i ] ) ) ; } } return res ; } static public void Main ( ) { int [ ] arr = { 3 , 2 , - 2 , 5 , - 3 } ; Console . WriteLine ( largestNum ( arr ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void findElement ( int [ ] A , int N , int X ) { int i = 0 ; int Comparisons = 0 ; int T = 1 ; Comparisons ++ ; if ( N % 2 == 1 ) { i = 1 ; T *= ( A [ 0 ] - X ) ; } for ( ; i < N ; i += 2 ) { Comparisons += 1 ; T *= ( A [ i ] - X ) ; T *= ( A [ i + 1 ] - X ) ; } Comparions += 1 ; if ( T == 0 ) { Console . Write ( " Yes ▁ " + Comparisons ) ; } else { Console . Write ( " No " ) ; } } public static void Main ( ) { int [ ] A = { - 3 , 5 , 11 , 3 , 100 , 2 , 88 , 22 , 7 , 900 , 23 , 4 , 1 } ; int N = A . Length ; int X = 1 ; findElement ( A , N , X ) ; } }

Index/key variables: i
Accumulator variables: Comparions, Comparisons, T, i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int find ( List < int > arr , int N , int key ) { int l = 0 ; int h = N - 1 ; while ( l <= h ) { int mid = ( l + h ) / 2 ; if ( arr [ mid ] == key ) return mid ; if ( arr [ l ] >= arr [ mid ] ) { if ( arr [ l ] >= key && key >= arr [ mid ] ) h = mid - 1 ; else l = mid + 1 ; } else { if ( arr [ mid ] >= key && key >= arr [ h ] ) l = mid + 1 ; else h = mid - 1 ; } } return - 1 ; } public static void Main ( ) { List < int > arr = new List < int > ( ) { 10 , 8 , 6 , 5 , 2 , 1 , 13 , 12 } ; int N = arr . Count ; int key = 8 ; int ans = find ( arr , N , key ) ; Console . Write ( ans ) ; } }

Index/key variables: h, l, mid
Class/struct names: GFG
C# program:
using System ; class GFG { static void maxItems ( int n , int m , int [ ] a , int [ ] b , int K ) { int count = 0 ; int [ ] A = new int [ n + 1 ] ; int [ ] B = new int [ m + 1 ] ; A [ 0 ] = 0 ; B [ 0 ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { A [ i ] = a [ i - 1 ] + A [ i - 1 ] ; } for ( int i = 1 ; i <= m ; i ++ ) { B [ i ] = b [ i - 1 ] + B [ i - 1 ] ; } for ( int i = 0 ; i <= n ; i ++ ) { if ( A [ i ] > K ) break ; int rem = K - A [ i ] ; int j = 0 ; int lo = 0 , hi = m ; while ( lo <= hi ) { int mid = ( lo + hi ) / 2 ; if ( B [ mid ] <= rem ) { j = mid ; lo = mid + 1 ; } else { hi = mid - 1 ; } } count = Math . Max ( j + i , count ) ; } Console . Write ( count ) ; } public static void Main ( String [ ] args ) { int n = 4 , m = 5 , K = 7 ; int [ ] A = { 2 , 4 , 7 , 3 } ; int [ ] B = { 1 , 9 , 3 , 4 , 5 } ; maxItems ( n , m , A , B , K ) ; } }

Index/key variables: i, mid
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isPrime ( int N ) { if ( N == 1 ) return false ; for ( int i = 2 ; i * i <= N ; i ++ ) { if ( N % i == 0 ) return false ; } return true ; } static int findCoPrime ( int L , int R ) { int coPrime ; for ( int i = R + 1 ; ; i ++ ) { if ( isPrime ( i ) ) { coPrime = i ; break ; } } return coPrime ; } public static void Main ( string [ ] args ) { int L = 16 , R = 17 ; Console . WriteLine ( findCoPrime ( L , R ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void maximumValue ( int [ ] arr , int n ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { ans = Math . Max ( ans , arr [ i ] + arr [ j ] + i - j ) ; } } Console . Write ( ans ) ; } static void Main ( ) { int [ ] arr = { 1 , 9 , 3 , 6 , 5 } ; int N = arr . Length ; maximumValue ( arr , N ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void maximumValue ( int [ ] arr , int n ) { int maxvalue = arr [ 0 ] ; int result = 0 ; for ( int i = 1 ; i < n ; i ++ ) { result = Math . Max ( result , maxvalue + arr [ i ] - i ) ; maxvalue = Math . Max ( maxvalue , arr [ i ] + i ) ; } Console . Write ( result ) ; } static void Main ( ) { int [ ] arr = { 1 , 9 , 3 , 6 , 5 } ; int N = arr . Length ; maximumValue ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int lower_bound ( int [ ] arr , int key ) { int low = 0 ; int high = arr . Length - 1 ; while ( low < high ) { int mid = low + ( high - low ) / 2 ; if ( arr [ mid ] >= key ) { high = mid ; } else { low = mid + 1 ; } } return low ; } static int closestValue ( int [ ] A , int k ) { int close = A [ A . Length - 1 ] ; int it = lower_bound ( A , k ) ; if ( it != A . Length ) { close = A [ it ] ; if ( it != 0 ) { if ( ( k - A [ it - 1 ] ) < ( close - k ) ) { close = A [ it - 1 ] ; } } } return close ; } static void minPossible ( int [ ] arr , int [ ] brr , int [ ] crr ) { Array . Sort ( arr ) ; Array . Sort ( crr ) ; int minimum = Int32 . MaxValue ; foreach ( int val in brr ) { int arr_close = closestValue ( arr , val ) ; int crr_close = closestValue ( crr , val ) ; if ( Math . Abs ( val - arr_close ) + Math . Abs ( val - crr_close ) < minimum ) minimum = Math . Abs ( val - arr_close ) + Math . Abs ( val - crr_close ) ; } Console . WriteLine ( minimum ) ; } static void Main ( ) { int [ ] a = { 1 , 8 , 5 } ; int [ ] b = { 2 , 9 } ; int [ ] c = { 5 , 4 } ; minPossible ( a , b , c ) ; } }

Index/key variables: it, mid
Iterator variables: val
Class/struct names: GFG
C# program:
using System ; using System . Linq ; class GFG { static int minimum_swaps ( int [ ] arr , int n ) { int count = 0 ; int max_el = arr . Max ( ) ; int min_el = arr . Min ( ) ; if ( min_el == max_el ) return 0 ; int index_max = - 1 ; int index_min = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == max_el && index_max == - 1 ) { index_max = i ; } if ( arr [ i ] == min_el ) { index_min = i ; } } count += index_max ; count += ( n - 1 - index_min ) ; if ( index_min < index_max ) count -= 1 ; return count ; } public static void Main ( string [ ] args ) { int [ ] arr = { 2 , 4 , 1 , 6 , 5 } ; int N = arr . Length ; Console . WriteLine ( minimum_swaps ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int ans ; static void DFS ( int src , List < List < int > > Adj , int [ ] arr , int currentMin , int currentMax ) { ans = Math . Max ( ans , Math . Max ( Math . Abs ( currentMax - arr [ src - 1 ] ) , Math . Abs ( currentMin - arr [ src - 1 ] ) ) ) ; currentMin = Math . Min ( currentMin , arr [ src - 1 ] ) ; currentMax = Math . Min ( currentMax , arr [ src - 1 ] ) ; foreach ( int child in Adj [ src ] ) { DFS ( child , Adj , arr , currentMin , currentMax ) ; } } static void getMaximumDifference ( int [ , ] Edges , int [ ] arr , int N , int M ) { ans = 0 ; List < List < int > > Adj = new List < List < int > > ( ) ; for ( int i = 0 ; i < N + 1 ; i ++ ) Adj . Add ( new List < int > ( ) ) ; for ( int i = 0 ; i < M ; i ++ ) { int u = Edges [ i , 0 ] ; int v = Edges [ i , 1 ] ; Adj [ u ] . Add ( v ) ; } DFS ( 1 , Adj , arr , arr [ 0 ] , arr [ 0 ] ) ; Console . WriteLine ( ans ) ; } static void Main ( ) { int N = 5 , M = 4 ; int [ , ] Edges = { { 1 , 2 } , { 2 , 3 } , { 4 , 5 } , { 1 , 3 } } ; int [ ] arr = { 13 , 8 , 3 , 15 , 18 } ; getMaximumDifference ( Edges , arr , N , M ) ; } }

Index/key variables: src, u
Accumulator variables: i
Iterator variables: child, i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void isComment ( string S ) { char [ ] line = S . ToCharArray ( ) ; if ( line [ 0 ] == ' / ' && line [ 1 ] == ' / ' && line [ 2 ] != ' / ' ) { Console . WriteLine ( " It ▁ is ▁ a ▁ single - line ▁ comment " ) ; return ; } if ( line [ line . Length - 2 ] == ' * ' && line [ line . Length - 1 ] == ' / ' && line [ 0 ] == ' / ' && line [ 1 ] == ' * ' ) { Console . WriteLine ( " It ▁ is ▁ a ▁ multi - line ▁ comment " ) ; return ; } Console . WriteLine ( " It ▁ is ▁ not ▁ a ▁ comment " ) ; } static public void Main ( ) { string line = " GeeksForGeeks ▁ GeeksForGeeks " ; isComment ( line ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void indivisibleDigits ( int [ ] arr , int N ) { for ( int i = 0 ; i < N ; i ++ ) { Console . Write ( arr [ i ] + " : ▁ " ) ; for ( int j = 2 ; j < 10 ; j ++ ) { int temp = arr [ i ] ; bool flag = true ; while ( temp > 0 ) { if ( ( temp % 10 ) != 0 && ( temp % 10 ) % j == 0 ) { flag = false ; break ; } temp /= 10 ; } if ( flag ) { Console . Write ( j + " ▁ " ) ; } } Console . WriteLine ( ) ; } } public static void Main ( ) { int [ ] arr = { 4162 , 1152 , 99842 } ; int N = arr . Length ; indivisibleDigits ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i, j, temp
Iterator variables: i, j
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; public class GFG { static void longestSequence ( int [ ] arr , int N ) { if ( N == 0 ) { Console . WriteLine ( 0 ) ; return ; } Array . Sort ( arr ) ; int maxLen = 1 ; int len = 1 ; for ( int i = 1 ; i < N ; i ++ ) { if ( arr [ i ] == arr [ i - 1 ] arr [ i ] == arr [ i - 1 ] + 1 ) { len ++ ; maxLen = Math . Max ( maxLen , len ) ; } else { len = 1 ; } } Console . WriteLine ( maxLen ) ; } public static void Main ( string [ ] args ) { int [ ] arr = { 8 , 5 , 4 , 8 , 4 } ; int N = arr . Length ; longestSequence ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i, len
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void minSum ( int [ ] arr , int N , int [ ] Q , int M ) { for ( int i = 0 ; i < M ; i ++ ) { int val = Q [ i ] ; int front = 0 , rear = 0 ; for ( int j = 0 ; j < N ; j ++ ) { front += arr [ j ] ; if ( arr [ j ] == val ) { break ; } } for ( int j = N - 1 ; j >= 0 ; j -- ) { rear += arr [ j ] ; if ( arr [ j ] == val ) { break ; } } Console . Write ( Math . Min ( front , rear ) + " ▁ " ) ; } } static public void Main ( ) { int [ ] arr = { 2 , 3 , 6 , 7 , 4 , 5 , 1 } ; int N = arr . Length ; int [ ] Q = { 7 , 6 } ; int M = Q . Length ; minSum ( arr , N , Q , M ) ; } }

Index/key variables: i, j
Accumulator variables: front, i, j, rear
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static void KthCharacter ( string S , int N , int K ) { char [ ] strarray = S . ToCharArray ( ) ; Array . Sort ( strarray ) ; char ch = strarray [ K - 1 ] ; int count = 0 ; foreach ( char c in strarray ) { if ( c == ch ) count ++ ; } Console . Write ( count ) ; } public static void Main ( ) { string S = " geeksforgeeks " ; int N = S . Length ; int K = 3 ; KthCharacter ( S , N , K ) ; } }

Accumulator variables: count
Iterator variables: c
Class/struct names: GFG