P19567 [HackerEarth] One fine day, when everything was going good, Mehta was fired from his job and had to leave all the work.
提高
题目描述

One fine day, when everything was going good, Mehta was fired from his job and had to leave all the work.
So, he decided to become a member of gangster squad and start his new career of robbing.
Being a novice, mehta was asked to perform a robbery task in which he was given a bag having a capacity W units.
So, when he reached the house to be robbed, there lay N items each having particular weight and particular profit associated with it.
But, theres a twist associated, He has first 10 primes with him, which he can use atmost once, if he picks any item x, then he can multiply his profit[x] with any of the first 10 primes and then put that item into his bag. Each prime can only be used with one particular item and one item can only have atmost one prime multiplied with its profit. Its not necessary to pick all the items. If he doesnt want to use a prime with any particular item, he can simply add the profit as it is, more specifically, 1*profit[x] for xth item will get added to its total profit, and that he can do with as many items as he wants. He cannot fill his bag more than weight W units. Each item should be picked with its whole weight, i.e it cannot be broken into several other items of lesser weight. So, now to impress his squad, he wishes to maximize the total profit he can achieve by robbing this wealthy house.

Input:

First Line of input containts two integers N and W.
Next N lines contain information of ith item, describing profit and weight of the ith item, profit and weight are separated by single space.

Output:

In a single line, output the maximum profit obtainable.

Constraints:

1 ≤ N ≤ 2000, 1 ≤ W ≤ 2000

1 ≤ Profit[i] ≤ 10^9, 1 ≤ Weight[i] ≤ 2000

Explanation:

As all, the items can be picked, so maximum profit is equal to = 1 X 19 + 2 X 23 + 3 X 29 = 152

SAMPLE INPUT
3 4
1 1
2 1
3 1

SAMPLE OUTPUT
152

输入格式

见题面

输出格式

见题面

样例输入
913 19 196796598 1352 370877841 1266 471352986 394 976356590 449 756022401 646 163760458 356 593174565 476 52284046 555 126343927 556 432924456 958 595835040 1973 294969506 1698 525729842 728 846508000 1534 639838704 651 260096758 1447 504728502 1241 933588132 1782 677028359 1479 318999919 1996 630553521 1777 467123292 316 617333279 1410 446137676 998 379014715 1379 659117295 164 425033213 1194 971754086 205 379436181 1428 436277369 1384 686455601 1182 234584689 635 248953451 1901 201734804 2000 860110931 1134 24147515 1912 183861524 887 693181841 698 805319749 1179 201140970 1332 786602702 1405 964039101 258 41753973 476 589455168 109 725544452 1389 962134687 186 289808665 87 849322712 1459 887067463 646 825324515 1570 201455975 1867 921401053 315 203804220 1458 346446859 1660 914485757 1785 771637605 703 233209191 1820 316471034 14 824589380 1972 774172083 919 870892196 1017 248970267 393 179164093 213 353660869 970 55072349 1844 738519851 519 149227287 47 184296323 354 703324008 647 21802984 1770 658506744 386 370932605 928 411801988 1744 70057269 917 352833126 1431 23850166 367 491770184 1372 481736024 597 666522355 354 168174924 413 100350789 44 34160346 31 463659329 1888 623779778 982 252688961 1595 857403076 1235 106944582 955 967265596 445 882215792 268 496775909 825 166664329 611 443395518 1537 120316603 1312 629335049 421 69818978 52 8168560 331 937686780 1855 80966211 323 360246845 420 13220316 172 531705408 875 939411236 381 448294103 1427 990661678 1569 388983299 1106 615318016 1874 363143551 1290 486098291 1984 198965623 1403 60156464 63 247748694 447 681720282 1818 915964348 229 762005834 1095 712974991 29 970917365 217 399799337 1565 561177196 1087 995633134 1272 365895473 1009 989047462 1741 992454861 450 155186937 2000 552180542 1520 213176112 1031 924901587 1351 834136366 47 607268298 259 464248276 1103 1443002 17 734418993 1696 244068915 925 955458932 49 780813088 591 768902288 127 165496763 558 434850695 1495 269927934 948 723209316 6 153242516 494 913466595 236 332200464 1981 243078893 1701 647474500 370 152992436 1206 779145930 1841 260062527 1513 198051395 1597 235960485 386 713098832 806 69670087 314 341926017 1731 379756040 1728 885632259 186 551141709 1366 249599862 1646 298048547 825 959978205 598 23356160 1386 65928367 774 24806818 846 74766090 1116 180650388 1038 580582634 367 483634332 1208 937116459 61 432497283 1150 393230809 249 639854215 247 650667826 468 479823781 1846 357833485 518 279025770 739 494424426 598 273255807 1376 442504479 556 296570436 1832 287562593 1193 707733282 1353 104297826 1089 337872636 1101 319911956 1030 560946627 980 761174539 498 544288808 1695 374424960 1408 442209389 1675 229248113 584 951231061 1303 526659302 1749 95159866 1844 483484495 1733 232164669 921 785335562 268 611406487 1072 393309440 661 421535246 1809 125235311 1303 750077608 130 951203695 1034 301536668 128 902622161 1104 81386995 1140 479146209 935 839518041 573 162197346 70 383411287 988 34756280 834 311999218 1405 358167916 690 918445647 877 202313380 1978 704518770 26 885724341 1701 513681954 1189 19104975 654 267291881 582 318353367 523 265852216 605 20643410 375 180967591 592 126803324 1515 464500825 134 985121145 40 285307261 1614 560781475 1219 96919026 125 343040514 1101 223454978 66 31701209 1902 97076815 1400 981550941 30 319107788 727 971696257 384 492845026 407 395175660 907 916056242 659 78323468 1718 514646394 1606 101988420 383 359188241 596 114773313 167 683951244 7 683380074 926 6105859 357 424614262 455 16839022 1946 104961815 56 269257384 984 844254676 81 558370710 1911 711376628 102 300816225 362 737018006 1226 101191134 1280 1938398 1146 571381263 1892 599370826 1267 834642115 66 113133602 65 874254680 277 238955534 1781 174504097 434 897484225 1393 231012322 43 665464275 1444 73978360 1633 524316333 1037 777820822 1241 288524445 1693 335540138 1209 640104202 686 716390621 752 587335873 169 212466489 1823 954526573 1689 192767206 40 676798502 666 472715533 1473 789224224 589 424197598 1157 374493316 1227 452646572 1863 793965147 691 629719605 1748 734710183 962 687517440 1860 415484556 1230 557108703 813 739623339 1023 826016916 1380 322835088 1787 874572944 1040 135953217 1068 753169366 1069 838711543 1679 176416255 122 461388777 92 44687702 160 423640643 1933 506944547 1791 262663734 398 398046213 630 41962281 1263 441627000 94 481581069 72 322439543 501 28375758 1226 699531579 1394 397113470 33 473855481 602 516551212 1801 886777149 1591 314425530 634 230016365 1720 132252575 1428 563195485 1743 284338963 1630 463136338 1619 693944333 1433 53909736 600 894017670 484 309352811 1659 362723274 722 994159764 500 826632976 1210 433481501 1352 997857345 676 936589538 217 261315869 1204 81676750 365 603053179 548 763072501 1542 374727277 1297 71260388 2 695463297 1043 740695971 1716 450146296 1211 28813826 754 499995540 1459 844464754 665 471874051 1301 446013350 571 191231410 1021 858825725 1825 218846281 58 506409866 636 769556525 1772 194589335 73 868901700 815 138383801 697 406351886 1319 96106306 418 943002530 1238 198846604 886 583511932 1358 957368329 101 32994747 1898 390519258 1454 209379947 606 416799598 346 826565820 1577 765882364 1944 526798349 738 141182250 25 489296823 181 186269323 306 221005816 629 904938592 411 651161918 1568 837012182 1397 194407551 1410 772507643 482 227528722 1111 146029349 1488 817620522 1088 116395779 1807 237935855 1924 375008830 1181 139729466 1582 117910219 1380 569971949 1668 592111056 1449 329604078 711 462029360 1525 388235454 486 111088053 1536 446451129 494 380857049 105 761623532 1117 40416561 498 530222734 276 272860791 56 409610269 1737 644063282 1809 224848150 732 628357636 430 198901234 496 505520336 1798 935145565 1142 380394535 960 534116029 300 210961749 1932 851396431 1610 717396432 925 982756818 1687 491358640 364 128556971 220 674582903 1633 49177401 351 786168309 1968 818476106 1068 686410357 994 908810111 1483 920749799 1418 388667605 149 84346999 838 155733711 1126 367311307 1544 517025346 286 26331866 1599 420291172 1230 410644882 590 514366225 1102 462572421 125 648058271 912 811525746 510 21279658 1585 770308498 1714 647590801 836 747072729 456 196312434 1193 273826123 542 550214580 1572 19411733 83 830022051 406 32894333 141 253674785 307 714271487 725 907001902 1401 192197276 235 370848499 304 860076730 93 318344909 121 617668400 1928 367853144 38 873271913 80 876674467 133 305928521 483 493592612 1212 507084488 447 643398157 604 727615038 933 795617530 992 389894597 311 193293403 1823 766679027 783 539776973 1551 242828668 348 727642243 1540 42466036 825 913872867 1384 260594353 1387 304693037 584 850056399 1160 762175574 1433 730297677 558 876049907 1414 690666068 1879 759722577 807 120328856 1671 504166817 479 813371863 1935 865524560 1170 731300223 1522 322173045 1361 452860268 96 503799652 980 892680399 1508 371333216 83 247110954 583 688798060 1376 108733303 1840 605325634 1124 698703209 1065 537951069 1189 498602186 1678 57838656 1299 3756212 923 34340745 1194 769454115 386 639017693 1701 945679442 317 17590096 878 30927710 878 353382999 1215 46854982 1564 562935092 252 513082982 398 524446970 1583 527069582 1875 273900348 287 542177727 1951 166205270 346 810730369 1936 236107729 1267 41204863 1706 507683411 1521 61132817 255 315444161 1739 204515533 1483 63187953 616 29078616 729 249329638 236 793178907 717 516647500 1799 861242225 522 571409374 560 997830564 1329 926289692 1604 204636224 1480 534560088 1758 651316956 1353 730144849 1510 615026759 814 722191217 1200 431786321 101 700995232 1029 293224499 19 530500803 1247 72470172 1253 838023637 909 538616921 289 116931744 1798 960095903 875 763347479 747 970072056 1523 757063763 709 480404169 1804 51692840 894 552907900 952 81305188 1627 724546239 867 642651911 758 658393454 418 647838699 1329 695934331 334 864170745 310 921822231 744 522589095 555 508852301 216 75721209 212 635667114 424 792676591 633 736158206 480 492866067 743 882653443 741 260168738 182 643219153 519 621092979 1670 419613764 541 936777188 1259 646309454 414 393571648 1194 653919271 459 203231873 1857 332852646 390 275706928 1465 394936894 1463 43229160 441 623960664 1123 585015230 1403 450840204 1570 685332027 584 917406793 581 62085587 1807 634477797 1524 400732672 401 994895172 752 833110523 552 74237988 1767 746528023 568 373238532 1109 768222906 1038 921884591 263 807632888 1413 934322793 540 364909773 631 827914932 1364 696105719 1184 235138239 650 138527854 527 845922668 926 503711617 998 10073341 1819 808005263 608 99427930 487 526598494 130 323372801 1897 878444571 1242 438865290 116 622270447 756 198336214 98 970649914 492 768178644 1996 820796782 541 682820591 805 559672971 1432 722766360 935 729624626 1120 607481963 133 696646760 1362 918905984 31 531558890 1187 527249489 244 515977256 1681 393618066 1039 483818267 1155 968941656 486 77896973 206 863325021 1748 679521795 1788 702137818 1820 248513630 1178 602107346 407 730590933 964 479068530 45 300675235 1963 113300882 1839 565827806 424 303853147 1587 870752488 1389 250711556 1629 300417022 132 402964405 103 714621422 391 388330124 317 739912933 1019 756827287 1542 627027155 228 888517463 1610 764499734 719 115066166 559 839636741 273 774651497 1530 128114947 163 65813938 845 332961294 269 936625345 637 141360554 928 131018723 1474 639290332 797 256262873 990 710604114 1984 554227395 1767 120665504 748 647059771 1043 857927589 1492 700108415 1871 978758668 675 845305030 476 157633518 1017 425458355 1174 656272789 899 293283559 658 660519702 1121 257851140 786 690854439 592 710142459 269 16043674 122 160141625 906 963935845 1221 497265490 1491 780320032 386 491458448 1098 25306715 1417 200484065 530 781905200 734 163827699 773 916393592 959 138088764 1963 934218177 977 489352945 705 112428116 290 14640809 1149 858072803 728 558045233 808 45689435 1956 931465029 339 153913142 131 535959788 1752 356877660 177 791657069 1627 35395767 329 430216689 559 419306578 1847 172266679 613 357394476 1486 624023789 79 910572959 1717 203768114 1650 470255720 1051 80508326 778 575365714 796 683168426 1015 794147716 156 170600761 1846 154499427 1393 764773602 1162 872403493 909 989581017 1876 89435208 393 49365178 892 652760497 1245 219194255 570 940465928 812 923648189 682 620918998 1405 737949548 1375 133274784 609 334018031 1689 496798167 86 387086249 996 302588110 913 155117981 110 95371095 1270 600925074 182 914925817 346 139266527 944 864633551 400 383514584 1509 634553600 496 780255957 7 557224310 1515 870035233 1997 625073254 1866 815475325 1243 96670333 1635 191620614 418 301930771 576 214343398 1164 476065632 709 234912873 1405 795423758 1677 59213788 1116 343093295 154 412633581 1745 774076325 230 411582650 1289 543486933 679 748562325 793 305668842 189 682948382 1539 209347303 1405 675106339 283 389412310 1732 450526685 498 619332586 1917 279117756 664 678409836 1125 827982918 1261 731956387 1683 196849697 1820 798939542 1433 265347469 1043 677130174 1459 200607788 368 424267695 879 945649567 1784 262777367 1032 449510581 1507 273627182 1341 678348727 1097 185091656 1741 954539509 739 713384110 1763 989178338 1799 640180618 909 534975324 814 912808955 1863 143821834 1011 633921993 1199 643519242 1058 698795849 1563 85311930 35 155489518 1792 7188984 1010 460000755 145 162936680 612 164036359 869 917124332 1001 241634189 1276 827815643 492 600246107 950 4590467 647 173844273 1202 632139886 159 389858473 1481 421194924 1399 79433183 1623 50936394 627 719767852 216 474752735 1482 463791373 1308 675192132 1606 440863778 1430 20553315 1340 122607955 1671 297068328 418 631348749 529 650547093 1042 822573259 1378 837157930 671 724007056 497 196012508 302 707627396 944 889497753 44 384384629 1591 897474133 1709 656727497 641 502622327 635 1715546 551 33674304 1894 874885099 1512 717583317 661 117412421 261 154683370 714 758191090 328 724672525 1412 232895381 677 442614157 1854 433779940 137 745126149 565 962887236 1263 55615112 1863 946692095 609 719099498 1238 804974884 380 715236521 555 966618108 44 212633335 1832 563248676 1510 590912357 1750 392733772 1077 889959853 109 367405963 107 362410268 1378 595295836 73 140516122 506 744849721 1035 680888920 1005 226923730 234 635712148 598 202485738 1829 544116492 1575 287518415 1818 776161661 1561 307449460 1981 873112534 1696 549663020 603 363044478 717 221222149 841 584834879 1102 628823999 661 854917325 688 255277672 1678 382137591 36 731359381 144 674637161 1648 159940414 279 791964955 380 77001527 405 900696154 1308 635683143 734 391599473 1726 412258279 320 345575924 761 485819545 993 659802280 1558 698311393 896 638194194 570 702692580 478 978596763 209 903216028 741 340655964 1415 480928438 902 848264332 879 706036233 1137 931268227 551 267553970 1821 719086186 82 142897616 648 136524674 933 856496345 1368 322824205 1150 644316055 1791 628777085 691 716694157 1686 402811143 1948 70990527 66 620588911 580 574759350 1282 16667125 792 476704931 1484 879726267 1833 520899117 405 141213746 1180 324943013 1100 383746964 1162 751603537 1521 83829130 1492 263558944 1901 391197208 1776
样例输出
40615184393