dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static String commonPrefixUtil ( String str1 , String str2 ) { String result = " " ; int n1 = str1 . Length , n2 = str2 . Length ; for ( int i = 0 , j = 0 ; i <= n1 - 1 && j <= n2 - 1 ; i ++ , j ++ ) { if ( str1 [ i ] != str2 [ j ] ) { break ; } result += str1 [ i ] ; } return ( result ) ; } static String commonPrefix ( String [ ] arr , int n ) { String prefix = arr [ 0 ] ; for ( int i = 1 ; i <= n - 1 ; i ++ ) { prefix = commonPrefixUtil ( prefix , arr . GetValue ( i ) . ToString ( ) ) ; } return ( prefix ) ; } public static void Main ( ) { String [ ] arr = { " geeksforgeeks " , " geeks " , " geek " , " geezer " } ; int n = arr . Length ; String ans = commonPrefix ( arr , n ) ; if ( ans . Length > 0 ) { Console . Write ( " The ▁ longest ▁ common ▁ " + " prefix ▁ is ▁ - ▁ " + ans ) ; } else { Console . Write ( " There ▁ is ▁ no ▁ common ▁ prefix " ) ; } } }

Index/key variables: i, j
Accumulator variables: i, j, result
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static char flip ( char c ) { return ( c == '0' ) ? '1' : '0' ; } static void printOneAndTwosComplement ( String bin ) { int n = bin . Length ; int i ; String ones = " " , twos = " " ; ones = twos = " " ; for ( i = 0 ; i < n ; i ++ ) { ones += flip ( bin [ i ] ) ; } twos = ones ; for ( i = n - 1 ; i >= 0 ; i -- ) { if ( ones [ i ] == '1' ) { twos = twos . Substring ( 0 , i ) + '0' + twos . Substring ( i + 1 , twos . Length - ( i + 1 ) ) ; } else { twos = twos . Substring ( 0 , i ) + '1' + twos . Substring ( i + 1 , twos . Length - ( i + 1 ) ) ; break ; } } if ( i == - 1 ) { twos = '1' + twos ; } Console . WriteLine ( "1 ' s ▁ complement : ▁ " + ones ) ; ; Console . WriteLine ( "2 ' s ▁ complement : ▁ " + twos ) ; } public static void Main ( String [ ] args ) { String bin = "1100" ; printOneAndTwosComplement ( bin ) ; } }

Index/key variables: i
Accumulator variables: i, ones
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static string zigZagConcat ( string s , int n ) { if ( n <= 1 ) { return s ; } string result = " " ; for ( int rowNum = 0 ; rowNum < n ; rowNum ++ ) { int i = rowNum ; bool up = true ; while ( i < s . Length ) { result += s [ i ] ; if ( rowNum == 0 rowNum == n - 1 ) { i += ( 2 * n - 2 ) ; } else { if ( up ) { i += ( 2 * ( n - rowNum ) - 2 ) ; } else { i += rowNum * 2 ; } up ^= true ; } } } return result ; } static public void Main ( ) { string str = " GEEKSFORGEEKS " ; int n = 3 ; Console . WriteLine ( zigZagConcat ( str , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, result, rowNum, up
Iterator variables: rowNum
Boolean variables: up
Class/struct names: GFG
C# program:
using System ; class GFG { static void pattern ( String str , int len ) { for ( int i = 0 ; i < len ; i ++ ) { int j = len - 1 - i ; for ( int k = 0 ; k < len ; k ++ ) { if ( k == i k == j ) Console . Write ( str [ k ] ) ; else Console . Write ( " ▁ " ) ; } Console . WriteLine ( " " ) ; } } public static void Main ( String [ ] args ) { String str = " geeksforgeeks " ; int len = str . Length ; pattern ( str , len ) ; } }

Index/key variables: k
Accumulator variables: i, k
Iterator variables: i, k
Class/struct names: GFG
C# program:
using System ; class GFG { static readonly int R = 3 ; static readonly int C = 3 ; static void printUtil ( String [ , ] arr , int m , int n , String [ ] output ) { output [ m ] = arr [ m , n ] ; if ( m == R - 1 ) { for ( int i = 0 ; i < R ; i ++ ) Console . Write ( output [ i ] + " ▁ " ) ; Console . WriteLine ( ) ; return ; } for ( int i = 0 ; i < C ; i ++ ) if ( arr [ m + 1 , i ] != " " && m < C ) printUtil ( arr , m + 1 , i , output ) ; } static void print ( String [ , ] arr ) { String [ ] output = new String [ R ] ; for ( int i = 0 ; i < C ; i ++ ) if ( arr [ 0 , i ] != " " ) printUtil ( arr , 0 , i , output ) ; } public static void Main ( String [ ] args ) { String [ , ] arr = { { " you " , " we " , " " } , { " have " , " are " , " " } , { " sleep " , " eat " , " drink " } } ; print ( arr ) ; } }

Index/key variables: R, i, m
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int NO_OF_CHARS = 256 ; static bool canFormPalindrome ( string str ) { int [ ] count = new int [ NO_OF_CHARS ] ; Array . Fill ( count , 0 ) ; for ( int i = 0 ; i < str . Length ; i ++ ) count [ ( int ) ( str [ i ] ) ] ++ ; int odd = 0 ; for ( int i = 0 ; i < NO_OF_CHARS ; i ++ ) { if ( ( count [ i ] & 1 ) == 1 ) odd ++ ; if ( odd > 1 ) return false ; } return true ; } public static void Main ( ) { if ( canFormPalindrome ( " geeksforgeeks " ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; if ( canFormPalindrome ( " geeksogeeks " ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: NO_OF_CHARS, i
Accumulator variables: i, odd
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static List < String > generateGray ( int n ) { if ( n <= 0 ) { List < String > temp = new List < String > ( ) ; temp . Add ( "0" ) ; return temp ; } if ( n == 1 ) { List < String > temp = new List < String > ( ) ; temp . Add ( "0" ) ; temp . Add ( "1" ) ; return temp ; } List < String > recAns = generateGray ( n - 1 ) ; List < String > mainAns = new List < String > ( ) ; for ( int i = 0 ; i < recAns . Count ; i ++ ) { String s = recAns [ i ] ; mainAns . Add ( "0" + s ) ; } for ( int i = recAns . Count - 1 ; i >= 0 ; i -- ) { String s = recAns [ i ] ; mainAns . Add ( "1" + s ) ; } return mainAns ; } static void generateGrayarr ( int n ) { List < String > arr = new List < String > ( ) ; arr = generateGray ( n ) ; for ( int i = 0 ; i < arr . Count ; i ++ ) { Console . WriteLine ( arr [ i ] ) ; } } public static void Main ( String [ ] args ) { generateGrayarr ( 3 ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int NO_OF_CHARS = 256 ; static bool areAnagram ( char [ ] str1 , char [ ] str2 ) { int [ ] count1 = new int [ NO_OF_CHARS ] ; int [ ] count2 = new int [ NO_OF_CHARS ] ; int i ; for ( i = 0 ; i < str1 . Length && i < str2 . Length ; i ++ ) { count1 [ str1 [ i ] ] ++ ; count2 [ str2 [ i ] ] ++ ; } if ( str1 . Length != str2 . Length ) return false ; for ( i = 0 ; i < NO_OF_CHARS ; i ++ ) if ( count1 [ i ] != count2 [ i ] ) return false ; return true ; } public static void Main ( ) { char [ ] str1 = ( " geeksforgeeks " ) . ToCharArray ( ) ; char [ ] str2 = ( " forgeeksgeeks " ) . ToCharArray ( ) ; if ( areAnagram ( str1 , str2 ) ) Console . WriteLine ( " The ▁ two ▁ strings ▁ are " + " anagram ▁ of ▁ each ▁ other " ) ; else Console . WriteLine ( " The ▁ two ▁ strings ▁ are ▁ not " + " ▁ anagram ▁ of ▁ each ▁ other " ) ; } }

Index/key variables: NO_OF_CHARS, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int no_of_chars = 256 ; static String findSubString ( String str , String pat ) { int len1 = str . Length ; int len2 = pat . Length ; if ( len1 < len2 ) { Console . WriteLine ( " No ▁ such ▁ window ▁ exists " ) ; return " " ; } int [ ] hash_pat = new int [ no_of_chars ] ; int [ ] hash_str = new int [ no_of_chars ] ; for ( int i = 0 ; i < len2 ; i ++ ) hash_pat [ pat [ i ] ] ++ ; int start = 0 , start_index = - 1 , min_len = int . MaxValue ; int count = 0 ; for ( int j = 0 ; j < len1 ; j ++ ) { hash_str [ str [ j ] ] ++ ; if ( hash_str [ str [ j ] ] <= hash_pat [ str [ j ] ] ) count ++ ; if ( count == len2 ) { while ( hash_str [ str [ start ] ] > hash_pat [ str [ start ] ] hash_pat [ str [ start ] ] == 0 ) { if ( hash_str [ str [ start ] ] > hash_pat [ str [ start ] ] ) hash_str [ str [ start ] ] -- ; start ++ ; } int len_window = j - start + 1 ; if ( min_len > len_window ) { min_len = len_window ; start_index = start ; } } } if ( start_index == - 1 ) { Console . WriteLine ( " No ▁ such ▁ window ▁ exists " ) ; return " " ; } return str . Substring ( start_index , min_len ) ; } public static void Main ( String [ ] args ) { String str = " this ▁ is ▁ a ▁ test ▁ string " ; String pat = " tist " ; Console . WriteLine ( " Smallest ▁ window ▁ is ▁ : STRNEWLINE ▁ " + findSubString ( str , pat ) ) ; } }

Index/key variables: i, j, no_of_chars, start
Accumulator variables: count, i, j, start
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static String removeDuplicate ( char [ ] str , int n ) { int index = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int j ; for ( j = 0 ; j < i ; j ++ ) { if ( str [ i ] == str [ j ] ) { break ; } } if ( j == i ) { str [ index ++ ] = str [ i ] ; } } char [ ] ans = new char [ index ] ; Array . Copy ( str , ans , index ) ; return String . Join ( " " , ans ) ; } public static void Main ( String [ ] args ) { char [ ] str = " geeksforgeeks " . ToCharArray ( ) ; int n = str . Length ; Console . WriteLine ( removeDuplicate ( str , n ) ) ; } }

Index/key variables: i, index, j
Accumulator variables: i, index, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool getans ( int i , List < int > v , int [ ] q ) { if ( i == q . Length ) return true ; for ( int j = 0 ; j < v . Count ; j ++ ) { if ( v [ j ] >= q [ i ] ) { v [ j ] -= q [ i ] ; if ( getans ( i + 1 , v , q ) ) { return true ; } v [ j ] += q [ i ] ; } } return false ; } static void Check ( int [ ] c , int [ ] b ) { Dictionary < int , int > m = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < b . Length ; i ++ ) m [ b [ i ] ] = 0 ; for ( int i = 0 ; i < b . Length ; i ++ ) { m [ b [ i ] ] ++ ; } List < int > v = new List < int > ( ) ; foreach ( KeyValuePair < int , int > i in m ) { v . Add ( i . Value ) ; } bool check = getans ( 0 , v , c ) ; if ( check ) Console . WriteLine ( " YES " ) ; else Console . WriteLine ( " NO " ) ; } public static void Main ( ) { int [ ] c = { 1 , 3 , 3 } ; int [ ] b = { 2 , 2 , 2 , 2 , 4 , 4 , 4 } ; Check ( c , b ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Linq ; class GFG { static int maximumXOR ( int [ ] arr , int n , int K ) { K ++ ; int maxXor = Int32 . MinValue ; for ( int i = 0 ; i < ( 1 << n ) ; i ++ ) { if ( Convert . ToString ( i , 2 ) . Count ( c => c == '1' ) == K ) { int cur_xor = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( ( i & ( 1 << j ) ) != 0 ) cur_xor = cur_xor ^ arr [ j ] ; } maxXor = Math . Max ( maxXor , cur_xor ) ; } } return maxXor ; } static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 } ; int N = arr . Length ; int M = 2 ; Console . WriteLine ( maximumXOR ( arr , N , M ) ) ; } }

Index/key variables: j
Accumulator variables: K, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void TowerOfHanoi ( int N ) { for ( int x = 1 ; x <= Math . Pow ( 2 , N ) - 1 ; x ++ ) { Console . Write ( " Move ▁ from ▁ Rod ▁ " + ( ( x & x - 1 ) % 3 + 1 ) + " ▁ to ▁ Rod ▁ " + ( ( ( x x - 1 ) + 1 ) % 3 + 1 ) + " STRNEWLINE " ) ; } } static void Main ( ) { int N = 3 ; TowerOfHanoi ( N ) ; } }

Accumulator variables: x
Iterator variables: x
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isValid ( int [ , ] board , int i , int j , int K ) { if ( board [ i , j ] <= K ) { return true ; } return false ; } static bool findPath ( int [ , ] board , int X , int Y , int M , int N , int K ) { if ( X < 0 X == M Y < 0 Y == N ) { return true ; } if ( isValid ( board , X , Y , K ) ) { int board_XY = board [ X , Y ] ; board [ X , Y ] = int . MaxValue ; if ( findPath ( board , X + 1 , Y , M , N , K - board_XY ) || findPath ( board , X - 1 , Y , M , N , K - board_XY ) || findPath ( board , X , Y + 1 , M , N , K - board_XY ) || findPath ( board , X , Y - 1 , M , N , K - board_XY ) ) { return true ; } board [ X , Y ] = board_XY ; } return false ; } public static void Main ( string [ ] args ) { int [ , ] grid = { { 25 , 5 , 25 , 25 , 25 , 25 } , { 25 , 1 , 1 , 5 , 12 , 25 } , { 25 , 1 , 12 , 0 , 15 , 25 } , { 22 , 1 , 11 , 2 , 19 , 15 } , { 25 , 2 , 2 , 1 , 12 , 15 } , { 25 , 9 , 10 , 1 , 11 , 25 } , { 25 , 25 , 25 , 25 , 25 , 25 } } ; int K = 17 ; int M = grid . Length ; int N = grid . GetLength ( 0 ) ; int X = 2 , Y = 3 ; if ( findPath ( grid , X , Y , M , N , K ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int isPerfect ( int x ) { int sum_div = 1 ; for ( int i = 2 ; i <= x / 2 ; ++ i ) { if ( x % i == 0 ) { sum_div += i ; } } if ( sum_div == x ) { return 1 ; } else return 0 ; } static void subsetSum ( int [ ] arr , int n ) { long total = 1 << n ; for ( long i = 0 ; i < total ; i ++ ) { int sum = 0 ; for ( int j = 0 ; j < n ; j ++ ) if ( ( i & ( 1 << j ) ) != 0 ) sum += arr [ j ] ; if ( isPerfect ( sum ) != 0 ) { Console . Write ( sum + " ▁ " ) ; } } } static public void Main ( ) { int [ ] arr = { 5 , 4 , 6 } ; int N = arr . Length ; subsetSum ( arr , N ) ; } }

Index/key variables: j
Accumulator variables: i, j, sum, sum_div
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void solve ( int N , int P1 , int P2 , int X , int Move , bool QuitP1 , bool QuitP2 ) { if ( N == 0 || ( QuitP1 && QuitP2 ) ) { Console . WriteLine ( " Number ▁ of ▁ pens ▁ remaining " + " ▁ in ▁ the ▁ box : ▁ " + N ) ; Console . WriteLine ( " Number ▁ of ▁ pens ▁ collected " + " ▁ by ▁ P1 : ▁ " + P1 ) ; Console . WriteLine ( " Number ▁ of ▁ pens ▁ collected " + " ▁ by ▁ P2 : ▁ " + P2 ) ; return ; } if ( Move == 0 && QuitP1 == false ) { int req_P1 = ( int ) ( Math . Pow ( 2 , X ) ) ; if ( req_P1 <= N ) { P1 += req_P1 ; N -= req_P1 ; } else { QuitP1 = true ; } } else if ( Move == 1 && QuitP2 == false ) { int req_P2 = ( int ) ( Math . Pow ( 3 , X ) ) ; if ( req_P2 <= N ) { P2 += req_P2 ; N -= req_P2 ; } else { QuitP2 = true ; } } X ++ ; Move = ( ( Move == 1 ) ? 0 : 1 ) ; solve ( N , P1 , P2 , X , Move , QuitP1 , QuitP2 ) ; } static void PenGame ( int N ) { int P1 = 0 ; int P2 = 0 ; int X = 0 ; int Move = 0 ; bool QuitP1 = false ; bool QuitP2 = false ; solve ( N , P1 , P2 , X , Move , QuitP1 , QuitP2 ) ; } public static void Main ( ) { int N = 22 ; PenGame ( N ) ; } }

Accumulator variables: N, P1, P2, X
Boolean variables: QuitP1, QuitP2
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void checkUntil ( int num , int K , int N , List < int > ans ) { if ( N == 1 ) { ans . Add ( num ) ; return ; } if ( ( num % 10 + K ) <= 9 ) checkUntil ( 10 * num + ( num % 10 + K ) , K , N - 1 , ans ) ; if ( K > 0 ) { if ( ( num % 10 - K ) >= 0 ) checkUntil ( 10 * num + num % 10 - K , K , N - 1 , ans ) ; } } static void check ( int K , int N , List < int > ans ) { for ( int i = 1 ; i <= 9 ; i ++ ) { checkUntil ( i , K , N , ans ) ; } } static void print ( List < int > ans ) { for ( int i = 0 ; i < ans . Count ; i ++ ) { Console . Write ( ans [ i ] + " , ▁ " ) ; } } public static void Main ( String [ ] args ) { int N = 4 , K = 8 ; List < int > ans = new List < int > ( ) ; ; check ( K , N , ans ) ; print ( ans ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { class pair { public int first , second ; public pair ( int f , int s ) { this . first = f ; this . second = s ; } } static int minSum = 100000000 ; static void getMinPathSum ( Dictionary < int , ArrayList > graph , bool [ ] visited , ArrayList necessary , int source , int dest , int currSum ) { if ( src == dest ) { bool flag = true ; foreach ( int i in necessary ) { if ( ! visited [ i ] ) { flag = false ; break ; } } if ( flag ) minSum = Math . Min ( minSum , currSum ) ; return ; } else { visited [ src ] = true ; foreach ( pair node in graph ) { if ( ! visited [ node . first ] ) { visited [ node . first ] = true ; getMinPathSum ( graph , visited , necessary , node . first , dest , currSum + node . second ) ; visited [ node . first ] = false ; } } visited [ src ] = false ; } } public static void Main ( string [ ] args ) { Dictionary < int , ArrayList > graph = new Dictionary < int , ArrayList > ( ) ; for ( int i = 0 ; i <= 6 ; i ++ ) graph [ i ] = new ArrayList ( ) ; graph [ 0 ] . Add ( new pair ( 1 , 2 ) ) ; graph [ 0 ] . Add ( new pair ( 2 , 3 ) ) ; graph [ 0 ] . Add ( new pair ( 3 , 2 ) ) ; graph [ 1 ] . Add ( new pair ( 4 , 4 ) ) ; graph [ 1 ] . Add ( new pair ( 0 , 1 ) ) ; graph [ 2 ] . Add ( new pair ( 4 , 5 ) ) ; graph [ 2 ] . Add ( new pair ( 5 , 6 ) ) ; graph [ 3 ] . Add ( new pair ( 5 , 7 ) ) ; graph [ 3 ] . Add ( new pair ( 0 , 1 ) ) ; graph [ 4 ] . Add ( new pair ( 6 , 4 ) ) ; graph [ 5 ] . Add ( new pair ( 4 , 2 ) ) ; graph [ 6 ] . Add ( new pair ( 7 , 11 ) ) ; int n = 7 ; int source = 0 ; int dest = 6 ; bool [ ] visited = new bool [ n ] ; ArrayList necessary = new ArrayList ( ) ; necessary . Add ( 2 ) ; necessary . Add ( 4 ) ; getMinPathSum ( graph , visited , necessary , source , dest , 0 ) ; if ( minSum == 100000000 ) Console . WriteLine ( - 1 ) ; else Console . WriteLine ( minSum ) ; } }

Index/key variables: i, n, src
Accumulator variables: i
Iterator variables: i, node
Boolean variables: flag
Class/struct names: GFG, pair
C# program:
using System ; class GFG { static void comb ( int [ ] arr , int len , int r , int ipos , int [ ] op , int opos , int sum ) { if ( opos == r ) { int sum2 = 0 ; for ( int i = 0 ; i < opos ; i ++ ) { sum2 = sum2 + op [ i ] ; } if ( sum == sum2 ) { for ( int i = 0 ; i < opos ; i ++ ) Console . Write ( op [ i ] + " , ▁ " ) ; Console . WriteLine ( ) ; } return ; } if ( ipos < len ) { comb ( arr , len , r , ipos + 1 , op , opos , sum ) ; op [ opos ] = arr [ ipos ] ; comb ( arr , len , r , ipos + 1 , op , opos + 1 , sum ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 4 , 6 , 8 , 2 , 12 } ; int K = 3 ; int S = 20 ; int N = arr . Length ; int [ ] op = new int [ N ] ; comb ( arr , N , K , 0 , op , 0 , S ) ; } }

Index/key variables: N, i, ipos, opos
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int k1 = 0 , k2 = 0 ; static bool flag = true ; static bool traverseMatrixDiagonally ( int [ , ] m , int i , int j , int row , int col ) { if ( i >= row j >= col ) { if ( flag ) { int a = k1 ; k1 = k2 ; k2 = a ; flag = ! flag ; k1 ++ ; } else { int a = k1 ; k1 = k2 ; k2 = a ; flag = ! flag ; } Console . WriteLine ( ) ; return false ; } Console . Write ( m [ i , j ] + " ▁ " ) ; if ( traverseMatrixDiagonally ( m , i + 1 , j + 1 , row , col ) ) { return true ; } if ( traverseMatrixDiagonally ( m , k1 , k2 , row , col ) ) { return true ; } return true ; } public static void Main ( String [ ] args ) { int [ , ] mtrx = { { 10 , 11 , 12 , 13 , 14 } , { 15 , 16 , 17 , 18 , 19 } , { 20 , 21 , 22 , 23 , 24 } , { 25 , 26 , 27 , 28 , 29 } , { 30 , 31 , 32 , 33 , 34 } } ; traverseMatrixDiagonally ( mtrx , 0 , 0 , 5 , 5 ) ; } }

Accumulator variables: k1
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int n = 5 , m = 7 ; class pair { public int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static List < pair > [ ] g = new List < pair > [ m ] ; static int [ ] col = new int [ n ] ; static bool cyc ; static int [ ] res = new int [ m ] ; static void dfs ( int v ) { col [ v ] = 1 ; foreach ( pair p in g [ v ] ) { int to = p . first , id = p . second ; if ( col [ to ] == 0 ) { dfs ( to ) ; res [ id ] = 1 ; } else if ( col [ to ] == 2 ) { res [ id ] = 1 ; } else { res [ id ] = 2 ; cyc = true ; } } col [ v ] = 2 ; } public static void Main ( String [ ] args ) { for ( int i = 0 ; i < m ; i ++ ) g [ i ] = new List < pair > ( ) ; g [ 0 ] . Add ( new pair ( 1 , 0 ) ) ; g [ 0 ] . Add ( new pair ( 2 , 1 ) ) ; g [ 1 ] . Add ( new pair ( 2 , 2 ) ) ; g [ 1 ] . Add ( new pair ( 3 , 3 ) ) ; g [ 2 ] . Add ( new pair ( 3 , 4 ) ) ; g [ 3 ] . Add ( new pair ( 4 , 5 ) ) ; g [ 4 ] . Add ( new pair ( 2 , 6 ) ) ; for ( int i = 0 ; i < n ; ++ i ) { if ( col [ i ] == 0 ) { dfs ( i ) ; } } Console . Write ( ( cyc ? 2 : 1 ) + " STRNEWLINE " ) ; for ( int i = 0 ; i < m ; ++ i ) { Console . Write ( res [ i ] + " ▁ " ) ; } } }

Index/key variables: i, id, m, n, to, v
Accumulator variables: i
Iterator variables: i, p
Boolean variables: cyc
Class/struct names: GFG, pair
C# program:
using System ; class GFG { public static void sumSubsets ( int [ ] set , int n , int target ) { int [ ] x = new int [ set . Length ] ; int j = set . Length - 1 ; while ( n > 0 ) { x [ j ] = n % 2 ; n = n / 2 ; j -- ; } int sum = 0 ; for ( int i = 0 ; i < set . Length ; i ++ ) if ( x [ i ] == 1 ) sum = sum + set [ i ] ; if ( sum == target ) { Console . Write ( " { " ) ; for ( int i = 0 ; i < set . Length ; i ++ ) if ( x [ i ] == 1 ) Console . Write ( set [ i ] + " , ▁ " ) ; Console . Write ( " } , ▁ " ) ; } } public static void findSubsets ( int [ ] arr , int K ) { int x = ( int ) Math . Pow ( 2 , arr . Length ) ; for ( int i = 1 ; i < x ; i ++ ) sumSubsets ( arr , i , K ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 5 , 10 , 12 , 13 , 15 , 18 } ; int K = 30 ; findSubsets ( arr , K ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxN = 10 ; static int [ ] fact = new int [ maxN ] ; static int ncr ( int n , int r ) { return ( fact [ n ] / fact [ r ] ) / fact [ n - r ] ; } static int findSum ( int [ ] arr , int n ) { fact [ 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) fact [ i ] = i * fact [ i - 1 ] ; int mul = 0 ; for ( int i = 0 ; i <= n - 1 ; i ++ ) mul += ( int ) Math . Pow ( 2 , i ) * ncr ( n - 1 , i ) ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) ans += mul * arr [ i ] ; return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 1 } ; int n = arr . Length ; Console . WriteLine ( findSum ( arr , n ) ) ; } }

Index/key variables: i, maxN, n, r
Accumulator variables: ans, i, mul
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int R = 4 ; static int C = 4 ; static int countPaths ( int [ , ] maze ) { if ( maze [ 0 , 0 ] == - 1 ) return 0 ; for ( int i = 0 ; i < R ; i ++ ) { if ( maze [ i , 0 ] == 0 ) maze [ i , 0 ] = 1 ; else break ; } for ( int i = 1 ; i < C ; i ++ ) { if ( maze [ 0 , i ] == 0 ) maze [ 0 , i ] = 1 ; else break ; } for ( int i = 1 ; i < R ; i ++ ) { for ( int j = 1 ; j < C ; j ++ ) { if ( maze [ i , j ] == - 1 ) continue ; if ( maze [ i - 1 , j ] > 0 ) maze [ i , j ] = ( maze [ i , j ] + maze [ i - 1 , j ] ) ; if ( maze [ i , j - 1 ] > 0 ) maze [ i , j ] = ( maze [ i , j ] + maze [ i , j - 1 ] ) ; } } return ( maze [ R - 1 , C - 1 ] > 0 ) ? maze [ R - 1 , C - 1 ] : 0 ; } static int numberOfPaths ( int m , int n ) { int path = 1 ; for ( int i = n ; i < ( m + n - 1 ) ; i ++ ) { path *= i ; path /= ( i - n + 1 ) ; } return path ; } static int solve ( int [ , ] maze ) { int ans = numberOfPaths ( R , C ) - countPaths ( maze ) ; return ans ; } public static void Main ( ) { int [ , ] maze = { { 0 , 0 , 0 , 0 } , { 0 , - 1 , 0 , 0 } , { - 1 , 0 , 0 , 0 } , { 0 , 0 , 0 , 0 } } ; Console . Write ( solve ( maze ) ) ; } }

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