code
stringlengths 31
2.27k
| tokenized_code
stringlengths 30
1.69k
| sexp
stringlengths 115
9.43k
|
---|---|---|
public static void main ( String [ ] args ) {
int w [ ] = new int [ ] {
3 , 8 , 9 };
int n = w . length ;
preCompute ( w , n ) ;
int queries [ ] = new int [ ] {
11 , 10 , 4 };
int q = queries . length ;
for ( int i = 0 ;
i < q ;
i ++ ) System . out . println ( ansQuery ( queries [ i ] ) ) ;
}
| public static void main ( String [ ] args ) { int w [ ] = new int [ ] { 3 , 8 , 9 } ; int n = w . length ; preCompute ( w , n ) ; int queries [ ] = new int [ ] { 11 , 10 , 4 } ; int q = queries . length ; for ( int i = 0 ; i < q ; i ++ ) System . out . println ( ansQuery ( queries [ i ] ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions) value: (array_initializer (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions) value: (array_initializer (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)))))))))) |
public static long findWays ( int m , int n , int x ) {
long [ ] [ ] table = new long [ n + 1 ] [ x + 1 ] ;
for ( int j = 1 ;
j <= m && j <= x ;
j ++ ) table [ 1 ] [ j ] = 1 ;
for ( int i = 2 ;
i <= n ;
i ++ ) {
for ( int j = 1 ;
j <= x ;
j ++ ) {
for ( int k = 1 ;
k < j && k <= m ;
k ++ ) table [ i ] [ j ] += table [ i - 1 ] [ j - k ] ;
}
}
return table [ n ] [ x ] ;
}
| public static long findWays ( int m , int n , int x ) { long [ ] [ ] table = new long [ n + 1 ] [ x + 1 ] ; for ( int j = 1 ; j <= m && j <= x ; j ++ ) table [ 1 ] [ j ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= x ; j ++ ) { for ( int k = 1 ; k < j && k <= m ; k ++ ) table [ i ] [ j ] += table [ i - 1 ] [ j - k ] ; } } return table [ n ] [ x ] ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (identifier) right: (decimal_integer_literal))) dimensions: (dimensions_expr (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (identifier) right: (identifier))) update: (update_expression (identifier)) body: (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (decimal_integer_literal)) index: (identifier)) right: (decimal_integer_literal)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (identifier) right: (identifier))) update: (update_expression (identifier)) body: (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (array_access array: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) index: (binary_expression left: (identifier) right: (identifier)))))))))) (return_statement (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier))))) |
public static void main ( String [ ] args ) {
System . out . println ( findWays ( 4 , 2 , 1 ) ) ;
System . out . println ( findWays ( 2 , 2 , 3 ) ) ;
System . out . println ( findWays ( 6 , 3 , 8 ) ) ;
System . out . println ( findWays ( 4 , 2 , 5 ) ) ;
System . out . println ( findWays ( 4 , 3 , 5 ) ) ;
}
| public static void main ( String [ ] args ) { System . out . println ( findWays ( 4 , 2 , 1 ) ) ; System . out . println ( findWays ( 2 , 2 , 3 ) ) ; System . out . println ( findWays ( 6 , 3 , 8 ) ) ; System . out . println ( findWays ( 4 , 2 , 5 ) ) ; System . out . println ( findWays ( 4 , 3 , 5 ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)))))))) |
static int toggle ( int n ) {
int temp = 1 ;
while ( temp <= n ) {
n = n ^ temp ;
temp = temp << 1 ;
}
return n ;
}
| static int toggle ( int n ) { int temp = 1 ; while ( temp <= n ) { n = n ^ temp ; temp = temp << 1 ; } return n ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (return_statement (identifier)))) |
public static void main ( String arg [ ] ) {
int n = 10 ;
n = toggle ( n ) ;
System . out . print ( n ) ;
}
| public static void main ( String arg [ ] ) { int n = 10 ; n = toggle ( n ) ; System . out . print ( n ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier) dimensions: (dimensions))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier)))))) |
static void sieve ( int maxm , int prime [ ] ) {
prime [ 0 ] = prime [ 1 ] = 1 ;
for ( int i = 2 ;
i * i <= maxm ;
i ++ ) if ( prime [ i ] == 0 ) for ( int j = 2 * i ;
j <= maxm ;
j += i ) prime [ j ] = 1 ;
}
| static void sieve ( int maxm , int prime [ ] ) { prime [ 0 ] = prime [ 1 ] = 1 ; for ( int i = 2 ; i * i <= maxm ; i ++ ) if ( prime [ i ] == 0 ) for ( int j = 2 * i ; j <= maxm ; j += i ) prime [ j ] = 1 ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions))) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)) update: (update_expression (identifier)) body: (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (decimal_integer_literal) right: (identifier)))) condition: (binary_expression left: (identifier) right: (identifier)) update: (assignment_expression left: (identifier) right: (identifier)) body: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)))))))) |
static int countPair ( int a [ ] , int n ) {
int maxm = a [ 0 ] ;
for ( int i = 1 ;
i < n ;
i ++ ) if ( a [ i ] > maxm ) maxm = a [ i ] ;
int [ ] prime = new int [ maxm + 1 ] ;
for ( int i = 0 ;
i < maxm + 1 ;
i ++ ) prime [ i ] = 0 ;
sieve ( maxm , prime ) ;
int count = 0 ;
for ( int i = 0 ;
i < n ;
i ++ ) for ( int j = i + 1 ;
j < n ;
j ++ ) if ( prime [ a [ i ] ] == 0 || prime [ a [ j ] ] == 0 ) count ++ ;
return count ;
}
| static int countPair ( int a [ ] , int n ) { int maxm = a [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) if ( a [ i ] > maxm ) maxm = a [ i ] ; int [ ] prime = new int [ maxm + 1 ] ; for ( int i = 0 ; i < maxm + 1 ; i ++ ) prime [ i ] = 0 ; sieve ( maxm , prime ) ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) if ( prime [ a [ i ] ] == 0 || prime [ a [ j ] ] == 0 ) count ++ ; return count ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (array_access array: (identifier) index: (decimal_integer_literal)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))) consequence: (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) update: (update_expression (identifier)) body: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (array_access array: (identifier) index: (identifier))) right: (decimal_integer_literal)) right: (binary_expression left: (array_access array: (identifier) index: (array_access array: (identifier) index: (identifier))) right: (decimal_integer_literal)))) consequence: (expression_statement (update_expression (identifier)))))) (return_statement (identifier)))) |
public static void main ( String [ ] args ) {
int arr [ ] = {
2 , 3 , 5 , 4 , 7 };
int n = arr . length ;
System . out . println ( countPair ( arr , n ) ) ;
}
| public static void main ( String [ ] args ) { int arr [ ] = { 2 , 3 , 5 , 4 , 7 } ; int n = arr . length ; System . out . println ( countPair ( arr , n ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_initializer (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))))))) |
static int maximumChars ( String str ) {
int n = str . length ( ) ;
int res = - 1 ;
int [ ] firstInd = new int [ MAX_CHAR ] ;
for ( int i = 0 ;
i < MAX_CHAR ;
i ++ ) firstInd [ i ] = - 1 ;
for ( int i = 0 ;
i < n ;
i ++ ) {
int first_ind = firstInd [ str . charAt ( i ) ] ;
if ( first_ind == - 1 ) firstInd [ str . charAt ( i ) ] = i ;
else res = Math . max ( res , Math . abs ( i - first_ind - 1 ) ) ;
}
return res ;
}
| static int maximumChars ( String str ) { int n = str . length ( ) ; int res = - 1 ; int [ ] firstInd = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) firstInd [ i ] = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { int first_ind = firstInd [ str . charAt ( i ) ] ; if ( first_ind == - 1 ) firstInd [ str . charAt ( i ) ] = i ; else res = Math . max ( res , Math . abs ( i - first_ind - 1 ) ) ; } return res ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (unary_expression operand: (decimal_integer_literal)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (unary_expression operand: (decimal_integer_literal))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (array_access array: (identifier) index: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (unary_expression operand: (decimal_integer_literal)))) consequence: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) right: (identifier))) alternative: (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal))))))))))) (return_statement (identifier)))) |
static public void main ( String [ ] args ) {
String str = "abba" ;
System . out . println ( maximumChars ( str ) ) ;
}
| static public void main ( String [ ] args ) { String str = " abba " ; System . out . println ( maximumChars ( str ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (string_literal))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier)))))))) |
static void frequency ( int fre [ ] [ ] , String s [ ] , int n ) {
for ( int i = 0 ;
i < n ;
i ++ ) {
String str = s [ i ] ;
for ( int j = 0 ;
j < str . length ( ) ;
j ++ ) fre [ i ] [ str . charAt ( j ) - 'a' ] ++ ;
}
}
| static void frequency ( int fre [ ] [ ] , String s [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { String str = s [ i ] ; for ( int j = 0 ; j < str . length ( ) ; j ++ ) fre [ i ] [ str . charAt ( j ) - ' a ' ] ++ ; } } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (type_identifier) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (array_access array: (identifier) index: (identifier)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (expression_statement (update_expression (array_access array: (array_access array: (identifier) index: (identifier)) index: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal)))))))))) |
static void LongestSequence ( int fre [ ] [ ] , int n ) {
for ( int i = 24 ;
i >= 0 ;
i -- ) {
int mi = fre [ 0 ] [ i ] ;
for ( int j = 1 ;
j < n ;
j ++ ) mi = Math . min ( fre [ j ] [ i ] , mi ) ;
while ( mi -- != 0 ) System . out . print ( ( char ) ( 'a' + i ) ) ;
}
}
| static void LongestSequence ( int fre [ ] [ ] , int n ) { for ( int i = 24 ; i >= 0 ; i -- ) { int mi = fre [ 0 ] [ i ] ; for ( int j = 1 ; j < n ; j ++ ) mi = Math . min ( fre [ j ] [ i ] , mi ) ; while ( mi -- != 0 ) System . out . print ( ( char ) ( ' a ' + i ) ) ; } } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (array_access array: (array_access array: (identifier) index: (decimal_integer_literal)) index: (identifier)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) (identifier)))))) (while_statement condition: (parenthesized_expression (binary_expression left: (update_expression (identifier)) right: (decimal_integer_literal))) body: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (cast_expression type: (integral_type) value: (parenthesized_expression (binary_expression left: (character_literal) right: (identifier)))))))))))) |
public static void main ( String args [ ] ) {
String s [ ] = {
"loo" , "lol" , "olive" };
int n = s . length ;
int fre [ ] [ ] = new int [ n ] [ 26 ] ;
frequency ( fre , s , n ) ;
LongestSequence ( fre , n ) ;
}
| public static void main ( String args [ ] ) { String s [ ] = { " loo " , " lol " , " olive " } ; int n = s . length ; int fre [ ] [ ] = new int [ n ] [ 26 ] ; frequency ( fre , s , n ) ; LongestSequence ( fre , n ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier) dimensions: (dimensions))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_initializer (string_literal) (string_literal) (string_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier)) dimensions: (dimensions_expr (decimal_integer_literal))))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier)))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))))) |
static int NumberOfSolutions ( int x , int y , int z , int n ) {
int ans = 0 ;
for ( int i = 0 ;
i <= x ;
i ++ ) {
for ( int j = 0 ;
j <= y ;
j ++ ) {
int temp = n - i - j ;
if ( temp >= 0 ) {
temp = Math . min ( temp , z ) ;
ans += temp + 1 ;
}
}
}
return ans ;
}
| static int NumberOfSolutions ( int x , int y , int z , int n ) { int ans = 0 ; for ( int i = 0 ; i <= x ; i ++ ) { for ( int j = 0 ; j <= y ; j ++ ) { int temp = n - i - j ; if ( temp >= 0 ) { temp = Math . min ( temp , z ) ; ans += temp + 1 ; } } } return ans ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))))))))) (return_statement (identifier)))) |
public static void main ( String [ ] args ) {
int x = 1 , y = 2 , z = 3 , n = 4 ;
System . out . println ( NumberOfSolutions ( x , y , z , n ) ) ;
}
| public static void main ( String [ ] args ) { int x = 1 , y = 2 , z = 3 , n = 4 ; System . out . println ( NumberOfSolutions ( x , y , z , n ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier) (identifier)))))))) |
static int findMaxOR ( int [ ] arr , int n ) {
int temp ;
for ( int i = 0 ;
i < n ;
i ++ ) {
for ( int j = i + 1 ;
j < n ;
j ++ ) {
if ( arr [ i ] < arr [ j ] ) {
temp = arr [ i ] ;
arr [ i ] = arr [ j ] ;
arr [ j ] = temp ;
}
}
}
int maxOR = arr [ 0 ] ;
int count = 1 ;
for ( int i = 1 ;
i < n ;
i ++ ) {
if ( ( maxOR | arr [ i ] ) > maxOR ) {
maxOR = maxOR | arr [ i ] ;
count ++ ;
}
}
return count ;
}
| static int findMaxOR ( int [ ] arr , int n ) { int temp ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( arr [ i ] < arr [ j ] ) { temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; } } } int maxOR = arr [ 0 ] ; int count = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( ( maxOR | arr [ i ] ) > maxOR ) { maxOR = maxOR | arr [ i ] ; count ++ ; } } return count ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (array_access array: (identifier) index: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier))))) (expression_statement (update_expression (identifier))))))) (return_statement (identifier)))) |
public static void main ( String arrgs [ ] ) {
int [ ] arr = {
5 , 1 , 3 , 4 , 2 };
int n = arr . length ;
System . out . println ( findMaxOR ( arr , n ) ) ;
}
| public static void main ( String arrgs [ ] ) { int [ ] arr = { 5 , 1 , 3 , 4 , 2 } ; int n = arr . length ; System . out . println ( findMaxOR ( arr , n ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier) dimensions: (dimensions))) body: (block (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_initializer (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))))))) |
static int maxSubArraySum ( int a [ ] , int size ) {
int max_so_far = Integer . MIN_VALUE , max_ending_here = 0 ;
for ( int i = 0 ;
i < size ;
i ++ ) {
max_ending_here = max_ending_here + a [ i ] ;
if ( max_so_far < max_ending_here ) max_so_far = max_ending_here ;
if ( max_ending_here < 0 ) max_ending_here = 0 ;
}
return max_so_far ;
}
| static int maxSubArraySum ( int a [ ] , int size ) { int max_so_far = Integer . MIN_VALUE , max_ending_here = 0 ; for ( int i = 0 ; i < size ; i ++ ) { max_ending_here = max_ending_here + a [ i ] ; if ( max_so_far < max_ending_here ) max_so_far = max_ending_here ; if ( max_ending_here < 0 ) max_ending_here = 0 ; } return max_so_far ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier))) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (expression_statement (assignment_expression left: (identifier) right: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal)))))) (return_statement (identifier)))) |
static int maximizeSum ( int a [ ] , int n ) {
int cnt = 0 ;
int mini = Integer . MAX_VALUE ;
int minSubarray = Integer . MAX_VALUE ;
int sum = maxSubArraySum ( a , n ) ;
int max_so_far = Integer . MIN_VALUE , max_ending_here = 0 ;
for ( int i = 0 ;
i < n ;
i ++ ) {
max_ending_here = max_ending_here + a [ i ] ;
cnt ++ ;
minSubarray = Math . min ( a [ i ] , minSubarray ) ;
if ( sum == max_ending_here ) {
if ( cnt == 1 ) mini = Math . min ( mini , 0 ) ;
else mini = Math . min ( mini , minSubarray ) ;
}
if ( max_ending_here < 0 ) {
max_ending_here = 0 ;
cnt = 0 ;
minSubarray = Integer . MAX_VALUE ;
}
}
return sum - mini ;
}
| static int maximizeSum ( int a [ ] , int n ) { int cnt = 0 ; int mini = Integer . MAX_VALUE ; int minSubarray = Integer . MAX_VALUE ; int sum = maxSubArraySum ( a , n ) ; int max_so_far = Integer . MIN_VALUE , max_ending_here = 0 ; for ( int i = 0 ; i < n ; i ++ ) { max_ending_here = max_ending_here + a [ i ] ; cnt ++ ; minSubarray = Math . min ( a [ i ] , minSubarray ) ; if ( sum == max_ending_here ) { if ( cnt == 1 ) mini = Math . min ( mini , 0 ) ; else mini = Math . min ( mini , minSubarray ) ; } if ( max_ending_here < 0 ) { max_ending_here = 0 ; cnt = 0 ; minSubarray = Integer . MAX_VALUE ; } } return sum - mini ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier))) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier))))) (expression_statement (update_expression (identifier))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)) (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal))))) alternative: (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier)))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (expression_statement (assignment_expression left: (identifier) right: (field_access object: (identifier) field: (identifier)))))))) (return_statement (binary_expression left: (identifier) right: (identifier))))) |
public static void main ( String [ ] args ) {
int a [ ] = {
1 , 2 , 3 , - 2 , 3 };
int n = a . length ;
System . out . println ( maximizeSum ( a , n ) ) ;
}
| public static void main ( String [ ] args ) { int a [ ] = { 1 , 2 , 3 , - 2 , 3 } ; int n = a . length ; System . out . println ( maximizeSum ( a , n ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_initializer (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (unary_expression operand: (decimal_integer_literal)) (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))))))) |
static int findSum ( int [ ] arr , int n , int k ) {
int ans = arr [ n - k - 1 ] - arr [ 0 ] ;
for ( int i = 1 ;
i <= k ;
i ++ ) {
ans = Math . min ( arr [ n - 1 - ( k - i ) ] - arr [ i ] , ans ) ;
}
return ans ;
}
| static int findSum ( int [ ] arr , int n , int k ) { int ans = arr [ n - k - 1 ] - arr [ 0 ] ; for ( int i = 1 ; i <= k ; i ++ ) { ans = Math . min ( arr [ n - 1 - ( k - i ) ] - arr [ i ] , ans ) ; } return ans ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal))) right: (array_access array: (identifier) index: (decimal_integer_literal))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))))) right: (array_access array: (identifier) index: (identifier))) (identifier))))))) (return_statement (identifier)))) |
public static void main ( String [ ] args ) {
int arr [ ] = {
1 , 2 , 100 , 120 , 140 };
int k = 2 ;
int n = arr . length ;
System . out . println ( findSum ( arr , n , k ) ) ;
}
| public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 100 , 120 , 140 } ; int k = 2 ; int n = arr . length ; System . out . println ( findSum ( arr , n , k ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_initializer (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier)))))))) |
static void longest ( int a [ ] , int n , int k ) {
int [ ] freq = new int [ 7 ] ;
int start = 0 , end = 0 , now = 0 , l = 0 ;
for ( int i = 0 ;
i < n ;
i ++ ) {
freq [ a [ i ] ] ++ ;
if ( freq [ a [ i ] ] == 1 ) now ++ ;
while ( now > k ) {
freq [ a [ l ] ] -- ;
if ( freq [ a [ l ] ] == 0 ) now -- ;
l ++ ;
}
if ( i - l + 1 >= end - start + 1 ) {
end = i ;
start = l ;
}
}
for ( int i = start ;
i <= end ;
i ++ ) System . out . print ( a [ i ] + " " ) ;
}
| static void longest ( int a [ ] , int n , int k ) { int [ ] freq = new int [ 7 ] ; int start = 0 , end = 0 , now = 0 , l = 0 ; for ( int i = 0 ; i < n ; i ++ ) { freq [ a [ i ] ] ++ ; if ( freq [ a [ i ] ] == 1 ) now ++ ; while ( now > k ) { freq [ a [ l ] ] -- ; if ( freq [ a [ l ] ] == 0 ) now -- ; l ++ ; } if ( i - l + 1 >= end - start + 1 ) { end = i ; start = l ; } } for ( int i = start ; i <= end ; i ++ ) System . out . print ( a [ i ] + " β " ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (decimal_integer_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (update_expression (array_access array: (identifier) index: (array_access array: (identifier) index: (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (array_access array: (identifier) index: (identifier))) right: (decimal_integer_literal))) consequence: (expression_statement (update_expression (identifier)))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) body: (block (expression_statement (update_expression (array_access array: (identifier) index: (array_access array: (identifier) index: (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (array_access array: (identifier) index: (identifier))) right: (decimal_integer_literal))) consequence: (expression_statement (update_expression (identifier)))) (expression_statement (update_expression (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal)) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (identifier))))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (string_literal)))))))) |
public static void main ( String args [ ] ) {
int a [ ] = {
6 , 5 , 1 , 2 , 3 , 2 , 1 , 4 , 5 };
int n = a . length ;
int k = 3 ;
longest ( a , n , k ) ;
}
| public static void main ( String args [ ] ) { int a [ ] = { 6 , 5 , 1 , 2 , 3 , 2 , 1 , 4 , 5 } ; int n = a . length ; int k = 3 ; longest ( a , n , k ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier) dimensions: (dimensions))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_initializer (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier)))))) |
public static void printMultiples ( int N ) {
for ( int i = 1 ;
i <= N ;
i ++ ) {
for ( int j = 1 ;
j <= i ;
j ++ ) {
System . out . print ( ( i * j ) + " " ) ;
}
System . out . println ( ) ;
}
}
| public static void printMultiples ( int N ) { for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = 1 ; j <= i ; j ++ ) { System . out . print ( ( i * j ) + " β " ) ; } System . out . println ( ) ; } } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier))) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (string_literal))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list))))))) |
public static void main ( String args [ ] ) {
int N = 5 ;
printMultiples ( N ) ;
}
| public static void main ( String args [ ] ) { int N = 5 ; printMultiples ( N ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier) dimensions: (dimensions))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier)))))) |
static int maxEvenLenSum ( int arr [ ] , int n ) {
if ( n < 2 ) return 0 ;
int [ ] dp = new int [ n ] ;
dp [ n - 1 ] = 0 ;
dp [ n - 2 ] = arr [ n - 2 ] + arr [ n - 1 ] ;
for ( int i = n - 3 ;
i >= 0 ;
i -- ) {
dp [ i ] = arr [ i ] + arr [ i + 1 ] ;
if ( dp [ i + 2 ] > 0 ) dp [ i ] += dp [ i + 2 ] ;
}
int maxSum = Arrays . stream ( dp ) . max ( ) . getAsInt ( ) ;
return maxSum ;
}
| static int maxEvenLenSum ( int arr [ ] , int n ) { if ( n < 2 ) return 0 ; int [ ] dp = new int [ n ] ; dp [ n - 1 ] = 0 ; dp [ n - 2 ] = arr [ n - 2 ] + arr [ n - 1 ] ; for ( int i = n - 3 ; i >= 0 ; i -- ) { dp [ i ] = arr [ i ] + arr [ i + 1 ] ; if ( dp [ i + 2 ] > 0 ) dp [ i ] += dp [ i + 2 ] ; } int maxSum = Arrays . stream ( dp ) . max ( ) . getAsInt ( ) ; return maxSum ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (return_statement (decimal_integer_literal))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list)))) (return_statement (identifier)))) |
public static void main ( String [ ] args ) {
int arr [ ] = {
8 , 9 , - 8 , 9 , 10 };
int n = arr . length ;
System . out . println ( maxEvenLenSum ( arr , n ) ) ;
}
| public static void main ( String [ ] args ) { int arr [ ] = { 8 , 9 , - 8 , 9 , 10 } ; int n = arr . length ; System . out . println ( maxEvenLenSum ( arr , n ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_initializer (decimal_integer_literal) (decimal_integer_literal) (unary_expression operand: (decimal_integer_literal)) (decimal_integer_literal) (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))))))) |
public static void main ( String args [ ] ) {
int arr [ ] = {
2 , 1 , 3 , 2 , 3 };
System . out . println ( countDistictSubarray ( arr , arr . length ) ) ;
}
| public static void main ( String args [ ] ) { int arr [ ] = { 2 , 1 , 3 , 2 , 3 } ; System . out . println ( countDistictSubarray ( arr , arr . length ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier) dimensions: (dimensions))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_initializer (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier) (field_access object: (identifier) field: (identifier))))))))) |
static int nth_term ( int a , int b , int n ) {
int z = 0 ;
if ( n % 6 == 1 ) z = a ;
else if ( n % 6 == 2 ) z = b ;
else if ( n % 6 == 3 ) z = b - a ;
else if ( n % 6 == 4 ) z = - a ;
else if ( n % 6 == 5 ) z = - b ;
if ( n % 6 == 0 ) z = - ( b - a ) ;
return z ;
}
| static int nth_term ( int a , int b , int n ) { int z = 0 ; if ( n % 6 == 1 ) z = a ; else if ( n % 6 == 2 ) z = b ; else if ( n % 6 == 3 ) z = b - a ; else if ( n % 6 == 4 ) z = - a ; else if ( n % 6 == 5 ) z = - b ; if ( n % 6 == 0 ) z = - ( b - a ) ; return z ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (identifier))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (identifier))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier)))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (unary_expression operand: (identifier)))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (unary_expression operand: (identifier))))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (unary_expression operand: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))))))) (return_statement (identifier)))) |
public static void main ( String [ ] args ) {
int a = 10 , b = 17 , n = 3 ;
System . out . println ( nth_term ( a , b , n ) ) ;
}
| public static void main ( String [ ] args ) { int a = 10 , b = 17 , n = 3 ; System . out . println ( nth_term ( a , b , n ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier)))))))) |
static int totalDigits ( int n ) {
int number_of_digits = 0 ;
for ( int i = 1 ;
i <= n ;
i *= 10 ) number_of_digits += ( n - i + 1 ) ;
return number_of_digits ;
}
| static int totalDigits ( int n ) { int number_of_digits = 0 ; for ( int i = 1 ; i <= n ; i *= 10 ) number_of_digits += ( n - i + 1 ) ; return number_of_digits ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (assignment_expression left: (identifier) right: (decimal_integer_literal)) body: (expression_statement (assignment_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal)))))) (return_statement (identifier)))) |
public static void main ( String [ ] args ) {
int n = 13 ;
System . out . println ( totalDigits ( n ) ) ;
}
| public static void main ( String [ ] args ) { int n = 13 ; System . out . println ( totalDigits ( n ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier)))))))) |
static void isSubsetAndZero ( int array [ ] , int length , int N ) {
int arrAnd = array [ 0 ] ;
for ( int i = 1 ;
i < length ;
i ++ ) {
arrAnd = arrAnd & array [ i ] ;
}
if ( ( arrAnd & N ) == 0 ) System . out . println ( "YES" ) ;
else System . out . println ( "NO" ) ;
}
| static void isSubsetAndZero ( int array [ ] , int length , int N ) { int arrAnd = array [ 0 ] ; for ( int i = 1 ; i < length ; i ++ ) { arrAnd = arrAnd & array [ i ] ; } if ( ( arrAnd & N ) == 0 ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (array_access array: (identifier) index: (decimal_integer_literal)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal))) consequence: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) alternative: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal))))))) |
public static void main ( String [ ] args ) {
int array [ ] = {
1 , 2 , 4 };
int length = array . length ;
int N = 3 ;
isSubsetAndZero ( array , length , N ) ;
}
| public static void main ( String [ ] args ) { int array [ ] = { 1 , 2 , 4 } ; int length = array . length ; int N = 3 ; isSubsetAndZero ( array , length , N ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_initializer (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier)))))) |
static int maximumAbsolute ( int arr [ ] , int n ) {
int mn = Integer . MAX_VALUE ;
int mx = Integer . MIN_VALUE ;
for ( int i = 0 ;
i < n ;
i ++ ) {
if ( i > 0 && arr [ i ] == - 1 && arr [ i - 1 ] != - 1 ) {
mn = Math . min ( mn , arr [ i - 1 ] ) ;
mx = Math . max ( mx , arr [ i - 1 ] ) ;
}
if ( i < n - 1 && arr [ i ] == - 1 && arr [ i + 1 ] != - 1 ) {
mn = Math . min ( mn , arr [ i + 1 ] ) ;
mx = Math . max ( mx , arr [ i + 1 ] ) ;
}
}
int common_integer = ( mn + mx ) / 2 ;
for ( int i = 0 ;
i < n ;
i ++ ) {
if ( arr [ i ] == - 1 ) arr [ i ] = common_integer ;
}
int max_diff = 0 ;
for ( int i = 0 ;
i < n - 1 ;
i ++ ) {
int diff = Math . abs ( arr [ i ] - arr [ i + 1 ] ) ;
if ( diff > max_diff ) max_diff = diff ;
}
return max_diff ;
}
| static int maximumAbsolute ( int arr [ ] , int n ) { int mn = Integer . MAX_VALUE ; int mx = Integer . MIN_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { if ( i > 0 && arr [ i ] == - 1 && arr [ i - 1 ] != - 1 ) { mn = Math . min ( mn , arr [ i - 1 ] ) ; mx = Math . max ( mx , arr [ i - 1 ] ) ; } if ( i < n - 1 && arr [ i ] == - 1 && arr [ i + 1 ] != - 1 ) { mn = Math . min ( mn , arr [ i + 1 ] ) ; mx = Math . max ( mx , arr [ i + 1 ] ) ; } } int common_integer = ( mn + mx ) / 2 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == - 1 ) arr [ i ] = common_integer ; } int max_diff = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { int diff = Math . abs ( arr [ i ] - arr [ i + 1 ] ) ; if ( diff > max_diff ) max_diff = diff ; } return max_diff ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (unary_expression operand: (decimal_integer_literal)))) right: (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (unary_expression operand: (decimal_integer_literal))))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (unary_expression operand: (decimal_integer_literal)))) right: (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (unary_expression operand: (decimal_integer_literal))))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))))))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (unary_expression operand: (decimal_integer_literal)))) consequence: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (expression_statement (assignment_expression left: (identifier) right: (identifier)))))) (return_statement (identifier)))) |
public static void main ( String [ ] args ) {
int arr [ ] = {
- 1 , - 1 , 11 , - 1 , 3 , - 1 };
int n = arr . length ;
System . out . print ( maximumAbsolute ( arr , n ) ) ;
}
| public static void main ( String [ ] args ) { int arr [ ] = { - 1 , - 1 , 11 , - 1 , 3 , - 1 } ; int n = arr . length ; System . out . print ( maximumAbsolute ( arr , n ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_initializer (unary_expression operand: (decimal_integer_literal)) (unary_expression operand: (decimal_integer_literal)) (decimal_integer_literal) (unary_expression operand: (decimal_integer_literal)) (decimal_integer_literal) (unary_expression operand: (decimal_integer_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))))))) |
static void pattern ( int n ) {
int i , j ;
for ( i = n - 1 ;
i >= 0 ;
i -- ) {
for ( j = n - 1 ;
j > i ;
j -- ) {
System . out . print ( " " ) ;
}
System . out . print ( ( char ) ( i + 65 ) ) ;
for ( j = 1 ;
j < ( i * 2 ) ;
j ++ ) System . out . print ( " " ) ;
if ( i >= 1 ) System . out . print ( ( char ) ( i + 65 ) ) ;
System . out . print ( "\n" ) ;
}
}
| static void pattern ( int n ) { int i , j ; for ( i = n - 1 ; i >= 0 ; i -- ) { for ( j = n - 1 ; j > i ; j -- ) { System . out . print ( " β " ) ; } System . out . print ( ( char ) ( i + 65 ) ) ; for ( j = 1 ; j < ( i * 2 ) ; j ++ ) System . out . print ( " β " ) ; if ( i >= 1 ) System . out . print ( ( char ) ( i + 65 ) ) ; System . out . print ( " \n " ) ; } } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier))) (for_statement init: (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (for_statement init: (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (cast_expression type: (integral_type) value: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))))))) (for_statement init: (assignment_expression left: (identifier) right: (decimal_integer_literal)) condition: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal)))) update: (update_expression (identifier)) body: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (cast_expression type: (integral_type) value: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal)))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))))))) |
public static void main ( String args [ ] ) {
int n = 5 ;
pattern ( n ) ;
}
| public static void main ( String args [ ] ) { int n = 5 ; pattern ( n ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier) dimensions: (dimensions))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier)))))) |
static int octalToDecimal ( int n ) {
int num = n ;
int dec_value = 0 ;
int base = 1 ;
int temp = num ;
while ( temp > 0 ) {
int last_digit = temp % 10 ;
temp = temp / 10 ;
dec_value += last_digit * base ;
base = base * 8 ;
}
return dec_value ;
}
| static int octalToDecimal ( int n ) { int num = n ; int dec_value = 0 ; int base = 1 ; int temp = num ; while ( temp > 0 ) { int last_digit = temp % 10 ; temp = temp / 10 ; dec_value += last_digit * base ; base = base * 8 ; } return dec_value ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (return_statement (identifier)))) |
public static void main ( String [ ] args ) {
int num = 67 ;
System . out . println ( octalToDecimal ( num ) ) ;
}
| public static void main ( String [ ] args ) { int num = 67 ; System . out . println ( octalToDecimal ( num ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier)))))))) |
public static void main ( String [ ] args ) {
OddOccurance occur = new OddOccurance ( ) ;
int ar [ ] = new int [ ] {
2 , 3 , 5 , 4 , 5 , 2 , 4 , 3 , 5 , 2 , 4 , 4 , 2 };
int n = ar . length ;
System . out . println ( occur . getOddOccurrence ( ar , n ) ) ;
}
| public static void main ( String [ ] args ) { OddOccurance occur = new OddOccurance ( ) ; int ar [ ] = new int [ ] { 2 , 3 , 5 , 4 , 5 , 2 , 4 , 3 , 5 , 2 , 4 , 4 , 2 } ; int n = ar . length ; System . out . println ( occur . getOddOccurrence ( ar , n ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions) value: (array_initializer (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier)))))))) |
public static int find_value ( int a [ ] , int n , int k ) {
int sum = 0 ;
for ( int i = 0 ;
i < n ;
i ++ ) {
sum += a [ i ] ;
}
return sum % k ;
}
| public static int find_value ( int a [ ] , int n , int k ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += a [ i ] ; } return sum % k ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))))) (return_statement (binary_expression left: (identifier) right: (identifier))))) |
public static void main ( String [ ] args ) {
int n = 5 , k = 3 ;
int a [ ] = {
12 , 4 , 13 , 0 , 5 };
System . out . println ( find_value ( a , n , k ) ) ;
}
| public static void main ( String [ ] args ) { int n = 5 , k = 3 ; int a [ ] = { 12 , 4 , 13 , 0 , 5 } ; System . out . println ( find_value ( a , n , k ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_initializer (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier)))))))) |
static Vector < Integer > Diffs ( int [ ] a , int k ) {
Vector < Integer > out = new Vector < Integer > ( ) ;
int [ ] inc , dec ;
inc = new int [ a . length ] ;
dec = new int [ a . length ] ;
int inc_sum = 0 ;
int dec_sum = 0 ;
for ( int i = 0 ;
i < a . length ;
++ i ) {
for ( int j = i - 1 ;
j >= 0 && j > i - k && a [ j + 1 ] > a [ j ] ;
-- j ) {
++ inc [ j ] ;
++ inc_sum ;
}
for ( int j = i - 1 ;
j >= 0 && j > i - k && a [ j + 1 ] < a [ j ] ;
-- j ) {
++ dec [ j ] ;
++ dec_sum ;
}
if ( i >= k - 1 ) {
if ( i >= k ) {
inc_sum -= inc [ i - k ] ;
dec_sum -= dec [ i - k ] ;
}
out . add ( inc_sum - dec_sum ) ;
}
}
return out ;
}
| static Vector < Integer > Diffs ( int [ ] a , int k ) { Vector < Integer > out = new Vector < Integer > ( ) ; int [ ] inc , dec ; inc = new int [ a . length ] ; dec = new int [ a . length ] ; int inc_sum = 0 ; int dec_sum = 0 ; for ( int i = 0 ; i < a . length ; ++ i ) { for ( int j = i - 1 ; j >= 0 && j > i - k && a [ j + 1 ] > a [ j ] ; -- j ) { ++ inc [ j ] ; ++ inc_sum ; } for ( int j = i - 1 ; j >= 0 && j > i - k && a [ j + 1 ] < a [ j ] ; -- j ) { ++ dec [ j ] ; ++ dec_sum ; } if ( i >= k - 1 ) { if ( i >= k ) { inc_sum -= inc [ i - k ] ; dec_sum -= dec [ i - k ] ; } out . add ( inc_sum - dec_sum ) ; } } return out ; } | (method_declaration (modifiers) type: (generic_type (type_identifier) (type_arguments (type_identifier))) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments (type_identifier))) arguments: (argument_list)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (field_access object: (identifier) field: (identifier)))))) (expression_statement (assignment_expression left: (identifier) right: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (field_access object: (identifier) field: (identifier))) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier)))) right: (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (array_access array: (identifier) index: (identifier)))) update: (update_expression (identifier)) body: (block (expression_statement (update_expression (array_access array: (identifier) index: (identifier)))) (expression_statement (update_expression (identifier))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier)))) right: (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (array_access array: (identifier) index: (identifier)))) update: (update_expression (identifier)) body: (block (expression_statement (update_expression (array_access array: (identifier) index: (identifier)))) (expression_statement (update_expression (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (identifier))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier))))))))) (return_statement (identifier)))) |
public static void main ( String [ ] args ) {
int [ ] arr = {
10 , 20 , 30 , 15 , 15 };
Vector < Integer > out = Diffs ( arr , 3 ) ;
for ( int n : out ) System . out . print ( n + ", " ) ;
}
| public static void main ( String [ ] args ) { int [ ] arr = { 10 , 20 , 30 , 15 , 15 } ; Vector < Integer > out = Diffs ( arr , 3 ) ; for ( int n : out ) System . out . print ( n + " , β " ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_initializer (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal))))) (enhanced_for_statement type: (integral_type) name: (identifier) value: (identifier) body: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (string_literal)))))))) |
static int evaluateBoolExpr ( StringBuffer s ) {
int n = s . length ( ) ;
for ( int i = 0 ;
i < n ;
i += 2 ) {
if ( i + 1 < n && i + 2 < n ) {
if ( s . charAt ( i + 1 ) == 'A' ) {
if ( s . charAt ( i + 2 ) == '0' || s . charAt ( i ) == 0 ) s . setCharAt ( i + 2 , '0' ) ;
else s . setCharAt ( i + 2 , '1' ) ;
}
else if ( ( i + 1 ) < n && s . charAt ( i + 1 ) == 'B' ) {
if ( s . charAt ( i + 2 ) == '1' || s . charAt ( i ) == '1' ) s . setCharAt ( i + 2 , '1' ) ;
else s . setCharAt ( i + 2 , '0' ) ;
}
else {
if ( s . charAt ( i + 2 ) == s . charAt ( i ) ) s . setCharAt ( i + 2 , '0' ) ;
else s . setCharAt ( i + 2 , '1' ) ;
}
}
}
return s . charAt ( n - 1 ) - '0' ;
}
| static int evaluateBoolExpr ( StringBuffer s ) { int n = s . length ( ) ; for ( int i = 0 ; i < n ; i += 2 ) { if ( i + 1 < n && i + 2 < n ) { if ( s . charAt ( i + 1 ) == ' A ' ) { if ( s . charAt ( i + 2 ) == '0' || s . charAt ( i ) == 0 ) s . setCharAt ( i + 2 , '0' ) ; else s . setCharAt ( i + 2 , '1' ) ; } else if ( ( i + 1 ) < n && s . charAt ( i + 1 ) == ' B ' ) { if ( s . charAt ( i + 2 ) == '1' || s . charAt ( i ) == '1' ) s . setCharAt ( i + 2 , '1' ) ; else s . setCharAt ( i + 2 , '0' ) ; } else { if ( s . charAt ( i + 2 ) == s . charAt ( i ) ) s . setCharAt ( i + 2 , '0' ) ; else s . setCharAt ( i + 2 , '1' ) ; } } } return s . charAt ( n - 1 ) - '0' ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (assignment_expression left: (identifier) right: (decimal_integer_literal)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (identifier)) right: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (identifier)))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (character_literal))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (character_literal)) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (decimal_integer_literal)))) consequence: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (character_literal)))) alternative: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (character_literal)))))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (identifier)) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (character_literal)))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (character_literal)) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal)))) consequence: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (character_literal)))) alternative: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (character_literal)))))) alternative: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) consequence: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (character_literal)))) alternative: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (character_literal)))))))))))) (return_statement (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (character_literal))))) |
public static void main ( String [ ] args ) {
String s = "1C1B1B0A0" ;
StringBuffer sb = new StringBuffer ( s ) ;
System . out . println ( evaluateBoolExpr ( sb ) ) ;
}
| public static void main ( String [ ] args ) { String s = "1C1B1B0A0" ; StringBuffer sb = new StringBuffer ( s ) ; System . out . println ( evaluateBoolExpr ( sb ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (string_literal))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier)))))))) |
static void printPair ( int g , int l ) {
System . out . print ( g + " " + l ) ;
}
| static void printPair ( int g , int l ) { System . out . print ( g + " β " + l ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (identifier) right: (string_literal)) right: (identifier))))))) |
public static void main ( String [ ] args ) {
int g = 3 , l = 12 ;
printPair ( g , l ) ;
}
| public static void main ( String [ ] args ) { int g = 3 , l = 12 ; printPair ( g , l ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))))) |
static int no_of_ways ( int a [ ] , int n ) {
int count_0 = 0 , count_1 = 0 ;
for ( int i = 0 ;
i < n ;
i ++ ) {
if ( a [ i ] == 0 ) count_0 ++ ;
else count_1 ++ ;
}
if ( count_1 % 2 == 0 ) return count_0 ;
else return count_1 ;
}
| static int no_of_ways ( int a [ ] , int n ) { int count_0 = 0 , count_1 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] == 0 ) count_0 ++ ; else count_1 ++ ; } if ( count_1 % 2 == 0 ) return count_0 ; else return count_1 ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (expression_statement (update_expression (identifier))) alternative: (expression_statement (update_expression (identifier)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (return_statement (identifier)) alternative: (return_statement (identifier))))) |
public static void main ( String [ ] args ) {
int n = 4 ;
int a1 [ ] = {
1 , 1 , 0 , 0 };
System . out . println ( no_of_ways ( a1 , n ) ) ;
n = 5 ;
int a2 [ ] = {
1 , 1 , 1 , 0 , 0 };
System . out . println ( no_of_ways ( a2 , n ) ) ;
n = 5 ;
int a3 [ ] = {
1 , 1 , 0 , 0 , 0 };
System . out . println ( no_of_ways ( a3 , n ) ) ;
n = 6 ;
int a4 [ ] = {
1 , 1 , 1 , 0 , 0 , 0 };
System . out . println ( no_of_ways ( a4 , n ) ) ;
}
| public static void main ( String [ ] args ) { int n = 4 ; int a1 [ ] = { 1 , 1 , 0 , 0 } ; System . out . println ( no_of_ways ( a1 , n ) ) ; n = 5 ; int a2 [ ] = { 1 , 1 , 1 , 0 , 0 } ; System . out . println ( no_of_ways ( a2 , n ) ) ; n = 5 ; int a3 [ ] = { 1 , 1 , 0 , 0 , 0 } ; System . out . println ( no_of_ways ( a3 , n ) ) ; n = 6 ; int a4 [ ] = { 1 , 1 , 1 , 0 , 0 , 0 } ; System . out . println ( no_of_ways ( a4 , n ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_initializer (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_initializer (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_initializer (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_initializer (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))))))) |
static int printNthElement ( int n ) {
int arr [ ] = new int [ n + 1 ] ;
arr [ 1 ] = 1 ;
arr [ 2 ] = 2 ;
for ( int i = 3 ;
i <= n ;
i ++ ) {
if ( i % 2 != 0 ) arr [ i ] = arr [ i / 2 ] * 10 + 1 ;
else arr [ i ] = arr [ ( i / 2 ) - 1 ] * 10 + 2 ;
}
return arr [ n ] ;
}
| static int printNthElement ( int n ) { int arr [ ] = new int [ n + 1 ] ; arr [ 1 ] = 1 ; arr [ 2 ] = 2 ; for ( int i = 3 ; i <= n ; i ++ ) { if ( i % 2 != 0 ) arr [ i ] = arr [ i / 2 ] * 10 + 1 ; else arr [ i ] = arr [ ( i / 2 ) - 1 ] * 10 + 2 ; } return arr [ n ] ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal)) right: (decimal_integer_literal)))) alternative: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal))) right: (decimal_integer_literal)) right: (decimal_integer_literal))))))) (return_statement (array_access array: (identifier) index: (identifier))))) |
public static void main ( String [ ] args ) {
int n = 5 ;
System . out . println ( printNthElement ( n ) ) ;
}
| public static void main ( String [ ] args ) { int n = 5 ; System . out . println ( printNthElement ( n ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier)))))))) |
static boolean isPrime ( int n ) {
int i , c = 0 ;
for ( i = 1 ;
i < n / 2 ;
i ++ ) {
if ( n % i == 0 ) c ++ ;
}
if ( c == 1 ) {
return true ;
}
else {
return false ;
}
}
| static boolean isPrime ( int n ) { int i , c = 0 ; for ( i = 1 ; i < n / 2 ; i ++ ) { if ( n % i == 0 ) c ++ ; } if ( c == 1 ) { return true ; } else { return false ; } } | (method_declaration (modifiers) type: (boolean_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (assignment_expression left: (identifier) right: (decimal_integer_literal)) condition: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal))) consequence: (expression_statement (update_expression (identifier)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (return_statement (true))) alternative: (block (return_statement (false)))))) |
static void findMinNum ( int arr [ ] , int n ) {
int first = 0 , last = 0 , num , rev , i ;
int hash [ ] = new int [ 10 ] ;
for ( i = 0 ;
i < n ;
i ++ ) {
hash [ arr [ i ] ] ++ ;
}
System . out . print ( "Minimum number: " ) ;
for ( i = 0 ;
i <= 9 ;
i ++ ) {
for ( int j = 0 ;
j < hash [ i ] ;
j ++ ) System . out . print ( i ) ;
}
System . out . println ( ) ;
System . out . println ( ) ;
for ( i = 0 ;
i <= 9 ;
i ++ ) {
if ( hash [ i ] != 0 ) {
first = i ;
break ;
}
}
for ( i = 9 ;
i >= 0 ;
i -- ) {
if ( hash [ i ] != 0 ) {
last = i ;
break ;
}
}
num = first * 10 + last ;
rev = last * 10 + first ;
System . out . print ( "Prime combinations: " ) ;
if ( isPrime ( num ) && isPrime ( rev ) ) {
System . out . println ( num + " " + rev ) ;
}
else if ( isPrime ( num ) ) {
System . out . println ( num ) ;
}
else if ( isPrime ( rev ) ) {
System . out . println ( rev ) ;
}
else {
System . out . println ( "No combinations exist" ) ;
}
}
| static void findMinNum ( int arr [ ] , int n ) { int first = 0 , last = 0 , num , rev , i ; int hash [ ] = new int [ 10 ] ; for ( i = 0 ; i < n ; i ++ ) { hash [ arr [ i ] ] ++ ; } System . out . print ( " Minimum β number : β " ) ; for ( i = 0 ; i <= 9 ; i ++ ) { for ( int j = 0 ; j < hash [ i ] ; j ++ ) System . out . print ( i ) ; } System . out . println ( ) ; System . out . println ( ) ; for ( i = 0 ; i <= 9 ; i ++ ) { if ( hash [ i ] != 0 ) { first = i ; break ; } } for ( i = 9 ; i >= 0 ; i -- ) { if ( hash [ i ] != 0 ) { last = i ; break ; } } num = first * 10 + last ; rev = last * 10 + first ; System . out . print ( " Prime β combinations : β " ) ; if ( isPrime ( num ) && isPrime ( rev ) ) { System . out . println ( num + " β " + rev ) ; } else if ( isPrime ( num ) ) { System . out . println ( num ) ; } else if ( isPrime ( rev ) ) { System . out . println ( rev ) ; } else { System . out . println ( " No β combinations β exist " ) ; } } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (decimal_integer_literal))))) (for_statement init: (assignment_expression left: (identifier) right: (decimal_integer_literal)) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (update_expression (array_access array: (identifier) index: (array_access array: (identifier) index: (identifier))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) (for_statement init: (assignment_expression left: (identifier) right: (decimal_integer_literal)) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier))) update: (update_expression (identifier)) body: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list))) (for_statement init: (assignment_expression left: (identifier) right: (decimal_integer_literal)) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))) (break_statement))))) (for_statement init: (assignment_expression left: (identifier) right: (decimal_integer_literal)) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))) (break_statement))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (identifier)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation name: (identifier) arguments: (argument_list (identifier))) right: (method_invocation name: (identifier) arguments: (argument_list (identifier))))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (identifier) right: (string_literal)) right: (identifier)))))) alternative: (if_statement condition: (parenthesized_expression (method_invocation name: (identifier) arguments: (argument_list (identifier)))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))) alternative: (if_statement condition: (parenthesized_expression (method_invocation name: (identifier) arguments: (argument_list (identifier)))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))) alternative: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))))))))) |
public static void main ( String [ ] args ) {
SmallPrime smallprime = new SmallPrime ( ) ;
int arr [ ] = {
1 , 2 , 4 , 7 , 8 };
smallprime . findMinNum ( arr , 5 ) ;
}
| public static void main ( String [ ] args ) { SmallPrime smallprime = new SmallPrime ( ) ; int arr [ ] = { 1 , 2 , 4 , 7 , 8 } ; smallprime . findMinNum ( arr , 5 ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_initializer (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal)))))) |
static String check ( int [ ] Arr , int n , int M , int K ) {
int flag = 0 ;
for ( int i = 0 ;
i < n ;
i ++ ) {
if ( Arr [ i ] == 0 ) flag = 1 ;
}
if ( K % 2 != 0 && flag == 0 ) return "No" ;
else return "Yes" ;
}
| static String check ( int [ ] Arr , int n , int M , int K ) { int flag = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( Arr [ i ] == 0 ) flag = 1 ; } if ( K % 2 != 0 && flag == 0 ) return " No " ; else return " Yes " ; } | (method_declaration (modifiers) type: (type_identifier) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal)) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) consequence: (return_statement (string_literal)) alternative: (return_statement (string_literal))))) |
public static void main ( String args [ ] ) {
int [ ] Arr = {
1 , 1 , 2 , 4 , 7 , 8 };
int M = 5 ;
int K = 6 ;
int n = Arr . length ;
System . out . println ( check ( Arr , n , M , K ) ) ;
}
| public static void main ( String args [ ] ) { int [ ] Arr = { 1 , 1 , 2 , 4 , 7 , 8 } ; int M = 5 ; int K = 6 ; int n = Arr . length ; System . out . println ( check ( Arr , n , M , K ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier) dimensions: (dimensions))) body: (block (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_initializer (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier) (identifier)))))))) |
static void sieve ( ) {
spf [ 1 ] = 1 ;
for ( int i = 2 ;
i < MAXN ;
i ++ ) spf [ i ] = i ;
for ( int i = 4 ;
i < MAXN ;
i += 2 ) spf [ i ] = 2 ;
for ( int i = 3 ;
i * i < MAXN ;
i ++ ) {
if ( spf [ i ] == i ) {
for ( int j = i * i ;
j < MAXN ;
j += i ) if ( spf [ j ] == j ) spf [ j ] = i ;
}
}
}
| static void sieve ( ) { spf [ 1 ] = 1 ; for ( int i = 2 ; i < MAXN ; i ++ ) spf [ i ] = i ; for ( int i = 4 ; i < MAXN ; i += 2 ) spf [ i ] = 2 ; for ( int i = 3 ; i * i < MAXN ; i ++ ) { if ( spf [ i ] == i ) { for ( int j = i * i ; j < MAXN ; j += i ) if ( spf [ j ] == j ) spf [ j ] = i ; } } } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (assignment_expression left: (identifier) right: (decimal_integer_literal)) body: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))) consequence: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (identifier)))) condition: (binary_expression left: (identifier) right: (identifier)) update: (assignment_expression left: (identifier) right: (identifier)) body: (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))) consequence: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))))))))))) |
static Vector < Integer > getFactorization ( int x ) {
Vector < Integer > ret = new Vector < > ( ) ;
while ( x != 1 ) {
ret . add ( spf [ x ] ) ;
x = x / spf [ x ] ;
}
return ret ;
}
| static Vector < Integer > getFactorization ( int x ) { Vector < Integer > ret = new Vector < > ( ) ; while ( x != 1 ) { ret . add ( spf [ x ] ) ; x = x / spf [ x ] ; } return ret ; } | (method_declaration (modifiers) type: (generic_type (type_identifier) (type_arguments (type_identifier))) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier))))))) (return_statement (identifier)))) |
public static void main ( String args [ ] ) {
sieve ( ) ;
int x = 12246 ;
System . out . print ( "prime factorization for " + x + " : " ) ;
Vector < Integer > p = getFactorization ( x ) ;
for ( int i = 0 ;
i < p . size ( ) ;
i ++ ) System . out . print ( p . get ( i ) + " " ) ;
System . out . println ( ) ;
}
| public static void main ( String args [ ] ) { sieve ( ) ; int x = 12246 ; System . out . print ( " prime β factorization β for β " + x + " β : β " ) ; Vector < Integer > p = getFactorization ( x ) ; for ( int i = 0 ; i < p . size ( ) ; i ++ ) System . out . print ( p . get ( i ) + " β " ) ; System . out . println ( ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier) dimensions: (dimensions))) body: (block (expression_statement (method_invocation name: (identifier) arguments: (argument_list))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (string_literal) right: (identifier)) right: (string_literal))))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (string_literal)))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list))))) |
static int getIntesectionNode ( Node head1 , Node head2 ) {
Node current1 = head1 ;
Node current2 = head2 ;
if ( current1 == null || current2 == null ) return - 1 ;
while ( current1 != null && current2 != null && current1 != current2 ) {
current1 = current1 . next ;
current2 = current2 . next ;
if ( current1 == current2 ) return current1 . data ;
if ( current1 == null ) current1 = head2 ;
if ( current2 == null ) current2 = head1 ;
}
return current1 . data ;
}
| static int getIntesectionNode ( Node head1 , Node head2 ) { Node current1 = head1 ; Node current2 = head2 ; if ( current1 == null || current2 == null ) return - 1 ; while ( current1 != null && current2 != null && current1 != current2 ) { current1 = current1 . next ; current2 = current2 . next ; if ( current1 == current2 ) return current1 . data ; if ( current1 == null ) current1 = head2 ; if ( current2 == null ) current2 = head1 ; } return current1 . data ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier)) (formal_parameter type: (type_identifier) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (identifier))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (identifier))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (null_literal)) right: (binary_expression left: (identifier) right: (null_literal)))) consequence: (return_statement (unary_expression operand: (decimal_integer_literal)))) (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (null_literal)) right: (binary_expression left: (identifier) right: (null_literal))) right: (binary_expression left: (identifier) right: (identifier)))) body: (block (expression_statement (assignment_expression left: (identifier) right: (field_access object: (identifier) field: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (field_access object: (identifier) field: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (return_statement (field_access object: (identifier) field: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (null_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (null_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (identifier)))))) (return_statement (field_access object: (identifier) field: (identifier))))) |
public static void main ( String [ ] args ) {
Node newNode ;
Node head1 = new Node ( ) ;
head1 . data = 10 ;
Node head2 = new Node ( ) ;
head2 . data = 3 ;
newNode = new Node ( ) ;
newNode . data = 6 ;
head2 . next = newNode ;
newNode = new Node ( ) ;
newNode . data = 9 ;
head2 . next . next = newNode ;
newNode = new Node ( ) ;
newNode . data = 15 ;
head1 . next = newNode ;
head2 . next . next . next = newNode ;
newNode = new Node ( ) ;
newNode . data = 30 ;
head1 . next . next = newNode ;
head1 . next . next . next = null ;
System . out . print ( getIntesectionNode ( head1 , head2 ) ) ;
}
| public static void main ( String [ ] args ) { Node newNode ; Node head1 = new Node ( ) ; head1 . data = 10 ; Node head2 = new Node ( ) ; head2 . data = 3 ; newNode = new Node ( ) ; newNode . data = 6 ; head2 . next = newNode ; newNode = new Node ( ) ; newNode . data = 9 ; head2 . next . next = newNode ; newNode = new Node ( ) ; newNode . data = 15 ; head1 . next = newNode ; head2 . next . next . next = newNode ; newNode = new Node ( ) ; newNode . data = 30 ; head1 . next . next = newNode ; head1 . next . next . next = null ; System . out . print ( getIntesectionNode ( head1 , head2 ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal))) (expression_statement (assignment_expression left: (identifier) right: (object_creation_expression type: (type_identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal))) (expression_statement (assignment_expression left: (field_access object: (identifier) field: (identifier)) right: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (object_creation_expression type: (type_identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal))) (expression_statement (assignment_expression left: (field_access object: (field_access object: (identifier) field: (identifier)) field: (identifier)) right: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (object_creation_expression type: (type_identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal))) (expression_statement (assignment_expression left: (field_access object: (identifier) field: (identifier)) right: (identifier))) (expression_statement (assignment_expression left: (field_access object: (field_access object: (field_access object: (identifier) field: (identifier)) field: (identifier)) field: (identifier)) right: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (object_creation_expression type: (type_identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal))) (expression_statement (assignment_expression left: (field_access object: (field_access object: (identifier) field: (identifier)) field: (identifier)) right: (identifier))) (expression_statement (assignment_expression left: (field_access object: (field_access object: (field_access object: (identifier) field: (identifier)) field: (identifier)) field: (identifier)) right: (null_literal))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))))))) |
static void reverse ( String str , int x ) {
int n = ( str . length ( ) - x ) / 2 ;
for ( int i = 0 ;
i < n ;
i ++ ) System . out . print ( str . charAt ( i ) ) ;
for ( int i = n + x - 1 ;
i >= n ;
i -- ) System . out . print ( str . charAt ( i ) ) ;
for ( int i = n + x ;
i < str . length ( ) ;
i ++ ) System . out . print ( str . charAt ( i ) ) ;
}
| static void reverse ( String str , int x ) { int n = ( str . length ( ) - x ) / 2 ; for ( int i = 0 ; i < n ; i ++ ) System . out . print ( str . charAt ( i ) ) ; for ( int i = n + x - 1 ; i >= n ; i -- ) System . out . print ( str . charAt ( i ) ) ; for ( int i = n + x ; i < str . length ( ) ; i ++ ) System . out . print ( str . charAt ( i ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (identifier))) right: (decimal_integer_literal)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (identifier)))) condition: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))))))) |
public static void main ( String [ ] args ) {
String str = "geeksforgeeks" ;
int x = 3 ;
reverse ( str , x ) ;
}
| public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; int x = 3 ; reverse ( str , x ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (string_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))))) |
static int countDigits ( int a , int b ) {
int count = 0 ;
int p = Math . abs ( a * b ) ;
if ( p == 0 ) return 1 ;
while ( p > 0 ) {
count ++ ;
p = p / 10 ;
}
return count ;
}
| static int countDigits ( int a , int b ) { int count = 0 ; int p = Math . abs ( a * b ) ; if ( p == 0 ) return 1 ; while ( p > 0 ) { count ++ ; p = p / 10 ; } return count ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (return_statement (decimal_integer_literal))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) body: (block (expression_statement (update_expression (identifier))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (return_statement (identifier)))) |
public static void main ( String args [ ] ) {
int a = 33 ;
int b = - 24 ;
System . out . println ( "Number of digits = " + countDigits ( a , b ) ) ;
}
| public static void main ( String args [ ] ) { int a = 33 ; int b = - 24 ; System . out . println ( " Number β of β digits β = β " + countDigits ( a , b ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier) dimensions: (dimensions))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (unary_expression operand: (decimal_integer_literal)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (string_literal) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier))))))))) |
static boolean isPrime ( int n ) {
if ( n <= 1 ) return false ;
if ( n <= 3 ) return true ;
if ( n % 2 == 0 || n % 3 == 0 ) return false ;
for ( int i = 5 ;
i * i <= n ;
i = i + 6 ) {
if ( n % i == 0 || n % ( i + 2 ) == 0 ) {
return false ;
}
}
return true ;
}
| static boolean isPrime ( int n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return true ; if ( n % 2 == 0 || n % 3 == 0 ) return false ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) { if ( n % i == 0 || n % ( i + 2 ) == 0 ) { return false ; } } return true ; } | (method_declaration (modifiers) type: (boolean_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (return_statement (false))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (return_statement (true))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal)) right: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal)))) consequence: (return_statement (false))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)) update: (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal)) right: (binary_expression left: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (decimal_integer_literal)))) consequence: (block (return_statement (false)))))) (return_statement (true)))) |
public static void main ( String [ ] args ) {
int n = 17 ;
if ( isPrime ( n ) && ( n % 16 == 1 ) ) {
System . out . println ( "YES" ) ;
}
else {
System . out . println ( "NO" ) ;
}
}
| public static void main ( String [ ] args ) { int n = 17 ; if ( isPrime ( n ) && ( n % 16 == 1 ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation name: (identifier) arguments: (argument_list (identifier))) right: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal))))) alternative: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))))))) |
static int minOperations ( int x , int y , int p , int q ) {
if ( y % x != 0 ) return - 1 ;
int d = y / x ;
int a = 0 ;
while ( d % p == 0 ) {
d /= p ;
a ++ ;
}
int b = 0 ;
while ( d % q == 0 ) {
d /= q ;
b ++ ;
}
if ( d != 1 ) return - 1 ;
return ( a + b ) ;
}
| static int minOperations ( int x , int y , int p , int q ) { if ( y % x != 0 ) return - 1 ; int d = y / x ; int a = 0 ; while ( d % p == 0 ) { d /= p ; a ++ ; } int b = 0 ; while ( d % q == 0 ) { d /= q ; b ++ ; } if ( d != 1 ) return - 1 ; return ( a + b ) ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal))) consequence: (return_statement (unary_expression operand: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal))) body: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))) (expression_statement (update_expression (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal))) body: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))) (expression_statement (update_expression (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (return_statement (unary_expression operand: (decimal_integer_literal)))) (return_statement (parenthesized_expression (binary_expression left: (identifier) right: (identifier)))))) |
public static void main ( String [ ] args ) {
int x = 12 , y = 2592 , p = 2 , q = 3 ;
System . out . println ( minOperations ( x , y , p , q ) ) ;
}
| public static void main ( String [ ] args ) { int x = 12 , y = 2592 , p = 2 , q = 3 ; System . out . println ( minOperations ( x , y , p , q ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier) (identifier)))))))) |
public static void main ( String args [ ] ) {
int numRay [ ] = {
0 , 4 , 3 , 2 , 7 , 8 , 2 , 3 , 1 };
for ( int i = 0 ;
i < numRay . length ;
i ++ ) {
numRay [ numRay [ i ] % numRay . length ] = numRay [ numRay [ i ] % numRay . length ] + numRay . length ;
}
System . out . println ( "The repeating elements are : " ) ;
for ( int i = 0 ;
i < numRay . length ;
i ++ ) {
if ( numRay [ i ] >= numRay . length * 2 ) {
System . out . println ( i + " " ) ;
}
}
}
| public static void main ( String args [ ] ) { int numRay [ ] = { 0 , 4 , 3 , 2 , 7 , 8 , 2 , 3 , 1 } ; for ( int i = 0 ; i < numRay . length ; i ++ ) { numRay [ numRay [ i ] % numRay . length ] = numRay [ numRay [ i ] % numRay . length ] + numRay . length ; } System . out . println ( " The β repeating β elements β are β : β " ) ; for ( int i = 0 ; i < numRay . length ; i ++ ) { if ( numRay [ i ] >= numRay . length * 2 ) { System . out . println ( i + " β " ) ; } } } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier) dimensions: (dimensions))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_initializer (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (field_access object: (identifier) field: (identifier))) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (field_access object: (identifier) field: (identifier)))) right: (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (field_access object: (identifier) field: (identifier)))) right: (field_access object: (identifier) field: (identifier))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (field_access object: (identifier) field: (identifier))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal)))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (string_literal))))))))))) |
static boolean check ( int n ) {
int m = n ;
while ( n != 0 ) {
int r = n % 10 ;
if ( r > 0 ) if ( ( m % r ) != 0 ) return false ;
n /= 10 ;
}
return true ;
}
| static boolean check ( int n ) { int m = n ; while ( n != 0 ) { int r = n % 10 ; if ( r > 0 ) if ( ( m % r ) != 0 ) return false ; n /= 10 ; } return true ; } | (method_declaration (modifiers) type: (boolean_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (if_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal))) consequence: (return_statement (false)))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))))) (return_statement (true)))) |
static int count ( int l , int r ) {
int ans = 0 ;
for ( int i = l ;
i <= r ;
i ++ ) if ( check ( i ) ) ans += 1 ;
return ans ;
}
| static int count ( int l , int r ) { int ans = 0 ; for ( int i = l ; i <= r ; i ++ ) if ( check ( i ) ) ans += 1 ; return ans ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (if_statement condition: (parenthesized_expression (method_invocation name: (identifier) arguments: (argument_list (identifier)))) consequence: (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))))) (return_statement (identifier)))) |
public static void main ( String args [ ] ) {
int l = 10 , r = 20 ;
System . out . println ( count ( 10 , 20 ) ) ;
}
| public static void main ( String args [ ] ) { int l = 10 , r = 20 ; System . out . println ( count ( 10 , 20 ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier) dimensions: (dimensions))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal) (decimal_integer_literal)))))))) |
static int deleteFromStart ( int num , int n ) {
int d = ( int ) Math . log10 ( num ) + 1 ;
int rev_new_num = 0 ;
for ( int i = 0 ;
num != 0 ;
i ++ ) {
int digit = num % 10 ;
num = num / 10 ;
if ( i == ( d - n ) ) {
continue ;
}
else {
rev_new_num = ( rev_new_num * 10 ) + digit ;
}
}
int new_num = 0 ;
for ( int i = 0 ;
rev_new_num != 0 ;
i ++ ) {
new_num = ( new_num * 10 ) + ( rev_new_num % 10 ) ;
rev_new_num = rev_new_num / 10 ;
}
return new_num ;
}
| static int deleteFromStart ( int num , int n ) { int d = ( int ) Math . log10 ( num ) + 1 ; int rev_new_num = 0 ; for ( int i = 0 ; num != 0 ; i ++ ) { int digit = num % 10 ; num = num / 10 ; if ( i == ( d - n ) ) { continue ; } else { rev_new_num = ( rev_new_num * 10 ) + digit ; } } int new_num = 0 ; for ( int i = 0 ; rev_new_num != 0 ; i ++ ) { new_num = ( new_num * 10 ) + ( rev_new_num % 10 ) ; rev_new_num = rev_new_num / 10 ; } return new_num ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (cast_expression type: (integral_type) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) right: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))))) consequence: (block (continue_statement)) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (identifier)))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (return_statement (identifier)))) |
static int deleteFromEnd ( int num , int n ) {
int rev_new_num = 0 ;
for ( int i = 1 ;
num != 0 ;
i ++ ) {
int digit = num % 10 ;
num = num / 10 ;
if ( i == n ) {
continue ;
}
else {
rev_new_num = ( rev_new_num * 10 ) + digit ;
}
}
int new_num = 0 ;
for ( int i = 0 ;
rev_new_num != 0 ;
i ++ ) {
new_num = ( new_num * 10 ) + ( rev_new_num % 10 ) ;
rev_new_num = rev_new_num / 10 ;
}
return new_num ;
}
| static int deleteFromEnd ( int num , int n ) { int rev_new_num = 0 ; for ( int i = 1 ; num != 0 ; i ++ ) { int digit = num % 10 ; num = num / 10 ; if ( i == n ) { continue ; } else { rev_new_num = ( rev_new_num * 10 ) + digit ; } } int new_num = 0 ; for ( int i = 0 ; rev_new_num != 0 ; i ++ ) { new_num = ( new_num * 10 ) + ( rev_new_num % 10 ) ; rev_new_num = rev_new_num / 10 ; } return new_num ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (continue_statement)) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (identifier)))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (return_statement (identifier)))) |
public static void main ( String [ ] args ) {
int num = 1234 ;
System . out . println ( "Number: " + num ) ;
int n = 3 ;
System . out . println ( "Digit to be deleted: " + n ) ;
System . out . println ( "Number after " + n + " digit deleted from starting: " + deleteFromStart ( num , n ) ) ;
System . out . println ( "Number after " + n + " digit deleted from ending: " + deleteFromEnd ( num , n ) ) ;
}
| public static void main ( String [ ] args ) { int num = 1234 ; System . out . println ( " Number : β " + num ) ; int n = 3 ; System . out . println ( " Digit β to β be β deleted : β " + n ) ; System . out . println ( " Number β after β " + n + " β digit β deleted β from β starting : β " + deleteFromStart ( num , n ) ) ; System . out . println ( " Number β after β " + n + " β digit β deleted β from β ending : β " + deleteFromEnd ( num , n ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (string_literal) right: (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (string_literal) right: (identifier))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (binary_expression left: (string_literal) right: (identifier)) right: (string_literal)) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (binary_expression left: (string_literal) right: (identifier)) right: (string_literal)) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier))))))))) |
static void printMatrix ( int n , int m ) {
if ( n < 5 || m < 5 ) {
System . out . print ( - 1 ) ;
return ;
}
char [ ] s = "aeiou" . toCharArray ( ) ;
for ( int i = 0 ;
i < n ;
i ++ ) {
for ( int j = 0 ;
j < m ;
j ++ ) {
System . out . print ( s [ j % 5 ] + " " ) ;
}
System . out . println ( ) ;
char c = s [ 0 ] ;
for ( int k = 0 ;
k < 4 ;
k ++ ) {
s [ k ] = s [ k + 1 ] ;
}
s [ 4 ] = c ;
}
}
| static void printMatrix ( int n , int m ) { if ( n < 5 || m < 5 ) { System . out . print ( - 1 ) ; return ; } char [ ] s = " aeiou " . toCharArray ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { System . out . print ( s [ j % 5 ] + " β " ) ; } System . out . println ( ) ; char c = s [ 0 ] ; for ( int k = 0 ; k < 4 ; k ++ ) { s [ k ] = s [ k + 1 ] ; } s [ 4 ] = c ; } } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (unary_expression operand: (decimal_integer_literal))))) (return_statement))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (string_literal) name: (identifier) arguments: (argument_list)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (string_literal))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (array_access array: (identifier) index: (decimal_integer_literal)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (identifier))))))) |
public static void main ( String [ ] args ) {
int n = 5 , m = 5 ;
printMatrix ( n , m ) ;
}
| public static void main ( String [ ] args ) { int n = 5 , m = 5 ; printMatrix ( n , m ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))))) |
static int largestNum ( int a , int b ) {
return a * ( ( a / b ) > 0 ? 1 : 0 ) + b * ( ( b / a ) > 0 ? 1 : 0 ) ;
}
| static int largestNum ( int a , int b ) { return a * ( ( a / b ) > 0 ? 1 : 0 ) + b * ( ( b / a ) > 0 ? 1 : 0 ) ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (return_statement (binary_expression left: (binary_expression left: (identifier) right: (parenthesized_expression (ternary_expression condition: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal)) consequence: (decimal_integer_literal) alternative: (decimal_integer_literal)))) right: (binary_expression left: (identifier) right: (parenthesized_expression (ternary_expression condition: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal)) consequence: (decimal_integer_literal) alternative: (decimal_integer_literal)))))))) |
public static void main ( String [ ] args ) {
int a = 22 , b = 1231 ;
System . out . print ( largestNum ( a , b ) ) ;
}
| public static void main ( String [ ] args ) { int a = 22 , b = 1231 ; System . out . print ( largestNum ( a , b ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))))))) |
static int minimumMoves ( int n , int a [ ] , int s , int t ) {
int i , x ;
x = s ;
for ( i = 1 ;
i <= n ;
i ++ ) {
if ( x == t ) break ;
x = a [ x ] ;
}
if ( x == t ) return i - 1 ;
else return - 1 ;
}
| static int minimumMoves ( int n , int a [ ] , int s , int t ) { int i , x ; x = s ; for ( i = 1 ; i <= n ; i ++ ) { if ( x == t ) break ; x = a [ x ] ; } if ( x == t ) return i - 1 ; else return - 1 ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (identifier))) (for_statement init: (assignment_expression left: (identifier) right: (decimal_integer_literal)) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (break_statement)) (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (return_statement (binary_expression left: (identifier) right: (decimal_integer_literal))) alternative: (return_statement (unary_expression operand: (decimal_integer_literal)))))) |
public static void main ( String [ ] args ) {
int s = 2 , t = 1 , i ;
int a [ ] = {
- 1 , 2 , 3 , 4 , 1 };
int n = a . length ;
System . out . println ( minimumMoves ( n , a , s , t ) ) ;
}
| public static void main ( String [ ] args ) { int s = 2 , t = 1 , i ; int a [ ] = { - 1 , 2 , 3 , 4 , 1 } ; int n = a . length ; System . out . println ( minimumMoves ( n , a , s , t ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_initializer (unary_expression operand: (decimal_integer_literal)) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier) (identifier)))))))) |
static int highestPower ( String str , int len ) {
int ans = 0 ;
for ( int i = len - 1 ;
i >= 0 ;
i -- ) {
if ( str . charAt ( i ) == '0' ) ans ++ ;
else break ;
}
return ans ;
}
| static int highestPower ( String str , int len ) { int ans = 0 ; for ( int i = len - 1 ; i >= 0 ; i -- ) { if ( str . charAt ( i ) == '0' ) ans ++ ; else break ; } return ans ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))) consequence: (expression_statement (update_expression (identifier))) alternative: (break_statement)))) (return_statement (identifier)))) |
public static void main ( String [ ] args ) {
String str = "100100" ;
int len = str . length ( ) ;
System . out . println ( highestPower ( str , len ) ) ;
}
| public static void main ( String [ ] args ) { String str = "100100" ; int len = str . length ( ) ; System . out . println ( highestPower ( str , len ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (string_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))))))) |
static void segmentedSieve ( ) {
int n = 10000 ;
int nNew = ( n - 2 ) / 2 ;
boolean [ ] marked = new boolean [ nNew + 1 ] ;
for ( int i = 1 ;
i <= nNew ;
i ++ ) for ( int j = i ;
( i + j + 2 * i * j ) <= nNew ;
j ++ ) marked [ i + j + 2 * i * j ] = true ;
primes . add ( 2 ) ;
for ( int i = 1 ;
i <= nNew ;
i ++ ) if ( marked [ i ] == false ) primes . add ( 2 * i + 1 ) ;
}
| static void segmentedSieve ( ) { int n = 10000 ; int nNew = ( n - 2 ) / 2 ; boolean [ ] marked = new boolean [ nNew + 1 ] ; for ( int i = 1 ; i <= nNew ; i ++ ) for ( int j = i ; ( i + j + 2 * i * j ) <= nNew ; j ++ ) marked [ i + j + 2 * i * j ] = true ; primes . add ( 2 ) ; for ( int i = 1 ; i <= nNew ; i ++ ) if ( marked [ i ] == false ) primes . add ( 2 * i + 1 ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal)))) (local_variable_declaration type: (array_type element: (boolean_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (boolean_type) dimensions: (dimensions_expr (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (binary_expression left: (decimal_integer_literal) right: (identifier)) right: (identifier)))) right: (identifier)) update: (update_expression (identifier)) body: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (binary_expression left: (decimal_integer_literal) right: (identifier)) right: (identifier)))) right: (true))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (false))) consequence: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (decimal_integer_literal) right: (identifier)) right: (decimal_integer_literal))))))))) |
static int Nfactors ( int a , int b , int n ) {
segmentedSieve ( ) ;
int result = 0 ;
for ( int i = a ;
i <= b ;
i ++ ) {
int tmp = ( int ) Math . sqrt ( i ) , copy = i ;
int count = 0 ;
for ( int j = 0 ;
primes . get ( j ) <= tmp ;
j ++ ) {
if ( copy % primes . get ( j ) == 0 ) {
count ++ ;
while ( copy % primes . get ( j ) == 0 ) copy = copy / primes . get ( j ) ;
}
}
if ( copy != 1 ) count ++ ;
if ( count == n ) result ++ ;
}
return result ;
}
| static int Nfactors ( int a , int b , int n ) { segmentedSieve ( ) ; int result = 0 ; for ( int i = a ; i <= b ; i ++ ) { int tmp = ( int ) Math . sqrt ( i ) , copy = i ; int count = 0 ; for ( int j = 0 ; primes . get ( j ) <= tmp ; j ++ ) { if ( copy % primes . get ( j ) == 0 ) { count ++ ; while ( copy % primes . get ( j ) == 0 ) copy = copy / primes . get ( j ) ; } } if ( copy != 1 ) count ++ ; if ( count == n ) result ++ ; } return result ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (expression_statement (method_invocation name: (identifier) arguments: (argument_list))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (cast_expression type: (integral_type) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) declarator: (variable_declarator name: (identifier) value: (identifier))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) right: (decimal_integer_literal))) consequence: (block (expression_statement (update_expression (identifier))) (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) right: (decimal_integer_literal))) body: (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (expression_statement (update_expression (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (expression_statement (update_expression (identifier)))))) (return_statement (identifier)))) |
public static void main ( String [ ] args ) {
int a = 1 , b = 100 , n = 3 ;
System . out . println ( Nfactors ( a , b , n ) ) ;
}
| public static void main ( String [ ] args ) { int a = 1 , b = 100 , n = 3 ; System . out . println ( Nfactors ( a , b , n ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier)))))))) |
static int maxval ( int a [ ] , int n ) {
if ( n < 2 ) {
return - 99999 ;
}
int max = 0 ;
for ( int i = 0 ;
i < n ;
i ++ ) {
for ( int j = i + 1 ;
j < n ;
j ++ ) {
int x = ( a [ i ] + i ) * ( a [ j ] + j ) ;
if ( max < x ) {
max = x ;
}
}
}
return max ;
}
| static int maxval ( int a [ ] , int n ) { if ( n < 2 ) { return - 99999 ; } int max = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { int x = ( a [ i ] + i ) * ( a [ j ] + j ) ; if ( max < x ) { max = x ; } } } return max ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (return_statement (unary_expression operand: (decimal_integer_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))) right: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))))))))) (return_statement (identifier)))) |
public static void main ( String args [ ] ) {
int arr [ ] = {
4 , 5 , 3 , 1 , 10 };
int len = arr . length ;
System . out . println ( maxval ( arr , len ) ) ;
}
| public static void main ( String args [ ] ) { int arr [ ] = { 4 , 5 , 3 , 1 , 10 } ; int len = arr . length ; System . out . println ( maxval ( arr , len ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier) dimensions: (dimensions))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_initializer (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))))))) |
public static int nCr ( int n , int r ) {
int res = 1 ;
for ( int i = 1 ;
i <= r ;
i ++ ) {
res *= ( n - r + i ) ;
res /= i ;
}
return res ;
}
| public static int nCr ( int n , int r ) { int res = 1 ; for ( int i = 1 ; i <= r ; i ++ ) { res *= ( n - r + i ) ; res /= i ; } return res ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (identifier))))) (return_statement (identifier)))) |
public static int NoofSequences ( int N , int M ) {
HashMap < Integer , Integer > prime = new HashMap < > ( ) ;
for ( int i = 2 ;
i <= Math . sqrt ( M ) ;
i ++ ) {
while ( M % i == 0 ) {
if ( prime . get ( i ) == null ) prime . put ( i , 1 ) ;
else {
int x = prime . get ( i ) ;
prime . put ( i , ++ x ) ;
}
M /= i ;
}
}
if ( M > 1 ) {
if ( prime . get ( M ) != null ) {
int x = prime . get ( M ) ;
prime . put ( M , ++ x ) ;
}
else prime . put ( M , 1 ) ;
}
int ans = 1 ;
for ( HashMap . Entry < Integer , Integer > entry : prime . entrySet ( ) ) {
ans *= ( nCr ( N + entry . getValue ( ) - 1 , N - 1 ) ) ;
}
return ans ;
}
| public static int NoofSequences ( int N , int M ) { HashMap < Integer , Integer > prime = new HashMap < > ( ) ; for ( int i = 2 ; i <= Math . sqrt ( M ) ; i ++ ) { while ( M % i == 0 ) { if ( prime . get ( i ) == null ) prime . put ( i , 1 ) ; else { int x = prime . get ( i ) ; prime . put ( i , ++ x ) ; } M /= i ; } } if ( M > 1 ) { if ( prime . get ( M ) != null ) { int x = prime . get ( M ) ; prime . put ( M , ++ x ) ; } else prime . put ( M , 1 ) ; } int ans = 1 ; for ( HashMap . Entry < Integer , Integer > entry : prime . entrySet ( ) ) { ans *= ( nCr ( N + entry . getValue ( ) - 1 , N - 1 ) ) ; } return ans ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier) (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) update: (update_expression (identifier)) body: (block (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (null_literal))) consequence: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal)))) alternative: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (update_expression (identifier))))))) (expression_statement (assignment_expression left: (identifier) right: (identifier))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (null_literal))) consequence: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (update_expression (identifier)))))) alternative: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (enhanced_for_statement type: (generic_type (scoped_type_identifier (type_identifier) (type_identifier)) (type_arguments (type_identifier) (type_identifier))) name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) body: (block (expression_statement (assignment_expression left: (identifier) right: (parenthesized_expression (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) right: (decimal_integer_literal)) (binary_expression left: (identifier) right: (decimal_integer_literal))))))))) (return_statement (identifier)))) |
public static void main ( String [ ] args ) {
int N = 2 , M = 6 ;
System . out . println ( NoofSequences ( N , M ) ) ;
}
| public static void main ( String [ ] args ) { int N = 2 , M = 6 ; System . out . println ( NoofSequences ( N , M ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))))))) |
static void sieve_modified ( ) {
for ( int i = 2 ;
i < MAX ;
i += 2 ) {
for ( int j = i ;
j < MAX ;
j += i ) prefix [ j ] += i ;
}
for ( int i = 1 ;
i < MAX ;
i ++ ) prefix [ i ] += prefix [ i - 1 ] ;
}
| static void sieve_modified ( ) { for ( int i = 2 ; i < MAX ; i += 2 ) { for ( int j = i ; j < MAX ; j += i ) prefix [ j ] += i ; } for ( int i = 1 ; i < MAX ; i ++ ) prefix [ i ] += prefix [ i - 1 ] ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (assignment_expression left: (identifier) right: (decimal_integer_literal)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (identifier)) update: (assignment_expression left: (identifier) right: (identifier)) body: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier)))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))))))) |
static long sumEvenFactors ( int L , int R ) {
return ( prefix [ R ] - prefix [ L - 1 ] ) ;
}
| static long sumEvenFactors ( int L , int R ) { return ( prefix [ R ] - prefix [ L - 1 ] ) ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (return_statement (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))))))) |
public static void main ( String args [ ] ) {
sieve_modified ( ) ;
int l = 6 , r = 10 ;
System . out . print ( sumEvenFactors ( l , r ) ) ;
}
| public static void main ( String args [ ] ) { sieve_modified ( ) ; int l = 6 , r = 10 ; System . out . print ( sumEvenFactors ( l , r ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier) dimensions: (dimensions))) body: (block (expression_statement (method_invocation name: (identifier) arguments: (argument_list))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))))))) |
static boolean isPerfectSquare ( double x ) {
double sr = Math . sqrt ( x ) ;
return ( ( sr - Math . floor ( sr ) ) == 0 ) ;
}
| static boolean isPerfectSquare ( double x ) { double sr = Math . sqrt ( x ) ; return ( ( sr - Math . floor ( sr ) ) == 0 ) ; } | (method_declaration (modifiers) type: (boolean_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (floating_point_type) name: (identifier))) body: (block (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (return_statement (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) right: (decimal_integer_literal)))))) |
static boolean isSunnyNum ( int n ) {
if ( isPerfectSquare ( n + 1 ) ) return true ;
return false ;
}
| static boolean isSunnyNum ( int n ) { if ( isPerfectSquare ( n + 1 ) ) return true ; return false ; } | (method_declaration (modifiers) type: (boolean_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier))) body: (block (if_statement condition: (parenthesized_expression (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal))))) consequence: (return_statement (true))) (return_statement (false)))) |
Subsets and Splits