dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int minLength ( string s ) { int i = 0 , j = s . Length - 1 ; for ( ; i < j && s [ i ] == s [ j ] ; ) { char d = s [ i ] ; while ( i <= j && s [ i ] == d ) i ++ ; while ( i <= j && s [ j ] == d ) j -- ; } return j - i + 1 ; } public static void Main ( string [ ] args ) { string S = " aacbcca " ; Console . WriteLine ( minLength ( S ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int mod = 1000000007 ; static long power ( long x , int y ) { long res = 1 ; x = x % mod ; if ( x == 0 ) return 0 ; while ( y > 0 ) { if ( ( y & 1 ) == 1 ) res = ( res * x ) % mod ; y = y >> 1 ; x = ( x * x ) % mod ; } return res ; } static long CountBST ( int H ) { return power ( 2 , H ) ; } static void Main ( ) { int H = 2 ; Console . Write ( CountBST ( H ) ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void rotateString ( int n , int m , string s ) { List < int > v = new List < int > ( ) ; int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == '1' ) { v . Add ( i ) ; } } for ( int i = 1 ; i < v . Count ; i ++ ) { if ( ( v [ i ] - v [ i - 1 ] - 1 ) > m ) { cnt ++ ; } } if ( v . Count >= 2 && ( n - ( v [ v . Count - 1 ] - v [ 0 ] ) - 1 ) > m ) { cnt ++ ; } if ( cnt <= 1 ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } public static void Main ( ) { string S = "101001" ; int M = 1 ; int N = S . Length ; rotateString ( N , M , S ) ; } }

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findNumber ( int N ) { int [ ] ans = { 1 , 2 , 4 , 8 , 7 , 5 } ; return ans [ N % 6 ] ; } public static void Main ( ) { int N = 6 ; Console . WriteLine ( findNumber ( N ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void canBeEmptied ( int A , int B ) { if ( Math . Max ( A , B ) > 2 * Math . Min ( A , B ) ) { Console . WriteLine ( " No " ) ; return ; } if ( ( A + B ) % 3 == 0 ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } public static void Main ( ) { int A = 1 , B = 2 ; canBeEmptied ( A , B ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void maximumIndex ( int N , int B ) { int i = 0 , j = 1 ; int cnt = 0 ; int sum = N * ( N + 1 ) / 2 ; bool flag = false ; while ( cnt < N ) { i += j ; j ++ ; cnt ++ ; if ( i == B ) { flag = true ; break ; } } if ( ! flag == true ) { Console . Write ( sum ) ; } else { Console . Write ( sum - 1 ) ; } } static public void Main ( ) { int N = 4 , B = 6 ; maximumIndex ( N , B ) ; } }

Accumulator variables: cnt, i, j
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; class GFG { static void minsteps ( int [ ] A ) { int n = A . Length ; int [ ] left = new int [ n ] ; for ( int i = 1 ; i < n ; i ++ ) { left [ i ] = 0 ; } int [ ] right = new int [ n ] ; for ( int i = 1 ; i < n ; i ++ ) { right [ i ] = 0 ; } int [ ] res = new int [ n ] ; for ( int i = 1 ; i < n ; i ++ ) { res [ i ] = 0 ; } int count = A [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { left [ i ] = left [ i - 1 ] + count ; count += A [ i ] ; } count = A [ n - 1 ] ; for ( int i = n - 2 ; i >= 0 ; i -- ) { right [ i ] = right [ i + 1 ] + count ; count += A [ i ] ; } for ( int i = 0 ; i < n ; i ++ ) { res [ i ] = left [ i ] + right [ i ] ; Console . Write ( res [ i ] + " ▁ " ) ; } Console . WriteLine ( ) ; } public static void Main ( String [ ] args ) { int [ ] A = { 1 , 0 , 1 , 0 } ; minsteps ( A ) ; } }

Index/key variables: i, n
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void minimumOperations ( List < int > A , int K ) { List < int > isflipped = new List < int > ( ) ; for ( int i = 0 ; i < A . Count + 1 ; i ++ ) isflipped . Add ( 0 ) ; int ans = 0 ; for ( int i = 0 ; i < A . Count ; i ++ ) { if ( i > 0 ) { isflipped [ i ] += isflipped [ i - 1 ] ; isflipped [ i ] %= 2 ; } if ( A [ i ] == 0 && isflipped [ i ] == 0 ) { if ( ( A . Count - i + 1 ) <= K ) { Console . Write ( - 1 ) ; return ; } ans += 1 ; isflipped [ i ] += 1 ; isflipped [ i + K ] -= 1 ; } else if ( A [ i ] == 1 && isflipped [ i ] != 0 ) { if ( ( A . Count - i + 1 ) <= K ) { Console . Write ( - 1 ) ; return ; } ans += 1 ; isflipped [ i ] += 1 ; isflipped [ i + K ] -= 1 ; } } Console . WriteLine ( ans ) ; } public static void Main ( ) { List < int > arr = new List < int > ( ) { 0 , 1 , 0 } ; int K = 1 ; minimumOperations ( arr , K ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void findScoreSum ( int n ) { int total = 0 ; int prev_monday = 0 , curr_day = 0 ; for ( int day = 1 ; day <= n ; day ++ ) { if ( day % 7 == 1 ) { prev_monday ++ ; curr_day = prev_monday ; } total += curr_day ++ ; } Console . Write ( total ) ; } public static void Main ( String [ ] args ) { int N = 8 ; findScoreSum ( N ) ; } }

Accumulator variables: curr_day, day, prev_monday, total
Iterator variables: day
Class/struct names: GFG
C# program:
using System ; class GFG { static void findScoreSum ( int n ) { int F = n / 7 ; int D = n % 7 ; int fullWeekScore = ( 49 + 7 * F ) * F / 2 ; int lastNonFullWeekScore = ( 2 * F + D + 1 ) * D / 2 ; Console . WriteLine ( fullWeekScore + lastNonFullWeekScore ) ; } static public void Main ( ) { int N = 8 ; findScoreSum ( N ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static long maximumNum ( long X , long Y , long N ) { long num = 0 ; if ( N - N % X + Y <= N ) { num = N - N % X + Y ; } else { num = N - N % X - ( X - Y ) ; } return num ; } public static void Main ( string [ ] args ) { long X = 10 ; long Y = 5 ; long N = 15 ; Console . WriteLine ( maximumNum ( X , Y , N ) ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static int getArea ( int x1 , int y1 , int x2 , int y2 , int x3 , int y3 ) { return Math . Abs ( ( x1 * ( y2 - y3 ) + x2 * ( y3 - y1 ) + x3 * ( y1 - y2 ) ) / 2 ) ; } static int isInside ( List < List < int > > triangle , List < int > point ) { List < int > A = triangle [ 0 ] ; List < int > B = triangle [ 1 ] ; List < int > C = triangle [ 2 ] ; int x = point [ 0 ] ; int y = point [ 1 ] ; int ABC = getArea ( A [ 0 ] , A [ 1 ] , B [ 0 ] , B [ 1 ] , C [ 0 ] , C [ 1 ] ) ; int BPC = getArea ( x , y , B [ 0 ] , B [ 1 ] , C [ 0 ] , C [ 1 ] ) ; int APC = getArea ( A [ 0 ] , A [ 1 ] , x , y , C [ 0 ] , C [ 1 ] ) ; int APB = getArea ( A [ 0 ] , A [ 1 ] , B [ 0 ] , B [ 1 ] , x , y ) ; return ABC == ( APC + APB + BPC ) ? 1 : 0 ; } static void countPoints ( List < List < int > > rectangle , List < List < int > > triangle , List < List < int > > points ) { int n = rectangle . Count ; List < List < int > > triangle1 = new List < List < int > > ( ) ; for ( int i = 1 ; i < n ; i ++ ) triangle1 . Add ( rectangle [ i ] ) ; List < List < int > > triangle2 = new List < List < int > > ( ) ; for ( int i = 0 ; i < 3 ; i ++ ) { triangle2 . Add ( rectangle [ i ] ) ; } List < List < int > > triangle3 = new List < List < int > > ( ) ; for ( int i = 0 ; i < 2 ; i ++ ) { triangle3 . Add ( rectangle [ i ] ) ; } triangle3 . Add ( rectangle [ 3 ] ) ; List < List < int > > triangle4 = new List < List < int > > ( ) ; for ( int i = n - 2 ; i < n ; i ++ ) { triangle4 . Add ( rectangle [ i ] ) ; } triangle4 . Add ( rectangle [ 0 ] ) ; int ans = 0 ; foreach ( List < int > point in points ) { int condOne = isInside ( triangle1 , point ) ; int condTwo = isInside ( triangle2 , point ) ; int condThree = isInside ( triangle3 , point ) ; int condFour = isInside ( triangle4 , point ) ; int condFive = isInside ( triangle , point ) ; if ( ( condOne != 0 condTwo != 0 condThree != 0 condFour != 0 ) && condFive != 0 ) ans += 1 ; } Console . WriteLine ( ans ) ; } static public void Main ( ) { List < List < int > > rectangle = new List < List < int > > ( ) ; List < List < int > > points = new List < List < int > > ( ) ; List < List < int > > triangle = new List < List < int > > ( ) ; rectangle . Add ( new List < int > ( ) { 6 , 5 } ) ; rectangle . Add ( new List < int > ( ) { 2 , 2 } ) ; rectangle . Add ( new List < int > ( ) { 2 , 1 } ) ; rectangle . Add ( new List < int > ( ) { 5 , 5 } ) ; points . Add ( new List < int > ( ) { 1 , 1 } ) ; points . Add ( new List < int > ( ) { 6 , 1 } ) ; points . Add ( new List < int > ( ) { 6 , 6 } ) ; points . Add ( new List < int > ( ) { 1 , 6 } ) ; triangle . Add ( new List < int > ( ) { 4 , 4 } ) ; triangle . Add ( new List < int > ( ) { 0 , 4 } ) ; triangle . Add ( new List < int > ( ) { 0 , - 2 } ) ; countPoints ( points , triangle , rectangle ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i, point
Class/struct names: GFG
C# program:
using System ; class GFG { static void minimumOperations ( int [ ] A , int n ) { int cnt = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( A [ i ] != ( i + 1 ) ) { if ( ( ( i - 1 ) >= 0 ) && A [ i - 1 ] == ( i + 1 ) ) { cnt ++ ; int t = A [ i ] ; A [ i ] = A [ i - 1 ] ; A [ i - 1 ] = t ; } else if ( ( ( i - 2 ) >= 0 ) && A [ i - 2 ] == ( i + 1 ) ) { cnt += 2 ; A [ i - 2 ] = A [ i - 1 ] ; A [ i - 1 ] = A [ i ] ; A [ i ] = i + 1 ; } else { Console . WriteLine ( - 1 ) ; return ; } } } Console . WriteLine ( cnt ) ; } public static void Main ( ) { int [ ] A = { 7 , 3 , 2 , 1 , 4 } ; int n = A . Length ; minimumOperations ( A , n ) ; } }

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void countOccurrences ( int n , int x ) { int count = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( x % i == 0 ) { if ( x / i <= n ) count ++ ; } } Console . WriteLine ( count ) ; } public static void Main ( String [ ] args ) { int N = 7 , X = 12 ; countOccurrences ( N , X ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void ConvertArray ( int [ ] arr , int N ) { if ( N == 1 ) { Console . WriteLine ( " Operation ▁ 1 ▁ : ▁ " + 1 + " ▁ " + 1 ) ; Console . WriteLine ( " Added ▁ elements : ▁ " + - 1 * arr [ 0 ] ) ; Console . WriteLine ( ) ; Console . WriteLine ( " Operation ▁ 2 ▁ : ▁ " + 1 + " ▁ " + 1 ) ; Console . WriteLine ( " Added ▁ elements : ▁ " + 1 * arr [ 0 ] ) ; Console . WriteLine ( ) ; Console . WriteLine ( " Operation ▁ 3 ▁ : ▁ " + 1 + " ▁ " + 1 ) ; Console . WriteLine ( " Added ▁ elements : ▁ " + - 1 * arr [ 0 ] ) ; } else { Console . WriteLine ( " Operation ▁ 1 ▁ : ▁ " + 1 + " ▁ " + N ) ; Console . Write ( " Added ▁ elements : ▁ " ) ; for ( int i = 0 ; i < N ; i ++ ) { Console . Write ( - 1 * arr [ i ] * N + " ▁ " ) ; } Console . WriteLine ( ) ; Console . WriteLine ( ) ; Console . WriteLine ( " Operation ▁ 2 ▁ : ▁ " + 1 + " ▁ " + ( N - 1 ) ) ; Console . Write ( " Added ▁ elements : ▁ " ) ; for ( int i = 0 ; i < N - 1 ; i ++ ) { Console . Write ( arr [ i ] * ( N - 1 ) + " ▁ " ) ; } Console . WriteLine ( ) ; Console . WriteLine ( ) ; Console . WriteLine ( " Operation ▁ 3 ▁ : ▁ " + N + " ▁ " + N ) ; Console . Write ( " Added ▁ elements : ▁ " ) ; Console . WriteLine ( arr [ N - 1 ] * ( N - 1 ) ) ; } } public static void Main ( string [ ] args ) { int [ ] arr = { 1 , 3 , 2 , 4 } ; int N = arr . Length ; ConvertArray ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int MAX = 1000000 ; static void countOfPrimefactors ( int [ ] CountDistinct ) { bool [ ] prime = new bool [ MAX + 1 ] ; for ( int i = 0 ; i <= MAX ; i ++ ) { CountDistinct [ i ] = 0 ; prime [ i ] = true ; } for ( int i = 2 ; i <= MAX ; i ++ ) { if ( prime [ i ] == true ) { CountDistinct [ i ] = 1 ; for ( int j = i * 2 ; j <= MAX ; j += i ) { CountDistinct [ j ] ++ ; prime [ j ] = false ; } } } } static int CountEvenPair ( int [ ] A , int [ ] B , int N , int M ) { int [ ] countDistinct = new int [ ( MAX + 1 ) ] ; countOfPrimefactors ( countDistinct ) ; int evenCount = 0 ; int oddCount = 0 ; int evenPairs = 0 ; for ( int i = 0 ; i < M ; i ++ ) { if ( countDistinct [ B [ i ] ] == 0 ) continue ; if ( ( countDistinct [ B [ i ] ] & 1 ) != 0 ) { oddCount ++ ; } else { evenCount ++ ; } } for ( int i = 0 ; i < N ; i ++ ) { if ( countDistinct [ A [ i ] ] == 0 ) continue ; if ( ( countDistinct [ A [ i ] ] & 1 ) != 0 ) { evenPairs += ( evenCount ) ; } else { evenPairs += evenCount + oddCount ; } } return evenPairs ; } public static void Main ( string [ ] args ) { int [ ] A = { 1 , 2 , 3 } ; int [ ] B = { 4 , 5 , 6 } ; int N = A . Length ; int M = B . Length ; Console . WriteLine ( CountEvenPair ( A , B , N , M ) ) ; } }

Index/key variables: i, j
Accumulator variables: evenCount, evenPairs, i, j, oddCount
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int longestSubarray ( int [ ] arr , int N , int K ) { Dictionary < int , int > um = new Dictionary < int , int > ( ) ; int sum = 0 , maxLen = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += arr [ i ] ; if ( sum == K ) maxLen = i + 1 ; if ( ! um . ContainsKey ( sum ) ) um [ sum ] = i ; if ( um . ContainsKey ( sum - K ) ) { if ( maxLen < ( i - um [ sum - K ] ) ) maxLen = i - um [ sum - K ] ; } } return maxLen ; } static void minRequiredOperation ( int [ ] arr , int N , int K ) { int TotalSum = 0 ; for ( int i = 0 ; i < N ; i ++ ) TotalSum += arr [ i ] ; int maxLen = longestSubarray ( arr , N , TotalSum - K ) ; if ( maxLen == - 1 ) { Console . WriteLine ( - 1 ) ; } else Console . WriteLine ( N - maxLen ) ; } public static void Main ( ) { int [ ] arr = { 1 , 3 , 1 , 1 , 2 } ; int K = 4 ; int N = arr . Length ; minRequiredOperation ( arr , N , K ) ; } }

Index/key variables: i, sum
Accumulator variables: TotalSum, i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void minimumDeletions ( string s ) { int n = s . Length ; int ans = n ; for ( int i = n - 1 ; i >= 0 ; i -- ) { int t = s [ i ] - '0' ; if ( t % 2 == 0 ) { for ( int j = i - 1 ; j >= 0 ; j -- ) { int num = ( s [ j ] - '0' ) * 10 + t ; if ( num % 4 == 0 ) { int k1 = i - j - 1 ; int k2 = n - i - 1 ; ans = Math . Min ( ans , k1 + k2 ) ; } } } } if ( ans == n ) { for ( int i = 0 ; i < n ; i ++ ) { int num = s [ i ] - '0' ; if ( num % 4 == 0 ) { ans = n - 1 ; } } } Console . WriteLine ( ans ) ; } static public void Main ( ) { string str = "12367" ; minimumDeletions ( str ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void generateSequence ( int [ ] arr , int n ) { string ans = " " ; ans = arr [ 0 ] . ToString ( ) ; if ( n == 1 ) Console . WriteLine ( ans ) ; else if ( n == 2 ) { Console . WriteLine ( ans + " / " + arr [ 1 ] . ToString ( ) ) ; } else { ans += " / ( " + arr [ 1 ] . ToString ( ) ; for ( int i = 2 ; i < n ; i ++ ) { ans += " / " + arr [ i ] . ToString ( ) ; } ans += " ) " ; Console . WriteLine ( ans ) ; } } public static void Main ( string [ ] args ) { int [ ] arr = { 1000 , 100 , 10 , 2 } ; int N = arr . Length ; generateSequence ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void LCMPairs ( int [ ] arr , int N ) { int total_pairs = ( N * ( N - 1 ) ) / 2 ; int odd = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( ( arr [ i ] & 1 ) != 0 ) odd ++ ; } odd = ( odd * ( odd - 1 ) ) / 2 ; Console . Write ( " Even ▁ = ▁ " + ( total_pairs - odd ) + " , ▁ Odd ▁ = ▁ " + odd ) ; } static void Main ( ) { int [ ] arr = { 3 , 6 , 5 , 4 } ; int N = arr . Length ; LCMPairs ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i, odd
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int printNumber ( int N , int K , int M ) { int sum = K * ( M * ( M + 1 ) / 2 ) ; return sum - N ; } public static void Main ( String [ ] args ) { int N = 17 ; int K = 3 ; int M = 4 ; Console . Write ( printNumber ( N , K , M ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void countEvenOdd ( int L , int R ) { int range = R - L + 1 ; int even = ( range / 4 ) * 2 ; if ( ( L & 1 ) != 0 && ( range % 4 == 3 ) ) { even ++ ; } else if ( ( L & 1 ) == 0 && ( range % 4 != 0 ) ) { even ++ ; } Console . Write ( " Even ▁ = ▁ " + even + " , ▁ Odd ▁ = ▁ " + ( range - even ) ) ; } static void Main ( ) { int L = 2 , R = 7 ; countEvenOdd ( L , R ) ; } }

Accumulator variables: even
Class/struct names: GFG
C# program:
using System ; public class GFG { static void countSwaps ( string S , string T ) { int [ ] value = new int [ 26 ] ; for ( int i = 0 ; i < 26 ; i ++ ) value [ i ] = i + 1 ; int N = S . Length ; int sum1 = 0 ; int sum2 = 0 ; bool flag = false ; for ( int i = 0 ; i < N ; i ++ ) { sum1 += value [ S [ i ] - ' a ' ] ; sum2 += value [ T [ i ] - ' a ' ] ; if ( ( value [ S [ i ] - ' a ' ] % 2 == 0 && value [ T [ i ] - ' a ' ] % 2 == 1 ) || ( value [ S [ i ] - ' a ' ] % 2 == 1 && value [ T [ i ] - ' a ' ] % 2 == 0 ) ) flag = false ; } if ( sum1 % 2 == 1 && sum2 % 2 == 1 ) Console . Write ( "0 STRNEWLINE " ) ; else if ( sum1 % 2 == 0 && sum2 % 2 == 0 ) { if ( flag ) Console . Write ( "1" ) ; else Console . Write ( " - 1" ) ; } else { Console . Write ( " - 1" ) ; } } public static void Main ( String [ ] args ) { string S = " acd " ; string T = " dbf " ; countSwaps ( S , T ) ; } }

Index/key variables: i
Accumulator variables: i, sum1, sum2
Iterator variables: i
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; public class GFG { static bool isPrime ( int N ) { if ( N <= 1 ) return false ; for ( int i = 2 ; i <= Math . Sqrt ( N ) ; i ++ ) { if ( N % i == 0 ) return false ; } return true ; } static void countPrimeTuples ( int N ) { int count = 0 ; for ( int i = 2 ; i <= N ; i ++ ) { if ( isPrime ( i ) && isPrime ( i - 2 ) ) count ++ ; } Console . WriteLine ( count ) ; } static public void Main ( ) { int N = 6 ; countPrimeTuples ( N ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void countPairs ( int [ ] A , int n ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) if ( ( A [ i ] A [ j ] ) > ( A [ i ] & A [ j ] ) ) { count ++ ; } } Console . Write ( count ) ; } public static void Main ( ) { int [ ] A = { 1 , 4 , 7 } ; int N = A . Length ; countPairs ( A , N ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int maximumCandy ( int [ ] candies , int [ ] safety , int N , int M ) { int total = 0 ; int ans = Int32 . MaxValue ; bool all_safe = true ; for ( int i = 0 ; i < N ; i ++ ) { if ( candies [ i ] + M > safety [ i ] ) { all_safe = false ; ans = Math . Min ( ans , safety [ i ] ) ; } else { ans = Math . Min ( ans , candies [ i ] + M ) ; } total += candies [ i ] ; } if ( all_safe ) return total ; else return ans ; } static void Main ( ) { int [ ] A = { 4 , 5 , 2 , 3 } ; int [ ] B = { 8 , 13 , 6 , 4 } ; int M = 5 ; int N = A . Length ; Console . WriteLine ( maximumCandy ( A , B , N , M ) ) ; } }

Index/key variables: i
Accumulator variables: i, total
Iterator variables: i
Boolean variables: all_safe
Class/struct names: GFG
C# program:
using System ; class GFG { static void checkArrays ( int [ ] arr1 , int [ ] arr2 , int N ) { int count = 0 ; bool flag = true ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr1 [ i ] != arr2 [ i ] ) { if ( arr1 [ i ] == 0 ) count ++ ; else { count -- ; if ( count < 0 ) { flag = false ; break ; } } } } if ( ( flag && ( count == 0 ) ) == true ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } static public void Main ( ) { int [ ] arr1 = { 0 , 0 , 1 , 1 } ; int [ ] arr2 = { 1 , 1 , 0 , 0 } ; int N = arr1 . Length ; checkArrays ( arr1 , arr2 , N ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; public class GFG { static void canArrayBeReduced ( int [ ] arr , int N ) { if ( N == 1 ) { Console . Write ( arr [ 0 ] ) ; return ; } if ( arr [ 0 ] < arr [ N - 1 ] ) { Console . Write ( arr [ N - 1 ] ) ; } else Console . Write ( " Not ▁ Possible " ) ; } static public void Main ( ) { int [ ] arr = { 6 , 5 , 2 , 4 , 1 , 3 , 7 } ; int N = arr . Length ; canArrayBeReduced ( arr , N ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int MinimumMoves ( int [ ] A , int [ ] B , int N ) { int totalOperations = 0 ; int carry = 0 ; int K = 0 ; for ( int i = N - 1 ; i >= 0 ; i -- ) { int nearestMultiple = ( int ) ( Math . Ceiling ( ( double ) ( A [ i ] + carry ) / ( double ) ( B [ i ] ) ) * B [ i ] ) ; K = nearestMultiple - ( A [ i ] + carry ) ; totalOperations += K ; carry += K ; } return totalOperations ; } public static void Main ( string [ ] args ) { int [ ] A = { 3 , 4 , 5 , 2 , 5 , 5 , 9 } ; int [ ] B = { 1 , 1 , 9 , 6 , 3 , 8 , 7 } ; int N = A . Length ; Console . Write ( MinimumMoves ( A , B , N ) + " STRNEWLINE " ) ; } }

Index/key variables: i
Accumulator variables: carry, i, totalOperations
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; using System . Linq ; class GFG { static void minimumDeviation ( int [ ] A , int N ) { HashSet < int > s = new HashSet < int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( A [ i ] % 2 == 0 ) s . Add ( A [ i ] ) ; else s . Add ( 2 * A [ i ] ) ; } List < int > S = s . ToList ( ) ; S . Sort ( ) ; int diff = S [ S . Count - 1 ] - S [ 0 ] ; while ( ( int ) S . Count != 0 && S [ S . Count - 1 ] % 2 == 0 ) { int maxEl = S [ S . Count - 1 ] ; S . RemoveAt ( S . Count - 1 ) ; S . Add ( maxEl / 2 ) ; S . Sort ( ) ; diff = Math . Min ( diff , S [ S . Count - 1 ] - S [ 0 ] ) ; } Console . Write ( diff ) ; } static void Main ( ) { int [ ] A = { 4 , 1 , 5 , 20 , 3 } ; int N = A . Length ; minimumDeviation ( A , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { public static int findMaxNum ( int num ) { string binaryNumber = Convert . ToString ( num , 2 ) ; string maxBinaryNumber = " " ; int count0 = 0 , count1 = 0 ; int N = binaryNumber . Length ; for ( int i = 0 ; i < N ; i ++ ) { if ( binaryNumber [ i ] == '1' ) { count1 ++ ; } else { count0 ++ ; } } for ( int i = 0 ; i < count1 ; i ++ ) { maxBinaryNumber += '1' ; } for ( int i = 0 ; i < count0 ; i ++ ) { maxBinaryNumber += '0' ; } return Convert . ToInt32 ( maxBinaryNumber , 2 ) ; } static public void Main ( ) { int N = 11 ; Console . WriteLine ( findMaxNum ( N ) ) ; } }

Index/key variables: i
Accumulator variables: count0, count1, i, maxBinaryNumber
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void minOperations ( String N ) { int even = 0 ; int odd = 0 ; foreach ( int it in N . ToCharArray ( ) ) { if ( ( it - '0' ) % 2 == 0 ) { even ++ ; } else { odd ++ ; } } if ( odd == 0 odd == 1 ) { Console . Write ( " Not ▁ Possible " + " STRNEWLINE " ) ; } else { int ans = 0 ; foreach ( int it in N . ToCharArray ( ) ) { if ( ( it - '0' ) % 2 == 0 ) { ans ++ ; } else { ans = 0 ; } } if ( odd % 2 != 0 ) { ans ++ ; } Console . Write ( ans + " STRNEWLINE " ) ; } } public static void Main ( String [ ] args ) { String N = "12345" ; minOperations ( N ) ; } }

Accumulator variables: ans, even, odd
Iterator variables: it
Class/struct names: GFG