code
stringlengths 31
2.27k
| tokenized_code
stringlengths 30
1.69k
| sexp
stringlengths 115
9.43k
|
---|---|---|
public static void main ( String args [ ] ) {
int a [ ] = {
3 , 5 , 6 , 8 };
int n = a . length ;
int m = 5 ;
printCombinations ( a , n , m ) ;
}
| public static void main ( String args [ ] ) { int a [ ] = { 3 , 5 , 6 , 8 } ; int n = a . length ; int m = 5 ; printCombinations ( a , n , m ) ; } | (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)))) (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 maxOR ( int L , int R ) {
int maximum = Integer . MIN_VALUE ;
for ( int i = L ;
i < R ;
i ++ ) for ( int j = i + 1 ;
j <= R ;
j ++ ) maximum = Math . max ( maximum , ( i | j ) ) ;
return maximum ;
}
| static int maxOR ( int L , int R ) { int maximum = Integer . MIN_VALUE ; for ( int i = L ; i < R ; i ++ ) for ( int j = i + 1 ; j <= R ; j ++ ) maximum = Math . max ( maximum , ( i | j ) ) ; return maximum ; } | (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: (field_access object: (identifier) field: (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: (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: (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (parenthesized_expression (binary_expression left: (identifier) right: (identifier))))))))) (return_statement (identifier)))) |
public static void main ( String [ ] args ) {
int L = 4 , R = 5 ;
System . out . println ( maxOR ( L , R ) ) ;
}
| public static void main ( String [ ] args ) { int L = 4 , R = 5 ; System . out . println ( maxOR ( L , R ) ) ; } | (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 float circlearea ( float R ) {
if ( R < 0 ) return - 1 ;
float a = ( float ) ( ( 3.14 * R * R ) / 4 ) ;
return a ;
}
| static float circlearea ( float R ) { if ( R < 0 ) return - 1 ; float a = ( float ) ( ( 3.14 * R * R ) / 4 ) ; return a ; } | (method_declaration (modifiers) type: (floating_point_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (floating_point_type) name: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (return_statement (unary_expression operand: (decimal_integer_literal)))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (cast_expression type: (floating_point_type) value: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (binary_expression left: (decimal_floating_point_literal) right: (identifier)) right: (identifier))) right: (decimal_integer_literal)))))) (return_statement (identifier)))) |
public static void main ( String [ ] args ) {
float R = 2 ;
System . out . println ( circlearea ( R ) ) ;
}
| public static void main ( String [ ] args ) { float R = 2 ; System . out . println ( circlearea ( R ) ) ; } | (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: (floating_point_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 double findMean ( int a [ ] , int n ) {
int sum = 0 ;
for ( int i = 0 ;
i < n ;
i ++ ) sum += a [ i ] ;
return ( double ) sum / ( double ) n ;
}
| public static double findMean ( int a [ ] , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += a [ i ] ; return ( double ) sum / ( double ) n ; } | (method_declaration (modifiers) type: (floating_point_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))) (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: (array_access array: (identifier) index: (identifier))))) (return_statement (binary_expression left: (cast_expression type: (floating_point_type) value: (identifier)) right: (cast_expression type: (floating_point_type) value: (identifier)))))) |
public static double findMedian ( int a [ ] , int n ) {
Arrays . sort ( a ) ;
if ( n % 2 != 0 ) return ( double ) a [ n / 2 ] ;
return ( double ) ( a [ ( n - 1 ) / 2 ] + a [ n / 2 ] ) / 2.0 ;
}
| public static double findMedian ( int a [ ] , int n ) { Arrays . sort ( a ) ; if ( n % 2 != 0 ) return ( double ) a [ n / 2 ] ; return ( double ) ( a [ ( n - 1 ) / 2 ] + a [ n / 2 ] ) / 2.0 ; } | (method_declaration (modifiers) type: (floating_point_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (return_statement (cast_expression type: (floating_point_type) value: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (return_statement (binary_expression left: (cast_expression type: (floating_point_type) value: (parenthesized_expression (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: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) right: (decimal_floating_point_literal))))) |
public static void main ( String args [ ] ) {
int a [ ] = {
1 , 3 , 4 , 2 , 7 , 5 , 8 , 6 };
int n = a . length ;
System . out . println ( "Mean = " + findMean ( a , n ) ) ;
System . out . println ( "Median = " + findMedian ( a , n ) ) ;
}
| public static void main ( String args [ ] ) { int a [ ] = { 1 , 3 , 4 , 2 , 7 , 5 , 8 , 6 } ; int n = a . length ; System . out . println ( " Mean β = β " + findMean ( a , n ) ) ; System . out . println ( " Median β = β " + findMedian ( a , 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) 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)))) (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 (binary_expression left: (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: (string_literal) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier))))))))) |
static double squareRoot ( double n ) {
return Math . pow ( 2 , 0.5 * ( Math . log ( n ) / Math . log ( 2 ) ) ) ;
}
| static double squareRoot ( double n ) { return Math . pow ( 2 , 0.5 * ( Math . log ( n ) / Math . log ( 2 ) ) ) ; } | (method_declaration (modifiers) type: (floating_point_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (floating_point_type) name: (identifier))) body: (block (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (binary_expression left: (decimal_floating_point_literal) right: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal))))))))))) |
public static void main ( String [ ] args ) {
double n = 12 ;
System . out . println ( squareRoot ( n ) ) ;
}
| public static void main ( String [ ] args ) { double n = 12 ; System . out . println ( squareRoot ( 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: (floating_point_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 int __gcd ( int a , int b ) {
if ( a == 0 || b == 0 ) return 0 ;
if ( a == b ) return a ;
if ( a > b ) return __gcd ( a - b , b ) ;
return __gcd ( a , b - a ) ;
}
| static int __gcd ( int a , int b ) { if ( a == 0 || b == 0 ) return 0 ; if ( a == b ) return a ; if ( a > b ) return __gcd ( a - b , b ) ; return __gcd ( a , b - a ) ; } | (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 (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: (return_statement (decimal_integer_literal))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (return_statement (identifier))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (return_statement (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)) (identifier))))) (return_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (identifier))))))) |
static int lcm ( int a , int b ) {
return ( a * b ) / __gcd ( a , b ) ;
}
| static int lcm ( int a , int b ) { return ( a * b ) / __gcd ( 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))) body: (block (return_statement (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier))))))) |
static void printArray ( int a [ ] , int n ) {
System . out . print ( a [ 0 ] + " " ) ;
for ( int i = 0 ;
i < n - 1 ;
i ++ ) System . out . print ( lcm ( a [ i ] , a [ i + 1 ] ) + " " ) ;
System . out . print ( a [ n - 1 ] ) ;
}
| static void printArray ( int a [ ] , int n ) { System . out . print ( a [ 0 ] + " β " ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) System . out . print ( lcm ( a [ i ] , a [ i + 1 ] ) + " β " ) ; System . out . print ( a [ n - 1 ] ) ; } | (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 (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (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: (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 (binary_expression left: (method_invocation name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)) (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 (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))))))) |
public static void main ( String [ ] args ) {
int a [ ] = {
1 , 2 , 3 };
int n = a . length ;
printArray ( a , n ) ;
}
| public static void main ( String [ ] args ) { int a [ ] = { 1 , 2 , 3 } ; int n = a . length ; printArray ( 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)))) (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)))))) |
static void findMajority ( int arr [ ] , int n ) {
int len = 32 ;
int number = 0 ;
for ( int i = 0 ;
i < len ;
i ++ ) {
int count = 0 ;
for ( int j = 0 ;
j < n ;
j ++ ) {
if ( ( arr [ j ] & ( 1 << i ) ) != 0 ) count ++ ;
}
if ( count > ( n / 2 ) ) number += ( 1 << i ) ;
}
int count = 0 ;
for ( int i = 0 ;
i < n ;
i ++ ) if ( arr [ i ] == number ) count ++ ;
if ( count > ( n / 2 ) ) System . out . println ( number ) ;
else System . out . println ( "Majority Element Not Present" ) ;
}
| static void findMajority ( int arr [ ] , int n ) { int len = 32 ; int number = 0 ; for ( int i = 0 ; i < len ; i ++ ) { int count = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( ( arr [ j ] & ( 1 << i ) ) != 0 ) count ++ ; } if ( count > ( n / 2 ) ) number += ( 1 << i ) ; } int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] == number ) count ++ ; if ( count > ( n / 2 ) ) System . out . println ( number ) ; else System . out . println ( " Majority β Element β Not β Present " ) ; } | (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))) (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 (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: (array_access array: (identifier) index: (identifier)) right: (parenthesized_expression (binary_expression left: (decimal_integer_literal) right: (identifier))))) right: (decimal_integer_literal))) consequence: (expression_statement (update_expression (identifier)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))))) consequence: (expression_statement (assignment_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (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: (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 (update_expression (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (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 (identifier)))) 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 arr [ ] = {
3 , 3 , 4 , 2 , 4 , 4 , 2 , 4 , 4 };
int n = arr . length ;
findMajority ( arr , n ) ;
}
| public static void main ( String [ ] args ) { int arr [ ] = { 3 , 3 , 4 , 2 , 4 , 4 , 2 , 4 , 4 } ; int n = arr . length ; findMajority ( 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) (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 name: (identifier) arguments: (argument_list (identifier) (identifier)))))) |
static void findElements ( int arr [ ] , int n ) {
Arrays . sort ( arr ) ;
for ( int i = 0 ;
i < n - 2 ;
i ++ ) System . out . print ( arr [ i ] + " " ) ;
}
| static void findElements ( int arr [ ] , int n ) { Arrays . sort ( arr ) ; for ( int i = 0 ; i < n - 2 ; i ++ ) System . out . print ( arr [ 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 (expression_statement (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: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (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 (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (string_literal)))))))) |
public static void main ( String args [ ] ) {
int arr [ ] = {
2 , - 6 , 3 , 5 , 1 };
int n = arr . length ;
findElements ( arr , n ) ;
}
| public static void main ( String args [ ] ) { int arr [ ] = { 2 , - 6 , 3 , 5 , 1 } ; int n = arr . length ; findElements ( 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: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_initializer (decimal_integer_literal) (unary_expression operand: (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 name: (identifier) arguments: (argument_list (identifier) (identifier)))))) |
static void printArray ( int arr [ ] , int size ) {
for ( int i = 0 ;
i < size ;
i ++ ) {
System . out . printf ( "%d " , arr [ i ] ) ;
}
System . out . printf ( "\n" ) ;
return ;
}
| static void printArray ( int arr [ ] , int size ) { for ( int i = 0 ; i < size ; i ++ ) { System . out . printf ( " % d β " , arr [ i ] ) ; } System . out . printf ( " \n " ) ; return ; } | (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: (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) (array_access array: (identifier) index: (identifier))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) (return_statement))) |
static int getSuccessor ( int arr [ ] , int k , int n ) {
int p = k - 1 ;
while ( arr [ p ] == n ) {
p -- ;
if ( p < 0 ) {
break ;
}
}
if ( p < 0 ) {
return 0 ;
}
arr [ p ] = arr [ p ] + 1 ;
for ( int i = p + 1 ;
i < k ;
i ++ ) {
arr [ i ] = 1 ;
}
return 1 ;
}
| static int getSuccessor ( int arr [ ] , int k , int n ) { int p = k - 1 ; while ( arr [ p ] == n ) { p -- ; if ( p < 0 ) { break ; } } if ( p < 0 ) { return 0 ; } arr [ p ] = arr [ p ] + 1 ; for ( int i = p + 1 ; i < k ; i ++ ) { arr [ i ] = 1 ; } return 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)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (while_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))) body: (block (expression_statement (update_expression (identifier))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (break_statement))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (return_statement (decimal_integer_literal)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_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: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))))) (return_statement (decimal_integer_literal)))) |
static void printSequences ( int n , int k ) {
int [ ] arr = new int [ k ] ;
for ( int i = 0 ;
i < k ;
i ++ ) {
arr [ i ] = 1 ;
}
while ( true ) {
printArray ( arr , k ) ;
if ( getSuccessor ( arr , k , n ) == 0 ) {
break ;
}
}
}
| static void printSequences ( int n , int k ) { int [ ] arr = new int [ k ] ; for ( int i = 0 ; i < k ; i ++ ) { arr [ i ] = 1 ; } while ( true ) { printArray ( arr , k ) ; if ( getSuccessor ( arr , k , n ) == 0 ) { break ; } } } | (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 (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: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))))) (while_statement condition: (parenthesized_expression (true)) body: (block (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier))) right: (decimal_integer_literal))) consequence: (block (break_statement))))))) |
public static void main ( String [ ] args ) {
int n = 3 ;
int k = 2 ;
printSequences ( n , k ) ;
}
| public static void main ( String [ ] args ) { int n = 3 ; int k = 2 ; printSequences ( 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))) (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 countOperations ( int n ) {
int i = 2 ;
while ( ( i * i ) < n && ( n % i ) > 0 ) i += 1 ;
if ( ( i * i ) > n ) i = n ;
return ( 1 + ( n - i ) / 2 ) ;
}
| static int countOperations ( int n ) { int i = 2 ; while ( ( i * i ) < n && ( n % i ) > 0 ) i += 1 ; if ( ( i * i ) > n ) i = n ; return ( 1 + ( n - i ) / 2 ) ; } | (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: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (identifier)) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal)))) body: (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (identifier))) consequence: (expression_statement (assignment_expression left: (identifier) right: (identifier)))) (return_statement (parenthesized_expression (binary_expression left: (decimal_integer_literal) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal))))))) |
public static void main ( String [ ] args ) {
int n = 5 ;
System . out . println ( countOperations ( n ) ) ;
}
| public static void main ( String [ ] args ) { int n = 5 ; System . out . println ( countOperations ( 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 long fact ( long n ) {
if ( n == 1 ) return 1 ;
else return ( fact ( n - 1 ) * n ) % mod ;
}
| static long fact ( long n ) { if ( n == 1 ) return 1 ; else return ( fact ( n - 1 ) * n ) % mod ; } | (method_declaration (modifiers) type: (integral_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 (decimal_integer_literal)) alternative: (return_statement (binary_expression left: (parenthesized_expression (binary_expression left: (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (identifier))) right: (identifier)))))) |
static long countPairs ( int m , int n ) {
long ans = fact ( 2 * m + n - 1 ) / ( fact ( n - 1 ) * fact ( 2 * m ) ) ;
return ( ans % mod ) ;
}
| static long countPairs ( int m , int n ) { long ans = fact ( 2 * m + n - 1 ) / ( fact ( n - 1 ) * fact ( 2 * m ) ) ; return ( ans % mod ) ; } | (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: (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (binary_expression left: (decimal_integer_literal) right: (identifier)) right: (identifier)) right: (decimal_integer_literal)))) right: (parenthesized_expression (binary_expression left: (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (decimal_integer_literal) right: (identifier))))))))) (return_statement (parenthesized_expression (binary_expression left: (identifier) right: (identifier)))))) |
public static void main ( String [ ] args ) {
int n = 5 , m = 3 ;
System . out . println ( countPairs ( m , n ) ) ;
}
| public static void main ( String [ ] args ) { int n = 5 , m = 3 ; System . out . println ( countPairs ( m , 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))) (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 count ( int n ) {
if ( n < 4 ) return - 1 ;
int rem = n % 4 ;
if ( rem == 0 ) return n / 4 ;
if ( rem == 1 ) {
if ( n < 9 ) return - 1 ;
return ( n - 9 ) / 4 + 1 ;
}
if ( rem == 2 ) return ( n - 6 ) / 4 + 1 ;
if ( rem == 3 ) {
if ( n < 15 ) return - 1 ;
return ( n - 15 ) / 4 + 2 ;
}
return 0 ;
}
| static int count ( int n ) { if ( n < 4 ) return - 1 ; int rem = n % 4 ; if ( rem == 0 ) return n / 4 ; if ( rem == 1 ) { if ( n < 9 ) return - 1 ; return ( n - 9 ) / 4 + 1 ; } if ( rem == 2 ) return ( n - 6 ) / 4 + 1 ; if ( rem == 3 ) { if ( n < 15 ) return - 1 ; return ( n - 15 ) / 4 + 2 ; } return 0 ; } | (method_declaration (modifiers) type: (integral_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 (unary_expression operand: (decimal_integer_literal)))) (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: (return_statement (binary_expression left: (identifier) right: (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (return_statement (unary_expression operand: (decimal_integer_literal)))) (return_statement (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal)) right: (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (return_statement (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal)) right: (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (return_statement (unary_expression operand: (decimal_integer_literal)))) (return_statement (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal)) right: (decimal_integer_literal))))) (return_statement (decimal_integer_literal)))) |
public static void main ( String [ ] args ) {
int n = 90 ;
System . out . println ( count ( n ) ) ;
n = 143 ;
System . out . println ( count ( n ) ) ;
}
| public static void main ( String [ ] args ) { int n = 90 ; System . out . println ( count ( n ) ) ; n = 143 ; System . out . println ( count ( 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)))))) (expression_statement (assignment_expression left: (identifier) right: (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 int magicIndex ( int arr [ ] , int start , int end ) {
if ( start > end ) return - 1 ;
int midIndex = ( start + end ) / 2 ;
int midValue = arr [ midIndex ] ;
if ( midIndex == midValue ) return midIndex ;
int left = magicIndex ( arr , start , Math . min ( midValue , midIndex - 1 ) ) ;
if ( left >= 0 ) return left ;
return magicIndex ( arr , Math . max ( midValue , midIndex + 1 ) , end ) ;
}
| static int magicIndex ( int arr [ ] , int start , int end ) { if ( start > end ) return - 1 ; int midIndex = ( start + end ) / 2 ; int midValue = arr [ midIndex ] ; if ( midIndex == midValue ) return midIndex ; int left = magicIndex ( arr , start , Math . min ( midValue , midIndex - 1 ) ) ; if ( left >= 0 ) return left ; return magicIndex ( arr , Math . max ( midValue , midIndex + 1 ) , end ) ; } | (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 (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (return_statement (unary_expression operand: (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)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (array_access array: (identifier) index: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (return_statement (identifier))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (return_statement (identifier))) (return_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)))) (identifier)))))) |
public static void main ( String [ ] args ) {
int arr [ ] = {
- 10 , - 5 , 2 , 2 , 2 , 3 , 4 , 7 , 9 , 12 , 13 };
int n = arr . length ;
int index = magicIndex ( arr , 0 , n - 1 ) ;
if ( index == - 1 ) System . out . print ( "No Magic Index" ) ;
else System . out . print ( "Magic Index is : " + index ) ;
}
| public static void main ( String [ ] args ) { int arr [ ] = { - 10 , - 5 , 2 , 2 , 2 , 3 , 4 , 7 , 9 , 12 , 13 } ; int n = arr . length ; int index = magicIndex ( arr , 0 , n - 1 ) ; if ( index == - 1 ) System . out . print ( " No β Magic β Index " ) ; else System . out . print ( " Magic β Index β is β : β " + index ) ; } | (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) (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: (method_invocation name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal) (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (unary_expression operand: (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 (binary_expression left: (string_literal) right: (identifier)))))))) |
public static void main ( String [ ] args ) {
LinkedList list = new LinkedList ( ) ;
for ( int i = 20 ;
i > 0 ;
i -- ) {
list . push ( i ) ;
}
System . out . println ( "Given Linked List :" ) ;
list . printList ( head ) ;
head = list . kAltReverse ( head , 3 ) ;
System . out . println ( "" ) ;
System . out . println ( "Modified Linked List :" ) ;
list . printList ( head ) ;
}
| public static void main ( String [ ] args ) { LinkedList list = new LinkedList ( ) ; for ( int i = 20 ; i > 0 ; i -- ) { list . push ( i ) ; } System . out . println ( " Given β Linked β List β : " ) ; list . printList ( head ) ; head = list . kAltReverse ( head , 3 ) ; System . out . println ( " " ) ; System . out . println ( " Modified β Linked β List β : " ) ; list . printList ( head ) ; } | (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)))) (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 (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal))))) (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 (string_literal)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))) |
static void gouldSequence ( int n ) {
for ( int row_num = 1 ;
row_num <= n ;
row_num ++ ) {
int count = 1 ;
int c = 1 ;
for ( int i = 1 ;
i <= row_num ;
i ++ ) {
c = c * ( row_num - i ) / i ;
if ( c % 2 == 1 ) count ++ ;
}
System . out . print ( count + " " ) ;
}
}
| static void gouldSequence ( int n ) { for ( int row_num = 1 ; row_num <= n ; row_num ++ ) { int count = 1 ; int c = 1 ; for ( int i = 1 ; i <= row_num ; i ++ ) { c = c * ( row_num - i ) / i ; if ( c % 2 == 1 ) count ++ ; } System . out . print ( count + " β " ) ; } } | (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 (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: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (identifier)))) right: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (expression_statement (update_expression (identifier)))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (string_literal))))))))) |
public static void main ( String [ ] args ) {
int n = 16 ;
gouldSequence ( n ) ;
}
| public static void main ( String [ ] args ) { int n = 16 ; gouldSequence ( 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 name: (identifier) arguments: (argument_list (identifier)))))) |
public static int first ( int arr [ ] , int low , int high , int x , int n ) {
if ( high >= low ) {
int mid = low + ( high - low ) / 2 ;
if ( ( mid == 0 || x > arr [ mid - 1 ] ) && arr [ mid ] == x ) return mid ;
else if ( x > arr [ mid ] ) return first ( arr , ( mid + 1 ) , high , x , n ) ;
else return first ( arr , low , ( mid - 1 ) , x , n ) ;
}
return - 1 ;
}
| public static int first ( int arr [ ] , int low , int high , int x , int n ) { if ( high >= low ) { int mid = low + ( high - low ) / 2 ; if ( ( mid == 0 || x > arr [ mid - 1 ] ) && arr [ mid ] == x ) return mid ; else if ( x > arr [ mid ] ) return first ( arr , ( mid + 1 ) , high , x , n ) ; else return first ( arr , low , ( mid - 1 ) , x , n ) ; } return - 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)) (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: (identifier) right: (identifier))) consequence: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (binary_expression left: (identifier) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier)))) consequence: (return_statement (identifier)) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))) consequence: (return_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) (identifier) (identifier) (identifier)))) alternative: (return_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) (identifier) (identifier)))))))) (return_statement (unary_expression operand: (decimal_integer_literal))))) |
public static int last ( int arr [ ] , int low , int high , int x , int n ) {
if ( high >= low ) {
int mid = low + ( high - low ) / 2 ;
if ( ( mid == n - 1 || x < arr [ mid + 1 ] ) && arr [ mid ] == x ) return mid ;
else if ( x < arr [ mid ] ) return last ( arr , low , ( mid - 1 ) , x , n ) ;
else return last ( arr , ( mid + 1 ) , high , x , n ) ;
}
return - 1 ;
}
| public static int last ( int arr [ ] , int low , int high , int x , int n ) { if ( high >= low ) { int mid = low + ( high - low ) / 2 ; if ( ( mid == n - 1 || x < arr [ mid + 1 ] ) && arr [ mid ] == x ) return mid ; else if ( x < arr [ mid ] ) return last ( arr , low , ( mid - 1 ) , x , n ) ; else return last ( arr , ( mid + 1 ) , high , x , n ) ; } return - 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)) (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: (identifier) right: (identifier))) consequence: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (binary_expression left: (identifier) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier)))) consequence: (return_statement (identifier)) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))) consequence: (return_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) (identifier) (identifier)))) alternative: (return_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) (identifier) (identifier) (identifier)))))))) (return_statement (unary_expression operand: (decimal_integer_literal))))) |
public static void main ( String [ ] args ) {
int arr [ ] = {
1 , 2 , 2 , 2 , 2 , 3 , 4 , 7 , 8 , 8 };
int n = arr . length ;
int x = 8 ;
System . out . println ( "First Occurrence = " + first ( arr , 0 , n - 1 , x , n ) ) ;
System . out . println ( "Last Occurrence = " + last ( arr , 0 , n - 1 , x , n ) ) ;
}
| public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 2 , 2 , 2 , 3 , 4 , 7 , 8 , 8 } ; int n = arr . length ; int x = 8 ; System . out . println ( " First β Occurrence β = β " + first ( arr , 0 , n - 1 , x , n ) ) ; System . out . println ( " Last β Occurrence β = β " + last ( arr , 0 , n - 1 , x , 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) (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 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) (decimal_integer_literal) (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier) (identifier))))))) (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) (decimal_integer_literal) (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier) (identifier))))))))) |
static int assignValue ( int a , int b , int x ) {
int arr [ ] = {
a , b };
return ( arr [ x ] ) ;
}
| static int assignValue ( int a , int b , int x ) { int arr [ ] = { a , b } ; return ( arr [ 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: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_initializer (identifier) (identifier)))) (return_statement (parenthesized_expression (array_access array: (identifier) index: (identifier)))))) |
public static void main ( String [ ] args ) {
int y = assignValue ( 3 , 7 , 0 ) ;
System . out . println ( y ) ;
}
| public static void main ( String [ ] args ) { int y = assignValue ( 3 , 7 , 0 ) ; System . out . println ( y ) ; } | (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: (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 (identifier)))))) |
static int findNthEvenDigitNumber ( int n ) {
int count = 0 ;
for ( int i = 0 ;
;
i ++ ) {
int curr = i ;
boolean isCurrEvenDigit = true ;
while ( curr != 0 ) {
if ( curr % 10 == 1 || curr % 10 == 3 || curr % 10 == 5 || curr % 10 == 7 || curr % 10 == 9 ) isCurrEvenDigit = false ;
curr = curr / 10 ;
}
if ( isCurrEvenDigit == true ) count ++ ;
if ( count == n ) return i ;
}
}
| static int findNthEvenDigitNumber ( int n ) { int count = 0 ; for ( int i = 0 ; ; i ++ ) { int curr = i ; boolean isCurrEvenDigit = true ; while ( curr != 0 ) { if ( curr % 10 == 1 || curr % 10 == 3 || curr % 10 == 5 || curr % 10 == 7 || curr % 10 == 9 ) isCurrEvenDigit = false ; curr = curr / 10 ; } if ( isCurrEvenDigit == true ) count ++ ; if ( count == n ) return i ; } } | (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))) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (true))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (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))) right: (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))) right: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal)))) consequence: (expression_statement (assignment_expression left: (identifier) right: (false)))) (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: (true))) consequence: (expression_statement (update_expression (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (return_statement (identifier))))))) |
public static void main ( String [ ] args ) {
System . out . println ( findNthEvenDigitNumber ( 2 ) ) ;
System . out . println ( findNthEvenDigitNumber ( 10 ) ) ;
}
| public static void main ( String [ ] args ) { System . out . println ( findNthEvenDigitNumber ( 2 ) ) ; System . out . println ( findNthEvenDigitNumber ( 10 ) ) ; } | (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)))))) (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)))))))) |
static int power ( long x , long y , long p ) {
int res = 1 ;
x = x % p ;
while ( y > 0 ) {
long r = y & 1 ;
if ( r == 1 ) res = ( res * ( int ) x ) % ( int ) p ;
y = y >> 1 ;
x = ( x * x ) % p ;
}
return res ;
}
| static int power ( long x , long y , long p ) { int res = 1 ; x = x % p ; while ( y > 0 ) { long r = y & 1 ; if ( r == 1 ) res = ( res * ( int ) x ) % ( int ) p ; y = y >> 1 ; x = ( x * x ) % p ; } 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)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (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: (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (cast_expression type: (integral_type) value: (identifier)))) right: (cast_expression type: (integral_type) value: (identifier)))))) (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: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (identifier)))))) (return_statement (identifier)))) |
static int numberOfDigits ( int x ) {
int i = 0 ;
while ( x != 0 ) {
x /= 10 ;
i ++ ;
}
return i ;
}
| static int numberOfDigits ( int x ) { int i = 0 ; while ( x != 0 ) { x /= 10 ; i ++ ; } return i ; } | (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: (decimal_integer_literal))) body: (block (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (expression_statement (update_expression (identifier))))) (return_statement (identifier)))) |
static void LastTwoDigit ( int n ) {
System . out . print ( "Last " + 2 + " digits of " + 2 + "^" ) ;
System . out . print ( n + " = " ) ;
int temp = 1 ;
for ( int i = 1 ;
i <= 2 ;
i ++ ) temp *= 10 ;
temp = power ( 2 , n , temp ) ;
for ( int i = 0 ;
i < ( 2 - numberOfDigits ( temp ) ) ;
i ++ ) System . out . print ( 0 + " " ) ;
if ( temp != 0 ) System . out . println ( temp ) ;
}
| static void LastTwoDigit ( int n ) { System . out . print ( " Last β " + 2 + " β digits β of β " + 2 + " ^ " ) ; System . out . print ( n + " β = β " ) ; int temp = 1 ; for ( int i = 1 ; i <= 2 ; i ++ ) temp *= 10 ; temp = power ( 2 , n , temp ) ; for ( int i = 0 ; i < ( 2 - numberOfDigits ( temp ) ) ; i ++ ) System . out . print ( 0 + " β " ) ; if ( temp != 0 ) System . out . println ( temp ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (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: (binary_expression left: (binary_expression left: (string_literal) right: (decimal_integer_literal)) right: (string_literal)) right: (decimal_integer_literal)) right: (string_literal))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (string_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: (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier) (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: (parenthesized_expression (binary_expression left: (decimal_integer_literal) right: (method_invocation name: (identifier) arguments: (argument_list (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: (decimal_integer_literal) right: (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 (identifier))))))) |
public static void main ( String [ ] args ) {
int n = 72 ;
LastTwoDigit ( n ) ;
}
| public static void main ( String [ ] args ) { int n = 72 ; LastTwoDigit ( 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 name: (identifier) arguments: (argument_list (identifier)))))) |
static int rightmostNonZero ( int a [ ] , int n ) {
int c5 = 0 ;
for ( int i = 0 ;
i < n ;
i ++ ) {
while ( a [ i ] > 0 && a [ i ] % 5 == 0 ) {
a [ i ] /= 5 ;
c5 ++ ;
}
}
for ( int i = 0 ;
i < n ;
i ++ ) {
while ( c5 != 0 && a [ i ] > 0 && ( a [ i ] & 1 ) == 0 ) {
a [ i ] >>= 1 ;
c5 -- ;
}
}
int ans = 1 ;
for ( int i = 0 ;
i < n ;
i ++ ) {
ans = ( ans * a [ i ] % 10 ) % 10 ;
}
if ( c5 != 0 ) ans = ( ans * 5 ) % 10 ;
if ( ans != 0 ) return ans ;
return - 1 ;
}
| static int rightmostNonZero ( int a [ ] , int n ) { int c5 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { while ( a [ i ] > 0 && a [ i ] % 5 == 0 ) { a [ i ] /= 5 ; c5 ++ ; } } for ( int i = 0 ; i < n ; i ++ ) { while ( c5 != 0 && a [ i ] > 0 && ( a [ i ] & 1 ) == 0 ) { a [ i ] >>= 1 ; c5 -- ; } } int ans = 1 ; for ( int i = 0 ; i < n ; i ++ ) { ans = ( ans * a [ i ] % 10 ) % 10 ; } if ( c5 != 0 ) ans = ( ans * 5 ) % 10 ; if ( ans != 0 ) return ans ; return - 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))) (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 (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)) right: (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)) right: (decimal_integer_literal)))) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) (expression_statement (update_expression (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 (while_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: (decimal_integer_literal))) right: (binary_expression left: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) right: (decimal_integer_literal)))) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) (expression_statement (update_expression (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: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier))) right: (decimal_integer_literal))) right: (decimal_integer_literal)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (return_statement (identifier))) (return_statement (unary_expression operand: (decimal_integer_literal))))) |
public static void main ( String args [ ] ) {
int a [ ] = {
7 , 42 , 11 , 64 };
int n = a . length ;
System . out . println ( rightmostNonZero ( a , n ) ) ;
}
| public static void main ( String args [ ] ) { int a [ ] = { 7 , 42 , 11 , 64 } ; int n = a . length ; System . out . println ( rightmostNonZero ( a , 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) dimensions: (dimensions) value: (array_initializer (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 void main ( String [ ] args ) {
LinkedList list = new LinkedList ( ) ;
for ( int i = 20 ;
i > 0 ;
i -- ) {
list . push ( i ) ;
}
System . out . println ( "Given Linked List :" ) ;
list . printList ( head ) ;
head = list . kAltReverse ( head , 3 ) ;
System . out . println ( "" ) ;
System . out . println ( "Modified Linked List :" ) ;
list . printList ( head ) ;
}
| public static void main ( String [ ] args ) { LinkedList list = new LinkedList ( ) ; for ( int i = 20 ; i > 0 ; i -- ) { list . push ( i ) ; } System . out . println ( " Given β Linked β List β : " ) ; list . printList ( head ) ; head = list . kAltReverse ( head , 3 ) ; System . out . println ( " " ) ; System . out . println ( " Modified β Linked β List β : " ) ; list . printList ( head ) ; } | (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)))) (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 (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal))))) (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 (string_literal)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))) |
static int GCD ( int a , int b ) {
if ( b == 0 ) return a ;
return GCD ( b , a % b ) ;
}
| static int GCD ( int a , int b ) { if ( b == 0 ) return a ; return GCD ( b , 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))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (return_statement (identifier))) (return_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (identifier))))))) |
static int multiplicativeOrder ( int A , int N ) {
if ( GCD ( A , N ) != 1 ) return - 1 ;
int result = 1 ;
int K = 1 ;
while ( K < N ) {
result = ( result * A ) % N ;
if ( result == 1 ) return K ;
K ++ ;
}
return - 1 ;
}
| static int multiplicativeOrder ( int A , int N ) { if ( GCD ( A , N ) != 1 ) return - 1 ; int result = 1 ; int K = 1 ; while ( K < N ) { result = ( result * A ) % N ; if ( result == 1 ) return K ; K ++ ; } 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))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation name: (identifier) arguments: (argument_list (identifier) (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: (decimal_integer_literal))) (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: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (return_statement (identifier))) (expression_statement (update_expression (identifier))))) (return_statement (unary_expression operand: (decimal_integer_literal))))) |
public static void main ( String args [ ] ) {
int A = 4 , N = 7 ;
System . out . println ( multiplicativeOrder ( A , N ) ) ;
}
| public static void main ( String args [ ] ) { int A = 4 , N = 7 ; System . out . println ( multiplicativeOrder ( A , 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)) 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 long calculateSum ( int n ) {
long sum = 0 ;
sum = 1 << n ;
return ( sum - 1 ) ;
}
| static long calculateSum ( int n ) { long sum = 0 ; sum = 1 << n ; return ( sum - 1 ) ; } | (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))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (decimal_integer_literal) right: (identifier)))) (return_statement (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal)))))) |
public static void main ( String [ ] args ) {
int n = 10 ;
System . out . println ( "Sum of all elements:" + calculateSum ( n ) ) ;
}
| public static void main ( String [ ] args ) { int n = 10 ; System . out . println ( " Sum β of β all β elements : " + calculateSum ( 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: (method_invocation name: (identifier) arguments: (argument_list (identifier))))))))) |
static int selectRandom ( int x ) {
count ++ ;
if ( count == 1 ) res = x ;
else {
Random r = new Random ( ) ;
int i = r . nextInt ( count ) ;
if ( i == count - 1 ) res = x ;
}
return res ;
}
| static int selectRandom ( int x ) { count ++ ; if ( count == 1 ) res = x ; else { Random r = new Random ( ) ; int i = r . nextInt ( count ) ; if ( i == count - 1 ) res = x ; } return res ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier))) body: (block (expression_statement (update_expression (identifier))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (identifier))) alternative: (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) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) consequence: (expression_statement (assignment_expression left: (identifier) right: (identifier)))))) (return_statement (identifier)))) |
public static void main ( String [ ] args ) {
int stream [ ] = {
1 , 2 , 3 , 4 };
int n = stream . length ;
for ( int i = 0 ;
i < n ;
i ++ ) System . out . println ( "Random number from first " + ( i + 1 ) + " numbers is " + selectRandom ( stream [ i ] ) ) ;
}
| public static void main ( String [ ] args ) { int stream [ ] = { 1 , 2 , 3 , 4 } ; int n = stream . length ; for ( int i = 0 ; i < n ; i ++ ) System . out . println ( " Random β number β from β first β " + ( i + 1 ) + " β numbers β is β " + selectRandom ( stream [ 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_initializer (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)))) (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 (binary_expression left: (binary_expression left: (binary_expression left: (string_literal) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (string_literal)) right: (method_invocation name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier))))))))))) |
public static boolean areAllBitsSet ( long n ) {
if ( n == 0 ) return false ;
if ( ( ( n + 1 ) & n ) == 0 ) return true ;
return false ;
}
| public static boolean areAllBitsSet ( long n ) { if ( n == 0 ) return false ; if ( ( ( n + 1 ) & n ) == 0 ) 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 (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (return_statement (false))) (if_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (identifier))) right: (decimal_integer_literal))) consequence: (return_statement (true))) (return_statement (false)))) |
public static boolean isOnesComplementOfOther ( long a , long b ) {
return areAllBitsSet ( a ^ b ) ;
}
| public static boolean isOnesComplementOfOther ( long a , long b ) { return areAllBitsSet ( a ^ b ) ; } | (method_declaration (modifiers) type: (boolean_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (return_statement (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier))))))) |
public static void main ( String argc [ ] ) {
long a = 10 , b = 5 ;
if ( isOnesComplementOfOther ( a , b ) ) System . out . println ( "Yes" ) ;
else System . out . println ( "No" ) ;
}
| public static void main ( String argc [ ] ) { long a = 10 , b = 5 ; if ( isOnesComplementOfOther ( a , b ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } | (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))) (if_statement condition: (parenthesized_expression (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))) 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))))))) |
static void printDiagonalSums ( int [ ] [ ] mat , int n ) {
int principal = 0 , secondary = 0 ;
for ( int i = 0 ;
i < n ;
i ++ ) {
principal += mat [ i ] [ i ] ;
secondary += mat [ i ] [ n - i - 1 ] ;
}
System . out . println ( "Principal Diagonal:" + principal ) ;
System . out . println ( "Secondary Diagonal:" + secondary ) ;
}
| static void printDiagonalSums ( int [ ] [ ] mat , int n ) { int principal = 0 , secondary = 0 ; for ( int i = 0 ; i < n ; i ++ ) { principal += mat [ i ] [ i ] ; secondary += mat [ i ] [ n - i - 1 ] ; } System . out . println ( " Principal β Diagonal : " + principal ) ; System . out . println ( " Secondary β Diagonal : " + secondary ) ; } | (method_declaration (modifiers) type: (void_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) 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 (assignment_expression left: (identifier) right: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (array_access array: (array_access array: (identifier) index: (identifier)) index: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (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: (string_literal) right: (identifier))))))) |
static public void main ( String [ ] args ) {
int [ ] [ ] a = {
{
1 , 2 , 3 , 4 }, {
5 , 6 , 7 , 8 }, {
1 , 2 , 3 , 4 }, {
5 , 6 , 7 , 8 }
};
printDiagonalSums ( a , 4 ) ;
}
| static public void main ( String [ ] args ) { int [ ] [ ] a = { { 1 , 2 , 3 , 4 } , { 5 , 6 , 7 , 8 } , { 1 , 2 , 3 , 4 } , { 5 , 6 , 7 , 8 } } ; printDiagonalSums ( a , 4 ) ; } | (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 (array_initializer (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)) (array_initializer (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)) (array_initializer (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)) (array_initializer (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal))))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal)))))) |
static void check ( int n , int m ) {
if ( n == 2 || m == 2 || n % m == 0 ) {
System . out . println ( "Yes" ) ;
}
else {
System . out . println ( "No" ) ;
}
}
| static void check ( int n , int m ) { if ( n == 2 || m == 2 || n % m == 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)) (formal_parameter type: (integral_type) name: (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: (identifier) right: (decimal_integer_literal))) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) 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)))))))) |
public static void main ( String [ ] args ) {
int m = 3 , n = 9 ;
check ( n , m ) ;
}
| public static void main ( String [ ] args ) { int m = 3 , n = 9 ; check ( 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 boolean onlyFirstAndLastAreSet ( int n ) {
if ( n == 1 ) return true ;
if ( n == 2 ) return false ;
return ( ( ( n - 1 ) & ( n - 2 ) ) == 0 ) ;
}
| static boolean onlyFirstAndLastAreSet ( int n ) { if ( n == 1 ) return true ; if ( n == 2 ) return false ; return ( ( ( n - 1 ) & ( n - 2 ) ) == 0 ) ; } | (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 (true))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (return_statement (false))) (return_statement (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))))) right: (decimal_integer_literal)))))) |
public static void main ( String [ ] args ) {
int n = 9 ;
if ( onlyFirstAndLastAreSet ( n ) ) System . out . println ( "Yes" ) ;
else System . out . println ( "No" ) ;
}
| public static void main ( String [ ] args ) { int n = 9 ; if ( onlyFirstAndLastAreSet ( n ) ) 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 (method_invocation name: (identifier) arguments: (argument_list (identifier)))) 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 int removeZero ( int n ) {
int res = 0 ;
int d = 1 ;
while ( n > 0 ) {
if ( n % 10 != 0 ) {
res += ( n % 10 ) * d ;
d *= 10 ;
}
n /= 10 ;
}
return res ;
}
| public static int removeZero ( int n ) { int res = 0 ; int d = 1 ; while ( n > 0 ) { if ( n % 10 != 0 ) { res += ( n % 10 ) * d ; d *= 10 ; } n /= 10 ; } return res ; } | (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))) (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: (decimal_integer_literal))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))))) (return_statement (identifier)))) |
public static boolean isEqual ( int a , int b ) {
if ( removeZero ( a ) + removeZero ( b ) == removeZero ( a + b ) ) return true ;
return false ;
}
| public static boolean isEqual ( int a , int b ) { if ( removeZero ( a ) + removeZero ( b ) == removeZero ( a + b ) ) return true ; return false ; } | (method_declaration (modifiers) type: (boolean_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: (method_invocation name: (identifier) arguments: (argument_list (identifier))) right: (method_invocation name: (identifier) arguments: (argument_list (identifier)))) right: (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)))))) consequence: (return_statement (true))) (return_statement (false)))) |
public static void main ( String [ ] args ) {
int a = 105 , b = 106 ;
if ( isEqual ( a , b ) == true ) System . out . println ( "Yes" ) ;
else System . out . println ( "No" ) ;
}
| public static void main ( String [ ] args ) { int a = 105 , b = 106 ; if ( isEqual ( a , b ) == true ) 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)) 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) (identifier))) right: (true))) 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))))))) |
static int FindLCM ( int a , int b ) {
return ( a * b ) / new BigInteger ( a + "" ) . gcd ( new BigInteger ( b + "" ) ) . intValue ( ) ;
}
| static int FindLCM ( int a , int b ) { return ( a * b ) / new BigInteger ( a + " " ) . gcd ( new BigInteger ( b + " " ) ) . intValue ( ) ; } | (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: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (method_invocation object: (method_invocation object: (object_creation_expression type: (type_identifier) arguments: (argument_list (binary_expression left: (identifier) right: (string_literal)))) name: (identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (binary_expression left: (identifier) right: (string_literal)))))) name: (identifier) arguments: (argument_list)))))) |
static int rangeDivisor ( int m , int n , int a , int b ) {
int lcm = FindLCM ( a , b ) ;
int a_divisor = n / a - ( m - 1 ) / a ;
int b_divisor = n / b - ( m - 1 ) / b ;
int common_divisor = n / lcm - ( m - 1 ) / lcm ;
int ans = a_divisor + b_divisor - common_divisor ;
return ans ;
}
| static int rangeDivisor ( int m , int n , int a , int b ) { int lcm = FindLCM ( a , b ) ; int a_divisor = n / a - ( m - 1 ) / a ; int b_divisor = n / b - ( m - 1 ) / b ; int common_divisor = n / lcm - ( m - 1 ) / lcm ; int ans = a_divisor + b_divisor - common_divisor ; 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: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (binary_expression left: (identifier) right: (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: (binary_expression left: (binary_expression left: (identifier) right: (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: (binary_expression left: (binary_expression left: (identifier) right: (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: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)))) (return_statement (identifier)))) |
public static void main ( String args [ ] ) {
int m = 3 , n = 11 , a = 2 , b = 3 ;
System . out . println ( rangeDivisor ( m , n , a , b ) ) ;
m = 11 ;
n = 1000000 ;
a = 6 ;
b = 35 ;
System . out . println ( rangeDivisor ( m , n , a , b ) ) ;
}
| public static void main ( String args [ ] ) { int m = 3 , n = 11 , a = 2 , b = 3 ; System . out . println ( rangeDivisor ( m , n , a , b ) ) ; m = 11 ; n = 1000000 ; a = 6 ; b = 35 ; System . out . println ( rangeDivisor ( m , n , 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)) 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)))))) (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: (decimal_integer_literal))) (expression_statement (assignment_expression left: (identifier) right: (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 void solve ( long a , long b ) {
if ( a > 0 && b > 0 ) {
System . out . println ( "Positive" ) ;
}
else if ( a <= 0 && b >= 0 ) {
System . out . println ( "Zero" ) ;
}
else {
long n = Math . abs ( a - b ) + 1 ;
if ( n % 2 == 0 ) {
System . out . println ( "Positive" ) ;
}
else {
System . out . println ( "Negative" ) ;
}
}
}
| static void solve ( long a , long b ) { if ( a > 0 && b > 0 ) { System . out . println ( " Positive " ) ; } else if ( a <= 0 && b >= 0 ) { System . out . println ( " Zero " ) ; } else { long n = Math . abs ( a - b ) + 1 ; if ( n % 2 == 0 ) { System . out . println ( " Positive " ) ; } else { System . out . println ( " Negative " ) ; } } } | (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 (string_literal))))) alternative: (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 (string_literal))))) alternative: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)))) right: (decimal_integer_literal)))) (if_statement condition: (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))))))))))) |
public static void main ( String [ ] args ) {
int a = - 10 , b = - 2 ;
solve ( a , b ) ;
}
| public static void main ( String [ ] args ) { int a = - 10 , b = - 2 ; solve ( 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: (unary_expression operand: (decimal_integer_literal))) declarator: (variable_declarator name: (identifier) value: (unary_expression operand: (decimal_integer_literal)))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))))) |
static void sieve ( int n ) {
boolean [ ] prime = new boolean [ n + 1 ] ;
for ( int p = 2 ;
p * p <= n ;
p ++ ) {
if ( prime [ p ] == false ) {
for ( int i = p * 2 ;
i <= n ;
i += p ) prime [ i ] = true ;
}
}
for ( int p = 2 ;
p <= n ;
p ++ ) if ( prime [ p ] == false ) allPrimes . add ( p ) ;
}
| static void sieve ( int n ) { boolean [ ] prime = new boolean [ n + 1 ] ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == false ) { for ( int i = p * 2 ; i <= n ; i += p ) prime [ i ] = true ; } } for ( int p = 2 ; p <= n ; p ++ ) if ( prime [ p ] == false ) allPrimes . add ( p ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier))) body: (block (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: (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: (false))) consequence: (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: (assignment_expression left: (identifier) right: (identifier)) body: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (true)))))))) (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 (identifier)))))))) |
static int factorialDivisors ( int n ) {
sieve ( n ) ;
int result = 1 ;
for ( int i = 0 ;
i < allPrimes . size ( ) ;
i ++ ) {
int p = allPrimes . get ( i ) ;
int exp = 0 ;
while ( p <= n ) {
exp = exp + ( n / p ) ;
p = p * allPrimes . get ( i ) ;
}
result = result * ( ( int ) Math . pow ( allPrimes . get ( i ) , exp + 1 ) - 1 ) / ( allPrimes . get ( i ) - 1 ) ;
}
return result ;
}
| static int factorialDivisors ( int n ) { sieve ( n ) ; int result = 1 ; for ( int i = 0 ; i < allPrimes . size ( ) ; i ++ ) { int p = allPrimes . get ( i ) ; int exp = 0 ; while ( p <= n ) { exp = exp + ( n / p ) ; p = p * allPrimes . get ( i ) ; } result = result * ( ( int ) Math . pow ( allPrimes . get ( i ) , exp + 1 ) - 1 ) / ( allPrimes . get ( i ) - 1 ) ; } return result ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier))) body: (block (expression_statement (method_invocation name: (identifier) arguments: (argument_list (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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) 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 (identifier))))) (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: (parenthesized_expression (binary_expression left: (identifier) right: (identifier)))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (cast_expression type: (integral_type) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) (binary_expression left: (identifier) right: (decimal_integer_literal))))) right: (decimal_integer_literal)))) right: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (decimal_integer_literal)))))))) (return_statement (identifier)))) |
public static void main ( String [ ] args ) {
System . out . println ( factorialDivisors ( 4 ) ) ;
}
| public static void main ( String [ ] args ) { System . out . println ( factorialDivisors ( 4 ) ) ; } | (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)))))))) |
static void fibonacci ( ) {
fib [ 0 ] = 1 ;
fib [ 1 ] = 2 ;
for ( int i = 2 ;
i < 43 ;
i ++ ) fib [ i ] = fib [ i - 1 ] + fib [ i - 2 ] ;
}
| static void fibonacci ( ) { fib [ 0 ] = 1 ; fib [ 1 ] = 2 ; for ( int i = 2 ; i < 43 ; i ++ ) fib [ i ] = fib [ i - 1 ] + fib [ i - 2 ] ; } | (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))) (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: (decimal_integer_literal)) update: (update_expression (identifier)) body: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) 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))))))))) |
static int rec ( int x , int y , int last ) {
if ( y == 0 ) {
if ( x == 0 ) return 1 ;
return 0 ;
}
int sum = 0 ;
for ( int i = last ;
i >= 0 && fib [ i ] * y >= x ;
i -- ) {
if ( fib [ i ] > x ) continue ;
sum += rec ( x - fib [ i ] , y - 1 , i ) ;
}
return sum ;
}
| static int rec ( int x , int y , int last ) { if ( y == 0 ) { if ( x == 0 ) return 1 ; return 0 ; } int sum = 0 ; for ( int i = last ; i >= 0 && fib [ i ] * y >= x ; i -- ) { if ( fib [ i ] > x ) continue ; sum += rec ( x - fib [ i ] , y - 1 , i ) ; } return sum ; } | (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 (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (return_statement (decimal_integer_literal))) (return_statement (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: (identifier))) condition: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (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: (continue_statement)) (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier))) (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier))))))) (return_statement (identifier)))) |
public static void main ( String [ ] args ) {
fibonacci ( ) ;
int n = 13 , k = 3 ;
System . out . println ( "Possible ways are: " + rec ( n , k , 42 ) ) ;
}
| public static void main ( String [ ] args ) { fibonacci ( ) ; int n = 13 , k = 3 ; System . out . println ( " Possible β ways β are : β " + rec ( n , k , 42 ) ) ; } | (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 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 (binary_expression left: (string_literal) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (decimal_integer_literal))))))))) |
static boolean isVowel ( char ch ) {
if ( ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' ) return true ;
return false ;
}
| static boolean isVowel ( char ch ) { if ( ch == ' a ' || ch == ' e ' || ch == ' i ' || ch == ' o ' || ch == ' u ' ) 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 (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (character_literal)) right: (binary_expression left: (identifier) right: (character_literal))) right: (binary_expression left: (identifier) right: (character_literal))) right: (binary_expression left: (identifier) right: (character_literal))) right: (binary_expression left: (identifier) right: (character_literal)))) consequence: (return_statement (true))) (return_statement (false)))) |
static int lcs ( String X , String Y , int m , int n ) {
int L [ ] [ ] = new int [ m + 1 ] [ n + 1 ] ;
int i , j ;
for ( i = 0 ;
i <= m ;
i ++ ) {
for ( j = 0 ;
j <= n ;
j ++ ) {
if ( i == 0 || j == 0 ) L [ i ] [ j ] = 0 ;
else if ( ( X . charAt ( i - 1 ) == Y . charAt ( j - 1 ) ) && isVowel ( X . charAt ( i - 1 ) ) ) L [ i ] [ j ] = L [ i - 1 ] [ j - 1 ] + 1 ;
else L [ i ] [ j ] = Math . max ( L [ i - 1 ] [ j ] , L [ i ] [ j - 1 ] ) ;
}
}
return L [ m ] [ n ] ;
}
| static int lcs ( String X , String Y , int m , int n ) { int L [ ] [ ] = new int [ m + 1 ] [ n + 1 ] ; int i , j ; for ( i = 0 ; i <= m ; i ++ ) { for ( j = 0 ; j <= n ; j ++ ) { if ( i == 0 || j == 0 ) L [ i ] [ j ] = 0 ; else if ( ( X . charAt ( i - 1 ) == Y . charAt ( j - 1 ) ) && isVowel ( X . charAt ( i - 1 ) ) ) L [ i ] [ j ] = L [ i - 1 ] [ j - 1 ] + 1 ; else L [ i ] [ j ] = Math . max ( L [ i - 1 ] [ j ] , L [ i ] [ j - 1 ] ) ; } } return L [ m ] [ n ] ; } | (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)) (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) dimensions: (dimensions) 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)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (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 (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: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) consequence: (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (decimal_integer_literal))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (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 (binary_expression left: (identifier) right: (decimal_integer_literal)))))) right: (method_invocation name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))))))) consequence: (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (binary_expression left: (array_access array: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal)))) alternative: (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) index: (identifier)) (array_access array: (array_access array: (identifier) index: (identifier)) index: (binary_expression left: (identifier) right: (decimal_integer_literal))))))))))))) (return_statement (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier))))) |
public static void main ( String [ ] args ) {
String X = "aieef" ;
String Y = "klaief" ;
int m = X . length ( ) ;
int n = Y . length ( ) ;
System . out . println ( "Length of LCS = " + lcs ( X , Y , m , n ) ) ;
}
| public static void main ( String [ ] args ) { String X = " aieef " ; String Y = " klaief " ; int m = X . length ( ) ; int n = Y . length ( ) ; System . out . println ( " Length β of β LCS β = β " + lcs ( X , Y , m , 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: (string_literal))) (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)))) (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 (binary_expression left: (string_literal) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier) (identifier))))))))) |
static void palindrome ( int arr [ ] , int n ) {
int flag = 0 ;
for ( int i = 0 ;
i <= n / 2 && n != 0 ;
i ++ ) {
if ( arr [ i ] != arr [ n - i - 1 ] ) {
flag = 1 ;
break ;
}
}
if ( flag == 1 ) System . out . println ( "Not Palindrome" ) ;
else System . out . println ( "Palindrome" ) ;
}
| static void palindrome ( int arr [ ] , int n ) { int flag = 0 ; for ( int i = 0 ; i <= n / 2 && n != 0 ; i ++ ) { if ( arr [ i ] != arr [ n - i - 1 ] ) { flag = 1 ; break ; } } if ( flag == 1 ) System . out . println ( " Not β Palindrome " ) ; else System . out . println ( " Palindrome " ) ; } | (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))) (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: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (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: (array_access array: (identifier) index: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal))))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (break_statement))))) (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 (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 arr [ ] = {
1 , 2 , 3 , 2 , 1 };
int n = arr . length ;
palindrome ( arr , n ) ;
}
| public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 2 , 1 } ; int n = arr . length ; palindrome ( 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 name: (identifier) arguments: (argument_list (identifier) (identifier)))))) |
static int countSolutions ( int n , int val ) {
int total = 0 ;
if ( n == 1 && val >= 0 ) return 1 ;
for ( int i = 0 ;
i <= val ;
i ++ ) {
total += countSolutions ( n - 1 , val - i ) ;
}
return total ;
}
| static int countSolutions ( int n , int val ) { int total = 0 ; if ( n == 1 && val >= 0 ) return 1 ; for ( int i = 0 ; i <= val ; i ++ ) { total += countSolutions ( n - 1 , val - i ) ; } return total ; } | (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))) (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: (return_statement (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 name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (binary_expression left: (identifier) right: (identifier)))))))) (return_statement (identifier)))) |
public static void main ( String [ ] args ) {
int n = 5 ;
int val = 20 ;
System . out . print ( countSolutions ( n , val ) ) ;
}
| public static void main ( String [ ] args ) { int n = 5 ; int val = 20 ; System . out . print ( countSolutions ( n , val ) ) ; } | (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) 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 isPrime ( long n ) {
if ( n <= 1 ) return false ;
if ( n <= 3 ) return true ;
if ( n % 2 == 0 || n % 3 == 0 ) return false ;
for ( long i = 5 ;
i * i <= n ;
i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return false ;
return true ;
}
| static boolean isPrime ( long n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return true ; if ( n % 2 == 0 || n % 3 == 0 ) return false ; for ( long 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: (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: (return_statement (false)))) (return_statement (true)))) |
static boolean isDiffPrime ( long a , long b ) {
if ( isPrime ( a + b ) && a - b == 1 ) return true ;
else return false ;
}
| static boolean isDiffPrime ( long a , long b ) { if ( isPrime ( a + b ) && a - b == 1 ) return true ; else return false ; } | (method_declaration (modifiers) type: (boolean_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: (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)))) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal)))) consequence: (return_statement (true)) alternative: (return_statement (false))))) |
public static void main ( String [ ] args ) {
long a = 6 , b = 5 ;
if ( isDiffPrime ( a , b ) ) System . out . println ( "Yes" ) ;
else System . out . println ( "No" ) ;
}
| public static void main ( String [ ] args ) { long a = 6 , b = 5 ; if ( isDiffPrime ( a , b ) ) 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)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (if_statement condition: (parenthesized_expression (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))) 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))))))) |
static int CalculateDifference ( int arr [ ] , int n ) {
int max_val = Integer . MIN_VALUE ;
for ( int i = 0 ;
i < n ;
i ++ ) {
if ( arr [ i ] > max_val ) max_val = arr [ i ] ;
}
boolean [ ] prime = new boolean [ max_val + 1 ] ;
for ( int i = 0 ;
i <= max_val ;
i ++ ) prime [ i ] = true ;
prime [ 0 ] = false ;
prime [ 1 ] = false ;
for ( int p = 2 ;
p * p <= max_val ;
p ++ ) {
if ( prime [ p ] == true ) {
for ( int i = p * 2 ;
i <= max_val ;
i += p ) prime [ i ] = false ;
}
}
int S1 = 0 , S2 = 0 ;
for ( int i = 0 ;
i < n ;
i ++ ) {
if ( prime [ arr [ i ] ] ) {
S1 += arr [ i ] ;
}
else if ( arr [ i ] != 1 ) {
S2 += arr [ i ] ;
}
}
return Math . abs ( S2 - S1 ) ;
}
| static int CalculateDifference ( int arr [ ] , int n ) { int max_val = Integer . MIN_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > max_val ) max_val = arr [ i ] ; } boolean [ ] prime = new boolean [ max_val + 1 ] ; for ( int i = 0 ; i <= max_val ; i ++ ) prime [ i ] = true ; prime [ 0 ] = false ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= max_val ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i <= max_val ; i += p ) prime [ i ] = false ; } } int S1 = 0 , S2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( prime [ arr [ i ] ] ) { S1 += arr [ i ] ; } else if ( arr [ i ] != 1 ) { S2 += arr [ i ] ; } } return Math . abs ( S2 - S1 ) ; } | (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)))) (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: (identifier))) consequence: (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier))))))) (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: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (true)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (false))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (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: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (true))) consequence: (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: (assignment_expression left: (identifier) right: (identifier)) body: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (false)))))))) (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 (array_access array: (identifier) index: (array_access array: (identifier) index: (identifier)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier))))) alternative: (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: (array_access array: (identifier) index: (identifier))))))))) (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier))))))) |
public static void main ( String [ ] args ) {
int arr [ ] = {
1 , 3 , 5 , 10 , 15 , 7 };
int n = arr . length ;
System . out . println ( CalculateDifference ( arr , n ) ) ;
}
| public static void main ( String [ ] args ) { int arr [ ] = { 1 , 3 , 5 , 10 , 15 , 7 } ; int n = arr . length ; System . out . println ( CalculateDifference ( 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) (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 power ( int x , int y , int p ) {
int res = 1 ;
x = x % p ;
while ( y > 0 ) {
if ( ( y & 1 ) != 0 ) res = ( res * x ) % p ;
y = y >> 1 ;
x = ( x * x ) % p ;
}
return res ;
}
| static int power ( int x , int y , int p ) { int res = 1 ; x = x % p ; while ( y > 0 ) { if ( ( y & 1 ) != 0 ) res = ( res * x ) % p ; y = y >> 1 ; x = ( x * x ) % p ; } 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)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier)))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (identifier))))) (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: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (identifier)))))) (return_statement (identifier)))) |
static int NearestElement ( int A , int D , int P ) {
if ( A == 0 ) return 0 ;
else if ( D == 0 ) return - 1 ;
else {
int X = power ( D , P - 2 , P ) ;
return ( X * ( P - A ) ) % P ;
}
}
| static int NearestElement ( int A , int D , int P ) { if ( A == 0 ) return 0 ; else if ( D == 0 ) return - 1 ; else { int X = power ( D , P - 2 , P ) ; return ( X * ( P - A ) ) % P ; } } | (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 (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (return_statement (decimal_integer_literal)) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (return_statement (unary_expression operand: (decimal_integer_literal))) alternative: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier))))) (return_statement (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))))) right: (identifier)))))))) |
public static void main ( String args [ ] ) {
int A = 4 , D = 9 , P = 11 ;
A %= P ;
D %= P ;
System . out . println ( NearestElement ( A , D , P ) ) ;
}
| public static void main ( String args [ ] ) { int A = 4 , D = 9 , P = 11 ; A %= P ; D %= P ; System . out . println ( NearestElement ( A , D , P ) ) ; } | (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)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (assignment_expression left: (identifier) right: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (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 Preprocess ( ) {
arr [ 0 ] [ 0 ] = 1 ;
for ( int i = 1 ;
i <= 1000 ;
++ i ) {
arr [ i ] [ 0 ] = 1 ;
for ( int j = 1 ;
j < i ;
++ j ) {
arr [ i ] [ j ] = ( arr [ i - 1 ] [ j - 1 ] + arr [ i - 1 ] [ j ] ) % mod ;
}
arr [ i ] [ i ] = 1 ;
}
}
| static void Preprocess ( ) { arr [ 0 ] [ 0 ] = 1 ; for ( int i = 1 ; i <= 1000 ; ++ i ) { arr [ i ] [ 0 ] = 1 ; for ( int j = 1 ; j < i ; ++ j ) { arr [ i ] [ j ] = ( arr [ i - 1 ] [ j - 1 ] + arr [ i - 1 ] [ j ] ) % mod ; } arr [ i ] [ i ] = 1 ; } } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters) body: (block (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (decimal_integer_literal)) 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: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (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 (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (binary_expression left: (parenthesized_expression (binary_expression left: (array_access array: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (array_access array: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) index: (identifier)))) right: (identifier)))))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (decimal_integer_literal))))))) |
static long powmod ( long a , long n ) {
if ( n == 0 ) {
return 1 ;
}
long pt = powmod ( a , n / 2 ) ;
pt = ( pt * pt ) % mod ;
if ( n % 2 == 1 ) {
return ( pt * a ) % mod ;
}
else {
return pt ;
}
}
| static long powmod ( long a , long n ) { if ( n == 0 ) { return 1 ; } long pt = powmod ( a , n / 2 ) ; pt = ( pt * pt ) % mod ; if ( n % 2 == 1 ) { return ( pt * a ) % mod ; } else { return pt ; } } | (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 (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (return_statement (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (block (return_statement (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (identifier)))) alternative: (block (return_statement (identifier)))))) |
static long CountSubset ( int [ ] val , int n ) {
long ans = powmod ( 2 , n - 1 ) ;
Arrays . sort ( val ) ;
for ( int i = 0 ;
i < n ;
++ i ) {
int j = i + 1 ;
while ( j < n && val [ j ] == val [ i ] ) {
int r = n - 1 - j ;
int l = i ;
ans = ( ans + arr [ l + r ] [ l ] ) % mod ;
j ++ ;
}
}
return ans ;
}
| static long CountSubset ( int [ ] val , int n ) { long ans = powmod ( 2 , n - 1 ) ; Arrays . sort ( val ) ; for ( int i = 0 ; i < n ; ++ i ) { int j = i + 1 ; while ( j < n && val [ j ] == val [ i ] ) { int r = n - 1 - j ; int l = i ; ans = ( ans + arr [ l + r ] [ l ] ) % mod ; j ++ ; } } 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))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal) (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (expression_statement (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: (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: (identifier) right: (decimal_integer_literal)))) (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier))))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (array_access array: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (identifier))) index: (identifier)))) right: (identifier)))) (expression_statement (update_expression (identifier))))))) (return_statement (identifier)))) |
public static void main ( String [ ] args ) {
Preprocess ( ) ;
int val [ ] = {
2 , 3 , 2 };
int n = val . length ;
System . out . println ( CountSubset ( val , n ) ) ;
}
| public static void main ( String [ ] args ) { Preprocess ( ) ; int val [ ] = { 2 , 3 , 2 } ; int n = val . length ; System . out . println ( CountSubset ( val , 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 (expression_statement (method_invocation name: (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)))) (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 countStrings ( String s ) {
int sum = 1 ;
for ( int i = 0 ;
i < s . length ( ) ;
i ++ ) {
if ( i % 2 == 0 && s . charAt ( i ) == '$' ) sum *= 21 ;
else if ( s . charAt ( i ) == '$' ) sum *= 5 ;
}
return sum ;
}
| static int countStrings ( String s ) { int sum = 1 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i % 2 == 0 && s . charAt ( i ) == ' $ ' ) sum *= 21 ; else if ( s . charAt ( i ) == ' $ ' ) sum *= 5 ; } return sum ; } | (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: (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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) 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: (decimal_integer_literal)) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal)))) consequence: (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))))))) (return_statement (identifier)))) |
public static void main ( String args [ ] ) {
String str = "s$$e$" ;
System . out . println ( countStrings ( str ) ) ;
}
| public static void main ( String args [ ] ) { String str = " s $ $ e $ " ; System . out . println ( countStrings ( str ) ) ; } | (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) 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 boolean areKAnagrams ( String str1 , String str2 , int k ) {
int n = str1 . length ( ) ;
if ( str2 . length ( ) != n ) return false ;
int [ ] hash_str1 = new int [ MAX_CHAR ] ;
for ( int i = 0 ;
i < n ;
i ++ ) hash_str1 [ str1 . charAt ( i ) - 'a' ] ++ ;
int count = 0 ;
for ( int i = 0 ;
i < n ;
i ++ ) {
if ( hash_str1 [ str2 . charAt ( i ) - 'a' ] > 0 ) hash_str1 [ str2 . charAt ( i ) - 'a' ] -- ;
else count ++ ;
if ( count > k ) return false ;
}
return true ;
}
| static boolean areKAnagrams ( String str1 , String str2 , int k ) { int n = str1 . length ( ) ; if ( str2 . length ( ) != n ) return false ; int [ ] hash_str1 = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < n ; i ++ ) hash_str1 [ str1 . charAt ( i ) - ' a ' ] ++ ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( hash_str1 [ str2 . charAt ( i ) - ' a ' ] > 0 ) hash_str1 [ str2 . charAt ( i ) - ' a ' ] -- ; else count ++ ; if ( count > k ) return false ; } return true ; } | (method_declaration (modifiers) type: (boolean_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier)) (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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (identifier))) consequence: (return_statement (false))) (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 (update_expression (array_access array: (identifier) index: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_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: (array_access array: (identifier) index: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))) right: (decimal_integer_literal))) consequence: (expression_statement (update_expression (array_access array: (identifier) index: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))))) alternative: (expression_statement (update_expression (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (return_statement (false))))) (return_statement (true)))) |
Subsets and Splits