sample_inputs
stringlengths
5
384
input_specification
stringlengths
48
911
src_uid
stringlengths
32
32
source_code
stringlengths
29
6.77k
sample_outputs
stringlengths
5
393
lang_cluster
stringclasses
4 values
notes
stringlengths
30
1.52k
βŒ€
output_specification
stringlengths
25
681
description
stringlengths
140
2.49k
human_testcases
stringlengths
243
50.8k
human_pass_rate
float64
100
100
human_line_coverage
float64
100
100
human_branch_coverage
float64
100
100
human_sample_testcases_1
stringlengths
190
3.11k
human_sample_testcases_2
stringlengths
190
3.11k
human_sample_testcases_3
stringlengths
190
3.11k
human_sample_testcases_4
stringlengths
190
3.11k
human_sample_testcases_5
stringlengths
190
3.11k
human_sample_pass_rate_1
float64
100
100
human_sample_pass_rate_2
float64
100
100
human_sample_pass_rate_3
float64
100
100
human_sample_pass_rate_4
float64
100
100
human_sample_pass_rate_5
float64
100
100
human_sample_line_coverage_1
float64
52.2
100
human_sample_line_coverage_2
float64
60
100
human_sample_line_coverage_3
float64
50
100
human_sample_line_coverage_4
float64
43.5
100
human_sample_line_coverage_5
float64
21.7
100
human_sample_branch_coverage_1
float64
45.5
100
human_sample_branch_coverage_2
float64
45.8
100
human_sample_branch_coverage_3
float64
16.7
100
human_sample_branch_coverage_4
float64
36.4
100
human_sample_branch_coverage_5
float64
18.2
100
id
int64
1
400
human_sample_pass_rate
float64
100
100
human_sample_line_coverage
float64
47
100
human_sample_branch_coverage
float64
41.8
100
["127", "130", "123456789101112131415161718192021222324"]
The first line contains a positive number n. It consists of no more than 100 digits and doesn't contain any leading zeros. The number n can't be represented as an empty string. Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d).
33041f1832fa7f641e37c4c638ab08a1
n = int(input()) if n >= -128 and n <= 127: print("byte") elif n >= -32768 and n <= 32767: print("short") elif n >= -2147483648 and n <= 2147483647: print("int") elif n >= -9223372036854775808 and n <= 9223372036854775807: print("long") else: print("BigInteger")
["byte", "short", "BigInteger"]
Python
null
Print the first type from the list "byte, short, int, long, BigInteger", that can store the natural number n, in accordance with the data given above.
Little Petya has recently started attending a programming club. Naturally he is facing the problem of choosing a programming language. After long considerations he realized that Java is the best choice. The main argument in favor of choosing Java was that it has a very large integer data type, called BigInteger.But having attended several classes of the club, Petya realized that not all tasks require using the BigInteger type. It turned out that in some tasks it is much easier to use small data types. That's why a question arises: "Which integer type to use if one wants to store a positive integer n?"Petya knows only 5 integer types:1) byte occupies 1 byte and allows you to store numbers from  - 128 to 1272) short occupies 2 bytes and allows you to store numbers from  - 32768 to 327673) int occupies 4 bytes and allows you to store numbers from  - 2147483648 to 21474836474) long occupies 8 bytes and allows you to store numbers from  - 9223372036854775808 to 92233720368547758075) BigInteger can store any integer number, but at that it is not a primitive type, and operations with it are much slower.For all the types given above the boundary values are included in the value range.From this list, Petya wants to choose the smallest type that can store a positive integer n. Since BigInteger works much slower, Peter regards it last. Help him.
[{"input": "127\r\n", "output": ["byte"]}, {"input": "130\r\n", "output": ["short"]}, {"input": "123456789101112131415161718192021222324\r\n", "output": ["BigInteger"]}, {"input": "6\r\n", "output": ["byte"]}, {"input": "16\r\n", "output": ["byte"]}, {"input": "126\r\n", "output": ["byte"]}, {"input": "128\r\n", "output": ["short"]}, {"input": "32766\r\n", "output": ["short"]}, {"input": "111111\r\n", "output": ["int"]}, {"input": "22222\r\n", "output": ["short"]}, {"input": "32767\r\n", "output": ["short"]}, {"input": "32768\r\n", "output": ["int"]}, {"input": "32769\r\n", "output": ["int"]}, {"input": "2147483645\r\n", "output": ["int"]}, {"input": "2147483646\r\n", "output": ["int"]}, {"input": "2147483647\r\n", "output": ["int"]}, {"input": "2147483648\r\n", "output": ["long"]}, {"input": "2147483649\r\n", "output": ["long"]}, {"input": "9223372036854775805\r\n", "output": ["long"]}, {"input": "9223372036854775806\r\n", "output": ["long"]}, {"input": "9223372036854775807\r\n", "output": ["long"]}, {"input": "9223372036854775808\r\n", "output": ["BigInteger"]}, {"input": "9223372036854775809\r\n", "output": ["BigInteger"]}, {"input": "1111111111111111111111111111111111111111111111\r\n", "output": ["BigInteger"]}, {"input": "232\r\n", "output": ["short"]}, {"input": "241796563564014133460267652699\r\n", "output": ["BigInteger"]}, {"input": "29360359146807441660707083821018832188095237636414144034857851003419752010124705615779249\r\n", "output": ["BigInteger"]}, {"input": "337300529263821789926982715723773719445001702036602052198530564\r\n", "output": ["BigInteger"]}, {"input": "381127467969689863953686682245136076127159921\r\n", "output": ["BigInteger"]}, {"input": "2158324958633591462\r\n", "output": ["long"]}, {"input": "268659422768117401499491767189496733446324586965055954729177892248858259490346\r\n", "output": ["BigInteger"]}, {"input": "3023764505449745844381036446038799100004717936344985\r\n", "output": ["BigInteger"]}, {"input": "13408349824892484976400774\r\n", "output": ["BigInteger"]}, {"input": "18880842614378213198381172973704766723997934818440985546083314104481253291692101136681\r\n", "output": ["BigInteger"]}, {"input": "1180990956946757129733650596194933741\r\n", "output": ["BigInteger"]}, {"input": "73795216631038776655609800540262114612084443385902708034055020082090470662930545328551\r\n", "output": ["BigInteger"]}, {"input": "1658370691480968202384509492140362150472696196949\r\n", "output": ["BigInteger"]}, {"input": "59662093286671707493190399502717308574459619342109544431740791973099298641871347858082458491958703\r\n", "output": ["BigInteger"]}, {"input": "205505005582428018613354752739589866670902346355933720701937\r\n", "output": ["BigInteger"]}, {"input": "53348890623013817139699\r\n", "output": ["BigInteger"]}, {"input": "262373979958859125198440634134122707574734706745701184688685117904709744\r\n", "output": ["BigInteger"]}, {"input": "69113784278456828987289369893745977\r\n", "output": ["BigInteger"]}, {"input": "2210209454022702335652564247406666491086662454147967686455330365147159266087\r\n", "output": ["BigInteger"]}, {"input": "630105816139991597267787581532092408135\r\n", "output": ["BigInteger"]}, {"input": "800461429306907809762708270\r\n", "output": ["BigInteger"]}, {"input": "7685166910821197056344900917707673568669808490600751439157\r\n", "output": ["BigInteger"]}, {"input": "713549841568602590705962611607726022334779480510421458817648621376683672722573289661127894\r\n", "output": ["BigInteger"]}, {"input": "680504312323996476676434432\r\n", "output": ["BigInteger"]}, {"input": "3376595620091080825479292544658464163405755746884100218035\r\n", "output": ["BigInteger"]}, {"input": "303681723783491968617491075591006152690484825330764215796396316561122383310011589365655481\r\n", "output": ["BigInteger"]}, {"input": "4868659422768117401499491767189496733446324586965055954729177892248858259490346614099717639491763430\r\n", "output": ["BigInteger"]}, {"input": "3502376450544974584438103644603879910000471793634498544789130945841846713263971487355748226237288709\r\n", "output": ["BigInteger"]}, {"input": "2334083498248924849764007740114454487565621932425948046430072197452845278935316358800789014185793377\r\n", "output": ["BigInteger"]}, {"input": "1988808426143782131983811729737047667239979348184409855460833141044812532916921011366813880911319644\r\n", "output": ["BigInteger"]}, {"input": "1018099095694675712973365059619493374113337270925179793757322992466016001294122941535439492265169131\r\n", "output": ["BigInteger"]}, {"input": "8437952166310387766556098005402621146120844433859027080340550200820904706629305453285512716464931911\r\n", "output": ["BigInteger"]}, {"input": "6965837069148096820238450949214036215047269619694967357734070611376013382163559966747678150791825071\r\n", "output": ["BigInteger"]}, {"input": "4596620932866717074931903995027173085744596193421095444317407919730992986418713478580824584919587030\r\n", "output": ["BigInteger"]}, {"input": "1905505005582428018613354752739589866670902346355933720701937408006000562951996789032987808118459990\r\n", "output": ["BigInteger"]}, {"input": "8433488906230138171396997888322916936677429522910871017295155818340819168386140293774243244435122950\r\n", "output": ["BigInteger"]}, {"input": "6862373979958859125198440634134122707574734706745701184688685117904709744830303784215298687654884810\r\n", "output": ["BigInteger"]}, {"input": "4491137842784568289872893698937459777201151060689848471272003426250808340375567208957554901863756992\r\n", "output": ["BigInteger"]}, {"input": "9721020945402270233565256424740666649108666245414796768645533036514715926608741510409618545180420952\r\n", "output": ["BigInteger"]}, {"input": "7330105816139991597267787581532092408135003429259616955239761315950805521264994021242873979309182812\r\n", "output": ["BigInteger"]}, {"input": "2000461429306907809762708270752707617318091579531521957022940951538737203583768926365382290530636885\r\n", "output": ["BigInteger"]}, {"input": "9868516691082119705634490091770767356866980849060075143915700796802700437762260163478754592094654326\r\n", "output": ["BigInteger"]}, {"input": "8713549841568602590705962611607726022334779480510421458817648621376683672722573289661127894678771177\r\n", "output": ["BigInteger"]}, {"input": "4580504312323996476676434432646986768872786931159974634901608445720467716981185426771899006352697916\r\n", "output": ["BigInteger"]}, {"input": "2537659562009108082547929254465846416340575574688410021803548570097340949141688442074263189944614467\r\n", "output": ["BigInteger"]}, {"input": "1403681723783491968617491075591006152690484825330764215796396316561122383310011589365655481428540208\r\n", "output": ["BigInteger"]}, {"input": "26\r\n", "output": ["byte"]}, {"input": "302376450544\r\n", "output": ["long"]}, {"input": "13\r\n", "output": ["byte"]}, {"input": "188808426143\r\n", "output": ["long"]}, {"input": "118099095694675\r\n", "output": ["long"]}, {"input": "73795216631038\r\n", "output": ["long"]}, {"input": "1658370691480\r\n", "output": ["long"]}, {"input": "596620932866\r\n", "output": ["long"]}, {"input": "2055050055\r\n", "output": ["int"]}, {"input": "533488906\r\n", "output": ["int"]}, {"input": "26237397\r\n", "output": ["int"]}, {"input": "6911378\r\n", "output": ["int"]}, {"input": "221020945402270233\r\n", "output": ["long"]}, {"input": "63010581613999159\r\n", "output": ["long"]}, {"input": "80046142930\r\n", "output": ["long"]}, {"input": "7685166910821197\r\n", "output": ["long"]}, {"input": "71\r\n", "output": ["byte"]}, {"input": "6805043123239964766\r\n", "output": ["long"]}, {"input": "3376\r\n", "output": ["short"]}, {"input": "3036817237\r\n", "output": ["long"]}]
100
100
100
[{'input': '130\r\n', 'output': ['short']}, {'input': '69113784278456828987289369893745977\r\n', 'output': ['BigInteger']}, {'input': '188808426143\r\n', 'output': ['long']}, {'input': '1658370691480968202384509492140362150472696196949\r\n', 'output': ['BigInteger']}, {'input': '2147483647\r\n', 'output': ['int']}]
[{'input': '1403681723783491968617491075591006152690484825330764215796396316561122383310011589365655481428540208\r\n', 'output': ['BigInteger']}, {'input': '4491137842784568289872893698937459777201151060689848471272003426250808340375567208957554901863756992\r\n', 'output': ['BigInteger']}, {'input': '16\r\n', 'output': ['byte']}, {'input': '1988808426143782131983811729737047667239979348184409855460833141044812532916921011366813880911319644\r\n', 'output': ['BigInteger']}, {'input': '128\r\n', 'output': ['short']}]
[{'input': '1111111111111111111111111111111111111111111111\r\n', 'output': ['BigInteger']}, {'input': '32768\r\n', 'output': ['int']}, {'input': '4491137842784568289872893698937459777201151060689848471272003426250808340375567208957554901863756992\r\n', 'output': ['BigInteger']}, {'input': '32766\r\n', 'output': ['short']}, {'input': '130\r\n', 'output': ['short']}]
[{'input': '4596620932866717074931903995027173085744596193421095444317407919730992986418713478580824584919587030\r\n', 'output': ['BigInteger']}, {'input': '221020945402270233\r\n', 'output': ['long']}, {'input': '8713549841568602590705962611607726022334779480510421458817648621376683672722573289661127894678771177\r\n', 'output': ['BigInteger']}, {'input': '2210209454022702335652564247406666491086662454147967686455330365147159266087\r\n', 'output': ['BigInteger']}, {'input': '73795216631038\r\n', 'output': ['long']}]
[{'input': '2334083498248924849764007740114454487565621932425948046430072197452845278935316358800789014185793377\r\n', 'output': ['BigInteger']}, {'input': '2147483648\r\n', 'output': ['long']}, {'input': '1988808426143782131983811729737047667239979348184409855460833141044812532916921011366813880911319644\r\n', 'output': ['BigInteger']}, {'input': '6862373979958859125198440634134122707574734706745701184688685117904709744830303784215298687654884810\r\n', 'output': ['BigInteger']}, {'input': '4491137842784568289872893698937459777201151060689848471272003426250808340375567208957554901863756992\r\n', 'output': ['BigInteger']}]
100
100
100
100
100
90
80
80
70
70
87.5
75
75
62.5
62.5
301
100
78
72.5
["6\n1 3 4 5 6 9", "3\n998 999 1000", "5\n1 2 3 4 5"]
The first line of the input contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$)Β β€” the number of elements in the array. The second line of the input contains $$$n$$$ integers $$$a_i$$$ ($$$1 \le a_1&lt;a_2&lt;\dots&lt;a_n \le 10^3$$$)Β β€” the array written by Giraffe.
858b5e75e21c4cba6d08f3f66be0c198
n = int(input()) a = list(map(int,input().split())) count=ans=0 if(n>=2 and a[0]==1 and a[1]==2): count+=1 for i in range(1,n-1): if(a[i-1]+1==a[i] and a[i+1]-1==a[i]): count+=1 else: ans=max(ans,count) count=0 if(n>=2 and a[-1]==1000 and a[-2]==999): count+=1 ans=max(count,ans) print(ans)
["2", "2", "4"]
Python
NoteIn the first example, JATC can erase the third and fourth elements, leaving the array $$$[1, 3, \_, \_, 6, 9]$$$. As you can see, there is only one way to fill in the blanks.In the second example, JATC can erase the second and the third elements. The array will become $$$[998, \_, \_]$$$. Because all the elements are less than or equal to $$$1000$$$, the array is still can be restored. Note, that he can't erase the first $$$2$$$ elements.In the third example, JATC can erase the first $$$4$$$ elements. Since all the elements are greater than or equal to $$$1$$$, Giraffe can still restore the array. Note, that he can't erase the last $$$4$$$ elements.
Print a single integerΒ β€” the maximum number of consecutive elements in the array that JATC can erase. If it is impossible to erase even a single element, print $$$0$$$.
JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ of integers, such that $$$1 \le a_1 &lt; a_2 &lt; \ldots &lt; a_n \le 10^3$$$, and then went to the bathroom.JATC decided to prank his friend by erasing some consecutive elements in the array. Since he doesn't want for the prank to go too far, he will only erase in a way, such that Giraffe can still restore the array using the information from the remaining elements. Because Giraffe has created the array, he's also aware that it's an increasing array and all the elements are integers in the range $$$[1, 10^3]$$$.JATC wonders what is the greatest number of elements he can erase?
[{"input": "6\r\n1 3 4 5 6 9\r\n", "output": ["2"]}, {"input": "3\r\n998 999 1000\r\n", "output": ["2"]}, {"input": "5\r\n1 2 3 4 5\r\n", "output": ["4"]}, {"input": "1\r\n1\r\n", "output": ["0"]}, {"input": "2\r\n1 2\r\n", "output": ["1"]}, {"input": "2\r\n999 1000\r\n", "output": ["1"]}, {"input": "9\r\n1 4 5 6 7 100 101 102 103\r\n", "output": ["2"]}, {"input": "100\r\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\r\n", "output": ["99"]}, {"input": "8\r\n6 8 9 11 14 18 19 20\r\n", "output": ["1"]}, {"input": "2\r\n1 7\r\n", "output": ["0"]}, {"input": "1\r\n779\r\n", "output": ["0"]}, {"input": "5\r\n3 8 25 37 43\r\n", "output": ["0"]}, {"input": "73\r\n38 45 46 95 98 99 103 157 164 175 184 193 208 251 258 276 279 282 319 329 336 344 349 419 444 452 490 499 507 508 519 542 544 553 562 576 579 590 594 603 634 635 648 659 680 686 687 688 695 698 743 752 757 774 776 779 792 809 860 879 892 911 918 927 928 945 947 951 953 958 959 960 983\r\n", "output": ["1"]}, {"input": "15\r\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\r\n", "output": ["14"]}, {"input": "63\r\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\r\n", "output": ["62"]}, {"input": "100\r\n252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 409 410 425 426 604 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895\r\n", "output": ["70"]}, {"input": "95\r\n34 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 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 911 912 913\r\n", "output": ["35"]}, {"input": "90\r\n126 239 240 241 242 253 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 600 601 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 934 935\r\n", "output": ["44"]}, {"input": "85\r\n52 53 54 55 56 57 58 59 60 61 62 63 64 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 333 334 453 454 455 456 457 458 459 460 461 462 463 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624\r\n", "output": ["23"]}, {"input": "80\r\n237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 408 409 410 411 412 413 414 415 416 417 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985\r\n", "output": ["25"]}, {"input": "70\r\n72 73 74 75 76 77 78 79 80 81 82 354 355 356 357 358 359 360 361 362 363 364 365 366 367 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 764 765 766 767 768 769 770 794 795 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826\r\n", "output": ["19"]}, {"input": "75\r\n327 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653\r\n", "output": ["72"]}, {"input": "60\r\n12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 134 135 136 137 353 354 355 356 357 358 359 360 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815\r\n", "output": ["24"]}, {"input": "65\r\n253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 533 614 615 864\r\n", "output": ["59"]}, {"input": "55\r\n67 68 69 70 160 161 162 163 164 165 166 167 168 169 170 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 960\r\n", "output": ["21"]}, {"input": "50\r\n157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 632 633 634 635 636 637 638\r\n", "output": ["20"]}, {"input": "45\r\n145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 333 334 831 832 978 979 980 981\r\n", "output": ["35"]}, {"input": "100\r\n901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000\r\n", "output": ["99"]}, {"input": "10\r\n1 2 3 4 5 6 7 8 9 10\r\n", "output": ["9"]}, {"input": "10\r\n991 992 993 994 995 996 997 998 999 1000\r\n", "output": ["9"]}, {"input": "39\r\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\r\n", "output": ["38"]}, {"input": "42\r\n959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000\r\n", "output": ["41"]}, {"input": "100\r\n144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 198 199 200 201 202 203 204 205 206 207 208 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 376 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 904 905 997\r\n", "output": ["16"]}, {"input": "95\r\n9 10 11 12 13 134 271 272 273 274 275 276 277 278 290 291 292 293 294 295 296 297 298 299 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 620 621 622 623 624 625 626 627 628 629 630 631 632 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 952\r\n", "output": ["20"]}, {"input": "90\r\n20 21 22 23 24 25 56 57 58 59 60 61 62 63 64 84 85 404 405 406 407 408 409 410 420 421 422 423 424 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 491 492 588 589 590 652 653 654 655 656 657 754 755 756 757 758 759 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 982 983 984 985 986 987 988 989 990 991 992 995\r\n", "output": ["15"]}, {"input": "85\r\n40 41 42 43 44 69 70 71 72 73 305 306 307 308 309 333 334 335 336 337 338 339 340 341 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 717 718 719 720 721 862 863 864 865 866 867 868 869 870 871 872 873 874 945 946 947 948 949 950\r\n", "output": ["18"]}, {"input": "80\r\n87 88 89 90 91 92 93 94 95 96 97 98 99 173 174 175 176 177 178 179 180 184 185 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 550 551 552 553 554 555 650 702 703 704 705 706 707 708 709 710 727 728 729 730 731 798 799 800 831 832 833 869 870 980 981 982 983 984 985 986 987 988 989 990 991 992\r\n", "output": ["13"]}, {"input": "1\r\n1000\r\n", "output": ["0"]}, {"input": "2\r\n998 999\r\n", "output": ["0"]}, {"input": "2\r\n3 4\r\n", "output": ["0"]}, {"input": "3\r\n9 10 11\r\n", "output": ["1"]}, {"input": "6\r\n4 5 6 7 8 9\r\n", "output": ["4"]}, {"input": "5\r\n5 6 7 8 9\r\n", "output": ["3"]}, {"input": "8\r\n1 2 5 6 7 8 9 11\r\n", "output": ["3"]}, {"input": "4\r\n1 2 3 6\r\n", "output": ["2"]}, {"input": "4\r\n1 2 3 66\r\n", "output": ["2"]}, {"input": "7\r\n1 2 5 6 7 8 9\r\n", "output": ["3"]}, {"input": "2\r\n2 4\r\n", "output": ["0"]}, {"input": "8\r\n1 2 5 6 7 8 9 1000\r\n", "output": ["3"]}, {"input": "2\r\n1 1000\r\n", "output": ["0"]}, {"input": "4\r\n3 4 5 6\r\n", "output": ["2"]}, {"input": "5\r\n2 3 4 5 6\r\n", "output": ["3"]}, {"input": "6\r\n1 2 3 4 5 7\r\n", "output": ["4"]}, {"input": "6\r\n1 996 997 998 999 1000\r\n", "output": ["4"]}, {"input": "5\r\n1 2 3 4 6\r\n", "output": ["3"]}, {"input": "6\r\n1 2 3 5 6 7\r\n", "output": ["2"]}, {"input": "3\r\n3 4 5\r\n", "output": ["1"]}, {"input": "1\r\n5\r\n", "output": ["0"]}, {"input": "3\r\n2 3 4\r\n", "output": ["1"]}, {"input": "7\r\n1 3 5 997 998 999 1000\r\n", "output": ["3"]}, {"input": "4\r\n3 4 5 10\r\n", "output": ["1"]}, {"input": "3\r\n997 998 999\r\n", "output": ["1"]}, {"input": "7\r\n1 2 3 4 6 7 8\r\n", "output": ["3"]}, {"input": "2\r\n2 3\r\n", "output": ["0"]}, {"input": "7\r\n2 3 4 6 997 998 999\r\n", "output": ["1"]}, {"input": "1\r\n2\r\n", "output": ["0"]}, {"input": "3\r\n4 5 6\r\n", "output": ["1"]}, {"input": "2\r\n5 6\r\n", "output": ["0"]}, {"input": "7\r\n1 2 3 997 998 999 1000\r\n", "output": ["3"]}, {"input": "4\r\n1 3 999 1000\r\n", "output": ["1"]}, {"input": "5\r\n1 3 5 7 9\r\n", "output": ["0"]}, {"input": "6\r\n1 2 3 4 5 10\r\n", "output": ["4"]}, {"input": "4\r\n1 2 999 1000\r\n", "output": ["1"]}, {"input": "2\r\n10 20\r\n", "output": ["0"]}, {"input": "5\r\n2 3 4 5 10\r\n", "output": ["2"]}, {"input": "4\r\n2 3 4 5\r\n", "output": ["2"]}, {"input": "42\r\n35 145 153 169 281 292 299 322 333 334 358 382 391 421 436 447 464 467 478 491 500 538 604 667 703 705 716 718 724 726 771 811 827 869 894 895 902 912 942 961 962 995\r\n", "output": ["0"]}, {"input": "3\r\n10 11 12\r\n", "output": ["1"]}, {"input": "7\r\n1 2 3 4 6 9 18\r\n", "output": ["3"]}, {"input": "5\r\n1 2 3 4 800\r\n", "output": ["3"]}, {"input": "5\r\n1 2 3 4 1000\r\n", "output": ["3"]}, {"input": "5\r\n1 997 998 999 1000\r\n", "output": ["3"]}, {"input": "6\r\n1 2 6 7 8 9\r\n", "output": ["2"]}, {"input": "4\r\n1 2 3 5\r\n", "output": ["2"]}, {"input": "9\r\n1 2 3 7 8 9 10 11 13\r\n", "output": ["3"]}, {"input": "4\r\n1 2 5 6\r\n", "output": ["1"]}, {"input": "6\r\n1 2 5 6 7 8\r\n", "output": ["2"]}, {"input": "5\r\n1 2 3 999 1000\r\n", "output": ["2"]}, {"input": "100\r\n656 658 660 662 664 666 668 670 672 674 676 678 680 682 684 686 688 690 692 694 696 698 700 702 704 706 708 710 712 714 716 718 720 722 724 726 728 730 732 734 736 738 740 742 744 746 748 750 752 754 756 758 760 762 764 766 768 770 772 774 776 778 780 782 784 786 788 790 792 794 796 798 800 802 804 806 808 810 812 814 816 818 820 822 824 826 828 830 832 834 836 838 840 842 844 848 850 852 999 1000\r\n", "output": ["1"]}, {"input": "3\r\n1 2 9\r\n", "output": ["1"]}, {"input": "8\r\n2 3 4 5 997 998 999 1000\r\n", "output": ["3"]}, {"input": "9\r\n1 2 3 4 6 7 9 10 12\r\n", "output": ["3"]}, {"input": "4\r\n1 2 7 8\r\n", "output": ["1"]}, {"input": "3\r\n1 2 5\r\n", "output": ["1"]}, {"input": "5\r\n1 2 998 999 1000\r\n", "output": ["2"]}, {"input": "4\r\n1 2 3 7\r\n", "output": ["2"]}, {"input": "7\r\n2 4 6 997 998 999 1000\r\n", "output": ["3"]}, {"input": "5\r\n1 2 3 5 6\r\n", "output": ["2"]}, {"input": "6\r\n3 4 5 998 999 1000\r\n", "output": ["2"]}]
100
100
100
[{'input': '2\r\n2 4\r\n', 'output': ['0']}, {'input': '4\r\n1 2 3 7\r\n', 'output': ['2']}, {'input': '4\r\n2 3 4 5\r\n', 'output': ['2']}, {'input': '8\r\n1 2 5 6 7 8 9 11\r\n', 'output': ['3']}, {'input': '4\r\n3 4 5 6\r\n', 'output': ['2']}]
[{'input': '8\r\n2 3 4 5 997 998 999 1000\r\n', 'output': ['3']}, {'input': '4\r\n3 4 5 6\r\n', 'output': ['2']}, {'input': '9\r\n1 2 3 4 6 7 9 10 12\r\n', 'output': ['3']}, {'input': '63\r\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\r\n', 'output': ['62']}, {'input': '3\r\n2 3 4\r\n', 'output': ['1']}]
[{'input': '6\r\n1 2 3 5 6 7\r\n', 'output': ['2']}, {'input': '2\r\n1 1000\r\n', 'output': ['0']}, {'input': '2\r\n998 999\r\n', 'output': ['0']}, {'input': '2\r\n3 4\r\n', 'output': ['0']}, {'input': '7\r\n1 2 3 4 6 7 8\r\n', 'output': ['3']}]
[{'input': '39\r\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\r\n', 'output': ['38']}, {'input': '4\r\n2 3 4 5\r\n', 'output': ['2']}, {'input': '7\r\n2 4 6 997 998 999 1000\r\n', 'output': ['3']}, {'input': '7\r\n1 2 3 4 6 9 18\r\n', 'output': ['3']}, {'input': '42\r\n959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000\r\n', 'output': ['41']}]
[{'input': '7\r\n1 2 3 4 6 7 8\r\n', 'output': ['3']}, {'input': '7\r\n2 3 4 6 997 998 999\r\n', 'output': ['1']}, {'input': '45\r\n145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 333 334 831 832 978 979 980 981\r\n', 'output': ['35']}, {'input': '8\r\n1 2 5 6 7 8 9 11\r\n', 'output': ['3']}, {'input': '5\r\n1 2 3 4 800\r\n', 'output': ['3']}]
100
100
100
100
100
92.86
100
92.86
100
92.86
87.5
100
87.5
100
87.5
302
100
95.716
92.5
["3 6", "3 4"]
The only line contains two integers p and y (2 ≀ p ≀ y ≀ 109).
b533203f488fa4caf105f3f46dd5844d
p, y = [int(x) for x in input().split()] res = -1 for i in range(y, p, -1): flag = True for a in range(2, min(p+1, int(i**0.5)+1)): if i % a == 0: flag = False break if flag: res = i break print(res)
["5", "-1"]
Python
NoteIn the first sample case grasshopper from branch 2 reaches branches 2, 4 and 6 while branch 3 is initially settled by another grasshopper. Therefore the answer is 5.It immediately follows that there are no valid branches in second sample case.
Output the number of the highest suitable branch. If there are none, print -1 instead.
The weather is fine today and hence it's high time to climb the nearby pine and enjoy the landscape.The pine's trunk includes several branches, located one above another and numbered from 2 to y. Some of them (more precise, from 2 to p) are occupied by tiny vile grasshoppers which you're at war with. These grasshoppers are known for their awesome jumping skills: the grasshopper at branch x can jump to branches .Keeping this in mind, you wisely decided to choose such a branch that none of the grasshoppers could interrupt you. At the same time you wanna settle as high as possible since the view from up there is simply breathtaking.In other words, your goal is to find the highest branch that cannot be reached by any of the grasshoppers or report that it's impossible.
[{"input": "3 6\r\n", "output": ["5"]}, {"input": "3 4\r\n", "output": ["-1"]}, {"input": "2 2\r\n", "output": ["-1"]}, {"input": "5 50\r\n", "output": ["49"]}, {"input": "944192806 944193066\r\n", "output": ["944192807"]}, {"input": "1000000000 1000000000\r\n", "output": ["-1"]}, {"input": "2 1000000000\r\n", "output": ["999999999"]}, {"input": "28788 944193066\r\n", "output": ["944192833"]}, {"input": "49 52\r\n", "output": ["-1"]}, {"input": "698964997 734575900\r\n", "output": ["734575871"]}, {"input": "287894773 723316271\r\n", "output": ["723316207"]}, {"input": "171837140 733094070\r\n", "output": ["733094069"]}, {"input": "37839169 350746807\r\n", "output": ["350746727"]}, {"input": "125764821 234689174\r\n", "output": ["234689137"]}, {"input": "413598841 430509920\r\n", "output": ["430509917"]}, {"input": "145320418 592508508\r\n", "output": ["592508479"]}, {"input": "155098216 476450875\r\n", "output": ["476450861"]}, {"input": "459843315 950327842\r\n", "output": ["950327831"]}, {"input": "469621113 834270209\r\n", "output": ["834270209"]}, {"input": "13179877 557546766\r\n", "output": ["557546753"]}, {"input": "541748242 723508350\r\n", "output": ["723508301"]}, {"input": "607450717 924641194\r\n", "output": ["924641189"]}, {"input": "786360384 934418993\r\n", "output": ["934418981"]}, {"input": "649229491 965270051\r\n", "output": ["965270051"]}, {"input": "144179719 953974590\r\n", "output": ["953974583"]}, {"input": "28122086 963752388\r\n", "output": ["963752347"]}, {"input": "268497487 501999053\r\n", "output": ["501999053"]}, {"input": "356423140 385941420\r\n", "output": ["385941419"]}, {"input": "71233638 269883787\r\n", "output": ["269883787"]}, {"input": "2601 698964997\r\n", "output": ["698964983"]}, {"input": "4096 287894773\r\n", "output": ["287894771"]}, {"input": "5675 171837140\r\n", "output": ["171837131"]}, {"input": "13067 350746807\r\n", "output": ["350746727"]}, {"input": "8699 234689174\r\n", "output": ["234689137"]}, {"input": "12190 413598841\r\n", "output": ["413598817"]}, {"input": "20555 592508508\r\n", "output": ["592508479"]}, {"input": "19137 476450875\r\n", "output": ["476450861"]}, {"input": "8793 950327842\r\n", "output": ["950327831"]}, {"input": "1541 834270209\r\n", "output": ["834270209"]}, {"input": "1082 13179877\r\n", "output": ["13179871"]}, {"input": "3888 723508350\r\n", "output": ["723508301"]}, {"input": "14078 607450717\r\n", "output": ["607450703"]}, {"input": "20869 786360384\r\n", "output": ["786360373"]}, {"input": "13689 965270051\r\n", "output": ["965270051"]}, {"input": "782 144179719\r\n", "output": ["144179719"]}, {"input": "404 28122086\r\n", "output": ["28122079"]}, {"input": "21992 501999053\r\n", "output": ["501999053"]}, {"input": "13745 385941420\r\n", "output": ["385941419"]}, {"input": "8711 269883787\r\n", "output": ["269883787"]}, {"input": "31333 981756889\r\n", "output": ["981756871"]}, {"input": "944192808 944193061\r\n", "output": ["-1"]}, {"input": "3 9\r\n", "output": ["7"]}, {"input": "4 5\r\n", "output": ["5"]}, {"input": "2 13\r\n", "output": ["13"]}, {"input": "7 53\r\n", "output": ["53"]}, {"input": "10 1000000000\r\n", "output": ["999999997"]}, {"input": "2 7\r\n", "output": ["7"]}, {"input": "4 9\r\n", "output": ["7"]}]
100
100
100
[{'input': '1541 834270209\r\n', 'output': ['834270209']}, {'input': '8793 950327842\r\n', 'output': ['950327831']}, {'input': '171837140 733094070\r\n', 'output': ['733094069']}, {'input': '649229491 965270051\r\n', 'output': ['965270051']}, {'input': '4 5\r\n', 'output': ['5']}]
[{'input': '404 28122086\r\n', 'output': ['28122079']}, {'input': '31333 981756889\r\n', 'output': ['981756871']}, {'input': '19137 476450875\r\n', 'output': ['476450861']}, {'input': '287894773 723316271\r\n', 'output': ['723316207']}, {'input': '5 50\r\n', 'output': ['49']}]
[{'input': '649229491 965270051\r\n', 'output': ['965270051']}, {'input': '404 28122086\r\n', 'output': ['28122079']}, {'input': '356423140 385941420\r\n', 'output': ['385941419']}, {'input': '20869 786360384\r\n', 'output': ['786360373']}, {'input': '3888 723508350\r\n', 'output': ['723508301']}]
[{'input': '3 4\r\n', 'output': ['-1']}, {'input': '14078 607450717\r\n', 'output': ['607450703']}, {'input': '37839169 350746807\r\n', 'output': ['350746727']}, {'input': '13067 350746807\r\n', 'output': ['350746727']}, {'input': '8699 234689174\r\n', 'output': ['234689137']}]
[{'input': '944192806 944193066\r\n', 'output': ['944192807']}, {'input': '2 7\r\n', 'output': ['7']}, {'input': '19137 476450875\r\n', 'output': ['476450861']}, {'input': '20869 786360384\r\n', 'output': ['786360373']}, {'input': '469621113 834270209\r\n', 'output': ['834270209']}]
100
100
100
100
100
100
100
100
100
100
90
90
90
100
90
303
100
100
92
["monday\ntuesday", "sunday\nsunday", "saturday\ntuesday"]
The input consists of two lines, each of them containing the name of exactly one day of the week. It's guaranteed that each string in the input is from the set "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday".
2a75f68a7374b90b80bb362c6ead9a35
s1=input() s2=input() week=["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"] if week[(week.index(s1)+31)%7]==s2:print("YES") elif week[(week.index(s1)+28)%7]==s2:print("YES") elif week[(week.index(s1)+30)%7]==s2:print("YES") else:print("NO")
["NO", "YES", "YES"]
Python
NoteIn the second sample, one can consider February 1 and March 1 of year 2015. Both these days were Sundays.In the third sample, one can consider July 1 and August 1 of year 2017. First of these two days is Saturday, while the second one is Tuesday.
Print "YES" (without quotes) if such situation is possible during some non-leap year. Otherwise, print "NO" (without quotes).
You are given names of two days of the week.Please, determine whether it is possible that during some non-leap year the first day of some month was equal to the first day of the week you are given, while the first day of the next month was equal to the second day of the week you are given. Both months should belong to one year.In this problem, we consider the Gregorian calendar to be used. The number of months in this calendar is equal to 12. The number of days in months during any non-leap year is: 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31.Names of the days of the week are given with lowercase English letters: "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday".
[{"input": "monday\r\ntuesday\r\n", "output": ["NO"]}, {"input": "sunday\r\nsunday\r\n", "output": ["YES"]}, {"input": "saturday\r\ntuesday\r\n", "output": ["YES"]}, {"input": "tuesday\r\nthursday\r\n", "output": ["YES"]}, {"input": "friday\r\nwednesday\r\n", "output": ["NO"]}, {"input": "sunday\r\nsaturday\r\n", "output": ["NO"]}, {"input": "monday\r\nmonday\r\n", "output": ["YES"]}, {"input": "monday\r\nwednesday\r\n", "output": ["YES"]}, {"input": "monday\r\nthursday\r\n", "output": ["YES"]}, {"input": "monday\r\nfriday\r\n", "output": ["NO"]}, {"input": "monday\r\nsaturday\r\n", "output": ["NO"]}, {"input": "monday\r\nsunday\r\n", "output": ["NO"]}, {"input": "tuesday\r\nmonday\r\n", "output": ["NO"]}, {"input": "tuesday\r\ntuesday\r\n", "output": ["YES"]}, {"input": "tuesday\r\nwednesday\r\n", "output": ["NO"]}, {"input": "tuesday\r\nfriday\r\n", "output": ["YES"]}, {"input": "tuesday\r\nsaturday\r\n", "output": ["NO"]}, {"input": "tuesday\r\nsunday\r\n", "output": ["NO"]}, {"input": "wednesday\r\nmonday\r\n", "output": ["NO"]}, {"input": "wednesday\r\ntuesday\r\n", "output": ["NO"]}, {"input": "wednesday\r\nwednesday\r\n", "output": ["YES"]}, {"input": "wednesday\r\nthursday\r\n", "output": ["NO"]}, {"input": "wednesday\r\nfriday\r\n", "output": ["YES"]}, {"input": "wednesday\r\nsaturday\r\n", "output": ["YES"]}, {"input": "wednesday\r\nsunday\r\n", "output": ["NO"]}, {"input": "thursday\r\nmonday\r\n", "output": ["NO"]}, {"input": "thursday\r\ntuesday\r\n", "output": ["NO"]}, {"input": "thursday\r\nwednesday\r\n", "output": ["NO"]}, {"input": "thursday\r\nthursday\r\n", "output": ["YES"]}, {"input": "thursday\r\nfriday\r\n", "output": ["NO"]}, {"input": "thursday\r\nsaturday\r\n", "output": ["YES"]}, {"input": "thursday\r\nsunday\r\n", "output": ["YES"]}, {"input": "friday\r\nmonday\r\n", "output": ["YES"]}, {"input": "friday\r\ntuesday\r\n", "output": ["NO"]}, {"input": "friday\r\nthursday\r\n", "output": ["NO"]}, {"input": "friday\r\nsaturday\r\n", "output": ["NO"]}, {"input": "friday\r\nsunday\r\n", "output": ["YES"]}, {"input": "saturday\r\nmonday\r\n", "output": ["YES"]}, {"input": "saturday\r\nwednesday\r\n", "output": ["NO"]}, {"input": "saturday\r\nthursday\r\n", "output": ["NO"]}, {"input": "saturday\r\nfriday\r\n", "output": ["NO"]}, {"input": "saturday\r\nsaturday\r\n", "output": ["YES"]}, {"input": "saturday\r\nsunday\r\n", "output": ["NO"]}, {"input": "sunday\r\nmonday\r\n", "output": ["NO"]}, {"input": "sunday\r\ntuesday\r\n", "output": ["YES"]}, {"input": "sunday\r\nwednesday\r\n", "output": ["YES"]}, {"input": "sunday\r\nthursday\r\n", "output": ["NO"]}, {"input": "sunday\r\nfriday\r\n", "output": ["NO"]}, {"input": "friday\r\nfriday\r\n", "output": ["YES"]}]
100
100
100
[{'input': 'friday\r\nthursday\r\n', 'output': ['NO']}, {'input': 'tuesday\r\nwednesday\r\n', 'output': ['NO']}, {'input': 'thursday\r\nmonday\r\n', 'output': ['NO']}, {'input': 'wednesday\r\nmonday\r\n', 'output': ['NO']}, {'input': 'tuesday\r\nsaturday\r\n', 'output': ['NO']}]
[{'input': 'monday\r\nsaturday\r\n', 'output': ['NO']}, {'input': 'tuesday\r\nmonday\r\n', 'output': ['NO']}, {'input': 'friday\r\nmonday\r\n', 'output': ['YES']}, {'input': 'monday\r\nsunday\r\n', 'output': ['NO']}, {'input': 'wednesday\r\nmonday\r\n', 'output': ['NO']}]
[{'input': 'friday\r\nwednesday\r\n', 'output': ['NO']}, {'input': 'saturday\r\nsunday\r\n', 'output': ['NO']}, {'input': 'thursday\r\ntuesday\r\n', 'output': ['NO']}, {'input': 'saturday\r\nmonday\r\n', 'output': ['YES']}, {'input': 'wednesday\r\ntuesday\r\n', 'output': ['NO']}]
[{'input': 'thursday\r\nthursday\r\n', 'output': ['YES']}, {'input': 'tuesday\r\ntuesday\r\n', 'output': ['YES']}, {'input': 'friday\r\nsunday\r\n', 'output': ['YES']}, {'input': 'wednesday\r\nmonday\r\n', 'output': ['NO']}, {'input': 'sunday\r\nfriday\r\n', 'output': ['NO']}]
[{'input': 'friday\r\nfriday\r\n', 'output': ['YES']}, {'input': 'tuesday\r\nwednesday\r\n', 'output': ['NO']}, {'input': 'monday\r\nsunday\r\n', 'output': ['NO']}, {'input': 'thursday\r\nwednesday\r\n', 'output': ['NO']}, {'input': 'wednesday\r\nsunday\r\n', 'output': ['NO']}]
100
100
100
100
100
100
100
100
100
100
50
66.67
66.67
83.33
66.67
304
100
100
66.668
["X0X\n.0.\n.X."]
The input consists of three lines, each of the lines contains characters ".", "X" or "0" (a period, a capital letter X, or a digit zero).
892680e26369325fb00d15543a96192c
def win(l,s): if l[0] == [s, s, s] or l[1] == [s, s, s] or l[2] == [s, s, s] or l[0][0] == s and l[1][0] == s and l[2][0] == s or \ l[0][1] == s and l[1][1] == s and l[2][1] == s or l[0][2] == s and l[1][2] == s and l[2][2] == s or l[0][ 0] == s and l[1][1] == s and l[2][2] == s or l[0][2] == s and l[1][1] == s and l[2][0] == s: return 1 else: return 0 a=list(input()) b=list(input()) c=list(input()) l=[a,b,c] mf=a.count('X')+b.count('X')+c.count('X') ms=a.count('0')+b.count('0')+c.count('0') me=a.count('.')+b.count('.')+c.count('.') if mf -ms!= 1 and mf -ms!=0 : print('illegal') else: n=win(l,'0') m=win(l,'X') if n==1 and m==1 or n==1 and mf-ms!=0 or m==1 and mf-ms!=1: print('illegal') elif n==1: print('the second player won') elif m==1: print('the first player won') else: if me==0: print('draw') elif mf-ms==1: print('second') else:print('first')
["second"]
Python
null
Print one of the six verdicts: first, second, illegal, the first player won, the second player won or draw.
Certainly, everyone is familiar with tic-tac-toe game. The rules are very simple indeed. Two players take turns marking the cells in a 3 × 3 grid (one player always draws crosses, the other β€” noughts). The player who succeeds first in placing three of his marks in a horizontal, vertical or diagonal line wins, and the game is finished. The player who draws crosses goes first. If the grid is filled, but neither Xs, nor 0s form the required line, a draw is announced.You are given a 3 × 3 grid, each grid cell is empty, or occupied by a cross or a nought. You have to find the player (first or second), whose turn is next, or print one of the verdicts below: illegal β€” if the given board layout can't appear during a valid game; the first player won β€” if in the given board layout the first player has just won; the second player won β€” if in the given board layout the second player has just won; draw β€” if the given board layout has just let to a draw.
[{"input": "X0X\r\n.0.\r\n.X.\r\n", "output": ["second"]}, {"input": "0.X\r\nXX.\r\n000\r\n", "output": ["illegal"]}, {"input": "XXX\r\n.0.\r\n000\r\n", "output": ["illegal"]}, {"input": "XXX\r\n...\r\n000\r\n", "output": ["illegal"]}, {"input": "X.X\r\nX..\r\n00.\r\n", "output": ["second"]}, {"input": "X.X\r\nX.0\r\n0.0\r\n", "output": ["first"]}, {"input": "0..\r\n...\r\n...\r\n", "output": ["illegal"]}, {"input": "XXX\r\nX00\r\nX00\r\n", "output": ["the first player won"]}, {"input": "000\r\nX.X\r\nX.X\r\n", "output": ["illegal"]}, {"input": "XXX\r\n0.0\r\n0..\r\n", "output": ["illegal"]}, {"input": "X0X\r\n0X0\r\nX0X\r\n", "output": ["the first player won"]}, {"input": "XX.\r\nX0X\r\nX..\r\n", "output": ["illegal"]}, {"input": "X0X\r\n0X0\r\nX..\r\n", "output": ["the first player won"]}, {"input": "XX0\r\n0..\r\n000\r\n", "output": ["illegal"]}, {"input": "XXX\r\n0..\r\n.0.\r\n", "output": ["the first player won"]}, {"input": "XXX\r\nX..\r\n.00\r\n", "output": ["illegal"]}, {"input": "X00\r\n0.0\r\nXX0\r\n", "output": ["illegal"]}, {"input": "0.0\r\n0XX\r\n..0\r\n", "output": ["illegal"]}, {"input": ".00\r\nX.X\r\n0..\r\n", "output": ["illegal"]}, {"input": "..0\r\n.00\r\n.0X\r\n", "output": ["illegal"]}, {"input": "..0\r\n0..\r\n00X\r\n", "output": ["illegal"]}, {"input": "..0\r\n.XX\r\nX..\r\n", "output": ["illegal"]}, {"input": "0.X\r\n0X0\r\n.00\r\n", "output": ["illegal"]}, {"input": "..X\r\n0X0\r\n0X.\r\n", "output": ["first"]}, {"input": "0X0\r\nX..\r\nX.0\r\n", "output": ["first"]}, {"input": ".0.\r\nX.X\r\n0..\r\n", "output": ["first"]}, {"input": "0X0\r\n00X\r\n.00\r\n", "output": ["illegal"]}, {"input": ".0.\r\n.X0\r\nX..\r\n", "output": ["first"]}, {"input": "00X\r\n0.X\r\n00X\r\n", "output": ["illegal"]}, {"input": "00X\r\n0XX\r\n0X.\r\n", "output": ["the second player won"]}, {"input": "X00\r\n..0\r\nX.X\r\n", "output": ["first"]}, {"input": "X00\r\nX00\r\n.X0\r\n", "output": ["illegal"]}, {"input": "X0X\r\n.X0\r\n0..\r\n", "output": ["first"]}, {"input": "..0\r\nXXX\r\n000\r\n", "output": ["illegal"]}, {"input": "XXX\r\n...\r\n.0.\r\n", "output": ["illegal"]}, {"input": "0..\r\n000\r\nX0X\r\n", "output": ["illegal"]}, {"input": ".00\r\n0X.\r\n0.0\r\n", "output": ["illegal"]}, {"input": "X..\r\nX00\r\n0.0\r\n", "output": ["illegal"]}, {"input": ".X0\r\nXX0\r\nX.X\r\n", "output": ["illegal"]}, {"input": "X.X\r\n0.0\r\nX..\r\n", "output": ["second"]}, {"input": "00X\r\n.00\r\n..0\r\n", "output": ["illegal"]}, {"input": "..0\r\n0.X\r\n00.\r\n", "output": ["illegal"]}, {"input": "0.X\r\nX0X\r\n.X0\r\n", "output": ["illegal"]}, {"input": "0X.\r\n.X.\r\n0X0\r\n", "output": ["illegal"]}, {"input": "00.\r\nX0.\r\n..X\r\n", "output": ["illegal"]}, {"input": "..X\r\n.00\r\nXX.\r\n", "output": ["second"]}, {"input": ".00\r\n.0.\r\n.X.\r\n", "output": ["illegal"]}, {"input": "XX0\r\nX.0\r\nXX0\r\n", "output": ["illegal"]}, {"input": "00.\r\n00.\r\nX.X\r\n", "output": ["illegal"]}, {"input": "X00\r\nX.0\r\nX.0\r\n", "output": ["illegal"]}, {"input": "0X.\r\n0XX\r\n000\r\n", "output": ["illegal"]}, {"input": "00.\r\n00.\r\n.X.\r\n", "output": ["illegal"]}, {"input": "X0X\r\n00.\r\n0.X\r\n", "output": ["illegal"]}, {"input": "XX0\r\nXXX\r\n0X0\r\n", "output": ["illegal"]}, {"input": "XX0\r\n..X\r\nXX0\r\n", "output": ["illegal"]}, {"input": "0X.\r\n..X\r\nX..\r\n", "output": ["illegal"]}, {"input": "...\r\nX0.\r\nXX0\r\n", "output": ["second"]}, {"input": "..X\r\n.0.\r\n0..\r\n", "output": ["illegal"]}, {"input": "00X\r\nXX.\r\n00X\r\n", "output": ["first"]}, {"input": "..0\r\nXX0\r\n..X\r\n", "output": ["second"]}, {"input": ".0.\r\n.00\r\nX00\r\n", "output": ["illegal"]}, {"input": "X00\r\n.XX\r\n00.\r\n", "output": ["illegal"]}, {"input": ".00\r\n0.X\r\n000\r\n", "output": ["illegal"]}, {"input": "X0.\r\n..0\r\nX.0\r\n", "output": ["illegal"]}, {"input": "X0X\r\n.XX\r\n00.\r\n", "output": ["second"]}, {"input": "0X.\r\n00.\r\n.X.\r\n", "output": ["illegal"]}, {"input": "0..\r\n000\r\n...\r\n", "output": ["illegal"]}, {"input": ".0.\r\n...\r\n0.0\r\n", "output": ["illegal"]}, {"input": "..X\r\nX00\r\n0.0\r\n", "output": ["illegal"]}, {"input": "0XX\r\n...\r\nX0.\r\n", "output": ["second"]}, {"input": "X.X\r\n0X.\r\n.0X\r\n", "output": ["illegal"]}, {"input": "XX0\r\nX.X\r\n00.\r\n", "output": ["second"]}, {"input": ".0X\r\n.00\r\n00.\r\n", "output": ["illegal"]}, {"input": ".XX\r\nXXX\r\n0..\r\n", "output": ["illegal"]}, {"input": "XX0\r\n.X0\r\n.0.\r\n", "output": ["first"]}, {"input": "X00\r\n0.X\r\nX..\r\n", "output": ["first"]}, {"input": "X..\r\n.X0\r\nX0.\r\n", "output": ["second"]}, {"input": ".0X\r\nX..\r\nXXX\r\n", "output": ["illegal"]}, {"input": "X0X\r\nXXX\r\nX.X\r\n", "output": ["illegal"]}, {"input": ".00\r\nX0.\r\n00X\r\n", "output": ["illegal"]}, {"input": "0XX\r\n.X0\r\n0.0\r\n", "output": ["illegal"]}, {"input": "00X\r\nXXX\r\n..0\r\n", "output": ["the first player won"]}, {"input": "X0X\r\n...\r\n.X.\r\n", "output": ["illegal"]}, {"input": ".X0\r\n...\r\n0X.\r\n", "output": ["first"]}, {"input": "X..\r\n0X0\r\nX.0\r\n", "output": ["first"]}, {"input": "..0\r\n.00\r\nX.0\r\n", "output": ["illegal"]}, {"input": ".XX\r\n.0.\r\nX0X\r\n", "output": ["illegal"]}, {"input": "00.\r\n0XX\r\n..0\r\n", "output": ["illegal"]}, {"input": ".0.\r\n00.\r\n00.\r\n", "output": ["illegal"]}, {"input": "00.\r\n000\r\nX.X\r\n", "output": ["illegal"]}, {"input": "0X0\r\n.X0\r\n.X.\r\n", "output": ["illegal"]}, {"input": "00X\r\n0..\r\n0..\r\n", "output": ["illegal"]}, {"input": ".X.\r\n.X0\r\nX.0\r\n", "output": ["second"]}, {"input": ".0.\r\n0X0\r\nX0X\r\n", "output": ["illegal"]}, {"input": "...\r\nX.0\r\n0..\r\n", "output": ["illegal"]}, {"input": "..0\r\nXX.\r\n00X\r\n", "output": ["first"]}, {"input": "0.X\r\n.0X\r\nX00\r\n", "output": ["illegal"]}, {"input": "..X\r\n0X.\r\n.0.\r\n", "output": ["first"]}, {"input": "..X\r\nX.0\r\n.0X\r\n", "output": ["second"]}, {"input": "X0.\r\n.0X\r\nX0X\r\n", "output": ["illegal"]}, {"input": "...\r\n.0.\r\n.X0\r\n", "output": ["illegal"]}, {"input": ".X0\r\nXX0\r\n0..\r\n", "output": ["first"]}, {"input": "0X.\r\n...\r\nX..\r\n", "output": ["second"]}, {"input": ".0.\r\n0.0\r\n0.X\r\n", "output": ["illegal"]}, {"input": "XX.\r\n.X0\r\n.0X\r\n", "output": ["illegal"]}, {"input": ".0.\r\nX0X\r\nX00\r\n", "output": ["illegal"]}, {"input": "0X.\r\n.X0\r\nX..\r\n", "output": ["second"]}, {"input": "..0\r\n0X.\r\n000\r\n", "output": ["illegal"]}, {"input": "0.0\r\nX.X\r\nXX.\r\n", "output": ["illegal"]}, {"input": ".X.\r\n.XX\r\nX0.\r\n", "output": ["illegal"]}, {"input": "X.X\r\n.XX\r\n0X.\r\n", "output": ["illegal"]}, {"input": "...\r\n.X.\r\n...\r\n", "output": ["second"]}, {"input": "..0\r\n.X.\r\n...\r\n", "output": ["first"]}, {"input": "..0\r\n.XX\r\n...\r\n", "output": ["second"]}, {"input": "..0\r\n0XX\r\n...\r\n", "output": ["first"]}, {"input": "X.0\r\n0XX\r\n...\r\n", "output": ["second"]}, {"input": "X.0\r\n0XX\r\n..0\r\n", "output": ["first"]}, {"input": "X.0\r\n0XX\r\n.X0\r\n", "output": ["second"]}, {"input": "X00\r\n0XX\r\n.X0\r\n", "output": ["first"]}, {"input": "X00\r\n0XX\r\nXX0\r\n", "output": ["draw"]}, {"input": "X00\r\n0XX\r\n0X0\r\n", "output": ["illegal"]}, {"input": "XXX\r\nXXX\r\nXXX\r\n", "output": ["illegal"]}, {"input": "000\r\n000\r\n000\r\n", "output": ["illegal"]}, {"input": "XX0\r\n00X\r\nXX0\r\n", "output": ["draw"]}, {"input": "X00\r\n00X\r\nXX0\r\n", "output": ["illegal"]}, {"input": "X.0\r\n00.\r\nXXX\r\n", "output": ["the first player won"]}, {"input": "X..\r\nX0.\r\nX0.\r\n", "output": ["the first player won"]}, {"input": ".XX\r\n000\r\nXX0\r\n", "output": ["the second player won"]}, {"input": "X0.\r\nX.X\r\nX00\r\n", "output": ["the first player won"]}, {"input": "00X\r\nX00\r\nXXX\r\n", "output": ["the first player won"]}, {"input": "XXX\r\n.00\r\nX0.\r\n", "output": ["the first player won"]}, {"input": "XX0\r\n000\r\nXX.\r\n", "output": ["the second player won"]}, {"input": ".X0\r\n0.0\r\nXXX\r\n", "output": ["the first player won"]}, {"input": "0XX\r\nX00\r\n0XX\r\n", "output": ["draw"]}, {"input": "0XX\r\nX0X\r\n00X\r\n", "output": ["the first player won"]}, {"input": "XX0\r\n0XX\r\n0X0\r\n", "output": ["the first player won"]}, {"input": "0X0\r\nX0X\r\nX0X\r\n", "output": ["draw"]}, {"input": "XXX\r\n0.0\r\n...\r\n", "output": ["the first player won"]}, {"input": "X0X\r\n0XX\r\n00X\r\n", "output": ["the first player won"]}, {"input": "0XX\r\nX0.\r\nX00\r\n", "output": ["the second player won"]}, {"input": "X.0\r\n0X0\r\nXX0\r\n", "output": ["the second player won"]}, {"input": "X0X\r\nX0X\r\n0X0\r\n", "output": ["draw"]}, {"input": "X.0\r\n00X\r\n0XX\r\n", "output": ["the second player won"]}, {"input": "00X\r\nX0X\r\n.X0\r\n", "output": ["the second player won"]}, {"input": "X0X\r\n.00\r\nX0X\r\n", "output": ["the second player won"]}, {"input": "0XX\r\nX00\r\nX0X\r\n", "output": ["draw"]}, {"input": "000\r\nX0X\r\n.XX\r\n", "output": ["the second player won"]}, {"input": "0.0\r\n0.X\r\nXXX\r\n", "output": ["the first player won"]}, {"input": "X.0\r\nX0.\r\n0X.\r\n", "output": ["the second player won"]}, {"input": "X0X\r\n0X0\r\n..X\r\n", "output": ["the first player won"]}, {"input": "0X0\r\nXX0\r\n.X.\r\n", "output": ["the first player won"]}, {"input": "X0.\r\n.X.\r\n0.X\r\n", "output": ["the first player won"]}, {"input": "0XX\r\nX00\r\n.X0\r\n", "output": ["the second player won"]}, {"input": "0.0\r\nXXX\r\n0.X\r\n", "output": ["the first player won"]}, {"input": ".0X\r\n.X.\r\nX.0\r\n", "output": ["the first player won"]}, {"input": "XXX\r\nX.0\r\n0.0\r\n", "output": ["the first player won"]}, {"input": "XX0\r\nX..\r\nX00\r\n", "output": ["the first player won"]}, {"input": "XXX\r\n00X\r\n00X\r\n", "output": ["the first player won"]}, {"input": "X00\r\n00X\r\nXXX\r\n", "output": ["the first player won"]}, {"input": "0X0\r\nX0X\r\n0X.\r\n", "output": ["the second player won"]}, {"input": "XX0\r\nX00\r\n0X.\r\n", "output": ["the second player won"]}, {"input": "..X\r\n0X0\r\nX..\r\n", "output": ["the first player won"]}, {"input": "X0.\r\n00.\r\nXXX\r\n", "output": ["the first player won"]}, {"input": "0.X\r\nX00\r\nXX0\r\n", "output": ["the second player won"]}, {"input": "X0.\r\n0X.\r\n..X\r\n", "output": ["the first player won"]}, {"input": "00X\r\nX0.\r\nXX0\r\n", "output": ["the second player won"]}, {"input": "XX.\r\n000\r\n0XX\r\n", "output": ["the second player won"]}, {"input": "..X\r\n0.X\r\n.0X\r\n", "output": ["the first player won"]}, {"input": "X00\r\n.0X\r\n0XX\r\n", "output": ["the second player won"]}, {"input": "00X\r\n0X.\r\nXX.\r\n", "output": ["the first player won"]}, {"input": "X00\r\nXX.\r\n0.X\r\n", "output": ["the first player won"]}, {"input": "XXX\r\n00X\r\n0X0\r\n", "output": ["the first player won"]}, {"input": "X00\r\nXX0\r\n0XX\r\n", "output": ["the first player won"]}, {"input": "0X0\r\nX00\r\nXXX\r\n", "output": ["the first player won"]}, {"input": "XX0\r\nX00\r\n.X0\r\n", "output": ["the second player won"]}]
100
100
100
[{'input': 'X.0\r\n00.\r\nXXX\r\n', 'output': ['the first player won']}, {'input': 'X0.\r\n00.\r\nXXX\r\n', 'output': ['the first player won']}, {'input': '.0X\r\n.00\r\n00.\r\n', 'output': ['illegal']}, {'input': '..X\r\n0X.\r\n.0.\r\n', 'output': ['first']}, {'input': '00.\r\nX0.\r\n..X\r\n', 'output': ['illegal']}]
[{'input': '0..\r\n000\r\n...\r\n', 'output': ['illegal']}, {'input': '.0.\r\n00.\r\n00.\r\n', 'output': ['illegal']}, {'input': '0X0\r\nX00\r\nXXX\r\n', 'output': ['the first player won']}, {'input': 'X00\r\n0.X\r\nX..\r\n', 'output': ['first']}, {'input': '0X.\r\n.X.\r\n0X0\r\n', 'output': ['illegal']}]
[{'input': '0X0\r\nX..\r\nX.0\r\n', 'output': ['first']}, {'input': '.0X\r\n.X.\r\nX.0\r\n', 'output': ['the first player won']}, {'input': '.0.\r\n.X0\r\nX..\r\n', 'output': ['first']}, {'input': 'X.X\r\nX.0\r\n0.0\r\n', 'output': ['first']}, {'input': '.0.\r\n.00\r\nX00\r\n', 'output': ['illegal']}]
[{'input': 'X..\r\n.X0\r\nX0.\r\n', 'output': ['second']}, {'input': '.00\r\nX0.\r\n00X\r\n', 'output': ['illegal']}, {'input': '...\r\n.X.\r\n...\r\n', 'output': ['second']}, {'input': 'XXX\r\n0.0\r\n0..\r\n', 'output': ['illegal']}, {'input': '0.0\r\n0.X\r\nXXX\r\n', 'output': ['the first player won']}]
[{'input': '000\r\nX.X\r\nX.X\r\n', 'output': ['illegal']}, {'input': 'X00\r\n00X\r\nXXX\r\n', 'output': ['the first player won']}, {'input': '000\r\n000\r\n000\r\n', 'output': ['illegal']}, {'input': 'XX0\r\n0..\r\n000\r\n', 'output': ['illegal']}, {'input': '..0\r\nXX.\r\n00X\r\n', 'output': ['first']}]
100
100
100
100
100
84.62
88.46
84.62
88.46
88.46
71.43
78.57
71.43
78.57
78.57
305
100
86.924
75.714
["10\nrocesfedoc", "16\nplmaetwoxesisiht", "1\nz"]
The first line of input consists of a single integer $$$n$$$ ($$$1 \le n \le 100$$$) β€” the length of the string $$$t$$$. The second line of input consists of the string $$$t$$$. The length of $$$t$$$ is $$$n$$$, and it consists only of lowercase Latin letters.
1b0b2ee44c63cb0634cb63f2ad65cdd3
a = int(input()) s = list(input()) b = [] for i in range(a, 1, -1): if a % i == 0: b.append(i) for i in range(len(b)-1, -1, -1): s[0:b[i]] = reversed(s[0:b[i]]) s = "".join(s) print(s)
["codeforces", "thisisexampletwo", "z"]
Python
NoteThe first example is described in the problem statement.
Print a string $$$s$$$ such that the above algorithm results in $$$t$$$.
A string $$$s$$$ of length $$$n$$$ can be encrypted by the following algorithm: iterate over all divisors of $$$n$$$ in decreasing order (i.e. from $$$n$$$ to $$$1$$$), for each divisor $$$d$$$, reverse the substring $$$s[1 \dots d]$$$ (i.e. the substring which starts at position $$$1$$$ and ends at position $$$d$$$). For example, the above algorithm applied to the string $$$s$$$="codeforces" leads to the following changes: "codeforces" $$$\to$$$ "secrofedoc" $$$\to$$$ "orcesfedoc" $$$\to$$$ "rocesfedoc" $$$\to$$$ "rocesfedoc" (obviously, the last reverse operation doesn't change the string because $$$d=1$$$).You are given the encrypted string $$$t$$$. Your task is to decrypt this string, i.e., to find a string $$$s$$$ such that the above algorithm results in string $$$t$$$. It can be proven that this string $$$s$$$ always exists and is unique.
[{"input": "10\r\nrocesfedoc\r\n", "output": ["codeforces"]}, {"input": "16\r\nplmaetwoxesisiht\r\n", "output": ["thisisexampletwo"]}, {"input": "1\r\nz\r\n", "output": ["z"]}, {"input": "2\r\nir\r\n", "output": ["ri"]}, {"input": "3\r\nilj\r\n", "output": ["jli"]}, {"input": "4\r\njfyy\r\n", "output": ["yyjf"]}, {"input": "6\r\nkrdych\r\n", "output": ["hcyrkd"]}, {"input": "60\r\nfnebsopcvmlaoecpzmakqigyuutueuozjxutlwwiochekmhjgwxsgfbcrpqj\r\n", "output": ["jqprcbfgsxwgjhmkehcoiwwltuxjzokamzpalobnfespcvmoecqigyuutueu"]}, {"input": "64\r\nhnlzzhrvqnldswxfsrowfhmyzbxtyoxhogudasgywxycyhzgiseerbislcncvnwy\r\n", "output": ["ywnvcnclsibreesigzhycyxwygsadugofxwsdlnqzlhnzhrvsrowfhmyzbxtyoxh"]}, {"input": "97\r\nqnqrmdhmbubaijtwsecbidqouhlecladwgwcuxbigckrfzasnbfbslukoayhcgquuacygakhxoubibxtqkpyyhzjipylujgrc\r\n", "output": ["crgjulypijzhyypkqtxbibuoxhkagycauuqgchyaokulsbfbnsazfrkcgibxucwgwdalcelhuoqdibceswtjiabubmhdmrqnq"]}, {"input": "100\r\nedykhvzcntljuuoqghptioetqnfllwekzohiuaxelgecabvsbibgqodqxvyfkbyjwtgbyhvssntinkwsinwsmalusiwnjmtcoovf\r\n", "output": ["fvooctmjnwisulamswniswknitnssvhybgtwjybkfyvxqdoqgbqteoitnczvkyedhljuuoqghptnfllwekzohiuaxelgecabvsbi"]}, {"input": "96\r\nqtbcksuvxonzbkokhqlgkrvimzqmqnrvqlihrmksldyydacbtckfphenxszcnzhfjmpeykrvshgiboivkvabhrpphgavvprz\r\n", "output": ["zrpvvaghpprhbavkviobighsvrkyepmjfhznczsxnehpfkctvrnqmqzmkokbvuctqbksxonzhqlgkrviqlihrmksldyydacb"]}, {"input": "90\r\nmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm\r\n", "output": ["mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm"]}, {"input": "89\r\nwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww\r\n", "output": ["wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww"]}, {"input": "99\r\nqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\r\n", "output": ["qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"]}, {"input": "100\r\noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo\r\n", "output": ["oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo"]}, {"input": "60\r\nwwwwwxwwwwwwfhwwhwwwwwwawwwwwwwwwwwwwnwwwwwwwwwwwwwwwwwwwwww\r\n", "output": ["wwwwwwwwwwwwwwwwwwwwwwnwwwwwwwwwwhwwwxwwwwwwwwwfhwwwwawwwwww"]}, {"input": "90\r\ncccchccccccccccccccccccccccccccwcccccccccgcccccchccccccccccccccccccccccxccccccncccccccuccc\r\n", "output": ["cccucccccccnccccccxcccccccccccccccccccccchccccccccccccccccccccccchccccccccccwcccccccccgccc"]}, {"input": "97\r\nfwffffffffffffffffffffffffrffffffffffffffzfffffffffffffffftfcfffffffqffffffffffffffffffffffyfffff\r\n", "output": ["fffffyffffffffffffffffffffffqfffffffcftffffffffffffffffzffffffffffffffrffffffffffffffffffffffffwf"]}, {"input": "100\r\ndjjjjjjjjjjgjjjjjjjjjjjjjjsvjjjjjjjjjjmjjjjjjjjjjjjjajjjjjjajjjjjjrjjjjjjjjjjjjrjjtjjjjjjjjjjjjjojjj\r\n", "output": ["jjjojjjjjjjjjjjjjtjjrjjjjjjjjjjjjrjjjjjjajjjjjjajjjjjjjjjjjjjjdjjjgjjjjjjjjjsvjjjjjjjjjjmjjjjjjjjjjj"]}]
100
100
100
[{'input': '96\r\nqtbcksuvxonzbkokhqlgkrvimzqmqnrvqlihrmksldyydacbtckfphenxszcnzhfjmpeykrvshgiboivkvabhrpphgavvprz\r\n', 'output': ['zrpvvaghpprhbavkviobighsvrkyepmjfhznczsxnehpfkctvrnqmqzmkokbvuctqbksxonzhqlgkrviqlihrmksldyydacb']}, {'input': '100\r\noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo\r\n', 'output': ['oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo']}, {'input': '99\r\nqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\r\n', 'output': ['qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq']}, {'input': '90\r\ncccchccccccccccccccccccccccccccwcccccccccgcccccchccccccccccccccccccccccxccccccncccccccuccc\r\n', 'output': ['cccucccccccnccccccxcccccccccccccccccccccchccccccccccccccccccccccchccccccccccwcccccccccgccc']}, {'input': '97\r\nfwffffffffffffffffffffffffrffffffffffffffzfffffffffffffffftfcfffffffqffffffffffffffffffffffyfffff\r\n', 'output': ['fffffyffffffffffffffffffffffqfffffffcftffffffffffffffffzffffffffffffffrffffffffffffffffffffffffwf']}]
[{'input': '97\r\nfwffffffffffffffffffffffffrffffffffffffffzfffffffffffffffftfcfffffffqffffffffffffffffffffffyfffff\r\n', 'output': ['fffffyffffffffffffffffffffffqfffffffcftffffffffffffffffzffffffffffffffrffffffffffffffffffffffffwf']}, {'input': '16\r\nplmaetwoxesisiht\r\n', 'output': ['thisisexampletwo']}, {'input': '1\r\nz\r\n', 'output': ['z']}, {'input': '90\r\ncccchccccccccccccccccccccccccccwcccccccccgcccccchccccccccccccccccccccccxccccccncccccccuccc\r\n', 'output': ['cccucccccccnccccccxcccccccccccccccccccccchccccccccccccccccccccccchccccccccccwcccccccccgccc']}, {'input': '100\r\nedykhvzcntljuuoqghptioetqnfllwekzohiuaxelgecabvsbibgqodqxvyfkbyjwtgbyhvssntinkwsinwsmalusiwnjmtcoovf\r\n', 'output': ['fvooctmjnwisulamswniswknitnssvhybgtwjybkfyvxqdoqgbqteoitnczvkyedhljuuoqghptnfllwekzohiuaxelgecabvsbi']}]
[{'input': '6\r\nkrdych\r\n', 'output': ['hcyrkd']}, {'input': '100\r\nedykhvzcntljuuoqghptioetqnfllwekzohiuaxelgecabvsbibgqodqxvyfkbyjwtgbyhvssntinkwsinwsmalusiwnjmtcoovf\r\n', 'output': ['fvooctmjnwisulamswniswknitnssvhybgtwjybkfyvxqdoqgbqteoitnczvkyedhljuuoqghptnfllwekzohiuaxelgecabvsbi']}, {'input': '10\r\nrocesfedoc\r\n', 'output': ['codeforces']}, {'input': '4\r\njfyy\r\n', 'output': ['yyjf']}, {'input': '3\r\nilj\r\n', 'output': ['jli']}]
[{'input': '100\r\ndjjjjjjjjjjgjjjjjjjjjjjjjjsvjjjjjjjjjjmjjjjjjjjjjjjjajjjjjjajjjjjjrjjjjjjjjjjjjrjjtjjjjjjjjjjjjjojjj\r\n', 'output': ['jjjojjjjjjjjjjjjjtjjrjjjjjjjjjjjjrjjjjjjajjjjjjajjjjjjjjjjjjjjdjjjgjjjjjjjjjsvjjjjjjjjjjmjjjjjjjjjjj']}, {'input': '99\r\nqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\r\n', 'output': ['qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq']}, {'input': '60\r\nfnebsopcvmlaoecpzmakqigyuutueuozjxutlwwiochekmhjgwxsgfbcrpqj\r\n', 'output': ['jqprcbfgsxwgjhmkehcoiwwltuxjzokamzpalobnfespcvmoecqigyuutueu']}, {'input': '16\r\nplmaetwoxesisiht\r\n', 'output': ['thisisexampletwo']}, {'input': '89\r\nwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww\r\n', 'output': ['wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww']}]
[{'input': '60\r\nfnebsopcvmlaoecpzmakqigyuutueuozjxutlwwiochekmhjgwxsgfbcrpqj\r\n', 'output': ['jqprcbfgsxwgjhmkehcoiwwltuxjzokamzpalobnfespcvmoecqigyuutueu']}, {'input': '99\r\nqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\r\n', 'output': ['qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq']}, {'input': '16\r\nplmaetwoxesisiht\r\n', 'output': ['thisisexampletwo']}, {'input': '97\r\nfwffffffffffffffffffffffffrffffffffffffffzfffffffffffffffftfcfffffffqffffffffffffffffffffffyfffff\r\n', 'output': ['fffffyffffffffffffffffffffffqfffffffcftffffffffffffffffzffffffffffffffrffffffffffffffffffffffffwf']}, {'input': '100\r\ndjjjjjjjjjjgjjjjjjjjjjjjjjsvjjjjjjjjjjmjjjjjjjjjjjjjajjjjjjajjjjjjrjjjjjjjjjjjjrjjtjjjjjjjjjjjjjojjj\r\n', 'output': ['jjjojjjjjjjjjjjjjtjjrjjjjjjjjjjjjrjjjjjjajjjjjjajjjjjjjjjjjjjjdjjjgjjjjjjjjjsvjjjjjjjjjjmjjjjjjjjjjj']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
306
100
100
100
["3 3", "6 5", "1000000000 1"]
The only line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^9$$$, $$$1 \le m \le 1000$$$)Β β€” the size of the field and the number of parts to split the sets into.
2ec9e7cddc634d7830575e14363a4657
n, m = [int(i) for i in input().split()] ans = 0 ar = [n // m] * m for i in range(1, n % m + 1, 1): ar[i] += 1 for i in range(m): for j in range(m): if ((i * i + j * j) % m == 0): ans += ar[i] * ar[j] print(ans)
["1", "13", "1000000000000000000"]
Python
NoteIn the first example, only the set for cell $$$(3, 3)$$$ can be split equally ($$$3^2 + 3^2 = 18$$$, which is divisible by $$$m=3$$$).In the second example, the sets for the following cells can be divided equally: $$$(1, 2)$$$ and $$$(2, 1)$$$, since $$$1^2 + 2^2 = 5$$$, which is divisible by $$$5$$$; $$$(1, 3)$$$ and $$$(3, 1)$$$; $$$(2, 4)$$$ and $$$(4, 2)$$$; $$$(2, 6)$$$ and $$$(6, 2)$$$; $$$(3, 4)$$$ and $$$(4, 3)$$$; $$$(3, 6)$$$ and $$$(6, 3)$$$; $$$(5, 5)$$$. In the third example, sets in all cells can be divided equally, since $$$m = 1$$$.
Print a single integerΒ β€” the number of sets that can be split equally.
Arkady and his friends love playing checkers on an $$$n \times n$$$ field. The rows and the columns of the field are enumerated from $$$1$$$ to $$$n$$$.The friends have recently won a championship, so Arkady wants to please them with some candies. Remembering an old parable (but not its moral), Arkady wants to give to his friends one set of candies per each cell of the field: the set of candies for cell $$$(i, j)$$$ will have exactly $$$(i^2 + j^2)$$$ candies of unique type.There are $$$m$$$ friends who deserve the present. How many of these $$$n \times n$$$ sets of candies can be split equally into $$$m$$$ parts without cutting a candy into pieces? Note that each set has to be split independently since the types of candies in different sets are different.
[{"input": "3 3\r\n", "output": ["1"]}, {"input": "6 5\r\n", "output": ["13"]}, {"input": "1000000000 1\r\n", "output": ["1000000000000000000"]}, {"input": "1 1\r\n", "output": ["1"]}, {"input": "1000000000 81\r\n", "output": ["12345678987654321"]}, {"input": "10000 1\r\n", "output": ["100000000"]}, {"input": "10000 2\r\n", "output": ["50000000"]}, {"input": "10000 3\r\n", "output": ["11108889"]}, {"input": "15 1000\r\n", "output": ["0"]}, {"input": "10 200\r\n", "output": ["1"]}, {"input": "1000000000 1000\r\n", "output": ["3400000000000000"]}, {"input": "999999998 229\r\n", "output": ["8714555372170630"]}, {"input": "999999999 228\r\n", "output": ["76946738381041"]}, {"input": "1 2\r\n", "output": ["1"]}, {"input": "10000 5\r\n", "output": ["36000000"]}, {"input": "1 10\r\n", "output": ["0"]}, {"input": "100 100\r\n", "output": ["260"]}, {"input": "360 900\r\n", "output": ["374"]}, {"input": "1000 999\r\n", "output": ["657"]}, {"input": "12345 1\r\n", "output": ["152399025"]}]
100
100
100
[{'input': '15 1000\r\n', 'output': ['0']}, {'input': '1000000000 81\r\n', 'output': ['12345678987654321']}, {'input': '10 200\r\n', 'output': ['1']}, {'input': '100 100\r\n', 'output': ['260']}, {'input': '3 3\r\n', 'output': ['1']}]
[{'input': '100 100\r\n', 'output': ['260']}, {'input': '10000 2\r\n', 'output': ['50000000']}, {'input': '15 1000\r\n', 'output': ['0']}, {'input': '12345 1\r\n', 'output': ['152399025']}, {'input': '1 10\r\n', 'output': ['0']}]
[{'input': '1 2\r\n', 'output': ['1']}, {'input': '360 900\r\n', 'output': ['374']}, {'input': '15 1000\r\n', 'output': ['0']}, {'input': '10000 3\r\n', 'output': ['11108889']}, {'input': '3 3\r\n', 'output': ['1']}]
[{'input': '1 2\r\n', 'output': ['1']}, {'input': '3 3\r\n', 'output': ['1']}, {'input': '6 5\r\n', 'output': ['13']}, {'input': '10000 5\r\n', 'output': ['36000000']}, {'input': '1 1\r\n', 'output': ['1']}]
[{'input': '999999999 228\r\n', 'output': ['76946738381041']}, {'input': '10000 1\r\n', 'output': ['100000000']}, {'input': '10 200\r\n', 'output': ['1']}, {'input': '10000 2\r\n', 'output': ['50000000']}, {'input': '360 900\r\n', 'output': ['374']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
307
100
100
100
["Is it a melon?", "Is it an apple?", "Is it a banana ?", "Is it an apple and a banana simultaneouSLY?"]
The single line contains a question represented by a non-empty line consisting of large and small Latin letters, spaces and a question mark. The line length does not exceed 100. It is guaranteed that the question mark occurs exactly once in the line β€” as the last symbol and that the line contains at least one letter.
dea7eb04e086a4c1b3924eff255b9648
s = input() vowels = 'aeiouyAEIOUY' if s.split()[-1] == '?': if s.split()[-2][-1] in vowels: print('YES') else: print('NO') else: if s.split()[-1][:-1][-1] in vowels: print('YES') else: print('NO')
["NO", "YES", "YES", "YES"]
Python
null
Print answer for the question in a single line: YES if the answer is "Yes", NO if the answer is "No". Remember that in the reply to the question the last letter, not the last character counts. I. e. the spaces and the question mark do not count as letters.
Vasya plays the sleuth with his friends. The rules of the game are as follows: those who play for the first time, that is Vasya is the sleuth, he should investigate a "crime" and find out what is happening. He can ask any questions whatsoever that can be answered with "Yes" or "No". All the rest agree beforehand to answer the questions like that: if the question’s last letter is a vowel, they answer "Yes" and if the last letter is a consonant, they answer "No". Of course, the sleuth knows nothing about it and his task is to understand that.Unfortunately, Vasya is not very smart. After 5 hours of endless stupid questions everybody except Vasya got bored. That’s why Vasya’s friends ask you to write a program that would give answers instead of them.The English alphabet vowels are: A, E, I, O, U, YThe English alphabet consonants are: B, C, D, F, G, H, J, K, L, M, N, P, Q, R, S, T, V, W, X, Z
[{"input": "Is it a melon?\r\n", "output": ["NO"]}, {"input": "Is it an apple?\r\n", "output": ["YES"]}, {"input": " Is it a banana ?\r\n", "output": ["YES"]}, {"input": "Is it an apple and a banana simultaneouSLY?\r\n", "output": ["YES"]}, {"input": "oHtSbDwzHb?\r\n", "output": ["NO"]}, {"input": "sZecYdUvZHrXx?\r\n", "output": ["NO"]}, {"input": "uMtXK?\r\n", "output": ["NO"]}, {"input": "U?\r\n", "output": ["YES"]}, {"input": "aqFDkCUKeHMyvZFcAyWlMUSQTFomtaWjoKLVyxLCw vcufPBFbaljOuHWiDCROYTcmbgzbaqHXKPOYEbuEtRqqoxBbOETCsQzhw?\r\n", "output": ["NO"]}, {"input": "dJcNqQiFXzcbsj fItCpBLyXOnrSBPebwyFHlxUJHqCUzzCmcAvMiKL NunwOXnKeIxUZmBVwiCUfPkjRAkTPbkYCmwRRnDSLaz?\r\n", "output": ["NO"]}, {"input": "gxzXbdcAQMuFKuuiPohtMgeypr wpDIoDSyOYTdvylcg SoEBZjnMHHYZGEqKgCgBeTbyTwyGuPZxkxsnSczotBdYyfcQsOVDVC?\r\n", "output": ["NO"]}, {"input": "FQXBisXaJFMiHFQlXjixBDMaQuIbyqSBKGsBfTmBKCjszlGVZxEOqYYqRTUkGpSDDAoOXyXcQbHcPaegeOUBNeSD JiKOdECPOF?\r\n", "output": ["NO"]}, {"input": "YhCuZnrWUBEed?\r\n", "output": ["NO"]}, {"input": "hh?\r\n", "output": ["NO"]}, {"input": "whU?\r\n", "output": ["YES"]}, {"input": "fgwg?\r\n", "output": ["NO"]}, {"input": "GlEmEPKrYcOnBNJUIFjszWUyVdvWw DGDjoCMtRJUburkPToCyDrOtMr?\r\n", "output": ["NO"]}, {"input": "n?\r\n", "output": ["NO"]}, {"input": "BueDOlxgzeNlxrzRrMbKiQdmGujEKmGxclvaPpTuHmTqBp?\r\n", "output": ["NO"]}, {"input": "iehvZNQXDGCuVmJPOEysLyUryTdfaIxIuTzTadDbqRQGoCLXkxnyfWSGoLXebNnQQNTqAQJebbyYvHOfpUnXeWdjx?\r\n", "output": ["NO"]}, {"input": " J ?\r\n", "output": ["NO"]}, {"input": " j ?\r\n", "output": ["NO"]}, {"input": " o ?\r\n", "output": ["YES"]}, {"input": " T ?\r\n", "output": ["NO"]}, {"input": " q ?\r\n", "output": ["NO"]}, {"input": " j ?\r\n", "output": ["NO"]}, {"input": " c ?\r\n", "output": ["NO"]}, {"input": " B ?\r\n", "output": ["NO"]}, {"input": "LuhxDHVwMPTtUIUMIQTuQETgXCOQPsfdFlyHvpfOVedjUTpGLAZGOHloIjJJtOLAlHPivzA?\r\n", "output": ["YES"]}, {"input": "wmztmzFfwbGyOmNHENUFMTsFEMWYA?\r\n", "output": ["YES"]}, {"input": "wGsfZCSwN PEUhNUrLfABrxA?\r\n", "output": ["YES"]}, {"input": "mCDHENXjYbgMdBimAdPnewaHfpGWowjWrVAdvWczjw iDcUbyzMsmsnwbviiKiAyGVA?\r\n", "output": ["YES"]}, {"input": "ARIWnwqFqxsQXsXXzHqvFjxOCttAGPUzDtWzsenPYdNXuFOIUGYZsLLK IaoxiyjBBRThoelwdPTkuCQfcBLUEJpCPIrVZlvUWA?\r\n", "output": ["YES"]}, {"input": " PslvVpgpN BXkMFBEVXsyZFIQbBEFxGkYTeXKrOdcmhbiTUatYRUoYAayrchqbksswIlfIjerZPqptvCGnMUhyrQSvwltRhFzA?\r\n", "output": ["YES"]}, {"input": "HpBkttwSjBXDmyleGiRWNUMPaAIE uzTrp KJDzaUiCdsMYOoWKHoUhWUoecCPmACymMUUbGav UMRpCytPETwNFAObZJA?\r\n", "output": ["YES"]}]
100
100
100
[{'input': ' q ?\r\n', 'output': ['NO']}, {'input': 'wmztmzFfwbGyOmNHENUFMTsFEMWYA?\r\n', 'output': ['YES']}, {'input': ' j ?\r\n', 'output': ['NO']}, {'input': 'YhCuZnrWUBEed?\r\n', 'output': ['NO']}, {'input': 'Is it an apple and a banana simultaneouSLY?\r\n', 'output': ['YES']}]
[{'input': 'iehvZNQXDGCuVmJPOEysLyUryTdfaIxIuTzTadDbqRQGoCLXkxnyfWSGoLXebNnQQNTqAQJebbyYvHOfpUnXeWdjx?\r\n', 'output': ['NO']}, {'input': 'n?\r\n', 'output': ['NO']}, {'input': ' T ?\r\n', 'output': ['NO']}, {'input': 'gxzXbdcAQMuFKuuiPohtMgeypr wpDIoDSyOYTdvylcg SoEBZjnMHHYZGEqKgCgBeTbyTwyGuPZxkxsnSczotBdYyfcQsOVDVC?\r\n', 'output': ['NO']}, {'input': 'sZecYdUvZHrXx?\r\n', 'output': ['NO']}]
[{'input': 'iehvZNQXDGCuVmJPOEysLyUryTdfaIxIuTzTadDbqRQGoCLXkxnyfWSGoLXebNnQQNTqAQJebbyYvHOfpUnXeWdjx?\r\n', 'output': ['NO']}, {'input': 'mCDHENXjYbgMdBimAdPnewaHfpGWowjWrVAdvWczjw iDcUbyzMsmsnwbviiKiAyGVA?\r\n', 'output': ['YES']}, {'input': 'GlEmEPKrYcOnBNJUIFjszWUyVdvWw DGDjoCMtRJUburkPToCyDrOtMr?\r\n', 'output': ['NO']}, {'input': 'Is it an apple?\r\n', 'output': ['YES']}, {'input': 'HpBkttwSjBXDmyleGiRWNUMPaAIE uzTrp KJDzaUiCdsMYOoWKHoUhWUoecCPmACymMUUbGav UMRpCytPETwNFAObZJA?\r\n', 'output': ['YES']}]
[{'input': 'wGsfZCSwN PEUhNUrLfABrxA?\r\n', 'output': ['YES']}, {'input': 'fgwg?\r\n', 'output': ['NO']}, {'input': 'n?\r\n', 'output': ['NO']}, {'input': ' T ?\r\n', 'output': ['NO']}, {'input': 'U?\r\n', 'output': ['YES']}]
[{'input': 'BueDOlxgzeNlxrzRrMbKiQdmGujEKmGxclvaPpTuHmTqBp?\r\n', 'output': ['NO']}, {'input': ' j ?\r\n', 'output': ['NO']}, {'input': 'FQXBisXaJFMiHFQlXjixBDMaQuIbyqSBKGsBfTmBKCjszlGVZxEOqYYqRTUkGpSDDAoOXyXcQbHcPaegeOUBNeSD JiKOdECPOF?\r\n', 'output': ['NO']}, {'input': 'wmztmzFfwbGyOmNHENUFMTsFEMWYA?\r\n', 'output': ['YES']}, {'input': ' PslvVpgpN BXkMFBEVXsyZFIQbBEFxGkYTeXKrOdcmhbiTUatYRUoYAayrchqbksswIlfIjerZPqptvCGnMUhyrQSvwltRhFzA?\r\n', 'output': ['YES']}]
100
100
100
100
100
88.89
77.78
66.67
88.89
88.89
83.33
66.67
50
83.33
83.33
308
100
82.224
73.332
["4", "6"]
The first line of the input contains integer n (1 ≀ n ≀ 1000).
62db589bad3b7023418107de05b7a8ee
P = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47] def power(a, b): res = 1 while (b): if (b & 1): res *= a a *= a b >>= 1 return res ans = [] ans.append(1e30) def solve(pos, n, res): if (n == 1): ans[0] = min(ans[0], res) for i in range(2, 62): if (n % i == 0): solve(pos + 1, n / i, res * power(P[pos], i - 1)) n = int(input()) solve(0, n, 1) print(ans[0])
["6", "12"]
Python
null
Output the smallest positive integer with exactly n divisors.
Given the number n, find the smallest positive integer which has exactly n divisors. It is guaranteed that for the given n the answer will not exceed 1018.
[{"input": "1\r\n", "output": ["1"]}, {"input": "7\r\n", "output": ["64"]}, {"input": "8\r\n", "output": ["24"]}, {"input": "9\r\n", "output": ["36"]}, {"input": "10\r\n", "output": ["48"]}, {"input": "15\r\n", "output": ["144"]}, {"input": "20\r\n", "output": ["240"]}, {"input": "47\r\n", "output": ["70368744177664"]}, {"input": "59\r\n", "output": ["288230376151711744"]}, {"input": "100\r\n", "output": ["45360"]}, {"input": "159\r\n", "output": ["40532396646334464"]}, {"input": "265\r\n", "output": ["364791569817010176"]}, {"input": "312\r\n", "output": ["14192640"]}, {"input": "473\r\n", "output": ["259700248434180096"]}, {"input": "637\r\n", "output": ["46656000000"]}, {"input": "500\r\n", "output": ["62370000"]}, {"input": "720\r\n", "output": ["61261200"]}, {"input": "902\r\n", "output": ["324625310542725120"]}, {"input": "940\r\n", "output": ["199495389743677440"]}, {"input": "1000\r\n", "output": ["810810000"]}, {"input": "999\r\n", "output": ["757632231014400"]}, {"input": "118\r\n", "output": ["864691128455135232"]}]
100
100
100
[{'input': '902\r\n', 'output': ['324625310542725120']}, {'input': '20\r\n', 'output': ['240']}, {'input': '7\r\n', 'output': ['64']}, {'input': '118\r\n', 'output': ['864691128455135232']}, {'input': '265\r\n', 'output': ['364791569817010176']}]
[{'input': '159\r\n', 'output': ['40532396646334464']}, {'input': '10\r\n', 'output': ['48']}, {'input': '265\r\n', 'output': ['364791569817010176']}, {'input': '720\r\n', 'output': ['61261200']}, {'input': '902\r\n', 'output': ['324625310542725120']}]
[{'input': '8\r\n', 'output': ['24']}, {'input': '7\r\n', 'output': ['64']}, {'input': '100\r\n', 'output': ['45360']}, {'input': '312\r\n', 'output': ['14192640']}, {'input': '720\r\n', 'output': ['61261200']}]
[{'input': '1000\r\n', 'output': ['810810000']}, {'input': '15\r\n', 'output': ['144']}, {'input': '10\r\n', 'output': ['48']}, {'input': '1\r\n', 'output': ['1']}, {'input': '9\r\n', 'output': ['36']}]
[{'input': '265\r\n', 'output': ['364791569817010176']}, {'input': '637\r\n', 'output': ['46656000000']}, {'input': '15\r\n', 'output': ['144']}, {'input': '10\r\n', 'output': ['48']}, {'input': '47\r\n', 'output': ['70368744177664']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
309
100
100
100
[".......A\n........\n........\n........\n........\n........\n........\nM.......", ".......A\n........\n........\n........\n........\n........\nSS......\nM.......", ".......A\n........\n........\n........\n........\n.S......\nS.......\nMS......"]
You are given the 8 strings whose length equals 8, describing the initial position on the board. The first line represents the top row of the board, the next one β€” for the second from the top, and so on, the last line represents the bottom row. Each character string matches a single cell board in the appropriate row, and the characters are in the same manner as that of the corresponding cell. If the cell is empty, the corresponding character is ".". If a cell has Maria, then it is represented by character "M". If a cell has Anna, it is represented by the character "A". If a cell has a statue, then the cell is represented by character "S". It is guaranteed that the last character of the first row is always "A", the first character of the last line is always "M". The remaining characters are "." or "S".
f47e4ab041288ba9567c19930eb9a090
r, s = [63], ''.join(input() + 'T' for i in range(8)) + 'T' * 9 for i in range(0, 72, 9): t = set() for x in r: for y in (x, x - 1, x + 1, x - 9, x + 9, x - 10, x - 8, x + 10, x + 8): if s[y] == 'T': continue if (y < i or s[y - i] != 'S') and (y < i + 9 or s[y - i - 9] != 'S'): t.add(y) r = t print('WIN' if r else 'LOSE')
["WIN", "LOSE", "LOSE"]
Python
null
If Maria wins, print string "WIN". If the statues win, print string "LOSE".
In this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8 × 8): Anna is in the upper right corner, and Maria is in the lower left one. Apart from them, the board has several statues. Each statue occupies exactly one square. A square that contains a statue cannot have anything or anyone β€” neither any other statues, nor Anna, nor Maria.Anna is present on the board as a figurant (she stands still and never moves), and Maria has been actively involved in the game. Her goal is β€” to come to Anna's square. Maria and statues move in turn, Maria moves first. During one move Maria can go to any adjacent on the side or diagonal cell in which there is no statue, or she can stay in the cell where she is. The statues during their move must go one square down simultaneously, and those statues that were in the bottom row fall from the board and are no longer appeared.At that moment, when one of the statues is in the cell in which the Maria is, the statues are declared winners. At the moment when Maria comes into the cell where Anna has been waiting, Maria is declared the winner.Obviously, nothing depends on the statues, so it all depends on Maria. Determine who will win, if Maria does not make a strategic error.
[{"input": ".......A\r\n........\r\n........\r\n........\r\n........\r\n........\r\n........\r\nM.......\r\n", "output": ["WIN"]}, {"input": ".......A\r\n........\r\n........\r\n........\r\n........\r\n........\r\nSS......\r\nM.......\r\n", "output": ["LOSE"]}, {"input": ".......A\r\n........\r\n........\r\n........\r\n........\r\n.S......\r\nS.......\r\nMS......\r\n", "output": ["LOSE"]}, {"input": ".......A\r\n........\r\n........\r\n........\r\n........\r\n.SSSSSSS\r\nS.......\r\nM.......\r\n", "output": ["WIN"]}, {"input": ".......A\r\n........\r\n........\r\n........\r\nS.......\r\n.SSSSSSS\r\nS.......\r\nM.......\r\n", "output": ["LOSE"]}, {"input": ".SSSSSSA\r\n.SSSSSSS\r\n.SSSSSSS\r\n.SSSSSSS\r\n.SSSSSSS\r\n.SSSSSSS\r\n.SSSSSSS\r\nMSSSSSSS\r\n", "output": ["WIN"]}, {"input": ".......A\r\n..SSSSSS\r\n........\r\n........\r\nSSS.....\r\n........\r\n........\r\nM.......\r\n", "output": ["WIN"]}, {"input": "SSSSSSSA\r\nSSSSSSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nMSSSSSSS\r\n", "output": ["LOSE"]}, {"input": ".......A\r\n........\r\n........\r\n........\r\n.S......\r\nS.......\r\n.S......\r\nM.......\r\n", "output": ["LOSE"]}, {"input": ".......A\r\n........\r\n........\r\n........\r\n........\r\nS.......\r\n.S......\r\nM.......\r\n", "output": ["WIN"]}, {"input": "SSSSSSSA\r\n......SS\r\n.......S\r\n.......S\r\n.......S\r\n.......S\r\n.......S\r\nM......S\r\n", "output": ["LOSE"]}, {"input": ".......A\r\nS.S.S.S.\r\n........\r\n.S.S.S.S\r\n........\r\nS.S.S.S.\r\n........\r\nMS.S.S.S\r\n", "output": ["WIN"]}, {"input": "SSSSSSSA\r\n......S.\r\n......S.\r\n.....SS.\r\n....SS..\r\n...SS...\r\n..SS....\r\nMSS.....\r\n", "output": ["LOSE"]}, {"input": ".S.....A\r\n..SS....\r\n.S......\r\nSS......\r\n..S.....\r\nS.......\r\n.S......\r\nM.......\r\n", "output": ["WIN"]}, {"input": "S..SSSSA\r\n...S.S.S\r\n.SS.SS.S\r\nSS....SS\r\n.S.SSSS.\r\n...S.S.S\r\n..S..S..\r\nMSSSSS.S\r\n", "output": ["WIN"]}, {"input": "SSSSSSSA\r\nSS.SSSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nS..SS.SS\r\nSSSS.SSS\r\nSSSS.SSS\r\nM.SSS.SS\r\n", "output": ["LOSE"]}, {"input": ".......A\r\n....S...\r\n...S....\r\n........\r\nS..S..SS\r\n.S....S.\r\nS....S..\r\nM....S.S\r\n", "output": ["WIN"]}, {"input": "S..SSSSA\r\n.S..S...\r\nS.S....S\r\nSS..S.S.\r\nSSSS.S..\r\n.SS..SS.\r\n....SS..\r\nMS..S...\r\n", "output": ["LOSE"]}, {"input": "...S.SSA\r\n.....S..\r\nSSS....S\r\n...S...S\r\n....SSSS\r\n.S.S...S\r\n..S....S\r\nM..SSSSS\r\n", "output": ["WIN"]}, {"input": "S..SS.SA\r\n.SSS.S.S\r\nSS.SSS.S\r\nSSS.S.S.\r\nSS.SSSSS\r\nSSSSSSSS\r\nSSSS.SS.\r\nM.SSS.S.\r\n", "output": ["LOSE"]}, {"input": "...SSS.A\r\n.....S..\r\n..S.S.SS\r\n.S.S...S\r\nS.S...S.\r\n....S...\r\n........\r\nM..S.SSS\r\n", "output": ["WIN"]}, {"input": ".S.S..SA\r\n.S...S.S\r\nS....S..\r\n...S....\r\n.S.SSSSS\r\nS.....SS\r\n.S.S.SSS\r\nM....S.S\r\n", "output": ["LOSE"]}, {"input": ".......A\r\n....S...\r\n........\r\n........\r\n........\r\n........\r\n.S......\r\nM.......\r\n", "output": ["WIN"]}, {"input": "SSSS.SSA\r\nSSS.SSSS\r\nSSSSSS.S\r\nSS.SSS.S\r\nSS.S.SS.\r\nSSSS.SS.\r\nSSSS.SSS\r\nMSS.SSS.\r\n", "output": ["LOSE"]}, {"input": "SSSS.SSA\r\nSSSSS.SS\r\nSSSS.SSS\r\nSSSSSSSS\r\nSS.SSSSS\r\nSSS.SSSS\r\nSSSSSSSS\r\nMSSS..SS\r\n", "output": ["LOSE"]}, {"input": "S.S.S..A\r\n...SSS.S\r\n.SSSSSS.\r\nSS.S..SS\r\nSSSS.SSS\r\n.S.SSS..\r\nSS.SSSSS\r\nMSSSS.S.\r\n", "output": ["LOSE"]}, {"input": "SSSSSSSA\r\nSS.SSS.S\r\nSSSSSS.S\r\nSSSSSSSS\r\nSSSSSSSS\r\nSSSSSSS.\r\nSSSSSSSS\r\nM.SSSSSS\r\n", "output": ["LOSE"]}, {"input": "...S...A\r\n........\r\n..S..S.S\r\n.S....S.\r\nS.......\r\n..S.S..S\r\n......S.\r\nM..SS..S\r\n", "output": ["WIN"]}, {"input": "SSSSSSSA\r\nSSSSSSSS\r\n.SSSSSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nSSSSS.SS\r\nSSSSSSSS\r\nMSSSSSSS\r\n", "output": ["LOSE"]}, {"input": "SSSSSSSA\r\nSSS.SSSS\r\nSSSSSSSS\r\nSSS.SSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nMSSSS.SS\r\n", "output": ["LOSE"]}, {"input": "S.S..SSA\r\n...S.S..\r\n.SS.SSS.\r\n......S.\r\n.S...S..\r\n..S.S..S\r\n..SS..S.\r\nM.SS..SS\r\n", "output": ["WIN"]}, {"input": "SSSSSSSA\r\nSSSSSSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nMSSSSSSS\r\n", "output": ["LOSE"]}, {"input": ".....S.A\r\n...S.S..\r\n.....S..\r\n........\r\n........\r\n........\r\n......S.\r\nM....S..\r\n", "output": ["WIN"]}, {"input": ".S.S.S.A\r\n.SS.S..S\r\n..S....S\r\n..S.....\r\nSSS.S...\r\n.S....S.\r\nSSSSSS..\r\nM..S....\r\n", "output": ["LOSE"]}, {"input": "SSSSS..A\r\nS.SS.SS.\r\n.S.SSS.S\r\n..SSSSS.\r\n.S..S.S.\r\n.SS.S..S\r\nSSS.S...\r\nM..S..S.\r\n", "output": ["LOSE"]}, {"input": ".......A\r\n........\r\n........\r\n........\r\n..S....S\r\n........\r\n........\r\nM.......\r\n", "output": ["WIN"]}, {"input": ".......A\r\n...S...S\r\n...S....\r\n....S..S\r\n........\r\nS.S...S.\r\nSS......\r\nMS......\r\n", "output": ["LOSE"]}, {"input": "S......A\r\n.SS..S..\r\nS....S..\r\nSSS...S.\r\n.SS.SSS.\r\n.S.SS...\r\n..S..S..\r\nM.SS....\r\n", "output": ["LOSE"]}, {"input": ".SSSS.SA\r\n.SS.SSS.\r\n..S.SS..\r\nSSSS.SS.\r\nS.S.....\r\nS.S.SSSS\r\nS..SS..S\r\nMS.SS.SS\r\n", "output": ["LOSE"]}, {"input": "SSS..SSA\r\nSSSSSSSS\r\n..SS..SS\r\n.S.S.SSS\r\n.SSS.SSS\r\nSSSS.S.S\r\n...SS..S\r\nMS..S.SS\r\n", "output": ["LOSE"]}, {"input": "S..SSS.A\r\nS.S.SSSS\r\nSSSSSSSS\r\n...SS...\r\nS.SSSSSS\r\nSS..SS.S\r\nSS..S.S.\r\nMSS..SSS\r\n", "output": ["LOSE"]}, {"input": "S.SS.SSA\r\n.S..SSS.\r\nSSS.SSS.\r\nSSSS.SSS\r\nS.SSSSSS\r\nSSSSSSSS\r\nSSSSS.SS\r\nMS.SSSSS\r\n", "output": ["LOSE"]}, {"input": "SSS.SSSA\r\nSSS....S\r\nSS...SSS\r\n..SSS..S\r\nS..SS...\r\nSS.SS...\r\n.S..SSSS\r\nM.SSSSSS\r\n", "output": ["LOSE"]}, {"input": "SSS.SSSA\r\nSSSSSSSS\r\nSSSSSSSS\r\nSS.SSS.S\r\nSSSSSSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nMSSSSSSS\r\n", "output": ["LOSE"]}, {"input": "SSSSSSSA\r\n........\r\n........\r\n........\r\n........\r\n........\r\n........\r\nM.......\r\n", "output": ["WIN"]}, {"input": ".......A\r\n........\r\nSSS.....\r\n........\r\n........\r\n.S......\r\n.S......\r\nMS......\r\n", "output": ["WIN"]}]
100
100
100
[{'input': 'SSSSSSSA\r\nSS.SSSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nS..SS.SS\r\nSSSS.SSS\r\nSSSS.SSS\r\nM.SSS.SS\r\n', 'output': ['LOSE']}, {'input': 'SSSSSSSA\r\nSSS.SSSS\r\nSSSSSSSS\r\nSSS.SSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nMSSSS.SS\r\n', 'output': ['LOSE']}, {'input': '.......A\r\n........\r\n........\r\n........\r\n........\r\n.SSSSSSS\r\nS.......\r\nM.......\r\n', 'output': ['WIN']}, {'input': 'SSS..SSA\r\nSSSSSSSS\r\n..SS..SS\r\n.S.S.SSS\r\n.SSS.SSS\r\nSSSS.S.S\r\n...SS..S\r\nMS..S.SS\r\n', 'output': ['LOSE']}, {'input': 'S.SS.SSA\r\n.S..SSS.\r\nSSS.SSS.\r\nSSSS.SSS\r\nS.SSSSSS\r\nSSSSSSSS\r\nSSSSS.SS\r\nMS.SSSSS\r\n', 'output': ['LOSE']}]
[{'input': '.......A\r\n........\r\n........\r\n........\r\nS.......\r\n.SSSSSSS\r\nS.......\r\nM.......\r\n', 'output': ['LOSE']}, {'input': '.S.S.S.A\r\n.SS.S..S\r\n..S....S\r\n..S.....\r\nSSS.S...\r\n.S....S.\r\nSSSSSS..\r\nM..S....\r\n', 'output': ['LOSE']}, {'input': 'SSSSSSSA\r\nSSSSSSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nMSSSSSSS\r\n', 'output': ['LOSE']}, {'input': 'SSSSSSSA\r\n......SS\r\n.......S\r\n.......S\r\n.......S\r\n.......S\r\n.......S\r\nM......S\r\n', 'output': ['LOSE']}, {'input': '.......A\r\n........\r\n........\r\n........\r\n........\r\n........\r\n........\r\nM.......\r\n', 'output': ['WIN']}]
[{'input': '.......A\r\n........\r\n........\r\n........\r\n........\r\n.SSSSSSS\r\nS.......\r\nM.......\r\n', 'output': ['WIN']}, {'input': '...S...A\r\n........\r\n..S..S.S\r\n.S....S.\r\nS.......\r\n..S.S..S\r\n......S.\r\nM..SS..S\r\n', 'output': ['WIN']}, {'input': '.......A\r\nS.S.S.S.\r\n........\r\n.S.S.S.S\r\n........\r\nS.S.S.S.\r\n........\r\nMS.S.S.S\r\n', 'output': ['WIN']}, {'input': 'SSSSSSSA\r\nSSS.SSSS\r\nSSSSSSSS\r\nSSS.SSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nMSSSS.SS\r\n', 'output': ['LOSE']}, {'input': '.SSSSSSA\r\n.SSSSSSS\r\n.SSSSSSS\r\n.SSSSSSS\r\n.SSSSSSS\r\n.SSSSSSS\r\n.SSSSSSS\r\nMSSSSSSS\r\n', 'output': ['WIN']}]
[{'input': '.....S.A\r\n...S.S..\r\n.....S..\r\n........\r\n........\r\n........\r\n......S.\r\nM....S..\r\n', 'output': ['WIN']}, {'input': '.S.S..SA\r\n.S...S.S\r\nS....S..\r\n...S....\r\n.S.SSSSS\r\nS.....SS\r\n.S.S.SSS\r\nM....S.S\r\n', 'output': ['LOSE']}, {'input': '.......A\r\n...S...S\r\n...S....\r\n....S..S\r\n........\r\nS.S...S.\r\nSS......\r\nMS......\r\n', 'output': ['LOSE']}, {'input': 'S.S.S..A\r\n...SSS.S\r\n.SSSSSS.\r\nSS.S..SS\r\nSSSS.SSS\r\n.S.SSS..\r\nSS.SSSSS\r\nMSSSS.S.\r\n', 'output': ['LOSE']}, {'input': 'SSSSSSSA\r\n......S.\r\n......S.\r\n.....SS.\r\n....SS..\r\n...SS...\r\n..SS....\r\nMSS.....\r\n', 'output': ['LOSE']}]
[{'input': '.......A\r\n....S...\r\n........\r\n........\r\n........\r\n........\r\n.S......\r\nM.......\r\n', 'output': ['WIN']}, {'input': '.......A\r\nS.S.S.S.\r\n........\r\n.S.S.S.S\r\n........\r\nS.S.S.S.\r\n........\r\nMS.S.S.S\r\n', 'output': ['WIN']}, {'input': '.S.S.S.A\r\n.SS.S..S\r\n..S....S\r\n..S.....\r\nSSS.S...\r\n.S....S.\r\nSSSSSS..\r\nM..S....\r\n', 'output': ['LOSE']}, {'input': 'SSSSSSSA\r\nSSSSSSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nMSSSSSSS\r\n', 'output': ['LOSE']}, {'input': '.......A\r\n........\r\n........\r\n........\r\n.S......\r\nS.......\r\n.S......\r\nM.......\r\n', 'output': ['LOSE']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
310
100
100
100
["2 2 1 1", "1 2 1 2"]
The only line contains four integers $$$n$$$, $$$m$$$, $$$L$$$ and $$$R$$$ ($$$1\le n,m,L,R \le 10^9$$$, $$$L \le R$$$, $$$n \cdot m \ge 2$$$).
ded299fa1cd010822c60f2389a3ba1a3
n, m, L, R = map(int, input().split()) mod = 998244353 if n*m % 2: print(pow(R-L+1, n*m, mod)) else: print((pow(R-L+1, n*m, mod) + 1 - (R-L) % 2) * pow(2, mod-2, mod) % mod)
["1", "2"]
Python
NoteIn the first sample, the only initial grid that satisfies the requirements is $$$a_{1,1}=a_{2,1}=a_{1,2}=a_{2,2}=1$$$. Thus the answer should be $$$1$$$.In the second sample, initial grids that satisfy the requirements are $$$a_{1,1}=a_{1,2}=1$$$ and $$$a_{1,1}=a_{1,2}=2$$$. Thus the answer should be $$$2$$$.
Output one integer, representing the desired answer modulo $$$998,244,353$$$.
Alice has got addicted to a game called Sirtet recently.In Sirtet, player is given an $$$n \times m$$$ grid. Initially $$$a_{i,j}$$$ cubes are stacked up in the cell $$$(i,j)$$$. Two cells are called adjacent if they share a side. Player can perform the following operations: stack up one cube in two adjacent cells; stack up two cubes in one cell. Cubes mentioned above are identical in height.Here is an illustration of the game. States on the right are obtained by performing one of the above operations on the state on the left, and grey cubes are added due to the operation. Player's goal is to make the height of all cells the same (i.e. so that each cell has the same number of cubes in it) using above operations. Alice, however, has found out that on some starting grids she may never reach the goal no matter what strategy she uses. Thus, she is wondering the number of initial grids such that $$$L \le a_{i,j} \le R$$$ for all $$$1 \le i \le n$$$, $$$1 \le j \le m$$$; player can reach the goal using above operations. Please help Alice with it. Notice that the answer might be large, please output the desired value modulo $$$998,244,353$$$.
[{"input": "2 2 1 1\r\n", "output": ["1"]}, {"input": "1 2 1 2\r\n", "output": ["2"]}, {"input": "485 117 386829368 748204956\r\n", "output": ["735420370"]}, {"input": "564 558 305171115 960941497\r\n", "output": ["880111542"]}, {"input": "692 210 44175861 843331069\r\n", "output": ["714028205"]}, {"input": "741 806 424647372 965259389\r\n", "output": ["861647194"]}, {"input": "461 650 18427925 104278996\r\n", "output": ["936348652"]}, {"input": "589 790 462465375 766499149\r\n", "output": ["374887989"]}, {"input": "13 635 761278633 941090619\r\n", "output": ["893955177"]}, {"input": "140 713 711390561 727285861\r\n", "output": ["641355762"]}, {"input": "494587372 852064625 134519483 167992226\r\n", "output": ["552905694"]}, {"input": "672670796 425613469 728300037 940234946\r\n", "output": ["779704132"]}, {"input": "850754220 853938121 172337487 490664825\r\n", "output": ["237240423"]}, {"input": "28837644 722454262 471150744 905552093\r\n", "output": ["740846915"]}, {"input": "911953772 296003106 210155490 889555498\r\n", "output": ["225799480"]}, {"input": "795069900 869551950 803936044 964554424\r\n", "output": ["884379548"]}, {"input": "268120620 443100795 102749301 604856694\r\n", "output": ["834319192"]}, {"input": "151236748 16649639 841754047 855153000\r\n", "output": ["108988868"]}, {"input": "329320172 739941588 435534601 986184053\r\n", "output": ["425887732"]}, {"input": "1000000000 1 1000000000 1000000000\r\n", "output": ["1"]}, {"input": "1 1000000000 1 1000000000\r\n", "output": ["285141888"]}, {"input": "407070359 971940670 264302148 270591105\r\n", "output": ["992759231"]}, {"input": "290186487 840456810 858082702 987072033\r\n", "output": ["366829057"]}, {"input": "763237207 414005655 302120151 421405724\r\n", "output": ["193545831"]}, {"input": "646353335 282521795 600933409 772270276\r\n", "output": ["13680108"]}, {"input": "824436759 415879151 194713963 293553316\r\n", "output": ["453443939"]}, {"input": "707552887 989427996 933718708 955125306\r\n", "output": ["355610620"]}, {"input": "885636311 857944136 232531966 493119835\r\n", "output": ["779245677"]}, {"input": "63719735 431492981 971536712 994663491\r\n", "output": ["97582142"]}, {"input": "946835863 300009121 565317265 947272048\r\n", "output": ["337235143"]}, {"input": "124919287 578590669 9354715 32571540\r\n", "output": ["263200129"]}, {"input": "202669473 255300152 987865366 994537507\r\n", "output": ["926661352"]}, {"input": "2 2 1 998244353\r\n", "output": ["499122177"]}, {"input": "2 3 1 998244353\r\n", "output": ["499122177"]}, {"input": "3 3 1 998244353\r\n", "output": ["0"]}, {"input": "1000000000 1000000000 1 998244353\r\n", "output": ["499122177"]}, {"input": "999999999 999999999 1 998244353\r\n", "output": ["0"]}, {"input": "999999999 1000000000 1755648 1000000000\r\n", "output": ["499122177"]}, {"input": "1 2 1 86583718\r\n", "output": ["499122176"]}, {"input": "1 2 1 911660635\r\n", "output": ["0"]}, {"input": "2 2 2 4\r\n", "output": ["41"]}, {"input": "2 2 2 5\r\n", "output": ["128"]}, {"input": "2 2 3 4\r\n", "output": ["8"]}, {"input": "2 2 3 5\r\n", "output": ["41"]}, {"input": "2 3 2 4\r\n", "output": ["365"]}, {"input": "2 3 2 5\r\n", "output": ["2048"]}, {"input": "2 3 3 4\r\n", "output": ["32"]}, {"input": "2 3 3 5\r\n", "output": ["365"]}, {"input": "3 2 2 4\r\n", "output": ["365"]}, {"input": "3 2 2 5\r\n", "output": ["2048"]}, {"input": "3 2 3 4\r\n", "output": ["32"]}, {"input": "3 2 3 5\r\n", "output": ["365"]}, {"input": "3 3 2 4\r\n", "output": ["19683"]}, {"input": "3 3 2 5\r\n", "output": ["262144"]}, {"input": "3 3 3 4\r\n", "output": ["512"]}, {"input": "3 3 3 5\r\n", "output": ["19683"]}, {"input": "998244352 2 1 998244353\r\n", "output": ["499122177"]}, {"input": "3 3 1 1\r\n", "output": ["1"]}]
100
100
100
[{'input': '3 2 2 5\r\n', 'output': ['2048']}, {'input': '646353335 282521795 600933409 772270276\r\n', 'output': ['13680108']}, {'input': '461 650 18427925 104278996\r\n', 'output': ['936348652']}, {'input': '999999999 999999999 1 998244353\r\n', 'output': ['0']}, {'input': '2 3 3 4\r\n', 'output': ['32']}]
[{'input': '268120620 443100795 102749301 604856694\r\n', 'output': ['834319192']}, {'input': '2 3 3 5\r\n', 'output': ['365']}, {'input': '795069900 869551950 803936044 964554424\r\n', 'output': ['884379548']}, {'input': '202669473 255300152 987865366 994537507\r\n', 'output': ['926661352']}, {'input': '124919287 578590669 9354715 32571540\r\n', 'output': ['263200129']}]
[{'input': '824436759 415879151 194713963 293553316\r\n', 'output': ['453443939']}, {'input': '2 3 2 4\r\n', 'output': ['365']}, {'input': '63719735 431492981 971536712 994663491\r\n', 'output': ['97582142']}, {'input': '741 806 424647372 965259389\r\n', 'output': ['861647194']}, {'input': '1 1000000000 1 1000000000\r\n', 'output': ['285141888']}]
[{'input': '564 558 305171115 960941497\r\n', 'output': ['880111542']}, {'input': '999999999 999999999 1 998244353\r\n', 'output': ['0']}, {'input': '3 3 3 4\r\n', 'output': ['512']}, {'input': '1 2 1 2\r\n', 'output': ['2']}, {'input': '2 2 1 998244353\r\n', 'output': ['499122177']}]
[{'input': '3 2 3 4\r\n', 'output': ['32']}, {'input': '3 2 2 4\r\n', 'output': ['365']}, {'input': '63719735 431492981 971536712 994663491\r\n', 'output': ['97582142']}, {'input': '3 3 3 4\r\n', 'output': ['512']}, {'input': '2 3 1 998244353\r\n', 'output': ['499122177']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
311
100
100
100
["0 1 1 0 0 0 0 0 0 7 0 0 0 0", "5 1 1 1 1 0 0 0 0 0 0 0 0 0"]
The only line contains 14 integers $$$a_1, a_2, \ldots, a_{14}$$$ ($$$0 \leq a_i \leq 10^9$$$)Β β€” the number of stones in each hole. It is guaranteed that for any $$$i$$$ ($$$1\leq i \leq 14$$$) $$$a_i$$$ is either zero or odd, and there is at least one stone in the board.
1ac11153e35509e755ea15f1d57d156b
A=list(map(int,input().split())) score=0 for i in range(14): score=max(score,sum([j for j in [(A[j] if i!=j else 0)+A[i]//14+(1 if (j+13-i)%14<A[i]%14 else 0) for j in range(14)] if j%2==0])) print(score)
["4", "8"]
Python
NoteIn the first test case the board after the move from the hole with $$$7$$$ stones will look like 1 2 2 0 0 0 0 0 0 0 1 1 1 1. Then the player collects the even numbers and ends up with a score equal to $$$4$$$.
Output one integer, the maximum possible score after one move.
Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes. Initially, each hole has $$$a_i$$$ stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in the next holes in a counter-clockwise direction.Note that the counter-clockwise order means if the player takes the stones from hole $$$i$$$, he will put one stone in the $$$(i+1)$$$-th hole, then in the $$$(i+2)$$$-th, etc. If he puts a stone in the $$$14$$$-th hole, the next one will be put in the first hole.After the move, the player collects all the stones from holes that contain even number of stones. The number of stones collected by player is the score, according to Resli.Resli is a famous Mancala player. He wants to know the maximum score he can obtain after one move.
[{"input": "0 1 1 0 0 0 0 0 0 7 0 0 0 0\r\n", "output": ["4"]}, {"input": "5 1 1 1 1 0 0 0 0 0 0 0 0 0\r\n", "output": ["8"]}, {"input": "10001 10001 10001 10001 10001 10001 10001 10001 10001 10001 10001 10001 10001 1\r\n", "output": ["54294"]}, {"input": "0 0 0 0 0 0 0 0 0 0 0 0 0 15\r\n", "output": ["2"]}, {"input": "1 0 0 0 0 1 0 0 0 0 1 0 0 0\r\n", "output": ["0"]}, {"input": "5 5 1 1 1 3 3 3 5 7 5 3 7 5\r\n", "output": ["38"]}, {"input": "787 393 649 463 803 365 81 961 989 531 303 407 579 915\r\n", "output": ["7588"]}, {"input": "8789651 4466447 1218733 6728667 1796977 6198853 8263135 6309291 8242907 7136751 3071237 5397369 6780785 9420869\r\n", "output": ["81063456"]}, {"input": "0 0 0 0 0 0 0 0 0 0 0 0 0 29\r\n", "output": ["26"]}, {"input": "282019717 109496191 150951267 609856495 953855615 569750143 6317733 255875779 645191029 572053369 290936613 338480779 879775193 177172893\r\n", "output": ["5841732816"]}, {"input": "105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505\r\n", "output": ["120472578"]}, {"input": "404418821 993626161 346204297 122439813 461187221 628048227 625919459 628611733 938993057 701270099 398043779 684205961 630975553 575964835\r\n", "output": ["8139909016"]}, {"input": "170651077 730658441 824213789 583764177 129437345 717005779 675398017 314979709 380861369 265878463 746564659 797260041 506575735 335169317\r\n", "output": ["6770880638"]}, {"input": "622585025 48249287 678950449 891575125 637411965 457739735 829353393 235216425 284006447 875591469 492839209 296444305 513776057 810057753\r\n", "output": ["7673796644"]}, {"input": "475989857 930834747 786217439 927967137 489188151 869354161 276693267 56154399 131055697 509249443 143116853 426254423 44465165 105798821\r\n", "output": ["6172339560"]}, {"input": "360122921 409370351 226220005 604004145 85173909 600403773 624052991 138163383 729239967 189036661 619842883 270087537 749500483 243727913\r\n", "output": ["5848946922"]}, {"input": "997102881 755715147 273805839 436713689 547411799 72470207 522269145 647688957 137422311 422612659 197751751 679663349 821420227 387967237\r\n", "output": ["6900015198"]}, {"input": "690518849 754551537 652949719 760695679 491633619 477564457 11669279 700467439 470069297 782338983 718169393 884421719 24619427 215745577\r\n", "output": ["7635414974"]}, {"input": "248332749 486342237 662201929 917696895 555278549 252122023 850296207 463343655 832574345 954281071 168282553 825538865 996753493 461254663\r\n", "output": ["6400166934"]}, {"input": "590789361 636464947 404477303 337309187 476703809 426863069 120608741 703406277 645444697 761482231 996635839 33459441 677458865 483861751\r\n", "output": ["7294965518"]}, {"input": "297857621 238127103 749085829 139033277 597985489 202617713 982184715 183932743 278551059 297781685 330124279 338959601 682874531 187519685\r\n", "output": ["5201808164"]}, {"input": "1 1 1 1 1 0 0 0 0 0 0 0 0 0\r\n", "output": ["2"]}, {"input": "1 1 0 0 0 0 0 0 0 0 0 0 0 0\r\n", "output": ["2"]}, {"input": "1 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n", "output": ["2"]}, {"input": "1 0 0 0 0 0 0 0 0 0 0 0 0 1\r\n", "output": ["2"]}, {"input": "0 0 0 0 0 0 0 0 0 0 0 0 1 1\r\n", "output": ["2"]}]
100
100
100
[{'input': '475989857 930834747 786217439 927967137 489188151 869354161 276693267 56154399 131055697 509249443 143116853 426254423 44465165 105798821\r\n', 'output': ['6172339560']}, {'input': '360122921 409370351 226220005 604004145 85173909 600403773 624052991 138163383 729239967 189036661 619842883 270087537 749500483 243727913\r\n', 'output': ['5848946922']}, {'input': '0 0 0 0 0 0 0 0 0 0 0 0 0 29\r\n', 'output': ['26']}, {'input': '248332749 486342237 662201929 917696895 555278549 252122023 850296207 463343655 832574345 954281071 168282553 825538865 996753493 461254663\r\n', 'output': ['6400166934']}, {'input': '997102881 755715147 273805839 436713689 547411799 72470207 522269145 647688957 137422311 422612659 197751751 679663349 821420227 387967237\r\n', 'output': ['6900015198']}]
[{'input': '1 0 0 0 0 1 0 0 0 0 1 0 0 0\r\n', 'output': ['0']}, {'input': '590789361 636464947 404477303 337309187 476703809 426863069 120608741 703406277 645444697 761482231 996635839 33459441 677458865 483861751\r\n', 'output': ['7294965518']}, {'input': '170651077 730658441 824213789 583764177 129437345 717005779 675398017 314979709 380861369 265878463 746564659 797260041 506575735 335169317\r\n', 'output': ['6770880638']}, {'input': '0 0 0 0 0 0 0 0 0 0 0 0 0 15\r\n', 'output': ['2']}, {'input': '0 1 1 0 0 0 0 0 0 7 0 0 0 0\r\n', 'output': ['4']}]
[{'input': '1 1 0 0 0 0 0 0 0 0 0 0 0 0\r\n', 'output': ['2']}, {'input': '0 1 1 0 0 0 0 0 0 7 0 0 0 0\r\n', 'output': ['4']}, {'input': '105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505\r\n', 'output': ['120472578']}, {'input': '622585025 48249287 678950449 891575125 637411965 457739735 829353393 235216425 284006447 875591469 492839209 296444305 513776057 810057753\r\n', 'output': ['7673796644']}, {'input': '690518849 754551537 652949719 760695679 491633619 477564457 11669279 700467439 470069297 782338983 718169393 884421719 24619427 215745577\r\n', 'output': ['7635414974']}]
[{'input': '787 393 649 463 803 365 81 961 989 531 303 407 579 915\r\n', 'output': ['7588']}, {'input': '590789361 636464947 404477303 337309187 476703809 426863069 120608741 703406277 645444697 761482231 996635839 33459441 677458865 483861751\r\n', 'output': ['7294965518']}, {'input': '105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505\r\n', 'output': ['120472578']}, {'input': '8789651 4466447 1218733 6728667 1796977 6198853 8263135 6309291 8242907 7136751 3071237 5397369 6780785 9420869\r\n', 'output': ['81063456']}, {'input': '5 5 1 1 1 3 3 3 5 7 5 3 7 5\r\n', 'output': ['38']}]
[{'input': '1 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n', 'output': ['2']}, {'input': '0 0 0 0 0 0 0 0 0 0 0 0 1 1\r\n', 'output': ['2']}, {'input': '787 393 649 463 803 365 81 961 989 531 303 407 579 915\r\n', 'output': ['7588']}, {'input': '0 1 1 0 0 0 0 0 0 7 0 0 0 0\r\n', 'output': ['4']}, {'input': '5 1 1 1 1 0 0 0 0 0 0 0 0 0\r\n', 'output': ['8']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
312
100
100
100
["abcd", "ababa", "zzz"]
The first input line contains the string. It's guaranteed, that the string is non-empty, consists of lower-case Latin letters, and its length doesn't exceed 100.
13b5cf94f2fabd053375a5ccf3fd44c7
S = input() ans = 0 met = set() for i in range(len(S)): for j in range(i, -1, -1): if S[j:i+1] in met: ans = max(ans, i - j + 1) else: met.add(S[j:i+1]) print(ans)
["0", "3", "2"]
Python
null
Output one number β€” length of the longest substring that can be met in the string at least twice.
You're given a string of lower-case Latin letters. Your task is to find the length of its longest substring that can be met in the string at least twice. These occurrences can overlap (see sample test 2).
[{"input": "abcd\r\n", "output": ["0"]}, {"input": "ababa\r\n", "output": ["3"]}, {"input": "zzz\r\n", "output": ["2"]}, {"input": "kmmm\r\n", "output": ["2"]}, {"input": "wzznz\r\n", "output": ["1"]}, {"input": "qlzazaaqll\r\n", "output": ["2"]}, {"input": "lzggglgpep\r\n", "output": ["2"]}, {"input": "iegdlraaidefgegiagrdfhihe\r\n", "output": ["2"]}, {"input": "esxpqmdrtidgtkxojuxyrcwxlycywtzbjzpxvbngnlepgzcaeg\r\n", "output": ["1"]}, {"input": "garvpaimjdjiivamusjdwfcaoswuhxyyxvrxzajoyihggvuxumaadycfphrzbprraicvjjlsdhojihaw\r\n", "output": ["2"]}, {"input": "ckvfndqgkmhcyojaqgdkenmbexufryhqejdhctxujmtrwkpbqxufxamgoeigzfyzbhevpbkvviwntdhqscvkmphnkkljizndnbjt\r\n", "output": ["3"]}, {"input": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\r\n", "output": ["99"]}, {"input": "ikiikiikikiiikkkkkikkkkiiiiikkiiikkiikiikkkkikkkikikkikiiikkikikiiikikkkiiikkkikkikkikkkkiiikkiiiiii\r\n", "output": ["10"]}, {"input": "ovovhoovvhohhhvhhvhhvhovoohovhhoooooovohvooooohvvoooohvvovhhvhovhhvoovhvhvoovovvhooovhhooovohvhhovhv\r\n", "output": ["8"]}, {"input": "ccwckkkycccccckwckwkwkwkkkkyycykcccycyckwywcckwykcycykkkwcycwwcykcwkwkwwykwkwcykywwwyyykckkyycckwcwk\r\n", "output": ["5"]}, {"input": "ttketfkefktfztezzkzfkkeetkkfktftzktezekkeezkeeetteeteefetefkzzzetekfftkeffzkktffzkzzeftfeezfefzffeef\r\n", "output": ["4"]}, {"input": "rtharczpfznrgdnkltchafduydgbgkdjqrmjqyfmpwjwphrtsjbmswkanjlprbnduaqbcjqxlxmkspkhkcnzbqwxonzxxdmoigti\r\n", "output": ["2"]}, {"input": "fplrkfklvwdeiynbjgaypekambmbjfnoknlhczhkdmljicookdywdgpnlnqlpunnkebnikgcgcjefeqhknvlynmvjcegvcdgvvdb\r\n", "output": ["2"]}, {"input": "txbciieycswqpniwvzipwlottivvnfsysgzvzxwbctcchfpvlbcjikdofhpvsknptpjdbxemtmjcimetkemdbettqnbvzzbdyxxb\r\n", "output": ["2"]}, {"input": "fmubmfwefikoxtqvmaavwjxmoqltapexkqxcsztpezfcltqavuicefxovuswmqimuikoppgqpiapqutkczgcvxzutavkujxvpklv\r\n", "output": ["3"]}, {"input": "ipsrjylhpkjvlzncfixipstwcicxqygqcfrawpzzvckoveyqhathglblhpkjvlzncfixipfajaqobtzvthmhgbuawoxoknirclxg\r\n", "output": ["15"]}, {"input": "kcnjsntjzcbgzjscrsrjkrbytqsrptzspzctjrorsyggrtkcnjsntjzcbgzjscrsrjyqbrtpcgqirsrrjbbbrnyqstnrozcoztt\r\n", "output": ["20"]}, {"input": "unhcfnrhsqetuerjqcetrhlsqgfnqfntvkgxsscquolxxroqgtchffyccetrhlsqgfnqfntvkgxsscquolxxroqgtchffhfqvx\r\n", "output": ["37"]}, {"input": "kkcckkccckkcckcccckcckkkkcckkkkckkkcckckkkkkckkkkkcckkccckkcckcccckcckkkkcckkkkckkkcckckkkkkckckckkc\r\n", "output": ["46"]}, {"input": "mlhsyijxeydqxhtkmpdeqwzogjvxahmssyhfhqessbxzvydbrxdmlhsyijxeydqxhtkmpdeqwzogjvxahmssyhfhqessbxzvydik\r\n", "output": ["47"]}, {"input": "abcdefghijklmnopqrstuvwxyz\r\n", "output": ["0"]}, {"input": "tttttbttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttmttttttt\r\n", "output": ["85"]}, {"input": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffffffffffffffffffffffffffffffffffff\r\n", "output": ["61"]}, {"input": "cccccccccccccccccccccccwcccccccccccccccccccccuccccccccccccccnccccccccccccccccccccccccccccccccccccccc\r\n", "output": ["38"]}, {"input": "ffffffffffffffffffffffffffufffgfffffffffffffffffffffffffffffffffffffffgffffffftffffffgffffffffffffff\r\n", "output": ["38"]}, {"input": "rrrrrrrrrrrrrrrrrrrlhbrrrrrrrrurrrrrrrfrrqrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrewrrrrrrryrrxrrrrrrrrrrr\r\n", "output": ["33"]}, {"input": "vyvvvvvvvvzvvvvvzvvvwvvvvrvvvvvvvvvvvvvvvrvvvvvvvvvpkvvpvgvvvvvvvvvvvvvgvvvvvvvvvvvvvvvvvvysvvvbvvvv\r\n", "output": ["17"]}, {"input": "cbubbbbbbbbbbfbbbbbbbbjbobbbbbbbbbbibbubbbbjbbbnzgbbzbbfbbbbbbbbbbbfbpbbbbbbbbbbygbbbgbabbbbbbbhibbb\r\n", "output": ["12"]}, {"input": "lrqrrrrrrrjrrrrrcdrrgrrmwvrrrrrrrrrxfzrmrmrryrrrurrrdrrrrrrrrrrererrrsrrrrrrrrrrrqrrrrcrrwjsrrlrrrrr\r\n", "output": ["10"]}, {"input": "ssssusisisosscssssztzessssyspskjssvosiissussszsosssslsssdsssvssvsssslsssmsfjasjsssssowscsjsssszsspss\r\n", "output": ["8"]}, {"input": "uukuuuumueuuuujuukgdhbztuuuubbguuocuozfaunqufjujuguyuuvkuuauubuubuucuvtjuuuuuusduduuuuuuuueunuuuuuzu\r\n", "output": ["7"]}, {"input": "jpkkgwklngwqcfzmwkkpcwkkkkkekkkekkkdsykqwjkkkhkkkxdnukkkkkkmkqykkkxqklkskkrkkkkkqqjikkkkkkpknkkkkkoh\r\n", "output": ["7"]}, {"input": "bmzbbfbbhqxwthtbbisbbbbbtbbfbbpbfbbpbkbjfbcbbbbzbbbdwmbbbrnvqdbbtbbuglrnbbbbvmbyblebbabibrevaxbbjbqb\r\n", "output": ["6"]}, {"input": "qqqmqqqsbteqqopsuqiqumrqzpqnqgqeniqqkyqqyqqqpxzqeqqquhdqquhqqqfqjirqaqqaquxqoqqjqqqqbjbgqcqqqqicnkqc\r\n", "output": ["4"]}, {"input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasaaaavaaaaaaauaaeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n", "output": ["44"]}, {"input": "a\r\n", "output": ["0"]}, {"input": "fg\r\n", "output": ["0"]}, {"input": "yy\r\n", "output": ["1"]}, {"input": "abcabcabc\r\n", "output": ["6"]}, {"input": "qwerqwedqwes\r\n", "output": ["3"]}]
100
100
100
[{'input': 'abcd\r\n', 'output': ['0']}, {'input': 'rrrrrrrrrrrrrrrrrrrlhbrrrrrrrrurrrrrrrfrrqrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrewrrrrrrryrrxrrrrrrrrrrr\r\n', 'output': ['33']}, {'input': 'ababa\r\n', 'output': ['3']}, {'input': 'ikiikiikikiiikkkkkikkkkiiiiikkiiikkiikiikkkkikkkikikkikiiikkikikiiikikkkiiikkkikkikkikkkkiiikkiiiiii\r\n', 'output': ['10']}, {'input': 'lzggglgpep\r\n', 'output': ['2']}]
[{'input': 'qlzazaaqll\r\n', 'output': ['2']}, {'input': 'kmmm\r\n', 'output': ['2']}, {'input': 'qqqmqqqsbteqqopsuqiqumrqzpqnqgqeniqqkyqqyqqqpxzqeqqquhdqquhqqqfqjirqaqqaquxqoqqjqqqqbjbgqcqqqqicnkqc\r\n', 'output': ['4']}, {'input': 'a\r\n', 'output': ['0']}, {'input': 'ipsrjylhpkjvlzncfixipstwcicxqygqcfrawpzzvckoveyqhathglblhpkjvlzncfixipfajaqobtzvthmhgbuawoxoknirclxg\r\n', 'output': ['15']}]
[{'input': 'lrqrrrrrrrjrrrrrcdrrgrrmwvrrrrrrrrrxfzrmrmrryrrrurrrdrrrrrrrrrrererrrsrrrrrrrrrrrqrrrrcrrwjsrrlrrrrr\r\n', 'output': ['10']}, {'input': 'kkcckkccckkcckcccckcckkkkcckkkkckkkcckckkkkkckkkkkcckkccckkcckcccckcckkkkcckkkkckkkcckckkkkkckckckkc\r\n', 'output': ['46']}, {'input': 'jpkkgwklngwqcfzmwkkpcwkkkkkekkkekkkdsykqwjkkkhkkkxdnukkkkkkmkqykkkxqklkskkrkkkkkqqjikkkkkkpknkkkkkoh\r\n', 'output': ['7']}, {'input': 'bmzbbfbbhqxwthtbbisbbbbbtbbfbbpbfbbpbkbjfbcbbbbzbbbdwmbbbrnvqdbbtbbuglrnbbbbvmbyblebbabibrevaxbbjbqb\r\n', 'output': ['6']}, {'input': 'zzz\r\n', 'output': ['2']}]
[{'input': 'ipsrjylhpkjvlzncfixipstwcicxqygqcfrawpzzvckoveyqhathglblhpkjvlzncfixipfajaqobtzvthmhgbuawoxoknirclxg\r\n', 'output': ['15']}, {'input': 'tttttbttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttmttttttt\r\n', 'output': ['85']}, {'input': 'wzznz\r\n', 'output': ['1']}, {'input': 'bmzbbfbbhqxwthtbbisbbbbbtbbfbbpbfbbpbkbjfbcbbbbzbbbdwmbbbrnvqdbbtbbuglrnbbbbvmbyblebbabibrevaxbbjbqb\r\n', 'output': ['6']}, {'input': 'cbubbbbbbbbbbfbbbbbbbbjbobbbbbbbbbbibbubbbbjbbbnzgbbzbbfbbbbbbbbbbbfbpbbbbbbbbbbygbbbgbabbbbbbbhibbb\r\n', 'output': ['12']}]
[{'input': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasaaaavaaaaaaauaaeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n', 'output': ['44']}, {'input': 'cbubbbbbbbbbbfbbbbbbbbjbobbbbbbbbbbibbubbbbjbbbnzgbbzbbfbbbbbbbbbbbfbpbbbbbbbbbbygbbbgbabbbbbbbhibbb\r\n', 'output': ['12']}, {'input': 'qqqmqqqsbteqqopsuqiqumrqzpqnqgqeniqqkyqqyqqqpxzqeqqquhdqquhqqqfqjirqaqqaquxqoqqjqqqqbjbgqcqqqqicnkqc\r\n', 'output': ['4']}, {'input': 'kmmm\r\n', 'output': ['2']}, {'input': 'kkcckkccckkcckcccckcckkkkcckkkkckkkcckckkkkkckkkkkcckkccckkcckcccckcckkkkcckkkkckkkcckckkkkkckckckkc\r\n', 'output': ['46']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
313
100
100
100
["10 5", "-10 5"]
The first line contains two integers x, y ( - 109 ≀ x, y ≀ 109, x ≠ 0, y ≠ 0).
e2f15a9d9593eec2e19be3140a847712
x,y = map(int,input().split()) if x > 0 and y > 0: print(0, x + y, x + y, 0) elif x < 0 and y > 0: print(-y + x, 0, 0,-x + y) elif x > 0 and y < 0: print(0, y - x, x - y, 0) else: print(x + y, 0,0, x + y)
["0 15 15 0", "-15 0 0 15"]
Python
NoteFigure to the first sample
Print in the single line four integers x1, y1, x2, y2 β€” the coordinates of the required points.
Vasily the bear has a favorite rectangle, it has one vertex at point (0, 0), and the opposite vertex at point (x, y). Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate axes. Vasya also loves triangles, if the triangles have one vertex at point B = (0, 0). That's why today he asks you to find two points A = (x1, y1) and C = (x2, y2), such that the following conditions hold: the coordinates of points: x1, x2, y1, y2 are integers. Besides, the following inequation holds: x1 &lt; x2; the triangle formed by point A, B and C is rectangular and isosceles ( is right); all points of the favorite rectangle are located inside or on the border of triangle ABC; the area of triangle ABC is as small as possible. Help the bear, find the required points. It is not so hard to proof that these points are unique.
[{"input": "10 5\r\n", "output": ["0 15 15 0"]}, {"input": "-10 5\r\n", "output": ["-15 0 0 15"]}, {"input": "20 -10\r\n", "output": ["0 -30 30 0"]}, {"input": "-10 -1000000000\r\n", "output": ["-1000000010 0 0 -1000000010"]}, {"input": "-1000000000 -1000000000\r\n", "output": ["-2000000000 0 0 -2000000000"]}, {"input": "1000000000 1000000000\r\n", "output": ["0 2000000000 2000000000 0"]}, {"input": "-123131 3123141\r\n", "output": ["-3246272 0 0 3246272"]}, {"input": "-23423 -243242423\r\n", "output": ["-243265846 0 0 -243265846"]}, {"input": "123112 4560954\r\n", "output": ["0 4684066 4684066 0"]}, {"input": "1321 -23131\r\n", "output": ["0 -24452 24452 0"]}, {"input": "1000000000 999999999\r\n", "output": ["0 1999999999 1999999999 0"]}, {"input": "54543 432423\r\n", "output": ["0 486966 486966 0"]}, {"input": "1 1\r\n", "output": ["0 2 2 0"]}, {"input": "-1 -1\r\n", "output": ["-2 0 0 -2"]}, {"input": "-1 1\r\n", "output": ["-2 0 0 2"]}, {"input": "1 -1\r\n", "output": ["0 -2 2 0"]}, {"input": "42 -2\r\n", "output": ["0 -44 44 0"]}, {"input": "2 -435\r\n", "output": ["0 -437 437 0"]}, {"input": "76 -76\r\n", "output": ["0 -152 152 0"]}, {"input": "1000000000 1\r\n", "output": ["0 1000000001 1000000001 0"]}, {"input": "1000000000 -1\r\n", "output": ["0 -1000000001 1000000001 0"]}, {"input": "-1000000000 1\r\n", "output": ["-1000000001 0 0 1000000001"]}, {"input": "-1000000000 -1\r\n", "output": ["-1000000001 0 0 -1000000001"]}, {"input": "1000000000 -999999999\r\n", "output": ["0 -1999999999 1999999999 0"]}, {"input": "-1000000000 999999999\r\n", "output": ["-1999999999 0 0 1999999999"]}, {"input": "-1000000000 -999999999\r\n", "output": ["-1999999999 0 0 -1999999999"]}, {"input": "999999999 1000000000\r\n", "output": ["0 1999999999 1999999999 0"]}, {"input": "-999999999 1000000000\r\n", "output": ["-1999999999 0 0 1999999999"]}, {"input": "999999999 -1000000000\r\n", "output": ["0 -1999999999 1999999999 0"]}, {"input": "-999999999 -1000000000\r\n", "output": ["-1999999999 0 0 -1999999999"]}]
100
100
100
[{'input': '1000000000 1\r\n', 'output': ['0 1000000001 1000000001 0']}, {'input': '-10 5\r\n', 'output': ['-15 0 0 15']}, {'input': '1000000000 -1\r\n', 'output': ['0 -1000000001 1000000001 0']}, {'input': '42 -2\r\n', 'output': ['0 -44 44 0']}, {'input': '1 -1\r\n', 'output': ['0 -2 2 0']}]
[{'input': '-10 -1000000000\r\n', 'output': ['-1000000010 0 0 -1000000010']}, {'input': '-10 5\r\n', 'output': ['-15 0 0 15']}, {'input': '-999999999 1000000000\r\n', 'output': ['-1999999999 0 0 1999999999']}, {'input': '-1000000000 -999999999\r\n', 'output': ['-1999999999 0 0 -1999999999']}, {'input': '10 5\r\n', 'output': ['0 15 15 0']}]
[{'input': '-1000000000 -1\r\n', 'output': ['-1000000001 0 0 -1000000001']}, {'input': '-1 1\r\n', 'output': ['-2 0 0 2']}, {'input': '-10 -1000000000\r\n', 'output': ['-1000000010 0 0 -1000000010']}, {'input': '999999999 1000000000\r\n', 'output': ['0 1999999999 1999999999 0']}, {'input': '-1000000000 999999999\r\n', 'output': ['-1999999999 0 0 1999999999']}]
[{'input': '2 -435\r\n', 'output': ['0 -437 437 0']}, {'input': '1000000000 1\r\n', 'output': ['0 1000000001 1000000001 0']}, {'input': '54543 432423\r\n', 'output': ['0 486966 486966 0']}, {'input': '20 -10\r\n', 'output': ['0 -30 30 0']}, {'input': '-1 1\r\n', 'output': ['-2 0 0 2']}]
[{'input': '76 -76\r\n', 'output': ['0 -152 152 0']}, {'input': '20 -10\r\n', 'output': ['0 -30 30 0']}, {'input': '-123131 3123141\r\n', 'output': ['-3246272 0 0 3246272']}, {'input': '1000000000 999999999\r\n', 'output': ['0 1999999999 1999999999 0']}, {'input': '1321 -23131\r\n', 'output': ['0 -24452 24452 0']}]
100
100
100
100
100
87.5
87.5
87.5
87.5
87.5
83.33
83.33
83.33
83.33
83.33
314
100
87.5
83.33
["4 4 0\n2 1 2", "5 6 1\n2 7 2", "3 3 3\n2 2 2"]
The first line of the input contains three integers a, b and c (0 ≀ a, b, c ≀ 1 000 000)Β β€” the number of blue, violet and orange spheres that are in the magician's disposal. The second line of the input contains three integers, x, y and z (0 ≀ x, y, z ≀ 1 000 000)Β β€” the number of blue, violet and orange spheres that he needs to get.
1db4ba9dc1000e26532bb73336cf12c3
a, b, c =[int(q) for q in input().split()] x, y, z =[int(q) for q in input().split()] if a>=x: a -=x x=0 else: x -=a a=0 if b>=y: b -=y y=0 else: y -=b b=0 if c>=z: c -=z z=0 else: z -=c c=0 if x+y+z<=a//2+b//2+c//2: print("Yes") else: print("No")
["Yes", "No", "Yes"]
Python
NoteIn the first sample the wizard has 4 blue and 4 violet spheres. In his first action he can turn two blue spheres into one violet one. After that he will have 2 blue and 5 violet spheres. Then he turns 4 violet spheres into 2 orange spheres and he ends up with 2 blue, 1 violet and 2 orange spheres, which is exactly what he needs.
If the wizard is able to obtain the required numbers of spheres, print "Yes". Otherwise, print "No".
Carl is a beginner magician. He has a blue, b violet and c orange magic spheres. In one move he can transform two spheres of the same color into one sphere of any other color. To make a spell that has never been seen before, he needs at least x blue, y violet and z orange spheres. Can he get them (possible, in multiple actions)?
[{"input": "4 4 0\r\n2 1 2\r\n", "output": ["YES", "Yes"]}, {"input": "5 6 1\r\n2 7 2\r\n", "output": ["No", "NO"]}, {"input": "3 3 3\r\n2 2 2\r\n", "output": ["YES", "Yes"]}, {"input": "0 0 0\r\n0 0 0\r\n", "output": ["YES", "Yes"]}, {"input": "0 0 0\r\n0 0 1\r\n", "output": ["No", "NO"]}, {"input": "0 1 0\r\n0 0 0\r\n", "output": ["YES", "Yes"]}, {"input": "1 0 0\r\n1 0 0\r\n", "output": ["YES", "Yes"]}, {"input": "2 2 1\r\n1 1 2\r\n", "output": ["No", "NO"]}, {"input": "1 3 1\r\n2 1 1\r\n", "output": ["YES", "Yes"]}, {"input": "1000000 1000000 1000000\r\n1000000 1000000 1000000\r\n", "output": ["YES", "Yes"]}, {"input": "1000000 500000 500000\r\n0 750000 750000\r\n", "output": ["YES", "Yes"]}, {"input": "500000 1000000 500000\r\n750001 0 750000\r\n", "output": ["No", "NO"]}, {"input": "499999 500000 1000000\r\n750000 750000 0\r\n", "output": ["No", "NO"]}, {"input": "500000 500000 0\r\n0 0 500000\r\n", "output": ["YES", "Yes"]}, {"input": "0 500001 499999\r\n500000 0 0\r\n", "output": ["No", "NO"]}, {"input": "1000000 500000 1000000\r\n500000 1000000 500000\r\n", "output": ["YES", "Yes"]}, {"input": "1000000 1000000 499999\r\n500000 500000 1000000\r\n", "output": ["No", "NO"]}, {"input": "500000 1000000 1000000\r\n1000000 500001 500000\r\n", "output": ["No", "NO"]}, {"input": "1000000 500000 500000\r\n0 1000000 500000\r\n", "output": ["YES", "Yes"]}, {"input": "500000 500000 1000000\r\n500001 1000000 0\r\n", "output": ["No", "NO"]}, {"input": "500000 999999 500000\r\n1000000 0 500000\r\n", "output": ["No", "NO"]}, {"input": "4 0 3\r\n2 2 1\r\n", "output": ["YES", "Yes"]}, {"input": "0 2 4\r\n2 0 2\r\n", "output": ["YES", "Yes"]}, {"input": "3 1 0\r\n1 1 1\r\n", "output": ["YES", "Yes"]}, {"input": "4 4 1\r\n1 3 2\r\n", "output": ["YES", "Yes"]}, {"input": "1 2 4\r\n2 1 3\r\n", "output": ["No", "NO"]}, {"input": "1 1 0\r\n0 0 1\r\n", "output": ["No", "NO"]}, {"input": "4 0 0\r\n0 1 1\r\n", "output": ["YES", "Yes"]}, {"input": "0 3 0\r\n1 0 1\r\n", "output": ["No", "NO"]}, {"input": "0 0 3\r\n1 0 1\r\n", "output": ["YES", "Yes"]}, {"input": "1 12 1\r\n4 0 4\r\n", "output": ["YES", "Yes"]}, {"input": "4 0 4\r\n1 2 1\r\n", "output": ["YES", "Yes"]}, {"input": "4 4 0\r\n1 1 3\r\n", "output": ["No", "NO"]}, {"input": "0 9 0\r\n2 2 2\r\n", "output": ["No", "NO"]}, {"input": "0 10 0\r\n2 2 2\r\n", "output": ["YES", "Yes"]}, {"input": "9 0 9\r\n0 8 0\r\n", "output": ["YES", "Yes"]}, {"input": "0 9 9\r\n9 0 0\r\n", "output": ["No", "NO"]}, {"input": "9 10 0\r\n0 0 9\r\n", "output": ["YES", "Yes"]}, {"input": "10 0 9\r\n0 10 0\r\n", "output": ["No", "NO"]}, {"input": "0 10 10\r\n10 0 0\r\n", "output": ["YES", "Yes"]}, {"input": "10 10 0\r\n0 0 11\r\n", "output": ["No", "NO"]}, {"input": "307075 152060 414033\r\n381653 222949 123101\r\n", "output": ["No", "NO"]}, {"input": "569950 228830 153718\r\n162186 357079 229352\r\n", "output": ["No", "NO"]}, {"input": "149416 303568 749016\r\n238307 493997 190377\r\n", "output": ["No", "NO"]}, {"input": "438332 298094 225324\r\n194220 400244 245231\r\n", "output": ["No", "NO"]}, {"input": "293792 300060 511272\r\n400687 382150 133304\r\n", "output": ["No", "NO"]}, {"input": "295449 518151 368838\r\n382897 137148 471892\r\n", "output": ["No", "NO"]}, {"input": "191789 291147 691092\r\n324321 416045 176232\r\n", "output": ["YES", "Yes"]}, {"input": "286845 704749 266526\r\n392296 104421 461239\r\n", "output": ["YES", "Yes"]}, {"input": "135522 188282 377041\r\n245719 212473 108265\r\n", "output": ["YES", "Yes"]}, {"input": "404239 359124 133292\r\n180069 184791 332544\r\n", "output": ["No", "NO"]}, {"input": "191906 624432 244408\r\n340002 367217 205432\r\n", "output": ["No", "NO"]}, {"input": "275980 429361 101824\r\n274288 302579 166062\r\n", "output": ["No", "NO"]}, {"input": "136092 364927 395302\r\n149173 343146 390922\r\n", "output": ["No", "NO"]}, {"input": "613852 334661 146012\r\n363786 326286 275233\r\n", "output": ["No", "NO"]}, {"input": "348369 104625 525203\r\n285621 215396 366411\r\n", "output": ["No", "NO"]}, {"input": "225307 153572 114545\r\n154753 153282 149967\r\n", "output": ["YES", "Yes"]}, {"input": "438576 124465 629784\r\n375118 276028 390116\r\n", "output": ["YES", "Yes"]}, {"input": "447521 327510 158732\r\n395759 178458 259139\r\n", "output": ["YES", "Yes"]}, {"input": "8 5 5\r\n5 5 5\r\n", "output": ["YES", "Yes"]}, {"input": "100 100 100\r\n1 1 1\r\n", "output": ["YES", "Yes"]}, {"input": "100 100 100\r\n0 0 0\r\n", "output": ["YES", "Yes"]}, {"input": "3 2 3\r\n2 3 2\r\n", "output": ["No", "NO"]}, {"input": "5 4 3\r\n2 2 2\r\n", "output": ["YES", "Yes"]}, {"input": "14 9 8\r\n12 5 10\r\n", "output": ["YES", "Yes"]}, {"input": "10 10 10\r\n1 1 1\r\n", "output": ["YES", "Yes"]}, {"input": "6 3 3\r\n3 3 3\r\n", "output": ["YES", "Yes"]}, {"input": "10 0 4\r\n2 4 2\r\n", "output": ["YES", "Yes"]}, {"input": "100 100 100\r\n2 2 2\r\n", "output": ["YES", "Yes"]}, {"input": "4 6 0\r\n2 1 2\r\n", "output": ["YES", "Yes"]}, {"input": "4 6 3\r\n4 2 3\r\n", "output": ["YES", "Yes"]}, {"input": "5 5 5\r\n1 1 1\r\n", "output": ["YES", "Yes"]}, {"input": "41 17 34\r\n0 19 24\r\n", "output": ["YES", "Yes"]}, {"input": "8 8 8\r\n3 3 3\r\n", "output": ["YES", "Yes"]}, {"input": "7 7 1\r\n1 1 2\r\n", "output": ["YES", "Yes"]}, {"input": "6 6 0\r\n2 2 2\r\n", "output": ["YES", "Yes"]}, {"input": "5 5 5\r\n2 2 2\r\n", "output": ["YES", "Yes"]}, {"input": "400 400 400\r\n1 1 1\r\n", "output": ["YES", "Yes"]}, {"input": "4 4 4\r\n2 2 2\r\n", "output": ["YES", "Yes"]}]
100
100
100
[{'input': '438332 298094 225324\r\n194220 400244 245231\r\n', 'output': ['No', 'NO']}, {'input': '438576 124465 629784\r\n375118 276028 390116\r\n', 'output': ['YES', 'Yes']}, {'input': '0 10 10\r\n10 0 0\r\n', 'output': ['YES', 'Yes']}, {'input': '1 3 1\r\n2 1 1\r\n', 'output': ['YES', 'Yes']}, {'input': '2 2 1\r\n1 1 2\r\n', 'output': ['No', 'NO']}]
[{'input': '4 0 3\r\n2 2 1\r\n', 'output': ['YES', 'Yes']}, {'input': '6 3 3\r\n3 3 3\r\n', 'output': ['YES', 'Yes']}, {'input': '14 9 8\r\n12 5 10\r\n', 'output': ['YES', 'Yes']}, {'input': '293792 300060 511272\r\n400687 382150 133304\r\n', 'output': ['No', 'NO']}, {'input': '286845 704749 266526\r\n392296 104421 461239\r\n', 'output': ['YES', 'Yes']}]
[{'input': '348369 104625 525203\r\n285621 215396 366411\r\n', 'output': ['No', 'NO']}, {'input': '6 6 0\r\n2 2 2\r\n', 'output': ['YES', 'Yes']}, {'input': '0 2 4\r\n2 0 2\r\n', 'output': ['YES', 'Yes']}, {'input': '404239 359124 133292\r\n180069 184791 332544\r\n', 'output': ['No', 'NO']}, {'input': '41 17 34\r\n0 19 24\r\n', 'output': ['YES', 'Yes']}]
[{'input': '500000 500000 1000000\r\n500001 1000000 0\r\n', 'output': ['No', 'NO']}, {'input': '0 9 9\r\n9 0 0\r\n', 'output': ['No', 'NO']}, {'input': '1000000 500000 1000000\r\n500000 1000000 500000\r\n', 'output': ['YES', 'Yes']}, {'input': '4 4 0\r\n1 1 3\r\n', 'output': ['No', 'NO']}, {'input': '0 0 3\r\n1 0 1\r\n', 'output': ['YES', 'Yes']}]
[{'input': '1 12 1\r\n4 0 4\r\n', 'output': ['YES', 'Yes']}, {'input': '4 0 0\r\n0 1 1\r\n', 'output': ['YES', 'Yes']}, {'input': '5 5 5\r\n2 2 2\r\n', 'output': ['YES', 'Yes']}, {'input': '500000 500000 1000000\r\n500001 1000000 0\r\n', 'output': ['No', 'NO']}, {'input': '0 0 0\r\n0 0 1\r\n', 'output': ['No', 'NO']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
315
100
100
100
["1 7 3 3", "7 7 7 7"]
The first line contains four space-separated integers s1, s2, s3, s4 (1 ≀ s1, s2, s3, s4 ≀ 109) β€” the colors of horseshoes Valera has. Consider all possible colors indexed with integers.
38c4864937e57b35d3cce272f655e20f
s = [int(i) for i in input().split()] m=0 for i in s: if s.count(i) >= 2: s = list(set(s)) m = len(s) if m == 4: print(0) elif m == 3: print(1) elif m == 2: print(2) else: print(3)
["1", "3"]
Python
null
Print a single integer β€” the minimum number of horseshoes Valera needs to buy.
Valera the Horse is going to the party with friends. He has been following the fashion trends for a while, and he knows that it is very popular to wear all horseshoes of different color. Valera has got four horseshoes left from the last year, but maybe some of them have the same color. In this case he needs to go to the store and buy some few more horseshoes, not to lose face in front of his stylish comrades.Fortunately, the store sells horseshoes of all colors under the sun and Valera has enough money to buy any four of them. However, in order to save the money, he would like to spend as little money as possible, so you need to help Valera and determine what is the minimum number of horseshoes he needs to buy to wear four horseshoes of different colors to a party.
[{"input": "1 7 3 3\r\n", "output": ["1"]}, {"input": "7 7 7 7\r\n", "output": ["3"]}, {"input": "81170865 673572653 756938629 995577259\r\n", "output": ["0"]}, {"input": "3491663 217797045 522540872 715355328\r\n", "output": ["0"]}, {"input": "251590420 586975278 916631563 586975278\r\n", "output": ["1"]}, {"input": "259504825 377489979 588153796 377489979\r\n", "output": ["1"]}, {"input": "652588203 931100304 931100304 652588203\r\n", "output": ["2"]}, {"input": "391958720 651507265 391958720 651507265\r\n", "output": ["2"]}, {"input": "90793237 90793237 90793237 90793237\r\n", "output": ["3"]}, {"input": "551651653 551651653 551651653 551651653\r\n", "output": ["3"]}, {"input": "156630260 609654355 668943582 973622757\r\n", "output": ["0"]}, {"input": "17061017 110313588 434481173 796661222\r\n", "output": ["0"]}, {"input": "24975422 256716298 337790533 690960249\r\n", "output": ["0"]}, {"input": "255635360 732742923 798648949 883146723\r\n", "output": ["0"]}, {"input": "133315691 265159773 734556507 265159773\r\n", "output": ["1"]}, {"input": "28442865 741657755 978106882 978106882\r\n", "output": ["1"]}, {"input": "131245479 174845575 497483467 131245479\r\n", "output": ["1"]}, {"input": "139159884 616215581 958341883 616215581\r\n", "output": ["1"]}, {"input": "147784432 947653080 947653080 947653080\r\n", "output": ["2"]}, {"input": "94055790 756126496 756126496 94055790\r\n", "output": ["2"]}, {"input": "240458500 511952208 240458500 511952208\r\n", "output": ["2"]}, {"input": "681828506 972810624 972810624 681828506\r\n", "output": ["2"]}, {"input": "454961014 454961014 454961014 454961014\r\n", "output": ["3"]}, {"input": "915819430 915819430 915819430 915819430\r\n", "output": ["3"]}, {"input": "671645142 671645142 671645142 671645142\r\n", "output": ["3"]}, {"input": "132503558 132503558 132503558 132503558\r\n", "output": ["3"]}, {"input": "5 5 999999 6\r\n", "output": ["1"]}, {"input": "1 1 2 5\r\n", "output": ["1"]}, {"input": "2 1 2 3\r\n", "output": ["1"]}, {"input": "1 1 3 5\r\n", "output": ["1"]}, {"input": "1 1 3 3\r\n", "output": ["2"]}, {"input": "2 2 2 1\r\n", "output": ["2"]}, {"input": "3 1 1 1\r\n", "output": ["2"]}, {"input": "1 2 2 2\r\n", "output": ["2"]}]
100
100
100
[{'input': '133315691 265159773 734556507 265159773\r\n', 'output': ['1']}, {'input': '81170865 673572653 756938629 995577259\r\n', 'output': ['0']}, {'input': '251590420 586975278 916631563 586975278\r\n', 'output': ['1']}, {'input': '147784432 947653080 947653080 947653080\r\n', 'output': ['2']}, {'input': '1 1 2 5\r\n', 'output': ['1']}]
[{'input': '7 7 7 7\r\n', 'output': ['3']}, {'input': '551651653 551651653 551651653 551651653\r\n', 'output': ['3']}, {'input': '156630260 609654355 668943582 973622757\r\n', 'output': ['0']}, {'input': '3491663 217797045 522540872 715355328\r\n', 'output': ['0']}, {'input': '1 2 2 2\r\n', 'output': ['2']}]
[{'input': '81170865 673572653 756938629 995577259\r\n', 'output': ['0']}, {'input': '1 2 2 2\r\n', 'output': ['2']}, {'input': '1 1 3 5\r\n', 'output': ['1']}, {'input': '1 1 2 5\r\n', 'output': ['1']}, {'input': '3491663 217797045 522540872 715355328\r\n', 'output': ['0']}]
[{'input': '156630260 609654355 668943582 973622757\r\n', 'output': ['0']}, {'input': '255635360 732742923 798648949 883146723\r\n', 'output': ['0']}, {'input': '454961014 454961014 454961014 454961014\r\n', 'output': ['3']}, {'input': '915819430 915819430 915819430 915819430\r\n', 'output': ['3']}, {'input': '1 1 3 5\r\n', 'output': ['1']}]
[{'input': '551651653 551651653 551651653 551651653\r\n', 'output': ['3']}, {'input': '1 1 3 3\r\n', 'output': ['2']}, {'input': '17061017 110313588 434481173 796661222\r\n', 'output': ['0']}, {'input': '391958720 651507265 391958720 651507265\r\n', 'output': ['2']}, {'input': '132503558 132503558 132503558 132503558\r\n', 'output': ['3']}]
100
100
100
100
100
92.31
92.31
92.31
92.31
92.31
91.67
91.67
91.67
91.67
91.67
316
100
92.31
91.67
["code\nedoc", "abb\naba", "code\ncode"]
The first line contains word s, the second line contains word t. The words consist of lowercase Latin letters. The input data do not consist unnecessary spaces. The words are not empty and their lengths do not exceed 100 symbols.
35a4be326690b58bf9add547fb63a5a5
word1 = input() word2 = input() w1len = len(word1) w2len = len(word2) if w1len != w2len: print('NO') else: if (w1len % 2) == 0: # ES index = w1len - 1 cant = w1len i = 0 while cant != 0: a = word1[i] b = word2[index] if a == b: i += 1 index -= 1 cant -= 1 else: print('NO') break if cant == 0: print('YES') else: index = w1len - 1 cant = w1len i = 0 while cant != 0: a = word1[i] b = word2[index] if a == b: i += 1 index -= 1 cant -= 1 else: print('NO') break if cant == 0: print('YES')
["YES", "NO", "NO"]
Python
null
If the word t is a word s, written reversely, print YES, otherwise print NO.
The translation from the Berland language into the Birland language is not an easy task. Those languages are very similar: a berlandish word differs from a birlandish word with the same meaning a little: it is spelled (and pronounced) reversely. For example, a Berlandish word code corresponds to a Birlandish word edoc. However, it's easy to make a mistake during the Β«translationΒ». Vasya translated word s from Berlandish into Birlandish as t. Help him: find out if he translated the word correctly.
[{"input": "code\r\nedoc\r\n", "output": ["YES"]}, {"input": "abb\r\naba\r\n", "output": ["NO"]}, {"input": "code\r\ncode\r\n", "output": ["NO"]}, {"input": "abacaba\r\nabacaba\r\n", "output": ["YES"]}, {"input": "q\r\nq\r\n", "output": ["YES"]}, {"input": "asrgdfngfnmfgnhweratgjkk\r\nasrgdfngfnmfgnhweratgjkk\r\n", "output": ["NO"]}, {"input": "z\r\na\r\n", "output": ["NO"]}, {"input": "asd\r\ndsa\r\n", "output": ["YES"]}, {"input": "abcdef\r\nfecdba\r\n", "output": ["NO"]}, {"input": "ywjjbirapvskozubvxoemscfwl\r\ngnduubaogtfaiowjizlvjcu\r\n", "output": ["NO"]}, {"input": "mfrmqxtzvgaeuleubcmcxcfqyruwzenguhgrmkuhdgnhgtgkdszwqyd\r\nmfxufheiperjnhyczclkmzyhcxntdfskzkzdwzzujdinf\r\n", "output": ["NO"]}, {"input": "bnbnemvybqizywlnghlykniaxxxlkhftppbdeqpesrtgkcpoeqowjwhrylpsziiwcldodcoonpimudvrxejjo\r\ntiynnekmlalogyvrgptbinkoqdwzuiyjlrldxhzjmmp\r\n", "output": ["NO"]}, {"input": "pwlpubwyhzqvcitemnhvvwkmwcaawjvdiwtoxyhbhbxerlypelevasmelpfqwjk\r\nstruuzebbcenziscuoecywugxncdwzyfozhljjyizpqcgkyonyetarcpwkqhuugsqjuixsxptmbnlfupdcfigacdhhrzb\r\n", "output": ["NO"]}, {"input": "gdvqjoyxnkypfvdxssgrihnwxkeojmnpdeobpecytkbdwujqfjtxsqspxvxpqioyfagzjxupqqzpgnpnpxcuipweunqch\r\nkkqkiwwasbhezqcfeceyngcyuogrkhqecwsyerdniqiocjehrpkljiljophqhyaiefjpavoom\r\n", "output": ["NO"]}, {"input": "umeszdawsvgkjhlqwzents\r\nhxqhdungbylhnikwviuh\r\n", "output": ["NO"]}, {"input": "juotpscvyfmgntshcealgbsrwwksgrwnrrbyaqqsxdlzhkbugdyx\r\nibqvffmfktyipgiopznsqtrtxiijntdbgyy\r\n", "output": ["NO"]}, {"input": "zbwueheveouatecaglziqmudxemhrsozmaujrwlqmppzoumxhamwugedikvkblvmxwuofmpafdprbcftew\r\nulczwrqhctbtbxrhhodwbcxwimncnexosksujlisgclllxokrsbnozthajnnlilyffmsyko\r\n", "output": ["NO"]}, {"input": "nkgwuugukzcv\r\nqktnpxedwxpxkrxdvgmfgoxkdfpbzvwsduyiybynbkouonhvmzakeiruhfmvrktghadbfkmwxduoqv\r\n", "output": ["NO"]}, {"input": "incenvizhqpcenhjhehvjvgbsnfixbatrrjstxjzhlmdmxijztphxbrldlqwdfimweepkggzcxsrwelodpnryntepioqpvk\r\ndhjbjjftlvnxibkklxquwmzhjfvnmwpapdrslioxisbyhhfymyiaqhlgecpxamqnocizwxniubrmpyubvpenoukhcobkdojlybxd\r\n", "output": ["NO"]}, {"input": "w\r\nw\r\n", "output": ["YES"]}, {"input": "vz\r\nzv\r\n", "output": ["YES"]}, {"input": "ry\r\nyr\r\n", "output": ["YES"]}, {"input": "xou\r\nuox\r\n", "output": ["YES"]}, {"input": "axg\r\ngax\r\n", "output": ["NO"]}, {"input": "zdsl\r\nlsdz\r\n", "output": ["YES"]}, {"input": "kudl\r\nldku\r\n", "output": ["NO"]}, {"input": "zzlzwnqlcl\r\nlclqnwzlzz\r\n", "output": ["YES"]}, {"input": "vzzgicnzqooejpjzads\r\nsdazjpjeooqzncigzzv\r\n", "output": ["YES"]}, {"input": "raqhmvmzuwaykjpyxsykr\r\nxkysrypjkyawuzmvmhqar\r\n", "output": ["NO"]}, {"input": "ngedczubzdcqbxksnxuavdjaqtmdwncjnoaicvmodcqvhfezew\r\nwezefhvqcdomvciaonjcnwdmtqajdvauxnskxbqcdzbuzcdegn\r\n", "output": ["YES"]}, {"input": "muooqttvrrljcxbroizkymuidvfmhhsjtumksdkcbwwpfqdyvxtrlymofendqvznzlmim\r\nmimlznzvqdnefomylrtxvydqfpwwbckdskmutjshhmfvdiumykziorbxcjlrrvttqooum\r\n", "output": ["YES"]}, {"input": "vxpqullmcbegsdskddortcvxyqlbvxmmkhevovnezubvpvnrcajpxraeaxizgaowtfkzywvhnbgzsxbhkaipcmoumtikkiyyaivg\r\ngviayyikkitmuomcpiakhbxszgbnhvwyzkftwoagzixaearxpjacrnvpvbuzenvovehkmmxvblqyxvctroddksdsgebcmlluqpxv\r\n", "output": ["YES"]}, {"input": "mnhaxtaopjzrkqlbroiyipitndczpunwygstmzevgyjdzyanxkdqnvgkikfabwouwkkbzuiuvgvxgpizsvqsbwepktpdrgdkmfdc\r\ncdfmkdgrdptkpewbsqvszipgxvgvuiuzbkkwuowbafkikgvnqdkxnayzdjygvezmtsgywnupocdntipiyiorblqkrzjpzatxahnm\r\n", "output": ["NO"]}, {"input": "dgxmzbqofstzcdgthbaewbwocowvhqpinehpjatnnbrijcolvsatbblsrxabzrpszoiecpwhfjmwuhqrapvtcgvikuxtzbftydkw\r\nwkdytfbztxukivgctvparqhuwmjfhwpceiozsprzbaxrslbbqasvlocjirbnntajphenipthvwocowbweabhtgdcztsfoqbzmxgd\r\n", "output": ["NO"]}, {"input": "gxoixiecetohtgjgbqzvlaobkhstejxdklghowtvwunnnvauriohuspsdmpzckprwajyxldoyckgjivjpmbfqtszmtocovxwgeh\r\nhegwxvocotmzstqfbmpjvijgkcyodlxyjawrpkczpmdspsuhoiruavnnnuwvtwohglkdxjetshkboalvzqbgjgthoteceixioxg\r\n", "output": ["YES"]}, {"input": "sihxuwvmaambplxvjfoskinghzicyfqebjtkysotattkahssumfcgrkheotdxwjckpvapbkaepqrxseyfrwtyaycmrzsrsngkh\r\nhkgnsrszrmcyaytwrfyesxrqpeakbpavpkcjwxdtoehkrgcfmusshakttatosyktjbeqfycizhgniksofjvxlpbmaamvwuxhis\r\n", "output": ["YES"]}, {"input": "ycnahksbughnonldzrhkysujmylcgcfuludjvjiahtkyzqvkopzqcnwhltbzfugzojqkjjlggmvnultascmygelkiktmfieok\r\nkoeifmtkiklegkmcsatlunvmggkjjlqjozgufzbtlhwncqzpokvqzykthaijvjdulufcgclymjusyyhrzdlnonhgubskhancy\r\n", "output": ["NO"]}, {"input": "wbqasaehtkfojruzyhrlgwmtyiovmzyfifslvlemhqheyaelzwnthrenjsbmntwaoryzwfbxmscmypvxlfmzpnkkjlvwvmtz\r\nztmvwvljkknpzmflxvpymcsmxbfwzyroawtnmbsjnerhtnwzleayehqhmelvlsfifyzmvoiytmwglrhyzurjofktheasaqbw\r\n", "output": ["YES"]}, {"input": "imippqurprbhfugngtgifelytadegwrgaefnfhbjjnmzikvjaccotqzemufqieqldgnbmviisgkynzeldlhqxuqphjfmyij\r\njiymfjhpquxqhldleznykgsiivmbngdlqeiqfumezqtoccajvkizmnjjbhfnfeagrwgedatylefigtgngufhbrpruqppimi\r\n", "output": ["YES"]}, {"input": "bikydffiuisckpvzqlteqfhegsagimodb\r\nbdomigasgehfqetlqzvpkcsiuiffdykib\r\n", "output": ["YES"]}]
100
100
100
[{'input': 'abcdef\r\nfecdba\r\n', 'output': ['NO']}, {'input': 'umeszdawsvgkjhlqwzents\r\nhxqhdungbylhnikwviuh\r\n', 'output': ['NO']}, {'input': 'code\r\nedoc\r\n', 'output': ['YES']}, {'input': 'q\r\nq\r\n', 'output': ['YES']}, {'input': 'bnbnemvybqizywlnghlykniaxxxlkhftppbdeqpesrtgkcpoeqowjwhrylpsziiwcldodcoonpimudvrxejjo\r\ntiynnekmlalogyvrgptbinkoqdwzuiyjlrldxhzjmmp\r\n', 'output': ['NO']}]
[{'input': 'z\r\na\r\n', 'output': ['NO']}, {'input': 'mfrmqxtzvgaeuleubcmcxcfqyruwzenguhgrmkuhdgnhgtgkdszwqyd\r\nmfxufheiperjnhyczclkmzyhcxntdfskzkzdwzzujdinf\r\n', 'output': ['NO']}, {'input': 'abcdef\r\nfecdba\r\n', 'output': ['NO']}, {'input': 'gxoixiecetohtgjgbqzvlaobkhstejxdklghowtvwunnnvauriohuspsdmpzckprwajyxldoyckgjivjpmbfqtszmtocovxwgeh\r\nhegwxvocotmzstqfbmpjvijgkcyodlxyjawrpkczpmdspsuhoiruavnnnuwvtwohglkdxjetshkboalvzqbgjgthoteceixioxg\r\n', 'output': ['YES']}, {'input': 'dgxmzbqofstzcdgthbaewbwocowvhqpinehpjatnnbrijcolvsatbblsrxabzrpszoiecpwhfjmwuhqrapvtcgvikuxtzbftydkw\r\nwkdytfbztxukivgctvparqhuwmjfhwpceiozsprzbaxrslbbqasvlocjirbnntajphenipthvwocowbweabhtgdcztsfoqbzmxgd\r\n', 'output': ['NO']}]
[{'input': 'asrgdfngfnmfgnhweratgjkk\r\nasrgdfngfnmfgnhweratgjkk\r\n', 'output': ['NO']}, {'input': 'abacaba\r\nabacaba\r\n', 'output': ['YES']}, {'input': 'kudl\r\nldku\r\n', 'output': ['NO']}, {'input': 'sihxuwvmaambplxvjfoskinghzicyfqebjtkysotattkahssumfcgrkheotdxwjckpvapbkaepqrxseyfrwtyaycmrzsrsngkh\r\nhkgnsrszrmcyaytwrfyesxrqpeakbpavpkcjwxdtoehkrgcfmusshakttatosyktjbeqfycizhgniksofjvxlpbmaamvwuxhis\r\n', 'output': ['YES']}, {'input': 'vxpqullmcbegsdskddortcvxyqlbvxmmkhevovnezubvpvnrcajpxraeaxizgaowtfkzywvhnbgzsxbhkaipcmoumtikkiyyaivg\r\ngviayyikkitmuomcpiakhbxszgbnhvwyzkftwoagzixaearxpjacrnvpvbuzenvovehkmmxvblqyxvctroddksdsgebcmlluqpxv\r\n', 'output': ['YES']}]
[{'input': 'w\r\nw\r\n', 'output': ['YES']}, {'input': 'abacaba\r\nabacaba\r\n', 'output': ['YES']}, {'input': 'muooqttvrrljcxbroizkymuidvfmhhsjtumksdkcbwwpfqdyvxtrlymofendqvznzlmim\r\nmimlznzvqdnefomylrtxvydqfpwwbckdskmutjshhmfvdiumykziorbxcjlrrvttqooum\r\n', 'output': ['YES']}, {'input': 'z\r\na\r\n', 'output': ['NO']}, {'input': 'zbwueheveouatecaglziqmudxemhrsozmaujrwlqmppzoumxhamwugedikvkblvmxwuofmpafdprbcftew\r\nulczwrqhctbtbxrhhodwbcxwimncnexosksujlisgclllxokrsbnozthajnnlilyffmsyko\r\n', 'output': ['NO']}]
[{'input': 'ywjjbirapvskozubvxoemscfwl\r\ngnduubaogtfaiowjizlvjcu\r\n', 'output': ['NO']}, {'input': 'vzzgicnzqooejpjzads\r\nsdazjpjeooqzncigzzv\r\n', 'output': ['YES']}, {'input': 'abb\r\naba\r\n', 'output': ['NO']}, {'input': 'abacaba\r\nabacaba\r\n', 'output': ['YES']}, {'input': 'mnhaxtaopjzrkqlbroiyipitndczpunwygstmzevgyjdzyanxkdqnvgkikfabwouwkkbzuiuvgvxgpizsvqsbwepktpdrgdkmfdc\r\ncdfmkdgrdptkpewbsqvszipgxvgvuiuzbkkwuowbafkikgvnqdkxnayzdjygvezmtsgywnupocdntipiyiorblqkrzjpzatxahnm\r\n', 'output': ['NO']}]
100
100
100
100
100
94.29
97.14
91.43
60
97.14
87.5
87.5
81.25
56.25
87.5
317
100
88
80
["3000"]
The only line of the input contains one integer n (1 ≀ n ≀ 1018) β€” the prediction on the number of people who will buy the game.
8551308e5ff435e0fc507b89a912408a
print(int(int(input())/2520))
["1"]
Python
null
Output one integer showing how many numbers from 1 to n are divisible by all numbers from 2 to 10.
IT City company developing computer games invented a new way to reward its employees. After a new game release users start buying it actively, and the company tracks the number of sales with precision to each transaction. Every time when the next number of sales is divisible by all numbers from 2 to 10 every developer of this game gets a small bonus.A game designer Petya knows that the company is just about to release a new game that was partly developed by him. On the basis of his experience he predicts that n people will buy the game during the first month. Now Petya wants to determine how many times he will get the bonus. Help him to know it.
[{"input": "3000\r\n", "output": ["1"]}, {"input": "2520\r\n", "output": ["1"]}, {"input": "2519\r\n", "output": ["0"]}, {"input": "2521\r\n", "output": ["1"]}, {"input": "1\r\n", "output": ["0"]}, {"input": "314159265\r\n", "output": ["124666"]}, {"input": "718281828459045235\r\n", "output": ["285032471610732"]}, {"input": "1000000000000000000\r\n", "output": ["396825396825396"]}, {"input": "987654321234567890\r\n", "output": ["391926317950225"]}, {"input": "3628800\r\n", "output": ["1440"]}, {"input": "504000000000000000\r\n", "output": ["200000000000000"]}]
100
100
100
[{'input': '3628800\r\n', 'output': ['1440']}, {'input': '1000000000000000000\r\n', 'output': ['396825396825396']}, {'input': '314159265\r\n', 'output': ['124666']}, {'input': '504000000000000000\r\n', 'output': ['200000000000000']}, {'input': '2520\r\n', 'output': ['1']}]
[{'input': '1000000000000000000\r\n', 'output': ['396825396825396']}, {'input': '314159265\r\n', 'output': ['124666']}, {'input': '3000\r\n', 'output': ['1']}, {'input': '1\r\n', 'output': ['0']}, {'input': '2521\r\n', 'output': ['1']}]
[{'input': '1000000000000000000\r\n', 'output': ['396825396825396']}, {'input': '314159265\r\n', 'output': ['124666']}, {'input': '2519\r\n', 'output': ['0']}, {'input': '3628800\r\n', 'output': ['1440']}, {'input': '2521\r\n', 'output': ['1']}]
[{'input': '718281828459045235\r\n', 'output': ['285032471610732']}, {'input': '1\r\n', 'output': ['0']}, {'input': '1000000000000000000\r\n', 'output': ['396825396825396']}, {'input': '3000\r\n', 'output': ['1']}, {'input': '2520\r\n', 'output': ['1']}]
[{'input': '1000000000000000000\r\n', 'output': ['396825396825396']}, {'input': '2520\r\n', 'output': ['1']}, {'input': '718281828459045235\r\n', 'output': ['285032471610732']}, {'input': '2521\r\n', 'output': ['1']}, {'input': '2519\r\n', 'output': ['0']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
318
100
100
100
["1", "2", "3"]
The first line contains a single integer n (1 ≀ n ≀ 40).
c2cbc35012c6ff7ab0d6899e6015e4e7
# I've proven, that z takes form of 2 ** (k - 1) - 1, # where 2 ** k - 1 is prime, which are called 'Mersenne primes'. p = [2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127,\ 521, 607, 1279, 2203, 2281, 3217, 4253, 4423, 9689,\ 9941, 11213, 19937, 21701, 23209, 44497, 86243, 110503,\ 132049, 216091, 756839, 859433, 1257787, 1398269,\ 2976221, 3021377, 6972593, 13466917, 20996011] n = int(input()) MOD = 10 ** 9 + 7 print((pow(2, p[n - 1] - 1, MOD) - 1) % MOD)
["1", "3", "15"]
Python
null
Print a single integer β€” the number zn modulo 1000000007 (109 + 7). It is guaranteed that the answer exists.
Consider the following equation: where sign [a] represents the integer part of number a.Let's find all integer z (z &gt; 0), for which this equation is unsolvable in positive integers. The phrase "unsolvable in positive integers" means that there are no such positive integers x and y (x, y &gt; 0), for which the given above equation holds.Let's write out all such z in the increasing order: z1, z2, z3, and so on (zi &lt; zi + 1). Your task is: given the number n, find the number zn.
[{"input": "1\r\n", "output": ["1"]}, {"input": "2\r\n", "output": ["3"]}, {"input": "3\r\n", "output": ["15"]}, {"input": "4\r\n", "output": ["63"]}, {"input": "5\r\n", "output": ["4095"]}, {"input": "6\r\n", "output": ["65535"]}, {"input": "7\r\n", "output": ["262143"]}, {"input": "8\r\n", "output": ["73741816"]}, {"input": "9\r\n", "output": ["536396503"]}, {"input": "10\r\n", "output": ["140130950"]}, {"input": "11\r\n", "output": ["487761805"]}, {"input": "12\r\n", "output": ["319908070"]}, {"input": "13\r\n", "output": ["106681874"]}, {"input": "14\r\n", "output": ["373391776"]}, {"input": "15\r\n", "output": ["317758023"]}, {"input": "16\r\n", "output": ["191994803"]}, {"input": "17\r\n", "output": ["416292236"]}, {"input": "18\r\n", "output": ["110940209"]}, {"input": "19\r\n", "output": ["599412198"]}, {"input": "20\r\n", "output": ["383601260"]}, {"input": "21\r\n", "output": ["910358878"]}, {"input": "22\r\n", "output": ["532737550"]}, {"input": "23\r\n", "output": ["348927936"]}, {"input": "24\r\n", "output": ["923450985"]}, {"input": "25\r\n", "output": ["470083777"]}, {"input": "26\r\n", "output": ["642578561"]}, {"input": "27\r\n", "output": ["428308066"]}, {"input": "28\r\n", "output": ["485739298"]}, {"input": "29\r\n", "output": ["419990027"]}, {"input": "30\r\n", "output": ["287292016"]}, {"input": "31\r\n", "output": ["202484167"]}, {"input": "32\r\n", "output": ["389339971"]}, {"input": "33\r\n", "output": ["848994100"]}, {"input": "34\r\n", "output": ["273206869"]}, {"input": "35\r\n", "output": ["853092282"]}, {"input": "36\r\n", "output": ["411696552"]}, {"input": "37\r\n", "output": ["876153853"]}, {"input": "38\r\n", "output": ["90046024"]}, {"input": "39\r\n", "output": ["828945523"]}, {"input": "40\r\n", "output": ["697988359"]}]
100
100
100
[{'input': '37\r\n', 'output': ['876153853']}, {'input': '22\r\n', 'output': ['532737550']}, {'input': '26\r\n', 'output': ['642578561']}, {'input': '15\r\n', 'output': ['317758023']}, {'input': '36\r\n', 'output': ['411696552']}]
[{'input': '15\r\n', 'output': ['317758023']}, {'input': '29\r\n', 'output': ['419990027']}, {'input': '7\r\n', 'output': ['262143']}, {'input': '39\r\n', 'output': ['828945523']}, {'input': '35\r\n', 'output': ['853092282']}]
[{'input': '24\r\n', 'output': ['923450985']}, {'input': '2\r\n', 'output': ['3']}, {'input': '13\r\n', 'output': ['106681874']}, {'input': '5\r\n', 'output': ['4095']}, {'input': '18\r\n', 'output': ['110940209']}]
[{'input': '28\r\n', 'output': ['485739298']}, {'input': '21\r\n', 'output': ['910358878']}, {'input': '13\r\n', 'output': ['106681874']}, {'input': '7\r\n', 'output': ['262143']}, {'input': '35\r\n', 'output': ['853092282']}]
[{'input': '30\r\n', 'output': ['287292016']}, {'input': '12\r\n', 'output': ['319908070']}, {'input': '31\r\n', 'output': ['202484167']}, {'input': '17\r\n', 'output': ['416292236']}, {'input': '1\r\n', 'output': ['1']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
319
100
100
100
["1 2 1000", "2 2 1000", "5 3 1103"]
Input consists of three integers n, k, m (1 ≀ n ≀ 1000, 1 ≀ k ≀ 100, 1 ≀ m ≀ 109).
656bf8df1e79499aa2ab2c28712851f0
def get_input(): hahaha=input() (n,k,m)=hahaha.split(sep=None, maxsplit=1000) return (int(n),int(k),int(m)) (n,k,m)=get_input() f=[0 for i in range(k)] s=0 for v in range(n): tens = 10**v%k f=[ (sum( [f[(j+k-(x+1)*tens)%k] for x in range(9)] )+f[j])%m for j in range(k)] for x in range(9): f[(x+1)*tens%k]+=1 if n-v-1==0: s+=(f[0]%m) else: s+=f[0]*((10**(n-v-2)*9))%m f[0]=0 print(s%m)
["4", "45", "590"]
Python
NoteA suffix of a string S is a non-empty string that can be obtained by removing some number (possibly, zero) of first characters from S.
Print the required number modulo m.
Amr doesn't like Maths as he finds it really boring, so he usually sleeps in Maths lectures. But one day the teacher suspected that Amr is sleeping and asked him a question to make sure he wasn't.First he gave Amr two positive integers n and k. Then he asked Amr, how many integer numbers x &gt; 0 exist such that: Decimal representation of x (without leading zeroes) consists of exactly n digits; There exists some integer y &gt; 0 such that: ; decimal representation of y is a suffix of decimal representation of x. As the answer to this question may be pretty huge the teacher asked Amr to output only its remainder modulo a number m.Can you help Amr escape this embarrassing situation?
[{"input": "1 2 1000\r\n", "output": ["4"]}, {"input": "2 2 1000\r\n", "output": ["45"]}, {"input": "5 3 1103\r\n", "output": ["590"]}, {"input": "2 17 10000\r\n", "output": ["5"]}, {"input": "3 9 10000\r\n", "output": ["252"]}, {"input": "6 64 941761822\r\n", "output": ["46530"]}, {"input": "183 3 46847167\r\n", "output": ["29891566"]}, {"input": "472 44 364550669\r\n", "output": ["122479316"]}, {"input": "510 76 811693420\r\n", "output": ["546301720"]}, {"input": "783 30 602209107\r\n", "output": ["279682329"]}, {"input": "863 47 840397713\r\n", "output": ["433465398"]}, {"input": "422 22 411212542\r\n", "output": ["63862621"]}, {"input": "370 9 385481464\r\n", "output": ["163845824"]}, {"input": "312 41 915197716\r\n", "output": ["912219984"]}, {"input": "261 32 49719977\r\n", "output": ["19320923"]}, {"input": "434 6 56571287\r\n", "output": ["56257936"]}, {"input": "355 3 945669623\r\n", "output": ["219132384"]}, {"input": "905 71 999142682\r\n", "output": ["825882209"]}, {"input": "900 84 526417573\r\n", "output": ["281234824"]}, {"input": "387 3 521021345\r\n", "output": ["435545521"]}, {"input": "246 33 996704992\r\n", "output": ["385601286"]}, {"input": "443 29 106807555\r\n", "output": ["7872021"]}, {"input": "621 43 356382217\r\n", "output": ["251594310"]}, {"input": "782 84 643445347\r\n", "output": ["208138038"]}, {"input": "791 23 94030462\r\n", "output": ["41862326"]}, {"input": "543 98 508536403\r\n", "output": ["117587951"]}, {"input": "20 96 238661639\r\n", "output": ["198761428"]}, {"input": "845 60 888437864\r\n", "output": ["193926448"]}, {"input": "998 85 501663165\r\n", "output": ["145180249"]}, {"input": "123 72 56222855\r\n", "output": ["32350599"]}, {"input": "12 39 618421525\r\n", "output": ["115875938"]}, {"input": "462 35 144751085\r\n", "output": ["79931198"]}, {"input": "674 22 494819681\r\n", "output": ["19590614"]}, {"input": "650 66 579060528\r\n", "output": ["224930740"]}, {"input": "432 80 133016247\r\n", "output": ["25032672"]}, {"input": "176 70 196445230\r\n", "output": ["64904804"]}, {"input": "393 71 933802677\r\n", "output": ["366541352"]}, {"input": "37 92 9838905\r\n", "output": ["7980021"]}, {"input": "993 26 108974437\r\n", "output": ["87469631"]}, {"input": "433 93 36915724\r\n", "output": ["20722839"]}, {"input": "957 88 512982771\r\n", "output": ["161742313"]}, {"input": "170 94 82742818\r\n", "output": ["1117330"]}, {"input": "624 33 145653575\r\n", "output": ["99048377"]}, {"input": "56 48 961996131\r\n", "output": ["199203510"]}, {"input": "889 6 225765429\r\n", "output": ["193135878"]}, {"input": "1 93 727895661\r\n", "output": ["0"]}, {"input": "470 61 617307737\r\n", "output": ["428782123"]}, {"input": "520 94 712232167\r\n", "output": ["199435818"]}, {"input": "531 78 460047919\r\n", "output": ["117748792"]}, {"input": "776 32 523607700\r\n", "output": ["309970800"]}, {"input": "648 74 329538445\r\n", "output": ["177655063"]}, {"input": "885 6 743810885\r\n", "output": ["297512873"]}, {"input": "712 53 592302770\r\n", "output": ["147693148"]}, {"input": "426 72 589297447\r\n", "output": ["316207784"]}, {"input": "561 69 310141994\r\n", "output": ["245538618"]}, {"input": "604 97 26180786\r\n", "output": ["6950800"]}, {"input": "586 32 846994504\r\n", "output": ["579729448"]}, {"input": "514 67 260591607\r\n", "output": ["88291586"]}, {"input": "429 45 103817253\r\n", "output": ["41335161"]}, {"input": "767 27 364988776\r\n", "output": ["259490746"]}, {"input": "497 33 479662107\r\n", "output": ["84548778"]}, {"input": "262 71 404639692\r\n", "output": ["93447345"]}, {"input": "125 33 152527721\r\n", "output": ["59122415"]}, {"input": "857 98 70814341\r\n", "output": ["58423075"]}, {"input": "375 79 416634034\r\n", "output": ["175150318"]}, {"input": "886 10 902171654\r\n", "output": ["134375492"]}, {"input": "335 28 979397289\r\n", "output": ["675105408"]}, {"input": "769 30 474381420\r\n", "output": ["157049322"]}, {"input": "736 31 26855044\r\n", "output": ["24225276"]}, {"input": "891 7 814335325\r\n", "output": ["611862019"]}, {"input": "346 23 947672082\r\n", "output": ["59151110"]}, {"input": "1000 1 382210711\r\n", "output": ["372462157"]}, {"input": "1 1 10000\r\n", "output": ["9"]}, {"input": "1000 100 777767777\r\n", "output": ["577920877"]}, {"input": "1000 13 10619863\r\n", "output": ["8796170"]}, {"input": "1 100 1000\r\n", "output": ["0"]}, {"input": "11 11 11\r\n", "output": ["7"]}, {"input": "1 1 1\r\n", "output": ["0"]}, {"input": "1 2 2\r\n", "output": ["0"]}]
100
100
100
[{'input': '674 22 494819681\r\n', 'output': ['19590614']}, {'input': '900 84 526417573\r\n', 'output': ['281234824']}, {'input': '767 27 364988776\r\n', 'output': ['259490746']}, {'input': '520 94 712232167\r\n', 'output': ['199435818']}, {'input': '998 85 501663165\r\n', 'output': ['145180249']}]
[{'input': '2 2 1000\r\n', 'output': ['45']}, {'input': '1 1 1\r\n', 'output': ['0']}, {'input': '20 96 238661639\r\n', 'output': ['198761428']}, {'input': '561 69 310141994\r\n', 'output': ['245538618']}, {'input': '462 35 144751085\r\n', 'output': ['79931198']}]
[{'input': '712 53 592302770\r\n', 'output': ['147693148']}, {'input': '561 69 310141994\r\n', 'output': ['245538618']}, {'input': '429 45 103817253\r\n', 'output': ['41335161']}, {'input': '355 3 945669623\r\n', 'output': ['219132384']}, {'input': '20 96 238661639\r\n', 'output': ['198761428']}]
[{'input': '510 76 811693420\r\n', 'output': ['546301720']}, {'input': '426 72 589297447\r\n', 'output': ['316207784']}, {'input': '993 26 108974437\r\n', 'output': ['87469631']}, {'input': '1 1 1\r\n', 'output': ['0']}, {'input': '712 53 592302770\r\n', 'output': ['147693148']}]
[{'input': '170 94 82742818\r\n', 'output': ['1117330']}, {'input': '510 76 811693420\r\n', 'output': ['546301720']}, {'input': '998 85 501663165\r\n', 'output': ['145180249']}, {'input': '905 71 999142682\r\n', 'output': ['825882209']}, {'input': '56 48 961996131\r\n', 'output': ['199203510']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
320
100
100
100
["42", "5"]
The only line contains an integer n (1 ≀ n ≀ 10000).
5d4f38ffd1849862623325fdbe06cd00
n=int(input()) a=n//3 b=n%3 if b==2: a=a+1 p=a//12 q=a%12 print(p,q)
["1 2", "0 2"]
Python
null
Print two non-negative space-separated integers a and b, where a is the numbers of feet and b is the number of inches.
Lengths are measures in Baden in inches and feet. To a length from centimeters it is enough to know that an inch equals three centimeters in Baden and one foot contains 12 inches.You are given a length equal to n centimeters. Your task is to convert it to feet and inches so that the number of feet was maximum. The result should be an integer rounded to the closest value containing an integral number of inches.Note that when you round up, 1 cm rounds up to 0 inches and 2 cm round up to 1 inch.
[{"input": "42\r\n", "output": ["1 2"]}, {"input": "5\r\n", "output": ["0 2"]}, {"input": "24\r\n", "output": ["0 8"]}, {"input": "1\r\n", "output": ["0 0"]}, {"input": "2\r\n", "output": ["0 1"]}, {"input": "3\r\n", "output": ["0 1"]}, {"input": "4\r\n", "output": ["0 1"]}, {"input": "8\r\n", "output": ["0 3"]}, {"input": "10\r\n", "output": ["0 3"]}, {"input": "12\r\n", "output": ["0 4"]}, {"input": "13\r\n", "output": ["0 4"]}, {"input": "100\r\n", "output": ["2 9"]}, {"input": "120\r\n", "output": ["3 4"]}, {"input": "199\r\n", "output": ["5 6"]}, {"input": "501\r\n", "output": ["13 11"]}, {"input": "1000\r\n", "output": ["27 9"]}, {"input": "1233\r\n", "output": ["34 3"]}, {"input": "9876\r\n", "output": ["274 4"]}, {"input": "9999\r\n", "output": ["277 9"]}, {"input": "10000\r\n", "output": ["277 9"]}, {"input": "35\r\n", "output": ["1 0"]}, {"input": "71\r\n", "output": ["2 0"]}]
100
100
100
[{'input': '199\r\n', 'output': ['5 6']}, {'input': '10000\r\n', 'output': ['277 9']}, {'input': '1\r\n', 'output': ['0 0']}, {'input': '1233\r\n', 'output': ['34 3']}, {'input': '120\r\n', 'output': ['3 4']}]
[{'input': '1000\r\n', 'output': ['27 9']}, {'input': '3\r\n', 'output': ['0 1']}, {'input': '1\r\n', 'output': ['0 0']}, {'input': '100\r\n', 'output': ['2 9']}, {'input': '10\r\n', 'output': ['0 3']}]
[{'input': '120\r\n', 'output': ['3 4']}, {'input': '501\r\n', 'output': ['13 11']}, {'input': '1\r\n', 'output': ['0 0']}, {'input': '1233\r\n', 'output': ['34 3']}, {'input': '8\r\n', 'output': ['0 3']}]
[{'input': '100\r\n', 'output': ['2 9']}, {'input': '199\r\n', 'output': ['5 6']}, {'input': '3\r\n', 'output': ['0 1']}, {'input': '10\r\n', 'output': ['0 3']}, {'input': '35\r\n', 'output': ['1 0']}]
[{'input': '35\r\n', 'output': ['1 0']}, {'input': '10\r\n', 'output': ['0 3']}, {'input': '199\r\n', 'output': ['5 6']}, {'input': '10000\r\n', 'output': ['277 9']}, {'input': '13\r\n', 'output': ['0 4']}]
100
100
100
100
100
87.5
87.5
100
100
100
50
50
100
100
100
321
100
95
80
["4", "5"]
The single line contains the positive integer n (1 ≀ n ≀ 1015).
689e7876048ee4eb7479e838c981f068
x=int(input()) if x%2==0: print(int(x/2)) else: print(-(int(x/2)+1))
["2", "-3"]
Python
Notef(4) =  - 1 + 2 - 3 + 4 = 2f(5) =  - 1 + 2 - 3 + 4 - 5 =  - 3
Print f(n) in a single line.
For a positive integer n let's define a function f:f(n) =  - 1 + 2 - 3 + .. + ( - 1)nn Your task is to calculate f(n) for a given integer n.
[{"input": "4\r\n", "output": ["2"]}, {"input": "5\r\n", "output": ["-3"]}, {"input": "1000000000\r\n", "output": ["500000000"]}, {"input": "1000000001\r\n", "output": ["-500000001"]}, {"input": "1000000000000000\r\n", "output": ["500000000000000"]}, {"input": "100\r\n", "output": ["50"]}, {"input": "101\r\n", "output": ["-51"]}, {"input": "102\r\n", "output": ["51"]}, {"input": "103\r\n", "output": ["-52"]}, {"input": "104\r\n", "output": ["52"]}, {"input": "105\r\n", "output": ["-53"]}, {"input": "106\r\n", "output": ["53"]}, {"input": "107\r\n", "output": ["-54"]}, {"input": "108\r\n", "output": ["54"]}, {"input": "109\r\n", "output": ["-55"]}, {"input": "208170109961052\r\n", "output": ["104085054980526"]}, {"input": "46017661651072\r\n", "output": ["23008830825536"]}, {"input": "4018154546667\r\n", "output": ["-2009077273334"]}, {"input": "288565475053\r\n", "output": ["-144282737527"]}, {"input": "3052460231\r\n", "output": ["-1526230116"]}, {"input": "29906716\r\n", "output": ["14953358"]}, {"input": "87897701693326\r\n", "output": ["43948850846663"]}, {"input": "8240\r\n", "output": ["4120"]}, {"input": "577935\r\n", "output": ["-288968"]}, {"input": "62\r\n", "output": ["31"]}, {"input": "1\r\n", "output": ["-1"]}, {"input": "2\r\n", "output": ["1"]}, {"input": "9999999999999\r\n", "output": ["-5000000000000"]}, {"input": "1000000000000\r\n", "output": ["500000000000"]}, {"input": "99999999999999\r\n", "output": ["-50000000000000"]}, {"input": "999999999999999\r\n", "output": ["-500000000000000"]}, {"input": "42191359342\r\n", "output": ["21095679671"]}, {"input": "100000000000000\r\n", "output": ["50000000000000"]}, {"input": "145645214654154\r\n", "output": ["72822607327077"]}, {"input": "4294967296\r\n", "output": ["2147483648"]}, {"input": "3037000499\r\n", "output": ["-1518500250"]}, {"input": "10000000000001\r\n", "output": ["-5000000000001"]}, {"input": "100000017040846\r\n", "output": ["50000008520423"]}, {"input": "98979894985999\r\n", "output": ["-49489947493000"]}]
100
100
100
[{'input': '101\r\n', 'output': ['-51']}, {'input': '100\r\n', 'output': ['50']}, {'input': '288565475053\r\n', 'output': ['-144282737527']}, {'input': '100000017040846\r\n', 'output': ['50000008520423']}, {'input': '145645214654154\r\n', 'output': ['72822607327077']}]
[{'input': '1\r\n', 'output': ['-1']}, {'input': '999999999999999\r\n', 'output': ['-500000000000000']}, {'input': '103\r\n', 'output': ['-52']}, {'input': '98979894985999\r\n', 'output': ['-49489947493000']}, {'input': '4294967296\r\n', 'output': ['2147483648']}]
[{'input': '3052460231\r\n', 'output': ['-1526230116']}, {'input': '105\r\n', 'output': ['-53']}, {'input': '999999999999999\r\n', 'output': ['-500000000000000']}, {'input': '103\r\n', 'output': ['-52']}, {'input': '99999999999999\r\n', 'output': ['-50000000000000']}]
[{'input': '100000017040846\r\n', 'output': ['50000008520423']}, {'input': '101\r\n', 'output': ['-51']}, {'input': '1000000000000\r\n', 'output': ['500000000000']}, {'input': '103\r\n', 'output': ['-52']}, {'input': '107\r\n', 'output': ['-54']}]
[{'input': '98979894985999\r\n', 'output': ['-49489947493000']}, {'input': '1000000000\r\n', 'output': ['500000000']}, {'input': '3037000499\r\n', 'output': ['-1518500250']}, {'input': '5\r\n', 'output': ['-3']}, {'input': '62\r\n', 'output': ['31']}]
100
100
100
100
100
100
100
75
100
100
100
100
50
100
100
322
100
95
90
["21", "20"]
The first line contains integer n (1 ≀ n ≀ 109).
ae20ae2a16273a0d379932d6e973f878
n = int(input()) m = str(n) g = len(m) l = [int(m[0])-1]+[9]*(g-1) h = 0 less = 0 while(h<len(l)): less = less + l[h] h = h + 1 a = n - less r = [] i = 0 while(a<n): j = 0 s = str(a) c = a while j<len(s): c = c + int(s[j]) j = j + 1 if(c==n): i +=1 r = r + [a] a = a + 1 if(i==0): print(0) else: print(i) j = 0 while(j<len(r)): print(r[j]) j = j + 1
["1\n15", "0"]
Python
NoteIn the first test case x = 15 there is only one variant: 15 + 1 + 5 = 21.In the second test case there are no such x.
In the first line print one integer kΒ β€” number of different values of x satisfying the condition. In next k lines print these values in ascending order.
Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answer to the arithmetic task for first-graders. In the textbook, a certain positive integer x was given. The task was to add x to the sum of the digits of the number x written in decimal numeral system.Since the number n on the board was small, Vova quickly guessed which x could be in the textbook. Now he wants to get a program which will search for arbitrary values of the number n for all suitable values of x or determine that such x does not exist. Write such a program for Vova.
[{"input": "21\r\n", "output": ["1\r\n15"]}, {"input": "20\r\n", "output": ["0"]}, {"input": "1\r\n", "output": ["0"]}, {"input": "2\r\n", "output": ["1\r\n1"]}, {"input": "3\r\n", "output": ["0"]}, {"input": "100000001\r\n", "output": ["2\r\n99999937\r\n 100000000", "2\r\n99999937 100000000", "2\r\n99999937\r\n100000000"]}, {"input": "1000000000\r\n", "output": ["1\r\n999999932"]}, {"input": "999999979\r\n", "output": ["2\r\n999999899\r\n 999999908", "2\r\n999999899 999999908", "2\r\n999999899\r\n999999908"]}, {"input": "9\r\n", "output": ["0"]}, {"input": "10\r\n", "output": ["1\r\n5"]}, {"input": "11\r\n", "output": ["1\r\n10"]}, {"input": "39\r\n", "output": ["1\r\n33"]}, {"input": "66\r\n", "output": ["1\r\n60"]}, {"input": "75\r\n", "output": ["0"]}, {"input": "100\r\n", "output": ["1\r\n86"]}, {"input": "101\r\n", "output": ["2\r\n91\r\n100", "2\r\n91\r\n 100", "2\r\n91 100"]}, {"input": "2014\r\n", "output": ["2\r\n1988\r\n2006", "2\r\n1988 2006", "2\r\n1988\r\n 2006"]}, {"input": "999999994\r\n", "output": ["0"]}]
100
100
100
[{'input': '100000001\r\n', 'output': ['2\r\n99999937\r\n 100000000', '2\r\n99999937 100000000', '2\r\n99999937\r\n100000000']}, {'input': '100\r\n', 'output': ['1\r\n86']}, {'input': '999999994\r\n', 'output': ['0']}, {'input': '21\r\n', 'output': ['1\r\n15']}, {'input': '1000000000\r\n', 'output': ['1\r\n999999932']}]
[{'input': '75\r\n', 'output': ['0']}, {'input': '11\r\n', 'output': ['1\r\n10']}, {'input': '2014\r\n', 'output': ['2\r\n1988\r\n2006', '2\r\n1988 2006', '2\r\n1988\r\n 2006']}, {'input': '999999979\r\n', 'output': ['2\r\n999999899\r\n 999999908', '2\r\n999999899 999999908', '2\r\n999999899\r\n999999908']}, {'input': '9\r\n', 'output': ['0']}]
[{'input': '3\r\n', 'output': ['0']}, {'input': '39\r\n', 'output': ['1\r\n33']}, {'input': '1000000000\r\n', 'output': ['1\r\n999999932']}, {'input': '21\r\n', 'output': ['1\r\n15']}, {'input': '11\r\n', 'output': ['1\r\n10']}]
[{'input': '100\r\n', 'output': ['1\r\n86']}, {'input': '3\r\n', 'output': ['0']}, {'input': '1\r\n', 'output': ['0']}, {'input': '2014\r\n', 'output': ['2\r\n1988\r\n2006', '2\r\n1988 2006', '2\r\n1988\r\n 2006']}, {'input': '101\r\n', 'output': ['2\r\n91\r\n100', '2\r\n91\r\n 100', '2\r\n91 100']}]
[{'input': '9\r\n', 'output': ['0']}, {'input': '999999979\r\n', 'output': ['2\r\n999999899\r\n 999999908', '2\r\n999999899 999999908', '2\r\n999999899\r\n999999908']}, {'input': '66\r\n', 'output': ['1\r\n60']}, {'input': '2014\r\n', 'output': ['2\r\n1988\r\n2006', '2\r\n1988 2006', '2\r\n1988\r\n 2006']}, {'input': '21\r\n', 'output': ['1\r\n15']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
323
100
100
100
["48", "6"]
The only line of the input contains one integer m (1 ≀ m ≀ 1015), meaning that Limak wants you to choose X between 1 and m, inclusive.
385cf3c40c96f0879788b766eeb25139
#D razbor 1 def func(n): if n<8: return n,n max_a = int(n**(1/3)) if (max_a+1)**3<=n: max_a += 1 v1=func(n-max_a**3) v1=(v1[0]+1,v1[1]+max_a**3) v2=func(max_a**3-1-(max_a-1)**3) v2=(v2[0]+1,v2[1]+(max_a-1)**3) if v2>v1: return v2 else: return v1 print(' '.join(map(str, func(int(input())))))
["9 42", "6 6"]
Python
NoteIn the first sample test, there will be 9 blocks if you choose X = 23 or X = 42. Limak wants to maximize X secondarily so you should choose 42.In more detail, after choosing X = 42 the process of building a tower is: Limak takes a block with side 3 because it's the biggest block with volume not greater than 42. The remaining volume is 42 - 27 = 15. The second added block has side 2, so the remaining volume is 15 - 8 = 7. Finally, Limak adds 7 blocks with side 1, one by one. So, there are 9 blocks in the tower. The total volume is is 33 + 23 + 7Β·13 = 27 + 8 + 7 = 42.
Print two integersΒ β€” the maximum number of blocks in the tower and the maximum required total volume X, resulting in the maximum number of blocks.
Limak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive integer length of side. Limak has infinitely many blocks of each side length.A block with side a has volume a3. A tower consisting of blocks with sides a1, a2, ..., ak has the total volume a13 + a23 + ... + ak3.Limak is going to build a tower. First, he asks you to tell him a positive integer XΒ β€” the required total volume of the tower. Then, Limak adds new blocks greedily, one by one. Each time he adds the biggest block such that the total volume doesn't exceed X.Limak asks you to choose X not greater than m. Also, he wants to maximize the number of blocks in the tower at the end (however, he still behaves greedily). Secondarily, he wants to maximize X.Can you help Limak? Find the maximum number of blocks his tower can have and the maximum X ≀ m that results this number of blocks.
[{"input": "48\r\n", "output": ["9 42"]}, {"input": "6\r\n", "output": ["6 6"]}, {"input": "1\r\n", "output": ["1 1"]}, {"input": "994\r\n", "output": ["12 941"]}, {"input": "567000123\r\n", "output": ["16 566998782"]}, {"input": "123830583943\r\n", "output": ["17 123830561521"]}, {"input": "3842529393411\r\n", "output": ["17 3842529383076"]}, {"input": "999999993700000\r\n", "output": ["18 999999993541753"]}, {"input": "2\r\n", "output": ["2 2"]}, {"input": "7\r\n", "output": ["7 7"]}, {"input": "8\r\n", "output": ["7 7"]}, {"input": "9\r\n", "output": ["7 7"]}, {"input": "112\r\n", "output": ["10 106"]}, {"input": "113\r\n", "output": ["10 113"]}, {"input": "114\r\n", "output": ["11 114"]}, {"input": "265\r\n", "output": ["11 212"]}, {"input": "995\r\n", "output": ["12 995"]}, {"input": "200385\r\n", "output": ["14 200355"]}, {"input": "909383000\r\n", "output": ["16 909381874"]}, {"input": "108000000057\r\n", "output": ["17 107986074062"]}, {"input": "385925923480002\r\n", "output": ["17 385925923479720"]}, {"input": "735412349812385\r\n", "output": ["18 735409591249436"]}, {"input": "980123123123123\r\n", "output": ["18 980123123116482"]}, {"input": "999088000000000\r\n", "output": ["18 999087986204952"]}, {"input": "409477218238716\r\n", "output": ["17 409477218238710"]}, {"input": "409477218238717\r\n", "output": ["17 409477218238717"]}, {"input": "409477218238718\r\n", "output": ["18 409477218238718"]}, {"input": "409477218238719\r\n", "output": ["18 409477218238718"]}, {"input": "419477218238718\r\n", "output": ["18 419466459294818"]}, {"input": "415000000238718\r\n", "output": ["18 414993991790735"]}, {"input": "850085504652042\r\n", "output": ["18 850085504652042"]}, {"input": "850085504652041\r\n", "output": ["18 850085504650655"]}, {"input": "936302451687000\r\n", "output": ["18 936302448662019"]}, {"input": "936302451687001\r\n", "output": ["18 936302448662019"]}, {"input": "936302451686999\r\n", "output": ["18 936302448662019"]}, {"input": "1000000000000000\r\n", "output": ["18 999999993541753"]}, {"input": "780869426483087\r\n", "output": ["18 780869407920631"]}, {"input": "1000000000000000\r\n", "output": ["18 999999993541753"]}, {"input": "990000000000000\r\n", "output": ["18 989983621692990"]}, {"input": "999998169714888\r\n", "output": ["18 999998150030846"]}, {"input": "999971000299999\r\n", "output": ["18 999969994441746"]}, {"input": "999999999999999\r\n", "output": ["18 999999993541753"]}, {"input": "999986542686123\r\n", "output": ["18 999969994441746"]}, {"input": "899990298504716\r\n", "output": ["18 899973747835553"]}, {"input": "409477318238718\r\n", "output": ["18 409477218238718"]}]
100
100
100
[{'input': '123830583943\r\n', 'output': ['17 123830561521']}, {'input': '995\r\n', 'output': ['12 995']}, {'input': '114\r\n', 'output': ['11 114']}, {'input': '1000000000000000\r\n', 'output': ['18 999999993541753']}, {'input': '112\r\n', 'output': ['10 106']}]
[{'input': '999998169714888\r\n', 'output': ['18 999998150030846']}, {'input': '415000000238718\r\n', 'output': ['18 414993991790735']}, {'input': '108000000057\r\n', 'output': ['17 107986074062']}, {'input': '990000000000000\r\n', 'output': ['18 989983621692990']}, {'input': '114\r\n', 'output': ['11 114']}]
[{'input': '108000000057\r\n', 'output': ['17 107986074062']}, {'input': '780869426483087\r\n', 'output': ['18 780869407920631']}, {'input': '8\r\n', 'output': ['7 7']}, {'input': '1000000000000000\r\n', 'output': ['18 999999993541753']}, {'input': '114\r\n', 'output': ['11 114']}]
[{'input': '909383000\r\n', 'output': ['16 909381874']}, {'input': '994\r\n', 'output': ['12 941']}, {'input': '567000123\r\n', 'output': ['16 566998782']}, {'input': '999998169714888\r\n', 'output': ['18 999998150030846']}, {'input': '999999999999999\r\n', 'output': ['18 999999993541753']}]
[{'input': '850085504652042\r\n', 'output': ['18 850085504652042']}, {'input': '6\r\n', 'output': ['6 6']}, {'input': '112\r\n', 'output': ['10 106']}, {'input': '999971000299999\r\n', 'output': ['18 999969994441746']}, {'input': '567000123\r\n', 'output': ['16 566998782']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
324
100
100
100
["1 50\n50", "3 100\n50 50 100", "2 50\n50 50"]
The first line contains two integers n, k (1 ≀ n ≀ 50, 1 ≀ k ≀ 5000) β€” the number of people, including Greg, and the boat's weight limit. The next line contains n integers β€” the people's weights. A person's weight is either 50 kilos or 100 kilos. You can consider Greg and his friends indexed in some way.
ebb0323a854e19794c79ab559792a1f7
from collections import deque n, k = [int(i) for i in input().split()] a = [int(i) for i in input().split()] c50 = sum([1 for i in a if i == 50]) c100 = sum([1 for i in a if i == 100]) c = [[0] * 51 for i in range(51)] c[0][0] = 1 c[1][0] = 1 c[1][1] = 1 for x in range(2, 51): for y in range(x + 1): c[x][y] = c[x - 1][y - 1] + c[x - 1][y] d = [[[[0, float('inf')] for l in range(2)] for i in range(c100 + 1)] for j in range(c50 + 1)] # d[i][j][c] ΠΎΡ‚Π²Π΅Ρ‚, ΠΊΠΎΠ³Π΄Π° ΠΌΡ‹ ΠΏΠ΅Ρ€Π΅ΠΏΡ€Π°Π²ΠΈΠ»ΠΈ i ΠΏΠΎ 50 ΠΊΠ³ ΠΈ j ΠΏΠΎ 100 ΠΊΠ³ ΠΈ Π»ΠΎΠ΄ΠΊΠ° Π½Π° Π±Π΅Ρ€Π΅Π³Ρƒ c d[0][0][0][0] = 1 d[0][0][0][1] = 0 q = deque() q.append([0, 0, 0]) while len(q) > 0: i, j, shore = q.popleft() for fifty in range(c50 - i + 1 if shore == 0 else i + 1): for hundreds in range(c100 - j + 1 if shore == 0 else j + 1): if fifty * 50 + hundreds * 100 > k or fifty + hundreds == 0: continue i1 = i + fifty if shore == 0 else i - fifty j1 = j + hundreds if shore == 0 else j - hundreds if d[i1][j1][1 ^ shore][1] > d[i][j][shore][1] + 1: d[i1][j1][1 ^ shore][1] = d[i][j][shore][1] + 1 d[i1][j1][1 ^ shore][0] = 0 q.append((i1, j1, 1 ^ shore)) if d[i1][j1][1 ^ shore][1] < d[i][j][shore][1] + 1: continue koeff = (c[c50 - i][fifty] if shore == 0 else c[i][fifty]) * ( c[c100 - j][hundreds] if shore == 0 else c[j][hundreds]) d[i1][j1][1 ^ shore][0] += d[i][j][shore][0] * koeff d[i1][j1][1 ^ shore][0] %= 10 ** 9 + 7 if d[c50][c100][1][1] == float('inf'): print(-1) print(0) else: print(d[c50][c100][1][1]) print(d[c50][c100][1][0])
["1\n1", "5\n2", "-1\n0"]
Python
NoteIn the first test Greg walks alone and consequently, he needs only one ride across the river.In the second test you should follow the plan: transport two 50 kg. people; transport one 50 kg. person back; transport one 100 kg. person; transport one 50 kg. person back; transport two 50 kg. people. That totals to 5 rides. Depending on which person to choose at step 2, we can get two distinct ways.
In the first line print an integer β€” the minimum number of rides. If transporting everyone to the other bank is impossible, print an integer -1. In the second line print the remainder after dividing the number of ways to transport the people in the minimum number of rides by number 1000000007 (109 + 7). If transporting everyone to the other bank is impossible, print integer 0.
One day Greg and his friends were walking in the forest. Overall there were n people walking, including Greg. Soon he found himself in front of a river. The guys immediately decided to get across the river. Luckily, there was a boat by the river bank, just where the guys were standing. We know that the boat can hold people with the total weight of at most k kilograms.Greg immediately took a piece of paper and listed there the weights of all people in his group (including himself). It turned out that each person weights either 50 or 100 kilograms. Now Greg wants to know what minimum number of times the boat needs to cross the river to transport the whole group to the other bank. The boat needs at least one person to navigate it from one bank to the other. As the boat crosses the river, it can have any non-zero number of passengers as long as their total weight doesn't exceed k.Also Greg is wondering, how many ways there are to transport everybody to the other side in the minimum number of boat rides. Two ways are considered distinct if during some ride they have distinct sets of people on the boat.Help Greg with this problem.
[{"input": "1 50\r\n50\r\n", "output": ["1\r\n1"]}, {"input": "3 100\r\n50 50 100\r\n", "output": ["5\r\n2"]}, {"input": "2 50\r\n50 50\r\n", "output": ["-1\r\n0"]}, {"input": "5 258\r\n100 100 50 50 50\r\n", "output": ["3\r\n72"]}, {"input": "8 191\r\n50 100 50 100 50 100 100 50\r\n", "output": ["11\r\n19318272"]}, {"input": "3 121\r\n100 100 50\r\n", "output": ["-1\r\n0"]}, {"input": "8 271\r\n100 50 100 50 50 50 100 50\r\n", "output": ["5\r\n78090"]}, {"input": "2 233\r\n50 100\r\n", "output": ["1\r\n1"]}, {"input": "2 153\r\n100 50\r\n", "output": ["1\r\n1"]}, {"input": "5 257\r\n50 50 50 50 50\r\n", "output": ["1\r\n1"]}, {"input": "49 290\r\n100 100 100 100 100 100 100 100 50 100 50 100 100 100 50 50 100 50 50 100 100 100 100 100 100 50 100 100 50 100 50 50 100 100 100 50 50 50 50 50 100 100 100 50 100 50 100 50 50\r\n", "output": ["39\r\n99624366"]}, {"input": "29 129\r\n50 50 50 100 100 100 50 100 50 50 50 100 50 100 100 100 50 100 100 100 50 50 50 50 50 50 50 50 50\r\n", "output": ["77\r\n37050209"]}, {"input": "32 121\r\n100 100 100 100 100 50 100 100 50 100 50 100 50 100 50 100 50 50 50 100 100 50 100 100 100 100 50 100 50 100 100 50\r\n", "output": ["101\r\n245361086"]}, {"input": "3 118\r\n100 100 100\r\n", "output": ["-1\r\n0"]}, {"input": "10 4894\r\n100 50 50 50 100 50 50 100 50 100\r\n", "output": ["1\r\n1"]}, {"input": "36 250\r\n50 100 100 50 100 100 100 50 50 100 50 50 50 50 50 50 100 50 100 100 100 100 100 100 100 50 50 100 50 50 100 100 100 100 100 50\r\n", "output": ["27\r\n77447096"]}, {"input": "31 291\r\n50 100 100 50 100 100 100 50 100 100 100 100 50 50 50 100 100 100 50 100 100 50 50 50 50 100 100 50 50 100 100\r\n", "output": ["23\r\n393964729"]}, {"input": "31 161\r\n100 50 50 50 50 100 50 100 50 100 100 50 50 100 100 50 100 50 50 100 50 100 100 50 50 100 50 50 100 50 100\r\n", "output": ["43\r\n670669365"]}, {"input": "5 123\r\n50 100 50 50 50\r\n", "output": ["9\r\n4536"]}, {"input": "43 293\r\n50 50 100 100 50 100 100 50 100 100 50 100 50 100 50 50 50 50 50 100 100 100 50 50 100 50 100 100 100 50 100 100 100 50 50 50 100 50 100 100 50 100 50\r\n", "output": ["31\r\n658920847"]}, {"input": "23 100\r\n50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50\r\n", "output": ["43\r\n689584957"]}, {"input": "41 218\r\n50 50 100 50 100 100 50 100 100 50 50 100 50 50 50 50 100 50 100 50 50 50 100 50 50 50 50 100 100 100 100 100 100 50 100 50 100 100 100 50 50\r\n", "output": ["39\r\n298372053"]}, {"input": "11 4668\r\n50 100 100 100 50 100 50 50 100 100 100\r\n", "output": ["1\r\n1"]}, {"input": "43 178\r\n50 50 100 100 100 50 100 100 50 100 100 100 50 100 50 100 50 50 100 100 50 100 100 50 50 50 100 50 50 50 100 50 100 100 100 50 100 50 50 50 50 100 100\r\n", "output": ["63\r\n503334985"]}, {"input": "33 226\r\n50 50 50 50 50 100 100 100 100 50 100 50 100 50 100 50 100 100 50 50 50 100 100 50 50 100 50 100 50 100 50 50 50\r\n", "output": ["31\r\n370884215"]}, {"input": "1 2994\r\n100\r\n", "output": ["1\r\n1"]}, {"input": "1 204\r\n50\r\n", "output": ["1\r\n1"]}, {"input": "33 123\r\n50 100 100 100 50 100 50 50 50 50 50 100 100 50 100 50 100 50 50 50 50 50 50 50 100 100 50 50 100 100 100 100 100\r\n", "output": ["93\r\n337243149"]}, {"input": "34 2964\r\n50 50 50 50 50 100 50 100 50 100 100 50 50 50 50 50 50 100 100 100 50 50 100 100 50 50 50 100 50 100 100 50 100 50\r\n", "output": ["1\r\n1"]}, {"input": "27 200\r\n50 50 50 50 100 100 50 50 100 100 100 50 100 50 100 50 50 100 100 100 50 100 100 50 50 50 100\r\n", "output": ["25\r\n271877303"]}, {"input": "31 197\r\n50 100 50 50 100 50 100 100 100 50 50 100 50 100 50 50 50 50 100 100 50 50 100 50 50 50 50 50 100 50 100\r\n", "output": ["41\r\n24368657"]}, {"input": "28 183\r\n50 100 100 50 100 50 100 100 50 100 50 100 100 100 50 50 100 50 50 50 100 50 100 50 50 100 100 100\r\n", "output": ["41\r\n844409785"]}, {"input": "48 204\r\n100 100 100 50 50 50 50 100 100 50 100 100 50 100 50 50 50 100 100 100 50 100 50 50 50 100 50 100 50 100 100 100 50 50 100 100 100 50 100 50 50 50 50 50 100 50 50 50\r\n", "output": ["45\r\n538567333"]}, {"input": "5 188\r\n50 50 50 50 50\r\n", "output": ["3\r\n30"]}, {"input": "29 108\r\n100 50 100 100 100 100 100 50 50 100 100 100 50 100 50 50 100 50 100 50 50 100 100 50 50 50 100 100 50\r\n", "output": ["87\r\n417423429"]}, {"input": "50 125\r\n50 50 50 100 100 50 100 100 50 50 100 100 100 100 100 100 50 50 100 50 100 100 50 50 50 100 100 50 100 100 100 100 100 100 100 50 50 50 100 50 50 50 50 100 100 100 100 100 50 50\r\n", "output": ["153\r\n971933773"]}, {"input": "50 2263\r\n50 100 50 100 50 100 100 100 50 50 50 100 100 100 100 100 100 50 50 100 50 100 50 50 100 50 50 100 100 50 100 100 100 50 50 50 100 50 100 50 50 50 50 50 100 100 50 50 100 50\r\n", "output": ["3\r\n211048352"]}, {"input": "50 110\r\n50 100 100 50 50 50 50 50 50 50 100 100 50 100 50 50 50 50 100 50 100 100 100 100 50 100 100 100 100 50 50 50 50 50 100 100 50 100 50 100 100 50 50 100 50 100 50 50 100 100\r\n", "output": ["143\r\n105841088"]}, {"input": "50 185\r\n100 50 50 50 50 50 100 50 100 50 100 100 50 50 100 100 100 50 50 100 50 100 50 50 100 100 100 100 100 50 50 100 100 100 50 100 50 100 50 50 100 50 100 50 50 100 50 50 100 100\r\n", "output": ["73\r\n930170107"]}, {"input": "50 207\r\n50 100 100 100 100 50 100 100 100 50 100 100 100 50 100 100 50 100 50 100 50 100 100 100 50 100 50 50 100 50 100 100 50 100 100 100 100 50 100 100 100 100 50 50 50 100 100 50 100 100\r\n", "output": ["55\r\n833060250"]}, {"input": "3 49\r\n50 50 50\r\n", "output": ["-1\r\n0"]}, {"input": "3 50\r\n50 50 50\r\n", "output": ["-1\r\n0"]}, {"input": "3 99\r\n100 50 50\r\n", "output": ["-1\r\n0"]}, {"input": "4 100\r\n100 100 100 50\r\n", "output": ["-1\r\n0"]}]
100
100
100
[{'input': '49 290\r\n100 100 100 100 100 100 100 100 50 100 50 100 100 100 50 50 100 50 50 100 100 100 100 100 100 50 100 100 50 100 50 50 100 100 100 50 50 50 50 50 100 100 100 50 100 50 100 50 50\r\n', 'output': ['39\r\n99624366']}, {'input': '11 4668\r\n50 100 100 100 50 100 50 50 100 100 100\r\n', 'output': ['1\r\n1']}, {'input': '36 250\r\n50 100 100 50 100 100 100 50 50 100 50 50 50 50 50 50 100 50 100 100 100 100 100 100 100 50 50 100 50 50 100 100 100 100 100 50\r\n', 'output': ['27\r\n77447096']}, {'input': '31 161\r\n100 50 50 50 50 100 50 100 50 100 100 50 50 100 100 50 100 50 50 100 50 100 100 50 50 100 50 50 100 50 100\r\n', 'output': ['43\r\n670669365']}, {'input': '50 185\r\n100 50 50 50 50 50 100 50 100 50 100 100 50 50 100 100 100 50 50 100 50 100 50 50 100 100 100 100 100 50 50 100 100 100 50 100 50 100 50 50 100 50 100 50 50 100 50 50 100 100\r\n', 'output': ['73\r\n930170107']}]
[{'input': '50 207\r\n50 100 100 100 100 50 100 100 100 50 100 100 100 50 100 100 50 100 50 100 50 100 100 100 50 100 50 50 100 50 100 100 50 100 100 100 100 50 100 100 100 100 50 50 50 100 100 50 100 100\r\n', 'output': ['55\r\n833060250']}, {'input': '3 121\r\n100 100 50\r\n', 'output': ['-1\r\n0']}, {'input': '31 161\r\n100 50 50 50 50 100 50 100 50 100 100 50 50 100 100 50 100 50 50 100 50 100 100 50 50 100 50 50 100 50 100\r\n', 'output': ['43\r\n670669365']}, {'input': '10 4894\r\n100 50 50 50 100 50 50 100 50 100\r\n', 'output': ['1\r\n1']}, {'input': '11 4668\r\n50 100 100 100 50 100 50 50 100 100 100\r\n', 'output': ['1\r\n1']}]
[{'input': '50 2263\r\n50 100 50 100 50 100 100 100 50 50 50 100 100 100 100 100 100 50 50 100 50 100 50 50 100 50 50 100 100 50 100 100 100 50 50 50 100 50 100 50 50 50 50 50 100 100 50 50 100 50\r\n', 'output': ['3\r\n211048352']}, {'input': '5 123\r\n50 100 50 50 50\r\n', 'output': ['9\r\n4536']}, {'input': '8 271\r\n100 50 100 50 50 50 100 50\r\n', 'output': ['5\r\n78090']}, {'input': '27 200\r\n50 50 50 50 100 100 50 50 100 100 100 50 100 50 100 50 50 100 100 100 50 100 100 50 50 50 100\r\n', 'output': ['25\r\n271877303']}, {'input': '41 218\r\n50 50 100 50 100 100 50 100 100 50 50 100 50 50 50 50 100 50 100 50 50 50 100 50 50 50 50 100 100 100 100 100 100 50 100 50 100 100 100 50 50\r\n', 'output': ['39\r\n298372053']}]
[{'input': '29 129\r\n50 50 50 100 100 100 50 100 50 50 50 100 50 100 100 100 50 100 100 100 50 50 50 50 50 50 50 50 50\r\n', 'output': ['77\r\n37050209']}, {'input': '31 161\r\n100 50 50 50 50 100 50 100 50 100 100 50 50 100 100 50 100 50 50 100 50 100 100 50 50 100 50 50 100 50 100\r\n', 'output': ['43\r\n670669365']}, {'input': '33 226\r\n50 50 50 50 50 100 100 100 100 50 100 50 100 50 100 50 100 100 50 50 50 100 100 50 50 100 50 100 50 100 50 50 50\r\n', 'output': ['31\r\n370884215']}, {'input': '50 185\r\n100 50 50 50 50 50 100 50 100 50 100 100 50 50 100 100 100 50 50 100 50 100 50 50 100 100 100 100 100 50 50 100 100 100 50 100 50 100 50 50 100 50 100 50 50 100 50 50 100 100\r\n', 'output': ['73\r\n930170107']}, {'input': '27 200\r\n50 50 50 50 100 100 50 50 100 100 100 50 100 50 100 50 50 100 100 100 50 100 100 50 50 50 100\r\n', 'output': ['25\r\n271877303']}]
[{'input': '43 178\r\n50 50 100 100 100 50 100 100 50 100 100 100 50 100 50 100 50 50 100 100 50 100 100 50 50 50 100 50 50 50 100 50 100 100 100 50 100 50 50 50 50 100 100\r\n', 'output': ['63\r\n503334985']}, {'input': '3 121\r\n100 100 50\r\n', 'output': ['-1\r\n0']}, {'input': '34 2964\r\n50 50 50 50 50 100 50 100 50 100 100 50 50 50 50 50 50 100 100 100 50 50 100 100 50 50 50 100 50 100 100 50 100 50\r\n', 'output': ['1\r\n1']}, {'input': '3 99\r\n100 50 50\r\n', 'output': ['-1\r\n0']}, {'input': '50 125\r\n50 50 50 100 100 50 100 100 50 50 100 100 100 100 100 100 50 50 100 50 100 100 50 50 50 100 100 50 100 100 100 100 100 100 100 50 50 50 100 50 50 50 50 100 100 100 100 100 50 50\r\n', 'output': ['153\r\n971933773']}]
100
100
100
100
100
94.87
100
94.87
94.87
100
96.67
100
96.67
96.67
100
325
100
96.922
98.002
["1 2 1 2", "1 12 1 12", "50 100 3 30"]
The only line contains four integers l, r, x, y (1 ≀ l ≀ r ≀ 109, 1 ≀ x ≀ y ≀ 109).
d37dde5841116352c9b37538631d0b15
import math def gcd(a, b): while b != 0: a, b = b, a % b return a def lcm(a, b): return a * b // (gcd(a, b)) def f(d): d = str(d) if d[len(d) - 2:] == '.0': return True return False l, r, x, y = [int(i) for i in input().split()] count = 0 for c in range(1, int(math.sqrt(y / x)) + 1): d = (y / x) / c if f(d): if l <= c * x and r >= d * x and gcd(c * x, d * x) == x and lcm(c * x, d * x) == y: if c != d: count += 2 else: count += 1 print(count)
["2", "4", "0"]
Python
NoteIn the first example there are two suitable good pairs of integers (a, b): (1, 2) and (2, 1).In the second example there are four suitable good pairs of integers (a, b): (1, 12), (12, 1), (3, 4) and (4, 3).In the third example there are good pairs of integers, for example, (3, 30), but none of them fits the condition l ≀ a, b ≀ r.
In the only line print the only integerΒ β€” the answer for the problem.
Today on Informatics class Nastya learned about GCD and LCM (see links below). Nastya is very intelligent, so she solved all the tasks momentarily and now suggests you to solve one of them as well.We define a pair of integers (a, b) good, if GCD(a, b) = x and LCM(a, b) = y, where GCD(a, b) denotes the greatest common divisor of a and b, and LCM(a, b) denotes the least common multiple of a and b.You are given two integers x and y. You are to find the number of good pairs of integers (a, b) such that l ≀ a, b ≀ r. Note that pairs (a, b) and (b, a) are considered different if a ≠ b.
[{"input": "1 2 1 2\r\n", "output": ["2"]}, {"input": "1 12 1 12\r\n", "output": ["4"]}, {"input": "50 100 3 30\r\n", "output": ["0"]}, {"input": "1 1000000000 1 1000000000\r\n", "output": ["4"]}, {"input": "1 1000000000 158260522 200224287\r\n", "output": ["0"]}, {"input": "1 1000000000 2 755829150\r\n", "output": ["8"]}, {"input": "1 1000000000 158260522 158260522\r\n", "output": ["1"]}, {"input": "1 1000000000 877914575 877914575\r\n", "output": ["1"]}, {"input": "232 380232688 116 760465376\r\n", "output": ["30"]}, {"input": "47259 3393570 267 600661890\r\n", "output": ["30"]}, {"input": "1 1000000000 1 672672000\r\n", "output": ["64"]}, {"input": "1000000000 1000000000 1000000000 1000000000\r\n", "output": ["1"]}, {"input": "1 1000000000 1 649209600\r\n", "output": ["32"]}, {"input": "1 1000000000 1 682290000\r\n", "output": ["32"]}, {"input": "1 1000000000 1 228614400\r\n", "output": ["16"]}, {"input": "1 1000000000 1 800280000\r\n", "output": ["32"]}, {"input": "1 1000000000 1 919987200\r\n", "output": ["16"]}, {"input": "1 1000000000 1 456537870\r\n", "output": ["64"]}, {"input": "1 1000000000 1 7198102\r\n", "output": ["8"]}, {"input": "1 1000000000 1 58986263\r\n", "output": ["16"]}, {"input": "1 1000000000 1 316465536\r\n", "output": ["16"]}, {"input": "1 1000000000 1 9558312\r\n", "output": ["16"]}, {"input": "1 1000000000 1 5461344\r\n", "output": ["16"]}, {"input": "58 308939059 29 617878118\r\n", "output": ["62"]}, {"input": "837 16262937 27 504151047\r\n", "output": ["28"]}, {"input": "47275 402550 25 761222050\r\n", "output": ["12"]}, {"input": "22 944623394 22 944623394\r\n", "output": ["32"]}, {"input": "1032 8756124 12 753026664\r\n", "output": ["18"]}, {"input": "7238 939389 11 618117962\r\n", "output": ["10"]}, {"input": "58351 322621 23 818489477\r\n", "output": ["6"]}, {"input": "3450 7068875 25 975504750\r\n", "output": ["86"]}, {"input": "13266 1606792 22 968895576\r\n", "output": ["14"]}, {"input": "21930 632925 15 925336350\r\n", "output": ["42"]}, {"input": "2193 4224517 17 544962693\r\n", "output": ["42"]}, {"input": "526792 39807152 22904 915564496\r\n", "output": ["8"]}, {"input": "67728 122875524 16932 491502096\r\n", "output": ["12"]}, {"input": "319813 63298373 24601 822878849\r\n", "output": ["6"]}, {"input": "572464 23409136 15472 866138032\r\n", "output": ["4"]}, {"input": "39443 809059020 19716 777638472\r\n", "output": ["12"]}, {"input": "2544768 8906688 27072 837228672\r\n", "output": ["0"]}, {"input": "413592 46975344 21768 892531536\r\n", "output": ["10"]}, {"input": "11349 816231429 11349 816231429\r\n", "output": ["8"]}, {"input": "16578 939956022 16578 939956022\r\n", "output": ["4"]}, {"input": "2783175 6882425 21575 887832825\r\n", "output": ["2"]}, {"input": "2862252 7077972 22188 913058388\r\n", "output": ["2"]}, {"input": "1856828 13124976 25436 958123248\r\n", "output": ["6"]}, {"input": "100 1000000000 158260522 158260522\r\n", "output": ["1"]}, {"input": "100 1000000000 877914575 877914575\r\n", "output": ["1"]}, {"input": "100 1000000000 602436426 602436426\r\n", "output": ["1"]}, {"input": "100 1000000000 24979445 24979445\r\n", "output": ["1"]}, {"input": "1 1000000000 18470 112519240\r\n", "output": ["4"]}, {"input": "1 1000000000 22692 2201124\r\n", "output": ["2"]}, {"input": "1 1000000000 24190 400949250\r\n", "output": ["16"]}, {"input": "1 1000000000 33409 694005157\r\n", "output": ["2"]}, {"input": "1 1000000000 24967 470827686\r\n", "output": ["16"]}, {"input": "1 1000000000 35461 152517761\r\n", "output": ["8"]}, {"input": "2 1000000000 158260522 200224287\r\n", "output": ["0"]}, {"input": "2 1000000000 602436426 611751520\r\n", "output": ["0"]}, {"input": "2 1000000000 861648772 942726551\r\n", "output": ["0"]}, {"input": "2 1000000000 433933447 485982495\r\n", "output": ["0"]}, {"input": "2 1000000000 262703497 480832794\r\n", "output": ["0"]}, {"input": "2672374 422235092 1336187 844470184\r\n", "output": ["2"]}, {"input": "1321815 935845020 1321815 935845020\r\n", "output": ["8"]}, {"input": "29259607 69772909 2250739 907047817\r\n", "output": ["2"]}, {"input": "11678540 172842392 2335708 864211960\r\n", "output": ["4"]}, {"input": "297 173688298 2876112 851329152\r\n", "output": ["2"]}, {"input": "7249 55497026 659 610467286\r\n", "output": ["28"]}, {"input": "398520 1481490 810 728893080\r\n", "output": ["4"]}, {"input": "2354 369467362 1177 738934724\r\n", "output": ["14"]}, {"input": "407264 2497352 1144 889057312\r\n", "output": ["2"]}, {"input": "321399 1651014 603 879990462\r\n", "output": ["4"]}, {"input": "475640 486640 440 526057840\r\n", "output": ["2"]}, {"input": "631714 179724831 1136 717625968\r\n", "output": ["0"]}, {"input": "280476 1595832 588 761211864\r\n", "output": ["8"]}, {"input": "10455 39598005 615 673166085\r\n", "output": ["6"]}, {"input": "24725 19759875 575 849674625\r\n", "output": ["22"]}, {"input": "22 158 2 1738\r\n", "output": ["2"]}, {"input": "1 2623 1 2623\r\n", "output": ["4"]}, {"input": "7 163677675 3 18\r\n", "output": ["0"]}, {"input": "159 20749927 1 158\r\n", "output": ["0"]}, {"input": "5252 477594071 1 5251\r\n", "output": ["0"]}, {"input": "2202 449433679 3 6603\r\n", "output": ["0"]}, {"input": "6 111 3 222\r\n", "output": ["2"]}, {"input": "26 46 2 598\r\n", "output": ["2"]}, {"input": "26 82 2 1066\r\n", "output": ["2"]}, {"input": "1 2993 1 2993\r\n", "output": ["4"]}, {"input": "17 17 1 289\r\n", "output": ["0"]}, {"input": "177 267 3 15753\r\n", "output": ["2"]}, {"input": "7388 22705183 1 7387\r\n", "output": ["0"]}, {"input": "1 100 3 100\r\n", "output": ["0"]}, {"input": "1 1000 6 1024\r\n", "output": ["0"]}, {"input": "1 100 2 4\r\n", "output": ["2"]}, {"input": "1 10000 2 455\r\n", "output": ["0"]}, {"input": "1 1000000000 250000000 1000000000\r\n", "output": ["2"]}, {"input": "3 3 1 1\r\n", "output": ["0"]}, {"input": "1 1000000000 100000000 1000000000\r\n", "output": ["4"]}, {"input": "5 10 3 3\r\n", "output": ["0"]}, {"input": "1 1000 5 13\r\n", "output": ["0"]}, {"input": "2 2 3 3\r\n", "output": ["0"]}, {"input": "1 1000000000 499999993 999999986\r\n", "output": ["2"]}, {"input": "1 1 1 10\r\n", "output": ["0"]}, {"input": "1 10 10 100\r\n", "output": ["0"]}, {"input": "1 1000 4 36\r\n", "output": ["2"]}, {"input": "1 1000000000 10000000 20000000\r\n", "output": ["2"]}, {"input": "100 100 5 5\r\n", "output": ["0"]}, {"input": "3 3 3 9\r\n", "output": ["0"]}, {"input": "36 200 24 144\r\n", "output": ["2"]}, {"input": "1 100 3 10\r\n", "output": ["0"]}]
100
100
100
[{'input': '1 1000000000 24967 470827686\r\n', 'output': ['16']}, {'input': '29259607 69772909 2250739 907047817\r\n', 'output': ['2']}, {'input': '100 1000000000 877914575 877914575\r\n', 'output': ['1']}, {'input': '6 111 3 222\r\n', 'output': ['2']}, {'input': '5 10 3 3\r\n', 'output': ['0']}]
[{'input': '1 2993 1 2993\r\n', 'output': ['4']}, {'input': '1 1000000000 100000000 1000000000\r\n', 'output': ['4']}, {'input': '1 100 2 4\r\n', 'output': ['2']}, {'input': '3 3 3 9\r\n', 'output': ['0']}, {'input': '2672374 422235092 1336187 844470184\r\n', 'output': ['2']}]
[{'input': '29259607 69772909 2250739 907047817\r\n', 'output': ['2']}, {'input': '1 1000000000 33409 694005157\r\n', 'output': ['2']}, {'input': '1 1000000000 24190 400949250\r\n', 'output': ['16']}, {'input': '1032 8756124 12 753026664\r\n', 'output': ['18']}, {'input': '5 10 3 3\r\n', 'output': ['0']}]
[{'input': '13266 1606792 22 968895576\r\n', 'output': ['14']}, {'input': '6 111 3 222\r\n', 'output': ['2']}, {'input': '1 2993 1 2993\r\n', 'output': ['4']}, {'input': '47259 3393570 267 600661890\r\n', 'output': ['30']}, {'input': '26 82 2 1066\r\n', 'output': ['2']}]
[{'input': '2672374 422235092 1336187 844470184\r\n', 'output': ['2']}, {'input': '1 1000000000 1 7198102\r\n', 'output': ['8']}, {'input': '1 10000 2 455\r\n', 'output': ['0']}, {'input': '1 1000000000 499999993 999999986\r\n', 'output': ['2']}, {'input': '398520 1481490 810 728893080\r\n', 'output': ['4']}]
100
100
100
100
100
100
95.45
95.45
95.45
95.45
100
92.86
92.86
92.86
92.86
326
100
96.36
94.288
["5 2 2", "5 4 7", "6 2 3"]
The single line contains three integers T, S, q (2 ≀ q ≀ 104, 1 ≀ S &lt; T ≀ 105).
0d01bf286fb2c7950ce5d5fa59a17dd9
t,s,q=map(int,input().split()) res=0 while s<t:s*=q;res+=1 print(res)
["2", "1", "1"]
Python
NoteIn the first test, the song is played twice faster than it is downloaded, which means that during four first seconds Lesha reaches the moment that has not been downloaded, and starts the song again. After another two seconds, the song is downloaded completely, and thus, Lesha starts the song twice.In the second test, the song is almost downloaded, and Lesha will start it only once.In the third sample test the download finishes and Lesha finishes listening at the same moment. Note that song isn't restarted in this case.
Print a single integerΒ β€” the number of times the song will be restarted.
Little Lesha loves listening to music via his smartphone. But the smartphone doesn't have much memory, so Lesha listens to his favorite songs in a well-known social network InTalk.Unfortunately, internet is not that fast in the city of Ekaterinozavodsk and the song takes a lot of time to download. But Lesha is quite impatient. The song's duration is T seconds. Lesha downloads the first S seconds of the song and plays it. When the playback reaches the point that has not yet been downloaded, Lesha immediately plays the song from the start (the loaded part of the song stays in his phone, and the download is continued from the same place), and it happens until the song is downloaded completely and Lesha listens to it to the end. For q seconds of real time the Internet allows you to download q - 1 seconds of the track.Tell Lesha, for how many times he will start the song, including the very first start.
[{"input": "5 2 2\r\n", "output": ["2"]}, {"input": "5 4 7\r\n", "output": ["1"]}, {"input": "6 2 3\r\n", "output": ["1"]}, {"input": "2 1 2\r\n", "output": ["1"]}, {"input": "2 1 3\r\n", "output": ["1"]}, {"input": "2 1 10000\r\n", "output": ["1"]}, {"input": "12326 6163 2\r\n", "output": ["1"]}, {"input": "10000 2500 4\r\n", "output": ["1"]}, {"input": "100000 99999 4\r\n", "output": ["1"]}, {"input": "12351 1223 6\r\n", "output": ["2"]}, {"input": "100000 1 10000\r\n", "output": ["2"]}, {"input": "10028 13 10000\r\n", "output": ["1"]}, {"input": "100000 99999 2\r\n", "output": ["1"]}, {"input": "100000 99999 3\r\n", "output": ["1"]}, {"input": "100000 1 2\r\n", "output": ["17"]}, {"input": "100000 1 3\r\n", "output": ["11"]}, {"input": "100000 1 4\r\n", "output": ["9"]}, {"input": "100000 1 5\r\n", "output": ["8"]}, {"input": "100000 3125 2\r\n", "output": ["5"]}, {"input": "12628 1804 7\r\n", "output": ["1"]}, {"input": "100000 45 13\r\n", "output": ["4"]}, {"input": "100000 500 3\r\n", "output": ["5"]}, {"input": "356 2 3\r\n", "output": ["5"]}, {"input": "50 2 2\r\n", "output": ["5"]}, {"input": "65465 12 3\r\n", "output": ["8"]}, {"input": "10033 3 8\r\n", "output": ["4"]}, {"input": "100000 3 2\r\n", "output": ["16"]}, {"input": "64 1 8\r\n", "output": ["2"]}, {"input": "10000 9 2\r\n", "output": ["11"]}, {"input": "25 2 2\r\n", "output": ["4"]}, {"input": "129 2 2\r\n", "output": ["7"]}, {"input": "6562 1 3\r\n", "output": ["9"]}, {"input": "100000 1 10\r\n", "output": ["5"]}]
100
100
100
[{'input': '100000 1 5\r\n', 'output': ['8']}, {'input': '25 2 2\r\n', 'output': ['4']}, {'input': '10033 3 8\r\n', 'output': ['4']}, {'input': '100000 1 10\r\n', 'output': ['5']}, {'input': '356 2 3\r\n', 'output': ['5']}]
[{'input': '2 1 10000\r\n', 'output': ['1']}, {'input': '64 1 8\r\n', 'output': ['2']}, {'input': '10000 2500 4\r\n', 'output': ['1']}, {'input': '2 1 3\r\n', 'output': ['1']}, {'input': '100000 1 5\r\n', 'output': ['8']}]
[{'input': '50 2 2\r\n', 'output': ['5']}, {'input': '65465 12 3\r\n', 'output': ['8']}, {'input': '10000 9 2\r\n', 'output': ['11']}, {'input': '100000 1 10000\r\n', 'output': ['2']}, {'input': '5 4 7\r\n', 'output': ['1']}]
[{'input': '5 4 7\r\n', 'output': ['1']}, {'input': '5 2 2\r\n', 'output': ['2']}, {'input': '100000 99999 4\r\n', 'output': ['1']}, {'input': '356 2 3\r\n', 'output': ['5']}, {'input': '2 1 2\r\n', 'output': ['1']}]
[{'input': '6562 1 3\r\n', 'output': ['9']}, {'input': '2 1 10000\r\n', 'output': ['1']}, {'input': '12628 1804 7\r\n', 'output': ['1']}, {'input': '100000 99999 3\r\n', 'output': ['1']}, {'input': '25 2 2\r\n', 'output': ['4']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
327
100
100
100
["3\n2014 2016 2015", "1\n2050"]
The first line contains the positive odd integer n (1 ≀ n ≀ 5) β€” the number of groups which Igor joined. The next line contains n distinct integers a1, a2, ..., an (2010 ≀ ai ≀ 2100) β€” years of student's university entrance for each group in which Igor is the member. It is guaranteed that the input data is correct and the answer always exists. Groups are given randomly.
f03773118cca29ff8d5b4281d39e7c63
count = int(input()) sum = 0 years = input().split(' ') for y in years: sum += int(y) print(int(sum/count))
["2015", "2050"]
Python
NoteIn the first test the value x = 1. Igor entered the university in 2015. So he joined groups members of which are students who entered the university in 2014, 2015 and 2016.In the second test the value x = 0. Igor entered only the group which corresponds to the year of his university entrance.
Print the year of Igor's university entrance.
There is the faculty of Computer Science in Berland. In the social net "TheContact!" for each course of this faculty there is the special group whose name equals the year of university entrance of corresponding course of students at the university. Each of students joins the group of his course and joins all groups for which the year of student's university entrance differs by no more than x from the year of university entrance of this student, where x β€” some non-negative integer. A value x is not given, but it can be uniquely determined from the available data. Note that students don't join other groups. You are given the list of groups which the student Igor joined. According to this information you need to determine the year of Igor's university entrance.
[{"input": "3\r\n2014 2016 2015\r\n", "output": ["2015"]}, {"input": "1\r\n2050\r\n", "output": ["2050"]}, {"input": "1\r\n2010\r\n", "output": ["2010"]}, {"input": "1\r\n2011\r\n", "output": ["2011"]}, {"input": "3\r\n2010 2011 2012\r\n", "output": ["2011"]}, {"input": "3\r\n2049 2047 2048\r\n", "output": ["2048"]}, {"input": "5\r\n2043 2042 2041 2044 2040\r\n", "output": ["2042"]}, {"input": "5\r\n2012 2013 2014 2015 2016\r\n", "output": ["2014"]}, {"input": "1\r\n2045\r\n", "output": ["2045"]}, {"input": "1\r\n2046\r\n", "output": ["2046"]}, {"input": "1\r\n2099\r\n", "output": ["2099"]}, {"input": "1\r\n2100\r\n", "output": ["2100"]}, {"input": "3\r\n2011 2010 2012\r\n", "output": ["2011"]}, {"input": "3\r\n2011 2012 2010\r\n", "output": ["2011"]}, {"input": "3\r\n2012 2011 2010\r\n", "output": ["2011"]}, {"input": "3\r\n2010 2012 2011\r\n", "output": ["2011"]}, {"input": "3\r\n2012 2010 2011\r\n", "output": ["2011"]}, {"input": "3\r\n2047 2048 2049\r\n", "output": ["2048"]}, {"input": "3\r\n2047 2049 2048\r\n", "output": ["2048"]}, {"input": "3\r\n2048 2047 2049\r\n", "output": ["2048"]}, {"input": "3\r\n2048 2049 2047\r\n", "output": ["2048"]}, {"input": "3\r\n2049 2048 2047\r\n", "output": ["2048"]}, {"input": "5\r\n2011 2014 2012 2013 2010\r\n", "output": ["2012"]}, {"input": "5\r\n2014 2013 2011 2012 2015\r\n", "output": ["2013"]}, {"input": "5\r\n2021 2023 2024 2020 2022\r\n", "output": ["2022"]}, {"input": "5\r\n2081 2079 2078 2080 2077\r\n", "output": ["2079"]}, {"input": "5\r\n2095 2099 2097 2096 2098\r\n", "output": ["2097"]}, {"input": "5\r\n2097 2099 2100 2098 2096\r\n", "output": ["2098"]}, {"input": "5\r\n2012 2010 2014 2011 2013\r\n", "output": ["2012"]}, {"input": "5\r\n2012 2011 2013 2015 2014\r\n", "output": ["2013"]}, {"input": "5\r\n2023 2024 2022 2021 2020\r\n", "output": ["2022"]}, {"input": "5\r\n2077 2078 2080 2079 2081\r\n", "output": ["2079"]}, {"input": "5\r\n2099 2096 2095 2097 2098\r\n", "output": ["2097"]}, {"input": "5\r\n2097 2100 2098 2096 2099\r\n", "output": ["2098"]}, {"input": "5\r\n2011 2014 2013 2010 2012\r\n", "output": ["2012"]}, {"input": "5\r\n2013 2011 2015 2012 2014\r\n", "output": ["2013"]}, {"input": "5\r\n2024 2020 2021 2023 2022\r\n", "output": ["2022"]}, {"input": "5\r\n2079 2080 2077 2081 2078\r\n", "output": ["2079"]}, {"input": "5\r\n2095 2097 2096 2098 2099\r\n", "output": ["2097"]}, {"input": "5\r\n2099 2096 2100 2097 2098\r\n", "output": ["2098"]}, {"input": "5\r\n2034 2033 2036 2032 2035\r\n", "output": ["2034"]}, {"input": "5\r\n2030 2031 2033 2032 2029\r\n", "output": ["2031"]}, {"input": "5\r\n2093 2092 2094 2096 2095\r\n", "output": ["2094"]}, {"input": "5\r\n2012 2015 2014 2013 2011\r\n", "output": ["2013"]}, {"input": "5\r\n2056 2057 2058 2059 2060\r\n", "output": ["2058"]}]
100
100
100
[{'input': '1\r\n2099\r\n', 'output': ['2099']}, {'input': '5\r\n2077 2078 2080 2079 2081\r\n', 'output': ['2079']}, {'input': '3\r\n2012 2011 2010\r\n', 'output': ['2011']}, {'input': '5\r\n2099 2096 2095 2097 2098\r\n', 'output': ['2097']}, {'input': '1\r\n2045\r\n', 'output': ['2045']}]
[{'input': '5\r\n2081 2079 2078 2080 2077\r\n', 'output': ['2079']}, {'input': '1\r\n2045\r\n', 'output': ['2045']}, {'input': '3\r\n2047 2048 2049\r\n', 'output': ['2048']}, {'input': '5\r\n2012 2013 2014 2015 2016\r\n', 'output': ['2014']}, {'input': '5\r\n2024 2020 2021 2023 2022\r\n', 'output': ['2022']}]
[{'input': '3\r\n2049 2047 2048\r\n', 'output': ['2048']}, {'input': '1\r\n2100\r\n', 'output': ['2100']}, {'input': '5\r\n2056 2057 2058 2059 2060\r\n', 'output': ['2058']}, {'input': '3\r\n2049 2048 2047\r\n', 'output': ['2048']}, {'input': '5\r\n2011 2014 2013 2010 2012\r\n', 'output': ['2012']}]
[{'input': '5\r\n2030 2031 2033 2032 2029\r\n', 'output': ['2031']}, {'input': '3\r\n2048 2049 2047\r\n', 'output': ['2048']}, {'input': '5\r\n2079 2080 2077 2081 2078\r\n', 'output': ['2079']}, {'input': '5\r\n2097 2099 2100 2098 2096\r\n', 'output': ['2098']}, {'input': '3\r\n2010 2012 2011\r\n', 'output': ['2011']}]
[{'input': '5\r\n2024 2020 2021 2023 2022\r\n', 'output': ['2022']}, {'input': '3\r\n2049 2047 2048\r\n', 'output': ['2048']}, {'input': '5\r\n2043 2042 2041 2044 2040\r\n', 'output': ['2042']}, {'input': '5\r\n2093 2092 2094 2096 2095\r\n', 'output': ['2094']}, {'input': '1\r\n2011\r\n', 'output': ['2011']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
328
100
100
100
["........\n........\n.B....B.\n....W...\n........\n..W.....\n........\n........", "..B.....\n..W.....\n......B.\n........\n.....W..\n......B.\n........\n........"]
The input consists of the board description given in eight lines, each line contains eight characters. Character 'B' is used to denote a black pawn, and character 'W' represents a white pawn. Empty cell is marked with '.'. It's guaranteed that there will not be white pawns on the first row neither black pawns on the last row.
0ddc839e17dee20e1a954c1289de7fbd
a = [input() for i in range(8)] ra, rb = 8, 8 for j in range(8) : for i in range(8) : if a[i][j] == 'W' : ra = min(ra, i) if a[i][j] != '.' : break for j in range(8) : for i in range(7,-1,-1) : if a[i][j] == 'B' : rb = min(rb, 7 - i) if a[i][j] != '.' : break print ('A' if ra <= rb else 'B')
["A", "B"]
Python
NoteIn the first sample player A is able to complete his goal in 3 steps by always moving a pawn initially located at (4, 5). Player B needs at least 5 steps for any of his pawns to reach the row 8. Hence, player A will be the winner.
Print 'A' if player A wins the game on the given board, and 'B' if player B will claim the victory. Again, it's guaranteed that there will always be a winner on the given board.
Galois is one of the strongest chess players of Byteforces. He has even invented a new variant of chess, which he named Β«PawnChessΒ».This new game is played on a board consisting of 8 rows and 8 columns. At the beginning of every game some black and white pawns are placed on the board. The number of black pawns placed is not necessarily equal to the number of white pawns placed. Lets enumerate rows and columns with integers from 1 to 8. Rows are numbered from top to bottom, while columns are numbered from left to right. Now we denote as (r, c) the cell located at the row r and at the column c.There are always two players A and B playing the game. Player A plays with white pawns, while player B plays with black ones. The goal of player A is to put any of his pawns to the row 1, while player B tries to put any of his pawns to the row 8. As soon as any of the players completes his goal the game finishes immediately and the succeeded player is declared a winner.Player A moves first and then they alternate turns. On his move player A must choose exactly one white pawn and move it one step upward and player B (at his turn) must choose exactly one black pawn and move it one step down. Any move is possible only if the targeted cell is empty. It's guaranteed that for any scenario of the game there will always be at least one move available for any of the players.Moving upward means that the pawn located in (r, c) will go to the cell (r - 1, c), while moving down means the pawn located in (r, c) will go to the cell (r + 1, c). Again, the corresponding cell must be empty, i.e. not occupied by any other pawn of any color.Given the initial disposition of the board, determine who wins the game if both players play optimally. Note that there will always be a winner due to the restriction that for any game scenario both players will have some moves available.
[{"input": "........\r\n........\r\n.B....B.\r\n....W...\r\n........\r\n..W.....\r\n........\r\n........\r\n", "output": ["A"]}, {"input": "..B.....\r\n..W.....\r\n......B.\r\n........\r\n.....W..\r\n......B.\r\n........\r\n........\r\n", "output": ["B"]}, {"input": ".BB.B.B.\r\nB..B..B.\r\n.B.BB...\r\nBB.....B\r\nBBB....B\r\nB..BB...\r\nBB.B...B\r\n....WWW.\r\n", "output": ["B"]}, {"input": "..BB....\r\n........\r\nWW.W..WW\r\nW...W...\r\n.W...W..\r\n.W..W.WW\r\nW.....WW\r\nWW......\r\n", "output": ["A"]}, {"input": "BB....B.\r\nB.....B.\r\n.....B..\r\n..B...BB\r\n.W.BWBWB\r\n....W...\r\nWW.WWW..\r\n....W...\r\n", "output": ["B"]}, {"input": "B.B.BB.B\r\nW.WWW.WW\r\n.WWWWW.W\r\nW.BB.WBW\r\n.W..BBWB\r\nBB.WWBBB\r\n.W.W.WWB\r\nWWW..WW.\r\n", "output": ["A"]}, {"input": "BB..BB..\r\nBW.W.W.B\r\n..B.....\r\n.....BB.\r\n.B..B..B\r\n........\r\n...BB.B.\r\nW.WWWW.W\r\n", "output": ["A"]}, {"input": "BB......\r\nW....BBW\r\n........\r\n.B.B.BBB\r\n....BB..\r\nB....BB.\r\n...WWWW.\r\n....WW..\r\n", "output": ["A"]}, {"input": ".B.B..B.\r\nB.B....B\r\n...B.B.B\r\n..B.W..B\r\n.BBB.B.B\r\nB.BB.B.B\r\nBB..BBBB\r\nW.W.W.WW\r\n", "output": ["B"]}, {"input": "..BB....\r\n.B.B.B.B\r\n..B.B...\r\n..B..B.B\r\nWWWBWWB.\r\n.BB...B.\r\n..BBB...\r\n......W.\r\n", "output": ["B"]}, {"input": "..BB....\r\n.WBWBWBB\r\n.....BBB\r\n..WW....\r\n.W.W...W\r\nWWW...W.\r\n.W....W.\r\nW...W.W.\r\n", "output": ["A"]}, {"input": "B...BB..\r\nWWBBW.BB\r\n.W.W....\r\nWWWW....\r\nW....W..\r\nW..WW...\r\n...W....\r\nWW.W....\r\n", "output": ["A"]}, {"input": "B..BB..B\r\n..B.B...\r\nBW..BBW.\r\n...B.BBB\r\n.B..BB..\r\n..B.B.BB\r\n........\r\n........\r\n", "output": ["A"]}, {"input": "....BB..\r\nBB......\r\n.B.....B\r\nWW..WWW.\r\n...BB.B.\r\nB...BB..\r\n..W..WWW\r\n...W...W\r\n", "output": ["B"]}, {"input": "B...BBBB\r\n...BBB..\r\nBBWBWW.W\r\n.B..BB.B\r\nW..W..WW\r\nW.WW....\r\n........\r\nWW.....W\r\n", "output": ["A"]}, {"input": ".BB..B..\r\n.B.....B\r\n.B......\r\n.B...B..\r\n.......B\r\n.WWB.WWB\r\nW.....W.\r\n...W....\r\n", "output": ["B"]}, {"input": ".B......\r\n.B....B.\r\n...W....\r\n......W.\r\nW.WWWW.W\r\nW.WW....\r\n..WWW...\r\n..W...WW\r\n", "output": ["A"]}, {"input": "B.......\r\nBBB.....\r\n.B....B.\r\n.W.BWB.W\r\n......B.\r\nW..WW...\r\n...W....\r\nW...W..W\r\n", "output": ["A"]}, {"input": ".B......\r\n.B...B.B\r\n.B..B.BB\r\nW.......\r\n..W.....\r\n..WWW...\r\n.......W\r\n........\r\n", "output": ["A"]}, {"input": ".....B..\r\n........\r\n........\r\n.BB..B..\r\n..BB....\r\n........\r\n....WWW.\r\n......W.\r\n", "output": ["B"]}, {"input": "B.B...B.\r\n...BBBBB\r\n....B...\r\n...B...B\r\nB.B.B..B\r\n........\r\n........\r\nWWW..WW.\r\n", "output": ["B"]}, {"input": "B.B...B.\r\n........\r\n.......B\r\n.BB....B\r\n.....W..\r\n.W.WW.W.\r\n...W.WW.\r\nW..WW..W\r\n", "output": ["A"]}, {"input": "......B.\r\nB....B..\r\n...B.BB.\r\n...B....\r\n........\r\n..W....W\r\nWW......\r\n.W....W.\r\n", "output": ["B"]}, {"input": ".BBB....\r\nB.B.B...\r\nB.BB.B..\r\nB.BB.B.B\r\n........\r\n........\r\nW.....W.\r\n..WW..W.\r\n", "output": ["B"]}, {"input": "..B..BBB\r\n........\r\n........\r\n........\r\n...W.W..\r\n...W..W.\r\nW.......\r\n..W...W.\r\n", "output": ["A"]}, {"input": "........\r\n.B.B....\r\n...B..BB\r\n........\r\n........\r\nW...W...\r\nW...W...\r\nW.WW.W..\r\n", "output": ["A"]}, {"input": "...B..BB\r\n.B..B..B\r\n........\r\n........\r\n........\r\nW..W....\r\n.....WW.\r\n.W......\r\n", "output": ["A"]}, {"input": "B....BB.\r\n...B...B\r\n.B......\r\n........\r\n........\r\n........\r\n........\r\n....W..W\r\n", "output": ["B"]}, {"input": "...BB.BB\r\nBB...B..\r\n........\r\n........\r\n........\r\n........\r\n..W..W..\r\n......W.\r\n", "output": ["A"]}, {"input": "...BB...\r\n........\r\n........\r\n........\r\n........\r\n........\r\n......W.\r\nWW...WW.\r\n", "output": ["A"]}, {"input": "...B.B..\r\n........\r\n........\r\n........\r\n........\r\n........\r\n........\r\nWWW...WW\r\n", "output": ["A"]}, {"input": "BBBBBBB.\r\n........\r\n........\r\n........\r\n........\r\n........\r\n........\r\n.WWWWWWW\r\n", "output": ["A"]}, {"input": ".BBBBBB.\r\nB.......\r\n........\r\n........\r\n........\r\n........\r\n........\r\n.WWWWWWW\r\n", "output": ["B"]}, {"input": ".BBBBBBB\r\n........\r\n........\r\n........\r\n........\r\n........\r\n........\r\nWWWWWWW.\r\n", "output": ["A"]}, {"input": ".BBBBBB.\r\n.......B\r\n........\r\n........\r\n........\r\n........\r\n........\r\nWWWWWWW.\r\n", "output": ["B"]}, {"input": "B..BB...\r\n..B...B.\r\n.WBB...B\r\nBW......\r\nW.B...W.\r\n..BBW.B.\r\nBW..BB..\r\n......W.\r\n", "output": ["B"]}, {"input": "BBB.BBBB\r\nWB.W..B.\r\nBBBB...B\r\nB..B....\r\n.......W\r\n.BWB..BB\r\nB..BW.BW\r\n.W......\r\n", "output": ["A"]}, {"input": "B.BBBBBB\r\nB..BBB.B\r\nW.BB.W.B\r\nB.BWBB.B\r\nBWBWBBBB\r\n...BBBBB\r\nB.B...BB\r\nWW..WW.W\r\n", "output": ["B"]}, {"input": "BBBB.BBB\r\nBBBB.B.B\r\nB.B..BBB\r\nB.BB.BWW\r\nB.BB.BBB\r\nB.BB.BBB\r\n..BW.BB.\r\nW.WWWWWW\r\n", "output": ["B"]}, {"input": "BBBB.BBB\r\n.B....WB\r\nBB.B...B\r\nWWWW.WWB\r\nBB...BWW\r\nWWW..BBB\r\nW.BW.BB.\r\nWWWWWWW.\r\n", "output": ["B"]}, {"input": "B.BBBBBB\r\nW.WWBBBW\r\nW.BB.WBB\r\nW.W.BBBW\r\nW.BWW.WB\r\nB..B..BB\r\nB.B.W.BB\r\nWWWWW.WW\r\n", "output": ["B"]}, {"input": "BBBBBB.B\r\n.BBWBB.B\r\nWWW..B.W\r\n..WW.W.W\r\nBWB..W.W\r\n..BW.B.W\r\nB..B....\r\nWWWW.WWW\r\n", "output": ["B"]}, {"input": ".B...BB.\r\nWBB.BWBB\r\n.BWBW...\r\n..W...B.\r\nWB.BWW..\r\nWBW.....\r\n.W..W.B.\r\n.W.W.WW.\r\n", "output": ["A"]}, {"input": ".B..BBBB\r\nBB...WWB\r\nB..B.W.B\r\nWB.W...B\r\n...W.WW.\r\nW.....W.\r\nWB.W.W.W\r\n.WW...WW\r\n", "output": ["A"]}, {"input": "B.BBBBBB\r\nW.BB.W.B\r\nW.BBW...\r\n..WWWW.B\r\n....W..B\r\n.WW.W..W\r\n.W..WW.W\r\nW.W....W\r\n", "output": ["A"]}, {"input": "........\r\n.......W\r\n........\r\n........\r\n........\r\n........\r\n.......B\r\n........\r\n", "output": ["A"]}, {"input": "..B.....\r\n..W.....\r\n.W....B.\r\n........\r\n.B...W..\r\n......B.\r\n.W......\r\n........\r\n", "output": ["A"]}, {"input": "........\r\nB.......\r\n........\r\n........\r\n........\r\n........\r\n.......W\r\n........\r\n", "output": ["A"]}, {"input": "........\r\n........\r\n........\r\n.W......\r\n......B.\r\n........\r\n........\r\n........\r\n", "output": ["A"]}, {"input": "........\r\nB.......\r\nW.......\r\n.......B\r\n........\r\n........\r\n........\r\n...W....\r\n", "output": ["B"]}, {"input": "........\r\n.B......\r\n.W......\r\n........\r\n....B...\r\n........\r\n........\r\n.......W\r\n", "output": ["B"]}, {"input": "........\r\n..B.....\r\n..W...B.\r\n........\r\n.....W..\r\n......B.\r\n........\r\n........\r\n", "output": ["B"]}, {"input": "........\r\nW.......\r\n........\r\n........\r\n........\r\n........\r\n.......B\r\n........\r\n", "output": ["A"]}, {"input": "........\r\n........\r\n........\r\n........\r\nW.......\r\nB.......\r\n........\r\n........\r\n", "output": ["B"]}, {"input": "........\r\n........\r\n.W......\r\n........\r\n........\r\n........\r\n.B......\r\n........\r\n", "output": ["B"]}, {"input": "........\r\nB.......\r\nW.......\r\n.W......\r\n........\r\nB.......\r\n........\r\n........\r\n", "output": ["B"]}]
100
100
100
[{'input': 'BB....B.\r\nB.....B.\r\n.....B..\r\n..B...BB\r\n.W.BWBWB\r\n....W...\r\nWW.WWW..\r\n....W...\r\n', 'output': ['B']}, {'input': '......B.\r\nB....B..\r\n...B.BB.\r\n...B....\r\n........\r\n..W....W\r\nWW......\r\n.W....W.\r\n', 'output': ['B']}, {'input': '..B..BBB\r\n........\r\n........\r\n........\r\n...W.W..\r\n...W..W.\r\nW.......\r\n..W...W.\r\n', 'output': ['A']}, {'input': 'BBBB.BBB\r\n.B....WB\r\nBB.B...B\r\nWWWW.WWB\r\nBB...BWW\r\nWWW..BBB\r\nW.BW.BB.\r\nWWWWWWW.\r\n', 'output': ['B']}, {'input': '........\r\nB.......\r\nW.......\r\n.......B\r\n........\r\n........\r\n........\r\n...W....\r\n', 'output': ['B']}]
[{'input': 'B...BBBB\r\n...BBB..\r\nBBWBWW.W\r\n.B..BB.B\r\nW..W..WW\r\nW.WW....\r\n........\r\nWW.....W\r\n', 'output': ['A']}, {'input': '........\r\n........\r\n........\r\n........\r\nW.......\r\nB.......\r\n........\r\n........\r\n', 'output': ['B']}, {'input': '........\r\n..B.....\r\n..W...B.\r\n........\r\n.....W..\r\n......B.\r\n........\r\n........\r\n', 'output': ['B']}, {'input': 'B.B...B.\r\n...BBBBB\r\n....B...\r\n...B...B\r\nB.B.B..B\r\n........\r\n........\r\nWWW..WW.\r\n', 'output': ['B']}, {'input': '........\r\nB.......\r\n........\r\n........\r\n........\r\n........\r\n.......W\r\n........\r\n', 'output': ['A']}]
[{'input': 'BB..BB..\r\nBW.W.W.B\r\n..B.....\r\n.....BB.\r\n.B..B..B\r\n........\r\n...BB.B.\r\nW.WWWW.W\r\n', 'output': ['A']}, {'input': 'B...BB..\r\nWWBBW.BB\r\n.W.W....\r\nWWWW....\r\nW....W..\r\nW..WW...\r\n...W....\r\nWW.W....\r\n', 'output': ['A']}, {'input': 'B.B...B.\r\n........\r\n.......B\r\n.BB....B\r\n.....W..\r\n.W.WW.W.\r\n...W.WW.\r\nW..WW..W\r\n', 'output': ['A']}, {'input': '.B.B..B.\r\nB.B....B\r\n...B.B.B\r\n..B.W..B\r\n.BBB.B.B\r\nB.BB.B.B\r\nBB..BBBB\r\nW.W.W.WW\r\n', 'output': ['B']}, {'input': 'B.B...B.\r\n...BBBBB\r\n....B...\r\n...B...B\r\nB.B.B..B\r\n........\r\n........\r\nWWW..WW.\r\n', 'output': ['B']}]
[{'input': '........\r\n.B.B....\r\n...B..BB\r\n........\r\n........\r\nW...W...\r\nW...W...\r\nW.WW.W..\r\n', 'output': ['A']}, {'input': '.BBB....\r\nB.B.B...\r\nB.BB.B..\r\nB.BB.B.B\r\n........\r\n........\r\nW.....W.\r\n..WW..W.\r\n', 'output': ['B']}, {'input': 'B...BB..\r\nWWBBW.BB\r\n.W.W....\r\nWWWW....\r\nW....W..\r\nW..WW...\r\n...W....\r\nWW.W....\r\n', 'output': ['A']}, {'input': '.B.B..B.\r\nB.B....B\r\n...B.B.B\r\n..B.W..B\r\n.BBB.B.B\r\nB.BB.B.B\r\nBB..BBBB\r\nW.W.W.WW\r\n', 'output': ['B']}, {'input': '...BB.BB\r\nBB...B..\r\n........\r\n........\r\n........\r\n........\r\n..W..W..\r\n......W.\r\n', 'output': ['A']}]
[{'input': 'BB....B.\r\nB.....B.\r\n.....B..\r\n..B...BB\r\n.W.BWBWB\r\n....W...\r\nWW.WWW..\r\n....W...\r\n', 'output': ['B']}, {'input': '........\r\n.B.B....\r\n...B..BB\r\n........\r\n........\r\nW...W...\r\nW...W...\r\nW.WW.W..\r\n', 'output': ['A']}, {'input': '........\r\n........\r\n.B....B.\r\n....W...\r\n........\r\n..W.....\r\n........\r\n........\r\n', 'output': ['A']}, {'input': 'BBBBBB.B\r\n.BBWBB.B\r\nWWW..B.W\r\n..WW.W.W\r\nBWB..W.W\r\n..BW.B.W\r\nB..B....\r\nWWWW.WWW\r\n', 'output': ['B']}, {'input': 'BBB.BBBB\r\nWB.W..B.\r\nBBBB...B\r\nB..B....\r\n.......W\r\n.BWB..BB\r\nB..BW.BW\r\n.W......\r\n', 'output': ['A']}]
100
100
100
100
100
100
100
100
100
100
100
100
88.89
88.89
100
329
100
100
95.556
["1 1 -1", "1 3 1", "3 3 -1"]
The only line contains three integers n, m and k (1 ≀ n, m ≀ 1018, k is either 1 or -1).
6b9eff690fae14725885cbc891ff7243
mod=1000000007 n,m,k=list(map(int,input().split())) if k==-1: co=n+m if co%2!=0: print("0") else: n=n-1 m=m-1 n=n*m co=pow(2,n,mod) co%=1000000007 print(co) else: n=n-1 m=m-1 n=n*m co=pow(2,n,mod) co%=1000000007 print(co)
["1", "1", "16"]
Python
NoteIn the first example the only way is to put -1 into the only block.In the second example the only way is to put 1 into every block.
Print a single number denoting the answer modulo 1000000007.
Ralph has a magic field which is divided into n × m blocks. That is to say, there are n rows and m columns on the field. Ralph can put an integer in each block. However, the magic field doesn't always work properly. It works only if the product of integers in each row and each column equals to k, where k is either 1 or -1.Now Ralph wants you to figure out the number of ways to put numbers in each block in such a way that the magic field works properly. Two ways are considered different if and only if there exists at least one block where the numbers in the first way and in the second way are different. You are asked to output the answer modulo 1000000007 = 109 + 7.Note that there is no range of the numbers to put in the blocks, but we can prove that the answer is not infinity.
[{"input": "1 1 -1\r\n", "output": ["1"]}, {"input": "1 3 1\r\n", "output": ["1"]}, {"input": "3 3 -1\r\n", "output": ["16"]}, {"input": "2 7 1\r\n", "output": ["64"]}, {"input": "1 1 1\r\n", "output": ["1"]}, {"input": "2 4 -1\r\n", "output": ["8"]}, {"input": "173 69 -1\r\n", "output": ["814271739"]}, {"input": "110 142 1\r\n", "output": ["537040244"]}, {"input": "162 162 -1\r\n", "output": ["394042552"]}, {"input": "49 153 -1\r\n", "output": ["412796600"]}, {"input": "94 182 1\r\n", "output": ["33590706"]}, {"input": "106666666 233333333 1\r\n", "output": ["121241754"]}, {"input": "2 2 1\r\n", "output": ["2"]}, {"input": "146 34 -1\r\n", "output": ["742752757"]}, {"input": "94 86 -1\r\n", "output": ["476913727"]}, {"input": "2529756051797760 2682355969139391 -1\r\n", "output": ["0"]}, {"input": "3126690179932000 2474382898739836 -1\r\n", "output": ["917305624"]}, {"input": "3551499873841921 2512677762780671 -1\r\n", "output": ["350058339"]}, {"input": "3613456196418270 2872267429531501 1\r\n", "output": ["223552863"]}, {"input": "2886684369091916 3509787933422130 1\r\n", "output": ["341476979"]}, {"input": "3536041043537343 2416093514489183 1\r\n", "output": ["394974516"]}, {"input": "2273134852621270 2798005122439669 1\r\n", "output": ["901406364"]}, {"input": "2870150496178092 3171485931753811 -1\r\n", "output": ["0"]}, {"input": "999999999999999999 1000000000000000000 1\r\n", "output": ["102810659"]}, {"input": "987654321987654321 666666666666666666 1\r\n", "output": ["279028602"]}, {"input": "1 2 -1\r\n", "output": ["0"]}, {"input": "2 1 -1\r\n", "output": ["0"]}, {"input": "1000000000000000000 1 1\r\n", "output": ["1"]}, {"input": "1000000006 100000000000000000 1\r\n", "output": ["123624987"]}]
100
100
100
[{'input': '146 34 -1\r\n', 'output': ['742752757']}, {'input': '2886684369091916 3509787933422130 1\r\n', 'output': ['341476979']}, {'input': '987654321987654321 666666666666666666 1\r\n', 'output': ['279028602']}, {'input': '1000000006 100000000000000000 1\r\n', 'output': ['123624987']}, {'input': '173 69 -1\r\n', 'output': ['814271739']}]
[{'input': '2529756051797760 2682355969139391 -1\r\n', 'output': ['0']}, {'input': '3551499873841921 2512677762780671 -1\r\n', 'output': ['350058339']}, {'input': '3 3 -1\r\n', 'output': ['16']}, {'input': '1 1 1\r\n', 'output': ['1']}, {'input': '94 182 1\r\n', 'output': ['33590706']}]
[{'input': '2 2 1\r\n', 'output': ['2']}, {'input': '1 3 1\r\n', 'output': ['1']}, {'input': '94 182 1\r\n', 'output': ['33590706']}, {'input': '1 1 1\r\n', 'output': ['1']}, {'input': '3613456196418270 2872267429531501 1\r\n', 'output': ['223552863']}]
[{'input': '1 1 1\r\n', 'output': ['1']}, {'input': '173 69 -1\r\n', 'output': ['814271739']}, {'input': '3613456196418270 2872267429531501 1\r\n', 'output': ['223552863']}, {'input': '2 1 -1\r\n', 'output': ['0']}, {'input': '2273134852621270 2798005122439669 1\r\n', 'output': ['901406364']}]
[{'input': '987654321987654321 666666666666666666 1\r\n', 'output': ['279028602']}, {'input': '3536041043537343 2416093514489183 1\r\n', 'output': ['394974516']}, {'input': '1000000000000000000 1 1\r\n', 'output': ['1']}, {'input': '94 86 -1\r\n', 'output': ['476913727']}, {'input': '110 142 1\r\n', 'output': ['537040244']}]
100
100
100
100
100
94.44
100
50
100
94.44
75
100
25
100
75
330
100
87.776
75
["3 2", "5 4"]
The input consists of two space-separated integers p and k (3 ≀ p ≀ 1 000 000, 0 ≀ k ≀ p - 1) on a single line. It is guaranteed that p is an odd prime number.
580bf65af24fb7f08250ddbc4ca67e0e
__author__ = 'MoonBall' import sys # sys.stdin = open('data/D.in', 'r') T = 1 M = 1000000007 def process(): P, K = list(map(int, input().split())) k = [K * x % P for x in range(P)] # print(k) # f(0) = k[f(0)] # f(1) = k[f(4)] # f(2) = k[f(3)] # f(3) = k[f(2)] # f(4) = k[f(1)] if not K: print(pow(P, P - 1, M)) return if K == 1: print(pow(P, P, M)) return f = [0] * P c = [0] * P ans = 1 for i in range(P): if f[i]: continue cnt = 1 u = i f[u] = 1 while not f[k[u]]: u = k[u] f[u] = 1 cnt = cnt + 1 c[cnt] = c[cnt] + 1 # print(c) for i in range(2, P): if c[i] != 0: cnt = i * c[i] + 1 ans = ans * pow(cnt, c[i], M) % M print(ans) for _ in range(T): process()
["3", "25"]
Python
NoteIn the first sample, p = 3 and k = 2. The following functions work: f(0) = 0, f(1) = 1, f(2) = 2. f(0) = 0, f(1) = 2, f(2) = 1. f(0) = f(1) = f(2) = 0.
Print a single integer, the number of distinct functions f modulo 109 + 7.
As behooves any intelligent schoolboy, Kevin Sun is studying psycowlogy, cowculus, and cryptcowgraphy at the Bovinia State University (BGU) under Farmer Ivan. During his Mathematics of Olympiads (MoO) class, Kevin was confronted with a weird functional equation and needs your help. For two fixed integers k and p, where p is an odd prime number, the functional equation states that for some function . (This equation should hold for any integer x in the range 0 to p - 1, inclusive.)It turns out that f can actually be many different functions. Instead of finding a solution, Kevin wants you to count the number of distinct functions f that satisfy this equation. Since the answer may be very large, you should print your result modulo 109 + 7.
[{"input": "3 2\r\n", "output": ["3"]}, {"input": "5 4\r\n", "output": ["25"]}, {"input": "7 2\r\n", "output": ["49"]}, {"input": "7 6\r\n", "output": ["343"]}, {"input": "10007 25\r\n", "output": ["100140049"]}, {"input": "40037 4\r\n", "output": ["602961362"]}, {"input": "5 0\r\n", "output": ["625"]}, {"input": "5 3\r\n", "output": ["5"]}, {"input": "7 1\r\n", "output": ["823543"]}, {"input": "13 5\r\n", "output": ["2197"]}, {"input": "13 4\r\n", "output": ["169"]}, {"input": "5 2\r\n", "output": ["5"]}, {"input": "11 1\r\n", "output": ["311668616"]}, {"input": "11 10\r\n", "output": ["161051"]}, {"input": "6907 2590\r\n", "output": ["543643888"]}, {"input": "3229 153\r\n", "output": ["552691282"]}, {"input": "727 282\r\n", "output": ["471521101"]}, {"input": "7621 6195\r\n", "output": ["501036626"]}, {"input": "4649 4648\r\n", "output": ["460009811"]}, {"input": "5527 1711\r\n", "output": ["837297007"]}, {"input": "1901 633\r\n", "output": ["557576188"]}, {"input": "463 408\r\n", "output": ["853558215"]}, {"input": "6871 5566\r\n", "output": ["742783884"]}, {"input": "4177 556\r\n", "output": ["594173514"]}, {"input": "65213 29960\r\n", "output": ["65213"]}, {"input": "375103 52131\r\n", "output": ["947042280"]}, {"input": "990037 453792\r\n", "output": ["654009570"]}, {"input": "95531 94787\r\n", "output": ["95531"]}, {"input": "498653 116674\r\n", "output": ["625264514"]}, {"input": "561389 213181\r\n", "output": ["10668315"]}, {"input": "649849 339573\r\n", "output": ["649849"]}, {"input": "512287 359783\r\n", "output": ["542484357"]}, {"input": "337411 146419\r\n", "output": ["532279245"]}, {"input": "717887 1\r\n", "output": ["559281518"]}, {"input": "586189 189159\r\n", "output": ["168174057"]}, {"input": "613463 269592\r\n", "output": ["336849737"]}, {"input": "873781 51595\r\n", "output": ["226847774"]}, {"input": "203317 12108\r\n", "output": ["374893480"]}, {"input": "51419 21829\r\n", "output": ["643913547"]}, {"input": "115237 90311\r\n", "output": ["355904974"]}, {"input": "437071 24705\r\n", "output": ["743969711"]}, {"input": "278917 84398\r\n", "output": ["727771018"]}, {"input": "40867 37466\r\n", "output": ["560078799"]}, {"input": "274783 98997\r\n", "output": ["505696564"]}, {"input": "450431 344107\r\n", "output": ["450431"]}, {"input": "288179 113623\r\n", "output": ["124681010"]}, {"input": "807689 9869\r\n", "output": ["636680820"]}, {"input": "69833 569\r\n", "output": ["69833"]}, {"input": "805711 702149\r\n", "output": ["759894252"]}, {"input": "999983 999982\r\n", "output": ["794678399"]}, {"input": "999983 0\r\n", "output": ["416606930"]}, {"input": "999983 1\r\n", "output": ["844765997"]}, {"input": "823457 2\r\n", "output": ["203355139"]}, {"input": "999983 239239\r\n", "output": ["965993296"]}]
100
100
100
[{'input': '337411 146419\r\n', 'output': ['532279245']}, {'input': '6907 2590\r\n', 'output': ['543643888']}, {'input': '5 2\r\n', 'output': ['5']}, {'input': '7 2\r\n', 'output': ['49']}, {'input': '999983 999982\r\n', 'output': ['794678399']}]
[{'input': '40867 37466\r\n', 'output': ['560078799']}, {'input': '6907 2590\r\n', 'output': ['543643888']}, {'input': '807689 9869\r\n', 'output': ['636680820']}, {'input': '203317 12108\r\n', 'output': ['374893480']}, {'input': '5 3\r\n', 'output': ['5']}]
[{'input': '7621 6195\r\n', 'output': ['501036626']}, {'input': '999983 999982\r\n', 'output': ['794678399']}, {'input': '203317 12108\r\n', 'output': ['374893480']}, {'input': '5 2\r\n', 'output': ['5']}, {'input': '450431 344107\r\n', 'output': ['450431']}]
[{'input': '4177 556\r\n', 'output': ['594173514']}, {'input': '5 3\r\n', 'output': ['5']}, {'input': '7 2\r\n', 'output': ['49']}, {'input': '115237 90311\r\n', 'output': ['355904974']}, {'input': '873781 51595\r\n', 'output': ['226847774']}]
[{'input': '999983 1\r\n', 'output': ['844765997']}, {'input': '999983 0\r\n', 'output': ['416606930']}, {'input': '203317 12108\r\n', 'output': ['374893480']}, {'input': '873781 51595\r\n', 'output': ['226847774']}, {'input': '4649 4648\r\n', 'output': ['460009811']}]
100
100
100
100
100
87.88
87.88
87.88
87.88
100
88.89
88.89
88.89
88.89
100
331
100
90.304
91.112
["120 51840", "42 42", "48 72"]
The only line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le m \le 5\cdot10^8$$$).
3f9980ad292185f63a80bce10705e806
n2, n1 = (int(_) for _ in input().split()) if n1 % n2 == 0: n = n1 // n2 k = 0 f = True while n != 1: if n % 3 == 0: n //= 3 k += 1 elif n % 2 == 0: n //= 2 k += 1 else: print(-1) f = False break if f: print(k) else: print(-1)
["7", "0", "-1"]
Python
NoteIn the first example, the possible sequence of moves is: $$$120 \rightarrow 240 \rightarrow 720 \rightarrow 1440 \rightarrow 4320 \rightarrow 12960 \rightarrow 25920 \rightarrow 51840.$$$ The are $$$7$$$ steps in total.In the second example, no moves are needed. Thus, the answer is $$$0$$$.In the third example, it is impossible to transform $$$48$$$ to $$$72$$$.
Print the number of moves to transform $$$n$$$ to $$$m$$$, or -1 if there is no solution.
Polycarp plays "Game 23". Initially he has a number $$$n$$$ and his goal is to transform it to $$$m$$$. In one move, he can multiply $$$n$$$ by $$$2$$$ or multiply $$$n$$$ by $$$3$$$. He can perform any number of moves.Print the number of moves needed to transform $$$n$$$ to $$$m$$$. Print -1 if it is impossible to do so.It is easy to prove that any way to transform $$$n$$$ to $$$m$$$ contains the same number of moves (i.e. number of moves doesn't depend on the way of transformation).
[{"input": "120 51840\r\n", "output": ["7"]}, {"input": "42 42\r\n", "output": ["0"]}, {"input": "48 72\r\n", "output": ["-1"]}, {"input": "1 1\r\n", "output": ["0"]}, {"input": "1 2\r\n", "output": ["1"]}, {"input": "1 4\r\n", "output": ["2"]}, {"input": "1 5\r\n", "output": ["-1"]}, {"input": "1 6\r\n", "output": ["2"]}, {"input": "3024 94058496\r\n", "output": ["12"]}, {"input": "1953125 500000000\r\n", "output": ["8"]}, {"input": "139999978 419999934\r\n", "output": ["1"]}, {"input": "1 223092870\r\n", "output": ["-1"]}, {"input": "2 5\r\n", "output": ["-1"]}, {"input": "289777775 341477104\r\n", "output": ["-1"]}, {"input": "12 26\r\n", "output": ["-1"]}, {"input": "4 9\r\n", "output": ["-1"]}, {"input": "5 11\r\n", "output": ["-1"]}, {"input": "3 83\r\n", "output": ["-1"]}, {"input": "40 123\r\n", "output": ["-1"]}, {"input": "3 10\r\n", "output": ["-1"]}, {"input": "64 243\r\n", "output": ["-1"]}, {"input": "2 7\r\n", "output": ["-1"]}, {"input": "1 2048\r\n", "output": ["11"]}, {"input": "2 9\r\n", "output": ["-1"]}, {"input": "120 51841\r\n", "output": ["-1"]}, {"input": "1 512\r\n", "output": ["9"]}, {"input": "7 15\r\n", "output": ["-1"]}, {"input": "10001 10001\r\n", "output": ["0"]}, {"input": "300000007 300000007\r\n", "output": ["0"]}, {"input": "5 7\r\n", "output": ["-1"]}, {"input": "1001 1001\r\n", "output": ["0"]}, {"input": "120 1081\r\n", "output": ["-1"]}, {"input": "2 19\r\n", "output": ["-1"]}, {"input": "101 101\r\n", "output": ["0"]}, {"input": "1111 2223\r\n", "output": ["-1"]}, {"input": "201 201\r\n", "output": ["0"]}, {"input": "202 202\r\n", "output": ["0"]}, {"input": "203 203\r\n", "output": ["0"]}, {"input": "303 303\r\n", "output": ["0"]}, {"input": "403 403\r\n", "output": ["0"]}, {"input": "23 97\r\n", "output": ["-1"]}, {"input": "404 404\r\n", "output": ["0"]}, {"input": "405 405\r\n", "output": ["0"]}, {"input": "505 505\r\n", "output": ["0"]}, {"input": "3 9\r\n", "output": ["1"]}, {"input": "2 6\r\n", "output": ["1"]}, {"input": "11 67\r\n", "output": ["-1"]}, {"input": "1234 2469\r\n", "output": ["-1"]}, {"input": "1000 1000\r\n", "output": ["0"]}, {"input": "6 20\r\n", "output": ["-1"]}, {"input": "9 24\r\n", "output": ["-1"]}, {"input": "18782 37565\r\n", "output": ["-1"]}, {"input": "1 22\r\n", "output": ["-1"]}, {"input": "10 61\r\n", "output": ["-1"]}, {"input": "1000 2001\r\n", "output": ["-1"]}, {"input": "100000000 100000001\r\n", "output": ["-1"]}, {"input": "4000 8001\r\n", "output": ["-1"]}, {"input": "1 499999993\r\n", "output": ["-1"]}, {"input": "1 50331648\r\n", "output": ["25"]}, {"input": "3 13\r\n", "output": ["-1"]}, {"input": "10 24\r\n", "output": ["-1"]}, {"input": "2 22\r\n", "output": ["-1"]}, {"input": "6 29\r\n", "output": ["-1"]}, {"input": "1 7\r\n", "output": ["-1"]}, {"input": "6 21\r\n", "output": ["-1"]}, {"input": "50 64800\r\n", "output": ["8"]}, {"input": "5 16\r\n", "output": ["-1"]}, {"input": "2 18\r\n", "output": ["2"]}, {"input": "1 491280007\r\n", "output": ["-1"]}, {"input": "4 16\r\n", "output": ["2"]}, {"input": "2 13\r\n", "output": ["-1"]}, {"input": "1 262144\r\n", "output": ["18"]}, {"input": "1 16777216\r\n", "output": ["24"]}, {"input": "405691171 405691171\r\n", "output": ["0"]}, {"input": "5 12\r\n", "output": ["-1"]}, {"input": "1 500000000\r\n", "output": ["-1"]}, {"input": "1 362797056\r\n", "output": ["22"]}]
100
100
100
[{'input': '10 61\r\n', 'output': ['-1']}, {'input': '1 16777216\r\n', 'output': ['24']}, {'input': '1 262144\r\n', 'output': ['18']}, {'input': '50 64800\r\n', 'output': ['8']}, {'input': '203 203\r\n', 'output': ['0']}]
[{'input': '201 201\r\n', 'output': ['0']}, {'input': '1 500000000\r\n', 'output': ['-1']}, {'input': '1 223092870\r\n', 'output': ['-1']}, {'input': '505 505\r\n', 'output': ['0']}, {'input': '10 24\r\n', 'output': ['-1']}]
[{'input': '5 7\r\n', 'output': ['-1']}, {'input': '1001 1001\r\n', 'output': ['0']}, {'input': '201 201\r\n', 'output': ['0']}, {'input': '1 22\r\n', 'output': ['-1']}, {'input': '1 2\r\n', 'output': ['1']}]
[{'input': '120 51841\r\n', 'output': ['-1']}, {'input': '1 500000000\r\n', 'output': ['-1']}, {'input': '5 12\r\n', 'output': ['-1']}, {'input': '120 1081\r\n', 'output': ['-1']}, {'input': '1 6\r\n', 'output': ['2']}]
[{'input': '1 223092870\r\n', 'output': ['-1']}, {'input': '9 24\r\n', 'output': ['-1']}, {'input': '404 404\r\n', 'output': ['0']}, {'input': '5 7\r\n', 'output': ['-1']}, {'input': '1 1\r\n', 'output': ['0']}]
100
100
100
100
100
83.33
100
88.89
100
100
83.33
100
91.67
100
100
332
100
94.444
95
["25 3", "50 5"]
The only input line contains a pair of integers a, n (1 ≀ a, n ≀ 107; a + n - 1 ≀ 107).
915081861e391958dce6ee2a117abd4e
F = {} def f(k): if not k in F: s, i, j = 0, 4, 4 while i <= k: s += i * f(k // i) i += j + 1 j += 2 F[k] = (k * (k + 1)) // 2 - s return F[k] def g(k): s, i, j = 0, 4, 4 while i <= k: s += (i - 1) * f(k // i) i += j + 1 j += 2 return (k * (k + 1)) // 2 - s a, n = map(int, input().split()) print(g(a + n - 1) - g(a - 1))
["30", "125"]
Python
NoteA note to the first sample test. A year of 25 days will consist of one month containing 25 days. A year of 26 days will consist of 26 months, one day each. A year of 27 days will have three months, 9 days each.
Print the required number p. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use cin, cout streams or the %I64d specifier.
Reforms have started in Berland again! At this time, the Parliament is discussing the reform of the calendar. To make the lives of citizens of Berland more varied, it was decided to change the calendar. As more and more people are complaining that "the years fly by...", it was decided that starting from the next year the number of days per year will begin to grow. So the coming year will have exactly a days, the next after coming year will have a + 1 days, the next one will have a + 2 days and so on. This schedule is planned for the coming n years (in the n-th year the length of the year will be equal a + n - 1 day).No one has yet decided what will become of months. An MP Palevny made the following proposal. The calendar for each month is comfortable to be printed on a square sheet of paper. We are proposed to make the number of days in each month be the square of some integer. The number of days per month should be the same for each month of any year, but may be different for different years. The number of days in each year must be divisible by the number of days per month in this year. This rule ensures that the number of months in each year is an integer. The number of days per month for each year must be chosen so as to save the maximum amount of paper to print the calendars. In other words, the number of days per month should be as much as possible. These rules provide an unambiguous method for choosing the number of days in each month for any given year length. For example, according to Palevny's proposition, a year that consists of 108 days will have three months, 36 days each. The year that consists of 99 days will have 11 months, 9 days each, and a year of 365 days will have 365 months, one day each.The proposal provoked heated discussion in the community, the famous mathematician Perelmanov quickly calculated that if the proposal is supported, then in a period of n years, beginning with the year that has a days, the country will spend p sheets of paper to print a set of calendars for these years. Perelmanov's calculations take into account the fact that the set will contain one calendar for each year and each month will be printed on a separate sheet.Repeat Perelmanov's achievement and print the required number p. You are given positive integers a and n. Perelmanov warns you that your program should not work longer than four seconds at the maximum test.
[{"input": "25 3\r\n", "output": ["30"]}, {"input": "50 5\r\n", "output": ["125"]}, {"input": "1 1\r\n", "output": ["1"]}, {"input": "1 2\r\n", "output": ["3"]}, {"input": "1 10\r\n", "output": ["38"]}, {"input": "1 5000000\r\n", "output": ["8224640917276"]}, {"input": "5000000 5000000\r\n", "output": ["24674231279431"]}, {"input": "4000000 5000000\r\n", "output": ["21384022194564"]}, {"input": "3000000 5000000\r\n", "output": ["18094224526592"]}, {"input": "1000000 5000000\r\n", "output": ["11514506860120"]}, {"input": "1 10000000\r\n", "output": ["32898872196712"]}]
100
100
100
[{'input': '1 5000000\r\n', 'output': ['8224640917276']}, {'input': '25 3\r\n', 'output': ['30']}, {'input': '1 10\r\n', 'output': ['38']}, {'input': '3000000 5000000\r\n', 'output': ['18094224526592']}, {'input': '5000000 5000000\r\n', 'output': ['24674231279431']}]
[{'input': '4000000 5000000\r\n', 'output': ['21384022194564']}, {'input': '1 1\r\n', 'output': ['1']}, {'input': '1 2\r\n', 'output': ['3']}, {'input': '25 3\r\n', 'output': ['30']}, {'input': '1 5000000\r\n', 'output': ['8224640917276']}]
[{'input': '1 1\r\n', 'output': ['1']}, {'input': '1 2\r\n', 'output': ['3']}, {'input': '1 10\r\n', 'output': ['38']}, {'input': '1 10000000\r\n', 'output': ['32898872196712']}, {'input': '3000000 5000000\r\n', 'output': ['18094224526592']}]
[{'input': '3000000 5000000\r\n', 'output': ['18094224526592']}, {'input': '25 3\r\n', 'output': ['30']}, {'input': '1 10\r\n', 'output': ['38']}, {'input': '1 5000000\r\n', 'output': ['8224640917276']}, {'input': '1000000 5000000\r\n', 'output': ['11514506860120']}]
[{'input': '4000000 5000000\r\n', 'output': ['21384022194564']}, {'input': '1 2\r\n', 'output': ['3']}, {'input': '1000000 5000000\r\n', 'output': ['11514506860120']}, {'input': '5000000 5000000\r\n', 'output': ['24674231279431']}, {'input': '3000000 5000000\r\n', 'output': ['18094224526592']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
333
100
100
100
["4 2\naabb", "6 3\naacaab"]
The first line contains two integers n and k (1 ≀ n, k ≀ 100) β€” the number of baloons and friends. Next line contains string s β€” colors of baloons.
ceb3807aaffef60bcdbcc9a17a1391be
# -*- coding: utf-8 -*- """ Created on Sun Jun 30 16:47:42 2019 @author: avina """ n,m = map(int, input().split()) s = input() d = [] w = set(s) for i in w: d.append(s.count(i)) if max(d) > m: print('NO') else: print('YES')
["YES", "NO"]
Python
NoteIn the first sample Kefa can give 1-st and 3-rd baloon to the first friend, and 2-nd and 4-th to the second.In the second sample Kefa needs to give to all his friends baloons of color a, but one baloon will stay, thats why answer is Β«NOΒ».
Answer to the task β€” Β«YESΒ» or Β«NOΒ» in a single line. You can choose the case (lower or upper) for each letter arbitrary.
One day Kefa found n baloons. For convenience, we denote color of i-th baloon as si β€” lowercase letter of the Latin alphabet. Also Kefa has k friends. Friend will be upset, If he get two baloons of the same color. Kefa want to give out all baloons to his friends. Help Kefa to find out, can he give out all his baloons, such that no one of his friens will be upset β€” print Β«YESΒ», if he can, and Β«NOΒ», otherwise. Note, that Kefa's friend will not upset, if he doesn't get baloons at all.
[{"input": "4 2\r\naabb\r\n", "output": ["YES"]}, {"input": "6 3\r\naacaab\r\n", "output": ["NO"]}, {"input": "2 2\r\nlu\r\n", "output": ["YES"]}, {"input": "5 3\r\novvoo\r\n", "output": ["YES"]}, {"input": "36 13\r\nbzbzcffczzcbcbzzfzbbfzfzzbfbbcbfccbf\r\n", "output": ["YES"]}, {"input": "81 3\r\nooycgmvvrophvcvpoupepqllqttwcocuilvyxbyumdmmfapvpnxhjhxfuagpnntonibicaqjvwfhwxhbv\r\n", "output": ["NO"]}, {"input": "100 100\r\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\n", "output": ["YES"]}, {"input": "100 1\r\nnubcvvjvbjgnjsdkajimdcxvewbcytvfkihunycdrlconddlwgzjasjlsrttlrzsumzpyumpveglfqzmaofbshbojmwuwoxxvrod\r\n", "output": ["NO"]}, {"input": "100 13\r\nvyldolgryldqrvoldvzvrdrgorlorszddtgqvrlisxxrxdxlqtvtgsrqlzixoyrozxzogqxlsgzdddzqrgitxxritoolzolgrtvl\r\n", "output": ["YES"]}, {"input": "18 6\r\njzwtnkvmscqhmdlsxy\r\n", "output": ["YES"]}, {"input": "21 2\r\nfscegcqgzesefghhwcexs\r\n", "output": ["NO"]}, {"input": "32 22\r\ncduamsptaklqtxlyoutlzepxgyfkvngc\r\n", "output": ["YES"]}, {"input": "49 27\r\noxyorfnkzwsfllnyvdhdanppuzrnbxehugvmlkgeymqjlmfxd\r\n", "output": ["YES"]}, {"input": "50 24\r\nxxutzjwbggcwvxztttkmzovtmuwttzcbwoztttohzzxghuuthv\r\n", "output": ["YES"]}, {"input": "57 35\r\nglxshztrqqfyxthqamagvtmrdparhelnzrqvcwqxjytkbuitovkdxueul\r\n", "output": ["YES"]}, {"input": "75 23\r\nittttiiuitutuiiuuututiuttiuiuutuuuiuiuuuuttuuttuutuiiuiuiiuiitttuututuiuuii\r\n", "output": ["NO"]}, {"input": "81 66\r\nfeqevfqfebhvubhuuvfuqheuqhbeeuebehuvhffvbqvqvfbqqvvhevqffbqqhvvqhfeehuhqeqhueuqqq\r\n", "output": ["YES"]}, {"input": "93 42\r\npqeiafraiavfcteumflpcbpozcomlvpovlzdbldvoopnhdoeqaopzthiuzbzmeieiatthdeqovaqfipqlddllmfcrrnhb\r\n", "output": ["YES"]}, {"input": "100 53\r\nizszyqyndzwzyzgsdagdwdazadiawizinagqqgczaqqnawgijziziawzszdjdcqjdjqiwgadydcnqisaayjiqqsscwwzjzaycwwc\r\n", "output": ["YES"]}, {"input": "100 14\r\nvkrdcqbvkwuckpmnbydmczdxoagdsgtqxvhaxntdcxhjcrjyvukhugoglbmyoaqexgtcfdgemmizoniwtmisqqwcwfusmygollab\r\n", "output": ["YES"]}, {"input": "100 42\r\naaaaaiiiiaiiiaaiaiiaaiiiiiaaaaaiaiiiaiiiiaiiiaaaaaiiiaaaiiaaiiiaiiiaiaaaiaiiiiaaiiiaiiaiaiiaiiiaaaia\r\n", "output": ["NO"]}, {"input": "100 89\r\ntjbkmydejporbqhcbztkcumxjjgsrvxpuulbhzeeckkbchpbxwhedrlhjsabcexcohgdzouvsgphjdthpuqrlkgzxvqbuhqxdsmf\r\n", "output": ["YES"]}, {"input": "100 100\r\njhpyiuuzizhubhhpxbbhpyxzhbpjphzppuhiahihiappbhuypyauhizpbibzixjbzxzpbphuiaypyujappuxiyuyaajaxjupbahb\r\n", "output": ["YES"]}, {"input": "100 3\r\nsszoovvzysavsvzsozzvoozvysozsaszayaszasaysszzzysosyayyvzozovavzoyavsooaoyvoozvvozsaosvayyovazzszzssa\r\n", "output": ["NO"]}, {"input": "100 44\r\ndluthkxwnorabqsukgnxnvhmsmzilyulpursnxkdsavgemiuizbyzebhyjejgqrvuckhaqtuvdmpziesmpmewpvozdanjyvwcdgo\r\n", "output": ["YES"]}, {"input": "100 90\r\ntljonbnwnqounictqqctgonktiqoqlocgoblngijqokuquoolciqwnctgoggcbojtwjlculoikbggquqncittwnjbkgkgubnioib\r\n", "output": ["YES"]}, {"input": "100 79\r\nykxptzgvbqxlregvkvucewtydvnhqhuggdsyqlvcfiuaiddnrrnstityyehiamrggftsqyduwxpuldztyzgmfkehprrneyvtknmf\r\n", "output": ["YES"]}, {"input": "100 79\r\naagwekyovbviiqeuakbqbqifwavkfkutoriovgfmittulhwojaptacekdirgqoovlleeoqkkdukpadygfwavppohgdrmymmulgci\r\n", "output": ["YES"]}, {"input": "100 93\r\nearrehrehenaddhdnrdddhdahnadndheeennrearrhraharddreaeraddhehhhrdnredanndneheddrraaneerreedhnadnerhdn\r\n", "output": ["YES"]}, {"input": "100 48\r\nbmmaebaebmmmbbmxvmammbvvebvaemvbbaxvbvmaxvvmveaxmbbxaaemxmxvxxxvxbmmxaaaevvaxmvamvvmaxaxavexbmmbmmev\r\n", "output": ["YES"]}, {"input": "100 55\r\nhsavbkehaaesffaeeffakhkhfehbbvbeasahbbbvkesbfvkefeesesevbsvfkbffakvshsbkahfkfakebsvafkbvsskfhfvaasss\r\n", "output": ["YES"]}, {"input": "100 2\r\ncscffcffsccffsfsfffccssfsscfsfsssffcffsscfccssfffcfscfsscsccccfsssffffcfcfsfffcsfsccffscffcfccccfffs\r\n", "output": ["NO"]}, {"input": "100 3\r\nzrgznxgdpgfoiifrrrsjfuhvtqxjlgochhyemismjnanfvvpzzvsgajcbsulxyeoepjfwvhkqogiiwqxjkrpsyaqdlwffoockxnc\r\n", "output": ["NO"]}, {"input": "100 5\r\njbltyyfjakrjeodqepxpkjideulofbhqzxjwlarufwzwsoxhaexpydpqjvhybmvjvntuvhvflokhshpicbnfgsqsmrkrfzcrswwi\r\n", "output": ["NO"]}, {"input": "100 1\r\nfnslnqktlbmxqpvcvnemxcutebdwepoxikifkzaaixzzydffpdxodmsxjribmxuqhueifdlwzytxkklwhljswqvlejedyrgguvah\r\n", "output": ["NO"]}, {"input": "100 21\r\nddjenetwgwmdtjbpzssyoqrtirvoygkjlqhhdcjgeurqpunxpupwaepcqkbjjfhnvgpyqnozhhrmhfwararmlcvpgtnopvjqsrka\r\n", "output": ["YES"]}, {"input": "100 100\r\nnjrhiauqlgkkpkuvciwzivjbbplipvhslqgdkfnmqrxuxnycmpheenmnrglotzuyxycosfediqcuadklsnzjqzfxnbjwvfljnlvq\r\n", "output": ["YES"]}, {"input": "100 100\r\nbbbbbbbtbbttbtbbbttbttbtbbttttbbbtbttbbbtbttbtbbttttbbbbbtbbttbtbbtbttbbbtbtbtbtbtbtbbbttbbtbtbtbbtb\r\n", "output": ["YES"]}, {"input": "14 5\r\nfssmmsfffmfmmm\r\n", "output": ["NO"]}, {"input": "2 1\r\nff\r\n", "output": ["NO"]}, {"input": "2 1\r\nhw\r\n", "output": ["YES"]}, {"input": "2 2\r\nss\r\n", "output": ["YES"]}, {"input": "1 1\r\nl\r\n", "output": ["YES"]}, {"input": "100 50\r\nfffffttttttjjjuuuvvvvvdddxxxxwwwwgggbsssncccczzyyyyyhhhhhkrreeeeeeaaaaaiiillllllllooooqqqqqqmmpppppp\r\n", "output": ["YES"]}, {"input": "100 50\r\nbbbbbbbbgggggggggggaaaaaaaahhhhhhhhhhpppppppppsssssssrrrrrrrrllzzzzzzzeeeeeeekkkkkkkwwwwwwwwjjjjjjjj\r\n", "output": ["YES"]}, {"input": "100 50\r\nwwwwwwwwwwwwwwxxxxxxxxxxxxxxxxxxxxxxxxzzzzzzzzzzzzzzzzzzbbbbbbbbbbbbbbbbbbbbjjjjjjjjjjjjjjjjjjjjjjjj\r\n", "output": ["YES"]}, {"input": "100 80\r\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm\r\n", "output": ["YES"]}, {"input": "100 10\r\nbbttthhhhiiiiiiijjjjjvvvvpppssssseeeeeeewwwwgggkkkkkkkkmmmddddduuuzzzzllllnnnnnxxyyyffffccraaaaooooq\r\n", "output": ["YES"]}, {"input": "100 20\r\nssssssssssbbbbbbbhhhhhhhyyyyyyyzzzzzzzzzzzzcccccxxxxxxxxxxddddmmmmmmmeeeeeeejjjjjjjjjwwwwwwwtttttttt\r\n", "output": ["YES"]}, {"input": "1 2\r\na\r\n", "output": ["YES"]}, {"input": "3 1\r\nabb\r\n", "output": ["NO"]}, {"input": "2 1\r\naa\r\n", "output": ["NO"]}, {"input": "2 1\r\nab\r\n", "output": ["YES"]}, {"input": "6 2\r\naaaaaa\r\n", "output": ["NO"]}, {"input": "8 4\r\naaaaaaaa\r\n", "output": ["NO"]}, {"input": "4 2\r\naaaa\r\n", "output": ["NO"]}, {"input": "4 3\r\naaaa\r\n", "output": ["NO"]}, {"input": "1 3\r\na\r\n", "output": ["YES"]}, {"input": "4 3\r\nzzzz\r\n", "output": ["NO"]}, {"input": "4 1\r\naaaa\r\n", "output": ["NO"]}, {"input": "3 4\r\nabc\r\n", "output": ["YES"]}, {"input": "2 5\r\nab\r\n", "output": ["YES"]}, {"input": "2 4\r\nab\r\n", "output": ["YES"]}, {"input": "1 10\r\na\r\n", "output": ["YES"]}, {"input": "5 2\r\nzzzzz\r\n", "output": ["NO"]}, {"input": "53 26\r\naaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbb\r\n", "output": ["NO"]}, {"input": "4 1\r\nabab\r\n", "output": ["NO"]}, {"input": "4 1\r\nabcb\r\n", "output": ["NO"]}, {"input": "4 2\r\nabbb\r\n", "output": ["NO"]}, {"input": "5 2\r\nabccc\r\n", "output": ["NO"]}, {"input": "2 3\r\nab\r\n", "output": ["YES"]}, {"input": "4 3\r\nbbbs\r\n", "output": ["YES"]}, {"input": "10 2\r\nazzzzzzzzz\r\n", "output": ["NO"]}, {"input": "1 2\r\nb\r\n", "output": ["YES"]}, {"input": "1 3\r\nb\r\n", "output": ["YES"]}, {"input": "4 5\r\nabcd\r\n", "output": ["YES"]}, {"input": "4 6\r\naabb\r\n", "output": ["YES"]}, {"input": "5 2\r\naaaab\r\n", "output": ["NO"]}, {"input": "3 5\r\naaa\r\n", "output": ["YES"]}, {"input": "5 3\r\nazzzz\r\n", "output": ["NO"]}, {"input": "4 100\r\naabb\r\n", "output": ["YES"]}, {"input": "3 10\r\naaa\r\n", "output": ["YES"]}, {"input": "3 4\r\naaa\r\n", "output": ["YES"]}, {"input": "12 5\r\naaaaabbbbbbb\r\n", "output": ["NO"]}, {"input": "5 2\r\naabbb\r\n", "output": ["NO"]}, {"input": "10 5\r\nzzzzzzzzzz\r\n", "output": ["NO"]}, {"input": "2 4\r\naa\r\n", "output": ["YES"]}, {"input": "1 5\r\na\r\n", "output": ["YES"]}, {"input": "10 5\r\naaaaaaaaaa\r\n", "output": ["NO"]}, {"input": "6 3\r\naaaaaa\r\n", "output": ["NO"]}, {"input": "7 1\r\nabcdeee\r\n", "output": ["NO"]}, {"input": "18 3\r\naaaaaabbbbbbcccccc\r\n", "output": ["NO"]}, {"input": "8 2\r\naabbccdd\r\n", "output": ["YES"]}, {"input": "4 2\r\nzzzz\r\n", "output": ["NO"]}, {"input": "4 2\r\nabaa\r\n", "output": ["NO"]}, {"input": "3 2\r\naaa\r\n", "output": ["NO"]}, {"input": "3 1\r\nzzz\r\n", "output": ["NO"]}, {"input": "5 4\r\nzzzzz\r\n", "output": ["NO"]}, {"input": "6 2\r\naabbbc\r\n", "output": ["NO"]}, {"input": "3 6\r\naaa\r\n", "output": ["YES"]}, {"input": "2 1\r\nzz\r\n", "output": ["NO"]}, {"input": "10 3\r\naaaeeeeeee\r\n", "output": ["NO"]}, {"input": "4 5\r\naabb\r\n", "output": ["YES"]}, {"input": "3 1\r\naaa\r\n", "output": ["NO"]}, {"input": "5 2\r\naazzz\r\n", "output": ["NO"]}, {"input": "6 2\r\nabbbbc\r\n", "output": ["NO"]}, {"input": "4 2\r\nxxxx\r\n", "output": ["NO"]}, {"input": "6 3\r\nzzzzzz\r\n", "output": ["NO"]}, {"input": "3 2\r\nabb\r\n", "output": ["YES"]}, {"input": "3 2\r\nzzz\r\n", "output": ["NO"]}, {"input": "6 5\r\nzzzzzz\r\n", "output": ["NO"]}, {"input": "6 3\r\nbcaaaa\r\n", "output": ["NO"]}, {"input": "100 100\r\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n", "output": ["YES"]}, {"input": "3 6\r\nabc\r\n", "output": ["YES"]}]
100
100
100
[{'input': '5 2\r\nzzzzz\r\n', 'output': ['NO']}, {'input': '1 3\r\na\r\n', 'output': ['YES']}, {'input': '75 23\r\nittttiiuitutuiiuuututiuttiuiuutuuuiuiuuuuttuuttuutuiiuiuiiuiitttuututuiuuii\r\n', 'output': ['NO']}, {'input': '3 6\r\naaa\r\n', 'output': ['YES']}, {'input': '1 10\r\na\r\n', 'output': ['YES']}]
[{'input': '49 27\r\noxyorfnkzwsfllnyvdhdanppuzrnbxehugvmlkgeymqjlmfxd\r\n', 'output': ['YES']}, {'input': '100 100\r\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\n', 'output': ['YES']}, {'input': '53 26\r\naaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbb\r\n', 'output': ['NO']}, {'input': '4 1\r\nabcb\r\n', 'output': ['NO']}, {'input': '5 2\r\nabccc\r\n', 'output': ['NO']}]
[{'input': '3 6\r\naaa\r\n', 'output': ['YES']}, {'input': '7 1\r\nabcdeee\r\n', 'output': ['NO']}, {'input': '2 1\r\nhw\r\n', 'output': ['YES']}, {'input': '8 4\r\naaaaaaaa\r\n', 'output': ['NO']}, {'input': '100 100\r\nbbbbbbbtbbttbtbbbttbttbtbbttttbbbtbttbbbtbttbtbbttttbbbbbtbbttbtbbtbttbbbtbtbtbtbtbtbbbttbbtbtbtbbtb\r\n', 'output': ['YES']}]
[{'input': '100 50\r\nfffffttttttjjjuuuvvvvvdddxxxxwwwwgggbsssncccczzyyyyyhhhhhkrreeeeeeaaaaaiiillllllllooooqqqqqqmmpppppp\r\n', 'output': ['YES']}, {'input': '100 100\r\nbbbbbbbtbbttbtbbbttbttbtbbttttbbbtbttbbbtbttbtbbttttbbbbbtbbttbtbbtbttbbbtbtbtbtbtbtbbbttbbtbtbtbbtb\r\n', 'output': ['YES']}, {'input': '4 1\r\nabab\r\n', 'output': ['NO']}, {'input': '100 48\r\nbmmaebaebmmmbbmxvmammbvvebvaemvbbaxvbvmaxvvmveaxmbbxaaemxmxvxxxvxbmmxaaaevvaxmvamvvmaxaxavexbmmbmmev\r\n', 'output': ['YES']}, {'input': '4 1\r\naaaa\r\n', 'output': ['NO']}]
[{'input': '6 2\r\naabbbc\r\n', 'output': ['NO']}, {'input': '3 2\r\naaa\r\n', 'output': ['NO']}, {'input': '4 6\r\naabb\r\n', 'output': ['YES']}, {'input': '32 22\r\ncduamsptaklqtxlyoutlzepxgyfkvngc\r\n', 'output': ['YES']}, {'input': '1 2\r\na\r\n', 'output': ['YES']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
334
100
100
100
["6\n4 1 7 8 3 8\n1"]
The first line of the input contains integer n (1 ≀ n ≀ 100), where n β€” the number of students shouted "Fly, freebie, fly!" The second line contains n positive integers ti (1 ≀ ti ≀ 1000). The last line contains integer T (1 ≀ T ≀ 1000) β€” the time interval during which the freebie was near the dormitory.
086d07bd6f9031df09bd6a6e8fe8f25c
n, t = input(), [0] * 1002 for i in map(int, input().split()): t[i] += 1 T = int(input()) + 1 for i in range(1000): t[i + 1] += t[i] print(max(t[i + T] - t[i] for i in range(-1, 1001 - T)))
["3"]
Python
null
Print a single integer β€” the largest number of people who will pass exam tomorrow because of the freebie visit.
Everyone loves a freebie. Especially students.It is well-known that if in the night before exam a student opens window, opens the student's record-book and shouts loudly three times "Fly, freebie, fly!" β€” then flown freebie helps him to pass the upcoming exam.In the night before the exam on mathematical analysis n students living in dormitory shouted treasured words. The i-th student made a sacrament at the time ti, where ti is the number of seconds elapsed since the beginning of the night.It is known that the freebie is a capricious and willful lady. That night the freebie was near dormitory only for T seconds. Therefore, if for two students their sacrament times differ for more than T, then the freebie didn't visit at least one of them.Since all students are optimists, they really want to know what is the maximal number of students visited by the freebie can be.
[{"input": "6\r\n4 1 7 8 3 8\r\n1\r\n", "output": ["3"]}, {"input": "4\r\n4 2 1 5\r\n2\r\n", "output": ["2"]}, {"input": "10\r\n4 7 1 3 8 5 2 1 8 4\r\n3\r\n", "output": ["6"]}, {"input": "8\r\n39 49 37 28 40 17 50 2\r\n10\r\n", "output": ["3"]}, {"input": "2\r\n1 1\r\n1\r\n", "output": ["2"]}, {"input": "2\r\n1 1\r\n2\r\n", "output": ["2"]}, {"input": "2\r\n1 1\r\n1000\r\n", "output": ["2"]}, {"input": "2\r\n1 2\r\n2\r\n", "output": ["2"]}, {"input": "2\r\n450 826\r\n1000\r\n", "output": ["2"]}, {"input": "3\r\n3 1 1\r\n1\r\n", "output": ["2"]}, {"input": "3\r\n3 1 2\r\n2\r\n", "output": ["3"]}, {"input": "3\r\n3 4 3\r\n1\r\n", "output": ["3"]}, {"input": "3\r\n3 4 3\r\n1\r\n", "output": ["3"]}, {"input": "100\r\n63 69 36 40 74 31 86 42 81 95 60 55 98 98 2 16 84 37 61 47 81 91 85 62 85 32 79 74 65 48 39 60 97 90 59 76 98 73 58 5 16 54 59 42 9 27 95 24 9 6 42 49 64 61 22 27 43 60 39 87 99 57 5 62 48 67 81 36 27 87 41 88 5 33 43 81 82 65 46 52 43 68 85 75 81 99 30 56 67 55 92 4 3 3 66 32 30 45 22 88\r\n5\r\n", "output": ["11"]}, {"input": "100\r\n97 29 39 42 68 100 44 54 6 70 17 100 52 85 67 1 43 49 1 47 98 35 5 38 37 73 84 20 13 15 78 65 29 92 20 40 38 11 12 100 24 94 29 92 83 47 25 63 23 85 85 93 61 60 35 40 96 50 19 15 28 19 98 59 42 14 54 65 2 53 38 9 15 69 43 63 63 8 55 12 81 57 69 21 57 11 99 45 23 31 59 2 16 61 43 36 12 39 42 13\r\n50\r\n", "output": ["62"]}, {"input": "100\r\n31 1 56 82 96 98 25 41 74 73 8 66 95 50 89 77 98 12 69 45 6 10 48 59 1 77 15 77 9 52 66 8 6 71 39 3 58 73 66 45 8 22 67 83 58 6 96 79 46 43 44 90 13 67 56 32 83 96 93 22 49 10 100 79 99 41 13 71 42 96 89 10 84 95 89 7 18 49 16 54 61 35 25 71 26 68 22 40 68 19 30 51 18 20 12 61 11 23 86 72\r\n1\r\n", "output": ["6"]}, {"input": "100\r\n30 74 20 6 3 63 48 45 36 26 33 24 60 71 45 5 19 37 74 100 98 82 67 76 37 46 68 48 56 29 33 19 15 84 76 92 50 53 42 19 5 91 23 38 93 50 39 45 89 17 57 14 86 81 31 6 16 5 80 6 86 49 18 75 30 30 85 94 38 33 50 76 72 32 73 96 28 3 18 20 96 84 89 48 71 64 6 59 87 31 94 24 9 64 15 86 66 11 32 40\r\n90\r\n", "output": ["94"]}, {"input": "100\r\n398 82 739 637 913 962 680 125 963 931 311 680 20 530 795 126 881 666 226 323 594 416 176 6 820 317 866 723 831 432 139 706 608 218 963 550 592 544 874 927 763 468 121 424 91 956 42 442 883 66 299 654 964 730 160 615 515 255 709 278 224 223 304 292 41 450 445 556 477 327 647 518 90 470 894 837 655 495 612 113 746 610 751 486 116 933 314 348 736 58 219 429 976 773 678 642 696 522 161 422\r\n1\r\n", "output": ["3"]}, {"input": "100\r\n760 621 622 793 66 684 411 813 474 404 304 934 319 411 99 965 722 156 681 400 481 462 571 726 696 244 124 350 403 566 564 641 381 494 703 3 348 213 343 390 27 660 46 591 990 931 477 823 890 21 936 267 282 753 599 269 387 443 622 673 473 745 646 224 911 7 155 880 332 932 51 994 144 666 789 691 323 738 192 372 191 246 903 666 929 252 132 614 11 938 298 286 309 596 210 18 143 760 759 584\r\n10\r\n", "output": ["6"]}, {"input": "100\r\n923 357 749 109 685 126 961 437 859 91 985 488 644 777 950 144 479 667 1 535 475 38 843 606 672 333 798 42 595 854 410 914 934 586 329 595 861 321 603 924 434 636 475 395 619 449 336 790 279 931 605 898 276 47 537 935 508 576 168 465 115 884 960 593 883 581 468 426 848 289 525 309 589 106 924 238 829 975 897 373 650 41 952 621 817 46 366 488 924 561 960 449 311 32 517 737 20 765 799 3\r\n100\r\n", "output": ["18"]}, {"input": "100\r\n98 63 672 100 254 218 623 415 426 986 920 915 736 795 407 541 382 213 935 743 961 59 660 512 134 935 248 378 739 356 543 714 28 667 602 596 759 791 103 564 225 520 159 542 966 332 983 655 517 273 95 242 593 940 286 236 41 318 941 727 384 225 319 627 982 359 232 769 854 172 643 598 215 231 305 30 347 469 929 919 90 294 739 641 368 270 932 452 234 741 309 234 357 392 707 873 808 398 417 483\r\n1000\r\n", "output": ["100"]}, {"input": "100\r\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\r\n1\r\n", "output": ["100"]}, {"input": "100\r\n2 1 1 1 2 2 2 2 2 2 1 1 1 1 2 2 1 1 1 2 2 1 1 1 1 2 1 2 1 2 1 2 1 2 2 2 1 1 2 1 2 2 1 1 2 2 2 2 2 1 1 2 1 1 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 2 1 2 2 1 1 1 2 2 2 1 1 2 2 1 2 2 2 1 2 2 1 2 2\r\n1\r\n", "output": ["100"]}, {"input": "100\r\n3 3 1 2 3 3 1 3 3 2 2 2 2 1 2 3 2 1 2 2 2 2 3 2 1 3 3 3 2 1 3 1 2 1 1 2 2 3 2 2 3 1 1 3 1 2 1 3 3 1 1 3 1 3 2 3 3 2 2 2 2 1 1 1 2 1 1 2 1 1 1 1 1 3 2 2 1 3 1 1 3 1 2 2 1 3 1 1 1 1 2 2 2 3 2 2 3 1 1 3\r\n1\r\n", "output": ["72"]}, {"input": "100\r\n2 1 3 4 1 1 4 1 3 2 1 4 4 4 4 4 3 2 1 1 2 2 1 3 3 1 1 1 2 3 4 3 1 1 1 4 2 2 2 2 4 1 2 4 2 2 4 3 3 4 1 2 4 1 3 4 1 2 1 2 1 3 3 2 1 1 4 2 1 3 3 2 3 4 1 2 2 4 2 1 4 3 4 3 1 4 3 1 2 3 3 3 2 4 1 1 4 1 2 3\r\n1\r\n", "output": ["55"]}, {"input": "100\r\n5 1 3 1 2 3 2 5 5 2 5 1 1 4 1 1 3 5 3 3 3 3 4 4 3 5 4 1 1 3 1 4 2 5 2 5 4 2 3 5 1 3 5 5 5 2 2 5 1 4 1 5 1 5 1 3 3 2 2 4 3 2 1 4 2 5 4 1 2 1 4 3 3 5 4 3 5 5 1 2 4 1 4 2 1 1 2 5 3 3 4 1 3 3 3 5 4 1 1 1\r\n1\r\n", "output": ["41"]}, {"input": "100\r\n1 7 8 10 9 4 2 1 6 5 10 6 3 1 10 1 8 4 3 1 7 4 3 7 4 9 1 3 3 5 10 3 7 10 10 10 3 6 2 8 1 3 3 6 2 8 3 7 8 3 4 1 6 4 4 2 10 6 2 10 10 1 7 8 8 1 9 8 7 8 5 2 5 9 2 5 7 10 3 9 8 3 9 4 3 8 6 8 2 8 9 6 7 10 7 9 6 4 4 8\r\n1\r\n", "output": ["24"]}, {"input": "1\r\n1\r\n1\r\n", "output": ["1"]}, {"input": "1\r\n1\r\n1000\r\n", "output": ["1"]}, {"input": "1\r\n849\r\n1\r\n", "output": ["1"]}]
100
100
100
[{'input': '1\r\n849\r\n1\r\n', 'output': ['1']}, {'input': '3\r\n3 1 1\r\n1\r\n', 'output': ['2']}, {'input': '100\r\n923 357 749 109 685 126 961 437 859 91 985 488 644 777 950 144 479 667 1 535 475 38 843 606 672 333 798 42 595 854 410 914 934 586 329 595 861 321 603 924 434 636 475 395 619 449 336 790 279 931 605 898 276 47 537 935 508 576 168 465 115 884 960 593 883 581 468 426 848 289 525 309 589 106 924 238 829 975 897 373 650 41 952 621 817 46 366 488 924 561 960 449 311 32 517 737 20 765 799 3\r\n100\r\n', 'output': ['18']}, {'input': '100\r\n1 7 8 10 9 4 2 1 6 5 10 6 3 1 10 1 8 4 3 1 7 4 3 7 4 9 1 3 3 5 10 3 7 10 10 10 3 6 2 8 1 3 3 6 2 8 3 7 8 3 4 1 6 4 4 2 10 6 2 10 10 1 7 8 8 1 9 8 7 8 5 2 5 9 2 5 7 10 3 9 8 3 9 4 3 8 6 8 2 8 9 6 7 10 7 9 6 4 4 8\r\n1\r\n', 'output': ['24']}, {'input': '3\r\n3 4 3\r\n1\r\n', 'output': ['3']}]
[{'input': '2\r\n1 1\r\n1\r\n', 'output': ['2']}, {'input': '100\r\n30 74 20 6 3 63 48 45 36 26 33 24 60 71 45 5 19 37 74 100 98 82 67 76 37 46 68 48 56 29 33 19 15 84 76 92 50 53 42 19 5 91 23 38 93 50 39 45 89 17 57 14 86 81 31 6 16 5 80 6 86 49 18 75 30 30 85 94 38 33 50 76 72 32 73 96 28 3 18 20 96 84 89 48 71 64 6 59 87 31 94 24 9 64 15 86 66 11 32 40\r\n90\r\n', 'output': ['94']}, {'input': '3\r\n3 1 1\r\n1\r\n', 'output': ['2']}, {'input': '100\r\n2 1 1 1 2 2 2 2 2 2 1 1 1 1 2 2 1 1 1 2 2 1 1 1 1 2 1 2 1 2 1 2 1 2 2 2 1 1 2 1 2 2 1 1 2 2 2 2 2 1 1 2 1 1 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 2 1 2 2 1 1 1 2 2 2 1 1 2 2 1 2 2 2 1 2 2 1 2 2\r\n1\r\n', 'output': ['100']}, {'input': '3\r\n3 4 3\r\n1\r\n', 'output': ['3']}]
[{'input': '6\r\n4 1 7 8 3 8\r\n1\r\n', 'output': ['3']}, {'input': '100\r\n2 1 1 1 2 2 2 2 2 2 1 1 1 1 2 2 1 1 1 2 2 1 1 1 1 2 1 2 1 2 1 2 1 2 2 2 1 1 2 1 2 2 1 1 2 2 2 2 2 1 1 2 1 1 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 2 1 2 2 1 1 1 2 2 2 1 1 2 2 1 2 2 2 1 2 2 1 2 2\r\n1\r\n', 'output': ['100']}, {'input': '100\r\n30 74 20 6 3 63 48 45 36 26 33 24 60 71 45 5 19 37 74 100 98 82 67 76 37 46 68 48 56 29 33 19 15 84 76 92 50 53 42 19 5 91 23 38 93 50 39 45 89 17 57 14 86 81 31 6 16 5 80 6 86 49 18 75 30 30 85 94 38 33 50 76 72 32 73 96 28 3 18 20 96 84 89 48 71 64 6 59 87 31 94 24 9 64 15 86 66 11 32 40\r\n90\r\n', 'output': ['94']}, {'input': '1\r\n1\r\n1000\r\n', 'output': ['1']}, {'input': '2\r\n1 2\r\n2\r\n', 'output': ['2']}]
[{'input': '2\r\n450 826\r\n1000\r\n', 'output': ['2']}, {'input': '2\r\n1 1\r\n1\r\n', 'output': ['2']}, {'input': '8\r\n39 49 37 28 40 17 50 2\r\n10\r\n', 'output': ['3']}, {'input': '3\r\n3 4 3\r\n1\r\n', 'output': ['3']}, {'input': '2\r\n1 1\r\n2\r\n', 'output': ['2']}]
[{'input': '100\r\n923 357 749 109 685 126 961 437 859 91 985 488 644 777 950 144 479 667 1 535 475 38 843 606 672 333 798 42 595 854 410 914 934 586 329 595 861 321 603 924 434 636 475 395 619 449 336 790 279 931 605 898 276 47 537 935 508 576 168 465 115 884 960 593 883 581 468 426 848 289 525 309 589 106 924 238 829 975 897 373 650 41 952 621 817 46 366 488 924 561 960 449 311 32 517 737 20 765 799 3\r\n100\r\n', 'output': ['18']}, {'input': '100\r\n760 621 622 793 66 684 411 813 474 404 304 934 319 411 99 965 722 156 681 400 481 462 571 726 696 244 124 350 403 566 564 641 381 494 703 3 348 213 343 390 27 660 46 591 990 931 477 823 890 21 936 267 282 753 599 269 387 443 622 673 473 745 646 224 911 7 155 880 332 932 51 994 144 666 789 691 323 738 192 372 191 246 903 666 929 252 132 614 11 938 298 286 309 596 210 18 143 760 759 584\r\n10\r\n', 'output': ['6']}, {'input': '2\r\n1 1\r\n1\r\n', 'output': ['2']}, {'input': '3\r\n3 4 3\r\n1\r\n', 'output': ['3']}, {'input': '3\r\n3 1 1\r\n1\r\n', 'output': ['2']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
335
100
100
100
["60 60 45 55\n80 80 8 32", "60 60 45 55\n80 60 15 25", "50 50 35 45\n90 50 35 45"]
The input contains two lines. Each line has four space-separated integers xi, yi, ri, Ri, that describe the i-th ring; xi and yi are coordinates of the ring's center, ri and Ri are the internal and external radii of the ring correspondingly ( - 100 ≀ xi, yi ≀ 100;Β 1 ≀ ri &lt; Ri ≀ 100). It is guaranteed that the centers of the rings do not coinside.
4c2865e4742a29460ca64860740b84f4
def is_intersect(r1, r2, R, x1, y1, x2, y2): d = (x1 - x2)**2 + (y1 - y2)**2 return d >= (r1 + R)**2 or r1 < r2 and d <= (r2 - r1)**2 or R < r1 and d <= (r1 - R)**2 x1, y1, r1, R1 = map(int, input().split()) x2, y2, r2, R2 = map(int, input().split()) res1 = is_intersect(r1, r2, R2, x1, y1, x2, y2) res2 = is_intersect(R1, r2, R2, x1, y1, x2, y2) res3 = is_intersect(r2, r1, R1, x2, y2, x1, y1) res4 = is_intersect(R2, r1, R1, x2, y2, x1, y1) print(res1 + res2 + res3 + res4)
["1", "4", "0"]
Python
NoteFigures for test samples are given below. The possible cuts are marked with red dotted line.
A single integer β€” the number of ways to cut out a circle from the canvas.
A renowned abstract artist Sasha, drawing inspiration from nowhere, decided to paint a picture entitled "Special Olympics". He justly thought that, if the regular Olympic games have five rings, then the Special ones will do with exactly two rings just fine.Let us remind you that a ring is a region located between two concentric circles with radii r and R (r &lt; R). These radii are called internal and external, respectively. Concentric circles are circles with centers located at the same point.Soon a white canvas, which can be considered as an infinite Cartesian plane, had two perfect rings, painted with solid black paint. As Sasha is very impulsive, the rings could have different radii and sizes, they intersect and overlap with each other in any way. We know only one thing for sure: the centers of the pair of rings are not the same.When Sasha got tired and fell into a deep sleep, a girl called Ilona came into the room and wanted to cut a circle for the sake of good memories. To make the circle beautiful, she decided to cut along the contour.We'll consider a contour to be a continuous closed line through which there is transition from one color to another (see notes for clarification). If the contour takes the form of a circle, then the result will be cutting out a circle, which Iona wants.But the girl's inquisitive mathematical mind does not rest: how many ways are there to cut a circle out of the canvas?
[{"input": "60 60 45 55\r\n80 80 8 32\r\n", "output": ["1"]}, {"input": "60 60 45 55\r\n80 60 15 25\r\n", "output": ["4"]}, {"input": "50 50 35 45\r\n90 50 35 45\r\n", "output": ["0"]}, {"input": "0 0 50 70\r\n1 0 60 80\r\n", "output": ["2"]}, {"input": "0 0 1 2\r\n10 0 2 20\r\n", "output": ["2"]}, {"input": "31 13 22 95\r\n48 63 21 98\r\n", "output": ["0"]}, {"input": "31 40 37 76\r\n48 65 66 98\r\n", "output": ["0"]}, {"input": "-65 -81 37 76\r\n48 65 66 98\r\n", "output": ["4"]}, {"input": "41 -14 37 76\r\n48 65 66 98\r\n", "output": ["0"]}, {"input": "41 -14 16 100\r\n48 17 37 66\r\n", "output": ["1"]}, {"input": "-75 -9 20 40\r\n25 55 99 100\r\n", "output": ["0"]}, {"input": "-45 6 20 40\r\n35 6 99 100\r\n", "output": ["0"]}, {"input": "-3 84 20 40\r\n76 96 96 100\r\n", "output": ["0"]}, {"input": "10 -91 20 40\r\n70 -91 79 100\r\n", "output": ["1"]}, {"input": "-64 -47 20 40\r\n-5 -37 79 100\r\n", "output": ["1"]}, {"input": "-63 97 20 40\r\n-34 97 11 48\r\n", "output": ["0"]}, {"input": "-67 47 20 40\r\n-38 47 11 49\r\n", "output": ["0"]}, {"input": "-100 -91 20 40\r\n-71 -91 11 68\r\n", "output": ["0"]}, {"input": "45 -76 20 40\r\n69 -69 15 65\r\n", "output": ["1"]}, {"input": "12 -43 20 40\r\n41 -43 11 97\r\n", "output": ["1"]}, {"input": "10 71 20 40\r\n39 78 10 49\r\n", "output": ["0"]}, {"input": "56 44 20 40\r\n83 44 12 13\r\n", "output": ["1"]}, {"input": "-20 78 20 40\r\n8 85 10 11\r\n", "output": ["1"]}, {"input": "65 -9 20 40\r\n94 -9 10 49\r\n", "output": ["0"]}, {"input": "-84 -59 20 40\r\n-74 -59 29 30\r\n", "output": ["1"]}, {"input": "33 -37 20 40\r\n42 -37 28 29\r\n", "output": ["1"]}, {"input": "-25 10 20 40\r\n4 17 10 69\r\n", "output": ["0"]}, {"input": "13 32 20 40\r\n42 32 10 69\r\n", "output": ["1"]}, {"input": "-12 -1 20 40\r\n-3 -1 28 31\r\n", "output": ["1"]}, {"input": "48 30 20 40\r\n77 37 10 99\r\n", "output": ["1"]}, {"input": "47 -50 20 40\r\n56 -46 28 30\r\n", "output": ["1"]}, {"input": "-26 -65 20 40\r\n52 -65 98 100\r\n", "output": ["1"]}, {"input": "-46 36 20 40\r\n14 36 80 100\r\n", "output": ["2"]}, {"input": "19 96 20 40\r\n77 96 78 99\r\n", "output": ["2"]}, {"input": "-42 -44 20 40\r\n-32 -44 30 48\r\n", "output": ["1"]}, {"input": "83 -23 20 40\r\n93 -23 30 50\r\n", "output": ["2"]}, {"input": "-100 -97 20 40\r\n-90 -97 30 100\r\n", "output": ["2"]}, {"input": "65 16 20 40\r\n74 16 29 48\r\n", "output": ["1"]}, {"input": "-66 78 20 40\r\n-62 81 25 45\r\n", "output": ["2"]}, {"input": "-11 63 20 40\r\n-2 63 29 31\r\n", "output": ["2"]}, {"input": "91 -59 20 40\r\n100 -59 29 100\r\n", "output": ["2"]}, {"input": "39 90 20 40\r\n47 90 28 31\r\n", "output": ["2"]}, {"input": "-100 40 20 40\r\n-81 40 1 38\r\n", "output": ["1"]}, {"input": "24 -24 20 40\r\n43 -24 1 21\r\n", "output": ["2"]}, {"input": "-8 35 20 40\r\n11 35 1 19\r\n", "output": ["2"]}, {"input": "-52 -94 20 40\r\n-33 -94 1 39\r\n", "output": ["1"]}, {"input": "61 2 20 40\r\n67 10 10 30\r\n", "output": ["2"]}, {"input": "49 -67 20 40\r\n57 -67 12 28\r\n", "output": ["2"]}, {"input": "65 17 20 40\r\n84 17 1 58\r\n", "output": ["1"]}, {"input": "-16 -18 20 40\r\n3 -18 1 59\r\n", "output": ["2"]}, {"input": "24 -16 20 40\r\n33 -16 11 31\r\n", "output": ["2"]}, {"input": "-83 96 20 40\r\n-64 96 1 98\r\n", "output": ["2"]}, {"input": "-10 89 20 40\r\n-2 89 12 29\r\n", "output": ["2"]}, {"input": "-40 -69 20 40\r\n60 -69 80 100\r\n", "output": ["0"]}, {"input": "-70 66 20 40\r\n8 66 58 98\r\n", "output": ["0"]}, {"input": "-11 -97 20 40\r\n67 -97 58 100\r\n", "output": ["0"]}, {"input": "-60 60 20 40\r\n0 60 40 100\r\n", "output": ["1"]}, {"input": "0 73 20 40\r\n59 73 39 100\r\n", "output": ["1"]}, {"input": "28 -91 20 40\r\n58 -91 10 49\r\n", "output": ["0"]}, {"input": "75 72 20 40\r\n99 90 10 50\r\n", "output": ["0"]}, {"input": "-84 74 20 40\r\n-54 74 10 63\r\n", "output": ["0"]}, {"input": "35 -6 20 40\r\n59 12 10 70\r\n", "output": ["1"]}, {"input": "67 41 20 40\r\n97 41 10 98\r\n", "output": ["1"]}, {"input": "-27 -68 20 40\r\n2 -68 9 48\r\n", "output": ["0"]}, {"input": "50 13 20 40\r\n78 13 8 12\r\n", "output": ["1"]}, {"input": "-73 36 20 40\r\n-44 36 9 10\r\n", "output": ["1"]}, {"input": "70 92 20 40\r\n99 92 9 49\r\n", "output": ["0"]}, {"input": "37 -80 20 40\r\n66 -80 9 66\r\n", "output": ["0"]}, {"input": "8 -95 20 40\r\n36 -95 8 68\r\n", "output": ["1"]}, {"input": "-9 77 20 40\r\n20 77 9 100\r\n", "output": ["1"]}, {"input": "-37 20 20 40\r\n41 31 99 100\r\n", "output": ["1"]}, {"input": "-36 28 20 40\r\n24 28 99 100\r\n", "output": ["2"]}, {"input": "-77 -16 20 40\r\n-18 -6 99 100\r\n", "output": ["2"]}, {"input": "-65 24 20 40\r\n-6 24 99 100\r\n", "output": ["4"]}, {"input": "-55 23 20 40\r\n-46 23 31 48\r\n", "output": ["1"]}, {"input": "-37 18 20 40\r\n-30 18 33 47\r\n", "output": ["2"]}, {"input": "-45 -93 20 40\r\n-36 -93 31 99\r\n", "output": ["2"]}, {"input": "-97 -29 20 40\r\n-39 -19 99 100\r\n", "output": ["4"]}, {"input": "14 18 20 40\r\n23 22 30 49\r\n", "output": ["1"]}, {"input": "-90 -38 20 40\r\n-81 -38 30 49\r\n", "output": ["2"]}, {"input": "52 -4 20 40\r\n61 -4 30 31\r\n", "output": ["2"]}, {"input": "-54 46 20 40\r\n-45 50 30 98\r\n", "output": ["2"]}, {"input": "74 -34 20 40\r\n82 -30 30 31\r\n", "output": ["2"]}, {"input": "23 -61 20 40\r\n41 -55 1 37\r\n", "output": ["1"]}, {"input": "57 -86 20 40\r\n75 -86 1 22\r\n", "output": ["2"]}, {"input": "-38 43 20 40\r\n-20 49 1 20\r\n", "output": ["2"]}, {"input": "-19 10 20 40\r\n-2 10 2 37\r\n", "output": ["1"]}, {"input": "64 58 20 40\r\n74 58 7 30\r\n", "output": ["2"]}, {"input": "53 49 20 40\r\n62 49 10 29\r\n", "output": ["2"]}, {"input": "53 80 20 40\r\n70 80 2 3\r\n", "output": ["4"]}, {"input": "73 -41 20 40\r\n91 -35 1 49\r\n", "output": ["1"]}, {"input": "-8 -34 20 40\r\n9 -34 2 57\r\n", "output": ["2"]}, {"input": "51 -40 20 40\r\n60 -40 9 31\r\n", "output": ["2"]}, {"input": "-29 87 20 40\r\n-11 93 1 94\r\n", "output": ["2"]}, {"input": "-64 3 20 40\r\n-55 7 6 30\r\n", "output": ["2"]}, {"input": "24 36 20 40\r\n41 39 1 2\r\n", "output": ["4"]}, {"input": "-56 -64 20 40\r\n44 2 96 100\r\n", "output": ["0"]}, {"input": "-59 -17 20 40\r\n21 -17 59 100\r\n", "output": ["0"]}, {"input": "-43 -3 20 40\r\n57 -3 79 80\r\n", "output": ["1"]}, {"input": "20 57 20 40\r\n99 69 58 100\r\n", "output": ["0"]}, {"input": "36 82 20 40\r\n96 82 38 100\r\n", "output": ["1"]}, {"input": "-55 37 20 40\r\n4 47 38 100\r\n", "output": ["1"]}, {"input": "-58 -4 20 40\r\n42 91 99 100\r\n", "output": ["1"]}, {"input": "28 51 20 40\r\n67 51 1 58\r\n", "output": ["0"]}, {"input": "-79 -62 20 40\r\n-41 -62 2 58\r\n", "output": ["0"]}, {"input": "-19 -10 20 40\r\n20 -10 1 19\r\n", "output": ["1"]}, {"input": "-95 -64 20 40\r\n-56 -64 1 78\r\n", "output": ["0"]}, {"input": "-17 -7 20 40\r\n22 -7 1 79\r\n", "output": ["1"]}, {"input": "-45 86 20 40\r\n-6 86 1 99\r\n", "output": ["1"]}, {"input": "-71 -23 20 40\r\n-32 -23 1 18\r\n", "output": ["1"]}, {"input": "-20 11 20 40\r\n80 11 60 100\r\n", "output": ["1"]}, {"input": "-27 97 20 40\r\n51 97 38 98\r\n", "output": ["1"]}, {"input": "-47 -84 20 40\r\n52 -64 61 81\r\n", "output": ["2"]}, {"input": "-81 99 20 40\r\n-3 99 38 99\r\n", "output": ["1"]}, {"input": "-54 25 20 40\r\n6 25 20 100\r\n", "output": ["2"]}, {"input": "-22 40 20 40\r\n36 40 18 100\r\n", "output": ["2"]}, {"input": "-71 15 20 40\r\n29 90 85 100\r\n", "output": ["2"]}, {"input": "31 -13 20 40\r\n69 -5 1 56\r\n", "output": ["0"]}, {"input": "-46 55 20 40\r\n-17 55 7 11\r\n", "output": ["1"]}, {"input": "-35 25 20 40\r\n-6 32 7 10\r\n", "output": ["1"]}, {"input": "27 -98 20 40\r\n65 -98 1 58\r\n", "output": ["0"]}, {"input": "-100 -19 20 40\r\n-62 -19 1 18\r\n", "output": ["1"]}, {"input": "48 66 20 40\r\n78 66 9 10\r\n", "output": ["2"]}, {"input": "-37 -22 20 40\r\n-8 -22 8 9\r\n", "output": ["2"]}, {"input": "-42 41 20 40\r\n-4 49 1 78\r\n", "output": ["0"]}, {"input": "-2 -27 20 40\r\n35 -27 1 77\r\n", "output": ["1"]}, {"input": "-28 -36 20 40\r\n10 -28 1 100\r\n", "output": ["1"]}, {"input": "-17 31 20 40\r\n21 39 1 14\r\n", "output": ["1"]}, {"input": "1 44 20 40\r\n39 44 1 2\r\n", "output": ["2"]}, {"input": "21 -99 20 40\r\n58 -97 1 2\r\n", "output": ["2"]}, {"input": "-86 -97 20 40\r\n14 -31 79 100\r\n", "output": ["1"]}, {"input": "-33 42 20 40\r\n47 42 39 100\r\n", "output": ["1"]}, {"input": "-79 45 20 40\r\n21 45 57 80\r\n", "output": ["2"]}, {"input": "-99 -66 20 40\r\n-20 -54 39 100\r\n", "output": ["1"]}, {"input": "39 -44 20 40\r\n99 -44 17 100\r\n", "output": ["2"]}, {"input": "10 86 20 40\r\n69 96 19 100\r\n", "output": ["2"]}, {"input": "-72 -4 20 40\r\n28 93 99 100\r\n", "output": ["2"]}, {"input": "-81 -55 20 40\r\n19 20 83 85\r\n", "output": ["4"]}, {"input": "-65 -34 20 40\r\n35 66 99 100\r\n", "output": ["4"]}, {"input": "-91 -46 10 50\r\n-73 -40 30 31\r\n", "output": ["2"]}]
100
100
100
[{'input': '-65 24 20 40\r\n-6 24 99 100\r\n', 'output': ['4']}, {'input': '31 40 37 76\r\n48 65 66 98\r\n', 'output': ['0']}, {'input': '-71 15 20 40\r\n29 90 85 100\r\n', 'output': ['2']}, {'input': '-20 78 20 40\r\n8 85 10 11\r\n', 'output': ['1']}, {'input': '49 -67 20 40\r\n57 -67 12 28\r\n', 'output': ['2']}]
[{'input': '19 96 20 40\r\n77 96 78 99\r\n', 'output': ['2']}, {'input': '-67 47 20 40\r\n-38 47 11 49\r\n', 'output': ['0']}, {'input': '-81 -55 20 40\r\n19 20 83 85\r\n', 'output': ['4']}, {'input': '-64 -47 20 40\r\n-5 -37 79 100\r\n', 'output': ['1']}, {'input': '8 -95 20 40\r\n36 -95 8 68\r\n', 'output': ['1']}]
[{'input': '1 44 20 40\r\n39 44 1 2\r\n', 'output': ['2']}, {'input': '-73 36 20 40\r\n-44 36 9 10\r\n', 'output': ['1']}, {'input': '-81 -55 20 40\r\n19 20 83 85\r\n', 'output': ['4']}, {'input': '-77 -16 20 40\r\n-18 -6 99 100\r\n', 'output': ['2']}, {'input': '28 -91 20 40\r\n58 -91 10 49\r\n', 'output': ['0']}]
[{'input': '19 96 20 40\r\n77 96 78 99\r\n', 'output': ['2']}, {'input': '41 -14 37 76\r\n48 65 66 98\r\n', 'output': ['0']}, {'input': '-67 47 20 40\r\n-38 47 11 49\r\n', 'output': ['0']}, {'input': '-100 -19 20 40\r\n-62 -19 1 18\r\n', 'output': ['1']}, {'input': '-86 -97 20 40\r\n14 -31 79 100\r\n', 'output': ['1']}]
[{'input': '57 -86 20 40\r\n75 -86 1 22\r\n', 'output': ['2']}, {'input': '1 44 20 40\r\n39 44 1 2\r\n', 'output': ['2']}, {'input': '31 40 37 76\r\n48 65 66 98\r\n', 'output': ['0']}, {'input': '-73 36 20 40\r\n-44 36 9 10\r\n', 'output': ['1']}, {'input': '-38 43 20 40\r\n-20 49 1 20\r\n', 'output': ['2']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
336
100
100
100
["5 3 2 3", "5 3 100 1"]
The only line contains four integers $$$k$$$, $$$n$$$, $$$s$$$, $$$p$$$ ($$$1 \le k, n, s, p \le 10^4$$$)Β β€” the number of people, the number of airplanes each should make, the number of airplanes that can be made using one sheet and the number of sheets in one pack, respectively.
73f0c7cfc06a9b04e4766d6aa61fc780
from math import * k, n, s, p = map(int, input().split()) q = k * ceil(n / s) w = ceil(q / p) print(w)
["4", "5"]
Python
NoteIn the first sample they have to buy $$$4$$$ packs of paper: there will be $$$12$$$ sheets in total, and giving $$$2$$$ sheets to each person is enough to suit everyone's needs.In the second sample they have to buy a pack for each person as they can't share sheets.
Print a single integerΒ β€” the minimum number of packs they should buy.
To make a paper airplane, one has to use a rectangular piece of paper. From a sheet of standard size you can make $$$s$$$ airplanes.A group of $$$k$$$ people decided to make $$$n$$$ airplanes each. They are going to buy several packs of paper, each of them containing $$$p$$$ sheets, and then distribute the sheets between the people. Each person should have enough sheets to make $$$n$$$ airplanes. How many packs should they buy?
[{"input": "5 3 2 3\r\n", "output": ["4"]}, {"input": "5 3 100 1\r\n", "output": ["5"]}, {"input": "10000 10000 1 1\r\n", "output": ["100000000"]}, {"input": "1 1 10000 10000\r\n", "output": ["1"]}, {"input": "300 300 21 23\r\n", "output": ["196"]}, {"input": "300 2 37 51\r\n", "output": ["6"]}, {"input": "2 400 23 57\r\n", "output": ["1"]}, {"input": "1 1 1 1\r\n", "output": ["1"]}, {"input": "10000 10000 3 2\r\n", "output": ["16670000"]}, {"input": "1 2 1 2\r\n", "output": ["1"]}, {"input": "1 1 2 2\r\n", "output": ["1"]}, {"input": "1 1 10 10\r\n", "output": ["1"]}, {"input": "5324 5439 32 13\r\n", "output": ["69622"]}, {"input": "9000 1 2432 1\r\n", "output": ["9000"]}, {"input": "230 1234 9124 23\r\n", "output": ["10"]}, {"input": "11 1 1 1\r\n", "output": ["11"]}, {"input": "6246 8489 1227 9\r\n", "output": ["4858"]}, {"input": "9 20 5 7\r\n", "output": ["6"]}]
100
100
100
[{'input': '1 1 2 2\r\n', 'output': ['1']}, {'input': '1 2 1 2\r\n', 'output': ['1']}, {'input': '9 20 5 7\r\n', 'output': ['6']}, {'input': '6246 8489 1227 9\r\n', 'output': ['4858']}, {'input': '10000 10000 3 2\r\n', 'output': ['16670000']}]
[{'input': '5 3 2 3\r\n', 'output': ['4']}, {'input': '10000 10000 1 1\r\n', 'output': ['100000000']}, {'input': '6246 8489 1227 9\r\n', 'output': ['4858']}, {'input': '5 3 100 1\r\n', 'output': ['5']}, {'input': '230 1234 9124 23\r\n', 'output': ['10']}]
[{'input': '300 2 37 51\r\n', 'output': ['6']}, {'input': '10000 10000 3 2\r\n', 'output': ['16670000']}, {'input': '5324 5439 32 13\r\n', 'output': ['69622']}, {'input': '1 1 10000 10000\r\n', 'output': ['1']}, {'input': '230 1234 9124 23\r\n', 'output': ['10']}]
[{'input': '1 2 1 2\r\n', 'output': ['1']}, {'input': '1 1 10000 10000\r\n', 'output': ['1']}, {'input': '300 2 37 51\r\n', 'output': ['6']}, {'input': '9 20 5 7\r\n', 'output': ['6']}, {'input': '10000 10000 3 2\r\n', 'output': ['16670000']}]
[{'input': '300 300 21 23\r\n', 'output': ['196']}, {'input': '6246 8489 1227 9\r\n', 'output': ['4858']}, {'input': '10000 10000 3 2\r\n', 'output': ['16670000']}, {'input': '1 1 1 1\r\n', 'output': ['1']}, {'input': '1 1 10 10\r\n', 'output': ['1']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
337
100
100
100
["30 5 20 20 3 5", "10 4 100 5 5 1"]
The single line of the input contains six integers x, t, a, b, da, db (0 ≀ x ≀ 600;Β 1 ≀ t, a, b, da, db ≀ 300) β€” Valera's result, the contest's duration, the initial cost of the first problem, the initial cost of the second problem, the number of points that the first and the second problem lose per minute, correspondingly. It is guaranteed that at each minute of the contest each problem has a non-negative cost, that is, a - iΒ·da β‰₯ 0 and b - iΒ·db β‰₯ 0 for all 0 ≀ i ≀ t - 1.
f98168cdd72369303b82b5a7ac45c3af
x,t,a,b,c,d=map(int,input().split()) R=range(t) y=x==0 for i in R: if x==a-c*i or x==b-d*i:y=1 for j in R:y|=x==a+b-c*i-d*j print(['NO','YES'][y])
["YES", "NO"]
Python
NoteIn the first sample Valera could have acted like this: he could have submitted the first problem at minute 0 and the second problem β€” at minute 2. Then the first problem brings him 20 points and the second problem brings him 10 points, that in total gives the required 30 points.
If Valera could have earned exactly x points at a contest, print "YES", otherwise print "NO" (without the quotes).
A boy Valera registered on site Codeforces as Valera, and wrote his first Codeforces Round #300. He boasted to a friend Arkady about winning as much as x points for his first contest. But Arkady did not believe his friend's words and decided to check whether Valera could have shown such a result.He knows that the contest number 300 was unusual because there were only two problems. The contest lasted for t minutes, the minutes are numbered starting from zero. The first problem had the initial cost of a points, and every minute its cost reduced by da points. The second problem had the initial cost of b points, and every minute this cost reduced by db points. Thus, as soon as the zero minute of the contest is over, the first problem will cost a - da points, and the second problem will cost b - db points. It is guaranteed that at any moment of the contest each problem has a non-negative cost.Arkady asks you to find out whether Valera could have got exactly x points for this contest. You should assume that Valera could have solved any number of the offered problems. You should also assume that for each problem Valera made no more than one attempt, besides, he could have submitted both problems at the same minute of the contest, starting with minute 0 and ending with minute number t - 1. Please note that Valera can't submit a solution exactly t minutes after the start of the contest or later.
[{"input": "30 5 20 20 3 5\r\n", "output": ["YES"]}, {"input": "10 4 100 5 5 1\r\n", "output": ["NO"]}, {"input": "0 7 30 50 3 4\r\n", "output": ["YES"]}, {"input": "50 10 30 20 1 2\r\n", "output": ["YES"]}, {"input": "40 1 40 5 11 2\r\n", "output": ["YES"]}, {"input": "35 8 20 20 1 2\r\n", "output": ["YES"]}, {"input": "10 2 27 4 11 1\r\n", "output": ["NO"]}, {"input": "64 12 258 141 10 7\r\n", "output": ["YES"]}, {"input": "5 3 11 100 2 4\r\n", "output": ["NO"]}, {"input": "5 4 11 80 2 4\r\n", "output": ["YES"]}, {"input": "28 3 16 20 3 10\r\n", "output": ["NO"]}, {"input": "6 2 11 1 11 1\r\n", "output": ["NO"]}, {"input": "15 5 230 213 32 25\r\n", "output": ["NO"]}, {"input": "223 92 123 118 1 1\r\n", "output": ["YES"]}, {"input": "375 6 133 267 19 36\r\n", "output": ["NO"]}, {"input": "80 5 39 40 1 1\r\n", "output": ["NO"]}, {"input": "543 4 31 69 6 5\r\n", "output": ["NO"]}, {"input": "38 100 99 245 1 1\r\n", "output": ["YES"]}, {"input": "3 1 20 15 17 5\r\n", "output": ["NO"]}, {"input": "360 5 215 4 52 1\r\n", "output": ["NO"]}, {"input": "363 2 280 239 5 231\r\n", "output": ["NO"]}, {"input": "46 7 18 6 3 1\r\n", "output": ["NO"]}, {"input": "5 3 135 12 21 6\r\n", "output": ["NO"]}, {"input": "15 5 230 213 32 25\r\n", "output": ["NO"]}, {"input": "2 5 29 36 5 6\r\n", "output": ["NO"]}, {"input": "59 4 113 45 25 12\r\n", "output": ["YES"]}, {"input": "74 72 104 71 1 1\r\n", "output": ["YES"]}, {"input": "16 24 26 23 1 1\r\n", "output": ["YES"]}, {"input": "11 1 10 1 10 1\r\n", "output": ["YES"]}, {"input": "13 3 11 14 5 1\r\n", "output": ["YES"]}, {"input": "1 2 1 2 1 2\r\n", "output": ["YES"]}, {"input": "145 26 25 150 1 4\r\n", "output": ["YES"]}, {"input": "59 18 50 17 1 1\r\n", "output": ["YES"]}, {"input": "230 125 175 124 1 1\r\n", "output": ["YES"]}, {"input": "142 1 66 76 18 39\r\n", "output": ["YES"]}, {"input": "0 3 5 6 1 2\r\n", "output": ["YES"]}, {"input": "6 46 95 45 1 1\r\n", "output": ["YES"]}, {"input": "16 73 92 72 1 1\r\n", "output": ["YES"]}, {"input": "3 18 272 17 6 1\r\n", "output": ["YES"]}, {"input": "1 21 178 20 1 1\r\n", "output": ["YES"]}, {"input": "0 15 86 84 5 2\r\n", "output": ["YES"]}, {"input": "0 35 208 98 6 2\r\n", "output": ["YES"]}, {"input": "0 11 67 82 6 4\r\n", "output": ["YES"]}, {"input": "30 9 18 83 1 7\r\n", "output": ["NO"]}, {"input": "18 12 11 54 1 3\r\n", "output": ["NO"]}, {"input": "41 77 96 145 1 1\r\n", "output": ["YES"]}, {"input": "27 45 44 169 1 2\r\n", "output": ["YES"]}, {"input": "50 5 30 60 3 3\r\n", "output": ["NO"]}, {"input": "49 2 50 20 2 1\r\n", "output": ["NO"]}, {"input": "49 2 50 20 2 1\r\n", "output": ["NO"]}, {"input": "17 10 10 20 1 2\r\n", "output": ["YES"]}]
100
100
100
[{'input': '17 10 10 20 1 2\r\n', 'output': ['YES']}, {'input': '80 5 39 40 1 1\r\n', 'output': ['NO']}, {'input': '30 5 20 20 3 5\r\n', 'output': ['YES']}, {'input': '5 4 11 80 2 4\r\n', 'output': ['YES']}, {'input': '0 35 208 98 6 2\r\n', 'output': ['YES']}]
[{'input': '80 5 39 40 1 1\r\n', 'output': ['NO']}, {'input': '10 4 100 5 5 1\r\n', 'output': ['NO']}, {'input': '543 4 31 69 6 5\r\n', 'output': ['NO']}, {'input': '1 21 178 20 1 1\r\n', 'output': ['YES']}, {'input': '142 1 66 76 18 39\r\n', 'output': ['YES']}]
[{'input': '363 2 280 239 5 231\r\n', 'output': ['NO']}, {'input': '50 10 30 20 1 2\r\n', 'output': ['YES']}, {'input': '41 77 96 145 1 1\r\n', 'output': ['YES']}, {'input': '27 45 44 169 1 2\r\n', 'output': ['YES']}, {'input': '5 4 11 80 2 4\r\n', 'output': ['YES']}]
[{'input': '2 5 29 36 5 6\r\n', 'output': ['NO']}, {'input': '360 5 215 4 52 1\r\n', 'output': ['NO']}, {'input': '74 72 104 71 1 1\r\n', 'output': ['YES']}, {'input': '223 92 123 118 1 1\r\n', 'output': ['YES']}, {'input': '16 24 26 23 1 1\r\n', 'output': ['YES']}]
[{'input': '6 2 11 1 11 1\r\n', 'output': ['NO']}, {'input': '38 100 99 245 1 1\r\n', 'output': ['YES']}, {'input': '2 5 29 36 5 6\r\n', 'output': ['NO']}, {'input': '46 7 18 6 3 1\r\n', 'output': ['NO']}, {'input': '3 1 20 15 17 5\r\n', 'output': ['NO']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
338
100
100
100
["6 4\n1 2 5 10 15 20", "4 10\n1 3 2 4", "6 100\n1 2 3 4 5 6"]
First line of the input contains an integer $$$n$$$ ($$$2 \le n \le 100$$$) and an integer $$$B$$$ ($$$1 \le B \le 100$$$)Β β€” the number of elements in the sequence and the number of bitcoins you have. Second line contains $$$n$$$ integers: $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$1 \le a_i \le 100$$$)Β β€” elements of the sequence, which contains the equal number of even and odd numbers
b3f8e769ee7719ea5c9f458428b16a4e
n, B = [int(x) for x in input().split()] arr = [int(x) for x in input().split()] poss_Splits = [] ps = 0 ptlan = 0 for i in range(n - 1): if arr[i] % 2 == 0: ps += 1 else: ptlan += 1 if ps == ptlan: poss_Splits.append((abs(arr[i] - arr[i + 1]), i)) poss_Splits = sorted(poss_Splits) i = 0 while i < len(poss_Splits) and B >= poss_Splits[i][0]: B -= poss_Splits[i][0] i += 1 print(i)
["1", "0", "2"]
Python
NoteIn the first sample the optimal answer is to split sequence between $$$2$$$ and $$$5$$$. Price of this cut is equal to $$$3$$$ bitcoins.In the second sample it is not possible to make even one cut even with unlimited number of bitcoins.In the third sample the sequence should be cut between $$$2$$$ and $$$3$$$, and between $$$4$$$ and $$$5$$$. The total price of the cuts is $$$1 + 1 = 2$$$ bitcoins.
Print the maximum possible number of cuts which can be made while spending no more than $$$B$$$ bitcoins.
There are a lot of things which could be cutΒ β€” trees, paper, "the rope". In this problem you are going to cut a sequence of integers.There is a sequence of integers, which contains the equal number of even and odd numbers. Given a limited budget, you need to make maximum possible number of cuts such that each resulting segment will have the same number of odd and even integers.Cuts separate a sequence to continuous (contiguous) segments. You may think about each cut as a break between two adjacent elements in a sequence. So after cutting each element belongs to exactly one segment. Say, $$$[4, 1, 2, 3, 4, 5, 4, 4, 5, 5]$$$ $$$\to$$$ two cuts $$$\to$$$ $$$[4, 1 | 2, 3, 4, 5 | 4, 4, 5, 5]$$$. On each segment the number of even elements should be equal to the number of odd elements.The cost of the cut between $$$x$$$ and $$$y$$$ numbers is $$$|x - y|$$$ bitcoins. Find the maximum possible number of cuts that can be made while spending no more than $$$B$$$ bitcoins.
[{"input": "6 4\r\n1 2 5 10 15 20\r\n", "output": ["1"]}, {"input": "4 10\r\n1 3 2 4\r\n", "output": ["0"]}, {"input": "6 100\r\n1 2 3 4 5 6\r\n", "output": ["2"]}, {"input": "2 100\r\n13 78\r\n", "output": ["0"]}, {"input": "10 1\r\n56 56 98 2 11 64 97 41 95 53\r\n", "output": ["0"]}, {"input": "10 100\r\n94 65 24 47 29 98 20 65 6 17\r\n", "output": ["2"]}, {"input": "100 1\r\n35 6 19 84 49 64 36 91 50 65 21 86 20 89 10 52 50 24 98 74 11 48 58 98 51 85 1 29 44 83 9 97 68 41 83 57 1 57 46 42 87 2 32 50 3 57 17 77 22 100 36 27 3 34 55 8 90 61 34 20 15 39 43 46 60 60 14 23 4 22 75 51 98 23 69 22 99 57 63 30 79 7 16 8 34 84 13 47 93 40 48 25 93 1 80 6 82 93 6 21\r\n", "output": ["0"]}, {"input": "100 10\r\n3 20 3 29 90 69 2 30 70 28 71 99 22 99 34 70 87 48 3 92 71 61 26 90 14 38 51 81 16 33 49 71 14 52 50 95 65 16 80 57 87 47 29 14 40 31 74 15 87 76 71 61 30 91 44 10 87 48 84 12 77 51 25 68 49 38 79 8 7 9 39 19 48 40 15 53 29 4 60 86 76 84 6 37 45 71 46 38 80 68 94 71 64 72 41 51 71 60 79 7\r\n", "output": ["2"]}, {"input": "100 100\r\n60 83 82 16 17 7 89 6 83 100 85 41 72 44 23 28 64 84 3 23 33 52 93 30 81 38 67 25 26 97 94 78 41 74 74 17 53 51 54 17 20 81 95 76 42 16 16 56 74 69 30 9 82 91 32 13 47 45 97 40 56 57 27 28 84 98 91 5 61 20 3 43 42 26 83 40 34 100 5 63 62 61 72 5 32 58 93 79 7 18 50 43 17 24 77 73 87 74 98 2\r\n", "output": ["11"]}, {"input": "100 100\r\n70 54 10 72 81 84 56 15 27 19 43 100 49 44 52 33 63 40 95 17 58 2 51 39 22 18 82 1 16 99 32 29 24 94 9 98 5 37 47 14 42 73 41 31 79 64 12 6 53 26 68 67 89 13 90 4 21 93 46 74 75 88 66 57 23 7 25 48 92 62 30 8 50 61 38 87 71 34 97 28 80 11 60 91 3 35 86 96 36 20 59 65 83 45 76 77 78 69 85 55\r\n", "output": ["3"]}, {"input": "100 100\r\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\r\n", "output": ["49"]}, {"input": "10 10\r\n94 32 87 13 4 22 85 81 18 95\r\n", "output": ["1"]}, {"input": "10 50\r\n40 40 9 3 64 96 67 19 21 30\r\n", "output": ["1"]}, {"input": "100 50\r\n13 31 29 86 46 10 2 87 94 2 28 31 29 15 64 3 94 71 37 76 9 91 89 38 12 46 53 33 58 11 98 4 37 72 30 52 6 86 40 98 28 6 34 80 61 47 45 69 100 47 91 64 87 41 67 58 88 75 13 81 36 58 66 29 10 27 54 83 44 15 11 33 49 36 61 18 89 26 87 1 99 19 57 21 55 84 20 74 14 43 15 51 2 76 22 92 43 14 72 77\r\n", "output": ["3"]}, {"input": "100 1\r\n78 52 95 76 96 49 53 59 77 100 64 11 9 48 15 17 44 46 21 54 39 68 43 4 32 28 73 6 16 62 72 84 65 86 98 75 33 45 25 3 91 82 2 92 63 88 7 50 97 93 14 22 20 42 60 55 80 85 29 34 56 71 83 38 26 47 90 70 51 41 40 31 37 12 35 99 67 94 1 87 57 8 61 19 23 79 36 18 66 74 5 27 81 69 24 58 13 10 89 30\r\n", "output": ["0"]}, {"input": "100 10\r\n19 55 91 50 31 23 60 84 38 1 22 51 27 76 28 98 11 44 61 63 15 93 52 3 66 16 53 36 18 62 35 85 78 37 73 64 87 74 46 26 82 69 49 33 83 89 56 67 71 25 39 94 96 17 21 6 47 68 34 42 57 81 13 10 54 2 48 80 20 77 4 5 59 30 90 95 45 75 8 88 24 41 40 14 97 32 7 9 65 70 100 99 72 58 92 29 79 12 86 43\r\n", "output": ["0"]}, {"input": "100 50\r\n2 4 82 12 47 63 52 91 87 45 53 1 17 25 64 50 9 13 22 54 21 30 43 24 38 33 68 11 41 78 99 23 28 18 58 67 79 10 71 56 49 61 26 29 59 20 90 74 5 75 89 8 39 95 72 42 66 98 44 32 88 35 92 3 97 55 65 51 77 27 81 76 84 69 73 85 19 46 62 100 60 37 7 36 57 6 14 83 40 48 16 70 96 15 31 93 80 86 94 34\r\n", "output": ["1"]}, {"input": "100 1\r\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\r\n", "output": ["1"]}, {"input": "100 10\r\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\r\n", "output": ["10"]}, {"input": "100 50\r\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\r\n", "output": ["49"]}, {"input": "100 30\r\n2 1 2 2 2 2 1 1 1 2 1 1 2 2 1 2 1 2 2 2 2 1 2 1 2 1 1 2 1 1 2 2 2 1 1 2 1 2 2 2 1 1 1 1 1 2 1 1 1 1 1 2 2 2 2 1 2 1 1 1 2 2 2 2 1 2 2 1 1 1 1 2 2 2 1 2 2 1 2 1 1 2 2 2 1 2 2 1 2 1 1 2 1 1 1 1 2 1 1 2\r\n", "output": ["11"]}, {"input": "100 80\r\n1 1 1 2 2 1 1 2 1 1 1 1 2 2 2 1 2 2 2 2 1 1 2 2 1 1 1 1 2 2 2 1 1 1 1 1 1 1 2 2 2 2 1 2 2 1 2 1 1 1 1 2 2 1 2 2 1 2 2 2 2 2 1 1 2 2 2 2 2 2 1 1 2 1 1 1 2 1 1 2 1 2 1 2 2 1 1 2 1 1 1 1 2 2 2 1 2 2 1 2\r\n", "output": ["12"]}, {"input": "100 30\r\n100 99 100 99 99 100 100 99 100 99 99 100 100 100 99 99 99 100 99 99 99 99 100 99 99 100 100 99 100 99 99 99 100 99 100 100 99 100 100 100 100 100 99 99 100 99 99 100 99 100 99 99 100 100 99 100 99 99 100 99 100 100 100 100 99 99 99 100 99 100 99 100 100 100 99 100 100 100 99 100 99 99 100 100 100 100 99 99 99 100 99 100 100 99 99 99 100 100 99 99\r\n", "output": ["14"]}, {"input": "100 80\r\n99 100 100 100 99 99 99 99 100 99 99 99 99 99 99 99 99 100 100 99 99 99 99 99 100 99 100 99 100 100 100 100 100 99 100 100 99 99 100 100 100 100 100 99 100 99 100 99 99 99 100 99 99 99 99 99 99 99 99 100 99 100 100 99 99 99 99 100 100 100 99 100 100 100 100 100 99 100 100 100 100 100 100 100 100 99 99 99 99 100 99 100 100 100 100 100 99 100 99 100\r\n", "output": ["4"]}, {"input": "100 30\r\n100 100 39 39 39 100 100 39 39 100 39 39 100 39 100 39 100 100 100 100 100 39 100 100 100 39 39 39 100 39 100 100 39 39 100 39 39 39 100 100 39 100 39 100 39 39 100 100 39 100 39 100 39 39 39 100 39 100 39 39 39 100 39 39 100 100 39 39 39 100 100 39 39 39 100 100 100 100 39 100 100 100 39 39 100 39 100 100 39 100 39 100 39 39 100 39 39 100 100 100\r\n", "output": ["5"]}, {"input": "100 80\r\n39 100 39 100 100 100 100 39 39 100 100 39 39 100 39 39 39 39 100 39 39 39 39 100 100 100 100 39 100 39 39 100 100 39 39 100 39 100 39 100 100 39 39 100 39 39 39 100 39 100 39 100 100 100 100 100 100 100 39 100 39 100 100 100 39 39 39 39 39 100 100 100 39 100 100 100 100 39 100 100 39 39 100 39 39 39 100 39 100 39 39 100 100 39 100 39 39 39 100 39\r\n", "output": ["6"]}, {"input": "4 1\r\n1 2 3 4\r\n", "output": ["1"]}, {"input": "4 1\r\n1 2 1 2\r\n", "output": ["1"]}, {"input": "4 4\r\n1 2 6 7\r\n", "output": ["1"]}, {"input": "4 8\r\n1 2 10 11\r\n", "output": ["1"]}, {"input": "6 2\r\n1 2 3 4 5 6\r\n", "output": ["2"]}, {"input": "6 1\r\n1 2 1 2 1 2\r\n", "output": ["1"]}, {"input": "6 4\r\n1 2 4 5 7 8\r\n", "output": ["2"]}, {"input": "6 3\r\n1 2 5 10 15 20\r\n", "output": ["1"]}]
100
100
100
[{'input': '10 10\r\n94 32 87 13 4 22 85 81 18 95\r\n', 'output': ['1']}, {'input': '100 10\r\n3 20 3 29 90 69 2 30 70 28 71 99 22 99 34 70 87 48 3 92 71 61 26 90 14 38 51 81 16 33 49 71 14 52 50 95 65 16 80 57 87 47 29 14 40 31 74 15 87 76 71 61 30 91 44 10 87 48 84 12 77 51 25 68 49 38 79 8 7 9 39 19 48 40 15 53 29 4 60 86 76 84 6 37 45 71 46 38 80 68 94 71 64 72 41 51 71 60 79 7\r\n', 'output': ['2']}, {'input': '100 100\r\n60 83 82 16 17 7 89 6 83 100 85 41 72 44 23 28 64 84 3 23 33 52 93 30 81 38 67 25 26 97 94 78 41 74 74 17 53 51 54 17 20 81 95 76 42 16 16 56 74 69 30 9 82 91 32 13 47 45 97 40 56 57 27 28 84 98 91 5 61 20 3 43 42 26 83 40 34 100 5 63 62 61 72 5 32 58 93 79 7 18 50 43 17 24 77 73 87 74 98 2\r\n', 'output': ['11']}, {'input': '10 1\r\n56 56 98 2 11 64 97 41 95 53\r\n', 'output': ['0']}, {'input': '100 1\r\n35 6 19 84 49 64 36 91 50 65 21 86 20 89 10 52 50 24 98 74 11 48 58 98 51 85 1 29 44 83 9 97 68 41 83 57 1 57 46 42 87 2 32 50 3 57 17 77 22 100 36 27 3 34 55 8 90 61 34 20 15 39 43 46 60 60 14 23 4 22 75 51 98 23 69 22 99 57 63 30 79 7 16 8 34 84 13 47 93 40 48 25 93 1 80 6 82 93 6 21\r\n', 'output': ['0']}]
[{'input': '100 50\r\n13 31 29 86 46 10 2 87 94 2 28 31 29 15 64 3 94 71 37 76 9 91 89 38 12 46 53 33 58 11 98 4 37 72 30 52 6 86 40 98 28 6 34 80 61 47 45 69 100 47 91 64 87 41 67 58 88 75 13 81 36 58 66 29 10 27 54 83 44 15 11 33 49 36 61 18 89 26 87 1 99 19 57 21 55 84 20 74 14 43 15 51 2 76 22 92 43 14 72 77\r\n', 'output': ['3']}, {'input': '6 100\r\n1 2 3 4 5 6\r\n', 'output': ['2']}, {'input': '100 10\r\n19 55 91 50 31 23 60 84 38 1 22 51 27 76 28 98 11 44 61 63 15 93 52 3 66 16 53 36 18 62 35 85 78 37 73 64 87 74 46 26 82 69 49 33 83 89 56 67 71 25 39 94 96 17 21 6 47 68 34 42 57 81 13 10 54 2 48 80 20 77 4 5 59 30 90 95 45 75 8 88 24 41 40 14 97 32 7 9 65 70 100 99 72 58 92 29 79 12 86 43\r\n', 'output': ['0']}, {'input': '4 1\r\n1 2 3 4\r\n', 'output': ['1']}, {'input': '2 100\r\n13 78\r\n', 'output': ['0']}]
[{'input': '100 30\r\n100 100 39 39 39 100 100 39 39 100 39 39 100 39 100 39 100 100 100 100 100 39 100 100 100 39 39 39 100 39 100 100 39 39 100 39 39 39 100 100 39 100 39 100 39 39 100 100 39 100 39 100 39 39 39 100 39 100 39 39 39 100 39 39 100 100 39 39 39 100 100 39 39 39 100 100 100 100 39 100 100 100 39 39 100 39 100 100 39 100 39 100 39 39 100 39 39 100 100 100\r\n', 'output': ['5']}, {'input': '6 4\r\n1 2 4 5 7 8\r\n', 'output': ['2']}, {'input': '100 1\r\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\r\n', 'output': ['1']}, {'input': '100 50\r\n2 4 82 12 47 63 52 91 87 45 53 1 17 25 64 50 9 13 22 54 21 30 43 24 38 33 68 11 41 78 99 23 28 18 58 67 79 10 71 56 49 61 26 29 59 20 90 74 5 75 89 8 39 95 72 42 66 98 44 32 88 35 92 3 97 55 65 51 77 27 81 76 84 69 73 85 19 46 62 100 60 37 7 36 57 6 14 83 40 48 16 70 96 15 31 93 80 86 94 34\r\n', 'output': ['1']}, {'input': '4 1\r\n1 2 3 4\r\n', 'output': ['1']}]
[{'input': '6 1\r\n1 2 1 2 1 2\r\n', 'output': ['1']}, {'input': '100 10\r\n19 55 91 50 31 23 60 84 38 1 22 51 27 76 28 98 11 44 61 63 15 93 52 3 66 16 53 36 18 62 35 85 78 37 73 64 87 74 46 26 82 69 49 33 83 89 56 67 71 25 39 94 96 17 21 6 47 68 34 42 57 81 13 10 54 2 48 80 20 77 4 5 59 30 90 95 45 75 8 88 24 41 40 14 97 32 7 9 65 70 100 99 72 58 92 29 79 12 86 43\r\n', 'output': ['0']}, {'input': '100 1\r\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\r\n', 'output': ['1']}, {'input': '100 50\r\n2 4 82 12 47 63 52 91 87 45 53 1 17 25 64 50 9 13 22 54 21 30 43 24 38 33 68 11 41 78 99 23 28 18 58 67 79 10 71 56 49 61 26 29 59 20 90 74 5 75 89 8 39 95 72 42 66 98 44 32 88 35 92 3 97 55 65 51 77 27 81 76 84 69 73 85 19 46 62 100 60 37 7 36 57 6 14 83 40 48 16 70 96 15 31 93 80 86 94 34\r\n', 'output': ['1']}, {'input': '100 1\r\n78 52 95 76 96 49 53 59 77 100 64 11 9 48 15 17 44 46 21 54 39 68 43 4 32 28 73 6 16 62 72 84 65 86 98 75 33 45 25 3 91 82 2 92 63 88 7 50 97 93 14 22 20 42 60 55 80 85 29 34 56 71 83 38 26 47 90 70 51 41 40 31 37 12 35 99 67 94 1 87 57 8 61 19 23 79 36 18 66 74 5 27 81 69 24 58 13 10 89 30\r\n', 'output': ['0']}]
[{'input': '4 10\r\n1 3 2 4\r\n', 'output': ['0']}, {'input': '6 4\r\n1 2 4 5 7 8\r\n', 'output': ['2']}, {'input': '100 80\r\n39 100 39 100 100 100 100 39 39 100 100 39 39 100 39 39 39 39 100 39 39 39 39 100 100 100 100 39 100 39 39 100 100 39 39 100 39 100 39 100 100 39 39 100 39 39 39 100 39 100 39 100 100 100 100 100 100 100 39 100 39 100 100 100 39 39 39 39 39 100 100 100 39 100 100 100 100 39 100 100 39 39 100 39 39 39 100 39 100 39 39 100 100 39 100 39 39 39 100 39\r\n', 'output': ['6']}, {'input': '100 100\r\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\r\n', 'output': ['49']}, {'input': '100 10\r\n3 20 3 29 90 69 2 30 70 28 71 99 22 99 34 70 87 48 3 92 71 61 26 90 14 38 51 81 16 33 49 71 14 52 50 95 65 16 80 57 87 47 29 14 40 31 74 15 87 76 71 61 30 91 44 10 87 48 84 12 77 51 25 68 49 38 79 8 7 9 39 19 48 40 15 53 29 4 60 86 76 84 6 37 45 71 46 38 80 68 94 71 64 72 41 51 71 60 79 7\r\n', 'output': ['2']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
339
100
100
100
["harry potter", "tom riddle"]
The input consists of a single line containing two space-separated strings: the first and the last names. Each character of each string is a lowercase English letter. The length of each string is between 1 and 10, inclusive.
aed892f2bda10b6aee10dcb834a63709
first_name, last_name = input().split() first_done = first_name.lower() last_done = last_name.lower() login = first_name[0] for i in range(1, len(first_name)): if ord(first_done[i]) < ord(last_done[0]): login += first_name[i] else: break login += last_name[0] print(login)
["hap", "tomr"]
Python
null
Output a single stringΒ β€” alphabetically earliest possible login formed from these names. The output should be given in lowercase as well.
The preferred way to generate user login in Polygon is to concatenate a prefix of the user's first name and a prefix of their last name, in that order. Each prefix must be non-empty, and any of the prefixes can be the full name. Typically there are multiple possible logins for each person.You are given the first and the last name of a user. Return the alphabetically earliest login they can get (regardless of other potential Polygon users).As a reminder, a prefix of a string s is its substring which occurs at the beginning of s: "a", "ab", "abc" etc. are prefixes of string "{abcdef}" but "b" and 'bc" are not. A string a is alphabetically earlier than a string b, if a is a prefix of b, or a and b coincide up to some position, and then a has a letter that is alphabetically earlier than the corresponding letter in b: "a" and "ab" are alphabetically earlier than "ac" but "b" and "ba" are alphabetically later than "ac".
[{"input": "harry potter\r\n", "output": ["hap"]}, {"input": "tom riddle\r\n", "output": ["tomr"]}, {"input": "a qdpinbmcrf\r\n", "output": ["aq"]}, {"input": "wixjzniiub ssdfodfgap\r\n", "output": ["wis"]}, {"input": "z z\r\n", "output": ["zz"]}, {"input": "ertuyivhfg v\r\n", "output": ["ertuv"]}, {"input": "asdfghjkli ware\r\n", "output": ["asdfghjkliw"]}, {"input": "udggmyop ze\r\n", "output": ["udggmyopz"]}, {"input": "fapkdme rtzxovx\r\n", "output": ["fapkdmer"]}, {"input": "mybiqxmnqq l\r\n", "output": ["ml"]}, {"input": "dtbqya fyyymv\r\n", "output": ["df"]}, {"input": "fyclu zokbxiahao\r\n", "output": ["fycluz"]}, {"input": "qngatnviv rdych\r\n", "output": ["qngar"]}, {"input": "ttvnhrnng lqkfulhrn\r\n", "output": ["tl"]}, {"input": "fya fgx\r\n", "output": ["ff"]}, {"input": "nuis zvjjqlre\r\n", "output": ["nuisz"]}, {"input": "ly qtsmze\r\n", "output": ["lq"]}, {"input": "d kgfpjsurfw\r\n", "output": ["dk"]}, {"input": "lwli ewrpu\r\n", "output": ["le"]}, {"input": "rr wldsfubcs\r\n", "output": ["rrw"]}, {"input": "h qart\r\n", "output": ["hq"]}, {"input": "vugvblnzx kqdwdulm\r\n", "output": ["vk"]}, {"input": "xohesmku ef\r\n", "output": ["xe"]}, {"input": "twvvsl wtcyawv\r\n", "output": ["tw"]}, {"input": "obljndajv q\r\n", "output": ["obljndajq"]}, {"input": "jjxwj kxccwx\r\n", "output": ["jjk"]}, {"input": "sk fftzmv\r\n", "output": ["sf"]}, {"input": "cgpegngs aufzxkyyrw\r\n", "output": ["ca"]}, {"input": "reyjzjdvq skuch\r\n", "output": ["res"]}, {"input": "ardaae mxgdulijf\r\n", "output": ["am"]}, {"input": "bgopsdfji uaps\r\n", "output": ["bgopsdfjiu"]}, {"input": "amolfed pun\r\n", "output": ["amolfedp"]}, {"input": "badkiln yort\r\n", "output": ["badkilny"]}, {"input": "aaaaaaaaaz york\r\n", "output": ["aaaaaaaaay"]}, {"input": "bbbbcbbbbd c\r\n", "output": ["bbbbc"]}, {"input": "aa ab\r\n", "output": ["aa"]}, {"input": "ab b\r\n", "output": ["ab"]}, {"input": "aaaaa ab\r\n", "output": ["aa"]}, {"input": "aa a\r\n", "output": ["aa"]}, {"input": "aba b\r\n", "output": ["ab"]}, {"input": "aaaaaaa aaaaaa\r\n", "output": ["aa"]}, {"input": "a a\r\n", "output": ["aa"]}, {"input": "a aa\r\n", "output": ["aa"]}, {"input": "a b\r\n", "output": ["ab"]}, {"input": "b a\r\n", "output": ["ba"]}, {"input": "z a\r\n", "output": ["za"]}, {"input": "aaa a\r\n", "output": ["aa"]}, {"input": "aa aa\r\n", "output": ["aa"]}, {"input": "a aaa\r\n", "output": ["aa"]}, {"input": "aaaaaaaaaa aaaaaaaaaa\r\n", "output": ["aa"]}, {"input": "aaaaaaaaaa a\r\n", "output": ["aa"]}, {"input": "a aaaaaaaaaa\r\n", "output": ["aa"]}, {"input": "zzaa b\r\n", "output": ["zb"]}, {"input": "ca cf\r\n", "output": ["cac"]}, {"input": "abhi ia\r\n", "output": ["abhi"]}, {"input": "aaaa aaaab\r\n", "output": ["aa"]}, {"input": "aar raa\r\n", "output": ["aar"]}, {"input": "harry hotter\r\n", "output": ["hah"]}, {"input": "aaaaaaa a\r\n", "output": ["aa"]}, {"input": "apple pie\r\n", "output": ["ap"]}, {"input": "aaa aaa\r\n", "output": ["aa"]}, {"input": "kabc buba\r\n", "output": ["kab"]}, {"input": "asd ss\r\n", "output": ["as"]}, {"input": "bbb b\r\n", "output": ["bb"]}]
100
100
100
[{'input': 'h qart\r\n', 'output': ['hq']}, {'input': 'cgpegngs aufzxkyyrw\r\n', 'output': ['ca']}, {'input': 'bbb b\r\n', 'output': ['bb']}, {'input': 'lwli ewrpu\r\n', 'output': ['le']}, {'input': 'badkiln yort\r\n', 'output': ['badkilny']}]
[{'input': 'tom riddle\r\n', 'output': ['tomr']}, {'input': 'udggmyop ze\r\n', 'output': ['udggmyopz']}, {'input': 'amolfed pun\r\n', 'output': ['amolfedp']}, {'input': 'aaaaaaaaaz york\r\n', 'output': ['aaaaaaaaay']}, {'input': 'a b\r\n', 'output': ['ab']}]
[{'input': 'vugvblnzx kqdwdulm\r\n', 'output': ['vk']}, {'input': 'aaaaaaaaaa a\r\n', 'output': ['aa']}, {'input': 'd kgfpjsurfw\r\n', 'output': ['dk']}, {'input': 'obljndajv q\r\n', 'output': ['obljndajq']}, {'input': 'bgopsdfji uaps\r\n', 'output': ['bgopsdfjiu']}]
[{'input': 'z a\r\n', 'output': ['za']}, {'input': 'h qart\r\n', 'output': ['hq']}, {'input': 'aaaaaaaaaa aaaaaaaaaa\r\n', 'output': ['aa']}, {'input': 'aa ab\r\n', 'output': ['aa']}, {'input': 'aaaaaaa aaaaaa\r\n', 'output': ['aa']}]
[{'input': 'aaaaaaa aaaaaa\r\n', 'output': ['aa']}, {'input': 'aar raa\r\n', 'output': ['aar']}, {'input': 'a aaa\r\n', 'output': ['aa']}, {'input': 'wixjzniiub ssdfodfgap\r\n', 'output': ['wis']}, {'input': 'd kgfpjsurfw\r\n', 'output': ['dk']}]
100
100
100
100
100
100
100
100
90
100
100
100
100
75
100
340
100
98
95
["7\nj......", "7\n...feon", "7\n.l.r.o."]
First line contains an integer n (6 ≀ n ≀ 8) – the length of the string. Next line contains a string consisting of n characters, each of which is either a lower case english letter (indicating a known letter) or a dot character (indicating an empty cell in the crossword).
ec3d15ff198d1e4ab9fd04dd3b12e6c0
import re input() print(next(filter(re.compile(input()[:-3] + '$').match, ['vapor', 'jolt', 'flar', 'esp', 'umbr', 'leaf', 'glac', 'sylv'])) + 'eon')
["jolteon", "leafeon", "flareon"]
Python
NoteHere's a set of names in a form you can paste into your solution:["vaporeon", "jolteon", "flareon", "espeon", "umbreon", "leafeon", "glaceon", "sylveon"]{"vaporeon", "jolteon", "flareon", "espeon", "umbreon", "leafeon", "glaceon", "sylveon"}
Print a name of the pokemon that Eevee can evolve into that matches the pattern in the input. Use lower case letters only to print the name (in particular, do not capitalize the first letter).
You are solving the crossword problem K from IPSC 2014. You solved all the clues except for one: who does Eevee evolve into? You are not very into pokemons, but quick googling helped you find out, that Eevee can evolve into eight different pokemons: Vaporeon, Jolteon, Flareon, Espeon, Umbreon, Leafeon, Glaceon, and Sylveon.You know the length of the word in the crossword, and you already know some letters. Designers of the crossword made sure that the answer is unambiguous, so you can assume that exactly one pokemon out of the 8 that Eevee evolves into fits the length and the letters given. Your task is to find it.
[{"input": "7\r\nj......\r\n", "output": ["jolteon"]}, {"input": "7\r\n...feon\r\n", "output": ["leafeon"]}, {"input": "7\r\n.l.r.o.\r\n", "output": ["flareon"]}, {"input": "6\r\n.s..o.\r\n", "output": ["espeon"]}, {"input": "7\r\n.mb....\r\n", "output": ["umbreon"]}, {"input": "7\r\nglaceon\r\n", "output": ["glaceon"]}, {"input": "7\r\n.y.....\r\n", "output": ["sylveon"]}, {"input": "8\r\n.a.o.e.n\r\n", "output": ["vaporeon"]}, {"input": "6\r\n......\r\n", "output": ["espeon"]}, {"input": "8\r\n........\r\n", "output": ["vaporeon"]}, {"input": "6\r\n..p...\r\n", "output": ["espeon"]}, {"input": "7\r\n.laceon\r\n", "output": ["glaceon"]}, {"input": "8\r\n..p.....\r\n", "output": ["vaporeon"]}, {"input": "7\r\n..lveon\r\n", "output": ["sylveon"]}, {"input": "7\r\n.l.ceon\r\n", "output": ["glaceon"]}, {"input": "7\r\n.l.c...\r\n", "output": ["glaceon"]}, {"input": "7\r\n..b....\r\n", "output": ["umbreon"]}, {"input": "7\r\n..areon\r\n", "output": ["flareon"]}, {"input": "7\r\n..ar...\r\n", "output": ["flareon"]}, {"input": "7\r\n..lv...\r\n", "output": ["sylveon"]}]
100
100
100
[{'input': '7\r\n.l.c...\r\n', 'output': ['glaceon']}, {'input': '7\r\n.y.....\r\n', 'output': ['sylveon']}, {'input': '7\r\n..lveon\r\n', 'output': ['sylveon']}, {'input': '7\r\n.l.ceon\r\n', 'output': ['glaceon']}, {'input': '8\r\n........\r\n', 'output': ['vaporeon']}]
[{'input': '7\r\n..lveon\r\n', 'output': ['sylveon']}, {'input': '7\r\n.mb....\r\n', 'output': ['umbreon']}, {'input': '7\r\n.laceon\r\n', 'output': ['glaceon']}, {'input': '8\r\n..p.....\r\n', 'output': ['vaporeon']}, {'input': '7\r\n.l.c...\r\n', 'output': ['glaceon']}]
[{'input': '7\r\n.l.ceon\r\n', 'output': ['glaceon']}, {'input': '7\r\n.l.c...\r\n', 'output': ['glaceon']}, {'input': '7\r\n..lv...\r\n', 'output': ['sylveon']}, {'input': '8\r\n..p.....\r\n', 'output': ['vaporeon']}, {'input': '8\r\n........\r\n', 'output': ['vaporeon']}]
[{'input': '6\r\n......\r\n', 'output': ['espeon']}, {'input': '7\r\n..lv...\r\n', 'output': ['sylveon']}, {'input': '7\r\n.laceon\r\n', 'output': ['glaceon']}, {'input': '7\r\n..areon\r\n', 'output': ['flareon']}, {'input': '7\r\n.l.c...\r\n', 'output': ['glaceon']}]
[{'input': '8\r\n..p.....\r\n', 'output': ['vaporeon']}, {'input': '7\r\n..ar...\r\n', 'output': ['flareon']}, {'input': '8\r\n........\r\n', 'output': ['vaporeon']}, {'input': '7\r\n..lv...\r\n', 'output': ['sylveon']}, {'input': '6\r\n......\r\n', 'output': ['espeon']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
341
100
100
100
["-2 1", "2 1", "4 3"]
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.
8c92aac1bef5822848a136a1328346c6
x, y = map(int, input().split()) p = x * x + y * y d = int(p ** 0.5) if d * d == p: print('black') else: if x * y < 0: print('black' if d % 2 else 'white') else: print('white' if d % 2 else 'black')
["white", "black", "black"]
Python
null
Find the required color. All the points between which and the origin of coordinates the distance is integral-value are painted black.
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.
[{"input": "-2 1\r\n", "output": ["white"]}, {"input": "2 1\r\n", "output": ["black"]}, {"input": "4 3\r\n", "output": ["black"]}, {"input": "3 3\r\n", "output": ["black"]}, {"input": "4 4\r\n", "output": ["white"]}, {"input": "-4 4\r\n", "output": ["black"]}, {"input": "4 -4\r\n", "output": ["black"]}, {"input": "-4 -4\r\n", "output": ["white"]}, {"input": "0 0\r\n", "output": ["black"]}, {"input": "0 1\r\n", "output": ["black"]}, {"input": "0 2\r\n", "output": ["black"]}, {"input": "0 1000\r\n", "output": ["black"]}, {"input": "1000 0\r\n", "output": ["black"]}, {"input": "-1000 0\r\n", "output": ["black"]}, {"input": "0 -1000\r\n", "output": ["black"]}, {"input": "1000 -1000\r\n", "output": ["white"]}, {"input": "12 5\r\n", "output": ["black"]}, {"input": "12 -5\r\n", "output": ["black"]}, {"input": "-12 -35\r\n", "output": ["black"]}, {"input": "20 -21\r\n", "output": ["black"]}, {"input": "-677 492\r\n", "output": ["white"]}, {"input": "-673 -270\r\n", "output": ["white"]}, {"input": "-668 970\r\n", "output": ["black"]}, {"input": "-220 208\r\n", "output": ["white"]}, {"input": "-215 -996\r\n", "output": ["black"]}, {"input": "-211 243\r\n", "output": ["black"]}, {"input": "-206 -518\r\n", "output": ["white"]}, {"input": "-201 278\r\n", "output": ["black"]}, {"input": "-196 -484\r\n", "output": ["black"]}, {"input": "902 479\r\n", "output": ["white"]}, {"input": "-441 572\r\n", "output": ["white"]}, {"input": "217 221\r\n", "output": ["white"]}, {"input": "875 -129\r\n", "output": ["white"]}, {"input": "-469 -36\r\n", "output": ["black"]}, {"input": "189 -387\r\n", "output": ["white"]}, {"input": "847 -294\r\n", "output": ["white"]}, {"input": "-496 -644\r\n", "output": ["black"]}, {"input": "-281 -552\r\n", "output": ["white"]}, {"input": "377 -902\r\n", "output": ["black"]}, {"input": "165 -738\r\n", "output": ["white"]}, {"input": "61 -175\r\n", "output": ["black"]}, {"input": "-42 389\r\n", "output": ["black"]}, {"input": "-589 952\r\n", "output": ["black"]}, {"input": "-693 -929\r\n", "output": ["white"]}, {"input": "-796 -365\r\n", "output": ["white"]}, {"input": "658 198\r\n", "output": ["white"]}, {"input": "555 319\r\n", "output": ["black"]}, {"input": "8 882\r\n", "output": ["black"]}, {"input": "-96 -556\r\n", "output": ["black"]}, {"input": "-129 489\r\n", "output": ["black"]}, {"input": "207 -224\r\n", "output": ["black"]}, {"input": "64 0\r\n", "output": ["black"]}, {"input": "17 144\r\n", "output": ["black"]}, {"input": "60 -448\r\n", "output": ["black"]}, {"input": "-399 -40\r\n", "output": ["black"]}, {"input": "128 -504\r\n", "output": ["black"]}, {"input": "0 72\r\n", "output": ["black"]}, {"input": "168 -26\r\n", "output": ["black"]}, {"input": "72 -154\r\n", "output": ["black"]}, {"input": "117 -44\r\n", "output": ["black"]}, {"input": "-72 -646\r\n", "output": ["black"]}, {"input": "253 -204\r\n", "output": ["black"]}, {"input": "-40 198\r\n", "output": ["black"]}, {"input": "-216 -90\r\n", "output": ["black"]}, {"input": "15 -8\r\n", "output": ["black"]}, {"input": "-180 -432\r\n", "output": ["black"]}, {"input": "280 342\r\n", "output": ["black"]}, {"input": "132 224\r\n", "output": ["black"]}, {"input": "-192 -256\r\n", "output": ["black"]}, {"input": "351 -280\r\n", "output": ["black"]}]
100
100
100
[{'input': '253 -204\r\n', 'output': ['black']}, {'input': '-469 -36\r\n', 'output': ['black']}, {'input': '351 -280\r\n', 'output': ['black']}, {'input': '132 224\r\n', 'output': ['black']}, {'input': '4 4\r\n', 'output': ['white']}]
[{'input': '-589 952\r\n', 'output': ['black']}, {'input': '72 -154\r\n', 'output': ['black']}, {'input': '-40 198\r\n', 'output': ['black']}, {'input': '0 2\r\n', 'output': ['black']}, {'input': '0 0\r\n', 'output': ['black']}]
[{'input': '-1000 0\r\n', 'output': ['black']}, {'input': '-211 243\r\n', 'output': ['black']}, {'input': '-206 -518\r\n', 'output': ['white']}, {'input': '902 479\r\n', 'output': ['white']}, {'input': '-4 -4\r\n', 'output': ['white']}]
[{'input': '-4 4\r\n', 'output': ['black']}, {'input': '-668 970\r\n', 'output': ['black']}, {'input': '-215 -996\r\n', 'output': ['black']}, {'input': '555 319\r\n', 'output': ['black']}, {'input': '72 -154\r\n', 'output': ['black']}]
[{'input': '17 144\r\n', 'output': ['black']}, {'input': '875 -129\r\n', 'output': ['white']}, {'input': '-40 198\r\n', 'output': ['black']}, {'input': '-180 -432\r\n', 'output': ['black']}, {'input': '8 882\r\n', 'output': ['black']}]
100
100
100
100
100
100
83.33
100
100
100
75
75
100
100
100
342
100
96.666
90
["78 87", "1 1"]
The first letter contains two space-separated numbers a and b (1 ≀ a, b ≀ 1000) which represent the given summands.
8ccfb9b1fef6a992177cc49bd56fab7b
a, b = input().split() x = int(max(a + b)) + 1 s, v = int(a, x) + int(b, x), 0 while s: s, v = s // x, v + 1 print(v)
["3", "2"]
Python
null
Print a single number β€” the length of the longest answer.
Vasya studies positional numeral systems. Unfortunately, he often forgets to write the base of notation in which the expression is written. Once he saw a note in his notebook saying a + b = ?, and that the base of the positional notation wasn’t written anywhere. Now Vasya has to choose a base p and regard the expression as written in the base p positional notation. Vasya understood that he can get different results with different bases, and some bases are even invalid. For example, expression 78 + 87 in the base 16 positional notation is equal to FF16, in the base 15 positional notation it is equal to 11015, in the base 10 one β€” to 16510, in the base 9 one β€” to 1769, and in the base 8 or lesser-based positional notations the expression is invalid as all the numbers should be strictly less than the positional notation base. Vasya got interested in what is the length of the longest possible expression value. Help him to find this length.The length of a number should be understood as the number of numeric characters in it. For example, the length of the longest answer for 78 + 87 = ? is 3. It is calculated like that in the base 15 (11015), base 10 (16510), base 9 (1769) positional notations, for example, and in some other ones.
[{"input": "78 87\r\n", "output": ["3"]}, {"input": "1 1\r\n", "output": ["2"]}, {"input": "9 7\r\n", "output": ["2"]}, {"input": "11 11\r\n", "output": ["3"]}, {"input": "43 21\r\n", "output": ["3"]}, {"input": "84 89\r\n", "output": ["3"]}, {"input": "12 34\r\n", "output": ["3"]}, {"input": "99 11\r\n", "output": ["3"]}, {"input": "11 99\r\n", "output": ["3"]}, {"input": "99 99\r\n", "output": ["3"]}, {"input": "1 2\r\n", "output": ["2"]}, {"input": "1 3\r\n", "output": ["2"]}, {"input": "2 1\r\n", "output": ["2"]}, {"input": "2 2\r\n", "output": ["2"]}, {"input": "2 3\r\n", "output": ["2"]}, {"input": "3 1\r\n", "output": ["2"]}, {"input": "3 2\r\n", "output": ["2"]}, {"input": "3 3\r\n", "output": ["2"]}, {"input": "1 466\r\n", "output": ["3"]}, {"input": "1 1000\r\n", "output": ["4"]}, {"input": "1 999\r\n", "output": ["4"]}, {"input": "149 1\r\n", "output": ["3"]}, {"input": "999 1\r\n", "output": ["4"]}, {"input": "1000 1\r\n", "output": ["4"]}, {"input": "998 998\r\n", "output": ["4"]}, {"input": "998 999\r\n", "output": ["4"]}, {"input": "998 1000\r\n", "output": ["4"]}, {"input": "999 998\r\n", "output": ["4"]}, {"input": "999 999\r\n", "output": ["4"]}, {"input": "999 1000\r\n", "output": ["4"]}, {"input": "1000 998\r\n", "output": ["4"]}, {"input": "1000 999\r\n", "output": ["4"]}, {"input": "1000 1000\r\n", "output": ["5"]}, {"input": "1000 539\r\n", "output": ["4"]}, {"input": "999 619\r\n", "output": ["4"]}, {"input": "2 511\r\n", "output": ["3"]}, {"input": "877 2\r\n", "output": ["3"]}, {"input": "379 999\r\n", "output": ["4"]}, {"input": "247 1000\r\n", "output": ["4"]}, {"input": "555 555\r\n", "output": ["4"]}, {"input": "208 997\r\n", "output": ["4"]}, {"input": "633 581\r\n", "output": ["4"]}, {"input": "411 517\r\n", "output": ["4"]}, {"input": "836 101\r\n", "output": ["4"]}, {"input": "262 685\r\n", "output": ["4"]}, {"input": "39 269\r\n", "output": ["3"]}, {"input": "464 205\r\n", "output": ["4"]}, {"input": "890 789\r\n", "output": ["4"]}, {"input": "667 373\r\n", "output": ["4"]}, {"input": "840 975\r\n", "output": ["4"]}, {"input": "810 413\r\n", "output": ["4"]}, {"input": "133 851\r\n", "output": ["4"]}, {"input": "104 938\r\n", "output": ["4"]}, {"input": "427 376\r\n", "output": ["4"]}, {"input": "398 815\r\n", "output": ["4"]}, {"input": "721 253\r\n", "output": ["4"]}, {"input": "692 339\r\n", "output": ["4"]}, {"input": "15 778\r\n", "output": ["3"]}, {"input": "986 216\r\n", "output": ["4"]}, {"input": "450 277\r\n", "output": ["3"]}, {"input": "333 1\r\n", "output": ["4"]}, {"input": "499 499\r\n", "output": ["3"]}, {"input": "79 1\r\n", "output": ["2"]}, {"input": "87 1\r\n", "output": ["2"]}, {"input": "47 8\r\n", "output": ["2"]}, {"input": "87 8\r\n", "output": ["3"]}, {"input": "1 11\r\n", "output": ["3"]}]
100
100
100
[{'input': '1000 1000\r\n', 'output': ['5']}, {'input': '986 216\r\n', 'output': ['4']}, {'input': '262 685\r\n', 'output': ['4']}, {'input': '1 999\r\n', 'output': ['4']}, {'input': '99 11\r\n', 'output': ['3']}]
[{'input': '87 8\r\n', 'output': ['3']}, {'input': '78 87\r\n', 'output': ['3']}, {'input': '2 1\r\n', 'output': ['2']}, {'input': '11 99\r\n', 'output': ['3']}, {'input': '1000 1000\r\n', 'output': ['5']}]
[{'input': '2 2\r\n', 'output': ['2']}, {'input': '890 789\r\n', 'output': ['4']}, {'input': '262 685\r\n', 'output': ['4']}, {'input': '999 1000\r\n', 'output': ['4']}, {'input': '3 3\r\n', 'output': ['2']}]
[{'input': '9 7\r\n', 'output': ['2']}, {'input': '998 1000\r\n', 'output': ['4']}, {'input': '208 997\r\n', 'output': ['4']}, {'input': '999 998\r\n', 'output': ['4']}, {'input': '104 938\r\n', 'output': ['4']}]
[{'input': '43 21\r\n', 'output': ['3']}, {'input': '1 466\r\n', 'output': ['3']}, {'input': '3 2\r\n', 'output': ['2']}, {'input': '79 1\r\n', 'output': ['2']}, {'input': '667 373\r\n', 'output': ['4']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
343
100
100
100
["4\n1 1 0 1", "6\n0 1 0 0 1 0", "1\n0"]
The first line contains one integer number n (1 ≀ n ≀ 100). The second line contains n space-separated integer numbers s1, s2, ..., sn (0 ≀ si ≀ 1). 0 corresponds to an unsuccessful game, 1 β€” to a successful one.
c7b1f0b40e310f99936d1c33e4816b95
n = int(input()) t = -1 an = 0 a = list(map(int, input().split())) while a.count(1): an = max(a.index(1) + a.count(1), an) del a[a.index(1)] print(max(an, len(a)))
["3", "4", "1"]
Python
null
Print one integer β€” the maximum number of games Hideo can leave in his CV so that no unsuccessful game comes after a successful one.
Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job.During all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero) from his CV to make a better impression on employers. As a result there should be no unsuccessful game which comes right after successful one in his CV.More formally, you are given an array s1, s2, ..., sn of zeros and ones. Zero corresponds to an unsuccessful game, one β€” to a successful one. Games are given in order they were produced, and Hideo can't swap these values. He should remove some elements from this array in such a way that no zero comes right after one.Besides that, Hideo still wants to mention as much games in his CV as possible. Help this genius of a man determine the maximum number of games he can leave in his CV.
[{"input": "4\r\n1 1 0 1\r\n", "output": ["3"]}, {"input": "6\r\n0 1 0 0 1 0\r\n", "output": ["4"]}, {"input": "1\r\n0\r\n", "output": ["1"]}, {"input": "100\r\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\r\n", "output": ["100"]}, {"input": "100\r\n0 0 1 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 1 1 1 0 0 1 0 1 0 0 0 1 1 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0\r\n", "output": ["80"]}, {"input": "1\r\n1\r\n", "output": ["1"]}, {"input": "100\r\n1 1 0 1 1 0 0 0 0 1 0 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 0 1 1 0 0 1 1 1 0 0 0 1 0 0 1 0 1 1 0 1 0 0 1 0 0 1 1 0 0 1 0 0 1 1 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 1 1 1 0 1 1 0 1 1 1 0 0 1 1 0 0 0 0 1\r\n", "output": ["53"]}, {"input": "100\r\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\r\n", "output": ["100"]}, {"input": "3\r\n1 0 0\r\n", "output": ["2"]}, {"input": "10\r\n1 1 0 0 0 1 1 0 0 0\r\n", "output": ["6"]}, {"input": "90\r\n1 0 0 1 1 0 0 1 0 0 0 0 1 1 1 0 1 0 1 0 0 0 0 1 0 0 1 1 1 1 1 0 0 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 0 1 0 0 1 1 0 0 1 0 0 0 0 1 1 1 0 1 0 1 0 0 0 0 1 0 0 1 1 1 1 1 0 0 0 1 0\r\n", "output": ["52"]}, {"input": "78\r\n0 0 1 0 1 0 1 1 0 0 0 1 1 1 1 0 0 0 1 0 1 1 1 0 1 0 0 0 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 0 0 0 1 0 0 1 0 1 0 1 0 1 0 1 1 1 0 0 1 0 0 0 0 1 0 1 0 0 1 0\r\n", "output": ["42"]}, {"input": "4\r\n1 0 0 1\r\n", "output": ["3"]}, {"input": "2\r\n0 1\r\n", "output": ["2"]}, {"input": "5\r\n0 1 0 0 1\r\n", "output": ["4"]}, {"input": "3\r\n1 0 1\r\n", "output": ["2"]}, {"input": "3\r\n1 1 0\r\n", "output": ["2"]}, {"input": "16\r\n1 1 1 1 1 0 0 0 0 0 1 0 1 0 0 1\r\n", "output": ["9"]}]
100
100
100
[{'input': '6\r\n0 1 0 0 1 0\r\n', 'output': ['4']}, {'input': '78\r\n0 0 1 0 1 0 1 1 0 0 0 1 1 1 1 0 0 0 1 0 1 1 1 0 1 0 0 0 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 0 0 0 1 0 0 1 0 1 0 1 0 1 0 1 1 1 0 0 1 0 0 0 0 1 0 1 0 0 1 0\r\n', 'output': ['42']}, {'input': '16\r\n1 1 1 1 1 0 0 0 0 0 1 0 1 0 0 1\r\n', 'output': ['9']}, {'input': '100\r\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\r\n', 'output': ['100']}, {'input': '4\r\n1 0 0 1\r\n', 'output': ['3']}]
[{'input': '3\r\n1 0 0\r\n', 'output': ['2']}, {'input': '4\r\n1 1 0 1\r\n', 'output': ['3']}, {'input': '5\r\n0 1 0 0 1\r\n', 'output': ['4']}, {'input': '1\r\n1\r\n', 'output': ['1']}, {'input': '100\r\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\r\n', 'output': ['100']}]
[{'input': '3\r\n1 0 1\r\n', 'output': ['2']}, {'input': '100\r\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\r\n', 'output': ['100']}, {'input': '100\r\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\r\n', 'output': ['100']}, {'input': '1\r\n0\r\n', 'output': ['1']}, {'input': '6\r\n0 1 0 0 1 0\r\n', 'output': ['4']}]
[{'input': '90\r\n1 0 0 1 1 0 0 1 0 0 0 0 1 1 1 0 1 0 1 0 0 0 0 1 0 0 1 1 1 1 1 0 0 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 0 1 0 0 1 1 0 0 1 0 0 0 0 1 1 1 0 1 0 1 0 0 0 0 1 0 0 1 1 1 1 1 0 0 0 1 0\r\n', 'output': ['52']}, {'input': '5\r\n0 1 0 0 1\r\n', 'output': ['4']}, {'input': '4\r\n1 0 0 1\r\n', 'output': ['3']}, {'input': '1\r\n0\r\n', 'output': ['1']}, {'input': '78\r\n0 0 1 0 1 0 1 1 0 0 0 1 1 1 1 0 0 0 1 0 1 1 1 0 1 0 0 0 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 0 0 0 1 0 0 1 0 1 0 1 0 1 0 1 1 1 0 0 1 0 0 0 0 1 0 1 0 0 1 0\r\n', 'output': ['42']}]
[{'input': '4\r\n1 0 0 1\r\n', 'output': ['3']}, {'input': '90\r\n1 0 0 1 1 0 0 1 0 0 0 0 1 1 1 0 1 0 1 0 0 0 0 1 0 0 1 1 1 1 1 0 0 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 0 1 0 0 1 1 0 0 1 0 0 0 0 1 1 1 0 1 0 1 0 0 0 0 1 0 0 1 1 1 1 1 0 0 0 1 0\r\n', 'output': ['52']}, {'input': '100\r\n0 0 1 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 1 1 1 0 0 1 0 1 0 0 0 1 1 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0\r\n', 'output': ['80']}, {'input': '2\r\n0 1\r\n', 'output': ['2']}, {'input': '10\r\n1 1 0 0 0 1 1 0 0 0\r\n', 'output': ['6']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
344
100
100
100
["3 1", "2 3", "7 3"]
The single line of the input contains two positive integers a and b (1 ≀ a, b ≀ 100) β€” the number of red and blue socks that Vasya's got.
775766790e91e539c1cfaa5030e5b955
a, b = map(int, input().split()) k = 0 k2 = 0 while a > 0 and b > 0: a -= 1 b -= 1 k += 1 if a > 0: k2 = int(a//2) elif b > 0: k2 = int(b//2) print(k, k2)
["1 1", "2 0", "3 2"]
Python
NoteIn the first sample Vasya can first put on one pair of different socks, after that he has two red socks left to wear on the second day.
Print two space-separated integers β€” the maximum number of days when Vasya can wear different socks and the number of days when he can wear the same socks until he either runs out of socks or cannot make a single pair from the socks he's got. Keep in mind that at the end of the day Vasya throws away the socks that he's been wearing on that day.
One day Vasya the Hipster decided to count how many socks he had. It turned out that he had a red socks and b blue socks.According to the latest fashion, hipsters should wear the socks of different colors: a red one on the left foot, a blue one on the right foot.Every day Vasya puts on new socks in the morning and throws them away before going to bed as he doesn't want to wash them.Vasya wonders, what is the maximum number of days when he can dress fashionable and wear different socks, and after that, for how many days he can then wear the same socks until he either runs out of socks or cannot make a single pair from the socks he's got.Can you help him?
[{"input": "3 1\r\n", "output": ["1 1", "1 1", "1\r\n1"]}, {"input": "2 3\r\n", "output": ["2 0", "2 0", "2\r\n0"]}, {"input": "7 3\r\n", "output": ["3\r\n2", "3 2", "3 2"]}, {"input": "100 100\r\n", "output": ["100 0", "100 0", "100\r\n0"]}, {"input": "4 10\r\n", "output": ["4\r\n3", "4 3", "4 3"]}, {"input": "6 10\r\n", "output": ["6\r\n2", "6 2", "6 2"]}, {"input": "6 11\r\n", "output": ["6\r\n2", "6 2", "6 2"]}, {"input": "10 40\r\n", "output": ["10\r\n15", "10 15", "10 15"]}, {"input": "11 56\r\n", "output": ["11 22", "11\r\n22", "11 22"]}, {"input": "34 30\r\n", "output": ["30\r\n2", "30 2", "30 2"]}, {"input": "33 33\r\n", "output": ["33 0", "33\r\n0", "33 0"]}, {"input": "100 45\r\n", "output": ["45\r\n27", "45 27", "45 27"]}, {"input": "100 23\r\n", "output": ["23 38", "23\r\n38", "23 38"]}, {"input": "45 12\r\n", "output": ["12 16", "12 16", "12\r\n16"]}, {"input": "1 1\r\n", "output": ["1 0", "1\r\n0", "1 0"]}, {"input": "1 100\r\n", "output": ["1 49", "1 49", "1\r\n49"]}, {"input": "100 1\r\n", "output": ["1 49", "1 49", "1\r\n49"]}, {"input": "68 59\r\n", "output": ["59 4", "59\r\n4", "59 4"]}, {"input": "45 99\r\n", "output": ["45\r\n27", "45 27", "45 27"]}, {"input": "99 100\r\n", "output": ["99 0", "99 0", "99\r\n0"]}, {"input": "100 98\r\n", "output": ["98 1", "98\r\n1", "98 1"]}, {"input": "59 12\r\n", "output": ["12 23", "12 23", "12\r\n23"]}, {"input": "86 4\r\n", "output": ["4 41", "4\r\n41", "4 41"]}, {"input": "68 21\r\n", "output": ["21 23", "21 23", "21\r\n23"]}, {"input": "100 11\r\n", "output": ["11 44", "11\r\n44", "11 44"]}, {"input": "100 10\r\n", "output": ["10 45", "10\r\n45", "10 45"]}, {"input": "15 45\r\n", "output": ["15\r\n15", "15 15", "15 15"]}, {"input": "11 32\r\n", "output": ["11\r\n10", "11 10", "11 10"]}, {"input": "34 96\r\n", "output": ["34\r\n31", "34 31", "34 31"]}, {"input": "89 89\r\n", "output": ["89 0", "89 0", "89\r\n0"]}]
100
100
100
[{'input': '45 99\r\n', 'output': ['45\r\n27', '45 27', '45 27']}, {'input': '100 1\r\n', 'output': ['1 49', '1 49', '1\r\n49']}, {'input': '68 21\r\n', 'output': ['21 23', '21 23', '21\r\n23']}, {'input': '100 10\r\n', 'output': ['10 45', '10\r\n45', '10 45']}, {'input': '11 32\r\n', 'output': ['11\r\n10', '11 10', '11 10']}]
[{'input': '2 3\r\n', 'output': ['2 0', '2 0', '2\r\n0']}, {'input': '15 45\r\n', 'output': ['15\r\n15', '15 15', '15 15']}, {'input': '68 59\r\n', 'output': ['59 4', '59\r\n4', '59 4']}, {'input': '11 56\r\n', 'output': ['11 22', '11\r\n22', '11 22']}, {'input': '100 10\r\n', 'output': ['10 45', '10\r\n45', '10 45']}]
[{'input': '10 40\r\n', 'output': ['10\r\n15', '10 15', '10 15']}, {'input': '1 100\r\n', 'output': ['1 49', '1 49', '1\r\n49']}, {'input': '100 98\r\n', 'output': ['98 1', '98\r\n1', '98 1']}, {'input': '33 33\r\n', 'output': ['33 0', '33\r\n0', '33 0']}, {'input': '11 32\r\n', 'output': ['11\r\n10', '11 10', '11 10']}]
[{'input': '10 40\r\n', 'output': ['10\r\n15', '10 15', '10 15']}, {'input': '100 98\r\n', 'output': ['98 1', '98\r\n1', '98 1']}, {'input': '4 10\r\n', 'output': ['4\r\n3', '4 3', '4 3']}, {'input': '100 10\r\n', 'output': ['10 45', '10\r\n45', '10 45']}, {'input': '100 1\r\n', 'output': ['1 49', '1 49', '1\r\n49']}]
[{'input': '100 45\r\n', 'output': ['45\r\n27', '45 27', '45 27']}, {'input': '7 3\r\n', 'output': ['3\r\n2', '3 2', '3 2']}, {'input': '10 40\r\n', 'output': ['10\r\n15', '10 15', '10 15']}, {'input': '34 30\r\n', 'output': ['30\r\n2', '30 2', '30 2']}, {'input': '100 1\r\n', 'output': ['1 49', '1 49', '1\r\n49']}]
100
100
100
100
100
100
100
100
100
100
83.33
83.33
100
83.33
83.33
345
100
100
86.664
["4 3 9", "4 3 24", "2 4 4"]
The only line contains three integers n, m and k (1 ≀ n, m ≀ 10 000, 1 ≀ k ≀ 2nm)Β β€” the number of lanes, the number of desks in each lane and the number of Santa Claus' place.
d6929926b44c2d5b1a8e6b7f965ca1bb
n, m, k = map(int, input().split()) l = (k - 1) // (2 * m) + 1 print(l, ((k - 1) % (2 * m)) // 2 + 1, 'L' if k & 1 else 'R')
["2 2 L", "4 3 R", "1 2 R"]
Python
NoteThe first and the second samples are shown on the picture. The green place corresponds to Santa Claus' place in the first example, the blue place corresponds to Santa Claus' place in the second example.In the third sample there are two lanes with four desks in each, and Santa Claus has the fourth place. Thus, his place is in the first lane at the second desk on the right.
Print two integers: the number of lane r, the number of desk d, and a character s, which stands for the side of the desk Santa Claus. The character s should be "L", if Santa Clause should sit on the left, and "R" if his place is on the right.
Santa Claus is the first who came to the Christmas Olympiad, and he is going to be the first to take his place at a desk! In the classroom there are n lanes of m desks each, and there are two working places at each of the desks. The lanes are numbered from 1 to n from the left to the right, the desks in a lane are numbered from 1 to m starting from the blackboard. Note that the lanes go perpendicularly to the blackboard, not along it (see picture).The organizers numbered all the working places from 1 to 2nm. The places are numbered by lanes (i.Β e. all the places of the first lane go first, then all the places of the second lane, and so on), in a lane the places are numbered starting from the nearest to the blackboard (i.Β e. from the first desk in the lane), at each desk, the place on the left is numbered before the place on the right. The picture illustrates the first and the second samples. Santa Clause knows that his place has number k. Help him to determine at which lane at which desk he should sit, and whether his place is on the left or on the right!
[{"input": "4 3 9\r\n", "output": ["2 2 L"]}, {"input": "4 3 24\r\n", "output": ["4 3 R"]}, {"input": "2 4 4\r\n", "output": ["1 2 R"]}, {"input": "3 10 24\r\n", "output": ["2 2 R"]}, {"input": "10 3 59\r\n", "output": ["10 3 L"]}, {"input": "10000 10000 160845880\r\n", "output": ["8043 2940 R"]}, {"input": "1 1 1\r\n", "output": ["1 1 L"]}, {"input": "1 1 2\r\n", "output": ["1 1 R"]}, {"input": "1 10000 1\r\n", "output": ["1 1 L"]}, {"input": "1 10000 20000\r\n", "output": ["1 10000 R"]}, {"input": "10000 1 1\r\n", "output": ["1 1 L"]}, {"input": "10000 1 10000\r\n", "output": ["5000 1 R"]}, {"input": "10000 1 20000\r\n", "output": ["10000 1 R"]}, {"input": "3 2 1\r\n", "output": ["1 1 L"]}, {"input": "3 2 2\r\n", "output": ["1 1 R"]}, {"input": "3 2 3\r\n", "output": ["1 2 L"]}, {"input": "3 2 4\r\n", "output": ["1 2 R"]}, {"input": "3 2 5\r\n", "output": ["2 1 L"]}, {"input": "3 2 6\r\n", "output": ["2 1 R"]}, {"input": "3 2 7\r\n", "output": ["2 2 L"]}, {"input": "3 2 8\r\n", "output": ["2 2 R"]}, {"input": "3 2 9\r\n", "output": ["3 1 L"]}, {"input": "3 2 10\r\n", "output": ["3 1 R"]}, {"input": "3 2 11\r\n", "output": ["3 2 L"]}, {"input": "3 2 12\r\n", "output": ["3 2 R"]}, {"input": "300 2000 1068628\r\n", "output": ["268 314 R"]}, {"input": "300 2000 584756\r\n", "output": ["147 378 R"]}, {"input": "300 2000 268181\r\n", "output": ["68 91 L"]}, {"input": "10000 9999 186450844\r\n", "output": ["9324 4745 R"]}, {"input": "10000 9999 197114268\r\n", "output": ["9857 6990 R"]}, {"input": "10000 9999 112390396\r\n", "output": ["5621 818 R"]}, {"input": "10000 10000 1\r\n", "output": ["1 1 L"]}, {"input": "10000 10000 2\r\n", "output": ["1 1 R"]}, {"input": "10000 10000 100000001\r\n", "output": ["5001 1 L"]}, {"input": "10000 10000 199999999\r\n", "output": ["10000 10000 L"]}, {"input": "10000 10000 200000000\r\n", "output": ["10000 10000 R"]}, {"input": "1 2 1\r\n", "output": ["1 1 L"]}, {"input": "1 2 2\r\n", "output": ["1 1 R"]}, {"input": "1 2 3\r\n", "output": ["1 2 L"]}, {"input": "1 2 4\r\n", "output": ["1 2 R"]}, {"input": "2 1 1\r\n", "output": ["1 1 L"]}, {"input": "2 1 2\r\n", "output": ["1 1 R"]}, {"input": "2 1 3\r\n", "output": ["2 1 L"]}, {"input": "2 1 4\r\n", "output": ["2 1 R"]}, {"input": "4 3 7\r\n", "output": ["2 1 L"]}, {"input": "1 1 1\r\n", "output": ["1 1 L"]}]
100
100
100
[{'input': '3 2 8\r\n', 'output': ['2 2 R']}, {'input': '1 2 4\r\n', 'output': ['1 2 R']}, {'input': '3 2 12\r\n', 'output': ['3 2 R']}, {'input': '10000 1 20000\r\n', 'output': ['10000 1 R']}, {'input': '10000 9999 197114268\r\n', 'output': ['9857 6990 R']}]
[{'input': '1 2 2\r\n', 'output': ['1 1 R']}, {'input': '10000 10000 1\r\n', 'output': ['1 1 L']}, {'input': '3 2 9\r\n', 'output': ['3 1 L']}, {'input': '3 2 7\r\n', 'output': ['2 2 L']}, {'input': '2 4 4\r\n', 'output': ['1 2 R']}]
[{'input': '1 10000 1\r\n', 'output': ['1 1 L']}, {'input': '3 2 5\r\n', 'output': ['2 1 L']}, {'input': '300 2000 1068628\r\n', 'output': ['268 314 R']}, {'input': '1 1 1\r\n', 'output': ['1 1 L']}, {'input': '2 1 2\r\n', 'output': ['1 1 R']}]
[{'input': '10000 10000 2\r\n', 'output': ['1 1 R']}, {'input': '1 10000 20000\r\n', 'output': ['1 10000 R']}, {'input': '1 2 1\r\n', 'output': ['1 1 L']}, {'input': '10 3 59\r\n', 'output': ['10 3 L']}, {'input': '10000 10000 1\r\n', 'output': ['1 1 L']}]
[{'input': '4 3 7\r\n', 'output': ['2 1 L']}, {'input': '10000 1 1\r\n', 'output': ['1 1 L']}, {'input': '10000 9999 112390396\r\n', 'output': ['5621 818 R']}, {'input': '3 2 11\r\n', 'output': ['3 2 L']}, {'input': '1 2 1\r\n', 'output': ['1 1 L']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
346
100
100
100
["5"]
The only line of the input contains one integer n (5 ≀ n ≀ 100) β€” the number of east to west paths and north to south paths.
92db14325cd8aee06b502c12d2e3dd81
n = int(input()) print(((n*(n-1)*(n-2)*(n-3)*(n-4))**2)//120)
["120"]
Python
null
Output one integer β€” the number of ways to place the benches.
The city park of IT City contains n east to west paths and n north to south paths. Each east to west path crosses each north to south path, so there are n2 intersections.The city funded purchase of five benches. To make it seems that there are many benches it was decided to place them on as many paths as possible. Obviously this requirement is satisfied by the following scheme: each bench is placed on a cross of paths and each path contains not more than one bench.Help the park administration count the number of ways to place the benches.
[{"input": "5\r\n", "output": ["120"]}, {"input": "6\r\n", "output": ["4320"]}, {"input": "7\r\n", "output": ["52920"]}, {"input": "15\r\n", "output": ["1082161080"]}, {"input": "17\r\n", "output": ["4594961280"]}, {"input": "72\r\n", "output": ["23491596420472320"]}, {"input": "83\r\n", "output": ["101159538130177920"]}, {"input": "95\r\n", "output": ["402852449038723320"]}, {"input": "99\r\n", "output": ["613867215317368320"]}, {"input": "100\r\n", "output": ["680185280130048000"]}]
100
100
100
[{'input': '6\r\n', 'output': ['4320']}, {'input': '95\r\n', 'output': ['402852449038723320']}, {'input': '72\r\n', 'output': ['23491596420472320']}, {'input': '17\r\n', 'output': ['4594961280']}, {'input': '83\r\n', 'output': ['101159538130177920']}]
[{'input': '83\r\n', 'output': ['101159538130177920']}, {'input': '5\r\n', 'output': ['120']}, {'input': '72\r\n', 'output': ['23491596420472320']}, {'input': '100\r\n', 'output': ['680185280130048000']}, {'input': '6\r\n', 'output': ['4320']}]
[{'input': '15\r\n', 'output': ['1082161080']}, {'input': '95\r\n', 'output': ['402852449038723320']}, {'input': '5\r\n', 'output': ['120']}, {'input': '100\r\n', 'output': ['680185280130048000']}, {'input': '17\r\n', 'output': ['4594961280']}]
[{'input': '17\r\n', 'output': ['4594961280']}, {'input': '83\r\n', 'output': ['101159538130177920']}, {'input': '6\r\n', 'output': ['4320']}, {'input': '5\r\n', 'output': ['120']}, {'input': '100\r\n', 'output': ['680185280130048000']}]
[{'input': '95\r\n', 'output': ['402852449038723320']}, {'input': '100\r\n', 'output': ['680185280130048000']}, {'input': '72\r\n', 'output': ['23491596420472320']}, {'input': '15\r\n', 'output': ['1082161080']}, {'input': '5\r\n', 'output': ['120']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
347
100
100
100
["3 3\n0 0\n2 0\n3 1\n-2 1\n0 3\n2 2", "2 1\n1 0\n2 2\n3 1"]
The first line contains two space-separated integers R, B(1 ≀ R, B ≀ 10). For 1 ≀ i ≀ R, the i + 1-th line contains two space-separated integers xi and yi (|xi|, |yi| ≀ 10000) denoting the coordinates of the i-th Rebel spaceship. The following B lines have the same format, denoting the position of bases. It is guaranteed that no two points coincide and that no three points are on the same line.
65f81f621c228c09915adcb05256c634
n,m=[int(x) for x in input().split()] for i in range(n+m): s=input() if n==m: print('Yes') else: print('No')
["Yes", "No"]
Python
NoteFor the first example, one possible way is to connect the Rebels and bases in order.For the second example, there is no perfect matching between Rebels and bases.
If it is possible to connect Rebel spaceships and bases so as satisfy the constraint, output Yes, otherwise output No (without quote).
The Rebel fleet is afraid that the Empire might want to strike back again. Princess Heidi needs to know if it is possible to assign R Rebel spaceships to guard B bases so that every base has exactly one guardian and each spaceship has exactly one assigned base (in other words, the assignment is a perfect matching). Since she knows how reckless her pilots are, she wants to be sure that any two (straight) paths – from a base to its assigned spaceship – do not intersect in the galaxy plane (that is, in 2D), and so there is no risk of collision.
[{"input": "3 3\r\n0 0\r\n2 0\r\n3 1\r\n-2 1\r\n0 3\r\n2 2\r\n", "output": ["YES", "Yes"]}, {"input": "2 1\r\n1 0\r\n2 2\r\n3 1\r\n", "output": ["No", "NO"]}, {"input": "1 1\r\n3686 4362\r\n-7485 5112\r\n", "output": ["YES", "Yes"]}, {"input": "1 2\r\n1152 -7324\r\n-5137 -35\r\n-6045 -5271\r\n", "output": ["No", "NO"]}, {"input": "1 3\r\n-8824 -9306\r\n-5646 -9767\r\n8123 9355\r\n-6203 -1643\r\n", "output": ["No", "NO"]}, {"input": "1 5\r\n-8775 6730\r\n-3806 -6906\r\n-9256 -8240\r\n-1320 6849\r\n8155 746\r\n8284 -7317\r\n", "output": ["No", "NO"]}, {"input": "1 8\r\n8741 3638\r\n381 -9191\r\n7534 8792\r\n-8848 -414\r\n2926 -7444\r\n9475 559\r\n6938 2359\r\n2570 4721\r\n3329 -9365\r\n", "output": ["No", "NO"]}, {"input": "1 9\r\n6207 1655\r\n2728 8520\r\n9142 3418\r\n-1258 -8727\r\n5370 3161\r\n-5167 -7691\r\n517 2242\r\n3702 -9904\r\n-6862 -2997\r\n2524 -5492\r\n", "output": ["No", "NO"]}, {"input": "1 10\r\n9424 3979\r\n-8582 9252\r\n-2432 -3287\r\n-4247 1932\r\n-9491 5544\r\n-635 5689\r\n8260 -6790\r\n8841 3067\r\n-5624 -1990\r\n1569 1045\r\n-8844 -8462\r\n", "output": ["No", "NO"]}, {"input": "2 1\r\n2893 -5488\r\n-5087 -5042\r\n-8928 -9453\r\n", "output": ["No", "NO"]}, {"input": "2 2\r\n359 -29\r\n6964 -7332\r\n2384 -4529\r\n4434 2253\r\n", "output": ["YES", "Yes"]}, {"input": "2 3\r\n-9617 845\r\n4195 -2181\r\n-6305 -9903\r\n-535 -6060\r\n9417 -8419\r\n", "output": ["No", "NO"]}, {"input": "2 5\r\n-9568 -3121\r\n-1408 2942\r\n-827 -7497\r\n4348 2432\r\n-7958 231\r\n6440 1896\r\n2647 -1305\r\n", "output": ["No", "NO"]}, {"input": "2 8\r\n7948 3490\r\n2779 3512\r\n3403 -3024\r\n-3180 -4831\r\n6815 4601\r\n7631 9772\r\n-6320 -1060\r\n5592 362\r\n-785 4040\r\n8030 3272\r\n", "output": ["No", "NO"]}, {"input": "2 9\r\n5414 -8195\r\n-5171 -1634\r\n5012 4161\r\n-5888 -585\r\n9258 2646\r\n5548 1523\r\n7259 -8619\r\n9580 5738\r\n-8715 706\r\n-2232 -3280\r\n1866 1775\r\n", "output": ["No", "NO"]}, {"input": "2 10\r\n-5118 -3971\r\n-1169 -9140\r\n-7807 -3139\r\n9702 -5328\r\n8555 3460\r\n-1442 -733\r\n701 -2802\r\n-5784 2578\r\n8186 -4810\r\n-2722 -1013\r\n-9437 4021\r\n-5403 -1331\r\n", "output": ["No", "NO"]}, {"input": "3 1\r\n-8199 -7896\r\n7015 -4898\r\n-499 -8710\r\n9953 -6411\r\n", "output": ["No", "NO"]}, {"input": "3 2\r\n9268 -9879\r\n4245 2515\r\n-9188 -3786\r\n-2458 -2165\r\n3420 463\r\n", "output": ["No", "NO"]}, {"input": "3 3\r\n-8149 697\r\n6593 7667\r\n2123 -9160\r\n-5165 9523\r\n747 -8933\r\n-1536 -2691\r\n", "output": ["YES", "Yes"]}, {"input": "3 5\r\n-658 7030\r\n990 3086\r\n-4958 -6755\r\n7159 -1986\r\n5634 -7726\r\n1740 -1450\r\n1947 7835\r\n-2755 -4709\r\n", "output": ["No", "NO"]}, {"input": "3 8\r\n-3143 -6360\r\n-5121 -6641\r\n-727 -9723\r\n-369 454\r\n-9298 4086\r\n5787 -1016\r\n2683 -9660\r\n-1089 1121\r\n-4898 7743\r\n418 5485\r\n7425 -6644\r\n", "output": ["No", "NO"]}, {"input": "3 9\r\n6882 -8342\r\n4669 -8932\r\n882 4904\r\n-220 4700\r\n587 -5311\r\n3704 -1823\r\n6559 -6921\r\n-7399 6497\r\n-5387 -5890\r\n-9844 -1067\r\n5367 -7237\r\n-8314 -939\r\n", "output": ["No", "NO"]}, {"input": "3 10\r\n-7100 -1623\r\n-3459 2172\r\n9676 1595\r\n-6053 4558\r\n-842 8819\r\n-9691 3144\r\n3440 -9112\r\n7034 4946\r\n4851 -2513\r\n430 4372\r\n-7175 -3497\r\n5719 381\r\n-8859 -1347\r\n", "output": ["No", "NO"]}, {"input": "5 1\r\n9621 -154\r\n6694 -2348\r\n944 -7225\r\n-1568 -5543\r\n-3805 -872\r\n1204 -2651\r\n", "output": ["No", "NO"]}, {"input": "5 2\r\n-355 -9579\r\n-1256 -4638\r\n-4890 7402\r\n-1420 -1297\r\n-1362 2290\r\n-879 9101\r\n9514 -6689\r\n", "output": ["No", "NO"]}, {"input": "5 3\r\n9670 8440\r\n1091 -9784\r\n6422 4884\r\n3314 -9610\r\n8523 -7107\r\n-2963 8293\r\n3092 -3950\r\n-4093 -6502\r\n", "output": ["No", "NO"]}, {"input": "5 5\r\n-2840 4475\r\n2931 -6923\r\n-659 -8125\r\n8197 -1118\r\n851 -5899\r\n313 6679\r\n-9751 6115\r\n-6415 4250\r\n-227 -9732\r\n-6282 5041\r\n", "output": ["YES", "Yes"]}, {"input": "5 8\r\n-5325 1383\r\n-5441 3351\r\n-3870 1465\r\n669 -8381\r\n-4377 5913\r\n4360 -329\r\n8725 8620\r\n7810 -2479\r\n4019 4850\r\n8052 9911\r\n4130 -4668\r\n3744 2537\r\n-7171 -3933\r\n", "output": ["No", "NO"]}, {"input": "5 9\r\n-2742 -600\r\n6609 8502\r\n-5118 6389\r\n-4300 5568\r\n-1934 -3484\r\n9719 -1137\r\n2303 -8641\r\n1500 2897\r\n-6172 -8783\r\n-2210 -6939\r\n9514 -5262\r\n-3773 -4081\r\n1983 -4032\r\n4503 -3496\r\n", "output": ["No", "NO"]}, {"input": "5 10\r\n1493 7658\r\n-598 7650\r\n9226 -964\r\n2439 -3114\r\n366 2391\r\n-1008 -2258\r\n6063 8568\r\n7488 6824\r\n-4674 9523\r\n9590 9960\r\n-8361 -8234\r\n520 -1312\r\n-3878 -1142\r\n-8261 -239\r\n-2346 -2362\r\n", "output": ["No", "NO"]}, {"input": "8 1\r\n-796 -1\r\n3591 -2510\r\n-6330 4706\r\n-7422 -9093\r\n7860 -7002\r\n5375 -5310\r\n3538 3108\r\n-9851 -9798\r\n-8884 -170\r\n", "output": ["No", "NO"]}, {"input": "8 2\r\n-3330 -1983\r\n-6621 -4800\r\n-4721 9630\r\n9871 -4847\r\n-2256 -8957\r\n3292 -6118\r\n4558 -6712\r\n-5863 5282\r\n-9373 3938\r\n-5179 -8073\r\n", "output": ["No", "NO"]}, {"input": "8 3\r\n6695 8593\r\n-7129 352\r\n6590 -5447\r\n-2540 -3457\r\n7630 1647\r\n8651 5634\r\n-1864 -6829\r\n7828 -1901\r\n-7005 -9695\r\n4561 -4921\r\n-4782 -6478\r\n", "output": ["No", "NO"]}, {"input": "8 5\r\n6744 2367\r\n-5290 -7085\r\n-491 6662\r\n2343 -2407\r\n-43 2855\r\n-8075 6875\r\n-7265 -4206\r\n-4197 8851\r\n7433 780\r\n4038 -8321\r\n-1455 -7665\r\n3139 -1225\r\n9884 -167\r\n", "output": ["No", "NO"]}, {"input": "8 8\r\n4260 1536\r\n-8545 6045\r\n-3702 3693\r\n-5185 -2228\r\n-5271 -5335\r\n-4027 4453\r\n-8790 8598\r\n7172 -5320\r\n-880 -4638\r\n-1630 -3452\r\n2076 8296\r\n-9116 -5599\r\n2461 9832\r\n4268 5116\r\n-7582 -805\r\n3548 3776\r\n", "output": ["YES", "Yes"]}, {"input": "8 9\r\n-5716 6995\r\n1245 3754\r\n7610 8617\r\n-451 -5424\r\n-2828 5270\r\n-6111 6502\r\n-2653 1039\r\n3718 7498\r\n-8810 -7973\r\n667 -300\r\n-2838 -2001\r\n3367 5523\r\n-8386 -2827\r\n6929 -6260\r\n3247 1167\r\n1873 6265\r\n4376 -8781\r\n", "output": ["No", "NO"]}, {"input": "8 10\r\n5844 -8156\r\n9676 -8121\r\n-6302 -1050\r\n-4823 -8343\r\n4736 -3859\r\n9129 5920\r\n-3990 2792\r\n3615 -8930\r\n-7831 -8703\r\n-5542 931\r\n7599 -7930\r\n8705 -8735\r\n-6438 1724\r\n-7568 -8351\r\n5893 2316\r\n2574 -9723\r\n2416 3827\r\n856 -4877\r\n", "output": ["No", "NO"]}, {"input": "9 1\r\n8114 -9851\r\n872 -9807\r\n9541 5449\r\n7948 -3808\r\n8892 -7517\r\n-6767 3903\r\n-18 -311\r\n-3973 5845\r\n-3295 3533\r\n-4790 -4426\r\n", "output": ["No", "NO"]}, {"input": "9 2\r\n5580 8167\r\n-7078 -4655\r\n3707 -9628\r\n2980 438\r\n1632 -9472\r\n-8850 -4346\r\n-6440 2428\r\n-2841 923\r\n6515 -2658\r\n-2492 -8716\r\n8219 5104\r\n", "output": ["No", "NO"]}, {"input": "9 3\r\n8163 6185\r\n-4731 2757\r\n-4982 -4704\r\n3128 4684\r\n-8483 1132\r\n6807 2288\r\n4878 2311\r\n-6295 6299\r\n8882 -5992\r\n-195 4733\r\n6162 4510\r\n-7264 -1020\r\n", "output": ["No", "NO"]}, {"input": "9 5\r\n-4347 -5222\r\n-2891 5618\r\n-4621 7404\r\n-4548 -6825\r\n3846 2340\r\n2640 3530\r\n-7965 4934\r\n-8617 -2950\r\n-9240 4483\r\n-718 6451\r\n-8251 -6379\r\n558 3484\r\n9861 -6432\r\n483 -7331\r\n", "output": ["No", "NO"]}, {"input": "9 8\r\n-6832 -872\r\n1295 -4109\r\n-7832 -8123\r\n-2373 -6646\r\n-1383 -5849\r\n3832 -6334\r\n-7229 -2263\r\n-6951 -9678\r\n4709 1326\r\n-6386 -1239\r\n2721 -8159\r\n-4255 -890\r\n9880 3567\r\n3349 5921\r\n2487 -828\r\n-783 2422\r\n-5497 -8399\r\n", "output": ["No", "NO"]}, {"input": "9 9\r\n3193 -2855\r\n787 -6399\r\n3479 9360\r\n5217 -9842\r\n1061 4755\r\n1748 -7142\r\n-6209 -2380\r\n6740 -4302\r\n-5482 5433\r\n3353 -5529\r\n664 1546\r\n8228 -9769\r\n-8409 -1650\r\n893 9365\r\n-9542 8585\r\n7245 -9972\r\n-475 -6359\r\n-3775 2139\r\n", "output": ["YES", "Yes"]}, {"input": "9 10\r\n-3581 3894\r\n7385 3191\r\n-8820 6540\r\n-577 -5900\r\n2781 -5943\r\n8322 -7944\r\n-1251 -5779\r\n-3567 3140\r\n8835 -6406\r\n-2390 -1126\r\n7006 4553\r\n-174 -7023\r\n-6538 1530\r\n3318 2477\r\n7864 -9657\r\n-2379 -6961\r\n4456 9852\r\n1462 -5871\r\n-9931 6466\r\n", "output": ["No", "NO"]}, {"input": "10 1\r\n3362 3137\r\n-6006 -2168\r\n-9207 8006\r\n-6284 -114\r\n4617 -4997\r\n-4360 3540\r\n-6423 2328\r\n-8768 8468\r\n2899 1032\r\n-7561 -3623\r\n6979 653\r\n", "output": ["No", "NO"]}, {"input": "10 2\r\n5945 8596\r\n-3658 -4459\r\n-7598 -7071\r\n3567 4132\r\n7060 -1835\r\n-6443 -4709\r\n4895 2211\r\n-4780 3546\r\n5266 7400\r\n2178 -472\r\n4922 -9643\r\n4163 6030\r\n", "output": ["No", "NO"]}, {"input": "10 3\r\n3411 6614\r\n8392 693\r\n-8846 7555\r\n-1402 -4181\r\n-3055 -3789\r\n4033 -5516\r\n-1527 4950\r\n-792 8922\r\n-4925 4065\r\n4475 5536\r\n-9695 9764\r\n6943 -2849\r\n7022 1986\r\n", "output": ["No", "NO"]}, {"input": "10 5\r\n3460 5504\r\n529 -6744\r\n4075 9961\r\n-3961 4311\r\n-7871 9977\r\n7308 -4275\r\n-6928 7573\r\n-3114 -327\r\n-3046 -5461\r\n3953 4398\r\n-4106 -3981\r\n-8092 -8048\r\n7590 9228\r\n9433 -4\r\n-8808 -6742\r\n", "output": ["No", "NO"]}, {"input": "10 8\r\n8417 -444\r\n-5582 6386\r\n863 6992\r\n-4047 6751\r\n-5658 1788\r\n-1204 5862\r\n-6192 -2480\r\n813 -7056\r\n-9098 -1176\r\n-1715 -3292\r\n6866 -2905\r\n-7788 137\r\n7609 -774\r\n-7702 -6753\r\n-6622 -3090\r\n3089 -7006\r\n-9374 1882\r\n-481 -5698\r\n", "output": ["No", "NO"]}, {"input": "10 9\r\n-9001 -9868\r\n4207 1240\r\n-7826 1618\r\n-6755 3555\r\n-3214 -167\r\n4155 -4648\r\n-2316 259\r\n4801 -1679\r\n-6730 8048\r\n-4535 -9843\r\n4809 -5759\r\n4695 -8742\r\n9321 -5991\r\n2401 4133\r\n6468 6324\r\n1414 -9103\r\n-6613 3922\r\n5544 -5092\r\n-6777 -788\r\n", "output": ["No", "NO"]}, {"input": "10 10\r\n8530 -3814\r\n-9330 -6035\r\n3951 -217\r\n-9276 8291\r\n636 -3118\r\n5024 -2403\r\n4601 7977\r\n-3620 -1428\r\n4954 -9632\r\n-9852 6553\r\n-3457 5430\r\n-8866 -7343\r\n1020 -5748\r\n5043 -3820\r\n-2832 1528\r\n-5058 -825\r\n2406 -3530\r\n9152 -7463\r\n-8547 7108\r\n2492 8953\r\n", "output": ["YES", "Yes"]}]
100
100
100
[{'input': '8 1\r\n-796 -1\r\n3591 -2510\r\n-6330 4706\r\n-7422 -9093\r\n7860 -7002\r\n5375 -5310\r\n3538 3108\r\n-9851 -9798\r\n-8884 -170\r\n', 'output': ['No', 'NO']}, {'input': '10 5\r\n3460 5504\r\n529 -6744\r\n4075 9961\r\n-3961 4311\r\n-7871 9977\r\n7308 -4275\r\n-6928 7573\r\n-3114 -327\r\n-3046 -5461\r\n3953 4398\r\n-4106 -3981\r\n-8092 -8048\r\n7590 9228\r\n9433 -4\r\n-8808 -6742\r\n', 'output': ['No', 'NO']}, {'input': '1 9\r\n6207 1655\r\n2728 8520\r\n9142 3418\r\n-1258 -8727\r\n5370 3161\r\n-5167 -7691\r\n517 2242\r\n3702 -9904\r\n-6862 -2997\r\n2524 -5492\r\n', 'output': ['No', 'NO']}, {'input': '10 8\r\n8417 -444\r\n-5582 6386\r\n863 6992\r\n-4047 6751\r\n-5658 1788\r\n-1204 5862\r\n-6192 -2480\r\n813 -7056\r\n-9098 -1176\r\n-1715 -3292\r\n6866 -2905\r\n-7788 137\r\n7609 -774\r\n-7702 -6753\r\n-6622 -3090\r\n3089 -7006\r\n-9374 1882\r\n-481 -5698\r\n', 'output': ['No', 'NO']}, {'input': '9 2\r\n5580 8167\r\n-7078 -4655\r\n3707 -9628\r\n2980 438\r\n1632 -9472\r\n-8850 -4346\r\n-6440 2428\r\n-2841 923\r\n6515 -2658\r\n-2492 -8716\r\n8219 5104\r\n', 'output': ['No', 'NO']}]
[{'input': '8 1\r\n-796 -1\r\n3591 -2510\r\n-6330 4706\r\n-7422 -9093\r\n7860 -7002\r\n5375 -5310\r\n3538 3108\r\n-9851 -9798\r\n-8884 -170\r\n', 'output': ['No', 'NO']}, {'input': '9 3\r\n8163 6185\r\n-4731 2757\r\n-4982 -4704\r\n3128 4684\r\n-8483 1132\r\n6807 2288\r\n4878 2311\r\n-6295 6299\r\n8882 -5992\r\n-195 4733\r\n6162 4510\r\n-7264 -1020\r\n', 'output': ['No', 'NO']}, {'input': '8 9\r\n-5716 6995\r\n1245 3754\r\n7610 8617\r\n-451 -5424\r\n-2828 5270\r\n-6111 6502\r\n-2653 1039\r\n3718 7498\r\n-8810 -7973\r\n667 -300\r\n-2838 -2001\r\n3367 5523\r\n-8386 -2827\r\n6929 -6260\r\n3247 1167\r\n1873 6265\r\n4376 -8781\r\n', 'output': ['No', 'NO']}, {'input': '2 5\r\n-9568 -3121\r\n-1408 2942\r\n-827 -7497\r\n4348 2432\r\n-7958 231\r\n6440 1896\r\n2647 -1305\r\n', 'output': ['No', 'NO']}, {'input': '1 8\r\n8741 3638\r\n381 -9191\r\n7534 8792\r\n-8848 -414\r\n2926 -7444\r\n9475 559\r\n6938 2359\r\n2570 4721\r\n3329 -9365\r\n', 'output': ['No', 'NO']}]
[{'input': '8 10\r\n5844 -8156\r\n9676 -8121\r\n-6302 -1050\r\n-4823 -8343\r\n4736 -3859\r\n9129 5920\r\n-3990 2792\r\n3615 -8930\r\n-7831 -8703\r\n-5542 931\r\n7599 -7930\r\n8705 -8735\r\n-6438 1724\r\n-7568 -8351\r\n5893 2316\r\n2574 -9723\r\n2416 3827\r\n856 -4877\r\n', 'output': ['No', 'NO']}, {'input': '5 5\r\n-2840 4475\r\n2931 -6923\r\n-659 -8125\r\n8197 -1118\r\n851 -5899\r\n313 6679\r\n-9751 6115\r\n-6415 4250\r\n-227 -9732\r\n-6282 5041\r\n', 'output': ['YES', 'Yes']}, {'input': '3 10\r\n-7100 -1623\r\n-3459 2172\r\n9676 1595\r\n-6053 4558\r\n-842 8819\r\n-9691 3144\r\n3440 -9112\r\n7034 4946\r\n4851 -2513\r\n430 4372\r\n-7175 -3497\r\n5719 381\r\n-8859 -1347\r\n', 'output': ['No', 'NO']}, {'input': '5 3\r\n9670 8440\r\n1091 -9784\r\n6422 4884\r\n3314 -9610\r\n8523 -7107\r\n-2963 8293\r\n3092 -3950\r\n-4093 -6502\r\n', 'output': ['No', 'NO']}, {'input': '9 2\r\n5580 8167\r\n-7078 -4655\r\n3707 -9628\r\n2980 438\r\n1632 -9472\r\n-8850 -4346\r\n-6440 2428\r\n-2841 923\r\n6515 -2658\r\n-2492 -8716\r\n8219 5104\r\n', 'output': ['No', 'NO']}]
[{'input': '10 1\r\n3362 3137\r\n-6006 -2168\r\n-9207 8006\r\n-6284 -114\r\n4617 -4997\r\n-4360 3540\r\n-6423 2328\r\n-8768 8468\r\n2899 1032\r\n-7561 -3623\r\n6979 653\r\n', 'output': ['No', 'NO']}, {'input': '3 2\r\n9268 -9879\r\n4245 2515\r\n-9188 -3786\r\n-2458 -2165\r\n3420 463\r\n', 'output': ['No', 'NO']}, {'input': '2 2\r\n359 -29\r\n6964 -7332\r\n2384 -4529\r\n4434 2253\r\n', 'output': ['YES', 'Yes']}, {'input': '2 1\r\n2893 -5488\r\n-5087 -5042\r\n-8928 -9453\r\n', 'output': ['No', 'NO']}, {'input': '2 9\r\n5414 -8195\r\n-5171 -1634\r\n5012 4161\r\n-5888 -585\r\n9258 2646\r\n5548 1523\r\n7259 -8619\r\n9580 5738\r\n-8715 706\r\n-2232 -3280\r\n1866 1775\r\n', 'output': ['No', 'NO']}]
[{'input': '1 2\r\n1152 -7324\r\n-5137 -35\r\n-6045 -5271\r\n', 'output': ['No', 'NO']}, {'input': '10 2\r\n5945 8596\r\n-3658 -4459\r\n-7598 -7071\r\n3567 4132\r\n7060 -1835\r\n-6443 -4709\r\n4895 2211\r\n-4780 3546\r\n5266 7400\r\n2178 -472\r\n4922 -9643\r\n4163 6030\r\n', 'output': ['No', 'NO']}, {'input': '3 9\r\n6882 -8342\r\n4669 -8932\r\n882 4904\r\n-220 4700\r\n587 -5311\r\n3704 -1823\r\n6559 -6921\r\n-7399 6497\r\n-5387 -5890\r\n-9844 -1067\r\n5367 -7237\r\n-8314 -939\r\n', 'output': ['No', 'NO']}, {'input': '9 1\r\n8114 -9851\r\n872 -9807\r\n9541 5449\r\n7948 -3808\r\n8892 -7517\r\n-6767 3903\r\n-18 -311\r\n-3973 5845\r\n-3295 3533\r\n-4790 -4426\r\n', 'output': ['No', 'NO']}, {'input': '2 5\r\n-9568 -3121\r\n-1408 2942\r\n-827 -7497\r\n4348 2432\r\n-7958 231\r\n6440 1896\r\n2647 -1305\r\n', 'output': ['No', 'NO']}]
100
100
100
100
100
83.33
83.33
100
100
83.33
83.33
83.33
100
100
83.33
348
100
89.998
89.998
["4 2 2", "5 1 5"]
The only input line contains three integers $$$n$$$, $$$l$$$ and $$$r$$$ ($$$1 \leq n \leq 1\,000$$$, $$$1 \leq l \leq r \leq \min(n, 20)$$$)Β β€” an array's size, the minimal number and the maximal number of distinct elements in an array.
ce220726392fb0cacf0ec44a7490084a
n,l,r=map(int,input().split()) m=n a=1 x=0 A=[] B=[] while n>0: if l==1: A.append(1) n-=1 else: A.append(2**(l-1)) l-=1 n-=1 while x<m: if a==r: B.append(2**(a-1)) x+=1 else: B.append(2**(a-1)) x+=1 a+=1 print(sum(A),sum(B))
["5 7", "5 31"]
Python
NoteIn the first example, an array could be the one of the following: $$$[1,1,1,2]$$$, $$$[1,1,2,2]$$$ or $$$[1,2,2,2]$$$. In the first case the minimal sum is reached and in the last case the maximal sum is reached.In the second example, the minimal sum is reached at the array $$$[1,1,1,1,1]$$$, and the maximal one is reached at the array $$$[1,2,4,8,16]$$$.
Output two numbersΒ β€” the minimal and the maximal possible sums of all elements in an array.
Mislove had an array $$$a_1$$$, $$$a_2$$$, $$$\cdots$$$, $$$a_n$$$ of $$$n$$$ positive integers, but he has lost it. He only remembers the following facts about it: The number of different numbers in the array is not less than $$$l$$$ and is not greater than $$$r$$$; For each array's element $$$a_i$$$ either $$$a_i = 1$$$ or $$$a_i$$$ is even and there is a number $$$\dfrac{a_i}{2}$$$ in the array.For example, if $$$n=5$$$, $$$l=2$$$, $$$r=3$$$ then an array could be $$$[1,2,2,4,4]$$$ or $$$[1,1,1,1,2]$$$; but it couldn't be $$$[1,2,2,4,8]$$$ because this array contains $$$4$$$ different numbers; it couldn't be $$$[1,2,2,3,3]$$$ because $$$3$$$ is odd and isn't equal to $$$1$$$; and it couldn't be $$$[1,1,2,2,16]$$$ because there is a number $$$16$$$ in the array but there isn't a number $$$\frac{16}{2} = 8$$$.According to these facts, he is asking you to count the minimal and the maximal possible sums of all elements in an array.
[{"input": "4 2 2\r\n", "output": ["5 7"]}, {"input": "5 1 5\r\n", "output": ["5 31"]}, {"input": "106 16 18\r\n", "output": ["65625 11796479"]}, {"input": "114 18 19\r\n", "output": ["262239 25427967"]}, {"input": "655 3 18\r\n", "output": ["659 83755007"]}, {"input": "1000 1 20\r\n", "output": ["1000 514850815"]}, {"input": "1000 20 20\r\n", "output": ["1049555 514850815"]}, {"input": "1 1 1\r\n", "output": ["1 1"]}, {"input": "588 13 15\r\n", "output": ["8766 9420799"]}, {"input": "408 13 13\r\n", "output": ["8586 1626111"]}, {"input": "879 17 17\r\n", "output": ["131933 56623103"]}, {"input": "17 2 14\r\n", "output": ["18 40959"]}, {"input": "624 7 17\r\n", "output": ["744 39911423"]}, {"input": "1000 1 1\r\n", "output": ["1000 1000"]}]
100
100
100
[{'input': '655 3 18\r\n', 'output': ['659 83755007']}, {'input': '5 1 5\r\n', 'output': ['5 31']}, {'input': '879 17 17\r\n', 'output': ['131933 56623103']}, {'input': '17 2 14\r\n', 'output': ['18 40959']}, {'input': '1000 1 1\r\n', 'output': ['1000 1000']}]
[{'input': '1000 1 1\r\n', 'output': ['1000 1000']}, {'input': '106 16 18\r\n', 'output': ['65625 11796479']}, {'input': '5 1 5\r\n', 'output': ['5 31']}, {'input': '408 13 13\r\n', 'output': ['8586 1626111']}, {'input': '879 17 17\r\n', 'output': ['131933 56623103']}]
[{'input': '17 2 14\r\n', 'output': ['18 40959']}, {'input': '588 13 15\r\n', 'output': ['8766 9420799']}, {'input': '655 3 18\r\n', 'output': ['659 83755007']}, {'input': '114 18 19\r\n', 'output': ['262239 25427967']}, {'input': '1000 1 20\r\n', 'output': ['1000 514850815']}]
[{'input': '1000 1 1\r\n', 'output': ['1000 1000']}, {'input': '17 2 14\r\n', 'output': ['18 40959']}, {'input': '588 13 15\r\n', 'output': ['8766 9420799']}, {'input': '408 13 13\r\n', 'output': ['8586 1626111']}, {'input': '4 2 2\r\n', 'output': ['5 7']}]
[{'input': '1000 1 20\r\n', 'output': ['1000 514850815']}, {'input': '4 2 2\r\n', 'output': ['5 7']}, {'input': '114 18 19\r\n', 'output': ['262239 25427967']}, {'input': '655 3 18\r\n', 'output': ['659 83755007']}, {'input': '408 13 13\r\n', 'output': ['8586 1626111']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
349
100
100
100
["2 2\n5 8", "1 2\n7 1", "1 2\n4 4", "1 4\n2 2 1 2"]
The first line contains two integers n and k (1 ≀ n ≀ 10000, 1 ≀ k ≀ 100)Β β€” the number of rows and the number of groups of soldiers, respectively. The second line contains k integers a1, a2, a3, ..., ak (1 ≀ ai ≀ 10000), where ai denotes the number of soldiers in the i-th group. It is guaranteed that a1 + a2 + ... + ak ≀ 8Β·n.
d1f88a97714d6c13309c88fcf7d86821
n,k = map(int, input().split()) a = list(map(int,input().split())) all_sum = sum(a) r4,r2 = n,n*2 for v in range(len(a)): mid = a[v] // 4 a[v] = a[v] % 4 if mid <= r4: r4 -= mid else: a[v] += 4 * (mid - r4) r4 = 0 if r4 == 0: break mid = 0 r22 = 0 for v in a: if v % 2 == 1: mid += 1 r22 += v // 2 #print(r4,r22,mid,r2) if r4 > 0: mid -=r4 r22 -= r4 if mid < 0: r22 -= (mid // -2) mid = 0 if r22 + mid > r2: print('NO') else: print('YES')
["YES", "NO", "YES", "YES"]
Python
NoteIn the first sample, Daenerys can place the soldiers like in the figure below: In the second sample, there is no way to place the soldiers in the plane since the second group soldier will always have a seat neighboring to someone from the first group.In the third example Daenerys can place the first group on seats (1, 2, 7, 8), and the second group an all the remaining seats.In the fourth example she can place the first two groups on seats (1, 2) and (7, 8), the third group on seats (3), and the fourth group on seats (5, 6).
If we can place the soldiers in the airplane print "YES" (without quotes). Otherwise print "NO" (without quotes). You can choose the case (lower or upper) for each letter arbitrary.
Daenerys Targaryen has an army consisting of k groups of soldiers, the i-th group contains ai soldiers. She wants to bring her army to the other side of the sea to get the Iron Throne. She has recently bought an airplane to carry her army through the sea. The airplane has n rows, each of them has 8 seats. We call two seats neighbor, if they are in the same row and in seats {1, 2}, {3, 4}, {4, 5}, {5, 6} or {7, 8}. A row in the airplane Daenerys Targaryen wants to place her army in the plane so that there are no two soldiers from different groups sitting on neighboring seats.Your task is to determine if there is a possible arranging of her army in the airplane such that the condition above is satisfied.
[{"input": "2 2\r\n5 8\r\n", "output": ["YES"]}, {"input": "1 2\r\n7 1\r\n", "output": ["NO"]}, {"input": "1 2\r\n4 4\r\n", "output": ["YES"]}, {"input": "1 4\r\n2 2 1 2\r\n", "output": ["YES"]}, {"input": "10000 100\r\n749 2244 949 2439 2703 44 2394 124 285 3694 3609 717 1413 155 974 1778 1448 1327 1487 3458 319 1395 3783 2184 2062 43 826 38 3276 807 1837 4635 171 1386 1768 1128 2020 2536 800 782 3058 174 455 83 647 595 658 109 33 23 70 39 38 1 6 35 94 9 22 12 6 1 2 2 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 9938\r\n", "output": ["YES"]}, {"input": "100 15\r\n165 26 83 64 235 48 36 51 3 18 5 10 9 6 5\r\n", "output": ["YES"]}, {"input": "1 4\r\n2 2 2 2\r\n", "output": ["NO"]}, {"input": "5691 91\r\n6573 1666 2158 2591 4636 886 263 4217 389 29 1513 1172 617 2012 1855 798 1588 979 152 37 890 375 1091 839 385 382 1 255 117 289 119 224 182 69 19 71 115 13 4 22 35 2 60 12 6 12 19 9 3 2 2 6 5 1 7 7 3 1 5 1 7 1 4 1 1 3 2 1 2 1 1 2 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 5631\r\n", "output": ["NO"]}, {"input": "2000 50\r\n203 89 1359 3105 898 1381 248 365 108 766 961 630 265 819 838 125 1751 289 177 81 131 564 102 95 49 74 92 101 19 17 156 5 5 4 20 9 25 16 16 2 8 5 4 2 1 3 4 1 3 2\r\n", "output": ["NO"]}, {"input": "10000 100\r\n800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800\r\n", "output": ["YES"]}, {"input": "10000 100\r\n749 2244 949 2439 2703 44 2394 124 285 3694 3609 717 1413 155 974 1778 1448 1327 1487 3458 319 1395 3783 2184 2062 43 826 38 3276 807 1837 4635 171 1386 1768 1128 2020 2536 2050 1074 605 979 1724 1608 672 88 1243 129 718 544 3590 37 187 600 738 34 64 316 58 6 84 252 75 68 40 68 4 29 29 8 13 11 5 1 5 1 3 2 1 1 1 2 3 4 1 1 2 2 2 1 1 1 1 1 1 1 1 1 1 3\r\n", "output": ["NO"]}, {"input": "8459 91\r\n778 338 725 1297 115 540 1452 2708 193 1806 1496 1326 2648 176 199 93 342 3901 2393 2718 800 3434 657 4037 291 690 1957 3280 73 6011 2791 1987 440 455 444 155 261 234 829 1309 1164 616 34 627 107 213 52 110 323 81 98 8 7 73 20 12 56 3 40 12 8 7 69 1 14 3 6 2 6 8 3 5 4 4 3 1 1 4 2 1 1 1 8 2 2 2 1 1 1 2 8421\r\n", "output": ["NO"]}, {"input": "1 3\r\n2 3 2\r\n", "output": ["YES"]}, {"input": "10000 91\r\n2351 1402 1137 2629 4718 1138 1839 1339 2184 2387 165 370 918 1476 2717 879 1152 5367 3940 608 941 766 1256 656 2768 916 4176 489 1989 1633 2725 2329 2795 1970 667 340 1275 120 870 488 225 59 64 255 207 3 37 127 19 224 34 283 144 50 132 60 57 29 18 6 7 4 4 15 3 5 1 10 5 2 3 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 9948\r\n", "output": ["YES"]}, {"input": "10000 83\r\n64 612 2940 2274 1481 1713 860 1264 104 5616 2574 5292 4039 292 1416 854 3854 1140 4344 3904 1720 1968 442 884 2032 875 291 677 2780 3074 3043 2997 407 727 344 511 156 321 134 51 382 336 591 52 134 39 104 10 20 15 24 2 70 39 14 16 16 25 1 6 2 2 1 1 1 2 4 2 1 2 1 2 1 1 1 1 1 1 1 1 1 1 9968\r\n", "output": ["YES"]}, {"input": "4000 71\r\n940 1807 57 715 532 212 3842 2180 2283 744 1453 800 1945 380 2903 293 633 391 2866 256 102 46 228 1099 434 210 244 14 27 4 63 53 3 9 36 25 1 12 2 14 12 28 2 28 8 5 11 8 2 3 6 4 1 1 1 3 2 1 1 1 2 2 1 1 1 1 1 2 1 1 3966\r\n", "output": ["YES"]}, {"input": "3403 59\r\n1269 1612 453 795 1216 941 19 44 1796 324 2019 1397 651 382 841 2003 3013 638 1007 1001 351 95 394 149 125 13 116 183 20 78 208 19 152 10 151 177 16 23 17 22 8 1 3 2 6 1 5 3 13 1 8 4 3 4 4 4 2 2 3378\r\n", "output": ["YES"]}, {"input": "2393 33\r\n1381 2210 492 3394 912 2927 1189 269 66 102 104 969 395 385 369 354 251 28 203 334 20 10 156 29 61 13 30 4 1 32 2 2 2436\r\n", "output": ["YES"]}, {"input": "10000 100\r\n749 2244 949 2439 2703 44 2394 124 285 3694 3609 717 1413 155 974 1778 1448 1327 1487 3458 319 1395 3783 2184 2062 43 826 38 3276 807 1837 4635 171 1386 1768 1128 2020 2536 800 782 3058 174 455 83 647 595 658 109 33 23 70 39 38 1 6 35 94 9 22 12 6 1 2 2 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 9939\r\n", "output": ["NO"]}, {"input": "10000 89\r\n1001 1531 2489 457 1415 617 2057 2658 3030 789 2500 3420 1550 376 720 78 506 293 1978 383 3195 2036 891 1741 1817 486 2650 360 2250 2531 3250 1612 2759 603 5321 1319 791 1507 265 174 877 1861 572 172 580 536 777 165 169 11 125 31 186 113 78 27 25 37 8 21 48 24 4 33 35 13 15 1 3 2 2 8 3 5 1 1 6 1 1 2 1 1 2 2 1 1 2 1 9953\r\n", "output": ["NO"]}, {"input": "4 16\r\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\r\n", "output": ["NO"]}, {"input": "10000 71\r\n110 14 2362 260 423 881 1296 3904 1664 849 57 631 1922 917 4832 1339 3398 4578 59 2663 2223 698 4002 3013 747 699 1230 2750 239 1409 6291 2133 1172 5824 181 797 26 281 574 557 19 82 624 387 278 53 64 163 22 617 15 35 42 48 14 140 171 36 28 22 5 49 17 5 10 14 13 1 3 3 9979\r\n", "output": ["NO"]}, {"input": "3495 83\r\n2775 2523 1178 512 3171 1159 1382 2146 2192 1823 799 231 502 16 99 309 656 665 222 285 11 106 244 137 241 45 41 29 485 6 62 38 94 5 7 93 48 5 10 13 2 1 2 1 4 8 5 9 4 6 1 1 1 3 4 3 7 1 2 3 1 1 7 1 1 2 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 3443\r\n", "output": ["NO"]}, {"input": "1000 40\r\n1701 1203 67 464 1884 761 11 559 29 115 405 133 174 63 147 93 41 19 1 15 41 8 33 4 4 1 4 1 1 2 1 2 1 1 2 1 1 2 1 4\r\n", "output": ["NO"]}, {"input": "347 20\r\n55 390 555 426 140 360 29 115 23 113 58 30 33 1 23 3 35 5 7 363\r\n", "output": ["NO"]}, {"input": "10000 100\r\n749 2244 949 2439 2703 44 2394 124 285 3694 3609 717 1413 155 974 1778 1448 1327 1487 3458 319 1395 3783 2184 2062 43 826 38 3276 807 1837 4635 171 1386 1768 1128 2020 2536 800 782 3058 174 455 83 647 595 658 109 33 23 70 39 38 1 6 35 94 9 22 12 6 1 2 2 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 9940\r\n", "output": ["NO"]}, {"input": "10000 93\r\n1388 119 711 23 4960 4002 2707 188 813 1831 334 543 338 3402 1808 3368 1428 971 985 220 1521 457 457 140 332 1503 1539 2095 1891 269 5223 226 1528 190 428 5061 410 1587 1149 1934 2275 1337 1828 275 181 85 499 29 585 808 751 401 635 461 181 164 274 36 401 255 38 60 76 16 6 35 79 46 1 39 11 2 8 2 4 14 3 1 1 1 1 1 2 1 3 1 1 1 1 2 1 1 9948\r\n", "output": ["NO"]}, {"input": "4981 51\r\n5364 2166 223 742 350 1309 15 229 4100 3988 227 1719 9 125 787 427 141 842 171 2519 32 2554 2253 721 775 88 720 9 397 513 100 291 111 32 238 42 152 108 5 58 96 53 7 19 11 2 5 5 6 2 4966\r\n", "output": ["NO"]}, {"input": "541 31\r\n607 204 308 298 398 213 1182 58 162 46 64 12 38 91 29 2 4 12 19 3 7 9 3 6 1 1 2 1 3 1 529\r\n", "output": ["YES"]}, {"input": "100 100\r\n6 129 61 6 87 104 45 28 3 35 2 14 1 37 2 4 24 4 3 1 6 4 2 1 1 3 1 2 2 9 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 22\r\n", "output": ["NO"]}, {"input": "1 4\r\n2 2 2 1\r\n", "output": ["YES"]}, {"input": "1 3\r\n2 2 2\r\n", "output": ["YES"]}, {"input": "2 5\r\n8 2 2 2 2\r\n", "output": ["YES"]}, {"input": "1 4\r\n1 1 2 2\r\n", "output": ["YES"]}, {"input": "1 3\r\n2 2 3\r\n", "output": ["YES"]}, {"input": "1 3\r\n4 2 2\r\n", "output": ["YES"]}, {"input": "1 4\r\n2 1 2 2\r\n", "output": ["YES"]}, {"input": "1 3\r\n3 2 2\r\n", "output": ["YES"]}, {"input": "2 8\r\n2 2 2 2 2 2 1 1\r\n", "output": ["YES"]}, {"input": "2 6\r\n2 2 2 2 2 2\r\n", "output": ["YES"]}, {"input": "1 4\r\n1 2 2 2\r\n", "output": ["YES"]}, {"input": "1 4\r\n1 1 1 1\r\n", "output": ["YES"]}, {"input": "2 7\r\n2 2 2 2 2 2 2\r\n", "output": ["YES"]}, {"input": "2 8\r\n1 1 1 1 1 1 1 1\r\n", "output": ["YES"]}, {"input": "3 7\r\n12 2 2 2 2 2 2\r\n", "output": ["YES"]}, {"input": "2 6\r\n4 1 3 1 1 3\r\n", "output": ["NO"]}, {"input": "1 3\r\n2 2 4\r\n", "output": ["YES"]}, {"input": "5 15\r\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\r\n", "output": ["YES"]}, {"input": "2 8\r\n2 2 2 2 1 1 1 1\r\n", "output": ["YES"]}, {"input": "1 2\r\n6 2\r\n", "output": ["YES"]}, {"input": "4 13\r\n2 2 2 2 2 2 2 2 2 2 2 2 4\r\n", "output": ["YES"]}, {"input": "2 7\r\n1 1 1 4 2 2 2\r\n", "output": ["YES"]}, {"input": "3 8\r\n8 2 2 2 2 2 2 2\r\n", "output": ["YES"]}, {"input": "2 8\r\n1 1 1 1 2 2 2 2\r\n", "output": ["YES"]}, {"input": "2 8\r\n2 2 2 2 1 1 2 2\r\n", "output": ["YES"]}, {"input": "1 4\r\n2 2 1 1\r\n", "output": ["YES"]}, {"input": "3 9\r\n2 2 2 2 2 2 2 2 2\r\n", "output": ["YES"]}, {"input": "2 6\r\n2 2 2 2 2 5\r\n", "output": ["YES"]}, {"input": "1 1\r\n6\r\n", "output": ["YES"]}, {"input": "2 1\r\n16\r\n", "output": ["YES"]}, {"input": "1 1\r\n2\r\n", "output": ["YES"]}, {"input": "2 8\r\n2 2 2 2 2 2 2 1\r\n", "output": ["NO"]}, {"input": "4 16\r\n1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2\r\n", "output": ["YES"]}, {"input": "2 7\r\n4 1 1 1 1 2 2\r\n", "output": ["YES"]}, {"input": "2 6\r\n2 2 2 5 2 2\r\n", "output": ["YES"]}, {"input": "3 1\r\n22\r\n", "output": ["YES"]}, {"input": "2 8\r\n2 2 2 2 1 1 1 3\r\n", "output": ["NO"]}, {"input": "3 12\r\n2 1 2 2 2 1 2 2 2 1 2 2\r\n", "output": ["YES"]}, {"input": "1 4\r\n2 2 3 1\r\n", "output": ["NO"]}, {"input": "2 6\r\n5 2 2 2 2 2\r\n", "output": ["YES"]}, {"input": "20 100\r\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\r\n", "output": ["NO"]}, {"input": "1 3\r\n2 2 1\r\n", "output": ["YES"]}, {"input": "1 2\r\n3 3\r\n", "output": ["YES"]}, {"input": "2 6\r\n2 3 2 2 3 2\r\n", "output": ["YES"]}, {"input": "2 8\r\n2 2 1 1 2 2 2 2\r\n", "output": ["YES"]}, {"input": "2 6\r\n3 3 2 2 2 2\r\n", "output": ["YES"]}, {"input": "3 12\r\n2 2 2 2 2 2 2 2 2 1 1 1\r\n", "output": ["YES"]}, {"input": "3 10\r\n2 2 2 2 2 2 2 2 2 3\r\n", "output": ["YES"]}]
100
100
100
[{'input': '1 4\r\n2 1 2 2\r\n', 'output': ['YES']}, {'input': '1 3\r\n2 2 1\r\n', 'output': ['YES']}, {'input': '10000 100\r\n800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800\r\n', 'output': ['YES']}, {'input': '1 2\r\n4 4\r\n', 'output': ['YES']}, {'input': '10000 93\r\n1388 119 711 23 4960 4002 2707 188 813 1831 334 543 338 3402 1808 3368 1428 971 985 220 1521 457 457 140 332 1503 1539 2095 1891 269 5223 226 1528 190 428 5061 410 1587 1149 1934 2275 1337 1828 275 181 85 499 29 585 808 751 401 635 461 181 164 274 36 401 255 38 60 76 16 6 35 79 46 1 39 11 2 8 2 4 14 3 1 1 1 1 1 2 1 3 1 1 1 1 2 1 1 9948\r\n', 'output': ['NO']}]
[{'input': '10000 100\r\n749 2244 949 2439 2703 44 2394 124 285 3694 3609 717 1413 155 974 1778 1448 1327 1487 3458 319 1395 3783 2184 2062 43 826 38 3276 807 1837 4635 171 1386 1768 1128 2020 2536 800 782 3058 174 455 83 647 595 658 109 33 23 70 39 38 1 6 35 94 9 22 12 6 1 2 2 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 9939\r\n', 'output': ['NO']}, {'input': '4981 51\r\n5364 2166 223 742 350 1309 15 229 4100 3988 227 1719 9 125 787 427 141 842 171 2519 32 2554 2253 721 775 88 720 9 397 513 100 291 111 32 238 42 152 108 5 58 96 53 7 19 11 2 5 5 6 2 4966\r\n', 'output': ['NO']}, {'input': '1 4\r\n2 2 2 1\r\n', 'output': ['YES']}, {'input': '10000 100\r\n749 2244 949 2439 2703 44 2394 124 285 3694 3609 717 1413 155 974 1778 1448 1327 1487 3458 319 1395 3783 2184 2062 43 826 38 3276 807 1837 4635 171 1386 1768 1128 2020 2536 2050 1074 605 979 1724 1608 672 88 1243 129 718 544 3590 37 187 600 738 34 64 316 58 6 84 252 75 68 40 68 4 29 29 8 13 11 5 1 5 1 3 2 1 1 1 2 3 4 1 1 2 2 2 1 1 1 1 1 1 1 1 1 1 3\r\n', 'output': ['NO']}, {'input': '1 4\r\n2 2 1 2\r\n', 'output': ['YES']}]
[{'input': '541 31\r\n607 204 308 298 398 213 1182 58 162 46 64 12 38 91 29 2 4 12 19 3 7 9 3 6 1 1 2 1 3 1 529\r\n', 'output': ['YES']}, {'input': '5691 91\r\n6573 1666 2158 2591 4636 886 263 4217 389 29 1513 1172 617 2012 1855 798 1588 979 152 37 890 375 1091 839 385 382 1 255 117 289 119 224 182 69 19 71 115 13 4 22 35 2 60 12 6 12 19 9 3 2 2 6 5 1 7 7 3 1 5 1 7 1 4 1 1 3 2 1 2 1 1 2 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 5631\r\n', 'output': ['NO']}, {'input': '1 4\r\n1 1 2 2\r\n', 'output': ['YES']}, {'input': '100 15\r\n165 26 83 64 235 48 36 51 3 18 5 10 9 6 5\r\n', 'output': ['YES']}, {'input': '1 2\r\n3 3\r\n', 'output': ['YES']}]
[{'input': '4 16\r\n1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2\r\n', 'output': ['YES']}, {'input': '2 6\r\n3 3 2 2 2 2\r\n', 'output': ['YES']}, {'input': '10000 100\r\n749 2244 949 2439 2703 44 2394 124 285 3694 3609 717 1413 155 974 1778 1448 1327 1487 3458 319 1395 3783 2184 2062 43 826 38 3276 807 1837 4635 171 1386 1768 1128 2020 2536 800 782 3058 174 455 83 647 595 658 109 33 23 70 39 38 1 6 35 94 9 22 12 6 1 2 2 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 9939\r\n', 'output': ['NO']}, {'input': '1000 40\r\n1701 1203 67 464 1884 761 11 559 29 115 405 133 174 63 147 93 41 19 1 15 41 8 33 4 4 1 4 1 1 2 1 2 1 1 2 1 1 2 1 4\r\n', 'output': ['NO']}, {'input': '1 4\r\n2 2 2 2\r\n', 'output': ['NO']}]
[{'input': '2 7\r\n2 2 2 2 2 2 2\r\n', 'output': ['YES']}, {'input': '1 4\r\n2 2 2 1\r\n', 'output': ['YES']}, {'input': '2 6\r\n2 2 2 2 2 5\r\n', 'output': ['YES']}, {'input': '1 3\r\n2 2 4\r\n', 'output': ['YES']}, {'input': '5691 91\r\n6573 1666 2158 2591 4636 886 263 4217 389 29 1513 1172 617 2012 1855 798 1588 979 152 37 890 375 1091 839 385 382 1 255 117 289 119 224 182 69 19 71 115 13 4 22 35 2 60 12 6 12 19 9 3 2 2 6 5 1 7 7 3 1 5 1 7 1 4 1 1 3 2 1 2 1 1 2 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 5631\r\n', 'output': ['NO']}]
100
100
100
100
100
92.86
92.86
92.86
100
100
93.75
93.75
93.75
100
100
350
100
95.716
96.25
["5 1 2 1 2", "3 3 1 1 1", "4 5 3 1 5"]
The first line contains five integers s, v1, v2, t1, t2 (1 ≀ s, v1, v2, t1, t2 ≀ 1000)Β β€” the number of characters in the text, the time of typing one character for the first participant, the time of typing one character for the the second participant, the ping of the first participant and the ping of the second participant.
10226b8efe9e3c473239d747b911a1ef
def t(a,b,c,d,e): #for i in range(5): # v.append (int(input("podaj liczbe"))) gr1=0 gr2=0 gr1=(b*a)+(d*2) gr2=(c*a)+(e*2) #print(gr1) #print(gr2) if gr1>gr2: print("Second") if gr1<gr2: print("First") if gr1==gr2: print("Friendship") a,b,c,d,e = input().split(" ") t(int(a),int(b),int(c),int(d),int(e))
["First", "Second", "Friendship"]
Python
NoteIn the first example, information on the success of the first participant comes in 7 milliseconds, of the second participantΒ β€” in 14 milliseconds. So, the first wins.In the second example, information on the success of the first participant comes in 11 milliseconds, of the second participantΒ β€” in 5 milliseconds. So, the second wins.In the third example, information on the success of the first participant comes in 22 milliseconds, of the second participantΒ β€” in 22 milliseconds. So, it is be a draw.
If the first participant wins, print "First". If the second participant wins, print "Second". In case of a draw print "Friendship".
Two boys decided to compete in text typing on the site "Key races". During the competition, they have to type a text consisting of s characters. The first participant types one character in v1 milliseconds and has ping t1 milliseconds. The second participant types one character in v2 milliseconds and has ping t2 milliseconds.If connection ping (delay) is t milliseconds, the competition passes for a participant as follows: Exactly after t milliseconds after the start of the competition the participant receives the text to be entered. Right after that he starts to type it. Exactly t milliseconds after he ends typing all the text, the site receives information about it. The winner is the participant whose information on the success comes earlier. If the information comes from both participants at the same time, it is considered that there is a draw.Given the length of the text and the information about participants, determine the result of the game.
[{"input": "5 1 2 1 2\r\n", "output": ["First"]}, {"input": "3 3 1 1 1\r\n", "output": ["Second"]}, {"input": "4 5 3 1 5\r\n", "output": ["Friendship"]}, {"input": "1000 1000 1000 1000 1000\r\n", "output": ["Friendship"]}, {"input": "1 1 1 1 1\r\n", "output": ["Friendship"]}, {"input": "8 8 1 1 1\r\n", "output": ["Second"]}, {"input": "15 14 32 65 28\r\n", "output": ["First"]}, {"input": "894 197 325 232 902\r\n", "output": ["First"]}, {"input": "1 2 8 8 5\r\n", "output": ["Friendship"]}, {"input": "37 261 207 1 1000\r\n", "output": ["Friendship"]}, {"input": "29 344 406 900 1\r\n", "output": ["Friendship"]}, {"input": "1 2 8 9 8\r\n", "output": ["First"]}, {"input": "2 9 8 8 9\r\n", "output": ["Friendship"]}, {"input": "213 480 811 134 745\r\n", "output": ["First"]}, {"input": "2 313 856 964 421\r\n", "output": ["Friendship"]}, {"input": "1 10 2 6 10\r\n", "output": ["Friendship"]}, {"input": "2 7 6 2 3\r\n", "output": ["Friendship"]}, {"input": "637 324 69 612 998\r\n", "output": ["Second"]}, {"input": "13 849 819 723 918\r\n", "output": ["Friendship"]}, {"input": "9 5 7 8 7\r\n", "output": ["First"]}, {"input": "6 5 7 10 4\r\n", "output": ["Friendship"]}, {"input": "61 464 623 89 548\r\n", "output": ["First"]}, {"input": "641 31 29 161 802\r\n", "output": ["Friendship"]}, {"input": "3 3 1 6 9\r\n", "output": ["Friendship"]}, {"input": "2 3 9 8 2\r\n", "output": ["Friendship"]}, {"input": "485 117 368 567 609\r\n", "output": ["First"]}, {"input": "4 202 512 995 375\r\n", "output": ["Friendship"]}, {"input": "424 41 41 909 909\r\n", "output": ["Friendship"]}, {"input": "884 913 263 641 265\r\n", "output": ["Second"]}, {"input": "12 462 8 311 327\r\n", "output": ["Second"]}, {"input": "436 306 266 493 580\r\n", "output": ["Second"]}, {"input": "69 1 2 1 2\r\n", "output": ["First"]}]
100
100
100
[{'input': '6 5 7 10 4\r\n', 'output': ['Friendship']}, {'input': '894 197 325 232 902\r\n', 'output': ['First']}, {'input': '213 480 811 134 745\r\n', 'output': ['First']}, {'input': '5 1 2 1 2\r\n', 'output': ['First']}, {'input': '1 2 8 9 8\r\n', 'output': ['First']}]
[{'input': '424 41 41 909 909\r\n', 'output': ['Friendship']}, {'input': '641 31 29 161 802\r\n', 'output': ['Friendship']}, {'input': '1 10 2 6 10\r\n', 'output': ['Friendship']}, {'input': '2 313 856 964 421\r\n', 'output': ['Friendship']}, {'input': '894 197 325 232 902\r\n', 'output': ['First']}]
[{'input': '12 462 8 311 327\r\n', 'output': ['Second']}, {'input': '2 313 856 964 421\r\n', 'output': ['Friendship']}, {'input': '485 117 368 567 609\r\n', 'output': ['First']}, {'input': '6 5 7 10 4\r\n', 'output': ['Friendship']}, {'input': '1 10 2 6 10\r\n', 'output': ['Friendship']}]
[{'input': '1 1 1 1 1\r\n', 'output': ['Friendship']}, {'input': '1 2 8 9 8\r\n', 'output': ['First']}, {'input': '12 462 8 311 327\r\n', 'output': ['Second']}, {'input': '61 464 623 89 548\r\n', 'output': ['First']}, {'input': '641 31 29 161 802\r\n', 'output': ['Friendship']}]
[{'input': '485 117 368 567 609\r\n', 'output': ['First']}, {'input': '884 913 263 641 265\r\n', 'output': ['Second']}, {'input': '1 1 1 1 1\r\n', 'output': ['Friendship']}, {'input': '2 313 856 964 421\r\n', 'output': ['Friendship']}, {'input': '6 5 7 10 4\r\n', 'output': ['Friendship']}]
100
100
100
100
100
92.31
92.31
100
100
100
83.33
83.33
100
100
100
351
100
96.924
93.332
["0 1 1 1 1 0", "1 1 0 0 1000 1000"]
The only line contains six integers ax, ay, bx, by, cx, cy (|ax|, |ay|, |bx|, |by|, |cx|, |cy| ≀ 109). It's guaranteed that the points are distinct.
05ec6ec3e9ffcc0e856dc0d461e6eeab
ax,ay,bx,by,cx,cy=list(map(int,input().split())) ax-=bx ay-=by cx-=bx cy-=by print('No'if ax*cy-ay*cx==0 or ax**2+ay**2!=cx**2+cy**2 else'Yes')
["Yes", "No"]
Python
NoteIn the first sample test, rotate the page around (0.5, 0.5) by .In the second sample test, you can't find any solution.
Print "Yes" if the problem has a solution, "No" otherwise. You can print each letter in any case (upper or lower).
Arpa is taking a geometry exam. Here is the last problem of the exam.You are given three points a, b, c.Find a point and an angle such that if we rotate the page around the point by the angle, the new position of a is the same as the old position of b, and the new position of b is the same as the old position of c.Arpa is doubting if the problem has a solution or not (i.e. if there exists a point and an angle satisfying the condition). Help Arpa determine if the question has a solution or not.
[{"input": "0 1 1 1 1 0\r\n", "output": ["YES", "Yes"]}, {"input": "1 1 0 0 1000 1000\r\n", "output": ["No", "NO"]}, {"input": "1 0 2 0 3 0\r\n", "output": ["No", "NO"]}, {"input": "3 4 0 0 4 3\r\n", "output": ["YES", "Yes"]}, {"input": "-1000000000 1 0 0 1000000000 1\r\n", "output": ["YES", "Yes"]}, {"input": "49152 0 0 0 0 81920\r\n", "output": ["No", "NO"]}, {"input": "1 -1 4 4 2 -3\r\n", "output": ["No", "NO"]}, {"input": "-2 -2 1 4 -2 0\r\n", "output": ["No", "NO"]}, {"input": "5 0 4 -2 0 1\r\n", "output": ["No", "NO"]}, {"input": "-4 -3 2 -1 -3 4\r\n", "output": ["No", "NO"]}, {"input": "-3 -3 5 2 3 -1\r\n", "output": ["No", "NO"]}, {"input": "-1000000000 -1000000000 0 0 1000000000 999999999\r\n", "output": ["No", "NO"]}, {"input": "-1000000000 -1000000000 0 0 1000000000 1000000000\r\n", "output": ["No", "NO"]}, {"input": "-357531221 381512519 -761132895 -224448284 328888775 -237692564\r\n", "output": ["No", "NO"]}, {"input": "264193194 -448876521 736684426 -633906160 -328597212 -47935734\r\n", "output": ["No", "NO"]}, {"input": "419578772 -125025887 169314071 89851312 961404059 21419450\r\n", "output": ["No", "NO"]}, {"input": "-607353321 -620687860 248029390 477864359 728255275 -264646027\r\n", "output": ["No", "NO"]}, {"input": "299948862 -648908808 338174789 841279400 -850322448 350263551\r\n", "output": ["No", "NO"]}, {"input": "48517753 416240699 7672672 272460100 -917845051 199790781\r\n", "output": ["No", "NO"]}, {"input": "-947393823 -495674431 211535284 -877153626 -522763219 -778236665\r\n", "output": ["No", "NO"]}, {"input": "-685673792 -488079395 909733355 385950193 -705890324 256550506\r\n", "output": ["No", "NO"]}, {"input": "-326038504 547872194 49630307 713863100 303770000 -556852524\r\n", "output": ["No", "NO"]}, {"input": "-706921242 -758563024 -588592101 -443440080 858751713 238854303\r\n", "output": ["No", "NO"]}, {"input": "-1000000000 -1000000000 0 1000000000 1000000000 -1000000000\r\n", "output": ["YES", "Yes"]}, {"input": "1000000000 1000000000 0 -1000000000 -1000000000 1000000000\r\n", "output": ["YES", "Yes"]}, {"input": "-999999999 -1000000000 0 0 1000000000 999999999\r\n", "output": ["YES", "Yes"]}, {"input": "-1000000000 -999999999 0 0 1000000000 999999999\r\n", "output": ["No", "NO"]}, {"input": "-1 -1000000000 0 1000000000 1 -1000000000\r\n", "output": ["YES", "Yes"]}, {"input": "0 1000000000 1 0 0 -1000000000\r\n", "output": ["YES", "Yes"]}, {"input": "0 1000000000 0 0 0 -1000000000\r\n", "output": ["No", "NO"]}, {"input": "0 1 1 2 2 3\r\n", "output": ["No", "NO"]}, {"input": "999999999 1000000000 0 0 -1000000000 -999999999\r\n", "output": ["YES", "Yes"]}, {"input": "0 0 1 1 2 0\r\n", "output": ["YES", "Yes"]}, {"input": "0 0 1 1 2 2\r\n", "output": ["No", "NO"]}, {"input": "1 1 2 2 3 3\r\n", "output": ["No", "NO"]}, {"input": "0 2 0 3 0 4\r\n", "output": ["No", "NO"]}, {"input": "1 1 1 2 1 3\r\n", "output": ["No", "NO"]}, {"input": "0 0 3 4 3 9\r\n", "output": ["YES", "Yes"]}, {"input": "589824 196608 262144 196608 0 0\r\n", "output": ["YES", "Yes"]}, {"input": "0 0 1000000000 1 1000000000 -999999999\r\n", "output": ["No", "NO"]}, {"input": "0 0 2 45 0 90\r\n", "output": ["YES", "Yes"]}, {"input": "0 0 0 2 0 1\r\n", "output": ["No", "NO"]}, {"input": "0 2 4 5 4 0\r\n", "output": ["YES", "Yes"]}, {"input": "0 0 2 0 4 0\r\n", "output": ["No", "NO"]}, {"input": "1 1 3 3 5 5\r\n", "output": ["No", "NO"]}, {"input": "1 1 2 2 3 1\r\n", "output": ["YES", "Yes"]}]
100
100
100
[{'input': '-1000000000 -1000000000 0 1000000000 1000000000 -1000000000\r\n', 'output': ['YES', 'Yes']}, {'input': '0 1000000000 0 0 0 -1000000000\r\n', 'output': ['No', 'NO']}, {'input': '419578772 -125025887 169314071 89851312 961404059 21419450\r\n', 'output': ['No', 'NO']}, {'input': '-607353321 -620687860 248029390 477864359 728255275 -264646027\r\n', 'output': ['No', 'NO']}, {'input': '-999999999 -1000000000 0 0 1000000000 999999999\r\n', 'output': ['YES', 'Yes']}]
[{'input': '-3 -3 5 2 3 -1\r\n', 'output': ['No', 'NO']}, {'input': '1 1 0 0 1000 1000\r\n', 'output': ['No', 'NO']}, {'input': '48517753 416240699 7672672 272460100 -917845051 199790781\r\n', 'output': ['No', 'NO']}, {'input': '0 0 1000000000 1 1000000000 -999999999\r\n', 'output': ['No', 'NO']}, {'input': '-1000000000 1 0 0 1000000000 1\r\n', 'output': ['YES', 'Yes']}]
[{'input': '5 0 4 -2 0 1\r\n', 'output': ['No', 'NO']}, {'input': '589824 196608 262144 196608 0 0\r\n', 'output': ['YES', 'Yes']}, {'input': '0 0 1 1 2 0\r\n', 'output': ['YES', 'Yes']}, {'input': '-947393823 -495674431 211535284 -877153626 -522763219 -778236665\r\n', 'output': ['No', 'NO']}, {'input': '-1000000000 -1000000000 0 0 1000000000 1000000000\r\n', 'output': ['No', 'NO']}]
[{'input': '0 2 0 3 0 4\r\n', 'output': ['No', 'NO']}, {'input': '49152 0 0 0 0 81920\r\n', 'output': ['No', 'NO']}, {'input': '264193194 -448876521 736684426 -633906160 -328597212 -47935734\r\n', 'output': ['No', 'NO']}, {'input': '0 1000000000 1 0 0 -1000000000\r\n', 'output': ['YES', 'Yes']}, {'input': '-1000000000 1 0 0 1000000000 1\r\n', 'output': ['YES', 'Yes']}]
[{'input': '-326038504 547872194 49630307 713863100 303770000 -556852524\r\n', 'output': ['No', 'NO']}, {'input': '-4 -3 2 -1 -3 4\r\n', 'output': ['No', 'NO']}, {'input': '0 2 0 3 0 4\r\n', 'output': ['No', 'NO']}, {'input': '999999999 1000000000 0 0 -1000000000 -999999999\r\n', 'output': ['YES', 'Yes']}, {'input': '1 1 2 2 3 3\r\n', 'output': ['No', 'NO']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
352
100
100
100
["3 1\n2 1 4", "3 0\n7 7 7", "6 3\n1 3 4 6 9 10"]
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 ≀ xi ≀ 100)Β β€” the coordinates of the points.
6bcb324c072f796f4d50bafea5f624b2
x=input() x=x.split(' ') n=int(x[0]) d=int(x[1]) x=input() x=x.split(' ') for i in range(n): x[i]=int(x[i]) x.sort() l = [] for i in range(0, n): for j in range(i+1, n): if (x[j]-x[i])<=d: l.append(i + (n - j) - 1) if l == []: print(n-1) else: print(min(l))
["1", "0", "3"]
Python
NoteIn the first test case the optimal strategy is to remove the point with coordinate 4. The remaining points will have coordinates 1 and 2, so the diameter will be equal to 2 - 1 = 1.In the second test case the diameter is equal to 0, so its is unnecessary to remove any points. In the third test case the optimal strategy is to remove points with coordinates 1, 9 and 10. The remaining points will have coordinates 3, 4 and 6, so the diameter will be equal to 6 - 3 = 3.
Output a single integerΒ β€” the minimum number of points you have to remove.
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?
[{"input": "3 1\r\n2 1 4\r\n", "output": ["1"]}, {"input": "3 0\r\n7 7 7\r\n", "output": ["0"]}, {"input": "6 3\r\n1 3 4 6 9 10\r\n", "output": ["3"]}, {"input": "11 5\r\n10 11 12 13 14 15 16 17 18 19 20\r\n", "output": ["5"]}, {"input": "1 100\r\n1\r\n", "output": ["0"]}, {"input": "100 10\r\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\r\n", "output": ["84"]}, {"input": "100 70\r\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\r\n", "output": ["27"]}, {"input": "1 10\r\n25\r\n", "output": ["0"]}, {"input": "70 80\r\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\r\n", "output": ["0"]}, {"input": "3 1\r\n25 26 27\r\n", "output": ["1"]}, {"input": "100 5\r\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\r\n", "output": ["34"]}, {"input": "100 11\r\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\r\n", "output": ["70"]}, {"input": "100 0\r\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\r\n", "output": ["96"]}, {"input": "100 100\r\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\r\n", "output": ["0"]}, {"input": "76 32\r\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\r\n", "output": ["13"]}, {"input": "100 1\r\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\r\n", "output": ["93"]}, {"input": "100 5\r\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\r\n", "output": ["89"]}, {"input": "98 64\r\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\r\n", "output": ["1"]}, {"input": "100 56\r\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\r\n", "output": ["43"]}, {"input": "100 0\r\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\r\n", "output": ["50"]}, {"input": "100 0\r\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\r\n", "output": ["89"]}, {"input": "100 100\r\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\r\n", "output": ["0"]}, {"input": "1 100\r\n22\r\n", "output": ["0"]}, {"input": "1 0\r\n22\r\n", "output": ["0"]}, {"input": "1 99\r\n99\r\n", "output": ["0"]}, {"input": "1 5\r\n6\r\n", "output": ["0"]}, {"input": "3 1\r\n10 20 30\r\n", "output": ["2"]}, {"input": "3 0\r\n1 2 3\r\n", "output": ["2"]}, {"input": "3 2\r\n1 50 99\r\n", "output": ["2"]}, {"input": "7 4\r\n1 3 4 9 10 11 12\r\n", "output": ["3"]}, {"input": "2 5\r\n67 23\r\n", "output": ["1"]}, {"input": "4 2\r\n1 4 7 9\r\n", "output": ["2"]}, {"input": "2 0\r\n1 2\r\n", "output": ["1"]}, {"input": "8 1\r\n3 3 3 5 5 5 5 5\r\n", "output": ["3"]}, {"input": "5 1\r\n3 5 5 5 6\r\n", "output": ["1"]}]
100
100
100
[{'input': '100 5\r\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\r\n', 'output': ['34']}, {'input': '3 0\r\n7 7 7\r\n', 'output': ['0']}, {'input': '100 0\r\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\r\n', 'output': ['96']}, {'input': '1 0\r\n22\r\n', 'output': ['0']}, {'input': '98 64\r\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\r\n', 'output': ['1']}]
[{'input': '100 0\r\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\r\n', 'output': ['89']}, {'input': '7 4\r\n1 3 4 9 10 11 12\r\n', 'output': ['3']}, {'input': '3 1\r\n25 26 27\r\n', 'output': ['1']}, {'input': '3 0\r\n7 7 7\r\n', 'output': ['0']}, {'input': '100 10\r\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\r\n', 'output': ['84']}]
[{'input': '1 100\r\n1\r\n', 'output': ['0']}, {'input': '4 2\r\n1 4 7 9\r\n', 'output': ['2']}, {'input': '2 5\r\n67 23\r\n', 'output': ['1']}, {'input': '1 0\r\n22\r\n', 'output': ['0']}, {'input': '11 5\r\n10 11 12 13 14 15 16 17 18 19 20\r\n', 'output': ['5']}]
[{'input': '3 1\r\n10 20 30\r\n', 'output': ['2']}, {'input': '100 11\r\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\r\n', 'output': ['70']}, {'input': '100 0\r\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\r\n', 'output': ['89']}, {'input': '100 70\r\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\r\n', 'output': ['27']}, {'input': '98 64\r\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\r\n', 'output': ['1']}]
[{'input': '3 0\r\n7 7 7\r\n', 'output': ['0']}, {'input': '2 5\r\n67 23\r\n', 'output': ['1']}, {'input': '100 1\r\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\r\n', 'output': ['93']}, {'input': '7 4\r\n1 3 4 9 10 11 12\r\n', 'output': ['3']}, {'input': '1 99\r\n99\r\n', 'output': ['0']}]
100
100
100
100
100
100
94.12
100
100
100
100
90
100
100
100
353
100
98.824
98
["3 10 3 3", "3 10 1 3", "100 100 1 1000"]
The first line contains four space-separated integers k, a, b, v (2 ≀ k ≀ 1000; 1 ≀ a, b, v ≀ 1000) β€” the maximum number of sections in the box, the number of nuts, the number of divisors and the capacity of each section of the box.
7cff20b1c63a694baca69bdf4bdb2652
k,a,b,v = map(int, input().split()) answ = 0 while a != 0 and b != 0: a -= min(v*min(k,b+1),a) b -= min(k-1,b) answ+=1 answ += a//v + int(a%v != 0) print(answ)
["2", "3", "1"]
Python
NoteIn the first sample you can act like this: Put two divisors to the first box. Now the first box has three sections and we can put three nuts into each section. Overall, the first box will have nine nuts. Do not put any divisors into the second box. Thus, the second box has one section for the last nut. In the end we've put all the ten nuts into boxes.The second sample is different as we have exactly one divisor and we put it to the first box. The next two boxes will have one section each.
Print a single integer β€” the answer to the problem.
You have a nuts and lots of boxes. The boxes have a wonderful feature: if you put x (x β‰₯ 0) divisors (the spacial bars that can divide a box) to it, you get a box, divided into x + 1 sections.You are minimalist. Therefore, on the one hand, you are against dividing some box into more than k sections. On the other hand, you are against putting more than v nuts into some section of the box. What is the minimum number of boxes you have to use if you want to put all the nuts in boxes, and you have b divisors?Please note that you need to minimize the number of used boxes, not sections. You do not have to minimize the number of used divisors.
[{"input": "3 10 3 3\r\n", "output": ["2"]}, {"input": "3 10 1 3\r\n", "output": ["3"]}, {"input": "100 100 1 1000\r\n", "output": ["1"]}, {"input": "5 347 20 1\r\n", "output": ["327"]}, {"input": "6 978 10 5\r\n", "output": ["186"]}, {"input": "6 856 50 35\r\n", "output": ["5"]}, {"input": "8 399 13 36\r\n", "output": ["2"]}, {"input": "4 787 48 4\r\n", "output": ["149"]}, {"input": "4 714 7 6\r\n", "output": ["112"]}, {"input": "7 915 12 24\r\n", "output": ["27"]}, {"input": "8 995 3 28\r\n", "output": ["33"]}, {"input": "10 267 4 48\r\n", "output": ["2"]}, {"input": "10 697 1 34\r\n", "output": ["20"]}, {"input": "7 897 49 42\r\n", "output": ["4"]}, {"input": "10 849 3 28\r\n", "output": ["28"]}, {"input": "477 492 438 690\r\n", "output": ["1"]}, {"input": "461 790 518 105\r\n", "output": ["1"]}, {"input": "510 996 830 417\r\n", "output": ["1"]}, {"input": "763 193 388 346\r\n", "output": ["1"]}, {"input": "958 380 405 434\r\n", "output": ["1"]}, {"input": "346 991 4 4\r\n", "output": ["244"]}, {"input": "648 990 5 2\r\n", "output": ["490"]}, {"input": "810 1000 6 5\r\n", "output": ["194"]}, {"input": "683 995 10 1\r\n", "output": ["985"]}, {"input": "307 999 10 7\r\n", "output": ["133"]}, {"input": "974 999 3 4\r\n", "output": ["247"]}, {"input": "60 1000 2 2\r\n", "output": ["498"]}, {"input": "634 993 9 3\r\n", "output": ["322"]}, {"input": "579 990 8 9\r\n", "output": ["102"]}, {"input": "306 993 9 9\r\n", "output": ["102"]}, {"input": "845 996 1 1\r\n", "output": ["995"]}, {"input": "872 997 1 1\r\n", "output": ["996"]}, {"input": "2 990 1 1\r\n", "output": ["989"]}, {"input": "489 992 1 1\r\n", "output": ["991"]}, {"input": "638 1000 1 1\r\n", "output": ["999"]}, {"input": "2 4 1000 1\r\n", "output": ["2"]}]
100
100
100
[{'input': '634 993 9 3\r\n', 'output': ['322']}, {'input': '307 999 10 7\r\n', 'output': ['133']}, {'input': '8 399 13 36\r\n', 'output': ['2']}, {'input': '872 997 1 1\r\n', 'output': ['996']}, {'input': '763 193 388 346\r\n', 'output': ['1']}]
[{'input': '100 100 1 1000\r\n', 'output': ['1']}, {'input': '683 995 10 1\r\n', 'output': ['985']}, {'input': '2 990 1 1\r\n', 'output': ['989']}, {'input': '872 997 1 1\r\n', 'output': ['996']}, {'input': '7 915 12 24\r\n', 'output': ['27']}]
[{'input': '845 996 1 1\r\n', 'output': ['995']}, {'input': '8 399 13 36\r\n', 'output': ['2']}, {'input': '872 997 1 1\r\n', 'output': ['996']}, {'input': '638 1000 1 1\r\n', 'output': ['999']}, {'input': '7 915 12 24\r\n', 'output': ['27']}]
[{'input': '2 4 1000 1\r\n', 'output': ['2']}, {'input': '2 990 1 1\r\n', 'output': ['989']}, {'input': '306 993 9 9\r\n', 'output': ['102']}, {'input': '4 787 48 4\r\n', 'output': ['149']}, {'input': '7 915 12 24\r\n', 'output': ['27']}]
[{'input': '346 991 4 4\r\n', 'output': ['244']}, {'input': '10 849 3 28\r\n', 'output': ['28']}, {'input': '648 990 5 2\r\n', 'output': ['490']}, {'input': '2 4 1000 1\r\n', 'output': ['2']}, {'input': '763 193 388 346\r\n', 'output': ['1']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
354
100
100
100
["01.01.98\n01.01.80", "20.10.20\n10.02.30", "28.02.74\n28.02.64"]
The first line contains the date DD.MM.YY, the second line contains the date BD.BM.BY. It is guaranteed that both dates are correct, and YY and BY are always in [01;99]. It could be that by passport Bob was born after the finals. In this case, he can still change the order of numbers in date.
5418c98fe362909f7b28f95225837d33
import itertools as it month_to_days_non_leap = { 1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31, } def month_year_to_day(month, year): if year % 4 == 0 and month == 2: return 29 else: return month_to_days_non_leap[month] def good_date(day, month, year): if month > 12: return False if day > month_year_to_day(month, year): return False return True dd, mm, yy = map(int, input().split('.')) bd, bm, by = map(int, input().split('.')) found_sol = False for p_bd, p_bm, p_by in it.permutations([bd, bm, by]): if good_date(p_bd, p_bm, p_by): year_diff = yy - p_by if year_diff > 18: found_sol = True break elif year_diff < 18: continue if p_bm < mm: found_sol = True break elif p_bm > mm: continue if p_bd < dd: found_sol = True break elif p_bd > dd: continue found_sol = True break if found_sol: print("YES") else: print("NO")
["YES", "NO", "NO"]
Python
null
If it is possible to rearrange the numbers in the date of birth so that Bob will be at least 18 years old on the DD.MM.YY, output YES. In the other case, output NO. Each number contains exactly two digits and stands for day, month or year in a date. Note that it is permitted to rearrange only numbers, not digits.
The king Copa often has been reported about the Codeforces site, which is rapidly getting more and more popular among the brightest minds of the humanity, who are using it for training and competing. Recently Copa understood that to conquer the world he needs to organize the world Codeforces tournament. He hopes that after it the brightest minds will become his subordinates, and the toughest part of conquering the world will be completed.The final round of the Codeforces World Finals 20YY is scheduled for DD.MM.YY, where DD is the day of the round, MM is the month and YY are the last two digits of the year. Bob is lucky to be the first finalist form Berland. But there is one problem: according to the rules of the competition, all participants must be at least 18 years old at the moment of the finals. Bob was born on BD.BM.BY. This date is recorded in his passport, the copy of which he has already mailed to the organizers. But Bob learned that in different countries the way, in which the dates are written, differs. For example, in the US the month is written first, then the day and finally the year. Bob wonders if it is possible to rearrange the numbers in his date of birth so that he will be at least 18 years old on the day DD.MM.YY. He can always tell that in his motherland dates are written differently. Help him.According to another strange rule, eligible participant must be born in the same century as the date of the finals. If the day of the finals is participant's 18-th birthday, he is allowed to participate. As we are considering only the years from 2001 to 2099 for the year of the finals, use the following rule: the year is leap if it's number is divisible by four.
[{"input": "01.01.98\r\n01.01.80\r\n", "output": ["YES"]}, {"input": "20.10.20\r\n10.02.30\r\n", "output": ["NO"]}, {"input": "28.02.74\r\n28.02.64\r\n", "output": ["NO"]}, {"input": "05.05.25\r\n06.02.71\r\n", "output": ["NO"]}, {"input": "19.11.54\r\n29.11.53\r\n", "output": ["NO"]}, {"input": "01.06.84\r\n24.04.87\r\n", "output": ["NO"]}, {"input": "30.06.43\r\n14.09.27\r\n", "output": ["YES"]}, {"input": "09.05.55\r\n25.09.42\r\n", "output": ["NO"]}, {"input": "14.05.21\r\n02.01.88\r\n", "output": ["NO"]}, {"input": "27.12.51\r\n26.06.22\r\n", "output": ["YES"]}, {"input": "12.10.81\r\n18.11.04\r\n", "output": ["YES"]}, {"input": "26.04.11\r\n11.07.38\r\n", "output": ["NO"]}, {"input": "17.01.94\r\n17.03.58\r\n", "output": ["YES"]}, {"input": "15.01.93\r\n23.04.97\r\n", "output": ["NO"]}, {"input": "14.04.92\r\n27.05.35\r\n", "output": ["YES"]}, {"input": "13.08.91\r\n01.05.26\r\n", "output": ["YES"]}, {"input": "14.08.89\r\n05.06.65\r\n", "output": ["YES"]}, {"input": "13.11.88\r\n09.07.03\r\n", "output": ["YES"]}, {"input": "12.11.87\r\n14.08.42\r\n", "output": ["YES"]}, {"input": "11.03.86\r\n20.08.81\r\n", "output": ["NO"]}, {"input": "10.02.37\r\n25.09.71\r\n", "output": ["NO"]}, {"input": "11.06.36\r\n24.01.25\r\n", "output": ["NO"]}, {"input": "02.05.90\r\n08.03.50\r\n", "output": ["YES"]}, {"input": "15.01.15\r\n01.08.58\r\n", "output": ["NO"]}, {"input": "31.10.41\r\n27.12.13\r\n", "output": ["YES"]}, {"input": "14.06.18\r\n21.04.20\r\n", "output": ["NO"]}, {"input": "15.12.62\r\n17.12.21\r\n", "output": ["YES"]}, {"input": "13.03.69\r\n09.01.83\r\n", "output": ["NO"]}, {"input": "26.11.46\r\n03.05.90\r\n", "output": ["NO"]}, {"input": "11.12.72\r\n29.06.97\r\n", "output": ["NO"]}, {"input": "25.08.49\r\n22.10.05\r\n", "output": ["YES"]}, {"input": "08.04.74\r\n18.03.60\r\n", "output": ["NO"]}, {"input": "03.11.79\r\n10.09.61\r\n", "output": ["YES"]}, {"input": "29.03.20\r\n12.01.09\r\n", "output": ["YES"]}, {"input": "13.09.67\r\n07.09.48\r\n", "output": ["YES"]}, {"input": "23.05.53\r\n31.10.34\r\n", "output": ["YES"]}, {"input": "08.07.20\r\n27.01.01\r\n", "output": ["YES"]}, {"input": "10.05.64\r\n10.05.45\r\n", "output": ["YES"]}, {"input": "19.09.93\r\n17.05.74\r\n", "output": ["YES"]}, {"input": "14.06.61\r\n01.11.42\r\n", "output": ["YES"]}, {"input": "29.02.80\r\n29.02.60\r\n", "output": ["YES"]}, {"input": "21.02.59\r\n24.04.40\r\n", "output": ["YES"]}, {"input": "05.04.99\r\n19.08.80\r\n", "output": ["YES"]}, {"input": "02.06.59\r\n30.01.40\r\n", "output": ["YES"]}, {"input": "23.09.93\r\n12.11.74\r\n", "output": ["YES"]}, {"input": "09.08.65\r\n21.06.46\r\n", "output": ["YES"]}, {"input": "29.09.35\r\n21.07.17\r\n", "output": ["YES"]}, {"input": "30.06.58\r\n21.05.39\r\n", "output": ["YES"]}, {"input": "06.08.91\r\n05.12.73\r\n", "output": ["YES"]}, {"input": "08.07.88\r\n15.01.69\r\n", "output": ["YES"]}, {"input": "07.10.55\r\n13.05.36\r\n", "output": ["YES"]}, {"input": "22.03.79\r\n04.03.61\r\n", "output": ["YES"]}, {"input": "30.06.76\r\n03.10.57\r\n", "output": ["YES"]}, {"input": "03.03.70\r\n18.01.51\r\n", "output": ["YES"]}, {"input": "08.07.79\r\n25.08.60\r\n", "output": ["YES"]}, {"input": "01.09.92\r\n10.05.74\r\n", "output": ["YES"]}, {"input": "05.04.73\r\n28.09.54\r\n", "output": ["YES"]}, {"input": "30.08.83\r\n13.04.65\r\n", "output": ["YES"]}, {"input": "08.04.64\r\n27.01.45\r\n", "output": ["YES"]}, {"input": "10.11.95\r\n09.04.77\r\n", "output": ["YES"]}, {"input": "19.11.36\r\n17.02.21\r\n", "output": ["YES"]}, {"input": "28.02.20\r\n11.01.29\r\n", "output": ["YES"]}, {"input": "01.01.35\r\n16.02.29\r\n", "output": ["YES"]}, {"input": "01.01.47\r\n28.02.29\r\n", "output": ["YES"]}, {"input": "06.08.34\r\n16.02.29\r\n", "output": ["YES"]}, {"input": "30.09.46\r\n24.02.29\r\n", "output": ["YES"]}, {"input": "01.03.19\r\n01.02.29\r\n", "output": ["NO"]}, {"input": "30.08.32\r\n02.02.29\r\n", "output": ["NO"]}, {"input": "30.10.46\r\n25.02.29\r\n", "output": ["NO"]}, {"input": "06.03.20\r\n06.02.03\r\n", "output": ["YES"]}, {"input": "01.05.19\r\n08.01.04\r\n", "output": ["YES"]}, {"input": "31.05.19\r\n12.01.04\r\n", "output": ["YES"]}, {"input": "31.03.50\r\n02.11.32\r\n", "output": ["YES"]}, {"input": "03.12.98\r\n11.12.80\r\n", "output": ["YES"]}, {"input": "04.02.19\r\n01.03.02\r\n", "output": ["YES"]}, {"input": "01.05.21\r\n03.11.04\r\n", "output": ["YES"]}, {"input": "31.05.20\r\n02.12.04\r\n", "output": ["YES"]}, {"input": "31.03.36\r\n10.11.31\r\n", "output": ["YES"]}, {"input": "01.05.19\r\n03.01.28\r\n", "output": ["YES"]}, {"input": "30.12.68\r\n31.12.50\r\n", "output": ["NO"]}, {"input": "30.08.55\r\n31.08.37\r\n", "output": ["NO"]}, {"input": "30.08.41\r\n23.08.31\r\n", "output": ["NO"]}]
100
100
100
[{'input': '31.10.41\r\n27.12.13\r\n', 'output': ['YES']}, {'input': '20.10.20\r\n10.02.30\r\n', 'output': ['NO']}, {'input': '03.12.98\r\n11.12.80\r\n', 'output': ['YES']}, {'input': '05.04.99\r\n19.08.80\r\n', 'output': ['YES']}, {'input': '13.08.91\r\n01.05.26\r\n', 'output': ['YES']}]
[{'input': '08.04.64\r\n27.01.45\r\n', 'output': ['YES']}, {'input': '19.09.93\r\n17.05.74\r\n', 'output': ['YES']}, {'input': '30.08.83\r\n13.04.65\r\n', 'output': ['YES']}, {'input': '29.09.35\r\n21.07.17\r\n', 'output': ['YES']}, {'input': '29.02.80\r\n29.02.60\r\n', 'output': ['YES']}]
[{'input': '11.03.86\r\n20.08.81\r\n', 'output': ['NO']}, {'input': '30.08.83\r\n13.04.65\r\n', 'output': ['YES']}, {'input': '08.04.64\r\n27.01.45\r\n', 'output': ['YES']}, {'input': '05.04.99\r\n19.08.80\r\n', 'output': ['YES']}, {'input': '20.10.20\r\n10.02.30\r\n', 'output': ['NO']}]
[{'input': '19.11.36\r\n17.02.21\r\n', 'output': ['YES']}, {'input': '06.08.34\r\n16.02.29\r\n', 'output': ['YES']}, {'input': '13.11.88\r\n09.07.03\r\n', 'output': ['YES']}, {'input': '13.08.91\r\n01.05.26\r\n', 'output': ['YES']}, {'input': '10.02.37\r\n25.09.71\r\n', 'output': ['NO']}]
[{'input': '14.05.21\r\n02.01.88\r\n', 'output': ['NO']}, {'input': '05.04.73\r\n28.09.54\r\n', 'output': ['YES']}, {'input': '08.04.74\r\n18.03.60\r\n', 'output': ['NO']}, {'input': '02.06.59\r\n30.01.40\r\n', 'output': ['YES']}, {'input': '10.02.37\r\n25.09.71\r\n', 'output': ['NO']}]
100
100
100
100
100
83.33
69.44
83.33
75
66.67
83.33
45.83
83.33
70.83
62.5
355
100
75.554
69.164
["2\nRB", "3\nGRG", "5\nBBBBB"]
The first line of the input contains a single integer n (1 ≀ n ≀ 200)Β β€” the total number of cards. The next line contains a string s of length n β€” the colors of the cards. s contains only the characters 'B', 'G', and 'R', representing blue, green, and red, respectively.
4cedd3b70d793bc8ed4a93fc5a827f8f
from collections import Counter def go(s): ct = Counter(s) pos = ''.join(c for c in 'BGR' if ct[c] > 0) if len(pos) == 3 or len(pos) == 1: return pos one = ''.join(c for c in 'BGR' if ct[c] <= 1) if len(one) == 1: return 'BGR' if len(one) == 2: return one return ''.join(c for c in 'BGR' if ct[c] == 0) input() print(go(input()))
["G", "BR", "B"]
Python
NoteIn the first sample, Catherine has one red card and one blue card, which she must exchange for a green card.In the second sample, Catherine has two green cards and one red card. She has two options: she can exchange the two green cards for a green card, then exchange the new green card and the red card for a blue card. Alternatively, she can exchange a green and a red card for a blue card, then exchange the blue card and remaining green card for a red card.In the third sample, Catherine only has blue cards, so she can only exchange them for more blue cards.
Print a single string of up to three charactersΒ β€” the possible colors of the final card (using the same symbols as the input) in alphabetical order.
Catherine has a deck of n cards, each of which is either red, green, or blue. As long as there are at least two cards left, she can do one of two actions: take any two (not necessarily adjacent) cards with different colors and exchange them for a new card of the third color; take any two (not necessarily adjacent) cards with the same color and exchange them for a new card with that color. She repeats this process until there is only one card left. What are the possible colors for the final card?
[{"input": "2\r\nRB\r\n", "output": ["G"]}, {"input": "3\r\nGRG\r\n", "output": ["BR"]}, {"input": "5\r\nBBBBB\r\n", "output": ["B"]}, {"input": "1\r\nR\r\n", "output": ["R"]}, {"input": "200\r\nBBRGRRBBRGGGBGBGBGRRGRGRGRBGRGRRBBGRGBGRRGRRRGGBBRGBGBGBRBBBBBBBGGBRGGRRRGGRGBGBGGBRRRRBRRRBRBBGGBGBRGRGBBBBGGBGBBBGBGRRBRRRGBGGBBBRBGRBRRGGGRRGBBBGBGRRRRRRGGRGRGBBBRGGGBGGGBRBBRRGBGRGRBRRRBRBGRGGBRBB\r\n", "output": ["BGR"]}, {"input": "101\r\nRRRRRRRRRRRRRRRRRRRBRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\r\n", "output": ["BG"]}, {"input": "7\r\nBBBGBRG\r\n", "output": ["BGR"]}, {"input": "5\r\nGRRGR\r\n", "output": ["BGR"]}, {"input": "3\r\nGBR\r\n", "output": ["BGR"]}, {"input": "1\r\nB\r\n", "output": ["B"]}, {"input": "2\r\nBB\r\n", "output": ["B"]}, {"input": "1\r\nG\r\n", "output": ["G"]}, {"input": "2\r\nBG\r\n", "output": ["R"]}, {"input": "3\r\nBGB\r\n", "output": ["GR"]}, {"input": "2\r\nGG\r\n", "output": ["G"]}, {"input": "3\r\nGBG\r\n", "output": ["BR"]}, {"input": "4\r\nBGBG\r\n", "output": ["BGR"]}, {"input": "2\r\nBR\r\n", "output": ["G"]}, {"input": "3\r\nBRB\r\n", "output": ["GR"]}, {"input": "2\r\nRG\r\n", "output": ["B"]}, {"input": "3\r\nBGR\r\n", "output": ["BGR"]}, {"input": "4\r\nRBGB\r\n", "output": ["BGR"]}, {"input": "3\r\nGGR\r\n", "output": ["BR"]}, {"input": "4\r\nGGRB\r\n", "output": ["BGR"]}, {"input": "5\r\nBGBGR\r\n", "output": ["BGR"]}, {"input": "2\r\nRR\r\n", "output": ["R"]}, {"input": "3\r\nRBR\r\n", "output": ["BG"]}, {"input": "4\r\nRRBB\r\n", "output": ["BGR"]}, {"input": "3\r\nRRG\r\n", "output": ["BG"]}, {"input": "4\r\nBRRG\r\n", "output": ["BGR"]}, {"input": "5\r\nRBRBG\r\n", "output": ["BGR"]}, {"input": "4\r\nRGGR\r\n", "output": ["BGR"]}, {"input": "5\r\nBRGRG\r\n", "output": ["BGR"]}, {"input": "6\r\nGRRGBB\r\n", "output": ["BGR"]}, {"input": "150\r\nGRGBBBBRBGGBGBBGBBBBGRBBRRBBGRRGGGBRBBRGRRRRGBGRRBGBGBGRBBBGBBBGBGBRGBRRRRRGGGRGRBBGBRGGGRBBRGBBGRGGGBBRBRRGRGRRGRRGRRRGBGBRRGGRGGBRBGGGBBBRGRGBRGRRRR\r\n", "output": ["BGR"]}, {"input": "16\r\nRRGRRRRRRGGRGRRR\r\n", "output": ["BGR"]}, {"input": "190\r\nBBBBBBBBBBBBBBBBBGBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\n", "output": ["GR"]}, {"input": "200\r\nRGRGRRRRRGRRGRRRGRGRRRGGRGRRGGGRRGGRRRRRRRRRRRGRRGRRRGRRRGRRRRRRRGRRRRRRRRRRRGGRRGGRRRRGGRRRRRRRRRGGGRGRGRGRRGRGGRGRGRRRGRRRRRRGGRGRRRRGRRGRGGRRRRRRRGRGGRRGRRRRRRRGGRRRRGRRRRRRRGRRRGGRRRRRRGRRGGGRRRGR\r\n", "output": ["BGR"]}, {"input": "200\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\n", "output": ["G"]}, {"input": "52\r\nBBBBBBBBBBBBBBBBBBBBGBGBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\n", "output": ["BGR"]}, {"input": "200\r\nGRGRRGRBRRRGGGRGGRRRRRBBGRRGRBBGRRGBGRRBBRBBRRBBBGRBRGGGGBGGBRRBBRGRBGGRRGGBBRBGGRGBBRRBBRGBRRBGBRBGBBRGGRRRGGGBRGGGGRRRBBRRGRGRBRRGRBBGGRBBRGRGRBGRBBRGGBBBGRGBBGGBGBGBBRRBGRGRGGBRRGRGGGGGBRGGGGBBBBRB\r\n", "output": ["BGR"]}, {"input": "102\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGRGGGGGGGGBGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\n", "output": ["BGR"]}, {"input": "193\r\nRRRGGGRBGGBGGGBGGBBGRBGGRBGGBBRBGGRBBBRBRRGGBBRBRGRRRBGBBRGGRGGGBGGRRGGRGRRBRBRBRRGRGBGBRGBBRGRRRBGRGGBGBRBBBGBRBBGBGBGGGBGGGGBRBBRRBGRGGBBBRBBBBBGRRRGBRGBRRRBBBGBGGGGRGGRRBRBGRRGBGBRBGGGRBRRGG\r\n", "output": ["BGR"]}, {"input": "90\r\nBGBGGRRBGGRRRRRGGRGBBBBBRRBGBGBGBGGBBGRGGGGRBRBBRRRGBRRGBBGBBGGGRGRGRBGBBBRRGRRBRBRRGGRBRB\r\n", "output": ["BGR"]}, {"input": "3\r\nGGB\r\n", "output": ["BR"]}]
100
100
100
[{'input': '200\r\nRGRGRRRRRGRRGRRRGRGRRRGGRGRRGGGRRGGRRRRRRRRRRRGRRGRRRGRRRGRRRRRRRGRRRRRRRRRRRGGRRGGRRRRGGRRRRRRRRRGGGRGRGRGRRGRGGRGRGRRRGRRRRRRGGRGRRRRGRRGRGGRRRRRRRGRGGRRGRRRRRRRGGRRRRGRRRRRRRGRRRGGRRRRRRGRRGGGRRRGR\r\n', 'output': ['BGR']}, {'input': '4\r\nRGGR\r\n', 'output': ['BGR']}, {'input': '2\r\nRB\r\n', 'output': ['G']}, {'input': '3\r\nGGR\r\n', 'output': ['BR']}, {'input': '5\r\nGRRGR\r\n', 'output': ['BGR']}]
[{'input': '5\r\nBBBBB\r\n', 'output': ['B']}, {'input': '4\r\nRBGB\r\n', 'output': ['BGR']}, {'input': '16\r\nRRGRRRRRRGGRGRRR\r\n', 'output': ['BGR']}, {'input': '3\r\nGGR\r\n', 'output': ['BR']}, {'input': '1\r\nG\r\n', 'output': ['G']}]
[{'input': '5\r\nGRRGR\r\n', 'output': ['BGR']}, {'input': '1\r\nG\r\n', 'output': ['G']}, {'input': '3\r\nGBG\r\n', 'output': ['BR']}, {'input': '5\r\nBGBGR\r\n', 'output': ['BGR']}, {'input': '2\r\nRB\r\n', 'output': ['G']}]
[{'input': '3\r\nGBG\r\n', 'output': ['BR']}, {'input': '16\r\nRRGRRRRRRGGRGRRR\r\n', 'output': ['BGR']}, {'input': '190\r\nBBBBBBBBBBBBBBBBBGBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\n', 'output': ['GR']}, {'input': '2\r\nRB\r\n', 'output': ['G']}, {'input': '7\r\nBBBGBRG\r\n', 'output': ['BGR']}]
[{'input': '4\r\nRGGR\r\n', 'output': ['BGR']}, {'input': '200\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\n', 'output': ['G']}, {'input': '6\r\nGRRGBB\r\n', 'output': ['BGR']}, {'input': '4\r\nGGRB\r\n', 'output': ['BGR']}, {'input': '200\r\nBBRGRRBBRGGGBGBGBGRRGRGRGRBGRGRRBBGRGBGRRGRRRGGBBRGBGBGBRBBBBBBBGGBRGGRRRGGRGBGBGGBRRRRBRRRBRBBGGBGBRGRGBBBBGGBGBBBGBGRRBRRRGBGGBBBRBGRBRRGGGRRGBBBGBGRRRRRRGGRGRGBBBRGGGBGGGBRBBRRGBGRGRBRRRBRBGRGGBRBB\r\n', 'output': ['BGR']}]
100
100
100
100
100
92.86
92.86
100
100
78.57
91.67
75
100
100
58.33
356
100
92.858
85
["3 3 3\n1 1 1\n2 2 3\n3 3 2", "4 10 2\n2 3 8\n3 4 7"]
The first line contains three integers $$$n$$$, $$$h$$$, and $$$m$$$ ($$$1 \leq n,h,m \leq 50$$$)Β β€” the number of spots, the maximum height, and the number of restrictions. Each of the next $$$m$$$ lines contains three integers $$$l_i$$$, $$$r_i$$$, and $$$x_i$$$ ($$$1 \leq l_i \leq r_i \leq n$$$, $$$0 \leq x_i \leq h$$$)Β β€” left and right limits (inclusive) of the $$$i$$$-th restriction and the maximum possible height in that range.
f22b6dab443f63fb8d2d288b702f20ad
(n,h,m) = [int(x) for x in input().split()] houses= [h]*n for i in range(m): (l,r,x) = [int(x) for x in input().split()] for j in range(l-1,r): houses[j] = min(houses[j],x) mx = 0 for j in range(n): mx += houses[j]*houses[j] print(mx)
["14", "262"]
Python
NoteIn the first example, there are $$$3$$$ houses, the maximum height of a house is $$$3$$$, and there are $$$3$$$ restrictions. The first restriction says the tallest house between $$$1$$$ and $$$1$$$ must be at most $$$1$$$. The second restriction says the tallest house between $$$2$$$ and $$$2$$$ must be at most $$$3$$$. The third restriction says the tallest house between $$$3$$$ and $$$3$$$ must be at most $$$2$$$.In this case, it is optimal to build houses with heights $$$[1, 3, 2]$$$. This fits within all the restrictions. The total profit in this case is $$$1^2 + 3^2 + 2^2 = 14$$$.In the second example, there are $$$4$$$ houses, the maximum height of a house is $$$10$$$, and there are $$$2$$$ restrictions. The first restriction says the tallest house from $$$2$$$ to $$$3$$$ must be at most $$$8$$$. The second restriction says the tallest house from $$$3$$$ to $$$4$$$ must be at most $$$7$$$.In this case, it's optimal to build houses with heights $$$[10, 8, 7, 7]$$$. We get a profit of $$$10^2+8^2+7^2+7^2 = 262$$$. Note that there are two restrictions on house $$$3$$$ and both of them must be satisfied. Also, note that even though there isn't any explicit restrictions on house $$$1$$$, we must still limit its height to be at most $$$10$$$ ($$$h=10$$$).
Print a single integer, the maximum profit you can make.
You are planning to build housing on a street. There are $$$n$$$ spots available on the street on which you can build a house. The spots are labeled from $$$1$$$ to $$$n$$$ from left to right. In each spot, you can build a house with an integer height between $$$0$$$ and $$$h$$$.In each spot, if a house has height $$$a$$$, you will gain $$$a^2$$$ dollars from it.The city has $$$m$$$ zoning restrictions. The $$$i$$$-th restriction says that the tallest house from spots $$$l_i$$$ to $$$r_i$$$ (inclusive) must be at most $$$x_i$$$.You would like to build houses to maximize your profit. Determine the maximum profit possible.
[{"input": "3 3 3\r\n1 1 1\r\n2 2 3\r\n3 3 2\r\n", "output": ["14"]}, {"input": "4 10 2\r\n2 3 8\r\n3 4 7\r\n", "output": ["262"]}, {"input": "50 50 1\r\n1 50 0\r\n", "output": ["0"]}, {"input": "50 50 50\r\n17 40 12\r\n33 36 47\r\n8 43 35\r\n25 29 42\r\n18 36 6\r\n25 35 18\r\n36 48 47\r\n17 40 13\r\n20 27 37\r\n32 32 28\r\n17 20 13\r\n4 14 6\r\n13 18 47\r\n18 45 28\r\n3 50 45\r\n6 6 6\r\n3 25 36\r\n28 48 42\r\n14 34 32\r\n28 41 35\r\n29 35 25\r\n25 48 24\r\n32 40 40\r\n18 38 44\r\n6 16 2\r\n1 36 7\r\n14 48 2\r\n18 29 40\r\n11 16 37\r\n8 40 19\r\n12 16 44\r\n44 46 21\r\n19 24 26\r\n24 45 44\r\n22 22 15\r\n6 15 32\r\n19 42 7\r\n21 33 20\r\n1 13 26\r\n16 27 40\r\n46 48 30\r\n21 39 1\r\n1 9 32\r\n14 34 20\r\n35 38 11\r\n19 47 23\r\n13 38 15\r\n28 29 28\r\n7 20 40\r\n2 21 46\r\n", "output": ["4384"]}, {"input": "50 50 50\r\n20 34 50\r\n10 36 27\r\n46 49 19\r\n15 22 21\r\n5 10 21\r\n40 47 0\r\n26 43 48\r\n15 34 5\r\n29 48 49\r\n2 45 25\r\n5 40 42\r\n1 27 0\r\n43 50 47\r\n5 19 23\r\n1 42 20\r\n18 50 16\r\n13 38 14\r\n14 30 22\r\n5 26 2\r\n32 46 15\r\n10 49 37\r\n33 37 24\r\n10 31 45\r\n16 45 37\r\n22 41 7\r\n23 49 29\r\n22 44 49\r\n3 44 22\r\n26 32 4\r\n30 40 19\r\n19 28 5\r\n6 34 14\r\n16 21 40\r\n12 43 46\r\n9 36 42\r\n2 19 39\r\n13 45 12\r\n2 30 6\r\n5 28 35\r\n18 45 7\r\n39 46 29\r\n29 43 33\r\n3 16 24\r\n20 40 24\r\n35 36 8\r\n2 14 8\r\n3 29 47\r\n31 32 0\r\n27 49 16\r\n1 37 45\r\n", "output": ["1111"]}, {"input": "50 50 50\r\n28 29 9\r\n33 43 30\r\n12 34 3\r\n9 12 26\r\n24 39 10\r\n12 47 35\r\n29 41 47\r\n43 44 49\r\n19 37 36\r\n11 18 46\r\n19 42 20\r\n9 40 47\r\n18 34 22\r\n11 20 44\r\n5 31 44\r\n29 40 0\r\n1 26 19\r\n7 50 4\r\n14 34 48\r\n43 48 21\r\n12 49 23\r\n6 40 47\r\n22 37 50\r\n39 48 29\r\n12 34 13\r\n5 10 25\r\n30 45 46\r\n26 32 29\r\n2 4 23\r\n7 39 19\r\n22 49 42\r\n11 29 31\r\n23 50 29\r\n12 32 47\r\n4 13 18\r\n24 46 20\r\n33 34 44\r\n24 35 41\r\n39 50 47\r\n14 24 49\r\n25 44 28\r\n23 23 42\r\n32 44 40\r\n25 42 3\r\n25 31 6\r\n35 47 18\r\n22 49 2\r\n38 43 23\r\n1 27 16\r\n19 23 43\r\n", "output": ["1786"]}, {"input": "50 50 50\r\n24 31 47\r\n2 5 10\r\n18 22 39\r\n6 48 29\r\n30 43 25\r\n9 26 19\r\n20 40 23\r\n27 49 42\r\n41 49 50\r\n28 39 42\r\n35 37 49\r\n17 40 40\r\n26 38 21\r\n8 38 40\r\n10 28 19\r\n30 41 9\r\n2 13 24\r\n29 42 36\r\n20 49 17\r\n3 48 1\r\n33 38 10\r\n5 37 20\r\n7 21 30\r\n35 38 22\r\n37 38 19\r\n16 43 47\r\n46 50 16\r\n4 13 36\r\n18 20 41\r\n26 31 19\r\n11 34 30\r\n20 23 23\r\n20 46 19\r\n10 43 49\r\n27 33 45\r\n37 45 27\r\n6 12 0\r\n38 47 27\r\n3 50 6\r\n25 41 41\r\n2 37 27\r\n25 49 24\r\n38 44 31\r\n31 36 7\r\n18 31 3\r\n6 33 2\r\n19 36 33\r\n45 50 48\r\n10 21 17\r\n8 41 42\r\n", "output": ["2711"]}, {"input": "50 50 50\r\n26 27 33\r\n8 29 15\r\n10 31 23\r\n7 38 33\r\n9 12 39\r\n3 18 2\r\n11 35 25\r\n8 10 33\r\n12 19 11\r\n9 44 39\r\n17 32 27\r\n17 49 9\r\n13 13 20\r\n3 9 36\r\n18 20 43\r\n24 48 19\r\n12 26 1\r\n39 49 18\r\n11 33 38\r\n7 49 7\r\n23 38 48\r\n20 22 46\r\n12 31 34\r\n21 41 15\r\n3 13 26\r\n26 30 18\r\n50 50 12\r\n20 39 18\r\n34 40 10\r\n35 45 21\r\n28 41 17\r\n17 29 40\r\n21 30 34\r\n16 34 0\r\n28 45 21\r\n4 36 8\r\n31 50 6\r\n10 48 12\r\n18 42 43\r\n43 47 32\r\n35 38 27\r\n19 26 5\r\n5 36 22\r\n33 38 38\r\n7 24 50\r\n20 23 12\r\n5 35 40\r\n2 7 19\r\n38 49 45\r\n17 39 40\r\n", "output": ["3477"]}, {"input": "50 50 50\r\n7 47 45\r\n22 24 8\r\n31 48 31\r\n36 47 13\r\n7 25 19\r\n2 2 17\r\n34 40 14\r\n27 33 50\r\n31 45 35\r\n4 7 4\r\n27 30 27\r\n4 41 27\r\n34 41 15\r\n2 12 17\r\n2 3 19\r\n25 47 47\r\n6 43 50\r\n4 47 23\r\n5 38 30\r\n12 43 18\r\n8 38 28\r\n6 11 13\r\n23 35 41\r\n2 39 41\r\n27 30 1\r\n28 49 46\r\n15 39 29\r\n18 29 22\r\n37 39 33\r\n7 45 40\r\n23 49 19\r\n8 12 46\r\n21 48 26\r\n22 45 27\r\n9 35 50\r\n10 43 5\r\n13 29 22\r\n7 36 12\r\n18 37 34\r\n17 18 3\r\n17 27 4\r\n44 47 39\r\n6 10 34\r\n31 48 1\r\n32 45 33\r\n39 41 43\r\n5 40 4\r\n8 50 11\r\n1 45 42\r\n30 35 31\r\n", "output": ["2960"]}, {"input": "50 50 50\r\n14 41 31\r\n28 49 13\r\n4 19 15\r\n34 41 16\r\n37 40 34\r\n10 25 1\r\n28 35 15\r\n2 42 43\r\n2 12 47\r\n16 25 26\r\n21 48 4\r\n13 37 22\r\n16 26 15\r\n30 49 12\r\n8 40 45\r\n32 33 6\r\n6 27 2\r\n25 35 5\r\n22 42 24\r\n6 13 49\r\n23 26 14\r\n27 42 38\r\n9 34 45\r\n1 33 35\r\n42 44 7\r\n5 7 42\r\n12 43 25\r\n5 42 4\r\n7 47 2\r\n7 10 40\r\n20 34 6\r\n2 21 12\r\n9 45 15\r\n19 45 29\r\n4 50 0\r\n1 2 12\r\n1 47 26\r\n8 16 23\r\n9 48 45\r\n23 28 20\r\n12 19 4\r\n27 37 46\r\n21 47 25\r\n33 49 5\r\n21 49 6\r\n14 32 1\r\n5 13 36\r\n7 23 34\r\n15 34 43\r\n2 24 29\r\n", "output": ["432"]}, {"input": "50 50 50\r\n14 39 43\r\n22 27 43\r\n9 11 0\r\n23 38 21\r\n13 32 23\r\n19 43 35\r\n27 29 15\r\n6 31 8\r\n19 20 35\r\n36 45 22\r\n20 26 34\r\n13 49 42\r\n13 37 40\r\n37 45 7\r\n16 41 19\r\n27 48 15\r\n15 41 8\r\n33 45 37\r\n6 33 45\r\n10 18 4\r\n12 35 27\r\n15 42 37\r\n25 28 50\r\n19 46 28\r\n7 19 12\r\n12 44 13\r\n1 12 21\r\n7 36 11\r\n19 29 21\r\n6 33 14\r\n32 41 44\r\n30 46 30\r\n1 47 30\r\n14 43 31\r\n18 37 27\r\n11 50 44\r\n26 26 7\r\n24 31 9\r\n9 13 5\r\n29 47 12\r\n6 17 3\r\n3 35 29\r\n29 41 42\r\n5 27 35\r\n14 45 3\r\n27 31 37\r\n20 33 43\r\n18 22 7\r\n12 35 44\r\n10 24 28\r\n", "output": ["6751"]}, {"input": "50 50 50\r\n18 30 29\r\n39 40 46\r\n19 45 35\r\n13 32 26\r\n11 28 38\r\n15 19 18\r\n25 32 15\r\n15 15 1\r\n36 40 48\r\n15 48 18\r\n7 47 12\r\n26 49 37\r\n1 8 40\r\n5 38 4\r\n13 30 18\r\n5 21 0\r\n9 32 37\r\n14 16 44\r\n24 45 15\r\n18 19 36\r\n1 48 14\r\n46 49 11\r\n2 28 4\r\n2 6 21\r\n11 49 20\r\n22 27 34\r\n17 17 43\r\n12 35 19\r\n33 46 38\r\n1 6 15\r\n44 45 31\r\n37 47 22\r\n35 44 20\r\n22 45 33\r\n28 41 3\r\n28 45 0\r\n2 47 13\r\n25 41 45\r\n1 28 14\r\n3 47 3\r\n15 41 2\r\n33 37 37\r\n39 45 33\r\n11 33 38\r\n3 42 50\r\n10 48 47\r\n3 38 49\r\n21 33 31\r\n9 41 19\r\n33 50 27\r\n", "output": ["1243"]}, {"input": "50 50 50\r\n13 24 16\r\n13 46 26\r\n28 37 19\r\n2 22 29\r\n1 2 2\r\n30 31 3\r\n16 23 42\r\n32 44 45\r\n11 44 9\r\n19 35 39\r\n25 44 41\r\n4 35 31\r\n33 38 39\r\n28 35 25\r\n17 26 43\r\n17 49 9\r\n22 40 42\r\n11 44 26\r\n29 48 36\r\n20 30 41\r\n11 32 0\r\n15 31 35\r\n27 30 34\r\n38 47 39\r\n23 24 25\r\n14 20 30\r\n10 25 40\r\n5 39 0\r\n5 10 7\r\n5 20 15\r\n3 10 18\r\n10 35 39\r\n27 45 9\r\n18 34 35\r\n5 15 30\r\n35 41 32\r\n23 35 20\r\n9 37 30\r\n4 39 1\r\n2 26 46\r\n9 27 1\r\n13 31 18\r\n10 26 24\r\n17 28 17\r\n4 42 48\r\n24 50 32\r\n3 19 29\r\n28 35 2\r\n20 29 20\r\n22 23 24\r\n", "output": ["2167"]}, {"input": "50 50 50\r\n15 21 1\r\n8 40 30\r\n25 34 4\r\n19 46 8\r\n24 32 16\r\n2 31 37\r\n18 18 43\r\n27 42 37\r\n7 28 48\r\n2 31 36\r\n43 45 19\r\n8 48 25\r\n4 26 13\r\n36 42 20\r\n15 26 18\r\n28 43 18\r\n7 32 47\r\n18 46 7\r\n9 39 5\r\n17 35 21\r\n21 24 38\r\n12 30 34\r\n18 49 38\r\n28 46 32\r\n39 41 31\r\n1 26 1\r\n14 29 35\r\n23 33 7\r\n23 32 25\r\n1 13 15\r\n17 20 5\r\n20 21 31\r\n11 43 24\r\n8 33 37\r\n6 19 6\r\n34 46 39\r\n15 44 25\r\n31 50 15\r\n11 46 11\r\n16 40 12\r\n6 8 1\r\n25 44 0\r\n22 28 15\r\n22 30 21\r\n30 44 45\r\n41 45 41\r\n22 35 36\r\n39 46 25\r\n2 12 21\r\n7 41 23\r\n", "output": ["1022"]}, {"input": "50 50 50\r\n17 17 39\r\n11 13 9\r\n9 43 39\r\n9 35 13\r\n23 39 31\r\n21 43 21\r\n16 17 43\r\n2 47 30\r\n23 49 9\r\n22 47 7\r\n20 34 48\r\n12 49 20\r\n13 29 12\r\n3 29 17\r\n4 30 42\r\n37 40 28\r\n16 50 24\r\n31 43 40\r\n6 26 26\r\n22 43 28\r\n7 41 24\r\n33 35 8\r\n17 23 43\r\n11 49 25\r\n21 42 37\r\n34 36 23\r\n15 44 31\r\n7 7 14\r\n4 41 44\r\n13 16 16\r\n28 36 17\r\n19 29 48\r\n7 40 14\r\n7 32 39\r\n1 42 33\r\n9 25 21\r\n15 48 30\r\n1 45 1\r\n22 45 21\r\n1 22 4\r\n47 50 0\r\n16 19 8\r\n22 38 32\r\n24 32 1\r\n31 37 43\r\n16 36 25\r\n5 41 17\r\n42 45 49\r\n23 32 48\r\n21 43 21\r\n", "output": ["94"]}, {"input": "50 50 50\r\n15 20 50\r\n11 36 39\r\n1 7 23\r\n11 25 16\r\n2 8 46\r\n44 47 5\r\n7 15 20\r\n6 35 23\r\n21 31 47\r\n14 42 3\r\n22 44 25\r\n7 12 15\r\n5 50 13\r\n29 29 38\r\n4 35 17\r\n1 23 37\r\n22 32 30\r\n17 25 21\r\n17 40 47\r\n5 31 8\r\n46 50 10\r\n21 45 32\r\n7 47 48\r\n9 48 17\r\n4 46 43\r\n20 42 19\r\n2 15 28\r\n31 34 48\r\n9 22 11\r\n4 38 16\r\n31 49 4\r\n14 34 14\r\n41 49 28\r\n6 38 41\r\n10 38 8\r\n16 26 26\r\n24 36 37\r\n9 17 37\r\n37 41 32\r\n19 39 47\r\n10 33 0\r\n20 46 41\r\n12 45 22\r\n26 34 5\r\n27 34 40\r\n23 33 10\r\n6 17 23\r\n3 9 20\r\n1 2 49\r\n20 39 19\r\n", "output": ["2327"]}, {"input": "50 50 50\r\n6 28 36\r\n12 22 44\r\n12 39 7\r\n19 50 20\r\n27 43 35\r\n6 12 38\r\n2 6 20\r\n15 24 15\r\n38 43 8\r\n21 22 49\r\n15 21 4\r\n20 20 8\r\n25 42 37\r\n22 40 34\r\n43 43 17\r\n17 21 22\r\n35 41 34\r\n10 41 2\r\n8 29 17\r\n9 24 38\r\n14 31 24\r\n2 10 32\r\n6 20 2\r\n41 42 11\r\n20 22 49\r\n2 7 40\r\n16 18 48\r\n8 10 4\r\n31 40 30\r\n4 7 16\r\n19 39 42\r\n1 8 6\r\n37 42 17\r\n11 34 43\r\n25 29 36\r\n6 35 8\r\n12 15 42\r\n14 35 48\r\n33 48 43\r\n34 41 38\r\n4 18 50\r\n10 22 23\r\n7 15 13\r\n24 40 35\r\n23 27 36\r\n9 50 19\r\n24 30 29\r\n8 10 44\r\n26 30 50\r\n5 23 19\r\n", "output": ["2979"]}, {"input": "50 50 50\r\n24 50 22\r\n26 27 22\r\n22 27 43\r\n16 48 24\r\n27 46 50\r\n2 34 22\r\n1 4 21\r\n33 48 7\r\n5 14 21\r\n37 43 19\r\n8 39 32\r\n20 21 4\r\n4 34 36\r\n12 23 29\r\n32 47 42\r\n11 32 31\r\n4 49 13\r\n3 16 35\r\n13 44 37\r\n17 29 45\r\n16 23 10\r\n25 33 5\r\n1 44 6\r\n28 49 30\r\n31 47 4\r\n13 44 11\r\n17 22 45\r\n24 40 37\r\n11 45 48\r\n4 26 17\r\n32 50 30\r\n2 10 23\r\n29 48 31\r\n30 50 19\r\n16 47 11\r\n5 48 14\r\n33 41 48\r\n8 27 34\r\n9 32 27\r\n45 47 5\r\n2 50 49\r\n8 48 31\r\n27 47 29\r\n27 46 39\r\n12 28 34\r\n4 25 5\r\n43 50 10\r\n13 19 16\r\n9 46 0\r\n41 45 16\r\n", "output": ["498"]}, {"input": "50 50 50\r\n28 33 44\r\n15 17 1\r\n25 40 10\r\n7 43 38\r\n13 23 9\r\n4 4 43\r\n25 26 43\r\n5 41 14\r\n1 49 40\r\n4 31 18\r\n41 45 22\r\n38 43 48\r\n23 30 45\r\n5 13 3\r\n1 47 13\r\n14 25 33\r\n27 32 40\r\n23 50 26\r\n2 25 20\r\n7 41 41\r\n31 41 47\r\n34 37 7\r\n6 37 14\r\n23 43 20\r\n14 49 31\r\n22 25 22\r\n12 30 36\r\n44 46 32\r\n5 48 34\r\n17 22 31\r\n39 48 14\r\n27 34 25\r\n20 41 24\r\n31 48 9\r\n19 30 11\r\n45 49 48\r\n1 28 35\r\n10 16 10\r\n36 37 46\r\n5 42 48\r\n15 50 24\r\n12 44 27\r\n14 27 9\r\n5 37 46\r\n33 48 3\r\n12 45 8\r\n5 15 37\r\n1 5 43\r\n46 47 4\r\n8 49 33\r\n", "output": ["3080"]}, {"input": "20 50 20\r\n4 5 18\r\n14 15 32\r\n6 13 46\r\n13 19 39\r\n2 8 18\r\n15 16 29\r\n2 8 9\r\n1 2 23\r\n1 8 8\r\n18 18 11\r\n10 16 3\r\n9 18 44\r\n9 19 31\r\n2 3 19\r\n4 19 12\r\n10 17 24\r\n9 13 20\r\n4 7 10\r\n12 20 24\r\n3 19 19\r\n", "output": ["1704"]}, {"input": "50 20 20\r\n4 15 1\r\n26 31 15\r\n28 40 5\r\n16 42 1\r\n10 26 10\r\n42 42 1\r\n21 49 4\r\n24 50 10\r\n7 32 12\r\n5 38 18\r\n36 41 14\r\n16 44 2\r\n23 33 4\r\n18 19 15\r\n14 21 14\r\n18 28 16\r\n29 38 13\r\n6 17 10\r\n6 44 2\r\n17 45 1\r\n", "output": ["1406"]}, {"input": "20 20 50\r\n10 17 9\r\n5 10 5\r\n9 18 5\r\n4 19 8\r\n10 18 4\r\n5 19 2\r\n9 11 0\r\n3 9 9\r\n11 12 6\r\n7 9 7\r\n6 19 15\r\n7 12 10\r\n5 17 18\r\n4 9 14\r\n11 11 9\r\n2 20 8\r\n2 16 9\r\n5 16 1\r\n1 2 5\r\n6 9 1\r\n8 13 15\r\n6 15 18\r\n7 13 7\r\n13 18 11\r\n1 16 17\r\n16 20 17\r\n2 19 10\r\n15 18 0\r\n2 14 11\r\n1 3 11\r\n2 3 3\r\n2 16 10\r\n6 20 7\r\n3 17 2\r\n8 13 11\r\n7 11 13\r\n1 13 14\r\n5 16 4\r\n2 3 14\r\n2 5 4\r\n4 10 6\r\n10 17 20\r\n9 13 4\r\n1 5 20\r\n7 13 6\r\n16 20 9\r\n9 16 16\r\n5 12 7\r\n2 18 14\r\n9 13 19\r\n", "output": ["102"]}, {"input": "20 50 20\r\n3 9 4\r\n4 7 11\r\n9 14 31\r\n1 6 17\r\n5 13 33\r\n17 19 11\r\n13 14 10\r\n4 12 16\r\n8 19 46\r\n8 19 7\r\n11 20 32\r\n3 18 39\r\n1 12 31\r\n4 16 15\r\n2 15 38\r\n1 2 33\r\n2 11 25\r\n7 14 17\r\n3 14 45\r\n15 18 50\r\n", "output": ["2204"]}, {"input": "50 20 20\r\n19 49 15\r\n8 29 12\r\n28 33 20\r\n5 40 14\r\n1 45 14\r\n15 50 17\r\n20 44 17\r\n11 18 15\r\n20 40 6\r\n16 21 6\r\n12 31 10\r\n29 49 5\r\n20 44 17\r\n16 41 10\r\n3 30 9\r\n8 36 10\r\n45 48 5\r\n6 27 12\r\n35 44 8\r\n21 42 16\r\n", "output": ["2727"]}, {"input": "20 20 50\r\n1 3 9\r\n2 20 19\r\n2 5 3\r\n2 8 17\r\n1 19 16\r\n1 19 1\r\n17 19 13\r\n2 6 6\r\n9 12 14\r\n15 15 3\r\n6 13 7\r\n11 17 6\r\n12 15 15\r\n4 16 5\r\n8 13 4\r\n6 12 6\r\n10 13 1\r\n2 20 15\r\n9 16 11\r\n1 13 16\r\n2 12 17\r\n13 17 13\r\n17 18 9\r\n5 6 11\r\n5 16 6\r\n3 16 0\r\n2 10 3\r\n2 17 6\r\n6 9 4\r\n4 11 2\r\n5 20 17\r\n5 20 9\r\n7 20 15\r\n5 11 20\r\n11 15 12\r\n6 18 8\r\n9 16 4\r\n2 17 14\r\n4 8 11\r\n8 15 8\r\n15 18 20\r\n7 14 15\r\n5 8 14\r\n11 13 20\r\n16 17 15\r\n1 14 13\r\n6 10 11\r\n8 19 19\r\n8 20 17\r\n3 19 2\r\n", "output": ["86"]}, {"input": "20 50 20\r\n5 9 16\r\n17 17 15\r\n2 4 15\r\n6 20 22\r\n3 16 48\r\n11 13 46\r\n2 3 37\r\n7 9 8\r\n16 20 7\r\n11 19 3\r\n6 19 11\r\n3 18 34\r\n7 19 5\r\n7 17 37\r\n4 16 12\r\n13 16 42\r\n18 20 4\r\n3 8 50\r\n9 14 15\r\n17 19 5\r\n", "output": ["3556"]}, {"input": "50 20 20\r\n22 39 19\r\n23 37 18\r\n16 38 9\r\n30 49 15\r\n14 31 5\r\n1 29 16\r\n10 46 9\r\n27 40 16\r\n3 42 1\r\n33 38 6\r\n18 40 6\r\n3 34 5\r\n8 23 14\r\n5 9 14\r\n4 34 8\r\n1 48 16\r\n4 15 18\r\n9 46 18\r\n18 29 14\r\n25 47 20\r\n", "output": ["1951"]}, {"input": "20 20 50\r\n1 13 18\r\n1 18 9\r\n4 6 13\r\n2 7 17\r\n8 8 7\r\n5 11 17\r\n8 18 5\r\n8 18 11\r\n1 9 9\r\n6 15 12\r\n15 17 3\r\n2 15 10\r\n11 16 19\r\n2 17 13\r\n8 16 15\r\n6 7 0\r\n4 8 14\r\n5 8 0\r\n10 20 13\r\n6 12 3\r\n11 16 19\r\n4 14 20\r\n1 17 11\r\n7 15 7\r\n11 17 8\r\n6 17 7\r\n6 16 17\r\n5 16 3\r\n17 18 2\r\n6 14 14\r\n12 16 2\r\n2 11 16\r\n2 7 11\r\n1 14 4\r\n6 13 1\r\n1 17 10\r\n8 16 19\r\n9 13 16\r\n13 14 3\r\n8 19 12\r\n9 16 16\r\n5 10 17\r\n5 18 12\r\n1 17 15\r\n3 7 0\r\n17 18 4\r\n4 19 16\r\n6 18 9\r\n2 19 11\r\n1 4 11\r\n", "output": ["347"]}, {"input": "3 3 4\r\n1 3 1\r\n1 1 3\r\n2 2 3\r\n3 3 3\r\n", "output": ["3"]}]
100
100
100
[{'input': '50 50 50\r\n14 39 43\r\n22 27 43\r\n9 11 0\r\n23 38 21\r\n13 32 23\r\n19 43 35\r\n27 29 15\r\n6 31 8\r\n19 20 35\r\n36 45 22\r\n20 26 34\r\n13 49 42\r\n13 37 40\r\n37 45 7\r\n16 41 19\r\n27 48 15\r\n15 41 8\r\n33 45 37\r\n6 33 45\r\n10 18 4\r\n12 35 27\r\n15 42 37\r\n25 28 50\r\n19 46 28\r\n7 19 12\r\n12 44 13\r\n1 12 21\r\n7 36 11\r\n19 29 21\r\n6 33 14\r\n32 41 44\r\n30 46 30\r\n1 47 30\r\n14 43 31\r\n18 37 27\r\n11 50 44\r\n26 26 7\r\n24 31 9\r\n9 13 5\r\n29 47 12\r\n6 17 3\r\n3 35 29\r\n29 41 42\r\n5 27 35\r\n14 45 3\r\n27 31 37\r\n20 33 43\r\n18 22 7\r\n12 35 44\r\n10 24 28\r\n', 'output': ['6751']}, {'input': '50 50 50\r\n17 17 39\r\n11 13 9\r\n9 43 39\r\n9 35 13\r\n23 39 31\r\n21 43 21\r\n16 17 43\r\n2 47 30\r\n23 49 9\r\n22 47 7\r\n20 34 48\r\n12 49 20\r\n13 29 12\r\n3 29 17\r\n4 30 42\r\n37 40 28\r\n16 50 24\r\n31 43 40\r\n6 26 26\r\n22 43 28\r\n7 41 24\r\n33 35 8\r\n17 23 43\r\n11 49 25\r\n21 42 37\r\n34 36 23\r\n15 44 31\r\n7 7 14\r\n4 41 44\r\n13 16 16\r\n28 36 17\r\n19 29 48\r\n7 40 14\r\n7 32 39\r\n1 42 33\r\n9 25 21\r\n15 48 30\r\n1 45 1\r\n22 45 21\r\n1 22 4\r\n47 50 0\r\n16 19 8\r\n22 38 32\r\n24 32 1\r\n31 37 43\r\n16 36 25\r\n5 41 17\r\n42 45 49\r\n23 32 48\r\n21 43 21\r\n', 'output': ['94']}, {'input': '3 3 3\r\n1 1 1\r\n2 2 3\r\n3 3 2\r\n', 'output': ['14']}, {'input': '50 50 50\r\n26 27 33\r\n8 29 15\r\n10 31 23\r\n7 38 33\r\n9 12 39\r\n3 18 2\r\n11 35 25\r\n8 10 33\r\n12 19 11\r\n9 44 39\r\n17 32 27\r\n17 49 9\r\n13 13 20\r\n3 9 36\r\n18 20 43\r\n24 48 19\r\n12 26 1\r\n39 49 18\r\n11 33 38\r\n7 49 7\r\n23 38 48\r\n20 22 46\r\n12 31 34\r\n21 41 15\r\n3 13 26\r\n26 30 18\r\n50 50 12\r\n20 39 18\r\n34 40 10\r\n35 45 21\r\n28 41 17\r\n17 29 40\r\n21 30 34\r\n16 34 0\r\n28 45 21\r\n4 36 8\r\n31 50 6\r\n10 48 12\r\n18 42 43\r\n43 47 32\r\n35 38 27\r\n19 26 5\r\n5 36 22\r\n33 38 38\r\n7 24 50\r\n20 23 12\r\n5 35 40\r\n2 7 19\r\n38 49 45\r\n17 39 40\r\n', 'output': ['3477']}, {'input': '50 50 50\r\n17 40 12\r\n33 36 47\r\n8 43 35\r\n25 29 42\r\n18 36 6\r\n25 35 18\r\n36 48 47\r\n17 40 13\r\n20 27 37\r\n32 32 28\r\n17 20 13\r\n4 14 6\r\n13 18 47\r\n18 45 28\r\n3 50 45\r\n6 6 6\r\n3 25 36\r\n28 48 42\r\n14 34 32\r\n28 41 35\r\n29 35 25\r\n25 48 24\r\n32 40 40\r\n18 38 44\r\n6 16 2\r\n1 36 7\r\n14 48 2\r\n18 29 40\r\n11 16 37\r\n8 40 19\r\n12 16 44\r\n44 46 21\r\n19 24 26\r\n24 45 44\r\n22 22 15\r\n6 15 32\r\n19 42 7\r\n21 33 20\r\n1 13 26\r\n16 27 40\r\n46 48 30\r\n21 39 1\r\n1 9 32\r\n14 34 20\r\n35 38 11\r\n19 47 23\r\n13 38 15\r\n28 29 28\r\n7 20 40\r\n2 21 46\r\n', 'output': ['4384']}]
[{'input': '50 50 50\r\n18 30 29\r\n39 40 46\r\n19 45 35\r\n13 32 26\r\n11 28 38\r\n15 19 18\r\n25 32 15\r\n15 15 1\r\n36 40 48\r\n15 48 18\r\n7 47 12\r\n26 49 37\r\n1 8 40\r\n5 38 4\r\n13 30 18\r\n5 21 0\r\n9 32 37\r\n14 16 44\r\n24 45 15\r\n18 19 36\r\n1 48 14\r\n46 49 11\r\n2 28 4\r\n2 6 21\r\n11 49 20\r\n22 27 34\r\n17 17 43\r\n12 35 19\r\n33 46 38\r\n1 6 15\r\n44 45 31\r\n37 47 22\r\n35 44 20\r\n22 45 33\r\n28 41 3\r\n28 45 0\r\n2 47 13\r\n25 41 45\r\n1 28 14\r\n3 47 3\r\n15 41 2\r\n33 37 37\r\n39 45 33\r\n11 33 38\r\n3 42 50\r\n10 48 47\r\n3 38 49\r\n21 33 31\r\n9 41 19\r\n33 50 27\r\n', 'output': ['1243']}, {'input': '20 20 50\r\n10 17 9\r\n5 10 5\r\n9 18 5\r\n4 19 8\r\n10 18 4\r\n5 19 2\r\n9 11 0\r\n3 9 9\r\n11 12 6\r\n7 9 7\r\n6 19 15\r\n7 12 10\r\n5 17 18\r\n4 9 14\r\n11 11 9\r\n2 20 8\r\n2 16 9\r\n5 16 1\r\n1 2 5\r\n6 9 1\r\n8 13 15\r\n6 15 18\r\n7 13 7\r\n13 18 11\r\n1 16 17\r\n16 20 17\r\n2 19 10\r\n15 18 0\r\n2 14 11\r\n1 3 11\r\n2 3 3\r\n2 16 10\r\n6 20 7\r\n3 17 2\r\n8 13 11\r\n7 11 13\r\n1 13 14\r\n5 16 4\r\n2 3 14\r\n2 5 4\r\n4 10 6\r\n10 17 20\r\n9 13 4\r\n1 5 20\r\n7 13 6\r\n16 20 9\r\n9 16 16\r\n5 12 7\r\n2 18 14\r\n9 13 19\r\n', 'output': ['102']}, {'input': '50 50 50\r\n28 29 9\r\n33 43 30\r\n12 34 3\r\n9 12 26\r\n24 39 10\r\n12 47 35\r\n29 41 47\r\n43 44 49\r\n19 37 36\r\n11 18 46\r\n19 42 20\r\n9 40 47\r\n18 34 22\r\n11 20 44\r\n5 31 44\r\n29 40 0\r\n1 26 19\r\n7 50 4\r\n14 34 48\r\n43 48 21\r\n12 49 23\r\n6 40 47\r\n22 37 50\r\n39 48 29\r\n12 34 13\r\n5 10 25\r\n30 45 46\r\n26 32 29\r\n2 4 23\r\n7 39 19\r\n22 49 42\r\n11 29 31\r\n23 50 29\r\n12 32 47\r\n4 13 18\r\n24 46 20\r\n33 34 44\r\n24 35 41\r\n39 50 47\r\n14 24 49\r\n25 44 28\r\n23 23 42\r\n32 44 40\r\n25 42 3\r\n25 31 6\r\n35 47 18\r\n22 49 2\r\n38 43 23\r\n1 27 16\r\n19 23 43\r\n', 'output': ['1786']}, {'input': '20 50 20\r\n5 9 16\r\n17 17 15\r\n2 4 15\r\n6 20 22\r\n3 16 48\r\n11 13 46\r\n2 3 37\r\n7 9 8\r\n16 20 7\r\n11 19 3\r\n6 19 11\r\n3 18 34\r\n7 19 5\r\n7 17 37\r\n4 16 12\r\n13 16 42\r\n18 20 4\r\n3 8 50\r\n9 14 15\r\n17 19 5\r\n', 'output': ['3556']}, {'input': '50 20 20\r\n22 39 19\r\n23 37 18\r\n16 38 9\r\n30 49 15\r\n14 31 5\r\n1 29 16\r\n10 46 9\r\n27 40 16\r\n3 42 1\r\n33 38 6\r\n18 40 6\r\n3 34 5\r\n8 23 14\r\n5 9 14\r\n4 34 8\r\n1 48 16\r\n4 15 18\r\n9 46 18\r\n18 29 14\r\n25 47 20\r\n', 'output': ['1951']}]
[{'input': '50 50 50\r\n17 17 39\r\n11 13 9\r\n9 43 39\r\n9 35 13\r\n23 39 31\r\n21 43 21\r\n16 17 43\r\n2 47 30\r\n23 49 9\r\n22 47 7\r\n20 34 48\r\n12 49 20\r\n13 29 12\r\n3 29 17\r\n4 30 42\r\n37 40 28\r\n16 50 24\r\n31 43 40\r\n6 26 26\r\n22 43 28\r\n7 41 24\r\n33 35 8\r\n17 23 43\r\n11 49 25\r\n21 42 37\r\n34 36 23\r\n15 44 31\r\n7 7 14\r\n4 41 44\r\n13 16 16\r\n28 36 17\r\n19 29 48\r\n7 40 14\r\n7 32 39\r\n1 42 33\r\n9 25 21\r\n15 48 30\r\n1 45 1\r\n22 45 21\r\n1 22 4\r\n47 50 0\r\n16 19 8\r\n22 38 32\r\n24 32 1\r\n31 37 43\r\n16 36 25\r\n5 41 17\r\n42 45 49\r\n23 32 48\r\n21 43 21\r\n', 'output': ['94']}, {'input': '3 3 4\r\n1 3 1\r\n1 1 3\r\n2 2 3\r\n3 3 3\r\n', 'output': ['3']}, {'input': '20 20 50\r\n10 17 9\r\n5 10 5\r\n9 18 5\r\n4 19 8\r\n10 18 4\r\n5 19 2\r\n9 11 0\r\n3 9 9\r\n11 12 6\r\n7 9 7\r\n6 19 15\r\n7 12 10\r\n5 17 18\r\n4 9 14\r\n11 11 9\r\n2 20 8\r\n2 16 9\r\n5 16 1\r\n1 2 5\r\n6 9 1\r\n8 13 15\r\n6 15 18\r\n7 13 7\r\n13 18 11\r\n1 16 17\r\n16 20 17\r\n2 19 10\r\n15 18 0\r\n2 14 11\r\n1 3 11\r\n2 3 3\r\n2 16 10\r\n6 20 7\r\n3 17 2\r\n8 13 11\r\n7 11 13\r\n1 13 14\r\n5 16 4\r\n2 3 14\r\n2 5 4\r\n4 10 6\r\n10 17 20\r\n9 13 4\r\n1 5 20\r\n7 13 6\r\n16 20 9\r\n9 16 16\r\n5 12 7\r\n2 18 14\r\n9 13 19\r\n', 'output': ['102']}, {'input': '50 50 50\r\n7 47 45\r\n22 24 8\r\n31 48 31\r\n36 47 13\r\n7 25 19\r\n2 2 17\r\n34 40 14\r\n27 33 50\r\n31 45 35\r\n4 7 4\r\n27 30 27\r\n4 41 27\r\n34 41 15\r\n2 12 17\r\n2 3 19\r\n25 47 47\r\n6 43 50\r\n4 47 23\r\n5 38 30\r\n12 43 18\r\n8 38 28\r\n6 11 13\r\n23 35 41\r\n2 39 41\r\n27 30 1\r\n28 49 46\r\n15 39 29\r\n18 29 22\r\n37 39 33\r\n7 45 40\r\n23 49 19\r\n8 12 46\r\n21 48 26\r\n22 45 27\r\n9 35 50\r\n10 43 5\r\n13 29 22\r\n7 36 12\r\n18 37 34\r\n17 18 3\r\n17 27 4\r\n44 47 39\r\n6 10 34\r\n31 48 1\r\n32 45 33\r\n39 41 43\r\n5 40 4\r\n8 50 11\r\n1 45 42\r\n30 35 31\r\n', 'output': ['2960']}, {'input': '50 50 50\r\n15 21 1\r\n8 40 30\r\n25 34 4\r\n19 46 8\r\n24 32 16\r\n2 31 37\r\n18 18 43\r\n27 42 37\r\n7 28 48\r\n2 31 36\r\n43 45 19\r\n8 48 25\r\n4 26 13\r\n36 42 20\r\n15 26 18\r\n28 43 18\r\n7 32 47\r\n18 46 7\r\n9 39 5\r\n17 35 21\r\n21 24 38\r\n12 30 34\r\n18 49 38\r\n28 46 32\r\n39 41 31\r\n1 26 1\r\n14 29 35\r\n23 33 7\r\n23 32 25\r\n1 13 15\r\n17 20 5\r\n20 21 31\r\n11 43 24\r\n8 33 37\r\n6 19 6\r\n34 46 39\r\n15 44 25\r\n31 50 15\r\n11 46 11\r\n16 40 12\r\n6 8 1\r\n25 44 0\r\n22 28 15\r\n22 30 21\r\n30 44 45\r\n41 45 41\r\n22 35 36\r\n39 46 25\r\n2 12 21\r\n7 41 23\r\n', 'output': ['1022']}]
[{'input': '20 50 20\r\n4 5 18\r\n14 15 32\r\n6 13 46\r\n13 19 39\r\n2 8 18\r\n15 16 29\r\n2 8 9\r\n1 2 23\r\n1 8 8\r\n18 18 11\r\n10 16 3\r\n9 18 44\r\n9 19 31\r\n2 3 19\r\n4 19 12\r\n10 17 24\r\n9 13 20\r\n4 7 10\r\n12 20 24\r\n3 19 19\r\n', 'output': ['1704']}, {'input': '50 50 50\r\n15 20 50\r\n11 36 39\r\n1 7 23\r\n11 25 16\r\n2 8 46\r\n44 47 5\r\n7 15 20\r\n6 35 23\r\n21 31 47\r\n14 42 3\r\n22 44 25\r\n7 12 15\r\n5 50 13\r\n29 29 38\r\n4 35 17\r\n1 23 37\r\n22 32 30\r\n17 25 21\r\n17 40 47\r\n5 31 8\r\n46 50 10\r\n21 45 32\r\n7 47 48\r\n9 48 17\r\n4 46 43\r\n20 42 19\r\n2 15 28\r\n31 34 48\r\n9 22 11\r\n4 38 16\r\n31 49 4\r\n14 34 14\r\n41 49 28\r\n6 38 41\r\n10 38 8\r\n16 26 26\r\n24 36 37\r\n9 17 37\r\n37 41 32\r\n19 39 47\r\n10 33 0\r\n20 46 41\r\n12 45 22\r\n26 34 5\r\n27 34 40\r\n23 33 10\r\n6 17 23\r\n3 9 20\r\n1 2 49\r\n20 39 19\r\n', 'output': ['2327']}, {'input': '50 20 20\r\n4 15 1\r\n26 31 15\r\n28 40 5\r\n16 42 1\r\n10 26 10\r\n42 42 1\r\n21 49 4\r\n24 50 10\r\n7 32 12\r\n5 38 18\r\n36 41 14\r\n16 44 2\r\n23 33 4\r\n18 19 15\r\n14 21 14\r\n18 28 16\r\n29 38 13\r\n6 17 10\r\n6 44 2\r\n17 45 1\r\n', 'output': ['1406']}, {'input': '3 3 3\r\n1 1 1\r\n2 2 3\r\n3 3 2\r\n', 'output': ['14']}, {'input': '50 50 50\r\n15 21 1\r\n8 40 30\r\n25 34 4\r\n19 46 8\r\n24 32 16\r\n2 31 37\r\n18 18 43\r\n27 42 37\r\n7 28 48\r\n2 31 36\r\n43 45 19\r\n8 48 25\r\n4 26 13\r\n36 42 20\r\n15 26 18\r\n28 43 18\r\n7 32 47\r\n18 46 7\r\n9 39 5\r\n17 35 21\r\n21 24 38\r\n12 30 34\r\n18 49 38\r\n28 46 32\r\n39 41 31\r\n1 26 1\r\n14 29 35\r\n23 33 7\r\n23 32 25\r\n1 13 15\r\n17 20 5\r\n20 21 31\r\n11 43 24\r\n8 33 37\r\n6 19 6\r\n34 46 39\r\n15 44 25\r\n31 50 15\r\n11 46 11\r\n16 40 12\r\n6 8 1\r\n25 44 0\r\n22 28 15\r\n22 30 21\r\n30 44 45\r\n41 45 41\r\n22 35 36\r\n39 46 25\r\n2 12 21\r\n7 41 23\r\n', 'output': ['1022']}]
[{'input': '50 50 50\r\n7 47 45\r\n22 24 8\r\n31 48 31\r\n36 47 13\r\n7 25 19\r\n2 2 17\r\n34 40 14\r\n27 33 50\r\n31 45 35\r\n4 7 4\r\n27 30 27\r\n4 41 27\r\n34 41 15\r\n2 12 17\r\n2 3 19\r\n25 47 47\r\n6 43 50\r\n4 47 23\r\n5 38 30\r\n12 43 18\r\n8 38 28\r\n6 11 13\r\n23 35 41\r\n2 39 41\r\n27 30 1\r\n28 49 46\r\n15 39 29\r\n18 29 22\r\n37 39 33\r\n7 45 40\r\n23 49 19\r\n8 12 46\r\n21 48 26\r\n22 45 27\r\n9 35 50\r\n10 43 5\r\n13 29 22\r\n7 36 12\r\n18 37 34\r\n17 18 3\r\n17 27 4\r\n44 47 39\r\n6 10 34\r\n31 48 1\r\n32 45 33\r\n39 41 43\r\n5 40 4\r\n8 50 11\r\n1 45 42\r\n30 35 31\r\n', 'output': ['2960']}, {'input': '4 10 2\r\n2 3 8\r\n3 4 7\r\n', 'output': ['262']}, {'input': '20 50 20\r\n3 9 4\r\n4 7 11\r\n9 14 31\r\n1 6 17\r\n5 13 33\r\n17 19 11\r\n13 14 10\r\n4 12 16\r\n8 19 46\r\n8 19 7\r\n11 20 32\r\n3 18 39\r\n1 12 31\r\n4 16 15\r\n2 15 38\r\n1 2 33\r\n2 11 25\r\n7 14 17\r\n3 14 45\r\n15 18 50\r\n', 'output': ['2204']}, {'input': '50 50 50\r\n14 41 31\r\n28 49 13\r\n4 19 15\r\n34 41 16\r\n37 40 34\r\n10 25 1\r\n28 35 15\r\n2 42 43\r\n2 12 47\r\n16 25 26\r\n21 48 4\r\n13 37 22\r\n16 26 15\r\n30 49 12\r\n8 40 45\r\n32 33 6\r\n6 27 2\r\n25 35 5\r\n22 42 24\r\n6 13 49\r\n23 26 14\r\n27 42 38\r\n9 34 45\r\n1 33 35\r\n42 44 7\r\n5 7 42\r\n12 43 25\r\n5 42 4\r\n7 47 2\r\n7 10 40\r\n20 34 6\r\n2 21 12\r\n9 45 15\r\n19 45 29\r\n4 50 0\r\n1 2 12\r\n1 47 26\r\n8 16 23\r\n9 48 45\r\n23 28 20\r\n12 19 4\r\n27 37 46\r\n21 47 25\r\n33 49 5\r\n21 49 6\r\n14 32 1\r\n5 13 36\r\n7 23 34\r\n15 34 43\r\n2 24 29\r\n', 'output': ['432']}, {'input': '50 50 50\r\n18 30 29\r\n39 40 46\r\n19 45 35\r\n13 32 26\r\n11 28 38\r\n15 19 18\r\n25 32 15\r\n15 15 1\r\n36 40 48\r\n15 48 18\r\n7 47 12\r\n26 49 37\r\n1 8 40\r\n5 38 4\r\n13 30 18\r\n5 21 0\r\n9 32 37\r\n14 16 44\r\n24 45 15\r\n18 19 36\r\n1 48 14\r\n46 49 11\r\n2 28 4\r\n2 6 21\r\n11 49 20\r\n22 27 34\r\n17 17 43\r\n12 35 19\r\n33 46 38\r\n1 6 15\r\n44 45 31\r\n37 47 22\r\n35 44 20\r\n22 45 33\r\n28 41 3\r\n28 45 0\r\n2 47 13\r\n25 41 45\r\n1 28 14\r\n3 47 3\r\n15 41 2\r\n33 37 37\r\n39 45 33\r\n11 33 38\r\n3 42 50\r\n10 48 47\r\n3 38 49\r\n21 33 31\r\n9 41 19\r\n33 50 27\r\n', 'output': ['1243']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
357
100
100
100
["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"]
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 a1, a2, ..., an (1 ≀ ai ≀ 2), ai is the i-th element of the array.
5f94c2ecf1cf8fdbb6117cab801ed281
a=int(input().split()[1]) *b,=map(int,input().split()) c=0 for i in range(a): d=b[i::a] c+=min(d.count(1),d.count(2)) print(c)
["1", "0", "3"]
Python
NoteIn the first sample it is enough to change the fourth element from 2 to 1, then the array changes to [2, 1, 2, 1, 2, 1].In the second sample, the given array already is 4-periodic.In the third sample it is enough to replace each occurrence of number two by number one. In this case the array will look as [1, 1, 1, 1, 1, 1, 1, 1, 1] β€” this array is simultaneously 1-, 3- and 9-periodic.
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.
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.
[{"input": "6 2\r\n2 1 2 2 2 1\r\n", "output": ["1"]}, {"input": "8 4\r\n1 1 2 1 1 1 2 1\r\n", "output": ["0"]}, {"input": "9 3\r\n2 1 1 1 2 1 1 1 2\r\n", "output": ["3"]}, {"input": "1 1\r\n2\r\n", "output": ["0"]}, {"input": "2 1\r\n1 1\r\n", "output": ["0"]}, {"input": "2 2\r\n2 2\r\n", "output": ["0"]}, {"input": "100 1\r\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\r\n", "output": ["8"]}, {"input": "2 1\r\n1 2\r\n", "output": ["1"]}, {"input": "2 2\r\n2 1\r\n", "output": ["0"]}, {"input": "3 1\r\n2 1 2\r\n", "output": ["1"]}, {"input": "3 3\r\n1 2 1\r\n", "output": ["0"]}, {"input": "4 2\r\n2 1 2 2\r\n", "output": ["1"]}, {"input": "10 2\r\n2 2 2 1 1 2 2 2 2 1\r\n", "output": ["3"]}, {"input": "10 5\r\n2 2 1 2 1 1 2 1 1 1\r\n", "output": ["2"]}, {"input": "20 4\r\n2 2 1 2 2 2 1 2 2 2 1 2 2 2 1 2 2 2 1 2\r\n", "output": ["0"]}, {"input": "20 5\r\n2 2 1 1 1 2 1 1 1 1 2 2 1 1 2 2 2 1 1 2\r\n", "output": ["3"]}, {"input": "20 10\r\n1 2 2 2 2 1 1 1 2 1 1 2 2 2 2 1 2 2 2 1\r\n", "output": ["2"]}, {"input": "100 2\r\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\r\n", "output": ["5"]}, {"input": "100 4\r\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\r\n", "output": ["8"]}, {"input": "100 5\r\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\r\n", "output": ["16"]}, {"input": "100 10\r\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\r\n", "output": ["6"]}, {"input": "100 20\r\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\r\n", "output": ["13"]}, {"input": "100 25\r\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\r\n", "output": ["15"]}, {"input": "100 10\r\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\r\n", "output": ["0"]}]
100
100
100
[{'input': '20 5\r\n2 2 1 1 1 2 1 1 1 1 2 2 1 1 2 2 2 1 1 2\r\n', 'output': ['3']}, {'input': '100 2\r\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\r\n', 'output': ['5']}, {'input': '1 1\r\n2\r\n', 'output': ['0']}, {'input': '2 1\r\n1 2\r\n', 'output': ['1']}, {'input': '100 25\r\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\r\n', 'output': ['15']}]
[{'input': '20 10\r\n1 2 2 2 2 1 1 1 2 1 1 2 2 2 2 1 2 2 2 1\r\n', 'output': ['2']}, {'input': '100 5\r\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\r\n', 'output': ['16']}, {'input': '2 2\r\n2 2\r\n', 'output': ['0']}, {'input': '8 4\r\n1 1 2 1 1 1 2 1\r\n', 'output': ['0']}, {'input': '100 4\r\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\r\n', 'output': ['8']}]
[{'input': '100 4\r\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\r\n', 'output': ['8']}, {'input': '2 1\r\n1 1\r\n', 'output': ['0']}, {'input': '1 1\r\n2\r\n', 'output': ['0']}, {'input': '10 2\r\n2 2 2 1 1 2 2 2 2 1\r\n', 'output': ['3']}, {'input': '4 2\r\n2 1 2 2\r\n', 'output': ['1']}]
[{'input': '100 10\r\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\r\n', 'output': ['0']}, {'input': '9 3\r\n2 1 1 1 2 1 1 1 2\r\n', 'output': ['3']}, {'input': '1 1\r\n2\r\n', 'output': ['0']}, {'input': '100 25\r\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\r\n', 'output': ['15']}, {'input': '20 4\r\n2 2 1 2 2 2 1 2 2 2 1 2 2 2 1 2 2 2 1 2\r\n', 'output': ['0']}]
[{'input': '6 2\r\n2 1 2 2 2 1\r\n', 'output': ['1']}, {'input': '10 2\r\n2 2 2 1 1 2 2 2 2 1\r\n', 'output': ['3']}, {'input': '4 2\r\n2 1 2 2\r\n', 'output': ['1']}, {'input': '20 5\r\n2 2 1 1 1 2 1 1 1 1 2 2 1 1 2 2 2 1 1 2\r\n', 'output': ['3']}, {'input': '2 2\r\n2 1\r\n', 'output': ['0']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
358
100
100
100
["5\n6\n3", "5\n3\n5"]
The first line contains an integer $$$b$$$ ($$$1 \le b \le 300$$$), the number of boys. The second line contains an integer $$$g$$$ ($$$1 \le g \le 300$$$), the number of girls. The third line contains an integer $$$n$$$ ($$$1 \le n \le b + g$$$), the number of the board games tournament participants.
9266a69e767df299569986151852e7b1
b = int(input()) g = int(input()) n = int(input()) minig = min(n,g) minib = min(n,b) print(minig - (n-minib) +1)
["4", "4"]
Python
NoteIn the first example, each of 4 decks should be taken: (0 blue, 3 red), (1 blue, 2 red), (2 blue, 1 red), (3 blue, 0 red).In the second example, 4 decks should be taken: (2 blue, 3 red), (3 blue, 2 red), (4 blue, 1 red), (5 blue, 0 red). Piles (0 blue, 5 red) and (1 blue, 4 red) can not be used.
Output the only integer, the minimum number of badge decks that Vasya could take.
There are $$$b$$$ boys and $$$g$$$ girls participating in Olympiad of Metropolises. There will be a board games tournament in the evening and $$$n$$$ participants have accepted the invitation. The organizers do not know how many boys and girls are among them.Organizers are preparing red badges for girls and blue ones for boys.Vasya prepared $$$n+1$$$ decks of badges. The $$$i$$$-th (where $$$i$$$ is from $$$0$$$ to $$$n$$$, inclusive) deck contains $$$i$$$ blue badges and $$$n-i$$$ red ones. The total number of badges in any deck is exactly $$$n$$$.Determine the minimum number of decks among these $$$n+1$$$ that Vasya should take, so that there will be a suitable deck no matter how many girls and boys there will be among the participants of the tournament.
[{"input": "5\r\n6\r\n3\r\n", "output": ["4"]}, {"input": "5\r\n3\r\n5\r\n", "output": ["4"]}, {"input": "1\r\n200\r\n33\r\n", "output": ["2"]}, {"input": "100\r\n200\r\n150\r\n", "output": ["101"]}, {"input": "123\r\n55\r\n100\r\n", "output": ["56"]}, {"input": "300\r\n300\r\n600\r\n", "output": ["1"]}, {"input": "1\r\n1\r\n1\r\n", "output": ["2"]}, {"input": "100\r\n200\r\n250\r\n", "output": ["51"]}, {"input": "100\r\n200\r\n300\r\n", "output": ["1"]}, {"input": "123\r\n222\r\n250\r\n", "output": ["96"]}, {"input": "300\r\n300\r\n1\r\n", "output": ["2"]}, {"input": "300\r\n299\r\n300\r\n", "output": ["300"]}, {"input": "1\r\n1\r\n2\r\n", "output": ["1"]}, {"input": "300\r\n1\r\n45\r\n", "output": ["2"]}, {"input": "199\r\n199\r\n199\r\n", "output": ["200"]}, {"input": "297\r\n297\r\n298\r\n", "output": ["297"]}, {"input": "299\r\n259\r\n300\r\n", "output": ["259"]}, {"input": "288\r\n188\r\n300\r\n", "output": ["177"]}, {"input": "5\r\n299\r\n4\r\n", "output": ["5"]}, {"input": "199\r\n131\r\n45\r\n", "output": ["46"]}, {"input": "50\r\n100\r\n120\r\n", "output": ["31"]}, {"input": "3\r\n3\r\n4\r\n", "output": ["3"]}, {"input": "4\r\n4\r\n5\r\n", "output": ["4"]}, {"input": "4\r\n4\r\n7\r\n", "output": ["2"]}, {"input": "3\r\n3\r\n5\r\n", "output": ["2"]}, {"input": "10\r\n10\r\n12\r\n", "output": ["9"]}, {"input": "5\r\n5\r\n9\r\n", "output": ["2"]}, {"input": "2\r\n2\r\n3\r\n", "output": ["2"]}, {"input": "5\r\n6\r\n10\r\n", "output": ["2"]}, {"input": "2\r\n56\r\n57\r\n", "output": ["2"]}, {"input": "4\r\n7\r\n10\r\n", "output": ["2"]}, {"input": "4\r\n3\r\n5\r\n", "output": ["3"]}, {"input": "7\r\n8\r\n10\r\n", "output": ["6"]}, {"input": "4\r\n2\r\n5\r\n", "output": ["2"]}, {"input": "3\r\n4\r\n5\r\n", "output": ["3"]}]
100
100
100
[{'input': '100\r\n200\r\n300\r\n', 'output': ['1']}, {'input': '1\r\n1\r\n2\r\n', 'output': ['1']}, {'input': '4\r\n2\r\n5\r\n', 'output': ['2']}, {'input': '299\r\n259\r\n300\r\n', 'output': ['259']}, {'input': '297\r\n297\r\n298\r\n', 'output': ['297']}]
[{'input': '300\r\n300\r\n1\r\n', 'output': ['2']}, {'input': '199\r\n199\r\n199\r\n', 'output': ['200']}, {'input': '123\r\n222\r\n250\r\n', 'output': ['96']}, {'input': '299\r\n259\r\n300\r\n', 'output': ['259']}, {'input': '100\r\n200\r\n250\r\n', 'output': ['51']}]
[{'input': '1\r\n1\r\n1\r\n', 'output': ['2']}, {'input': '5\r\n3\r\n5\r\n', 'output': ['4']}, {'input': '2\r\n2\r\n3\r\n', 'output': ['2']}, {'input': '299\r\n259\r\n300\r\n', 'output': ['259']}, {'input': '4\r\n7\r\n10\r\n', 'output': ['2']}]
[{'input': '1\r\n1\r\n1\r\n', 'output': ['2']}, {'input': '3\r\n3\r\n4\r\n', 'output': ['3']}, {'input': '4\r\n2\r\n5\r\n', 'output': ['2']}, {'input': '5\r\n6\r\n10\r\n', 'output': ['2']}, {'input': '4\r\n7\r\n10\r\n', 'output': ['2']}]
[{'input': '299\r\n259\r\n300\r\n', 'output': ['259']}, {'input': '4\r\n7\r\n10\r\n', 'output': ['2']}, {'input': '5\r\n3\r\n5\r\n', 'output': ['4']}, {'input': '300\r\n300\r\n600\r\n', 'output': ['1']}, {'input': '1\r\n1\r\n2\r\n', 'output': ['1']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
359
100
100
100
["6 2\n1 0 1 1 1 1\n2 10\n4 7", "3 3\n1 0 2\n2 5\n2 4", "7 16\n15 15 4 0 0 7 10\n7 9\n4 8 0 3 1 5 0"]
The first line of the input contains two space-separated integers n and bx (1 ≀ n ≀ 10, 2 ≀ bx ≀ 40), where n is the number of digits in the bx-based representation of X. The second line contains n space-separated integers x1, x2, ..., xn (0 ≀ xi &lt; bx) β€” the digits of X. They are given in the order from the most significant digit to the least significant one. The following two lines describe Y in the same way: the third line contains two space-separated integers m and by (1 ≀ m ≀ 10, 2 ≀ by ≀ 40, bx ≠ by), where m is the number of digits in the by-based representation of Y, and the fourth line contains m space-separated integers y1, y2, ..., ym (0 ≀ yi &lt; by) β€” the digits of Y. There will be no leading zeroes. Both X and Y will be positive. All digits of both numbers are given in the standard decimal numeral system.
d6ab5f75a7bee28f0af2bf168a0b2e67
n, b = map(int, input().split()) curr = 1 c1 = 0 a = [int(i) for i in input().split()] a = a[::-1] for i in range(n): c1 += a[i] * curr curr *= b n, b = map(int, input().split()) curr = 1 c2 = 0 a = [int(i) for i in input().split()] a = a[::-1] for i in range(n): c2 += a[i] * curr curr *= b if (c1 < c2): print('<') elif (c1 == c2): print('=') else: print('>')
["=", "&lt;", "&gt;"]
Python
NoteIn the first sample, X = 1011112 = 4710 = Y.In the second sample, X = 1023 = 215 and Y = 245 = 1123, thus X &lt; Y.In the third sample, and Y = 48031509. We may notice that X starts with much larger digits and bx is much larger than by, so X is clearly larger than Y.
Output a single character (quotes for clarity): '&lt;' if X &lt; Y '&gt;' if X &gt; Y '=' if X = Y
After seeing the "ALL YOUR BASE ARE BELONG TO US" meme for the first time, numbers X and Y realised that they have different bases, which complicated their relations.You're given a number X represented in base bx and a number Y represented in base by. Compare those two numbers.
[{"input": "6 2\r\n1 0 1 1 1 1\r\n2 10\r\n4 7\r\n", "output": ["="]}, {"input": "3 3\r\n1 0 2\r\n2 5\r\n2 4\r\n", "output": ["<"]}, {"input": "7 16\r\n15 15 4 0 0 7 10\r\n7 9\r\n4 8 0 3 1 5 0\r\n", "output": [">"]}, {"input": "2 2\r\n1 0\r\n2 3\r\n1 0\r\n", "output": ["<"]}, {"input": "2 2\r\n1 0\r\n1 3\r\n1\r\n", "output": [">"]}, {"input": "10 2\r\n1 0 1 0 1 0 1 0 1 0\r\n10 3\r\n2 2 2 2 2 2 2 2 2 2\r\n", "output": ["<"]}, {"input": "10 16\r\n15 15 4 0 0 0 0 7 10 9\r\n7 9\r\n4 8 0 3 1 5 0\r\n", "output": [">"]}, {"input": "5 5\r\n4 4 4 4 4\r\n4 6\r\n5 5 5 5\r\n", "output": [">"]}, {"input": "2 8\r\n1 0\r\n4 2\r\n1 0 0 0\r\n", "output": ["="]}, {"input": "5 2\r\n1 0 0 0 1\r\n6 8\r\n1 4 7 2 0 0\r\n", "output": ["<"]}, {"input": "6 7\r\n1 1 2 1 2 1\r\n6 6\r\n2 3 2 2 2 2\r\n", "output": ["="]}, {"input": "9 35\r\n34 3 20 29 27 30 2 8 5\r\n7 33\r\n17 3 22 31 1 11 6\r\n", "output": [">"]}, {"input": "1 8\r\n5\r\n9 27\r\n23 23 23 23 23 23 23 23 23\r\n", "output": ["<"]}, {"input": "4 7\r\n3 0 6 6\r\n3 11\r\n7 10 10\r\n", "output": [">"]}, {"input": "1 40\r\n1\r\n2 5\r\n1 0\r\n", "output": ["<"]}, {"input": "1 36\r\n35\r\n4 5\r\n2 4 4 1\r\n", "output": ["<"]}, {"input": "1 30\r\n1\r\n1 31\r\n1\r\n", "output": ["="]}, {"input": "1 3\r\n1\r\n1 2\r\n1\r\n", "output": ["="]}, {"input": "1 2\r\n1\r\n1 40\r\n1\r\n", "output": ["="]}, {"input": "6 29\r\n1 1 1 1 1 1\r\n10 21\r\n1 1 1 1 1 1 1 1 1 1\r\n", "output": ["<"]}, {"input": "3 5\r\n1 0 0\r\n3 3\r\n2 2 2\r\n", "output": ["<"]}, {"input": "2 8\r\n1 0\r\n2 3\r\n2 2\r\n", "output": ["="]}, {"input": "2 4\r\n3 3\r\n2 15\r\n1 0\r\n", "output": ["="]}, {"input": "2 35\r\n1 0\r\n2 6\r\n5 5\r\n", "output": ["="]}, {"input": "2 6\r\n5 5\r\n2 34\r\n1 0\r\n", "output": [">"]}, {"input": "2 7\r\n1 0\r\n2 3\r\n2 2\r\n", "output": ["<"]}, {"input": "2 2\r\n1 0\r\n1 3\r\n2\r\n", "output": ["="]}, {"input": "2 9\r\n5 5\r\n4 3\r\n1 0 0 0\r\n", "output": [">"]}, {"input": "1 24\r\n6\r\n3 9\r\n1 1 1\r\n", "output": ["<"]}, {"input": "5 37\r\n9 9 9 9 9\r\n6 27\r\n13 0 0 0 0 0\r\n", "output": ["<"]}, {"input": "10 2\r\n1 1 1 1 1 1 1 1 1 1\r\n10 34\r\n14 14 14 14 14 14 14 14 14 14\r\n", "output": ["<"]}, {"input": "7 26\r\n8 0 0 0 0 0 0\r\n9 9\r\n3 3 3 3 3 3 3 3 3\r\n", "output": [">"]}, {"input": "2 40\r\n2 0\r\n5 13\r\n4 0 0 0 0\r\n", "output": ["<"]}, {"input": "1 22\r\n15\r\n10 14\r\n3 3 3 3 3 3 3 3 3 3\r\n", "output": ["<"]}, {"input": "10 22\r\n3 3 3 3 3 3 3 3 3 3\r\n3 40\r\n19 19 19\r\n", "output": [">"]}, {"input": "2 29\r\n11 11\r\n6 26\r\n11 11 11 11 11 11\r\n", "output": ["<"]}, {"input": "5 3\r\n1 0 0 0 0\r\n4 27\r\n1 0 0 0\r\n", "output": ["<"]}, {"input": "10 3\r\n1 0 0 0 0 0 0 0 0 0\r\n8 13\r\n1 0 0 0 0 0 0 0\r\n", "output": ["<"]}, {"input": "4 20\r\n1 1 1 1\r\n5 22\r\n1 1 1 1 1\r\n", "output": ["<"]}, {"input": "10 39\r\n34 2 24 34 11 6 33 12 22 21\r\n10 36\r\n25 35 17 24 30 0 1 32 14 35\r\n", "output": [">"]}, {"input": "10 39\r\n35 12 31 35 28 27 25 8 22 25\r\n10 40\r\n23 21 18 12 15 29 38 32 4 8\r\n", "output": [">"]}, {"input": "10 38\r\n16 19 37 32 16 7 14 33 16 11\r\n10 39\r\n10 27 35 15 31 15 17 16 38 35\r\n", "output": [">"]}, {"input": "10 39\r\n20 12 10 32 24 14 37 35 10 38\r\n9 40\r\n1 13 0 10 22 20 1 5 35\r\n", "output": [">"]}, {"input": "10 40\r\n18 1 2 25 28 2 10 2 17 37\r\n10 39\r\n37 8 12 8 21 11 23 11 25 21\r\n", "output": ["<"]}, {"input": "9 39\r\n10 20 16 36 30 29 28 9 8\r\n9 38\r\n12 36 10 22 6 3 19 12 34\r\n", "output": ["="]}, {"input": "7 39\r\n28 16 13 25 19 23 4\r\n7 38\r\n33 8 2 19 3 21 14\r\n", "output": ["="]}, {"input": "10 16\r\n15 15 4 0 0 0 0 7 10 9\r\n10 9\r\n4 8 0 3 1 5 4 8 1 0\r\n", "output": [">"]}, {"input": "7 22\r\n1 13 9 16 7 13 3\r\n4 4\r\n3 0 2 1\r\n", "output": [">"]}, {"input": "10 29\r\n10 19 8 27 1 24 13 15 13 26\r\n2 28\r\n20 14\r\n", "output": [">"]}, {"input": "6 16\r\n2 13 7 13 15 6\r\n10 22\r\n17 17 21 9 16 11 4 4 13 17\r\n", "output": ["<"]}, {"input": "8 26\r\n6 6 17 25 24 8 8 25\r\n4 27\r\n24 7 5 24\r\n", "output": [">"]}, {"input": "10 23\r\n5 21 4 15 12 7 10 7 16 21\r\n4 17\r\n3 11 1 14\r\n", "output": [">"]}, {"input": "10 21\r\n4 7 7 2 13 7 19 19 18 19\r\n3 31\r\n6 11 28\r\n", "output": [">"]}, {"input": "1 30\r\n9\r\n7 37\r\n20 11 18 14 0 36 27\r\n", "output": ["<"]}, {"input": "5 35\r\n22 18 28 29 11\r\n2 3\r\n2 0\r\n", "output": [">"]}, {"input": "7 29\r\n14 26 14 22 11 11 8\r\n6 28\r\n2 12 10 17 0 14\r\n", "output": [">"]}, {"input": "2 37\r\n25 2\r\n3 26\r\n13 13 12\r\n", "output": ["<"]}, {"input": "8 8\r\n4 0 4 3 4 1 5 6\r\n8 24\r\n19 8 15 6 10 7 2 18\r\n", "output": ["<"]}, {"input": "4 22\r\n18 16 1 2\r\n10 26\r\n23 0 12 24 16 2 24 25 1 11\r\n", "output": ["<"]}, {"input": "7 31\r\n14 6 16 6 26 18 17\r\n7 24\r\n22 10 4 5 14 6 9\r\n", "output": [">"]}, {"input": "10 29\r\n15 22 0 5 11 12 17 22 4 27\r\n4 22\r\n9 2 8 14\r\n", "output": [">"]}, {"input": "2 10\r\n6 0\r\n10 26\r\n16 14 8 18 24 4 9 5 22 25\r\n", "output": ["<"]}, {"input": "7 2\r\n1 0 0 0 1 0 1\r\n9 6\r\n1 1 5 1 2 5 3 5 3\r\n", "output": ["<"]}, {"input": "3 9\r\n2 5 4\r\n1 19\r\n15\r\n", "output": [">"]}, {"input": "6 16\r\n4 9 13 4 2 8\r\n4 10\r\n3 5 2 4\r\n", "output": [">"]}, {"input": "2 12\r\n1 4\r\n8 16\r\n4 4 10 6 15 10 8 15\r\n", "output": ["<"]}, {"input": "3 19\r\n9 18 16\r\n4 10\r\n4 3 5 4\r\n", "output": ["<"]}, {"input": "7 3\r\n1 1 2 1 2 0 2\r\n2 2\r\n1 0\r\n", "output": [">"]}, {"input": "3 2\r\n1 1 1\r\n1 3\r\n1\r\n", "output": [">"]}, {"input": "4 4\r\n1 3 1 3\r\n9 3\r\n1 1 0 1 2 2 2 2 1\r\n", "output": ["<"]}, {"input": "9 3\r\n1 0 0 1 1 0 0 1 2\r\n6 4\r\n1 2 0 1 3 2\r\n", "output": [">"]}, {"input": "3 5\r\n1 1 3\r\n10 4\r\n3 3 2 3 0 0 0 3 1 1\r\n", "output": ["<"]}, {"input": "6 4\r\n3 3 2 2 0 2\r\n6 5\r\n1 1 1 1 0 3\r\n", "output": [">"]}, {"input": "6 5\r\n4 4 4 3 1 3\r\n7 6\r\n4 2 2 2 5 0 4\r\n", "output": ["<"]}, {"input": "2 5\r\n3 3\r\n6 6\r\n4 2 0 1 1 0\r\n", "output": ["<"]}, {"input": "10 6\r\n3 5 4 2 4 2 3 5 4 2\r\n10 7\r\n3 2 1 1 3 1 0 3 4 5\r\n", "output": ["<"]}, {"input": "9 7\r\n2 0 3 2 6 6 1 4 3\r\n9 6\r\n4 4 1 1 4 5 5 0 2\r\n", "output": [">"]}, {"input": "1 7\r\n2\r\n4 8\r\n3 2 3 2\r\n", "output": ["<"]}, {"input": "2 8\r\n4 1\r\n1 7\r\n1\r\n", "output": [">"]}, {"input": "1 10\r\n7\r\n3 9\r\n2 1 7\r\n", "output": ["<"]}, {"input": "9 9\r\n2 2 3 6 3 6 3 8 4\r\n6 10\r\n4 7 7 0 3 8\r\n", "output": [">"]}, {"input": "3 11\r\n6 5 2\r\n8 10\r\n5 0 1 8 3 5 1 4\r\n", "output": ["<"]}, {"input": "6 11\r\n10 6 1 0 2 2\r\n9 10\r\n4 3 4 1 1 6 3 4 1\r\n", "output": ["<"]}, {"input": "2 19\r\n4 8\r\n8 18\r\n7 8 6 8 4 11 9 1\r\n", "output": ["<"]}, {"input": "2 24\r\n20 9\r\n10 23\r\n21 10 15 11 6 8 20 16 14 11\r\n", "output": ["<"]}, {"input": "8 36\r\n23 5 27 1 10 7 26 27\r\n10 35\r\n28 33 9 22 10 28 26 4 27 29\r\n", "output": ["<"]}, {"input": "6 37\r\n22 15 14 10 1 8\r\n6 36\r\n18 5 28 10 1 17\r\n", "output": [">"]}, {"input": "5 38\r\n1 31 2 21 21\r\n9 37\r\n8 36 32 30 13 9 24 2 35\r\n", "output": ["<"]}, {"input": "3 39\r\n27 4 3\r\n8 38\r\n32 15 11 34 35 27 30 15\r\n", "output": ["<"]}, {"input": "2 40\r\n22 38\r\n5 39\r\n8 9 32 4 1\r\n", "output": ["<"]}, {"input": "9 37\r\n1 35 7 33 20 21 26 24 5\r\n10 40\r\n39 4 11 9 33 12 26 32 11 8\r\n", "output": ["<"]}, {"input": "4 39\r\n13 25 23 35\r\n6 38\r\n19 36 20 4 12 33\r\n", "output": ["<"]}, {"input": "5 37\r\n29 29 5 7 27\r\n3 39\r\n13 1 10\r\n", "output": [">"]}, {"input": "7 28\r\n1 10 7 0 13 14 11\r\n6 38\r\n8 11 27 5 14 35\r\n", "output": ["="]}, {"input": "2 34\r\n1 32\r\n2 33\r\n2 0\r\n", "output": ["="]}, {"input": "7 5\r\n4 0 4 1 3 0 4\r\n4 35\r\n1 18 7 34\r\n", "output": ["="]}, {"input": "9 34\r\n5 8 4 4 26 1 30 5 24\r\n10 27\r\n1 6 3 10 8 13 22 3 12 8\r\n", "output": ["="]}, {"input": "10 36\r\n1 13 13 23 31 35 5 32 18 21\r\n9 38\r\n32 1 20 14 12 37 13 15 23\r\n", "output": ["="]}, {"input": "10 40\r\n1 1 14 5 6 3 3 11 3 25\r\n10 39\r\n1 11 24 33 25 34 38 29 27 33\r\n", "output": ["="]}, {"input": "9 37\r\n2 6 1 9 19 6 11 28 35\r\n9 40\r\n1 6 14 37 1 8 31 4 9\r\n", "output": ["="]}, {"input": "4 5\r\n1 4 2 0\r\n4 4\r\n3 2 2 3\r\n", "output": ["="]}, {"input": "6 4\r\n1 1 1 2 2 2\r\n7 3\r\n1 2 2 0 1 0 0\r\n", "output": ["="]}, {"input": "2 5\r\n3 3\r\n5 2\r\n1 0 0 1 0\r\n", "output": ["="]}, {"input": "1 9\r\n2\r\n1 10\r\n2\r\n", "output": ["="]}, {"input": "6 19\r\n4 9 14 1 3 1\r\n8 10\r\n1 1 1 7 3 7 3 0\r\n", "output": ["="]}, {"input": "7 15\r\n8 5 8 10 13 6 13\r\n8 13\r\n1 6 9 10 12 3 12 8\r\n", "output": ["="]}, {"input": "8 18\r\n1 1 4 15 7 4 9 3\r\n8 17\r\n1 10 2 10 3 11 14 10\r\n", "output": ["="]}, {"input": "8 21\r\n5 19 0 14 13 13 10 5\r\n10 13\r\n1 0 0 6 11 10 8 2 8 1\r\n", "output": ["="]}, {"input": "8 28\r\n3 1 10 19 10 14 21 15\r\n8 21\r\n14 0 18 13 2 1 18 6\r\n", "output": [">"]}, {"input": "7 34\r\n21 22 28 16 30 4 27\r\n7 26\r\n5 13 21 10 8 12 10\r\n", "output": [">"]}, {"input": "6 26\r\n7 6 4 18 6 1\r\n6 25\r\n5 3 11 1 8 15\r\n", "output": [">"]}, {"input": "10 31\r\n6 27 17 22 14 16 25 9 13 26\r\n10 39\r\n6 1 3 26 12 32 28 19 9 19\r\n", "output": ["<"]}, {"input": "3 5\r\n2 2 3\r\n3 6\r\n4 3 5\r\n", "output": ["<"]}, {"input": "2 24\r\n4 18\r\n2 40\r\n29 24\r\n", "output": ["<"]}, {"input": "5 38\r\n2 24 34 14 17\r\n8 34\r\n4 24 31 2 14 15 8 15\r\n", "output": ["<"]}, {"input": "9 40\r\n39 39 39 39 39 39 39 39 39\r\n6 35\r\n34 34 34 34 34 34\r\n", "output": [">"]}, {"input": "10 40\r\n39 39 39 39 39 39 39 39 39 39\r\n10 8\r\n7 7 7 7 7 7 7 7 7 7\r\n", "output": [">"]}, {"input": "10 40\r\n39 39 39 39 39 39 39 39 39 39\r\n10 39\r\n38 38 38 38 38 38 38 38 38 38\r\n", "output": [">"]}]
100
100
100
[{'input': '6 29\r\n1 1 1 1 1 1\r\n10 21\r\n1 1 1 1 1 1 1 1 1 1\r\n', 'output': ['<']}, {'input': '4 5\r\n1 4 2 0\r\n4 4\r\n3 2 2 3\r\n', 'output': ['=']}, {'input': '2 2\r\n1 0\r\n2 3\r\n1 0\r\n', 'output': ['<']}, {'input': '6 5\r\n4 4 4 3 1 3\r\n7 6\r\n4 2 2 2 5 0 4\r\n', 'output': ['<']}, {'input': '1 36\r\n35\r\n4 5\r\n2 4 4 1\r\n', 'output': ['<']}]
[{'input': '2 8\r\n1 0\r\n4 2\r\n1 0 0 0\r\n', 'output': ['=']}, {'input': '10 16\r\n15 15 4 0 0 0 0 7 10 9\r\n7 9\r\n4 8 0 3 1 5 0\r\n', 'output': ['>']}, {'input': '2 5\r\n3 3\r\n5 2\r\n1 0 0 1 0\r\n', 'output': ['=']}, {'input': '5 3\r\n1 0 0 0 0\r\n4 27\r\n1 0 0 0\r\n', 'output': ['<']}, {'input': '2 24\r\n4 18\r\n2 40\r\n29 24\r\n', 'output': ['<']}]
[{'input': '10 40\r\n39 39 39 39 39 39 39 39 39 39\r\n10 39\r\n38 38 38 38 38 38 38 38 38 38\r\n', 'output': ['>']}, {'input': '2 40\r\n2 0\r\n5 13\r\n4 0 0 0 0\r\n', 'output': ['<']}, {'input': '2 37\r\n25 2\r\n3 26\r\n13 13 12\r\n', 'output': ['<']}, {'input': '10 29\r\n15 22 0 5 11 12 17 22 4 27\r\n4 22\r\n9 2 8 14\r\n', 'output': ['>']}, {'input': '1 7\r\n2\r\n4 8\r\n3 2 3 2\r\n', 'output': ['<']}]
[{'input': '1 8\r\n5\r\n9 27\r\n23 23 23 23 23 23 23 23 23\r\n', 'output': ['<']}, {'input': '8 18\r\n1 1 4 15 7 4 9 3\r\n8 17\r\n1 10 2 10 3 11 14 10\r\n', 'output': ['=']}, {'input': '2 8\r\n4 1\r\n1 7\r\n1\r\n', 'output': ['>']}, {'input': '2 5\r\n3 3\r\n5 2\r\n1 0 0 1 0\r\n', 'output': ['=']}, {'input': '9 35\r\n34 3 20 29 27 30 2 8 5\r\n7 33\r\n17 3 22 31 1 11 6\r\n', 'output': ['>']}]
[{'input': '7 31\r\n14 6 16 6 26 18 17\r\n7 24\r\n22 10 4 5 14 6 9\r\n', 'output': ['>']}, {'input': '2 24\r\n20 9\r\n10 23\r\n21 10 15 11 6 8 20 16 14 11\r\n', 'output': ['<']}, {'input': '9 34\r\n5 8 4 4 26 1 30 5 24\r\n10 27\r\n1 6 3 10 8 13 22 3 12 8\r\n', 'output': ['=']}, {'input': '2 12\r\n1 4\r\n8 16\r\n4 4 10 6 15 10 8 15\r\n', 'output': ['<']}, {'input': '2 19\r\n4 8\r\n8 18\r\n7 8 6 8 4 11 9 1\r\n', 'output': ['<']}]
100
100
100
100
100
95.24
100
95.24
100
100
91.67
100
91.67
100
100
360
100
98.096
96.668
["1", "8", "10"]
The single line of input contains the integer m (1 ≀ m ≀ 1015)Β β€” the number of ways the thieves might steal the chocolates, as rumours say.
602deaad5c66e264997249457d555129
cubes = [i**3.0 for i in range(2, int(1.8e5+5))] def valid(mid): return sum([mid//i for i in cubes if i <= mid]) def binary_search(k): l = int(4.8 * k) r = min(8.0 * k, 5.0 * (10**15)) while (l+1 < r): mid = (l+r) / 2.0 res = valid(mid) if (res < k): l = mid else: r = mid return int(r) if int(valid(r)) == k else -1 def main(): k = int(input()) print(binary_search(k)) main()
["8", "54", "-1"]
Python
NoteIn the first sample case the smallest n that leads to exactly one way of stealing chocolates is n = 8, whereas the amounts of stealed chocolates are (1, 2, 4, 8) (the number of chocolates stolen by each of the thieves).In the second sample case the smallest n that leads to exactly 8 ways is n = 54 with the possibilities: (1, 2, 4, 8),  (1, 3, 9, 27),  (2, 4, 8, 16),  (2, 6, 18, 54),  (3, 6, 12, 24),  (4, 8, 16, 32),  (5, 10, 20, 40),  (6, 12, 24, 48).There is no n leading to exactly 10 ways of stealing chocolates in the third sample case.
Print the only integer nΒ β€” the maximum amount of chocolates that thieves' bags can carry. If there are more than one n satisfying the rumors, print the smallest one. If there is no such n for a false-rumoured m, print  - 1.
Bad news came to Mike's village, some thieves stole a bunch of chocolates from the local factory! Horrible! Aside from loving sweet things, thieves from this area are known to be very greedy. So after a thief takes his number of chocolates for himself, the next thief will take exactly k times more than the previous one. The value of k (k &gt; 1) is a secret integer known only to them. It is also known that each thief's bag can carry at most n chocolates (if they intend to take more, the deal is cancelled) and that there were exactly four thieves involved. Sadly, only the thieves know the value of n, but rumours say that the numbers of ways they could have taken the chocolates (for a fixed n, but not fixed k) is m. Two ways are considered different if one of the thieves (they should be numbered in the order they take chocolates) took different number of chocolates in them.Mike want to track the thieves down, so he wants to know what their bags are and value of n will help him in that. Please find the smallest possible value of n or tell him that the rumors are false and there is no such n.
[{"input": "1\r\n", "output": ["8"]}, {"input": "8\r\n", "output": ["54"]}, {"input": "10\r\n", "output": ["-1"]}, {"input": "27\r\n", "output": ["152"]}, {"input": "28206\r\n", "output": ["139840"]}, {"input": "32\r\n", "output": ["184"]}, {"input": "115\r\n", "output": ["608"]}, {"input": "81258\r\n", "output": ["402496"]}, {"input": "116003\r\n", "output": ["574506"]}, {"input": "149344197\r\n", "output": ["739123875"]}, {"input": "57857854\r\n", "output": ["286347520"]}, {"input": "999999999999999\r\n", "output": ["-1"]}, {"input": "181023403153\r\n", "output": ["895903132760"]}, {"input": "196071196742\r\n", "output": ["970376182648"]}, {"input": "49729446417673\r\n", "output": ["246116048009288"]}, {"input": "14821870173923\r\n", "output": ["73354931125416"]}, {"input": "29031595887308\r\n", "output": ["143680297402952"]}, {"input": "195980601490039\r\n", "output": ["969927770453672"]}, {"input": "181076658641313\r\n", "output": ["896166653569800"]}, {"input": "166173583620704\r\n", "output": ["822409831653228"]}, {"input": "151269640772354\r\n", "output": ["748648714769352"]}, {"input": "136366565751970\r\n", "output": ["674891892852776"]}, {"input": "121463490731834\r\n", "output": ["601135070936200"]}, {"input": "106559547884220\r\n", "output": ["527373954052328"]}, {"input": "91656472864718\r\n", "output": ["453617132135750"]}, {"input": "184061307002930\r\n", "output": ["910937979445720"]}, {"input": "57857853\r\n", "output": ["-1"]}, {"input": "1000000000000000\r\n", "output": ["4949100894494448"]}, {"input": "375402146575334\r\n", "output": ["-1"]}, {"input": "550368702711851\r\n", "output": ["-1"]}, {"input": "645093839227897\r\n", "output": ["-1"]}, {"input": "431\r\n", "output": ["-1"]}, {"input": "99999\r\n", "output": ["-1"]}, {"input": "2\r\n", "output": ["16"]}, {"input": "3\r\n", "output": ["24"]}, {"input": "4\r\n", "output": ["27"]}, {"input": "5\r\n", "output": ["32"]}, {"input": "6\r\n", "output": ["40"]}, {"input": "7\r\n", "output": ["48"]}, {"input": "13\r\n", "output": ["80"]}, {"input": "999999999999998\r\n", "output": ["-1"]}, {"input": "999999999999997\r\n", "output": ["4949100894494440"]}, {"input": "999999999999996\r\n", "output": ["4949100894494432"]}, {"input": "999999999999995\r\n", "output": ["4949100894494424"]}, {"input": "999999999999993\r\n", "output": ["4949100894494416"]}, {"input": "999999999999991\r\n", "output": ["4949100894494400"]}, {"input": "999999999999992\r\n", "output": ["4949100894494408"]}, {"input": "999999999999994\r\n", "output": ["4949100894494421"]}, {"input": "4235246\r\n", "output": ["-1"]}, {"input": "34\r\n", "output": ["-1"]}, {"input": "998749999999991\r\n", "output": ["4942914518376840"]}, {"input": "999999874999991\r\n", "output": ["4949100275856792"]}, {"input": "987654129875642\r\n", "output": ["4887999937625136"]}, {"input": "237648237648000\r\n", "output": ["1176145105832192"]}]
100
100
100
[{'input': '550368702711851\r\n', 'output': ['-1']}, {'input': '121463490731834\r\n', 'output': ['601135070936200']}, {'input': '49729446417673\r\n', 'output': ['246116048009288']}, {'input': '196071196742\r\n', 'output': ['970376182648']}, {'input': '999999999999997\r\n', 'output': ['4949100894494440']}]
[{'input': '999999999999995\r\n', 'output': ['4949100894494424']}, {'input': '999999999999997\r\n', 'output': ['4949100894494440']}, {'input': '8\r\n', 'output': ['54']}, {'input': '181023403153\r\n', 'output': ['895903132760']}, {'input': '151269640772354\r\n', 'output': ['748648714769352']}]
[{'input': '106559547884220\r\n', 'output': ['527373954052328']}, {'input': '2\r\n', 'output': ['16']}, {'input': '99999\r\n', 'output': ['-1']}, {'input': '999999999999992\r\n', 'output': ['4949100894494408']}, {'input': '999999999999995\r\n', 'output': ['4949100894494424']}]
[{'input': '999999999999994\r\n', 'output': ['4949100894494421']}, {'input': '184061307002930\r\n', 'output': ['910937979445720']}, {'input': '550368702711851\r\n', 'output': ['-1']}, {'input': '7\r\n', 'output': ['48']}, {'input': '49729446417673\r\n', 'output': ['246116048009288']}]
[{'input': '2\r\n', 'output': ['16']}, {'input': '106559547884220\r\n', 'output': ['527373954052328']}, {'input': '121463490731834\r\n', 'output': ['601135070936200']}, {'input': '999999999999996\r\n', 'output': ['4949100894494432']}, {'input': '4235246\r\n', 'output': ['-1']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
361
100
100
100
["5 2\n1 3 1 4 2", "6 4\n1 1 2 2 3 3"]
The first line contains two integers n, m (1 ≀ n ≀ 100;Β 1 ≀ m ≀ 100). The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 100).
c0ef1e4d7df360c5c1e52bc6f16ca87c
# http://codeforces.com/problemset/problem/450/A from collections import deque from math import ceil # n, m = [int(x) for x in input().split()] n, m = map(int, input().split()) candies = [int(x) for x in input().split()] children = deque([int(x) for x in range(1, n + 1)]) home = [] max_num = 0 counter = 0 candies_dict = {} for k in candies: counter += 1 candies_dict[counter] = k for i in candies: result = ceil(i / m) if result >= max_num: max_num = ceil(i / m) max_candies = i # print(candies_dict) # print(max_candies) max_keys = [] for k, v in candies_dict.items(): if v == max_candies: max_keys.append(k) print(max_keys[-1])
["4", "6"]
Python
NoteLet's consider the first sample. Firstly child 1 gets 2 candies and go home. Then child 2 gets 2 candies and go to the end of the line. Currently the line looks like [3, 4, 5, 2] (indices of the children in order of the line). Then child 3 gets 2 candies and go home, and then child 4 gets 2 candies and goes to the end of the line. Currently the line looks like [5, 2, 4]. Then child 5 gets 2 candies and goes home. Then child 2 gets two candies and goes home, and finally child 4 gets 2 candies and goes home.Child 4 is the last one who goes home.
Output a single integer, representing the number of the last child.
There are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number all the children from 1 to n. The i-th child wants to get at least ai candies.Jzzhu asks children to line up. Initially, the i-th child stands at the i-th place of the line. Then Jzzhu start distribution of the candies. He follows the algorithm: Give m candies to the first child of the line. If this child still haven't got enough candies, then the child goes to the end of the line, else the child go home. Repeat the first two steps while the line is not empty. Consider all the children in the order they go home. Jzzhu wants to know, which child will be the last in this order?
[{"input": "5 2\r\n1 3 1 4 2\r\n", "output": ["4"]}, {"input": "6 4\r\n1 1 2 2 3 3\r\n", "output": ["6"]}, {"input": "7 3\r\n6 1 5 4 2 3 1\r\n", "output": ["4"]}, {"input": "10 5\r\n2 7 3 6 2 5 1 3 4 5\r\n", "output": ["4"]}, {"input": "100 1\r\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\r\n", "output": ["100"]}, {"input": "9 3\r\n9 5 2 3 7 1 8 4 6\r\n", "output": ["7"]}, {"input": "20 10\r\n58 4 32 10 73 7 30 39 47 6 59 21 24 66 79 79 46 13 29 58\r\n", "output": ["16"]}, {"input": "50 5\r\n89 56 3 2 40 37 56 52 83 59 43 83 43 59 29 74 22 58 53 41 53 67 78 30 57 32 58 29 95 46 45 85 60 49 41 82 8 71 52 40 45 26 6 71 84 91 4 93 40 54\r\n", "output": ["48"]}, {"input": "50 1\r\n4 3 9 7 6 8 3 7 10 9 8 8 10 2 9 3 2 4 4 10 4 6 8 10 9 9 4 2 8 9 4 4 9 5 1 5 2 4 4 9 10 2 5 10 7 2 8 6 8 1\r\n", "output": ["44"]}, {"input": "50 5\r\n3 9 10 8 3 3 4 6 8 2 9 9 3 1 2 10 6 8 7 2 7 4 2 7 5 10 2 2 2 5 10 5 6 6 8 7 10 4 3 2 10 8 6 6 8 6 4 4 1 3\r\n", "output": ["46"]}, {"input": "50 2\r\n56 69 72 15 95 92 51 1 74 87 100 29 46 54 18 81 84 72 84 83 20 63 71 27 45 74 50 89 48 8 21 15 47 3 39 73 80 84 6 99 17 25 56 3 74 64 71 39 89 78\r\n", "output": ["40"]}, {"input": "50 3\r\n31 39 64 16 86 3 1 9 25 54 98 42 20 3 49 41 73 37 55 62 33 77 64 22 33 82 26 13 10 13 7 40 48 18 46 79 94 72 19 12 11 61 16 37 10 49 14 94 48 69\r\n", "output": ["11"]}, {"input": "50 100\r\n67 67 61 68 42 29 70 77 12 61 71 27 4 73 87 52 59 38 93 90 31 27 87 47 26 57 76 6 28 72 81 68 50 84 69 79 39 93 52 6 88 12 46 13 90 68 71 38 90 95\r\n", "output": ["50"]}, {"input": "100 3\r\n4 14 20 11 19 11 14 20 5 7 6 12 11 17 5 11 7 6 2 10 13 5 12 8 5 17 20 18 7 19 11 7 7 20 20 8 10 17 17 19 20 5 15 16 19 7 11 16 4 17 2 10 1 20 20 16 19 9 9 11 5 7 12 9 9 6 20 18 13 19 8 4 8 1 2 4 10 11 15 14 1 7 17 12 13 19 12 2 3 14 15 15 5 17 14 12 17 14 16 9\r\n", "output": ["86"]}, {"input": "100 5\r\n16 8 14 16 12 11 17 19 19 2 8 9 5 6 19 9 11 18 6 9 14 16 14 18 17 17 17 5 15 20 19 7 7 10 10 5 14 20 5 19 11 16 16 19 17 9 7 12 14 10 2 11 14 5 20 8 10 11 19 2 14 14 19 17 5 10 8 8 4 2 1 10 20 12 14 11 7 6 6 15 1 5 9 15 3 17 16 17 5 14 11 9 16 15 1 11 10 6 15 7\r\n", "output": ["93"]}, {"input": "100 1\r\n58 94 18 50 17 14 96 62 83 80 75 5 9 22 25 41 3 96 74 45 66 37 2 37 13 85 68 54 77 11 85 19 25 21 52 59 90 61 72 89 82 22 10 16 3 68 61 29 55 76 28 85 65 76 27 3 14 10 56 37 86 18 35 38 56 68 23 88 33 38 52 87 55 83 94 34 100 41 83 56 91 77 32 74 97 13 67 31 57 81 53 39 5 88 46 1 79 4 49 42\r\n", "output": ["77"]}, {"input": "100 2\r\n1 51 76 62 34 93 90 43 57 59 52 78 3 48 11 60 57 48 5 54 28 81 87 23 44 77 67 61 14 73 29 53 21 89 67 41 47 9 63 37 1 71 40 85 4 14 77 40 78 75 89 74 4 70 32 65 81 95 49 90 72 41 76 55 69 83 73 84 85 93 46 6 74 90 62 37 97 7 7 37 83 30 37 88 34 16 11 59 85 19 57 63 85 20 63 97 97 65 61 48\r\n", "output": ["97"]}, {"input": "100 3\r\n30 83 14 55 61 66 34 98 90 62 89 74 45 93 33 31 75 35 82 100 63 69 48 18 99 2 36 71 14 30 70 76 96 85 97 90 49 36 6 76 37 94 70 3 63 73 75 48 39 29 13 2 46 26 9 56 1 18 54 53 85 34 2 12 1 93 75 67 77 77 14 26 33 25 55 9 57 70 75 6 87 66 18 3 41 69 73 24 49 2 20 72 39 58 91 54 74 56 66 78\r\n", "output": ["20"]}, {"input": "100 4\r\n69 92 76 3 32 50 15 38 21 22 14 3 67 41 95 12 10 62 83 52 78 1 18 58 94 35 62 71 58 75 13 73 60 34 50 97 50 70 19 96 53 10 100 26 20 39 62 59 88 26 24 83 70 68 66 8 6 38 16 93 2 91 81 89 78 74 21 8 31 56 28 53 77 5 81 5 94 42 77 75 92 15 59 36 61 18 55 45 69 68 81 51 12 42 85 74 98 31 17 41\r\n", "output": ["97"]}, {"input": "100 5\r\n2 72 10 60 6 50 72 34 97 77 35 43 80 64 40 53 46 6 90 22 29 70 26 68 52 19 72 88 83 18 55 32 99 81 11 21 39 42 41 63 60 97 30 23 55 78 89 35 24 50 99 52 27 76 24 8 20 27 51 37 17 82 69 18 46 19 26 77 52 83 76 65 43 66 84 84 13 30 66 88 84 23 37 1 17 26 11 50 73 56 54 37 40 29 35 8 1 39 50 82\r\n", "output": ["51"]}, {"input": "100 7\r\n6 73 7 54 92 33 66 65 80 47 2 53 28 59 61 16 54 89 37 48 77 40 49 59 27 52 17 22 78 80 81 80 8 93 50 7 87 57 29 16 89 55 20 7 51 54 30 98 44 96 27 70 1 1 32 61 22 92 84 98 31 89 91 90 28 56 49 25 86 49 55 16 19 1 18 8 88 47 16 18 73 86 2 96 16 91 74 49 38 98 94 25 34 85 29 27 99 31 31 58\r\n", "output": ["97"]}, {"input": "100 9\r\n36 4 45 16 19 6 10 87 44 82 71 49 70 35 83 19 40 76 45 94 44 96 10 54 82 77 86 63 11 37 21 3 15 89 80 88 89 16 72 23 25 9 51 25 10 45 96 5 6 18 51 31 42 57 41 51 42 15 89 61 45 82 16 48 61 67 19 40 9 33 90 36 78 36 79 79 16 10 83 87 9 22 84 12 23 76 36 14 2 81 56 33 56 23 57 84 76 55 35 88\r\n", "output": ["47"]}, {"input": "100 10\r\n75 81 39 64 90 58 92 28 75 9 96 78 92 83 77 68 76 71 14 46 58 60 80 25 78 11 13 63 22 82 65 68 47 6 33 63 90 50 85 43 73 94 80 48 67 11 83 17 22 15 94 80 66 99 66 4 46 35 52 1 62 39 96 57 37 47 97 49 64 12 36 63 90 16 4 75 85 82 85 56 13 4 92 45 44 93 17 35 22 46 18 44 29 7 52 4 100 98 87 51\r\n", "output": ["98"]}, {"input": "100 20\r\n21 19 61 70 54 97 98 14 61 72 25 94 24 56 55 25 12 80 76 11 35 17 80 26 11 94 52 47 84 61 10 2 74 25 10 21 2 79 55 50 30 75 10 64 44 5 60 96 52 16 74 41 20 77 20 44 8 86 74 36 49 61 99 13 54 64 19 99 50 43 12 73 48 48 83 55 72 73 63 81 30 27 95 9 97 82 24 3 89 90 33 14 47 88 22 78 12 75 58 67\r\n", "output": ["94"]}, {"input": "100 30\r\n56 79 59 23 11 23 67 82 81 80 99 79 8 58 93 36 98 81 46 39 34 67 3 50 4 68 70 71 2 21 52 30 75 23 33 21 16 100 56 43 8 27 40 8 56 24 17 40 94 10 67 49 61 36 95 87 17 41 7 94 33 19 17 50 26 11 94 54 38 46 77 9 53 35 98 42 50 20 43 6 78 6 38 24 100 45 43 16 1 50 16 46 14 91 95 88 10 1 50 19\r\n", "output": ["95"]}, {"input": "100 40\r\n86 11 97 17 38 95 11 5 13 83 67 75 50 2 46 39 84 68 22 85 70 23 64 46 59 93 39 80 35 78 93 21 83 19 64 1 49 59 99 83 44 81 70 58 15 82 83 47 55 65 91 10 2 92 4 77 37 32 12 57 78 11 42 8 59 21 96 69 61 30 44 29 12 70 91 14 10 83 11 75 14 10 19 39 8 98 5 81 66 66 79 55 36 29 22 45 19 24 55 49\r\n", "output": ["88"]}, {"input": "100 50\r\n22 39 95 69 94 53 80 73 33 90 40 60 2 4 84 50 70 38 92 12 36 74 87 70 51 36 57 5 54 6 35 81 52 17 55 100 95 81 32 76 21 1 100 1 95 1 40 91 98 59 84 19 11 51 79 19 47 86 45 15 62 2 59 77 31 68 71 92 17 33 10 33 85 57 5 2 88 97 91 99 63 20 63 54 79 93 24 62 46 27 30 87 3 64 95 88 16 50 79 1\r\n", "output": ["99"]}, {"input": "100 70\r\n61 48 89 17 97 6 93 13 64 50 66 88 24 52 46 99 6 65 93 64 82 37 57 41 47 1 84 5 97 83 79 46 16 35 40 7 64 15 44 96 37 17 30 92 51 67 26 3 14 56 27 68 66 93 36 39 51 6 40 55 79 26 71 54 8 48 18 2 71 12 55 60 29 37 31 97 26 37 25 68 67 70 3 87 100 41 5 82 65 92 24 66 76 48 89 8 40 93 31 95\r\n", "output": ["100"]}, {"input": "100 90\r\n87 32 30 15 10 52 93 63 84 1 82 41 27 51 75 32 42 94 39 53 70 13 4 22 99 35 44 38 5 23 18 100 61 80 9 12 42 93 9 77 3 7 60 95 66 78 95 42 69 8 1 88 93 66 96 20 76 63 15 36 92 52 2 72 36 57 48 63 29 20 74 88 49 47 81 61 94 74 70 93 47 3 19 52 59 41 5 40 22 3 76 97 91 37 95 88 91 99 76 15\r\n", "output": ["98"]}, {"input": "100 100\r\n79 75 7 28 6 96 38 35 57 95 41 74 24 96 32 78 81 13 63 84 24 95 3 23 66 1 60 6 96 49 41 5 14 18 31 97 66 19 49 89 49 70 51 28 20 99 18 1 28 77 24 46 69 21 40 32 31 66 28 6 66 97 9 16 70 90 91 30 34 82 93 41 65 11 39 52 1 88 63 43 80 50 60 49 28 56 18 76 24 57 74 1 28 99 36 35 79 54 18 16\r\n", "output": ["100"]}, {"input": "1 3\r\n5\r\n", "output": ["1"]}, {"input": "1 1\r\n100\r\n", "output": ["1"]}, {"input": "2 3\r\n4 2\r\n", "output": ["1"]}, {"input": "2 5\r\n99 97\r\n", "output": ["2"]}, {"input": "3 4\r\n7 5 2\r\n", "output": ["2"]}, {"input": "3 50\r\n47 86 51\r\n", "output": ["3"]}, {"input": "5 100\r\n82 100 85 1 37\r\n", "output": ["5"]}, {"input": "5 20\r\n40 39 21 5 20\r\n", "output": ["3"]}, {"input": "1 27\r\n81\r\n", "output": ["1"]}, {"input": "20 13\r\n7 8 29 83 74 28 93 85 7 8 3 9 8 70 49 50 39 41 57 1\r\n", "output": ["7"]}, {"input": "2 1\r\n100 2\r\n", "output": ["1"]}, {"input": "2 2\r\n6 4\r\n", "output": ["1"]}, {"input": "5 2\r\n6 4 4 1 1\r\n", "output": ["1"]}, {"input": "1 4\r\n3\r\n", "output": ["1"]}, {"input": "3 2\r\n1 5 3\r\n", "output": ["2"]}, {"input": "3 1\r\n3 2 2\r\n", "output": ["1"]}, {"input": "3 1\r\n2 3 2\r\n", "output": ["2"]}, {"input": "5 1\r\n5 1 1 1 1\r\n", "output": ["1"]}, {"input": "2 3\r\n7 4\r\n", "output": ["1"]}]
100
100
100
[{'input': '100 2\r\n1 51 76 62 34 93 90 43 57 59 52 78 3 48 11 60 57 48 5 54 28 81 87 23 44 77 67 61 14 73 29 53 21 89 67 41 47 9 63 37 1 71 40 85 4 14 77 40 78 75 89 74 4 70 32 65 81 95 49 90 72 41 76 55 69 83 73 84 85 93 46 6 74 90 62 37 97 7 7 37 83 30 37 88 34 16 11 59 85 19 57 63 85 20 63 97 97 65 61 48\r\n', 'output': ['97']}, {'input': '100 4\r\n69 92 76 3 32 50 15 38 21 22 14 3 67 41 95 12 10 62 83 52 78 1 18 58 94 35 62 71 58 75 13 73 60 34 50 97 50 70 19 96 53 10 100 26 20 39 62 59 88 26 24 83 70 68 66 8 6 38 16 93 2 91 81 89 78 74 21 8 31 56 28 53 77 5 81 5 94 42 77 75 92 15 59 36 61 18 55 45 69 68 81 51 12 42 85 74 98 31 17 41\r\n', 'output': ['97']}, {'input': '100 30\r\n56 79 59 23 11 23 67 82 81 80 99 79 8 58 93 36 98 81 46 39 34 67 3 50 4 68 70 71 2 21 52 30 75 23 33 21 16 100 56 43 8 27 40 8 56 24 17 40 94 10 67 49 61 36 95 87 17 41 7 94 33 19 17 50 26 11 94 54 38 46 77 9 53 35 98 42 50 20 43 6 78 6 38 24 100 45 43 16 1 50 16 46 14 91 95 88 10 1 50 19\r\n', 'output': ['95']}, {'input': '100 70\r\n61 48 89 17 97 6 93 13 64 50 66 88 24 52 46 99 6 65 93 64 82 37 57 41 47 1 84 5 97 83 79 46 16 35 40 7 64 15 44 96 37 17 30 92 51 67 26 3 14 56 27 68 66 93 36 39 51 6 40 55 79 26 71 54 8 48 18 2 71 12 55 60 29 37 31 97 26 37 25 68 67 70 3 87 100 41 5 82 65 92 24 66 76 48 89 8 40 93 31 95\r\n', 'output': ['100']}, {'input': '3 1\r\n2 3 2\r\n', 'output': ['2']}]
[{'input': '100 3\r\n30 83 14 55 61 66 34 98 90 62 89 74 45 93 33 31 75 35 82 100 63 69 48 18 99 2 36 71 14 30 70 76 96 85 97 90 49 36 6 76 37 94 70 3 63 73 75 48 39 29 13 2 46 26 9 56 1 18 54 53 85 34 2 12 1 93 75 67 77 77 14 26 33 25 55 9 57 70 75 6 87 66 18 3 41 69 73 24 49 2 20 72 39 58 91 54 74 56 66 78\r\n', 'output': ['20']}, {'input': '5 2\r\n6 4 4 1 1\r\n', 'output': ['1']}, {'input': '3 50\r\n47 86 51\r\n', 'output': ['3']}, {'input': '2 3\r\n4 2\r\n', 'output': ['1']}, {'input': '20 10\r\n58 4 32 10 73 7 30 39 47 6 59 21 24 66 79 79 46 13 29 58\r\n', 'output': ['16']}]
[{'input': '100 2\r\n1 51 76 62 34 93 90 43 57 59 52 78 3 48 11 60 57 48 5 54 28 81 87 23 44 77 67 61 14 73 29 53 21 89 67 41 47 9 63 37 1 71 40 85 4 14 77 40 78 75 89 74 4 70 32 65 81 95 49 90 72 41 76 55 69 83 73 84 85 93 46 6 74 90 62 37 97 7 7 37 83 30 37 88 34 16 11 59 85 19 57 63 85 20 63 97 97 65 61 48\r\n', 'output': ['97']}, {'input': '100 7\r\n6 73 7 54 92 33 66 65 80 47 2 53 28 59 61 16 54 89 37 48 77 40 49 59 27 52 17 22 78 80 81 80 8 93 50 7 87 57 29 16 89 55 20 7 51 54 30 98 44 96 27 70 1 1 32 61 22 92 84 98 31 89 91 90 28 56 49 25 86 49 55 16 19 1 18 8 88 47 16 18 73 86 2 96 16 91 74 49 38 98 94 25 34 85 29 27 99 31 31 58\r\n', 'output': ['97']}, {'input': '5 1\r\n5 1 1 1 1\r\n', 'output': ['1']}, {'input': '2 3\r\n7 4\r\n', 'output': ['1']}, {'input': '50 100\r\n67 67 61 68 42 29 70 77 12 61 71 27 4 73 87 52 59 38 93 90 31 27 87 47 26 57 76 6 28 72 81 68 50 84 69 79 39 93 52 6 88 12 46 13 90 68 71 38 90 95\r\n', 'output': ['50']}]
[{'input': '2 2\r\n6 4\r\n', 'output': ['1']}, {'input': '100 2\r\n1 51 76 62 34 93 90 43 57 59 52 78 3 48 11 60 57 48 5 54 28 81 87 23 44 77 67 61 14 73 29 53 21 89 67 41 47 9 63 37 1 71 40 85 4 14 77 40 78 75 89 74 4 70 32 65 81 95 49 90 72 41 76 55 69 83 73 84 85 93 46 6 74 90 62 37 97 7 7 37 83 30 37 88 34 16 11 59 85 19 57 63 85 20 63 97 97 65 61 48\r\n', 'output': ['97']}, {'input': '100 100\r\n79 75 7 28 6 96 38 35 57 95 41 74 24 96 32 78 81 13 63 84 24 95 3 23 66 1 60 6 96 49 41 5 14 18 31 97 66 19 49 89 49 70 51 28 20 99 18 1 28 77 24 46 69 21 40 32 31 66 28 6 66 97 9 16 70 90 91 30 34 82 93 41 65 11 39 52 1 88 63 43 80 50 60 49 28 56 18 76 24 57 74 1 28 99 36 35 79 54 18 16\r\n', 'output': ['100']}, {'input': '1 3\r\n5\r\n', 'output': ['1']}, {'input': '50 5\r\n89 56 3 2 40 37 56 52 83 59 43 83 43 59 29 74 22 58 53 41 53 67 78 30 57 32 58 29 95 46 45 85 60 49 41 82 8 71 52 40 45 26 6 71 84 91 4 93 40 54\r\n', 'output': ['48']}]
[{'input': '9 3\r\n9 5 2 3 7 1 8 4 6\r\n', 'output': ['7']}, {'input': '2 5\r\n99 97\r\n', 'output': ['2']}, {'input': '100 1\r\n58 94 18 50 17 14 96 62 83 80 75 5 9 22 25 41 3 96 74 45 66 37 2 37 13 85 68 54 77 11 85 19 25 21 52 59 90 61 72 89 82 22 10 16 3 68 61 29 55 76 28 85 65 76 27 3 14 10 56 37 86 18 35 38 56 68 23 88 33 38 52 87 55 83 94 34 100 41 83 56 91 77 32 74 97 13 67 31 57 81 53 39 5 88 46 1 79 4 49 42\r\n', 'output': ['77']}, {'input': '100 2\r\n1 51 76 62 34 93 90 43 57 59 52 78 3 48 11 60 57 48 5 54 28 81 87 23 44 77 67 61 14 73 29 53 21 89 67 41 47 9 63 37 1 71 40 85 4 14 77 40 78 75 89 74 4 70 32 65 81 95 49 90 72 41 76 55 69 83 73 84 85 93 46 6 74 90 62 37 97 7 7 37 83 30 37 88 34 16 11 59 85 19 57 63 85 20 63 97 97 65 61 48\r\n', 'output': ['97']}, {'input': '100 50\r\n22 39 95 69 94 53 80 73 33 90 40 60 2 4 84 50 70 38 92 12 36 74 87 70 51 36 57 5 54 6 35 81 52 17 55 100 95 81 32 76 21 1 100 1 95 1 40 91 98 59 84 19 11 51 79 19 47 86 45 15 62 2 59 77 31 68 71 92 17 33 10 33 85 57 5 2 88 97 91 99 63 20 63 54 79 93 24 62 46 27 30 87 3 64 95 88 16 50 79 1\r\n', 'output': ['99']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
362
100
100
100
["0 0", "1 0", "0 1", "-1 -1"]
The first line contains two space-separated integers x and y (|x|, |y| ≀ 100).
2fb2a129e01efc03cfc3ad91dac88382
x = 0 y = 0 nx,ny = map(int,input().split()) if ((nx == 0 or nx == 1) and ny == 0): print(0) else: x = 1 turn = 0 flag = 0 while True: turn = turn + 1 while y != x: y = y + 1 if(x == nx and y == ny): flag = 1 break if flag == 1: break k = x * -1 turn = turn + 1 while x != k: x = x - 1 if(x == nx and y == ny): flag = 1 break if flag == 1: break turn = turn + 1 while y != x: y = y - 1 if(x == nx and y == ny): flag = 1 break if flag == 1: break k = (x * -1) + 1 turn = turn + 1 while x != k: x = x + 1 if(x == nx and y == ny): flag = 1 break if flag == 1: break print(turn)
["0", "0", "2", "3"]
Python
null
Print a single integer, showing how many times Valera has to turn.
Valera the horse lives on a plane. The Cartesian coordinate system is defined on this plane. Also an infinite spiral is painted on the plane. The spiral consists of segments: [(0, 0), (1, 0)], [(1, 0), (1, 1)], [(1, 1), ( - 1, 1)], [( - 1, 1), ( - 1,  - 1)], [( - 1,  - 1), (2,  - 1)], [(2,  - 1), (2, 2)] and so on. Thus, this infinite spiral passes through each integer point of the plane.Valera the horse lives on the plane at coordinates (0, 0). He wants to walk along the spiral to point (x, y). Valera the horse has four legs, so he finds turning very difficult. Count how many times he will have to turn if he goes along a spiral from point (0, 0) to point (x, y).
[{"input": "0 0\r\n", "output": ["0"]}, {"input": "1 0\r\n", "output": ["0"]}, {"input": "0 1\r\n", "output": ["2"]}, {"input": "-1 -1\r\n", "output": ["3"]}, {"input": "10 10\r\n", "output": ["37"]}, {"input": "0 6\r\n", "output": ["22"]}, {"input": "-7 -13\r\n", "output": ["52"]}, {"input": "37 -100\r\n", "output": ["400"]}, {"input": "99 100\r\n", "output": ["398"]}, {"input": "16 -32\r\n", "output": ["128"]}, {"input": "1 1\r\n", "output": ["1"]}, {"input": "-1 1\r\n", "output": ["2"]}, {"input": "-1 0\r\n", "output": ["3"]}, {"input": "3 -5\r\n", "output": ["20"]}, {"input": "0 -1\r\n", "output": ["4"]}, {"input": "1 -1\r\n", "output": ["4"]}, {"input": "100 100\r\n", "output": ["397"]}, {"input": "0 99\r\n", "output": ["394"]}, {"input": "-98 98\r\n", "output": ["390"]}, {"input": "-97 0\r\n", "output": ["387"]}, {"input": "-96 -96\r\n", "output": ["383"]}, {"input": "0 -95\r\n", "output": ["380"]}, {"input": "94 -94\r\n", "output": ["376"]}, {"input": "93 0\r\n", "output": ["369"]}, {"input": "17 25\r\n", "output": ["98"]}, {"input": "1 -84\r\n", "output": ["336"]}, {"input": "-5 44\r\n", "output": ["174"]}, {"input": "11 -15\r\n", "output": ["60"]}, {"input": "42 9\r\n", "output": ["165"]}, {"input": "-81 3\r\n", "output": ["323"]}, {"input": "100 99\r\n", "output": ["397"]}, {"input": "2 -1\r\n", "output": ["4"]}]
100
100
100
[{'input': '100 100\r\n', 'output': ['397']}, {'input': '-97 0\r\n', 'output': ['387']}, {'input': '1 1\r\n', 'output': ['1']}, {'input': '93 0\r\n', 'output': ['369']}, {'input': '0 0\r\n', 'output': ['0']}]
[{'input': '-7 -13\r\n', 'output': ['52']}, {'input': '-97 0\r\n', 'output': ['387']}, {'input': '0 6\r\n', 'output': ['22']}, {'input': '1 -84\r\n', 'output': ['336']}, {'input': '3 -5\r\n', 'output': ['20']}]
[{'input': '11 -15\r\n', 'output': ['60']}, {'input': '2 -1\r\n', 'output': ['4']}, {'input': '42 9\r\n', 'output': ['165']}, {'input': '1 -1\r\n', 'output': ['4']}, {'input': '16 -32\r\n', 'output': ['128']}]
[{'input': '94 -94\r\n', 'output': ['376']}, {'input': '99 100\r\n', 'output': ['398']}, {'input': '3 -5\r\n', 'output': ['20']}, {'input': '1 1\r\n', 'output': ['1']}, {'input': '1 0\r\n', 'output': ['0']}]
[{'input': '2 -1\r\n', 'output': ['4']}, {'input': '0 0\r\n', 'output': ['0']}, {'input': '0 1\r\n', 'output': ['2']}, {'input': '1 0\r\n', 'output': ['0']}, {'input': '93 0\r\n', 'output': ['369']}]
100
100
100
100
100
86.05
90.7
83.72
93.02
93.02
84.62
88.46
80.77
92.31
92.31
363
100
89.302
87.694
["1 0", "2 1", "3 2", "4 1", "7 4"]
The single line contains two space-separated integers n and k (1 ≀ n ≀ 1000, 0 ≀ k ≀ n).
1243e98fe2ebd6e6d1de851984b96079
mod=10**9+7 n,k=map(int,input().split()) A=[0]*(n+1) B=[0]*(n+1) C=[0]*(n+1) F=[0]*(n+1) G=[0]*(n+1) F[0]=G[0]=1 for i in range(1,n+1): G[i]=F[i]=F[i-1]*i%mod G[i]=pow(F[i],(mod-2),mod) for i in range(0,n): if i*2>n: break B[i]=(F[n-i]*G[i]*G[n-i*2])%mod for i in range(0,n//2+1): for j in range(0,n//2+1): A[i+j]=(A[i+j]+B[i]*B[j])%mod for i in range(0,n+1): A[i]=A[i]*F[n-i]%mod for i in range(0,n+1): for j in range(0,i+1): C[j]=(C[j]+A[i]*F[i]*G[j]*G[i-j]*(1-(i-j)%2*2))%mod print(C[k]%mod)
["1", "0", "4", "6", "328"]
Python
NoteThe only permutation of size 1 has 0 good positions.Permutation (1, 2) has 0 good positions, and permutation (2, 1) has 2 positions.Permutations of size 3: (1, 2, 3) β€” 0 positions β€” 2 positions β€” 2 positions β€” 2 positions β€” 2 positions (3, 2, 1) β€” 0 positions
Print the number of permutations of length n with exactly k good positions modulo 1000000007 (109 + 7).
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.We'll call position i (1 ≀ i ≀ n) in permutation p1, p2, ..., pn good, if |p[i] - i| = 1. Count the number of permutations of size n with exactly k good positions. Print the answer modulo 1000000007 (109 + 7).
[{"input": "1 0\r\n", "output": ["1"]}, {"input": "2 1\r\n", "output": ["0"]}, {"input": "3 2\r\n", "output": ["4"]}, {"input": "4 1\r\n", "output": ["6"]}, {"input": "7 4\r\n", "output": ["328"]}, {"input": "7 7\r\n", "output": ["0"]}, {"input": "8 4\r\n", "output": ["2658"]}, {"input": "8 5\r\n", "output": ["688"]}, {"input": "10 3\r\n", "output": ["614420"]}, {"input": "20 0\r\n", "output": ["111008677"]}, {"input": "100 99\r\n", "output": ["2450"]}, {"input": "13 13\r\n", "output": ["0"]}, {"input": "100 100\r\n", "output": ["1"]}, {"input": "1000 0\r\n", "output": ["845393494"]}, {"input": "1000 1\r\n", "output": ["418947603"]}, {"input": "1000 2\r\n", "output": ["819706485"]}, {"input": "1000 10\r\n", "output": ["305545369"]}, {"input": "1000 99\r\n", "output": ["115316732"]}, {"input": "1000 500\r\n", "output": ["979041279"]}, {"input": "1000 700\r\n", "output": ["642759746"]}, {"input": "1000 900\r\n", "output": ["301804159"]}, {"input": "1000 999\r\n", "output": ["249500"]}, {"input": "1000 998\r\n", "output": ["583666213"]}, {"input": "1000 1000\r\n", "output": ["1"]}, {"input": "999 0\r\n", "output": ["184907578"]}, {"input": "999 1\r\n", "output": ["167859862"]}, {"input": "999 5\r\n", "output": ["642835575"]}, {"input": "999 13\r\n", "output": ["740892203"]}, {"input": "999 300\r\n", "output": ["562270116"]}, {"input": "999 600\r\n", "output": ["553332041"]}, {"input": "999 999\r\n", "output": ["0"]}, {"input": "999 989\r\n", "output": ["254295912"]}, {"input": "999 998\r\n", "output": ["250000"]}, {"input": "10 0\r\n", "output": ["543597"]}, {"input": "5 0\r\n", "output": ["21"]}, {"input": "5 1\r\n", "output": ["36"]}, {"input": "5 2\r\n", "output": ["42"]}, {"input": "5 3\r\n", "output": ["12"]}, {"input": "5 4\r\n", "output": ["9"]}, {"input": "5 5\r\n", "output": ["0"]}, {"input": "4 4\r\n", "output": ["1"]}, {"input": "4 3\r\n", "output": ["2"]}, {"input": "4 2\r\n", "output": ["10"]}, {"input": "1 1\r\n", "output": ["0"]}, {"input": "2 2\r\n", "output": ["1"]}, {"input": "3 1\r\n", "output": ["0"]}, {"input": "3 3\r\n", "output": ["0"]}, {"input": "2 0\r\n", "output": ["1"]}, {"input": "3 0\r\n", "output": ["2"]}]
100
100
100
[{'input': '999 998\r\n', 'output': ['250000']}, {'input': '1000 0\r\n', 'output': ['845393494']}, {'input': '5 3\r\n', 'output': ['12']}, {'input': '5 0\r\n', 'output': ['21']}, {'input': '999 999\r\n', 'output': ['0']}]
[{'input': '3 3\r\n', 'output': ['0']}, {'input': '999 0\r\n', 'output': ['184907578']}, {'input': '2 0\r\n', 'output': ['1']}, {'input': '999 998\r\n', 'output': ['250000']}, {'input': '20 0\r\n', 'output': ['111008677']}]
[{'input': '20 0\r\n', 'output': ['111008677']}, {'input': '999 998\r\n', 'output': ['250000']}, {'input': '13 13\r\n', 'output': ['0']}, {'input': '8 5\r\n', 'output': ['688']}, {'input': '10 3\r\n', 'output': ['614420']}]
[{'input': '999 13\r\n', 'output': ['740892203']}, {'input': '3 0\r\n', 'output': ['2']}, {'input': '999 999\r\n', 'output': ['0']}, {'input': '1000 10\r\n', 'output': ['305545369']}, {'input': '8 4\r\n', 'output': ['2658']}]
[{'input': '1000 1\r\n', 'output': ['418947603']}, {'input': '1 1\r\n', 'output': ['0']}, {'input': '1000 99\r\n', 'output': ['115316732']}, {'input': '999 998\r\n', 'output': ['250000']}, {'input': '10 3\r\n', 'output': ['614420']}]
100
100
100
100
100
100
100
100
100
100
93.75
100
93.75
93.75
100
364
100
100
96.25
["WUBWUBABCWUB", "WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB"]
The input consists of a single non-empty string, consisting only of uppercase English letters, the string's length doesn't exceed 200 characters. It is guaranteed that before Vasya remixed the song, no word contained substring "WUB" in it; Vasya didn't change the word order. It is also guaranteed that initially the song had at least one word.
edede580da1395fe459a480f6a0a548d
n = input() n = list(n) space = 1 s = [] i = 0 for _ in range(0,len(n), 1): if i == len(n): break elif i + 2 < len(n) and n[i] == 'W' and n[i+1] == 'U' and n[i+2] == 'B': i += 3 if space == 0: s.append(" ") space = 1 else: s.append(n[i]) i += 1 space = 0 ans = "" for i in range(0, len(s)): ans = ans + s[i] print(ans)
["ABC", "WE ARE THE CHAMPIONS MY FRIEND"]
Python
NoteIn the first sample: "WUBWUBABCWUB" = "WUB" + "WUB" + "ABC" + "WUB". That means that the song originally consisted of a single word "ABC", and all words "WUB" were added by Vasya.In the second sample Vasya added a single word "WUB" between all neighbouring words, in the beginning and in the end, except for words "ARE" and "THE" β€” between them Vasya added two "WUB".
Print the words of the initial song that Vasya used to make a dubsteb remix. Separate the words with a space.
Vasya works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dubstep remixes from them.Let's assume that a song consists of some number of words. To make the dubstep remix of this song, Vasya inserts a certain number of words "WUB" before the first word of the song (the number may be zero), after the last word (the number may be zero), and between words (at least one between any pair of neighbouring words), and then the boy glues together all the words, including "WUB", in one string and plays the song at the club.For example, a song with words "I AM X" can transform into a dubstep remix as "WUBWUBIWUBAMWUBWUBX" and cannot transform into "WUBWUBIAMWUBX".Recently, Petya has heard Vasya's new dubstep track, but since he isn't into modern music, he decided to find out what was the initial song that Vasya remixed. Help Petya restore the original song.
[{"input": "WUBWUBABCWUB\r\n", "output": ["ABC"]}, {"input": "WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB\r\n", "output": ["WE ARE THE CHAMPIONS MY FRIEND", "WE ARE THE CHAMPIONS MY FRIEND"]}, {"input": "WUBWUBWUBSR\r\n", "output": ["SR"]}, {"input": "RWUBWUBWUBLWUB\r\n", "output": ["R L", "R L"]}, {"input": "ZJWUBWUBWUBJWUBWUBWUBL\r\n", "output": ["ZJ J L", "ZJ J L"]}, {"input": "CWUBBWUBWUBWUBEWUBWUBWUBQWUBWUBWUB\r\n", "output": ["C B E Q", "C B E Q"]}, {"input": "WUBJKDWUBWUBWBIRAQKFWUBWUBYEWUBWUBWUBWVWUBWUB\r\n", "output": ["JKD WBIRAQKF YE WV", "JKD WBIRAQKF YE WV"]}, {"input": "WUBKSDHEMIXUJWUBWUBRWUBWUBWUBSWUBWUBWUBHWUBWUBWUB\r\n", "output": ["KSDHEMIXUJ R S H", "KSDHEMIXUJ R S H"]}, {"input": "OGWUBWUBWUBXWUBWUBWUBIWUBWUBWUBKOWUBWUB\r\n", "output": ["OG X I KO", "OG X I KO"]}, {"input": "QWUBQQWUBWUBWUBIWUBWUBWWWUBWUBWUBJOPJPBRH\r\n", "output": ["Q QQ I WW JOPJPBRH", "Q QQ I WW JOPJPBRH"]}, {"input": "VSRNVEATZTLGQRFEGBFPWUBWUBWUBAJWUBWUBWUBPQCHNWUBCWUB\r\n", "output": ["VSRNVEATZTLGQRFEGBFP AJ PQCHN C", "VSRNVEATZTLGQRFEGBFP AJ PQCHN C"]}, {"input": "WUBWUBEWUBWUBWUBIQMJNIQWUBWUBWUBGZZBQZAUHYPWUBWUBWUBPMRWUBWUBWUBDCV\r\n", "output": ["E IQMJNIQ GZZBQZAUHYP PMR DCV", "E IQMJNIQ GZZBQZAUHYP PMR DCV"]}, {"input": "WUBWUBWUBFVWUBWUBWUBBPSWUBWUBWUBRXNETCJWUBWUBWUBJDMBHWUBWUBWUBBWUBWUBVWUBWUBB\r\n", "output": ["FV BPS RXNETCJ JDMBH B V B", "FV BPS RXNETCJ JDMBH B V B"]}, {"input": "WUBWUBWUBFBQWUBWUBWUBIDFSYWUBWUBWUBCTWDMWUBWUBWUBSXOWUBWUBWUBQIWUBWUBWUBL\r\n", "output": ["FBQ IDFSY CTWDM SXO QI L", "FBQ IDFSY CTWDM SXO QI L"]}, {"input": "IWUBWUBQLHDWUBYIIKZDFQWUBWUBWUBCXWUBWUBUWUBWUBWUBKWUBWUBWUBNL\r\n", "output": ["I QLHD YIIKZDFQ CX U K NL", "I QLHD YIIKZDFQ CX U K NL"]}, {"input": "KWUBUPDYXGOKUWUBWUBWUBAGOAHWUBIZDWUBWUBWUBIYWUBWUBWUBVWUBWUBWUBPWUBWUBWUBE\r\n", "output": ["K UPDYXGOKU AGOAH IZD IY V P E", "K UPDYXGOKU AGOAH IZD IY V P E"]}, {"input": "WUBWUBOWUBWUBWUBIPVCQAFWYWUBWUBWUBQWUBWUBWUBXHDKCPYKCTWWYWUBWUBWUBVWUBWUBWUBFZWUBWUB\r\n", "output": ["O IPVCQAFWY Q XHDKCPYKCTWWY V FZ", "O IPVCQAFWY Q XHDKCPYKCTWWY V FZ"]}, {"input": "PAMJGYWUBWUBWUBXGPQMWUBWUBWUBTKGSXUYWUBWUBWUBEWUBWUBWUBNWUBWUBWUBHWUBWUBWUBEWUBWUB\r\n", "output": ["PAMJGY XGPQM TKGSXUY E N H E", "PAMJGY XGPQM TKGSXUY E N H E"]}, {"input": "WUBYYRTSMNWUWUBWUBWUBCWUBWUBWUBCWUBWUBWUBFSYUINDWOBVWUBWUBWUBFWUBWUBWUBAUWUBWUBWUBVWUBWUBWUBJB\r\n", "output": ["YYRTSMNWU C C FSYUINDWOBV F AU V JB", "YYRTSMNWU C C FSYUINDWOBV F AU V JB"]}, {"input": "WUBWUBYGPYEYBNRTFKOQCWUBWUBWUBUYGRTQEGWLFYWUBWUBWUBFVWUBHPWUBWUBWUBXZQWUBWUBWUBZDWUBWUBWUBM\r\n", "output": ["YGPYEYBNRTFKOQC UYGRTQEGWLFY FV HP XZQ ZD M", "YGPYEYBNRTFKOQC UYGRTQEGWLFY FV HP XZQ ZD M"]}, {"input": "WUBZVMJWUBWUBWUBFOIMJQWKNZUBOFOFYCCWUBWUBWUBAUWWUBRDRADWUBWUBWUBCHQVWUBWUBWUBKFTWUBWUBWUBW\r\n", "output": ["ZVMJ FOIMJQWKNZUBOFOFYCC AUW RDRAD CHQV KFT W", "ZVMJ FOIMJQWKNZUBOFOFYCC AUW RDRAD CHQV KFT W"]}, {"input": "WUBWUBZBKOKHQLGKRVIMZQMQNRWUBWUBWUBDACWUBWUBNZHFJMPEYKRVSWUBWUBWUBPPHGAVVPRZWUBWUBWUBQWUBWUBAWUBG\r\n", "output": ["ZBKOKHQLGKRVIMZQMQNR DAC NZHFJMPEYKRVS PPHGAVVPRZ Q A G", "ZBKOKHQLGKRVIMZQMQNR DAC NZHFJMPEYKRVS PPHGAVVPRZ Q A G"]}, {"input": "WUBWUBJWUBWUBWUBNFLWUBWUBWUBGECAWUBYFKBYJWTGBYHVSSNTINKWSINWSMAWUBWUBWUBFWUBWUBWUBOVWUBWUBLPWUBWUBWUBN\r\n", "output": ["J NFL GECA YFKBYJWTGBYHVSSNTINKWSINWSMA F OV LP N", "J NFL GECA YFKBYJWTGBYHVSSNTINKWSINWSMA F OV LP N"]}, {"input": "WUBWUBLCWUBWUBWUBZGEQUEATJVIXETVTWUBWUBWUBEXMGWUBWUBWUBRSWUBWUBWUBVWUBWUBWUBTAWUBWUBWUBCWUBWUBWUBQG\r\n", "output": ["LC ZGEQUEATJVIXETVT EXMG RS V TA C QG", "LC ZGEQUEATJVIXETVT EXMG RS V TA C QG"]}, {"input": "WUBMPWUBWUBWUBORWUBWUBDLGKWUBWUBWUBVVZQCAAKVJTIKWUBWUBWUBTJLUBZJCILQDIFVZWUBWUBYXWUBWUBWUBQWUBWUBWUBLWUB\r\n", "output": ["MP OR DLGK VVZQCAAKVJTIK TJLUBZJCILQDIFVZ YX Q L", "MP OR DLGK VVZQCAAKVJTIK TJLUBZJCILQDIFVZ YX Q L"]}, {"input": "WUBNXOLIBKEGXNWUBWUBWUBUWUBGITCNMDQFUAOVLWUBWUBWUBAIJDJZJHFMPVTPOXHPWUBWUBWUBISCIOWUBWUBWUBGWUBWUBWUBUWUB\r\n", "output": ["NXOLIBKEGXN U GITCNMDQFUAOVL AIJDJZJHFMPVTPOXHP ISCIO G U", "NXOLIBKEGXN U GITCNMDQFUAOVL AIJDJZJHFMPVTPOXHP ISCIO G U"]}, {"input": "WUBWUBNMMWCZOLYPNBELIYVDNHJUNINWUBWUBWUBDXLHYOWUBWUBWUBOJXUWUBWUBWUBRFHTGJCEFHCGWARGWUBWUBWUBJKWUBWUBSJWUBWUB\r\n", "output": ["NMMWCZOLYPNBELIYVDNHJUNIN DXLHYO OJXU RFHTGJCEFHCGWARG JK SJ", "NMMWCZOLYPNBELIYVDNHJUNIN DXLHYO OJXU RFHTGJCEFHCGWARG JK SJ"]}, {"input": "SGWLYSAUJOJBNOXNWUBWUBWUBBOSSFWKXPDPDCQEWUBWUBWUBDIRZINODWUBWUBWUBWWUBWUBWUBPPHWUBWUBWUBRWUBWUBWUBQWUBWUBWUBJWUB\r\n", "output": ["SGWLYSAUJOJBNOXN BOSSFWKXPDPDCQE DIRZINOD W PPH R Q J", "SGWLYSAUJOJBNOXN BOSSFWKXPDPDCQE DIRZINOD W PPH R Q J"]}, {"input": "TOWUBWUBWUBGBTBNWUBWUBWUBJVIOJBIZFUUYHUAIEBQLQXPQKZJMPTCWBKPOSAWUBWUBWUBSWUBWUBWUBTOLVXWUBWUBWUBNHWUBWUBWUBO\r\n", "output": ["TO GBTBN JVIOJBIZFUUYHUAIEBQLQXPQKZJMPTCWBKPOSA S TOLVX NH O", "TO GBTBN JVIOJBIZFUUYHUAIEBQLQXPQKZJMPTCWBKPOSA S TOLVX NH O"]}, {"input": "WUBWUBWSPLAYSZSAUDSWUBWUBWUBUWUBWUBWUBKRWUBWUBWUBRSOKQMZFIYZQUWUBWUBWUBELSHUWUBWUBWUBUKHWUBWUBWUBQXEUHQWUBWUBWUBBWUBWUBWUBR\r\n", "output": ["WSPLAYSZSAUDS U KR RSOKQMZFIYZQU ELSHU UKH QXEUHQ B R", "WSPLAYSZSAUDS U KR RSOKQMZFIYZQU ELSHU UKH QXEUHQ B R"]}, {"input": "WUBXEMWWVUHLSUUGRWUBWUBWUBAWUBXEGILZUNKWUBWUBWUBJDHHKSWUBWUBWUBDTSUYSJHWUBWUBWUBPXFWUBMOHNJWUBWUBWUBZFXVMDWUBWUBWUBZMWUBWUB\r\n", "output": ["XEMWWVUHLSUUGR A XEGILZUNK JDHHKS DTSUYSJH PXF MOHNJ ZFXVMD ZM", "XEMWWVUHLSUUGR A XEGILZUNK JDHHKS DTSUYSJH PXF MOHNJ ZFXVMD ZM"]}, {"input": "BMBWUBWUBWUBOQKWUBWUBWUBPITCIHXHCKLRQRUGXJWUBWUBWUBVWUBWUBWUBJCWUBWUBWUBQJPWUBWUBWUBBWUBWUBWUBBMYGIZOOXWUBWUBWUBTAGWUBWUBHWUB\r\n", "output": ["BMB OQK PITCIHXHCKLRQRUGXJ V JC QJP B BMYGIZOOX TAG H", "BMB OQK PITCIHXHCKLRQRUGXJ V JC QJP B BMYGIZOOX TAG H"]}, {"input": "CBZNWUBWUBWUBNHWUBWUBWUBYQSYWUBWUBWUBMWUBWUBWUBXRHBTMWUBWUBWUBPCRCWUBWUBWUBTZUYLYOWUBWUBWUBCYGCWUBWUBWUBCLJWUBWUBWUBSWUBWUBWUB\r\n", "output": ["CBZN NH YQSY M XRHBTM PCRC TZUYLYO CYGC CLJ S", "CBZN NH YQSY M XRHBTM PCRC TZUYLYO CYGC CLJ S"]}, {"input": "DPDWUBWUBWUBEUQKWPUHLTLNXHAEKGWUBRRFYCAYZFJDCJLXBAWUBWUBWUBHJWUBOJWUBWUBWUBNHBJEYFWUBWUBWUBRWUBWUBWUBSWUBWWUBWUBWUBXDWUBWUBWUBJWUB\r\n", "output": ["DPD EUQKWPUHLTLNXHAEKG RRFYCAYZFJDCJLXBA HJ OJ NHBJEYF R S W XD J", "DPD EUQKWPUHLTLNXHAEKG RRFYCAYZFJDCJLXBA HJ OJ NHBJEYF R S W XD J"]}, {"input": "WUBWUBWUBISERPQITVIYERSCNWUBWUBWUBQWUBWUBWUBDGSDIPWUBWUBWUBCAHKDZWEXBIBJVVSKKVQJWUBWUBWUBKIWUBWUBWUBCWUBWUBWUBAWUBWUBWUBPWUBWUBWUBHWUBWUBWUBF\r\n", "output": ["ISERPQITVIYERSCN Q DGSDIP CAHKDZWEXBIBJVVSKKVQJ KI C A P H F", "ISERPQITVIYERSCN Q DGSDIP CAHKDZWEXBIBJVVSKKVQJ KI C A P H F"]}, {"input": "WUBWUBWUBIWUBWUBLIKNQVWUBWUBWUBPWUBWUBWUBHWUBWUBWUBMWUBWUBWUBDPRSWUBWUBWUBBSAGYLQEENWXXVWUBWUBWUBXMHOWUBWUBWUBUWUBWUBWUBYRYWUBWUBWUBCWUBWUBWUBY\r\n", "output": ["I LIKNQV P H M DPRS BSAGYLQEENWXXV XMHO U YRY C Y", "I LIKNQV P H M DPRS BSAGYLQEENWXXV XMHO U YRY C Y"]}, {"input": "WUBWUBWUBMWUBWUBWUBQWUBWUBWUBITCFEYEWUBWUBWUBHEUWGNDFNZGWKLJWUBWUBWUBMZPWUBWUBWUBUWUBWUBWUBBWUBWUBWUBDTJWUBHZVIWUBWUBWUBPWUBFNHHWUBWUBWUBVTOWUB\r\n", "output": ["M Q ITCFEYE HEUWGNDFNZGWKLJ MZP U B DTJ HZVI P FNHH VTO", "M Q ITCFEYE HEUWGNDFNZGWKLJ MZP U B DTJ HZVI P FNHH VTO"]}, {"input": "WUBWUBNDNRFHYJAAUULLHRRDEDHYFSRXJWUBWUBWUBMUJVDTIRSGYZAVWKRGIFWUBWUBWUBHMZWUBWUBWUBVAIWUBWUBWUBDDKJXPZRGWUBWUBWUBSGXWUBWUBWUBIFKWUBWUBWUBUWUBWUBWUBW\r\n", "output": ["NDNRFHYJAAUULLHRRDEDHYFSRXJ MUJVDTIRSGYZAVWKRGIF HMZ VAI DDKJXPZRG SGX IFK U W", "NDNRFHYJAAUULLHRRDEDHYFSRXJ MUJVDTIRSGYZAVWKRGIF HMZ VAI DDKJXPZRG SGX IFK U W"]}, {"input": "WUBOJMWRSLAXXHQRTPMJNCMPGWUBWUBWUBNYGMZIXNLAKSQYWDWUBWUBWUBXNIWUBWUBWUBFWUBWUBWUBXMBWUBWUBWUBIWUBWUBWUBINWUBWUBWUBWDWUBWUBWUBDDWUBWUBWUBD\r\n", "output": ["OJMWRSLAXXHQRTPMJNCMPG NYGMZIXNLAKSQYWD XNI F XMB I IN WD DD D", "OJMWRSLAXXHQRTPMJNCMPG NYGMZIXNLAKSQYWD XNI F XMB I IN WD DD D"]}, {"input": "WUBWUBWUBREHMWUBWUBWUBXWUBWUBWUBQASNWUBWUBWUBNLSMHLCMTICWUBWUBWUBVAWUBWUBWUBHNWUBWUBWUBNWUBWUBWUBUEXLSFOEULBWUBWUBWUBXWUBWUBWUBJWUBWUBWUBQWUBWUBWUBAWUBWUB\r\n", "output": ["REHM X QASN NLSMHLCMTIC VA HN N UEXLSFOEULB X J Q A", "REHM X QASN NLSMHLCMTIC VA HN N UEXLSFOEULB X J Q A"]}, {"input": "WUBWUBWUBSTEZTZEFFIWUBWUBWUBSWUBWUBWUBCWUBFWUBHRJPVWUBWUBWUBDYJUWUBWUBWUBPWYDKCWUBWUBWUBCWUBWUBWUBUUEOGCVHHBWUBWUBWUBEXLWUBWUBWUBVCYWUBWUBWUBMWUBWUBWUBYWUB\r\n", "output": ["STEZTZEFFI S C F HRJPV DYJU PWYDKC C UUEOGCVHHB EXL VCY M Y", "STEZTZEFFI S C F HRJPV DYJU PWYDKC C UUEOGCVHHB EXL VCY M Y"]}, {"input": "WPPNMSQOQIWUBWUBWUBPNQXWUBWUBWUBHWUBWUBWUBNFLWUBWUBWUBGWSGAHVJFNUWUBWUBWUBFWUBWUBWUBWCMLRICFSCQQQTNBWUBWUBWUBSWUBWUBWUBKGWUBWUBWUBCWUBWUBWUBBMWUBWUBWUBRWUBWUB\r\n", "output": ["WPPNMSQOQI PNQX H NFL GWSGAHVJFNU F WCMLRICFSCQQQTNB S KG C BM R", "WPPNMSQOQI PNQX H NFL GWSGAHVJFNU F WCMLRICFSCQQQTNB S KG C BM R"]}, {"input": "YZJOOYITZRARKVFYWUBWUBRZQGWUBWUBWUBUOQWUBWUBWUBIWUBWUBWUBNKVDTBOLETKZISTWUBWUBWUBWLWUBQQFMMGSONZMAWUBZWUBWUBWUBQZUXGCWUBWUBWUBIRZWUBWUBWUBLTTVTLCWUBWUBWUBY\r\n", "output": ["YZJOOYITZRARKVFY RZQG UOQ I NKVDTBOLETKZIST WL QQFMMGSONZMA Z QZUXGC IRZ LTTVTLC Y", "YZJOOYITZRARKVFY RZQG UOQ I NKVDTBOLETKZIST WL QQFMMGSONZMA Z QZUXGC IRZ LTTVTLC Y"]}, {"input": "WUBCAXNCKFBVZLGCBWCOAWVWOFKZVQYLVTWUBWUBWUBNLGWUBWUBWUBAMGDZBDHZMRMQMDLIRMIWUBWUBWUBGAJSHTBSWUBWUBWUBCXWUBWUBWUBYWUBZLXAWWUBWUBWUBOHWUBWUBWUBZWUBWUBWUBGBWUBWUBWUBE\r\n", "output": ["CAXNCKFBVZLGCBWCOAWVWOFKZVQYLVT NLG AMGDZBDHZMRMQMDLIRMI GAJSHTBS CX Y ZLXAW OH Z GB E", "CAXNCKFBVZLGCBWCOAWVWOFKZVQYLVT NLG AMGDZBDHZMRMQMDLIRMI GAJSHTBS CX Y ZLXAW OH Z GB E"]}, {"input": "WUBWUBCHXSOWTSQWUBWUBWUBCYUZBPBWUBWUBWUBSGWUBWUBWKWORLRRLQYUUFDNWUBWUBWUBYYGOJNEVEMWUBWUBWUBRWUBWUBWUBQWUBWUBWUBIHCKWUBWUBWUBKTWUBWUBWUBRGSNTGGWUBWUBWUBXCXWUBWUBWUBS\r\n", "output": ["CHXSOWTSQ CYUZBPB SG WKWORLRRLQYUUFDN YYGOJNEVEM R Q IHCK KT RGSNTGG XCX S", "CHXSOWTSQ CYUZBPB SG WKWORLRRLQYUUFDN YYGOJNEVEM R Q IHCK KT RGSNTGG XCX S"]}, {"input": "WUBWUBWUBHJHMSBURXTHXWSCHNAIJOWBHLZGJZDHEDSPWBWACCGQWUBWUBWUBXTZKGIITWUBWUBWUBAWUBWUBWUBVNCXPUBCQWUBWUBWUBIDPNAWUBWUBWUBOWUBWUBWUBYGFWUBWUBWUBMQOWUBWUBWUBKWUBWUBWUBAZVWUBWUBWUBEP\r\n", "output": ["HJHMSBURXTHXWSCHNAIJOWBHLZGJZDHEDSPWBWACCGQ XTZKGIIT A VNCXPUBCQ IDPNA O YGF MQO K AZV EP", "HJHMSBURXTHXWSCHNAIJOWBHLZGJZDHEDSPWBWACCGQ XTZKGIIT A VNCXPUBCQ IDPNA O YGF MQO K AZV EP"]}, {"input": "WUBKYDZOYWZSNGMKJSWAXFDFLTHDHEOGTDBNZMSMKZTVWUBWUBWUBLRMIIWUBWUBWUBGWUBWUBWUBADPSWUBWUBWUBANBWUBWUBPCWUBWUBWUBPWUBWUBWUBGPVNLSWIRFORYGAABUXMWUBWUBWUBOWUBWUBWUBNWUBWUBWUBYWUBWUB\r\n", "output": ["KYDZOYWZSNGMKJSWAXFDFLTHDHEOGTDBNZMSMKZTV LRMII G ADPS ANB PC P GPVNLSWIRFORYGAABUXM O N Y", "KYDZOYWZSNGMKJSWAXFDFLTHDHEOGTDBNZMSMKZTV LRMII G ADPS ANB PC P GPVNLSWIRFORYGAABUXM O N Y"]}, {"input": "REWUBWUBWUBJDWUBWUBWUBNWUBWUBWUBTWWUBWUBWUBWZDOCKKWUBWUBWUBLDPOVBFRCFWUBWUBAKZIBQKEUAZEEWUBWUBWUBLQYPNPFWUBYEWUBWUBWUBFWUBWUBWUBBPWUBWUBWUBAWWUBWUBWUBQWUBWUBWUBBRWUBWUBWUBXJL\r\n", "output": ["RE JD N TW WZDOCKK LDPOVBFRCF AKZIBQKEUAZEE LQYPNPF YE F BP AW Q BR XJL", "RE JD N TW WZDOCKK LDPOVBFRCF AKZIBQKEUAZEE LQYPNPF YE F BP AW Q BR XJL"]}, {"input": "CUFGJDXGMWUBWUBWUBOMWUBWUBWUBSIEWUBWUBWUBJJWKNOWUBWUBWUBYBHVNRNORGYWUBWUBWUBOAGCAWUBWUBWUBSBLBKTPFKPBIWUBWUBWUBJBWUBWUBWUBRMFCJPGWUBWUBWUBDWUBWUBWUBOJOWUBWUBWUBZPWUBWUBWUBMWUBRWUBWUBWUBFXWWUBWUBWUBO\r\n", "output": ["CUFGJDXGM OM SIE JJWKNO YBHVNRNORGY OAGCA SBLBKTPFKPBI JB RMFCJPG D OJO ZP M R FXW O", "CUFGJDXGM OM SIE JJWKNO YBHVNRNORGY OAGCA SBLBKTPFKPBI JB RMFCJPG D OJO ZP M R FXW O"]}, {"input": "WUBJZGAEXFMFEWMAKGQLUWUBWUBWUBICYTPQWGENELVYWANKUOJYWUBWUBWUBGWUBWUBWUBHYCJVLPHTUPNEGKCDGQWUBWUBWUBOFWUBWUBWUBCPGSOGZBRPRPVJJEWUBWUBWUBDQBCWUBWUBWUBHWUBWUBWUBMHOHYBMATWUBWUBWUBVWUBWUBWUBSWUBWUBWUBKOWU\r\n", "output": ["JZGAEXFMFEWMAKGQLU ICYTPQWGENELVYWANKUOJY G HYCJVLPHTUPNEGKCDGQ OF CPGSOGZBRPRPVJJE DQBC H MHOHYBMAT V S KOWU", "JZGAEXFMFEWMAKGQLU ICYTPQWGENELVYWANKUOJY G HYCJVLPHTUPNEGKCDGQ OF CPGSOGZBRPRPVJJE DQBC H MHOHYBMAT V S KOWU"]}, {"input": "A\r\n", "output": ["A"]}, {"input": "WUBA\r\n", "output": ["A"]}, {"input": "WUBWUBA\r\n", "output": ["A"]}, {"input": "AWUBWUBWUB\r\n", "output": ["A"]}, {"input": "AWUBBWUBCWUBD\r\n", "output": ["A B C D"]}, {"input": "WUBWWUBWUBWUBUWUBWUBBWUB\r\n", "output": ["W U B", "W U B"]}, {"input": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n", "output": ["AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"]}, {"input": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWUBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n", "output": ["AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"]}, {"input": "WUWUBBWWUBUB\r\n", "output": ["WU BW UB"]}, {"input": "WUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUABWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUB\r\n", "output": ["WUAB"]}, {"input": "ZWUB\r\n", "output": ["Z"]}, {"input": "WU\r\n", "output": ["WU"]}, {"input": "UB\r\n", "output": ["UB"]}, {"input": "U\r\n", "output": ["U"]}, {"input": "WUBW\r\n", "output": ["W"]}, {"input": "WUBWU\r\n", "output": ["WU"]}, {"input": "WUWUB\r\n", "output": ["WU"]}, {"input": "UBWUB\r\n", "output": ["UB"]}, {"input": "WUWUBUBWUBUWUB\r\n", "output": ["WU UB U"]}, {"input": "WUBWWUBAWUB\r\n", "output": ["W A"]}, {"input": "WUUUUU\r\n", "output": ["WUUUUU"]}]
100
100
100
[{'input': 'WUBWUBZBKOKHQLGKRVIMZQMQNRWUBWUBWUBDACWUBWUBNZHFJMPEYKRVSWUBWUBWUBPPHGAVVPRZWUBWUBWUBQWUBWUBAWUBG\r\n', 'output': ['ZBKOKHQLGKRVIMZQMQNR DAC NZHFJMPEYKRVS PPHGAVVPRZ Q A G', 'ZBKOKHQLGKRVIMZQMQNR DAC NZHFJMPEYKRVS PPHGAVVPRZ Q A G']}, {'input': 'WPPNMSQOQIWUBWUBWUBPNQXWUBWUBWUBHWUBWUBWUBNFLWUBWUBWUBGWSGAHVJFNUWUBWUBWUBFWUBWUBWUBWCMLRICFSCQQQTNBWUBWUBWUBSWUBWUBWUBKGWUBWUBWUBCWUBWUBWUBBMWUBWUBWUBRWUBWUB\r\n', 'output': ['WPPNMSQOQI PNQX H NFL GWSGAHVJFNU F WCMLRICFSCQQQTNB S KG C BM R', 'WPPNMSQOQI PNQX H NFL GWSGAHVJFNU F WCMLRICFSCQQQTNB S KG C BM R']}, {'input': 'WUBWU\r\n', 'output': ['WU']}, {'input': 'BMBWUBWUBWUBOQKWUBWUBWUBPITCIHXHCKLRQRUGXJWUBWUBWUBVWUBWUBWUBJCWUBWUBWUBQJPWUBWUBWUBBWUBWUBWUBBMYGIZOOXWUBWUBWUBTAGWUBWUBHWUB\r\n', 'output': ['BMB OQK PITCIHXHCKLRQRUGXJ V JC QJP B BMYGIZOOX TAG H', 'BMB OQK PITCIHXHCKLRQRUGXJ V JC QJP B BMYGIZOOX TAG H']}, {'input': 'REWUBWUBWUBJDWUBWUBWUBNWUBWUBWUBTWWUBWUBWUBWZDOCKKWUBWUBWUBLDPOVBFRCFWUBWUBAKZIBQKEUAZEEWUBWUBWUBLQYPNPFWUBYEWUBWUBWUBFWUBWUBWUBBPWUBWUBWUBAWWUBWUBWUBQWUBWUBWUBBRWUBWUBWUBXJL\r\n', 'output': ['RE JD N TW WZDOCKK LDPOVBFRCF AKZIBQKEUAZEE LQYPNPF YE F BP AW Q BR XJL', 'RE JD N TW WZDOCKK LDPOVBFRCF AKZIBQKEUAZEE LQYPNPF YE F BP AW Q BR XJL']}]
[{'input': 'WUBWUBWSPLAYSZSAUDSWUBWUBWUBUWUBWUBWUBKRWUBWUBWUBRSOKQMZFIYZQUWUBWUBWUBELSHUWUBWUBWUBUKHWUBWUBWUBQXEUHQWUBWUBWUBBWUBWUBWUBR\r\n', 'output': ['WSPLAYSZSAUDS U KR RSOKQMZFIYZQU ELSHU UKH QXEUHQ B R', 'WSPLAYSZSAUDS U KR RSOKQMZFIYZQU ELSHU UKH QXEUHQ B R']}, {'input': 'TOWUBWUBWUBGBTBNWUBWUBWUBJVIOJBIZFUUYHUAIEBQLQXPQKZJMPTCWBKPOSAWUBWUBWUBSWUBWUBWUBTOLVXWUBWUBWUBNHWUBWUBWUBO\r\n', 'output': ['TO GBTBN JVIOJBIZFUUYHUAIEBQLQXPQKZJMPTCWBKPOSA S TOLVX NH O', 'TO GBTBN JVIOJBIZFUUYHUAIEBQLQXPQKZJMPTCWBKPOSA S TOLVX NH O']}, {'input': 'WUBW\r\n', 'output': ['W']}, {'input': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWUBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n', 'output': ['AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA']}, {'input': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n', 'output': ['AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA']}]
[{'input': 'WUBWUBWUBSR\r\n', 'output': ['SR']}, {'input': 'WUWUBUBWUBUWUB\r\n', 'output': ['WU UB U']}, {'input': 'WUBXEMWWVUHLSUUGRWUBWUBWUBAWUBXEGILZUNKWUBWUBWUBJDHHKSWUBWUBWUBDTSUYSJHWUBWUBWUBPXFWUBMOHNJWUBWUBWUBZFXVMDWUBWUBWUBZMWUBWUB\r\n', 'output': ['XEMWWVUHLSUUGR A XEGILZUNK JDHHKS DTSUYSJH PXF MOHNJ ZFXVMD ZM', 'XEMWWVUHLSUUGR A XEGILZUNK JDHHKS DTSUYSJH PXF MOHNJ ZFXVMD ZM']}, {'input': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n', 'output': ['AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA']}, {'input': 'ZWUB\r\n', 'output': ['Z']}]
[{'input': 'QWUBQQWUBWUBWUBIWUBWUBWWWUBWUBWUBJOPJPBRH\r\n', 'output': ['Q QQ I WW JOPJPBRH', 'Q QQ I WW JOPJPBRH']}, {'input': 'ZJWUBWUBWUBJWUBWUBWUBL\r\n', 'output': ['ZJ J L', 'ZJ J L']}, {'input': 'WUBWUBEWUBWUBWUBIQMJNIQWUBWUBWUBGZZBQZAUHYPWUBWUBWUBPMRWUBWUBWUBDCV\r\n', 'output': ['E IQMJNIQ GZZBQZAUHYP PMR DCV', 'E IQMJNIQ GZZBQZAUHYP PMR DCV']}, {'input': 'WUBWUBYGPYEYBNRTFKOQCWUBWUBWUBUYGRTQEGWLFYWUBWUBWUBFVWUBHPWUBWUBWUBXZQWUBWUBWUBZDWUBWUBWUBM\r\n', 'output': ['YGPYEYBNRTFKOQC UYGRTQEGWLFY FV HP XZQ ZD M', 'YGPYEYBNRTFKOQC UYGRTQEGWLFY FV HP XZQ ZD M']}, {'input': 'WUBWUBJWUBWUBWUBNFLWUBWUBWUBGECAWUBYFKBYJWTGBYHVSSNTINKWSINWSMAWUBWUBWUBFWUBWUBWUBOVWUBWUBLPWUBWUBWUBN\r\n', 'output': ['J NFL GECA YFKBYJWTGBYHVSSNTINKWSINWSMA F OV LP N', 'J NFL GECA YFKBYJWTGBYHVSSNTINKWSINWSMA F OV LP N']}]
[{'input': 'WU\r\n', 'output': ['WU']}, {'input': 'WUBWUBWUBIWUBWUBLIKNQVWUBWUBWUBPWUBWUBWUBHWUBWUBWUBMWUBWUBWUBDPRSWUBWUBWUBBSAGYLQEENWXXVWUBWUBWUBXMHOWUBWUBWUBUWUBWUBWUBYRYWUBWUBWUBCWUBWUBWUBY\r\n', 'output': ['I LIKNQV P H M DPRS BSAGYLQEENWXXV XMHO U YRY C Y', 'I LIKNQV P H M DPRS BSAGYLQEENWXXV XMHO U YRY C Y']}, {'input': 'WUBWUBWUBFBQWUBWUBWUBIDFSYWUBWUBWUBCTWDMWUBWUBWUBSXOWUBWUBWUBQIWUBWUBWUBL\r\n', 'output': ['FBQ IDFSY CTWDM SXO QI L', 'FBQ IDFSY CTWDM SXO QI L']}, {'input': 'QWUBQQWUBWUBWUBIWUBWUBWWWUBWUBWUBJOPJPBRH\r\n', 'output': ['Q QQ I WW JOPJPBRH', 'Q QQ I WW JOPJPBRH']}, {'input': 'WUBWUBYGPYEYBNRTFKOQCWUBWUBWUBUYGRTQEGWLFYWUBWUBWUBFVWUBHPWUBWUBWUBXZQWUBWUBWUBZDWUBWUBWUBM\r\n', 'output': ['YGPYEYBNRTFKOQC UYGRTQEGWLFY FV HP XZQ ZD M', 'YGPYEYBNRTFKOQC UYGRTQEGWLFY FV HP XZQ ZD M']}]
100
100
100
100
100
100
100
100
100
100
90
100
100
90
100
365
100
100
96
["3 7 0", "2 0 1", "1 1 0", "0 0 1"]
The only line contains three integers $$$x$$$, $$$y$$$, $$$z$$$ ($$$0\le x,y,z\le100$$$), corresponding to the number of persons who would upvote, downvote or unknown.
66398694a4a142b4a4e709d059aca0fa
a,b,c=map(int,input().split()) x=a-b if(c>=abs(x) and c!=0): print("?") elif(x==0): print("0") elif(x<0): print("-") else: print("+")
["-", "+", "0", "?"]
Python
NoteIn the first example, Nauuo would definitely get three upvotes and seven downvotes, so the only possible result is "-".In the second example, no matter the person unknown downvotes or upvotes, Nauuo would get more upvotes than downvotes. So the only possible result is "+".In the third example, Nauuo would definitely get one upvote and one downvote, so the only possible result is "0".In the fourth example, if the only one person upvoted, the result would be "+", otherwise, the result would be "-". There are two possible results, so the result is uncertain.
If there is only one possible result, print the result : "+", "-" or "0". Otherwise, print "?" to report that the result is uncertain.
Nauuo is a girl who loves writing comments.One day, she posted a comment on Codeforces, wondering whether she would get upvotes or downvotes.It's known that there were $$$x$$$ persons who would upvote, $$$y$$$ persons who would downvote, and there were also another $$$z$$$ persons who would vote, but you don't know whether they would upvote or downvote. Note that each of the $$$x+y+z$$$ people would vote exactly one time.There are three different results: if there are more people upvote than downvote, the result will be "+"; if there are more people downvote than upvote, the result will be "-"; otherwise the result will be "0".Because of the $$$z$$$ unknown persons, the result may be uncertain (i.e. there are more than one possible results). More formally, the result is uncertain if and only if there exist two different situations of how the $$$z$$$ persons vote, that the results are different in the two situations.Tell Nauuo the result or report that the result is uncertain.
[{"input": "3 7 0\r\n", "output": ["-"]}, {"input": "2 0 1\r\n", "output": ["+"]}, {"input": "1 1 0\r\n", "output": ["0"]}, {"input": "0 0 1\r\n", "output": ["?"]}, {"input": "12 1 11\r\n", "output": ["?"]}, {"input": "22 99 77\r\n", "output": ["?"]}, {"input": "28 99 70\r\n", "output": ["-"]}, {"input": "73 29 43\r\n", "output": ["+"]}, {"input": "100 100 100\r\n", "output": ["?"]}, {"input": "1 0 1\r\n", "output": ["?"]}, {"input": "5 7 1\r\n", "output": ["-"]}, {"input": "13 6 8\r\n", "output": ["?"]}, {"input": "94 37 25\r\n", "output": ["+"]}, {"input": "45 0 44\r\n", "output": ["+"]}, {"input": "62 56 5\r\n", "output": ["+"]}, {"input": "88 88 0\r\n", "output": ["0"]}, {"input": "1 1 1\r\n", "output": ["?"]}, {"input": "0 0 0\r\n", "output": ["0"]}, {"input": "0 100 0\r\n", "output": ["-"]}, {"input": "0 0 100\r\n", "output": ["?"]}, {"input": "100 0 100\r\n", "output": ["?"]}, {"input": "100 100 0\r\n", "output": ["0"]}, {"input": "50 100 50\r\n", "output": ["?"]}, {"input": "100 50 50\r\n", "output": ["?"]}, {"input": "48 100 48\r\n", "output": ["-"]}, {"input": "100 48 48\r\n", "output": ["+"]}, {"input": "0 100 48\r\n", "output": ["-"]}, {"input": "100 0 48\r\n", "output": ["+"]}, {"input": "0 100 99\r\n", "output": ["-"]}, {"input": "100 0 99\r\n", "output": ["+"]}, {"input": "96 55 0\r\n", "output": ["+"]}, {"input": "21 50 0\r\n", "output": ["-"]}, {"input": "86 1 0\r\n", "output": ["+"]}, {"input": "58 58 1\r\n", "output": ["?"]}, {"input": "12 89 2\r\n", "output": ["-"]}, {"input": "34 51 3\r\n", "output": ["-"]}, {"input": "93 21 2\r\n", "output": ["+"]}, {"input": "97 78 2\r\n", "output": ["+"]}, {"input": "19 90 4\r\n", "output": ["-"]}, {"input": "21 52 5\r\n", "output": ["-"]}, {"input": "42 40 4\r\n", "output": ["?"]}, {"input": "58 97 4\r\n", "output": ["-"]}, {"input": "26 92 6\r\n", "output": ["-"]}, {"input": "8 87 7\r\n", "output": ["-"]}, {"input": "49 8 6\r\n", "output": ["+"]}, {"input": "97 64 6\r\n", "output": ["+"]}, {"input": "43 93 9\r\n", "output": ["-"]}, {"input": "21 55 9\r\n", "output": ["-"]}, {"input": "66 27 9\r\n", "output": ["+"]}, {"input": "58 83 8\r\n", "output": ["-"]}, {"input": "52 14 10\r\n", "output": ["+"]}, {"input": "2 87 10\r\n", "output": ["-"]}, {"input": "80 29 11\r\n", "output": ["+"]}, {"input": "92 93 10\r\n", "output": ["?"]}, {"input": "62 63 12\r\n", "output": ["?"]}, {"input": "33 24 13\r\n", "output": ["?"]}, {"input": "79 42 12\r\n", "output": ["+"]}, {"input": "98 82 13\r\n", "output": ["+"]}, {"input": "60 33 15\r\n", "output": ["+"]}, {"input": "37 5 15\r\n", "output": ["+"]}, {"input": "21 31 14\r\n", "output": ["?"]}, {"input": "78 95 14\r\n", "output": ["-"]}, {"input": "2 82 17\r\n", "output": ["-"]}, {"input": "42 43 16\r\n", "output": ["?"]}, {"input": "98 44 17\r\n", "output": ["+"]}, {"input": "82 84 16\r\n", "output": ["?"]}, {"input": "80 63 18\r\n", "output": ["?"]}, {"input": "21 24 18\r\n", "output": ["?"]}, {"input": "97 33 19\r\n", "output": ["+"]}, {"input": "87 98 19\r\n", "output": ["?"]}, {"input": "99 20 7\r\n", "output": ["+"]}, {"input": "47 78 6\r\n", "output": ["-"]}, {"input": "47 40 10\r\n", "output": ["?"]}, {"input": "96 71 19\r\n", "output": ["+"]}, {"input": "25 35 23\r\n", "output": ["?"]}, {"input": "36 3 35\r\n", "output": ["?"]}, {"input": "74 2 16\r\n", "output": ["+"]}, {"input": "58 83 39\r\n", "output": ["?"]}, {"input": "40 51 11\r\n", "output": ["?"]}, {"input": "0 87 13\r\n", "output": ["-"]}, {"input": "89 41 36\r\n", "output": ["+"]}, {"input": "97 71 36\r\n", "output": ["?"]}, {"input": "34 44 21\r\n", "output": ["?"]}, {"input": "13 1 13\r\n", "output": ["?"]}, {"input": "83 3 8\r\n", "output": ["+"]}, {"input": "60 60 32\r\n", "output": ["?"]}, {"input": "25 39 32\r\n", "output": ["?"]}, {"input": "46 1 89\r\n", "output": ["?"]}, {"input": "43 9 61\r\n", "output": ["?"]}, {"input": "82 98 93\r\n", "output": ["?"]}, {"input": "2 2 1\r\n", "output": ["?"]}, {"input": "10 5 6\r\n", "output": ["?"]}, {"input": "9 8 2\r\n", "output": ["?"]}, {"input": "5 3 3\r\n", "output": ["?"]}, {"input": "8 5 5\r\n", "output": ["?"]}, {"input": "5 3 2\r\n", "output": ["?"]}, {"input": "1 50 50\r\n", "output": ["?"]}, {"input": "3 2 3\r\n", "output": ["?"]}, {"input": "1 3 4\r\n", "output": ["?"]}, {"input": "1 2 2\r\n", "output": ["?"]}, {"input": "7 4 3\r\n", "output": ["?"]}, {"input": "7 3 5\r\n", "output": ["?"]}, {"input": "5 1 6\r\n", "output": ["?"]}, {"input": "3 4 5\r\n", "output": ["?"]}, {"input": "25 12 100\r\n", "output": ["?"]}, {"input": "3 3 2\r\n", "output": ["?"]}, {"input": "5 2 10\r\n", "output": ["?"]}, {"input": "7 4 4\r\n", "output": ["?"]}, {"input": "4 3 1\r\n", "output": ["?"]}, {"input": "5 5 3\r\n", "output": ["?"]}, {"input": "2 1 3\r\n", "output": ["?"]}, {"input": "1 2 7\r\n", "output": ["?"]}, {"input": "6 5 4\r\n", "output": ["?"]}, {"input": "15 4 15\r\n", "output": ["?"]}]
100
100
100
[{'input': '7 4 3\r\n', 'output': ['?']}, {'input': '0 0 100\r\n', 'output': ['?']}, {'input': '2 0 1\r\n', 'output': ['+']}, {'input': '89 41 36\r\n', 'output': ['+']}, {'input': '52 14 10\r\n', 'output': ['+']}]
[{'input': '96 71 19\r\n', 'output': ['+']}, {'input': '100 100 100\r\n', 'output': ['?']}, {'input': '62 63 12\r\n', 'output': ['?']}, {'input': '42 43 16\r\n', 'output': ['?']}, {'input': '28 99 70\r\n', 'output': ['-']}]
[{'input': '0 0 0\r\n', 'output': ['0']}, {'input': '19 90 4\r\n', 'output': ['-']}, {'input': '78 95 14\r\n', 'output': ['-']}, {'input': '58 97 4\r\n', 'output': ['-']}, {'input': '60 33 15\r\n', 'output': ['+']}]
[{'input': '8 87 7\r\n', 'output': ['-']}, {'input': '5 3 2\r\n', 'output': ['?']}, {'input': '3 4 5\r\n', 'output': ['?']}, {'input': '12 1 11\r\n', 'output': ['?']}, {'input': '58 83 39\r\n', 'output': ['?']}]
[{'input': '74 2 16\r\n', 'output': ['+']}, {'input': '0 0 1\r\n', 'output': ['?']}, {'input': '100 48 48\r\n', 'output': ['+']}, {'input': '28 99 70\r\n', 'output': ['-']}, {'input': '82 84 16\r\n', 'output': ['?']}]
100
100
100
100
100
77.78
88.89
88.89
77.78
88.89
66.67
83.33
83.33
66.67
83.33
366
100
84.446
76.666
["6\n1 5\n2 6\n3 7", "10\n1 2\n1 3\n1 5", "6\n1 3\n2 2\n2 2"]
The first line of the input contains a single integer n (3 ≀ n ≀ 3Β·106)Β β€”Β the number of schoolchildren who will participate in the Olympiad. The next line of the input contains two integers min1 and max1 (1 ≀ min1 ≀ max1 ≀ 106)Β β€”Β the minimum and maximum limits on the number of diplomas of the first degree that can be distributed. The third line of the input contains two integers min2 and max2 (1 ≀ min2 ≀ max2 ≀ 106)Β β€”Β the minimum and maximum limits on the number of diplomas of the second degree that can be distributed. The next line of the input contains two integers min3 and max3 (1 ≀ min3 ≀ max3 ≀ 106)Β β€”Β the minimum and maximum limits on the number of diplomas of the third degree that can be distributed. It is guaranteed that min1 + min2 + min3 ≀ n ≀ max1 + max2 + max3.
3cd092b6507079518cf206deab21cf97
n=int(input()) a=[None]*3 a[0]=list(map(int,input().split())) a[1]=list(map(int,input().split())) a[2]=list(map(int,input().split())) total=0 b=[None]*3 for i in range(3): total+=a[i][0] b[i]=a[i][0] while total<n: if b[0]<a[0][1]: k=a[0][1]-b[0] if total+k>n: b[0]+=(n-total) total=n else: b[0]+=k total+=k if b[1]<a[1][1]: k=a[1][1]-b[1] if total+k>n: b[1]+=(n-total) total=n else: b[1]+=k total+=k if b[2]<a[2][1]: k=a[2][1]-b[2] if total+k>n: b[2]+=(n-total) total=n else: b[2]+=k total+=k print(b[0],b[1],b[2])
["1 2 3", "2 3 5", "2 2 2"]
Python
null
In the first line of the output print three numbers, showing how many diplomas of the first, second and third degree will be given to students in the optimal variant of distributing diplomas. The optimal variant of distributing diplomas is the one that maximizes the number of students who receive diplomas of the first degree. Of all the suitable options, the best one is the one which maximizes the number of participants who receive diplomas of the second degree. If there are several of these options, the best one is the one that maximizes the number of diplomas of the third degree.
Soon a school Olympiad in Informatics will be held in Berland, n schoolchildren will participate there.At a meeting of the jury of the Olympiad it was decided that each of the n participants, depending on the results, will get a diploma of the first, second or third degree. Thus, each student will receive exactly one diploma.They also decided that there must be given at least min1 and at most max1 diplomas of the first degree, at least min2 and at most max2 diplomas of the second degree, and at least min3 and at most max3 diplomas of the third degree.After some discussion it was decided to choose from all the options of distributing diplomas satisfying these limitations the one that maximizes the number of participants who receive diplomas of the first degree. Of all these options they select the one which maximizes the number of the participants who receive diplomas of the second degree. If there are multiple of these options, they select the option that maximizes the number of diplomas of the third degree.Choosing the best option of distributing certificates was entrusted to Ilya, one of the best programmers of Berland. However, he found more important things to do, so it is your task now to choose the best option of distributing of diplomas, based on the described limitations.It is guaranteed that the described limitations are such that there is a way to choose such an option of distributing diplomas that all n participants of the Olympiad will receive a diploma of some degree.
[{"input": "6\r\n1 5\r\n2 6\r\n3 7\r\n", "output": ["1 2 3"]}, {"input": "10\r\n1 2\r\n1 3\r\n1 5\r\n", "output": ["2 3 5"]}, {"input": "6\r\n1 3\r\n2 2\r\n2 2\r\n", "output": ["2 2 2"]}, {"input": "55\r\n1 1000000\r\n40 50\r\n10 200\r\n", "output": ["5 40 10"]}, {"input": "3\r\n1 1\r\n1 1\r\n1 1\r\n", "output": ["1 1 1"]}, {"input": "3\r\n1 1000000\r\n1 1000000\r\n1 1000000\r\n", "output": ["1 1 1"]}, {"input": "1000\r\n100 400\r\n300 500\r\n400 1200\r\n", "output": ["300 300 400"]}, {"input": "3000000\r\n1 1000000\r\n1 1000000\r\n1 1000000\r\n", "output": ["1000000 1000000 1000000"]}, {"input": "11\r\n3 5\r\n3 5\r\n3 5\r\n", "output": ["5 3 3"]}, {"input": "12\r\n3 5\r\n3 5\r\n3 5\r\n", "output": ["5 4 3"]}, {"input": "13\r\n3 5\r\n3 5\r\n3 5\r\n", "output": ["5 5 3"]}, {"input": "3000000\r\n1000000 1000000\r\n1000000 1000000\r\n1000000 1000000\r\n", "output": ["1000000 1000000 1000000"]}, {"input": "50\r\n1 100\r\n1 100\r\n1 100\r\n", "output": ["48 1 1"]}, {"input": "1279\r\n123 670\r\n237 614\r\n846 923\r\n", "output": ["196 237 846"]}, {"input": "1589\r\n213 861\r\n5 96\r\n506 634\r\n", "output": ["861 96 632"]}, {"input": "2115\r\n987 987\r\n112 483\r\n437 959\r\n", "output": ["987 483 645"]}, {"input": "641\r\n251 960\r\n34 370\r\n149 149\r\n", "output": ["458 34 149"]}, {"input": "1655\r\n539 539\r\n10 425\r\n605 895\r\n", "output": ["539 425 691"]}, {"input": "1477\r\n210 336\r\n410 837\r\n448 878\r\n", "output": ["336 693 448"]}, {"input": "1707\r\n149 914\r\n190 422\r\n898 899\r\n", "output": ["619 190 898"]}, {"input": "1529\r\n515 515\r\n563 869\r\n169 451\r\n", "output": ["515 845 169"]}, {"input": "1543\r\n361 994\r\n305 407\r\n102 197\r\n", "output": ["994 407 142"]}, {"input": "1107\r\n471 849\r\n360 741\r\n71 473\r\n", "output": ["676 360 71"]}, {"input": "1629279\r\n267360 999930\r\n183077 674527\r\n202618 786988\r\n", "output": ["999930 426731 202618"]}, {"input": "1233589\r\n2850 555444\r\n500608 921442\r\n208610 607343\r\n", "output": ["524371 500608 208610"]}, {"input": "679115\r\n112687 183628\r\n101770 982823\r\n81226 781340\r\n", "output": ["183628 414261 81226"]}, {"input": "1124641\r\n117999 854291\r\n770798 868290\r\n76651 831405\r\n", "output": ["277192 770798 76651"]}, {"input": "761655\r\n88152 620061\r\n60403 688549\r\n79370 125321\r\n", "output": ["620061 62224 79370"]}, {"input": "2174477\r\n276494 476134\r\n555283 954809\r\n319941 935631\r\n", "output": ["476134 954809 743534"]}, {"input": "1652707\r\n201202 990776\r\n34796 883866\r\n162979 983308\r\n", "output": ["990776 498952 162979"]}, {"input": "2065529\r\n43217 891429\r\n434379 952871\r\n650231 855105\r\n", "output": ["891429 523869 650231"]}, {"input": "1702543\r\n405042 832833\r\n50931 747750\r\n381818 796831\r\n", "output": ["832833 487892 381818"]}, {"input": "501107\r\n19061 859924\r\n126478 724552\r\n224611 489718\r\n", "output": ["150018 126478 224611"]}, {"input": "1629279\r\n850831 967352\r\n78593 463906\r\n452094 885430\r\n", "output": ["967352 209833 452094"]}, {"input": "1233589\r\n2850 157021\r\n535109 748096\r\n392212 475634\r\n", "output": ["157021 684356 392212"]}, {"input": "679115\r\n125987 786267\r\n70261 688983\r\n178133 976789\r\n", "output": ["430721 70261 178133"]}, {"input": "1124641\r\n119407 734250\r\n213706 860770\r\n102149 102149\r\n", "output": ["734250 288242 102149"]}, {"input": "761655\r\n325539 325539\r\n280794 792505\r\n18540 106895\r\n", "output": ["325539 417576 18540"]}, {"input": "2174477\r\n352351 791072\r\n365110 969163\r\n887448 955610\r\n", "output": ["791072 495957 887448"]}, {"input": "1652707\r\n266774 638522\r\n65688 235422\r\n924898 992826\r\n", "output": ["638522 89287 924898"]}, {"input": "2065529\r\n608515 608515\r\n751563 864337\r\n614898 705451\r\n", "output": ["608515 842116 614898"]}, {"input": "1702543\r\n5784 996578\r\n47395 300407\r\n151614 710197\r\n", "output": ["996578 300407 405558"]}, {"input": "501107\r\n8073 390048\r\n190494 647328\r\n274071 376923\r\n", "output": ["36542 190494 274071"]}, {"input": "200\r\n50 50\r\n100 100\r\n50 50\r\n", "output": ["50 100 50"]}, {"input": "14\r\n1 100\r\n1 100\r\n8 9\r\n", "output": ["5 1 8"]}, {"input": "300\r\n200 400\r\n50 100\r\n40 80\r\n", "output": ["210 50 40"]}, {"input": "10\r\n3 6\r\n3 6\r\n3 6\r\n", "output": ["4 3 3"]}, {"input": "14\r\n3 6\r\n3 6\r\n3 6\r\n", "output": ["6 5 3"]}, {"input": "17\r\n3 6\r\n3 6\r\n3 6\r\n", "output": ["6 6 5"]}, {"input": "1000000\r\n300000 600000\r\n300000 600000\r\n300000 600000\r\n", "output": ["400000 300000 300000"]}, {"input": "1400000\r\n300000 600000\r\n300000 600000\r\n300000 600000\r\n", "output": ["600000 500000 300000"]}, {"input": "1700000\r\n300000 600000\r\n300000 600000\r\n300000 600000\r\n", "output": ["600000 600000 500000"]}, {"input": "561\r\n400 400\r\n80 80\r\n81 81\r\n", "output": ["400 80 81"]}, {"input": "2000\r\n100 1000\r\n1 1\r\n1 2000\r\n", "output": ["1000 1 999"]}, {"input": "1000002\r\n1 1000000\r\n1 1000000\r\n999999 1000000\r\n", "output": ["2 1 999999"]}, {"input": "1000002\r\n1 1000000\r\n1 1000000\r\n1000000 1000000\r\n", "output": ["1 1 1000000"]}]
100
100
100
[{'input': '300\r\n200 400\r\n50 100\r\n40 80\r\n', 'output': ['210 50 40']}, {'input': '1107\r\n471 849\r\n360 741\r\n71 473\r\n', 'output': ['676 360 71']}, {'input': '1233589\r\n2850 555444\r\n500608 921442\r\n208610 607343\r\n', 'output': ['524371 500608 208610']}, {'input': '1702543\r\n405042 832833\r\n50931 747750\r\n381818 796831\r\n', 'output': ['832833 487892 381818']}, {'input': '1652707\r\n266774 638522\r\n65688 235422\r\n924898 992826\r\n', 'output': ['638522 89287 924898']}]
[{'input': '2065529\r\n43217 891429\r\n434379 952871\r\n650231 855105\r\n', 'output': ['891429 523869 650231']}, {'input': '1000\r\n100 400\r\n300 500\r\n400 1200\r\n', 'output': ['300 300 400']}, {'input': '17\r\n3 6\r\n3 6\r\n3 6\r\n', 'output': ['6 6 5']}, {'input': '1529\r\n515 515\r\n563 869\r\n169 451\r\n', 'output': ['515 845 169']}, {'input': '501107\r\n19061 859924\r\n126478 724552\r\n224611 489718\r\n', 'output': ['150018 126478 224611']}]
[{'input': '1529\r\n515 515\r\n563 869\r\n169 451\r\n', 'output': ['515 845 169']}, {'input': '1702543\r\n405042 832833\r\n50931 747750\r\n381818 796831\r\n', 'output': ['832833 487892 381818']}, {'input': '1652707\r\n266774 638522\r\n65688 235422\r\n924898 992826\r\n', 'output': ['638522 89287 924898']}, {'input': '1700000\r\n300000 600000\r\n300000 600000\r\n300000 600000\r\n', 'output': ['600000 600000 500000']}, {'input': '300\r\n200 400\r\n50 100\r\n40 80\r\n', 'output': ['210 50 40']}]
[{'input': '1655\r\n539 539\r\n10 425\r\n605 895\r\n', 'output': ['539 425 691']}, {'input': '3\r\n1 1000000\r\n1 1000000\r\n1 1000000\r\n', 'output': ['1 1 1']}, {'input': '6\r\n1 5\r\n2 6\r\n3 7\r\n', 'output': ['1 2 3']}, {'input': '761655\r\n88152 620061\r\n60403 688549\r\n79370 125321\r\n', 'output': ['620061 62224 79370']}, {'input': '10\r\n1 2\r\n1 3\r\n1 5\r\n', 'output': ['2 3 5']}]
[{'input': '679115\r\n112687 183628\r\n101770 982823\r\n81226 781340\r\n', 'output': ['183628 414261 81226']}, {'input': '1000000\r\n300000 600000\r\n300000 600000\r\n300000 600000\r\n', 'output': ['400000 300000 300000']}, {'input': '2065529\r\n608515 608515\r\n751563 864337\r\n614898 705451\r\n', 'output': ['608515 842116 614898']}, {'input': '1543\r\n361 994\r\n305 407\r\n102 197\r\n', 'output': ['994 407 142']}, {'input': '2174477\r\n276494 476134\r\n555283 954809\r\n319941 935631\r\n', 'output': ['476134 954809 743534']}]
100
100
100
100
100
87.88
93.94
93.94
93.94
93.94
68.75
81.25
81.25
81.25
81.25
367
100
92.728
78.75
["1 1 10", "1 2 5", "2 3 9"]
The only string contains three integersΒ β€” n, m and z (1 ≀ n, m, z ≀ 104).
e7ad55ce26fc8610639323af1de36c2d
n = list(map(int, input().split())) a = set() b = set() for i in range(n[2]//n[0]): a.add((i+1)*n[0]) for i in range(n[2]//n[1]): b.add((i+1)*n[1]) print(len(a & b))
["10", "2", "1"]
Python
NoteTaymyr is a place in the north of Russia.In the first test the artists come each minute, as well as the calls, so we need to kill all of them.In the second test we need to kill artists which come on the second and the fourth minutes.In the third testΒ β€” only the artist which comes on the sixth minute.
Print single integerΒ β€” the minimum number of artists that should be killed so that there are no artists in the room when Ilia calls.
Comrade Dujikov is busy choosing artists for Timofey's birthday and is recieving calls from Taymyr from Ilia-alpinist.Ilia-alpinist calls every n minutes, i.e. in minutes n, 2n, 3n and so on. Artists come to the comrade every m minutes, i.e. in minutes m, 2m, 3m and so on. The day is z minutes long, i.e. the day consists of minutes 1, 2, ..., z. How many artists should be killed so that there are no artists in the room when Ilia calls? Consider that a call and a talk with an artist take exactly one minute.
[{"input": "1 1 10\r\n", "output": ["10"]}, {"input": "1 2 5\r\n", "output": ["2"]}, {"input": "2 3 9\r\n", "output": ["1"]}, {"input": "4 8 9\r\n", "output": ["1"]}, {"input": "7 9 2\r\n", "output": ["0"]}, {"input": "10000 10000 10000\r\n", "output": ["1"]}, {"input": "24 22 9235\r\n", "output": ["34"]}, {"input": "74 8 417\r\n", "output": ["1"]}, {"input": "972 1 203\r\n", "output": ["0"]}, {"input": "550 1 754\r\n", "output": ["1"]}, {"input": "860 1 884\r\n", "output": ["1"]}, {"input": "358 2 809\r\n", "output": ["2"]}, {"input": "33 27 216\r\n", "output": ["0"]}, {"input": "2940 1 9311\r\n", "output": ["3"]}, {"input": "4624 1 1953\r\n", "output": ["0"]}, {"input": "2696 2 7345\r\n", "output": ["2"]}, {"input": "3443 2 6701\r\n", "output": ["0"]}, {"input": "3 613 2275\r\n", "output": ["1"]}, {"input": "1 10000 10000\r\n", "output": ["1"]}, {"input": "10000 1 10000\r\n", "output": ["1"]}, {"input": "1 1 1\r\n", "output": ["1"]}, {"input": "1 1 10000\r\n", "output": ["10000"]}, {"input": "34 27 10000\r\n", "output": ["10"]}, {"input": "2 2 9999\r\n", "output": ["4999"]}, {"input": "2 2 1\r\n", "output": ["0"]}, {"input": "6 4 36\r\n", "output": ["3"]}, {"input": "33 6 3005\r\n", "output": ["45"]}, {"input": "5 1 20\r\n", "output": ["4"]}, {"input": "1 2 10\r\n", "output": ["5"]}, {"input": "2 1 100\r\n", "output": ["50"]}, {"input": "10 20 10000\r\n", "output": ["500"]}, {"input": "8 12 12\r\n", "output": ["0"]}]
100
100
100
[{'input': '1 1 1\r\n', 'output': ['1']}, {'input': '1 2 5\r\n', 'output': ['2']}, {'input': '2 3 9\r\n', 'output': ['1']}, {'input': '550 1 754\r\n', 'output': ['1']}, {'input': '5 1 20\r\n', 'output': ['4']}]
[{'input': '2940 1 9311\r\n', 'output': ['3']}, {'input': '2 2 9999\r\n', 'output': ['4999']}, {'input': '1 1 1\r\n', 'output': ['1']}, {'input': '1 2 5\r\n', 'output': ['2']}, {'input': '24 22 9235\r\n', 'output': ['34']}]
[{'input': '1 2 5\r\n', 'output': ['2']}, {'input': '6 4 36\r\n', 'output': ['3']}, {'input': '1 1 10\r\n', 'output': ['10']}, {'input': '1 1 10000\r\n', 'output': ['10000']}, {'input': '8 12 12\r\n', 'output': ['0']}]
[{'input': '6 4 36\r\n', 'output': ['3']}, {'input': '4624 1 1953\r\n', 'output': ['0']}, {'input': '358 2 809\r\n', 'output': ['2']}, {'input': '2940 1 9311\r\n', 'output': ['3']}, {'input': '2 3 9\r\n', 'output': ['1']}]
[{'input': '4 8 9\r\n', 'output': ['1']}, {'input': '550 1 754\r\n', 'output': ['1']}, {'input': '10 20 10000\r\n', 'output': ['500']}, {'input': '10000 10000 10000\r\n', 'output': ['1']}, {'input': '1 2 10\r\n', 'output': ['5']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
368
100
100
100
["17 15 5 3", "14 16 7 22", "4 2 6 4", "1000000000000000000 1000000000000000000 999999866000004473 999999822000007597"]
The first line contains four integers $$$a$$$, $$$b$$$, $$$x$$$, $$$y$$$ ($$$1 \le a, b, x, y \le 10^{18}$$$)Β β€” the constraints on the screen width and height, and on the aspect ratio.
907ac56260e84dbb6d98a271bcb2d62d
from math import gcd x, y, a, b = [int(x) for x in input().split()] gc = gcd(a, b) a = a // gc b = b // gc print(min(x//a, y//b))
["3", "0", "1", "1000000063"]
Python
NoteIn the first example, there are $$$3$$$ possible variants: $$$(5, 3)$$$, $$$(10, 6)$$$, $$$(15, 9)$$$.In the second example, there is no TV set meeting the constraints.In the third example, there is only one variant: $$$(3, 2)$$$.
Print one integerΒ β€” the number of different variants to choose TV screen width and screen height so that they meet the aforementioned constraints.
Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than $$$a$$$ and screen height not greater than $$$b$$$. Monocarp is also used to TV sets with a certain aspect ratio: formally, if the width of the screen is $$$w$$$, and the height of the screen is $$$h$$$, then the following condition should be met: $$$\frac{w}{h} = \frac{x}{y}$$$.There are many different TV sets in the shop. Monocarp is sure that for any pair of positive integers $$$w$$$ and $$$h$$$ there is a TV set with screen width $$$w$$$ and height $$$h$$$ in the shop.Monocarp isn't ready to choose the exact TV set he is going to buy. Firstly he wants to determine the optimal screen resolution. He has decided to try all possible variants of screen size. But he must count the number of pairs of positive integers $$$w$$$ and $$$h$$$, beforehand, such that $$$(w \le a)$$$, $$$(h \le b)$$$ and $$$(\frac{w}{h} = \frac{x}{y})$$$.In other words, Monocarp wants to determine the number of TV sets having aspect ratio $$$\frac{x}{y}$$$, screen width not exceeding $$$a$$$, and screen height not exceeding $$$b$$$. Two TV sets are considered different if they have different screen width or different screen height.
[{"input": "17 15 5 3\r\n", "output": ["3"]}, {"input": "14 16 7 22\r\n", "output": ["0"]}, {"input": "4 2 6 4\r\n", "output": ["1"]}, {"input": "1000000000000000000 1000000000000000000 999999866000004473 999999822000007597\r\n", "output": ["1000000063"]}, {"input": "1 1 1 1\r\n", "output": ["1"]}, {"input": "1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000\r\n", "output": ["1000000000000000000"]}, {"input": "3 3 2 4\r\n", "output": ["1"]}, {"input": "3 3 2 6\r\n", "output": ["1"]}, {"input": "1000000000000000000 1000000000 1000000000000000000 1000000000\r\n", "output": ["1000000000"]}, {"input": "58 29 27 60\r\n", "output": ["1"]}, {"input": "27 68 94 30\r\n", "output": ["0"]}, {"input": "144528195586472793 10446456359175098 764897453635731472 213446506570409801\r\n", "output": ["0"]}, {"input": "145354434469588921 446675416227691239 504832165374736218 221558716891006574\r\n", "output": ["0"]}, {"input": "146180677647672345 468138913968516772 6298881766892948 923367383029480585\r\n", "output": ["0"]}, {"input": "147006920825755769 542505368524532032 208073625707521517 14411087792522426\r\n", "output": ["0"]}, {"input": "147833164003839193 978734324098080876 171380370006334775 22523289523184607\r\n", "output": ["0"]}, {"input": "148659402886955322 414963275376662424 30635495548814085 902968491117271450\r\n", "output": ["2"]}, {"input": "149485641770071450 851192235245178565 874621826044152778 488378180096620703\r\n", "output": ["0"]}, {"input": "150311889243122170 287421190818727409 837928574637933332 823487866450329936\r\n", "output": ["0"]}, {"input": "151138128126238298 947022187542019357 577863282081970781 831600068180992118\r\n", "output": ["0"]}, {"input": "925426546533829903 18916656036525111 656064699607651706 504175130621743249\r\n", "output": ["0"]}, {"input": "667266829466 1518201697184 23643010980 898976260568\r\n", "output": ["6"]}, {"input": "66 116 86 64\r\n", "output": ["1"]}, {"input": "1162212930906 1437938729466 2281245858132 1953656377395\r\n", "output": ["1"]}, {"input": "114 6 288 30\r\n", "output": ["1"]}, {"input": "1639979163162 1340495892562 2036036266388 3428977687772\r\n", "output": ["1"]}, {"input": "162 86 200 332\r\n", "output": ["1"]}, {"input": "126335330010 1260232924842 1082265520235 316350257105\r\n", "output": ["0"]}, {"input": "10 182 480 305\r\n", "output": ["0"]}, {"input": "301287041544 1311267722334 1925090137416 582114484904\r\n", "output": ["1"]}, {"input": "165 108 114 184\r\n", "output": ["1"]}, {"input": "1043706193704 1177988368866 2133416547786 1380684288366\r\n", "output": ["2"]}, {"input": "225 276 42 210\r\n", "output": ["55"]}, {"input": "1760355542088 1044709015401 1674331546848 2647835033212\r\n", "output": ["1"]}, {"input": "9 99 272 208\r\n", "output": ["0"]}, {"input": "2489889792360 924314563821 835883336325 4339921938905\r\n", "output": ["1"]}, {"input": "84 231 70 145\r\n", "output": ["6"]}, {"input": "219424042632 791035210353 5273494032066 418290299778\r\n", "output": ["3"]}, {"input": "280 104 158 114\r\n", "output": ["1"]}, {"input": "606209757964 135185624000 1875022910016 905391624870\r\n", "output": ["0"]}, {"input": "360 264 99 117\r\n", "output": ["20"]}, {"input": "1561742222476 104898922608 1477225799720 2031291351072\r\n", "output": ["0"]}, {"input": "72 72 312 64\r\n", "output": ["1"]}, {"input": "2534454556172 3927193117988 589501152415 3547767499745\r\n", "output": ["38"]}, {"input": "168 252 180 450\r\n", "output": ["50"]}, {"input": "3375849775910 3759581410230 1727984390290 1874681381962\r\n", "output": ["3"]}, {"input": "405 55 194 58\r\n", "output": ["1"]}, {"input": "4591740193030 3537449154450 1714308697782 442983863265\r\n", "output": ["8"]}, {"input": "25 260 129 285\r\n", "output": ["0"]}, {"input": "786155773670 3336791735150 1280120052592 1250148696512\r\n", "output": ["9"]}, {"input": "165 500 388 308\r\n", "output": ["1"]}, {"input": "2023521027270 3298933358415 137370252990 2592814018030\r\n", "output": ["12"]}, {"input": "285 245 270 270\r\n", "output": ["245"]}, {"input": "100000 1 3 2\r\n", "output": ["0"]}, {"input": "10000000000000 1 1 10000000000000\r\n", "output": ["0"]}, {"input": "1000000000000000000 1000000000000000000 1 2\r\n", "output": ["500000000000000000"]}, {"input": "4 2 4 3\r\n", "output": ["0"]}, {"input": "100 81 10 9\r\n", "output": ["9"]}, {"input": "1 1 1 1000000000000000000\r\n", "output": ["0"]}, {"input": "1000000000000000000 1000000000000000000 1 1\r\n", "output": ["1000000000000000000"]}, {"input": "1000000000000000000 1000000000000000000 1 1000000000000000000\r\n", "output": ["1"]}, {"input": "1 1 1 100000000000000000\r\n", "output": ["0"]}, {"input": "1000000000000000000 1 1 1\r\n", "output": ["1"]}, {"input": "1000000000000000000 1000000000000000000 1 999999822000007597\r\n", "output": ["1"]}, {"input": "1 1000000000000000000 1 1000000000000000000\r\n", "output": ["1"]}, {"input": "3 60 3 4\r\n", "output": ["1"]}, {"input": "1 1 1000000000000000 1\r\n", "output": ["0"]}, {"input": "2 3 1000000000000000000 1\r\n", "output": ["0"]}, {"input": "20 5 10 7\r\n", "output": ["0"]}, {"input": "5 5 1 1\r\n", "output": ["5"]}, {"input": "1000000000000000000 1000000000000000000 1000000000000000000 11235955056173033\r\n", "output": ["1"]}, {"input": "281474976710656 1 1 281474976710656\r\n", "output": ["0"]}, {"input": "500 500 1000000000000000000 1\r\n", "output": ["0"]}, {"input": "2 2 1000000000000000000 2\r\n", "output": ["0"]}, {"input": "1000000000000000000 1000000000000000000 1000000000000000000 1\r\n", "output": ["1"]}]
100
100
100
[{'input': '3 3 2 6\r\n', 'output': ['1']}, {'input': '162 86 200 332\r\n', 'output': ['1']}, {'input': '1 1 1 100000000000000000\r\n', 'output': ['0']}, {'input': '405 55 194 58\r\n', 'output': ['1']}, {'input': '165 108 114 184\r\n', 'output': ['1']}]
[{'input': '1561742222476 104898922608 1477225799720 2031291351072\r\n', 'output': ['0']}, {'input': '4 2 4 3\r\n', 'output': ['0']}, {'input': '147006920825755769 542505368524532032 208073625707521517 14411087792522426\r\n', 'output': ['0']}, {'input': '1000000000000000000 1000000000000000000 999999866000004473 999999822000007597\r\n', 'output': ['1000000063']}, {'input': '27 68 94 30\r\n', 'output': ['0']}]
[{'input': '72 72 312 64\r\n', 'output': ['1']}, {'input': '20 5 10 7\r\n', 'output': ['0']}, {'input': '2023521027270 3298933358415 137370252990 2592814018030\r\n', 'output': ['12']}, {'input': '84 231 70 145\r\n', 'output': ['6']}, {'input': '500 500 1000000000000000000 1\r\n', 'output': ['0']}]
[{'input': '1760355542088 1044709015401 1674331546848 2647835033212\r\n', 'output': ['1']}, {'input': '162 86 200 332\r\n', 'output': ['1']}, {'input': '405 55 194 58\r\n', 'output': ['1']}, {'input': '225 276 42 210\r\n', 'output': ['55']}, {'input': '100000 1 3 2\r\n', 'output': ['0']}]
[{'input': '27 68 94 30\r\n', 'output': ['0']}, {'input': '1000000000000000000 1000000000000000000 999999866000004473 999999822000007597\r\n', 'output': ['1000000063']}, {'input': '149485641770071450 851192235245178565 874621826044152778 488378180096620703\r\n', 'output': ['0']}, {'input': '25 260 129 285\r\n', 'output': ['0']}, {'input': '1760355542088 1044709015401 1674331546848 2647835033212\r\n', 'output': ['1']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
369
100
100
100
["0 0\n4 5", "3 4\n6 1"]
The first line contains two integers x1, y1 ( - 109 ≀ x1, y1 ≀ 109) β€” the start position of the robot. The second line contains two integers x2, y2 ( - 109 ≀ x2, y2 ≀ 109) β€” the finish position of the robot.
a6e9405bc3d4847fe962446bc1c457b4
a, b=map(int, input().split()) c, d=map(int, input().split()) g=abs(c-a) h=abs(d-b) x=max(g, h) y=min(g, h) z=abs(x-y) if g==h: print(g) else: print(y+z)
["5", "3"]
Python
NoteIn the first example robot should increase both of its coordinates by one four times, so it will be in position (4, 4). After that robot should simply increase its y coordinate and get the finish position.In the second example robot should simultaneously increase x coordinate and decrease y coordinate by one three times.
Print the only integer d β€” the minimal number of steps to get the finish position.
Professor GukiZ makes a new robot. The robot are in the point with coordinates (x1, y1) and should go to the point (x2, y2). In a single step the robot can change any of its coordinates (maybe both of them) by one (decrease or increase). So the robot can move in one of the 8 directions. Find the minimal number of steps the robot should make to get the finish position.
[{"input": "0 0\r\n4 5\r\n", "output": ["5"]}, {"input": "3 4\r\n6 1\r\n", "output": ["3"]}, {"input": "0 0\r\n4 6\r\n", "output": ["6"]}, {"input": "1 1\r\n-3 -5\r\n", "output": ["6"]}, {"input": "-1 -1\r\n-10 100\r\n", "output": ["101"]}, {"input": "1 -1\r\n100 -100\r\n", "output": ["99"]}, {"input": "-1000000000 -1000000000\r\n1000000000 1000000000\r\n", "output": ["2000000000"]}, {"input": "-1000000000 -1000000000\r\n0 999999999\r\n", "output": ["1999999999"]}, {"input": "0 0\r\n2 1\r\n", "output": ["2"]}, {"input": "10 0\r\n100 0\r\n", "output": ["90"]}, {"input": "1 5\r\n6 4\r\n", "output": ["5"]}, {"input": "0 0\r\n5 4\r\n", "output": ["5"]}, {"input": "10 1\r\n20 1\r\n", "output": ["10"]}, {"input": "1 1\r\n-3 4\r\n", "output": ["4"]}, {"input": "-863407280 504312726\r\n786535210 -661703810\r\n", "output": ["1649942490"]}, {"input": "-588306085 -741137832\r\n341385643 152943311\r\n", "output": ["929691728"]}, {"input": "0 0\r\n4 0\r\n", "output": ["4"]}, {"input": "93097194 -48405232\r\n-716984003 -428596062\r\n", "output": ["810081197"]}, {"input": "9 1\r\n1 1\r\n", "output": ["8"]}, {"input": "4 6\r\n0 4\r\n", "output": ["4"]}, {"input": "2 4\r\n5 2\r\n", "output": ["3"]}, {"input": "-100000000 -100000000\r\n100000000 100000123\r\n", "output": ["200000123"]}, {"input": "5 6\r\n5 7\r\n", "output": ["1"]}, {"input": "12 16\r\n12 1\r\n", "output": ["15"]}, {"input": "0 0\r\n5 1\r\n", "output": ["5"]}, {"input": "0 1\r\n1 1\r\n", "output": ["1"]}, {"input": "-44602634 913365223\r\n-572368780 933284951\r\n", "output": ["527766146"]}, {"input": "-2 0\r\n2 -2\r\n", "output": ["4"]}, {"input": "0 0\r\n3 1\r\n", "output": ["3"]}, {"input": "-458 2\r\n1255 4548\r\n", "output": ["4546"]}, {"input": "-5 -4\r\n-3 -3\r\n", "output": ["2"]}, {"input": "4 5\r\n7 3\r\n", "output": ["3"]}, {"input": "-1000000000 -999999999\r\n1000000000 999999998\r\n", "output": ["2000000000"]}, {"input": "-1000000000 -1000000000\r\n1000000000 -1000000000\r\n", "output": ["2000000000"]}, {"input": "-464122675 -898521847\r\n656107323 -625340409\r\n", "output": ["1120229998"]}, {"input": "-463154699 -654742385\r\n-699179052 -789004997\r\n", "output": ["236024353"]}, {"input": "982747270 -593488945\r\n342286841 -593604186\r\n", "output": ["640460429"]}, {"input": "-80625246 708958515\r\n468950878 574646184\r\n", "output": ["549576124"]}, {"input": "0 0\r\n1 0\r\n", "output": ["1"]}, {"input": "109810 1\r\n2 3\r\n", "output": ["109808"]}, {"input": "-9 0\r\n9 9\r\n", "output": ["18"]}, {"input": "9 9\r\n9 9\r\n", "output": ["0"]}, {"input": "1 1\r\n4 3\r\n", "output": ["3"]}, {"input": "1 2\r\n45 1\r\n", "output": ["44"]}, {"input": "207558188 -313753260\r\n-211535387 -721675423\r\n", "output": ["419093575"]}, {"input": "-11 0\r\n0 0\r\n", "output": ["11"]}, {"input": "-1000000000 1000000000\r\n1000000000 -1000000000\r\n", "output": ["2000000000"]}, {"input": "0 0\r\n1 1\r\n", "output": ["1"]}, {"input": "0 0\r\n0 1\r\n", "output": ["1"]}, {"input": "0 0\r\n-1 1\r\n", "output": ["1"]}, {"input": "0 0\r\n-1 0\r\n", "output": ["1"]}, {"input": "0 0\r\n-1 -1\r\n", "output": ["1"]}, {"input": "0 0\r\n0 -1\r\n", "output": ["1"]}, {"input": "0 0\r\n1 -1\r\n", "output": ["1"]}, {"input": "10 90\r\n90 10\r\n", "output": ["80"]}, {"input": "851016864 573579544\r\n-761410925 -380746263\r\n", "output": ["1612427789"]}, {"input": "1 9\r\n9 9\r\n", "output": ["8"]}, {"input": "1000 1000\r\n1000 1000\r\n", "output": ["0"]}, {"input": "1 9\r\n9 1\r\n", "output": ["8"]}, {"input": "1 90\r\n90 90\r\n", "output": ["89"]}, {"input": "100 100\r\n1000 1000\r\n", "output": ["900"]}, {"input": "-1 0\r\n0 0\r\n", "output": ["1"]}, {"input": "-750595959 -2984043\r\n649569876 -749608783\r\n", "output": ["1400165835"]}, {"input": "958048496 712083589\r\n423286949 810566863\r\n", "output": ["534761547"]}, {"input": "146316710 53945094\r\n-523054748 147499505\r\n", "output": ["669371458"]}, {"input": "50383856 -596516251\r\n-802950224 -557916272\r\n", "output": ["853334080"]}, {"input": "-637204864 -280290367\r\n-119020929 153679771\r\n", "output": ["518183935"]}, {"input": "-100 -100\r\n-60 -91\r\n", "output": ["40"]}, {"input": "337537326 74909428\r\n-765558776 167951547\r\n", "output": ["1103096102"]}, {"input": "0 81\r\n18 90\r\n", "output": ["18"]}, {"input": "283722202 -902633305\r\n-831696497 -160868946\r\n", "output": ["1115418699"]}, {"input": "1000 1000\r\n-1000 1000\r\n", "output": ["2000"]}, {"input": "5 6\r\n4 8\r\n", "output": ["2"]}, {"input": "40572000 597493595\r\n-935051731 368493185\r\n", "output": ["975623731"]}, {"input": "-5 5\r\n5 5\r\n", "output": ["10"]}]
100
100
100
[{'input': '0 0\r\n4 6\r\n', 'output': ['6']}, {'input': '9 1\r\n1 1\r\n', 'output': ['8']}, {'input': '-11 0\r\n0 0\r\n', 'output': ['11']}, {'input': '0 0\r\n4 0\r\n', 'output': ['4']}, {'input': '93097194 -48405232\r\n-716984003 -428596062\r\n', 'output': ['810081197']}]
[{'input': '5 6\r\n5 7\r\n', 'output': ['1']}, {'input': '10 90\r\n90 10\r\n', 'output': ['80']}, {'input': '9 9\r\n9 9\r\n', 'output': ['0']}, {'input': '-5 -4\r\n-3 -3\r\n', 'output': ['2']}, {'input': '-1000000000 -1000000000\r\n1000000000 -1000000000\r\n', 'output': ['2000000000']}]
[{'input': '1000 1000\r\n-1000 1000\r\n', 'output': ['2000']}, {'input': '-44602634 913365223\r\n-572368780 933284951\r\n', 'output': ['527766146']}, {'input': '-1 0\r\n0 0\r\n', 'output': ['1']}, {'input': '2 4\r\n5 2\r\n', 'output': ['3']}, {'input': '1 2\r\n45 1\r\n', 'output': ['44']}]
[{'input': '0 0\r\n4 5\r\n', 'output': ['5']}, {'input': '-463154699 -654742385\r\n-699179052 -789004997\r\n', 'output': ['236024353']}, {'input': '1 1\r\n4 3\r\n', 'output': ['3']}, {'input': '-1 -1\r\n-10 100\r\n', 'output': ['101']}, {'input': '207558188 -313753260\r\n-211535387 -721675423\r\n', 'output': ['419093575']}]
[{'input': '1 2\r\n45 1\r\n', 'output': ['44']}, {'input': '0 0\r\n-1 1\r\n', 'output': ['1']}, {'input': '0 0\r\n1 -1\r\n', 'output': ['1']}, {'input': '-637204864 -280290367\r\n-119020929 153679771\r\n', 'output': ['518183935']}, {'input': '0 81\r\n18 90\r\n', 'output': ['18']}]
100
100
100
100
100
90
100
90
90
100
50
100
50
50
100
370
100
94
70
["6 10", "21 31", "5 10"]
The only line contains two integers $$$a$$$ and $$$b$$$ ($$$1 \le a, b \le 10^9$$$).
414149fadebe25ab6097fc67663177c3
a, b = input().split() a, b = int(a), int(b) a, b = min(a, b), max(a, b) def eu(a, b): if a == 0: return b if b == 0: return a if a > b: return eu(a%b, b) return eu(a, b%a) opt = b - a factor = [] i = 1 while i**2 < opt+1: if opt % i == 0: factor.append(i) factor.append(int(opt/i)) i+=1 target = a * b / eu(a, b) drop = 0 for i in factor: firstupd = a - (a % i) + i secondupd = b - (b % i) + i dres = firstupd * int(secondupd/eu(firstupd,secondupd)) if dres <= target: if dres == target: drop = min(i-(a%i),drop) else: target = dres drop = i-(a%i) print(drop)
["2", "9", "0"]
Python
NoteIn the first test, one should choose $$$k = 2$$$, as the least common multiple of $$$6 + 2$$$ and $$$10 + 2$$$ is $$$24$$$, which is the smallest least common multiple possible.
Print the smallest non-negative integer $$$k$$$ ($$$k \ge 0$$$) such that the lowest common multiple of $$$a+k$$$ and $$$b+k$$$ is the smallest possible. If there are many possible integers $$$k$$$ giving the same value of the least common multiple, print the smallest one.
Neko loves divisors. During the latest number theory lesson, he got an interesting exercise from his math teacher.Neko has two integers $$$a$$$ and $$$b$$$. His goal is to find a non-negative integer $$$k$$$ such that the least common multiple of $$$a+k$$$ and $$$b+k$$$ is the smallest possible. If there are multiple optimal integers $$$k$$$, he needs to choose the smallest one.Given his mathematical talent, Neko had no trouble getting Wrong Answer on this problem. Can you help him solve it?
[{"input": "6 10\r\n", "output": ["2"]}, {"input": "21 31\r\n", "output": ["9"]}, {"input": "5 10\r\n", "output": ["0"]}, {"input": "1924 5834\r\n", "output": ["31"]}, {"input": "9911 666013\r\n", "output": ["318140"]}, {"input": "1 1\r\n", "output": ["0"]}, {"input": "69 4295\r\n", "output": ["2044"]}, {"input": "948248258 533435433\r\n", "output": ["296190217"]}, {"input": "953 1349\r\n", "output": ["235"]}, {"input": "999999973 800000007\r\n", "output": ["199999823"]}, {"input": "112342324 524224233\r\n", "output": ["299539585"]}, {"input": "1021211 59555555\r\n", "output": ["309115"]}, {"input": "1000000000 1000000000\r\n", "output": ["0"]}, {"input": "199999943 999999973\r\n", "output": ["200000072"]}, {"input": "2 999999973\r\n", "output": ["191"]}, {"input": "199999973 99999937\r\n", "output": ["99"]}, {"input": "851187514 983401693\r\n", "output": ["74311739"]}, {"input": "414459569 161124945\r\n", "output": ["92209679"]}, {"input": "59774131 414357411\r\n", "output": ["11142525"]}, {"input": "588854730 468415815\r\n", "output": ["13339845"]}, {"input": "166027408 867208246\r\n", "output": ["67699538"]}, {"input": "416882693 26430642\r\n", "output": ["9064999"]}, {"input": "63906772 377040487\r\n", "output": ["40471133"]}, {"input": "573707893 93108818\r\n", "output": ["3010997"]}, {"input": "498599067 627630818\r\n", "output": ["17527937"]}, {"input": "41698727 40343\r\n", "output": ["19511"]}, {"input": "21184942 66889\r\n", "output": ["573052"]}, {"input": "584924132 27895\r\n", "output": ["34377766"]}, {"input": "34504222 65532\r\n", "output": ["54883"]}, {"input": "397410367 96163\r\n", "output": ["44330"]}, {"input": "772116208 99741\r\n", "output": ["703606"]}, {"input": "721896242 62189\r\n", "output": ["150930"]}, {"input": "480432805 79482\r\n", "output": ["480273841"]}, {"input": "526157284 30640\r\n", "output": ["8006"]}, {"input": "509022792 57335\r\n", "output": ["5508"]}, {"input": "13911 866384789\r\n", "output": ["488042"]}, {"input": "43736 145490995\r\n", "output": ["242015"]}, {"input": "27522 656219918\r\n", "output": ["38975"]}, {"input": "3904 787488950\r\n", "output": ["577695"]}, {"input": "64320 203032344\r\n", "output": ["17588"]}, {"input": "19430 993947341\r\n", "output": ["43194827"]}, {"input": "89229 680338802\r\n", "output": ["16502224"]}, {"input": "22648 30366541\r\n", "output": ["509701"]}, {"input": "89598 155519475\r\n", "output": ["1581691"]}, {"input": "80536 791328168\r\n", "output": ["4581"]}, {"input": "55138 453739731\r\n", "output": ["26632191"]}, {"input": "20827 81894\r\n", "output": ["40240"]}, {"input": "15162 60885\r\n", "output": ["79"]}, {"input": "33261 83156\r\n", "output": ["16634"]}, {"input": "12567 44055\r\n", "output": ["3177"]}, {"input": "36890 51759\r\n", "output": ["7717"]}, {"input": "69731 73202\r\n", "output": ["3160"]}, {"input": "92037 8625\r\n", "output": ["643"]}, {"input": "51783 5491\r\n", "output": ["6082"]}, {"input": "39204 15357\r\n", "output": ["8490"]}, {"input": "11 16\r\n", "output": ["4"]}, {"input": "5 18\r\n", "output": ["8"]}, {"input": "1 113\r\n", "output": ["0"]}, {"input": "18 102\r\n", "output": ["3"]}, {"input": "13 33\r\n", "output": ["7"]}, {"input": "22 51\r\n", "output": ["7"]}, {"input": "1 114\r\n", "output": ["0"]}, {"input": "10 12\r\n", "output": ["0"]}, {"input": "24 9\r\n", "output": ["6"]}, {"input": "21 1\r\n", "output": ["0"]}, {"input": "5 14\r\n", "output": ["4"]}, {"input": "273301753 369183717\r\n", "output": ["14344139"]}, {"input": "83893226 440673790\r\n", "output": ["5301915"]}, {"input": "391320363 805801085\r\n", "output": ["23160359"]}, {"input": "350089529 67401533\r\n", "output": ["3270466"]}, {"input": "356318639 545297094\r\n", "output": ["21638271"]}, {"input": "456039936 216657167\r\n", "output": ["22725602"]}, {"input": "200869227 429021875\r\n", "output": ["27283421"]}, {"input": "724338885 158040565\r\n", "output": ["125108595"]}, {"input": "354798648 439745337\r\n", "output": ["69934797"]}, {"input": "152408121 368230838\r\n", "output": ["63414596"]}, {"input": "532851498 235555724\r\n", "output": ["61740050"]}, {"input": "571244721 233692396\r\n", "output": ["103859929"]}, {"input": "434431270 432744926\r\n", "output": ["645482"]}, {"input": "845961672 92356861\r\n", "output": ["661247950"]}, {"input": "861681496 158472265\r\n", "output": ["75930812"]}, {"input": "358415973 475293324\r\n", "output": ["109093431"]}, {"input": "179237079 691088384\r\n", "output": ["332614226"]}, {"input": "159488527 938932258\r\n", "output": ["100326050"]}, {"input": "173726711 47100867\r\n", "output": ["16212055"]}, {"input": "113701457 374868637\r\n", "output": ["16882133"]}, {"input": "49160468 106133716\r\n", "output": ["7812780"]}, {"input": "258834406 21427940\r\n", "output": ["154466"]}, {"input": "209853278 238360826\r\n", "output": ["18207106"]}, {"input": "833630757 5203048\r\n", "output": ["823224661"]}, {"input": "898985699 25761857\r\n", "output": ["12204397"]}, {"input": "882561035 53440816\r\n", "output": ["775679403"]}, {"input": "844002269 45400923\r\n", "output": ["353899750"]}, {"input": "890747621 58942406\r\n", "output": ["107418637"]}, {"input": "823409948 63146277\r\n", "output": ["697117394"]}, {"input": "806104369 75421522\r\n", "output": ["5765461"]}, {"input": "950485973 21039711\r\n", "output": ["443683420"]}, {"input": "904189980 653467036\r\n", "output": ["98701796"]}, {"input": "986866706 981520552\r\n", "output": ["2171784"]}, {"input": "987324114 296975438\r\n", "output": ["48198900"]}, {"input": "932939238 454247778\r\n", "output": ["24443682"]}, {"input": "997908364 240589278\r\n", "output": ["138070265"]}, {"input": "2 3\r\n", "output": ["0"]}, {"input": "5 11\r\n", "output": ["1"]}, {"input": "2 2\r\n", "output": ["0"]}, {"input": "2 6\r\n", "output": ["0"]}, {"input": "6 9\r\n", "output": ["0"]}, {"input": "1000000000 264865600\r\n", "output": ["102701600"]}]
100
100
100
[{'input': '1 113\r\n', 'output': ['0']}, {'input': '851187514 983401693\r\n', 'output': ['74311739']}, {'input': '456039936 216657167\r\n', 'output': ['22725602']}, {'input': '152408121 368230838\r\n', 'output': ['63414596']}, {'input': '10 12\r\n', 'output': ['0']}]
[{'input': '898985699 25761857\r\n', 'output': ['12204397']}, {'input': '18 102\r\n', 'output': ['3']}, {'input': '89598 155519475\r\n', 'output': ['1581691']}, {'input': '584924132 27895\r\n', 'output': ['34377766']}, {'input': '5 10\r\n', 'output': ['0']}]
[{'input': '526157284 30640\r\n', 'output': ['8006']}, {'input': '391320363 805801085\r\n', 'output': ['23160359']}, {'input': '890747621 58942406\r\n', 'output': ['107418637']}, {'input': '179237079 691088384\r\n', 'output': ['332614226']}, {'input': '22 51\r\n', 'output': ['7']}]
[{'input': '861681496 158472265\r\n', 'output': ['75930812']}, {'input': '51783 5491\r\n', 'output': ['6082']}, {'input': '89229 680338802\r\n', 'output': ['16502224']}, {'input': '997908364 240589278\r\n', 'output': ['138070265']}, {'input': '199999973 99999937\r\n', 'output': ['99']}]
[{'input': '13911 866384789\r\n', 'output': ['488042']}, {'input': '39204 15357\r\n', 'output': ['8490']}, {'input': '1 113\r\n', 'output': ['0']}, {'input': '43736 145490995\r\n', 'output': ['242015']}, {'input': '55138 453739731\r\n', 'output': ['26632191']}]
100
100
100
100
100
96.77
100
100
100
96.77
93.75
100
100
100
93.75
371
100
98.708
97.5
["QAQAQYSYIOIWIN", "QAQQQZZYNOIWIN"]
The only line contains a string of length n (1 ≀ n ≀ 100). It's guaranteed that the string only contains uppercase English letters.
8aef4947322438664bd8610632fe0947
import itertools print(sum(map(lambda x:(x==('Q','A','Q')), itertools.combinations(input(),3))))
["4", "3"]
Python
NoteIn the first example there are 4 subsequences "QAQ": "QAQAQYSYIOIWIN", "QAQAQYSYIOIWIN", "QAQAQYSYIOIWIN", "QAQAQYSYIOIWIN".
Print a single integerΒ β€” the number of subsequences "QAQ" in the string.
"QAQ" is a word to denote an expression of crying. Imagine "Q" as eyes with tears and "A" as a mouth.Now Diamond has given Bort a string consisting of only uppercase English letters of length n. There is a great number of "QAQ" in the string (Diamond is so cute!). illustration by ηŒ«ε±‹ https://twitter.com/nekoyaliu Bort wants to know how many subsequences "QAQ" are in the string Diamond has given. Note that the letters "QAQ" don't have to be consecutive, but the order of letters should be exact.
[{"input": "QAQAQYSYIOIWIN\r\n", "output": ["4"]}, {"input": "QAQQQZZYNOIWIN\r\n", "output": ["3"]}, {"input": "QA\r\n", "output": ["0"]}, {"input": "IAQVAQZLQBQVQFTQQQADAQJA\r\n", "output": ["24"]}, {"input": "QQAAQASGAYAAAAKAKAQIQEAQAIAAIAQQQQQ\r\n", "output": ["378"]}, {"input": "AMVFNFJIAVNQJWIVONQOAOOQSNQSONOASONAONQINAONAOIQONANOIQOANOQINAONOQINAONOXJCOIAQOAOQAQAQAQAQWWWAQQAQ\r\n", "output": ["1077"]}, {"input": "AAQQAXBQQBQQXBNQRJAQKQNAQNQVDQASAGGANQQQQTJFFQQQTQQA\r\n", "output": ["568"]}, {"input": "KAZXAVLPJQBQVQQQQQAPAQQGQTQVZQAAAOYA\r\n", "output": ["70"]}, {"input": "W\r\n", "output": ["0"]}, {"input": "DBA\r\n", "output": ["0"]}, {"input": "RQAWNACASAAKAGAAAAQ\r\n", "output": ["10"]}, {"input": "QJAWZAAOAAGIAAAAAOQATASQAEAAAAQFQQHPA\r\n", "output": ["111"]}, {"input": "QQKWQAQAAAAAAAAGAAVAQUEQQUMQMAQQQNQLAMAAAUAEAAEMAAA\r\n", "output": ["411"]}, {"input": "QQUMQAYAUAAGWAAAQSDAVAAQAAAASKQJJQQQQMAWAYYAAAAAAEAJAXWQQ\r\n", "output": ["625"]}, {"input": "QORZOYAQ\r\n", "output": ["1"]}, {"input": "QCQAQAGAWAQQQAQAVQAQQQQAQAQQQAQAAATQAAVAAAQQQQAAAUUQAQQNQQWQQWAQAAQQKQYAQAAQQQAAQRAQQQWBQQQQAPBAQGQA\r\n", "output": ["13174"]}, {"input": "QQAQQAKQFAQLQAAWAMQAZQAJQAAQQOACQQAAAYANAQAQQAQAAQQAOBQQJQAQAQAQQQAAAAABQQQAVNZAQQQQAMQQAFAAEAQAQHQT\r\n", "output": ["10420"]}, {"input": "AQEGQHQQKQAQQPQKAQQQAAAAQQQAQEQAAQAAQAQFSLAAQQAQOQQAVQAAAPQQAWAQAQAFQAXAQQQQTRLOQAQQJQNQXQQQQSQVDQQQ\r\n", "output": ["12488"]}, {"input": "QNQKQQQLASQBAVQQQQAAQQOQRJQQAQQQEQZUOANAADAAQQJAQAQARAAAQQQEQBHTQAAQAAAAQQMKQQQIAOJJQQAQAAADADQUQQQA\r\n", "output": ["9114"]}, {"input": "QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ\r\n", "output": ["35937"]}, {"input": "AMQQAAQAAQAAAAAAQQQBOAAANAAKQJCYQAE\r\n", "output": ["254"]}, {"input": "AYQBAEQGAQEOAKGIXLQJAIAKQAAAQPUAJAKAATFWQQAOQQQUFQYAQQMQHOKAAJXGFCARAQSATHAUQQAATQJJQDQRAANQQAE\r\n", "output": ["2174"]}, {"input": "AAQXAAQAYQAAAAGAQHVQYAGIVACADFAAQAAAAQZAAQMAKZAADQAQDAAQDAAAMQQOXYAQQQAKQBAAQQKAXQBJZDDLAAHQQ\r\n", "output": ["2962"]}, {"input": "AYQQYAVAMNIAUAAKBBQVACWKTQSAQZAAQAAASZJAWBCAALAARHACQAKQQAQAARPAQAAQAQAAZQUSHQAMFVFZQQQQSAQQXAA\r\n", "output": ["2482"]}, {"input": "LQMAQQARQAQBJQQQAGAAZQQXALQQAARQAQQQQAAQQAQQQAQQCAQQAQQAYQQQRAAZATQALYQQAAHHAAQHAAAAAAAAQQMAAQNAKQ\r\n", "output": ["7768"]}, {"input": "MAQQWAQOYQMAAAQAQPQZAOAAQAUAQNAAQAAAITQSAQAKAQKAQQWSQAAQQAGUCDQMQWKQUXKWQQAAQQAAQQZQDQQQAABXQUUXQOA\r\n", "output": ["5422"]}, {"input": "QTAAQDAQXAQQJQQQGAAAQQQQSBQZKAQQAQQQQEAQNUQBZCQLYQZQEQQAAQHQVAORKQVAQYQNASZQAARZAAGAAAAOQDCQ\r\n", "output": ["3024"]}, {"input": "QQWAQQGQQUZQQQLZAAQYQXQVAQFQUAQZUQZZQUKBHSHTQYLQAOQXAQQGAQQTQOAQARQADAJRAAQPQAQQUQAUAMAUVQAAAQQAWQ\r\n", "output": ["4527"]}, {"input": "QQAAQQAQVAQZQQQQAOEAQZPQIBQZACQQAFQQLAAQDATZQANHKYQQAQTAAFQRQAIQAJPWQAQTEIRXAEQQAYWAAAUKQQAQAQQQSQQH\r\n", "output": ["6416"]}, {"input": "AQQQQAQAAQQAQAQAAAAAAAAAQAQAAAAAQAQAQQQAQQQAAAQQQAAAAAAAQAAAAQQQQQQQAQQQQAQAAAQAAAAAQAQAAAAAQAQAAAA\r\n", "output": ["14270"]}, {"input": "AQQQQAQAAQQAQAQAAAAAAAAAQAQAAAAAQAQAQQQAQQQAAAQQQAAAAAAAQAAAAQQQQQQQAQQQQAQAAAQAAAAAQAQAAAAAQ\r\n", "output": ["13136"]}, {"input": "AQQQQAQAAQQAQAQAAAAAAAAAQAQAAAAAQAQAQQQAQQQAAAQQQAAAAAAAQAAAAQQQQQQQAQQQQAQAAAQAAAAAQAQAAAAAQAQAA\r\n", "output": ["14270"]}, {"input": "AQQQQAQAAQQAQAQAAAAAAAAAQAQAAAAAQAQAQQQAQQQAAAQQQAAAAAAAQAAAAQQQQQQQAQQQQAQAAAQAAAAAQAQAAAAAQQAA\r\n", "output": ["14231"]}, {"input": "QQQQQAQAAQQAQAQAAAAAAAAAQAQAAAAAQAQAQQQAQQQAAAQQQAAAAAAAQAAAAQQQQQQQAQQQQAQAAAQAAAAAQAQAAAAAQAQAA\r\n", "output": ["15296"]}, {"input": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ\r\n", "output": ["0"]}, {"input": "QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n", "output": ["0"]}, {"input": "QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ\r\n", "output": ["0"]}, {"input": "QAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQA\r\n", "output": ["20825"]}, {"input": "AQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQ\r\n", "output": ["20825"]}, {"input": "Q\r\n", "output": ["0"]}, {"input": "A\r\n", "output": ["0"]}, {"input": "FFF\r\n", "output": ["0"]}, {"input": "AAAAAA\r\n", "output": ["0"]}]
100
100
100
[{'input': 'QQAAQASGAYAAAAKAKAQIQEAQAIAAIAQQQQQ\r\n', 'output': ['378']}, {'input': 'AQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQ\r\n', 'output': ['20825']}, {'input': 'W\r\n', 'output': ['0']}, {'input': 'LQMAQQARQAQBJQQQAGAAZQQXALQQAARQAQQQQAAQQAQQQAQQCAQQAQQAYQQQRAAZATQALYQQAAHHAAQHAAAAAAAAQQMAAQNAKQ\r\n', 'output': ['7768']}, {'input': 'AQQQQAQAAQQAQAQAAAAAAAAAQAQAAAAAQAQAQQQAQQQAAAQQQAAAAAAAQAAAAQQQQQQQAQQQQAQAAAQAAAAAQAQAAAAAQQAA\r\n', 'output': ['14231']}]
[{'input': 'FFF\r\n', 'output': ['0']}, {'input': 'QQWAQQGQQUZQQQLZAAQYQXQVAQFQUAQZUQZZQUKBHSHTQYLQAOQXAQQGAQQTQOAQARQADAJRAAQPQAQQUQAUAMAUVQAAAQQAWQ\r\n', 'output': ['4527']}, {'input': 'QQAAQASGAYAAAAKAKAQIQEAQAIAAIAQQQQQ\r\n', 'output': ['378']}, {'input': 'QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ\r\n', 'output': ['35937']}, {'input': 'QQUMQAYAUAAGWAAAQSDAVAAQAAAASKQJJQQQQMAWAYYAAAAAAEAJAXWQQ\r\n', 'output': ['625']}]
[{'input': 'W\r\n', 'output': ['0']}, {'input': 'QQUMQAYAUAAGWAAAQSDAVAAQAAAASKQJJQQQQMAWAYYAAAAAAEAJAXWQQ\r\n', 'output': ['625']}, {'input': 'QNQKQQQLASQBAVQQQQAAQQOQRJQQAQQQEQZUOANAADAAQQJAQAQARAAAQQQEQBHTQAAQAAAAQQMKQQQIAOJJQQAQAAADADQUQQQA\r\n', 'output': ['9114']}, {'input': 'KAZXAVLPJQBQVQQQQQAPAQQGQTQVZQAAAOYA\r\n', 'output': ['70']}, {'input': 'QQWAQQGQQUZQQQLZAAQYQXQVAQFQUAQZUQZZQUKBHSHTQYLQAOQXAQQGAQQTQOAQARQADAJRAAQPQAQQUQAUAMAUVQAAAQQAWQ\r\n', 'output': ['4527']}]
[{'input': 'FFF\r\n', 'output': ['0']}, {'input': 'AQQQQAQAAQQAQAQAAAAAAAAAQAQAAAAAQAQAQQQAQQQAAAQQQAAAAAAAQAAAAQQQQQQQAQQQQAQAAAQAAAAAQAQAAAAAQ\r\n', 'output': ['13136']}, {'input': 'QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ\r\n', 'output': ['35937']}, {'input': 'QQUMQAYAUAAGWAAAQSDAVAAQAAAASKQJJQQQQMAWAYYAAAAAAEAJAXWQQ\r\n', 'output': ['625']}, {'input': 'AYQBAEQGAQEOAKGIXLQJAIAKQAAAQPUAJAKAATFWQQAOQQQUFQYAQQMQHOKAAJXGFCARAQSATHAUQQAATQJJQDQRAANQQAE\r\n', 'output': ['2174']}]
[{'input': 'QJAWZAAOAAGIAAAAAOQATASQAEAAAAQFQQHPA\r\n', 'output': ['111']}, {'input': 'AQQQQAQAAQQAQAQAAAAAAAAAQAQAAAAAQAQAQQQAQQQAAAQQQAAAAAAAQAAAAQQQQQQQAQQQQAQAAAQAAAAAQAQAAAAAQ\r\n', 'output': ['13136']}, {'input': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ\r\n', 'output': ['0']}, {'input': 'QQQQQAQAAQQAQAQAAAAAAAAAQAQAAAAAQAQAQQQAQQQAAAQQQAAAAAAAQAAAAQQQQQQQAQQQQAQAAAQAAAAAQAQAAAAAQAQAA\r\n', 'output': ['15296']}, {'input': 'QAQQQZZYNOIWIN\r\n', 'output': ['3']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
372
100
100
100
["2 2", "9 3"]
The single line contains two integers n and m (1 ≀ n ≀ 100;Β 2 ≀ m ≀ 100), separated by a space.
42b25b7335ec01794fbb1d4086aa9dd0
def gogo(n, m): return n + ((n-1)//(m-1)) def main(): pairs, bought = map(int, input().split()) print(gogo(pairs, bought)) main()
["3", "13"]
Python
NoteIn the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two.In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought on the third, sixth and ninth days. Than he spends another day wearing the socks that were bought on the twelfth day.
Print a single integer β€” the answer to the problem.
Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2m, 3m, ...) mom buys a pair of socks to Vasya. She does it late in the evening, so that Vasya cannot put on a new pair of socks before the next day. How many consecutive days pass until Vasya runs out of socks?
[{"input": "2 2\r\n", "output": ["3"]}, {"input": "9 3\r\n", "output": ["13"]}, {"input": "1 2\r\n", "output": ["1"]}, {"input": "2 3\r\n", "output": ["2"]}, {"input": "1 99\r\n", "output": ["1"]}, {"input": "4 4\r\n", "output": ["5"]}, {"input": "10 2\r\n", "output": ["19"]}, {"input": "10 9\r\n", "output": ["11"]}, {"input": "100 100\r\n", "output": ["101"]}, {"input": "2 27\r\n", "output": ["2"]}, {"input": "99 100\r\n", "output": ["99"]}, {"input": "99 2\r\n", "output": ["197"]}, {"input": "100 3\r\n", "output": ["149"]}, {"input": "98 3\r\n", "output": ["146"]}, {"input": "100 2\r\n", "output": ["199"]}, {"input": "62 4\r\n", "output": ["82"]}, {"input": "99 10\r\n", "output": ["109"]}, {"input": "100 5\r\n", "output": ["124"]}, {"input": "80 80\r\n", "output": ["81"]}, {"input": "95 16\r\n", "output": ["101"]}, {"input": "75 16\r\n", "output": ["79"]}, {"input": "99 74\r\n", "output": ["100"]}, {"input": "20 21\r\n", "output": ["20"]}, {"input": "52 96\r\n", "output": ["52"]}, {"input": "24 5\r\n", "output": ["29"]}]
100
100
100
[{'input': '2 3\r\n', 'output': ['2']}, {'input': '99 10\r\n', 'output': ['109']}, {'input': '98 3\r\n', 'output': ['146']}, {'input': '99 2\r\n', 'output': ['197']}, {'input': '24 5\r\n', 'output': ['29']}]
[{'input': '10 2\r\n', 'output': ['19']}, {'input': '99 74\r\n', 'output': ['100']}, {'input': '100 3\r\n', 'output': ['149']}, {'input': '20 21\r\n', 'output': ['20']}, {'input': '100 2\r\n', 'output': ['199']}]
[{'input': '99 2\r\n', 'output': ['197']}, {'input': '10 9\r\n', 'output': ['11']}, {'input': '9 3\r\n', 'output': ['13']}, {'input': '100 3\r\n', 'output': ['149']}, {'input': '10 2\r\n', 'output': ['19']}]
[{'input': '99 2\r\n', 'output': ['197']}, {'input': '99 74\r\n', 'output': ['100']}, {'input': '100 100\r\n', 'output': ['101']}, {'input': '100 5\r\n', 'output': ['124']}, {'input': '1 2\r\n', 'output': ['1']}]
[{'input': '52 96\r\n', 'output': ['52']}, {'input': '9 3\r\n', 'output': ['13']}, {'input': '2 2\r\n', 'output': ['3']}, {'input': '95 16\r\n', 'output': ['101']}, {'input': '100 5\r\n', 'output': ['124']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
373
100
100
100
["1098", "10"]
The first line contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
055fbbde4b9ffd4473e6e716da6da899
def f(x): x+=1 while not x % 10: x //=10 return x previous = set() n = int(input()) while n not in previous: previous.add(n) n = f(n) print(len(previous))
["20", "19"]
Python
NoteThe numbers that are reachable from $$$1098$$$ are:$$$1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1098, 1099$$$.
Print one integer: the number of different numbers that are reachable from $$$n$$$.
Let's denote a function $$$f(x)$$$ in such a way: we add $$$1$$$ to $$$x$$$, then, while there is at least one trailing zero in the resulting number, we remove that zero. For example, $$$f(599) = 6$$$: $$$599 + 1 = 600 \rightarrow 60 \rightarrow 6$$$; $$$f(7) = 8$$$: $$$7 + 1 = 8$$$; $$$f(9) = 1$$$: $$$9 + 1 = 10 \rightarrow 1$$$; $$$f(10099) = 101$$$: $$$10099 + 1 = 10100 \rightarrow 1010 \rightarrow 101$$$. We say that some number $$$y$$$ is reachable from $$$x$$$ if we can apply function $$$f$$$ to $$$x$$$ some (possibly zero) times so that we get $$$y$$$ as a result. For example, $$$102$$$ is reachable from $$$10098$$$ because $$$f(f(f(10098))) = f(f(10099)) = f(101) = 102$$$; and any number is reachable from itself.You are given a number $$$n$$$; your task is to count how many different numbers are reachable from $$$n$$$.
[{"input": "1098\r\n", "output": ["20\n", "20", "20\r\n"]}, {"input": "10\r\n", "output": ["19", "19\r\n", "19\n"]}, {"input": "1000000000\r\n", "output": ["91\n", "91\r\n", "91"]}, {"input": "1\r\n", "output": ["9", "9\r\n", "9\n"]}, {"input": "9\r\n", "output": ["9", "9\r\n", "9\n"]}, {"input": "10119\r\n", "output": ["35\r\n", "35\n", "35"]}, {"input": "1337\r\n", "output": ["24", "24\n", "24\r\n"]}, {"input": "51\r\n", "output": ["18\n", "18", "18\r\n"]}, {"input": "99\r\n", "output": ["10\r\n", "10\n", "10"]}, {"input": "79\r\n", "output": ["10\r\n", "10\n", "10"]}, {"input": "29\r\n", "output": ["10\r\n", "10\n", "10"]}, {"input": "633\r\n", "output": ["22\r\n", "22\n", "22"]}, {"input": "9000\r\n", "output": ["37", "37\r\n", "37\n"]}, {"input": "99999999\r\n", "output": ["10\r\n", "10\n", "10"]}, {"input": "932415950\r\n", "output": ["53", "53\r\n", "53\n"]}, {"input": "90\r\n", "output": ["19", "19\r\n", "19\n"]}, {"input": "45\r\n", "output": ["14", "14\r\n", "14\n"]}, {"input": "22\r\n", "output": ["17", "17\n", "17\r\n"]}, {"input": "987654321\r\n", "output": ["46\r\n", "46\n", "46"]}, {"input": "599\r\n", "output": ["10\r\n", "10\n", "10"]}, {"input": "54\r\n", "output": ["15", "15\n", "15\r\n"]}, {"input": "73180\r\n", "output": ["34\r\n", "34", "34\n"]}, {"input": "9392\r\n", "output": ["23", "23\r\n", "23\n"]}, {"input": "25659427\r\n", "output": ["35\r\n", "35\n", "35"]}, {"input": "1999\r\n", "output": ["10\r\n", "10\n", "10"]}, {"input": "712\r\n", "output": ["25\n", "25\r\n", "25"]}, {"input": "21\r\n", "output": ["18\n", "18", "18\r\n"]}, {"input": "916073472\r\n", "output": ["52", "52\r\n", "52\n"]}, {"input": "920\r\n", "output": ["26\r\n", "26\n", "26"]}, {"input": "61261142\r\n", "output": ["56\r\n", "56", "56\n"]}, {"input": "999999999\r\n", "output": ["10\r\n", "10\n", "10"]}, {"input": "30\r\n", "output": ["19", "19\r\n", "19\n"]}, {"input": "299\r\n", "output": ["10\r\n", "10\n", "10"]}, {"input": "20\r\n", "output": ["19", "19\r\n", "19\n"]}, {"input": "960879599\r\n", "output": ["29\n", "29", "29\r\n"]}, {"input": "41\r\n", "output": ["18\n", "18", "18\r\n"]}, {"input": "9590\r\n", "output": ["23", "23\r\n", "23\n"]}, {"input": "9169813\r\n", "output": ["36", "36\n", "36\r\n"]}, {"input": "2001\r\n", "output": ["36", "36\n", "36\r\n"]}, {"input": "6171\r\n", "output": ["28", "28\n", "28\r\n"]}, {"input": "23\r\n", "output": ["16\n", "16", "16\r\n"]}, {"input": "99932791\r\n", "output": ["33", "33\r\n", "33\n"]}, {"input": "959590\r\n", "output": ["27", "27\n", "27\r\n"]}, {"input": "90000001\r\n", "output": ["72\r\n", "72", "72\n"]}, {"input": "98\r\n", "output": ["11", "11\n", "11\r\n"]}, {"input": "442188277\r\n", "output": ["43", "43\r\n", "43\n"]}, {"input": "751780\r\n", "output": ["34\r\n", "34", "34\n"]}, {"input": "909590\r\n", "output": ["32\n", "32", "32\r\n"]}, {"input": "91\r\n", "output": ["18\n", "18", "18\r\n"]}, {"input": "89\r\n", "output": ["10\r\n", "10\n", "10"]}, {"input": "76\r\n", "output": ["13\n", "13\r\n", "13"]}, {"input": "34\r\n", "output": ["15", "15\n", "15\r\n"]}, {"input": "70\r\n", "output": ["19", "19\r\n", "19\n"]}, {"input": "38\r\n", "output": ["11", "11\n", "11\r\n"]}, {"input": "58\r\n", "output": ["11", "11\n", "11\r\n"]}, {"input": "852240\r\n", "output": ["42\n", "42\r\n", "42"]}, {"input": "94\r\n", "output": ["15", "15\n", "15\r\n"]}, {"input": "44\r\n", "output": ["15", "15\n", "15\r\n"]}, {"input": "83\r\n", "output": ["16\n", "16", "16\r\n"]}, {"input": "81\r\n", "output": ["18\n", "18", "18\r\n"]}, {"input": "49\r\n", "output": ["10\r\n", "10\n", "10"]}, {"input": "71\r\n", "output": ["18\n", "18", "18\r\n"]}, {"input": "204907\r\n", "output": ["35\r\n", "35\n", "35"]}, {"input": "3\r\n", "output": ["9", "9\r\n", "9\n"]}, {"input": "40\r\n", "output": ["19", "19\r\n", "19\n"]}, {"input": "123123124\r\n", "output": ["64\n", "64\r\n", "64"]}, {"input": "88\r\n", "output": ["11", "11\n", "11\r\n"]}, {"input": "97\r\n", "output": ["12", "12\n", "12\r\n"]}, {"input": "642853\r\n", "output": ["33", "33\r\n", "33\n"]}, {"input": "986792\r\n", "output": ["23", "23\r\n", "23\n"]}, {"input": "5\r\n", "output": ["9", "9\r\n", "9\n"]}, {"input": "73\r\n", "output": ["16\n", "16", "16\r\n"]}, {"input": "50\r\n", "output": ["19", "19\r\n", "19\n"]}, {"input": "556740\r\n", "output": ["33", "33\r\n", "33\n"]}, {"input": "259835150\r\n", "output": ["46\r\n", "46\n", "46"]}, {"input": "5932\r\n", "output": ["23", "23\r\n", "23\n"]}, {"input": "36\r\n", "output": ["13\n", "13\r\n", "13"]}, {"input": "96\r\n", "output": ["13\n", "13\r\n", "13"]}, {"input": "999999\r\n", "output": ["10\r\n", "10\n", "10"]}, {"input": "921280\r\n", "output": ["42\n", "42\r\n", "42"]}, {"input": "84\r\n", "output": ["15", "15\n", "15\r\n"]}, {"input": "19909590\r\n", "output": ["32\n", "32", "32\r\n"]}, {"input": "599785072\r\n", "output": ["35\r\n", "35\n", "35"]}, {"input": "303719549\r\n", "output": ["44", "44\n", "44\r\n"]}, {"input": "90909590\r\n", "output": ["41", "41\r\n", "41\n"]}, {"input": "940160238\r\n", "output": ["58\n", "58\r\n", "58"]}, {"input": "255\r\n", "output": ["18\n", "18", "18\r\n"]}, {"input": "439674440\r\n", "output": ["45\n", "45\r\n", "45"]}, {"input": "870826420\r\n", "output": ["53", "53\r\n", "53\n"]}, {"input": "93\r\n", "output": ["16\n", "16", "16\r\n"]}, {"input": "55\r\n", "output": ["14", "14\r\n", "14\n"]}, {"input": "631\r\n", "output": ["24", "24\n", "24\r\n"]}, {"input": "24\r\n", "output": ["15", "15\n", "15\r\n"]}, {"input": "59\r\n", "output": ["10\r\n", "10\n", "10"]}, {"input": "78\r\n", "output": ["11", "11\n", "11\r\n"]}, {"input": "997184\r\n", "output": ["26\r\n", "26\n", "26"]}, {"input": "189070\r\n", "output": ["31\n", "31", "31\r\n"]}, {"input": "46\r\n", "output": ["13\n", "13\r\n", "13"]}, {"input": "63\r\n", "output": ["16\n", "16", "16\r\n"]}, {"input": "869667992\r\n", "output": ["28", "28\n", "28\r\n"]}, {"input": "963\r\n", "output": ["19", "19\r\n", "19\n"]}, {"input": "86\r\n", "output": ["13\n", "13\r\n", "13"]}, {"input": "880708\r\n", "output": ["32\n", "32", "32\r\n"]}, {"input": "80\r\n", "output": ["19", "19\r\n", "19\n"]}, {"input": "902826\r\n", "output": ["37", "37\r\n", "37\n"]}, {"input": "57\r\n", "output": ["12", "12\n", "12\r\n"]}, {"input": "956126\r\n", "output": ["35\r\n", "35\n", "35"]}, {"input": "790643\r\n", "output": ["33", "33\r\n", "33\n"]}, {"input": "68\r\n", "output": ["11", "11\n", "11\r\n"]}, {"input": "990\r\n", "output": ["19", "19\r\n", "19\n"]}, {"input": "860082635\r\n", "output": ["52", "52\r\n", "52\n"]}, {"input": "940740\r\n", "output": ["40", "40\r\n", "40\n"]}, {"input": "87\r\n", "output": ["12", "12\n", "12\r\n"]}, {"input": "799170\r\n", "output": ["29\n", "29", "29\r\n"]}, {"input": "75\r\n", "output": ["14", "14\r\n", "14\n"]}, {"input": "19\r\n", "output": ["10\r\n", "10\n", "10"]}, {"input": "312770\r\n", "output": ["38\n", "38\r\n", "38"]}, {"input": "69\r\n", "output": ["10\r\n", "10\n", "10"]}, {"input": "855520\r\n", "output": ["38\n", "38\r\n", "38"]}, {"input": "53\r\n", "output": ["16\n", "16", "16\r\n"]}, {"input": "841480\r\n", "output": ["38\n", "38\r\n", "38"]}, {"input": "60\r\n", "output": ["19", "19\r\n", "19\n"]}, {"input": "196530\r\n", "output": ["32\n", "32", "32\r\n"]}, {"input": "883260\r\n", "output": ["36", "36\n", "36\r\n"]}, {"input": "962131\r\n", "output": ["42\n", "42\r\n", "42"]}, {"input": "77\r\n", "output": ["12", "12\n", "12\r\n"]}, {"input": "47\r\n", "output": ["12", "12\n", "12\r\n"]}, {"input": "62\r\n", "output": ["17", "17\n", "17\r\n"]}, {"input": "2333\r\n", "output": ["28", "28\n", "28\r\n"]}, {"input": "999999970\r\n", "output": ["21\n", "21", "21\r\n"]}]
100
100
100
[{'input': '24\r\n', 'output': ['15', '15\n', '15\r\n']}, {'input': '69\r\n', 'output': ['10\r\n', '10\n', '10']}, {'input': '920\r\n', 'output': ['26\r\n', '26\n', '26']}, {'input': '9169813\r\n', 'output': ['36', '36\n', '36\r\n']}, {'input': '123123124\r\n', 'output': ['64\n', '64\r\n', '64']}]
[{'input': '1000000000\r\n', 'output': ['91\n', '91\r\n', '91']}, {'input': '189070\r\n', 'output': ['31\n', '31', '31\r\n']}, {'input': '90\r\n', 'output': ['19', '19\r\n', '19\n']}, {'input': '19909590\r\n', 'output': ['32\n', '32', '32\r\n']}, {'input': '869667992\r\n', 'output': ['28', '28\n', '28\r\n']}]
[{'input': '439674440\r\n', 'output': ['45\n', '45\r\n', '45']}, {'input': '23\r\n', 'output': ['16\n', '16', '16\r\n']}, {'input': '9392\r\n', 'output': ['23', '23\r\n', '23\n']}, {'input': '81\r\n', 'output': ['18\n', '18', '18\r\n']}, {'input': '90\r\n', 'output': ['19', '19\r\n', '19\n']}]
[{'input': '55\r\n', 'output': ['14', '14\r\n', '14\n']}, {'input': '96\r\n', 'output': ['13\n', '13\r\n', '13']}, {'input': '50\r\n', 'output': ['19', '19\r\n', '19\n']}, {'input': '990\r\n', 'output': ['19', '19\r\n', '19\n']}, {'input': '45\r\n', 'output': ['14', '14\r\n', '14\n']}]
[{'input': '5932\r\n', 'output': ['23', '23\r\n', '23\n']}, {'input': '98\r\n', 'output': ['11', '11\n', '11\r\n']}, {'input': '990\r\n', 'output': ['19', '19\r\n', '19\n']}, {'input': '38\r\n', 'output': ['11', '11\n', '11\r\n']}, {'input': '841480\r\n', 'output': ['38\n', '38\r\n', '38']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
374
100
100
100
["12"]
The only line of the input contains one integer n (1 ≀ n ≀ 1018) β€” the prediction on the number of people who will buy the game.
e392be5411ffccc1df50e65ec1f5c589
def main(): n = int(input()) print(solver(n)) def solver(n): factors = [2, 3, 5, 7] singles = n // 2 + n // 3 + n // 5 + n // 7 pairs = n // (2 * 3) + n // (2 * 5) + n // (2 * 7) + \ n // (3 * 5) + n // (3 * 7) + n // (5 * 7) triples = n // (2 * 3 * 5) + n // (2 * 3 * 7) + \ n // (2 * 5 * 7) + n // (3 * 5 * 7) quads = n // (2 * 3 * 5 * 7) return n - singles + pairs - triples + quads main()
["2"]
Python
null
Output one integer showing how many numbers from 1 to n are not divisible by any number from 2 to 10.
IT City company developing computer games decided to upgrade its way to reward its employees. Now it looks the following way. After a new game release users start buying it actively, and the company tracks the number of sales with precision to each transaction. Every time when the next number of sales is not divisible by any number from 2 to 10 every developer of this game gets a small bonus.A game designer Petya knows that the company is just about to release a new game that was partly developed by him. On the basis of his experience he predicts that n people will buy the game during the first month. Now Petya wants to determine how many times he will get the bonus. Help him to know it.
[{"input": "12\r\n", "output": ["2"]}, {"input": "2519\r\n", "output": ["576"]}, {"input": "2521\r\n", "output": ["577"]}, {"input": "1\r\n", "output": ["1"]}, {"input": "314159265\r\n", "output": ["71807832"]}, {"input": "718281828459045235\r\n", "output": ["164178703647781768"]}, {"input": "1000000000000000000\r\n", "output": ["228571428571428571"]}, {"input": "987654321234567890\r\n", "output": ["225749559139329804"]}, {"input": "3628800\r\n", "output": ["829440"]}, {"input": "504000000000000000\r\n", "output": ["115200000000000000"]}]
100
100
100
[{'input': '314159265\r\n', 'output': ['71807832']}, {'input': '504000000000000000\r\n', 'output': ['115200000000000000']}, {'input': '987654321234567890\r\n', 'output': ['225749559139329804']}, {'input': '2521\r\n', 'output': ['577']}, {'input': '3628800\r\n', 'output': ['829440']}]
[{'input': '1000000000000000000\r\n', 'output': ['228571428571428571']}, {'input': '1\r\n', 'output': ['1']}, {'input': '504000000000000000\r\n', 'output': ['115200000000000000']}, {'input': '2519\r\n', 'output': ['576']}, {'input': '987654321234567890\r\n', 'output': ['225749559139329804']}]
[{'input': '718281828459045235\r\n', 'output': ['164178703647781768']}, {'input': '3628800\r\n', 'output': ['829440']}, {'input': '1000000000000000000\r\n', 'output': ['228571428571428571']}, {'input': '2521\r\n', 'output': ['577']}, {'input': '504000000000000000\r\n', 'output': ['115200000000000000']}]
[{'input': '718281828459045235\r\n', 'output': ['164178703647781768']}, {'input': '504000000000000000\r\n', 'output': ['115200000000000000']}, {'input': '987654321234567890\r\n', 'output': ['225749559139329804']}, {'input': '2521\r\n', 'output': ['577']}, {'input': '12\r\n', 'output': ['2']}]
[{'input': '2521\r\n', 'output': ['577']}, {'input': '1\r\n', 'output': ['1']}, {'input': '1000000000000000000\r\n', 'output': ['228571428571428571']}, {'input': '12\r\n', 'output': ['2']}, {'input': '2519\r\n', 'output': ['576']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
375
100
100
100
["5 1 4 4 2 1", "1 6 6 2 1 1", "4 1 7 4 1 2"]
The only line contains six integers $$$x$$$, $$$y$$$, $$$z$$$, $$$t_1$$$, $$$t_2$$$, $$$t_3$$$ ($$$1 \leq x, y, z, t_1, t_2, t_3 \leq 1000$$$)Β β€” the floor Masha is at, the floor Masha wants to get to, the floor the elevator is located on, the time it takes Masha to pass between two floors by stairs, the time it takes the elevator to pass between two floors and the time it takes for the elevator to close or open the doors. It is guaranteed that $$$x \ne y$$$.
05cffd59b28b9e026ca3203718b2e6ca
x,y,z,t1,t2,t3 = map(int,input().split()) y=abs(y-x) if abs(z-x)*t2+y*t2+3*t3 <= y*t1 : print('YES') else: print('NO')
["YES", "NO", "YES"]
Python
NoteIn the first example:If Masha goes by the stairs, the time she spends is $$$4 \cdot 4 = 16$$$, because she has to go $$$4$$$ times between adjacent floors and each time she spends $$$4$$$ seconds. If she chooses the elevator, she will have to wait $$$2$$$ seconds while the elevator leaves the $$$4$$$-th floor and goes to the $$$5$$$-th. After that the doors will be opening for another $$$1$$$ second. Then Masha will enter the elevator, and she will have to wait for $$$1$$$ second for the doors closing. Next, the elevator will spend $$$4 \cdot 2 = 8$$$ seconds going from the $$$5$$$-th floor to the $$$1$$$-st, because the elevator has to pass $$$4$$$ times between adjacent floors and spends $$$2$$$ seconds each time. And finally, it will take another $$$1$$$ second before the doors are open and Masha can come out. Thus, all the way by elevator will take $$$2 + 1 + 1 + 8 + 1 = 13$$$ seconds, which is less than $$$16$$$ seconds, so Masha has to choose the elevator.In the second example, it is more profitable for Masha to use the stairs, because it will take $$$13$$$ seconds to use the elevator, that is more than the $$$10$$$ seconds it will takes to go by foot.In the third example, the time it takes to use the elevator is equal to the time it takes to walk up by the stairs, and is equal to $$$12$$$ seconds. That means Masha will take the elevator.
If the time it will take to use the elevator is not greater than the time it will take to use the stairs, print Β«YESΒ» (without quotes), otherwise print Β«NO&gt; (without quotes). You can print each letter in any case (upper or lower).
Masha lives in a multi-storey building, where floors are numbered with positive integers. Two floors are called adjacent if their numbers differ by one. Masha decided to visit Egor. Masha lives on the floor $$$x$$$, Egor on the floor $$$y$$$ (not on the same floor with Masha).The house has a staircase and an elevator. If Masha uses the stairs, it takes $$$t_1$$$ seconds for her to walk between adjacent floors (in each direction). The elevator passes between adjacent floors (in each way) in $$$t_2$$$ seconds. The elevator moves with doors closed. The elevator spends $$$t_3$$$ seconds to open or close the doors. We can assume that time is not spent on any action except moving between adjacent floors and waiting for the doors to open or close. If Masha uses the elevator, it immediately goes directly to the desired floor.Coming out of the apartment on her floor, Masha noticed that the elevator is now on the floor $$$z$$$ and has closed doors. Now she has to choose whether to use the stairs or use the elevator. If the time that Masha needs to get to the Egor's floor by the stairs is strictly less than the time it will take her using the elevator, then she will use the stairs, otherwise she will choose the elevator.Help Mary to understand whether to use the elevator or the stairs.
[{"input": "5 1 4 4 2 1\r\n", "output": ["YES"]}, {"input": "1 6 6 2 1 1\r\n", "output": ["NO"]}, {"input": "4 1 7 4 1 2\r\n", "output": ["YES"]}, {"input": "749 864 931 266 94 891\r\n", "output": ["NO"]}, {"input": "719 137 307 244 724 777\r\n", "output": ["NO"]}, {"input": "608 11 980 338 208 78\r\n", "output": ["YES"]}, {"input": "571 695 153 288 64 421\r\n", "output": ["NO"]}, {"input": "837 544 703 808 549 694\r\n", "output": ["YES"]}, {"input": "271 634 606 95 39 523\r\n", "output": ["YES"]}, {"input": "1000 999 1000 1000 1000 1000\r\n", "output": ["NO"]}, {"input": "236 250 259 597 178 591\r\n", "output": ["NO"]}, {"input": "385 943 507 478 389 735\r\n", "output": ["NO"]}, {"input": "559 540 735 635 58 252\r\n", "output": ["NO"]}, {"input": "500 922 443 965 850 27\r\n", "output": ["NO"]}, {"input": "995 584 903 362 290 971\r\n", "output": ["NO"]}, {"input": "494 475 456 962 297 450\r\n", "output": ["NO"]}, {"input": "866 870 898 979 30 945\r\n", "output": ["YES"]}, {"input": "602 375 551 580 466 704\r\n", "output": ["YES"]}, {"input": "76 499 93 623 595 576\r\n", "output": ["YES"]}, {"input": "256 45 584 731 281 927\r\n", "output": ["YES"]}, {"input": "213 264 205 94 70 221\r\n", "output": ["YES"]}, {"input": "649 104 595 70 62 337\r\n", "output": ["YES"]}, {"input": "976 970 800 607 13 425\r\n", "output": ["YES"]}, {"input": "140 713 561 101 223 264\r\n", "output": ["NO"]}, {"input": "437 169 136 492 353 94\r\n", "output": ["NO"]}, {"input": "85 931 66 464 683 497\r\n", "output": ["NO"]}, {"input": "723 971 992 711 336 872\r\n", "output": ["YES"]}, {"input": "5 10 6 873 640 175\r\n", "output": ["YES"]}, {"input": "99 6 108 25 3 673\r\n", "output": ["YES"]}, {"input": "519 706 467 8 4 180\r\n", "output": ["YES"]}, {"input": "4 2 3 540 121 239\r\n", "output": ["YES"]}, {"input": "327 52 3 175 79 268\r\n", "output": ["YES"]}, {"input": "304 501 408 502 324 457\r\n", "output": ["NO"]}, {"input": "1 3 1 669 68 401\r\n", "output": ["NO"]}, {"input": "56 33 8 263 58 644\r\n", "output": ["NO"]}, {"input": "492 476 254 200 2 897\r\n", "output": ["YES"]}, {"input": "22 594 816 276 847 290\r\n", "output": ["NO"]}, {"input": "33 997 1000 901 87 189\r\n", "output": ["YES"]}, {"input": "1 1000 1 1000 1000 1\r\n", "output": ["NO"]}, {"input": "1 1000 1 1000 1 1\r\n", "output": ["YES"]}, {"input": "1 1000 1000 1 1000 1\r\n", "output": ["NO"]}, {"input": "352 165 275 781 542 987\r\n", "output": ["NO"]}, {"input": "188 288 112 595 331 414\r\n", "output": ["YES"]}, {"input": "239 240 239 996 767 1\r\n", "output": ["YES"]}, {"input": "997 998 998 267 97 26\r\n", "output": ["NO"]}, {"input": "321 123 321 352 349 199\r\n", "output": ["NO"]}, {"input": "239 932 239 377 373 925\r\n", "output": ["NO"]}, {"input": "301 300 300 338 152 13\r\n", "output": ["NO"]}, {"input": "333 334 333 572 331 1\r\n", "output": ["YES"]}, {"input": "1 2 1 1 1 1\r\n", "output": ["NO"]}, {"input": "1 2 1 25 1 10\r\n", "output": ["NO"]}, {"input": "1 5 1 5 4 2\r\n", "output": ["NO"]}, {"input": "1 101 1 2 1 50\r\n", "output": ["NO"]}, {"input": "1 2 1 13 2 4\r\n", "output": ["NO"]}, {"input": "1 3 1 10 5 4\r\n", "output": ["NO"]}, {"input": "1 2 1 10 2 3\r\n", "output": ["NO"]}, {"input": "5 100 10 100 1 1\r\n", "output": ["YES"]}, {"input": "3 2 3 16 12 2\r\n", "output": ["NO"]}, {"input": "2 3 2 3 1 1\r\n", "output": ["NO"]}, {"input": "2 4 2 2 1 1\r\n", "output": ["NO"]}, {"input": "1 2 1 10 5 2\r\n", "output": ["NO"]}]
100
100
100
[{'input': '5 100 10 100 1 1\r\n', 'output': ['YES']}, {'input': '1 2 1 10 5 2\r\n', 'output': ['NO']}, {'input': '1 2 1 10 2 3\r\n', 'output': ['NO']}, {'input': '301 300 300 338 152 13\r\n', 'output': ['NO']}, {'input': '1 1000 1000 1 1000 1\r\n', 'output': ['NO']}]
[{'input': '1 2 1 1 1 1\r\n', 'output': ['NO']}, {'input': '1 5 1 5 4 2\r\n', 'output': ['NO']}, {'input': '385 943 507 478 389 735\r\n', 'output': ['NO']}, {'input': '571 695 153 288 64 421\r\n', 'output': ['NO']}, {'input': '256 45 584 731 281 927\r\n', 'output': ['YES']}]
[{'input': '188 288 112 595 331 414\r\n', 'output': ['YES']}, {'input': '1 3 1 669 68 401\r\n', 'output': ['NO']}, {'input': '85 931 66 464 683 497\r\n', 'output': ['NO']}, {'input': '1 2 1 10 2 3\r\n', 'output': ['NO']}, {'input': '56 33 8 263 58 644\r\n', 'output': ['NO']}]
[{'input': '5 10 6 873 640 175\r\n', 'output': ['YES']}, {'input': '1 2 1 13 2 4\r\n', 'output': ['NO']}, {'input': '1 6 6 2 1 1\r\n', 'output': ['NO']}, {'input': '1 3 1 10 5 4\r\n', 'output': ['NO']}, {'input': '608 11 980 338 208 78\r\n', 'output': ['YES']}]
[{'input': '2 3 2 3 1 1\r\n', 'output': ['NO']}, {'input': '1 6 6 2 1 1\r\n', 'output': ['NO']}, {'input': '1 2 1 25 1 10\r\n', 'output': ['NO']}, {'input': '56 33 8 263 58 644\r\n', 'output': ['NO']}, {'input': '213 264 205 94 70 221\r\n', 'output': ['YES']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
376
100
100
100
["5 5 3 2", "7 5 5 2"]
The first line contains four space-separated integers n, a, b and c (1 ≀ n, a, b, c ≀ 4000) β€” the length of the original ribbon and the acceptable lengths of the ribbon pieces after the cutting, correspondingly. The numbers a, b and c can coincide.
062a171cc3ea717ea95ede9d7a1c3a43
def f(n): # Build maximum number of pieces for #length 1 upto n in bottom up manner dp = [float("-inf")] * (n + 1) # Base Case dp[0] = 0 # dp[i] gives maximum number of pieces that can # be obtained by cutting ribbon of length i into pieces # of length a, b or c # dp[i] = -inf if it is not possible to cut the ribbon into pieces for i in range(1, n + 1): for length in l: # Cut into pieces if only we dont have negative length of ribbon if i - length >= 0: dp[i] = max(dp[i], 1 + dp[i - length]) # return maximum number of pieces possible for ribbon with length n return dp[n] l = list(map(int, input().split())) n, l = l[0], l[1:] print(f(n))
["2", "2"]
Python
NoteIn the first example Polycarpus can cut the ribbon in such way: the first piece has length 2, the second piece has length 3.In the second example Polycarpus can cut the ribbon in such way: the first piece has length 5, the second piece has length 2.
Print a single number β€” the maximum possible number of ribbon pieces. It is guaranteed that at least one correct ribbon cutting exists.
Polycarpus has a ribbon, its length is n. He wants to cut the ribbon in a way that fulfils the following two conditions: After the cutting each ribbon piece should have length a, b or c. After the cutting the number of ribbon pieces should be maximum. Help Polycarpus and find the number of ribbon pieces after the required cutting.
[{"input": "5 5 3 2\r\n", "output": ["2"]}, {"input": "7 5 5 2\r\n", "output": ["2"]}, {"input": "4 4 4 4\r\n", "output": ["1"]}, {"input": "1 1 1 1\r\n", "output": ["1"]}, {"input": "4000 1 2 3\r\n", "output": ["4000"]}, {"input": "4000 3 4 5\r\n", "output": ["1333"]}, {"input": "10 3 4 5\r\n", "output": ["3"]}, {"input": "100 23 15 50\r\n", "output": ["2"]}, {"input": "3119 3515 1021 7\r\n", "output": ["11"]}, {"input": "918 102 1327 1733\r\n", "output": ["9"]}, {"input": "3164 42 430 1309\r\n", "output": ["15"]}, {"input": "3043 317 1141 2438\r\n", "output": ["7"]}, {"input": "26 1 772 2683\r\n", "output": ["26"]}, {"input": "370 2 1 15\r\n", "output": ["370"]}, {"input": "734 12 6 2\r\n", "output": ["367"]}, {"input": "418 18 14 17\r\n", "output": ["29"]}, {"input": "18 16 28 9\r\n", "output": ["2"]}, {"input": "14 6 2 17\r\n", "output": ["7"]}, {"input": "29 27 18 2\r\n", "output": ["2"]}, {"input": "29 12 7 10\r\n", "output": ["3"]}, {"input": "27 23 4 3\r\n", "output": ["9"]}, {"input": "5 14 5 2\r\n", "output": ["1"]}, {"input": "5 17 26 5\r\n", "output": ["1"]}, {"input": "9 1 10 3\r\n", "output": ["9"]}, {"input": "2 19 15 1\r\n", "output": ["2"]}, {"input": "4 6 4 9\r\n", "output": ["1"]}, {"input": "10 6 2 9\r\n", "output": ["5"]}, {"input": "2 2 9 6\r\n", "output": ["1"]}, {"input": "6 2 4 1\r\n", "output": ["6"]}, {"input": "27 24 5 27\r\n", "output": ["1"]}, {"input": "2683 83 26 2709\r\n", "output": ["101"]}, {"input": "728 412 789 158\r\n", "output": ["3"]}, {"input": "3964 4 2916 176\r\n", "output": ["991"]}, {"input": "3399 2035 2 3334\r\n", "output": ["683"]}, {"input": "3455 244 3301 3\r\n", "output": ["991"]}, {"input": "595 2263 3625 1\r\n", "output": ["595"]}, {"input": "4000 1 1 1\r\n", "output": ["4000"]}, {"input": "3999 2 2 3999\r\n", "output": ["1"]}, {"input": "25 6 8 11\r\n", "output": ["3"]}, {"input": "4000 500 1000 2000\r\n", "output": ["8"]}, {"input": "53 10 11 23\r\n", "output": ["5"]}, {"input": "100 100 1 1\r\n", "output": ["100"]}, {"input": "17 3 4 10\r\n", "output": ["5"]}, {"input": "413 101 102 105\r\n", "output": ["4"]}, {"input": "490 4 49 50\r\n", "output": ["111"]}, {"input": "3999 2 3 3\r\n", "output": ["1999"]}, {"input": "8 3 8 4\r\n", "output": ["2"]}, {"input": "5 1 3 3\r\n", "output": ["5"]}, {"input": "100 3 17 22\r\n", "output": ["27"]}, {"input": "4000 2 3 4\r\n", "output": ["2000"]}, {"input": "4000 3 3 5\r\n", "output": ["1332"]}, {"input": "13 4 6 7\r\n", "output": ["2"]}, {"input": "4000 5 2 2\r\n", "output": ["2000"]}, {"input": "3999 2 2 3\r\n", "output": ["1999"]}, {"input": "4000 33 7 3333\r\n", "output": ["564"]}, {"input": "60 33 20 9\r\n", "output": ["4"]}, {"input": "100 9 11 99\r\n", "output": ["10"]}, {"input": "2009 6 8 9\r\n", "output": ["334"]}]
100
100
100
[{'input': '27 23 4 3\r\n', 'output': ['9']}, {'input': '595 2263 3625 1\r\n', 'output': ['595']}, {'input': '370 2 1 15\r\n', 'output': ['370']}, {'input': '4000 5 2 2\r\n', 'output': ['2000']}, {'input': '7 5 5 2\r\n', 'output': ['2']}]
[{'input': '5 17 26 5\r\n', 'output': ['1']}, {'input': '2 2 9 6\r\n', 'output': ['1']}, {'input': '3999 2 2 3\r\n', 'output': ['1999']}, {'input': '5 14 5 2\r\n', 'output': ['1']}, {'input': '3399 2035 2 3334\r\n', 'output': ['683']}]
[{'input': '13 4 6 7\r\n', 'output': ['2']}, {'input': '5 5 3 2\r\n', 'output': ['2']}, {'input': '595 2263 3625 1\r\n', 'output': ['595']}, {'input': '4 6 4 9\r\n', 'output': ['1']}, {'input': '100 100 1 1\r\n', 'output': ['100']}]
[{'input': '13 4 6 7\r\n', 'output': ['2']}, {'input': '4000 3 4 5\r\n', 'output': ['1333']}, {'input': '17 3 4 10\r\n', 'output': ['5']}, {'input': '3999 2 2 3\r\n', 'output': ['1999']}, {'input': '60 33 20 9\r\n', 'output': ['4']}]
[{'input': '14 6 2 17\r\n', 'output': ['7']}, {'input': '2 2 9 6\r\n', 'output': ['1']}, {'input': '2683 83 26 2709\r\n', 'output': ['101']}, {'input': '8 3 8 4\r\n', 'output': ['2']}, {'input': '4000 3 4 5\r\n', 'output': ['1333']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
377
100
100
100
["3 4", "2 1"]
The only line contains two integers $$$N$$$ and $$$M$$$ ($$$1 \leq N, M \leq 10^9$$$) β€” the number of rows and columns in the grid.
a91aab4c0618d036c81022232814ef44
G = list(map(int, input().split())) N = G[0] M = G[1] if M > 1: print(N * (M - 1)) else: print(M * (N - 1))
["9", "1"]
Python
NoteThe picture below is the grid that Pak Chanek has in the first example. The picture below is an example of a tight domino in the grid.
An integer representing the number of distinct tight dominoes in the grid.
Pak Chanek has a grid that has $$$N$$$ rows and $$$M$$$ columns. Each row is numbered from $$$1$$$ to $$$N$$$ from top to bottom. Each column is numbered from $$$1$$$ to $$$M$$$ from left to right.Each tile in the grid contains a number. The numbers are arranged as follows: Row $$$1$$$ contains integers from $$$1$$$ to $$$M$$$ from left to right. Row $$$2$$$ contains integers from $$$M+1$$$ to $$$2 \times M$$$ from left to right. Row $$$3$$$ contains integers from $$$2 \times M+1$$$ to $$$3 \times M$$$ from left to right. And so on until row $$$N$$$. A domino is defined as two different tiles in the grid that touch by their sides. A domino is said to be tight if and only if the two numbers in the domino have a difference of exactly $$$1$$$. Count the number of distinct tight dominoes in the grid.Two dominoes are said to be distinct if and only if there exists at least one tile that is in one domino, but not in the other.
[{"input": "3 4\n", "output": ["\n9", "9", "9\n\n", "9\n\n", "\n\n\n9\n", "9\n", "\n9\n", "\n\n\n\n\n\n\n\n9\n", "9\n"]}, {"input": "2 1\n", "output": ["\n1", "1\n", "1", "1\n\n", "\n1\n", "1\n\n", "\n\n1\n", "1\n", "\n\n\n\n\n1\n"]}, {"input": "1 1\n", "output": ["\n0\n", "\n0", "0\n\n", "0\n\n", "0\n", "0\n", "\n\n0\n", "0"]}, {"input": "1 2\n", "output": ["\n1", "1\n", "1", "1\n\n", "\n1\n", "1\n\n", "\n\n1\n", "1\n"]}, {"input": "2 2\n", "output": ["2\n", "2", "\n\n\n\n\n2\n", "2\n\n", "\n\n2\n", "\n2", "2\n\n", "\n2\n", "2\n"]}, {"input": "1 1000000000\n", "output": ["999999999\n", "\n999999999\n", "\n999999999", "999999999\n", "999999999\n\n", "999999999", "999999999\n\n"]}, {"input": "1 999999997\n", "output": ["999999996\n\n", "\n999999996", "999999996\n\n", "999999996\n", "999999996\n", "\n999999996\n", "999999996"]}, {"input": "1 589284012\n", "output": ["589284011\n", "\n589284011", "589284011", "589284011\n\n", "589284011\n\n", "\n589284011\n", "589284011\n"]}, {"input": "1000000000 1\n", "output": ["999999999\n", "\n999999999\n", "\n999999999", "999999999\n", "999999999\n\n", "999999999", "999999999\n\n"]}, {"input": "999999999 1\n", "output": ["\n999999998", "\n999999998\n", "999999998", "999999998\n\n", "999999998\n", "999999998\n\n", "999999998\n"]}, {"input": "636562060 1\n", "output": ["\n636562059", "636562059\n\n", "636562059\n", "636562059", "\n636562059\n", "636562059\n", "636562059\n\n"]}, {"input": "2 1000000000\n", "output": ["1999999998\n\n", "\n1999999998\n", "1999999998\n", "1999999998", "1999999998\n", "\n1999999998", "1999999998\n\n"]}, {"input": "1000000000 2\n", "output": ["1000000000", "1000000000\n\n", "1000000000\n", "1000000000\n", "\n1000000000", "\n1000000000\n", "1000000000\n\n"]}, {"input": "30001 30001\n", "output": ["900030000\n", "\n900030000\n", "900030000", "\n900030000", "900030000\n\n", "900030000\n\n", "900030000\n"]}, {"input": "1000000000 1000000000\n", "output": ["999999999000000000\n", "999999999000000000\n\n", "999999999000000000\n\n", "999999999000000000\n", "999999999000000000"]}, {"input": "767928735 1000000000\n", "output": ["767928734232071265\n\n", "767928734232071265\n", "767928734232071265\n\n", "767928734232071265\n", "767928734232071265"]}, {"input": "1000000000 906523442\n", "output": ["906523441000000000\n\n", "906523441000000000", "906523441000000000\n", "906523441000000000\n\n", "906523441000000000\n"]}, {"input": "647242241 921242095\n", "output": ["596266797424092654\n", "596266797424092654\n\n", "596266797424092654\n", "596266797424092654", "596266797424092654\n\n"]}]
100
100
100
[{'input': '1000000000 1000000000\n', 'output': ['999999999000000000\n', '999999999000000000\n\n', '999999999000000000\n\n', '999999999000000000\n', '999999999000000000']}, {'input': '2 1\n', 'output': ['\n1', '1\n', '1', '1\n\n', '\n1\n', '1\n\n', '\n\n1\n', '1\n', '\n\n\n\n\n1\n']}, {'input': '647242241 921242095\n', 'output': ['596266797424092654\n', '596266797424092654\n\n', '596266797424092654\n', '596266797424092654', '596266797424092654\n\n']}, {'input': '1000000000 2\n', 'output': ['1000000000', '1000000000\n\n', '1000000000\n', '1000000000\n', '\n1000000000', '\n1000000000\n', '1000000000\n\n']}, {'input': '767928735 1000000000\n', 'output': ['767928734232071265\n\n', '767928734232071265\n', '767928734232071265\n\n', '767928734232071265\n', '767928734232071265']}]
[{'input': '1 1\n', 'output': ['\n0\n', '\n0', '0\n\n', '0\n\n', '0\n', '0\n', '\n\n0\n', '0']}, {'input': '1 2\n', 'output': ['\n1', '1\n', '1', '1\n\n', '\n1\n', '1\n\n', '\n\n1\n', '1\n']}, {'input': '647242241 921242095\n', 'output': ['596266797424092654\n', '596266797424092654\n\n', '596266797424092654\n', '596266797424092654', '596266797424092654\n\n']}, {'input': '1000000000 1\n', 'output': ['999999999\n', '\n999999999\n', '\n999999999', '999999999\n', '999999999\n\n', '999999999', '999999999\n\n']}, {'input': '1 589284012\n', 'output': ['589284011\n', '\n589284011', '589284011', '589284011\n\n', '589284011\n\n', '\n589284011\n', '589284011\n']}]
[{'input': '1000000000 906523442\n', 'output': ['906523441000000000\n\n', '906523441000000000', '906523441000000000\n', '906523441000000000\n\n', '906523441000000000\n']}, {'input': '2 2\n', 'output': ['2\n', '2', '\n\n\n\n\n2\n', '2\n\n', '\n\n2\n', '\n2', '2\n\n', '\n2\n', '2\n']}, {'input': '767928735 1000000000\n', 'output': ['767928734232071265\n\n', '767928734232071265\n', '767928734232071265\n\n', '767928734232071265\n', '767928734232071265']}, {'input': '1 2\n', 'output': ['\n1', '1\n', '1', '1\n\n', '\n1\n', '1\n\n', '\n\n1\n', '1\n']}, {'input': '1000000000 1\n', 'output': ['999999999\n', '\n999999999\n', '\n999999999', '999999999\n', '999999999\n\n', '999999999', '999999999\n\n']}]
[{'input': '1 1000000000\n', 'output': ['999999999\n', '\n999999999\n', '\n999999999', '999999999\n', '999999999\n\n', '999999999', '999999999\n\n']}, {'input': '30001 30001\n', 'output': ['900030000\n', '\n900030000\n', '900030000', '\n900030000', '900030000\n\n', '900030000\n\n', '900030000\n']}, {'input': '999999999 1\n', 'output': ['\n999999998', '\n999999998\n', '999999998', '999999998\n\n', '999999998\n', '999999998\n\n', '999999998\n']}, {'input': '1000000000 1\n', 'output': ['999999999\n', '\n999999999\n', '\n999999999', '999999999\n', '999999999\n\n', '999999999', '999999999\n\n']}, {'input': '1 589284012\n', 'output': ['589284011\n', '\n589284011', '589284011', '589284011\n\n', '589284011\n\n', '\n589284011\n', '589284011\n']}]
[{'input': '2 1000000000\n', 'output': ['1999999998\n\n', '\n1999999998\n', '1999999998\n', '1999999998', '1999999998\n', '\n1999999998', '1999999998\n\n']}, {'input': '767928735 1000000000\n', 'output': ['767928734232071265\n\n', '767928734232071265\n', '767928734232071265\n\n', '767928734232071265\n', '767928734232071265']}, {'input': '1 589284012\n', 'output': ['589284011\n', '\n589284011', '589284011', '589284011\n\n', '589284011\n\n', '\n589284011\n', '589284011\n']}, {'input': '2 1\n', 'output': ['\n1', '1\n', '1', '1\n\n', '\n1\n', '1\n\n', '\n\n1\n', '1\n', '\n\n\n\n\n1\n']}, {'input': '1000000000 1000000000\n', 'output': ['999999999000000000\n', '999999999000000000\n\n', '999999999000000000\n\n', '999999999000000000\n', '999999999000000000']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
378
100
100
100
["3", "11"]
The only line of the input contains a single integer n (1 ≀ n ≀ 1000)Β β€” the position of the digit you need to print.
2d46e34839261eda822f0c23c6e19121
n=int(input()) st="" for i in range(1,1000): st=st+str(i) print(st[n-1] )
["3", "0"]
Python
NoteIn the first sample the digit at position 3 is '3', as both integers 1 and 2 consist on one digit.In the second sample, the digit at position 11 is '0', it belongs to the integer 10.
Print the n-th digit of the line.
Every year, hundreds of people come to summer camps, they learn new algorithms and solve hard problems.This is your first year at summer camp, and you are asked to solve the following problem. All integers starting with 1 are written in one line. The prefix of these line is "123456789101112131415...". Your task is to print the n-th digit of this string (digits are numbered starting with 1.
[{"input": "3\r\n", "output": ["3"]}, {"input": "11\r\n", "output": ["0"]}, {"input": "12\r\n", "output": ["1"]}, {"input": "13\r\n", "output": ["1"]}, {"input": "29\r\n", "output": ["9"]}, {"input": "30\r\n", "output": ["2"]}, {"input": "1000\r\n", "output": ["3"]}, {"input": "999\r\n", "output": ["9"]}, {"input": "100\r\n", "output": ["5"]}, {"input": "123\r\n", "output": ["6"]}, {"input": "8\r\n", "output": ["8"]}, {"input": "157\r\n", "output": ["3"]}, {"input": "289\r\n", "output": ["1"]}, {"input": "179\r\n", "output": ["4"]}, {"input": "942\r\n", "output": ["0"]}, {"input": "879\r\n", "output": ["9"]}, {"input": "394\r\n", "output": ["1"]}, {"input": "423\r\n", "output": ["7"]}, {"input": "952\r\n", "output": ["3"]}, {"input": "121\r\n", "output": ["5"]}, {"input": "613\r\n", "output": ["2"]}, {"input": "945\r\n", "output": ["1"]}, {"input": "270\r\n", "output": ["6"]}, {"input": "781\r\n", "output": ["2"]}, {"input": "453\r\n", "output": ["7"]}, {"input": "171\r\n", "output": ["0"]}, {"input": "643\r\n", "output": ["2"]}, {"input": "570\r\n", "output": ["6"]}, {"input": "750\r\n", "output": ["6"]}, {"input": "500\r\n", "output": ["0"]}, {"input": "2\r\n", "output": ["2"]}, {"input": "1\r\n", "output": ["1"]}, {"input": "108\r\n", "output": ["5"]}, {"input": "189\r\n", "output": ["9"]}, {"input": "491\r\n", "output": ["0"]}, {"input": "191\r\n", "output": ["0"]}]
100
100
100
[{'input': '3\r\n', 'output': ['3']}, {'input': '270\r\n', 'output': ['6']}, {'input': '945\r\n', 'output': ['1']}, {'input': '952\r\n', 'output': ['3']}, {'input': '423\r\n', 'output': ['7']}]
[{'input': '100\r\n', 'output': ['5']}, {'input': '500\r\n', 'output': ['0']}, {'input': '29\r\n', 'output': ['9']}, {'input': '394\r\n', 'output': ['1']}, {'input': '157\r\n', 'output': ['3']}]
[{'input': '8\r\n', 'output': ['8']}, {'input': '394\r\n', 'output': ['1']}, {'input': '121\r\n', 'output': ['5']}, {'input': '750\r\n', 'output': ['6']}, {'input': '11\r\n', 'output': ['0']}]
[{'input': '270\r\n', 'output': ['6']}, {'input': '13\r\n', 'output': ['1']}, {'input': '29\r\n', 'output': ['9']}, {'input': '289\r\n', 'output': ['1']}, {'input': '121\r\n', 'output': ['5']}]
[{'input': '100\r\n', 'output': ['5']}, {'input': '500\r\n', 'output': ['0']}, {'input': '191\r\n', 'output': ['0']}, {'input': '491\r\n', 'output': ['0']}, {'input': '8\r\n', 'output': ['8']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
379
100
100
100
["3\n0 0 1\n2 0 1\n4 0 1", "3\n0 0 2\n3 0 2\n6 0 2", "3\n0 0 2\n2 0 2\n1 1 2"]
The first line of input contains one integer n (1 ≀ n ≀ 3), denoting the number of circles. The following n lines each contains three space-separated integers x, y and r ( - 10 ≀ x, y ≀ 10, 1 ≀ r ≀ 10), describing a circle whose center is (x, y) and the radius is r. No two circles have the same x, y and r at the same time.
bda5879e94a82c6fd499796f258c4691
from math import sqrt pt = lambda *a, **k: print(*a, **k, flush=True) rd = lambda: map(int, input().split()) n = int(input()) def f(x1, y1, r1, x2, y2, r2): a = (r1 + r2) ** 2 b = (r1 - r2) ** 2 d = (x1 - x2) ** 2 + (y1 - y2) ** 2 if d > a: return 1 elif d == a: return 4 elif d < b: return 3 elif d == b: return 5 else: return 2 def g(x1, y1, r1, x2, y2, r2): ds = (x1 - x2) ** 2 + (y1 - y2) ** 2 d = sqrt(ds) A = (r1 ** 2 - r2 ** 2 + ds) / (2 * d) h = sqrt(r1 ** 2 - A ** 2) x = x1 + A * (x2 - x1) / d y = y1 + A * (y2 - y1) / d x3 = x - h * (y2 - y1) / d y3 = y + h * (x2 - x1) / d x4 = x + h * (y2 - y1) / d y4 = y - h * (x2 - x1) / d return x3, y3, x4, y4 if n is 1: pt(2) if n is 2: x1, y1, r1 = rd() x2, y2, r2 = rd() a = f(x1, y1, r1, x2, y2, r2) pt(4 if a is 2 else 3) if n is 3: x1, y1, r1 = rd() x2, y2, r2 = rd() x3, y3, r3 = rd() a = f(x1, y1, r1, x2, y2, r2) b = f(x1, y1, r1, x3, y3, r3) c = f(x3, y3, r3, x2, y2, r2) t = [a, b, c] t.sort() a, b, c = t if a is 1 and b is 1 and c in [1, 3, 4, 5]: pt(4) if a is 1 and b is 1 and c is 2: pt(5) if a is 1 and b is 2 and c is 2: pt(6) if a is 1 and b is 2 and c in [3, 4, 5]: pt(5) if a is 1 and b in [3, 4, 5]: pt(4) if a is 2 and b is 2 and c is 2: x4, y4, x5, y5 = g(x1, y1, r1, x2, y2, r2) r = 8 if abs((x4 - x3) ** 2 + (y4 - y3) ** 2 - r3 ** 2) < 1e-6: r -= 1 if abs((x5 - x3) ** 2 + (y5 - y3) ** 2 - r3 ** 2) < 1e-6: r -= 1 pt(r) if a is 2 and b is 2 and c is 3: pt(6) if a is 2 and b is 2 and c in [4, 5]: x4, y4, x5, y5 = g(x1, y1, r1, x2, y2, r2) if abs((x4 - x3) ** 2 + (y4 - y3) ** 2 - r3 ** 2) < 1e-6 or abs((x5 - x3) ** 2 + (y5 - y3) ** 2 - r3 ** 2) < 1e-6: pt(6) else: pt(7) if a is 2 and b is 3: pt(5) if a is 2 and b in [4, 5]: pt(6) if a is 3 and b in [3, 4, 5]: pt(4) if a is 4 and b is 4 and c is 4: pt(5) if a is 4 and b is 4 and c is 5: pt(4) if a is 4 and b is 5 and c is 5: pt(5) if a is 5 and b is 5 and c is 5: pt(4)
["4", "6", "8"]
Python
NoteFor the first example, For the second example, For the third example,
Print a single integerΒ β€” the number of regions on the plane.
Firecrackers scare Nian the monster, but they're wayyyyy too noisy! Maybe fireworks make a nice complement.Little Tommy is watching a firework show. As circular shapes spread across the sky, a splendid view unfolds on the night of Lunar New Year's eve.A wonder strikes Tommy. How many regions are formed by the circles on the sky? We consider the sky as a flat plane. A region is a connected part of the plane with positive area, whose bound consists of parts of bounds of the circles and is a curve or several curves without self-intersections, and that does not contain any curve other than its boundaries. Note that exactly one of the regions extends infinitely.
[{"input": "3\r\n0 0 1\r\n2 0 1\r\n4 0 1\r\n", "output": ["4"]}, {"input": "3\r\n0 0 2\r\n3 0 2\r\n6 0 2\r\n", "output": ["6"]}, {"input": "3\r\n0 0 2\r\n2 0 2\r\n1 1 2\r\n", "output": ["8"]}, {"input": "1\r\n0 0 10\r\n", "output": ["2"]}, {"input": "2\r\n-10 10 1\r\n10 -10 1\r\n", "output": ["3"]}, {"input": "2\r\n-6 6 9\r\n3 -6 6\r\n", "output": ["3"]}, {"input": "2\r\n-10 -10 10\r\n10 10 10\r\n", "output": ["3"]}, {"input": "3\r\n-4 1 5\r\n-7 7 10\r\n-3 -4 8\r\n", "output": ["8"]}, {"input": "3\r\n-2 8 10\r\n3 -2 5\r\n3 1 3\r\n", "output": ["8"]}, {"input": "3\r\n0 0 2\r\n0 0 4\r\n3 0 2\r\n", "output": ["6"]}, {"input": "3\r\n8 5 7\r\n7 3 7\r\n5 2 5\r\n", "output": ["8"]}, {"input": "3\r\n-6 5 7\r\n1 -2 7\r\n7 9 7\r\n", "output": ["8"]}, {"input": "3\r\n1 -7 10\r\n-7 9 10\r\n-2 -1 4\r\n", "output": ["8"]}, {"input": "3\r\n-2 -3 5\r\n-6 1 7\r\n5 4 5\r\n", "output": ["7"]}, {"input": "3\r\n3 -2 7\r\n-1 2 5\r\n-4 1 3\r\n", "output": ["7"]}, {"input": "3\r\n4 5 10\r\n1 -1 5\r\n-1 -5 5\r\n", "output": ["6"]}, {"input": "3\r\n-1 0 5\r\n-2 1 5\r\n-5 4 7\r\n", "output": ["6"]}, {"input": "3\r\n-3 3 5\r\n1 -1 7\r\n2 5 10\r\n", "output": ["7"]}, {"input": "3\r\n-4 4 3\r\n5 6 4\r\n1 -5 9\r\n", "output": ["6"]}, {"input": "3\r\n-4 4 4\r\n2 4 2\r\n-1 0 6\r\n", "output": ["7"]}, {"input": "3\r\n-10 4 10\r\n10 4 10\r\n0 -7 10\r\n", "output": ["7"]}, {"input": "3\r\n-4 -5 3\r\n-3 -4 1\r\n-6 0 9\r\n", "output": ["4"]}, {"input": "3\r\n4 0 1\r\n-1 1 9\r\n0 3 6\r\n", "output": ["4"]}, {"input": "3\r\n-3 -2 3\r\n-4 -6 3\r\n-6 -4 9\r\n", "output": ["5"]}, {"input": "3\r\n-3 6 4\r\n-1 4 7\r\n0 2 1\r\n", "output": ["4"]}, {"input": "3\r\n1 -1 2\r\n-6 -3 10\r\n-1 3 1\r\n", "output": ["4"]}, {"input": "3\r\n-2 -5 4\r\n-5 -1 5\r\n-6 -2 9\r\n", "output": ["5"]}, {"input": "3\r\n5 -2 3\r\n1 1 2\r\n4 -3 7\r\n", "output": ["4"]}, {"input": "3\r\n2 -6 3\r\n-2 0 1\r\n1 -4 6\r\n", "output": ["4"]}, {"input": "3\r\n-1 -2 3\r\n-5 -4 4\r\n-6 -5 8\r\n", "output": ["6"]}, {"input": "3\r\n-1 3 4\r\n-2 0 8\r\n3 6 1\r\n", "output": ["5"]}, {"input": "3\r\n-4 -1 2\r\n-6 -5 10\r\n1 3 1\r\n", "output": ["5"]}, {"input": "3\r\n-6 2 1\r\n0 -6 9\r\n-5 -3 2\r\n", "output": ["4"]}, {"input": "3\r\n-4 -5 4\r\n6 5 2\r\n-6 -6 7\r\n", "output": ["4"]}, {"input": "3\r\n-5 -2 3\r\n-1 1 8\r\n-4 -3 1\r\n", "output": ["4"]}, {"input": "3\r\n-3 -1 8\r\n0 3 3\r\n2 2 2\r\n", "output": ["5"]}, {"input": "3\r\n3 4 9\r\n2 -3 1\r\n-1 1 4\r\n", "output": ["4"]}, {"input": "3\r\n-5 -6 5\r\n-2 -2 10\r\n-3 4 3\r\n", "output": ["4"]}, {"input": "3\r\n2 6 5\r\n1 -1 5\r\n-2 3 10\r\n", "output": ["6"]}, {"input": "3\r\n3 -5 5\r\n-1 -2 10\r\n-5 1 5\r\n", "output": ["5"]}, {"input": "3\r\n0 0 6\r\n-4 -3 1\r\n-3 4 1\r\n", "output": ["4"]}, {"input": "3\r\n-5 -2 10\r\n3 -1 3\r\n-1 1 5\r\n", "output": ["7"]}, {"input": "3\r\n-1 -1 10\r\n-5 2 5\r\n1 -6 5\r\n", "output": ["6"]}, {"input": "3\r\n-4 1 1\r\n-2 -6 7\r\n-6 -3 2\r\n", "output": ["5"]}, {"input": "3\r\n3 -4 2\r\n-1 -1 3\r\n-5 2 8\r\n", "output": ["4"]}, {"input": "3\r\n6 -1 1\r\n1 1 4\r\n-2 5 9\r\n", "output": ["4"]}, {"input": "3\r\n2 -6 1\r\n-6 5 8\r\n-2 2 3\r\n", "output": ["4"]}, {"input": "3\r\n-6 -6 8\r\n-4 -5 1\r\n-1 -4 6\r\n", "output": ["5"]}, {"input": "3\r\n-4 -5 7\r\n2 -3 6\r\n-2 0 1\r\n", "output": ["5"]}, {"input": "3\r\n1 -5 1\r\n4 -3 3\r\n-6 -6 10\r\n", "output": ["6"]}, {"input": "3\r\n2 -1 4\r\n-1 -5 1\r\n-5 0 9\r\n", "output": ["5"]}, {"input": "3\r\n-6 -6 9\r\n4 -3 4\r\n-3 -1 1\r\n", "output": ["5"]}, {"input": "3\r\n-4 -2 7\r\n-6 -1 7\r\n-3 -5 2\r\n", "output": ["5"]}, {"input": "3\r\n2 -2 8\r\n6 -5 3\r\n3 -1 8\r\n", "output": ["6"]}, {"input": "3\r\n-3 1 4\r\n-1 6 9\r\n-6 5 9\r\n", "output": ["7"]}, {"input": "3\r\n-4 -1 5\r\n-1 3 10\r\n4 5 5\r\n", "output": ["6"]}, {"input": "3\r\n-2 2 3\r\n0 -6 3\r\n-6 -1 8\r\n", "output": ["5"]}, {"input": "3\r\n-1 -3 9\r\n0 -2 7\r\n-6 -6 10\r\n", "output": ["6"]}, {"input": "3\r\n-5 -6 8\r\n-2 -1 7\r\n1 -5 2\r\n", "output": ["7"]}, {"input": "3\r\n-5 3 4\r\n1 4 4\r\n-6 -6 10\r\n", "output": ["8"]}, {"input": "3\r\n6 2 6\r\n-6 5 7\r\n-2 -4 4\r\n", "output": ["7"]}, {"input": "3\r\n5 2 4\r\n-3 6 4\r\n-6 -6 10\r\n", "output": ["6"]}, {"input": "3\r\n5 -5 1\r\n-3 1 9\r\n2 -6 6\r\n", "output": ["5"]}, {"input": "3\r\n1 6 4\r\n4 2 9\r\n-4 -6 9\r\n", "output": ["6"]}, {"input": "3\r\n-6 -4 9\r\n0 4 1\r\n-1 3 1\r\n", "output": ["7"]}, {"input": "3\r\n-3 -6 4\r\n1 -3 1\r\n-2 1 4\r\n", "output": ["6"]}, {"input": "3\r\n-4 0 6\r\n-3 -6 6\r\n4 6 4\r\n", "output": ["5"]}, {"input": "3\r\n6 -5 1\r\n3 1 9\r\n-6 -6 9\r\n", "output": ["5"]}, {"input": "3\r\n-5 -6 7\r\n-6 0 6\r\n-2 3 1\r\n", "output": ["5"]}, {"input": "3\r\n-6 -6 9\r\n6 -5 3\r\n-5 -1 9\r\n", "output": ["6"]}, {"input": "3\r\n2 -5 2\r\n-5 -6 3\r\n-2 -2 3\r\n", "output": ["5"]}, {"input": "3\r\n-6 -6 9\r\n6 -4 1\r\n-3 -2 8\r\n", "output": ["5"]}, {"input": "3\r\n-6 -2 1\r\n-3 -1 1\r\n-2 1 4\r\n", "output": ["4"]}, {"input": "3\r\n5 -2 6\r\n-1 6 4\r\n2 2 1\r\n", "output": ["4"]}, {"input": "3\r\n2 1 2\r\n-6 -1 6\r\n6 4 7\r\n", "output": ["4"]}, {"input": "3\r\n0 4 4\r\n-6 -4 6\r\n-4 -2 4\r\n", "output": ["7"]}, {"input": "3\r\n5 -6 6\r\n-3 0 4\r\n-4 6 9\r\n", "output": ["6"]}, {"input": "3\r\n2 4 4\r\n3 -6 4\r\n-4 -4 6\r\n", "output": ["5"]}, {"input": "3\r\n6 -3 6\r\n2 0 1\r\n-6 6 9\r\n", "output": ["4"]}, {"input": "3\r\n-6 6 9\r\n6 1 4\r\n2 0 1\r\n", "output": ["6"]}, {"input": "3\r\n0 -5 2\r\n-6 3 2\r\n-3 -1 3\r\n", "output": ["4"]}, {"input": "3\r\n5 -4 1\r\n3 -5 5\r\n-3 3 5\r\n", "output": ["4"]}, {"input": "3\r\n1 3 1\r\n2 -6 7\r\n-3 6 6\r\n", "output": ["4"]}, {"input": "3\r\n-3 -4 2\r\n-6 -2 2\r\n0 0 3\r\n", "output": ["5"]}, {"input": "3\r\n-6 -2 7\r\n5 0 2\r\n2 4 3\r\n", "output": ["4"]}, {"input": "3\r\n-6 6 4\r\n-2 3 1\r\n-1 -3 1\r\n", "output": ["4"]}, {"input": "3\r\n-1 -5 2\r\n-6 -6 9\r\n4 4 5\r\n", "output": ["4"]}, {"input": "3\r\n-5 3 6\r\n4 -3 2\r\n-2 -1 1\r\n", "output": ["4"]}, {"input": "3\r\n-1 5 6\r\n-3 -4 5\r\n-6 -6 6\r\n", "output": ["6"]}, {"input": "3\r\n-2 -5 3\r\n1 -1 2\r\n-3 4 6\r\n", "output": ["5"]}, {"input": "3\r\n-6 -6 7\r\n1 4 2\r\n0 -5 2\r\n", "output": ["5"]}, {"input": "3\r\n-5 3 5\r\n5 -2 6\r\n-3 4 4\r\n", "output": ["5"]}, {"input": "3\r\n-2 0 2\r\n1 4 3\r\n-6 3 3\r\n", "output": ["4"]}, {"input": "3\r\n-4 3 4\r\n0 0 1\r\n-5 -4 3\r\n", "output": ["4"]}, {"input": "3\r\n2 5 4\r\n-6 -6 7\r\n1 6 6\r\n", "output": ["4"]}, {"input": "3\r\n-6 -6 8\r\n5 6 8\r\n2 2 3\r\n", "output": ["4"]}, {"input": "3\r\n6 1 2\r\n-6 -6 7\r\n5 -1 2\r\n", "output": ["5"]}, {"input": "3\r\n1 6 4\r\n-3 -6 5\r\n4 2 1\r\n", "output": ["4"]}, {"input": "3\r\n-5 5 4\r\n2 3 3\r\n-6 -6 7\r\n", "output": ["4"]}, {"input": "3\r\n-6 5 2\r\n-6 -1 4\r\n2 5 6\r\n", "output": ["5"]}, {"input": "3\r\n2 -2 5\r\n2 0 3\r\n2 -1 4\r\n", "output": ["4"]}, {"input": "3\r\n4 -3 8\r\n3 -3 7\r\n-3 -3 1\r\n", "output": ["4"]}, {"input": "3\r\n2 0 2\r\n4 0 4\r\n0 -4 4\r\n", "output": ["6"]}, {"input": "3\r\n-1 0 5\r\n5 0 5\r\n5 8 5\r\n", "output": ["6"]}, {"input": "3\r\n1 0 1\r\n-1 0 1\r\n0 1 1\r\n", "output": ["6"]}, {"input": "3\r\n2 0 2\r\n4 0 4\r\n0 -4 5\r\n", "output": ["7"]}, {"input": "3\r\n2 0 2\r\n4 0 4\r\n0 -4 3\r\n", "output": ["7"]}, {"input": "3\r\n2 0 2\r\n4 0 4\r\n0 -4 2\r\n", "output": ["5"]}, {"input": "3\r\n2 0 2\r\n4 0 4\r\n0 -4 8\r\n", "output": ["5"]}, {"input": "3\r\n-9 0 9\r\n-9 10 10\r\n9 4 10\r\n", "output": ["8"]}, {"input": "3\r\n-9 10 10\r\n9 4 10\r\n0 -2 6\r\n", "output": ["8"]}, {"input": "3\r\n9 5 10\r\n8 -2 9\r\n-9 -1 9\r\n", "output": ["8"]}, {"input": "3\r\n-4 -2 9\r\n8 4 9\r\n-10 10 10\r\n", "output": ["8"]}, {"input": "3\r\n1 8 2\r\n3 8 1\r\n3 -2 9\r\n", "output": ["7"]}, {"input": "3\r\n0 0 1\r\n0 3 2\r\n4 0 3\r\n", "output": ["5"]}, {"input": "3\r\n-3 0 5\r\n3 0 5\r\n0 0 4\r\n", "output": ["6"]}, {"input": "3\r\n4 1 5\r\n-4 1 5\r\n0 0 4\r\n", "output": ["7"]}, {"input": "3\r\n0 0 1\r\n0 1 1\r\n0 2 1\r\n", "output": ["7"]}, {"input": "3\r\n0 0 5\r\n1 7 5\r\n7 7 5\r\n", "output": ["7"]}, {"input": "2\r\n0 0 2\r\n3 0 2\r\n", "output": ["4"]}, {"input": "3\r\n0 0 2\r\n1 0 1\r\n-1 0 1\r\n", "output": ["5"]}, {"input": "3\r\n-2 0 2\r\n2 0 2\r\n0 0 4\r\n", "output": ["5"]}, {"input": "3\r\n3 4 5\r\n-3 4 5\r\n0 -5 5\r\n", "output": ["7"]}, {"input": "3\r\n0 0 1\r\n1 0 1\r\n2 0 1\r\n", "output": ["7"]}, {"input": "3\r\n2 2 4\r\n8 2 4\r\n5 10 5\r\n", "output": ["8"]}, {"input": "3\r\n0 0 5\r\n4 0 3\r\n8 0 5\r\n", "output": ["6"]}, {"input": "3\r\n0 0 1\r\n2 0 3\r\n-2 0 3\r\n", "output": ["6"]}, {"input": "3\r\n0 0 1\r\n2 0 1\r\n1 0 2\r\n", "output": ["5"]}, {"input": "3\r\n0 0 5\r\n8 0 5\r\n4 0 3\r\n", "output": ["6"]}, {"input": "3\r\n-10 0 2\r\n-8 2 2\r\n-4 -3 5\r\n", "output": ["7"]}]
100
100
100
[{'input': '3\r\n-4 -5 7\r\n2 -3 6\r\n-2 0 1\r\n', 'output': ['5']}, {'input': '3\r\n-4 1 1\r\n-2 -6 7\r\n-6 -3 2\r\n', 'output': ['5']}, {'input': '3\r\n-6 -2 1\r\n-3 -1 1\r\n-2 1 4\r\n', 'output': ['4']}, {'input': '3\r\n-4 -5 4\r\n6 5 2\r\n-6 -6 7\r\n', 'output': ['4']}, {'input': '3\r\n2 2 4\r\n8 2 4\r\n5 10 5\r\n', 'output': ['8']}]
[{'input': '3\r\n0 0 1\r\n2 0 1\r\n4 0 1\r\n', 'output': ['4']}, {'input': '3\r\n0 0 2\r\n2 0 2\r\n1 1 2\r\n', 'output': ['8']}, {'input': '3\r\n1 3 1\r\n2 -6 7\r\n-3 6 6\r\n', 'output': ['4']}, {'input': '3\r\n1 -1 2\r\n-6 -3 10\r\n-1 3 1\r\n', 'output': ['4']}, {'input': '3\r\n-4 -2 9\r\n8 4 9\r\n-10 10 10\r\n', 'output': ['8']}]
[{'input': '3\r\n0 0 2\r\n1 0 1\r\n-1 0 1\r\n', 'output': ['5']}, {'input': '3\r\n0 0 6\r\n-4 -3 1\r\n-3 4 1\r\n', 'output': ['4']}, {'input': '3\r\n3 -2 7\r\n-1 2 5\r\n-4 1 3\r\n', 'output': ['7']}, {'input': '3\r\n-6 -6 9\r\n4 -3 4\r\n-3 -1 1\r\n', 'output': ['5']}, {'input': '3\r\n-4 3 4\r\n0 0 1\r\n-5 -4 3\r\n', 'output': ['4']}]
[{'input': '3\r\n1 8 2\r\n3 8 1\r\n3 -2 9\r\n', 'output': ['7']}, {'input': '3\r\n0 0 2\r\n2 0 2\r\n1 1 2\r\n', 'output': ['8']}, {'input': '3\r\n-5 3 6\r\n4 -3 2\r\n-2 -1 1\r\n', 'output': ['4']}, {'input': '3\r\n5 -4 1\r\n3 -5 5\r\n-3 3 5\r\n', 'output': ['4']}, {'input': '3\r\n-1 0 5\r\n-2 1 5\r\n-5 4 7\r\n', 'output': ['6']}]
[{'input': '3\r\n-4 3 4\r\n0 0 1\r\n-5 -4 3\r\n', 'output': ['4']}, {'input': '3\r\n0 4 4\r\n-6 -4 6\r\n-4 -2 4\r\n', 'output': ['7']}, {'input': '3\r\n-1 5 6\r\n-3 -4 5\r\n-6 -6 6\r\n', 'output': ['6']}, {'input': '3\r\n-2 -5 4\r\n-5 -1 5\r\n-6 -2 9\r\n', 'output': ['5']}, {'input': '3\r\n-2 0 2\r\n2 0 2\r\n0 0 4\r\n', 'output': ['5']}]
100
100
100
100
100
76.47
72.94
77.65
80
74.12
68.52
62.96
68.52
72.22
66.67
380
100
76.236
67.778
["10 5", "6 12", "5 13"]
The single line contains numbers n and x (1 ≀ n ≀ 105, 1 ≀ x ≀ 109) β€” the size of the table and the number that we are looking for in the table.
c4b139eadca94201596f1305b2f76496
n, x = map(int, input().split()) count = 0 i = 1 while i * i <= x: if x % i == 0 and i <= n and x // i <= n: if i != x // i: count += 2 else: count += 1 i += 1 print(count)
["2", "4", "0"]
Python
NoteA table for the second sample test is given below. The occurrences of number 12 are marked bold.
Print a single number: the number of times x occurs in the table.
Let's consider a table consisting of n rows and n columns. The cell located at the intersection of i-th row and j-th column contains number i × j. The rows and columns are numbered starting from 1.You are given a positive integer x. Your task is to count the number of cells in a table that contain number x.
[{"input": "10 5\r\n", "output": ["2"]}, {"input": "6 12\r\n", "output": ["4"]}, {"input": "5 13\r\n", "output": ["0"]}, {"input": "1 1\r\n", "output": ["1"]}, {"input": "2 1\r\n", "output": ["1"]}, {"input": "100000 1\r\n", "output": ["1"]}, {"input": "1 1000000000\r\n", "output": ["0"]}, {"input": "100000 1000000000\r\n", "output": ["16"]}, {"input": "100000 362880\r\n", "output": ["154"]}, {"input": "1 4\r\n", "output": ["0"]}, {"input": "9 12\r\n", "output": ["4"]}, {"input": "10 123\r\n", "output": ["0"]}, {"input": "9551 975275379\r\n", "output": ["0"]}, {"input": "17286 948615687\r\n", "output": ["0"]}, {"input": "58942 936593001\r\n", "output": ["0"]}, {"input": "50000 989460910\r\n", "output": ["4"]}, {"input": "22741 989460910\r\n", "output": ["0"]}, {"input": "22740 989460910\r\n", "output": ["0"]}, {"input": "100000 989460910\r\n", "output": ["4"]}, {"input": "100000 98280\r\n", "output": ["128"]}, {"input": "100000 997920\r\n", "output": ["222"]}, {"input": "100000 720720\r\n", "output": ["226"]}, {"input": "100000 2162160\r\n", "output": ["282"]}, {"input": "100000 4324320\r\n", "output": ["320"]}, {"input": "100000 8648640\r\n", "output": ["348"]}, {"input": "100000 183783600\r\n", "output": ["438"]}, {"input": "100000 551350800\r\n", "output": ["392"]}, {"input": "40000 551350800\r\n", "output": ["150"]}, {"input": "20000 400000000\r\n", "output": ["1"]}, {"input": "19999 400000000\r\n", "output": ["0"]}, {"input": "19999 399960001\r\n", "output": ["1"]}, {"input": "31621 999887641\r\n", "output": ["1"]}, {"input": "31622 999887641\r\n", "output": ["1"]}, {"input": "31620 999887641\r\n", "output": ["0"]}, {"input": "100000 999887641\r\n", "output": ["3"]}, {"input": "100000 25\r\n", "output": ["3"]}, {"input": "100000 3628800\r\n", "output": ["220"]}, {"input": "100000 39916800\r\n", "output": ["328"]}, {"input": "100000 479001600\r\n", "output": ["254"]}, {"input": "4 9\r\n", "output": ["1"]}, {"input": "2 6\r\n", "output": ["0"]}, {"input": "20 100\r\n", "output": ["3"]}, {"input": "10 3\r\n", "output": ["2"]}, {"input": "4 4\r\n", "output": ["3"]}, {"input": "2 4\r\n", "output": ["1"]}, {"input": "89874 1\r\n", "output": ["1"]}]
100
100
100
[{'input': '58942 936593001\r\n', 'output': ['0']}, {'input': '6 12\r\n', 'output': ['4']}, {'input': '22740 989460910\r\n', 'output': ['0']}, {'input': '100000 479001600\r\n', 'output': ['254']}, {'input': '100000 362880\r\n', 'output': ['154']}]
[{'input': '31621 999887641\r\n', 'output': ['1']}, {'input': '22741 989460910\r\n', 'output': ['0']}, {'input': '10 3\r\n', 'output': ['2']}, {'input': '100000 25\r\n', 'output': ['3']}, {'input': '5 13\r\n', 'output': ['0']}]
[{'input': '58942 936593001\r\n', 'output': ['0']}, {'input': '20 100\r\n', 'output': ['3']}, {'input': '1 1\r\n', 'output': ['1']}, {'input': '100000 989460910\r\n', 'output': ['4']}, {'input': '19999 399960001\r\n', 'output': ['1']}]
[{'input': '20000 400000000\r\n', 'output': ['1']}, {'input': '2 4\r\n', 'output': ['1']}, {'input': '10 3\r\n', 'output': ['2']}, {'input': '100000 183783600\r\n', 'output': ['438']}, {'input': '22740 989460910\r\n', 'output': ['0']}]
[{'input': '19999 399960001\r\n', 'output': ['1']}, {'input': '100000 999887641\r\n', 'output': ['3']}, {'input': '1 1\r\n', 'output': ['1']}, {'input': '100000 551350800\r\n', 'output': ['392']}, {'input': '50000 989460910\r\n', 'output': ['4']}]
100
100
100
100
100
90
100
100
100
100
83.33
100
100
100
100
381
100
98
96.666
["5 2", "8 1"]
The only line of the input contains two integers n and m (1 ≀ n, m ≀ 1018)Β β€” the capacity of the barn and the number of grains that are brought every day.
3b585ea852ffc41034ef6804b6aebbd8
(n, m) = map(int, input().split()) if n <= m: print(n) else: aM = m n -= m (l, r) = (0, int(2e9)) while l < r: m = (l + r) // 2; val = m * (m+1) // 2; if val >= n: r = m else: l = m+1 print(l + aM)
["4", "5"]
Python
NoteIn the first sample the capacity of the barn is five grains and two grains are brought every day. The following happens: At the beginning of the first day grain is brought to the barn. It's full, so nothing happens. At the end of the first day one sparrow comes and eats one grain, so 5 - 1 = 4 grains remain. At the beginning of the second day two grains are brought. The barn becomes full and one grain doesn't fit to it. At the end of the second day two sparrows come. 5 - 2 = 3 grains remain. At the beginning of the third day two grains are brought. The barn becomes full again. At the end of the third day three sparrows come and eat grain. 5 - 3 = 2 grains remain. At the beginning of the fourth day grain is brought again. 2 + 2 = 4 grains remain. At the end of the fourth day four sparrows come and eat grain. 4 - 4 = 0 grains remain. The barn is empty. So the answer is 4, because by the end of the fourth day the barn becomes empty.
Output one integerΒ β€” the number of the day when the barn will become empty for the first time. Days are numbered starting with one.
Anton likes to listen to fairy tales, especially when Danik, Anton's best friend, tells them. Right now Danik tells Anton a fairy tale:"Once upon a time, there lived an emperor. He was very rich and had much grain. One day he ordered to build a huge barn to put there all his grain. Best builders were building that barn for three days and three nights. But they overlooked and there remained a little hole in the barn, from which every day sparrows came through. Here flew a sparrow, took a grain and flew away..."More formally, the following takes place in the fairy tale. At the beginning of the first day the barn with the capacity of n grains was full. Then, every day (starting with the first day) the following happens: m grains are brought to the barn. If m grains doesn't fit to the barn, the barn becomes full and the grains that doesn't fit are brought back (in this problem we can assume that the grains that doesn't fit to the barn are not taken into account). Sparrows come and eat grain. In the i-th day i sparrows come, that is on the first day one sparrow come, on the second day two sparrows come and so on. Every sparrow eats one grain. If the barn is empty, a sparrow eats nothing. Anton is tired of listening how Danik describes every sparrow that eats grain from the barn. Anton doesn't know when the fairy tale ends, so he asked you to determine, by the end of which day the barn will become empty for the first time. Help Anton and write a program that will determine the number of that day!
[{"input": "5 2\r\n", "output": ["4"]}, {"input": "8 1\r\n", "output": ["5"]}, {"input": "32 5\r\n", "output": ["12"]}, {"input": "1024 1024\r\n", "output": ["1024"]}, {"input": "58044 52909\r\n", "output": ["53010"]}, {"input": "996478063 658866858\r\n", "output": ["658892843"]}, {"input": "570441179141911871 511467058318039545\r\n", "output": ["511467058661475480"]}, {"input": "1 1\r\n", "output": ["1"]}, {"input": "1000000000000000000 1000000000000000000\r\n", "output": ["1000000000000000000"]}, {"input": "1000000000000000000 999999999999997145\r\n", "output": ["999999999999997221"]}, {"input": "1 1000000000000000000\r\n", "output": ["1"]}, {"input": "1000000000000000000 1\r\n", "output": ["1414213563"]}, {"input": "999999998765257149 10\r\n", "output": ["1414213571"]}, {"input": "999999998765257150 10\r\n", "output": ["1414213571"]}, {"input": "999999998765257151 10\r\n", "output": ["1414213571"]}, {"input": "999999998765257152 10\r\n", "output": ["1414213572"]}, {"input": "999999998765257153 10\r\n", "output": ["1414213572"]}, {"input": "762078938126917521 107528\r\n", "output": ["1234675418"]}, {"input": "762078938126917522 107528\r\n", "output": ["1234675418"]}, {"input": "762078938126917523 107528\r\n", "output": ["1234675418"]}, {"input": "762078938126917524 107528\r\n", "output": ["1234675419"]}, {"input": "762078938126917525 107528\r\n", "output": ["1234675419"]}, {"input": "443233170968441395 1048576\r\n", "output": ["942571991"]}, {"input": "443233170968441396 1048576\r\n", "output": ["942571991"]}, {"input": "443233170968441397 1048576\r\n", "output": ["942571992"]}, {"input": "1833551251625340 1359260576251\r\n", "output": ["1359321110406"]}, {"input": "1835002539467264 2810548418174\r\n", "output": ["2810608952329"]}, {"input": "1840276176082280 8084185033189\r\n", "output": ["8084245567345"]}, {"input": "262133107905 256256256256\r\n", "output": ["256256364670"]}, {"input": "262133108160 256256256256\r\n", "output": ["256256364670"]}, {"input": "262133108161 256256256256\r\n", "output": ["256256364670"]}, {"input": "262133108162 256256256256\r\n", "output": ["256256364671"]}, {"input": "399823373917798976 326385530977846185\r\n", "output": ["326385531361089823"]}, {"input": "836052329491347820 327211774155929609\r\n", "output": ["327211775164731428"]}, {"input": "870979176282270170 16\r\n", "output": ["1319832715"]}, {"input": "930580173005562081 4\r\n", "output": ["1364243511"]}, {"input": "831613653237860272 154\r\n", "output": ["1289661856"]}, {"input": "867842613106376421 178\r\n", "output": ["1317454248"]}, {"input": "939156247712499033 1902\r\n", "output": ["1370517314"]}, {"input": "975385203286047886 1326\r\n", "output": ["1396701153"]}, {"input": "953065701826839766 4023\r\n", "output": ["1380631201"]}, {"input": "989294657400388618 7447\r\n", "output": ["1406630820"]}, {"input": "885695753008586140 42775\r\n", "output": ["1330979102"]}, {"input": "921924708582134992 158903\r\n", "output": ["1358043072"]}, {"input": "802352815201515314 183504\r\n", "output": ["1266953266"]}, {"input": "861953807629839929 1299632\r\n", "output": ["1314276256"]}, {"input": "925155772916259712 1929889\r\n", "output": ["1362191462"]}, {"input": "961384732784775860 5046017\r\n", "output": ["1391685648"]}, {"input": "910494856396204496 39891744\r\n", "output": ["1389332262"]}, {"input": "946723811969753348 17975168\r\n", "output": ["1394001194"]}, {"input": "992316381103677158 1849603453\r\n", "output": ["3258373398"]}, {"input": "828545340972193305 1027686877\r\n", "output": ["2314967219"]}, {"input": "946697532222325132 16179805162\r\n", "output": ["17555812078"]}, {"input": "982926487795873985 19357888587\r\n", "output": ["20759977363"]}, {"input": "892753091050063317 2037020896\r\n", "output": ["3373249237"]}, {"input": "928982046623612170 45215104320\r\n", "output": ["46578175853"]}, {"input": "845950022554437217 1553155668877\r\n", "output": ["1554456398264"]}, {"input": "882178982422953366 1792038785005\r\n", "output": ["1793367075026"]}, {"input": "847407611288100389 9111983407070\r\n", "output": ["9113285250762"]}, {"input": "883636566861649242 15350866523198\r\n", "output": ["15352195899906"]}, {"input": "988545172809612094 126043487780965\r\n", "output": ["126044893781768"]}, {"input": "824774128383160945 152286665864389\r\n", "output": ["152287950093217"]}, {"input": "889067279135046636 783632221444127\r\n", "output": ["783633554323452"]}, {"input": "925296230413628192 1609871104560255\r\n", "output": ["1609872463741155"]}, {"input": "892888041747308306 15921193742955831\r\n", "output": ["15921195067317449"]}, {"input": "929116997320857159 16747432626071959\r\n", "output": ["16747433976901012"]}, {"input": "810365749050428005 176443295773423092\r\n", "output": ["176443296899409285"]}, {"input": "846594708918944153 177269538951506516\r\n", "output": ["177269540108507095"]}, {"input": "2 1\r\n", "output": ["2"]}, {"input": "2 2\r\n", "output": ["2"]}, {"input": "3 1\r\n", "output": ["3"]}, {"input": "3 2\r\n", "output": ["3"]}, {"input": "3 3\r\n", "output": ["3"]}, {"input": "4 1\r\n", "output": ["3"]}, {"input": "4 2\r\n", "output": ["4"]}, {"input": "256 20\r\n", "output": ["42"]}, {"input": "78520 8\r\n", "output": ["404"]}, {"input": "1367064836 777314907868410435\r\n", "output": ["1367064836"]}, {"input": "658866858 996478063\r\n", "output": ["658866858"]}, {"input": "10 648271718824741275\r\n", "output": ["10"]}, {"input": "326385530977846185 399823373917798976\r\n", "output": ["326385530977846185"]}, {"input": "327211774155929609 836052329491347820\r\n", "output": ["327211774155929609"]}, {"input": "2570 566042149577952145\r\n", "output": ["2570"]}, {"input": "512486308421983105 512486308421983105\r\n", "output": ["512486308421983105"]}, {"input": "262144 262144\r\n", "output": ["262144"]}, {"input": "314159265358979323 314159265358979323\r\n", "output": ["314159265358979323"]}, {"input": "16 5\r\n", "output": ["10"]}, {"input": "29 16\r\n", "output": ["21"]}, {"input": "24 14\r\n", "output": ["18"]}, {"input": "28 18\r\n", "output": ["22"]}, {"input": "8 11\r\n", "output": ["8"]}, {"input": "500000000500004239 4242\r\n", "output": ["1000004242"]}, {"input": "500000000500004240 4242\r\n", "output": ["1000004242"]}, {"input": "500000000500004241 4242\r\n", "output": ["1000004242"]}, {"input": "500000000500004242 4242\r\n", "output": ["1000004242"]}, {"input": "500000000500004243 4242\r\n", "output": ["1000004243"]}, {"input": "500000000500004244 4242\r\n", "output": ["1000004243"]}, {"input": "500000000500004245 4242\r\n", "output": ["1000004243"]}, {"input": "163162808800191208 163162808800191206\r\n", "output": ["163162808800191208"]}, {"input": "328584130811799021 328584130811799020\r\n", "output": ["328584130811799021"]}, {"input": "89633000579612779 89633000579612778\r\n", "output": ["89633000579612779"]}, {"input": "924211674273037668 924211674273037666\r\n", "output": ["924211674273037668"]}, {"input": "758790352261429854 758790352261429851\r\n", "output": ["758790352261429853"]}, {"input": "39154349371830603 39154349371830597\r\n", "output": ["39154349371830600"]}, {"input": "313727604417502165 313727604417502155\r\n", "output": ["313727604417502159"]}, {"input": "1000000000000000000 999999999999999999\r\n", "output": ["1000000000000000000"]}, {"input": "1000000000000000000 999999999999999998\r\n", "output": ["1000000000000000000"]}, {"input": "1000000000000000000 999999999999999997\r\n", "output": ["999999999999999999"]}, {"input": "1000000000000000000 999999999999999996\r\n", "output": ["999999999999999999"]}, {"input": "1000000000000000000 999999999999999995\r\n", "output": ["999999999999999998"]}, {"input": "1 5\r\n", "output": ["1"]}, {"input": "1 100\r\n", "output": ["1"]}, {"input": "1 3\r\n", "output": ["1"]}, {"input": "6 9\r\n", "output": ["6"]}, {"input": "1000000000000000000 2\r\n", "output": ["1414213564"]}, {"input": "1 10\r\n", "output": ["1"]}, {"input": "5 15\r\n", "output": ["5"]}, {"input": "12 1\r\n", "output": ["6"]}, {"input": "1000000000000000000 100000000000000000\r\n", "output": ["100000001341640786"]}, {"input": "100 200\r\n", "output": ["100"]}, {"input": "1 1000000000000000\r\n", "output": ["1"]}, {"input": "100000000000000000 1\r\n", "output": ["447213596"]}, {"input": "1000000000000000000 1000000000000000\r\n", "output": ["1000001413506279"]}, {"input": "1 9\r\n", "output": ["1"]}, {"input": "1000000000000000000 4\r\n", "output": ["1414213566"]}, {"input": "1000000000000 10000000000000\r\n", "output": ["1000000000000"]}, {"input": "1 100000\r\n", "output": ["1"]}, {"input": "3 7\r\n", "output": ["3"]}, {"input": "2 3\r\n", "output": ["2"]}, {"input": "1 8\r\n", "output": ["1"]}, {"input": "5 10\r\n", "output": ["5"]}, {"input": "10 11\r\n", "output": ["10"]}, {"input": "10 100\r\n", "output": ["10"]}, {"input": "5 16\r\n", "output": ["5"]}, {"input": "2 10\r\n", "output": ["2"]}, {"input": "10836 16097\r\n", "output": ["10836"]}, {"input": "16808 75250\r\n", "output": ["16808"]}, {"input": "900000000000169293 1\r\n", "output": ["1341640788"]}, {"input": "1 10000000\r\n", "output": ["1"]}, {"input": "2 100\r\n", "output": ["2"]}, {"input": "10 20\r\n", "output": ["10"]}, {"input": "10 10000\r\n", "output": ["10"]}, {"input": "4 5\r\n", "output": ["4"]}, {"input": "1 2\r\n", "output": ["1"]}, {"input": "1000000000000000000 5\r\n", "output": ["1414213567"]}, {"input": "2 5\r\n", "output": ["2"]}, {"input": "4 6\r\n", "output": ["4"]}, {"input": "999999998765257147 1\r\n", "output": ["1414213563"]}, {"input": "3 10\r\n", "output": ["3"]}, {"input": "997270248313594436 707405570208615798\r\n", "output": ["707405570970015402"]}, {"input": "1 100000000000\r\n", "output": ["1"]}, {"input": "6 1000000\r\n", "output": ["6"]}, {"input": "16808 282475250\r\n", "output": ["16808"]}, {"input": "1000000007 100000000000007\r\n", "output": ["1000000007"]}, {"input": "1 1000\r\n", "output": ["1"]}, {"input": "1000000000000000 10000000000000000\r\n", "output": ["1000000000000000"]}, {"input": "1000000000000000000 100\r\n", "output": ["1414213662"]}, {"input": "1000000000000000000 9\r\n", "output": ["1414213571"]}, {"input": "900000000000169293 171\r\n", "output": ["1341640957"]}, {"input": "1 999999999999\r\n", "output": ["1"]}, {"input": "10000 10000000000000\r\n", "output": ["10000"]}, {"input": "1 9999999999999\r\n", "output": ["1"]}, {"input": "695968090125646936 429718492544794353\r\n", "output": ["429718493274519777"]}, {"input": "2 5000\r\n", "output": ["2"]}, {"input": "8 100\r\n", "output": ["8"]}, {"input": "2 7\r\n", "output": ["2"]}, {"input": "999999999999999999 1\r\n", "output": ["1414213563"]}, {"input": "5 8\r\n", "output": ["5"]}, {"input": "1000000000000000000 99999999999999999\r\n", "output": ["100000001341640785"]}, {"input": "100000000000000000 100000000000000000\r\n", "output": ["100000000000000000"]}, {"input": "5 6\r\n", "output": ["5"]}, {"input": "1000000000000000000 1000000000\r\n", "output": ["2414213562"]}, {"input": "1 10000\r\n", "output": ["1"]}, {"input": "22 11\r\n", "output": ["16"]}, {"input": "10 10000000\r\n", "output": ["10"]}, {"input": "3 8\r\n", "output": ["3"]}, {"input": "10 123123\r\n", "output": ["10"]}, {"input": "3 5\r\n", "output": ["3"]}, {"input": "1000000000000000000 10\r\n", "output": ["1414213572"]}, {"input": "10000000000000 45687987897897\r\n", "output": ["10000000000000"]}, {"input": "5 4\r\n", "output": ["5"]}, {"input": "5000 123456789\r\n", "output": ["5000"]}, {"input": "7 100\r\n", "output": ["7"]}, {"input": "1000000000000000000 500000000000\r\n", "output": ["501414213209"]}, {"input": "8 7\r\n", "output": ["8"]}, {"input": "1 10000000000\r\n", "output": ["1"]}, {"input": "1000000000000000000 15\r\n", "output": ["1414213577"]}, {"input": "1 123456789\r\n", "output": ["1"]}, {"input": "2 1000\r\n", "output": ["2"]}, {"input": "5 11\r\n", "output": ["5"]}, {"input": "1 1000000000\r\n", "output": ["1"]}, {"input": "1000000000000000000 499999999999999999\r\n", "output": ["500000000999999999"]}, {"input": "1 100000000\r\n", "output": ["1"]}, {"input": "619768314833382029 108339531052386197\r\n", "output": ["108339532063750408"]}, {"input": "5 100\r\n", "output": ["5"]}, {"input": "2 10000\r\n", "output": ["2"]}, {"input": "1000000000000000000 500000000000000000\r\n", "output": ["500000001000000000"]}, {"input": "143 3\r\n", "output": ["20"]}, {"input": "2 6\r\n", "output": ["2"]}, {"input": "100 1000000000\r\n", "output": ["100"]}, {"input": "2 100000000000000000\r\n", "output": ["2"]}, {"input": "100000000000000000 1000000000000000000\r\n", "output": ["100000000000000000"]}, {"input": "999999999999999999 123456789\r\n", "output": ["1537670351"]}, {"input": "1 99999\r\n", "output": ["1"]}, {"input": "1000000000000000000 9999999999\r\n", "output": ["11414213554"]}, {"input": "5 100000000000000000\r\n", "output": ["5"]}, {"input": "6 999999\r\n", "output": ["6"]}, {"input": "100 10000000\r\n", "output": ["100"]}, {"input": "4 100\r\n", "output": ["4"]}, {"input": "1000000000 1000000000000000\r\n", "output": ["1000000000"]}, {"input": "10 100000\r\n", "output": ["10"]}, {"input": "5 15555555\r\n", "output": ["5"]}, {"input": "5 155555\r\n", "output": ["5"]}, {"input": "200 9999999999\r\n", "output": ["200"]}, {"input": "3 200\r\n", "output": ["3"]}, {"input": "1000000000000000000 490000000000000000\r\n", "output": ["490000001009950494"]}, {"input": "2 4\r\n", "output": ["2"]}, {"input": "5 15555\r\n", "output": ["5"]}, {"input": "5 7\r\n", "output": ["5"]}, {"input": "10040 200000\r\n", "output": ["10040"]}, {"input": "1000000000000000000 60000000000000000\r\n", "output": ["60000001371130920"]}, {"input": "10 1000000000000\r\n", "output": ["10"]}, {"input": "1 45\r\n", "output": ["1"]}]
100
100
100
[{'input': '762078938126917523 107528\r\n', 'output': ['1234675418']}, {'input': '200 9999999999\r\n', 'output': ['200']}, {'input': '882178982422953366 1792038785005\r\n', 'output': ['1793367075026']}, {'input': '10836 16097\r\n', 'output': ['10836']}, {'input': '262133108160 256256256256\r\n', 'output': ['256256364670']}]
[{'input': '831613653237860272 154\r\n', 'output': ['1289661856']}, {'input': '5000 123456789\r\n', 'output': ['5000']}, {'input': '1 100000000\r\n', 'output': ['1']}, {'input': '762078938126917525 107528\r\n', 'output': ['1234675419']}, {'input': '861953807629839929 1299632\r\n', 'output': ['1314276256']}]
[{'input': '2 1000\r\n', 'output': ['2']}, {'input': '1000000000000000000 2\r\n', 'output': ['1414213564']}, {'input': '762078938126917525 107528\r\n', 'output': ['1234675419']}, {'input': '1 99999\r\n', 'output': ['1']}, {'input': '982926487795873985 19357888587\r\n', 'output': ['20759977363']}]
[{'input': '262133108160 256256256256\r\n', 'output': ['256256364670']}, {'input': '999999999999999999 123456789\r\n', 'output': ['1537670351']}, {'input': '163162808800191208 163162808800191206\r\n', 'output': ['163162808800191208']}, {'input': '4 6\r\n', 'output': ['4']}, {'input': '5 16\r\n', 'output': ['5']}]
[{'input': '1 100000000000\r\n', 'output': ['1']}, {'input': '500000000500004240 4242\r\n', 'output': ['1000004242']}, {'input': '100000000000000000 1000000000000000000\r\n', 'output': ['100000000000000000']}, {'input': '10 10000000\r\n', 'output': ['10']}, {'input': '992316381103677158 1849603453\r\n', 'output': ['3258373398']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
382
100
100
100
["6 9", "38 11", "5 2", "5 10"]
The only line of the input contains two integers $$$n$$$ and $$$b$$$ ($$$1 \le n \le 10^{18}$$$, $$$2 \le b \le 10^{12}$$$).
491748694c1a53771be69c212a5e0e25
# Python3 code to find largest prime # factor of number from collections import Counter import math # A function to print all prime factors of # a given number n def primeFactors(n): # Print the number of two's that divide n list=[] while n % 2 == 0: list.append(2) n = n / 2 # n must be odd at this point # so a skip of 2 ( i = i + 2) can be used for i in range(3,int(math.sqrt(n))+1,2): # while i divides n , print i ad divide n while n % i== 0: list.append(i) n = n / i # Condition if n is a prime # number greater than 2 if n > 2: list.append(n) return list #write your main here #find the count of maximum factor in the b n,b=map(int,input().split()) m_fact=primeFactors(b) #counter = Counter(m_fact) #print(counter) ll=[] #print(m_fact) for fact in m_fact: #print(fact) div=0 bb=b while (bb%fact)==0: div+=1 bb=int(bb//fact) #print(div) #print(div) t_count=int(0) num=n #print(num) while num>=fact: t_count+=int(num//fact) num=(num//fact) #print(num) #print(t_count) ll.append(t_count//div) #print(ll) print(min(ll))
["1", "3", "3", "1"]
Python
NoteIn the first example, $$$6!_{(10)} = 720_{(10)} = 880_{(9)}$$$.In the third and fourth example, $$$5!_{(10)} = 120_{(10)} = 1111000_{(2)}$$$.The representation of the number $$$x$$$ in the $$$b$$$-ary base is $$$d_1, d_2, \ldots, d_k$$$ if $$$x = d_1 b^{k - 1} + d_2 b^{k - 2} + \ldots + d_k b^0$$$, where $$$d_i$$$ are integers and $$$0 \le d_i \le b - 1$$$. For example, the number $$$720$$$ from the first example is represented as $$$880_{(9)}$$$ since $$$720 = 8 \cdot 9^2 + 8 \cdot 9 + 0 \cdot 1$$$.You can read more about bases here.
Print an only integerΒ β€” the number of trailing zero digits in the $$$b$$$-ary representation of $$$n!$$$
The number "zero" is called "love" (or "l'oeuf" to be precise, literally means "egg" in French), for example when denoting the zero score in a game of tennis. Aki is fond of numbers, especially those with trailing zeros. For example, the number $$$9200$$$ has two trailing zeros. Aki thinks the more trailing zero digits a number has, the prettier it is.However, Aki believes, that the number of trailing zeros of a number is not static, but depends on the base (radix) it is represented in. Thus, he considers a few scenarios with some numbers and bases. And now, since the numbers he used become quite bizarre, he asks you to help him to calculate the beauty of these numbers.Given two integers $$$n$$$ and $$$b$$$ (in decimal notation), your task is to calculate the number of trailing zero digits in the $$$b$$$-ary (in the base/radix of $$$b$$$) representation of $$$n\,!$$$ (factorial of $$$n$$$).
[{"input": "6 9\r\n", "output": ["1"]}, {"input": "38 11\r\n", "output": ["3"]}, {"input": "5 2\r\n", "output": ["3"]}, {"input": "5 10\r\n", "output": ["1"]}, {"input": "1000000000000000000 1000000000000\r\n", "output": ["20833333333333332"]}, {"input": "1000000000000000000 999999999989\r\n", "output": ["1000000"]}, {"input": "1000000000000000000 97\r\n", "output": ["10416666666666661"]}, {"input": "62 45\r\n", "output": ["14"]}, {"input": "25 48\r\n", "output": ["5"]}, {"input": "594703138034372316 960179812013\r\n", "output": ["19200359"]}, {"input": "1 2\r\n", "output": ["0"]}, {"input": "2 2\r\n", "output": ["1"]}, {"input": "7 10080\r\n", "output": ["0"]}, {"input": "8 10080\r\n", "output": ["1"]}, {"input": "57 10080\r\n", "output": ["9"]}, {"input": "9 10080\r\n", "output": ["1"]}, {"input": "14 10080\r\n", "output": ["2"]}, {"input": "1000000000000000000 2\r\n", "output": ["999999999999999976"]}, {"input": "1000000000000000000 7\r\n", "output": ["166666666666666656"]}, {"input": "1000000000000000000 285311670611\r\n", "output": ["9090909090909090"]}, {"input": "1000000000000000000 322687697779\r\n", "output": ["6172839506172838"]}, {"input": "1000000000000000000 470184984576\r\n", "output": ["33333333333333332"]}, {"input": "1000000000000000000 743008370688\r\n", "output": ["45454545454545452"]}, {"input": "1000000000000000000 64339296875\r\n", "output": ["23809523809523808"]}, {"input": "1000000000000000000 200560490130\r\n", "output": ["33333333333333329"]}, {"input": "36 118587876497\r\n", "output": ["0"]}, {"input": "36 322687697779\r\n", "output": ["0"]}, {"input": "36 110075314176\r\n", "output": ["1"]}, {"input": "36 656100000000\r\n", "output": ["1"]}, {"input": "4294967296 999999999989\r\n", "output": ["0"]}, {"input": "4294967296 999999999958\r\n", "output": ["0"]}, {"input": "13 373621248000\r\n", "output": ["0"]}, {"input": "12 720\r\n", "output": ["2"]}, {"input": "12 576\r\n", "output": ["1"]}, {"input": "1 1000000000000\r\n", "output": ["0"]}, {"input": "6 13\r\n", "output": ["0"]}, {"input": "2 193773\r\n", "output": ["0"]}, {"input": "2 398273\r\n", "output": ["0"]}, {"input": "72 30\r\n", "output": ["16"]}, {"input": "72 2\r\n", "output": ["70"]}, {"input": "72 193773\r\n", "output": ["0"]}, {"input": "72 398273\r\n", "output": ["0"]}, {"input": "72 250880942892\r\n", "output": ["0"]}, {"input": "72 999999998141\r\n", "output": ["0"]}, {"input": "912222 193773\r\n", "output": ["14"]}, {"input": "912222 398273\r\n", "output": ["2"]}, {"input": "912222 250880942892\r\n", "output": ["0"]}, {"input": "912222 999999998141\r\n", "output": ["0"]}, {"input": "83143260522 193773\r\n", "output": ["1287245"]}, {"input": "83143260522 398273\r\n", "output": ["208759"]}, {"input": "83143260522 250880942892\r\n", "output": ["3"]}, {"input": "83143260522 999999998141\r\n", "output": ["0"]}, {"input": "822981260158260522 250880942892\r\n", "output": ["39364389"]}, {"input": "222981260158260518 850874549779\r\n", "output": ["15271097091"]}, {"input": "222981260158260518 999999998141\r\n", "output": ["222981"]}, {"input": "445422409459676274 999922001521\r\n", "output": ["222720113534"]}, {"input": "918586219753393663 999800009711\r\n", "output": ["918663387476"]}, {"input": "446248652637759698 972358665643\r\n", "output": ["15016106488920"]}, {"input": "237201990843960076 973532640023\r\n", "output": ["11953335559561"]}, {"input": "484242296072308881 978253641619\r\n", "output": ["48677351836781"]}, {"input": "447074895815843122 911125611841\r\n", "output": ["114517135198729"]}, {"input": "455817757639559194 970322544187\r\n", "output": ["153473992471231"]}, {"input": "238028234022043500 877592366401\r\n", "output": ["121195638504094"]}, {"input": "720471251645857727 800266614341\r\n", "output": ["380798758798020"]}, {"input": "883457908461157525 863363187787\r\n", "output": ["887005932189914"]}, {"input": "945422409459676266 962504231329\r\n", "output": ["481831307722"]}, {"input": "818586219753393638 868390924421\r\n", "output": ["878145564521"]}, {"input": "946248652637759690 834034807997\r\n", "output": ["33512135310870"]}, {"input": "937201990843960062 788432964607\r\n", "output": ["49755892484813"]}, {"input": "984242296072308866 826202217433\r\n", "output": ["99923075743380"]}, {"input": "947074895815843114 12897917761\r\n", "output": ["704668821291548"]}, {"input": "855817757639559189 261563075383\r\n", "output": ["310754450849512"]}, {"input": "938028234022043486 6255386281\r\n", "output": ["825729079244755"]}, {"input": "820471251645857717 184820096819\r\n", "output": ["539783718188063"]}, {"input": "883457908461157497 102269364647\r\n", "output": ["962372449304090"]}]
100
100
100
[{'input': '83143260522 250880942892\r\n', 'output': ['3']}, {'input': '7 10080\r\n', 'output': ['0']}, {'input': '72 30\r\n', 'output': ['16']}, {'input': '83143260522 999999998141\r\n', 'output': ['0']}, {'input': '946248652637759690 834034807997\r\n', 'output': ['33512135310870']}]
[{'input': '83143260522 193773\r\n', 'output': ['1287245']}, {'input': '72 193773\r\n', 'output': ['0']}, {'input': '4294967296 999999999958\r\n', 'output': ['0']}, {'input': '1 2\r\n', 'output': ['0']}, {'input': '4294967296 999999999989\r\n', 'output': ['0']}]
[{'input': '1000000000000000000 1000000000000\r\n', 'output': ['20833333333333332']}, {'input': '13 373621248000\r\n', 'output': ['0']}, {'input': '912222 398273\r\n', 'output': ['2']}, {'input': '445422409459676274 999922001521\r\n', 'output': ['222720113534']}, {'input': '883457908461157525 863363187787\r\n', 'output': ['887005932189914']}]
[{'input': '446248652637759698 972358665643\r\n', 'output': ['15016106488920']}, {'input': '237201990843960076 973532640023\r\n', 'output': ['11953335559561']}, {'input': '62 45\r\n', 'output': ['14']}, {'input': '984242296072308866 826202217433\r\n', 'output': ['99923075743380']}, {'input': '38 11\r\n', 'output': ['3']}]
[{'input': '720471251645857727 800266614341\r\n', 'output': ['380798758798020']}, {'input': '36 110075314176\r\n', 'output': ['1']}, {'input': '83143260522 193773\r\n', 'output': ['1287245']}, {'input': '947074895815843114 12897917761\r\n', 'output': ['704668821291548']}, {'input': '6 13\r\n', 'output': ['0']}]
100
100
100
100
100
100
100
100
93.33
100
100
100
100
92.86
100
383
100
98.666
98.572
["4 6\n10 12 10 7 5 22"]
The first line contains space-separated integers n and m (2 ≀ n ≀ m ≀ 50). The second line contains m space-separated integers f1, f2, ..., fm (4 ≀ fi ≀ 1000) β€” the quantities of pieces in the puzzles sold in the shop.
7830aabb0663e645d54004063746e47f
n,m = input().split() m=int(m) n=int(n) arr = sorted(map(int,input().split())) mini=999999999 for j in range(m-n+1): if (arr[j+n-1]-arr[j]<mini): mini=arr[j+n-1]-arr[j] print (mini)
["5"]
Python
NoteSample 1. The class has 4 students. The shop sells 6 puzzles. If Ms. Manana buys the first four puzzles consisting of 10, 12, 10 and 7 pieces correspondingly, then the difference between the sizes of the largest and the smallest puzzle will be equal to 5. It is impossible to obtain a smaller difference. Note that the teacher can also buy puzzles 1, 3, 4 and 5 to obtain the difference 5.
Print a single integer β€” the least possible difference the teacher can obtain.
The end of the school year is near and Ms. Manana, the teacher, will soon have to say goodbye to a yet another class. She decided to prepare a goodbye present for her n students and give each of them a jigsaw puzzle (which, as wikipedia states, is a tiling puzzle that requires the assembly of numerous small, often oddly shaped, interlocking and tessellating pieces).The shop assistant told the teacher that there are m puzzles in the shop, but they might differ in difficulty and size. Specifically, the first jigsaw puzzle consists of f1 pieces, the second one consists of f2 pieces and so on.Ms. Manana doesn't want to upset the children, so she decided that the difference between the numbers of pieces in her presents must be as small as possible. Let A be the number of pieces in the largest puzzle that the teacher buys and B be the number of pieces in the smallest such puzzle. She wants to choose such n puzzles that A - B is minimum possible. Help the teacher and find the least possible value of A - B.
[{"input": "4 6\r\n10 12 10 7 5 22\r\n", "output": ["5"]}, {"input": "2 2\r\n4 4\r\n", "output": ["0"]}, {"input": "2 10\r\n4 5 6 7 8 9 10 11 12 12\r\n", "output": ["0"]}, {"input": "4 5\r\n818 136 713 59 946\r\n", "output": ["759"]}, {"input": "3 20\r\n446 852 783 313 549 965 40 88 86 617 479 118 768 34 47 826 366 957 463 903\r\n", "output": ["13"]}, {"input": "2 25\r\n782 633 152 416 432 825 115 97 386 357 836 310 530 413 354 373 847 882 913 682 729 582 671 674 94\r\n", "output": ["3"]}, {"input": "4 25\r\n226 790 628 528 114 64 239 279 619 39 894 763 763 847 525 93 882 697 999 643 650 244 159 884 190\r\n", "output": ["31"]}, {"input": "2 50\r\n971 889 628 39 253 157 925 694 129 516 660 272 738 319 611 816 142 717 514 392 41 105 132 676 958 118 306 768 600 685 103 857 704 346 857 309 23 718 618 161 176 379 846 834 640 468 952 878 164 997\r\n", "output": ["0"]}, {"input": "25 50\r\n582 146 750 905 313 509 402 21 488 512 32 898 282 64 579 869 37 996 377 929 975 697 666 837 311 205 116 992 533 298 648 268 54 479 792 595 152 69 267 417 184 433 894 603 988 712 24 414 301 176\r\n", "output": ["412"]}, {"input": "49 50\r\n58 820 826 960 271 294 473 102 925 318 729 672 244 914 796 646 868 6 893 882 726 203 528 498 271 195 355 459 721 680 547 147 631 116 169 804 145 996 133 559 110 257 771 476 576 251 607 314 427 886\r\n", "output": ["938"]}, {"input": "50 50\r\n374 573 323 744 190 806 485 247 628 336 491 606 702 321 991 678 337 579 86 240 993 208 668 686 855 205 363 177 719 249 896 919 782 434 59 647 787 996 286 216 636 212 546 903 958 559 544 126 608 993\r\n", "output": ["937"]}, {"input": "6 50\r\n6 8 7 8 5 4 4 5 7 8 6 5 7 4 7 7 7 8 6 4 6 6 8 8 7 7 8 7 5 8 5 4 4 7 8 4 4 6 6 6 8 7 4 7 6 6 5 8 4 7\r\n", "output": ["0"]}, {"input": "37 50\r\n14 5 11 17 8 20 19 16 20 11 17 20 16 9 14 14 13 18 11 20 8 8 8 5 19 17 6 18 10 20 9 7 12 6 14 17 4 4 10 13 7 4 11 6 20 19 12 12 15 19\r\n", "output": ["12"]}, {"input": "40 50\r\n4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4\r\n", "output": ["0"]}, {"input": "40 50\r\n17 20 43 26 41 37 14 8 30 35 30 24 43 8 42 9 41 50 41 35 27 32 35 43 28 36 31 16 5 7 23 16 14 29 8 39 12 16 36 18 49 39 33 37 38 6 6 27 23 17\r\n", "output": ["31"]}, {"input": "2 2\r\n1000 4\r\n", "output": ["996"]}, {"input": "2 3\r\n4 502 1000\r\n", "output": ["498"]}, {"input": "3 3\r\n4 1000 4\r\n", "output": ["996"]}]
100
100
100
[{'input': '4 6\r\n10 12 10 7 5 22\r\n', 'output': ['5']}, {'input': '4 25\r\n226 790 628 528 114 64 239 279 619 39 894 763 763 847 525 93 882 697 999 643 650 244 159 884 190\r\n', 'output': ['31']}, {'input': '2 25\r\n782 633 152 416 432 825 115 97 386 357 836 310 530 413 354 373 847 882 913 682 729 582 671 674 94\r\n', 'output': ['3']}, {'input': '2 10\r\n4 5 6 7 8 9 10 11 12 12\r\n', 'output': ['0']}, {'input': '2 2\r\n4 4\r\n', 'output': ['0']}]
[{'input': '3 20\r\n446 852 783 313 549 965 40 88 86 617 479 118 768 34 47 826 366 957 463 903\r\n', 'output': ['13']}, {'input': '25 50\r\n582 146 750 905 313 509 402 21 488 512 32 898 282 64 579 869 37 996 377 929 975 697 666 837 311 205 116 992 533 298 648 268 54 479 792 595 152 69 267 417 184 433 894 603 988 712 24 414 301 176\r\n', 'output': ['412']}, {'input': '2 50\r\n971 889 628 39 253 157 925 694 129 516 660 272 738 319 611 816 142 717 514 392 41 105 132 676 958 118 306 768 600 685 103 857 704 346 857 309 23 718 618 161 176 379 846 834 640 468 952 878 164 997\r\n', 'output': ['0']}, {'input': '6 50\r\n6 8 7 8 5 4 4 5 7 8 6 5 7 4 7 7 7 8 6 4 6 6 8 8 7 7 8 7 5 8 5 4 4 7 8 4 4 6 6 6 8 7 4 7 6 6 5 8 4 7\r\n', 'output': ['0']}, {'input': '4 6\r\n10 12 10 7 5 22\r\n', 'output': ['5']}]
[{'input': '3 3\r\n4 1000 4\r\n', 'output': ['996']}, {'input': '49 50\r\n58 820 826 960 271 294 473 102 925 318 729 672 244 914 796 646 868 6 893 882 726 203 528 498 271 195 355 459 721 680 547 147 631 116 169 804 145 996 133 559 110 257 771 476 576 251 607 314 427 886\r\n', 'output': ['938']}, {'input': '50 50\r\n374 573 323 744 190 806 485 247 628 336 491 606 702 321 991 678 337 579 86 240 993 208 668 686 855 205 363 177 719 249 896 919 782 434 59 647 787 996 286 216 636 212 546 903 958 559 544 126 608 993\r\n', 'output': ['937']}, {'input': '2 25\r\n782 633 152 416 432 825 115 97 386 357 836 310 530 413 354 373 847 882 913 682 729 582 671 674 94\r\n', 'output': ['3']}, {'input': '2 50\r\n971 889 628 39 253 157 925 694 129 516 660 272 738 319 611 816 142 717 514 392 41 105 132 676 958 118 306 768 600 685 103 857 704 346 857 309 23 718 618 161 176 379 846 834 640 468 952 878 164 997\r\n', 'output': ['0']}]
[{'input': '2 25\r\n782 633 152 416 432 825 115 97 386 357 836 310 530 413 354 373 847 882 913 682 729 582 671 674 94\r\n', 'output': ['3']}, {'input': '25 50\r\n582 146 750 905 313 509 402 21 488 512 32 898 282 64 579 869 37 996 377 929 975 697 666 837 311 205 116 992 533 298 648 268 54 479 792 595 152 69 267 417 184 433 894 603 988 712 24 414 301 176\r\n', 'output': ['412']}, {'input': '49 50\r\n58 820 826 960 271 294 473 102 925 318 729 672 244 914 796 646 868 6 893 882 726 203 528 498 271 195 355 459 721 680 547 147 631 116 169 804 145 996 133 559 110 257 771 476 576 251 607 314 427 886\r\n', 'output': ['938']}, {'input': '2 2\r\n1000 4\r\n', 'output': ['996']}, {'input': '3 20\r\n446 852 783 313 549 965 40 88 86 617 479 118 768 34 47 826 366 957 463 903\r\n', 'output': ['13']}]
[{'input': '49 50\r\n58 820 826 960 271 294 473 102 925 318 729 672 244 914 796 646 868 6 893 882 726 203 528 498 271 195 355 459 721 680 547 147 631 116 169 804 145 996 133 559 110 257 771 476 576 251 607 314 427 886\r\n', 'output': ['938']}, {'input': '4 6\r\n10 12 10 7 5 22\r\n', 'output': ['5']}, {'input': '3 3\r\n4 1000 4\r\n', 'output': ['996']}, {'input': '40 50\r\n4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4\r\n', 'output': ['0']}, {'input': '2 25\r\n782 633 152 416 432 825 115 97 386 357 836 310 530 413 354 373 847 882 913 682 729 582 671 674 94\r\n', 'output': ['3']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
384
100
100
100
["2 1 2 2", "4 7 7 4"]
The first line contains four integers: xp, yp, xv, yv (0 ≀ xp, yp, xv, yv ≀ 105) β€” Polycarp's and Vasiliy's starting coordinates. It is guaranteed that in the beginning the pawns are in different cells and none of them is in the cell (0, 0).
2637d57f7809ff8f922549c617709074
x1, y1, x2, y2 = map(int, input().split()) if (x1 > x2 or y1 > y2) and x1 + y1 > max(x2, y2): print("Vasiliy") else: print("Polycarp")
["Polycarp", "Vasiliy"]
Python
NoteIn the first sample test Polycarp starts in (2, 1) and will move to (1, 1) in the first turn. No matter what his opponent is doing, in the second turn Polycarp can move to (1, 0) and finally to (0, 0) in the third turn.
Output the name of the winner: "Polycarp" or "Vasiliy".
Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from cell (x, y) to (x - 1, y) or (x, y - 1). Vasiliy can move his pawn from (x, y) to one of cells: (x - 1, y), (x - 1, y - 1) and (x, y - 1). Both players are also allowed to skip move. There are some additional restrictions β€” a player is forbidden to move his pawn to a cell with negative x-coordinate or y-coordinate or to the cell containing opponent's pawn The winner is the first person to reach cell (0, 0). You are given the starting coordinates of both pawns. Determine who will win if both of them play optimally well.
[{"input": "2 1 2 2\r\n", "output": ["Polycarp"]}, {"input": "4 7 7 4\r\n", "output": ["Vasiliy"]}, {"input": "20 0 7 22\r\n", "output": ["Polycarp"]}, {"input": "80 100 83 97\r\n", "output": ["Vasiliy"]}, {"input": "80 100 77 103\r\n", "output": ["Vasiliy"]}, {"input": "55000 60000 55003 60100\r\n", "output": ["Polycarp"]}, {"input": "100000 100000 100000 99999\r\n", "output": ["Vasiliy"]}, {"input": "100000 99999 100000 100000\r\n", "output": ["Polycarp"]}, {"input": "0 100000 100000 99999\r\n", "output": ["Polycarp"]}, {"input": "0 100000 99999 100000\r\n", "output": ["Polycarp"]}, {"input": "0 90000 89999 89999\r\n", "output": ["Vasiliy"]}, {"input": "0 1 0 2\r\n", "output": ["Polycarp"]}, {"input": "0 1 1 0\r\n", "output": ["Polycarp"]}, {"input": "0 1 1 1\r\n", "output": ["Polycarp"]}, {"input": "0 1 1 2\r\n", "output": ["Polycarp"]}, {"input": "0 1 2 0\r\n", "output": ["Polycarp"]}, {"input": "0 1 2 1\r\n", "output": ["Polycarp"]}, {"input": "0 1 2 2\r\n", "output": ["Polycarp"]}, {"input": "0 2 0 1\r\n", "output": ["Vasiliy"]}, {"input": "0 2 1 0\r\n", "output": ["Vasiliy"]}, {"input": "0 2 1 1\r\n", "output": ["Vasiliy"]}, {"input": "0 2 1 2\r\n", "output": ["Polycarp"]}, {"input": "0 2 2 0\r\n", "output": ["Polycarp"]}, {"input": "0 2 2 1\r\n", "output": ["Polycarp"]}, {"input": "0 2 2 2\r\n", "output": ["Polycarp"]}, {"input": "1 0 0 1\r\n", "output": ["Polycarp"]}, {"input": "1 0 0 2\r\n", "output": ["Polycarp"]}, {"input": "1 0 1 1\r\n", "output": ["Polycarp"]}, {"input": "1 0 1 2\r\n", "output": ["Polycarp"]}, {"input": "1 0 2 0\r\n", "output": ["Polycarp"]}, {"input": "1 0 2 1\r\n", "output": ["Polycarp"]}, {"input": "1 0 2 2\r\n", "output": ["Polycarp"]}, {"input": "1 1 0 1\r\n", "output": ["Vasiliy"]}, {"input": "1 1 0 2\r\n", "output": ["Polycarp"]}, {"input": "1 1 1 0\r\n", "output": ["Vasiliy"]}, {"input": "1 1 1 2\r\n", "output": ["Polycarp"]}, {"input": "1 1 2 0\r\n", "output": ["Polycarp"]}, {"input": "1 1 2 1\r\n", "output": ["Polycarp"]}, {"input": "1 1 2 2\r\n", "output": ["Polycarp"]}, {"input": "1 2 0 1\r\n", "output": ["Vasiliy"]}, {"input": "1 2 0 2\r\n", "output": ["Vasiliy"]}, {"input": "1 2 1 0\r\n", "output": ["Vasiliy"]}, {"input": "1 2 1 1\r\n", "output": ["Vasiliy"]}, {"input": "1 2 2 0\r\n", "output": ["Vasiliy"]}, {"input": "1 2 2 1\r\n", "output": ["Vasiliy"]}, {"input": "1 2 2 2\r\n", "output": ["Polycarp"]}, {"input": "2 0 0 1\r\n", "output": ["Vasiliy"]}, {"input": "2 0 0 2\r\n", "output": ["Polycarp"]}, {"input": "2 0 1 0\r\n", "output": ["Vasiliy"]}, {"input": "2 0 1 1\r\n", "output": ["Vasiliy"]}, {"input": "2 0 1 2\r\n", "output": ["Polycarp"]}, {"input": "2 0 2 1\r\n", "output": ["Polycarp"]}, {"input": "2 0 2 2\r\n", "output": ["Polycarp"]}, {"input": "2 1 0 1\r\n", "output": ["Vasiliy"]}, {"input": "2 1 0 2\r\n", "output": ["Vasiliy"]}, {"input": "2 1 1 0\r\n", "output": ["Vasiliy"]}, {"input": "2 1 1 1\r\n", "output": ["Vasiliy"]}, {"input": "2 1 1 2\r\n", "output": ["Vasiliy"]}, {"input": "2 1 2 0\r\n", "output": ["Vasiliy"]}, {"input": "2 1 2 2\r\n", "output": ["Polycarp"]}, {"input": "2 2 0 1\r\n", "output": ["Vasiliy"]}, {"input": "2 2 0 2\r\n", "output": ["Vasiliy"]}, {"input": "2 2 1 0\r\n", "output": ["Vasiliy"]}, {"input": "2 2 1 1\r\n", "output": ["Vasiliy"]}, {"input": "2 2 1 2\r\n", "output": ["Vasiliy"]}, {"input": "2 2 2 0\r\n", "output": ["Vasiliy"]}, {"input": "2 2 2 1\r\n", "output": ["Vasiliy"]}, {"input": "13118 79593 32785 22736\r\n", "output": ["Vasiliy"]}, {"input": "23039 21508 54113 76824\r\n", "output": ["Polycarp"]}, {"input": "32959 49970 75441 55257\r\n", "output": ["Polycarp"]}, {"input": "91573 91885 61527 58038\r\n", "output": ["Vasiliy"]}, {"input": "70620 15283 74892 15283\r\n", "output": ["Polycarp"]}, {"input": "43308 1372 53325 1370\r\n", "output": ["Polycarp"]}, {"input": "74005 7316 74004 7412\r\n", "output": ["Vasiliy"]}, {"input": "53208 42123 95332 85846\r\n", "output": ["Polycarp"]}, {"input": "14969 66451 81419 29039\r\n", "output": ["Vasiliy"]}, {"input": "50042 34493 84536 17892\r\n", "output": ["Polycarp"]}, {"input": "67949 70623 71979 70623\r\n", "output": ["Polycarp"]}, {"input": "67603 35151 67603 39519\r\n", "output": ["Polycarp"]}, {"input": "27149 26539 53690 17953\r\n", "output": ["Polycarp"]}, {"input": "36711 38307 75018 72040\r\n", "output": ["Polycarp"]}, {"input": "4650 67347 71998 50474\r\n", "output": ["Polycarp"]}, {"input": "4075 33738 4561 33738\r\n", "output": ["Polycarp"]}, {"input": "35868 55066 47754 55066\r\n", "output": ["Polycarp"]}, {"input": "41150 1761 41152 1841\r\n", "output": ["Polycarp"]}, {"input": "63557 16718 38133 80275\r\n", "output": ["Polycarp"]}, {"input": "8956 24932 30356 33887\r\n", "output": ["Polycarp"]}, {"input": "27338 8401 27337 12321\r\n", "output": ["Vasiliy"]}, {"input": "56613 48665 66408 48665\r\n", "output": ["Polycarp"]}, {"input": "34750 34886 34751 44842\r\n", "output": ["Polycarp"]}, {"input": "7591 24141 31732 23276\r\n", "output": ["Polycarp"]}, {"input": "2333 91141 93473 66469\r\n", "output": ["Vasiliy"]}, {"input": "9 0 8 0\r\n", "output": ["Vasiliy"]}, {"input": "0 1000 100 99\r\n", "output": ["Vasiliy"]}, {"input": "4 4 2 2\r\n", "output": ["Vasiliy"]}, {"input": "0 4 4 3\r\n", "output": ["Polycarp"]}, {"input": "100 1 1 100\r\n", "output": ["Vasiliy"]}, {"input": "9 17 14 16\r\n", "output": ["Vasiliy"]}, {"input": "0 3 3 1\r\n", "output": ["Polycarp"]}, {"input": "10 0 0 10\r\n", "output": ["Polycarp"]}, {"input": "5 0 0 4\r\n", "output": ["Vasiliy"]}, {"input": "2 1 1 3\r\n", "output": ["Polycarp"]}, {"input": "4 5 5 5\r\n", "output": ["Polycarp"]}, {"input": "0 3 2 2\r\n", "output": ["Vasiliy"]}, {"input": "3 0 0 10\r\n", "output": ["Polycarp"]}]
100
100
100
[{'input': '0 2 1 1\r\n', 'output': ['Vasiliy']}, {'input': '0 2 0 1\r\n', 'output': ['Vasiliy']}, {'input': '2 0 1 2\r\n', 'output': ['Polycarp']}, {'input': '4 7 7 4\r\n', 'output': ['Vasiliy']}, {'input': '4 4 2 2\r\n', 'output': ['Vasiliy']}]
[{'input': '2 0 2 1\r\n', 'output': ['Polycarp']}, {'input': '9 0 8 0\r\n', 'output': ['Vasiliy']}, {'input': '43308 1372 53325 1370\r\n', 'output': ['Polycarp']}, {'input': '2 1 1 2\r\n', 'output': ['Vasiliy']}, {'input': '67603 35151 67603 39519\r\n', 'output': ['Polycarp']}]
[{'input': '80 100 77 103\r\n', 'output': ['Vasiliy']}, {'input': '2 2 2 0\r\n', 'output': ['Vasiliy']}, {'input': '3 0 0 10\r\n', 'output': ['Polycarp']}, {'input': '41150 1761 41152 1841\r\n', 'output': ['Polycarp']}, {'input': '43308 1372 53325 1370\r\n', 'output': ['Polycarp']}]
[{'input': '80 100 83 97\r\n', 'output': ['Vasiliy']}, {'input': '50042 34493 84536 17892\r\n', 'output': ['Polycarp']}, {'input': '1 2 2 1\r\n', 'output': ['Vasiliy']}, {'input': '0 1 1 2\r\n', 'output': ['Polycarp']}, {'input': '0 3 2 2\r\n', 'output': ['Vasiliy']}]
[{'input': '0 1 2 2\r\n', 'output': ['Polycarp']}, {'input': '1 0 1 1\r\n', 'output': ['Polycarp']}, {'input': '0 1 2 1\r\n', 'output': ['Polycarp']}, {'input': '55000 60000 55003 60100\r\n', 'output': ['Polycarp']}, {'input': '4075 33738 4561 33738\r\n', 'output': ['Polycarp']}]
100
100
100
100
100
100
100
100
100
75
100
100
100
100
50
385
100
95
90
["4\nZCTH", "5\nZDATG", "6\nAFBAKC"]
The first line contains a single integer $$$n$$$ ($$$4 \leq n \leq 50$$$)Β β€” the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of exactly $$$n$$$ uppercase letters of the Latin alphabet.
ee4f88abe4c9fa776abd15c5f3a94543
def solve(a, b): return min((26 + a - b) % 26, (26 + b - a) % 26) def main(): n = int(input()) s = input().lower() print(min((sum((solve(ord(a), ord(b)) for a, b in zip(s[i:i + 4], 'actg'))) for i in range(n - 3)))) main()
["2", "5", "16"]
Python
NoteIn the first example, you should replace the letter "Z" with "A" for one operation, the letter "H"Β β€” with the letter "G" for one operation. You will get the string "ACTG", in which the genome is present as a substring.In the second example, we replace the letter "A" with "C" for two operations, the letter "D"Β β€” with the letter "A" for three operations. You will get the string "ZACTG", in which there is a genome.
Output the minimum number of operations that need to be applied to the string $$$s$$$ so that the genome appears as a substring in it.
Today in the scientific lyceum of the Kingdom of Kremland, there was a biology lesson. The topic of the lesson was the genomes. Let's call the genome the string "ACTG".Maxim was very boring to sit in class, so the teacher came up with a task for him: on a given string $$$s$$$ consisting of uppercase letters and length of at least $$$4$$$, you need to find the minimum number of operations that you need to apply, so that the genome appears in it as a substring. For one operation, you can replace any letter in the string $$$s$$$ with the next or previous in the alphabet. For example, for the letter "D" the previous one will be "C", and the nextΒ β€” "E". In this problem, we assume that for the letter "A", the previous one will be the letter "Z", and the next one will be "B", and for the letter "Z", the previous one is the letter "Y", and the next one is the letter "A".Help Maxim solve the problem that the teacher gave him.A string $$$a$$$ is a substring of a string $$$b$$$ if $$$a$$$ can be obtained from $$$b$$$ by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.
[{"input": "4\r\nZCTH\r\n", "output": ["2"]}, {"input": "5\r\nZDATG\r\n", "output": ["5"]}, {"input": "6\r\nAFBAKC\r\n", "output": ["16"]}, {"input": "9\r\nAAABBBCCC\r\n", "output": ["14"]}, {"input": "8\r\nABCDABCD\r\n", "output": ["13"]}, {"input": "4\r\nNPGT\r\n", "output": ["52"]}, {"input": "10\r\nABABABABAB\r\n", "output": ["13"]}, {"input": "8\r\nBBAACCZZ\r\n", "output": ["14"]}, {"input": "50\r\nALWLSFLXYPQYMIWXMYMXFYMIVFYJDTJAIGVOAUDAIIAHKNNVTX\r\n", "output": ["13"]}, {"input": "30\r\nTHCVHIPLYOOFCNWQJMBMEDTXLTCKMF\r\n", "output": ["10"]}, {"input": "39\r\nIHESTJHHSZRSHNUSPGMHDTKOJFEFLAUDXUEQWLO\r\n", "output": ["11"]}, {"input": "33\r\nIQHJDOVAGCIAEBAIXQYQCDVZGVOYIIYPR\r\n", "output": ["12"]}, {"input": "32\r\nIWMQCTKRNXICANQUPLBOMDNRBOWWIXZB\r\n", "output": ["14"]}, {"input": "6\r\nNQNEVX\r\n", "output": ["26"]}, {"input": "17\r\nGNPBRASKVPECJKECD\r\n", "output": ["16"]}, {"input": "18\r\nKNGWZFHGQIADTBYWDC\r\n", "output": ["6"]}, {"input": "14\r\nZXPFXCBVESQGAE\r\n", "output": ["7"]}, {"input": "37\r\nINUZOUSGLBHKDEFTQANRPIYMIBFLRTYFNWIFQ\r\n", "output": ["17"]}, {"input": "50\r\nVKRGXLUWYURTRNGAODFLYCKAPHGPHGDLWIGXEYVOAVYYXVDRAB\r\n", "output": ["12"]}, {"input": "50\r\nGOHDHOWWPMZBSEKHDBDKLIYRFEPOUHIHOHPUMVDAQRZDJMUBWV\r\n", "output": ["5"]}, {"input": "50\r\nQFWWIROYKRLAYBPSEXATCWILUBAZPWSGSKLTBLZOLZPHJKQQGF\r\n", "output": ["9"]}, {"input": "50\r\nROWGGKNUITVHOBMKZXOZNBZMQGSFERNCZDFKLRBCFVVDXJEFLP\r\n", "output": ["13"]}, {"input": "50\r\nYUPJIRNPTCFJIPODTHJXTWJUTLKCUYFNZKMJRBZZYBPEDYLKCY\r\n", "output": ["9"]}, {"input": "50\r\nZOMSHKIFVAMFATEIIEUJVITTYZGDWCGSOJMFQNYACRPOLGUZCM\r\n", "output": ["9"]}, {"input": "50\r\nLQFSFNEFCPBEARPMOGSSQVHAGNKOQXXCZKHSAEPTEHWOWSZMKH\r\n", "output": ["13"]}, {"input": "50\r\nHKKUWHLYYKBLLEHKVNIRYAPVFTAPRIFUZELKGRDXZNCNWHSAFG\r\n", "output": ["14"]}, {"input": "50\r\nMGDXLMPDPKUQOIMTLDUDTGTOMJCSYNRTSQSJANYDDPWQYTDTAW\r\n", "output": ["7"]}, {"input": "8\r\nACTGACTG\r\n", "output": ["0"]}, {"input": "10\r\nZZZZZZZZZZ\r\n", "output": ["17"]}, {"input": "8\r\nNPGTNPGT\r\n", "output": ["22"]}, {"input": "5\r\nACTGA\r\n", "output": ["0"]}, {"input": "4\r\nAZTG\r\n", "output": ["3"]}, {"input": "4\r\nYCTG\r\n", "output": ["2"]}, {"input": "4\r\nANTG\r\n", "output": ["11"]}, {"input": "4\r\nOCTG\r\n", "output": ["12"]}, {"input": "4\r\nACHG\r\n", "output": ["12"]}]
100
100
100
[{'input': '4\r\nAZTG\r\n', 'output': ['3']}, {'input': '37\r\nINUZOUSGLBHKDEFTQANRPIYMIBFLRTYFNWIFQ\r\n', 'output': ['17']}, {'input': '33\r\nIQHJDOVAGCIAEBAIXQYQCDVZGVOYIIYPR\r\n', 'output': ['12']}, {'input': '4\r\nOCTG\r\n', 'output': ['12']}, {'input': '4\r\nANTG\r\n', 'output': ['11']}]
[{'input': '17\r\nGNPBRASKVPECJKECD\r\n', 'output': ['16']}, {'input': '32\r\nIWMQCTKRNXICANQUPLBOMDNRBOWWIXZB\r\n', 'output': ['14']}, {'input': '50\r\nMGDXLMPDPKUQOIMTLDUDTGTOMJCSYNRTSQSJANYDDPWQYTDTAW\r\n', 'output': ['7']}, {'input': '50\r\nYUPJIRNPTCFJIPODTHJXTWJUTLKCUYFNZKMJRBZZYBPEDYLKCY\r\n', 'output': ['9']}, {'input': '50\r\nQFWWIROYKRLAYBPSEXATCWILUBAZPWSGSKLTBLZOLZPHJKQQGF\r\n', 'output': ['9']}]
[{'input': '33\r\nIQHJDOVAGCIAEBAIXQYQCDVZGVOYIIYPR\r\n', 'output': ['12']}, {'input': '9\r\nAAABBBCCC\r\n', 'output': ['14']}, {'input': '32\r\nIWMQCTKRNXICANQUPLBOMDNRBOWWIXZB\r\n', 'output': ['14']}, {'input': '50\r\nZOMSHKIFVAMFATEIIEUJVITTYZGDWCGSOJMFQNYACRPOLGUZCM\r\n', 'output': ['9']}, {'input': '4\r\nOCTG\r\n', 'output': ['12']}]
[{'input': '50\r\nGOHDHOWWPMZBSEKHDBDKLIYRFEPOUHIHOHPUMVDAQRZDJMUBWV\r\n', 'output': ['5']}, {'input': '8\r\nABCDABCD\r\n', 'output': ['13']}, {'input': '4\r\nACHG\r\n', 'output': ['12']}, {'input': '18\r\nKNGWZFHGQIADTBYWDC\r\n', 'output': ['6']}, {'input': '50\r\nMGDXLMPDPKUQOIMTLDUDTGTOMJCSYNRTSQSJANYDDPWQYTDTAW\r\n', 'output': ['7']}]
[{'input': '4\r\nYCTG\r\n', 'output': ['2']}, {'input': '4\r\nANTG\r\n', 'output': ['11']}, {'input': '50\r\nYUPJIRNPTCFJIPODTHJXTWJUTLKCUYFNZKMJRBZZYBPEDYLKCY\r\n', 'output': ['9']}, {'input': '50\r\nQFWWIROYKRLAYBPSEXATCWILUBAZPWSGSKLTBLZOLZPHJKQQGF\r\n', 'output': ['9']}, {'input': '39\r\nIHESTJHHSZRSHNUSPGMHDTKOJFEFLAUDXUEQWLO\r\n', 'output': ['11']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
386
100
100
100
["1 10 9 20 1", "1 100 50 200 75"]
The only line of the input contains integers l1, r1, l2, r2 and k (1 ≀ l1, r1, l2, r2, k ≀ 1018, l1 ≀ r1, l2 ≀ r2), providing the segments of time for Sonya and Filya and the moment of time when Sonya prinks.
9a74b3b0e9f3a351f2136842e9565a82
data = [int(info) for info in input().split(' ')] if data[0] == data[2] and data[1] == data[3]: time = data[1] - data[0] + 1 if data[4] >= data[0] and data[4] <= data[1]: time -= 1 elif (((data[2] < data[0]) and (data[2] < data[1])) and ((data[3] < data[0]) and (data[3] < data[1]))) or (((data[1] < data[2]) and (data[0] < data[2])) and ((data[0] < data[3]) and (data[0] < data[3]))): #import code #code.interact(local=locals()) #print('bine pa') time = 0 else: if data[0] < data[2]: if data[1] < data[3]: time = data[1] - data[2] + 1 if data[4] <= data[1] and data[4] >= data[2]: time -= 1 else: time = data[3] - data[2] + 1 if data[4] <= data[3] and data[4] >= data[2]: time -= 1 else: if data[1] > data[3]: time = data[3] - data[0] + 1 #import code #code.interact(local=locals()) if data[4] <= data[3] and data[4] >= data[0]: time -= 1 else: time = data[1] - data[0] + 1 if data[4] >= data[0] and data[4] <= data[1]: time -= 1 print(time)
["2", "50"]
Python
NoteIn the first sample, they will be together during minutes 9 and 10.In the second sample, they will be together from minute 50 to minute 74 and from minute 76 to minute 100.
Print one integerΒ β€” the number of minutes Sonya and Filya will be able to spend together.
Today an outstanding event is going to happen in the forestΒ β€” hedgehog Filya will come to his old fried Sonya!Sonya is an owl and she sleeps during the day and stay awake from minute l1 to minute r1 inclusive. Also, during the minute k she prinks and is unavailable for Filya.Filya works a lot and he plans to visit Sonya from minute l2 to minute r2 inclusive.Calculate the number of minutes they will be able to spend together.
[{"input": "1 10 9 20 1\r\n", "output": ["2"]}, {"input": "1 100 50 200 75\r\n", "output": ["50"]}, {"input": "6 6 5 8 9\r\n", "output": ["1"]}, {"input": "1 1000000000 1 1000000000 1\r\n", "output": ["999999999"]}, {"input": "5 100 8 8 8\r\n", "output": ["0"]}, {"input": "1 1000000000000000000 2 99999999999999999 1000000000\r\n", "output": ["99999999999999997"]}, {"input": "1 1 1 1 1\r\n", "output": ["0"]}, {"input": "1 2 3 4 5\r\n", "output": ["0"]}, {"input": "1 1000000000 2 999999999 3141592\r\n", "output": ["999999997"]}, {"input": "24648817341102 41165114064236 88046848035 13602161452932 10000831349205\r\n", "output": ["0"]}, {"input": "1080184299348 34666828555290 6878390132365 39891656267344 15395310291636\r\n", "output": ["27788438422925"]}, {"input": "11814 27385 22309 28354 23595\r\n", "output": ["5076"]}, {"input": "4722316546398 36672578279675 796716437180 33840047334985 13411035401708\r\n", "output": ["29117730788587"]}, {"input": "14300093617438 14381698008501 6957847034861 32510754974307 66056597033082\r\n", "output": ["81604391064"]}, {"input": "700062402405871919 762322967106512617 297732773882447821 747309903322652819 805776739998108178\r\n", "output": ["47247500916780901"]}, {"input": "59861796371397621 194872039092923459 668110259718450585 841148673332698972 928360292123223779\r\n", "output": ["0"]}, {"input": "298248781360904821 346420922793050061 237084570581741798 726877079564549183 389611850470532358\r\n", "output": ["48172141432145241"]}, {"input": "420745791717606818 864206437350900994 764928840030524015 966634105370748487 793326512080703489\r\n", "output": ["99277597320376979"]}, {"input": "519325240668210886 776112702001665034 360568516809443669 875594219634943179 994594983925273138\r\n", "output": ["256787461333454149"]}, {"input": "170331212821058551 891149660635282032 125964175621755330 208256491683509799 526532153531983174\r\n", "output": ["37925278862451249"]}, {"input": "1 3 3 5 3\r\n", "output": ["0"]}, {"input": "1 5 8 10 9\r\n", "output": ["0"]}, {"input": "1 2 4 5 10\r\n", "output": ["0"]}, {"input": "1 2 2 3 5\r\n", "output": ["1"]}, {"input": "2 4 3 7 3\r\n", "output": ["1"]}, {"input": "1 2 9 10 1\r\n", "output": ["0"]}, {"input": "5 15 1 10 5\r\n", "output": ["5"]}, {"input": "1 4 9 20 25\r\n", "output": ["0"]}, {"input": "2 4 1 2 5\r\n", "output": ["1"]}, {"input": "10 1000 1 100 2\r\n", "output": ["91"]}, {"input": "1 3 3 8 10\r\n", "output": ["1"]}, {"input": "4 6 6 8 9\r\n", "output": ["1"]}, {"input": "2 3 1 4 3\r\n", "output": ["1"]}, {"input": "1 2 2 3 100\r\n", "output": ["1"]}, {"input": "1 2 100 120 2\r\n", "output": ["0"]}, {"input": "1 3 5 7 4\r\n", "output": ["0"]}, {"input": "1 3 5 7 5\r\n", "output": ["0"]}, {"input": "1 4 8 10 6\r\n", "output": ["0"]}, {"input": "1 2 5 6 100\r\n", "output": ["0"]}, {"input": "1 2 5 10 20\r\n", "output": ["0"]}, {"input": "1 2 5 6 7\r\n", "output": ["0"]}, {"input": "2 5 7 12 6\r\n", "output": ["0"]}, {"input": "10 20 50 100 80\r\n", "output": ["0"]}, {"input": "1 2 5 10 2\r\n", "output": ["0"]}, {"input": "1 2 5 6 4\r\n", "output": ["0"]}, {"input": "5 9 1 2 3\r\n", "output": ["0"]}, {"input": "50 100 1 20 3\r\n", "output": ["0"]}, {"input": "10 20 3 7 30\r\n", "output": ["0"]}, {"input": "1 5 10 10 100\r\n", "output": ["0"]}, {"input": "100 101 1 2 3\r\n", "output": ["0"]}, {"input": "1 5 10 20 6\r\n", "output": ["0"]}, {"input": "1 10 15 25 5\r\n", "output": ["0"]}, {"input": "1 2 5 10 3\r\n", "output": ["0"]}, {"input": "2 3 5 6 100\r\n", "output": ["0"]}, {"input": "1 2 4 5 6\r\n", "output": ["0"]}, {"input": "6 10 1 2 40\r\n", "output": ["0"]}, {"input": "20 30 1 5 1\r\n", "output": ["0"]}, {"input": "20 40 50 100 50\r\n", "output": ["0"]}, {"input": "1 1 4 9 2\r\n", "output": ["0"]}, {"input": "1 2 5 6 1\r\n", "output": ["0"]}, {"input": "1 100 400 500 450\r\n", "output": ["0"]}, {"input": "5 6 1 2 5\r\n", "output": ["0"]}, {"input": "1 10 21 30 50\r\n", "output": ["0"]}, {"input": "100 200 300 400 101\r\n", "output": ["0"]}, {"input": "2 8 12 16 9\r\n", "output": ["0"]}, {"input": "1 5 7 9 6\r\n", "output": ["0"]}, {"input": "300 400 100 200 101\r\n", "output": ["0"]}, {"input": "1 2 2 3 10\r\n", "output": ["1"]}, {"input": "1 10 100 200 5\r\n", "output": ["0"]}, {"input": "1 3 3 4 4\r\n", "output": ["1"]}, {"input": "10 20 30 40 25\r\n", "output": ["0"]}, {"input": "1 2 5 10 1\r\n", "output": ["0"]}, {"input": "2 4 8 10 1\r\n", "output": ["0"]}, {"input": "2 5 10 15 7\r\n", "output": ["0"]}, {"input": "100 200 5 10 1\r\n", "output": ["0"]}, {"input": "1 2 100 200 300\r\n", "output": ["0"]}, {"input": "30 100 10 20 25\r\n", "output": ["0"]}, {"input": "10 20 1 5 6\r\n", "output": ["0"]}, {"input": "4 5 1 2 4\r\n", "output": ["0"]}, {"input": "11 100 1 9 1000\r\n", "output": ["0"]}, {"input": "1 1 10 10 228\r\n", "output": ["0"]}, {"input": "5 7 10 20 15\r\n", "output": ["0"]}, {"input": "1 3 8 9 7\r\n", "output": ["0"]}, {"input": "1 10 2 8 8\r\n", "output": ["6"]}, {"input": "1 5 9 15 1\r\n", "output": ["0"]}, {"input": "1 3 5 6 12\r\n", "output": ["0"]}, {"input": "1 100 500 1000 3\r\n", "output": ["0"]}, {"input": "1 1 1 1 2\r\n", "output": ["1"]}, {"input": "1 1000 100 1000 200\r\n", "output": ["900"]}, {"input": "4 5 1 4 1\r\n", "output": ["1"]}, {"input": "1 5 5 7 3\r\n", "output": ["1"]}, {"input": "1 4 4 10 11\r\n", "output": ["1"]}, {"input": "1 1 3 4 100\r\n", "output": ["0"]}, {"input": "1 4 3 5 6\r\n", "output": ["2"]}, {"input": "10 100 20 30 40\r\n", "output": ["11"]}, {"input": "5 9 1 11 7\r\n", "output": ["4"]}]
100
100
100
[{'input': '1 4 4 10 11\r\n', 'output': ['1']}, {'input': '1 2 100 200 300\r\n', 'output': ['0']}, {'input': '1 1 1 1 1\r\n', 'output': ['0']}, {'input': '30 100 10 20 25\r\n', 'output': ['0']}, {'input': '2 4 8 10 1\r\n', 'output': ['0']}]
[{'input': '1 4 3 5 6\r\n', 'output': ['2']}, {'input': '1 5 7 9 6\r\n', 'output': ['0']}, {'input': '2 3 5 6 100\r\n', 'output': ['0']}, {'input': '2 4 1 2 5\r\n', 'output': ['1']}, {'input': '1 1000000000000000000 2 99999999999999999 1000000000\r\n', 'output': ['99999999999999997']}]
[{'input': '1 10 9 20 1\r\n', 'output': ['2']}, {'input': '1 5 10 10 100\r\n', 'output': ['0']}, {'input': '519325240668210886 776112702001665034 360568516809443669 875594219634943179 994594983925273138\r\n', 'output': ['256787461333454149']}, {'input': '50 100 1 20 3\r\n', 'output': ['0']}, {'input': '1 2 5 6 1\r\n', 'output': ['0']}]
[{'input': '2 8 12 16 9\r\n', 'output': ['0']}, {'input': '1 2 5 6 7\r\n', 'output': ['0']}, {'input': '1 2 3 4 5\r\n', 'output': ['0']}, {'input': '4722316546398 36672578279675 796716437180 33840047334985 13411035401708\r\n', 'output': ['29117730788587']}, {'input': '1 10 15 25 5\r\n', 'output': ['0']}]
[{'input': '59861796371397621 194872039092923459 668110259718450585 841148673332698972 928360292123223779\r\n', 'output': ['0']}, {'input': '1 2 5 6 1\r\n', 'output': ['0']}, {'input': '2 4 8 10 1\r\n', 'output': ['0']}, {'input': '5 6 1 2 5\r\n', 'output': ['0']}, {'input': '1 5 7 9 6\r\n', 'output': ['0']}]
100
100
100
100
100
52.17
65.22
52.17
43.48
21.74
45.45
59.09
50
36.36
18.18
387
100
46.956
41.816
["1 1 1 1\n+ + *", "2 2 2 2\n* * +", "1 2 3 4\n* + +"]
First line contains four integers separated by space: 0 ≀ a, b, c, d ≀ 1000 β€” the original numbers. Second line contains three signs ('+' or '*' each) separated by space β€” the sequence of the operations in the order of performing. ('+' stands for addition, '*' β€” multiplication)
7a66fae63d9b27e444d84447012e484c
I=input a=I().split() def f(s,z): if not z:return int(s[0]) m=10**99 for i in s: t=s[::];t.remove(i) for j in t:k=t[::];k.remove(j);m=min(m,f(k+[str(eval(i+z[0]+j))],z[1:])) return m print(f(a,I().split()))
["3", "8", "9"]
Python
null
Output one integer number β€” the minimal result which can be obtained. 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).
Recently, Vladimir got bad mark in algebra again. To avoid such unpleasant events in future he decided to train his arithmetic skills. He wrote four integer numbers a, b, c, d on the blackboard. During each of the next three minutes he took two numbers from the blackboard (not necessarily adjacent) and replaced them with their sum or their product. In the end he got one number. Unfortunately, due to the awful memory he forgot that number, but he remembers four original numbers, sequence of the operations and his surprise because of the very small result. Help Vladimir remember the forgotten number: find the smallest number that can be obtained from the original numbers by the given sequence of operations.
[{"input": "1 1 1 1\r\n+ + *\r\n", "output": ["3"]}, {"input": "2 2 2 2\r\n* * +\r\n", "output": ["8"]}, {"input": "1 2 3 4\r\n* + +\r\n", "output": ["9"]}, {"input": "15 1 3 1\r\n* * +\r\n", "output": ["18"]}, {"input": "8 1 7 14\r\n+ + +\r\n", "output": ["30"]}, {"input": "7 17 3 25\r\n+ * +\r\n", "output": ["63"]}, {"input": "13 87 4 17\r\n* * *\r\n", "output": ["76908"]}, {"input": "7 0 8 15\r\n+ + *\r\n", "output": ["0"]}, {"input": "52 0 43 239\r\n+ + +\r\n", "output": ["334"]}, {"input": "1000 1000 999 1000\r\n* * *\r\n", "output": ["999000000000"]}, {"input": "720 903 589 804\r\n* * *\r\n", "output": ["307887168960"]}, {"input": "631 149 496 892\r\n* * +\r\n", "output": ["445884"]}, {"input": "220 127 597 394\r\n* + +\r\n", "output": ["28931"]}, {"input": "214 862 466 795\r\n+ + +\r\n", "output": ["2337"]}, {"input": "346 290 587 525\r\n* * *\r\n", "output": ["30922279500"]}, {"input": "323 771 559 347\r\n+ * *\r\n", "output": ["149067730"]}, {"input": "633 941 836 254\r\n* + +\r\n", "output": ["162559"]}, {"input": "735 111 769 553\r\n+ * *\r\n", "output": ["92320032"]}, {"input": "622 919 896 120\r\n* * +\r\n", "output": ["667592"]}, {"input": "652 651 142 661\r\n+ + +\r\n", "output": ["2106"]}, {"input": "450 457 975 35\r\n* * *\r\n", "output": ["7017806250"]}, {"input": "883 954 804 352\r\n* * +\r\n", "output": ["1045740"]}, {"input": "847 206 949 358\r\n* + *\r\n", "output": ["62660050"]}, {"input": "663 163 339 76\r\n+ + +\r\n", "output": ["1241"]}, {"input": "990 330 253 553\r\n+ * +\r\n", "output": ["85033"]}, {"input": "179 346 525 784\r\n* * *\r\n", "output": ["25492034400"]}, {"input": "780 418 829 778\r\n+ + *\r\n", "output": ["997766"]}, {"input": "573 598 791 124\r\n* * *\r\n", "output": ["33608874936"]}, {"input": "112 823 202 223\r\n* * +\r\n", "output": ["137222"]}, {"input": "901 166 994 315\r\n* + *\r\n", "output": ["47278294"]}, {"input": "393 342 840 486\r\n+ * *\r\n", "output": ["178222356"]}, {"input": "609 275 153 598\r\n+ + *\r\n", "output": ["226746"]}, {"input": "56 828 386 57\r\n+ * *\r\n", "output": ["3875088"]}, {"input": "944 398 288 986\r\n+ + *\r\n", "output": ["670464"]}, {"input": "544 177 162 21\r\n+ + *\r\n", "output": ["18543"]}, {"input": "105 238 316 265\r\n+ + +\r\n", "output": ["924"]}, {"input": "31 353 300 911\r\n* * *\r\n", "output": ["2990721900"]}, {"input": "46 378 310 194\r\n* * +\r\n", "output": ["77528"]}, {"input": "702 534 357 657\r\n+ * *\r\n", "output": ["259077042"]}, {"input": "492 596 219 470\r\n+ + *\r\n", "output": ["341202"]}, {"input": "482 842 982 902\r\n+ * +\r\n", "output": ["407728"]}, {"input": "827 578 394 351\r\n* * *\r\n", "output": ["66105361764"]}, {"input": "901 884 426 451\r\n* + *\r\n", "output": ["170223210"]}, {"input": "210 295 12 795\r\n* * +\r\n", "output": ["71490"]}, {"input": "40 734 948 202\r\n+ * *\r\n", "output": ["13590560"]}, {"input": "136 611 963 195\r\n+ + *\r\n", "output": ["240584"]}, {"input": "695 74 871 760\r\n+ * +\r\n", "output": ["53061"]}, {"input": "666 884 772 54\r\n* + +\r\n", "output": ["37620"]}, {"input": "975 785 753 224\r\n+ * +\r\n", "output": ["170432"]}, {"input": "35 187 126 596\r\n+ + +\r\n", "output": ["944"]}, {"input": "243 386 431 35\r\n* + *\r\n", "output": ["3298015"]}, {"input": "229 602 133 635\r\n* * +\r\n", "output": ["222313"]}, {"input": "916 207 238 891\r\n+ + *\r\n", "output": ["423315"]}, {"input": "922 145 883 357\r\n+ + *\r\n", "output": ["313490"]}, {"input": "69 355 762 111\r\n* + +\r\n", "output": ["8776"]}, {"input": "209 206 34 67\r\n* + *\r\n", "output": ["476374"]}, {"input": "693 824 375 361\r\n* * +\r\n", "output": ["557339"]}, {"input": "45 712 635 467\r\n* + +\r\n", "output": ["22362"]}, {"input": "426 283 179 211\r\n+ + +\r\n", "output": ["1099"]}, {"input": "802 387 686 12\r\n+ + +\r\n", "output": ["1887"]}]
100
100
100
[{'input': '735 111 769 553\r\n+ * *\r\n', 'output': ['92320032']}, {'input': '209 206 34 67\r\n* + *\r\n', 'output': ['476374']}, {'input': '15 1 3 1\r\n* * +\r\n', 'output': ['18']}, {'input': '652 651 142 661\r\n+ + +\r\n', 'output': ['2106']}, {'input': '220 127 597 394\r\n* + +\r\n', 'output': ['28931']}]
[{'input': '944 398 288 986\r\n+ + *\r\n', 'output': ['670464']}, {'input': '663 163 339 76\r\n+ + +\r\n', 'output': ['1241']}, {'input': '883 954 804 352\r\n* * +\r\n', 'output': ['1045740']}, {'input': '975 785 753 224\r\n+ * +\r\n', 'output': ['170432']}, {'input': '105 238 316 265\r\n+ + +\r\n', 'output': ['924']}]
[{'input': '8 1 7 14\r\n+ + +\r\n', 'output': ['30']}, {'input': '944 398 288 986\r\n+ + *\r\n', 'output': ['670464']}, {'input': '105 238 316 265\r\n+ + +\r\n', 'output': ['924']}, {'input': '35 187 126 596\r\n+ + +\r\n', 'output': ['944']}, {'input': '901 884 426 451\r\n* + *\r\n', 'output': ['170223210']}]
[{'input': '622 919 896 120\r\n* * +\r\n', 'output': ['667592']}, {'input': '214 862 466 795\r\n+ + +\r\n', 'output': ['2337']}, {'input': '735 111 769 553\r\n+ * *\r\n', 'output': ['92320032']}, {'input': '40 734 948 202\r\n+ * *\r\n', 'output': ['13590560']}, {'input': '393 342 840 486\r\n+ * *\r\n', 'output': ['178222356']}]
[{'input': '901 884 426 451\r\n* + *\r\n', 'output': ['170223210']}, {'input': '35 187 126 596\r\n+ + +\r\n', 'output': ['944']}, {'input': '652 651 142 661\r\n+ + +\r\n', 'output': ['2106']}, {'input': '944 398 288 986\r\n+ + *\r\n', 'output': ['670464']}, {'input': '720 903 589 804\r\n* * *\r\n', 'output': ['307887168960']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
388
100
100
100
["4\n3 2 1 2", "3\n2 3 8"]
The first line of input contains an integer n (1 ≀ n ≀ 100), the number of the columns in the box. The next line contains n space-separated integer numbers. The i-th number ai (1 ≀ ai ≀ 100) denotes the number of cubes in the i-th column.
ae20712265d4adf293e75d016b4b82d8
number_of_columns = int(input()) box_p_column = [int(i) for i in input().split(' ')] box_p_column = [str(i) for i in sorted(box_p_column)] print(' '.join(box_p_column).strip())
["1 2 2 3", "2 3 8"]
Python
NoteThe first example case is shown on the figure. The top cube of the first column falls to the top of the last column; the top cube of the second column falls to the top of the third column; the middle cube of the first column falls to the top of the second column.In the second example case the gravity switch does not change the heights of the columns.
Output n integer numbers separated by spaces, where the i-th number is the amount of cubes in the i-th column after the gravity switch.
Little Chris is bored during his physics lessons (too easy), so he has built a toy box to keep himself occupied. The box is special, since it has the ability to change gravity.There are n columns of toy cubes in the box arranged in a line. The i-th column contains ai cubes. At first, the gravity in the box is pulling the cubes downwards. When Chris switches the gravity, it begins to pull all the cubes to the right side of the box. The figure shows the initial and final configurations of the cubes in the box: the cubes that have changed their position are highlighted with orange. Given the initial configuration of the toy cubes in the box, find the amounts of cubes in each of the n columns after the gravity switch!
[{"input": "4\r\n3 2 1 2\r\n", "output": ["1 2 2 3"]}, {"input": "3\r\n2 3 8\r\n", "output": ["2 3 8"]}, {"input": "5\r\n2 1 2 1 2\r\n", "output": ["1 1 2 2 2"]}, {"input": "1\r\n1\r\n", "output": ["1"]}, {"input": "2\r\n4 3\r\n", "output": ["3 4"]}, {"input": "6\r\n100 40 60 20 1 80\r\n", "output": ["1 20 40 60 80 100"]}, {"input": "10\r\n10 8 6 7 5 3 4 2 9 1\r\n", "output": ["1 2 3 4 5 6 7 8 9 10"]}, {"input": "10\r\n1 2 3 4 5 6 7 8 9 10\r\n", "output": ["1 2 3 4 5 6 7 8 9 10"]}, {"input": "100\r\n82 51 81 14 37 17 78 92 64 15 8 86 89 8 87 77 66 10 15 12 100 25 92 47 21 78 20 63 13 49 41 36 41 79 16 87 87 69 3 76 80 60 100 49 70 59 72 8 38 71 45 97 71 14 76 54 81 4 59 46 39 29 92 3 49 22 53 99 59 52 74 31 92 43 42 23 44 9 82 47 7 40 12 9 3 55 37 85 46 22 84 52 98 41 21 77 63 17 62 91\r\n", "output": ["3 3 3 4 7 8 8 8 9 9 10 12 12 13 14 14 15 15 16 17 17 20 21 21 22 22 23 25 29 31 36 37 37 38 39 40 41 41 41 42 43 44 45 46 46 47 47 49 49 49 51 52 52 53 54 55 59 59 59 60 62 63 63 64 66 69 70 71 71 72 74 76 76 77 77 78 78 79 80 81 81 82 82 84 85 86 87 87 87 89 91 92 92 92 92 97 98 99 100 100"]}, {"input": "100\r\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\r\n", "output": ["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 100"]}, {"input": "10\r\n1 9 7 6 2 4 7 8 1 3\r\n", "output": ["1 1 2 3 4 6 7 7 8 9"]}, {"input": "20\r\n53 32 64 20 41 97 50 20 66 68 22 60 74 61 97 54 80 30 72 59\r\n", "output": ["20 20 22 30 32 41 50 53 54 59 60 61 64 66 68 72 74 80 97 97"]}, {"input": "30\r\n7 17 4 18 16 12 14 10 1 13 2 16 13 17 8 16 13 14 9 17 17 5 13 5 1 7 6 20 18 12\r\n", "output": ["1 1 2 4 5 5 6 7 7 8 9 10 12 12 13 13 13 13 14 14 16 16 16 17 17 17 17 18 18 20"]}, {"input": "40\r\n22 58 68 58 48 53 52 1 16 78 75 17 63 15 36 32 78 75 49 14 42 46 66 54 49 82 40 43 46 55 12 73 5 45 61 60 1 11 31 84\r\n", "output": ["1 1 5 11 12 14 15 16 17 22 31 32 36 40 42 43 45 46 46 48 49 49 52 53 54 55 58 58 60 61 63 66 68 73 75 75 78 78 82 84"]}, {"input": "70\r\n1 3 3 1 3 3 1 1 1 3 3 2 3 3 1 1 1 2 3 1 3 2 3 3 3 2 2 3 1 3 3 2 1 1 2 1 2 1 2 2 1 1 1 3 3 2 3 2 3 2 3 3 2 2 2 3 2 3 3 3 1 1 3 3 1 1 1 1 3 1\r\n", "output": ["1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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 3"]}, {"input": "90\r\n17 75 51 30 100 5 50 95 51 73 66 5 7 76 43 49 23 55 3 24 95 79 10 11 44 93 17 99 53 66 82 66 63 76 19 4 51 71 75 43 27 5 24 19 48 7 91 15 55 21 7 6 27 10 2 91 64 58 18 21 16 71 90 88 21 20 6 6 95 85 11 7 40 65 52 49 92 98 46 88 17 48 85 96 77 46 100 34 67 52\r\n", "output": ["2 3 4 5 5 5 6 6 6 7 7 7 7 10 10 11 11 15 16 17 17 17 18 19 19 20 21 21 21 23 24 24 27 27 30 34 40 43 43 44 46 46 48 48 49 49 50 51 51 51 52 52 53 55 55 58 63 64 65 66 66 66 67 71 71 73 75 75 76 76 77 79 82 85 85 88 88 90 91 91 92 93 95 95 95 96 98 99 100 100"]}, {"input": "100\r\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\r\n", "output": ["1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"]}, {"input": "100\r\n1 1 1 1 2 1 1 1 1 1 2 2 1 1 2 1 2 1 1 1 2 1 1 2 1 2 1 1 2 2 2 1 1 2 1 1 1 2 2 2 1 1 1 2 1 2 2 1 2 1 1 2 2 1 2 1 2 1 2 2 1 1 1 2 1 1 2 1 2 1 2 2 2 1 2 1 2 2 2 1 2 2 1 1 1 1 2 2 2 2 2 2 2 1 1 1 2 1 2 1\r\n", "output": ["1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2"]}, {"input": "100\r\n2 1 1 1 3 2 3 3 2 3 3 1 3 3 1 3 3 1 1 1 2 3 1 2 3 1 2 3 3 1 3 1 1 2 3 2 3 3 2 3 3 1 2 2 1 2 3 2 3 2 2 1 1 3 1 3 2 1 3 1 3 1 3 1 1 3 3 3 2 3 2 2 2 2 1 3 3 3 1 2 1 2 3 2 1 3 1 3 2 1 3 1 2 1 2 3 1 3 2 3\r\n", "output": ["1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 2 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 3 3 3 3 3 3 3 3 3 3 3 3"]}, {"input": "100\r\n7 4 5 5 10 10 5 8 5 7 4 5 4 6 8 8 2 6 3 3 10 7 10 8 6 2 7 3 9 7 7 2 4 5 2 4 9 5 10 1 10 5 10 4 1 3 4 2 6 9 9 9 10 6 2 5 6 1 8 10 4 10 3 4 10 5 5 4 10 4 5 3 7 10 2 7 3 6 9 6 1 6 5 5 4 6 6 4 4 1 5 1 6 6 6 8 8 6 2 6\r\n", "output": ["1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 10 10 10"]}, {"input": "100\r\n12 10 5 11 13 12 14 13 7 15 15 12 13 19 12 18 14 10 10 3 1 10 16 11 19 8 10 15 5 10 12 16 11 13 11 15 14 12 16 8 11 8 15 2 18 2 14 13 15 20 8 8 4 12 14 7 10 3 9 1 7 19 6 7 2 14 8 20 7 17 18 20 3 18 18 9 6 10 4 1 4 19 9 13 3 3 12 11 11 20 8 2 13 6 7 12 1 4 17 3\r\n", "output": ["1 1 1 1 2 2 2 2 3 3 3 3 3 3 4 4 4 4 5 5 6 6 6 7 7 7 7 7 7 8 8 8 8 8 8 8 9 9 9 10 10 10 10 10 10 10 10 11 11 11 11 11 11 11 12 12 12 12 12 12 12 12 12 13 13 13 13 13 13 13 14 14 14 14 14 14 15 15 15 15 15 15 16 16 16 17 17 18 18 18 18 18 19 19 19 19 20 20 20 20"]}, {"input": "100\r\n5 13 1 40 30 10 23 32 33 12 6 4 15 29 31 17 23 5 36 31 32 38 24 11 34 39 19 21 6 19 31 35 1 15 6 29 22 15 17 15 1 17 2 34 20 8 27 2 29 26 13 9 22 27 27 3 20 40 4 40 33 29 36 30 35 16 19 28 26 11 36 24 29 5 40 10 38 34 33 23 34 39 31 7 10 31 22 6 36 24 14 31 34 23 2 4 26 16 2 32\r\n", "output": ["1 1 1 2 2 2 2 3 4 4 4 5 5 5 6 6 6 6 7 8 9 10 10 10 11 11 12 13 13 14 15 15 15 15 16 16 17 17 17 19 19 19 20 20 21 22 22 22 23 23 23 23 24 24 24 26 26 26 27 27 27 28 29 29 29 29 29 30 30 31 31 31 31 31 31 32 32 32 33 33 33 34 34 34 34 34 35 35 36 36 36 36 38 38 39 39 40 40 40 40"]}, {"input": "100\r\n72 44 34 74 9 60 26 37 55 77 74 69 28 66 54 55 8 36 57 31 31 48 32 66 40 70 77 43 64 28 37 10 21 58 51 32 60 28 51 52 28 35 7 33 1 68 38 70 57 71 8 20 42 57 59 4 58 10 17 47 22 48 16 3 76 67 32 37 64 47 33 41 75 69 2 76 39 9 27 75 20 21 52 25 71 21 11 29 38 10 3 1 45 55 63 36 27 7 59 41\r\n", "output": ["1 1 2 3 3 4 7 7 8 8 9 9 10 10 10 11 16 17 20 20 21 21 21 22 25 26 27 27 28 28 28 28 29 31 31 32 32 32 33 33 34 35 36 36 37 37 37 38 38 39 40 41 41 42 43 44 45 47 47 48 48 51 51 52 52 54 55 55 55 57 57 57 58 58 59 59 60 60 63 64 64 66 66 67 68 69 69 70 70 71 71 72 74 74 75 75 76 76 77 77"]}, {"input": "100\r\n75 18 61 10 56 53 42 57 79 80 31 2 50 45 54 99 84 52 71 21 86 3 19 98 14 37 40 62 63 68 5 10 87 8 81 85 52 52 57 94 2 7 56 96 19 76 1 13 81 6 80 47 22 59 99 32 9 5 36 88 98 91 70 70 12 93 12 22 85 1 97 48 94 16 84 84 51 34 62 7 68 51 30 2 37 82 4 7 27 1 80 9 61 16 59 55 12 96 94 82\r\n", "output": ["1 1 1 2 2 2 3 4 5 5 6 7 7 7 8 9 9 10 10 12 12 12 13 14 16 16 18 19 19 21 22 22 27 30 31 32 34 36 37 37 40 42 45 47 48 50 51 51 52 52 52 53 54 55 56 56 57 57 59 59 61 61 62 62 63 68 68 70 70 71 75 76 79 80 80 80 81 81 82 82 84 84 84 85 85 86 87 88 91 93 94 94 94 96 96 97 98 98 99 99"]}, {"input": "100\r\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\r\n", "output": ["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"]}, {"input": "100\r\n100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1\r\n", "output": ["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"]}, {"input": "100\r\n50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50\r\n", "output": ["50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50"]}, {"input": "49\r\n1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97\r\n", "output": ["1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97"]}, {"input": "30\r\n1 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 73 76 79 82 85 88\r\n", "output": ["1 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 73 76 79 82 85 88"]}, {"input": "100\r\n100 51 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n", "output": ["1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 51 100"]}, {"input": "10\r\n100 90 80 70 60 50 40 30 20 10\r\n", "output": ["10 20 30 40 50 60 70 80 90 100"]}, {"input": "1\r\n10\r\n", "output": ["10"]}]
100
100
100
[{'input': '4\r\n3 2 1 2\r\n', 'output': ['1 2 2 3']}, {'input': '49\r\n1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97\r\n', 'output': ['1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97']}, {'input': '30\r\n7 17 4 18 16 12 14 10 1 13 2 16 13 17 8 16 13 14 9 17 17 5 13 5 1 7 6 20 18 12\r\n', 'output': ['1 1 2 4 5 5 6 7 7 8 9 10 12 12 13 13 13 13 14 14 16 16 16 17 17 17 17 18 18 20']}, {'input': '70\r\n1 3 3 1 3 3 1 1 1 3 3 2 3 3 1 1 1 2 3 1 3 2 3 3 3 2 2 3 1 3 3 2 1 1 2 1 2 1 2 2 1 1 1 3 3 2 3 2 3 2 3 3 2 2 2 3 2 3 3 3 1 1 3 3 1 1 1 1 3 1\r\n', 'output': ['1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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 3']}, {'input': '30\r\n1 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 73 76 79 82 85 88\r\n', 'output': ['1 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 73 76 79 82 85 88']}]
[{'input': '40\r\n22 58 68 58 48 53 52 1 16 78 75 17 63 15 36 32 78 75 49 14 42 46 66 54 49 82 40 43 46 55 12 73 5 45 61 60 1 11 31 84\r\n', 'output': ['1 1 5 11 12 14 15 16 17 22 31 32 36 40 42 43 45 46 46 48 49 49 52 53 54 55 58 58 60 61 63 66 68 73 75 75 78 78 82 84']}, {'input': '5\r\n2 1 2 1 2\r\n', 'output': ['1 1 2 2 2']}, {'input': '100\r\n100 51 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n', 'output': ['1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 51 100']}, {'input': '30\r\n1 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 73 76 79 82 85 88\r\n', 'output': ['1 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 73 76 79 82 85 88']}, {'input': '100\r\n12 10 5 11 13 12 14 13 7 15 15 12 13 19 12 18 14 10 10 3 1 10 16 11 19 8 10 15 5 10 12 16 11 13 11 15 14 12 16 8 11 8 15 2 18 2 14 13 15 20 8 8 4 12 14 7 10 3 9 1 7 19 6 7 2 14 8 20 7 17 18 20 3 18 18 9 6 10 4 1 4 19 9 13 3 3 12 11 11 20 8 2 13 6 7 12 1 4 17 3\r\n', 'output': ['1 1 1 1 2 2 2 2 3 3 3 3 3 3 4 4 4 4 5 5 6 6 6 7 7 7 7 7 7 8 8 8 8 8 8 8 9 9 9 10 10 10 10 10 10 10 10 11 11 11 11 11 11 11 12 12 12 12 12 12 12 12 12 13 13 13 13 13 13 13 14 14 14 14 14 14 15 15 15 15 15 15 16 16 16 17 17 18 18 18 18 18 19 19 19 19 20 20 20 20']}]
[{'input': '100\r\n1 1 1 1 2 1 1 1 1 1 2 2 1 1 2 1 2 1 1 1 2 1 1 2 1 2 1 1 2 2 2 1 1 2 1 1 1 2 2 2 1 1 1 2 1 2 2 1 2 1 1 2 2 1 2 1 2 1 2 2 1 1 1 2 1 1 2 1 2 1 2 2 2 1 2 1 2 2 2 1 2 2 1 1 1 1 2 2 2 2 2 2 2 1 1 1 2 1 2 1\r\n', 'output': ['1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2']}, {'input': '100\r\n100 51 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n', 'output': ['1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 51 100']}, {'input': '100\r\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\r\n', 'output': ['1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1']}, {'input': '3\r\n2 3 8\r\n', 'output': ['2 3 8']}, {'input': '4\r\n3 2 1 2\r\n', 'output': ['1 2 2 3']}]
[{'input': '4\r\n3 2 1 2\r\n', 'output': ['1 2 2 3']}, {'input': '100\r\n82 51 81 14 37 17 78 92 64 15 8 86 89 8 87 77 66 10 15 12 100 25 92 47 21 78 20 63 13 49 41 36 41 79 16 87 87 69 3 76 80 60 100 49 70 59 72 8 38 71 45 97 71 14 76 54 81 4 59 46 39 29 92 3 49 22 53 99 59 52 74 31 92 43 42 23 44 9 82 47 7 40 12 9 3 55 37 85 46 22 84 52 98 41 21 77 63 17 62 91\r\n', 'output': ['3 3 3 4 7 8 8 8 9 9 10 12 12 13 14 14 15 15 16 17 17 20 21 21 22 22 23 25 29 31 36 37 37 38 39 40 41 41 41 42 43 44 45 46 46 47 47 49 49 49 51 52 52 53 54 55 59 59 59 60 62 63 63 64 66 69 70 71 71 72 74 76 76 77 77 78 78 79 80 81 81 82 82 84 85 86 87 87 87 89 91 92 92 92 92 97 98 99 100 100']}, {'input': '100\r\n50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50\r\n', 'output': ['50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50']}, {'input': '6\r\n100 40 60 20 1 80\r\n', 'output': ['1 20 40 60 80 100']}, {'input': '100\r\n5 13 1 40 30 10 23 32 33 12 6 4 15 29 31 17 23 5 36 31 32 38 24 11 34 39 19 21 6 19 31 35 1 15 6 29 22 15 17 15 1 17 2 34 20 8 27 2 29 26 13 9 22 27 27 3 20 40 4 40 33 29 36 30 35 16 19 28 26 11 36 24 29 5 40 10 38 34 33 23 34 39 31 7 10 31 22 6 36 24 14 31 34 23 2 4 26 16 2 32\r\n', 'output': ['1 1 1 2 2 2 2 3 4 4 4 5 5 5 6 6 6 6 7 8 9 10 10 10 11 11 12 13 13 14 15 15 15 15 16 16 17 17 17 19 19 19 20 20 21 22 22 22 23 23 23 23 24 24 24 26 26 26 27 27 27 28 29 29 29 29 29 30 30 31 31 31 31 31 31 32 32 32 33 33 33 34 34 34 34 34 35 35 36 36 36 36 38 38 39 39 40 40 40 40']}]
[{'input': '100\r\n100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1\r\n', 'output': ['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']}, {'input': '5\r\n2 1 2 1 2\r\n', 'output': ['1 1 2 2 2']}, {'input': '2\r\n4 3\r\n', 'output': ['3 4']}, {'input': '90\r\n17 75 51 30 100 5 50 95 51 73 66 5 7 76 43 49 23 55 3 24 95 79 10 11 44 93 17 99 53 66 82 66 63 76 19 4 51 71 75 43 27 5 24 19 48 7 91 15 55 21 7 6 27 10 2 91 64 58 18 21 16 71 90 88 21 20 6 6 95 85 11 7 40 65 52 49 92 98 46 88 17 48 85 96 77 46 100 34 67 52\r\n', 'output': ['2 3 4 5 5 5 6 6 6 7 7 7 7 10 10 11 11 15 16 17 17 17 18 19 19 20 21 21 21 23 24 24 27 27 30 34 40 43 43 44 46 46 48 48 49 49 50 51 51 51 52 52 53 55 55 58 63 64 65 66 66 66 67 71 71 73 75 75 76 76 77 79 82 85 85 88 88 90 91 91 92 93 95 95 95 96 98 99 100 100']}, {'input': '100\r\n75 18 61 10 56 53 42 57 79 80 31 2 50 45 54 99 84 52 71 21 86 3 19 98 14 37 40 62 63 68 5 10 87 8 81 85 52 52 57 94 2 7 56 96 19 76 1 13 81 6 80 47 22 59 99 32 9 5 36 88 98 91 70 70 12 93 12 22 85 1 97 48 94 16 84 84 51 34 62 7 68 51 30 2 37 82 4 7 27 1 80 9 61 16 59 55 12 96 94 82\r\n', 'output': ['1 1 1 2 2 2 3 4 5 5 6 7 7 7 8 9 9 10 10 12 12 12 13 14 16 16 18 19 19 21 22 22 27 30 31 32 34 36 37 37 40 42 45 47 48 50 51 51 52 52 52 53 54 55 56 56 57 57 59 59 61 61 62 62 63 68 68 70 70 71 75 76 79 80 80 80 81 81 82 82 84 84 84 85 85 86 87 88 91 93 94 94 94 96 96 97 98 98 99 99']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
389
100
100
100
["4 1 2", "8 2 6", "8 7 5"]
The only line contains three integers n, a and b (2 ≀ n ≀ 256, 1 ≀ a, b ≀ n)Β β€” the total number of teams, and the ids of the teams that Arkady is interested in. It is guaranteed that n is such that in each round an even number of team advance, and that a and b are not equal.
a753bfa7bde157e108f34a28240f441f
total_teams,team1,team2 = map(int,input().split()) count = 1 while True: if round((team1/2)+0.1)==round((team2/2)+0.1): break team1=round((team1/2)+0.1) team2=round((team2/2)+0.1) total_teams//=2 count+=1 if total_teams==2: print('Final!') else: print(count)
["1", "Final!", "2"]
Python
NoteIn the first example teams 1 and 2 meet in the first round.In the second example teams 2 and 6 can only meet in the third round, which is the Final, if they win all their opponents in earlier rounds.In the third example the teams with ids 7 and 5 can meet in the second round, if they win their opponents in the first round.
In the only line print "Final!" (without quotes), if teams a and b can meet in the Final. Otherwise, print a single integerΒ β€” the number of the round in which teams a and b can meet. The round are enumerated from 1.
The last stage of Football World Cup is played using the play-off system.There are n teams left in this stage, they are enumerated from 1 to n. Several rounds are held, in each round the remaining teams are sorted in the order of their ids, then the first in this order plays with the second, the thirdΒ β€” with the fourth, the fifthΒ β€” with the sixth, and so on. It is guaranteed that in each round there is even number of teams. The winner of each game advances to the next round, the loser is eliminated from the tournament, there are no draws. In the last round there is the only game with two remaining teams: the round is called the Final, the winner is called the champion, and the tournament is over.Arkady wants his two favorite teams to play in the Final. Unfortunately, the team ids are already determined, and it may happen that it is impossible for teams to meet in the Final, because they are to meet in some earlier stage, if they are strong enough. Determine, in which round the teams with ids a and b can meet.
[{"input": "4 1 2\r\n", "output": ["1"]}, {"input": "8 2 6\r\n", "output": ["Final!"]}, {"input": "8 7 5\r\n", "output": ["2"]}, {"input": "128 30 98\r\n", "output": ["Final!"]}, {"input": "256 128 256\r\n", "output": ["Final!"]}, {"input": "256 2 127\r\n", "output": ["7"]}, {"input": "2 1 2\r\n", "output": ["Final!"]}, {"input": "2 2 1\r\n", "output": ["Final!"]}, {"input": "4 1 3\r\n", "output": ["Final!"]}, {"input": "4 1 4\r\n", "output": ["Final!"]}, {"input": "4 2 1\r\n", "output": ["1"]}, {"input": "4 2 3\r\n", "output": ["Final!"]}, {"input": "4 2 4\r\n", "output": ["Final!"]}, {"input": "4 3 1\r\n", "output": ["Final!"]}, {"input": "4 3 2\r\n", "output": ["Final!"]}, {"input": "4 3 4\r\n", "output": ["1"]}, {"input": "4 4 1\r\n", "output": ["Final!"]}, {"input": "4 4 2\r\n", "output": ["Final!"]}, {"input": "4 4 3\r\n", "output": ["1"]}, {"input": "8 8 7\r\n", "output": ["1"]}, {"input": "8 8 5\r\n", "output": ["2"]}, {"input": "8 8 1\r\n", "output": ["Final!"]}, {"input": "16 4 3\r\n", "output": ["1"]}, {"input": "16 2 4\r\n", "output": ["2"]}, {"input": "16 14 11\r\n", "output": ["3"]}, {"input": "16 3 11\r\n", "output": ["Final!"]}, {"input": "32 10 9\r\n", "output": ["1"]}, {"input": "32 25 28\r\n", "output": ["2"]}, {"input": "32 22 18\r\n", "output": ["3"]}, {"input": "32 17 25\r\n", "output": ["4"]}, {"input": "32 18 3\r\n", "output": ["Final!"]}, {"input": "64 40 39\r\n", "output": ["1"]}, {"input": "64 60 58\r\n", "output": ["2"]}, {"input": "64 34 37\r\n", "output": ["3"]}, {"input": "64 26 24\r\n", "output": ["4"]}, {"input": "64 50 43\r\n", "output": ["5"]}, {"input": "64 17 42\r\n", "output": ["Final!"]}, {"input": "128 116 115\r\n", "output": ["1"]}, {"input": "128 35 33\r\n", "output": ["2"]}, {"input": "128 61 59\r\n", "output": ["3"]}, {"input": "128 116 123\r\n", "output": ["4"]}, {"input": "128 17 15\r\n", "output": ["5"]}, {"input": "128 124 77\r\n", "output": ["6"]}, {"input": "128 4 80\r\n", "output": ["Final!"]}, {"input": "256 224 223\r\n", "output": ["1"]}, {"input": "256 24 22\r\n", "output": ["2"]}, {"input": "256 199 196\r\n", "output": ["3"]}, {"input": "256 148 159\r\n", "output": ["4"]}, {"input": "256 178 166\r\n", "output": ["5"]}, {"input": "256 75 97\r\n", "output": ["6"]}, {"input": "256 185 200\r\n", "output": ["7"]}, {"input": "256 3 238\r\n", "output": ["Final!"]}, {"input": "256 128 129\r\n", "output": ["Final!"]}, {"input": "256 255 129\r\n", "output": ["7"]}, {"input": "256 255 128\r\n", "output": ["Final!"]}, {"input": "256 129 256\r\n", "output": ["7"]}, {"input": "128 98 69\r\n", "output": ["6"]}, {"input": "128 47 83\r\n", "output": ["Final!"]}, {"input": "16 2 3\r\n", "output": ["2"]}, {"input": "64 32 30\r\n", "output": ["2"]}, {"input": "8 4 5\r\n", "output": ["Final!"]}, {"input": "8 7 8\r\n", "output": ["1"]}, {"input": "8 2 3\r\n", "output": ["2"]}, {"input": "8 2 5\r\n", "output": ["Final!"]}]
100
100
100
[{'input': '16 4 3\r\n', 'output': ['1']}, {'input': '256 128 256\r\n', 'output': ['Final!']}, {'input': '8 8 5\r\n', 'output': ['2']}, {'input': '128 47 83\r\n', 'output': ['Final!']}, {'input': '64 60 58\r\n', 'output': ['2']}]
[{'input': '16 2 4\r\n', 'output': ['2']}, {'input': '16 14 11\r\n', 'output': ['3']}, {'input': '128 124 77\r\n', 'output': ['6']}, {'input': '128 116 115\r\n', 'output': ['1']}, {'input': '4 1 4\r\n', 'output': ['Final!']}]
[{'input': '256 255 129\r\n', 'output': ['7']}, {'input': '256 2 127\r\n', 'output': ['7']}, {'input': '32 17 25\r\n', 'output': ['4']}, {'input': '4 2 4\r\n', 'output': ['Final!']}, {'input': '16 4 3\r\n', 'output': ['1']}]
[{'input': '8 7 8\r\n', 'output': ['1']}, {'input': '4 1 4\r\n', 'output': ['Final!']}, {'input': '16 2 4\r\n', 'output': ['2']}, {'input': '128 116 115\r\n', 'output': ['1']}, {'input': '256 178 166\r\n', 'output': ['5']}]
[{'input': '256 128 129\r\n', 'output': ['Final!']}, {'input': '256 185 200\r\n', 'output': ['7']}, {'input': '256 178 166\r\n', 'output': ['5']}, {'input': '32 18 3\r\n', 'output': ['Final!']}, {'input': '4 2 4\r\n', 'output': ['Final!']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
390
100
100
100
["####\n.#..\n####\n....", "####\n....\n####\n...."]
Four lines contain four characters each: the j-th character of the i-th line equals "." if the cell in the i-th row and the j-th column of the square is painted white, and "#", if the cell is black.
01b145e798bbdf0ca2ecc383676d79f3
#!/usr/bin/env python # coding: utf-8 # In[14]: # # n = int(input()) # # line = list(map(int, input().split())) # # line = list(str(input())) # from tqdm import trange # In[24]: from collections import Counter # In[13]: matrix = [] for _ in range(4): matrix.append(list(str(input()))) # In[29]: ans = "NO" for i in range(3): for j in range(3): tmp_list = [matrix[i][j], matrix[i][j+1], matrix[i+1][j], matrix[i+1][j+1]] tmp_dict = Counter(tmp_list) if max(tmp_dict.values()) >= 3: ans = "YES" break print(ans) # In[ ]: # In[ ]:
["YES", "NO"]
Python
NoteIn the first test sample it is enough to repaint the first cell in the second row. After such repainting the required 2 × 2 square is on the intersection of the 1-st and 2-nd row with the 1-st and 2-nd column.
Print "YES" (without the quotes), if the test can be passed and "NO" (without the quotes) otherwise.
In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the person gets a piece of squared paper with a 4 × 4 square painted on it. Some of the square's cells are painted black and others are painted white. Your task is to repaint at most one cell the other color so that the picture has a 2 × 2 square, completely consisting of cells of the same color. If the initial picture already has such a square, the person should just say so and the test will be completed. Your task is to write a program that determines whether it is possible to pass the test. You cannot pass the test if either repainting any cell or no action doesn't result in a 2 × 2 square, consisting of cells of the same color.
[{"input": "####\r\n.#..\r\n####\r\n....\r\n", "output": ["YES"]}, {"input": "####\r\n....\r\n####\r\n....\r\n", "output": ["NO"]}, {"input": "....\r\n....\r\n....\r\n....\r\n", "output": ["YES"]}, {"input": "###.\r\n...#\r\n###.\r\n...#\r\n", "output": ["NO"]}, {"input": ".##.\r\n#..#\r\n.##.\r\n#..#\r\n", "output": ["NO"]}, {"input": ".#.#\r\n#.#.\r\n.#.#\r\n#.#.\r\n", "output": ["NO"]}, {"input": "##..\r\n..##\r\n##..\r\n..##\r\n", "output": ["NO"]}, {"input": "#.#.\r\n#.#.\r\n.#.#\r\n.#.#\r\n", "output": ["NO"]}, {"input": ".#.#\r\n#.#.\r\n#.#.\r\n#.#.\r\n", "output": ["NO"]}, {"input": ".#.#\r\n#.#.\r\n#.#.\r\n.#.#\r\n", "output": ["NO"]}, {"input": "#.#.\r\n#.#.\r\n#.#.\r\n#.#.\r\n", "output": ["NO"]}, {"input": ".#.#\r\n.#.#\r\n.#.#\r\n.#.#\r\n", "output": ["NO"]}, {"input": "#..#\r\n.##.\r\n####\r\n####\r\n", "output": ["YES"]}, {"input": "#.#.\r\n.###\r\n#.#.\r\n.###\r\n", "output": ["YES"]}, {"input": "#..#\r\n.##.\r\n.##.\r\n#..#\r\n", "output": ["YES"]}, {"input": ".##.\r\n.#..\r\n##.#\r\n#..#\r\n", "output": ["YES"]}, {"input": ".##.\r\n##..\r\n#..#\r\n..##\r\n", "output": ["YES"]}, {"input": "##..\r\n##..\r\n..##\r\n..##\r\n", "output": ["YES"]}, {"input": ".#..\r\n###.\r\n.#.#\r\n..#.\r\n", "output": ["YES"]}, {"input": "####\r\n#...\r\n#.#.\r\n#...\r\n", "output": ["YES"]}, {"input": "###.\r\n###.\r\n...#\r\n...#\r\n", "output": ["YES"]}, {"input": "####\r\n#..#\r\n.##.\r\n....\r\n", "output": ["YES"]}, {"input": "#.##\r\n##.#\r\n#.##\r\n##.#\r\n", "output": ["YES"]}, {"input": ".#.#\r\n#.#.\r\n.#.#\r\n#.##\r\n", "output": ["YES"]}, {"input": "##..\r\n..##\r\n##..\r\n...#\r\n", "output": ["YES"]}, {"input": ".#..\r\n..##\r\n##..\r\n..##\r\n", "output": ["YES"]}, {"input": "##..\r\n...#\r\n##..\r\n...#\r\n", "output": ["YES"]}, {"input": ".#..\r\n..#.\r\n.#..\r\n..#.\r\n", "output": ["YES"]}, {"input": "....\r\n....\r\n....\r\n.#.#\r\n", "output": ["YES"]}, {"input": "....\r\n....\r\n....\r\n...#\r\n", "output": ["YES"]}]
100
100
100
[{'input': '###.\r\n...#\r\n###.\r\n...#\r\n', 'output': ['NO']}, {'input': '####\r\n.#..\r\n####\r\n....\r\n', 'output': ['YES']}, {'input': '#..#\r\n.##.\r\n.##.\r\n#..#\r\n', 'output': ['YES']}, {'input': '.#..\r\n..##\r\n##..\r\n..##\r\n', 'output': ['YES']}, {'input': '.#..\r\n###.\r\n.#.#\r\n..#.\r\n', 'output': ['YES']}]
[{'input': '....\r\n....\r\n....\r\n...#\r\n', 'output': ['YES']}, {'input': '.#.#\r\n#.#.\r\n#.#.\r\n#.#.\r\n', 'output': ['NO']}, {'input': '##..\r\n..##\r\n##..\r\n..##\r\n', 'output': ['NO']}, {'input': '.##.\r\n#..#\r\n.##.\r\n#..#\r\n', 'output': ['NO']}, {'input': '.##.\r\n##..\r\n#..#\r\n..##\r\n', 'output': ['YES']}]
[{'input': '##..\r\n...#\r\n##..\r\n...#\r\n', 'output': ['YES']}, {'input': '####\r\n#..#\r\n.##.\r\n....\r\n', 'output': ['YES']}, {'input': '#.#.\r\n.###\r\n#.#.\r\n.###\r\n', 'output': ['YES']}, {'input': '.##.\r\n##..\r\n#..#\r\n..##\r\n', 'output': ['YES']}, {'input': '#..#\r\n.##.\r\n####\r\n####\r\n', 'output': ['YES']}]
[{'input': '#..#\r\n.##.\r\n####\r\n####\r\n', 'output': ['YES']}, {'input': '#..#\r\n.##.\r\n.##.\r\n#..#\r\n', 'output': ['YES']}, {'input': '###.\r\n...#\r\n###.\r\n...#\r\n', 'output': ['NO']}, {'input': '###.\r\n###.\r\n...#\r\n...#\r\n', 'output': ['YES']}, {'input': '.#.#\r\n#.#.\r\n.#.#\r\n#.##\r\n', 'output': ['YES']}]
[{'input': '.#.#\r\n#.#.\r\n#.#.\r\n.#.#\r\n', 'output': ['NO']}, {'input': '####\r\n....\r\n####\r\n....\r\n', 'output': ['NO']}, {'input': '####\r\n.#..\r\n####\r\n....\r\n', 'output': ['YES']}, {'input': '##..\r\n##..\r\n..##\r\n..##\r\n', 'output': ['YES']}, {'input': '.#..\r\n..#.\r\n.#..\r\n..#.\r\n', 'output': ['YES']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
391
100
100
100
["390", "7", "1000000000"]
The only input line contains the integer $$$n$$$ ($$$1 \le n \le 2\cdot10^9$$$).
38690bd32e7d0b314f701f138ce19dfb
import math i=int(input()) max=0 k=len(str(i))-1 if i<10: print(i) else: list=[] p=str(i) for m in p: list.append(int(m)) p=list m=1 for j in p: m*=j if m>max: max=m m=1 for l in range(k,0,-1): q=i minus=i%10**l+1 q-=minus list=[] p=str(q) for m in p: list.append(int(m)) p=list m=1 for j in p: m*=j if m>max: max=m print(max)
["216", "7", "387420489"]
Python
NoteIn the first example the maximum product is achieved for $$$389$$$ (the product of digits is $$$3\cdot8\cdot9=216$$$).In the second example the maximum product is achieved for $$$7$$$ (the product of digits is $$$7$$$).In the third example the maximum product is achieved for $$$999999999$$$ (the product of digits is $$$9^9=387420489$$$).
Print the maximum product of digits among all integers from $$$1$$$ to $$$n$$$.
Kurt reaches nirvana when he finds the product of all the digits of some positive integer. Greater value of the product makes the nirvana deeper.Help Kurt find the maximum possible product of digits among all integers from $$$1$$$ to $$$n$$$.
[{"input": "390\r\n", "output": ["216"]}, {"input": "7\r\n", "output": ["7"]}, {"input": "1000000000\r\n", "output": ["387420489"]}, {"input": "1\r\n", "output": ["1"]}, {"input": "9\r\n", "output": ["9"]}, {"input": "2000000000\r\n", "output": ["387420489"]}, {"input": "4876\r\n", "output": ["2268"]}, {"input": "889878787\r\n", "output": ["301327047"]}, {"input": "1382011913\r\n", "output": ["387420489"]}, {"input": "999999999\r\n", "output": ["387420489"]}, {"input": "396579088\r\n", "output": ["114791256"]}, {"input": "890133136\r\n", "output": ["306110016"]}, {"input": "485908655\r\n", "output": ["133923132"]}, {"input": "261560170\r\n", "output": ["47829690"]}, {"input": "391789744\r\n", "output": ["114791256"]}, {"input": "480330141\r\n", "output": ["133923132"]}, {"input": "691993260\r\n", "output": ["229582512"]}, {"input": "483212601\r\n", "output": ["133923132"]}, {"input": "892295273\r\n", "output": ["306110016"]}, {"input": "389041744\r\n", "output": ["102036672"]}, {"input": "282587478\r\n", "output": ["66961566"]}, {"input": "791812587\r\n", "output": ["267846264"]}, {"input": "2\r\n", "output": ["2"]}, {"input": "3\r\n", "output": ["3"]}, {"input": "4\r\n", "output": ["4"]}, {"input": "10\r\n", "output": ["9"]}, {"input": "11\r\n", "output": ["9"]}, {"input": "12\r\n", "output": ["9"]}, {"input": "19\r\n", "output": ["9"]}, {"input": "20\r\n", "output": ["9"]}, {"input": "98\r\n", "output": ["72"]}, {"input": "99\r\n", "output": ["81"]}, {"input": "100\r\n", "output": ["81"]}, {"input": "101\r\n", "output": ["81"]}, {"input": "997\r\n", "output": ["648"]}, {"input": "998\r\n", "output": ["648"]}, {"input": "999\r\n", "output": ["729"]}, {"input": "1000\r\n", "output": ["729"]}, {"input": "1001\r\n", "output": ["729"]}, {"input": "25\r\n", "output": ["10"]}, {"input": "278\r\n", "output": ["112"]}, {"input": "1999999999\r\n", "output": ["387420489"]}, {"input": "2690\r\n", "output": ["864"]}, {"input": "268\r\n", "output": ["96"]}, {"input": "289664200\r\n", "output": ["68024448"]}, {"input": "288\r\n", "output": ["128"]}, {"input": "1999999998\r\n", "output": ["387420489"]}]
100
100
100
[{'input': '1382011913\r\n', 'output': ['387420489']}, {'input': '480330141\r\n', 'output': ['133923132']}, {'input': '99\r\n', 'output': ['81']}, {'input': '1\r\n', 'output': ['1']}, {'input': '101\r\n', 'output': ['81']}]
[{'input': '1999999998\r\n', 'output': ['387420489']}, {'input': '19\r\n', 'output': ['9']}, {'input': '2\r\n', 'output': ['2']}, {'input': '288\r\n', 'output': ['128']}, {'input': '396579088\r\n', 'output': ['114791256']}]
[{'input': '691993260\r\n', 'output': ['229582512']}, {'input': '1382011913\r\n', 'output': ['387420489']}, {'input': '288\r\n', 'output': ['128']}, {'input': '1999999998\r\n', 'output': ['387420489']}, {'input': '282587478\r\n', 'output': ['66961566']}]
[{'input': '98\r\n', 'output': ['72']}, {'input': '1001\r\n', 'output': ['729']}, {'input': '1000\r\n', 'output': ['729']}, {'input': '4876\r\n', 'output': ['2268']}, {'input': '999999999\r\n', 'output': ['387420489']}]
[{'input': '3\r\n', 'output': ['3']}, {'input': '11\r\n', 'output': ['9']}, {'input': '2690\r\n', 'output': ['864']}, {'input': '98\r\n', 'output': ['72']}, {'input': '999999999\r\n', 'output': ['387420489']}]
100
100
100
100
100
100
100
96.88
96.88
100
100
100
93.75
93.75
100
392
100
98.752
97.5
["500 1000 20 30", "1000 1000 1 1", "1500 1000 176 177"]
The first line contains four integers a, b, c, d (250 ≀ a, b ≀ 3500, 0 ≀ c, d ≀ 180). It is guaranteed that numbers a and b are divisible by 250 (just like on any real Codeforces round).
95b19d7569d6b70bd97d46a8541060d0
a,b,c,d = map(int, input().split()) s1 = max(0.3 * a, int(a * (1 - c / 250))) s2 = max(0.3 * b, int(b * (1 - d / 250))) if s1 > s2: print('Misha') elif s1 == s2: print('Tie') else: print('Vasya')
["Vasya", "Tie", "Misha"]
Python
null
Output on a single line: "Misha" (without the quotes), if Misha got more points than Vasya. "Vasya" (without the quotes), if Vasya got more points than Misha. "Tie" (without the quotes), if both of them got the same number of points.
Misha and Vasya participated in a Codeforces contest. Unfortunately, each of them solved only one problem, though successfully submitted it at the first attempt. Misha solved the problem that costs a points and Vasya solved the problem that costs b points. Besides, Misha submitted the problem c minutes after the contest started and Vasya submitted the problem d minutes after the contest started. As you know, on Codeforces the cost of a problem reduces as a round continues. That is, if you submit a problem that costs p points t minutes after the contest started, you get points. Misha and Vasya are having an argument trying to find out who got more points. Help them to find out the truth.
[{"input": "500 1000 20 30\r\n", "output": ["Vasya"]}, {"input": "1000 1000 1 1\r\n", "output": ["Tie"]}, {"input": "1500 1000 176 177\r\n", "output": ["Misha"]}, {"input": "1500 1000 74 177\r\n", "output": ["Misha"]}, {"input": "750 2500 175 178\r\n", "output": ["Vasya"]}, {"input": "750 1000 54 103\r\n", "output": ["Tie"]}, {"input": "2000 1250 176 130\r\n", "output": ["Tie"]}, {"input": "1250 1750 145 179\r\n", "output": ["Tie"]}, {"input": "2000 2000 176 179\r\n", "output": ["Tie"]}, {"input": "1500 1500 148 148\r\n", "output": ["Tie"]}, {"input": "2750 1750 134 147\r\n", "output": ["Misha"]}, {"input": "3250 250 175 173\r\n", "output": ["Misha"]}, {"input": "500 500 170 176\r\n", "output": ["Misha"]}, {"input": "250 1000 179 178\r\n", "output": ["Vasya"]}, {"input": "3250 1000 160 138\r\n", "output": ["Misha"]}, {"input": "3000 2000 162 118\r\n", "output": ["Tie"]}, {"input": "1500 1250 180 160\r\n", "output": ["Tie"]}, {"input": "1250 2500 100 176\r\n", "output": ["Tie"]}, {"input": "3500 3500 177 178\r\n", "output": ["Tie"]}, {"input": "3000 3250 16 34\r\n", "output": ["Tie"]}, {"input": "1750 3000 137 49\r\n", "output": ["Vasya"]}, {"input": "500 1500 179 71\r\n", "output": ["Vasya"]}, {"input": "1250 2000 101 180\r\n", "output": ["Misha"]}, {"input": "250 750 180 176\r\n", "output": ["Vasya"]}, {"input": "2250 2250 163 145\r\n", "output": ["Vasya"]}, {"input": "3000 3000 176 78\r\n", "output": ["Vasya"]}, {"input": "250 3500 8 178\r\n", "output": ["Vasya"]}, {"input": "1750 1250 179 180\r\n", "output": ["Misha"]}, {"input": "2750 1750 13 164\r\n", "output": ["Misha"]}, {"input": "1750 2250 178 53\r\n", "output": ["Vasya"]}, {"input": "2500 2750 73 179\r\n", "output": ["Misha"]}, {"input": "1000 3500 178 175\r\n", "output": ["Vasya"]}, {"input": "1000 500 7 162\r\n", "output": ["Misha"]}, {"input": "1000 250 175 48\r\n", "output": ["Misha"]}, {"input": "1750 500 166 177\r\n", "output": ["Misha"]}, {"input": "250 250 0 0\r\n", "output": ["Tie"]}, {"input": "250 3500 0 0\r\n", "output": ["Vasya"]}, {"input": "250 3500 0 180\r\n", "output": ["Vasya"]}, {"input": "3500 3500 180 180\r\n", "output": ["Tie"]}, {"input": "3500 250 0 180\r\n", "output": ["Misha"]}]
100
100
100
[{'input': '2500 2750 73 179\r\n', 'output': ['Misha']}, {'input': '1500 1000 74 177\r\n', 'output': ['Misha']}, {'input': '3000 2000 162 118\r\n', 'output': ['Tie']}, {'input': '1500 1250 180 160\r\n', 'output': ['Tie']}, {'input': '250 250 0 0\r\n', 'output': ['Tie']}]
[{'input': '1500 1250 180 160\r\n', 'output': ['Tie']}, {'input': '3000 3000 176 78\r\n', 'output': ['Vasya']}, {'input': '3250 1000 160 138\r\n', 'output': ['Misha']}, {'input': '1000 3500 178 175\r\n', 'output': ['Vasya']}, {'input': '3500 250 0 180\r\n', 'output': ['Misha']}]
[{'input': '250 250 0 0\r\n', 'output': ['Tie']}, {'input': '500 1500 179 71\r\n', 'output': ['Vasya']}, {'input': '1500 1000 74 177\r\n', 'output': ['Misha']}, {'input': '3250 1000 160 138\r\n', 'output': ['Misha']}, {'input': '1750 3000 137 49\r\n', 'output': ['Vasya']}]
[{'input': '3000 3250 16 34\r\n', 'output': ['Tie']}, {'input': '3500 3500 177 178\r\n', 'output': ['Tie']}, {'input': '2000 2000 176 179\r\n', 'output': ['Tie']}, {'input': '3000 3000 176 78\r\n', 'output': ['Vasya']}, {'input': '2500 2750 73 179\r\n', 'output': ['Misha']}]
[{'input': '1000 1000 1 1\r\n', 'output': ['Tie']}, {'input': '1750 3000 137 49\r\n', 'output': ['Vasya']}, {'input': '1750 2250 178 53\r\n', 'output': ['Vasya']}, {'input': '250 3500 0 180\r\n', 'output': ['Vasya']}, {'input': '500 500 170 176\r\n', 'output': ['Misha']}]
100
100
100
100
100
87.5
100
100
100
100
75
100
100
100
100
393
100
97.5
95
["19", "16"]
The first and only line contains an integer $$$r$$$ ($$$1 \le r \le 10^{12}$$$).
3ff1c25a1026c90aeb14d148d7fb96ba
r = int(input()) y = int((r-3)/2) if(r&1 and y > 0): print("{} {}".format(1,y)) else : print("NO")
["1 8", "NO"]
Python
null
Output integers $$$x, y$$$ such that $$$H(x,y) = r$$$ and $$$x$$$ is smallest possible, or "NO" if no such pair exists.
Melody Pond was stolen from her parents as a newborn baby by Madame Kovarian, to become a weapon of the Silence in their crusade against the Doctor. Madame Kovarian changed Melody's name to River Song, giving her a new identity that allowed her to kill the Eleventh Doctor.Heidi figured out that Madame Kovarian uses a very complicated hashing function in order to change the names of the babies she steals. In order to prevent this from happening to future Doctors, Heidi decided to prepare herself by learning some basic hashing techniques.The first hashing function she designed is as follows.Given two positive integers $$$(x, y)$$$ she defines $$$H(x,y):=x^2+2xy+x+1$$$.Now, Heidi wonders if the function is reversible. That is, given a positive integer $$$r$$$, can you find a pair $$$(x, y)$$$ (of positive integers) such that $$$H(x, y) = r$$$?If multiple such pairs exist, output the one with smallest possible $$$x$$$. If there is no such pair, output "NO".
[{"input": "19\r\n", "output": ["1 8"]}, {"input": "16\r\n", "output": ["NO"]}, {"input": "1\r\n", "output": ["NO"]}, {"input": "2\r\n", "output": ["NO"]}, {"input": "3\r\n", "output": ["NO"]}, {"input": "4\r\n", "output": ["NO"]}, {"input": "5\r\n", "output": ["1 1"]}, {"input": "6\r\n", "output": ["NO"]}, {"input": "7\r\n", "output": ["1 2"]}, {"input": "8\r\n", "output": ["NO"]}, {"input": "9\r\n", "output": ["1 3"]}, {"input": "10\r\n", "output": ["NO"]}, {"input": "11\r\n", "output": ["1 4"]}, {"input": "12\r\n", "output": ["NO"]}, {"input": "13\r\n", "output": ["1 5"]}, {"input": "14\r\n", "output": ["NO"]}, {"input": "15\r\n", "output": ["1 6"]}, {"input": "17\r\n", "output": ["1 7"]}, {"input": "18\r\n", "output": ["NO"]}, {"input": "20\r\n", "output": ["NO"]}, {"input": "21\r\n", "output": ["1 9"]}, {"input": "260158260522\r\n", "output": ["NO"]}, {"input": "250877914575\r\n", "output": ["1 125438957286"]}, {"input": "116602436426\r\n", "output": ["NO"]}, {"input": "540024979445\r\n", "output": ["1 270012489721"]}, {"input": "917861648772\r\n", "output": ["NO"]}, {"input": "962623690081\r\n", "output": ["1 481311845039"]}, {"input": "54433933447\r\n", "output": ["1 27216966722"]}, {"input": "16476190629\r\n", "output": ["1 8238095313"]}, {"input": "426262703497\r\n", "output": ["1 213131351747"]}, {"input": "723211047202\r\n", "output": ["NO"]}, {"input": "652509336151\r\n", "output": ["1 326254668074"]}, {"input": "215283472163\r\n", "output": ["1 107641736080"]}, {"input": "29617919\r\n", "output": ["1 14808958"]}, {"input": "7505295085\r\n", "output": ["1 3752647541"]}, {"input": "149890929717\r\n", "output": ["1 74945464857"]}, {"input": "185589070745\r\n", "output": ["1 92794535371"]}, {"input": "419450839\r\n", "output": ["1 209725418"]}, {"input": "519397679401\r\n", "output": ["1 259698839699"]}, {"input": "943447972637\r\n", "output": ["1 471723986317"]}, {"input": "54336309171\r\n", "output": ["1 27168154584"]}, {"input": "688373050717\r\n", "output": ["1 344186525357"]}, {"input": "156231653273\r\n", "output": ["1 78115826635"]}, {"input": "23744498401\r\n", "output": ["1 11872249199"]}, {"input": "768407398177\r\n", "output": ["1 384203699087"]}, {"input": "963761198401\r\n", "output": ["1 481880599199"]}, {"input": "240940299601\r\n", "output": ["1 120470149799"]}]
100
100
100
[{'input': '2\r\n', 'output': ['NO']}, {'input': '3\r\n', 'output': ['NO']}, {'input': '240940299601\r\n', 'output': ['1 120470149799']}, {'input': '260158260522\r\n', 'output': ['NO']}, {'input': '185589070745\r\n', 'output': ['1 92794535371']}]
[{'input': '9\r\n', 'output': ['1 3']}, {'input': '14\r\n', 'output': ['NO']}, {'input': '963761198401\r\n', 'output': ['1 481880599199']}, {'input': '8\r\n', 'output': ['NO']}, {'input': '419450839\r\n', 'output': ['1 209725418']}]
[{'input': '962623690081\r\n', 'output': ['1 481311845039']}, {'input': '13\r\n', 'output': ['1 5']}, {'input': '215283472163\r\n', 'output': ['1 107641736080']}, {'input': '4\r\n', 'output': ['NO']}, {'input': '419450839\r\n', 'output': ['1 209725418']}]
[{'input': '3\r\n', 'output': ['NO']}, {'input': '768407398177\r\n', 'output': ['1 384203699087']}, {'input': '426262703497\r\n', 'output': ['1 213131351747']}, {'input': '688373050717\r\n', 'output': ['1 344186525357']}, {'input': '8\r\n', 'output': ['NO']}]
[{'input': '116602436426\r\n', 'output': ['NO']}, {'input': '10\r\n', 'output': ['NO']}, {'input': '1\r\n', 'output': ['NO']}, {'input': '963761198401\r\n', 'output': ['1 481880599199']}, {'input': '250877914575\r\n', 'output': ['1 125438957286']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
394
100
100
100
["3 1 1", "5 2 3"]
The only line contains three integers n, a and b (0 ≀ a, b &lt; n ≀ 100).
51a072916bff600922a77da0c4582180
n,a,b = map(int, input().split(' ')) print(n-max(a+1,n-b)+1)
["2", "3"]
Python
NoteThe possible positions in the first sample are: 2 and 3 (if we number the positions starting with 1).In the second sample they are 3, 4 and 5.
Print the single number β€” the number of the sought positions.
Petr stands in line of n people, but he doesn't know exactly which position he occupies. He can say that there are no less than a people standing in front of him and no more than b people standing behind him. Find the number of different positions Petr can occupy.
[{"input": "3 1 1\r\n", "output": ["2"]}, {"input": "5 2 3\r\n", "output": ["3"]}, {"input": "5 4 0\r\n", "output": ["1"]}, {"input": "6 5 5\r\n", "output": ["1"]}, {"input": "9 4 3\r\n", "output": ["4"]}, {"input": "11 4 6\r\n", "output": ["7"]}, {"input": "13 8 7\r\n", "output": ["5"]}, {"input": "14 5 5\r\n", "output": ["6"]}, {"input": "16 6 9\r\n", "output": ["10"]}, {"input": "20 13 17\r\n", "output": ["7"]}, {"input": "22 4 8\r\n", "output": ["9"]}, {"input": "23 8 14\r\n", "output": ["15"]}, {"input": "26 18 22\r\n", "output": ["8"]}, {"input": "28 6 1\r\n", "output": ["2"]}, {"input": "29 5 23\r\n", "output": ["24"]}, {"input": "32 27 15\r\n", "output": ["5"]}, {"input": "33 11 5\r\n", "output": ["6"]}, {"input": "37 21 15\r\n", "output": ["16"]}, {"input": "39 34 33\r\n", "output": ["5"]}, {"input": "41 27 11\r\n", "output": ["12"]}, {"input": "42 25 16\r\n", "output": ["17"]}, {"input": "45 7 43\r\n", "output": ["38"]}, {"input": "47 16 17\r\n", "output": ["18"]}, {"input": "49 11 37\r\n", "output": ["38"]}, {"input": "51 38 39\r\n", "output": ["13"]}, {"input": "52 29 7\r\n", "output": ["8"]}, {"input": "56 43 12\r\n", "output": ["13"]}, {"input": "58 57 28\r\n", "output": ["1"]}, {"input": "59 12 39\r\n", "output": ["40"]}, {"input": "62 9 52\r\n", "output": ["53"]}, {"input": "63 29 44\r\n", "output": ["34"]}, {"input": "65 30 22\r\n", "output": ["23"]}, {"input": "66 27 38\r\n", "output": ["39"]}, {"input": "71 33 53\r\n", "output": ["38"]}, {"input": "73 14 12\r\n", "output": ["13"]}, {"input": "73 37 35\r\n", "output": ["36"]}, {"input": "76 69 44\r\n", "output": ["7"]}, {"input": "79 25 20\r\n", "output": ["21"]}, {"input": "81 60 20\r\n", "output": ["21"]}, {"input": "81 79 14\r\n", "output": ["2"]}, {"input": "84 0 42\r\n", "output": ["43"]}, {"input": "88 79 8\r\n", "output": ["9"]}, {"input": "90 76 59\r\n", "output": ["14"]}, {"input": "92 2 22\r\n", "output": ["23"]}, {"input": "94 5 88\r\n", "output": ["89"]}, {"input": "94 62 48\r\n", "output": ["32"]}, {"input": "96 22 72\r\n", "output": ["73"]}, {"input": "100 11 88\r\n", "output": ["89"]}, {"input": "100 81 91\r\n", "output": ["19"]}, {"input": "1 0 0\r\n", "output": ["1"]}]
100
100
100
[{'input': '5 2 3\r\n', 'output': ['3']}, {'input': '23 8 14\r\n', 'output': ['15']}, {'input': '71 33 53\r\n', 'output': ['38']}, {'input': '39 34 33\r\n', 'output': ['5']}, {'input': '62 9 52\r\n', 'output': ['53']}]
[{'input': '3 1 1\r\n', 'output': ['2']}, {'input': '23 8 14\r\n', 'output': ['15']}, {'input': '73 14 12\r\n', 'output': ['13']}, {'input': '62 9 52\r\n', 'output': ['53']}, {'input': '11 4 6\r\n', 'output': ['7']}]
[{'input': '59 12 39\r\n', 'output': ['40']}, {'input': '62 9 52\r\n', 'output': ['53']}, {'input': '58 57 28\r\n', 'output': ['1']}, {'input': '41 27 11\r\n', 'output': ['12']}, {'input': '66 27 38\r\n', 'output': ['39']}]
[{'input': '71 33 53\r\n', 'output': ['38']}, {'input': '56 43 12\r\n', 'output': ['13']}, {'input': '51 38 39\r\n', 'output': ['13']}, {'input': '62 9 52\r\n', 'output': ['53']}, {'input': '22 4 8\r\n', 'output': ['9']}]
[{'input': '5 4 0\r\n', 'output': ['1']}, {'input': '62 9 52\r\n', 'output': ['53']}, {'input': '100 81 91\r\n', 'output': ['19']}, {'input': '100 11 88\r\n', 'output': ['89']}, {'input': '14 5 5\r\n', 'output': ['6']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
395
100
100
100
["6 4\n5237\n2753\n7523\n5723\n5327\n2537", "3 3\n010\n909\n012", "7 5\n50808\n36603\n37198\n44911\n29994\n42543\n50156"]
The first line contains integers n and k β€” the number and digit capacity of numbers correspondingly (1 ≀ n, k ≀ 8). Next n lines contain k-digit positive integers. Leading zeroes are allowed both in the initial integers and the integers resulting from the rearranging of digits.
08f85cd4ffbd135f0b630235209273a4
import itertools, sys n, k = [int(x) for x in input().split()] perms = zip(*[[int(''.join(p)) for p in itertools.permutations(input())] for y in range(n)]) perms = list(perms) # print(perms) minimum = float("inf") for p in perms: temp = max(p) - min(p) if temp < minimum: minimum = temp print(minimum) # Made By Mostafa_Khaled
["2700", "3", "20522"]
Python
NoteIn the first sample, if we rearrange the digits in numbers as (3,1,4,2), then the 2-nd and the 4-th numbers will equal 5237 and 2537 correspondingly (they will be maximum and minimum for such order of digits).In the second sample, if we swap the second digits and the first ones, we get integers 100, 99 and 102.
Print a single number: the minimally possible difference between the largest and the smallest number after the digits are rearranged in all integers by the same rule.
You are given n k-digit integers. You have to rearrange the digits in the integers so that the difference between the largest and the smallest number was minimum. Digits should be rearranged by the same rule in all integers.
[{"input": "6 4\r\n5237\r\n2753\r\n7523\r\n5723\r\n5327\r\n2537\r\n", "output": ["2700"]}, {"input": "3 3\r\n010\r\n909\r\n012\r\n", "output": ["3"]}, {"input": "7 5\r\n50808\r\n36603\r\n37198\r\n44911\r\n29994\r\n42543\r\n50156\r\n", "output": ["20522"]}, {"input": "5 5\r\n61374\r\n74304\r\n41924\r\n46010\r\n09118\r\n", "output": ["64592"]}, {"input": "8 8\r\n68785928\r\n11981277\r\n32480720\r\n72495162\r\n69969623\r\n42118868\r\n64235849\r\n81412116\r\n", "output": ["52901157"]}, {"input": "7 1\r\n1\r\n0\r\n8\r\n5\r\n4\r\n9\r\n8\r\n", "output": ["9"]}, {"input": "3 8\r\n34848224\r\n16307102\r\n25181102\r\n", "output": ["8612277"]}, {"input": "2 8\r\n13633861\r\n68468345\r\n", "output": ["14445725"]}, {"input": "4 4\r\n0950\r\n0634\r\n9264\r\n8684\r\n", "output": ["3738"]}, {"input": "6 5\r\n65777\r\n80932\r\n32260\r\n49089\r\n00936\r\n85557\r\n", "output": ["41439"]}, {"input": "5 6\r\n687443\r\n279213\r\n765651\r\n611680\r\n500192\r\n", "output": ["258067"]}, {"input": "8 6\r\n034753\r\n917195\r\n222679\r\n778596\r\n980006\r\n467267\r\n482763\r\n807481\r\n", "output": ["647026"]}, {"input": "8 6\r\n075967\r\n240855\r\n352399\r\n791547\r\n103244\r\n982259\r\n409866\r\n926586\r\n", "output": ["491255"]}, {"input": "3 1\r\n7\r\n2\r\n9\r\n", "output": ["7"]}, {"input": "6 4\r\n5407\r\n4617\r\n3050\r\n7647\r\n8647\r\n1993\r\n", "output": ["6474"]}, {"input": "8 5\r\n47553\r\n55138\r\n81768\r\n78902\r\n50691\r\n73010\r\n93969\r\n01675\r\n", "output": ["71123"]}, {"input": "8 7\r\n5945843\r\n9094433\r\n0750024\r\n6255984\r\n1784849\r\n7275947\r\n6513944\r\n0145523\r\n", "output": ["5152379"]}, {"input": "8 7\r\n8112819\r\n8982110\r\n5457941\r\n4575033\r\n5203331\r\n7410823\r\n0532182\r\n8151054\r\n", "output": ["6194602"]}, {"input": "8 8\r\n63315032\r\n20587190\r\n05461152\r\n76872565\r\n71177578\r\n53541174\r\n00451913\r\n85740357\r\n", "output": ["60622457"]}, {"input": "2 3\r\n135\r\n725\r\n", "output": ["4"]}, {"input": "7 1\r\n9\r\n5\r\n8\r\n9\r\n7\r\n6\r\n9\r\n", "output": ["4"]}, {"input": "5 3\r\n560\r\n978\r\n543\r\n846\r\n714\r\n", "output": ["435"]}, {"input": "7 2\r\n53\r\n74\r\n84\r\n62\r\n14\r\n77\r\n59\r\n", "output": ["69"]}, {"input": "3 4\r\n0537\r\n2174\r\n5299\r\n", "output": ["3583"]}, {"input": "7 5\r\n13532\r\n16394\r\n97663\r\n73133\r\n22712\r\n58185\r\n65035\r\n", "output": ["26455"]}, {"input": "8 5\r\n07936\r\n07927\r\n46068\r\n99158\r\n90958\r\n41283\r\n59266\r\n87841\r\n", "output": ["52364"]}, {"input": "8 6\r\n867468\r\n695388\r\n700723\r\n444270\r\n545657\r\n178053\r\n315040\r\n554471\r\n", "output": ["559559"]}, {"input": "7 7\r\n6575460\r\n6965366\r\n1912357\r\n7080608\r\n2561692\r\n5209630\r\n0439095\r\n", "output": ["5917123"]}, {"input": "1 2\r\n96\r\n", "output": ["0"]}, {"input": "1 3\r\n289\r\n", "output": ["0"]}, {"input": "1 8\r\n78795220\r\n", "output": ["0"]}, {"input": "8 7\r\n2407792\r\n7023368\r\n2609925\r\n0587109\r\n3543873\r\n6602371\r\n4579875\r\n9893509\r\n", "output": ["6790457"]}, {"input": "4 6\r\n065169\r\n150326\r\n924608\r\n490012\r\n", "output": ["488134"]}, {"input": "4 4\r\n8851\r\n6190\r\n0521\r\n1659\r\n", "output": ["6596"]}, {"input": "4 4\r\n4381\r\n3147\r\n7017\r\n5593\r\n", "output": ["3690"]}, {"input": "8 4\r\n0344\r\n9196\r\n1379\r\n5470\r\n0989\r\n8316\r\n7096\r\n7918\r\n", "output": ["7801"]}, {"input": "1 6\r\n430254\r\n", "output": ["0"]}, {"input": "8 1\r\n4\r\n0\r\n8\r\n5\r\n9\r\n0\r\n4\r\n7\r\n", "output": ["9"]}, {"input": "5 2\r\n60\r\n08\r\n77\r\n66\r\n03\r\n", "output": ["74"]}, {"input": "3 1\r\n9\r\n8\r\n2\r\n", "output": ["7"]}, {"input": "7 2\r\n89\r\n00\r\n59\r\n90\r\n99\r\n22\r\n55\r\n", "output": ["99"]}, {"input": "2 4\r\n7694\r\n6577\r\n", "output": ["712"]}, {"input": "8 8\r\n68785928\r\n11981277\r\n32480720\r\n72495162\r\n69969623\r\n42118868\r\n64235849\r\n81412116\r\n", "output": ["52901157"]}, {"input": "2 7\r\n9183508\r\n9276377\r\n", "output": ["26912"]}, {"input": "5 4\r\n7411\r\n3080\r\n9578\r\n5902\r\n3225\r\n", "output": ["6498"]}, {"input": "3 4\r\n0136\r\n4556\r\n4268\r\n", "output": ["2134"]}, {"input": "6 8\r\n99358096\r\n38390629\r\n71597322\r\n35940809\r\n48949759\r\n66204248\r\n", "output": ["53570178"]}, {"input": "7 2\r\n23\r\n11\r\n88\r\n25\r\n22\r\n45\r\n10\r\n", "output": ["78"]}, {"input": "2 3\r\n834\r\n630\r\n", "output": ["24"]}, {"input": "4 2\r\n87\r\n03\r\n95\r\n23\r\n", "output": ["48"]}, {"input": "2 8\r\n10715643\r\n97664296\r\n", "output": ["1244714"]}, {"input": "6 1\r\n9\r\n3\r\n1\r\n3\r\n4\r\n5\r\n", "output": ["8"]}, {"input": "8 5\r\n47553\r\n55138\r\n81768\r\n78902\r\n50691\r\n73010\r\n93969\r\n01675\r\n", "output": ["71123"]}, {"input": "4 4\r\n7603\r\n0859\r\n5241\r\n7680\r\n", "output": ["5518"]}, {"input": "1 7\r\n4605461\r\n", "output": ["0"]}, {"input": "3 4\r\n3061\r\n3404\r\n6670\r\n", "output": ["2916"]}, {"input": "8 4\r\n1847\r\n0962\r\n3216\r\n0772\r\n6399\r\n3082\r\n7997\r\n0625\r\n", "output": ["7246"]}, {"input": "2 6\r\n834527\r\n764560\r\n", "output": ["577"]}, {"input": "5 6\r\n959808\r\n303464\r\n414335\r\n758650\r\n828038\r\n", "output": ["486245"]}, {"input": "4 1\r\n0\r\n7\r\n5\r\n1\r\n", "output": ["7"]}, {"input": "6 7\r\n4565736\r\n9842969\r\n1412800\r\n6411011\r\n5744909\r\n3791659\r\n", "output": ["4066781"]}, {"input": "4 1\r\n0\r\n7\r\n5\r\n1\r\n", "output": ["7"]}, {"input": "1 3\r\n250\r\n", "output": ["0"]}, {"input": "2 1\r\n2\r\n0\r\n", "output": ["2"]}, {"input": "8 8\r\n96805230\r\n73119021\r\n06552907\r\n86283347\r\n88650846\r\n19155689\r\n37032451\r\n19310120\r\n", "output": ["53604668"]}, {"input": "3 2\r\n64\r\n94\r\n65\r\n", "output": ["10"]}, {"input": "8 4\r\n8008\r\n4983\r\n0295\r\n0353\r\n5838\r\n1960\r\n0270\r\n7144\r\n", "output": ["7475"]}, {"input": "4 8\r\n22025344\r\n54085308\r\n77633421\r\n59238322\r\n", "output": ["7681556"]}, {"input": "5 3\r\n504\r\n878\r\n599\r\n683\r\n083\r\n", "output": ["615"]}, {"input": "5 4\r\n7663\r\n4755\r\n2941\r\n4588\r\n0232\r\n", "output": ["5346"]}, {"input": "6 2\r\n97\r\n57\r\n40\r\n99\r\n22\r\n94\r\n", "output": ["77"]}, {"input": "6 7\r\n4104025\r\n1370353\r\n3472874\r\n5258456\r\n5595923\r\n0279404\r\n", "output": ["2790148"]}, {"input": "8 2\r\n42\r\n86\r\n25\r\n30\r\n27\r\n64\r\n67\r\n38\r\n", "output": ["61"]}, {"input": "5 2\r\n52\r\n22\r\n05\r\n37\r\n74\r\n", "output": ["51"]}, {"input": "2 2\r\n63\r\n50\r\n", "output": ["13"]}, {"input": "6 7\r\n4104025\r\n1370353\r\n3472874\r\n5258456\r\n5595923\r\n0279404\r\n", "output": ["2790148"]}, {"input": "6 2\r\n95\r\n56\r\n06\r\n46\r\n77\r\n51\r\n", "output": ["62"]}, {"input": "3 5\r\n97424\r\n96460\r\n47766\r\n", "output": ["9536"]}, {"input": "2 3\r\n596\r\n246\r\n", "output": ["35"]}, {"input": "3 1\r\n1\r\n2\r\n2\r\n", "output": ["1"]}, {"input": "4 2\r\n87\r\n03\r\n95\r\n23\r\n", "output": ["48"]}, {"input": "7 5\r\n41078\r\n41257\r\n35324\r\n70082\r\n66783\r\n99954\r\n85784\r\n", "output": ["56901"]}, {"input": "8 7\r\n8943041\r\n2427704\r\n3775080\r\n2956111\r\n1345704\r\n0937172\r\n1979973\r\n7081540\r\n", "output": ["3544246"]}, {"input": "6 6\r\n505845\r\n903151\r\n055779\r\n733849\r\n508266\r\n029177\r\n", "output": ["249045"]}, {"input": "4 4\r\n1871\r\n9417\r\n7444\r\n4294\r\n", "output": ["5368"]}, {"input": "2 5\r\n60106\r\n07866\r\n", "output": ["5224"]}, {"input": "3 3\r\n195\r\n860\r\n567\r\n", "output": ["258"]}, {"input": "8 5\r\n68186\r\n57779\r\n78079\r\n47451\r\n69788\r\n82172\r\n75373\r\n50157\r\n", "output": ["32237"]}, {"input": "4 7\r\n5342341\r\n5194611\r\n4032103\r\n8739798\r\n", "output": ["4056779"]}, {"input": "4 8\r\n91401735\r\n53979237\r\n20857777\r\n94594293\r\n", "output": ["34567247"]}, {"input": "1 2\r\n95\r\n", "output": ["0"]}, {"input": "6 4\r\n0443\r\n7108\r\n7211\r\n4287\r\n6439\r\n7711\r\n", "output": ["5301"]}, {"input": "6 7\r\n5794383\r\n4078451\r\n0263676\r\n7682294\r\n7436158\r\n3363189\r\n", "output": ["3560125"]}, {"input": "2 5\r\n07259\r\n51985\r\n", "output": ["23657"]}, {"input": "3 3\r\n624\r\n125\r\n097\r\n", "output": ["247"]}, {"input": "8 1\r\n9\r\n7\r\n6\r\n2\r\n9\r\n6\r\n4\r\n8\r\n", "output": ["7"]}, {"input": "6 3\r\n530\r\n862\r\n874\r\n932\r\n972\r\n157\r\n", "output": ["442"]}, {"input": "3 2\r\n51\r\n39\r\n97\r\n", "output": ["58"]}, {"input": "8 4\r\n4650\r\n1735\r\n4269\r\n8023\r\n0948\r\n9685\r\n3675\r\n6017\r\n", "output": ["6836"]}, {"input": "5 3\r\n168\r\n513\r\n110\r\n386\r\n501\r\n", "output": ["403"]}, {"input": "6 2\r\n01\r\n81\r\n60\r\n27\r\n23\r\n67\r\n", "output": ["70"]}, {"input": "4 4\r\n2759\r\n7250\r\n3572\r\n8067\r\n", "output": ["2028"]}, {"input": "8 5\r\n12658\r\n00588\r\n23491\r\n09985\r\n63973\r\n78517\r\n98187\r\n29863\r\n", "output": ["68592"]}, {"input": "3 1\r\n5\r\n4\r\n2\r\n", "output": ["3"]}, {"input": "7 8\r\n24925537\r\n07626274\r\n77060131\r\n82415056\r\n70422753\r\n60455207\r\n32176884\r\n", "output": ["54680138"]}, {"input": "5 8\r\n94157433\r\n85577189\r\n62547277\r\n11815893\r\n35445851\r\n", "output": ["15679126"]}, {"input": "5 5\r\n31164\r\n27213\r\n17981\r\n48806\r\n01273\r\n", "output": ["33367"]}, {"input": "3 6\r\n743197\r\n172242\r\n635654\r\n", "output": ["261245"]}, {"input": "4 6\r\n760130\r\n653002\r\n902824\r\n380915\r\n", "output": ["268111"]}, {"input": "8 8\r\n83239439\r\n62184887\r\n58968944\r\n39808261\r\n68740623\r\n38480328\r\n81965504\r\n52600488\r\n", "output": ["44481119"]}, {"input": "8 2\r\n99\r\n20\r\n22\r\n39\r\n33\r\n60\r\n54\r\n08\r\n", "output": ["91"]}, {"input": "1 7\r\n3545113\r\n", "output": ["0"]}, {"input": "6 7\r\n3761949\r\n8095136\r\n4875085\r\n5017784\r\n4459097\r\n4354762\r\n", "output": ["4126934"]}, {"input": "6 8\r\n50157346\r\n63836375\r\n03176371\r\n83637145\r\n28631038\r\n18617159\r\n", "output": ["24702445"]}, {"input": "1 5\r\n84932\r\n", "output": ["0"]}, {"input": "4 3\r\n204\r\n515\r\n280\r\n840\r\n", "output": ["467"]}, {"input": "8 2\r\n40\r\n41\r\n02\r\n55\r\n26\r\n52\r\n60\r\n25\r\n", "output": ["58"]}, {"input": "2 5\r\n90526\r\n32565\r\n", "output": ["586"]}, {"input": "4 4\r\n3058\r\n2370\r\n0288\r\n5983\r\n", "output": ["2972"]}, {"input": "6 7\r\n9085507\r\n7716507\r\n1952887\r\n6569746\r\n1900754\r\n9212439\r\n", "output": ["3180457"]}, {"input": "5 2\r\n01\r\n07\r\n63\r\n71\r\n99\r\n", "output": ["89"]}, {"input": "6 4\r\n4505\r\n3672\r\n4248\r\n2783\r\n9780\r\n6579\r\n", "output": ["4484"]}, {"input": "2 3\r\n281\r\n498\r\n", "output": ["127"]}, {"input": "8 5\r\n16966\r\n36762\r\n49579\r\n71703\r\n66646\r\n41125\r\n94022\r\n26623\r\n", "output": ["66868"]}, {"input": "1 6\r\n170086\r\n", "output": ["0"]}, {"input": "4 1\r\n4\r\n2\r\n2\r\n2\r\n", "output": ["2"]}, {"input": "3 8\r\n12418144\r\n74773130\r\n10504811\r\n", "output": ["22901234"]}, {"input": "6 7\r\n3761949\r\n8095136\r\n4875085\r\n5017784\r\n4459097\r\n4354762\r\n", "output": ["4126934"]}]
100
100
100
[{'input': '4 1\r\n0\r\n7\r\n5\r\n1\r\n', 'output': ['7']}, {'input': '3 4\r\n0136\r\n4556\r\n4268\r\n', 'output': ['2134']}, {'input': '6 7\r\n9085507\r\n7716507\r\n1952887\r\n6569746\r\n1900754\r\n9212439\r\n', 'output': ['3180457']}, {'input': '4 4\r\n8851\r\n6190\r\n0521\r\n1659\r\n', 'output': ['6596']}, {'input': '2 5\r\n60106\r\n07866\r\n', 'output': ['5224']}]
[{'input': '1 6\r\n430254\r\n', 'output': ['0']}, {'input': '8 7\r\n8112819\r\n8982110\r\n5457941\r\n4575033\r\n5203331\r\n7410823\r\n0532182\r\n8151054\r\n', 'output': ['6194602']}, {'input': '6 7\r\n4104025\r\n1370353\r\n3472874\r\n5258456\r\n5595923\r\n0279404\r\n', 'output': ['2790148']}, {'input': '3 3\r\n195\r\n860\r\n567\r\n', 'output': ['258']}, {'input': '1 7\r\n3545113\r\n', 'output': ['0']}]
[{'input': '1 7\r\n4605461\r\n', 'output': ['0']}, {'input': '3 4\r\n3061\r\n3404\r\n6670\r\n', 'output': ['2916']}, {'input': '3 1\r\n5\r\n4\r\n2\r\n', 'output': ['3']}, {'input': '6 4\r\n0443\r\n7108\r\n7211\r\n4287\r\n6439\r\n7711\r\n', 'output': ['5301']}, {'input': '8 5\r\n07936\r\n07927\r\n46068\r\n99158\r\n90958\r\n41283\r\n59266\r\n87841\r\n', 'output': ['52364']}]
[{'input': '6 8\r\n50157346\r\n63836375\r\n03176371\r\n83637145\r\n28631038\r\n18617159\r\n', 'output': ['24702445']}, {'input': '5 2\r\n01\r\n07\r\n63\r\n71\r\n99\r\n', 'output': ['89']}, {'input': '8 5\r\n07936\r\n07927\r\n46068\r\n99158\r\n90958\r\n41283\r\n59266\r\n87841\r\n', 'output': ['52364']}, {'input': '2 5\r\n90526\r\n32565\r\n', 'output': ['586']}, {'input': '5 6\r\n959808\r\n303464\r\n414335\r\n758650\r\n828038\r\n', 'output': ['486245']}]
[{'input': '7 7\r\n6575460\r\n6965366\r\n1912357\r\n7080608\r\n2561692\r\n5209630\r\n0439095\r\n', 'output': ['5917123']}, {'input': '6 4\r\n5237\r\n2753\r\n7523\r\n5723\r\n5327\r\n2537\r\n', 'output': ['2700']}, {'input': '4 1\r\n0\r\n7\r\n5\r\n1\r\n', 'output': ['7']}, {'input': '8 1\r\n9\r\n7\r\n6\r\n2\r\n9\r\n6\r\n4\r\n8\r\n', 'output': ['7']}, {'input': '4 1\r\n0\r\n7\r\n5\r\n1\r\n', 'output': ['7']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
396
100
100
100
["3 6\n2 3 5", "6 7\n1 2 3 4 5 6"]
The first line of input contains two integer numbers n and k (1 ≀ n, k ≀ 100) β€” the number of buckets and the length of the garden, respectively. The second line of input contains n integer numbers ai (1 ≀ ai ≀ 100) β€” the length of the segment that can be watered by the i-th bucket in one hour. It is guaranteed that there is at least one bucket such that it is possible to water the garden in integer number of hours using only this bucket.
80520be9916045aca3a7de7bc925af1f
import sys n, k = sys.stdin.readline().strip().split(' ') a = sys.stdin.readline().strip().split(' ') a = list(map(int,a)) s=0 m=0 n = int(n) k = int(k) for i in range(n,0,-1): r = k%a[i-1] if r==0 and a[i-1]>m: m=a[i-1] s=k/m print(int(s))
["2", "7"]
Python
NoteIn the first test the best option is to choose the bucket that allows to water the segment of length 3. We can't choose the bucket that allows to water the segment of length 5 because then we can't water the whole garden.In the second test we can choose only the bucket that allows us to water the segment of length 1.
Print one integer number β€” the minimum number of hours required to water the garden.
Luba thinks about watering her garden. The garden can be represented as a segment of length k. Luba has got n buckets, the i-th bucket allows her to water some continuous subsegment of garden of length exactly ai each hour. Luba can't water any parts of the garden that were already watered, also she can't water the ground outside the garden.Luba has to choose one of the buckets in order to water the garden as fast as possible (as mentioned above, each hour she will water some continuous subsegment of length ai if she chooses the i-th bucket). Help her to determine the minimum number of hours she has to spend watering the garden. It is guaranteed that Luba can always choose a bucket so it is possible water the garden.See the examples for better understanding.
[{"input": "3 6\r\n2 3 5\r\n", "output": ["2"]}, {"input": "6 7\r\n1 2 3 4 5 6\r\n", "output": ["7"]}, {"input": "5 97\r\n1 10 50 97 2\r\n", "output": ["1"]}, {"input": "5 97\r\n1 10 50 100 2\r\n", "output": ["97"]}, {"input": "100 100\r\n2 46 24 18 86 90 31 38 84 49 58 28 15 80 14 24 87 56 62 87 41 87 55 71 87 32 41 56 91 32 24 75 43 42 35 30 72 53 31 26 54 61 87 85 36 75 44 31 7 38 77 57 61 54 70 77 45 96 39 57 11 8 91 42 52 15 42 30 92 41 27 26 34 27 3 80 32 86 26 97 63 91 30 75 14 7 19 23 45 11 8 43 44 73 11 56 3 55 63 16\r\n", "output": ["50"]}, {"input": "100 91\r\n13 13 62 96 74 47 81 46 78 21 20 42 4 73 25 30 76 74 58 28 25 52 42 48 74 40 82 9 25 29 17 22 46 64 57 95 81 39 47 86 40 95 97 35 31 98 45 98 47 78 52 63 58 14 89 97 17 95 28 22 20 36 68 38 95 16 2 26 54 47 42 31 31 81 21 21 65 40 82 53 60 71 75 33 96 98 6 22 95 12 5 48 18 27 58 62 5 96 36 75\r\n", "output": ["7"]}, {"input": "8 8\r\n8 7 6 5 4 3 2 1\r\n", "output": ["1"]}, {"input": "3 8\r\n4 3 2\r\n", "output": ["2"]}, {"input": "3 8\r\n2 4 2\r\n", "output": ["2"]}, {"input": "3 6\r\n1 3 2\r\n", "output": ["2"]}, {"input": "3 6\r\n3 2 5\r\n", "output": ["2"]}, {"input": "3 8\r\n4 2 1\r\n", "output": ["2"]}, {"input": "5 6\r\n2 3 5 1 2\r\n", "output": ["2"]}, {"input": "2 6\r\n5 3\r\n", "output": ["2"]}, {"input": "4 12\r\n6 4 3 1\r\n", "output": ["2"]}, {"input": "3 18\r\n1 9 6\r\n", "output": ["2"]}, {"input": "3 9\r\n3 2 1\r\n", "output": ["3"]}, {"input": "3 6\r\n5 3 2\r\n", "output": ["2"]}, {"input": "2 10\r\n5 2\r\n", "output": ["2"]}, {"input": "2 18\r\n6 3\r\n", "output": ["3"]}, {"input": "4 12\r\n1 2 12 3\r\n", "output": ["1"]}, {"input": "3 7\r\n3 2 1\r\n", "output": ["7"]}, {"input": "3 6\r\n3 2 1\r\n", "output": ["2"]}, {"input": "5 10\r\n5 4 3 2 1\r\n", "output": ["2"]}, {"input": "5 16\r\n8 4 2 1 7\r\n", "output": ["2"]}, {"input": "6 7\r\n6 5 4 3 7 1\r\n", "output": ["1"]}, {"input": "2 6\r\n3 2\r\n", "output": ["2"]}, {"input": "2 4\r\n4 1\r\n", "output": ["1"]}, {"input": "6 8\r\n2 4 1 3 5 7\r\n", "output": ["2"]}, {"input": "6 8\r\n6 5 4 3 2 1\r\n", "output": ["2"]}, {"input": "6 15\r\n5 2 3 6 4 3\r\n", "output": ["3"]}, {"input": "4 8\r\n2 4 8 1\r\n", "output": ["1"]}, {"input": "2 5\r\n5 1\r\n", "output": ["1"]}, {"input": "4 18\r\n3 1 1 2\r\n", "output": ["6"]}, {"input": "2 1\r\n2 1\r\n", "output": ["1"]}, {"input": "3 10\r\n2 10 5\r\n", "output": ["1"]}, {"input": "5 12\r\n12 4 4 4 3\r\n", "output": ["1"]}, {"input": "3 6\r\n6 3 2\r\n", "output": ["1"]}, {"input": "2 2\r\n2 1\r\n", "output": ["1"]}, {"input": "3 18\r\n1 9 3\r\n", "output": ["2"]}, {"input": "3 8\r\n7 2 4\r\n", "output": ["2"]}, {"input": "2 100\r\n99 1\r\n", "output": ["100"]}, {"input": "4 12\r\n1 3 4 2\r\n", "output": ["3"]}, {"input": "3 6\r\n2 3 1\r\n", "output": ["2"]}, {"input": "4 6\r\n3 2 5 12\r\n", "output": ["2"]}, {"input": "4 97\r\n97 1 50 10\r\n", "output": ["1"]}, {"input": "3 12\r\n1 12 2\r\n", "output": ["1"]}, {"input": "4 12\r\n1 4 3 2\r\n", "output": ["3"]}, {"input": "1 1\r\n1\r\n", "output": ["1"]}, {"input": "3 19\r\n7 1 1\r\n", "output": ["19"]}, {"input": "5 12\r\n12 4 3 4 4\r\n", "output": ["1"]}, {"input": "3 8\r\n8 4 2\r\n", "output": ["1"]}, {"input": "3 3\r\n3 2 1\r\n", "output": ["1"]}, {"input": "5 6\r\n3 2 4 2 2\r\n", "output": ["2"]}, {"input": "2 16\r\n8 4\r\n", "output": ["2"]}, {"input": "3 6\r\n10 2 3\r\n", "output": ["2"]}, {"input": "5 3\r\n2 4 5 3 6\r\n", "output": ["1"]}, {"input": "11 99\r\n1 2 3 6 5 4 7 8 99 33 66\r\n", "output": ["1"]}, {"input": "3 12\r\n3 12 2\r\n", "output": ["1"]}, {"input": "5 25\r\n24 5 15 25 23\r\n", "output": ["1"]}, {"input": "2 4\r\n8 1\r\n", "output": ["4"]}, {"input": "4 100\r\n2 50 4 1\r\n", "output": ["2"]}, {"input": "3 28\r\n7 14 1\r\n", "output": ["2"]}, {"input": "4 8\r\n2 8 4 1\r\n", "output": ["1"]}, {"input": "4 6\r\n6 1 2 3\r\n", "output": ["1"]}, {"input": "2 12\r\n4 3\r\n", "output": ["3"]}, {"input": "4 12\r\n1 2 4 3\r\n", "output": ["3"]}, {"input": "5 12\r\n2 3 12 6 4\r\n", "output": ["1"]}, {"input": "4 4\r\n1 2 2 4\r\n", "output": ["1"]}, {"input": "3 6\r\n2 3 2\r\n", "output": ["2"]}, {"input": "4 21\r\n21 20 21 2\r\n", "output": ["1"]}, {"input": "3 8\r\n3 4 2\r\n", "output": ["2"]}, {"input": "1 25\r\n25\r\n", "output": ["1"]}, {"input": "99 12\r\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\r\n", "output": ["1"]}, {"input": "98 12\r\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\r\n", "output": ["1"]}, {"input": "79 12\r\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\r\n", "output": ["1"]}, {"input": "4 32\r\n1 1 1 1\r\n", "output": ["32"]}, {"input": "1 100\r\n1\r\n", "output": ["100"]}, {"input": "2 100\r\n7 1\r\n", "output": ["100"]}, {"input": "7 24\r\n1 3 6 4 5 2 7\r\n", "output": ["4"]}, {"input": "6 87\r\n1 2 8 4 5 7\r\n", "output": ["87"]}, {"input": "1 88\r\n1\r\n", "output": ["88"]}, {"input": "1 89\r\n1\r\n", "output": ["89"]}]
100
100
100
[{'input': '3 18\r\n1 9 6\r\n', 'output': ['2']}, {'input': '2 2\r\n2 1\r\n', 'output': ['1']}, {'input': '2 100\r\n99 1\r\n', 'output': ['100']}, {'input': '4 12\r\n1 3 4 2\r\n', 'output': ['3']}, {'input': '2 4\r\n4 1\r\n', 'output': ['1']}]
[{'input': '4 100\r\n2 50 4 1\r\n', 'output': ['2']}, {'input': '2 100\r\n99 1\r\n', 'output': ['100']}, {'input': '79 12\r\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\r\n', 'output': ['1']}, {'input': '3 6\r\n5 3 2\r\n', 'output': ['2']}, {'input': '2 4\r\n4 1\r\n', 'output': ['1']}]
[{'input': '3 8\r\n3 4 2\r\n', 'output': ['2']}, {'input': '3 8\r\n4 2 1\r\n', 'output': ['2']}, {'input': '5 25\r\n24 5 15 25 23\r\n', 'output': ['1']}, {'input': '4 12\r\n1 3 4 2\r\n', 'output': ['3']}, {'input': '4 21\r\n21 20 21 2\r\n', 'output': ['1']}]
[{'input': '7 24\r\n1 3 6 4 5 2 7\r\n', 'output': ['4']}, {'input': '3 10\r\n2 10 5\r\n', 'output': ['1']}, {'input': '4 32\r\n1 1 1 1\r\n', 'output': ['32']}, {'input': '3 6\r\n10 2 3\r\n', 'output': ['2']}, {'input': '2 16\r\n8 4\r\n', 'output': ['2']}]
[{'input': '3 8\r\n3 4 2\r\n', 'output': ['2']}, {'input': '100 100\r\n2 46 24 18 86 90 31 38 84 49 58 28 15 80 14 24 87 56 62 87 41 87 55 71 87 32 41 56 91 32 24 75 43 42 35 30 72 53 31 26 54 61 87 85 36 75 44 31 7 38 77 57 61 54 70 77 45 96 39 57 11 8 91 42 52 15 42 30 92 41 27 26 34 27 3 80 32 86 26 97 63 91 30 75 14 7 19 23 45 11 8 43 44 73 11 56 3 55 63 16\r\n', 'output': ['50']}, {'input': '2 4\r\n8 1\r\n', 'output': ['4']}, {'input': '3 9\r\n3 2 1\r\n', 'output': ['3']}, {'input': '5 3\r\n2 4 5 3 6\r\n', 'output': ['1']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
397
100
100
100
["1f", "2d", "4a", "5e"]
The only line of input contains a description of Vasya's seat in the format ns, where n (1 ≀ n ≀ 1018) is the index of the row and s is the seat in this row, denoted as letter from 'a' to 'f'. The index of the row and the seat are not separated by a space.
069d0cb9b7c798a81007fb5b63fa0f45
import math rows = [0, 1, 0, 1] seats = ["f", "e", "d", "a", "b", "c"] s = input() a, b = int(s[:-1]), s[-1] print((a - 1) // 4 * 16 + rows[a % 4 - 1] * 7 + seats.index(b) + 1)
["1", "10", "11", "18"]
Python
NoteIn the first sample, the first flight attendant serves Vasya first, so Vasya gets his lunch after 1 second.In the second sample, the flight attendants will spend 6 seconds to serve everyone in the rows 1 and 3, then they will move one row forward in 1 second. As they first serve seats located to the right of the aisle in order from window to aisle, Vasya has to wait 3 more seconds. The total is 6 + 1 + 3 = 10.
Print one integerΒ β€” the number of seconds Vasya has to wait until he gets his lunch.
A new airplane SuperPuperJet has an infinite number of rows, numbered with positive integers starting with 1 from cockpit to tail. There are six seats in each row, denoted with letters from 'a' to 'f'. Seats 'a', 'b' and 'c' are located to the left of an aisle (if one looks in the direction of the cockpit), while seats 'd', 'e' and 'f' are located to the right. Seats 'a' and 'f' are located near the windows, while seats 'c' and 'd' are located near the aisle. Β It's lunch time and two flight attendants have just started to serve food. They move from the first rows to the tail, always maintaining a distance of two rows from each other because of the food trolley. Thus, at the beginning the first attendant serves row 1 while the second attendant serves row 3. When both rows are done they move one row forward: the first attendant serves row 2 while the second attendant serves row 4. Then they move three rows forward and the first attendant serves row 5 while the second attendant serves row 7. Then they move one row forward again and so on.Flight attendants work with the same speed: it takes exactly 1 second to serve one passenger and 1 second to move one row forward. Each attendant first serves the passengers on the seats to the right of the aisle and then serves passengers on the seats to the left of the aisle (if one looks in the direction of the cockpit). Moreover, they always serve passengers in order from the window to the aisle. Thus, the first passenger to receive food in each row is located in seat 'f', and the last oneΒ β€” in seat 'c'. Assume that all seats are occupied.Vasya has seat s in row n and wants to know how many seconds will pass before he gets his lunch.
[{"input": "1f\r\n", "output": ["1"]}, {"input": "2d\r\n", "output": ["10"]}, {"input": "4a\r\n", "output": ["11"]}, {"input": "5e\r\n", "output": ["18"]}, {"input": "2c\r\n", "output": ["13"]}, {"input": "1b\r\n", "output": ["5"]}, {"input": "1000000000000000000d\r\n", "output": ["3999999999999999994"]}, {"input": "999999999999999997a\r\n", "output": ["3999999999999999988"]}, {"input": "1c\r\n", "output": ["6"]}, {"input": "1d\r\n", "output": ["3"]}, {"input": "1e\r\n", "output": ["2"]}, {"input": "1a\r\n", "output": ["4"]}, {"input": "2a\r\n", "output": ["11"]}, {"input": "2b\r\n", "output": ["12"]}, {"input": "2e\r\n", "output": ["9"]}, {"input": "2f\r\n", "output": ["8"]}, {"input": "3a\r\n", "output": ["4"]}, {"input": "3b\r\n", "output": ["5"]}, {"input": "3c\r\n", "output": ["6"]}, {"input": "3d\r\n", "output": ["3"]}, {"input": "3e\r\n", "output": ["2"]}, {"input": "3f\r\n", "output": ["1"]}, {"input": "4b\r\n", "output": ["12"]}, {"input": "4c\r\n", "output": ["13"]}, {"input": "4d\r\n", "output": ["10"]}, {"input": "4e\r\n", "output": ["9"]}, {"input": "4f\r\n", "output": ["8"]}, {"input": "999999997a\r\n", "output": ["3999999988"]}, {"input": "999999997b\r\n", "output": ["3999999989"]}, {"input": "999999997c\r\n", "output": ["3999999990"]}, {"input": "999999997d\r\n", "output": ["3999999987"]}, {"input": "999999997e\r\n", "output": ["3999999986"]}, {"input": "999999997f\r\n", "output": ["3999999985"]}, {"input": "999999998a\r\n", "output": ["3999999995"]}, {"input": "999999998b\r\n", "output": ["3999999996"]}, {"input": "999999998c\r\n", "output": ["3999999997"]}, {"input": "999999998d\r\n", "output": ["3999999994"]}, {"input": "999999998e\r\n", "output": ["3999999993"]}, {"input": "999999998f\r\n", "output": ["3999999992"]}, {"input": "999999999a\r\n", "output": ["3999999988"]}, {"input": "999999999b\r\n", "output": ["3999999989"]}, {"input": "999999999c\r\n", "output": ["3999999990"]}, {"input": "999999999d\r\n", "output": ["3999999987"]}, {"input": "999999999e\r\n", "output": ["3999999986"]}, {"input": "999999999f\r\n", "output": ["3999999985"]}, {"input": "1000000000a\r\n", "output": ["3999999995"]}, {"input": "1000000000b\r\n", "output": ["3999999996"]}, {"input": "1000000000c\r\n", "output": ["3999999997"]}, {"input": "1000000000d\r\n", "output": ["3999999994"]}, {"input": "1000000000e\r\n", "output": ["3999999993"]}, {"input": "1000000000f\r\n", "output": ["3999999992"]}, {"input": "100000b\r\n", "output": ["399996"]}, {"input": "100000f\r\n", "output": ["399992"]}, {"input": "100001d\r\n", "output": ["400003"]}, {"input": "100001e\r\n", "output": ["400002"]}, {"input": "100001f\r\n", "output": ["400001"]}, {"input": "100002a\r\n", "output": ["400011"]}, {"input": "100002b\r\n", "output": ["400012"]}, {"input": "100002d\r\n", "output": ["400010"]}, {"input": "1231273a\r\n", "output": ["4925092"]}, {"input": "82784f\r\n", "output": ["331128"]}, {"input": "88312c\r\n", "output": ["353245"]}, {"input": "891237e\r\n", "output": ["3564946"]}, {"input": "999999999999999997b\r\n", "output": ["3999999999999999989"]}, {"input": "999999999999999997c\r\n", "output": ["3999999999999999990"]}, {"input": "999999999999999997d\r\n", "output": ["3999999999999999987"]}, {"input": "999999999999999997e\r\n", "output": ["3999999999999999986"]}, {"input": "999999999999999997f\r\n", "output": ["3999999999999999985"]}, {"input": "999999999999999998a\r\n", "output": ["3999999999999999995"]}, {"input": "999999999999999998b\r\n", "output": ["3999999999999999996"]}, {"input": "999999999999999998c\r\n", "output": ["3999999999999999997"]}, {"input": "999999999999999998d\r\n", "output": ["3999999999999999994"]}, {"input": "999999999999999998e\r\n", "output": ["3999999999999999993"]}, {"input": "999999999999999998f\r\n", "output": ["3999999999999999992"]}, {"input": "999999999999999999a\r\n", "output": ["3999999999999999988"]}, {"input": "999999999999999999b\r\n", "output": ["3999999999999999989"]}, {"input": "999999999999999999c\r\n", "output": ["3999999999999999990"]}, {"input": "999999999999999999d\r\n", "output": ["3999999999999999987"]}, {"input": "1000000000000000000a\r\n", "output": ["3999999999999999995"]}, {"input": "1000000000000000000e\r\n", "output": ["3999999999999999993"]}, {"input": "1000000000000000000f\r\n", "output": ["3999999999999999992"]}, {"input": "1000000000000000000c\r\n", "output": ["3999999999999999997"]}, {"input": "97a\r\n", "output": ["388"]}, {"input": "6f\r\n", "output": ["24"]}, {"input": "7f\r\n", "output": ["17"]}, {"input": "7e\r\n", "output": ["18"]}, {"input": "999999999999999992c\r\n", "output": ["3999999999999999965"]}, {"input": "7a\r\n", "output": ["20"]}, {"input": "8f\r\n", "output": ["24"]}, {"input": "999999999999999992a\r\n", "output": ["3999999999999999963"]}, {"input": "999999999999999992b\r\n", "output": ["3999999999999999964"]}, {"input": "999999999999999992c\r\n", "output": ["3999999999999999965"]}, {"input": "999999999999999992d\r\n", "output": ["3999999999999999962"]}, {"input": "999999999999999992e\r\n", "output": ["3999999999999999961"]}, {"input": "999999999999999992f\r\n", "output": ["3999999999999999960"]}, {"input": "999999999999999993a\r\n", "output": ["3999999999999999972"]}, {"input": "999999999999999993b\r\n", "output": ["3999999999999999973"]}, {"input": "999999999999999993c\r\n", "output": ["3999999999999999974"]}, {"input": "999999999999999993d\r\n", "output": ["3999999999999999971"]}, {"input": "999999999999999993e\r\n", "output": ["3999999999999999970"]}, {"input": "999999999999999993f\r\n", "output": ["3999999999999999969"]}, {"input": "999999999999999994a\r\n", "output": ["3999999999999999979"]}, {"input": "999999999999999994b\r\n", "output": ["3999999999999999980"]}, {"input": "999999999999999994c\r\n", "output": ["3999999999999999981"]}, {"input": "999999999999999994d\r\n", "output": ["3999999999999999978"]}, {"input": "999999999999999994e\r\n", "output": ["3999999999999999977"]}, {"input": "999999999999999994f\r\n", "output": ["3999999999999999976"]}, {"input": "999999999999999995a\r\n", "output": ["3999999999999999972"]}, {"input": "999999999999999995b\r\n", "output": ["3999999999999999973"]}, {"input": "999999999999999995c\r\n", "output": ["3999999999999999974"]}, {"input": "999999999999999995d\r\n", "output": ["3999999999999999971"]}, {"input": "999999999999999995e\r\n", "output": ["3999999999999999970"]}, {"input": "999999999999999995f\r\n", "output": ["3999999999999999969"]}, {"input": "10a\r\n", "output": ["43"]}, {"input": "11f\r\n", "output": ["33"]}, {"input": "681572647b\r\n", "output": ["2726290581"]}, {"input": "23f\r\n", "output": ["81"]}, {"input": "123a\r\n", "output": ["484"]}, {"input": "999999888888777777a\r\n", "output": ["3999999555555111108"]}]
100
100
100
[{'input': '999999999999999997a\r\n', 'output': ['3999999999999999988']}, {'input': '999999999999999997e\r\n', 'output': ['3999999999999999986']}, {'input': '1000000000f\r\n', 'output': ['3999999992']}, {'input': '1b\r\n', 'output': ['5']}, {'input': '999999999999999998c\r\n', 'output': ['3999999999999999997']}]
[{'input': '999999999999999995a\r\n', 'output': ['3999999999999999972']}, {'input': '1a\r\n', 'output': ['4']}, {'input': '999999999f\r\n', 'output': ['3999999985']}, {'input': '999999999d\r\n', 'output': ['3999999987']}, {'input': '999999999999999999c\r\n', 'output': ['3999999999999999990']}]
[{'input': '3f\r\n', 'output': ['1']}, {'input': '999999999999999992d\r\n', 'output': ['3999999999999999962']}, {'input': '999999999999999997b\r\n', 'output': ['3999999999999999989']}, {'input': '2c\r\n', 'output': ['13']}, {'input': '999999999999999997c\r\n', 'output': ['3999999999999999990']}]
[{'input': '3a\r\n', 'output': ['4']}, {'input': '999999997c\r\n', 'output': ['3999999990']}, {'input': '999999999999999993e\r\n', 'output': ['3999999999999999970']}, {'input': '100000b\r\n', 'output': ['399996']}, {'input': '100001e\r\n', 'output': ['400002']}]
[{'input': '2c\r\n', 'output': ['13']}, {'input': '999999998f\r\n', 'output': ['3999999992']}, {'input': '1000000000b\r\n', 'output': ['3999999996']}, {'input': '100000f\r\n', 'output': ['399992']}, {'input': '1000000000e\r\n', 'output': ['3999999993']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
398
100
100
100
["10 3", "7 7"]
The only line of input contains integers n and k (1 ≀ k ≀ n ≀ 1012). Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
1f8056884db00ad8294a7cc0be75fe97
n,k=map(int,input().split()) if n%2==0 : if (k > n//2) : print((k-n//2)*2) else : print(2*k - 1) else : if (k > ((n-1)//2)+ 1) : print((k-1-((n-1)//2))*2) else : print(2*k - 1)
["5", "6"]
Python
NoteIn the first sample Volodya's sequence will look like this: {1, 3, 5, 7, 9, 2, 4, 6, 8, 10}. The third place in the sequence is therefore occupied by the number 5.
Print the number that will stand at the position number k after Volodya's manipulations.
Being a nonconformist, Volodya is displeased with the current state of things, particularly with the order of natural numbers (natural number is positive integer number). He is determined to rearrange them. But there are too many natural numbers, so Volodya decided to start with the first n. He writes down the following sequence of numbers: firstly all odd integers from 1 to n (in ascending order), then all even integers from 1 to n (also in ascending order). Help our hero to find out which number will stand at the position number k.
[{"input": "10 3\r\n", "output": ["5"]}, {"input": "7 7\r\n", "output": ["6"]}, {"input": "7 1\r\n", "output": ["1"]}, {"input": "7 2\r\n", "output": ["3"]}, {"input": "8 5\r\n", "output": ["2"]}, {"input": "8 3\r\n", "output": ["5"]}, {"input": "8 4\r\n", "output": ["7"]}, {"input": "1000000000000 500000000001\r\n", "output": ["2"]}, {"input": "999999999997 499999999999\r\n", "output": ["999999999997"]}, {"input": "999999999999 999999999999\r\n", "output": ["999999999998"]}, {"input": "1000000000000 1\r\n", "output": ["1"]}, {"input": "999999999999 1\r\n", "output": ["1"]}, {"input": "1 1\r\n", "output": ["1"]}, {"input": "1000000000000 1000000000000\r\n", "output": ["1000000000000"]}, {"input": "1000000000000 500000000000\r\n", "output": ["999999999999"]}, {"input": "1000000000000 499999999999\r\n", "output": ["999999999997"]}, {"input": "999999999997 499999999998\r\n", "output": ["999999999995"]}, {"input": "619234238 556154835\r\n", "output": ["493075432"]}, {"input": "38151981 36650624\r\n", "output": ["35149266"]}, {"input": "680402465 442571217\r\n", "output": ["204739968"]}, {"input": "109135284 9408714\r\n", "output": ["18817427"]}, {"input": "603701841 56038951\r\n", "output": ["112077901"]}, {"input": "356764822 321510177\r\n", "output": ["286255532"]}, {"input": "284911189 142190783\r\n", "output": ["284381565"]}, {"input": "91028405 61435545\r\n", "output": ["31842684"]}]
100
100
100
[{'input': '8 4\r\n', 'output': ['7']}, {'input': '8 3\r\n', 'output': ['5']}, {'input': '999999999997 499999999999\r\n', 'output': ['999999999997']}, {'input': '1000000000000 1000000000000\r\n', 'output': ['1000000000000']}, {'input': '7 2\r\n', 'output': ['3']}]
[{'input': '999999999999 999999999999\r\n', 'output': ['999999999998']}, {'input': '7 1\r\n', 'output': ['1']}, {'input': '1000000000000 1\r\n', 'output': ['1']}, {'input': '619234238 556154835\r\n', 'output': ['493075432']}, {'input': '91028405 61435545\r\n', 'output': ['31842684']}]
[{'input': '91028405 61435545\r\n', 'output': ['31842684']}, {'input': '603701841 56038951\r\n', 'output': ['112077901']}, {'input': '1000000000000 1000000000000\r\n', 'output': ['1000000000000']}, {'input': '1000000000000 500000000001\r\n', 'output': ['2']}, {'input': '999999999997 499999999998\r\n', 'output': ['999999999995']}]
[{'input': '8 5\r\n', 'output': ['2']}, {'input': '999999999997 499999999999\r\n', 'output': ['999999999997']}, {'input': '8 3\r\n', 'output': ['5']}, {'input': '999999999999 1\r\n', 'output': ['1']}, {'input': '7 1\r\n', 'output': ['1']}]
[{'input': '1 1\r\n', 'output': ['1']}, {'input': '999999999997 499999999999\r\n', 'output': ['999999999997']}, {'input': '91028405 61435545\r\n', 'output': ['31842684']}, {'input': '7 1\r\n', 'output': ['1']}, {'input': '1000000000000 500000000001\r\n', 'output': ['2']}]
100
100
100
100
100
87.5
100
87.5
87.5
87.5
83.33
100
83.33
83.33
83.33
399
100
90
86.664
["3 30\n2 2 1", "3 20\n2 1 1"]
The first line contains two space separated integers n, d (1 ≀ n ≀ 100;Β 1 ≀ d ≀ 10000). The second line contains n space-separated integers: t1, t2, ..., tn (1 ≀ ti ≀ 100).
b16f5f5c4eeed2a3700506003e8ea8ea
__author__ = 'myduomilia' n, t = list(map(int, input().split())) arr = list(map(int, input().split())) s = sum(arr) ans = 0 if s + (len(arr) - 1) * 10 > t: print(-1) else: print((t - s) // 5)
["5", "-1"]
Python
NoteConsider the first example. The duration of the event is 30 minutes. There could be maximum 5 jokes in the following way: First Churu cracks a joke in 5 minutes. Then Devu performs the first song for 2 minutes. Then Churu cracks 2 jokes in 10 minutes. Now Devu performs second song for 2 minutes. Then Churu cracks 2 jokes in 10 minutes. Now finally Devu will perform his last song in 1 minutes. Total time spent is 5 + 2 + 10 + 2 + 10 + 1 = 30 minutes.Consider the second example. There is no way of organizing Devu's all songs. Hence the answer is -1.
If there is no way to conduct all the songs of Devu, output -1. Otherwise output the maximum number of jokes that Churu can crack in the grand event.
Devu is a renowned classical singer. He is invited to many big functions/festivals. Recently he was invited to "All World Classical Singing Festival". Other than Devu, comedian Churu was also invited.Devu has provided organizers a list of the songs and required time for singing them. He will sing n songs, ith song will take ti minutes exactly. The Comedian, Churu will crack jokes. All his jokes are of 5 minutes exactly.People have mainly come to listen Devu. But you know that he needs rest of 10 minutes after each song. On the other hand, Churu being a very active person, doesn't need any rest.You as one of the organizers should make an optimal sсhedule for the event. For some reasons you must follow the conditions: The duration of the event must be no more than d minutes; Devu must complete all his songs; With satisfying the two previous conditions the number of jokes cracked by Churu should be as many as possible. If it is not possible to find a way to conduct all the songs of the Devu, output -1. Otherwise find out maximum number of jokes that Churu can crack in the grand event.
[{"input": "3 30\r\n2 2 1\r\n", "output": ["5"]}, {"input": "3 20\r\n2 1 1\r\n", "output": ["-1"]}, {"input": "50 10000\r\n5 4 10 9 9 6 7 7 7 3 3 7 7 4 7 4 10 10 1 7 10 3 1 4 5 7 2 10 10 10 2 3 4 7 6 1 8 4 7 3 8 8 4 10 1 1 9 2 6 1\r\n", "output": ["1943"]}, {"input": "50 10000\r\n4 7 15 9 11 12 20 9 14 14 10 13 6 13 14 17 6 8 20 12 10 15 13 17 5 12 13 11 7 5 5 2 3 15 13 7 14 14 19 2 13 14 5 15 3 19 15 16 4 1\r\n", "output": ["1891"]}, {"input": "100 9000\r\n5 2 3 1 1 3 4 9 9 6 7 10 10 10 2 10 6 8 8 6 7 9 9 5 6 2 1 10 10 9 4 5 9 2 4 3 8 5 6 1 1 5 3 6 2 6 6 6 5 8 3 6 7 3 1 10 9 1 8 3 10 9 5 6 3 4 1 1 10 10 2 3 4 8 10 10 5 1 5 3 6 8 10 6 10 2 1 8 10 1 7 6 9 10 5 2 3 5 3 2\r\n", "output": ["1688"]}, {"input": "100 8007\r\n5 19 14 18 9 6 15 8 1 14 11 20 3 17 7 12 2 6 3 17 7 20 1 14 20 17 2 10 13 7 18 18 9 10 16 8 1 11 11 9 13 18 9 20 12 12 7 15 12 17 11 5 11 15 9 2 15 1 18 3 18 16 15 4 10 5 18 13 13 12 3 8 17 2 12 2 13 3 1 13 2 4 9 10 18 10 14 4 4 17 12 19 2 9 6 5 5 20 18 12\r\n", "output": ["1391"]}, {"input": "39 2412\r\n1 1 1 1 1 1 26 1 1 1 99 1 1 1 1 1 1 1 1 1 1 88 7 1 1 1 1 76 1 1 1 93 40 1 13 1 68 1 32\r\n", "output": ["368"]}, {"input": "39 2617\r\n47 1 1 1 63 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 70 1 99 63 1 1 1 1 1 1 1 1 64 1 1\r\n", "output": ["435"]}, {"input": "39 3681\r\n83 77 1 94 85 47 1 98 29 16 1 1 1 71 96 85 31 97 96 93 40 50 98 1 60 51 1 96 100 72 1 1 1 89 1 93 1 92 100\r\n", "output": ["326"]}, {"input": "45 894\r\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 28 28 1 1 1 1 1 1 1 1 1 1 1 1 1 1 99 3 1 1\r\n", "output": ["139"]}, {"input": "45 4534\r\n1 99 65 99 4 46 54 80 51 30 96 1 28 30 44 70 78 1 1 100 1 62 1 1 1 85 1 1 1 61 1 46 75 1 61 77 97 26 67 1 1 63 81 85 86\r\n", "output": ["514"]}, {"input": "72 3538\r\n52 1 8 1 1 1 7 1 1 1 1 48 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 40 1 1 38 1 1 1 1 1 1 1 1 1 1 1 35 1 93 79 1 1 1 1 1 1 1 1 1 51 1 1 1 1 1 1 1 1 1 1 1 1 96 1\r\n", "output": ["586"]}, {"input": "81 2200\r\n1 59 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 93 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 50 1 1 1 1 1 1 1 1 1 1 1\r\n", "output": ["384"]}, {"input": "81 2577\r\n85 91 1 1 2 1 1 100 1 80 1 1 17 86 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 37 1 66 24 1 1 96 49 1 66 1 44 1 1 1 1 98 1 1 1 1 35 1 37 3 35 1 1 87 64 1 24 1 58 1 1 42 83 5 1 1 1 1 1 95 1 94 1 50 1 1\r\n", "output": ["174"]}, {"input": "81 4131\r\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 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n", "output": ["807"]}, {"input": "81 6315\r\n1 1 67 100 1 99 36 1 92 5 1 96 42 12 1 57 91 1 1 66 41 30 74 95 1 37 1 39 91 69 1 52 77 47 65 1 1 93 96 74 90 35 85 76 71 92 92 1 1 67 92 74 1 1 86 76 35 1 56 16 27 57 37 95 1 40 20 100 51 1 80 60 45 79 95 1 46 1 25 100 96\r\n", "output": ["490"]}, {"input": "96 1688\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 45 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 25 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 71 1 1 1 30 1 1 1\r\n", "output": ["284"]}, {"input": "96 8889\r\n1 1 18 1 1 1 1 1 1 1 1 1 99 1 1 1 1 88 1 45 1 1 1 1 1 1 1 1 1 1 1 1 1 1 96 1 1 1 1 21 1 1 1 1 1 1 1 73 1 1 1 1 1 10 1 1 1 1 1 1 1 46 43 1 1 1 1 1 98 1 1 1 1 1 1 6 1 1 1 1 1 74 1 25 1 55 1 1 1 13 1 1 54 1 1 1\r\n", "output": ["1589"]}, {"input": "10 100\r\n1 1 1 1 1 1 1 1 1 1\r\n", "output": ["18"]}, {"input": "100 10000\r\n54 46 72 94 79 83 91 54 73 3 24 55 54 31 28 20 19 6 25 19 47 23 1 70 15 87 51 39 54 77 55 5 60 3 15 99 56 88 22 78 79 21 38 27 28 86 7 88 12 59 55 70 25 1 70 49 1 45 69 72 50 17 4 56 8 100 90 34 35 20 61 76 88 79 4 74 65 68 75 26 40 72 59 94 10 67 96 85 29 90 47 24 44 1 66 93 55 36 1 99\r\n", "output": ["1017"]}, {"input": "100 6000\r\n41 31 23 17 24 78 26 96 93 48 46 2 49 33 35 9 73 100 34 48 83 36 33 69 43 24 3 74 8 81 27 33 94 38 77 9 76 90 62 90 21 67 22 22 12 2 17 27 61 18 72 85 59 65 71 38 90 75 74 66 60 47 58 50 90 95 75 10 5 100 97 29 83 88 65 26 93 90 22 98 36 55 70 38 50 92 88 72 99 96 25 14 74 16 25 92 67 94 77 96\r\n", "output": ["-1"]}, {"input": "1 1\r\n1\r\n", "output": ["0"]}, {"input": "1 6\r\n1\r\n", "output": ["1"]}, {"input": "1 5\r\n1\r\n", "output": ["0"]}, {"input": "1 3\r\n4\r\n", "output": ["-1"]}, {"input": "3 24\r\n2 1 2\r\n", "output": ["-1"]}]
100
100
100
[{'input': '100 10000\r\n54 46 72 94 79 83 91 54 73 3 24 55 54 31 28 20 19 6 25 19 47 23 1 70 15 87 51 39 54 77 55 5 60 3 15 99 56 88 22 78 79 21 38 27 28 86 7 88 12 59 55 70 25 1 70 49 1 45 69 72 50 17 4 56 8 100 90 34 35 20 61 76 88 79 4 74 65 68 75 26 40 72 59 94 10 67 96 85 29 90 47 24 44 1 66 93 55 36 1 99\r\n', 'output': ['1017']}, {'input': '45 894\r\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 28 28 1 1 1 1 1 1 1 1 1 1 1 1 1 1 99 3 1 1\r\n', 'output': ['139']}, {'input': '39 2412\r\n1 1 1 1 1 1 26 1 1 1 99 1 1 1 1 1 1 1 1 1 1 88 7 1 1 1 1 76 1 1 1 93 40 1 13 1 68 1 32\r\n', 'output': ['368']}, {'input': '81 2577\r\n85 91 1 1 2 1 1 100 1 80 1 1 17 86 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 37 1 66 24 1 1 96 49 1 66 1 44 1 1 1 1 98 1 1 1 1 35 1 37 3 35 1 1 87 64 1 24 1 58 1 1 42 83 5 1 1 1 1 1 95 1 94 1 50 1 1\r\n', 'output': ['174']}, {'input': '96 8889\r\n1 1 18 1 1 1 1 1 1 1 1 1 99 1 1 1 1 88 1 45 1 1 1 1 1 1 1 1 1 1 1 1 1 1 96 1 1 1 1 21 1 1 1 1 1 1 1 73 1 1 1 1 1 10 1 1 1 1 1 1 1 46 43 1 1 1 1 1 98 1 1 1 1 1 1 6 1 1 1 1 1 74 1 25 1 55 1 1 1 13 1 1 54 1 1 1\r\n', 'output': ['1589']}]
[{'input': '81 4131\r\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 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n', 'output': ['807']}, {'input': '3 30\r\n2 2 1\r\n', 'output': ['5']}, {'input': '81 2200\r\n1 59 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 93 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 50 1 1 1 1 1 1 1 1 1 1 1\r\n', 'output': ['384']}, {'input': '96 8889\r\n1 1 18 1 1 1 1 1 1 1 1 1 99 1 1 1 1 88 1 45 1 1 1 1 1 1 1 1 1 1 1 1 1 1 96 1 1 1 1 21 1 1 1 1 1 1 1 73 1 1 1 1 1 10 1 1 1 1 1 1 1 46 43 1 1 1 1 1 98 1 1 1 1 1 1 6 1 1 1 1 1 74 1 25 1 55 1 1 1 13 1 1 54 1 1 1\r\n', 'output': ['1589']}, {'input': '45 894\r\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 28 28 1 1 1 1 1 1 1 1 1 1 1 1 1 1 99 3 1 1\r\n', 'output': ['139']}]
[{'input': '81 6315\r\n1 1 67 100 1 99 36 1 92 5 1 96 42 12 1 57 91 1 1 66 41 30 74 95 1 37 1 39 91 69 1 52 77 47 65 1 1 93 96 74 90 35 85 76 71 92 92 1 1 67 92 74 1 1 86 76 35 1 56 16 27 57 37 95 1 40 20 100 51 1 80 60 45 79 95 1 46 1 25 100 96\r\n', 'output': ['490']}, {'input': '81 2577\r\n85 91 1 1 2 1 1 100 1 80 1 1 17 86 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 37 1 66 24 1 1 96 49 1 66 1 44 1 1 1 1 98 1 1 1 1 35 1 37 3 35 1 1 87 64 1 24 1 58 1 1 42 83 5 1 1 1 1 1 95 1 94 1 50 1 1\r\n', 'output': ['174']}, {'input': '39 3681\r\n83 77 1 94 85 47 1 98 29 16 1 1 1 71 96 85 31 97 96 93 40 50 98 1 60 51 1 96 100 72 1 1 1 89 1 93 1 92 100\r\n', 'output': ['326']}, {'input': '45 4534\r\n1 99 65 99 4 46 54 80 51 30 96 1 28 30 44 70 78 1 1 100 1 62 1 1 1 85 1 1 1 61 1 46 75 1 61 77 97 26 67 1 1 63 81 85 86\r\n', 'output': ['514']}, {'input': '1 1\r\n1\r\n', 'output': ['0']}]
[{'input': '1 1\r\n1\r\n', 'output': ['0']}, {'input': '50 10000\r\n4 7 15 9 11 12 20 9 14 14 10 13 6 13 14 17 6 8 20 12 10 15 13 17 5 12 13 11 7 5 5 2 3 15 13 7 14 14 19 2 13 14 5 15 3 19 15 16 4 1\r\n', 'output': ['1891']}, {'input': '81 4131\r\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 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n', 'output': ['807']}, {'input': '100 9000\r\n5 2 3 1 1 3 4 9 9 6 7 10 10 10 2 10 6 8 8 6 7 9 9 5 6 2 1 10 10 9 4 5 9 2 4 3 8 5 6 1 1 5 3 6 2 6 6 6 5 8 3 6 7 3 1 10 9 1 8 3 10 9 5 6 3 4 1 1 10 10 2 3 4 8 10 10 5 1 5 3 6 8 10 6 10 2 1 8 10 1 7 6 9 10 5 2 3 5 3 2\r\n', 'output': ['1688']}, {'input': '1 6\r\n1\r\n', 'output': ['1']}]
[{'input': '3 24\r\n2 1 2\r\n', 'output': ['-1']}, {'input': '81 4131\r\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 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n', 'output': ['807']}, {'input': '3 30\r\n2 2 1\r\n', 'output': ['5']}, {'input': '100 9000\r\n5 2 3 1 1 3 4 9 9 6 7 10 10 10 2 10 6 8 8 6 7 9 9 5 6 2 1 10 10 9 4 5 9 2 4 3 8 5 6 1 1 5 3 6 2 6 6 6 5 8 3 6 7 3 1 10 9 1 8 3 10 9 5 6 3 4 1 1 10 10 2 3 4 8 10 10 5 1 5 3 6 8 10 6 10 2 1 8 10 1 7 6 9 10 5 2 3 5 3 2\r\n', 'output': ['1688']}, {'input': '45 894\r\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 28 28 1 1 1 1 1 1 1 1 1 1 1 1 1 1 99 3 1 1\r\n', 'output': ['139']}]
100
100
100
100
100
87.5
87.5
87.5
87.5
100
50
50
50
50
100
400
100
90
60