code
stringlengths 31
2.27k
| tokenized_code
stringlengths 30
1.69k
| sexp
stringlengths 115
9.43k
|
---|---|---|
public static void main ( String [ ] args ) {
Scanner sc = new Scanner ( System . in ) ;
int N = sc . nextInt ( ) ;
int M = sc . nextInt ( ) ;
TreeMap < Long , Integer > map = new TreeMap < > ( ) ;
for ( int i = 0 ;
i < N ;
i ++ ) {
long cost = sc . nextLong ( ) ;
int num = sc . nextInt ( ) ;
map . put ( cost , map . containsKey ( cost ) ? num + map . get ( cost ) : num ) ;
}
sc . close ( ) ;
long totalcost = 0 ;
int bought = 0 ;
for ( Map . Entry < Long , Integer > kv : map . entrySet ( ) ) {
long cost = kv . getKey ( ) ;
int maxnum = kv . getValue ( ) ;
int buycount = Math . min ( maxnum , M - bought ) ;
totalcost += buycount * cost ;
bought += buycount ;
if ( bought > M ) {
break ;
}
}
System . out . println ( totalcost ) ;
}
| public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; TreeMap < Long , Integer > map = new TreeMap < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { long cost = sc . nextLong ( ) ; int num = sc . nextInt ( ) ; map . put ( cost , map . containsKey ( cost ) ? num + map . get ( cost ) : num ) ; } sc . close ( ) ; long totalcost = 0 ; int bought = 0 ; for ( Map . Entry < Long , Integer > kv : map . entrySet ( ) ) { long cost = kv . getKey ( ) ; int maxnum = kv . getValue ( ) ; int buycount = Math . min ( maxnum , M - bought ) ; totalcost += buycount * cost ; bought += buycount ; if ( bought > M ) { break ; } } System . out . println ( totalcost ) ; } | (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 (field_access object: (identifier) field: (identifier)))))) (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)))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier) (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) 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)))) (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: (identifier) name: (identifier) arguments: (argument_list (identifier) (ternary_expression condition: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) consequence: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) alternative: (identifier))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) (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))) (enhanced_for_statement type: (generic_type (scoped_type_identifier (type_identifier) (type_identifier)) (type_arguments (type_identifier) (type_identifier))) name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) body: (block (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)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (identifier)))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (identifier))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (break_statement))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier)))))) |
public static void main ( String [ ] args ) {
Scanner sc = new Scanner ( System . in ) ;
int a = Integer . parseInt ( sc . next ( ) ) ;
int b = Integer . parseInt ( sc . next ( ) ) ;
int c = Integer . parseInt ( sc . next ( ) ) ;
if ( a * b <= c ) {
System . out . println ( a * b ) ;
}
else if ( c < a * b ) {
System . out . println ( c ) ;
}
}
| public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; int c = Integer . parseInt ( sc . next ( ) ) ; if ( a * b <= c ) { System . out . println ( a * b ) ; } else if ( c < a * b ) { System . out . println ( c ) ; } } | (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 (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (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 (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 (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)))))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier)))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))))))) |
public static void main ( String [ ] args ) throws Exception {
BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ;
StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ;
int n = Integer . parseInt ( tokenizer . nextToken ( ) ) ;
int a = Integer . parseInt ( tokenizer . nextToken ( ) ) ;
int b = Integer . parseInt ( tokenizer . nextToken ( ) ) ;
System . out . println ( n * a > b ? b : n * a ) ;
}
| public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; int n = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int a = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int b = Integer . parseInt ( tokenizer . nextToken ( ) ) ; System . out . println ( n * a > b ? b : n * a ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) (throws (type_identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (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 (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 (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 (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 (ternary_expression condition: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)) consequence: (identifier) alternative: (binary_expression left: (identifier) right: (identifier)))))))) |
public static void main ( String [ ] args ) {
new Main ( ) ;
}
| public static void main ( String [ ] args ) { new Main ( ) ; } | (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 (object_creation_expression type: (type_identifier) arguments: (argument_list))))) |
public static void main ( String [ ] args ) {
new Main ( ) . solveA ( ) ;
}
| public static void main ( String [ ] args ) { new Main ( ) . solveA ( ) ; } | (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: (object_creation_expression type: (type_identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list))))) |
public static void main ( String [ ] args ) throws Exception {
Scanner sc = new Scanner ( System . in ) ;
int N = sc . nextInt ( ) ;
int A = sc . nextInt ( ) ;
int B = sc . nextInt ( ) ;
System . out . println ( A * N < B ? A * N : B ) ;
}
| public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; System . out . println ( A * N < B ? A * N : B ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) (throws (type_identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (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)))) (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 (ternary_expression condition: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)) consequence: (binary_expression left: (identifier) right: (identifier)) alternative: (identifier))))))) |
public static void main ( String [ ] args ) {
int N = readInt ( ) ;
char [ ] [ ] charMatrix = new char [ N ] [ N ] ;
for ( int i = 0 ;
i < N ;
i ++ ) {
String tmpStr = sc . next ( ) ;
for ( int j = 0 ;
j < N ;
j ++ ) {
charMatrix [ i ] [ j ] = tmpStr . charAt ( j ) ;
}
}
long cnt = 0 ;
for ( int i = 0 ;
i < N ;
i ++ ) {
char [ ] [ ] shiftedMatrix = shiftCharMatrix ( charMatrix , 0 , i ) ;
if ( checkCharMatrixSymmetry ( shiftedMatrix ) ) {
cnt += N ;
}
}
System . out . println ( cnt ) ;
}
| public static void main ( String [ ] args ) { int N = readInt ( ) ; char [ ] [ ] charMatrix = new char [ N ] [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { String tmpStr = sc . next ( ) ; for ( int j = 0 ; j < N ; j ++ ) { charMatrix [ i ] [ j ] = tmpStr . charAt ( j ) ; } } long cnt = 0 ; for ( int i = 0 ; i < N ; i ++ ) { char [ ] [ ] shiftedMatrix = shiftCharMatrix ( charMatrix , 0 , i ) ; if ( checkCharMatrixSymmetry ( shiftedMatrix ) ) { cnt += N ; } } System . out . println ( cnt ) ; } | (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)))) (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)) 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 (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (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 (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 (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal) (identifier))))) (if_statement condition: (parenthesized_expression (method_invocation name: (identifier) arguments: (argument_list (identifier)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier)))))) |
private static char [ ] [ ] shiftCharMatrix ( char [ ] [ ] matrix , int H , int W ) {
int SIZE_H = matrix . length ;
int SIZE_W = matrix [ 0 ] . length ;
char [ ] [ ] shiftedMatrix = new char [ SIZE_H ] [ SIZE_W ] ;
for ( int h = 0 ;
h < SIZE_H ;
h ++ ) {
for ( int w = 0 ;
w < SIZE_W ;
w ++ ) {
int next_h = ( h + H ) % SIZE_H ;
int next_w = ( w + W ) % SIZE_W ;
shiftedMatrix [ next_h ] [ next_w ] = matrix [ h ] [ w ] ;
}
}
return shiftedMatrix ;
}
| private static char [ ] [ ] shiftCharMatrix ( char [ ] [ ] matrix , int H , int W ) { int SIZE_H = matrix . length ; int SIZE_W = matrix [ 0 ] . length ; char [ ] [ ] shiftedMatrix = new char [ SIZE_H ] [ SIZE_W ] ; for ( int h = 0 ; h < SIZE_H ; h ++ ) { for ( int w = 0 ; w < SIZE_W ; w ++ ) { int next_h = ( h + H ) % SIZE_H ; int next_w = ( w + W ) % SIZE_W ; shiftedMatrix [ next_h ] [ next_w ] = matrix [ h ] [ w ] ; } } return shiftedMatrix ; } | (method_declaration (modifiers) type: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (array_access array: (identifier) index: (decimal_integer_literal)) field: (identifier)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier)) 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 (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: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (identifier)))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)))))))) (return_statement (identifier)))) |
private static boolean checkCharMatrixSymmetry ( char [ ] [ ] matrix ) {
int N = matrix . length ;
for ( int i = 0 ;
i < N ;
i ++ ) {
for ( int j = i ;
j < N ;
j ++ ) {
if ( matrix [ i ] [ j ] != matrix [ j ] [ i ] ) {
return false ;
}
}
}
return true ;
}
| private static boolean checkCharMatrixSymmetry ( char [ ] [ ] matrix ) { int N = matrix . length ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i ; j < N ; j ++ ) { if ( matrix [ i ] [ j ] != matrix [ j ] [ i ] ) { return false ; } } } return true ; } | (method_declaration (modifiers) type: (boolean_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (integral_type) dimensions: (dimensions)) 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 (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)))) consequence: (block (return_statement (false)))))))) (return_statement (true)))) |
private static char readChar ( ) {
return sc . next ( ) . charAt ( 0 ) ;
}
| private static char readChar ( ) { return sc . next ( ) . charAt ( 0 ) ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters) body: (block (return_statement (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list (decimal_integer_literal)))))) |
private static int readInt ( ) {
return Integer . parseInt ( sc . next ( ) ) ;
}
| private static int readInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters) body: (block (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))))) |
private static long readLong ( ) {
return Long . parseLong ( sc . next ( ) ) ;
}
| private static long readLong ( ) { return Long . parseLong ( sc . next ( ) ) ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters) body: (block (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))))) |
public static void main ( String [ ] args ) {
InputStream inputStream = System . in ;
OutputStream outputStream = System . out ;
InputReader in = new InputReader ( inputStream ) ;
PrintWriter out = new PrintWriter ( outputStream ) ;
TaskB solver = new TaskB ( ) ;
solver . solve ( 1 , in , out ) ;
out . close ( ) ;
}
| public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskB solver = new TaskB ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } | (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: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier) (identifier)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) |
public static void main ( String args [ ] ) throws Exception {
Scanner sc = new Scanner ( System . in ) ;
int N = sc . nextInt ( ) ;
int ansbase = 0 ;
String [ ] S = new String [ N ] ;
char [ ] [ ] s = new char [ N ] [ N ] ;
for ( int i = 0 ;
i < N ;
i ++ ) {
S [ i ] = sc . next ( ) ;
for ( int j = 0 ;
j < N ;
j ++ ) {
s [ i ] [ j ] = S [ i ] . charAt ( j ) ;
}
}
for ( int i = 0 ;
i < N ;
i ++ ) {
Boolean OK = true ;
for ( int j = 0 ;
j < N ;
j ++ ) {
for ( int k = 0 ;
k < N ;
k ++ ) {
if ( s [ ( i + j ) % N ] [ k ] != s [ ( i + k ) % N ] [ j ] ) {
OK = false ;
}
}
}
if ( OK ) {
ansbase ++ ;
}
}
System . out . println ( ansbase * N ) ;
}
| public static void main ( String args [ ] ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int ansbase = 0 ; String [ ] S = new String [ N ] ; char [ ] [ ] s = new char [ N ] [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { S [ i ] = sc . next ( ) ; for ( int j = 0 ; j < N ; j ++ ) { s [ i ] [ j ] = S [ i ] . charAt ( j ) ; } } for ( int i = 0 ; i < N ; i ++ ) { Boolean OK = true ; for ( int j = 0 ; j < N ; j ++ ) { for ( int k = 0 ; k < N ; k ++ ) { if ( s [ ( i + j ) % N ] [ k ] != s [ ( i + k ) % N ] [ j ] ) { OK = false ; } } } if ( OK ) { ansbase ++ ; } } System . out . println ( ansbase * N ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier) dimensions: (dimensions))) (throws (type_identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (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: (decimal_integer_literal))) (local_variable_declaration type: (array_type element: (type_identifier) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (type_identifier) dimensions: (dimensions_expr (identifier))))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier)) 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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (method_invocation object: (array_access array: (identifier) index: (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: (type_identifier) declarator: (variable_declarator name: (identifier) value: (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: (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 (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (array_access array: (identifier) index: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (identifier))) index: (identifier)) right: (array_access array: (array_access array: (identifier) index: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (identifier))) index: (identifier)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (false))))))))) (if_statement condition: (parenthesized_expression (identifier)) consequence: (block (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: (identifier))))))) |
public static void main ( String args [ ] ) {
new Main ( ) . run ( ) ;
}
| public static void main ( String args [ ] ) { new Main ( ) . run ( ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier) dimensions: (dimensions))) body: (block (expression_statement (method_invocation object: (object_creation_expression type: (type_identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list))))) |
public static void main ( String args [ ] ) {
Scanner sc = new Scanner ( System . in ) ;
int n = sc . nextInt ( ) ;
String [ ] [ ] str = new String [ n ] [ n ] ;
for ( int i = 0 ;
i < n ;
i ++ ) {
String tmpStr = sc . next ( ) ;
for ( int j = 0 ;
j < n ;
j ++ ) {
str [ i ] [ j ] = String . valueOf ( tmpStr . charAt ( j ) ) ;
}
}
int count = 0 ;
String [ ] [ ] secondStr = new String [ n ] [ n ] ;
for ( int A = 0 ;
A < n ;
A ++ ) {
for ( int i = 0 ;
i < n ;
i ++ ) {
for ( int j = 0 ;
j < n ;
j ++ ) {
secondStr [ i ] [ j ] = str [ ( i + A ) % n ] [ j ] ;
}
}
boolean ans = true ;
for ( int i = 0 ;
i < n ;
i ++ ) {
for ( int j = 0 ;
j < n ;
j ++ ) {
if ( ! ( secondStr [ i ] [ j ] . equals ( secondStr [ j ] [ i ] ) ) ) {
ans = false ;
}
}
}
if ( ans == true ) count += n ;
}
System . out . println ( count ) ;
}
| public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String [ ] [ ] str = new String [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { String tmpStr = sc . next ( ) ; for ( int j = 0 ; j < n ; j ++ ) { str [ i ] [ j ] = String . valueOf ( tmpStr . charAt ( j ) ) ; } } int count = 0 ; String [ ] [ ] secondStr = new String [ n ] [ n ] ; for ( int A = 0 ; A < n ; A ++ ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { secondStr [ i ] [ j ] = str [ ( i + A ) % n ] [ j ] ; } } boolean ans = true ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( ! ( secondStr [ i ] [ j ] . equals ( secondStr [ j ] [ i ] ) ) ) { ans = false ; } } } if ( ans == true ) count += n ; } System . out . println ( count ) ; } | (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: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (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: (array_type element: (type_identifier) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (type_identifier) dimensions: (dimensions_expr (identifier)) 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 (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (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 (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))) (local_variable_declaration type: (array_type element: (type_identifier) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (type_identifier) dimensions: (dimensions_expr (identifier)) 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 (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (array_access array: (array_access array: (identifier) index: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (identifier))) index: (identifier)))))))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (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: (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 (if_statement condition: (parenthesized_expression (unary_expression operand: (parenthesized_expression (method_invocation object: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) name: (identifier) arguments: (argument_list (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier))))))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (false))))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (true))) consequence: (expression_statement (assignment_expression left: (identifier) right: (identifier)))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier)))))) |
public static void main ( String [ ] $ ) {
Scanner sc = new Scanner ( in ) ;
String s = sc . next ( ) ;
int l = 0 , r = 1 ;
int n = s . length ( ) ;
int ans = 0 ;
while ( r < n && l < n - 1 ) {
if ( l == r ) r ++ ;
if ( s . charAt ( l ) == 'S' ) {
if ( s . charAt ( r ) == 'T' ) {
ans ++ ;
r ++ ;
l ++ ;
}
else {
r ++ ;
}
}
else {
l ++ ;
}
}
out . println ( n - ans * 2 ) ;
}
| public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; String s = sc . next ( ) ; int l = 0 , r = 1 ; int n = s . length ( ) ; int ans = 0 ; while ( r < n && l < n - 1 ) { if ( l == r ) r ++ ; if ( s . charAt ( l ) == ' S ' ) { if ( s . charAt ( r ) == ' T ' ) { ans ++ ; r ++ ; l ++ ; } else { r ++ ; } } else { l ++ ; } } out . println ( n - ans * 2 ) ; } | (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 (identifier))))) (local_variable_declaration type: (type_identifier) 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: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (expression_statement (update_expression (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))) consequence: (block (expression_statement (update_expression (identifier))) (expression_statement (update_expression (identifier))) (expression_statement (update_expression (identifier)))) alternative: (block (expression_statement (update_expression (identifier)))))) alternative: (block (expression_statement (update_expression (identifier))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))))))) |
public static void main ( String [ ] args ) {
InputStream inputStream = System . in ;
OutputStream outputStream = System . out ;
LightScanner in = new LightScanner ( inputStream ) ;
PrintWriter out = new PrintWriter ( outputStream ) ;
ASTring solver = new ASTring ( ) ;
solver . solve ( 1 , in , out ) ;
out . close ( ) ;
}
| public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; LightScanner in = new LightScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; ASTring solver = new ASTring ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } | (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: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier) (identifier)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) |
static int nextInt ( ) {
return Integer . parseInt ( sc . next ( ) ) ;
}
| static int nextInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters) body: (block (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))))) |
static long nextLong ( ) {
return Long . parseLong ( sc . next ( ) ) ;
}
| static long nextLong ( ) { return Long . parseLong ( sc . next ( ) ) ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters) body: (block (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))))) |
static int [ ] nextIntArray ( int n ) {
return IntStream . range ( 0 , n ) . map ( i -> nextInt ( ) ) . toArray ( ) ;
}
| static int [ ] nextIntArray ( int n ) { return IntStream . range ( 0 , n ) . map ( i -> nextInt ( ) ) . toArray ( ) ; } | (method_declaration (modifiers) type: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier))) body: (block (return_statement (method_invocation object: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier))) name: (identifier) arguments: (argument_list (lambda_expression parameters: (identifier) body: (method_invocation name: (identifier) arguments: (argument_list))))) name: (identifier) arguments: (argument_list))))) |
static int max ( int ... ar ) {
Arrays . sort ( ar ) ;
return ar [ ar . length - 1 ] ;
}
| static int max ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ ar . length - 1 ] ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (spread_parameter (integral_type) (variable_declarator name: (identifier)))) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (return_statement (array_access array: (identifier) index: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal)))))) |
static int min ( int ... ar ) {
Arrays . sort ( ar ) ;
return ar [ 0 ] ;
}
| static int min ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ 0 ] ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (spread_parameter (integral_type) (variable_declarator name: (identifier)))) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (return_statement (array_access array: (identifier) index: (decimal_integer_literal))))) |
static String yesno ( boolean b ) {
return b ? "Yes" : "No" ;
}
| static String yesno ( boolean b ) { return b ? " Yes " : " No " ; } | (method_declaration (modifiers) type: (type_identifier) name: (identifier) parameters: (formal_parameters (formal_parameter type: (boolean_type) name: (identifier))) body: (block (return_statement (ternary_expression condition: (identifier) consequence: (string_literal) alternative: (string_literal))))) |
public static void main ( String [ ] args ) {
String s = sc . next ( ) ;
ArrayDeque < Character > dq = new ArrayDeque < > ( ) ;
for ( int i = 0 ;
i < s . length ( ) ;
i ++ ) {
char c = s . charAt ( i ) ;
if ( c == 'T' ) {
if ( dq . peekFirst ( ) == null || dq . peekFirst ( ) == 'T' ) {
dq . addFirst ( c ) ;
}
else if ( dq . peekFirst ( ) == 'S' ) {
dq . removeFirst ( ) ;
}
}
else if ( c == 'S' ) {
dq . addFirst ( c ) ;
}
}
System . out . println ( dq . size ( ) ) ;
}
| public static void main ( String [ ] args ) { String s = sc . next ( ) ; ArrayDeque < Character > dq = new ArrayDeque < > ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; if ( c == ' T ' ) { if ( dq . peekFirst ( ) == null || dq . peekFirst ( ) == ' T ' ) { dq . addFirst ( c ) ; } else if ( dq . peekFirst ( ) == ' S ' ) { dq . removeFirst ( ) ; } } else if ( c == ' S ' ) { dq . addFirst ( c ) ; } } System . out . println ( dq . size ( ) ) ; } | (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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (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))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (character_literal))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (null_literal)) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (character_literal)))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (character_literal))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (character_literal))) consequence: (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 (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))))) |
public static void main ( String [ ] args ) {
Scanner sc = new Scanner ( System . in ) ;
String a = sc . next ( ) ;
int [ ] stacks = new int [ a . length ( ) ] ;
int kaisu = 0 ;
int pointer = 0 ;
for ( int i = 0 ;
i < a . length ( ) ;
i ++ ) {
if ( a . charAt ( i ) == 'S' ) {
stacks [ pointer ] = 1 ;
pointer ++ ;
}
else if ( a . charAt ( i ) == 'T' ) {
stacks [ pointer ] = 2 ;
pointer ++ ;
}
if ( pointer >= 2 ) {
if ( stacks [ pointer - 2 ] == 1 && stacks [ pointer - 1 ] == 2 ) {
stacks [ pointer - 2 ] = 0 ;
stacks [ pointer - 1 ] = 0 ;
pointer -= 2 ;
kaisu ++ ;
}
}
}
System . out . println ( ( a . length ( ) - kaisu * 2 ) ) ;
}
| public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; int [ ] stacks = new int [ a . length ( ) ] ; int kaisu = 0 ; int pointer = 0 ; for ( int i = 0 ; i < a . length ( ) ; i ++ ) { if ( a . charAt ( i ) == ' S ' ) { stacks [ pointer ] = 1 ; pointer ++ ; } else if ( a . charAt ( i ) == ' T ' ) { stacks [ pointer ] = 2 ; pointer ++ ; } if ( pointer >= 2 ) { if ( stacks [ pointer - 2 ] == 1 && stacks [ pointer - 1 ] == 2 ) { stacks [ pointer - 2 ] = 0 ; stacks [ pointer - 1 ] = 0 ; pointer -= 2 ; kaisu ++ ; } } } System . out . println ( ( a . length ( ) - kaisu * 2 ) ) ; } | (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 (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (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 (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) (expression_statement (update_expression (identifier)))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) (expression_statement (update_expression (identifier)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal)) right: (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal)))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (expression_statement (update_expression (identifier))))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (binary_expression left: (identifier) right: (decimal_integer_literal))))))))) |
public static void main ( String [ ] args ) {
Scanner sc = new Scanner ( System . in ) ;
String X = sc . next ( ) ;
Deque < Character > stack = new ArrayDeque < > ( ) ;
for ( int i = 0 ;
i < X . length ( ) ;
i ++ ) {
if ( X . charAt ( i ) == 'S' ) {
stack . push ( X . charAt ( i ) ) ;
}
else {
if ( stack . size ( ) == 0 ) {
stack . push ( X . charAt ( i ) ) ;
}
else if ( stack . peek ( ) == 'S' ) {
stack . pop ( ) ;
}
else if ( stack . peek ( ) == 'T' ) {
stack . push ( X . charAt ( i ) ) ;
}
}
}
System . out . println ( stack . size ( ) ) ;
}
| public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String X = sc . next ( ) ; Deque < Character > stack = new ArrayDeque < > ( ) ; for ( int i = 0 ; i < X . length ( ) ; i ++ ) { if ( X . charAt ( i ) == ' S ' ) { stack . push ( X . charAt ( i ) ) ; } else { if ( stack . size ( ) == 0 ) { stack . push ( X . charAt ( i ) ) ; } else if ( stack . peek ( ) == ' S ' ) { stack . pop ( ) ; } else if ( stack . peek ( ) == ' T ' ) { stack . push ( X . charAt ( i ) ) ; } } } System . out . println ( stack . size ( ) ) ; } | (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 (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))))) alternative: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (character_literal))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (character_literal))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (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 (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))))) |
public static void main ( String [ ] args ) {
Scanner sc = new Scanner ( System . in ) ;
int i , j ;
double p , q , n , a , b , c , d , ans ;
int pX [ ] = new int [ 12 ] ;
int pY [ ] = new int [ 12 ] ;
ans = 10000000 ;
p = sc . nextInt ( ) ;
q = sc . nextInt ( ) ;
n = sc . nextInt ( ) ;
for ( i = 0 ;
i < n ;
i ++ ) {
pX [ i ] = sc . nextInt ( ) ;
pY [ i ] = sc . nextInt ( ) ;
}
for ( i = 0 ;
i < n ;
i ++ ) {
j = ( i < n - 1 ) ? i + 1 : 0 ;
a = pX [ j ] - pX [ i ] ;
b = pY [ j ] - pY [ i ] ;
c = Math . sqrt ( a * a + b * b ) ;
d = ( a * ( q - pY [ i ] ) + b * ( pX [ i ] - p ) ) / c ;
d = ( d >= 0 ) ? d : - d ;
if ( ans > d ) ans = d ;
}
System . out . println ( ans ) ;
}
| public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int i , j ; double p , q , n , a , b , c , d , ans ; int pX [ ] = new int [ 12 ] ; int pY [ ] = new int [ 12 ] ; ans = 10000000 ; p = sc . nextInt ( ) ; q = sc . nextInt ( ) ; n = sc . nextInt ( ) ; for ( i = 0 ; i < n ; i ++ ) { pX [ i ] = sc . nextInt ( ) ; pY [ i ] = sc . nextInt ( ) ; } for ( i = 0 ; i < n ; i ++ ) { j = ( i < n - 1 ) ? i + 1 : 0 ; a = pX [ j ] - pX [ i ] ; b = pY [ j ] - pY [ i ] ; c = Math . sqrt ( a * a + b * b ) ; d = ( a * ( q - pY [ i ] ) + b * ( pX [ i ] - p ) ) / c ; d = ( d >= 0 ) ? d : - d ; if ( ans > d ) ans = d ; } System . out . println ( ans ) ; } | (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 (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (decimal_integer_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (decimal_integer_literal))))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (for_statement init: (assignment_expression left: (identifier) right: (decimal_integer_literal)) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (for_statement init: (assignment_expression left: (identifier) right: (decimal_integer_literal)) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (ternary_expression condition: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) consequence: (binary_expression left: (identifier) right: (decimal_integer_literal)) alternative: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (identifier) right: (identifier))))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier))))) right: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier)))))) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (ternary_expression condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (identifier) alternative: (unary_expression operand: (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (expression_statement (assignment_expression left: (identifier) right: (identifier)))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier)))))) |
public static void main ( String [ ] args ) {
Scanner sc = new Scanner ( System . in ) ;
double cx = sc . nextDouble ( ) ;
double cy = sc . nextDouble ( ) ;
int N = sc . nextInt ( ) ;
double [ ] x = new double [ N + 2 ] ;
double [ ] y = new double [ N + 2 ] ;
for ( int i = 0 ;
i < N ;
i ++ ) {
x [ i ] = sc . nextDouble ( ) ;
y [ i ] = sc . nextDouble ( ) ;
}
double min = 100000000 ;
for ( int i = 0 ;
i < N - 1 ;
i ++ ) {
double l = dist ( x [ i ] , x [ i + 1 ] , y [ i ] , y [ i + 1 ] , cx , cy ) ;
min = Math . min ( l , min ) ;
}
double l = dist ( x [ N - 1 ] , x [ 0 ] , y [ N - 1 ] , y [ 0 ] , cx , cy ) ;
min = Math . min ( l , min ) ;
System . out . println ( min ) ;
}
| public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double cx = sc . nextDouble ( ) ; double cy = sc . nextDouble ( ) ; int N = sc . nextInt ( ) ; double [ ] x = new double [ N + 2 ] ; double [ ] y = new double [ N + 2 ] ; for ( int i = 0 ; i < N ; i ++ ) { x [ i ] = sc . nextDouble ( ) ; y [ i ] = sc . nextDouble ( ) ; } double min = 100000000 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { double l = dist ( x [ i ] , x [ i + 1 ] , y [ i ] , y [ i + 1 ] , cx , cy ) ; min = Math . min ( l , min ) ; } double l = dist ( x [ N - 1 ] , x [ 0 ] , y [ N - 1 ] , y [ 0 ] , cx , cy ) ; min = Math . min ( l , min ) ; System . out . println ( min ) ; } | (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 (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (floating_point_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)))) (local_variable_declaration type: (array_type element: (floating_point_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (floating_point_type) dimensions: (dimensions_expr (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (local_variable_declaration type: (array_type element: (floating_point_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (floating_point_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: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (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))) (array_access array: (identifier) index: (identifier)) (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) (identifier) (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) (array_access array: (identifier) index: (decimal_integer_literal)) (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) (array_access array: (identifier) index: (decimal_integer_literal)) (identifier) (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier)))))) |
public static double dist ( double x1 , double x2 , double y1 , double y2 , double x , double y ) {
if ( x1 == x2 ) {
return Math . abs ( x - x1 ) ;
}
else if ( y1 == y2 ) {
return Math . abs ( y - y1 ) ;
}
else {
double a = ( y1 - y2 ) / ( x1 - x2 ) ;
double b = y1 - a * x1 ;
return Math . abs ( y - a * x - b ) / Math . sqrt ( 1 + a * a ) ;
}
}
| public static double dist ( double x1 , double x2 , double y1 , double y2 , double x , double y ) { if ( x1 == x2 ) { return Math . abs ( x - x1 ) ; } else if ( y1 == y2 ) { return Math . abs ( y - y1 ) ; } else { double a = ( y1 - y2 ) / ( x1 - x2 ) ; double b = y1 - a * x1 ; return Math . abs ( y - a * x - b ) / Math . sqrt ( 1 + a * a ) ; } } | (method_declaration (modifiers) type: (floating_point_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (floating_point_type) name: (identifier)) (formal_parameter type: (floating_point_type) name: (identifier)) (formal_parameter type: (floating_point_type) name: (identifier)) (formal_parameter type: (floating_point_type) name: (identifier)) (formal_parameter type: (floating_point_type) name: (identifier)) (formal_parameter type: (floating_point_type) name: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)))))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)))))) alternative: (block (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (parenthesized_expression (binary_expression left: (identifier) right: (identifier)))))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier))))) (return_statement (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier))) right: (identifier)))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (decimal_integer_literal) right: (binary_expression left: (identifier) right: (identifier)))))))))))) |
public static void main ( String [ ] args ) {
int a = sc . nextInt ( ) ;
int b = sc . nextInt ( ) ;
int k = sc . nextInt ( ) ;
TreeSet < Integer > set = new TreeSet < > ( ) ;
for ( int i = a ;
i <= Math . min ( b , a + k - 1 ) ;
i ++ ) set . add ( i ) ;
for ( int i = b ;
i >= Math . max ( a , b - k + 1 ) ;
i -- ) set . add ( i ) ;
set . forEach ( out :: println ) ;
}
| public static void main ( String [ ] args ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; TreeSet < Integer > set = new TreeSet < > ( ) ; for ( int i = a ; i <= Math . min ( b , a + k - 1 ) ; i ++ ) set . add ( i ) ; for ( int i = b ; i >= Math . max ( a , b - k + 1 ) ; i -- ) set . add ( i ) ; set . forEach ( out :: println ) ; } | (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 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)))) (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: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal))))) update: (update_expression (identifier)) body: (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: (identifier))) condition: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal))))) update: (update_expression (identifier)) body: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_reference (identifier) (identifier))))))) |
public static void main ( String [ ] args ) throws Exception {
BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ;
StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ;
int a = Integer . parseInt ( tokenizer . nextToken ( ) ) ;
int b = Integer . parseInt ( tokenizer . nextToken ( ) ) ;
int c = Integer . parseInt ( tokenizer . nextToken ( ) ) ;
Set < Integer > hashSet = new HashSet < > ( ) ;
StringBuilder out = new StringBuilder ( ) ;
for ( int i = a ;
i < a + c && i <= b ;
i ++ ) {
if ( ! hashSet . contains ( i ) ) {
out . append ( i ) . append ( "\n" ) ;
hashSet . add ( i ) ;
}
}
for ( int i = b - c + 1 ;
i <= b && i > a ;
i ++ ) {
if ( ! hashSet . contains ( i ) ) {
out . append ( i ) . append ( "\n" ) ;
hashSet . add ( i ) ;
}
}
System . out . print ( out ) ;
}
| public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; int a = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int b = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int c = Integer . parseInt ( tokenizer . nextToken ( ) ) ; Set < Integer > hashSet = new HashSet < > ( ) ; StringBuilder out = new StringBuilder ( ) ; for ( int i = a ; i < a + c && i <= b ; i ++ ) { if ( ! hashSet . contains ( i ) ) { out . append ( i ) . append ( " \n " ) ; hashSet . add ( i ) ; } } for ( int i = b - c + 1 ; i <= b && i > a ; i ++ ) { if ( ! hashSet . contains ( i ) ) { out . append ( i ) . append ( " \n " ) ; hashSet . add ( i ) ; } } System . out . print ( out ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) (throws (type_identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (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 (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 (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 (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (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: (identifier))) condition: (binary_expression left: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier))) right: (binary_expression left: (identifier) right: (identifier))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) consequence: (block (expression_statement (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) name: (identifier) arguments: (argument_list (string_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: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal)))) condition: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (identifier) right: (identifier))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) consequence: (block (expression_statement (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) name: (identifier) arguments: (argument_list (string_literal)))) (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 (identifier)))))) |
public static void main ( String [ ] args ) {
Main main = new Main ( ) ;
main . solve ( ) ;
}
| public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solve ( ) ; } | (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)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) |
public static void main ( String [ ] args ) throws IOException {
BufferedReader stdin = new BufferedReader ( new InputStreamReader ( System . in ) ) ;
int [ ] input = Arrays . stream ( stdin . readLine ( ) . split ( " " ) ) . mapToInt ( Integer :: parseInt ) . toArray ( ) ;
IntStream . rangeClosed ( input [ 0 ] , input [ 1 ] ) . filter ( i -> {
int order = i - input [ 0 ] ;
if ( order < input [ 2 ] || input [ 1 ] - input [ 0 ] - input [ 2 ] < order ) return true ;
else return false ;
}
) . forEach ( System . out :: println ) ;
}
| public static void main ( String [ ] args ) throws IOException { BufferedReader stdin = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int [ ] input = Arrays . stream ( stdin . readLine ( ) . split ( " ▁ " ) ) . mapToInt ( Integer :: parseInt ) . toArray ( ) ; IntStream . rangeClosed ( input [ 0 ] , input [ 1 ] ) . filter ( i -> { int order = i - input [ 0 ] ; if ( order < input [ 2 ] || input [ 1 ] - input [ 0 ] - input [ 2 ] < order ) return true ; else return false ; } ) . forEach ( System . out :: println ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) (throws (type_identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list (string_literal))))) name: (identifier) arguments: (argument_list (method_reference (identifier) (identifier)))) name: (identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (decimal_integer_literal)) (array_access array: (identifier) index: (decimal_integer_literal)))) name: (identifier) arguments: (argument_list (lambda_expression parameters: (identifier) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (array_access array: (identifier) index: (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (array_access array: (identifier) index: (decimal_integer_literal))) right: (binary_expression left: (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (array_access array: (identifier) index: (decimal_integer_literal))) right: (array_access array: (identifier) index: (decimal_integer_literal))) right: (identifier)))) consequence: (return_statement (true)) alternative: (return_statement (false))))))) name: (identifier) arguments: (argument_list (method_reference (field_access object: (identifier) field: (identifier)) (identifier))))))) |
public static void main ( String [ ] args ) {
Scanner sc = new Scanner ( System . in ) ;
int A = sc . nextInt ( ) ;
int B = sc . nextInt ( ) ;
int K = sc . nextInt ( ) ;
ArrayList < Integer > array = new ArrayList < > ( ) ;
for ( int i = 0 ;
i < K ;
i ++ ) {
if ( A + i <= B ) array . add ( A + i ) ;
}
for ( int i = K - 1 ;
i >= 0 ;
i -- ) {
if ( ! array . contains ( B - i ) && B - i >= A ) array . add ( B - i ) ;
}
for ( int i = 0 ;
i < array . size ( ) ;
i ++ ) {
System . out . println ( array . get ( i ) ) ;
}
}
| public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; ArrayList < Integer > array = new ArrayList < > ( ) ; for ( int i = 0 ; i < K ; i ++ ) { if ( A + i <= B ) array . add ( A + i ) ; } for ( int i = K - 1 ; i >= 0 ; i -- ) { if ( ! array . contains ( B - i ) && B - i >= A ) array . add ( B - i ) ; } for ( int i = 0 ; i < array . size ( ) ; i ++ ) { System . out . println ( array . get ( 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: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (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)))) (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: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier))) consequence: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)))))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier))))) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)))) consequence: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)))))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))))))) |
public static void main ( String [ ] args ) {
Scanner sc = new Scanner ( System . in ) ;
int n = sc . nextInt ( ) ;
int ans = ( int ) 1e9 ;
if ( n == 1 ) {
ans = 0 ;
System . out . println ( ans ) ;
return ;
}
for ( int i = 1 ;
i < n ;
i ++ ) {
for ( int j = 1 ;
i + j <= n && i * j <= n ;
j ++ ) {
int x = Math . abs ( i - j ) ;
int v = i * j ;
int res = n - v ;
int sum = x + res ;
if ( res >= 0 && sum < ans ) {
ans = sum ;
}
}
}
System . out . println ( ans ) ;
}
| public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int ans = ( int ) 1e9 ; if ( n == 1 ) { ans = 0 ; System . out . println ( ans ) ; return ; } for ( int i = 1 ; i < n ; i ++ ) { for ( int j = 1 ; i + j <= n && i * j <= n ; j ++ ) { int x = Math . abs ( i - j ) ; int v = i * j ; int res = n - v ; int sum = x + res ; if ( res >= 0 && sum < ans ) { ans = sum ; } } } System . out . println ( ans ) ; } | (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 (field_access object: (identifier) field: (identifier)))))) (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: (cast_expression type: (integral_type) value: (decimal_floating_point_literal)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier)))) (return_statement))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier))) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (binary_expression left: (identifier) right: (identifier)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier)))))) |
public static void main ( String [ ] args ) {
InputStream inputStream = System . in ;
OutputStream outputStream = System . out ;
FastScanner in = new FastScanner ( inputStream ) ;
PrintWriter out = new PrintWriter ( outputStream ) ;
TaskB solver = new TaskB ( ) ;
solver . solve ( 1 , in , out ) ;
out . close ( ) ;
}
| public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskB solver = new TaskB ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } | (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: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier) (identifier)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) |
private static boolean isSpaceChar ( int c ) {
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == - 1 ;
}
| private static boolean isSpaceChar ( int c ) { return c == ' ▁ ' || c == ' \n ' || c == ' \r ' || c == ' \t ' || c == - 1 ; } | (method_declaration (modifiers) type: (boolean_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier))) body: (block (return_statement (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: (unary_expression operand: (decimal_integer_literal))))))) |
public static void main ( String [ ] args ) {
InputStream inputStream = System . in ;
OutputStream outputStream = System . out ;
LightScanner in = new LightScanner ( inputStream ) ;
PrintWriter out = new PrintWriter ( outputStream ) ;
B solver = new B ( ) ;
solver . solve ( 1 , in , out ) ;
out . close ( ) ;
}
| public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; LightScanner in = new LightScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; B solver = new B ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } | (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: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier) (identifier)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) |
public static void main ( String [ ] args ) {
Scanner sc = new Scanner ( System . in ) ;
int n = sc . nextInt ( ) ;
int hen = 1 ;
int min = 20000000 ;
while ( ! ( hen * hen > n ) ) {
hen ++ ;
}
hen -- ;
while ( hen != 0 ) {
min = Math . min ( ( n - n / hen * hen ) + ( n / hen - hen ) , min ) ;
hen -- ;
}
System . out . println ( min ) ;
sc . close ( ) ;
}
| public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int hen = 1 ; int min = 20000000 ; while ( ! ( hen * hen > n ) ) { hen ++ ; } hen -- ; while ( hen != 0 ) { min = Math . min ( ( n - n / hen * hen ) + ( n / hen - hen ) , min ) ; hen -- ; } System . out . println ( min ) ; sc . close ( ) ; } | (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 (field_access object: (identifier) field: (identifier)))))) (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: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (while_statement condition: (parenthesized_expression (unary_expression operand: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier))))) body: (block (expression_statement (update_expression (identifier))))) (expression_statement (update_expression (identifier))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) body: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)))) right: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)))) (identifier))))) (expression_statement (update_expression (identifier))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) |
public static void main ( String [ ] args ) {
Scanner reader = new Scanner ( System . in ) ;
int A = reader . nextInt ( ) ;
int base = getMaxSqueaBase ( A ) ;
int min = A - ( int ) Math . pow ( base , 2 ) ;
if ( min > 0 ) {
for ( int i = base ;
i > 0 ;
i -- ) {
int remain = A - ( int ) Math . pow ( i , 2 ) ;
int tmp = 0 ;
while ( i <= remain ) {
remain -= i ;
tmp ++ ;
}
if ( remain + tmp < min ) {
min = remain + tmp ;
}
}
}
System . out . println ( min ) ;
reader . close ( ) ;
}
| public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int A = reader . nextInt ( ) ; int base = getMaxSqueaBase ( A ) ; int min = A - ( int ) Math . pow ( base , 2 ) ; if ( min > 0 ) { for ( int i = base ; i > 0 ; i -- ) { int remain = A - ( int ) Math . pow ( i , 2 ) ; int tmp = 0 ; while ( i <= remain ) { remain -= i ; tmp ++ ; } if ( remain + tmp < min ) { min = remain + tmp ; } } } System . out . println ( min ) ; reader . close ( ) ; } | (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 (field_access object: (identifier) field: (identifier)))))) (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 name: (identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (cast_expression type: (integral_type) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (cast_expression type: (integral_type) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) body: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))) (expression_statement (update_expression (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier)))))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) |
public static int getMaxSqueaBase ( int num ) {
int base = 1 ;
while ( Math . pow ( ( base + 1 ) , 2 ) <= num ) {
base ++ ;
}
return base ;
}
| public static int getMaxSqueaBase ( int num ) { int base = 1 ; while ( Math . pow ( ( base + 1 ) , 2 ) <= num ) { base ++ ; } return base ; } | (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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) (decimal_integer_literal))) right: (identifier))) body: (block (expression_statement (update_expression (identifier))))) (return_statement (identifier)))) |
public static void main ( String [ ] args ) {
Scanner sc = new Scanner ( System . in ) ;
int N = sc . nextInt ( ) ;
boolean [ ] a = new boolean [ N + 1 ] ;
long odd = 0 ;
long even = 0 ;
long max = Long . MIN_VALUE ;
int mp = - 1 ;
for ( int i = 1 ;
i <= N ;
++ i ) {
long temp = sc . nextLong ( ) ;
if ( temp > max ) {
max = temp ;
mp = i ;
}
if ( temp > 0 ) {
a [ i ] = true ;
if ( i % 2 == 1 ) odd += temp ;
else even += temp ;
}
}
if ( odd == 0 && even == 0 ) {
System . out . println ( max ) ;
System . out . println ( N - 1 ) ;
for ( int i = N ;
i > mp ;
-- i ) {
System . out . println ( i ) ;
}
for ( int i = 1 ;
i < mp ;
++ i ) {
System . out . println ( 1 ) ;
}
return ;
}
System . out . println ( Math . max ( odd , even ) ) ;
int offset = odd > even ? 1 : 0 ;
int p = N ;
ArrayList < Integer > al = new ArrayList < Integer > ( ) ;
while ( ! a [ p ] || ( p + offset ) % 2 != 0 ) {
al . add ( p ) ;
p -- ;
}
int left = 0 ;
while ( ! a [ left ] || ( left + offset ) % 2 != 0 ) left ++ ;
for ( int i = p - 2 ;
i >= left ;
i -= 2 ) {
if ( a [ i ] ) al . add ( i + 1 ) ;
else al . add ( i ) ;
}
for ( int i = 1 ;
i < left ;
++ i ) al . add ( 1 ) ;
System . out . println ( al . size ( ) ) ;
for ( int i = 0 ;
i < al . size ( ) ;
i ++ ) {
System . out . println ( al . get ( i ) ) ;
}
return ;
}
| public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; boolean [ ] a = new boolean [ N + 1 ] ; long odd = 0 ; long even = 0 ; long max = Long . MIN_VALUE ; int mp = - 1 ; for ( int i = 1 ; i <= N ; ++ i ) { long temp = sc . nextLong ( ) ; if ( temp > max ) { max = temp ; mp = i ; } if ( temp > 0 ) { a [ i ] = true ; if ( i % 2 == 1 ) odd += temp ; else even += temp ; } } if ( odd == 0 && even == 0 ) { System . out . println ( max ) ; System . out . println ( N - 1 ) ; for ( int i = N ; i > mp ; -- i ) { System . out . println ( i ) ; } for ( int i = 1 ; i < mp ; ++ i ) { System . out . println ( 1 ) ; } return ; } System . out . println ( Math . max ( odd , even ) ) ; int offset = odd > even ? 1 : 0 ; int p = N ; ArrayList < Integer > al = new ArrayList < Integer > ( ) ; while ( ! a [ p ] || ( p + offset ) % 2 != 0 ) { al . add ( p ) ; p -- ; } int left = 0 ; while ( ! a [ left ] || ( left + offset ) % 2 != 0 ) left ++ ; for ( int i = p - 2 ; i >= left ; i -= 2 ) { if ( a [ i ] ) al . add ( i + 1 ) ; else al . add ( i ) ; } for ( int i = 1 ; i < left ; ++ i ) al . add ( 1 ) ; System . out . println ( al . size ( ) ) ; for ( int i = 0 ; i < al . size ( ) ; i ++ ) { System . out . println ( al . get ( i ) ) ; } return ; } | (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 (field_access object: (identifier) field: (identifier)))))) (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: (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)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (unary_expression operand: (decimal_integer_literal)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (true))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (identifier))) alternative: (expression_statement (assignment_expression left: (identifier) right: (identifier)))))))) (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 (identifier)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (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 (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (decimal_integer_literal)))))) (return_statement))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (ternary_expression condition: (binary_expression left: (identifier) right: (identifier)) consequence: (decimal_integer_literal) alternative: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments (type_identifier))) arguments: (argument_list)))) (while_statement condition: (parenthesized_expression (binary_expression left: (unary_expression operand: (array_access array: (identifier) index: (identifier))) right: (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal)) right: (decimal_integer_literal)))) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (expression_statement (update_expression (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (while_statement condition: (parenthesized_expression (binary_expression left: (unary_expression operand: (array_access array: (identifier) index: (identifier))) right: (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal)) right: (decimal_integer_literal)))) body: (expression_statement (update_expression (identifier)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (identifier)) update: (assignment_expression left: (identifier) right: (decimal_integer_literal)) body: (block (if_statement condition: (parenthesized_expression (array_access array: (identifier) index: (identifier))) consequence: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal))))) alternative: (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: (expression_statement (method_invocation object: (identifier) 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 object: (identifier) name: (identifier) arguments: (argument_list))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))))) (return_statement))) |
public static void main ( String [ ] args ) {
Scanner sc = new Scanner ( System . in ) ;
String s = sc . next ( ) ;
int [ ] c = new int [ 6 ] ;
for ( int i = 0 ;
i < s . length ( ) ;
i ++ ) {
if ( s . charAt ( i ) == 'A' ) {
c [ 0 ] ++ ;
}
else if ( s . charAt ( i ) == 'B' ) {
c [ 1 ] ++ ;
}
else if ( s . charAt ( i ) == 'C' ) {
c [ 2 ] ++ ;
}
else if ( s . charAt ( i ) == 'D' ) {
c [ 3 ] ++ ;
}
else if ( s . charAt ( i ) == 'E' ) {
c [ 4 ] ++ ;
}
else if ( s . charAt ( i ) == 'F' ) {
c [ 5 ] ++ ;
}
}
System . out . printf ( "%d %d %d %d %d %d%n" , c [ 0 ] , c [ 1 ] , c [ 2 ] , c [ 3 ] , c [ 4 ] , c [ 5 ] ) ;
}
| public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int [ ] c = new int [ 6 ] ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' A ' ) { c [ 0 ] ++ ; } else if ( s . charAt ( i ) == ' B ' ) { c [ 1 ] ++ ; } else if ( s . charAt ( i ) == ' C ' ) { c [ 2 ] ++ ; } else if ( s . charAt ( i ) == ' D ' ) { c [ 3 ] ++ ; } else if ( s . charAt ( i ) == ' E ' ) { c [ 4 ] ++ ; } else if ( s . charAt ( i ) == ' F ' ) { c [ 5 ] ++ ; } } System . out . printf ( " % d ▁ % d ▁ % d ▁ % d ▁ % d ▁ % d % n " , c [ 0 ] , c [ 1 ] , c [ 2 ] , c [ 3 ] , c [ 4 ] , c [ 5 ] ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (decimal_integer_literal))))) (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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))) consequence: (block (expression_statement (update_expression (array_access array: (identifier) index: (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: (block (expression_statement (update_expression (array_access array: (identifier) index: (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: (block (expression_statement (update_expression (array_access array: (identifier) index: (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: (block (expression_statement (update_expression (array_access array: (identifier) index: (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: (block (expression_statement (update_expression (array_access array: (identifier) index: (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: (block (expression_statement (update_expression (array_access array: (identifier) index: (decimal_integer_literal))))))))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal) (array_access array: (identifier) index: (decimal_integer_literal)) (array_access array: (identifier) index: (decimal_integer_literal)) (array_access array: (identifier) index: (decimal_integer_literal)) (array_access array: (identifier) index: (decimal_integer_literal)) (array_access array: (identifier) index: (decimal_integer_literal)) (array_access array: (identifier) index: (decimal_integer_literal))))))) |
public static void main ( String [ ] args ) {
InputStream inputStream = System . in ;
OutputStream outputStream = System . out ;
LightScanner in = new LightScanner ( inputStream ) ;
PrintWriter out = new PrintWriter ( outputStream ) ;
B solver = new B ( ) ;
solver . solve ( 1 , in , out ) ;
out . close ( ) ;
}
| public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; LightScanner in = new LightScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; B solver = new B ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } | (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: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier) (identifier)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) |
public static void main ( String [ ] args ) {
InputStream inputStream = System . in ;
OutputStream outputStream = System . out ;
FastScanner in = new FastScanner ( inputStream ) ;
PrintWriter out = new PrintWriter ( outputStream ) ;
TaskB solver = new TaskB ( ) ;
solver . solve ( 1 , in , out ) ;
out . close ( ) ;
}
| public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskB solver = new TaskB ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } | (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: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier) (identifier)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) |
private static boolean isPrintableChar ( int c ) {
return c >= 33 && c <= 126 ;
}
| private static boolean isPrintableChar ( int c ) { return c >= 33 && c <= 126 ; } | (method_declaration (modifiers) type: (boolean_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier))) body: (block (return_statement (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) |
public static void main ( String [ ] args ) {
String s = sc . next ( ) ;
int [ ] count = new int [ 6 ] ;
for ( int i = 0 ;
i < s . length ( ) ;
i ++ ) {
count [ s . charAt ( i ) - 'A' ] ++ ;
}
System . out . println ( count [ 0 ] + " " + count [ 1 ] + " " + count [ 2 ] + " " + count [ 3 ] + " " + count [ 4 ] + " " + count [ 5 ] ) ;
}
| public static void main ( String [ ] args ) { String s = sc . next ( ) ; int [ ] count = new int [ 6 ] ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { count [ s . charAt ( i ) - ' A ' ] ++ ; } System . out . println ( count [ 0 ] + " ▁ " + count [ 1 ] + " ▁ " + count [ 2 ] + " ▁ " + count [ 3 ] + " ▁ " + count [ 4 ] + " ▁ " + count [ 5 ] ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (decimal_integer_literal))))) (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 (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))))))) (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: (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (string_literal)) right: (array_access array: (identifier) index: (decimal_integer_literal))) right: (string_literal)) right: (array_access array: (identifier) index: (decimal_integer_literal))) right: (string_literal)) right: (array_access array: (identifier) index: (decimal_integer_literal))) right: (string_literal)) right: (array_access array: (identifier) index: (decimal_integer_literal))) right: (string_literal)) right: (array_access array: (identifier) index: (decimal_integer_literal)))))))) |
public static void main ( String [ ] args ) throws Exception {
Scanner sc = new Scanner ( System . in ) ;
Map < String , Integer > map = new TreeMap < > ( ) ;
String s = sc . next ( ) ;
String A [ ] = {
"A" , "B" , "C" , "D" , "E" , "F" };
for ( int i = 0 ;
i < 6 ;
i ++ ) map . put ( A [ i ] , 0 ) ;
for ( int i = 0 ;
i < s . length ( ) ;
i ++ ) {
String S = s . substring ( i , i + 1 ) ;
map . put ( S , map . get ( S ) + 1 ) ;
}
System . out . println ( map . get ( "A" ) + " " + map . get ( "B" ) + " " + map . get ( "C" ) + " " + map . get ( "D" ) + " " + map . get ( "E" ) + " " + map . get ( "F" ) ) ;
}
| public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; Map < String , Integer > map = new TreeMap < > ( ) ; String s = sc . next ( ) ; String A [ ] = { " A " , " B " , " C " , " D " , " E " , " F " } ; for ( int i = 0 ; i < 6 ; i ++ ) map . put ( A [ i ] , 0 ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { String S = s . substring ( i , i + 1 ) ; map . put ( S , map . get ( S ) + 1 ) ; } System . out . println ( map . get ( " A " ) + " ▁ " + map . get ( " B " ) + " ▁ " + map . get ( " C " ) + " ▁ " + map . get ( " D " ) + " ▁ " + map . get ( " E " ) + " ▁ " + map . get ( " F " ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) (throws (type_identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier) (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_initializer (string_literal) (string_literal) (string_literal) (string_literal) (string_literal) (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: (decimal_integer_literal)) update: (update_expression (identifier)) body: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)) (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: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (decimal_integer_literal))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal))) right: (string_literal)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal)))) right: (string_literal)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal)))) right: (string_literal)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal)))) right: (string_literal)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal)))) right: (string_literal)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal))))))))) |
public static void main ( String [ ] args ) {
try ( Scanner scanner = new Scanner ( System . in ) ) {
String string = scanner . nextLine ( ) ;
System . out . println ( string . chars ( ) . filter ( x -> x == '1' ) . count ( ) ) ;
}
}
| public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { String string = scanner . nextLine ( ) ; System . out . println ( string . chars ( ) . filter ( x -> x == '1' ) . count ( ) ) ; } } | (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 (try_with_resources_statement resources: (resource_specification (resource type: (type_identifier) name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation object: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list (lambda_expression parameters: (identifier) body: (binary_expression left: (identifier) right: (character_literal))))) name: (identifier) arguments: (argument_list))))))))) |
private static String readLine ( ) {
buffer = null ;
try {
return br . readLine ( ) ;
}
catch ( IOException e ) {
throw new RuntimeException ( e ) ;
}
}
| private static String readLine ( ) { buffer = null ; try { return br . readLine ( ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } | (method_declaration (modifiers) type: (type_identifier) name: (identifier) parameters: (formal_parameters) body: (block (expression_statement (assignment_expression left: (identifier) right: (null_literal))) (try_statement body: (block (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (catch_clause (catch_formal_parameter (catch_type (type_identifier)) name: (identifier)) body: (block (throw_statement (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier))))))))) |
private static String read ( ) {
if ( buffer == null || ! buffer . hasMoreTokens ( ) ) {
buffer = new StringTokenizer ( readLine ( ) ) ;
}
return buffer . nextToken ( ) ;
}
| private static String read ( ) { if ( buffer == null || ! buffer . hasMoreTokens ( ) ) { buffer = new StringTokenizer ( readLine ( ) ) ; } return buffer . nextToken ( ) ; } | (method_declaration (modifiers) type: (type_identifier) name: (identifier) parameters: (formal_parameters) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (null_literal)) right: (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (object_creation_expression type: (type_identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list)))))))) (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) |
private static int readInt ( ) {
return Integer . parseInt ( read ( ) ) ;
}
| private static int readInt ( ) { return Integer . parseInt ( read ( ) ) ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters) body: (block (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list))))))) |
private static int [ ] readIntArray ( int loop ) {
int [ ] result = new int [ loop ] ;
for ( int i = 0 ;
i < loop ;
i ++ ) {
result [ i ] = readInt ( ) ;
}
return result ;
}
| private static int [ ] readIntArray ( int loop ) { int [ ] result = new int [ loop ] ; for ( int i = 0 ; i < loop ; i ++ ) { result [ i ] = readInt ( ) ; } return result ; } | (method_declaration (modifiers) type: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier) parameters: (formal_parameters (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: (method_invocation name: (identifier) arguments: (argument_list)))))) (return_statement (identifier)))) |
private static int [ ] splitInt ( ) {
String [ ] tmp = read ( ) . split ( "" ) ;
int [ ] result = new int [ tmp . length ] ;
for ( int i = 0 , n = tmp . length ;
i < n ;
i ++ ) {
result [ i ] = Integer . parseInt ( tmp [ i ] ) ;
}
return result ;
}
| private static int [ ] splitInt ( ) { String [ ] tmp = read ( ) . split ( " " ) ; int [ ] result = new int [ tmp . length ] ; for ( int i = 0 , n = tmp . length ; i < n ; i ++ ) { result [ i ] = Integer . parseInt ( tmp [ i ] ) ; } return result ; } | (method_declaration (modifiers) type: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier) parameters: (formal_parameters) body: (block (local_variable_declaration type: (array_type element: (type_identifier) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list (string_literal))))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (field_access object: (identifier) field: (identifier)))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) 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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)))))))) (return_statement (identifier)))) |
private static long readLong ( ) {
return Long . parseLong ( read ( ) ) ;
}
| private static long readLong ( ) { return Long . parseLong ( read ( ) ) ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters) body: (block (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list))))))) |
private static double readDouble ( ) {
return Double . parseDouble ( read ( ) ) ;
}
| private static double readDouble ( ) { return Double . parseDouble ( read ( ) ) ; } | (method_declaration (modifiers) type: (floating_point_type) name: (identifier) parameters: (formal_parameters) body: (block (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list))))))) |
public static void main ( String [ ] args ) {
run ( ) ;
}
| public static void main ( String [ ] args ) { run ( ) ; } | (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))))) |
private static void run ( ) {
String [ ] input = readLine ( ) . split ( "" ) ;
int count = 0 ;
if ( input [ 0 ] . equals ( "1" ) ) count ++ ;
if ( input [ 1 ] . equals ( "1" ) ) count ++ ;
if ( input [ 2 ] . equals ( "1" ) ) count ++ ;
System . out . println ( count ) ;
}
| private static void run ( ) { String [ ] input = readLine ( ) . split ( " " ) ; int count = 0 ; if ( input [ 0 ] . equals ( "1" ) ) count ++ ; if ( input [ 1 ] . equals ( "1" ) ) count ++ ; if ( input [ 2 ] . equals ( "1" ) ) count ++ ; System . out . println ( count ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters) body: (block (local_variable_declaration type: (array_type element: (type_identifier) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list (string_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (if_statement condition: (parenthesized_expression (method_invocation object: (array_access array: (identifier) index: (decimal_integer_literal)) name: (identifier) arguments: (argument_list (string_literal)))) consequence: (expression_statement (update_expression (identifier)))) (if_statement condition: (parenthesized_expression (method_invocation object: (array_access array: (identifier) index: (decimal_integer_literal)) name: (identifier) arguments: (argument_list (string_literal)))) consequence: (expression_statement (update_expression (identifier)))) (if_statement condition: (parenthesized_expression (method_invocation object: (array_access array: (identifier) index: (decimal_integer_literal)) name: (identifier) arguments: (argument_list (string_literal)))) consequence: (expression_statement (update_expression (identifier)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier)))))) |
public static void main ( String arg [ ] ) {
Scanner sc = new Scanner ( System . in ) ;
String S = sc . nextLine ( ) ;
sc . close ( ) ;
System . out . println ( calc ( S ) ) ;
}
| public static void main ( String arg [ ] ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . nextLine ( ) ; sc . close ( ) ; System . out . println ( calc ( S ) ) ; } | (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: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier)))))))) |
public static int calc ( String S ) {
String [ ] s = S . split ( "" ) ;
int count = 0 ;
for ( int i = 0 ;
i < 3 ;
i ++ ) {
if ( s [ i ] . equals ( "1" ) ) {
count ++ ;
}
}
return count ;
}
| public static int calc ( String S ) { String [ ] s = S . split ( " " ) ; int count = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s [ i ] . equals ( "1" ) ) { count ++ ; } } return count ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier))) body: (block (local_variable_declaration type: (array_type element: (type_identifier) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (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: (block (if_statement condition: (parenthesized_expression (method_invocation object: (array_access array: (identifier) index: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) consequence: (block (expression_statement (update_expression (identifier))))))) (return_statement (identifier)))) |
public static void main ( String args [ ] ) {
Scanner scan = new Scanner ( System . in ) ;
int num = scan . nextInt ( ) ;
int cnt = 0 ;
boolean a = num > 99 ;
if ( a ) {
cnt ++ ;
num = num - 100 ;
}
boolean b = num > 9 ;
if ( b ) {
num = num - 10 ;
cnt ++ ;
}
boolean c = num == 1 ;
if ( c ) {
cnt ++ ;
}
System . out . println ( cnt ) ;
}
| public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; int num = scan . nextInt ( ) ; int cnt = 0 ; boolean a = num > 99 ; if ( a ) { cnt ++ ; num = num - 100 ; } boolean b = num > 9 ; if ( b ) { num = num - 10 ; cnt ++ ; } boolean c = num == 1 ; if ( c ) { cnt ++ ; } System . out . println ( cnt ) ; } | (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: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (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: (decimal_integer_literal))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (identifier)) consequence: (block (expression_statement (update_expression (identifier))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (identifier)) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (expression_statement (update_expression (identifier))))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (identifier)) consequence: (block (expression_statement (update_expression (identifier))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier)))))) |
public static void main ( String [ ] args ) {
Scanner sc = new Scanner ( System . in ) ;
String [ ] array = sc . nextLine ( ) . split ( "" ) ;
int sum = 0 ;
for ( String s : array ) {
if ( Integer . parseInt ( s ) == 1 ) {
sum ++ ;
}
}
System . out . println ( sum ) ;
}
| public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] array = sc . nextLine ( ) . split ( " " ) ; int sum = 0 ; for ( String s : array ) { if ( Integer . parseInt ( s ) == 1 ) { sum ++ ; } } System . out . println ( sum ) ; } | (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 (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (array_type element: (type_identifier) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list (string_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (enhanced_for_statement type: (type_identifier) name: (identifier) value: (identifier) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (decimal_integer_literal))) consequence: (block (expression_statement (update_expression (identifier))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier)))))) |
public static void main ( String [ ] args ) throws Exception {
Scanner sc = new Scanner ( System . in ) ;
int n = sc . nextInt ( ) ;
long [ ] cnt = new long [ 5 ] ;
for ( int i = 0 ;
i < n ;
i ++ ) {
char ch = sc . next ( ) . charAt ( 0 ) ;
if ( ch == 'M' ) cnt [ 0 ] ++ ;
if ( ch == 'A' ) cnt [ 1 ] ++ ;
if ( ch == 'R' ) cnt [ 2 ] ++ ;
if ( ch == 'C' ) cnt [ 3 ] ++ ;
if ( ch == 'H' ) cnt [ 4 ] ++ ;
}
sc . close ( ) ;
int c = 0 ;
for ( int i = 0 ;
i < cnt . length ;
i ++ ) {
if ( cnt [ i ] > 0 ) c ++ ;
}
if ( c < 3 ) {
System . out . println ( 0 ) ;
return ;
}
long ans = 0L ;
for ( int i = 0 ;
i < cnt . length ;
i ++ ) {
for ( int j = i + 1 ;
j < cnt . length ;
j ++ ) {
for ( int k = j + 1 ;
k < cnt . length ;
k ++ ) {
ans += cnt [ i ] * cnt [ j ] * cnt [ k ] ;
}
}
}
System . out . println ( ans ) ;
}
| public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long [ ] cnt = new long [ 5 ] ; for ( int i = 0 ; i < n ; i ++ ) { char ch = sc . next ( ) . charAt ( 0 ) ; if ( ch == ' M ' ) cnt [ 0 ] ++ ; if ( ch == ' A ' ) cnt [ 1 ] ++ ; if ( ch == ' R ' ) cnt [ 2 ] ++ ; if ( ch == ' C ' ) cnt [ 3 ] ++ ; if ( ch == ' H ' ) cnt [ 4 ] ++ ; } sc . close ( ) ; int c = 0 ; for ( int i = 0 ; i < cnt . length ; i ++ ) { if ( cnt [ i ] > 0 ) c ++ ; } if ( c < 3 ) { System . out . println ( 0 ) ; return ; } long ans = 0L ; for ( int i = 0 ; i < cnt . length ; i ++ ) { for ( int j = i + 1 ; j < cnt . length ; j ++ ) { for ( int k = j + 1 ; k < cnt . length ; k ++ ) { ans += cnt [ i ] * cnt [ j ] * cnt [ k ] ; } } } System . out . println ( ans ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) (throws (type_identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (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: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (decimal_integer_literal))))) (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: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (character_literal))) consequence: (expression_statement (update_expression (array_access array: (identifier) index: (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (character_literal))) consequence: (expression_statement (update_expression (array_access array: (identifier) index: (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (character_literal))) consequence: (expression_statement (update_expression (array_access array: (identifier) index: (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (character_literal))) consequence: (expression_statement (update_expression (array_access array: (identifier) index: (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (character_literal))) consequence: (expression_statement (update_expression (array_access array: (identifier) index: (decimal_integer_literal))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (field_access object: (identifier) field: (identifier))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (expression_statement (update_expression (identifier)))))) (if_statement condition: (parenthesized_expression (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 (decimal_integer_literal)))) (return_statement))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (field_access object: (identifier) field: (identifier))) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (field_access object: (identifier) field: (identifier))) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (field_access object: (identifier) field: (identifier))) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier))) right: (array_access array: (identifier) index: (identifier))))))))))) (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 = scanner . nextInt ( ) ;
long m = 0 , a = 0 , r = 0 , c = 0 , h = 0 ;
for ( int i = 0 ;
i < n ;
i ++ ) {
switch ( scanner . next ( ) . charAt ( 0 ) ) {
case 'M' : m ++ ;
continue ;
case 'A' : a ++ ;
continue ;
case 'R' : r ++ ;
continue ;
case 'C' : c ++ ;
continue ;
case 'H' : h ++ ;
}
}
System . out . println ( m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h ) ;
}
| public static void main ( String [ ] args ) { int n = scanner . nextInt ( ) ; long m = 0 , a = 0 , r = 0 , c = 0 , h = 0 ; for ( int i = 0 ; i < n ; i ++ ) { switch ( scanner . next ( ) . charAt ( 0 ) ) { case ' M ' : m ++ ; continue ; case ' A ' : a ++ ; continue ; case ' R ' : r ++ ; continue ; case ' C ' : c ++ ; continue ; case ' H ' : h ++ ; } } System . out . println ( m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h ) ; } | (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 object: (identifier) 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)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (switch_expression condition: (parenthesized_expression (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list (decimal_integer_literal)))) body: (switch_block (switch_block_statement_group (switch_label (character_literal)) (expression_statement (update_expression (identifier))) (continue_statement)) (switch_block_statement_group (switch_label (character_literal)) (expression_statement (update_expression (identifier))) (continue_statement)) (switch_block_statement_group (switch_label (character_literal)) (expression_statement (update_expression (identifier))) (continue_statement)) (switch_block_statement_group (switch_label (character_literal)) (expression_statement (update_expression (identifier))) (continue_statement)) (switch_block_statement_group (switch_label (character_literal)) (expression_statement (update_expression (identifier)))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier))) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier))) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier))) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier))) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier))) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier))) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier))) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier))) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)))))))) |
static long Examine ( long countM , long countA , long countR , long countC , long countH ) {
long count = 0 ;
count += countR * countC * countH ;
count += countA * countC * countH ;
count += countA * countR * countH ;
count += countA * countR * countC ;
count += countM * countC * countH ;
count += countM * countR * countH ;
count += countM * countR * countC ;
count += countM * countA * countH ;
count += countM * countA * countC ;
count += countM * countA * countR ;
return count ;
}
| static long Examine ( long countM , long countA , long countR , long countC , long countH ) { long count = 0 ; count += countR * countC * countH ; count += countA * countC * countH ; count += countA * countR * countH ; count += countA * countR * countC ; count += countM * countC * countH ; count += countM * countR * countH ; count += countM * countR * countC ; count += countM * countA * countH ; count += countM * countA * countC ; count += countM * countA * countR ; return count ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (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: (binary_expression left: (identifier) right: (identifier)) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)))) (return_statement (identifier)))) |
public static void main ( String [ ] args ) {
Scanner sc = new Scanner ( System . in ) ;
int N = sc . nextInt ( ) ;
String [ ] names = new String [ N ] ;
long countM = 0 ;
long countA = 0 ;
long countR = 0 ;
long countC = 0 ;
long countH = 0 ;
String [ ] I = new String [ N ] ;
for ( int i = 0 ;
i < N ;
i ++ ) {
names [ i ] = sc . next ( ) ;
I [ i ] = names [ i ] . substring ( 0 , 1 ) ;
}
for ( int k = 0 ;
k < N ;
k ++ ) {
if ( I [ k ] . equals ( "M" ) ) countM ++ ;
else if ( I [ k ] . equals ( "A" ) ) countA ++ ;
else if ( I [ k ] . equals ( "R" ) ) countR ++ ;
else if ( I [ k ] . equals ( "C" ) ) countC ++ ;
else if ( I [ k ] . equals ( "H" ) ) countH ++ ;
}
System . out . println ( Examine ( countM , countA , countR , countC , countH ) ) ;
sc . close ( ) ;
}
| public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; String [ ] names = new String [ N ] ; long countM = 0 ; long countA = 0 ; long countR = 0 ; long countC = 0 ; long countH = 0 ; String [ ] I = new String [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { names [ i ] = sc . next ( ) ; I [ i ] = names [ i ] . substring ( 0 , 1 ) ; } for ( int k = 0 ; k < N ; k ++ ) { if ( I [ k ] . equals ( " M " ) ) countM ++ ; else if ( I [ k ] . equals ( " A " ) ) countA ++ ; else if ( I [ k ] . equals ( " R " ) ) countR ++ ; else if ( I [ k ] . equals ( " C " ) ) countC ++ ; else if ( I [ k ] . equals ( " H " ) ) countH ++ ; } System . out . println ( Examine ( countM , countA , countR , countC , countH ) ) ; sc . close ( ) ; } | (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 (field_access object: (identifier) field: (identifier)))))) (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: (array_type element: (type_identifier) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (type_identifier) dimensions: (dimensions_expr (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (array_type element: (type_identifier) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (type_identifier) 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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (array_access array: (identifier) index: (identifier)) name: (identifier) arguments: (argument_list (decimal_integer_literal) (decimal_integer_literal))))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (method_invocation object: (array_access array: (identifier) index: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) consequence: (expression_statement (update_expression (identifier))) alternative: (if_statement condition: (parenthesized_expression (method_invocation object: (array_access array: (identifier) index: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) consequence: (expression_statement (update_expression (identifier))) alternative: (if_statement condition: (parenthesized_expression (method_invocation object: (array_access array: (identifier) index: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) consequence: (expression_statement (update_expression (identifier))) alternative: (if_statement condition: (parenthesized_expression (method_invocation object: (array_access array: (identifier) index: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) consequence: (expression_statement (update_expression (identifier))) alternative: (if_statement condition: (parenthesized_expression (method_invocation object: (array_access array: (identifier) index: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) consequence: (expression_statement (update_expression (identifier)))))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier) (identifier) (identifier)))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) |
public static void main ( String [ ] args ) {
Scanner sc = new Scanner ( System . in ) ;
int N = sc . nextInt ( ) ;
long [ ] startNum = new long [ 'Z' - 'A' + 1 ] ;
for ( int i = 0 ;
i < N ;
i ++ ) {
String str = sc . next ( ) ;
startNum [ str . charAt ( 0 ) - 'A' ] ++ ;
}
long comb = 0 ;
char [ ] march = new char [ ] {
'M' , 'A' , 'R' , 'C' , 'H' };
for ( int i = 0 ;
i < march . length ;
i ++ ) {
for ( int j = i + 1 ;
j < march . length ;
j ++ ) {
for ( int k = j + 1 ;
k < march . length ;
k ++ ) {
comb += startNum [ march [ i ] - 'A' ] * startNum [ march [ j ] - 'A' ] * startNum [ march [ k ] - 'A' ] ;
}
}
}
out . println ( comb ) ;
}
| public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; long [ ] startNum = new long [ ' Z ' - ' A ' + 1 ] ; for ( int i = 0 ; i < N ; i ++ ) { String str = sc . next ( ) ; startNum [ str . charAt ( 0 ) - ' A ' ] ++ ; } long comb = 0 ; char [ ] march = new char [ ] { ' M ' , ' A ' , ' R ' , ' C ' , ' H ' } ; for ( int i = 0 ; i < march . length ; i ++ ) { for ( int j = i + 1 ; j < march . length ; j ++ ) { for ( int k = j + 1 ; k < march . length ; k ++ ) { comb += startNum [ march [ i ] - ' A ' ] * startNum [ march [ j ] - ' A ' ] * startNum [ march [ k ] - ' A ' ] ; } } } out . println ( comb ) ; } | (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 (field_access object: (identifier) field: (identifier)))))) (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: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (binary_expression left: (character_literal) right: (character_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 (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (update_expression (array_access array: (identifier) index: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal))) right: (character_literal))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions) value: (array_initializer (character_literal) (character_literal) (character_literal) (character_literal) (character_literal))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (field_access object: (identifier) field: (identifier))) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (field_access object: (identifier) field: (identifier))) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (field_access object: (identifier) field: (identifier))) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (character_literal))) right: (array_access array: (identifier) index: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (character_literal)))) right: (array_access array: (identifier) index: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (character_literal)))))))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))) |
public static void main ( String [ ] args ) throws IOException {
Scanner in = new Scanner ( System . in ) ;
int N = in . nextInt ( ) ;
long [ ] march = new long [ 5 ] ;
String marchS = "MARCH" ;
for ( int i = 0 ;
i < N ;
i ++ ) {
String S = in . next ( ) . substring ( 0 , 1 ) ;
for ( int j = 0 ;
j < 5 ;
j ++ ) {
if ( S . equals ( String . valueOf ( marchS . charAt ( j ) ) ) ) {
march [ j ] ++ ;
break ;
}
}
}
long ans = 0 ;
for ( int i = 0 ;
i < 5 - 2 ;
i ++ ) {
for ( int j = i + 1 ;
j < 5 - 1 ;
j ++ ) {
for ( int k = j + 1 ;
k < 5 ;
k ++ ) {
ans += march [ i ] * march [ j ] * march [ k ] ;
}
}
}
System . out . println ( ans ) ;
}
| public static void main ( String [ ] args ) throws IOException { Scanner in = new Scanner ( System . in ) ; int N = in . nextInt ( ) ; long [ ] march = new long [ 5 ] ; String marchS = " MARCH " ; for ( int i = 0 ; i < N ; i ++ ) { String S = in . next ( ) . substring ( 0 , 1 ) ; for ( int j = 0 ; j < 5 ; j ++ ) { if ( S . equals ( String . valueOf ( marchS . charAt ( j ) ) ) ) { march [ j ] ++ ; break ; } } } long ans = 0 ; for ( int i = 0 ; i < 5 - 2 ; i ++ ) { for ( int j = i + 1 ; j < 5 - 1 ; j ++ ) { for ( int k = j + 1 ; k < 5 ; k ++ ) { ans += march [ i ] * march [ j ] * march [ k ] ; } } } System . out . println ( ans ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) (throws (type_identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (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: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (decimal_integer_literal))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (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: (identifier)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list (decimal_integer_literal) (decimal_integer_literal))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))))) consequence: (block (expression_statement (update_expression (array_access array: (identifier) index: (identifier)))) (break_statement))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (binary_expression left: (decimal_integer_literal) right: (decimal_integer_literal))) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (binary_expression left: (decimal_integer_literal) right: (decimal_integer_literal))) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier))) right: (array_access array: (identifier) index: (identifier))))))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier)))))) |
public static void main ( String [ ] args ) throws Exception {
Scanner sc = new Scanner ( System . in ) ;
int N = sc . nextInt ( ) ;
int ans = 1 ;
int tmp = 0 ;
while ( ( tmp + 1 ) * ( tmp + 1 ) <= N ) {
ans = ( tmp + 1 ) * ( tmp + 1 ) ;
tmp ++ ;
}
System . out . println ( ans ) ;
}
| public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int ans = 1 ; int tmp = 0 ; while ( ( tmp + 1 ) * ( tmp + 1 ) <= N ) { ans = ( tmp + 1 ) * ( tmp + 1 ) ; tmp ++ ; } System . out . println ( ans ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) (throws (type_identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (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: (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: (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: (identifier))) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (expression_statement (update_expression (identifier))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier)))))) |
public static void main ( String [ ] args ) {
InputStream inputStream = System . in ;
OutputStream outputStream = System . out ;
InputReader in = new InputReader ( inputStream ) ;
PrintWriter out = new PrintWriter ( outputStream ) ;
Task solver = new Task ( ) ;
solver . solve ( 1 , in , out ) ;
out . close ( ) ;
}
| public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } | (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: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier) (identifier)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) |
public static void main ( String [ ] args ) {
B ( ) ;
}
| public static void main ( String [ ] args ) { 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 (expression_statement (method_invocation name: (identifier) arguments: (argument_list))))) |
public static void A ( ) {
Scanner sc = new Scanner ( System . in ) ;
String s1 = sc . next ( ) ;
String s2 = sc . next ( ) ;
for ( int i = 0 ;
i < 3 ;
i ++ ) {
if ( s1 . charAt ( i ) != s2 . charAt ( 2 - i ) ) {
System . out . println ( "NO" ) ;
return ;
}
}
System . out . println ( "YES" ) ;
}
| public static void A ( ) { Scanner sc = new Scanner ( System . in ) ; String s1 = sc . next ( ) ; String s2 = sc . next ( ) ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s1 . charAt ( i ) != s2 . charAt ( 2 - i ) ) { System . out . println ( " NO " ) ; return ; } } System . out . println ( " YES " ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (decimal_integer_literal) right: (identifier)))))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) (return_statement))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))))) |
public static long binsearchN2 ( long left , long right , int N ) {
if ( left >= right ) return ( long ) Math . pow ( right , 2 ) ;
long mid = ( left + right ) / 2 ;
if ( Math . pow ( mid , 2 ) > N ) return binsearchN2 ( left , mid - 1 , N ) ;
else {
if ( Math . pow ( mid + 1 , 2 ) > N ) return ( long ) Math . pow ( mid , 2 ) ;
else return binsearchN2 ( mid + 1 , right , N ) ;
}
}
| public static long binsearchN2 ( long left , long right , int N ) { if ( left >= right ) return ( long ) Math . pow ( right , 2 ) ; long mid = ( left + right ) / 2 ; if ( Math . pow ( mid , 2 ) > N ) return binsearchN2 ( left , mid - 1 , N ) ; else { if ( Math . pow ( mid + 1 , 2 ) > N ) return ( long ) Math . pow ( mid , 2 ) ; else return binsearchN2 ( mid + 1 , right , N ) ; } } | (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: (identifier))) consequence: (return_statement (cast_expression type: (integral_type) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal))) right: (identifier))) consequence: (return_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier)))) alternative: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (decimal_integer_literal))) right: (identifier))) consequence: (return_statement (cast_expression type: (integral_type) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal))))) alternative: (return_statement (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier) (identifier))))))))) |
public static void B ( ) {
Scanner sc = new Scanner ( System . in ) ;
int N = sc . nextInt ( ) ;
System . out . println ( binsearchN2 ( 0 , N , N ) ) ;
}
| public static void B ( ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; System . out . println ( binsearchN2 ( 0 , N , N ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier) (identifier)))))))) |
public static void main ( String [ ] args ) throws Exception {
BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ;
int n = Integer . parseInt ( input . readLine ( ) ) ;
System . out . println ( ( int ) Math . pow ( ( int ) Math . sqrt ( n ) , 2 ) ) ;
}
| public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( input . readLine ( ) ) ; System . out . println ( ( int ) Math . pow ( ( int ) Math . sqrt ( n ) , 2 ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) (throws (type_identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (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 (cast_expression type: (integral_type) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (cast_expression type: (integral_type) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (decimal_integer_literal))))))))) |
public static void main ( String [ ] args ) {
InputStream inputStream = System . in ;
OutputStream outputStream = System . out ;
Scanner in = new Scanner ( inputStream ) ;
PrintWriter out = new PrintWriter ( outputStream ) ;
TaskB solver = new TaskB ( ) ;
solver . solve ( 1 , in , out ) ;
out . close ( ) ;
}
| public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskB solver = new TaskB ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } | (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: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier) (identifier)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) |
public static void main ( String [ ] args ) throws Exception {
Scanner sc = new Scanner ( System . in ) ;
int X = sc . nextInt ( ) ;
int Y = sc . nextInt ( ) ;
int Z = sc . nextInt ( ) ;
sc . close ( ) ;
X = X - Z ;
int ans = 0 ;
while ( X >= 0 ) {
X = X - ( Y + Z ) ;
ans ++ ;
}
System . out . println ( ans == 0 ? 0 : ans - 1 ) ;
}
| public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int X = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; int Z = sc . nextInt ( ) ; sc . close ( ) ; X = X - Z ; int ans = 0 ; while ( X >= 0 ) { X = X - ( Y + Z ) ; ans ++ ; } System . out . println ( ans == 0 ? 0 : ans - 1 ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) (throws (type_identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (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)))) (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: (identifier) name: (identifier) arguments: (argument_list))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (identifier)))))) (expression_statement (update_expression (identifier))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (ternary_expression condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) consequence: (decimal_integer_literal) alternative: (binary_expression left: (identifier) right: (decimal_integer_literal)))))))) |
public static void main ( String [ ] args ) throws IOException {
BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ;
StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ;
int x = Integer . parseInt ( tokenizer . nextToken ( ) ) ;
int y = Integer . parseInt ( tokenizer . nextToken ( ) ) ;
int z = Integer . parseInt ( tokenizer . nextToken ( ) ) ;
x -= z ;
if ( x < 1 ) {
System . out . println ( 0 ) ;
}
else {
System . out . println ( x / ( y + z ) ) ;
}
}
| public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; int x = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int y = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int z = Integer . parseInt ( tokenizer . nextToken ( ) ) ; x -= z ; if ( x < 1 ) { System . out . println ( 0 ) ; } else { System . out . println ( x / ( y + z ) ) ; } } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) (throws (type_identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (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 (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 (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 (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (expression_statement (assignment_expression left: (identifier) right: (identifier))) (if_statement condition: (parenthesized_expression (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 (decimal_integer_literal))))) alternative: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))))))))))) |
public static void main ( String [ ] args ) {
B ( ) ;
}
| public static void main ( String [ ] args ) { 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 (expression_statement (method_invocation name: (identifier) arguments: (argument_list))))) |
public static void A ( ) {
Scanner sc = new Scanner ( System . in ) ;
String s1 = sc . next ( ) ;
String s2 = sc . next ( ) ;
if ( s1 . compareTo ( s2 ) < 0 ) System . out . println ( "<" ) ;
else if ( s1 . compareTo ( s2 ) == 0 ) System . out . println ( "=" ) ;
else System . out . println ( ">" ) ;
}
| public static void A ( ) { Scanner sc = new Scanner ( System . in ) ; String s1 = sc . next ( ) ; String s2 = sc . next ( ) ; if ( s1 . compareTo ( s2 ) < 0 ) System . out . println ( " < " ) ; else if ( s1 . compareTo ( s2 ) == 0 ) System . out . println ( " = " ) ; else System . out . println ( " > " ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (type_identifier) 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 (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: (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (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 B ( ) {
Scanner sc = new Scanner ( System . in ) ;
int X = sc . nextInt ( ) ;
int Y = sc . nextInt ( ) ;
int Z = sc . nextInt ( ) ;
if ( X < Y || X < Z ) {
System . out . println ( 0 ) ;
return ;
}
X -= Z ;
System . out . println ( X / ( Y + Z ) ) ;
}
| public static void B ( ) { Scanner sc = new Scanner ( System . in ) ; int X = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; int Z = sc . nextInt ( ) ; if ( X < Y || X < Z ) { System . out . println ( 0 ) ; return ; } X -= Z ; System . out . println ( X / ( Y + Z ) ) ; } | (method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (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)))) (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: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (identifier) right: (identifier)))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (decimal_integer_literal)))) (return_statement))) (expression_statement (assignment_expression left: (identifier) right: (identifier))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))))))))) |
public static void main ( String [ ] args ) {
Scanner sc = new Scanner ( System . in ) ;
int x = sc . nextInt ( ) ;
int y = sc . nextInt ( ) ;
int z = sc . nextInt ( ) ;
int ans = x / ( z + y ) ;
if ( ans * ( z + y ) + z <= x ) System . out . println ( ans ) ;
else System . out . println ( ans - 1 ) ;
}
| public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int z = sc . nextInt ( ) ; int ans = x / ( z + y ) ; if ( ans * ( z + y ) + z <= x ) System . out . println ( ans ) ; else System . out . println ( ans - 1 ) ; } | (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 (field_access object: (identifier) field: (identifier)))))) (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)))) (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: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (identifier)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (identifier)))) right: (identifier)) right: (identifier))) 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 (binary_expression left: (identifier) right: (decimal_integer_literal)))))))) |
public static void main ( String [ ] args ) {
Scanner sc = new Scanner ( System . in ) ;
int x = sc . nextInt ( ) ;
int y = sc . nextInt ( ) ;
int z = sc . nextInt ( ) ;
int semians = x / ( y + z ) ;
if ( x % ( y + z ) < z ) semians -= 1 ;
System . out . println ( semians ) ;
}
| public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int z = sc . nextInt ( ) ; int semians = x / ( y + z ) ; if ( x % ( y + z ) < z ) semians -= 1 ; System . out . println ( semians ) ; } | (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 (field_access object: (identifier) field: (identifier)))))) (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)))) (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: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (identifier)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (identifier)))) right: (identifier))) consequence: (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 (identifier)))))) |
public static void main ( String [ ] args ) {
Scanner sc = new Scanner ( System . in ) ;
int N = sc . nextInt ( ) ;
int M = sc . nextInt ( ) ;
int [ ] x = new int [ M ] ;
int [ ] y = new int [ M ] ;
ArrayList [ ] edge = new ArrayList [ N ] ;
for ( int i = 0 ;
i < N ;
i ++ ) {
edge [ i ] = new ArrayList ( ) ;
}
for ( int i = 0 ;
i < M ;
i ++ ) {
x [ i ] = sc . nextInt ( ) - 1 ;
y [ i ] = sc . nextInt ( ) - 1 ;
edge [ x [ i ] ] . add ( y [ i ] ) ;
}
long [ ] dp = new long [ ( int ) Math . pow ( 2 , N ) ] ;
dp [ 0 ] = 1 ;
for ( int i = 1 ;
i < ( int ) Math . pow ( 2 , N ) ;
i ++ ) {
for ( int j = 0 ;
j < N ;
j ++ ) {
if ( ( i & ( 1 << j ) ) != 0 ) {
boolean flg = true ;
for ( int k = 0 ;
k < N ;
k ++ ) {
if ( ( i & ( 1 << k ) ) != 0 && edge [ j ] . contains ( k ) ) flg = false ;
}
if ( flg ) dp [ i ] += dp [ i - ( 1 << j ) ] ;
}
}
}
System . out . println ( dp [ ( int ) Math . pow ( 2 , N ) - 1 ] ) ;
}
| public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] x = new int [ M ] ; int [ ] y = new int [ M ] ; ArrayList [ ] edge = new ArrayList [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { edge [ i ] = new ArrayList ( ) ; } for ( int i = 0 ; i < M ; i ++ ) { x [ i ] = sc . nextInt ( ) - 1 ; y [ i ] = sc . nextInt ( ) - 1 ; edge [ x [ i ] ] . add ( y [ i ] ) ; } long [ ] dp = new long [ ( int ) Math . pow ( 2 , N ) ] ; dp [ 0 ] = 1 ; for ( int i = 1 ; i < ( int ) Math . pow ( 2 , N ) ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( ( i & ( 1 << j ) ) != 0 ) { boolean flg = true ; for ( int k = 0 ; k < N ; k ++ ) { if ( ( i & ( 1 << k ) ) != 0 && edge [ j ] . contains ( k ) ) flg = false ; } if ( flg ) dp [ i ] += dp [ i - ( 1 << j ) ] ; } } } System . out . println ( dp [ ( int ) Math . pow ( 2 , N ) - 1 ] ) ; } | (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 (field_access object: (identifier) field: (identifier)))))) (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)))) (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))))) (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))))) (local_variable_declaration type: (array_type element: (type_identifier) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (type_identifier) 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: (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: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)))) (expression_statement (method_invocation object: (array_access array: (identifier) index: (array_access array: (identifier) index: (identifier))) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier))))))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (cast_expression type: (integral_type) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier)))))))) (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: (cast_expression type: (integral_type) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier))))) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (decimal_integer_literal) right: (identifier))))) right: (decimal_integer_literal))) consequence: (block (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (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: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (decimal_integer_literal) right: (identifier))))) right: (decimal_integer_literal)) right: (method_invocation object: (array_access array: (identifier) index: (identifier)) name: (identifier) arguments: (argument_list (identifier))))) consequence: (expression_statement (assignment_expression left: (identifier) right: (false)))))) (if_statement condition: (parenthesized_expression (identifier)) consequence: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (decimal_integer_literal) right: (identifier)))))))))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (binary_expression left: (cast_expression type: (integral_type) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier)))) right: (decimal_integer_literal)))))))) |
public static void main ( String [ ] args ) {
new Main ( ) . compute ( ) ;
}
| public static void main ( String [ ] args ) { new Main ( ) . compute ( ) ; } | (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: (object_creation_expression type: (type_identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list))))) |
public static void main ( String [ ] args ) {
MyScanner sc = new MyScanner ( ) ;
out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ;
int n = sc . nextInt ( ) ;
int m = sc . nextInt ( ) ;
int [ ] g = new int [ n ] ;
for ( int i = 0 ;
i < m ;
++ i ) {
int x = sc . nextInt ( ) - 1 ;
int y = sc . nextInt ( ) - 1 ;
g [ x ] |= 1 << y ;
}
long [ ] dp = new long [ 1 << n ] ;
dp [ 0 ] = 1 ;
for ( int b = 1 ;
b < 1 << n ;
++ b ) {
for ( int i = 0 ;
i < n ;
++ i ) {
if ( ( b & 1 << i ) == 0 ) continue ;
if ( ( ( b ^ 1 << i ) & g [ i ] ) == 0 ) dp [ b ] += dp [ b ^ 1 << i ] ;
}
}
out . println ( dp [ ( 1 << n ) - 1 ] ) ;
out . close ( ) ;
}
| public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] g = new int [ n ] ; for ( int i = 0 ; i < m ; ++ i ) { int x = sc . nextInt ( ) - 1 ; int y = sc . nextInt ( ) - 1 ; g [ x ] |= 1 << y ; } long [ ] dp = new long [ 1 << n ] ; dp [ 0 ] = 1 ; for ( int b = 1 ; b < 1 << n ; ++ b ) { for ( int i = 0 ; i < n ; ++ i ) { if ( ( b & 1 << i ) == 0 ) continue ; if ( ( ( b ^ 1 << i ) & g [ i ] ) == 0 ) dp [ b ] += dp [ b ^ 1 << i ] ; } } out . println ( dp [ ( 1 << n ) - 1 ] ) ; out . close ( ) ; } | (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)))) (expression_statement (assignment_expression left: (identifier) right: (object_creation_expression type: (type_identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))))) (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)))) (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 (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (decimal_integer_literal) right: (identifier)))))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (decimal_integer_literal) right: (identifier)))))) (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: (binary_expression left: (decimal_integer_literal) right: (identifier))) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (decimal_integer_literal) right: (identifier)))) right: (decimal_integer_literal))) consequence: (continue_statement)) (if_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (decimal_integer_literal) right: (identifier)))) right: (array_access array: (identifier) index: (identifier)))) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (binary_expression left: (decimal_integer_literal) right: (identifier))))))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (binary_expression left: (parenthesized_expression (binary_expression left: (decimal_integer_literal) right: (identifier))) right: (decimal_integer_literal)))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) |
public static void main ( String [ ] args ) {
Scanner sc = new Scanner ( System . in ) ;
int N = Integer . parseInt ( sc . next ( ) ) ;
int M = Integer . parseInt ( sc . next ( ) ) ;
Node [ ] nodes = new Node [ N ] ;
for ( int i = 0 ;
i < N ;
i ++ ) nodes [ i ] = new Node ( i ) ;
for ( int i = 0 ;
i < M ;
i ++ ) {
Node x = nodes [ Integer . parseInt ( sc . next ( ) ) - 1 ] ;
Node y = nodes [ Integer . parseInt ( sc . next ( ) ) - 1 ] ;
x . neighbor . put ( y , 1 ) ;
}
sc . close ( ) ;
int S = 1 << N ;
long [ ] dp = new long [ S ] ;
dp [ 0 ] = 1 ;
Queue < Integer > que = new ArrayDeque < > ( ) ;
que . add ( 0 ) ;
while ( ! que . isEmpty ( ) ) {
int s = que . remove ( ) ;
for ( int i = 0 ;
i < N ;
i ++ ) {
if ( ( 1 << i & s ) > 0 ) continue ;
boolean check = true ;
for ( int j = 0 ;
j < N ;
j ++ ) {
if ( ( 1 << j & s ) > 0 && nodes [ i ] . neighbor . containsKey ( nodes [ j ] ) ) {
check = false ;
break ;
}
}
if ( check ) {
if ( dp [ s + ( 1 << i ) ] == 0 ) {
que . add ( s + ( 1 << i ) ) ;
}
dp [ s + ( 1 << i ) ] += dp [ s ] ;
}
}
}
System . out . println ( dp [ S - 1 ] ) ;
}
| public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = Integer . parseInt ( sc . next ( ) ) ; int M = Integer . parseInt ( sc . next ( ) ) ; Node [ ] nodes = new Node [ N ] ; for ( int i = 0 ; i < N ; i ++ ) nodes [ i ] = new Node ( i ) ; for ( int i = 0 ; i < M ; i ++ ) { Node x = nodes [ Integer . parseInt ( sc . next ( ) ) - 1 ] ; Node y = nodes [ Integer . parseInt ( sc . next ( ) ) - 1 ] ; x . neighbor . put ( y , 1 ) ; } sc . close ( ) ; int S = 1 << N ; long [ ] dp = new long [ S ] ; dp [ 0 ] = 1 ; Queue < Integer > que = new ArrayDeque < > ( ) ; que . add ( 0 ) ; while ( ! que . isEmpty ( ) ) { int s = que . remove ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( ( 1 << i & s ) > 0 ) continue ; boolean check = true ; for ( int j = 0 ; j < N ; j ++ ) { if ( ( 1 << j & s ) > 0 && nodes [ i ] . neighbor . containsKey ( nodes [ j ] ) ) { check = false ; break ; } } if ( check ) { if ( dp [ s + ( 1 << i ) ] == 0 ) { que . add ( s + ( 1 << i ) ) ; } dp [ s + ( 1 << i ) ] += dp [ s ] ; } } } System . out . println ( dp [ S - 1 ] ) ; } | (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 (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (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 (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (local_variable_declaration type: (array_type element: (type_identifier) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (type_identifier) dimensions: (dimensions_expr (identifier))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (object_creation_expression type: (type_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: (type_identifier) declarator: (variable_declarator name: (identifier) value: (array_access array: (identifier) index: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) right: (decimal_integer_literal))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (array_access array: (identifier) index: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) right: (decimal_integer_literal))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal)))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (decimal_integer_literal) right: (identifier)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal)))) (while_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (binary_expression left: (decimal_integer_literal) right: (identifier)) right: (identifier))) right: (decimal_integer_literal))) consequence: (continue_statement)) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (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: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (binary_expression left: (decimal_integer_literal) right: (identifier)) right: (identifier))) right: (decimal_integer_literal)) right: (method_invocation object: (field_access object: (array_access array: (identifier) index: (identifier)) field: (identifier)) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)))))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (false))) (break_statement))))) (if_statement condition: (parenthesized_expression (identifier)) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (decimal_integer_literal) right: (identifier))))) right: (decimal_integer_literal))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (decimal_integer_literal) right: (identifier))))))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (decimal_integer_literal) right: (identifier))))) right: (array_access array: (identifier) index: (identifier)))))))))) (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 ) {
Scanner scan = new Scanner ( System . in ) ;
N = scan . nextInt ( ) ;
int M = scan . nextInt ( ) ;
two = new int [ N ] ;
two [ 0 ] = 1 ;
for ( int i = 1 ;
i < N ;
i ++ ) {
two [ i ] = two [ i - 1 ] * 2 ;
}
xy = new int [ N ] [ N ] ;
for ( int i = 0 ;
i < M ;
i ++ ) {
int x = scan . nextInt ( ) - 1 ;
int y = scan . nextInt ( ) - 1 ;
xy [ y ] [ x ] = - 1 ;
}
dp = new long [ two [ N - 1 ] * 2 ] ;
dp [ 0 ] = 1 ;
System . out . println ( res ( two [ N - 1 ] * 2 - 1 ) ) ;
}
| public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; N = scan . nextInt ( ) ; int M = scan . nextInt ( ) ; two = new int [ N ] ; two [ 0 ] = 1 ; for ( int i = 1 ; i < N ; i ++ ) { two [ i ] = two [ i - 1 ] * 2 ; } xy = new int [ N ] [ N ] ; for ( int i = 0 ; i < M ; i ++ ) { int x = scan . nextInt ( ) - 1 ; int y = scan . nextInt ( ) - 1 ; xy [ y ] [ x ] = - 1 ; } dp = new long [ two [ N - 1 ] * 2 ] ; dp [ 0 ] = 1 ; System . out . println ( res ( two [ N - 1 ] * 2 - 1 ) ) ; } | (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 (field_access object: (identifier) field: (identifier)))))) (expression_statement (assignment_expression left: (identifier) right: (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 (assignment_expression left: (identifier) right: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (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: (decimal_integer_literal)))))) (expression_statement (assignment_expression left: (identifier) right: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier)) 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 (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (unary_expression operand: (decimal_integer_literal)))))) (expression_statement (assignment_expression left: (identifier) right: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal)))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) 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 (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal)) right: (decimal_integer_literal))))))))) |
static long res ( int bit ) {
if ( dp [ bit ] > 0 ) return dp [ bit ] ;
for ( int i = 0 ;
i < N ;
i ++ ) {
if ( ( two [ i ] & bit ) > 0 ) {
if ( admit ( bit - two [ i ] , i ) ) {
dp [ bit ] += res ( bit - two [ i ] ) ;
}
}
}
return dp [ bit ] ;
}
| static long res ( int bit ) { if ( dp [ bit ] > 0 ) return dp [ bit ] ; for ( int i = 0 ; i < N ; i ++ ) { if ( ( two [ i ] & bit ) > 0 ) { if ( admit ( bit - two [ i ] , i ) ) { dp [ bit ] += res ( bit - two [ i ] ) ; } } } return dp [ bit ] ; } | (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: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (return_statement (array_access array: (identifier) index: (identifier)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (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: (identifier))) right: (decimal_integer_literal))) consequence: (block (if_statement condition: (parenthesized_expression (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier))) (identifier)))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier))))))))))))) (return_statement (array_access array: (identifier) index: (identifier))))) |
static boolean admit ( int bit , int k ) {
for ( int i = 0 ;
i < N ;
i ++ ) {
if ( ( two [ i ] & bit ) > 0 ) {
if ( xy [ i ] [ k ] == - 1 ) {
return false ;
}
}
}
return true ;
}
| static boolean admit ( int bit , int k ) { for ( int i = 0 ; i < N ; i ++ ) { if ( ( two [ i ] & bit ) > 0 ) { if ( xy [ i ] [ k ] == - 1 ) { return false ; } } } return true ; } | (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 (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: (identifier))) right: (decimal_integer_literal))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (unary_expression operand: (decimal_integer_literal)))) consequence: (block (return_statement (false)))))))) (return_statement (true)))) |
public static void main ( String [ ] args ) {
Scanner sc = new Scanner ( System . in ) ;
int D = sc . nextInt ( ) ;
System . out . println ( solve ( D ) ) ;
sc . close ( ) ;
}
| public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int D = sc . nextInt ( ) ; System . out . println ( solve ( D ) ) ; sc . close ( ) ; } | (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 (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (identifier)))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) |
static long solve ( int D ) {
if ( D % 9 != 0 ) return 0 ;
D /= 9 ;
long [ ] B = new long [ MAXL ] ;
B [ 0 ] = 1 ;
for ( int i = 1 ;
i < MAXL ;
i ++ ) B [ i ] = B [ i - 1 ] * 10 ;
long ans = 0 ;
for ( int i = 1 ;
i <= MAXL ;
i ++ ) {
N = ( i + 1 ) / 2 ;
v = new long [ N ] ;
for ( int j = 0 ;
j < N ;
j ++ ) for ( int k = j ;
k < i - j ;
k ++ ) v [ j ] += B [ k ] ;
ans += count ( D , i , 0 , new int [ N ] ) ;
}
return ans ;
}
| static long solve ( int D ) { if ( D % 9 != 0 ) return 0 ; D /= 9 ; long [ ] B = new long [ MAXL ] ; B [ 0 ] = 1 ; for ( int i = 1 ; i < MAXL ; i ++ ) B [ i ] = B [ i - 1 ] * 10 ; long ans = 0 ; for ( int i = 1 ; i <= MAXL ; i ++ ) { N = ( i + 1 ) / 2 ; v = new long [ N ] ; for ( int j = 0 ; j < N ; j ++ ) for ( int k = j ; k < i - j ; k ++ ) v [ j ] += B [ k ] ; ans += count ( D , i , 0 , new int [ N ] ) ; } return ans ; } | (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: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (return_statement (decimal_integer_literal))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (identifier) right: (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: (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier))) update: (update_expression (identifier)) body: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier)))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (decimal_integer_literal) (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))))))) (return_statement (identifier)))) |
static long count ( long D , int l , int t , int [ ] x ) {
if ( t == N ) {
if ( D != 0 ) return 0 ;
long ans = 1 ;
for ( int i = 0 ;
i < N ;
i ++ ) {
ans *= ( i == 0 ? 9 : 10 ) - Math . abs ( x [ i ] ) ;
}
if ( l % 2 == 0 ) ans *= 10 ;
return ans ;
}
long ans = 0 ;
for ( int m = - 9 ;
m <= 9 ;
m ++ ) {
if ( - v [ t ] < D + v [ t ] * m && D + v [ t ] * m < v [ t ] ) {
x [ t ] = m ;
ans += count ( D + v [ t ] * m , l , t + 1 , x ) ;
}
}
return ans ;
}
| static long count ( long D , int l , int t , int [ ] x ) { if ( t == N ) { if ( D != 0 ) return 0 ; long ans = 1 ; for ( int i = 0 ; i < N ; i ++ ) { ans *= ( i == 0 ? 9 : 10 ) - Math . abs ( x [ i ] ) ; } if ( l % 2 == 0 ) ans *= 10 ; return ans ; } long ans = 0 ; for ( int m = - 9 ; m <= 9 ; m ++ ) { if ( - v [ t ] < D + v [ t ] * m && D + v [ t ] * m < v [ t ] ) { x [ t ] = m ; ans += count ( D + v [ t ] * m , l , t + 1 , x ) ; } } 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: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (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: (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 (ternary_expression condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) consequence: (decimal_integer_literal) alternative: (decimal_integer_literal))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier))))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal)))) (return_statement (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: (unary_expression operand: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (unary_expression operand: (array_access array: (identifier) index: (identifier))) right: (binary_expression left: (identifier) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier)))) right: (binary_expression left: (binary_expression left: (identifier) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))) right: (array_access array: (identifier) index: (identifier))))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))) (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier))))))))) (return_statement (identifier)))) |
public static long [ ] buildValues ( int d ) {
long [ ] res = new long [ d / 2 ] ;
long high = ( long ) Math . pow ( 10 , d - 1 ) ;
long low = 1L ;
for ( int i = 0 ;
i < d / 2 ;
i ++ ) {
res [ i ] = high - low ;
high /= 10 ;
low *= 10 ;
}
return res ;
}
| public static long [ ] buildValues ( int d ) { long [ ] res = new long [ d / 2 ] ; long high = ( long ) Math . pow ( 10 , d - 1 ) ; long low = 1L ; for ( int i = 0 ; i < d / 2 ; i ++ ) { res [ i ] = high - low ; high /= 10 ; low *= 10 ; } return res ; } | (method_declaration (modifiers) type: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (cast_expression type: (integral_type) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (binary_expression left: (identifier) right: (decimal_integer_literal))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (identifier) 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 long calc ( long [ ] vs , long D ) {
long res = 1 ;
long ten = 10 ;
for ( int i = 0 ;
i < vs . length ;
i ++ ) {
long now = 0 ;
while ( D % ten != 0 && now < 9 ) {
D -= vs [ i ] ;
now ++ ;
}
D = Math . abs ( D ) ;
ten *= 10 ;
res *= ( i == 0 ) ? ( 9 - now ) : ( 10 - now ) ;
}
return D == 0 ? res : 0 ;
}
| public static long calc ( long [ ] vs , long D ) { long res = 1 ; long ten = 10 ; for ( int i = 0 ; i < vs . length ; i ++ ) { long now = 0 ; while ( D % ten != 0 && now < 9 ) { D -= vs [ i ] ; now ++ ; } D = Math . abs ( D ) ; ten *= 10 ; res *= ( i == 0 ) ? ( 9 - now ) : ( 10 - now ) ; } return D == 0 ? res : 0 ; } | (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: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (field_access object: (identifier) field: (identifier))) update: (update_expression (identifier)) body: (block (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: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal)) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) body: (block (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))) (expression_statement (update_expression (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (expression_statement (assignment_expression left: (identifier) right: (ternary_expression condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (parenthesized_expression (binary_expression left: (decimal_integer_literal) right: (identifier))) alternative: (parenthesized_expression (binary_expression left: (decimal_integer_literal) right: (identifier)))))))) (return_statement (ternary_expression condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) consequence: (identifier) alternative: (decimal_integer_literal))))) |
public static void main ( String [ ] args ) {
Scanner in = new Scanner ( System . in ) ;
int D = in . nextInt ( ) ;
long res = 0 ;
for ( int d = 1 ;
d <= 20 ;
d ++ ) {
long [ ] vs = buildValues ( d ) ;
long next = calc ( vs , D ) ;
if ( d % 2 == 1 ) next *= 10 ;
res += next ;
}
System . out . println ( res ) ;
}
| public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int D = in . nextInt ( ) ; long res = 0 ; for ( int d = 1 ; d <= 20 ; d ++ ) { long [ ] vs = buildValues ( d ) ; long next = calc ( vs , D ) ; if ( d % 2 == 1 ) next *= 10 ; res += next ; } System . out . println ( res ) ; } | (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 (field_access object: (identifier) field: (identifier)))))) (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: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (identifier) right: (identifier))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier)))))) |
static int rev ( int x ) {
String s = "0" ;
while ( x > 0 ) {
s += x % 10 + "" ;
x /= 10 ;
}
return Integer . valueOf ( s ) ;
}
| static int rev ( int x ) { String s = "0" ; while ( x > 0 ) { s += x % 10 + " " ; x /= 10 ; } return Integer . valueOf ( s ) ; } | (method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (string_literal))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (string_literal)))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))))) (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))) |
static IntStream REPS ( int v ) {
return IntStream . range ( 0 , v ) ;
}
| static IntStream REPS ( int v ) { return IntStream . range ( 0 , v ) ; } | (method_declaration (modifiers) type: (type_identifier) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier))) body: (block (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier)))))) |
static IntStream REPS ( int l , int r ) {
return IntStream . rangeClosed ( l , r ) ;
}
| static IntStream REPS ( int l , int r ) { return IntStream . rangeClosed ( l , r ) ; } | (method_declaration (modifiers) type: (type_identifier) 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 object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier)))))) |