├── templates ├── classic.rs ├── single.rs ├── multi_eof.rs ├── interactive.rs ├── multi_number.rs ├── main │ ├── stdin.rs │ ├── stdout.rs │ ├── main.rs │ ├── file_in.rs │ ├── file_out.rs │ └── regex.rs ├── build.rs ├── Cargo.toml ├── main.rs └── sites │ └── meta.rs ├── algo_lib ├── tests │ ├── grid │ │ ├── 1.ans │ │ ├── 2.ans │ │ ├── 3.ans │ │ ├── 1.in │ │ ├── 2.in │ │ └── 3.in │ ├── s_mil │ │ ├── 3.ans │ │ ├── 4.ans │ │ ├── 3.in │ │ ├── 4.in │ │ ├── 2.in │ │ ├── 1.ans │ │ ├── 1.in │ │ └── 2.ans │ ├── veci │ │ ├── 1.ans │ │ ├── 1.in │ │ ├── 2.ans │ │ ├── 2.in │ │ ├── 3.ans │ │ └── 3.in │ ├── a_bproblem │ │ ├── 1.ans │ │ ├── 2.ans │ │ ├── .failed_999.ans │ │ ├── 1.in │ │ ├── 2.in │ │ └── .failed_999.in │ ├── a_list_game │ │ ├── 2.ans │ │ ├── 1.ans │ │ ├── 1.in │ │ └── 2.in │ ├── d_borders │ │ ├── 1.ans │ │ ├── 2.ans │ │ ├── 2.in │ │ ├── 3.ans │ │ ├── 4.ans │ │ ├── 4.in │ │ ├── 1.in │ │ └── 3.in │ ├── dominos │ │ ├── 1.ans │ │ └── 1.in │ ├── h_two_sat │ │ ├── 2.ans │ │ ├── 1.ans │ │ ├── 1.in │ │ └── 2.in │ ├── ucucp_11_o │ │ ├── 1.ans │ │ ├── 2.ans │ │ ├── .failed_999.ans │ │ ├── .failed_996.ans │ │ ├── .failed_997.ans │ │ ├── .failed_998.ans │ │ ├── .failed_997.in │ │ ├── .0.in │ │ ├── .failed_999.in │ │ ├── 1.in │ │ ├── .failed_998.in │ │ ├── .failed_996.in │ │ └── 2.in │ ├── a_next │ │ ├── 1.ans │ │ ├── .failed_998.ans │ │ ├── 1.in │ │ ├── .failed_999.ans │ │ ├── .failed_998.in │ │ └── .failed_999.in │ ├── a_suffix_array_1 │ │ ├── 4.in │ │ ├── 1.in │ │ ├── 2.in │ │ ├── 4.ans │ │ ├── 2.ans │ │ ├── 3.in │ │ ├── 1.ans │ │ └── 3.ans │ ├── a_suffix_array_2 │ │ ├── 4.in │ │ ├── 1.in │ │ ├── 2.in │ │ ├── 4.ans │ │ ├── 2.ans │ │ ├── 3.in │ │ ├── 1.ans │ │ └── 3.ans │ ├── candy_division │ │ ├── 1.in │ │ └── 1.ans │ ├── coast_length │ │ ├── 1.ans │ │ └── 1.in │ ├── d_inca_rituals │ │ ├── 1.ans │ │ ├── 1.in │ │ ├── 2.ans │ │ └── 2.in │ ├── digit_product │ │ ├── 1.ans │ │ ├── 1.in │ │ ├── 2.ans │ │ └── 2.in │ ├── download_speed │ │ ├── 0.ans │ │ ├── 1.ans │ │ ├── 1.in │ │ └── 0.in │ ├── e_refrain │ │ ├── 2.in │ │ ├── 0.in │ │ ├── 2.ans │ │ ├── 1.ans │ │ ├── 3.in │ │ ├── 1.in │ │ └── 3.ans │ ├── f_insert │ │ ├── 1.ans │ │ ├── 2.ans │ │ ├── 1.in │ │ └── 2.in │ ├── g_fine_triplets │ │ ├── 1.ans │ │ ├── 2.ans │ │ ├── 3.ans │ │ ├── 1.in │ │ ├── 3.in │ │ └── 2.in │ ├── hragreining │ │ ├── 1.in │ │ ├── 2.in │ │ ├── 3.in │ │ ├── 1.ans │ │ ├── 3.ans │ │ └── 2.ans │ ├── kovzanka │ │ ├── 1.ans │ │ └── 1.in │ ├── lizhnya │ │ ├── 1.ans │ │ └── 1.in │ ├── lost_lineup │ │ ├── 1.ans │ │ ├── 1.in │ │ ├── 2.ans │ │ └── 2.in │ ├── m_cup_trick │ │ ├── 1.ans │ │ ├── 2.ans │ │ ├── 3.ans │ │ ├── 1.in │ │ ├── 2.in │ │ └── 3.in │ ├── maximum_flow │ │ ├── 3.ans │ │ ├── 2.ans │ │ ├── 2.in │ │ ├── 3.in │ │ ├── 1.ans │ │ └── 1.in │ ├── nine_knights │ │ ├── 2.ans │ │ ├── 1.ans │ │ ├── 3.ans │ │ ├── 1.in │ │ ├── 2.in │ │ └── 3.in │ ├── prsteni │ │ ├── 1.in │ │ ├── 1.ans │ │ ├── 2.in │ │ ├── 2.ans │ │ ├── 3.in │ │ └── 3.ans │ ├── similar_pair │ │ ├── 1.ans │ │ └── 1.in │ ├── tochka_vdrzok │ │ ├── 1.ans │ │ └── 1.in │ ├── walrus_weights │ │ ├── 2.ans │ │ ├── 1.ans │ │ ├── 2.in │ │ └── 1.in │ ├── a_feast_for_cats │ │ ├── 1.ans │ │ └── 1.in │ ├── a_inversions │ │ ├── 1.ans │ │ └── 1.in │ ├── a_two_out_of_three │ │ ├── 1.ans │ │ ├── 2.ans │ │ ├── 1.in │ │ └── 2.in │ ├── c_bitwise_or_and_and │ │ ├── 2.ans │ │ ├── 1.ans │ │ ├── 2.in │ │ └── 1.in │ ├── f_convolution │ │ ├── 2.ans │ │ ├── 1.ans │ │ ├── 1.in │ │ └── 2.in │ ├── f_periodic_substring │ │ ├── 1.ans │ │ ├── 2.ans │ │ ├── 3.ans │ │ ├── 4.ans │ │ ├── 5.ans │ │ ├── 5.in │ │ ├── 2.in │ │ ├── 3.in │ │ ├── 4.in │ │ └── 1.in │ ├── fenwick_tree │ │ ├── 1.ans │ │ ├── 2.ans │ │ ├── 2.in │ │ └── 1.in │ ├── j_royal_waterways │ │ ├── 1.ans │ │ ├── 2.ans │ │ ├── 3.ans │ │ ├── 2.in │ │ ├── 1.in │ │ └── 3.in │ ├── m_do_not_turn_back │ │ ├── 1.ans │ │ ├── 2.ans │ │ ├── 3.ans │ │ ├── 1.in │ │ ├── 2.in │ │ └── 3.in │ ├── min_max_paths │ │ ├── 0.ans │ │ ├── 1.ans │ │ ├── 0.in │ │ └── 1.in │ ├── money_matters │ │ ├── 1.ans │ │ ├── 2.ans │ │ ├── 2.in │ │ └── 1.in │ ├── numismatics │ │ ├── 1.ans │ │ └── 1.in │ ├── p3_tally_clicker │ │ ├── 1.in │ │ └── 2.in │ ├── p6_candygrams │ │ ├── 1.ans │ │ ├── .failed_999.ans │ │ ├── .failed_999.in │ │ └── 1.in │ ├── reachable_roads │ │ ├── 1.ans │ │ └── 1.in │ ├── simple_addition │ │ ├── 1.ans │ │ ├── 1.in │ │ ├── 2.ans │ │ └── 2.in │ ├── sliding_window_or │ │ ├── 1.ans │ │ └── 1.in │ ├── sliding_window_sum │ │ ├── 1.ans │ │ └── 1.in │ ├── sliding_window_xor │ │ ├── 1.ans │ │ └── 1.in │ ├── union_find │ │ ├── 1.ans │ │ ├── 2.ans │ │ ├── 1.in │ │ └── 2.in │ ├── a_suffix_array_and_lcp │ │ ├── 1.in │ │ ├── 2.in │ │ ├── 4.in │ │ ├── 3.in │ │ ├── 4.ans │ │ ├── 2.ans │ │ ├── 1.ans │ │ └── 3.ans │ ├── b_inversions_2 │ │ ├── 1.ans │ │ └── 1.in │ ├── c_nested_segments │ │ ├── 1.ans │ │ └── 1.in │ ├── c_sorting_substrings │ │ ├── 2.ans │ │ ├── 2.in │ │ ├── 3.ans │ │ ├── 1.ans │ │ ├── 3.in │ │ └── 1.in │ ├── continuous_median │ │ ├── 1.ans │ │ └── 1.in │ ├── e_earthquakes │ │ ├── 1.ans │ │ └── 1.in │ ├── get_shorty │ │ ├── 1.ans │ │ └── 1.in │ ├── linear_recurrences │ │ ├── 3.ans │ │ ├── 2.ans │ │ ├── 1.ans │ │ ├── 3.in │ │ ├── 2.in │ │ └── 1.in │ ├── pick_up_sticks │ │ ├── 1.ans │ │ └── 1.in │ ├── power_strings │ │ ├── 1.ans │ │ └── 1.in │ ├── sliding_window_minimum │ │ ├── 1.ans │ │ └── 1.in │ ├── supercomputer │ │ ├── 1.ans │ │ └── 1.in │ ├── the_goal │ │ ├── 1.ans │ │ └── 1.in │ ├── wheres_my_internet │ │ ├── 1.ans │ │ ├── 2.ans │ │ ├── 2.in │ │ ├── 3.ans │ │ ├── 3.in │ │ └── 1.in │ ├── a_substring_search │ │ ├── 3.ans │ │ ├── 1.ans │ │ ├── 2.ans │ │ ├── 3.in │ │ ├── 1.in │ │ └── 2.in │ ├── almost_perfect │ │ ├── 1.in │ │ └── 1.ans │ ├── b_counting_substrings │ │ ├── 3.ans │ │ ├── 1.ans │ │ ├── 2.ans │ │ ├── 3.in │ │ ├── 1.in │ │ └── 2.in │ ├── b_longest_common_substring │ │ ├── 1.ans │ │ ├── 2.ans │ │ ├── 3.ans │ │ ├── 4.ans │ │ ├── 1.in │ │ ├── 2.in │ │ ├── 3.in │ │ └── 4.in │ ├── b_multiplication_and_sum │ │ ├── 2.ans │ │ ├── 1.ans │ │ ├── 2.in │ │ └── 1.in │ ├── birthday_party │ │ ├── 1.ans │ │ └── 1.in │ ├── break_and_fix_the_tree │ │ ├── 1.ans │ │ └── 1.in │ ├── class_field_trip │ │ ├── 1.ans │ │ └── 1.in │ ├── d_intersecting_segments │ │ ├── 1.ans │ │ └── 1.in │ ├── e_fog_canyon │ │ ├── 1.ans │ │ └── 1.in │ ├── f_mountain │ │ ├── 1.ans │ │ ├── mou0.ans │ │ ├── 1.in │ │ ├── mou0.in │ │ ├── mou2.ans │ │ ├── 0.ans │ │ ├── mou1.ans │ │ ├── mou3.ans │ │ ├── mou4.ans │ │ ├── 0.in │ │ ├── mou1.in │ │ ├── mou12.ans │ │ ├── mou5.ans │ │ ├── mou6.ans │ │ ├── mou2.in │ │ ├── mou3.in │ │ └── mou11.ans │ ├── g_forward_v2 │ │ ├── 1.in │ │ └── 1.ans │ ├── kannas_friendship │ │ ├── 2.ans │ │ ├── 1.ans │ │ ├── 1.in │ │ └── 2.in │ ├── l_lazy_segment_tree │ │ ├── 1.ans │ │ └── 1.in │ ├── longest_palindrome │ │ ├── 1.ans │ │ ├── 1.in │ │ ├── 2.ans │ │ └── 2.in │ ├── minimum_cost_maximum_flow │ │ ├── 1.ans │ │ ├── 3.ans │ │ ├── 2.ans │ │ ├── 2.in │ │ ├── 3.in │ │ └── 1.in │ ├── next_permutation │ │ ├── 1.ans │ │ └── 1.in │ ├── perfect_pth_powers │ │ ├── 1.ans │ │ └── 1.in │ ├── problems │ │ ├── 1.ans │ │ ├── 2.ans │ │ ├── 1.in │ │ └── 2.in │ ├── subtree_swapping │ │ ├── 1.ans │ │ └── 1.in │ ├── virtual_friends │ │ ├── 1.ans │ │ └── 1.in │ ├── a_addition_to_segment │ │ ├── 1.ans │ │ └── 1.in │ ├── a_number_of_different_substrings │ │ ├── 1.ans │ │ ├── 1.in │ │ ├── 2.ans │ │ ├── 2.in │ │ ├── 3.ans │ │ ├── 4.ans │ │ ├── 4.in │ │ └── 3.in │ ├── b_fenwick_tree │ │ ├── 1.ans │ │ └── 1.in │ ├── b_kth_one │ │ ├── 1.ans │ │ └── 1.in │ ├── c_assignment_to_segment │ │ ├── 1.ans │ │ └── 1.in │ ├── chinese_remainder │ │ ├── 1.ans │ │ └── 1.in │ ├── cookie_selection │ │ ├── 1.ans │ │ ├── 2.ans │ │ ├── 1.in │ │ └── 2.in │ ├── d_maxflow │ │ ├── 1.ans │ │ └── 1.in │ ├── d_problem_about_weighted_sum │ │ ├── 1.ans │ │ └── 1.in │ ├── direct_connections │ │ ├── 1.ans │ │ └── 1.in │ ├── e_addition_to_segment │ │ ├── 1.ans │ │ └── 1.in │ ├── e_forward │ │ └── 1.in │ ├── f_decoding_the_maya_code │ │ ├── .failed_996.ans │ │ ├── .failed_997.ans │ │ ├── .failed_998.ans │ │ ├── .failed_999.ans │ │ ├── 1.ans │ │ ├── 2.ans │ │ ├── .failed_996.in │ │ ├── 1.in │ │ ├── .failed_998.in │ │ ├── 2.in │ │ ├── .failed_997.in │ │ └── .failed_999.in │ ├── i_bingo │ │ ├── 1.ans │ │ └── 1.in │ ├── j_segment_tree │ │ ├── 1.ans │ │ └── 1.in │ ├── kattiss_quest │ │ ├── 1.ans │ │ └── 1.in │ ├── kinds_of_people │ │ ├── 1.ans │ │ ├── 2.ans │ │ ├── 1.in │ │ └── 2.in │ ├── polygon_area │ │ ├── 1.ans │ │ └── 1.in │ ├── string_matching │ │ ├── 1.ans │ │ └── 1.in │ ├── ucup_11_a │ │ ├── 1.in │ │ ├── 1.ans │ │ ├── 2.ans │ │ └── 2.in │ ├── a_addition_and_minimum │ │ ├── 1.ans │ │ └── 1.in │ ├── a_disjoint_set_union │ │ ├── 1.ans │ │ └── 1.in │ ├── a_segment_tree_for_the_sum │ │ ├── 1.ans │ │ └── 1.in │ ├── a_sign_alternation │ │ ├── 1.ans │ │ └── 1.in │ ├── all_equal │ │ ├── 1.ans │ │ └── 1.in │ ├── b_applying_max_to_segment │ │ ├── 1.ans │ │ └── 1.in │ ├── b_inverse_and_kth_one │ │ ├── 1.ans │ │ └── 1.in │ ├── d_addition_and_sum │ │ ├── 1.ans │ │ └── 1.in │ ├── e_euclids_tree │ │ ├── 1.ans │ │ ├── 1.in │ │ ├── 2.ans │ │ └── 2.in │ ├── e_min_cost_flow │ │ ├── 1.ans │ │ ├── 2.ans │ │ ├── 1.in │ │ └── 2.in │ ├── f_assignment_and_sum │ │ ├── 1.ans │ │ └── 1.in │ ├── f_fast_tree_queries │ │ ├── 1.ans │ │ └── 1.in │ ├── g_scc │ │ ├── 1.ans │ │ └── 1.in │ ├── goldbachs_conjecture │ │ ├── 1.in │ │ └── 1.ans │ ├── island_hopping │ │ ├── 1.ans │ │ └── 1.in │ ├── n_shuffle_the_cards │ │ └── 1.in │ ├── replace_with_first_literally │ │ ├── 1.ans │ │ └── 1.in │ ├── sequence_creation │ │ ├── 1.ans │ │ └── 1.in │ ├── triangle_count_hard │ │ ├── 0.in │ │ ├── 1.ans │ │ └── 1.in │ ├── a_assignment_addition_and_sum │ │ ├── 1.ans │ │ └── 1.in │ ├── a_assignment_and_maximal_segment │ │ ├── 1.ans │ │ └── 1.in │ ├── a_segment_with_the_maximum_sum │ │ ├── 1.ans │ │ ├── 2.ans │ │ ├── 1.in │ │ └── 2.in │ ├── b_segment_tree_for_the_minimum │ │ ├── 1.ans │ │ └── 1.in │ ├── c_the_case_of_the_last_emperor │ │ ├── 1.ans │ │ └── 1.in │ ├── d_maksimum_minimum_kolichestvo │ │ ├── 0.in │ │ └── 1.in │ ├── dynamic_tree_vertex_add_subtree_sum │ │ ├── .failed_999.ans │ │ ├── 1.ans │ │ ├── .failed_999.in │ │ └── 1.in │ ├── e_assignment_and_minimum │ │ ├── 1.ans │ │ └── 1.in │ ├── j_another │ │ ├── 1.ans │ │ └── 1.in │ ├── l_the_easiest_task │ │ ├── 1.ans │ │ └── 1.in │ ├── m_ordainer_of_inexorable_judgment │ │ ├── 1.ans │ │ ├── 2.ans │ │ ├── 3.ans │ │ ├── 1.in │ │ ├── 2.in │ │ └── 3.in │ ├── matching_on_bipartite_graph │ │ ├── 1.ans │ │ └── 1.in │ ├── polynomial_multiplication_2 │ │ ├── 1.ans │ │ └── 1.in │ ├── task_1553_caves_and_tunnels │ │ ├── 1.ans │ │ └── 1.in │ ├── c_first_element_at_least_x │ │ ├── 1.ans │ │ └── 1.in │ ├── c_number_of_minimums_on_a_segment │ │ ├── 1.ans │ │ └── 1.in │ ├── prime_sieve │ │ ├── 1.ans │ │ └── 1.in │ ├── roy_and_tree_permutation │ │ ├── 1.ans │ │ └── 1.in │ ├── task │ │ ├── 5.ans │ │ ├── 6.ans │ │ ├── 1.ans │ │ ├── 2.ans │ │ ├── 3.ans │ │ ├── 4.ans │ │ ├── 1.in │ │ ├── 2.in │ │ ├── 3.in │ │ ├── 4.in │ │ ├── 5.in │ │ └── 6.in │ ├── d_first_element_at_least_x_2 │ │ ├── 1.ans │ │ └── 1.in │ ├── d_number_of_different_on_segment │ │ ├── 1.ans │ │ └── 1.in │ ├── k_range_affine_range_sum │ │ ├── 1.ans │ │ └── 1.in │ ├── the_easiest_problem_is_this_one │ │ ├── 1.ans │ │ └── 1.in │ ├── c2_yet_another_nim_game_counting_version │ │ └── 1.in │ ├── c_addition_and_first_element_at_least_x │ │ ├── 1.ans │ │ └── 1.in │ ├── c_number_of_inversions_on_segment │ │ ├── 1.ans │ │ └── 1.in │ ├── c_painter │ │ ├── 1.ans │ │ └── 1.in │ ├── engineering_english │ │ ├── 2.ans │ │ ├── 2.in │ │ ├── 1.ans │ │ └── 1.in │ ├── f1_sverkhskorostnoi_podschyot_prostaya_versiya │ │ ├── 0.in │ │ └── 1.in │ ├── galactic_collegiate_programming_contest │ │ ├── 1.ans │ │ └── 1.in │ ├── modular_arithmetic │ │ ├── 1.ans │ │ └── 1.in │ ├── rational_arithmetic │ │ ├── 1.ans │ │ └── 1.in │ ├── c_isnova_summa │ │ └── 1.in │ ├── k_reka │ │ └── 1.in │ ├── line_segment_distance │ │ ├── 1.ans │ │ └── 1.in │ ├── running_mom │ │ ├── 1.ans │ │ └── 1.in │ ├── conga_line │ │ ├── 1.in │ │ ├── 2.in │ │ ├── 3.in │ │ ├── 1.ans │ │ ├── 2.ans │ │ └── 3.ans │ ├── dynamic_tree_subtree_add_subtree_sum │ │ ├── 1.ans │ │ └── 1.in │ ├── e_wall │ │ ├── 1.ans │ │ └── 1.in │ ├── big_sorting │ │ ├── 1.ans │ │ ├── 1.in │ │ ├── 2.ans │ │ └── 2.in │ ├── encoded_message │ │ ├── 1.ans │ │ └── 1.in │ ├── minimum_spanning_tree │ │ ├── 1.ans │ │ └── 1.in │ ├── polynomial_multiplication_1 │ │ ├── 1.ans │ │ └── 1.in │ ├── all_pairs_shortest_path │ │ ├── 1.ans │ │ └── 1.in │ ├── b_add_arithmetic_progression_on_segment │ │ ├── 1.ans │ │ └── 1.in │ ├── string_multimatching │ │ ├── 1.ans │ │ └── 1.in │ ├── single_source_shortest_path_negative_weights │ │ ├── 1.ans │ │ └── 1.in │ ├── single_source_shortest_path_non_negative_weights │ │ ├── 1.ans │ │ └── 1.in │ ├── p5_coffee_jelly │ │ ├── 2.in │ │ └── 1.in │ ├── ucup_10_g │ │ ├── 0.in │ │ └── 1.in │ ├── anagram_counting │ │ ├── 1.ans │ │ └── 1.in │ ├── b_cryptography │ │ ├── 1.ans │ │ └── 1.in │ ├── convex_hull │ │ ├── 1.ans │ │ └── 1.in │ ├── f_flip │ │ └── 1.in │ ├── d_kii_maksimum │ │ └── 1.in │ ├── c2_koordinatsiya_prezentatsii_slozhnaya_versiya │ │ ├── 1.ans │ │ └── 1.in │ ├── d_greenpath │ │ ├── 1.ans │ │ └── 1.in │ ├── reverse_rot │ │ ├── 1.ans │ │ └── 1.in │ ├── b_binary_search_tree │ │ └── 1.in │ ├── the_amazing_human_cannonball │ │ ├── 1.ans │ │ └── 1.in │ └── e_innocent_students │ │ └── 1.in ├── src │ ├── numbers │ │ ├── primes │ │ │ ├── mod.rs │ │ │ └── sieve.rs │ │ ├── num_traits │ │ │ ├── invertible.rs │ │ │ ├── mod.rs │ │ │ ├── ord.rs │ │ │ ├── primitive.rs │ │ │ ├── sign.rs │ │ │ └── op_to_assign.rs │ │ ├── mod.rs │ │ ├── series.rs │ │ ├── fwht.rs │ │ ├── matrix_series.rs │ │ └── gcd.rs │ ├── collections │ │ ├── md_arr │ │ │ └── mod.rs │ │ ├── iter_ext │ │ │ ├── mod.rs │ │ │ ├── min_max.rs │ │ │ └── interleave.rs │ │ ├── vec_ext │ │ │ ├── mod.rs │ │ │ ├── default.rs │ │ │ ├── transpose.rs │ │ │ └── sorted.rs │ │ ├── slice_ext │ │ │ ├── mod.rs │ │ │ ├── indices.rs │ │ │ ├── qty.rs │ │ │ ├── next_permutation.rs │ │ │ ├── consecutive_iter.rs │ │ │ ├── backward.rs │ │ │ └── compress.rs │ │ ├── order.rs │ │ ├── bounds.rs │ │ ├── mod.rs │ │ └── test.rs │ ├── misc │ │ ├── direction.rs │ │ ├── extensions │ │ │ ├── mod.rs │ │ │ ├── with.rs │ │ │ ├── do_with.rs │ │ │ ├── option.rs │ │ │ └── replace_with.rs │ │ ├── between.rs │ │ ├── memo │ │ │ ├── mod.rs │ │ │ ├── test.rs │ │ │ └── memoization_vec.rs │ │ ├── test_type.rs │ │ ├── when.rs │ │ ├── mod.rs │ │ ├── owned_cell.rs │ │ ├── value_delta.rs │ │ ├── transparent_wrapper.rs │ │ ├── simd.rs │ │ ├── time_tracker.rs │ │ └── maybe.rs │ ├── graph │ │ ├── edges │ │ │ ├── bi_edge_trait.rs │ │ │ ├── weighted_edge_trait.rs │ │ │ ├── mod.rs │ │ │ ├── edge_trait.rs │ │ │ ├── flow_edge_trait.rs │ │ │ └── edge_id.rs │ │ └── flow_graph.rs │ ├── io │ │ ├── mod.rs │ │ ├── output_macro.rs │ │ └── eol.rs │ ├── string │ │ ├── string_algorithms │ │ │ ├── mod.rs │ │ │ ├── prefix_function.rs │ │ │ ├── z_algorithm.rs │ │ │ └── string_search.rs │ │ ├── mod.rs │ │ ├── concat.rs │ │ ├── trim.rs │ │ ├── qty.rs │ │ ├── split.rs │ │ └── slicelike.rs │ ├── geometry │ │ ├── mod.rs │ │ ├── geometry_utils.rs │ │ └── angle.rs │ └── lib.rs └── Cargo.toml ├── main ├── src │ └── main.rs ├── Cargo.toml └── .cargo │ └── config.toml ├── run ├── src │ └── main.rs └── Cargo.toml ├── .gitignore ├── README.md ├── Cargo.toml ├── .cargo └── config.toml ├── tester └── Cargo.toml ├── archive ├── 2021 │ └── 12 │ │ ├── Advent of Code │ │ ├── day01a.rs │ │ ├── day01b.rs │ │ ├── day02a.rs │ │ ├── day02b.rs │ │ ├── day06a.rs │ │ ├── day06b.rs │ │ ├── day03a.rs │ │ └── day07a.rs │ │ ├── 27.12.2021 - Abakoda 2021 Long Contest │ │ └── f_funny_sequence.rs │ │ ├── 11.12.2021 - Panasonic Programming Contest 2021(AtCoder Beginner Contest 231) │ │ └── a_water_pressure.rs │ │ ├── 25.12.2021 - AtCoder Beginner Contest 233 │ │ └── a10yen_stamp.rs │ │ └── 19.12.2021 - M-SOLUTIONS Programming Contest 2021(AtCoder Beginner Contest 232) │ │ └── a_qqsolver.rs ├── 2022 │ ├── 1 │ │ └── 8.1.2022 - January Easy '22 │ │ │ └── non_empty_subsets.rs │ ├── 6 │ │ └── 20.6.2022 - AtCoder Beginner Contest #256 │ │ │ └── a2_n.rs │ └── 8 │ │ ├── 17.8.2022 - AtCoder Beginner Contest #264 │ │ └── a_atcodersubstr.rs │ │ └── 17.8.2022 - AtCoder Beginner Contest #261 │ │ └── a_intersection.rs └── 2023 │ └── 12 │ └── 7.12.2023 - CPython Programming Contest #3 │ └── c.cpp └── .github └── workflows └── rust.yml /templates/classic.rs: -------------------------------------------------------------------------------- 1 | Classic -------------------------------------------------------------------------------- /templates/single.rs: -------------------------------------------------------------------------------- 1 | Single -------------------------------------------------------------------------------- /algo_lib/tests/grid/1.ans: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /algo_lib/tests/grid/2.ans: -------------------------------------------------------------------------------- 1 | -1 2 | -------------------------------------------------------------------------------- /algo_lib/tests/grid/3.ans: -------------------------------------------------------------------------------- 1 | 6 2 | -------------------------------------------------------------------------------- /algo_lib/tests/s_mil/3.ans: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /algo_lib/tests/s_mil/4.ans: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /algo_lib/tests/veci/1.ans: -------------------------------------------------------------------------------- 1 | 165 2 | -------------------------------------------------------------------------------- /algo_lib/tests/veci/1.in: -------------------------------------------------------------------------------- 1 | 156 2 | -------------------------------------------------------------------------------- /algo_lib/tests/veci/2.ans: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /algo_lib/tests/veci/2.in: -------------------------------------------------------------------------------- 1 | 330 2 | -------------------------------------------------------------------------------- /main/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() {} 2 | -------------------------------------------------------------------------------- /run/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() {} 2 | -------------------------------------------------------------------------------- /templates/multi_eof.rs: -------------------------------------------------------------------------------- 1 | MultiEof -------------------------------------------------------------------------------- /algo_lib/tests/a_bproblem/1.ans: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_bproblem/2.ans: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_list_game/2.ans: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /algo_lib/tests/d_borders/1.ans: -------------------------------------------------------------------------------- 1 | 20 2 | -------------------------------------------------------------------------------- /algo_lib/tests/d_borders/2.ans: -------------------------------------------------------------------------------- 1 | 11 2 | -------------------------------------------------------------------------------- /algo_lib/tests/d_borders/2.in: -------------------------------------------------------------------------------- 1 | hhya 2 | -------------------------------------------------------------------------------- /algo_lib/tests/d_borders/3.ans: -------------------------------------------------------------------------------- 1 | 50 2 | -------------------------------------------------------------------------------- /algo_lib/tests/d_borders/4.ans: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /algo_lib/tests/d_borders/4.in: -------------------------------------------------------------------------------- 1 | a 2 | -------------------------------------------------------------------------------- /algo_lib/tests/dominos/1.ans: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /algo_lib/tests/h_two_sat/2.ans: -------------------------------------------------------------------------------- 1 | No 2 | -------------------------------------------------------------------------------- /algo_lib/tests/s_mil/3.in: -------------------------------------------------------------------------------- 1 | ::))(: 2 | -------------------------------------------------------------------------------- /algo_lib/tests/s_mil/4.in: -------------------------------------------------------------------------------- 1 | ):): 2 | -------------------------------------------------------------------------------- /algo_lib/tests/ucucp_11_o/1.ans: -------------------------------------------------------------------------------- 1 | 0101 -------------------------------------------------------------------------------- /algo_lib/tests/ucucp_11_o/2.ans: -------------------------------------------------------------------------------- 1 | 001101 -------------------------------------------------------------------------------- /algo_lib/tests/veci/3.ans: -------------------------------------------------------------------------------- 1 | 71127 2 | -------------------------------------------------------------------------------- /algo_lib/tests/veci/3.in: -------------------------------------------------------------------------------- 1 | 27711 2 | -------------------------------------------------------------------------------- /templates/interactive.rs: -------------------------------------------------------------------------------- 1 | Interactive -------------------------------------------------------------------------------- /templates/multi_number.rs: -------------------------------------------------------------------------------- 1 | MultiNumber -------------------------------------------------------------------------------- /algo_lib/tests/a_list_game/1.ans: -------------------------------------------------------------------------------- 1 | 16 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_list_game/1.in: -------------------------------------------------------------------------------- 1 | 65536 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_list_game/2.in: -------------------------------------------------------------------------------- 1 | 127381 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_next/1.ans: -------------------------------------------------------------------------------- 1 | 3 2 | 4 3 | -------------------------------------------------------------------------------- /algo_lib/tests/a_suffix_array_1/4.in: -------------------------------------------------------------------------------- 1 | nn 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_suffix_array_2/4.in: -------------------------------------------------------------------------------- 1 | nn 2 | -------------------------------------------------------------------------------- /algo_lib/tests/candy_division/1.in: -------------------------------------------------------------------------------- 1 | 30 2 | -------------------------------------------------------------------------------- /algo_lib/tests/coast_length/1.ans: -------------------------------------------------------------------------------- 1 | 20 2 | -------------------------------------------------------------------------------- /algo_lib/tests/d_borders/1.in: -------------------------------------------------------------------------------- 1 | ababb 2 | -------------------------------------------------------------------------------- /algo_lib/tests/d_borders/3.in: -------------------------------------------------------------------------------- 1 | aaazaaa 2 | -------------------------------------------------------------------------------- /algo_lib/tests/d_inca_rituals/1.ans: -------------------------------------------------------------------------------- 1 | 16 2 | -------------------------------------------------------------------------------- /algo_lib/tests/digit_product/1.ans: -------------------------------------------------------------------------------- 1 | 8 2 | -------------------------------------------------------------------------------- /algo_lib/tests/digit_product/1.in: -------------------------------------------------------------------------------- 1 | 808 2 | -------------------------------------------------------------------------------- /algo_lib/tests/digit_product/2.ans: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /algo_lib/tests/digit_product/2.in: -------------------------------------------------------------------------------- 1 | 20 2 | -------------------------------------------------------------------------------- /algo_lib/tests/download_speed/0.ans: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /algo_lib/tests/download_speed/1.ans: -------------------------------------------------------------------------------- 1 | 6 2 | -------------------------------------------------------------------------------- /algo_lib/tests/e_refrain/2.in: -------------------------------------------------------------------------------- 1 | 1 1 2 | 1 3 | -------------------------------------------------------------------------------- /algo_lib/tests/f_insert/1.ans: -------------------------------------------------------------------------------- 1 | 4 2 3 1 2 | -------------------------------------------------------------------------------- /algo_lib/tests/f_insert/2.ans: -------------------------------------------------------------------------------- 1 | 1 2 3 4 5 2 | -------------------------------------------------------------------------------- /algo_lib/tests/g_fine_triplets/1.ans: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /algo_lib/tests/g_fine_triplets/2.ans: -------------------------------------------------------------------------------- 1 | 5 2 | -------------------------------------------------------------------------------- /algo_lib/tests/g_fine_triplets/3.ans: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /algo_lib/tests/hragreining/1.in: -------------------------------------------------------------------------------- 1 | COV 2 | -------------------------------------------------------------------------------- /algo_lib/tests/hragreining/2.in: -------------------------------------------------------------------------------- 1 | COOOV 2 | -------------------------------------------------------------------------------- /algo_lib/tests/hragreining/3.in: -------------------------------------------------------------------------------- 1 | AACOVAA 2 | -------------------------------------------------------------------------------- /algo_lib/tests/kovzanka/1.ans: -------------------------------------------------------------------------------- 1 | 2.2000 2 | -------------------------------------------------------------------------------- /algo_lib/tests/lizhnya/1.ans: -------------------------------------------------------------------------------- 1 | 2.0000000 2 | -------------------------------------------------------------------------------- /algo_lib/tests/lost_lineup/1.ans: -------------------------------------------------------------------------------- 1 | 1 2 2 | -------------------------------------------------------------------------------- /algo_lib/tests/lost_lineup/1.in: -------------------------------------------------------------------------------- 1 | 2 2 | 0 3 | -------------------------------------------------------------------------------- /algo_lib/tests/m_cup_trick/1.ans: -------------------------------------------------------------------------------- 1 | 2 1 2 | -------------------------------------------------------------------------------- /algo_lib/tests/m_cup_trick/2.ans: -------------------------------------------------------------------------------- 1 | 2 1 3 2 | -------------------------------------------------------------------------------- /algo_lib/tests/m_cup_trick/3.ans: -------------------------------------------------------------------------------- 1 | -1 2 | -------------------------------------------------------------------------------- /algo_lib/tests/maximum_flow/3.ans: -------------------------------------------------------------------------------- 1 | 2 0 0 2 | -------------------------------------------------------------------------------- /algo_lib/tests/nine_knights/2.ans: -------------------------------------------------------------------------------- 1 | valid 2 | -------------------------------------------------------------------------------- /algo_lib/tests/prsteni/1.in: -------------------------------------------------------------------------------- 1 | 3 2 | 8 4 2 3 | -------------------------------------------------------------------------------- /algo_lib/tests/s_mil/2.in: -------------------------------------------------------------------------------- 1 | :-):);-):) 2 | -------------------------------------------------------------------------------- /algo_lib/tests/similar_pair/1.ans: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /algo_lib/tests/tochka_vdrzok/1.ans: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /algo_lib/tests/walrus_weights/2.ans: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | .idea/ 3 | .vscode/ 4 | -------------------------------------------------------------------------------- /algo_lib/tests/a_bproblem/.failed_999.ans: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_bproblem/1.in: -------------------------------------------------------------------------------- 1 | 4 2 | 1 2 3 4 3 | -------------------------------------------------------------------------------- /algo_lib/tests/a_feast_for_cats/1.ans: -------------------------------------------------------------------------------- 1 | yes 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_inversions/1.ans: -------------------------------------------------------------------------------- 1 | 0 1 1 0 3 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_suffix_array_1/1.in: -------------------------------------------------------------------------------- 1 | ababba 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_suffix_array_1/2.in: -------------------------------------------------------------------------------- 1 | aaaa 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_suffix_array_1/4.ans: -------------------------------------------------------------------------------- 1 | 2 1 0 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_suffix_array_2/1.in: -------------------------------------------------------------------------------- 1 | ababba 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_suffix_array_2/2.in: -------------------------------------------------------------------------------- 1 | aaaa 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_suffix_array_2/4.ans: -------------------------------------------------------------------------------- 1 | 2 1 0 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_two_out_of_three/1.ans: -------------------------------------------------------------------------------- 1 | 42 2 | -------------------------------------------------------------------------------- /algo_lib/tests/c_bitwise_or_and_and/2.ans: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /algo_lib/tests/d_inca_rituals/1.in: -------------------------------------------------------------------------------- 1 | 1 2 | 4 5 3 | -------------------------------------------------------------------------------- /algo_lib/tests/e_refrain/0.in: -------------------------------------------------------------------------------- 1 | 3 3 2 | 1 2 3 3 | -------------------------------------------------------------------------------- /algo_lib/tests/e_refrain/2.ans: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | 1 4 | -------------------------------------------------------------------------------- /algo_lib/tests/f_convolution/2.ans: -------------------------------------------------------------------------------- 1 | 871938225 2 | -------------------------------------------------------------------------------- /algo_lib/tests/f_insert/1.in: -------------------------------------------------------------------------------- 1 | 4 2 | 1 1 2 1 3 | -------------------------------------------------------------------------------- /algo_lib/tests/f_insert/2.in: -------------------------------------------------------------------------------- 1 | 5 2 | 1 2 3 4 5 3 | -------------------------------------------------------------------------------- /algo_lib/tests/f_periodic_substring/1.ans: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /algo_lib/tests/f_periodic_substring/2.ans: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /algo_lib/tests/f_periodic_substring/3.ans: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /algo_lib/tests/f_periodic_substring/4.ans: -------------------------------------------------------------------------------- 1 | 5 2 | -------------------------------------------------------------------------------- /algo_lib/tests/f_periodic_substring/5.ans: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /algo_lib/tests/f_periodic_substring/5.in: -------------------------------------------------------------------------------- 1 | nn 2 | -------------------------------------------------------------------------------- /algo_lib/tests/fenwick_tree/1.ans: -------------------------------------------------------------------------------- 1 | 23 2 | 40 3 | -------------------------------------------------------------------------------- /algo_lib/tests/fenwick_tree/2.ans: -------------------------------------------------------------------------------- 1 | 0 2 | -42 3 | -------------------------------------------------------------------------------- /algo_lib/tests/grid/1.in: -------------------------------------------------------------------------------- 1 | 2 2 2 | 11 3 | 11 4 | -------------------------------------------------------------------------------- /algo_lib/tests/grid/2.in: -------------------------------------------------------------------------------- 1 | 2 2 2 | 22 3 | 22 4 | -------------------------------------------------------------------------------- /algo_lib/tests/hragreining/1.ans: -------------------------------------------------------------------------------- 1 | Veikur! 2 | -------------------------------------------------------------------------------- /algo_lib/tests/hragreining/3.ans: -------------------------------------------------------------------------------- 1 | Veikur! 2 | -------------------------------------------------------------------------------- /algo_lib/tests/j_royal_waterways/1.ans: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /algo_lib/tests/j_royal_waterways/2.ans: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /algo_lib/tests/j_royal_waterways/3.ans: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /algo_lib/tests/lost_lineup/2.ans: -------------------------------------------------------------------------------- 1 | 1 4 2 3 2 | -------------------------------------------------------------------------------- /algo_lib/tests/lost_lineup/2.in: -------------------------------------------------------------------------------- 1 | 4 2 | 1 2 0 3 | -------------------------------------------------------------------------------- /algo_lib/tests/m_cup_trick/1.in: -------------------------------------------------------------------------------- 1 | 2 1 2 | 2 1 3 | -------------------------------------------------------------------------------- /algo_lib/tests/m_do_not_turn_back/1.ans: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /algo_lib/tests/m_do_not_turn_back/2.ans: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /algo_lib/tests/min_max_paths/0.ans: -------------------------------------------------------------------------------- 1 | 3 0 6 7 2 | -------------------------------------------------------------------------------- /algo_lib/tests/money_matters/1.ans: -------------------------------------------------------------------------------- 1 | POSSIBLE 2 | -------------------------------------------------------------------------------- /algo_lib/tests/nine_knights/1.ans: -------------------------------------------------------------------------------- 1 | invalid 2 | -------------------------------------------------------------------------------- /algo_lib/tests/nine_knights/3.ans: -------------------------------------------------------------------------------- 1 | invalid 2 | -------------------------------------------------------------------------------- /algo_lib/tests/numismatics/1.ans: -------------------------------------------------------------------------------- 1 | 3 2 | 0 3 | -------------------------------------------------------------------------------- /algo_lib/tests/p3_tally_clicker/1.in: -------------------------------------------------------------------------------- 1 | 9999 2 | -------------------------------------------------------------------------------- /algo_lib/tests/p3_tally_clicker/2.in: -------------------------------------------------------------------------------- 1 | 101 2 | -------------------------------------------------------------------------------- /algo_lib/tests/p6_candygrams/1.ans: -------------------------------------------------------------------------------- 1 | 4 2 | 12 3 | -------------------------------------------------------------------------------- /algo_lib/tests/prsteni/1.ans: -------------------------------------------------------------------------------- 1 | 2/1 2 | 4/1 3 | -------------------------------------------------------------------------------- /algo_lib/tests/prsteni/2.in: -------------------------------------------------------------------------------- 1 | 4 2 | 12 3 8 4 3 | -------------------------------------------------------------------------------- /algo_lib/tests/reachable_roads/1.ans: -------------------------------------------------------------------------------- 1 | 1 2 | 0 3 | -------------------------------------------------------------------------------- /algo_lib/tests/s_mil/1.ans: -------------------------------------------------------------------------------- 1 | 0 2 | 9 3 | 13 4 | -------------------------------------------------------------------------------- /algo_lib/tests/s_mil/1.in: -------------------------------------------------------------------------------- 1 | :)xsy:->>;-)::)3 2 | -------------------------------------------------------------------------------- /algo_lib/tests/simple_addition/1.ans: -------------------------------------------------------------------------------- 1 | 1379 2 | -------------------------------------------------------------------------------- /algo_lib/tests/sliding_window_or/1.ans: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /algo_lib/tests/sliding_window_sum/1.ans: -------------------------------------------------------------------------------- 1 | 12 2 | -------------------------------------------------------------------------------- /algo_lib/tests/sliding_window_xor/1.ans: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /algo_lib/tests/ucucp_11_o/.failed_999.ans: -------------------------------------------------------------------------------- 1 | 01 2 | -------------------------------------------------------------------------------- /algo_lib/tests/union_find/1.ans: -------------------------------------------------------------------------------- 1 | no 2 | yes 3 | -------------------------------------------------------------------------------- /algo_lib/tests/union_find/2.ans: -------------------------------------------------------------------------------- 1 | yes 2 | no 3 | -------------------------------------------------------------------------------- /algo_lib/tests/walrus_weights/1.ans: -------------------------------------------------------------------------------- 1 | 1002 2 | -------------------------------------------------------------------------------- /algo_lib/tests/walrus_weights/2.in: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | -------------------------------------------------------------------------------- /algo_lib/tests/a_bproblem/2.in: -------------------------------------------------------------------------------- 1 | 6 2 | 1 1 3 3 4 6 3 | -------------------------------------------------------------------------------- /algo_lib/tests/a_inversions/1.in: -------------------------------------------------------------------------------- 1 | 5 2 | 4 1 3 5 2 3 | -------------------------------------------------------------------------------- /algo_lib/tests/a_next/.failed_998.ans: -------------------------------------------------------------------------------- 1 | 808663477 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_suffix_array_1/2.ans: -------------------------------------------------------------------------------- 1 | 4 3 2 1 0 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_suffix_array_1/3.in: -------------------------------------------------------------------------------- 1 | ppppplppp 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_suffix_array_2/2.ans: -------------------------------------------------------------------------------- 1 | 4 3 2 1 0 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_suffix_array_2/3.in: -------------------------------------------------------------------------------- 1 | ppppplppp 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_suffix_array_and_lcp/1.in: -------------------------------------------------------------------------------- 1 | ababba 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_suffix_array_and_lcp/2.in: -------------------------------------------------------------------------------- 1 | aaaa 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_suffix_array_and_lcp/4.in: -------------------------------------------------------------------------------- 1 | nn 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_two_out_of_three/2.ans: -------------------------------------------------------------------------------- 1 | 13999986 2 | -------------------------------------------------------------------------------- /algo_lib/tests/b_inversions_2/1.ans: -------------------------------------------------------------------------------- 1 | 4 1 3 5 2 2 | -------------------------------------------------------------------------------- /algo_lib/tests/c_nested_segments/1.ans: -------------------------------------------------------------------------------- 1 | 1 0 0 0 3 2 | -------------------------------------------------------------------------------- /algo_lib/tests/c_sorting_substrings/2.ans: -------------------------------------------------------------------------------- 1 | 1 1 2 | -------------------------------------------------------------------------------- /algo_lib/tests/continuous_median/1.ans: -------------------------------------------------------------------------------- 1 | 15 2 | 20 3 | -------------------------------------------------------------------------------- /algo_lib/tests/d_inca_rituals/2.ans: -------------------------------------------------------------------------------- 1 | 351 2 | 4114 3 | -------------------------------------------------------------------------------- /algo_lib/tests/e_earthquakes/1.ans: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | 3 4 | -------------------------------------------------------------------------------- /algo_lib/tests/e_refrain/1.ans: -------------------------------------------------------------------------------- 1 | 9 2 | 3 3 | 1 2 1 4 | -------------------------------------------------------------------------------- /algo_lib/tests/e_refrain/3.in: -------------------------------------------------------------------------------- 1 | 6 2 2 | 1 2 1 2 1 2 3 | -------------------------------------------------------------------------------- /algo_lib/tests/f_periodic_substring/2.in: -------------------------------------------------------------------------------- 1 | aabaabb 2 | -------------------------------------------------------------------------------- /algo_lib/tests/f_periodic_substring/3.in: -------------------------------------------------------------------------------- 1 | aaaa 2 | -------------------------------------------------------------------------------- /algo_lib/tests/get_shorty/1.ans: -------------------------------------------------------------------------------- 1 | 0.8100 2 | 1.0000 3 | -------------------------------------------------------------------------------- /algo_lib/tests/hragreining/2.ans: -------------------------------------------------------------------------------- 1 | Ekki veikur! 2 | -------------------------------------------------------------------------------- /algo_lib/tests/linear_recurrences/3.ans: -------------------------------------------------------------------------------- 1 | 552200 2 | -------------------------------------------------------------------------------- /algo_lib/tests/lizhnya/1.in: -------------------------------------------------------------------------------- 1 | 1 3 1 0 2 | -4 1 18 0 3 | -------------------------------------------------------------------------------- /algo_lib/tests/m_do_not_turn_back/3.ans: -------------------------------------------------------------------------------- 1 | 405422475 2 | -------------------------------------------------------------------------------- /algo_lib/tests/money_matters/2.ans: -------------------------------------------------------------------------------- 1 | IMPOSSIBLE 2 | -------------------------------------------------------------------------------- /algo_lib/tests/p6_candygrams/.failed_999.ans: -------------------------------------------------------------------------------- 1 | 38 2 | -------------------------------------------------------------------------------- /algo_lib/tests/pick_up_sticks/1.ans: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | -------------------------------------------------------------------------------- /algo_lib/tests/power_strings/1.ans: -------------------------------------------------------------------------------- 1 | 1 2 | 4 3 | 3 4 | -------------------------------------------------------------------------------- /algo_lib/tests/prsteni/2.ans: -------------------------------------------------------------------------------- 1 | 4/1 2 | 3/2 3 | 3/1 4 | -------------------------------------------------------------------------------- /algo_lib/tests/prsteni/3.in: -------------------------------------------------------------------------------- 1 | 4 2 | 300 1 1 300 3 | -------------------------------------------------------------------------------- /algo_lib/tests/s_mil/2.ans: -------------------------------------------------------------------------------- 1 | 0 2 | 3 3 | 5 4 | 8 5 | -------------------------------------------------------------------------------- /algo_lib/tests/simple_addition/1.in: -------------------------------------------------------------------------------- 1 | 1337 2 | 42 3 | -------------------------------------------------------------------------------- /algo_lib/tests/sliding_window_minimum/1.ans: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /algo_lib/tests/supercomputer/1.ans: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 1 4 | -------------------------------------------------------------------------------- /algo_lib/tests/the_goal/1.ans: -------------------------------------------------------------------------------- 1 | 9.899494936611665 2 | -------------------------------------------------------------------------------- /algo_lib/tests/tochka_vdrzok/1.in: -------------------------------------------------------------------------------- 1 | 1 1 0 0 2 2 2 | -------------------------------------------------------------------------------- /algo_lib/tests/ucucp_11_o/.failed_996.ans: -------------------------------------------------------------------------------- 1 | 001101 2 | -------------------------------------------------------------------------------- /algo_lib/tests/ucucp_11_o/.failed_997.ans: -------------------------------------------------------------------------------- 1 | 0110 2 | -------------------------------------------------------------------------------- /algo_lib/tests/ucucp_11_o/.failed_998.ans: -------------------------------------------------------------------------------- 1 | 0110 2 | -------------------------------------------------------------------------------- /algo_lib/tests/wheres_my_internet/1.ans: -------------------------------------------------------------------------------- 1 | 5 2 | 6 3 | -------------------------------------------------------------------------------- /algo_lib/tests/wheres_my_internet/2.ans: -------------------------------------------------------------------------------- 1 | Connected 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_bproblem/.failed_999.in: -------------------------------------------------------------------------------- 1 | 2 2 | -4 0 3 | -------------------------------------------------------------------------------- /algo_lib/tests/a_substring_search/3.ans: -------------------------------------------------------------------------------- 1 | Yes 2 | Yes 3 | -------------------------------------------------------------------------------- /algo_lib/tests/a_suffix_array_1/1.ans: -------------------------------------------------------------------------------- 1 | 6 5 0 2 4 1 3 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_suffix_array_2/1.ans: -------------------------------------------------------------------------------- 1 | 6 5 0 2 4 1 3 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_suffix_array_and_lcp/3.in: -------------------------------------------------------------------------------- 1 | ppppplppp 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_two_out_of_three/1.in: -------------------------------------------------------------------------------- 1 | 2 3 5 2 | 10 3 | -------------------------------------------------------------------------------- /algo_lib/tests/almost_perfect/1.in: -------------------------------------------------------------------------------- 1 | 6 2 | 65 3 | 650 4 | -------------------------------------------------------------------------------- /algo_lib/tests/b_counting_substrings/3.ans: -------------------------------------------------------------------------------- 1 | 3 2 | 2 3 | -------------------------------------------------------------------------------- /algo_lib/tests/b_inversions_2/1.in: -------------------------------------------------------------------------------- 1 | 5 2 | 0 1 1 0 3 3 | -------------------------------------------------------------------------------- /algo_lib/tests/b_longest_common_substring/1.ans: -------------------------------------------------------------------------------- 1 | aba 2 | -------------------------------------------------------------------------------- /algo_lib/tests/b_longest_common_substring/2.ans: -------------------------------------------------------------------------------- 1 | qrdq 2 | -------------------------------------------------------------------------------- /algo_lib/tests/b_longest_common_substring/3.ans: -------------------------------------------------------------------------------- 1 | hhhhhh 2 | -------------------------------------------------------------------------------- /algo_lib/tests/b_longest_common_substring/4.ans: -------------------------------------------------------------------------------- 1 | opopo 2 | -------------------------------------------------------------------------------- /algo_lib/tests/b_multiplication_and_sum/2.ans: -------------------------------------------------------------------------------- 1 | 993000 2 | -------------------------------------------------------------------------------- /algo_lib/tests/birthday_party/1.ans: -------------------------------------------------------------------------------- 1 | Yes 2 | No 3 | Yes 4 | -------------------------------------------------------------------------------- /algo_lib/tests/break_and_fix_the_tree/1.ans: -------------------------------------------------------------------------------- 1 | 11 2 | 20 3 | -------------------------------------------------------------------------------- /algo_lib/tests/candy_division/1.ans: -------------------------------------------------------------------------------- 1 | 0 1 2 4 5 9 14 29 2 | -------------------------------------------------------------------------------- /algo_lib/tests/class_field_trip/1.ans: -------------------------------------------------------------------------------- 1 | aachijjjkllmnoy 2 | -------------------------------------------------------------------------------- /algo_lib/tests/d_intersecting_segments/1.ans: -------------------------------------------------------------------------------- 1 | 1 0 1 1 1 2 | -------------------------------------------------------------------------------- /algo_lib/tests/dominos/1.in: -------------------------------------------------------------------------------- 1 | 1 2 | 3 2 3 | 1 2 4 | 2 3 5 | -------------------------------------------------------------------------------- /algo_lib/tests/e_fog_canyon/1.ans: -------------------------------------------------------------------------------- 1 | 8 7 2 | 8 5 3 | 7 3 4 | -------------------------------------------------------------------------------- /algo_lib/tests/e_refrain/1.in: -------------------------------------------------------------------------------- 1 | 8 3 2 | 1 2 1 2 1 1 2 1 3 | -------------------------------------------------------------------------------- /algo_lib/tests/e_refrain/3.ans: -------------------------------------------------------------------------------- 1 | 8 2 | 4 3 | 1 2 1 2 4 | -------------------------------------------------------------------------------- /algo_lib/tests/f_mountain/1.ans: -------------------------------------------------------------------------------- 1 | 4 2 | 1 3 | 0 4 | 3 5 | -------------------------------------------------------------------------------- /algo_lib/tests/f_mountain/mou0.ans: -------------------------------------------------------------------------------- 1 | 4 2 | 1 3 | 0 4 | 3 5 | -------------------------------------------------------------------------------- /algo_lib/tests/f_periodic_substring/4.in: -------------------------------------------------------------------------------- 1 | ppppplppp 2 | -------------------------------------------------------------------------------- /algo_lib/tests/g_fine_triplets/1.in: -------------------------------------------------------------------------------- 1 | 5 2 | 8 3 1 5 2 3 | -------------------------------------------------------------------------------- /algo_lib/tests/g_forward_v2/1.in: -------------------------------------------------------------------------------- 1 | 5 2 2 | 4 5 3 | 2 3 4 | -------------------------------------------------------------------------------- /algo_lib/tests/h_two_sat/1.ans: -------------------------------------------------------------------------------- 1 | Yes 2 | 4 3 | 2 4 | 0 5 | -------------------------------------------------------------------------------- /algo_lib/tests/kannas_friendship/2.ans: -------------------------------------------------------------------------------- 1 | 7 2 | 10 3 | 11 4 | -------------------------------------------------------------------------------- /algo_lib/tests/l_lazy_segment_tree/1.ans: -------------------------------------------------------------------------------- 1 | 2 2 | 0 3 | 1 4 | -------------------------------------------------------------------------------- /algo_lib/tests/longest_palindrome/1.ans: -------------------------------------------------------------------------------- 1 | 5 2 | abbba 3 | -------------------------------------------------------------------------------- /algo_lib/tests/longest_palindrome/1.in: -------------------------------------------------------------------------------- 1 | 5 2 | abbba 3 | -------------------------------------------------------------------------------- /algo_lib/tests/longest_palindrome/2.ans: -------------------------------------------------------------------------------- 1 | 8 2 | bcabbacb 3 | -------------------------------------------------------------------------------- /algo_lib/tests/m_cup_trick/2.in: -------------------------------------------------------------------------------- 1 | 3 2 2 | 1 2 3 | 1 1 4 | -------------------------------------------------------------------------------- /algo_lib/tests/minimum_cost_maximum_flow/1.ans: -------------------------------------------------------------------------------- 1 | 4 140 2 | -------------------------------------------------------------------------------- /algo_lib/tests/minimum_cost_maximum_flow/3.ans: -------------------------------------------------------------------------------- 1 | 0 0 2 | -------------------------------------------------------------------------------- /algo_lib/tests/next_permutation/1.ans: -------------------------------------------------------------------------------- 1 | 3 2 1 2 | 3 1 2 3 | -------------------------------------------------------------------------------- /algo_lib/tests/perfect_pth_powers/1.ans: -------------------------------------------------------------------------------- 1 | 1 2 | 30 3 | 2 4 | -------------------------------------------------------------------------------- /algo_lib/tests/pick_up_sticks/1.in: -------------------------------------------------------------------------------- 1 | 3 2 2 | 1 2 3 | 2 3 4 | -------------------------------------------------------------------------------- /algo_lib/tests/problems/1.ans: -------------------------------------------------------------------------------- 1 | 11 2 | -1 3 | 10 4 | 10 5 | -------------------------------------------------------------------------------- /algo_lib/tests/problems/2.ans: -------------------------------------------------------------------------------- 1 | 10 2 | 10 3 | -1 4 | 11 5 | -------------------------------------------------------------------------------- /algo_lib/tests/prsteni/3.ans: -------------------------------------------------------------------------------- 1 | 300/1 2 | 300/1 3 | 1/1 4 | -------------------------------------------------------------------------------- /algo_lib/tests/simple_addition/2.ans: -------------------------------------------------------------------------------- 1 | 10000000000000 2 | -------------------------------------------------------------------------------- /algo_lib/tests/sliding_window_or/1.in: -------------------------------------------------------------------------------- 1 | 8 5 2 | 3 7 1 11 3 | -------------------------------------------------------------------------------- /algo_lib/tests/subtree_swapping/1.ans: -------------------------------------------------------------------------------- 1 | 5 2 | 7 3 | -1 4 | -------------------------------------------------------------------------------- /algo_lib/tests/ucucp_11_o/.failed_997.in: -------------------------------------------------------------------------------- 1 | 2 1 2 | 2 1 3 | -------------------------------------------------------------------------------- /algo_lib/tests/virtual_friends/1.ans: -------------------------------------------------------------------------------- 1 | 2 2 | 3 3 | 4 4 | -------------------------------------------------------------------------------- /algo_lib/tests/wheres_my_internet/2.in: -------------------------------------------------------------------------------- 1 | 2 1 2 | 2 1 3 | -------------------------------------------------------------------------------- /algo_lib/tests/wheres_my_internet/3.ans: -------------------------------------------------------------------------------- 1 | 2 2 | 3 3 | 4 4 | -------------------------------------------------------------------------------- /algo_lib/tests/a_addition_to_segment/1.ans: -------------------------------------------------------------------------------- 1 | 3 2 | 4 3 | 0 4 | -------------------------------------------------------------------------------- /algo_lib/tests/a_number_of_different_substrings/1.ans: -------------------------------------------------------------------------------- 1 | 15 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_number_of_different_substrings/1.in: -------------------------------------------------------------------------------- 1 | ababba 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_number_of_different_substrings/2.ans: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_number_of_different_substrings/2.in: -------------------------------------------------------------------------------- 1 | mmuc 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_number_of_different_substrings/3.ans: -------------------------------------------------------------------------------- 1 | 24 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_number_of_different_substrings/4.ans: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_number_of_different_substrings/4.in: -------------------------------------------------------------------------------- 1 | nnnn 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_substring_search/1.ans: -------------------------------------------------------------------------------- 1 | Yes 2 | No 3 | Yes 4 | -------------------------------------------------------------------------------- /algo_lib/tests/a_substring_search/2.ans: -------------------------------------------------------------------------------- 1 | Yes 2 | Yes 3 | No 4 | -------------------------------------------------------------------------------- /algo_lib/tests/a_substring_search/3.in: -------------------------------------------------------------------------------- 1 | a 2 | 2 3 | a 4 | a 5 | -------------------------------------------------------------------------------- /algo_lib/tests/a_suffix_array_1/3.ans: -------------------------------------------------------------------------------- 1 | 9 5 8 4 7 3 6 2 1 0 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_suffix_array_2/3.ans: -------------------------------------------------------------------------------- 1 | 9 5 8 4 7 3 6 2 1 0 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_suffix_array_and_lcp/4.ans: -------------------------------------------------------------------------------- 1 | 2 1 0 2 | 0 1 3 | -------------------------------------------------------------------------------- /algo_lib/tests/a_two_out_of_three/2.in: -------------------------------------------------------------------------------- 1 | 5 6 7 2 | 1000000 3 | -------------------------------------------------------------------------------- /algo_lib/tests/b_counting_substrings/1.ans: -------------------------------------------------------------------------------- 1 | 2 2 | 0 3 | 1 4 | -------------------------------------------------------------------------------- /algo_lib/tests/b_counting_substrings/2.ans: -------------------------------------------------------------------------------- 1 | 2 2 | 0 3 | 1 4 | -------------------------------------------------------------------------------- /algo_lib/tests/b_fenwick_tree/1.ans: -------------------------------------------------------------------------------- 1 | 15 2 | 7 3 | 25 4 | 6 5 | -------------------------------------------------------------------------------- /algo_lib/tests/b_kth_one/1.ans: -------------------------------------------------------------------------------- 1 | 0 2 | 1 3 | 3 4 | 3 5 | 1 6 | -------------------------------------------------------------------------------- /algo_lib/tests/c_assignment_to_segment/1.ans: -------------------------------------------------------------------------------- 1 | 3 2 | 4 3 | 0 4 | -------------------------------------------------------------------------------- /algo_lib/tests/c_sorting_substrings/2.in: -------------------------------------------------------------------------------- 1 | a 2 | 1 3 | 1 1 4 | -------------------------------------------------------------------------------- /algo_lib/tests/chinese_remainder/1.ans: -------------------------------------------------------------------------------- 1 | 5 6 2 | 31471 217674 3 | -------------------------------------------------------------------------------- /algo_lib/tests/class_field_trip/1.in: -------------------------------------------------------------------------------- 1 | ahjmnoy 2 | acijjkll 3 | -------------------------------------------------------------------------------- /algo_lib/tests/cookie_selection/1.ans: -------------------------------------------------------------------------------- 1 | 3 2 | 2 3 | 4 4 | 1 5 | -------------------------------------------------------------------------------- /algo_lib/tests/cookie_selection/2.ans: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | -------------------------------------------------------------------------------- /algo_lib/tests/d_maxflow/1.ans: -------------------------------------------------------------------------------- 1 | 3 2 | #>< 3 | vv# 4 | ^^. 5 | -------------------------------------------------------------------------------- /algo_lib/tests/d_maxflow/1.in: -------------------------------------------------------------------------------- 1 | 3 3 2 | #.. 3 | ..# 4 | ... 5 | -------------------------------------------------------------------------------- /algo_lib/tests/d_problem_about_weighted_sum/1.ans: -------------------------------------------------------------------------------- 1 | 19 2 | 55 3 | -------------------------------------------------------------------------------- /algo_lib/tests/direct_connections/1.ans: -------------------------------------------------------------------------------- 1 | 280 2 | 463055586 3 | -------------------------------------------------------------------------------- /algo_lib/tests/e_addition_to_segment/1.ans: -------------------------------------------------------------------------------- 1 | 3 2 | 4 3 | 0 4 | -------------------------------------------------------------------------------- /algo_lib/tests/e_forward/1.in: -------------------------------------------------------------------------------- 1 | 6 3 2 | 2 4 3 | 3 5 4 | 2 2 5 | -------------------------------------------------------------------------------- /algo_lib/tests/f_convolution/1.ans: -------------------------------------------------------------------------------- 1 | 5 16 34 60 70 70 59 36 2 | -------------------------------------------------------------------------------- /algo_lib/tests/f_decoding_the_maya_code/.failed_996.ans: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /algo_lib/tests/f_decoding_the_maya_code/.failed_997.ans: -------------------------------------------------------------------------------- 1 | 5 2 | -------------------------------------------------------------------------------- /algo_lib/tests/f_decoding_the_maya_code/.failed_998.ans: -------------------------------------------------------------------------------- 1 | 6 2 | -------------------------------------------------------------------------------- /algo_lib/tests/f_decoding_the_maya_code/.failed_999.ans: -------------------------------------------------------------------------------- 1 | 75 2 | -------------------------------------------------------------------------------- /algo_lib/tests/f_periodic_substring/1.in: -------------------------------------------------------------------------------- 1 | aabaaabaaabaaabaab 2 | -------------------------------------------------------------------------------- /algo_lib/tests/h_two_sat/1.in: -------------------------------------------------------------------------------- 1 | 3 2 2 | 1 4 3 | 2 5 4 | 0 6 5 | -------------------------------------------------------------------------------- /algo_lib/tests/h_two_sat/2.in: -------------------------------------------------------------------------------- 1 | 3 3 2 | 1 4 3 | 2 5 4 | 0 6 5 | -------------------------------------------------------------------------------- /algo_lib/tests/i_bingo/1.ans: -------------------------------------------------------------------------------- 1 | 56 2 | 60 3 | 60 4 | 855346687 5 | -------------------------------------------------------------------------------- /algo_lib/tests/j_segment_tree/1.ans: -------------------------------------------------------------------------------- 1 | 3 2 | 3 3 | 2 4 | 6 5 | -------------------------------------------------------------------------------- /algo_lib/tests/kattiss_quest/1.ans: -------------------------------------------------------------------------------- 1 | 6 2 | 25 3 | 32 4 | 0 5 | -------------------------------------------------------------------------------- /algo_lib/tests/kinds_of_people/1.ans: -------------------------------------------------------------------------------- 1 | neither 2 | decimal 3 | -------------------------------------------------------------------------------- /algo_lib/tests/longest_palindrome/2.in: -------------------------------------------------------------------------------- 1 | 12 2 | abcbcabbacba 3 | -------------------------------------------------------------------------------- /algo_lib/tests/m_cup_trick/3.in: -------------------------------------------------------------------------------- 1 | 3 3 2 | 1 3 3 | 2 3 4 | 1 3 5 | -------------------------------------------------------------------------------- /algo_lib/tests/maximum_flow/2.ans: -------------------------------------------------------------------------------- 1 | 2 100000 1 2 | 0 1 100000 3 | -------------------------------------------------------------------------------- /algo_lib/tests/maximum_flow/2.in: -------------------------------------------------------------------------------- 1 | 2 1 0 1 2 | 0 1 100000 3 | -------------------------------------------------------------------------------- /algo_lib/tests/maximum_flow/3.in: -------------------------------------------------------------------------------- 1 | 2 1 1 0 2 | 0 1 100000 3 | -------------------------------------------------------------------------------- /algo_lib/tests/minimum_cost_maximum_flow/2.ans: -------------------------------------------------------------------------------- 1 | 1000 100000 2 | -------------------------------------------------------------------------------- /algo_lib/tests/polygon_area/1.ans: -------------------------------------------------------------------------------- 1 | CCW 50.0 2 | CW 3817.5 3 | -------------------------------------------------------------------------------- /algo_lib/tests/simple_addition/2.in: -------------------------------------------------------------------------------- 1 | 1 2 | 9999999999999 3 | -------------------------------------------------------------------------------- /algo_lib/tests/sliding_window_minimum/1.in: -------------------------------------------------------------------------------- 1 | 8 5 2 | 3 7 1 11 3 | -------------------------------------------------------------------------------- /algo_lib/tests/sliding_window_sum/1.in: -------------------------------------------------------------------------------- 1 | 8 5 2 | 3 7 1 11 3 | -------------------------------------------------------------------------------- /algo_lib/tests/sliding_window_xor/1.in: -------------------------------------------------------------------------------- 1 | 8 5 2 | 3 7 1 11 3 | -------------------------------------------------------------------------------- /algo_lib/tests/string_matching/1.ans: -------------------------------------------------------------------------------- 1 | 2 4 2 | 3 | 5 4 | 7 5 | -------------------------------------------------------------------------------- /algo_lib/tests/ucup_11_a/1.in: -------------------------------------------------------------------------------- 1 | 4 2 | 12 3 | 6 4 | 5839 5 | 123456 -------------------------------------------------------------------------------- /algo_lib/tests/a_addition_and_minimum/1.ans: -------------------------------------------------------------------------------- 1 | 3 2 | 7 3 | 4 4 | 0 5 | -------------------------------------------------------------------------------- /algo_lib/tests/a_disjoint_set_union/1.ans: -------------------------------------------------------------------------------- 1 | 0 2 | 1 3 | 0 4 | 1 5 | -------------------------------------------------------------------------------- /algo_lib/tests/a_number_of_different_substrings/3.in: -------------------------------------------------------------------------------- 1 | xmnnnuu 2 | -------------------------------------------------------------------------------- /algo_lib/tests/a_segment_tree_for_the_sum/1.ans: -------------------------------------------------------------------------------- 1 | 11 2 | 8 3 | 14 4 | -------------------------------------------------------------------------------- /algo_lib/tests/a_sign_alternation/1.ans: -------------------------------------------------------------------------------- 1 | -1 2 | 2 3 | -1 4 | 3 5 | -------------------------------------------------------------------------------- /algo_lib/tests/all_equal/1.ans: -------------------------------------------------------------------------------- 1 | 25 2 | 118 3 | 5695 4 | 97142466 5 | -------------------------------------------------------------------------------- /algo_lib/tests/b_applying_max_to_segment/1.ans: -------------------------------------------------------------------------------- 1 | 3 2 | 4 3 | 0 4 | -------------------------------------------------------------------------------- /algo_lib/tests/b_counting_substrings/3.in: -------------------------------------------------------------------------------- 1 | aaa 2 | 2 3 | a 4 | aa 5 | -------------------------------------------------------------------------------- /algo_lib/tests/b_inverse_and_kth_one/1.ans: -------------------------------------------------------------------------------- 1 | 2 2 | 0 3 | 2 4 | 4 5 | -------------------------------------------------------------------------------- /algo_lib/tests/c_bitwise_or_and_and/1.ans: -------------------------------------------------------------------------------- 1 | 3 2 | 7 3 | 4 4 | 0 5 | -------------------------------------------------------------------------------- /algo_lib/tests/c_nested_segments/1.in: -------------------------------------------------------------------------------- 1 | 5 2 | 5 1 2 2 3 1 3 4 5 4 3 | -------------------------------------------------------------------------------- /algo_lib/tests/d_addition_and_sum/1.ans: -------------------------------------------------------------------------------- 1 | 3 2 | 14 3 | 18 4 | 4 5 | -------------------------------------------------------------------------------- /algo_lib/tests/d_inca_rituals/2.in: -------------------------------------------------------------------------------- 1 | 2 2 | 10 20 3 | 2024 2024 4 | -------------------------------------------------------------------------------- /algo_lib/tests/e_euclids_tree/1.ans: -------------------------------------------------------------------------------- 1 | 3 2 | 3 3 | 3 4 | 2 5 | 0 6 | -------------------------------------------------------------------------------- /algo_lib/tests/e_min_cost_flow/1.ans: -------------------------------------------------------------------------------- 1 | 19 2 | X.. 3 | ..X 4 | .X. 5 | -------------------------------------------------------------------------------- /algo_lib/tests/e_min_cost_flow/2.ans: -------------------------------------------------------------------------------- 1 | 50 2 | XX. 3 | XX. 4 | ..X 5 | -------------------------------------------------------------------------------- /algo_lib/tests/f_assignment_and_sum/1.ans: -------------------------------------------------------------------------------- 1 | 3 2 | 7 3 | 11 4 | 4 5 | -------------------------------------------------------------------------------- /algo_lib/tests/f_convolution/1.in: -------------------------------------------------------------------------------- 1 | 4 5 2 | 1 2 3 4 3 | 5 6 7 8 9 4 | -------------------------------------------------------------------------------- /algo_lib/tests/f_convolution/2.in: -------------------------------------------------------------------------------- 1 | 1 1 2 | 10000000 3 | 10000000 4 | -------------------------------------------------------------------------------- /algo_lib/tests/f_fast_tree_queries/1.ans: -------------------------------------------------------------------------------- 1 | 5 2 | 1 3 | 6 4 | 2 5 | -------------------------------------------------------------------------------- /algo_lib/tests/g_scc/1.ans: -------------------------------------------------------------------------------- 1 | 4 2 | 1 5 3 | 2 1 4 4 | 1 2 5 | 2 0 3 6 | -------------------------------------------------------------------------------- /algo_lib/tests/goldbachs_conjecture/1.in: -------------------------------------------------------------------------------- 1 | 3 2 | 4 3 | 26 4 | 100 5 | -------------------------------------------------------------------------------- /algo_lib/tests/island_hopping/1.ans: -------------------------------------------------------------------------------- 1 | 2.000 2 | 168.01015709273446 3 | -------------------------------------------------------------------------------- /algo_lib/tests/min_max_paths/1.ans: -------------------------------------------------------------------------------- 1 | 3 5 0 7 8 2 | 2 0 3 | 0 2 3 4 4 | -------------------------------------------------------------------------------- /algo_lib/tests/n_shuffle_the_cards/1.in: -------------------------------------------------------------------------------- 1 | 10 2 2 | 6 2 2 3 | 5 3 6 4 | -------------------------------------------------------------------------------- /algo_lib/tests/next_permutation/1.in: -------------------------------------------------------------------------------- 1 | 3 2 2 | 3 1 2 3 | 2 3 1 4 | -------------------------------------------------------------------------------- /algo_lib/tests/power_strings/1.in: -------------------------------------------------------------------------------- 1 | abcd 2 | aaaa 3 | ababab 4 | . 5 | -------------------------------------------------------------------------------- /algo_lib/tests/replace_with_first_literally/1.ans: -------------------------------------------------------------------------------- 1 | 1 2 | -1 3 | 0 4 | -------------------------------------------------------------------------------- /algo_lib/tests/sequence_creation/1.ans: -------------------------------------------------------------------------------- 1 | 1 2 3 2 2 | 2 1 1 1 2 3 | -------------------------------------------------------------------------------- /algo_lib/tests/triangle_count_hard/0.in: -------------------------------------------------------------------------------- 1 | 1 2 | 6 3 | 3 1 6 5 50 17 -------------------------------------------------------------------------------- /algo_lib/tests/ucucp_11_o/.0.in: -------------------------------------------------------------------------------- 1 | 2 4 2 | 1 3 3 | 2 4 4 | 1 4 5 | 1 2 -------------------------------------------------------------------------------- /algo_lib/tests/ucucp_11_o/.failed_999.in: -------------------------------------------------------------------------------- 1 | 1 2 2 | 2 1 3 | 2 1 4 | -------------------------------------------------------------------------------- /algo_lib/tests/ucucp_11_o/1.in: -------------------------------------------------------------------------------- 1 | 2 4 2 | 1 3 3 | 2 4 4 | 1 4 5 | 1 2 -------------------------------------------------------------------------------- /algo_lib/tests/ucup_11_a/1.ans: -------------------------------------------------------------------------------- 1 | 924 2 | 0 3 | 966252995 4 | 432934749 -------------------------------------------------------------------------------- /algo_lib/tests/ucup_11_a/2.ans: -------------------------------------------------------------------------------- 1 | 333574957 2 | 124462731 3 | 163251704 -------------------------------------------------------------------------------- /algo_lib/tests/a_assignment_addition_and_sum/1.ans: -------------------------------------------------------------------------------- 1 | 8 2 | 10 3 | 4 4 | -------------------------------------------------------------------------------- /algo_lib/tests/a_assignment_and_maximal_segment/1.ans: -------------------------------------------------------------------------------- 1 | 15 2 | 7 3 | 3 4 | -------------------------------------------------------------------------------- /algo_lib/tests/a_segment_with_the_maximum_sum/1.ans: -------------------------------------------------------------------------------- 1 | 8 2 | 11 3 | 7 4 | -------------------------------------------------------------------------------- /algo_lib/tests/a_segment_with_the_maximum_sum/2.ans: -------------------------------------------------------------------------------- 1 | 0 2 | 3 3 | 3 4 | -------------------------------------------------------------------------------- /algo_lib/tests/a_suffix_array_and_lcp/2.ans: -------------------------------------------------------------------------------- 1 | 4 3 2 1 0 2 | 0 1 2 3 3 | -------------------------------------------------------------------------------- /algo_lib/tests/all_equal/1.in: -------------------------------------------------------------------------------- 1 | 4 2 | 1 5 3 | 3 4 4 | 5 5 5 | 343 1093 6 | -------------------------------------------------------------------------------- /algo_lib/tests/b_longest_common_substring/1.in: -------------------------------------------------------------------------------- 1 | bababb 2 | zabacabba 3 | -------------------------------------------------------------------------------- /algo_lib/tests/b_longest_common_substring/2.in: -------------------------------------------------------------------------------- 1 | qrdq 2 | rqqqrdqrqd 3 | -------------------------------------------------------------------------------- /algo_lib/tests/b_longest_common_substring/3.in: -------------------------------------------------------------------------------- 1 | hhhhhh 2 | hhhhhhh 3 | -------------------------------------------------------------------------------- /algo_lib/tests/b_longest_common_substring/4.in: -------------------------------------------------------------------------------- 1 | opopo 2 | ppppopopo 3 | -------------------------------------------------------------------------------- /algo_lib/tests/b_multiplication_and_sum/1.ans: -------------------------------------------------------------------------------- 1 | 3 2 | 24 3 | 28 4 | 5 5 | -------------------------------------------------------------------------------- /algo_lib/tests/b_segment_tree_for_the_minimum/1.ans: -------------------------------------------------------------------------------- 1 | 2 2 | 4 3 | 1 4 | -------------------------------------------------------------------------------- /algo_lib/tests/c_the_case_of_the_last_emperor/1.ans: -------------------------------------------------------------------------------- 1 | 8 2 | 16 3 | 32 4 | -------------------------------------------------------------------------------- /algo_lib/tests/d_intersecting_segments/1.in: -------------------------------------------------------------------------------- 1 | 5 2 | 5 1 2 2 3 1 3 4 5 4 3 | -------------------------------------------------------------------------------- /algo_lib/tests/d_maksimum_minimum_kolichestvo/0.in: -------------------------------------------------------------------------------- 1 | 1 2 | 3 3 | 4 5 4 4 | -------------------------------------------------------------------------------- /algo_lib/tests/dynamic_tree_vertex_add_subtree_sum/.failed_999.ans: -------------------------------------------------------------------------------- 1 | 5 2 | -------------------------------------------------------------------------------- /algo_lib/tests/e_assignment_and_minimum/1.ans: -------------------------------------------------------------------------------- 1 | 3 2 | 4 3 | 4 4 | 0 5 | -------------------------------------------------------------------------------- /algo_lib/tests/e_min_cost_flow/1.in: -------------------------------------------------------------------------------- 1 | 3 1 2 | 5 3 2 3 | 1 4 8 4 | 7 6 9 5 | -------------------------------------------------------------------------------- /algo_lib/tests/f_decoding_the_maya_code/1.ans: -------------------------------------------------------------------------------- 1 | 6 2 | 1 3 | 3 4 | 3 5 | -------------------------------------------------------------------------------- /algo_lib/tests/f_decoding_the_maya_code/2.ans: -------------------------------------------------------------------------------- 1 | 9 2 | 5 3 | 2 4 | 0 5 | -------------------------------------------------------------------------------- /algo_lib/tests/g_fine_triplets/3.in: -------------------------------------------------------------------------------- 1 | 10 2 | 13 1 16 15 12 4 7 10 2 19 3 | -------------------------------------------------------------------------------- /algo_lib/tests/g_forward_v2/1.ans: -------------------------------------------------------------------------------- 1 | 5 2 2 | 1 1 3 | 4 1 4 | 2 0 5 | 3 0 6 | -------------------------------------------------------------------------------- /algo_lib/tests/j_another/1.ans: -------------------------------------------------------------------------------- 1 | 5 6 -1 2 | 5 3 1 3 | 2 6 -1 4 | 2 6 4 5 | -------------------------------------------------------------------------------- /algo_lib/tests/kinds_of_people/2.ans: -------------------------------------------------------------------------------- 1 | binary 2 | decimal 3 | neither 4 | -------------------------------------------------------------------------------- /algo_lib/tests/l_the_easiest_task/1.ans: -------------------------------------------------------------------------------- 1 | 1 1 2 | 3 1 2 2 3 | 2 3 4 4 | -------------------------------------------------------------------------------- /algo_lib/tests/linear_recurrences/2.ans: -------------------------------------------------------------------------------- 1 | 7282 2 | 0 3 | 16 4 | 299255 5 | -------------------------------------------------------------------------------- /algo_lib/tests/m_ordainer_of_inexorable_judgment/1.ans: -------------------------------------------------------------------------------- 1 | 1.000000000000 2 | -------------------------------------------------------------------------------- /algo_lib/tests/m_ordainer_of_inexorable_judgment/2.ans: -------------------------------------------------------------------------------- 1 | 1.570796326795 2 | -------------------------------------------------------------------------------- /algo_lib/tests/matching_on_bipartite_graph/1.ans: -------------------------------------------------------------------------------- 1 | 3 2 | 0 0 3 | 1 1 4 | 2 2 -------------------------------------------------------------------------------- /algo_lib/tests/min_max_paths/0.in: -------------------------------------------------------------------------------- 1 | 1 2 | 4 2 3 | 3 4 4 | 3 2 5 | 1 3 6 | -------------------------------------------------------------------------------- /algo_lib/tests/perfect_pth_powers/1.in: -------------------------------------------------------------------------------- 1 | 17 2 | 1073741824 3 | 25 4 | 0 5 | -------------------------------------------------------------------------------- /algo_lib/tests/polynomial_multiplication_2/1.ans: -------------------------------------------------------------------------------- 1 | 3 2 | 0 -2 0 -10 3 | -------------------------------------------------------------------------------- /algo_lib/tests/similar_pair/1.in: -------------------------------------------------------------------------------- 1 | 5 2 2 | 3 2 3 | 3 1 4 | 1 4 5 | 1 5 6 | -------------------------------------------------------------------------------- /algo_lib/tests/task_1553_caves_and_tunnels/1.ans: -------------------------------------------------------------------------------- 1 | 1 2 | 0 3 | 1 4 | 3 5 | -------------------------------------------------------------------------------- /algo_lib/tests/ucucp_11_o/.failed_998.in: -------------------------------------------------------------------------------- 1 | 2 3 2 | 1 2 3 | 4 2 4 | 4 2 5 | -------------------------------------------------------------------------------- /algo_lib/tests/ucup_11_a/2.in: -------------------------------------------------------------------------------- 1 | 3 2 | 123456789 3 | 987654321 4 | 999999999 -------------------------------------------------------------------------------- /algo_lib/tests/walrus_weights/1.in: -------------------------------------------------------------------------------- 1 | 4 2 | 900 3 | 500 4 | 498 5 | 4 6 | -------------------------------------------------------------------------------- /algo_lib/tests/wheres_my_internet/3.in: -------------------------------------------------------------------------------- 1 | 4 3 2 | 2 3 3 | 4 2 4 | 3 4 5 | -------------------------------------------------------------------------------- /algo_lib/tests/a_suffix_array_and_lcp/1.ans: -------------------------------------------------------------------------------- 1 | 6 5 0 2 4 1 3 2 | 0 1 2 0 2 1 3 | -------------------------------------------------------------------------------- /algo_lib/tests/c_first_element_at_least_x/1.ans: -------------------------------------------------------------------------------- 1 | 1 2 | 4 3 | 2 4 | -1 5 | 3 6 | -------------------------------------------------------------------------------- /algo_lib/tests/c_number_of_minimums_on_a_segment/1.ans: -------------------------------------------------------------------------------- 1 | 3 2 2 | 2 1 3 | 2 3 4 | -------------------------------------------------------------------------------- /algo_lib/tests/chinese_remainder/1.in: -------------------------------------------------------------------------------- 1 | 2 2 | 1 2 2 3 3 | 151 783 57 278 4 | -------------------------------------------------------------------------------- /algo_lib/tests/e_min_cost_flow/2.in: -------------------------------------------------------------------------------- 1 | 3 2 2 | 10 10 1 3 | 10 10 1 4 | 1 1 10 5 | -------------------------------------------------------------------------------- /algo_lib/tests/fenwick_tree/2.in: -------------------------------------------------------------------------------- 1 | 5 4 2 | + 0 -43 3 | + 4 1 4 | ? 0 5 | ? 5 6 | -------------------------------------------------------------------------------- /algo_lib/tests/grid/3.in: -------------------------------------------------------------------------------- 1 | 5 4 2 | 2120 3 | 1203 4 | 3113 5 | 1120 6 | 1110 7 | -------------------------------------------------------------------------------- /algo_lib/tests/kannas_friendship/1.ans: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 2 4 | 5 5 | 7 6 | 10 7 | -------------------------------------------------------------------------------- /algo_lib/tests/kovzanka/1.in: -------------------------------------------------------------------------------- 1 | 0 0 2 | 0 3 3 | 4 0 4 | 2 5 | -1 -1 6 | 5 2 7 | -------------------------------------------------------------------------------- /algo_lib/tests/linear_recurrences/1.ans: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | 2 4 | 3 5 | 5 6 | 8 7 | -------------------------------------------------------------------------------- /algo_lib/tests/m_ordainer_of_inexorable_judgment/3.ans: -------------------------------------------------------------------------------- 1 | 2500.707752257475 2 | -------------------------------------------------------------------------------- /algo_lib/tests/minimum_cost_maximum_flow/2.in: -------------------------------------------------------------------------------- 1 | 2 1 0 1 2 | 0 1 1000 100 3 | -------------------------------------------------------------------------------- /algo_lib/tests/minimum_cost_maximum_flow/3.in: -------------------------------------------------------------------------------- 1 | 2 1 1 0 2 | 0 1 1000 100 3 | -------------------------------------------------------------------------------- /algo_lib/tests/prime_sieve/1.ans: -------------------------------------------------------------------------------- 1 | 1229 2 | 0 3 | 1 4 | 1 5 | 0 6 | 0 7 | 1 8 | -------------------------------------------------------------------------------- /algo_lib/tests/roy_and_tree_permutation/1.ans: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | 3 4 | 0 5 | 3 6 | -------------------------------------------------------------------------------- /algo_lib/tests/task/5.ans: -------------------------------------------------------------------------------- 1 | 4 4 8 0 2 | 8 4 0 0 3 | 32 32 0 0 4 | 32 32 32 0 5 | -------------------------------------------------------------------------------- /algo_lib/tests/task/6.ans: -------------------------------------------------------------------------------- 1 | 0 4 4 8 2 | 0 0 4 8 3 | 0 0 32 32 4 | 0 32 32 32 5 | -------------------------------------------------------------------------------- /algo_lib/tests/triangle_count_hard/1.ans: -------------------------------------------------------------------------------- 1 | 3 7 15 2 | 1 6 9 20 53 3 | 3 137 4 | -------------------------------------------------------------------------------- /algo_lib/tests/wheres_my_internet/1.in: -------------------------------------------------------------------------------- 1 | 6 4 2 | 1 2 3 | 2 3 4 | 3 4 5 | 5 6 6 | -------------------------------------------------------------------------------- /templates/main/stdin.rs: -------------------------------------------------------------------------------- 1 | let input = algo_lib::io::input::Input::stdin(); -------------------------------------------------------------------------------- /algo_lib/tests/a_next/1.in: -------------------------------------------------------------------------------- 1 | 6 2 | + 1 3 | + 3 4 | + 3 5 | ? 2 6 | + 1 7 | ? 4 8 | -------------------------------------------------------------------------------- /algo_lib/tests/a_substring_search/1.in: -------------------------------------------------------------------------------- 1 | ababba 2 | 3 3 | ba 4 | baba 5 | abba 6 | -------------------------------------------------------------------------------- /algo_lib/tests/b_counting_substrings/1.in: -------------------------------------------------------------------------------- 1 | ababba 2 | 3 3 | ba 4 | baba 5 | abba 6 | -------------------------------------------------------------------------------- /algo_lib/tests/c_bitwise_or_and_and/2.in: -------------------------------------------------------------------------------- 1 | 2 3 2 | 1 0 1 3 3 | 1 1 2 9 4 | 2 0 2 5 | -------------------------------------------------------------------------------- /algo_lib/tests/c_sorting_substrings/3.ans: -------------------------------------------------------------------------------- 1 | 1 1 2 | 1 1 3 | 2 2 4 | 2 2 5 | 1 2 6 | -------------------------------------------------------------------------------- /algo_lib/tests/d_first_element_at_least_x_2/1.ans: -------------------------------------------------------------------------------- 1 | 1 2 | 3 3 | 2 4 | -1 5 | 3 6 | -------------------------------------------------------------------------------- /algo_lib/tests/d_number_of_different_on_segment/1.ans: -------------------------------------------------------------------------------- 1 | 3 2 | 4 3 | 3 4 | 6 5 | 3 6 | -------------------------------------------------------------------------------- /algo_lib/tests/fenwick_tree/1.in: -------------------------------------------------------------------------------- 1 | 10 4 2 | + 7 23 3 | ? 8 4 | + 3 17 5 | ? 8 6 | -------------------------------------------------------------------------------- /algo_lib/tests/k_range_affine_range_sum/1.ans: -------------------------------------------------------------------------------- 1 | 15 2 | 404 3 | 41511 4 | 4317767 5 | -------------------------------------------------------------------------------- /algo_lib/tests/kinds_of_people/1.in: -------------------------------------------------------------------------------- 1 | 1 4 2 | 1100 3 | 2 4 | 1 1 1 4 5 | 1 1 1 1 6 | -------------------------------------------------------------------------------- /algo_lib/tests/nine_knights/1.in: -------------------------------------------------------------------------------- 1 | ...k. 2 | ...k. 3 | k.k.. 4 | .k.k. 5 | k.k.k 6 | -------------------------------------------------------------------------------- /algo_lib/tests/nine_knights/2.in: -------------------------------------------------------------------------------- 1 | ..... 2 | ...k. 3 | k.k.k 4 | .k.k. 5 | k.k.k 6 | -------------------------------------------------------------------------------- /algo_lib/tests/nine_knights/3.in: -------------------------------------------------------------------------------- 1 | ..... 2 | ...k. 3 | k.k.k 4 | .k.k. 5 | k...k 6 | -------------------------------------------------------------------------------- /algo_lib/tests/problems/1.in: -------------------------------------------------------------------------------- 1 | 3 4 2 | 10 10 11 3 | 1 10 4 | 1 10 5 | 1 9 6 | 1 5 7 | -------------------------------------------------------------------------------- /algo_lib/tests/task/1.ans: -------------------------------------------------------------------------------- 1 | 4 0 0 0 2 | 4 16 8 2 3 | 2 64 32 4 4 | 2048 64 0 0 5 | -------------------------------------------------------------------------------- /algo_lib/tests/task/2.ans: -------------------------------------------------------------------------------- 1 | 2 16 8 4 2 | 4 64 32 4 3 | 2 1024 64 0 4 | 1024 0 0 0 5 | -------------------------------------------------------------------------------- /algo_lib/tests/task/3.ans: -------------------------------------------------------------------------------- 1 | 0 0 0 4 2 | 4 16 8 2 3 | 2 64 32 4 4 | 0 0 2048 64 5 | -------------------------------------------------------------------------------- /algo_lib/tests/task/4.ans: -------------------------------------------------------------------------------- 1 | 2 0 0 0 2 | 4 16 8 0 3 | 2 64 32 4 4 | 1024 1024 64 4 5 | -------------------------------------------------------------------------------- /algo_lib/tests/the_easiest_problem_is_this_one/1.ans: -------------------------------------------------------------------------------- 1 | 37 2 | 28 3 | 28 4 | 25 5 | -------------------------------------------------------------------------------- /algo_lib/tests/union_find/1.in: -------------------------------------------------------------------------------- 1 | 10 4 2 | ? 1 3 3 | = 1 8 4 | = 3 8 5 | ? 1 3 6 | -------------------------------------------------------------------------------- /templates/main/stdout.rs: -------------------------------------------------------------------------------- 1 | let output = algo_lib::io::output::Output::stdout(); -------------------------------------------------------------------------------- /algo_lib/tests/a_next/.failed_999.ans: -------------------------------------------------------------------------------- 1 | -1 2 | -1 3 | 232729849 4 | 232729849 5 | -1 6 | -------------------------------------------------------------------------------- /algo_lib/tests/a_substring_search/2.in: -------------------------------------------------------------------------------- 1 | codeforces 2 | 3 3 | code 4 | forces 5 | math 6 | -------------------------------------------------------------------------------- /algo_lib/tests/c2_yet_another_nim_game_counting_version/1.in: -------------------------------------------------------------------------------- 1 | 3 2 | 1 3 | 4 4 | 7 5 | -------------------------------------------------------------------------------- /algo_lib/tests/c_addition_and_first_element_at_least_x/1.ans: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 4 4 | 4 5 | -------------------------------------------------------------------------------- /algo_lib/tests/c_number_of_inversions_on_segment/1.ans: -------------------------------------------------------------------------------- 1 | 0 2 | 1 3 | 0 4 | 7 5 | 1 6 | -------------------------------------------------------------------------------- /algo_lib/tests/c_painter/1.ans: -------------------------------------------------------------------------------- 1 | 0 0 2 | 1 2 3 | 1 4 4 | 1 4 5 | 2 6 6 | 3 5 7 | 0 0 8 | -------------------------------------------------------------------------------- /algo_lib/tests/cookie_selection/1.in: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | # 6 | # 7 | # 8 | # 9 | -------------------------------------------------------------------------------- /algo_lib/tests/cookie_selection/2.in: -------------------------------------------------------------------------------- 1 | 1 2 | # 3 | 2 4 | # 5 | 3 6 | # 7 | 4 8 | # 9 | -------------------------------------------------------------------------------- /algo_lib/tests/engineering_english/2.ans: -------------------------------------------------------------------------------- 1 | he said that . . . . man used 2 | was wrong 3 | -------------------------------------------------------------------------------- /algo_lib/tests/f1_sverkhskorostnoi_podschyot_prostaya_versiya/0.in: -------------------------------------------------------------------------------- 1 | 1 2 | 2 998244353 3 | -------------------------------------------------------------------------------- /algo_lib/tests/galactic_collegiate_programming_contest/1.ans: -------------------------------------------------------------------------------- 1 | 2 2 | 3 3 | 2 4 | 1 5 | -------------------------------------------------------------------------------- /algo_lib/tests/j_royal_waterways/2.in: -------------------------------------------------------------------------------- 1 | 3 2 | 1 0 0 5 0 3 | 1 0 5 0 0 4 | 1 5 5 0 5 5 | -------------------------------------------------------------------------------- /algo_lib/tests/modular_arithmetic/1.ans: -------------------------------------------------------------------------------- 1 | 999 2 | -1 3 | 884 4 | 8 5 | 1 6 | 4 7 | 7 8 | -------------------------------------------------------------------------------- /algo_lib/tests/money_matters/2.in: -------------------------------------------------------------------------------- 1 | 4 2 2 | 15 3 | 20 4 | -10 5 | -25 6 | 0 2 7 | 1 3 8 | -------------------------------------------------------------------------------- /algo_lib/tests/polynomial_multiplication_2/1.in: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 1 0 5 4 | 1 5 | 0 -2 6 | -------------------------------------------------------------------------------- /algo_lib/tests/prime_sieve/1.in: -------------------------------------------------------------------------------- 1 | 9973 6 2 | 1 3 | 2 4 | 3 5 | 4 6 | 9972 7 | 9973 8 | -------------------------------------------------------------------------------- /algo_lib/tests/problems/2.in: -------------------------------------------------------------------------------- 1 | 3 4 2 | 10 10 11 3 | 2 10 4 | 2 10 5 | 2 10 6 | 2 15 7 | -------------------------------------------------------------------------------- /algo_lib/tests/rational_arithmetic/1.ans: -------------------------------------------------------------------------------- 1 | 5 / 6 2 | -1 / 6 3 | -82 / 189 4 | -4 / 1 5 | -------------------------------------------------------------------------------- /algo_lib/tests/task/1.in: -------------------------------------------------------------------------------- 1 | 2 0 0 2 2 | 4 16 8 2 3 | 2 64 32 4 4 | 1024 1024 64 0 5 | 0 6 | -------------------------------------------------------------------------------- /algo_lib/tests/task/2.in: -------------------------------------------------------------------------------- 1 | 2 0 0 2 2 | 4 16 8 2 3 | 2 64 32 4 4 | 1024 1024 64 0 5 | 1 6 | -------------------------------------------------------------------------------- /algo_lib/tests/task/3.in: -------------------------------------------------------------------------------- 1 | 2 0 0 2 2 | 4 16 8 2 3 | 2 64 32 4 4 | 1024 1024 64 0 5 | 2 6 | -------------------------------------------------------------------------------- /algo_lib/tests/task/4.in: -------------------------------------------------------------------------------- 1 | 2 0 0 2 2 | 4 16 8 2 3 | 2 64 32 4 4 | 1024 1024 64 0 5 | 3 6 | -------------------------------------------------------------------------------- /algo_lib/tests/task/5.in: -------------------------------------------------------------------------------- 1 | 2 2 4 8 2 | 4 0 4 4 3 | 16 16 16 16 4 | 32 16 16 32 5 | 0 6 | -------------------------------------------------------------------------------- /algo_lib/tests/task/6.in: -------------------------------------------------------------------------------- 1 | 2 2 4 8 2 | 4 0 4 4 3 | 16 16 16 16 4 | 32 16 16 32 5 | 2 6 | -------------------------------------------------------------------------------- /algo_lib/tests/the_easiest_problem_is_this_one/1.in: -------------------------------------------------------------------------------- 1 | 3029 2 | 4 3 | 5 4 | 42 5 | 0 6 | -------------------------------------------------------------------------------- /algo_lib/tests/ucucp_11_o/.failed_996.in: -------------------------------------------------------------------------------- 1 | 3 5 2 | 5 4 3 | 6 3 4 | 6 2 5 | 1 4 6 | 6 5 7 | -------------------------------------------------------------------------------- /algo_lib/tests/union_find/2.in: -------------------------------------------------------------------------------- 1 | 4 5 2 | ? 0 0 3 | = 0 1 4 | = 1 2 5 | = 0 2 6 | ? 0 3 7 | -------------------------------------------------------------------------------- /algo_lib/tests/a_assignment_and_maximal_segment/1.in: -------------------------------------------------------------------------------- 1 | 5 3 2 | 0 5 3 3 | 1 3 -1 4 | 3 4 -5 5 | -------------------------------------------------------------------------------- /algo_lib/tests/a_next/.failed_998.in: -------------------------------------------------------------------------------- 1 | 3 2 | + 808663477 3 | + 166222175 4 | ? 445121814 5 | -------------------------------------------------------------------------------- /algo_lib/tests/a_segment_with_the_maximum_sum/1.in: -------------------------------------------------------------------------------- 1 | 5 2 2 | 5 -4 4 3 -5 3 | 4 3 4 | 3 -1 5 | -------------------------------------------------------------------------------- /algo_lib/tests/a_segment_with_the_maximum_sum/2.in: -------------------------------------------------------------------------------- 1 | 4 2 2 | -2 -1 -5 -4 3 | 1 3 4 | 3 2 5 | -------------------------------------------------------------------------------- /algo_lib/tests/a_suffix_array_and_lcp/3.ans: -------------------------------------------------------------------------------- 1 | 9 5 8 4 7 3 6 2 1 0 2 | 0 0 1 1 2 2 3 3 4 3 | -------------------------------------------------------------------------------- /algo_lib/tests/almost_perfect/1.ans: -------------------------------------------------------------------------------- 1 | 6 perfect 2 | 65 not perfect 3 | 650 almost perfect 4 | -------------------------------------------------------------------------------- /algo_lib/tests/c_isnova_summa/1.in: -------------------------------------------------------------------------------- 1 | 6 2 | + 1 3 | + 3 4 | + 3 5 | ? 2 4 6 | + 1 7 | ? 2 4 8 | -------------------------------------------------------------------------------- /algo_lib/tests/c_sorting_substrings/1.ans: -------------------------------------------------------------------------------- 1 | 1 1 2 | 1 2 3 | 1 3 4 | 5 7 5 | 3 4 6 | 4 7 7 | -------------------------------------------------------------------------------- /algo_lib/tests/c_sorting_substrings/3.in: -------------------------------------------------------------------------------- 1 | aa 2 | 5 3 | 1 1 4 | 1 2 5 | 2 2 6 | 1 1 7 | 2 2 8 | -------------------------------------------------------------------------------- /algo_lib/tests/continuous_median/1.in: -------------------------------------------------------------------------------- 1 | 2 2 | 6 3 | 1 3 6 2 7 8 4 | 7 5 | 1 3 6 2 7 8 5 6 | -------------------------------------------------------------------------------- /algo_lib/tests/download_speed/1.in: -------------------------------------------------------------------------------- 1 | 4 5 2 | 1 2 3 3 | 2 4 2 4 | 1 3 4 5 | 3 4 5 6 | 4 1 3 7 | -------------------------------------------------------------------------------- /algo_lib/tests/e_euclids_tree/1.in: -------------------------------------------------------------------------------- 1 | 1 2 | 5 3 | 4 6 6 6 5 4 | 1 5 5 | 2 5 6 | 5 4 7 | 3 4 8 | -------------------------------------------------------------------------------- /algo_lib/tests/g_scc/1.in: -------------------------------------------------------------------------------- 1 | 6 7 2 | 1 4 3 | 5 2 4 | 3 0 5 | 5 5 6 | 4 1 7 | 0 3 8 | 4 2 9 | -------------------------------------------------------------------------------- /algo_lib/tests/j_royal_waterways/1.in: -------------------------------------------------------------------------------- 1 | 3 2 | 2 0 0 1 0 3 | 2 0 5 1 5 4 | 4 1 -10 -5 10 5 | -------------------------------------------------------------------------------- /algo_lib/tests/k_reka/1.in: -------------------------------------------------------------------------------- 1 | 4 0 2 | 3 5 5 4 3 | 5 4 | 1 1 5 | 2 1 6 | 1 3 7 | 2 2 8 | 1 3 9 | -------------------------------------------------------------------------------- /algo_lib/tests/line_segment_distance/1.ans: -------------------------------------------------------------------------------- 1 | 0.00 2 | 0.00 3 | 0.00 4 | 1.00 5 | 713.86 6 | -------------------------------------------------------------------------------- /algo_lib/tests/m_ordainer_of_inexorable_judgment/1.in: -------------------------------------------------------------------------------- 1 | 3 1 0 1 1 2 | 1 2 3 | 2 1 4 | 2 2 5 | -------------------------------------------------------------------------------- /algo_lib/tests/m_ordainer_of_inexorable_judgment/2.in: -------------------------------------------------------------------------------- 1 | 3 1 0 1 2 2 | 1 2 3 | 2 1 4 | 2 2 5 | -------------------------------------------------------------------------------- /algo_lib/tests/maximum_flow/1.ans: -------------------------------------------------------------------------------- 1 | 4 3 5 2 | 0 1 2 3 | 0 2 1 4 | 1 2 1 5 | 1 3 1 6 | 2 3 2 7 | -------------------------------------------------------------------------------- /algo_lib/tests/numismatics/1.in: -------------------------------------------------------------------------------- 1 | 1 2 | 7 4 3 | 0101100 4 | 2 1 5 | 1 3 6 6 | 1 2 4 7 | 2 1 8 | -------------------------------------------------------------------------------- /algo_lib/tests/running_mom/1.ans: -------------------------------------------------------------------------------- 1 | San_Antonio safe 2 | Baltimore safe 3 | New_York trapped 4 | -------------------------------------------------------------------------------- /algo_lib/tests/ucucp_11_o/2.in: -------------------------------------------------------------------------------- 1 | 3 7 2 | 2 5 3 | 1 3 4 | 4 6 5 | 2 6 6 | 4 5 7 | 2 4 8 | 5 6 -------------------------------------------------------------------------------- /algo_lib/src/numbers/primes/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod factorize; 2 | pub mod prime; 3 | pub mod sieve; 4 | -------------------------------------------------------------------------------- /algo_lib/tests/a_addition_to_segment/1.in: -------------------------------------------------------------------------------- 1 | 5 5 2 | 1 0 3 3 3 | 2 1 4 | 1 2 4 4 5 | 2 3 6 | 2 4 7 | -------------------------------------------------------------------------------- /algo_lib/tests/b_counting_substrings/2.in: -------------------------------------------------------------------------------- 1 | itmouniversity 2 | 3 3 | it 4 | more 5 | university 6 | -------------------------------------------------------------------------------- /algo_lib/tests/b_multiplication_and_sum/2.in: -------------------------------------------------------------------------------- 1 | 2 3 2 | 1 0 1 1000000 3 | 1 0 2 1000000 4 | 2 0 2 5 | -------------------------------------------------------------------------------- /algo_lib/tests/coast_length/1.in: -------------------------------------------------------------------------------- 1 | 5 6 2 | 011110 3 | 010110 4 | 111000 5 | 000010 6 | 000000 7 | -------------------------------------------------------------------------------- /algo_lib/tests/conga_line/1.in: -------------------------------------------------------------------------------- 1 | 3 6 2 | amelia bubba 3 | kiryu coco 4 | ollie udin 5 | PBBPFP 6 | -------------------------------------------------------------------------------- /algo_lib/tests/dynamic_tree_subtree_add_subtree_sum/1.ans: -------------------------------------------------------------------------------- 1 | 11110 2 | 310111 3 | 210011 4 | 401111 -------------------------------------------------------------------------------- /algo_lib/tests/dynamic_tree_vertex_add_subtree_sum/1.ans: -------------------------------------------------------------------------------- 1 | 10011 2 | 110011 3 | 110011 4 | 101111 -------------------------------------------------------------------------------- /algo_lib/tests/e_addition_to_segment/1.in: -------------------------------------------------------------------------------- 1 | 5 5 2 | 1 0 3 3 3 | 2 1 4 | 1 2 4 4 5 | 2 3 6 | 2 4 7 | -------------------------------------------------------------------------------- /algo_lib/tests/e_wall/1.ans: -------------------------------------------------------------------------------- 1 | 3 2 | 4 3 | 5 4 | 4 5 | 3 6 | 3 7 | 0 8 | 0 9 | 1 10 | 0 11 | -------------------------------------------------------------------------------- /algo_lib/tests/g_fine_triplets/2.in: -------------------------------------------------------------------------------- 1 | 7 2 | 300000 100000 499998 499999 200000 400000 500000 3 | -------------------------------------------------------------------------------- /algo_lib/tests/l_the_easiest_task/1.in: -------------------------------------------------------------------------------- 1 | 3 2 2 | 3 1 2 3 3 | 3 1 2 4 4 | 0 5 | 1 2 2 6 | 2 3 3 7 | -------------------------------------------------------------------------------- /algo_lib/tests/m_ordainer_of_inexorable_judgment/3.in: -------------------------------------------------------------------------------- 1 | 3 1 0 1 10000 2 | 1 2 3 | 2 1 4 | 2 2 5 | -------------------------------------------------------------------------------- /algo_lib/tests/maximum_flow/1.in: -------------------------------------------------------------------------------- 1 | 4 5 0 3 2 | 0 1 10 3 | 1 2 1 4 | 1 3 1 5 | 0 2 1 6 | 2 3 10 7 | -------------------------------------------------------------------------------- /algo_lib/tests/virtual_friends/1.in: -------------------------------------------------------------------------------- 1 | 1 2 | 3 3 | Fred Barney 4 | Barney Betty 5 | Betty Wilma 6 | -------------------------------------------------------------------------------- /algo_lib/tests/b_applying_max_to_segment/1.in: -------------------------------------------------------------------------------- 1 | 5 5 2 | 1 0 3 3 3 | 2 1 4 | 1 2 4 4 5 | 2 3 6 | 2 4 7 | -------------------------------------------------------------------------------- /algo_lib/tests/big_sorting/1.ans: -------------------------------------------------------------------------------- 1 | 1 2 | 3 3 | 3 4 | 5 5 | 10 6 | 31415926535897932384626433832795 7 | -------------------------------------------------------------------------------- /algo_lib/tests/c_assignment_to_segment/1.in: -------------------------------------------------------------------------------- 1 | 5 5 2 | 1 0 3 3 3 | 2 1 4 | 1 2 4 4 5 | 2 3 6 | 2 4 7 | -------------------------------------------------------------------------------- /algo_lib/tests/download_speed/0.in: -------------------------------------------------------------------------------- 1 | 4 6 2 | 1 3 8 3 | 4 3 4 4 | 2 4 10 5 | 1 2 5 6 | 1 2 2 7 | 3 2 8 8 | -------------------------------------------------------------------------------- /algo_lib/tests/encoded_message/1.ans: -------------------------------------------------------------------------------- 1 | TOPSECRET 2 | RosesAreRedVioletsAreBlue 3 | SquaresMayBeEven 4 | -------------------------------------------------------------------------------- /algo_lib/tests/engineering_english/2.in: -------------------------------------------------------------------------------- 1 | he said that that that that that man used 2 | was wrong 3 | -------------------------------------------------------------------------------- /algo_lib/tests/f_mountain/1.in: -------------------------------------------------------------------------------- 1 | 4 2 | Q 1 3 | I 1 4 2 4 | Q 3 5 | Q 1 6 | I 2 2 -1 7 | Q 3 8 | E 9 | -------------------------------------------------------------------------------- /algo_lib/tests/f_mountain/mou0.in: -------------------------------------------------------------------------------- 1 | 4 2 | Q 1 3 | I 1 4 2 4 | Q 3 5 | Q 1 6 | I 2 2 -1 7 | Q 3 8 | E 9 | -------------------------------------------------------------------------------- /algo_lib/tests/galactic_collegiate_programming_contest/1.in: -------------------------------------------------------------------------------- 1 | 3 4 2 | 2 7 3 | 3 5 4 | 1 6 5 | 1 9 6 | -------------------------------------------------------------------------------- /algo_lib/tests/get_shorty/1.in: -------------------------------------------------------------------------------- 1 | 3 3 2 | 0 1 0.9 3 | 1 2 0.9 4 | 0 2 0.8 5 | 2 1 6 | 1 0 1 7 | 0 0 8 | -------------------------------------------------------------------------------- /algo_lib/tests/j_royal_waterways/3.in: -------------------------------------------------------------------------------- 1 | 4 2 | 1 0 0 5 0 3 | 1 0 5 0 0 4 | 1 5 5 0 5 5 | 1 5 0 0 0 6 | -------------------------------------------------------------------------------- /algo_lib/tests/linear_recurrences/3.in: -------------------------------------------------------------------------------- 1 | 3 2 | 1 2 3 4 3 | 0 0 0 4 | 1 5 | 42424242424242 1000000 6 | -------------------------------------------------------------------------------- /algo_lib/tests/minimum_spanning_tree/1.ans: -------------------------------------------------------------------------------- 1 | 3 2 | 0 1 3 | 1 2 4 | 2 3 5 | 100 6 | 0 1 7 | Impossible 8 | -------------------------------------------------------------------------------- /algo_lib/tests/polynomial_multiplication_1/1.ans: -------------------------------------------------------------------------------- 1 | 3 2 | 0 -2 0 -10 3 | 8 4 | 9 1 -10 30 5 -2 8 11 5 5 | -------------------------------------------------------------------------------- /algo_lib/tests/supercomputer/1.in: -------------------------------------------------------------------------------- 1 | 6 7 2 | F 3 3 | C 2 5 4 | F 3 5 | F 4 6 | F 5 7 | C 2 5 8 | C 1 4 9 | -------------------------------------------------------------------------------- /templates/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | rust_competitive_helper_util::build::build_new(false); 3 | } 4 | -------------------------------------------------------------------------------- /algo_lib/tests/all_pairs_shortest_path/1.ans: -------------------------------------------------------------------------------- 1 | 4 2 | 2 3 | Impossible 4 | 0 5 | 6 | 100 7 | Impossible 8 | -------------------------------------------------------------------------------- /algo_lib/tests/b_add_arithmetic_progression_on_segment/1.ans: -------------------------------------------------------------------------------- 1 | 5 2 | 9 3 | 13 4 | 19 5 | 3 6 | 6 7 | 10 8 | -------------------------------------------------------------------------------- /algo_lib/tests/b_fenwick_tree/1.in: -------------------------------------------------------------------------------- 1 | 5 5 2 | 1 2 3 4 5 3 | 1 0 5 4 | 1 2 4 5 | 0 3 10 6 | 1 0 5 7 | 1 0 3 8 | -------------------------------------------------------------------------------- /algo_lib/tests/big_sorting/1.in: -------------------------------------------------------------------------------- 1 | 6 2 | 31415926535897932384626433832795 3 | 1 4 | 3 5 | 10 6 | 3 7 | 5 8 | -------------------------------------------------------------------------------- /algo_lib/tests/c_painter/1.in: -------------------------------------------------------------------------------- 1 | 7 2 | W 2 3 3 | B 2 2 4 | B 4 2 5 | B 3 2 6 | B 7 2 7 | W 3 1 8 | W 0 10 9 | -------------------------------------------------------------------------------- /algo_lib/tests/c_sorting_substrings/1.in: -------------------------------------------------------------------------------- 1 | abacaba 2 | 6 3 | 4 7 4 | 1 2 5 | 1 1 6 | 3 4 7 | 5 7 8 | 1 3 9 | -------------------------------------------------------------------------------- /algo_lib/tests/c_the_case_of_the_last_emperor/1.in: -------------------------------------------------------------------------------- 1 | 3 3 3 2 | 1 2 3 | 2 3 4 | 1 3 5 | 1 3 6 | 2 4 7 | 3 5 8 | -------------------------------------------------------------------------------- /algo_lib/tests/conga_line/2.in: -------------------------------------------------------------------------------- 1 | 3 16 2 | amelia bubba 3 | kiryu coco 4 | ollie udin 5 | BRBPRFFPRBBBBBRP 6 | -------------------------------------------------------------------------------- /algo_lib/tests/e_fog_canyon/1.in: -------------------------------------------------------------------------------- 1 | 8 5 2 | 1 1 1 1 1 2 8 2 3 | 1 1 4 | 0 1 3 5 | 1 1 6 | 0 3 4 7 | 1 2 8 | -------------------------------------------------------------------------------- /algo_lib/tests/e_wall/1.in: -------------------------------------------------------------------------------- 1 | 10 6 2 | 1 1 8 4 3 | 2 4 9 1 4 | 2 3 6 5 5 | 1 0 5 3 6 | 1 2 2 5 7 | 2 6 7 0 8 | -------------------------------------------------------------------------------- /algo_lib/tests/encoded_message/1.in: -------------------------------------------------------------------------------- 1 | 3 2 | RSTEEOTCP 3 | eedARBtVrolsiesuAoReerles 4 | EarSvyeqeBsuneMa 5 | -------------------------------------------------------------------------------- /algo_lib/tests/j_segment_tree/1.in: -------------------------------------------------------------------------------- 1 | 5 5 2 | 1 2 3 2 1 3 | 2 1 5 4 | 3 2 3 5 | 1 3 1 6 | 2 2 4 7 | 3 1 3 8 | -------------------------------------------------------------------------------- /algo_lib/tests/matching_on_bipartite_graph/1.in: -------------------------------------------------------------------------------- 1 | 4 4 7 2 | 1 1 3 | 2 2 4 | 0 0 5 | 3 1 6 | 1 2 7 | 2 0 8 | 3 2 -------------------------------------------------------------------------------- /algo_lib/tests/reachable_roads/1.in: -------------------------------------------------------------------------------- 1 | 2 2 | 5 3 | 3 4 | 0 1 5 | 1 2 6 | 3 4 7 | 2 8 | 1 9 | 0 1 10 | -------------------------------------------------------------------------------- /algo_lib/tests/sequence_creation/1.in: -------------------------------------------------------------------------------- 1 | 2 2 | 4 3 | 2 2 3 2 4 | 2 3 4 4 5 | 5 6 | 1 2 2 3 3 7 | 2 1 2 3 1 8 | -------------------------------------------------------------------------------- /algo_lib/tests/triangle_count_hard/1.in: -------------------------------------------------------------------------------- 1 | 3 2 | 4 3 | 5 2 4 12 4 | 6 5 | 3 1 6 5 50 17 6 | 3 7 | 100 2 69 8 | -------------------------------------------------------------------------------- /templates/main/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | $INPUT 3 | $OUTPUT 4 | solution::run(input, output); 5 | } 6 | -------------------------------------------------------------------------------- /algo_lib/tests/a_sign_alternation/1.in: -------------------------------------------------------------------------------- 1 | 3 2 | 1 2 3 3 | 5 4 | 1 1 2 5 | 1 1 3 6 | 1 2 3 7 | 0 2 1 8 | 1 1 3 9 | -------------------------------------------------------------------------------- /algo_lib/tests/b_inverse_and_kth_one/1.in: -------------------------------------------------------------------------------- 1 | 5 7 2 | 1 1 3 3 | 2 1 4 | 1 0 2 5 | 2 0 6 | 2 1 7 | 1 0 5 8 | 2 2 9 | -------------------------------------------------------------------------------- /algo_lib/tests/c_bitwise_or_and_and/1.in: -------------------------------------------------------------------------------- 1 | 5 6 2 | 1 0 3 3 3 | 2 1 2 4 | 1 1 4 4 5 | 2 1 3 6 | 2 1 4 7 | 2 3 5 8 | -------------------------------------------------------------------------------- /algo_lib/tests/conga_line/3.in: -------------------------------------------------------------------------------- 1 | 3 22 2 | amelia bubba 3 | kiryu coco 4 | ollie udin 5 | BRBPRFFPRBBBBBRPCBBCFP 6 | -------------------------------------------------------------------------------- /algo_lib/tests/d_addition_and_sum/1.in: -------------------------------------------------------------------------------- 1 | 5 6 2 | 1 0 3 3 3 | 2 1 2 4 | 1 1 4 4 5 | 2 1 3 6 | 2 1 4 7 | 2 3 5 8 | -------------------------------------------------------------------------------- /algo_lib/tests/f_assignment_and_sum/1.in: -------------------------------------------------------------------------------- 1 | 5 6 2 | 1 0 3 3 3 | 2 1 2 4 | 1 2 4 4 5 | 2 1 3 6 | 2 1 4 7 | 2 3 5 8 | -------------------------------------------------------------------------------- /algo_lib/tests/f_decoding_the_maya_code/.failed_996.in: -------------------------------------------------------------------------------- 1 | 3 1 2 | AAB 3 | B 4 | ABA 5 | 1 2 6 | 2 3 7 | 1 AABA 8 | -------------------------------------------------------------------------------- /algo_lib/tests/j_another/1.in: -------------------------------------------------------------------------------- 1 | 6 6 2 | 1 2 3 4 5 6 3 | 2 4 4 | 1 1 2 4 5 5 | 2 4 6 | 2 1 7 | 1 1 3 4 6 8 | 2 1 9 | -------------------------------------------------------------------------------- /algo_lib/tests/l_lazy_segment_tree/1.in: -------------------------------------------------------------------------------- 1 | 5 5 2 | 0 1 0 0 1 3 | 2 1 5 4 | 1 3 4 5 | 2 2 5 6 | 1 1 3 7 | 2 1 2 8 | -------------------------------------------------------------------------------- /algo_lib/tests/minimum_cost_maximum_flow/1.in: -------------------------------------------------------------------------------- 1 | 4 4 0 3 2 | 0 1 4 10 3 | 1 2 2 10 4 | 0 2 4 30 5 | 2 3 4 10 6 | -------------------------------------------------------------------------------- /algo_lib/tests/rational_arithmetic/1.in: -------------------------------------------------------------------------------- 1 | 4 2 | 1 3 + 1 2 3 | 1 3 - 1 2 4 | 123 287 / 81 -82 5 | 12 -3 * -1 -1 6 | -------------------------------------------------------------------------------- /algo_lib/tests/string_multimatching/1.ans: -------------------------------------------------------------------------------- 1 | 2 4 2 | 2 3 | 4 | 5 5 | 7 6 | 1 3 5 7 7 | 1 3 5 7 8 | 1 3 5 7 9 12 9 | -------------------------------------------------------------------------------- /algo_lib/src/collections/md_arr/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod arr2d; 2 | pub mod arr3d; 3 | pub mod arr4d; 4 | pub mod arr5d; 5 | -------------------------------------------------------------------------------- /algo_lib/src/misc/direction.rs: -------------------------------------------------------------------------------- 1 | #[derive(Copy, Clone)] 2 | pub enum Direction { 3 | Left, 4 | Right, 5 | } 6 | -------------------------------------------------------------------------------- /algo_lib/tests/a_addition_and_minimum/1.in: -------------------------------------------------------------------------------- 1 | 5 6 2 | 1 0 3 3 3 | 2 1 2 4 | 1 1 4 4 5 | 2 1 3 6 | 2 1 4 7 | 2 3 5 8 | -------------------------------------------------------------------------------- /algo_lib/tests/a_disjoint_set_union/1.in: -------------------------------------------------------------------------------- 1 | 4 7 2 | 1 0 1 3 | 0 0 1 4 | 0 2 3 5 | 1 0 1 6 | 1 1 2 7 | 0 0 2 8 | 1 1 3 9 | -------------------------------------------------------------------------------- /algo_lib/tests/a_segment_tree_for_the_sum/1.in: -------------------------------------------------------------------------------- 1 | 5 5 2 | 5 4 2 3 5 3 | 2 0 3 4 | 1 1 1 5 | 2 0 3 6 | 1 3 1 7 | 2 0 5 8 | -------------------------------------------------------------------------------- /algo_lib/tests/b_kth_one/1.in: -------------------------------------------------------------------------------- 1 | 5 7 2 | 1 1 0 1 0 3 | 2 0 4 | 2 1 5 | 2 2 6 | 1 2 7 | 2 3 8 | 1 0 9 | 2 0 10 | -------------------------------------------------------------------------------- /algo_lib/tests/b_multiplication_and_sum/1.in: -------------------------------------------------------------------------------- 1 | 5 6 2 | 1 0 3 3 3 | 2 1 2 4 | 1 1 4 4 5 | 2 1 3 6 | 2 1 4 7 | 2 3 5 8 | -------------------------------------------------------------------------------- /algo_lib/tests/d_problem_about_weighted_sum/1.in: -------------------------------------------------------------------------------- 1 | 5 4 2 | 1 2 3 4 5 3 | 1 2 3 1 4 | 2 1 3 5 | 1 2 3 -1 6 | 2 1 5 7 | -------------------------------------------------------------------------------- /algo_lib/tests/e_assignment_and_minimum/1.in: -------------------------------------------------------------------------------- 1 | 5 6 2 | 1 0 3 3 3 | 2 1 2 4 | 1 1 4 4 5 | 2 1 3 6 | 2 1 4 7 | 2 3 5 8 | -------------------------------------------------------------------------------- /algo_lib/tests/money_matters/1.in: -------------------------------------------------------------------------------- 1 | 5 3 2 | 100 3 | -75 4 | -25 5 | -42 6 | 42 7 | 0 1 8 | 1 2 9 | 3 4 10 | -------------------------------------------------------------------------------- /algo_lib/tests/single_source_shortest_path_negative_weights/1.ans: -------------------------------------------------------------------------------- 1 | -Infinity 2 | 2 3 | Impossible 4 | 5 | -100 6 | -------------------------------------------------------------------------------- /algo_lib/tests/single_source_shortest_path_non_negative_weights/1.ans: -------------------------------------------------------------------------------- 1 | 0 2 | 2 3 | 4 4 | Impossible 5 | 6 | 100 7 | -------------------------------------------------------------------------------- /algo_lib/src/misc/extensions/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod do_with; 2 | pub mod option; 3 | pub mod replace_with; 4 | pub mod with; 5 | -------------------------------------------------------------------------------- /algo_lib/tests/b_segment_tree_for_the_minimum/1.in: -------------------------------------------------------------------------------- 1 | 5 5 2 | 5 4 2 3 5 3 | 2 0 3 4 | 1 2 6 5 | 2 0 3 6 | 1 3 1 7 | 2 0 5 8 | -------------------------------------------------------------------------------- /algo_lib/tests/m_do_not_turn_back/1.in: -------------------------------------------------------------------------------- 1 | 6 8 5 2 | 1 2 3 | 1 3 4 | 2 3 5 | 2 4 6 | 3 5 7 | 4 5 8 | 4 6 9 | 5 6 10 | -------------------------------------------------------------------------------- /algo_lib/tests/p5_coffee_jelly/2.in: -------------------------------------------------------------------------------- 1 | 7 6 2 | XXX..X 3 | ..XXX* 4 | XXXXXX 5 | ..*... 6 | XXXXXX 7 | XXXXX. 8 | ...... 9 | -------------------------------------------------------------------------------- /algo_lib/tests/ucup_10_g/0.in: -------------------------------------------------------------------------------- 1 | 1 2 | 4 4 1 3 | 5 5 4 | 2 5 5 | 5 3 6 | 5 1 7 | 2 4 8 | 5 2 9 | 3 5 10 | 5 4 11 | -------------------------------------------------------------------------------- /algo_lib/tests/anagram_counting/1.ans: -------------------------------------------------------------------------------- 1 | 2 2 | 5040 3 | 403291461126605635584000000 4 | 49229914688306352000000 5 | 29937600 6 | -------------------------------------------------------------------------------- /algo_lib/tests/b_cryptography/1.ans: -------------------------------------------------------------------------------- 1 | 0 2 2 | 0 0 3 | 4 | 0 2 5 | 0 1 6 | 7 | 0 1 8 | 0 0 9 | 10 | 2 1 11 | 1 2 12 | -------------------------------------------------------------------------------- /algo_lib/tests/c_number_of_minimums_on_a_segment/1.in: -------------------------------------------------------------------------------- 1 | 5 5 2 | 3 4 3 5 2 3 | 2 0 3 4 | 1 1 2 5 | 2 0 3 6 | 1 0 2 7 | 2 0 5 8 | -------------------------------------------------------------------------------- /algo_lib/tests/direct_connections/1.in: -------------------------------------------------------------------------------- 1 | 2 2 | 3 3 | 1 3 6 4 | 10 20 30 5 | 5 6 | 5 55 555 55555 555555 7 | 3333 333 333 33 35 8 | -------------------------------------------------------------------------------- /algo_lib/tests/the_goal/1.in: -------------------------------------------------------------------------------- 1 | -6 7 2 | 5 4 3 | 5 4 4 | 8 7 5 | 8 -7 6 | 5 4 7 | 8 -1 8 | -4 3 9 | -6 -7 10 | 1 -9 11 | -------------------------------------------------------------------------------- /algo_lib/tests/convex_hull/1.ans: -------------------------------------------------------------------------------- 1 | 3 2 | 10 0 3 | 0 10 4 | 0 0 5 | 3 6 | -24 -74 7 | 73 17 8 | -51 -6 9 | 1 10 | 50 50 11 | -------------------------------------------------------------------------------- /algo_lib/tests/f_mountain/mou2.ans: -------------------------------------------------------------------------------- 1 | 50 2 | 50 3 | 23 4 | 26 5 | 26 6 | 25 7 | 7 8 | 32 9 | 41 10 | 33 11 | 41 12 | 44 13 | -------------------------------------------------------------------------------- /algo_lib/tests/p6_candygrams/.failed_999.in: -------------------------------------------------------------------------------- 1 | 6 3 2 | 5 4 3 | 2 5 4 | 3 4 5 | 3 1 6 | 6 2 7 | U 6 10 8 | U 2 6 9 | Q 3 6 10 | -------------------------------------------------------------------------------- /main/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "main" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | regex = "1.11" 8 | -------------------------------------------------------------------------------- /algo_lib/src/graph/edges/bi_edge_trait.rs: -------------------------------------------------------------------------------- 1 | use crate::graph::edges::edge_trait::EdgeTrait; 2 | 3 | pub trait BiEdgeTrait: EdgeTrait {} 4 | -------------------------------------------------------------------------------- /algo_lib/tests/a_assignment_addition_and_sum/1.in: -------------------------------------------------------------------------------- 1 | 5 7 2 | 1 0 3 3 3 | 2 2 4 2 4 | 3 1 3 5 | 2 1 5 1 6 | 1 0 2 2 7 | 3 0 3 8 | 3 3 5 9 | -------------------------------------------------------------------------------- /algo_lib/tests/anagram_counting/1.in: -------------------------------------------------------------------------------- 1 | at 2 | ordeals 3 | abcdefghijklmnopqrstuvwxyz 4 | abcdefghijklmabcdefghijklm 5 | abcdABCDabcd 6 | -------------------------------------------------------------------------------- /algo_lib/tests/c_first_element_at_least_x/1.in: -------------------------------------------------------------------------------- 1 | 5 7 2 | 1 3 2 4 6 3 | 2 2 4 | 2 5 5 | 1 2 5 6 | 2 4 7 | 2 8 8 | 1 3 7 9 | 2 6 10 | -------------------------------------------------------------------------------- /algo_lib/tests/conga_line/1.ans: -------------------------------------------------------------------------------- 1 | bubba 2 | coco 3 | amelia 4 | 5 | amelia 6 | bubba 7 | kiryu 8 | coco 9 | ollie 10 | udin 11 | -------------------------------------------------------------------------------- /algo_lib/tests/conga_line/2.ans: -------------------------------------------------------------------------------- 1 | kiryu 2 | bubba 3 | coco 4 | 5 | kiryu 6 | ollie 7 | udin 8 | bubba 9 | coco 10 | amelia 11 | -------------------------------------------------------------------------------- /algo_lib/tests/e_euclids_tree/2.ans: -------------------------------------------------------------------------------- 1 | 3 2 | 2 3 | 3 4 | 3 5 | 2 6 | 5 7 | 4 8 | 3 9 | 3 10 | 3 11 | 3 12 | 5 13 | 5 14 | 4 15 | -------------------------------------------------------------------------------- /algo_lib/tests/linear_recurrences/2.in: -------------------------------------------------------------------------------- 1 | 2 2 | 5 7 9 3 | 36713 5637282 4 | 4 5 | 1 10000 6 | 1375 1 7 | 3781 23 8 | 34683447233 1571385 9 | -------------------------------------------------------------------------------- /algo_lib/tests/minimum_spanning_tree/1.in: -------------------------------------------------------------------------------- 1 | 4 4 2 | 0 1 1 3 | 1 2 2 4 | 1 3 3 5 | 2 3 0 6 | 2 1 7 | 0 1 100 8 | 3 0 9 | 0 0 10 | -------------------------------------------------------------------------------- /algo_lib/tests/p5_coffee_jelly/1.in: -------------------------------------------------------------------------------- 1 | 6 10 2 | XXXXXXXXXX 3 | X.*.X..X.X 4 | XX.XXXXXXX 5 | XXXX..XXXX 6 | *.......XX 7 | XXXXXXXXXX 8 | -------------------------------------------------------------------------------- /algo_lib/tests/polynomial_multiplication_1/1.in: -------------------------------------------------------------------------------- 1 | 2 2 | 2 3 | 1 0 5 4 | 1 5 | 0 -2 6 | 4 7 | 1 1 -1 1 1 8 | 4 9 | 9 -8 7 6 5 10 | -------------------------------------------------------------------------------- /algo_lib/src/io/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod eol; 2 | pub mod input; 3 | pub mod input_iter; 4 | pub mod output; 5 | mod output_macro; 6 | pub mod scan; 7 | -------------------------------------------------------------------------------- /algo_lib/tests/c_addition_and_first_element_at_least_x/1.in: -------------------------------------------------------------------------------- 1 | 5 7 2 | 1 2 5 3 3 | 1 1 3 4 4 | 2 3 0 5 | 2 5 0 6 | 1 4 5 5 7 | 2 5 3 8 | 2 8 1 9 | -------------------------------------------------------------------------------- /algo_lib/tests/c_number_of_inversions_on_segment/1.in: -------------------------------------------------------------------------------- 1 | 7 6 2 | 1 2 3 6 5 4 19 3 | 1 1 3 4 | 1 2 5 5 | 1 2 4 6 | 2 2 8 7 | 1 1 6 8 | 1 1 3 9 | -------------------------------------------------------------------------------- /algo_lib/tests/d_number_of_different_on_segment/1.in: -------------------------------------------------------------------------------- 1 | 7 6 2 | 1 2 3 6 5 4 19 3 | 1 1 3 4 | 1 2 5 5 | 1 2 4 6 | 2 2 8 7 | 1 1 6 8 | 1 1 3 9 | -------------------------------------------------------------------------------- /algo_lib/tests/engineering_english/1.ans: -------------------------------------------------------------------------------- 1 | Engineering will save the world from inefficiency 2 | . is a blight on . . and its 3 | humanity 4 | -------------------------------------------------------------------------------- /algo_lib/tests/f_flip/1.in: -------------------------------------------------------------------------------- 1 | 10 7 2 | 5 3 2 3 12 6 7 5 10 12 3 | 2 4 9 4 | 1 4 6 5 | 2 1 8 6 | 1 1 8 7 | 1 8 9 8 | 2 1 7 9 | 2 3 6 10 | -------------------------------------------------------------------------------- /algo_lib/tests/i_bingo/1.in: -------------------------------------------------------------------------------- 1 | 4 2 | 2 2 3 | 1 3 2 4 4 | 3 1 5 | 10 10 10 6 | 1 3 7 | 20 10 30 8 | 3 4 9 | 1 1 4 5 1 4 1 9 1 9 8 10 10 | -------------------------------------------------------------------------------- /algo_lib/tests/min_max_paths/1.in: -------------------------------------------------------------------------------- 1 | 3 2 | 5 3 3 | 1 2 4 | 2 3 5 | 3 4 6 | 4 5 7 | 2 2 8 | 1 2 9 | 4 1 10 | 1 2 11 | 1 3 12 | 2 4 13 | -------------------------------------------------------------------------------- /algo_lib/tests/polygon_area/1.in: -------------------------------------------------------------------------------- 1 | 3 2 | 0 0 3 | 10 0 4 | 0 10 5 | 5 6 | 41 -6 7 | -24 -74 8 | -51 -6 9 | 73 17 10 | -30 -34 11 | 0 12 | -------------------------------------------------------------------------------- /algo_lib/tests/big_sorting/2.ans: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 100 4 | 111 5 | 200 6 | 3084193741082937 7 | 3084193741082938 8 | 12303479849857341718340192371 9 | -------------------------------------------------------------------------------- /algo_lib/tests/conga_line/3.ans: -------------------------------------------------------------------------------- 1 | kiryu 2 | bubba 3 | coco 4 | ollie 5 | 6 | ollie 7 | udin 8 | coco 9 | kiryu 10 | amelia 11 | bubba 12 | -------------------------------------------------------------------------------- /algo_lib/tests/d_kii_maksimum/1.in: -------------------------------------------------------------------------------- 1 | 11 2 | 1 5 3 | 1 3 4 | 1 7 5 | 0 1 6 | 0 2 7 | 0 3 8 | -1 5 9 | 1 10 10 | 0 1 11 | 0 2 12 | 0 3 13 | -------------------------------------------------------------------------------- /algo_lib/tests/f_mountain/0.ans: -------------------------------------------------------------------------------- 1 | 5 2 | 4 3 | 1 4 | 4 5 | 7 6 | 5 7 | 4 8 | 5 9 | 7 10 | 4 11 | 8 12 | 8 13 | 8 14 | 9 15 | 9 16 | 9 17 | -------------------------------------------------------------------------------- /algo_lib/tests/f_mountain/mou1.ans: -------------------------------------------------------------------------------- 1 | 5 2 | 4 3 | 1 4 | 4 5 | 7 6 | 5 7 | 4 8 | 5 9 | 7 10 | 4 11 | 8 12 | 8 13 | 8 14 | 9 15 | 9 16 | 9 17 | -------------------------------------------------------------------------------- /algo_lib/tests/replace_with_first_literally/1.in: -------------------------------------------------------------------------------- 1 | 3 2 | 4 3 3 | aabc 4 | aab 5 | 8 8 6 | accepted 7 | accapted 8 | 1 1 9 | z 10 | z 11 | -------------------------------------------------------------------------------- /run/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "run" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | [dependencies] 7 | algo_lib = { path = "../algo_lib" } -------------------------------------------------------------------------------- /templates/main/file_in.rs: -------------------------------------------------------------------------------- 1 | let in_file = std::fs::File::open("$IN_FILE").unwrap(); 2 | let input = algo_lib::io::input::Input::file(in_file); -------------------------------------------------------------------------------- /algo_lib/src/collections/iter_ext/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod cur_next; 2 | pub mod interleave; 3 | pub mod iter_copied; 4 | pub mod iters; 5 | pub mod min_max; 6 | -------------------------------------------------------------------------------- /algo_lib/src/numbers/num_traits/invertible.rs: -------------------------------------------------------------------------------- 1 | pub trait Invertible { 2 | type Output; 3 | 4 | fn inv(&self) -> Option; 5 | } 6 | -------------------------------------------------------------------------------- /algo_lib/src/string/string_algorithms/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod palindromes; 2 | pub mod prefix_function; 3 | pub mod string_search; 4 | pub mod z_algorithm; 5 | -------------------------------------------------------------------------------- /algo_lib/tests/break_and_fix_the_tree/1.in: -------------------------------------------------------------------------------- 1 | 5 2 | 1 1 2 2 3 | 1 2 3 4 5 4 | 6 5 | 3 4 5 6 | 1 4 3 7 | 1 5 3 8 | 1 2 4 9 | 2 4 10 10 | 3 2 5 11 | -------------------------------------------------------------------------------- /algo_lib/tests/c2_koordinatsiya_prezentatsii_slozhnaya_versiya/1.ans: -------------------------------------------------------------------------------- 1 | YA 2 | TIDAK 3 | YA 4 | YA 5 | TIDAK 6 | YA 7 | TIDAK 8 | YA 9 | YA 10 | -------------------------------------------------------------------------------- /algo_lib/tests/d_first_element_at_least_x_2/1.in: -------------------------------------------------------------------------------- 1 | 5 7 2 | 1 3 2 4 3 3 | 2 3 0 4 | 2 3 2 5 | 1 2 5 6 | 2 4 1 7 | 2 5 4 8 | 1 3 7 9 | 2 6 1 10 | -------------------------------------------------------------------------------- /algo_lib/tests/d_greenpath/1.ans: -------------------------------------------------------------------------------- 1 | 1 2 | 199648871 3 | 399297742 4 | 199648871 5 | 199648871 6 | 598946614 7 | 199648873 8 | 2 9 | 2 10 | 2 11 | -------------------------------------------------------------------------------- /algo_lib/tests/e_earthquakes/1.in: -------------------------------------------------------------------------------- 1 | 5 9 2 | 1 0 3 3 | 1 2 5 4 | 2 0 4 3 5 | 1 1 4 6 | 1 2 7 7 | 2 1 3 6 8 | 1 3 8 9 | 1 4 4 10 | 2 0 5 10 11 | -------------------------------------------------------------------------------- /algo_lib/tests/p6_candygrams/1.in: -------------------------------------------------------------------------------- 1 | 7 5 2 | 1 2 3 | 3 1 4 | 2 4 5 | 4 6 6 | 5 4 7 | 6 7 8 | U 5 2 9 | Q 1 4 10 | U 7 3 11 | U 5 -1 12 | Q 6 3 13 | -------------------------------------------------------------------------------- /algo_lib/tests/engineering_english/1.in: -------------------------------------------------------------------------------- 1 | Engineering will save the world from inefficiency 2 | Inefficiency is a blight on the world and its 3 | humanity 4 | -------------------------------------------------------------------------------- /algo_lib/tests/f_fast_tree_queries/1.in: -------------------------------------------------------------------------------- 1 | 5 6 2 | 1 2 3 | 1 3 4 | 3 4 5 | 3 5 6 | ? 2 5 7 | + 1 4 1 8 | ? 2 5 9 | + 4 5 2 10 | ? 4 5 11 | ? 1 1 12 | -------------------------------------------------------------------------------- /algo_lib/tests/kannas_friendship/1.in: -------------------------------------------------------------------------------- 1 | 10 12 2 | 1 5 5 3 | 2 4 | 1 6 6 5 | 2 6 | 1 5 6 7 | 2 8 | 1 2 4 9 | 2 10 | 1 3 8 11 | 2 12 | 1 1 10 13 | 2 14 | -------------------------------------------------------------------------------- /algo_lib/tests/linear_recurrences/1.in: -------------------------------------------------------------------------------- 1 | 2 2 | 0 1 1 3 | 0 1 4 | 6 5 | 1 100000 6 | 2 100000 7 | 3 100000 8 | 4 100000 9 | 5 100000 10 | 6 100000 11 | -------------------------------------------------------------------------------- /algo_lib/tests/m_do_not_turn_back/2.in: -------------------------------------------------------------------------------- 1 | 11 11 2023 2 | 1 2 3 | 2 3 4 | 3 4 5 | 4 5 6 | 5 6 7 | 6 7 8 | 7 8 9 | 8 9 10 | 9 10 11 | 10 11 12 | 1 11 13 | -------------------------------------------------------------------------------- /algo_lib/tests/modular_arithmetic/1.in: -------------------------------------------------------------------------------- 1 | 1000 3 2 | 1 / 999 3 | 1 / 998 4 | 578 * 178 5 | 13 4 6 | 7 / 9 7 | 9 * 3 8 | 0 - 9 9 | 10 + 10 10 | 0 0 11 | -------------------------------------------------------------------------------- /algo_lib/tests/string_matching/1.in: -------------------------------------------------------------------------------- 1 | p 2 | Popup 3 | helo 4 | Hello there! 5 | peek a boo 6 | you speek a bootiful language 7 | anas 8 | bananananaspaj 9 | -------------------------------------------------------------------------------- /algo_lib/tests/task_1553_caves_and_tunnels/1.in: -------------------------------------------------------------------------------- 1 | 4 2 | 1 2 3 | 2 3 4 | 2 4 5 | 6 6 | I 1 1 7 | G 1 1 8 | G 3 4 9 | I 2 3 10 | G 1 1 11 | G 3 4 12 | -------------------------------------------------------------------------------- /templates/main/file_out.rs: -------------------------------------------------------------------------------- 1 | let out_file = std::fs::File::create("$OUT_FILE").unwrap(); 2 | let output = algo_lib::io::output::Output::file(out_file); -------------------------------------------------------------------------------- /algo_lib/tests/big_sorting/2.in: -------------------------------------------------------------------------------- 1 | 8 2 | 1 3 | 2 4 | 100 5 | 12303479849857341718340192371 6 | 3084193741082937 7 | 3084193741082938 8 | 111 9 | 200 10 | -------------------------------------------------------------------------------- /algo_lib/tests/birthday_party/1.in: -------------------------------------------------------------------------------- 1 | 2 1 2 | 0 1 3 | 4 4 4 | 0 1 5 | 1 2 6 | 2 3 7 | 3 0 8 | 5 5 9 | 0 1 10 | 1 2 11 | 0 3 12 | 3 4 13 | 3 1 14 | 0 0 15 | -------------------------------------------------------------------------------- /algo_lib/tests/kattiss_quest/1.in: -------------------------------------------------------------------------------- 1 | 9 2 | add 8 10 3 | add 3 25 4 | add 5 6 5 | query 7 6 | query 7 7 | add 1 9 8 | add 2 13 9 | query 20 10 | query 1 11 | -------------------------------------------------------------------------------- /algo_lib/tests/reverse_rot/1.ans: -------------------------------------------------------------------------------- 1 | EDCB 2 | CHUHKWBR. 3 | UPEA 4 | ROAD 5 | PWRAYF_LWNHAXWH.RHPWRAJAX_HMWJHPWRAORQ. 6 | FGVTGXPQEAGDAQVAIPKTVU 7 | REVERSE_ROT 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is work in progress 2 | 3 | See [https://github.com/rust-competitive-helper/example-contests-workspace] on how to use 4 | rust-competitive-helper 5 | -------------------------------------------------------------------------------- /algo_lib/src/collections/vec_ext/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod default; 2 | pub mod detuple; 3 | pub mod gen_vec; 4 | pub mod inc_dec; 5 | pub mod sorted; 6 | pub mod transpose; 7 | -------------------------------------------------------------------------------- /algo_lib/tests/a_feast_for_cats/1.in: -------------------------------------------------------------------------------- 1 | 1 2 | 20 5 3 | 0 1 4 4 | 0 2 3 5 | 0 3 10 6 | 0 4 15 7 | 1 2 7 8 | 1 3 3 9 | 1 4 5 10 | 2 3 4 11 | 2 4 3 12 | 3 4 8 13 | -------------------------------------------------------------------------------- /algo_lib/tests/roy_and_tree_permutation/1.in: -------------------------------------------------------------------------------- 1 | 1 2 | 8 3 | 1 5 2 1 1 3 5 6 4 | 1 2 5 | 1 3 6 | 2 7 7 | 2 8 8 | 3 4 9 | 4 5 10 | 4 6 11 | 5 12 | 4 3 2 5 1 13 | -------------------------------------------------------------------------------- /algo_lib/src/misc/between.rs: -------------------------------------------------------------------------------- 1 | use std::ops::RangeInclusive; 2 | 3 | pub fn between(x: T, y: T) -> RangeInclusive { 4 | x.min(y)..=x.max(y) 5 | } 6 | -------------------------------------------------------------------------------- /algo_lib/tests/b_binary_search_tree/1.in: -------------------------------------------------------------------------------- 1 | insert 2 2 | insert 5 3 | insert 3 4 | exists 2 5 | exists 4 6 | next 4 7 | prev 4 8 | delete 5 9 | next 4 10 | prev 4 11 | -------------------------------------------------------------------------------- /algo_lib/tests/convex_hull/1.in: -------------------------------------------------------------------------------- 1 | 3 2 | 0 0 3 | 10 0 4 | 0 10 5 | 5 6 | 41 -6 7 | -24 -74 8 | -51 -6 9 | 73 17 10 | -30 -34 11 | 2 12 | 50 50 13 | 50 50 14 | 0 15 | -------------------------------------------------------------------------------- /algo_lib/tests/d_maksimum_minimum_kolichestvo/1.in: -------------------------------------------------------------------------------- 1 | 4 2 | 3 3 | 5 4 5 4 | 3 5 | 4 5 4 6 | 10 7 | 3 3 3 3 4 1 2 3 5 4 8 | 10 9 | 17 89 92 42 29 41 92 14 70 45 10 | -------------------------------------------------------------------------------- /algo_lib/tests/f_decoding_the_maya_code/1.in: -------------------------------------------------------------------------------- 1 | 5 4 2 | A 3 | B 4 | C 5 | D 6 | E 7 | 1 2 8 | 1 3 9 | 1 4 10 | 2 5 11 | 1 AABCDE 12 | 1 A 13 | 2 BEE 14 | 3 CCCA 15 | -------------------------------------------------------------------------------- /algo_lib/tests/k_range_affine_range_sum/1.in: -------------------------------------------------------------------------------- 1 | 5 7 2 | 1 2 3 4 5 3 | 1 0 5 4 | 0 2 4 100 101 5 | 1 0 3 6 | 0 1 3 102 103 7 | 1 2 5 8 | 0 2 5 104 105 9 | 1 0 5 10 | -------------------------------------------------------------------------------- /algo_lib/tests/all_pairs_shortest_path/1.in: -------------------------------------------------------------------------------- 1 | 4 3 4 2 | 0 1 2 3 | 1 2 2 4 | 3 3 1 5 | 0 2 6 | 1 2 7 | 3 0 8 | 3 3 9 | 2 1 2 10 | 0 1 100 11 | 0 1 12 | 1 0 13 | 0 0 0 14 | -------------------------------------------------------------------------------- /algo_lib/tests/b_add_arithmetic_progression_on_segment/1.in: -------------------------------------------------------------------------------- 1 | 9 10 2 | 1 4 8 1 2 3 | 2 6 4 | 2 8 5 | 1 1 9 3 1 6 | 2 6 7 | 2 8 8 | 1 2 5 2 3 9 | 2 1 10 | 2 2 11 | 2 3 12 | -------------------------------------------------------------------------------- /algo_lib/tests/b_cryptography/1.in: -------------------------------------------------------------------------------- 1 | 3 4 4 2 | 0 1 3 | 0 0 4 | 5 | 2 1 6 | 1 2 7 | 8 | 0 0 9 | 0 2 10 | 11 | 1 0 12 | 0 2 13 | 14 | 1 4 15 | 2 3 16 | 1 3 17 | 2 2 18 | -------------------------------------------------------------------------------- /algo_lib/tests/dynamic_tree_vertex_add_subtree_sum/.failed_999.in: -------------------------------------------------------------------------------- 1 | 5 4 2 | 0 1 7 9 0 3 | 4 2 4 | 2 1 5 | 0 3 6 | 1 0 7 | 1 4 8 8 | 1 1 4 9 | 0 0 3 2 3 10 | 2 1 2 11 | -------------------------------------------------------------------------------- /algo_lib/tests/f_mountain/mou3.ans: -------------------------------------------------------------------------------- 1 | 162 2 | 225 3 | 231 4 | 222 5 | 224 6 | 160 7 | 159 8 | 161 9 | 226 10 | 158 11 | 68 12 | 257 13 | 208 14 | 241 15 | 241 16 | 232 17 | -------------------------------------------------------------------------------- /algo_lib/tests/line_segment_distance/1.in: -------------------------------------------------------------------------------- 1 | 5 2 | -10 0 10 0 0 -10 0 10 3 | -10 0 10 0 -5 0 5 0 4 | 1 1 1 1 1 1 2 1 5 | 1 1 1 1 2 1 2 1 6 | 1871 5789 216 -517 189 -1518 3851 1895 7 | -------------------------------------------------------------------------------- /algo_lib/tests/reverse_rot/1.in: -------------------------------------------------------------------------------- 1 | 1 ABCD 2 | 3 YO_THERE. 3 | 1 .DOT 4 | 14 ROAD 5 | 9 SHIFTING_AND_ROTATING_IS_NOT_ENCRYPTING 6 | 2 STRING_TO_BE_CONVERTED 7 | 1 SNQZDRQDUDQ 8 | 0 9 | -------------------------------------------------------------------------------- /algo_lib/src/io/output_macro.rs: -------------------------------------------------------------------------------- 1 | #[macro_export] 2 | macro_rules! output { 3 | ($output: expr, $($arg:tt)*) => { 4 | $output.print_line(format!($($arg)*)); 5 | }; 6 | } 7 | -------------------------------------------------------------------------------- /algo_lib/tests/d_greenpath/1.in: -------------------------------------------------------------------------------- 1 | 5 12 2 | 1 2 3 | 1 3 4 | 2 4 5 | 2 5 6 | 1 1 1 7 | 2 1 8 | 2 2 9 | 2 3 10 | 2 4 11 | 2 5 12 | 1 2 2 13 | 2 1 14 | 2 2 15 | 2 3 16 | 2 4 17 | 2 5 18 | -------------------------------------------------------------------------------- /algo_lib/tests/single_source_shortest_path_negative_weights/1.in: -------------------------------------------------------------------------------- 1 | 5 4 3 0 2 | 0 1 999 3 | 1 2 -2 4 | 2 1 1 5 | 0 3 2 6 | 1 7 | 3 8 | 4 9 | 2 1 1 0 10 | 0 1 -100 11 | 1 12 | 0 0 0 0 13 | -------------------------------------------------------------------------------- /algo_lib/tests/single_source_shortest_path_non_negative_weights/1.in: -------------------------------------------------------------------------------- 1 | 4 3 4 0 2 | 0 1 2 3 | 1 2 2 4 | 3 0 2 5 | 0 6 | 1 7 | 2 8 | 3 9 | 2 1 1 0 10 | 0 1 100 11 | 1 12 | 0 0 0 0 13 | -------------------------------------------------------------------------------- /algo_lib/tests/the_amazing_human_cannonball/1.ans: -------------------------------------------------------------------------------- 1 | Not Safe 2 | Safe 3 | Not Safe 4 | Not Safe 5 | Not Safe 6 | Not Safe 7 | Not Safe 8 | Not Safe 9 | Not Safe 10 | Safe 11 | Safe 12 | -------------------------------------------------------------------------------- /algo_lib/tests/f_decoding_the_maya_code/.failed_998.in: -------------------------------------------------------------------------------- 1 | 7 1 2 | BAABA 3 | BBA 4 | A 5 | BBA 6 | BABA 7 | AABA 8 | ABA 9 | 1 2 10 | 2 3 11 | 2 4 12 | 4 5 13 | 1 6 14 | 3 7 15 | 1 BAAAAAA 16 | -------------------------------------------------------------------------------- /algo_lib/tests/f_decoding_the_maya_code/2.in: -------------------------------------------------------------------------------- 1 | 6 4 2 | AA 3 | AB 4 | BC 5 | CD 6 | AA 7 | AA 8 | 1 2 9 | 2 3 10 | 3 4 11 | 4 5 12 | 5 6 13 | 1 AAABCD 14 | 2 AABCD 15 | 3 BCD 16 | 1 DCBA 17 | -------------------------------------------------------------------------------- /algo_lib/tests/e_euclids_tree/2.in: -------------------------------------------------------------------------------- 1 | 2 2 | 5 3 | 6 4 6 2 4 4 | 5 3 5 | 1 5 6 | 5 2 7 | 2 4 8 | 9 9 | 4 6 6 7 7 3 4 4 2 10 | 2 7 11 | 1 6 12 | 3 4 13 | 4 9 14 | 6 4 15 | 3 2 16 | 5 2 17 | 6 8 18 | -------------------------------------------------------------------------------- /algo_lib/tests/string_multimatching/1.in: -------------------------------------------------------------------------------- 1 | 2 2 | p 3 | pup 4 | Popup 5 | 2 6 | You 7 | peek a boo 8 | you speek a bootiful language 9 | 4 10 | anas 11 | ana 12 | an 13 | a 14 | bananananaspaj 15 | -------------------------------------------------------------------------------- /algo_lib/tests/f_decoding_the_maya_code/.failed_997.in: -------------------------------------------------------------------------------- 1 | 8 1 2 | A 3 | BA 4 | A 5 | BA 6 | A 7 | BBB 8 | BBA 9 | BAB 10 | 1 2 11 | 2 3 12 | 3 4 13 | 1 5 14 | 5 6 15 | 6 7 16 | 5 8 17 | 5 AABBBA 18 | -------------------------------------------------------------------------------- /algo_lib/tests/subtree_swapping/1.in: -------------------------------------------------------------------------------- 1 | 10 5 2 | 1 1 1 1 1 1 1 1 1 1 3 | 1 2 4 | 1 3 5 | 1 8 6 | 3 4 7 | 8 9 8 | 8 10 9 | 4 5 10 | 4 6 11 | 4 7 12 | 2 8 1 13 | 1 3 14 | 3 4 8 15 | 1 3 16 | 3 1 2 17 | -------------------------------------------------------------------------------- /algo_lib/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "algo_lib" 3 | version = "0.1.0" 4 | edition = "2021" 5 | rust-version = "1.70.0" 6 | 7 | [dev-dependencies] 8 | tester = { path = "../tester", features = ["test"] } 9 | -------------------------------------------------------------------------------- /algo_lib/tests/dynamic_tree_subtree_add_subtree_sum/1.in: -------------------------------------------------------------------------------- 1 | 5 7 2 | 1 10 100 1000 10000 3 | 0 1 4 | 1 2 5 | 2 3 6 | 1 4 7 | 2 1 0 8 | 1 1 4 100000 9 | 2 2 3 10 | 0 1 2 2 0 11 | 2 0 2 12 | 0 2 3 3 1 13 | 2 1 4 -------------------------------------------------------------------------------- /algo_lib/tests/dynamic_tree_vertex_add_subtree_sum/1.in: -------------------------------------------------------------------------------- 1 | 5 7 2 | 1 10 100 1000 10000 3 | 0 1 4 | 1 2 5 | 2 3 6 | 1 4 7 | 2 1 2 8 | 1 1 100000 9 | 2 1 2 10 | 0 1 2 2 0 11 | 2 0 2 12 | 0 2 3 3 1 13 | 2 1 4 -------------------------------------------------------------------------------- /algo_lib/tests/running_mom/1.in: -------------------------------------------------------------------------------- 1 | 5 2 | Arlington San_Antonio 3 | San_Antonio Baltimore 4 | Baltimore New_York 5 | New_York Dallas 6 | Baltimore Arlington 7 | San_Antonio 8 | Baltimore 9 | New_York 10 | -------------------------------------------------------------------------------- /algo_lib/src/numbers/num_traits/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod algebra; 2 | pub mod assign_to_op; 3 | pub mod bit_ops; 4 | pub mod invertible; 5 | pub mod op_to_assign; 6 | pub mod ord; 7 | pub mod primitive; 8 | pub mod sign; 9 | -------------------------------------------------------------------------------- /algo_lib/tests/a_next/.failed_999.in: -------------------------------------------------------------------------------- 1 | 10 2 | ? 878945653 3 | ? 647658120 4 | + 232729850 5 | ? 114965479 6 | + 713838575 7 | + 874216573 8 | ? 178527978 9 | + 241509972 10 | ? 951847274 11 | + 883876569 12 | -------------------------------------------------------------------------------- /algo_lib/src/misc/memo/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod memoization; 2 | pub mod memoization_2d; 3 | pub mod memoization_3d; 4 | pub mod memoization_4d; 5 | pub mod memoization_5d; 6 | pub mod memoization_vec; 7 | #[cfg(test)] 8 | mod test; 9 | -------------------------------------------------------------------------------- /algo_lib/src/collections/vec_ext/default.rs: -------------------------------------------------------------------------------- 1 | pub fn default_vec(len: usize) -> Vec { 2 | let mut v = Vec::with_capacity(len); 3 | for _ in 0..len { 4 | v.push(T::default()); 5 | } 6 | v 7 | } 8 | -------------------------------------------------------------------------------- /algo_lib/tests/f_decoding_the_maya_code/.failed_999.in: -------------------------------------------------------------------------------- 1 | 5 1 2 | ABAAA 3 | AAABB 4 | BB 5 | B 6 | AAABA 7 | 1 2 8 | 2 3 9 | 2 4 10 | 3 5 11 | 1 BBAABBAABAAABAAABBABBBAAABBAABBAAAAAABABBAABBBBBAABBBBBBABBBBBABABBAAABBBBB 12 | -------------------------------------------------------------------------------- /algo_lib/src/graph/edges/weighted_edge_trait.rs: -------------------------------------------------------------------------------- 1 | use crate::graph::edges::edge_trait::EdgeTrait; 2 | 3 | pub trait WeightedEdgeTrait: EdgeTrait { 4 | fn weight(&self) -> W; 5 | fn weight_mut(&mut self) -> &mut W; 6 | } 7 | -------------------------------------------------------------------------------- /algo_lib/src/misc/extensions/with.rs: -------------------------------------------------------------------------------- 1 | pub trait With: Sized { 2 | fn with(self, f: F) -> R 3 | where 4 | F: FnOnce(Self) -> R, 5 | { 6 | f(self) 7 | } 8 | } 9 | 10 | impl With for T {} 11 | -------------------------------------------------------------------------------- /algo_lib/tests/c2_koordinatsiya_prezentatsii_slozhnaya_versiya/1.in: -------------------------------------------------------------------------------- 1 | 3 2 | 4 2 2 3 | 1 2 3 4 4 | 1 1 5 | 1 2 6 | 1 1 7 | 3 6 2 8 | 1 2 3 9 | 1 1 2 3 3 2 10 | 3 3 11 | 2 2 12 | 4 6 2 13 | 3 1 4 2 14 | 3 1 1 2 3 4 15 | 3 4 16 | 4 2 17 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "2" 3 | members = [ 4 | "algo_lib", 5 | "main", 6 | "tester", 7 | "run", 8 | ] 9 | 10 | [profile.release] 11 | overflow-checks = true 12 | 13 | [profile.dev] 14 | lto = "off" 15 | -------------------------------------------------------------------------------- /algo_lib/tests/island_hopping/1.in: -------------------------------------------------------------------------------- 1 | 2 2 | 3 3 | 0.0 0.0 4 | 0.0 1.0 5 | 1.0 0.0 6 | 10 7 | 30.0 38.0 8 | 43.0 72.0 9 | 47.0 46.0 10 | 49.0 69.0 11 | 52.0 42.0 12 | 58.0 17.0 13 | 73.0 7.0 14 | 84.0 81.0 15 | 86.0 75.0 16 | 93.0 50.0 17 | -------------------------------------------------------------------------------- /algo_lib/src/string/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod aho_corasick; 2 | pub mod concat; 3 | pub mod hash; 4 | pub mod qty; 5 | pub mod slicelike; 6 | pub mod split; 7 | pub mod str; 8 | pub mod string_algorithms; 9 | pub mod suffix_array; 10 | pub mod trim; 11 | -------------------------------------------------------------------------------- /algo_lib/tests/m_do_not_turn_back/3.in: -------------------------------------------------------------------------------- 1 | 7 21 1000000000 2 | 1 2 3 | 1 3 4 | 1 4 5 | 1 5 6 | 1 6 7 | 1 7 8 | 2 3 9 | 2 4 10 | 2 5 11 | 2 6 12 | 2 7 13 | 3 4 14 | 3 5 15 | 3 6 16 | 3 7 17 | 4 5 18 | 4 6 19 | 4 7 20 | 5 6 21 | 5 7 22 | 6 7 23 | -------------------------------------------------------------------------------- /algo_lib/src/collections/slice_ext/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod backward; 2 | pub mod bounds; 3 | pub mod compress; 4 | pub mod consecutive_iter; 5 | pub mod indices; 6 | pub mod next_permutation; 7 | pub mod permutation; 8 | pub mod qty; 9 | pub mod splits; 10 | -------------------------------------------------------------------------------- /algo_lib/tests/e_innocent_students/1.in: -------------------------------------------------------------------------------- 1 | 2 2 | 3 5 3 | 1 -2 3 4 | 1 1 3 0 5 | 2 3 -2 6 | 1 2 3 1 7 | 2 1 -4 8 | 1 1 1 -10 9 | 7 8 10 | 1 2 4 2 4 6 7 11 | 1 3 5 5 12 | 1 1 7 5 13 | 2 1 6 14 | 2 4 4 15 | 1 1 7 5 16 | 1 1 3 2 17 | 2 7 1 18 | 1 1 7 -1 19 | -------------------------------------------------------------------------------- /algo_lib/tests/goldbachs_conjecture/1.ans: -------------------------------------------------------------------------------- 1 | 4 has 1 representation(s) 2 | 2+2 3 | 4 | 26 has 3 representation(s) 5 | 3+23 6 | 7+19 7 | 13+13 8 | 9 | 100 has 6 representation(s) 10 | 3+97 11 | 11+89 12 | 17+83 13 | 29+71 14 | 41+59 15 | 47+53 16 | 17 | -------------------------------------------------------------------------------- /algo_lib/tests/kannas_friendship/2.in: -------------------------------------------------------------------------------- 1 | 26 19 2 | 1 8 8 3 | 1 15 15 4 | 1 20 20 5 | 1 19 19 6 | 1 16 16 7 | 1 21 21 8 | 1 18 18 9 | 2 10 | 1 1 1 11 | 1 9 9 12 | 1 9 9 13 | 1 7 7 14 | 2 15 | 1 1 1 16 | 1 20 20 17 | 1 8 8 18 | 1 9 9 19 | 1 14 14 20 | 2 21 | -------------------------------------------------------------------------------- /algo_lib/tests/f1_sverkhskorostnoi_podschyot_prostaya_versiya/1.in: -------------------------------------------------------------------------------- 1 | 11 2 | 1 998244353 3 | 2 998244353 4 | 3 998244353 5 | 4 998244353 6 | 5 998244353 7 | 6 998244353 8 | 7 998244353 9 | 8 998244353 10 | 9 998244353 11 | 10 102275857 12 | 10 999662017 13 | -------------------------------------------------------------------------------- /algo_lib/src/misc/extensions/do_with.rs: -------------------------------------------------------------------------------- 1 | pub trait DoWith: Sized { 2 | fn do_with(mut self, f: F) -> Self 3 | where 4 | F: FnOnce(&mut Self), 5 | { 6 | f(&mut self); 7 | self 8 | } 9 | } 10 | 11 | impl DoWith for T {} 12 | -------------------------------------------------------------------------------- /algo_lib/tests/the_amazing_human_cannonball/1.in: -------------------------------------------------------------------------------- 1 | 11 2 | 19 45 20 9 12 3 | 20 45 20 9 12 4 | 25 45 20 9 12 5 | 20 43 20 9 12 6 | 20 47.5 20 9 12 7 | 20 45 17 9 12 8 | 20 45 24 9 12 9 | 20 45 20 10 12 10 | 20 45 20 9 11 11 | 20 45 20 9.0 11.5 12 | 20 45 18.1 9 12 13 | -------------------------------------------------------------------------------- /algo_lib/tests/ucup_10_g/1.in: -------------------------------------------------------------------------------- 1 | 3 2 | 8 6 4 3 | 1 3 4 | 2 1 5 | 2 6 6 | 4 1 7 | 4 7 8 | 6 1 9 | 6 3 10 | 6 6 11 | 2 3 12 | 3 1 13 | 4 3 14 | 4 6 15 | 5 2 16 | 6 4 17 | 3 2 1 18 | 10 12 19 | 10 10 20 | 10 11 21 | 1 4 22 | 1 5 23 | 1 3 2 24 | 1 1 25 | 2 1 26 | 2 2 27 | 2 3 -------------------------------------------------------------------------------- /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | # 64 bit MSVC 2 | [target.x86_64-pc-windows-msvc] 3 | rustflags = [ 4 | "-C", "link-arg=/STACK:1000000000" 5 | ] 6 | 7 | # 64 bit Mingw 8 | [target.x86_64-pc-windows-gnu] 9 | rustflags = [ 10 | "-C", "link-arg=-Wl,--stack,1000000000" 11 | ] 12 | -------------------------------------------------------------------------------- /algo_lib/src/collections/slice_ext/indices.rs: -------------------------------------------------------------------------------- 1 | use std::ops::Range; 2 | 3 | pub trait Indices { 4 | fn indices(&self) -> Range; 5 | } 6 | 7 | impl Indices for [T] { 8 | fn indices(&self) -> Range { 9 | 0..self.len() 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /main/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | # 64 bit MSVC 2 | [target.x86_64-pc-windows-msvc] 3 | rustflags = [ 4 | "-C", "link-arg=/STACK:1000000000" 5 | ] 6 | 7 | # 64 bit Mingw 8 | [target.x86_64-pc-windows-gnu] 9 | rustflags = [ 10 | "-C", "link-arg=-Wl,--stack,1000000000" 11 | ] 12 | -------------------------------------------------------------------------------- /algo_lib/src/graph/edges/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod bi_edge; 2 | pub mod bi_edge_trait; 3 | pub mod bi_weighted_edge; 4 | pub mod edge; 5 | pub mod edge_id; 6 | pub mod edge_trait; 7 | pub mod flow_edge; 8 | pub mod flow_edge_trait; 9 | pub mod weighted_edge; 10 | pub mod weighted_edge_trait; 11 | pub mod weighted_flow_edge; 12 | -------------------------------------------------------------------------------- /algo_lib/src/collections/order.rs: -------------------------------------------------------------------------------- 1 | pub trait Order { 2 | fn order(&self) -> Vec; 3 | } 4 | 5 | impl Order for [T] { 6 | fn order(&self) -> Vec { 7 | let mut order = (0..self.len()).collect::>(); 8 | order.sort_by_key(|&i| &self[i]); 9 | order 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /algo_lib/src/collections/vec_ext/transpose.rs: -------------------------------------------------------------------------------- 1 | pub trait TransposePairVec { 2 | fn transpose_pair_vec(self) -> Vec<(V, U)>; 3 | } 4 | 5 | impl TransposePairVec for Vec<(U, V)> { 6 | fn transpose_pair_vec(self) -> Vec<(V, U)> { 7 | self.into_iter().map(|(u, v)| (v, u)).collect() 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tester/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tester" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | algo_lib = { path = "../algo_lib" } 10 | pretty_assertions = "1.4" 11 | 12 | [features] 13 | test = [] 14 | -------------------------------------------------------------------------------- /algo_lib/src/geometry/mod.rs: -------------------------------------------------------------------------------- 1 | use crate::numbers::num_traits::algebra::Ring; 2 | 3 | pub mod angle; 4 | pub mod circle; 5 | pub mod geometry_utils; 6 | pub mod line; 7 | pub mod point; 8 | pub mod polygon; 9 | pub mod ray; 10 | pub mod segment; 11 | 12 | pub trait Base: Copy + Ring {} 13 | 14 | impl Base for T {} 15 | -------------------------------------------------------------------------------- /algo_lib/tests/f_mountain/mou4.ans: -------------------------------------------------------------------------------- 1 | 1632 2 | 1882 3 | 1374 4 | 1645 5 | 1320 6 | 1313 7 | 1093 8 | 618 9 | 1471 10 | 1635 11 | 1908 12 | 1004 13 | 1893 14 | 1324 15 | 1897 16 | 1676 17 | 1717 18 | 1758 19 | 1687 20 | 2047 21 | 1700 22 | 1744 23 | 1559 24 | 1506 25 | 1535 26 | 1646 27 | 1794 28 | 655 29 | 828 30 | 1402 31 | 1240 32 | 419 33 | -------------------------------------------------------------------------------- /algo_lib/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![allow(clippy::too_many_arguments)] 2 | #![allow(clippy::type_complexity)] 3 | #![allow(clippy::missing_safety_doc)] 4 | #![allow(clippy::missing_const_for_thread_local)] 5 | 6 | pub mod collections; 7 | pub mod geometry; 8 | pub mod graph; 9 | pub mod io; 10 | pub mod misc; 11 | pub mod numbers; 12 | pub mod string; 13 | -------------------------------------------------------------------------------- /algo_lib/src/misc/test_type.rs: -------------------------------------------------------------------------------- 1 | pub enum LegacyTestType { 2 | Single, 3 | MultiNumber, 4 | MultiEof, 5 | } 6 | 7 | pub enum TestType { 8 | Single, 9 | MultiNumber, 10 | MultiEof, 11 | RunTwiceSingle, 12 | RunTwiceMultiNumber, 13 | } 14 | 15 | pub enum TaskType { 16 | Classic, 17 | Interactive, 18 | } 19 | -------------------------------------------------------------------------------- /algo_lib/tests/kinds_of_people/2.in: -------------------------------------------------------------------------------- 1 | 10 20 2 | 11111111111111111111 3 | 11000000000000000101 4 | 11111111111111110000 5 | 11111111111111110000 6 | 11000000000000000111 7 | 00011111111111111111 8 | 00111111111111111111 9 | 10000000000000001111 10 | 11111111111111111111 11 | 11111111111111111111 12 | 3 13 | 2 3 8 16 14 | 8 1 7 3 15 | 1 1 10 20 16 | -------------------------------------------------------------------------------- /templates/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "$TASK" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | algo_lib = { path = "../../algo_lib" } 8 | tester = { path = "../../tester" } 9 | 10 | [build-dependencies] 11 | rust_competitive_helper_util = { path = "../../../rust-competitive-helper/rust-competitive-helper-util" } 12 | 13 | [features] 14 | local = [] 15 | default = ["local"] 16 | -------------------------------------------------------------------------------- /algo_lib/tests/f_mountain/0.in: -------------------------------------------------------------------------------- 1 | 10 2 | I 2 6 7 3 | Q 34 4 | I 4 8 11 5 | Q 33 6 | I 2 5 6 7 | Q 3 8 | I 4 7 10 9 | Q 28 10 | I 2 5 6 11 | Q 45 12 | I 3 6 8 13 | Q 37 14 | I 3 5 7 15 | Q 25 16 | I 4 6 9 17 | Q 34 18 | I 5 7 11 19 | Q 58 20 | I 5 7 11 21 | Q 23 22 | I 9 10 18 23 | Q 70 24 | I 7 8 14 25 | Q 73 26 | I 9 10 18 27 | Q 78 28 | I 9 10 18 29 | Q 94 30 | I 8 8 15 31 | Q 101 32 | I 10 10 19 33 | Q 93 34 | E 35 | -------------------------------------------------------------------------------- /algo_lib/tests/f_mountain/mou1.in: -------------------------------------------------------------------------------- 1 | 10 2 | I 2 6 7 3 | Q 34 4 | I 4 8 11 5 | Q 33 6 | I 2 5 6 7 | Q 3 8 | I 4 7 10 9 | Q 28 10 | I 2 5 6 11 | Q 45 12 | I 3 6 8 13 | Q 37 14 | I 3 5 7 15 | Q 25 16 | I 4 6 9 17 | Q 34 18 | I 5 7 11 19 | Q 58 20 | I 5 7 11 21 | Q 23 22 | I 9 10 18 23 | Q 70 24 | I 7 8 14 25 | Q 73 26 | I 9 10 18 27 | Q 78 28 | I 9 10 18 29 | Q 94 30 | I 8 8 15 31 | Q 101 32 | I 10 10 19 33 | Q 93 34 | E 35 | -------------------------------------------------------------------------------- /templates/main.rs: -------------------------------------------------------------------------------- 1 | //$JSON 2 | 3 | use algo_lib::io::input::Input; 4 | use algo_lib::io::output::Output; 5 | use algo_lib::misc::test_type::TaskType; 6 | $SOLVE 7 | 8 | #[cfg(feature = "local")] 9 | mod tester; 10 | 11 | #[cfg(feature = "local")] 12 | fn main() { 13 | tester::run_tests(); 14 | } 15 | 16 | #[cfg(not(feature = "local"))] 17 | fn main() { 18 | $INPUT 19 | $OUTPUT 20 | run(input, output); 21 | } 22 | -------------------------------------------------------------------------------- /algo_lib/src/string/concat.rs: -------------------------------------------------------------------------------- 1 | use crate::string::str::Str; 2 | 3 | pub trait StrConcat { 4 | fn str_concat(&self, other: &[u8]) -> Str; 5 | } 6 | 7 | impl StrConcat for [u8] { 8 | fn str_concat(&self, other: &[u8]) -> Str { 9 | let mut res = Vec::with_capacity(self.len() + other.len()); 10 | res.extend_from_slice(self); 11 | res.extend_from_slice(other); 12 | Str::from(res) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /algo_lib/src/misc/when.rs: -------------------------------------------------------------------------------- 1 | #[macro_export] 2 | macro_rules! when { 3 | {$($cond: expr => $then: expr,)*} => { 4 | match () { 5 | $(_ if $cond => $then,)* 6 | _ => unreachable!(), 7 | } 8 | }; 9 | {$($cond: expr => $then: expr,)* else $(=>)? $else: expr$(,)?} => { 10 | match () { 11 | $(_ if $cond => $then,)* 12 | _ => $else, 13 | } 14 | }; 15 | } 16 | -------------------------------------------------------------------------------- /algo_lib/src/misc/extensions/option.rs: -------------------------------------------------------------------------------- 1 | pub trait OptionExt: Sized { 2 | fn as_opt(&self) -> Option<&Self> { 3 | Some(self) 4 | } 5 | 6 | fn to_opt(self) -> Option { 7 | Some(self) 8 | } 9 | 10 | fn take_if(self, val: bool) -> Option { 11 | if val { 12 | Some(self) 13 | } else { 14 | None 15 | } 16 | } 17 | } 18 | 19 | impl OptionExt for T {} 20 | -------------------------------------------------------------------------------- /algo_lib/src/numbers/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod fwht; 2 | pub mod gauss; 3 | pub mod gcd; 4 | pub mod integer_sqrt; 5 | pub mod interpolation; 6 | pub mod matrix; 7 | pub mod matrix_series; 8 | pub mod mod_int; 9 | pub mod multiplicative_function; 10 | pub mod num_traits; 11 | pub mod num_utils; 12 | pub mod number_ext; 13 | pub mod number_iterator; 14 | pub mod primes; 15 | pub mod rational; 16 | pub mod real; 17 | pub mod series; 18 | pub mod signed_big_int; 19 | #[cfg(test)] 20 | mod test; 21 | pub mod unsigned_big_int; 22 | -------------------------------------------------------------------------------- /algo_lib/src/string/trim.rs: -------------------------------------------------------------------------------- 1 | // 1.80 2 | pub trait StrTrim { 3 | fn trim(&self) -> &[u8]; 4 | } 5 | 6 | impl StrTrim for [u8] { 7 | fn trim(&self) -> &[u8] { 8 | let mut start = 0; 9 | while start < self.len() && self[start].is_ascii_whitespace() { 10 | start += 1; 11 | } 12 | let mut end = self.len(); 13 | while end > start && self[end - 1].is_ascii_whitespace() { 14 | end -= 1; 15 | } 16 | &self[start..end] 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /algo_lib/src/graph/edges/edge_trait.rs: -------------------------------------------------------------------------------- 1 | pub trait EdgeTrait: Clone { 2 | type Payload; 3 | 4 | const REVERSABLE: bool; 5 | 6 | fn to(&self) -> usize; 7 | fn id(&self) -> usize; 8 | fn set_id(&mut self, id: usize); 9 | fn reverse_id(&self) -> usize; 10 | fn set_reverse_id(&mut self, reverse_id: usize); 11 | #[must_use] 12 | fn reverse_edge(&self, from: usize) -> Self; 13 | fn payload(&self) -> &Self::Payload; 14 | } 15 | 16 | pub trait BidirectionalEdgeTrait: EdgeTrait {} 17 | -------------------------------------------------------------------------------- /algo_lib/src/numbers/series.rs: -------------------------------------------------------------------------------- 1 | use crate::numbers::num_traits::algebra::Ring; 2 | use crate::numbers::number_ext::Power; 3 | use std::ops::Div; 4 | 5 | pub fn sum_arithmetic_series + Copy>(first: T, step: T, len: T) -> T { 6 | (first + first + step * (len - T::one())) * len / (T::one() + T::one()) 7 | } 8 | 9 | pub fn sum_geometric_series + Copy>(first: T, ratio: T, len: usize) -> T { 10 | first * (T::one() - ratio.power(len)) / (T::one() - ratio) 11 | } 12 | -------------------------------------------------------------------------------- /algo_lib/src/string/qty.rs: -------------------------------------------------------------------------------- 1 | pub trait StrQty { 2 | fn qty(&self, from: u8, to: u8) -> Vec; 3 | fn qty_lower(&self) -> Vec; 4 | } 5 | 6 | impl StrQty for [u8] { 7 | fn qty(&self, from: u8, to: u8) -> Vec { 8 | let mut res = vec![0; (to - from + 1) as usize]; 9 | for &c in self { 10 | res[(c - from) as usize] += 1; 11 | } 12 | res 13 | } 14 | 15 | fn qty_lower(&self) -> Vec { 16 | self.qty(b'a', b'z') 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /algo_lib/tests/f_mountain/mou12.ans: -------------------------------------------------------------------------------- 1 | 20000 2 | 8890 3 | 9072 4 | 9424 5 | 9496 6 | 9449 7 | 9329 8 | 11663 9 | 11877 10 | 20000 11 | 6703 12 | 10193 13 | 11867 14 | 12945 15 | 11910 16 | 13341 17 | 14253 18 | 20000 19 | 11974 20 | 4658 21 | 13600 22 | 8678 23 | 9743 24 | 20000 25 | 15541 26 | 20000 27 | 14827 28 | 14840 29 | 13889 30 | 14699 31 | 15563 32 | 5645 33 | 9195 34 | 11323 35 | 2693 36 | 16476 37 | 17029 38 | 9358 39 | 20000 40 | 12452 41 | 1802 42 | 5228 43 | 3607 44 | 19074 45 | 16171 46 | 7256 47 | 15754 48 | 14417 49 | -------------------------------------------------------------------------------- /algo_lib/src/graph/edges/flow_edge_trait.rs: -------------------------------------------------------------------------------- 1 | use crate::graph::edges::edge_trait::EdgeTrait; 2 | use crate::graph::Graph; 3 | use crate::numbers::num_traits::algebra::AdditionMonoidWithSub; 4 | 5 | pub trait FlowEdgeTrait: EdgeTrait { 6 | fn capacity(&self) -> C; 7 | fn capacity_mut(&mut self) -> &mut C; 8 | fn flow(&self, graph: &Graph) -> C; 9 | fn push_flow(&self, flow: C) -> (usize, usize, C) { 10 | (self.to(), self.reverse_id(), flow) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /algo_lib/src/numbers/num_traits/ord.rs: -------------------------------------------------------------------------------- 1 | pub trait MinMax: PartialOrd { 2 | fn min_val() -> Self; 3 | fn max_val() -> Self; 4 | } 5 | 6 | macro_rules! min_max_integer_impl { 7 | ($($t: ident)+) => {$( 8 | impl MinMax for $t { 9 | fn min_val() -> Self { 10 | $t::MIN 11 | } 12 | 13 | fn max_val() -> Self { 14 | $t::MAX 15 | } 16 | } 17 | )+}; 18 | } 19 | 20 | min_max_integer_impl!(i128 i64 i32 i16 i8 isize u128 u64 u32 u16 u8 usize); 21 | -------------------------------------------------------------------------------- /algo_lib/src/misc/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod between; 2 | pub mod bin_search; 3 | pub mod direction; 4 | pub mod dirs; 5 | pub mod expression_parser; 6 | pub mod extensions; 7 | pub mod hungarian_algorithm; 8 | pub mod lazy_lock; 9 | pub mod maybe; 10 | pub mod memo; 11 | pub mod owned_cell; 12 | pub mod random; 13 | pub mod recursive_function; 14 | pub mod run_parallel; 15 | pub mod simd; 16 | pub mod test_type; 17 | pub mod time_tracker; 18 | pub mod transparent_wrapper; 19 | pub mod value; 20 | pub mod value_delta; 21 | pub mod value_ref; 22 | pub mod when; 23 | -------------------------------------------------------------------------------- /algo_lib/src/geometry/geometry_utils.rs: -------------------------------------------------------------------------------- 1 | use crate::numbers::num_traits::algebra::Zero; 2 | use crate::numbers::real::Real; 3 | 4 | pub fn canonize_angle(angle: Real) -> Real { 5 | canonize_angle_base(angle, Real::zero() - Real::PI) 6 | } 7 | 8 | pub fn canonize_angle_base(angle: Real, base: Real) -> Real { 9 | let two = 2.; 10 | let mut angle = angle; 11 | while angle < base { 12 | angle += Real::PI * two; 13 | } 14 | while angle > base + Real::PI * two { 15 | angle -= Real::PI * two; 16 | } 17 | angle 18 | } 19 | -------------------------------------------------------------------------------- /algo_lib/src/misc/owned_cell.rs: -------------------------------------------------------------------------------- 1 | use std::cell::UnsafeCell; 2 | 3 | pub struct OwnedCell(UnsafeCell); 4 | 5 | impl OwnedCell { 6 | pub fn new(val: T) -> Self { 7 | Self(UnsafeCell::new(val)) 8 | } 9 | 10 | pub unsafe fn as_ref<'a>(&self) -> &'a T { 11 | &*self.0.get() 12 | } 13 | 14 | pub unsafe fn as_mut<'a>(&self) -> &'a mut T { 15 | &mut *self.0.get() 16 | } 17 | 18 | pub unsafe fn replace(&self, new_val: T) -> T { 19 | std::mem::replace(self.as_mut(), new_val) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /archive/2021/12/Advent of Code/day01a.rs: -------------------------------------------------------------------------------- 1 | use algo_lib::io::input::Input; 2 | 3 | fn main() { 4 | let mut sin = std::io::stdin(); 5 | let mut inp = Input::new(&mut sin); 6 | 7 | let mut ans = 0usize; 8 | let mut last: u16 = inp.read(); 9 | loop { 10 | inp.skip_whitespace(); 11 | if inp.peek().is_none() { 12 | break; 13 | } 14 | let cur: u16 = inp.read(); 15 | if cur > last { 16 | ans += 1; 17 | } 18 | last = cur; 19 | } 20 | println!("{}", ans); 21 | } 22 | -------------------------------------------------------------------------------- /algo_lib/src/string/split.rs: -------------------------------------------------------------------------------- 1 | pub trait StrSplit { 2 | fn str_split(&self, pattern: &[u8]) -> Vec<&[u8]>; 3 | } 4 | 5 | impl StrSplit for [u8] { 6 | fn str_split(&self, pattern: &[u8]) -> Vec<&[u8]> { 7 | let mut res = Vec::new(); 8 | let mut start = 0; 9 | for i in 0..self.len() { 10 | if self[i..].starts_with(pattern) { 11 | res.push(&self[start..i]); 12 | start = i + pattern.len(); 13 | } 14 | } 15 | res.push(&self[start..]); 16 | res 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /algo_lib/src/collections/bounds.rs: -------------------------------------------------------------------------------- 1 | use std::ops::RangeBounds; 2 | 3 | pub fn clamp(range: &impl RangeBounds, n: usize) -> (usize, usize) { 4 | let start = match range.start_bound() { 5 | std::ops::Bound::Included(&x) => x, 6 | std::ops::Bound::Excluded(&x) => x + 1, 7 | std::ops::Bound::Unbounded => 0, 8 | }; 9 | let end = match range.end_bound() { 10 | std::ops::Bound::Included(&x) => x + 1, 11 | std::ops::Bound::Excluded(&x) => x, 12 | std::ops::Bound::Unbounded => n, 13 | }; 14 | (start, end.min(n)) 15 | } 16 | -------------------------------------------------------------------------------- /archive/2021/12/Advent of Code/day01b.rs: -------------------------------------------------------------------------------- 1 | use algo_lib::io::input::Input; 2 | 3 | fn main() { 4 | let mut sin = std::io::stdin(); 5 | let mut inp = Input::new(&mut sin); 6 | 7 | let mut ans = 0usize; 8 | let mut last = Vec::new(); 9 | loop { 10 | inp.skip_whitespace(); 11 | if inp.peek().is_none() { 12 | break; 13 | } 14 | let cur: u16 = inp.read(); 15 | if last.len() >= 3 && last[last.len() - 3] < cur { 16 | ans += 1; 17 | } 18 | last.push(cur); 19 | } 20 | println!("{}", ans); 21 | } 22 | -------------------------------------------------------------------------------- /.github/workflows/rust.yml: -------------------------------------------------------------------------------- 1 | name: Cargo Build & Test 2 | 3 | on: 4 | push: 5 | pull_request: 6 | 7 | env: 8 | CARGO_TERM_COLOR: always 9 | 10 | jobs: 11 | build_and_test: 12 | name: Rust project - latest 13 | runs-on: ubuntu-latest 14 | strategy: 15 | matrix: 16 | toolchain: 17 | - stable 18 | - beta 19 | - nightly 20 | steps: 21 | - uses: actions/checkout@v4 22 | - run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} 23 | - run: cargo build --verbose 24 | - run: cargo test --verbose 25 | -------------------------------------------------------------------------------- /algo_lib/src/collections/slice_ext/qty.rs: -------------------------------------------------------------------------------- 1 | pub trait Qty { 2 | fn qty_bound(&self, bound: usize) -> Vec; 3 | fn qty(&self) -> Vec; 4 | } 5 | 6 | impl Qty for [usize] { 7 | fn qty_bound(&self, bound: usize) -> Vec { 8 | let mut res = vec![0; bound]; 9 | for i in self.iter() { 10 | res[*i] += 1; 11 | } 12 | res 13 | } 14 | 15 | fn qty(&self) -> Vec { 16 | if self.is_empty() { 17 | Vec::new() 18 | } else { 19 | self.qty_bound(self.iter().max().unwrap() + 1) 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /algo_lib/tests/f_mountain/mou5.ans: -------------------------------------------------------------------------------- 1 | 7197 2 | 4862 3 | 7815 4 | 8013 5 | 4779 6 | 6737 7 | 7894 8 | 5472 9 | 7974 10 | 7329 11 | 8160 12 | 5566 13 | 5846 14 | 3788 15 | 7974 16 | 6339 17 | 6303 18 | 5326 19 | 6583 20 | 7339 21 | 7214 22 | 4245 23 | 4522 24 | 7606 25 | 7376 26 | 2130 27 | 8008 28 | 8031 29 | 2967 30 | 7938 31 | 6348 32 | 7802 33 | 6892 34 | 7985 35 | 7786 36 | 6642 37 | 7236 38 | 6776 39 | 1706 40 | 4764 41 | 6880 42 | 3240 43 | 5553 44 | 2929 45 | 3852 46 | 2053 47 | 2551 48 | 8026 49 | 7385 50 | 7162 51 | 8016 52 | 6245 53 | 7174 54 | 5833 55 | 6565 56 | 5517 57 | 7799 58 | 7694 59 | 7514 60 | 3460 61 | 1579 62 | 6345 63 | 7049 64 | 7433 65 | -------------------------------------------------------------------------------- /algo_lib/src/collections/vec_ext/sorted.rs: -------------------------------------------------------------------------------- 1 | pub trait Sorted { 2 | fn sorted(self) -> Self 3 | where 4 | T: Ord; 5 | fn reversed(self) -> Self; 6 | fn sorted_by_key(self, f: impl FnMut(&T) -> R) -> Self; 7 | } 8 | 9 | impl Sorted for Vec { 10 | fn sorted(mut self) -> Self 11 | where 12 | T: Ord, 13 | { 14 | self.sort(); 15 | self 16 | } 17 | fn reversed(mut self) -> Self { 18 | self.reverse(); 19 | self 20 | } 21 | fn sorted_by_key(mut self, f: impl FnMut(&T) -> R) -> Self { 22 | self.sort_by_key(f); 23 | self 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /algo_lib/src/misc/value_delta.rs: -------------------------------------------------------------------------------- 1 | pub trait ValueDeltaTrait { 2 | type V; 3 | type D; 4 | fn join(v1: Self::V, v2: Self::V) -> Self::V; 5 | fn accumulate(d1: Self::D, d2: Self::D) -> Self::D; 6 | fn apply(v: Self::V, d: Self::D) -> Self::V; 7 | } 8 | 9 | pub trait ValueTrait { 10 | type V; 11 | fn join(v1: Self::V, v2: Self::V) -> Self::V; 12 | } 13 | 14 | impl ValueDeltaTrait for T { 15 | type V = T::V; 16 | type D = (); 17 | 18 | fn join(v1: T::V, v2: T::V) -> T::V { 19 | T::join(v1, v2) 20 | } 21 | 22 | fn accumulate(_d1: (), _d2: ()) {} 23 | 24 | fn apply(v: T::V, _d: ()) -> T::V { 25 | v 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /algo_lib/src/misc/transparent_wrapper.rs: -------------------------------------------------------------------------------- 1 | #[macro_export] 2 | macro_rules! transparent_wrapper { 3 | ($name: ident $(<$($par: ident$(,)?)+>)? = $t: ty $(, derive $($d: ty$(,)?)+)?) => { 4 | $(#[derive($($d,)+)])? 5 | pub struct $name$(<$($par,)+>)?($t); 6 | 7 | impl$(<$($par,)+>)? Deref for $name$(<$($par,)+>)? { 8 | type Target = $t; 9 | 10 | fn deref(&self) -> &Self::Target { 11 | &self.0 12 | } 13 | } 14 | 15 | impl$(<$($par,)+>)? DerefMut for $name$(<$($par,)+>)? { 16 | fn deref_mut(&mut self) -> &mut Self::Target { 17 | &mut self.0 18 | } 19 | } 20 | }; 21 | } 22 | -------------------------------------------------------------------------------- /algo_lib/src/numbers/num_traits/primitive.rs: -------------------------------------------------------------------------------- 1 | pub trait Primitive: Copy { 2 | fn to(self) -> T; 3 | fn from(t: T) -> Self; 4 | } 5 | 6 | macro_rules! primitive_one { 7 | ($t: ident, $($u: ident)+) => {$( 8 | impl Primitive<$u> for $t { 9 | fn to(self) -> $u { 10 | self as $u 11 | } 12 | fn from(t: $u) -> Self { 13 | t as $t 14 | } 15 | } 16 | )+}; 17 | } 18 | 19 | macro_rules! primitive { 20 | ($($t: ident)+) => {$( 21 | primitive_one!($t, u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize); 22 | )+} 23 | } 24 | 25 | primitive!(u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize); 26 | -------------------------------------------------------------------------------- /archive/2021/12/Advent of Code/day02a.rs: -------------------------------------------------------------------------------- 1 | use algo_lib::io::input::Input; 2 | 3 | fn main() { 4 | let mut sin = std::io::stdin(); 5 | let mut inp = Input::new(&mut sin); 6 | 7 | let mut pos = 0usize; 8 | let mut depth = 0usize; 9 | loop { 10 | inp.skip_whitespace(); 11 | if inp.peek().is_none() { 12 | break; 13 | } 14 | let dir: String = inp.read(); 15 | let cur: usize = inp.read(); 16 | match dir.as_str() { 17 | "forward" => pos += cur, 18 | "up" => depth -= cur, 19 | "down" => depth += cur, 20 | _ => unreachable!(), 21 | } 22 | } 23 | println!("{}", pos * depth); 24 | } 25 | -------------------------------------------------------------------------------- /algo_lib/src/misc/simd.rs: -------------------------------------------------------------------------------- 1 | #[target_feature(enable = "avx2")] 2 | unsafe fn fast_apply_avx2(a: &mut [T], mut f: impl FnMut(T) -> T) { 3 | for val in a.iter_mut() { 4 | *val = f(*val); 5 | } 6 | } 7 | 8 | pub fn fast_apply(a: &mut [T], f: impl FnMut(T) -> T) { 9 | unsafe { fast_apply_avx2(a, f) } 10 | } 11 | 12 | #[target_feature(enable = "avx2")] 13 | unsafe fn fast_fold_avx2(a: &[T], mut acc: R, mut f: impl FnMut(R, T) -> R) -> R { 14 | for val in a.iter() { 15 | acc = f(acc, *val); 16 | } 17 | acc 18 | } 19 | 20 | pub fn fast_fold(a: &[T], acc: R, f: impl FnMut(R, T) -> R) -> R { 21 | unsafe { fast_fold_avx2(a, acc, f) } 22 | } 23 | -------------------------------------------------------------------------------- /algo_lib/src/collections/slice_ext/next_permutation.rs: -------------------------------------------------------------------------------- 1 | pub trait NextPermutation { 2 | fn next_permutation(&mut self) -> bool; 3 | } 4 | 5 | impl NextPermutation for [T] { 6 | fn next_permutation(&mut self) -> bool { 7 | if self.len() <= 1 { 8 | return false; 9 | } 10 | let mut i = self.len() - 1; 11 | while i > 0 && self[i - 1] >= self[i] { 12 | i -= 1; 13 | } 14 | if i == 0 { 15 | return false; 16 | } 17 | let mut j = self.len() - 1; 18 | while self[j] <= self[i - 1] { 19 | j -= 1; 20 | } 21 | self.swap(i - 1, j); 22 | self[i..].reverse(); 23 | true 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /algo_lib/src/misc/time_tracker.rs: -------------------------------------------------------------------------------- 1 | use std::time::{Duration, Instant}; 2 | 3 | pub struct TimeTracker(Instant, bool); 4 | 5 | impl TimeTracker { 6 | pub fn new() -> Self { 7 | Self(Instant::now(), true) 8 | } 9 | 10 | pub fn elapsed(&self) -> Duration { 11 | self.0.elapsed() 12 | } 13 | 14 | pub fn disable(&mut self) { 15 | self.1 = false; 16 | } 17 | 18 | pub fn milestone(&mut self, name: &str) { 19 | if self.1 { 20 | eprintln!("{}: {}ms", name, self.elapsed().as_millis()); 21 | } 22 | self.0 = Instant::now(); 23 | } 24 | } 25 | 26 | impl Default for TimeTracker { 27 | fn default() -> Self { 28 | Self::new() 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /algo_lib/tests/f_mountain/mou6.ans: -------------------------------------------------------------------------------- 1 | 12347 2 | 16991 3 | 6502 4 | 15835 5 | 11808 6 | 15654 7 | 17279 8 | 19827 9 | 19074 10 | 18697 11 | 14880 12 | 9778 13 | 17802 14 | 14952 15 | 13069 16 | 17101 17 | 19515 18 | 11908 19 | 17776 20 | 19539 21 | 16316 22 | 15911 23 | 17242 24 | 17459 25 | 10443 26 | 19590 27 | 18072 28 | 14096 29 | 6288 30 | 11669 31 | 19709 32 | 11550 33 | 14144 34 | 14368 35 | 18333 36 | 17969 37 | 18989 38 | 18885 39 | 19707 40 | 19060 41 | 4835 42 | 19355 43 | 17947 44 | 19122 45 | 18214 46 | 14640 47 | 19784 48 | 10526 49 | 15136 50 | 18649 51 | 17907 52 | 19718 53 | 7197 54 | 18982 55 | 19846 56 | 19710 57 | 17194 58 | 18005 59 | 19160 60 | 4057 61 | 14357 62 | 13580 63 | 19832 64 | 18393 65 | 15291 66 | 18604 67 | -------------------------------------------------------------------------------- /algo_lib/tests/f_mountain/mou2.in: -------------------------------------------------------------------------------- 1 | 50 2 | I 5 8 0 3 | I 21 24 0 4 | I 25 28 0 5 | Q 0 6 | I 17 20 35 7 | I 23 26 11 8 | I 43 46 -46 9 | Q 184 10 | I 28 31 0 11 | I 40 43 34 12 | I 22 25 40 13 | Q 259 14 | I 15 18 175 15 | I 5 8 0 16 | I 24 27 155 17 | Q 1346 18 | I 29 30 235 19 | I 26 27 373 20 | I 8 9 235 21 | Q 2015 22 | I 1 2 0 23 | I 44 45 159 24 | I 6 7 0 25 | Q 1639 26 | I 28 29 -146 27 | I 25 26 -41 28 | I 8 9 235 29 | Q 160 30 | I 16 17 41 31 | I 33 34 347 32 | I 24 25 -63 33 | Q 1368 34 | I 42 42 489 35 | I 16 16 -15 36 | I 40 40 96 37 | Q 2443 38 | I 20 20 -160 39 | I 41 41 -238 40 | I 30 30 -24 41 | Q 1066 42 | I 18 18 253 43 | I 48 48 216 44 | I 22 22 -8 45 | Q 1568 46 | I 26 26 -123 47 | I 10 10 168 48 | I 28 28 -786 49 | Q 1422 50 | E 51 | -------------------------------------------------------------------------------- /algo_lib/src/collections/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod bit_set; 2 | pub mod bounds; 3 | pub mod btree_ext; 4 | pub mod default_map; 5 | pub mod divided_set; 6 | pub mod dsu; 7 | pub mod dsu2d; 8 | pub mod euler_tour_tree; 9 | pub mod fast_clear_arr; 10 | pub mod fast_clear_fenwick; 11 | pub mod fenwick; 12 | pub mod fx_hash_map; 13 | pub mod id; 14 | pub mod indexed_heap; 15 | pub mod iter_ext; 16 | pub mod link_cut; 17 | pub mod md_arr; 18 | pub mod min_max; 19 | pub mod multi_set; 20 | pub mod order; 21 | pub mod payload; 22 | pub mod persistent_fenwick; 23 | pub mod segment_tree; 24 | pub mod slice_ext; 25 | pub mod sliding_window; 26 | pub mod sparse_table; 27 | pub mod sparse_table_pos; 28 | #[cfg(test)] 29 | mod test; 30 | pub mod treap; 31 | pub mod vec_ext; 32 | -------------------------------------------------------------------------------- /algo_lib/src/string/string_algorithms/prefix_function.rs: -------------------------------------------------------------------------------- 1 | use crate::string::slicelike::Slicelike; 2 | 3 | pub trait PrefixFunction { 4 | fn prefix_function(&self) -> Vec; 5 | } 6 | 7 | impl PrefixFunction for S 8 | where 9 | S::Output: PartialEq + Sized, 10 | { 11 | fn prefix_function(&self) -> Vec { 12 | let mut res = Vec::with_capacity(self.len()); 13 | res.push(0); 14 | for i in 1..self.len() { 15 | let mut j = res[i - 1]; 16 | while j > 0 && self[i] != self[j] { 17 | j = res[j - 1]; 18 | } 19 | if self[i] == self[j] { 20 | j += 1; 21 | } 22 | res.push(j); 23 | } 24 | res 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /templates/sites/meta.rs: -------------------------------------------------------------------------------- 1 | use algo_lib::misc::run_parallel::run_parallel; 2 | use algo_lib::misc::test_type::TestType; 3 | use std::sync::MutexGuard; 4 | 5 | type PreCalc = (); 6 | 7 | fn solve(mut input: MutexGuard, out: &mut Output, test_case: usize, _data: &PreCalc) { 8 | $CARET 9 | drop(input); 10 | out.print_line((format!("Case #{}:", test_case),)); 11 | } 12 | 13 | pub static TASK_TYPE: TaskType = TaskType::Classic; 14 | pub static TEST_TYPE: TestType = TestType::MultiNumber; 15 | 16 | pub(crate) fn run(input: Input, mut output: Output) -> bool { 17 | eprint!("\x1B[33m\x1B[03m"); 18 | let pre_calc = (); 19 | let is_exhausted = run_parallel(input, &mut output, true, pre_calc, solve); 20 | eprint!("\x1B[0m"); 21 | output.flush(); 22 | is_exhausted 23 | } 24 | -------------------------------------------------------------------------------- /algo_lib/src/graph/edges/edge_id.rs: -------------------------------------------------------------------------------- 1 | pub trait EdgeId: Clone { 2 | fn new() -> Self; 3 | fn id(&self) -> usize; 4 | fn set_id(&mut self, id: usize); 5 | } 6 | 7 | #[derive(Clone)] 8 | pub struct WithId { 9 | id: u32, 10 | } 11 | 12 | impl EdgeId for WithId { 13 | fn new() -> Self { 14 | Self { id: 0 } 15 | } 16 | 17 | fn id(&self) -> usize { 18 | self.id as usize 19 | } 20 | 21 | fn set_id(&mut self, id: usize) { 22 | self.id = id as u32; 23 | } 24 | } 25 | 26 | #[derive(Clone)] 27 | pub struct NoId {} 28 | 29 | impl EdgeId for NoId { 30 | fn new() -> Self { 31 | Self {} 32 | } 33 | 34 | fn id(&self) -> usize { 35 | panic!("Id called on no id") 36 | } 37 | 38 | fn set_id(&mut self, _: usize) {} 39 | } 40 | -------------------------------------------------------------------------------- /algo_lib/src/collections/slice_ext/consecutive_iter.rs: -------------------------------------------------------------------------------- 1 | use std::iter::{Copied, Skip, Zip}; 2 | use std::slice::Iter; 3 | 4 | pub trait ConsecutiveIter { 5 | fn consecutive_iter(&self) -> Zip, Skip>>; 6 | } 7 | 8 | impl ConsecutiveIter for [T] { 9 | fn consecutive_iter(&self) -> Zip, Skip>> { 10 | self.iter().zip(self.iter().skip(1)) 11 | } 12 | } 13 | 14 | pub trait ConsecutiveIterCopy { 15 | fn consecutive_iter_copy(&self) -> Zip>, Copied>>>; 16 | } 17 | 18 | impl ConsecutiveIterCopy for [T] { 19 | fn consecutive_iter_copy(&self) -> Zip>, Copied>>> { 20 | self.iter().copied().zip(self.iter().skip(1).copied()) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /archive/2021/12/Advent of Code/day02b.rs: -------------------------------------------------------------------------------- 1 | use algo_lib::io::input::Input; 2 | 3 | fn main() { 4 | let mut sin = std::io::stdin(); 5 | let mut inp = Input::new(&mut sin); 6 | 7 | let mut pos = 0usize; 8 | let mut depth = 0usize; 9 | let mut aim = 0usize; 10 | loop { 11 | inp.skip_whitespace(); 12 | if inp.peek().is_none() { 13 | break; 14 | } 15 | let dir: String = inp.read(); 16 | let cur: usize = inp.read(); 17 | match dir.as_str() { 18 | "forward" => { 19 | pos += cur; 20 | depth += aim * cur; 21 | } 22 | "up" => aim -= cur, 23 | "down" => aim += cur, 24 | _ => unreachable!(), 25 | } 26 | } 27 | println!("{}", pos * depth); 28 | } 29 | -------------------------------------------------------------------------------- /archive/2021/12/Advent of Code/day06a.rs: -------------------------------------------------------------------------------- 1 | use algo_lib::collections::iter_ext::IterExt; 2 | use algo_lib::io::input::Input; 3 | 4 | fn main() { 5 | let mut sin = std::io::stdin(); 6 | let mut inp = Input::new(&mut sin); 7 | 8 | let mut s: String = inp.read(); 9 | s = s.replace(",", " "); 10 | let mut bytes = s.as_bytes(); 11 | let mut inp = Input::new(&mut bytes); 12 | let mut vals: Vec = inp.into_iter().collect_vec(); 13 | for _ in 0..80 { 14 | let mut nvals = Vec::new(); 15 | for i in vals { 16 | if i == 0 { 17 | nvals.push(6); 18 | nvals.push(8); 19 | } else { 20 | nvals.push(i - 1); 21 | } 22 | } 23 | vals = nvals; 24 | } 25 | println!("{}", vals.len()); 26 | } 27 | -------------------------------------------------------------------------------- /algo_lib/tests/f_mountain/mou3.in: -------------------------------------------------------------------------------- 1 | 257 2 | I 99 130 2048 3 | I 92 124 1986 4 | I 216 246 2114 5 | I 211 241 2114 6 | I 176 208 1986 7 | I 185 216 2048 8 | I 140 172 1986 9 | I 25 57 1986 10 | I 215 247 1986 11 | I 44 75 2048 12 | I 173 203 2114 13 | I 169 201 1986 14 | I 217 249 1986 15 | I 165 195 2114 16 | I 41 73 1986 17 | I 84 114 2114 18 | I 155 166 5461 19 | Q 276413 20 | I 210 221 0 21 | Q 393605 22 | I 121 127 0 23 | Q 390395 24 | I 167 173 0 25 | Q 358481 26 | I 211 221 0 27 | Q 362765 28 | I 156 157 0 29 | Q 238574 30 | I 110 115 0 31 | Q 223736 32 | I 24 34 5958 33 | Q 277693 34 | I 194 200 0 35 | Q 374965 36 | I 12 19 0 37 | Q 263436 38 | I 30 37 8192 39 | Q 164523 40 | I 245 250 0 41 | Q 438774 42 | I 3 7 0 43 | Q 391788 44 | I 235 239 0 45 | Q 423984 46 | I 101 103 0 47 | Q 416751 48 | I 217 220 0 49 | Q 409910 50 | E 51 | -------------------------------------------------------------------------------- /algo_lib/src/collections/slice_ext/backward.rs: -------------------------------------------------------------------------------- 1 | use std::ops::{Index, IndexMut}; 2 | 3 | pub struct Back(pub usize); 4 | 5 | impl Index for [T] { 6 | type Output = T; 7 | 8 | fn index(&self, index: Back) -> &Self::Output { 9 | &self[self.len() - index.0 - 1] 10 | } 11 | } 12 | 13 | impl IndexMut for [T] { 14 | fn index_mut(&mut self, index: Back) -> &mut Self::Output { 15 | &mut self[self.len() - index.0 - 1] 16 | } 17 | } 18 | 19 | impl Index for Vec { 20 | type Output = T; 21 | 22 | fn index(&self, index: Back) -> &Self::Output { 23 | self.as_slice().index(index) 24 | } 25 | } 26 | 27 | impl IndexMut for Vec { 28 | fn index_mut(&mut self, index: Back) -> &mut Self::Output { 29 | self.as_mut_slice().index_mut(index) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /templates/main/regex.rs: -------------------------------------------------------------------------------- 1 | let paths = std::fs::read_dir(".").unwrap(); 2 | let mut result = None; 3 | let mut last_accessed = None; 4 | let re = regex::Regex::new("$PATTERN").unwrap(); 5 | for path in paths { 6 | let path = path.unwrap(); 7 | let cur_accessed = path.metadata().unwrap().accessed().unwrap(); 8 | let path = path.path(); 9 | let cur_name = path.file_name().unwrap().to_str().unwrap(); 10 | if re.is_match(cur_name) { 11 | if last_accessed.is_none() || cur_accessed > last_accessed.unwrap() { 12 | result = Some(cur_name.to_string()); 13 | last_accessed = Some(cur_accessed); 14 | } 15 | } 16 | } 17 | let in_file = std::fs::File::open(result.unwrap()).unwrap(); 18 | let input = algo_lib::io::input::Input::file(in_file); -------------------------------------------------------------------------------- /archive/2023/12/7.12.2023 - CPython Programming Contest #3/c.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | int n; 8 | scanf("%d", &n); 9 | 10 | auto is_prime = vector(n + 1, true); 11 | bool first = true; 12 | int id = 0; 13 | is_prime.at(1) = false; 14 | for (int i = 2; i <= n; i++) { 15 | if (is_prime.at(i)) { 16 | id += 1; 17 | if (is_prime.at(id)) { 18 | if (first) { 19 | first = false; 20 | } else { 21 | printf(" "); 22 | } 23 | printf("%d", i); 24 | } 25 | for (int j = 2 * i; j <= n; j += i) { 26 | is_prime.at(j) = false; 27 | } 28 | } 29 | } 30 | printf("\n"); 31 | } 32 | -------------------------------------------------------------------------------- /archive/2021/12/Advent of Code/day06b.rs: -------------------------------------------------------------------------------- 1 | use algo_lib::collections::iter_ext::IterExt; 2 | use algo_lib::io::input::Input; 3 | 4 | fn main() { 5 | let mut sin = std::io::stdin(); 6 | let mut inp = Input::new(&mut sin); 7 | 8 | let mut s: String = inp.read(); 9 | s = s.replace(",", " "); 10 | let mut bytes = s.as_bytes(); 11 | let mut inp = Input::new(&mut bytes); 12 | let mut vals: Vec = inp.into_iter().collect_vec(); 13 | let mut qty = vec![0u64; 9]; 14 | for i in vals { 15 | qty[i] += 1; 16 | } 17 | for _ in 0..256 { 18 | let mut nqty = vec![0u64; 9]; 19 | nqty[6] = qty[0]; 20 | nqty[8] = qty[0]; 21 | for i in 1usize..9 { 22 | nqty[i - 1] += qty[i]; 23 | } 24 | qty = nqty; 25 | } 26 | let x: u64 = qty.iter().sum(); 27 | println!("{}", x); 28 | } 29 | -------------------------------------------------------------------------------- /algo_lib/src/misc/maybe.rs: -------------------------------------------------------------------------------- 1 | use std::mem; 2 | use std::mem::ManuallyDrop; 3 | use std::ops::{Deref, DerefMut}; 4 | 5 | pub union Maybe { 6 | pub value: ManuallyDrop, 7 | pub none: (), 8 | } 9 | 10 | impl Maybe { 11 | pub fn new(value: T) -> Self { 12 | Self { 13 | value: ManuallyDrop::new(value), 14 | } 15 | } 16 | 17 | pub fn none() -> Self { 18 | Self { none: () } 19 | } 20 | 21 | pub unsafe fn take(&mut self) -> T { 22 | unsafe { ManuallyDrop::into_inner(mem::replace(self, Maybe::none()).value) } 23 | } 24 | 25 | pub unsafe fn as_ref(&self) -> &T { 26 | self.value.deref() 27 | } 28 | 29 | pub unsafe fn as_mut(&mut self) -> &mut T { 30 | self.value.deref_mut() 31 | } 32 | 33 | pub unsafe fn drop(&mut self) { 34 | unsafe { ManuallyDrop::drop(&mut self.value) } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /algo_lib/src/graph/flow_graph.rs: -------------------------------------------------------------------------------- 1 | use crate::graph::edges::flow_edge_trait::FlowEdgeTrait; 2 | use crate::graph::Graph; 3 | use crate::numbers::num_traits::algebra::AdditionMonoidWithSub; 4 | 5 | pub trait FlowGraph> { 6 | fn push_flow(&mut self, push_data: (usize, usize, C)); 7 | } 8 | 9 | impl> FlowGraph 10 | for Graph 11 | { 12 | fn push_flow(&mut self, (to, reverse_id, flow): (usize, usize, C)) { 13 | *self.edges[to][reverse_id].capacity_mut() += flow; 14 | let from = self.edges[to][reverse_id].to(); 15 | let direct_id = self.edges[to][reverse_id].reverse_id(); 16 | let direct = &mut self.edges[from][direct_id]; 17 | assert!(flow >= C::zero() && flow <= direct.capacity()); 18 | *direct.capacity_mut() -= flow; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /algo_lib/src/collections/iter_ext/min_max.rs: -------------------------------------------------------------------------------- 1 | use crate::collections::min_max::MinimMaxim; 2 | 3 | pub trait IterMinMaxPos<'a, T: Ord + 'a>: 'a 4 | where 5 | &'a Self: IntoIterator, 6 | { 7 | fn max_position(&'a self) -> usize { 8 | let mut res = None; 9 | let mut val = None; 10 | for (i, cur) in self.into_iter().enumerate() { 11 | if val.maxim(cur) { 12 | res = Some(i); 13 | } 14 | } 15 | res.unwrap() 16 | } 17 | 18 | fn min_position(&'a self) -> usize { 19 | let mut res = None; 20 | let mut val = None; 21 | for (i, cur) in self.into_iter().enumerate() { 22 | if val.minim(cur) { 23 | res = Some(i); 24 | } 25 | } 26 | res.unwrap() 27 | } 28 | } 29 | 30 | impl<'a, T: Ord + 'a, I: ?Sized + 'a> IterMinMaxPos<'a, T> for I where &'a I: IntoIterator {} 31 | -------------------------------------------------------------------------------- /algo_lib/src/misc/extensions/replace_with.rs: -------------------------------------------------------------------------------- 1 | use std::{mem, ptr}; 2 | 3 | pub trait ReplaceWith Self>: Sized { 4 | fn replace_with(&mut self, f: F) { 5 | unsafe { 6 | let old = ptr::read(self); 7 | let new = on_unwind(move || f(old), || std::process::abort()); 8 | ptr::write(self, new); 9 | } 10 | } 11 | } 12 | 13 | impl Self> ReplaceWith for T {} 14 | 15 | pub fn on_unwind T, T, P: FnOnce()>(f: F, p: P) -> T { 16 | let x = OnDrop(mem::ManuallyDrop::new(p)); 17 | let t = f(); 18 | let mut x = mem::ManuallyDrop::new(x); 19 | unsafe { mem::ManuallyDrop::drop(&mut x.0) }; 20 | t 21 | } 22 | 23 | struct OnDrop(mem::ManuallyDrop); 24 | impl Drop for OnDrop { 25 | #[inline(always)] 26 | fn drop(&mut self) { 27 | (unsafe { ptr::read(&*self.0) })(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /algo_lib/src/geometry/angle.rs: -------------------------------------------------------------------------------- 1 | use crate::geometry::geometry_utils::canonize_angle_base; 2 | use crate::geometry::point::Point; 3 | use crate::geometry::ray::Ray; 4 | use crate::numbers::num_traits::algebra::Zero; 5 | use crate::numbers::real::Real; 6 | 7 | pub struct Angle { 8 | pub origin: Point, 9 | pub dir1: Point, 10 | pub dir2: Point, 11 | } 12 | 13 | impl Angle { 14 | pub fn new(origin: Point, dir1: Point, dir2: Point) -> Self { 15 | Self { origin, dir1, dir2 } 16 | } 17 | } 18 | 19 | impl Angle { 20 | pub fn value(&self) -> Real { 21 | let a1 = (self.dir1 - self.origin).angle(); 22 | let a2 = (self.dir2 - self.origin).angle(); 23 | canonize_angle_base(a2 - a1, Real::zero()) 24 | } 25 | 26 | pub fn bisector(&self) -> Ray { 27 | let angle = (self.dir1 - self.origin).angle(); 28 | Ray::from_angle(self.origin, angle + self.value() / 2.) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /algo_lib/src/io/eol.rs: -------------------------------------------------------------------------------- 1 | use crate::io::input::{Input, Readable}; 2 | use crate::string::str::{Str, StrReader}; 3 | use crate::transparent_wrapper; 4 | use std::ops::{Deref, DerefMut}; 5 | 6 | transparent_wrapper!(EolStr = Str); 7 | impl EolStr { 8 | pub fn unwrap(self) -> Str { 9 | self.0 10 | } 11 | } 12 | 13 | impl Readable for EolStr { 14 | fn read(input: &mut Input) -> Self { 15 | Self(input.read_line()) 16 | } 17 | } 18 | 19 | transparent_wrapper!(EolVec = Vec); 20 | impl EolVec { 21 | pub fn unwrap(self) -> Vec { 22 | self.0 23 | } 24 | } 25 | 26 | impl Readable for EolVec { 27 | fn read(input: &mut Input) -> Self { 28 | let mut vec = Vec::new(); 29 | loop { 30 | let item = T::read(input); 31 | vec.push(item); 32 | if input.is_eol() { 33 | break; 34 | } 35 | } 36 | Self(vec) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /algo_lib/src/collections/test.rs: -------------------------------------------------------------------------------- 1 | use crate::collections::iter_ext::iter_copied::ItersCopied; 2 | use crate::collections::slice_ext::compress::{compress, Compressed}; 3 | use crate::collections::slice_ext::permutation::Permutation; 4 | use crate::collections::vec_ext::inc_dec::IncDec; 5 | 6 | #[test] 7 | fn test_find() { 8 | let v = vec![1, 2, 3]; 9 | assert_eq!(Some(1), v.copy_find(2)); 10 | assert_eq!(None, v.copy_find(0)); 11 | } 12 | 13 | #[test] 14 | fn test_permutation_mul() { 15 | let p = vec![1, 3, 2].dec(); 16 | let q = vec![2, 1, 3].dec(); 17 | assert_eq!(p.mul(&q), vec![2, 0, 1]); 18 | assert_eq!(q.mul(&p), vec![1, 2, 0]); 19 | } 20 | 21 | #[test] 22 | fn test_compress() { 23 | let a = vec![3, 5, 7]; 24 | let b = vec![7, 4, 5]; 25 | assert_eq!( 26 | compress([&a, &b]), 27 | Compressed { 28 | order: vec![3, 4, 5, 7], 29 | arrs: [vec![0, 2, 3], vec![3, 1, 2]] 30 | } 31 | ); 32 | } 33 | -------------------------------------------------------------------------------- /algo_lib/src/numbers/fwht.rs: -------------------------------------------------------------------------------- 1 | use crate::numbers::num_traits::algebra::SemiRingWithSub; 2 | use std::ops::DivAssign; 3 | 4 | pub trait FWHT { 5 | fn fwht(&mut self, inverse: bool); 6 | } 7 | 8 | impl + Copy> FWHT for [T] { 9 | fn fwht(&mut self, inverse: bool) { 10 | assert!(!self.is_empty()); 11 | let n = self.len(); 12 | assert_eq!(n & (n - 1), 0); 13 | let mut len = 1; 14 | while len < n { 15 | for i in (0..n).step_by(2 * len) { 16 | let (head, tail) = self.split_at_mut(i + len); 17 | for (u, v) in head.iter_mut().skip(i).zip(tail.iter_mut()) { 18 | (*u, *v) = (*u + *v, *u - *v); 19 | } 20 | } 21 | len *= 2; 22 | } 23 | 24 | if inverse { 25 | for p in self.iter_mut() { 26 | *p /= T::from(n); 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /algo_lib/src/misc/memo/test.rs: -------------------------------------------------------------------------------- 1 | mod memoization_test { 2 | use crate::misc::memo::memoization::Memoization2; 3 | use crate::misc::memo::memoization_2d::Memoization2d; 4 | use crate::misc::recursive_function::Callable2; 5 | use crate::numbers::mod_int::ModIntF; 6 | use crate::numbers::num_traits::algebra::One; 7 | 8 | #[test] 9 | fn test() { 10 | type Mod = ModIntF; 11 | let mut mem2d = Memoization2d::new(1001, 1001, |f, n, m| { 12 | if n == 0 || m == 0 { 13 | Mod::one() 14 | } else { 15 | f.call(n - 1, m) + f.call(n, m - 1) 16 | } 17 | }); 18 | let mut mem = Memoization2::new(|f, n, m| { 19 | if n == 0 || m == 0 { 20 | Mod::one() 21 | } else { 22 | f.call(n - 1, m) + f.call(n, m - 1) 23 | } 24 | }); 25 | assert_eq!(mem.call(1000, 1000), mem2d.call(1000, 1000)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /algo_lib/src/numbers/primes/sieve.rs: -------------------------------------------------------------------------------- 1 | use crate::collections::bit_set::BitSet; 2 | 3 | pub fn primality_table(n: usize) -> BitSet { 4 | let mut res = BitSet::new(n); 5 | res.fill(true); 6 | if n > 0 { 7 | res.unset(0); 8 | } 9 | if n > 1 { 10 | res.unset(1); 11 | } 12 | let mut i = 2; 13 | while i * i < n { 14 | if res[i] { 15 | for j in ((i * i)..n).step_by(i) { 16 | res.unset(j); 17 | } 18 | } 19 | i += 1; 20 | } 21 | res 22 | } 23 | 24 | pub fn primes(n: usize) -> Vec { 25 | primality_table(n).into_iter().collect() 26 | } 27 | 28 | pub fn divisor_table(n: usize) -> Vec { 29 | let mut res: Vec<_> = (0..n).collect(); 30 | let mut i = 2; 31 | while i * i < n { 32 | if res[i] == i { 33 | for j in ((i * i)..n).step_by(i) { 34 | res[j] = i; 35 | } 36 | } 37 | i += 1; 38 | } 39 | res 40 | } 41 | -------------------------------------------------------------------------------- /algo_lib/src/string/string_algorithms/z_algorithm.rs: -------------------------------------------------------------------------------- 1 | use crate::string::slicelike::Slicelike; 2 | 3 | pub trait ZAlgorithm { 4 | fn z_algorithm(&self) -> Vec; 5 | } 6 | 7 | impl ZAlgorithm for S 8 | where 9 | S::Output: PartialEq + Sized, 10 | { 11 | fn z_algorithm(&self) -> Vec { 12 | let mut res = Vec::with_capacity(self.len()); 13 | res.push(0); 14 | let mut l = 0; 15 | let mut r = 0; 16 | for i in 1..self.len() { 17 | if i <= r { 18 | let cur = (r - i + 1).min(res[i - l]); 19 | res.push(cur); 20 | } else { 21 | res.push(0); 22 | } 23 | while i + res[i] < self.len() && self[res[i]] == self[i + res[i]] { 24 | res[i] += 1; 25 | } 26 | if i + res[i] - 1 > r { 27 | l = i; 28 | r = i + res[i] - 1; 29 | } 30 | } 31 | res 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /algo_lib/src/numbers/num_traits/sign.rs: -------------------------------------------------------------------------------- 1 | pub trait IsSigned { 2 | const SIGNED: bool; 3 | } 4 | 5 | pub trait Signed: IsSigned {} 6 | 7 | pub trait Unsigned: IsSigned { 8 | fn distance(self, other: Self) -> Self; 9 | } 10 | 11 | macro_rules! unsigned_impl { 12 | ($($t: ident)+) => {$( 13 | impl Unsigned for $t { 14 | fn distance(self, other: Self) -> Self { 15 | if self > other { 16 | self - other 17 | } else { 18 | other - self 19 | } 20 | } 21 | } 22 | 23 | impl IsSigned for $t { 24 | const SIGNED: bool = false; 25 | } 26 | )+}; 27 | } 28 | 29 | unsigned_impl!(u128 u64 u32 u16 u8 usize); 30 | 31 | macro_rules! signed_impl { 32 | ($($t: ident)+) => {$( 33 | impl Signed for $t {} 34 | 35 | impl IsSigned for $t { 36 | const SIGNED: bool = true; 37 | } 38 | )+}; 39 | } 40 | 41 | signed_impl!(i128 i64 i32 i16 i8 isize); 42 | -------------------------------------------------------------------------------- /archive/2021/12/Advent of Code/day03a.rs: -------------------------------------------------------------------------------- 1 | use algo_lib::collections::min_max::MinimMaxim; 2 | use algo_lib::io::input::Input; 3 | 4 | fn main() { 5 | let mut sin = std::io::stdin(); 6 | let mut inp = Input::new(&mut sin); 7 | 8 | let mut zeros = vec![0usize; 32]; 9 | let mut ones = vec![0usize; 32]; 10 | let mut len = 0; 11 | loop { 12 | inp.skip_whitespace(); 13 | if inp.peek().is_none() { 14 | break; 15 | } 16 | let cur: String = inp.read(); 17 | len.maxim(cur.len()); 18 | for (i, d) in cur.chars().rev().enumerate() { 19 | if d == '0' { 20 | zeros[i] += 1; 21 | } else { 22 | ones[i] += 1; 23 | } 24 | } 25 | } 26 | let mut gamma = 0u64; 27 | let mut eps = 0u64; 28 | for i in 0..len { 29 | if zeros[i] > ones[i] { 30 | eps += 1u64 << i; 31 | } else { 32 | gamma += 1u64 << i; 33 | } 34 | } 35 | println!("{}", gamma * eps); 36 | } 37 | -------------------------------------------------------------------------------- /algo_lib/src/collections/iter_ext/interleave.rs: -------------------------------------------------------------------------------- 1 | enum NextFrom { 2 | First, 3 | Second, 4 | } 5 | 6 | pub struct Interleave, J: Iterator> { 7 | iter1: I, 8 | iter2: J, 9 | next_from: NextFrom, 10 | } 11 | 12 | impl, J: Iterator> Iterator for Interleave { 13 | type Item = T; 14 | 15 | fn next(&mut self) -> Option { 16 | match self.next_from { 17 | NextFrom::First => { 18 | self.next_from = NextFrom::Second; 19 | self.iter1.next() 20 | } 21 | NextFrom::Second => { 22 | self.next_from = NextFrom::First; 23 | self.iter2.next() 24 | } 25 | } 26 | } 27 | } 28 | 29 | pub fn interleave, J: Iterator>( 30 | iter1: I, 31 | iter2: J, 32 | ) -> Interleave { 33 | Interleave { 34 | iter1, 35 | iter2, 36 | next_from: NextFrom::First, 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /archive/2021/12/27.12.2021 - Abakoda 2021 Long Contest/f_funny_sequence.rs: -------------------------------------------------------------------------------- 1 | //{"name":"F. Funny Sequence","group":"Codeforces - Abakoda 2021 Long Contest","url":"http://codeforces.com/gym/103496/problem/F","interactive":false,"timeLimit":500,"tests":[{"input":"0\n","output":"2\n"},{"input":"1\n","output":"3\n"},{"input":"2\n","output":"6\n"}],"testType":"single","input":{"type":"stdin","fileName":null,"pattern":null},"output":{"type":"stdout","fileName":null,"pattern":null},"languages":{"java":{"taskClass":"FFunnySequence"}}} 2 | 3 | use algo_lib::io::input::Input; 4 | use algo_lib::io::output::output; 5 | use algo_lib::out_line; 6 | 7 | fn solve(input: &mut Input, _test_case: usize) { 8 | let n = input.read_long(); 9 | 10 | out_line!(n * n + 2); 11 | } 12 | 13 | pub(crate) fn run(mut input: Input) -> bool { 14 | solve(&mut input, 1); 15 | output().flush(); 16 | input.skip_whitespace(); 17 | !input.peek().is_some() 18 | } 19 | 20 | //START MAIN 21 | mod tester; 22 | 23 | fn main() { 24 | tester::run_tests(); 25 | } 26 | //END MAIN 27 | -------------------------------------------------------------------------------- /algo_lib/src/string/slicelike.rs: -------------------------------------------------------------------------------- 1 | use std::ops::Index; 2 | 3 | pub trait Slicelike: Index 4 | where 5 | Self::Output: Sized, 6 | { 7 | fn len(&self) -> usize; 8 | fn is_empty(&self) -> bool { 9 | self.len() == 0 10 | } 11 | } 12 | 13 | impl Slicelike for [T] { 14 | fn len(&self) -> usize { 15 | <[T]>::len(self) 16 | } 17 | } 18 | 19 | pub struct Concat<'s, T> { 20 | first: &'s [T], 21 | second: &'s [T], 22 | } 23 | 24 | impl Index for Concat<'_, T> { 25 | type Output = T; 26 | 27 | fn index(&self, index: usize) -> &Self::Output { 28 | if index < self.first.len() { 29 | &self.first[index] 30 | } else { 31 | &self.second[index - self.first.len()] 32 | } 33 | } 34 | } 35 | 36 | impl Slicelike for Concat<'_, T> { 37 | fn len(&self) -> usize { 38 | self.first.len() + self.second.len() 39 | } 40 | } 41 | 42 | pub fn chain<'a, T>(first: &'a [T], second: &'a [T]) -> Concat<'a, T> { 43 | Concat { first, second } 44 | } 45 | -------------------------------------------------------------------------------- /algo_lib/tests/f_mountain/mou11.ans: -------------------------------------------------------------------------------- 1 | 12454 2 | 9395 3 | 11746 4 | 16743 5 | 19570 6 | 13749 7 | 9456 8 | 10435 9 | 13250 10 | 10736 11 | 19193 12 | 6521 13 | 11370 14 | 12188 15 | 19384 16 | 12496 17 | 19126 18 | 11230 19 | 15570 20 | 12607 21 | 17845 22 | 19658 23 | 8517 24 | 17238 25 | 15849 26 | 272 27 | 8633 28 | 12181 29 | 4479 30 | 14360 31 | 19351 32 | 19816 33 | 1829 34 | 19753 35 | 3469 36 | 10147 37 | 17302 38 | 11811 39 | 10907 40 | 12550 41 | 12829 42 | 15606 43 | 10952 44 | 14065 45 | 16583 46 | 10541 47 | 11394 48 | 19143 49 | 10198 50 | 9319 51 | 10615 52 | 11714 53 | 3576 54 | 7219 55 | 15048 56 | 16733 57 | 19100 58 | 12345 59 | 10721 60 | 3241 61 | 18694 62 | 10430 63 | 11328 64 | 16228 65 | 11924 66 | 13355 67 | 19902 68 | 10695 69 | 17886 70 | 11907 71 | 16763 72 | 8114 73 | 10285 74 | 6959 75 | 12851 76 | 14713 77 | 10123 78 | 8284 79 | 10046 80 | 10564 81 | 16417 82 | 18522 83 | 18985 84 | 10333 85 | 10832 86 | 19686 87 | 15924 88 | 10400 89 | 10306 90 | 10294 91 | 10181 92 | 12958 93 | 18031 94 | 10209 95 | 17216 96 | 19912 97 | 12785 98 | 2176 99 | -------------------------------------------------------------------------------- /algo_lib/src/numbers/matrix_series.rs: -------------------------------------------------------------------------------- 1 | use crate::numbers::matrix::Matrix; 2 | use crate::numbers::num_traits::algebra::SemiRing; 3 | use crate::numbers::num_traits::bit_ops::BitOps; 4 | use std::mem::swap; 5 | 6 | pub struct MatrixPowers { 7 | powers: Vec>, 8 | } 9 | 10 | impl MatrixPowers { 11 | pub fn new(mut base: Matrix, max_power_log: usize) -> Self { 12 | let mut powers = Vec::with_capacity(max_power_log); 13 | for _ in 0..max_power_log { 14 | powers.push(base.clone()); 15 | base = base.mult(&base); 16 | } 17 | Self { powers } 18 | } 19 | 20 | pub fn calculate(&self, mut matrix: Matrix, power: usize) -> Matrix { 21 | let mut temp = Matrix::zero(matrix.d1(), matrix.d2()); 22 | for i in 0..self.powers.len() { 23 | if power.is_set(i) { 24 | Matrix::do_mult(&mut temp, &matrix, &self.powers[i]); 25 | swap(&mut matrix, &mut temp); 26 | } 27 | } 28 | matrix 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /archive/2021/12/Advent of Code/day07a.rs: -------------------------------------------------------------------------------- 1 | use algo_lib::collections::iter_ext::IterExt; 2 | use algo_lib::io::input::{Input, Readable}; 3 | 4 | pub trait CommaList { 5 | fn read_list(&mut self) -> Vec; 6 | } 7 | 8 | impl CommaList for Input<'_> { 9 | fn read_list(&mut self) -> Vec { 10 | let mut s: String = self.read(); 11 | s = s.replace(",", " "); 12 | let mut b = s.as_bytes(); 13 | let mut input = Input::new(&mut b); 14 | input.into_iter().collect_vec() 15 | } 16 | } 17 | 18 | fn main() { 19 | let mut sin = std::io::stdin(); 20 | let mut inp = Input::new(&mut sin); 21 | 22 | let mut vals: Vec = inp.read_list(); 23 | // for _ in 0..80 { 24 | // vals.push(vals.len()); 25 | // } 26 | vals.sort(); 27 | let mut ans = 0; 28 | let n = vals.len(); 29 | for i in 0..n / 2 { 30 | ans += vals[n / 2] - vals[i]; 31 | } 32 | for i in n / 2..n { 33 | ans += vals[i] - vals[n / 2]; 34 | } 35 | println!("{}", vals.len()); 36 | } 37 | -------------------------------------------------------------------------------- /algo_lib/src/string/string_algorithms/string_search.rs: -------------------------------------------------------------------------------- 1 | use crate::string::slicelike::chain; 2 | use crate::string::string_algorithms::z_algorithm::ZAlgorithm; 3 | 4 | pub trait StringSearch { 5 | fn index_of(&self, pattern: &Self) -> Option; 6 | fn str_contains(&self, pattern: &Self) -> bool { 7 | self.index_of(pattern).is_some() 8 | } 9 | fn all_matches(&self, pattern: &Self) -> Vec; 10 | } 11 | 12 | impl StringSearch for [T] { 13 | fn index_of(&self, pattern: &Self) -> Option { 14 | chain(pattern, self) 15 | .z_algorithm() 16 | .into_iter() 17 | .skip(pattern.len()) 18 | .position(|x| x >= pattern.len()) 19 | } 20 | 21 | fn all_matches(&self, pattern: &Self) -> Vec { 22 | chain(pattern, self) 23 | .z_algorithm() 24 | .into_iter() 25 | .skip(pattern.len()) 26 | .enumerate() 27 | .filter(|&(_, x)| x >= pattern.len()) 28 | .map(|(i, _)| i) 29 | .collect() 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /archive/2022/6/20.6.2022 - AtCoder Beginner Contest #256/a2_n.rs: -------------------------------------------------------------------------------- 1 | //{"name":"A - 2^N","group":"AtCoder - Tokio Marine & Nichido Fire Insurance Programming Contest 2022(AtCoder Beginner Contest 256)","url":"https://atcoder.jp/contests/abc256/tasks/abc256_a","interactive":false,"timeLimit":2000,"tests":[{"input":"3\n","output":"8\n"},{"input":"30\n","output":"1073741824\n"}],"testType":"single","input":{"type":"stdin","fileName":null,"pattern":null},"output":{"type":"stdout","fileName":null,"pattern":null},"languages":{"java":{"taskClass":"A2N"}}} 2 | 3 | use algo_lib::io::input::Input; 4 | use algo_lib::io::output::output; 5 | use algo_lib::numbers::number_ext::Power; 6 | use algo_lib::out_line; 7 | 8 | fn solve(input: &mut Input) { 9 | let n = input.read_usize(); 10 | 11 | out_line!(2i32.power(n)); 12 | } 13 | 14 | pub(crate) fn run(mut input: Input) -> bool { 15 | solve(&mut input); 16 | output().flush(); 17 | input.skip_whitespace(); 18 | !input.peek().is_some() 19 | } 20 | 21 | //START MAIN 22 | mod tester; 23 | 24 | fn main() { 25 | tester::run_tests(); 26 | } 27 | //END MAIN 28 | -------------------------------------------------------------------------------- /algo_lib/src/numbers/gcd.rs: -------------------------------------------------------------------------------- 1 | use crate::numbers::num_traits::algebra::{ 2 | IntegerMultiplicationMonoid, IntegerSemiRingWithSub, Zero, 3 | }; 4 | use std::mem::swap; 5 | 6 | pub fn extended_gcd(a: T, b: T) -> (T, T, T) { 7 | if a == T::zero() { 8 | (b, T::zero(), T::one()) 9 | } else { 10 | let (d, y, mut x) = extended_gcd(b % a, a); 11 | x -= b / a * y; 12 | (d, x, y) 13 | } 14 | } 15 | 16 | pub fn gcd(mut a: T, mut b: T) -> T { 17 | while b != T::zero() { 18 | a %= b; 19 | swap(&mut a, &mut b); 20 | } 21 | a 22 | } 23 | 24 | pub fn lcm(a: T, b: T) -> T { 25 | (a / gcd(a, b)) * b 26 | } 27 | 28 | pub fn remainder(a1: T, n1: T, a2: T, n2: T) -> Option { 29 | let (d, m1, m2) = extended_gcd(n1, n2); 30 | if (a2 - a1) % d != T::zero() { 31 | return None; 32 | } 33 | let m = lcm(n1, n2); 34 | Some(((a1 * m2) % n1 * n2 + (a2 * m1) % n2 * n1) % m) 35 | } 36 | -------------------------------------------------------------------------------- /algo_lib/src/collections/slice_ext/compress.rs: -------------------------------------------------------------------------------- 1 | use crate::collections::slice_ext::bounds::Bounds; 2 | use std::mem::MaybeUninit; 3 | 4 | #[derive(Eq, PartialEq, Debug)] 5 | pub struct Compressed { 6 | pub order: Vec, 7 | pub arrs: [Vec; N], 8 | } 9 | 10 | pub fn compress(vs: [&[T]; N]) -> Compressed { 11 | let mut size = 0; 12 | for v in &vs { 13 | size += v.len(); 14 | } 15 | let mut all = Vec::with_capacity(size); 16 | for v in &vs { 17 | all.extend_from_slice(v); 18 | } 19 | all.sort(); 20 | all.dedup(); 21 | let arrs = unsafe { 22 | let mut arr: MaybeUninit<[Vec; N]> = MaybeUninit::uninit(); 23 | for (i, v) in vs.iter().enumerate() { 24 | let mut cur = Vec::with_capacity(vs[i].len()); 25 | for vv in *v { 26 | cur.push(all.bin_search(vv).unwrap()); 27 | } 28 | arr.as_mut_ptr().cast::>().add(i).write(cur); 29 | } 30 | arr.assume_init() 31 | }; 32 | Compressed { order: all, arrs } 33 | } 34 | -------------------------------------------------------------------------------- /archive/2021/12/11.12.2021 - Panasonic Programming Contest 2021(AtCoder Beginner Contest 231)/a_water_pressure.rs: -------------------------------------------------------------------------------- 1 | //{"name":"A - Water Pressure","group":"AtCoder - Panasonic Programming Contest 2021(AtCoder Beginner Contest 231)","url":"https://atcoder.jp/contests/abc231/tasks/abc231_a","interactive":false,"timeLimit":2000,"tests":[{"input":"1000\n","output":"10\n"},{"input":"50\n","output":"0.5\n"},{"input":"3141\n","output":"31.41\n"}],"testType":"single","input":{"type":"stdin","fileName":null,"pattern":null},"output":{"type":"stdout","fileName":null,"pattern":null},"languages":{"java":{"taskClass":"AWaterPressure"}}} 2 | 3 | use algo_lib::io::input::Input; 4 | use algo_lib::io::output::output; 5 | use algo_lib::{out, out_line}; 6 | 7 | fn solve(input: &mut Input) { 8 | let d: f64 = input.read(); 9 | out_line!(d / 100.); 10 | } 11 | 12 | pub(crate) fn run(mut input: Input) -> bool { 13 | solve(&mut input); 14 | output().flush(); 15 | input.skip_whitespace(); 16 | !input.peek().is_some() 17 | } 18 | 19 | //START MAIN 20 | mod tester; 21 | 22 | fn main() { 23 | tester::run_tests(); 24 | } 25 | //END MAIN 26 | -------------------------------------------------------------------------------- /algo_lib/src/numbers/num_traits/op_to_assign.rs: -------------------------------------------------------------------------------- 1 | #[macro_export] 2 | macro_rules! add_assign { 3 | ($t: ident, $u: ident) => { 4 | impl AddAssign<$u> for $t { 5 | fn add_assign(&mut self, rhs: $u) { 6 | *self = *self + rhs; 7 | } 8 | } 9 | }; 10 | } 11 | 12 | #[macro_export] 13 | macro_rules! mul_assign { 14 | ($t: ident, $u: ident) => { 15 | impl MulAssign<$u> for $t { 16 | fn mul_assign(&mut self, rhs: $u) { 17 | *self = *self * rhs; 18 | } 19 | } 20 | }; 21 | } 22 | 23 | #[macro_export] 24 | macro_rules! sub_assign { 25 | ($t: ident, $u: ident) => { 26 | impl SubAssign<$u> for $t { 27 | fn sub_assign(&mut self, rhs: $u) { 28 | *self = *self - rhs; 29 | } 30 | } 31 | }; 32 | } 33 | 34 | #[macro_export] 35 | macro_rules! div_assign { 36 | ($t: ident, $u: ident) => { 37 | impl DivAssign<$u> for $t { 38 | fn div_assign(&mut self, rhs: $u) { 39 | *self = *self / rhs; 40 | } 41 | } 42 | }; 43 | } 44 | -------------------------------------------------------------------------------- /algo_lib/src/misc/memo/memoization_vec.rs: -------------------------------------------------------------------------------- 1 | use crate::misc::recursive_function::Callable; 2 | 3 | pub struct Memoization1d 4 | where 5 | F: FnMut(&mut dyn Callable, usize) -> Output, 6 | { 7 | f: std::cell::UnsafeCell, 8 | res: Vec>, 9 | } 10 | 11 | impl Memoization1d 12 | where 13 | F: FnMut(&mut dyn Callable, usize) -> Output, 14 | { 15 | pub fn new(len: usize, f: F) -> Self { 16 | Self { 17 | f: std::cell::UnsafeCell::new(f), 18 | res: vec![None; len], 19 | } 20 | } 21 | } 22 | 23 | impl Callable for Memoization1d 24 | where 25 | F: FnMut(&mut dyn Callable, usize) -> Output, 26 | { 27 | fn call(&mut self, n: usize) -> Output { 28 | match self.res[n].as_ref() { 29 | None => { 30 | let res = unsafe { (*self.f.get())(self, n) }; 31 | self.res[n] = Some(res.clone()); 32 | res 33 | } 34 | Some(res) => res.clone(), 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /archive/2022/8/17.8.2022 - AtCoder Beginner Contest #264/a_atcodersubstr.rs: -------------------------------------------------------------------------------- 1 | //{"name":"A - \"atcoder\".substr()","group":"AtCoder - freee Programming Contest 2022(AtCoder Beginner Contest 264)","url":"https://atcoder.jp/contests/abc264/tasks/abc264_a","interactive":false,"timeLimit":2000,"tests":[{"input":"3 6\n","output":"code\n"},{"input":"4 4\n","output":"o\n"},{"input":"1 7\n","output":"atcoder\n"}],"testType":"single","input":{"type":"stdin","fileName":null,"pattern":null},"output":{"type":"stdout","fileName":null,"pattern":null},"languages":{"java":{"taskClass":"AAtcodersubstr"}}} 2 | 3 | use algo_lib::io::input::Input; 4 | use algo_lib::io::output::output; 5 | use algo_lib::out_line; 6 | 7 | fn solve(input: &mut Input) { 8 | let l = input.read_usize() - 1; 9 | let r = input.read_usize(); 10 | 11 | out_line!(&"atcoder"[l..r]); 12 | } 13 | 14 | pub(crate) fn run(mut input: Input) -> bool { 15 | solve(&mut input); 16 | output().flush(); 17 | input.skip_whitespace(); 18 | !input.peek().is_some() 19 | } 20 | 21 | //START MAIN 22 | mod tester; 23 | 24 | fn main() { 25 | tester::run_tests(); 26 | } 27 | //END MAIN 28 | -------------------------------------------------------------------------------- /archive/2021/12/25.12.2021 - AtCoder Beginner Contest 233/a10yen_stamp.rs: -------------------------------------------------------------------------------- 1 | //{"name":"A - 10yen Stamp","group":"AtCoder - AtCoder Beginner Contest 233","url":"https://atcoder.jp/contests/abc233/tasks/abc233_a","interactive":false,"timeLimit":2000,"tests":[{"input":"80 94\n","output":"2\n"},{"input":"1000 63\n","output":"0\n"},{"input":"270 750\n","output":"48\n"}],"testType":"single","input":{"type":"stdin","fileName":null,"pattern":null},"output":{"type":"stdout","fileName":null,"pattern":null},"languages":{"java":{"taskClass":"A10yenStamp"}}} 2 | 3 | use algo_lib::io::input::Input; 4 | use algo_lib::io::output::output; 5 | use algo_lib::out_line; 6 | 7 | fn solve(input: &mut Input) { 8 | let x: i32 = input.read(); 9 | let y: i32 = input.read(); 10 | 11 | if y > x { 12 | out_line!((y - x + 9) / 10); 13 | } else { 14 | out_line!(0); 15 | } 16 | } 17 | 18 | pub(crate) fn run(mut input: Input) -> bool { 19 | solve(&mut input); 20 | output().flush(); 21 | input.skip_whitespace(); 22 | !input.peek().is_some() 23 | } 24 | 25 | //START MAIN 26 | mod tester; 27 | 28 | fn main() { 29 | tester::run_tests(); 30 | } 31 | //END MAIN 32 | -------------------------------------------------------------------------------- /archive/2022/8/17.8.2022 - AtCoder Beginner Contest #261/a_intersection.rs: -------------------------------------------------------------------------------- 1 | //{"name":"A - Intersection","group":"AtCoder - AtCoder Beginner Contest 261","url":"https://atcoder.jp/contests/abc261/tasks/abc261_a","interactive":false,"timeLimit":2000,"tests":[{"input":"0 3 1 5\n","output":"2\n"},{"input":"0 1 4 5\n","output":"0\n"},{"input":"0 3 3 7\n","output":"0\n"}],"testType":"single","input":{"type":"stdin","fileName":null,"pattern":null},"output":{"type":"stdout","fileName":null,"pattern":null},"languages":{"java":{"taskClass":"AIntersection"}}} 2 | 3 | use algo_lib::io::input::Input; 4 | use algo_lib::io::output::output; 5 | use algo_lib::out_line; 6 | 7 | fn solve(input: &mut Input) { 8 | let l1 = input.read_int(); 9 | let r1 = input.read_int(); 10 | let l2 = input.read_int(); 11 | let r2 = input.read_int(); 12 | 13 | out_line!((r2.min(r1) - l2.max(l1)).max(0)); 14 | } 15 | 16 | pub(crate) fn run(mut input: Input) -> bool { 17 | solve(&mut input); 18 | output().flush(); 19 | input.skip_whitespace(); 20 | !input.peek().is_some() 21 | } 22 | 23 | //START MAIN 24 | mod tester; 25 | 26 | fn main() { 27 | tester::run_tests(); 28 | } 29 | //END MAIN 30 | -------------------------------------------------------------------------------- /archive/2021/12/19.12.2021 - M-SOLUTIONS Programming Contest 2021(AtCoder Beginner Contest 232)/a_qqsolver.rs: -------------------------------------------------------------------------------- 1 | //{"name":"A - QQ solver","group":"AtCoder - M-SOLUTIONS Programming Contest 2021(AtCoder Beginner Contest 232)","url":"https://atcoder.jp/contests/abc232/tasks/abc232_a","interactive":false,"timeLimit":2000,"tests":[{"input":"3x7\n","output":"21\n"},{"input":"9x9\n","output":"81\n"},{"input":"1x1\n","output":"1\n"}],"testType":"single","input":{"type":"stdin","fileName":null,"pattern":null},"output":{"type":"stdout","fileName":null,"pattern":null},"languages":{"java":{"taskClass":"AQQSolver"}}} 2 | 3 | use algo_lib::io::input::Input; 4 | use algo_lib::io::output::output; 5 | use algo_lib::{out, out_line}; 6 | 7 | fn solve(input: &mut Input) { 8 | let a = input.get().unwrap() - b'0'; 9 | input.get(); 10 | let b = input.get().unwrap() - b'0'; 11 | 12 | out_line!(a * b); 13 | } 14 | 15 | pub(crate) fn run(mut input: Input) -> bool { 16 | solve(&mut input); 17 | output().flush(); 18 | input.skip_whitespace(); 19 | !input.peek().is_some() 20 | } 21 | 22 | //START MAIN 23 | mod tester; 24 | 25 | fn main() { 26 | tester::run_tests(); 27 | } 28 | //END MAIN 29 | -------------------------------------------------------------------------------- /archive/2022/1/8.1.2022 - January Easy '22/non_empty_subsets.rs: -------------------------------------------------------------------------------- 1 | //{"name":"Non-empty subsets","group":"HackerEarth - January Easy '22","url":"https://www.hackerearth.com/challenges/competitive/january-easy-22/algorithm/minor-4-41918cb8/","interactive":false,"timeLimit":1000,"tests":[{"input":"2\n4\n1 3 5 7\n3\n2 6 14\n","output":"1\n2\n"}],"testType":"multiNumber","input":{"type":"stdin","fileName":null,"pattern":null},"output":{"type":"stdout","fileName":null,"pattern":null},"languages":{"java":{"taskClass":"NonEmptySubsets"}}} 2 | 3 | use algo_lib::io::input::Input; 4 | use algo_lib::io::output::output; 5 | use algo_lib::out_line; 6 | 7 | fn solve(input: &mut Input, _test_case: usize) { 8 | let n = input.read_usize(); 9 | let a = input.read_unsigned_vec(n); 10 | 11 | out_line!(a.into_iter().min()); 12 | } 13 | 14 | pub(crate) fn run(mut input: Input) -> bool { 15 | let t = input.read(); 16 | for i in 0usize..t { 17 | solve(&mut input, i + 1); 18 | } 19 | output().flush(); 20 | input.skip_whitespace(); 21 | !input.peek().is_some() 22 | } 23 | 24 | //START MAIN 25 | mod tester; 26 | 27 | fn main() { 28 | tester::run_tests(); 29 | } 30 | //END MAIN 31 | --------------------------------------------------------------------------------