dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int [ ] b = new int [ 50 ] ; static int PowerArray ( int n , int k ) { int count = 0 ; while ( k > 0 ) { if ( k % n == 0 ) { k /= n ; count ++ ; } else if ( k % n == 1 ) { k -= 1 ; b [ count ] ++ ; if ( b [ count ] > 1 ) { Console . Write ( - 1 ) ; return 0 ; } } else { Console . Write ( - 1 ) ; return 0 ; } } for ( int i = 0 ; i < 50 ; i ++ ) { if ( b [ i ] != 0 ) { Console . Write ( i + " , ▁ " ) ; } } return int . MinValue ; } public static void Main ( String [ ] args ) { int N = 3 ; int K = 40 ; PowerArray ( N , K ) ; } }

Index/key variables: count, i
Accumulator variables: count, i, k
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int findSum ( int N , int k ) { int sum = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { sum += ( int ) Math . Pow ( i , k ) ; } return sum ; } public static void Main ( string [ ] args ) { int N = 8 , k = 4 ; Console . WriteLine ( findSum ( N , k ) ) ; } }

Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countIndices ( int [ ] arr , int n ) { int cnt = 0 ; int max = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( max < arr [ i ] ) { max = arr [ i ] ; cnt ++ ; } } return cnt ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 } ; int n = arr . Length ; Console . WriteLine ( countIndices ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static String [ ] bin = { "000" , "001" , "010" , "011" , "100" , "101" , "110" , "111" } ; static int maxFreq ( String s ) { String binary = " " ; for ( int K = 0 ; K < s . Length ; K ++ ) { binary += bin [ s [ K ] - '0' ] ; } binary = binary . Substring ( 0 , binary . Length - 1 ) ; int count = 1 , prev = - 1 , i , j = 0 ; for ( i = binary . Length - 1 ; i >= 0 ; i -- , j ++ ) if ( binary [ i ] == '1' ) { count = Math . Max ( count , j - prev ) ; prev = j ; } return count ; } public static void Main ( String [ ] args ) { String octal = "13" ; Console . WriteLine ( maxFreq ( octal ) ) ; } }

Index/key variables: K, i
Accumulator variables: K, binary, i, j
Iterator variables: K, i
Class/struct names: GFG
C# program:
using System ; class GFG { static int sz = 100000 ; static bool [ ] isPrime = new bool [ sz + 1 ] ; static void sieve ( ) { for ( int i = 0 ; i <= sz ; i ++ ) isPrime [ i ] = true ; isPrime [ 0 ] = isPrime [ 1 ] = false ; for ( int i = 2 ; i * i <= sz ; i ++ ) { if ( isPrime [ i ] ) { for ( int j = i * i ; j < sz ; j += i ) { isPrime [ j ] = false ; } } } } static void findPrimesD ( int d ) { int left = ( int ) Math . Pow ( 10 , d - 1 ) ; int right = ( int ) Math . Pow ( 10 , d ) - 1 ; for ( int i = left ; i <= right ; i ++ ) { if ( isPrime [ i ] ) { Console . Write ( i + " ▁ " ) ; } } } static public void Main ( ) { sieve ( ) ; int d = 1 ; findPrimesD ( d ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static int Cells ( int n , int x ) { if ( n <= 0 x <= 0 x > n * n ) return 0 ; int i = 0 , count = 0 ; while ( ++ i * i < x ) if ( x % i == 0 && x <= n * i ) count += 2 ; return i * i == x ? count + 1 : count ; } static public void Main ( ) { int n = 6 , x = 12 ; Console . WriteLine ( Cells ( n , x ) ) ; } }

Accumulator variables: count
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxOfMin ( int [ ] a , int n , int S ) { int mi = int . MaxValue ; int s1 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { s1 += a [ i ] ; mi = Math . Min ( a [ i ] , mi ) ; } if ( s1 < S ) return - 1 ; if ( s1 == S ) return 0 ; int low = 0 ; int high = mi ; int ans = 0 ; while ( low <= high ) { int mid = ( low + high ) / 2 ; if ( s1 - ( mid * n ) >= S ) { ans = mid ; low = mid + 1 ; } else high = mid - 1 ; } return ans ; } public static void Main ( ) { int [ ] a = { 10 , 10 , 10 , 10 , 10 } ; int S = 10 ; int n = a . Length ; Console . WriteLine ( maxOfMin ( a , n , S ) ) ; } }

Index/key variables: i
Accumulator variables: i, s1
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void Alphabet_N_Pattern ( int N ) { int index , side_index ; int Right = 1 , Left = 1 , Diagonal = 2 ; for ( index = 0 ; index < N ; index ++ ) { Console . Write ( Left ++ ) ; for ( side_index = 0 ; side_index < 2 * ( index ) ; side_index ++ ) Console . Write ( " ▁ " ) ; if ( index != 0 && index != N - 1 ) Console . Write ( Diagonal ++ ) ; else Console . Write ( " ▁ " ) ; for ( side_index = 0 ; side_index < 2 * ( N - index - 1 ) ; side_index ++ ) Console . Write ( " ▁ " ) ; Console . Write ( Right ++ ) ; Console . Write ( " STRNEWLINE " ) ; } } static void Main ( ) { int Size = 6 ; Alphabet_N_Pattern ( Size ) ; } }

Accumulator variables: Diagonal, Left, Right, index, side_index
Iterator variables: index, side_index
Class/struct names: GFG
C# program:
using System ; class GFG { public int isSumDivides ( int N ) { int temp = N , sum = 0 ; while ( temp > 0 ) { sum += temp % 10 ; temp /= 10 ; } if ( N % sum == 0 ) return 1 ; else return 0 ; } public static void Main ( ) { GFG g = new GFG ( ) ; int N = 12 ; if ( g . isSumDivides ( N ) > 0 ) Console . WriteLine ( " YES " ) ; else Console . WriteLine ( " NO " ) ; } }

Accumulator variables: sum, temp
Class/struct names: GFG
C# program:
using System ; class GFG { static int sum ( int N ) { int S1 , S2 , S3 ; S1 = ( ( N / 3 ) ) * ( 2 * 3 + ( N / 3 - 1 ) * 3 ) / 2 ; S2 = ( ( N / 4 ) ) * ( 2 * 4 + ( N / 4 - 1 ) * 4 ) / 2 ; S3 = ( ( N / 12 ) ) * ( 2 * 12 + ( N / 12 - 1 ) * 12 ) / 2 ; return S1 + S2 - S3 ; } public static void Main ( ) { int N = 20 ; Console . WriteLine ( sum ( 12 ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int nextGreater ( int N ) { int power_of_2 = 1 , shift_count = 0 ; while ( true ) { if ( ( ( N >> shift_count ) & 1 ) % 2 == 0 ) break ; shift_count ++ ; power_of_2 = power_of_2 * 2 ; } return ( N + power_of_2 ) ; } public static void Main ( ) { int N = 11 ; Console . WriteLine ( " The ▁ next ▁ number ▁ is ▁ = ▁ " + nextGreater ( N ) ) ; } }

Accumulator variables: shift_count
Class/struct names: GFG
C# program:
using System ; class GFG { static int countWays ( int n ) { if ( n == 0 ) return 1 ; if ( n <= 2 ) return n ; int f0 = 1 , f1 = 1 , f2 = 2 ; int ans = 0 ; for ( int i = 3 ; i <= n ; i ++ ) { ans = f0 + f1 + f2 ; f0 = f1 ; f1 = f2 ; f2 = ans ; } return ans ; } public static void Main ( String [ ] args ) { int n = 4 ; Console . WriteLine ( countWays ( n ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int n = 6 , m = 6 ; static void maxSum ( long [ , ] arr ) { long [ , ] dp = new long [ n + 1 , 3 ] ; for ( int i = 0 ; i < n ; i ++ ) { long m1 = 0 , m2 = 0 , m3 = 0 ; for ( int j = 0 ; j < m ; j ++ ) { if ( ( j / ( m / 3 ) ) == 0 ) { m1 = Math . Max ( m1 , arr [ i , j ] ) ; } else if ( ( j / ( m / 3 ) ) == 1 ) { m2 = Math . Max ( m2 , arr [ i , j ] ) ; } else if ( ( j / ( m / 3 ) ) == 2 ) { m3 = Math . Max ( m3 , arr [ i , j ] ) ; } } dp [ i + 1 , 0 ] = Math . Max ( dp [ i , 1 ] , dp [ i , 2 ] ) + m1 ; dp [ i + 1 , 1 ] = Math . Max ( dp [ i , 0 ] , dp [ i , 2 ] ) + m2 ; dp [ i + 1 , 2 ] = Math . Max ( dp [ i , 1 ] , dp [ i , 0 ] ) + m3 ; } Console . Write ( Math . Max ( Math . Max ( dp [ n , 0 ] , dp [ n , 1 ] ) , dp [ n , 2 ] ) + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { long [ , ] arr = { { 1 , 3 , 5 , 2 , 4 , 6 } , { 6 , 4 , 5 , 1 , 3 , 2 } , { 1 , 3 , 5 , 2 , 4 , 6 } , { 6 , 4 , 5 , 1 , 3 , 2 } , { 6 , 4 , 5 , 1 , 3 , 2 } , { 1 , 3 , 5 , 2 , 4 , 6 } } ; maxSum ( arr ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void solve ( char [ ] s ) { int n = s . Length ; int [ , ] dp = new int [ n , n ] ; for ( int len = n - 1 ; len >= 0 ; -- len ) { for ( int i = 0 ; i + len < n ; ++ i ) { int j = i + len ; if ( i == 0 && j == n - 1 ) { if ( s [ i ] == s [ j ] ) dp [ i , j ] = 2 ; else if ( s [ i ] != s [ j ] ) dp [ i , j ] = 1 ; } else { if ( s [ i ] == s [ j ] ) { if ( i - 1 >= 0 ) { dp [ i , j ] += dp [ i - 1 , j ] ; } if ( j + 1 <= n - 1 ) { dp [ i , j ] += dp [ i , j + 1 ] ; } if ( i - 1 < 0 j + 1 >= n ) { dp [ i , j ] += 1 ; } } else if ( s [ i ] != s [ j ] ) { if ( i - 1 >= 0 ) { dp [ i , j ] += dp [ i - 1 , j ] ; } if ( j + 1 <= n - 1 ) { dp [ i , j ] += dp [ i , j + 1 ] ; } if ( i - 1 >= 0 && j + 1 <= n - 1 ) { dp [ i , j ] -= dp [ i - 1 , j + 1 ] ; } } } } } List < int > ways = new List < int > ( ) ; for ( int i = 0 ; i < n ; ++ i ) { if ( i == 0 i == n - 1 ) { ways . Add ( 1 ) ; } else { int total = dp [ i - 1 , i + 1 ] ; ways . Add ( total ) ; } } for ( int i = 0 ; i < ways . Capacity ; ++ i ) { Console . Write ( ways [ i ] + " ▁ " ) ; } } public static void Main ( ) { char [ ] s = " xyxyx " . ToCharArray ( ) ; solve ( s ) ; } }

Index/key variables: i, j
Iterator variables: i, len
Class/struct names: GFG
C# program:
using System ; class GFG { static long getChicks ( int n ) { int size = Math . Max ( n , 7 ) ; long [ ] dp = new long [ size ] ; dp [ 0 ] = 0 ; dp [ 1 ] = 1 ; for ( int i = 2 ; i < 6 ; i ++ ) { dp [ i ] = dp [ i - 1 ] * 3 ; } dp [ 6 ] = 726 ; for ( int i = 8 ; i <= n ; i ++ ) { dp [ i ] = ( dp [ i - 1 ] - ( 2 * dp [ i - 6 ] / 3 ) ) * 3 ; } return dp [ n ] ; } static public void Main ( ) { int n = 3 ; Console . WriteLine ( getChicks ( n ) ) ; } }

Index/key variables: i, n, size
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int getChicks ( int n ) { int chicks = ( int ) Math . Pow ( 3 , n - 1 ) ; return chicks ; } public static void Main ( ) { int n = 3 ; Console . WriteLine ( getChicks ( n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int n = 3 ; static int [ , ] dp = new int [ n , n ] ; static int [ , ] v = new int [ n , n ] ; static int minSteps ( int i , int j , int [ , ] arr ) { if ( i == n - 1 && j == n - 1 ) { return 0 ; } if ( i > n - 1 j > n - 1 ) { return 9999999 ; } if ( v [ i , j ] == 1 ) { return dp [ i , j ] ; } v [ i , j ] = 1 ; dp [ i , j ] = 9999999 ; for ( int k = Math . Max ( 0 , arr [ i , j ] + j - n + 1 ) ; k <= Math . Min ( n - i - 1 , arr [ i , j ] ) ; k ++ ) { dp [ i , j ] = Math . Min ( dp [ i , j ] , minSteps ( i + k , j + arr [ i , j ] - k , arr ) ) ; } dp [ i , j ] ++ ; return dp [ i , j ] ; } static public void Main ( ) { int [ , ] arr = { { 4 , 1 , 2 } , { 1 , 1 , 1 } , { 2 , 1 , 1 } } ; int ans = minSteps ( 0 , 0 , arr ) ; if ( ans >= 9999999 ) { Console . WriteLine ( - 1 ) ; } else { Console . WriteLine ( ans ) ; } } }

Accumulator variables: k
Iterator variables: k
Class/struct names: GFG
C# program:
using System ; class GFG { static int n = 3 ; static int [ , ] dp = new int [ n , n ] ; static int [ , ] v = new int [ n , n ] ; static int minSteps ( int i , int j , int [ , ] arr ) { if ( i == n - 1 && j == n - 1 ) { return 0 ; } if ( i > n - 1 j > n - 1 ) { return 9999999 ; } if ( v [ i , j ] == 1 ) { return dp [ i , j ] ; } v [ i , j ] = 1 ; dp [ i , j ] = 1 + Math . Min ( minSteps ( i + arr [ i , j ] , j , arr ) , minSteps ( i , j + arr [ i , j ] , arr ) ) ; return dp [ i , j ] ; } static public void Main ( ) { int [ , ] arr = { { 2 , 1 , 2 } , { 1 , 1 , 1 } , { 1 , 1 , 1 } } ; int ans = minSteps ( 0 , 0 , arr ) ; if ( ans >= 9999999 ) { Console . WriteLine ( - 1 ) ; } else { Console . WriteLine ( ans ) ; } } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 1001 ; static int [ , ] dp = new int [ MAX , MAX ] ; static int MaxProfit ( int [ ] treasure , int [ ] color , int n , int k , int col , int A , int B ) { return dp [ k , col ] = 0 ; if ( dp [ k , col ] != - 1 ) return dp [ k , col ] ; int sum = 0 ; if ( col == color [ k ] ) sum += Math . Max ( A * treasure [ k ] + MaxProfit ( treasure , color , n , k + 1 , color [ k ] , A , B ) , MaxProfit ( treasure , color , n , k + 1 , col , A , B ) ) ; else sum += Math . Max ( B * treasure [ k ] + MaxProfit ( treasure , color , n , k + 1 , color [ k ] , A , B ) , MaxProfit ( treasure , color , n , k + 1 , col , A , B ) ) ; return dp [ k , col ] = sum ; } public static void Main ( String [ ] args ) { int A = - 5 , B = 7 ; int [ ] treasure = { 4 , 8 , 2 , 9 } ; int [ ] color = { 2 , 2 , 6 , 2 } ; int n = color . Length ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < MAX ; j ++ ) dp [ i , j ] = - 1 ; Console . Write ( MaxProfit ( treasure , color , n , 0 , 0 , A , B ) ) ; } }

Index/key variables: k
Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
class GFG { static void printTetra ( int n ) { int [ ] dp = new int [ n + 5 ] ; dp [ 0 ] = 0 ; dp [ 1 ] = dp [ 2 ] = 1 ; dp [ 3 ] = 2 ; for ( int i = 4 ; i <= n ; i ++ ) dp [ i ] = dp [ i - 1 ] + dp [ i - 2 ] + dp [ i - 3 ] + dp [ i - 4 ] ; System . Console . WriteLine ( dp [ n ] ) ; } static void Main ( ) { int n = 10 ; printTetra ( n ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxSum1 ( int [ ] arr , int n ) { int [ ] dp = new int [ n ] ; int maxi = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { dp [ i ] = arr [ i ] ; if ( maxi < arr [ i ] ) maxi = arr [ i ] ; } for ( int i = 2 ; i < n - 1 ; i ++ ) { for ( int j = 0 ; j < i - 1 ; j ++ ) { if ( dp [ i ] < dp [ j ] + arr [ i ] ) { dp [ i ] = dp [ j ] + arr [ i ] ; if ( maxi < dp [ i ] ) maxi = dp [ i ] ; } } } return maxi ; } static int maxSum2 ( int [ ] arr , int n ) { int [ ] dp = new int [ n ] ; int maxi = 0 ; for ( int i = 1 ; i < n ; i ++ ) { dp [ i ] = arr [ i ] ; if ( maxi < arr [ i ] ) maxi = arr [ i ] ; } for ( int i = 3 ; i < n ; i ++ ) { for ( int j = 1 ; j < i - 1 ; j ++ ) { if ( dp [ i ] < arr [ i ] + dp [ j ] ) { dp [ i ] = arr [ i ] + dp [ j ] ; if ( maxi < dp [ i ] ) maxi = dp [ i ] ; } } } return maxi ; } static int findMaxSum ( int [ ] arr , int n ) { int t = Math . Max ( maxSum1 ( arr , n ) , maxSum2 ( arr , n ) ) ; return t ; } static public void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 1 } ; int n = arr . Length ; Console . WriteLine ( findMaxSum ( 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 permutationCoeff ( int n , int k ) { int [ , ] P = new int [ n + 2 , k + 2 ] ; for ( int i = 0 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= Math . Min ( i , k ) ; j ++ ) { if ( j == 0 ) P [ i , j ] = 1 ; else P [ i , j ] = P [ i - 1 , j ] + ( j * P [ i - 1 , j - 1 ] ) ; P [ i , j + 1 ] = 0 ; } } return P [ n , k ] ; } public static void Main ( ) { int n = 10 , k = 2 ; Console . WriteLine ( " Value ▁ of ▁ P ( ▁ " + n + " , " + k + " ) " + " ▁ is ▁ " + permutationCoeff ( n , k ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { static int permutationCoeff ( int n , int k ) { int [ ] fact = new int [ n + 1 ] ; fact [ 0 ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) fact [ i ] = i * fact [ i - 1 ] ; return fact [ n ] / fact [ n - k ] ; } static public void Main ( ) { int n = 10 , k = 2 ; Console . WriteLine ( " Value ▁ of " + " ▁ P ( ▁ " + n + " , ▁ " + k + " ) ▁ is ▁ " + permutationCoeff ( n , k ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isSubsetSum ( int [ ] set , int n , int sum ) { if ( sum == 0 ) return true ; if ( n == 0 ) return false ; if ( set [ n - 1 ] > sum ) return isSubsetSum ( set , n - 1 , sum ) ; return isSubsetSum ( set , n - 1 , sum ) || isSubsetSum ( set , n - 1 , sum - set [ n - 1 ] ) ; } public static void Main ( ) { int [ ] set = { 3 , 34 , 4 , 12 , 5 , 2 } ; int sum = 9 ; int n = set . Length ; if ( isSubsetSum ( set , n , sum ) == true ) Console . WriteLine ( " Found ▁ a ▁ subset ▁ with ▁ given ▁ sum " ) ; else Console . WriteLine ( " No ▁ subset ▁ with ▁ given ▁ sum " ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { public static void compute_z ( string s , int [ ] z ) { int l = 0 , r = 0 ; int n = s . Length ; for ( int i = 1 ; i <= n - 1 ; i ++ ) { if ( i > r ) { l = i ; r = i ; while ( r < n && s [ r - l ] == s [ r ] ) { r ++ ; } z [ i ] = r - l ; r -- ; } else { int k = i - l ; if ( z [ k ] < r - i + 1 ) { z [ i ] = z [ k ] ; } else { l = i ; while ( r < n && s [ r - l ] == s [ r ] ) { r ++ ; } z [ i ] = r - l ; r -- ; } } } } public static int countPermutation ( string a , string b ) { b = b + b ; b = b . Substring ( 0 , b . Length - 1 ) ; int ans = 0 ; string s = a + " $ " + b ; int n = s . Length ; int [ ] z = new int [ n ] ; compute_z ( s , z ) ; for ( int i = 1 ; i <= n - 1 ; i ++ ) { if ( z [ i ] == a . Length ) { ans ++ ; } } return ans ; } public static void Main ( string [ ] args ) { string a = "101" ; string b = "101" ; Console . WriteLine ( countPermutation ( a , b ) ) ; } }

Index/key variables: i, k, n, r
Accumulator variables: ans, i, r
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static void smallestSubsequence ( char [ ] S , int K ) { int N = S . Length ; Stack < char > answer = new Stack < char > ( ) ; for ( int i = 0 ; i < N ; ++ i ) { if ( answer . Count == 0 ) { answer . Push ( S [ i ] ) ; } else { while ( ( answer . Count != 0 ) && ( S [ i ] < answer . Peek ( ) ) && ( answer . Count - 1 + N - i >= K ) ) { answer . Pop ( ) ; } if ( answer . Count == 0 answer . Count < K ) { answer . Push ( S [ i ] ) ; } } } String ret = " " ; while ( answer . Count != 0 ) { ret += ( answer . Peek ( ) ) ; answer . Pop ( ) ; } ret = reverse ( ret ) ; Console . Write ( ret ) ; } static String reverse ( String input ) { char [ ] a = input . ToCharArray ( ) ; int l , r = a . Length - 1 ; for ( l = 0 ; l < r ; l ++ , r -- ) { char temp = a [ l ] ; a [ l ] = a [ r ] ; a [ r ] = temp ; } return String . Join ( " " , a ) ; } public static void Main ( String [ ] args ) { String S = " aabdaabc " ; int K = 3 ; smallestSubsequence ( S . ToCharArray ( ) , K ) ; } }

Index/key variables: i, l, r
Accumulator variables: l, r, ret
Iterator variables: i, l
Class/struct names: GFG
C# program:
using System ; class GFG { public static bool is_rtol ( String s ) { int tmp = ( int ) ( Math . Sqrt ( s . Length ) ) - 1 ; char first = s [ tmp ] ; for ( int pos = tmp ; pos < s . Length - 1 ; pos += tmp ) { if ( s [ pos ] != first ) { return false ; } } return true ; } public static void Main ( String [ ] args ) { String str = " abcxabxcaxbcxabc " ; if ( is_rtol ( str ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }

Index/key variables: pos, tmp
Accumulator variables: pos
Iterator variables: pos
Class/struct names: GFG
C# program:
using System ; class GFG { static bool check ( string str , int K ) { if ( str . Length % K == 0 ) { int sum = 0 , i ; for ( i = 0 ; i < K ; i ++ ) { sum += str [ i ] ; } for ( int j = i ; j < str . Length ; j += K ) { int s_comp = 0 ; for ( int p = j ; p < j + K ; p ++ ) s_comp += str [ p ] ; if ( s_comp != sum ) return false ; } return true ; } return false ; } public static void Main ( string [ ] args ) { int K = 3 ; string str = " abdcbbdba " ; if ( check ( str , K ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Index/key variables: i, p
Accumulator variables: i, j, p, s_comp, sum
Iterator variables: i, j, p
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxSum ( string str ) { int maximumSum = 0 ; int totalOnes = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) { if ( str [ i ] == '1' ) { totalOnes ++ ; } } int zero = 0 , ones = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) { if ( str [ i ] == '0' ) { zero ++ ; } else { ones ++ ; } maximumSum = Math . Max ( maximumSum , zero + ( totalOnes - ones ) ) ; } return maximumSum ; } public static void Main ( string [ ] args ) { string str = "011101" ; Console . Write ( maxSum ( str ) ) ; } }

Index/key variables: i
Accumulator variables: i, ones, totalOnes, zero
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxLenSubStr ( String s ) { if ( s . Length < 3 ) return s . Length ; int temp = 2 ; int ans = 2 ; for ( int i = 2 ; i < s . Length ; i ++ ) { if ( s [ i ] != s [ i - 1 ] s [ i ] != s [ i - 2 ] ) temp ++ ; else { ans = Math . Max ( temp , ans ) ; temp = 2 ; } } ans = Math . Max ( temp , ans ) ; return ans ; } static public void Main ( ) { String s = " baaabbabbb " ; Console . Write ( maxLenSubStr ( s ) ) ; } }

Index/key variables: i
Accumulator variables: i, temp
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int no_of_ways ( string s ) { int n = s . Length ; int count_left = 0 , count_right = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( s [ i ] == s [ 0 ] ) { ++ count_left ; } else break ; } for ( int i = n - 1 ; i >= 0 ; -- i ) { if ( s [ i ] == s [ n - 1 ] ) { ++ count_right ; } else break ; } if ( s [ 0 ] == s [ n - 1 ] ) return ( ( count_left + 1 ) * ( count_right + 1 ) ) ; else return ( count_left + count_right + 1 ) ; } public static void Main ( ) { string s = " geeksforgeeks " ; Console . WriteLine ( no_of_ways ( s ) ) ; } }

Index/key variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void preCompute ( int n , string s , int [ ] pref ) { pref [ 0 ] = 0 ; for ( int i = 1 ; i < n ; i ++ ) { pref [ i ] = pref [ i - 1 ] ; if ( s [ i - 1 ] == s [ i ] ) pref [ i ] ++ ; } } static int query ( int [ ] pref , int l , int r ) { return pref [ r ] - pref [ l ] ; } public static void Main ( ) { string s = " ggggggg " ; int n = s . Length ; int [ ] pref = new int [ n ] ; preCompute ( n , s , pref ) ; int l = 1 ; int r = 2 ; Console . WriteLine ( query ( pref , l , r ) ) ; l = 1 ; r = 5 ; Console . WriteLine ( query ( pref , l , r ) ) ; } }

Index/key variables: i, l, n, r
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static String findDirection ( String s ) { int count = 0 ; String d = " " ; for ( int i = 0 ; i < s . Length ; i ++ ) { if ( s [ 0 ] == ' STRNEWLINE ' ) return null ; if ( s [ i ] == ' L ' ) count -- ; else { if ( s [ i ] == ' R ' ) count ++ ; } } if ( count > 0 ) { if ( count % 4 == 0 ) d = " N " ; else if ( count % 4 == 1 ) d = " E " ; else if ( count % 4 == 2 ) d = " S " ; else if ( count % 4 == 3 ) d = " W " ; } if ( count < 0 ) { if ( count % 4 == 0 ) d = " N " ; else if ( count % 4 == - 1 ) d = " W " ; else if ( count % 4 == - 2 ) d = " S " ; else if ( count % 4 == - 3 ) d = " E " ; } return d ; } public static void Main ( ) { String s = " LLRLRRL " ; Console . WriteLine ( findDirection ( s ) ) ; s = " LL " ; Console . WriteLine ( findDirection ( s ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isCheck ( string str ) { int len = str . Length ; string lowerStr = " " , upperStr = " " ; char [ ] str1 = str . ToCharArray ( ) ; for ( int i = 0 ; i < len ; i ++ ) { if ( ( int ) ( str1 [ i ] ) >= 65 && ( int ) str1 [ i ] <= 91 ) upperStr = upperStr + str1 [ i ] ; else lowerStr = lowerStr + str1 [ i ] ; } String transformStr = lowerStr . ToUpper ( ) ; return ( transformStr . Equals ( upperStr ) ) ; } public static void Main ( String [ ] args ) { String str = " geeGkEEsKS " ; if ( isCheck ( str ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

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