dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int NumberOfways ( int N , int K ) { int [ ] dp = new int [ ( N + 1 ) ] ; dp [ 0 ] = 1 ; for ( int row = 1 ; row < K + 1 ; row ++ ) { for ( int col = 1 ; col < N + 1 ; col ++ ) { if ( col >= row ) dp [ col ] = dp [ col ] + dp [ col - row ] ; } } return ( dp [ N ] ) ; } public static void Main ( ) { int N = 8 ; int K = 2 ; Console . WriteLine ( NumberOfways ( N , K ) ) ; } }

Index/key variables: N, col
Accumulator variables: col, row
Iterator variables: col, row
Class/struct names: GFG
C# program:
using System ; public class GFG { static void findAPSequence ( int [ ] arr , int N , int [ , ] Q , int M ) { int [ ] dp = new int [ N + 5 ] ; for ( int i = 0 ; i + 1 < N ; ) { int j = i + 1 ; while ( j + 1 < N && arr [ j + 1 ] - arr [ j ] == arr [ i + 1 ] - arr [ i ] ) j ++ ; for ( int k = i ; k < j ; k ++ ) { dp [ k ] = j - k ; } i = j ; } for ( int i = 0 ; i < M ; i ++ ) { if ( dp [ Q [ i , 0 ] ] >= Q [ i , 1 ] - Q [ i , 0 ] ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } } static public void Main ( ) { int [ ] arr = { 1 , 3 , 5 , 7 , 6 , 5 , 4 , 1 } ; int [ , ] Q = { { 0 , 3 } , { 3 , 4 } , { 2 , 4 } } ; int N = arr . Length ; int M = Q . GetLength ( 0 ) ; findAPSequence ( arr , N , Q , M ) ; } }

Index/key variables: i, j, k
Accumulator variables: i, j, k
Iterator variables: i, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ , , ] dp = new int [ 100 , 100 , 100 ] ; static int minSumDifference ( int [ ] arr , int n , int k1 , int k2 , int sum1 , int sum2 ) { if ( n < 0 ) { if ( k1 == 0 && k2 == 0 ) { return Math . Abs ( sum1 - sum2 ) ; } else { return Int32 . MaxValue ; } } if ( dp [ n , sum1 , sum2 ] != - 1 ) { return dp [ n , sum1 , sum2 ] ; } int op1 = Int32 . MaxValue ; int op2 = Int32 . MaxValue ; int op3 = Int32 . MaxValue ; if ( k1 > 0 ) { op1 = minSumDifference ( arr , n - 1 , k1 - 1 , k2 , sum1 + arr [ n ] , sum2 ) ; } if ( k2 > 0 ) { op2 = minSumDifference ( arr , n - 1 , k1 , k2 - 1 , sum1 , sum2 + arr [ n ] ) ; } op3 = minSumDifference ( arr , n - 1 , k1 , k2 , sum1 , sum2 ) ; dp [ n , sum1 , sum2 ] = Math . Min ( op1 , Math . Min ( op2 , op3 ) ) ; return dp [ n , sum1 , sum2 ] ; } static public void Main ( ) { int [ ] arr = { 12 , 3 , 5 , 6 , 7 , 17 } ; int K = 2 ; int N = arr . Length ; for ( int i = 0 ; i < 100 ; i ++ ) { for ( int j = 0 ; j < 100 ; j ++ ) { for ( int k = 0 ; k < 100 ; k ++ ) { dp [ i , j , k ] = - 1 ; } } } Console . WriteLine ( minSumDifference ( arr , N - 1 , K , K , 0 , 0 ) ) ; } }

Index/key variables: n
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int find ( int A , int B , int C , int N ) { int [ ] arr = new int [ N ] ; arr [ 0 ] = A ; arr [ 1 ] = B ; arr [ 2 ] = C ; for ( int i = 3 ; i < N ; i ++ ) { arr [ i ] = arr [ i - 1 ] + arr [ i - 2 ] + arr [ i - 3 ] ; } return arr [ N - 1 ] ; } public static void Main ( string [ ] args ) { int A = 1 , B = 3 , C = 2 , N = 4 ; Console . Write ( find ( A , B , C , N ) ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void daysToCure ( int [ ] arr , int N , int P ) { int risk = 0 ; int normal_risk = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] >= 60 arr [ i ] <= 10 ) { risk ++ ; } else { normal_risk ++ ; } } int days = ( risk / P ) + ( normal_risk / P ) ; if ( risk % P > 0 ) { days ++ ; } if ( normal_risk % P > 0 ) { days ++ ; } Console . Write ( days ) ; } static void Main ( ) { int [ ] arr = { 9 , 80 , 27 , 72 , 79 } ; int N = arr . Length ; int P = 2 ; daysToCure ( arr , N , P ) ; } }

Index/key variables: i
Accumulator variables: days, i, normal_risk, risk
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static readonly int M = 100 ; static int cntNum ( String X , int i , int prod , int K , int st , int tight , int [ , , , ] dp ) { if ( i >= X . Length prod > K ) { return prod == K ? 1 : 0 ; } if ( dp [ prod , i , tight , st ] != - 1 ) { return dp [ prod , i , tight , st ] ; } int res = 0 ; int end = tight > 0 ? X [ i ] - '0' : 9 ; for ( int j = 0 ; j <= end ; j ++ ) { if ( j == 0 && st == 0 ) { res += cntNum ( X , i + 1 , prod , K , 0 , ( tight & ( ( j == end ) ? 1 : 0 ) ) , dp ) ; } else { res += cntNum ( X , i + 1 , prod * j , K , 1 , ( tight & ( ( j == end ) ? 1 : 0 ) ) , dp ) ; } } return dp [ prod , i , tight , st ] = res ; } static int UtilCntNumRange ( int L , int R , int K ) { String str = String . Join ( " " , R ) ; int [ , , , ] dp = new int [ M , M , 2 , 2 ] ; for ( int i = 0 ; i < M ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { for ( int k = 0 ; k < 2 ; k ++ ) for ( int l = 0 ; l < 2 ; l ++ ) dp [ i , j , k , l ] = - 1 ; } } int cntR = cntNum ( str , 0 , 1 , K , 0 , 1 , dp ) ; str = String . Join ( " " , L - 1 ) ; for ( int i = 0 ; i < M ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { for ( int k = 0 ; k < 2 ; k ++ ) for ( int l = 0 ; l < 2 ; l ++ ) dp [ i , j , k , l ] = - 1 ; } } int cntL = cntNum ( str , 0 , 1 , K , 0 , 1 , dp ) ; return ( cntR - cntL ) ; } public static void Main ( String [ ] args ) { int L = 20 , R = 10000 , K = 14 ; Console . Write ( UtilCntNumRange ( L , R , K ) ) ; } }

Index/key variables: i
Accumulator variables: i, j, k, l, res
Iterator variables: i, j, k, l
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int countVowelPermutation ( int n ) { int MOD = ( int ) ( 1e9 + 7 ) ; long [ , ] dp = new long [ n + 1 , 5 ] ; for ( int i = 0 ; i < 5 ; i ++ ) { dp [ 1 , i ] = 1 ; } List < List < int > > relation = new List < List < int > > ( ) ; relation . Add ( new List < int > { 1 } ) ; relation . Add ( new List < int > { 0 , 2 } ) ; relation . Add ( new List < int > { 0 , 1 , 3 , 4 } ) ; relation . Add ( new List < int > { 2 , 4 } ) ; relation . Add ( new List < int > { 0 } ) ; for ( int i = 1 ; i < n ; i ++ ) { for ( int u = 0 ; u < 5 ; u ++ ) { dp [ i + 1 , u ] = 0 ; foreach ( int v in relation [ u ] ) { dp [ i + 1 , u ] += dp [ i , v ] % MOD ; } } } long ans = 0 ; for ( int i = 0 ; i < 5 ; i ++ ) { ans = ( ans + dp [ n , i ] ) % MOD ; } return ( int ) ans ; } static void Main ( ) { int N = 2 ; Console . WriteLine ( countVowelPermutation ( N ) ) ; } }

Index/key variables: u
Accumulator variables: i, u
Iterator variables: i, u, v
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int N = ( int ) 1e5 + 5 ; static List < List < int > > adj ; static int [ ] answer ; static void AddEdgesToGraph ( int [ , ] Edges , int N ) { for ( int i = 0 ; i < N - 1 ; i ++ ) { int u = Edges [ i , 0 ] ; int v = Edges [ i , 1 ] ; adj [ u ] . Add ( v ) ; adj [ v ] . Add ( u ) ; } } static void DFS ( int node , int parent , int [ ] Val ) { answer [ node ] = Val [ node ] ; foreach ( int child in adj [ node ] ) { if ( child == parent ) continue ; DFS ( child , node , Val ) ; answer [ node ] = ( answer [ node ] answer [ child ] ) ; } } static void preprocess ( int [ ] Val ) { DFS ( 1 , - 1 , Val ) ; } static void findSubtreeOR ( int [ ] Queries , int Q , int [ ] Val ) { preprocess ( Val ) ; for ( int i = 0 ; i < Q ; i ++ ) { Console . Write ( answer [ Queries [ i ] ] + " ▁ " ) ; } } static void findSubtreeORUtil ( int N , int [ , ] Edges , int [ ] Val , int [ ] Queries , int Q ) { AddEdgesToGraph ( Edges , N ) ; findSubtreeOR ( Queries , Q , Val ) ; } public static void Main ( String [ ] args ) { adj = new List < List < int > > ( ) ; for ( int i = 0 ; i < N ; i ++ ) adj . Add ( new List < int > ( ) ) ; answer = new int [ N ] ; N = 5 ; int [ , ] Edges = { { 1 , 2 } , { 1 , 3 } , { 3 , 4 } , { 3 , 5 } } ; int [ ] Val = { 0 , 2 , 3 , 4 , 8 , 16 } ; int [ ] Queries = { 2 , 3 , 1 } ; int Q = Queries . Length ; findSubtreeORUtil ( N , Edges , Val , Queries , Q ) ; } }

Index/key variables: N, child, i, node, u, v
Accumulator variables: i
Iterator variables: child, i
Class/struct names: GFG
C# program:
using System ; class GFG { static int max ( int a , int b ) { return a > b ? a : b ; } static int maximumsum ( int [ , ] arr , int K , int N , int M ) { int sum = 0 , maxSum ; int i , j , k ; int [ , ] dp = new int [ K + 1 , N + 1 ] ; for ( i = 0 ; i <= N ; i ++ ) dp [ 0 , i ] = 0 ; for ( i = 0 ; i <= K ; i ++ ) dp [ i , 0 ] = 0 ; for ( i = 1 ; i <= K ; i ++ ) { for ( j = 0 ; j < N ; j ++ ) { sum = 0 ; maxSum = dp [ i , j ] ; for ( k = 1 ; k <= M && k <= i ; k ++ ) { sum += arr [ j , k - 1 ] ; maxSum = Math . Max ( maxSum , sum + dp [ i - k , j ] ) ; } dp [ i , j + 1 ] = maxSum ; } } return dp [ K , N ] ; } public static void Main ( String [ ] args ) { int [ , ] arr = { { 10 , 10 , 100 , 30 } , { 80 , 50 , 10 , 50 } } ; int N = 2 , M = 4 ; int K = 5 ; Console . Write ( maximumsum ( arr , K , N , M ) ) ; } }

Accumulator variables: i, j, k, sum
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { public static void FindSub ( HashSet < String > sub , HashSet < char > ch , String str , String res , int i ) { if ( i == str . Length ) { sub . Add ( res ) ; return ; } if ( ! ch . Contains ( str [ i ] ) ) { ch . Add ( str [ i ] ) ; FindSub ( sub , ch , str , res + str [ i ] , i + 1 ) ; ch . Remove ( str [ i ] ) ; } FindSub ( sub , ch , str , res , i + 1 ) ; } public static void printSubwithUniqueChar ( String str , int N ) { HashSet < String > sub = new HashSet < String > ( ) ; HashSet < char > ch = new HashSet < char > ( ) ; FindSub ( sub , ch , str , " " , 0 ) ; foreach ( String subString in sub ) { Console . Write ( subString + " ▁ " ) ; } } public static void Main ( String [ ] args ) { String str = " abac " ; int N = str . Length ; printSubwithUniqueChar ( str , N ) ; } }

Index/key variables: i
Iterator variables: subString
Class/struct names: GFG
C# program:
using System ; class GFG { static void waysToArrangeKLengthStrings ( int N , int K ) { int [ ] column_sum = new int [ N + 1 ] ; int i , j ; for ( i = 1 ; i < N + 1 ; i ++ ) { column_sum [ i ] = 0 ; } int [ , ] dp = new int [ K + 1 , N + 1 ] ; for ( i = 1 ; i < K + 1 ; i ++ ) { for ( j = 1 ; j < N + 1 ; j ++ ) { dp [ i , j ] = 0 ; } } for ( i = 0 ; i <= N ; i ++ ) { dp [ 0 , i ] = 1 ; column_sum [ i ] = 1 ; } for ( i = 1 ; i <= K ; i ++ ) { for ( j = 1 ; j <= N ; j ++ ) { dp [ i , j ] += column_sum [ j - 1 ] ; column_sum [ j ] += dp [ i , j ] ; } } Console . Write ( dp [ K , N ] ) ; } public static void Main ( ) { int N = 5 , K = 2 ; waysToArrangeKLengthStrings ( N , K ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int findNumberOfStrings ( int n ) { int [ , ] DP = new int [ n + 1 , 6 ] ; DP [ 1 , 1 ] = 1 ; for ( int i = 1 ; i < n + 1 ; i ++ ) { for ( int j = 1 ; j < 6 ; j ++ ) { if ( i == 1 ) { DP [ i , j ] = DP [ i , j - 1 ] + 1 ; } else { DP [ i , j ] = DP [ i , j - 1 ] + DP [ i - 1 , j ] ; } } } return DP [ n , 5 ] ; } public static void Main ( string [ ] args ) { int N = 2 ; Console . Write ( findNumberOfStrings ( N ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void dfs ( int v , int p , List < int > [ ] adj , int [ ] ans , int [ ] vals ) { bool isLeaf = true ; ans [ v ] = int . MinValue ; foreach ( int u in adj [ v ] ) { if ( u == p ) continue ; isLeaf = false ; dfs ( u , v , adj , ans , vals ) ; ans [ v ] = Math . Max ( ans [ u ] + vals [ v ] , Math . Max ( ans [ u ] , vals [ u ] ) ) ; } if ( isLeaf ) { ans [ v ] = vals [ v ] ; } } static void printAnswer ( int n , int [ , ] edges , int [ ] values ) { List < int > [ ] adj = new List < int > [ n ] ; for ( int i = 0 ; i < n ; i ++ ) adj [ i ] = new List < int > ( ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) { int u = edges [ i , 0 ] - 1 ; int v = edges [ i , 1 ] - 1 ; adj [ u ] . Add ( v ) ; adj [ v ] . Add ( u ) ; } int [ ] ans = new int [ n ] ; dfs ( 0 , - 1 , adj , ans , values ) ; foreach ( int x in ans ) { Console . Write ( x + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int N = 4 ; int [ , ] edges = new int [ , ] { { 1 , 2 } , { 1 , 3 } , { 3 , 4 } } ; int [ ] values = { 1 , - 1 , 0 , 1 } ; printAnswer ( N , edges , values ) ; } }

Index/key variables: i, n, u, v
Accumulator variables: i
Iterator variables: i, u, x
Boolean variables: isLeaf
Class/struct names: GFG
C# program:
using System ; public class GFG { static void noOfChars ( String s , char [ , ] queries ) { int n = s . Length ; int [ , ] dp = new int [ n + 1 , 26 ] ; for ( int i = 0 ; i < n ; i ++ ) { dp [ i + 1 , s [ i ] - ' a ' ] ++ ; for ( int j = 0 ; j < 26 ; j ++ ) { dp [ i + 1 , j ] += dp [ i , j ] ; } } int q = queries . GetLength ( 0 ) ; for ( int i = 0 ; i < q ; i ++ ) { int l = ( int ) queries [ i , 0 ] ; int r = ( int ) queries [ i , 1 ] ; int c = queries [ i , 2 ] - ' a ' ; Console . Write ( dp [ r , c ] - dp [ l - 1 , c ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { String S = " aabv " ; char [ , ] queries = new char [ , ] { { ( char ) 1 , ( char ) 2 , ' a ' } , { ( char ) 2 , ( char ) 3 , ' b ' } } ; noOfChars ( S , queries ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int LowerBound ( int [ ] a , int k , int x ) { int l = - 1 ; int r = k ; while ( l + 1 < r ) { int m = ( l + r ) >> 1 ; if ( a [ m ] >= x ) { r = m ; } else { l = m ; } } return r ; } static int findLCS ( int [ ] nums , int N ) { int k = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int pos = LowerBound ( nums , k , nums [ i ] ) ; nums [ pos ] = nums [ i ] ; if ( k == pos ) { k = pos + 1 ; } } return k ; } static int minimumCost ( int [ ] A , int [ ] B , int M , int N , int C ) { int [ ] nums = new int [ 100000 ] ; int [ ] index = new int [ 100000 ] ; for ( int i = 0 ; i < 100000 ; i ++ ) index [ i ] = - 1 ; for ( int i = 0 ; i < N ; i ++ ) { index [ B [ i ] ] = i ; } int k = 0 ; for ( int i = 0 ; i < M ; i ++ ) { if ( index [ A [ i ] ] != - 1 ) { nums [ k ++ ] = index [ A [ i ] ] ; } } int lcs_length = findLCS ( nums , k ) ; int elements_to_be_added = N - lcs_length ; int min_cost = elements_to_be_added * C ; Console . WriteLine ( min_cost ) ; return 0 ; } public static void Main ( ) { int [ ] A = { 1 , 6 , 3 , 5 , 10 } ; int [ ] B = { 3 , 1 , 5 } ; int C = 2 ; int M = A . Length ; int N = B . Length ; minimumCost ( A , B , M , N , C ) ; } }

Index/key variables: i, m, pos
Accumulator variables: i, k
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxCount ( int [ ] arr , int m , int V ) { int [ ] table = new int [ V + 1 ] ; table [ 0 ] = 0 ; for ( int i = 1 ; i <= V ; i ++ ) table [ i ] = - 1 ; for ( int i = 1 ; i <= V ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( arr [ j ] <= i ) { int sub_res = table [ i - arr [ j ] ] ; if ( sub_res != - 1 && sub_res + 1 > table [ i ] ) table [ i ] = sub_res + 1 ; } } } return table [ V ] ; } static void Main ( ) { int [ ] arr = { 25 , 10 , 5 } ; int m = arr . Length ; int V = 30 ; Console . WriteLine ( maxCount ( arr , m , V ) ) ; } }

Index/key variables: V, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Text ; class GFG { static bool isdivisible ( StringBuilder newstr , long K ) { long num = 0 ; for ( int i = 0 ; i < newstr . Length ; i ++ ) { num = num * 10 + newstr [ i ] - '0' ; } if ( num % K == 0 ) return true ; else return false ; } static void findLargestNo ( String str , StringBuilder newstr , StringBuilder ans , int index , long K ) { if ( index == str . Length ) { if ( isdivisible ( newstr , K ) ) { if ( ( newstr . ToString ( ) . CompareTo ( ans . ToString ( ) ) > 0 && ans . Length == newstr . Length ) newstr . Length > ans . Length ) { ans . Append ( newstr ) ; } } return ; } StringBuilder x = new StringBuilder ( newstr . ToString ( ) + str [ index ] ) ; findLargestNo ( str , x , ans , index + 1 , K ) ; findLargestNo ( str , newstr , ans , index + 1 , K ) ; } public static void Main ( String [ ] args ) { String str = "121400" ; StringBuilder ans = new StringBuilder ( ) , newstr = new StringBuilder ( ) ; long K = 8 ; findLargestNo ( str , newstr , ans , 0 , K ) ; if ( ans . ToString ( ) != " " ) Console . WriteLine ( ans ) ; else Console . WriteLine ( - 1 ) ; } }

Index/key variables: i, index
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static readonly int SZ = 100 ; static void pathSum ( int [ , ] mat , int N , int M ) { int [ , ] dp = new int [ N , M ] ; dp [ 0 , 0 ] = mat [ 0 , 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { dp [ i , 0 ] = mat [ i , 0 ] + dp [ i - 1 , 0 ] ; } for ( int j = 1 ; j < M ; j ++ ) { dp [ 0 , j ] = mat [ 0 , j ] + dp [ 0 , j - 1 ] ; } for ( int i = 1 ; i < N ; i ++ ) { for ( int j = 1 ; j < M ; j ++ ) { dp [ i , j ] = mat [ i , j ] + Math . Max ( dp [ i - 1 , j ] , dp [ i , j - 1 ] ) ; } } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { Console . Write ( dp [ i , j ] + " ▁ " ) ; } Console . WriteLine ( ) ; } } public static void Main ( String [ ] args ) { int [ , ] mat = { { 3 , 2 , 1 } , { 6 , 5 , 4 } , { 7 , 8 , 9 } } ; int N = 3 ; int M = 3 ; pathSum ( mat , N , M ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int longestPalSubstr ( String str ) { int n = str . Length ; bool [ , ] table = new bool [ n , n ] ; int maxLength = 1 ; for ( int i = 0 ; i < n ; ++ i ) table [ i , i ] = true ; int start = 0 ; for ( int i = 0 ; i < n - 1 ; ++ i ) { if ( str [ i ] == str [ i + 1 ] ) { table [ i , i + 1 ] = true ; start = i ; maxLength = 2 ; } } for ( int k = 3 ; k <= n ; ++ k ) { for ( int i = 0 ; i < n - k + 1 ; ++ i ) { int j = i + k - 1 ; if ( table [ i + 1 , j - 1 ] && str [ i ] == str [ j ] ) { table [ i , j ] = true ; if ( k > maxLength ) { start = i ; maxLength = k ; } } } } return maxLength ; } public static void Main ( String [ ] args ) { String str = " forgeeksskeegfor " ; Console . Write ( longestPalSubstr ( str ) ) ; } }

Index/key variables: i, j
Iterator variables: i, k
Class/struct names: GFG
C# program:
using System ; class GFG { public static int maxSumFlip ( int [ ] a , int n ) { int total_sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) total_sum += a [ i ] ; int max_sum = int . MinValue ; for ( int i = 0 ; i < n ; i ++ ) { int sum = 0 ; for ( int j = i ; j < n ; j ++ ) { sum += a [ j ] ; max_sum = Math . Max ( max_sum , total_sum - 2 * sum ) ; } } return Math . Max ( max_sum , total_sum ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { - 2 , 3 , - 1 , - 4 , - 2 } ; int N = arr . Length ; Console . WriteLine ( maxSumFlip ( arr , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, sum, total_sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int INF = ( int ) 1e7 ; static int max_size = 100007 ; static int [ ] dp = new int [ max_size ] ; static int min_op ( int cur , int M ) { if ( cur > M ) return INF ; if ( cur == M ) return 0 ; if ( dp [ cur ] != - 1 ) return dp [ cur ] ; int op = INF ; for ( int i = 2 ; i * i <= cur ; i ++ ) { if ( cur % i == 0 ) { if ( i % 2 == 0 ) { op = Math . Min ( op , 1 + min_op ( cur + i , M ) ) ; } if ( ( cur / i ) != i && ( cur / i ) % 2 == 0 ) { op = Math . Min ( op , 1 + min_op ( cur + ( cur / i ) , M ) ) ; } } } return dp [ cur ] = op ; } static int min_operations ( int N , int M ) { for ( int i = N ; i <= M ; i ++ ) { dp [ i ] = - 1 ; } return min_op ( N , M ) ; } public static void Main ( String [ ] args ) { int N = 6 , M = 24 ; int op = min_operations ( N , M ) ; if ( op >= INF ) Console . Write ( " - 1" ) ; else Console . Write ( op + " STRNEWLINE " ) ; } }

Index/key variables: cur, i, max_size
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int maxValue ( int [ ] a , int n , int pos , int moves , int left , int [ , ] dp ) { if ( moves == 0 || ( pos > n - 1 pos < 0 ) ) return 0 ; if ( dp [ pos , left ] != - 1 ) return dp [ pos , left ] ; int value = 0 ; if ( left > 0 && pos >= 1 ) value = Math . Max ( value , a [ pos ] + maxValue ( a , n , pos - 1 , moves - 1 , left - 1 , dp ) ) ; if ( pos <= n - 1 ) value = Math . Max ( value , a [ pos ] + maxValue ( a , n , pos + 1 , moves - 1 , left , dp ) ) ; return dp [ pos , left ] = value ; } public static void Main ( String [ ] args ) { int n = 5 ; int [ ] a = { 1 , 5 , 4 , 3 , 2 } ; int k = 1 ; int m = 4 ; int [ , ] dp = new int [ n + 1 , k + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) for ( int j = 0 ; j <= k ; j ++ ) dp [ i , j ] = - 1 ; Console . WriteLine ( ( a [ 0 ] + maxValue ( a , n , 1 , m , k , dp ) ) ) ; } }

Index/key variables: pos
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static int maximumSum ( int [ ] a , int count , int index , int n , int [ , ] dp ) { if ( index == n ) return 0 ; if ( dp [ index , count ] != - 1 ) return dp [ index , count ] ; int take_element = a [ index ] * count + maximumSum ( a , count + 1 , index + 1 , n , dp ) ; int dont_take = maximumSum ( a , count , index + 1 , n , dp ) ; return dp [ index , count ] = Math . Max ( take_element , dont_take ) ; } public static void Main ( String [ ] args ) { int n = 5 ; int [ ] a = { - 1 , - 9 , 0 , 5 , - 7 } ; int [ , ] dp = new int [ n + 1 , n + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) { for ( int j = 0 ; j < n + 1 ; j ++ ) { dp [ i , j ] = - 1 ; } } Console . WriteLine ( maximumSum ( a , 1 , 0 , n , dp ) ) ; } }

Index/key variables: index
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static readonly int N = 20 ; static bool [ ] visited = new bool [ N ] ; static int K ; static int removals = 0 ; static List < int > removed_nodes = new List < int > ( ) ; static List < List < int > > adj = new List < List < int > > ( ) ; static int dfs ( int s ) { visited [ s ] = true ; int nodes = 1 ; foreach ( int child in adj [ s ] ) { if ( visited [ child ] ) continue ; nodes += dfs ( child ) ; } if ( nodes > K ) { removals ++ ; removed_nodes . Add ( s ) ; nodes = 0 ; } return nodes ; } static void addEdge ( int a , int b ) { adj [ a ] . Add ( b ) ; adj [ b ] . Add ( a ) ; } public static void findRemovedNodes ( int K ) { dfs ( 1 ) ; Console . WriteLine ( " Number ▁ of ▁ nodes " + " ▁ removed : ▁ " + removals ) ; Console . Write ( " Removed ▁ Nodes : ▁ " ) ; foreach ( int node in removed_nodes ) Console . Write ( node + " ▁ " ) ; } public static void Main ( String [ ] args ) { for ( int i = 0 ; i < N ; i ++ ) adj . Add ( new List < int > ( ) ) ; addEdge ( 1 , 2 ) ; addEdge ( 1 , 3 ) ; addEdge ( 2 , 4 ) ; addEdge ( 2 , 5 ) ; addEdge ( 3 , 6 ) ; K = 3 ; findRemovedNodes ( K ) ; } }

Index/key variables: N, a, b, child, s
Accumulator variables: i, nodes, removals
Iterator variables: child, i, node
Class/struct names: GFG