codeparrot/xlcost-text-to-code huggingface dataset:
Minimize the cost to make all the adjacent elements distinct in an Array | C # program to find the minimum cost required to make all adjacent elements distinct ; Function that prints minimum cost required ; Dp - table ; Base case Not increasing the first element ; Increasing the first element by 1 ; Increasing the first element by 2 ; Condition if current element is not equal to previous non - increased element ; Condition if current element is not equal to previous element after being increased by 1 ; Condition if current element is not equal to previous element after being increased by 2 ; Take the minimum from all cases ; Finding the minimum cost ; Printing the minimum cost required to make all adjacent elements distinct ; Driver Code
using System ; class GFG { static void minimumCost ( int [ ] arr , int [ ] cost , int N ) { int [ , ] dp = new int [ N , 3 ] ; dp [ 0 , 0 ] = 0 ; dp [ 0 , 1 ] = cost [ 0 ] ; dp [ 0 , 2 ] = cost [ 0 ] * 2 ; for ( int i = 1 ; i < N ; i ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { int minimum = ( int ) 1e6 ; if ( j + arr [ i ] != arr [ i - 1 ] ) minimum = Math . Min ( minimum , dp [ i - 1 , 0 ] ) ; if ( j + arr [ i ] != arr [ i - 1 ] + 1 ) minimum = Math . Min ( minimum , dp [ i - 1 , 1 ] ) ; if ( j + arr [ i ] != arr [ i - 1 ] + 2 ) minimum = Math . Min ( minimum , dp [ i - 1 , 2 ] ) ; dp [ i , j ] = j * cost [ i ] + minimum ; } } int ans = ( int ) 1e6 ; for ( int i = 0 ; i < 3 ; i ++ ) ans = Math . Min ( ans , dp [ N - 1 , i ] ) ; Console . Write ( ans + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 1 , 2 , 2 , 3 , 4 } ; int [ ] cost = { 3 , 2 , 5 , 4 , 2 , 1 } ; int N = arr . Length ; minimumCost ( arr , cost , N ) ; } }
Subarray with largest sum after excluding its maximum element | C # implementation to find the maximum sum subarray such by excluding the maximum element from the subarray ; Function to find the maximum sum subarray by excluding the maximum element from the array ; Loop to store all the positive elements in the map ; Loop to iterating over the map and considering as the maximum element of the current including subarray ; Make the current element maximum ; Iterate through array and apply kadane 's algorithm ; Condition if current element is greater than mx then make the element - infinity ; Store the indices in some variable ; Driver code ; Function call
using System ; using System . Collections . Generic ; class GFG { static void maximumSumSubarray ( int [ ] arr , int n ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] >= 0 ) mp . Add ( arr [ i ] , 1 ) ; } int first = 0 ; int last = 0 ; int ans = 0 ; int INF = ( int ) 1e6 ; foreach ( KeyValuePair < int , int > i in mp ) { int mx = i . Key ; int curr = 0 ; int curr_start = - 1 ; for ( int j = 0 ; j < n ; j ++ ) { if ( curr == 0 ) curr_start = j ; int val = arr [ j ] > mx ? - INF : arr [ j ] ; curr += val ; if ( curr < 0 ) curr = 0 ; if ( curr > ans ) { ans = curr ; first = curr_start ; last = j ; } } } Console . Write ( ( first + 1 ) + " ▁ " + ( last + 1 ) ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 5 , - 2 , 10 , - 1 , 4 } ; int size = arr . Length ; maximumSumSubarray ( arr , size ) ; } }
Minimum insertions to make XOR of an Array equal to half of its sum | C # program to make XOR of all array elements equal to half of its sum by minimum insertions ; Function to make XOR of the array equal to half of its sum ; Calculate the sum and Xor of all the elements ; If the required condition satisfies already , return the original array ; If Xor is already zero , Insert sum ; Otherwise , insert xr and insert sum + xr ; Driver code
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { static int make_xor_half ( ArrayList arr ) { int sum = 0 , xr = 0 ; foreach ( int a in arr ) { sum += a ; xr ^= a ; } if ( 2 * xr == sum ) return - 1 ; if ( xr == 0 ) { arr . Add ( sum ) ; return 1 ; } arr . Add ( xr ) ; arr . Add ( sum + xr ) ; return 2 ; } public static void Main ( string [ ] args ) { int N = 7 ; ArrayList nums = new ArrayList ( ) { 3 , 4 , 7 , 1 , 2 , 5 , 6 } ; int count = make_xor_half ( nums ) ; if ( count == - 1 ) Console . Write ( - 1 + " STRNEWLINE " ) ; else if ( count == 1 ) Console . Write ( nums [ N ] + " STRNEWLINE " ) ; else Console . Write ( nums [ N ] + " ▁ " + nums [ N + 1 ] + " STRNEWLINE " ) ; } }
Count number of triangles possible for the given sides range | C # implementation to count the number of possible triangles for the given sides ranges ; Function to count the number of possible triangles for the given sides ranges ; Iterate for every possible of x ; Range of y is [ b , c ] From this range First we will find the number of x + y greater than d ; For x + y greater than d we can choose all z from [ c , d ] Total permutation will be ; Now we will find the number of x + y in between the [ c , d ] ; [ l , r ] will be the range from total [ c , d ] x + y belongs For any r such that r = x + y We can choose z , in the range [ c , d ] only less than r , Thus total permutation be ; Driver Code
using System ; class GFG { public static int count_triangles ( int a , int b , int c , int d ) { int ans = 0 ; for ( int x = a ; x <= b ; ++ x ) { int num_greater_than_d = Math . Max ( d , c + x ) - Math . Max ( d , b + x - 1 ) ; ans += num_greater_than_d * ( d - c + 1 ) ; int r = Math . Min ( Math . Max ( c , c + x ) , d ) - c ; int l = Math . Min ( Math . Max ( c , b + x - 1 ) , d ) - c ; int x1 = ( r * ( r + 1 ) ) / 2 ; int x2 = ( l * ( l + 1 ) ) / 2 ; ans += x1 - x2 ; } return ans ; } public static void Main ( String [ ] args ) { int a = 2 , b = 3 , c = 4 , d = 5 ; Console . WriteLine ( count_triangles ( a , b , c , d ) ) ; } }
Minimum number of swaps required to make the string K periodic | C # code to find the minimum number of swaps required to make the String K periodic ; Mark all allowed characters as true ; Initialize the freq array to 0 ; Increase the frequency of each character ; Total number of periods of size K in the String ; Check if the current character is present in allowed and whether the current frequency is greater than all previous frequencies for this position ; Update the answer by subtracting the maxfrequency from total positions if there exist extra character at the end of the String apart from the n / k characters then add 1. ; Driver code
using System ; class GFG { static void minFlip ( String s , int n , int k , char [ ] a , int p ) { bool [ ] allowed = new bool [ 26 ] ; for ( int i = 0 ; i < p ; i ++ ) { allowed [ a [ i ] - ' a ' ] = true ; } char [ , ] freq = new char [ k , 26 ] ; for ( int i = 0 ; i < k ; i ++ ) for ( int j = 0 ; j < 26 ; j ++ ) freq [ i , j ] = ( char ) 0 ; for ( int i = 0 ; i < n ; i ++ ) { freq [ i % k , s [ i ] - ' a ' ] += ( char ) 1 ; } int ans = 0 ; int totalpositions = n / k ; for ( int i = 0 ; i < k ; i ++ ) { int maxfrequency = 0 ; for ( int j = 0 ; j < 26 ; j ++ ) { if ( freq [ i , j ] > maxfrequency && allowed [ j ] == true ) maxfrequency = freq [ i , j ] ; } ans += ( totalpositions - maxfrequency + ( ( i % k < n % k ) ? 1 : 0 ) ) ; } Console . Write ( ans + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { String S = " nihsiakyt " ; int n = S . Length ; int K = 3 ; char [ ] A = { ' n ' , ' i ' , ' p ' , ' s ' , ' q ' } ; int p = A . Length ; minFlip ( S , n , K , A , p ) ; } }
Minimum number of colors required to color a Circular Array | C # implementation of above approach ; Function that finds minimum number of colors required ; To check that if all the elements are same or not ; To check if only one adjacent exist ; Traverse the array ; If adjacent elements found different means all are not same ; If two adjacent elements found to be same then make one_adjacent_same true ; If all elements are same then print 1 ; If total number of elements are even or there exist two adjacent elements that are same then print 2 ; Else 3 type of colors are required ; Driver Code ; Function call
using System ; class GFG { static void colorRequired ( int [ ] arr , int n ) { bool all_same = true ; bool one_adjacent_same = false ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( arr [ i ] != arr [ i + 1 ] ) { all_same = false ; } if ( arr [ i ] == arr [ i + 1 ] ) { one_adjacent_same = true ; } } if ( all_same == true ) { Console . Write ( 1 + " STRNEWLINE " ) ; return ; } if ( n % 2 == 0 one_adjacent_same == true ) { Console . Write ( 2 + " STRNEWLINE " ) ; return ; } Console . Write ( 3 + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 1 , 1 , 2 } ; int n = arr . Length ; colorRequired ( arr , n ) ; } }
Maximize the sum of sum of the Array by removing end elements | C # program to maximize the sum of sum of the Array by removing end elements ; Function to find the maximum sum of sum ; Compute the sum of whole array ; Traverse and remove the minimum value from an end to maximum the sum value ; If the left end element is smaller than right end ; Remove the left end element ; If the right end element is smaller than left end ; Remove the right end element ; Add the remaining element sum in the result ; Return the maximum sum of sum ; Driver code
using System ; class GFG { static int maxRemainingSum ( int [ ] arr , int n ) { int i , sum = 0 ; for ( i = 0 ; i < n ; i ++ ) sum += arr [ i ] ; i = 0 ; int j = n - 1 ; int result = 0 ; while ( i < j ) { if ( arr [ i ] < arr [ j ] ) { sum -= arr [ i ] ; i ++ ; } else { sum -= arr [ j ] ; j -- ; } result += sum ; } return result ; } public static void Main ( ) { int [ ] arr = { 3 , 1 , 7 , 2 , 1 } ; int N = arr . Length ; Console . Write ( maxRemainingSum ( arr , N ) ) ; } }
Split a number as sum of K numbers which are not divisible by K | C # program to split a number as sum of K numbers which are not divisible by K ; Function to split into K parts and print them ; Print 1 K - 1 times ; Print N - K + 1 ; Print 1 K - 2 times ; Print 2 and N - K ; Driver code
using System ; class GFG { static void printKParts ( int N , int K ) { if ( N % K == 0 ) { for ( int i = 1 ; i < K ; i ++ ) Console . Write ( "1 , ▁ " ) ; Console . Write ( N - ( K - 1 ) + " STRNEWLINE " ) ; } else { if ( K == 2 ) { Console . Write ( " Not ▁ Possible " + " STRNEWLINE " ) ; return ; } for ( int i = 1 ; i < K - 1 ; i ++ ) Console . Write ( 1 + " , ▁ " ) ; Console . Write ( 2 + " , ▁ " + ( N - K ) + " STRNEWLINE " ) ; } } public static void Main ( String [ ] args ) { int N = 18 , K = 5 ; printKParts ( N , K ) ; } }
Minimum operation required to make a balanced sequence | C # implementation of the above approach ; Function to return the minimum operations required ; Condition where we got only one closing bracket instead of 2 , here we have to add one more closing bracket to make the sequence balanced ; Add closing bracket that costs us one operation ; Remove the top opening bracket because we got the 1 opening and 2 continuous closing brackets ; Inserting the opening bracket to stack ; After making the sequence balanced closing is now set to 0 ; Case when there is no opening bracket the sequence starts with a closing bracket and one opening bracket is required Now we have one opening and one closing bracket ; Add opening bracket that costs us one operation ; Assigning 1 to cntClosing because we have one closing bracket ; Case where we got two continuous closing brackets need to pop one opening bracket from stack top ; Condition where stack is not empty This is the case where we have only opening brackets ( st . Count * 2 ) will give us the total closing bracket needed cntClosing is the count of closing bracket that we already have ; Driver code
using System ; using System . Collections . Generic ; class GFG { static int minOperations ( String s , int len ) { int operationCnt = 0 ; Stack < char > st = new Stack < char > ( ) ; int cntClosing = 0 ; for ( int i = 0 ; i < len ; i ++ ) { if ( s [ i ] == ' { ' ) { if ( cntClosing > 0 ) { operationCnt ++ ; st . Pop ( ) ; } st . Push ( s [ i ] ) ; cntClosing = 0 ; } else if ( st . Count != 0 ) { st . Push ( ' { ' ) ; operationCnt ++ ; cntClosing = 1 ; } else { cntClosing = ( cntClosing + 1 ) % 2 ; if ( cntClosing == 0 && st . Count != 0 ) { st . Pop ( ) ; } } } operationCnt += st . Count * 2 - cntClosing + 1 ; return operationCnt ; } public static void Main ( String [ ] args ) { String str = " } } { " ; int len = str . Length ; Console . Write ( minOperations ( str , len ) ) ; } }
Longest subsequence with different adjacent characters | C # program for the above approach ; Function to find the longest subsequence with different adjacent character ; Length of the String s ; Previously picked character ; If the current character is different from the previous then include this character and update previous character ; Driver Code ; Function call
using System ; class GFG { static int longestSubsequence ( String s ) { int n = s . Length ; int answer = 0 ; char prev = ' - ' ; for ( int i = 0 ; i < n ; i ++ ) { if ( prev != s [ i ] ) { prev = s [ i ] ; answer ++ ; } } return answer ; } public static void Main ( String [ ] args ) { String str = " ababa " ; Console . Write ( longestSubsequence ( str ) ) ; } }
Length of longest subarray of length at least 2 with maximum GCD | C # program for the above approach ; Function to calculate GCD of two numbers ; Function to find maximum size subarray having maximum GCD ; Base case ; Let the maximum GCD be 1 initially ; Loop through array to find maximum GCD of subarray with size 2 ; Traverse the array ; Is a multiple of k , increase cnt ; Else update maximum length with consecutive element divisible by k Set cnt to 0 ; Update the maxLength ; Return the maxLength ; Driver code ; Function call
using System ; using System . Collections . Generic ; class GFG { static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } static int maximumGcdSubarray ( int [ ] arr , int n ) { if ( n == 1 ) return 0 ; int k = 1 ; for ( int i = 1 ; i < n ; i ++ ) { k = Math . Max ( k , gcd ( arr [ i ] , arr [ i - 1 ] ) ) ; } int cnt = 0 ; int maxLength = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % k == 0 ) { cnt ++ ; } else { maxLength = Math . Max ( maxLength , cnt ) ; cnt = 0 ; } } maxLength = Math . Max ( maxLength , cnt ) ; return maxLength ; } static void Main ( ) { int [ ] arr = { 18 , 3 , 6 , 9 } ; int n = arr . Length ; Console . WriteLine ( maximumGcdSubarray ( arr , n ) ) ; } }
Split N powers of 2 into two subsets such that their difference of sum is minimum | C # program to find the minimum difference possible by splitting all powers of 2 up to N into two sets of equal size ; Store the largest ; Form two separate groups ; Initialize the sum for two groups as 0 ; Insert 2 ^ n in the first group ; Calculate the sum of least n / 2 - 1 elements added to the first set ; Sum of remaining n / 2 - 1 elements ; Min difference between the two groups ; Driver Code
using System ; class GFG { public static void MinDiff ( int n ) { int val = ( int ) Math . Pow ( 2 , n ) ; int sep = n / 2 ; int grp1 = 0 ; int grp2 = 0 ; grp1 = grp1 + val ; for ( int i = 1 ; i < sep ; i ++ ) grp1 = grp1 + ( int ) Math . Pow ( 2 , i ) ; for ( int i = sep ; i < n ; i ++ ) grp2 = grp2 + ( int ) Math . Pow ( 2 , i ) ; Console . Write ( Math . Abs ( grp1 - grp2 ) ) ; } public static void Main ( ) { int n = 4 ; MinDiff ( n ) ; } }
Count elements in first Array with absolute difference greater than K with an element in second Array | C # program to count elements in first array with absolute difference greater than K with an element in second Array ; Function to count the such elements ; Store count of required elements in arr1 ; Initialise the smallest and the largest value from the second array arr2 [ ] ; Find the smallest and the largest element in arr2 ; Check if absolute difference of smallest and arr1 [ i ] or largest and arr1 [ i ] is > K then arr [ i ] is a required element ; Print the readonly result ; Driver code
using System ; class GFG { static void countDist ( int [ ] arr1 , int n , int [ ] arr2 , int m , int k ) { int count = 0 ; int smallest = arr2 [ 0 ] ; int largest = arr2 [ 0 ] ; for ( int i = 0 ; i < m ; i ++ ) { smallest = Math . Max ( smallest , arr2 [ i ] ) ; largest = Math . Min ( largest , arr1 [ i ] ) ; } for ( int i = 0 ; i < n ; i ++ ) { if ( Math . Abs ( arr1 [ i ] - smallest ) > k || Math . Abs ( arr1 [ i ] - largest ) > k ) count ++ ; } Console . Write ( count ) ; } public static void Main ( String [ ] args ) { int [ ] arr1 = { 3 , 1 , 4 } ; int n = arr1 . Length ; int [ ] arr2 = { 5 , 1 , 2 } ; int m = arr2 . Length ; int k = 2 ; countDist ( arr1 , n , arr2 , m , k ) ; } }
Make sum of all subarrays of length K equal by only inserting elements | C # implementation of above approach ; Function that prints another array whose all subarray of length k have an equal sum ; Store all distinct elements in the unordered map ; Condition if the number of distinct elements is greater than k ; Push all distinct elements in a vector ; Push 1 while the size of vector not equal to k ; Print the vector 2 times ; Driver Code
using System ; using System . Collections . Generic ; class GFG { static void MakeArray ( int [ ] a , int n , int k ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! mp . ContainsKey ( a [ i ] ) ) mp . Add ( a [ i ] , 1 ) ; } if ( mp . Count > k ) { Console . Write ( " Not ▁ possible STRNEWLINE " ) ; return ; } List < int > ans = new List < int > ( ) ; foreach ( KeyValuePair < int , int > i in mp ) { ans . Add ( i . Key ) ; } while ( ans . Count < k ) { ans . Add ( 1 ) ; } for ( int i = 0 ; i < 2 ; i ++ ) { for ( int j = 0 ; j < k ; j ++ ) Console . Write ( ans [ j ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 2 , 1 } ; int K = 2 ; int size = arr . Length ; MakeArray ( arr , size , K ) ; } }
Find the minimum value of the given expression over all pairs of the array | C # program to find the minimum value of the given expression over all pairs of the array ; Function to find the minimum value of the expression ; Iterate over all the pairs and find the minimum value ; Driver Code
using System ; class GFG { static int MinimumValue ( int [ ] a , int n ) { int answer = Int32 . MaxValue ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { answer = Math . Min ( answer , ( ( a [ i ] & a [ j ] ) ^ ( a [ i ] a [ j ] ) ) ) ; } } return answer ; } public static void Main ( ) { int N = 6 ; int [ ] A = new int [ ] { 12 , 3 , 14 , 5 , 9 , 8 } ; Console . Write ( MinimumValue ( A , N ) ) ; } }
Number of substrings with length divisible by the number of 1 's in it | C # program to count number of subString under given condition ; Function return count of such substring ; Mark 1 at those indices where '1' appears ; Take prefix sum ; Iterate through all the subStrings ; Driver Code
using System ; class GFG { static int countOfSubStrings ( String s ) { int n = s . Length ; int [ ] prefix_sum = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == '1' ) prefix_sum [ i ] = 1 ; } for ( int i = 1 ; i < n ; i ++ ) prefix_sum [ i ] += prefix_sum [ i - 1 ] ; int answer = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { int countOfOnes = prefix_sum [ j ] - ( i - 1 >= 0 ? prefix_sum [ i - 1 ] : 0 ) ; int length = j - i + 1 ; if ( countOfOnes > 0 && length % countOfOnes == 0 ) answer ++ ; } } return answer ; } public static void Main ( String [ ] args ) { String S = "1111100000" ; Console . Write ( countOfSubStrings ( S ) ) ; } }
Find the number of elements X such that X + K also exists in the array | C # implementation of find number of elements x in this array such x + k also present in this array . ; Function to return the count of element x such that x + k also lies in this array ; Key in map will store elements and value will store the frequency of the elements ; Find if i . first + K is present in this map or not ; If we find i . first or key + K in this map then we have to increase in answer the frequency of this element ; Driver code ; array initialisation ; size of array ; initialise k
using System ; using System . Collections . Generic ; public class GFG { static int count_element ( int N , int K , int [ ] arr ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < N ; ++ i ) if ( mp . ContainsKey ( arr [ i ] ) ) { mp [ arr [ i ] ] = mp [ arr [ i ] ] + 1 ; } else { mp . Add ( arr [ i ] , 1 ) ; } int answer = 0 ; foreach ( KeyValuePair < int , int > i in mp ) { if ( mp . ContainsKey ( i . Key + K ) ) answer += i . Value ; } return answer ; } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , 6 , 2 , 8 , 7 , 6 , 5 , 9 } ; int N = arr . Length ; int K = 2 ; Console . Write ( count_element ( N , K , arr ) ) ; } }
Find the size of largest group where groups are according to the xor of digits | C # implementation to Find the size of largest group , where groups are according to the xor of its digits . ; Function to find out xor of digit ; calculate xor digitwise ; return xor ; Function to find the size of largest group ; hash map for counting frequency ; counting freq of each element ; find the maximum ; Driver code ; initialise N
using System ; using System . Collections . Generic ; class GFG { static int digit_xor ( int x ) { int xorr = 0 ; while ( x > 0 ) { xorr ^= x % 10 ; x = x / 10 ; } return xorr ; } static int find_count ( int n ) { Dictionary < int , int > mpp = new Dictionary < int , int > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { if ( mpp . ContainsKey ( digit_xor ( i ) ) ) mpp [ digit_xor ( i ) ] = mpp [ digit_xor ( i ) ] + 1 ; else mpp . Add ( digit_xor ( i ) , 1 ) ; } int maxm = 0 ; foreach ( KeyValuePair < int , int > x in mpp ) { if ( x . Value > maxm ) maxm = x . Value ; } return maxm ; } public static void Main ( String [ ] args ) { int N = 13 ; Console . Write ( find_count ( N ) ) ; } }
Count of largest sized groups while grouping according to product of digits | C # implementation to count the groups having largest size while grouping is according to the product of its digits ; Function to find out product of digit ; Calculate product ; Return the product of digits ; Function to find the count ; Hash map for counting frequency ; Counting freq of each element ; Find the maximum ; Count the number of groups having size of equal to largest group . ; Driver Code ; Initialise N
using System ; using System . Collections ; using System . Collections . Generic ; using System . Text ; class GFG { static int digit_prod ( int x ) { int prod = 1 ; while ( x != 0 ) { prod *= x % 10 ; x = x / 10 ; } return prod ; } static int find_count ( int n ) { Dictionary < int , int > mpp = new Dictionary < int , int > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { int t = digit_prod ( i ) ; if ( mpp . ContainsKey ( t ) ) { mpp [ t ] ++ ; } else { mpp [ i ] = 1 ; } } int ans = 1 ; int maxm = 0 ; foreach ( KeyValuePair < int , int > x in mpp ) { if ( x . Value > maxm ) { maxm = x . Value ; ans = 1 ; } else if ( x . Value == maxm ) { ans ++ ; } } return ans ; } public static void Main ( string [ ] args ) { int N = 13 ; Console . Write ( find_count ( N ) ) ; } }