dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { public static int findMaximumSum ( int [ ] a , int n ) { int [ ] prev_smaller = findPrevious ( a , n ) ; int [ ] next_smaller = findNext ( a , n ) ; int max_value = 0 ; for ( int i = 0 ; i < n ; i ++ ) { max_value = Math . Max ( max_value , a [ i ] * ( next_smaller [ i ] - prev_smaller [ i ] - 1 ) ) ; } return max_value ; } public static int [ ] findPrevious ( int [ ] a , int n ) { int [ ] ps = new int [ n ] ; ps [ 0 ] = - 1 ; Stack < int > stack = new Stack < int > ( ) ; stack . Push ( 0 ) ; for ( int i = 1 ; i < a . Length ; i ++ ) { while ( stack . Count > 0 && a [ stack . Peek ( ) ] >= a [ i ] ) stack . Pop ( ) ; ps [ i ] = stack . Count > 0 ? stack . Peek ( ) : - 1 ; stack . Push ( i ) ; } return ps ; } public static int [ ] findNext ( int [ ] a , int n ) { int [ ] ns = new int [ n ] ; ns [ n - 1 ] = n ; Stack < int > stack = new Stack < int > ( ) ; stack . Push ( n - 1 ) ; for ( int i = n - 2 ; i >= 0 ; i -- ) { while ( stack . Count > 0 && a [ stack . Peek ( ) ] >= a [ i ] ) stack . Pop ( ) ; ns [ i ] = stack . Count > 0 ? stack . Peek ( ) : a . Length ; stack . Push ( i ) ; } return ns ; } public static void Main ( String [ ] args ) { int n = 3 ; int [ ] a = { 80 , 48 , 82 } ; Console . WriteLine ( findMaximumSum ( a , n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
static bool compare ( int [ ] arr1 , int [ ] arr2 ) { for ( int i = 0 ; i < 256 ; i ++ ) if ( arr1 [ i ] != arr2 [ i ] ) return false ; return true ; } static bool search ( String pat , String txt ) { int M = pat . Length ; int N = txt . Length ; int [ ] countP = new int [ 256 ] ; int [ ] countTW = new int [ 256 ] ; for ( int i = 0 ; i < 256 ; i ++ ) { countP [ i ] = 0 ; countTW [ i ] = 0 ; } for ( int i = 0 ; i < M ; i ++ ) { ( countP [ pat [ i ] ] ) ++ ; ( countTW [ txt [ i ] ] ) ++ ; } for ( int i = M ; i < N ; i ++ ) { if ( compare ( countP , countTW ) ) return true ; ( countTW [ txt [ i ] ] ) ++ ; countTW [ txt [ i - M ] ] -- ; } if ( compare ( countP , countTW ) ) return true ; return false ; } public static void Main ( ) { string txt = " BACDGABCDA " ; string pat = " ABCD " ; if ( search ( pat , txt ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " NO " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
C# program:
using System ; using System . Linq ; class GFG { static double getMaxMedian ( int [ ] arr , int n , int k ) { int size = n + k ; Array . Sort ( arr ) ; if ( size % 2 == 0 ) { double median = ( double ) ( arr [ ( size / 2 ) - 1 ] + arr [ size / 2 ] ) / 2 ; return median ; } double median1 = arr [ size / 2 ] ; return median1 ; } static void Main ( ) { int [ ] arr = { 3 , 2 , 3 , 4 , 2 } ; int n = arr . Length ; int k = 2 ; Console . WriteLine ( getMaxMedian ( arr , n , k ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void printSorted ( int a , int b , int c ) { int get_max = Math . Max ( a , Math . Max ( b , c ) ) ; int get_min = - Math . Max ( - a , Math . Max ( - b , - c ) ) ; int get_mid = ( a + b + c ) - ( get_max + get_min ) ; Console . Write ( get_min + " ▁ " + get_mid + " ▁ " + get_max ) ; } public static void Main ( ) { int a = 4 , b = 1 , c = 9 ; printSorted ( a , b , c ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int binarySearch ( int [ ] a , int item , int low , int high ) { while ( low <= high ) { int mid = low + ( high - low ) / 2 ; if ( item == a [ mid ] ) return mid + 1 ; else if ( item > a [ mid ] ) low = mid + 1 ; else high = mid - 1 ; } return low ; } static void insertionSort ( int [ ] a , int n ) { int i , loc , j , selected ; for ( i = 1 ; i < n ; ++ i ) { j = i - 1 ; selected = a [ i ] ; loc = binarySearch ( a , selected , 0 , j ) ; while ( j >= loc ) { a [ j + 1 ] = a [ j ] ; j -- ; } a [ j + 1 ] = selected ; } } public static void Main ( String [ ] args ) { int [ ] a = { 37 , 23 , 0 , 17 , 12 , 72 , 31 , 46 , 100 , 88 , 54 } ; int n = a . Length , i ; insertionSort ( a , n ) ; Console . WriteLine ( " Sorted ▁ array : " ) ; for ( i = 0 ; i < n ; i ++ ) Console . Write ( a [ i ] + " ▁ " ) ; } }

Index/key variables: i, j, mid
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class InsertionSort { void sort ( int [ ] arr ) { int n = arr . Length ; for ( int i = 1 ; i < n ; ++ i ) { int key = arr [ i ] ; int j = i - 1 ; while ( j >= 0 && arr [ j ] > key ) { arr [ j + 1 ] = arr [ j ] ; j = j - 1 ; } arr [ j + 1 ] = key ; } } static void printArray ( int [ ] arr ) { int n = arr . Length ; for ( int i = 0 ; i < n ; ++ i ) Console . Write ( arr [ i ] + " ▁ " ) ; Console . Write ( " STRNEWLINE " ) ; } public static void Main ( ) { int [ ] arr = { 12 , 11 , 13 , 5 , 6 } ; InsertionSort ob = new InsertionSort ( ) ; ob . sort ( arr ) ; printArray ( arr ) ; } }

Index/key variables: i, j
Iterator variables: i
Class/struct names: InsertionSort
C# program:
using System ; using System . Collections . Generic ; public class GFG { static int validPermutations ( String str ) { Dictionary < char , int > m = new Dictionary < char , int > ( ) ; int count = str . Length , ans = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) { if ( m . ContainsKey ( str [ i ] ) ) m [ str [ i ] ] = m [ str [ i ] ] + 1 ; else m . Add ( str [ i ] , 1 ) ; } for ( int i = 0 ; i < str . Length ; i ++ ) { ans += count - m [ str [ i ] ] ; if ( m . ContainsKey ( str [ i ] ) ) m [ str [ i ] ] = m [ str [ i ] ] - 1 ; count -- ; } return ans + 1 ; } public static void Main ( String [ ] args ) { String str = " sstt " ; Console . WriteLine ( validPermutations ( str ) ) ; } }

Index/key variables: i
Accumulator variables: ans, count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int countPaths ( int n , int m ) { int [ , ] dp = new int [ n + 1 , m + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) dp [ i , 0 ] = 1 ; for ( int i = 0 ; i <= m ; i ++ ) dp [ 0 , i ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) for ( int j = 1 ; j <= m ; j ++ ) dp [ i , j ] = dp [ i - 1 , j ] + dp [ i , j - 1 ] ; return dp [ n , m ] ; } public static void Main ( ) { int n = 3 , m = 2 ; Console . WriteLine ( " ▁ Number ▁ of " + " ▁ Paths ▁ " + countPaths ( n , m ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { static bool equalIgnoreCase ( String str1 , String str2 ) { str1 = str1 . ToUpper ( ) ; str2 = str2 . ToUpper ( ) ; int x = str1 . CompareTo ( str2 ) ; if ( x != 0 ) { return false ; } else { return true ; } } static void equalIgnoreCaseUtil ( String str1 , String str2 ) { bool res = equalIgnoreCase ( str1 , str2 ) ; if ( res == true ) { Console . WriteLine ( " Same " ) ; } else { Console . WriteLine ( " Not ▁ Same " ) ; } } public static void Main ( ) { String str1 , str2 ; str1 = " Geeks " ; str2 = " geeks " ; equalIgnoreCaseUtil ( str1 , str2 ) ; str1 = " Geek " ; str2 = " geeksforgeeks " ; equalIgnoreCaseUtil ( str1 , str2 ) ; } }

Class/struct names: GFG
C# program:
using System ; public class GFG { public static string replaceConsonants ( string str ) { string res = " " ; int i = 0 , count = 0 ; while ( i < str . Length ) { if ( str [ i ] != ' a ' && str [ i ] != ' e ' && str [ i ] != ' i ' && str [ i ] != ' o ' && str [ i ] != ' u ' ) { i ++ ; count ++ ; } else { if ( count > 0 ) { res += count ; } res += str [ i ] ; i ++ ; count = 0 ; } } if ( count > 0 ) { res += count ; } return res ; } public static void Main ( string [ ] args ) { string str = " abcdeiop " ; Console . WriteLine ( replaceConsonants ( str ) ) ; } }

Index/key variables: i
Accumulator variables: count, i, res
Class/struct names: GFG
C# program:
using System ; public class GFG { static bool isVowel ( char c ) { return ( c == ' a ' c == ' e ' c == ' i ' c == ' o ' c == ' u ' ) ; } static String encryptString ( String s , int n , int k ) { int countVowels = 0 ; int countConsonants = 0 ; String ans = " " ; for ( int l = 0 ; l <= n - k ; l ++ ) { countVowels = 0 ; countConsonants = 0 ; for ( int r = l ; r <= l + k - 1 ; r ++ ) { if ( isVowel ( s [ r ] ) == true ) { countVowels ++ ; } else { countConsonants ++ ; } } ans += Convert . ToString ( countVowels * countConsonants ) ; } return ans ; } static public void Main ( ) { String s = " hello " ; int n = s . Length ; int k = 2 ; Console . Write ( encryptString ( s , n , k ) ) ; } }

Index/key variables: r
Accumulator variables: ans, countConsonants, countVowels, l, r
Iterator variables: l, r
Class/struct names: GFG
C# program:
using System ; using System . Text ; class GFG { private static StringBuilder charBuffer = new StringBuilder ( ) ; public static String processWords ( String input ) { String [ ] s = input . Split ( ' ▁ ' ) ; foreach ( String values in s ) { charBuffer . Append ( values [ 0 ] ) ; } return charBuffer . ToString ( ) ; } public static void Main ( ) { String input = " geeks ▁ for ▁ geeks " ; Console . WriteLine ( processWords ( input ) ) ; } }

Iterator variables: values
Class/struct names: GFG
C# program:
using System ; class GFG { static string toString ( char [ ] a ) { string String = new string ( a ) ; return String ; } static void generate ( int k , char [ ] ch , int n ) { if ( n == k ) { Console . Write ( toString ( ch ) + " ▁ " ) ; return ; } if ( ch [ n - 1 ] == '0' ) { ch [ n ] = '0' ; generate ( k , ch , n + 1 ) ; ch [ n ] = '1' ; generate ( k , ch , n + 1 ) ; } if ( ch [ n - 1 ] == '1' ) { ch [ n ] = '0' ; generate ( k , ch , n + 1 ) ; } } static void fun ( int k ) { if ( k <= 0 ) { return ; } char [ ] ch = new char [ k ] ; ch [ 0 ] = '0' ; generate ( k , ch , 1 ) ; ch [ 0 ] = '1' ; generate ( k , ch , 1 ) ; } static void Main ( ) { int k = 3 ; fun ( k ) ; } }

Index/key variables: k, n
Class/struct names: GFG
C# program:
using System ; class GFG { static float findVolume ( float a ) { if ( a < 0 ) return - 1 ; float r = a / 2 ; float h = a ; float V = ( float ) ( 3.14 * Math . Pow ( r , 2 ) * h ) ; return V ; } public static void Main ( ) { float a = 5 ; Console . WriteLine ( findVolume ( a ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { public static float volumeTriangular ( int a , int b , int h ) { float vol = ( float ) ( 0.1666 ) * a * b * h ; return vol ; } public static float volumeSquare ( int b , int h ) { float vol = ( float ) ( 0.33 ) * b * b * h ; return vol ; } public static float volumePentagonal ( int a , int b , int h ) { float vol = ( float ) ( 0.83 ) * a * b * h ; return vol ; } public static float volumeHexagonal ( int a , int b , int h ) { float vol = ( float ) a * b * h ; return vol ; } public static void Main ( ) { int b = 4 , h = 9 , a = 4 ; Console . WriteLine ( " Volume ▁ of ▁ triangular " + " ▁ base ▁ pyramid ▁ is ▁ " + volumeTriangular ( a , b , h ) ) ; Console . WriteLine ( " Volume ▁ of ▁ square ▁ " + " base ▁ pyramid ▁ is ▁ " + volumeSquare ( b , h ) ) ; Console . WriteLine ( " Volume ▁ of ▁ pentagonal " + " ▁ base ▁ pyramid ▁ is ▁ " + volumePentagonal ( a , b , h ) ) ; Console . WriteLine ( " Volume ▁ of ▁ Hexagonal " + " ▁ base ▁ pyramid ▁ is ▁ " + volumeHexagonal ( a , b , h ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static double Area ( int b1 , int b2 , int h ) { return ( ( b1 + b2 ) / 2 ) * h ; } public static void Main ( ) { int base1 = 8 , base2 = 10 , height = 6 ; double area = Area ( base1 , base2 , height ) ; Console . WriteLine ( " Area ▁ is : ▁ " + area ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int numberOfDiagonals ( int n ) { return n * ( n - 3 ) / 2 ; } public static void Main ( ) { int n = 5 ; Console . Write ( n + " ▁ sided ▁ convex ▁ polygon ▁ have ▁ " ) ; Console . WriteLine ( numberOfDiagonals ( n ) + " ▁ diagonals " ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void maximumArea ( int l , int b , int x , int y ) { int left , right , above , below ; left = x * b ; right = ( l - x - 1 ) * b ; above = l * y ; below = ( b - y - 1 ) * l ; Console . Write ( Math . Max ( Math . Max ( left , right ) , Math . Max ( above , below ) ) ) ; } public static void Main ( String [ ] args ) { int L = 8 , B = 8 ; int X = 0 , Y = 0 ; maximumArea ( L , B , X , Y ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int delCost ( string s , int [ ] cost ) { int ans = 0 ; Dictionary < int , int > forMax = new Dictionary < int , int > ( ) ; Dictionary < int , int > forTot = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < s . Length ; i ++ ) { if ( ! forMax . ContainsKey ( s [ i ] ) ) { forMax [ s [ i ] ] = cost [ i ] ; } else { forMax [ s [ i ] ] = Math . Max ( cost [ i ] , forMax [ s [ i ] ] ) ; } if ( ! forTot . ContainsKey ( s [ i ] ) ) { forTot [ s [ i ] ] = cost [ i ] ; } else { forTot [ s [ i ] ] += cost [ i ] ; } } foreach ( KeyValuePair < int , int > i in forMax ) { ans += forTot [ i . Key ] - i . Value ; } return ans ; } static void Main ( ) { string s = " AAABBB " ; int [ ] cost = { 1 , 2 , 3 , 4 , 5 , 6 } ; Console . WriteLine ( delCost ( s , cost ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static readonly int MAX = 10000 ; static List < int > [ ] divisors = new List < int > [ MAX + 1 ] ; static void computeDivisors ( ) { for ( int i = 1 ; i <= MAX ; i ++ ) { for ( int j = i ; j <= MAX ; j += i ) { divisors [ j ] . Add ( i ) ; } } } static int getClosest ( int val1 , int val2 , int target ) { if ( target - val1 >= val2 - target ) return val2 ; else return val1 ; } static int findClosest ( List < int > array , int n , int target ) { int [ ] arr = array . ToArray ( ) ; if ( target <= arr [ 0 ] ) return arr [ 0 ] ; if ( target >= arr [ n - 1 ] ) return arr [ n - 1 ] ; int i = 0 , j = n , mid = 0 ; while ( i < j ) { mid = ( i + j ) / 2 ; if ( arr [ mid ] == target ) return arr [ mid ] ; if ( target < arr [ mid ] ) { if ( mid > 0 && target > arr [ mid - 1 ] ) return getClosest ( arr [ mid - 1 ] , arr [ mid ] , target ) ; j = mid ; } else { if ( mid < n - 1 && target < arr [ mid + 1 ] ) return getClosest ( arr [ mid ] , arr [ mid + 1 ] , target ) ; i = mid + 1 ; } } return arr [ mid ] ; } static void printClosest ( int N , int X ) { computeDivisors ( ) ; int ans = findClosest ( divisors [ N ] , divisors [ N ] . Count , X ) ; Console . Write ( ans ) ; } public static void Main ( String [ ] args ) { int N = 16 , X = 5 ; for ( int i = 0 ; i < divisors . Length ; i ++ ) divisors [ i ] = new List < int > ( ) ; printClosest ( N , X ) ; } }

Index/key variables: N, i, j, mid
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int maxMatch ( int [ ] A , int [ ] B ) { Dictionary < int , int > Aindex = new Dictionary < int , int > ( ) ; Dictionary < int , int > diff = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < A . Length ; i ++ ) { Aindex [ A [ i ] ] = i ; } for ( int i = 0 ; i < B . Length ; i ++ ) { if ( i - Aindex [ B [ i ] ] < 0 ) { if ( ! diff . ContainsKey ( A . Length + i - Aindex [ B [ i ] ] ) ) { diff [ A . Length + i - Aindex [ B [ i ] ] ] = 1 ; } else { diff [ A . Length + i - Aindex [ B [ i ] ] ] += 1 ; } } else { if ( ! diff . ContainsKey ( i - Aindex [ B [ i ] ] ) ) { diff [ i - Aindex [ B [ i ] ] ] = 1 ; } else { diff [ i - Aindex [ B [ i ] ] ] += 1 ; } } } int max = 0 ; foreach ( KeyValuePair < int , int > ele in diff ) { if ( ele . Value > max ) { max = ele . Value ; } } return max ; } static void Main ( ) { int [ ] A = { 5 , 3 , 7 , 9 , 8 } ; int [ ] B = { 8 , 7 , 3 , 5 , 9 } ; Console . WriteLine ( maxMatch ( A , B ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: ele, i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int N = 9 ; static bool isinRange ( int [ , ] board ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( board [ i , j ] <= 0 board [ i , j ] > 9 ) { return false ; } } } return true ; } static bool isValidSudoku ( int [ , ] board ) { if ( isinRange ( board ) == false ) { return false ; } bool [ ] unique = new bool [ N + 1 ] ; for ( int i = 0 ; i < N ; i ++ ) { Array . Fill ( unique , false ) ; for ( int j = 0 ; j < N ; j ++ ) { int Z = board [ i , j ] ; if ( unique [ Z ] ) { return false ; } unique [ Z ] = true ; } } for ( int i = 0 ; i < N ; i ++ ) { Array . Fill ( unique , false ) ; for ( int j = 0 ; j < N ; j ++ ) { int Z = board [ j , i ] ; if ( unique [ Z ] ) { return false ; } unique [ Z ] = true ; } } for ( int i = 0 ; i < N - 2 ; i += 3 ) { for ( int j = 0 ; j < N - 2 ; j += 3 ) { Array . Fill ( unique , false ) ; for ( int k = 0 ; k < 3 ; k ++ ) { for ( int l = 0 ; l < 3 ; l ++ ) { int X = i + k ; int Y = j + l ; int Z = board [ X , Y ] ; if ( unique [ Z ] ) { return false ; } unique [ Z ] = true ; } } } } return true ; } public static void Main ( ) { int [ , ] board = { { 7 , 9 , 2 , 1 , 5 , 4 , 3 , 8 , 6 } , { 6 , 4 , 3 , 8 , 2 , 7 , 1 , 5 , 9 } , { 8 , 5 , 1 , 3 , 9 , 6 , 7 , 2 , 4 } , { 2 , 6 , 5 , 9 , 7 , 3 , 8 , 4 , 1 } , { 4 , 8 , 9 , 5 , 6 , 1 , 2 , 7 , 3 } , { 3 , 1 , 7 , 4 , 8 , 2 , 9 , 6 , 5 } , { 1 , 3 , 6 , 7 , 4 , 8 , 5 , 9 , 2 } , { 9 , 7 , 4 , 2 , 1 , 5 , 6 , 3 , 8 } , { 5 , 2 , 8 , 6 , 3 , 9 , 4 , 1 , 7 } } ; if ( isValidSudoku ( board ) ) { Console . WriteLine ( " Valid " ) ; } else { Console . WriteLine ( " Not ▁ Valid " ) ; } } }

Index/key variables: Z
Accumulator variables: i, j, k, l
Iterator variables: i, j, k, l
Class/struct names: GFG
C# program:
using System ; class GFG { public static bool palindrome ( int [ ] a , int i , int j ) { while ( i < j ) { if ( a [ i ] != a [ j ] ) return false ; i ++ ; j -- ; } return true ; } static int findSubArray ( int [ ] arr , int k ) { int n = arr . Length ; for ( int i = 0 ; i <= n - k ; i ++ ) { if ( palindrome ( arr , i , i + k - 1 ) ) return i ; } return - 1 ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 3 , 5 , 1 , 3 } ; int k = 4 ; int ans = findSubArray ( arr , k ) ; if ( ans == - 1 ) Console . Write ( - 1 + " STRNEWLINE " ) ; else { for ( int i = ans ; i < ans + k ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; Console . Write ( " STRNEWLINE " ) ; } } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void isCrossed ( String path ) { if ( path . Length == 0 ) return ; bool ans = false ; HashSet < KeyValuePair < int , int > > mySet = new HashSet < KeyValuePair < int , int > > ( ) ; int x = 0 , y = 0 ; mySet . Add ( new KeyValuePair < int , int > ( x , y ) ) ; for ( int i = 0 ; i < path . Length ; i ++ ) { if ( path [ i ] == ' N ' ) mySet . Add ( new KeyValuePair < int , int > ( x , y ++ ) ) ; if ( path [ i ] == ' S ' ) mySet . Add ( new KeyValuePair < int , int > ( x , y -- ) ) ; if ( path [ i ] == ' E ' ) mySet . Add ( new KeyValuePair < int , int > ( x ++ , y ) ) ; if ( path [ i ] == ' W ' ) mySet . Add ( new KeyValuePair < int , int > ( x -- , y ) ) ; if ( mySet . Contains ( new KeyValuePair < int , int > ( x , y ) ) ) { ans = true ; break ; } } if ( ans ) Console . Write ( " Crossed " ) ; else Console . Write ( " Not ▁ Crossed " ) ; } public static void Main ( String [ ] args ) { String path = " NESW " ; isCrossed ( path ) ; } }

Index/key variables: i
Accumulator variables: i, x, y
Iterator variables: i
Boolean variables: ans
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int maxWidth ( int N , int M , List < int > cost , List < List < int > > s ) { List < List < int > > adj = new List < List < int > > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { adj . Add ( new List < int > ( ) ) ; } for ( int i = 0 ; i < M ; i ++ ) { adj [ s [ i ] [ 0 ] ] . Add ( s [ i ] [ 1 ] ) ; } int result = 0 ; Queue < int > q = new Queue < int > ( ) ; q . Enqueue ( 0 ) ; while ( q . Count != 0 ) { int count = q . Count ; result = Math . Max ( count , result ) ; while ( count -- > 0 ) { int temp = q . Dequeue ( ) ; for ( int i = 0 ; i < adj [ temp ] . Count ; i ++ ) { q . Enqueue ( adj [ temp ] [ i ] ) ; } } } return result ; } static public void Main ( ) { int N = 11 , M = 10 ; List < List < int > > edges = new List < List < int > > ( ) ; edges . Add ( new List < int > ( ) { 0 , 1 } ) ; edges . Add ( new List < int > ( ) { 0 , 2 } ) ; edges . Add ( new List < int > ( ) { 0 , 3 } ) ; edges . Add ( new List < int > ( ) { 1 , 4 } ) ; edges . Add ( new List < int > ( ) { 1 , 5 } ) ; edges . Add ( new List < int > ( ) { 3 , 6 } ) ; edges . Add ( new List < int > ( ) { 4 , 7 } ) ; edges . Add ( new List < int > ( ) { 6 , 10 } ) ; edges . Add ( new List < int > ( ) { 6 , 8 } ) ; edges . Add ( new List < int > ( ) { 6 , 9 } ) ; List < int > cost = new List < int > ( ) { 1 , 2 , - 1 , 3 , 4 , 5 , 8 , 2 , 6 , 12 , 7 } ; Console . WriteLine ( maxWidth ( N , M , cost , edges ) ) ; } }

Index/key variables: i, temp
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { static int MAX = 10000000 ; static bool [ ] isPrime = new bool [ MAX + 1 ] ; static ArrayList primes = new ArrayList ( ) ; static void SieveOfEratosthenes ( ) { Array . Fill ( isPrime , true ) ; for ( int p = 2 ; p * p <= MAX ; p ++ ) { if ( isPrime [ p ] == true ) { for ( int i = p * p ; i <= MAX ; i += p ) isPrime [ i ] = false ; } } for ( int p = 2 ; p <= MAX ; p ++ ) if ( isPrime [ p ] ) primes . Add ( p ) ; } static int prime_search ( ArrayList primes , int diff ) { int low = 0 ; int high = primes . Count - 1 ; int res = - 1 ; while ( low <= high ) { int mid = ( low + high ) / 2 ; if ( ( int ) primes [ mid ] == diff ) { return ( int ) primes [ mid ] ; } else if ( ( int ) primes [ mid ] < diff ) { low = mid + 1 ; } else { res = ( int ) primes [ mid ] ; high = mid - 1 ; } } return res ; } static int minCost ( int [ ] arr , int n ) { SieveOfEratosthenes ( ) ; int res = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] < arr [ i - 1 ] ) { int diff = arr [ i - 1 ] - arr [ i ] ; int closest_prime = prime_search ( primes , diff ) ; res += closest_prime ; arr [ i ] += closest_prime ; } } return res ; } public static void Main ( string [ ] args ) { int [ ] arr = { 2 , 1 , 5 , 4 , 3 } ; int n = 5 ; Console . Write ( minCost ( arr , n ) ) ; } }

Index/key variables: i, mid, p
Accumulator variables: i, p, res
Iterator variables: i, p
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int count ( String s ) { int cnt = 0 ; foreach ( char c in s . ToCharArray ( ) ) { cnt += c == '0' ? 1 : 0 ; } if ( cnt % 3 != 0 ) return 0 ; int res = 0 , k = cnt / 3 , sum = 0 ; Dictionary < int , int > map = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < s . Length ; i ++ ) { sum += s [ i ] == '0' ? 1 : 0 ; if ( sum == 2 * k && map . ContainsKey ( k ) && i < s . Length - 1 && i > 0 ) { res += map [ k ] ; } if ( map . ContainsKey ( sum ) ) map [ sum ] = map [ sum ] + 1 ; else map . Add ( sum , 1 ) ; } return res ; } public static void Main ( String [ ] args ) { String str = "01010" ; Console . WriteLine ( count ( str ) ) ; } }

Index/key variables: i, k, sum
Accumulator variables: cnt, i, res, sum
Iterator variables: c, i
Class/struct names: GFG