dhyuti-n/xlcost-variable-roles huggingface dataset:
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 solve ( int [ ] health , int n ) { int currentgcd = gcd ( health [ 0 ] , health [ 1 ] ) ; for ( int i = 2 ; i < n ; ++ i ) { currentgcd = gcd ( currentgcd , health [ i ] ) ; } return currentgcd ; } public static void Main ( String [ ] args ) { int [ ] health = { 4 , 6 , 8 , 12 } ; int n = health . Length ; Console . WriteLine ( solve ( health , n ) ) ; } }

Index/key variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { static void Find_Sequence ( int [ ] arr , int n ) { ArrayList inc_arr = new ArrayList ( ) ; ArrayList dec_arr = new ArrayList ( ) ; int flag = 0 ; long inc = - 1 , dec = ( long ) 1e7 ; for ( int i = 0 ; i < n ; i ++ ) { if ( inc < arr [ i ] && arr [ i ] < dec ) { if ( arr [ i ] < arr [ i + 1 ] ) { inc = arr [ i ] ; inc_arr . Add ( arr [ i ] ) ; } else { dec = arr [ i ] ; dec_arr . Add ( arr [ i ] ) ; } } else if ( inc < arr [ i ] ) { inc = arr [ i ] ; inc_arr . Add ( arr [ i ] ) ; } else if ( dec > arr [ i ] ) { dec = arr [ i ] ; dec_arr . Add ( arr [ i ] ) ; } else { Console . Write ( - 1 ) ; flag = 1 ; break ; } } if ( flag == 0 ) { foreach ( int i in inc_arr ) Console . Write ( i + " ▁ " ) ; Console . Write ( ' STRNEWLINE ' ) ; foreach ( int i in dec_arr ) Console . Write ( i + " ▁ " ) ; Console . Write ( ' STRNEWLINE ' ) ; } } public static void Main ( string [ ] args ) { int [ ] arr = { 5 , 1 , 3 , 6 , 8 , 2 , 9 , 0 , 10 } ; int n = arr . Length ; Find_Sequence ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int reverse ( int n ) { int rev = 0 ; while ( n != 0 ) { rev = ( rev * 10 ) + ( n % 10 ) ; n /= 10 ; } return rev ; } static void getSum ( int n ) { n = reverse ( n ) ; int sumOdd = 0 , sumEven = 0 , c = 1 ; while ( n != 0 ) { if ( c % 2 == 0 ) sumEven += n % 10 ; else sumOdd += n % 10 ; n /= 10 ; c ++ ; } Console . WriteLine ( " Sum ▁ odd ▁ = ▁ " + sumOdd ) ; Console . WriteLine ( " Sum ▁ even ▁ = ▁ " + sumEven ) ; } public static void Main ( ) { int n = 457892 ; getSum ( n ) ; } }

Accumulator variables: c, n, sumEven, sumOdd
Class/struct names: GFG
C# program:
using System ; class GFG { static void getSum ( int n ) { bool isOdd = ( n % 2 == 1 ) ? true : false ; int sumOdd = 0 , sumEven = 0 ; while ( n != 0 ) { if ( isOdd ) sumOdd += n % 10 ; else sumEven += n % 10 ; isOdd = ! isOdd ; n /= 10 ; } Console . WriteLine ( " Sum ▁ odd ▁ = ▁ " + sumOdd ) ; Console . Write ( " Sum ▁ even ▁ = ▁ " + sumEven ) ; } static public void Main ( ) { int n = 457892 ; getSum ( n ) ; } }

Accumulator variables: n, sumEven, sumOdd
Class/struct names: GFG
C# program:
using System ; class GFG { static int bankNotes ( int A , int B , int S , int N ) { int numerator = S - ( B * N ) ; int denominator = A - B ; if ( numerator % denominator == 0 ) return ( numerator / denominator ) ; return - 1 ; } public static void Main ( ) { int A = 1 , B = 2 , S = 7 , N = 5 ; Console . Write ( bankNotes ( A , B , S , N ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GfG { static void twoParts ( string str ) { int flag = 0 ; string a = " " ; char [ ] gfg = str . ToCharArray ( ) ; for ( int i = 0 ; i < str . Length ; i ++ ) { if ( gfg [ i ] == '4' ) { gfg [ i ] = '3' ; a += '1' ; flag = 1 ; } else if ( flag != 0 ) a += '0' ; } str = new String ( gfg ) ; Console . WriteLine ( str + " ▁ " + a ) ; } static void Main ( ) { string str = "9441" ; twoParts ( str ) ; } }

Index/key variables: i
Accumulator variables: a, i
Iterator variables: i
Class/struct names: GfG
C# program:
using System ; class GfG { static int longestSubstring ( string s ) { int cnt = 1 , maxi = 1 ; int n = s . Length ; for ( int i = 1 ; i < n ; i ++ ) { if ( s [ i ] != s [ i - 1 ] ) cnt ++ ; else { maxi = Math . Max ( cnt , maxi ) ; cnt = 1 ; } } maxi = Math . Max ( cnt , maxi ) ; return maxi ; } static void Main ( ) { string s = " ccccdeededff " ; Console . WriteLine ( longestSubstring ( s ) ) ; } }

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GfG
C# program:
using System ; class GFG { static int Minimum_Operations ( int [ ] a , int n ) { int [ ] np = new int [ n + 1 ] ; np [ n ] = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { np [ i ] = np [ i + 1 ] ; if ( a [ i ] <= 0 ) np [ i ] ++ ; } int pos = 0 ; int ans = n ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( a [ i ] >= 0 ) pos ++ ; ans = Math . Min ( ans , pos + np [ i + 1 ] ) ; } return ans ; } static void Main ( ) { int [ ] a = { - 1 , 0 , 1 , 2 } ; int n = a . Length ; Console . WriteLine ( Minimum_Operations ( a , n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i, pos
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findSumofEle ( int [ ] arr1 , int m , int [ ] arr2 , int n , int k ) { float arraySum = 0 ; for ( int i = 0 ; i < n ; i ++ ) arraySum += arr2 [ i ] ; float mean = arraySum / n ; int sumOfElements = 0 ; float difference = 0 ; for ( int i = 0 ; i < m ; i ++ ) { difference = arr1 [ i ] - mean ; if ( ( difference < 0 ) && ( k > ( - 1 ) * difference ) ) { sumOfElements += arr1 [ i ] ; } if ( ( difference >= 0 ) && ( k > difference ) ) { sumOfElements += arr1 [ i ] ; } } return sumOfElements ; } static void Main ( ) { int [ ] arr1 = { 1 , 2 , 3 , 4 , 7 , 9 } ; int [ ] arr2 = { 0 , 1 , 2 , 1 , 1 , 4 } ; int k = 2 ; int m = arr1 . Length ; int n = arr2 . Length ; Console . WriteLine ( findSumofEle ( arr1 , m , arr2 , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: arraySum, i, sumOfElements
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static void findIntegers ( int n , int x , int y ) { ArrayList ans = new ArrayList ( ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) ans . Add ( 1 ) ; if ( y - ( n - 1 ) <= 0 ) { Console . Write ( " - 1" ) ; return ; } ans . Add ( y - ( n - 1 ) ) ; int store = 0 ; for ( int i = 0 ; i < n ; i ++ ) store += ( int ) ans [ i ] * ( int ) ans [ i ] ; if ( store < x ) { Console . Write ( " - 1" ) ; return ; } for ( int i = 0 ; i < n ; i ++ ) Console . Write ( ( int ) ans [ i ] + " ▁ " ) ; } static void Main ( ) { int n = 3 , x = 254 , y = 18 ; findIntegers ( n , x , y ) ; } }

Index/key variables: i
Accumulator variables: i, store
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int Minsteps ( int n , int m ) { int ans = 0 ; while ( m > n ) { if ( m % 2 != 0 ) { m ++ ; ans ++ ; } m /= 2 ; ans ++ ; } return ans + n - m ; } public static void Main ( ) { int n = 4 , m = 6 ; Console . WriteLine ( Minsteps ( n , m ) ) ; } }

Accumulator variables: ans, m
Class/struct names: GFG
C# program:
using System ; class GFG { static int getsum ( int x ) { return ( x * ( x + 1 ) ) / 2 ; } static int countJumps ( int n ) { n = Math . Abs ( n ) ; int ans = 0 ; while ( getsum ( ans ) < n || ( ( getsum ( ans ) - n ) & 1 ) > 0 ) ans ++ ; return ans ; } static void Main ( ) { int n = 9 ; Console . WriteLine ( countJumps ( n ) ) ; } }

Accumulator variables: ans
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxCandies ( int [ ] arr , int n ) { int prevBought = arr [ n - 1 ] ; int candies = prevBought ; for ( int i = n - 2 ; i >= 0 ; i -- ) { int x = Math . Min ( prevBought - 1 , arr [ i ] ) ; if ( x >= 0 ) { candies += x ; prevBought = x ; } } return candies ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 1 , 3 , 6 } ; int n = arr . Length ; Console . WriteLine ( maxCandies ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: candies, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void printArray ( int N , int [ ] arr ) { for ( int i = 0 ; i < N ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; Console . WriteLine ( ) ; } static void replacedArray ( int N , int [ ] arr ) { int pos_sum , neg_sum , i , j , diff ; for ( i = 0 ; i < N ; i ++ ) { pos_sum = 0 ; neg_sum = 0 ; for ( j = i + 1 ; j < N ; j ++ ) { if ( arr [ j ] > 0 ) pos_sum += arr [ j ] ; else neg_sum += arr [ j ] ; } diff = Math . Abs ( pos_sum ) - Math . Abs ( neg_sum ) ; arr [ i ] = Math . Abs ( diff ) ; } } static void Main ( ) { int N = 5 ; int [ ] arr = { 1 , - 1 , 2 , 3 , - 2 } ; replacedArray ( N , arr ) ; printArray ( N , arr ) ; N = 6 ; int [ ] arr1 = { - 3 , - 4 , - 2 , 5 , 1 , - 2 } ; replacedArray ( N , arr1 ) ; printArray ( N , arr1 ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, neg_sum, pos_sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Linq ; class GFG { static bool isPalindrome ( string s ) { for ( int i = 0 ; i < s . Length ; ++ i ) { if ( s [ i ] != s [ s . Length - i - 1 ] ) { return false ; } } return true ; } static bool ans ( string s ) { string s2 = s ; for ( int i = 0 ; i < s . Length ; ++ i ) { s2 = s2 [ s2 . Length - 1 ] + s2 ; s2 = s2 . Substring ( 0 , s2 . Length - 1 ) ; if ( ( s == null ? s2 != null : ! s . Equals ( s2 ) ) && isPalindrome ( s2 ) ) { return true ; } } return false ; } static int solve ( string s ) { if ( s . Length <= 3 ) { return - 1 ; } int [ ] cnt = new int [ 25 ] ; for ( int i = 0 ; i < s . Length ; i ++ ) { cnt [ s [ i ] - ' a ' ] ++ ; } if ( cnt . Max ( ) >= ( s . Length - 1 ) ) { return - 1 ; } else { return ( ans ( s ) ? 1 : 2 ) ; } } static void Main ( ) { string s = " nolon " ; Console . WriteLine ( solve ( s ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Linq ; class GFG { static int solveEven ( String s ) { if ( s . Length % 2 == 1 ) { return 2 ; } String ls = s . Substring ( 0 , s . Length / 2 ) ; String rs = s . Substring ( s . Length / 2 , s . Length ) ; if ( ls != rs ) { return 1 ; } return solveEven ( ls ) ; } static int solveOdd ( String s ) { return 2 ; } static int solve ( String s ) { if ( s . Length <= 3 ) { return - 1 ; } int [ ] cnt = new int [ 25 ] ; for ( int i = 0 ; i < s . Length ; i ++ ) { cnt [ s [ i ] - ' a ' ] ++ ; } if ( cnt . Max ( ) >= s . Length - 1 ) { return - 1 ; } if ( s . Length % 2 == 0 ) { return solveEven ( s ) ; } if ( s . Length % 2 == 1 ) { return solveOdd ( s ) ; } return int . MinValue ; } public static void Main ( ) { String s = " nolon " ; Console . WriteLine ( solve ( s ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minChanges ( char [ ] str , int n ) { int count = 0 , zeros = 0 , ones = 0 ; if ( str [ 0 ] != '1' ) { count ++ ; ones ++ ; } for ( int i = 1 ; i < n ; i ++ ) { if ( str [ i ] == '0' ) zeros ++ ; else ones ++ ; if ( zeros > ones ) { zeros -- ; ones ++ ; count ++ ; } } return count ; } public static void Main ( String [ ] args ) { char [ ] str = "0000" . ToCharArray ( ) ; int n = str . Length ; Console . Write ( minChanges ( str , n ) ) ; } }

Index/key variables: i
Accumulator variables: count, i, ones, zeros
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int steps ( int cur , int x , int n ) { if ( x == 0 ) return int . MaxValue ; if ( x > 0 ) return Math . Abs ( ( n - cur ) / x ) ; else return Math . Abs ( ( cur - 1 ) / x ) ; } static int countSteps ( int curx , int cury , int n , int m , int [ , ] moves ) { int count = 0 ; int k = moves . GetLength ( 0 ) ; for ( int i = 0 ; i < k ; i ++ ) { int x = moves [ i , 0 ] ; int y = moves [ i , 1 ] ; int stepct = Math . Min ( steps ( curx , x , n ) , steps ( cury , y , m ) ) ; count += stepct ; curx += stepct * x ; cury += stepct * y ; } return count ; } public static void Main ( String [ ] args ) { int n = 4 , m = 5 , x = 1 , y = 1 ; int [ , ] moves = { { 1 , 1 } , { 1 , 1 } , { 0 , - 2 } } ; Console . Write ( countSteps ( x , y , n , m , moves ) ) ; } }

Accumulator variables: count, curx, cury, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System . Linq ; using System ; class GFG { static int minimumRemoval ( int n , int [ ] a ) { int [ ] c = new int [ 1000 ] ; for ( int i = 0 ; i < n ; i ++ ) c [ a [ i ] ] ++ ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { bool ok = true ; for ( int j = 0 ; j < 31 ; j ++ ) { int x = ( 1 << j ) - a [ i ] ; if ( c . Contains ( x ) && ( c [ x ] > 1 || ( c [ x ] == 1 && x != a [ i ] ) ) ) { ok = false ; break ; } } if ( ! ok ) ans ++ ; } return ans ; } static void Main ( ) { int [ ] a = { 4 , 7 , 1 , 5 , 4 , 9 } ; int n = a . Length ; Console . WriteLine ( minimumRemoval ( n , a ) ) ; } }

Index/key variables: i, x
Accumulator variables: ans, i, j
Iterator variables: i, j
Boolean variables: ok
Class/struct names: GFG
C# program:
using System ; class GFG { static int min_elimination ( int n , int [ ] arr ) { int count = 0 ; int prev_val = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { int curr_val = arr [ i ] ; if ( curr_val % 2 == prev_val % 2 ) count ++ ; prev_val = curr_val ; } return count ; } public static void Main ( ) { int [ ] arr = new int [ ] { 1 , 2 , 3 , 7 , 9 } ; int n = arr . Length ; Console . WriteLine ( min_elimination ( n , arr ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static string getCount ( int N ) { if ( N % 2 == 1 ) return "0" ; string result = "9" ; for ( int i = 1 ; i <= N / 2 - 1 ; i ++ ) result += "0" ; return result ; } public static void Main ( ) { int N = 4 ; Console . WriteLine ( getCount ( N ) ) ; } }

Accumulator variables: i, result
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool canFormTeam ( int n , int m ) { if ( n >= 1 && m >= 2 ) return true ; if ( m >= 1 && n >= 2 ) return true ; return false ; } static int maxTeams ( int n , int m ) { int count = 0 ; while ( canFormTeam ( n , m ) ) { if ( n > m ) { n -= 2 ; m -= 1 ; } else { m -= 2 ; n -= 1 ; } count ++ ; } return count ; } public static void Main ( ) { int n = 4 , m = 5 ; Console . WriteLine ( maxTeams ( n , m ) ) ; } }

Accumulator variables: count, m, n
Class/struct names: GFG
C# program:
using System ; class GFG { static long max ( long a , long b ) { if ( a > b ) return a ; else return b ; } static long smallestSide ( long [ ] a ) { Array . Sort ( a ) ; long side1 , side2 , side3 , side4 , side11 , side12 , sideOfSquare ; side1 = a [ 0 ] + a [ 3 ] ; side2 = a [ 1 ] + a [ 2 ] ; side3 = a [ 0 ] + a [ 1 ] ; side4 = a [ 2 ] + a [ 3 ] ; side11 = max ( side1 , side2 ) ; side12 = max ( side3 , side4 ) ; sideOfSquare = max ( side11 , side12 ) ; return sideOfSquare ; } public static void Main ( String [ ] args ) { long [ ] side = new long [ 4 ] ; Console . WriteLine ( " Test ▁ Case ▁ 1" ) ; side [ 0 ] = 2 ; side [ 1 ] = 2 ; side [ 2 ] = 2 ; side [ 3 ] = 2 ; Console . WriteLine ( smallestSide ( side ) ) ; Console . WriteLine ( " STRNEWLINE Test ▁ Case ▁ 2" ) ; side [ 0 ] = 100000000000000L ; side [ 1 ] = 123450000000000L ; side [ 2 ] = 987650000000000L ; side [ 3 ] = 987654321000000L ; Console . WriteLine ( smallestSide ( side ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void find_rectangle ( int area ) { int l = 0 , b = 0 ; int M = ( int ) Math . Sqrt ( area ) ; for ( int i = M ; i >= 1 ; i -- ) { if ( area % i == 0 ) { l = ( area / i ) ; b = i ; break ; } } Console . WriteLine ( " l ▁ = ▁ " + l + " , ▁ b ▁ = ▁ " + b ) ; } public static void Main ( ) { int area = 99 ; find_rectangle ( area ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void find_rectangle ( int area ) { for ( int i = ( int ) Math . Ceiling ( Math . Sqrt ( area ) ) ; i <= area ; i ++ ) { if ( area / i * i == area ) { Console . WriteLine ( i + " ▁ " + ( int ) ( area / i ) ) ; return ; } } } static void Main ( ) { int area = 99 ; find_rectangle ( area ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int sizeSubSet ( int [ ] a , int k , int n ) { Array . Sort ( a ) ; Dictionary < int , int > s = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] % k != 0 || ! s . ContainsKey ( a [ i ] / k ) ) { if ( s . ContainsKey ( a [ i ] ) ) { var val = s [ a [ i ] ] ; s . Remove ( a [ i ] ) ; s . Add ( a [ i ] , val + 1 ) ; } else { s . Add ( a [ i ] , 1 ) ; } } } return s . Count ; } public static void Main ( String [ ] args ) { int [ ] a = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 } ; int n = a . Length ; int k = 2 ; Console . WriteLine ( sizeSubSet ( a , k , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class solution { static int minimumSets ( string s , int y ) { int cnt = 0 ; int num = 0 ; int l = s . Length ; bool f = false ; for ( int i = 0 ; i < l ; i ++ ) { num = num * 10 + ( s [ i ] - '0' ) ; if ( num <= y ) f = true ; { if ( f ) cnt += 1 ; num = s [ i ] - '0' ; f = false ; if ( num <= y ) f = true ; else num = 0 ; } } if ( f == true ) cnt += 1 ; return cnt ; } public static void Main ( ) { string s = "1234" ; int y = 30 ; Console . WriteLine ( minimumSets ( s , y ) ) ; } }

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Boolean variables: f
Class/struct names: solution
C# program:
using System ; public class GFG { static void printArr ( int [ ] b , int n ) { for ( int i = 0 ; i < n ; i ++ ) { Console . Write ( " ▁ " + b [ i ] + " ▁ " ) ; } } static void ModifiedArray ( int [ ] a , int n ) { int l = 0 , r = int . MaxValue ; int [ ] b = new int [ n ] ; for ( int i = 0 ; i < n / 2 ; i ++ ) { b [ i ] = Math . Max ( l , a [ i ] - r ) ; b [ n - i - 1 ] = a [ i ] - b [ i ] ; l = b [ i ] ; r = b [ n - i - 1 ] ; } printArr ( b , n ) ; } static public void Main ( ) { int [ ] a = { 5 , 6 } ; int n = a . Length ; ModifiedArray ( a , 2 * n ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ ] numberOfLines ( String S , int [ ] widths ) { if ( S . Length == 0 ) return new int [ ] { 0 , 0 } ; int lines = 1 , width = 0 ; foreach ( char character in S . ToCharArray ( ) ) { int w = widths [ character - ' a ' ] ; width += w ; if ( width >= 10 ) { lines ++ ; width = w ; } } return new int [ ] { lines , width } ; } public static void Main ( String [ ] args ) { String S = " bbbcccdddaa " ; int [ ] widths = { 4 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 } ; int [ ] ans = numberOfLines ( S , widths ) ; Console . Write ( ans [ 0 ] + " ▁ " + ans [ 1 ] + " STRNEWLINE " ) ; } }

Accumulator variables: lines, width
Iterator variables: character
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static String canReorder ( int [ ] A , int n ) { Dictionary < int , int > m = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( m . ContainsKey ( A [ i ] ) ) m [ A [ i ] ] = m [ A [ i ] ] + 1 ; else m . Add ( A [ i ] , 1 ) ; } Array . Sort ( A ) ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( m [ A [ i ] ] == 0 ) continue ; if ( m . ContainsKey ( 2 * A [ i ] ) ) { count += 2 ; m [ A [ i ] ] = m [ A [ i ] ] - 1 ; if ( m . ContainsKey ( 2 * A [ i ] ) ) m [ 2 * A [ i ] ] = m [ 2 * A [ i ] ] - 1 ; else m . Add ( 2 * A [ i ] , m [ 2 * A [ i ] ] - 1 ) ; } } if ( count == n ) return " True " ; else return " False " ; } public static void Main ( String [ ] args ) { int [ ] A = { 4 , - 2 , 2 , - 4 } ; int n = A . Length ; Console . WriteLine ( canReorder ( A , n ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxSubArraySum ( int [ ] a , int size ) { int max_so_far = int . MinValue , max_ending_here = 0 ; for ( int i = 0 ; i < size ; i ++ ) { max_ending_here = max_ending_here + a [ i ] ; if ( max_so_far < max_ending_here ) max_so_far = max_ending_here ; if ( max_ending_here < 0 ) max_ending_here = 0 ; } return max_so_far ; } static int maxSum ( int [ ] a , int n ) { int S = 0 ; int S1 = maxSubArraySum ( a , n ) ; for ( int i = 0 ; i < n ; i ++ ) S += a [ i ] ; return ( 2 * S1 - S ) ; } public static void Main ( ) { int [ ] a = { - 35 , 32 , - 24 , 0 , 27 , - 10 , 0 , - 19 } ; int n = a . Length ; Console . WriteLine ( maxSum ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: S, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Linq ; class GFG { static int minimizeDiff ( int [ ] arr , int n , int k ) { int max = arr . Max ( ) ; int min = arr . Min ( ) ; if ( ( max - min ) <= k ) { return ( max - min ) ; } int avg = ( max + min ) / 2 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > avg ) { arr [ i ] -= k ; } else { arr [ i ] += k ; } } max = arr . Max ( ) ; min = arr . Min ( ) ; return ( max - min ) ; } public static void Main ( ) { int [ ] arr = { 3 , 16 , 12 , 9 , 20 } ; int n = 5 ; int k = 3 ; Console . WriteLine ( " Max ▁ height ▁ difference ▁ = ▁ " + minimizeDiff ( arr , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void maxLitres ( int budget , int plastic , int glass , int refund ) { if ( glass - refund < plastic ) { int ans = Math . Max ( ( budget - refund ) / ( glass - refund ) , 0 ) ; budget -= ans * ( glass - refund ) ; ans += budget / plastic ; Console . WriteLine ( ans ) ; } else { Console . WriteLine ( ( budget / plastic ) ) ; } } public static void Main ( String [ ] args ) { int budget = 10 , plastic = 11 , glass = 9 , refund = 8 ; maxLitres ( budget , plastic , glass , refund ) ; } }

Accumulator variables: ans, budget
Class/struct names: GFG
C# program:
using System ; class GFG { static int leastValue ( int P , int A , int N , int [ ] a ) { int ans = - 1 ; float tmp = float . MaxValue ; for ( int i = 0 ; i < N ; i ++ ) { float t = ( float ) ( P - a [ i ] * 0.006 ) ; if ( Math . Abs ( t - A ) < tmp ) { tmp = Math . Abs ( t - A ) ; ans = i ; } } return a [ ans ] ; } public static void Main ( String [ ] args ) { int N = 2 , P = 12 , A = 2005 ; int [ ] a = { 1000 , 2000 } ; Console . WriteLine ( leastValue ( P , A , N , a ) ) ; } }

Index/key variables: ans, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findPermutation ( int n ) { int len = ( int ) Math . Ceiling ( Math . Log10 ( n ) ) ; for ( int i = 0 ; i < len ; i ++ ) { if ( n % 2 != 0 ) { return n ; } else { n = ( n / 10 ) + ( n % 10 ) * ( int ) Math . Pow ( 10 , len - i - 1 ) ; continue ; } } return - 1 ; } public static void Main ( ) { int n = 132 ; Console . WriteLine ( findPermutation ( n ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG