Search is not available for this dataset
problem_id
stringlengths 32
32
| name
stringlengths 2
112
| problem
stringlengths 200
14k
| test_cases
stringlengths 33
79.2M
| difficulty
stringclasses 33
values | language
sequencelengths 1
1
| source
stringclasses 14
values | num_solutions
int64 2
1.9M
| starter_code
stringlengths 0
1.47k
| subset
stringclasses 3
values |
---|---|---|---|---|---|---|---|---|---|
50791db071f3edbf0b1751f2239c954b | Coin Troubles | In the Isle of Guernsey there are *n* different types of coins. For each *i* (1<=β€<=*i*<=β€<=*n*), coin of type *i* is worth *a**i* cents. It is possible that *a**i*<==<=*a**j* for some *i* and *j* (*i*<=β <=*j*).
Bessie has some set of these coins totaling *t* cents. She tells Jessie *q* pairs of integers. For each *i* (1<=β€<=*i*<=β€<=*q*), the pair *b**i*,<=*c**i* tells Jessie that Bessie has a strictly greater number of coins of type *b**i* than coins of type *c**i*. It is known that all *b**i* are distinct and all *c**i* are distinct.
Help Jessie find the number of possible combinations of coins Bessie could have. Two combinations are considered different if there is some *i* (1<=β€<=*i*<=β€<=*n*), such that the number of coins Bessie has of type *i* is different in the two combinations. Since the answer can be very large, output it modulo 1000000007 (109<=+<=7).
If there are no possible combinations of coins totaling *t* cents that satisfy Bessie's conditions, output 0.
The first line contains three space-separated integers, *n*,<=*q* and *t* (1<=β€<=*n*<=β€<=300;Β 0<=β€<=*q*<=β€<=*n*;Β 1<=β€<=*t*<=β€<=105). The second line contains *n* space separated integers, *a*1,<=*a*2,<=...,<=*a**n* (1<=β€<=*a**i*<=β€<=105). The next *q* lines each contain two distinct space-separated integers, *b**i* and *c**i* (1<=β€<=*b**i*,<=*c**i*<=β€<=*n*;Β *b**i*<=β <=*c**i*).
It's guaranteed that all *b**i* are distinct and all *c**i* are distinct.
A single integer, the number of valid coin combinations that Bessie could have, modulo 1000000007 (109<=+<=7).
Sample Input
4 2 17
3 1 2 5
4 2
3 4
3 2 6
3 1 1
1 2
2 3
3 2 10
1 2 3
1 2
2 1
Sample Output
3
0
0
| {"inputs": ["4 2 17\n3 1 2 5\n4 2\n3 4", "3 2 6\n3 1 1\n1 2\n2 3", "3 2 10\n1 2 3\n1 2\n2 1", "10 0 97\n7 2 10 5 10 5 8 9 6 2", "10 2 11\n4 9 3 1 4 10 2 6 10 8\n3 6\n6 4", "10 4 18\n9 2 8 2 7 4 9 5 10 9\n7 9\n9 2\n2 5\n5 10", "10 0 96374\n9 4 9 8 4 1 10 1 6 6", "10 5 857\n3 9 8 10 10 5 3 3 8 1\n6 9\n9 2\n2 7\n4 3\n8 10", "10 5 78\n6 5 9 10 3 7 10 10 5 7\n2 10\n10 6\n6 8\n8 5\n5 1", "30 25 100000\n75 56 61 47 71 52 59 75 30 12 43 29 2 3 37 58 32 47 36 49 51 16 3 25 22 61 63 20 18 8\n15 17\n17 28\n28 18\n18 16\n16 12\n8 9\n9 19\n19 13\n13 7\n7 29\n24 5\n5 6\n6 20\n20 4\n4 26\n26 2\n2 30\n30 1\n1 22\n22 25\n25 27\n27 23\n23 10\n10 11\n11 21", "50 20 63791\n63 66 35 40 94 85 40 41 56 76 96 78 3 57 65 27 46 49 53 79 39 77 61 64 47 27 11 41 98 96 98 67 74 9 22 87 22 68 94 43 13 53 24 30 2 72 1 26 18 3\n35 34\n9 4\n4 27\n6 36\n23 7\n37 3\n3 12\n21 39\n39 22\n22 47\n47 14\n14 29\n24 30\n30 18\n18 20\n43 8\n49 13\n33 16\n16 38\n38 42", "70 50 34755\n5 2 5 3 2 1 4 2 5 2 2 4 1 2 1 1 1 3 5 2 1 1 3 5 4 2 4 5 4 2 5 3 2 1 3 2 4 3 2 5 5 3 4 1 2 4 3 4 1 4 4 3 2 3 1 1 5 1 3 5 5 5 4 4 4 3 3 3 5 1\n68 39\n39 60\n60 6\n19 41\n41 24\n24 45\n2 57\n15 29\n29 34\n34 56\n56 51\n51 43\n43 46\n46 21\n23 12\n12 66\n66 3\n3 54\n54 17\n17 28\n28 70\n70 4\n4 33\n26 48\n48 9\n1 49\n49 67\n67 11\n11 55\n55 38\n38 30\n30 20\n20 18\n18 40\n40 13\n13 10\n10 61\n61 36\n27 65\n65 59\n59 58\n32 22\n22 53\n53 50\n50 63\n63 35\n7 69\n31 14\n14 8\n8 37", "50 46 74793\n1 1 1 2 2 2 2 2 2 2 1 2 2 2 2 2 1 1 2 1 2 1 2 1 1 1 1 1 1 2 1 1 2 2 2 1 1 2 1 1 2 1 2 1 2 2 1 2 1 2\n47 14\n14 19\n19 22\n22 2\n2 8\n50 10\n10 42\n42 23\n23 34\n34 49\n46 28\n28 32\n32 33\n33 7\n7 43\n43 18\n18 13\n13 41\n41 27\n27 20\n20 12\n12 35\n35 39\n39 1\n1 9\n9 5\n5 21\n21 31\n31 24\n24 6\n6 48\n38 15\n15 4\n4 45\n45 25\n25 26\n26 17\n17 36\n36 11\n11 16\n16 37\n37 44\n44 29\n29 3\n3 30\n30 40", "10 9 20\n1 6 3 6 8 5 5 4 5 7\n1 6\n6 9\n9 3\n3 10\n10 7\n7 1\n4 8\n8 5\n5 4", "50 48 40000\n63 28 99 26 67 25 3 64 13 95 4 99 76 70 87 74 95 62 29 72 55 19 70 53 87 46 98 47 46 17 92 23 60 67 82 5 60 5 70 47 90 78 51 98 98 67 8 62 11 23\n27 5\n5 24\n24 47\n47 48\n48 31\n31 28\n28 46\n46 49\n49 15\n15 12\n12 35\n35 22\n22 45\n45 34\n34 39\n39 7\n7 13\n13 41\n41 40\n40 23\n23 18\n18 29\n29 50\n50 33\n33 42\n42 3\n3 26\n26 38\n38 44\n44 36\n36 30\n4 20\n20 17\n17 16\n16 10\n10 32\n32 25\n25 9\n9 6\n6 21\n21 2\n2 14\n14 19\n19 8\n8 1\n1 37\n37 11\n11 43", "50 47 100000\n7 5 24 30 17 22 29 19 13 26 3 8 30 8 28 9 1 1 6 19 15 1 7 1 26 13 23 25 9 10 3 8 18 10 5 25 4 21 26 24 14 30 22 7 18 27 24 14 1 24\n41 3\n3 50\n50 22\n22 48\n48 11\n11 20\n20 26\n26 19\n19 37\n37 27\n27 39\n39 38\n38 28\n28 15\n15 44\n44 29\n29 49\n49 25\n25 10\n10 6\n6 14\n14 35\n35 18\n18 46\n46 34\n34 24\n24 32\n32 5\n45 8\n8 30\n30 33\n33 16\n16 40\n40 12\n12 36\n36 2\n2 4\n4 42\n42 47\n47 7\n7 43\n43 21\n21 31\n31 13\n13 17\n23 9\n9 1", "50 10 71619\n9251 4973 9076 8848 9107 2558 2275 7571 5109 7491 1830 8047 1253 4354 2819 843 8258 309 7712 3697 333 4133 9159 7038 8903 7841 5620 9776 4262 3336 3413 982 2240 2666 3977 8531 5693 7770 7041 1851 56 2286 4946 7012 7743 861 2545 9526 702 591\n43 7\n38 45\n10 3\n3 41\n41 22\n22 35\n35 15\n15 20\n20 13\n13 1", "50 49 100000\n4 30 4 36 35 20 47 49 3 32 41 10 28 48 49 28 22 2 41 5 30 31 37 4 49 43 50 10 15 32 44 6 18 50 35 28 18 5 7 49 12 29 26 33 4 38 36 24 44 22\n16 19\n19 17\n17 35\n35 46\n46 4\n4 21\n21 44\n44 40\n40 43\n43 42\n42 37\n37 18\n18 6\n6 32\n32 41\n41 14\n14 50\n50 45\n45 29\n29 39\n39 31\n31 13\n13 9\n9 30\n30 12\n12 10\n10 20\n20 2\n2 8\n8 24\n24 27\n27 5\n5 15\n15 7\n7 1\n1 3\n3 26\n26 25\n25 23\n23 48\n48 36\n36 49\n49 33\n33 28\n28 38\n38 47\n47 11\n11 22\n22 34", "50 30 53347\n3252 5324 6506 402 3117 2734 470 1071 1023 5163 5382 1705 6580 7739 5124 9916 5938 9186 4562 9088 9082 5291 349 6807 9253 7645 2364 5707 7479 424 3584 5922 6126 8326 659 9515 6802 7372 939 1088 7732 5768 6965 3508 9760 6930 2044 2948 3677 5917\n50 43\n21 6\n4 24\n8 45\n20 41\n41 39\n39 3\n3 36\n36 37\n37 48\n48 33\n33 11\n11 44\n32 25\n25 2\n2 42\n42 7\n7 16\n16 31\n31 14\n14 49\n49 12\n12 46\n46 13\n13 47\n47 5\n5 15\n15 23\n23 35\n35 40", "50 31 52896\n904 2140 4069 1417 138 1915 3856 252 60 413 2872 2395 753 833 4875 4646 1088 502 432 1367 1201 2874 4696 3577 3272 2544 911 4228 3921 1624 859 4062 57 3386 4540 4002 4123 1330 3690 2541 2504 2541 3370 1931 1061 4546 4649 4286 4793 4218\n31 32\n32 49\n49 15\n26 1\n11 48\n44 19\n19 16\n16 24\n33 6\n6 5\n5 38\n38 21\n23 13\n13 50\n50 36\n36 28\n17 39\n14 37\n37 34\n2 42\n7 30\n30 43\n43 40\n40 47\n47 20\n20 3\n41 8\n8 22\n22 46\n46 27\n29 18", "50 0 97423\n807 8376 3868 6622 2094 1422 1424 6555 8441 789 2763 9375 6605 3659 7592 3493 5387 1609 4795 17 9866 6511 3266 6436 2158 9355 1846 5956 4198 1248 2217 8086 9591 5841 3768 1142 9236 1525 9321 5147 1703 3521 7947 2214 3110 6804 9034 3233 3024 900", "50 0 92199\n7437 3796 6996 16720 6903 11061 7623 2072 4645 8613 3446 18466 18584 7824 9332 19439 10793 673 16520 15655 2047 5639 19181 13743 15732 11668 14380 12371 7315 9368 15523 8061 19484 16106 1409 18875 11711 13535 11462 16892 3068 1904 8647 6323 14025 17848 2121 7218 12971 8659", "50 0 80851\n2677 3535 2535 3273 2782 1614 4729 3131 1577 2702 1711 1453 4783 4940 624 873 2801 230 1498 4530 92 1116 1662 141 1869 4832 4127 721 2884 1544 1337 193 2698 4745 4084 2462 4108 4939 4671 4695 3791 2577 3959 914 588 3567 4871 1946 1507 4316", "50 10 67762\n387 938 646 600 703 181 159 382 802 874 147 227 201 301 119 35 546 33 923 691 780 29 727 916 938 913 71 350 136 593 247 253 692 304 312 56 373 678 264 532 775 138 21 980 581 296 355 292 733 180\n44 42\n20 22\n38 34\n34 2\n39 4\n4 30\n28 31\n41 7\n7 45\n45 43", "10 3 74157\n45942 42089 40710 33249 7260 3064 27937 2605 40339 20319\n3 8\n4 7\n6 9", "10 4 94133\n90 51 89 78 36 92 96 60 94 13\n8 7\n7 9\n9 2\n10 4", "5 1 94696\n43240 46244 30822 15658 36578\n3 5", "5 3 94384\n47463 49802 36765 6547 34115\n4 2\n3 5\n5 1", "4 2 64391\n21936 49650 27547 43105\n3 2\n2 4", "150 10 69\n2 2 1 2 2 1 2 1 1 1 1 1 2 2 2 1 2 1 2 2 1 2 2 2 2 2 2 2 1 2 2 1 2 2 1 1 2 1 2 1 2 1 2 1 2 2 1 1 1 2 2 2 1 2 1 1 1 1 1 1 2 2 1 2 1 1 2 2 1 1 1 2 1 2 1 1 1 1 2 1 2 2 1 1 1 1 2 1 1 2 1 2 2 1 2 2 2 1 1 2 1 2 2 1 2 1 2 1 2 2 1 2 1 1 1 1 2 2 2 2 1 1 2 1 2 2 2 2 1 2 1 2 1 1 2 1 2 1 1 2 2 1 1 2 2 1 1 1 1 2\n147 9\n42 108\n143 131\n52 112\n86 79\n92 4\n29 72\n26 80\n80 40\n63 32", "150 10 44\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n100 43\n63 24\n149 78\n78 139\n136 143\n67 16\n73 32\n20 59\n12 61\n57 116", "150 10 190\n1 2 1 2 2 2 1 1 1 1 2 1 1 2 2 2 2 1 1 1 1 2 1 2 2 2 1 2 1 2 1 1 1 1 1 1 1 2 2 1 1 2 1 2 2 2 1 1 1 1 2 1 1 1 2 1 2 2 1 2 2 2 2 1 2 1 2 2 2 2 1 1 2 1 2 1 2 1 2 2 2 1 2 2 1 1 1 1 1 2 2 1 2 1 1 2 2 2 2 1 1 2 2 1 2 2 1 2 2 2 2 1 1 2 2 2 1 1 2 1 1 2 1 1 1 1 1 2 2 2 2 1 2 1 1 2 1 2 2 1 1 2 1 2 2 1 2 1 1 1\n7 55\n35 41\n150 76\n76 34\n45 110\n62 1\n97 20\n20 79\n145 133\n133 14", "150 2 16\n2 3 2 2 2 2 2 2 1 1 2 3 1 2 2 3 2 3 1 2 1 1 1 1 2 3 3 1 2 3 3 3 3 2 2 3 3 1 1 2 3 3 1 3 2 1 1 2 2 2 3 1 2 1 3 3 1 2 1 1 2 1 3 2 1 3 2 2 1 2 1 1 2 2 3 3 2 2 3 2 1 1 2 2 1 3 1 1 1 2 2 3 1 3 3 3 3 2 3 3 3 2 1 3 2 1 3 2 1 3 2 3 3 2 2 1 3 2 2 2 1 2 1 3 1 1 3 3 1 1 1 3 3 3 2 3 1 2 1 3 2 3 3 2 1 2 2 2 2 3\n2 131\n131 43", "150 3 25\n1 3 3 3 3 2 1 3 2 1 1 3 1 3 1 1 2 2 2 2 1 1 3 3 3 1 2 3 2 1 3 2 3 3 3 1 3 3 2 2 3 3 2 3 3 3 2 3 2 3 3 2 2 1 2 1 2 2 2 3 1 1 2 3 3 1 3 2 1 1 1 2 3 2 3 3 3 1 2 3 3 3 2 1 2 2 1 2 3 1 3 2 3 2 1 2 1 2 1 2 3 3 2 1 2 1 1 2 2 2 1 3 3 1 3 1 1 3 2 1 1 3 2 3 3 3 1 1 2 1 3 2 2 2 2 3 2 1 3 3 1 3 2 3 3 1 3 3 3 1\n133 100\n100 7\n82 105", "150 4 15\n2 3 3 1 1 3 1 2 3 1 2 2 3 3 2 2 3 3 1 1 3 3 1 2 1 1 2 2 3 3 1 2 1 1 2 3 2 1 1 3 1 1 1 3 3 2 2 1 1 3 1 3 2 2 3 3 1 2 3 2 1 1 2 2 2 2 2 1 1 2 1 2 2 1 3 1 2 3 1 2 3 1 2 1 3 2 2 3 1 1 1 1 2 3 1 1 1 1 3 2 2 2 3 2 1 2 2 2 1 1 3 2 2 3 2 2 2 3 3 1 2 1 2 3 3 3 3 3 1 1 2 3 1 1 1 3 1 1 3 1 3 1 2 3 1 3 1 2 1 2\n97 80\n101 138\n105 14\n14 131", "200 4 32\n1 1 2 3 1 1 3 1 2 1 3 2 1 1 1 1 2 1 3 1 1 2 2 1 3 2 2 1 1 3 1 1 1 3 1 3 1 2 1 3 1 1 1 1 1 2 3 1 1 1 1 1 3 1 1 3 2 3 2 2 1 3 1 1 3 2 1 3 3 1 1 2 3 2 3 1 2 2 1 1 1 3 3 3 1 1 1 1 2 3 1 1 3 1 3 3 3 1 1 3 2 3 1 1 2 3 1 1 1 2 3 2 2 3 2 3 1 3 2 3 3 3 1 2 3 3 2 3 2 2 3 3 1 1 3 1 2 2 1 1 3 3 1 2 2 2 1 2 3 2 1 3 3 3 1 2 1 3 1 1 2 2 2 3 2 3 1 2 1 3 2 2 3 1 2 3 2 2 2 1 2 1 2 2 1 1 2 1 2 1 3 3 1 3 3 3 2 2 2 1\n41 92\n32 39\n39 191\n133 47", "200 5 37\n1 3 3 1 2 2 3 3 2 2 2 2 2 1 2 2 2 2 2 3 1 2 3 1 1 2 2 3 3 2 2 2 2 3 3 2 1 2 2 2 2 2 3 2 2 2 2 1 3 3 2 2 2 3 1 2 2 1 1 2 1 3 1 3 3 2 3 2 3 1 2 3 2 1 2 3 2 1 1 3 3 2 2 2 2 2 3 2 3 1 2 2 3 2 1 3 3 3 2 1 2 2 1 1 1 3 2 2 2 1 1 1 3 1 3 2 3 3 2 3 1 2 1 2 3 2 3 2 1 1 1 2 1 1 3 3 3 2 1 3 1 3 2 3 3 1 2 1 2 3 2 2 3 1 3 2 1 2 2 1 3 3 3 1 1 2 2 1 1 3 2 2 3 3 1 1 1 1 2 3 2 2 1 3 3 1 1 2 1 1 2 1 1 3 2 1 1 2 1 1\n31 86\n86 6\n114 70\n70 170\n113 124", "200 5 31\n2 1 2 3 3 3 1 1 2 3 2 2 3 3 3 3 2 2 2 2 3 3 1 2 2 3 1 3 1 2 3 2 1 2 3 2 1 2 3 1 3 1 1 1 1 2 1 1 2 1 2 3 3 2 3 3 2 1 1 3 2 1 2 2 3 1 2 2 2 1 2 1 3 1 2 2 1 1 3 2 3 2 2 2 2 2 2 2 1 3 3 3 2 2 3 1 2 1 2 2 2 1 2 1 2 3 2 2 2 1 2 1 3 2 1 3 3 3 1 1 1 2 3 3 1 1 3 2 2 2 3 1 2 3 3 2 3 3 3 2 3 2 3 2 1 1 3 3 1 3 2 1 2 1 3 2 3 1 2 3 3 1 2 3 3 2 3 2 3 2 2 3 3 2 1 3 1 2 1 1 2 2 3 3 1 3 2 1 3 1 2 3 1 3 2 1 3 1 2 1\n168 181\n53 143\n143 17\n17 62\n157 192", "200 5 49\n8 6 4 7 7 6 10 6 10 10 2 1 8 5 1 10 9 6 6 7 1 3 7 4 2 3 10 8 8 9 10 2 8 8 4 3 9 10 3 9 2 4 6 9 2 6 6 6 4 10 9 5 6 5 10 4 8 7 2 8 2 10 9 3 6 4 9 1 9 7 6 7 9 2 1 7 4 4 7 8 7 7 7 10 1 10 1 1 2 10 1 10 7 7 10 7 2 2 2 2 6 8 5 6 6 10 5 9 7 1 4 2 1 7 4 2 5 10 2 5 5 4 5 2 8 2 3 10 3 10 8 7 2 9 8 5 5 2 9 8 7 7 1 4 4 8 5 1 8 1 9 4 3 1 1 1 9 4 8 10 9 9 7 7 1 10 5 5 2 8 3 2 9 10 4 1 4 9 4 3 10 9 4 4 1 9 7 8 2 7 7 4 2 9 6 5 5 7 10 5\n25 185\n185 34\n34 150\n18 107\n169 73", "3 2 10\n1 2 3\n1 2\n2 1", "5 5 100\n1 2 3 4 5\n1 2\n2 3\n3 1\n4 5\n5 4", "3 2 4\n1 1 1\n1 2\n2 1", "4 2 17\n3 1 2 5\n4 2\n2 4"], "outputs": ["3", "0", "0", "823423", "0", "0", "38660230", "396987358", "0", "219045999", "612038014", "955052", "775295641", "0", "53", "674759362", "0", "225562046", "0", "0", "89229105", "43914666", "637731835", "451068924", "0", "389321092", "0", "0", "0", "881565073", "760159310", "734591180", "905924923", "130409091", "734625463", "639007649", "863037024", "442696153", "831914771", "0", "0", "0", "0"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces |
|
508e636f3924d8df0d7fac38849e57da | none | Piegirl was asked to implement two table join operation for distributed database system, minimizing the network traffic.
Suppose she wants to join two tables, *A* and *B*. Each of them has certain number of rows which are distributed on different number of partitions. Table *A* is distributed on the first cluster consisting of *m* partitions. Partition with index *i* has *a**i* rows from *A*. Similarly, second cluster containing table *B* has *n* partitions, *i*-th one having *b**i* rows from *B*.
In one network operation she can copy one row from any partition to any other partition. At the end, for each row from *A* and each row from *B* there should be a partition that has both rows. Determine the minimal number of network operations to achieve this.
First line contains two integer numbers, *m* and *n* (1<=β€<=*m*,<=*n*<=β€<=105). Second line contains description of the first cluster with *m* space separated integers, *a**i* (1<=β€<=*a**i*<=β€<=109). Similarly, third line describes second cluster with *n* space separated integers, *b**i* (1<=β€<=*b**i*<=β€<=109).
Print one integer β minimal number of copy operations.
Sample Input
2 2
2 6
3 100
2 3
10 10
1 1 1
Sample Output
11
6
| {"inputs": ["2 2\n2 6\n3 100", "2 3\n10 10\n1 1 1", "2 2\n888381664 866366630\n170399907 404233949", "3 4\n337369924 278848730 654933675\n866361693 732544605 890800310 350303294", "10 10\n510955240 684852706 455356451 284505713 595775142 646334608 563116339 941123613 818750895 516673753\n382626402 204542396 341363992 234231105 75079663 683639780 624391764 265169060 686304227 280991725", "6 5\n45936257 8169878 14134346 26323055 65863745 50728147\n997339869 2970526 163305525 839524148 193404120", "5 4\n556840201 669601415 674042771 93322040 157280418\n253115131 933556803 294280580 169051325", "5 7\n473347111 640932948 320036306 595696211 365475226\n347859328 553364017 687935743 145411543 689180757 696504973 783694820", "8 8\n808147225 623333304 535665685 469385259 122918604 200681823 800211367 286974812\n85215517 983921829 274028967 567054904 144473212 964018990 177471567 73882806", "10 10\n326151338 981287141 830123412 482457331 77554645 351237238 663827505 549778905 967488359 954617100\n238752550 787656851 393452025 837732771 522417885 876998499 195063055 325140429 546151936 403260186", "10 10\n933168403 835157665 823216696 818565876 448948583 884328249 809244579 473034231 407137956 871269623\n653126539 145998557 644003076 138712151 839886312 479712343 709513279 138285801 858528549 643830064", "10 10\n269584761 865524829 265226347 963092340 261501474 16861445 221090297 746538035 842020225 649641719\n49728483 423679832 107851851 179960003 345895125 400584885 460489835 377856735 506736683 676996548", "10 10\n458278487 288667180 648471199 581765640 758405216 589361337 319325955 938498114 249892107 138299026\n57775135 470751607 454623764 556600014 141039336 225043834 692497485 517610562 635337211 56258907", "5 6\n7780674 1861750 4491902 10256124 14362475\n1809567 5616386 1771573 2099536 1113026 3938402", "6 5\n40192277 37957130 22509015 95257198 6210193 16850057\n76289330 265203569 184343840 163207736 126924648", "6 5\n4689556 6609945 15705705 10301912 11245669 5844638\n440894622 898226832 22060902 222576920 53133033", "5 6\n284534195 993347068 628813225 512761241 835859363\n61567950 7311163 14322159 100466429 66443161 48573213", "5 6\n574664105 497253985 200935113 926362846 223381305\n34188719 14075259 27219005 9682257 14352213 11696423", "1 1\n1889\n2867", "20 30\n81 67 100 83 97 97 58 54 72 78 59 64 55 85 75 58 79 91 64 84\n116 13 114 180 17 123 64 185 170 54 138 142 89 191 78 152 49 5 121 66 163 171 64 170 143 143 126 12 175 84"], "outputs": ["11", "6", "1149267712", "3220361921", "8854660961", "781991027", "2867533881", "5515744163", "6133464042", "10329862020", "11622500129", "7667769112", "7840004002", "40738940", "769741424", "238386210", "1479270495", "556069380", "1889", "4628"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 7 | codeforces |
|
50deaa2fdf386fcdaf44f03cf4706b8e | A rectangle | Developing tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem.
A field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for quick filling of a field part with identical enemy units. This action will look like following: a game designer will select a rectangular area on the map, and each cell whose center belongs to the selected rectangle will be filled with the enemy unit.
More formally, if a game designer selected cells having coordinates (*x*1,<=*y*1) and (*x*2,<=*y*2), where *x*1<=β€<=*x*2 and *y*1<=β€<=*y*2, then all cells having center coordinates (*x*,<=*y*) such that *x*1<=β€<=*x*<=β€<=*x*2 and *y*1<=β€<=*y*<=β€<=*y*2 will be filled. Orthogonal coordinates system is set up so that one of cell sides is parallel to *OX* axis, all hexagon centers have integer coordinates and for each integer *x* there are cells having center with such *x* coordinate and for each integer *y* there are cells having center with such *y* coordinate. It is guaranteed that difference *x*2<=-<=*x*1 is divisible by 2.
Working on the problem Petya decided that before painting selected units he wants to output number of units that will be painted on the map.
Help him implement counting of these units before painting.
The only line of input contains four integers *x*1,<=*y*1,<=*x*2,<=*y*2 (<=-<=109<=β€<=*x*1<=β€<=*x*2<=β€<=109,<=<=-<=109<=β€<=*y*1<=β€<=*y*2<=β€<=109) β the coordinates of the centers of two cells.
Output one integer β the number of cells to be filled.
Sample Input
1 1 5 5
Sample Output
13 | {"inputs": ["1 1 5 5", "-1 -3 1 3", "-2 -2 2 2", "0 0 2 2", "0 0 2 0", "0 0 0 0", "0 -2 0 2", "-2 -2 -2 0", "-1000000000 -1000000000 1000000000 1000000000", "-999999999 -999999999 999999999 999999999", "-999999999 -999999999 -1 -1", "-411495869 33834653 -234317741 925065545", "-946749893 -687257665 -539044455 -443568671", "-471257905 -685885153 782342299 909511043", "-26644507 -867720841 975594569 264730225", "-537640548 -254017710 62355638 588691834", "309857887 -687373065 663986893 403321751", "-482406510 -512306894 412844236 -168036050", "-330513944 -970064382 500608496 369852884", "-157778763 218978791 976692563 591093087", "1000000000 1000000000 1000000000 1000000000", "1 0 5 6", "-1 -4 1 4", "-2 -3 2 3", "0 -1 2 3", "0 -1 2 1", "0 -1 0 1", "0 -3 0 3", "-2 -3 -2 1", "-1000000000 -999999999 1000000000 999999999", "-999999999 -1000000000 999999999 1000000000", "-999999999 -1000000000 -1 0", "-411495869 33834652 -234317741 925065546", "-946749893 -687257666 -539044455 -443568670", "-471257905 -685885154 782342299 909511044", "-26644507 -867720842 975594569 264730226", "-537640548 -254017711 62355638 588691835", "309857887 -687373066 663986893 403321752", "-482406510 -512306895 412844236 -168036049", "-330513944 -970064383 500608496 369852885", "-157778763 218978790 976692563 591093088", "1000000000 999999999 1000000000 999999999"], "outputs": ["13", "11", "13", "5", "2", "1", "3", "2", "2000000002000000001", "1999999998000000001", "499999999000000001", "78953311064369599", "49676664342971903", "999994499807710193", "567493356068872580", "252811256874252458", "193123336242128360", "154104365578285608", "556817654843544374", "211076500156631060", "1", "18", "14", "18", "8", "5", "2", "4", "3", "2000000000000000000", "2000000000000000000", "500000000000000000", "78953311241547728", "49676664750677342", "999994501061310398", "567493357071111657", "252811257474248645", "193123336596257367", "154104366473536355", "556817655674666815", "211076501291102387", "1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces |
|
50e08cf44bddd6a4b194ec1f594526c0 | Black Square | Polycarp has a checkered sheet of paper of size *n*<=Γ<=*m*. Polycarp painted some of cells with black, the others remained white. Inspired by Malevich's "Black Square", Polycarp wants to paint minimum possible number of white cells with black so that all black cells form a square.
You are to determine the minimum possible number of cells needed to be painted black so that the black cells form a black square with sides parallel to the painting's sides. All the cells that do not belong to the square should be white. The square's side should have positive length.
The first line contains two integers *n* and *m* (1<=β€<=*n*,<=*m*<=β€<=100) β the sizes of the sheet.
The next *n* lines contain *m* letters 'B' or 'W' each β the description of initial cells' colors. If a letter is 'B', then the corresponding cell is painted black, otherwise it is painted white.
Print the minimum number of cells needed to be painted black so that the black cells form a black square with sides parallel to the painting's sides. All the cells that do not belong to the square should be white. If it is impossible, print -1.
Sample Input
5 4
WWWW
WWWB
WWWB
WWBB
WWWW
1 2
BB
3 3
WWW
WWW
WWW
Sample Output
5
-1
1
| {"inputs": ["5 4\nWWWW\nWWWB\nWWWB\nWWBB\nWWWW", "1 2\nBB", "3 3\nWWW\nWWW\nWWW", "100 1\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nB\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nB", "1 1\nW", "2 4\nWWWW\nWBWW", "4 5\nWWWWW\nBBWWW\nBBWWW\nWWWWW", "5 4\nWWWW\nWWWW\nWWWB\nWWWW\nWWWW", "10 5\nWWWWB\nWWWWW\nWWWBB\nWWBWW\nWWWWW\nWWWWW\nWWWWW\nWWWWW\nWWWWW\nWWWWW", "5 10\nWWWWWWWWWW\nWWWWBWBBWW\nWWWWWWWWWW\nWWWWBWWWWW\nWWWWWWBWWW", "20 10\nWWWWWWWWWW\nWWWWWWWWWW\nWWWWWWWWWW\nWWWWWWWWWW\nWWWWWWWWWW\nWWBBWBWWWW\nWWBWWBWWWW\nWWWWBWWWWW\nWWWWBWWWWW\nWWWWWWWWWW\nWWWWWWWWWW\nWWWWWWWWWW\nWWWWWWWWWW\nWWWWWWWWWW\nWWWWWWWWWW\nWWWWWWWWWW\nWWWWWWWWWW\nWWWWWWWWWW\nWWWWWWWWWW\nWWWWWWWWWW", "10 20\nWWWWWWWWWWWWWWWWWWWW\nWWWWWWWWWWWWWWWWWWWW\nWWWWWWWWWWWWWWWWWWWW\nWWWWWWWWWWWWWWWWWWWW\nWWWWWWWWWWWWWWWWWWWW\nWWWWWWWWWWWWWWWWWWWW\nWWWWWWWWWWWWWWWWWWWW\nWWWWWWWWWWWWWWWWWWBW\nWWWWWWWWWWWWWWWWWBWW\nWWWWWWWWWWWWWWWWWWWW", "1 1\nW", "1 1\nB", "2 2\nWW\nWW", "2 2\nWW\nWB", "2 2\nWW\nBW", "2 2\nWW\nBB", "2 2\nWB\nWW", "2 2\nWB\nWB", "2 2\nWB\nBW", "2 2\nWB\nBB", "2 2\nBW\nWW", "2 2\nBW\nWB", "2 2\nBW\nBW", "2 2\nBW\nBB", "2 2\nBB\nWW", "2 2\nBB\nWB", "2 2\nBB\nBW", "2 2\nBB\nBB", "1 2\nWW", "1 2\nWB", "1 2\nBW", "2 1\nW\nW", "2 1\nW\nB", "2 1\nB\nW", "2 1\nB\nB", "20 10\nWWBWWWBBWW\nWWWWWBWWWW\nWWWWWWWWWW\nWWWWWWWWWW\nWWWBBBWWWW\nWWWWWWWWWW\nWWWWWWWWWW\nWWWWWWWWWW\nWBWWWWWBWW\nWBWWBWWWBW\nWWBWBWWWWW\nWWWBWWBBWW\nWWBBWBWBWW\nBBWWWWWBWW\nWWBWWBBBWW\nWWWBWBBWWW\nWWWBBWBWWW\nWWWWWWWWWW\nWWWBWWWWWW\nWWWWWWWWWW", "10 20\nWWWWWWWBWWWWWWWBWWWB\nWWWBWWWBWWWWWWWWWWWW\nBWWWWWWWWWWWWWWWWWBB\nWWWWWWBWWBWWBWWWBWWW\nWWWWWWWWBWWBWWWBWWWW\nWBWWWWWWWBWWWWWWWWWW\nWWWBWBWWBWWWWWBBWWWB\nWWBBWWWWWWWWWWWWWWWW\nWWWWWWWWWWWWWBWWWWBW\nWWWWWWWWWWWWBWWBWWWB", "1 100\nBWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW", "1 100\nWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWB", "1 100\nWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW", "1 100\nBWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW", "1 100\nWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWB", "100 1\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nB", "100 1\nB\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW", "100 1\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nB\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW", "100 1\nB\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nB\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW", "1 5\nWBBWW", "20 1\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nB\nB\nB", "3 3\nWBW\nWBB\nWWW", "4 6\nWWWWWW\nWWWBWW\nWWWWWB\nWWWWWW", "5 5\nWBWBW\nWWWWW\nWWWWW\nWWWWW\nWWWWW", "3 3\nBBB\nBBB\nBBB", "5 5\nWWBWW\nWWWWW\nWWWWW\nWWWWW\nWWBWW", "5 4\nWWBW\nBWWB\nWWWW\nWWWW\nWWWW", "5 4\nWWWW\nWWWB\nWWWB\nWWWW\nWBBW", "6 6\nWWBWWW\nWWWWWW\nWWWWWW\nWWWWWW\nWWWWWW\nWWWBWW", "3 3\nBBW\nWWW\nBWW", "3 3\nBWB\nWWW\nBWW", "6 6\nWBWWWW\nBWWWBW\nWWWWWW\nWWBWWW\nWWWWWW\nWWWWWW", "3 3\nWWW\nWBW\nWWW", "3 3\nBBB\nWWW\nWWW", "5 5\nWWBWW\nWWBWW\nWBBBW\nWWBWW\nWWBWW", "5 2\nWB\nWB\nWB\nWW\nWW", "4 7\nBBBBBWW\nWWWWWWW\nWWWWWWW\nWWWWWWW", "5 4\nWWWW\nWWWB\nWWWW\nWWBB\nWWWW", "4 4\nWWWW\nWBWW\nWWWW\nWWWW", "2 5\nWWWWW\nBBBWW", "6 6\nWWBWWW\nWWWWWW\nWWWWBW\nWWWWWW\nWWWWWW\nWWBWWW", "3 3\nWBW\nWBW\nWBW", "3 5\nWWBBB\nBWBBB\nWWBBB", "5 5\nWWWWB\nBWWWW\nWWWWB\nWWWWW\nWWWWW", "5 5\nBWWWB\nWWWWW\nWWWWW\nWWWWW\nBWWWW", "4 5\nWWWWW\nBWWWW\nBBBWW\nWWWWW", "4 4\nBBBB\nWWWW\nWWWW\nWWWW", "4 6\nWWWWWW\nBWWWWW\nBWWWWW\nBBBBBB", "3 6\nWWWWWW\nBBBWWW\nWWWWWW", "5 2\nWW\nBW\nBW\nBB\nWW", "5 5\nWWWWW\nWWWWW\nBBBBB\nWWWWW\nWWWWW", "5 5\nWWWWW\nWWWWW\nWWWWB\nWBWWW\nWWWWW", "1 5\nWWBWW", "1 3\nBBB", "2 4\nWWBW\nBWBW", "6 6\nBBBBBB\nWWWWWW\nWWWWWW\nWWWWWW\nWWWWWW\nWWWWWW", "4 4\nWWWW\nWWWW\nWWWW\nWWWW", "3 3\nWWW\nWWW\nWWB", "5 1\nB\nB\nW\nW\nW", "2 3\nWBW\nWBW", "5 2\nWW\nWB\nWB\nWB\nWW", "5 5\nWWWWW\nBWWWW\nWWWWB\nWWWWW\nWWWWW"], "outputs": ["5", "-1", "1", "-1", "1", "0", "0", "0", "12", "11", "9", "2", "1", "0", "1", "0", "0", "2", "0", "2", "2", "1", "0", "2", "2", "1", "2", "1", "1", "0", "1", "0", "0", "1", "0", "0", "-1", "-1", "-1", "0", "0", "0", "-1", "-1", "0", "0", "0", "-1", "-1", "-1", "1", "7", "7", "0", "23", "13", "12", "34", "6", "6", "21", "0", "6", "18", "-1", "-1", "6", "0", "-1", "33", "6", "-1", "22", "22", "5", "12", "-1", "6", "-1", "20", "14", "0", "-1", "-1", "30", "1", "0", "-1", "2", "-1", "23"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 73 | codeforces |
|
50e3de91cc5521bb0c2850880e212a5f | Commentary Boxes | Berland Football Cup starts really soon! Commentators from all over the world come to the event.
Organizers have already built $n$ commentary boxes. $m$ regional delegations will come to the Cup. Every delegation should get the same number of the commentary boxes. If any box is left unoccupied then the delegations will be upset. So each box should be occupied by exactly one delegation.
If $n$ is not divisible by $m$, it is impossible to distribute the boxes to the delegations at the moment.
Organizers can build a new commentary box paying $a$ burles and demolish a commentary box paying $b$ burles. They can both build and demolish boxes arbitrary number of times (each time paying a corresponding fee). It is allowed to demolish all the existing boxes.
What is the minimal amount of burles organizers should pay to satisfy all the delegations (i.e. to make the number of the boxes be divisible by $m$)?
The only line contains four integer numbers $n$, $m$, $a$ and $b$ ($1 \le n, m \le 10^{12}$, $1 \le a, b \le 100$), where $n$ is the initial number of the commentary boxes, $m$ is the number of delegations to come, $a$ is the fee to build a box and $b$ is the fee to demolish a box.
Output the minimal amount of burles organizers should pay to satisfy all the delegations (i.e. to make the number of the boxes be divisible by $m$). It is allowed that the final number of the boxes is equal to $0$.
Sample Input
9 7 3 8
2 7 3 7
30 6 17 19
Sample Output
15
14
0
| {"inputs": ["9 7 3 8", "2 7 3 7", "30 6 17 19", "500000000001 1000000000000 100 100", "1000000000000 750000000001 10 100", "1000000000000 750000000001 100 10", "42 1 1 1", "1 1000000000000 1 100", "7 2 3 7", "999999999 2 1 1", "999999999999 10000000007 100 100", "10000000001 2 1 1", "29 6 1 2", "99999999999 6 100 100", "1000000000000 7 3 8", "99999999999 2 1 1", "1 2 1 1", "999999999999 2 1 1", "9 2 1 1", "17 4 5 5", "100000000000 3 1 1", "100 7 1 1", "1000000000000 3 100 100", "70 3 10 10", "1 2 5 1", "1000000000000 3 1 1", "804289377 846930887 78 16", "1000000000000 9 55 55", "957747787 424238336 87 93", "25 6 1 2", "22 7 3 8", "10000000000 1 1 1", "999999999999 2 10 10", "999999999999 2 100 100", "100 3 3 8", "99999 2 1 1", "100 3 2 5", "1000000000000 13 10 17", "7 2 1 2", "10 3 1 2", "5 2 2 2", "100 3 5 2", "7 2 1 1", "70 4 1 1", "10 4 1 1", "6 7 41 42", "10 3 10 1", "5 5 2 3", "1000000000000 3 99 99", "7 3 100 1", "7 2 100 5", "1000000000000 1 23 33", "30 7 1 1", "100 3 1 1", "90001 300 100 1", "13 4 1 2", "1000000000000 6 1 3", "50 4 5 100", "999 2 1 1", "5 2 5 5", "20 3 3 3", "3982258181 1589052704 87 20", "100 3 1 3", "7 3 1 1", "19 10 100 100", "23 3 100 1", "25 7 100 1", "100 9 1 2", "9999999999 2 1 100", "1000000000000 2 1 1", "10000 3 1 1", "22 7 1 6", "100000000000 1 1 1", "18 7 100 1", "10003 4 1 100", "3205261341 718648876 58 11", "8 3 100 1", "15 7 1 1", "1000000000000 1 20 20", "16 7 3 2", "1000000000000 1 1 1", "7 3 1 100", "16 3 1 100", "13 4 1 10", "10 4 5 5", "14 3 1 100", "100 33 100 1", "22 7 1 8", "10 4 2 1", "6 4 2 2", "17 4 2 1", "7 3 100 10", "702 7 3 2", "8 3 1 5", "3 2 5 2", "99 19 1 7", "16 3 100 1", "100 34 1 100", "100 33 1 1", "2 3 4 3", "15 4 4 10", "1144108931 470211273 45 79", "2 3 3 4", "29 5 4 9", "15 7 1 5", "1 1 1 1", "1 1 3 4", "10 12 2 1", "1 2 3 4"], "outputs": ["15", "14", "0", "49999999999900", "5000000000020", "2499999999990", "0", "100", "3", "1", "70100", "1", "1", "300", "8", "1", "1", "1", "1", "5", "1", "2", "100", "10", "1", "1", "3326037780", "55", "10162213695", "2", "8", "0", "10", "100", "6", "1", "4", "17", "1", "2", "2", "2", "1", "2", "2", "41", "1", "0", "99", "1", "5", "0", "2", "1", "1", "2", "2", "10", "1", "5", "3", "16083055460", "2", "1", "100", "2", "4", "2", "1", "0", "1", "6", "0", "4", "1", "3637324207", "2", "1", "0", "4", "0", "2", "2", "3", "10", "1", "1", "6", "2", "4", "1", "10", "4", "1", "2", "15", "1", "2", "1", "4", "4", "11993619960", "3", "4", "5", "0", "0", "4", "3"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 269 | codeforces |
|
510995f0772298cdcea496ca8e30b37f | Jamie and Alarm Snooze | Jamie loves sleeping. One day, he decides that he needs to wake up at exactly *hh*:<=*mm*. However, he hates waking up, so he wants to make waking up less painful by setting the alarm at a lucky time. He will then press the snooze button every *x* minutes until *hh*:<=*mm* is reached, and only then he will wake up. He wants to know what is the smallest number of times he needs to press the snooze button.
A time is considered lucky if it contains a digit '7'. For example, 13:<=07 and 17:<=27 are lucky, while 00:<=48 and 21:<=34 are not lucky.
Note that it is not necessary that the time set for the alarm and the wake-up time are on the same day. It is guaranteed that there is a lucky time Jamie can set so that he can wake at *hh*:<=*mm*.
Formally, find the smallest possible non-negative integer *y* such that the time representation of the time *x*Β·*y* minutes before *hh*:<=*mm* contains the digit '7'.
Jamie uses 24-hours clock, so after 23:<=59 comes 00:<=00.
The first line contains a single integer *x* (1<=β€<=*x*<=β€<=60).
The second line contains two two-digit integers, *hh* and *mm* (00<=β€<=*hh*<=β€<=23,<=00<=β€<=*mm*<=β€<=59).
Print the minimum number of times he needs to press the button.
Sample Input
3
11 23
5
01 07
Sample Output
2
0
| {"inputs": ["3\n11 23", "5\n01 07", "34\n09 24", "2\n14 37", "14\n19 54", "42\n15 44", "46\n02 43", "14\n06 41", "26\n04 58", "54\n16 47", "38\n20 01", "11\n02 05", "55\n22 10", "23\n10 08", "23\n23 14", "51\n03 27", "35\n15 25", "3\n12 15", "47\n00 28", "31\n13 34", "59\n17 32", "25\n11 03", "9\n16 53", "53\n04 06", "37\n00 12", "5\n13 10", "50\n01 59", "34\n06 13", "2\n18 19", "46\n06 16", "14\n03 30", "40\n13 37", "24\n17 51", "8\n14 57", "52\n18 54", "20\n15 52", "20\n03 58", "48\n07 11", "32\n04 01", "60\n08 15", "44\n20 20", "55\n15 35", "55\n03 49", "23\n16 39", "7\n20 36", "35\n16 42", "35\n05 56", "3\n17 45", "47\n05 59", "15\n10 13", "59\n06 18", "34\n17 18", "18\n05 23", "46\n17 21", "30\n06 27", "14\n18 40", "58\n22 54", "26\n19 44", "10\n15 57", "54\n20 47", "22\n08 45", "48\n18 08", "32\n07 06", "60\n19 19", "45\n07 25", "29\n12 39", "13\n08 28", "41\n21 42", "41\n09 32", "9\n21 45", "37\n10 43", "3\n20 50", "47\n00 04", "15\n13 10", "15\n17 23", "43\n22 13", "27\n10 26", "55\n22 24", "55\n03 30", "24\n23 27", "52\n11 33", "18\n22 48", "1\n12 55", "1\n04 27", "1\n12 52", "1\n20 16", "1\n04 41", "1\n20 21", "1\n04 45", "1\n12 18", "1\n04 42", "1\n02 59", "1\n18 24", "1\n02 04", "1\n18 28", "1\n18 01", "1\n10 25", "1\n02 49", "1\n02 30", "1\n18 54", "1\n02 19", "1\n05 25", "60\n23 55", "60\n08 19", "60\n00 00", "60\n08 24", "60\n16 13", "60\n08 21", "60\n16 45", "60\n08 26", "60\n08 50", "60\n05 21", "60\n13 29", "60\n05 18", "60\n13 42", "60\n05 07", "60\n05 47", "60\n21 55", "60\n05 36", "60\n21 08", "60\n21 32", "60\n16 31", "5\n00 00", "2\n06 58", "60\n00 00", "2\n00 00", "10\n00 00", "60\n01 00", "12\n00 06", "1\n00 01", "5\n00 05", "60\n01 01", "11\n18 11", "60\n01 15", "10\n00 16", "60\n00 59", "30\n00 00", "60\n01 05", "4\n00 03", "4\n00 00", "60\n00 01", "6\n00 03", "13\n00 00", "1\n18 01", "5\n06 00", "60\n04 08", "5\n01 55", "8\n00 08", "23\n18 23", "6\n00 06", "59\n18 59", "11\n00 10", "10\n00 01", "59\n00 00", "10\n18 10", "5\n00 01", "1\n00 00", "8\n00 14", "60\n03 00", "60\n00 10", "5\n01 13", "30\n02 43", "17\n00 08", "3\n00 00", "60\n00 05", "5\n18 05", "30\n00 30", "1\n00 06", "55\n00 00", "8\n02 08", "7\n00 00", "6\n08 06", "48\n06 24", "8\n06 58", "3\n12 00", "5\n01 06", "2\n00 08", "3\n18 03", "1\n17 00", "59\n00 48", "5\n12 01", "55\n01 25", "2\n07 23", "10\n01 10", "2\n00 01", "59\n00 01", "5\n00 02", "4\n01 02", "5\n00 06", "42\n00 08", "60\n01 20", "3\n06 00", "4\n00 01", "2\n00 06", "1\n00 57", "6\n00 00", "5\n08 40", "58\n00 55", "2\n00 02", "1\n08 01", "10\n10 10", "60\n01 11", "2\n07 00", "15\n00 03", "6\n04 34", "16\n00 16", "2\n00 59", "59\n00 08", "10\n03 10", "3\n08 03", "20\n06 11", "4\n01 00", "38\n01 08", "60\n00 06", "5\n12 00", "6\n01 42", "4\n00 04", "60\n04 05", "1\n00 53", "5\n08 05", "60\n18 45", "60\n06 23", "6\n00 15", "58\n00 06", "2\n06 44", "1\n08 00", "10\n06 58", "59\n00 58", "1\n18 00", "50\n00 42", "30\n18 30", "60\n21 59", "2\n10 52", "56\n00 00", "16\n18 16", "5\n01 05", "5\n05 00", "5\n23 59", "7\n17 13", "58\n00 00", "15\n00 07", "59\n08 00", "46\n00 00", "59\n01 05", "2\n01 00", "60\n00 24", "10\n00 08", "10\n00 06", "60\n01 24", "50\n00 10", "2\n03 00", "4\n19 04", "25\n00 23", "10\n01 01"], "outputs": ["2", "0", "3", "0", "9", "12", "1", "1", "26", "0", "3", "8", "5", "6", "9", "0", "13", "6", "3", "7", "0", "8", "4", "3", "5", "63", "10", "4", "1", "17", "41", "0", "0", "0", "2", "24", "30", "0", "2", "1", "4", "9", "11", "4", "7", "1", "21", "0", "6", "9", "9", "0", "2", "0", "0", "3", "6", "5", "0", "0", "3", "1", "0", "2", "0", "8", "3", "5", "3", "2", "5", "1", "1", "21", "0", "2", "6", "5", "11", "0", "3", "17", "8", "0", "5", "9", "4", "4", "8", "1", "5", "2", "7", "7", "1", "2", "8", "2", "3", "7", "2", "8", "6", "1", "7", "1", "9", "1", "9", "1", "1", "12", "6", "12", "6", "0", "0", "4", "12", "4", "4", "9", "73", "390", "7", "181", "37", "8", "31", "4", "74", "8", "2", "8", "38", "7", "13", "8", "4", "91", "7", "1", "1", "2", "145", "11", "96", "47", "2", "62", "2", "3", "37", "7", "2", "73", "3", "47", "10", "7", "87", "18", "3", "1", "7", "2", "14", "9", "7", "62", "9", "2", "16", "98", "1", "86", "185", "2", "0", "7", "49", "9", "0", "44", "2", "6", "1", "106", "74", "9", "8", "1", "1", "184", "0", "61", "9", "1", "182", "2", "14", "8", "0", "25", "106", "24", "1", "7", "56", "2", "37", "106", "12", "7", "49", "78", "92", "11", "6", "2", "1", "13", "3", "7", "383", "1", "78", "8", "1", "9", "2", "4", "87", "7", "2", "86", "133", "72", "0", "7", "0", "1", "8", "2", "211", "7", "37", "37", "8", "8", "271", "17", "16", "43"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 221 | codeforces |
|
510c8b6e384edf5cc7c5ebc9f24ffc8d | Die Roll | Yakko, Wakko and Dot, world-famous animaniacs, decided to rest from acting in cartoons, and take a leave to travel a bit. Yakko dreamt to go to Pennsylvania, his Motherland and the Motherland of his ancestors. Wakko thought about Tasmania, its beaches, sun and sea. Dot chose Transylvania as the most mysterious and unpredictable place.
But to their great regret, the leave turned to be very short, so it will be enough to visit one of the three above named places. That's why Yakko, as the cleverest, came up with a truly genius idea: let each of the three roll an ordinary six-sided die, and the one with the highest amount of points will be the winner, and will take the other two to the place of his/her dreams.
Yakko thrown a die and got Y points, Wakko β W points. It was Dot's turn. But she didn't hurry. Dot wanted to know for sure what were her chances to visit Transylvania.
It is known that Yakko and Wakko are true gentlemen, that's why if they have the same amount of points with Dot, they will let Dot win.
The only line of the input file contains two natural numbers Y and W β the results of Yakko's and Wakko's die rolls.
Output the required probability in the form of irreducible fraction in format Β«A/BΒ», where A β the numerator, and B β the denominator. If the required probability equals to zero, output Β«0/1Β». If the required probability equals to 1, output Β«1/1Β».
Sample Input
4 2
Sample Output
1/2
| {"inputs": ["4 2", "1 1", "1 2", "1 3", "1 4", "1 5", "1 6", "2 1", "2 2", "2 3", "2 4", "2 5", "2 6", "3 1", "3 2", "3 3", "3 4", "3 5", "3 6", "4 1", "4 3", "4 4", "4 5", "4 6", "5 1", "5 2", "5 3", "5 4", "5 5", "5 6", "6 1", "6 2", "6 3", "6 4", "6 5", "6 6"], "outputs": ["1/2", "1/1", "5/6", "2/3", "1/2", "1/3", "1/6", "5/6", "5/6", "2/3", "1/2", "1/3", "1/6", "2/3", "2/3", "2/3", "1/2", "1/3", "1/6", "1/2", "1/2", "1/2", "1/3", "1/6", "1/3", "1/3", "1/3", "1/3", "1/3", "1/6", "1/6", "1/6", "1/6", "1/6", "1/6", "1/6"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1,289 | codeforces |
|
51541df11a68a266455ed6830f33bb89 | 3-cycles | During a recent research Berland scientists found out that there were *n* cities in Ancient Berland, joined by two-way paths. Any two cities are joined by no more than one path. No path joins a city with itself. According to a well-known tradition, the road network was built so that it would be impossible to choose three cities from each of which one can get to any other one directly. That is, there was no cycle exactly as long as 3. Unfortunately, the road map has not been preserved till nowadays. Now the scientists are interested how much developed a country Ancient Berland was. Help them - find, what maximal number of roads could be in the country. You also have to restore any of the possible road maps.
The first line contains an integer *n* (1<=β€<=*n*<=β€<=100) β the number of cities in Berland.
On the first line must be printed number *m* β the maximal number of roads in Berland. Then print *m* lines containing two numbers each β the numbers of cities that the given road joins. The cities are numbered with integers from 1 to *n*. If there are several variants of solving the problem, print any of them.
Sample Input
3
4
Sample Output
2
1 2
2 3
4
1 2
2 3
3 4
4 1
| {"inputs": ["3", "4", "5", "6", "7", "8", "9", "10", "1", "2", "11", "13", "16", "18", "19", "12", "22", "23", "15", "29", "31", "33", "36", "40", "42", "47", "50", "52", "59", "63", "64", "68", "75", "77", "81", "86", "87", "88", "89", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "100"], "outputs": ["2\n1 2\n1 3", "4\n1 3\n1 4\n2 3\n2 4", "6\n1 3\n1 4\n1 5\n2 3\n2 4\n2 5", "9\n1 4\n1 5\n1 6\n2 4\n2 5\n2 6\n3 4\n3 5\n3 6", "12\n1 4\n1 5\n1 6\n1 7\n2 4\n2 5\n2 6\n2 7\n3 4\n3 5\n3 6\n3 7", "16\n1 5\n1 6\n1 7\n1 8\n2 5\n2 6\n2 7\n2 8\n3 5\n3 6\n3 7\n3 8\n4 5\n4 6\n4 7\n4 8", "20\n1 5\n1 6\n1 7\n1 8\n1 9\n2 5\n2 6\n2 7\n2 8\n2 9\n3 5\n3 6\n3 7\n3 8\n3 9\n4 5\n4 6\n4 7\n4 8\n4 9", "25\n1 6\n1 7\n1 8\n1 9\n1 10\n2 6\n2 7\n2 8\n2 9\n2 10\n3 6\n3 7\n3 8\n3 9\n3 10\n4 6\n4 7\n4 8\n4 9\n4 10\n5 6\n5 7\n5 8\n5 9\n5 10", "0", "1\n1 2", "30\n1 6\n1 7\n1 8\n1 9\n1 10\n1 11\n2 6\n2 7\n2 8\n2 9\n2 10\n2 11\n3 6\n3 7\n3 8\n3 9\n3 10\n3 11\n4 6\n4 7\n4 8\n4 9\n4 10\n4 11\n5 6\n5 7\n5 8\n5 9\n5 10\n5 11", "42\n1 7\n1 8\n1 9\n1 10\n1 11\n1 12\n1 13\n2 7\n2 8\n2 9\n2 10\n2 11\n2 12\n2 13\n3 7\n3 8\n3 9\n3 10\n3 11\n3 12\n3 13\n4 7\n4 8\n4 9\n4 10\n4 11\n4 12\n4 13\n5 7\n5 8\n5 9\n5 10\n5 11\n5 12\n5 13\n6 7\n6 8\n6 9\n6 10\n6 11\n6 12\n6 13", "64\n1 9\n1 10\n1 11\n1 12\n1 13\n1 14\n1 15\n1 16\n2 9\n2 10\n2 11\n2 12\n2 13\n2 14\n2 15\n2 16\n3 9\n3 10\n3 11\n3 12\n3 13\n3 14\n3 15\n3 16\n4 9\n4 10\n4 11\n4 12\n4 13\n4 14\n4 15\n4 16\n5 9\n5 10\n5 11\n5 12\n5 13\n5 14\n5 15\n5 16\n6 9\n6 10\n6 11\n6 12\n6 13\n6 14\n6 15\n6 16\n7 9\n7 10\n7 11\n7 12\n7 13\n7 14\n7 15\n7 16\n8 9\n8 10\n8 11\n8 12\n8 13\n8 14\n8 15\n8 16", "81\n1 10\n1 11\n1 12\n1 13\n1 14\n1 15\n1 16\n1 17\n1 18\n2 10\n2 11\n2 12\n2 13\n2 14\n2 15\n2 16\n2 17\n2 18\n3 10\n3 11\n3 12\n3 13\n3 14\n3 15\n3 16\n3 17\n3 18\n4 10\n4 11\n4 12\n4 13\n4 14\n4 15\n4 16\n4 17\n4 18\n5 10\n5 11\n5 12\n5 13\n5 14\n5 15\n5 16\n5 17\n5 18\n6 10\n6 11\n6 12\n6 13\n6 14\n6 15\n6 16\n6 17\n6 18\n7 10\n7 11\n7 12\n7 13\n7 14\n7 15\n7 16\n7 17\n7 18\n8 10\n8 11\n8 12\n8 13\n8 14\n8 15\n8 16\n8 17\n8 18\n9 10\n9 11\n9 12\n9 13\n9 14\n9 15\n9 16\n9 17\n9 18", "90\n1 10\n1 11\n1 12\n1 13\n1 14\n1 15\n1 16\n1 17\n1 18\n1 19\n2 10\n2 11\n2 12\n2 13\n2 14\n2 15\n2 16\n2 17\n2 18\n2 19\n3 10\n3 11\n3 12\n3 13\n3 14\n3 15\n3 16\n3 17\n3 18\n3 19\n4 10\n4 11\n4 12\n4 13\n4 14\n4 15\n4 16\n4 17\n4 18\n4 19\n5 10\n5 11\n5 12\n5 13\n5 14\n5 15\n5 16\n5 17\n5 18\n5 19\n6 10\n6 11\n6 12\n6 13\n6 14\n6 15\n6 16\n6 17\n6 18\n6 19\n7 10\n7 11\n7 12\n7 13\n7 14\n7 15\n7 16\n7 17\n7 18\n7 19\n8 10\n8 11\n8 12\n8 13\n8 14\n8 15\n8 16\n8 17\n8 18\n8 19\n9 10\n9 11\n9 12\n9 13\n9 1...", "36\n1 7\n1 8\n1 9\n1 10\n1 11\n1 12\n2 7\n2 8\n2 9\n2 10\n2 11\n2 12\n3 7\n3 8\n3 9\n3 10\n3 11\n3 12\n4 7\n4 8\n4 9\n4 10\n4 11\n4 12\n5 7\n5 8\n5 9\n5 10\n5 11\n5 12\n6 7\n6 8\n6 9\n6 10\n6 11\n6 12", "121\n1 12\n1 13\n1 14\n1 15\n1 16\n1 17\n1 18\n1 19\n1 20\n1 21\n1 22\n2 12\n2 13\n2 14\n2 15\n2 16\n2 17\n2 18\n2 19\n2 20\n2 21\n2 22\n3 12\n3 13\n3 14\n3 15\n3 16\n3 17\n3 18\n3 19\n3 20\n3 21\n3 22\n4 12\n4 13\n4 14\n4 15\n4 16\n4 17\n4 18\n4 19\n4 20\n4 21\n4 22\n5 12\n5 13\n5 14\n5 15\n5 16\n5 17\n5 18\n5 19\n5 20\n5 21\n5 22\n6 12\n6 13\n6 14\n6 15\n6 16\n6 17\n6 18\n6 19\n6 20\n6 21\n6 22\n7 12\n7 13\n7 14\n7 15\n7 16\n7 17\n7 18\n7 19\n7 20\n7 21\n7 22\n8 12\n8 13\n8 14\n8 15\n8 16\n8 17\n8 18\n8 ...", "132\n1 12\n1 13\n1 14\n1 15\n1 16\n1 17\n1 18\n1 19\n1 20\n1 21\n1 22\n1 23\n2 12\n2 13\n2 14\n2 15\n2 16\n2 17\n2 18\n2 19\n2 20\n2 21\n2 22\n2 23\n3 12\n3 13\n3 14\n3 15\n3 16\n3 17\n3 18\n3 19\n3 20\n3 21\n3 22\n3 23\n4 12\n4 13\n4 14\n4 15\n4 16\n4 17\n4 18\n4 19\n4 20\n4 21\n4 22\n4 23\n5 12\n5 13\n5 14\n5 15\n5 16\n5 17\n5 18\n5 19\n5 20\n5 21\n5 22\n5 23\n6 12\n6 13\n6 14\n6 15\n6 16\n6 17\n6 18\n6 19\n6 20\n6 21\n6 22\n6 23\n7 12\n7 13\n7 14\n7 15\n7 16\n7 17\n7 18\n7 19\n7 20\n7 21\n7 22\n7 23\n8 ...", "56\n1 8\n1 9\n1 10\n1 11\n1 12\n1 13\n1 14\n1 15\n2 8\n2 9\n2 10\n2 11\n2 12\n2 13\n2 14\n2 15\n3 8\n3 9\n3 10\n3 11\n3 12\n3 13\n3 14\n3 15\n4 8\n4 9\n4 10\n4 11\n4 12\n4 13\n4 14\n4 15\n5 8\n5 9\n5 10\n5 11\n5 12\n5 13\n5 14\n5 15\n6 8\n6 9\n6 10\n6 11\n6 12\n6 13\n6 14\n6 15\n7 8\n7 9\n7 10\n7 11\n7 12\n7 13\n7 14\n7 15", "210\n1 15\n1 16\n1 17\n1 18\n1 19\n1 20\n1 21\n1 22\n1 23\n1 24\n1 25\n1 26\n1 27\n1 28\n1 29\n2 15\n2 16\n2 17\n2 18\n2 19\n2 20\n2 21\n2 22\n2 23\n2 24\n2 25\n2 26\n2 27\n2 28\n2 29\n3 15\n3 16\n3 17\n3 18\n3 19\n3 20\n3 21\n3 22\n3 23\n3 24\n3 25\n3 26\n3 27\n3 28\n3 29\n4 15\n4 16\n4 17\n4 18\n4 19\n4 20\n4 21\n4 22\n4 23\n4 24\n4 25\n4 26\n4 27\n4 28\n4 29\n5 15\n5 16\n5 17\n5 18\n5 19\n5 20\n5 21\n5 22\n5 23\n5 24\n5 25\n5 26\n5 27\n5 28\n5 29\n6 15\n6 16\n6 17\n6 18\n6 19\n6 20\n6 21\n6 22\n6 23\n6 ...", "240\n1 16\n1 17\n1 18\n1 19\n1 20\n1 21\n1 22\n1 23\n1 24\n1 25\n1 26\n1 27\n1 28\n1 29\n1 30\n1 31\n2 16\n2 17\n2 18\n2 19\n2 20\n2 21\n2 22\n2 23\n2 24\n2 25\n2 26\n2 27\n2 28\n2 29\n2 30\n2 31\n3 16\n3 17\n3 18\n3 19\n3 20\n3 21\n3 22\n3 23\n3 24\n3 25\n3 26\n3 27\n3 28\n3 29\n3 30\n3 31\n4 16\n4 17\n4 18\n4 19\n4 20\n4 21\n4 22\n4 23\n4 24\n4 25\n4 26\n4 27\n4 28\n4 29\n4 30\n4 31\n5 16\n5 17\n5 18\n5 19\n5 20\n5 21\n5 22\n5 23\n5 24\n5 25\n5 26\n5 27\n5 28\n5 29\n5 30\n5 31\n6 16\n6 17\n6 18\n6 19\n6 ...", "272\n1 17\n1 18\n1 19\n1 20\n1 21\n1 22\n1 23\n1 24\n1 25\n1 26\n1 27\n1 28\n1 29\n1 30\n1 31\n1 32\n1 33\n2 17\n2 18\n2 19\n2 20\n2 21\n2 22\n2 23\n2 24\n2 25\n2 26\n2 27\n2 28\n2 29\n2 30\n2 31\n2 32\n2 33\n3 17\n3 18\n3 19\n3 20\n3 21\n3 22\n3 23\n3 24\n3 25\n3 26\n3 27\n3 28\n3 29\n3 30\n3 31\n3 32\n3 33\n4 17\n4 18\n4 19\n4 20\n4 21\n4 22\n4 23\n4 24\n4 25\n4 26\n4 27\n4 28\n4 29\n4 30\n4 31\n4 32\n4 33\n5 17\n5 18\n5 19\n5 20\n5 21\n5 22\n5 23\n5 24\n5 25\n5 26\n5 27\n5 28\n5 29\n5 30\n5 31\n5 32\n5 ...", "324\n1 19\n1 20\n1 21\n1 22\n1 23\n1 24\n1 25\n1 26\n1 27\n1 28\n1 29\n1 30\n1 31\n1 32\n1 33\n1 34\n1 35\n1 36\n2 19\n2 20\n2 21\n2 22\n2 23\n2 24\n2 25\n2 26\n2 27\n2 28\n2 29\n2 30\n2 31\n2 32\n2 33\n2 34\n2 35\n2 36\n3 19\n3 20\n3 21\n3 22\n3 23\n3 24\n3 25\n3 26\n3 27\n3 28\n3 29\n3 30\n3 31\n3 32\n3 33\n3 34\n3 35\n3 36\n4 19\n4 20\n4 21\n4 22\n4 23\n4 24\n4 25\n4 26\n4 27\n4 28\n4 29\n4 30\n4 31\n4 32\n4 33\n4 34\n4 35\n4 36\n5 19\n5 20\n5 21\n5 22\n5 23\n5 24\n5 25\n5 26\n5 27\n5 28\n5 29\n5 30\n5 ...", "400\n1 21\n1 22\n1 23\n1 24\n1 25\n1 26\n1 27\n1 28\n1 29\n1 30\n1 31\n1 32\n1 33\n1 34\n1 35\n1 36\n1 37\n1 38\n1 39\n1 40\n2 21\n2 22\n2 23\n2 24\n2 25\n2 26\n2 27\n2 28\n2 29\n2 30\n2 31\n2 32\n2 33\n2 34\n2 35\n2 36\n2 37\n2 38\n2 39\n2 40\n3 21\n3 22\n3 23\n3 24\n3 25\n3 26\n3 27\n3 28\n3 29\n3 30\n3 31\n3 32\n3 33\n3 34\n3 35\n3 36\n3 37\n3 38\n3 39\n3 40\n4 21\n4 22\n4 23\n4 24\n4 25\n4 26\n4 27\n4 28\n4 29\n4 30\n4 31\n4 32\n4 33\n4 34\n4 35\n4 36\n4 37\n4 38\n4 39\n4 40\n5 21\n5 22\n5 23\n5 24\n5 ...", "441\n1 22\n1 23\n1 24\n1 25\n1 26\n1 27\n1 28\n1 29\n1 30\n1 31\n1 32\n1 33\n1 34\n1 35\n1 36\n1 37\n1 38\n1 39\n1 40\n1 41\n1 42\n2 22\n2 23\n2 24\n2 25\n2 26\n2 27\n2 28\n2 29\n2 30\n2 31\n2 32\n2 33\n2 34\n2 35\n2 36\n2 37\n2 38\n2 39\n2 40\n2 41\n2 42\n3 22\n3 23\n3 24\n3 25\n3 26\n3 27\n3 28\n3 29\n3 30\n3 31\n3 32\n3 33\n3 34\n3 35\n3 36\n3 37\n3 38\n3 39\n3 40\n3 41\n3 42\n4 22\n4 23\n4 24\n4 25\n4 26\n4 27\n4 28\n4 29\n4 30\n4 31\n4 32\n4 33\n4 34\n4 35\n4 36\n4 37\n4 38\n4 39\n4 40\n4 41\n4 42\n5 ...", "552\n1 24\n1 25\n1 26\n1 27\n1 28\n1 29\n1 30\n1 31\n1 32\n1 33\n1 34\n1 35\n1 36\n1 37\n1 38\n1 39\n1 40\n1 41\n1 42\n1 43\n1 44\n1 45\n1 46\n1 47\n2 24\n2 25\n2 26\n2 27\n2 28\n2 29\n2 30\n2 31\n2 32\n2 33\n2 34\n2 35\n2 36\n2 37\n2 38\n2 39\n2 40\n2 41\n2 42\n2 43\n2 44\n2 45\n2 46\n2 47\n3 24\n3 25\n3 26\n3 27\n3 28\n3 29\n3 30\n3 31\n3 32\n3 33\n3 34\n3 35\n3 36\n3 37\n3 38\n3 39\n3 40\n3 41\n3 42\n3 43\n3 44\n3 45\n3 46\n3 47\n4 24\n4 25\n4 26\n4 27\n4 28\n4 29\n4 30\n4 31\n4 32\n4 33\n4 34\n4 35\n4 ...", "625\n1 26\n1 27\n1 28\n1 29\n1 30\n1 31\n1 32\n1 33\n1 34\n1 35\n1 36\n1 37\n1 38\n1 39\n1 40\n1 41\n1 42\n1 43\n1 44\n1 45\n1 46\n1 47\n1 48\n1 49\n1 50\n2 26\n2 27\n2 28\n2 29\n2 30\n2 31\n2 32\n2 33\n2 34\n2 35\n2 36\n2 37\n2 38\n2 39\n2 40\n2 41\n2 42\n2 43\n2 44\n2 45\n2 46\n2 47\n2 48\n2 49\n2 50\n3 26\n3 27\n3 28\n3 29\n3 30\n3 31\n3 32\n3 33\n3 34\n3 35\n3 36\n3 37\n3 38\n3 39\n3 40\n3 41\n3 42\n3 43\n3 44\n3 45\n3 46\n3 47\n3 48\n3 49\n3 50\n4 26\n4 27\n4 28\n4 29\n4 30\n4 31\n4 32\n4 33\n4 34\n4 ...", "676\n1 27\n1 28\n1 29\n1 30\n1 31\n1 32\n1 33\n1 34\n1 35\n1 36\n1 37\n1 38\n1 39\n1 40\n1 41\n1 42\n1 43\n1 44\n1 45\n1 46\n1 47\n1 48\n1 49\n1 50\n1 51\n1 52\n2 27\n2 28\n2 29\n2 30\n2 31\n2 32\n2 33\n2 34\n2 35\n2 36\n2 37\n2 38\n2 39\n2 40\n2 41\n2 42\n2 43\n2 44\n2 45\n2 46\n2 47\n2 48\n2 49\n2 50\n2 51\n2 52\n3 27\n3 28\n3 29\n3 30\n3 31\n3 32\n3 33\n3 34\n3 35\n3 36\n3 37\n3 38\n3 39\n3 40\n3 41\n3 42\n3 43\n3 44\n3 45\n3 46\n3 47\n3 48\n3 49\n3 50\n3 51\n3 52\n4 27\n4 28\n4 29\n4 30\n4 31\n4 32\n4 ...", "870\n1 30\n1 31\n1 32\n1 33\n1 34\n1 35\n1 36\n1 37\n1 38\n1 39\n1 40\n1 41\n1 42\n1 43\n1 44\n1 45\n1 46\n1 47\n1 48\n1 49\n1 50\n1 51\n1 52\n1 53\n1 54\n1 55\n1 56\n1 57\n1 58\n1 59\n2 30\n2 31\n2 32\n2 33\n2 34\n2 35\n2 36\n2 37\n2 38\n2 39\n2 40\n2 41\n2 42\n2 43\n2 44\n2 45\n2 46\n2 47\n2 48\n2 49\n2 50\n2 51\n2 52\n2 53\n2 54\n2 55\n2 56\n2 57\n2 58\n2 59\n3 30\n3 31\n3 32\n3 33\n3 34\n3 35\n3 36\n3 37\n3 38\n3 39\n3 40\n3 41\n3 42\n3 43\n3 44\n3 45\n3 46\n3 47\n3 48\n3 49\n3 50\n3 51\n3 52\n3 53\n3 ...", "992\n1 32\n1 33\n1 34\n1 35\n1 36\n1 37\n1 38\n1 39\n1 40\n1 41\n1 42\n1 43\n1 44\n1 45\n1 46\n1 47\n1 48\n1 49\n1 50\n1 51\n1 52\n1 53\n1 54\n1 55\n1 56\n1 57\n1 58\n1 59\n1 60\n1 61\n1 62\n1 63\n2 32\n2 33\n2 34\n2 35\n2 36\n2 37\n2 38\n2 39\n2 40\n2 41\n2 42\n2 43\n2 44\n2 45\n2 46\n2 47\n2 48\n2 49\n2 50\n2 51\n2 52\n2 53\n2 54\n2 55\n2 56\n2 57\n2 58\n2 59\n2 60\n2 61\n2 62\n2 63\n3 32\n3 33\n3 34\n3 35\n3 36\n3 37\n3 38\n3 39\n3 40\n3 41\n3 42\n3 43\n3 44\n3 45\n3 46\n3 47\n3 48\n3 49\n3 50\n3 51\n3 ...", "1024\n1 33\n1 34\n1 35\n1 36\n1 37\n1 38\n1 39\n1 40\n1 41\n1 42\n1 43\n1 44\n1 45\n1 46\n1 47\n1 48\n1 49\n1 50\n1 51\n1 52\n1 53\n1 54\n1 55\n1 56\n1 57\n1 58\n1 59\n1 60\n1 61\n1 62\n1 63\n1 64\n2 33\n2 34\n2 35\n2 36\n2 37\n2 38\n2 39\n2 40\n2 41\n2 42\n2 43\n2 44\n2 45\n2 46\n2 47\n2 48\n2 49\n2 50\n2 51\n2 52\n2 53\n2 54\n2 55\n2 56\n2 57\n2 58\n2 59\n2 60\n2 61\n2 62\n2 63\n2 64\n3 33\n3 34\n3 35\n3 36\n3 37\n3 38\n3 39\n3 40\n3 41\n3 42\n3 43\n3 44\n3 45\n3 46\n3 47\n3 48\n3 49\n3 50\n3 51\n3 52\n3...", "1156\n1 35\n1 36\n1 37\n1 38\n1 39\n1 40\n1 41\n1 42\n1 43\n1 44\n1 45\n1 46\n1 47\n1 48\n1 49\n1 50\n1 51\n1 52\n1 53\n1 54\n1 55\n1 56\n1 57\n1 58\n1 59\n1 60\n1 61\n1 62\n1 63\n1 64\n1 65\n1 66\n1 67\n1 68\n2 35\n2 36\n2 37\n2 38\n2 39\n2 40\n2 41\n2 42\n2 43\n2 44\n2 45\n2 46\n2 47\n2 48\n2 49\n2 50\n2 51\n2 52\n2 53\n2 54\n2 55\n2 56\n2 57\n2 58\n2 59\n2 60\n2 61\n2 62\n2 63\n2 64\n2 65\n2 66\n2 67\n2 68\n3 35\n3 36\n3 37\n3 38\n3 39\n3 40\n3 41\n3 42\n3 43\n3 44\n3 45\n3 46\n3 47\n3 48\n3 49\n3 50\n3...", "1406\n1 38\n1 39\n1 40\n1 41\n1 42\n1 43\n1 44\n1 45\n1 46\n1 47\n1 48\n1 49\n1 50\n1 51\n1 52\n1 53\n1 54\n1 55\n1 56\n1 57\n1 58\n1 59\n1 60\n1 61\n1 62\n1 63\n1 64\n1 65\n1 66\n1 67\n1 68\n1 69\n1 70\n1 71\n1 72\n1 73\n1 74\n1 75\n2 38\n2 39\n2 40\n2 41\n2 42\n2 43\n2 44\n2 45\n2 46\n2 47\n2 48\n2 49\n2 50\n2 51\n2 52\n2 53\n2 54\n2 55\n2 56\n2 57\n2 58\n2 59\n2 60\n2 61\n2 62\n2 63\n2 64\n2 65\n2 66\n2 67\n2 68\n2 69\n2 70\n2 71\n2 72\n2 73\n2 74\n2 75\n3 38\n3 39\n3 40\n3 41\n3 42\n3 43\n3 44\n3 45\n3...", "1482\n1 39\n1 40\n1 41\n1 42\n1 43\n1 44\n1 45\n1 46\n1 47\n1 48\n1 49\n1 50\n1 51\n1 52\n1 53\n1 54\n1 55\n1 56\n1 57\n1 58\n1 59\n1 60\n1 61\n1 62\n1 63\n1 64\n1 65\n1 66\n1 67\n1 68\n1 69\n1 70\n1 71\n1 72\n1 73\n1 74\n1 75\n1 76\n1 77\n2 39\n2 40\n2 41\n2 42\n2 43\n2 44\n2 45\n2 46\n2 47\n2 48\n2 49\n2 50\n2 51\n2 52\n2 53\n2 54\n2 55\n2 56\n2 57\n2 58\n2 59\n2 60\n2 61\n2 62\n2 63\n2 64\n2 65\n2 66\n2 67\n2 68\n2 69\n2 70\n2 71\n2 72\n2 73\n2 74\n2 75\n2 76\n2 77\n3 39\n3 40\n3 41\n3 42\n3 43\n3 44\n3...", "1640\n1 41\n1 42\n1 43\n1 44\n1 45\n1 46\n1 47\n1 48\n1 49\n1 50\n1 51\n1 52\n1 53\n1 54\n1 55\n1 56\n1 57\n1 58\n1 59\n1 60\n1 61\n1 62\n1 63\n1 64\n1 65\n1 66\n1 67\n1 68\n1 69\n1 70\n1 71\n1 72\n1 73\n1 74\n1 75\n1 76\n1 77\n1 78\n1 79\n1 80\n1 81\n2 41\n2 42\n2 43\n2 44\n2 45\n2 46\n2 47\n2 48\n2 49\n2 50\n2 51\n2 52\n2 53\n2 54\n2 55\n2 56\n2 57\n2 58\n2 59\n2 60\n2 61\n2 62\n2 63\n2 64\n2 65\n2 66\n2 67\n2 68\n2 69\n2 70\n2 71\n2 72\n2 73\n2 74\n2 75\n2 76\n2 77\n2 78\n2 79\n2 80\n2 81\n3 41\n3 42\n3...", "1849\n1 44\n1 45\n1 46\n1 47\n1 48\n1 49\n1 50\n1 51\n1 52\n1 53\n1 54\n1 55\n1 56\n1 57\n1 58\n1 59\n1 60\n1 61\n1 62\n1 63\n1 64\n1 65\n1 66\n1 67\n1 68\n1 69\n1 70\n1 71\n1 72\n1 73\n1 74\n1 75\n1 76\n1 77\n1 78\n1 79\n1 80\n1 81\n1 82\n1 83\n1 84\n1 85\n1 86\n2 44\n2 45\n2 46\n2 47\n2 48\n2 49\n2 50\n2 51\n2 52\n2 53\n2 54\n2 55\n2 56\n2 57\n2 58\n2 59\n2 60\n2 61\n2 62\n2 63\n2 64\n2 65\n2 66\n2 67\n2 68\n2 69\n2 70\n2 71\n2 72\n2 73\n2 74\n2 75\n2 76\n2 77\n2 78\n2 79\n2 80\n2 81\n2 82\n2 83\n2 84\n2...", "1892\n1 44\n1 45\n1 46\n1 47\n1 48\n1 49\n1 50\n1 51\n1 52\n1 53\n1 54\n1 55\n1 56\n1 57\n1 58\n1 59\n1 60\n1 61\n1 62\n1 63\n1 64\n1 65\n1 66\n1 67\n1 68\n1 69\n1 70\n1 71\n1 72\n1 73\n1 74\n1 75\n1 76\n1 77\n1 78\n1 79\n1 80\n1 81\n1 82\n1 83\n1 84\n1 85\n1 86\n1 87\n2 44\n2 45\n2 46\n2 47\n2 48\n2 49\n2 50\n2 51\n2 52\n2 53\n2 54\n2 55\n2 56\n2 57\n2 58\n2 59\n2 60\n2 61\n2 62\n2 63\n2 64\n2 65\n2 66\n2 67\n2 68\n2 69\n2 70\n2 71\n2 72\n2 73\n2 74\n2 75\n2 76\n2 77\n2 78\n2 79\n2 80\n2 81\n2 82\n2 83\n2...", "1936\n1 45\n1 46\n1 47\n1 48\n1 49\n1 50\n1 51\n1 52\n1 53\n1 54\n1 55\n1 56\n1 57\n1 58\n1 59\n1 60\n1 61\n1 62\n1 63\n1 64\n1 65\n1 66\n1 67\n1 68\n1 69\n1 70\n1 71\n1 72\n1 73\n1 74\n1 75\n1 76\n1 77\n1 78\n1 79\n1 80\n1 81\n1 82\n1 83\n1 84\n1 85\n1 86\n1 87\n1 88\n2 45\n2 46\n2 47\n2 48\n2 49\n2 50\n2 51\n2 52\n2 53\n2 54\n2 55\n2 56\n2 57\n2 58\n2 59\n2 60\n2 61\n2 62\n2 63\n2 64\n2 65\n2 66\n2 67\n2 68\n2 69\n2 70\n2 71\n2 72\n2 73\n2 74\n2 75\n2 76\n2 77\n2 78\n2 79\n2 80\n2 81\n2 82\n2 83\n2 84\n2...", "1980\n1 45\n1 46\n1 47\n1 48\n1 49\n1 50\n1 51\n1 52\n1 53\n1 54\n1 55\n1 56\n1 57\n1 58\n1 59\n1 60\n1 61\n1 62\n1 63\n1 64\n1 65\n1 66\n1 67\n1 68\n1 69\n1 70\n1 71\n1 72\n1 73\n1 74\n1 75\n1 76\n1 77\n1 78\n1 79\n1 80\n1 81\n1 82\n1 83\n1 84\n1 85\n1 86\n1 87\n1 88\n1 89\n2 45\n2 46\n2 47\n2 48\n2 49\n2 50\n2 51\n2 52\n2 53\n2 54\n2 55\n2 56\n2 57\n2 58\n2 59\n2 60\n2 61\n2 62\n2 63\n2 64\n2 65\n2 66\n2 67\n2 68\n2 69\n2 70\n2 71\n2 72\n2 73\n2 74\n2 75\n2 76\n2 77\n2 78\n2 79\n2 80\n2 81\n2 82\n2 83\n2...", "2025\n1 46\n1 47\n1 48\n1 49\n1 50\n1 51\n1 52\n1 53\n1 54\n1 55\n1 56\n1 57\n1 58\n1 59\n1 60\n1 61\n1 62\n1 63\n1 64\n1 65\n1 66\n1 67\n1 68\n1 69\n1 70\n1 71\n1 72\n1 73\n1 74\n1 75\n1 76\n1 77\n1 78\n1 79\n1 80\n1 81\n1 82\n1 83\n1 84\n1 85\n1 86\n1 87\n1 88\n1 89\n1 90\n2 46\n2 47\n2 48\n2 49\n2 50\n2 51\n2 52\n2 53\n2 54\n2 55\n2 56\n2 57\n2 58\n2 59\n2 60\n2 61\n2 62\n2 63\n2 64\n2 65\n2 66\n2 67\n2 68\n2 69\n2 70\n2 71\n2 72\n2 73\n2 74\n2 75\n2 76\n2 77\n2 78\n2 79\n2 80\n2 81\n2 82\n2 83\n2 84\n2...", "2070\n1 46\n1 47\n1 48\n1 49\n1 50\n1 51\n1 52\n1 53\n1 54\n1 55\n1 56\n1 57\n1 58\n1 59\n1 60\n1 61\n1 62\n1 63\n1 64\n1 65\n1 66\n1 67\n1 68\n1 69\n1 70\n1 71\n1 72\n1 73\n1 74\n1 75\n1 76\n1 77\n1 78\n1 79\n1 80\n1 81\n1 82\n1 83\n1 84\n1 85\n1 86\n1 87\n1 88\n1 89\n1 90\n1 91\n2 46\n2 47\n2 48\n2 49\n2 50\n2 51\n2 52\n2 53\n2 54\n2 55\n2 56\n2 57\n2 58\n2 59\n2 60\n2 61\n2 62\n2 63\n2 64\n2 65\n2 66\n2 67\n2 68\n2 69\n2 70\n2 71\n2 72\n2 73\n2 74\n2 75\n2 76\n2 77\n2 78\n2 79\n2 80\n2 81\n2 82\n2 83\n2...", "2116\n1 47\n1 48\n1 49\n1 50\n1 51\n1 52\n1 53\n1 54\n1 55\n1 56\n1 57\n1 58\n1 59\n1 60\n1 61\n1 62\n1 63\n1 64\n1 65\n1 66\n1 67\n1 68\n1 69\n1 70\n1 71\n1 72\n1 73\n1 74\n1 75\n1 76\n1 77\n1 78\n1 79\n1 80\n1 81\n1 82\n1 83\n1 84\n1 85\n1 86\n1 87\n1 88\n1 89\n1 90\n1 91\n1 92\n2 47\n2 48\n2 49\n2 50\n2 51\n2 52\n2 53\n2 54\n2 55\n2 56\n2 57\n2 58\n2 59\n2 60\n2 61\n2 62\n2 63\n2 64\n2 65\n2 66\n2 67\n2 68\n2 69\n2 70\n2 71\n2 72\n2 73\n2 74\n2 75\n2 76\n2 77\n2 78\n2 79\n2 80\n2 81\n2 82\n2 83\n2 84\n2...", "2162\n1 47\n1 48\n1 49\n1 50\n1 51\n1 52\n1 53\n1 54\n1 55\n1 56\n1 57\n1 58\n1 59\n1 60\n1 61\n1 62\n1 63\n1 64\n1 65\n1 66\n1 67\n1 68\n1 69\n1 70\n1 71\n1 72\n1 73\n1 74\n1 75\n1 76\n1 77\n1 78\n1 79\n1 80\n1 81\n1 82\n1 83\n1 84\n1 85\n1 86\n1 87\n1 88\n1 89\n1 90\n1 91\n1 92\n1 93\n2 47\n2 48\n2 49\n2 50\n2 51\n2 52\n2 53\n2 54\n2 55\n2 56\n2 57\n2 58\n2 59\n2 60\n2 61\n2 62\n2 63\n2 64\n2 65\n2 66\n2 67\n2 68\n2 69\n2 70\n2 71\n2 72\n2 73\n2 74\n2 75\n2 76\n2 77\n2 78\n2 79\n2 80\n2 81\n2 82\n2 83\n2...", "2209\n1 48\n1 49\n1 50\n1 51\n1 52\n1 53\n1 54\n1 55\n1 56\n1 57\n1 58\n1 59\n1 60\n1 61\n1 62\n1 63\n1 64\n1 65\n1 66\n1 67\n1 68\n1 69\n1 70\n1 71\n1 72\n1 73\n1 74\n1 75\n1 76\n1 77\n1 78\n1 79\n1 80\n1 81\n1 82\n1 83\n1 84\n1 85\n1 86\n1 87\n1 88\n1 89\n1 90\n1 91\n1 92\n1 93\n1 94\n2 48\n2 49\n2 50\n2 51\n2 52\n2 53\n2 54\n2 55\n2 56\n2 57\n2 58\n2 59\n2 60\n2 61\n2 62\n2 63\n2 64\n2 65\n2 66\n2 67\n2 68\n2 69\n2 70\n2 71\n2 72\n2 73\n2 74\n2 75\n2 76\n2 77\n2 78\n2 79\n2 80\n2 81\n2 82\n2 83\n2 84\n2...", "2256\n1 48\n1 49\n1 50\n1 51\n1 52\n1 53\n1 54\n1 55\n1 56\n1 57\n1 58\n1 59\n1 60\n1 61\n1 62\n1 63\n1 64\n1 65\n1 66\n1 67\n1 68\n1 69\n1 70\n1 71\n1 72\n1 73\n1 74\n1 75\n1 76\n1 77\n1 78\n1 79\n1 80\n1 81\n1 82\n1 83\n1 84\n1 85\n1 86\n1 87\n1 88\n1 89\n1 90\n1 91\n1 92\n1 93\n1 94\n1 95\n2 48\n2 49\n2 50\n2 51\n2 52\n2 53\n2 54\n2 55\n2 56\n2 57\n2 58\n2 59\n2 60\n2 61\n2 62\n2 63\n2 64\n2 65\n2 66\n2 67\n2 68\n2 69\n2 70\n2 71\n2 72\n2 73\n2 74\n2 75\n2 76\n2 77\n2 78\n2 79\n2 80\n2 81\n2 82\n2 83\n2...", "2304\n1 49\n1 50\n1 51\n1 52\n1 53\n1 54\n1 55\n1 56\n1 57\n1 58\n1 59\n1 60\n1 61\n1 62\n1 63\n1 64\n1 65\n1 66\n1 67\n1 68\n1 69\n1 70\n1 71\n1 72\n1 73\n1 74\n1 75\n1 76\n1 77\n1 78\n1 79\n1 80\n1 81\n1 82\n1 83\n1 84\n1 85\n1 86\n1 87\n1 88\n1 89\n1 90\n1 91\n1 92\n1 93\n1 94\n1 95\n1 96\n2 49\n2 50\n2 51\n2 52\n2 53\n2 54\n2 55\n2 56\n2 57\n2 58\n2 59\n2 60\n2 61\n2 62\n2 63\n2 64\n2 65\n2 66\n2 67\n2 68\n2 69\n2 70\n2 71\n2 72\n2 73\n2 74\n2 75\n2 76\n2 77\n2 78\n2 79\n2 80\n2 81\n2 82\n2 83\n2 84\n2...", "2352\n1 49\n1 50\n1 51\n1 52\n1 53\n1 54\n1 55\n1 56\n1 57\n1 58\n1 59\n1 60\n1 61\n1 62\n1 63\n1 64\n1 65\n1 66\n1 67\n1 68\n1 69\n1 70\n1 71\n1 72\n1 73\n1 74\n1 75\n1 76\n1 77\n1 78\n1 79\n1 80\n1 81\n1 82\n1 83\n1 84\n1 85\n1 86\n1 87\n1 88\n1 89\n1 90\n1 91\n1 92\n1 93\n1 94\n1 95\n1 96\n1 97\n2 49\n2 50\n2 51\n2 52\n2 53\n2 54\n2 55\n2 56\n2 57\n2 58\n2 59\n2 60\n2 61\n2 62\n2 63\n2 64\n2 65\n2 66\n2 67\n2 68\n2 69\n2 70\n2 71\n2 72\n2 73\n2 74\n2 75\n2 76\n2 77\n2 78\n2 79\n2 80\n2 81\n2 82\n2 83\n2...", "2401\n1 50\n1 51\n1 52\n1 53\n1 54\n1 55\n1 56\n1 57\n1 58\n1 59\n1 60\n1 61\n1 62\n1 63\n1 64\n1 65\n1 66\n1 67\n1 68\n1 69\n1 70\n1 71\n1 72\n1 73\n1 74\n1 75\n1 76\n1 77\n1 78\n1 79\n1 80\n1 81\n1 82\n1 83\n1 84\n1 85\n1 86\n1 87\n1 88\n1 89\n1 90\n1 91\n1 92\n1 93\n1 94\n1 95\n1 96\n1 97\n1 98\n2 50\n2 51\n2 52\n2 53\n2 54\n2 55\n2 56\n2 57\n2 58\n2 59\n2 60\n2 61\n2 62\n2 63\n2 64\n2 65\n2 66\n2 67\n2 68\n2 69\n2 70\n2 71\n2 72\n2 73\n2 74\n2 75\n2 76\n2 77\n2 78\n2 79\n2 80\n2 81\n2 82\n2 83\n2 84\n2...", "2450\n1 50\n1 51\n1 52\n1 53\n1 54\n1 55\n1 56\n1 57\n1 58\n1 59\n1 60\n1 61\n1 62\n1 63\n1 64\n1 65\n1 66\n1 67\n1 68\n1 69\n1 70\n1 71\n1 72\n1 73\n1 74\n1 75\n1 76\n1 77\n1 78\n1 79\n1 80\n1 81\n1 82\n1 83\n1 84\n1 85\n1 86\n1 87\n1 88\n1 89\n1 90\n1 91\n1 92\n1 93\n1 94\n1 95\n1 96\n1 97\n1 98\n1 99\n2 50\n2 51\n2 52\n2 53\n2 54\n2 55\n2 56\n2 57\n2 58\n2 59\n2 60\n2 61\n2 62\n2 63\n2 64\n2 65\n2 66\n2 67\n2 68\n2 69\n2 70\n2 71\n2 72\n2 73\n2 74\n2 75\n2 76\n2 77\n2 78\n2 79\n2 80\n2 81\n2 82\n2 83\n2...", "2500\n1 51\n1 52\n1 53\n1 54\n1 55\n1 56\n1 57\n1 58\n1 59\n1 60\n1 61\n1 62\n1 63\n1 64\n1 65\n1 66\n1 67\n1 68\n1 69\n1 70\n1 71\n1 72\n1 73\n1 74\n1 75\n1 76\n1 77\n1 78\n1 79\n1 80\n1 81\n1 82\n1 83\n1 84\n1 85\n1 86\n1 87\n1 88\n1 89\n1 90\n1 91\n1 92\n1 93\n1 94\n1 95\n1 96\n1 97\n1 98\n1 99\n1 100\n2 51\n2 52\n2 53\n2 54\n2 55\n2 56\n2 57\n2 58\n2 59\n2 60\n2 61\n2 62\n2 63\n2 64\n2 65\n2 66\n2 67\n2 68\n2 69\n2 70\n2 71\n2 72\n2 73\n2 74\n2 75\n2 76\n2 77\n2 78\n2 79\n2 80\n2 81\n2 82\n2 83\n2 84\n..."]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 7 | codeforces |
|
5178b46518ed8b00d8287e9a143991df | New Year Tree | The New Year holidays are over, but Resha doesn't want to throw away the New Year tree. He invited his best friends Kerim and Gural to help him to redecorate the New Year tree.
The New Year tree is an undirected tree with *n* vertices and root in the vertex 1.
You should process the queries of the two types:
1. Change the colours of all vertices in the subtree of the vertex *v* to the colour *c*. 1. Find the number of different colours in the subtree of the vertex *v*.
The first line contains two integers *n*,<=*m* (1<=β€<=*n*,<=*m*<=β€<=4Β·105) β the number of vertices in the tree and the number of the queries.
The second line contains *n* integers *c**i* (1<=β€<=*c**i*<=β€<=60) β the colour of the *i*-th vertex.
Each of the next *n*<=-<=1 lines contains two integers *x**j*,<=*y**j* (1<=β€<=*x**j*,<=*y**j*<=β€<=*n*) β the vertices of the *j*-th edge. It is guaranteed that you are given correct undirected tree.
The last *m* lines contains the description of the queries. Each description starts with the integer *t**k* (1<=β€<=*t**k*<=β€<=2) β the type of the *k*-th query. For the queries of the first type then follows two integers *v**k*,<=*c**k* (1<=β€<=*v**k*<=β€<=*n*,<=1<=β€<=*c**k*<=β€<=60) β the number of the vertex whose subtree will be recoloured with the colour *c**k*. For the queries of the second type then follows integer *v**k* (1<=β€<=*v**k*<=β€<=*n*) β the number of the vertex for which subtree you should find the number of different colours.
For each query of the second type print the integer *a* β the number of different colours in the subtree of the vertex given in the query.
Each of the numbers should be printed on a separate line in order of query appearing in the input.
Sample Input
7 10
1 1 1 1 1 1 1
1 2
1 3
1 4
3 5
3 6
3 7
1 3 2
2 1
1 4 3
2 1
1 2 5
2 1
1 6 4
2 1
2 2
2 3
23 30
1 2 2 6 5 3 2 1 1 1 2 4 5 3 4 4 3 3 3 3 3 4 6
1 2
1 3
1 4
2 5
2 6
3 7
3 8
4 9
4 10
4 11
6 12
6 13
7 14
7 15
7 16
8 17
8 18
10 19
10 20
10 21
11 22
11 23
2 1
2 5
2 6
2 7
2 8
2 9
2 10
2 11
2 4
1 12 1
1 13 1
1 14 1
1 15 1
1 16 1
1 17 1
1 18 1
1 19 1
1 20 1
1 21 1
1 22 1
1 23 1
2 1
2 5
2 6
2 7
2 8
2 9
2 10
2 11
2 4
Sample Output
2
3
4
5
1
2
6
1
3
3
2
1
2
3
5
5
1
2
2
1
1
1
2
3
| {"inputs": ["7 10\n1 1 1 1 1 1 1\n1 2\n1 3\n1 4\n3 5\n3 6\n3 7\n1 3 2\n2 1\n1 4 3\n2 1\n1 2 5\n2 1\n1 6 4\n2 1\n2 2\n2 3", "23 30\n1 2 2 6 5 3 2 1 1 1 2 4 5 3 4 4 3 3 3 3 3 4 6\n1 2\n1 3\n1 4\n2 5\n2 6\n3 7\n3 8\n4 9\n4 10\n4 11\n6 12\n6 13\n7 14\n7 15\n7 16\n8 17\n8 18\n10 19\n10 20\n10 21\n11 22\n11 23\n2 1\n2 5\n2 6\n2 7\n2 8\n2 9\n2 10\n2 11\n2 4\n1 12 1\n1 13 1\n1 14 1\n1 15 1\n1 16 1\n1 17 1\n1 18 1\n1 19 1\n1 20 1\n1 21 1\n1 22 1\n1 23 1\n2 1\n2 5\n2 6\n2 7\n2 8\n2 9\n2 10\n2 11\n2 4", "1 1\n14\n2 1", "1 1\n36\n2 1", "1 1\n3\n2 1", "1 1\n43\n2 1", "1 1\n41\n2 1", "10 10\n59 59 59 59 59 59 59 59 59 59\n6 8\n6 10\n2 6\n2 5\n7 2\n10 1\n4 2\n7 3\n9 1\n1 8 59\n2 8\n1 3 59\n1 4 59\n1 8 59\n1 2 59\n1 5 59\n1 10 59\n2 2\n2 5", "10 10\n8 8 14 32 14 8 32 8 14 32\n4 5\n4 1\n4 8\n4 9\n7 4\n2 5\n3 5\n4 6\n10 4\n2 2\n1 9 8\n1 1 40\n1 7 32\n1 4 8\n2 8\n1 1 8\n2 2\n2 8\n2 4", "10 10\n39 50 50 7 39 7 46 7 39 7\n10 7\n7 3\n3 5\n3 4\n6 4\n1 4\n1 8\n8 2\n2 9\n2 8\n1 6 50\n2 4\n2 6\n1 7 39\n1 3 39\n2 9\n1 1 15\n2 7\n1 10 7", "10 10\n23 25 23 42 23 53 49 40 28 44\n1 7\n1 2\n2 4\n4 10\n8 10\n6 8\n3 8\n5 3\n9 5\n2 10\n1 6 52\n1 8 43\n2 3\n1 4 39\n1 8 44\n1 9 39\n2 1\n2 4\n1 6 36", "10 10\n16 25 25 27 39 29 29 58 50 30\n8 2\n2 10\n4 2\n2 1\n6 2\n2 3\n9 2\n5 2\n2 7\n2 4\n1 3 31\n2 5\n1 7 27\n1 4 56\n1 4 52\n1 5 25\n1 6 32\n1 6 22\n1 7 42", "10 10\n60 46 56 7 4 27 43 28 4 9\n1 5\n5 8\n10 8\n10 6\n7 6\n2 10\n4 2\n9 4\n9 3\n2 3\n1 9 57\n2 2\n1 6 50\n1 5 34\n1 8 45\n1 9 39\n2 2\n1 10 1\n2 4", "10 10\n15 39 52 24 36 30 46 21 40 24\n5 9\n5 3\n5 10\n1 3\n9 4\n9 8\n9 7\n7 2\n3 6\n1 4 47\n1 7 25\n1 10 42\n2 10\n1 2 18\n1 1 60\n1 7 56\n2 7\n2 9\n2 10", "10 10\n39 28 21 20 11 11 40 30 42 14\n7 1\n10 1\n6 1\n1 9\n5 1\n8 1\n1 3\n1 4\n2 10\n1 7 55\n2 3\n1 8 18\n1 10 48\n2 7\n1 6 26\n2 2\n1 1 4\n2 9\n1 5 31"], "outputs": ["2\n3\n4\n5\n1\n2", "6\n1\n3\n3\n2\n1\n2\n3\n5\n5\n1\n2\n2\n1\n1\n1\n2\n3", "1", "1", "1", "1", "1", "1\n1\n1", "1\n1\n1\n1\n1", "3\n4\n1\n1\n1", "5\n1\n5\n2", "1\n1", "1\n3\n2\n1", "1\n1\n2\n1", "1\n1\n1\n1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces |
|
517c2823ba28b9c195cdcd650d4db4fb | 2 + 2 != 4 | One very experienced problem writer decided to prepare a problem for April Fools Day contest. The task was very simple - given an arithmetic expression, return the result of evaluating this expression. However, looks like there is a bug in the reference solution...
The only line of input data contains the arithmetic expression. The expression will contain between 2 and 10 operands, separated with arithmetic signs plus and/or minus. Each operand will be an integer between 0 and 255, inclusive.
Reproduce the output of the reference solution, including the bug.
Sample Input
8-7+6-5+4-3+2-1-0
2+2
112-37
Sample Output
4
-46
375
| {"inputs": ["8-7+6-5+4-3+2-1-0", "2+2", "112-37", "255+255+255+255+255+255+255+255+255+255", "0-255-255-255-255-255-255-255-255-255", "0+0+0+0+0+0+0+0+0+0", "0-0-0-0-0-0-0-0-0-0", "0+100+100+100+100+100+100+100+100+100", "255-100-100-100-100-100-100-100-100-100", "45+5", "23+6-9", "123+234-56-78-90", "97+67+12+9+42+45+13", "9-109-22+23-87+27-40+10", "66-165-34+209+76", "150+222-3-90-248-187+198", "136+90-200+6-102", "255-12-34-56-69-78-90", "243-173+90-56+78-53+53-21", "131+49+249+71-251-61+159-111+51", "5-9-1-3+6+4-7+8-2", "101+200+195+231+107+222+146+254+160+209", "240-120-234-156-207-189", "1-2+3-4+5-6", "9-8+7-6+5-4+3-2+1-0"], "outputs": ["4", "-46", "375", "-42450", "24705", "-450", "270", "-44100", "26355", "0", "0", "-3967", "-2265", "2211", "-2048", "-3628", "5380", "1716", "2561", "-4913", "1", "-43175", "14334", "-13", "-45"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces |
|
51871bcfc6ef6119fe456069494bd418 | Tricky Alchemy | During the winter holidays, the demand for Christmas balls is exceptionally high. Since it's already 2018, the advances in alchemy allow easy and efficient ball creation by utilizing magic crystals.
Grisha needs to obtain some yellow, green and blue balls. It's known that to produce a yellow ball one needs two yellow crystals, greenΒ β one yellow and one blue, and for a blue ball, three blue crystals are enough.
Right now there are *A* yellow and *B* blue crystals in Grisha's disposal. Find out how many additional crystals he should acquire in order to produce the required number of balls.
The first line features two integers *A* and *B* (0<=β€<=*A*,<=*B*<=β€<=109), denoting the number of yellow and blue crystals respectively at Grisha's disposal.
The next line contains three integers *x*, *y* and *z* (0<=β€<=*x*,<=*y*,<=*z*<=β€<=109)Β β the respective amounts of yellow, green and blue balls to be obtained.
Print a single integerΒ β the minimum number of crystals that Grisha should acquire in addition.
Sample Input
4 3
2 1 1
3 9
1 1 3
12345678 87654321
43043751 1000000000 53798715
Sample Output
2
1
2147483648
| {"inputs": ["4 3\n2 1 1", "3 9\n1 1 3", "12345678 87654321\n43043751 1000000000 53798715", "12 12\n3 5 2", "770 1390\n170 442 311", "3555165 6693472\n1499112 556941 3075290", "0 0\n1000000000 1000000000 1000000000", "1 1\n0 1 0", "117708228 562858833\n118004008 360437130 154015822", "999998118 700178721\n822106746 82987112 547955384", "566568710 765371101\n60614022 80126928 809950465", "448858599 829062060\n764716760 97644201 203890025", "626115781 966381948\n395190569 820194184 229233367", "803372962 103701834\n394260597 837711458 623172928", "980630143 241021722\n24734406 928857659 312079781", "862920032 378341609\n360240924 241342224 337423122", "40177212 515661496\n64343660 963892207 731362684", "217434393 579352456\n694817470 981409480 756706026", "394691574 716672343\n398920207 72555681 150645586", "276981463 853992230\n29394015 90072954 839552440", "843552056 919184611\n341530221 423649259 101547519", "20809236 56504497\n972004030 441166533 495487081", "198066417 825228166\n602477839 532312735 520830423", "80356306 962548053\n601547868 549830008 914769984", "257613487 394835231\n642087093 567347282 308709545", "139903376 532155119\n641157122 289897263 629020178", "612127849 669475006\n271630930 676010757 22959739", "0 0\n0 0 0", "1000000000 1000000000\n499999998 4 333333332", "1000000000 1000000000\n1000000000 1000000000 1000000000", "4 3\n1 0 1", "4 12\n1 2 3", "4 20\n1 2 1", "100 10\n2 3 4", "6 0\n1 1 1", "25 5\n3 3 3", "48 27\n22 39 20", "4 0\n1 1 1"], "outputs": ["2", "1", "2147483648", "0", "12", "3089339", "7000000000", "0", "738362681", "1753877029", "1744607222", "1178219122", "1525971878", "3426388098", "1624075280", "974174021", "3694721078", "4825785129", "475704521", "1754738044", "263157645", "4235488636", "2808777834", "4004161345", "2692548667", "3077110809", "682559736", "0", "0", "5000000000", "0", "0", "0", "5", "4", "7", "107", "4"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 401 | codeforces |
|
519044032d5415fdfdd43cc483036c0a | Test | Sometimes it is hard to prepare tests for programming problems. Now Bob is preparing tests to new problem about strings β input data to his problem is one string. Bob has 3 wrong solutions to this problem. The first gives the wrong answer if the input data contains the substring *s*1, the second enters an infinite loop if the input data contains the substring *s*2, and the third requires too much memory if the input data contains the substring *s*3. Bob wants these solutions to fail single test. What is the minimal length of test, which couldn't be passed by all three Bob's solutions?
There are exactly 3 lines in the input data. The *i*-th line contains string *s**i*. All the strings are non-empty, consists of lowercase Latin letters, the length of each string doesn't exceed 105.
Output one number β what is minimal length of the string, containing *s*1, *s*2 and *s*3 as substrings.
Sample Input
ab
bc
cd
abacaba
abaaba
x
Sample Output
4
11
| {"inputs": ["ab\nbc\ncd", "abacaba\nabaaba\nx", "syvncqmfhautvxudqdhggz\nhrpxzeghsocjpicuixskfuzupytsgjsdiyb\nybcmnmnbpndbxlxbzhbfnqvwcffvrdhtickyqhupmcehls", "jwdezvgfm\nmdoqvylpuvyk\nqylldbziva", "ujgquqxdlowuwnqkmbd\nwdwkhkdgsujgqu\njlxqvcuivagmw", "rdtevvmiqmfgvafkdypxjthzhfsbavmhgkavkfonscaokdxoscenpxrc\nijbvueenzsmgkmkrskjspvfchwkqdglkxnrdtevvmiqmfgvafkdypxjthz\nkqdglkxnrdtevvmiqmfgvafkdypxjthzhfsbavmhgkavkfonscaokdxoscenpxrcivydtkrxjy", "xufuzdlsjxmevrtessfbwlnzzclcqwevnnucxyvhngnxhcbdfwq\nwlwobhnmmgtfolfaeckbrnnglylydxtgtvrlmeeszoiuatzzzxufuzdlsjxmevrt\nbrnnglylydxtgtvrlmeeszoiuatzzzx", "iefouqzxoyuieqdzalfktehtvdbvjmeubju\nocotspetkkhvwfgaqynhovjwjhciefouqzxoyuieqdzalfktehtvdbvjmeubjubcmnvpwgdpnchqhzjrchyrfpvigubp\nycnhjwgbocotspetkkhvwfgaqynhovjwjhcief"], "outputs": ["4", "11", "100", "30", "40", "100", "100", "100"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces |
|
519062580288920390ab5b9c5f1e5dd1 | Divisible by Seven | You have number *a*, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.
Number *a* doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting number also mustn't contain any leading zeroes.
The first line contains positive integer *a* in the decimal record. It is guaranteed that the record of number *a* contains digits: 1, 6, 8, 9. Number *a* doesn't contain any leading zeroes. The decimal representation of number *a* contains at least 4 and at most 106 characters.
Print a number in the decimal notation without leading zeroes β the result of the permutation.
If it is impossible to rearrange the digits of the number *a* in the required manner, print 0.
Sample Input
1689
18906
Sample Output
1869
18690
| {"inputs": ["1689", "18906", "2419323689", "8589157262", "2717172350336955863014903670481525170997949309274087058935108848979319747543008692128164875210350026", "9825995656040286793128006047268547610068699214477842995873286607346639816314908021369221299622234988", "100000000689", "16891", "16892", "16893", "16894", "16895", "16896", "16897", "16898", "16899", "4048169", "10994168", "168903", "11689", "91111168", "16890000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "1689999999999", "9883291673084", "6198"], "outputs": ["1869", "18690", "2432391689", "5857221986", "2771723503355630149036704815251709979493092740870589351088489793197475430086921281648752103500261986", "2599556040286793280060472685476100686992144778429958732866073466398163149080213692212996222349881968", "186900000000", "16198", "21896", "31689", "41986", "51968", "61698", "71869", "86198", "91896", "4041968", "94116890", "316890", "16198", "11111968", "18690000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "9999999991968", "8329730841698", "1869"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 13 | codeforces |
|
51911583dab871f5ea0ac52588a84b8b | Antimatter | Iahub accidentally discovered a secret lab. He found there *n* devices ordered in a line, numbered from 1 to *n* from left to right. Each device *i* (1<=β€<=*i*<=β€<=*n*) can create either *a**i* units of matter or *a**i* units of antimatter.
Iahub wants to choose some contiguous subarray of devices in the lab, specify the production mode for each of them (produce matter or antimatter) and finally take a photo of it. However he will be successful only if the amounts of matter and antimatter produced in the selected subarray will be the same (otherwise there would be overflowing matter or antimatter in the photo).
You are requested to compute the number of different ways Iahub can successful take a photo. A photo is different than another if it represents another subarray, or if at least one device of the subarray is set to produce matter in one of the photos and antimatter in the other one.
The first line contains an integer *n* (1<=β€<=*n*<=β€<=1000). The second line contains *n* integers *a*1, *a*2, ..., *a**n* (1<=β€<=*a**i*<=β€<=1000).
The sum *a*1<=+<=*a*2<=+<=...<=+<=*a**n* will be less than or equal to 10000.
Output a single integer, the number of ways Iahub can take a photo, modulo 1000000007 (109<=+<=7).
Sample Input
4
1 1 1 1
Sample Output
12
| {"inputs": ["4\n1 1 1 1", "10\n16 9 9 11 10 12 9 6 10 8", "50\n2 1 5 2 1 3 1 2 3 2 1 1 5 2 2 2 3 2 1 2 2 2 3 3 1 3 1 1 2 2 2 2 1 2 3 1 2 4 1 1 1 3 2 1 1 1 3 2 1 3", "100\n8 3 3 7 3 6 4 6 9 4 6 5 5 5 4 3 4 2 3 5 3 6 5 3 6 5 6 6 2 6 4 5 5 4 6 4 3 2 8 5 6 6 7 4 4 9 5 6 6 3 7 1 6 2 6 5 9 3 8 6 2 6 3 2 4 4 3 5 4 7 6 5 4 6 3 5 6 8 8 6 3 7 7 1 4 6 8 6 5 3 7 8 4 7 5 3 8 5 4 4", "250\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", "250\n6 1 4 3 3 7 4 5 3 2 4 4 2 5 4 2 1 7 6 2 4 5 3 3 4 5 3 4 5 4 6 4 6 5 3 3 1 5 4 5 3 4 2 4 2 5 1 4 3 3 3 2 6 6 4 7 2 6 5 3 3 6 5 2 1 3 3 5 2 2 3 7 3 5 6 4 7 3 5 3 4 5 5 4 11 5 1 5 3 3 3 1 4 6 4 4 5 5 5 5 2 5 5 3 2 2 5 6 10 5 4 2 5 4 2 5 5 3 4 2 5 4 3 2 4 4 2 5 4 1 5 3 9 6 4 6 3 5 4 5 3 6 7 4 5 5 3 6 2 6 3 3 4 5 6 3 3 3 5 2 4 4 4 5 4 2 5 4 6 5 3 3 6 3 1 5 6 5 4 6 2 3 4 4 5 2 1 7 4 5 5 5 2 2 7 6 1 5 3 2 7 5 8 2 2 2 3 5 2 4 4 2 2 6 4 6 3 2 8 3 4 7 3 2 7 3 5 5 3 2 2 4 5 3 4 3 5 3 5 4 3 1 2 4 7 4 2 3 3 5", "250\n2 2 2 2 3 2 4 2 3 2 5 1 2 3 4 4 5 3 5 1 2 5 2 3 5 3 2 3 3 3 5 1 5 5 5 4 1 3 2 5 1 2 3 5 3 3 5 2 1 1 3 3 5 1 4 2 3 3 2 2 3 5 5 4 1 4 1 5 1 3 3 4 1 5 2 5 5 3 2 4 4 4 4 3 5 1 3 4 3 4 2 1 4 3 5 1 2 3 4 2 5 5 3 2 5 3 5 4 2 3 2 3 1 1 2 4 2 5 2 3 3 2 4 5 4 2 2 5 5 5 5 4 3 4 5 2 2 3 3 4 5 1 5 5 2 5 1 5 5 4 4 1 4 2 1 2 1 2 2 3 1 4 5 4 2 4 5 1 1 3 2 1 4 1 5 2 3 1 2 3 2 3 3 2 4 2 5 5 2 3 4 2 2 4 2 4 1 5 5 3 1 3 4 5 2 5 5 1 3 1 3 3 2 5 3 5 2 4 3 5 5 3 3 2 3 2 5 3 4 3 5 3 3 4 5 3 1 2 2 5 4 4 5 1 4 1 2 5 2 3", "1\n1", "2\n1 1", "2\n1000 1000", "2\n1 2", "3\n1 2 4", "3\n1 2 2", "1\n1000", "3\n999 999 999"], "outputs": ["12", "86", "115119382", "450259307", "533456111", "377970747", "257270797", "0", "2", "2", "0", "0", "2", "0", "4"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces |
|
51b23f121a010950ffd4756d31d02d4a | Fafa and Ancient Alphabet | Ancient Egyptians are known to have used a large set of symbols to write on the walls of the temples. Fafa and Fifa went to one of the temples and found two non-empty words *S*1 and *S*2 of equal lengths on the wall of temple written one below the other. Since this temple is very ancient, some symbols from the words were erased. The symbols in the set have equal probability for being in the position of any erased symbol.
Fifa challenged Fafa to calculate the probability that *S*1 is lexicographically greater than *S*2. Can you help Fafa with this task?
You know that , i.Β e. there were *m* distinct characters in Egyptians' alphabet, in this problem these characters are denoted by integers from 1 to *m* in alphabet order. A word *x* is lexicographically greater than a word *y* of the same length, if the words are same up to some position, and then the word *x* has a larger character, than the word *y*.
We can prove that the probability equals to some fraction , where *P* and *Q* are coprime integers, and . Print as the answer the value , i.Β e. such a non-negative integer less than 109<=+<=7, such that , where means that *a* and *b* give the same remainders when divided by *m*.
The first line contains two integers *n* and *m* (1<=β€<=*n*,<=<=*m*<=β€<=105) β the length of each of the two words and the size of the alphabet , respectively.
The second line contains *n* integers *a*1,<=*a*2,<=...,<=*a**n* (0<=β€<=*a**i*<=β€<=*m*) β the symbols of *S*1. If *a**i*<==<=0, then the symbol at position *i* was erased.
The third line contains *n* integers representing *S*2 with the same format as *S*1.
Print the value , where *P* and *Q* are coprime and is the answer to the problem.
Sample Input
1 2
0
1
1 2
1
0
7 26
0 15 12 9 13 0 14
11 1 0 13 15 12 0
Sample Output
500000004
0
230769233
| {"inputs": ["1 2\n0\n1", "1 2\n1\n0", "7 26\n0 15 12 9 13 0 14\n11 1 0 13 15 12 0", "6 26\n14 5 19 18 9 14\n0 0 0 0 0 0", "4 26\n0 0 0 0\n13 15 18 1", "5 100\n0 0 0 0 0\n0 0 0 0 0", "7 30\n11 1 0 13 15 12 0\n0 15 12 9 13 0 14", "4 50\n19 1 19 1\n19 1 19 15", "4 50\n19 1 19 15\n19 1 19 1", "107 100000\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "34 20\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "10 100000\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0", "100 100000\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "5 27\n25 0 6 0 0\n0 24 2 0 14", "5 27\n0 24 2 0 14\n25 0 6 0 0", "8 27\n20 5 6 1 6 1 6 1\n20 5 6 1 6 1 6 1", "10 100000\n0 0 0 0 0 0 0 0 0 0\n17249 88822 85448 44244 91609 68248 2971 11280 92940 19585", "10 100000\n74605 69376 14926 60793 94578 72935 86959 78140 97122 47320\n0 0 0 0 0 0 0 0 0 0", "10 100000\n65970 55981 23160 61003 12898 65502 60210 86706 29731 95712\n23450 82634 77108 10047 40650 69111 70947 44999 1304 7760", "10 85645\n7599 0 0 0 21264 0 0 0 68545 0\n67886 24576 72894 0 0 59979 14715 0 12822 6265", "10 87817\n86287 30778 0 66706 25545 59637 0 81488 47915 63800\n30067 4553 0 0 0 26765 81163 24777 16517 32518", "10 95854\n1879 78538 0 34766 1893 89997 69204 94054 0 0\n62148 62838 62104 88228 6930 57539 9897 37830 7336 95377", "10 98026\n68996 54116 0 21132 18444 0 24468 49121 55132 67144\n12505 0 39174 63502 0 6134 95276 64690 74791 47771", "10 90086\n41910 22500 6101 0 0 0 34790 9614 0 83351\n11155 21861 0 19394 81349 53888 33712 3834 17500 48357", "10 92258\n49583 2716 75176 0 90723 67482 14300 72653 56300 73929\n12163 619 44775 73277 80327 39278 0 0 0 71268", "10 70294\n0 0 22537 42830 0 65446 0 23427 60461 13653\n8888 69738 9505 29182 32466 18003 49610 192 7905 12002", "10 96602\n90709 0 10976 18427 0 13508 8299 7659 69934 0\n80891 15064 7805 4204 52322 10621 3779 7261 14059 90207", "5 1\n0 0 0 0 0\n0 0 0 0 0", "8 1\n0 0 0 0 0 0 0 0\n0 1 0 0 0 0 0 0", "5 1\n1 1 1 1 1\n0 0 0 0 0"], "outputs": ["500000004", "0", "230769233", "182369325", "306407779", "907142864", "333333336", "0", "1", "771105300", "591011954", "715785945", "792381120", "832647469", "167352539", "0", "290890611", "86514169", "1", "0", "1", "0", "1", "1", "1", "389886462", "1", "0", "0", "0"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces |
|
51cf8476c1c8c68b031ab3f1f1625c98 | Points on the line | We've got no test cases. A big olympiad is coming up. But the problemsetters' number one priority should be adding another problem to the round.
The diameter of a multiset of points on the line is the largest distance between two points from this set. For example, the diameter of the multiset {1,<=3,<=2,<=1} is 2.
Diameter of multiset consisting of one point is 0.
You are given *n* points on the line. What is the minimum number of points you have to remove, so that the diameter of the multiset of the remaining points will not exceed *d*?
The first line contains two integers *n* and *d* (1<=β€<=*n*<=β€<=100,<=0<=β€<=*d*<=β€<=100)Β β the amount of points and the maximum allowed diameter respectively.
The second line contains *n* space separated integers (1<=β€<=*x**i*<=β€<=100)Β β the coordinates of the points.
Output a single integerΒ β the minimum number of points you have to remove.
Sample Input
3 1
2 1 4
3 0
7 7 7
6 3
1 3 4 6 9 10
Sample Output
1
0
3
| {"inputs": ["3 1\n2 1 4", "3 0\n7 7 7", "6 3\n1 3 4 6 9 10", "11 5\n10 11 12 13 14 15 16 17 18 19 20", "1 100\n1", "100 10\n22 75 26 45 72 81 47 29 97 2 75 25 82 84 17 56 32 2 28 37 57 39 18 11 79 6 40 68 68 16 40 63 93 49 91 10 55 68 31 80 57 18 34 28 76 55 21 80 22 45 11 67 67 74 91 4 35 34 65 80 21 95 1 52 25 31 2 53 96 22 89 99 7 66 32 2 68 33 75 92 84 10 94 28 54 12 9 80 43 21 51 92 20 97 7 25 67 17 38 100", "100 70\n22 75 26 45 72 81 47 29 97 2 75 25 82 84 17 56 32 2 28 37 57 39 18 11 79 6 40 68 68 16 40 63 93 49 91 10 55 68 31 80 57 18 34 28 76 55 21 80 22 45 11 67 67 74 91 4 35 34 65 80 21 95 1 52 25 31 2 53 96 22 89 99 7 66 32 2 68 33 75 92 84 10 94 28 54 12 9 80 43 21 51 92 20 97 7 25 67 17 38 100", "1 10\n25", "70 80\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70", "3 1\n25 26 27", "100 5\n51 56 52 60 52 53 52 60 56 54 55 50 53 51 57 53 52 54 54 52 51 55 50 56 60 51 58 50 60 59 50 54 60 55 55 57 54 59 59 55 55 52 56 57 59 54 53 57 52 50 50 55 59 54 54 56 51 58 52 51 56 56 58 56 54 54 57 52 51 58 56 57 54 59 58 53 50 52 50 60 57 51 54 59 54 54 52 55 53 55 51 53 52 54 51 56 55 53 58 56", "100 11\n44 89 57 64 94 96 73 96 55 52 91 73 73 93 51 62 63 85 43 75 60 78 98 55 80 84 65 75 61 88 62 71 53 57 94 85 60 96 66 96 61 72 97 64 51 44 63 82 67 86 60 57 74 85 57 79 61 94 86 78 84 56 60 75 91 91 92 62 89 85 79 57 76 97 65 56 46 78 51 69 50 52 85 80 76 71 81 51 90 71 77 60 63 62 84 59 79 84 69 81", "100 0\n22 75 26 45 72 81 47 29 97 2 75 25 82 84 17 56 32 2 28 37 57 39 18 11 79 6 40 68 68 16 40 63 93 49 91 10 55 68 31 80 57 18 34 28 76 55 21 80 22 45 11 67 67 74 91 4 35 34 65 80 21 95 1 52 25 31 2 53 96 22 89 99 7 66 32 2 68 33 75 92 84 10 94 28 54 12 9 80 43 21 51 92 20 97 7 25 67 17 38 100", "100 100\n22 75 26 45 72 81 47 29 97 2 75 25 82 84 17 56 32 2 28 37 57 39 18 11 79 6 40 68 68 16 40 63 93 49 91 10 55 68 31 80 57 18 34 28 76 55 21 80 22 45 11 67 67 74 91 4 35 34 65 80 21 95 1 52 25 31 2 53 96 22 89 99 7 66 32 2 68 33 75 92 84 10 94 28 54 12 9 80 43 21 51 92 20 97 7 25 67 17 38 100", "76 32\n50 53 69 58 55 39 40 42 40 55 58 73 55 72 75 44 45 55 46 60 60 42 41 64 77 39 68 51 61 49 38 41 56 57 64 43 78 36 39 63 40 66 52 76 39 68 39 73 40 68 54 60 35 67 69 52 58 52 38 63 69 38 69 60 73 64 65 41 59 55 37 57 40 34 35 35", "100 1\n22 75 26 45 72 81 47 29 97 2 75 25 82 84 17 56 32 2 28 37 57 39 18 11 79 6 40 68 68 16 40 63 93 49 91 10 55 68 31 80 57 18 34 28 76 55 21 80 22 45 11 67 67 74 91 4 35 34 65 80 21 95 1 52 25 31 2 53 96 22 89 99 7 66 32 2 68 33 75 92 84 10 94 28 54 12 9 80 43 21 51 92 20 97 7 25 67 17 38 100", "100 5\n22 75 26 45 72 81 47 29 97 2 75 25 82 84 17 56 32 2 28 37 57 39 18 11 79 6 40 68 68 16 40 63 93 49 91 10 55 68 31 80 57 18 34 28 76 55 21 80 22 45 11 67 67 74 91 4 35 34 65 80 21 95 1 52 25 31 2 53 96 22 89 99 7 66 32 2 68 33 75 92 84 10 94 28 54 12 9 80 43 21 51 92 20 97 7 25 67 17 38 100", "98 64\n2 29 36 55 58 15 25 33 7 16 61 1 4 24 63 26 36 16 16 3 57 39 56 7 11 24 20 12 22 10 56 5 11 39 61 52 27 54 21 6 61 36 40 52 54 5 15 52 58 23 45 39 65 16 27 40 13 64 47 24 51 29 9 18 49 49 8 47 2 64 7 63 49 10 20 26 34 3 45 66 8 46 16 32 16 38 3 6 15 17 35 48 36 5 57 29 61 15", "100 56\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100", "100 0\n14 13 14 13 14 13 13 13 13 14 13 13 14 14 13 14 14 14 14 13 13 13 14 13 13 14 14 14 14 14 14 13 13 13 13 14 13 14 13 14 13 14 14 14 14 13 13 14 14 13 13 13 13 14 13 14 13 14 13 14 13 13 13 14 13 13 14 13 14 14 13 13 13 14 14 14 14 13 13 14 14 14 14 14 14 14 13 14 13 13 13 14 14 13 13 13 13 13 14 14", "100 0\n14 17 18 22 19 18 19 21 19 19 22 22 19 21 24 23 24 19 25 24 24 21 20 13 26 18 17 15 25 13 17 20 20 21 13 22 27 15 18 27 19 15 16 25 18 17 18 22 19 17 18 24 14 16 18 16 22 16 17 27 18 17 18 24 22 13 14 20 23 19 16 21 19 13 14 14 25 15 27 24 26 22 16 20 16 14 21 27 15 23 23 24 27 14 24 17 19 24 15 27", "100 100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100", "1 100\n22", "1 0\n22", "1 99\n99", "1 5\n6", "3 1\n10 20 30", "3 0\n1 2 3", "3 2\n1 50 99", "7 4\n1 3 4 9 10 11 12", "2 5\n67 23", "4 2\n1 4 7 9", "2 0\n1 2", "8 1\n3 3 3 5 5 5 5 5", "5 1\n3 5 5 5 6"], "outputs": ["1", "0", "3", "5", "0", "84", "27", "0", "0", "1", "34", "70", "96", "0", "13", "93", "89", "1", "43", "50", "89", "0", "0", "0", "0", "0", "2", "2", "2", "3", "1", "2", "1", "3", "1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 121 | codeforces |
|
51dcd299d4c1375028194acc6f588742 | Vitaly and Strings | Vitaly is a diligent student who never missed a lesson in his five years of studying in the university. He always does his homework on time and passes his exams in time.
During the last lesson the teacher has provided two strings *s* and *t* to Vitaly. The strings have the same length, they consist of lowercase English letters, string *s* is lexicographically smaller than string *t*. Vitaly wondered if there is such string that is lexicographically larger than string *s* and at the same is lexicographically smaller than string *t*. This string should also consist of lowercase English letters and have the length equal to the lengths of strings *s* and *t*.
Let's help Vitaly solve this easy problem!
The first line contains string *s* (1<=β€<=|*s*|<=β€<=100), consisting of lowercase English letters. Here, |*s*| denotes the length of the string.
The second line contains string *t* (|*t*|<==<=|*s*|), consisting of lowercase English letters.
It is guaranteed that the lengths of strings *s* and *t* are the same and string *s* is lexicographically less than string *t*.
If the string that meets the given requirements doesn't exist, print a single string "No such string" (without the quotes).
If such string exists, print it. If there are multiple valid strings, you may print any of them.
Sample Input
a
c
aaa
zzz
abcdefg
abcdefh
Sample Output
b
kkk
No such string
| {"inputs": ["a\nc", "aaa\nzzz", "abcdefg\nabcdefh", "abcdefg\nabcfefg", "frt\nfru", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\nzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzx\nzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", "q\nz", "pnzcl\npnzdf", "vklldrxnfgyorgfpfezvhbouyzzzzz\nvklldrxnfgyorgfpfezvhbouzaaadv", "pkjlxzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\npkjlyaaaaaaaaaaaaaaaaaaaaaaaaaaaahr", "exoudpymnspkocwszzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\nexoudpymnspkocwtaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabml", "anarzvsklmwvovozwnmhklkpcseeogdgauoppmzrukynbjjoxytuvsiecuzfquxnowewebhtuoxepocyeamqfrblpwqiokbcubil\nanarzvsklmwvovozwnmhklkpcseeogdgauoppmzrukynbjjoxytuvsiecuzfquxnowewebhtuoxepocyeamqfrblpwqiokbcubim", "uqyugulumzwlxsjnxxkutzqayskrbjoaaekbhckjryhjjllzzz\nuqyugulumzwlxsjnxxkutzqayskrbjoaaekbhckjryhjjlmaaa", "esfaeyxpblcrriizhnhfrxnbopqvhwtetgjqavlqdlxexaifgvkqfwzneibhxxdacbzzzzzzzzzzzzzz\nesfaeyxpblcrriizhnhfrxnbopqvhwtetgjqavlqdlxexaifgvkqfwzneibhxxdaccaaaaaaaaaaaatf", "oisjtilteipnzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\noisjtilteipoaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaao", "svpoxbsudndfnnpugbouawegyxgtmvqzbewxpcwhopdbwscimgzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\nsvpoxbsudndfnnpugbouawegyxgtmvqzbewxpcwhopdbwscimhaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "ddzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\ndeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaao", "xqzbhslocdbifnyzyjenlpctocieaccsycmwlcebkqqkeibatfvylbqlutvjijgjhdetqsjqnoipqbmjhhzxggdobyvpczdavdzz\nxqzbhslocdbifnyzyjenlpctocieaccsycmwlcebkqqkeibatfvylbqlutvjijgjhdetqsjqnoipqbmjhhzxggdobyvpczdavilj", "poflpxucohdobeisxfsnkbdzwizjjhgngufssqhmfgmydmmrnuminrvxxamoebhczlwsfefdtnchaisfxkfcovxmvppxnrfawfoq\npoflpxucohdobeisxfsnkbdzwizjjhgngufssqhmfgmydmmrnuminrvxxamoebhczlwsfefdtnchaisfxkfcovxmvppxnrfawujg", "vonggnmokmvmguwtobkxoqgxkuxtyjmxrygyliohlhwxuxjmlkqcfuxboxjnzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\nvonggnmokmvmguwtobkxoqgxkuxtyjmxrygyliohlhwxuxjmlkqcfuxboxjoaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac", "bqycw\nquhod", "hceslswecf\nnmxshuymaa", "awqtzslxowuaefe\nvujscakjpvxviki", "lerlcnaogdravnogfogcyoxgi\nojrbithvjdqtempegvqxmgmmw", "jbrhvicytqaivheqeourrlosvnsujsxdinryyawgalidsaufxv\noevvkhujmhagaholrmsatdjjyfmyblvgetpnxgjcilugjsncjs", "jrpogrcuhqdpmyzpuabuhaptlxaeiqjxhqkmuzsjbhqxvdtoocrkusaeasqdwlunomwzww\nspvgaswympzlscnumemgiznngnxqgccbubmxgqmaakbnyngkxlxjjsafricchhpecdjgxw", "mzmhjmfxaxaplzjmjkbyadeweltagyyuzpvrmnyvirjpdmebxyzjvdoezhnayfrvtnccryhkvhcvakcf\nohhhhkujfpjbgouebtmmbzizuhuumvrsqfniwpmxdtzhyiaivdyxhywnqzagicydixjtvbqbevhbqttu", "cdmwmzutsicpzhcokbbhwktqbomozxvvjlhwdgtiledgurxsfreisgczdwgupzxmjnfyjxcpdwzkggludkcmgppndl\nuvuqvyrnhtyubpevizhjxdvmpueittksrnosmfuuzbimnqussasdjufrthrgjbyzomauaxbvwferfvtmydmwmjaoxg", "dpnmrwpbgzvcmrcodwgvvfwpyagdwlngmhrazyvalszhruprxzmwltftxmujfyrrnwzvphgqlcphreumqkytswxziugburwrlyay\nqibcfxdfovoejutaeetbbwrgexdrvqywwmhipxgfrvhzovxkfawpfnpjvlhkyahessodqcclangxefcaixysqijnitevwmpalkzd", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", "phdvmuwqmvzyurtnshitcypuzbhpceovkibzbhhjwxkdtvqmbpoumeoiztxtvkvsjrlnhowsdmgftuiulzebdigmun\nphdvmuwqmvzyurtnshitcypuzbhpceovkibzbhhjwxkdtvqmbpoumeoiztxtvkvsjrlnhowsdmgftuiulzebdigmuo", "hrsantdquixzjyjtqytcmnflnyehzbibkbgkqffgqpkgeuqmbmxzhbjwsnfkizvbcyoghyvnxxjavoahlqjxomtsouzoog\nhrsantdquixzjyjtqytcmnflnyehzbibkbgkqffgqpkgeuqmbmxzhbjwsnfkizvbcyoghyvnxxjavoahlqjxomtsouzooh", "kexdbtpkjbwwyibjndbtmwqzolopqitgkomqggojevoankiepxirrcidxldlzsppehmoazdywltmjbxgsxgihwnwpmczjrcwpywl\nkexdbtpkjbwwyibjndbtmwqzolopqitgkomqggojevoankiepxirrcidxldlzsppehmoazdywltmjbxgsxgihwnwpmczjrcwpywm", "yijdysvzfcnaedvnecswgoylhzgguxecmucepgstjbdkbjyfdlxxxejkrrxfiuwjpdmdhhqhlqeqzjwudtdryrfkpwfxdjlkowmk\nyijdysvzfcnaedvnecswgoylhzgguxecmucepgstjbdkbjyfdlxxxejkrrxfiuwjpdmdhhqhlqeqzjwudtdryrfkpwfxdjlkowml", "a\nb", "x\nz", "a\nz", "y\nz", "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzy\nzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\nzaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "yzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\nzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\nzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", "aaa\naac", "aaa\naab", "zzx\nzzz", "zzy\nzzz", "aba\naca", "aaa\nbbb", "azzz\ncaaa"], "outputs": ["b", "kkk", "No such string", "abcdefh", "No such string", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzy", "r", "pnzcm", "vklldrxnfgyorgfpfezvhbouzaaaaa", "pkjlyaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "exoudpymnspkocwtaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "No such string", "No such string", "esfaeyxpblcrriizhnhfrxnbopqvhwtetgjqavlqdlxexaifgvkqfwzneibhxxdaccaaaaaaaaaaaaaa", "oisjtilteipoaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "No such string", "deaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "xqzbhslocdbifnyzyjenlpctocieaccsycmwlcebkqqkeibatfvylbqlutvjijgjhdetqsjqnoipqbmjhhzxggdobyvpczdaveaa", "poflpxucohdobeisxfsnkbdzwizjjhgngufssqhmfgmydmmrnuminrvxxamoebhczlwsfefdtnchaisfxkfcovxmvppxnrfawfor", "vonggnmokmvmguwtobkxoqgxkuxtyjmxrygyliohlhwxuxjmlkqcfuxboxjoaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "bqycx", "hceslswecg", "awqtzslxowuaeff", "lerlcnaogdravnogfogcyoxgj", "jbrhvicytqaivheqeourrlosvnsujsxdinryyawgalidsaufxw", "jrpogrcuhqdpmyzpuabuhaptlxaeiqjxhqkmuzsjbhqxvdtoocrkusaeasqdwlunomwzwx", "mzmhjmfxaxaplzjmjkbyadeweltagyyuzpvrmnyvirjpdmebxyzjvdoezhnayfrvtnccryhkvhcvakcg", "cdmwmzutsicpzhcokbbhwktqbomozxvvjlhwdgtiledgurxsfreisgczdwgupzxmjnfyjxcpdwzkggludkcmgppndm", "dpnmrwpbgzvcmrcodwgvvfwpyagdwlngmhrazyvalszhruprxzmwltftxmujfyrrnwzvphgqlcphreumqkytswxziugburwrlyaz", "No such string", "No such string", "No such string", "No such string", "No such string", "No such string", "y", "b", "No such string", "No such string", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", "zaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyz", "aab", "No such string", "zzy", "No such string", "abb", "aab", "baaa"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 118 | codeforces |
|
51ea43be131b02c7ef7343fe9f2b02c0 | Secret Combination | You got a box with a combination lock. The lock has a display showing *n* digits. There are two buttons on the box, each button changes digits on the display. You have quickly discovered that the first button adds 1 to all the digits (all digits 9 become digits 0), and the second button shifts all the digits on the display one position to the right (the last digit becomes the first one). For example, if the display is currently showing number 579, then if we push the first button, the display will show 680, and if after that we push the second button, the display will show 068.
You know that the lock will open if the display is showing the smallest possible number that can be obtained by pushing the buttons in some order. The leading zeros are ignored while comparing numbers. Now your task is to find the desired number.
The first line contains a single integer *n* (1<=β€<=*n*<=β€<=1000)Β β the number of digits on the display.
The second line contains *n* digitsΒ β the initial state of the display.
Print a single line containing *n* digitsΒ β the desired state of the display containing the smallest possible number.
Sample Input
3
579
4
2014
Sample Output
024
0142
| {"inputs": ["3\n579", "4\n2014", "1\n1", "3\n039", "4\n4444", "5\n46802", "10\n4447444444", "10\n5810438174", "30\n027027027027027027027027027027", "50\n41012516454101251645410125164541012516454101251645", "72\n464553044645330446455304464553064645530445455304464553044645530446455304", "100\n2144315253572020279108092911160072328496568665545836825277616363478721946398140227406814602154768031", "200\n79025531557298703099245700860027432585447902553155729870309924570086002743258544790255315572987030992457008600274325854479025531557298703099245700860027432585447902553155729870309924570086002743258544", "100\n6669666666666666666866266666666666666666666666666666666666666666626666666666666966666766665667666656", "1\n0"], "outputs": ["024", "0142", "0", "014", "0000", "02468", "0000000003", "0147609473", "027027027027027027027027027027", "01076781720107678172010767817201076781720107678172", "001011960020119600201196002011960020119600201996002011960020119620201196", "0005996121738545755443472571416650525236761083528703911639570359104365792010332041424619191680979818", "00274325854479025531557298703099245700860027432585447902553155729870309924570086002743258544790255315572987030992457008600274325854479025531557298703099245700860027432585447902553155729870309924570086", "0000000000000000000000000000000000000000006000000000000030000010000900100009000030000000000000002006", "0"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 89 | codeforces |
|
525529e7c4f14a1e5c41a441db482ecb | Mister B and Flight to the Moon | In order to fly to the Moon Mister B just needs to solve the following problem.
There is a complete indirected graph with *n* vertices. You need to cover it with several simple cycles of length 3 and 4 so that each edge is in exactly 2 cycles.
We are sure that Mister B will solve the problem soon and will fly to the Moon. Will you?
The only line contains single integer *n* (3<=β€<=*n*<=β€<=300).
If there is no answer, print -1.
Otherwise, in the first line print *k* (1<=β€<=*k*<=β€<=*n*2)Β β the number of cycles in your solution.
In each of the next *k* lines print description of one cycle in the following format: first print integer *m* (3<=β€<=*m*<=β€<=4)Β β the length of the cycle, then print *m* integers *v*1,<=*v*2,<=...,<=*v**m* (1<=β€<=*v**i*<=β€<=*n*)Β β the vertices in the cycle in the traverse order. Each edge should be in exactly two cycles.
Sample Input
3
5
Sample Output
2
3 1 2 3
3 1 2 3
6
3 5 4 2
3 3 1 5
4 4 5 2 3
4 4 3 2 1
3 4 2 1
3 3 1 5
| {"inputs": ["3", "5", "299", "300", "4", "5", "6", "7", "8", "9", "10", "298", "297", "11", "14", "21", "28", "35", "42", "49", "56", "63", "70", "77", "84", "91", "98", "105", "112", "119", "126", "133", "140", "147", "154", "161", "168", "175", "182", "189", "196", "203", "210", "217", "224", "231", "238", "245", "252", "259", "266", "273", "280", "287", "294"], "outputs": ["2\n3 1 2 3\n3 1 2 3", "6\n3 1 2 3\n3 2 3 4\n3 3 4 5\n3 4 5 1\n4 2 1 3 5\n4 5 1 4 2", "22350\n4 2 3 1 4\n4 1 4 299 5\n4 299 5 298 6\n4 298 6 297 7\n4 297 7 296 8\n4 296 8 295 9\n4 295 9 294 10\n4 294 10 293 11\n4 293 11 292 12\n4 292 12 291 13\n4 291 13 290 14\n4 290 14 289 15\n4 289 15 288 16\n4 288 16 287 17\n4 287 17 286 18\n4 286 18 285 19\n4 285 19 284 20\n4 284 20 283 21\n4 283 21 282 22\n4 282 22 281 23\n4 281 23 280 24\n4 280 24 279 25\n4 279 25 278 26\n4 278 26 277 27\n4 277 27 276 28\n4 276 28 275 29\n4 275 29 274 30\n4 274 30 273 31\n4 273 31 272 32\n4 272 32 271 33\n4 271 33 270 ...", "22500\n3 300 1 2\n4 300 2 299 3\n4 299 3 298 4\n4 298 4 297 5\n4 297 5 296 6\n4 296 6 295 7\n4 295 7 294 8\n4 294 8 293 9\n4 293 9 292 10\n4 292 10 291 11\n4 291 11 290 12\n4 290 12 289 13\n4 289 13 288 14\n4 288 14 287 15\n4 287 15 286 16\n4 286 16 285 17\n4 285 17 284 18\n4 284 18 283 19\n4 283 19 282 20\n4 282 20 281 21\n4 281 21 280 22\n4 280 22 279 23\n4 279 23 278 24\n4 278 24 277 25\n4 277 25 276 26\n4 276 26 275 27\n4 275 27 274 28\n4 274 28 273 29\n4 273 29 272 30\n4 272 30 271 31\n4 271 31 270 32...", "4\n3 4 1 2\n3 2 3 4\n3 1 2 3\n3 3 4 1", "6\n3 1 2 3\n3 2 3 4\n3 3 4 5\n3 4 5 1\n4 2 1 3 5\n4 5 1 4 2", "9\n3 6 1 2\n4 6 2 5 3\n3 3 4 5\n3 1 2 3\n4 1 3 6 4\n3 4 5 6\n3 2 3 4\n4 2 4 1 5\n3 5 6 1", "12\n4 2 3 1 4\n4 3 4 2 5\n4 4 5 3 6\n4 5 6 4 7\n4 6 7 5 1\n4 7 1 6 2\n3 2 5 6\n3 1 5 4\n3 3 6 7\n3 7 4 3\n3 3 2 1\n3 7 1 2", "16\n3 8 1 2\n4 8 2 7 3\n4 7 3 6 4\n3 4 5 6\n3 1 2 3\n4 1 3 8 4\n4 8 4 7 5\n3 5 6 7\n3 2 3 4\n4 2 4 1 5\n4 1 5 8 6\n3 6 7 8\n3 3 4 5\n4 3 5 2 6\n4 2 6 1 7\n3 7 8 1", "20\n3 1 2 3\n4 1 3 9 4\n3 2 3 4\n4 2 4 1 5\n3 3 4 5\n4 3 5 2 6\n3 4 5 6\n4 4 6 3 7\n3 5 6 7\n4 5 7 4 8\n3 6 7 8\n4 6 8 5 9\n3 7 8 9\n4 7 9 6 1\n3 8 9 1\n4 8 1 7 2\n4 2 1 5 9\n4 9 1 6 2\n4 3 9 4 8\n4 8 2 7 3", "25\n3 10 1 2\n4 10 2 9 3\n4 9 3 8 4\n4 8 4 7 5\n3 5 6 7\n3 1 2 3\n4 1 3 10 4\n4 10 4 9 5\n4 9 5 8 6\n3 6 7 8\n3 2 3 4\n4 2 4 1 5\n4 1 5 10 6\n4 10 6 9 7\n3 7 8 9\n3 3 4 5\n4 3 5 2 6\n4 2 6 1 7\n4 1 7 10 8\n3 8 9 10\n3 4 5 6\n4 4 6 3 7\n4 3 7 2 8\n4 2 8 1 9\n3 9 10 1", "22201\n3 298 1 2\n4 298 2 297 3\n4 297 3 296 4\n4 296 4 295 5\n4 295 5 294 6\n4 294 6 293 7\n4 293 7 292 8\n4 292 8 291 9\n4 291 9 290 10\n4 290 10 289 11\n4 289 11 288 12\n4 288 12 287 13\n4 287 13 286 14\n4 286 14 285 15\n4 285 15 284 16\n4 284 16 283 17\n4 283 17 282 18\n4 282 18 281 19\n4 281 19 280 20\n4 280 20 279 21\n4 279 21 278 22\n4 278 22 277 23\n4 277 23 276 24\n4 276 24 275 25\n4 275 25 274 26\n4 274 26 273 27\n4 273 27 272 28\n4 272 28 271 29\n4 271 29 270 30\n4 270 30 269 31\n4 269 31 268 32...", "22052\n3 1 2 3\n4 1 3 297 4\n4 297 4 296 5\n4 296 5 295 6\n4 295 6 294 7\n4 294 7 293 8\n4 293 8 292 9\n4 292 9 291 10\n4 291 10 290 11\n4 290 11 289 12\n4 289 12 288 13\n4 288 13 287 14\n4 287 14 286 15\n4 286 15 285 16\n4 285 16 284 17\n4 284 17 283 18\n4 283 18 282 19\n4 282 19 281 20\n4 281 20 280 21\n4 280 21 279 22\n4 279 22 278 23\n4 278 23 277 24\n4 277 24 276 25\n4 276 25 275 26\n4 275 26 274 27\n4 274 27 273 28\n4 273 28 272 29\n4 272 29 271 30\n4 271 30 270 31\n4 270 31 269 32\n4 269 32 268 33\n...", "30\n4 2 3 1 4\n4 1 4 11 5\n4 3 4 2 5\n4 2 5 1 6\n4 4 5 3 6\n4 3 6 2 7\n4 5 6 4 7\n4 4 7 3 8\n4 6 7 5 8\n4 5 8 4 9\n4 7 8 6 9\n4 6 9 5 10\n4 8 9 7 10\n4 7 10 6 11\n4 9 10 8 11\n4 8 11 7 1\n4 10 11 9 1\n4 9 1 8 2\n4 11 1 10 2\n4 10 2 9 3\n3 2 7 8\n3 1 7 6\n3 3 8 9\n3 11 6 5\n3 4 9 10\n3 10 5 4\n3 3 2 1\n3 11 1 2\n3 4 3 11\n3 10 11 3", "49\n3 14 1 2\n4 14 2 13 3\n4 13 3 12 4\n4 12 4 11 5\n4 11 5 10 6\n4 10 6 9 7\n3 7 8 9\n3 1 2 3\n4 1 3 14 4\n4 14 4 13 5\n4 13 5 12 6\n4 12 6 11 7\n4 11 7 10 8\n3 8 9 10\n3 2 3 4\n4 2 4 1 5\n4 1 5 14 6\n4 14 6 13 7\n4 13 7 12 8\n4 12 8 11 9\n3 9 10 11\n3 3 4 5\n4 3 5 2 6\n4 2 6 1 7\n4 1 7 14 8\n4 14 8 13 9\n4 13 9 12 10\n3 10 11 12\n3 4 5 6\n4 4 6 3 7\n4 3 7 2 8\n4 2 8 1 9\n4 1 9 14 10\n4 14 10 13 11\n3 11 12 13\n3 5 6 7\n4 5 7 4 8\n4 4 8 3 9\n4 3 9 2 10\n4 2 10 1 11\n4 1 11 14 12\n3 12 13 14\n3 6 7 8\n4 6 ...", "110\n3 1 2 3\n4 1 3 21 4\n4 21 4 20 5\n4 20 5 19 6\n4 19 6 18 7\n3 2 3 4\n4 2 4 1 5\n4 1 5 21 6\n4 21 6 20 7\n4 20 7 19 8\n3 3 4 5\n4 3 5 2 6\n4 2 6 1 7\n4 1 7 21 8\n4 21 8 20 9\n3 4 5 6\n4 4 6 3 7\n4 3 7 2 8\n4 2 8 1 9\n4 1 9 21 10\n3 5 6 7\n4 5 7 4 8\n4 4 8 3 9\n4 3 9 2 10\n4 2 10 1 11\n3 6 7 8\n4 6 8 5 9\n4 5 9 4 10\n4 4 10 3 11\n4 3 11 2 12\n3 7 8 9\n4 7 9 6 10\n4 6 10 5 11\n4 5 11 4 12\n4 4 12 3 13\n3 8 9 10\n4 8 10 7 11\n4 7 11 6 12\n4 6 12 5 13\n4 5 13 4 14\n3 9 10 11\n4 9 11 8 12\n4 8 12 7 13\n4 7 ...", "196\n3 28 1 2\n4 28 2 27 3\n4 27 3 26 4\n4 26 4 25 5\n4 25 5 24 6\n4 24 6 23 7\n4 23 7 22 8\n4 22 8 21 9\n4 21 9 20 10\n4 20 10 19 11\n4 19 11 18 12\n4 18 12 17 13\n4 17 13 16 14\n3 14 15 16\n3 1 2 3\n4 1 3 28 4\n4 28 4 27 5\n4 27 5 26 6\n4 26 6 25 7\n4 25 7 24 8\n4 24 8 23 9\n4 23 9 22 10\n4 22 10 21 11\n4 21 11 20 12\n4 20 12 19 13\n4 19 13 18 14\n4 18 14 17 15\n3 15 16 17\n3 2 3 4\n4 2 4 1 5\n4 1 5 28 6\n4 28 6 27 7\n4 27 7 26 8\n4 26 8 25 9\n4 25 9 24 10\n4 24 10 23 11\n4 23 11 22 12\n4 22 12 21 13\n4 ...", "306\n4 2 3 1 4\n4 1 4 35 5\n4 35 5 34 6\n4 34 6 33 7\n4 33 7 32 8\n4 32 8 31 9\n4 31 9 30 10\n4 30 10 29 11\n4 3 4 2 5\n4 2 5 1 6\n4 1 6 35 7\n4 35 7 34 8\n4 34 8 33 9\n4 33 9 32 10\n4 32 10 31 11\n4 31 11 30 12\n4 4 5 3 6\n4 3 6 2 7\n4 2 7 1 8\n4 1 8 35 9\n4 35 9 34 10\n4 34 10 33 11\n4 33 11 32 12\n4 32 12 31 13\n4 5 6 4 7\n4 4 7 3 8\n4 3 8 2 9\n4 2 9 1 10\n4 1 10 35 11\n4 35 11 34 12\n4 34 12 33 13\n4 33 13 32 14\n4 6 7 5 8\n4 5 8 4 9\n4 4 9 3 10\n4 3 10 2 11\n4 2 11 1 12\n4 1 12 35 13\n4 35 13 34 14\n4...", "441\n3 42 1 2\n4 42 2 41 3\n4 41 3 40 4\n4 40 4 39 5\n4 39 5 38 6\n4 38 6 37 7\n4 37 7 36 8\n4 36 8 35 9\n4 35 9 34 10\n4 34 10 33 11\n4 33 11 32 12\n4 32 12 31 13\n4 31 13 30 14\n4 30 14 29 15\n4 29 15 28 16\n4 28 16 27 17\n4 27 17 26 18\n4 26 18 25 19\n4 25 19 24 20\n4 24 20 23 21\n3 21 22 23\n3 1 2 3\n4 1 3 42 4\n4 42 4 41 5\n4 41 5 40 6\n4 40 6 39 7\n4 39 7 38 8\n4 38 8 37 9\n4 37 9 36 10\n4 36 10 35 11\n4 35 11 34 12\n4 34 12 33 13\n4 33 13 32 14\n4 32 14 31 15\n4 31 15 30 16\n4 30 16 29 17\n4 29 17 2...", "600\n3 1 2 3\n4 1 3 49 4\n4 49 4 48 5\n4 48 5 47 6\n4 47 6 46 7\n4 46 7 45 8\n4 45 8 44 9\n4 44 9 43 10\n4 43 10 42 11\n4 42 11 41 12\n4 41 12 40 13\n4 40 13 39 14\n3 2 3 4\n4 2 4 1 5\n4 1 5 49 6\n4 49 6 48 7\n4 48 7 47 8\n4 47 8 46 9\n4 46 9 45 10\n4 45 10 44 11\n4 44 11 43 12\n4 43 12 42 13\n4 42 13 41 14\n4 41 14 40 15\n3 3 4 5\n4 3 5 2 6\n4 2 6 1 7\n4 1 7 49 8\n4 49 8 48 9\n4 48 9 47 10\n4 47 10 46 11\n4 46 11 45 12\n4 45 12 44 13\n4 44 13 43 14\n4 43 14 42 15\n4 42 15 41 16\n3 4 5 6\n4 4 6 3 7\n4 3 7 ...", "784\n3 56 1 2\n4 56 2 55 3\n4 55 3 54 4\n4 54 4 53 5\n4 53 5 52 6\n4 52 6 51 7\n4 51 7 50 8\n4 50 8 49 9\n4 49 9 48 10\n4 48 10 47 11\n4 47 11 46 12\n4 46 12 45 13\n4 45 13 44 14\n4 44 14 43 15\n4 43 15 42 16\n4 42 16 41 17\n4 41 17 40 18\n4 40 18 39 19\n4 39 19 38 20\n4 38 20 37 21\n4 37 21 36 22\n4 36 22 35 23\n4 35 23 34 24\n4 34 24 33 25\n4 33 25 32 26\n4 32 26 31 27\n4 31 27 30 28\n3 28 29 30\n3 1 2 3\n4 1 3 56 4\n4 56 4 55 5\n4 55 5 54 6\n4 54 6 53 7\n4 53 7 52 8\n4 52 8 51 9\n4 51 9 50 10\n4 50 10 4...", "992\n4 2 3 1 4\n4 1 4 63 5\n4 63 5 62 6\n4 62 6 61 7\n4 61 7 60 8\n4 60 8 59 9\n4 59 9 58 10\n4 58 10 57 11\n4 57 11 56 12\n4 56 12 55 13\n4 55 13 54 14\n4 54 14 53 15\n4 53 15 52 16\n4 52 16 51 17\n4 51 17 50 18\n4 3 4 2 5\n4 2 5 1 6\n4 1 6 63 7\n4 63 7 62 8\n4 62 8 61 9\n4 61 9 60 10\n4 60 10 59 11\n4 59 11 58 12\n4 58 12 57 13\n4 57 13 56 14\n4 56 14 55 15\n4 55 15 54 16\n4 54 16 53 17\n4 53 17 52 18\n4 52 18 51 19\n4 4 5 3 6\n4 3 6 2 7\n4 2 7 1 8\n4 1 8 63 9\n4 63 9 62 10\n4 62 10 61 11\n4 61 11 60 12\n...", "1225\n3 70 1 2\n4 70 2 69 3\n4 69 3 68 4\n4 68 4 67 5\n4 67 5 66 6\n4 66 6 65 7\n4 65 7 64 8\n4 64 8 63 9\n4 63 9 62 10\n4 62 10 61 11\n4 61 11 60 12\n4 60 12 59 13\n4 59 13 58 14\n4 58 14 57 15\n4 57 15 56 16\n4 56 16 55 17\n4 55 17 54 18\n4 54 18 53 19\n4 53 19 52 20\n4 52 20 51 21\n4 51 21 50 22\n4 50 22 49 23\n4 49 23 48 24\n4 48 24 47 25\n4 47 25 46 26\n4 46 26 45 27\n4 45 27 44 28\n4 44 28 43 29\n4 43 29 42 30\n4 42 30 41 31\n4 41 31 40 32\n4 40 32 39 33\n4 39 33 38 34\n4 38 34 37 35\n3 35 36 37\n3 1...", "1482\n3 1 2 3\n4 1 3 77 4\n4 77 4 76 5\n4 76 5 75 6\n4 75 6 74 7\n4 74 7 73 8\n4 73 8 72 9\n4 72 9 71 10\n4 71 10 70 11\n4 70 11 69 12\n4 69 12 68 13\n4 68 13 67 14\n4 67 14 66 15\n4 66 15 65 16\n4 65 16 64 17\n4 64 17 63 18\n4 63 18 62 19\n4 62 19 61 20\n4 61 20 60 21\n3 2 3 4\n4 2 4 1 5\n4 1 5 77 6\n4 77 6 76 7\n4 76 7 75 8\n4 75 8 74 9\n4 74 9 73 10\n4 73 10 72 11\n4 72 11 71 12\n4 71 12 70 13\n4 70 13 69 14\n4 69 14 68 15\n4 68 15 67 16\n4 67 16 66 17\n4 66 17 65 18\n4 65 18 64 19\n4 64 19 63 20\n4 63 ...", "1764\n3 84 1 2\n4 84 2 83 3\n4 83 3 82 4\n4 82 4 81 5\n4 81 5 80 6\n4 80 6 79 7\n4 79 7 78 8\n4 78 8 77 9\n4 77 9 76 10\n4 76 10 75 11\n4 75 11 74 12\n4 74 12 73 13\n4 73 13 72 14\n4 72 14 71 15\n4 71 15 70 16\n4 70 16 69 17\n4 69 17 68 18\n4 68 18 67 19\n4 67 19 66 20\n4 66 20 65 21\n4 65 21 64 22\n4 64 22 63 23\n4 63 23 62 24\n4 62 24 61 25\n4 61 25 60 26\n4 60 26 59 27\n4 59 27 58 28\n4 58 28 57 29\n4 57 29 56 30\n4 56 30 55 31\n4 55 31 54 32\n4 54 32 53 33\n4 53 33 52 34\n4 52 34 51 35\n4 51 35 50 36\n...", "2070\n4 2 3 1 4\n4 1 4 91 5\n4 91 5 90 6\n4 90 6 89 7\n4 89 7 88 8\n4 88 8 87 9\n4 87 9 86 10\n4 86 10 85 11\n4 85 11 84 12\n4 84 12 83 13\n4 83 13 82 14\n4 82 14 81 15\n4 81 15 80 16\n4 80 16 79 17\n4 79 17 78 18\n4 78 18 77 19\n4 77 19 76 20\n4 76 20 75 21\n4 75 21 74 22\n4 74 22 73 23\n4 73 23 72 24\n4 72 24 71 25\n4 3 4 2 5\n4 2 5 1 6\n4 1 6 91 7\n4 91 7 90 8\n4 90 8 89 9\n4 89 9 88 10\n4 88 10 87 11\n4 87 11 86 12\n4 86 12 85 13\n4 85 13 84 14\n4 84 14 83 15\n4 83 15 82 16\n4 82 16 81 17\n4 81 17 80 1...", "2401\n3 98 1 2\n4 98 2 97 3\n4 97 3 96 4\n4 96 4 95 5\n4 95 5 94 6\n4 94 6 93 7\n4 93 7 92 8\n4 92 8 91 9\n4 91 9 90 10\n4 90 10 89 11\n4 89 11 88 12\n4 88 12 87 13\n4 87 13 86 14\n4 86 14 85 15\n4 85 15 84 16\n4 84 16 83 17\n4 83 17 82 18\n4 82 18 81 19\n4 81 19 80 20\n4 80 20 79 21\n4 79 21 78 22\n4 78 22 77 23\n4 77 23 76 24\n4 76 24 75 25\n4 75 25 74 26\n4 74 26 73 27\n4 73 27 72 28\n4 72 28 71 29\n4 71 29 70 30\n4 70 30 69 31\n4 69 31 68 32\n4 68 32 67 33\n4 67 33 66 34\n4 66 34 65 35\n4 65 35 64 36\n...", "2756\n3 1 2 3\n4 1 3 105 4\n4 105 4 104 5\n4 104 5 103 6\n4 103 6 102 7\n4 102 7 101 8\n4 101 8 100 9\n4 100 9 99 10\n4 99 10 98 11\n4 98 11 97 12\n4 97 12 96 13\n4 96 13 95 14\n4 95 14 94 15\n4 94 15 93 16\n4 93 16 92 17\n4 92 17 91 18\n4 91 18 90 19\n4 90 19 89 20\n4 89 20 88 21\n4 88 21 87 22\n4 87 22 86 23\n4 86 23 85 24\n4 85 24 84 25\n4 84 25 83 26\n4 83 26 82 27\n4 82 27 81 28\n3 2 3 4\n4 2 4 1 5\n4 1 5 105 6\n4 105 6 104 7\n4 104 7 103 8\n4 103 8 102 9\n4 102 9 101 10\n4 101 10 100 11\n4 100 11 99 ...", "3136\n3 112 1 2\n4 112 2 111 3\n4 111 3 110 4\n4 110 4 109 5\n4 109 5 108 6\n4 108 6 107 7\n4 107 7 106 8\n4 106 8 105 9\n4 105 9 104 10\n4 104 10 103 11\n4 103 11 102 12\n4 102 12 101 13\n4 101 13 100 14\n4 100 14 99 15\n4 99 15 98 16\n4 98 16 97 17\n4 97 17 96 18\n4 96 18 95 19\n4 95 19 94 20\n4 94 20 93 21\n4 93 21 92 22\n4 92 22 91 23\n4 91 23 90 24\n4 90 24 89 25\n4 89 25 88 26\n4 88 26 87 27\n4 87 27 86 28\n4 86 28 85 29\n4 85 29 84 30\n4 84 30 83 31\n4 83 31 82 32\n4 82 32 81 33\n4 81 33 80 34\n4 80...", "3540\n4 2 3 1 4\n4 1 4 119 5\n4 119 5 118 6\n4 118 6 117 7\n4 117 7 116 8\n4 116 8 115 9\n4 115 9 114 10\n4 114 10 113 11\n4 113 11 112 12\n4 112 12 111 13\n4 111 13 110 14\n4 110 14 109 15\n4 109 15 108 16\n4 108 16 107 17\n4 107 17 106 18\n4 106 18 105 19\n4 105 19 104 20\n4 104 20 103 21\n4 103 21 102 22\n4 102 22 101 23\n4 101 23 100 24\n4 100 24 99 25\n4 99 25 98 26\n4 98 26 97 27\n4 97 27 96 28\n4 96 28 95 29\n4 95 29 94 30\n4 94 30 93 31\n4 93 31 92 32\n4 3 4 2 5\n4 2 5 1 6\n4 1 6 119 7\n4 119 7 118...", "3969\n3 126 1 2\n4 126 2 125 3\n4 125 3 124 4\n4 124 4 123 5\n4 123 5 122 6\n4 122 6 121 7\n4 121 7 120 8\n4 120 8 119 9\n4 119 9 118 10\n4 118 10 117 11\n4 117 11 116 12\n4 116 12 115 13\n4 115 13 114 14\n4 114 14 113 15\n4 113 15 112 16\n4 112 16 111 17\n4 111 17 110 18\n4 110 18 109 19\n4 109 19 108 20\n4 108 20 107 21\n4 107 21 106 22\n4 106 22 105 23\n4 105 23 104 24\n4 104 24 103 25\n4 103 25 102 26\n4 102 26 101 27\n4 101 27 100 28\n4 100 28 99 29\n4 99 29 98 30\n4 98 30 97 31\n4 97 31 96 32\n4 96 3...", "4422\n3 1 2 3\n4 1 3 133 4\n4 133 4 132 5\n4 132 5 131 6\n4 131 6 130 7\n4 130 7 129 8\n4 129 8 128 9\n4 128 9 127 10\n4 127 10 126 11\n4 126 11 125 12\n4 125 12 124 13\n4 124 13 123 14\n4 123 14 122 15\n4 122 15 121 16\n4 121 16 120 17\n4 120 17 119 18\n4 119 18 118 19\n4 118 19 117 20\n4 117 20 116 21\n4 116 21 115 22\n4 115 22 114 23\n4 114 23 113 24\n4 113 24 112 25\n4 112 25 111 26\n4 111 26 110 27\n4 110 27 109 28\n4 109 28 108 29\n4 108 29 107 30\n4 107 30 106 31\n4 106 31 105 32\n4 105 32 104 33\n4...", "4900\n3 140 1 2\n4 140 2 139 3\n4 139 3 138 4\n4 138 4 137 5\n4 137 5 136 6\n4 136 6 135 7\n4 135 7 134 8\n4 134 8 133 9\n4 133 9 132 10\n4 132 10 131 11\n4 131 11 130 12\n4 130 12 129 13\n4 129 13 128 14\n4 128 14 127 15\n4 127 15 126 16\n4 126 16 125 17\n4 125 17 124 18\n4 124 18 123 19\n4 123 19 122 20\n4 122 20 121 21\n4 121 21 120 22\n4 120 22 119 23\n4 119 23 118 24\n4 118 24 117 25\n4 117 25 116 26\n4 116 26 115 27\n4 115 27 114 28\n4 114 28 113 29\n4 113 29 112 30\n4 112 30 111 31\n4 111 31 110 32\n...", "5402\n4 2 3 1 4\n4 1 4 147 5\n4 147 5 146 6\n4 146 6 145 7\n4 145 7 144 8\n4 144 8 143 9\n4 143 9 142 10\n4 142 10 141 11\n4 141 11 140 12\n4 140 12 139 13\n4 139 13 138 14\n4 138 14 137 15\n4 137 15 136 16\n4 136 16 135 17\n4 135 17 134 18\n4 134 18 133 19\n4 133 19 132 20\n4 132 20 131 21\n4 131 21 130 22\n4 130 22 129 23\n4 129 23 128 24\n4 128 24 127 25\n4 127 25 126 26\n4 126 26 125 27\n4 125 27 124 28\n4 124 28 123 29\n4 123 29 122 30\n4 122 30 121 31\n4 121 31 120 32\n4 120 32 119 33\n4 119 33 118 3...", "5929\n3 154 1 2\n4 154 2 153 3\n4 153 3 152 4\n4 152 4 151 5\n4 151 5 150 6\n4 150 6 149 7\n4 149 7 148 8\n4 148 8 147 9\n4 147 9 146 10\n4 146 10 145 11\n4 145 11 144 12\n4 144 12 143 13\n4 143 13 142 14\n4 142 14 141 15\n4 141 15 140 16\n4 140 16 139 17\n4 139 17 138 18\n4 138 18 137 19\n4 137 19 136 20\n4 136 20 135 21\n4 135 21 134 22\n4 134 22 133 23\n4 133 23 132 24\n4 132 24 131 25\n4 131 25 130 26\n4 130 26 129 27\n4 129 27 128 28\n4 128 28 127 29\n4 127 29 126 30\n4 126 30 125 31\n4 125 31 124 32\n...", "6480\n3 1 2 3\n4 1 3 161 4\n4 161 4 160 5\n4 160 5 159 6\n4 159 6 158 7\n4 158 7 157 8\n4 157 8 156 9\n4 156 9 155 10\n4 155 10 154 11\n4 154 11 153 12\n4 153 12 152 13\n4 152 13 151 14\n4 151 14 150 15\n4 150 15 149 16\n4 149 16 148 17\n4 148 17 147 18\n4 147 18 146 19\n4 146 19 145 20\n4 145 20 144 21\n4 144 21 143 22\n4 143 22 142 23\n4 142 23 141 24\n4 141 24 140 25\n4 140 25 139 26\n4 139 26 138 27\n4 138 27 137 28\n4 137 28 136 29\n4 136 29 135 30\n4 135 30 134 31\n4 134 31 133 32\n4 133 32 132 33\n4...", "7056\n3 168 1 2\n4 168 2 167 3\n4 167 3 166 4\n4 166 4 165 5\n4 165 5 164 6\n4 164 6 163 7\n4 163 7 162 8\n4 162 8 161 9\n4 161 9 160 10\n4 160 10 159 11\n4 159 11 158 12\n4 158 12 157 13\n4 157 13 156 14\n4 156 14 155 15\n4 155 15 154 16\n4 154 16 153 17\n4 153 17 152 18\n4 152 18 151 19\n4 151 19 150 20\n4 150 20 149 21\n4 149 21 148 22\n4 148 22 147 23\n4 147 23 146 24\n4 146 24 145 25\n4 145 25 144 26\n4 144 26 143 27\n4 143 27 142 28\n4 142 28 141 29\n4 141 29 140 30\n4 140 30 139 31\n4 139 31 138 32\n...", "7656\n4 2 3 1 4\n4 1 4 175 5\n4 175 5 174 6\n4 174 6 173 7\n4 173 7 172 8\n4 172 8 171 9\n4 171 9 170 10\n4 170 10 169 11\n4 169 11 168 12\n4 168 12 167 13\n4 167 13 166 14\n4 166 14 165 15\n4 165 15 164 16\n4 164 16 163 17\n4 163 17 162 18\n4 162 18 161 19\n4 161 19 160 20\n4 160 20 159 21\n4 159 21 158 22\n4 158 22 157 23\n4 157 23 156 24\n4 156 24 155 25\n4 155 25 154 26\n4 154 26 153 27\n4 153 27 152 28\n4 152 28 151 29\n4 151 29 150 30\n4 150 30 149 31\n4 149 31 148 32\n4 148 32 147 33\n4 147 33 146 3...", "8281\n3 182 1 2\n4 182 2 181 3\n4 181 3 180 4\n4 180 4 179 5\n4 179 5 178 6\n4 178 6 177 7\n4 177 7 176 8\n4 176 8 175 9\n4 175 9 174 10\n4 174 10 173 11\n4 173 11 172 12\n4 172 12 171 13\n4 171 13 170 14\n4 170 14 169 15\n4 169 15 168 16\n4 168 16 167 17\n4 167 17 166 18\n4 166 18 165 19\n4 165 19 164 20\n4 164 20 163 21\n4 163 21 162 22\n4 162 22 161 23\n4 161 23 160 24\n4 160 24 159 25\n4 159 25 158 26\n4 158 26 157 27\n4 157 27 156 28\n4 156 28 155 29\n4 155 29 154 30\n4 154 30 153 31\n4 153 31 152 32\n...", "8930\n3 1 2 3\n4 1 3 189 4\n4 189 4 188 5\n4 188 5 187 6\n4 187 6 186 7\n4 186 7 185 8\n4 185 8 184 9\n4 184 9 183 10\n4 183 10 182 11\n4 182 11 181 12\n4 181 12 180 13\n4 180 13 179 14\n4 179 14 178 15\n4 178 15 177 16\n4 177 16 176 17\n4 176 17 175 18\n4 175 18 174 19\n4 174 19 173 20\n4 173 20 172 21\n4 172 21 171 22\n4 171 22 170 23\n4 170 23 169 24\n4 169 24 168 25\n4 168 25 167 26\n4 167 26 166 27\n4 166 27 165 28\n4 165 28 164 29\n4 164 29 163 30\n4 163 30 162 31\n4 162 31 161 32\n4 161 32 160 33\n4...", "9604\n3 196 1 2\n4 196 2 195 3\n4 195 3 194 4\n4 194 4 193 5\n4 193 5 192 6\n4 192 6 191 7\n4 191 7 190 8\n4 190 8 189 9\n4 189 9 188 10\n4 188 10 187 11\n4 187 11 186 12\n4 186 12 185 13\n4 185 13 184 14\n4 184 14 183 15\n4 183 15 182 16\n4 182 16 181 17\n4 181 17 180 18\n4 180 18 179 19\n4 179 19 178 20\n4 178 20 177 21\n4 177 21 176 22\n4 176 22 175 23\n4 175 23 174 24\n4 174 24 173 25\n4 173 25 172 26\n4 172 26 171 27\n4 171 27 170 28\n4 170 28 169 29\n4 169 29 168 30\n4 168 30 167 31\n4 167 31 166 32\n...", "10302\n4 2 3 1 4\n4 1 4 203 5\n4 203 5 202 6\n4 202 6 201 7\n4 201 7 200 8\n4 200 8 199 9\n4 199 9 198 10\n4 198 10 197 11\n4 197 11 196 12\n4 196 12 195 13\n4 195 13 194 14\n4 194 14 193 15\n4 193 15 192 16\n4 192 16 191 17\n4 191 17 190 18\n4 190 18 189 19\n4 189 19 188 20\n4 188 20 187 21\n4 187 21 186 22\n4 186 22 185 23\n4 185 23 184 24\n4 184 24 183 25\n4 183 25 182 26\n4 182 26 181 27\n4 181 27 180 28\n4 180 28 179 29\n4 179 29 178 30\n4 178 30 177 31\n4 177 31 176 32\n4 176 32 175 33\n4 175 33 174 ...", "11025\n3 210 1 2\n4 210 2 209 3\n4 209 3 208 4\n4 208 4 207 5\n4 207 5 206 6\n4 206 6 205 7\n4 205 7 204 8\n4 204 8 203 9\n4 203 9 202 10\n4 202 10 201 11\n4 201 11 200 12\n4 200 12 199 13\n4 199 13 198 14\n4 198 14 197 15\n4 197 15 196 16\n4 196 16 195 17\n4 195 17 194 18\n4 194 18 193 19\n4 193 19 192 20\n4 192 20 191 21\n4 191 21 190 22\n4 190 22 189 23\n4 189 23 188 24\n4 188 24 187 25\n4 187 25 186 26\n4 186 26 185 27\n4 185 27 184 28\n4 184 28 183 29\n4 183 29 182 30\n4 182 30 181 31\n4 181 31 180 32...", "11772\n3 1 2 3\n4 1 3 217 4\n4 217 4 216 5\n4 216 5 215 6\n4 215 6 214 7\n4 214 7 213 8\n4 213 8 212 9\n4 212 9 211 10\n4 211 10 210 11\n4 210 11 209 12\n4 209 12 208 13\n4 208 13 207 14\n4 207 14 206 15\n4 206 15 205 16\n4 205 16 204 17\n4 204 17 203 18\n4 203 18 202 19\n4 202 19 201 20\n4 201 20 200 21\n4 200 21 199 22\n4 199 22 198 23\n4 198 23 197 24\n4 197 24 196 25\n4 196 25 195 26\n4 195 26 194 27\n4 194 27 193 28\n4 193 28 192 29\n4 192 29 191 30\n4 191 30 190 31\n4 190 31 189 32\n4 189 32 188 33\n...", "12544\n3 224 1 2\n4 224 2 223 3\n4 223 3 222 4\n4 222 4 221 5\n4 221 5 220 6\n4 220 6 219 7\n4 219 7 218 8\n4 218 8 217 9\n4 217 9 216 10\n4 216 10 215 11\n4 215 11 214 12\n4 214 12 213 13\n4 213 13 212 14\n4 212 14 211 15\n4 211 15 210 16\n4 210 16 209 17\n4 209 17 208 18\n4 208 18 207 19\n4 207 19 206 20\n4 206 20 205 21\n4 205 21 204 22\n4 204 22 203 23\n4 203 23 202 24\n4 202 24 201 25\n4 201 25 200 26\n4 200 26 199 27\n4 199 27 198 28\n4 198 28 197 29\n4 197 29 196 30\n4 196 30 195 31\n4 195 31 194 32...", "13340\n4 2 3 1 4\n4 1 4 231 5\n4 231 5 230 6\n4 230 6 229 7\n4 229 7 228 8\n4 228 8 227 9\n4 227 9 226 10\n4 226 10 225 11\n4 225 11 224 12\n4 224 12 223 13\n4 223 13 222 14\n4 222 14 221 15\n4 221 15 220 16\n4 220 16 219 17\n4 219 17 218 18\n4 218 18 217 19\n4 217 19 216 20\n4 216 20 215 21\n4 215 21 214 22\n4 214 22 213 23\n4 213 23 212 24\n4 212 24 211 25\n4 211 25 210 26\n4 210 26 209 27\n4 209 27 208 28\n4 208 28 207 29\n4 207 29 206 30\n4 206 30 205 31\n4 205 31 204 32\n4 204 32 203 33\n4 203 33 202 ...", "14161\n3 238 1 2\n4 238 2 237 3\n4 237 3 236 4\n4 236 4 235 5\n4 235 5 234 6\n4 234 6 233 7\n4 233 7 232 8\n4 232 8 231 9\n4 231 9 230 10\n4 230 10 229 11\n4 229 11 228 12\n4 228 12 227 13\n4 227 13 226 14\n4 226 14 225 15\n4 225 15 224 16\n4 224 16 223 17\n4 223 17 222 18\n4 222 18 221 19\n4 221 19 220 20\n4 220 20 219 21\n4 219 21 218 22\n4 218 22 217 23\n4 217 23 216 24\n4 216 24 215 25\n4 215 25 214 26\n4 214 26 213 27\n4 213 27 212 28\n4 212 28 211 29\n4 211 29 210 30\n4 210 30 209 31\n4 209 31 208 32...", "15006\n3 1 2 3\n4 1 3 245 4\n4 245 4 244 5\n4 244 5 243 6\n4 243 6 242 7\n4 242 7 241 8\n4 241 8 240 9\n4 240 9 239 10\n4 239 10 238 11\n4 238 11 237 12\n4 237 12 236 13\n4 236 13 235 14\n4 235 14 234 15\n4 234 15 233 16\n4 233 16 232 17\n4 232 17 231 18\n4 231 18 230 19\n4 230 19 229 20\n4 229 20 228 21\n4 228 21 227 22\n4 227 22 226 23\n4 226 23 225 24\n4 225 24 224 25\n4 224 25 223 26\n4 223 26 222 27\n4 222 27 221 28\n4 221 28 220 29\n4 220 29 219 30\n4 219 30 218 31\n4 218 31 217 32\n4 217 32 216 33\n...", "15876\n3 252 1 2\n4 252 2 251 3\n4 251 3 250 4\n4 250 4 249 5\n4 249 5 248 6\n4 248 6 247 7\n4 247 7 246 8\n4 246 8 245 9\n4 245 9 244 10\n4 244 10 243 11\n4 243 11 242 12\n4 242 12 241 13\n4 241 13 240 14\n4 240 14 239 15\n4 239 15 238 16\n4 238 16 237 17\n4 237 17 236 18\n4 236 18 235 19\n4 235 19 234 20\n4 234 20 233 21\n4 233 21 232 22\n4 232 22 231 23\n4 231 23 230 24\n4 230 24 229 25\n4 229 25 228 26\n4 228 26 227 27\n4 227 27 226 28\n4 226 28 225 29\n4 225 29 224 30\n4 224 30 223 31\n4 223 31 222 32...", "16770\n4 2 3 1 4\n4 1 4 259 5\n4 259 5 258 6\n4 258 6 257 7\n4 257 7 256 8\n4 256 8 255 9\n4 255 9 254 10\n4 254 10 253 11\n4 253 11 252 12\n4 252 12 251 13\n4 251 13 250 14\n4 250 14 249 15\n4 249 15 248 16\n4 248 16 247 17\n4 247 17 246 18\n4 246 18 245 19\n4 245 19 244 20\n4 244 20 243 21\n4 243 21 242 22\n4 242 22 241 23\n4 241 23 240 24\n4 240 24 239 25\n4 239 25 238 26\n4 238 26 237 27\n4 237 27 236 28\n4 236 28 235 29\n4 235 29 234 30\n4 234 30 233 31\n4 233 31 232 32\n4 232 32 231 33\n4 231 33 230 ...", "17689\n3 266 1 2\n4 266 2 265 3\n4 265 3 264 4\n4 264 4 263 5\n4 263 5 262 6\n4 262 6 261 7\n4 261 7 260 8\n4 260 8 259 9\n4 259 9 258 10\n4 258 10 257 11\n4 257 11 256 12\n4 256 12 255 13\n4 255 13 254 14\n4 254 14 253 15\n4 253 15 252 16\n4 252 16 251 17\n4 251 17 250 18\n4 250 18 249 19\n4 249 19 248 20\n4 248 20 247 21\n4 247 21 246 22\n4 246 22 245 23\n4 245 23 244 24\n4 244 24 243 25\n4 243 25 242 26\n4 242 26 241 27\n4 241 27 240 28\n4 240 28 239 29\n4 239 29 238 30\n4 238 30 237 31\n4 237 31 236 32...", "18632\n3 1 2 3\n4 1 3 273 4\n4 273 4 272 5\n4 272 5 271 6\n4 271 6 270 7\n4 270 7 269 8\n4 269 8 268 9\n4 268 9 267 10\n4 267 10 266 11\n4 266 11 265 12\n4 265 12 264 13\n4 264 13 263 14\n4 263 14 262 15\n4 262 15 261 16\n4 261 16 260 17\n4 260 17 259 18\n4 259 18 258 19\n4 258 19 257 20\n4 257 20 256 21\n4 256 21 255 22\n4 255 22 254 23\n4 254 23 253 24\n4 253 24 252 25\n4 252 25 251 26\n4 251 26 250 27\n4 250 27 249 28\n4 249 28 248 29\n4 248 29 247 30\n4 247 30 246 31\n4 246 31 245 32\n4 245 32 244 33\n...", "19600\n3 280 1 2\n4 280 2 279 3\n4 279 3 278 4\n4 278 4 277 5\n4 277 5 276 6\n4 276 6 275 7\n4 275 7 274 8\n4 274 8 273 9\n4 273 9 272 10\n4 272 10 271 11\n4 271 11 270 12\n4 270 12 269 13\n4 269 13 268 14\n4 268 14 267 15\n4 267 15 266 16\n4 266 16 265 17\n4 265 17 264 18\n4 264 18 263 19\n4 263 19 262 20\n4 262 20 261 21\n4 261 21 260 22\n4 260 22 259 23\n4 259 23 258 24\n4 258 24 257 25\n4 257 25 256 26\n4 256 26 255 27\n4 255 27 254 28\n4 254 28 253 29\n4 253 29 252 30\n4 252 30 251 31\n4 251 31 250 32...", "20592\n4 2 3 1 4\n4 1 4 287 5\n4 287 5 286 6\n4 286 6 285 7\n4 285 7 284 8\n4 284 8 283 9\n4 283 9 282 10\n4 282 10 281 11\n4 281 11 280 12\n4 280 12 279 13\n4 279 13 278 14\n4 278 14 277 15\n4 277 15 276 16\n4 276 16 275 17\n4 275 17 274 18\n4 274 18 273 19\n4 273 19 272 20\n4 272 20 271 21\n4 271 21 270 22\n4 270 22 269 23\n4 269 23 268 24\n4 268 24 267 25\n4 267 25 266 26\n4 266 26 265 27\n4 265 27 264 28\n4 264 28 263 29\n4 263 29 262 30\n4 262 30 261 31\n4 261 31 260 32\n4 260 32 259 33\n4 259 33 258 ...", "21609\n3 294 1 2\n4 294 2 293 3\n4 293 3 292 4\n4 292 4 291 5\n4 291 5 290 6\n4 290 6 289 7\n4 289 7 288 8\n4 288 8 287 9\n4 287 9 286 10\n4 286 10 285 11\n4 285 11 284 12\n4 284 12 283 13\n4 283 13 282 14\n4 282 14 281 15\n4 281 15 280 16\n4 280 16 279 17\n4 279 17 278 18\n4 278 18 277 19\n4 277 19 276 20\n4 276 20 275 21\n4 275 21 274 22\n4 274 22 273 23\n4 273 23 272 24\n4 272 24 271 25\n4 271 25 270 26\n4 270 26 269 27\n4 269 27 268 28\n4 268 28 267 29\n4 267 29 266 30\n4 266 30 265 31\n4 265 31 264 32..."]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces |
|
528e74abdd6f1a9f497825c446f2ef2b | ChewbaΡca and Number | Luke Skywalker gave Chewbacca an integer number *x*. Chewbacca isn't good at numbers but he loves inverting digits in them. Inverting digit *t* means replacing it with digit 9<=-<=*t*.
Help Chewbacca to transform the initial number *x* to the minimum possible positive number by inverting some (possibly, zero) digits. The decimal representation of the final number shouldn't start with a zero.
The first line contains a single integer *x* (1<=β€<=*x*<=β€<=1018) β the number that Luke Skywalker gave to Chewbacca.
Print the minimum possible positive number that Chewbacca can obtain after inverting some digits. The number shouldn't contain leading zeroes.
Sample Input
27
4545
Sample Output
22
4444
| {"inputs": ["27", "4545", "1", "9", "8772", "81", "71723447", "91730629", "420062703497", "332711047202", "3395184971407775", "8464062628894325", "164324828731963982", "384979173822804784", "41312150450968417", "2156", "1932", "5902", "5728", "8537", "55403857", "270739", "28746918", "10279211", "40289679", "545203238506", "461117063340", "658492686568", "857373361868", "429325660016", "9894448650287940", "6354510839296263", "6873575462224593", "4237951492601449", "2680352384836991", "606187734191890310", "351499943576823355", "180593481782177068", "999999999999999999", "1000000000000000000", "9999", "99", "9991"], "outputs": ["22", "4444", "1", "9", "1222", "11", "21223442", "91230320", "420032203402", "332211042202", "3304114021402224", "1434032321104324", "134324121231033012", "314020123122104214", "41312140440031412", "2143", "1032", "4002", "4221", "1432", "44403142", "220230", "21243011", "10220211", "40210320", "444203231403", "431112033340", "341402313431", "142323331131", "420324330013", "9104441340212040", "3344410130203233", "3123424432224403", "4232041402301440", "2310342314133001", "303112234101100310", "341400043423123344", "110403411212122031", "900000000000000000", "1000000000000000000", "9000", "90", "9001"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 346 | codeforces |
|
5292b9c42c14e162f4ce34076de89ae1 | none | Little Elephant loves Furik and Rubik, who he met in a small city Kremenchug.
The Little Elephant has two strings of equal length *a* and *b*, consisting only of uppercase English letters. The Little Elephant selects a pair of substrings of equal length β the first one from string *a*, the second one from string *b*. The choice is equiprobable among all possible pairs. Let's denote the substring of *a* as *x*, and the substring of *b* β as *y*. The Little Elephant gives string *x* to Furik and string *y* β to Rubik.
Let's assume that *f*(*x*,<=*y*) is the number of such positions of *i* (1<=β€<=*i*<=β€<=|*x*|), that *x**i*<==<=*y**i* (where |*x*| is the length of lines *x* and *y*, and *x**i*, *y**i* are the *i*-th characters of strings *x* and *y*, correspondingly). Help Furik and Rubik find the expected value of *f*(*x*,<=*y*).
The first line contains a single integer *n* (1<=β€<=*n*<=β€<=2Β·105) β the length of strings *a* and *b*. The second line contains string *a*, the third line contains string *b*. The strings consist of uppercase English letters only. The length of both strings equals *n*.
On a single line print a real number β the answer to the problem. The answer will be considered correct if its relative or absolute error does not exceed 10<=-<=6.
Sample Input
2
AB
BA
3
AAB
CAA
Sample Output
0.400000000
0.642857143
| {"inputs": ["2\nAB\nBA", "3\nAAB\nCAA", "7\nAAAAAAA\nBBBBBBB", "4\nAAAA\nAAAB", "10\nSATYFFJYBA\nBGFOBFBVAV", "1\nA\nA", "1\nA\nZ", "14\nBABBABABABABAA\nBABABAABAAABAB", "10\nQUDLGGRJEG\nMIZIEZRCJU", "47\nGMQXICWAZQNJFYHHAFWXZOLNEZGUIPEKMWPWXLXUBDFONZF\nXSGRAAAFYJBCJYECMTWRTZNKVWMSVYJOFDNZFEFYLWGUGYX", "25\nYWORWQKEMDATWPMKFZJWMKOWL\nPOQZKBGWTPZYPLSHCRKLBPMDW", "22\nUGZZIPTKHGBOQDDTDGAHQH\nKVWQHSEFVUVUSLRTMWSGZQ", "74\nYIHNLSUPBCQMOVFQGZRXVQRGQHXLZXVXMHQEOOENWGAZHZXCPTGLVIIZAYOPDIPKVBWZKKXORC\nOCEAPWMUHWVAGRGWGJCEPDQENOMUOHKXWQHTCJLVLGRRLZXBXEKLUDDGTTMTIMHUMZGPSLRVYH", "99\nJJXMQAXSBLUZFSMEDKNRICWXAQFRAHIMDANLUGSNFBGRZRBHVDRTZEUYKDTNAODQJVFOGQBAMGFOFBSNZEQRLALVPBAHDCNBBUY\nPYPLLECGNRFMDNUIAGPEBVOZRUWIWBSGZOQVNJCAUBXRNLKABJJAMHXKMQOLKJKMHCDJFRIZUMMOSMQUCRUZAEXNMWHCOJRZIXX", "100\nNSTGTRSMJLIDBREUSGYQOMBMECCEHNNRJDPMTKKIHIECODCEKZVVIBYZIHNOXGMUXWEZQSLVPJADKFAOVYVZPRRPTPSCXLAACZPQ\nSRZIMRLLUKNTSGJMAUCMMDCCRRQSPMQCMGSEFECMQFONXBODWCIJBEWXNQQHYVGKHELDIPJZZDSDYEDZZOOHUNTEEDDVAMIODOGY", "58\nMTMWEDBBHGQTSZBGRSIILBAEAERRLNQSVRCAWUTBQIBWJHOJUYNFFBGKMB\nXSYEOUBVEMINIUCWKYGAFDMFFMDEAZFZTQGZGMECZYQLBNUXHMJWIEYRWB", "17\nKEILXLMPJGZNOGKJD\nBLAFXHTHYHMSHMZOZ", "147\nRJZCSVHLQANGDWUFVZEDLQBSCXBQVAHUKLQAULNYGEUADUECVWMQUTNQPEFRFYZHWQCOUDSFZMPYVXQMIYOGWCFVAJDBUHDXOPZCAZULLYLSJZITCSUQNCLNKUCVATCSJNHUWSBTUSZSMKNYRKS\nCZHMNCRNBKTJPDSEAZQRDEHZGWNLIHPPSMTANDLITUDTOGTLQGLXFJNXWTAPJRSYSBYJPKKBIQBSRQIGQTHDXZQFWHDVROCVFMMLNLEVSJJXQDUTTWGDLZHKJTPDIZASVXOAPNSETRODEHJWTTV", "67\nNUAYJNTNCQIDKDKHCPJNKKTFHLTFIZKXZBOHXQLOFJAKKAXWPLSZBGTOOGBPFYTTFPM\nVUEPNNIBGKNAMKASOTQZOZADBYHOKTYFBMOZAFUBMKPEBJZBOKKZQZZSKSCHTMIPGYR", "100\nXYXYYXXYYXYYYXXXXXXXXYXXXXXYYYYYYYXYXXXYXXXXYXXXYYYXYXYXYYXYXXXYXXYXXYYYYXYXYXXYXYYYYYYYYXXYYXXXYYXX\nYYXXYYYXXYYXXYXXXXXXYXXYYXXYXXXXXXXYXXXXYXYYYXYXXXYYXXYYXXYXYXXYXYYXYYYYYXYXXYYYXXYXYYXXYYYXXXXYXXXX"], "outputs": ["0.400000000", "0.642857143", "0.000000000", "1.333333333", "0.329870130", "1.000000000", "0.000000000", "2.065024631", "0.145454545", "0.476567749", "0.307149321", "0.125428195", "0.819858516", "1.000852749", "1.119453229", "0.520493339", "0.147899160", "1.381732684", "0.917705590", "13.007657751"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces |
|
5298cee5f0c18b0718c0ec3fe8bd388a | Wet Shark and Flowers | There are *n* sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharks *i* and *i*<=+<=1 are neighbours for all *i* from 1 to *n*<=-<=1. Sharks *n* and 1 are neighbours too.
Each shark will grow some number of flowers *s**i*. For *i*-th shark value *s**i* is random integer equiprobably chosen in range from *l**i* to *r**i*. Wet Shark has it's favourite prime number *p*, and he really likes it! If for any pair of neighbouring sharks *i* and *j* the product *s**i*Β·*s**j* is divisible by *p*, then Wet Shark becomes happy and gives 1000 dollars to each of these sharks.
At the end of the day sharks sum all the money Wet Shark granted to them. Find the expectation of this value.
The first line of the input contains two space-separated integers *n* and *p* (3<=β€<=*n*<=β€<=100<=000,<=2<=β€<=*p*<=β€<=109)Β β the number of sharks and Wet Shark's favourite prime number. It is guaranteed that *p* is prime.
The *i*-th of the following *n* lines contains information about *i*-th sharkΒ β two space-separated integers *l**i* and *r**i* (1<=β€<=*l**i*<=β€<=*r**i*<=β€<=109), the range of flowers shark *i* can produce. Remember that *s**i* is chosen equiprobably among all integers from *l**i* to *r**i*, inclusive.
Print a single real number β the expected number of dollars that the sharks receive in total. You answer will be considered correct if its absolute or relative error does not exceed 10<=-<=6.
Namely: let's assume that your answer is *a*, and the answer of the jury is *b*. The checker program will consider your answer correct, if .
Sample Input
3 2
1 2
420 421
420420 420421
3 5
1 4
2 3
11 14
Sample Output
4500.0
0.0
| {"inputs": ["3 2\n1 2\n420 421\n420420 420421", "3 5\n1 4\n2 3\n11 14", "3 3\n3 3\n2 4\n1 1", "5 5\n5 204\n420 469\n417 480\n442 443\n44 46", "3 2\n2 2\n3 3\n4 4", "6 7\n8 13\n14 14\n8 13\n14 14\n8 13\n14 14", "3 7\n7 14\n700000000 700000007\n420 4200", "5 999999937\n999999935 999999936\n999999937 999999938\n999999939 999999940\n999999941 999999942\n999999943 999999944", "5 999999937\n1 999999936\n1 999999936\n1 999999936\n1 999999936\n1 999999936", "20 999999937\n999999936 999999937\n999999937 999999938\n999999936 999999937\n999999937 999999938\n999999936 999999937\n999999937 999999938\n999999936 999999937\n999999937 999999938\n999999936 999999937\n999999937 999999938\n999999936 999999937\n999999937 999999938\n999999936 999999937\n999999937 999999938\n999999936 999999937\n999999937 999999938\n999999936 999999937\n999999937 999999938\n999999936 999999937\n999999937 999999938", "9 41\n40 42\n42 44\n44 46\n82 84\n82 83\n80 83\n40 83\n40 82\n42 82", "3 2\n1 1\n1 2\n1 1", "12 3\n697806 966852\n802746 974920\n579567 821770\n628655 642480\n649359 905832\n87506 178848\n605628 924780\n843338 925533\n953514 978612\n375312 997707\n367620 509906\n277106 866177", "5 3\n67050 461313\n927808 989615\n169239 201720\n595515 756354\n392844 781910", "6 7\n984774 984865\n720391 916269\n381290 388205\n628383 840455\n747138 853964\n759705 959629", "3 5\n99535 124440\n24114 662840\n529335 875935", "4 3\n561495 819666\n718673 973130\n830124 854655\n430685 963699", "10 3\n311664 694971\n364840 366487\n560148 821101\n896470 923613\n770019 828958\n595743 827536\n341418 988218\n207847 366132\n517968 587855\n168695 878142", "11 3\n66999 737907\n499872 598806\n560583 823299\n579017 838419\n214308 914576\n31820 579035\n373821 695652\n438988 889317\n181332 513682\n740575 769488\n597348 980891", "12 3\n158757 341790\n130709 571435\n571161 926255\n851779 952236\n914910 941369\n774359 860799\n224067 618483\n411639 902888\n264423 830336\n33133 608526\n951696 976379\n923880 968563", "9 2\n717582 964152\n268030 456147\n400022 466269\n132600 698200\n658890 807357\n196658 849497\n257020 380298\n267729 284534\n311978 917744", "10 7\n978831 984305\n843967 844227\n454356 748444\n219513 623868\n472997 698189\n542337 813387\n867615 918554\n413076 997267\n79310 138855\n195703 296681"], "outputs": ["4500.0", "0.0", "4666.666666666667", "3451.25", "6000.0", "12000.0", "2304.2515207617034", "2000.0", "0.0", "30000.0", "5503.274377352654", "2000.0", "13333.518289809368", "5555.597086312073", "3215.6233297395006", "2160.11317825774", "4444.521972611004", "11110.602699850484", "12222.259608784536", "13333.377729413933", "13500.015586135814", "5303.027968302269"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 52 | codeforces |
|
52bb700295732c2b5c9555abba470fd8 | Kids' Riddle | Programmers' kids solve this riddle in 5-10 minutes. How fast can you do it?
The input contains a single integer *n* (0<=β€<=*n*<=β€<=2000000000).
Output a single integer.
Sample Input
11
14
61441
571576
2128506
Sample Output
2
0
2
10
3
| {"inputs": ["11", "14", "61441", "571576", "2128506", "0", "2000000000", "143165576", "1741", "1919020031", "1795248373", "1818960378", "1285316221", "1309028227", "1304312649", "1180540990", "1204252996", "1199537418", "1075765759", "724264821", "747976826", "624205168", "619489590", "643201595", "638486017", "514714359", "833393692", "186925426", "210637432", "58438190"], "outputs": ["2", "0", "2", "10", "3", "1", "4", "14", "2", "3", "5", "5", "3", "5", "8", "5", "3", "4", "2", "5", "4", "4", "4", "5", "6", "3", "3", "4", "4", "4"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 33 | codeforces |
|
52bdea90e6852a13d360805c66942d58 | Finite or not? | You are given several queries. Each query consists of three integers $p$, $q$ and $b$. You need to answer whether the result of $p/q$ in notation with base $b$ is a finite fraction.
A fraction in notation with base $b$ is finite if it contains finite number of numerals after the decimal point. It is also possible that a fraction has zero numerals after the decimal point.
The first line contains a single integer $n$ ($1 \le n \le 10^5$)Β β the number of queries.
Next $n$ lines contain queries, one per line. Each line contains three integers $p$, $q$, and $b$ ($0 \le p \le 10^{18}$, $1 \le q \le 10^{18}$, $2 \le b \le 10^{18}$). All numbers are given in notation with base $10$.
For each question, in a separate line, print Finite if the fraction is finite and Infinite otherwise.
Sample Input
2
6 12 10
4 3 10
4
1 1 2
9 36 2
4 12 3
3 5 4
Sample Output
Finite
Infinite
Finite
Finite
Finite
Infinite
| {"inputs": ["2\n6 12 10\n4 3 10", "4\n1 1 2\n9 36 2\n4 12 3\n3 5 4", "10\n10 5 3\n1 7 10\n7 5 7\n4 4 9\n6 5 2\n6 7 5\n9 9 7\n7 5 5\n6 6 4\n10 8 2", "10\n1 3 10\n6 2 6\n2 3 9\n7 8 4\n5 6 10\n1 2 7\n0 3 6\n9 3 4\n4 4 9\n10 9 10", "10\n10 8 5\n0 6 9\n0 7 6\n5 7 3\n7 6 8\n0 4 8\n2 6 3\n10 2 9\n6 7 9\n9 1 4", "10\n5 8 2\n0 5 8\n5 9 7\n0 7 2\n6 7 2\n10 3 7\n8 1 10\n9 1 8\n0 7 10\n9 1 4", "1\n1 864691128455135232 2", "11\n1 1000000000000000000 10000000\n2 999 9\n2 999 333111\n0 9 7\n17 128 2\n13 311992186885373952 18\n1971402979058461 750473176484995605 75\n14 19 23\n3 21914624432020321 23\n3 21914624432020321 46\n3 21914624432020321 47", "1\n1 100000000000000000 10000000000000000", "1\n1 4294967297 4294967296", "1\n1 5244319080000 30030"], "outputs": ["Finite\nInfinite", "Finite\nFinite\nFinite\nInfinite", "Finite\nInfinite\nInfinite\nFinite\nInfinite\nInfinite\nFinite\nFinite\nFinite\nFinite", "Infinite\nFinite\nFinite\nFinite\nInfinite\nInfinite\nFinite\nFinite\nFinite\nInfinite", "Infinite\nFinite\nFinite\nInfinite\nInfinite\nFinite\nFinite\nFinite\nInfinite\nFinite", "Finite\nFinite\nInfinite\nFinite\nInfinite\nInfinite\nFinite\nFinite\nFinite\nFinite", "Infinite", "Finite\nInfinite\nFinite\nFinite\nFinite\nFinite\nFinite\nInfinite\nFinite\nFinite\nInfinite", "Finite", "Infinite", "Finite"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 12 | codeforces |
|
52c301e110c218203ec5f2e7b16fdaef | k-substrings | You are given a string *s* consisting of *n* lowercase Latin letters.
Let's denote *k*-substring of *s* as a string *subs**k*<==<=*s**k**s**k*<=+<=1..*s**n*<=+<=1<=-<=*k*. Obviously, *subs*1<==<=*s*, and there are exactly such substrings.
Let's call some string *t* an odd proper suprefix of a string *T* iff the following conditions are met:
- |*T*|<=><=|*t*|; - |*t*| is an odd number; - *t* is simultaneously a prefix and a suffix of *T*.
For evey *k*-substring () of *s* you have to calculate the maximum length of its odd proper suprefix.
The first line contains one integer *n* (2<=β€<=*n*<=β€<=106) β the length *s*.
The second line contains the string *s* consisting of *n* lowercase Latin letters.
Print integers. *i*-th of them should be equal to maximum length of an odd proper suprefix of *i*-substring of *s* (or <=-<=1, if there is no such string that is an odd proper suprefix of *i*-substring).
Sample Input
15
bcabcabcabcabca
24
abaaabaaaabaaabaaaabaaab
19
cabcabbcabcabbcabca
Sample Output
9 7 5 3 1 -1 -1 -1
15 13 11 9 7 5 3 1 1 -1 -1 1
5 3 1 -1 -1 1 1 -1 -1 -1
| {"inputs": ["15\nbcabcabcabcabca", "24\nabaaabaaaabaaabaaaabaaab", "19\ncabcabbcabcabbcabca", "2\nza", "20\nbbbaaabbbbbbbbaaabbb", "2\nzz", "3\ndad", "4\naccd", "5\naabcd", "6\nbcabbd", "7\nbaaaadd"], "outputs": ["9 7 5 3 1 -1 -1 -1", "15 13 11 9 7 5 3 1 1 -1 -1 1", "5 3 1 -1 -1 1 1 -1 -1 -1", "-1", "9 7 5 3 1 1 7 5 3 1", "1", "1 -1", "-1 1", "-1 -1 -1", "-1 -1 -1", "-1 -1 1 -1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces |
|
52f5dd7190e4ec2cbb522191d7d08ee6 | Robot Sequence | Calvin the robot lies in an infinite rectangular grid. Calvin's source code contains a list of *n* commands, each either 'U', 'R', 'D', or 'L'Β β instructions to move a single square up, right, down, or left, respectively. How many ways can Calvin execute a non-empty contiguous substrings of commands and return to the same square he starts in? Two substrings are considered different if they have different starting or ending indices.
The first line of the input contains a single positive integer, *n* (1<=β€<=*n*<=β€<=200)Β β the number of commands.
The next line contains *n* characters, each either 'U', 'R', 'D', or 'L'Β β Calvin's source code.
Print a single integerΒ β the number of contiguous substrings that Calvin can execute and return to his starting square.
Sample Input
6
URLLDR
4
DLUU
7
RLRLRLR
Sample Output
2
0
12
| {"inputs": ["6\nURLLDR", "4\nDLUU", "7\nRLRLRLR", "1\nR", "100\nURDLURDLURDLURDLURDLURDLURDLURDLURDLURDLURDLURDLURDLURDLURDLURDLURDLURDLURDLURDLURDLURDLURDLURDLURDL", "200\nLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR", "20\nLDURLDURRLRUDLRRUDLU", "140\nDLDLULULDRDDDLLUDRRDLLUULLDDLDLUURLDLDRDUDDLRRDURUUUUURLDUDDLLRRLLDRRRDDDDDUDUULLURRDLDULUDLLUUDRRLUDULUDUDULULUURURRDUURRDLULLURUDDDDRDRDRD", "194\nULLLDLLDRUUDURRULLRLUUURDRLLURDUDDUDLULRLDRUDURLDLRDLLLLUDDRRRULULULUDDULRURURLLDLDLDRUDUUDULRULDDRRLRDRULLDRULLLLRRDDLLLLULDRLUULRUUULDUUDLDLDUUUDDLDDRULDRRLUURRULLDULRRDLLRDURDLUUDUDLLUDDULDDD", "200\nDDDURLLUUULUDDURRDLLDDLLRLUULUULDDDLRRDLRRDUDURDUDRRLLDRDUDDLDDRDLURRRLLRDRRLLLRDDDRDRRLLRRLULRUULRLDLUDRRRDDUUURLLUDRLDUDRLLRLRRLUDLRULDUDDRRLLRLURDLRUDDDURLRDUDUUURLLULULRDRLDLDRURDDDLLRUDDRDUDDDLRU", "197\nDUUDUDUDUDUUDUUDUUUDDDDUUUDUUUDUUUUUDUUUDDUDDDUUDUDDDUUDDUUUUUUUDUDDDDDUUUUUDDDDDDUUUUDDUDDUDDDUDUUUDUUDUDUDUUUDUDDDDUUDDUDDDDUDDDUDUUUDUUDUUUDDDDUUUDUUDDUUUUUDDDDUUDUUDDDDUDDUUDUUUDDDDUDUUUDDDUUDU", "200\nLLLLRLLRLLRRRRLLRRLRRLRRRLLLRRLRRRRLLRRLLRRRLRLRLRRLLRLLRRLLLRRRRLRLLRLLLRLLLRRLLLRLRLRRRRRRRLRRRLRLRLLLLRLRRRRRLRRLRLLLLRLLLRRLRRLLRLRLLLRRLLRRLRRRRRLRLRRLRLLRLLLLRLRRRLRRLRLLRLRRLRRRRRLRRLLLRRRRRLLR", "184\nUUUDDUDDDDDUDDDDUDDUUUUUDDDUUDDUDUUDUUUDDUDDDDDDDDDDUDUDDUUDDDUUDDUDUDDDUUDUDUUUUDDUDUUUDDUDUUUUDUUDDUUDUUUDUDUDDUDUDDDUUDDDDUUUUUDDDUDUDUDUDUDUUUDUDDUUDDUDUUDUDUUUDUUDDDDUDDDDUDUUDUUD", "187\nRLLRLRRLLRRLRRRRLLRLLRLLLLRRRLLLRLLLLRRLRLRRRRRRLLRRLRLLRRRLLRRLLLRRLRRLRLLLLRRRRLRRLLRRLRRRRLLLLRRLRLRLRRRRRLLRLRLRLRLRLRLLLRLLLLLRRRLLRLRRRLLLRRLLLLLRLLRLLLRRRLLLRRLRRRLLLRRLRLLRRLRLRLR", "190\nUULLLUUULLLULLUULUUUUULUUULLULLULUULLUULLUUULULUULLUULLUUULULLLLLLULLLLLULUULLULLULLLUULUULLLUUUULLLLUUULLUUULLLULULUULULLUULULULUUULLUUUULLUUULULUULLLLULLLLLUULLUULULLULUUUUUULULLLULLUULUUU", "46\nULUURRRRLDRDRDDDURRRLLLDDULLRRRRRLUDDLRDRULLLL", "70\nUUDRLDRDRUDLLURURULRDULRRDULDUDDRUULLDDDDDRLLRDURRDULRDLRUUUDDLRUURRLD", "198\nURLLUDRDUUDRDLLRURULLRRLRRUULRLULUUDRRURLRUURRDRUUDRLRURLLULRDDDDDRDDRRRLRUDULLDDLLLUDRLDRUDRDLDUULLUUUULULLRLDDRDURDRURLULDRURLLDDULURULDLUUUUULDLURRLLDLULLDULRUURRLDLLUUURDLDDUDUULRLUDULLULDRDRLRL", "22\nDUDDDURURUDURRUDRDULUL", "200\nUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUD", "4\nRRDR", "6\nUULLLL", "2\nDU", "6\nUURRRR", "101\nRDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"], "outputs": ["2", "0", "12", "0", "1225", "100", "29", "125", "282", "408", "1995", "1368", "1243", "1501", "0", "23", "86", "160", "10", "10000", "0", "0", "1", "0", "0"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 166 | codeforces |
|
533ae5b3b2eae7d179cdcdabdab45238 | Little Elephant and Chess | The Little Elephant loves chess very much.
One day the Little Elephant and his friend decided to play chess. They've got the chess pieces but the board is a problem. They've got an 8<=Γ<=8 checkered board, each square is painted either black or white. The Little Elephant and his friend know that a proper chessboard doesn't have any side-adjacent cells with the same color and the upper left cell is white. To play chess, they want to make the board they have a proper chessboard. For that the friends can choose any row of the board and cyclically shift the cells of the chosen row, that is, put the last (rightmost) square on the first place in the row and shift the others one position to the right. You can run the described operation multiple times (or not run it at all).
For example, if the first line of the board looks like that "BBBBBBWW" (the white cells of the line are marked with character "W", the black cells are marked with character "B"), then after one cyclic shift it will look like that "WBBBBBBW".
Help the Little Elephant and his friend to find out whether they can use any number of the described operations to turn the board they have into a proper chessboard.
The input consists of exactly eight lines. Each line contains exactly eight characters "W" or "B" without any spaces: the *j*-th character in the *i*-th line stands for the color of the *j*-th cell of the *i*-th row of the elephants' board. Character "W" stands for the white color, character "B" stands for the black color.
Consider the rows of the board numbered from 1 to 8 from top to bottom, and the columns β from 1 to 8 from left to right. The given board can initially be a proper chessboard.
In a single line print "YES" (without the quotes), if we can make the board a proper chessboard and "NO" (without the quotes) otherwise.
Sample Input
WBWBWBWB
BWBWBWBW
BWBWBWBW
BWBWBWBW
WBWBWBWB
WBWBWBWB
BWBWBWBW
WBWBWBWB
WBWBWBWB
WBWBWBWB
BBWBWWWB
BWBWBWBW
BWBWBWBW
BWBWBWWW
BWBWBWBW
BWBWBWBW
Sample Output
YES
NO
| {"inputs": ["WBWBWBWB\nBWBWBWBW\nBWBWBWBW\nBWBWBWBW\nWBWBWBWB\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB", "WBWBWBWB\nWBWBWBWB\nBBWBWWWB\nBWBWBWBW\nBWBWBWBW\nBWBWBWWW\nBWBWBWBW\nBWBWBWBW", "BWBWBWBW\nWBWBWBWB\nBWBWBWBW\nBWBWBWBW\nWBWBWBWB\nWBWBWBWB\nWBWBWBWB\nWBWBWBWB", "BWBWBWBW\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB\nWBWBWBWB\nWBWBWBWB", "WBWBWBWB\nBWBWBWBW\nBWBWBWBW\nWBWBWBWB\nBWBWBWBW\nBWBWBWBW\nBWBWBWBW\nBWBWBWBW", "WBWBWBWB\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB\nWBWBWBWB\nWBWBWBWB\nWBWBWBWB\nBWWWBWBW", "BBBBBWWW\nWBBWBWWB\nWWWWWBWW\nBWBWWBWW\nBBBWWBWW\nBBBBBWBW\nWBBBWBWB\nWBWBWWWB", "BWBWBWBW\nBWBWBWBW\nBWWWWWBB\nBBWBWBWB\nWBWBWBWB\nWWBWWBWW\nBWBWBWBW\nWBWWBBBB", "WBWBWBWB\nWBWBWBWB\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB\nWBWWBWBB", "WBWBWBWB\nBWBWBWBW\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB\nWBWBWBWB\nBWBWBWBW\nBWBWBWBW", "WBWBWBWB\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB\nBWBWBWBW\nBWBWBWBW", "WWWWBWWB\nBWBWBWBW\nBWBWBWBW\nWWBWBBBB\nBBWWBBBB\nBBBWWBBW\nBWWWWWWB\nBWWBBBWW", "WBBWWBWB\nBBWBWBWB\nBWBWBWBW\nBWBWBWBW\nWBWBWBBW\nWBWBBBBW\nBWWWWBWB\nBBBBBBBW", "BWBWBWBW\nBWBWBWBW\nBBWWWBBB\nWBBBBBWW\nWBBBBWBB\nWBWBWBWB\nWBWWBWWB\nWBBWBBWW", "WBBBBBWB\nBWBWBWBW\nBWBWBWBW\nWBWBWBWB\nWBWBWBWB\nBBBBBWBB\nWBBWWBWB\nBWBWBWBW", "BWBWBWBW\nBWBWBWBW\nBWBWBWBW\nWBWBWBWB\nWBWBWBWB\nBWBWBWBW\nBWBWBWBW\nWBBWWBWB", "BWBWBWBW\nWBWBWBWB\nBWBWBWBW\nBWWWBWBW\nWBWBWBWB\nWBWBWBWB\nBWBWBWBW\nWBWBWBBW", "WBWBWBWB\nWBWBWBWB\nBWBWBWBW\nBWBWBWBW\nBWBWBWBW\nBWBWBWBW\nWBWBWBWB\nBWBWBWBW", "BWBWBWBW\nWBWBWBWB\nBWBWBWBW\nBWBWBWBW\nBWBWBWBW\nBWBWBWBW\nWBWBWBWB\nBWBWBWBW", "BWBWBWBW\nBWBWBWBW\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB\nBWBWBWBW", "WWBBWWBB\nBWWBBWWB\nBWBWBWBW\nWWBBWWWB\nWBWWWWBB\nWBWWBBWB\nBWBBWBWW\nBWBWWWWW", "WBWBWBWB\nWBWBWBWB\nWWBBWBBB\nWBWBWBWB\nWWWWBWWB\nWBBBBWWW\nBWBWWWBW\nWWWBWBBB", "WBWBWBWB\nBWWBWWWW\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB\nWWBBBBBW\nWWWBWWBW\nWWBBBBWW", "BWBWBWBW\nBWBBBWWB\nWBWBWBWB\nBWBWBWBW\nBWBWBWBW\nBWBWBWBW\nWBWBWBWB\nBWBWBWBW", "BWBWBWBW\nBWBWBWBW\nWBWBWBWB\nWBWBWBWB\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB\nBWBWBWBW", "BBBBBBBB\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW", "BBBBBBBB\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB", "BWBWBWBB\nBWBWBWBB\nBWBWBWBB\nBWBWBWBB\nBWBWBWBB\nBWBWBWBB\nBWBWBWBB\nBWBWBWBB", "WWBWWBWB\nBWBWBWBW\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB\nBWBWBWBW", "WWWWWWWW\nBBBBBBBB\nWWWWWWWW\nBBBBBBBB\nWWWWWWWW\nBBBBBBBB\nWWWWWWWW\nBBBBBBBB", "BBBBBBBB\nBWBWBWBW\nBWBWBWBW\nBWBWBWBW\nWBWBWBWB\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB", "BBBBBBBW\nBBBBBBBW\nBBBBBBBW\nBBBBBBBW\nBBBBBBBW\nBBBBBBBW\nBBBBBBBW\nBBBBBBBW", "BBBWWWWW\nWWWBBBBB\nBBBWWWWW\nWWWBBBBB\nBWBWBWBW\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB"], "outputs": ["YES", "NO", "YES", "YES", "YES", "NO", "NO", "NO", "NO", "YES", "YES", "NO", "NO", "NO", "NO", "NO", "NO", "YES", "YES", "YES", "NO", "NO", "NO", "NO", "YES", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 204 | codeforces |
|
53591cfe13dfca10ed3fe3da3e03db20 | Little Artem and Random Variable | Little Artyom decided to study probability theory. He found a book with a lot of nice exercises and now wants you to help him with one of them.
Consider two dices. When thrown each dice shows some integer from 1 to *n* inclusive. For each dice the probability of each outcome is given (of course, their sum is 1), and different dices may have different probability distributions.
We throw both dices simultaneously and then calculate values *max*(*a*,<=*b*) and *min*(*a*,<=*b*), where *a* is equal to the outcome of the first dice, while *b* is equal to the outcome of the second dice. You don't know the probability distributions for particular values on each dice, but you know the probability distributions for *max*(*a*,<=*b*) and *min*(*a*,<=*b*). That is, for each *x* from 1 to *n* you know the probability that *max*(*a*,<=*b*) would be equal to *x* and the probability that *min*(*a*,<=*b*) would be equal to *x*. Find any valid probability distribution for values on the dices. It's guaranteed that the input data is consistent, that is, at least one solution exists.
First line contains the integer *n* (1<=β€<=*n*<=β€<=100<=000)Β β the number of different values for both dices.
Second line contains an array consisting of *n* real values with up to 8 digits after the decimal point Β β probability distribution for *max*(*a*,<=*b*), the *i*-th of these values equals to the probability that *max*(*a*,<=*b*)<==<=*i*. It's guaranteed that the sum of these values for one dice is 1. The third line contains the description of the distribution *min*(*a*,<=*b*) in the same format.
Output two descriptions of the probability distribution for *a* on the first line and for *b* on the second line.
The answer will be considered correct if each value of max(*a*,<=*b*) and min(*a*,<=*b*) probability distribution values does not differ by more than 10<=-<=6 from ones given in input. Also, probabilities should be non-negative and their sums should differ from 1 by no more than 10<=-<=6.
Sample Input
2
0.25 0.75
0.75 0.25
3
0.125 0.25 0.625
0.625 0.25 0.125
Sample Output
0.5 0.5
0.5 0.5
0.25 0.25 0.5
0.5 0.25 0.25
| {"inputs": ["2\n0.25 0.75\n0.75 0.25", "3\n0.125 0.25 0.625\n0.625 0.25 0.125", "10\n0.01 0.01 0.01 0.01 0.01 0.1 0.2 0.2 0.4 0.05\n1.0 0 0 0 0 0 0 0 0 0", "10\n0 0 0 0 0 0 0 0 0 1.0\n1.0 0 0 0 0 0 0 0 0 0", "1\n1.0\n1.0", "2\n0.00001 0.99999\n0.5 0.5", "3\n0.1 0.1 0.8\n0.6 0.2 0.2", "8\n0.09597231 0.11315755 0.32077119 0.22643005 0.03791746 0.04296694 0.10284494 0.05993956\n0.52402769 0.19814245 0.20452881 0.06686995 0.00468254 0.00103306 0.00055506 0.00016044"], "outputs": ["0.5 0.5 \n0.5 0.5 ", "0.25 0.25 0.5 \n0.5 0.25 0.25 ", "0.010000000000000009 0.010000000000000009 0.010000000000000009 0.009999999999999953 0.010000000000000009 0.10000000000000003 0.2 0.1999999999999999 0.39999999999999825 0.05000000000000182 \n1.0 0.0 0.0 0.0 0.0 -1.1102230246251565E-16 1.1102230246251565E-16 0.0 1.9984014443252818E-15 -1.9984014443252818E-15 ", "0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 \n1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ", "1.0 \n1.0 ", "2.000040002400616E-5 0.999979999599976 \n0.4999899995999759 0.5000100004000241 ", "0.20000000000000004 0.07639320225002103 0.7236067977499789 \n0.4999999999999999 0.22360679774997905 0.27639320225002106 ", "0.29869999999999886 0.07920000000000116 0.32760000000000133 0.0734999999999989 0.02229999999999943 0.039699999999999847 0.10169999999999968 0.057299989463288625 \n0.32130000000000125 0.23209999999999875 0.19769999999999854 0.219800000000001 0.020300000000000762 0.0043000000000001926 0.0017000000000002569 0.002800010536711417 "]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces |
|
535ff148f11b5e0f05a3efd56473da55 | Ilya and Roads | Everything is great about Ilya's city, except the roads. The thing is, the only ZooVille road is represented as *n* holes in a row. We will consider the holes numbered from 1 to *n*, from left to right.
Ilya is really keep on helping his city. So, he wants to fix at least *k* holes (perharps he can fix more) on a single ZooVille road.
The city has *m* building companies, the *i*-th company needs *c**i* money units to fix a road segment containing holes with numbers of at least *l**i* and at most *r**i*. The companies in ZooVille are very greedy, so, if they fix a segment containing some already fixed holes, they do not decrease the price for fixing the segment.
Determine the minimum money Ilya will need to fix at least *k* holes.
The first line contains three integers *n*,<=*m*,<=*k* (1<=β€<=*n*<=β€<=300,<=1<=β€<=*m*<=β€<=105,<=1<=β€<=*k*<=β€<=*n*). The next *m* lines contain the companies' description. The *i*-th line contains three integers *l**i*,<=*r**i*,<=*c**i* (1<=β€<=*l**i*<=β€<=*r**i*<=β€<=*n*,<=1<=β€<=*c**i*<=β€<=109).
Print a single integer β the minimum money Ilya needs to fix at least *k* holes.
If it is impossible to fix at least *k* holes, print -1.
Please, do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier.
Sample Input
10 4 6
7 9 11
6 9 13
7 7 7
3 5 6
10 7 1
3 4 15
8 9 8
5 6 8
9 10 6
1 4 2
1 4 10
8 10 13
10 1 9
5 10 14
Sample Output
17
2
-1
| {"inputs": ["10 4 6\n7 9 11\n6 9 13\n7 7 7\n3 5 6", "10 7 1\n3 4 15\n8 9 8\n5 6 8\n9 10 6\n1 4 2\n1 4 10\n8 10 13", "10 1 9\n5 10 14", "10 6 9\n6 8 7\n2 8 11\n2 6 10\n8 10 9\n2 5 8\n2 3 8", "10 6 8\n3 6 7\n1 4 3\n2 7 10\n4 7 4\n7 10 15\n4 7 7", "10 4 10\n1 1 11\n7 7 15\n2 3 11\n2 8 6", "10 3 7\n4 6 6\n5 7 1\n2 10 15", "10 5 3\n2 10 10\n3 6 10\n5 5 7\n2 7 4\n2 7 6", "10 5 4\n2 8 3\n4 7 15\n1 1 13\n7 9 10\n10 10 2", "1 1 1\n1 1 1", "10 2 6\n1 7 1123\n2 10 33", "5 2 5\n1 3 1\n2 5 1", "1 3 1\n1 1 5\n1 1 3\n1 1 12", "3 3 3\n1 2 1000000000\n2 3 1000000000\n1 1 1000000000"], "outputs": ["17", "2", "-1", "20", "18", "-1", "15", "4", "3", "1", "33", "2", "3", "2000000000"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces |
|
538e5a259bf9609053b62f07a3684521 | The Child and Toy | On Children's Day, the child got a toy from Delayyy as a present. However, the child is so naughty that he can't wait to destroy the toy.
The toy consists of *n* parts and *m* ropes. Each rope links two parts, but every pair of parts is linked by at most one rope. To split the toy, the child must remove all its parts. The child can remove a single part at a time, and each remove consume an energy. Let's define an energy value of part *i* as *v**i*. The child spend *v**f*1<=+<=*v**f*2<=+<=...<=+<=*v**f**k* energy for removing part *i* where *f*1,<=*f*2,<=...,<=*f**k* are the parts that are directly connected to the *i*-th and haven't been removed.
Help the child to find out, what is the minimum total energy he should spend to remove all *n* parts.
The first line contains two integers *n* and *m* (1<=β€<=*n*<=β€<=1000; 0<=β€<=*m*<=β€<=2000). The second line contains *n* integers: *v*1,<=*v*2,<=...,<=*v**n* (0<=β€<=*v**i*<=β€<=105). Then followed *m* lines, each line contains two integers *x**i* and *y**i*, representing a rope from part *x**i* to part *y**i* (1<=β€<=*x**i*,<=*y**i*<=β€<=*n*;Β *x**i*<=β <=*y**i*).
Consider all the parts are numbered from 1 to *n*.
Output the minimum total energy the child should spend to remove all *n* parts of the toy.
Sample Input
4 3
10 20 30 40
1 4
1 2
2 3
4 4
100 100 100 100
1 2
2 3
2 4
3 4
7 10
40 10 20 10 20 80 40
1 5
4 7
4 5
5 2
5 7
6 4
1 6
1 3
4 3
1 4
Sample Output
40
400
160
| {"inputs": ["4 3\n10 20 30 40\n1 4\n1 2\n2 3", "4 4\n100 100 100 100\n1 2\n2 3\n2 4\n3 4", "7 10\n40 10 20 10 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4", "1 0\n23333", "5 4\n1 2 2 2 2\n1 2\n1 3\n1 4\n1 5", "10 30\n3 6 17 15 13 15 6 12 9 1\n3 8\n1 10\n4 7\n1 7\n3 7\n2 9\n8 10\n3 1\n3 4\n8 6\n10 3\n3 9\n2 3\n10 4\n2 10\n5 8\n9 5\n6 1\n2 1\n7 2\n7 6\n7 10\n4 8\n5 6\n3 6\n4 1\n8 9\n7 9\n4 2\n5 10", "3 3\n1 1 1\n1 2\n2 3\n3 1"], "outputs": ["40", "400", "160", "0", "4", "188", "3"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 224 | codeforces |
|
53bf4c704b2a544a0f1fb3c16762f47a | Lineland Mail | All cities of Lineland are located on the *Ox* coordinate axis. Thus, each city is associated with its position *x**i* β a coordinate on the *Ox* axis. No two cities are located at a single point.
Lineland residents love to send letters to each other. A person may send a letter only if the recipient lives in another city (because if they live in the same city, then it is easier to drop in).
Strange but true, the cost of sending the letter is exactly equal to the distance between the sender's city and the recipient's city.
For each city calculate two values ββ*min**i* and *max**i*, where *min**i* is the minimum cost of sending a letter from the *i*-th city to some other city, and *max**i* is the the maximum cost of sending a letter from the *i*-th city to some other city
The first line of the input contains integer *n* (2<=β€<=*n*<=β€<=105) β the number of cities in Lineland. The second line contains the sequence of *n* distinct integers *x*1,<=*x*2,<=...,<=*x**n* (<=-<=109<=β€<=*x**i*<=β€<=109), where *x**i* is the *x*-coordinate of the *i*-th city. All the *x**i*'s are distinct and follow in ascending order.
Print *n* lines, the *i*-th line must contain two integers *min**i*,<=*max**i*, separated by a space, where *min**i* is the minimum cost of sending a letter from the *i*-th city, and *max**i* is the maximum cost of sending a letter from the *i*-th city.
Sample Input
4
-5 -2 2 7
2
-1 1
Sample Output
3 12
3 9
4 7
5 12
2 2
2 2
| {"inputs": ["4\n-5 -2 2 7", "2\n-1 1", "3\n-1 0 1", "4\n-1 0 1 3", "3\n-1000000000 0 1000000000", "2\n-1000000000 1000000000", "10\n1 10 12 15 59 68 130 912 1239 9123", "5\n-2 -1 0 1 2", "5\n-2 -1 0 1 3", "3\n-10000 1 10000", "5\n-1000000000 -999999999 -999999998 -999999997 -999999996", "10\n-857422304 -529223472 82412729 145077145 188538640 265299215 527377039 588634631 592896147 702473706", "10\n-876779400 -829849659 -781819137 -570920213 18428128 25280705 121178189 219147240 528386329 923854124", "30\n-15 1 21 25 30 40 59 60 77 81 97 100 103 123 139 141 157 158 173 183 200 215 226 231 244 256 267 279 289 292", "10\n-1000000000 -999999999 -999999997 -999999996 -999999995 -999999994 -999999992 -999999990 -999999988 -999999986", "50\n-50000 -49459 -48875 -48456 -48411 -48096 -47901 -47500 -47150 -46808 -46687 -46679 -46337 -45747 -45604 -45194 -44752 -44242 -44231 -44122 -43636 -43274 -42916 -42881 -42386 -42095 -41830 -41618 -41145 -40897 -40534 -40007 -39761 -39389 -39104 -38909 -38630 -38561 -38364 -38255 -38214 -38084 -37959 -37607 -37202 -36890 -36681 -36136 -36123 -35886", "3\n-1000000000 999999999 1000000000"], "outputs": ["3 12\n3 9\n4 7\n5 12", "2 2\n2 2", "1 2\n1 1\n1 2", "1 4\n1 3\n1 2\n2 4", "1000000000 2000000000\n1000000000 1000000000\n1000000000 2000000000", "2000000000 2000000000\n2000000000 2000000000", "9 9122\n2 9113\n2 9111\n3 9108\n9 9064\n9 9055\n62 8993\n327 8211\n327 7884\n7884 9122", "1 4\n1 3\n1 2\n1 3\n1 4", "1 5\n1 4\n1 3\n1 3\n2 5", "10001 20000\n9999 10001\n9999 20000", "1 4\n1 3\n1 2\n1 3\n1 4", "328198832 1559896010\n328198832 1231697178\n62664416 939835033\n43461495 1002499449\n43461495 1045960944\n76760575 1122721519\n61257592 1384799343\n4261516 1446056935\n4261516 1450318451\n109577559 1559896010", "46929741 1800633524\n46929741 1753703783\n48030522 1705673261\n210898924 1494774337\n6852577 905425996\n6852577 902060105\n95897484 997957589\n97969051 1095926640\n309239089 1405165729\n395467795 1800633524", "16 307\n16 291\n4 271\n4 267\n5 262\n10 252\n1 233\n1 232\n4 215\n4 211\n3 195\n3 192\n3 189\n16 169\n2 154\n2 156\n1 172\n1 173\n10 188\n10 198\n15 215\n11 230\n5 241\n5 246\n12 259\n11 271\n11 282\n10 294\n3 304\n3 307", "1 14\n1 13\n1 11\n1 10\n1 9\n1 8\n2 8\n2 10\n2 12\n2 14", "541 14114\n541 13573\n419 12989\n45 12570\n45 12525\n195 12210\n195 12015\n350 11614\n342 11264\n121 10922\n8 10801\n8 10793\n342 10451\n143 9861\n143 9718\n410 9308\n442 8866\n11 8356\n11 8345\n109 8236\n362 7750\n358 7388\n35 7084\n35 7119\n291 7614\n265 7905\n212 8170\n212 8382\n248 8855\n248 9103\n363 9466\n246 9993\n246 10239\n285 10611\n195 10896\n195 11091\n69 11370\n69 11439\n109 11636\n41 11745\n41 11786\n125 11916\n125 12041\n352 12393\n312 12798\n209 13110\n209 13319\n13 13864\n13 13877\n237 141...", "1999999999 2000000000\n1 1999999999\n1 2000000000"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 608 | codeforces |
|
53c54a45f7b49ca7ba7f34ca352c10d6 | Dog Show | A new dog show on TV is starting next week. On the show dogs are required to demonstrate bottomless stomach, strategic thinking and self-preservation instinct. You and your dog are invited to compete with other participants and naturally you want to win!
On the show a dog needs to eat as many bowls of dog food as possible (bottomless stomach helps here). Dogs compete separately of each other and the rules are as follows:
At the start of the show the dog and the bowls are located on a line. The dog starts at position *x*<==<=0 and *n* bowls are located at positions *x*<==<=1,<=*x*<==<=2,<=...,<=*x*<==<=*n*. The bowls are numbered from 1 to *n* from left to right. After the show starts the dog immediately begins to run to the right to the first bowl.
The food inside bowls is not ready for eating at the start because it is too hot (dog's self-preservation instinct prevents eating). More formally, the dog can eat from the *i*-th bowl after *t**i* seconds from the start of the show or later.
It takes dog 1 second to move from the position *x* to the position *x*<=+<=1. The dog is not allowed to move to the left, the dog runs only to the right with the constant speed 1 distance unit per second. When the dog reaches a bowl (say, the bowl *i*), the following cases are possible:
- the food had cooled down (i.e. it passed at least *t**i* seconds from the show start): the dog immediately eats the food and runs to the right without any stop, - the food is hot (i.e. it passed less than *t**i* seconds from the show start): the dog has two options: to wait for the *i*-th bowl, eat the food and continue to run at the moment *t**i* or to skip the *i*-th bowl and continue to run to the right without any stop.
After *T* seconds from the start the show ends. If the dog reaches a bowl of food at moment *T* the dog can not eat it. The show stops before *T* seconds if the dog had run to the right of the last bowl.
You need to help your dog create a strategy with which the maximum possible number of bowls of food will be eaten in *T* seconds.
Two integer numbers are given in the first line - *n* and *T* (1<=β€<=*n*<=β€<=200<=000, 1<=β€<=*T*<=β€<=2Β·109) β the number of bowls of food and the time when the dog is stopped.
On the next line numbers *t*1,<=*t*2,<=...,<=*t**n* (1<=β€<=*t**i*<=β€<=109) are given, where *t**i* is the moment of time when the *i*-th bowl of food is ready for eating.
Output a single integer β the maximum number of bowls of food the dog will be able to eat in *T* seconds.
Sample Input
3 5
1 5 3
1 2
1
1 1
1
Sample Output
2
1
0
| {"inputs": ["3 5\n1 5 3", "1 2\n1", "1 1\n1", "1 1\n2", "2 2\n2 3", "2 3\n2 1", "3 3\n2 3 2", "3 2\n2 3 4", "3 4\n2 1 2", "4 4\n2 1 2 3", "4 3\n2 1 2 3", "4 6\n2 3 4 5", "5 5\n2 1 2 3 4", "5 3\n2 3 2 1 2", "5 7\n2 1 2 3 4", "6 6\n2 3 2 3 4 3", "6 4\n2 3 2 3 4 3", "6 9\n2 1 2 1 2 3", "7 7\n2 3 4 5 6 5 6", "7 4\n2 1 2 3 2 3 2", "7 10\n2 3 4 3 2 3 2", "8 8\n2 3 2 3 4 5 4 5", "8 5\n2 3 2 3 4 3 4 3", "8 12\n2 3 2 3 4 3 4 3", "9 9\n2 3 4 5 4 5 6 7 6", "9 5\n2 3 4 3 2 3 4 5 6", "9 13\n2 1 2 3 4 5 4 5 6", "10 10\n2 1 2 3 4 3 4 3 4 3", "10 6\n2 3 4 3 4 5 6 7 6 7", "10 15\n2 1 2 1 2 3 4 5 6 7", "11 11\n2 3 4 5 6 5 4 5 4 3 4", "11 6\n2 3 4 3 4 3 4 5 4 3 2", "11 16\n2 3 2 1 2 3 4 5 4 3 4", "12 12\n2 3 4 5 6 7 6 7 8 9 10 11", "12 7\n2 3 4 3 4 3 2 3 4 3 4 5", "12 18\n2 1 2 3 4 5 6 5 6 5 6 5", "13 13\n2 1 2 3 4 3 2 3 4 5 6 5 4", "13 7\n2 1 2 3 2 3 2 3 4 3 4 5 6", "13 19\n2 3 4 5 6 5 4 5 6 7 8 9 8", "14 14\n2 3 4 5 6 7 8 9 10 11 12 13 14 15", "14 8\n2 3 4 5 6 7 8 7 6 7 8 9 10 9", "14 21\n2 1 2 3 4 5 6 5 6 7 8 9 8 9", "15 15\n2 3 4 3 2 3 4 3 4 3 4 5 6 5 6", "15 8\n2 3 2 1 2 1 2 3 2 3 4 3 4 5 4", "15 22\n2 3 2 3 2 3 4 5 6 7 6 7 8 9 10", "16 16\n2 1 2 3 2 3 4 5 6 5 4 5 6 5 6 7", "16 9\n2 3 4 5 4 3 4 5 6 7 8 7 8 9 10 11", "16 24\n2 3 4 5 6 5 6 7 6 7 8 9 10 11 12 13", "17 17\n2 3 2 1 2 3 4 5 6 7 8 9 10 11 12 11 12", "17 9\n2 3 4 5 6 7 8 9 10 11 10 11 10 11 12 13 12", "17 25\n2 1 2 1 2 3 2 3 2 1 2 1 2 1 2 1 2", "18 18\n2 3 4 5 4 5 6 5 6 7 6 7 6 5 6 7 8 7", "18 10\n2 3 4 3 4 3 4 5 6 5 6 7 8 9 10 9 8 9", "18 27\n2 3 4 3 4 5 6 7 8 9 10 9 8 9 8 9 10 9", "19 19\n2 1 2 3 4 5 4 5 6 7 6 7 8 9 10 11 12 11 12", "19 10\n2 1 2 3 4 3 4 3 2 3 4 3 4 3 4 5 6 5 4", "19 28\n2 3 4 3 4 5 6 5 6 5 6 7 8 7 8 9 10 11 12", "20 20\n2 1 2 3 2 1 2 3 4 3 2 3 4 5 6 7 8 9 8 9", "20 11\n2 3 4 5 6 7 6 5 6 7 8 9 10 11 12 11 12 13 12 11", "20 30\n2 3 2 3 4 5 6 5 6 7 6 7 8 9 8 7 8 9 10 11", "1 1\n2", "2 2\n2 3", "2 3\n2 3", "3 3\n2 1 2", "3 2\n2 1 2", "3 4\n2 1 2", "4 4\n2 3 2 3", "4 3\n2 1 2 3", "4 6\n2 3 4 5", "5 5\n2 1 2 3 4", "5 3\n2 3 4 5 6", "5 7\n2 3 4 5 6", "6 6\n2 1 2 3 4 5", "6 4\n2 3 4 5 6 7", "6 9\n2 3 4 5 6 7", "7 7\n2 1 2 1 2 3 4", "7 4\n2 3 4 5 4 5 6", "7 10\n2 1 2 3 2 3 4", "8 8\n2 3 2 3 2 3 4 5", "8 5\n2 3 4 3 2 3 4 3", "8 12\n2 3 4 3 2 3 4 3", "9 9\n2 1 2 3 4 5 6 5 6", "9 5\n2 1 2 3 4 3 2 3 4", "9 13\n2 3 4 5 6 5 6 7 8", "10 10\n2 3 4 3 4 5 6 7 6 7", "10 6\n2 3 4 5 6 7 8 9 10 11", "10 15\n2 3 4 5 6 7 8 9 10 11", "11 11\n2 3 4 5 6 7 8 9 10 11 12", "11 6\n2 3 4 5 6 7 8 7 8 9 8", "11 16\n2 3 4 5 6 5 6 5 6 5 6", "12 12\n2 1 2 3 4 5 6 7 8 7 6 5", "12 7\n2 3 4 5 6 7 8 9 10 11 10 11", "12 18\n2 1 2 3 2 3 2 1 2 3 2 3", "13 13\n2 3 4 5 6 7 8 7 6 7 8 9 10", "13 7\n2 3 4 5 6 7 8 9 10 11 12 13 14", "13 19\n2 3 4 5 6 5 6 7 6 7 8 9 8", "14 14\n2 3 4 5 6 5 4 5 6 7 8 7 8 9", "14 8\n2 3 4 5 6 7 6 7 8 7 8 9 10 11", "14 21\n2 1 2 3 4 5 4 5 4 5 4 3 4 5", "15 15\n2 1 2 3 2 3 4 5 6 5 6 5 6 5 6", "15 8\n2 3 4 3 4 5 6 7 8 7 6 5 6 7 8", "15 22\n2 3 2 1 2 3 4 5 6 7 8 9 10 9 10", "16 16\n2 3 4 5 6 5 6 7 8 7 6 7 8 9 10 11", "16 9\n2 1 2 3 4 5 6 5 4 5 6 7 8 9 10 11", "16 24\n2 3 4 5 6 7 8 9 10 9 10 9 10 11 12 13", "17 17\n2 3 2 3 4 3 4 5 6 7 8 9 8 7 6 7 8", "17 9\n2 1 2 3 4 3 4 5 6 7 8 9 10 11 10 11 12", "17 25\n2 3 4 3 2 3 2 1 2 3 4 5 4 5 4 5 6", "18 18\n2 3 2 3 4 5 6 5 6 7 8 9 10 11 12 13 14 15", "18 10\n2 3 4 5 6 7 8 9 10 11 12 13 12 11 10 9 10 11", "18 27\n2 3 4 5 6 7 8 9 10 9 10 9 10 11 10 9 10 11", "19 19\n2 3 4 5 6 5 4 5 6 7 8 9 10 11 12 13 14 15 16", "19 10\n2 1 2 3 4 3 4 5 4 5 6 7 8 9 10 11 12 13 14", "19 28\n2 1 2 3 4 5 4 5 6 7 8 9 8 9 10 9 8 9 8", "20 20\n2 3 4 5 6 7 8 9 10 11 12 11 12 13 14 15 16 17 18 19", "20 11\n2 3 2 3 4 5 6 5 6 7 8 7 6 7 8 7 8 9 8 9", "20 30\n2 3 4 5 4 5 4 5 6 7 8 9 10 11 12 13 14 15 16 17", "100 180\n150 52 127 175 146 138 25 71 192 108 142 79 196 129 23 44 92 11 63 198 197 65 47 144 141 158 142 41 1 102 113 50 171 97 75 31 199 24 17 59 138 53 37 123 64 103 156 141 33 186 150 10 103 29 2 182 38 85 155 73 136 175 83 93 20 59 11 87 178 92 132 11 6 99 109 193 135 132 57 36 123 152 36 80 9 137 122 131 122 108 44 84 180 65 192 192 29 150 147 20", "100 154\n132 88 72 98 184 47 176 56 68 168 137 88 188 140 198 18 162 139 94 133 90 91 37 156 196 28 186 1 51 47 4 92 18 51 37 121 86 195 153 195 183 191 15 24 104 174 94 83 102 61 131 40 149 46 22 112 13 136 133 177 3 175 160 152 172 48 44 174 77 100 155 157 167 174 64 109 118 194 120 7 8 179 36 149 58 145 163 163 45 14 164 111 176 196 42 161 71 148 192 38", "7 11\n3 7 10 13 9 12 4", "10 20\n5 12 21 14 23 17 24 11 25 22"], "outputs": ["2", "1", "0", "0", "0", "1", "1", "0", "2", "2", "1", "4", "3", "1", "5", "4", "2", "6", "5", "2", "7", "6", "3", "8", "7", "3", "9", "8", "4", "10", "9", "4", "11", "10", "5", "12", "11", "5", "13", "12", "6", "14", "13", "6", "15", "14", "7", "16", "15", "7", "17", "16", "8", "18", "17", "8", "19", "18", "9", "20", "0", "0", "1", "1", "0", "2", "2", "1", "4", "3", "1", "5", "4", "2", "6", "5", "2", "7", "6", "3", "8", "7", "3", "9", "8", "4", "10", "9", "4", "11", "10", "5", "12", "11", "5", "13", "12", "6", "14", "13", "6", "15", "14", "7", "16", "15", "7", "17", "16", "8", "18", "17", "8", "19", "18", "9", "20", "68", "44", "3", "5"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces |
|
53de648b0565d1a3703a8ca27e960722 | Nikita and string | One day Nikita found the string containing letters "a" and "b" only.
Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-nd contains only letters "b".
Nikita wants to make the string beautiful by removing some (possibly none) of its characters, but without changing their order. What is the maximum length of the string he can get?
The first line contains a non-empty string of length not greater than 5<=000 containing only lowercase English letters "a" and "b".
Print a single integerΒ β the maximum possible size of beautiful string Nikita can get.
Sample Input
abba
bab
Sample Output
42 | {"inputs": ["abba", "bab", "bbabbbaabbbb", "bbabbbbbaaba", "bbabbbababaa", "aabbaababbab", "a", "b", "ab", "ba", "bb", "aa", "babbbaab", "abaaaa", "aaa"], "outputs": ["4", "2", "9", "10", "9", "8", "1", "1", "2", "2", "2", "2", "6", "6", "3"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 72 | codeforces |
|
53fa4bd5bc566062e8f1db038d8f15de | Pattern | Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string meets the certain rules.
In this task, a pattern will be a string consisting of small English letters and question marks ('?'). The question mark in the pattern is a metacharacter that denotes an arbitrary small letter of the English alphabet. We will assume that a string matches the pattern if we can transform the string into the pattern by replacing the question marks by the appropriate characters. For example, string aba matches patterns: ???, ??a, a?a, aba.
Programmers that work for the R1 company love puzzling each other (and themselves) with riddles. One of them is as follows: you are given *n* patterns of the same length, you need to find a pattern that contains as few question marks as possible, and intersects with each of the given patterns. Two patterns intersect if there is a string that matches both the first and the second pattern. Can you solve this riddle?
The first line contains a single integer *n* (1<=β€<=*n*<=β€<=105) β the number of patterns. Next *n* lines contain the patterns.
It is guaranteed that the patterns can only consist of small English letters and symbols '?'. All patterns are non-empty and have the same length. The total length of all the patterns does not exceed 105 characters.
In a single line print the answer to the problem β the pattern with the minimal number of signs '?', which intersects with each of the given ones. If there are several answers, print any of them.
Sample Input
2
?ab
??b
2
a
b
1
?a?b
Sample Output
xab
?
cacb
| {"inputs": ["2\n?ab\n??b", "2\na\nb", "1\n?a?b", "1\n?", "3\nabacaba\nabacaba\nabacaba", "3\nabc?t\n?bc?z\nab??t", "4\nabc\ndef\n???\nxyz", "2\n?????\n?????", "2\na\na", "3\nabc\n???\naxc", "1\n?m??x?xxexxx?xxmxx??", "2\nhszhh?zszs\nhhzhz?zzhs", "3\neddzde\needded\nzdde?z", "4\nff?o?\nfk?of\nk?kof\nfk?oo", "5\nyigi\ne?gi\niig?\n?eg?\n??gi", "100\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz\nz", "100\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?", "1\nq", "2\n?\n?", "2\n?\na", "2\n?\nb", "3\n?\na\na", "3\na\n?\na", "3\na\nb\n?", "3\n?\na\nb", "3\nb\n?\na", "2\n???\naaa", "2\n??\nss"], "outputs": ["xab", "?", "cacb", "x", "abacaba", "abcx?", "???", "xxxxx", "a", "a?c", "cmccxcxxexxxcxxmxxcc", "h?zh?cz??s", "??d???", "??ko?", "??gi", "z", "bc", "q", "x", "a", "b", "a", "a", "?", "?", "?", "aaa", "ss"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 74 | codeforces |
|
5400ae66fbdd291d560caf981f43e7e0 | Petya and Staircases | Little boy Petya loves stairs very much. But he is bored from simple going up and down them β he loves jumping over several stairs at a time. As he stands on some stair, he can either jump to the next one or jump over one or two stairs at a time. But some stairs are too dirty and Petya doesn't want to step on them.
Now Petya is on the first stair of the staircase, consisting of *n* stairs. He also knows the numbers of the dirty stairs of this staircase. Help Petya find out if he can jump through the entire staircase and reach the last stair number *n* without touching a dirty stair once.
One has to note that anyway Petya should step on the first and last stairs, so if the first or the last stair is dirty, then Petya cannot choose a path with clean steps only.
The first line contains two integers *n* and *m* (1<=β€<=*n*<=β€<=109, 0<=β€<=*m*<=β€<=3000) β the number of stairs in the staircase and the number of dirty stairs, correspondingly. The second line contains *m* different space-separated integers *d*1,<=*d*2,<=...,<=*d**m* (1<=β€<=*d**i*<=β€<=*n*) β the numbers of the dirty stairs (in an arbitrary order).
Print "YES" if Petya can reach stair number *n*, stepping only on the clean stairs. Otherwise print "NO".
Sample Input
10 5
2 4 8 3 6
10 5
2 4 5 7 9
Sample Output
NOYES | {"inputs": ["10 5\n2 4 8 3 6", "10 5\n2 4 5 7 9", "10 9\n2 3 4 5 6 7 8 9 10", "5 2\n4 5", "123 13\n36 73 111 2 92 5 47 55 48 113 7 78 37", "10 10\n7 6 4 2 5 10 8 3 9 1", "12312 0", "9817239 1\n6323187", "1 1\n1", "5 4\n4 2 5 1", "5 3\n4 3 5", "500 3\n18 62 445", "500 50\n72 474 467 241 442 437 336 234 410 120 438 164 405 177 142 114 27 20 445 235 46 176 88 488 242 391 28 414 145 92 206 334 152 343 367 254 100 243 155 348 148 450 461 483 97 34 471 69 416 362", "500 8\n365 313 338 410 482 417 325 384", "1000000000 10\n2 3 5 6 8 9 123 874 1230 1000000000", "1000000000 10\n1 2 3 5 6 8 9 123 874 1230", "10 1\n1", "10 4\n1 2 4 5", "50 20\n22 33 17 23 27 5 26 31 41 20 8 24 6 3 4 29 40 25 13 16", "50 40\n14 27 19 30 31 20 28 11 37 29 23 33 7 26 22 16 1 6 18 3 47 36 38 2 48 9 41 8 5 50 4 45 44 25 39 12 43 42 40 46", "123 12\n35 95 47 99 79 122 58 94 31 57 18 10", "10 5\n1 3 5 7 9", "100 7\n2 3 5 6 8 9 100", "100 3\n98 99 100", "100 3\n97 98 99", "100 3\n96 98 99", "10 6\n2 3 5 6 8 9", "1000000000 10\n2 4 10 18 40 42 49 58 59 60", "10 3\n1 4 6", "8 3\n2 3 4", "100 3\n4 5 6", "10 2\n10 1", "10 1\n10", "4 2\n2 3", "2 1\n1", "2 0", "4 3\n2 3 4", "5 3\n4 2 3"], "outputs": ["NO", "YES", "NO", "NO", "YES", "NO", "YES", "YES", "NO", "NO", "NO", "YES", "NO", "YES", "NO", "NO", "NO", "NO", "NO", "NO", "YES", "NO", "NO", "NO", "NO", "YES", "YES", "NO", "NO", "NO", "NO", "NO", "NO", "YES", "NO", "YES", "NO", "NO"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 44 | codeforces |
|
5403d9edc0e697bd7a0b0ef11150d83c | Gleb And Pizza | Gleb ordered pizza home. When the courier delivered the pizza, he was very upset, because several pieces of sausage lay on the crust, and he does not really like the crust.
The pizza is a circle of radius *r* and center at the origin. Pizza consists of the main part β circle of radius *r*<=-<=*d* with center at the origin, and crust around the main part of the width *d*. Pieces of sausage are also circles. The radius of the *i*Β -th piece of the sausage is *r**i*, and the center is given as a pair (*x**i*, *y**i*).
Gleb asks you to help determine the number of pieces of sausage caught on the crust. A piece of sausage got on the crust, if it completely lies on the crust.
First string contains two integer numbers *r* and *d* (0<=β€<=*d*<=<<=*r*<=β€<=500)Β β the radius of pizza and the width of crust.
Next line contains one integer number *n*Β β the number of pieces of sausage (1<=β€<=*n*<=β€<=105).
Each of next *n* lines contains three integer numbers *x**i*, *y**i* and *r**i* (<=-<=500<=β€<=*x**i*,<=*y**i*<=β€<=500, 0<=β€<=*r**i*<=β€<=500), where *x**i* and *y**i* are coordinates of the center of *i*-th peace of sausage, *r**i*Β β radius of *i*-th peace of sausage.
Output the number of pieces of sausage that lay on the crust.
Sample Input
8 4
7
7 8 1
-7 3 2
0 2 1
0 -2 2
-3 -3 1
0 6 2
5 3 1
10 8
4
0 0 9
0 0 10
1 0 1
1 0 2
Sample Output
2
0
| {"inputs": ["8 4\n7\n7 8 1\n-7 3 2\n0 2 1\n0 -2 2\n-3 -3 1\n0 6 2\n5 3 1", "10 8\n4\n0 0 9\n0 0 10\n1 0 1\n1 0 2", "1 0\n1\n1 1 0", "3 0\n5\n3 0 0\n0 3 0\n-3 0 0\n0 -3 0\n3 0 1", "9 0\n5\n8 1 0\n8 2 0\n8 3 0\n-8 3 0\n-8 2 0", "10 2\n11\n1 1 0\n2 2 3\n3 3 0\n4 4 0\n5 5 0\n6 6 0\n7 7 4\n8 8 7\n9 9 3\n10 10 100\n9 0 1", "5 3\n1\n500 500 10"], "outputs": ["2", "0", "0", "4", "0", "2", "0"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 190 | codeforces |
|
540cb1fd4a6870c7db9c8333423e798f | Cows and Poker Game | There are *n* cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED" may show his/her hand to the table. However, so as not to affect any betting decisions, he/she may only do so if all other players have a status of either "ALLIN" or "FOLDED". The player's own status may be either "ALLIN" or "IN".
Find the number of cows that can currently show their hands without affecting any betting decisions.
The first line contains a single integer, *n* (2<=β€<=*n*<=β€<=2Β·105). The second line contains *n* characters, each either "A", "I", or "F". The *i*-th character is "A" if the *i*-th player's status is "ALLIN", "I" if the *i*-th player's status is "IN", or "F" if the *i*-th player's status is "FOLDED".
The first line should contain a single integer denoting the number of players that can currently show their hands.
Sample Input
6
AFFAAA
3
AFI
Sample Output
4
1
| {"inputs": ["6\nAFFAAA", "3\nAFI", "3\nFFF", "3\nFIF", "3\nAAA", "3\nIII", "3\nIIA", "3\nAFF", "5\nFAFFF", "3\nIAA", "3\nIIF", "2\nFA", "2\nFF", "2\nIF", "5\nAAAAI", "5\nIIIIF", "10\nAAAAAAAAAA", "100\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "5\nFAIAF", "5\nAIAIF", "5\nFAAII", "5\nAIFFF", "5\nAFAFA", "2\nFA", "8\nAFFFFIAF", "8\nIAAIFFFI", "5\nIIIII"], "outputs": ["4", "1", "0", "1", "3", "0", "0", "1", "1", "1", "0", "1", "0", "1", "1", "0", "10", "100", "1", "0", "0", "1", "3", "1", "1", "0", "0"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 126 | codeforces |
|
549053419f14efeb49ea7377628d5a2d | Mashmokh and Numbers | It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh.
In this game Mashmokh writes sequence of *n* distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he removes the first and the second integer of the remaining sequence from the board, and so on. Bimokh stops when the board contains less than two numbers. When Bimokh removes numbers *x* and *y* from the board, he gets *gcd*(*x*,<=*y*) points. At the beginning of the game Bimokh has zero points.
Mashmokh wants to win in the game. For this reason he wants his boss to get exactly *k* points in total. But the guy doesn't know how choose the initial sequence in the right way.
Please, help him. Find *n* distinct integers *a*1,<=*a*2,<=...,<=*a**n* such that his boss will score exactly *k* points. Also Mashmokh can't memorize too huge numbers. Therefore each of these integers must be at most 109.
The first line of input contains two space-separated integers *n*,<=*k*Β (1<=β€<=*n*<=β€<=105;Β 0<=β€<=*k*<=β€<=108).
If such sequence doesn't exist output -1 otherwise output *n* distinct space-separated integers *a*1,<=*a*2,<=...,<=*a**n*Β (1<=β€<=*a**i*<=β€<=109).
Sample Input
5 2
5 37 2
Sample Output
1 2 3 4 5
2 4 3 7 1-1
| {"inputs": ["5 2", "5 3", "7 2", "1 1", "2 0", "1 10", "1 0", "7 3", "7 6", "7 7", "100000 100000000", "3455 2792393", "74086 16504611", "28515 44887064", "21324 73830196", "90212 5921828", "25095 2372924", "92977 95851971", "39095 77350428", "785 70908164", "28051 5506872", "74077 37498088", "58284 12998910", "28768 33384329", "6357 92661202", "80996 61457012", "60752 21494069", "95065 81120597", "77240 1683376", "35136 35044765", "98218 71868966", "45671 48503349", "7081 26961063", "69213 98333912", "91055 20775941", "14106 71280052", "17599 34327121", "74244 96611492", "77554 5672752", "51040 32015531", "95593 16086029", "44405 95772109", "46297 84634875", "3842 99757561", "90252 19406877", "13321 67580511", "19919 79287791", "58499 59427255", "34423 86770315", "21460 11888516", "57534 85681593", "28652 18840000", "18247 23541343", "89529 95022203", "42775 89315917", "946 93333203", "93595 48782905", "87371 60145723", "7695 94816808", "21846 16967905", "10 3", "6 1000003", "100000 549999", "10 4", "8 10", "6 10000003", "50 50000030", "7 11", "2 96996900", "3 99999997", "10000 10", "5 100000000", "20 15", "10 50000006", "4 1257", "100 1", "6 1", "10 1000004", "100000 100000", "10 3000004", "99999 149998", "11 1434567", "205 110", "11 14342267"], "outputs": ["1 2 3 4 5", "2 4 5 6 7", "-1", "-1", "-1", "-1", "1", "1 2 3 4 5 6 7", "4 8 1 2 5 6 7", "5 10 1 2 3 4 6", "99950001 199900002 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 ...", "2790667 5581334 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151...", "16467569 32935138 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 1...", "44872808 89745616 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 1...", "73819535 147639070 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 ...", "5876723 11753446 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 15...", "2360378 4720756 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151...", "95805484 191610968 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 ...", "77330882 154661764 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 ...", "70907773 141815546 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 ...", "5492848 10985696 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 15...", "37461051 74922102 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 1...", "12969769 25939538 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 1...", "33369946 66739892 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 1...", "92658025 185316050 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 ...", "61416515 122833030 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 ...", "21463694 42927388 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 1...", "81073066 162146132 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 ...", "1644757 3289514 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151...", "35027198 70054396 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 1...", "71819858 143639716 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 ...", "48480515 96961030 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 1...", "26957524 53915048 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 1...", "98299307 196598614 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 ...", "20730415 41460830 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 1...", "71273000 142546000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 ...", "34318323 68636646 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 1...", "96574371 193148742 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 ...", "5633976 11267952 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 15...", "31990012 63980024 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 1...", "16038234 32076468 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 1...", "95749908 191499816 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 ...", "84611728 169223456 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 ...", "99755641 199511282 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 ...", "19361752 38723504 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 1...", "67573852 135147704 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 ...", "79277833 158555666 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 ...", "59398007 118796014 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 ...", "86753105 173506210 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 ...", "11877787 23755574 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 1...", "85652827 171305654 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 ...", "18825675 37651350 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 1...", "23532221 47064442 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 1...", "94977440 189954880 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 ...", "89294531 178589062 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 ...", "93332731 186665462 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 ...", "48736109 97472218 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 1...", "60102039 120204078 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 ...", "94812962 189625924 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 ...", "16956983 33913966 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 1...", "-1", "1000001 2000002 1 2 3 4", "500000 1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 ...", "-1", "7 14 1 2 3 4 5 6", "10000001 20000002 1 2 3 4", "50000006 100000012 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48", "9 18 1 2 3 4 5", "96996900 193993800", "99999997 199999994 1", "-1", "99999999 199999998 1 2 3", "6 12 1 2 3 4 7 8 9 10 13 14 15 16 17 18 19 20 21 22", "50000002 100000004 1 2 3 4 5 6 7 8", "1256 2512 1 2", "-1", "-1", "1000000 2000000 1 2 3 4 5 6 7 8", "50001 100002 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 15...", "3000000 6000000 1 2 3 4 5 6 7 8", "100000 200000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 1...", "1434563 2869126 1 2 3 4 5 6 7 8 9", "9 18 1 2 3 4 5 6 7 8 10 11 12 13 14 15 16 17 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155...", "14342263 28684526 1 2 3 4 5 6 7 8 9"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 43 | codeforces |
|
54a78b545ae5ffb4e728231eb0a098e9 | Surrounded | So, the Berland is at war with its eternal enemy Flatland again, and Vasya, an accountant, was assigned to fulfil his duty to the nation.
Right now the situation in Berland is dismal β their both cities are surrounded! The armies of flatlanders stand on the borders of circles, the circles' centers are in the surrounded cities. At any moment all points of the flatland ring can begin to move quickly in the direction of the city β that's the strategy the flatlanders usually follow when they besiege cities.
The berlanders are sure that they can repel the enemy's attack if they learn the exact time the attack starts. For that they need to construct a radar that would register any movement at the distance of at most *r* from it. Thus, we can install a radar at such point, that at least one point of the enemy ring will be in its detecting range (that is, at a distance of at most *r*). Then the radar can immediately inform about the enemy's attack.
Due to the newest technologies, we can place a radar at any point without any problems. But the problem is that the berlanders have the time to make only one radar. Besides, the larger the detection radius (*r*) is, the more the radar costs.
That's why Vasya's task (that is, your task) is to find the minimum possible detection radius for the radar. In other words, your task is to find the minimum radius *r* (*r*<=β₯<=0) such, that a radar with radius *r* can be installed at some point and it can register the start of the movements of both flatland rings from that point.
In this problem you can consider the cities as material points, the attacking enemy rings - as circles with centers in the cities, the radar's detection range β as a disk (including the border) with the center at the point where the radar is placed.
The input files consist of two lines. Each line represents the city and the flatland ring that surrounds it as three space-separated integers *x**i*, *y**i*, *r**i* (|*x**i*|,<=|*y**i*|<=β€<=104;Β 1<=β€<=*r**i*<=β€<=104) β the city's coordinates and the distance from the city to the flatlanders, correspondingly.
It is guaranteed that the cities are located at different points.
Print a single real number β the minimum detection radius of the described radar. The answer is considered correct if the absolute or relative error does not exceed 10<=-<=6.
Sample Input
0 0 1
6 0 3
-10 10 3
10 -10 3
Sample Output
1.00000000000000011.142135623730951 | {"inputs": ["0 0 1\n6 0 3", "-10 10 3\n10 -10 3", "2 1 3\n8 9 5", "0 0 1\n-10 -10 9", "10000 -9268 1\n-9898 9000 10", "10000 10000 1\n-10000 -10000 1", "123 21 50\n10 100 1000", "0 3278 2382\n2312 1 1111", "3 4 5\n5 12 13", "-2 7 5\n4 0 6", "4 0 2\n6 -1 10", "41 17 3\n71 -86 10", "761 641 6\n506 -293 5", "-5051 -7339 9\n-9030 755 8", "0 5 2\n8 -4 94", "83 -64 85\n27 80 89", "-655 -750 68\n905 -161 68", "1055 -5271 60\n-2992 8832 38", "4 0 201\n-6 4 279", "-34 -5 836\n52 -39 706", "659 -674 277\n-345 -556 127", "4763 2945 956\n3591 9812 180", "3 -7 5749\n1 -6 9750", "28 -63 2382\n43 -83 1364", "315 -532 7813\n407 -157 2121", "-9577 9051 5276\n-4315 -1295 8453", "-7 -10 1\n-4 3 1", "-74 27 535\n18 84 1", "-454 -721 72\n-33 279 911", "-171 762 304\n-428 -85 523", "192 -295 1386\n-54 -78 1", "-5134 -9860 5513\n6291 -855 9034", "6651 8200 610\n-9228 9387 10000", "6370 7728 933\n4595 3736 2748", "-6 3 8\n7 2 1", "0 -1 1\n1 -1 1", "0 1 3\n1 -1 1", "-2 0 1\n3 -2 1", "-10000 42 10000\n10000 43 10000", "103 104 5\n97 96 5", "2587 4850 3327\n3278 -204 1774", "826 4417 2901\n833 -2286 3802", "1003 -5005 3399\n-6036 -1729 4365"], "outputs": ["1.000000000000000", "11.142135623730951", "1.000000000000000", "2.071067811865475", "13500.519287710202000", "14141.135623730950000", "406.061621719103360", "258.747677968983450", "0.000000000000000", "0.000000000000000", "2.881966011250105", "47.140003728560643", "478.592191632957450", "4501.080828635849700", "39.979202710603850", "0.000000000000000", "765.744715125679250", "7287.089182936641900", "33.614835192865499", "18.761487913212431", "303.455240352694320", "2915.147750239716500", "1999.381966011250100", "496.500000000000000", "2652.939776235497000", "0.000000000000000", "5.670832032063167", "212.886692948961240", "51.003686623418254", "29.065814314662131", "528.483994683445640", "0.093506651303098", "2656.651995660197400", "343.915768575204200", "2.019202405202649", "0.000000000000000", "0.000000000000000", "1.692582403567252", "0.000012499999992", "0.000000000000000", "0.009605941526345", "0.001827539409235", "0.000032199896827"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 24 | codeforces |
|
54ae528218897038012509ab2051c563 | Broken robot | You received as a gift a very clever robot walking on a rectangular board. Unfortunately, you understood that it is broken and behaves rather strangely (randomly). The board consists of *N* rows and *M* columns of cells. The robot is initially at some cell on the *i*-th row and the *j*-th column. Then at every step the robot could go to some another cell. The aim is to go to the bottommost (*N*-th) row. The robot can stay at it's current cell, move to the left, move to the right, or move to the cell below the current. If the robot is in the leftmost column it cannot move to the left, and if it is in the rightmost column it cannot move to the right. At every step all possible moves are equally probable. Return the expected number of step to reach the bottommost row.
On the first line you will be given two space separated integers *N* and *M* (1<=β€<=*N*,<=*M*<=β€<=1000). On the second line you will be given another two space separated integers *i* and *j* (1<=β€<=*i*<=β€<=*N*,<=1<=β€<=*j*<=β€<=*M*) β the number of the initial row and the number of the initial column. Note that, (1,<=1) is the upper left corner of the board and (*N*,<=*M*) is the bottom right corner.
Output the expected number of steps on a line of itself with at least 4 digits after the decimal point.
Sample Input
10 10
10 4
10 14
5 14
Sample Output
0.0000000000
18.0038068653
| {"inputs": ["10 10\n10 4", "10 14\n5 14", "126 125\n115 22", "755 51\n205 12", "385 978\n344 18", "663 904\n192 518", "293 183\n279 21", "922 109\n431 55", "552 36\n199 35", "182 314\n54 201", "812 240\n561 19", "595 881\n417 120", "694 685\n278 653", "793 840\n534 276", "892 996\n288 751", "990 800\n801 66", "89 955\n4 629", "188 759\n53 162", "287 915\n152 177", "738 718\n455 206", "1 1\n1 1", "1 2\n1 1", "1 2\n1 2", "2 1\n1 1", "2 1\n2 1", "1000 1\n2 1", "1000 1\n777 1", "1000 1\n1000 1", "1000 1\n1 1", "1000 2\n1 1", "1000 2\n1 2", "1000 2\n987 2", "1000 2\n555 1", "1000 2\n99 1", "1000 1000\n1 1", "1000 1000\n1 1000", "1000 1000\n784 234", "890 987\n84 34", "789 1\n678 1", "999 999\n888 777"], "outputs": ["0.0000000000", "18.0038068653", "43.9999127943", "2178.8368031733", "163.8049096776", "1884.0000000000", "55.9993687291", "1961.9105215665", "1387.8241647800", "512.0000000000", "998.8543916240", "711.9999999978", "1660.2444446762", "1036.0000000000", "2416.0000000000", "755.9957631761", "340.0000000000", "540.0000000000", "540.0000000000", "1132.0000000000", "0.0000000000", "0.0000000000", "0.0000000000", "2.0000000000", "0.0000000000", "1996.0000000000", "446.0000000000", "0.0000000000", "1998.0000000000", "2997.0000000000", "2997.0000000000", "39.0000000000", "1335.0000000000", "2703.0000000000", "3960.8375934644", "3960.8375934644", "864.0000000000", "3214.9192801305", "222.0000000000", "444.0000000000"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces |
|
54b9ba5fab7b748e49429697be63d53e | Present from Lena | Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to *n* as the pattern. The digits will form a rhombus. The largest digit *n* should be located in the centre. The digits should decrease as they approach the edges. For example, for *n*<==<=5 the handkerchief pattern should look like that:
Your task is to determine the way the handkerchief will look like by the given *n*.
The first line contains the single integer *n* (2<=β€<=*n*<=β€<=9).
Print a picture for the given *n*. You should strictly observe the number of spaces before the first digit on each line. Every two adjacent digits in the same line should be separated by exactly one space. There should be no spaces after the last digit at the end of each line.
Sample Input
2
3
Sample Output
0
0 1 0
0 1 2 1 0
0 1 0
0
0
0 1 0
0 1 2 1 0
0 1 2 3 2 1 0
0 1 2 1 0
0 1 0
0
| {"inputs": ["2", "3", "4", "5", "6", "7", "8", "9"], "outputs": [" 0\n 0 1 0\n0 1 2 1 0\n 0 1 0\n 0", " 0\n 0 1 0\n 0 1 2 1 0\n0 1 2 3 2 1 0\n 0 1 2 1 0\n 0 1 0\n 0", " 0\n 0 1 0\n 0 1 2 1 0\n 0 1 2 3 2 1 0\n0 1 2 3 4 3 2 1 0\n 0 1 2 3 2 1 0\n 0 1 2 1 0\n 0 1 0\n 0", " 0\n 0 1 0\n 0 1 2 1 0\n 0 1 2 3 2 1 0\n 0 1 2 3 4 3 2 1 0\n0 1 2 3 4 5 4 3 2 1 0\n 0 1 2 3 4 3 2 1 0\n 0 1 2 3 2 1 0\n 0 1 2 1 0\n 0 1 0\n 0", " 0\n 0 1 0\n 0 1 2 1 0\n 0 1 2 3 2 1 0\n 0 1 2 3 4 3 2 1 0\n 0 1 2 3 4 5 4 3 2 1 0\n0 1 2 3 4 5 6 5 4 3 2 1 0\n 0 1 2 3 4 5 4 3 2 1 0\n 0 1 2 3 4 3 2 1 0\n 0 1 2 3 2 1 0\n 0 1 2 1 0\n 0 1 0\n 0", " 0\n 0 1 0\n 0 1 2 1 0\n 0 1 2 3 2 1 0\n 0 1 2 3 4 3 2 1 0\n 0 1 2 3 4 5 4 3 2 1 0\n 0 1 2 3 4 5 6 5 4 3 2 1 0\n0 1 2 3 4 5 6 7 6 5 4 3 2 1 0\n 0 1 2 3 4 5 6 5 4 3 2 1 0\n 0 1 2 3 4 5 4 3 2 1 0\n 0 1 2 3 4 3 2 1 0\n 0 1 2 3 2 1 0\n 0 1 2 1 0\n 0 1 0\n 0", " 0\n 0 1 0\n 0 1 2 1 0\n 0 1 2 3 2 1 0\n 0 1 2 3 4 3 2 1 0\n 0 1 2 3 4 5 4 3 2 1 0\n 0 1 2 3 4 5 6 5 4 3 2 1 0\n 0 1 2 3 4 5 6 7 6 5 4 3 2 1 0\n0 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1 0\n 0 1 2 3 4 5 6 7 6 5 4 3 2 1 0\n 0 1 2 3 4 5 6 5 4 3 2 1 0\n 0 1 2 3 4 5 4 3 2 1 0\n 0 1 2 3 4 3 2 1 0\n 0 1 2 3 2 1 0\n 0 1 2 1 0\n 0 1 0\n 0", " 0\n 0 1 0\n 0 1 2 1 0\n 0 1 2 3 2 1 0\n 0 1 2 3 4 3 2 1 0\n 0 1 2 3 4 5 4 3 2 1 0\n 0 1 2 3 4 5 6 5 4 3 2 1 0\n 0 1 2 3 4 5 6 7 6 5 4 3 2 1 0\n 0 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1 0\n0 1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1 0\n 0 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1 0\n 0 1 2 3 4 5 6 7 6 5 4 3 2 1 0\n 0 1 2 3 4 5 6 5 4 3 2 1 0\n 0 1 2 3 4 5 4 3 2 1 0\n 0 1 2 3 4 3 2 1 0\n 0 1 2 3 2 1 0\n 0 1 2..."]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 13 | codeforces |
|
54eabc2821352e7e3a39754857af9e14 | A Game With Numbers | Imagine that Alice is playing a card game with her friend Bob. They both have exactly $8$ cards and there is an integer on each card, ranging from $0$ to $4$. In each round, Alice or Bob in turns choose two cards from different players, let them be $a$ and $b$, where $a$ is the number on the player's card, and $b$ is the number on the opponent's card. It is necessary that $a \cdot b \ne 0$. Then they calculate $c = (a + b) \bmod 5$ and replace the number $a$ with $c$. The player who ends up with numbers on all $8$ cards being $0$, wins.
Now Alice wants to know who wins in some situations. She will give you her cards' numbers, Bob's cards' numbers and the person playing the first round. Your task is to determine who wins if both of them choose the best operation in their rounds.
The first line contains one positive integer $T$ ($1 \leq T \leq 100\,000$), denoting the number of situations you need to consider.
The following lines describe those $T$ situations. For each situation:
- The first line contains a non-negative integer $f$ ($0 \leq f \leq 1$), where $f = 0$ means that Alice plays first and $f = 1$ means Bob plays first. - The second line contains $8$ non-negative integers $a_1, a_2, \ldots, a_8$ ($0 \leq a_i \leq 4$), describing Alice's cards. - The third line contains $8$ non-negative integers $b_1, b_2, \ldots, b_8$ ($0 \leq b_i \leq 4$), describing Bob's cards.
We guarantee that if $f=0$, we have $\sum_{i=1}^{8}a_i \ne 0$. Also when $f=1$, $\sum_{i=1}^{8}b_i \ne 0$ holds.
Output $T$ lines. For each situation, determine who wins. Output
- "Alice" (without quotes) if Alice wins. - "Bob" (without quotes) if Bob wins. - "Deal" (without quotes) if it gets into a deal, i.e. no one wins.
Sample Input
4
1
0 0 0 0 0 0 0 0
1 2 3 4 1 2 3 4
1
0 0 0 1 0 0 0 0
0 0 0 0 4 0 0 0
0
1 0 0 0 0 0 0 0
0 0 0 4 0 0 2 0
1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
Sample Output
Alice
Bob
Alice
Deal
| {"inputs": ["4\n1\n0 0 0 0 0 0 0 0\n1 2 3 4 1 2 3 4\n1\n0 0 0 1 0 0 0 0\n0 0 0 0 4 0 0 0\n0\n1 0 0 0 0 0 0 0\n0 0 0 4 0 0 2 0\n1\n1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1", "1\n0\n0 2 2 0 1 2 1 2\n1 2 4 3 2 1 1 0"], "outputs": ["Alice\nBob\nAlice\nDeal", "Alice"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces |
|
54ef95eac742c7cf136cec111b8e7b83 | Borya's Diagnosis | It seems that Borya is seriously sick. He is going visit *n* doctors to find out the exact diagnosis. Each of the doctors needs the information about all previous visits, so Borya has to visit them in the prescribed order (i.e. Borya should first visit doctor 1, then doctor 2, then doctor 3 and so on). Borya will get the information about his health from the last doctor.
Doctors have a strange working schedule. The doctor *i* goes to work on the *s**i*-th day and works every *d**i* day. So, he works on days *s**i*,<=*s**i*<=+<=*d**i*,<=*s**i*<=+<=2*d**i*,<=....
The doctor's appointment takes quite a long time, so Borya can not see more than one doctor per day. What is the minimum time he needs to visit all doctors?
First line contains an integer *n* β number of doctors (1<=β€<=*n*<=β€<=1000).
Next *n* lines contain two numbers *s**i* and *d**i* (1<=β€<=*s**i*,<=*d**i*<=β€<=1000).
Output a single integer β the minimum day at which Borya can visit the last doctor.
Sample Input
3
2 2
1 2
2 2
2
10 1
6 5
Sample Output
4
11
| {"inputs": ["3\n2 2\n1 2\n2 2", "2\n10 1\n6 5", "3\n6 10\n3 3\n8 2", "4\n4 8\n10 10\n4 2\n8 2", "5\n7 1\n5 1\n6 1\n1 6\n6 8", "6\n1 3\n2 5\n4 7\n7 5\n6 8\n8 8", "10\n4 10\n8 7\n6 5\n2 1\n2 3\n8 8\n2 4\n2 2\n6 7\n7 9", "1\n1 1", "1\n1000 1000", "42\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2", "2\n5 5\n5 1", "2\n5 5\n5 5", "2\n1 1\n1 1", "2\n1 6\n7 1", "2\n4 3\n4 5", "2\n1 2\n1 3", "3\n2 3\n5 1\n2 1", "2\n2 1\n6 3", "3\n10 1\n4 4\n12 1", "2\n2 2\n10 2", "2\n1 1\n1000 2", "14\n1000 1\n1000 1000\n1000 1000\n1000 1000\n1000 1000\n1000 1000\n1000 1000\n1000 1000\n1000 1000\n1000 1000\n1000 1000\n1000 1000\n1000 1000\n1 1", "2\n2 4\n2 1", "3\n1 100\n100 3\n200 1", "7\n1000 1000\n1000 1000\n1000 1000\n1000 1000\n1000 1000\n1000 1000\n1 1", "2\n5 5\n15 5", "2\n2 2\n2 4", "2\n1 1\n10 1", "2\n10 1\n100 1", "15\n1000 1000\n1000 1000\n1000 1000\n1000 1000\n1000 1000\n1000 1000\n1000 1000\n1000 1000\n1000 1000\n1000 1000\n1000 1000\n1000 1000\n1000 1000\n1000 1000\n1 1", "3\n2 1\n1 3\n4 7", "2\n5 5\n100 5", "2\n1 10\n2 30", "4\n2 2\n2 2\n2 2\n2 2", "1\n10 10"], "outputs": ["4", "11", "10", "14", "14", "16", "34", "1", "1000", "83", "6", "10", "2", "7", "9", "4", "6", "6", "13", "10", "1000", "13001", "3", "200", "6001", "15", "6", "10", "100", "14001", "11", "100", "2", "8", "10"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 67 | codeforces |
|
54f2b0eb96295a35dd0ba51561306f0a | none | Natasha travels around Mars in the Mars rover. But suddenly it broke down, namelyΒ β the logical scheme inside it. The scheme is an undirected tree (connected acyclic graph) with a root in the vertex $1$, in which every leaf (excluding root) is an input, and all other vertices are logical elements, including the root, which is output. One bit is fed to each input. One bit is returned at the output.
There are four types of logical elements: [AND](https://en.wikipedia.org/wiki/Logical_conjunction) ($2$ inputs), [OR](https://en.wikipedia.org/wiki/Logical_disjunction) ($2$ inputs), [XOR](https://en.wikipedia.org/wiki/Exclusive_or) ($2$ inputs), [NOT](https://en.wikipedia.org/wiki/Negation) ($1$ input). Logical elements take values from their direct descendants (inputs) and return the result of the function they perform. Natasha knows the logical scheme of the Mars rover, as well as the fact that only one input is broken. In order to fix the Mars rover, she needs to change the value on this input.
For each input, determine what the output will be if Natasha changes this input.
The first line contains a single integer $n$ ($2 \le n \le 10^6$)Β β the number of vertices in the graph (both inputs and elements).
The $i$-th of the next $n$ lines contains a description of $i$-th vertex: the first word "AND", "OR", "XOR", "NOT" or "IN" (means the input of the scheme) is the vertex type. If this vertex is "IN", then the value of this input follows ($0$ or $1$), otherwise follow the indices of input vertices of this element: "AND", "OR", "XOR" have $2$ inputs, whereas "NOT" has $1$ input. The vertices are numbered from one.
It is guaranteed that input data contains a correct logical scheme with an output produced by the vertex $1$.
Print a string of characters '0' and '1' (without quotes)Β β answers to the problem for each input in the ascending order of their vertex indices.
Sample Input
10
AND 9 4
IN 1
IN 1
XOR 6 5
AND 3 7
IN 0
NOT 10
IN 1
IN 1
AND 2 8
Sample Output
10110 | {"inputs": ["10\nAND 9 4\nIN 1\nIN 1\nXOR 6 5\nAND 3 7\nIN 0\nNOT 10\nIN 1\nIN 1\nAND 2 8", "3\nAND 2 3\nIN 0\nIN 0", "3\nAND 2 3\nIN 1\nIN 0", "3\nAND 2 3\nIN 0\nIN 1", "3\nAND 2 3\nIN 1\nIN 1", "3\nOR 2 3\nIN 0\nIN 0", "3\nOR 2 3\nIN 1\nIN 0", "3\nOR 2 3\nIN 0\nIN 1", "3\nOR 2 3\nIN 1\nIN 1", "3\nXOR 2 3\nIN 0\nIN 0", "3\nXOR 2 3\nIN 1\nIN 0", "3\nXOR 2 3\nIN 0\nIN 1", "3\nXOR 2 3\nIN 1\nIN 1", "2\nNOT 2\nIN 0", "2\nNOT 2\nIN 1", "20\nOR 17 10\nIN 0\nIN 0\nNOT 6\nOR 18 14\nIN 1\nOR 16 3\nXOR 5 4\nIN 0\nXOR 11 9\nNOT 15\nAND 20 19\nIN 0\nIN 1\nIN 1\nNOT 8\nNOT 12\nIN 1\nAND 13 7\nNOT 2", "30\nXOR 4 11\nXOR 6 25\nNOT 29\nNOT 9\nNOT 17\nNOT 26\nNOT 30\nNOT 27\nNOT 14\nIN 1\nNOT 5\nNOT 15\nNOT 22\nIN 0\nNOT 24\nIN 1\nNOT 3\nNOT 19\nNOT 8\nNOT 16\nNOT 23\nNOT 28\nNOT 7\nNOT 2\nNOT 10\nNOT 13\nNOT 12\nNOT 20\nNOT 21\nNOT 18", "40\nOR 9 2\nAND 30 31\nIN 1\nIN 1\nIN 0\nOR 25 21\nIN 1\nXOR 20 10\nAND 24 34\nIN 0\nIN 0\nNOT 16\nAND 14 4\nIN 0\nAND 18 27\nIN 1\nAND 15 22\nOR 26 12\nIN 1\nAND 36 3\nXOR 11 38\nIN 1\nIN 1\nNOT 29\nIN 0\nXOR 32 13\nIN 1\nIN 0\nNOT 8\nIN 1\nXOR 37 39\nXOR 7 23\nIN 1\nXOR 33 5\nIN 0\nOR 40 28\nIN 1\nIN 0\nAND 35 17\nXOR 6 19", "50\nNOT 37\nOR 23 10\nIN 1\nAND 28 48\nIN 0\nIN 0\nIN 0\nAND 39 21\nNOT 6\nNOT 40\nAND 18 36\nIN 0\nIN 1\nOR 33 43\nNOT 27\nNOT 25\nNOT 35\nXOR 16 34\nNOT 22\nIN 1\nAND 4 13\nNOT 46\nIN 1\nNOT 3\nOR 5 49\nXOR 30 15\nOR 41 31\nIN 0\nIN 0\nOR 8 38\nIN 1\nAND 7 20\nNOT 11\nIN 1\nXOR 2 32\nXOR 29 9\nAND 50 44\nIN 1\nIN 0\nOR 42 47\nIN 0\nNOT 14\nIN 1\nNOT 19\nIN 1\nIN 0\nNOT 26\nOR 45 12\nIN 1\nOR 24 17", "60\nAND 20 4\nNOT 42\nAND 48 59\nOR 17 7\nIN 0\nAND 36 37\nIN 1\nIN 0\nIN 1\nNOT 47\nAND 52 49\nOR 44 35\nIN 0\nIN 1\nAND 33 56\nIN 0\nIN 0\nIN 0\nAND 31 41\nOR 15 3\nOR 43 46\nIN 1\nXOR 22 28\nIN 1\nIN 1\nIN 1\nAND 34 21\nIN 1\nIN 1\nIN 0\nXOR 51 23\nXOR 10 54\nOR 57 40\nIN 0\nNOT 18\nNOT 25\nIN 1\nAND 5 50\nIN 0\nAND 60 53\nAND 45 8\nIN 0\nIN 1\nNOT 27\nIN 0\nIN 1\nAND 19 2\nOR 29 32\nAND 58 24\nNOT 16\nXOR 55 11\nIN 0\nNOT 30\nAND 12 38\nAND 14 9\nIN 1\nIN 0\nOR 26 6\nIN 0\nAND 13 39", "9\nAND 2 3\nIN 1\nOR 4 5\nIN 0\nAND 6 7\nIN 1\nOR 8 9\nIN 0\nIN 0"], "outputs": ["10110", "00", "01", "10", "00", "11", "01", "10", "11", "11", "00", "00", "11", "0", "1", "11111111", "000", "1111111111111111111", "0110111111111111111", "000000000000000000000000011", "01011"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces |
|
54f654755a3f3b43fcc1e4463c5ec344 | K-Periodic Array | This task will exclusively concentrate only on the arrays where all elements equal 1 and/or 2.
Array *a* is *k*-period if its length is divisible by *k* and there is such array *b* of length *k*, that *a* is represented by array *b* written exactly times consecutively. In other words, array *a* is *k*-periodic, if it has period of length *k*.
For example, any array is *n*-periodic, where *n* is the array length. Array [2,<=1,<=2,<=1,<=2,<=1] is at the same time 2-periodic and 6-periodic and array [1,<=2,<=1,<=1,<=2,<=1,<=1,<=2,<=1] is at the same time 3-periodic and 9-periodic.
For the given array *a*, consisting only of numbers one and two, find the minimum number of elements to change to make the array *k*-periodic. If the array already is *k*-periodic, then the required value equals 0.
The first line of the input contains a pair of integers *n*, *k* (1<=β€<=*k*<=β€<=*n*<=β€<=100), where *n* is the length of the array and the value *n* is divisible by *k*. The second line contains the sequence of elements of the given array *a*1,<=*a*2,<=...,<=*a**n* (1<=β€<=*a**i*<=β€<=2), *a**i* is the *i*-th element of the array.
Print the minimum number of array elements we need to change to make the array *k*-periodic. If the array already is *k*-periodic, then print 0.
Sample Input
6 2
2 1 2 2 2 1
8 4
1 1 2 1 1 1 2 1
9 3
2 1 1 1 2 1 1 1 2
Sample Output
1
0
3
| {"inputs": ["6 2\n2 1 2 2 2 1", "8 4\n1 1 2 1 1 1 2 1", "9 3\n2 1 1 1 2 1 1 1 2", "1 1\n2", "2 1\n1 1", "2 2\n2 2", "100 1\n1 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 1 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2", "2 1\n1 2", "2 2\n2 1", "3 1\n2 1 2", "3 3\n1 2 1", "4 2\n2 1 2 2", "10 2\n2 2 2 1 1 2 2 2 2 1", "10 5\n2 2 1 2 1 1 2 1 1 1", "20 4\n2 2 1 2 2 2 1 2 2 2 1 2 2 2 1 2 2 2 1 2", "20 5\n2 2 1 1 1 2 1 1 1 1 2 2 1 1 2 2 2 1 1 2", "20 10\n1 2 2 2 2 1 1 1 2 1 1 2 2 2 2 1 2 2 2 1", "100 2\n2 2 1 2 1 2 1 2 1 2 1 2 1 2 2 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 2 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 1 1 2 1 2 1 1 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2", "100 4\n1 2 1 1 1 2 1 1 1 2 1 1 1 2 1 1 1 2 2 2 1 2 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 2 1 1 1 2 2 1 1 1 1 1 1 2 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 2 1 1 1 2 1 1 1 2 1 1 1 2 2 1 1 2 1 1 1 2 1 2 1 2 1 1 1 2 1 1 1 2 1 1", "100 5\n2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 1 2 1 2 1 2 2 2 2 2 2 1 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 1 2 2 2 2 2 1 2 1 2 2 2 2 1 2 2 2 1 1 2 1 2 2 2 2 2 2 2 1 2 2 2", "100 10\n2 1 1 1 1 2 2 2 1 1 2 1 1 2 1 2 1 2 1 1 2 1 1 1 1 2 1 2 1 1 2 1 1 1 1 2 2 2 1 1 2 1 1 1 1 2 1 2 1 1 2 1 1 1 1 2 1 2 2 1 2 1 1 1 1 2 1 2 1 1 2 1 2 1 1 2 1 2 1 1 2 1 1 1 1 2 1 2 1 1 2 1 1 1 2 2 1 2 1 1", "100 20\n2 2 2 1 1 2 1 2 1 2 1 1 2 2 2 2 2 1 2 1 2 2 2 2 1 2 1 2 1 1 1 1 2 2 2 2 1 2 1 1 2 2 2 2 1 2 1 2 1 2 1 1 2 1 2 2 2 1 2 2 2 2 2 2 2 2 1 2 1 1 1 1 2 2 2 2 2 1 1 2 2 1 2 2 1 2 1 2 1 2 1 1 2 2 1 2 2 1 1 1", "100 25\n2 2 1 2 2 2 2 2 1 2 2 1 2 1 1 2 1 2 1 2 2 2 1 2 2 2 1 1 2 1 2 1 2 1 2 2 1 2 1 1 2 2 2 1 2 2 1 2 2 2 2 1 1 2 1 2 2 1 1 2 2 2 2 2 1 2 1 2 2 2 2 2 2 2 1 2 1 1 2 2 2 2 2 1 2 2 1 1 2 1 2 2 2 1 2 2 2 2 2 2", "100 10\n2 2 2 2 2 1 2 1 2 1 2 2 2 2 2 1 2 1 2 1 2 2 2 2 2 1 2 1 2 1 2 2 2 2 2 1 2 1 2 1 2 2 2 2 2 1 2 1 2 1 2 2 2 2 2 1 2 1 2 1 2 2 2 2 2 1 2 1 2 1 2 2 2 2 2 1 2 1 2 1 2 2 2 2 2 1 2 1 2 1 2 2 2 2 2 1 2 1 2 1"], "outputs": ["1", "0", "3", "0", "0", "0", "8", "1", "0", "1", "0", "1", "3", "2", "0", "3", "2", "5", "8", "16", "6", "13", "15", "0"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 81 | codeforces |
|
5593c830d71188d6cb7298d1414d88e3 | Python Indentation | In Python, code blocks don't have explicit begin/end or curly braces to mark beginning and end of the block. Instead, code blocks are defined by indentation.
We will consider an extremely simplified subset of Python with only two types of statements.
Simple statements are written in a single line, one per line. An example of a simple statement is assignment.
For statements are compound statements: they contain one or several other statements. For statement consists of a header written in a separate line which starts with "for" prefix, and loop body. Loop body is a block of statements indented one level further than the header of the loop. Loop body can contain both types of statements. Loop body can't be empty.
You are given a sequence of statements without indentation. Find the number of ways in which the statements can be indented to form a valid Python program.
The first line contains a single integer *N* (1<=β€<=*N*<=β€<=5000)Β β the number of commands in the program. *N* lines of the program follow, each line describing a single command. Each command is either "f" (denoting "for statement") or "s" ("simple statement"). It is guaranteed that the last line is a simple statement.
Output one line containing an integer - the number of ways the given sequence of statements can be indented modulo 109<=+<=7.
Sample Input
4
s
f
f
s
4
f
s
f
s
Sample Output
1
2
| {"inputs": ["4\ns\nf\nf\ns", "4\nf\ns\nf\ns", "156\nf\ns\nf\ns\nf\ns\ns\ns\ns\nf\ns\ns\nf\nf\ns\nf\nf\nf\nf\ns\ns\ns\nf\ns\ns\nf\nf\nf\nf\nf\nf\ns\ns\ns\ns\nf\ns\nf\ns\nf\ns\nf\nf\nf\nf\ns\ns\nf\nf\ns\ns\ns\ns\nf\ns\nf\ns\nf\ns\nf\ns\ns\ns\nf\ns\ns\nf\ns\nf\nf\ns\ns\ns\nf\nf\nf\nf\ns\ns\nf\nf\nf\nf\nf\nf\nf\ns\nf\ns\ns\ns\nf\nf\ns\ns\ns\ns\ns\nf\nf\nf\nf\ns\nf\nf\ns\nf\ns\ns\nf\nf\nf\ns\ns\ns\nf\ns\ns\nf\ns\nf\nf\nf\ns\nf\nf\ns\ns\nf\ns\nf\nf\ns\ns\ns\ns\nf\ns\nf\nf\ns\ns\nf\nf\nf\ns\ns\nf\nf\nf\ns\nf\ns\nf\nf\ns", "4\nf\nf\ns\ns", "2\nf\ns", "1\ns", "3\nf\nf\ns", "2\ns\ns", "156\ns\nf\ns\ns\ns\ns\nf\ns\ns\ns\nf\nf\ns\nf\nf\ns\nf\nf\nf\ns\nf\nf\ns\nf\nf\ns\ns\nf\nf\ns\nf\nf\nf\nf\nf\ns\ns\nf\ns\nf\nf\nf\ns\nf\nf\nf\ns\ns\ns\nf\ns\ns\nf\nf\ns\ns\nf\ns\nf\nf\ns\nf\nf\nf\ns\ns\nf\nf\ns\nf\ns\ns\ns\ns\ns\ns\ns\nf\ns\nf\nf\nf\ns\ns\ns\ns\nf\nf\ns\nf\nf\ns\ns\nf\ns\nf\ns\ns\nf\nf\nf\nf\nf\ns\nf\ns\ns\nf\nf\ns\nf\nf\ns\ns\ns\nf\ns\ns\ns\ns\nf\nf\ns\nf\nf\nf\nf\ns\nf\ns\ns\nf\nf\ns\nf\ns\nf\nf\nf\nf\ns\ns\nf\nf\nf\nf\ns\nf\ns\nf\ns\ns\ns\nf\nf\ns", "66\ns\nf\ns\ns\nf\ns\ns\ns\ns\nf\ns\ns\nf\nf\ns\ns\nf\ns\ns\nf\ns\ns\nf\nf\ns\ns\nf\nf\ns\ns\nf\ns\ns\ns\ns\nf\nf\ns\ns\nf\nf\ns\ns\nf\ns\ns\nf\ns\ns\nf\ns\ns\nf\nf\ns\nf\ns\ns\nf\nf\ns\nf\ns\nf\nf\ns"], "outputs": ["1", "2", "666443222", "3", "1", "1", "1", "1", "479461584", "392847498"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 27 | codeforces |
|
55ae3df199bb9e610ef7dd2ba38b3fe1 | Shooting Gallery | One warm and sunny day king Copa decided to visit the shooting gallery, located at the Central Park, and try to win the main prize β big pink plush panda. The king is not good at shooting, so he invited you to help him.
The shooting gallery is an infinite vertical plane with Cartesian coordinate system on it. The targets are points on this plane. Each target is described by it's coordinates *x**i*, and *y**i*, by the time of it's appearance *t**i* and by the number *p**i*, which gives the probability that Copa hits this target if he aims at it.
A target appears and disappears instantly, so Copa can hit the target only if at the moment *t**i* his gun sight aimed at (*x**i*,<=*y**i*). Speed of movement of the gun sight on the plane is equal to 1. Copa knows all the information about the targets beforehand (remember, he is a king!). He wants to play in the optimal way, which maximizes the expected value of the amount of hit targets. He can aim at any target at the moment 0.
The first line contains integer *n* (1<=β€<=*n*<=β€<=1000) β amount of targets in the shooting gallery. Then *n* lines follow, each describing one target. Each description consists of four numbers *x**i*, *y**i*, *t**i*, *p**i* (where *x**i*, *y**i*, *t**i* β integers, <=-<=1000<=β€<=*x**i*,<=*y**i*<=β€<=1000,<=0<=β€<=*t**i*<=β€<=109, real number *p**i* is given with no more than 6 digits after the decimal point, 0<=β€<=*p**i*<=β€<=1). No two targets may be at the same point.
Output the maximum expected value of the amount of targets that was shot by the king. Your answer will be accepted if it differs from the correct answer by not more than 10<=-<=6.
Sample Input
1
0 0 0 0.5
2
0 0 0 0.6
5 0 5 0.7
Sample Output
0.5000000000
1.3000000000
| {"inputs": ["1\n0 0 0 0.5", "2\n0 0 0 0.6\n5 0 5 0.7", "1\n-5 2 3 0.886986", "4\n10 -7 14 0.926305\n-7 -8 12 0.121809\n-7 7 14 0.413446\n3 -8 6 0.859061", "5\n-2 -2 34 0.127276\n5 -5 4 0.459998\n10 3 15 0.293766\n1 -3 7 0.089869\n-4 -7 11 0.772515", "5\n2 5 1 0.955925\n9 -9 14 0.299977\n0 1 97 0.114582\n-4 -2 66 0.561033\n0 -10 75 0.135937", "10\n-4 7 39 0.921693\n3 -1 50 0.111185\n-2 -8 27 0.976475\n-9 -2 25 0.541029\n6 -4 21 0.526054\n-7 2 19 0.488637\n-6 -5 50 0.819011\n-7 3 39 0.987596\n-3 -8 16 0.685997\n4 10 1 0.246686"], "outputs": ["0.5000000000", "1.3000000000", "0.8869860000", "1.7853660000", "0.8997910000", "1.7674770000", "3.0829590000"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 8 | codeforces |
|
55bd32dabd659fa4145edf5cace46d7e | Maximal Area Quadrilateral | Iahub has drawn a set of *n* points in the cartesian plane which he calls "special points". A quadrilateral is a simple polygon without self-intersections with four sides (also called edges) and four vertices (also called corners). Please note that a quadrilateral doesn't have to be convex. A special quadrilateral is one which has all four vertices in the set of special points. Given the set of special points, please calculate the maximal area of a special quadrilateral.
The first line contains integer *n* (4<=β€<=*n*<=β€<=300). Each of the next *n* lines contains two integers: *x**i*, *y**i* (<=-<=1000<=β€<=*x**i*,<=*y**i*<=β€<=1000) β the cartesian coordinates of *i*th special point. It is guaranteed that no three points are on the same line. It is guaranteed that no two points coincide.
Output a single real number β the maximal area of a special quadrilateral. The answer will be considered correct if its absolute or relative error does't exceed 10<=-<=9.
Sample Input
5
0 0
0 4
4 0
4 4
2 3
Sample Output
16.000000 | {"inputs": ["5\n0 0\n0 4\n4 0\n4 4\n2 3", "10\n-6 -4\n-7 5\n-7 -7\n5 -7\n4 -9\n-6 7\n2 9\n-4 -6\n2 10\n-10 -4", "4\n-3 3\n0 3\n-2 -1\n2 2", "5\n-4 -3\n-3 -2\n3 3\n-1 2\n3 -3", "6\n-4 -3\n-1 3\n0 0\n2 2\n2 1\n-3 1", "7\n-2 -1\n4 3\n2 2\n-4 0\n-2 4\n0 0\n1 -3", "4\n-874 606\n-996 -207\n897 847\n775 191", "10\n156 -415\n879 198\n-250 -676\n-594 -433\n-207 368\n296 -641\n-387 -795\n143 -304\n-468 390\n-873 226", "50\n-768 -243\n-741 -984\n-370 213\n-808 571\n-726 442\n234 452\n-105 -990\n-876 -278\n987 473\n-968 -531\n-274 -842\n259 -655\n-59 -555\n976 -396\n878 -85\n551 213\n675 599\n-990 -507\n1 48\n-147 919\n-218 798\n-191 928\n916 263\n-975 169\n567 -967\n394 16\n-224 915\n280 -613\n804 -877\n988 -576\n-256 -708\n757 546\n777 99\n-579 -608\n-102 1\n-309 636\n-24 -718\n644 -84\n111 -822\n-722 544\n78 595\n-194 716\n-409 -845\n-291 441\n388 379\n-950 277\n-718 359\n881 198\n198 670\n828 -820", "4\n0 0\n0 5\n5 0\n1 1"], "outputs": ["16.000000", "166.000000", "11.000000", "29.500000", "15.000000", "32.500000", "1261820.500000", "1129219.500000", "2425414.000000", "10.000000"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces |
|
55d0b2a7f663cfde27c5fb8e3f1bdcd8 | Schedule | At the beginning of the new semester there is new schedule in the Berland State University. According to this schedule, *n* groups have lessons at the room 31. For each group the starting time of the lesson and the finishing time of the lesson are known. It has turned out that it is impossible to hold all lessons, because for some groups periods of their lessons intersect. If at some moment of time one groups finishes it's lesson, and the other group starts the lesson, their lessons don't intersect.
The dean wants to cancel the lesson in one group so that no two time periods of lessons of the remaining groups intersect. You are to find all ways to do that.
The first line contains integer *n* (1<=β€<=*n*<=β€<=5000) β amount of groups, which have lessons in the room 31. Then *n* lines follow, each of them contains two integers *l**i* *r**i* (1<=β€<=*l**i*<=<<=*r**i*<=β€<=106) β starting and finishing times of lesson of the *i*-th group. It is possible that initially no two lessons intersect (see sample 1).
Output integer *k* β amount of ways to cancel the lesson in exactly one group so that no two time periods of lessons of the remaining groups intersect. In the second line output *k* numbers β indexes of groups, where it is possible to cancel the lesson. Groups are numbered starting from 1 in the order that they were given in the input. Output the numbers in increasing order.
Sample Input
3
3 10
20 30
1 3
4
3 10
20 30
1 3
1 39
3
1 5
2 6
3 7
Sample Output
3
1 2 3 1
4 0
| {"inputs": ["3\n3 10\n20 30\n1 3", "4\n3 10\n20 30\n1 3\n1 39", "3\n1 5\n2 6\n3 7", "4\n1 5\n5 7\n6 9\n9 10", "11\n717170 795210\n866429 970764\n163324 322182\n677099 717170\n241684 393937\n50433 114594\n970764 997956\n393937 664883\n235698 241684\n795210 832346\n114594 232438", "16\n203671 381501\n58867 59732\n817520 962123\n125391 163027\n601766 617692\n381501 444610\n761937 817520\n16 10551\n21096 38291\n718073 761937\n583868 601766\n554859 731755\n678098 718073\n962123 992003\n163027 203671\n87917 96397"], "outputs": ["3\n1 2 3 ", "1\n4 ", "0", "2\n2 3 ", "1\n3 ", "1\n12 "]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 12 | codeforces |
|
55e0f5d579ec5fa6ede167fd6433cad2 | Gifts by the List | Sasha lives in a big happy family. At the Man's Day all the men of the family gather to celebrate it following their own traditions. There are *n* men in Sasha's family, so let's number them with integers from 1 to *n*.
Each man has at most one father but may have arbitrary number of sons.
Man number *A* is considered to be the ancestor of the man number *B* if at least one of the following conditions is satisfied:
- *A*<==<=*B*; - the man number *A* is the father of the man number *B*; - there is a man number *C*, such that the man number *A* is his ancestor and the man number *C* is the father of the man number *B*.
Of course, if the man number *A* is an ancestor of the man number *B* and *A*<=β <=*B*, then the man number *B* is not an ancestor of the man number *A*.
The tradition of the Sasha's family is to give gifts at the Man's Day. Because giving gifts in a normal way is boring, each year the following happens.
1. A list of candidates is prepared, containing some (possibly all) of the *n* men in some order. 1. Each of the *n* men decides to give a gift. 1. In order to choose a person to give a gift to, man *A* looks through the list and picks the first man *B* in the list, such that *B* is an ancestor of *A* and gives him a gift. Note that according to definition it may happen that a person gives a gift to himself. 1. If there is no ancestor of a person in the list, he becomes sad and leaves the celebration without giving a gift to anyone.
This year you have decided to help in organizing celebration and asked each of the *n* men, who do they want to give presents to (this person is chosen only among ancestors). Are you able to make a list of candidates, such that all the wishes will be satisfied if they give gifts according to the process described above?
In the first line of the input two integers *n* and *m* (0<=β€<=*m*<=<<=*n*<=β€<=100<=000) are givenΒ β the number of the men in the Sasha's family and the number of family relations in it respectively.
The next *m* lines describe family relations: the (*i*<=+<=1)*th* line consists of pair of integers *p**i* and *q**i* (1<=β€<=*p**i*,<=*q**i*<=β€<=*n*, *p**i*<=β <=*q**i*) meaning that the man numbered *p**i* is the father of the man numbered *q**i*. It is guaranteed that every pair of numbers appears at most once, that among every pair of two different men at least one of them is not an ancestor of another and that every man has at most one father.
The next line contains *n* integers *a*1,<=*a*2,<=...,<=*a**n* (1<=β€<=*a**i*<=β€<=*n*), *i**th* of which means that the man numbered *i* wants to give a gift to the man numbered *a**i*. It is guaranteed that for every 1<=β€<=*i*<=β€<=*n* the man numbered *a**i* is an ancestor of the man numbered *i*.
Print an integer *k* (1<=β€<=*k*<=β€<=*n*)Β β the number of the men in the list of candidates, in the first line.
Print then *k* pairwise different positive integers not exceeding *n* β the numbers of the men in the list in an order satisfying every of the men's wishes, one per line.
If there are more than one appropriate lists, print any of them. If there is no appropriate list print <=-<=1 in the only line.
Sample Input
3 2
1 2
2 3
1 2 1
4 2
1 2
3 4
1 2 3 3
Sample Output
-13
2
1
3
| {"inputs": ["3 2\n1 2\n2 3\n1 2 1", "4 2\n1 2\n3 4\n1 2 3 3", "1 0\n1", "2 1\n2 1\n2 2", "2 1\n2 1\n1 2", "4 3\n1 2\n2 3\n3 4\n1 1 3 2", "4 3\n4 3\n3 2\n2 1\n3 4 4 4", "4 3\n1 2\n2 3\n3 4\n1 1 1 2"], "outputs": ["-1", "3\n2\n1\n3", "1\n1", "1\n2", "2\n1\n2", "-1", "-1", "-1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces |
|
55e2de5ea4444a213d58a4e0107ee79d | none | Bob is about to take a hot bath.
There are two taps to fill the bath: a hot water tap and a cold water tap. The cold water's temperature is *t*1, and the hot water's temperature is *t*2. The cold water tap can transmit any integer number of water units per second from 0 to *x*1, inclusive. Similarly, the hot water tap can transmit from 0 to *x*2 water units per second.
If *y*1 water units per second flow through the first tap and *y*2 water units per second flow through the second tap, then the resulting bath water temperature will be:
Bob wants to open both taps so that the bath water temperature was not less than *t*0. However, the temperature should be as close as possible to this value. If there are several optimal variants, Bob chooses the one that lets fill the bath in the quickest way possible.
Determine how much each tap should be opened so that Bob was pleased with the result in the end.
You are given five integers *t*1, *t*2, *x*1, *x*2 and *t*0 (1<=β€<=*t*1<=β€<=*t*0<=β€<=*t*2<=β€<=106, 1<=β€<=*x*1,<=*x*2<=β€<=106).
Print two space-separated integers *y*1 and *y*2 (0<=β€<=*y*1<=β€<=*x*1, 0<=β€<=*y*2<=β€<=*x*2).
Sample Input
10 70 100 100 25
300 500 1000 1000 300
143 456 110 117 273
Sample Output
99 331000 076 54 | {"inputs": ["10 70 100 100 25", "300 500 1000 1000 300", "143 456 110 117 273", "10 20 5 5 13", "1 3 1999 3444 2", "100 110 2 2 109", "3746 3797 485 485 3747", "900000 1000000 50000 50000 960000", "1 3 100 100 2", "1 3 100 100 3", "1 1 100 100 1", "1 1 1 1 1", "10 14 1 1 12", "10 14 1 1 13", "10 14 1 1 14", "10 14 1 1 11", "10 14 1 1 10", "1 1000000 1000000 1000000 500000", "1 1000000 1000000 1000000 2", "1 1000000 1000000 1000000 999999", "3 9 9 2 5", "7 9 481 961 9", "5 10 6361 6643 9", "3 10 202534 204124 7", "4 7 990105 993245 7", "167 6430 3 2 4879", "59039 78548 8 5 68239", "99065 826220 9 3 659285", "973058 995844 1 10 973658", "983534 987908 2 7 984750", "127873 889327 5550 623544 491743", "146692 953585 99505 406219 259334", "61097 812001 384947 188893 662044", "581106 975502 703094 487920 637713", "663155 979777 797049 494787 951112", "129630 805489 631548 761110 577559", "499637 716156 949694 543785 663905", "522321 902347 10945 842811 630561", "285510 831681 329092 849678 821409", "176902 815637 847541 412251 587604", "690136 947897 137581 128882 932136", "122316 918901 393457 621754 907250", "345903 808776 240052 245730 365687", "483180 855922 224311 233776 855647", "353408 572330 154358 165573 557017", "632076 716031 914 915 662639", "668704 747356 945 949 696258", "463050 509065 994 994 489428", "77909 251377 937 952 115397", "13612 793764 96 76 398584", "1 5 3 5 5", "99 99 99 99 99", "100 100 100 100 100", "1000000 1000000 1000000 1000000 1000000", "1000000 1000000 999999 999998 1000000", "5 5 5 5 5", "10 10 100 100 10", "1000 1000 1000 1000 1000", "10 10 5 5 10", "1 2 100 100 2", "100 100 1000 1000 100", "1000 1000000 1000000 1000000 1000000", "50 100 100 100 100", "10 10 20 20 10", "1 100000 1000 1 2", "1000 1000000 100000 1000000 1000000", "1 10 10 10 10", "1000000 1000000 50 50 1000000", "300 300 1000 1000 300", "5 5 123 1234 5"], "outputs": ["99 33", "1000 0", "76 54", "4 2", "1999 1999", "0 2", "450 9", "33332 49998", "100 100", "0 100", "100 100", "1 1", "1 1", "0 1", "0 1", "1 1", "1 0", "1000000 999998", "999998 1", "1 999998", "4 2", "0 961", "1660 6640", "153093 204124", "0 993245", "0 2", "5 5", "0 3", "1 1", "2 1", "4953 4533", "92031 14932", "41007 164334", "675578 113214", "28665 287957", "227930 447929", "156753 492804", "9052 3605", "13696 714532", "228033 410702", "6612 101523", "9025 608019", "231914 10355", "141 190974", "11080 147325", "856 490", "790 426", "737 990", "798 220", "78 76", "0 5", "99 99", "100 100", "1000000 1000000", "999999 999998", "5 5", "100 100", "1000 1000", "5 5", "0 100", "1000 1000", "0 1000000", "0 100", "20 20", "1000 1", "0 1000000", "0 10", "50 50", "1000 1000", "123 1234"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 4 | codeforces |
|
55e557b14d1dcc88b6b22982f8316a5d | Verse Pattern | You are given a text consisting of *n* lines. Each line contains some space-separated words, consisting of lowercase English letters.
We define a syllable as a string that contains exactly one vowel and any arbitrary number (possibly none) of consonants. In English alphabet following letters are considered to be vowels: 'a', 'e', 'i', 'o', 'u' and 'y'.
Each word of the text that contains at least one vowel can be divided into syllables. Each character should be a part of exactly one syllable. For example, the word "mamma" can be divided into syllables as "ma" and "mma", "mam" and "ma", and "mamm" and "a". Words that consist of only consonants should be ignored.
The verse patterns for the given text is a sequence of *n* integers *p*1,<=*p*2,<=...,<=*p**n*. Text matches the given verse pattern if for each *i* from 1 to *n* one can divide words of the *i*-th line in syllables in such a way that the total number of syllables is equal to *p**i*.
You are given the text and the verse pattern. Check, if the given text matches the given verse pattern.
The first line of the input contains a single integer *n* (1<=β€<=*n*<=β€<=100)Β β the number of lines in the text.
The second line contains integers *p*1,<=...,<=*p**n* (0<=β€<=*p**i*<=β€<=100)Β β the verse pattern.
Next *n* lines contain the text itself. Text consists of lowercase English letters and spaces. It's guaranteed that all lines are non-empty, each line starts and ends with a letter and words are separated by exactly one space. The length of each line doesn't exceed 100 characters.
If the given text matches the given verse pattern, then print "YES" (without quotes) in the only line of the output. Otherwise, print "NO" (without quotes).
Sample Input
3
2 2 3
intel
code
ch allenge
4
1 2 3 1
a
bcdefghi
jklmnopqrstu
vwxyz
4
13 11 15 15
to be or not to be that is the question
whether tis nobler in the mind to suffer
the slings and arrows of outrageous fortune
or to take arms against a sea of troubles
Sample Output
YES
NO
YES
| {"inputs": ["3\n2 2 3\nintel\ncode\nch allenge", "4\n1 2 3 1\na\nbcdefghi\njklmnopqrstu\nvwxyz", "4\n13 11 15 15\nto be or not to be that is the question\nwhether tis nobler in the mind to suffer\nthe slings and arrows of outrageous fortune\nor to take arms against a sea of troubles", "5\n2 2 1 1 1\nfdbie\naaj\ni\ni n\nshi", "5\n2 11 10 7 9\nhy of\nyur pjyacbatdoylojayu\nemd ibweioiimyxya\nyocpyivudobua\nuiraueect impxqhzpty e", "5\n6 9 7 3 10\nabtbdaa\nom auhz ub iaravozegs\ncieulibsdhj ufki\nadu pnpurt\nh naony i jaysjsjxpwuuc", "2\n26 35\ngouojxaoobw iu bkaadyo degnjkubeabt kbap thwki dyebailrhnoh ooa\npiaeaebaocptyswuc wezesazipu osebhaonouygasjrciyiqaejtqsioubiuakg umynbsvw xpfqdwxo", "5\n1 0 0 1 1\ngqex\nw\nh\nzsvu\nqcqd", "5\n0 0 0 0 0\njtv\nl\nqg\ntp\nfgd", "10\n0 0 0 0 0 0 0 0 0 0\nj t fr\nn\nnhcgx\np\nmb hmhtz\ndbjc\ncwdxj\nn j whkbt\nzk m cwh\nqr n", "5\n4 5 1 0 0\noa\nqfohq\ni l\naik\nx", "10\n2 9 0 3 2 4 1 2 4 2\nxtwl oy\nafgeju fi\nr hy\nddsowagw\nxoredo f\nwufnxy k uh\nod\nlejrinw\nsueecohfjl\nedufg", "10\n1 1 0 0 0 4 0 4 0 0\na bn\nhnwss f\nd s bn\nbdzxzgsxq\nghh v\neimblv i er\nca kn k\nzm ffc zcb\nn\nz hkhvfkwhg", "5\n0 10 6 6 0\nfgthrxst\nsohnweymewnnmbobj\nj\nfwwt acdtfvkpv khbxokn\nhndovkkgfhnhqod", "5\n3 2 2 4 2\ni yu\niu\noa\naiio\nuo", "5\n11 12 11 4 6\nuuuayoiaoiy\nuaiee iai eieu\nooayaayeuee\noii o\noea uuo", "3\n2 3 2\nintel\ncode\nch allenge", "2\n1 2\ncode\na", "2\n1 1\nbababa\nbababa", "1\n1\naa", "1\n1\naaa", "2\n2 3\naee\nae"], "outputs": ["YES", "NO", "YES", "YES", "NO", "NO", "NO", "NO", "YES", "YES", "NO", "NO", "NO", "NO", "YES", "YES", "NO", "NO", "NO", "NO", "NO", "NO"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 170 | codeforces |
|
5614f76a9a106b37d45a3d86e6f37cd2 | Pixels | Flatland is inhabited by pixels of three colors: red, green and blue. We know that if two pixels of different colors meet in a violent fight, only one of them survives the fight (that is, the total number of pixels decreases by one). Besides, if pixels of colors *x* and *y* (*x*<=β <=*y*) meet in a violent fight, then the pixel that survives the fight immediately changes its color to *z* (*z*<=β <=*x*;Β *z*<=β <=*y*). Pixels of the same color are friends, so they don't fight.
The King of Flatland knows that his land will be peaceful and prosperous when the pixels are of the same color. For each of the three colors you know the number of pixels of this color that inhabit Flatland. Help the king and determine whether fights can bring peace and prosperity to the country and if it is possible, find the minimum number of fights needed to make the land peaceful and prosperous.
The first line contains three space-separated integers *a*, *b* and *c* (0<=β€<=*a*,<=*b*,<=*c*<=β€<=231;Β *a*<=+<=*b*<=+<=*c*<=><=0) β the number of red, green and blue pixels, correspondingly.
Print a single number β the minimum number of pixel fights before the country becomes peaceful and prosperous. If making the country peaceful and prosperous is impossible, print -1.
Sample Input
1 1 1
3 1 0
Sample Output
1
3
| {"inputs": ["1 1 1", "3 1 0", "1 4 4", "5 10 6", "6 8 10", "1 10 2", "10 6 8", "18 67 5", "67 81 1", "51 10 91", "48 6 7", "8 97 83", "2 7 95", "772486757 1747374885 377299255", "1358352906 27037371 1947040615", "1944219055 454183506 1369298327", "382601556 881329640 791556039", "246543403 71853598 1504509195", "50606342 2 1134945035", "9 530792195 6", "1016450951 2 9", "3 10 1007169359", "0 1 0", "1 0 0", "0 0 1", "3 2 0", "0 3 2", "3 0 2", "10 10 0", "0 0 10", "2 2 0", "0 2 10", "5 0 5", "5 9 0", "2147483648 2147483648 2147483648", "2147483648 2147483647 2147483648", "2147483648 0 0", "2147483648 2147483648 0", "2147483648 0 2147483647", "2147483630 2147483642 2147483610", "1 4 3", "1 2 3", "1 0 1", "92134834 23742837 92374737", "92134834 23742837 92374738", "92134834 23742837 92374739", "9214834 2742837 9234739", "914835 2742837 9234739", "1 2 2147483648", "0 0 58"], "outputs": ["1", "3", "4", "10", "8", "10", "8", "67", "67", "91", "48", "97", "95", "772486757", "1947040615", "1944219055", "881329640", "1504509195", "50606342", "530792195", "1016450951", "1007169359", "0", "0", "0", "2", "2", "2", "10", "0", "2", "2", "5", "9", "2147483648", "2147483648", "0", "2147483648", "2147483648", "2147483630", "3", "3", "1", "92374737", "92374738", "92374739", "9234739", "2742837", "2147483648", "0"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 4 | codeforces |
|
561ea8f650301bad39b3ab5015b8b0dd | Space Voyage | The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit *n* planets. For planet *i* *a**i* is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and *b**i* is the number of citizens on the planet.
The Smart Beaver is going to bring some presents from ABBYY to the planets he will be visiting. The presents are packed in suitcases, *x* presents in each. The Beaver will take to the ship exactly *a*1<=+<=...<=+<=*a**n* suitcases.
As the Beaver lands on the *i*-th planet, he takes *a**i* suitcases and goes out. On the first day on the planet the Beaver takes a walk and gets to know the citizens. On the second and all subsequent days the Beaver gives presents to the citizens β each of the *b**i* citizens gets one present per day. The Beaver leaves the planet in the evening of the day when the number of presents left is strictly less than the number of citizens (i.e. as soon as he won't be able to give away the proper number of presents the next day). He leaves the remaining presents at the hotel.
The Beaver is going to spend exactly *c* days traveling. The time spent on flights between the planets is considered to be zero. In how many ways can one choose the positive integer *x* so that the planned voyage will take exactly *c* days?
The first input line contains space-separated integers *n* and *c* β the number of planets that the Beaver is going to visit and the number of days he is going to spend traveling, correspondingly.
The next *n* lines contain pairs of space-separated integers *a**i*,<=*b**i* (1<=β€<=*i*<=β€<=*n*) β the number of suitcases he can bring to the *i*-th planet and the number of citizens of the *i*-th planet, correspondingly.
The input limitations for getting 30 points are:
- 1<=β€<=*n*<=β€<=100 - 1<=β€<=*a**i*<=β€<=100 - 1<=β€<=*b**i*<=β€<=100 - 1<=β€<=*c*<=β€<=100
The input limitations for getting 100 points are:
- 1<=β€<=*n*<=β€<=104 - 0<=β€<=*a**i*<=β€<=109 - 1<=β€<=*b**i*<=β€<=109 - 1<=β€<=*c*<=β€<=109
Due to possible overflow, it is recommended to use the 64-bit arithmetic. In some solutions even the 64-bit arithmetic can overflow. So be careful in calculations!
Print a single number *k* β the number of ways to choose *x* so as to travel for exactly *c* days. If there are infinitely many possible values of *x*, print -1.
Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use cin, cout streams or the %I64d specifier.
Sample Input
2 5
1 5
2 4
Sample Output
1
| {"inputs": ["2 5\n1 5\n2 4", "1 97\n1 91", "2 79\n1 91\n1 77", "3 100\n8 46\n8 56\n77 98", "71 100\n1 92\n1 94\n1 97\n1 95\n1 100\n1 100\n1 98\n1 99\n1 98\n1 96\n1 97\n1 93\n1 97\n1 92\n1 91\n1 96\n1 97\n1 96\n1 92\n1 99\n1 92\n1 95\n1 93\n1 99\n1 99\n1 99\n1 97\n1 99\n1 95\n1 95\n1 95\n1 96\n1 95\n1 97\n1 93\n1 93\n1 93\n1 92\n1 94\n1 96\n1 100\n1 98\n1 96\n1 97\n1 96\n1 93\n1 94\n1 95\n1 100\n1 93\n1 93\n1 99\n1 100\n1 97\n1 95\n1 98\n1 91\n1 100\n1 98\n1 99\n1 100\n1 100\n1 94\n1 97\n1 99\n1 98\n1 95\n1 92\n1 98\n1 99\n1 98", "7 77\n2 95\n2 91\n3 95\n2 94\n3 96\n2 97\n2 91", "7 45\n1 1\n1 2\n1 4\n1 8\n1 16\n1 32\n1 64", "7 77\n2 95\n1 97\n1 100\n1 99\n1 99\n1 100\n4 100", "1 1\n3 89", "1 100\n1 100", "5 100\n1 95\n2 96\n3 97\n4 98\n5 99", "8 97\n23 45\n91 20\n100 18\n11 82\n33 58\n11 99\n3 9\n75 55", "23 100\n1 51\n3 35\n2 92\n1 8\n1 2\n1 50\n1 94\n1 64\n3 82\n3 91\n2 68\n1 100\n3 69\n2 83\n3 6\n1 38\n1 6\n1 35\n2 87\n2 29\n3 32\n3 54\n2 62", "55 100\n1 87\n2 84\n1 83\n3 88\n3 94\n1 82\n4 86\n4 96\n2 93\n1 98\n2 98\n4 93\n1 87\n1 81\n4 85\n4 85\n3 85\n4 88\n1 87\n4 96\n4 89\n2 86\n2 95\n2 99\n1 99\n2 84\n1 96\n1 99\n3 82\n4 89\n3 94\n3 98\n1 81\n3 90\n1 80\n1 92\n4 85\n4 90\n1 91\n2 92\n3 84\n4 94\n1 85\n2 85\n1 97\n2 87\n3 84\n2 98\n1 90\n1 97\n3 88\n1 97\n1 91\n1 85\n2 82", "15 100\n3 76\n2 98\n3 80\n2 97\n4 99\n2 81\n2 100\n4 77\n2 96\n2 78\n2 87\n2 80\n2 100\n3 95\n3 84", "2 2\n1 2\n1 3"], "outputs": ["1", "91", "42", "1", "1", "9", "1", "10", "29", "100", "3", "0", "2", "1", "9", "1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces |
|
56451bdd43f18cd529603f3281b1328a | Vanya and Brackets | Vanya is doing his maths homework. He has an expression of form , where *x*1,<=*x*2,<=...,<=*x**n* are digits from 1 to 9, and sign represents either a plus '+' or the multiplication sign '*'. Vanya needs to add one pair of brackets in this expression so that to maximize the value of the resulting expression.
The first line contains expression *s* (1<=β€<=|*s*|<=β€<=5001, |*s*| is odd), its odd positions only contain digits from 1 to 9, and even positions only contain signs <=+<= and <=*<=.
The number of signs <=*<= doesn't exceed 15.
In the first line print the maximum possible value of an expression.
Sample Input
3+5*7+8*4
2+3*5
3*4*5
Sample Output
303
25
60
| {"inputs": ["3+5*7+8*4", "2+3*5", "3*4*5", "5*5*5*5*5*5*5*5*5*5*5*5*5*5*5*5", "2*2+2*2", "1+1+1+1+1+1+1", "1+5*6+7*8", "9*8+7*6+5*4+3*2+1", "3*3*9+4+6+8*4+5+1*4*6", "4*9+4+5+8*4+6+9+8+2+5+2+5*7+6+8", "9+9+9*9*9*9+9+9", "9+9+9+9+9*9*9*9", "1*1*1*1*1*1*1*1+1*1*1*1*1*1*1*1", "4+2*7+8+9*6+6*9+8+7*2+4", "5", "4+6*7+4", "2+7+3+5+4+2+3+9+9+6+9+2+3+6+5*3+4+5+6+5+8", "3+2+2+3+7+1+9+1+6+8+3+2+2+6+7+2+8+8+1+4+9", "3+9+3+1+6+4+7+9+5+8+2+6+1+4+4+5+1+7+5+4+6+4+3+1*9+7+7+4+5+2+3+2+6+5+5+8+7+8+2+3*3+8+3+4+9+8*5+9+2+8+2+8+6+6+9+6+4+2+5+3+1+2+6+6+2+4+6+4+2+7+2+7+6+9+9+3+6+7+8+3+3+2+3+7+9+7+8+5+5+5*1+3+2+5+8+5*6+5+4*6+2+5+5+4+9+8+3+5+1+3+1+6+2+2+1+3+2+3+3+3+2+8+3+2+8+8+5+2+6+6+3+1+1+5+5*1+5+7+5+8+4+1*7+5+9+5+8+1*8+5+9+3+1+8+6+7+8+3+5+1+5+6+9*9+6+1+9+8+9+1+5+9+9+6+3+8+8+6*9*3+9+7+7+4+3+8+8+6+7+1+8+6+3+1+7+7+1+1+3+9+8+5+5+6+8+2+4+1+5+7+2+3+7+1+5+1+6+1+7+3*5+5+9+2+1+3+9+4+8+6+5+5+2+3+7+9+5+6+8+3*3+2+4+4+6+3+2+4+1+4+8", "1*5*1+8*2*6*5*3*9+3+8+2+9*5+7+2+9+5+1*3+2*2*3*4*2*3", "4+4+6+2+5+9+9+5+5+9+4+1*5+3+6+9+6+2+4+3+2+8+9*6+5+4+3+8+7+3+2*3+1+6+8+3+8+1+8+2+1+1+1+6+9+6+4+6+7+8+3+1+5+4+8+8+6+5+8+7+7+1+7+6+3+3+9+6+3+5+4+4+1+4+1+8+6+2+9+8+7+2+3+1+4+3+9+9+2*1+3+8+2+4+1+8+9+3*7+3+7+5+3+7+5+5+3+2+9+8+4+7+5+3+7+7+3+8+9+4+9+6*6+3+8+8*7+7+9+1+3+5+1+1+1+9+8+2+1+1+5+5+5+1+6+7+3+6+1+4+1+7+1+7+1+1+9+9*4+1+3+9+3+5+5+5+5+2+9+6+7+3+5+9+3+5+3+9+3+9+9+2+7+2+1*4+6*2+5+7+6+1+1+2+8+9+5+8+3+9+9+1+1+4+9+7+5+8*9+5+2+6+5+6*2+4+2+5+2+3+9+6+9+5+5+5*6+8+2+3+1+2+8+3+1+6+5+9+7+4+2+8+9+1+5+8+5+3+2+7+1", "6*9+9*5*5+1*2*9*9*1+4*8+8+9+5+6*5*6+4+2+2+1+5*5*7*8", "5+3+5+9+3+9+1+3+1*7+7+1+9+3+7+7+6+6+3+7+4+3+6+4+5+1+2*3+6*5+5+6+2+8+3+3+9+9+1+1+2+8+4+8+9+3*7+3+2*8+9+8+1*9+9+7+4+8+6+7+3+5+6+4+4+9+2+2+8+6+7+1+5+4+4+6+6+6+9+8+7+2+3+5+4+6+1+8+8+9+1+9+6+3+8+5*7+3+1+6+7+9+1+6+2+2+8+8+9+3+7+7+2+5+8+6+7+9+7+2+4+9+8+3+7+4+5+7+6+5*6+4+6+4+6+2+2*6+2+5+5+1+8+7+7+6+6+8+2+8+8+6+7+1+1+1+2+5+1+1+8+9+9+6+5+8+7+5+8+4+8+8+1+4+6+7+3+2*1+1+3+5+3+3+3+9+8+7*2+4+7+5+8+3+3+9+3+7+2+1+1+7+6+2+5+5+2+1+8+8+2+9+9+2+4+6+6+4+8+9+3+7+1+3*9+8+7+4+9+4+6+2+9+8+8+5+8+8+2+5+6+6+4+7+9+4+7+2+3+1+7", "2+7+8*8*7+1+3+6*5*3*7*3*2+8+5*1+5*5+9*6+6*5+1*3+8+5", "1+2+4+8+6+5+3+8+2+9+9+5+8+7+7+7+6+1+7+2+8+3+2+5+1+6+1+3+8+2+5+4+3+5+7+8+5+7+7+3+8+1+7+1+1+1+5+9+5+9+1+6+7+6+8+9+2+7+9+2+9+9+7+3+2+8+4+4+5+9+6+2+6+8+1+3+5+3+9+4+7+4+3+9+8+2+6+3+5+1*3+1+6+8+5+3+9+2+9+9+3+4+8*6+3+9+7+1+1+4+6+4+5*6*1+1*9+6+5+4+3+7+3+8+6+2+3+7+4+1+5+8+6+1+6+9+1+2+7+2+2+1+7+9+4+3+1+4+3+3+1+1+2+1+8+9+8+6+9+9+6+3+7*1+1+3+7+9+3+6+5+2*9+8+1+9+8+7+5+3+6+9+3+5+3+5+5+7+5+2*9+9+2+4+2+3+7+1+7+1+3+8+6+4+5+9+3*2+8+6+8+2*6+8+1+4+2+7+7+6+8+3+2+5+8+1+8+5+6+1+6+4+6+8+6+6+4+3+5+2+1+5+9+9+4+4*9+7+8+4+4", "8+3*6*9*6+5*1*8*2+1+9+2+1*3*2+9+5+4+3+1+3*9*6*8+4+1", "1*1*1*1*1*1*1*1*1*1*1*1", "5+5*5+5*5+5*5+5", "8+7+3+6+3*8+8+9+8+4+2", "7+8*4+9+5+3+2+3+3+2+9", "1+1+7+1+7+7*7+5+3*9+3", "9+6+9+7+8*2*9+8+6+7+5", "8+8*3*8+1+9*4+9+2+8+4", "3+5+5+2+2+9*7+7+7*2*2", "6+8+5+9*2+7*9*3+2*2+8", "2*3+9+6*5*8+2+9*6+3+9", "7+7*6+7+6*1+8+8*1*2*4", "3+2*5+9+5*2+5*5*7+9*2", "3+4*5+6"], "outputs": ["303", "25", "60", "152587890625", "16", "7", "521", "1987", "12312", "2450", "19701", "32805", "2", "1380", "5", "74", "253", "94", "162353", "19699205", "82140", "11294919", "58437", "1473847", "178016", "9027949", "1", "885", "247", "327", "965", "728", "1759", "773", "3501", "3447", "1967", "2051", "47"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 27 | codeforces |
|
56463ac6ae649470f5a322be850540a6 | Codecraft III | Today Vasya visited a widely known site and learned that the continuation of his favourite game Codecraft II will appear after exactly *k* months. He looked at the calendar and learned that at the moment is the month number *s*. Vasya immediately got interested in what month Codecraft III will appear. Help him understand that.
All the twelve months in Vasya's calendar are named using their usual English names: January, February, March, April, May, June, July, August, September, October, November, December.
The first input line contains the name of the current month. It is guaranteed that it is a proper English name of one of twelve months. The first letter is uppercase, the rest are lowercase. The second line contains integer *k* (0<=β€<=*k*<=β€<=100) β the number of months left till the appearance of Codecraft III.
Print starting from an uppercase letter the name of the month in which the continuation of Codeforces II will appear. The printed name must be contained in the list January, February, March, April, May, June, July, August, September, October, November, December.
Sample Input
November
3
May
24
Sample Output
February
May
| {"inputs": ["November\n3", "May\n24", "April\n0", "September\n0", "August\n0", "June\n1", "July\n2", "September\n3", "July\n4", "August\n24", "May\n48", "November\n47", "December\n49", "June\n99", "March\n100", "December\n1", "January\n11", "December\n0", "January\n0", "July\n77", "February\n11", "February\n22", "July\n33", "May\n44", "June\n97"], "outputs": ["February", "May", "April", "September", "August", "July", "September", "December", "November", "August", "May", "October", "January", "September", "July", "January", "December", "December", "January", "December", "January", "December", "April", "January", "July"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 227 | codeforces |
|
565ba3eb6d9564437c2cdd828875b47c | Kefa and Watch | One day Kefa the parrot was walking down the street as he was on the way home from the restaurant when he saw something glittering by the road. As he came nearer he understood that it was a watch. He decided to take it to the pawnbroker to earn some money.
The pawnbroker said that each watch contains a serial number represented by a string of digits from 0 to 9, and the more quality checks this number passes, the higher is the value of the watch. The check is defined by three positive integers *l*, *r* and *d*. The watches pass a check if a substring of the serial number from *l* to *r* has period *d*. Sometimes the pawnbroker gets distracted and Kefa changes in some substring of the serial number all digits to *c* in order to increase profit from the watch.
The seller has a lot of things to do to begin with and with Kefa messing about, he gave you a task: to write a program that determines the value of the watch.
Let us remind you that number *x* is called a period of string *s* (1<=β€<=*x*<=β€<=|*s*|), if *s**i*<=<==<=<=*s**i*<=+<=*x* for all *i* from 1 to |*s*|<=<=-<=<=*x*.
The first line of the input contains three positive integers *n*, *m* and *k* (1<=β€<=*n*<=β€<=105, 1<=β€<=*m*<=+<=*k*<=β€<=105) β the length of the serial number, the number of change made by Kefa and the number of quality checks.
The second line contains a serial number consisting of *n* digits.
Then *m*<=+<=*k* lines follow, containing either checks or changes.
The changes are given as 1 *l* *r* *c* (1<=β€<=*l*<=β€<=*r*<=β€<=*n*, 0<=β€<=*c*<=β€<=9). That means that Kefa changed all the digits from the *l*-th to the *r*-th to be *c*.
The checks are given as 2 *l* *r* *d* (1<=β€<=*l*<=β€<=*r*<=β€<=*n*, 1<=β€<=*d*<=β€<=*r*<=-<=*l*<=+<=1).
For each check on a single line print "YES" if the watch passed it, otherwise print "NO".
Sample Input
3 1 2
112
2 2 3 1
1 1 3 8
2 1 2 1
6 2 3
334934
2 2 5 2
1 4 4 3
2 1 6 3
1 2 3 8
2 3 6 1
Sample Output
NO
YES
NO
YES
NO
| {"inputs": ["3 1 2\n112\n2 2 3 1\n1 1 3 8\n2 1 2 1", "6 2 3\n334934\n2 2 5 2\n1 4 4 3\n2 1 6 3\n1 2 3 8\n2 3 6 1", "1 0 1\n5\n2 1 1 1", "20 1 2\n34075930750342906718\n2 1 20 20\n1 1 20 6\n2 1 20 1", "10 1 4\n4545454545\n2 1 10 2\n2 2 4 2\n2 2 9 4\n1 2 9 6\n2 3 8 3", "15 1 5\n234072305423089\n2 1 15 1\n2 5 6 1\n2 8 11 2\n2 2 13 6\n1 5 12 4\n2 5 13 3", "9 7 5\n622851212\n2 1 9 3\n1 1 4 2\n1 6 9 7\n2 2 8 1\n1 2 3 9\n1 7 8 5\n2 1 9 9\n1 2 3 7\n1 7 7 2\n2 4 9 3\n1 2 2 5\n2 1 9 3", "18 0 6\n000000000000000000\n2 1 18 1\n2 1 18 18\n2 1 18 6\n2 1 18 3\n2 1 18 9\n2 1 18 2", "8 3 4\n90925761\n2 5 8 2\n1 2 4 5\n2 2 5 2\n1 6 7 5\n2 2 7 3\n1 3 4 9\n2 1 4 2", "10 10 7\n8888888888\n1 1 1 4\n1 2 2 5\n1 3 3 7\n1 4 4 7\n1 5 5 7\n1 6 6 7\n1 7 7 5\n1 8 8 6\n1 9 9 3\n1 10 10 7\n2 5 6 1\n2 8 8 1\n2 5 6 1\n2 7 9 3\n2 5 6 1\n2 4 4 1\n2 9 10 1", "20 5 5\n23655146364900318111\n1 5 19 9\n2 1 3 3\n2 4 5 1\n1 2 17 9\n2 4 5 1\n1 8 9 0\n2 4 5 1\n1 4 15 2\n2 1 3 3\n1 20 20 6", "20 10 15\n00137794455431057085\n2 1 20 1\n2 8 10 3\n2 1 20 1\n1 2 2 6\n1 11 13 0\n2 1 20 1\n2 1 2 1\n1 14 16 0\n1 5 9 0\n1 5 8 3\n1 10 11 7\n1 17 19 5\n2 1 20 1\n2 8 10 3\n2 1 20 1\n1 17 20 0\n1 7 10 7\n1 7 12 7\n2 1 20 1\n2 1 2 1\n2 8 10 3\n2 1 2 1\n2 8 10 3\n2 8 10 3\n2 8 10 3", "50 10 9\n78117811831783178317831700000000000000000000117773\n1 5 22 4\n1 11 24 0\n1 35 37 5\n2 45 46 1\n2 45 46 1\n1 41 41 3\n1 24 27 1\n2 9 24 4\n1 2 21 5\n2 45 46 1\n1 3 9 1\n1 11 23 5\n1 25 32 1\n2 47 49 1\n2 9 24 4\n1 34 45 0\n2 9 24 4\n2 1 8 4\n2 9 24 4", "52 5 30\n0073971598462524060181848948785829847120611111998011\n2 43 46 1\n1 25 28 2\n1 1 30 4\n2 1 52 1\n2 1 3 3\n2 1 3 3\n1 11 15 2\n2 1 52 1\n2 43 46 1\n1 3 7 9\n2 1 3 3\n1 26 49 3\n2 1 3 3\n2 1 52 1\n2 43 46 1\n2 1 3 3\n2 1 52 1\n2 1 52 1\n2 1 3 3\n2 1 52 1\n2 1 3 3\n2 1 3 3\n2 1 52 1\n2 1 3 3\n2 1 52 1\n2 43 46 1\n2 1 52 1\n2 43 46 1\n2 1 3 3\n2 43 46 1\n2 43 46 1\n2 43 46 1\n2 1 3 3\n2 1 52 1\n2 43 46 1", "314 0 1\n12121112111122221121111111212111122212111111112211111111111211121121212112222211222222112222121112121112211211111211111221211112111122212121112221111112111111121122122111111211121112111111121112121222222111211212221212111221112121111112111111112111121121121222112211212212121111112112122111112121212111222221111111\n2 1 314 157", "153 0 16\n000000000961748941961748947961748951961748969961748987961748993961749023961749037961749043961749067961749079961749091961749097961749101961749121961749157\n2 1 18 9\n2 1 27 18\n2 1 36 27\n2 1 45 36\n2 1 54 45\n2 1 63 54\n2 1 72 63\n2 1 81 72\n2 1 90 81\n2 1 99 90\n2 1 108 99\n2 1 117 108\n2 1 126 117\n2 1 135 126\n2 1 144 135\n2 1 153 144", "20 1 1\n52018731676138902386\n2 1 20 10\n1 1 20 8"], "outputs": ["NO\nYES", "NO\nYES\nNO", "YES", "YES\nYES", "YES\nYES\nYES\nYES", "NO\nNO\nNO\nNO\nNO", "NO\nNO\nYES\nYES\nYES", "YES\nYES\nYES\nYES\nYES\nYES", "NO\nYES\nYES\nNO", "YES\nYES\nYES\nYES\nYES\nYES\nNO", "YES\nNO\nYES\nYES\nYES", "NO\nYES\nNO\nNO\nNO\nNO\nYES\nNO\nNO\nNO\nYES\nNO\nYES\nYES\nYES", "YES\nYES\nNO\nYES\nYES\nNO\nNO\nNO\nNO", "YES\nNO\nYES\nYES\nNO\nYES\nYES\nYES\nNO\nYES\nYES\nNO\nNO\nYES\nNO\nYES\nYES\nNO\nYES\nNO\nYES\nNO\nYES\nYES\nYES\nYES\nYES\nYES\nNO\nYES", "NO", "NO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO", "NO"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces |
|
56792a031cc15f8d2f78b3cbe37979f4 | Funky Numbers | As you very well know, this year's funkiest numbers are so called triangular numbers (that is, integers that are representable as , where *k* is some positive integer), and the coolest numbers are those that are representable as a sum of two triangular numbers.
A well-known hipster Andrew adores everything funky and cool but unfortunately, he isn't good at maths. Given number *n*, help him define whether this number can be represented by a sum of two triangular numbers (not necessarily different)!
The first input line contains an integer *n* (1<=β€<=*n*<=β€<=109).
Print "YES" (without the quotes), if *n* can be represented as a sum of two triangular numbers, otherwise print "NO" (without the quotes).
Sample Input
256
512
Sample Output
YES
NO
| {"inputs": ["256", "512", "80", "828", "6035", "39210", "79712", "190492", "5722367", "816761542", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "12", "13", "14", "15", "16", "17", "18", "19", "20", "41", "11", "69", "82", "85", "736", "895", "934", "6213", "7405", "9919", "40942", "41992", "68535", "405718", "1046146", "3761248", "6195181", "35354345", "81282830", "187719774", "296798673", "938938476", "1000000000", "999887464", "999111944", "999966520", "999912080", "999992017", "999990474", "999999190", "999999125", "999999940", "999999995", "1000000000", "1", "999999999", "83495494", "968022000", "399980000", "4", "999999998"], "outputs": ["YES", "NO", "NO", "YES", "NO", "YES", "NO", "YES", "NO", "YES", "NO", "YES", "NO", "YES", "NO", "YES", "YES", "NO", "YES", "NO", "YES", "YES", "NO", "NO", "YES", "NO", "YES", "NO", "YES", "NO", "YES", "YES", "NO", "NO", "NO", "YES", "YES", "YES", "NO", "NO", "YES", "NO", "NO", "NO", "YES", "YES", "YES", "NO", "NO", "NO", "NO", "NO", "NO", "YES", "NO", "YES", "NO", "YES", "NO", "YES", "NO", "YES", "NO", "NO", "NO", "YES", "NO", "YES", "YES", "YES", "NO"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 116 | codeforces |
|
5691be4e6291720f4fc740dc091f5666 | Working out | Summer is coming! It's time for Iahub and Iahubina to work out, as they both want to look hot at the beach. The gym where they go is a matrix *a* with *n* lines and *m* columns. Let number *a*[*i*][*j*] represents the calories burned by performing workout at the cell of gym in the *i*-th line and the *j*-th column.
Iahub starts with workout located at line 1 and column 1. He needs to finish with workout *a*[*n*][*m*]. After finishing workout *a*[*i*][*j*], he can go to workout *a*[*i*<=+<=1][*j*] or *a*[*i*][*j*<=+<=1]. Similarly, Iahubina starts with workout *a*[*n*][1] and she needs to finish with workout *a*[1][*m*]. After finishing workout from cell *a*[*i*][*j*], she goes to either *a*[*i*][*j*<=+<=1] or *a*[*i*<=-<=1][*j*].
There is one additional condition for their training. They have to meet in exactly one cell of gym. At that cell, none of them will work out. They will talk about fast exponentiation (pretty odd small talk) and then both of them will move to the next workout.
If a workout was done by either Iahub or Iahubina, it counts as total gain. Please plan a workout for Iahub and Iahubina such as total gain to be as big as possible. Note, that Iahub and Iahubina can perform workouts with different speed, so the number of cells that they use to reach meet cell may differs.
The first line of the input contains two integers *n* and *m* (3<=β€<=*n*,<=*m*<=β€<=1000). Each of the next *n* lines contains *m* integers: *j*-th number from *i*-th line denotes element *a*[*i*][*j*] (0<=β€<=*a*[*i*][*j*]<=β€<=105).
The output contains a single number β the maximum total gain possible.
Sample Input
3 3
100 100 100
100 1 100
100 100 100
Sample Output
800 | {"inputs": ["3 3\n100 100 100\n100 1 100\n100 100 100", "4 5\n87882 40786 3691 85313 46694\n28884 16067 3242 97367 78518\n4250 35501 9780 14435 19004\n64673 65438 56977 64495 27280", "3 3\n3 1 2\n3 2 0\n2 3 2", "3 3\n1 10 1\n1 10 1\n1 10 1", "3 3\n0 0 0\n0 10000 0\n0 0 0", "3 3\n1 1 1\n0 10000 0\n1 1 1", "3 3\n9 0 9\n0 9 9\n9 9 9", "3 3\n0 0 0\n0 100 0\n0 0 0", "3 3\n100000 100000 100000\n1 100000 100000\n1 1 100000", "3 3\n100 0 100\n1 100 100\n0 100 100"], "outputs": ["800", "747898", "16", "26", "0", "6", "54", "0", "500003", "501"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 13 | codeforces |
|
569f266d1ef3cadb019f0bea338062a5 | none | Valentin participates in a show called "Shockers". The rules are quite easy: jury selects one letter which Valentin doesn't know. He should make a small speech, but every time he pronounces a word that contains the selected letter, he receives an electric shock. He can make guesses which letter is selected, but for each incorrect guess he receives an electric shock too. The show ends when Valentin guesses the selected letter correctly.
Valentin can't keep in mind everything, so he could guess the selected letter much later than it can be uniquely determined and get excessive electric shocks. Excessive electric shocks are those which Valentin got after the moment the selected letter can be uniquely determined. You should find out the number of excessive electric shocks.
The first line contains a single integer *n* (1<=β€<=*n*<=β€<=105)Β β the number of actions Valentin did.
The next *n* lines contain descriptions of his actions, each line contains description of one action. Each action can be of one of three types:
1. Valentin pronounced some word and didn't get an electric shock. This action is described by the string ". w" (without quotes), in which "." is a dot (ASCII-code 46), and *w* is the word that Valentin said. 1. Valentin pronounced some word and got an electric shock. This action is described by the string "! w" (without quotes), in which "!" is an exclamation mark (ASCII-code 33), and *w* is the word that Valentin said. 1. Valentin made a guess about the selected letter. This action is described by the string "? s" (without quotes), in which "?" is a question mark (ASCII-code 63), and *s* is the guessΒ β a lowercase English letter.
All words consist only of lowercase English letters. The total length of all words does not exceed 105.
It is guaranteed that last action is a guess about the selected letter. Also, it is guaranteed that Valentin didn't make correct guesses about the selected letter before the last action. Moreover, it's guaranteed that if Valentin got an electric shock after pronouncing some word, then it contains the selected letter; and also if Valentin didn't get an electric shock after pronouncing some word, then it does not contain the selected letter.
Output a single integerΒ β the number of electric shocks that Valentin could have avoided if he had told the selected letter just after it became uniquely determined.
Sample Input
5
! abc
. ad
. b
! cd
? c
8
! hello
! codeforces
? c
. o
? d
? h
. l
? e
7
! ababahalamaha
? a
? b
? a
? b
? a
? h
Sample Output
1
2
0
| {"inputs": ["5\n! abc\n. ad\n. b\n! cd\n? c", "8\n! hello\n! codeforces\n? c\n. o\n? d\n? h\n. l\n? e", "7\n! ababahalamaha\n? a\n? b\n? a\n? b\n? a\n? h", "4\n! abcd\n! cdef\n? d\n? c", "1\n? q", "15\n. r\n? e\n. s\n. rw\n? y\n. fj\n. zftyd\n? r\n! wq\n? w\n? p\n. ours\n. dto\n. lbyfru\n? q", "3\n. abcdefghijklmnopqrstuvwxy\n? a\n? z", "3\n. abcdefghijklmnopqrstuvwxy\n! z\n? z"], "outputs": ["1", "2", "0", "0", "0", "2", "1", "1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 82 | codeforces |
|
56c299caf0c2946a94e66bc57bd96b66 | Tom Riddle's Diary | Harry Potter is on a mission to destroy You-Know-Who's Horcruxes. The first Horcrux that he encountered in the Chamber of Secrets is Tom Riddle's diary. The diary was with Ginny and it forced her to open the Chamber of Secrets. Harry wants to know the different people who had ever possessed the diary to make sure they are not under its influence.
He has names of *n* people who possessed the diary in order. You need to tell, for each person, if he/she possessed the diary at some point before or not.
Formally, for a name *s**i* in the *i*-th line, output "YES" (without quotes) if there exists an index *j* such that *s**i*<==<=*s**j* and *j*<=<<=*i*, otherwise, output "NO" (without quotes).
First line of input contains an integer *n* (1<=β€<=*n*<=β€<=100)Β β the number of names in the list.
Next *n* lines each contain a string *s**i*, consisting of lowercase English letters. The length of each string is between 1 and 100.
Output *n* lines each containing either "YES" or "NO" (without quotes), depending on whether this string was already present in the stream or not.
You can print each letter in any case (upper or lower).
Sample Input
6
tom
lucius
ginny
harry
ginny
harry
3
a
a
a
Sample Output
NO
NO
NO
NO
YES
YES
NO
YES
YES
| {"inputs": ["6\ntom\nlucius\nginny\nharry\nginny\nharry", "3\na\na\na", "1\nzn", "9\nliyzmbjwnzryjokufuxcqtzwworjeoxkbaqrujrhdidqdvwdfzilwszgnzglnnbogaclckfnbqovtziuhwvyrqwmskx\nliyzmbjwnzryjokufuxcqtzwworjeoxkbaqrujrhdidqdvwdfzilwszgnzglnnbogaclckfnbqovtziuhwvyrqwmskx\nliyzmbjwnzryjokufuxcqtzwworjeoxkbaqrujrhdidqdvwdfzilwszgnzglnnbogaclckfnbqovtziuhwvyrqwmskx\nhrtm\nssjqvixduertmotgagizamvfucfwtxqnhuowbqbzctgznivehelpcyigwrbbdsxnewfqvcf\nhyrtxvozpbveexfkgalmguozzakitjiwsduqxonb\nwcyxteiwtcyuztaguilqpbiwcwjaiq\nwcyxteiwtcyuztaguilqpbiwcwjaiq\nbdbivqzvhggth", "10\nkkiubdktydpdcbbttwpfdplhhjhrpqmpg\nkkiubdktydpdcbbttwpfdplhhjhrpqmpg\nmvutw\nqooeqoxzxwetlpecqiwgdbogiqqulttysyohwhzxzphvsfmnplizxoebzcvvfyppqbhxjksuzepuezqqzxlfmdanoeaoqmor\nmvutw\nvchawxjoreboqzuklifv\nvchawxjoreboqzuklifv\nnivijte\nrflybruq\nvchawxjoreboqzuklifv", "1\nz", "9\nl\ny\nm\nj\nn\nr\nj\nk\nf", "14\nw\na\nh\np\nk\nw\ny\nv\ns\nf\nx\nd\nk\nr", "25\np\nk\nu\nl\nf\nt\nc\ns\nq\nd\nb\nq\no\ni\ni\nd\ni\nw\nn\ng\nw\nt\na\ne\ni", "20\nd\nh\ng\no\np\ne\nt\nj\nv\ni\nt\nh\ns\ni\nw\nf\nx\na\nl\ni", "3\nbbbbbbb\nbbbbbbbbb\nbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "2\nab\nba", "6\ntom\nlucius\nginnys\nharpy\nginny\nharry", "2\nabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde\nabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde", "42\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na"], "outputs": ["NO\nNO\nNO\nNO\nYES\nYES", "NO\nYES\nYES", "NO", "NO\nYES\nYES\nNO\nNO\nNO\nNO\nYES\nNO", "NO\nYES\nNO\nNO\nYES\nNO\nYES\nNO\nNO\nYES", "NO", "NO\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO", "NO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\nNO\nNO\nNO\nNO\nYES\nNO", "NO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\nNO\nYES\nYES\nNO\nNO\nYES", "NO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nNO\nYES\nNO\nNO\nNO\nNO\nNO\nYES", "NO\nNO\nNO", "NO\nNO", "NO\nNO\nNO\nNO\nNO\nNO", "NO\nYES", "NO\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 591 | codeforces |
|
56c6f54cc6eef938ce3755bc6b36a16d | Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly *n* stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length *n*. Piegirl wants to create a string *s* using stickers. She may buy as many sheets of stickers as she wants, and may specify any string of length *n* for the sheets, but all the sheets must be identical, so the string is the same for all sheets. Once she attains the sheets of stickers, she will take some of the stickers from the sheets and arrange (in any order) them to form *s*. Determine the minimum number of sheets she has to buy, and provide a string describing a possible sheet of stickers she should buy.
The first line contains string *s* (1<=β€<=|*s*|<=β€<=1000), consisting of lowercase English characters only. The second line contains an integer *n* (1<=β€<=*n*<=β€<=1000).
On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of *n* lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string *s*, print instead a single line with the number -1.
Sample Input
banana
4
banana
3
banana
2
Sample Output
2
baan
3
nab
-1
| {"inputs": ["banana\n4", "banana\n3", "banana\n2", "p\n1000", "b\n1", "aba\n2", "aaa\n2", "aa\n3", "aaaaaaaabbbbbccccccccccccccccccccccccccccccc\n7", "aaaaa\n10", "baba\n3", "a\n1000", "aan\n5", "banana\n5", "a\n5", "aaaaaaa\n5", "abc\n100", "zzz\n4", "aaabbb\n3", "abc\n5", "abc\n10", "aaaaa\n100", "abc\n1000", "a\n10", "bbbbb\n6", "bnana\n4", "aaaaaaabbbbbbb\n3", "aabbbcccc\n7", "aaa\n9", "a\n2", "cccbba\n10", "a\n4"], "outputs": ["2\nbaan", "3\nnab", "-1", "1\npaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...", "1\nb", "2\nab", "2\naa", "1\naaa", "8\nabcccca", "1\naaaaaaaaaa", "2\naba", "1\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...", "1\naanaa", "2\naabna", "1\naaaaa", "2\naaaaa", "1\nabcaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "1\nzzza", "3\naba", "1\nabcaa", "1\nabcaaaaaaa", "1\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "1\nabcaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...", "1\naaaaaaaaaa", "1\nbbbbba", "2\nabna", "7\naba", "2\nabbccaa", "1\naaaaaaaaa", "1\naa", "1\nabbcccaaaa", "1\naaaa"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 9 | codeforces |
|
56dd00818d60b0d068df5b0ca0550b87 | Perfect Pair | Let us call a pair of integer numbers *m*-perfect, if at least one number in the pair is greater than or equal to *m*. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not.
Two integers *x*, *y* are written on the blackboard. It is allowed to erase one of them and replace it with the sum of the numbers, (*x*<=+<=*y*).
What is the minimum number of such operations one has to perform in order to make the given pair of integers *m*-perfect?
Single line of the input contains three integers *x*, *y* and *m* (<=-<=1018<=β€<=*x*, *y*, *m*<=β€<=1018).
Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preffered to use the cin, cout streams or the %I64d specifier.
Print the minimum number of operations or "-1" (without quotes), if it is impossible to transform the given pair to the *m*-perfect one.
Sample Input
1 2 5
-1 4 15
0 -1 5
Sample Output
2
4
-1
| {"inputs": ["1 2 5", "-1 4 15", "0 -1 5", "0 1 8", "-134 -345 -134", "-134 -345 -133", "999999999 -1000000000 1000000000", "0 0 0", "0 0 1", "-1000000000000000000 1 1000000000000000000", "-3 26 -1", "-25 4 -8", "12 30 -8", "-12 17 3", "4 -11 28", "38 174 957147453", "154 30 763391461", "3 193 648520002", "139 82 923851170", "171 185 534908267", "-868993006 -389009632 -766659629", "-429468031 69656014 39767881", "185212727 871828769 828159476", "140457446 731228634 -75123935", "223567628 -731033737 352248633", "-187818082 -372699371 -301077133", "-552043292 -693546115 415527936", "-29007970 -344600631 62206369", "101292660 -305927896 648565756", "702748103 -278432024 995244274", "0 0 -1", "0 0 0", "0 0 1000000000", "0 0 1", "1 -999999999 239239239", "-1 -1 0", "-1 0 0", "-1 0 1", "-1000000000 -1000000000 -1000000000", "-1000000000 -1000000000 1000000000", "999999999 999999999 1000000000", "-1 1 609276626", "-1 2 926098525", "0 0 698431198", "0 -3 702455284", "0 0 648749804", "-1 0 861856808", "2 2 -213745374", "-1 1 21065410", "3 -3 607820420", "36 -58 428518679", "8 55 931239629", "-99 -91 523666385", "-56 -11 631827324", "-4 6 447215792", "-47 -31 -669106932", "12 -76 -999189104", "39 15 -960040787", "-96 26 -210129802", "93 86 -850132431", "1 -1000000000000000000 1000000000000000000", "-2348349823443 234234545453 1000000000000000000", "0 1 679891637638612258", "-1000000000000000000 -1000000000000000000 -1000000000000000000", "-1000000000000000000 -1000000000000000000 -999999999999999999", "-100000000000000 1 233", "-1000000000000 2 1000000000000", "-1000000000000 3 1000000000", "10 -10 0", "-1000000000000000 2 444"], "outputs": ["2", "4", "-1", "5", "0", "-1", "3", "0", "-1", "1000000000000000087", "0", "0", "0", "0", "8", "33", "33", "32", "33", "31", "0", "0", "0", "0", "5", "0", "-1", "-1", "8", "2", "0", "0", "-1", "-1", "1000000040", "-1", "0", "-1", "0", "-1", "1", "44", "43", "-1", "-1", "-1", "-1", "0", "37", "42", "37", "36", "-1", "-1", "39", "0", "0", "0", "0", "0", "1000000000000000087", "43", "86", "0", "-1", "100000000000012", "500000000057", "333333333375", "0", "500000000000012"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 22 | codeforces |
|
570f9c7077215c141fdea3f969d947e8 | Pineapple Incident | Ted has a pineapple. This pineapple is able to bark like a bulldog! At time *t* (in seconds) it barks for the first time. Then every *s* seconds after it, it barks twice with 1 second interval. Thus it barks at times *t*, *t*<=+<=*s*, *t*<=+<=*s*<=+<=1, *t*<=+<=2*s*, *t*<=+<=2*s*<=+<=1, etc.
Barney woke up in the morning and wants to eat the pineapple, but he can't eat it when it's barking. Barney plans to eat it at time *x* (in seconds), so he asked you to tell him if it's gonna bark at that time.
The first and only line of input contains three integers *t*, *s* and *x* (0<=β€<=*t*,<=*x*<=β€<=109, 2<=β€<=*s*<=β€<=109)Β β the time the pineapple barks for the first time, the pineapple barking interval, and the time Barney wants to eat the pineapple respectively.
Print a single "YES" (without quotes) if the pineapple will bark at time *x* or a single "NO" (without quotes) otherwise in the only line of output.
Sample Input
3 10 4
3 10 3
3 8 51
3 8 52
Sample Output
NO
YES
YES
YES
| {"inputs": ["3 10 4", "3 10 3", "3 8 51", "3 8 52", "456947336 740144 45", "33 232603 599417964", "4363010 696782227 701145238", "9295078 2 6", "76079 281367 119938421", "93647 7 451664565", "5 18553 10908", "6 52 30", "6431 855039 352662", "749399100 103031711 761562532", "21 65767 55245", "4796601 66897 4860613", "8 6728951 860676", "914016 6 914019", "60686899 78474 60704617", "3 743604 201724", "571128 973448796 10", "688051712 67 51", "74619 213344 6432326", "6947541 698167 6", "83 6 6772861", "251132 67561 135026988", "8897216 734348516 743245732", "50 64536 153660266", "876884 55420 971613604", "0 6906451 366041903", "11750 8 446010134", "582692707 66997 925047377", "11 957526890 957526901", "556888 514614196 515171084", "6 328006 584834704", "4567998 4 204966403", "60 317278 109460971", "906385 342131991 685170368", "1 38 902410512", "29318 787017 587931018", "351416375 243431 368213115", "54 197366062 197366117", "586389 79039 850729874", "723634470 2814619 940360134", "0 2 0", "0 2 1", "0 2 2", "0 2 3", "0 2 1000000000", "0 10 23", "0 2 999999999", "10 5 11", "1 2 1000000000", "1 10 20", "1 2 999999937", "10 3 5", "3 2 5", "0 4 0", "0 215 403", "5 2 10", "0 2 900000000", "0 79 4000", "5 1000 1000", "1 5 103", "5 2 6", "120 2 1000000000", "2 2 1000000000", "5 5 13", "10 5 15", "11 2 0", "3 8 53", "2 2 4", "4 4 0", "1 2 3", "5 3 9", "5 6 19", "3 10 125", "5 3 8", "6 3 9", "0 3 5", "5 3 300000035", "5 2 7", "1 5 6", "4 2 6", "0 3 999999998", "0 10001 0", "6 5 3", "1 5 1000000000", "1 3 6", "3 3 1000000000", "3 3 4", "3 3 5", "3 3 0", "1 2 4", "5 5 10"], "outputs": ["NO", "YES", "YES", "YES", "NO", "YES", "YES", "NO", "YES", "YES", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "YES", "YES", "YES", "YES", "YES", "YES", "YES", "YES", "YES", "YES", "YES", "YES", "YES", "YES", "YES", "YES", "YES", "YES", "YES", "NO", "YES", "YES", "YES", "NO", "YES", "NO", "YES", "NO", "YES", "NO", "YES", "YES", "NO", "YES", "YES", "NO", "NO", "NO", "NO", "YES", "YES", "NO", "YES", "NO", "NO", "YES", "NO", "YES", "YES", "NO", "NO", "YES", "YES", "NO", "YES", "YES", "YES", "YES", "NO", "YES", "NO", "NO", "NO", "YES", "NO", "NO", "NO", "YES", "YES"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 205 | codeforces |
|
571267a70a8005908ca90f309f896f28 | Constants in the language of Shakespeare | Shakespeare is a widely known esoteric programming language in which programs look like plays by Shakespeare, and numbers are given by combinations of ornate epithets. In this problem we will have a closer look at the way the numbers are described in Shakespeare.
Each constant in Shakespeare is created from non-negative powers of 2 using arithmetic operations. For simplicity we'll allow only addition and subtraction and will look for a representation of the given number which requires a minimal number of operations.
You are given an integer *n*. You have to represent it as *n*<==<=*a*1<=+<=*a*2<=+<=...<=+<=*a**m*, where each of *a**i* is a non-negative power of 2, possibly multiplied by -1. Find a representation which minimizes the value of *m*.
The only line of input contains a positive integer *n*, written as its binary notation. The length of the notation is at most 106. The first digit of the notation is guaranteed to be 1.
Output the required minimal *m*. After it output *m* lines. Each line has to be formatted as "+2^x" or "-2^x", where *x* is the power coefficient of the corresponding term. The order of the lines doesn't matter.
Sample Input
1111
1010011
Sample Output
2
+2^4
-2^0
4
+2^0
+2^1
+2^4
+2^6
| {"inputs": ["1111", "1010011", "1", "10110111", "10101110", "1011001", "10001", "10", "11", "100", "100", "111", "1000000000", "1011000000", "1100010000", "1000111001", "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "1000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000", "1000000000000000000000000000010000000000000000100000000000100000000000000000000000000000000000000000", "1000000000000000000100000001000000000000000000100000101000000000000000000000100000000000000100000000", "1000100000101000000100100000000000000000100000000000000010000010000001010010100000000000000001001000", "1000001001000011000010001000100110010110100000000101010101000100100010000100000100000100001000000000", "1110000000001011100111001010000010101100010101001101001010101100011101100110000010000101110101000011", "1001110101111100101111011111111111101010111111010111011111111111011111111111111100011011111111111101", "1111111101111111101111111111101111111111111111111111101111111011111110011111101111111110111111111111", "100000000000000000000000000000000", "111111000111111000111111000111111", "10001100000000000011011011", "1101011", "11000101010000101101101101111000100100001101001111000011011100", "11101011"], "outputs": ["2\n+2^4\n-2^0", "4\n+2^0\n+2^1\n+2^4\n+2^6", "1\n+2^0", "4\n+2^8\n-2^6\n-2^3\n-2^0", "4\n+2^8\n-2^6\n-2^4\n-2^1", "4\n+2^0\n+2^3\n+2^4\n+2^6", "2\n+2^0\n+2^4", "1\n+2^1", "2\n+2^0\n+2^1", "1\n+2^2", "1\n+2^2", "2\n+2^3\n-2^0", "1\n+2^9", "3\n+2^6\n+2^7\n+2^9", "3\n+2^4\n+2^8\n+2^9", "4\n+2^0\n+2^6\n-2^3\n+2^9", "1\n+2^99", "1\n+2^99", "2\n+2^18\n+2^99", "4\n+2^41\n+2^53\n+2^70\n+2^99", "8\n+2^8\n+2^23\n+2^45\n+2^47\n+2^53\n+2^72\n+2^80\n+2^99", "15\n+2^3\n+2^6\n+2^23\n+2^25\n+2^28\n+2^30\n+2^37\n+2^43\n+2^59\n+2^77\n+2^80\n+2^87\n+2^89\n+2^95\n+2^99", "26\n+2^9\n+2^14\n+2^20\n+2^26\n+2^31\n+2^35\n+2^38\n+2^42\n+2^44\n+2^46\n+2^48\n+2^50\n+2^59\n+2^61\n+2^62\n+2^64\n+2^67\n+2^68\n+2^71\n+2^75\n+2^79\n+2^84\n+2^85\n+2^90\n+2^93\n+2^99", "37\n+2^0\n+2^1\n+2^6\n+2^8\n+2^15\n-2^13\n-2^10\n+2^19\n+2^25\n+2^26\n+2^35\n-2^31\n-2^29\n+2^38\n+2^39\n+2^41\n+2^43\n+2^45\n+2^48\n+2^50\n+2^51\n+2^54\n+2^56\n+2^58\n+2^62\n+2^63\n+2^65\n+2^67\n+2^73\n+2^75\n+2^81\n-2^78\n+2^88\n-2^86\n-2^83\n+2^100\n-2^97", "20\n+2^0\n+2^17\n-2^14\n-2^2\n+2^84\n-2^82\n-2^77\n-2^64\n-2^62\n-2^60\n-2^53\n-2^51\n-2^47\n-2^35\n-2^20\n+2^97\n-2^93\n-2^91\n-2^86\n+2^99", "11\n+2^29\n-2^22\n-2^12\n-2^0\n+2^100\n-2^91\n-2^82\n-2^70\n-2^46\n-2^38\n-2^31", "1\n+2^32", "8\n+2^6\n-2^0\n+2^15\n-2^9\n+2^24\n-2^18\n+2^33\n-2^27", "7\n+2^8\n-2^5\n-2^2\n-2^0\n+2^20\n+2^21\n+2^25", "4\n+2^7\n-2^4\n-2^2\n-2^0", "21\n+2^8\n-2^5\n-2^2\n+2^16\n-2^12\n+2^18\n+2^20\n+2^21\n+2^26\n+2^29\n+2^48\n-2^46\n-2^43\n-2^40\n-2^37\n-2^33\n+2^52\n+2^54\n+2^56\n+2^60\n+2^61", "4\n+2^8\n-2^4\n-2^2\n-2^0"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces |
|
571ae45c10d438fc84e131b6b6598e6f | Subsequence Counting | Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size *n* has 2*n*<=-<=1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence <=-<= Minimum_element_of_subsequence <=β₯<=*d*
Pikachu was finally left with *X* subsequences.
However, he lost the initial array he had, and now is in serious trouble. He still remembers the numbers *X* and *d*. He now wants you to construct any such array which will satisfy the above conditions. All the numbers in the final array should be positive integers less than 1018.
Note the number of elements in the output array should not be more than 104. If no answer is possible, print <=-<=1.
The only line of input consists of two space separated integers *X* and *d* (1<=β€<=*X*,<=*d*<=β€<=109).
Output should consist of two lines.
First line should contain a single integer *n* (1<=β€<=*n*<=β€<=10<=000)β the number of integers in the final array.
Second line should consist of *n* space separated integers β *a*1,<=*a*2,<=... ,<=*a**n* (1<=β€<=*a**i*<=<<=1018).
If there is no answer, print a single integer -1. If there are multiple answers, print any of them.
Sample Input
10 5
4 2
Sample Output
6
5 50 7 15 6 1004
10 100 1000 10000 | {"inputs": ["10 5", "4 2", "4 1", "1 1", "63 1", "98 88", "746 173", "890 553", "883 1000", "1 1000", "695 188", "2060 697", "70 3321", "6358 1646", "167959139 481199252", "641009859 54748096", "524125987 923264237", "702209411 496813081", "585325539 365329221", "58376259 643910770", "941492387 72235422", "824608515 940751563", "2691939 514300407", "802030518 598196518", "685146646 26521171", "863230070 895037311", "41313494 468586155", "219396918 747167704", "102513046 615683844", "985629174 189232688", "458679894 912524637", "341796022 486073481", "519879446 764655030", "452405440 586588704", "335521569 160137548", "808572289 733686393", "691688417 162011045", "869771841 30527185", "752887969 604076030", "930971393 177624874", "109054817 751173719", "992170945 324722563", "170254369 48014511", "248004555 280013594", "131120683 148529734", "604171403 722078578", "487287531 295627423", "665370955 18919371", "843454379 297500920", "21537803 166017060", "904653932 739565904", "787770060 313114749", "260820780 181630889", "43603670 268405779", "1000000000 1000000000", "15000 1", "1048576 1", "1000000000 1", "100000000 1", "1000000 1", "536870911 1", "10009 1", "10001 1"], "outputs": ["6\n1 1 1 7 13 19 ", "3\n1 1 4 ", "3\n1 1 3 ", "1\n1 ", "21\n1 1 1 1 1 3 3 3 3 5 5 5 7 7 9 11 13 15 17 19 21 ", "15\n1 1 1 1 1 1 90 90 90 90 90 179 268 357 446 ", "37\n1 1 1 1 1 1 1 1 1 175 175 175 175 175 175 175 349 349 349 349 349 349 523 523 523 523 523 697 697 697 871 1045 1219 1393 1567 1741 1915 ", "43\n1 1 1 1 1 1 1 1 1 555 555 555 555 555 555 555 555 1109 1109 1109 1109 1109 1109 1663 1663 1663 1663 1663 2217 2217 2217 2217 2771 2771 2771 3325 3879 4433 4987 5541 6095 6649 7203 ", "40\n1 1 1 1 1 1 1 1 1 1002 1002 1002 1002 1002 1002 1002 1002 2003 2003 2003 2003 2003 2003 3004 3004 3004 3004 3004 4005 4005 4005 4005 5006 6007 7008 8009 9010 10011 11012 12013 ", "1\n1 ", "35\n1 1 1 1 1 1 1 1 1 190 190 190 190 190 190 190 379 379 379 379 379 568 568 568 568 757 757 946 1135 1324 1513 1702 1891 2080 2269 ", "19\n1 1 1 1 1 1 1 1 1 1 1 699 699 699 1397 1397 2095 2793 3491 ", "12\n1 1 1 1 1 1 3323 3323 6645 9967 13289 16611 ", "50\n1 1 1 1 1 1 1 1 1 1 1 1 1648 1648 1648 1648 1648 1648 1648 1648 1648 1648 1648 3295 3295 3295 3295 3295 3295 3295 4942 4942 4942 4942 4942 4942 6589 6589 6589 6589 8236 8236 9883 11530 13177 14824 16471 18118 19765 21412 ", "154\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 481199254 481199254 481199254 481199254 481199254 481199254 481199254 481199254 481199254 481199254 481199254 481199254 481199254 481199254 481199254 481199254 481199254 481199254 481199254 481199254 481199254 481199254 481199254 481199254 481199254 962398507 962398507 962398507 962398507 962398507 962398507 962398507 962398507 962398507 962398507 962398507 962398507 962398507 962398507 962398507 962398507 962398507 1443597760 1443597760 1443597760...", "192\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 54748098 54748098 54748098 54748098 54748098 54748098 54748098 54748098 54748098 54748098 54748098 54748098 54748098 54748098 54748098 54748098 54748098 54748098 54748098 54748098 54748098 54748098 54748098 54748098 54748098 54748098 109496195 109496195 109496195 109496195 109496195 109496195 109496195 109496195 109496195 109496195 109496195 109496195 109496195 109496195 109496195 109496195 109496195 109496195 109496195 109496195 109496195 1094...", "289\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 923264239 923264239 923264239 923264239 923264239 923264239 923264239 923264239 923264239 923264239 923264239 923264239 923264239 923264239 923264239 923264239 923264239 923264239 923264239 923264239 923264239 923264239 923264239 923264239 923264239 923264239 923264239 1846528477 1846528477 1846528477 1846528477 1846528477 1846528477 1846528477 1846528477 1846528477 1846528477 1846528477 1846528477 1846528477 1846528477 1846528477 1846528477 1846...", "276\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 496813083 496813083 496813083 496813083 496813083 496813083 496813083 496813083 496813083 496813083 496813083 496813083 496813083 496813083 496813083 496813083 496813083 496813083 496813083 496813083 496813083 496813083 496813083 496813083 496813083 496813083 496813083 993626165 993626165 993626165 993626165 993626165 993626165 993626165 993626165 993626165 993626165 993626165 993626165 993626165 993626165 993626165 993626165 993626165 99362616...", "243\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 365329223 365329223 365329223 365329223 365329223 365329223 365329223 365329223 365329223 365329223 365329223 365329223 365329223 365329223 365329223 365329223 365329223 365329223 365329223 365329223 365329223 365329223 365329223 365329223 365329223 730658445 730658445 730658445 730658445 730658445 730658445 730658445 730658445 730658445 730658445 730658445 730658445 730658445 730658445 730658445 730658445 730658445 730658445 730658445 73065844...", "196\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 643910772 643910772 643910772 643910772 643910772 643910772 643910772 643910772 643910772 643910772 643910772 643910772 643910772 643910772 643910772 643910772 643910772 643910772 643910772 643910772 643910772 643910772 643910772 643910772 1287821543 1287821543 1287821543 1287821543 1287821543 1287821543 1287821543 1287821543 1287821543 1287821543 1287821543 1287821543 1287821543 1287821543 1287821543 1287821543 1287821543 1287821543 1287821543 1287821...", "194\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 72235424 72235424 72235424 72235424 72235424 72235424 72235424 72235424 72235424 72235424 72235424 72235424 72235424 72235424 72235424 72235424 72235424 72235424 72235424 72235424 72235424 72235424 72235424 72235424 72235424 72235424 72235424 72235424 144470847 144470847 144470847 144470847 144470847 144470847 144470847 144470847 144470847 144470847 144470847 144470847 144470847 144470847 144470847 144470847 144470847 144470847 144470847 144470...", "192\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 940751565 940751565 940751565 940751565 940751565 940751565 940751565 940751565 940751565 940751565 940751565 940751565 940751565 940751565 940751565 940751565 940751565 940751565 940751565 940751565 940751565 940751565 940751565 940751565 940751565 940751565 940751565 940751565 1881503129 1881503129 1881503129 1881503129 1881503129 1881503129 1881503129 1881503129 1881503129 1881503129 1881503129 1881503129 1881503129 1881503129 1881503129 188...", "107\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 514300409 514300409 514300409 514300409 514300409 514300409 514300409 514300409 514300409 514300409 514300409 514300409 514300409 514300409 514300409 514300409 514300409 514300409 514300409 1028600817 1028600817 1028600817 1028600817 1028600817 1028600817 1028600817 1028600817 1028600817 1028600817 1028600817 1028600817 1028600817 1028600817 1028600817 1028600817 1542901225 1542901225 1542901225 1542901225 1542901225 1542901225 1542901225 1542901225 1542901225...", "283\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 598196520 598196520 598196520 598196520 598196520 598196520 598196520 598196520 598196520 598196520 598196520 598196520 598196520 598196520 598196520 598196520 598196520 598196520 598196520 598196520 598196520 598196520 598196520 598196520 598196520 598196520 598196520 1196393039 1196393039 1196393039 1196393039 1196393039 1196393039 1196393039 1196393039 1196393039 1196393039 1196393039 1196393039 1196393039 1196393039 1196393039 1196393039 11...", "199\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 26521173 26521173 26521173 26521173 26521173 26521173 26521173 26521173 26521173 26521173 26521173 26521173 26521173 26521173 26521173 26521173 26521173 26521173 26521173 26521173 26521173 26521173 26521173 26521173 26521173 26521173 26521173 53042345 53042345 53042345 53042345 53042345 53042345 53042345 53042345 53042345 53042345 53042345 53042345 53042345 53042345 53042345 53042345 53042345 53042345 53042345 53042345 53042345 53042345 5304234...", "290\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 895037313 895037313 895037313 895037313 895037313 895037313 895037313 895037313 895037313 895037313 895037313 895037313 895037313 895037313 895037313 895037313 895037313 895037313 895037313 895037313 895037313 895037313 895037313 895037313 895037313 895037313 895037313 895037313 1790074625 1790074625 1790074625 1790074625 1790074625 1790074625 1790074625 1790074625 1790074625 1790074625 1790074625 1790074625 1790074625 1790074625 1790074625 179...", "194\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 468586157 468586157 468586157 468586157 468586157 468586157 468586157 468586157 468586157 468586157 468586157 468586157 468586157 468586157 468586157 468586157 468586157 468586157 468586157 468586157 468586157 468586157 937172313 937172313 937172313 937172313 937172313 937172313 937172313 937172313 937172313 937172313 937172313 937172313 937172313 937172313 937172313 937172313 937172313 937172313 937172313 937172313 937172313 1405758469 1405758469 1405...", "226\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 747167706 747167706 747167706 747167706 747167706 747167706 747167706 747167706 747167706 747167706 747167706 747167706 747167706 747167706 747167706 747167706 747167706 747167706 747167706 747167706 747167706 747167706 747167706 747167706 747167706 747167706 1494335411 1494335411 1494335411 1494335411 1494335411 1494335411 1494335411 1494335411 1494335411 1494335411 1494335411 1494335411 1494335411 1494335411 1494335411 1494335411 1494335411 14943...", "179\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 615683846 615683846 615683846 615683846 615683846 615683846 615683846 615683846 615683846 615683846 615683846 615683846 615683846 615683846 615683846 615683846 615683846 615683846 615683846 615683846 615683846 615683846 615683846 615683846 615683846 1231367691 1231367691 1231367691 1231367691 1231367691 1231367691 1231367691 1231367691 1231367691 1231367691 1231367691 1231367691 1231367691 1231367691 1231367691 1231367691 1231367691 1231367691 123136...", "310\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 189232690 189232690 189232690 189232690 189232690 189232690 189232690 189232690 189232690 189232690 189232690 189232690 189232690 189232690 189232690 189232690 189232690 189232690 189232690 189232690 189232690 189232690 189232690 189232690 189232690 189232690 189232690 189232690 378465379 378465379 378465379 378465379 378465379 378465379 378465379 378465379 378465379 378465379 378465379 378465379 378465379 378465379 378465379 378465379 37846537...", "272\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 912524639 912524639 912524639 912524639 912524639 912524639 912524639 912524639 912524639 912524639 912524639 912524639 912524639 912524639 912524639 912524639 912524639 912524639 912524639 912524639 912524639 912524639 912524639 912524639 912524639 912524639 912524639 1825049277 1825049277 1825049277 1825049277 1825049277 1825049277 1825049277 1825049277 1825049277 1825049277 1825049277 1825049277 1825049277 1825049277 1825049277 1825049277 1825...", "238\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 486073483 486073483 486073483 486073483 486073483 486073483 486073483 486073483 486073483 486073483 486073483 486073483 486073483 486073483 486073483 486073483 486073483 486073483 486073483 486073483 486073483 486073483 486073483 486073483 486073483 486073483 972146965 972146965 972146965 972146965 972146965 972146965 972146965 972146965 972146965 972146965 972146965 972146965 972146965 972146965 972146965 972146965 972146965 972146965 972146965 ...", "323\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 764655032 764655032 764655032 764655032 764655032 764655032 764655032 764655032 764655032 764655032 764655032 764655032 764655032 764655032 764655032 764655032 764655032 764655032 764655032 764655032 764655032 764655032 764655032 764655032 764655032 764655032 764655032 1529310063 1529310063 1529310063 1529310063 1529310063 1529310063 1529310063 1529310063 1529310063 1529310063 1529310063 1529310063 1529310063 1529310063 1529310063 1529310063 1529...", "268\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 586588706 586588706 586588706 586588706 586588706 586588706 586588706 586588706 586588706 586588706 586588706 586588706 586588706 586588706 586588706 586588706 586588706 586588706 586588706 586588706 586588706 586588706 586588706 586588706 586588706 586588706 586588706 1173177411 1173177411 1173177411 1173177411 1173177411 1173177411 1173177411 1173177411 1173177411 1173177411 1173177411 1173177411 1173177411 1173177411 1173177411 1173177411 1173...", "311\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 160137550 160137550 160137550 160137550 160137550 160137550 160137550 160137550 160137550 160137550 160137550 160137550 160137550 160137550 160137550 160137550 160137550 160137550 160137550 160137550 160137550 160137550 160137550 160137550 160137550 320275099 320275099 320275099 320275099 320275099 320275099 320275099 320275099 320275099 320275099 320275099 320275099 320275099 320275099 320275099 320275099 320275099 320275099 320275099 320275099 ...", "192\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 733686395 733686395 733686395 733686395 733686395 733686395 733686395 733686395 733686395 733686395 733686395 733686395 733686395 733686395 733686395 733686395 733686395 733686395 733686395 733686395 733686395 733686395 733686395 733686395 733686395 733686395 733686395 733686395 1467372789 1467372789 1467372789 1467372789 1467372789 1467372789 1467372789 1467372789 1467372789 1467372789 1467372789 1467372789 1467372789 1467372789 1467372789 146...", "233\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 162011047 162011047 162011047 162011047 162011047 162011047 162011047 162011047 162011047 162011047 162011047 162011047 162011047 162011047 162011047 162011047 162011047 162011047 162011047 162011047 162011047 162011047 162011047 162011047 162011047 162011047 162011047 324022093 324022093 324022093 324022093 324022093 324022093 324022093 324022093 324022093 324022093 324022093 324022093 324022093 324022093 324022093 324022093 324022093 32402209...", "292\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 30527187 30527187 30527187 30527187 30527187 30527187 30527187 30527187 30527187 30527187 30527187 30527187 30527187 30527187 30527187 30527187 30527187 30527187 30527187 30527187 30527187 30527187 30527187 30527187 30527187 30527187 30527187 30527187 61054373 61054373 61054373 61054373 61054373 61054373 61054373 61054373 61054373 61054373 61054373 61054373 61054373 61054373 61054373 61054373 61054373 61054373 61054373 61054373 61054373 6105437...", "195\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 604076032 604076032 604076032 604076032 604076032 604076032 604076032 604076032 604076032 604076032 604076032 604076032 604076032 604076032 604076032 604076032 604076032 604076032 604076032 604076032 604076032 604076032 604076032 604076032 604076032 604076032 604076032 1208152063 1208152063 1208152063 1208152063 1208152063 1208152063 1208152063 1208152063 1208152063 1208152063 1208152063 1208152063 1208152063 1208152063 1208152063 1208152063 12...", "344\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 177624876 177624876 177624876 177624876 177624876 177624876 177624876 177624876 177624876 177624876 177624876 177624876 177624876 177624876 177624876 177624876 177624876 177624876 177624876 177624876 177624876 177624876 177624876 177624876 177624876 177624876 177624876 177624876 355249751 355249751 355249751 355249751 355249751 355249751 355249751 355249751 355249751 355249751 355249751 355249751 355249751 355249751 355249751 355249751 35524975...", "122\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 751173721 751173721 751173721 751173721 751173721 751173721 751173721 751173721 751173721 751173721 751173721 751173721 751173721 751173721 751173721 751173721 751173721 751173721 751173721 751173721 751173721 751173721 751173721 751173721 751173721 1502347441 1502347441 1502347441 1502347441 1502347441 1502347441 1502347441 1502347441 1502347441 1502347441 1502347441 1502347441 1502347441 1502347441 1502347441 1502347441 1502347441 1502347441 150234...", "258\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 324722565 324722565 324722565 324722565 324722565 324722565 324722565 324722565 324722565 324722565 324722565 324722565 324722565 324722565 324722565 324722565 324722565 324722565 324722565 324722565 324722565 324722565 324722565 324722565 324722565 324722565 324722565 324722565 649445129 649445129 649445129 649445129 649445129 649445129 649445129 649445129 649445129 649445129 649445129 649445129 649445129 649445129 649445129 649445129 64944512...", "164\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 48014513 48014513 48014513 48014513 48014513 48014513 48014513 48014513 48014513 48014513 48014513 48014513 48014513 48014513 48014513 48014513 48014513 48014513 48014513 48014513 48014513 48014513 48014513 48014513 48014513 96029025 96029025 96029025 96029025 96029025 96029025 96029025 96029025 96029025 96029025 96029025 96029025 96029025 96029025 96029025 96029025 96029025 96029025 96029025 96029025 96029025 144043537 144043537 144043537 14404353...", "239\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 280013596 280013596 280013596 280013596 280013596 280013596 280013596 280013596 280013596 280013596 280013596 280013596 280013596 280013596 280013596 280013596 280013596 280013596 280013596 280013596 280013596 280013596 280013596 280013596 280013596 280013596 560027191 560027191 560027191 560027191 560027191 560027191 560027191 560027191 560027191 560027191 560027191 560027191 560027191 560027191 560027191 560027191 560027191 560027191 560027191 56...", "235\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 148529736 148529736 148529736 148529736 148529736 148529736 148529736 148529736 148529736 148529736 148529736 148529736 148529736 148529736 148529736 148529736 148529736 148529736 148529736 148529736 148529736 148529736 148529736 148529736 148529736 297059471 297059471 297059471 297059471 297059471 297059471 297059471 297059471 297059471 297059471 297059471 297059471 297059471 297059471 297059471 297059471 297059471 297059471 297059471 297059471 2970...", "158\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 722078580 722078580 722078580 722078580 722078580 722078580 722078580 722078580 722078580 722078580 722078580 722078580 722078580 722078580 722078580 722078580 722078580 722078580 722078580 722078580 722078580 722078580 722078580 722078580 722078580 722078580 1444157159 1444157159 1444157159 1444157159 1444157159 1444157159 1444157159 1444157159 1444157159 1444157159 1444157159 1444157159 1444157159 1444157159 1444157159 1444157159 1444157159 2...", "243\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 295627425 295627425 295627425 295627425 295627425 295627425 295627425 295627425 295627425 295627425 295627425 295627425 295627425 295627425 295627425 295627425 295627425 295627425 295627425 295627425 295627425 295627425 295627425 295627425 295627425 295627425 295627425 591254849 591254849 591254849 591254849 591254849 591254849 591254849 591254849 591254849 591254849 591254849 591254849 591254849 591254849 591254849 591254849 591254849 591254849 ...", "228\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 18919373 18919373 18919373 18919373 18919373 18919373 18919373 18919373 18919373 18919373 18919373 18919373 18919373 18919373 18919373 18919373 18919373 18919373 18919373 18919373 18919373 18919373 18919373 18919373 18919373 18919373 37838745 37838745 37838745 37838745 37838745 37838745 37838745 37838745 37838745 37838745 37838745 37838745 37838745 37838745 37838745 37838745 37838745 37838745 37838745 37838745 37838745 37838745 37838745 3783874...", "209\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 297500922 297500922 297500922 297500922 297500922 297500922 297500922 297500922 297500922 297500922 297500922 297500922 297500922 297500922 297500922 297500922 297500922 297500922 297500922 297500922 297500922 297500922 297500922 297500922 297500922 297500922 297500922 297500922 595001843 595001843 595001843 595001843 595001843 595001843 595001843 595001843 595001843 595001843 595001843 595001843 595001843 595001843 595001843 595001843 59500184...", "116\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 166017062 166017062 166017062 166017062 166017062 166017062 166017062 166017062 166017062 166017062 166017062 166017062 166017062 166017062 166017062 166017062 166017062 166017062 166017062 166017062 166017062 166017062 332034123 332034123 332034123 332034123 332034123 332034123 332034123 332034123 332034123 332034123 332034123 332034123 332034123 332034123 332034123 332034123 332034123 332034123 332034123 498051184 498051184 498051184 498051184 49805118...", "323\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 739565906 739565906 739565906 739565906 739565906 739565906 739565906 739565906 739565906 739565906 739565906 739565906 739565906 739565906 739565906 739565906 739565906 739565906 739565906 739565906 739565906 739565906 739565906 739565906 739565906 739565906 739565906 739565906 1479131811 1479131811 1479131811 1479131811 1479131811 1479131811 1479131811 1479131811 1479131811 1479131811 1479131811 1479131811 1479131811 1479131811 1479131811 147...", "293\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 313114751 313114751 313114751 313114751 313114751 313114751 313114751 313114751 313114751 313114751 313114751 313114751 313114751 313114751 313114751 313114751 313114751 313114751 313114751 313114751 313114751 313114751 313114751 313114751 313114751 313114751 313114751 626229501 626229501 626229501 626229501 626229501 626229501 626229501 626229501 626229501 626229501 626229501 626229501 626229501 626229501 626229501 626229501 626229501 62622950...", "271\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 181630891 181630891 181630891 181630891 181630891 181630891 181630891 181630891 181630891 181630891 181630891 181630891 181630891 181630891 181630891 181630891 181630891 181630891 181630891 181630891 181630891 181630891 181630891 181630891 181630891 181630891 363261781 363261781 363261781 363261781 363261781 363261781 363261781 363261781 363261781 363261781 363261781 363261781 363261781 363261781 363261781 363261781 363261781 363261781 363261781 36...", "182\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 268405781 268405781 268405781 268405781 268405781 268405781 268405781 268405781 268405781 268405781 268405781 268405781 268405781 268405781 268405781 268405781 268405781 268405781 268405781 268405781 268405781 268405781 268405781 536811561 536811561 536811561 536811561 536811561 536811561 536811561 536811561 536811561 536811561 536811561 536811561 536811561 536811561 536811561 536811561 536811561 536811561 536811561 536811561 805217341 805217341 805217...", "274\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 2000000003 2000000003 2000000003 2000000003 2000000003 2000000003 2000000003 2000000003 2000000003 2000000003 2000000003 2000000003 20000000...", "66\n1 1 1 1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3 3 3 3 3 5 5 5 5 5 5 5 5 5 5 5 7 7 7 7 7 7 7 7 7 9 9 9 9 9 9 9 11 11 11 11 13 13 13 15 17 19 21 23 25 27 ", "21\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 ", "274\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 19 ...", "232\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 19 19 19 19 19 19 19 19 19 19 19 19 19 19 21 21 21 21 21 21 21 21 2...", "106\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 9 9 9 9 9 9 9 9 9 9 9 9 9 9 11 11 11 11 11 11 11 11 11 13 13 13 13 13 13 15 17 19 21 23 25 27 ", "435\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 ...", "54\n1 1 1 1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3 3 3 5 5 5 5 5 5 5 5 5 7 7 7 7 7 7 7 7 9 9 9 9 11 11 11 13 15 17 19 21 23 25 ", "50\n1 1 1 1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3 3 3 5 5 5 5 5 5 5 5 5 7 7 7 7 7 7 7 7 9 9 9 9 11 13 15 17 19 21 "]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 30 | codeforces |
|
571fcb9db60f838e9e04086862d0e748 | Energy exchange | It is well known that the planet suffers from the energy crisis. Little Petya doesn't like that and wants to save the world. For this purpose he needs every accumulator to contain the same amount of energy. Initially every accumulator has some amount of energy: the *i*-th accumulator has *a**i* units of energy. Energy can be transferred from one accumulator to the other. Every time *x* units of energy are transferred (*x* is not necessarily an integer) *k* percent of it is lost. That is, if *x* units were transferred from one accumulator to the other, amount of energy in the first one decreased by *x* units and in other increased by units.
Your task is to help Petya find what maximum equal amount of energy can be stored in each accumulator after the transfers.
First line of the input contains two integers *n* and *k* (1<=β€<=*n*<=β€<=10000,<=0<=β€<=*k*<=β€<=99) β number of accumulators and the percent of energy that is lost during transfers.
Next line contains *n* integers *a*1,<=*a*2,<=... ,<=*a**n* β amounts of energy in the first, second, .., *n*-th accumulator respectively (0<=β€<=*a**i*<=β€<=1000,<=1<=β€<=*i*<=β€<=*n*).
Output maximum possible amount of energy that can remain in each of accumulators after the transfers of energy.
The absolute or relative error in the answer should not exceed 10<=-<=6.
Sample Input
3 50
4 2 1
2 90
1 11
Sample Output
2.000000000
1.909090909
| {"inputs": ["3 50\n4 2 1", "2 90\n1 11", "5 26\n42 65 23 43 64", "5 45\n964 515 454 623 594", "1 20\n784", "10 20\n812 896 36 596 709 641 679 778 738 302", "10 83\n689 759 779 927 15 231 976 943 604 917", "11 1\n235 280 196 670 495 379 391 280 847 875 506", "12 71\n472 111 924 103 975 527 807 618 400 523 607 424", "13 89\n19 944 341 846 764 676 222 957 953 481 708 920 950", "14 6\n256 465 759 589 242 824 638 985 506 128 809 105 301 827", "100 95\n154 444 715 98 35 347 799 313 40 821 118 786 31 587 888 84 88 751 98 86 321 720 201 247 302 518 663 904 482 385 139 646 581 995 847 775 173 252 508 722 380 922 634 911 102 384 346 212 705 380 220 221 492 421 244 591 758 631 370 866 536 872 294 152 337 810 761 235 789 839 365 366 623 897 905 249 685 838 380 873 702 379 865 68 215 168 425 264 652 228 167 498 733 41 502 21 565 956 430 171", "101 71\n113 551 568 26 650 547 89 668 64 651 110 515 482 401 170 971 623 672 135 106 985 751 286 255 82 588 122 568 751 867 335 488 324 122 829 256 675 471 255 723 630 802 667 665 206 774 573 499 361 202 620 522 72 220 739 868 101 135 254 519 896 227 224 968 263 826 466 377 360 24 124 874 877 513 130 79 630 786 265 150 232 783 449 914 815 557 646 367 733 576 840 683 417 709 569 432 515 702 811 877 286", "102 99\n73 348 420 956 955 436 69 714 87 480 102 555 933 215 452 167 157 593 863 816 337 471 371 574 862 967 581 543 330 348 221 640 378 250 500 428 866 379 1 723 880 992 9 419 0 163 800 96 16 25 19 513 653 19 924 144 135 950 449 481 255 582 844 473 189 841 862 520 242 210 573 381 130 820 357 911 884 735 460 428 764 187 344 760 413 636 868 780 123 614 822 869 792 66 636 843 465 449 191 891 819 30", "103 26\n33 455 273 884 569 636 360 69 802 310 405 594 693 339 43 53 692 514 590 835 1000 191 456 582 641 35 731 207 600 830 416 483 431 377 481 910 367 597 58 413 128 873 42 173 104 553 26 383 673 849 728 503 924 819 108 422 169 454 333 134 926 247 464 289 115 547 567 663 123 396 21 890 385 436 584 432 829 683 345 706 294 901 238 606 12 24 89 882 203 962 804 745 166 425 393 252 415 195 571 596 41 486 445", "104 54\n683 252 125 813 874 835 651 424 826 139 397 323 143 153 326 941 536 435 317 854 353 222 851 591 420 415 190 872 178 311 612 635 174 505 153 81 559 815 805 414 378 62 75 929 208 942 254 670 329 671 127 494 504 618 292 699 203 959 218 788 285 602 83 104 41 562 272 806 4 582 780 87 639 743 811 263 83 632 230 984 826 304 133 142 612 413 310 985 594 309 787 930 541 92 461 663 675 942 952 610 574 633 758 999"], "outputs": ["2.000000000", "1.909090909", "45.415178571", "594.109756098", "784.000000000", "597.255813953", "406.839285714", "467.586301370", "413.249554367", "361.924390244", "523.427098675", "179.075000000", "343.047284817", "68.702920443", "419.922659430", "399.430903462"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 47 | codeforces |
|
573dc1b93b6aae1166255b4af7c1e03a | k-Multiple Free Set | A *k*-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by *k*. That is, there are no two integers *x* and *y* (*x*<=<<=*y*) from the set, such that *y*<==<=*x*Β·*k*.
You're given a set of *n* distinct positive integers. Your task is to find the size of it's largest *k*-multiple free subset.
The first line of the input contains two integers *n* and *k* (1<=β€<=*n*<=β€<=105,<=1<=β€<=*k*<=β€<=109). The next line contains a list of *n* distinct positive integers *a*1,<=*a*2,<=...,<=*a**n* (1<=β€<=*a**i*<=β€<=109).
All the numbers in the lines are separated by single spaces.
On the only line of the output print the size of the largest *k*-multiple free subset of {*a*1,<=*a*2,<=...,<=*a**n*}.
Sample Input
6 2
2 3 6 5 4 10
Sample Output
3
| {"inputs": ["6 2\n2 3 6 5 4 10", "10 2\n1 2 3 4 5 6 7 8 9 10", "1 1\n1", "100 2\n191 17 61 40 77 95 128 88 26 69 79 10 131 106 142 152 68 39 182 53 83 81 6 89 65 148 33 22 5 47 107 121 52 163 150 158 189 118 75 180 177 176 112 167 140 184 29 166 25 46 169 145 187 123 196 18 115 126 155 100 63 58 159 19 173 113 133 60 130 161 76 157 93 199 50 97 15 67 109 164 99 149 3 137 153 136 56 43 103 170 13 183 194 72 9 181 86 30 91 36", "100 3\n13 38 137 24 46 192 33 8 170 141 118 57 198 133 112 176 40 36 91 130 166 72 123 28 82 180 134 52 64 107 97 79 199 184 158 22 181 163 98 7 88 41 73 87 167 109 15 173 153 70 50 119 139 56 17 152 84 161 11 116 31 187 143 196 27 102 132 126 149 63 146 168 67 48 53 120 20 105 155 10 128 47 23 6 94 3 113 65 44 179 189 99 75 34 111 193 60 145 171 77", "12 400000000\n1 400000000 800000000 2 3 4 5 6 7 8 9 10", "3 1\n1 2 3", "1 1\n1000000000", "10 1\n1 100 300 400 500 500000 1000000 10000000 100000000 1000000000", "2 1\n2 1", "2 1000000000\n1 1000000000", "4 1000\n1 1000 1000000 1000000000", "2 2\n1 3", "2 2\n16 8", "3 2\n8 4 2", "5 1\n1 2 3 4 5", "2 2\n500000000 1000000000", "2 2\n4 2", "10 100000000\n1 2 3 4 5 6 7 8 82000 907431936", "8 65538\n65535 65536 65537 65538 65539 131072 262144 196608", "5 2\n10 8 6 4 2", "2 1000000000\n276447232 100000"], "outputs": ["3", "6", "1", "79", "87", "10", "3", "1", "10", "2", "1", "2", "2", "1", "2", "5", "1", "1", "10", "8", "4", "2"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 77 | codeforces |
|
5798885d5811c8fe3f4c55cfa0dcc0b7 | Cave Painting | Imp is watching a documentary about cave painting.
Some numbers, carved in chaotic order, immediately attracted his attention. Imp rapidly proposed a guess that they are the remainders of division of a number *n* by all integers *i* from 1 to *k*. Unfortunately, there are too many integers to analyze for Imp.
Imp wants you to check whether all these remainders are distinct. Formally, he wants to check, if all , 1<=β€<=*i*<=β€<=*k*, are distinct, i.Β e. there is no such pair (*i*,<=*j*) that:
- 1<=β€<=*i*<=<<=*j*<=β€<=*k*, - , where is the remainder of division *x* by *y*.
The only line contains two integers *n*, *k* (1<=β€<=*n*,<=*k*<=β€<=1018).
Print "Yes", if all the remainders are distinct, and "No" otherwise.
You can print each letter in arbitrary case (lower or upper).
Sample Input
4 4
5 3
Sample Output
No
Yes
| {"inputs": ["4 4", "5 3", "1 1", "744 18", "47879 10", "1000000000000000000 1000000000000000000", "657180569218773599 42", "442762254977842799 30", "474158606260730555 1", "807873101233533988 39", "423 7", "264306177888923090 5", "998857801526481788 87", "999684044704565212 28", "319575605003866172 71", "755804560577415016 17", "72712630136142067 356370939", "807264258068668062 33080422", "808090496951784190 311661970", "808916740129867614 180178111", "1 2", "2 1", "57334064998850639 19", "144353716412182199 11", "411002215096001759 11", "347116374613371527 3", "518264351335130399 37", "192435891235905239 11", "491802505049361659 7", "310113769227703889 3", "876240758958364799 41", "173284263472319999 33", "334366426725130799 29", "415543470272330399 26", "631689521541558479 22", "581859366558790319 14", "224113913709159599 10", "740368848764104559 21", "895803074828822159 17", "400349974997012039 13", "205439024252247599 5", "197688463911338399 39", "283175367224349599 39", "893208176423362799 31", "440681012669897999 27", "947403664618451039 19", "232435556779345919 19", "504428493840551279 23", "30019549241681999 20", "648000813924303839 16", "763169499725761451 488954176053755860", "199398459594277592 452260924647536414", "635627415167826436 192195636386541160", "71856370741375281 155502380685354417", "731457367464667229 118809129279134971", "167686318743248777 858743836723172421", "603915274316797622 822050585316952974", "647896534275160623 65689274138731296", "648722777453244047 501918229712280140", "649549020631327471 41923378183538525", "650375259514443599 597748177714153637", "651201506987494319 33977137582669778", "652027745870610447 470206093156218622", "652853989048693871 906435048729767466", "653680227931809999 342664004303316311", "654506475404860719 375019787446735639", "655332714287976847 438493956600157103", "166512305365727033 900267947832156186", "167338548543810457 336496907700672326", "168164787426926585 772725863274221171", "523 3", "39211 6", "22151 9", "1 3", "47 5", "999999998999999999 1000000000", "11 6", "7 4", "1 10", "9 5", "2519 20", "700001 3", "13 7", "999999 10000", "1 4", "232792559 30", "1 5", "5 4", "5 8", "55 4"], "outputs": ["No", "Yes", "Yes", "No", "Yes", "No", "Yes", "Yes", "Yes", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "Yes", "No", "No", "No", "No", "No", "No", "No", "No"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 29 | codeforces |
|
57afa8f407534eefb24cd9f1ed75cce9 | none | While Duff was resting in the beach, she accidentally found a strange array *b*0,<=*b*1,<=...,<=*b**l*<=-<=1 consisting of *l* positive integers. This array was strange because it was extremely long, but there was another (maybe shorter) array, *a*0,<=...,<=*a**n*<=-<=1 that *b* can be build from *a* with formula: *b**i*<==<=*a**i* *mod* *n* where *a* *mod* *b* denoted the remainder of dividing *a* by *b*.
Duff is so curious, she wants to know the number of subsequences of *b* like *b**i*1,<=*b**i*2,<=...,<=*b**i**x* (0<=β€<=*i*1<=<<=*i*2<=<<=...<=<<=*i**x*<=<<=*l*), such that:
- 1<=β€<=*x*<=β€<=*k* - For each 1<=β€<=*j*<=β€<=*x*<=-<=1, - For each 1<=β€<=*j*<=β€<=*x*<=-<=1, *b**i**j*<=β€<=*b**i**j*<=+<=1. i.e this subsequence is non-decreasing.
Since this number can be very large, she want to know it modulo 109<=+<=7.
Duff is not a programmer, and Malek is unavailable at the moment. So she asked for your help. Please tell her this number.
The first line of input contains three integers, *n*,<=*l* and *k* (1<=β€<=*n*,<=*k*, *n*<=Γ<=*k*<=β€<=106 and 1<=β€<=*l*<=β€<=1018).
The second line contains *n* space separated integers, *a*0,<=*a*1,<=...,<=*a**n*<=-<=1 (1<=β€<=*a**i*<=β€<=109 for each 0<=β€<=*i*<=β€<=*n*<=-<=1).
Print the answer modulo 1<=000<=000<=007 in one line.
Sample Input
3 5 3
5 9 1
5 10 3
1 2 3 4 5
Sample Output
10
25
| {"inputs": ["3 5 3\n5 9 1", "5 10 3\n1 2 3 4 5", "1 1000000000000000000 1\n508953607", "13 1984343432234 32\n347580985 506695806 506695806 42598441 347580985 720568974 208035957 385072757 42598441 506695806 42598441 42598441 506695806", "1 75937459749 1000000\n521563672", "1 1 1000000\n496389707", "10 823749283742342340 100000\n613388720 92441578 429122758 800184178 7831199 296755757 143926380 532259266 666463501 582255174", "10 8937248923748923 100000\n697241802 157690363 87519001 44105829 526518823 565974315 157690363 157690363 87519001 432857075", "9 893274793247 100000\n80508704 493552693 379373165 493552693 571722315 493552693 936471477 80508704 956107679", "9 4070991807 100000\n268727819 812713870 268727819 268727819 258038451 268727819 258038451 258038451 268727819", "1 1000000000000000000 1000000\n332310729", "1 1 1\n95524514", "2 5 2\n1 1"], "outputs": ["10", "25", "49", "746224565", "217941287", "1", "173780079", "858348724", "331933333", "349189014", "49503500", "1", "11"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces |
|
57b85f4fcba005a67ee75fe25e8a7e4b | Array and Operations | You have written on a piece of paper an array of *n* positive integers *a*[1],<=*a*[2],<=...,<=*a*[*n*] and *m* good pairs of integers (*i*1,<=*j*1),<=(*i*2,<=*j*2),<=...,<=(*i**m*,<=*j**m*). Each good pair (*i**k*,<=*j**k*) meets the following conditions: *i**k*<=+<=*j**k* is an odd number and 1<=β€<=*i**k*<=<<=*j**k*<=β€<=*n*.
In one operation you can perform a sequence of actions:
- take one of the good pairs (*i**k*,<=*j**k*) and some integer *v* (*v*<=><=1), which divides both numbers *a*[*i**k*] and *a*[*j**k*]; - divide both numbers by *v*, i. e. perform the assignments: and .
Determine the maximum number of operations you can sequentially perform on the given array. Note that one pair may be used several times in the described operations.
The first line contains two space-separated integers *n*, *m* (2<=β€<=*n*<=β€<=100, 1<=β€<=*m*<=β€<=100).
The second line contains *n* space-separated integers *a*[1],<=*a*[2],<=...,<=*a*[*n*] (1<=β€<=*a*[*i*]<=β€<=109) β the description of the array.
The following *m* lines contain the description of good pairs. The *k*-th line contains two space-separated integers *i**k*, *j**k* (1<=β€<=*i**k*<=<<=*j**k*<=β€<=*n*, *i**k*<=+<=*j**k* is an odd number).
It is guaranteed that all the good pairs are distinct.
Output the answer for the problem.
Sample Input
3 2
8 3 8
1 2
2 3
3 2
8 12 8
1 2
2 3
Sample Output
0
2
| {"inputs": ["3 2\n8 3 8\n1 2\n2 3", "3 2\n8 12 8\n1 2\n2 3", "6 4\n35 33 46 58 7 61\n4 5\n3 6\n5 6\n1 6", "10 25\n262144 262144 64 64 16 134217728 32 512 32 8192\n1 2\n3 10\n5 8\n9 10\n2 5\n5 10\n3 6\n3 8\n2 9\n4 5\n8 9\n1 4\n4 9\n3 4\n1 6\n4 7\n7 8\n5 6\n2 3\n1 10\n1 8\n6 9\n6 7\n2 7\n7 10", "10 9\n67108864 8 2 131072 268435456 256 16384 128 8 128\n4 9\n5 10\n6 9\n9 10\n1 4\n3 8\n8 9\n1 2\n4 5", "20 10\n512 64 536870912 256 1 262144 8 2097152 8192 524288 32 2 16 16777216 524288 64 268435456 256 67108864 131072\n17 20\n2 13\n11 12\n18 19\n4 7\n4 13\n8 9\n14 17\n8 19\n7 10", "20 19\n512 524288 268435456 2048 16384 8192 524288 16777216 128 536870912 256 1 32768 2097152 131072 268435456 262144 134217728 8388608 16\n3 20\n5 12\n19 20\n10 15\n3 18\n3 4\n6 19\n3 14\n3 16\n5 10\n3 12\n5 20\n12 17\n6 9\n13 18\n2 11\n7 12\n6 11\n2 15", "20 19\n4 65536 2097152 512 16777216 262144 4096 4096 64 32 268435456 2 2048 128 512 1048576 524288 1024 512 536870912\n10 15\n16 17\n15 18\n19 20\n9 12\n2 9\n12 19\n8 19\n2 11\n4 17\n2 5\n7 18\n7 10\n17 20\n9 10\n4 15\n10 19\n5 18\n1 16", "22 2\n2097152 2048 1024 134217728 536870912 2097152 32768 2 16777216 67108864 4194304 4194304 512 16 1048576 8 16384 131072 8388608 8192 2097152 4\n9 10\n14 21", "10 25\n2048 536870912 64 65536 524288 2048 4194304 131072 8 128\n7 10\n3 6\n8 9\n9 10\n1 2\n1 8\n2 9\n2 3\n4 7\n5 6\n5 8\n6 9\n1 4\n3 10\n4 5\n3 8\n5 10\n6 7\n2 7\n1 10\n4 9\n1 6\n3 4\n2 5\n7 8", "2 1\n1020407 1020407\n1 2", "8 6\n1020407 1020407 1020407 1020407 1020407 1020407 1020407 1020407\n1 2\n1 4\n2 3\n5 6\n6 7\n7 8", "2 1\n9999991 9999991\n1 2", "2 1\n19961993 19961993\n1 2", "5 3\n1 2 2 2 2\n2 3\n3 4\n2 5", "2 1\n10 10\n1 2", "5 3\n1 1000003 1000003 1000003 1000003\n2 3\n3 4\n2 5", "6 3\n12 7 8 12 7 8\n1 4\n1 6\n3 4", "4 3\n2 2 2 2\n1 2\n1 4\n2 3", "6 3\n12 3 4 12 8 8\n1 4\n4 5\n1 6"], "outputs": ["0", "2", "0", "38", "31", "65", "99", "71", "28", "61", "1", "4", "1", "1", "2", "2", "2", "5", "2", "5"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces |
|
57b85f9568ee496d7d360784500df856 | Strip | Alexandra has a paper strip with *n* numbers on it. Let's call them *a**i* from left to right.
Now Alexandra wants to split it into some pieces (possibly 1). For each piece of strip, it must satisfy:
- Each piece should contain at least *l* numbers.- The difference between the maximal and the minimal number on the piece should be at most *s*.
Please help Alexandra to find the minimal number of pieces meeting the condition above.
The first line contains three space-separated integers *n*,<=*s*,<=*l* (1<=β€<=*n*<=β€<=105,<=0<=β€<=*s*<=β€<=109,<=1<=β€<=*l*<=β€<=105).
The second line contains *n* integers *a**i* separated by spaces (<=-<=109<=β€<=*a**i*<=β€<=109).
Output the minimal number of strip pieces.
If there are no ways to split the strip, output -1.
Sample Input
7 2 2
1 3 1 2 4 1 2
7 2 2
1 100 1 100 1 100 1
Sample Output
3
-1
| {"inputs": ["7 2 2\n1 3 1 2 4 1 2", "7 2 2\n1 100 1 100 1 100 1", "1 0 1\n0", "6 565 2\n31 76 162 -182 -251 214", "1 0 1\n0", "1 0 1\n-1000000000", "1 100 2\n42", "2 1000000000 1\n-1000000000 1000000000", "2 1000000000 2\n-1000000000 1000000000", "10 3 3\n1 1 1 1 1 5 6 7 8 9", "10 3 3\n1 1 1 2 2 5 6 7 8 9"], "outputs": ["3", "-1", "1", "1", "1", "1", "-1", "2", "-1", "-1", "3"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces |
|
57d971eb6fe7181e2ba33519339db54d | Exams | One day the Codeforces round author sat exams. He had *n* exams and he needed to get an integer from 2 to 5 for each exam. He will have to re-sit each failed exam, i.e. the exam that gets mark 2.
The author would need to spend too much time and effort to make the sum of his marks strictly more than *k*. That could have spoilt the Codeforces round. On the other hand, if the sum of his marks is strictly less than *k*, the author's mum won't be pleased at all.
The Codeforces authors are very smart and they always get the mark they choose themselves. Also, the Codeforces authors just hate re-sitting exams.
Help the author and find the minimum number of exams he will have to re-sit if he passes the exams in the way that makes the sum of marks for all *n* exams equal exactly *k*.
The single input line contains space-separated integers *n* and *k* (1<=β€<=*n*<=β€<=50, 1<=β€<=*k*<=β€<=250) β the number of exams and the required sum of marks.
It is guaranteed that there exists a way to pass *n* exams in the way that makes the sum of marks equal exactly *k*.
Print the single number β the minimum number of exams that the author will get a 2 for, considering that the sum of marks for all exams must equal *k*.
Sample Input
4 8
4 10
1 3
Sample Output
4
2
0
| {"inputs": ["4 8", "4 10", "1 3", "1 2", "4 9", "50 234", "50 100", "50 250", "29 116", "20 69", "46 127", "3 7", "36 99", "45 104", "13 57", "25 106", "8 19", "20 69", "13 32", "47 128", "17 73", "3 7", "16 70", "1 5", "38 137", "7 20", "1 5", "36 155", "5 15", "27 75", "21 73", "2 5", "49 177", "7 20", "44 173", "49 219", "16 70", "10 28"], "outputs": ["4", "2", "0", "1", "3", "0", "50", "0", "0", "0", "11", "2", "9", "31", "0", "0", "5", "0", "7", "13", "0", "2", "0", "0", "0", "1", "0", "0", "0", "6", "0", "1", "0", "1", "0", "0", "0", "2"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 261 | codeforces |
|
57d99909d9c306e4442f6732b3ca3243 | Little Elephant and Cards | The Little Elephant loves to play with color cards.
He has *n* cards, each has exactly two colors (the color of the front side and the color of the back side). Initially, all the cards lay on the table with the front side up. In one move the Little Elephant can turn any card to the other side. The Little Elephant thinks that a set of cards on the table is funny if at least half of the cards have the same color (for each card the color of the upper side is considered).
Help the Little Elephant to find the minimum number of moves needed to make the set of *n* cards funny.
The first line contains a single integer *n* (1<=β€<=*n*<=β€<=105) β the number of the cards. The following *n* lines contain the description of all cards, one card per line. The cards are described by a pair of positive integers not exceeding 109 β colors of both sides. The first number in a line is the color of the front of the card, the second one β of the back. The color of the front of the card may coincide with the color of the back of the card.
The numbers in the lines are separated by single spaces.
On a single line print a single integer β the sought minimum number of moves. If it is impossible to make the set funny, print -1.
Sample Input
3
4 7
4 7
7 4
5
4 7
7 4
2 11
9 7
1 1
Sample Output
0
2
| {"inputs": ["3\n4 7\n4 7\n7 4", "5\n4 7\n7 4\n2 11\n9 7\n1 1", "1\n1 1", "2\n1 1\n1 1", "7\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8", "2\n1 2\n2 1", "3\n7 7\n1 2\n2 1", "3\n1 1\n2 5\n3 6", "4\n1000000000 1000000000\n999999999 1000000000\n999999997 999999998\n47 74", "6\n1 2\n3 1\n4 7\n4 1\n9 1\n7 2", "4\n1 2\n1 2\n2 1\n2 1", "7\n4 7\n7 4\n4 7\n1 1\n2 2\n3 3\n4 4", "10\n1000000000 999999999\n47 74\n47474 75785445\n8798878 458445\n1 2\n888888888 777777777\n99999999 1000000000\n9999999 1000000000\n999999 1000000000\n99999 1000000000", "10\n9 1000000000\n47 74\n47474 75785445\n8798878 458445\n1 2\n888888888 777777777\n99999999 1000000000\n9999999 1000000000\n999999 1000000000\n99999 1000000000", "10\n1 10\n1 10\n1 1\n7 8\n6 7\n9 5\n4 1\n2 3\n3 10\n2 8", "10\n262253762 715261903\n414831157 8354405\n419984358 829693421\n376600467 175941985\n367533995 350629286\n681027822 408529849\n654503328 717740407\n539773033 704670473\n55322828 380422378\n46174018 186723478", "10\n2 2\n1 1\n1 1\n1 2\n1 2\n2 2\n2 1\n1 1\n1 2\n1 1", "12\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1", "47\n53 63\n43 57\n69 52\n66 47\n74 5\n5 2\n6 56\n19 27\n46 27\n31 45\n41 38\n20 20\n69 43\n17 74\n39 43\n28 70\n73 24\n73 59\n23 11\n56 49\n51 37\n70 16\n66 36\n4 7\n1 49\n7 65\n38 5\n47 74\n34 38\n17 22\n59 3\n70 40\n21 15\n10 5\n17 30\n9 12\n28 48\n70 42\n39 70\n18 53\n71 49\n66 25\n37 51\n10 62\n55 7\n18 53\n40 50", "100\n1 2\n2 1\n2 1\n1 2\n1 1\n1 2\n2 1\n1 1\n2 2\n2 1\n2 1\n1 1\n1 1\n2 1\n2 1\n2 1\n2 1\n2 1\n1 1\n2 1\n1 1\n1 1\n2 2\n1 2\n1 2\n1 2\n2 2\n1 2\n1 2\n2 1\n1 2\n2 1\n1 2\n2 2\n1 1\n2 1\n1 2\n2 1\n2 1\n1 2\n2 1\n2 1\n1 2\n2 1\n1 1\n1 2\n1 1\n1 1\n2 2\n2 2\n2 1\n2 1\n1 2\n2 2\n1 1\n2 1\n2 2\n1 1\n1 1\n1 2\n2 2\n2 1\n2 1\n2 2\n1 1\n1 1\n2 1\n2 1\n2 1\n2 2\n2 2\n2 1\n1 1\n1 2\n2 1\n2 2\n2 1\n1 1\n2 1\n2 1\n1 1\n1 2\n1 2\n2 1\n2 1\n2 1\n2 2\n1 2\n1 2\n2 1\n1 1\n1 1\n1 2\n2 1\n1 2\n2 2\n1 2\n2 1\n2 2\n2 1", "7\n1 1\n1 1\n1 1\n2 3\n4 5\n6 7\n8 9", "1\n1 2", "7\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999", "2\n1 2\n2 3", "2\n47 74\n47 85874", "5\n5 8\n9 10\n5 17\n5 24\n1 147", "5\n1 7\n2 7\n3 7\n4 7\n5 7", "5\n1 10\n2 10\n3 10\n4 10\n5 10", "3\n2 1\n3 1\n4 1", "5\n1 2\n1 3\n4 1\n5 1\n6 7", "5\n4 7\n4 7\n2 7\n9 7\n1 1", "8\n1 2\n2 1\n2 1\n3 1\n4 2\n5 2\n6 2\n7 2", "3\n98751 197502\n296253 395004\n493755 592506", "5\n1 5\n2 5\n3 5\n4 7\n2 5", "10\n1 10\n2 10\n3 10\n4 10\n5 10\n10 1\n10 2\n10 3\n10 4\n10 5", "7\n1 2\n1 2\n1 2\n3 1\n3 1\n3 1\n2 1", "5\n1 6\n2 6\n3 6\n4 6\n5 6", "5\n1 6\n2 6\n3 6\n4 4\n5 5", "5\n1 1\n1 1\n2 2\n2 2\n3 3", "4\n1 5\n2 5\n3 5\n4 4"], "outputs": ["0", "2", "0", "0", "-1", "0", "1", "-1", "1", "2", "0", "1", "4", "5", "-1", "-1", "0", "0", "-1", "0", "-1", "0", "0", "0", "0", "0", "3", "3", "2", "1", "3", "2", "-1", "3", "0", "1", "3", "3", "-1", "2"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 12 | codeforces |
|
57e7e421e1a36b78c8e4fde63ced274c | Anatoly and Cockroaches | Anatoly lives in the university dorm as many other students do. As you know, cockroaches are also living there together with students. Cockroaches might be of two colors: black and red. There are *n* cockroaches living in Anatoly's room.
Anatoly just made all his cockroaches to form a single line. As he is a perfectionist, he would like the colors of cockroaches in the line to alternate. He has a can of black paint and a can of red paint. In one turn he can either swap any two cockroaches, or take any single cockroach and change it's color.
Help Anatoly find out the minimum number of turns he needs to make the colors of cockroaches in the line alternate.
The first line of the input contains a single integer *n* (1<=β€<=*n*<=β€<=100<=000)Β β the number of cockroaches.
The second line contains a string of length *n*, consisting of characters 'b' and 'r' that denote black cockroach and red cockroach respectively.
Print one integerΒ β the minimum number of moves Anatoly has to perform in order to make the colors of cockroaches in the line to alternate.
Sample Input
5
rbbrr
5
bbbbb
3
rbr
Sample Output
1
2
0
| {"inputs": ["5\nrbbrr", "5\nbbbbb", "3\nrbr", "13\nrbbbrbrrbrrbb", "18\nrrrrrrrrrrrrrrrrrb", "100\nbrbbbrrrbbrbrbbrbbrbbbbrbbrrbbbrrbbbbrbrbbbbbbbbbbbbbbbbrrrrbbbbrrrbbbbbbbrbrrbrbbbbrrrbbbbrbbrbbbrb", "166\nrbbbbbbbbbbbbrbrrbbrbbbrbbbbbbbbbbrbbbbbbrbbbrbbbbbrbbbbbbbrbbbbbbbrbbrbbbbbbbbrbbbbbbbbbbbbbbrrbbbrbbbbbbbbbbbbbbrbrbbbbbbbbbbbrbbbbbbbbbbbbbbrbbbbbbbbbbbbbbbbbbbbbb", "1\nr", "1\nb", "2\nrb", "2\nbr", "2\nrr", "2\nbb", "8\nrbbrbrbr", "7\nrrbrbrb"], "outputs": ["1", "2", "0", "3", "8", "34", "70", "0", "0", "0", "0", "1", "1", "1", "1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 110 | codeforces |
|
57ee5e055f24eba95c780683a584296b | ZS and The Birthday Paradox | ZS the Coder has recently found an interesting concept called the Birthday Paradox. It states that given a random set of 23 people, there is around 50% chance that some two of them share the same birthday. ZS the Coder finds this very interesting, and decides to test this with the inhabitants of Udayland.
In Udayland, there are 2*n* days in a year. ZS the Coder wants to interview *k* people from Udayland, each of them has birthday in one of 2*n* days (each day with equal probability). He is interested in the probability of at least two of them have the birthday at the same day.
ZS the Coder knows that the answer can be written as an irreducible fraction . He wants to find the values of *A* and *B* (he does not like to deal with floating point numbers). Can you help him?
The first and only line of the input contains two integers *n* and *k* (1<=β€<=*n*<=β€<=1018,<=2<=β€<=*k*<=β€<=1018), meaning that there are 2*n* days in a year and that ZS the Coder wants to interview exactly *k* people.
If the probability of at least two *k* people having the same birthday in 2*n* days long year equals (*A*<=β₯<=0, *B*<=β₯<=1, ), print the *A* and *B* in a single line.
Since these numbers may be too large, print them modulo 106<=+<=3. Note that *A* and *B* must be coprime before their remainders modulo 106<=+<=3 are taken.
Sample Input
3 2
1 3
4 3
Sample Output
1 81 123 128 | {"inputs": ["3 2", "1 3", "4 3", "1000000000000000000 1000000000000000000", "59 576460752303423489", "1234567891234 100005", "2 4", "59 576460752303423488", "2016 2016", "2016 2017", "468804735183774830 244864585447548924", "172714899512474455 414514930706102803", "876625063841174080 360793239109880865", "70181875975239647 504898544415017211", "364505998666117889 208660487087853057", "648371335753080490 787441", "841928147887146057 620004", "545838312215845682 715670", "473120513399321115 489435", "17922687587622540 3728", "211479504016655403 861717213151744108", "718716873663426516 872259572564867078", "422627037992126141 41909917823420958", "616183854421159004 962643186273781485", "160986032904427725 153429", "88268234087903158 290389", "58453009367192916 164246", "565690379013964030 914981", "269600543342663655 10645", "37774758680708184 156713778825283978", "231331570814773750 77447051570611803", "935241735143473375 247097392534198386", "639151895177205704 416747737792752265", "412663884364501543 401745061547424998", "180838095407578776 715935", "884748259736278401 407112", "78305076165311264 280970", "782215240494010889 417929", "486125404822710514 109107", "57626821183859235 372443612949184377", "27811605053083586 516548918254320722", "955093801941591723 462827230953066080", "659003966270291348 426245", "852560778404356914 258808", "397362961182592931 814397", "904600330829364045 969618", "98157142963429612 169605644318211774", "802067302997161941 115883952721989836", "505977467325861565 285534302275511011", "274151686958873391 747281437213482980", "467708499092938957 59762", "751573831884934263 851791", "455483991918666592 947456", "649040812642666750 821314", "417215023685743983 376900", "121125188014443608 400338158982406735", "314682004443476471 544443468582510377", "821919374090247584 554985827995633347", "525829538418947209 501264136399411409", "426597183791521709 928925", "620154000220554572 802783", "324064160254286900 898448", "831301534196025310 690475", "24858346330090877 523038", "569660524813359598 814752357830129986", "496942725996835031 761030666233908048", "467127505571092085 905135971539044394", "394409702459600222 851414284237789752", "703820075205013062 862025309890418636", "471994290543057591 972026", "665551106972090453 845883", "369461267005822782 537061", "73371431334522407 674020", "266928247763555270 547878", "615057631564895479 807178821338760482", "318967795893595104 976829166597314361", "512524612322627967 897562435047674890", "216434772356360296 67212780306228770", "13491088710006829 715337619732144903", "688519152023104450 70486", "685403173770208801 962607", "389313338098908426 99564", "93223502427608051 790744", "286780314561673617 664601", "831582488749975043 182016637013124494", "758864689933450475 128294949711869852", "532376674825779019 113292273466542585", "236286839154478644 282942618725096464", "940197003483178269 77403", "708371214526255502 632992", "901928035250255660 465555", "605838195283987989 198026", "15266076338626979 913942576088954168", "83260344505016157 935999340494020219", "851434559843060686 397746475431992189", "555344724171760311 567396824985513364", "748901536305825878 347728", "452811696339558207 443394", "960049070281296616 235421", "728223285619341145 791009", "698408060898630904 50803201495883240", "625690262082106337 220453546754437119", "329600422115838666 166731855158215181", "523157242839838824 310837164758318823", "871286622346211738 836848346410668404", "575196786674911363 36374", "768753603103944226 868940", "472663767432643850 601411", "176573931761343475 697077", "301399940652446487 937011639371661304", "494956757081479349 760223", "198866921410178974 492694", "902777085738878599 348432", "96333897872944166 462217", "864508113210988695 17803", "371745482857759808 590068361140585059", "341930258137049567 734173670740688701", "269212459320525000 680451979144466763", "973122623649224625 850102328697987938", "517924802132493346 67413", "711481618561526208 858685", "218718983913330026 55198", "922629148242029651 787671", "116185964671062513 620234", "884360180009107043 795255840146329784", "588270344337806667 964906185404883662", "781827160766839530 885639453855244191", "91237529217285074 672878442653097259", "859411744555329603 932262", "563321908884029228 664734", "756878725313062090 497297", "460788885346794419 634257", "164699049675494044 325434", "500001 1000002", "1000003 1000002", "1000002 1000003", "1000002 1000003", "1000002 1000002", "500001 1000003"], "outputs": ["1 8", "1 1", "23 128", "906300 906300", "1 1", "173817 722464", "29 32", "840218 840218", "1564 227035", "360153 815112", "365451 365451", "626500 626500", "34117 34117", "79176 79176", "83777 83777", "228932 228932", "151333 51640", "156176 156176", "57896 535051", "478998 792943", "196797 196797", "401470 401470", "268735 268735", "149006 149006", "100374 100374", "566668 88331", "317900 341568", "547343 547343", "913809 282202", "73122 73122", "578654 578654", "181888 181888", "135045 135045", "228503 228503", "378695 378695", "25714 811489", "293282 624669", "665887 270857", "832669 164722", "802451 802451", "894732 894732", "999170 999170", "795318 278062", "775128 775128", "155345 155345", "245893 245893", "409023 409023", "928705 928705", "782797 782797", "977029 977029", "283212 204310", "905743 905743", "570626 570626", "57323 57323", "122689 122689", "199488 199488", "279665 279665", "854880 854880", "715564 715564", "835709 835709", "163153 163153", "18338 18338", "964028 964028", "5846 5846", "780635 780635", "746587 746587", "608084 608084", "419420 419420", "982260 982260", "215668 215668", "623684 623684", "97003 97003", "899111 372106", "817352 54712", "52078 52078", "750015 750015", "614855 614855", "995572 995572", "719453 719453", "476402 371144", "135409 135409", "205907 386429", "983387 983387", "654850 654850", "159828 159828", "37325 37325", "36122 36122", "187677 187677", "119089 181418", "615316 615316", "586380 781987", "929969 156402", "506165 506165", "138293 138293", "314138 314138", "666610 666610", "80599 80599", "474530 348263", "274784 325200", "764528 274644", "750308 750308", "741435 741435", "242921 242921", "726051 726051", "530710 530710", "88076 806040", "118118 118118", "203104 203104", "389281 749563", "165989 165989", "586955 423513", "847137 847137", "396798 564327", "367832 367832", "107443 838933", "748215 748215", "21530 21530", "868951 868951", "781676 781676", "954073 995488", "929035 929035", "99469 89622", "164442 164442", "798435 622171", "541758 541758", "544853 544853", "627074 627074", "988072 988072", "859175 859175", "883734 883734", "641345 641345", "660266 660266", "170498 994561", "998979 999491", "256 256", "256 256", "256 256", "512 512", "256 256"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces |
|
57f6b670c52d8702a7686ef2568dbfed | The Monster | A monster is chasing after Rick and Morty on another planet. They're so frightened that sometimes they scream. More accurately, Rick screams at times *b*,<=*b*<=+<=*a*,<=*b*<=+<=2*a*,<=*b*<=+<=3*a*,<=... and Morty screams at times *d*,<=*d*<=+<=*c*,<=*d*<=+<=2*c*,<=*d*<=+<=3*c*,<=....
The Monster will catch them if at any point they scream at the same time, so it wants to know when it will catch them (the first time they scream at the same time) or that they will never scream at the same time.
The first line of input contains two integers *a* and *b* (1<=β€<=*a*,<=*b*<=β€<=100).
The second line contains two integers *c* and *d* (1<=β€<=*c*,<=*d*<=β€<=100).
Print the first time Rick and Morty will scream at the same time, or <=-<=1 if they will never scream at the same time.
Sample Input
20 2
9 19
2 1
16 12
Sample Output
82
-1
| {"inputs": ["20 2\n9 19", "2 1\n16 12", "39 52\n88 78", "59 96\n34 48", "87 37\n91 29", "11 81\n49 7", "39 21\n95 89", "59 70\n48 54", "87 22\n98 32", "15 63\n51 13", "39 7\n97 91", "18 18\n71 71", "46 71\n16 49", "70 11\n74 27", "94 55\n20 96", "18 4\n77 78", "46 44\n23 55", "74 88\n77 37", "94 37\n34 7", "22 81\n80 88", "46 30\n34 62", "40 4\n81 40", "69 48\n39 9", "89 93\n84 87", "17 45\n42 65", "41 85\n95 46", "69 30\n41 16", "93 74\n99 93", "17 19\n44 75", "45 63\n98 53", "69 11\n48 34", "55 94\n3 96", "100 100\n100 100", "1 1\n1 1", "1 1\n1 100", "1 100\n100 1", "98 1\n99 100", "98 1\n99 2", "97 2\n99 100", "3 3\n3 1", "3 2\n7 2", "2 3\n2 5", "2 3\n2 3", "100 3\n100 5", "6 10\n12 14", "4 2\n4 4", "2 3\n2 2", "2 3\n4 99", "1 5\n1 5", "1 100\n3 1", "2 2\n2 1", "2 10\n6 20", "2 2\n2 10", "3 7\n3 6", "1 100\n1 100", "7 25\n39 85", "84 82\n38 6", "7 7\n7 14"], "outputs": ["82", "-1", "1222", "1748", "211", "301", "3414", "1014", "718", "-1", "1255", "1278", "209", "2321", "-1", "1156", "-1", "1346", "789", "-1", "674", "364", "48", "5967", "317", "331", "1410", "-1", "427", "3483", "-1", "204", "100", "1", "100", "101", "9703", "9605", "4852", "-1", "2", "5", "3", "-1", "-1", "-1", "-1", "99", "5", "100", "-1", "20", "10", "-1", "100", "319", "82", "14"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 210 | codeforces |
|
5828394940254fd6efa3a0abedfaa1be | Genetic Engineering | You will receive 3 points for solving this problem.
Manao is designing the genetic code for a new type of algae to efficiently produce fuel. Specifically, Manao is focusing on a stretch of DNA that encodes one protein. The stretch of DNA is represented by a string containing only the characters 'A', 'T', 'G' and 'C'.
Manao has determined that if the stretch of DNA contains a maximal sequence of consecutive identical nucleotides that is of even length, then the protein will be nonfunctional. For example, consider a protein described by DNA string "GTTAAAG". It contains four maximal sequences of consecutive identical nucleotides: "G", "TT", "AAA", and "G". The protein is nonfunctional because sequence "TT" has even length.
Manao is trying to obtain a functional protein from the protein he currently has. Manao can insert additional nucleotides into the DNA stretch. Each additional nucleotide is a character from the set {'A', 'T', 'G', 'C'}. Manao wants to determine the minimum number of insertions necessary to make the DNA encode a functional protein.
The input consists of a single line, containing a string *s* of length *n* (1<=β€<=*n*<=β€<=100). Each character of *s* will be from the set {'A', 'T', 'G', 'C'}.
This problem doesn't have subproblems. You will get 3 points for the correct submission.
The program should print on one line a single integer representing the minimum number of 'A', 'T', 'G', 'C' characters that are required to be inserted into the input string in order to make all runs of identical characters have odd length.
Sample Input
GTTAAAG
AACCAACCAAAAC
Sample Output
1
5
| {"inputs": ["GTTAAAG", "AACCAACCAAAAC", "GTGAATTTCC", "CAGGGGGCCGCCCATGAAAAAAACCCGGCCCCTTGGGAAAACTTGGGTTA", "CCCTTCACCCGGATCCAAATCCCTTAGAAATAATCCCCGACGGCGTTGTATCACCTCTGCACTTGTTAGTAAGGTCAGGCGTCCATTACGGAAGAACGTA", "GCATTACATGGGGGGGTCCTACGAGCCCGGCATCCCGGAAACTAGCCGGTTAATTTGGTTTAAACCCTCCCACCCCGGATTGTAACCCCCCTCATTGGTT", "TTCCCAGAGAAAAAAAGGGGCCCAAATGCCCTAAAAACCCCCTTTGCCCCCCAACCCCTTTTTAAAATAAAAAGGGGCCCATTCCCTTAAAAATTTTTTG", "AGCCGCCCCCCCAAAAAAGGGGGAAAAAAAAAAAAAAAAAAAAACTTTTGGAAACCCCCCCCTTTTTTTTTTTTTTTTTTTTTTTTTGGGGAAGGGGGGG", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAAAAATTTTTTTTTTTTTTTTGGGGGGGGGGGGGGGGGGGGGGGTTTTTTTTTTTTTTGGGGGGGGGGGGGGGGGGGGAAAAATTTT", "AACCGGTTAACCGGTTAACCGGTTAACCGGTTAACCGGTTAACCGGTTAACCGGTTAACCGGTTAACCGGTTAACCGGTTAACCGGTTAACCGGTTCCGG", "A", "TTT", "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG", "G", "T", "C", "AA", "GGG", "AAG"], "outputs": ["1", "5", "2", "7", "19", "17", "10", "7", "1", "5", "50", "0", "0", "0", "0", "0", "0", "1", "0", "1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 42 | codeforces |
|
582ec02a56804cc5560660c3e04cd02a | On Number of Decompositions into Multipliers | You are given an integer *m* as a product of integers *a*1,<=*a*2,<=... *a**n* . Your task is to find the number of distinct decompositions of number *m* into the product of *n* ordered positive integers.
Decomposition into *n* products, given in the input, must also be considered in the answer. As the answer can be very large, print it modulo 1000000007 (109<=+<=7).
The first line contains positive integer *n* (1<=β€<=*n*<=β€<=500). The second line contains space-separated integers *a*1,<=*a*2,<=...,<=*a**n* (1<=β€<=*a**i*<=β€<=109).
In a single line print a single number *k* β the number of distinct decompositions of number *m* into *n* ordered multipliers modulo 1000000007 (109<=+<=7).
Sample Input
1
15
3
1 1 2
2
5 7
Sample Output
1
3
4
| {"inputs": ["1\n15", "3\n1 1 2", "2\n5 7", "2\n5 10", "3\n1 30 1", "2\n1000000000 1000000000", "1\n1", "3\n1 1 1", "2\n1 2", "2\n1 6", "3\n8 10 8", "5\n14 67 15 28 21", "8\n836 13 77 218 743 530 404 741", "10\n6295 3400 4042 2769 3673 264 5932 4977 1776 5637", "23\n77 12 25 7 44 75 80 92 49 77 56 93 59 45 45 39 86 83 99 91 4 70 83", "1\n111546435", "7\n111546435 58642669 600662303 167375713 371700317 33984931 89809099", "19\n371700317 12112039 167375713 7262011 21093827 89809099 600662303 18181979 9363547 30857731 58642669 111546435 645328247 5605027 38706809 14457349 25456133 44227723 33984931", "1\n536870912", "2\n536870912 387420489", "10\n214358881 536870912 815730721 387420489 893871739 244140625 282475249 594823321 148035889 410338673", "5\n387420489 536870912 536870912 536870912 387420489", "5\n387420489 244140625 387420489 387420489 1", "10\n2097152 67108864 65536 262144 262144 131072 8388608 536870912 65536 2097152", "10\n237254761 1 817430153 1 1 1 1 1 90679621 1", "20\n16777216 1048576 524288 8192 8192 524288 2097152 8388608 1048576 67108864 16777216 1048576 4096 8388608 134217728 67108864 1048576 536870912 67108864 67108864", "50\n675 25000 2025 50 450 31250 3750 225 1350 250 72 187500 12000 281250 187500 30000 45000 90000 90 1200 9000 56250 5760 270000 3125 3796875 2250 101250 40 2500 175781250 1250000 45000 2250 3000 31250 46875 135000 421875000 36000 360 140625000 13500 1406250 1125 250 75000 62500 150 6", "2\n999983 999983", "3\n1 1 39989"], "outputs": ["1", "3", "4", "6", "27", "361", "1", "1", "2", "4", "108", "459375", "544714485", "928377494", "247701073", "1", "25706464", "376284721", "1", "570", "547239398", "255309592", "772171400", "176451954", "1000", "985054761", "18983788", "3", "3"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces |
|
58300c1535aca1212396fa7342a89cff | Domino | Valera has got *n* domino pieces in a row. Each piece consists of two halves β the upper one and the lower one. Each of the halves contains a number from 1 to 6. Valera loves even integers very much, so he wants the sum of the numbers on the upper halves and the sum of the numbers on the lower halves to be even.
To do that, Valera can rotate the dominoes by 180 degrees. After the rotation the upper and the lower halves swap places. This action takes one second. Help Valera find out the minimum time he must spend rotating dominoes to make his wish come true.
The first line contains integer *n* (1<=β€<=*n*<=β€<=100), denoting the number of dominoes Valera has. Next *n* lines contain two space-separated integers *x**i*,<=*y**i* (1<=β€<=*x**i*,<=*y**i*<=β€<=6). Number *x**i* is initially written on the upper half of the *i*-th domino, *y**i* is initially written on the lower half.
Print a single number β the minimum required number of seconds. If Valera can't do the task in any time, print <=-<=1.
Sample Input
2
4 2
6 4
1
2 3
3
1 4
2 3
4 4
Sample Output
0
-1
1
| {"inputs": ["2\n4 2\n6 4", "1\n2 3", "3\n1 4\n2 3\n4 4", "5\n5 4\n5 4\n1 5\n5 5\n3 3", "20\n1 3\n5 2\n5 2\n2 6\n2 4\n1 1\n1 3\n1 4\n2 6\n4 2\n5 6\n2 2\n6 2\n4 3\n2 1\n6 2\n6 5\n4 5\n2 4\n1 4", "100\n2 3\n2 4\n3 3\n1 4\n5 2\n5 4\n6 6\n3 4\n1 1\n4 2\n5 1\n5 5\n5 3\n3 6\n4 1\n1 6\n1 1\n3 2\n4 5\n6 1\n6 4\n1 1\n3 4\n3 3\n2 2\n1 1\n4 4\n6 4\n3 2\n5 2\n6 4\n3 2\n3 5\n4 4\n1 4\n5 2\n3 4\n1 4\n2 2\n5 6\n3 5\n6 1\n5 5\n1 6\n6 3\n1 4\n1 5\n5 5\n4 1\n3 2\n4 1\n5 5\n5 5\n1 5\n1 2\n6 4\n1 3\n3 6\n4 3\n3 5\n6 4\n2 6\n5 5\n1 4\n2 2\n2 3\n5 1\n2 5\n1 2\n2 6\n5 5\n4 6\n1 4\n3 6\n2 3\n6 1\n6 5\n3 2\n6 4\n4 5\n4 5\n2 6\n1 3\n6 2\n1 2\n2 3\n4 3\n5 4\n3 4\n1 6\n6 6\n2 4\n4 1\n3 1\n2 6\n5 4\n1 2\n6 5\n3 6\n2 4", "1\n2 4", "1\n1 1", "1\n1 2", "2\n1 1\n3 3", "2\n1 1\n2 2", "2\n1 1\n1 2", "5\n1 2\n6 6\n1 1\n3 3\n6 1", "5\n5 4\n2 6\n6 2\n1 4\n6 2", "10\n4 1\n3 2\n1 2\n2 6\n3 5\n2 1\n5 2\n4 6\n5 6\n3 1", "10\n6 1\n4 4\n2 6\n6 5\n3 6\n6 3\n2 4\n5 1\n1 6\n1 5", "15\n1 2\n5 1\n6 4\n5 1\n1 6\n2 6\n3 1\n6 4\n3 1\n2 1\n6 4\n3 5\n6 2\n1 6\n1 1", "15\n3 3\n2 1\n5 4\n3 3\n5 3\n5 4\n2 5\n1 3\n3 2\n3 3\n3 5\n2 5\n4 1\n2 3\n5 4", "20\n1 5\n6 4\n4 3\n6 2\n1 1\n1 5\n6 3\n2 3\n3 6\n3 6\n3 6\n2 5\n4 3\n4 6\n5 5\n4 6\n3 4\n4 2\n3 3\n5 2", "20\n2 1\n6 5\n3 1\n2 5\n3 5\n4 1\n1 1\n5 4\n5 1\n2 4\n1 5\n3 2\n1 2\n3 5\n5 2\n1 2\n1 3\n4 2\n2 3\n4 5", "25\n4 1\n6 3\n1 3\n2 3\n2 4\n6 6\n4 2\n4 2\n1 5\n5 4\n1 2\n2 5\n3 6\n4 1\n3 4\n2 6\n6 1\n5 6\n6 6\n4 2\n1 5\n3 3\n3 3\n6 5\n1 4", "25\n5 5\n4 3\n2 5\n4 3\n4 6\n4 2\n5 6\n2 1\n5 4\n6 6\n1 3\n1 4\n2 3\n5 6\n5 4\n5 6\n5 4\n6 3\n3 5\n1 3\n2 5\n2 2\n4 4\n2 1\n4 4", "30\n3 5\n2 5\n1 6\n1 6\n2 4\n5 5\n5 4\n5 6\n5 4\n2 1\n2 4\n1 6\n3 5\n1 1\n3 6\n5 5\n1 6\n3 4\n1 4\n4 6\n2 1\n3 3\n1 3\n4 5\n1 4\n1 6\n2 1\n4 6\n3 5\n5 6", "30\n2 3\n3 1\n6 6\n1 3\n5 5\n3 6\n4 5\n2 1\n1 3\n2 3\n4 4\n2 4\n6 4\n2 4\n5 4\n2 1\n2 5\n2 5\n4 2\n1 4\n2 6\n3 2\n3 2\n6 6\n4 2\n3 4\n6 3\n6 6\n6 6\n5 5", "35\n6 1\n4 3\n1 2\n4 3\n6 4\n4 6\n3 1\n5 5\n3 4\n5 4\n4 6\n1 6\n2 4\n6 6\n5 4\n5 2\n1 3\n1 4\n3 5\n1 4\n2 3\n4 5\n4 3\n6 1\n5 3\n3 2\n5 6\n3 5\n6 5\n4 1\n1 3\n5 5\n4 6\n6 1\n1 3", "35\n4 3\n5 6\n4 5\n2 5\n6 6\n4 1\n2 2\n4 2\n3 4\n4 1\n6 6\n6 3\n1 5\n1 5\n5 6\n4 2\n4 6\n5 5\n2 2\n5 2\n1 2\n4 6\n6 6\n6 5\n2 1\n3 5\n2 5\n3 1\n5 3\n6 4\n4 6\n5 6\n5 1\n3 4\n3 5", "40\n5 6\n1 1\n3 3\n2 6\n6 6\n5 4\n6 4\n3 5\n1 3\n4 4\n4 4\n2 5\n1 3\n3 6\n5 2\n4 3\n4 4\n5 6\n2 3\n1 1\n3 1\n1 1\n1 5\n4 3\n5 5\n3 4\n6 6\n5 6\n2 2\n6 6\n2 1\n2 4\n5 2\n2 2\n1 1\n1 4\n4 2\n3 5\n5 5\n4 5", "40\n3 2\n5 3\n4 6\n3 5\n6 1\n5 2\n1 2\n6 2\n5 3\n3 2\n4 4\n3 3\n5 2\n4 5\n1 4\n5 1\n3 3\n1 3\n1 3\n2 1\n3 6\n4 2\n4 6\n6 2\n2 5\n2 2\n2 5\n3 3\n5 3\n2 1\n3 2\n2 3\n6 3\n6 3\n3 4\n3 2\n4 3\n5 4\n2 4\n4 6", "45\n2 4\n3 4\n6 1\n5 5\n1 1\n3 5\n4 3\n5 2\n3 6\n6 1\n4 4\n6 1\n2 1\n6 1\n3 6\n3 3\n6 1\n1 2\n1 5\n6 5\n1 3\n5 6\n6 1\n4 5\n3 6\n2 2\n1 2\n4 5\n5 6\n1 5\n6 2\n2 4\n3 3\n3 1\n6 5\n6 5\n2 1\n5 2\n2 1\n3 3\n2 2\n1 4\n2 2\n3 3\n2 1", "45\n6 6\n1 6\n1 2\n3 5\n4 4\n2 1\n5 3\n2 1\n5 2\n5 3\n1 4\n5 2\n4 2\n3 6\n5 2\n1 5\n4 4\n5 5\n6 5\n2 1\n2 6\n5 5\n2 1\n6 1\n1 6\n6 5\n2 4\n4 3\n2 6\n2 4\n6 5\n6 4\n6 3\n6 6\n2 1\n6 4\n5 6\n5 4\n1 5\n5 1\n3 3\n5 6\n2 5\n4 5\n3 6", "50\n4 4\n5 1\n6 4\n6 2\n6 2\n1 4\n5 5\n4 2\n5 5\n5 4\n1 3\n3 5\n6 1\n6 1\n1 4\n4 3\n5 1\n3 6\n2 2\n6 2\n4 4\n2 3\n4 2\n6 5\n5 6\n2 2\n2 4\n3 5\n1 5\n3 2\n3 4\n5 6\n4 6\n1 6\n4 5\n2 6\n2 2\n3 5\n6 4\n5 1\n4 3\n3 4\n3 5\n3 3\n2 3\n3 2\n2 2\n1 4\n3 1\n4 4", "50\n1 2\n1 4\n1 1\n4 5\n4 4\n3 2\n4 5\n3 5\n1 1\n3 4\n3 2\n2 4\n2 6\n2 6\n3 2\n4 6\n1 6\n3 1\n1 6\n2 1\n4 1\n1 6\n4 3\n6 6\n5 2\n6 4\n2 1\n4 3\n6 4\n5 1\n5 5\n3 1\n1 1\n5 5\n2 2\n2 3\n2 3\n3 5\n5 5\n1 6\n1 5\n3 6\n3 6\n1 1\n3 3\n2 6\n5 5\n1 3\n6 3\n6 6", "55\n3 2\n5 6\n5 1\n3 5\n5 5\n1 5\n5 4\n6 3\n5 6\n4 2\n3 1\n1 2\n5 5\n1 1\n5 2\n6 3\n5 4\n3 6\n4 6\n2 6\n6 4\n1 4\n1 6\n4 1\n2 5\n4 3\n2 1\n2 1\n6 2\n3 1\n2 5\n4 4\n6 3\n2 2\n3 5\n5 1\n3 6\n5 4\n4 6\n6 5\n5 6\n2 2\n3 2\n5 2\n6 5\n2 2\n5 3\n3 1\n4 5\n6 4\n2 4\n1 2\n5 6\n2 6\n5 2", "55\n4 6\n3 3\n6 5\n5 3\n5 6\n2 3\n2 2\n3 4\n3 1\n5 4\n5 4\n2 4\n3 4\n4 5\n1 5\n6 3\n1 1\n5 1\n3 4\n1 5\n3 1\n2 5\n3 3\n4 3\n3 3\n3 1\n6 6\n3 3\n3 3\n5 6\n5 3\n3 5\n1 4\n5 5\n1 3\n1 4\n3 5\n3 6\n2 4\n2 4\n5 1\n6 4\n5 1\n5 5\n1 1\n3 2\n4 3\n5 4\n5 1\n2 4\n4 3\n6 1\n3 4\n1 5\n6 3", "60\n2 6\n1 4\n3 2\n1 2\n3 2\n2 4\n6 4\n4 6\n1 3\n3 1\n6 5\n2 4\n5 4\n4 2\n1 6\n3 4\n4 5\n5 2\n1 5\n5 4\n3 4\n3 4\n4 4\n4 1\n6 6\n3 6\n2 4\n2 1\n4 4\n6 5\n3 1\n4 3\n1 3\n6 3\n5 5\n1 4\n3 1\n3 6\n1 5\n3 1\n1 5\n4 4\n1 3\n2 4\n6 2\n4 1\n5 3\n3 4\n5 6\n1 2\n1 6\n6 3\n1 6\n3 6\n3 4\n6 2\n4 6\n2 3\n3 3\n3 3", "60\n2 3\n4 6\n2 4\n1 3\n5 6\n1 5\n1 2\n1 3\n5 6\n4 3\n4 2\n3 1\n1 3\n3 5\n1 5\n3 4\n2 4\n3 5\n4 5\n1 2\n3 1\n1 5\n2 5\n6 2\n1 6\n3 3\n6 2\n5 3\n1 3\n1 4\n6 4\n6 3\n4 2\n4 2\n1 4\n1 3\n3 2\n3 1\n2 1\n1 2\n3 1\n2 6\n1 4\n3 6\n3 3\n1 5\n2 4\n5 5\n6 2\n5 2\n3 3\n5 3\n3 4\n4 5\n5 6\n2 4\n5 3\n3 1\n2 4\n5 4", "65\n5 4\n3 3\n1 2\n4 3\n3 5\n1 5\n4 5\n2 6\n1 2\n1 5\n6 3\n2 6\n4 3\n3 6\n1 5\n3 5\n4 6\n2 5\n6 5\n1 4\n3 4\n4 3\n1 4\n2 5\n6 5\n3 1\n4 3\n1 2\n1 1\n6 1\n5 2\n3 2\n1 6\n2 6\n3 3\n6 6\n4 6\n1 5\n5 1\n4 5\n1 4\n3 2\n5 4\n4 2\n6 2\n1 3\n4 2\n5 3\n6 4\n3 6\n1 2\n6 1\n6 6\n3 3\n4 2\n3 5\n4 6\n4 1\n5 4\n6 1\n5 1\n5 6\n6 1\n4 6\n5 5", "65\n5 4\n6 3\n5 4\n4 5\n5 3\n3 6\n1 3\n3 1\n1 3\n6 1\n6 4\n1 3\n2 2\n4 6\n4 1\n5 6\n6 5\n1 1\n1 3\n6 6\n4 1\n2 4\n5 4\n4 1\n5 5\n5 3\n6 2\n2 6\n4 2\n2 2\n6 2\n3 3\n4 5\n4 3\n3 1\n1 4\n4 5\n3 2\n5 5\n4 6\n5 1\n3 4\n5 4\n5 2\n1 6\n4 2\n3 4\n3 4\n1 3\n1 2\n3 3\n3 6\n6 4\n4 6\n6 2\n6 5\n3 2\n2 1\n6 4\n2 1\n1 5\n5 2\n6 5\n3 6\n5 1", "70\n4 1\n2 6\n1 1\n5 6\n5 1\n2 3\n3 5\n1 1\n1 1\n4 6\n4 3\n1 5\n2 2\n2 3\n3 1\n6 4\n3 1\n4 2\n5 4\n1 3\n3 5\n5 2\n5 6\n4 4\n4 5\n2 2\n4 5\n3 2\n3 5\n2 5\n2 6\n5 5\n2 6\n5 1\n1 1\n2 5\n3 1\n1 2\n6 4\n6 5\n5 5\n5 1\n1 5\n2 2\n6 3\n4 3\n6 2\n5 5\n1 1\n6 2\n6 6\n3 4\n2 2\n3 5\n1 5\n2 5\n4 5\n2 4\n6 3\n5 1\n2 6\n4 2\n1 4\n1 6\n6 2\n5 2\n5 6\n2 5\n5 6\n5 5", "70\n4 3\n6 4\n5 5\n3 1\n1 2\n2 5\n4 6\n4 2\n3 2\n4 2\n1 5\n2 2\n4 3\n1 2\n6 1\n6 6\n1 6\n5 1\n2 2\n6 3\n4 2\n4 3\n1 2\n6 6\n3 3\n6 5\n6 2\n3 6\n6 6\n4 6\n5 2\n5 4\n3 3\n1 6\n5 6\n2 3\n4 6\n1 1\n1 2\n6 6\n1 1\n3 4\n1 6\n2 6\n3 4\n6 3\n5 3\n1 2\n2 3\n4 6\n2 1\n6 4\n4 6\n4 6\n4 2\n5 5\n3 5\n3 2\n4 3\n3 6\n1 4\n3 6\n1 4\n1 6\n1 5\n5 6\n4 4\n3 3\n3 5\n2 2", "75\n1 3\n4 5\n4 1\n6 5\n2 1\n1 4\n5 4\n1 5\n5 3\n1 2\n4 1\n1 1\n5 1\n5 3\n1 5\n4 2\n2 2\n6 3\n1 2\n4 3\n2 5\n5 3\n5 5\n4 1\n4 6\n2 5\n6 1\n2 4\n6 4\n5 2\n6 2\n2 4\n1 3\n5 4\n6 5\n5 4\n6 4\n1 5\n4 6\n1 5\n1 1\n4 4\n3 5\n6 3\n6 5\n1 5\n2 1\n1 5\n6 6\n2 2\n2 2\n4 4\n6 6\n5 4\n4 5\n3 2\n2 4\n1 1\n4 3\n3 2\n5 4\n1 6\n1 2\n2 2\n3 5\n2 6\n1 1\n2 2\n2 3\n6 2\n3 6\n4 4\n5 1\n4 1\n4 1", "75\n1 1\n2 1\n5 5\n6 5\n6 3\n1 6\n6 1\n4 4\n2 1\n6 2\n3 1\n6 4\n1 6\n2 2\n4 3\n4 2\n1 2\n6 2\n4 2\n5 1\n1 2\n3 2\n6 6\n6 3\n2 4\n4 1\n4 1\n2 4\n5 5\n2 3\n5 5\n4 5\n3 1\n1 5\n4 3\n2 3\n3 5\n4 6\n5 6\n1 6\n2 3\n2 2\n1 2\n5 6\n1 4\n1 5\n1 3\n6 2\n1 2\n4 2\n2 1\n1 3\n6 4\n4 1\n5 2\n6 2\n3 5\n2 3\n4 2\n5 1\n5 6\n3 2\n2 1\n6 6\n2 1\n6 2\n1 1\n3 2\n1 2\n3 5\n4 6\n1 3\n3 4\n5 5\n6 2", "80\n3 1\n6 3\n2 2\n2 2\n6 3\n6 1\n6 5\n1 4\n3 6\n6 5\n1 3\n2 4\n1 4\n3 1\n5 3\n5 3\n1 4\n2 5\n4 3\n4 4\n4 5\n6 1\n3 1\n2 6\n4 2\n3 1\n6 5\n2 6\n2 2\n5 1\n1 3\n5 1\n2 1\n4 3\n6 3\n3 5\n4 3\n5 6\n3 3\n4 1\n5 1\n6 5\n5 1\n2 5\n6 1\n3 2\n4 3\n3 3\n5 6\n1 6\n5 2\n1 5\n5 6\n6 4\n2 2\n4 2\n4 6\n4 2\n4 4\n6 5\n5 2\n6 2\n4 6\n6 4\n4 3\n5 1\n4 1\n3 5\n3 2\n3 2\n5 3\n5 4\n3 4\n1 3\n1 2\n6 6\n6 3\n6 1\n5 6\n3 2", "80\n4 5\n3 3\n3 6\n4 5\n3 4\n6 5\n1 5\n2 5\n5 6\n5 1\n5 1\n1 2\n5 5\n5 1\n2 3\n1 1\n4 5\n4 1\n1 1\n5 5\n5 6\n5 2\n5 4\n4 2\n6 2\n5 3\n3 2\n4 2\n1 3\n1 6\n2 1\n6 6\n4 5\n6 4\n2 2\n1 6\n6 2\n4 3\n2 3\n4 6\n4 6\n6 2\n3 4\n4 3\n5 5\n1 6\n3 2\n4 6\n2 3\n1 6\n5 4\n4 2\n5 4\n1 1\n4 3\n5 1\n3 6\n6 2\n3 1\n4 1\n5 3\n2 2\n3 4\n3 6\n3 5\n5 5\n5 1\n3 5\n2 6\n6 3\n6 5\n3 3\n5 6\n1 2\n3 1\n6 3\n3 4\n6 6\n6 6\n1 2", "85\n6 3\n4 1\n1 2\n3 5\n6 4\n6 2\n2 6\n1 2\n1 5\n6 2\n1 4\n6 6\n2 4\n4 6\n4 5\n1 6\n3 1\n2 5\n5 1\n5 2\n3 5\n1 1\n4 1\n2 3\n1 1\n3 3\n6 4\n1 4\n1 1\n3 6\n1 5\n1 6\n2 5\n2 2\n5 1\n6 6\n1 3\n1 5\n5 6\n4 5\n4 3\n5 5\n1 3\n6 3\n4 6\n2 4\n5 6\n6 2\n4 5\n1 4\n1 4\n6 5\n1 6\n6 1\n1 6\n5 5\n2 1\n5 2\n2 3\n1 6\n1 6\n1 6\n5 6\n2 4\n6 5\n6 5\n4 2\n5 4\n3 4\n4 3\n6 6\n3 3\n3 2\n3 6\n2 5\n2 1\n2 5\n3 4\n1 2\n5 4\n6 2\n5 1\n1 4\n3 4\n4 5", "85\n3 1\n3 2\n6 3\n1 3\n2 1\n3 6\n1 4\n2 5\n6 5\n1 6\n1 5\n1 1\n4 3\n3 5\n4 6\n3 2\n6 6\n4 4\n4 1\n5 5\n4 2\n6 2\n2 2\n4 5\n6 1\n3 4\n4 5\n3 5\n4 2\n3 5\n4 4\n3 1\n4 4\n6 4\n1 4\n5 5\n1 5\n2 2\n6 5\n5 6\n6 5\n3 2\n3 2\n6 1\n6 5\n2 1\n4 6\n2 1\n3 1\n5 6\n1 3\n5 4\n1 4\n1 4\n5 3\n2 3\n1 3\n2 2\n5 3\n2 3\n2 3\n1 3\n3 6\n4 4\n6 6\n6 2\n5 1\n5 5\n5 5\n1 2\n1 4\n2 4\n3 6\n4 6\n6 3\n6 4\n5 5\n3 2\n5 4\n5 4\n4 5\n6 4\n2 1\n5 2\n5 1", "90\n5 2\n5 5\n5 1\n4 6\n4 3\n5 3\n5 6\n5 1\n3 4\n1 3\n4 2\n1 6\n6 4\n1 2\n6 1\n4 1\n6 2\n6 5\n6 2\n5 4\n3 6\n1 1\n5 5\n2 2\n1 6\n3 5\n6 5\n1 6\n1 5\n2 3\n2 6\n2 3\n3 3\n1 3\n5 1\n2 5\n3 6\n1 2\n4 4\n1 6\n2 3\n1 5\n2 5\n1 3\n2 2\n4 6\n3 6\n6 3\n1 2\n4 3\n4 5\n4 6\n3 2\n6 5\n6 2\n2 5\n2 4\n1 3\n1 6\n4 3\n1 3\n6 4\n4 6\n4 1\n1 1\n4 1\n4 4\n6 2\n6 5\n1 1\n2 2\n3 1\n1 4\n6 2\n5 2\n1 4\n1 3\n6 5\n3 2\n6 4\n3 4\n2 6\n2 2\n6 3\n4 6\n1 2\n4 2\n3 4\n2 3\n1 5", "90\n1 4\n3 5\n4 2\n2 5\n4 3\n2 6\n2 6\n3 2\n4 4\n6 1\n4 3\n2 3\n5 3\n6 6\n2 2\n6 3\n4 1\n4 4\n5 6\n6 4\n4 2\n5 6\n4 6\n4 4\n6 4\n4 1\n5 3\n3 2\n4 4\n5 2\n5 4\n6 4\n1 2\n3 3\n3 4\n6 4\n1 6\n4 2\n3 2\n1 1\n2 2\n5 1\n6 6\n4 1\n5 2\n3 6\n2 1\n2 2\n4 6\n6 5\n4 4\n5 5\n5 6\n1 6\n1 4\n5 6\n3 6\n6 3\n5 6\n6 5\n5 1\n6 1\n6 6\n6 3\n1 5\n4 5\n3 1\n6 6\n3 4\n6 2\n1 4\n2 2\n3 2\n5 6\n2 4\n1 4\n6 3\n4 6\n1 4\n5 2\n1 2\n6 5\n1 5\n1 4\n4 2\n2 5\n3 2\n5 1\n5 4\n5 3", "95\n4 3\n3 2\n5 5\n5 3\n1 6\n4 4\n5 5\n6 5\n3 5\n1 5\n4 2\n5 1\n1 2\n2 3\n6 4\n2 3\n6 3\n6 5\n5 6\n1 4\n2 6\n2 6\n2 5\n2 1\n3 1\n3 5\n2 2\n6 1\n2 4\n4 6\n6 6\n6 4\n3 2\n5 1\n4 3\n6 5\n2 3\n4 1\n2 5\n6 5\n6 5\n6 5\n5 1\n5 4\n4 6\n3 2\n2 5\n2 6\n4 6\n6 3\n6 4\n5 6\n4 6\n2 4\n3 4\n1 4\n2 4\n2 3\n5 6\n6 4\n3 1\n5 1\n3 6\n3 5\n2 6\n6 3\n4 3\n3 1\n6 1\n2 2\n6 3\n2 2\n2 2\n6 4\n6 1\n2 1\n5 6\n5 4\n5 2\n3 4\n3 6\n2 1\n1 6\n5 5\n2 6\n2 3\n3 6\n1 3\n1 5\n5 1\n1 2\n2 2\n5 3\n6 4\n4 5", "95\n4 5\n5 6\n3 2\n5 1\n4 3\n4 1\n6 1\n5 2\n2 4\n5 3\n2 3\n6 4\n4 1\n1 6\n2 6\n2 3\n4 6\n2 4\n3 4\n4 2\n5 5\n1 1\n1 5\n4 3\n4 5\n6 2\n6 1\n6 3\n5 5\n4 1\n5 1\n2 3\n5 1\n3 6\n6 6\n4 5\n4 4\n4 3\n1 6\n6 6\n4 6\n6 4\n1 2\n6 2\n4 6\n6 6\n5 5\n6 1\n5 2\n4 5\n6 6\n6 5\n4 4\n1 5\n4 6\n4 1\n3 6\n5 1\n3 1\n4 6\n4 5\n1 3\n5 4\n4 5\n2 2\n6 1\n5 2\n6 5\n2 2\n1 1\n6 3\n6 1\n2 6\n3 3\n2 1\n4 6\n2 4\n5 5\n5 2\n3 2\n1 2\n6 6\n6 2\n5 1\n2 6\n5 2\n2 2\n5 5\n3 5\n3 3\n2 6\n5 3\n4 3\n1 6\n5 4", "100\n1 1\n3 5\n2 1\n1 2\n3 4\n5 6\n5 6\n6 1\n5 5\n2 4\n5 5\n5 6\n6 2\n6 6\n2 6\n1 4\n2 2\n3 2\n1 3\n5 5\n6 3\n5 6\n1 1\n1 2\n1 2\n2 1\n2 3\n1 6\n4 3\n1 1\n2 5\n2 4\n4 4\n1 5\n3 3\n6 1\n3 5\n1 1\n3 6\n3 1\n4 2\n4 3\n3 6\n6 6\n1 6\n6 2\n2 5\n5 4\n6 3\n1 4\n2 6\n6 2\n3 4\n6 1\n6 5\n4 6\n6 5\n4 4\n3 1\n6 3\n5 1\n2 4\n5 1\n1 2\n2 4\n2 1\n6 6\n5 3\n4 6\n6 3\n5 5\n3 3\n1 1\n6 5\n4 3\n2 6\n1 5\n3 5\n2 4\n4 5\n1 6\n2 3\n6 3\n5 5\n2 6\n2 6\n3 4\n3 2\n6 1\n3 4\n6 4\n3 3\n2 3\n5 1\n3 1\n6 2\n2 3\n6 4\n1 4\n1 2", "100\n1 1\n5 5\n1 2\n5 3\n5 5\n2 2\n1 5\n3 4\n3 2\n1 3\n5 6\n4 5\n2 1\n5 5\n2 2\n1 6\n6 1\n5 1\n4 1\n4 6\n3 5\n6 1\n2 3\n5 6\n3 6\n2 3\n5 6\n1 6\n3 2\n2 2\n3 3\n6 5\n5 5\n1 4\n5 6\n6 4\n1 4\n1 2\n2 6\n3 2\n6 4\n5 3\n3 3\n6 4\n4 6\n2 2\n5 6\n5 1\n1 2\n3 4\n4 5\n1 1\n3 4\n5 2\n4 5\n3 3\n1 1\n3 4\n1 6\n2 4\n1 3\n3 2\n6 5\n1 6\n3 6\n2 3\n2 6\n5 1\n5 5\n5 6\n4 1\n6 2\n3 6\n5 3\n2 2\n2 4\n6 6\n3 6\n4 6\n2 5\n5 3\n1 2\n3 4\n3 4\n6 2\n2 4\n2 2\n4 6\n3 5\n4 2\n5 6\n4 2\n2 3\n6 2\n5 6\n2 1\n3 3\n6 6\n4 3\n4 2", "1\n2 2", "3\n2 4\n6 6\n3 3", "2\n3 6\n4 1", "3\n1 1\n1 1\n3 3", "3\n2 3\n1 1\n2 3", "3\n2 2\n2 1\n1 2", "3\n1 1\n1 1\n1 1"], "outputs": ["0", "-1", "1", "1", "-1", "-1", "0", "-1", "-1", "0", "-1", "-1", "1", "0", "0", "-1", "1", "-1", "0", "-1", "-1", "-1", "1", "1", "1", "1", "-1", "-1", "-1", "-1", "1", "-1", "0", "-1", "-1", "-1", "1", "1", "-1", "0", "0", "1", "0", "-1", "0", "-1", "-1", "-1", "0", "-1", "-1", "1", "0", "-1", "1", "-1", "1", "1", "-1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 236 | codeforces |
|
5836b24c0f11bb4c360cb09cc7022291 | Mean Requests | In this problem you will have to deal with a real algorithm that is used in the VK social network.
As in any other company that creates high-loaded websites, the VK developers have to deal with request statistics regularly. An important indicator reflecting the load of the site is the mean number of requests for a certain period of time of *T* seconds (for example, *T*<==<=60Β *seconds*<==<=1Β *min* and *T*<==<=86400Β *seconds*<==<=1Β *day*). For example, if this value drops dramatically, that shows that the site has access problem. If this value grows, that may be a reason to analyze the cause for the growth and add more servers to the website if it is really needed.
However, even such a natural problem as counting the mean number of queries for some period of time can be a challenge when you process the amount of data of a huge social network. That's why the developers have to use original techniques to solve problems approximately, but more effectively at the same time.
Let's consider the following formal model. We have a service that works for *n* seconds. We know the number of queries to this resource *a**t* at each moment of time *t* (1<=β€<=*t*<=β€<=*n*). Let's formulate the following algorithm of calculating the mean with exponential decay. Let *c* be some real number, strictly larger than one.
Thus, the mean variable is recalculated each second using the number of queries that came at that second. We can make some mathematical calculations and prove that choosing the value of constant *c* correctly will make the value of mean not very different from the real mean value *a**x* at *t*<=-<=*T*<=+<=1<=β€<=*x*<=β€<=*t*.
The advantage of such approach is that it only uses the number of requests at the current moment of time and doesn't require storing the history of requests for a large time range. Also, it considers the recent values with the weight larger than the weight of the old ones, which helps to react to dramatic change in values quicker.
However before using the new theoretical approach in industrial programming, there is an obligatory step to make, that is, to test its credibility practically on given test data sets. Your task is to compare the data obtained as a result of the work of an approximate algorithm to the real data.
You are given *n* values *a**t*, integer *T* and real number *c*. Also, you are given *m* moments *p**j* (1<=β€<=*j*<=β€<=*m*), where we are interested in the mean value of the number of queries for the last *T* seconds. Implement two algorithms. The first one should calculate the required value by definition, i.e. by the formula . The second algorithm should calculate the mean value as is described above. Print both values and calculate the relative error of the second algorithm by the formula , where *approx* is the approximate value, obtained by the second algorithm, and *real* is the exact value obtained by the first algorithm.
The first line contains integer *n* (1<=β€<=*n*<=β€<=2Β·105), integer *T* (1<=β€<=*T*<=β€<=*n*) and real number *c* (1<=<<=*c*<=β€<=100) β the time range when the resource should work, the length of the time range during which we need the mean number of requests and the coefficient *c* of the work of approximate algorithm. Number *c* is given with exactly six digits after the decimal point.
The next line contains *n* integers *a**t* (1<=β€<=*a**t*<=β€<=106) β the number of queries to the service at each moment of time.
The next line contains integer *m* (1<=β€<=*m*<=β€<=*n*) β the number of moments of time when we are interested in the mean number of queries for the last *T* seconds.
The next line contains *m* integers *p**j* (*T*<=β€<=*p**j*<=β€<=*n*), representing another moment of time for which we need statistics. Moments *p**j* are strictly increasing.
Print *m* lines. The *j*-th line must contain three numbers *real*, *approx* and *error*, where:
- is the real mean number of queries for the last *T* seconds; - *approx* is calculated by the given algorithm and equals *mean* at the moment of time *t*<==<=*p**j* (that is, after implementing the *p**j*-th iteration of the cycle); - is the relative error of the approximate algorithm.
The numbers you printed will be compared to the correct numbers with the relative or absolute error 10<=-<=4. It is recommended to print the numbers with at least five digits after the decimal point.
Sample Input
1 1 2.000000
1
1
1
11 4 1.250000
9 11 7 5 15 6 6 6 6 6 6
8
4 5 6 7 8 9 10 11
13 4 1.250000
3 3 3 3 3 20 3 3 3 3 3 3 3
10
4 5 6 7 8 9 10 11 12 13
Sample Output
1.000000 0.500000 0.500000
8.000000 4.449600 0.443800
9.500000 6.559680 0.309507
8.250000 6.447744 0.218455
8.000000 6.358195 0.205226
8.250000 6.286556 0.237993
6.000000 6.229245 0.038207
6.000000 6.183396 0.030566
6.000000 6.146717 0.024453
3.000000 1.771200 0.409600
3.000000 2.016960 0.327680
7.250000 5.613568 0.225715
7.250000 5.090854 0.297813
7.250000 4.672684 0.355492
7.250000 4.338147 0.401635
3.000000 4.070517 0.356839
3.000000 3.856414 0.285471
3.000000 3.685131 0.228377
3.000000 3.548105 0.182702
| {"inputs": ["1 1 2.000000\n1\n1\n1", "11 4 1.250000\n9 11 7 5 15 6 6 6 6 6 6\n8\n4 5 6 7 8 9 10 11", "13 4 1.250000\n3 3 3 3 3 20 3 3 3 3 3 3 3\n10\n4 5 6 7 8 9 10 11 12 13", "1 1 2.000000\n4\n1\n1", "1 1 2.000000\n1121\n1\n1", "1 1 2.000000\n758432\n1\n1", "3 1 2.000000\n8 25 21\n3\n1 2 3", "19 3 1.333333\n12 15 11 10 16 4 9 2 24 3 6 3 21 21 2 16 13 12 2\n17\n3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19", "64 3 1.333333\n1337 1913 135 885 1567 1049 1116 368 350 725 517 1874 588 918 1923 998 1237 1098 121 1304 1459 942 538 1480 293 178 958 728 1240 1721 1549 825 928 1189 194 626 1872 670 1145 200 333 1772 1136 614 174 1448 249 1783 798 1375 1574 870 360 398 1387 1092 314 294 1056 1890 1170 697 668 1570\n62\n3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64"], "outputs": ["1.000000 0.500000 0.500000", "8.000000 4.449600 0.443800\n9.500000 6.559680 0.309507\n8.250000 6.447744 0.218455\n8.000000 6.358195 0.205226\n8.250000 6.286556 0.237993\n6.000000 6.229245 0.038207\n6.000000 6.183396 0.030566\n6.000000 6.146717 0.024453", "3.000000 1.771200 0.409600\n3.000000 2.016960 0.327680\n7.250000 5.613568 0.225715\n7.250000 5.090854 0.297813\n7.250000 4.672684 0.355492\n7.250000 4.338147 0.401635\n3.000000 4.070517 0.356839\n3.000000 3.856414 0.285471\n3.000000 3.685131 0.228377\n3.000000 3.548105 0.182702", "4.000000 2.000000 0.500000", "1121.000000 560.500000 0.500000", "758432.000000 379216.000000 0.500000", "8.000000 4.000000 0.500000\n25.000000 14.500000 0.420000\n21.000000 17.750000 0.154762", "12.666667 7.250003 0.427631\n12.000000 7.937505 0.338541\n12.333333 9.953131 0.192989\n10.000000 8.464850 0.153515\n9.666667 8.598640 0.110486\n5.000000 6.948982 0.389796\n11.666667 11.211739 0.038994\n9.666667 9.158807 0.052537\n11.000000 8.369107 0.239172\n4.000000 7.026832 0.756708\n10.000000 10.520127 0.052013\n15.000000 13.140098 0.123993\n14.666667 10.355076 0.293972\n13.000000 11.766310 0.094899\n10.333333 12.074736 0.168523\n13.666667 12.056055 0.117850\n9.000000 9.542043 0.060227", "1128.333333 580.453454 0.485566\n977.666667 656.590254 0.328411\n862.333333 884.192912 0.025349\n1167.000000 925.394915 0.207031\n1244.000000 973.046430 0.217808\n844.333333 821.785028 0.026705\n611.333333 703.838947 0.151318\n481.000000 709.129387 0.474281\n530.666667 661.097206 0.245786\n1038.666667 964.323145 0.071576\n993.000000 870.242577 0.123623\n1126.666667 882.182153 0.216998\n1143.000000 1142.386900 0.000536\n1279.666667 1106.290452 0.135485\n1386.000000 1138.968124 0.178234\n1111.000000 1128.726375 0.015955\n81..."]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 4 | codeforces |
|
5845aa1a775a0630183ec6836b5c2a58 | Super M | Ari the monster is not an ordinary monster. She is the hidden identity of Super M, the Byteforcesβ superhero. Byteforces is a country that consists of *n* cities, connected by *n*<=-<=1 bidirectional roads. Every road connects exactly two distinct cities, and the whole road system is designed in a way that one is able to go from any city to any other city using only the given roads. There are *m* cities being attacked by humans. So Ari... we meant Super M have to immediately go to each of the cities being attacked to scare those bad humans. Super M can pass from one city to another only using the given roads. Moreover, passing through one road takes her exactly one kron - the time unit used in Byteforces.
However, Super M is not on Byteforces now - she is attending a training camp located in a nearby country Codeforces. Fortunately, there is a special device in Codeforces that allows her to instantly teleport from Codeforces to any city of Byteforces. The way back is too long, so for the purpose of this problem teleportation is used exactly once.
You are to help Super M, by calculating the city in which she should teleport at the beginning in order to end her job in the minimum time (measured in krons). Also, provide her with this time so she can plan her way back to Codeforces.
The first line of the input contains two integers *n* and *m* (1<=β€<=*m*<=β€<=*n*<=β€<=123456) - the number of cities in Byteforces, and the number of cities being attacked respectively.
Then follow *n*<=-<=1 lines, describing the road system. Each line contains two city numbers *u**i* and *v**i* (1<=β€<=*u**i*,<=*v**i*<=β€<=*n*) - the ends of the road *i*.
The last line contains *m* distinct integers - numbers of cities being attacked. These numbers are given in no particular order.
First print the number of the city Super M should teleport to. If there are many possible optimal answers, print the one with the lowest city number.
Then print the minimum possible time needed to scare all humans in cities being attacked, measured in Krons.
Note that the correct answer is always unique.
Sample Input
7 2
1 2
1 3
1 4
3 5
3 6
3 7
2 7
6 4
1 2
2 3
2 4
4 5
4 6
2 4 5 6
Sample Output
2
3
2
4
| {"inputs": ["7 2\n1 2\n1 3\n1 4\n3 5\n3 6\n3 7\n2 7", "6 4\n1 2\n2 3\n2 4\n4 5\n4 6\n2 4 5 6", "2 1\n2 1\n1", "1 1\n1", "10 2\n6 9\n6 2\n1 6\n4 10\n3 7\n9 4\n9 5\n6 7\n2 8\n7 6", "15 2\n7 12\n13 11\n6 8\n2 15\n10 9\n5 1\n13 5\n5 4\n14 3\n8 9\n8 4\n4 7\n12 14\n5 2\n7 4", "20 2\n1 16\n12 5\n15 19\n18 9\n8 4\n10 16\n9 16\n20 15\n14 19\n7 4\n18 12\n17 12\n2 20\n6 14\n3 19\n7 19\n18 15\n19 13\n9 11\n12 18", "4 2\n4 3\n3 1\n1 2\n3 4", "8 5\n2 5\n1 8\n6 7\n3 4\n6 8\n8 5\n5 3\n1 6 7 3 8", "16 8\n16 12\n16 15\n15 9\n15 13\n16 3\n15 2\n15 10\n1 2\n6 16\n5 15\n2 7\n15 4\n14 15\n11 16\n8 5\n5 10 14 6 8 3 1 9", "32 28\n30 12\n30 27\n24 32\n6 13\n11 5\n4 30\n8 28\n9 20\n8 20\n7 20\n5 30\n18 5\n20 14\n23 20\n17 20\n8 26\n20 1\n15 2\n20 13\n24 20\n22 24\n25 16\n2 3\n19 5\n16 10\n31 2\n29 5\n20 16\n2 20\n5 21\n5 20\n32 11 6 12 22 30 23 21 14 13 1 20 7 25 9 29 10 27 5 19 24 31 15 26 8 3 28 17", "10 3\n10 5\n3 2\n6 8\n1 5\n10 4\n6 1\n9 8\n2 9\n7 3\n3 9 1", "7 5\n6 4\n5 6\n6 7\n2 3\n5 2\n2 1\n4 6 1 7 3", "15 7\n5 4\n12 5\n7 13\n10 11\n3 8\n6 12\n3 15\n1 3\n5 14\n7 9\n1 10\n6 1\n12 7\n10 2\n4 10 8 13 1 7 9", "31 16\n3 25\n8 1\n1 9\n1 23\n16 15\n10 6\n25 30\n20 29\n2 24\n3 7\n19 22\n2 12\n16 4\n7 26\n31 10\n17 13\n25 21\n7 18\n28 2\n6 27\n19 5\n13 3\n17 31\n10 16\n20 14\n8 19\n6 11\n28 20\n13 28\n31 8\n31 27 25 20 26 8 28 15 18 17 10 23 4 16 30 22", "63 20\n35 26\n54 5\n32 56\n56 53\n59 46\n37 31\n46 8\n4 1\n2 47\n59 42\n55 11\n62 6\n30 7\n60 24\n41 36\n34 22\n24 34\n21 2\n12 52\n8 44\n60 21\n24 30\n48 35\n48 25\n32 57\n20 37\n11 54\n11 62\n42 58\n31 43\n12 23\n55 48\n51 55\n41 27\n25 33\n21 18\n42 12\n4 15\n51 60\n62 39\n46 41\n57 9\n30 61\n31 4\n58 13\n34 29\n37 32\n18 16\n57 45\n2 49\n40 51\n43 17\n40 20\n20 59\n8 19\n58 10\n43 63\n54 50\n18 14\n25 38\n56 28\n35 3\n41 36 18 28 54 22 20 6 23 38 33 52 48 44 29 56 63 4 27 50", "4 2\n2 3\n2 1\n2 4\n3 4", "13 11\n4 11\n2 7\n4 13\n8 12\n8 9\n8 6\n3 8\n4 1\n2 10\n2 5\n3 4\n3 2\n10 4 5 6 1 2 3 9 13 7 12", "7 5\n1 5\n4 1\n1 3\n7 1\n1 6\n1 2\n2 4 1 3 7", "12 9\n11 12\n1 10\n1 7\n5 6\n8 7\n9 8\n4 5\n1 4\n2 3\n1 2\n10 11\n4 9 11 3 5 12 8 6 7", "56 34\n7 31\n47 6\n13 4\n51 29\n13 12\n10 52\n10 41\n1 47\n47 54\n9 1\n4 27\n4 40\n49 19\n21 26\n24 33\n56 49\n41 56\n7 23\n41 48\n16 34\n35 9\n56 51\n5 43\n44 46\n10 25\n49 2\n1 21\n9 32\n33 20\n16 5\n5 35\n55 50\n55 53\n37 44\n43 15\n4 55\n8 10\n8 24\n21 42\n37 8\n39 13\n49 38\n39 16\n50 3\n55 7\n51 45\n21 11\n51 28\n50 18\n50 30\n5 37\n7 17\n35 22\n47 36\n35 14\n3 38 47 22 34 10 54 50 9 52 36 1 21 29 28 6 13 39 4 40 53 51 35 55 45 18 44 20 42 31 11 46 41 12", "26 22\n20 16\n2 7\n7 19\n5 9\n20 23\n22 18\n24 3\n8 22\n16 10\n5 2\n7 15\n22 14\n25 4\n25 11\n24 13\n8 24\n13 1\n20 8\n22 6\n7 26\n16 12\n16 5\n13 21\n25 17\n2 25\n16 4 7 24 10 12 2 23 20 1 26 14 8 9 3 6 21 13 11 18 22 17", "43 13\n7 28\n17 27\n39 8\n21 3\n17 20\n17 2\n9 6\n35 23\n43 22\n7 41\n5 24\n26 11\n21 43\n41 17\n16 5\n25 15\n39 10\n18 7\n37 33\n39 13\n39 16\n10 12\n1 21\n2 25\n14 36\n12 7\n16 34\n24 4\n25 40\n5 29\n37 31\n3 32\n22 14\n16 35\n5 37\n10 38\n25 19\n9 1\n26 42\n43 26\n10 30\n33 9\n28 6 42 38 27 32 8 11 36 7 41 29 19", "21 20\n16 9\n7 11\n4 12\n2 17\n17 7\n5 2\n2 8\n4 10\n8 19\n6 15\n2 6\n12 18\n16 5\n20 16\n6 14\n5 3\n5 21\n20 1\n17 13\n6 4\n6 4 18 11 14 1 19 15 10 8 9 17 16 3 20 13 2 5 12 21", "29 6\n16 9\n20 13\n24 3\n24 28\n22 12\n10 11\n10 26\n22 4\n10 27\n5 1\n2 23\n23 5\n16 7\n8 24\n7 19\n19 17\n8 10\n20 16\n20 25\n24 20\n23 15\n22 29\n2 8\n7 22\n2 21\n23 14\n19 18\n19 6\n19 17 18 27 29 4", "31 29\n10 14\n16 6\n23 22\n25 23\n2 27\n24 17\n20 8\n5 2\n8 24\n16 5\n10 26\n8 7\n5 29\n20 16\n13 9\n13 21\n24 30\n13 1\n10 15\n23 3\n25 10\n2 25\n20 13\n25 11\n8 12\n30 28\n20 18\n5 4\n23 19\n16 31\n13 14 3 30 5 6 26 22 25 1 23 7 31 12 16 28 17 2 8 18 24 4 20 21 15 11 9 29 10", "54 8\n33 9\n39 36\n22 14\n24 13\n8 50\n34 52\n47 2\n35 44\n16 54\n34 25\n1 3\n39 11\n9 17\n43 19\n10 40\n47 38\n5 37\n21 47\n37 12\n16 6\n37 7\n32 26\n39 42\n44 10\n1 18\n37 8\n9 1\n8 24\n10 33\n33 53\n5 4\n21 30\n9 31\n24 28\n24 49\n16 5\n34 35\n21 48\n47 43\n13 34\n39 16\n10 27\n22 32\n43 22\n13 46\n33 23\n44 15\n1 21\n8 41\n43 45\n5 29\n35 20\n13 51\n40 50 33 14 48 25 44 9", "17 12\n5 2\n4 3\n8 17\n2 4\n2 8\n17 12\n8 10\n6 11\n16 7\n4 14\n15 13\n6 9\n4 6\n15 16\n16 5\n9 1\n4 8 1 9 3 12 15 10 13 6 14 16", "28 6\n25 21\n9 18\n25 1\n16 5\n9 11\n28 19\n5 2\n20 16\n20 13\n2 23\n5 25\n8 24\n14 27\n3 15\n24 28\n8 10\n22 14\n14 17\n13 9\n3 22\n22 26\n16 7\n2 8\n25 3\n3 12\n14 4\n9 6\n28 27 22 24 20 16", "10 9\n3 9\n4 8\n10 1\n2 3\n5 6\n4 3\n1 2\n5 4\n6 7\n9 1 5 8 7 3 4 6 10", "9 6\n1 6\n3 4\n9 7\n3 2\n8 7\n2 1\n6 7\n3 5\n2 5 1 6 3 9", "19 11\n8 9\n10 13\n16 15\n6 4\n3 2\n17 16\n4 7\n1 14\n10 11\n15 14\n4 3\n10 12\n4 5\n2 1\n16 19\n8 1\n10 9\n18 16\n10 14 18 12 17 11 19 8 1 3 9", "36 5\n36 33\n11 12\n14 12\n25 24\n27 26\n23 24\n20 19\n1 2\n3 2\n17 18\n33 34\n23 1\n32 31\n12 15\n25 26\n4 5\n5 8\n5 6\n26 29\n1 9\n35 33\n33 32\n16 1\n3 4\n31 30\n16 17\n19 21\n1 30\n7 5\n9 10\n13 12\n19 18\n10 11\n22 19\n28 26\n29 12 11 17 33", "10 2\n5 1\n1 3\n3 4\n4 2\n5 10\n1 9\n3 8\n4 7\n2 6\n3 4", "53 30\n41 42\n27 24\n13 11\n10 11\n32 33\n34 33\n37 40\n21 22\n21 20\n46 47\n2 1\n31 30\n29 30\n11 14\n42 43\n50 51\n34 35\n36 35\n24 23\n48 47\n41 1\n28 29\n45 44\n16 15\n5 4\n6 5\n18 19\n9 8\n37 38\n11 12\n39 37\n49 48\n50 49\n43 44\n50 53\n3 4\n50 52\n24 25\n7 6\n46 45\n2 3\n17 18\n31 32\n19 20\n7 8\n15 1\n36 37\n23 22\n9 10\n17 16\n24 26\n28 1\n38 52 41 35 53 43 3 29 36 4 23 20 46 5 40 30 49 25 16 48 17 27 21 9 45 44 15 13 14 2", "10 4\n2 3\n4 2\n8 9\n6 5\n8 1\n5 1\n8 10\n7 5\n1 2\n4 10 2 5", "10 5\n4 5\n9 1\n1 2\n7 1\n5 1\n10 1\n7 3\n6 3\n5 8\n5 2 7 10 1", "10 4\n8 7\n7 6\n1 2\n3 2\n3 4\n6 5\n10 7\n7 9\n5 4\n9 5 10 4", "5 4\n2 3\n2 1\n3 5\n4 3\n4 2 5 1", "5 1\n1 2\n2 3\n3 4\n4 5\n4"], "outputs": ["2\n3", "2\n4", "1\n0", "1\n0", "6\n1", "4\n1", "12\n1", "3\n1", "3\n6", "1\n16", "3\n53", "1\n5", "1\n8", "4\n14", "4\n34", "6\n66", "3\n2", "1\n18", "2\n6", "6\n16", "3\n70", "1\n37", "19\n41", "1\n32", "4\n16", "3\n46", "14\n21", "1\n20", "27\n13", "7\n11", "5\n6", "11\n18", "12\n21", "3\n1", "13\n74", "4\n6", "2\n6", "4\n6", "1\n5", "4\n0"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 4 | codeforces |
|
586f37714c4649e29d7df6664178ab08 | Find Color | Not so long ago as a result of combat operations the main Berland place of interest β the magic clock β was damaged. The cannon's balls made several holes in the clock, that's why the residents are concerned about the repair. The magic clock can be represented as an infinite Cartesian plane, where the origin corresponds to the clock center. The clock was painted two colors as is shown in the picture:
The picture shows only the central part of the clock. This coloring naturally extends to infinity.
The balls can be taken to be points on the plane. Your task is to find the color of the area, damaged by the given ball.
All the points located on the border of one of the areas have to be considered painted black.
The first and single line contains two integers *x* and *y* β the coordinates of the hole made in the clock by the ball. Each of the numbers *x* and *y* has an absolute value that does not exceed 1000.
Find the required color.
All the points between which and the origin of coordinates the distance is integral-value are painted black.
Sample Input
-2 1
2 1
4 3
Sample Output
white
black
black
| {"inputs": ["-2 1", "2 1", "4 3", "3 3", "4 4", "-4 4", "4 -4", "-4 -4", "0 0", "0 1", "0 2", "0 1000", "1000 0", "-1000 0", "0 -1000", "1000 -1000", "12 5", "12 -5", "-12 -35", "20 -21", "-677 492", "-673 -270", "-668 970", "-220 208", "-215 -996", "-211 243", "-206 -518", "-201 278", "-196 -484", "902 479", "-441 572", "217 221", "875 -129", "-469 -36", "189 -387", "847 -294", "-496 -644", "-281 -552", "377 -902", "165 -738", "61 -175", "-42 389", "-589 952", "-693 -929", "-796 -365", "658 198", "555 319", "8 882", "-96 -556", "-129 489", "207 -224", "64 0", "17 144", "60 -448", "-399 -40", "128 -504", "0 72", "168 -26", "72 -154", "117 -44", "-72 -646", "253 -204", "-40 198", "-216 -90", "15 -8", "-180 -432", "280 342", "132 224", "-192 -256", "351 -280"], "outputs": ["white", "black", "black", "black", "white", "black", "black", "white", "black", "black", "black", "black", "black", "black", "black", "white", "black", "black", "black", "black", "white", "white", "black", "white", "black", "black", "white", "black", "black", "white", "white", "white", "white", "black", "white", "white", "black", "white", "black", "white", "black", "black", "black", "white", "white", "white", "black", "black", "black", "black", "black", "black", "black", "black", "black", "black", "black", "black", "black", "black", "black", "black", "black", "black", "black", "black", "black", "black", "black", "black"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 67 | codeforces |
|
5877a100f511348a0d6590e174c3e4fa | Fake NP | Tavak and Seyyed are good friends. Seyyed is very funny and he told Tavak to solve the following problem instead of longest-path.
You are given *l* and *r*. For all integers from *l* to *r*, inclusive, we wrote down all of their integer divisors except 1. Find the integer that we wrote down the maximum number of times.
Solve the problem to show that it's not a NP problem.
The first line contains two integers *l* and *r* (2<=β€<=*l*<=β€<=*r*<=β€<=109).
Print single integer, the integer that appears maximum number of times in the divisors.
If there are multiple answers, print any of them.
Sample Input
19 29
3 6
Sample Output
2
3
| {"inputs": ["19 29", "3 6", "39 91", "76 134", "93 95", "17 35", "94 95", "51 52", "47 52", "38 98", "30 37", "56 92", "900000000 1000000000", "37622224 162971117", "760632746 850720703", "908580370 968054552", "951594860 953554446", "347877978 913527175", "620769961 988145114", "820844234 892579936", "741254764 741254768", "80270976 80270977", "392602363 392602367", "519002744 519002744", "331900277 331900277", "419873015 419873018", "349533413 349533413", "28829775 28829776", "568814539 568814539", "720270740 720270743", "871232720 871232722", "305693653 305693653", "634097178 634097179", "450868287 450868290", "252662256 252662260", "575062045 575062049", "273072892 273072894", "770439256 770439256", "2 1000000000", "6 8", "2 879190747", "5 5", "999999937 999999937", "3 3", "5 100", "2 2", "3 18", "7 7", "39916801 39916801", "3 8", "13 13", "4 8", "3 12", "6 12", "999999103 999999103", "100000007 100000007", "3 99", "999999733 999999733", "5 10", "982451653 982451653", "999900001 1000000000", "999727999 999727999", "2 999999999", "242 244", "3 10", "15 27", "998244353 998244353", "5 15", "999999797 999999797", "2 3", "999999929 999999929", "3 111111", "12 18", "479001599 479001599", "10000019 10000019", "715827883 715827883", "999992977 999992977", "11 11", "29 29", "1000003 1000003", "6 15", "1200007 1200007", "3 1000000000", "990000023 990000023", "1717 1717", "141650963 141650963", "1002523 1002523", "900000011 900000011", "104729 104729", "4 12", "100003 100003", "17 17", "10 100"], "outputs": ["2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "519002744", "331900277", "2", "349533413", "2", "568814539", "2", "2", "305693653", "2", "2", "2", "2", "2", "770439256", "2", "2", "2", "5", "999999937", "3", "2", "2", "2", "7", "39916801", "2", "13", "2", "2", "2", "999999103", "100000007", "2", "999999733", "2", "982451653", "2", "999727999", "2", "2", "2", "2", "998244353", "2", "999999797", "2", "999999929", "2", "2", "479001599", "10000019", "715827883", "999992977", "11", "29", "1000003", "2", "1200007", "2", "990000023", "1717", "141650963", "1002523", "900000011", "104729", "2", "100003", "17", "2"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 173 | codeforces |
|
587a688de32a2c20d1ca304fba736ece | Camels | Bob likes to draw camels: with a single hump, two humps, three humps, etc. He draws a camel by connecting points on a coordinate plane. Now he's drawing camels with *t* humps, representing them as polylines in the plane. Each polyline consists of *n* vertices with coordinates (*x*1,<=*y*1), (*x*2,<=*y*2), ..., (*x**n*,<=*y**n*). The first vertex has a coordinate *x*1<==<=1, the second β *x*2<==<=2, etc. Coordinates *y**i* might be any, but should satisfy the following conditions:
- there should be *t* humps precisely, i.e. such indexes *j* (2<=β€<=*j*<=β€<=*n*<=-<=1), so that *y**j*<=-<=1<=<<=*y**j*<=><=*y**j*<=+<=1, - there should be precisely *t*<=-<=1 such indexes *j* (2<=β€<=*j*<=β€<=*n*<=-<=1), so that *y**j*<=-<=1<=><=*y**j*<=<<=*y**j*<=+<=1, - no segment of a polyline should be parallel to the *Ox*-axis, - all *y**i* are integers between 1 and 4.
For a series of his drawings of camels with *t* humps Bob wants to buy a notebook, but he doesn't know how many pages he will need. Output the amount of different polylines that can be drawn to represent camels with *t* humps for a given number *n*.
The first line contains a pair of integers *n* and *t* (3<=β€<=*n*<=β€<=20, 1<=β€<=*t*<=β€<=10).
Output the required amount of camels with *t* humps.
Sample Input
6 1
4 2
Sample Output
6
0
| {"inputs": ["6 1", "4 2", "3 1", "3 2", "3 3", "3 10", "4 1", "4 3", "4 9", "5 1", "5 2", "5 3", "5 5", "5 9", "5 10", "6 1", "6 2", "6 3", "6 4", "6 10", "19 1", "19 2", "19 3", "19 4", "19 5", "19 6", "19 7", "19 8", "19 9", "19 10", "20 1", "20 2", "20 3", "20 4", "20 5", "20 6", "20 7", "20 8", "20 9", "20 10"], "outputs": ["6", "0", "14", "0", "0", "0", "22", "0", "0", "16", "70", "0", "0", "0", "0", "6", "232", "0", "0", "0", "0", "0", "1", "32632", "4594423", "69183464", "197939352", "109824208", "5846414", "0", "0", "0", "0", "12628", "3715462", "96046590", "468541040", "503245466", "90700276", "0"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 10 | codeforces |
|
588081e1dbf946870f913796b2adf243 | none | Student Vladislav came to his programming exam completely unprepared as usual. He got a question about some strange algorithm on a graphΒ β something that will definitely never be useful in real life. He asked a girl sitting next to him to lend him some cheat papers for this questions and found there the following definition:
The minimum spanning tree *T* of graph *G* is such a tree that it contains all the vertices of the original graph *G*, and the sum of the weights of its edges is the minimum possible among all such trees.
Vladislav drew a graph with *n* vertices and *m* edges containing no loops and multiple edges. He found one of its minimum spanning trees and then wrote for each edge its weight and whether it is included in the found tree or not. Unfortunately, the piece of paper where the graph was painted is gone and the teacher is getting very angry and demands to see the original graph. Help Vladislav come up with a graph so that the information about the minimum spanning tree remains correct.
The first line of the input contains two integers *n* and *m* ()Β β the number of vertices and the number of edges in the graph.
Each of the next *m* lines describes an edge of the graph and consists of two integers *a**j* and *b**j* (1<=β€<=*a**j*<=β€<=109,<=*b**j*<==<={0,<=1}). The first of these numbers is the weight of the edge and the second number is equal to 1 if this edge was included in the minimum spanning tree found by Vladislav, or 0 if it was not.
It is guaranteed that exactly *n*<=-<=1 number {*b**j*} are equal to one and exactly *m*<=-<=*n*<=+<=1 of them are equal to zero.
If Vladislav has made a mistake and such graph doesn't exist, print <=-<=1.
Otherwise print *m* lines. On the *j*-th line print a pair of vertices (*u**j*,<=*v**j*) (1<=β€<=*u**j*,<=*v**j*<=β€<=*n*,<=*u**j*<=β <=*v**j*), that should be connected by the *j*-th edge. The edges are numbered in the same order as in the input. The graph, determined by these edges, must be connected, contain no loops or multiple edges and its edges with *b**j*<==<=1 must define the minimum spanning tree. In case there are multiple possible solutions, print any of them.
Sample Input
4 5
2 1
3 1
4 0
1 1
5 0
3 3
1 0
2 1
3 1
Sample Output
2 4
1 4
3 4
3 1
3 2
-1
| {"inputs": ["4 5\n2 1\n3 1\n4 0\n1 1\n5 0", "3 3\n1 0\n2 1\n3 1", "2 1\n7 1", "3 2\n8 1\n9 1", "3 3\n4 1\n5 0\n7 1", "3 3\n4 1\n5 1\n7 0", "3 3\n4 1\n4 0\n4 1", "3 3\n4 0\n5 1\n4 1", "3 3\n5 0\n4 1\n5 1", "4 4\n2 1\n3 0\n3 1\n4 1", "4 5\n4 1\n4 1\n4 0\n4 0\n6 1", "4 6\n2 1\n4 0\n3 0\n1 1\n4 1\n5 0", "4 4\n2 1\n6 0\n7 1\n7 1", "4 4\n2 1\n8 0\n8 1\n8 1", "4 4\n2 0\n2 1\n8 1\n2 1", "4 4\n2 1\n3 1\n1 1\n4 0", "4 5\n3 1\n4 1\n4 0\n6 0\n6 1", "4 5\n7 0\n3 0\n1 1\n5 1\n7 1", "4 6\n2 1\n7 1\n3 0\n1 1\n7 0\n6 0", "4 6\n1 1\n3 1\n2 0\n2 1\n3 0\n3 0", "4 6\n1 1\n4 1\n2 0\n2 1\n4 0\n3 0", "10 15\n900000012 1\n900000010 1\n900000007 0\n900000005 0\n900000014 1\n900000000 1\n900000004 0\n900000006 1\n900000009 0\n900000002 0\n900000008 0\n900000001 1\n900000011 1\n900000003 1\n900000013 1", "10 15\n900000007 1\n900000002 1\n900000004 0\n900000002 1\n900000006 1\n900000000 1\n900000006 1\n900000008 1\n900000002 0\n900000003 0\n900000002 0\n900000005 0\n900000001 0\n900000000 1\n900000008 1", "10 15\n900000004 0\n900000006 1\n900000001 1\n900000004 1\n900000007 1\n900000007 1\n900000004 1\n900000008 1\n900000004 0\n900000004 0\n900000007 1\n900000005 0\n900000004 0\n900000002 0\n900000000 1", "10 15\n900000006 1\n900000000 1\n900000004 0\n900000000 1\n900000004 0\n900000006 1\n900000000 1\n900000006 1\n900000005 1\n900000001 0\n900000003 1\n900000006 1\n900000000 0\n900000003 0\n900000000 0", "10 15\n900000000 1\n900000003 1\n900000000 1\n900000000 0\n900000003 0\n900000005 1\n900000005 1\n900000005 1\n900000001 0\n900000002 0\n900000002 0\n900000004 1\n900000002 0\n900000000 1\n900000004 1", "10 15\n900000001 1\n900000001 1\n900000002 1\n900000001 1\n900000001 0\n900000001 1\n900000001 0\n900000001 0\n900000001 0\n900000001 1\n900000001 0\n900000001 0\n900000004 1\n900000000 1\n900000001 1", "10 15\n900000001 1\n900000001 1\n900000001 0\n900000000 1\n900000001 0\n900000002 1\n900000000 1\n900000002 1\n900000001 0\n900000001 0\n900000001 0\n900000002 1\n900000000 0\n900000002 1\n900000000 1", "5 5\n1 1\n2 1\n3 0\n4 1\n5 1", "5 6\n1 1\n2 1\n3 0\n4 1\n5 0\n6 1", "5 6\n1 1\n2 1\n3 0\n4 0\n5 1\n6 1", "5 7\n1 1\n1 1\n1 0\n2 0\n1 0\n2 1\n2 1", "5 8\n1 0\n1 1\n1 1\n2 0\n1 0\n2 1\n1 0\n1 1", "5 8\n1 0\n1 1\n1 1\n3 0\n1 0\n3 1\n2 0\n1 1", "5 8\n1 0\n1 1\n1 1\n3 0\n1 0\n4 1\n2 0\n1 1", "5 9\n1 1\n2 1\n3 0\n4 1\n5 0\n6 0\n7 1\n8 0\n9 0", "5 9\n1 1\n2 1\n3 0\n4 1\n5 0\n6 0\n7 0\n8 1\n9 0", "5 10\n1 1\n1 1\n1 0\n1 1\n2 0\n2 0\n2 1\n2 0\n2 0\n2 0", "5 10\n1 1\n1 1\n1 0\n1 1\n2 0\n2 0\n3 1\n2 0\n3 0\n3 0", "10 15\n761759620 0\n761759620 1\n787655728 1\n761759620 0\n294001884 1\n465325912 1\n787655728 0\n683571303 1\n683571303 0\n761759620 0\n787655728 0\n391499930 1\n758807870 1\n611782565 1\n132266542 1", "10 15\n752087443 1\n537185872 1\n439895449 1\n494086747 1\n718088132 1\n93444012 0\n670136349 1\n545547453 0\n718088132 0\n853059674 0\n853059674 1\n762928724 1\n762928724 0\n853059674 0\n156495293 1", "10 15\n417559883 0\n300974070 1\n292808458 1\n469395226 0\n469395226 1\n564721882 1\n125636288 1\n417559883 0\n417559883 1\n469395226 0\n376390930 1\n233782394 1\n780369860 1\n564721882 0\n417559883 0"], "outputs": ["2 4\n1 4\n3 4\n3 1\n3 2", "-1", "1 2", "1 2\n1 3", "-1", "1 2\n1 3\n2 3", "1 2\n2 3\n1 3", "-1", "2 3\n1 2\n1 3", "1 2\n2 3\n1 3\n1 4", "-1", "1 3\n2 4\n2 3\n1 2\n1 4\n3 4", "-1", "1 2\n2 3\n1 3\n1 4", "2 3\n1 2\n1 4\n1 3", "1 3\n1 4\n1 2\n2 3", "1 2\n1 3\n2 3\n2 4\n1 4", "-1", "-1", "1 2\n1 4\n2 3\n1 3\n2 4\n3 4", "-1", "1 8\n1 6\n2 5\n3 4\n1 10\n1 2\n2 4\n1 5\n4 5\n2 3\n3 5\n1 3\n1 7\n1 4\n1 9", "1 8\n1 4\n3 5\n1 5\n1 6\n1 2\n1 7\n1 9\n2 4\n2 5\n3 4\n4 5\n2 3\n1 3\n1 10", "2 4\n1 6\n1 3\n1 4\n1 7\n1 8\n1 5\n1 10\n3 4\n2 5\n1 9\n4 5\n3 5\n2 3\n1 2", "1 7\n1 2\n3 5\n1 3\n4 5\n1 8\n1 4\n1 9\n1 6\n3 4\n1 5\n1 10\n2 3\n2 5\n2 4", "-1", "1 3\n1 4\n1 9\n1 5\n2 3\n1 6\n2 4\n3 4\n2 5\n1 7\n3 5\n4 5\n1 10\n1 2\n1 8", "1 5\n1 6\n2 4\n1 2\n3 4\n1 7\n1 3\n1 8\n2 5\n3 5\n4 5\n1 9\n2 3\n1 10\n1 4", "1 2\n1 3\n2 3\n1 4\n1 5", "1 2\n1 3\n2 3\n1 4\n2 4\n1 5", "-1", "-1", "2 3\n1 2\n1 3\n2 5\n2 4\n1 5\n3 4\n1 4", "2 3\n1 2\n1 3\n2 5\n2 4\n1 5\n3 4\n1 4", "-1", "1 2\n1 3\n2 3\n1 4\n2 4\n3 4\n1 5\n2 5\n3 5", "-1", "1 2\n1 3\n2 3\n1 4\n2 4\n3 4\n1 5\n2 5\n3 5\n4 5", "-1", "2 4\n1 9\n1 10\n3 4\n1 3\n1 5\n3 5\n1 7\n2 3\n2 5\n4 5\n1 4\n1 8\n1 6\n1 2", "-1", "2 3\n1 5\n1 4\n2 5\n1 8\n1 9\n1 2\n2 4\n1 7\n3 5\n1 6\n1 3\n1 10\n4 5\n3 4"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 8 | codeforces |
|
5881aa5d667ad0d66be9e421fbdb0c19 | Tanya and Postcard | Little Tanya decided to present her dad a postcard on his Birthday. She has already created a message β string *s* of length *n*, consisting of uppercase and lowercase English letters. Tanya can't write yet, so she found a newspaper and decided to cut out the letters and glue them into the postcard to achieve string *s*. The newspaper contains string *t*, consisting of uppercase and lowercase English letters. We know that the length of string *t* greater or equal to the length of the string *s*.
The newspaper may possibly have too few of some letters needed to make the text and too many of some other letters. That's why Tanya wants to cut some *n* letters out of the newspaper and make a message of length exactly *n*, so that it looked as much as possible like *s*. If the letter in some position has correct value and correct letter case (in the string *s* and in the string that Tanya will make), then she shouts joyfully "YAY!", and if the letter in the given position has only the correct value but it is in the wrong case, then the girl says "WHOOPS".
Tanya wants to make such message that lets her shout "YAY!" as much as possible. If there are multiple ways to do this, then her second priority is to maximize the number of times she says "WHOOPS". Your task is to help Tanya make the message.
The first line contains line *s* (1<=β€<=|*s*|<=β€<=2Β·105), consisting of uppercase and lowercase English letters β the text of Tanya's message.
The second line contains line *t* (|*s*|<=β€<=|*t*|<=β€<=2Β·105), consisting of uppercase and lowercase English letters β the text written in the newspaper.
Here |*a*| means the length of the string *a*.
Print two integers separated by a space:
- the first number is the number of times Tanya shouts "YAY!" while making the message, - the second number is the number of times Tanya says "WHOOPS" while making the message.
Sample Input
AbC
DCbA
ABC
abc
abacaba
AbaCaBA
Sample Output
3 0
0 3
3 4
| {"inputs": ["AbC\nDCbA", "ABC\nabc", "abacaba\nAbaCaBA", "zzzzz\nZZZZZ", "zzzZZZ\nZZZzzZ", "abcdefghijklmnopqrstuvwxyz\nABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz\nqrsimtabuvzhnwcdefgjklxyop", "l\nFPbAVjsMpPDTLkfwNYFmBDHPTDSWSOUlrBHYJHPM", "ncMeXssLHS\nuwyeMcaFatpInZVdEYpwJQSnVxLK", "DpiNBmCRFWxpdbfGOzvvOcemjructoAdEwegTvbVbfWWRPGyEAxGdDRWVlqNyGWMWHMrHAIZpyxvgaflrsVZhhZRouvpxrKXFZam\nwwPLFtNfPtJXvMLuHjKfYyaRhreNSWSzOvDpqHCGcqllACNPGHxReeFUCmAqIKXYytsSQwIxJzNiiUtgebVuwRmWpRALLyKAzyDPvgIGxALSaeeTIqm", "CCAE\ndcecc", "Dccb\nbeeeb", "Adc\neadeabcad", "DBAdeb\ndeeabcddadaa", "EDCED\neebeacdba", "CdAbD\ndecbde", "a\nB", "r\nqA"], "outputs": ["3 0", "0 3", "3 4", "0 5", "5 1", "0 26", "26 0", "1 0", "6 1", "66 12", "0 3", "1 0", "2 1", "3 2", "0 4", "2 2", "0 0", "0 0"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 88 | codeforces |
|
5892b69c55b4fe459e4286fdace16edf | Sort the Array | Being a programmer, you like arrays a lot. For your birthday, your friends have given you an array *a* consisting of *n* distinct integers.
Unfortunately, the size of *a* is too small. You want a bigger array! Your friends agree to give you a bigger array, but only if you are able to answer the following question correctly: is it possible to sort the array *a* (in increasing order) by reversing exactly one segment of *a*? See definitions of segment and reversing in the notes.
The first line of the input contains an integer *n* (1<=β€<=*n*<=β€<=105) β the size of array *a*.
The second line contains *n* distinct space-separated integers: *a*[1],<=*a*[2],<=...,<=*a*[*n*] (1<=β€<=*a*[*i*]<=β€<=109).
Print "yes" or "no" (without quotes), depending on the answer.
If your answer is "yes", then also print two space-separated integers denoting start and end (start must not be greater than end) indices of the segment to be reversed. If there are multiple ways of selecting these indices, print any of them.
Sample Input
3
3 2 1
4
2 1 3 4
4
3 1 2 4
2
1 2
Sample Output
yes
1 3
yes
1 2
no
yes
1 1
| {"inputs": ["3\n3 2 1", "4\n2 1 3 4", "4\n3 1 2 4", "2\n1 2", "2\n58 4", "5\n69 37 27 4 2", "9\n6 78 63 59 28 24 8 96 99", "6\n19517752 43452931 112792556 68417469 779722934 921694415", "6\n169793171 335736854 449917902 513287332 811627074 938727967", "6\n509329 173849943 297546987 591032670 796346199 914588283", "25\n46 45 37 35 26 25 21 19 11 3 1 51 54 55 57 58 59 62 66 67 76 85 88 96 100", "46\n10 12 17 19 20 21 22 24 25 26 27 28 29 30 32 37 42 43 47 48 50 51 52 56 87 86 81 79 74 71 69 67 66 65 60 59 57 89 91 92 94 96 97 98 99 100", "96\n1 2 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 68 69 70 71 72 73 74 75 76 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100", "2\n404928771 698395106", "2\n699573624 308238132", "5\n75531609 242194958 437796493 433259361 942142185", "5\n226959376 840957605 833410429 273566427 872976052", "5\n373362086 994096202 767275079 734424844 515504383", "5\n866379155 593548704 259097686 216134784 879911740", "5\n738083041 719956102 420866851 307749161 257917459", "5\n90786760 107075352 139104198 424911569 858427981", "6\n41533825 525419745 636375901 636653266 879043107 967434399", "40\n22993199 75843013 76710455 99749069 105296587 122559115 125881005 153961749 163646706 175409222 185819807 214465092 264449243 278246513 295514446 322935239 370349154 375773209 390474983 775646826 767329655 740310077 718820037 708508595 693119912 680958422 669537382 629123011 607511013 546574974 546572137 511951383 506996390 493995578 458256840 815612821 881161983 901337648 962275390 986568907", "40\n3284161 23121669 24630274 33434127 178753820 231503277 271972002 272578266 346450638 355655265 372217434 376132047 386622863 387235708 389799554 427160037 466577363 491873718 492746058 502535866 535768673 551570285 557477055 583643014 586216753 588981593 592960633 605923775 611051145 643142759 632768011 634888864 736715552 750574599 867737742 924365786 927179496 934453020 954090860 977765165", "40\n42131757 49645896 49957344 78716964 120937785 129116222 172128600 211446903 247833196 779340466 717548386 709969818 696716905 636153997 635635467 614115746 609201167 533608141 521874836 273044950 291514539 394083281 399369419 448830087 485128983 487192341 488673105 497678164 501864738 265305156 799595875 831638598 835155840 845617770 847736630 851436542 879757553 885618675 964068808 969215471", "40\n25722567 28250400 47661056 108729970 119887370 142272261 145287693 178946020 182917658 187405805 209478929 278713296 312035195 393514697 403876943 410188367 413061616 420619615 477231590 511200584 560288373 571690007 603093961 615463729 631624043 723138759 726089658 728151980 756393077 785590533 809755752 823601179 828357990 866942019 869575503 877310377 881382070 901314141 929048602 947139655", "40\n17927221 33153935 60257083 110553879 114654567 119809916 163899753 167741765 182812464 188486743 220036903 220127072 227545828 229552200 244963635 248298934 299478582 354141058 371400641 430054473 452548736 458695269 466968129 469000714 478004472 478693873 509342093 750631027 609759323 669427158 688490225 690701652 696893030 704668825 749028408 557906039 545356441 926901326 955586118 972642992", "4\n1 4 2 3", "6\n1 2 5 4 3 6", "1\n1", "6\n1 5 3 4 2 6", "4\n3 4 1 2", "5\n2 5 4 3 1", "4\n2 1 4 3", "6\n2 1 4 3 5 6"], "outputs": ["yes\n1 3", "yes\n1 2", "no", "yes\n1 1", "yes\n1 2", "yes\n1 5", "yes\n2 7", "yes\n3 4", "yes\n1 1", "yes\n1 1", "yes\n1 11", "yes\n25 37", "yes\n3 22", "yes\n1 1", "yes\n1 2", "yes\n3 4", "yes\n2 4", "yes\n2 5", "yes\n1 4", "yes\n1 5", "yes\n1 1", "yes\n1 1", "yes\n20 35", "no", "no", "yes\n1 1", "no", "no", "yes\n3 5", "yes\n1 1", "no", "no", "no", "no", "no"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 97 | codeforces |
|
5897bd968f90d3c87e025d3df2080b70 | Dominoes | During the break, we decided to relax and play dominoes. Our box with Domino was empty, so we decided to borrow the teacher's dominoes.
The teacher responded instantly at our request. He put *nm* dominoes on the table as an *n*<=Γ<=2*m* rectangle so that each of the *n* rows contained *m* dominoes arranged horizontally. Each half of each domino contained number (0 or 1).
We were taken aback, and the teacher smiled and said: "Consider some arrangement of dominoes in an *n*<=Γ<=2*m* matrix. Let's count for each column of the matrix the sum of numbers in this column. Then among all such sums find the maximum one. Can you rearrange the dominoes in the matrix in such a way that the maximum sum will be minimum possible? Note that it is prohibited to change the orientation of the dominoes, they all need to stay horizontal, nevertheless dominoes are allowed to rotate by 180 degrees. As a reward I will give you all my dominoes".
We got even more taken aback. And while we are wondering what was going on, help us make an optimal matrix of dominoes.
The first line contains integers *n*, *m* (1<=β€<=*n*,<=*m*<=β€<=103).
In the next lines there is a description of the teachers' matrix. Each of next *n* lines contains *m* dominoes. The description of one domino is two integers (0 or 1), written without a space β the digits on the left and right half of the domino.
Print the resulting matrix of dominoes in the format: *n* lines, each of them contains *m* space-separated dominoes.
If there are multiple optimal solutions, print any of them.
Sample Input
2 3
01 11 00
00 01 11
4 1
11
10
01
00
Sample Output
11 11 10
00 00 01
11
10
01
00
| {"inputs": ["2 3\n01 11 00\n00 01 11", "4 1\n11\n10\n01\n00", "1 1\n00", "1 1\n01", "1 1\n11", "9 9\n01 00 00 01 00 01 11 11 11\n10 10 10 01 10 01 11 01 10\n10 00 10 00 11 01 00 10 00\n01 00 01 01 11 00 00 11 11\n11 00 10 11 01 01 11 00 01\n01 10 00 00 11 10 01 01 10\n11 10 11 00 11 11 01 10 10\n10 00 01 00 00 00 11 01 01\n00 11 01 00 10 01 10 00 01", "9 9\n10 10 10 01 10 11 11 01 10\n11 00 10 10 11 10 01 00 00\n10 00 11 01 00 01 01 11 10\n10 11 10 00 01 11 11 10 11\n01 11 11 01 11 00 10 00 01\n01 00 00 10 01 01 10 00 01\n11 10 11 10 01 00 00 11 00\n10 11 10 10 01 10 10 10 01\n10 10 10 10 11 11 01 00 11", "9 1\n01\n00\n01\n01\n00\n00\n00\n01\n11", "2 9\n11 10 11 10 10 11 00 10 00\n10 00 00 10 10 00 11 01 01", "2 8\n10 01 01 11 10 10 01 10\n01 11 01 01 11 10 01 01", "3 5\n00 10 10 11 01\n11 01 11 11 10\n10 11 00 00 00", "2 3\n00 10 01\n01 01 00", "2 5\n01 00 01 01 00\n11 01 11 11 10"], "outputs": ["11 11 10\n00 00 01", "11\n10\n01\n00", "00", "10", "11", "11 11 11 11 11 11 11 11 11\n11 11 11 11 11 11 11 11 11\n10 10 10 10 10 10 10 10 10\n10 10 10 10 10 10 10 10 10\n10 10 10 01 01 01 01 01 01\n01 01 01 01 01 01 01 01 01\n01 01 01 00 00 00 00 01 01\n00 00 00 00 00 00 00 00 00\n00 00 00 00 00 00 00 00 00", "11 11 11 11 11 11 11 11 11\n11 11 11 11 11 11 11 11 11\n11 11 10 10 10 10 10 10 10\n10 10 10 10 10 10 10 10 10\n10 10 10 10 10 10 10 01 01\n01 01 01 01 01 01 01 01 01\n01 01 01 01 01 01 01 01 01\n00 00 00 00 01 01 01 00 00\n00 00 00 00 00 00 00 00 00", "11\n10\n10\n01\n01\n00\n00\n00\n00", "11 11 11 11 10 10 10 10 10\n00 00 00 00 00 01 01 01 01", "11 11 11 10 10 10 10 10\n10 10 01 01 01 01 01 01", "11 11 11 11 11\n10 10 10 01 01\n00 00 01 00 00", "10 10 01\n00 01 00", "11 11 11 10 10\n10 00 00 01 01"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces |
|
5898c00f01fa4b898400dca4b5772eea | Puzzles | Barney lives in country USC (United States of Charzeh). USC has *n* cities numbered from 1 through *n* and *n*<=-<=1 roads between them. Cities and roads of USC form a rooted tree (Barney's not sure why it is rooted). Root of the tree is the city number 1. Thus if one will start his journey from city 1, he can visit any city he wants by following roads.
Some girl has stolen Barney's heart, and Barney wants to find her. He starts looking for in the root of the tree and (since he is Barney Stinson not a random guy), he uses a random DFS to search in the cities. A pseudo code of this algorithm is as follows:
As told before, Barney will start his journey in the root of the tree (equivalent to call dfs(1)).
Now Barney needs to pack a backpack and so he wants to know more about his upcoming journey: for every city *i*, Barney wants to know the expected value of starting_time[i]. He's a friend of Jon Snow and knows nothing, that's why he asked for your help.
The first line of input contains a single integer *n* (1<=β€<=*n*<=β€<=105)Β β the number of cities in USC.
The second line contains *n*<=-<=1 integers *p*2,<=*p*3,<=...,<=*p**n* (1<=β€<=*p**i*<=<<=*i*), where *p**i* is the number of the parent city of city number *i* in the tree, meaning there is a road between cities numbered *p**i* and *i* in USC.
In the first and only line of output print *n* numbers, where *i*-th number is the expected value of starting_time[i].
Your answer for each city will be considered correct if its absolute or relative error does not exceed 10<=-<=6.
Sample Input
7
1 2 1 1 4 4
12
1 1 2 2 4 4 3 3 1 10 8
Sample Output
1.0 4.0 5.0 3.5 4.5 5.0 5.0
1.0 5.0 5.5 6.5 7.5 8.0 8.0 7.0 7.5 6.5 7.5 8.0
| {"inputs": ["7\n1 2 1 1 4 4", "12\n1 1 2 2 4 4 3 3 1 10 8", "3\n1 2", "8\n1 1 2 2 3 6 1", "85\n1 1 2 2 4 6 1 3 6 3 3 11 9 14 12 5 8 11 16 19 12 17 2 19 1 24 6 2 6 6 24 3 20 1 1 1 17 8 4 25 31 32 39 12 35 23 31 26 46 9 37 7 5 23 41 41 39 9 11 54 36 54 28 15 25 58 56 18 23 70 68 18 3 48 57 70 15 65 22 35 25 13 49 34", "1", "2\n1", "10\n1 2 2 2 5 4 6 5 6"], "outputs": ["1.0 4.0 5.0 3.5 4.5 5.0 5.0 ", "1.0 5.0 5.5 6.5 7.5 8.0 8.0 7.0 7.5 6.5 7.5 8.0 ", "1.0 2.0 3.0 ", "1.0 4.0 4.0 5.5 5.5 5.0 6.0 5.0 ", "1.0 28.5 27.0 38.0 38.5 39.5 44.5 40.0 40.5 45.0 37.0 40.5 44.0 42.5 43.5 43.0 41.0 43.0 39.5 44.0 45.0 44.0 42.5 42.5 41.0 42.5 44.5 44.5 44.0 45.0 43.5 44.0 44.0 45.0 42.0 43.0 43.0 45.0 42.5 44.5 43.0 45.5 45.0 44.5 44.5 43.5 45.5 45.0 43.5 44.5 44.5 44.0 45.5 43.5 45.5 45.0 45.5 44.0 44.5 44.5 45.0 44.0 45.0 45.5 45.0 45.5 45.0 46.0 44.5 44.5 46.0 47.0 44.5 44.0 46.0 46.5 46.0 45.5 46.0 45.0 44.0 45.5 45.0 44.5 46.0 ", "1.0 ", "1.0 2.0 ", "1.0 2.0 6.5 6.0 4.5 6.0 7.0 7.5 7.0 7.5 "]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 9 | codeforces |
|
58a83557040dfdbc385a042906d45d1f | Wrong Subtraction | Little girl Tanya is learning how to decrease a number by one, but she does it wrong with a number consisting of two or more digits. Tanya subtracts one from a number by the following algorithm:
- if the last digit of the number is non-zero, she decreases the number by one; - if the last digit of the number is zero, she divides the number by 10 (i.e. removes the last digit).
You are given an integer number $n$. Tanya will subtract one from it $k$ times. Your task is to print the result after all $k$ subtractions.
It is guaranteed that the result will be positive integer number.
The first line of the input contains two integer numbers $n$ and $k$ ($2 \le n \le 10^9$, $1 \le k \le 50$) β the number from which Tanya will subtract and the number of subtractions correspondingly.
Print one integer number β the result of the decreasing $n$ by one $k$ times.
It is guaranteed that the result will be positive integer number.
Sample Input
512 4
1000000000 9
Sample Output
50
1
| {"inputs": ["512 4", "1000000000 9", "131203 11", "999999999 50", "999999999 49", "131203 9", "900000000 16", "909090909 50", "1001 2", "5 2", "2 1"], "outputs": ["50", "1", "12", "9999", "99990", "130", "1", "3", "100", "3", "1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 428 | codeforces |
|
58af402ad60c89300051482d9084e5a8 | Minimum Ternary String | You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For example, for string "010210" we can perform the following moves:
- "010210" $\rightarrow$ "100210"; - "010210" $\rightarrow$ "001210"; - "010210" $\rightarrow$ "010120"; - "010210" $\rightarrow$ "010201".
Note than you cannot swap "02" $\rightarrow$ "20" and vice versa. You cannot perform any other operations with the given string excluding described above.
You task is to obtain the minimum possible (lexicographically) string by using these swaps arbitrary number of times (possibly, zero).
String $a$ is lexicographically less than string $b$ (if strings $a$ and $b$ have the same length) if there exists some position $i$ ($1 \le i \le |a|$, where $|s|$ is the length of the string $s$) such that for every $j < i$ holds $a_j = b_j$, and $a_i < b_i$.
The first line of the input contains the string $s$ consisting only of characters '0', '1' and '2', its length is between $1$ and $10^5$ (inclusive).
Print a single string β the minimum possible (lexicographically) string you can obtain by using the swaps described above arbitrary number of times (possibly, zero).
Sample Input
100210
11222121
20
Sample Output
001120
11112222
20
| {"inputs": ["100210", "11222121", "20", "1002", "10", "000021", "021", "2", "201", "2112120", "102", "202", "220201", "12", "100022202", "01", "1"], "outputs": ["001120", "11112222", "20", "0012", "01", "000012", "012", "2", "120", "1112220", "012", "202", "122020", "12", "000122202", "01", "1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 151 | codeforces |
|
58bb01f8136f320b940058018a44f47c | Design Tutorial: Learn from Math | One way to create a task is to learn from math. You can generate some random math statement or modify some theorems to get something new and build a new task from that.
For example, there is a statement called the "Goldbach's conjecture". It says: "each even number no less than four can be expressed as the sum of two primes". Let's modify it. How about a statement like that: "each integer no less than 12 can be expressed as the sum of two composite numbers." Not like the Goldbach's conjecture, I can prove this theorem.
You are given an integer *n* no less than 12, express it as a sum of two composite numbers.
The only line contains an integer *n* (12<=β€<=*n*<=β€<=106).
Output two composite integers *x* and *y* (1<=<<=*x*,<=*y*<=<<=*n*) such that *x*<=+<=*y*<==<=*n*. If there are multiple solutions, you can output any of them.
Sample Input
12
15
23
1000000
Sample Output
4 8
6 9
8 15
500000 500000
| {"inputs": ["12", "15", "23", "1000000", "63874", "14568", "192", "86", "46220", "57114", "869", "738457", "58113", "4864", "15", "74752", "6073", "1289", "20", "58134", "57756", "765", "59", "991666", "70761", "13", "999999", "17", "21", "19", "100007", "999987", "22"], "outputs": ["4 8", "6 9", "8 15", "500000 500000", "4 63870", "4 14564", "4 188", "4 82", "4 46216", "4 57110", "4 865", "4 738453", "6 58107", "4 4860", "6 9", "4 74748", "4 6069", "4 1285", "4 16", "4 58130", "4 57752", "6 759", "4 55", "4 991662", "4 70757", "4 9", "4 999995", "8 9", "6 15", "4 15", "6 100001", "6 999981", "4 18"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 597 | codeforces |
|
58c5d42231d8ef54d85d53c0d3311e95 | Appleman and Toastman | Appleman and Toastman play a game. Initially Appleman gives one group of *n* numbers to the Toastman, then they start to complete the following tasks:
- Each time Toastman gets a group of numbers, he sums up all the numbers and adds this sum to the score. Then he gives the group to the Appleman. - Each time Appleman gets a group consisting of a single number, he throws this group out. Each time Appleman gets a group consisting of more than one number, he splits the group into two non-empty groups (he can do it in any way) and gives each of them to Toastman.
After guys complete all the tasks they look at the score value. What is the maximum possible value of score they can get?
The first line contains a single integer *n* (1<=β€<=*n*<=β€<=3Β·105). The second line contains *n* integers *a*1, *a*2, ..., *a**n* (1<=β€<=*a**i*<=β€<=106) β the initial group that is given to Toastman.
Print a single integer β the largest possible score.
Sample Input
3
3 1 5
1
10
Sample Output
26
10
| {"inputs": ["3\n3 1 5", "1\n10", "10\n8 10 2 5 6 2 4 7 2 1", "10\n171308 397870 724672 431255 228496 892002 542924 718337 888642 161821", "10\n1 2 2 2 4 5 6 7 8 10", "10\n161821 171308 228496 397870 431255 542924 718337 724672 888642 892002", "1\n397870", "1\n1000000", "10\n10 8 7 6 5 4 2 2 2 1", "10\n892002 888642 724672 718337 542924 431255 397870 228496 171308 161821", "10\n5 2 6 10 10 10 10 2 2 5", "10\n431255 724672 228496 397870 397870 397870 397870 724672 888642 431255", "10\n2 2 2 5 5 6 10 10 10 10", "10\n228496 397870 397870 397870 397870 431255 431255 724672 724672 888642", "10\n10 10 10 10 6 5 5 2 2 2", "10\n888642 724672 724672 431255 431255 397870 397870 397870 397870 228496", "10\n10 10 10 10 10 10 10 10 10 10", "10\n1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000", "1\n397870", "2\n1 2", "2\n2 3", "2\n1 1"], "outputs": ["26", "10", "376", "40204082", "376", "40204082", "397870", "1000000", "376", "40204082", "485", "36742665", "485", "36742665", "485", "36742665", "640", "64000000", "397870", "6", "10", "4"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 503 | codeforces |
|
58c677856c4b02ac52a4fc953812e4cd | Longest Subsequence | You are given array *a* with *n* elements and the number *m*. Consider some subsequence of *a* and the value of least common multiple (LCM) of its elements. Denote LCM as *l*. Find any longest subsequence of *a* with the value *l*<=β€<=*m*.
A subsequence of *a* is an array we can get by erasing some elements of *a*. It is allowed to erase zero or all elements.
The LCM of an empty array equals 1.
The first line contains two integers *n* and *m* (1<=β€<=*n*,<=*m*<=β€<=106) β the size of the array *a* and the parameter from the problem statement.
The second line contains *n* integers *a**i* (1<=β€<=*a**i*<=β€<=109) β the elements of *a*.
In the first line print two integers *l* and *k**max* (1<=β€<=*l*<=β€<=*m*,<=0<=β€<=*k**max*<=β€<=*n*) β the value of LCM and the number of elements in optimal subsequence.
In the second line print *k**max* integers β the positions of the elements from the optimal subsequence in the ascending order.
Note that you can find and print any subsequence with the maximum length.
Sample Input
7 8
6 2 9 2 7 2 3
6 4
2 2 2 3 3 3
Sample Output
6 5
1 2 4 6 7
2 3
1 2 3
| {"inputs": ["7 8\n6 2 9 2 7 2 3", "6 4\n2 2 2 3 3 3", "10 50\n39 22 60 88 11 65 41 85 65 100", "100 343\n999 284 486 785 176 742 856 415 992 601 600 122 460 214 338 92 627 913 376 835 384 914 335 179 409 957 96 784 531 43 584 206 971 799 592 801 870 978 437 517 466 952 1 327 731 689 816 681 383 969 452 298 114 687 314 436 267 154 827 197 805 207 284 550 351 700 94 567 524 329 414 561 284 666 702 226 793 814 3 133 115 67 981 807 5 471 146 19 349 168 850 623 952 734 836 925 155 580 280 291", "1 1\n2", "7 1\n6 2 9 2 7 2 3", "5 1\n5 4 3 2 6", "5 1\n5 4 6 2 5", "3 5\n5 7 9", "2 2\n3 5", "2 1\n2 2", "1 3\n5", "1 2\n3", "10 1\n2 3 2 4 2 3 4 4 2 3", "5 1\n2 3 4 5 6", "3 1\n3 3 3", "5 1\n4 5 6 7 8", "2 10\n14 15", "3 10\n11 13 17", "1 1\n1024", "1 1\n333", "1 5\n4321", "1 1\n1234", "1 1\n2000", "1 1\n2222", "1 3\n2", "4 1\n2 3 4 5", "1 1000000\n1234", "1 1000000\n1", "1 6\n5"], "outputs": ["6 5\n1 2 4 6 7", "2 3\n1 2 3", "22 2\n2 5", "114 4\n43 53 79 88", "1 0", "1 0", "1 0", "1 0", "5 1\n1", "1 0", "1 0", "1 0", "1 0", "1 0", "1 0", "1 0", "1 0", "1 0", "1 0", "1 0", "1 0", "1 0", "1 0", "1 0", "1 0", "2 1\n1", "1 0", "1234 1\n1", "1 1\n1", "5 1\n1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces |
|
58d9c92f6edcd490cef2fee5f38142a7 | Weather | Scientists say a lot about the problems of global warming and cooling of the Earth. Indeed, such natural phenomena strongly influence all life on our planet.
Our hero Vasya is quite concerned about the problems. He decided to try a little experiment and observe how outside daily temperature changes. He hung out a thermometer on the balcony every morning and recorded the temperature. He had been measuring the temperature for the last *n* days. Thus, he got a sequence of numbers *t*1,<=*t*2,<=...,<=*t**n*, where the *i*-th number is the temperature on the *i*-th day.
Vasya analyzed the temperature statistics in other cities, and came to the conclusion that the city has no environmental problems, if first the temperature outside is negative for some non-zero number of days, and then the temperature is positive for some non-zero number of days. More formally, there must be a positive integer *k* (1<=β€<=*k*<=β€<=*n*<=-<=1) such that *t*1<=<<=0,<=*t*2<=<<=0,<=...,<=*t**k*<=<<=0 and *t**k*<=+<=1<=><=0,<=*t**k*<=+<=2<=><=0,<=...,<=*t**n*<=><=0. In particular, the temperature should never be zero. If this condition is not met, Vasya decides that his city has environmental problems, and gets upset.
You do not want to upset Vasya. Therefore, you want to select multiple values of temperature and modify them to satisfy Vasya's condition. You need to know what the least number of temperature values needs to be changed for that.
The first line contains a single integer *n* (2<=β€<=*n*<=β€<=105) β the number of days for which Vasya has been measuring the temperature.
The second line contains a sequence of *n* integers *t*1,<=*t*2,<=...,<=*t**n* (|*t**i*|<=β€<=109) β the sequence of temperature values. Numbers *t**i* are separated by single spaces.
Print a single integer β the answer to the given task.
Sample Input
4
-1 1 -2 1
5
0 -1 1 2 -5
Sample Output
1
2
| {"inputs": ["4\n-1 1 -2 1", "5\n0 -1 1 2 -5", "6\n0 0 0 0 0 0", "6\n-1 -2 -3 -4 5 6", "8\n1 2 -1 0 10 2 12 13", "7\n-1 -2 -3 3 -1 3 4", "2\n3 -5", "50\n4 -8 0 -1 -3 -9 0 -2 0 1 -1 0 7 -10 9 7 0 -10 5 0 1 -6 9 -9 3 -3 3 7 4 -8 -8 3 3 -1 0 2 -6 10 7 -1 -6 -3 -4 2 3 0 -4 0 7 -9", "90\n52 -89 17 64 11 -61 92 51 42 -92 -14 -100 21 -88 73 -11 84 72 -80 -78 5 -70 -70 80 91 -89 87 -74 63 -79 -94 52 82 79 81 40 69 -15 33 -52 18 30 -39 99 84 -98 44 69 -75 0 60 -89 51 -92 83 73 16 -43 17 0 51 9 -53 86 86 -50 0 -80 3 0 86 0 -76 -45 0 -32 45 81 47 15 -62 21 4 -82 77 -67 -64 -12 0 -50", "10\n-19 -29 -21 -6 29 89 -74 -22 18 -13", "100\n-782 365 -283 769 -58 224 1000 983 7 595 -963 -267 -934 -187 -609 693 -316 431 859 -753 865 -421 861 -728 -793 621 -311 414 -101 -196 120 84 633 -362 989 94 206 19 -949 -629 489 376 -391 165 50 22 -209 735 565 61 -321 -256 890 34 343 -326 984 -268 -609 385 717 81 372 -391 271 -89 297 -510 797 -425 -276 573 510 560 165 -482 511 541 -491 60 168 -805 235 -657 -679 -617 -212 816 -98 901 380 103 608 -257 -643 333 8 355 743 -801"], "outputs": ["1", "2", "6", "0", "3", "1", "2", "26", "42", "3", "40"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 32 | codeforces |
|
58dd3c2180285dbfc243479705c44459 | none | In the capital city of Berland, Bertown, demonstrations are against the recent election of the King of Berland. Berland opposition, led by Mr. Ovalny, believes that the elections were not fair enough and wants to organize a demonstration at one of the squares.
Bertown has *n* squares, numbered from 1 to *n*, they are numbered in the order of increasing distance between them and the city center. That is, square number 1 is central, and square number *n* is the farthest from the center. Naturally, the opposition wants to hold a meeting as close to the city center as possible (that is, they want an square with the minimum number).
There are exactly *k* (*k*<=<<=*n*) days left before the demonstration. Now all squares are free. But the Bertown city administration never sleeps, and the approval of an application for the demonstration threatens to become a very complex process. The process of approval lasts several days, but every day the following procedure takes place:
- The opposition shall apply to hold a demonstration at a free square (the one which isn't used by the administration). - The administration tries to move the demonstration to the worst free square left. To do this, the administration organizes some long-term activities on the square, which is specified in the application of opposition. In other words, the administration starts using the square and it is no longer free. Then the administration proposes to move the opposition demonstration to the worst free square. If the opposition has applied for the worst free square then request is accepted and administration doesn't spend money. If the administration does not have enough money to organize an event on the square in question, the opposition's application is accepted. If administration doesn't have enough money to organize activity, then rest of administration's money spends and application is accepted - If the application is not accepted, then the opposition can agree to the administration's proposal (that is, take the worst free square), or withdraw the current application and submit another one the next day. If there are no more days left before the meeting, the opposition has no choice but to agree to the proposal of City Hall. If application is accepted opposition can reject it. It means than opposition still can submit more applications later, but square remains free.
In order to organize an event on the square *i*, the administration needs to spend *a**i* bourles. Because of the crisis the administration has only *b* bourles to confront the opposition. What is the best square that the opposition can take, if the administration will keep trying to occupy the square in question each time? Note that the administration's actions always depend only on the actions of the opposition.
The first line contains two integers *n* and *k* β the number of squares and days left before the meeting, correspondingly (1<=β€<=*k*<=<<=*n*<=β€<=105).
The second line contains a single integer *b* β the number of bourles the administration has (1<=β€<=*b*<=β€<=1018).
The third line contains *n* space-separated integers *a**i* β the sum of money, needed to organise an event on square *i* (1<=β€<=*a**i*<=β€<=109).
Please, do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier.
Print a single number β the minimum number of the square where the opposition can organize the demonstration.
Sample Input
5 2
8
2 4 5 3 1
5 2
8
3 2 4 1 5
5 4
1000000000000000
5 4 3 2 1
Sample Output
2
5
5
| {"inputs": ["5 2\n8\n2 4 5 3 1", "5 2\n8\n3 2 4 1 5", "5 4\n1000000000000000\n5 4 3 2 1", "10 1\n55\n45 55 61 64 95 95 98 96 65 81", "10 6\n462\n33 98 95 82 91 63 61 51 68 94", "10 4\n38080\n15 3005 4725 1952 8761 8797 9712 9752 9858 9128", "10 9\n46660\n724 2304 7793 7049 7847 5593 4685 7971 2701 5643", "100 50\n42431\n206 579 445 239 166 627 37 583 183 87 172 608 573 235 584 29 429 51 264 334 593 493 265 660 106 312 655 292 647 75 130 521 367 191 460 323 544 176 338 495 346 663 922 943 839 790 977 849 927 744 869 733 717 692 873 838 941 701 777 835 986 924 667 888 883 690 712 864 921 921 912 937 958 992 931 779 708 794 906 863 933 780 823 774 733 806 987 682 819 777 668 733 762 691 799 781 671 910 896 860", "100 25\n21341\n129 396 227 144 72 443 77 406 192 199 293 171 331 3 243 204 191 9 261 328 60 37 105 158 305 308 411 247 216 226 290 145 254 166 352 194 471 638 729 868 769 901 654 728 526 477 546 753 750 790 514 870 808 989 711 688 718 909 687 788 733 776 875 548 946 950 809 489 539 664 961 511 781 570 811 977 686 522 533 785 708 739 515 738 753 837 841 516 867 828 534 523 855 794 602 477 590 868 938 489", "10 1\n290\n225 78 199 283 168 287 442 990 833 465", "10 1\n297\n215 281 102 280 243 225 294 296 7383 2623", "10 2\n192\n5 17 85 100 98 93 99 99 90 93", "10 2\n1523\n661 230 363 300 28 72 676 741 837 984", "10 2\n16658\n5957 5343 3495 7042 9622 7999 7503 9560 7661 8345", "10 3\n160\n23 11 11 18 3 26 31 81 53 79", "10 3\n1791\n168 140 21 1 64 222 577 665 911 479", "10 3\n16915\n437 1210 634 1320 5344 7913 7249 6798 7688 2030", "10 4\n300\n53 17 39 24 66 97 70 68 67 77", "10 4\n1834\n11 44 49 420 93 653 306 596 535 842", "10 5\n307\n2 3 93 45 88 8 39 26 71 96", "10 5\n3495\n361 539 81 67 479 594 641 932 787 810", "10 5\n32004\n2343 3657 286 4040 558 5509 6547 7213 8696 7885", "10 6\n3773\n295 266 340 728 664 763 623 349 662 697", "10 6\n59489\n5112 4734 9786 9997 9960 9801 9921 9863 9963 9889", "10 7\n621\n18 73 87 74 93 87 98 98 90 100", "10 7\n6704\n885 999 993 951 955 890 927 987 942 929", "10 7\n60174\n2528 2832 5927 8115 9631 9101 9932 9076 8392 8264", "10 8\n358\n10 15 20 36 30 73 55 86 39 18", "10 8\n6569\n328 712 854 844 712 919 804 931 789 732", "10 8\n47953\n811 8835 5410 4894 8801 2378 6377 9978 2847 9118", "10 9\n624\n47 56 60 51 88 82 77 83 89 100", "10 9\n4916\n258 290 341 342 756 963 758 530 674 665", "100 10\n9199\n89 409 428 408 309 400 259 393 212 273 472 654 533 774 663 484 695 801 587 518 521 578 767 644 532 785 500 944 582 680 899 882 589 601 614 633 877 543 770 614 852 715 932 627 639 658 765 957 898 545 977 751 740 869 885 831 834 702 934 954 500 626 605 921 755 661 707 952 842 978 979 879 837 581 595 638 829 725 571 899 753 800 747 942 782 517 915 594 981 918 549 628 804 989 966 806 806 882 860 496", "100 70\n62082\n355 462 474 218 753 303 494 424 356 688 69 38 759 975 844 789 959 855 989 902 838 931 939 970 795 832 846 997 919 832 830 827 935 761 795 898 770 887 840 906 833 807 903 871 772 949 926 867 941 933 819 853 805 901 871 907 847 832 950 900 833 764 944 937 804 823 793 785 902 822 793 932 896 981 827 862 767 852 934 806 818 846 786 963 851 790 781 819 948 764 994 820 948 962 892 845 875 856 866 832", "5 2\n11\n8 2 3 4 5"], "outputs": ["2", "5", "5", "3", "1", "5", "1", "43", "38", "7", "9", "4", "8", "4", "7", "6", "4", "5", "4", "3", "10", "4", "3", "3", "2", "1", "10", "10", "10", "2", "1", "10", "11", "14", "1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces |
|
58e042e2444f9dd4fa27b74cbe69e58f | Beautiful numbers | Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if and only if it is divisible by each of its nonzero digits. We will not argue with this and just count the quantity of beautiful numbers in given ranges.
The first line of the input contains the number of cases *t* (1<=β€<=*t*<=β€<=10). Each of the next *t* lines contains two natural numbers *l**i* and *r**i* (1<=β€<=*l**i*<=β€<=*r**i*<=β€<=9<=Β·1018).
Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cin (also you may use %I64d).
Output should contain *t* numbers β answers to the queries, one number per line β quantities of beautiful numbers in given intervals (from *l**i* to *r**i*, inclusively).
Sample Input
1
1 9
1
12 15
Sample Output
9
2
| {"inputs": ["1\n1 9", "1\n12 15", "1\n25 53", "1\n1 1000", "1\n1 100000", "2\n234 59843\n46 3243", "4\n55 55\n1234 2348\n620 620\n4 1000", "1\n1 9000000000000000000", "5\n5397562498 1230483490253448\n39218765 5293867493184739\n99 999999999999\n546234 2394748365397856\n67 801834", "3\n1 1\n9000000000000000000 9000000000000000000\n8999999999999999999 8999999999999999999", "9\n357816591093473912 478906145736655650\n154072099530098530 297675544560923083\n853274171983555776 877332810632329118\n258601077826366175 856890041027686262\n151084241340128367 868279055062218946\n360302714872207562 400114081267420149\n15181634044326791 602401427137909762\n85295343866069509 372373854804747278\n61825864286248332 820583114541565140", "7\n104609317611013150 341289880328203892\n97241912027543222 314418300699926877\n53441135299739439 389735416311904624\n275391517859532788 467960038909170238\n304318532879803217 768089672739846481\n319824835697587963 736305171087865698\n409387390360731466 545771099640557323", "9\n445541835776354804 558734188486271358\n73682036065176542 366947184576839560\n308564620247881013 586289290590337947\n191966067909858814 427579642915908767\n96549472115040860 524715559221512354\n255020036710938147 654502276995773879\n80176357776022017 657344223781591909\n16719475415528318 443326279724654990\n338052544981592129 686095491515876947", "8\n423727899203401096 465066089007515233\n592099166919122847 693326943315408193\n231531173552972562 531446476635170028\n716633579315369700 812280907158531602\n418627020920440527 499027876613131004\n163898261665251882 822784355862669948\n435839418352342371 467127616759016838\n485096651053655121 650414421921269042", "10\n317170715064111090 793355628628194180\n739156054415396992 777408930205278114\n190203742284298612 871433095584843953\n299464632866349604 887366147454183925\n604292320992752545 686849525965889579\n671343144075216807 887426356575285220\n29419076620738966 587651333431204877\n623639325649517323 649463206025796889\n433988870372201677 826343090001917979\n59211672688034983 185391377687885100", "10\n284628591358250298 646259693733499061\n124314877444536921 158360653417589331\n294802485707819594 348409229744008981\n600000720865727637 612539571868349067\n43148541126130378 706710122330555006\n623654284391810432 864058024613618266\n96275043624390708 878551347136533260\n101314040620664356 877345387577542422\n330459790968153544 396766608075635018\n437750508922390426 606265056174456186", "2\n699477065952458657 872009205627849715\n125384274193311446 322714849067940236", "5\n287022480899155515 575607276198133575\n269577246853440756 493029962385944199\n33867048981266469 753806197266881614\n122720683292361468 585860767594869710\n158415500607290576 291208960498755656", "7\n256594007991864539 522344824090301945\n244974983299956912 369564779245483014\n389003124143900342 870218470015550418\n195460950995683388 651270783906429493\n346224221518880818 866785151789106062\n253038155332981304 335508507616974071\n90600597989420506 233249608331610512", "4\n1316690822130409 43473794526140271\n31324963681870844 400596320533679208\n145052817797209833 830063350205257021\n158658407621553147 888417552777282422", "5\n54466217578737820 199602944107455170\n590840692238108171 845011715230237399\n13556617965656361 472040489988635161\n714035286668109810 850408020486632812\n300350088832329391 447391742372023290", "5\n319233236657111501 439203315902660433\n576536153378125966 581498392015228293\n211896470192814609 802604291686025035\n276426676181343125 621591075446200211\n508640487982063778 534483221559283380", "2\n109665811875257879 257740418232519221\n604210587139443191 625314575765100157", "6\n268178188710040742 576988663070502189\n504550929759464987 781375970672533626\n383664952430952316 634627265571145187\n32079280703703870 854176930200007145\n91332009005179043 184053275183946180\n40615673830587752 81118443341384874", "6\n302303335070090868 450003809972976938\n38797475097975886 362745244153909054\n255979212134580442 584044352113226014\n296314585958572870 577227175635398364\n62422561943575682 256080854477707325\n211472647017729730 238012961902478501", "2\n682002069204224661 741697951489458142\n183681502765856661 640437699585130293", "10\n139335835151468925 484066860116557425\n263442856552254877 313125870358044935\n251857673095776569 867489314560690117\n537516700522410653 723282616279678271\n395380521908450082 806672097008414136\n235871329996145263 884796582724269557\n534443148879117170 654182410587394685\n380572226198783846 879140470933346585\n44215071468435238 258286912303970378\n26312939052691831 729014058195540988", "1\n409932656755767888 555182693984224688", "5\n85486498031991129 609519488362467658\n580104402950188545 585551649929612890\n266889485749089795 290577696596475568\n29875185901092149 120388080236728441\n287513302314456963 523308494771522710", "5\n19182336056148152 208792307948641418\n679752014854666194 698235312605408252\n171120031998422805 569721388031168451\n12148793149507654 583293559019372679\n132953494234881925 342019770688732055", "1\n290788238061324166 326414205793715944", "5\n234980802136837794 678684394174931737\n379107007207217021 898625960325636363\n299786954727403405 471077420542543174\n128226582798019699 763298680395163050\n211161692546607273 384187742288440244", "5\n89021901785536018 721970357006512096\n10455209854982 672121404159230388\n177585137659819353 575574850046871820\n65145962073623720 680133228947272669\n391876042757036995 669425246021613653", "7\n759792714318263446 835705573208322900\n460742320949633715 470758694665495415\n415505837605910991 569430654167207205\n377168676014875291 658290859272415183\n283793404702060566 304952201274598832\n511204209665235974 673646757429123938\n204114397228198672 797985176265960222", "9\n84911486803129062 371360395960886607\n215284546951446780 821388426823792006\n166750422723367513 332960369043386392\n656713493264874130 830533243210221453\n279192318807285719 846434989742407222\n184571653844680221 502821438236701008\n158613676606887401 202707248716070578\n57540730334410124 60880782285483617\n180003597833276637 824443392811852241", "8\n57710938094283125 133772303709577393\n225971608986591641 527160269434785752\n326606700768403490 501974015736773213\n104238980296659530 597665360857507536\n129585992859086273 782985334217822917\n95949900165719335 509445717207521416\n282373530338110359 395331940454914825\n109101574779985403 119360877564462401", "6\n143809081082381724 710709485503956307\n477002227475791129 748415761498654762\n194250190495612708 722691609433551584\n75162568328377570 286478648363940215\n167009103400266860 565869134050802277\n502744098916587217 886107958887143606", "7\n44244599058777278 782140424182656491\n253187103338885776 695335736560569599\n29699011635943174 255027033171638318\n620123105021375390 632580504164439237\n15375925200954959 514151645969327190\n543405682133478575 609214152593311339\n319215262961370608 516830493012444317", "9\n126345625290218706 784850219000022089\n87023426041824251 129119697169349357\n115069371829617205 505544318183729913\n101524249349082603 410056021854163969\n365868821220246374 407398810119575711\n430453801123321243 449066562720974247\n343735112634641611 864077546788537811\n40949324306296116 718988450894528392\n374523541044751782 624503429430134549", "6\n628054167404305809 628631960105352883\n76614448048985164 664591413517666821\n262907302737145633 436561742851767924\n546542973469933497 609783019570052293\n144878328150224178 587802477340215629\n418802873287839235 492960279487924481", "4\n314756235091775713 527675415702104393\n262211905544992553 474539845101486132\n650849880923001511 686127592579746738\n302723886566715571 800643954239584448", "10\n459047565386426124 557194352219781174\n334174633100816445 574518777618872908\n339256617206207374 461702378236276473\n588718051366049429 591583237944573629\n279503563837328065 787989497738844701\n21523491428669060 804432015267107086\n176599362925115382 372462231016537122\n86537781617987114 189304598553178698\n752344156097144261 806368993421691027\n823292318017906645 846671299523066080", "8\n235988693924367721 871763392821283031\n831354122145544757 897628959367475233\n208456624263360265 304233837602695736\n564455930754426325 747724855342153655\n733111142906877033 788390309965048178\n105753118324937331 227328301612681221\n89981956803108752 608240082487490427\n247970213583436454 274499034399377923", "3\n106944629644846234 868784028501976520\n609893146415774201 829549590949963820\n280831004762390139 860314575937399777", "6\n43993555587390686 472396927744198873\n166115563323012274 740944002931589125\n745385119308013664 778824408151010477\n298307917637500505 739076799736050705\n270559504032562580 324248373286245715\n445587297201428883 453886541051311950", "7\n617593704688843596 828119736217232389\n3293204449283890 690109219324558805\n175366679625274382 211592984052182604\n134013605241468389 156621244614592310\n87651424533962276 294531661482220423\n652576309304110648 855895695568516689\n477666266196006205 647707658685159920", "10\n50041481631208215 447762572637187951\n168215116153505310 514436306319509511\n247862097199125155 712191937735295742\n98125769392212035 345332927057490352\n351553192787723038 775772738657478138\n412742092029203073 627638533260248401\n196268314021034051 765318785061421414\n129127817256091656 848467628311779115\n209408331444736026 477286893553657979\n199077079465747558 382720611537297379", "9\n360616474860484616 383999497202599749\n309747278163068128 324627518197345788\n37810933547908346 442701859960681398\n206321505581033547 517952468011059058\n830707273735965413 838545144291501943\n481064567699374119 637860173392597272\n64724838137416918 401453198057895626\n90969763647055934 161655002682127994\n832701350006309129 863335897035281262", "2\n17998572321587853 467288454221606647\n123156820907183052 834785732165266684", "1\n1 999999999999999999", "1\n191919191919191919 919191919191919191", "10\n7090909090909090909 8191919191919191919\n7090909090909090909 8191919191919191919\n7090909090909090909 8191919191919191919\n7090909090909090909 8191919191919191919\n7090909090909090909 8191919191919191919\n7090909090909090909 8191919191919191919\n7090909090909090909 8191919191919191919\n7090909090909090909 8191919191919191919\n7090909090909090909 8191919191919191919\n7090909090909090909 8191919191919191919", "10\n5555555555555555555 5555555555555555555\n5555555555555555555 5555555555555555555\n5555555555555555555 5555555555555555555\n5555555555555555555 5555555555555555555\n5555555555555555555 5555555555555555555\n5555555555555555555 5555555555555555555\n5555555555555555555 5555555555555555555\n5555555555555555555 5555555555555555555\n5555555555555555555 5555555555555555555\n5555555555555555555 5555555555555555555", "6\n312118719 8999999999291228845\n667149650 8999999999517267203\n913094187 8999999999725405253\n154899869 8999999999515635472\n17006149 8999999999611234564\n557783437 8999999999450461526", "3\n49395813 8999999999232681026\n130560985 8999999999732049698\n561847056 8999999999660238105", "5\n988020422 8999999999820367297\n146385894 8999999999144649284\n647276749 8999999999118469703\n545904849 8999999999653000715\n66157176 8999999999517239977", "4\n159528081 8999999999254686152\n155140195 8999999999221118378\n573463040 8999999999924740913\n984536526 8999999999076714216", "10\n79746525 8999999999623095709\n107133428 8999999999011808285\n395554969 8999999999078624899\n617453363 8999999999094258969\n152728928 8999999999672481523\n252006040 8999999999766225306\n547017602 8999999999444173567\n765495515 8999999999421300177\n974820465 8999999999294163554\n560970841 8999999999720023934", "8\n989660313 8999999999396148104\n74305000 8999999999742113337\n122356523 8999999999305515797\n592472806 8999999999132041329\n241537546 8999999999521843612\n885836059 8999999999480097833\n636266002 8999999999732372739\n202992959 8999999999981938988", "6\n367798644 8999999999638151319\n332338496 8999999999040457114\n623242741 8999999999949105799\n531142995 8999999999535909314\n717090981 8999999999596647230\n158402883 8999999999599697481", "5\n956765583 8999999999016337994\n370504871 8999999999584832832\n419407328 8999999999309673477\n518267114 8999999999030078889\n575673403 8999999999079982623", "3\n739134224 8999999999892539778\n960410270 8999999999024682694\n286103376 8999999999849390015", "4\n674378376 8999999999719931608\n37509017 8999999999387372213\n406034921 8999999999018438724\n546125539 8999999999879368044", "4\n840893847 8999999999654562383\n139840441 8999999999921619811\n311512855 8999999999801704512\n25959825 8999999999551930487", "7\n89870013 8999999999917755425\n802311555 8999999999055366008\n847333505 8999999999726653552\n132149035 8999999999144498325\n943135535 8999999999038849200\n820468253 8999999999630582637\n369473186 8999999999168524327", "5\n508307251 8999999999718177123\n521516981 8999999999464659141\n290241176 8999999999356325428\n615193857 8999999999597603944\n207549445 8999999999906844873", "2\n27550482 8999999999973770612\n120156054 8999999999028557489", "1\n271055852 8999999999909378243", "8\n787842267 8999999999359738007\n133322301 8999999999943290774\n417668696 8999999999749402497\n46587622 8999999999589402579\n718959740 8999999999109688815\n529442028 8999999999809940983\n943175645 8999999999567139418\n865545527 8999999999260702769", "10\n1883143 8999999999664400380\n373522758 8999999999528614034\n49945668 8999999999257821295\n659209563 8999999999455232186\n74336065 8999999999709871509\n97315679 8999999999108629997\n112069256 8999999999626576439\n12161303 8999999999432219862\n756831002 8999999999681371635\n230283719 8999999999550291145"], "outputs": ["9", "2", "7", "138", "4578", "3378\n381", "1\n135\n0\n135", "15957349671845566", "3974776165902\n15977172601197\n5429986145\n7654830993719\n26117", "1\n1\n0", "262303539156695\n312897266661597\n38778726789519\n1139862940345127\n1402615778591617\n79118901111096\n1245376292216844\n659738283968181\n1512151848646298", "549953639217759\n500330757015166\n752572674468163\n436944574287103\n888035593458099\n815512909354668\n274130616468780", "201308654973933\n671018900952294\n557260640825456\n540245067535034\n951590675251248\n821822247331406\n1236063703297355\n975752055142342\n695221153195519", "95861671721858\n223094952917814\n644166606425537\n120467904177516\n171364758258616\n1283490622790032\n70087190765465\n307069761298908", "882906430841196\n42022148935039\n1331583561781769\n1112192163424357\n187737287429964\n340983354590699\n1187362489423650\n65177281203879\n681151115425128\n281120105826732", "747510034316095\n79156178606166\n135124732730027\n34085557037263\n1399630254414422\n411736949395029\n1554771181008711\n1542736445406160\n140533045281525\n291140888308231", "264558248920386\n447564169675211", "592269002835278\n490392318097910\n1479332749456685\n973971824970712\n293817273058831", "569988591376813\n279165427586805\n878614839734539\n963922382771989\n955701376330903\n185737826200532\n335147883567859", "111729862958642\n828223557472883\n1338195829521665\n1422989272142417", "315665808201383\n452173335782140\n1043520592810950\n207881845406015\n346723658222085", "275614372867493\n4659637264553\n1137342068923219\n699280378176787\n43498698267824", "346819987743014\n55092823341467", "626997097457560\n461119872685266\n494669041669140\n1651825364810407\n212939340175502\n81771949489938", "346244647306943\n735804706209393\n662539475305881\n575163541821522\n442982474060829\n69445242386875", "88198304176240\n962081125874149", "768880516070086\n105251422042778\n1171842666779485\n340594731814913\n733127744647337\n1237953582953797\n227668828811669\n906919615037865\n483212415948596\n1471096234030452", "288403268897055", "1105188916073505\n8401535899653\n42676144797046\n203278778614845\n511366630991705", "428539359425062\n38145118408539\n843379203441666\n1226321445918381\n477944627277795", "88194728799125", "912901045635585\n946264344323228\n396530582015099\n1276195957822587\n393055025121430", "1326519621640374\n1455095002395873\n839815657146984\n1301765297380635\n556427727905125", "125479708961158\n23959650169069\n295105797092887\n558580533111335\n46911931274954\n306769834874325\n1148348273935072", "659040707264401\n1169272353137522\n376194188156988\n265702711225992\n1082952205541968\n710617267557674\n90657680784523\n5900863115303\n1261270219463080", "174229855050036\n652036071424638\n380051677908779\n1036346035129658\n1296518899055801\n926646671294788\n253442916135262\n27096176893815", "1174608615264406\n478873948513061\n1088489184647499\n477237176264941\n845730891804138\n655620551892311", "1483854651250762\n905015525981812\n517553165213234\n33709204034254\n1113374351058951\n100352641671765\n426472119432887", "1305739310768597\n102116549043209\n871997518159200\n702650020836287\n83143533290706\n47299584944773\n955940809894257\n1421553310960175\n483847068411766", "1567925255004\n1257931500816068\n392229959274848\n95900315764706\n917682338726377\n160732132866347", "453938626100478\n474023849716525\n67782962321158\n928258453065819", "175044419962203\n475567289515459\n271613608429105\n3445772208321\n966370135430115\n1572574434602937\n449309541759218\n233323955652174\n64992990053986\n52429533514265", "1217007726638431\n122388636057875\n217887979666251\n326178731297371\n61066928664641\n284737008145535\n1093373317372355\n53748508684990", "1516745018492261\n379777276962608\n1101541359723373", "964419689750151\n1163718720277976\n36086421106555\n874162586490607\n118661992679784\n16505740933228", "355371372539710\n1476637881473656\n78566652210064\n51957130064357\n470606070577295\n325555975457004\n316743540058033", "901252368499013\n758846043617857\n939353740423384\n579394703095088\n778021740563806\n409454897225469\n1132337130752633\n1422718774146674\n606275219995081\n421492007921185", "46498133371402\n40850597316229\n919493060637341\n687618814419970\n17501208925553\n286355733364676\n752235164806132\n170035203610447\n60213403274850", "1024878648284905\n1407846459864944", "1986512740492024", "1412002458948136", "1308643426185330\n1308643426185330\n1308643426185330\n1308643426185330\n1308643426185330\n1308643426185330\n1308643426185330\n1308643426185330\n1308643426185330\n1308643426185330", "1\n1\n1\n1\n1\n1\n1\n1\n1\n1", "15957349664614135\n15957349661485914\n15957349660288369\n15957349667743907\n15957349670077199\n15957349662484120", "15957349668110658\n15957349668753664\n15957349663087863", "15957349659989376\n15957349666269127\n15957349660004094\n15957349663205409\n15957349669084965", "15957349666612744\n15957349666487217\n15957349663881451\n15957349657279299", "15957349669242168\n15957349666397845\n15957349662613062\n15957349660358569\n15957349668236046\n15957349666959085\n15957349662552352\n15957349660553361\n15957349658288950\n15957349663286963", "15957349658680891\n15957349669642622\n15957349667387215\n15957349660885350\n15957349666468387\n15957349659758751\n15957349662500550\n15957349668676585", "15957349665093234\n15957349663187787\n15957349663490125\n15957349662956630\n15957349661257647\n15957349667853562", "15957349657174545\n15957349664842554\n15957349663287444\n15957349660934012\n15957349660687410", "15957349662121656\n15957349657206147\n15957349666880631", "15957349662041057\n15957349668957044\n15957349662212605\n15957349663840013", "15957349660688006\n15957349669232504\n15957349666299121\n15957349669765189", "15957349670087446\n15957349658761550\n15957349660810956\n15957349666520206\n15957349657360988\n15957349660817284\n15957349663250037", "15957349663733007\n15957349662832928\n15957349665236045\n15957349662359742\n15957349668276315", "15957349671150714\n15957349666232530", "15957349667254063", "15957349660173586\n15957349669437416\n15957349664824777\n15957349669455115\n15957349659354335\n15957349663684224\n15957349659508226\n15957349658965833", "15957349670641976\n15957349664736116\n15957349668207957\n15957349661419878\n15957349669602216\n15957349667015648\n15957349668768809\n15957349669676588\n15957349661437380\n15957349666718051"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces |
|
5905d6dd07b7ab56dc2b9a6790ab9061 | Supercentral Point | One day Vasya painted a Cartesian coordinate system on a piece of paper and marked some set of points (*x*1,<=*y*1),<=(*x*2,<=*y*2),<=...,<=(*x**n*,<=*y**n*). Let's define neighbors for some fixed point from the given set (*x*,<=*y*):
- point (*x*',<=*y*') is (*x*,<=*y*)'s right neighbor, if *x*'<=><=*x* and *y*'<==<=*y* - point (*x*',<=*y*') is (*x*,<=*y*)'s left neighbor, if *x*'<=<<=*x* and *y*'<==<=*y* - point (*x*',<=*y*') is (*x*,<=*y*)'s lower neighbor, if *x*'<==<=*x* and *y*'<=<<=*y* - point (*x*',<=*y*') is (*x*,<=*y*)'s upper neighbor, if *x*'<==<=*x* and *y*'<=><=*y*
We'll consider point (*x*,<=*y*) from the given set supercentral, if it has at least one upper, at least one lower, at least one left and at least one right neighbor among this set's points.
Vasya marked quite many points on the paper. Analyzing the picture manually is rather a challenge, so Vasya asked you to help him. Your task is to find the number of supercentral points in the given set.
The first input line contains the only integer *n* (1<=β€<=*n*<=β€<=200) β the number of points in the given set. Next *n* lines contain the coordinates of the points written as "*x* *y*" (without the quotes) (|*x*|,<=|*y*|<=β€<=1000), all coordinates are integers. The numbers in the line are separated by exactly one space. It is guaranteed that all points are different.
Print the only number β the number of supercentral points of the given set.
Sample Input
8
1 1
4 2
3 1
1 2
0 2
0 1
1 0
1 3
5
0 0
0 1
1 0
0 -1
-1 0
Sample Output
2
1
| {"inputs": ["8\n1 1\n4 2\n3 1\n1 2\n0 2\n0 1\n1 0\n1 3", "5\n0 0\n0 1\n1 0\n0 -1\n-1 0", "9\n-565 -752\n-184 723\n-184 -752\n-184 1\n950 723\n-565 723\n950 -752\n950 1\n-565 1", "25\n-651 897\n916 897\n-651 -808\n-748 301\n-734 414\n-651 -973\n-734 897\n916 -550\n-758 414\n916 180\n-758 -808\n-758 -973\n125 -550\n125 -973\n125 301\n916 414\n-748 -808\n-651 301\n-734 301\n-307 897\n-651 -550\n-651 414\n125 -808\n-748 -550\n916 -808", "1\n487 550", "10\n990 -396\n990 736\n990 646\n990 -102\n990 -570\n990 155\n990 528\n990 489\n990 268\n990 676", "30\n507 836\n525 836\n-779 196\n507 -814\n525 -814\n525 42\n525 196\n525 -136\n-779 311\n507 -360\n525 300\n507 578\n507 311\n-779 836\n507 300\n525 -360\n525 311\n-779 -360\n-779 578\n-779 300\n507 42\n525 578\n-779 379\n507 196\n525 379\n507 379\n-779 -814\n-779 42\n-779 -136\n507 -136", "25\n890 -756\n890 -188\n-37 -756\n-37 853\n523 998\n-261 853\n-351 853\n-351 -188\n523 -756\n-261 -188\n-37 998\n523 -212\n-351 998\n-37 -188\n-351 -756\n-37 -212\n890 998\n890 -212\n523 853\n-351 -212\n-261 -212\n-261 998\n-261 -756\n890 853\n523 -188", "21\n-813 -11\n486 254\n685 254\n-708 254\n-55 -11\n-671 -191\n486 -11\n-671 -11\n685 -11\n685 -191\n486 -191\n-55 254\n-708 -11\n-813 254\n-708 -191\n41 -11\n-671 254\n-813 -191\n41 254\n-55 -191\n41 -191", "4\n1 0\n2 0\n1 1\n1 -1"], "outputs": ["2", "1", "1", "7", "0", "0", "8", "9", "5", "0"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 390 | codeforces |
|
59114d397555cf1a5a46cb976295c8dc | Vasily the Bear and Sequence | Vasily the bear has got a sequence of positive integers *a*1,<=*a*2,<=...,<=*a**n*. Vasily the Bear wants to write out several numbers on a piece of paper so that the beauty of the numbers he wrote out was maximum.
The beauty of the written out numbers *b*1,<=*b*2,<=...,<=*b**k* is such maximum non-negative integer *v*, that number *b*1 *and* *b*2 *and* ... *and* *b**k* is divisible by number 2*v* without a remainder. If such number *v* doesn't exist (that is, for any non-negative integer *v*, number *b*1 *and* *b*2 *and* ... *and* *b**k* is divisible by 2*v* without a remainder), the beauty of the written out numbers equals -1.
Tell the bear which numbers he should write out so that the beauty of the written out numbers is maximum. If there are multiple ways to write out the numbers, you need to choose the one where the bear writes out as many numbers as possible.
Here expression *x* *and* *y* means applying the bitwise AND operation to numbers *x* and *y*. In programming languages C++ and Java this operation is represented by "&", in Pascal β by "and".
The first line contains integer *n* (1<=β€<=*n*<=β€<=105). The second line contains *n* space-separated integers *a*1,<=*a*2,<=...,<=*a**n* (1<=β€<=*a*1<=<<=*a*2<=<<=...<=<<=*a**n*<=β€<=109).
In the first line print a single integer *k* (*k*<=><=0), showing how many numbers to write out. In the second line print *k* integers *b*1,<=*b*2,<=...,<=*b**k* β the numbers to write out. You are allowed to print numbers *b*1,<=*b*2,<=...,<=*b**k* in any order, but all of them must be distinct. If there are multiple ways to write out the numbers, choose the one with the maximum number of numbers to write out. If there still are multiple ways, you are allowed to print any of them.
Sample Input
5
1 2 3 4 5
3
1 2 4
Sample Output
2
4 5
1
4
| {"inputs": ["5\n1 2 3 4 5", "3\n1 2 4", "3\n1 20 22", "10\n109070199 215498062 361633800 406156967 452258663 530571268 670482660 704334662 841023955 967424642", "30\n61 65 67 71 73 75 77 79 129 131 135 137 139 141 267 520 521 522 524 526 1044 1053 6924600 32125372 105667932 109158064 192212084 202506108 214625360 260071380", "40\n6 7 10 11 18 19 33 65 129 258 514 515 1026 2049 4741374 8220406 14324390 17172794 17931398 33354714 34796238 38926670 39901570 71292026 72512934 77319030 95372470 102081830 114152702 120215390 133853238 134659386 159128594 165647058 219356350 225884742 236147130 240926050 251729234 263751314", "1\n536870912", "1\n1", "1\n536870911", "2\n536870911 536870912", "38\n37750369 37750485 37750546 37751012 37751307 37751414 37751958 37751964 37752222 37752448 75497637 75497768 75497771 75498087 75498145 75498177 75498298 75498416 75498457 150994987 150994994 150994999 150995011 150995012 150995015 150995016 150995023 150995040 150995053 805306375 805306377 805306379 805306387 805306389 805306390 805306392 805306396 805306400", "39\n37749932 37750076 37750391 37750488 37750607 37750812 37750978 37751835 37752173 37752254 75497669 75497829 75497852 75498044 75498061 75498155 75498198 75498341 75498382 75498465 150994988 150994989 150995009 150995019 150995024 150995030 150995031 150995069 150995072 805306369 805306373 805306375 805306379 805306380 805306384 805306387 805306389 805306398 805306400"], "outputs": ["2\n4 5", "1\n4", "2\n20 22", "6\n361633800 406156967 452258663 530571268 841023955 967424642", "8\n520 521 522 524 526 109158064 202506108 260071380", "13\n2049 4741374 8220406 17172794 17931398 38926670 39901570 77319030 134659386 159128594 219356350 225884742 240926050", "1\n536870912", "1\n1", "1\n536870911", "1\n536870912", "9\n805306375 805306377 805306379 805306387 805306389 805306390 805306392 805306396 805306400", "10\n805306369 805306373 805306375 805306379 805306380 805306384 805306387 805306389 805306398 805306400"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 7 | codeforces |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.