dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int MOD = 1000000007 ; static long modInv ( long a ) { long p = MOD - 2 ; long s = 1 ; while ( p != 1 ) { if ( p % 2 == 1 ) s = ( s * a ) % MOD ; a = ( a * a ) % MOD ; p /= 2 ; } return ( a * s ) % MOD ; } static long findCnt ( char x , String y ) { long ans = 0 ; long [ ] fact = new long [ y . Length + 1 ] ; for ( int i = 0 ; i < y . Length + 1 ; i ++ ) fact [ i ] = 1 ; for ( int i = 1 ; i <= y . Length ; i ++ ) fact [ i ] = ( fact [ i - 1 ] * i ) % MOD ; for ( int i = 0 ; i < y . Length ; i ++ ) { if ( y [ i ] == x ) { ans += ( modInv ( fact [ i ] ) * modInv ( fact [ y . Length - i - 1 ] ) ) % MOD ; ans %= MOD ; } } ans *= fact [ ( y . Length - 1 ) ] ; ans %= MOD ; return ans ; } public static void Main ( ) { char x = ' a ' ; string y = " xxayy " ; Console . WriteLine ( findCnt ( x , y ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i, p
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static void findSubSeq ( int [ ] arr , int n ) { Array . Sort ( arr ) ; int [ ] count = new int [ n ] ; int [ ] prev = new int [ n ] ; int i , j ; for ( i = 0 ; i < n ; i ++ ) count [ i ] = 1 ; for ( j = 0 ; j < n ; j ++ ) prev [ j ] = - 1 ; int max = 0 ; int maxprev = - 1 ; for ( i = 0 ; i < n ; i ++ ) { for ( j = i - 1 ; j >= 0 ; j -- ) { if ( arr [ i ] % arr [ j ] == 0 && count [ j ] + 1 > count [ i ] ) { count [ i ] = count [ j ] + 1 ; prev [ i ] = j ; } } if ( max < count [ i ] ) { max = count [ i ] ; maxprev = i ; } } i = maxprev ; while ( i >= 0 ) { if ( arr [ i ] != - 1 ) Console . Write ( arr [ i ] + " ▁ " ) ; i = prev [ i ] ; } } public static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 } ; int n = arr . Length ; findSubSeq ( 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 long solve ( string str , int K ) { int n = str . Length ; long [ , ] dp = new long [ K , n ] ; if ( n < K ) return - 1 ; else if ( n == K ) return 0 ; long zeroes = 0 , ones = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == '0' ) zeroes ++ ; else ones ++ ; dp [ 0 , i ] = ones * zeroes ; } for ( int s = 1 ; s < K ; s ++ ) { for ( int i = 0 ; i < n ; i ++ ) { dp [ s , i ] = Int32 . MaxValue ; ones = 0 ; zeroes = 0 ; for ( int k = i ; k >= 0 ; k -- ) { if ( str [ k ] == '0' ) zeroes ++ ; else ones ++ ; dp [ s , i ] = Math . Min ( dp [ s , i ] , + ( ( k - 1 >= 0 ) ? ones * zeroes + dp [ s - 1 , k - 1 ] : Int32 . MaxValue ) ) ; } } } return ( dp [ K - 1 , n - 1 ] == Int32 . MaxValue ) ? - 1 : dp [ K - 1 , n - 1 ] ; } public static void Main ( string [ ] args ) { string S = "0101" ; int K = 2 ; Console . WriteLine ( solve ( S , K ) ) ; } }

Index/key variables: i, k
Accumulator variables: i, k, ones, s, zeroes
Iterator variables: i, k, s
Class/struct names: GFG
C# program:
using System ; public class GFG { private static void substringCheck ( string stra , string strb , int [ ] query ) { int [ , ] matrix = new int [ strb . Length , stra . Length ] ; char [ ] charCrr = stra . ToCharArray ( ) ; char [ ] charRrr = strb . ToCharArray ( ) ; for ( int c = 0 ; c < stra . Length ; c ++ ) { if ( charRrr [ 0 ] == charCrr ) { matrix [ 0 , c ] = 1 ; } } for ( int r = 1 ; r < charRrr . Length ; r ++ ) { char ch = charRrr [ r ] ; for ( int c = 1 ; c < charCrr . Length ; c ++ ) { if ( ch == charCrr && matrix [ r - 1 , c - 1 ] == 1 ) { matrix [ r , c ] = 1 ; } } } foreach ( int q in query ) { int matLoc = ( q + ( strb . Length - 1 ) ) ; if ( matLoc >= stra . Length ) { Console . WriteLine ( false ) ; } else { if ( matrix [ strb . Length - 1 , matLoc ] == 1 ) { Console . WriteLine ( true ) ; } else { Console . WriteLine ( false ) ; } } } } public static void Main ( string [ ] args ) { string stra = " GeeksForGeeks " ; string strb = " Geeks " ; int [ ] query = { 0 , 5 , 8 } ; substringCheck ( stra , strb , query ) ; } }

Index/key variables: r
Accumulator variables: c, r
Iterator variables: c, q, r
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 100000 ; static int bitscount = 32 ; static int [ , ] prefix_count = new int [ bitscount , MAX ] ; static void findPrefixCount ( int [ ] arr , int n ) { for ( int i = 0 ; i < bitscount ; i ++ ) { prefix_count [ i , 0 ] = ( ( arr [ 0 ] >> i ) & 1 ) ; for ( int j = 1 ; j < n ; j ++ ) { prefix_count [ i , j ] = ( ( arr [ j ] >> i ) & 1 ) ; prefix_count [ i , j ] += prefix_count [ i , j - 1 ] ; } } } static int rangeAnd ( int l , int r ) { int ans = 0 ; for ( int i = 0 ; i < bitscount ; i ++ ) { int x ; if ( l == 0 ) x = prefix_count [ i , r ] ; else x = prefix_count [ i , r ] - prefix_count [ i , l - 1 ] ; if ( x == r - l + 1 ) ans = ( ans | ( 1 << i ) ) ; } return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 7 , 5 , 3 , 5 , 2 , 3 } ; int n = arr . Length ; findPrefixCount ( arr , n ) ; int [ , ] queries = { { 1 , 3 } , { 4 , 5 } } ; int q = queries . GetLength ( 0 ) ; for ( int i = 0 ; i < q ; i ++ ) Console . WriteLine ( rangeAnd ( queries [ i , 0 ] , queries [ i , 1 ] ) ) ; } }

Index/key variables: j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class Graph { public int vertices ; public List < int > [ ] edge ; public Graph ( int vertices ) { this . vertices = vertices ; edge = new List < int > [ vertices + 1 ] ; for ( int i = 0 ; i <= vertices ; i ++ ) { edge [ i ] = new List < int > ( ) ; } } public void dfs ( int node , List < int > [ ] adj , int [ ] dp , Boolean [ ] visited ) { visited [ node ] = true ; for ( int i = 0 ; i < adj [ node ] . Count ; i ++ ) { if ( ! visited [ adj [ node ] [ i ] ] ) dfs ( adj [ node ] [ i ] , adj , dp , visited ) ; dp [ node ] = Math . Max ( dp [ node ] , 1 + dp [ adj [ node ] [ i ] ] ) ; } } public void addEdge ( int a , int b ) { edge [ a ] . Add ( b ) ; } public int findLongestPath ( int n ) { List < int > [ ] adj = edge ; int [ ] dp = new int [ n + 1 ] ; Boolean [ ] visited = new Boolean [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { if ( ! visited [ i ] ) dfs ( i , adj , dp , visited ) ; } int ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { ans = Math . Max ( ans , dp [ i ] ) ; } return ans ; } } class GFG { public static void Main ( String [ ] args ) { int n = 5 ; Graph graph = new Graph ( n ) ; graph . addEdge ( 1 , 2 ) ; graph . addEdge ( 1 , 3 ) ; graph . addEdge ( 3 , 2 ) ; graph . addEdge ( 2 , 4 ) ; graph . addEdge ( 3 , 4 ) ; graph . findLongestPath ( n ) ; Console . WriteLine ( graph . findLongestPath ( n ) ) ; } }

Index/key variables: a, i, node
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Graph
C# program:
using System ; using System . Collections ; class GFG { static int N = 100005 ; static int MAX = 10000002 ; static int [ ] lpd = new int [ MAX ] ; static void preCompute ( ) { lpd [ 0 ] = lpd [ 1 ] = 1 ; for ( int i = 2 ; i * i < MAX ; i ++ ) { for ( int j = i * 2 ; j < MAX ; j += i ) { if ( lpd [ j ] == 0 ) { lpd [ j ] = i ; } } } for ( int i = 2 ; i < MAX ; i ++ ) { if ( lpd [ i ] == 0 ) { lpd [ i ] = i ; } } } static int maxLengthSubsequence ( int [ ] arr , int n ) { int [ ] dp = new int [ N ] ; Hashtable pos = new Hashtable ( ) ; for ( int i = 0 ; i <= n ; i ++ ) dp [ i ] = 1 ; for ( int i = 0 ; i <= n ; i ++ ) { while ( arr [ i ] > 1 ) { int p = lpd [ arr [ i ] ] ; if ( pos . ContainsKey ( p ) ) { dp [ i ] = Math . Max ( dp [ i ] , 1 + dp [ Convert . ToInt32 ( pos [ p ] ) ] ) ; } pos [ p ] = i ; while ( arr [ i ] % p == 0 ) arr [ i ] /= p ; } } int ans = 1 ; for ( int i = 0 ; i <= n ; i ++ ) { ans = Math . Max ( ans , dp [ i ] ) ; } return ans ; } public static void Main ( ) { int [ ] arr = { 13 , 2 , 8 , 6 , 3 , 1 , 9 } ; int n = arr . Length - 1 ; preCompute ( ) ; Console . WriteLine ( maxLengthSubsequence ( arr , n ) ) ; } }

Index/key variables: MAX, N, i, j, p
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class Node { public int data ; public Node left , right , nextRight ; public Node ( int item ) { data = item ; left = right = nextRight = null ; } } public class BinaryTree { public Node root ; public virtual Node getNextRight ( Node p ) { Node temp = p . nextRight ; while ( temp != null ) { if ( temp . left != null ) { return temp . left ; } if ( temp . right != null ) { return temp . right ; } temp = temp . nextRight ; } return null ; } public virtual void connect ( Node p ) { Node temp = null ; if ( p == null ) { return ; } p . nextRight = null ; while ( p != null ) { Node q = p ; while ( q != null ) { if ( q . left != null ) { if ( q . right != null ) { q . left . nextRight = q . right ; } else { q . left . nextRight = getNextRight ( q ) ; } } if ( q . right != null ) { q . right . nextRight = getNextRight ( q ) ; } q = q . nextRight ; } if ( p . left != null ) { p = p . left ; } else if ( p . right != null ) { p = p . right ; } else { p = getNextRight ( p ) ; } } } public static void Main ( string [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 10 ) ; tree . root . left = new Node ( 8 ) ; tree . root . right = new Node ( 2 ) ; tree . root . left . left = new Node ( 3 ) ; tree . root . right . right = new Node ( 90 ) ; tree . connect ( tree . root ) ; int a = tree . root . nextRight != null ? tree . root . nextRight . data : - 1 ; int b = tree . root . left . nextRight != null ? tree . root . left . nextRight . data : - 1 ; int c = tree . root . right . nextRight != null ? tree . root . right . nextRight . data : - 1 ; int d = tree . root . left . left . nextRight != null ? tree . root . left . left . nextRight . data : - 1 ; int e = tree . root . right . right . nextRight != null ? tree . root . right . right . nextRight . data : - 1 ; Console . WriteLine ( " Following ▁ are ▁ populated ▁ nextRight ▁ pointers ▁ in ▁ " + " ▁ the ▁ tree ( -1 ▁ is ▁ printed ▁ if ▁ there ▁ is ▁ no ▁ nextRight ) " ) ; Console . WriteLine ( " nextRight ▁ of ▁ " + tree . root . data + " ▁ is ▁ " + a ) ; Console . WriteLine ( " nextRight ▁ of ▁ " + tree . root . left . data + " ▁ is ▁ " + b ) ; Console . WriteLine ( " nextRight ▁ of ▁ " + tree . root . right . data + " ▁ is ▁ " + c ) ; Console . WriteLine ( " nextRight ▁ of ▁ " + tree . root . left . left . data + " ▁ is ▁ " + d ) ; Console . WriteLine ( " nextRight ▁ of ▁ " + tree . root . right . right . data + " ▁ is ▁ " + e ) ; } }

Class/struct names: BinaryTree, Node
C# program:
using System ; class GFG { static int MAX = 10 ; static int [ , , ] F = new int [ MAX , MAX , MAX ] ; static int noOfAssignments ( String s , int n , int i , int c_x , int c_y ) { if ( F [ i , c_x , c_y ] != - 1 ) return F [ i , c_x , c_y ] ; if ( i == n ) { F [ i , c_x , c_y ] = ( c_x == 0 && c_y == 0 ) ? 1 : 0 ; return F [ i , c_x , c_y ] ; } if ( s [ i ] == ' ( ' ) { F [ i , c_x , c_y ] = noOfAssignments ( s , n , i + 1 , c_x + 1 , c_y ) + noOfAssignments ( s , n , i + 1 , c_x , c_y + 1 ) ; return F [ i , c_x , c_y ] ; } F [ i , c_x , c_y ] = 0 ; if ( c_x != 0 ) F [ i , c_x , c_y ] += noOfAssignments ( s , n , i + 1 , c_x - 1 , c_y ) ; if ( c_y != 0 ) F [ i , c_x , c_y ] += noOfAssignments ( s , n , i + 1 , c_x , c_y - 1 ) ; return F [ i , c_x , c_y ] ; } public static void Main ( String [ ] args ) { String s = " ( ( ) ) " ; int n = s . Length ; for ( int i = 0 ; i < MAX ; i ++ ) for ( int j = 0 ; j < MAX ; j ++ ) for ( int k = 0 ; k < MAX ; k ++ ) F [ i , j , k ] = - 1 ; Console . WriteLine ( noOfAssignments ( s , n , 0 , 0 , 0 ) ) ; } }

Index/key variables: i
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int countOddNumber ( int row_num ) { int count = 0 ; while ( row_num > 0 ) { count += row_num & 1 ; row_num >>= 1 ; } return ( 1 << count ) ; } static void gouldSequence ( int n ) { for ( int row_num = 0 ; row_num < n ; row_num ++ ) { Console . Write ( countOddNumber ( row_num ) + " ▁ " ) ; } } public static void Main ( ) { int n = 16 ; gouldSequence ( n ) ; } }

Accumulator variables: count, row_num
Iterator variables: row_num
Class/struct names: GFG
C# program:
using System ; class GFG { static long [ , , ] dp = new long [ 18 , 2 , 162 ] ; static long solve ( int i , bool tight , int sum_so_far , int Sum , String number , int len ) { if ( i == len ) { if ( sum_so_far == Sum ) return 1 ; else return 0 ; } long ans = dp [ i , 1 , sum_so_far ] ; if ( ans != - 1 ) { return ans ; } ans = 0 ; bool ntight ; int nsum_so_far ; for ( char currdigit = '0' ; currdigit <= '9' ; currdigit ++ ) { if ( ! tight && currdigit > number [ i ] ) { break ; } ntight = tight || currdigit < number [ i ] ; nsum_so_far = sum_so_far + ( currdigit - '0' ) ; ans += solve ( i + 1 , ntight , nsum_so_far , Sum , number , len ) ; } return ans ; } public static void Main ( String [ ] args ) { int sum = 4 ; String number = "100" ; for ( int i = 0 ; i < 18 ; i ++ ) { for ( int j = 0 ; j < 2 ; j ++ ) { for ( int k = 0 ; k < 162 ; k ++ ) dp [ i , j , k ] = - 1 ; } } Console . WriteLine ( solve ( 0 , false , 0 , sum , number , number . Length ) ) ; } }

Index/key variables: i
Accumulator variables: ans, currdigit, i, j, k
Iterator variables: currdigit, i, j, k
Class/struct names: GFG
C# program:
using System ; using System . Linq ; public class GFG { static int lds ( int [ ] arr , int n ) { int [ ] lds = new int [ n ] ; lds [ 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { lds [ i ] = 1 ; for ( int j = 0 ; j < i ; j ++ ) if ( lds [ j ] != 0 && arr [ i ] % arr [ j ] == 0 ) lds [ i ] = Math . Max ( lds [ i ] , lds [ j ] + 1 ) ; } int max = lds . Max ( ) ; return max ; } public static void Main ( ) { int [ ] arr = { 2 , 11 , 16 , 12 , 36 , 60 , 71 , 17 , 29 , 144 , 288 , 129 , 432 , 993 } ; int n = arr . Length ; Console . Write ( " Length ▁ of ▁ lds ▁ is ▁ " + lds ( arr , n ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class Node { public int data ; public Node left , right , nextRight ; public Node ( int item ) { data = item ; left = right = nextRight = null ; } } public class BinaryTree { Node root ; void connect ( Node p ) { Queue < Node > q = new Queue < Node > ( ) ; q . Enqueue ( root ) ; Node temp = null ; while ( q . Count > 0 ) { int n = q . Count ; for ( int i = 0 ; i < n ; i ++ ) { Node prev = temp ; temp = q . Dequeue ( ) ; if ( i > 0 ) prev . nextRight = temp ; if ( temp . left != null ) q . Enqueue ( temp . left ) ; if ( temp . right != null ) q . Enqueue ( temp . right ) ; } temp . nextRight = null ; } } public static void Main ( String [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 10 ) ; tree . root . left = new Node ( 8 ) ; tree . root . right = new Node ( 2 ) ; tree . root . left . left = new Node ( 3 ) ; tree . connect ( tree . root ) ; Console . WriteLine ( " Following ▁ are ▁ populated ▁ nextRight ▁ pointers ▁ in ▁ " + " the ▁ tree " + " ( -1 ▁ is ▁ printed ▁ if ▁ there ▁ is ▁ no ▁ nextRight ) " ) ; int a = tree . root . nextRight != null ? tree . root . nextRight . data : - 1 ; Console . WriteLine ( " nextRight ▁ of ▁ " + tree . root . data + " ▁ is ▁ " + a ) ; int b = tree . root . left . nextRight != null ? tree . root . left . nextRight . data : - 1 ; Console . WriteLine ( " nextRight ▁ of ▁ " + tree . root . left . data + " ▁ is ▁ " + b ) ; int c = tree . root . right . nextRight != null ? tree . root . right . nextRight . data : - 1 ; Console . WriteLine ( " nextRight ▁ of ▁ " + tree . root . right . data + " ▁ is ▁ " + c ) ; int d = tree . root . left . left . nextRight != null ? tree . root . left . left . nextRight . data : - 1 ; Console . WriteLine ( " nextRight ▁ of ▁ " + tree . root . left . left . data + " ▁ is ▁ " + d ) ; Console . ReadKey ( ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: BinaryTree, Node
C# program:
using System ; class GFG { static int max ( int a , int b ) { return ( a > b ) ? a : b ; } static int lcs ( char [ ] X , char [ ] Y , char [ ] Z , int m , int n , int o ) { if ( m == 0 n == 0 o == 0 ) return 0 ; if ( X [ m - 1 ] == Y [ n - 1 ] && Y [ n - 1 ] == Z [ o - 1 ] ) { return 1 + lcs ( X , Y , Z , m - 1 , n - 1 , o - 1 ) ; } else { return Math . Max ( lcs ( X , Y , Z , m , n - 1 , o ) , Math . Max ( lcs ( X , Y , Z , m - 1 , n , o ) , lcs ( X , Y , Z , m , n , o - 1 ) ) ) ; } } static void Main ( ) { char [ ] X = " geeks " . ToCharArray ( ) ; char [ ] Y = " geeksfor " . ToCharArray ( ) ; char [ ] Z = " geeksforge " . ToCharArray ( ) ; int m = X . Length ; int n = Y . Length ; int o = Z . Length ; Console . WriteLine ( " Length ▁ of ▁ LCS ▁ is ▁ " + lcs ( X , Y , Z , m , n , o ) ) ; } }

Class/struct names: GFG
C# program:
using System ; public class GFG { public static int [ , , ] arr = new int [ 100 , 100 , 100 ] ; static int lcs ( String X , String Y , String Z , int m , int n , int o ) { if ( m == 0 n == 0 o == 0 ) return 0 ; if ( arr [ m - 1 , n - 1 , o - 1 ] != - 1 ) return arr [ m - 1 , n - 1 , o - 1 ] ; if ( X [ m - 1 ] == Y [ n - 1 ] && Y [ n - 1 ] == Z [ o - 1 ] ) { arr [ m - 1 , n - 1 , o - 1 ] = 1 + lcs ( X , Y , Z , m - 1 , n - 1 , o - 1 ) ; return arr [ m - 1 , n - 1 , o - 1 ] ; } else { arr [ m - 1 , n - 1 , o - 1 ] = max ( lcs ( X , Y , Z , m , n - 1 , o ) , max ( lcs ( X , Y , Z , m - 1 , n , o ) , lcs ( X , Y , Z , m , n , o - 1 ) ) ) ; return arr [ m - 1 , n - 1 , o - 1 ] ; } } static int max ( int a , int b ) { return ( a > b ) ? a : b ; } static public void Main ( ) { for ( int i = 0 ; i < 100 ; i ++ ) { for ( int j = 0 ; j < 100 ; j ++ ) { for ( int k = 0 ; k < 100 ; k ++ ) { arr [ i , j , k ] = - 1 ; } } } String X = " geeks " ; String Y = " geeksfor " ; String Z = " geeksforgeeks " ; int m = X . Length ; int n = Y . Length ; int o = Z . Length ; Console . WriteLine ( " Length ▁ of ▁ LCS ▁ is ▁ " + lcs ( X , Y , Z , m , n , o ) ) ; } }

Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static void printProbabilities ( int n , double left ) { double right = 1 - left ; double [ , ] arr = new double [ n + 1 , 2 * n + 1 ] ; arr [ 1 , n + 1 ] = right ; arr [ 1 , n - 1 ] = left ; for ( int i = 2 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= 2 * n ; j ++ ) { arr [ i , j ] += ( arr [ i - 1 , j - 1 ] * right ) ; } for ( int j = 2 * n - 1 ; j >= 0 ; j -- ) { arr [ i , j ] += ( arr [ i - 1 , j + 1 ] * left ) ; } } printArray ( arr , n ) ; } static void printArray ( double [ , ] arr , int n ) { for ( int i = 0 ; i < GetRow ( arr , 0 ) . GetLength ( 0 ) ; i ++ ) { Console . Write ( " { 0 : F4 } ▁ " , arr [ n , i ] ) ; } } public static double [ ] GetRow ( double [ , ] matrix , int row ) { var rowLength = matrix . GetLength ( 1 ) ; var rowVector = new double [ rowLength ] ; for ( var i = 0 ; i < rowLength ; i ++ ) rowVector [ i ] = matrix [ row , i ] ; return rowVector ; } public static void Main ( String [ ] args ) { int n = 2 ; double left = 0.5 ; printProbabilities ( n , left ) ; } }

Index/key variables: i, rowLength
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public class pair { public int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static int __gcd ( int a , int b ) { if ( b == 0 ) return a ; return __gcd ( b , a % b ) ; } static int minStepsNeeded ( int k , int d1 , int d2 , int x ) { int gcd = __gcd ( d1 , d2 ) ; if ( ( k - x ) % gcd != 0 ) return - 1 ; Queue < pair > q = new Queue < pair > ( ) ; HashSet < int > visited = new HashSet < int > ( ) ; q . Enqueue ( new pair ( k , 0 ) ) ; visited . Add ( k ) ; while ( q . Count != 0 ) { int s = q . Peek ( ) . first ; int stp = q . Peek ( ) . second ; if ( s == x ) return stp ; q . Dequeue ( ) ; if ( ! visited . Contains ( s + d1 ) ) { q . Enqueue ( new pair ( s + d1 , stp + 1 ) ) ; visited . Add ( s + d1 ) ; } if ( ! visited . Contains ( s + d2 ) ) { q . Enqueue ( new pair ( s + d2 , stp + 1 ) ) ; visited . Add ( s + d2 ) ; } if ( ! visited . Contains ( s - d1 ) ) { q . Enqueue ( new pair ( s - d1 , stp + 1 ) ) ; visited . Add ( s - d1 ) ; } if ( ! visited . Contains ( s - d2 ) ) { q . Enqueue ( new pair ( s - d2 , stp + 1 ) ) ; visited . Add ( s - d2 ) ; } } return int . MinValue ; } public static void Main ( String [ ] args ) { int k = 10 , d1 = 4 , d2 = 6 , x = 8 ; Console . WriteLine ( minStepsNeeded ( k , d1 , d2 , x ) ) ; } }

Class/struct names: GFG, pair
C# program:
using System ; class GFG { static int countWays ( int n ) { int [ ] A = new int [ n + 1 ] ; int [ ] B = new int [ n + 1 ] ; A [ 0 ] = 1 ; A [ 1 ] = 0 ; B [ 0 ] = 0 ; B [ 1 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { A [ i ] = A [ i - 2 ] + 2 * B [ i - 1 ] ; B [ i ] = A [ i - 1 ] + B [ i - 2 ] ; } return A [ n ] ; } public static void Main ( ) { int n = 8 ; Console . WriteLine ( countWays ( n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int sequence ( int n ) { if ( n == 1 n == 2 ) return 1 ; else return sequence ( sequence ( n - 1 ) ) + sequence ( n - sequence ( n - 1 ) ) ; } public static void Main ( ) { int n = 10 ; Console . Write ( sequence ( n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; public class Node { public int data ; public Node left , right , nextRight ; public Node ( int item ) { data = item ; left = right = nextRight = null ; } } public class BinaryTree { public Node root ; public virtual void connect ( Node p ) { p . nextRight = null ; connectRecur ( p ) ; } public virtual void connectRecur ( Node p ) { if ( p == null ) { return ; } if ( p . left != null ) { p . left . nextRight = p . right ; } if ( p . right != null ) { p . right . nextRight = ( p . nextRight != null ) ? p . nextRight . left : null ; } connectRecur ( p . left ) ; connectRecur ( p . right ) ; } public static void Main ( string [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 10 ) ; tree . root . left = new Node ( 8 ) ; tree . root . right = new Node ( 2 ) ; tree . root . left . left = new Node ( 3 ) ; tree . connect ( tree . root ) ; Console . WriteLine ( " Following ▁ are ▁ populated ▁ nextRight ▁ pointers ▁ in ▁ " + " the ▁ tree " + " ( -1 ▁ is ▁ printed ▁ if ▁ there ▁ is ▁ no ▁ nextRight ) " ) ; int a = tree . root . nextRight != null ? tree . root . nextRight . data : - 1 ; Console . WriteLine ( " nextRight ▁ of ▁ " + tree . root . data + " ▁ is ▁ " + a ) ; int b = tree . root . left . nextRight != null ? tree . root . left . nextRight . data : - 1 ; Console . WriteLine ( " nextRight ▁ of ▁ " + tree . root . left . data + " ▁ is ▁ " + b ) ; int c = tree . root . right . nextRight != null ? tree . root . right . nextRight . data : - 1 ; Console . WriteLine ( " nextRight ▁ of ▁ " + tree . root . right . data + " ▁ is ▁ " + c ) ; int d = tree . root . left . left . nextRight != null ? tree . root . left . left . nextRight . data : - 1 ; Console . WriteLine ( " nextRight ▁ of ▁ " + tree . root . left . left . data + " ▁ is ▁ " + d ) ; } }

Class/struct names: BinaryTree, Node
C# program:
using System ; class GFG { static int numberOfWays ( int x ) { if ( x == 0 x == 1 ) return 1 ; else return numberOfWays ( x - 1 ) + ( x - 1 ) * numberOfWays ( x - 2 ) ; } public static void Main ( ) { int x = 3 ; Console . WriteLine ( numberOfWays ( x ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int numberOfWays ( int x ) { int [ ] dp = new int [ x + 1 ] ; dp [ 0 ] = dp [ 1 ] = 1 ; for ( int i = 2 ; i <= x ; i ++ ) dp [ i ] = dp [ i - 1 ] + ( i - 1 ) * dp [ i - 2 ] ; return dp [ x ] ; } public static void Main ( ) { int x = 3 ; Console . WriteLine ( numberOfWays ( x ) ) ; } }

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