codeparrot/xlcost-text-to-code huggingface dataset:
Maximum power of jump required to reach the end of string | java program to calculate power of jump ; Function to calculate the maximum power of the jump ; Initialize the count with 1 ; Find the character at last index ; Start traversing the string ; Check if the current char is equal to the last character ; max_so_far stores maximum value of the power of the jump from starting to ith position ; Reset the count to 1 ; Else , increment the number of jumps / count ; Return the maximum number of jumps ; Driver code
import java . util . ArrayList ; public class string_sort { public static int powerOfJump ( String s ) { int count = 1 ; int max_so_far = Integer . MIN_VALUE ; char ch = s . charAt ( s . length ( ) - 1 ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ch ) { if ( count > max_so_far ) { max_so_far = count ; } count = 1 ; } else count ++ ; } return max_so_far ; } public static void main ( String [ ] args ) { String st = "1010101" ; System . out . println ( powerOfJump ( st ) ) ; } }
Longest substring with count of 1 s more than 0 s | Java program to find largest substring having count of 1 s more than count count of 0 s . ; Function to find longest substring having count of 1 s more than count of 0 s . ; To store sum . ; To store first occurrence of each sum value . ; To store maximum length . ; To store current substring length . ; Add 1 if current character is 1 else subtract 1. ; If sum is positive , then maximum length substring is bin [ 0. . i ] ; If sum is negative , then maximum length substring is bin [ j + 1. . i ] , where sum of substring bin [ 0. . j ] is sum - 1. ; Make entry for this sum value in hash table if this value is not present . ; Driver code
import java . util . HashMap ; class GFG { static int findLongestSub ( String bin ) { int n = bin . length ( ) , i ; int sum = 0 ; HashMap < Integer , Integer > prevSum = new HashMap < > ( ) ; int maxlen = 0 ; int currlen ; for ( i = 0 ; i < n ; i ++ ) { if ( bin . charAt ( i ) == '1' ) sum ++ ; else sum -- ; if ( sum > 0 ) { maxlen = i + 1 ; } else if ( sum <= 0 ) { if ( prevSum . containsKey ( sum - 1 ) ) { currlen = i - ( prevSum . get ( sum - 1 ) == null ? 1 : prevSum . get ( sum - 1 ) ) ; maxlen = Math . max ( maxlen , currlen ) ; } } if ( ! prevSum . containsKey ( sum ) ) prevSum . put ( sum , i ) ; } return maxlen ; } public static void main ( String [ ] args ) { String bin = "1010" ; System . out . println ( findLongestSub ( bin ) ) ; } }
Average of ASCII values of characters of a given string | Java code to find average of ASCII characters ; Function to find average of ASCII value of chars ; loop to sum the ascii value of chars ; Returning average of chars ; Driver code
import java . io . * ; class GFG { public static int averageValue ( String s ) { int sum_char = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { sum_char += ( int ) s . charAt ( i ) ; } return sum_char / s . length ( ) ; } public static void main ( String [ ] args ) { String s = " GeeksforGeeks " ; System . out . println ( averageValue ( s ) ) ; } }
Check if two same sub | Java program to Check if similar subsequences exist or not ; Function to check if similar subsequences occur in a string or not ; iterate and count the frequency ; counting frequency of the letters ; check if frequency is more than once of any character ; Driver Code
import java . io . * ; import java . util . * ; import java . util . Arrays ; class GFG { static boolean check ( String s , int l ) { int freq [ ] = new int [ 26 ] ; Arrays . fill ( freq , 0 ) ; for ( int i = 0 ; i < l ; i ++ ) { freq [ s . charAt ( i ) - ' a ' ] ++ ; } for ( int i = 0 ; i < 26 ; i ++ ) { if ( freq [ i ] >= 2 ) return true ; } return false ; } public static void main ( String args [ ] ) { String s = " geeksforgeeks " ; int l = s . length ( ) ; if ( check ( s , l ) ) System . out . print ( " YES " ) ; else System . out . print ( " NO " ) ; } }
Find the winner of a game where scores are given as a binary string | Java program for predicting winner ; function for winner prediction ; increase count ; check losing condition ; check winning condition ; check tie on n - 1 point ; increase count ; check for 2 point lead ; condition of lost ; condition of win ; Driver Code
import java . io . * ; import java . util . * ; import java . lang . * ; class GFG { static void predictWinner ( String score , int n ) { int count [ ] = new int [ 2 ] , i ; for ( i = 0 ; i < score . length ( ) ; i ++ ) { count [ score . charAt ( i ) - '0' ] ++ ; if ( count [ 0 ] == n && count [ 1 ] < n - 1 ) { System . out . print ( " GEEKS ▁ lost " ) ; return ; } if ( count [ 1 ] == n && count [ 0 ] < n - 1 ) { System . out . print ( " GEEKS ▁ won " ) ; return ; } if ( count [ 0 ] == n - 1 && count [ 1 ] == n - 1 ) { count [ 0 ] = 0 ; count [ 1 ] = 0 ; break ; } } for ( i ++ ; i < score . length ( ) ; i ++ ) { count [ score . charAt ( i ) - '0' ] ++ ; if ( Math . abs ( count [ 0 ] - count [ 1 ] ) == 2 ) { if ( count [ 0 ] > count [ 1 ] ) System . out . print ( " GEEKS ▁ lost " ) ; else System . out . print ( " GEEKS ▁ won " ) ; return ; } } } public static void main ( String [ ] args ) { String score = "1001010101111011101111" ; int n = 15 ; predictWinner ( score , n ) ; } }
Number of Counterclockwise shifts to make a string palindrome | Java program to find counter clockwise shifts to make string palindrome . ; Function to check if given string is palindrome or not . ; Function to find counter clockwise shifts to make string palindrome . ; Pointer to starting of current shifted string . ; Pointer to ending of current shifted string . ; Concatenate string with itself ; To store counterclockwise shifts ; Move left and right pointers one step at a time . ; Check if current shifted string is palindrome or not ; If string is not palindrome then increase count of number of shifts by 1. ; Driver code .
class GFG { static boolean isPalindrome ( String str , int l , int r ) { while ( l < r ) { if ( str . charAt ( l ) != str . charAt ( r ) ) return false ; l ++ ; r -- ; } return true ; } static int CyclicShifts ( String str ) { int n = str . length ( ) ; int left = 0 ; int right = n - 1 ; str = str + str ; int cnt = 0 ; while ( right < 2 * n - 1 ) { if ( isPalindrome ( str , left , right ) ) break ; cnt ++ ; left ++ ; right ++ ; } return cnt ; } public static void main ( String [ ] args ) { String str = " bccbbaab " ; System . out . println ( CyclicShifts ( str ) ) ; } }
Find a string such that every character is lexicographically greater than its immediate next character | Java program to print a String in reverse alphabetical order upto given number ; Function that prints the required String ; Find modulus with 26 ; Print extra characters required ; Print the given reverse String countOfStr times ; Driver Code ; Initialize a String in reverse order
class GFG { static String printString ( int n , String str ) { String str2 = " " ; int extraChar = n % 26 ; if ( extraChar >= 1 ) { for ( int i = 26 - ( extraChar + 1 ) ; i <= 25 ; i ++ ) { str2 += str . charAt ( i ) ; } } int countOfStr = n / 26 ; for ( int i = 1 ; i <= countOfStr ; i ++ ) { for ( int j = 0 ; j < 26 ; j ++ ) { str2 += str . charAt ( j ) ; } } return str2 ; } public static void main ( String [ ] args ) { int n = 30 ; String str = " zyxwvutsrqponmlkjihgfedcba " ; System . out . println ( printString ( n , str ) ) ; } }
Longest Common Prefix Matching | Set | A Java program to find the longest common prefix ; A Utility Function to find the common prefix between first and last strings ; Compare str1 and str2 ; A Function that returns the longest common prefix from the array of strings ; sorts the N set of strings ; prints the common prefix of the first and the last String of the set of strings ; Driver Code
import java . util . Arrays ; 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 . charAt ( i ) != str2 . charAt ( j ) ) { break ; } result += str1 . charAt ( i ) ; } return ( result ) ; } static void commonPrefix ( String arr [ ] , int n ) { Arrays . sort ( arr ) ; System . out . println ( commonPrefixUtil ( arr [ 0 ] , arr [ n - 1 ] ) ) ; } public static void main ( String [ ] args ) { String arr [ ] = { " geeksforgeeks " , " geeks " , " geek " , " geezer " } ; int n = arr . length ; commonPrefix ( arr , n ) ; } }
Square of large number represented as String | Java program to multiply two numbers represented as strings . ; Multiplies str1 and str2 , and prints result . ; will keep the result number in vector in reverse order ; Below two indexes are used to find positions in result . ; Go from right to left in num1 ; To shift position to left after every multiplication of a digit in num2 ; Go from right to left in num2 ; Take current digit of second number ; Multiply with current digit of first number and add result to previously stored result at current position . ; Carry for next iteration ; Store result ; store carry in next cell ; To shift position to left after every multiplication of a digit in num1 . ; ignore '0' s from the right ; If all were '0' s - means either both or one of num1 or num2 were '0' ; generate the result string ; Driver code
class GFG { public static String multiply ( String num1 , String num2 ) { int n1 = num1 . length ( ) ; int n2 = num2 . length ( ) ; if ( n1 == 0 n2 == 0 ) return "0" ; int [ ] result = new int [ n1 + n2 ] ; int i_n1 = 0 ; int i_n2 = 0 ; for ( int i = n1 - 1 ; i >= 0 ; i -- ) { int carry = 0 ; int n_1 = num1 . charAt ( i ) - '0' ; i_n2 = 0 ; for ( int j = n2 - 1 ; j >= 0 ; j -- ) { int n_2 = num2 . charAt ( j ) - '0' ; int sum = n_1 * n_2 + result [ i_n1 + i_n2 ] + carry ; carry = sum / 10 ; result [ i_n1 + i_n2 ] = sum % 10 ; i_n2 ++ ; } if ( carry > 0 ) result [ i_n1 + i_n2 ] += carry ; i_n1 ++ ; } int i = result . length - 1 ; while ( i >= 0 && result [ i ] == 0 ) i -- ; if ( i == - 1 ) return "0" ; String s = " " ; while ( i >= 0 ) s += Integer . toString ( result [ i -- ] ) ; return s ; } public static void main ( String [ ] args ) { String str1 = "454545454545454545" ; System . out . println ( multiply ( str1 , str1 ) ) ; } }
Perform n steps to convert every digit of a number in the format [ count ] [ digit ] | Java program to convert number to the format [ count ] [ digit ] at every step ; Function to perform every step ; perform N steps ; Traverse in the string ; for last digit ; recur for current string ; Driver Code
class GFG { public static void countDigits ( String st , int n ) { if ( n > 0 ) { int cnt = 1 , i ; String st2 = " " ; for ( i = 1 ; i < st . length ( ) ; i ++ ) { if ( st . charAt ( i ) == st . charAt ( i - 1 ) ) cnt ++ ; else { st2 += ( ( char ) 0 + ( char ) cnt ) ; st2 += st . charAt ( i - 1 ) ; cnt = 1 ; } } st2 += ( ( char ) 0 + ( char ) cnt ) ; st2 += st . charAt ( i - 1 ) ; countDigits ( st2 , -- n ) ; } else System . out . print ( st ) ; } public static void main ( String [ ] args ) { String num = "123" ; int n = 3 ; countDigits ( num , n ) ; } }
Sudo Placement | Special Subsequences | Java Program to find all special subsequences of the given type ; Function to generate the required subsequences ; If the index pointer has reached the end of input string ; Skip empty ( " ▁ " ) subsequence ; Exclude the character in the output string ; Include the current character as it is ; Include the current character in its upper case form To remove the last character , we generate a substring till the second last character ; Function to print the required subsequences ; Output String to store every subsequence ; Set of strings that will store all special subsequences in lexicographical sorted order ; Sort the strings to print in the sorted order ; Driver code
import java . util . * ; import java . io . * ; public class SpecialSubsequences { public static void generateSubsequences ( String input , String output , int index , ArrayList < String > ans ) { if ( index == input . length ( ) ) { if ( output . length ( ) != 0 ) { ans . add ( output ) ; } return ; } generateSubsequences ( input , output , index + 1 , ans ) ; output += String . valueOf ( input . charAt ( index ) ) ; generateSubsequences ( input , output , index + 1 , ans ) ; output = output . substring ( 0 , output . length ( ) - 1 ) ; output += String . valueOf ( Character . toUpperCase ( input . charAt ( index ) ) ) ; generateSubsequences ( input , output , index + 1 , ans ) ; } public static void printSubsequences ( String s ) { String output = " " ; ArrayList < String > ans = new ArrayList < > ( ) ; generateSubsequences ( s , output , 0 , ans ) ; Collections . sort ( ans ) ; for ( String str : ans ) { System . out . print ( str + " ▁ " ) ; } System . out . println ( ) ; } public static void main ( String [ ] args ) { String s = " ab " ; printSubsequences ( s ) ; } }
Check if the given string of words can be formed from words present in the dictionary | Java program to check if a sentence can be formed from a given set of words . ; Function to check if the word is in the dictionary or not ; map to store all words in dictionary with their count ; adding all words in map ; search in map for all words in the sentence ; all words of sentence are present ; Driver Code ; Calling function to check if words are present in the dictionary or not
import java . util . * ; class GFG { static boolean match_words ( String dictionary [ ] , String sentence [ ] , int n , int m ) { Map < String , Integer > mp = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( mp . containsKey ( dictionary [ i ] ) ) { mp . put ( dictionary [ i ] , mp . get ( dictionary [ i ] ) + 1 ) ; } else { mp . put ( dictionary [ i ] , 1 ) ; } } for ( int i = 0 ; i < m ; i ++ ) { if ( mp . containsKey ( sentence [ i ] ) ) mp . put ( sentence [ i ] , mp . get ( sentence [ i ] ) - 1 ) ; else return false ; } return true ; } public static void main ( String [ ] args ) { String dictionary [ ] = { " find " , " a " , " geeks " , " all " , " for " , " on " , " geeks " , " answers " , " inter " } ; int n = dictionary . length ; String sentence [ ] = { " find " , " all " , " answers " , " on " , " geeks " , " for " , " geeks " } ; int m = sentence . length ; if ( match_words ( dictionary , sentence , n , m ) ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } }
Print all 3 digit repeating numbers in a very large number | Java program to print 3 digit repeating numbers ; function to print 3 digit repeating numbers ; Hashmap to store the frequency of a 3 digit number ; first three digit number ; if key already exists increase value by 1 ; Output the three digit numbers with frequency > 1 ; Driver Code ; Input string ; Calling Function
import java . util . * ; import java . lang . * ; public class GFG { static void printNum ( String s ) { int i = 0 , j = 0 , val = 0 ; LinkedHashMap < Integer , Integer > hm = new LinkedHashMap < > ( ) ; val = ( s . charAt ( 0 ) - '0' ) * 100 + ( s . charAt ( 1 ) - '0' ) * 10 + ( s . charAt ( 2 ) - '0' ) ; hm . put ( val , 1 ) ; for ( i = 3 ; i < s . length ( ) ; i ++ ) { val = ( val % 100 ) * 10 + s . charAt ( i ) - '0' ; if ( hm . containsKey ( val ) ) { hm . put ( val , hm . get ( val ) + 1 ) ; } else { hm . put ( val , 1 ) ; } } for ( Map . Entry < Integer , Integer > en : hm . entrySet ( ) ) { int key = en . getKey ( ) ; int value = en . getValue ( ) ; if ( value > 1 ) System . out . println ( key + " ▁ - ▁ " + value + " ▁ times " ) ; } } public static void main ( String args [ ] ) { String input = "123412345123456" ; printNum ( input ) ; } }
Count occurrences of a substring recursively | Recursive Java program for counting number of substrings ; Recursive function to count the number of occurrences of " hi " in str . ; Base Case ; Recursive Case Checking if the first substring matches ; Otherwise , return the count from the remaining index ; Driver Code
class GFG { static int countSubstrig ( String str1 , String str2 ) { int n1 = str1 . length ( ) ; int n2 = str2 . length ( ) ; if ( n1 == 0 n1 < n2 ) return 0 ; if ( str1 . substring ( 0 , n2 ) . equals ( str2 ) ) return countSubstrig ( str1 . substring ( n2 - 1 ) , str2 ) + 1 ; return countSubstrig ( str1 . substring ( n2 - 1 ) , str2 ) ; } public static void main ( String args [ ] ) { String str1 = " geeksforgeeks " , str2 = " geeks " ; System . out . println ( countSubstrig ( str1 , str2 ) ) ; str1 = " hikakashi " ; str2 = " hi " ; System . out . println ( countSubstrig ( str1 , str2 ) ) ; } }
Check if a binary string contains all permutations of length k | Java Program to Check If a String Contains All Binary Codes of Size K ; Unordered map of type string ; Driver code
import java . io . * ; import java . util . * ; class GFG { static boolean hasAllcodes ( String s , int k ) { Set < String > us = new HashSet < String > ( ) ; for ( int i = 0 ; i + k <= s . length ( ) ; i ++ ) { us . add ( s . substring ( i , i + k ) ) ; } return ( us . size ( ) == ( 1 << k ) ) ; } public static void main ( String [ ] args ) { String s = "00110110" ; int k = 2 ; if ( hasAllcodes ( s , k ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } }
Add n binary strings | Java program to add n binary strings ; This function adds two binary strings and return result as a third string ; Initialize result ; Initialize digit sum ; Traverse both strings starting from last characters ; Compute sum of last digits and carry ; If current digit sum is 1 or 3 , add 1 to result ; Compute carry ; Move to next digits ; function to add n binary strings ; Driver code
class GFG { static String addBinaryUtil ( String a , String b ) { String result = " " ; int s = 0 ; int i = a . length ( ) - 1 , j = b . length ( ) - 1 ; while ( i >= 0 j >= 0 s == 1 ) { s += ( ( i >= 0 ) ? a . charAt ( i ) - '0' : 0 ) ; s += ( ( j >= 0 ) ? b . charAt ( j ) - '0' : 0 ) ; result = s % 2 + result ; s /= 2 ; i -- ; j -- ; } return result ; } static String addBinary ( String arr [ ] , int n ) { String result = " " ; for ( int i = 0 ; i < n ; i ++ ) { result = addBinaryUtil ( result , arr [ i ] ) ; } return result ; } public static void main ( String [ ] args ) { String arr [ ] = { "1" , "10" , "11" } ; int n = arr . length ; System . out . println ( addBinary ( arr , n ) ) ; } }
Reverse String according to the number of words | Java program to reverse string according to the number of words ; Reverse the letters of the word ; Temporary variable to store character ; Swapping the first and last character ; This function forms the required string ; Checking the number of words present in string to reverse ; Reverse the letter of the words ; Driver Code
class GFG { static void reverse ( char str [ ] , int start , int end ) { char temp ; while ( start <= end ) { temp = str [ start ] ; str [ start ] = str [ end ] ; str [ end ] = temp ; start ++ ; end -- ; } } static void reverseletter ( char str [ ] , int start , int end ) { int wstart , wend ; for ( wstart = wend = start ; wend < end ; wend ++ ) { if ( str [ wend ] == ' ▁ ' ) { continue ; } while ( wend <= end && str [ wend ] != ' ▁ ' ) { wend ++ ; } wend -- ; reverse ( str , wstart , wend ) ; } } public static void main ( String [ ] args ) { char str [ ] = " Ashish ▁ Yadav ▁ Abhishek ▁ Rajput ▁ Sunil ▁ Pundir " . toCharArray ( ) ; reverseletter ( str , 0 , str . length - 1 ) ; System . out . printf ( " % s " , String . valueOf ( str ) ) ; } }
Minimum bit changes in Binary Circular array to reach a index | Java program to find direction with minimum flips ; finding which path have minimum flip bit and the minimum flip bits ; concatenating given string to itself , to make it circular ; check x is greater than y . marking if output need to be opposite . ; iterate Clockwise ; if current bit is not equal to next index bit . ; iterate Anti - Clockwise ; if current bit is not equal to next index bit . ; Finding whether Clockwise or Anti - clockwise path take minimum flip . ; Driver code
class GFG { static void minimumFlip ( String s , int x , int y ) { s = s + s ; boolean isOpposite = false ; if ( x > y ) { swap ( x , y ) ; isOpposite = true ; } int valClockwise = 0 ; char cur = s . charAt ( x ) ; for ( int i = x ; i <= y ; i ++ ) { if ( s . charAt ( i ) != cur ) { cur = s . charAt ( i ) ; valClockwise ++ ; } } int valAnticlockwise = 0 ; cur = s . charAt ( y ) ; x += s . length ( ) ; for ( int i = y ; i < x ; i ++ ) { if ( s . charAt ( i ) != cur ) { cur = s . charAt ( i ) ; valAnticlockwise ++ ; } } if ( valClockwise <= valAnticlockwise ) { if ( ! isOpposite ) { System . out . println ( " Clockwise ▁ " + valClockwise ) ; } else { System . out . println ( " Anti - clockwise ▁ " + valAnticlockwise ) ; } } else if ( ! isOpposite ) { System . out . println ( " Anti - clockwise ▁ " + valAnticlockwise ) ; } else { System . out . println ( " Clockwise ▁ " + valClockwise ) ; } } static void swap ( int a , int b ) { int c = a ; a = b ; b = c ; } public static void main ( String [ ] args ) { int x = 0 , y = 8 ; String s = "000110" ; minimumFlip ( s , x , y ) ; } }
Prefixes with more a than b | Java code to count the prefixes with more a than b ; Function to count prefixes ; calculating for string S ; count == 0 or when N == 1 ; when all characters are a or a - b == 0 ; checking for saturation of string after repetitive addition ; Driver Code
import java . io . * ; class GFG { static int prefix ( String k , int n ) { int a = 0 , b = 0 , count = 0 ; int i = 0 ; int len = k . length ( ) ; for ( i = 0 ; i < len ; i ++ ) { if ( k . charAt ( i ) == ' a ' ) a ++ ; if ( k . charAt ( i ) == ' b ' ) b ++ ; if ( a > b ) { count ++ ; } } if ( count == 0 n == 1 ) { System . out . println ( count ) ; return 0 ; } if ( count == len a - b == 0 ) { System . out . println ( count * n ) ; return 0 ; } int n2 = n - 1 , count2 = 0 ; while ( n2 != 0 ) { for ( i = 0 ; i < len ; i ++ ) { if ( k . charAt ( i ) == ' a ' ) a ++ ; if ( k . charAt ( i ) == ' b ' ) b ++ ; if ( a > b ) { count2 ++ ; } } count += count2 ; n2 -- ; if ( count2 == 0 ) break ; if ( count2 == len ) { count += ( n2 * count2 ) ; break ; } count2 = 0 ; } return count ; } public static void main ( String [ ] args ) { String S = " aba " ; int N = 2 ; System . out . println ( prefix ( S , N ) ) ; S = " baa " ; N = 3 ; System . out . println ( prefix ( S , N ) ) ; } }
Pairs whose concatenation contain all digits | Java Program to find number of pairs whose concatenation contains all digits from 0 to 9. ; Function to return number of pairs whose concatenation contain all digits from 0 to 9 ; making the mask for each of the number . ; for each of the possible pair which can make OR value equal to 1023 ; finding the count of pair from the given numbers . ; Driver Code
class GFG { static final int N = 20 ; static int countPair ( char str [ ] [ ] , int n ) { int [ ] cnt = new int [ 1 << 10 ] ; for ( int i = 0 ; i < n ; i ++ ) { int mask = 0 ; for ( int j = 0 ; j < str [ i ] . length ; ++ j ) mask |= ( 1 << ( str [ i ] [ j ] - '0' ) ) ; cnt [ mask ] ++ ; } int ans = 0 ; for ( int m1 = 0 ; m1 <= 1023 ; m1 ++ ) for ( int m2 = 0 ; m2 <= 1023 ; m2 ++ ) if ( ( m1 m2 ) == 1023 ) { ans += ( ( m1 == m2 ) ? ( cnt [ m1 ] * ( cnt [ m1 ] - 1 ) ) : ( cnt [ m1 ] * cnt [ m2 ] ) ) ; } return ans / 2 ; } public static void main ( String [ ] args ) { int n = 5 ; char str [ ] [ ] = { "129300455" . toCharArray ( ) , "5559948277" . toCharArray ( ) , "012334556" . toCharArray ( ) , "56789" . toCharArray ( ) , "123456879" . toCharArray ( ) } ; System . out . print ( countPair ( str , n ) + "NEW_LINE"); } }