dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static readonly int N = 4 ; static readonly int M = 5 ; static void preProcess ( int [ , ] mat , int [ , ] aux ) { for ( int i = 0 ; i < M ; i ++ ) aux [ 0 , i ] = mat [ 0 , i ] ; for ( int i = 1 ; i < N ; i ++ ) for ( int j = 0 ; j < M ; j ++ ) aux [ i , j ] = mat [ i , j ] + aux [ i - 1 , j ] ; for ( int i = 0 ; i < N ; i ++ ) for ( int j = 1 ; j < M ; j ++ ) aux [ i , j ] += aux [ i , j - 1 ] ; } static int sumQuery ( int [ , ] aux , int tli , int tlj , int rbi , int rbj ) { int res = aux [ rbi , rbj ] ; if ( tli > 0 ) res = res - aux [ tli - 1 , rbj ] ; if ( tlj > 0 ) res = res - aux [ rbi , tlj - 1 ] ; if ( tli > 0 && tlj > 0 ) res = res + aux [ tli - 1 , tlj - 1 ] ; return res ; } static bool check ( int mid , int [ , ] aux , int K ) { bool satisfies = true ; for ( int x = 0 ; x < N ; x ++ ) { for ( int y = 0 ; y < M ; y ++ ) { if ( x + mid - 1 <= N - 1 && y + mid - 1 <= M - 1 ) { if ( sumQuery ( aux , x , y , x + mid - 1 , y + mid - 1 ) > K ) satisfies = false ; } } } return ( satisfies == true ) ; } static int maximumSquareSize ( int [ , ] mat , int K ) { int [ , ] aux = new int [ N , M ] ; preProcess ( mat , aux ) ; int low = 1 , high = Math . Min ( N , M ) ; int mid ; while ( high - low > 1 ) { mid = ( low + high ) / 2 ; if ( check ( mid , aux , K ) ) { low = mid ; } else high = mid ; } if ( check ( high , aux , K ) ) return high ; return low ; } public static void Main ( String [ ] args ) { int K = 30 ; int [ , ] mat = { { 1 , 2 , 3 , 4 , 6 } , { 5 , 3 , 8 , 1 , 2 } , { 4 , 6 , 7 , 5 , 5 } , { 2 , 4 , 8 , 9 , 4 } } ; Console . Write ( maximumSquareSize ( mat , K ) ) ; } }

Accumulator variables: i, j, x, y
Iterator variables: i, j, x, y
Boolean variables: satisfies
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ ] segment_tree = new int [ 4 * 1000000 ] ; static int build ( int [ ] A , int start , int end , int node ) { if ( start == end ) segment_tree [ node ] = A [ start ] ; else { int mid = ( start + end ) / 2 ; segment_tree [ node ] = Math . Max ( build ( A , start , mid , 2 * node + 1 ) , build ( A , mid + 1 , end , 2 * node + 2 ) ) ; } return segment_tree [ node ] ; } static int query ( int start , int end , int l , int r , int node ) { if ( start > r end < l ) return - 1 ; if ( start >= l && end <= r ) return segment_tree [ node ] ; int mid = ( start + end ) / 2 ; return Math . Max ( query ( start , mid , l , r , 2 * node + 1 ) , query ( mid + 1 , end , l , r , 2 * node + 2 ) ) ; } static int longestSubArray ( int [ ] A , int N , int K ) { int res = 1 ; int [ ] preSum = new int [ N + 1 ] ; preSum [ 0 ] = A [ 0 ] ; for ( int i = 0 ; i < N ; i ++ ) preSum [ i + 1 ] = preSum [ i ] + A [ i ] ; build ( A , 0 , N - 1 , 0 ) ; for ( int i = 0 ; i < N ; i ++ ) { int start = i , end = N - 1 , mid , max_index = i ; while ( start <= end ) { mid = ( start + end ) / 2 ; int max_element = query ( 0 , N - 1 , i , mid , 0 ) ; int expected_sum = ( mid - i + 1 ) * max_element ; int actual_sum = preSum [ mid + 1 ] - preSum [ i ] ; if ( expected_sum - actual_sum <= K ) { start = mid + 1 ; max_index = Math . Max ( max_index , mid ) ; } else { end = mid - 1 ; } } res = Math . Max ( res , max_index - i + 1 ) ; } return res ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 0 , 4 , 6 , 7 } ; int K = 6 ; int N = arr . Length ; Console . WriteLine ( longestSubArray ( arr , N , K ) ) ; } }

Index/key variables: i, node, start
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countNums ( int l , int r ) { int cnt = 0 ; for ( int i = l ; i <= r ; i ++ ) { int lastDigit = ( i % 10 ) ; if ( ( lastDigit % 10 ) == 2 || ( lastDigit % 10 ) == 3 || ( lastDigit % 10 ) == 9 ) { cnt ++ ; } } return cnt ; } public static void Main ( ) { int l = 11 , r = 33 ; Console . Write ( countNums ( l , r ) ) ; } }

Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findMinimumK ( int [ ] a , int n , int s ) { int maximum = a [ 0 ] ; for ( int i = 0 ; i < n ; i ++ ) { maximum = Math . Max ( maximum , a [ i ] ) ; } int low = 1 , high = maximum + 1 ; int ans = high ; while ( low <= high ) { int mid = ( low + high ) / 2 ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += ( int ) ( a [ i ] / mid ) ; } if ( sum > s ) low = mid + 1 ; else { ans = Math . Min ( ans , mid ) ; high = mid - 1 ; } } return ans ; } public static void Main ( ) { int [ ] a = { 10 , 7 , 8 , 10 , 12 , 19 } ; int n = a . Length ; int s = 27 ; Console . WriteLine ( findMinimumK ( a , n , s ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ , ] SparseTable = new int [ 100001 , 51 ] ; static void buildSparseTable ( int [ ] a , int n ) { for ( int i = 0 ; i < n ; i ++ ) { SparseTable [ i , 0 ] = a [ i ] ; } for ( int j = 1 ; j <= 19 ; j ++ ) { for ( int i = 0 ; i <= n - ( 1 << j ) ; i ++ ) { SparseTable [ i , j ] = __gcd ( SparseTable [ i , j - 1 ] , SparseTable [ i + ( 1 << ( j - 1 ) ) , j - 1 ] ) ; } } } static int queryForGCD ( int L , int R ) { int returnValue ; int j = ( int ) ( Math . Log ( R - L + 1 ) ) ; returnValue = __gcd ( SparseTable [ L , j ] , SparseTable [ R - ( 1 << j ) + 1 , j ] ) ; return returnValue ; } static int nextPosition ( int tempGCD , int startPointer , int prevEndPointer , int n ) { int high = n - 1 ; int low = prevEndPointer ; int mid = prevEndPointer ; int nextPos = prevEndPointer ; while ( high >= low ) { mid = ( ( high + low ) >> 1 ) ; if ( queryForGCD ( startPointer , mid ) == tempGCD ) { nextPos = mid ; low = mid + 1 ; } else { high = mid - 1 ; } } return nextPos + 1 ; } static int calculateSum ( int [ ] a , int n ) { buildSparseTable ( a , n ) ; int endPointer , startPointer , prevEndPointer , tempGCD ; int tempAns = 0 ; for ( int i = 0 ; i < n ; i ++ ) { endPointer = i ; startPointer = i ; prevEndPointer = i ; tempGCD = a [ i ] ; while ( endPointer < n ) { endPointer = nextPosition ( tempGCD , startPointer , prevEndPointer , n ) ; tempAns += ( ( endPointer - prevEndPointer ) * tempGCD ) ; prevEndPointer = endPointer ; if ( endPointer < n ) { tempGCD = __gcd ( tempGCD , a [ endPointer ] ) ; } } } return tempAns ; } static int __gcd ( int a , int b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } public static void Main ( String [ ] args ) { int n = 6 ; int [ ] a = { 2 , 2 , 2 , 3 , 5 , 5 } ; Console . WriteLine ( calculateSum ( a , n ) ) ; } }

Index/key variables: endPointer, i
Accumulator variables: i, j, tempAns
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int partition ( int [ ] arr , int low , int high ) { int temp ; int pivot = arr [ high ] ; int i = ( low - 1 ) ; for ( int j = low ; j <= high - 1 ; j ++ ) { if ( arr [ j ] <= pivot ) { i ++ ; temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; } } temp = arr [ i + 1 ] ; arr [ i + 1 ] = arr [ high ] ; arr [ high ] = temp ; return ( i + 1 ) ; } static int kthSmallest ( int [ ] a , int left , int right , int k ) { while ( left <= right ) { int pivotIndex = partition ( a , left , right ) ; if ( pivotIndex == k - 1 ) return a [ pivotIndex ] ; else if ( pivotIndex > k - 1 ) right = pivotIndex - 1 ; else left = pivotIndex + 1 ; } return - 1 ; } public static void Main ( String [ ] args ) { int [ ] arr = { 10 , 4 , 5 , 8 , 11 , 6 , 26 } ; int n = arr . Length ; int k = 5 ; Console . WriteLine ( " K - th ▁ smallest ▁ element ▁ is ▁ " + kthSmallest ( arr , 0 , n - 1 , k ) ) ; } }

Index/key variables: high, i, j, pivotIndex
Accumulator variables: i, j
Iterator variables: j
Class/struct names: GFG
C# program:
using System ; class GFG { static void Max_Sum ( int [ ] arr , int n , int k ) { int p = n ; Array . Sort ( arr ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] >= k ) { p = i ; break ; } } int maxsum = 0 , a = 0 , b = 0 ; for ( int i = 0 ; i < p ; i ++ ) { for ( int j = i + 1 ; j < p ; j ++ ) { if ( arr [ i ] + arr [ j ] < k && arr [ i ] + arr [ j ] > maxsum ) { maxsum = arr [ i ] + arr [ j ] ; a = arr [ i ] ; b = arr [ j ] ; } } } Console . WriteLine ( a + " ▁ " + b ) ; } public static void Main ( ) { int [ ] arr = { 5 , 20 , 110 , 100 , 10 } ; int k = 85 ; int n = arr . Length ; Max_Sum ( arr , n , k ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isPalindrome ( string str , int i , int j ) { while ( i < j ) { if ( str [ i ] != str [ j ] ) { return false ; } i ++ ; j -- ; } return true ; } static int maxLenPalindrome ( string str , int n , char ch ) { int maxLen = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == ch ) { for ( int j = n - 1 ; j >= i ; j -- ) { if ( str [ j ] == ch ) { if ( isPalindrome ( str , i , j ) ) { maxLen = Math . Max ( maxLen , j - i + 1 ) ; break ; } } } } } return maxLen ; } public static void Main ( ) { string str = " lapqooqpqpl " ; int n = str . Length ; char ch = ' p ' ; Console . WriteLine ( maxLenPalindrome ( str , n , ch ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int MAX = 26 ; static String countingsort ( char [ ] s ) { int [ ] count = new int [ MAX ] ; for ( int i = 0 ; i < s . Length ; i ++ ) { count [ s [ i ] - ' a ' ] ++ ; } int index = 0 ; for ( int i = 0 ; i < MAX ; i ++ ) { int j = 0 ; while ( j < count [ i ] ) { s [ index ++ ] = ( char ) ( i + ' a ' ) ; j ++ ; } } return String . Join ( " " , s ) ; } static Boolean isPossible ( List < String > v , String str ) { str = countingsort ( str . ToCharArray ( ) ) ; for ( int i = 0 ; i < v . Count - 1 ; i ++ ) { for ( int j = i + 1 ; j < v . Count ; j ++ ) { String temp = v [ i ] + v [ j ] ; temp = countingsort ( temp . ToCharArray ( ) ) ; if ( temp . Equals ( str ) ) { return true ; } } } return false ; } public static void Main ( String [ ] args ) { String str = " amazon " ; String [ ] arr = { " fds " , " oxq " , " zoa " , " epw " , " amn " } ; List < String > v = new List < String > ( arr ) ; if ( isPossible ( v , str ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: MAX, i, j
Accumulator variables: i, index, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 256 ; static int [ , ] freq ; static void preCalculate ( string str , int n ) { freq [ ( int ) str [ 0 ] , 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { char ch = str [ i ] ; for ( int j = 0 ; j < MAX ; j ++ ) { char charToUpdate = ( char ) j ; if ( charToUpdate == ch ) freq [ j , i ] = freq [ j , i - 1 ] + 1 ; else freq [ j , i ] = freq [ j , i - 1 ] ; } } } static int getFrequency ( char ch , int l , int r ) { if ( l == 0 ) return freq [ ( int ) ch , r ] ; else return ( freq [ ( int ) ch , r ] - freq [ ( int ) ch , l - 1 ] ) ; } static string firstNonRepeating ( string str , int n , int l , int r ) { for ( int i = l ; i < r ; i ++ ) { char ch = str [ i ] ; if ( getFrequency ( ch , l , r ) == 1 ) return ( " " + ch ) ; } return " - 1" ; } public static void Main ( ) { string str = " GeeksForGeeks " ; int n = str . Length ; int [ , ] queries = { { 0 , 3 } , { 2 , 3 } , { 5 , 12 } } ; int q = queries . Length ; freq = new int [ MAX , n ] ; preCalculate ( str , n ) ; for ( int i = 0 ; i < q ; i ++ ) { Console . WriteLine ( firstNonRepeating ( str , n , queries [ i , 0 ] , queries [ i , 1 ] ) ) ; } } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int maxLength ( String s , int n ) { int ans = int . MinValue ; List < int > A = new List < int > ( ) ; List < int > L = new List < int > ( ) ; List < int > R = new List < int > ( ) ; int [ ] freq = new int [ n + 5 ] ; for ( int i = 0 ; i < 26 ; i ++ ) { int count = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( s [ j ] - ' a ' == i ) count ++ ; freq [ j ] = count ; } for ( int j = 1 ; j < n ; j ++ ) { L . Add ( ( 2 * freq [ j - 1 ] ) - j ) ; R . Add ( ( 2 * freq [ j ] ) - j ) ; } int max_len = int . MinValue ; int min_val = int . MaxValue ; for ( int j = 0 ; j < L . Count ; j ++ ) { min_val = Math . Min ( min_val , L [ j ] ) ; A . Add ( min_val ) ; int l = 0 , r = j ; while ( l <= r ) { int mid = ( l + r ) >> 1 ; if ( A [ mid ] <= R [ j ] ) { max_len = Math . Max ( max_len , j - mid + 1 ) ; r = mid - 1 ; } else { l = mid + 1 ; } } } ans = Math . Max ( ans , max_len ) ; A . Clear ( ) ; R . Clear ( ) ; L . Clear ( ) ; } return ans ; } public static void Main ( String [ ] args ) { String s = " ababbbacbcbcca " ; int n = s . Length ; Console . WriteLine ( maxLength ( s , n ) ) ; } }

Index/key variables: j, mid
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int NO_OF_CHARS = 256 ; static int firstRepeating ( String str ) { Boolean [ ] visited = new Boolean [ NO_OF_CHARS ] ; for ( int i = 0 ; i < NO_OF_CHARS ; i ++ ) visited [ i ] = false ; int res = - 1 ; for ( int i = str . Length - 1 ; i >= 0 ; i -- ) { if ( visited [ str [ i ] ] == false ) visited [ str [ i ] ] = true ; else res = i ; } return res ; } public static void Main ( String [ ] args ) { String str = " geeksforgeeks " ; int index = firstRepeating ( str ) ; if ( index == - 1 ) Console . Write ( " Either ▁ all ▁ characters ▁ are ▁ " + " distinct ▁ or ▁ string ▁ is ▁ empty " ) ; else Console . Write ( " First ▁ Repeating ▁ character " + " ▁ is ▁ { 0 } " , str [ index ] ) ; } }

Index/key variables: NO_OF_CHARS, i, index
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxSum ( int [ ] arr , int n , int K ) { int maximum = int . MinValue ; int [ ] sum = new int [ n ] ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( i + K < n ) sum [ i ] = sum [ i + K ] + arr [ i ] ; else sum [ i ] = arr [ i ] ; maximum = Math . Max ( maximum , sum [ i ] ) ; } return maximum ; } public static void Main ( ) { int [ ] arr = { 3 , 6 , 4 , 7 , 2 } ; int n = arr . Length ; int K = 2 ; Console . Write ( maxSum ( arr , n , K ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countPairs ( string s1 , int n1 , string s2 , int n2 ) { int [ ] freq1 = new int [ 26 ] ; int [ ] freq2 = new int [ 26 ] ; Array . Fill ( freq1 , 0 ) ; Array . Fill ( freq2 , 0 ) ; int i , count = 0 ; for ( i = 0 ; i < n1 ; i ++ ) freq1 [ s1 [ i ] - ' a ' ] ++ ; for ( i = 0 ; i < n2 ; i ++ ) freq2 [ s2 [ i ] - ' a ' ] ++ ; for ( i = 0 ; i < 26 ; i ++ ) count += ( Math . Min ( freq1 [ i ] , freq2 [ i ] ) ) ; return count ; } public static void Main ( ) { string s1 = " geeksforgeeks " , s2 = " platformforgeeks " ; int n1 = s1 . Length , n2 = s2 . Length ; Console . WriteLine ( countPairs ( s1 , n1 , s2 , n2 ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void findpair ( int l , int r ) { int c = 0 ; for ( int i = l ; i <= r ; i ++ ) { for ( int j = i + 1 ; j <= r ; j ++ ) { if ( j % i == 0 && j != i ) { Console . Write ( i + " , ▁ " + j ) ; c = 1 ; break ; } } if ( c == 1 ) break ; } } static void Main ( ) { int l = 1 , r = 10 ; findpair ( l , r ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static bool check ( int [ ] arr , int N , int K ) { HashSet < int > unique = new HashSet < int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { unique . Add ( arr [ i ] ) ; } if ( unique . Count == K ) { return true ; } return false ; } public static void Main ( string [ ] args ) { int [ ] arr = new int [ ] { 1 , 1 , 2 , 3 } ; int N = arr . Length ; int K = 3 ; if ( check ( arr , N , K ) ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void findSumPairs ( int [ ] a , int n ) { Dictionary < int , int > mpp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( mpp . ContainsKey ( a [ i ] + a [ j ] ) ) { var val = mpp [ a [ i ] + a [ j ] ] ; mpp . Remove ( a [ i ] + a [ j ] ) ; mpp . Add ( a [ i ] + a [ j ] , val + 1 ) ; } else { mpp . Add ( a [ i ] + a [ j ] , 1 ) ; } } } int occur = 0 ; foreach ( KeyValuePair < int , int > entry in mpp ) { if ( entry . Value > occur ) { occur = entry . Value ; } } foreach ( KeyValuePair < int , int > entry in mpp ) { if ( entry . Value == occur ) Console . WriteLine ( entry . Key ) ; } } public static void Main ( String [ ] args ) { int [ ] a = { 1 , 8 , 3 , 11 , 4 , 9 , 2 , 7 } ; int n = a . Length ; findSumPairs ( a , n ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: entry, i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int minIndex ( int [ ] arr , int n , int pos ) { int num = arr [ pos ] ; int i = pos - 1 ; while ( i >= 0 ) { if ( arr [ i ] != num ) break ; i -- ; } return i + 1 ; } public static void Main ( ) { int [ ] arr = { 2 , 1 , 1 , 1 , 5 , 2 } ; int n = arr . Length ; int pos = 4 ; Console . WriteLine ( minIndex ( arr , n , pos ) ) ; } }

Index/key variables: i, pos
Accumulator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minIndex ( int [ ] arr , int pos ) { int low = 0 ; int high = pos ; int i = pos ; while ( low < high ) { int mid = ( low + high ) / 2 ; if ( arr [ mid ] != arr [ pos ] ) { low = mid + 1 ; } else { high = mid - 1 ; i = mid ; if ( mid > 0 && arr [ mid - 1 ] != arr [ pos ] ) { break ; } } } return arr [ low ] == arr [ pos ] ? low : i ; } public static void Main ( ) { int [ ] arr = { 2 , 1 , 1 , 1 , 5 , 2 } ; } }

Index/key variables: low, mid, pos
Class/struct names: GFG
C# program:
using System ; class GFG { static int findAnswer ( string str1 , string str2 , int n ) { int l = 0 , r = 0 ; int ans = 2 ; for ( int i = 0 ; i < n ; ++ i ) { if ( str1 [ i ] != str2 [ i ] ) { l = i ; break ; } } for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( str1 [ i ] != str2 [ i ] ) { r = i ; break ; } } if ( r < l ) return 26 * ( n + 1 ) ; else if ( l == r ) return ans ; else { for ( int i = l + 1 ; i <= r ; i ++ ) { if ( str1 [ i ] != str2 [ i - 1 ] ) { ans -- ; break ; } } for ( int i = l + 1 ; i <= r ; i ++ ) { if ( str1 [ i - 1 ] != str2 [ i ] ) { ans -- ; break ; } } return ans ; } } public static void Main ( ) { String str1 = " toy " , str2 = " try " ; int n = str1 . Length ; Console . WriteLine ( findAnswer ( str1 , str2 , n ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int findMinDifference ( int [ ] arr , int n ) { Array . Sort ( arr ) ; int diff1 = arr [ n - 1 ] - arr [ 1 ] ; int diff2 = arr [ n - 2 ] - arr [ 0 ] ; return Math . Min ( diff1 , diff2 ) ; } static public void Main ( ) { int [ ] arr = { 1 , 2 , 4 , 3 , 4 } ; int n = arr . Length ; Console . Write ( findMinDifference ( arr , n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; public class GFG { static int findMinDifference ( int [ ] arr , int n ) { int min , secondMin , max , secondMax ; min = secondMax = ( arr [ 0 ] < arr [ 1 ] ) ? arr [ 0 ] : arr [ 1 ] ; max = secondMin = ( arr [ 0 ] < arr [ 1 ] ) ? arr [ 1 ] : arr [ 0 ] ; for ( int i = 2 ; i < n ; i ++ ) { if ( arr [ i ] > max ) { secondMax = max ; max = arr [ i ] ; } else if ( arr [ i ] > secondMax ) { secondMax = arr [ i ] ; } else if ( arr [ i ] < min ) { secondMin = min ; min = arr [ i ] ; } else if ( arr [ i ] < secondMin ) { secondMin = arr [ i ] ; } } int diff = Math . Min ( max - secondMin , secondMax - min ) ; return diff ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 4 , 3 , 4 } ; int n = arr . Length ; Console . WriteLine ( findMinDifference ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static Boolean checkDistinct ( int x ) { int last = x % 10 ; while ( x > 0 ) { if ( x % 10 != last ) return false ; x = x / 10 ; } return true ; } static int findCount ( int L , int R ) { int count = 0 ; for ( int i = L ; i <= R ; i ++ ) { if ( checkDistinct ( i ) ) count += 1 ; } return count ; } static public void Main ( String [ ] args ) { int L = 10 , R = 50 ; Console . WriteLine ( findCount ( L , R ) ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int smallest_pair ( int [ ] a , int n ) { int min = int . MaxValue , secondMin = int . MaxValue ; for ( int j = 0 ; j < n ; j ++ ) { if ( a [ j ] < min ) { secondMin = min ; min = a [ j ] ; } else if ( ( a [ j ] < secondMin ) && a [ j ] != min ) secondMin = a [ j ] ; } return ( secondMin + min ) ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 3 } ; int n = arr . Length ; Console . Write ( smallest_pair ( arr , n ) ) ; } }

Index/key variables: j
Accumulator variables: j
Iterator variables: j
Class/struct names: GFG
C# program:
using System ; class GFG { static int longestsubarray ( int [ ] arr , int n , int k ) { int current_count = 0 ; int max_count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % k == 0 ) current_count ++ ; else current_count = 0 ; max_count = Math . Max ( current_count , max_count ) ; } return max_count ; } public static void Main ( ) { int [ ] arr = { 2 , 5 , 11 , 32 , 64 , 88 } ; int n = arr . Length ; int k = 8 ; Console . Write ( longestsubarray ( arr , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: current_count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class geeks { public static void removeElements ( int [ ] arr , int n , int k ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; ++ i ) { if ( ! mp . ContainsKey ( arr [ i ] ) ) mp . Add ( arr [ i ] , 1 ) ; else { int x = mp [ arr [ i ] ] ; mp [ arr [ i ] ] = mp [ arr [ i ] ] + ++ x ; } } for ( int i = 0 ; i < n ; ++ i ) { if ( mp [ arr [ i ] ] >= k ) Console . Write ( arr [ i ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 2 , 3 , 2 , 3 , 4 } ; int n = arr . Length ; int k = 2 ; removeElements ( arr , n , k ) ; } }

Index/key variables: i
Iterator variables: i
Class/struct names: geeks
C# program:
using System ; public class GFG { static bool check ( String s ) { for ( int i = 0 ; i < s . Length - 1 ; i ++ ) if ( s [ i ] == s [ i + 1 ] ) return true ; return false ; } public static void Main ( ) { String s = " xzyyz " ; if ( check ( s ) ) Console . WriteLine ( " YES " ) ; else Console . WriteLine ( " NO " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void RemoveElements ( int [ ] arr , int n , int k ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; ++ i ) { if ( mp . ContainsKey ( arr [ i ] ) ) mp [ arr [ i ] ] ++ ; else mp [ arr [ i ] ] = 1 ; } for ( int i = 0 ; i < n ; ++ i ) { if ( mp . ContainsKey ( arr [ i ] ) && mp [ arr [ i ] ] <= k ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } } static public void Main ( ) { int [ ] arr = { 1 , 2 , 2 , 3 , 2 , 3 , 4 } ; int n = arr . Length ; int k = 2 ; RemoveElements ( arr , n , k ) ; } }

Index/key variables: i
Iterator variables: i
Class/struct names: GFG