dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { public static long getCount ( int n , int k ) { if ( n == 1 ) return 10 ; long [ ] dp = new long [ 11 ] ; long [ ] next = new long [ 11 ] ; for ( int i = 1 ; i <= 9 ; i ++ ) dp [ i ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= 9 ; j ++ ) { int l = Math . Max ( 0 , j - k ) ; int r = Math . Min ( 9 , j + k ) ; next [ l ] += dp [ j ] ; next [ r + 1 ] -= dp [ j ] ; } for ( int j = 1 ; j <= 9 ; j ++ ) next [ j ] += next [ j - 1 ] ; for ( int j = 0 ; j < 10 ; j ++ ) { dp [ j ] = next [ j ] ; next [ j ] = 0 ; } } long count = 0 ; for ( int i = 0 ; i <= 9 ; i ++ ) count += dp [ i ] ; return count ; } public static void Main ( String [ ] args ) { int n = 2 , k = 1 ; Console . WriteLine ( getCount ( n , k ) ) ; } }

Index/key variables: i, j, l
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static bool sortedAfterSwap ( int [ ] A , bool [ ] B , int n ) { int i , j ; for ( i = 0 ; i < n - 1 ; i ++ ) { if ( B [ i ] ) { j = i ; while ( B [ j ] ) { j ++ ; } Array . Sort ( A , i , 1 + j ) ; i = j ; } } for ( i = 0 ; i < n ; i ++ ) { if ( A [ i ] != i + 1 ) { return false ; } } return true ; } public static void Main ( ) { int [ ] A = { 1 , 2 , 5 , 3 , 4 , 6 } ; bool [ ] B = { false , true , true , true , false } ; int n = A . Length ; if ( sortedAfterSwap ( A , B , n ) ) { Console . WriteLine ( " A ▁ can ▁ be ▁ sorted " ) ; } else { Console . WriteLine ( " A ▁ can ▁ not ▁ be ▁ sorted " ) ; } } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { class Edge { public int src , dest , weight ; } class Graph { public int V , E ; public Edge [ ] edge ; } static Graph createGraph ( int V , int E ) { Graph graph = new Graph ( ) ; graph . V = V ; graph . E = E ; graph . edge = new Edge [ graph . E ] ; for ( int i = 0 ; i < graph . E ; i ++ ) { graph . edge [ i ] = new Edge ( ) ; } return graph ; } static void NegCycleBellmanFord ( Graph graph , int src ) { int V = graph . V ; int E = graph . E ; int [ ] dist = new int [ V ] ; int [ ] parent = new int [ V ] ; for ( int i = 0 ; i < V ; i ++ ) { dist [ i ] = 1000000 ; parent [ i ] = - 1 ; } dist [ src ] = 0 ; for ( int i = 1 ; i <= V - 1 ; i ++ ) { for ( int j = 0 ; j < E ; j ++ ) { int u = graph . edge [ j ] . src ; int v = graph . edge [ j ] . dest ; int weight = graph . edge [ j ] . weight ; if ( dist [ u ] != 1000000 && dist [ u ] + weight < dist [ v ] ) { dist [ v ] = dist [ u ] + weight ; parent [ v ] = u ; } } } int C = - 1 ; for ( int i = 0 ; i < E ; i ++ ) { int u = graph . edge [ i ] . src ; int v = graph . edge [ i ] . dest ; int weight = graph . edge [ i ] . weight ; if ( dist [ u ] != 1000000 && dist [ u ] + weight < dist [ v ] ) { C = v ; break ; } } if ( C != - 1 ) { for ( int i = 0 ; i < V ; i ++ ) C = parent [ C ] ; ArrayList cycle = new ArrayList ( ) ; for ( int v = C ; ; v = parent [ v ] ) { cycle . Add ( v ) ; if ( v == C && cycle . Count > 1 ) break ; } cycle . Reverse ( ) ; foreach ( int v in cycle ) Console . Write ( v + " ▁ " ) ; Console . WriteLine ( ) ; } else Console . WriteLine ( - 1 ) ; } public static void Main ( string [ ] args ) { int V = 5 ; int E = 5 ; Graph graph = createGraph ( V , E ) ; graph . edge [ 0 ] . src = 0 ; graph . edge [ 0 ] . dest = 1 ; graph . edge [ 0 ] . weight = 1 ; graph . edge [ 1 ] . src = 1 ; graph . edge [ 1 ] . dest = 2 ; graph . edge [ 1 ] . weight = 2 ; graph . edge [ 2 ] . src = 2 ; graph . edge [ 2 ] . dest = 3 ; graph . edge [ 2 ] . weight = 3 ; graph . edge [ 3 ] . src = 3 ; graph . edge [ 3 ] . dest = 4 ; graph . edge [ 3 ] . weight = - 3 ; graph . edge [ 4 ] . src = 4 ; graph . edge [ 4 ] . dest = 1 ; graph . edge [ 4 ] . weight = - 3 ; NegCycleBellmanFord ( graph , 0 ) ; } }

Index/key variables: C, V, i, j, src, u, v
Accumulator variables: i, j
Iterator variables: i, j, v
Class/struct names: Edge, GFG, Graph
C# program:
using System ; class GFG { static int sortedAfterSwap ( int [ ] A , int [ ] B , int n ) { int t = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( B [ i ] != 0 ) { if ( A [ i ] != i + 1 ) t = A [ i ] ; A [ i ] = A [ i + 1 ] ; A [ i + 1 ] = t ; } } for ( int i = 0 ; i < n ; i ++ ) { if ( A [ i ] != i + 1 ) return 0 ; } return 1 ; } public static void Main ( ) { int [ ] A = { 1 , 2 , 5 , 3 , 4 , 6 } ; int [ ] B = { 0 , 1 , 1 , 1 , 0 } ; int n = A . Length ; if ( sortedAfterSwap ( A , B , n ) == 0 ) Console . WriteLine ( " A ▁ can ▁ be ▁ sorted " ) ; else Console . WriteLine ( " A ▁ can ▁ not ▁ be ▁ sorted " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void segregate0and1 ( int [ ] arr , int n ) { int type0 = 0 ; int type1 = n - 1 ; while ( type0 < type1 ) { if ( arr [ type0 ] == 1 ) { arr [ type0 ] = arr [ type0 ] + arr [ type1 ] ; arr [ type1 ] = arr [ type0 ] - arr [ type1 ] ; arr [ type0 ] = arr [ type0 ] - arr [ type1 ] ; type1 -- ; } else { type0 ++ ; } } } public static void Main ( ) { int [ ] arr = { 1 , 1 , 1 , 0 , 1 , 0 , 0 , 1 , 1 , 1 , 1 } ; segregate0and1 ( arr , arr . Length ) ; for ( int i = 0 ; i < arr . Length ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } }

Index/key variables: i, type0, type1
Accumulator variables: i, type0, type1
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int printpentaRec ( int n ) { if ( n == 0 n == 1 n == 2 n == 3 n == 4 ) return 0 ; else if ( n == 5 ) return 1 ; else return ( printpentaRec ( n - 1 ) + printpentaRec ( n - 2 ) + printpentaRec ( n - 3 ) + printpentaRec ( n - 4 ) + printpentaRec ( n - 5 ) ) ; } static void printPenta ( int n ) { Console . WriteLine ( printpentaRec ( n ) ) ; } static void Main ( ) { int n = 10 ; printPenta ( n ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int [ ] arr = new int [ ] { 1 , 20 , 6 , 4 , 5 } ; static int getInvCount ( int n ) { int inv_count = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) if ( arr [ i ] > arr [ j ] ) inv_count ++ ; return inv_count ; } public static void Main ( ) { Console . WriteLine ( " Number ▁ of ▁ " + " inversions ▁ are ▁ " + getInvCount ( arr . Length ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, inv_count, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { class Query { public int L , R ; public Query ( int l , int r ) { L = l ; R = r ; } } ; static int findResultUtil ( int [ ] arr , int L , int R ) { int result = 0 ; bool flag = false ; for ( int i = L ; i <= R ; i ++ ) { if ( flag == false ) { result = result + arr [ i ] ; flag = true ; } else { result = result - arr [ i ] ; flag = false ; } } return result ; } static void findResult ( int [ ] arr , int n , Query [ ] q , int m ) { for ( int i = 0 ; i < m ; i ++ ) { Console . Write ( findResultUtil ( arr , q [ i ] . L , q [ i ] . R ) + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 10 , 13 , 15 , 2 , 45 , 31 , 22 , 3 , 27 } ; int n = arr . Length ; Query [ ] q = { new Query ( 2 , 5 ) , new Query ( 6 , 8 ) , new Query ( 1 , 7 ) , new Query ( 4 , 8 ) , new Query ( 0 , 5 ) } ; int m = q . Length ; findResult ( arr , n , q , m ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: flag
Class/struct names: GFG, Query
C# program:
using System ; class GFG { static void minAbsSumPair ( int [ ] arr , int arr_size ) { int l , r , min_sum , sum , min_l , min_r ; if ( arr_size < 2 ) { Console . Write ( " Invalid ▁ Input " ) ; return ; } min_l = 0 ; min_r = 1 ; min_sum = arr [ 0 ] + arr [ 1 ] ; for ( l = 0 ; l < arr_size - 1 ; l ++ ) { for ( r = l + 1 ; r < arr_size ; r ++ ) { sum = arr [ l ] + arr [ r ] ; if ( Math . Abs ( min_sum ) > Math . Abs ( sum ) ) { min_sum = sum ; min_l = l ; min_r = r ; } } } Console . Write ( " ▁ The ▁ two ▁ elements ▁ whose ▁ " + " sum ▁ is ▁ minimum ▁ are ▁ " + arr [ min_l ] + " ▁ and ▁ " + arr [ min_r ] ) ; } public static void Main ( ) { int [ ] arr = { 1 , 60 , - 10 , 70 , - 80 , 85 } ; minAbsSumPair ( arr , 6 ) ; } }

Index/key variables: l, min_l, min_r, r
Accumulator variables: l, r
Iterator variables: l, r
Class/struct names: GFG
C# program:
using System ; class GFG { static int maximumSum ( int S , int M , int N , int [ , ] stacks ) { int [ , ] dp = new int [ S + 1 , N + 1 ] ; for ( int i = 0 ; i < S ; i ++ ) { for ( int j = 0 ; j <= N ; j ++ ) { for ( int k = 0 ; k <= Math . Min ( j , M ) ; k ++ ) { dp [ i + 1 , j ] = Math . Max ( dp [ i + 1 , j ] , stacks [ i , k ] + dp [ i , j - k ] ) ; } } } int result = int . MinValue ; for ( int i = 0 ; i <= N ; i ++ ) { result = Math . Max ( result , dp [ S , i ] ) ; } return result ; } public static void Main ( String [ ] args ) { int S = 2 ; int M = 4 ; int [ , ] stacks = { { 2 , 6 , 4 , 5 } , { 1 , 6 , 15 , 10 } } ; int N = 3 ; Console . Write ( maximumSum ( S , M , N , stacks ) ) ; } }

Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static void findMinSum ( int [ ] arr , int n ) { for ( int i = 1 ; i < n ; i ++ ) { if ( ! ( Math . Abs ( arr [ i - 1 ] ) < Math . Abs ( arr [ i ] ) ) ) { int temp = arr [ i - 1 ] ; arr [ i - 1 ] = arr [ i ] ; arr [ i ] = temp ; } } int min = Int32 . MaxValue ; int x = 0 , y = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( Math . Abs ( arr [ i - 1 ] + arr [ i ] ) <= min ) { min = Math . Abs ( arr [ i - 1 ] + arr [ i ] ) ; x = i - 1 ; y = i ; } } Console . WriteLine ( " The ▁ two ▁ elements ▁ whose ▁ " + " sum ▁ is ▁ minimum ▁ are ▁ " + arr [ x ] + " ▁ and ▁ " + arr [ y ] ) ; } static void Main ( ) { int [ ] arr = { 1 , 60 , - 10 , 70 , - 80 , 85 } ; int n = arr . Length ; findMinSum ( arr , n ) ; } }

Index/key variables: i, x, y
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void dicesSum ( int n ) { double [ , ] dp = new double [ n + 1 , 6 * n + 1 ] ; for ( int i = 1 ; i <= 6 ; i ++ ) dp [ 1 , i ] = 1 / 6.0 ; for ( int i = 2 ; i <= n ; i ++ ) for ( int j = i - 1 ; j <= 6 * ( i - 1 ) ; j ++ ) for ( int k = 1 ; k <= 6 ; k ++ ) { dp [ i , j + k ] += ( dp [ i - 1 , j ] * dp [ 1 , k ] ) ; } for ( int i = n ; i <= 6 * n ; i ++ ) { Console . WriteLine ( i + " ▁ " + Math . Round ( dp [ n , i ] * 1000.0 ) / 1000.0 ) ; } } static void Main ( ) { int n = 2 ; dicesSum ( n ) ; } }

Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { static ArrayList ans ; static int flag = 1 ; static int dfs ( ArrayList adj , int [ ] order , int [ ] bridge_detect , bool [ ] mark , int v , int l ) { mark [ v ] = true ; order [ v ] = order [ l ] + 1 ; bridge_detect [ v ] = order [ v ] ; for ( int i = 0 ; i < ( ( ArrayList ) adj [ v ] ) . Count ; i ++ ) { int u = ( int ) ( ( ArrayList ) adj [ v ] ) [ i ] ; if ( u == l ) { continue ; } if ( order [ v ] < order [ u ] ) { continue ; } if ( mark [ u ] ) { bridge_detect [ v ] = Math . Min ( order [ u ] , bridge_detect [ v ] ) ; } else { dfs ( adj , order , bridge_detect , mark , u , v ) ; } bridge_detect [ v ] = Math . Min ( bridge_detect [ u ] , bridge_detect [ v ] ) ; ans . Add ( new int [ ] { v , u } ) ; } if ( bridge_detect [ v ] == order [ v ] && l != 0 ) { flag = 0 ; } return flag ; } static void convert ( ArrayList adj , int n ) { int [ ] order = new int [ n ] ; int [ ] bridge_detect = new int [ n ] ; bool [ ] mark = new bool [ n ] ; int flag = dfs ( adj , order , bridge_detect , mark , 1 , 0 ) ; if ( flag == 0 ) { Console . Write ( " - 1" ) ; } else { foreach ( int [ ] it in ans ) { Console . WriteLine ( it [ 0 ] + " - > " + it [ 1 ] ) ; } } } static void createGraph ( int [ , ] Edges , ArrayList adj , int M ) { for ( int i = 0 ; i < M ; i ++ ) { int u = Edges [ i , 0 ] ; int v = Edges [ i , 1 ] ; ( ( ArrayList ) adj [ u ] ) . Add ( v ) ; ( ( ArrayList ) adj [ v ] ) . Add ( u ) ; } } public static void Main ( string [ ] args ) { int N = 5 , M = 6 ; int [ , ] Edges = { { 0 , 1 } , { 0 , 2 } , { 1 , 2 } , { 1 , 4 } , { 2 , 3 } , { 3 , 4 } } ; ArrayList adj = new ArrayList ( ) ; ans = new ArrayList ( ) ; for ( int i = 0 ; i < N ; i ++ ) adj . Add ( new ArrayList ( ) ) ; createGraph ( Edges , adj , M ) ; convert ( adj , N ) ; } }

Index/key variables: i, l, n, u, v
Accumulator variables: i
Iterator variables: i, it
Class/struct names: GFG
C# program:
using System ; class GFG { public static bool increasing ( int [ ] a , int n ) { for ( int i = 0 ; i < n - 1 ; i ++ ) if ( a [ i ] >= a [ i + 1 ] ) return false ; return true ; } public static bool decreasing ( int [ ] arr , int n ) { for ( int i = 0 ; i < n - 1 ; i ++ ) if ( arr [ i ] < arr [ i + 1 ] ) return false ; return true ; } public static int shortestUnsorted ( int [ ] a , int n ) { if ( increasing ( a , n ) == true || decreasing ( a , n ) == true ) return 0 ; else return 3 ; } public static void Main ( ) { int [ ] ar = new int [ ] { 7 , 9 , 10 , 8 , 11 } ; int n = ar . Length ; Console . WriteLine ( shortestUnsorted ( ar , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; left = right = null ; } } public class Res { public int val ; } public class BinaryTree { public static Node root ; public virtual int maxPathSumUtil ( Node node , Res res ) { if ( node == null ) { return 0 ; } if ( node . left == null && node . right == null ) { return node . data ; } int ls = maxPathSumUtil ( node . left , res ) ; int rs = maxPathSumUtil ( node . right , res ) ; if ( node . left != null && node . right != null ) { res . val = Math . Max ( res . val , ls + rs + node . data ) ; return Math . Max ( ls , rs ) + node . data ; } return ( node . left == null ) ? rs + node . data : ls + node . data ; } public virtual int maxPathSum ( Node node ) { Res res = new Res ( ) ; res . val = int . MinValue ; maxPathSumUtil ( root , res ) ; return res . val ; } public static void Main ( string [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; BinaryTree . root = new Node ( - 15 ) ; BinaryTree . root . left = new Node ( 5 ) ; BinaryTree . root . right = new Node ( 6 ) ; BinaryTree . root . left . left = new Node ( - 8 ) ; BinaryTree . root . left . right = new Node ( 1 ) ; BinaryTree . root . left . left . left = new Node ( 2 ) ; BinaryTree . root . left . left . right = new Node ( 6 ) ; BinaryTree . root . right . left = new Node ( 3 ) ; BinaryTree . root . right . right = new Node ( 9 ) ; BinaryTree . root . right . right . right = new Node ( 0 ) ; BinaryTree . root . right . right . right . left = new Node ( 4 ) ; BinaryTree . root . right . right . right . right = new Node ( - 1 ) ; BinaryTree . root . right . right . right . right . left = new Node ( 10 ) ; Console . WriteLine ( " Max ▁ pathSum ▁ of ▁ the ▁ given ▁ binary ▁ tree ▁ is ▁ " + tree . maxPathSum ( root ) ) ; } }

Class/struct names: BinaryTree, Node, Res
C# program:
using System ; public class GFG { static void swap ( int [ ] arr , int i , int j ) { int temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; } static int indexOf ( int [ ] arr , int ele ) { for ( int i = 0 ; i < arr . Length ; i ++ ) { if ( arr [ i ] == ele ) { return i ; } } return - 1 ; } static int minSwaps ( int [ ] arr , int N ) { int ans = 0 ; int [ ] temp = new int [ N ] ; Array . Copy ( arr , temp , N ) ; Array . Sort ( temp ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] != temp [ i ] ) { ans ++ ; swap ( arr , i , indexOf ( arr , temp [ i ] ) ) ; } } return ans ; } static public void Main ( ) { int [ ] a = { 101 , 758 , 315 , 730 , 472 , 619 , 460 , 479 } ; int n = a . Length ; Console . WriteLine ( minSwaps ( a , n ) ) ; } }

Index/key variables: N, i, j
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int printUnion ( int [ ] arr1 , int [ ] arr2 , int m , int n ) { int i = 0 , j = 0 ; while ( i < m && j < n ) { if ( arr1 [ i ] < arr2 [ j ] ) Console . Write ( arr1 [ i ++ ] + " ▁ " ) ; else if ( arr2 [ j ] < arr1 [ i ] ) Console . Write ( arr2 [ j ++ ] + " ▁ " ) ; else { Console . Write ( arr2 [ j ++ ] + " ▁ " ) ; i ++ ; } } while ( i < m ) Console . Write ( arr1 [ i ++ ] + " ▁ " ) ; while ( j < n ) Console . Write ( arr2 [ j ++ ] + " ▁ " ) ; return 0 ; } public static void Main ( ) { int [ ] arr1 = { 1 , 2 , 4 , 5 , 6 } ; int [ ] arr2 = { 2 , 3 , 5 , 7 } ; int m = arr1 . Length ; int n = arr2 . Length ; printUnion ( arr1 , arr2 , m , n ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { static HashSet < int > kPowKform = new HashSet < int > ( ) ; static int [ ] dp = new int [ 100005 ] ; static int func ( int n ) { if ( n <= 0 ) return 0 ; if ( kPowKform . Contains ( n ) ) return 1 ; if ( dp [ n ] != - 1 ) return dp [ n ] ; int answer = 0 ; int x = n ; while ( x > 0 ) { int d = x % 10 ; if ( d != 0 ) { if ( func ( n - d * d ) != 0 ) { answer = 1 ; break ; } } x /= 10 ; } dp [ n ] = answer ; return answer ; } static void canBeConverted ( int n ) { Array . Fill ( dp , - 1 ) ; if ( func ( n ) != 0 ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } public static void Main ( string [ ] args ) { int N = 13 ; for ( int i = 1 ; i <= 8 ; i ++ ) { int val = 1 ; for ( int j = 1 ; j <= i ; j ++ ) val *= i ; kPowKform . Add ( val ) ; } canBeConverted ( N ) ; } }

Index/key variables: n
Accumulator variables: i, j, val, x
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void UnionArray ( int [ ] arr1 , int [ ] arr2 ) { int m = arr1 [ arr1 . Length - 1 ] ; int n = arr2 [ arr2 . Length - 1 ] ; int ans = 0 ; if ( m > n ) ans = m ; else ans = n ; int [ ] newtable = new int [ ans + 1 ] ; Console . Write ( arr1 [ 0 ] + " ▁ " ) ; ++ newtable [ arr1 [ 0 ] ] ; for ( int i = 1 ; i < arr1 . Length ; i ++ ) { if ( arr1 [ i ] != arr1 [ i - 1 ] ) { Console . Write ( arr1 [ i ] + " ▁ " ) ; ++ newtable [ arr1 [ i ] ] ; } } for ( int j = 0 ; j < arr2 . Length ; j ++ ) { if ( newtable [ arr2 [ j ] ] == 0 ) { Console . Write ( arr2 [ j ] + " ▁ " ) ; ++ newtable [ arr2 [ j ] ] ; } } } public static void Main ( ) { int [ ] arr1 = { 1 , 2 , 2 , 2 , 3 } ; int [ ] arr2 = { 2 , 3 , 4 , 5 } ; UnionArray ( arr1 , arr2 ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void printIntersection ( int [ ] arr1 , int [ ] arr2 , int m , int n ) { int i = 0 , j = 0 ; while ( i < m && j < n ) { if ( arr1 [ i ] < arr2 [ j ] ) i ++ ; else if ( arr2 [ j ] < arr1 [ i ] ) j ++ ; else { Console . Write ( arr2 [ j ++ ] + " ▁ " ) ; i ++ ; } } } public static void Main ( ) { int [ ] arr1 = { 1 , 2 , 4 , 5 , 6 } ; int [ ] arr2 = { 2 , 3 , 5 , 7 } ; int m = arr1 . Length ; int n = arr2 . Length ; printIntersection ( arr1 , arr2 , m , n ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Class/struct names: GFG
C# program:
using System ; class PureNumbers { public bool isPowerOfTwo ( int N ) { double number = Math . Log ( N ) / Math . Log ( 2 ) ; int checker = ( int ) number ; return number - checker == 0 ; } public bool isSeriesFour ( int N , int digits ) { int upperBound = ( int ) ( Math . Pow ( 2 , digits ) + Math . Pow ( 2 , digits - 1 ) - 1 ) ; int lowerBound = ( int ) ( Math . Pow ( 2 , digits ) - 1 ) ; return ( N >= lowerBound ) && ( N < upperBound ) ; } public string getPureNumber ( int N ) { string [ ] numbers = new string [ N + 1 ] ; numbers [ 0 ] = " " ; int blocks = 0 ; int displacement = 0 ; for ( int i = 1 ; i < N + 1 ; i ++ ) { if ( isPowerOfTwo ( i + 1 ) ) { blocks = blocks + 1 ; } if ( isSeriesFour ( i , blocks ) ) { displacement = ( int ) Math . Pow ( 2 , blocks - 1 ) ; numbers [ i ] = "4" + numbers [ i - displacement ] + "4" ; } else { displacement = ( int ) Math . Pow ( 2 , blocks ) ; numbers [ i ] = "5" + numbers [ i - displacement ] + "5" ; } } return numbers [ N ] ; } public static void Main ( ) { int N = 5 ; PureNumbers ob = new PureNumbers ( ) ; string pure = ob . getPureNumber ( N ) ; Console . Write ( pure ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: PureNumbers
C# program:
using System ; class GFG { static int [ , ] dp = new int [ 15 , 2 ] ; static String convertToString ( int num ) { return String . Join ( " " , num ) ; } static int calculate ( int pos , int tight , int [ ] D , int sz , String num ) { if ( pos == num . Length ) return 1 ; if ( dp [ pos , tight ] != - 1 ) return dp [ pos , tight ] ; int val = 0 ; if ( tight == 0 ) { for ( int i = 0 ; i < sz ; i ++ ) { if ( D [ i ] < ( num [ pos ] - '0' ) ) { val += calculate ( pos + 1 , 1 , D , sz , num ) ; } else if ( D [ i ] == num [ pos ] - '0' ) val += calculate ( pos + 1 , tight , D , sz , num ) ; } } else { for ( int i = 0 ; i < sz ; i ++ ) { val += calculate ( pos + 1 , tight , D , sz , num ) ; } } return dp [ pos , tight ] = val ; } static int countNumbers ( int [ ] D , int N , int sz ) { String num = convertToString ( N ) ; int len = num . Length ; for ( int i = 0 ; i < 15 ; i ++ ) for ( int j = 0 ; j < 2 ; j ++ ) dp [ i , j ] = - 1 ; int ans = calculate ( 0 , 0 , D , sz , num ) ; for ( int i = 1 ; i < len ; i ++ ) ans += calculate ( i , 1 , D , sz , num ) ; return ans ; } public static void Main ( String [ ] args ) { int sz = 3 ; int [ ] D = { 1 , 4 , 9 } ; int N = 10 ; Console . Write ( countNumbers ( D , N , sz ) ) ; } }

Index/key variables: i, pos
Accumulator variables: ans, i, j, val
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ , ] dp = new int [ 1001 , 1001 ] ; static int find_max ( int i , int sum , int [ ] v , int k ) { if ( i == v . Length ) return 0 ; if ( dp [ i , sum ] != - 1 ) return dp [ i , sum ] ; int ans = 0 ; if ( ( sum + find_max ( i + 1 , sum , v , k ) ) % k == 0 ) ans = find_max ( i + 1 , sum , v , k ) ; if ( ( sum + v [ i ] + find_max ( i + 1 , ( sum + v [ i ] ) % k , v , k ) ) % k == 0 ) ans = Math . Max ( ans , v [ i ] + find_max ( i + 1 , ( sum + v [ i ] ) % k , v , k ) ) ; return dp [ i , sum ] = ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 43 , 1 , 17 , 26 , 15 } ; int k = 16 ; for ( int i = 0 ; i < 1001 ; i ++ ) for ( int j = 0 ; j < 1001 ; j ++ ) dp [ i , j ] = - 1 ; Console . Write ( find_max ( 0 , 0 , arr , k ) ) ; } }

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