dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { static void findTotalDistance ( string S , int N ) { int [ ] prefixDistance = new int [ N ] ; int [ ] suffixDistance = new int [ N ] ; int cnt = 0 ; bool haveOne = false ; for ( int i = 0 ; i < N ; ++ i ) { if ( S [ i ] == '1' ) { haveOne = true ; cnt = 0 ; prefixDistance [ i ] = 0 ; } else if ( haveOne ) { cnt ++ ; prefixDistance [ i ] = cnt ; } else prefixDistance [ i ] = Int32 . MaxValue ; } haveOne = false ; for ( int i = N - 1 ; i >= 0 ; -- i ) { if ( S [ i ] == '1' ) { haveOne = true ; cnt = 0 ; suffixDistance [ i ] = 0 ; } else if ( haveOne ) { cnt ++ ; suffixDistance [ i ] = cnt ; } else suffixDistance [ i ] = Int32 . MaxValue ; } int sum = 0 ; for ( int i = 0 ; i < N ; ++ i ) { if ( S [ i ] == '0' ) { sum += Math . Min ( prefixDistance [ i ] , suffixDistance [ i ] ) ; } } Console . Write ( sum ) ; } public static void Main ( ) { string S = "100100" ; int N = S . Length ; findTotalDistance ( S , N ) ; } }

Index/key variables: N, i
Accumulator variables: cnt, sum
Iterator variables: i
Boolean variables: haveOne
Class/struct names: GFG
C# program:
using System ; class GFG { public static int minimizeCost ( int A , int B , int C ) { int ans = A + B + C ; for ( int i = 1 ; i <= 2 * C ; i ++ ) { int j = 0 ; while ( i * j <= 2 * C ) { ans = Math . Min ( ans , Math . Abs ( A - i ) + Math . Abs ( B - j ) + Math . Abs ( i * j - C ) ) ; j ++ ; } } return ans ; } public static void Main ( String [ ] args ) { int A = 19 , B = 28 , C = 522 ; Console . Write ( minimizeCost ( A , B , C ) ) ; } }

Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static double averageSetBits ( int N , int K , int [ ] arr ) { double p = N ; double q = 0 ; for ( int i = 0 ; i < K ; i ++ ) { double _p = p , _q = q ; p = _p - _p * arr [ i ] / N + _q * arr [ i ] / N ; q = _q - _q * arr [ i ] / N + _p * arr [ i ] / N ; } return p ; } public static void Main ( String [ ] args ) { int N = 5 ; int [ ] arr = { 1 , 2 , 3 } ; int K = arr . Length ; Console . WriteLine ( String . Format ( " { 0 : F10 } " , averageSetBits ( N , K , arr ) ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxSubseq ( int [ ] arr , int N , int K ) { int sum = 0 ; Array . Sort ( arr ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( K == 0 ) break ; if ( arr [ i ] < 0 ) { arr [ i ] = - arr [ i ] ; K -- ; } } for ( int i = 0 ; i < N ; i ++ ) if ( arr [ i ] > 0 ) sum += arr [ i ] ; return sum ; } public static void Main ( string [ ] args ) { int [ ] arr = { 6 , - 10 , - 1 , 0 , - 4 , 2 } ; int K = 2 ; int N = arr . Length ; Console . Write ( maxSubseq ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: K, i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static long KthSolution ( long X , long K ) { long ans = 0 ; for ( int i = 0 ; i < 64 ; i ++ ) { if ( ( X & ( 1L L << i ) ) == 0 ) { if ( ( K & 1 ) > 0 ) { ans |= ( 1L L << i ) ; } K >>= 1 ; if ( K == 0 ) { break ; } } } return ans ; } public static void Main ( ) { long X = 5 , K = 5 ; Console . Write ( KthSolution ( X , K ) ) ; } }

Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void printTheArray ( int [ ] arr , int N ) { for ( int i = 0 ; i < N ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } static void rearrange ( int [ ] arr , int N ) { if ( ( N & 1 ) != 0 ) N -- ; int odd_idx = 1 , even_idx = 0 ; int i , max_elem = arr [ N - 1 ] + 1 ; for ( i = 0 ; i < N / 2 ; i ++ ) { arr [ i ] += ( arr [ odd_idx ] % max_elem ) * max_elem ; odd_idx += 2 ; } for ( ; i < N ; i ++ ) { arr [ i ] += ( arr [ even_idx ] % max_elem ) * max_elem ; even_idx += 2 ; } for ( i = 0 ; i < N ; i ++ ) { arr [ i ] = arr [ i ] / max_elem ; } } public static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 16 , 18 , 19 } ; int N = arr . Length ; rearrange ( arr , N ) ; printTheArray ( arr , N ) ; } }

Index/key variables: even_idx, i, odd_idx
Accumulator variables: N, even_idx, i, odd_idx
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void findRange ( int [ ] arr , int N , int K ) { int L = Int32 . MinValue ; int R = Int32 . MaxValue ; for ( int i = 0 ; i < N ; i ++ ) { int l = ( int ) Math . Ceiling ( 1.0 * arr [ i ] * K / ( i + 1 ) ) ; int r = ( int ) Math . Ceiling ( ( 1.0 + arr [ i ] ) * K / ( i + 1 ) ) - 1 ; L = Math . Max ( L , l ) ; R = Math . Min ( R , r ) ; } Console . WriteLine ( L + " ▁ " + R ) ; } public static void Main ( ) { int [ ] arr = { 2 , 4 , 6 , 9 , 11 } ; int K = 10 ; int N = arr . Length ; findRange ( arr , N , K ) ; } }

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 findAnagram ( string s ) { string check = s ; int i = 0 , j = s . Length - 1 ; while ( i < s . Length && j >= 0 ) { if ( s [ i ] != s [ j ] && check [ i ] != s [ j ] && check [ j ] != s [ i ] ) { char temp = s [ i ] ; s = s . Substring ( 0 , i ) + s [ j ] + s . Substring ( i + 1 ) ; s = s . Substring ( 0 , j ) + temp + s . Substring ( j + 1 ) ; i ++ ; j = s . Length - 1 ; } else { j -- ; } } if ( s . Length % 2 != 0 ) { int mid = s . Length / 2 ; if ( check [ mid ] == s [ mid ] ) { for ( i = 0 ; i < s . Length ; i ++ ) { if ( check [ i ] != s [ mid ] && s [ i ] != s [ mid ] ) { char temp = s [ i ] ; s = s . Substring ( 0 , i ) + s [ mid ] + s . Substring ( i + 1 ) ; s = s . Substring ( 0 , mid ) + temp + s . Substring ( mid + 1 ) ; break ; } } } } bool ok = true ; for ( i = 0 ; i < s . Length ; i ++ ) { if ( check [ i ] == s [ i ] ) { ok = false ; break ; } } if ( ok ) Console . Write ( s ) ; else Console . Write ( - 1 ) ; } public static void Main ( ) { string S = " geek " ; findAnagram ( S ) ; } }

Index/key variables: i, j, mid
Accumulator variables: i, j
Iterator variables: i
Boolean variables: ok
Class/struct names: GFG
C# program:
using System ; class GFG { static void constructPermutation ( string S , int N ) { int [ ] ans = new int [ N ] ; ans [ 0 ] = 1 ; for ( int i = 1 ; i < N ; ++ i ) { if ( S [ i - 1 ] == '0' ) { ans [ i ] = i + 1 ; } else { ans [ i ] = ans [ i - 1 ] ; } for ( int j = 0 ; j < i ; ++ j ) { if ( ans [ j ] >= ans [ i ] ) { ans [ j ] ++ ; } } } for ( int i = 0 ; i < N ; i ++ ) { Console . Write ( ans [ i ] ) ; if ( i != N - 1 ) { Console . Write ( " ▁ " ) ; } } } public static void Main ( ) { string S = "100101" ; constructPermutation ( S , S . Length + 1 ) ; } }

Index/key variables: N, i, j
Accumulator variables: i
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { static long KthSolution ( long X , long K ) { int ans = 0 ; for ( int i = 0 ; i < 64 ; i ++ ) { if ( ( X & ( 1 << i ) ) == 0 ) { if ( ( K & 1 ) > 0 ) { ans |= ( 1 << i ) ; } K >>= 1 ; if ( K == 0 ) { break ; } } } return ans ; } public static void Main ( String [ ] args ) { long X = 10 ; long K = 5 ; Console . WriteLine ( KthSolution ( X , K ) ) ; } }

Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int countArrays ( int n , int k ) { List < int > [ ] divisors = new List < int > [ k + 1 ] ; for ( int i = 0 ; i < divisors . Length ; i ++ ) divisors [ i ] = new List < int > ( ) ; for ( int i = 1 ; i <= k ; i ++ ) { for ( int j = 2 * i ; j <= k ; j += i ) { divisors [ j ] . Add ( i ) ; } } int [ , ] dp = new int [ n + 1 , k + 1 ] ; for ( int j = 1 ; j <= k ; j ++ ) { dp [ 1 , j ] = 1 ; } int sum ; for ( int x = 2 ; x <= n ; x ++ ) { sum = 0 ; for ( int j = 1 ; j <= k ; j ++ ) { sum += dp [ x - 1 , j ] ; } for ( int y = 1 ; y <= k ; y ++ ) { dp [ x , y ] = sum ; foreach ( int d in divisors [ y ] ) { dp [ x , y ] = ( dp [ x , y ] - dp [ x - 1 , d ] ) ; } } } sum = 0 ; for ( int j = 1 ; j <= k ; j ++ ) { sum += dp [ n , j ] ; } return sum ; } public static void Main ( ) { int N = 2 , K = 3 ; Console . Write ( countArrays ( N , K ) ) ; } }

Index/key variables: i, j, y
Accumulator variables: i, j, sum, x, y
Iterator variables: d, i, j, x, y
Class/struct names: GFG
C# program:
using System ; public class GFG { static int minimumMoves ( int [ ] A , int [ ] B , int N ) { int ans = 0 ; int sum_A = 0 , sum_B = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum_A += A [ i ] ; } for ( int i = 0 ; i < N ; i ++ ) { sum_B += B [ i ] ; } if ( sum_A != sum_B ) { return - 1 ; } int k = 0 ; while ( k < N ) { if ( A [ k ] > B [ k ] ) { int temp = A [ k ] - B [ k ] ; int j = k - 1 ; while ( j >= 0 && temp > 0 ) { if ( B [ j ] > A [ j ] ) { int cnt = Math . Min ( temp , ( B [ j ] - A [ j ] ) ) ; A [ j ] += cnt ; temp -= cnt ; ans += ( cnt * Math . Abs ( j - k ) ) ; } j -- ; } if ( temp > 0 ) { j = k + 1 ; while ( j < N && temp > 0 ) { if ( B [ j ] > A [ j ] ) { int cnt = Math . Min ( temp , ( B [ j ] - A [ j ] ) ) ; A [ j ] += cnt ; temp -= cnt ; ans += ( cnt * Math . Abs ( j - k ) ) ; } j ++ ; } } } k ++ ; } return ans ; } public static void Main ( string [ ] args ) { int [ ] A = { 1 , 5 , 7 } ; int [ ] B = { 13 , 0 , 0 } ; int N = A . Length ; Console . WriteLine ( minimumMoves ( A , B , N ) ) ; } }

Index/key variables: i, j, k
Accumulator variables: ans, i, j, k, sum_A, sum_B, temp
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int possibleReachingSequence ( int X , int D , int T ) { if ( X < T ) { Console . WriteLine ( " NO " ) ; return 0 ; } if ( T * D < X ) { Console . WriteLine ( " NO " ) ; return 0 ; } if ( ( X - T ) % ( D - 1 ) == 0 ) { Console . WriteLine ( " YES " ) ; } else { Console . WriteLine ( " NO " ) ; } return 0 ; } public static void Main ( string [ ] args ) { int X = 10 , D = 3 , T = 6 ; possibleReachingSequence ( X , D , T ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int arrayDivisionByTwo ( int [ ] arr , int n ) { int cnt = 0 ; int ans = Int32 . MaxValue ; for ( int i = 0 ; i < n ; i ++ ) { cnt = 0 ; while ( arr [ i ] % 2 == 0 ) { arr [ i ] = arr [ i ] / 2 ; cnt ++ ; } ans = Math . Min ( ans , cnt ) ; } return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 8 , 12 , 40 } ; int n = arr . Length ; Console . Write ( arrayDivisionByTwo ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static void printMinint ( int P , int Q , int N ) { if ( Q > P ) { int temp ; temp = P ; P = Q ; Q = temp ; } if ( Q == 0 && ( P == 0 N % P != 0 ) ) { Console . WriteLine ( " Not ▁ Possible " ) ; return ; } int count_P = 0 , count_Q = 0 ; while ( N > 0 ) { if ( N % P == 0 ) { count_P += N / P ; N = 0 ; } else { N = N - Q ; count_Q ++ ; } } if ( N == 0 ) { for ( int i = 0 ; i < count_Q ; i ++ ) Console . Write ( Q ) ; for ( int i = 0 ; i < count_P ; i ++ ) Console . Write ( P ) ; } else { Console . WriteLine ( " Not ▁ Possible " ) ; } } public static void Main ( String [ ] args ) { int N = 32 ; int P = 7 ; int Q = 4 ; printMinint ( P , Q , N ) ; } }

Accumulator variables: count_P, count_Q, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int minPushes ( int N , int K , int [ ] arr ) { int [ ] dp = new int [ 100000 ] ; for ( int i = 0 ; i < dp . Length ; i ++ ) dp [ i ] = - 1 ; dp [ N ] = 0 ; for ( int i = 0 ; i < arr . Length ; i ++ ) { for ( int xx = 0 ; xx < 100000 ; xx ++ ) { int x = xx ; if ( dp [ x ] == - 1 ) continue ; int next = ( x + arr [ i ] ) % 100000 ; while ( dp [ next ] == - 1 dp [ next ] > dp [ x ] + 1 ) { dp [ next ] = dp [ x ] + 1 ; x = next ; next = ( next + arr [ i ] ) % 100000 ; } } } return dp [ K ] ; } public static void Main ( String [ ] args ) { int N = 99880 , K = 89 ; int [ ] arr = { 100 , 3 } ; Console . Write ( minPushes ( N , K , arr ) ) ; } }

Index/key variables: K, N, i, next, x
Accumulator variables: i, xx
Iterator variables: i, xx
Class/struct names: GFG
C# program:
using System ; class GFG { static int minApples ( int M , int K , int N , int S , int W , int E ) { if ( M <= S * K ) return M ; else if ( M <= S * K + E + W ) return S * K + ( M - S * K ) * K ; else return - 1 ; } public static void Main ( String [ ] args ) { int M = 10 ; int K = 15 ; int N = 0 ; int S = 1 ; int W = 0 ; int E = 0 ; int ans = minApples ( M , K , N , S , W , E ) ; Console . Write ( ans ) ; } }

Class/struct names: GFG
C# program:
using System ; public class GFG { static int minimumOperations ( int [ ] A , int N ) { int cur_prefix_1 = 0 ; int parity = - 1 ; int minOperationsCase1 = 0 ; for ( int i = 0 ; i < N ; i ++ ) { cur_prefix_1 += A [ i ] ; if ( cur_prefix_1 == 0 parity * cur_prefix_1 < 0 ) { minOperationsCase1 += Math . Abs ( parity - cur_prefix_1 ) ; cur_prefix_1 = parity ; } parity *= - 1 ; } int cur_prefix_2 = 0 ; parity = 1 ; int minOperationsCase2 = 0 ; for ( int i = 0 ; i < N ; i ++ ) { cur_prefix_2 += A [ i ] ; if ( cur_prefix_2 == 0 parity * cur_prefix_2 < 0 ) { minOperationsCase2 += Math . Abs ( parity - cur_prefix_2 ) ; cur_prefix_2 = parity ; } parity *= - 1 ; } return Math . Min ( minOperationsCase1 , minOperationsCase2 ) ; } public static void Main ( String [ ] args ) { int [ ] A = { 1 , - 3 , 1 , 0 } ; int N = A . Length ; Console . Write ( minimumOperations ( A , N ) ) ; } }

Index/key variables: i
Accumulator variables: cur_prefix_1, cur_prefix_2, i, minOperationsCase1, minOperationsCase2, parity
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void maximumSumArray ( int [ ] arr , int N ) { int [ ] arrA = new int [ N ] ; int [ ] ans = new int [ N ] ; int maxSum = 0 ; for ( int i = 0 ; i < N ; i ++ ) arrA [ i ] = arr [ i ] ; for ( int i = 0 ; i < N ; i ++ ) { int [ ] arrB = new int [ N ] ; int maximum = arrA [ i ] ; arrB [ i ] = maximum ; for ( int j = i - 1 ; j >= 0 ; j -- ) { arrB [ j ] = Math . Min ( maximum , arrA [ j ] ) ; maximum = arrB [ j ] ; } maximum = arrA [ i ] ; for ( int j = i + 1 ; j < N ; j ++ ) { arrB [ j ] = Math . Min ( maximum , arrA [ j ] ) ; maximum = arrB [ j ] ; } int sum = 0 ; for ( int j = 0 ; j < N ; j ++ ) sum += arrB [ j ] ; if ( sum > maxSum ) { maxSum = sum ; ans = arrB ; } } foreach ( int val in ans ) { Console . Write ( val + " ▁ " ) ; } } public static void Main ( ) { int [ ] A = { 10 , 6 , 8 } ; int N = A . Length ; maximumSumArray ( A , N ) ; } }

Index/key variables: N, i, j
Accumulator variables: i, j, sum
Iterator variables: i, j, val
Class/struct names: GFG
C# program:
using System ; class GFG { static int minProductUtil ( int R1 , int B1 , int R2 , int B2 , int M ) { int x = Math . Min ( R1 - B1 , M ) ; M -= x ; R1 -= x ; if ( M > 0 ) { int y = Math . Min ( R2 - B2 , M ) ; M -= y ; R2 -= y ; } return R1 * R2 ; } static int minProduct ( int R1 , int B1 , int R2 , int B2 , int M ) { int res1 = minProductUtil ( R1 , B1 , R2 , B2 , M ) ; int res2 = minProductUtil ( R2 , B2 , R1 , B1 , M ) ; return Math . Min ( res1 , res2 ) ; } public static void Main ( String [ ] args ) { int R1 = 21 , B1 = 10 , R2 = 13 , B2 = 11 , M = 3 ; Console . Write ( ( minProduct ( R1 , B1 , R2 , B2 , M ) ) ) ; } }

Accumulator variables: M, R1, R2
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int maxAmount ( int n , int k , int [ ] arr ) { int i ; int [ ] A = new int [ 1000001 ] ; Array . Clear ( A , 0 , 1000001 ) ; for ( i = 0 ; i < n ; i ++ ) { A [ arr [ i ] ] ++ ; } int j = 0 ; for ( i = 0 ; i < 1000001 ; i ++ ) { while ( A [ i ] != 0 ) { arr [ j ++ ] = i ; A [ i ] -- ; } } int ans = 0 ; int mod = 1000000007 ; i = n - 1 ; j = n - 2 ; while ( k > 0 && j >= 0 ) { if ( arr [ i ] > arr [ j ] ) { ans = ans + Math . Min ( k , ( i - j ) ) * arr [ i ] ; k = k - ( i - j ) ; arr [ i ] -- ; } else { while ( j >= 0 && arr [ j ] == arr [ i ] ) j -- ; if ( j < 0 ) break ; ans = ans + Math . Min ( k , ( i - j ) ) * arr [ i ] ; k = k - ( i - j ) ; arr [ i ] -- ; } } while ( k > 0 && arr [ i ] != 0 ) { ans = ans + Math . Min ( n , k ) * arr [ i ] ; k -= n ; arr [ i ] -- ; } ans = ans % mod ; int x = ans ; return x ; } public static void Main ( ) { int n = 5 ; int k = 3 ; int [ ] arr = { 4 , 3 , 6 , 2 , 4 } ; int ans = maxAmount ( n , k , arr ) ; Console . Write ( ans ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, k
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static void maxAverage ( int [ ] A , int N , int X , int Y ) { Array . Sort ( A ) ; int sum = 0 ; double res = 0 ; int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += A [ i ] ; count ++ ; if ( count == X ) { if ( N - i - 1 < X ) { i ++ ; int cnt = 0 ; while ( i < N ) { cnt ++ ; sum += A [ i ] ; i ++ ; } X = X + cnt ; res += ( double ) sum / ( double ) ( X ) ; break ; } res += ( double ) sum / ( double ) ( X ) ; sum = 0 ; count = 0 ; } } Console . WriteLine ( res ) ; } public static void Main ( String [ ] args ) { int [ ] A = { 4 , 10 , 6 , 5 } ; int N = A . Length ; int X = 2 , Y = 3 ; maxAverage ( A , N , X , Y ) ; } }

Index/key variables: i
Accumulator variables: cnt, count, i, res, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static char [ ] S = " aaabc " . ToCharArray ( ) ; static bool isAdjChar ( ) { for ( int i = 0 ; i < S . Length - 1 ; i ++ ) { if ( S [ i ] == S [ i + 1 ] ) return true ; } return false ; } static void rearrangeStringUtil ( int N ) { int i = 0 , j = 1 , k = 2 ; while ( k < N ) { if ( S [ i ] != S [ j ] ) { i ++ ; j ++ ; if ( j == k ) { k ++ ; } } else { if ( S [ j ] == S [ k ] ) { k ++ ; } else { swap ( k , j ) ; i ++ ; j ++ ; if ( j == k ) { k ++ ; } } } } } static void swap ( int i , int j ) { char temp = S [ i ] ; S [ i ] = S [ j ] ; S [ j ] = temp ; } static String rearrangeString ( int N ) { if ( isAdjChar ( ) == false ) { return String . Join ( " " , S ) ; } if ( S . Length == 2 ) return " - 1" ; rearrangeStringUtil ( N ) ; reverse ( ) ; rearrangeStringUtil ( N ) ; if ( isAdjChar ( ) == false ) { return String . Join ( " " , S ) ; } return " - 1" ; } static void reverse ( ) { int l , r = S . Length - 1 ; for ( l = 0 ; l < r ; l ++ , r -- ) { char temp = S [ l ] ; S [ l ] = S [ r ] ; S [ r ] = temp ; } } public static void Main ( String [ ] args ) { int N = S . Length ; Console . Write ( rearrangeString ( N ) ) ; } }

Index/key variables: i, j, k, l, r
Accumulator variables: i, j, k, l, r
Iterator variables: i, l
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static string largestMerge ( string word1 , string word2 ) { string merge = " " ; while ( word1 . Length != 0 word2 . Length != 0 ) { if ( String . Compare ( word1 , word2 ) == 0 || String . Compare ( word1 , word2 ) > 0 ) { merge = merge + word1 [ 0 ] ; word1 = word1 . Substring ( 1 ) ; } else { merge = merge + word2 [ 0 ] ; word2 = word2 . Substring ( 1 ) ; } } return merge ; } public static void Main ( ) { string S1 = " xyzxyz " ; string S2 = " xywzxyx " ; Console . Write ( largestMerge ( S1 , S2 ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { public static int findMaximumPoints ( int N , int [ ] X , int [ ] H ) { int ans = 0 ; int prev = Int32 . MinValue ; for ( int i = 0 ; i < N ; ++ i ) { if ( prev < ( X [ i ] - H [ i ] ) ) { ++ ans ; prev = X [ i ] ; } else if ( i == N - 1 || ( X [ i ] + H [ i ] ) < X [ i + 1 ] ) { ++ ans ; prev = X [ i ] + H [ i ] ; } else { prev = X [ i ] ; } } return ans ; } static public void Main ( ) { int [ ] X = { 1 , 2 , 3 } ; int [ ] H = { 2 , 5 , 5 } ; int N = X . Length ; Console . WriteLine ( findMaximumPoints ( N , X , H ) ) ; } }

Index/key variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class gfg { public static void maxTime ( String S ) { char [ ] s = S . ToCharArray ( ) ; if ( s [ 0 ] == ' ? ' ) { if ( s [ 1 ] <= '3' s [ 1 ] == ' ? ' ) s [ 0 ] = '2' ; else s [ 0 ] = '1' ; } if ( s [ 1 ] == ' ? ' ) { if ( s [ 0 ] != '2' ) { s [ 1 ] = '9' ; } else s [ 1 ] = '3' ; } if ( s [ 3 ] == ' ? ' ) s [ 3 ] = '5' ; if ( s [ 4 ] == ' ? ' ) s [ 4 ] = '9' ; Console . Write ( new String ( s ) ) ; } public static void Main ( String [ ] args ) { String S = " ? 4:5 ? " ; maxTime ( S ) ; } }

Class/struct names: gfg
C# program:
using System ; class GFG { static void maxGcd ( int a , int b ) { Console . Write ( Math . Abs ( a - b ) ) ; } static public void Main ( ) { int a = 2231 ; int b = 343 ; maxGcd ( a , b ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void sumOfCombinationOf4OR5 ( int [ ] arr , int N ) { int [ ] ans = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) ans [ i ] = - 1 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] < 4 ) { continue ; } int sum = Int32 . MaxValue , cnt = 0 ; for ( int j = 0 ; j <= arr [ i ] ; j += 4 ) { if ( ( arr [ i ] - j ) % 5 == 0 ) { sum = Math . Min ( sum , cnt + ( int ) ( arr [ i ] - j ) / 5 ) ; } cnt ++ ; } if ( sum != Int32 . MaxValue ) ans [ i ] = sum ; } foreach ( int num in ans ) Console . Write ( num + " ▁ " ) ; } public static void Main ( ) { int [ ] arr = { 7 , 15 , 17 , 22 } ; int N = arr . Length ; sumOfCombinationOf4OR5 ( arr , N ) ; } }

Index/key variables: N, i
Accumulator variables: cnt, i, j
Iterator variables: i, j, num
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void printBinaryString ( int [ , ] arr , int N ) { for ( int i = 1 ; i <= N ; i ++ ) { if ( i % 2 == 1 ) { Console . Write ( 0 ) ; } else { Console . Write ( 1 ) ; } } } public static void Main ( ) { int N = 5 ; int [ , ] arr = { { 1 , 3 } , { 2 , 4 } , { 2 , 5 } } ; printBinaryString ( arr , N ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MinCost ( int [ ] days , int [ ] cost , int N ) { int size = days [ N - 1 ] + 1 ; int [ ] dp = new int [ size ] ; dp [ size - 1 ] = Math . Min ( cost [ 0 ] , Math . Min ( cost [ 1 ] , cost [ 2 ] ) ) ; int ptr = N - 2 ; for ( int i = size - 2 ; i > 0 ; i -- ) { if ( ptr >= 0 && days [ ptr ] == i ) { int val1 = dp [ i + 1 ] + cost [ 0 ] ; int val2 = cost [ 1 ] + ( ( i + 7 >= size ) ? 0 : dp [ i + 7 ] ) ; int val3 = cost [ 2 ] + ( ( i + 30 >= size ) ? 0 : dp [ i + 30 ] ) ; dp [ i ] = Math . Min ( val1 , Math . Min ( val2 , val3 ) ) ; ptr -- ; } else { dp [ i ] = dp [ i + 1 ] ; } } return dp [ 1 ] ; } public static void Main ( ) { int [ ] arr = { 2 , 4 , 6 , 7 , 8 , 10 , 17 } ; int [ ] cost = { 3 , 8 , 20 } ; int N = arr . Length ; Console . WriteLine ( MinCost ( arr , cost , N ) ) ; } }

Index/key variables: i, ptr, size
Accumulator variables: i, ptr
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void countPairs ( int N , List < string > arr ) { int [ ] open = new int [ 100 ] ; int [ ] close = new int [ 100 ] ; int ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { char [ ] c = arr [ i ] . ToCharArray ( ) ; int d = 0 ; int min = 0 ; for ( int j = 0 ; j < c . Length ; j ++ ) { if ( c [ j ] == ' ( ' ) { d ++ ; } else { d -- ; if ( d < min ) min = d ; } } if ( d >= 0 ) { if ( min == 0 ) close [ d ] ++ ; } else if ( d < 0 ) { if ( min == d ) open [ - d ] ++ ; } } ans += close [ 0 ] / 2 ; for ( int i = 1 ; i < 100 ; i ++ ) { ans += Math . Min ( open [ i ] , close [ i ] ) ; } Console . WriteLine ( ans ) ; } public static void Main ( string [ ] args ) { int N = 7 ; List < string > list = new List < string > ( ) ; list . Add ( " ) ( ) ) " ) ; list . Add ( " ) " ) ; list . Add ( " ( ( " ) ; list . Add ( " ( ( " ) ; list . Add ( " ( " ) ; list . Add ( " ) " ) ; list . Add ( " ) " ) ; countPairs ( N , list ) ; } }

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