dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static Boolean strmatch ( char [ ] txt , char [ ] pat , int n , int m ) { if ( m == 0 ) return ( n == 0 ) ; int i = 0 , j = 0 , index_txt = - 1 , index_pat = - 1 ; while ( i < n ) { if ( j < m && txt [ i ] == pat [ j ] ) { i ++ ; j ++ ; } else if ( j < m && pat [ j ] == ' ? ' ) { i ++ ; j ++ ; } else if ( j < m && pat [ j ] == ' * ' ) { index_txt = i ; index_pat = j ; j ++ ; } else if ( index_pat != - 1 ) { j = index_pat + 1 ; i = index_txt + 1 ; index_txt ++ ; } else { return false ; } } while ( j < m && pat [ j ] == ' * ' ) { j ++ ; } if ( j == m ) { return true ; } return false ; } public static void Main ( String [ ] args ) { char [ ] str = " baaabab " . ToCharArray ( ) ; char [ ] pattern = " * * * * * ba * * * * * ab " . ToCharArray ( ) ; char pattern [ ] = " ba * * * * * ab " ; char pattern [ ] = " ba * ab " ; char pattern [ ] = " a * ab " ; if ( strmatch ( str , pattern , str . Length , pattern . Length ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; char [ ] pattern2 = " a * * * * * ab " . ToCharArray ( ) ; if ( strmatch ( str , pattern2 , str . Length , pattern2 . Length ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i, j
Accumulator variables: i, index_txt, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int findSDSFunc ( int n ) { int [ ] DP = new int [ n + 1 ] ; DP [ 0 ] = 0 ; DP [ 1 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { if ( i % 2 == 0 ) DP [ i ] = DP [ i / 2 ] ; else DP [ i ] = DP [ ( i - 1 ) / 2 ] + DP [ ( i + 1 ) / 2 ] ; } return DP [ n ] ; } static public void Main ( ) { int n = 15 ; Console . WriteLine ( findSDSFunc ( n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 100 ; static int isPossible ( int n , int index , int modulo , int M , int [ ] arr , int [ , ] dp ) { modulo = ( ( modulo % M ) + M ) % M ; if ( index == n ) { if ( modulo == 0 ) { return 1 ; } return 0 ; } if ( dp [ index , modulo ] != - 1 ) { return dp [ index , modulo ] ; } int placeAdd = isPossible ( n , index + 1 , modulo + arr [ index ] , M , arr , dp ) ; int placeMinus = isPossible ( n , index + 1 , modulo - arr [ index ] , M , arr , dp ) ; int res = placeAdd ; dp [ index , modulo ] = res ; return res ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 6 } ; int n = arr . Length ; int M = 4 ; int [ , ] dp = new int [ n + 1 , MAX ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) { for ( int j = 0 ; j < MAX ; j ++ ) { dp [ i , j ] = - 1 ; } } bool res ; if ( isPossible ( n , 1 , arr [ 0 ] , M , arr , dp ) == 1 ) { res = true ; } else { res = false ; } Console . WriteLine ( res ? " True " : " False " ) ; } }

Index/key variables: index
Accumulator variables: i, j
Iterator variables: i, j
Boolean variables: res
Class/struct names: GFG
C# program:
using System ; class GFG { static void findCommon ( int [ ] ar1 , int [ ] ar2 , int [ ] ar3 ) { int i = 0 , j = 0 , k = 0 ; while ( i < ar1 . Length && j < ar2 . Length && k < ar3 . Length ) { if ( ar1 [ i ] == ar2 [ j ] && ar2 [ j ] == ar3 [ k ] ) { Console . Write ( ar1 [ i ] + " ▁ " ) ; i ++ ; j ++ ; k ++ ; } else if ( ar1 [ i ] < ar2 [ j ] ) i ++ ; else if ( ar2 [ j ] < ar3 [ k ] ) j ++ ; else k ++ ; } } public static void Main ( ) { int [ ] ar1 = { 1 , 5 , 10 , 20 , 40 , 80 } ; int [ ] ar2 = { 6 , 7 , 20 , 80 , 100 } ; int [ ] ar3 = { 3 , 4 , 15 , 20 , 30 , 70 , 80 , 120 } ; Console . Write ( " Common ▁ elements ▁ are ▁ " ) ; findCommon ( ar1 , ar2 , ar3 ) ; } }

Index/key variables: i, j, k
Accumulator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int [ ] dp = new int [ 100 ] ; static void dfs ( int [ ] a , List < int > [ ] v , int u , int parent ) { dp [ u ] = a [ u - 1 ] ; int maximum = 0 ; foreach ( int child in v [ u ] ) { if ( child == parent ) continue ; dfs ( a , v , child , u ) ; maximum = Math . Max ( maximum , dp [ child ] ) ; } dp [ u ] += maximum ; } static int maximumValue ( int [ ] a , List < int > [ ] v ) { dfs ( a , v , 1 , 0 ) ; return dp [ 1 ] ; } public static void Main ( String [ ] args ) { int n = 14 ; List < int > [ ] v = new List < int > [ n + 1 ] ; for ( int i = 0 ; i < v . Length ; i ++ ) v [ i ] = new List < int > ( ) ; v [ 1 ] . Add ( 2 ) ; v [ 2 ] . Add ( 1 ) ; v [ 1 ] . Add ( 3 ) ; v [ 3 ] . Add ( 1 ) ; v [ 1 ] . Add ( 4 ) ; v [ 4 ] . Add ( 1 ) ; v [ 2 ] . Add ( 5 ) ; v [ 5 ] . Add ( 2 ) ; v [ 2 ] . Add ( 6 ) ; v [ 6 ] . Add ( 2 ) ; v [ 3 ] . Add ( 7 ) ; v [ 7 ] . Add ( 3 ) ; v [ 4 ] . Add ( 8 ) ; v [ 8 ] . Add ( 4 ) ; v [ 4 ] . Add ( 9 ) ; v [ 9 ] . Add ( 4 ) ; v [ 4 ] . Add ( 10 ) ; v [ 10 ] . Add ( 4 ) ; v [ 5 ] . Add ( 11 ) ; v [ 11 ] . Add ( 5 ) ; v [ 5 ] . Add ( 12 ) ; v [ 12 ] . Add ( 5 ) ; v [ 7 ] . Add ( 13 ) ; v [ 13 ] . Add ( 7 ) ; v [ 7 ] . Add ( 14 ) ; v [ 14 ] . Add ( 7 ) ; int [ ] a = { 3 , 2 , 1 , 10 , 1 , 3 , 9 , 1 , 5 , 3 , 4 , 5 , 9 , 8 } ; Console . WriteLine ( maximumValue ( a , v ) ) ; } }

Index/key variables: child, i, u
Accumulator variables: i
Iterator variables: child, i
Class/struct names: GFG
C# program:
using System ; public class GfG { public static int Jacobsthal ( int n ) { int [ ] dp = new int [ n + 1 ] ; dp [ 0 ] = 0 ; dp [ 1 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) dp [ i ] = dp [ i - 1 ] + 2 * dp [ i - 2 ] ; return dp [ n ] ; } public static int Jacobsthal_Lucas ( int n ) { int [ ] dp = new int [ n + 1 ] ; dp [ 0 ] = 2 ; dp [ 1 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) dp [ i ] = dp [ i - 1 ] + 2 * dp [ i - 2 ] ; return dp [ n ] ; } public static void Main ( ) { int n = 5 ; Console . WriteLine ( " Jacobsthal ▁ number : ▁ " + Jacobsthal ( n ) ) ; Console . WriteLine ( " Jacobsthal - Lucas ▁ number : ▁ " + Jacobsthal_Lucas ( n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GfG
C# program:
using System ; class GFG { static int binarySearch ( int [ ] arr , int l , int r , int x ) { if ( r >= l ) { int mid = l + ( r - l ) / 2 ; if ( arr [ mid ] == x ) return mid ; if ( arr [ mid ] > x ) return binarySearch ( arr , l , mid - 1 , x ) ; return binarySearch ( arr , mid + 1 , r , x ) ; } return - 1 ; } static int findPos ( int [ ] arr , int key ) { int l = 0 , h = 1 ; int val = arr [ 0 ] ; while ( val < key ) { l = h ; h = 2 * h ; val = arr [ h ] ; } return binarySearch ( arr , l , h , key ) ; } public static void Main ( ) { int [ ] arr = new int [ ] { 3 , 5 , 7 , 9 , 10 , 90 , 100 , 130 , 140 , 160 , 170 } ; int ans = findPos ( arr , 10 ) ; if ( ans == - 1 ) Console . Write ( " Element ▁ not ▁ found " ) ; else Console . Write ( " Element ▁ found ▁ at ▁ " + " index ▁ " + ans ) ; } }

Index/key variables: h, mid
Class/struct names: GFG
C# program:
using System ; class GFG { static int depth = 14 ; static int [ , , ] ways = new int [ 16 , 16 , 16 ] ; static int stepNum ; static void preprocess ( int [ ] list ) { ways [ 0 , 8 , 8 ] = 1 ; for ( int N = 1 ; N <= 14 ; N ++ ) { for ( int i = 1 ; i < depth ; i ++ ) { for ( int j = 1 ; j < depth ; j ++ ) { ways [ N , i , j ] = ways [ N - 1 , i , j + 1 ] + ways [ N - 1 , i , j - 1 ] + ways [ N - 1 , i + 1 , j ] + ways [ N - 1 , i - 1 , j ] + ways [ N - 1 , i + 1 , j - 1 ] + ways [ N - 1 , i - 1 , j + 1 ] ; } } list [ N ] = ways [ N , 8 , 8 ] ; } } public static void Main ( ) { int [ ] list = new int [ 15 ] ; preprocess ( list ) ; int steps = 4 ; Console . WriteLine ( " Number ▁ of ▁ walks " + " ▁ possible ▁ is / are ▁ " + list [ steps ] ) ; } }

Index/key variables: N, steps
Accumulator variables: N, i, j
Iterator variables: N, i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int N = 105 ; static int R = 3 ; static int C = 4 ; static int maximumValue ( int n , int m , int p , int [ , ] grid ) { bool [ , , ] dp = new bool [ N , N , N ] ; int i , j , k ; for ( i = 0 ; i < N ; i ++ ) { for ( j = 0 ; j < N ; j ++ ) { for ( k = 0 ; k < N ; k ++ ) dp [ i , j , k ] = false ; } } for ( i = 0 ; i < n ; i ++ ) { for ( j = 0 ; j < m ; j ++ ) { for ( k = grid [ i , j ] ; k <= p ; k ++ ) { if ( i == 0 && j == 0 ) { if ( k == grid [ i , j ] ) dp [ i , j , k ] = true ; } else if ( i == 0 ) { dp [ i , j , k ] = ( dp [ i , j , k ] dp [ i , j - 1 , k - grid [ i , j ] ] ) ; } else if ( j == 0 ) { dp [ i , j , k ] = ( dp [ i , j , k ] dp [ i - 1 , j , k - grid [ i , j ] ] ) ; } else { dp [ i , j , k ] = ( dp [ i , j , k ] dp [ i , j - 1 , k - grid [ i , j ] ] ) ; dp [ i , j , k ] = ( dp [ i , j , k ] dp [ i - 1 , j , k - grid [ i , j ] ] ) ; dp [ i , j , k ] = ( dp [ i , j , k ] dp [ i - 1 , j - 1 , k - grid [ i , j ] ] ) ; } } } } k = p ; int ans = 0 ; for ( ans = k ; ans >= 0 ; ans -- ) if ( dp [ n - 1 , m - 1 , ans ] ) break ; return ans ; } public static void Main ( ) { int n = 3 , m = 4 , p = 9 ; int [ , ] grid = { { 2 , 3 , 4 , 1 } , { 6 , 5 , 5 , 3 } , { 5 , 2 , 3 , 4 } } ; Console . WriteLine ( maximumValue ( n , m , p , grid ) ) ; } }

Accumulator variables: ans, i, j, k
Iterator variables: ans, i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static long answer ( int n ) { int [ , ] dp = new int [ n + 1 , 10 ] ; if ( n == 1 ) return 10 ; for ( int j = 0 ; j <= 9 ; j ++ ) dp [ 1 , j ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= 9 ; j ++ ) { if ( j == 0 ) dp [ i , j ] = dp [ i - 1 , j + 1 ] ; else if ( j == 9 ) dp [ i , j ] = dp [ i - 1 , j - 1 ] ; else dp [ i , j ] = dp [ i - 1 , j - 1 ] + dp [ i - 1 , j + 1 ] ; } } long sum = 0 ; for ( int j = 1 ; j <= 9 ; j ++ ) sum += dp [ n , j ] ; return sum ; } public static void Main ( ) { int n = 2 ; Console . WriteLine ( answer ( n ) ) ; } }

Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { static String lcs ( String a , String b ) { int m = a . Length ; int n = b . Length ; char [ ] X = a . ToCharArray ( ) ; char [ ] Y = b . ToCharArray ( ) ; int [ , ] L = new int [ m + 1 , n + 1 ] ; int i , j ; for ( i = 0 ; i <= m ; i ++ ) { for ( j = 0 ; j <= n ; j ++ ) { if ( i == 0 j == 0 ) { L [ i , j ] = 0 ; } else if ( X [ i - 1 ] == Y [ j - 1 ] ) { L [ i , j ] = L [ i - 1 , j - 1 ] + 1 ; } else { L [ i , j ] = Math . Max ( L [ i - 1 , j ] , L [ i , j - 1 ] ) ; } } } int index = L [ m , n ] ; char [ ] lcs = new char [ index + 1 ] ; i = m ; j = n ; while ( i > 0 && j > 0 ) { if ( X [ i - 1 ] == Y [ j - 1 ] ) { lcs [ index - 1 ] = X [ i - 1 ] ; i -- ; j -- ; index -- ; } else if ( L [ i - 1 , j ] > L [ i , j - 1 ] ) { i -- ; } else { j -- ; } } String ans = " " ; for ( int x = 0 ; x < lcs . Length ; x ++ ) { ans += lcs [ x ] ; } return ans ; } static String longestPalSubseq ( String str ) { String rev = str ; rev = reverse ( rev ) ; return lcs ( str , rev ) ; } static String reverse ( String str ) { String ans = " " ; char [ ] try1 = str . ToCharArray ( ) ; for ( int i = try1 . Length - 1 ; i >= 0 ; i -- ) { ans += try1 [ i ] ; } return ans ; } public static void Main ( ) { String str = " GEEKSFORGEEKS " ; Console . Write ( longestPalSubseq ( str ) ) ; } }

Index/key variables: i, x
Accumulator variables: ans, i, index, j, x
Iterator variables: i, j, x
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class CountSubsequences { public static int productSubSeqCount ( ArrayList arr , int k ) { int n = arr . Count ; int [ , ] dp = new int [ k + 1 , n + 1 ] ; for ( int i = 1 ; i <= k ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { dp [ i , j ] = dp [ i , j - 1 ] ; if ( Convert . ToInt32 ( arr [ j - 1 ] ) <= i && Convert . ToInt32 ( arr [ j - 1 ] ) > 0 ) dp [ i , j ] += dp [ i / Convert . ToInt32 ( arr [ j - 1 ] ) , j - 1 ] + 1 ; } } return dp [ k , n ] ; } public static void Main ( ) { ArrayList A = new ArrayList ( ) ; A . Add ( 1 ) ; A . Add ( 2 ) ; A . Add ( 3 ) ; A . Add ( 4 ) ; int k = 10 ; Console . WriteLine ( productSubSeqCount ( A , k ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: CountSubsequences
C# program:
using System ; class GFG { static int findSingle ( int [ ] ar , int ar_size ) { int res = ar [ 0 ] ; for ( int i = 1 ; i < ar_size ; i ++ ) res = res ^ ar [ i ] ; return res ; } public static void Main ( ) { int [ ] ar = { 2 , 3 , 5 , 4 , 5 , 3 , 4 } ; int n = ar . Length ; Console . Write ( " Element ▁ occurring ▁ once ▁ is ▁ " + findSingle ( ar , n ) + " ▁ " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int [ , ] dp ; public static void computeDpArray ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; ++ i ) { for ( int j = 1 ; j <= 15000 ; ++ j ) { if ( i == 0 && j == arr [ i ] ) dp [ i , j ] = 1 ; else if ( i == 0 ) dp [ i , j ] = 0 ; else if ( arr [ i ] == j ) dp [ i , j ] = dp [ i - 1 , j ] + 1 ; else dp [ i , j ] = dp [ i - 1 , j ] ; } } } public static int countTripletSum ( int [ ] arr , int n ) { computeDpArray ( arr , n ) ; int ans = 0 ; for ( int i = 0 ; i < n - 2 ; ++ i ) { for ( int j = i + 1 ; j < n - 1 ; ++ j ) { for ( int k = 1 ; k <= 24 ; ++ k ) { int cube = k * k * k ; int rem = cube - ( arr [ i ] + arr [ j ] ) ; if ( rem > 0 ) ans += dp [ n - 1 , rem ] - dp [ j , rem ] ; } } } return ans ; } public static void Main ( ) { int [ ] arr = { 2 , 5 , 1 , 20 , 6 } ; int n = arr . Length ; dp = new int [ 1001 , 15001 ] ; Console . Write ( countTripletSum ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: ans
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int singleNumber ( int [ ] nums , int n ) { Dictionary < int , int > m = new Dictionary < int , int > ( ) ; long sum1 = 0 , sum2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! m . ContainsKey ( nums [ i ] ) ) { sum1 += nums [ i ] ; m . Add ( nums [ i ] , 1 ) ; } sum2 += nums [ i ] ; } return ( int ) ( 2 * ( sum1 ) - sum2 ) ; } public static void Main ( String [ ] args ) { int [ ] a = { 2 , 3 , 5 , 4 , 5 , 3 , 4 } ; int n = 7 ; Console . WriteLine ( singleNumber ( a , n ) ) ; int [ ] b = { 15 , 18 , 16 , 18 , 16 , 15 , 89 } ; Console . WriteLine ( singleNumber ( b , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum1, sum2
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isPresent ( int [ ] B , int m , int x ) { for ( int i = 0 ; i < m ; i ++ ) if ( B [ i ] == x ) return true ; return false ; } static int findMaxSubarraySumUtil ( int [ ] A , int [ ] B , int n , int m ) { int max_so_far = - 2147483648 , curr_max = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( isPresent ( B , m , A [ i ] ) ) { curr_max = 0 ; continue ; } curr_max = Math . Max ( A [ i ] , curr_max + A [ i ] ) ; max_so_far = Math . Max ( max_so_far , curr_max ) ; } return max_so_far ; } static void findMaxSubarraySum ( int [ ] A , int [ ] B , int n , int m ) { int maxSubarraySum = findMaxSubarraySumUtil ( A , B , n , m ) ; if ( maxSubarraySum == - 2147483648 ) { Console . Write ( " Maximum ▁ Subarray ▁ Sum " + " ▁ " + " can ' t ▁ be ▁ found " ) ; } else { Console . Write ( " The ▁ Maximum ▁ Subarray ▁ Sum ▁ = ▁ " + maxSubarraySum ) ; } } static public void Main ( ) { int [ ] A = { 3 , 4 , 5 , - 4 , 6 } ; int [ ] B = { 1 , 8 , 5 } ; int n = A . Length ; int m = B . Length ; findMaxSubarraySum ( A , B , n , m ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findMaxSubarraySumUtil ( int [ ] A , int [ ] B , int n , int m ) { int max_so_far = int . MinValue , curr_max = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( Array . BinarySearch ( B , A [ i ] ) >= 0 ) { curr_max = 0 ; continue ; } curr_max = Math . Max ( A [ i ] , curr_max + A [ i ] ) ; max_so_far = Math . Max ( max_so_far , curr_max ) ; } return max_so_far ; } static void findMaxSubarraySum ( int [ ] A , int [ ] B , int n , int m ) { Array . Sort ( B ) ; int maxSubarraySum = findMaxSubarraySumUtil ( A , B , n , m ) ; if ( maxSubarraySum == int . MinValue ) { Console . WriteLine ( " Maximum ▁ subarray ▁ sum ▁ cant ▁ be ▁ found " ) ; } else { Console . WriteLine ( " The ▁ Maximum ▁ subarray ▁ sum ▁ = ▁ " + maxSubarraySum ) ; } } public static void Main ( params string [ ] args ) { int [ ] A = { 3 , 4 , 5 , - 4 , 6 } ; int [ ] B = { 1 , 8 , 5 } ; int n = A . Length ; int m = B . Length ; findMaxSubarraySum ( A , B , n , m ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int nonDecNums ( int n ) { int [ , ] a = new int [ n + 1 , 10 ] ; for ( int i = 0 ; i <= 9 ; i ++ ) a [ 0 , i ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) a [ i , 9 ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) for ( int j = 8 ; j >= 0 ; j -- ) a [ i , j ] = a [ i - 1 , j ] + a [ i , j + 1 ] ; return a [ n , 0 ] ; } public static void Main ( ) { int n = 2 ; Console . WriteLine ( " Non - decreasing ▁ digits ▁ = ▁ " + nonDecNums ( n ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int MOD = 1000000007 ; public static long countBT ( int h ) { long [ ] dp = new long [ h + 1 ] ; dp [ 0 ] = 1 ; dp [ 1 ] = 1 ; for ( int i = 2 ; i <= h ; ++ i ) dp [ i ] = ( dp [ i - 1 ] * ( ( 2 * dp [ i - 2 ] ) % MOD + dp [ i - 1 ] ) % MOD ) % MOD ; return dp [ h ] ; } static void Main ( ) { int h = 3 ; Console . WriteLine ( " No . ▁ of ▁ balanced ▁ binary ▁ trees ▁ of ▁ height ▁ " + h + " ▁ is : ▁ " + countBT ( h ) ) ; } }

Index/key variables: h, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int findMaxSubarraySum ( int [ ] A , int [ ] B ) { Dictionary < int , int > m = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < B . Length ; i ++ ) { m [ B [ i ] ] = 1 ; } int max_so_far = Int32 . MinValue ; int currmax = 0 ; for ( int i = 0 ; i < A . Length ; i ++ ) { if ( currmax < 0 || ( m . ContainsKey ( A [ i ] ) && m [ A [ i ] ] == 1 ) ) { currmax = 0 ; continue ; } currmax = Math . Max ( A [ i ] , A [ i ] + currmax ) ; if ( max_so_far < currmax ) { max_so_far = currmax ; } } return max_so_far ; } static void Main ( ) { int [ ] a = { 3 , 4 , 5 , - 4 , 6 } ; int [ ] b = { 1 , 8 , 5 } ; Console . WriteLine ( findMaxSubarraySum ( a , b ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int count ( String s , int len ) { int MAX = 1000 ; int cur = 0 , dig = 0 ; int [ ] sum = new int [ MAX ] ; int [ , ] dp = new int [ MAX , 3 ] ; dp [ 0 , 0 ] = 1 ; for ( int i = 1 ; i <= len ; i ++ ) { dig = ( int ) ( s [ i - 1 ] ) - 48 ; cur += dig ; cur %= 3 ; sum [ i ] = cur ; dp [ i , 0 ] = dp [ i - 1 , 0 ] ; dp [ i , 1 ] = dp [ i - 1 , 1 ] ; dp [ i , 2 ] = dp [ i - 1 , 2 ] ; dp [ i , sum [ i ] ] ++ ; } int ans = 0 , dprev = 0 , value = 0 , dprev2 = 0 ; for ( int i = 1 ; i <= len ; i ++ ) { dig = ( int ) ( s [ i - 1 ] ) - 48 ; if ( dig == 8 ) ans ++ ; if ( i - 2 >= 0 ) { dprev = ( int ) ( s [ i - 2 ] ) - 48 ; value = dprev * 10 + dig ; if ( ( value % 8 == 0 ) && ( value % 3 != 0 ) ) ans ++ ; } if ( i - 3 >= 0 ) { dprev2 = ( int ) ( s [ i - 3 ] ) - 48 ; dprev = ( int ) ( s [ i - 2 ] ) - 48 ; value = dprev2 * 100 + dprev * 10 + dig ; if ( value % 8 != 0 ) continue ; ans += ( i - 2 ) ; ans -= ( dp [ i - 3 , sum [ i ] ] ) ; } } return ans ; } public static void Main ( String [ ] args ) { String str = "6564525600" ; int len = str . Length ; Console . Write ( count ( str , len ) ) ; } }

Index/key variables: MAX, i
Accumulator variables: ans, cur, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int MAX_CHAR = 256 ; static void printDistinct ( string str ) { int n = str . Length ; int [ ] count = new int [ MAX_CHAR ] ; int [ ] index = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) { count [ i ] = 0 ; index [ i ] = n ; } for ( int i = 0 ; i < n ; i ++ ) { char x = str [ i ] ; ++ count [ x ] ; if ( count [ x ] == 1 && x != ' ▁ ' ) index [ x ] = i ; if ( count [ x ] == 2 ) index [ x ] = n ; } Array . Sort ( index ) ; for ( int i = 0 ; i < MAX_CHAR && index [ i ] != n ; i ++ ) Console . Write ( str [ index [ i ] ] ) ; } public static void Main ( ) { string str = " GeeksforGeeks " ; printDistinct ( str ) ; } }

Index/key variables: MAX_CHAR, i, x
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int MAX_LEN = 110 ; static int [ , , ] DP = new int [ MAX_LEN , MAX_LEN , MAX_LEN ] ; static int length ( int a , int b , int c ) { if ( a < 0 b < 0 c < 0 ) if ( DP [ a , b , c ] != - 1 ) return DP [ a , b , c ] ; if ( a == 0 && b == 0 ) return ( DP [ a , b , c ] = c ) ; if ( a == 0 && c == 0 ) return ( DP [ a , b , c ] = b ) ; if ( b == 0 && c == 0 ) return ( DP [ a , b , c ] = a ) ; if ( a == 0 ) return ( DP [ a , b , c ] = length ( a + 1 , b - 1 , c - 1 ) ) ; if ( b == 0 ) return ( DP [ a , b , c ] = length ( a - 1 , b + 1 , c - 1 ) ) ; if ( c == 0 ) return ( DP [ a , b , c ] = length ( a - 1 , b - 1 , c + 1 ) ) ; DP [ a , b , c ] = Math . Min ( length ( a - 1 , b - 1 , c + 1 ) , Math . Min ( length ( a - 1 , b + 1 , c - 1 ) , length ( a + 1 , b - 1 , c - 1 ) ) ) ; return DP [ a , b , c ] ; } static int stringReduction ( string str ) { int n = str . Length ; int [ ] count = new int [ 3 ] ; for ( int i = 0 ; i < n ; ++ i ) count [ str [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i <= count [ 0 ] ; ++ i ) for ( int j = 0 ; j < count [ 1 ] ; ++ j ) for ( int k = 0 ; k < count [ 2 ] ; ++ k ) DP [ i , j , k ] = - 1 ; return length ( count [ 0 ] , count [ 1 ] , count [ 2 ] ) ; } static public void Main ( ) { string str = " abcbbaacb " ; Console . WriteLine ( stringReduction ( str ) ) ; } }

Index/key variables: i
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int equilibrium ( int [ ] arr , int n ) { int i , j ; int leftsum , rightsum ; for ( i = 0 ; i < n ; ++ i ) { leftsum = 0 ; rightsum = 0 ; for ( j = 0 ; j < i ; j ++ ) leftsum += arr [ j ] ; for ( j = i + 1 ; j < n ; j ++ ) rightsum += arr [ j ] ; if ( leftsum == rightsum ) return i ; } return - 1 ; } public static void Main ( ) { int [ ] arr = { - 7 , 1 , 5 , 2 , - 4 , 3 , 0 } ; int arr_size = arr . Length ; Console . Write ( equilibrium ( arr , arr_size ) ) ; } }

Index/key variables: j
Accumulator variables: j, leftsum, rightsum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { static int countEndless ( bool [ , ] input , int n ) { bool [ , ] row = new bool [ n , n ] ; bool [ , ] col = new bool [ n , n ] ; for ( int j = 0 ; j < n ; j ++ ) { bool isEndless = true ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( input [ i , j ] == false ) isEndless = false ; col [ i , j ] = isEndless ; } } for ( int i = 0 ; i < n ; i ++ ) { bool isEndless = true ; for ( int j = n - 1 ; j >= 0 ; j -- ) { if ( input [ i , j ] == false ) isEndless = false ; row [ i , j ] = isEndless ; } } int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 1 ; j < n ; j ++ ) if ( row [ i , j ] && col [ i , j ] ) ans ++ ; return ans ; } public static void Main ( ) { bool [ , ] input = { { true , false , true , true } , { false , true , true , true } , { true , true , true , true } , { false , true , true , false } } ; int n = 4 ; Console . Write ( countEndless ( input , n ) ) ; } }

Accumulator variables: ans, i, j
Iterator variables: i, j
Boolean variables: isEndless
Class/struct names: GFG
C# program:
using System ; class GFG { static int equilibrium ( int [ ] arr , int n ) { int sum = 0 ; int leftsum = 0 ; for ( int i = 0 ; i < n ; ++ i ) sum += arr [ i ] ; for ( int i = 0 ; i < n ; ++ i ) { sum -= arr [ i ] ; if ( leftsum == sum ) return i ; leftsum += arr [ i ] ; } return - 1 ; } public static void Main ( ) { int [ ] arr = { - 7 , 1 , 5 , 2 , - 4 , 3 , 0 } ; int arr_size = arr . Length ; Console . Write ( " First ▁ equilibrium ▁ index ▁ is ▁ " + equilibrium ( arr , arr_size ) ) ; } }

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