dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int bitExtracted ( int number , int k , int p ) { return ( ( ( 1 << k ) - 1 ) & ( number >> ( p - 1 ) ) ) ; } public static void Main ( ) { int number = 171 , k = 5 , p = 2 ; Console . WriteLine ( " The ▁ extracted ▁ number ▁ is ▁ " + bitExtracted ( number , k , p ) ) ; } }

Class/struct names: GFG
C# program:
using System ; public class GFG { static int findMax ( int num ) { byte size_of_int = 4 ; int num_copy = num ; int j = size_of_int * 8 - 1 ; int i = 0 ; while ( i < j ) { int m = ( num_copy >> i ) & 1 ; int n = ( num_copy >> j ) & 1 ; if ( m > n ) { int x = ( 1 << i 1 << j ) ; num = num ^ x ; } i ++ ; j -- ; } return num ; } static public void Main ( ) { int num = 4 ; Console . Write ( findMax ( num ) ) ; } }

Accumulator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isAMultipleOf4 ( int n ) { if ( ( n & 3 ) == 0 ) return true ; return false ; } public static void Main ( ) { int n = 16 ; Console . WriteLine ( isAMultipleOf4 ( n ) ? " Yes " : " No " ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { public static int square ( int n ) { if ( n < 0 ) n = - n ; int res = n ; for ( int i = 1 ; i < n ; i ++ ) res += n ; return res ; } public static void Main ( ) { for ( int n = 1 ; n <= 5 ; n ++ ) Console . WriteLine ( " n ▁ = ▁ " + n + " , ▁ n ^ 2 ▁ = ▁ " + square ( n ) ) ; } }

Accumulator variables: i, n, res
Iterator variables: i, n
Class/struct names: GFG
C# program:
using System ; class GFG { static int PointInKSquares ( int n , int [ ] a , int k ) { Array . Sort ( a ) ; return a [ n - k ] ; } public static void Main ( String [ ] args ) { int k = 2 ; int [ ] a = { 1 , 2 , 3 , 4 } ; int n = a . Length ; int x = PointInKSquares ( n , a , k ) ; Console . WriteLine ( " ( " + x + " , ▁ " + x + " ) " ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static long answer ( int n ) { int [ ] dp = new int [ 10 ] ; int [ ] prev = new int [ 10 ] ; if ( n == 1 ) return 10 ; for ( int j = 0 ; j <= 9 ; j ++ ) dp [ j ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= 9 ; j ++ ) { prev [ j ] = dp [ j ] ; } for ( int j = 0 ; j <= 9 ; j ++ ) { if ( j == 0 ) dp [ j ] = prev [ j + 1 ] ; else if ( j == 9 ) dp [ j ] = prev [ j - 1 ] ; else dp [ j ] = prev [ j - 1 ] + prev [ j + 1 ] ; } } long sum = 0 ; for ( int j = 1 ; j <= 9 ; j ++ ) sum += dp [ j ] ; return sum ; } static void Main ( ) { int n = 2 ; Console . WriteLine ( answer ( n ) ) ; } }

Index/key variables: j
Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG1 { static int MAX = 100000 ; static long [ ] catalan = new long [ MAX ] ; static void catalanDP ( long n ) { catalan [ 0 ] = catalan [ 1 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { catalan [ i ] = 0 ; for ( int j = 0 ; j < i ; j ++ ) { catalan [ i ] += catalan [ j ] * catalan [ i - j - 1 ] ; } } } static int CatalanSequence ( int [ ] arr , int n ) { catalanDP ( n ) ; HashSet < int > s = new HashSet < int > ( ) ; int a = 1 , b = 1 ; s . Add ( a ) ; if ( n >= 2 ) { s . Add ( b ) ; } for ( int i = 2 ; i < n ; i ++ ) { s . Add ( ( int ) catalan [ i ] ) ; } for ( int i = 0 ; i < n ; i ++ ) { if ( s . Contains ( arr [ i ] ) ) { s . Remove ( arr [ i ] ) ; } } return s . Count ; } public static void Main ( ) { int [ ] arr = { 1 , 1 , 2 , 5 , 41 } ; int n = arr . Length ; Console . WriteLine ( CatalanSequence ( arr , n ) ) ; } }

Index/key variables: MAX, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG1
C# program:
using System ; class GFG { static int composite ( int n ) { int flag = 0 ; int c = 0 ; for ( int j = 1 ; j <= n ; j ++ ) { if ( n % j == 0 ) { c += 1 ; } } if ( c >= 3 ) flag = 1 ; return flag ; } static void odd_indices ( int [ ] arr , int n ) { int sum = 0 ; for ( int k = 0 ; k < n ; k += 2 ) { int check = composite ( arr [ k ] ) ; if ( check == 1 ) sum += arr [ k ] ; } Console . Write ( sum + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 13 , 5 , 8 , 16 , 25 } ; int n = arr . Length ; odd_indices ( arr , n ) ; } }

Index/key variables: k
Accumulator variables: c, j, k, sum
Iterator variables: j, k
Class/struct names: GFG
C# program:
using System ; class GFG { public static void preprocess ( int [ ] p , int [ ] x , int [ ] y , int n ) { for ( int i = 0 ; i < n ; i ++ ) p [ i ] = x [ i ] * x [ i ] + y [ i ] * y [ i ] ; Array . Sort ( p ) ; } public static int query ( int [ ] p , int n , int rad ) { int start = 0 , end = n - 1 ; while ( ( end - start ) > 1 ) { int mid = ( start + end ) / 2 ; double tp = Math . Sqrt ( p [ mid ] ) ; if ( tp > ( rad * 1.0 ) ) end = mid - 1 ; else start = mid ; } double tp1 = Math . Sqrt ( p [ start ] ) ; double tp2 = Math . Sqrt ( p [ end ] ) ; if ( tp1 > ( rad * 1.0 ) ) return 0 ; else if ( tp2 <= ( rad * 1.0 ) ) return end + 1 ; else return start + 1 ; } public static void Main ( ) { int [ ] x = { 1 , 2 , 3 , - 1 , 4 } ; int [ ] y = { 1 , 2 , 3 , - 1 , 4 } ; int n = x . Length ; int [ ] p = new int [ n ] ; preprocess ( p , x , y , n ) ; Console . WriteLine ( query ( p , n , 3 ) ) ; Console . WriteLine ( query ( p , n , 32 ) ) ; } }

Index/key variables: end, i, mid, n, start
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int find_Numb_ways ( int n ) { int odd_indices = n / 2 ; int even_indices = ( n / 2 ) + ( n % 2 ) ; int arr_odd = ( int ) Math . Pow ( 4 , odd_indices ) ; int arr_even = ( int ) Math . Pow ( 5 , even_indices ) ; return arr_odd * arr_even ; } public static void Main ( ) { int n = 4 ; Console . Write ( find_Numb_ways ( n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool isSpiralSorted ( int [ ] arr , int n ) { int start = 0 ; int end = n - 1 ; while ( start < end ) { if ( arr [ start ] > arr [ end ] ) { return false ; } start ++ ; if ( arr [ end ] > arr [ start ] ) { return false ; } end -- ; } return true ; } static void Main ( ) { int [ ] arr = { 1 , 10 , 14 , 20 , 18 , 12 , 5 } ; int N = arr . Length ; if ( isSpiralSorted ( arr , N ) ) Console . WriteLine ( " YES " ) ; else Console . WriteLine ( " NO " ) ; } }

Index/key variables: end, start
Accumulator variables: end, start
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void findWordsSameRow ( List < string > arr ) { Dictionary < char , int > mp = new Dictionary < char , int > ( ) ; mp . Add ( ' q ' , 1 ) ; mp . Add ( ' w ' , 1 ) ; mp . Add ( ' e ' , 1 ) ; mp . Add ( ' r ' , 1 ) ; mp . Add ( ' t ' , 1 ) ; mp . Add ( ' y ' , 1 ) ; mp . Add ( ' u ' , 1 ) ; mp . Add ( ' i ' , 1 ) ; mp . Add ( ' o ' , 1 ) ; mp . Add ( ' p ' , 1 ) ; mp . Add ( ' a ' , 2 ) ; mp . Add ( ' s ' , 2 ) ; mp . Add ( ' d ' , 2 ) ; mp . Add ( ' f ' , 2 ) ; mp . Add ( ' g ' , 2 ) ; mp . Add ( ' h ' , 2 ) ; mp . Add ( ' j ' , 2 ) ; mp . Add ( ' k ' , 2 ) ; mp . Add ( ' l ' , 2 ) ; mp . Add ( ' z ' , 3 ) ; mp . Add ( ' x ' , 3 ) ; mp . Add ( ' c ' , 3 ) ; mp . Add ( ' v ' , 3 ) ; mp . Add ( ' b ' , 3 ) ; mp . Add ( ' n ' , 3 ) ; mp . Add ( ' m ' , 3 ) ; foreach ( string word in arr ) { if ( word . Length != 0 ) { bool flag = true ; int rowNum = mp [ char . ToLower ( word [ 0 ] ) ] ; int M = word . Length ; for ( int i = 1 ; i < M ; i ++ ) { if ( mp [ Char . ToLower ( word [ i ] ) ] != rowNum ) { flag = false ; break ; } } if ( flag ) { Console . Write ( word + " ▁ " ) ; } } } } public static void Main ( String [ ] args ) { List < string > words = new List < string > ( new string [ ] { " Yeti " , " Had " , " GFG " , " comment " } ) ; findWordsSameRow ( words ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i, word
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; class GFG { static int countSubsequece ( int [ ] a , int n ) { int i , j , k , l ; int answer = 0 ; for ( i = 0 ; i < n ; i ++ ) { for ( j = i + 1 ; j < n ; j ++ ) { for ( k = j + 1 ; k < n ; k ++ ) { for ( l = k + 1 ; l < n ; l ++ ) { if ( a [ j ] == a [ l ] && a [ i ] == a [ k ] ) { answer ++ ; } } } } } return answer ; } public static void Main ( ) { int [ ] a = { 1 , 2 , 3 , 2 , 1 , 3 , 2 } ; Console . WriteLine ( countSubsequece ( a , 7 ) ) ; } }

Index/key variables: i, j, k, l
Accumulator variables: answer, i, j, k, l
Iterator variables: i, j, k, l
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static char minDistChar ( char [ ] s ) { int n = s . Length ; int [ ] first = new int [ 26 ] ; int [ ] last = new int [ 26 ] ; for ( int i = 0 ; i < 26 ; i ++ ) { first [ i ] = - 1 ; last [ i ] = - 1 ; } for ( int i = 0 ; i < n ; i ++ ) { if ( first [ s [ i ] - ' a ' ] == - 1 ) { first [ s [ i ] - ' a ' ] = i ; } last [ s [ i ] - ' a ' ] = i ; } int min = int . MaxValue ; char ans = '1' ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( last [ i ] == first [ i ] ) continue ; if ( min > last [ i ] - first [ i ] ) { min = last [ i ] - first [ i ] ; ans = ( char ) ( i + ' a ' ) ; } } return ans ; } public static void Main ( string [ ] args ) { String str = " geeksforgeeks " ; Console . Write ( minDistChar ( str . ToCharArray ( ) ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int n = 3 ; public class Pair { public int first , second ; public Pair ( int a , int b ) { first = a ; second = b ; } } static int minSteps ( int [ , ] arr ) { Boolean [ , ] v = new Boolean [ n , n ] ; Queue < Pair > q = new Queue < Pair > ( ) ; q . Enqueue ( new Pair ( 0 , 0 ) ) ; int depth = 0 ; while ( q . Count != 0 ) { int x = q . Count ; while ( x -- > 0 ) { Pair y = q . Peek ( ) ; int i = y . first , j = y . second ; q . Dequeue ( ) ; if ( v [ i , j ] ) continue ; if ( i == n - 1 && j == n - 1 ) return depth ; v [ i , j ] = true ; if ( i + arr [ i , j ] < n ) q . Enqueue ( new Pair ( i + arr [ i , j ] , j ) ) ; if ( j + arr [ i , j ] < n ) q . Enqueue ( new Pair ( i , j + arr [ i , j ] ) ) ; } depth ++ ; } return - 1 ; } public static void Main ( ) { int [ , ] arr = { { 1 , 1 , 1 } , { 1 , 1 , 1 } , { 1 , 1 , 1 } } ; Console . WriteLine ( minSteps ( arr ) ) ; } }

Accumulator variables: depth, x
Class/struct names: GFG, Pair
C# program:
using System ; class GFG { static int solve ( int [ ] a , int n ) { int max1 = int . MinValue ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( Math . Abs ( a [ i ] - a [ j ] ) > max1 ) { max1 = Math . Abs ( a [ i ] - a [ j ] ) ; } } } return max1 ; } static public void Main ( ) { int [ ] arr = { - 1 , 2 , 3 , - 4 , - 10 , 22 } ; int size = arr . Length ; Console . WriteLine ( " Largest ▁ gap ▁ is ▁ : ▁ " + solve ( arr , size ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int solve ( int [ ] a , int n ) { int min1 = a [ 0 ] ; int max1 = a [ 0 ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] > max1 ) max1 = a [ i ] ; if ( a [ i ] < min1 ) min1 = a [ i ] ; } return Math . Abs ( min1 - max1 ) ; } public static void Main ( ) { int [ ] arr = { - 1 , 2 , 3 , 4 , - 10 } ; int size = arr . Length ; Console . WriteLine ( " Largest ▁ gap ▁ is ▁ : ▁ " + solve ( arr , size ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void replaceOriginal ( String s , int n ) { char [ ] r = new char [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { r [ i ] = s [ n - 1 - i ] ; if ( s [ i ] != ' a ' && s [ i ] != ' e ' && s [ i ] != ' i ' && s [ i ] != ' o ' && s [ i ] != ' u ' ) { Console . Write ( r [ i ] ) ; } } Console . WriteLine ( " " ) ; } public static void Main ( String [ ] args ) { String s = " geeksforgeeks " ; int n = s . Length ; replaceOriginal ( s , n ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool sameStrings ( string str1 , string str2 ) { int N = str1 . Length ; int M = str2 . Length ; if ( N != M ) { return false ; } int [ ] a = new int [ 256 ] ; int [ ] b = new int [ 256 ] ; for ( int j = 0 ; j < N ; j ++ ) { a [ str1 [ j ] - ' a ' ] ++ ; b [ str2 [ j ] - ' a ' ] ++ ; } int i = 0 ; while ( i < 256 ) { if ( ( a [ i ] == 0 && b [ i ] == 0 ) || ( a [ i ] != 0 && b [ i ] != 0 ) ) { i ++ ; } else { return false ; } } Array . Sort ( a ) ; Array . Sort ( b ) ; for ( int j = 0 ; j < 256 ; j ++ ) { if ( a [ j ] != b [ j ] ) return false ; } return true ; } static public void Main ( ) { string S1 = " cabbba " , S2 = " abbccc " ; if ( sameStrings ( S1 , S2 ) ) Console . Write ( " YES " + " STRNEWLINE " ) ; else Console . Write ( " ▁ NO " + " STRNEWLINE " ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: j
Class/struct names: GFG
C# program:
using System ; class GFG { public static int solution ( int A , int B , int C ) { int [ ] arr = new int [ 3 ] ; arr [ 0 ] = A ; arr [ 1 ] = B ; arr [ 2 ] = C ; Array . Sort ( arr ) ; if ( arr [ 2 ] < arr [ 0 ] + arr [ 1 ] ) return ( ( arr [ 0 ] + arr [ 1 ] + arr [ 2 ] ) / 2 ) ; else return ( arr [ 0 ] + arr [ 1 ] ) ; } public static void Main ( String [ ] args ) { int A = 8 , B = 1 , C = 5 ; Console . WriteLine ( solution ( A , B , C ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int search ( int [ ] arr , int l , int h , int key ) { if ( l > h ) return - 1 ; int mid = ( l + h ) / 2 ; if ( arr [ mid ] == key ) return mid ; if ( ( arr [ l ] == arr [ mid ] ) && ( arr [ h ] == arr [ mid ] ) ) { ++ l ; -- h ; return search ( arr , l , h , key ) } if ( arr [ l ] <= arr [ mid ] ) { if ( key >= arr [ l ] && key <= arr [ mid ] ) return search ( arr , l , mid - 1 , key ) ; return search ( arr , mid + 1 , h , key ) ; } if ( key >= arr [ mid ] && key <= arr [ h ] ) return search ( arr , mid + 1 , h , key ) ; return search ( arr , l , mid - 1 , key ) ; } public static void Main ( ) { int [ ] arr = { 3 , 3 , 1 , 2 , 3 , 3 } ; int n = arr . Length ; int key = 3 ; Console . WriteLine ( search ( arr , 0 , n - 1 , key ) ) ; } }

Index/key variables: h, l, mid
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static String getSortedString ( char [ ] s , int n ) { List < char > v1 = new List < char > ( ) ; List < char > v2 = new List < char > ( ) ; int i = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( s [ i ] > ' a ' && s [ i ] <= ' z ' ) v1 . Add ( s [ i ] ) ; if ( s [ i ] > ' A ' && s [ i ] <= ' z ' ) v2 . Add ( s [ i ] ) ; } v1 . Sort ( ) ; v2 . Sort ( ) ; int j = 0 ; i = 0 ; for ( int k = 0 ; k < n ; k ++ ) { if ( s [ k ] > ' a ' && s [ k ] <= ' z ' ) { s [ k ] = v1 [ i ] ; ++ i ; } else if ( s [ k ] > ' A ' && s [ k ] <= ' Z ' ) { s [ k ] = v2 [ j ] ; ++ j ; } } return String . Join ( " " , s ) ; } public static void Main ( String [ ] args ) { String s = " gEeksfOrgEEkS " ; int n = s . Length ; Console . WriteLine ( getSortedString ( s . ToCharArray ( ) , n ) ) ; } }

Index/key variables: i, j, k
Accumulator variables: i, k
Iterator variables: i, k
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GfG { static bool check ( char [ ] s ) { int l = s . Length ; Array . Sort ( s ) ; for ( int i = 1 ; i < l ; i ++ ) { if ( s [ i ] - s [ i - 1 ] != 1 ) return false ; } return true ; } public static void Main ( ) { string str = " dcef " ; if ( check ( str . ToCharArray ( ) ) == true ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; String str1 = " xyza " ; if ( check ( str1 . ToCharArray ( ) ) == true ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GfG
C# program:
using System ; class GFG { static int minElements ( int [ ] arr , int n ) { int halfSum = 0 ; for ( int i = 0 ; i < n ; i ++ ) halfSum = halfSum + arr [ i ] ; halfSum = halfSum / 2 ; Array . Sort ( arr ) ; int res = 0 , curr_sum = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { curr_sum += arr [ i ] ; res ++ ; if ( curr_sum > halfSum ) return res ; } return res ; } public static void Main ( ) { int [ ] arr = { 3 , 1 , 7 , 1 } ; int n = arr . Length ; Console . WriteLine ( minElements ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: curr_sum, i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static void arrayElementEqual ( int [ ] arr , int N ) { int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += arr [ i ] ; } if ( sum % N == 0 ) { Console . WriteLine ( " Yes " ) ; } else { Console . Write ( " No " + " STRNEWLINE " ) ; } } static public void Main ( ) { int [ ] arr = { 1 , 5 , 6 , 4 } ; int N = arr . Length ; arrayElementEqual ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findMaxValByRearrArr ( int [ ] arr , int N ) { int res = 0 ; res = ( N * ( N + 1 ) ) / 2 ; return res ; } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , 2 , 1 } ; int N = arr . Length ; Console . Write ( findMaxValByRearrArr ( arr , N ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int MaximumSides ( int n ) { if ( n < 4 ) return - 1 ; return n % 2 == 0 ? n / 2 : - 1 ; } public static void Main ( String [ ] args ) { int N = 8 ; Console . Write ( MaximumSides ( N ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static double pairProductMean ( int [ ] arr , int N ) { int [ ] suffixSumArray = new int [ N ] ; suffixSumArray [ N - 1 ] = arr [ N - 1 ] ; for ( int i = N - 2 ; i >= 0 ; i -- ) { suffixSumArray [ i ] = suffixSumArray [ i + 1 ] + arr [ i ] ; } int length = ( N * ( N - 1 ) ) / 2 ; double res = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { res += arr [ i ] * suffixSumArray [ i + 1 ] ; } double mean ; if ( length != 0 ) mean = res / length ; else mean = 0 ; return mean ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 4 , 8 } ; int N = arr . Length ; Console . WriteLine ( string . Format ( " { 0:0.00 } " , pairProductMean ( arr , N ) ) ) ; } }

Index/key variables: N, i
Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int ncr ( int n , int k ) { int res = 1 ; if ( k > n - k ) k = n - k ; for ( int i = 0 ; i < k ; ++ i ) { res *= ( n - i ) ; res /= ( i + 1 ) ; } return res ; } static int countPath ( int N , int M , int K ) { int answer ; if ( K >= 2 ) answer = 0 ; else if ( K == 0 ) answer = ncr ( N + M - 2 , N - 1 ) ; else { answer = ncr ( N + M - 2 , N - 1 ) ; int X = ( N - 1 ) / 2 + ( M - 1 ) / 2 ; int Y = ( N - 1 ) / 2 ; int midCount = ncr ( X , Y ) ; X = ( ( N - 1 ) - ( N - 1 ) / 2 ) + ( ( M - 1 ) - ( M - 1 ) / 2 ) ; Y = ( ( N - 1 ) - ( N - 1 ) / 2 ) ; midCount *= ncr ( X , Y ) ; answer -= midCount ; } return answer ; } public static void Main ( String [ ] args ) { int N = 3 ; int M = 3 ; int K = 1 ; Console . Write ( countPath ( N , M , K ) ) ; } }

Accumulator variables: answer, midCount, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { class pair { public int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static int find_max ( List < pair > v , int n ) { int count = 0 ; if ( n >= 2 ) count = 2 ; else count = 1 ; for ( int i = 1 ; i < n - 1 ; i ++ ) { if ( v [ i - 1 ] . first < ( v [ i ] . first - v [ i ] . second ) ) count ++ ; else if ( v [ i + 1 ] . first > ( v [ i ] . first + v [ i ] . second ) ) { count ++ ; v [ i ] . first = v [ i ] . first + v [ i ] . second ; } else continue ; } return count ; } public static void Main ( String [ ] args ) { int n = 3 ; List < pair > v = new List < pair > ( ) ; v . Add ( new pair ( 10 , 20 ) ) ; v . Add ( new pair ( 15 , 10 ) ) ; v . Add ( new pair ( 20 , 16 ) ) ; Console . Write ( find_max ( v , n ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG, pair
C# program:
using System ; class GFG { public static void numberofsubstrings ( String str , int k , char [ ] charArray ) { int N = str . Length ; int [ ] available = new int [ 26 ] ; for ( int i = 0 ; i < k ; i ++ ) { available [ charArray [ i ] - ' a ' ] = 1 ; } int lastPos = - 1 ; int ans = ( N * ( N + 1 ) ) / 2 ; for ( int i = 0 ; i < N ; i ++ ) { if ( available [ str [ i ] - ' a ' ] == 0 ) { ans -= ( ( i - lastPos ) * ( N - i ) ) ; lastPos = i ; } } Console . WriteLine ( ans ) ; } public static void Main ( String [ ] args ) { String str = " abcb " ; int k = 2 ; char [ ] charArray = { ' a ' , ' b ' } ; numberofsubstrings ( str , k , charArray ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
class GFG { static int minCost ( int N , int P , int Q ) { int cost = 0 ; while ( N > 0 ) { if ( ( N & 1 ) > 0 ) { cost += P ; N -- ; } else { int temp = N / 2 ; if ( temp * P > Q ) cost += Q ; else cost += P * temp ; N /= 2 ; } } return cost ; } static void Main ( ) { int N = 9 , P = 5 , Q = 1 ; System . Console . WriteLine ( minCost ( N , P , Q ) ) ; } }

Accumulator variables: N, cost
Class/struct names: GFG
C# program:
using System ; class GFG { static void numberOfWays ( int n , int k ) { int [ ] dp = new int [ 1000 ] ; for ( int i = 0 ; i < n ; i ++ ) { dp [ i ] = 0 ; } dp [ 0 ] = 1 ; for ( int i = 1 ; i <= k ; i ++ ) { int numWays = 0 ; for ( int j = 0 ; j < n ; j ++ ) { numWays += dp [ j ] ; } for ( int j = 0 ; j < n ; j ++ ) { dp [ j ] = numWays - dp [ j ] ; } } Console . Write ( dp [ 0 ] ) ; } static public void Main ( ) { int N = 5 , K = 3 ; numberOfWays ( N , K ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, numWays
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int M = 1000000007 ; static int waysOfDecoding ( string s ) { long first = 1 , second = s [ 0 ] == ' * ' ? 9 : s [ 0 ] == '0' ? 0 : 1 ; for ( int i = 1 ; i < s . Length ; i ++ ) { long temp = second ; if ( s [ i ] == ' * ' ) { second = 9 * second ; if ( s [ i - 1 ] == '1' ) second = ( second + 9 * first ) % M ; else if ( s [ i - 1 ] == '2' ) second = ( second + 6 * first ) % M ; else if ( s [ i - 1 ] == ' * ' ) second = ( second + 15 * first ) % M ; } else { second = s [ i ] != '0' ? second : 0 ; if ( s [ i - 1 ] == '1' ) second = ( second + first ) % M ; else if ( s [ i - 1 ] == '2' && s [ i ] <= '6' ) second = ( second + first ) % M ; else if ( s [ i - 1 ] == ' * ' ) second = ( second + ( s [ i ] <= '6' ? 2 : 1 ) * first ) % M ; } first = temp ; } return ( int ) second ; } static public void Main ( ) { string s = " * " ; Console . WriteLine ( waysOfDecoding ( s ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findMinCost ( int [ , ] arr , int X , int n , int i = 0 ) { if ( X <= 0 ) return 0 ; if ( i >= n ) return Int32 . MaxValue ; int inc = findMinCost ( arr , X - arr [ i , 0 ] , n , i + 1 ) ; if ( inc != Int32 . MaxValue ) inc += arr [ i , 1 ] ; int exc = findMinCost ( arr , X , n , i + 1 ) ; return Math . Min ( inc , exc ) ; } public static void Main ( ) { int [ , ] arr = { { 4 , 3 } , { 3 , 2 } , { 2 , 4 } , { 1 , 3 } , { 4 , 2 } } ; int X = 7 ; int n = arr . GetLength ( 0 ) ; int ans = findMinCost ( arr , X , n ) ; if ( ans != Int32 . MaxValue ) Console . Write ( ans ) ; else Console . Write ( - 1 ) ; } }

Accumulator variables: inc
Class/struct names: GFG