dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int countOfSubStrings ( String s ) { int n = s . Length ; int [ ] prefix_sum = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == '1' ) prefix_sum [ i ] = 1 ; } for ( int i = 1 ; i < n ; i ++ ) prefix_sum [ i ] += prefix_sum [ i - 1 ] ; int answer = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { int countOfOnes = prefix_sum [ j ] - ( i - 1 >= 0 ? prefix_sum [ i - 1 ] : 0 ) ; int length = j - i + 1 ; if ( countOfOnes > 0 && length % countOfOnes == 0 ) answer ++ ; } } return answer ; } public static void Main ( String [ ] args ) { String S = "1111100000" ; Console . Write ( countOfSubStrings ( S ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: answer, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static int count_element ( int N , int K , int [ ] arr ) { 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 ) ; } int answer = 0 ; foreach ( KeyValuePair < int , int > i in mp ) { if ( mp . ContainsKey ( i . Key + K ) ) answer += i . Value ; } return answer ; } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , 6 , 2 , 8 , 7 , 6 , 5 , 9 } ; int N = arr . Length ; int K = 2 ; Console . Write ( count_element ( N , K , arr ) ) ; } }

Index/key variables: i
Accumulator variables: answer
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int digit_xor ( int x ) { int xorr = 0 ; while ( x > 0 ) { xorr ^= x % 10 ; x = x / 10 ; } return xorr ; } static int find_count ( int n ) { Dictionary < int , int > mpp = new Dictionary < int , int > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { if ( mpp . ContainsKey ( digit_xor ( i ) ) ) mpp [ digit_xor ( i ) ] = mpp [ digit_xor ( i ) ] + 1 ; else mpp . Add ( digit_xor ( i ) , 1 ) ; } int maxm = 0 ; foreach ( KeyValuePair < int , int > x in mpp ) { if ( x . Value > maxm ) maxm = x . Value ; } return maxm ; } public static void Main ( String [ ] args ) { int N = 13 ; Console . Write ( find_count ( N ) ) ; } }

Accumulator variables: i, xorr
Iterator variables: i, x
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; using System . Text ; class GFG { static int digit_prod ( int x ) { int prod = 1 ; while ( x != 0 ) { prod *= x % 10 ; x = x / 10 ; } return prod ; } static int find_count ( int n ) { Dictionary < int , int > mpp = new Dictionary < int , int > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { int t = digit_prod ( i ) ; if ( mpp . ContainsKey ( t ) ) { mpp [ t ] ++ ; } else { mpp [ i ] = 1 ; } } int ans = 1 ; int maxm = 0 ; foreach ( KeyValuePair < int , int > x in mpp ) { if ( x . Value > maxm ) { maxm = x . Value ; ans = 1 ; } else if ( x . Value == maxm ) { ans ++ ; } } return ans ; } public static void Main ( string [ ] args ) { int N = 13 ; Console . Write ( find_count ( N ) ) ; } }

Index/key variables: i, t
Accumulator variables: ans, i, prod
Iterator variables: i, x
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool isPrime ( int n ) { int i ; if ( n <= 1 ) return false ; if ( n <= 3 ) return true ; if ( n % 2 == 0 n % 3 == 0 ) { return false ; } for ( i = 5 ; i * i <= n ; i += 6 ) { if ( n % i == 0 || n % ( i + 2 ) == 0 ) { return false ; } } return true ; } static int findSubarraySum ( int [ ] arr , int n , int K ) { Dictionary < int , int > prevSum = new Dictionary < int , int > ( ) ; int res = 0 ; int currsum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { currsum += arr [ i ] ; if ( currsum == K ) { res ++ ; } if ( prevSum . ContainsKey ( currsum - K ) ) { res += ( prevSum [ currsum - K ] ) ; } if ( prevSum . ContainsKey ( currsum ) ) { prevSum [ currsum ] = prevSum [ currsum ] + 1 ; } else { prevSum . Add ( currsum , 1 ) ; } } return res ; } static void countSubarray ( int [ ] arr , int n , int K ) { for ( int i = 0 ; i < n ; i ++ ) { if ( isPrime ( arr [ i ] ) ) { arr [ i ] = 1 ; } else { arr [ i ] = 0 ; } } Console . Write ( findSubarraySum ( arr , n , K ) ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 } ; int K = 2 ; int N = arr . Length ; countSubarray ( arr , N , K ) ; } }

Index/key variables: currsum, i
Accumulator variables: currsum, i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int find_maxm ( 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 ) ; } } int ans = 0 ; foreach ( KeyValuePair < int , int > x in mp ) { int value = x . Key ; int freq = x . Value ; if ( value == freq ) { ans ++ ; } } return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , 2 , 2 , 3 , 4 , 3 } ; int n = arr . Length ; Console . Write ( find_maxm ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i, x
Class/struct names: GFG
C# program:
using System ; class GFG { static int pow ( int x , int y ) { if ( y == 1 ) return x ; if ( y == 0 ) return 1 ; int temp = pow ( x , y / 2 ) ; temp *= temp ; if ( y % 2 == 1 ) temp *= x ; return temp ; } static int noOfPermutations ( int [ ] a , int n ) { if ( n == 1 ) { return 1 ; } Array . Sort ( a ) ; if ( a [ n - 1 ] == a [ n - 2 ] ) { return 0 ; } int x = 0 ; for ( int i = 0 ; i < n - 2 ; ++ i ) { if ( a [ i ] == a [ i + 1 ] ) { if ( a [ i ] == a [ i + 2 ] ) { return 0 ; } x ++ ; i ++ ; } } return pow ( 2 , n - 2 * x - 1 ) ; } public static void Main ( String [ ] args ) { int [ ] a = { 1 , 2 , 2 , 3 , 4 } ; int n = a . Length ; int num = noOfPermutations ( a , n ) ; Console . Write ( num ) ; } }

Index/key variables: i
Accumulator variables: i, temp, x
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int GetMinSubarrayLength ( int [ ] a , int n ) { int ans = Math . Max ( a [ 0 ] , a [ n - 1 ] ) ; int lo = 0 , hi = n - 1 ; while ( lo < n && a [ lo ] % ans == 0 ) lo ++ ; while ( hi > lo && a [ hi ] % ans == 0 ) hi -- ; return ( hi - lo + 1 ) ; } public static void Main ( string [ ] args ) { int [ ] arr = { 4 , 8 , 2 , 1 , 4 } ; int N = arr . Length ; int Length = GetMinSubarrayLength ( arr , N ) ; Console . WriteLine ( Length ) ; } }

Index/key variables: hi, lo
Accumulator variables: hi, lo
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void countPairs ( 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 ) ; } } int maxFreq = 0 ; foreach ( KeyValuePair < int , int > it in mp ) { maxFreq = Math . Max ( maxFreq , it . Value ) ; } Console . Write ( N - maxFreq + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 8 , 5 , 9 , 8 , 8 , 7 , 7 , 5 , 7 , 7 } ; int N = arr . Length ; countPairs ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i, it
Class/struct names: GFG
C# program:
using System ; class GFG { static int minimumValue ( int [ ] arr , int n , int k ) { Array . Sort ( arr ) ; int answer = 0 ; for ( int i = 0 ; i < k ; i ++ ) answer += arr [ i ] * arr [ i ] ; return answer * ( 2 * k - 2 ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 4 , 21 , 5 , 3 , 8 } ; int k = 3 ; int n = arr . Length ; Console . Write ( minimumValue ( arr , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: answer, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int min_val = int . MaxValue ; static int min_steps = 0 ; static int sumOfDigits ( int n ) { string s = n . ToString ( ) ; int sum = 0 ; for ( int i = 0 ; i < s . Length ; i ++ ) { sum += ( s [ i ] - '0' ) ; } return sum ; } static void Transform ( int n , int d , int steps ) { if ( n < min_val ) { min_val = n ; min_steps = steps ; } else if ( n == min_val ) { min_steps = Math . Min ( min_steps , steps ) ; } if ( steps < 15 ) { Transform ( sumOfDigits ( n ) , d , steps + 1 ) ; Transform ( n + d , d , steps + 1 ) ; } } public static void Main ( string [ ] args ) { int N = 9 , D = 3 ; Transform ( N , D , 0 ) ; Console . Write ( min_val + " ▁ " + min_steps ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static void noOfMoves ( int [ ] arr , int n ) { int cnt = 0 ; int maxCnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == 1 ) { cnt ++ ; } else { if ( cnt != 0 ) { maxCnt = Math . Max ( maxCnt , cnt ) ; cnt = 0 ; } } } Console . Write ( maxCnt + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 0 , 1 , 1 , 1 , 1 , 0 , 0 , 1 , 1 , 0 , 0 , 1 } ; int N = arr . Length ; noOfMoves ( arr , N ) ; int [ ] arr1 = { 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 } ; N = arr1 . Length ; noOfMoves ( arr1 , N ) ; } }

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void knowPair ( int a , int b , int n , int s , int m ) { int i = 0 , rem = 0 ; int count_b = 0 , flag = 0 ; while ( i <= a ) { rem = s - ( n * i ) ; count_b = rem / m ; if ( rem % m == 0 && count_b <= b ) { flag = 1 ; } i ++ ; } if ( flag == 1 ) { Console . Write ( " YES " + " STRNEWLINE " ) ; } else { Console . Write ( " NO " + " STRNEWLINE " ) ; } } public static void Main ( String [ ] args ) { int A = 1 ; int B = 2 ; int n = 3 ; int S = 4 ; int m = 2 ; knowPair ( A , B , n , S , m ) ; } }

Accumulator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int sumDivisibles ( int A , int B , int M ) { int sum = 0 ; for ( int i = A ; i <= B ; i ++ ) if ( i % M == 0 ) sum += i ; return sum ; } public static void Main ( String [ ] args ) { int A = 6 , B = 15 , M = 3 ; Console . Write ( sumDivisibles ( A , B , M ) + " STRNEWLINE " ) ; } }

Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int findSmallNum ( int N , int K ) { int rem = N % K ; if ( rem == 0 ) return N ; else return N - rem ; } static int findLargeNum ( int N , int K ) { int rem = ( N + K ) % K ; if ( rem == 0 ) return N ; else return N + K - rem ; } static int sumDivisibles ( int A , int B , int M ) { int first = findSmallNum ( A , M ) ; int last = findLargeNum ( B , M ) ; if ( first < A ) first += M ; if ( last > B ) first -= M ; int n = ( B / M ) - ( A - 1 ) / M ; return n * ( first + last ) / 2 ; } public static void Main ( String [ ] args ) { int A = 6 , B = 15 , M = 3 ; Console . Write ( sumDivisibles ( A , B , M ) ) ; } }

Accumulator variables: first
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int distinctSubString ( String P , int N ) { HashSet < String > S = new HashSet < String > ( ) ; for ( int i = 0 ; i < N ; ++ i ) { bool [ ] freq = new bool [ 26 ] ; String s = " " ; for ( int j = i ; j < N ; ++ j ) { int pos = P [ j ] - ' a ' ; if ( freq [ pos ] == true ) break ; freq [ pos ] = true ; s += P [ j ] ; S . Add ( s ) ; } } return S . Count ; } public static void Main ( String [ ] args ) { String S = " abba " ; int N = S . Length ; Console . Write ( distinctSubString ( S , N ) ) ; } }

Index/key variables: j, pos
Accumulator variables: s
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void calcSum ( int [ ] arr , int n , int k ) { for ( int i = 0 ; i <= n - k ; i ++ ) { int sum = 0 ; for ( int j = i ; j < k + i ; j ++ ) sum += arr [ j ] ; Console . Write ( sum + " ▁ " ) ; } } static void Main ( ) { int [ ] arr = new int [ ] { 1 , 2 , 3 , 4 , 5 , 6 } ; int n = arr . Length ; int k = 3 ; calcSum ( arr , n , k ) ; } }

Index/key variables: j
Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void calcSum ( int [ ] arr , int n , int k ) { int sum = 0 ; for ( int i = 0 ; i < k ; i ++ ) sum += arr [ i ] ; Console . Write ( sum + " ▁ " ) ; for ( int i = k ; i < n ; i ++ ) { sum = ( sum - arr [ i - k ] ) + arr [ i ] ; Console . Write ( sum + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 6 } ; int n = arr . Length ; int k = 3 ; calcSum ( arr , n , k ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static long getPairs ( List < int > A , List < int > B , int n ) { int [ ] D = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { D [ i ] = A [ i ] - B [ i ] ; } Array . Sort ( D ) ; long total = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( D [ i ] > 0 ) { total += n - i - 1 ; } else { int k = upper_bound ( D , 0 , D . Length , - D [ i ] ) ; total += n - k ; } } return total ; } static int upper_bound ( int [ ] a , int low , int high , int element ) { while ( low < high ) { int middle = low + ( high - low ) / 2 ; if ( a [ middle ] > element ) high = middle ; else low = middle + 1 ; } return low ; } public static void Main ( String [ ] args ) { int n = 5 ; List < int > A = new List < int > ( ) ; List < int > B = new List < int > ( ) ; A . Add ( 4 ) ; A . Add ( 8 ) ; A . Add ( 2 ) ; A . Add ( 6 ) ; A . Add ( 2 ) ; B . Add ( 4 ) ; B . Add ( 5 ) ; B . Add ( 4 ) ; B . Add ( 1 ) ; B . Add ( 3 ) ; Console . Write ( getPairs ( A , B , n ) ) ; } }

Index/key variables: i, middle, n
Accumulator variables: i, total
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } static int lcm ( int a , int b ) { return ( a * b ) / gcd ( a , b ) ; } static int countPairs ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) if ( lcm ( arr [ i ] , arr [ j ] ) == gcd ( arr [ i ] , arr [ j ] ) ) ans ++ ; return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 1 , 1 } ; int n = arr . Length ; Console . Write ( countPairs ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int countPairs ( int [ ] a , int n ) { Dictionary < int , int > frequency = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( frequency . ContainsKey ( a [ i ] ) ) { var val = frequency [ a [ i ] ] ; frequency . Remove ( a [ i ] ) ; frequency . Add ( a [ i ] , val + 1 ) ; } else { frequency . Add ( a [ i ] , 1 ) ; } } int count = 0 ; foreach ( KeyValuePair < int , int > entry in frequency ) { int f = entry . Value ; count += f * ( f - 1 ) / 2 ; } return count ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 1 , 1 } ; int n = arr . Length ; Console . Write ( countPairs ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: entry, i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxValue ( int [ ] arr , int n , int moves ) { for ( int i = n - 2 ; i >= 0 ; i -- ) { if ( arr [ i ] > 0 ) { int distance = n - 1 - i ; if ( moves < distance ) break ; int can_take = moves / distance ; int take = Math . Min ( arr [ i ] , can_take ) ; arr [ n - 1 ] += take ; moves -= take * distance ; } } return arr [ n - 1 ] ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 3 , 0 , 1 } ; int M = 5 ; int N = arr . Length ; Console . Write ( maxValue ( arr , N , M ) ) ; } }

Index/key variables: i
Accumulator variables: i, moves
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int [ ] fact = new int [ 14 ] ; static int size = 1 ; static void preCompute ( int N ) { fact [ 0 ] = 1 ; for ( int i = 1 ; fact [ i - 1 ] <= N ; i ++ ) { fact [ i ] = ( fact [ i - 1 ] * i ) ; size ++ ; } } static void findMin ( int N ) { preCompute ( N ) ; int originalN = N ; List < int > ans = new List < int > ( ) ; for ( int i = size - 1 ; i >= 0 ; i -- ) { while ( N >= fact [ i ] ) { N -= fact [ i ] ; ans . Add ( fact [ i ] ) ; } } Console . Write ( ans . Count + " STRNEWLINE " ) ; for ( int i = 0 ; i < ans . Count ; i ++ ) Console . Write ( ans [ i ] + " ▁ " ) ; } public static void Main ( String [ ] args ) { int n = 27 ; findMin ( n ) ; } }

Index/key variables: i
Accumulator variables: N, i, size
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static readonly int N = 3 ; static readonly int M = 3 ; static int maxProductPath ( int [ , ] arr ) { int [ , ] maxPath = new int [ N , M ] ; int [ , ] minPath = new int [ N , M ] ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { int minVal = int . MaxValue ; int maxVal = int . MinValue ; if ( i == 0 && j == 0 ) { maxVal = arr [ i , j ] ; minVal = arr [ i , j ] ; } if ( i > 0 ) { int tempMax = Math . Max ( maxPath [ i - 1 , j ] * arr [ i , j ] , minPath [ i - 1 , j ] * arr [ i , j ] ) ; maxVal = Math . Max ( maxVal , tempMax ) ; int tempMin = Math . Min ( maxPath [ i - 1 , j ] * arr [ i , j ] , minPath [ i - 1 , j ] * arr [ i , j ] ) ; minVal = Math . Min ( minVal , tempMin ) ; } if ( j > 0 ) { int tempMax = Math . Max ( maxPath [ i , j - 1 ] * arr [ i , j ] , minPath [ i , j - 1 ] * arr [ i , j ] ) ; maxVal = Math . Max ( maxVal , tempMax ) ; int tempMin = Math . Min ( maxPath [ i , j - 1 ] * arr [ i , j ] , minPath [ i , j - 1 ] * arr [ i , j ] ) ; minVal = Math . Min ( minVal , tempMin ) ; } maxPath [ i , j ] = maxVal ; minPath [ i , j ] = minVal ; } } return maxPath [ N - 1 , M - 1 ] ; } public static void Main ( String [ ] args ) { int [ , ] arr = { { 1 , - 2 , 3 } , { 4 , - 5 , 6 } , { - 7 , - 8 , 9 } } ; Console . Write ( maxProductPath ( arr ) + " STRNEWLINE " ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void vertical_Fill ( int [ ] records , int [ ] tape , int m , int n ) { int [ , ] v = new int [ m , n ] ; int sum = 0 ; int Retrieval_Time = 0 ; double Mrt ; int z = 0 , j = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( j = 0 ; j < m ; j ++ ) { sum = 0 ; for ( int k = 0 ; k < i ; k ++ ) { sum += v [ j , k ] ; } if ( sum + records [ z ] <= tape [ j ] ) { v [ j , i ] = records [ z ] ; z ++ ; } } if ( v [ 2 , i ] == 0 ) { break ; } } for ( int i = 0 ; i < m ; i ++ ) { Retrieval_Time = 0 ; Console . Write ( " tape ▁ " + ( i + 1 ) + " ▁ : ▁ [ ▁ " ) ; for ( j = 0 ; j < n ; j ++ ) { if ( v [ i , j ] != 0 ) { Console . Write ( v [ i , j ] + " ▁ " ) ; } else { break ; } } Console . Write ( " ] " ) ; for ( int k = 0 ; v [ i , k ] != 0 ; k ++ ) { Retrieval_Time += v [ i , k ] * ( j - k ) ; } Mrt = ( double ) Retrieval_Time / j ; Console . Write ( " TABSYMBOL MRT ▁ : ▁ " + Mrt + " STRNEWLINE " ) ; } } public static void Main ( String [ ] args ) { int [ ] records = { 15 , 2 , 8 , 23 , 45 , 50 , 60 , 120 } ; int [ ] tape = { 25 , 80 , 160 } ; int n = records . Length ; int m = tape . Length ; Array . Sort ( records ) ; vertical_Fill ( records , tape , m , n ) ; } }

Index/key variables: j, z
Accumulator variables: Retrieval_Time, i, j, k, sum, z
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 26 ; static int maxLength ( string str , int len ) { int res = 0 ; int [ ] lastPos = new int [ MAX ] ; for ( int i = 0 ; i < MAX ; i ++ ) { lastPos [ i ] = - 1 ; } for ( int i = 0 ; i < len ; i ++ ) { int C = str [ i ] - ' a ' ; if ( lastPos [ C ] != - 1 ) { res = Math . Max ( len - ( i - lastPos [ C ] - 1 ) - 1 , res ) ; } lastPos [ C ] = i ; } return res ; } public static void Main ( ) { string str = " geeksforgeeks " ; int len = str . Length ; Console . WriteLine ( maxLength ( str , len ) ) ; } }

Index/key variables: C, MAX, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int INT_MAX = int . MaxValue ; static int min_element ( int [ ] A , int N ) { int min = A [ 0 ] ; int i ; for ( i = 1 ; i < N ; i ++ ) { if ( min > A [ i ] ) { min = A [ i ] ; } } return min ; } static int countPartitions ( int [ ] A , int N ) { int count = 0 ; int i , j ; for ( i = 0 ; i < N ; i ++ ) { int min_elem = min_element ( A , N ) ; if ( min_elem == INT_MAX ) break ; count ++ ; for ( j = 0 ; j < N ; j ++ ) { if ( A [ j ] % min_elem == 0 ) A [ j ] = INT_MAX ; } } return count ; } public static void Main ( ) { int [ ] arr = { 7 , 6 , 5 , 4 , 3 , 2 , 2 , 3 } ; int N = arr . Length ; Console . WriteLine ( countPartitions ( arr , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int minSwaps ( string s1 , string s2 ) { int c0 = 0 , c1 = 0 ; for ( int i = 0 ; i < s1 . Length ; i ++ ) { if ( s1 [ i ] == '0' && s2 [ i ] == '1' ) { c0 ++ ; } else if ( s1 [ i ] == '1' && s2 [ i ] == '0' ) { c1 ++ ; } } int ans = c0 / 2 + c1 / 2 ; if ( c0 % 2 == 0 && c1 % 2 == 0 ) { return ans ; } else if ( ( c0 + c1 ) % 2 == 0 ) { return ans + 2 ; } else { return - 1 ; } } public static void Main ( ) { string s1 = "0011" , s2 = "1111" ; int ans = minSwaps ( s1 , s2 ) ; Console . WriteLine ( ans ) ; } }

Index/key variables: i
Accumulator variables: c0, c1, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int minChanges ( int [ ] arr , int n ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( mp . ContainsKey ( arr [ i ] ) ) { var val = mp [ arr [ i ] ] ; mp . Remove ( arr [ i ] ) ; mp . Add ( arr [ i ] , val + 1 ) ; } else { mp . Add ( arr [ i ] , 1 ) ; } } int maxElem = 0 ; foreach ( KeyValuePair < int , int > entry in mp ) { maxElem = Math . Max ( maxElem , entry . Value ) ; } return n - maxElem ; } public static void Main ( string [ ] args ) { int [ ] arr = { 2 , 3 , 3 , 4 } ; int n = arr . Length ; Console . WriteLine ( minChanges ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: entry, i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minOperations ( int n , int m ) { int a = 0 , k = 1 ; int p = Math . Max ( n , m ) ; while ( n != m ) { float s = ( float ) ( p - n + p - m ) ; float q = ( float ) ( ( - 1 + Math . Sqrt ( 8 * s + 1 ) ) / 2 ) ; if ( q - Math . Floor ( q ) == 0 ) { a = ( int ) q ; n = m ; } p = p + 1 ; } return a ; } public static void Main ( ) { int n = 1 , m = 3 ; Console . Write ( minOperations ( n , m ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int k_sum ( int [ ] a , int n , int k ) { int r = 0 , sum = 0 ; int ans = 0 ; for ( int l = 0 ; l < n ; l ++ ) { while ( sum < k ) { if ( r == n ) break ; else { sum += a [ r ] ; r ++ ; } } if ( sum < k ) break ; ans += n - r + 1 ; sum -= a [ l ] ; } return ans ; } public static void Main ( ) { int [ ] a = { 6 , 1 , 2 , 7 } ; int k = 10 ; int n = a . Length ; Console . WriteLine ( k_sum ( a , n , k ) ) ; } }

Index/key variables: l, r
Accumulator variables: ans, l, r, sum
Iterator variables: l
Class/struct names: GFG