dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static void count ( int [ ] a , int n ) { if ( n == 1 ) { Console . Write ( 0 ) ; return ; } int [ ] pre = new int [ n - 1 ] ; int [ ] suf = new int [ n - 1 ] ; int max = a [ 0 ] ; int ans = 0 , i ; pre [ 0 ] = a [ 0 ] ; for ( i = 1 ; i < n - 1 ; i ++ ) { if ( a [ i ] > max ) max = a [ i ] ; pre [ i ] = max ; } max = a [ n - 1 ] ; suf [ n - 2 ] = a [ n - 1 ] ; for ( i = n - 2 ; i >= 1 ; i -- ) { if ( a [ i ] > max ) max = a [ i ] ; suf [ i - 1 ] = max ; } for ( i = 0 ; i < n - 1 ; i ++ ) { if ( pre [ i ] < suf [ i ] ) ans ++ ; } Console . Write ( ans ) ; } static void Main ( ) { int [ ] arr = { 2 , 3 , 4 , 8 , 1 , 4 } ; int N = arr . Length ; count ( 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 ; public class GFG { public static int xorSubsequence ( int [ ] a , int n , int k ) { int ans = 0 ; Dictionary < int , int > map = new Dictionary < int , int > ( ) ; int [ ] dp = new int [ n ] ; map . Add ( a [ 0 ] , 1 ) ; dp [ 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { int dpj = map . ContainsKey ( a [ i ] ^ k ) ? map [ a [ i ] ^ k ] : - 1 ; if ( dpj != 0 ) dp [ i ] = Math . Max ( dp [ i ] , dpj + 1 ) ; ans = Math . Max ( ans , dp [ i ] ) ; if ( map . ContainsKey ( a [ i ] ) ) { map [ a [ i ] ] = Math . Max ( map [ a [ i ] ] + 1 , dp [ i ] ) ; ; } else { map . Add ( a [ i ] , Math . Max ( 1 , dp [ i ] ) ) ; } } return ans >= 2 ? ans : 0 ; } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , 2 , 4 , 3 , 5 } ; int N = arr . Length ; int K = 1 ; Console . WriteLine ( xorSubsequence ( arr , N , K ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int ans ; class pair { public int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } class TreeNode { public int data ; public TreeNode left ; public TreeNode right ; } ; static TreeNode newNode ( int data ) { TreeNode Node = new TreeNode ( ) ; Node . data = data ; Node . left = null ; Node . right = null ; return ( Node ) ; } static pair sumofsubtree ( TreeNode root ) { pair p = new pair ( 1 , 0 ) ; if ( root . left != null ) { pair ptemp = sumofsubtree ( root . left ) ; p . second += ptemp . first + ptemp . second ; p . first += ptemp . first ; } if ( root . right != null ) { pair ptemp = sumofsubtree ( root . right ) ; p . second += ptemp . first + ptemp . second ; p . first += ptemp . first ; } ans += p . second ; return p ; } public static void Main ( String [ ] args ) { TreeNode root = newNode ( 1 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 3 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 5 ) ; root . right . left = newNode ( 6 ) ; root . right . right = newNode ( 7 ) ; root . left . left . left = newNode ( 8 ) ; root . left . left . right = newNode ( 9 ) ; ans = 0 ; sumofsubtree ( root ) ; Console . Write ( ans ) ; } }

Accumulator variables: ans, first, second
Class/struct names: GFG, TreeNode, pair
C# program:
using System ; using System . Collections . Generic ; class GFG { static void minTime ( List < int > arr , int N , int K ) { Queue < int > q = new Queue < int > ( ) ; int [ ] vis = new int [ N + 1 ] ; Array . Clear ( vis , 0 , vis . Length ) ; int time = 0 ; for ( int i = 0 ; i < K ; i ++ ) { q . Enqueue ( arr [ i ] ) ; vis [ arr [ i ] ] = 1 ; } while ( q . Count > 0 ) { for ( int i = 0 ; i < q . Count ; i ++ ) { int curr = q . Peek ( ) ; q . Dequeue ( ) ; if ( curr - 1 >= 1 && vis [ curr - 1 ] == 0 ) { vis [ curr - 1 ] = 1 ; q . Enqueue ( curr - 1 ) ; } if ( curr + 1 <= N && vis [ curr + 1 ] == 0 ) { vis [ curr + 1 ] = 1 ; q . Enqueue ( curr + 1 ) ; } } time ++ ; } Console . WriteLine ( time - 1 ) ; } public static void Main ( ) { int N = 6 ; List < int > arr = new List < int > ( ) { 2 , 6 } ; int K = arr . Count ; minTime ( arr , N , K ) ; } }

Index/key variables: i
Accumulator variables: i, time
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAXL = 17 ; static int N ; static long [ ] v ; static long findN ( int D ) { if ( D % 9 != 0 ) return 0 ; D /= 9 ; long [ ] B = new long [ MAXL ] ; B [ 0 ] = 1 ; for ( int i = 1 ; i < MAXL ; i ++ ) { B [ i ] = B [ i - 1 ] * 10 ; } long ans = 0 ; for ( int i = 1 ; i <= MAXL ; i ++ ) { N = ( i + 1 ) / 2 ; v = new long [ N ] ; for ( int j = 0 ; j < N ; j ++ ) for ( int k = j ; k < i - j ; k ++ ) v [ j ] += B [ k ] ; ans += count ( D , i , 0 , new int [ N ] ) ; } return ans ; } static long count ( long D , int l , int t , int [ ] x ) { if ( t == N ) { if ( D != 0 ) return 0 ; long ans = 1 ; for ( int i = 0 ; i < N ; i ++ ) { ans *= ( i == 0 ? 9 : 10 ) - Math . Abs ( x [ i ] ) ; } if ( l % 2 == 0 ) { ans *= 10 ; } return ans ; } long anss = 0 ; for ( int m = - 9 ; m <= 9 ; m ++ ) { if ( - v [ t ] < D + v [ t ] * m && D + v [ t ] * m < v [ t ] ) { x [ t ] = m ; anss += count ( D + v [ t ] * m , l , t + 1 , x ) ; } } return anss ; } public static void Main ( String [ ] args ) { int D = 63 ; Console . WriteLine ( findN ( D ) ) ; } }

Index/key variables: MAXL, N, i, j, k, t
Accumulator variables: D, ans, anss, i, j, k, m
Iterator variables: i, j, k, m
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; using System . Linq ; class GFG { public static int findPeak ( List < int > arr ) { int left = 0 ; int right = arr . Count - 1 ; while ( left < right ) { int mid = left + ( right - left ) / 2 ; if ( arr [ mid ] < arr [ ( mid + 1 ) ] ) { left = mid + 1 ; } else { right = mid ; } } return left ; } static int BS ( int X , int left , int right , List < int > arr ) { while ( left <= right ) { int mid = left + ( right - left ) / 2 ; if ( arr [ ( mid ) ] == X ) { return mid ; } else if ( X > arr [ mid ] ) { left = mid + 1 ; } else { right = mid - 1 ; } } return - 1 ; } static int reverseBS ( int X , int left , int right , List < int > arr ) { while ( left <= right ) { int mid = left + ( right - left ) / 2 ; if ( arr [ mid ] == X ) { return mid ; } else if ( X > arr [ mid ] ) { right = mid - 1 ; } else { left = mid + 1 ; } } return - 1 ; } static void findInMA ( int X , List < int > mountainArr ) { int peakIndex = findPeak ( mountainArr ) ; int res = - 1 ; if ( X >= mountainArr [ 0 ] && X <= mountainArr [ peakIndex ] ) { res = BS ( X , 0 , peakIndex , mountainArr ) ; } if ( res == - 1 ) { res = reverseBS ( X , peakIndex + 1 , mountainArr . Count - 1 , mountainArr ) ; } Console . WriteLine ( res ) ; } public static void Main ( ) { int X = 3 ; List < int > list = new List < int > ( ) { 1 , 2 , 3 , 4 , 5 , 3 , 1 } ; findInMA ( X , list ) ; } }

Index/key variables: mid, peakIndex
Class/struct names: GFG
C# program:
using System ; class GFG { static int count ( int [ ] a ) { int counter = 0 ; for ( int i = 0 ; i < a . Length ; i ++ ) { if ( a [ i ] == 0 ) { counter ++ ; } } return counter ; } static void rearrange ( int [ ] a , int n , int x ) { for ( int i = 0 ; i < n ; i ++ ) a [ i ] = Math . Abs ( a [ i ] ) ; Array . Sort ( a ) ; x = n - x ; int z = count ( a ) ; if ( x > n - z ) { Console . WriteLine ( " - 1" ) ; return ; } for ( int i = 0 ; i < n && x > 0 ; i += 2 ) { a [ i ] = - a [ i ] ; x -- ; } for ( int i = n - 1 ; i >= 0 && x > 0 ; i -- ) { if ( a [ i ] > 0 ) { a [ i ] = - a [ i ] ; x -- ; } } for ( int i = 0 ; i < n ; i ++ ) { Console . Write ( a [ i ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 0 , - 2 , 4 , 5 , - 3 } ; int K = 3 ; int N = arr . Length ; rearrange ( arr , N , K ) ; } }

Index/key variables: i
Accumulator variables: counter, i, x
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static int maxSubarrayProduct ( List < int > arr , int n ) { int max_ending_here = 1 ; int min_ending_here = 1 ; int max_so_far = 0 ; int flag = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > 0 ) { max_ending_here = max_ending_here * arr [ i ] ; min_ending_here = Math . Min ( min_ending_here * arr [ i ] , 1 ) ; flag = 1 ; } else if ( arr [ i ] == 0 ) { max_ending_here = 1 ; min_ending_here = 1 ; } else { int temp = max_ending_here ; max_ending_here = Math . Max ( min_ending_here * arr [ i ] , 1 ) ; min_ending_here = temp * arr [ i ] ; } if ( max_so_far < max_ending_here ) max_so_far = max_ending_here ; } if ( flag == 0 && max_so_far == 0 ) return 0 ; return max_so_far ; } static int findMaxProduct ( int [ ] a , int n ) { int i = 0 ; int maxProd = 1 ; while ( i < n ) { List < int > v = new List < int > ( ) ; v . Add ( a [ i ] ) ; if ( i < n - 1 && a [ i ] < a [ i + 1 ] ) { while ( i < n - 1 && a [ i ] < a [ i + 1 ] ) { v . Add ( a [ i + 1 ] ) ; i += 1 ; } } else if ( i < n - 1 && a [ i ] > a [ i + 1 ] ) { while ( i < n - 1 && a [ i ] > a [ i + 1 ] ) { v . Add ( a [ i + 1 ] ) ; i += 1 ; } } int prod = maxSubarrayProduct ( v , v . Count ) ; maxProd = Math . Max ( maxProd , prod ) ; i ++ ; } return maxProd ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 10 , 8 , 1 , 100 , 101 } ; int N = arr . Length ; Console . Write ( findMaxProduct ( arr , N ) ) ; } }

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 int [ ] parent = new int [ 1000000 ] ; static int root ( int a ) { if ( a == parent [ a ] ) { return a ; } return parent [ a ] = root ( parent [ a ] ) ; } static void connect ( int a , int b ) { a = root ( a ) ; b = root ( b ) ; if ( a != b ) { parent [ b ] = a ; } } static void connectedComponents ( int n ) { HashSet < int > s = new HashSet < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { s . Add ( parent [ i ] ) ; } Console . WriteLine ( s . Count ) ; } static void printAnswer ( int N , List < List < int > > edges ) { for ( int i = 0 ; i <= N ; i ++ ) { parent [ i ] = i ; } for ( int i = 0 ; i < edges . Count ; i ++ ) { connect ( edges [ i ] [ 0 ] , edges [ i ] [ 1 ] ) ; } connectedComponents ( N ) ; } static void Main ( ) { int N = 8 ; List < List < int > > edges = new List < List < int > > ( ) ; edges . Add ( new List < int > { 1 , 0 } ) ; edges . Add ( new List < int > { 0 , 2 } ) ; edges . Add ( new List < int > { 5 , 3 } ) ; edges . Add ( new List < int > { 3 , 4 } ) ; edges . Add ( new List < int > { 6 , 7 } ) ; printAnswer ( N , edges ) ; } }

Index/key variables: a, b, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void removeZeroRowCol ( int [ , ] arr ) { int n = arr . GetLength ( 0 ) ; int [ ] col = new int [ n + 1 ] ; int [ ] row = new int [ n + 1 ] ; for ( int i = 0 ; i < n ; ++ i ) { int count = 0 ; for ( int j = 0 ; j < n ; ++ j ) { if ( arr [ i , j ] == 1 ) col [ j ] += 1 ; else col [ j ] += 0 ; if ( arr [ i , j ] == 1 ) count += 1 ; else count += 0 ; } row [ i ] = count ; } for ( int i = 0 ; i < n ; ++ i ) { if ( row [ i ] == 0 ) { continue ; } for ( int j = 0 ; j < n ; ++ j ) { if ( col [ j ] != 0 ) Console . Write ( arr [ i , j ] ) ; } Console . WriteLine ( ) ; } } public static void Main ( String [ ] args ) { int [ , ] arr = { { 1 , 1 , 0 , 1 } , { 0 , 0 , 0 , 0 } , { 1 , 1 , 0 , 1 } , { 0 , 1 , 0 , 1 } } ; removeZeroRowCol ( arr ) ; } }

Index/key variables: i, j
Accumulator variables: count
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void findOverlapSegement ( int N , int [ ] a , int [ ] b ) { List < Tuple < Tuple < int , int > , int > > tup = new List < Tuple < Tuple < int , int > , int > > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int x , y ; x = a [ i ] ; y = b [ i ] ; tup . Add ( new Tuple < Tuple < int , int > , int > ( new Tuple < int , int > ( x , y ) , i ) ) ; } tup . Sort ( ) ; int curr = tup [ 0 ] . Item1 . Item2 ; int currPos = tup [ 0 ] . Item2 ; for ( int i = 1 ; i < N ; i ++ ) { int Q = tup [ i - 1 ] . Item1 . Item1 ; int R = tup [ i ] . Item1 . Item1 ; if ( Q == R ) { if ( tup [ i - 1 ] . Item1 . Item2 < tup [ i ] . Item1 . Item2 ) Console . Write ( tup [ i - 1 ] . Item2 + " ▁ " + tup [ i ] . Item2 ) ; else Console . Write ( tup [ i ] . Item2 + " ▁ " + tup [ i - 1 ] . Item2 ) ; return ; } int T = tup [ i ] . Item1 . Item2 ; if ( T <= curr ) { Console . Write ( tup [ i ] . Item2 + " ▁ " + currPos ) ; return ; } else { curr = T ; currPos = tup [ i ] . Item2 ; } } Console . Write ( " - 1 ▁ - 1" ) ; } static void Main ( ) { int [ ] a = { 1 , 2 , 3 , 2 , 2 } ; int [ ] b = { 5 , 10 , 10 , 2 , 15 } ; int N = a . Length ; findOverlapSegement ( N , a , b ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { public static int countDivBy3InArray ( int [ ] arr ) { int ans = 0 ; bool [ ] taken = new bool [ arr . Length ] ; for ( int i = 0 ; i < arr . Length ; i ++ ) { if ( taken [ i ] == true ) { continue ; } for ( int j = i + 1 ; j < arr . Length ; j ++ ) { if ( taken [ j ] == true ) { continue ; } if ( Int32 . Parse ( ( arr [ i ] ) . ToString ( ) + ( arr [ j ] ) . ToString ( ) ) % 3 == 0 || Int32 . Parse ( ( arr [ j ] ) . ToString ( ) + ( arr [ i ] ) . ToString ( ) ) % 3 == 0 ) { ans += 1 ; taken [ i ] = true ; taken [ j ] = true ; } } } return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 5 , 3 , 2 , 8 , 7 } ; Console . WriteLine ( countDivBy3InArray ( arr ) ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void findMaxLengthSequence ( int N , int [ ] arr ) { int rightmost_element = - 1 ; int i = 0 ; int j = N - 1 ; List < int > sequence = new List < int > ( ) ; while ( i <= j ) { if ( arr [ i ] > arr [ j ] ) { if ( arr [ j ] > rightmost_element ) { sequence . Add ( arr [ j ] ) ; rightmost_element = arr [ j ] ; j -- ; } else if ( arr [ i ] > rightmost_element ) { sequence . Add ( arr [ i ] ) ; rightmost_element = arr [ i ] ; i ++ ; } else break ; } else if ( arr [ i ] < arr [ j ] ) { if ( arr [ i ] > rightmost_element ) { sequence . Add ( arr [ i ] ) ; rightmost_element = arr [ i ] ; i ++ ; } else if ( arr [ j ] > rightmost_element ) { sequence . Add ( arr [ j ] ) ; rightmost_element = arr [ j ] ; j -- ; } else break ; } else if ( arr [ i ] == arr [ j ] ) { if ( i == j ) { if ( arr [ i ] > rightmost_element ) { sequence . Add ( arr [ i ] ) ; rightmost_element = arr [ i ] ; i ++ ; } break ; } else { sequence . Add ( arr [ i ] ) ; int k = i + 1 ; List < int > max_left = new List < int > ( ) ; while ( k < j && arr [ k ] > arr [ k - 1 ] ) { max_left . Add ( arr [ k ] ) ; k ++ ; } int l = j - 1 ; List < int > max_right = new List < int > ( ) ; while ( l > i && arr [ l ] > arr [ l + 1 ] ) { max_right . Add ( arr [ l ] ) ; l -- ; } if ( max_left . Count > max_right . Count ) foreach ( int element in max_left ) sequence . Add ( element ) ; else foreach ( int element in max_right ) sequence . Add ( element ) ; break ; } } } foreach ( int element in sequence ) Console . Write ( element + " ▁ " ) ; } static void Main ( ) { int N = 4 ; int [ ] arr = { 1 , 3 , 2 , 1 } ; findMaxLengthSequence ( N , arr ) ; } }

Index/key variables: i, j, k, l
Accumulator variables: i, j, k, l
Iterator variables: element
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; using System . Globalization ; public class TreeNode { public int val ; public List < TreeNode > children ; public TreeNode ( int v ) { val = v ; children = new List < TreeNode > ( ) ; } } public class GFG { static double ans = 0.0 ; public static double [ ] MaxAverage ( TreeNode root ) { if ( root . children != null && root . children . Count == 0 ) { ans = Math . Max ( ans , root . val ) ; return new double [ ] { root . val , 1 } ; } double [ ] childResult = new double [ 2 ] ; foreach ( TreeNode child in root . children ) { double [ ] childTotal = MaxAverage ( child ) ; childResult [ 0 ] = childResult [ 0 ] + childTotal [ 0 ] ; childResult [ 1 ] = childResult [ 1 ] + childTotal [ 1 ] ; } double sum = childResult [ 0 ] + root . val ; double count = childResult [ 1 ] + 1 ; ans = Math . Max ( ans , sum / count ) ; return new double [ ] { sum , count } ; } static public void Main ( ) { TreeNode root = new TreeNode ( 20 ) ; TreeNode left = new TreeNode ( 12 ) ; TreeNode right = new TreeNode ( 18 ) ; root . children . Add ( left ) ; root . children . Add ( right ) ; left . children . Add ( new TreeNode ( 11 ) ) ; left . children . Add ( new TreeNode ( 3 ) ) ; right . children . Add ( new TreeNode ( 15 ) ) ; right . children . Add ( new TreeNode ( 8 ) ) ; MaxAverage ( root ) ; NumberFormatInfo setPrecision = new NumberFormatInfo ( ) ; setPrecision . NumberDecimalDigits = 1 ; Console . WriteLine ( ans . ToString ( " N " , setPrecision ) ) ; } }

Iterator variables: child
Class/struct names: GFG, TreeNode
C# program:
using System ; using System . Collections ; class GFG { static void canTransformStrings ( string A , string B ) { int n1 = A . Length ; int n2 = B . Length ; int count1A = 0 , count1B = 0 ; int odd1A = 0 , odd1B = 0 ; int even1A = 0 , even1B = 0 ; for ( int i = 0 ; i < n1 ; i ++ ) { if ( A [ i ] == '1' ) count1A ++ ; else { if ( ( count1A & 1 ) == 1 ) odd1A ++ ; else even1A ++ ; } } for ( int i = 0 ; i < n2 ; i ++ ) { if ( B [ i ] == '1' ) count1B ++ ; else { if ( ( count1B & 1 ) == 1 ) odd1B ++ ; else even1B ++ ; } } if ( count1A == count1B && odd1A == odd1B && even1A == even1B ) { Console . Write ( " Yes " ) ; } else Console . Write ( " No " ) ; } static void Main ( ) { string A = "10011" , B = "11100" ; canTransformStrings ( A , B ) ; } }

Index/key variables: i
Accumulator variables: count1A, count1B, even1A, even1B, i, odd1A, odd1B
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void printAnswer ( int [ ] answer , int N ) { for ( int i = 1 ; i <= N ; i ++ ) { Console . Write ( answer [ i ] + " ▁ " ) ; } } static void updateAnswerArray ( int [ ] answer , int N ) { int i = 0 ; while ( answer [ i ] == - 1 ) i ++ ; int minimum = answer [ i ] ; while ( i <= N ) { if ( answer [ i ] == - 1 ) answer [ i ] = minimum ; else answer [ i ] = Math . Min ( minimum , answer [ i ] ) ; minimum = Math . Min ( minimum , answer [ i ] ) ; i ++ ; } } static void lengthOfSubarray ( List < List < int > > indices , HashSet < int > st , int N ) { int [ ] answer = new int [ N + 1 ] ; Array . Fill ( answer , - 1 ) ; foreach ( int itr in st ) { int start = - 1 ; int gap = - 1 ; int t = itr ; indices [ t ] . Add ( N ) ; for ( int i = 0 ; i < indices [ t ] . Count ; i ++ ) { gap = Math . Max ( gap , indices [ t ] [ i ] - start ) ; start = indices [ t ] [ i ] ; } if ( answer [ gap ] == - 1 ) answer [ gap ] = t ; } updateAnswerArray ( answer , N ) ; printAnswer ( answer , N ) ; } static void smallestPresentNumber ( int [ ] arr , int N ) { List < List < int > > indices = new List < List < int > > ( ) ; for ( int i = 0 ; i <= N ; i ++ ) indices . Add ( new List < int > ( ) ) ; HashSet < int > elements = new HashSet < int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { indices [ arr [ i ] ] . Add ( i ) ; elements . Add ( arr [ i ] ) ; } lengthOfSubarray ( indices , elements , N ) ; } static void Main ( ) { int [ ] arr = { 2 , 3 , 5 , 3 , 2 , 3 , 1 , 3 , 2 , 7 } ; int N = arr . Length ; smallestPresentNumber ( arr , N ) ; } }

Index/key variables: gap, i, t
Accumulator variables: i
Iterator variables: i, itr
Class/struct names: GFG
C# program:
using System ; public class GFG { static int smallestLeft ( int [ ] arr , int total , int sum , int i , int [ , ] dp ) { if ( i == 0 ) { return Math . Abs ( total - 2 * sum ) ; } if ( dp [ i , sum ] != - 1 ) return dp [ i , sum ] ; int X = smallestLeft ( arr , total , sum + arr [ i - 1 ] , i - 1 , dp ) ; int Y = smallestLeft ( arr , total , sum , i - 1 , dp ) ; return dp [ i , sum ] = Math . Min ( X , Y ) ; } static void UtilSmallestElement ( int [ ] arr , int N ) { int total = 0 ; for ( int i = 0 ; i < N ; i ++ ) { total += arr [ i ] ; } int [ , ] dp = new int [ N + 1 , total ] ; for ( int i = 0 ; i < N + 1 ; i ++ ) { for ( int j = 0 ; j < total ; j ++ ) { dp [ i , j ] = - 1 ; } } Console . WriteLine ( smallestLeft ( arr , total , 0 , N , dp ) ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 7 , 4 , 1 , 8 , 1 } ; int N = arr . Length ; UtilSmallestElement ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i, j, total
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int SmallestElementLeft ( int [ ] arr , int N ) { int totalSum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { totalSum += arr [ i ] ; } int req = totalSum / 2 ; bool [ ] dp = new bool [ req + 1 ] ; for ( int i = 0 ; i < req + 1 ; i ++ ) { dp [ i ] = false ; } dp [ 0 ] = true ; int reach = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = req ; j - arr [ i ] >= 0 ; j -- ) { dp [ j ] = dp [ j ] || dp [ j - arr [ i ] ] ; if ( dp [ j ] ) { reach = Math . Max ( reach , j ) ; } } } return totalSum - ( 2 * reach ) ; } public static void Main ( ) { int [ ] arr = { 2 , 2 , 2 } ; int N = arr . Length ; Console . Write ( SmallestElementLeft ( arr , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, totalSum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int min_Operations ( String str1 , String str2 ) { int N = str1 . Length ; char [ ] str = str1 . ToCharArray ( ) ; int cntOp = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( str [ i ] == str2 [ i ] ) { continue ; } int ptr = i ; while ( ptr < N && str [ ptr ] != str2 [ ptr ] ) { str [ ptr ] = str2 [ ptr ] ; ptr += 2 ; } cntOp ++ ; } return cntOp ; } public static void Main ( String [ ] args ) { String str1 = " abcdef " ; String str2 = " ffffff " ; Console . WriteLine ( min_Operations ( str1 , str2 ) ) ; } }

Index/key variables: i, ptr
Accumulator variables: cntOp, i, ptr
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool isComposite ( int n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return false ; if ( n % 2 == 0 n % 3 == 0 ) return true ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return true ; return false ; } static bool isPerfectSquare ( int x ) { int s = ( int ) Math . Sqrt ( x ) ; return ( s * s == x ) ; } static bool isFibonacci ( int n ) { return isPerfectSquare ( 5 * n * n + 4 ) || isPerfectSquare ( 5 * n * n - 4 ) ; } static void ifgcdFibonacci ( int [ ] a , int n , int k ) { List < int > compositeset = new List < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( isComposite ( a [ i ] ) && a [ i ] % k == 0 ) { compositeset . Add ( a [ i ] ) ; } } int gcd = compositeset [ 0 ] ; for ( int i = 1 ; i < compositeset . Count ; i ++ ) { gcd = __gcd ( gcd , compositeset [ i ] ) ; if ( gcd == 1 ) { break ; } } if ( isFibonacci ( gcd ) ) { Console . Write ( " Yes " ) ; return ; } Console . Write ( " No " ) ; return ; } static int __gcd ( int a , int b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 34 , 2 , 4 , 8 , 5 , 7 , 11 } ; int n = arr . Length ; int k = 2 ; ifgcdFibonacci ( arr , n , k ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int find_longest_subarray ( int [ ] A , int N , int K ) { int MaxLen = 0 ; int Len = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( K % A [ i ] == 0 ) { Len ++ ; MaxLen = Math . Max ( MaxLen , Len ) ; } else { Len = 0 ; } } return MaxLen ; } public static void Main ( string [ ] args ) { int [ ] A = { 2 , 8 , 3 , 10 , 6 , 7 , 4 , 9 } ; int N = A . Length ; int K = 60 ; Console . WriteLine ( find_longest_subarray ( A , N , K ) ) ; } }

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