Educational Codeforces Round 187 (Rated for Div. 2)

Solutions are presented as using the least memory and the fastest execution time. It also takes the top 10 most recent solutions from each language. If you want to limit to a specific index, click the "Solved" button and go to that problem.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
2203 Educational Codeforces Round 187 (Rated for Div. 2) FINISHED False 7200 4375523 Feb. 25, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 6736 ) C Test Generator PROGRAMMING binary search bitmasks greedy math

You are developing a test generator. It takes two integers (s) and (m) as input. You need to construct an array of non-negative integers (a = a_{1}, a_{2}, \dots, a_{n}) such that: (\displaystyle\sum_{i=1}^{n} a_i = s); for each (i), the condition (a_i \,\&\, m = a_i) holds, where (\&) denotes the bitwise AND operator. In other words, in each number (a_i), the bits that are set to one can only be in the positions where the bits in the number (m) are also set to one. Determine whether there exists at least one such array. If it exists, find the minimum possible length (n). Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^4)). The description of the test cases follows. Each test case consists of a single line containing two integers (s) and (m) ((1 \le s, m \le 10^{18})) — parameters of the generator. For each test case, print one integer: if such an array does not exist, print (-1); otherwise, print the minimum possible value of (n) — the length of the array. Let's analyze some examples: For (s = 13, m = 5), the answer is (3), as there is a suitable array (a = 5, 4, 4); For (s = 13, m = 3), the answer is (5), as there is a suitable array (a = 3, 3, 3, 3, 1); For (s = 13, m = 6), the answer is (-1), as there is no suitable array.

Tutorials

Educational Codeforces Round 187 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
364380039 sto_LingLing_orz C Feb. 25, 2026, 4:51 p.m. OK C++17 (GCC 7-32) TESTS 8 31 0
364376112 yigit11 C Feb. 25, 2026, 4:32 p.m. OK C++17 (GCC 7-32) TESTS 8 31 0
364375324 cherish-to C Feb. 25, 2026, 4:31 p.m. OK C++17 (GCC 7-32) TESTS 8 31 0
364374403 pandaa73 C Feb. 25, 2026, 4:28 p.m. OK C++17 (GCC 7-32) TESTS 8 31 0
364369280 crazxy2307 C Feb. 25, 2026, 4:16 p.m. OK C++17 (GCC 7-32) TESTS 8 31 0
364428116 I_am_BackTrack C Feb. 26, 2026, 4:37 a.m. OK C++17 (GCC 7-32) TESTS 8 46 0
364395917 Nicolo_010 C Feb. 25, 2026, 7:16 p.m. OK C++17 (GCC 7-32) TESTS 8 46 0
364395537 Aykhan_Kh C Feb. 25, 2026, 7:11 p.m. OK C++17 (GCC 7-32) TESTS 8 46 0
364391235 NotLosingHope C Feb. 25, 2026, 6:25 p.m. OK C++17 (GCC 7-32) TESTS 8 46 0
364389619 ItsProfessor C Feb. 25, 2026, 6:09 p.m. OK C++17 (GCC 7-32) TESTS 8 46 0
364389562 Aerysaint C Feb. 25, 2026, 6:09 p.m. OK C++20 (GCC 13-64) TESTS 8 31 0
364379790 gevak C Feb. 25, 2026, 4:50 p.m. OK C++20 (GCC 13-64) TESTS 8 31 0
364378275 zhanzhijiea C Feb. 25, 2026, 4:40 p.m. OK C++20 (GCC 13-64) TESTS 8 31 0
364374106 ParXsy C Feb. 25, 2026, 4:28 p.m. OK C++20 (GCC 13-64) TESTS 8 31 0
364374069 rishith2508 C Feb. 25, 2026, 4:28 p.m. OK C++20 (GCC 13-64) TESTS 8 31 0
364369892 OMI_14 C Feb. 25, 2026, 4:17 p.m. OK C++20 (GCC 13-64) TESTS 8 31 0
364428627 Sashisu09 C Feb. 26, 2026, 4:44 a.m. OK C++20 (GCC 13-64) TESTS 8 31 102400
364432874 Sanae C Feb. 26, 2026, 5:40 a.m. OK C++20 (GCC 13-64) TESTS 8 46 0
364410274 LanceTheDragonTrainer C Feb. 25, 2026, 11:18 p.m. OK C++20 (GCC 13-64) TESTS 8 46 0
364404257 yogeshv1112 C Feb. 25, 2026, 9:12 p.m. OK C++20 (GCC 13-64) TESTS 8 46 0
364432161 hhhhs C Feb. 26, 2026, 5:31 a.m. OK C++23 (GCC 14-64, msys2) TESTS 8 31 0
364429186 crazyx13 C Feb. 26, 2026, 4:52 a.m. OK C++23 (GCC 14-64, msys2) TESTS 8 31 0
364408980 the_unknownone C Feb. 25, 2026, 10:42 p.m. OK C++23 (GCC 14-64, msys2) TESTS 8 31 0
364408958 mahtabansari911 C Feb. 25, 2026, 10:41 p.m. OK C++23 (GCC 14-64, msys2) TESTS 8 31 0
364408167 espacio C Feb. 25, 2026, 10:20 p.m. OK C++23 (GCC 14-64, msys2) TESTS 8 31 0
364403179 Knightmare_ C Feb. 25, 2026, 8:55 p.m. OK C++23 (GCC 14-64, msys2) TESTS 8 31 0
364391328 user23_97 C Feb. 25, 2026, 6:25 p.m. OK C++23 (GCC 14-64, msys2) TESTS 8 31 0
364385515 darkahmed C Feb. 25, 2026, 5:33 p.m. OK C++23 (GCC 14-64, msys2) TESTS 8 31 0
364381124 kinglacto C Feb. 25, 2026, 4:58 p.m. OK C++23 (GCC 14-64, msys2) TESTS 8 31 0
364374537 Rachit11 C Feb. 25, 2026, 4:29 p.m. OK C++23 (GCC 14-64, msys2) TESTS 8 31 0
364373433 Varunkumar-01 C Feb. 25, 2026, 4:26 p.m. OK Java 21 TESTS 8 203 1843200
364372242 AndreyQ C Feb. 25, 2026, 4:23 p.m. OK Java 21 TESTS 8 250 512000
364372187 vigneshgopal200 C Feb. 25, 2026, 4:23 p.m. OK Java 21 TESTS 8 265 409600
364375142 dhiswan1 C Feb. 25, 2026, 4:30 p.m. OK Java 21 TESTS 8 281 1126400
364367627 yashC03 C Feb. 25, 2026, 4:12 p.m. OK Java 21 TESTS 8 296 307200
364394306 n4418779 C Feb. 25, 2026, 6:58 p.m. OK Java 21 TESTS 8 296 1843200
364409624 Yousef_Badr C Feb. 25, 2026, 11 p.m. OK Java 21 TESTS 8 312 512000
364409796 Yousef_Badr C Feb. 25, 2026, 11:05 p.m. OK Java 21 TESTS 8 343 819200
364374271 ironman263 C Feb. 25, 2026, 4:28 p.m. OK Java 21 TESTS 8 343 921600
364429234 the_hadamard_gate C Feb. 26, 2026, 4:52 a.m. OK Java 21 TESTS 8 343 1024000
364430816 from_zero_cp C Feb. 26, 2026, 5:13 a.m. OK Java 8 TESTS 8 125 0
364429059 am_I_Newbie C Feb. 26, 2026, 4:50 a.m. OK Java 8 TESTS 8 296 0
364369888 kamranm C Feb. 25, 2026, 4:17 p.m. OK Java 8 TESTS 8 328 108748800
364375737 ppwani C Feb. 25, 2026, 4:32 p.m. OK Java 8 TESTS 8 375 0
364383587 kevin_0911 C Feb. 25, 2026, 5:16 p.m. OK Java 8 TESTS 8 593 0
364394542 TheJavaGuy C Feb. 25, 2026, 7:01 p.m. OK Java 8 TESTS 8 1125 0
364374488 ktobarsuk C Feb. 25, 2026, 4:29 p.m. OK Kotlin 1.9 TESTS 8 609 102400
364370323 sajjanikhil123 C Feb. 25, 2026, 4:19 p.m. OK Kotlin 1.9 TESTS 8 625 0
364369402 prvshkmrin C Feb. 25, 2026, 4:16 p.m. OK Kotlin 2.2 TESTS 8 265 102400
364378336 jagbarrameda C Feb. 25, 2026, 4:41 p.m. OK Kotlin 2.2 TESTS 8 609 25190400
364370006 DoryperPevin C Feb. 25, 2026, 4:18 p.m. OK PyPy 3 TESTS 8 500 9113600
364373056 Kandarp C Feb. 25, 2026, 4:25 p.m. OK PyPy 3 TESTS 8 1265 7372800
364384573 akane646 C Feb. 25, 2026, 5:25 p.m. OK PyPy 3-64 TESTS 8 78 3276800
364404465 OAY71011 C Feb. 25, 2026, 9:15 p.m. OK PyPy 3-64 TESTS 8 78 4096000
364370696 Zeoy C Feb. 25, 2026, 4:20 p.m. OK PyPy 3-64 TESTS 8 78 4812800
364404612 OAY71011 C Feb. 25, 2026, 9:17 p.m. OK PyPy 3-64 TESTS 8 93 4096000
364417609 Otabek_Aynazarov C Feb. 26, 2026, 2:09 a.m. OK PyPy 3-64 TESTS 8 140 4710400
364373697 ringwayy C Feb. 25, 2026, 4:27 p.m. OK PyPy 3-64 TESTS 8 156 4505600
364381220 longjourney C Feb. 25, 2026, 4:59 p.m. OK PyPy 3-64 TESTS 8 156 4915200
364372084 grecil C Feb. 25, 2026, 4:23 p.m. OK PyPy 3-64 TESTS 8 156 5120000
364412201 -nameless- C Feb. 26, 2026, 12:08 a.m. OK PyPy 3-64 TESTS 8 156 7065600
364373947 lopduhun C Feb. 25, 2026, 4:27 p.m. OK PyPy 3-64 TESTS 8 171 4915200
364371946 CopyNinja6 C Feb. 25, 2026, 4:23 p.m. OK Python 3 TESTS 8 312 1843200
364368328 Monish2000 C Feb. 25, 2026, 4:13 p.m. OK Python 3 TESTS 8 390 0
364385187 kutkrr C Feb. 25, 2026, 5:30 p.m. OK Python 3 TESTS 8 421 102400
364411714 Kiwiman C Feb. 25, 2026, 11:54 p.m. OK Python 3 TESTS 8 437 307200
364369462 coderbd C Feb. 25, 2026, 4:16 p.m. OK Python 3 TESTS 8 984 102400
364403626 ababsadfff C Feb. 25, 2026, 9:01 p.m. OK Python 3 TESTS 8 1734 409600
364367538 vanshit C Feb. 25, 2026, 4:11 p.m. OK Rust 2024 TESTS 8 265 0
364392135 Tantellam C Feb. 25, 2026, 6:33 p.m. OK Rust 2024 TESTS 8 500 11673600

remove filters

Back to search problems