dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int maxLenSub ( int [ ] arr , int N ) { int Pos = 0 ; int Neg = 0 ; int res = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == 0 ) { Pos = Neg = 0 ; } else if ( arr [ i ] > 0 ) { Pos += 1 ; if ( Neg != 0 ) { Neg += 1 ; } res = Math . Max ( res , Pos ) ; } else { Pos = Pos + Neg ; Neg = Pos - Neg ; Neg = Pos - Neg ; Neg += 1 ; if ( Pos != 0 ) { Pos += 1 ; } res = Math . Max ( res , Pos ) ; } } return res ; } public static void Main ( ) { int [ ] arr = { - 1 , - 2 , - 3 , 0 , 1 } ; int N = arr . Length ; Console . Write ( maxLenSub ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: Neg, Pos, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int maxLength ( String [ ] arr ) { int len = int . MinValue ; int N = arr . Length ; for ( int i = 0 ; i < N ; i ++ ) { int l = arr [ i ] . Length ; if ( len < l ) { len = l ; } } return len ; } static void maxStrings ( String [ ] arr , int len ) { int N = arr . Length ; List < String > ans = new List < String > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( len == arr [ i ] . Length ) { ans . Add ( arr [ i ] ) ; } } for ( int i = 0 ; i < ans . Count ; i ++ ) { Console . Write ( ans [ i ] + " ▁ " ) ; } } static void printStrings ( String [ ] arr ) { int max = maxLength ( arr ) ; maxStrings ( arr , max ) ; } public static void Main ( String [ ] args ) { String [ ] arr = { " aba " , " aa " , " ad " , " vcd " , " aba " } ; printStrings ( arr ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int min_flips ( String str , int k ) { if ( str . Length == 0 ) return 0 ; int ans = 0 ; int cnt_zeros = 0 ; foreach ( char ch in str . ToCharArray ( ) ) { if ( ch == '0' ) { ++ cnt_zeros ; } else { cnt_zeros = 0 ; } if ( cnt_zeros == k ) { ++ ans ; cnt_zeros = 0 ; } } return ans ; } public static void Main ( String [ ] args ) { String str = "11100000011" ; int k = 3 ; Console . Write ( min_flips ( str , k ) ) ; } }

Iterator variables: ch
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static List < List < int > > maxSubArray ( int [ ] arr , int K ) { List < List < int > > solution = new List < List < int > > ( ) ; int multi = 1 ; int start = 0 ; if ( arr . Length <= 1 K < 0 ) { return new List < List < int > > ( ) ; } for ( int i = 0 ; i < arr . Length ; i ++ ) { multi = multi * arr [ i ] ; while ( multi > K ) { multi = multi / arr [ start ] ; start ++ ; } List < int > list = new List < int > ( ) ; for ( int j = i ; j >= start ; j -- ) { list . Insert ( 0 , arr [ j ] ) ; solution . Add ( new List < int > ( list ) ) ; } } return solution ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 7 , 1 , 4 } ; int K = 7 ; List < List < int > > list = maxSubArray ( arr , K ) ; foreach ( List < int > i in list ) { Console . Write ( " [ " ) ; foreach ( int j in i ) { Console . Write ( j ) ; if ( i . Count > 1 ) Console . Write ( " , " ) ; } Console . Write ( " ] " ) ; } } }

Index/key variables: i, j, start
Accumulator variables: i, j, start
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static double solve ( int [ , ] D , int N , int X , int Y ) { ArrayList T = new ArrayList ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int x = D [ i , 0 ] ; int y = D [ i , 1 ] ; double speed = D [ i , 2 ] ; double time = ( ( x * x - X * X ) + ( y * y - Y * Y ) ) / ( speed * speed ) ; T . Add ( time ) ; } T . Sort ( ) ; int j = 0 ; int total = 0 ; while ( j < ( T . Count - 1 ) ) { int count = 1 ; while ( ( j < ( T . Count - 1 ) ) && ( Convert . ToDouble ( T [ j ] ) . CompareTo ( Convert . ToDouble ( T [ j + 1 ] ) ) == 0 ) ) { count += 1 ; j += 1 ; } total += ( count * ( count - 1 ) ) / 2 ; j += 1 ; } return total ; } public static void Main ( String [ ] args ) { int N = 5 ; int [ , ] D = new int [ , ] { { 5 , 12 , 1 } , { 16 , 63 , 5 } , { - 10 , 24 , 2 } , { 7 , 24 , 2 } , { - 24 , 7 , 2 } } ; int X = 0 , Y = 0 ; Console . WriteLine ( solve ( D , N , X , Y ) ) ; } }

Index/key variables: j
Accumulator variables: count, i, j, total
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int getMaxLength ( int [ ] arr , int N ) { int res = 2 ; int dist = 2 ; int curradj = ( arr [ 1 ] - arr [ 0 ] ) ; int prevadj = ( arr [ 1 ] - arr [ 0 ] ) ; for ( int i = 2 ; i < N ; i ++ ) { curradj = arr [ i ] - arr [ i - 1 ] ; if ( curradj == prevadj ) { dist ++ ; } else { prevadj = curradj ; res = Math . Max ( res , dist ) ; dist = 2 ; } } res = Math . Max ( res , dist ) ; return res ; } public static void Main ( String [ ] args ) { int [ ] arr = { 10 , 7 , 4 , 6 , 8 , 10 , 11 } ; int N = arr . Length ; Console . Write ( getMaxLength ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: dist, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minSteps ( string str , int N ) { int smaller , cost = 0 ; int [ ] f = new int [ 26 ] ; for ( int i = 0 ; i < N ; i ++ ) { int curr_ele = str [ i ] - ' a ' ; smaller = 0 ; for ( int j = 0 ; j <= curr_ele ; j ++ ) { if ( f [ j ] != 0 ) smaller += f [ j ] ; } if ( smaller == 0 ) cost += ( i + 1 ) ; else cost += ( i - smaller + 1 ) ; f [ str [ i ] - ' a ' ] ++ ; } return cost ; } public static void Main ( ) { string str = " abcab " ; int N = str . Length ; Console . Write ( minSteps ( str , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: cost, i, j, smaller
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ ] findSubarrays ( int [ ] a ) { int n = a . Length ; int [ ] freq = new int [ n + 1 ] ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] == 0 ) { if ( count == 0 ) continue ; else { int value = count ; for ( int j = 1 ; j <= count ; j ++ ) { freq [ j ] += value ; value -- ; } count = 0 ; } } else count ++ ; } if ( count > 0 ) { int value = count ; for ( int j = 1 ; j <= count ; j ++ ) { freq [ j ] += value ; value -- ; } } return freq ; } static void countRectangles ( int [ ] a , int [ ] b , int K ) { int n = a . Length ; int m = b . Length ; int [ ] subA = findSubarrays ( a ) ; int [ ] subB = findSubarrays ( b ) ; int total = 0 ; for ( int i = 1 ; i < subA . Length ; i ++ ) { if ( K % i == 0 && ( K / i ) <= m ) { total = total + subA [ i ] * subB [ K / i ] ; } } Console . Write ( total ) ; } public static void Main ( String [ ] args ) { int [ ] a = { 0 , 0 , 1 , 1 } ; int [ ] b = { 1 , 0 , 1 } ; int K = 2 ; countRectangles ( a , b , K ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j, value
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void printRes ( List < int > res ) { foreach ( int enu in res ) { Console . Write ( enu + " ▁ " ) ; } } static void printLBS ( int [ ] arr , int N ) { int [ ] lis = new int [ N ] ; int [ ] lds = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { lis [ i ] = lds [ i ] = 1 ; } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < i ; j ++ ) { if ( arr [ j ] < arr [ i ] ) { if ( lis [ i ] < lis [ j ] + 1 ) lis [ i ] = lis [ j ] + 1 ; } } } for ( int i = N - 1 ; i >= 0 ; i -- ) { for ( int j = N - 1 ; j > i ; j -- ) { if ( arr [ j ] < arr [ i ] ) { if ( lds [ i ] < lds [ j ] + 1 ) lds [ i ] = lds [ j ] + 1 ; } } } int MaxVal = arr [ 0 ] , inx = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( MaxVal < lis [ i ] + lds [ i ] - 1 ) { MaxVal = lis [ i ] + lds [ i ] - 1 ; inx = i ; } } int ct1 = lis [ inx ] ; List < int > res = new List < int > ( ) ; for ( int i = inx ; i >= 0 && ct1 > 0 ; i -- ) { if ( lis [ i ] == ct1 ) { res . Add ( arr [ i ] ) ; ct1 -- ; } } res . Reverse ( ) ; int ct2 = lds [ inx ] - 1 ; for ( int i = inx ; i < N && ct2 > 0 ; i ++ ) { if ( lds [ i ] == ct2 ) { res . Add ( arr [ i ] ) ; ct2 -- ; } } printRes ( res ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 80 , 60 , 30 , 40 , 20 , 10 } ; int N = arr . Length ; printLBS ( arr , N ) ; } }

Index/key variables: N, i, inx, j
Accumulator variables: ct1, ct2, i, j
Iterator variables: enu, i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static bool possible ( int T , int [ ] arr , int n , int d ) { int partition = 1 ; int total = 0 ; for ( int i = 0 ; i < n ; i ++ ) { total = total + arr [ i ] ; if ( total > T ) { partition = partition + 1 ; total = arr [ i ] ; if ( partition > d ) { return false ; } } } return true ; } public static void calcT ( int n , int d , int [ ] arr ) { int mx = - 1 , sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { mx = Math . Max ( mx , arr [ i ] ) ; sum = sum + arr [ i ] ; } int lb = mx ; int ub = sum ; while ( lb < ub ) { int T_mid = lb + ( ub - lb ) / 2 ; if ( possible ( T_mid , arr , n , d ) == true ) { ub = T_mid ; } else { lb = T_mid + 1 ; } } Console . WriteLine ( lb ) ; } public static void Main ( String [ ] args ) { int d = 2 ; int [ ] arr = { 1 , 1 , 1 , 1 , 1 } ; int n = arr . Length ; calcT ( n , d , arr ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minReqSubstring ( String s , int n ) { char ongoing = ' N ' ; int count = 0 , l = s . Length ; for ( int i = 1 ; i < l ; i ++ ) { if ( ongoing == ' N ' ) { if ( s [ i ] < s [ i - 1 ] ) { ongoing = ' D ' ; } else if ( s [ i ] == s [ i - 1 ] ) { ongoing = ' N ' ; } else { ongoing = ' I ' ; } } else if ( ongoing == ' I ' ) { if ( s [ i ] > s [ i - 1 ] ) { ongoing = ' I ' ; } else if ( s [ i ] == s [ i - 1 ] ) { ongoing = ' I ' ; } else { ongoing = ' N ' ; count += 1 ; } } else { if ( s [ i ] < s [ i - 1 ] ) { ongoing = ' D ' ; } else if ( s [ i ] == s [ i - 1 ] ) { ongoing = ' D ' ; } else { ongoing = ' N ' ; count += 1 ; } } } return count + 1 ; } public static void Main ( String [ ] args ) { String S = " aeccdhba " ; int n = S . Length ; Console . Write ( minReqSubstring ( S , n ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minimum_required_operations ( int [ ] arr , int n , int k ) { int answer = 0 ; long mod = 1000000007 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( arr [ i ] + arr [ i + 1 ] > k ) { if ( arr [ i ] > k ) { answer += ( arr [ i ] - k ) ; arr [ i ] = k ; } answer += ( arr [ i ] + arr [ i + 1 ] ) - k ; arr [ i + 1 ] = ( k - arr [ i ] ) ; answer = ( int ) ( answer % mod ) ; } } return answer ; } public static void Main ( String [ ] args ) { int [ ] a = { 9 , 50 , 4 , 14 , 42 , 89 } ; int k = 10 ; int n = a . Length ; Console . Write ( minimum_required_operations ( a , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: answer, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static String findSmallestString ( String str1 , String str2 ) { int [ ] freq1 = new int [ 26 ] ; int [ ] freq2 = new int [ 26 ] ; int n1 = str1 . Length ; int n2 = str2 . Length ; for ( int i = 0 ; i < n1 ; ++ i ) { freq1 [ str1 [ i ] - ' a ' ] ++ ; } for ( int i = 0 ; i < n2 ; ++ i ) { freq2 [ str2 [ i ] - ' a ' ] ++ ; } for ( int i = 0 ; i < 26 ; ++ i ) { freq1 [ i ] -= freq2 [ i ] ; } String res = " " ; int minIndex = str2 [ 0 ] - ' a ' ; for ( int i = 0 ; i < 26 ; ++ i ) { for ( int j = 0 ; j < freq1 [ i ] ; ++ j ) { res += ( char ) ( i + ' a ' ) ; } if ( i == minIndex ) { res += str2 ; } } return res ; } public static void Main ( String [ ] args ) { String str1 = " geeksforgeeksfor " ; String str2 = " for " ; Console . Write ( findSmallestString ( str1 , str2 ) ) ; } }

Index/key variables: i
Accumulator variables: res
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void determineWinner ( String str ) { int [ ] A = new int [ 10 ] ; int sum1 = 0 , sum2 = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) { A [ ( int ) str [ i ] - 48 ] ++ ; } for ( int i = 0 ; i <= 9 ; i ++ ) { if ( i % 2 != 0 ) { sum1 = sum1 + A [ i ] ; } else { sum2 = sum2 + A [ i ] ; } } if ( sum1 == sum2 ) { Console . Write ( " - 1" ) ; } else if ( sum1 > sum2 ) { Console . Write ( " Player ▁ 1" ) ; } else { Console . Write ( " Player ▁ 2" ) ; } } public static void Main ( String [ ] args ) { String str = "78787" ; determineWinner ( str ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void manipulateStrings ( String P , String Q ) { int [ ] freq = new int [ 26 ] ; for ( int i = 0 ; i < P . Length ; i ++ ) { freq [ P [ i ] - ' a ' ] ++ ; } for ( int i = 0 ; i < Q . Length ; i ++ ) { freq [ Q [ i ] - ' a ' ] -- ; } String sb = " " ; int pos = Q [ 0 ] - ' a ' ; for ( int i = 0 ; i <= pos ; i ++ ) { while ( freq [ i ] > 0 ) { char c = ( char ) ( ' a ' + i ) ; sb += c ; freq [ i ] -- ; } } sb += Q ; for ( int i = pos + 1 ; i < 26 ; i ++ ) { while ( freq [ i ] > 0 ) { char c = ( char ) ( ' a ' + i ) ; sb += c ; freq [ i ] -- ; } } Console . WriteLine ( sb ) ; } public static void Main ( String [ ] args ) { String P = " geeksforgeeksfor " ; String Q = " for " ; manipulateStrings ( P , Q ) ; } }

Index/key variables: i
Accumulator variables: i, sb
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int numberMoves ( String s ) { int [ ] row = { 2 , 3 , 3 , 2 , 1 , 2 , 2 , 2 , 1 , 2 , 2 , 2 , 3 , 3 , 1 , 1 , 1 , 1 , 2 , 1 , 1 , 3 , 1 , 3 , 1 , 3 } ; int n = s . Length ; int move = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( row [ s [ i ] - ' a ' ] != row [ s [ i - 1 ] - ' a ' ] ) { move ++ ; } } return move ; } public static void Main ( String [ ] args ) { String str = " geeksforgeeks " ; Console . Write ( numberMoves ( str ) ) ; } }

Index/key variables: i
Accumulator variables: i, move
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { class Node { public int L ; public int R ; public int K ; } ; static void kMultipleSum ( int [ ] arr , Node [ ] Query , int N , int Q ) { int [ , ] prefixSum = new int [ N + 1 , N ] ; for ( int i = 1 ; i <= N ; i ++ ) { prefixSum [ i , 0 ] = arr [ 0 ] ; for ( int j = 0 ; j < N ; j ++ ) { if ( j % i == 0 ) { if ( j != 0 ) prefixSum [ i , j ] = arr [ j ] + prefixSum [ i , j - 1 ] ; } else { prefixSum [ i , j ] = prefixSum [ i , j - 1 ] ; } } } for ( int i = 0 ; i < Q ; i ++ ) { int last = prefixSum [ Query [ i ] . K , Query [ i ] . R ] ; int first ; if ( Query [ i ] . L == 0 ) { first = prefixSum [ Query [ i ] . K , Query [ i ] . L ] ; } else { first = prefixSum [ Query [ i ] . K , Query [ i ] . L - 1 ] ; } Console . Write ( last - first + " STRNEWLINE " ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 6 } ; int N = arr . Length ; int Q = 2 ; Node [ ] Query = new Node [ Q ] ; for ( int i = 0 ; i < Q ; i ++ ) Query [ i ] = new Node ( ) ; Query [ 0 ] . L = 2 ; Query [ 0 ] . R = 5 ; Query [ 0 ] . K = 2 ; Query [ 1 ] . L = 3 ; Query [ 1 ] . R = 5 ; Query [ 1 ] . K = 5 ; kMultipleSum ( arr , Query , N , Q ) ; } }

Index/key variables: Q, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { static int mod = 1000000007 ; public static long countS ( String [ ] str , int n , int m ) { Dictionary < int , HashSet < char > > counts = new Dictionary < int , HashSet < char > > ( ) ; for ( int i = 0 ; i < m ; i ++ ) { counts . Add ( i , new HashSet < char > ( ) ) ; } for ( int i = 0 ; i < n ; i ++ ) { String s = str [ i ] ; for ( int j = 0 ; j < m ; j ++ ) { counts [ j ] . Add ( s [ j ] ) ; } } long result = 1 ; foreach ( int index in counts . Keys ) result = ( result * counts [ index ] . Count ) % mod ; return result ; } public static void Main ( String [ ] args ) { String [ ] str = { "112" , "211" } ; int N = 2 , M = 3 ; Console . WriteLine ( countS ( str , N , M ) ) ; } }

Index/key variables: i, index, j
Accumulator variables: i, j
Iterator variables: i, index, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void solve ( int n , int [ ] arr ) { int i , ans = 0 ; for ( i = 0 ; i < n ; i ++ ) { int left = Math . Max ( i - 1 , 0 ) ; int right = Math . Min ( n - 1 , i + 1 ) ; while ( left >= 0 ) { if ( arr [ left ] > arr [ i ] ) { left ++ ; break ; } left -- ; } if ( left < 0 ) left ++ ; while ( right < n ) { if ( arr [ right ] > arr [ i ] ) { right -- ; break ; } right ++ ; } if ( right >= n ) right -- ; ans = 1 + right - left ; Console . Write ( ans + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 4 , 2 , 1 } ; int n = arr . Length ; solve ( n , arr ) ; } }

Index/key variables: i, left, right
Accumulator variables: i, left, right
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int countSubStrings ( String s , int n ) { int count = 0 , sum = 0 ; Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; mp . Add ( 0 , 1 ) ; for ( int i = 0 ; i < n ; ++ i ) { sum += ( s [ i ] - '0' ) ; count += mp . ContainsKey ( sum - ( i + 1 ) ) == true ? mp [ sum - ( i + 1 ) ] : 0 ; if ( ! mp . ContainsKey ( sum - ( i + 1 ) ) ) mp . Add ( sum - ( i + 1 ) , 1 ) ; else mp [ sum - ( i + 1 ) ] = mp [ sum - ( i + 1 ) ] + 1 ; } return count ; } public static void Main ( String [ ] args ) { String str = "112112" ; int n = str . Length ; Console . Write ( countSubStrings ( str , n ) + " STRNEWLINE " ) ; } }

Index/key variables: i
Accumulator variables: count, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findCount ( int [ ] arr , int n ) { int [ ] prefix_sum = new int [ n ] ; prefix_sum [ 0 ] = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) prefix_sum [ i ] = prefix_sum [ i - 1 ] + arr [ i ] ; int [ ] suffix_sum = new int [ n ] ; suffix_sum [ n - 1 ] = arr [ n - 1 ] ; for ( int i = n - 2 ; i >= 0 ; i -- ) suffix_sum [ i ] = suffix_sum [ i + 1 ] + arr [ i ] ; int s = 1 , e = 1 ; int curr_subarray_sum = 0 , count = 0 ; while ( s < n - 1 && e < n - 1 ) { while ( e < n - 1 && curr_subarray_sum < prefix_sum [ s - 1 ] ) { curr_subarray_sum += arr [ e ++ ] ; } if ( curr_subarray_sum <= suffix_sum [ e ] ) { count ++ ; } curr_subarray_sum -= arr [ s ++ ] ; } return count ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 3 , 1 , 7 } ; int n = arr . Length ; Console . WriteLine ( findCount ( arr , n ) ) ; } }

Index/key variables: e, i, n
Accumulator variables: count, curr_subarray_sum, e, i, s
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minOperation ( String s , int n ) { int cnt1 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == '1' ) cnt1 ++ ; } int cnt0 = 0 ; for ( int i = 0 ; i < cnt1 ; i ++ ) { if ( s [ i ] == '0' ) cnt0 ++ ; } return cnt0 ; } public static void Main ( String [ ] args ) { int n = 8 ; String s = "01001011" ; int ans = minOperation ( s , n ) ; Console . Write ( ans + " STRNEWLINE " ) ; } }

Index/key variables: i
Accumulator variables: cnt0, cnt1, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minOperation ( String s , int n ) { int ans = 0 ; int i = 0 , j = n - 1 ; while ( i < j ) { if ( s [ i ] == '0' && s [ j ] == '1' ) { ans ++ ; i ++ ; j -- ; continue ; } if ( s [ i ] == '1' ) { i ++ ; } if ( s [ j ] == '0' ) { j -- ; } } return ans ; } public static void Main ( String [ ] args ) { int n = 8 ; String s = "10100101" ; Console . WriteLine ( minOperation ( s , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static void count ( int N ) { if ( N == 1 ) { Console . WriteLine ( 10 ) ; return ; } int [ , ] dp = new int [ N , 10 ] ; for ( int i = 1 ; i < 10 ; i ++ ) dp [ 0 , i ] = 1 ; for ( int i = 1 ; i < N ; i ++ ) { int temp = 0 ; for ( int j = 0 ; j < 10 ; j ++ ) temp += dp [ i - 1 , j ] ; for ( int j = 0 ; j < 10 ; j ++ ) dp [ i , j ] = temp - dp [ i - 1 , j ] ; } int ans = 0 ; for ( int i = 0 ; i < 10 ; i ++ ) ans += dp [ N - 1 , i ] ; Console . WriteLine ( ans ) ; } public static void Main ( String [ ] args ) { int N = 2 ; count ( N ) ; } }

Accumulator variables: ans, i, j, temp
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int power ( int x , int y , int mod ) { int 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 ; } public static void count ( int N ) { if ( N == 1 ) { Console . WriteLine ( 10 ) ; return ; } Console . WriteLine ( power ( 9 , N , 1000000007 ) ) ; } public static void Main ( String [ ] args ) { int N = 3 ; count ( N ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int [ ] kmp ( string s ) { int n = s . Length ; int [ ] lps = new int [ n ] ; lps [ 0 ] = 0 ; int i = 1 , len = 0 ; while ( i < n ) { if ( s [ i ] == s [ len ] ) { len ++ ; lps [ i ] = len ; i ++ ; } else { if ( len != 0 ) { len = lps [ len - 1 ] ; } else { lps [ i ] = 0 ; i ++ ; } } } return lps ; } static string findString ( string s , int k ) { int n = s . Length ; int [ ] lps = kmp ( s ) ; string ans = " " ; string suff = s . Substring ( 0 , n - lps [ n - 1 ] ) ; for ( int i = 0 ; i < k - 1 ; ++ i ) { ans += suff ; } ans += s ; return ans ; } public static void Main ( string [ ] args ) { int k = 3 ; string s = " geeksforgeeks " ; Console . Write ( findString ( s , k ) ) ; } }

Index/key variables: i, len, n
Accumulator variables: ans, i, len
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool check ( int [ ] arr , int n ) { int i , g ; g = 0 ; for ( i = 1 ; i < n ; i ++ ) { if ( arr [ i ] - arr [ i - 1 ] > 0 && g == 1 ) return false ; if ( arr [ i ] - arr [ i - 1 ] < 0 ) g = 1 ; } return true ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 3 , 4 , 10 , 4 , 3 , 1 } ; int n = arr . Length ; if ( check ( arr , n ) == true ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } }

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