dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static bool isOddStringPalindrome ( String str , int n ) { int left , right ; if ( n % 2 == 0 ) { left = 1 ; right = n - 1 ; } else { left = 1 ; right = n - 2 ; } while ( left < n && right >= 0 && left < right ) { if ( str [ left ] != str [ right ] ) return false ; left += 2 ; right -= 2 ; } return true ; } public static void Main ( String [ ] args ) { int n = 10 ; String s = " aeafacafae " ; if ( isOddStringPalindrome ( s , n ) ) Console . Write ( " Yes STRNEWLINE " ) ; else Console . Write ( " No STRNEWLINE " ) ; } }

Index/key variables: left, right
Accumulator variables: left, right
Class/struct names: GFG
C# program:
using System ; class GFG { static void min_remove ( string str ) { int N = str . Length ; int [ ] prefix_a = new int [ N + 1 ] ; int [ ] prefix_b = new int [ N + 1 ] ; int [ ] prefix_c = new int [ N + 1 ] ; prefix_a [ 0 ] = 0 ; prefix_b [ 0 ] = 0 ; prefix_c [ 0 ] = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { prefix_a [ i ] = prefix_a [ i - 1 ] + ( int ) ( ( str [ i - 1 ] == ' a ' ) ? 1 : 0 ) ; prefix_b [ i ] = prefix_b [ i - 1 ] + ( int ) ( ( str [ i - 1 ] == ' b ' ) ? 1 : 0 ) ; prefix_c [ i ] = prefix_c [ i - 1 ] + ( int ) ( ( str [ i - 1 ] == ' c ' ) ? 1 : 0 ) ; } int maxi = Int32 . MinValue ; for ( int i = 0 ; i <= N ; i ++ ) { for ( int j = i ; j <= N ; j ++ ) { maxi = Math . Max ( maxi , ( prefix_a [ i ] + ( prefix_b [ j ] - prefix_b [ i ] ) + ( prefix_c [ N ] - prefix_c [ j ] ) ) ) ; } } Console . WriteLine ( ( N - maxi ) ) ; } public static void Main ( ) { string str = " aaaabaaxccac " ; min_remove ( str ) ; } }

Index/key variables: N, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void createArray ( int n , int s ) { if ( 2 * n <= s ) { for ( int i = 0 ; i < n - 1 ; i ++ ) { Console . Write ( 2 + " ▁ " ) ; s -= 2 ; } Console . WriteLine ( s ) ; Console . WriteLine ( 1 ) ; } else Console . Write ( " - 1" ) ; } public static void Main ( ) { int N = 1 ; int S = 4 ; createArray ( N , S ) ; } }

Accumulator variables: i, s
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int maximum_partition ( String str ) { int i = 0 , j = 0 , k = 0 ; int c = 0 , r = 0 ; Dictionary < char , int > m = new Dictionary < char , int > ( ) ; for ( i = str . Length - 1 ; i >= 0 ; i -- ) { if ( ! m . ContainsKey ( str [ i ] ) ) { m . Add ( str [ i ] , i ) ; } } i = 0 ; k = m [ str [ i ] ] ; for ( i = 0 ; i < str . Length ; i ++ ) { if ( i <= k ) { c = c + 1 ; k = Math . Max ( k , m [ str [ i ] ] ) ; } else { r = r + 1 ; c = 1 ; k = Math . Max ( k , m [ str [ i ] ] ) ; } } if ( c != 0 ) { r = r + 1 ; } return r ; } public static void Main ( String [ ] args ) { String str = " ababcbacadefegdehijhklij " ; Console . Write ( maximum_partition ( str ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findAns ( int [ , ] mat , int x , int y , int n , int m ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( mat [ i , j ] == 1 ) { ans += Math . Abs ( x - i ) + Math . Abs ( y - j ) ; } } } return ans ; } public static void Main ( String [ ] args ) { int [ , ] mat = { { 1 , 0 , 0 , 0 } , { 0 , 1 , 0 , 1 } , { 1 , 0 , 1 , 1 } } ; int x = 0 , y = 2 ; Console . Write ( findAns ( mat , x , y , mat . GetLength ( 0 ) , mat . GetLength ( 1 ) ) + " STRNEWLINE " ) ; } }

Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void countReversebitonic ( int [ ] arr , int n ) { int c = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { int temp = arr [ i ] , f = 0 ; if ( j == i ) { c ++ ; continue ; } int k = i + 1 ; while ( temp > arr [ k ] && k <= j ) { temp = arr [ k ] ; k ++ ; } if ( k > j ) { c ++ ; f = 2 ; } while ( k <= j && temp < arr [ k ] && f != 2 ) { temp = arr [ k ] ; k ++ ; } if ( k > j && f != 2 ) { c ++ ; f = 0 ; } } } Console . Write ( c ) ; } public static void Main ( string [ ] args ) { int [ ] arr = { 2 , 3 , 1 , 4 } ; int N = arr . Length ; countReversebitonic ( arr , N ) ; } }

Index/key variables: i, k
Accumulator variables: c, i, j, k
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int longestSequence ( int n , int [ ] arr ) { int l = 0 , r = n - 1 ; int prev = int . MinValue ; int ans = 0 ; while ( l <= r ) { if ( arr [ l ] > prev && arr [ r ] > prev ) { if ( arr [ l ] < arr [ r ] ) { ans += 1 ; prev = arr [ l ] ; l += 1 ; } else { ans += 1 ; prev = arr [ r ] ; r -= 1 ; } } else if ( arr [ l ] > prev ) { ans += 1 ; prev = arr [ l ] ; l += 1 ; } else if ( arr [ r ] > prev ) { ans += 1 ; prev = arr [ r ] ; r -= 1 ; } else { break ; } } return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , 5 , 1 , 4 , 2 } ; int n = arr . Length ; Console . Write ( longestSequence ( n , arr ) ) ; } }

Index/key variables: l, r
Accumulator variables: ans, l, r
Class/struct names: GFG
C# program:
using System ; class GFG { static int solve ( int n , int m , int x , int y , int d ) { int top = Math . Min ( d , x - 1 ) ; int down = Math . Min ( d , n - x ) ; int left = Math . Min ( d , y - 1 ) ; int right = Math . Min ( d , m - y ) ; int quad1 = top * left ; int quad2 = left * down ; int quad3 = down * right ; int quad4 = right * top ; int totalsq = quad1 + quad2 + quad3 + quad4 ; int singleBlocks = top + down + left + right + 1 ; return totalsq + singleBlocks ; } public static void Main ( String [ ] args ) { int n = 10 , m = 10 ; int x = 7 , y = 8 ; int d = 4 ; d -- ; Console . WriteLine ( solve ( n , m , x , y , d ) ) ; } }

Accumulator variables: d
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void getSubsequence ( int [ ] arr , int n ) { List < int > req = new List < int > ( ) ; req . Add ( arr [ 0 ] ) ; for ( int i = 1 ; i < n - 1 ; i ++ ) { if ( arr [ i ] > arr [ i + 1 ] && arr [ i ] > arr [ i - 1 ] ) req . Add ( arr [ i ] ) ; else if ( arr [ i ] < arr [ i + 1 ] && arr [ i ] < arr [ i - 1 ] ) req . Add ( arr [ i ] ) ; } req . Add ( arr [ n - 1 ] ) ; Console . Write ( req . Count + " STRNEWLINE " ) ; foreach ( int x in req ) Console . Write ( x + " ▁ " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 5 , 3 , 6 , 7 , 4 } ; int n = arr . Length ; getSubsequence ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i, x
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { static int M = 3 ; static int N = 3 ; static int minchanges ( int [ , ] mat ) { int count = 0 ; int left = 0 , right = N + M - 2 ; while ( left < right ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; int totalsize = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { if ( i + j == left ) { if ( mp . ContainsKey ( mat [ i , j ] ) ) { mp [ mat [ i , j ] ] ++ ; } else { mp [ mat [ i , j ] ] = 1 ; } totalsize ++ ; } else if ( i + j == right ) { if ( mp . ContainsKey ( mat [ i , j ] ) ) { mp [ mat [ i , j ] ] ++ ; } else { mp [ mat [ i , j ] ] = 1 ; } totalsize ++ ; } } } int changes = 0 ; foreach ( KeyValuePair < int , int > itr in mp ) { changes = Math . Max ( changes , itr . Value ) ; } count += totalsize - changes ; left ++ ; right -- ; } return count ; } public static void Main ( string [ ] args ) { int [ , ] mat = { { 1 , 4 , 1 } , { 2 , 5 , 3 } , { 1 , 3 , 1 } } ; Console . Write ( minchanges ( mat ) ) ; } }

Accumulator variables: count, i, j, left, right, totalsize
Iterator variables: i, itr, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int CountLongestSubarrays ( int [ ] arr , int n , int k ) { int i , s = 0 ; for ( i = 0 ; i < n ; ++ i ) { s += arr [ i ] ; } if ( ( s % k ) != 0 ) { return 1 ; } else { int ini = 0 ; while ( ini < n && arr [ ini ] % k == 0 ) { ++ ini ; } int fin = n - 1 ; while ( fin >= 0 && arr [ fin ] % k == 0 ) { -- fin ; } int len , sum = 0 , count = 0 ; if ( ini == n ) { return - 1 ; } else { len = Math . Max ( n - 1 - ini , fin ) ; } for ( i = 0 ; i < len ; i ++ ) { sum += arr [ i ] ; } if ( sum % k != 0 ) { count ++ ; } for ( i = len ; i < n ; i ++ ) { sum = sum + arr [ i ] ; sum = sum - arr [ i - len ] ; if ( sum % k != 0 ) { count ++ ; } } return count ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , 2 , 2 , 2 , 3 } ; int n = arr . Length ; int k = 3 ; Console . WriteLine ( CountLongestSubarrays ( arr , n , k ) ) ; } }

Index/key variables: fin, i, ini
Accumulator variables: count, i, s, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAXN = 1000001 ; static int [ ] freq = new int [ MAXN ] ; static int [ ] mul = new int [ MAXN ] ; static int [ ] cnt = new int [ MAXN ] ; static int nC3 ( int n ) { if ( n < 3 ) return 0 ; return ( n * ( n - 1 ) * ( n - 2 ) ) / 6 ; } static void count_triplet ( int [ ] arr , int N , int K ) { int i , j ; for ( i = 0 ; i < N ; i ++ ) { freq [ arr [ i ] ] ++ ; } for ( i = 1 ; i <= 1000000 ; i ++ ) { for ( j = i ; j <= 1000000 ; j += i ) { mul [ i ] += freq [ j ] ; } cnt [ i ] = nC3 ( mul [ i ] ) ; } for ( i = 1000000 ; i >= 1 ; i -- ) { for ( j = 2 * i ; j <= 1000000 ; j += i ) { cnt [ i ] -= cnt [ j ] ; } } Console . Write ( " Number ▁ of ▁ triplets ▁ " + " with ▁ GCD ▁ " + K ) ; Console . Write ( " ▁ are ▁ " + cnt [ K ] ) ; } public static void Main ( string [ ] args ) { int [ ] arr = { 1 , 7 , 12 , 6 , 15 , 9 } ; int N = 6 , K = 3 ; count_triplet ( arr , N , K ) ; } }

Index/key variables: K, MAXN, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isSubseqPossible ( int [ ] arr , int N , int K ) { int i ; int odd = 0 , even = 0 ; for ( i = 0 ; i < N ; i ++ ) { if ( arr [ i ] % 2 == 1 ) odd ++ ; else even ++ ; } if ( odd == 0 || ( even == 0 && K % 2 == 0 ) ) return false ; return true ; } public static void Main ( ) { int [ ] arr = { 2 , 3 , 5 , 7 , 4 } ; int N = arr . Length ; int K = 3 ; Console . Write ( isSubseqPossible ( arr , N , K ) ? " Yes " : " No " ) ; } }

Index/key variables: i
Accumulator variables: even, i, odd
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void print_path ( int N , int jump , int coin ) { if ( jump > coin || jump * ( N - 1 ) < coin ) { Console . WriteLine ( " - 1" ) ; } else { int pos = 1 ; while ( jump > 0 ) { int tmp = Math . Min ( N - 1 , coin - ( jump - 1 ) ) ; if ( pos + tmp <= N ) { pos += tmp ; } else { pos -= tmp ; } Console . Write ( pos + " ▁ " ) ; coin -= tmp ; jump -= 1 ; } } } public static void Main ( String [ ] args ) { int N = 5 , K = 4 , M = 12 ; print_path ( N , K , M ) ; } }

Accumulator variables: coin, jump, pos
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static readonly int INF = 10000009 ; static void findMinHike ( List < int > arr , int n ) { arr . Insert ( 0 , INF ) ; arr . Add ( INF ) ; int [ ] hike = new int [ n + 2 ] ; for ( int i = 1 ; i <= n ; i ++ ) { if ( arr [ i - 1 ] >= arr [ i ] && arr [ i ] <= arr [ i + 1 ] ) { hike [ i ] = 1 ; } } for ( int i = 1 ; i <= n ; i ++ ) { if ( arr [ i - 1 ] < arr [ i ] && arr [ i ] <= arr [ i + 1 ] ) { hike [ i ] = hike [ i - 1 ] + 1 ; } } for ( int i = 1 ; i <= n ; i ++ ) { if ( arr [ i - 1 ] >= arr [ i ] && arr [ i ] > arr [ i + 1 ] ) { hike [ i ] = hike [ i + 1 ] + 1 ; } } for ( int i = 1 ; i <= n ; i ++ ) { if ( arr [ i - 1 ] < arr [ i ] && arr [ i ] > arr [ i + 1 ] ) { hike [ i ] = Math . Max ( hike [ i - 1 ] , hike [ i + 1 ] ) + 1 ; } } for ( int i = 1 ; i <= n ; i ++ ) { Console . Write ( hike [ i ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { List < int > arr = new List < int > ( ) ; arr . Add ( 5 ) ; arr . Add ( 3 ) ; arr . Add ( 4 ) ; arr . Add ( 2 ) ; arr . Add ( 1 ) ; arr . Add ( 6 ) ; findMinHike ( arr , arr . Count ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void minimumCost ( int [ ] arr , int [ ] cost , int N ) { int [ , ] dp = new int [ N , 3 ] ; dp [ 0 , 0 ] = 0 ; dp [ 0 , 1 ] = cost [ 0 ] ; dp [ 0 , 2 ] = cost [ 0 ] * 2 ; for ( int i = 1 ; i < N ; i ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { int minimum = ( int ) 1e6 ; if ( j + arr [ i ] != arr [ i - 1 ] ) minimum = Math . Min ( minimum , dp [ i - 1 , 0 ] ) ; if ( j + arr [ i ] != arr [ i - 1 ] + 1 ) minimum = Math . Min ( minimum , dp [ i - 1 , 1 ] ) ; if ( j + arr [ i ] != arr [ i - 1 ] + 2 ) minimum = Math . Min ( minimum , dp [ i - 1 , 2 ] ) ; dp [ i , j ] = j * cost [ i ] + minimum ; } } int ans = ( int ) 1e6 ; for ( int i = 0 ; i < 3 ; i ++ ) ans = Math . Min ( ans , dp [ N - 1 , i ] ) ; Console . Write ( ans + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 1 , 2 , 2 , 3 , 4 } ; int [ ] cost = { 3 , 2 , 5 , 4 , 2 , 1 } ; int N = arr . Length ; minimumCost ( arr , cost , N ) ; } }

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 void maximumSumSubarray ( int [ ] arr , int n ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] >= 0 ) mp . Add ( arr [ i ] , 1 ) ; } int first = 0 ; int last = 0 ; int ans = 0 ; int INF = ( int ) 1e6 ; foreach ( KeyValuePair < int , int > i in mp ) { int mx = i . Key ; int curr = 0 ; int curr_start = - 1 ; for ( int j = 0 ; j < n ; j ++ ) { if ( curr == 0 ) curr_start = j ; int val = arr [ j ] > mx ? - INF : arr [ j ] ; curr += val ; if ( curr < 0 ) curr = 0 ; if ( curr > ans ) { ans = curr ; first = curr_start ; last = j ; } } } Console . Write ( ( first + 1 ) + " ▁ " + ( last + 1 ) ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 5 , - 2 , 10 , - 1 , 4 } ; int size = arr . Length ; maximumSumSubarray ( arr , size ) ; } }

Index/key variables: i, j
Accumulator variables: curr, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { static int make_xor_half ( ArrayList arr ) { int sum = 0 , xr = 0 ; foreach ( int a in arr ) { sum += a ; xr ^= a ; } if ( 2 * xr == sum ) return - 1 ; if ( xr == 0 ) { arr . Add ( sum ) ; return 1 ; } arr . Add ( xr ) ; arr . Add ( sum + xr ) ; return 2 ; } public static void Main ( string [ ] args ) { int N = 7 ; ArrayList nums = new ArrayList ( ) { 3 , 4 , 7 , 1 , 2 , 5 , 6 } ; int count = make_xor_half ( nums ) ; if ( count == - 1 ) Console . Write ( - 1 + " STRNEWLINE " ) ; else if ( count == 1 ) Console . Write ( nums [ N ] + " STRNEWLINE " ) ; else Console . Write ( nums [ N ] + " ▁ " + nums [ N + 1 ] + " STRNEWLINE " ) ; } }

Index/key variables: N
Accumulator variables: sum, xr
Iterator variables: a
Class/struct names: GFG
C# program:
using System ; class GFG { public static int count_triangles ( int a , int b , int c , int d ) { int ans = 0 ; for ( int x = a ; x <= b ; ++ x ) { int num_greater_than_d = Math . Max ( d , c + x ) - Math . Max ( d , b + x - 1 ) ; ans += num_greater_than_d * ( d - c + 1 ) ; int r = Math . Min ( Math . Max ( c , c + x ) , d ) - c ; int l = Math . Min ( Math . Max ( c , b + x - 1 ) , d ) - c ; int x1 = ( r * ( r + 1 ) ) / 2 ; int x2 = ( l * ( l + 1 ) ) / 2 ; ans += x1 - x2 ; } return ans ; } public static void Main ( String [ ] args ) { int a = 2 , b = 3 , c = 4 , d = 5 ; Console . WriteLine ( count_triangles ( a , b , c , d ) ) ; } }

Accumulator variables: ans
Iterator variables: x
Class/struct names: GFG
C# program:
using System ; class GFG { static void minFlip ( String s , int n , int k , char [ ] a , int p ) { bool [ ] allowed = new bool [ 26 ] ; for ( int i = 0 ; i < p ; i ++ ) { allowed [ a [ i ] - ' a ' ] = true ; } char [ , ] freq = new char [ k , 26 ] ; for ( int i = 0 ; i < k ; i ++ ) for ( int j = 0 ; j < 26 ; j ++ ) freq [ i , j ] = ( char ) 0 ; for ( int i = 0 ; i < n ; i ++ ) { freq [ i % k , s [ i ] - ' a ' ] += ( char ) 1 ; } int ans = 0 ; int totalpositions = n / k ; for ( int i = 0 ; i < k ; i ++ ) { int maxfrequency = 0 ; for ( int j = 0 ; j < 26 ; j ++ ) { if ( freq [ i , j ] > maxfrequency && allowed [ j ] == true ) maxfrequency = freq [ i , j ] ; } ans += ( totalpositions - maxfrequency + ( ( i % k < n % k ) ? 1 : 0 ) ) ; } Console . Write ( ans + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { String S = " nihsiakyt " ; int n = S . Length ; int K = 3 ; char [ ] A = { ' n ' , ' i ' , ' p ' , ' s ' , ' q ' } ; int p = A . Length ; minFlip ( S , n , K , A , p ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void colorRequired ( int [ ] arr , int n ) { bool all_same = true ; bool one_adjacent_same = false ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( arr [ i ] != arr [ i + 1 ] ) { all_same = false ; } if ( arr [ i ] == arr [ i + 1 ] ) { one_adjacent_same = true ; } } if ( all_same == true ) { Console . Write ( 1 + " STRNEWLINE " ) ; return ; } if ( n % 2 == 0 one_adjacent_same == true ) { Console . Write ( 2 + " STRNEWLINE " ) ; return ; } Console . Write ( 3 + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 1 , 1 , 2 } ; int n = arr . Length ; colorRequired ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: all_same, one_adjacent_same
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxRemainingSum ( int [ ] arr , int n ) { int i , sum = 0 ; for ( i = 0 ; i < n ; i ++ ) sum += arr [ i ] ; i = 0 ; int j = n - 1 ; int result = 0 ; while ( i < j ) { if ( arr [ i ] < arr [ j ] ) { sum -= arr [ i ] ; i ++ ; } else { sum -= arr [ j ] ; j -- ; } result += sum ; } return result ; } public static void Main ( ) { int [ ] arr = { 3 , 1 , 7 , 2 , 1 } ; int N = arr . Length ; Console . Write ( maxRemainingSum ( arr , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, result, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void printKParts ( int N , int K ) { if ( N % K == 0 ) { for ( int i = 1 ; i < K ; i ++ ) Console . Write ( "1 , ▁ " ) ; Console . Write ( N - ( K - 1 ) + " STRNEWLINE " ) ; } else { if ( K == 2 ) { Console . Write ( " Not ▁ Possible " + " STRNEWLINE " ) ; return ; } for ( int i = 1 ; i < K - 1 ; i ++ ) Console . Write ( 1 + " , ▁ " ) ; Console . Write ( 2 + " , ▁ " + ( N - K ) + " STRNEWLINE " ) ; } } public static void Main ( String [ ] args ) { int N = 18 , K = 5 ; printKParts ( N , K ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int minOperations ( String s , int len ) { int operationCnt = 0 ; Stack < char > st = new Stack < char > ( ) ; int cntClosing = 0 ; for ( int i = 0 ; i < len ; i ++ ) { if ( s [ i ] == ' { ' ) { if ( cntClosing > 0 ) { operationCnt ++ ; st . Pop ( ) ; } st . Push ( s [ i ] ) ; cntClosing = 0 ; } else if ( st . Count != 0 ) { st . Push ( ' { ' ) ; operationCnt ++ ; cntClosing = 1 ; } else { cntClosing = ( cntClosing + 1 ) % 2 ; if ( cntClosing == 0 && st . Count != 0 ) { st . Pop ( ) ; } } } operationCnt += st . Count * 2 - cntClosing + 1 ; return operationCnt ; } public static void Main ( String [ ] args ) { String str = " } } { " ; int len = str . Length ; Console . Write ( minOperations ( str , len ) ) ; } }

Index/key variables: i
Accumulator variables: i, operationCnt
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int longestSubsequence ( String s ) { int n = s . Length ; int answer = 0 ; char prev = ' - ' ; for ( int i = 0 ; i < n ; i ++ ) { if ( prev != s [ i ] ) { prev = s [ i ] ; answer ++ ; } } return answer ; } public static void Main ( String [ ] args ) { String str = " ababa " ; Console . Write ( longestSubsequence ( str ) ) ; } }

Index/key variables: i
Accumulator variables: answer, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } static int maximumGcdSubarray ( int [ ] arr , int n ) { if ( n == 1 ) return 0 ; int k = 1 ; for ( int i = 1 ; i < n ; i ++ ) { k = Math . Max ( k , gcd ( arr [ i ] , arr [ i - 1 ] ) ) ; } int cnt = 0 ; int maxLength = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % k == 0 ) { cnt ++ ; } else { maxLength = Math . Max ( maxLength , cnt ) ; cnt = 0 ; } } maxLength = Math . Max ( maxLength , cnt ) ; return maxLength ; } static void Main ( ) { int [ ] arr = { 18 , 3 , 6 , 9 } ; int n = arr . Length ; Console . WriteLine ( maximumGcdSubarray ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void MinDiff ( int n ) { int val = ( int ) Math . Pow ( 2 , n ) ; int sep = n / 2 ; int grp1 = 0 ; int grp2 = 0 ; grp1 = grp1 + val ; for ( int i = 1 ; i < sep ; i ++ ) grp1 = grp1 + ( int ) Math . Pow ( 2 , i ) ; for ( int i = sep ; i < n ; i ++ ) grp2 = grp2 + ( int ) Math . Pow ( 2 , i ) ; Console . Write ( Math . Abs ( grp1 - grp2 ) ) ; } public static void Main ( ) { int n = 4 ; MinDiff ( n ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void countDist ( int [ ] arr1 , int n , int [ ] arr2 , int m , int k ) { int count = 0 ; int smallest = arr2 [ 0 ] ; int largest = arr2 [ 0 ] ; for ( int i = 0 ; i < m ; i ++ ) { smallest = Math . Max ( smallest , arr2 [ i ] ) ; largest = Math . Min ( largest , arr1 [ i ] ) ; } for ( int i = 0 ; i < n ; i ++ ) { if ( Math . Abs ( arr1 [ i ] - smallest ) > k || Math . Abs ( arr1 [ i ] - largest ) > k ) count ++ ; } Console . Write ( count ) ; } public static void Main ( String [ ] args ) { int [ ] arr1 = { 3 , 1 , 4 } ; int n = arr1 . Length ; int [ ] arr2 = { 5 , 1 , 2 } ; int m = arr2 . Length ; int k = 2 ; countDist ( arr1 , n , arr2 , m , k ) ; } }

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 void MakeArray ( int [ ] a , int n , int k ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! mp . ContainsKey ( a [ i ] ) ) mp . Add ( a [ i ] , 1 ) ; } if ( mp . Count > k ) { Console . Write ( " Not ▁ possible STRNEWLINE " ) ; return ; } List < int > ans = new List < int > ( ) ; foreach ( KeyValuePair < int , int > i in mp ) { ans . Add ( i . Key ) ; } while ( ans . Count < k ) { ans . Add ( 1 ) ; } for ( int i = 0 ; i < 2 ; i ++ ) { for ( int j = 0 ; j < k ; j ++ ) Console . Write ( ans [ j ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 2 , 1 } ; int K = 2 ; int size = arr . Length ; MakeArray ( arr , size , 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 int MinimumValue ( int [ ] a , int n ) { int answer = Int32 . MaxValue ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { answer = Math . Min ( answer , ( ( a [ i ] & a [ j ] ) ^ ( a [ i ] a [ j ] ) ) ) ; } } return answer ; } public static void Main ( ) { int N = 6 ; int [ ] A = new int [ ] { 12 , 3 , 14 , 5 , 9 , 8 } ; Console . Write ( MinimumValue ( A , N ) ) ; } }

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