dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static readonly int m = 5 ; static int countSubsquare ( int [ , ] arr , int n , int X ) { int [ , ] dp = new int [ n + 1 , m + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { dp [ i + 1 , j + 1 ] = arr [ i , j ] ; } } for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= m ; j ++ ) { dp [ i , j ] += dp [ i - 1 , j ] + dp [ i , j - 1 ] - dp [ i - 1 , j - 1 ] ; } } int cnt = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= m ; j ++ ) { int lo = 1 ; int hi = Math . Min ( n - i , m - j ) + 1 ; bool found = false ; while ( lo <= hi ) { int mid = ( lo + hi ) / 2 ; int ni = i + mid - 1 ; int nj = j + mid - 1 ; int sum = dp [ ni , nj ] - dp [ ni , j - 1 ] - dp [ i - 1 , nj ] + dp [ i - 1 , j - 1 ] ; if ( sum >= X ) { if ( sum == X ) { found = true ; } hi = mid - 1 ; } else { lo = mid + 1 ; } } if ( found == true ) { cnt ++ ; } } } return cnt ; } public static void Main ( String [ ] args ) { int N = 4 , X = 10 ; int [ , ] arr = { { 2 , 4 , 3 , 2 , 10 } , { 3 , 1 , 1 , 1 , 5 } , { 1 , 1 , 2 , 1 , 4 } , { 2 , 1 , 1 , 1 , 3 } } ; Console . Write ( countSubsquare ( arr , N , X ) + " STRNEWLINE " ) ; } }

Accumulator variables: cnt, i, j
Iterator variables: i, j
Boolean variables: found
Class/struct names: GFG
C# program:
using System ; class GFG { static void checkArray ( int [ ] A , int [ ] B , int N ) { int start = 0 ; int end = N - 1 ; for ( int i = 0 ; i < N ; i ++ ) { if ( A [ i ] != B [ i ] ) { start = i ; break ; } } for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( A [ i ] != B [ i ] ) { end = i ; break ; } } Array . Reverse ( A , start , end ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( A [ i ] != B [ i ] ) { Console . Write ( " No " ) ; return ; } } Console . Write ( " Yes " ) ; } public static void Main ( string [ ] args ) { int [ ] A = { 1 , 3 , 2 , 4 } ; int [ ] B = { 1 , 2 , 3 , 4 } ; int N = A . Length ; checkArray ( A , B , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countSub ( String str ) { int n = ( int ) str . Length ; int ans = 0 ; int [ ] cnt = new int [ 26 ] ; int i = 0 , j = 0 ; while ( i < n ) { if ( j < n && ( cnt [ str [ j ] - ' a ' ] == 0 ) ) { cnt [ str [ j ] - ' a ' ] ++ ; ans += ( j - i + 1 ) ; j ++ ; } else { cnt [ str [ i ] - ' a ' ] -- ; i ++ ; } } return ans ; } public static void Main ( String [ ] args ) { String str = " gffg " ; Console . Write ( countSub ( str ) ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int solve ( int n , int k ) { int ans = 0 ; for ( int j = 1 ; j * j <= n ; j ++ ) { if ( n % j == 0 ) { if ( j <= k ) { ans = Math . Max ( ans , j ) ; } if ( n / j <= k ) { ans = Math . Max ( ans , n / j ) ; } } } return ans ; } public static void Main ( String [ ] args ) { int N = 8 , K = 7 ; Console . Write ( ( N / solve ( N , K ) ) ) ; } }

Accumulator variables: j
Iterator variables: j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void max_sum_subarray ( List < int > arr , int L , int R ) { int n = arr . Count ; int [ ] pre = new int [ n ] ; pre [ 0 ] = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { pre [ i ] = pre [ i - 1 ] + arr [ i ] ; } List < int > s1 = new List < int > ( ) ; s1 . Add ( 0 ) ; int ans = Int32 . MinValue ; ans = Math . Max ( ans , pre [ L - 1 ] ) ; int flag = 0 ; for ( int i = L ; i < n ; i ++ ) { if ( i - R >= 0 ) { if ( flag == 0 ) { int it = s1 . IndexOf ( 0 ) ; s1 . RemoveAt ( it ) ; flag = 1 ; } } if ( i - L >= 0 ) s1 . Add ( pre [ i - L ] ) ; ans = Math . Max ( ans , pre [ i ] - s1 [ 0 ] ) ; if ( i - R >= 0 ) { int it = s1 . IndexOf ( pre [ i - R ] ) ; s1 . RemoveAt ( it ) ; } } Console . WriteLine ( ans ) ; } static void Main ( ) { int L , R ; L = 1 ; R = 3 ; List < int > arr = new List < int > ( ) { 1 , 2 , 2 , 1 } ; max_sum_subarray ( arr , L , R ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int rowWise ( char [ , ] v , int n , int m , int k ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int countcons = 0 ; for ( int j = 0 ; j < m ; j ++ ) { if ( v [ i , j ] == '1' ) { countcons = 0 ; } else { countcons ++ ; } if ( countcons >= k ) { ans ++ ; } } } return ans ; } static int colWise ( char [ , ] v , int n , int m , int k ) { int ans = 0 ; for ( int i = 0 ; i < m ; i ++ ) { int countcons = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( v [ j , i ] == '1' ) { countcons = 0 ; } else { countcons ++ ; } if ( countcons >= k ) { ans ++ ; } } } return ans ; } public static void Main ( String [ ] args ) { int n = 3 , m = 3 , k = 1 ; char [ , ] v = { { '0' , '0' , '0' } , { '0' , '0' , '0' } , { '0' , '0' , '0' } } ; if ( k == 1 ) { Console . Write ( rowWise ( v , n , m , k ) ) ; } else { Console . Write ( colWise ( v , n , m , k ) + rowWise ( v , n , m , k ) ) ; } } }

Accumulator variables: ans, countcons, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static bool solve ( int [ ] a , int n ) { int mx = Int32 . MinValue ; for ( int j = 1 ; j < n ; j ++ ) { if ( mx > a [ j ] ) return false ; mx = Math . Max ( mx , a [ j - 1 ] ) ; } return true ; } public static void Main ( ) { int [ ] a = { 1 , 0 , 2 } ; int n = a . Length ; bool possible = solve ( a , n ) ; if ( possible ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: j
Accumulator variables: j
Iterator variables: j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { class pair { public int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static int [ ] spf = new int [ 100009 ] ; static void sieve ( ) { for ( int i = 0 ; i < 100005 ; i ++ ) spf [ i ] = - 1 ; for ( int i = 2 ; i * i <= 100005 ; i ++ ) { for ( int j = i ; j <= 100005 ; j += i ) { if ( spf [ j ] == - 1 ) { spf [ j ] = i ; } } } } static HashSet < int > findPrimeFactors ( HashSet < int > s , int n ) { while ( n > 1 ) { s . Add ( spf [ n ] ) ; n /= spf [ n ] ; } return s ; } static int MinimumSteps ( int n , int m ) { Queue < pair > q = new Queue < pair > ( ) ; HashSet < int > s = new HashSet < int > ( ) ; q . Enqueue ( new pair ( n , 0 ) ) ; while ( q . Count != 0 ) { int newNum = q . Peek ( ) . first ; int distance = q . Peek ( ) . second ; q . Dequeue ( ) ; HashSet < int > k = findPrimeFactors ( s , newNum ) ; foreach ( int i in k ) { if ( newNum == m ) { return distance ; } else if ( newNum > m ) { break ; } else { q . Enqueue ( new pair ( newNum + i , distance + 1 ) ) ; } } } return - 1 ; } public static void Main ( String [ ] args ) { int N = 7 , M = 16 ; sieve ( ) ; Console . Write ( MinimumSteps ( N , M ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j, n
Iterator variables: i, j
Class/struct names: GFG, pair
C# program:
using System ; using System . Collections . Generic ; class GFG { static List < int > [ ] v = new List < int > [ 100000 ] ; static void div ( int n ) { for ( int i = 2 ; i <= Math . Sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { v [ n ] . Add ( i ) ; } } } static int prodof2elements ( int [ ] arr , int n ) { int [ ] arr2 = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr2 [ i ] = arr [ i ] ; } Array . Sort ( arr2 ) ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( v [ arr [ i ] ] . Count == 0 ) div ( arr [ i ] ) ; foreach ( int j in v [ arr [ i ] ] ) { if ( Array . BinarySearch ( arr2 , j ) >= 0 && Array . BinarySearch ( arr2 , ( int ) arr [ i ] / j ) >= 0 ) { ans ++ ; break ; } } } return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 1 , 8 , 4 , 32 , 18 } ; int N = arr . Length ; for ( int i = 0 ; i < v . Length ; i ++ ) v [ i ] = new List < int > ( ) ; Console . Write ( prodof2elements ( arr , N ) ) ; } }

Index/key variables: i, n
Accumulator variables: ans, i
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int max_subarray_size ( int N , int [ ] arr ) { int ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { Dictionary < int , int > map1 = new Dictionary < int , int > ( ) ; Dictionary < int , int > map2 = new Dictionary < int , int > ( ) ; for ( int j = i ; j < N ; j ++ ) { int ele_count ; if ( ! map1 . ContainsKey ( arr [ j ] ) ) { ele_count = 0 ; } else { ele_count = map1 [ arr [ j ] ] ; } if ( map1 . ContainsKey ( arr [ j ] ) ) { map1 [ arr [ j ] ] ++ ; } else { map1 . Add ( arr [ j ] , 1 ) ; } if ( map2 . ContainsKey ( ele_count ) ) { if ( map2 [ ele_count ] == 1 ) { map2 . Remove ( ele_count ) ; } else { map2 [ ele_count ] -- ; } } if ( map2 . ContainsKey ( ele_count + 1 ) ) { map2 [ ele_count + 1 ] ++ ; } else { map2 . Add ( ele_count + 1 , 1 ) ; } if ( map2 . Count == 1 ) ans = Math . Max ( ans , j - i + 1 ) ; } } return ans ; } static void Main ( ) { int [ ] arr = { 1 , 2 , 2 , 5 , 6 , 5 , 6 } ; int N = arr . Length ; Console . WriteLine ( max_subarray_size ( N , arr ) ) ; } }

Index/key variables: ele_count, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static bool vowel ( int vo ) { if ( vo == 0 vo == 4 vo == 8 vo == 14 vo == 20 ) return true ; else return false ; } static bool check ( String s , int k ) { int [ ] cnt = new int [ 26 ] ; for ( int i = 0 ; i < k - 1 ; i ++ ) { cnt [ s [ i ] - ' a ' ] ++ ; } for ( int i = k - 1 ; i < s . Length ; i ++ ) { cnt [ s [ i ] - ' a ' ] ++ ; int flag1 = 0 ; for ( int j = 0 ; j < 26 ; j ++ ) { if ( vowel ( j ) == false && cnt [ j ] > 0 ) { flag1 = 1 ; break ; } } if ( flag1 == 0 ) return true ; cnt [ s [ i - k + 1 ] - ' a ' ] -- ; } return false ; } static int longestSubString ( String s ) { int l = 1 , r = s . Length ; int maxi = 0 ; while ( l <= r ) { int mid = ( l + r ) / 2 ; if ( check ( s , mid ) ) { l = mid + 1 ; maxi = Math . Max ( maxi , mid ) ; } else r = mid - 1 ; } return maxi ; } public static void Main ( String [ ] args ) { String s = " sedrewaefhoiu " ; Console . Write ( longestSubString ( s ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int countPairs ( int [ ] X , int [ ] Y , int m , int n ) { int [ ] suffix = new int [ 1005 ] ; long total_pairs = 0 ; for ( int i = 0 ; i < n ; i ++ ) suffix [ Y [ i ] ] ++ ; for ( int i = ( int ) 1e3 ; i >= 3 ; i -- ) suffix [ i ] += suffix [ i + 1 ] ; for ( int i = 0 ; i < m ; i ++ ) { if ( X [ i ] == 0 ) continue ; else if ( X [ i ] == 1 ) { total_pairs += suffix [ 0 ] ; continue ; } else if ( X [ i ] == 2 ) total_pairs += suffix [ 5 ] ; else if ( X [ i ] == 3 ) total_pairs += suffix [ 2 ] + suffix [ 4 ] ; else total_pairs += suffix [ X [ i ] + 1 ] ; total_pairs += suffix [ 0 ] + suffix [ 1 ] ; } return ( int ) total_pairs ; } public static void Main ( String [ ] args ) { int [ ] X = { 10 , 19 , 18 } ; int [ ] Y = { 11 , 15 , 9 } ; int m = X . Length ; int n = Y . Length ; Console . Write ( countPairs ( X , Y , m , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, total_pairs
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int solve ( int [ , ] A , int N , int M ) { int [ , ] B = new int [ N , M ] ; int c = 1 ; HashSet < int > s = new HashSet < int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) B [ i , j ] = c ++ ; } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { if ( i != 0 ) { if ( A [ i - 1 , j ] == A [ i , j ] ) B [ i - 1 , j ] = B [ i , j ] ; } if ( i != N - 1 ) { if ( A [ i + 1 , j ] == A [ i , j ] ) B [ i + 1 , j ] = B [ i , j ] ; } if ( j != 0 ) { if ( A [ i , j - 1 ] == A [ i , j ] ) B [ i , j - 1 ] = B [ i , j ] ; } if ( j != M - 1 ) { if ( A [ i , j + 1 ] == A [ i , j ] ) B [ i , j + 1 ] = B [ i , j ] ; } } } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) s . Add ( B [ i , j ] ) ; } return s . Count ; } public static void Main ( String [ ] args ) { int N = 2 , M = 3 ; int [ , ] A = { { 2 , 1 , 3 } , { 1 , 1 , 2 } } ; Console . Write ( solve ( A , N , M ) ) ; } }

Accumulator variables: c, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int splitArray ( int start , int end , int [ ] arr , int [ ] prefix_sum ) { if ( start >= end ) return 0 ; for ( int k = start ; k < end ; ++ k ) { if ( ( prefix_sum [ k ] - prefix_sum [ start - 1 ] ) == ( prefix_sum [ end ] - prefix_sum [ k ] ) ) { return 1 + splitArray ( start , k , arr , prefix_sum ) + splitArray ( k + 1 , end , arr , prefix_sum ) ; } } return 0 ; } static void solve ( int [ ] arr , int n ) { int [ ] prefix_sum = new int [ n + 1 ] ; prefix_sum [ 0 ] = 0 ; for ( int i = 1 ; i <= n ; ++ i ) { prefix_sum [ i ] = prefix_sum [ i - 1 ] + arr [ i - 1 ] ; } Console . Write ( splitArray ( 1 , n , arr , prefix_sum ) ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 12 , 3 , 3 , 0 , 3 , 3 } ; int N = arr . Length ; solve ( arr , N ) ; } }

Index/key variables: end, i, k
Iterator variables: i, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int minDays ( int [ ] arr , int n , int k ) { int l = arr . Length ; int left = 1 , right = ( int ) 1e9 ; if ( n * k > l ) return - 1 ; while ( left < right ) { int mid = ( left + right ) / 2 , cnt = 0 , product = 0 ; for ( int j = 0 ; j < l ; ++ j ) { if ( arr [ j ] > mid ) { cnt = 0 ; } else if ( ++ cnt >= k ) { product ++ ; cnt = 0 ; } } if ( product < n ) { left = mid + 1 ; } else { right = mid ; } } return left ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 10 , 3 , 10 , 2 } ; int n = 3 , k = 1 ; Console . Write ( minDays ( arr , n , k ) + " STRNEWLINE " ) ; } }

Index/key variables: j
Accumulator variables: product
Iterator variables: j
Class/struct names: GFG
C# program:
using System ; class GFG { static int countFac ( int n ) { int m = n ; int count = 0 ; for ( int i = 2 ; ( i * i ) <= m ; ++ i ) { int total = 0 ; while ( n % i == 0 ) { n /= i ; ++ total ; } int temp = 0 ; for ( int j = 1 ; ( temp + j ) <= total ; ++ j ) { temp += j ; ++ count ; } } if ( n != 1 ) ++ count ; return count ; } public static void Main ( ) { int N = 24 ; Console . Write ( countFac ( N ) ) ; } }

Accumulator variables: n, temp
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void minimumSum ( int [ ] a , int [ ] b , int c , int n ) { int [ , ] dp = new int [ n , 2 ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < 2 ; j ++ ) { dp [ i , j ] = ( int ) 1e6 ; } } dp [ 0 , 0 ] = a [ 0 ] ; dp [ 0 , 1 ] = b [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { dp [ i , 0 ] = Math . Min ( dp [ i , 0 ] , dp [ i - 1 , 0 ] + a [ i ] ) ; dp [ i , 0 ] = Math . Min ( dp [ i , 0 ] , dp [ i - 1 , 1 ] + a [ i ] + c ) ; dp [ i , 1 ] = Math . Min ( dp [ i , 1 ] , dp [ i - 1 , 0 ] + b [ i ] + c ) ; dp [ i , 1 ] = Math . Min ( dp [ i , 1 ] , dp [ i - 1 , 1 ] + b [ i ] ) ; } Console . Write ( Math . Min ( dp [ n - 1 , 0 ] , dp [ n - 1 , 1 ] ) + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int [ ] arr1 = { 7 , 6 , 18 , 6 , 16 , 18 , 1 , 17 , 17 } ; int [ ] arr2 = { 6 , 9 , 3 , 10 , 9 , 1 , 10 , 1 , 5 } ; int C = 2 ; int N = arr1 . Length ; minimumSum ( arr1 , arr2 , C , N ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Text ; class GFG { public static int minimumMoves ( String s , int K ) { StringBuilder S = new StringBuilder ( s ) ; int N = S . Length ; int ops = 0 ; int last_idx = - 1 ; for ( int i = 0 ; i < K ; i ++ ) { if ( S [ i ] == '1' ) last_idx = i ; } if ( last_idx == - 1 ) { ++ ops ; S . Insert ( K - 1 , '1' ) ; last_idx = K - 1 ; } for ( int i = 1 ; i < N - K + 1 ; i ++ ) { if ( last_idx < i ) last_idx = - 1 ; if ( S [ i + K - 1 ] == '1' ) last_idx = i + K - 1 ; if ( last_idx == - 1 ) { ++ ops ; S . Insert ( i + K - 1 , '1' ) ; last_idx = i + K - 1 ; } } return ops ; } public static void Main ( String [ ] args ) { String S = "001010000" ; int K = 3 ; Console . WriteLine ( minimumMoves ( S , K ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static char [ ] arr = { ' a ' , ' b ' , ' c ' } ; static void findString ( int n , int k , char [ ] s1 , char [ ] s2 ) { char [ ] s3 = s2 ; int d = 0 ; for ( int i = 0 ; i < s1 . Length ; i ++ ) { if ( s1 [ i ] != s2 [ i ] ) d ++ ; } if ( ( d + 1 ) / 2 > k ) { Console . Write ( " - 1" + " STRNEWLINE " ) ; return ; } else { if ( k <= d ) { int X = d - k ; int T = 2 * k - d ; for ( int i = 0 ; i < s3 . Length ; i ++ ) { if ( s1 [ i ] != s2 [ i ] ) { if ( T > 0 ) { for ( int j = 0 ; j < 3 ; j ++ ) { if ( arr [ j ] != s1 [ i ] && arr [ j ] != s2 [ i ] ) { s3 [ i ] = arr [ j ] ; T -- ; break ; } } } else if ( X > 0 ) { s3 [ i ] = s1 [ i ] ; X -- ; } } } Console . Write ( new String ( s3 ) + " STRNEWLINE " ) ; } else { for ( int i = 0 ; i < s1 . Length ; i ++ ) { if ( s1 [ i ] != s3 [ i ] ) { for ( int j = 0 ; j < 3 ; j ++ ) { if ( arr [ j ] != s1 [ i ] && arr [ j ] != s3 [ i ] ) { s3 [ i ] = arr [ j ] ; k -- ; break ; } } } } for ( int i = 0 ; i < s1 . Length ; i ++ ) { if ( s1 [ i ] == s3 [ i ] && k > 0 ) { for ( int j = 0 ; j < 3 ; j ++ ) { if ( arr [ j ] != s1 [ i ] && arr [ j ] != s3 [ i ] ) { s3 [ i ] = arr [ j ] ; k -- ; break ; } } } } Console . Write ( new String ( s3 ) + " STRNEWLINE " ) ; } } } public static void Main ( String [ ] args ) { int N = 4 , k = 2 ; String S1 = " zzyy " ; String S2 = " zxxy " ; findString ( N , k , S1 . ToCharArray ( ) , S2 . ToCharArray ( ) ) ; } }

Index/key variables: i, j
Accumulator variables: T, X, d, i, j, k
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void findSolutions ( int N ) { int count = 0 ; for ( int i = 1 ; i <= Math . Sqrt ( N ) ; i ++ ) { if ( N % i == 0 ) { if ( ( i + N / i ) % 2 == 0 ) { count ++ ; } } } Console . Write ( 4 * count ) ; } public static void Main ( String [ ] args ) { int N = 80 ; findSolutions ( N ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static long check ( int A , int B , int C , int D , long x ) { long ans ; ans = ( A * x * x * x + B * x * x + C * x + D ) ; return ans ; } static void findSolution ( int A , int B , int C , int D , int E ) { long start = 0 , end = 100000 ; long mid , ans ; while ( start <= end ) { mid = start + ( end - start ) / 2 ; ans = check ( A , B , C , D , mid ) ; if ( ans == E ) { Console . WriteLine ( mid ) ; return ; } if ( ans < E ) start = mid + 1 ; else end = mid - 1 ; } Console . Write ( " NA " ) ; } public static void Main ( ) { int A = 1 , B = 0 , C = 0 ; int D = 0 , E = 27 ; findSolution ( A , B , C , D , E ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int countTriplets ( String color ) { int result = 0 , Blue_Count = 0 ; int Red_Count = 0 ; int len = color . Length ; int i ; for ( i = 0 ; i < len ; i ++ ) { if ( color [ i ] == ' B ' ) Blue_Count ++ ; } for ( i = 0 ; i < len ; i ++ ) { if ( color [ i ] == ' B ' ) Blue_Count -- ; if ( color [ i ] == ' R ' ) Red_Count ++ ; if ( color [ i ] == ' G ' ) result += Red_Count * Blue_Count ; } return result ; } public static void Main ( string [ ] args ) { string color = " RRGGBBRGGBB " ; Console . WriteLine ( countTriplets ( color ) ) ; } }

Index/key variables: i
Accumulator variables: Blue_Count, Red_Count, i, result
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int naive_find_x ( int N ) { int c = 0 , i ; for ( i = 1 ; i < N ; i ++ ) { c += i * i * i ; if ( c >= N ) break ; } return i ; } public static void Main ( String [ ] args ) { int N = 100 ; Console . WriteLine ( naive_find_x ( N ) ) ; } }

Accumulator variables: c, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int binary_searched_find_x ( int k ) { int l = 0 ; int r = k ; int ans = 0 ; while ( l <= r ) { int mid = l + ( r - l ) / 2 ; if ( Math . Pow ( ( ( mid * ( mid + 1 ) ) / 2 ) , 2 ) >= k ) { ans = mid ; r = mid - 1 ; } else { l = mid + 1 ; } } return ans ; } public static void Main ( ) { int N = 100 ; Console . Write ( binary_searched_find_x ( N ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int lenOflongZigZagArr ( int [ ] a , int n ) { int max = 1 , len = 1 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( i % 2 == 0 && ( a [ i ] < a [ i + 1 ] ) ) len ++ ; else if ( i % 2 == 1 && ( a [ i ] > a [ i + 1 ] ) ) len ++ ; else { if ( max < len ) max = len ; len = 1 ; } } if ( max < len ) max = len ; return max ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 } ; int n = arr . Length ; Console . WriteLine ( lenOflongZigZagArr ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, len
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int checkPerfectSquare ( int N , int start , int last ) { int mid = ( start + last ) / 2 ; if ( start > last ) { return - 1 ; } if ( mid * mid == N ) { return mid ; } else if ( mid * mid > N ) { return checkPerfectSquare ( N , start , mid - 1 ) ; } else { return checkPerfectSquare ( N , mid + 1 , last ) ; } } public static int Main ( ) { int N = 65 ; Console . Write ( checkPerfectSquare ( N , 1 , N ) ) ; return 0 ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void minpoint ( int [ ] arr , int n , int k ) { int min_point = 0 ; for ( int i = 1 ; i < k - 1 ; i ++ ) { if ( arr [ i ] < arr [ i - 1 ] && arr [ i ] < arr [ i + 1 ] ) min_point += 1 ; } int final_point = min_point ; for ( int i = k ; i < n ; i ++ ) { if ( arr [ i - ( k - 1 ) ] < arr [ i - ( k - 1 ) + 1 ] && arr [ i - ( k - 1 ) ] < arr [ i - ( k - 1 ) - 1 ] ) min_point -= 1 ; if ( arr [ i - 1 ] < arr [ i ] && arr [ i - 1 ] < arr [ i - 2 ] ) min_point += 1 ; if ( min_point > final_point ) final_point = min_point ; } Console . WriteLine ( final_point ) ; } public static void Main ( string [ ] args ) { int [ ] arr = { 2 , 1 , 4 , 2 , 3 , 4 , 1 , 2 } ; int n = arr . Length ; int k = 4 ; minpoint ( arr , n , k ) ; } }

Index/key variables: i
Accumulator variables: i, min_point
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void CountStrings ( String [ ] str ) { int size = str . Length ; int [ ] count = new int [ 26 ] ; bool [ ] visited = new bool [ 26 ] ; for ( int i = 0 ; i < size ; ++ i ) { for ( int j = 0 ; j < str [ i ] . Length ; ++ j ) { if ( visited [ str [ i ] [ j ] - ' a ' ] == false ) count [ str [ i ] [ j ] - ' a ' ] ++ ; visited [ str [ i ] [ j ] - ' a ' ] = true ; } for ( int j = 0 ; j < str [ i ] . Length ; ++ j ) { visited [ str [ i ] [ j ] - ' a ' ] = false ; } } for ( int i = 0 ; i < 26 ; ++ i ) { Console . Write ( count [ i ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { String [ ] str = { " i " , " will " , " practice " , " everyday " } ; CountStrings ( str ) ; } }

Index/key variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void findSubArray ( int [ ] a , int n , int k ) { int [ ] pref = new int [ n ] ; pref [ 0 ] = 0 ; for ( int i = 1 ; i < n - 1 ; ++ i ) { pref [ i ] = pref [ i - 1 ] ; if ( a [ i ] > a [ i - 1 ] && a [ i ] > a [ i + 1 ] ) { pref [ i ] ++ ; } } int peak = 0 ; int left = 0 ; for ( int i = 0 ; i + k - 1 < n ; ++ i ) { if ( pref [ i + k - 2 ] - pref [ i ] > peak ) { peak = pref [ i + k - 2 ] - pref [ i ] ; left = i ; } } Console . Write ( " Left ▁ = ▁ " + ( left + 1 ) + " STRNEWLINE " ) ; Console . Write ( " Right ▁ = ▁ " + ( left + k ) + " STRNEWLINE " ) ; Console . Write ( " Peak ▁ = ▁ " + peak + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , 2 , 3 , 2 , 1 } ; int n = arr . Length ; int k = 3 ; findSubArray ( arr , n , k ) ; } }

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