dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static bool isDivisible ( int N ) { return ( N a 1 ) % 3 != 0 ; } public static void Main ( ) { int N = 6 ; if ( isDivisible ( N ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int countDigitSum ( int N , int K ) { int l = ( int ) Math . Pow ( 10 , N - 1 ) , r = ( int ) Math . Pow ( 10 , N ) - 1 ; int count = 0 ; for ( int i = l ; i <= r ; i ++ ) { int num = i ; int [ ] digits = new int [ N ] ; for ( int j = N - 1 ; j >= 0 ; j -- ) { digits [ j ] = num % 10 ; num /= 10 ; } int sum = 0 , flag = 0 ; for ( int j = 0 ; j < K ; j ++ ) sum += digits [ j ] ; for ( int j = 1 ; j < N - K + 1 ; j ++ ) { int curr_sum = 0 ; for ( int m = j ; m < j + K ; m ++ ) { curr_sum += digits [ m ] ; } if ( sum != curr_sum ) { flag = 1 ; break ; } } if ( flag == 0 ) { count ++ ; } } return count ; } public static void Main ( ) { int N = 2 , K = 1 ; Console . Write ( countDigitSum ( N , K ) ) ; } }

Index/key variables: N, j, m
Accumulator variables: count, curr_sum, i, j, m, num, sum
Iterator variables: i, j, m
Class/struct names: GFG
C# program:
using System ; class GFG { static int noOfFactors ( int N ) { if ( N == 1 ) return 1 ; int count = 0 ; int ans = 1 ; while ( N % 2 == 0 ) { count ++ ; N = N / 2 ; } ans *= ( count / 2 + 1 ) ; for ( int i = 3 ; i * i <= N ; i = i + 2 ) { count = 0 ; while ( N % i == 0 ) { count ++ ; N = N / i ; } ans *= ( count / 2 + 1 ) ; } return ans ; } public static void Main ( String [ ] args ) { int N = 100 ; Console . Write ( noOfFactors ( N ) ) ; } }

Accumulator variables: ans, count
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool possible ( int N , int a , int b , int n ) { int sum_of_angle = 180 * ( N - 2 ) ; int Total_angle = ( N * ( ( 2 * a ) + ( N - 1 ) * b ) ) / 2 ; if ( sum_of_angle != Total_angle ) return false ; else return true ; } static int nth_angle ( int N , int a , int b , int n ) { int nth = 0 ; nth = a + ( n - 1 ) * b ; return nth ; } public static void Main ( string [ ] args ) { int N = 3 , a = 30 , b = 30 , n = 3 ; if ( possible ( N , a , b , n ) ) Console . Write ( nth_angle ( N , a , b , n ) ) ; else Console . Write ( " Not ▁ Possible " ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { static void DFS ( int U , int [ ] vis , ArrayList adj ) { vis [ U ] = 1 ; foreach ( int V in ( ArrayList ) adj [ U ] ) { if ( vis [ V ] == 0 ) DFS ( V , vis , adj ) ; } } static void minCost ( int N , int M , int vCost , int eCost , int [ ] sorc , ArrayList colored , int [ ] destination ) { ArrayList adj = new ArrayList ( ) ; for ( int i = 0 ; i < N + 1 ; i ++ ) adj . Add ( new ArrayList ( ) ) ; for ( int i = 0 ; i < M ; i ++ ) { ( ( ArrayList ) adj [ sorc [ i ] ] ) . Add ( destination [ i ] ) ; ( ( ArrayList ) adj [ destination [ i ] ] ) . Add ( sorc [ i ] ) ; } int [ ] vis = new int [ N + 1 ] ; for ( int i = 0 ; i < colored . Count ; i ++ ) { DFS ( ( int ) colored [ i ] , vis , adj ) ; } int X = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { if ( vis [ i ] == 0 ) { X ++ ; DFS ( i , vis , adj ) ; } } int mincost = X * Math . Min ( vCost , eCost ) ; Console . Write ( mincost ) ; } public static void Main ( string [ ] args ) { int N = 3 , M = 1 ; int [ ] sorc = { 1 } ; int [ ] destination = { 2 } ; int vCost = 3 , eCost = 2 ; ArrayList colored = new ArrayList ( ) ; colored . Add ( 1 ) ; minCost ( N , M , vCost , eCost , sorc , colored , destination ) ; } }

Index/key variables: U, V, i
Accumulator variables: X, i
Iterator variables: V, i
Class/struct names: GFG
C# program:
using System ; class GFG { static int min_cost ( int n , int x , int p , int q ) { if ( x == 1 ) { Console . WriteLine ( ( n - 1 ) * p ) ; return 0 ; } int ans = ( n - 1 ) * p ; int pre = 0 ; while ( n > 1 ) { int tmp = n / x ; if ( tmp < 0 ) break ; pre += ( n - tmp * x ) * p ; n /= x ; pre += q ; ans = Math . Min ( ans , pre + ( n - 1 ) * p ) ; } return ans ; } public static void Main ( String [ ] args ) { int n = 5 , x = 2 , p = 2 , q = 3 ; Console . WriteLine ( min_cost ( n , x , p , q ) ) ; } }

Accumulator variables: n, pre
Class/struct names: GFG
C# program:
using System ; class GFG { static int calculateWays ( int [ ] arr1 , int [ ] arr2 , int N ) { int A = arr2 [ 0 ] , B = arr2 [ 1 ] ; int C = arr2 [ 2 ] , D = arr2 [ 3 ] ; int ans = 0 ; for ( int b = 0 ; b <= B && b * 5 <= ( N ) ; b ++ ) for ( int c = 0 ; c <= C && b * 5 + c * 10 <= ( N ) ; c ++ ) for ( int d = 0 ; d <= D && b * 5 + c * 10 + d * 20 <= ( N ) ; d ++ ) if ( ( b * 5 ) + ( c * 10 ) + ( d * 20 ) >= ( N - A ) ) ans ++ ; return ans ; } public static void Main ( String [ ] args ) { int N = 123 ; int [ ] arr1 = { 1 , 5 , 10 , 20 } ; int [ ] arr2 = { 6 , 4 , 3 , 5 } ; Console . Write ( calculateWays ( arr1 , arr2 , N ) ) ; } }

Accumulator variables: ans, b, c, d
Iterator variables: b, c, d
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ ] ways = new int [ 1010 ] ; static int calculateWays ( int [ ] arr1 , int [ ] arr2 , int N ) { int A = arr2 [ 0 ] , B = arr2 [ 1 ] ; int C = arr2 [ 2 ] , D = arr2 [ 3 ] ; int ans = 0 ; for ( int b = 0 ; b <= B && b * 5 <= N ; b ++ ) { for ( int a = 0 ; a <= A && a * 1 + b * 5 <= N ; a ++ ) { ways [ a + b * 5 ] ++ ; } } for ( int c = 0 ; c <= C && c * 10 <= ( N ) ; c ++ ) { for ( int d = 0 ; d <= D && c * 10 + d * 20 <= ( N ) ; d ++ ) { ans += ways [ N - c * 10 - d * 20 ] ; } } return ans ; } public static void Main ( String [ ] args ) { int N = 123 ; int [ ] arr1 = { 1 , 5 , 10 , 20 } ; int [ ] arr2 = { 6 , 4 , 3 , 5 } ; Console . Write ( calculateWays ( arr1 , arr2 , N ) ) ; } }

Accumulator variables: a, ans, b, c, d
Iterator variables: a, b, c, d
Class/struct names: GFG
C# program:
using System ; class GFG { public static void countMissingNum ( int [ ] a , int N ) { int count = a [ N - 1 ] - a [ 0 ] + 1 - N ; Console . Write ( count ) ; } public static void Main ( string [ ] args ) { int [ ] arr = { 5 , 10 , 20 , 40 } ; int N = arr . Length ; countMissingNum ( arr , N ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int maxXORSubsequence ( int [ ] arr , int n ) { int i , odd = 0 , even = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( ( arr [ i ] & 1 ) != 0 ) odd ++ ; else even ++ ; } int maxlen ; if ( odd == n ) { if ( odd % 2 == 0 ) maxlen = n - 1 ; else maxlen = n ; } else if ( even == n ) { maxlen = 0 ; } else { if ( odd % 2 == 0 ) maxlen = even + odd - 1 ; else maxlen = even + odd ; } return maxlen ; } public static void Main ( string [ ] args ) { int [ ] arr = { 2 , 3 , 4 , 5 , 6 , 7 } ; int n = arr . Length ; Console . Write ( maxXORSubsequence ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: even, i, odd
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int numberOfPairs ( int n ) { if ( n % 2 == 0 ) return n / 2 - 1 ; else return n / 2 ; } public static void Main ( string [ ] args ) { int n = 8 ; Console . Write ( numberOfPairs ( n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int good_pair ( String [ ] str , int N ) { int countStr = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { String res = str [ i ] + str [ j ] ; int [ ] vowel = new int [ 5 ] ; for ( int k = 0 ; k < res . Length ; k ++ ) { if ( res [ k ] == ' a ' ) vowel [ 0 ] = 1 ; else if ( res [ k ] == ' e ' ) vowel [ 1 ] = 1 ; else if ( res [ k ] == ' i ' ) vowel [ 2 ] = 1 ; else if ( res [ k ] == ' o ' ) vowel [ 3 ] = 1 ; else if ( res [ k ] == ' u ' ) vowel [ 4 ] = 1 ; } int temp = 0 ; for ( int ind = 0 ; ind < 5 ; ind ++ ) { if ( vowel [ ind ] == 1 ) temp ++ ; } if ( temp == 5 ) countStr ++ ; } } return countStr ; } public static void Main ( String [ ] args ) { String [ ] arr = { " aaweiolkju " , " oxdfgujkmi " } ; int N = arr . Length ; Console . Write ( good_pair ( arr , N ) ) ; } }

Index/key variables: i, ind, j, k
Accumulator variables: countStr, i, ind, j, k, temp
Iterator variables: i, ind, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static void sieveOfEratosthenes ( int N , int [ ] s ) { bool [ ] prime = new bool [ N + 1 ] ; for ( int i = 2 ; i <= N ; i += 2 ) s [ i ] = 2 ; for ( int i = 3 ; i <= N ; i += 2 ) { if ( prime [ i ] == false ) { s [ i ] = i ; for ( int j = i ; j * i <= N ; j += 2 ) { if ( prime [ i * j ] == false ) { prime [ i * j ] = true ; s [ i * j ] = i ; } } } } } static int generatePrimeFactors ( int N ) { int [ ] s = new int [ N + 1 ] ; int sum = 0 ; sieveOfEratosthenes ( N , s ) ; int curr = s [ N ] ; int cnt = 1 ; while ( N > 1 ) { N /= s [ N ] ; if ( curr == s [ N ] ) { cnt ++ ; continue ; } sum = sum + cnt ; curr = s [ N ] ; cnt = 1 ; } return sum ; } static void findSum ( int N ) { int sum = 0 ; for ( int i = 2 ; i <= N ; i ++ ) { sum += generatePrimeFactors ( i ) ; } Console . Write ( sum + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int N = 4 ; findSum ( N ) ; } }

Index/key variables: N, i
Accumulator variables: N, cnt, i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int LCM ( int a , int b ) { int lcm = a > b ? a : b ; while ( true ) { if ( lcm % a == 0 && lcm % b == 0 ) break ; else lcm ++ ; } return lcm ; } static void findMinLCM ( int [ ] arr , int n ) { int minLCM = int . MaxValue ; for ( int i = 0 ; i < n - 1 ; i ++ ) { int val = LCM ( arr [ i ] , arr [ i + 1 ] ) ; if ( val < minLCM ) { minLCM = val ; } } Console . Write ( minLCM + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 4 , 8 , 12 , 16 , 20 , 24 } ; int n = arr . Length ; findMinLCM ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i, lcm
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int find_max ( int n , int k ) { int [ ] X = new int [ 32 ] ; int cnt = 0 ; for ( int i = 31 ; i >= 0 && cnt != k ; i -- ) { if ( ( n & ( 1 << i ) ) != 0 ) { X [ i ] = 1 ; cnt ++ ; } } String s = " " ; for ( int i = 31 ; i >= 0 ; i -- ) s += X [ i ] == 0 ? '0' : '1' ; return Convert . ToInt32 ( s , 2 ) ; } public static void Main ( String [ ] args ) { int n = 10 , k = 2 ; Console . Write ( find_max ( n , k ) ) ; } }

Index/key variables: i
Accumulator variables: cnt, i, s
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void convert ( string s ) { int num = 0 ; int n = s . Length ; for ( int i = 0 ; i < n ; i ++ ) num = num * 10 + ( ( int ) s [ i ] - 48 ) ; Console . Write ( num ) ; } public static void Main ( string [ ] args ) { string s = "123" ; convert ( s ) ; } }

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 readonly int hell = 1000000007 ; static readonly int N = 100005 ; static int c_0 , c_1 , c_2 ; static void count_k ( int [ ] arr , Stack < int > ones , Stack < int > twos , Stack < int > zeros ) { for ( int i = 0 ; i < arr . Length ; i ++ ) { if ( arr [ i ] % 3 == 0 ) { c_0 ++ ; zeros . Push ( arr [ i ] ) ; } else if ( arr [ i ] % 3 == 1 ) { c_1 ++ ; ones . Push ( arr [ i ] ) ; } else { c_2 ++ ; twos . Push ( arr [ i ] ) ; } } return ; } static void printArrangement ( int [ ] arr , Stack < int > ones , Stack < int > twos , Stack < int > zeros ) { if ( ( c_0 == 0 && c_1 != 0 && c_2 != 0 ) c_0 > c_1 + c_2 + 1 ) { Console . Write ( " - 1" ) ; return ; } int i ; if ( c_0 == 0 ) { for ( i = 0 ; i < arr . Length ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } return ; } int j ; int [ ] ans = new int [ N ] ; for ( i = 0 ; i < ans . Length ; i ++ ) ans [ i ] = - 1 ; for ( i = 1 , j = 0 ; j < c_1 ; i += 2 , j ++ ) { ans [ i ] = ones . Peek ( ) ; ones . Pop ( ) ; } ans [ i - 1 ] = zeros . Peek ( ) ; zeros . Pop ( ) ; c_0 -- ; for ( j = 0 ; j < c_2 ; j ++ , i += 2 ) { ans [ i ] = twos . Peek ( ) ; twos . Pop ( ) ; } for ( int k = 0 ; c_0 > 0 ; k += 2 ) { if ( ans [ k ] == - 1 ) { ans [ k ] = zeros . Peek ( ) ; c_0 -- ; } } for ( int i1 = 0 ; i1 < N ; i1 ++ ) { if ( ans [ i1 ] != - 1 ) Console . Write ( ans [ i1 ] + " ▁ " ) ; } return ; } static void solve ( int n , int [ ] arr ) { Stack < int > ones = new Stack < int > ( ) ; Stack < int > zeros = new Stack < int > ( ) ; Stack < int > twos = new Stack < int > ( ) ; c_0 = 0 ; c_1 = 0 ; c_2 = 0 ; count_k ( arr , ones , twos , zeros ) ; printArrangement ( arr , ones , twos , zeros ) ; } public static void Main ( String [ ] args ) { int n = 5 ; int [ ] arr = { 1 , 2 , 3 , 4 , 5 } ; solve ( n , arr ) ; } }

Index/key variables: N, i, i1, k
Accumulator variables: c_0, c_1, c_2, i, i1, j, k
Iterator variables: i, i1, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { public static void countUniqueDigits ( int N ) { int res = 0 ; int [ ] cnt = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ; while ( N > 0 ) { int rem = N % 10 ; cnt [ rem ] ++ ; N = N / 10 ; } for ( int i = 0 ; i < cnt . Length ; i ++ ) { if ( cnt [ i ] == 1 ) { res ++ ; } } Console . WriteLine ( res ) ; } public static void Main ( String [ ] args ) { int N = 2234262 ; countUniqueDigits ( N ) ; } }

Index/key variables: i, rem
Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool checkUniqueFrequency ( int [ ] arr , int n ) { Dictionary < int , int > freq = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( freq . ContainsKey ( arr [ i ] ) ) { freq [ arr [ i ] ] = freq [ arr [ i ] ] + 1 ; } else { freq . Add ( arr [ i ] , 1 ) ; } } HashSet < int > uniqueFreq = new HashSet < int > ( ) ; foreach ( KeyValuePair < int , int > i in freq ) { if ( uniqueFreq . Contains ( i . Value ) ) return false ; else uniqueFreq . Add ( i . Value ) ; } return true ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 1 , 2 , 5 , 5 } ; int n = arr . Length ; bool res = checkUniqueFrequency ( arr , n ) ; if ( res ) Console . Write ( " Yes " + " STRNEWLINE " ) ; else Console . Write ( " No " + " STRNEWLINE " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static double power ( int N , int P ) { return Math . Pow ( N , P ) ; } public static int log2 ( int N ) { int result = ( int ) ( Math . Log ( N ) / Math . Log ( 2 ) ) ; return result ; } static double specialSum ( int n ) { double sum = ( double ) ( n ) * ( n + 1 ) / 2 ; int a = log2 ( n ) ; sum = ( sum ) + power ( 2 , a + 1 ) - 1 ; return sum ; } public static void Main ( string [ ] args ) { int n = 4 ; Console . Write ( specialSum ( n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static void Permute ( List < int > arr , int n ) { int odd = 0 , four = 0 ; int non_four = 0 ; List < int > ODD = new List < int > ( ) ; List < int > FOUR = new List < int > ( n ) ; List < int > NON_FOUR = new List < int > ( n ) ; foreach ( int x in arr ) { if ( x % 2 != 0 ) { odd ++ ; ODD . Add ( x ) ; } else if ( x % 4 == 0 ) { four ++ ; FOUR . Add ( x ) ; } else { non_four ++ ; NON_FOUR . Add ( x ) ; } } if ( non_four == 0 && four >= odd - 1 ) { int x = ODD . Count ; int y = FOUR . Count ; int i ; for ( i = 0 ; i < x ; i ++ ) { Console . Write ( ODD [ i ] + " ▁ " ) ; if ( i < y ) Console . Write ( FOUR [ i ] + " ▁ " ) ; } while ( i < y ) Console . Write ( FOUR [ i ] + " ▁ " ) ; Console . WriteLine ( ) ; } else if ( non_four > 0 && four >= odd ) { int x = ODD . Count ; int y = FOUR . Count ; int i ; for ( i = 0 ; i < x ; i ++ ) { Console . Write ( ODD [ i ] + " ▁ " ) ; if ( i < y ) Console . Write ( FOUR [ i ] + " ▁ " ) ; } while ( i < y ) Console . Write ( FOUR [ i ] + " ▁ " ) ; for ( int j = 0 ; j < ( int ) NON_FOUR . Count ; j ++ ) Console . Write ( NON_FOUR [ j ] + " ▁ " ) ; Console . WriteLine ( ) ; } else Console . WriteLine ( " Not ▁ Possible " ) ; } public static void Main ( String [ ] args ) { List < int > arr = new List < int > ( ) ; arr . Add ( 2 ) ; arr . Add ( 7 ) ; arr . Add ( 1 ) ; arr . Add ( 8 ) ; arr . Add ( 2 ) ; arr . Add ( 8 ) ; Permute ( arr , arr . Count ) ; } }

Index/key variables: i, j
Accumulator variables: four, i, j, non_four, odd
Iterator variables: i, j, x
Class/struct names: GFG
C# program:
using System ; class GFG { static void findArray ( int sum , int xorr ) { if ( xorr > sum sum % 2 != xorr % 2 ) { Console . WriteLine ( " No ▁ Array ▁ Possible " ) ; return ; } if ( sum == xorr ) { if ( sum == 0 ) Console . WriteLine ( " Array ▁ is ▁ empty ▁ " + " with ▁ size ▁ 0" ) ; else Console . WriteLine ( " Array ▁ size ▁ is ▁ " + 1 ) ; Console . WriteLine ( " Array ▁ is ▁ " + sum ) ; return ; } int mid = ( sum - xorr ) / 2 ; if ( xorr == 1 && mid == 1 ) { Console . WriteLine ( " Array ▁ size ▁ is ▁ " + 3 ) ; Console . WriteLine ( " Array ▁ is ▁ " + xorr + " ▁ " + mid + " ▁ " + mid ) ; } else { Console . WriteLine ( " Array ▁ size ▁ is ▁ " + 2 ) ; Console . WriteLine ( " Array ▁ is ▁ " + ( xorr + mid ) + " ▁ " + mid ) ; } } public static void Main ( ) { int sum = 4 , xorr = 2 ; findArray ( sum , xorr ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static String Kperiodicinteger ( char [ ] X , int N , int K ) { String temp = String . Join ( " " , X ) ; for ( int i = 0 ; i < K ; i ++ ) { int j = i ; while ( j < N ) { X [ j ] = X [ i ] ; j += K ; } } if ( String . Join ( " " , X ) . CompareTo ( temp ) >= 0 ) { return String . Join ( " " , X ) ; } int POS = 0 ; for ( int i = K - 1 ; i >= 0 ; i -- ) { if ( X [ i ] != '9' ) { X [ i ] ++ ; POS = i ; break ; } } for ( int i = POS + 1 ; i < K ; i ++ ) { X [ i ] = '0' ; } for ( int i = 0 ; i < K ; i ++ ) { int j = i ; while ( j < N ) { X [ j ] = X [ i ] ; j += K ; } } return String . Join ( " " , X ) ; } public static void Main ( String [ ] args ) { int N = 4 , K = 2 ; String X = "1215" ; Console . Write ( Kperiodicinteger ( X . ToCharArray ( ) , N , K ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int N = 100000 ; static int canTake ; static int best ; static int [ ] dp = new int [ N ] ; static bool [ ] vis = new bool [ N ] ; static bool dfs ( List < int > [ ] g , int [ ] cost , int u , int pre ) { vis [ u ] = true ; dp [ u ] = cost [ u ] ; bool check = true ; int cur = cost [ u ] ; foreach ( int x in g [ u ] ) { if ( vis [ x ] && x != pre ) { check = false ; } else if ( ! vis [ x ] ) { check = dfs ( g , cost , x , u ) ? false : true ; cur = Math . Max ( cur , cost [ u ] + dp [ x ] ) ; } } dp [ u ] = cur ; if ( ! check ) { canTake += cost [ u ] ; } else { best = Math . Max ( best , dp [ u ] ) ; } return check ; } static void FindMaxCost ( List < int > [ ] g , int [ ] cost , int source ) { dfs ( g , cost , source , - 1 ) ; Console . Write ( canTake + best ) ; } public static void Main ( String [ ] args ) { int n = 5 , m = 5 ; int [ ] cost = { 2 , 2 , 8 , 6 , 9 } ; List < int > [ ] g = new List < int > [ n ] ; for ( int i = 0 ; i < g . Length ; i ++ ) g [ i ] = new List < int > ( ) ; g [ 0 ] . Add ( 1 ) ; g [ 1 ] . Add ( 0 ) ; g [ 0 ] . Add ( 2 ) ; g [ 2 ] . Add ( 0 ) ; g [ 0 ] . Add ( 3 ) ; g [ 3 ] . Add ( 0 ) ; g [ 1 ] . Add ( 2 ) ; g [ 2 ] . Add ( 1 ) ; g [ 1 ] . Add ( 4 ) ; g [ 4 ] . Add ( 1 ) ; int source = 1 ; FindMaxCost ( g , cost , source ) ; } }

Index/key variables: N, i, n, u, x
Accumulator variables: canTake, i
Iterator variables: i, x
Boolean variables: check
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static readonly int N = 5 ; static int after_rev ( List < int > v ) { int mini = 0 , count = 0 ; for ( int i = 0 ; i < v . Count ; i ++ ) { count += v [ i ] ; if ( count > 0 ) count = 0 ; if ( mini > count ) mini = count ; } return mini ; } static void print ( int [ ] arr ) { int sum = 0 ; for ( int i = 0 ; i < N ; i += 2 ) sum += arr [ i ] ; List < int > v1 , v2 ; v1 = new List < int > ( ) ; v2 = new List < int > ( ) ; for ( int i = 0 ; i + 1 < N ; i += 2 ) v1 . Add ( arr [ i + 1 ] - arr [ i ] ) ; for ( int i = 1 ; i + 1 < N ; i += 2 ) v2 . Add ( arr [ i ] - arr [ i + 1 ] ) ; int change = Math . Min ( after_rev ( v1 ) , after_rev ( v2 ) ) ; if ( change < 0 ) sum += change ; Console . Write ( sum + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 0 , 1 , 4 , 3 , 0 } ; print ( arr ) ; } }

Index/key variables: i
Accumulator variables: count, i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int moduloEquality ( int [ ] A , int [ ] B , int n , int m ) { Dictionary < int , int > mapA = new Dictionary < int , int > ( ) ; Dictionary < int , int > mapB = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( mapA . ContainsKey ( A [ i ] ) ) { mapA [ A [ i ] ] = mapA [ A [ i ] ] + 1 ; } else { mapA . Add ( A [ i ] , 1 ) ; } if ( mapB . ContainsKey ( B [ i ] ) ) { mapB [ B [ i ] ] = mapB [ B [ i ] ] + 1 ; } else { mapB . Add ( B [ i ] , 1 ) ; } } HashSet < int > possibleValues = new HashSet < int > ( ) ; int FirstElement = B [ 0 ] ; for ( int i = 0 ; i < n ; i ++ ) { int cur = A [ i ] ; possibleValues . Add ( cur > FirstElement ? m - cur + FirstElement : FirstElement - cur ) ; } int ans = Int32 . MaxValue ; foreach ( int it in possibleValues ) { bool possible = true ; foreach ( KeyValuePair < int , int > it2 in mapA ) { if ( it2 . Value != mapB [ ( it2 . Key + it ) % m ] ) { possible = false ; break ; } } if ( possible ) { ans = Math . Min ( ans , it ) ; } } return ans ; } static void Main ( ) { int n = 4 ; int m = 3 ; int [ ] A = { 0 , 0 , 2 , 1 } ; int [ ] B = { 2 , 0 , 1 , 1 } ; Console . WriteLine ( moduloEquality ( A , B , n , m ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i, it, it2
Boolean variables: possible
Class/struct names: GFG
C# program:
using System ; class GFG { static int countCyclicShifts ( string S , int n ) { int [ ] aux = new int [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { if ( S [ i ] == ' ( ' ) aux [ i ] = 1 ; else aux [ i ] = - 1 ; } int mn = aux [ 0 ] ; for ( int i = 1 ; i < n ; ++ i ) { aux [ i ] += aux [ i - 1 ] ; mn = Math . Min ( mn , aux [ i ] ) ; } if ( aux [ n - 1 ] != 0 ) return 0 ; int count = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( aux [ i ] == mn ) count ++ ; } return count ; } public static void Main ( string [ ] args ) { string S = " ) ( ) ( " ; int N = S . Length ; Console . Write ( countCyclicShifts ( S , N ) ) ; } }

Index/key variables: i, n
Accumulator variables: count
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxProfit ( int [ ] prices , int n ) { int profit = 0 , currentDay = n - 1 ; while ( currentDay > 0 ) { int day = currentDay - 1 ; while ( day >= 0 && ( prices [ currentDay ] > prices [ day ] ) ) { profit += ( prices [ currentDay ] - prices [ day ] ) ; day -- ; } currentDay = day ; } return profit ; } public static void Main ( String [ ] args ) { int [ ] prices = { 2 , 3 , 5 } ; int N = prices . Length ; Console . Write ( maxProfit ( prices , N ) ) ; } }

Index/key variables: currentDay, day
Accumulator variables: day, profit
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool isOddStringPalindrome ( String str , int n ) { int oddStringSize = n / 2 ; bool lengthOdd = ( ( oddStringSize % 2 == 1 ) ? true : false ) ; Stack < char > s = new Stack < char > ( ) ; int i = 1 ; int c = 0 ; while ( i < n && c < oddStringSize / 2 ) { s . Push ( str [ i ] ) ; i += 2 ; c ++ ; } if ( lengthOdd ) i = i + 2 ; while ( i < n && s . Count > 0 ) { if ( s . Peek ( ) == str [ i ] ) s . Pop ( ) ; else break ; i = i + 2 ; } if ( s . Count == 0 ) return true ; return false ; } 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: i
Accumulator variables: c, i
Class/struct names: GFG