dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int maximumSumSubarray ( int [ ] arr , int n ) { int min_prefix_sum = 0 ; int res = int . MinValue ; 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 ] ; for ( int i = 0 ; i < n ; i ++ ) { res = Math . Max ( res , prefix_sum [ i ] - min_prefix_sum ) ; min_prefix_sum = Math . Min ( min_prefix_sum , prefix_sum [ i ] ) ; } return res ; } public static void Main ( ) { int [ ] arr1 = { - 2 , - 3 , 4 , - 1 , - 2 , 1 , 5 , - 3 } ; int n1 = arr1 . Length ; Console . WriteLine ( maximumSumSubarray ( arr1 , n1 ) ) ; int [ ] arr2 = { 4 , - 8 , 9 , - 4 , 1 , - 8 , - 1 , 6 } ; int n2 = arr2 . Length ; Console . WriteLine ( maximumSumSubarray ( arr2 , n2 ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int DP_s = 9 ; static int getNumMonotone ( int len ) { int [ , ] DP = new int [ len , DP_s ] ; for ( int i = 0 ; i < DP_s ; ++ i ) DP [ 0 , i ] = i + 1 ; for ( int i = 0 ; i < len ; ++ i ) DP [ i , 0 ] = 1 ; for ( int i = 1 ; i < len ; ++ i ) for ( int j = 1 ; j < DP_s ; ++ j ) DP [ i , j ] = DP [ i - 1 , j ] + DP [ i , j - 1 ] ; return DP [ len - 1 , DP_s - 1 ] ; } public static void Main ( ) { Console . WriteLine ( getNumMonotone ( 10 ) ) ; } }

Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int sequence ( int n ) { int [ ] f = new int [ n + 1 ] ; f [ 0 ] = 0 ; f [ 1 ] = 1 ; f [ 2 ] = 1 ; int i ; for ( i = 3 ; i <= n ; i ++ ) f [ i ] = f [ f [ i - 1 ] ] + f [ i - f [ i - 1 ] ] ; return f [ n ] ; } public static void Main ( ) { int n = 10 ; Console . Write ( sequence ( n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Linq ; public class GFG { static long lis ( long [ ] arr , long n ) { long [ ] mpis = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) mpis [ i ] = arr [ i ] ; for ( int i = 1 ; i < n ; i ++ ) for ( int j = 0 ; j < i ; j ++ ) if ( arr [ i ] > arr [ j ] && mpis [ i ] < ( mpis [ j ] * arr [ i ] ) ) mpis [ i ] = mpis [ j ] * arr [ i ] ; return mpis . Max ( ) ; } static public void Main ( ) { long [ ] arr = { 3 , 100 , 4 , 5 , 150 , 6 } ; long n = arr . Length ; Console . WriteLine ( lis ( arr , n ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int Hosoya ( int n , int m ) { if ( ( n == 0 && m == 0 ) || ( n == 1 && m == 0 ) || ( n == 1 && m == 1 ) || ( n == 2 && m == 1 ) ) return 1 ; if ( n > m ) return Hosoya ( n - 1 , m ) + Hosoya ( n - 2 , m ) ; else if ( m == n ) return Hosoya ( n - 1 , m - 1 ) + Hosoya ( n - 2 , m - 2 ) ; else return 0 ; } static void printHosoya ( int n ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j <= i ; j ++ ) Console . Write ( Hosoya ( i , j ) + " ▁ " ) ; Console . WriteLine ( " " ) ; } } public static void Main ( ) { int n = 5 ; printHosoya ( n ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class Eulerian { public static int eulerian ( int n , int m ) { if ( m >= n n == 0 ) return 0 ; if ( m == 0 ) return 1 ; return ( n - m ) * eulerian ( n - 1 , m - 1 ) + ( m + 1 ) * eulerian ( n - 1 , m ) ; } public static void Main ( ) { int n = 3 , m = 1 ; Console . WriteLine ( eulerian ( n , m ) ) ; } }

Class/struct names: Eulerian
C# program:
using System ; using System . Linq ; public class GFG { static int largestSubset ( int [ ] a , int n ) { int [ ] dp = new int [ n ] ; dp [ n - 1 ] = 1 ; for ( int i = n - 2 ; i >= 0 ; i -- ) { int mxm = 0 ; for ( int j = i + 1 ; j < n ; j ++ ) if ( a [ j ] % a [ i ] == 0 a [ i ] % a [ j ] == 0 ) mxm = Math . Max ( mxm , dp [ j ] ) ; dp [ i ] = 1 + mxm ; } return dp . Max ( ) ; } static public void Main ( ) { int [ ] a = { 1 , 3 , 6 , 13 , 17 , 18 } ; int n = a . Length ; Console . WriteLine ( largestSubset ( a , n ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
public static int [ ] dp = new int [ MAXN ] ; static int solve ( int n ) { if ( n < 0 ) return 0 ; if ( n == 0 ) return 1 ; if ( dp [ n ] != - 1 ) return dp [ n ] ; return dp [ n ] = solve ( n - 1 ) + solve ( n - 3 ) + solve ( n - 5 ) ; }

Index/key variables: MAXN, n
C# program:
using System ; class GFG { static int countFriendsPairings ( int n ) { int [ ] dp = new int [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) { if ( i <= 2 ) dp [ i ] = i ; else dp [ i ] = dp [ i - 1 ] + ( i - 1 ) * dp [ i - 2 ] ; } return dp [ n ] ; } public static void Main ( ) { int n = 4 ; Console . Write ( countFriendsPairings ( n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countFriendsPairings ( int n ) { int a = 1 , b = 2 , c = 0 ; if ( n <= 2 ) { return n ; } for ( int i = 3 ; i <= n ; i ++ ) { c = b + ( i - 1 ) * a ; a = b ; b = c ; } return c ; } public static void Main ( String [ ] args ) { int n = 4 ; Console . WriteLine ( countFriendsPairings ( n ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int R = 5 ; static int C = 3 ; static void precompute ( int [ , ] mat , int [ , ] ryt , int [ , ] dwn ) { for ( int j = C - 1 ; j >= 0 ; j -- ) { for ( int i = 0 ; i < R ; ++ i ) { if ( mat [ i , j ] == 0 ) { ryt [ i , j ] = 0 ; else { ryt [ i , j ] = ryt [ i , j + 1 ] + 1 ; } } } for ( int i = R - 1 ; i >= 0 ; i -- ) { for ( int j = 0 ; j < C ; ++ j ) { if ( mat [ i , j ] == 0 ) { dwn [ i , j ] = 0 ; else { dwn [ i , j ] = dwn [ i + 1 , j ] + 1 ; } } } } static int solveRowSwap ( int [ , ] ryt ) { int [ ] b = new int [ R ] ; int ans = 0 ; for ( int j = 0 ; j < C ; j ++ ) { for ( int i = 0 ; i < R ; i ++ ) { b [ i ] = ryt [ i , j ] ; } Array . Sort ( b ) ; for ( int i = 0 ; i < R ; ++ i ) { ans = Math . Max ( ans , b [ i ] * ( R - i ) ) ; } } return ans ; } static int solveColumnSwap ( int [ , ] dwn ) { int [ ] b = new int [ C ] ; int ans = 0 ; for ( int i = 0 ; i < R ; ++ i ) { for ( int j = 0 ; j < C ; ++ j ) { b [ j ] = dwn [ i , j ] ; } Array . Sort ( b ) ; for ( int k = 0 ; k < C ; ++ k ) { ans = Math . Max ( ans , b [ k ] * ( C - k ) ) ; } } return ans ; } static void findMax1s ( int [ , ] mat ) { int [ , ] ryt = new int [ R + 2 , C + 2 ] ; int [ , ] dwn = new int [ R + 2 , C + 2 ] ; precompute ( mat , ryt , dwn ) ; int rswap = solveRowSwap ( ryt ) ; int cswap = solveColumnSwap ( dwn ) ; if ( rswap > cswap ) { Console . WriteLine ( " Row ▁ Swap STRNEWLINE " + rswap ) ; } else { Console . WriteLine ( " Column ▁ Swap STRNEWLINE " + cswap ) ; } } public static void Main ( ) { int [ , ] mat = { { 0 , 0 , 0 } , { 1 , 1 , 0 } , { 1 , 1 , 0 } , { 0 , 0 , 0 } , { 1 , 1 , 0 } } ; findMax1s ( mat ) ; } }

Index/key variables: C, R, i, j, k
Accumulator variables: i, j
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int lcsOf3 ( String X , String Y , String Z , int m , int n , int o ) { int [ , , ] L = new int [ m + 1 , n + 1 , o + 1 ] ; for ( int i = 0 ; i <= m ; i ++ ) { for ( int j = 0 ; j <= n ; j ++ ) { for ( int k = 0 ; k <= o ; k ++ ) { if ( i == 0 j == 0 k == 0 ) L [ i , j , k ] = 0 ; else if ( X [ i - 1 ] == Y [ j - 1 ] && X [ i - 1 ] == Z [ k - 1 ] ) L [ i , j , k ] = L [ i - 1 , j - 1 , k - 1 ] + 1 ; else L [ i , j , k ] = Math . Max ( Math . Max ( L [ i - 1 , j , k ] , L [ i , j - 1 , k ] ) , L [ i , j , k - 1 ] ) ; } } } return L [ m , n , o ] ; } public static void Main ( ) { string X = " AGGT12" ; string Y = "12TXAYB " ; string Z = "12XBA " ; int m = X . Length ; int n = Y . Length ; int o = Z . Length ; Console . Write ( " Length ▁ of ▁ LCS ▁ is ▁ " + lcsOf3 ( X , Y , Z , m , n , o ) ) ; } }

Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static String printShortestSuperSeq ( String X , String Y ) { int m = X . Length ; int n = Y . Length ; int [ , ] dp = new int [ m + 1 , n + 1 ] ; int i , j ; for ( i = 0 ; i <= m ; i ++ ) { for ( j = 0 ; j <= n ; j ++ ) { if ( i == 0 ) { dp [ i , j ] = j ; } else if ( j == 0 ) { dp [ i , j ] = i ; } else if ( X [ i - 1 ] == Y [ j - 1 ] ) { dp [ i , j ] = 1 + dp [ i - 1 , j - 1 ] ; } else { dp [ i , j ] = 1 + Math . Min ( dp [ i - 1 , j ] , dp [ i , j - 1 ] ) ; } } } String str = " " ; i = m ; j = n ; while ( i > 0 && j > 0 ) { if ( X [ i - 1 ] == Y [ j - 1 ] ) { str += ( X [ i - 1 ] ) ; i -- ; j -- ; } else if ( dp [ i - 1 , j ] > dp [ i , j - 1 ] ) { str += ( Y [ j - 1 ] ) ; j -- ; } else { str += ( X [ i - 1 ] ) ; i -- ; } } while ( i > 0 ) { str += ( X [ i - 1 ] ) ; i -- ; } while ( j > 0 ) { str += ( Y [ j - 1 ] ) ; j -- ; } str = reverse ( str ) ; return str ; } static String reverse ( String input ) { char [ ] temparray = input . ToCharArray ( ) ; int left , right = 0 ; right = temparray . Length - 1 ; for ( left = 0 ; left < right ; left ++ , right -- ) { char temp = temparray [ left ] ; temparray [ left ] = temparray [ right ] ; temparray [ right ] = temp ; } return String . Join ( " " , temparray ) ; } public static void Main ( String [ ] args ) { String X = " AGGTAB " ; String Y = " GXTXAYB " ; Console . WriteLine ( printShortestSuperSeq ( X , Y ) ) ; } }

Index/key variables: left, right
Accumulator variables: i, j, left, right, str
Iterator variables: i, j, left
Class/struct names: GFG
C# program:
using System ; class GFG { static int findLongestRepeatingSubSeq ( string str ) { int n = str . Length ; int [ , ] dp = new int [ n + 1 , n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { if ( str [ i - 1 ] == str [ j - 1 ] && i != j ) dp [ i , j ] = 1 + dp [ i - 1 , j - 1 ] ; else dp [ i , j ] = Math . Max ( dp [ i , j - 1 ] , dp [ i - 1 , j ] ) ; } } return dp [ n , n ] ; } public static void Main ( ) { string str = " aabb " ; Console . Write ( " The ▁ length ▁ of ▁ the ▁ largest ▁ " + " subsequence ▁ that ▁ repeats ▁ itself ▁ is ▁ : ▁ " + findLongestRepeatingSubSeq ( str ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ , , , ] lookup = new int [ 50 , 1000 , 1000 , 2 ] ; static int countRec ( int digits , int esum , int osum , int isOdd , int n ) { if ( digits == n ) return ( esum - osum == 1 ) ? 1 : 0 ; if ( lookup [ digits , esum , osum , isOdd ] != - 1 ) return lookup [ digits , esum , osum , isOdd ] ; int ans = 0 ; if ( isOdd == 1 ) for ( int i = 0 ; i <= 9 ; i ++ ) ans += countRec ( digits + 1 , esum , osum + i , 0 , n ) ; for ( int i = 0 ; i <= 9 ; i ++ ) ans += countRec ( digits + 1 , esum + i , osum , 1 , n ) ; return lookup [ digits , esum , osum , isOdd ] = ans ; } static int finalCount ( int n ) { int digits = 0 ; for ( int i = 0 ; i < 50 ; i ++ ) for ( int j = 0 ; j < 1000 ; j ++ ) for ( int k = 0 ; k < 1000 ; k ++ ) for ( int l = 0 ; l < 2 ; l ++ ) lookup [ i , j , k , l ] = - 1 ; int ans = 0 ; int esum = 0 , osum = 0 ; for ( int i = 1 ; i <= 9 ; i ++ ) ans += countRec ( digits + 1 , esum + i , osum , 1 , n ) ; return ans ; } public static void Main ( String [ ] args ) { int n = 3 ; Console . WriteLine ( " Count ▁ of ▁ " + n + " ▁ digit ▁ numbers ▁ is ▁ " + finalCount ( n ) ) ; } }

Accumulator variables: ans, i, j, k, l
Iterator variables: i, j, k, l
Class/struct names: GFG
C# program:
using System ; class GFG { static int numberOfPaths ( int m , int n ) { int [ ] dp = new int [ n ] ; dp [ 0 ] = 1 ; for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 1 ; j < n ; j ++ ) { dp [ j ] += dp [ j - 1 ] ; } } return dp [ n - 1 ] ; } public static void Main ( ) { Console . Write ( numberOfPaths ( 3 , 3 ) ) ; } }

Index/key variables: j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int Solution ( int [ ] A ) { int ans = 2 ; int n = A . Length ; if ( n <= 2 ) return n ; int [ ] llap = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) llap [ i ] = 2 ; Array . Sort ( A ) ; for ( int j = n - 2 ; j >= 0 ; j -- ) { int i = j - 1 ; int k = j + 1 ; while ( i >= 0 && k < n ) { if ( A [ i ] + A [ k ] == 2 * A [ j ] ) { llap [ j ] = Math . Max ( llap [ k ] + 1 , llap [ j ] ) ; ans = Math . Max ( ans , llap [ j ] ) ; i -= 1 ; k += 1 ; } else if ( A [ i ] + A [ k ] < 2 * A [ j ] ) k += 1 ; else i -= 1 ; } } return ans ; } public static void Main ( String [ ] args ) { int [ ] a = { 9 , 4 , 7 , 2 , 10 } ; Console . Write ( Solution ( a ) + " STRNEWLINE " ) ; } }

Index/key variables: i, j, k, n
Accumulator variables: i, j, k
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void minumumOperation ( int N , int [ ] arr ) { int sum_arr = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum_arr = sum_arr + arr [ i ] ; } if ( sum_arr >= N ) Console . Write ( sum_arr - N ) ; else Console . Write ( 1 ) ; } static public void Main ( ) { int N = 4 ; int [ ] arr = { 8 , 4 , 6 , 2 } ; minumumOperation ( N , arr ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int factorial ( int N ) { if ( N == 0 N == 1 ) return 1 ; return N * factorial ( N - 1 ) ; } static int nthTerm ( int N ) { return ( factorial ( N ) * ( N + 2 ) / 2 ) ; } public static void Main ( ) { int N = 6 ; Console . Write ( nthTerm ( N ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { public static void manipulate ( String s ) { int n = s . Length ; int i = 0 , j = 0 ; String res = " " ; while ( i < n ) { if ( s [ i ] == ' ▁ ' ) { res += util ( s . Substring ( j , i - j ) ) ; res = res + " ▁ " ; j = i + 1 ; i = j + 1 ; } else { i ++ ; } } res = res + util ( s . Substring ( j , i - j ) ) ; Console . WriteLine ( res ) ; } public static String util ( String sub ) { int n = sub . Length ; int i = 0 ; String ret = " " ; while ( i < n ) { int t = ( sub [ i ] - ' a ' ) + n - 1 - i ; char ch = ( char ) ( t % 26 + 97 ) ; ret = ret + String . Join ( " " , ch ) ; i ++ ; } return ret ; } public static void Main ( String [ ] args ) { String s = " acm ▁ fkz " ; manipulate ( s ) ; } }

Index/key variables: i
Accumulator variables: i, res
Class/struct names: GFG
C# program:
using System ; class GFG { static void countSmaller ( String str ) { int n = str . Length ; int [ ] arr = new int [ 26 ] ; int [ ] ans = new int [ n ] ; for ( int i = n - 1 ; i >= 0 ; i -- ) { arr [ str [ i ] - ' a ' ] ++ ; int ct = 0 ; for ( int j = 0 ; j < str [ i ] - ' a ' ; j ++ ) { ct += arr [ j ] ; } ans [ i ] = ct ; } for ( int i = 0 ; i < n ; i ++ ) { Console . Write ( ans [ i ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { String str = " edcbaa " ; countSmaller ( str ) ; } }

Index/key variables: i, j, n
Accumulator variables: ct, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class Node { public Node ( char data , Node next ) { Data = data ; Next = next ; } public char Data ; public Node Next ; } class GFG { private static Node CreateList ( String s ) { Node header = null ; Node temp = null ; for ( int i = 0 ; i < s . Length ; i ++ ) { char c = s [ i ] ; Node node = new Node ( c , null ) ; if ( header == null ) { header = node ; temp = header ; } else { temp . Next = node ; temp = temp . Next ; } } return header ; } private static Node Reverse ( Node header ) { if ( header == null ) return header ; Node wordStartPosition = null ; Node endOfSentence = null ; Node sentenceStartPosition = null ; wordStartPosition = header ; while ( header != null && header . Data != ' ▁ ' ) { endOfSentence = header ; header = header . Next ; } if ( header == null ) { header = wordStartPosition ; return header ; } do { Node temp = header . Next ; header . Next = wordStartPosition ; wordStartPosition = header ; header = temp ; Node prev = null ; sentenceStartPosition = header ; while ( header != null && header . Data != ' ▁ ' ) { prev = header ; header = header . Next ; } prev . Next = wordStartPosition ; wordStartPosition = sentenceStartPosition ; if ( header == null ) break ; } while ( header != null ) ; header = sentenceStartPosition ; endOfSentence . Next = null ; return header ; } private static void PrintList ( Node Header ) { Node temp = Header ; while ( temp != null ) { Console . Write ( temp . Data ) ; temp = temp . Next ; } } public static void Main ( String [ ] args ) { String s = " practice ▁ makes ▁ a ▁ man ▁ perfect " ; Node header = CreateList ( s ) ; Console . WriteLine ( " Before : " ) ; PrintList ( header ) ; header = Reverse ( header ) ; Console . WriteLine ( " After : " PrintList ( header ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Node
C# program:
using System ; class GFG { static int [ ] z_function ( char [ ] s ) { int n = s . Length ; int [ ] z = new int [ n ] ; for ( int i = 1 , l = 0 , r = 0 ; i < n ; i ++ ) { if ( i <= r ) z [ i ] = Math . Min ( r - i + 1 , z [ i - l ] ) ; while ( i + z [ i ] < n && s [ z [ i ] ] == s [ i + z [ i ] ] ) z [ i ] ++ ; if ( i + z [ i ] - 1 > r ) { l = i ; r = i + z [ i ] - 1 ; } } return z ; } static int n , len = 0 ; static int [ ] bit = new int [ 1000005 ] ; static String s ; static int [ ] z ; static void update ( int idx , int val ) { if ( idx == 0 ) return ; while ( idx <= n ) { bit [ idx ] += val ; idx += ( idx & - idx ) ; } } static int pref ( int idx ) { int ans = 0 ; while ( idx > 0 ) { ans += bit [ idx ] ; idx -= ( idx & - idx ) ; } return ans ; } public static void Main ( String [ ] args ) { s = " geeksisforgeeksinplatformgeeks " ; z = new int [ s . Length ] ; n = s . Length ; z = z_function ( s . ToCharArray ( ) ) ; for ( int i = 1 ; i < n ; i ++ ) { update ( z [ i ] , 1 ) ; } for ( int i = n - 1 ; i > 1 ; i -- ) { if ( z [ i ] != ( n - i ) ) continue ; if ( pref ( n ) - pref ( z [ i ] - 1 ) >= 2 ) { len = Math . Max ( len , z [ i ] ) ; } } if ( len == 0 ) Console . WriteLine ( " - 1" ) ; else Console . WriteLine ( s . Substring ( 0 , len ) ) ; } }

Index/key variables: i, idx, n
Accumulator variables: ans, i, idx
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int endingWith ( string str , string suff ) { int cnt = 0 ; string [ ] sep = { " ▁ " } ; string [ ] words = str . Split ( sep , StringSplitOptions . RemoveEmptyEntries ) ; for ( int i = 0 ; i < words . Length ; i ++ ) { if ( words [ i ] . EndsWith ( suff ) ) cnt ++ ; } return cnt ; } public static void Main ( string [ ] args ) { string str = " GeeksForGeeks ▁ is ▁ a ▁ computer " + " ▁ science ▁ portal ▁ for ▁ geeks " ; string suff = " ks " ; Console . Write ( endingWith ( str , suff ) ) ; } }

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isFrequencyEqual ( String str , int len ) { if ( len % 2 == 1 ) { return false ; } int i ; int [ ] freq = new int [ 26 ] ; for ( i = 0 ; i < len ; i ++ ) { freq [ str [ i ] - ' a ' ] ++ ; } for ( i = 0 ; i < 26 ; i ++ ) { if ( freq [ i ] == len / 2 ) { return true ; } } return false ; } public static void Main ( ) { String str = " geeksforgeeks " ; int len = str . Length ; if ( isFrequencyEqual ( str , len ) ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static readonly int MAX = 26 ; static int countMinimalReplacements ( char [ ] s ) { int n = s . Length ; int cnt = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( s [ i ] == s [ i - 1 ] ) { cnt += 1 ; if ( i != ( n - 1 ) ) { foreach ( char it in "012" . ToCharArray ( ) ) { if ( it != s [ i + 1 ] && it != s [ i - 1 ] ) { s [ i ] = it ; break ; } } } { foreach ( char it in "012" . ToCharArray ( ) ) { if ( it != s [ i - 1 ] ) { s [ i ] = it ; break ; } } } } } return cnt ; } public static void Main ( String [ ] args ) { String s = "201220211" ; Console . WriteLine ( countMinimalReplacements ( s . ToCharArray ( ) ) ) ; } }

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i, it
Class/struct names: GFG
C# program:
using System ; public class GFG { static int nextIndex ( string str , int start , char c ) { for ( int i = start ; i < str . Length ; i ++ ) { if ( str [ i ] == c ) return i ; } return - 1 ; } static int countSubStrings ( string str ) { int i , n = str . Length ; int [ ] countX = new int [ n ] ; int count = 0 ; for ( i = n - 1 ; i >= 0 ; i -- ) { if ( str [ i ] == ' x ' ) count ++ ; countX [ i ] = count ; } int nextIndexX = nextIndex ( str , 0 , ' x ' ) ; int nextIndexY = nextIndex ( str , 0 , ' y ' ) ; count = 0 ; while ( nextIndexX != - 1 && nextIndexY != - 1 ) { if ( nextIndexX > nextIndexY ) { nextIndexY = nextIndex ( str , nextIndexY + 1 , ' y ' ) ; continue ; } else { count += countX [ nextIndexY ] ; nextIndexX = nextIndex ( str , nextIndexX + 1 , ' x ' ) ; } } return count ; } public static void Main ( ) { string s = " xyyxx " ; Console . WriteLine ( countSubStrings ( s ) ) ; } }

Index/key variables: i, n, nextIndexY
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool isPrime ( int n ) { int i ; if ( n == 1 ) { return false ; } for ( i = 2 ; i <= Math . Sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { return false ; } } return true ; } static bool check_frequency ( char [ ] s ) { Dictionary < char , int > m = new Dictionary < char , int > ( ) ; { if ( m . ContainsKey ( s [ i ] ) ) { var c = m [ s [ i ] ] + 1 ; m . Remove ( s [ i ] ) ; m . Add ( s [ i ] , c ) ; } else { m . Add ( s [ i ] , 1 ) ; } } for ( char ch = ' a ' ; ch <= ' z ' ; ch ++ ) { if ( m . ContainsKey ( ch ) && m [ ch ] > 0 && ! isPrime ( m [ ch ] ) ) { return false ; } } return true ; } public static void Main ( String [ ] args ) { String s = " geeksforgeeks " ; if ( check_frequency ( s . ToCharArray ( ) ) ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } }

Index/key variables: ch, i
Accumulator variables: ch, i
Iterator variables: ch, i
Class/struct names: GFG
C# program:
using System ; public class Solution { public static int findSubstringCount ( string str ) { int result = 0 ; int n = str . Length ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( ( char ) ( str [ i ] + 1 ) == str [ i + 1 ] ) { result ++ ; while ( ( char ) ( str [ i ] + 1 ) == str [ i + 1 ] ) { i ++ ; } } } return result ; } public static void Main ( string [ ] args ) { string str = " alphabet " ; Console . WriteLine ( findSubstringCount ( str ) ) ; } }

Index/key variables: i
Accumulator variables: i, result
Iterator variables: i
Class/struct names: Solution
C# program:
using System ; using System . Collections . Generic ; public class GFG { public static String reduced_String ( int k , String s ) { if ( k == 1 ) { return " " ; } Stack < Pair > st = new Stack < Pair > ( ) ; int l = s . Length ; for ( int i = 0 ; i < l ; i ++ ) { if ( st . Count == 0 ) { st . Push ( new Pair ( s [ i ] , 1 ) ) ; continue ; } if ( st . Peek ( ) . c == s [ i ] ) { Pair p = st . Peek ( ) ; st . Pop ( ) ; p . ctr += 1 ; if ( p . ctr == k ) { continue ; } else { st . Push ( p ) ; } } else { st . Push ( new Pair ( s [ i ] , 1 ) ) ; } } String ans = " " ; while ( st . Count > 0 ) { char c = st . Peek ( ) . c ; int cnt = st . Peek ( ) . ctr ; while ( cnt -- > 0 ) ans = c + ans ; st . Pop ( ) ; } return ans ; } public static void Main ( String [ ] args ) { int k = 2 ; String st = " geeksforgeeks " ; String ans = reduced_String ( k , st ) ; Console . Write ( ans ) ; } public class Pair { public char c ; public int ctr ; public Pair ( char c , int ctr ) { this . c = c ; this . ctr = ctr ; } } }

Index/key variables: i
Accumulator variables: cnt, ctr, i
Iterator variables: i
Class/struct names: GFG, Pair