codeparrot/xlcost-text-to-code huggingface dataset:
Make a given Binary String non | Java program for the above approach ; Function to return the length of smallest subsequence required to be removed to make the given string non - decreasing ; Length of the string ; Count of zeros and ones ; Traverse the string ; Count minimum removals to obtain strings of the form "00000 . . . . " or "11111 . . . " ; Increment count ; Remove 1 s and remaining 0 s ; Driver Code
import java . io . * ; class GFG { public static void min_length ( String str ) { int n = str . length ( ) ; int total_zeros = 0 ; int total_ones = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str . charAt ( i ) == '0' ) { total_zeros ++ ; } else { total_ones ++ ; } } int ans = Math . min ( total_zeros , total_ones ) ; int cur_zeros = 0 , cur_ones = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { char x = str . charAt ( i ) ; if ( x == '0' ) { cur_zeros ++ ; } else { cur_ones ++ ; } ans = Math . min ( ans , cur_ones + ( total_zeros - cur_zeros ) ) ; } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { String str = "10011" ; min_length ( str ) ; } }
Check if substrings from three given strings can be concatenated to form a palindrome | Java program for the above approach ; Function to check if subStrings from three given Strings can be concatenated to form a palindrome ; Mask for S1 and S2 ; Set ( i - ' a ' ) th bit in maskA ; Set ( i - ' a ' ) th bit in maskC ; If the bitwise AND is > 0 ; Driver Code
import java . util . * ; class GFG { static String make_palindrome ( String S1 , String S2 , String S3 ) { int maskA = 0 , maskC = 0 ; for ( char i : S1 . toCharArray ( ) ) maskA |= ( 1 << ( i - ' a ' ) ) ; for ( char i : S3 . toCharArray ( ) ) maskC |= ( 1 << ( i - ' a ' ) ) ; if ( ( maskA & maskC ) > 0 ) return " YES " ; return " NO " ; } public static void main ( String [ ] args ) { String S1 = " adcb " , S2 = " bcdb " , S3 = " abe " ; System . out . print ( make_palindrome ( S1 , S2 , S3 ) ) ; } }
Length of longest prefix anagram which are common in given two strings | Java program for the above approach ; Function to check if two arrays are identical or not ; Iterate over the range [ 0 , SIZE ] ; If frequency any character is not same in both the strings ; Otherwise ; Function to find the maximum length of the required string ; Store the count of characters in string str1 ; Store the count of characters in string str2 ; Stores the maximum length ; Minimum length of str1 and str2 ; Increment the count of characters of str1 [ i ] in freq1 [ ] by one ; Increment the count of characters of str2 [ i ] in freq2 [ ] by one ; Checks if prefixes are anagram or not ; Finally print the ans ; Driver code ; Function Call
public class Main { static int SIZE = 26 ; static boolean longHelper ( int [ ] freq1 , int [ ] freq2 ) { for ( int i = 0 ; i < SIZE ; ++ i ) { if ( freq1 [ i ] != freq2 [ i ] ) { return false ; } } return true ; } static void longCommomPrefixAnagram ( String s1 , String s2 , int n1 , int n2 ) { int [ ] freq1 = new int [ 26 ] ; int [ ] freq2 = new int [ 26 ] ; int ans = 0 ; int mini_len = Math . min ( n1 , n2 ) ; for ( int i = 0 ; i < mini_len ; ++ i ) { freq1 [ s1 . charAt ( i ) - ' a ' ] ++ ; freq2 [ s2 . charAt ( i ) - ' a ' ] ++ ; if ( longHelper ( freq1 , freq2 ) ) { ans = i + 1 ; } } System . out . print ( ans ) ; } public static void main ( String [ ] args ) { String str1 = " abaabcdezzwer " ; String str2 = " caaabbttyh " ; int N = str1 . length ( ) ; int M = str2 . length ( ) ; longCommomPrefixAnagram ( str1 , str2 , N , M ) ; } }
Lexicographic rank of a Binary String | Java program for the above approach ; Function to find the rank of a string ; Store the length of the string ; Stores its equivalent decimal value ; Traverse the string ; Store the number of strings of length less than N occurring before the given string ; Store the decimal equivalent number of string bin ; Store the rank in answer ; Print the answer ; Driver Code
import java . io . * ; import java . lang . * ; import java . util . * ; public class Main { static void findRank ( String s ) { int N = s . length ( ) ; StringBuilder sb = new StringBuilder ( " " ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( s . charAt ( i ) == '0' ) sb . append ( '0' ) ; else sb . append ( '1' ) ; } String bin = sb . toString ( ) ; long X = ( long ) Math . pow ( 2 , N ) ; long Y = Long . parseLong ( bin , 2 ) ; long ans = X + Y - 1 ; System . out . println ( ans ) ; } public static void main ( String [ ] args ) { String S = "001" ; findRank ( S ) ; } }
Find the GCD of an array made up of numeric strings | JAVA program for the above approach ; Recursive function to return gcd of A and B ; Base case ; Length of A is greater ; Calculate GCD ; Store the GCD of the length of the Strings ; Driver Code ; Function call
import java . util . * ; class GFG { static int GCD ( int lena , int lenb ) { if ( lena == 0 ) return lenb ; if ( lenb == 0 ) return lena ; if ( lena == lenb ) return lena ; if ( lena > lenb ) return GCD ( lena - lenb , lenb ) ; return GCD ( lena , lenb - lena ) ; } static String StringGCD ( String a , String b ) { int gcd = GCD ( a . length ( ) , b . length ( ) ) ; if ( a . substring ( 0 , gcd ) . equals ( b . substring ( 0 , gcd ) ) ) { int x = ( ( int ) b . length ( ) / gcd ) ; int y = ( ( int ) a . length ( ) / gcd ) ; String r = " " , s = " " ; while ( x -- > 0 ) s += a ; while ( y -- > 0 ) r += b ; if ( s . equals ( r ) ) return a . substring ( 0 , gcd ) ; } return " - 1" ; } public static void main ( String [ ] args ) { String a = " geeksgeeks " ; String b = " geeks " ; System . out . print ( StringGCD ( a , b ) ) ; } }
Calculate score of a string consisting of balanced parentheses | Java program to implement the above approach ; Function to calculate score of parentheses ; Stores index of character of String ; Stores total scores obtained from the String ; Iterate over characters of the String ; If s [ i ] is ' ( ' ; If top element of stack is ' ( ' ; Stores score of inner parentheses ; Calculate score of inner parentheses ; Update count ; Pop from stack ; Insert score of inner parentheses ; Update i ; Calculate score of the String ; Update ans ; Driver Code
import java . util . * ; class GFG { static long scoreOfParentheses ( String S ) { Stack < String > s = new Stack < > ( ) ; int i = 0 ; long ans = 0 ; while ( i < S . length ( ) ) { if ( S . charAt ( i ) == ' ( ' ) s . add ( " ( " ) ; else { if ( s . peek ( ) == " ( " ) { s . pop ( ) ; s . add ( "1" ) ; } else { long count = 0 ; while ( s . peek ( ) != " ( " ) { count += Integer . parseInt ( s . peek ( ) ) ; s . pop ( ) ; } s . pop ( ) ; s . add ( String . valueOf ( 2 * count ) ) ; } } i ++ ; } while ( ! s . isEmpty ( ) ) { ans += Integer . parseInt ( s . peek ( ) ) ; s . pop ( ) ; } return ans ; } public static void main ( String [ ] args ) { String S1 = " ( ( ) ( ( ) ) ) " ; System . out . print ( scoreOfParentheses ( S1 ) + "NEW_LINE"); } }
Minimize cost to rearrange substrings to convert a string to a Balanced Bracket Sequence | Java program for the above approach ; Function to count minimum number of operations to convert the string to a balanced bracket sequence ; Initialize the integer array ; Traverse the string ; Decrement a [ i ] ; Increment a [ i ] ; Update the sum as current value of arr [ i ] ; If answer exists ; Traverse from i ; Find all substrings with 0 sum ; Print the sum of sizes ; No answer exists ; Driver Code
class GFG { static void countMinMoves ( String str ) { int n = str . length ( ) ; int a [ ] = new int [ n ] ; int j , ans = 0 , i , sum = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( str . charAt ( i ) == ' ) ' ) { a [ i ] += sum - 1 ; } else { a [ i ] += sum + 1 ; } sum = a [ i ] ; } if ( sum == 0 ) { i = 1 ; while ( i < n ) { j = i - 1 ; while ( i < n && a [ i ] != 0 ) i ++ ; if ( i < n && a [ i - 1 ] < 0 ) { ans += i - j ; if ( j == 0 ) ans ++ ; } i ++ ; } System . out . println ( ans ) ; } else System . out . println ( " - 1" ) ; } public static void main ( String [ ] args ) { String str = " ) ( ( ) " ; countMinMoves ( str ) ; } }
Check if a given string can be converted to a Balanced Bracket Sequence | Java program for the above approach ; Function to check if the String can be balanced by replacing the ' $ ' with opening or closing brackets ; If String can never be balanced ; Declare 2 stacks to check if all ) can be balanced with ( or $ and vice - versa ; Store the count the occurence of ( , ) and $ ; Traverse the String ; Increment closed bracket count by 1 ; If there are no opening bracket to match it then return false ; Otherwise , pop the character from the stack ; If current character is an opening bracket or $ , push it to the stack ; Increment symbol count by 1 ; Increment open bracket count by 1 ; Traverse the String from end and repeat the same process ; If there are no closing brackets to match it ; Otherwise , pop character from stack ; Store the extra ( or ) which are not balanced yet ; Check if $ is available to balance the extra brackets ; Count ramaining $ after balancing extra ( and ) ; Check if each pair of $ is convertable in ( ) ; Driver Code ; Function Call
import java . util . * ; class GFG { static boolean canBeBalanced ( String sequence ) { if ( sequence . length ( ) % 2 == 1 ) return false ; Stack < Character > stack_ = new Stack < Character > ( ) ; Stack < Character > stack2_ = new Stack < Character > ( ) ; int countOpen = 0 , countClosed = 0 ; int countSymbol = 0 ; for ( int i = 0 ; i < sequence . length ( ) ; i ++ ) { if ( sequence . charAt ( i ) == ' ) ' ) { countClosed ++ ; if ( stack_ . isEmpty ( ) ) { return false ; } else { stack_ . pop ( ) ; } } else { if ( sequence . charAt ( i ) == ' $ ' ) { countSymbol ++ ; } else { countOpen ++ ; } stack_ . add ( sequence . charAt ( i ) ) ; } } for ( int i = sequence . length ( ) - 1 ; i >= 0 ; i -- ) { if ( sequence . charAt ( i ) == ' ( ' ) { if ( stack2_ . isEmpty ( ) ) { return false ; } else { stack2_ . pop ( ) ; } } else { stack2_ . add ( sequence . charAt ( i ) ) ; } } int extra = Math . abs ( countClosed - countOpen ) ; if ( countSymbol < extra ) { return false ; } else { countSymbol -= extra ; if ( countSymbol % 2 == 0 ) { return true ; } } return false ; } public static void main ( String [ ] args ) { String S = " ( ) ( $ " ; if ( canBeBalanced ( S ) ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } }
Queries to calculate difference between the frequencies of the most and least occurring characters in specified substring | Java program for the above approach ; Function to find difference between maximum and minimum frequency of a character in given range ; Stores length of String ; Stores count of queries ; Iterate over the characters of the String ; Stores l - value of a query ; Stores r - value of a query ; Store count of every character laying in range [ l , r ] ; Update frequency of current character ; Stores maximum frequency of characters in given range ; Stores minimum frequency of characters in given range ; Iterate over all possible characters of the given String ; Update mx ; If ( j + ' a ' ) is present ; difference between max and min ; Driver Code ; Given String ; Given queries ; Function Call
import java . util . * ; class GFG { static void maxDiffFreq ( int [ ] [ ] queries , String S ) { int N = S . length ( ) ; int Q = queries . length ; for ( int i = 0 ; i < Q ; ++ i ) { int l = queries [ i ] [ 0 ] - 1 ; int r = queries [ i ] [ 1 ] - 1 ; int freq [ ] = new int [ 26 ] ; for ( int j = l ; j <= r ; j ++ ) { freq [ S . charAt ( j ) - ' a ' ] ++ ; } int mx = 0 ; int mn = 99999999 ; for ( int j = 0 ; j < 26 ; j ++ ) { mx = Math . max ( mx , freq [ j ] ) ; if ( freq [ j ] > 0 ) mn = Math . min ( mn , freq [ j ] ) ; } System . out . print ( mx - mn + "NEW_LINE"); } } public static void main ( String [ ] args ) { String S = " abaabac " ; int [ ] [ ] queries = { { 2 , 6 } , { 1 , 7 } } ; maxDiffFreq ( queries , S ) ; } }
Spell Checker using Trie | Java program to implement the above approach ; Structure of a Trie node ; Store address of a character ; Check if the character is last character of a string or not ; Constructor function ; Function to insert a string into Trie ; Traverse the string , s ; Initialize a node ; Update temp ; Mark the last character of the string to true ; Function to print suggestions of the string ; If current character is the last character of a string ; Iterate over all possible characters of the string ; If current character present in the Trie ; Insert current character into Trie ; Function to check if the string is present in Trie or not ; Traverse the string ; If current character not present in the Trie ; Update root ; Driver Code ; Given array of strings ; Initialize a Trie ; Insert strings to trie
import java . io . * ; class TrieNode { TrieNode Trie [ ] ; boolean isEnd ; public TrieNode ( ) { Trie = new TrieNode [ 256 ] ; for ( int i = 0 ; i < 256 ; i ++ ) { Trie [ i ] = null ; } isEnd = false ; } } class GFG { static void InsertTrie ( TrieNode root , String s ) { TrieNode temp = root ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( temp . Trie [ s . charAt ( i ) ] == null ) { temp . Trie [ s . charAt ( i ) ] = new TrieNode ( ) ; } temp = temp . Trie [ s . charAt ( i ) ] ; } temp . isEnd = true ; } static void printSuggestions ( TrieNode root , String res ) { if ( root . isEnd == true ) { System . out . print ( res + " ▁ " ) ; } for ( int i = 0 ; i < 256 ; i ++ ) { if ( root . Trie [ i ] != null ) { res += ( char ) i ; printSuggestions ( root . Trie [ i ] , res ) ; res = res . substring ( 0 , res . length ( ) - 2 ) ; } } } static boolean checkPresent ( TrieNode root , String key ) { for ( int i = 0 ; i < key . length ( ) ; i ++ ) { if ( root . Trie [ key . charAt ( i ) ] == null ) { printSuggestions ( root , key . substring ( 0 , i ) ) ; return false ; } root = root . Trie [ key . charAt ( i ) ] ; } if ( root . isEnd == true ) { return true ; } printSuggestions ( root , key ) ; return false ; } public static void main ( String [ ] args ) { String str [ ] = { " gee " , " geeks " , " ape " , " apple " , " geeksforgeeks " } ; String key = " geek " ; TrieNode root = new TrieNode ( ) ; for ( int i = 0 ; i < str . length ; i ++ ) { InsertTrie ( root , str [ i ] ) ; } if ( checkPresent ( root , key ) ) { System . out . println ( " YES " ) ; } } }
Count strings from given array having all characters appearing in a given string | Java program to implement the above approach ; Function to count the number of Strings from an array having all characters appearing in the String S ; Initialize a set to store all distinct characters of String S ; Traverse over String S ; Insert characters into the Set ; Stores the required count ; Traverse the array ; Traverse over String arr [ i ] ; Check if character in arr [ i ] [ j ] is present in the String S or not ; Increment the count if all the characters of arr [ i ] are present in the String S ; Finally , print the count ; Driver code
import java . util . * ; class GFG { static int countStrings ( String S , String [ ] list ) { HashSet < Character > valid = new HashSet < Character > ( ) ; for ( char x : S . toCharArray ( ) ) { valid . add ( x ) ; } int cnt = 0 ; for ( int i = 0 ; i < list . length ; i ++ ) { int j = 0 ; for ( j = 0 ; j < list [ i ] . length ( ) ; j ++ ) { if ( valid . contains ( list [ i ] . charAt ( j ) ) ) continue ; else break ; } if ( j == list [ i ] . length ( ) ) cnt ++ ; } return cnt ; } public static void main ( String [ ] args ) { String [ ] arr = { " ab " , " aab " , " abaaaa " , " bbd " } ; String S = " ab " ; System . out . print ( countStrings ( S , arr ) + "NEW_LINE"); } }
Minimize a string by removing all occurrences of another string | Java program for the above approach ; Function to find the minimum length to which String str can be reduced to by removing all occurrences of String K ; Initialize stack of characters ; Push character into the stack ; If stack size >= K . size ( ) ; Create empty String to store characters of stack ; Traverse the String K in reverse ; If any of the characters differ , it means that K is not present in the stack ; Push the elements back into the stack ; Store the String ; Remove top element ; Size of stack gives the minimized length of str ; Driver Code ; Function Call
import java . util . * ; class GFG { static int minLength ( String str , int N , String K , int M ) { Stack < Character > stackOfChar = new Stack < Character > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { stackOfChar . add ( str . charAt ( i ) ) ; if ( stackOfChar . size ( ) >= M ) { String l = " " ; for ( int j = M - 1 ; j >= 0 ; j -- ) { if ( K . charAt ( j ) != stackOfChar . peek ( ) ) { int f = 0 ; while ( f != l . length ( ) ) { stackOfChar . add ( l . charAt ( f ) ) ; f ++ ; } break ; } else { l = stackOfChar . peek ( ) + l ; stackOfChar . pop ( ) ; } } } } return stackOfChar . size ( ) ; } public static void main ( String [ ] args ) { String S1 = " fffoxoxoxfxo " ; String S2 = " fox " ; int N = S1 . length ( ) ; int M = S2 . length ( ) ; System . out . print ( minLength ( S1 , N , S2 , M ) ) ; } }
Largest palindrome not exceeding N which can be expressed as product of two 3 | Java program for the above approach ; Function to find the largest palindrome not exceeding N which can be expressed as the product of two 3 - digit numbers ; Stores all palindromes ; Stores the product ; Check if X is palindrome ; Check n is less than N ; If true , append it in the list ; Print the largest palindrome ; Driver Code ; Function Call
import java . util . * ; class GFG { static void palindrome_prod ( String N ) { Vector < Integer > palindrome_list = new Vector < Integer > ( ) ; for ( int i = 101 ; i < 1000 ; i ++ ) { for ( int j = 121 ; j < 1000 ; j += ( i % 11 == 0 ) ? 1 : 11 ) { int n = i * j ; String x = String . valueOf ( n ) ; String y = x ; reverse ( y ) ; if ( x == y ) { if ( n < Integer . valueOf ( N ) ) { palindrome_list . add ( i * j ) ; } } } } System . out . print ( Collections . max ( palindrome_list ) ) ; } static String reverse ( String input ) { char [ ] a = input . toCharArray ( ) ; int l , r = a . length - 1 ; for ( l = 0 ; l < r ; l ++ , r -- ) { char temp = a [ l ] ; a [ l ] = a [ r ] ; a [ r ] = temp ; } return String . valueOf ( a ) ; } public static void main ( String [ ] args ) { String N = "101110" ; palindrome_prod ( N ) ; } }
Check if given strings can be made same by swapping two characters of same or different strings | Java program to implement the above approach ; Function to check if all strings can be made equal by swapping any pair of characters from the same or different strings ; Stores length of string ; Store frequency of each distinct character of the strings ; Traverse the array ; Iterate over the characters ; Update frequency of arr [ i ] . charAt ( j ) ; Traverse the array cntFreq [ ] ; If cntFreq [ i ] is divisible by N or not ; Driver Code ; Function Call
class GFG { static boolean isEqualStrings ( String [ ] arr , int N ) { int M = arr [ 0 ] . length ( ) ; int [ ] cntFreq = new int [ 256 ] ; for ( int i = 0 ; i < N ; i ++ ) { cntFreq [ i ] = 0 ; } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { cntFreq [ arr [ i ] . charAt ( j ) - ' a ' ] += 1 ; } } for ( int i = 0 ; i < 256 ; i ++ ) { if ( cntFreq [ i ] % N != 0 ) { return false ; } } return true ; } public static void main ( String [ ] args ) { String [ ] arr = { " aab " , " bbc " , " cca " } ; int N = arr . length ; if ( isEqualStrings ( arr , N ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } }
Minimize a binary string by repeatedly removing even length substrings of same characters | Java program for the above approach ; Recursive function to print stack elements from bottom to top without changing their order ; If stack is empty ; Pop top element of the stack ; Recursively call the function PrintStack ; Print the stack element from the bottom ; Push the same element onto the stack to preserve the order ; Function to minimize binary String by removing subStrings consisting of same character ; Declare a stack of characters ; Push the first character of the String into the stack ; Traverse the String s ; If Stack is empty ; Push current character into the stack ; Check if the current character is same as the top of the stack ; If true , pop the top of the stack ; Otherwise , push the current element ; Print stack from bottom to top ; Driver Code
import java . util . * ; class GFG { static void PrintStack ( Stack < Character > s ) { if ( s . isEmpty ( ) ) return ; char x = s . peek ( ) ; s . pop ( ) ; PrintStack ( s ) ; System . out . print ( x ) ; s . add ( x ) ; } static void minString ( String s ) { Stack < Character > Stack = new Stack < Character > ( ) ; Stack . add ( s . charAt ( 0 ) ) ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( Stack . isEmpty ( ) ) { Stack . add ( s . charAt ( i ) ) ; } else { if ( Stack . peek ( ) == s . charAt ( i ) ) { Stack . pop ( ) ; } else { Stack . push ( s . charAt ( i ) ) ; } } } PrintStack ( Stack ) ; } public static void main ( String [ ] args ) { String str = "101001" ; minString ( str ) ; } }
Probability of collision between two trucks | Java program for the above approach ; Function to calculate total number of accidents ; String size ; Function to calculate count of all possible collision ; Stores the count of collisions ; Total number of truck in lane b ; Count total number of collisions while traversing the String a ; Function to calculate the probability of collisions ; Evaluate total outcome that is all the possible accident ; Evaluate favourable outcome i . e . , count of collision of trucks ; Print desired probability ; Driver Code ; Function Call
import java . util . * ; class GFG { static int count_of_accident ( String a , String b ) { int n = a . length ( ) , m = b . length ( ) ; if ( n > m ) return ( m * ( m + 1 ) ) / 2 ; else return ( n * ( n + 1 ) ) / 2 + ( m - n ) * n ; } static double count_of_collision ( String a , String b ) { int n = a . length ( ) , m = b . length ( ) ; double answer = 0 ; int count_of_truck_in_lane_b = 0 ; for ( int i = 0 ; i < m ; i ++ ) if ( b . charAt ( i ) == ' T ' ) count_of_truck_in_lane_b ++ ; for ( int i = 0 ; i < n && i < m ; i ++ ) { if ( a . charAt ( i ) == ' T ' ) answer += count_of_truck_in_lane_b ; if ( b . charAt ( i ) == ' T ' ) count_of_truck_in_lane_b -- ; } return answer ; } static void findProbability ( String a , String b ) { int total_outcome = count_of_accident ( a , b ) ; double favourable_outcome = count_of_collision ( a , b ) ; System . out . printf ( " % 4f " , favourable_outcome / total_outcome ) ; } public static void main ( String [ ] args ) { String S = " TCCBCTTB " , T = " BTCCBBTT " ; findProbability ( S , T ) ; } }
Count alphanumeric palindromes of length N | Java program for the above approach ; Function to calculate ( x ^ y ) mod p ; Initialize result ; Update x if it is more than or equal to p ; If y is odd , multiply x with result ; y must be even now ; Return the final result ; Driver Code ; Given N ; Base Case ; Check whether n is even or odd ; Function Call ; Function Call
import java . util . * ; class GFG { static int power ( int x , int y , int p ) { int res = 1 ; x = x % p ; if ( x == 0 ) return 0 ; while ( y > 0 ) { if ( ( y & 1 ) == 1 ) res = ( res * x ) % p ; y = y >> 1 ; x = ( x * x ) % p ; } return res ; } public static void main ( String [ ] args ) { int N = 3 ; int flag , k , m = 0 ; if ( ( N == 1 ) || ( N == 2 ) ) System . out . print ( 62 ) ; else m = 1000000000 + 7 ; if ( N % 2 == 0 ) { k = N / 2 ; flag = 1 ; } else { k = ( N - 1 ) / 2 ; flag = 0 ; } if ( flag != 0 ) { int a = power ( 62 , k , m ) ; System . out . print ( a ) ; } else { int a = power ( 62 , ( k + 1 ) , m ) ; System . out . print ( a ) ; } } }