id
stringlengths
14
117
description
stringlengths
29
13k
code
stringlengths
10
49.8k
test_samples
sequence
source
class label
3 classes
prompt
stringlengths
391
104k
328_B. Sheldon and Ice Pieces_38253
Do you remember how Kai constructed the word "eternity" using pieces of ice as components? Little Sheldon plays with pieces of ice, each piece has exactly one digit between 0 and 9. He wants to construct his favourite number t. He realized that digits 6 and 9 are very similar, so he can rotate piece of ice with 6 to use as 9 (and vice versa). Similary, 2 and 5 work the same. There is no other pair of digits with similar effect. He called this effect "Digital Mimicry". Sheldon favourite number is t. He wants to have as many instances of t as possible. How many instances he can construct using the given sequence of ice pieces. He can use any piece at most once. Input The first line contains integer t (1 ≤ t ≤ 10000). The second line contains the sequence of digits on the pieces. The length of line is equal to the number of pieces and between 1 and 200, inclusive. It contains digits between 0 and 9. Output Print the required number of instances. Examples Input 42 23454 Output 2 Input 169 12118999 Output 1 Note This problem contains very weak pretests.
def c(a, b): a = a.replace('6', '9') a = a.replace('2', '5') b = b.replace('6', '9') b = b.replace('2', '5') n = 10000 for i in '01345789': t = a.count(i) if t != 0: n = min(n, b.count(i)//t) return n a = input() b = input() print(c(a, b))
{ "input": [ "42\n23454\n", "169\n12118999\n", "5518\n9827108589585181118358352282425981568508825302611217254345831149357236227288533838583629451589201341265988858338548185158221291825821019993179835186961954871454\n", "533\n355233333332\n", "9\n666969\n", "2559\n5252555622565626\n", "2569\n9592525295556669222269569596622566529699\n", "11\n1\n", "9697\n76694996266995167659667796999669903799299696697971977966766996767667996967697669766777697969669669297966667776967677699767966667666769699790768276666766\n", "2559\n52555995269265555695922255525995255259555259252562655622526292929555265526255252526255555296956995596262965522222225655655262255226222259622295225295525265995566255556225522559559295225625559595222652\n", "5\n2\n", "555\n225225252222255\n", "33\n33333333\n", "25\n52\n", "100\n11111000000000001010110010101100011011110101000000000001100110007111110010100000011000010011000011000010010000111101000010000000801000100111000410010100100000001011000000000101100010110001001100010001\n", "266\n26266956652996996666662666992669966292555295699956956255562529696222966929669665256625596629565696225696662556996969659952659665522965269529566599526566699292225569566599656596562966965669929996226599\n", "9697\n979966799976\n", "18\n8118\n", "7\n777\n", "2569\n2569256925692569256925692569256925692569\n", "6\n9669969\n", "1\n1\n", "5518\n22882121\n", "2591\n5291\n", "1780\n8170880870810081711018110878070777078711\n", "22\n25552222222255\n", "5\n22252\n", "555\n25225222525252252255252525552255255522522522225252252525225555225552525255255252252225225255225552522252552252252522555255522225555252255555222225252525522252252255522522225252255522525552525225522552\n", "9\n99669996666966699999666999999666999699966669696969999696666669696967969666969696696696699669696999669669966696699666669996696666996699999696666696996666666969996996696696969666999999996666699966996696\n", "2\n5255\n", "22\n35354953025524221524235223225255512262254275553262592555522123522225045753552560550228255220622552552252517202252456715552032250226729355222227262525262552362252277292927052612301558753527582221622055\n", "52\n222222222222222\n", "99\n966969969696699969\n", "266\n565596629695965699\n", "2569\n09629965966225566262579565696595696954525955599926383255926955906666526913925296256629966292216925259225261263256229509529259756291959568892569599592218262625256926619266669279659295979299556965525222\n", "2591\n95195222396509125191259289255559161259521226176117\n", "9\n1178263\n", "2569\n12687990117657438775903332794212730347567\n", "9697\n126972072629057708380892077150586442702211079062622768297593630827097408755879669047000363344790409627751632102489460658059082365856765058433321796883434\n", "2559\n47586110869884297571181627810326188098267146037437994407647985995641052619326459527860368682268999054656294528136045716076587499539162106236898410199122194714268150137703293440784412716256983740127401\n", "266\n33078609529900981760806663496065705573537646989453663576760358103283660581437036731534240930507539795698970669471687852051836909461663584282848874393996875823647997166687422813409128500544828043896898\n", "1780\n1943608316423166319989074672999617645627\n", "555\n26116679321621886824225122316132204276055583923033131705570376492493124462565943546202097037799509292338340532492323959449103366043457102359559674982979069857300578460734259940492532955543486054737505\n", "9\n158688233798092460703535125410853542871810354045136991820211402212580627457582182580676981602929173714976711430400026565923483963770124037786590287560731905903867456067909100166900536197831119800810139\n", "22\n34976017947206371815775023229448382718181798943559886241613101952824542410662326283086225707573595164417068469606887398689158155107574624046095059568907593880969963022214754432833047930406077155608610\n", "99\n667764860664399730\n", "2569\n22260214657964421826321347467902804799829\n", "9697\n247413139714774869116810249639616212175638729704813549093523689360958801747422633912055720318725487858436408507797037967471004106743888137624176513338600\n", "2559\n94119935392617103050285912498380272459376573672999325734793242170027028840948875496473208999441341790962313785611542206222397355863581540092066757222793769942122846647660934138761290583990188854841009\n", "100\n37733549349126025727821227839900385006476032813696108316948761119397979111203493210570333334735946613365664785885029198270498566479571226733995954920599928857461753588507814971253815472804331564393494\n", "555\n9649494242966005701063126970126036467670242151045444987652434056160373299303771384051965786320871923368930269460224254278969901288349978135596762962075535790066431370231107755237027589107834348854058\n", "9\n143287287099411514941567198878779210274203095846103518420710076606730587422114269061470031477912984526415183331565530814031268539448423481991241736455384984349367588434520037245927542056958451318349237\n", "22\n7057027738611223497118880229082224245277193083249154115971198752733146806146713110707102350698830100819124913803606810033230991242755393689637199563206798778888431840460319927695454133558294437767790\n", "2559\n27451748028827002824527350033566573764525264144653313875689870376473093473726912794999998034743118014394520024438085225175988326504841356016178844795695402690543199213493523961431987034294074613198039\n", "9\n105117322917603332719876764078347680190661101095029308205585563645909525149454753787229638368128993506850948431386367806226621632958281248832910268525369055851986901113625051509519192863816000026976400\n", "22\n2256095964918082754782808885949050608951711724476270154824672696341270387418433790338325889690420387829672313645612147418105380904054522467635301465889261585227563089985954917894148938495059999421935\n", "266\n30025007243647050225764458686858354661283246567225509752261111699041868771868081213653969869249825308736032340695194971954308527015682596296663634759616597814926717624844673825583027817111684294907403\n", "555\n17001180100283959638851109492216927026457332397368952105718593515880823214582024157633315080945251303057106313753963615551462997570345800561287433098800745392712002454490436896409084604945575236209424\n", "9\n93517522835973416023478148119027841968283443921373754072940142266392240509172234215901983698371530797202993995411786088350221069734993133966834762461597982133951661304205585829761967061775872753750720\n", "22\n3958429471478430203587105749705398909513801482260856716310824465496156135435384879740032621803826752009303041050941980922699572170003783989558804866583171467039092420377616357104313028301628154509375\n", "9697\n948006532706505316467811625520457266460863733957063621861114036775046687252027714345852068911730337522361863222178640459410142107474109921448030873402767\n", "266\n34832616781632517042690485424471570246064157764459539358284485155981163836773029941189368175532477684009524191729583166839671514607567374096399379017566905727467793578092544385866745792519077531063459\n", "2559\n4149523190371965\n", "555\n186877331227356\n", "33\n31744823\n", "100\n19673053386549103186424939846568403930976116396229344851170078661846053921022524093640765056619960669129090332556641872373816457296432361743236341057248039747183021359953617850800893926013867246094357\n", "7\n769\n", "2569\n813449578351217387329427215789180120828\n", "6\n11601471\n", "52\n274605947877978\n", "266\n1097954168113261071\n", "2569\n4750742951628955517803990592584845318248130141734342365903452277985034983294858240213621295210870412745597143149488923403701787079691815361196138269899320924183396391997422632247174848441160643043384\n", "2591\n161523230274458492695824859901482848294309607823643\n", "555\n305895097942266\n", "266\n18481938613945544307623852243973719712551622624582898560718475000698244154411186368475300479960247371502772614839190284946594855353675889751151288648022169487229216579842137575282765651627366687439994\n", "7\n878\n", "2569\n1067600690286262853981364329703830514593\n", "52\n371476509783622\n", "99\n556997207023072934\n", "266\n1662600278409124562\n", "2569\n2416151626462923093531839114691039408440860342521471792807993457247056040244670225116790005941397366383677562574420993306548049214191444322755766893692116120495928518598213080035152807249618127706847\n", "2591\n7011719356990851756081497633620817703758179571369\n", "2569\n19704272278315158220329258732594469611045\n", "9697\n484991028961821055656024564110911422590957008096700674343204686263681185104322823301858372246787707207202874352243565952549629176166053375241280518724162\n", "555\n372502796203578\n", "100\n18327191800779544561854546996812601764886503886219342235714597696296170672241686628981845161136686014097112115953799165576648544047492033749190020171962479642280459351489729156194953503361257214910299\n", "266\n17379069325322549087615738691300377745367538847554147360977384212319546006103206758063253735617492116309589360163879888901867387660812205078433589509346631570063740450067676810855878939039532390949214\n", "2569\n1075759078832178993597823899179655800102\n", "555\n8554217035112627926773496974032355057552875531802619880278708280280086574325084412680871423512446303228145507989901011771213370920220307969930334768415468576820528495281414708147992229368775050969423\n", "99\n892653766004310406\n", "266\n2383786323909673311\n", "2569\n1711184056492879129935672561157729620729718765248182190327186766476115695244633663206294866237154163141364100660203338539436786216107275505105098825324630016863304828151937157052896652624247347964749\n", "2591\n201846284115134330742335888783907885353814777508\n", "2569\n8120683179672563401528366258473652935664\n", "9697\n665944826673784175923222754867545275212350997889924256667703391060493977725164943553891539933644078310874816186071369786112779869600881851751832768144900\n", "2559\n31508987523936867798413132700552802675051155133800499597415232268298217113360759698738604155174800719638747756848961331125698996603065378573778868126454676249283218675391306859758622997550194097995283\n", "555\n563460514965477\n", "100\n18373776256712967920744434880633665580054812643356496072936047524778113821777954843770928711160520592166826127157380437624750789317571533746226884877110863202696307606297122117987160760320355152847338\n", "2569\n56177594686745803266824815523416346622\n", "99\n1608914419940428454\n", "266\n1930754734632739640\n", "2569\n809047830812802542955131155921739844972251035577351768741391193362372478191570154055382370950340575677026880340898662798612982136706507057869876228698414279877649208408649612748808330118032289942807\n", "2591\n39736573870923756503382373513965484779223640000\n", "2569\n10116663615622734590429000235327649978477\n", "2559\n19929582732058876275953866789324547518680119116717678839185404102942186643708721832184166538045491601352731000758412727290435513754575481501414983891280874381032094412160911411860412611204713430529201\n", "555\n125610656001956\n", "100\n26367732229739425460445971632773112729408718006768586492049547578606069214049029836638885313215959887013035165910417558175235721471159274899102631400305219834204687998386050390592489726568787483647097\n" ], "output": [ "2\n", "1\n", "23\n", "4\n", "6\n", "4\n", "10\n", "0\n", "34\n", "48\n", "1\n", "5\n", "4\n", "1\n", "63\n", "62\n", "3\n", "2\n", "3\n", "10\n", "7\n", "1\n", "2\n", "1\n", "10\n", "7\n", "5\n", "66\n", "199\n", "4\n", "66\n", "7\n", "9\n", "6\n", "44\n", "10\n", "1\n", "3\n", "10\n", "11\n", "26\n", "2\n", "17\n", "38\n", "20\n", "4\n", "5\n", "9\n", "14\n", "7\n", "13\n", "30\n", "16\n", "12\n", "46\n", "21\n", "23\n", "15\n", "41\n", "18\n", "8\n", "22\n", "1\n", "1\n", "1\n", "11\n", "1\n", "1\n", "1\n", "1\n", "2\n", "17\n", "3\n", "1\n", "20\n", "1\n", "3\n", "1\n", "2\n", "2\n", "20\n", "3\n", "3\n", "9\n", "1\n", "7\n", "20\n", "4\n", "16\n", "2\n", "2\n", "20\n", "2\n", "5\n", "11\n", "13\n", "1\n", "9\n", "4\n", "2\n", "2\n", "17\n", "1\n", "4\n", "12\n", "1\n", "10\n" ] }
2CODEFORCES
Below is a problem description that describes the problem. Write code in Python that appropriately solves the problem. ### Description: Do you remember how Kai constructed the word "eternity" using pieces of ice as components? Little Sheldon plays with pieces of ice, each piece has exactly one digit between 0 and 9. He wants to construct his favourite number t. He realized that digits 6 and 9 are very similar, so he can rotate piece of ice with 6 to use as 9 (and vice versa). Similary, 2 and 5 work the same. There is no other pair of digits with similar effect. He called this effect "Digital Mimicry". Sheldon favourite number is t. He wants to have as many instances of t as possible. How many instances he can construct using the given sequence of ice pieces. He can use any piece at most once. Input The first line contains integer t (1 ≤ t ≤ 10000). The second line contains the sequence of digits on the pieces. The length of line is equal to the number of pieces and between 1 and 200, inclusive. It contains digits between 0 and 9. Output Print the required number of instances. Examples Input 42 23454 Output 2 Input 169 12118999 Output 1 Note This problem contains very weak pretests. ### Input: 42 23454 ### Output: 2 ### Input: 169 12118999 ### Output: 1 ### Code: def c(a, b): a = a.replace('6', '9') a = a.replace('2', '5') b = b.replace('6', '9') b = b.replace('2', '5') n = 10000 for i in '01345789': t = a.count(i) if t != 0: n = min(n, b.count(i)//t) return n a = input() b = input() print(c(a, b))
34_C. Page Numbers_38257
«Bersoft» company is working on a new version of its most popular text editor — Bord 2010. Bord, like many other text editors, should be able to print out multipage documents. A user keys a sequence of the document page numbers that he wants to print out (separates them with a comma, without spaces). Your task is to write a part of the program, responsible for «standardization» of this sequence. Your program gets the sequence, keyed by the user, as input. The program should output this sequence in format l1-r1,l2-r2,...,lk-rk, where ri + 1 < li + 1 for all i from 1 to k - 1, and li ≤ ri. The new sequence should contain all the page numbers, keyed by the user, and nothing else. If some page number appears in the input sequence several times, its appearances, starting from the second one, should be ignored. If for some element i from the new sequence li = ri, this element should be output as li, and not as «li - li». For example, sequence 1,2,3,1,1,2,6,6,2 should be output as 1-3,6. Input The only line contains the sequence, keyed by the user. The sequence contains at least one and at most 100 positive integer numbers. It's guaranteed, that this sequence consists of positive integer numbers, not exceeding 1000, separated with a comma, doesn't contain any other characters, apart from digits and commas, can't end with a comma, and the numbers don't contain leading zeroes. Also it doesn't start with a comma or contain more than one comma in a row. Output Output the sequence in the required format. Examples Input 1,2,3,1,1,2,6,6,2 Output 1-3,6 Input 3,2,1 Output 1-3 Input 30,20,10 Output 10,20,30
A=[int(num) for num in input().split(',')] s_a=sorted(set(A)) prev=None string="" count=0 for i in s_a: if prev is None: prev=i string+=str(prev) count+=1 else: if i-(prev+count)==0: count+=1 else: if count>1: string+='-'+str(prev+count-1)+','+str(i) else: string+=','+str(i) count=1 prev=i if count>1: string+='-'+str(prev+count-1) print(string)
{ "input": [ "30,20,10\n", "3,2,1\n", "1,2,3,1,1,2,6,6,2\n", "511,32\n", "684,698,429,694,956,812,594,170,937,764\n", "744,359,230,586,944,442\n", "37\n", "996,999,998,984,989,1000,996,993,1000,983,992,999,999,1000,979,992,987,1000,996,1000,1000,989,981,996,995,999,999,989,999,1000\n", "1000\n", "2\n", "93,27,28,4,5,78,59,24,19,134,31,128,118,36,90,32,32,1,44,32,33,13,31,10,12,25,38,50,25,12,4,22,28,53,48,83,4,25,57,31,71,24,8,7,28,86,23,80,101,58\n", "646,840,437,946,640,564,936,917,487,752,844,734,468,969,674,646,728,642,514,695\n", "4,24,6,1,15\n", "303,872,764,401\n", "48,108,63,21,27,8,49,21,75,8,24,42,149,18,8,28,21,18,25,35,59,70,59,33,40,1,67,34,120,82,4,115,72,87,3,15,15,63,37,12,40,27,83,14,38,20,14,58,93,10,31,3,39,6,197,77,54,16,31,146,9,49,14,8,77,82,5,11,80,116,8,61,50,24,7,103,29,11,3,3,1,12,46,24,21,131,39,29,36,2,107,40,16,99,31,41,29,48,17,17\n", "31,75,86,68,111,27,22,22,26,30,54,163,107,75,160,122,14,23,17,26,27,20,43,58,59,71,21,148,9,32,43,91,133,286,132,70,90,156,84,14,77,93,23,18,13,72,18,131,33,28,72,175,30,86,249,20,14,208,28,57,63,199,6,10,24,30,62,267,43,479,60,28,138,1,45,3,19,47,7,166,116,117,50,140,28,14,95,85,93,43,61,15,2,70,10,51,7,95,9,25\n", "1000,1000,1000,1000,1000,998,998,1000,1000,1000,1000,999,999,1000,1000,1000,999,1000,997,999,997,1000,999,998,1000,999,1000,1000,1000,999,1000,999,999,1000,1000,999,1000,999,1000,1000,998,1000,1000,1000,998,998,1000,1000,999,1000,1000,1000,1000,1000,1000,1000,998,1000,1000,1000,999,1000,1000,999,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,998,1000,1000,1000,998,1000,1000,998,1000,999,1000,1000,1000,1000\n", "896,898,967,979,973,709,961,968,806,967,896,967,826,975,936,903,986,856,851,931,852,971,786,837,949,978,686,936,952,909,965,749,908,916,943,973,983,975,939,886,964,928,960,976,907,788,994,773,949,871,947,980,945,985,726,981,887,943,907,990,931,874,840,867,948,951,961,904,888,901,976,967,994,921,828,970,972,722,755,970,860,855,914,869,714,899,969,978,898,862,642,939,904,936,819,934,884,983,955,964\n", "826,747,849,687,437\n", "907,452,355\n", "999\n", "4,4,21,6,5,3,13,2,6,1,3,4,1,3,1,9,11,1,6,17,4,5,20,4,1,9,5,11,3,4,14,1,3,3,1,4,3,5,27,1,1,2,10,7,11,4,19,7,11,6,11,13,3,1,10,7,2,1,16,1,9,4,29,13,2,12,14,2,21,1,9,8,26,12,12,5,2,14,7,8,8,8,9,4,12,2,6,6,7,16,8,14,2,10,20,15,3,7,4\n", "994,927,872,970,815,986,952,996,965,1000,877,986,978,999,950,990,936,997,993,960,921,860,895,869,943,998,983,968,973,953,999,990,995,871,853,979,973,963,953,938,997,989,993,964,960,973,946,975,1000,962,920,746,989,957,904,965,920,979,966,961,1000,993,975,952,846,971,991,979,985,969,984,973,956,1000,952,778,983,974,956,927,995,997,980,997,1000,970,960,970,988,983,947,904,935,972,1000,863,992,996,932,967\n", "713,572,318,890,577,657,646,146,373,783,392,229,455,871,20,593,573,336,26,381,280,916,907,732,820,713,111,840,570,446,184,711,481,399,788,647,492,15,40,530,549,506,719,782,126,20,778,996,712,761,9,74,812,418,488,175,103,585,900,3,604,521,109,513,145,708,990,361,682,827,791,22,596,780,596,385,450,643,158,496,876,975,319,783,654,895,891,361,397,81,682,899,347,623,809,557,435,279,513,438\n", "999,999,993,969,999\n", "1\n", "411,32\n", "684,699,429,694,956,812,594,170,937,764\n", "244,449,685,032,953,447\n", "19\n", "0001,999,989,999,999,599,699,189,989,0001,0001,699,0001,789,299,979,0001,999,999,299,389,0001,399,699,0001,989,489,899,999,699\n", "3\n", "596,415,246,827,646,476,969,864,437,448,257,784,719,639,465,046,649,734,048,646\n", "3,24,6,1,15\n", "31,75,86,78,111,27,22,22,26,30,54,163,107,75,160,122,14,23,17,26,27,20,43,58,59,71,21,148,9,32,43,91,133,286,132,70,90,156,84,14,77,93,23,18,13,72,18,131,33,28,72,175,30,86,249,20,14,208,28,57,63,199,6,10,24,30,62,267,43,479,60,28,138,1,45,3,19,47,7,166,116,117,50,140,28,14,95,85,93,43,61,15,2,70,10,51,7,95,9,25\n", "734,786,948,747,628\n", "907,352,355\n", "550\n", "4,4,21,6,5,3,13,2,6,1,3,4,1,3,1,9,11,1,6,17,4,5,20,4,1,9,6,11,3,4,14,1,3,3,1,4,3,5,27,1,1,2,10,7,11,4,19,7,11,6,11,13,3,1,10,7,2,1,16,1,9,4,29,13,2,12,14,2,21,1,9,8,26,12,12,5,2,14,7,8,8,8,9,4,12,2,6,6,7,16,8,14,2,10,20,15,3,7,4\n", "713,572,318,890,577,657,646,146,373,783,392,229,455,871,20,593,573,336,26,381,280,916,907,732,820,713,111,840,570,446,184,711,481,399,788,647,492,15,40,530,549,506,719,782,126,20,778,996,712,761,9,74,812,418,488,175,103,585,900,3,604,521,509,513,145,708,990,361,682,827,791,22,596,780,596,385,450,643,118,496,876,975,319,783,654,895,891,361,397,81,682,899,347,623,809,557,435,279,513,438\n", "999,999,983,969,999\n", "30,10,10\n", "114,32\n", "684,699,429,694,956,811,594,170,937,764\n", "244,449,685,032,953,457\n", "30\n", "0001,999,989,999,999,599,699,189,989,0001,0001,699,0001,789,299,979,0001,999,999,299,489,0001,399,699,0001,989,489,899,999,699\n", "566,415,246,827,646,476,969,864,437,448,257,784,719,939,465,046,649,734,048,646\n", "3,24,6,1,16\n", "553,253,709\n", "730\n", "01,01,03\n", "114,42\n", "684,699,429,694,856,911,594,170,937,764\n", "43\n", "0001,999,989,999,999,599,699,189,989,0001,0101,699,0001,789,299,979,0001,999,999,299,489,0001,399,699,0001,989,489,899,999,699\n", "566,415,246,824,646,476,969,864,437,448,257,784,719,939,465,046,649,737,048,646\n", "553,253,609\n", "01,01,13\n", "684,699,429,694,856,911,594,170,837,764\n", "78\n", "0001,999,989,999,999,699,699,189,989,0001,0101,699,0001,789,299,979,0001,999,999,299,489,0001,399,699,0001,989,489,899,999,699\n", "646,840,737,946,640,564,939,917,487,752,844,734,468,969,674,646,428,642,514,665\n", "553,252,609\n", "467,738,071,495,119,658,496,924,996,486\n", "85\n", "646,840,737,946,640,564,939,817,487,752,844,734,468,969,674,646,428,642,514,665\n", "555,232,609\n", "467,738,671,495,119,658,490,924,996,486\n", "99\n", "545,232,609\n", "467,738,672,495,119,658,490,924,996,486\n", "61\n", "906,232,545\n", "684,699,429,094,856,911,594,276,837,764\n", "93\n", "906,132,545\n", "49\n", "545,231,609\n", "97\n", "546,231,609\n", "511,31\n", "684,698,429,694,956,812,594,160,937,764\n", "744,359,234,586,940,442\n", "69\n", "646,840,437,946,640,564,936,917,587,752,844,734,468,969,674,646,728,642,514,695\n", "0001,0001,0001,0001,999,0001,899,0001,0001,899,0001,0001,0001,899,0001,0001,0001,0001,0001,0001,0001,0001,0001,0001,999,0001,0001,999,0001,0001,0001,899,0001,0001,0001,0001,0001,0001,0001,999,0001,0001,899,899,0001,0001,0001,899,0001,0001,999,0001,999,0001,0001,999,999,0001,999,0001,0001,0001,999,0001,899,999,0001,799,999,799,0001,999,0001,0001,0001,999,999,0001,0001,0001,0001,899,899,0001,0001,0001,0001,0001\n", "469,559,389,488,439,918,639,409,939,246,268,898,879,969,998,417,968,419,558,068,079,557,227,279,079,828,129,499,769,679,109,888,409,169,159,849,768,048,478,139,099,709,349,788,189,627,589,549,089,749,178,949,377,499,887,709,679,069,829,469,688,939,579,389,379,349,619,809,947,569,909,259,639,686,879,949,738,687,179,258,139,158,658,689,309,639,579,628,769,698,769,608,869,169,907,379,979,769,898,698\n", "907,453,355\n", "994,927,872,970,815,986,952,996,965,1000,877,986,978,999,950,990,936,997,993,960,920,860,895,869,943,998,983,968,973,953,999,990,995,871,853,979,973,963,953,938,997,989,993,964,960,973,946,975,1000,962,920,746,989,957,904,965,920,979,966,961,1000,993,975,952,846,971,991,979,985,969,984,973,956,1000,952,778,983,974,956,927,995,997,980,997,1000,970,960,970,988,983,947,904,935,972,1000,863,992,996,932,967\n", "999,989,993,969,999\n", "01,02,03\n", "410,32\n", "684,699,429,694,956,812,594,070,937,764\n", "744,359,230,576,944,442\n", "5\n", "7\n", "598,415,246,827,646,476,969,864,437,448,257,764,719,639,465,046,649,734,048,646\n", "51,1,6,42,3\n", "826,747,849,786,437\n", "907,342,355\n", "500\n", "4,4,21,6,5,3,13,2,6,1,3,4,1,3,1,9,11,1,6,17,4,5,20,4,1,9,6,11,3,4,14,1,3,3,1,4,3,5,27,1,1,2,10,7,11,4,19,7,11,6,11,13,3,1,10,7,2,1,16,1,9,4,29,13,2,12,24,2,21,1,9,8,26,12,12,5,2,14,7,8,8,8,9,4,12,2,6,6,7,16,8,14,2,10,20,15,3,7,4\n", "996,999,983,999,999\n", "114,24\n", "244,449,686,032,953,457\n", "54\n", "566,415,246,827,646,476,969,864,437,448,257,784,719,939,465,046,649,734,048,746\n", "3,14,6,1,16\n", "557,253,309\n", "419\n", "01,11,03\n", "684,699,429,694,856,911,594,270,937,764\n", "22\n", "0001,999,989,999,999,599,699,189,988,0001,0101,699,0001,789,299,979,0001,999,999,299,489,0001,399,699,0001,989,489,899,999,699\n", "966,415,246,824,646,476,969,864,437,448,257,784,719,939,465,046,645,737,048,646\n", "684,699,429,694,855,911,594,170,837,764\n", "104\n", "553,252,690\n", "684,699,429,694,856,911,594,170,837,763\n", "36\n", "566,415,246,824,646,476,969,864,437,448,257,784,718,939,465,046,649,737,048,646\n", "555,230,629\n", "684,699,429,094,856,911,594,176,837,764\n", "84\n", "906,032,545\n" ], "output": [ "10,20,30", "1-3", "1-3,6", "32,511", "170,429,594,684,694,698,764,812,937,956", "230,359,442,586,744,944", "37", "979,981,983-984,987,989,992-993,995-996,998-1000", "1000", "2", "1,4-5,7-8,10,12-13,19,22-25,27-28,31-33,36,38,44,48,50,53,57-59,71,78,80,83,86,90,93,101,118,128,134", "437,468,487,514,564,640,642,646,674,695,728,734,752,840,844,917,936,946,969", "1,4,6,15,24", "303,401,764,872", "1-12,14-18,20-21,24-25,27-29,31,33-42,46,48-50,54,58-59,61,63,67,70,72,75,77,80,82-83,87,93,99,103,107-108,115-116,120,131,146,149,197", "1-3,6-7,9-10,13-15,17-28,30-33,43,45,47,50-51,54,57-63,68,70-72,75,77,84-86,90-91,93,95,107,111,116-117,122,131-133,138,140,148,156,160,163,166,175,199,208,249,267,286,479", "997-1000", "642,686,709,714,722,726,749,755,773,786,788,806,819,826,828,837,840,851-852,855-856,860,862,867,869,871,874,884,886-888,896,898-899,901,903-904,907-909,914,916,921,928,931,934,936,939,943,945,947-949,951-952,955,960-961,964-965,967-973,975-976,978-981,983,985-986,990,994", "437,687,747,826,849", "355,452,907", "999", "1-17,19-21,26-27,29", "746,778,815,846,853,860,863,869,871-872,877,895,904,920-921,927,932,935-936,938,943,946-947,950,952-953,956-957,960-975,978-980,983-986,988-1000", "3,9,15,20,22,26,40,74,81,103,109,111,126,145-146,158,175,184,229,279-280,318-319,336,347,361,373,381,385,392,397,399,418,435,438,446,450,455,481,488,492,496,506,513,521,530,549,557,570,572-573,577,585,593,596,604,623,643,646-647,654,657,682,708,711-713,719,732,761,778,780,782-783,788,791,809,812,820,827,840,871,876,890-891,895,899-900,907,916,975,990,996", "969,993,999", "1", "32,411\n", "170,429,594,684,694,699,764,812,937,956\n", "32,244,447,449,685,953\n", "19\n", "1,189,299,389,399,489,599,699,789,899,979,989,999\n", "3\n", "46,48,246,257,415,437,448,465,476,596,639,646,649,719,734,784,827,864,969\n", "1,3,6,15,24\n", "1-3,6-7,9-10,13-15,17-28,30-33,43,45,47,50-51,54,57-63,70-72,75,77-78,84-86,90-91,93,95,107,111,116-117,122,131-133,138,140,148,156,160,163,166,175,199,208,249,267,286,479\n", "628,734,747,786,948\n", "352,355,907\n", "550\n", "1-17,19-21,26-27,29\n", "3,9,15,20,22,26,40,74,81,103,111,118,126,145-146,175,184,229,279-280,318-319,336,347,361,373,381,385,392,397,399,418,435,438,446,450,455,481,488,492,496,506,509,513,521,530,549,557,570,572-573,577,585,593,596,604,623,643,646-647,654,657,682,708,711-713,719,732,761,778,780,782-783,788,791,809,812,820,827,840,871,876,890-891,895,899-900,907,916,975,990,996\n", "969,983,999\n", "10,30\n", "32,114\n", "170,429,594,684,694,699,764,811,937,956\n", "32,244,449,457,685,953\n", "30\n", "1,189,299,399,489,599,699,789,899,979,989,999\n", "46,48,246,257,415,437,448,465,476,566,646,649,719,734,784,827,864,939,969\n", "1,3,6,16,24\n", "253,553,709\n", "730\n", "1,3\n", "42,114\n", "170,429,594,684,694,699,764,856,911,937\n", "43\n", "1,101,189,299,399,489,599,699,789,899,979,989,999\n", "46,48,246,257,415,437,448,465,476,566,646,649,719,737,784,824,864,939,969\n", "253,553,609\n", "1,13\n", "170,429,594,684,694,699,764,837,856,911\n", "78\n", "1,101,189,299,399,489,699,789,899,979,989,999\n", "428,468,487,514,564,640,642,646,665,674,734,737,752,840,844,917,939,946,969\n", "252,553,609\n", "71,119,467,486,495-496,658,738,924,996\n", "85\n", "428,468,487,514,564,640,642,646,665,674,734,737,752,817,840,844,939,946,969\n", "232,555,609\n", "119,467,486,490,495,658,671,738,924,996\n", "99\n", "232,545,609\n", "119,467,486,490,495,658,672,738,924,996\n", "61\n", "232,545,906\n", "94,276,429,594,684,699,764,837,856,911\n", "93\n", "132,545,906\n", "49\n", "231,545,609\n", "97\n", "231,546,609\n", "31,511\n", "160,429,594,684,694,698,764,812,937,956\n", "234,359,442,586,744,940\n", "69\n", "437,468,514,564,587,640,642,646,674,695,728,734,752,840,844,917,936,946,969\n", "1,799,899,999\n", "48,68-69,79,89,99,109,129,139,158-159,169,178-179,189,227,246,258-259,268,279,309,349,377,379,389,409,417,419,439,469,478,488,499,549,557-559,569,579,589,608,619,627-628,639,658,679,686-689,698,709,738,749,768-769,788,809,828-829,849,869,879,887-888,898,907,909,918,939,947,949,968-969,979,998\n", "355,453,907\n", "746,778,815,846,853,860,863,869,871-872,877,895,904,920,927,932,935-936,938,943,946-947,950,952-953,956-957,960-975,978-980,983-986,988-1000\n", "969,989,993,999\n", "1-3\n", "32,410\n", "70,429,594,684,694,699,764,812,937,956\n", "230,359,442,576,744,944\n", "5\n", "7\n", "46,48,246,257,415,437,448,465,476,598,639,646,649,719,734,764,827,864,969\n", "1,3,6,42,51\n", "437,747,786,826,849\n", "342,355,907\n", "500\n", "1-17,19-21,24,26-27,29\n", "983,996,999\n", "24,114\n", "32,244,449,457,686,953\n", "54\n", "46,48,246,257,415,437,448,465,476,566,646,649,719,734,746,784,827,864,939,969\n", "1,3,6,14,16\n", "253,309,557\n", "419\n", "1,3,11\n", "270,429,594,684,694,699,764,856,911,937\n", "22\n", "1,101,189,299,399,489,599,699,789,899,979,988-989,999\n", "46,48,246,257,415,437,448,465,476,645-646,719,737,784,824,864,939,966,969\n", "170,429,594,684,694,699,764,837,855,911\n", "104\n", "252,553,690\n", "170,429,594,684,694,699,763,837,856,911\n", "36\n", "46,48,246,257,415,437,448,465,476,566,646,649,718,737,784,824,864,939,969\n", "230,555,629\n", "94,176,429,594,684,699,764,837,856,911\n", "84\n", "32,545,906\n" ] }
2CODEFORCES
Below is a problem description that describes the problem. Write code in Python that appropriately solves the problem. ### Description: «Bersoft» company is working on a new version of its most popular text editor — Bord 2010. Bord, like many other text editors, should be able to print out multipage documents. A user keys a sequence of the document page numbers that he wants to print out (separates them with a comma, without spaces). Your task is to write a part of the program, responsible for «standardization» of this sequence. Your program gets the sequence, keyed by the user, as input. The program should output this sequence in format l1-r1,l2-r2,...,lk-rk, where ri + 1 < li + 1 for all i from 1 to k - 1, and li ≤ ri. The new sequence should contain all the page numbers, keyed by the user, and nothing else. If some page number appears in the input sequence several times, its appearances, starting from the second one, should be ignored. If for some element i from the new sequence li = ri, this element should be output as li, and not as «li - li». For example, sequence 1,2,3,1,1,2,6,6,2 should be output as 1-3,6. Input The only line contains the sequence, keyed by the user. The sequence contains at least one and at most 100 positive integer numbers. It's guaranteed, that this sequence consists of positive integer numbers, not exceeding 1000, separated with a comma, doesn't contain any other characters, apart from digits and commas, can't end with a comma, and the numbers don't contain leading zeroes. Also it doesn't start with a comma or contain more than one comma in a row. Output Output the sequence in the required format. Examples Input 1,2,3,1,1,2,6,6,2 Output 1-3,6 Input 3,2,1 Output 1-3 Input 30,20,10 Output 10,20,30 ### Input: 30,20,10 ### Output: 10,20,30 ### Input: 3,2,1 ### Output: 1-3 ### Code: A=[int(num) for num in input().split(',')] s_a=sorted(set(A)) prev=None string="" count=0 for i in s_a: if prev is None: prev=i string+=str(prev) count+=1 else: if i-(prev+count)==0: count+=1 else: if count>1: string+='-'+str(prev+count-1)+','+str(i) else: string+=','+str(i) count=1 prev=i if count>1: string+='-'+str(prev+count-1) print(string)
396_A. On Number of Decompositions into Multipliers_38263
You are given an integer m as a product of integers a1, a2, ... an <image>. Your task is to find the number of distinct decompositions of number m into the product of n ordered positive integers. Decomposition into n products, given in the input, must also be considered in the answer. As the answer can be very large, print it modulo 1000000007 (109 + 7). Input The first line contains positive integer n (1 ≤ n ≤ 500). The second line contains space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109). Output In a single line print a single number k — the number of distinct decompositions of number m into n ordered multipliers modulo 1000000007 (109 + 7). Examples Input 1 15 Output 1 Input 3 1 1 2 Output 3 Input 2 5 7 Output 4 Note In the second sample, the get a decomposition of number 2, you need any one number out of three to equal 2, and the rest to equal 1. In the third sample, the possible ways of decomposing into ordered multipliers are [7,5], [5,7], [1,35], [35,1]. A decomposition of positive integer m into n ordered multipliers is a cortege of positive integers b = {b1, b2, ... bn} such that <image>. Two decompositions b and c are considered different, if there exists index i such that bi ≠ ci.
# Made By Mostafa_Khaled bot = True Mod = 1000000007 MAX = 33000 n = int( input() ) A = list( map( int, input().split() ) ) B = [0] * MAX bePrime = [0] * MAX; primNum = [] C = [] fac=[1] for j in range(1, MAX): fac.append( fac[-1] * j % Mod ) def calc( M, N ): return fac[M] * pow( fac[N] * fac[M-N] % Mod, Mod-2,Mod ) % Mod for j in range(2, MAX): if bePrime[j] == 0: primNum.append( j ) i = j while i < MAX: bePrime[i] = 1 i = i + j for x in A: tmp = x for j in primNum: while tmp % j == 0: tmp /= j B[j] += 1 if tmp > 1: C.append( tmp ) ans = 1 for j in range(2,MAX): if B[j] > 0: ans = ans * calc( n + B[j] -1 , n - 1 ) % Mod l = len( C ) for j in range(0, l ): num= 0; for k in range(0, l ): if C[k] == C[j]: num = num + 1 if k > j: num = 0 break if num > 0: ans = ans * calc( n + num -1, n - 1 ) % Mod print( str( ans % Mod ) ) # Made By Mostafa_Khaled
{ "input": [ "1\n15\n", "3\n1 1 2\n", "2\n5 7\n", "3\n8 10 8\n", "1\n536870912\n", "1\n111546435\n", "10\n2097152 67108864 65536 262144 262144 131072 8388608 536870912 65536 2097152\n", "23\n77 12 25 7 44 75 80 92 49 77 56 93 59 45 45 39 86 83 99 91 4 70 83\n", "50\n675 25000 2025 50 450 31250 3750 225 1350 250 72 187500 12000 281250 187500 30000 45000 90000 90 1200 9000 56250 5760 270000 3125 3796875 2250 101250 40 2500 175781250 1250000 45000 2250 3000 31250 46875 135000 421875000 36000 360 140625000 13500 1406250 1125 250 75000 62500 150 6\n", "19\n371700317 12112039 167375713 7262011 21093827 89809099 600662303 18181979 9363547 30857731 58642669 111546435 645328247 5605027 38706809 14457349 25456133 44227723 33984931\n", "5\n387420489 536870912 536870912 536870912 387420489\n", "2\n1 2\n", "8\n836 13 77 218 743 530 404 741\n", "2\n5 10\n", "2\n1 6\n", "1\n1\n", "10\n6295 3400 4042 2769 3673 264 5932 4977 1776 5637\n", "5\n387420489 244140625 387420489 387420489 1\n", "20\n16777216 1048576 524288 8192 8192 524288 2097152 8388608 1048576 67108864 16777216 1048576 4096 8388608 134217728 67108864 1048576 536870912 67108864 67108864\n", "2\n536870912 387420489\n", "7\n111546435 58642669 600662303 167375713 371700317 33984931 89809099\n", "10\n214358881 536870912 815730721 387420489 893871739 244140625 282475249 594823321 148035889 410338673\n", "3\n1 1 1\n", "10\n237254761 1 817430153 1 1 1 1 1 90679621 1\n", "5\n14 67 15 28 21\n", "2\n1000000000 1000000000\n", "2\n999983 999983\n", "3\n1 30 1\n", "3\n1 1 39989\n", "3\n8 10 6\n", "1\n220265856\n", "10\n2097152 67108864 65536 262144 262144 131072 8388608 536870912 65536 1863321\n", "23\n77 12 25 7 44 75 80 92 49 151 56 93 59 45 45 39 86 83 99 91 4 70 83\n", "50\n675 25000 2025 83 450 31250 3750 225 1350 250 72 187500 12000 281250 187500 30000 45000 90000 90 1200 9000 56250 5760 270000 3125 3796875 2250 101250 40 2500 175781250 1250000 45000 2250 3000 31250 46875 135000 421875000 36000 360 140625000 13500 1406250 1125 250 75000 62500 150 6\n", "19\n371700317 12112039 167375713 7262011 21093827 89809099 600662303 18181979 9363547 41085159 58642669 111546435 645328247 5605027 38706809 14457349 25456133 44227723 33984931\n", "5\n387420489 536870912 536870912 207197421 387420489\n", "8\n1522 13 77 218 743 530 404 741\n", "2\n1 5\n", "10\n6295 3400 4042 4592 3673 264 5932 4977 1776 5637\n", "5\n387420489 345326591 387420489 387420489 1\n", "20\n16777216 25025 524288 8192 8192 524288 2097152 8388608 1048576 67108864 16777216 1048576 4096 8388608 134217728 67108864 1048576 536870912 67108864 67108864\n", "2\n921304979 387420489\n", "7\n111546435 58642669 600662303 167375713 371700317 37498469 89809099\n", "10\n214358881 536870912 815730721 387420489 893871739 244140625 282475249 310544439 148035889 410338673\n", "3\n1 2 1\n", "10\n237254761 1 817430153 1 1 1 2 1 90679621 1\n", "5\n13 67 15 28 21\n", "2\n1000000000 1000100000\n", "2\n241770 999983\n", "3\n1 49 1\n", "2\n2 7\n", "3\n8 10 9\n", "10\n2354079 67108864 65536 262144 262144 131072 8388608 536870912 65536 1863321\n", "23\n77 12 25 7 44 75 80 92 49 151 56 93 59 45 45 39 12 83 99 91 4 70 83\n", "50\n675 25000 2025 83 450 31250 3750 225 1350 250 72 187500 12000 281250 187500 30000 45000 90000 90 1200 9000 56250 5760 270000 3125 3796875 2250 101250 40 2500 175781250 1250000 45000 2250 3000 31250 46875 135000 643172839 36000 360 140625000 13500 1406250 1125 250 75000 62500 150 6\n", "19\n371700317 12112039 167375713 7262011 21093827 89809099 600662303 18181979 9363547 41085159 58642669 111546435 645328247 5605027 38706809 14457349 25456133 44227723 44827688\n", "5\n257161530 536870912 536870912 207197421 387420489\n", "8\n1522 13 77 218 743 530 404 342\n", "10\n6295 3400 4042 4592 3673 264 6967 4977 1776 5637\n", "5\n387420489 427918323 387420489 387420489 1\n", "20\n16777216 25025 524288 8192 2797 524288 2097152 8388608 1048576 67108864 16777216 1048576 4096 8388608 134217728 67108864 1048576 536870912 67108864 67108864\n", "2\n875069406 387420489\n", "7\n111546435 58642669 343378054 167375713 371700317 37498469 89809099\n", "10\n316079402 536870912 815730721 387420489 893871739 244140625 282475249 310544439 148035889 410338673\n", "5\n13 67 21 28 21\n", "2\n329497 999983\n", "3\n8 20 9\n", "10\n2354079 67108864 65536 262144 262144 250271 8388608 536870912 65536 1863321\n", "23\n77 12 25 7 44 75 80 92 49 151 56 93 59 45 18 39 12 83 99 91 4 70 83\n", "50\n675 25000 2025 83 450 31250 3750 225 1350 250 72 187500 12000 281250 187500 30000 45000 90000 90 1200 9000 56250 5760 270000 3125 3796875 2250 22959 40 2500 175781250 1250000 45000 2250 3000 31250 46875 135000 643172839 36000 360 140625000 13500 1406250 1125 250 75000 62500 150 6\n", "19\n371700317 12112039 167375713 7262011 21093827 89809099 812222065 18181979 9363547 41085159 58642669 111546435 645328247 5605027 38706809 14457349 25456133 44227723 44827688\n", "5\n257161530 536870912 909215645 207197421 387420489\n", "8\n1522 13 77 218 743 530 404 271\n", "2\n3 10\n", "10\n6295 5827 4042 4592 3673 264 6967 4977 1776 5637\n", "5\n332493834 427918323 387420489 387420489 1\n", "20\n16777216 25025 524288 8192 2797 524288 2097152 8388608 1048576 97108108 16777216 1048576 4096 8388608 134217728 67108864 1048576 536870912 67108864 67108864\n", "2\n859476554 387420489\n", "7\n111546435 58642669 343378054 190730883 371700317 37498469 89809099\n", "10\n238337238 536870912 815730721 387420489 893871739 244140625 282475249 310544439 148035889 410338673\n", "10\n237254761 1 817430153 2 1 1 1 1 28939360 1\n", "5\n13 126 21 28 21\n", "1\n190629401\n", "1\n243088005\n", "1\n251841745\n", "2\n1 10\n", "3\n2 2 1\n", "10\n237254761 1 817430153 2 1 1 1 1 90679621 1\n", "2\n2 10\n", "1\n381347381\n", "1\n436345080\n", "2\n329497 164785\n", "2\n2 12\n", "3\n8 20 7\n", "1\n634165685\n" ], "output": [ "1\n", "3\n", "4\n", "108\n", "1\n", "1\n", "176451954\n", "247701073\n", "18983788\n", "376284721\n", "255309592\n", "2\n", "544714485\n", "6\n", "4\n", "1\n", "928377494\n", "772171400\n", "985054761\n", "570\n", "25706464\n", "547239398\n", "1\n", "1000\n", "459375\n", "361\n", "3\n", "27\n", "3\n", "189\n", "1\n", "99140232\n", "485010245\n", "687306783\n", "314760312\n", "464813776\n", "526671590\n", "2\n", "493879649\n", "2121350\n", "869011558\n", "76\n", "408463052\n", "323437305\n", "3\n", "10000\n", "421875\n", "900\n", "32\n", "6\n", "4\n", "270\n", "143297218\n", "546379784\n", "285817182\n", "721141880\n", "960153565\n", "474455107\n", "277438869\n", "853361250\n", "627928287\n", "368\n", "593920734\n", "486503461\n", "196875\n", "16\n", "378\n", "506877987\n", "549495737\n", "753806527\n", "468320665\n", "889707577\n", "403518658\n", "8\n", "575485871\n", "246718715\n", "484562742\n", "152\n", "341203443\n", "549299384\n", "50050000\n", "857500\n", "1\n", "1\n", "1\n", "4\n", "6\n", "10000\n", "6\n", "1\n", "1\n", "32\n", "8\n", "189\n", "1\n" ] }
2CODEFORCES
Below is a problem description that describes the problem. Write code in Python that appropriately solves the problem. ### Description: You are given an integer m as a product of integers a1, a2, ... an <image>. Your task is to find the number of distinct decompositions of number m into the product of n ordered positive integers. Decomposition into n products, given in the input, must also be considered in the answer. As the answer can be very large, print it modulo 1000000007 (109 + 7). Input The first line contains positive integer n (1 ≤ n ≤ 500). The second line contains space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109). Output In a single line print a single number k — the number of distinct decompositions of number m into n ordered multipliers modulo 1000000007 (109 + 7). Examples Input 1 15 Output 1 Input 3 1 1 2 Output 3 Input 2 5 7 Output 4 Note In the second sample, the get a decomposition of number 2, you need any one number out of three to equal 2, and the rest to equal 1. In the third sample, the possible ways of decomposing into ordered multipliers are [7,5], [5,7], [1,35], [35,1]. A decomposition of positive integer m into n ordered multipliers is a cortege of positive integers b = {b1, b2, ... bn} such that <image>. Two decompositions b and c are considered different, if there exists index i such that bi ≠ ci. ### Input: 1 15 ### Output: 1 ### Input: 3 1 1 2 ### Output: 3 ### Code: # Made By Mostafa_Khaled bot = True Mod = 1000000007 MAX = 33000 n = int( input() ) A = list( map( int, input().split() ) ) B = [0] * MAX bePrime = [0] * MAX; primNum = [] C = [] fac=[1] for j in range(1, MAX): fac.append( fac[-1] * j % Mod ) def calc( M, N ): return fac[M] * pow( fac[N] * fac[M-N] % Mod, Mod-2,Mod ) % Mod for j in range(2, MAX): if bePrime[j] == 0: primNum.append( j ) i = j while i < MAX: bePrime[i] = 1 i = i + j for x in A: tmp = x for j in primNum: while tmp % j == 0: tmp /= j B[j] += 1 if tmp > 1: C.append( tmp ) ans = 1 for j in range(2,MAX): if B[j] > 0: ans = ans * calc( n + B[j] -1 , n - 1 ) % Mod l = len( C ) for j in range(0, l ): num= 0; for k in range(0, l ): if C[k] == C[j]: num = num + 1 if k > j: num = 0 break if num > 0: ans = ans * calc( n + num -1, n - 1 ) % Mod print( str( ans % Mod ) ) # Made By Mostafa_Khaled
444_E. DZY Loves Planting_38268
DZY loves planting, and he enjoys solving tree problems. DZY has a weighted tree (connected undirected graph without cycles) containing n nodes (they are numbered from 1 to n). He defines the function g(x, y) (1 ≤ x, y ≤ n) as the longest edge in the shortest path between nodes x and y. Specially g(z, z) = 0 for every z. For every integer sequence p1, p2, ..., pn (1 ≤ pi ≤ n), DZY defines f(p) as <image>. DZY wants to find such a sequence p that f(p) has maximum possible value. But there is one more restriction: the element j can appear in p at most xj times. Please, find the maximum possible f(p) under the described restrictions. Input The first line contains an integer n (1 ≤ n ≤ 3000). Each of the next n - 1 lines contains three integers ai, bi, ci (1 ≤ ai, bi ≤ n; 1 ≤ ci ≤ 10000), denoting an edge between ai and bi with length ci. It is guaranteed that these edges form a tree. Each of the next n lines describes an element of sequence x. The j-th line contains an integer xj (1 ≤ xj ≤ n). Output Print a single integer representing the answer. Examples Input 4 1 2 1 2 3 2 3 4 3 1 1 1 1 Output 2 Input 4 1 2 1 2 3 2 3 4 3 4 4 4 4 Output 3 Note In the first sample, one of the optimal p is [4, 3, 2, 1].
n = int(input()) edges = [[int(x) for x in input().split()] for i in range(n-1)] edges = sorted(edges) use_count = [0]+[int(input()) for i in range(n)] lo,hi = 0,10000 def getpar(par,u): if par[par[u]] == par[u]: return par[u] par[u] = getpar(par,par[u]) return par[u] def unite(par,sz,use,u,v): u = getpar(par,u) v = getpar(par,v) par[u] = v sz[v] += sz[u] use[v] += use[u] def solve(fp): par = [i for i in range(n+1)] sz = [1 for i in range(n+1)] use = [use_count[i] for i in range(n+1)] for edge in edges: if edge[2] < fp: unite(par,sz,use,edge[0],edge[1]) total_use = sum(use_count) for i in range(n+1): p = getpar(par,i) if(p == i): if(total_use - use[p] < sz[p]): return False return True while lo < hi: mid = (lo+hi+1)//2 if solve(mid): lo = mid else: hi = mid-1 print(lo)
{ "input": [ "4\n1 2 1\n2 3 2\n3 4 3\n1\n1\n1\n1\n", "4\n1 2 1\n2 3 2\n3 4 3\n4\n4\n4\n4\n", "1\n1\n", "10\n2 1 559\n3 1 5707\n4 2 9790\n5 3 1591\n6 1 7113\n7 6 2413\n8 6 3006\n9 4 1935\n10 6 5954\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n", "10\n2 1 8760\n3 1 3705\n4 1 1862\n5 2 7332\n6 3 7015\n7 5 4866\n8 3 4465\n9 7 8886\n10 3 9362\n2\n5\n5\n4\n4\n5\n4\n5\n1\n2\n", "2\n1 2 10000\n1\n1\n", "10\n1 6 4890\n2 6 2842\n3 6 7059\n4 6 3007\n5 6 6195\n7 6 3962\n8 6 3413\n9 6 7658\n10 6 8049\n3\n3\n3\n1\n4\n4\n5\n2\n1\n1\n", "10\n2 1 2464\n3 1 5760\n4 3 9957\n5 1 6517\n6 4 8309\n7 3 3176\n8 7 1982\n9 1 7312\n10 2 3154\n1\n1\n4\n1\n1\n3\n3\n5\n3\n2\n", "10\n2 1 3921\n3 2 3204\n4 3 1912\n5 4 6844\n6 5 8197\n7 6 7148\n8 7 5912\n9 8 104\n10 9 5881\n4\n4\n5\n2\n2\n4\n1\n2\n3\n1\n", "10\n1 2 5577\n3 2 6095\n4 2 4743\n5 2 2254\n6 2 9771\n7 2 7417\n8 2 9342\n9 2 2152\n10 2 5785\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n", "10\n2 1 5297\n3 2 7674\n4 1 1935\n5 2 1941\n6 3 1470\n7 1 3823\n8 2 4959\n9 4 6866\n10 9 2054\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n", "10\n2 1 6818\n3 2 9734\n4 3 2234\n5 4 3394\n6 5 1686\n7 6 3698\n8 7 700\n9 8 716\n10 9 1586\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n", "1\n2\n", "2\n1 2 10000\n2\n1\n", "10\n1 6 4890\n2 6 2842\n3 6 7059\n4 6 3007\n5 6 6195\n7 6 3962\n8 6 3413\n9 6 7658\n10 6 8049\n3\n3\n2\n1\n4\n4\n5\n2\n1\n1\n", "10\n2 1 2464\n3 1 5760\n4 3 9957\n5 1 6517\n6 4 8309\n7 2 3176\n8 7 1982\n9 1 7312\n10 2 3154\n1\n1\n4\n1\n1\n3\n3\n5\n3\n2\n", "10\n2 1 3921\n3 2 3204\n4 3 1912\n5 4 6844\n6 5 8197\n7 6 7148\n8 7 5912\n9 8 104\n10 9 5881\n6\n4\n5\n2\n2\n4\n1\n2\n3\n1\n", "10\n2 1 5297\n3 2 7674\n4 2 1935\n5 2 1941\n6 3 1470\n7 1 3823\n8 2 4959\n9 4 6866\n10 9 2054\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n", "10\n2 1 6915\n3 2 9734\n4 3 2234\n5 4 3394\n6 5 1686\n7 6 3698\n8 7 700\n9 8 716\n10 9 1586\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n", "4\n1 2 1\n2 3 2\n3 4 5\n1\n1\n1\n1\n", "4\n1 3 1\n2 3 2\n3 4 3\n4\n4\n4\n4\n", "10\n2 1 8760\n3 1 3705\n4 1 1862\n5 2 7332\n6 3 7015\n7 5 4866\n8 3 4465\n9 7 4213\n10 3 9362\n2\n5\n5\n4\n4\n5\n4\n5\n1\n2\n", "10\n1 3 5577\n3 2 6095\n4 2 4743\n5 2 2254\n6 2 9771\n7 2 7417\n8 2 9342\n9 2 2152\n10 2 5785\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n", "10\n1 10 4313\n2 6 2842\n3 6 7059\n4 6 3007\n5 6 6195\n7 6 3962\n8 6 3413\n9 6 7658\n10 6 8049\n3\n3\n2\n1\n4\n4\n5\n2\n1\n1\n", "1\n0\n", "10\n2 1 2464\n3 1 5760\n4 3 9957\n5 1 6517\n6 4 8309\n7 2 3176\n8 7 1982\n9 1 7312\n10 2 3154\n1\n1\n4\n1\n1\n3\n3\n5\n3\n4\n", "4\n1 3 1\n2 3 2\n3 4 3\n4\n5\n4\n4\n", "1\n-1\n", "1\n3\n", "10\n2 1 2464\n3 1 5760\n4 3 9957\n5 1 6517\n6 4 8309\n7 3 846\n8 7 1982\n9 1 7312\n10 2 3154\n1\n1\n4\n1\n1\n3\n3\n5\n3\n2\n", "10\n2 1 3921\n3 2 975\n4 3 1912\n5 4 6844\n6 5 8197\n7 6 7148\n8 7 5912\n9 8 104\n10 9 5881\n4\n4\n5\n2\n2\n4\n1\n2\n3\n1\n", "10\n2 1 5297\n3 2 7674\n4 1 420\n5 2 1941\n6 3 1470\n7 1 3823\n8 2 4959\n9 4 6866\n10 9 2054\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n", "10\n2 1 6818\n3 2 9734\n4 3 2234\n5 4 3394\n6 5 1686\n7 6 3698\n8 7 700\n9 8 716\n10 9 1586\n2\n1\n1\n1\n1\n1\n1\n1\n1\n1\n", "4\n1 4 1\n2 3 2\n3 4 3\n1\n1\n1\n1\n", "10\n1 6 4612\n2 6 2842\n3 6 7059\n4 6 3007\n5 6 6195\n7 6 3962\n8 6 3413\n9 6 7658\n10 6 8049\n3\n3\n2\n1\n4\n4\n5\n2\n1\n1\n", "10\n2 1 2464\n3 1 5760\n4 3 9957\n5 2 6517\n6 4 8309\n7 2 3176\n8 7 1982\n9 1 7312\n10 2 3154\n1\n1\n4\n1\n1\n3\n3\n5\n3\n2\n", "10\n2 1 3921\n3 2 3204\n4 3 2854\n5 4 6844\n6 5 8197\n7 6 7148\n8 7 5912\n9 8 104\n10 9 5881\n6\n4\n5\n2\n2\n4\n1\n2\n3\n1\n", "10\n2 1 6915\n3 2 9734\n4 3 2234\n5 4 364\n6 5 1686\n7 6 3698\n8 7 700\n9 8 716\n10 9 1586\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n", "4\n1 2 1\n2 3 2\n3 4 5\n1\n1\n2\n1\n", "4\n1 3 1\n2 3 2\n3 4 3\n4\n5\n6\n4\n", "1\n5\n", "10\n2 1 8760\n3 1 3705\n4 1 1862\n5 2 7332\n6 3 7015\n7 5 4866\n8 3 4465\n9 7 4213\n10 3 9362\n2\n5\n5\n4\n4\n2\n4\n5\n1\n2\n", "10\n2 1 2464\n3 1 5760\n4 3 9957\n5 1 6517\n6 4 8309\n7 3 846\n8 7 1982\n9 1 7312\n10 2 3154\n1\n1\n4\n1\n1\n3\n3\n5\n3\n3\n", "10\n1 3 9791\n3 2 6095\n4 2 4743\n5 2 2254\n6 2 9771\n7 2 7417\n8 2 9342\n9 2 2152\n10 2 5785\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n", "10\n2 1 5297\n3 2 7674\n4 1 420\n5 2 1941\n6 3 1515\n7 1 3823\n8 2 4959\n9 4 6866\n10 9 2054\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n", "4\n1 4 0\n2 3 2\n3 4 3\n1\n1\n1\n1\n", "10\n1 6 4313\n2 6 2842\n3 6 7059\n4 6 3007\n5 6 6195\n7 6 3962\n8 6 3413\n9 6 7658\n10 6 8049\n3\n3\n2\n1\n4\n4\n5\n2\n1\n1\n", "10\n2 1 2464\n3 1 5760\n4 3 9957\n5 2 6517\n6 4 8309\n7 2 3176\n8 7 1982\n9 1 7312\n10 2 3154\n0\n1\n4\n1\n1\n3\n3\n5\n3\n2\n", "10\n2 1 3921\n3 2 3204\n4 3 2854\n5 4 6844\n6 5 8197\n7 6 7148\n8 7 5912\n9 8 104\n10 9 5881\n1\n4\n5\n2\n2\n4\n1\n2\n3\n1\n", "4\n1 2 1\n2 3 2\n3 4 5\n1\n0\n2\n1\n", "1\n8\n", "10\n2 1 8760\n3 1 3705\n4 1 1862\n5 2 7332\n6 3 7015\n7 5 4866\n8 3 4465\n9 7 4213\n10 3 9362\n2\n5\n5\n4\n4\n2\n4\n7\n1\n2\n", "10\n2 1 2464\n3 1 5760\n4 3 9957\n5 1 6517\n6 4 5661\n7 3 846\n8 7 1982\n9 1 7312\n10 2 3154\n1\n1\n4\n1\n1\n3\n3\n5\n3\n3\n", "10\n2 1 2464\n3 1 5760\n4 3 9957\n5 2 6517\n6 4 8309\n7 2 3176\n8 7 1982\n9 1 7312\n10 2 3154\n0\n1\n4\n1\n1\n4\n3\n5\n3\n2\n", "10\n2 1 3921\n3 2 3204\n4 3 2854\n5 4 6844\n6 5 8197\n7 6 7148\n8 7 5912\n9 8 104\n10 9 5881\n1\n4\n5\n2\n2\n4\n1\n2\n3\n0\n", "10\n2 1 2464\n3 1 5760\n4 3 9957\n5 1 6517\n6 4 5661\n7 3 846\n8 7 1982\n9 1 7312\n10 2 3139\n1\n1\n4\n1\n1\n3\n3\n5\n3\n3\n", "10\n2 1 2464\n3 1 5760\n4 1 9957\n5 2 6517\n6 4 8309\n7 2 3176\n8 7 1982\n9 1 7312\n10 2 3154\n0\n1\n4\n1\n1\n4\n3\n5\n3\n2\n" ], "output": [ "2\n", "3\n", "0\n", "7113\n", "8760\n", "10000\n", "6195\n", "7312\n", "8197\n", "5785\n", "5297\n", "3698\n", "0\n", "10000\n", "6195\n", "7312\n", "8197\n", "5297\n", "3698\n", "2\n", "3\n", "8760\n", "6095\n", "7059\n", "0\n", "7312\n", "3\n", "0\n", "0\n", "7312\n", "8197\n", "5297\n", "3698\n", "3\n", "6195\n", "7312\n", "8197\n", "3698\n", "2\n", "3\n", "0\n", "8760\n", "7312\n", "6095\n", "5297\n", "3\n", "6195\n", "7312\n", "8197\n", "2\n", "0\n", "8760\n", "7312\n", "7312\n", "8197\n", "7312\n", "7312\n" ] }
2CODEFORCES
Below is a problem description that describes the problem. Write code in Python that appropriately solves the problem. ### Description: DZY loves planting, and he enjoys solving tree problems. DZY has a weighted tree (connected undirected graph without cycles) containing n nodes (they are numbered from 1 to n). He defines the function g(x, y) (1 ≤ x, y ≤ n) as the longest edge in the shortest path between nodes x and y. Specially g(z, z) = 0 for every z. For every integer sequence p1, p2, ..., pn (1 ≤ pi ≤ n), DZY defines f(p) as <image>. DZY wants to find such a sequence p that f(p) has maximum possible value. But there is one more restriction: the element j can appear in p at most xj times. Please, find the maximum possible f(p) under the described restrictions. Input The first line contains an integer n (1 ≤ n ≤ 3000). Each of the next n - 1 lines contains three integers ai, bi, ci (1 ≤ ai, bi ≤ n; 1 ≤ ci ≤ 10000), denoting an edge between ai and bi with length ci. It is guaranteed that these edges form a tree. Each of the next n lines describes an element of sequence x. The j-th line contains an integer xj (1 ≤ xj ≤ n). Output Print a single integer representing the answer. Examples Input 4 1 2 1 2 3 2 3 4 3 1 1 1 1 Output 2 Input 4 1 2 1 2 3 2 3 4 3 4 4 4 4 Output 3 Note In the first sample, one of the optimal p is [4, 3, 2, 1]. ### Input: 4 1 2 1 2 3 2 3 4 3 1 1 1 1 ### Output: 2 ### Input: 4 1 2 1 2 3 2 3 4 3 4 4 4 4 ### Output: 3 ### Code: n = int(input()) edges = [[int(x) for x in input().split()] for i in range(n-1)] edges = sorted(edges) use_count = [0]+[int(input()) for i in range(n)] lo,hi = 0,10000 def getpar(par,u): if par[par[u]] == par[u]: return par[u] par[u] = getpar(par,par[u]) return par[u] def unite(par,sz,use,u,v): u = getpar(par,u) v = getpar(par,v) par[u] = v sz[v] += sz[u] use[v] += use[u] def solve(fp): par = [i for i in range(n+1)] sz = [1 for i in range(n+1)] use = [use_count[i] for i in range(n+1)] for edge in edges: if edge[2] < fp: unite(par,sz,use,edge[0],edge[1]) total_use = sum(use_count) for i in range(n+1): p = getpar(par,i) if(p == i): if(total_use - use[p] < sz[p]): return False return True while lo < hi: mid = (lo+hi+1)//2 if solve(mid): lo = mid else: hi = mid-1 print(lo)
467_A. George and Accommodation_38272
George has recently entered the BSUCP (Berland State University for Cool Programmers). George has a friend Alex who has also entered the university. Now they are moving into a dormitory. George and Alex want to live in the same room. The dormitory has n rooms in total. At the moment the i-th room has pi people living in it and the room can accommodate qi people in total (pi ≤ qi). Your task is to count how many rooms has free place for both George and Alex. Input The first line contains a single integer n (1 ≤ n ≤ 100) — the number of rooms. The i-th of the next n lines contains two integers pi and qi (0 ≤ pi ≤ qi ≤ 100) — the number of people who already live in the i-th room and the room's capacity. Output Print a single integer — the number of rooms where George and Alex can move in. Examples Input 3 1 1 2 2 3 3 Output 0 Input 3 1 10 0 10 10 10 Output 2
c = 0 for _ in range(int(input())): n = [int(x) for x in input().split()] n,m = n[0],n[1] if m - n >= 2: c += 1 print(c)
{ "input": [ "3\n1 1\n2 2\n3 3\n", "3\n1 10\n0 10\n10 10\n", "17\n68 69\n47 48\n30 31\n52 54\n41 43\n33 35\n38 40\n56 58\n45 46\n92 93\n73 74\n61 63\n65 66\n37 39\n67 68\n77 78\n28 30\n", "26\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n", "10\n0 10\n0 20\n0 30\n0 40\n0 50\n0 60\n0 70\n0 80\n0 90\n0 100\n", "14\n1 1\n1 1\n1 55\n1 16\n1 1\n1 1\n1 55\n1 62\n1 53\n1 26\n1 1\n1 36\n1 2\n1 3\n", "44\n0 8\n1 11\n2 19\n3 5\n4 29\n5 45\n6 6\n7 40\n8 19\n9 22\n10 18\n11 26\n12 46\n13 13\n14 27\n15 48\n16 25\n17 20\n18 29\n19 27\n20 45\n21 39\n22 29\n23 39\n24 42\n25 37\n26 52\n27 36\n28 43\n29 35\n30 38\n31 70\n32 47\n33 38\n34 61\n35 71\n36 51\n37 71\n38 59\n39 77\n40 70\n41 80\n42 77\n43 73\n", "2\n36 67\n61 69\n", "15\n55 57\n95 97\n57 59\n34 36\n50 52\n96 98\n39 40\n13 15\n13 14\n74 76\n47 48\n56 58\n24 25\n11 13\n67 68\n", "1\n0 0\n", "19\n66 67\n97 98\n89 91\n67 69\n67 68\n18 20\n72 74\n28 30\n91 92\n27 28\n75 77\n17 18\n74 75\n28 30\n16 18\n90 92\n9 11\n22 24\n52 54\n", "13\n14 16\n30 31\n45 46\n19 20\n15 17\n66 67\n75 76\n95 97\n29 30\n37 38\n0 2\n36 37\n8 9\n", "55\n0 0\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n7 7\n8 8\n9 9\n10 10\n11 11\n12 12\n13 13\n14 14\n15 15\n16 16\n17 17\n18 18\n19 19\n20 20\n21 21\n22 22\n23 23\n24 24\n25 25\n26 26\n27 27\n28 28\n29 29\n30 30\n31 31\n32 32\n33 33\n34 34\n35 35\n36 36\n37 37\n38 38\n39 39\n40 40\n41 41\n42 42\n43 43\n44 44\n45 45\n46 46\n47 47\n48 48\n49 49\n50 50\n51 51\n52 52\n53 53\n54 54\n", "3\n1 2\n2 3\n3 4\n", "3\n21 71\n10 88\n43 62\n", "53\n0 1\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11\n11 12\n12 13\n13 14\n14 15\n15 16\n16 17\n17 18\n18 19\n19 20\n20 21\n21 22\n22 23\n23 24\n24 25\n25 26\n26 27\n27 28\n28 29\n29 30\n30 31\n31 32\n32 33\n33 34\n34 35\n35 36\n36 37\n37 38\n38 39\n39 40\n40 41\n41 42\n42 43\n43 44\n44 45\n45 46\n46 47\n47 48\n48 49\n49 50\n50 51\n51 52\n52 53\n", "68\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n", "100\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n", "51\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 62\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 73\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 82\n55 68\n55 70\n55 63\n55 55\n55 55\n55 55\n55 75\n55 75\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 73\n55 55\n55 82\n55 99\n55 60\n", "3\n1 3\n2 7\n8 9\n", "7\n0 1\n1 5\n2 4\n3 5\n4 6\n5 6\n6 8\n", "14\n64 66\n43 44\n10 12\n76 77\n11 12\n25 27\n87 88\n62 64\n39 41\n58 60\n10 11\n28 29\n57 58\n12 14\n", "1\n100 100\n", "38\n74 76\n52 54\n78 80\n48 49\n40 41\n64 65\n28 30\n6 8\n49 51\n68 70\n44 45\n57 59\n24 25\n46 48\n49 51\n4 6\n63 64\n76 78\n57 59\n18 20\n63 64\n71 73\n88 90\n21 22\n89 90\n65 66\n89 91\n96 98\n42 44\n1 1\n74 76\n72 74\n39 40\n75 76\n29 30\n48 49\n87 89\n27 28\n", "17\n68 69\n47 48\n30 31\n52 54\n41 43\n33 35\n38 40\n56 58\n45 46\n92 93\n73 74\n61 63\n65 66\n37 39\n64 68\n77 78\n28 30\n", "26\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n2 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n", "10\n0 10\n0 20\n0 30\n0 40\n0 50\n0 60\n0 70\n0 80\n0 84\n0 100\n", "14\n1 1\n1 1\n1 55\n1 16\n1 1\n1 1\n1 55\n1 62\n1 53\n1 2\n1 1\n1 36\n1 2\n1 3\n", "13\n14 16\n30 31\n45 46\n19 20\n15 17\n66 67\n75 135\n95 97\n29 30\n37 38\n0 2\n36 37\n8 9\n", "55\n0 0\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n7 7\n8 8\n9 9\n10 10\n11 11\n12 12\n13 13\n14 14\n15 15\n16 16\n17 17\n18 18\n19 19\n20 20\n21 21\n22 22\n23 23\n24 24\n25 25\n26 30\n27 27\n28 28\n29 29\n30 30\n31 31\n32 32\n33 33\n34 34\n35 35\n36 36\n37 37\n38 38\n39 39\n40 40\n41 41\n42 42\n43 43\n44 44\n45 45\n46 46\n47 47\n48 48\n49 49\n50 50\n51 51\n52 52\n53 53\n54 54\n", "3\n21 71\n9 88\n43 62\n", "68\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n1 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n", "51\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 62\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 73\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 82\n55 68\n55 70\n55 63\n48 55\n55 55\n55 55\n55 75\n55 75\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 73\n55 55\n55 82\n55 99\n55 60\n", "3\n1 3\n2 9\n8 9\n", "68\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 1\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n1 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n", "68\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n1 2\n0 2\n0 2\n0 2\n0 2\n0 1\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0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\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n", "14\n64 66\n43 44\n10 12\n76 77\n11 12\n25 27\n87 88\n62 64\n10 41\n58 60\n10 11\n28 29\n57 58\n12 14\n", "3\n1 1\n2 3\n3 3\n", "3\n1 20\n0 10\n10 10\n", "17\n68 69\n47 71\n30 31\n52 54\n41 43\n33 35\n38 40\n56 58\n45 46\n92 93\n73 74\n61 63\n65 66\n37 39\n64 68\n77 78\n28 30\n", "26\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n2 2\n1 2\n1 2\n1 2\n0 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n", "10\n1 10\n0 20\n0 30\n0 40\n0 50\n0 60\n0 70\n0 80\n0 84\n0 100\n", "14\n1 2\n1 1\n1 55\n1 16\n1 1\n1 1\n1 55\n1 62\n1 53\n1 2\n1 1\n1 36\n1 2\n1 3\n", "1\n0 2\n", "3\n1 3\n2 3\n3 7\n", "3\n21 71\n9 88\n43 79\n", "51\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 62\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 73\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 82\n55 68\n55 70\n55 63\n48 55\n55 55\n55 55\n55 75\n55 75\n55 55\n55 55\n55 55\n55 55\n55 55\n55 55\n55 73\n55 55\n19 82\n55 99\n55 60\n", "14\n64 66\n43 44\n10 12\n76 77\n11 12\n25 46\n87 88\n62 64\n10 41\n58 60\n10 11\n28 29\n57 58\n12 14\n", "3\n1 1\n2 3\n2 3\n", "3\n1 2\n0 10\n10 10\n", "17\n68 69\n47 71\n30 31\n52 54\n41 43\n33 35\n38 40\n56 58\n45 46\n92 93\n73 74\n61 80\n65 66\n37 39\n64 68\n77 78\n28 30\n", "26\n1 2\n1 2\n0 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n2 2\n1 2\n1 2\n1 2\n0 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n", "10\n1 10\n0 20\n1 30\n0 40\n0 50\n0 60\n0 70\n0 80\n0 84\n0 100\n", "14\n1 2\n1 1\n0 55\n1 16\n1 1\n1 1\n1 55\n1 62\n1 53\n1 2\n1 1\n1 36\n1 2\n1 3\n", "1\n-1 2\n", "3\n1 2\n2 3\n3 7\n", "3\n21 71\n9 88\n1 79\n", "26\n1 2\n1 2\n0 2\n1 2\n1 2\n1 3\n1 2\n1 2\n1 2\n2 2\n1 2\n1 2\n1 2\n0 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n", "10\n1 10\n1 20\n1 30\n0 40\n0 50\n0 60\n0 70\n0 80\n0 84\n0 100\n", "14\n1 2\n1 1\n0 55\n1 16\n1 1\n0 1\n1 55\n1 62\n1 53\n1 2\n1 1\n1 36\n1 2\n1 3\n", "1\n-1 0\n", "3\n21 71\n9 95\n1 79\n", "14\n52 66\n43 44\n10 12\n76 77\n7 12\n25 46\n87 88\n62 64\n10 41\n58 60\n10 11\n28 29\n57 58\n12 14\n", "10\n1 10\n1 20\n1 30\n0 39\n0 50\n0 60\n0 70\n0 80\n0 84\n0 100\n", "14\n1 2\n1 1\n0 55\n1 16\n1 1\n0 1\n0 55\n1 62\n1 53\n1 2\n1 1\n1 36\n1 2\n1 3\n", "1\n-1 1\n", "3\n21 71\n9 95\n1 6\n", "14\n52 66\n43 44\n10 12\n76 77\n7 12\n25 46\n87 88\n62 64\n10 41\n58 60\n10 19\n28 29\n57 58\n12 14\n", "26\n1 2\n1 2\n0 2\n1 2\n1 2\n1 3\n1 2\n1 2\n1 2\n2 2\n1 2\n1 2\n0 2\n0 2\n1 2\n1 2\n1 2\n0 2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0 2\n1 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n1 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 2\n0 0\n0 2\n0 2\n", "26\n1 2\n1 2\n0 2\n1 2\n1 2\n1 3\n1 2\n1 2\n1 2\n2 2\n1 2\n1 2\n0 2\n-1 2\n1 2\n1 2\n2 2\n0 2\n1 2\n1 2\n1 1\n1 2\n1 2\n1 2\n2 2\n1 2\n", "10\n1 10\n0 20\n1 30\n0 17\n0 50\n1 60\n0 108\n-1 80\n0 84\n0 100\n" ], "output": [ "0\n", "2\n", "8\n", "0\n", "10\n", "8\n", "42\n", "2\n", "10\n", "0\n", "12\n", "4\n", "0\n", "0\n", "3\n", "0\n", "68\n", "0\n", "12\n", "2\n", "5\n", "7\n", "0\n", "22\n", "9\n", "0\n", "10\n", "7\n", "5\n", "1\n", "3\n", "67\n", "13\n", "2\n", "66\n", "65\n", "8\n", "11\n", "64\n", "4\n", "63\n", "62\n", "61\n", "60\n", "59\n", "0\n", "1\n", "0\n", "7\n", "0\n", "2\n", "10\n", "1\n", "10\n", "7\n", "1\n", "2\n", "3\n", "13\n", "7\n", "0\n", "1\n", "10\n", "2\n", "10\n", "7\n", "1\n", "1\n", "3\n", "3\n", "10\n", "7\n", "0\n", "3\n", "8\n", "10\n", "7\n", "1\n", "3\n", "9\n", "5\n", "10\n", "7\n", "1\n", "3\n", "63\n", "9\n", "5\n", "10\n", "7\n", "1\n", "5\n", "10\n", "7\n", "5\n", "10\n", "7\n", "5\n", "10\n", "5\n", "10\n", "59\n", "5\n", "10\n" ] }
2CODEFORCES
Below is a problem description that describes the problem. Write code in Python that appropriately solves the problem. ### Description: George has recently entered the BSUCP (Berland State University for Cool Programmers). George has a friend Alex who has also entered the university. Now they are moving into a dormitory. George and Alex want to live in the same room. The dormitory has n rooms in total. At the moment the i-th room has pi people living in it and the room can accommodate qi people in total (pi ≤ qi). Your task is to count how many rooms has free place for both George and Alex. Input The first line contains a single integer n (1 ≤ n ≤ 100) — the number of rooms. The i-th of the next n lines contains two integers pi and qi (0 ≤ pi ≤ qi ≤ 100) — the number of people who already live in the i-th room and the room's capacity. Output Print a single integer — the number of rooms where George and Alex can move in. Examples Input 3 1 1 2 2 3 3 Output 0 Input 3 1 10 0 10 10 10 Output 2 ### Input: 3 1 1 2 2 3 3 ### Output: 0 ### Input: 3 1 10 0 10 10 10 ### Output: 2 ### Code: c = 0 for _ in range(int(input())): n = [int(x) for x in input().split()] n,m = n[0],n[1] if m - n >= 2: c += 1 print(c)
48_D. Permutations_38276
A permutation is a sequence of integers from 1 to n of length n containing each number exactly once. For example, (1), (4, 3, 5, 1, 2), (3, 2, 1) are permutations, and (1, 1), (4, 3, 1), (2, 3, 4) are not. There are many tasks on permutations. Today you are going to solve one of them. Let’s imagine that somebody took several permutations (perhaps, with a different number of elements), wrote them down consecutively as one array and then shuffled the resulting array. The task is to restore the initial permutations if it is possible. Input The first line contains an integer n (1 ≤ n ≤ 105). The next line contains the mixed array of n integers, divided with a single space. The numbers in the array are from 1 to 105. Output If this array can be split into several permutations so that every element of the array belongs to exactly one permutation, print in the first line the number of permutations. The second line should contain n numbers, corresponding to the elements of the given array. If the i-th element belongs to the first permutation, the i-th number should be 1, if it belongs to the second one, then its number should be 2 and so on. The order of the permutations’ numbering is free. If several solutions are possible, print any one of them. If there’s no solution, print in the first line - 1. Examples Input 9 1 2 3 1 2 1 4 2 5 Output 3 3 1 2 1 2 2 2 3 2 Input 4 4 3 2 1 Output 1 1 1 1 1 Input 4 1 2 2 3 Output -1 Note In the first sample test the array is split into three permutations: (2, 1), (3, 2, 1, 4, 5), (1, 2). The first permutation is formed by the second and the fourth elements of the array, the second one — by the third, the fifth, the sixth, the seventh and the ninth elements, the third one — by the first and the eigth elements. Clearly, there are other splitting variants possible.
def fail(): print(-1) import sys sys.exit() n = int(input()) count = (n + 1) * [ 0 ] assign = n * [ None ] for i, x in enumerate(map(int, input().split())): if x > n: fail() count[x] += 1 assign[i] = count[x] for i in range(2, n): if count[i - 1] < count[i]: fail() print(count[1]) print(' '.join(map(str, assign)))
{ "input": [ "9\n1 2 3 1 2 1 4 2 5\n", "4\n4 3 2 1\n", "4\n1 2 2 3\n", "2\n1000 1\n", "5\n2 2 1 1 3\n", "100\n12 18 1 1 14 23 1 1 22 5 7 9 7 1 1 1 3 8 4 2 1 6 9 1 3 2 11 1 11 2 3 2 1 4 2 7 1 16 3 4 2 13 3 1 5 11 2 10 20 24 3 21 5 2 6 2 1 10 10 5 17 1 1 4 19 8 5 5 3 9 4 2 7 8 10 4 9 1 3 3 9 7 6 4 4 3 6 8 12 1 3 6 2 1 8 4 1 15 2 5\n", "50\n7 1 6 5 15 3 13 7 1 1 4 2 4 3 2 1 11 9 4 2 3 7 1 1 1 14 3 14 5 2 5 4 1 8 2 2 2 2 1 1 4 1 2 3 6 12 1 1 5 1\n", "100\n10 1 13 1 5 2 5 5 9 10 3 8 4 1 3 5 6 4 1 4 9 8 1 1 1 1 8 2 3 1 1 2 5 1 1 12 6 4 5 3 1 3 18 10 1 2 3 2 6 2 3 15 1 3 5 3 9 7 1 6 11 7 7 8 6 17 11 7 6 1 4 4 1 1 3 1 2 6 7 14 4 4 5 1 11 1 4 2 8 4 2 7 16 12 1 1 2 2 1 2\n", "3\n2 1 1\n", "1\n1\n", "9\n1 2 3 1 2 1 4 2 5\n", "20\n4 6 6 4 5 4 3 2 5 7 3 2 4 1 3 1 1 4 1 7\n", "6\n3 3 2 2 1 1\n", "20\n2 10 3 3 2 1 14 13 2 15 1 4 5 12 7 11 9 1 6 8\n", "30\n1 3 2 5 9 4 16 14 2 2 4 11 7 17 1 15 13 3 6 12 6 19 8 1 20 5 18 4 10 3\n", "20\n1 1 1 2 3 1 5 9 5 8 4 6 7 3 1 2 2 1 3 4\n", "30\n2 8 3 3 7 4 2 9 4 3 5 6 1 5 3 5 8 1 9 6 6 7 2 7 1 1 1 10 2 1\n", "10\n4 1 2 1 3 3 1 2 2 1\n", "10\n1 2 5 1 1 1 4 1 3 2\n", "2\n100000 1\n", "50\n1 1 4 1 1 1 1 1 1 3 1 1 3 2 1 1 1 1 5 2 1 1 1 1 1 3 1 1 1 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "10\n2 2 6 3 1 4 5 3 7 7\n", "30\n8 7 9 6 2 3 7 1 1 5 7 2 3 1 7 4 5 6 3 9 4 9 4 2 3 1 1 2 2 10\n", "1\n2\n", "20\n1 7 2 3 1 1 8 1 6 1 9 11 5 10 1 4 2 3 1 2\n", "100\n9 6 3 28 10 2 2 11 2 1 25 3 13 5 14 13 4 14 2 16 12 27 8 1 7 9 8 19 33 23 4 1 15 6 7 12 2 8 30 4 1 31 6 1 15 5 18 3 2 24 7 3 1 20 10 8 26 22 3 3 9 6 1 10 1 5 1 3 7 6 11 10 1 16 19 5 9 4 4 4 2 18 12 21 11 5 2 32 17 29 2 4 8 1 7 5 3 2 17 1\n", "20\n2 7 3 8 4 6 3 7 6 4 13 5 1 12 1 10 2 11 5 9\n", "30\n6 1 2 3 6 4 1 8 1 2 2 5 5 1 1 3 9 1 5 8 1 2 7 7 4 3 1 3 4 2\n", "10\n2 1 2 4 6 1 5 3 7 1\n", "100\n2 13 10 4 13 8 22 11 5 3 4 6 19 4 8 8 6 1 16 4 11 17 5 18 7 7 4 5 3 7 2 16 5 6 10 1 6 12 14 6 8 7 9 7 1 2 1 8 5 5 9 21 7 11 6 1 12 10 6 23 10 9 8 4 1 2 3 13 2 14 15 1 1 12 3 9 12 3 13 9 8 1 12 5 2 3 11 7 11 9 3 14 1 2 15 2 10 4 14 20\n", "30\n2 6 2 3 3 1 4 2 1 3 3 2 1 2 1 8 1 2 4 1 1 1 5 1 4 7 1 9 1 1\n", "5\n1 1 1 1 1\n", "2\n1010 1\n", "9\n1 2 3 1 2 1 4 3 5\n", "50\n1 1 4 1 1 1 1 1 1 3 1 1 3 2 1 1 1 1 5 2 1 1 1 1 1 3 1 1 1 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 2\n", "9\n1 4 3 1 2 2 4 3 5\n", "50\n7 1 6 5 15 2 13 7 1 1 4 2 4 3 2 1 11 9 4 2 3 7 1 1 1 14 3 14 5 2 5 4 1 8 2 2 2 2 1 1 4 1 2 3 6 12 1 1 5 1\n", "100\n10 1 13 1 5 2 5 5 9 10 3 8 4 1 3 5 6 4 1 4 9 8 1 1 1 1 8 2 3 1 1 2 5 1 1 12 6 4 5 3 1 3 18 10 1 2 3 2 6 2 3 15 1 3 5 3 9 7 1 6 11 7 7 8 6 17 11 7 6 1 4 4 1 1 3 1 2 6 7 14 4 4 4 1 11 1 4 2 8 4 2 7 16 12 1 1 2 2 1 2\n", "3\n4 1 1\n", "20\n4 6 6 4 5 4 3 2 5 7 2 2 4 1 3 1 1 4 1 7\n", "6\n3 3 2 2 1 2\n", "20\n2 10 3 3 2 1 14 13 2 15 1 4 5 12 12 11 9 1 6 8\n", "30\n1 3 2 5 9 4 16 14 2 2 4 11 7 17 1 15 13 5 6 12 6 19 8 1 20 5 18 4 10 3\n", "20\n1 1 1 2 3 1 5 9 8 8 4 6 7 3 1 2 2 1 3 4\n", "30\n2 8 6 3 7 4 2 9 4 3 5 6 1 5 3 5 8 1 9 6 6 7 2 7 1 1 1 10 2 1\n", "10\n6 1 2 1 3 3 1 2 2 1\n", "10\n1 2 5 1 1 1 4 1 1 2\n", "10\n2 2 6 3 1 4 5 3 14 7\n", "30\n8 7 9 6 2 3 7 1 1 5 7 2 3 1 7 4 5 6 3 9 4 9 4 2 3 1 1 2 4 10\n", "1\n3\n", "20\n1 7 2 3 1 1 8 1 6 1 9 11 5 10 1 4 3 3 1 2\n", "100\n9 6 3 30 10 2 2 11 2 1 25 3 13 5 14 13 4 14 2 16 12 27 8 1 7 9 8 19 33 23 4 1 15 6 7 12 2 8 30 4 1 31 6 1 15 5 18 3 2 24 7 3 1 20 10 8 26 22 3 3 9 6 1 10 1 5 1 3 7 6 11 10 1 16 19 5 9 4 4 4 2 18 12 21 11 5 2 32 17 29 2 4 8 1 7 5 3 2 17 1\n", "20\n2 7 3 8 4 6 3 7 6 4 15 5 1 12 1 10 2 11 5 9\n", "10\n2 1 2 1 6 1 5 3 7 1\n", "4\n7 3 2 1\n", "2\n1010 2\n", "50\n7 1 6 5 15 2 13 7 1 1 4 2 4 3 2 1 11 9 5 2 3 7 1 1 1 14 3 14 5 2 5 4 1 8 2 2 2 2 1 1 4 1 2 3 6 12 1 1 5 1\n", "100\n10 1 13 1 5 2 5 5 9 10 3 8 4 1 3 5 6 4 1 4 9 8 1 1 1 1 8 2 3 1 1 2 5 1 1 12 6 6 5 3 1 3 18 10 1 2 3 2 6 2 3 15 1 3 5 3 9 7 1 6 11 7 7 8 6 17 11 7 6 1 4 4 1 1 3 1 2 6 7 14 4 4 4 1 11 1 4 2 8 4 2 7 16 12 1 1 2 2 1 2\n", "9\n1 4 3 1 2 1 4 3 5\n", "20\n4 6 6 4 5 4 3 2 5 7 2 2 4 1 6 1 1 4 1 7\n", "20\n2 10 3 3 2 1 14 13 2 15 1 4 5 12 12 11 9 1 5 8\n", "30\n1 3 2 5 9 4 16 14 2 2 4 11 7 17 1 15 13 5 6 12 6 19 8 1 20 5 18 4 2 3\n", "20\n1 1 1 2 3 1 4 9 8 8 4 6 7 3 1 2 2 1 3 4\n", "30\n2 8 2 3 7 4 2 9 4 3 5 6 1 5 3 5 8 1 9 6 6 7 2 7 1 1 1 10 2 1\n", "10\n6 1 3 1 3 3 1 2 2 1\n", "10\n2 2 6 3 1 4 5 3 10 7\n", "1\n5\n", "20\n1 7 2 3 1 1 8 1 6 1 9 11 9 10 1 4 3 3 1 2\n", "20\n2 7 3 8 4 6 3 7 6 4 15 5 1 12 1 10 2 11 8 9\n", "2\n1000 2\n", "50\n7 1 8 5 15 2 13 7 1 1 4 2 4 3 2 1 11 9 5 2 3 7 1 1 1 14 3 14 5 2 5 4 1 8 2 2 2 2 1 1 4 1 2 3 6 12 1 1 5 1\n", "20\n4 6 6 4 5 4 3 2 5 7 2 2 4 1 11 1 1 4 1 7\n", "20\n2 10 3 3 2 1 14 13 4 15 1 4 5 12 12 11 9 1 5 8\n", "30\n1 3 2 5 9 4 16 14 2 2 4 11 7 17 1 15 13 5 6 12 6 19 8 1 20 5 18 3 2 3\n", "20\n1 1 1 2 3 1 4 9 8 8 1 6 7 3 1 2 2 1 3 4\n", "30\n2 8 2 3 7 4 2 9 4 3 5 6 1 5 3 10 8 1 9 6 6 7 2 7 1 1 1 10 2 1\n", "10\n6 1 3 1 4 3 1 2 2 1\n", "10\n2 2 4 3 1 4 5 3 10 7\n", "1\n4\n", "20\n1 7 2 3 1 1 8 1 6 1 9 16 9 10 1 4 3 3 1 2\n", "20\n2 7 3 8 4 6 3 7 12 4 15 5 1 12 1 10 2 11 8 9\n", "2\n1000 3\n", "50\n7 1 8 5 15 2 13 7 1 1 4 2 4 3 2 1 11 9 5 2 3 7 1 1 1 28 3 14 5 2 5 4 1 8 2 2 2 2 1 1 4 1 2 3 6 12 1 1 5 1\n", "9\n1 8 3 1 2 2 4 3 5\n", "20\n4 6 6 4 5 4 3 2 5 4 2 2 4 1 11 1 1 4 1 7\n", "20\n2 10 3 3 2 1 14 13 4 15 1 4 5 12 12 11 18 1 5 8\n", "20\n1 1 1 2 3 1 4 9 8 1 1 6 7 3 1 2 2 1 3 4\n", "30\n2 8 2 3 7 4 2 9 4 3 5 6 2 5 3 10 8 1 9 6 6 7 2 7 1 1 1 10 2 1\n", "10\n6 1 3 2 4 3 1 2 2 1\n", "10\n3 2 4 3 1 4 5 3 10 7\n", "1\n6\n", "20\n2 7 3 8 4 6 3 7 12 4 15 5 1 12 1 10 2 11 8 15\n", "2\n1000 4\n", "50\n7 1 8 5 15 2 13 5 1 1 4 2 4 3 2 1 11 9 5 2 3 7 1 1 1 28 3 14 5 2 5 4 1 8 2 2 2 2 1 1 4 1 2 3 6 12 1 1 5 1\n", "9\n1 2 3 1 2 2 4 3 5\n", "20\n2 10 3 3 2 1 14 13 4 15 1 1 5 12 12 11 18 1 5 8\n" ], "output": [ "3\n1 1 1 2 2 3 1 3 1 ", "1\n1 1 1 1 ", "-1", "-1", "2\n1 2 1 2 1 ", "20\n1 1 1 2 1 1 3 4 1 1 1 1 2 5 6 7 1 1 1 1 8 1 2 9 2 2 1 10 2 3 3 4 11 2 5 3 12 1 4 3 6 1 5 13 2 3 7 1 1 1 6 1 3 8 2 9 14 2 3 4 1 15 16 4 1 2 5 6 7 3 5 10 4 3 4 6 4 17 8 9 5 5 3 7 8 10 4 4 2 18 11 5 11 19 5 9 20 1 12 7 ", "-1", "25\n1 1 1 2 1 1 2 3 1 2 1 1 1 3 2 4 1 2 4 3 2 2 5 6 7 8 3 2 3 9 10 3 5 11 12 1 2 4 6 4 13 5 1 3 14 4 6 5 3 6 7 1 15 8 7 9 3 1 16 4 1 2 3 4 5 1 2 4 6 17 5 6 18 19 10 20 7 7 5 1 7 8 8 21 3 22 9 8 5 10 9 6 1 2 23 24 10 11 25 12 ", "2\n1 1 2 ", "1\n1 ", "3\n1 1 1 2 2 3 1 3 1 ", "-1", "2\n1 2 1 2 1 2 ", "3\n1 1 1 2 2 1 1 1 3 1 2 1 1 1 1 1 1 3 1 1 ", "3\n1 1 1 1 1 1 1 1 2 3 2 1 1 1 2 1 1 2 1 1 2 1 1 3 1 2 1 3 1 3 ", "6\n1 2 3 1 1 4 1 1 2 1 1 1 1 2 5 2 3 6 3 2 ", "-1", "4\n1 1 1 2 1 2 3 2 3 4 ", "5\n1 1 1 2 3 4 1 5 1 2 ", "-1", "41\n1 2 1 3 4 5 6 7 8 1 9 10 2 1 11 12 13 14 1 2 15 16 17 18 19 3 20 21 22 23 24 25 3 26 27 4 28 29 30 31 32 33 34 35 36 37 38 39 40 41 ", "-1", "-1", "-1", "7\n1 1 1 1 2 3 1 4 1 5 1 1 1 1 6 1 2 2 7 3 ", "12\n1 1 1 1 1 1 2 1 3 1 1 2 1 1 1 2 1 2 4 1 1 1 1 2 1 2 2 1 1 1 2 3 1 2 2 2 5 3 1 3 4 1 3 5 2 2 1 3 6 1 3 4 6 1 2 4 1 1 5 6 3 4 7 3 8 3 9 7 4 5 2 4 10 2 2 4 4 4 5 6 7 2 3 1 3 5 8 1 1 1 9 7 5 11 5 6 8 10 2 12 ", "2\n1 1 1 1 1 1 2 2 2 2 1 1 1 1 2 1 2 1 2 1 ", "8\n1 1 1 1 2 1 2 1 3 2 3 1 2 4 5 2 1 6 3 2 7 4 1 2 2 3 8 4 3 5 ", "3\n1 1 2 1 1 2 1 1 1 3 ", "10\n1 1 1 1 2 1 1 1 1 1 2 1 1 3 2 3 2 1 1 4 2 1 2 1 1 2 5 3 2 3 2 2 4 3 2 2 4 1 1 5 4 4 1 5 3 3 4 5 5 6 2 1 6 3 6 5 2 3 7 1 4 3 6 6 6 4 3 3 5 2 1 7 8 3 4 4 4 5 4 5 7 9 5 7 6 6 4 7 5 6 7 3 10 7 2 8 5 7 4 1 ", "12\n1 1 2 1 2 1 1 3 2 3 4 4 3 5 4 1 5 6 2 6 7 8 1 9 3 1 10 1 11 12 ", "5\n1 2 3 4 5 ", "-1\n", "3\n1 1 1 2 2 3 1 2 1\n", "40\n1 2 1 3 4 5 6 7 8 1 9 10 2 1 11 12 13 14 1 2 15 16 17 18 19 3 20 21 22 23 24 25 3 26 27 4 28 29 30 31 32 33 34 35 36 37 38 39 40 5\n", "2\n1 1 1 2 1 2 2 2 1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n" ] }
2CODEFORCES
Below is a problem description that describes the problem. Write code in Python that appropriately solves the problem. ### Description: A permutation is a sequence of integers from 1 to n of length n containing each number exactly once. For example, (1), (4, 3, 5, 1, 2), (3, 2, 1) are permutations, and (1, 1), (4, 3, 1), (2, 3, 4) are not. There are many tasks on permutations. Today you are going to solve one of them. Let’s imagine that somebody took several permutations (perhaps, with a different number of elements), wrote them down consecutively as one array and then shuffled the resulting array. The task is to restore the initial permutations if it is possible. Input The first line contains an integer n (1 ≤ n ≤ 105). The next line contains the mixed array of n integers, divided with a single space. The numbers in the array are from 1 to 105. Output If this array can be split into several permutations so that every element of the array belongs to exactly one permutation, print in the first line the number of permutations. The second line should contain n numbers, corresponding to the elements of the given array. If the i-th element belongs to the first permutation, the i-th number should be 1, if it belongs to the second one, then its number should be 2 and so on. The order of the permutations’ numbering is free. If several solutions are possible, print any one of them. If there’s no solution, print in the first line - 1. Examples Input 9 1 2 3 1 2 1 4 2 5 Output 3 3 1 2 1 2 2 2 3 2 Input 4 4 3 2 1 Output 1 1 1 1 1 Input 4 1 2 2 3 Output -1 Note In the first sample test the array is split into three permutations: (2, 1), (3, 2, 1, 4, 5), (1, 2). The first permutation is formed by the second and the fourth elements of the array, the second one — by the third, the fifth, the sixth, the seventh and the ninth elements, the third one — by the first and the eigth elements. Clearly, there are other splitting variants possible. ### Input: 9 1 2 3 1 2 1 4 2 5 ### Output: 3 1 1 1 2 2 3 1 3 1 ### Input: 4 4 3 2 1 ### Output: 1 1 1 1 1 ### Code: def fail(): print(-1) import sys sys.exit() n = int(input()) count = (n + 1) * [ 0 ] assign = n * [ None ] for i, x in enumerate(map(int, input().split())): if x > n: fail() count[x] += 1 assign[i] = count[x] for i in range(2, n): if count[i - 1] < count[i]: fail() print(count[1]) print(' '.join(map(str, assign)))
53_B. Blog Photo_38282
One popular blog site edits the uploaded photos like this. It cuts a rectangular area out of them so that the ratio of height to width (i.e. the height / width quotient) can vary from 0.8 to 1.25 inclusively. Besides, at least one side of the cut area should have a size, equal to some power of number 2 (2x for some integer x). If those rules don't indicate the size of the cut are clearly, then the way with which the cut part possesses the largest area is chosen. Of course, both sides of the cut area should be integer. If there are several answers to this problem, you should choose the answer with the maximal height. Input The first line contains a pair of integers h and w (1 ≤ h, w ≤ 109) which are the height and width of the uploaded photo in pixels. Output Print two integers which are the height and width of the cut area. Examples Input 2 1 Output 1 1 Input 2 2 Output 2 2 Input 5 5 Output 5 4
from math import ceil,floor l = [] for i in range(39): l.append(2**i) h,w = map(int,input().split()) h1 = 0 w1 = 0 maxi = 0 for i in l: if i<=w: a = ceil(i*0.8) b = floor(i*1.25) if a<=h<=b: if i*h>=maxi: maxi = i * h h1 = h w1 = i elif b<h: if i*b>=maxi: maxi = i * b h1 = b w1 = i elif a<h: if i*a>=maxi: maxi = i * a h1 = a w1 = i h2 = 0 w2 = 0 w,h = h,w maxi = 0 for i in l: if i<=w: a = ceil(i/(1.25)) b = floor(i/(0.8)) if i<=w: a = ceil(i*0.8) b = floor(i*1.25) if a<=h<=b: if i*h>=maxi: maxi = i * h h2 = h w2 = i elif b<h: if i*b>=maxi: maxi = i * b h2 = b w2 = i elif a<h: if i*a>=maxi: maxi = i * a h2 = a w2 = i w2,h2 = h2,w2 if h1*w1>h2*w2: print(h1,w1) elif h1*w1 == h2*w2: if h1>h2: print(h1,w1) else: print(h2,w2) else: print(h2,w2)
{ "input": [ "2 1\n", "2 2\n", "5 5\n", "15 13\n", "9 10\n", "47 46\n", "49829224 49889315\n", "483242 484564\n", "644590722 593296648\n", "971840165 826141527\n", "49728622 49605627\n", "99692141 99232337\n", "48298903 49928606\n", "792322809 775058858\n", "998557701 924591072\n", "939 887\n", "9909199 9945873\n", "39271 49032\n", "1000000000 1000000000\n", "49934587 49239195\n", "4774 4806\n", "944976601 976175854\n", "4939191 4587461\n", "99 100\n", "48945079 49798393\n", "49874820 49474021\n", "47 56\n", "39271 49011\n", "1010000000 1000000000\n", "101 100\n", "6 5\n", "8 10\n", "40344417 49605627\n", "9909199 9735441\n", "51927138 49798393\n", "1 1\n", "13 13\n", "4939191 4455370\n", "47 54\n", "100 100\n", "110 100\n", "110 110\n", "100 110\n", "47 45\n", "1010000000 1000000010\n", "1010000000 1000000001\n", "101 110\n", "111 100\n", "111 110\n", "101 111\n", "1011000000 1000000010\n", "100 111\n", "100 101\n", "101 101\n", "49829224 60056281\n", "1000000010 1000000000\n", "57455132 49239195\n", "47 48\n", "47 57\n", "1010000000 1001000010\n", "1010000001 1000000001\n", "111 101\n", "111 111\n", "1011000000 1000001010\n", "1000000010 1010000000\n", "57455132 54832111\n", "1010000001 1000001001\n", "1011000000 1010001010\n", "1000000000 1010000000\n", "57455132 61793242\n", "1010000001 1000001000\n", "1011000000 1010001000\n", "1000000001 1010000000\n", "52750015 61793242\n", "1010000001 1000000000\n", "1011000000 1011001000\n", "1010000001 1010000000\n", "1010000101 1000000000\n", "1010000001 1010100000\n" ], "output": [ "1 1", "2 2", "5 4", "10 8", "8 10", "40 32", "41943040 33554432", "327680 262144", "644590722 536870912", "671088640 536870912", "41943040 33554432", "83886080 67108864", "41943040 33554432", "671088640 536870912", "671088640 536870912", "640 512", "8388608 9945873", "32768 40960", "671088640 536870912", "41943040 33554432", "4096 4806", "671088640 536870912", "4939191 4194304", "80 64", "41943040 33554432", "41943040 33554432", "40 32\n", "32768 40960\n", "671088640 536870912\n", "80 64\n", "5 4\n", "8 10\n", "33554432 41943040\n", "9909199 8388608\n", "41943040 33554432\n", "1 1\n", "10 8\n", "4939191 4194304\n", "40 32\n", "80 64\n", "80 64\n", "80 64\n", "80 64\n", "40 32\n", "671088640 536870912\n", "671088640 536870912\n", "80 64\n", "80 64\n", "80 64\n", "80 64\n", "671088640 536870912\n", "80 64\n", "80 64\n", "80 64\n", "41943040 33554432\n", "671088640 536870912\n", "41943040 33554432\n", "40 32\n", "40 32\n", "671088640 536870912\n", "671088640 536870912\n", "80 64\n", "80 64\n", "671088640 536870912\n", "671088640 536870912\n", "41943040 33554432\n", "671088640 536870912\n", "671088640 536870912\n", "671088640 536870912\n", "41943040 33554432\n", "671088640 536870912\n", "671088640 536870912\n", "671088640 536870912\n", "41943040 33554432\n", "671088640 536870912\n", "671088640 536870912\n", "671088640 536870912\n", "671088640 536870912\n", "671088640 536870912\n" ] }
2CODEFORCES
Below is a problem description that describes the problem. Write code in Python that appropriately solves the problem. ### Description: One popular blog site edits the uploaded photos like this. It cuts a rectangular area out of them so that the ratio of height to width (i.e. the height / width quotient) can vary from 0.8 to 1.25 inclusively. Besides, at least one side of the cut area should have a size, equal to some power of number 2 (2x for some integer x). If those rules don't indicate the size of the cut are clearly, then the way with which the cut part possesses the largest area is chosen. Of course, both sides of the cut area should be integer. If there are several answers to this problem, you should choose the answer with the maximal height. Input The first line contains a pair of integers h and w (1 ≤ h, w ≤ 109) which are the height and width of the uploaded photo in pixels. Output Print two integers which are the height and width of the cut area. Examples Input 2 1 Output 1 1 Input 2 2 Output 2 2 Input 5 5 Output 5 4 ### Input: 2 1 ### Output: 1 1 ### Input: 2 2 ### Output: 2 2 ### Code: from math import ceil,floor l = [] for i in range(39): l.append(2**i) h,w = map(int,input().split()) h1 = 0 w1 = 0 maxi = 0 for i in l: if i<=w: a = ceil(i*0.8) b = floor(i*1.25) if a<=h<=b: if i*h>=maxi: maxi = i * h h1 = h w1 = i elif b<h: if i*b>=maxi: maxi = i * b h1 = b w1 = i elif a<h: if i*a>=maxi: maxi = i * a h1 = a w1 = i h2 = 0 w2 = 0 w,h = h,w maxi = 0 for i in l: if i<=w: a = ceil(i/(1.25)) b = floor(i/(0.8)) if i<=w: a = ceil(i*0.8) b = floor(i*1.25) if a<=h<=b: if i*h>=maxi: maxi = i * h h2 = h w2 = i elif b<h: if i*b>=maxi: maxi = i * b h2 = b w2 = i elif a<h: if i*a>=maxi: maxi = i * a h2 = a w2 = i w2,h2 = h2,w2 if h1*w1>h2*w2: print(h1,w1) elif h1*w1 == h2*w2: if h1>h2: print(h1,w1) else: print(h2,w2) else: print(h2,w2)
567_D. One-Dimensional Battle Ships_38286
Alice and Bob love playing one-dimensional battle ships. They play on the field in the form of a line consisting of n square cells (that is, on a 1 × n table). At the beginning of the game Alice puts k ships on the field without telling their positions to Bob. Each ship looks as a 1 × a rectangle (that is, it occupies a sequence of a consecutive squares of the field). The ships cannot intersect and even touch each other. After that Bob makes a sequence of "shots". He names cells of the field and Alice either says that the cell is empty ("miss"), or that the cell belongs to some ship ("hit"). But here's the problem! Alice like to cheat. May be that is why she responds to each Bob's move with a "miss". Help Bob catch Alice cheating — find Bob's first move, such that after it you can be sure that Alice cheated. Input The first line of the input contains three integers: n, k and a (1 ≤ n, k, a ≤ 2·105) — the size of the field, the number of the ships and the size of each ship. It is guaranteed that the n, k and a are such that you can put k ships of size a on the field, so that no two ships intersect or touch each other. The second line contains integer m (1 ≤ m ≤ n) — the number of Bob's moves. The third line contains m distinct integers x1, x2, ..., xm, where xi is the number of the cell where Bob made the i-th shot. The cells are numbered from left to right from 1 to n. Output Print a single integer — the number of such Bob's first move, after which you can be sure that Alice lied. Bob's moves are numbered from 1 to m in the order the were made. If the sought move doesn't exist, then print "-1". Examples Input 11 3 3 5 4 8 6 1 11 Output 3 Input 5 1 3 2 1 5 Output -1 Input 5 1 3 1 3 Output 1
import sys def minp(): return sys.stdin.readline().strip() def mint(): return int(minp()) def mints(): return map(int, minp().split()) def solve(): n, k, a = mints() a += 1 m = mint() x = list(mints()) l = 0 r = m + 1 while r - l > 1: c = (l + r) // 2 b = x[:c] b.sort() last = 0 cnt = 0 for i in b: if i != last: cnt += (i-last) // a last = i cnt += (n+1-last)//a if cnt < k: r = c else: l = c if r == m + 1: r = -1 print(r) solve()
{ "input": [ "11 3 3\n5\n4 8 6 1 11\n", "5 1 3\n1\n3\n", "5 1 3\n2\n1 5\n", "200000 1 199999\n2\n2 200000\n", "5000 1660 2\n20\n1 100 18 102 300 81 19 25 44 88 1337 4999 1054 1203 91 16 164 914 1419 1487\n", "50 1 1\n50\n1 13 21 37 30 48 23 19 6 49 36 14 9 24 44 10 41 28 20 2 15 11 45 3 25 33 50 38 35 47 31 4 12 46 32 8 42 26 5 7 27 16 29 43 39 22 17 34 40 18\n", "200000 1 199999\n2\n1 200000\n", "200000 1 200000\n1\n200000\n", "200000 1 200000\n1\n1\n", "50 7 3\n50\n17 47 1 12 21 25 6 5 49 27 34 8 16 38 11 44 48 9 2 20 3 22 33 23 36 41 15 35 31 30 50 7 45 42 37 29 14 26 24 46 19 4 10 28 18 43 32 39 40 13\n", "200000 1 199999\n2\n200000 1\n", "10 2 4\n2\n5 6\n", "200000 100000 1\n1\n31618\n", "5000 1000 2\n3\n1000 2000 3000\n", "10 2 4\n3\n5 6 1\n", "4 2 1\n2\n1 3\n", "4 2 1\n2\n1 2\n", "50 7 3\n20\n24 18 34 32 44 2 5 40 17 48 31 45 8 6 15 27 26 1 20 10\n", "1 1 1\n1\n1\n", "5000 1660 2\n20\n1 100 18 102 300 81 19 25 44 88 1337 4999 1054 1203 91 16 70 914 1419 1487\n", "200000 1 119175\n2\n1 200000\n", "200000 1 200000\n1\n2\n", "9 2 4\n2\n5 6\n", "50 7 3\n20\n24 18 34 32 44 2 5 40 17 48 31 45 8 12 15 27 26 1 20 10\n", "11 3 3\n5\n4 8 7 1 11\n", "5000 1660 2\n20\n1 100 18 102 300 81 19 25 68 88 90 4999 1054 366 91 16 70 914 1419 1487\n", "5000 1660 2\n20\n1 100 18 102 300 81 19 25 44 88 1337 4999 1054 1203 91 16 164 955 1419 1487\n", "15 3 3\n5\n4 8 6 1 11\n", "50 10 3\n20\n24 18 34 32 44 2 5 40 17 48 31 45 8 6 15 32 26 1 20 10\n", "5000 1001 2\n3\n1000 2000 3000\n", "2 1 1\n1\n1\n", "5000 1660 2\n20\n1 100 18 102 300 81 19 25 44 88 90 4999 1054 1203 91 16 70 914 1419 1487\n", "11 2 4\n2\n5 6\n", "5000 1001 2\n3\n1000 2741 3000\n", "50 7 3\n20\n24 18 34 32 44 2 5 40 17 48 31 45 8 12 15 27 43 1 20 10\n", "2 1 2\n1\n1\n", "5000 1660 2\n20\n1 100 18 102 300 81 19 25 68 88 90 4999 1054 1203 91 16 70 914 1419 1487\n", "3 1 2\n1\n1\n", "5000 1660 2\n20\n1 100 18 102 300 81 19 25 68 88 90 4999 1685 366 91 16 70 914 1419 1487\n", "5000 1660 2\n20\n1 100 18 102 300 81 19 25 68 88 90 1961 1685 366 91 16 70 914 1419 1487\n", "5000 1660 2\n20\n1 100 18 102 272 81 19 25 68 88 90 1961 1685 366 91 16 70 914 1419 1487\n", "5000 1660 2\n20\n1 100 18 102 272 81 19 25 68 88 90 1961 1685 366 91 16 113 914 1419 1487\n", "5000 1660 2\n20\n1 100 18 102 272 81 19 25 68 88 90 1961 1685 366 91 16 207 914 1419 1487\n", "5000 1660 2\n20\n1 100 18 102 272 81 19 25 68 88 90 1961 1065 366 91 16 207 914 1419 1487\n", "5000 1660 2\n20\n1 100 18 102 272 81 19 25 68 88 90 1961 1065 366 91 16 207 914 1419 2892\n", "5000 1660 2\n20\n1 100 18 102 272 81 19 25 68 67 90 1961 1065 366 91 16 207 914 1419 2892\n", "200000 1 166087\n1\n200000\n", "200000 1 112231\n1\n1\n", "200000 0 199999\n2\n200000 1\n", "10 2 2\n2\n5 6\n", "5000 0000 2\n3\n1000 2000 3000\n", "8 2 1\n2\n1 3\n", "50 7 3\n20\n24 18 34 32 44 2 5 40 17 48 31 45 8 6 15 32 26 1 20 10\n", "5 1 3\n1\n2\n", "5 1 1\n2\n1 5\n", "5000 1660 2\n20\n1 100 18 102 300 81 19 25 44 88 500 4999 1054 1203 91 16 70 914 1419 1487\n", "200000 1 192534\n2\n1 200000\n", "17 2 4\n2\n5 6\n", "5000 1001 2\n3\n1000 2041 3000\n", "11 3 3\n5\n4 2 7 1 11\n", "5000 1001 2\n3\n1000 2741 140\n", "50 7 3\n20\n24 18 34 46 44 2 5 40 17 48 31 45 8 12 15 27 43 1 20 10\n", "5000 1660 2\n20\n1 100 18 102 300 81 19 25 68 88 90 4999 326 1203 91 16 70 914 1419 1487\n", "5 1 2\n1\n1\n", "5000 1660 2\n20\n1 100 18 102 300 81 19 25 79 88 90 4999 1054 366 91 16 70 914 1419 1487\n", "5000 1660 2\n20\n1 100 18 102 300 81 19 25 68 88 90 4999 3143 366 91 16 70 914 1419 1487\n", "5000 297 2\n20\n1 100 18 102 300 81 19 25 68 88 90 1961 1685 366 91 16 70 914 1419 1487\n", "5000 1660 2\n20\n1 100 18 102 272 81 19 25 68 88 32 1961 1685 366 91 16 113 914 1419 1487\n", "5000 1660 2\n20\n1 100 18 102 272 81 19 25 68 59 90 1961 1685 366 91 16 207 914 1419 1487\n", "5000 1660 2\n20\n1 100 18 102 272 81 19 34 68 88 90 1961 1065 366 91 16 207 914 1419 1487\n", "5000 1660 2\n20\n1 100 18 102 272 81 19 25 68 88 90 1961 1065 542 91 16 207 914 1419 2892\n", "5000 1660 2\n20\n2 100 18 102 272 81 19 25 68 67 90 1961 1065 366 91 16 207 914 1419 2892\n", "5000 1660 2\n20\n1 100 18 102 300 81 19 25 44 88 1337 4999 1054 1203 91 16 164 955 1648 1487\n", "200000 1 166087\n1\n71282\n", "10 2 2\n2\n5 1\n", "11 2 1\n2\n1 3\n", "5 1 3\n1\n1\n", "5000 1660 2\n20\n1 100 18 102 300 29 19 25 44 88 500 4999 1054 1203 91 16 70 914 1419 1487\n" ], "output": [ "3\n", "1\n", "-1\n", "1\n", "18\n", "50\n", "2\n", "1\n", "1\n", "19\n", "2\n", "-1\n", "-1\n", "-1\n", "3\n", "-1\n", "2\n", "13\n", "1\n", "18\n", "-1\n", "1\n", "2\n", "13\n", "3\n", "19\n", "20\n", "4\n", "7\n", "-1\n", "-1\n", "18\n", "-1\n", "-1\n", "13\n", "1\n", "18\n", "-1\n", "19\n", "-1\n", "19\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "13\n", "-1\n", "-1\n", "20\n", "-1\n", "-1\n", "-1\n", "2\n", "-1\n", "13\n", "20\n", "-1\n", "20\n", "19\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "1\n", "-1\n", "-1\n", "-1\n", "-1\n" ] }
2CODEFORCES
Below is a problem description that describes the problem. Write code in Python that appropriately solves the problem. ### Description: Alice and Bob love playing one-dimensional battle ships. They play on the field in the form of a line consisting of n square cells (that is, on a 1 × n table). At the beginning of the game Alice puts k ships on the field without telling their positions to Bob. Each ship looks as a 1 × a rectangle (that is, it occupies a sequence of a consecutive squares of the field). The ships cannot intersect and even touch each other. After that Bob makes a sequence of "shots". He names cells of the field and Alice either says that the cell is empty ("miss"), or that the cell belongs to some ship ("hit"). But here's the problem! Alice like to cheat. May be that is why she responds to each Bob's move with a "miss". Help Bob catch Alice cheating — find Bob's first move, such that after it you can be sure that Alice cheated. Input The first line of the input contains three integers: n, k and a (1 ≤ n, k, a ≤ 2·105) — the size of the field, the number of the ships and the size of each ship. It is guaranteed that the n, k and a are such that you can put k ships of size a on the field, so that no two ships intersect or touch each other. The second line contains integer m (1 ≤ m ≤ n) — the number of Bob's moves. The third line contains m distinct integers x1, x2, ..., xm, where xi is the number of the cell where Bob made the i-th shot. The cells are numbered from left to right from 1 to n. Output Print a single integer — the number of such Bob's first move, after which you can be sure that Alice lied. Bob's moves are numbered from 1 to m in the order the were made. If the sought move doesn't exist, then print "-1". Examples Input 11 3 3 5 4 8 6 1 11 Output 3 Input 5 1 3 2 1 5 Output -1 Input 5 1 3 1 3 Output 1 ### Input: 11 3 3 5 4 8 6 1 11 ### Output: 3 ### Input: 5 1 3 1 3 ### Output: 1 ### Code: import sys def minp(): return sys.stdin.readline().strip() def mint(): return int(minp()) def mints(): return map(int, minp().split()) def solve(): n, k, a = mints() a += 1 m = mint() x = list(mints()) l = 0 r = m + 1 while r - l > 1: c = (l + r) // 2 b = x[:c] b.sort() last = 0 cnt = 0 for i in b: if i != last: cnt += (i-last) // a last = i cnt += (n+1-last)//a if cnt < k: r = c else: l = c if r == m + 1: r = -1 print(r) solve()
610_C. Harmony Analysis_38291
The semester is already ending, so Danil made an effort and decided to visit a lesson on harmony analysis to know how does the professor look like, at least. Danil was very bored on this lesson until the teacher gave the group a simple task: find 4 vectors in 4-dimensional space, such that every coordinate of every vector is 1 or - 1 and any two vectors are orthogonal. Just as a reminder, two vectors in n-dimensional space are considered to be orthogonal if and only if their scalar product is equal to zero, that is: <image>. Danil quickly managed to come up with the solution for this problem and the teacher noticed that the problem can be solved in a more general case for 2k vectors in 2k-dimensinoal space. When Danil came home, he quickly came up with the solution for this problem. Can you cope with it? Input The only line of the input contains a single integer k (0 ≤ k ≤ 9). Output Print 2k lines consisting of 2k characters each. The j-th character of the i-th line must be equal to ' * ' if the j-th coordinate of the i-th vector is equal to - 1, and must be equal to ' + ' if it's equal to + 1. It's guaranteed that the answer always exists. If there are many correct answers, print any. Examples Input 2 Output ++** +*+* ++++ +**+ Note Consider all scalar products in example: * Vectors 1 and 2: ( + 1)·( + 1) + ( + 1)·( - 1) + ( - 1)·( + 1) + ( - 1)·( - 1) = 0 * Vectors 1 and 3: ( + 1)·( + 1) + ( + 1)·( + 1) + ( - 1)·( + 1) + ( - 1)·( + 1) = 0 * Vectors 1 and 4: ( + 1)·( + 1) + ( + 1)·( - 1) + ( - 1)·( - 1) + ( - 1)·( + 1) = 0 * Vectors 2 and 3: ( + 1)·( + 1) + ( - 1)·( + 1) + ( + 1)·( + 1) + ( - 1)·( + 1) = 0 * Vectors 2 and 4: ( + 1)·( + 1) + ( - 1)·( - 1) + ( + 1)·( - 1) + ( - 1)·( + 1) = 0 * Vectors 3 and 4: ( + 1)·( + 1) + ( + 1)·( - 1) + ( + 1)·( - 1) + ( + 1)·( + 1) = 0
p = [[0]] for i in range(int(input())): p = [t + t for t in p] + [[1 - q for q in t] + t for t in p] for t in p: print(''.join('+*'[q] for q in t))
{ "input": [ "2\n", "2\n", "4\n", "1\n", "5\n", "7\n", "8\n", "6\n", "0\n", "3\n" ], "output": [ "++++\n+*+*\n++**\n+**+\n", "++++\n+*+*\n++**\n+**+\n", "++++++++++++++++\n+*+*+*+*+*+*+*+*\n++**++**++**++**\n+**++**++**++**+\n++++****++++****\n+*+**+*++*+**+*+\n++****++++****++\n+**+*++*+**+*++*\n++++++++********\n+*+*+*+**+*+*+*+\n++**++****++**++\n+**++**+*++**++*\n++++********++++\n+*+**+*+*+*++*+*\n++****++**++++**\n+**+*++**++*+**+\n", "++\n+*\n", "++++++++++++++++++++++++++++++++\n+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*\n++**++**++**++**++**++**++**++**\n+**++**++**++**++**++**++**++**+\n++++****++++****++++****++++****\n+*+**+*++*+**+*++*+**+*++*+**+*+\n++****++++****++++****++++****++\n+**+*++*+**+*++*+**+*++*+**+*++*\n++++++++********++++++++********\n+*+*+*+**+*+*+*++*+*+*+**+*+*+*+\n++**++****++**++++**++****++**++\n+**++**+*++**++*+**++**+*++**++*\n++++********++++++++********++++\n+*+**+*+*+*++*+*+*+**+*+*+*++*+*\n++****++**++++**++****++**++++**\n+**+*++**++*+**++**+*++**++*+**+\n++++++++++++++++****************\n+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+\n++**++**++**++****++**++**++**++\n+**++**++**++**+*++**++**++**++*\n++++****++++********++++****++++\n+*+**+*++*+**+*+*+*++*+**+*++*+*\n++****++++****++**++++****++++**\n+**+*++*+**+*++**++*+**+*++*+**+\n++++++++****************++++++++\n+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*\n++**++****++**++**++**++++**++**\n+**++**+*++**++**++**++*+**++**+\n++++********++++****++++++++****\n+*+**+*+*+*++*+**+*++*+*+*+**+*+\n++****++**++++****++++**++****++\n+**+*++**++*+**+*++*+**++**+*++*\n", "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*\n++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**\n+**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**+\n++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****\n+*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*+\n++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++\n+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*\n++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********\n+*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*+\n++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++\n+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*\n++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++\n+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*\n++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**\n+**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**+\n++++++++++++++++****************++++++++++++++++****************++++++++++++++++****************++++++++++++++++****************\n+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+\n++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++\n+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*\n++++****++++********++++****++++++++****++++********++++****++++++++****++++********++++****++++++++****++++********++++****++++\n+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*\n++****++++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**\n+**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**+\n++++++++****************++++++++++++++++****************++++++++++++++++****************++++++++++++++++****************++++++++\n+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*\n++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**\n+**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**+\n++++********++++****++++++++****++++********++++****++++++++****++++********++++****++++++++****++++********++++****++++++++****\n+*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*+\n++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**++****++\n+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*\n++++++++++++++++++++++++++++++++********************************++++++++++++++++++++++++++++++++********************************\n+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+\n++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++\n+**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++*\n++++****++++****++++****++++********++++****++++****++++****++++++++****++++****++++****++++********++++****++++****++++****++++\n+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*\n++****++++****++++****++++****++**++++****++++****++++****++++**++****++++****++++****++++****++**++++****++++****++++****++++**\n+**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**+\n++++++++********++++++++****************++++++++********++++++++++++++++********++++++++****************++++++++********++++++++\n+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*\n++**++****++**++++**++****++**++**++**++++**++****++**++++**++**++**++****++**++++**++****++**++**++**++++**++****++**++++**++**\n+**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**+\n++++********++++++++********++++****++++++++********++++++++****++++********++++++++********++++****++++++++********++++++++****\n+*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*+\n++****++**++++**++****++**++++****++++**++****++**++++**++****++++****++**++++**++****++**++++****++++**++****++**++++**++****++\n+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*\n++++++++++++++++********************************++++++++++++++++++++++++++++++++********************************++++++++++++++++\n+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*\n++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++**\n+**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**+\n++++****++++********++++****++++****++++****++++++++****++++****++++****++++********++++****++++****++++****++++++++****++++****\n+*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*+\n++****++++****++**++++****++++****++++****++++**++****++++****++++****++++****++**++++****++++****++++****++++**++****++++****++\n+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*\n++++++++****************++++++++********++++++++++++++++********++++++++****************++++++++********++++++++++++++++********\n+*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*+\n++**++****++**++**++**++++**++****++**++++**++**++**++****++**++++**++****++**++**++**++++**++****++**++++**++**++**++****++**++\n+**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++*\n++++********++++****++++++++********++++++++****++++********++++++++********++++****++++++++********++++++++****++++********++++\n+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*\n++****++**++++****++++**++****++**++++**++****++++****++**++++**++****++**++++****++++**++****++**++++**++****++++****++**++++**\n+**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**+\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++****************************************************************\n+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+\n++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++\n+**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++*\n++++****++++****++++****++++****++++****++++****++++****++++********++++****++++****++++****++++****++++****++++****++++****++++\n+*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+*\n++****++++****++++****++++****++++****++++****++++****++++****++**++++****++++****++++****++++****++++****++++****++++****++++**\n+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+\n++++++++********++++++++********++++++++********++++++++****************++++++++********++++++++********++++++++********++++++++\n+*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+*\n++**++****++**++++**++****++**++++**++****++**++++**++****++**++**++**++++**++****++**++++**++****++**++++**++****++**++++**++**\n+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+\n++++********++++++++********++++++++********++++++++********++++****++++++++********++++++++********++++++++********++++++++****\n+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+\n++****++**++++**++****++**++++**++****++**++++**++****++**++++****++++**++****++**++++**++****++**++++**++****++**++++**++****++\n+**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++*\n++++++++++++++++****************++++++++++++++++********************************++++++++++++++++****************++++++++++++++++\n+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*\n++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++****++**++**++**++++**++**++**++**\n+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+\n++++****++++********++++****++++++++****++++********++++****++++****++++****++++++++****++++********++++****++++++++****++++****\n+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+\n++****++++****++**++++****++++**++****++++****++**++++****++++****++++****++++**++****++++****++**++++****++++**++****++++****++\n+**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++*\n++++++++****************++++++++++++++++****************++++++++********++++++++++++++++****************++++++++++++++++********\n+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+\n++**++****++**++**++**++++**++**++**++****++**++**++**++++**++****++**++++**++**++**++****++**++**++**++++**++**++**++****++**++\n+**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++*\n++++********++++****++++++++****++++********++++****++++++++********++++++++****++++********++++****++++++++****++++********++++\n+*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+*\n++****++**++++****++++**++****++++****++**++++****++++**++****++**++++**++****++++****++**++++****++++**++****++++****++**++++**\n+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+\n++++++++++++++++++++++++++++++++****************************************************************++++++++++++++++++++++++++++++++\n+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*\n++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++++**++**++**++**++**++**++**++**\n+**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++*+**++**++**++**++**++**++**++**+\n++++****++++****++++****++++********++++****++++****++++****++++****++++****++++****++++****++++++++****++++****++++****++++****\n+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*+\n++****++++****++++****++++****++**++++****++++****++++****++++****++++****++++****++++****++++**++****++++****++++****++++****++\n+**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++*\n++++++++********++++++++****************++++++++********++++++++********++++++++********++++++++++++++++********++++++++********\n+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*+\n++**++****++**++++**++****++**++**++**++++**++****++**++++**++****++**++++**++****++**++++**++**++**++****++**++++**++****++**++\n+**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**++**++**+*++**++*+**++**+*++**++*\n++++********++++++++********++++****++++++++********++++++++********++++++++********++++++++****++++********++++++++********++++\n+*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+*\n++****++**++++**++****++**++++****++++**++****++**++++**++****++**++++**++****++**++++**++****++++****++**++++**++****++**++++**\n+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**+\n++++++++++++++++********************************++++++++++++++++****************++++++++++++++++++++++++++++++++****************\n+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+\n++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++****++**++**++**++++**++**++**++**++**++**++**++****++**++**++**++\n+**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**++**++**++**++**+*++**++**++**++*\n++++****++++********++++****++++****++++****++++++++****++++********++++****++++++++****++++****++++****++++********++++****++++\n+*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+*\n++****++++****++**++++****++++****++++****++++**++****++++****++**++++****++++**++****++++****++++****++++****++**++++****++++**\n+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+\n++++++++****************++++++++********++++++++++++++++****************++++++++++++++++********++++++++****************++++++++\n+*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+*\n++**++****++**++**++**++++**++****++**++++**++**++**++****++**++**++**++++**++**++**++****++**++++**++****++**++**++**++++**++**\n+**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++*+**++**+*++**++**++**++*+**++**+\n++++********++++****++++++++********++++++++****++++********++++****++++++++****++++********++++++++********++++****++++++++****\n+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+\n++****++**++++****++++**++****++**++++**++****++++****++**++++****++++**++****++++****++**++++**++****++**++++****++++**++****++\n+**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++*\n", "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*\n++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**\n+**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**+\n++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****\n+*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*+\n++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++\n+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*\n++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********\n+*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*+\n++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++\n+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*\n++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++\n+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*\n++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**\n+**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**+\n++++++++++++++++****************++++++++++++++++****************++++++++++++++++****************++++++++++++++++****************++++++++++++++++****************++++++++++++++++****************++++++++++++++++****************++++++++++++++++****************\n+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+\n++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++\n+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*\n++++****++++********++++****++++++++****++++********++++****++++++++****++++********++++****++++++++****++++********++++****++++++++****++++********++++****++++++++****++++********++++****++++++++****++++********++++****++++++++****++++********++++****++++\n+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*\n++****++++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**\n+**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**+\n++++++++****************++++++++++++++++****************++++++++++++++++****************++++++++++++++++****************++++++++++++++++****************++++++++++++++++****************++++++++++++++++****************++++++++++++++++****************++++++++\n+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*\n++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**\n+**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**+\n++++********++++****++++++++****++++********++++****++++++++****++++********++++****++++++++****++++********++++****++++++++****++++********++++****++++++++****++++********++++****++++++++****++++********++++****++++++++****++++********++++****++++++++****\n+*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*+\n++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**++****++\n+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*\n++++++++++++++++++++++++++++++++********************************++++++++++++++++++++++++++++++++********************************++++++++++++++++++++++++++++++++********************************++++++++++++++++++++++++++++++++********************************\n+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+\n++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++\n+**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++*\n++++****++++****++++****++++********++++****++++****++++****++++++++****++++****++++****++++********++++****++++****++++****++++++++****++++****++++****++++********++++****++++****++++****++++++++****++++****++++****++++********++++****++++****++++****++++\n+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*\n++****++++****++++****++++****++**++++****++++****++++****++++**++****++++****++++****++++****++**++++****++++****++++****++++**++****++++****++++****++++****++**++++****++++****++++****++++**++****++++****++++****++++****++**++++****++++****++++****++++**\n+**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**+\n++++++++********++++++++****************++++++++********++++++++++++++++********++++++++****************++++++++********++++++++++++++++********++++++++****************++++++++********++++++++++++++++********++++++++****************++++++++********++++++++\n+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*\n++**++****++**++++**++****++**++**++**++++**++****++**++++**++**++**++****++**++++**++****++**++**++**++++**++****++**++++**++**++**++****++**++++**++****++**++**++**++++**++****++**++++**++**++**++****++**++++**++****++**++**++**++++**++****++**++++**++**\n+**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**+\n++++********++++++++********++++****++++++++********++++++++****++++********++++++++********++++****++++++++********++++++++****++++********++++++++********++++****++++++++********++++++++****++++********++++++++********++++****++++++++********++++++++****\n+*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*+\n++****++**++++**++****++**++++****++++**++****++**++++**++****++++****++**++++**++****++**++++****++++**++****++**++++**++****++++****++**++++**++****++**++++****++++**++****++**++++**++****++++****++**++++**++****++**++++****++++**++****++**++++**++****++\n+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*\n++++++++++++++++********************************++++++++++++++++++++++++++++++++********************************++++++++++++++++++++++++++++++++********************************++++++++++++++++++++++++++++++++********************************++++++++++++++++\n+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*\n++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++**\n+**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**+\n++++****++++********++++****++++****++++****++++++++****++++****++++****++++********++++****++++****++++****++++++++****++++****++++****++++********++++****++++****++++****++++++++****++++****++++****++++********++++****++++****++++****++++++++****++++****\n+*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*+\n++****++++****++**++++****++++****++++****++++**++****++++****++++****++++****++**++++****++++****++++****++++**++****++++****++++****++++****++**++++****++++****++++****++++**++****++++****++++****++++****++**++++****++++****++++****++++**++****++++****++\n+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*\n++++++++****************++++++++********++++++++++++++++********++++++++****************++++++++********++++++++++++++++********++++++++****************++++++++********++++++++++++++++********++++++++****************++++++++********++++++++++++++++********\n+*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*+\n++**++****++**++**++**++++**++****++**++++**++**++**++****++**++++**++****++**++**++**++++**++****++**++++**++**++**++****++**++++**++****++**++**++**++++**++****++**++++**++**++**++****++**++++**++****++**++**++**++++**++****++**++++**++**++**++****++**++\n+**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++*\n++++********++++****++++++++********++++++++****++++********++++++++********++++****++++++++********++++++++****++++********++++++++********++++****++++++++********++++++++****++++********++++++++********++++****++++++++********++++++++****++++********++++\n+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*\n++****++**++++****++++**++****++**++++**++****++++****++**++++**++****++**++++****++++**++****++**++++**++****++++****++**++++**++****++**++++****++++**++****++**++++**++****++++****++**++++**++****++**++++****++++**++****++**++++**++****++++****++**++++**\n+**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**+\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++****************************************************************++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++****************************************************************\n+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+\n++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++\n+**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++*+**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++*\n++++****++++****++++****++++****++++****++++****++++****++++********++++****++++****++++****++++****++++****++++****++++****++++++++****++++****++++****++++****++++****++++****++++****++++********++++****++++****++++****++++****++++****++++****++++****++++\n+*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+*\n++****++++****++++****++++****++++****++++****++++****++++****++**++++****++++****++++****++++****++++****++++****++++****++++**++****++++****++++****++++****++++****++++****++++****++++****++**++++****++++****++++****++++****++++****++++****++++****++++**\n+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+\n++++++++********++++++++********++++++++********++++++++****************++++++++********++++++++********++++++++********++++++++++++++++********++++++++********++++++++********++++++++****************++++++++********++++++++********++++++++********++++++++\n+*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+*\n++**++****++**++++**++****++**++++**++****++**++++**++****++**++**++**++++**++****++**++++**++****++**++++**++****++**++++**++**++**++****++**++++**++****++**++++**++****++**++++**++****++**++**++**++++**++****++**++++**++****++**++++**++****++**++++**++**\n+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**++**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+\n++++********++++++++********++++++++********++++++++********++++****++++++++********++++++++********++++++++********++++++++****++++********++++++++********++++++++********++++++++********++++****++++++++********++++++++********++++++++********++++++++****\n+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+\n++****++**++++**++****++**++++**++****++**++++**++****++**++++****++++**++****++**++++**++****++**++++**++****++**++++**++****++++****++**++++**++****++**++++**++****++**++++**++****++**++++****++++**++****++**++++**++****++**++++**++****++**++++**++****++\n+**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++*\n++++++++++++++++****************++++++++++++++++********************************++++++++++++++++****************++++++++++++++++++++++++++++++++****************++++++++++++++++********************************++++++++++++++++****************++++++++++++++++\n+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*\n++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++****++**++**++**++++**++**++**++**++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++****++**++**++**++++**++**++**++**\n+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**++**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+\n++++****++++********++++****++++++++****++++********++++****++++****++++****++++++++****++++********++++****++++++++****++++****++++****++++********++++****++++++++****++++********++++****++++****++++****++++++++****++++********++++****++++++++****++++****\n+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+\n++****++++****++**++++****++++**++****++++****++**++++****++++****++++****++++**++****++++****++**++++****++++**++****++++****++++****++++****++**++++****++++**++****++++****++**++++****++++****++++****++++**++****++++****++**++++****++++**++****++++****++\n+**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++*\n++++++++****************++++++++++++++++****************++++++++********++++++++++++++++****************++++++++++++++++********++++++++****************++++++++++++++++****************++++++++********++++++++++++++++****************++++++++++++++++********\n+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+\n++**++****++**++**++**++++**++**++**++****++**++**++**++++**++****++**++++**++**++**++****++**++**++**++++**++**++**++****++**++++**++****++**++**++**++++**++**++**++****++**++**++**++++**++****++**++++**++**++**++****++**++**++**++++**++**++**++****++**++\n+**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++*+**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++*\n++++********++++****++++++++****++++********++++****++++++++********++++++++****++++********++++****++++++++****++++********++++++++********++++****++++++++****++++********++++****++++++++********++++++++****++++********++++****++++++++****++++********++++\n+*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+*\n++****++**++++****++++**++****++++****++**++++****++++**++****++**++++**++****++++****++**++++****++++**++****++++****++**++++**++****++**++++****++++**++****++++****++**++++****++++**++****++**++++**++****++++****++**++++****++++**++****++++****++**++++**\n+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+\n++++++++++++++++++++++++++++++++****************************************************************++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++****************************************************************++++++++++++++++++++++++++++++++\n+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*\n++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++++**++**++**++**++**++**++**++**\n+**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++*+**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++*+**++**++**++**++**++**++**++**+\n++++****++++****++++****++++********++++****++++****++++****++++****++++****++++****++++****++++++++****++++****++++****++++****++++****++++****++++****++++********++++****++++****++++****++++****++++****++++****++++****++++++++****++++****++++****++++****\n+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*+\n++****++++****++++****++++****++**++++****++++****++++****++++****++++****++++****++++****++++**++****++++****++++****++++****++++****++++****++++****++++****++**++++****++++****++++****++++****++++****++++****++++****++++**++****++++****++++****++++****++\n+**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++*\n++++++++********++++++++****************++++++++********++++++++********++++++++********++++++++++++++++********++++++++********++++++++********++++++++****************++++++++********++++++++********++++++++********++++++++++++++++********++++++++********\n+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*+\n++**++****++**++++**++****++**++**++**++++**++****++**++++**++****++**++++**++****++**++++**++**++**++****++**++++**++****++**++++**++****++**++++**++****++**++**++**++++**++****++**++++**++****++**++++**++****++**++++**++**++**++****++**++++**++****++**++\n+**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**++**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**++**++**+*++**++*+**++**+*++**++*\n++++********++++++++********++++****++++++++********++++++++********++++++++********++++++++****++++********++++++++********++++++++********++++++++********++++****++++++++********++++++++********++++++++********++++++++****++++********++++++++********++++\n+*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+*\n++****++**++++**++****++**++++****++++**++****++**++++**++****++**++++**++****++**++++**++****++++****++**++++**++****++**++++**++****++**++++**++****++**++++****++++**++****++**++++**++****++**++++**++****++**++++**++****++++****++**++++**++****++**++++**\n+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**+\n++++++++++++++++********************************++++++++++++++++****************++++++++++++++++++++++++++++++++****************++++++++++++++++********************************++++++++++++++++****************++++++++++++++++++++++++++++++++****************\n+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+\n++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++****++**++**++**++++**++**++**++**++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++****++**++**++**++++**++**++**++**++**++**++**++****++**++**++**++\n+**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**++**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**++**++**++**++**+*++**++**++**++*\n++++****++++********++++****++++****++++****++++++++****++++********++++****++++++++****++++****++++****++++********++++****++++++++****++++********++++****++++****++++****++++++++****++++********++++****++++++++****++++****++++****++++********++++****++++\n+*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+*\n++****++++****++**++++****++++****++++****++++**++****++++****++**++++****++++**++****++++****++++****++++****++**++++****++++**++****++++****++**++++****++++****++++****++++**++****++++****++**++++****++++**++****++++****++++****++++****++**++++****++++**\n+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+\n++++++++****************++++++++********++++++++++++++++****************++++++++++++++++********++++++++****************++++++++++++++++****************++++++++********++++++++++++++++****************++++++++++++++++********++++++++****************++++++++\n+*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+*\n++**++****++**++**++**++++**++****++**++++**++**++**++****++**++**++**++++**++**++**++****++**++++**++****++**++**++**++++**++**++**++****++**++**++**++++**++****++**++++**++**++**++****++**++**++**++++**++**++**++****++**++++**++****++**++**++**++++**++**\n+**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++*+**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++*+**++**+*++**++**++**++*+**++**+\n++++********++++****++++++++********++++++++****++++********++++****++++++++****++++********++++++++********++++****++++++++****++++********++++****++++++++********++++++++****++++********++++****++++++++****++++********++++++++********++++****++++++++****\n+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+\n++****++**++++****++++**++****++**++++**++****++++****++**++++****++++**++****++++****++**++++**++****++**++++****++++**++****++++****++**++++****++++**++****++**++++**++****++++****++**++++****++++**++****++++****++**++++**++****++**++++****++++**++****++\n+**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++*\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++********************************************************************************************************************************\n+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+\n++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++\n+**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++*\n++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++********++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++\n+*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+*\n++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++**++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++**\n+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+\n++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++****************++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++\n+*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+*\n++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++**++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++**\n+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+\n++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++****++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++****\n+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+\n++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++****++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++\n+**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++*\n++++++++++++++++****************++++++++++++++++****************++++++++++++++++****************++++++++++++++++********************************++++++++++++++++****************++++++++++++++++****************++++++++++++++++****************++++++++++++++++\n+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*\n++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++**\n+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+\n++++****++++********++++****++++++++****++++********++++****++++++++****++++********++++****++++++++****++++********++++****++++****++++****++++++++****++++********++++****++++++++****++++********++++****++++++++****++++********++++****++++++++****++++****\n+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+\n++****++++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++****++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**++****++++****++\n+**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++*\n++++++++****************++++++++++++++++****************++++++++++++++++****************++++++++++++++++****************++++++++********++++++++++++++++****************++++++++++++++++****************++++++++++++++++****************++++++++++++++++********\n+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+\n++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++****++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++\n+**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++*\n++++********++++****++++++++****++++********++++****++++++++****++++********++++****++++++++****++++********++++****++++++++********++++++++****++++********++++****++++++++****++++********++++****++++++++****++++********++++****++++++++****++++********++++\n+*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+*\n++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**++****++**++++**++****++++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++**\n+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+\n++++++++++++++++++++++++++++++++********************************++++++++++++++++++++++++++++++++****************************************************************++++++++++++++++++++++++++++++++********************************++++++++++++++++++++++++++++++++\n+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*\n++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++**++**++**++**++**\n+**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++*+**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**++**++**++**++**+\n++++****++++****++++****++++********++++****++++****++++****++++++++****++++****++++****++++********++++****++++****++++****++++****++++****++++****++++****++++++++****++++****++++****++++********++++****++++****++++****++++++++****++++****++++****++++****\n+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*+\n++****++++****++++****++++****++**++++****++++****++++****++++**++****++++****++++****++++****++**++++****++++****++++****++++****++++****++++****++++****++++**++****++++****++++****++++****++**++++****++++****++++****++++**++****++++****++++****++++****++\n+**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++*\n++++++++********++++++++****************++++++++********++++++++++++++++********++++++++****************++++++++********++++++++********++++++++********++++++++++++++++********++++++++****************++++++++********++++++++++++++++********++++++++********\n+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*+\n++**++****++**++++**++****++**++**++**++++**++****++**++++**++**++**++****++**++++**++****++**++**++**++++**++****++**++++**++****++**++++**++****++**++++**++**++**++****++**++++**++****++**++**++**++++**++****++**++++**++**++**++****++**++++**++****++**++\n+**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**++**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++*+**++**+*++**++*\n++++********++++++++********++++****++++++++********++++++++****++++********++++++++********++++****++++++++********++++++++********++++++++********++++++++****++++********++++++++********++++****++++++++********++++++++****++++********++++++++********++++\n+*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+*\n++****++**++++**++****++**++++****++++**++****++**++++**++****++++****++**++++**++****++**++++****++++**++****++**++++**++****++**++++**++****++**++++**++****++++****++**++++**++****++**++++****++++**++****++**++++**++****++++****++**++++**++****++**++++**\n+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**+\n++++++++++++++++********************************++++++++++++++++++++++++++++++++********************************++++++++++++++++****************++++++++++++++++++++++++++++++++********************************++++++++++++++++++++++++++++++++****************\n+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+\n++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++****++**++**++**++++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++**++**++**++**++****++**++**++**++\n+**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**++**++**++**++**+*++**++**++**++*\n++++****++++********++++****++++****++++****++++++++****++++****++++****++++********++++****++++****++++****++++++++****++++********++++****++++++++****++++****++++****++++********++++****++++****++++****++++++++****++++****++++****++++********++++****++++\n+*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+*\n++****++++****++**++++****++++****++++****++++**++****++++****++++****++++****++**++++****++++****++++****++++**++****++++****++**++++****++++**++****++++****++++****++++****++**++++****++++****++++****++++**++****++++****++++****++++****++**++++****++++**\n+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+\n++++++++****************++++++++********++++++++++++++++********++++++++****************++++++++********++++++++++++++++****************++++++++++++++++********++++++++****************++++++++********++++++++++++++++********++++++++****************++++++++\n+*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+*\n++**++****++**++**++**++++**++****++**++++**++**++**++****++**++++**++****++**++**++**++++**++****++**++++**++**++**++****++**++**++**++++**++**++**++****++**++++**++****++**++**++**++++**++****++**++++**++**++**++****++**++++**++****++**++**++**++++**++**\n+**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++*+**++**+*++**++**++**++*+**++**+\n++++********++++****++++++++********++++++++****++++********++++++++********++++****++++++++********++++++++****++++********++++****++++++++****++++********++++++++********++++****++++++++********++++++++****++++********++++++++********++++****++++++++****\n+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+\n++****++**++++****++++**++****++**++++**++****++++****++**++++**++****++**++++****++++**++****++**++++**++****++++****++**++++****++++**++****++++****++**++++**++****++**++++****++++**++****++**++++**++****++++****++**++++**++****++**++++****++++**++****++\n+**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++*\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++********************************************************************************************************************************++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*\n++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**\n+**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++*+**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**+\n++++****++++****++++****++++****++++****++++****++++****++++********++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++++++****++++****++++****++++****++++****++++****++++****++++****\n+*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*+\n++****++++****++++****++++****++++****++++****++++****++++****++**++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++**++****++++****++++****++++****++++****++++****++++****++++****++\n+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*\n++++++++********++++++++********++++++++********++++++++****************++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++++++++++********++++++++********++++++++********++++++++********\n+*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*+\n++**++****++**++++**++****++**++++**++****++**++++**++****++**++**++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++**++**++****++**++++**++****++**++++**++****++**++++**++****++**++\n+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**++**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*\n++++********++++++++********++++++++********++++++++********++++****++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++****++++********++++++++********++++++++********++++++++********++++\n+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*\n++****++**++++**++****++**++++**++****++**++++**++****++**++++****++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++++****++**++++**++****++**++++**++****++**++++**++****++**++++**\n+**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**+\n++++++++++++++++****************++++++++++++++++********************************++++++++++++++++****************++++++++++++++++****************++++++++++++++++****************++++++++++++++++++++++++++++++++****************++++++++++++++++****************\n+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+\n++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++**++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++\n+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**++**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*\n++++****++++********++++****++++++++****++++********++++****++++****++++****++++++++****++++********++++****++++++++****++++********++++****++++++++****++++********++++****++++++++****++++****++++****++++********++++****++++++++****++++********++++****++++\n+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*\n++****++++****++**++++****++++**++****++++****++**++++****++++****++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**++****++++****++++****++++****++**++++****++++**++****++++****++**++++****++++**\n+**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**+\n++++++++****************++++++++++++++++****************++++++++********++++++++++++++++****************++++++++++++++++****************++++++++++++++++****************++++++++++++++++********++++++++****************++++++++++++++++****************++++++++\n+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*\n++**++****++**++**++**++++**++**++**++****++**++**++**++++**++****++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**\n+**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++*+**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**+\n++++********++++****++++++++****++++********++++****++++++++********++++++++****++++********++++****++++++++****++++********++++****++++++++****++++********++++****++++++++****++++********++++++++********++++****++++++++****++++********++++****++++++++****\n+*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*+\n++****++**++++****++++**++****++++****++**++++****++++**++****++**++++**++****++++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++**++****++**++++****++++**++****++++****++**++++****++++**++****++\n+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*\n++++++++++++++++++++++++++++++++****************************************************************++++++++++++++++++++++++++++++++********************************++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++********************************\n+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+\n++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++\n+**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++*+**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++*\n++++****++++****++++****++++********++++****++++****++++****++++****++++****++++****++++****++++++++****++++****++++****++++********++++****++++****++++****++++++++****++++****++++****++++****++++****++++****++++****++++********++++****++++****++++****++++\n+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*\n++****++++****++++****++++****++**++++****++++****++++****++++****++++****++++****++++****++++**++****++++****++++****++++****++**++++****++++****++++****++++**++****++++****++++****++++****++++****++++****++++****++++****++**++++****++++****++++****++++**\n+**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**+\n++++++++********++++++++****************++++++++********++++++++********++++++++********++++++++++++++++********++++++++****************++++++++********++++++++++++++++********++++++++********++++++++********++++++++****************++++++++********++++++++\n+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*\n++**++****++**++++**++****++**++**++**++++**++****++**++++**++****++**++++**++****++**++++**++**++**++****++**++++**++****++**++**++**++++**++****++**++++**++**++**++****++**++++**++****++**++++**++****++**++++**++****++**++**++**++++**++****++**++++**++**\n+**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**++**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**+\n++++********++++++++********++++****++++++++********++++++++********++++++++********++++++++****++++********++++++++********++++****++++++++********++++++++****++++********++++++++********++++++++********++++++++********++++****++++++++********++++++++****\n+*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*+\n++****++**++++**++****++**++++****++++**++****++**++++**++****++**++++**++****++**++++**++****++++****++**++++**++****++**++++****++++**++****++**++++**++****++++****++**++++**++****++**++++**++****++**++++**++****++**++++****++++**++****++**++++**++****++\n+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*\n++++++++++++++++********************************++++++++++++++++****************++++++++++++++++++++++++++++++++********************************++++++++++++++++++++++++++++++++****************++++++++++++++++********************************++++++++++++++++\n+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*\n++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++****++**++**++**++++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++**++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++**\n+**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**++**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**+\n++++****++++********++++****++++****++++****++++++++****++++********++++****++++++++****++++****++++****++++********++++****++++****++++****++++++++****++++****++++****++++********++++****++++++++****++++********++++****++++****++++****++++++++****++++****\n+*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*+\n++****++++****++**++++****++++****++++****++++**++****++++****++**++++****++++**++****++++****++++****++++****++**++++****++++****++++****++++**++****++++****++++****++++****++**++++****++++**++****++++****++**++++****++++****++++****++++**++****++++****++\n+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*\n++++++++****************++++++++********++++++++++++++++****************++++++++++++++++********++++++++****************++++++++********++++++++++++++++********++++++++****************++++++++++++++++****************++++++++********++++++++++++++++********\n+*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*+\n++**++****++**++**++**++++**++****++**++++**++**++**++****++**++**++**++++**++**++**++****++**++++**++****++**++**++**++++**++****++**++++**++**++**++****++**++++**++****++**++**++**++++**++**++**++****++**++**++**++++**++****++**++++**++**++**++****++**++\n+**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++*+**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++*\n++++********++++****++++++++********++++++++****++++********++++****++++++++****++++********++++++++********++++****++++++++********++++++++****++++********++++++++********++++****++++++++****++++********++++****++++++++********++++++++****++++********++++\n+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*\n++****++**++++****++++**++****++**++++**++****++++****++**++++****++++**++****++++****++**++++**++****++**++++****++++**++****++**++++**++****++++****++**++++**++****++**++++****++++**++****++++****++**++++****++++**++****++**++++**++****++++****++**++++**\n+**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**+\n", "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*\n++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**\n+**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**+\n++++****++++****++++****++++****++++****++++****++++****++++****\n+*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*+\n++****++++****++++****++++****++++****++++****++++****++++****++\n+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*\n++++++++********++++++++********++++++++********++++++++********\n+*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*+\n++**++****++**++++**++****++**++++**++****++**++++**++****++**++\n+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*\n++++********++++++++********++++++++********++++++++********++++\n+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*\n++****++**++++**++****++**++++**++****++**++++**++****++**++++**\n+**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**+\n++++++++++++++++****************++++++++++++++++****************\n+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+\n++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++\n+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*\n++++****++++********++++****++++++++****++++********++++****++++\n+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*\n++****++++****++**++++****++++**++****++++****++**++++****++++**\n+**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**+\n++++++++****************++++++++++++++++****************++++++++\n+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*\n++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**\n+**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**+\n++++********++++****++++++++****++++********++++****++++++++****\n+*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*+\n++****++**++++****++++**++****++++****++**++++****++++**++****++\n+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*\n++++++++++++++++++++++++++++++++********************************\n+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+\n++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++\n+**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++*\n++++****++++****++++****++++********++++****++++****++++****++++\n+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*\n++****++++****++++****++++****++**++++****++++****++++****++++**\n+**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**+\n++++++++********++++++++****************++++++++********++++++++\n+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*\n++**++****++**++++**++****++**++**++**++++**++****++**++++**++**\n+**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**+\n++++********++++++++********++++****++++++++********++++++++****\n+*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*+\n++****++**++++**++****++**++++****++++**++****++**++++**++****++\n+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*\n++++++++++++++++********************************++++++++++++++++\n+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*\n++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++**\n+**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**+\n++++****++++********++++****++++****++++****++++++++****++++****\n+*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*+\n++****++++****++**++++****++++****++++****++++**++****++++****++\n+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*\n++++++++****************++++++++********++++++++++++++++********\n+*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*+\n++**++****++**++**++**++++**++****++**++++**++**++**++****++**++\n+**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++*\n++++********++++****++++++++********++++++++****++++********++++\n+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*\n++****++**++++****++++**++****++**++++**++****++++****++**++++**\n+**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**+\n", "+\n", "++++++++\n+*+*+*+*\n++**++**\n+**++**+\n++++****\n+*+**+*+\n++****++\n+**+*++*\n" ] }
2CODEFORCES
Below is a problem description that describes the problem. Write code in Python that appropriately solves the problem. ### Description: The semester is already ending, so Danil made an effort and decided to visit a lesson on harmony analysis to know how does the professor look like, at least. Danil was very bored on this lesson until the teacher gave the group a simple task: find 4 vectors in 4-dimensional space, such that every coordinate of every vector is 1 or - 1 and any two vectors are orthogonal. Just as a reminder, two vectors in n-dimensional space are considered to be orthogonal if and only if their scalar product is equal to zero, that is: <image>. Danil quickly managed to come up with the solution for this problem and the teacher noticed that the problem can be solved in a more general case for 2k vectors in 2k-dimensinoal space. When Danil came home, he quickly came up with the solution for this problem. Can you cope with it? Input The only line of the input contains a single integer k (0 ≤ k ≤ 9). Output Print 2k lines consisting of 2k characters each. The j-th character of the i-th line must be equal to ' * ' if the j-th coordinate of the i-th vector is equal to - 1, and must be equal to ' + ' if it's equal to + 1. It's guaranteed that the answer always exists. If there are many correct answers, print any. Examples Input 2 Output ++** +*+* ++++ +**+ Note Consider all scalar products in example: * Vectors 1 and 2: ( + 1)·( + 1) + ( + 1)·( - 1) + ( - 1)·( + 1) + ( - 1)·( - 1) = 0 * Vectors 1 and 3: ( + 1)·( + 1) + ( + 1)·( + 1) + ( - 1)·( + 1) + ( - 1)·( + 1) = 0 * Vectors 1 and 4: ( + 1)·( + 1) + ( + 1)·( - 1) + ( - 1)·( - 1) + ( - 1)·( + 1) = 0 * Vectors 2 and 3: ( + 1)·( + 1) + ( - 1)·( + 1) + ( + 1)·( + 1) + ( - 1)·( + 1) = 0 * Vectors 2 and 4: ( + 1)·( + 1) + ( - 1)·( - 1) + ( + 1)·( - 1) + ( - 1)·( + 1) = 0 * Vectors 3 and 4: ( + 1)·( + 1) + ( + 1)·( - 1) + ( + 1)·( - 1) + ( + 1)·( + 1) = 0 ### Input: 2 ### Output: ++++ +*+* ++** +**+ ### Input: 2 ### Output: ++++ +*+* ++** +**+ ### Code: p = [[0]] for i in range(int(input())): p = [t + t for t in p] + [[1 - q for q in t] + t for t in p] for t in p: print(''.join('+*'[q] for q in t))
630_M. Turn_38295
Vasya started working in a machine vision company of IT City. Vasya's team creates software and hardware for identification of people by their face. One of the project's know-how is a camera rotating around its optical axis on shooting. People see an eye-catching gadget — a rotating camera — come up to it to see it better, look into it. And the camera takes their photo at that time. What could be better for high quality identification? But not everything is so simple. The pictures from camera appear rotated too (on clockwise camera rotation frame the content becomes rotated counter-clockwise). But the identification algorithm can work only with faces that are just slightly deviated from vertical. Vasya was entrusted to correct the situation — to rotate a captured image so that image would be minimally deviated from vertical. Requirements were severe. Firstly, the picture should be rotated only on angle divisible by 90 degrees to not lose a bit of information about the image. Secondly, the frames from the camera are so huge and FPS is so big that adequate rotation speed is provided by hardware FPGA solution only. And this solution can rotate only by 90 degrees clockwise. Of course, one can apply 90 degrees turn several times but for the sake of performance the number of turns should be minimized. Help Vasya implement the program that by the given rotation angle of the camera can determine the minimum number of 90 degrees clockwise turns necessary to get a picture in which up direction deviation from vertical is minimum. The next figure contains frames taken from an unrotated camera, then from rotated 90 degrees clockwise, then from rotated 90 degrees counter-clockwise. Arrows show direction to "true up". <image> The next figure shows 90 degrees clockwise turn by FPGA hardware. <image> Input The only line of the input contains one integer x ( - 1018 ≤ x ≤ 1018) — camera angle in degrees. Positive value denotes clockwise camera rotation, negative — counter-clockwise. Output Output one integer — the minimum required number of 90 degrees clockwise turns. Examples Input 60 Output 1 Input -60 Output 3 Note When the camera is rotated 60 degrees counter-clockwise (the second example), an image from it is rotated 60 degrees clockwise. One 90 degrees clockwise turn of the image result in 150 degrees clockwise total rotation and deviation from "true up" for one turn is 150 degrees. Two 90 degrees clockwise turns of the image result in 240 degrees clockwise total rotation and deviation from "true up" for two turns is 120 degrees because 240 degrees clockwise equal to 120 degrees counter-clockwise. Three 90 degrees clockwise turns of the image result in 330 degrees clockwise total rotation and deviation from "true up" for three turns is 30 degrees because 330 degrees clockwise equal to 30 degrees counter-clockwise. From 60, 150, 120 and 30 degrees deviations the smallest is 30, and it it achieved in three 90 degrees clockwise turns.
import math, re, sys, string, operator, functools, fractions, collections sys.setrecursionlimit(10**7) dX= [-1, 1, 0, 0,-1, 1,-1, 1] dY= [ 0, 0,-1, 1, 1,-1,-1, 1] RI=lambda x=' ': list(map(int,input().split(x))) RS=lambda x=' ': input().rstrip().split(x) mod=int(1e9+7) eps=1e-6 ################################################# x=RI()[0] x%=360 if x>180: x=x-360 ans=0 val=abs(x) for i in range(1,4): x-=90 if x<-180: x=360+x if abs(x)<val: val=abs(x) ans=i print(ans)
{ "input": [ "-60\n", "60\n", "6678504591813508\n", "44\n", "225\n", "-45\n", "-358\n", "46\n", "-999999999999999415\n", "-999999999999999639\n", "-44\n", "-999999999999999325\n", "999999999999999326\n", "316\n", "359\n", "999999999999999416\n", "-135\n", "999999999999999639\n", "-316\n", "-314\n", "-313\n", "134\n", "0\n", "-226\n", "999999999999999596\n", "-999999999999999640\n", "999999999999999640\n", "227\n", "313\n", "999999999999999505\n", "-360\n", "479865961765156498\n", "-201035370138545377\n", "-999999999999999326\n", "-136\n", "-999999999999999506\n", "999999999999999504\n", "314\n", "-46\n", "441505850043460771\n", "999999999999999595\n", "136\n", "999999999999999340\n", "-999999999999999416\n", "272028913373922389\n", "-224\n", "201035370138545377\n", "358\n", "-441505850043460771\n", "141460527912396122\n", "-272028913373922389\n", "135\n", "-999999999999999594\n", "252890591709237675\n", "-227\n", "-999999999999999505\n", "-479865961765156498\n", "-999999999999999596\n", "999999999999999506\n", "45\n", "226\n", "-999999999999999595\n", "224\n", "-359\n", "999999999999999415\n", "999999999999999594\n", "315\n", "-361\n", "999999999999999325\n", "-999999999999999504\n", "361\n", "-225\n", "-999999999999999340\n", "360\n", "-6678504591813508\n", "-315\n", "-141460527912396122\n", "-252890591709237675\n", "-134\n", "2944906229956001\n", "251\n", "-504\n", "65\n", "6\n", "-35\n", "-477564621877249879\n", "-731911479516817236\n", "-77\n", "-855339415526476122\n", "1723388402989387964\n", "596\n", "33\n", "959624699764823086\n", "-255\n", "62673244837271274\n", "-413\n", "-410\n", "-472\n", "37\n", "1\n", "-231\n", "634496775386813230\n", "-1315489005576995761\n", "1118873704423165622\n", "207\n", "240\n", "546277534138071673\n", "-484\n", "476754570092225867\n", "-312513450343933234\n", "-214320298455044899\n", "-219\n", "-1287027209222040878\n", "266413096245385420\n", "586\n", "-29\n", "397147891104652603\n", "235722930896035434\n", "61\n", "1466312578812176748\n", "-1503133216326740481\n", "265550619207158672\n", "-238\n", "165806911853237067\n", "41\n", "-555854491550879269\n", "185239521360898918\n", "-351938669876156567\n", "25\n", "-241090077058320052\n", "394911851966691718\n", "-400\n", "-46566207526617020\n", "-1638150760258347909\n", "1157187599693957575\n", "84\n", "426\n", "19\n", "-282\n", "1267947863483633273\n", "1479447205276710261\n", "14\n", "-607\n", "1915898940585361562\n", "-802422614550017389\n", "707\n", "-16\n", "-1070488124117177147\n", "601\n", "-7923004858287577\n", "-186\n", "-221014111108243233\n", "-63789947951473336\n", "-115\n", "-75\n", "113\n", "1722935677651939\n", "9\n", "478\n", "-61\n", "-554\n", "94\n", "-664334082246340020\n", "-1222371078233263533\n", "-145\n", "-1508540364689755267\n", "1467909105292482935\n", "631\n", "57\n", "187829167135459333\n", "-355\n", "81562247892860421\n", "-580\n", "-662\n", "-746\n", "66\n", "2\n", "-409\n", "782858836143824647\n" ], "output": [ "3\n", "1\n", "2\n", "0\n", "2\n", "0\n", "0\n", "1\n", "3\n", "1\n", "0\n", "0\n", "0\n", "0\n", "0\n", "1\n", "2\n", "3\n", "0\n", "1\n", "1\n", "1\n", "0\n", "1\n", "3\n", "1\n", "3\n", "3\n", "3\n", "2\n", "0\n", "2\n", "2\n", "0\n", "2\n", "2\n", "2\n", "3\n", "3\n", "1\n", "3\n", "2\n", "0\n", "3\n", "3\n", "2\n", "2\n", "0\n", "3\n", "0\n", "1\n", "1\n", "1\n", "2\n", "1\n", "2\n", "2\n", "1\n", "2\n", "0\n", "3\n", "1\n", "2\n", "0\n", "1\n", "3\n", "0\n", "0\n", "0\n", "2\n", "0\n", "1\n", "0\n", "0\n", "2\n", "0\n", "0\n", "2\n", "3\n", "0\n", "3\n", "2\n", "1\n", "0\n", "0\n", "0\n", "0\n", "3\n", "0\n", "2\n", "3\n", "0\n", "2\n", "1\n", "0\n", "3\n", "3\n", "3\n", "0\n", "0\n", "1\n", "3\n", "0\n", "1\n", "2\n", "3\n", "3\n", "3\n", "0\n", "1\n", "1\n", "2\n", "1\n", "0\n", "3\n", "0\n", "3\n", "0\n", "1\n", "0\n", "0\n", "0\n", "1\n", "3\n", "0\n", "0\n", "0\n", "3\n", "0\n", "2\n", "3\n", "0\n", "0\n", "1\n", "1\n", "1\n", "1\n", "0\n", "1\n", "0\n", "0\n", "0\n", "1\n", "1\n", "1\n", "0\n", "0\n", "3\n", "3\n", "2\n", "2\n", "1\n", "1\n", "3\n", "3\n", "1\n", "0\n", "0\n", "1\n", "3\n", "2\n", "1\n", "1\n", "0\n", "2\n", "1\n", "1\n", "3\n", "1\n", "0\n", "0\n", "0\n", "2\n", "1\n", "0\n", "1\n", "0\n", "3\n", "3\n" ] }
2CODEFORCES
Below is a problem description that describes the problem. Write code in Python that appropriately solves the problem. ### Description: Vasya started working in a machine vision company of IT City. Vasya's team creates software and hardware for identification of people by their face. One of the project's know-how is a camera rotating around its optical axis on shooting. People see an eye-catching gadget — a rotating camera — come up to it to see it better, look into it. And the camera takes their photo at that time. What could be better for high quality identification? But not everything is so simple. The pictures from camera appear rotated too (on clockwise camera rotation frame the content becomes rotated counter-clockwise). But the identification algorithm can work only with faces that are just slightly deviated from vertical. Vasya was entrusted to correct the situation — to rotate a captured image so that image would be minimally deviated from vertical. Requirements were severe. Firstly, the picture should be rotated only on angle divisible by 90 degrees to not lose a bit of information about the image. Secondly, the frames from the camera are so huge and FPS is so big that adequate rotation speed is provided by hardware FPGA solution only. And this solution can rotate only by 90 degrees clockwise. Of course, one can apply 90 degrees turn several times but for the sake of performance the number of turns should be minimized. Help Vasya implement the program that by the given rotation angle of the camera can determine the minimum number of 90 degrees clockwise turns necessary to get a picture in which up direction deviation from vertical is minimum. The next figure contains frames taken from an unrotated camera, then from rotated 90 degrees clockwise, then from rotated 90 degrees counter-clockwise. Arrows show direction to "true up". <image> The next figure shows 90 degrees clockwise turn by FPGA hardware. <image> Input The only line of the input contains one integer x ( - 1018 ≤ x ≤ 1018) — camera angle in degrees. Positive value denotes clockwise camera rotation, negative — counter-clockwise. Output Output one integer — the minimum required number of 90 degrees clockwise turns. Examples Input 60 Output 1 Input -60 Output 3 Note When the camera is rotated 60 degrees counter-clockwise (the second example), an image from it is rotated 60 degrees clockwise. One 90 degrees clockwise turn of the image result in 150 degrees clockwise total rotation and deviation from "true up" for one turn is 150 degrees. Two 90 degrees clockwise turns of the image result in 240 degrees clockwise total rotation and deviation from "true up" for two turns is 120 degrees because 240 degrees clockwise equal to 120 degrees counter-clockwise. Three 90 degrees clockwise turns of the image result in 330 degrees clockwise total rotation and deviation from "true up" for three turns is 30 degrees because 330 degrees clockwise equal to 30 degrees counter-clockwise. From 60, 150, 120 and 30 degrees deviations the smallest is 30, and it it achieved in three 90 degrees clockwise turns. ### Input: -60 ### Output: 3 ### Input: 60 ### Output: 1 ### Code: import math, re, sys, string, operator, functools, fractions, collections sys.setrecursionlimit(10**7) dX= [-1, 1, 0, 0,-1, 1,-1, 1] dY= [ 0, 0,-1, 1, 1,-1,-1, 1] RI=lambda x=' ': list(map(int,input().split(x))) RS=lambda x=' ': input().rstrip().split(x) mod=int(1e9+7) eps=1e-6 ################################################# x=RI()[0] x%=360 if x>180: x=x-360 ans=0 val=abs(x) for i in range(1,4): x-=90 if x<-180: x=360+x if abs(x)<val: val=abs(x) ans=i print(ans)
659_E. New Reform_38299
Berland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities is connected by no more than one road. It is not guaranteed that you can get from any city to any other one, using only the existing roads. The President of Berland decided to make changes to the road system and instructed the Ministry of Transport to make this reform. Now, each road should be unidirectional (only lead from one city to another). In order not to cause great resentment among residents, the reform needs to be conducted so that there can be as few separate cities as possible. A city is considered separate, if no road leads into it, while it is allowed to have roads leading from this city. Help the Ministry of Transport to find the minimum possible number of separate cities after the reform. Input The first line of the input contains two positive integers, n and m — the number of the cities and the number of roads in Berland (2 ≤ n ≤ 100 000, 1 ≤ m ≤ 100 000). Next m lines contain the descriptions of the roads: the i-th road is determined by two distinct integers xi, yi (1 ≤ xi, yi ≤ n, xi ≠ yi), where xi and yi are the numbers of the cities connected by the i-th road. It is guaranteed that there is no more than one road between each pair of cities, but it is not guaranteed that from any city you can get to any other one, using only roads. Output Print a single integer — the minimum number of separated cities after the reform. Examples Input 4 3 2 1 1 3 4 3 Output 1 Input 5 5 2 1 1 3 2 3 2 5 4 3 Output 0 Input 6 5 1 2 2 3 4 5 4 6 5 6 Output 1 Note In the first sample the following road orientation is allowed: <image>, <image>, <image>. The second sample: <image>, <image>, <image>, <image>, <image>. The third sample: <image>, <image>, <image>, <image>, <image>.
import sys from math import sqrt, gcd, ceil, log # from bisect import bisect, bisect_left from collections import defaultdict, Counter, deque # from heapq import heapify, heappush, heappop input = sys.stdin.readline read = lambda: list(map(int, input().strip().split())) sys.setrecursionlimit(200000) def main(): n, m = read() adj = defaultdict(list) visited = defaultdict(int) # visited for i in range(m): x, y = read() adj[x].append(y) adj[y].append(x) def dfs(ver): parent = defaultdict(int) stk = [(ver,0)] visited[ver] = 1 parent[ver] = 0 while stk: node, par = stk.pop() for child in adj[node]: if child == par:continue elif not visited[child]: visited[child] = 1 parent[child] = node stk.append((child, node)) elif parent[child] != node: return(0) return(1) ans = 0 for i in range(1, n+1): if not visited[i]: ans += dfs(i) # print(i, visited) print(ans) # if __name__ == "__main__": main()
{ "input": [ "5 5\n2 1\n1 3\n2 3\n2 5\n4 3\n", "4 3\n2 1\n1 3\n4 3\n", "6 5\n1 2\n2 3\n4 5\n4 6\n5 6\n", "10 45\n3 5\n2 3\n4 8\n2 5\n6 8\n5 7\n2 1\n3 7\n5 10\n6 1\n9 4\n3 6\n9 10\n6 7\n1 7\n7 9\n6 9\n9 3\n4 2\n2 6\n5 6\n5 8\n3 4\n10 8\n7 8\n4 6\n9 1\n5 9\n7 4\n1 10\n9 2\n2 8\n6 10\n9 8\n1 5\n7 2\n10 3\n3 8\n4 10\n4 1\n10 7\n1 3\n1 8\n10 2\n4 5\n", "20 20\n16 3\n15 14\n6 14\n13 19\n7 13\n3 13\n3 2\n17 11\n14 20\n19 10\n4 13\n3 8\n18 4\n12 7\n6 3\n11 13\n17 19\n5 14\n9 2\n11 1\n", "2 1\n1 2\n", "5 5\n1 2\n2 3\n3 4\n4 5\n5 2\n", "4 4\n1 2\n2 3\n3 4\n4 1\n", "10 45\n3 5\n2 3\n4 8\n2 5\n6 8\n5 7\n2 1\n3 7\n5 10\n6 1\n9 4\n3 6\n9 10\n6 7\n1 7\n7 9\n6 9\n9 3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 4\n3 1\n2 10\n6 7\n1 7\n7 9\n6 9\n9 3\n4 2\n2 6\n5 6\n5 8\n3 4\n10 8\n7 8\n4 6\n9 1\n5 5\n7 4\n1 10\n9 2\n2 8\n6 10\n9 8\n1 5\n7 2\n10 6\n3 8\n2 10\n1 1\n10 7\n1 3\n1 8\n10 2\n4 10\n", "10 45\n3 5\n2 3\n4 8\n3 5\n6 8\n5 7\n2 1\n3 7\n5 10\n6 1\n9 8\n3 1\n2 10\n8 7\n1 7\n7 9\n6 9\n9 3\n2 2\n2 6\n5 6\n5 8\n6 4\n10 8\n7 8\n4 6\n9 1\n5 5\n7 4\n1 10\n9 2\n2 8\n6 10\n9 8\n1 5\n7 2\n9 3\n3 8\n2 10\n1 1\n10 7\n1 3\n1 8\n10 2\n4 10\n", "10 45\n3 5\n2 3\n4 8\n2 5\n9 8\n5 7\n2 1\n4 7\n5 10\n6 2\n9 4\n3 6\n9 10\n6 7\n1 7\n7 9\n6 9\n9 3\n4 2\n2 6\n5 6\n5 8\n3 4\n10 8\n7 8\n4 6\n9 1\n5 9\n7 4\n1 10\n9 2\n2 8\n6 10\n9 8\n1 5\n7 2\n10 3\n3 8\n4 10\n4 1\n10 7\n1 3\n1 8\n10 2\n4 5\n", "20 20\n16 3\n15 1\n6 14\n13 19\n7 13\n3 13\n3 2\n17 12\n14 20\n19 10\n4 11\n3 8\n18 4\n12 7\n6 3\n11 13\n17 19\n5 14\n9 2\n11 1\n", "10 45\n3 5\n2 3\n4 8\n2 5\n6 7\n5 7\n4 1\n3 7\n5 10\n6 1\n9 4\n3 7\n9 10\n6 7\n1 7\n7 9\n6 9\n9 3\n4 2\n2 6\n5 6\n5 8\n3 4\n10 8\n7 8\n4 6\n9 1\n5 5\n7 4\n1 10\n9 2\n2 8\n6 10\n9 8\n1 5\n7 2\n10 3\n3 8\n4 10\n4 1\n10 7\n1 3\n1 8\n10 2\n4 5\n" ], "output": [ "0", "1", "1", "0", "0", "1", "0", "0", "0\n", "1\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "1\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n" ] }
2CODEFORCES
Below is a problem description that describes the problem. Write code in Python that appropriately solves the problem. ### Description: Berland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities is connected by no more than one road. It is not guaranteed that you can get from any city to any other one, using only the existing roads. The President of Berland decided to make changes to the road system and instructed the Ministry of Transport to make this reform. Now, each road should be unidirectional (only lead from one city to another). In order not to cause great resentment among residents, the reform needs to be conducted so that there can be as few separate cities as possible. A city is considered separate, if no road leads into it, while it is allowed to have roads leading from this city. Help the Ministry of Transport to find the minimum possible number of separate cities after the reform. Input The first line of the input contains two positive integers, n and m — the number of the cities and the number of roads in Berland (2 ≤ n ≤ 100 000, 1 ≤ m ≤ 100 000). Next m lines contain the descriptions of the roads: the i-th road is determined by two distinct integers xi, yi (1 ≤ xi, yi ≤ n, xi ≠ yi), where xi and yi are the numbers of the cities connected by the i-th road. It is guaranteed that there is no more than one road between each pair of cities, but it is not guaranteed that from any city you can get to any other one, using only roads. Output Print a single integer — the minimum number of separated cities after the reform. Examples Input 4 3 2 1 1 3 4 3 Output 1 Input 5 5 2 1 1 3 2 3 2 5 4 3 Output 0 Input 6 5 1 2 2 3 4 5 4 6 5 6 Output 1 Note In the first sample the following road orientation is allowed: <image>, <image>, <image>. The second sample: <image>, <image>, <image>, <image>, <image>. The third sample: <image>, <image>, <image>, <image>, <image>. ### Input: 5 5 2 1 1 3 2 3 2 5 4 3 ### Output: 0 ### Input: 4 3 2 1 1 3 4 3 ### Output: 1 ### Code: import sys from math import sqrt, gcd, ceil, log # from bisect import bisect, bisect_left from collections import defaultdict, Counter, deque # from heapq import heapify, heappush, heappop input = sys.stdin.readline read = lambda: list(map(int, input().strip().split())) sys.setrecursionlimit(200000) def main(): n, m = read() adj = defaultdict(list) visited = defaultdict(int) # visited for i in range(m): x, y = read() adj[x].append(y) adj[y].append(x) def dfs(ver): parent = defaultdict(int) stk = [(ver,0)] visited[ver] = 1 parent[ver] = 0 while stk: node, par = stk.pop() for child in adj[node]: if child == par:continue elif not visited[child]: visited[child] = 1 parent[child] = node stk.append((child, node)) elif parent[child] != node: return(0) return(1) ans = 0 for i in range(1, n+1): if not visited[i]: ans += dfs(i) # print(i, visited) print(ans) # if __name__ == "__main__": main()
682_B. Alyona and Mex_38303
Someone gave Alyona an array containing n positive integers a1, a2, ..., an. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not apply any operation to the array at all. Formally, after applying some operations Alyona will get an array of n positive integers b1, b2, ..., bn such that 1 ≤ bi ≤ ai for every 1 ≤ i ≤ n. Your task is to determine the maximum possible value of mex of this array. Mex of an array in this problem is the minimum positive integer that doesn't appear in this array. For example, mex of the array containing 1, 3 and 4 is equal to 2, while mex of the array containing 2, 3 and 2 is equal to 1. Input The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of elements in the Alyona's array. The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the elements of the array. Output Print one positive integer — the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. Examples Input 5 1 3 3 3 6 Output 5 Input 2 2 1 Output 3 Note In the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5. To reach the answer to the second sample case one must not decrease any of the array elements.
import sys n = int(input()) arr = list(map(int,input().split())) arr.sort() ans = 1 for i in range(1,n+1): if arr[i-1]>=ans: ans+=1 print(ans)
{ "input": [ "5\n1 3 3 3 6\n", "2\n2 1\n", "4\n1 2 2 3\n", "4\n1 4 1 1\n", "2\n3 3\n", "4\n1 2 1 2\n", "3\n3 3 1\n", "3\n2 4 1\n", "2\n1 1\n", "3\n2 2 2\n", "4\n2 2 2 1\n", "4\n2 2 2 3\n", "7\n1 2 2 2 5 5 1\n", "4\n1 4 4 3\n", "4\n2 2 3 2\n", "4\n2 4 1 2\n", "3\n4 3 4\n", "4\n1 1 1 1\n", "3\n1 1 1\n", "5\n1 1 1 1 10000\n", "4\n2 2 2 4\n", "20\n1 1 1 1 1 1 1 1 1 1 8 8 8 8 8 8 8 8 8 8\n", "4\n1 3 2 1\n", "3\n3 3 3\n", "3\n1 1 4\n", "4\n2 1 4 1\n", "4\n2 2 2 2\n", "3\n2 1 2\n", "4\n3 3 3 4\n", "4\n4 4 4 4\n", "7\n1 2 2 2 2 2 4\n", "4\n3 3 1 1\n", "4\n1 4 2 4\n", "4\n4 1 4 4\n", "4\n4 4 3 4\n", "4\n1 1 3 1\n", "3\n1 1 2\n", "4\n2 3 4 1\n", "4\n8 8 8 8\n", "8\n1 1 1 1 2 2 3 40\n", "4\n3 4 3 1\n", "4\n2 4 3 3\n", "10\n1 1 1 1 1 1 1 1 2 3\n", "1\n2\n", "4\n1 1 1 2\n", "2\n2 3\n", "3\n3 2 1\n", "3\n2 3 3\n", "5\n1 1 1 3 4\n", "4\n1 1 1 3\n", "4\n2 3 3 3\n", "4\n3 3 3 3\n", "4\n2 2 3 4\n", "2\n2 2\n", "4\n4 4 4 2\n", "4\n3 1 3 3\n", "4\n4 4 2 3\n", "10\n1 1 1 10000000 10000000 10000000 10000000 10000000 10000000 10000000\n", "3\n4 2 2\n", "4\n1 3 4 1\n", "3\n4 4 2\n", "4\n1 1 2 2\n", "1\n1000000000\n", "4\n1 1 4 4\n", "5\n5 6 6 6 7\n", "3\n3 2 2\n", "15\n1 2 2 20 23 25 28 60 66 71 76 77 79 99 100\n", "11\n1 1 1 1 1 1 1 1 1 3 3\n", "3\n2 1 1\n", "2\n1 3\n", "7\n1 3 3 3 3 3 6\n", "4\n1 1 2 1\n", "3\n3 1 1\n", "4\n4 3 3 4\n", "4\n2 4 4 2\n", "10\n1 1 1 1 1 1 1 1 1 100\n", "4\n3 3 1 2\n", "3\n4 4 4\n", "3\n4 1 4\n", "1\n1\n", "3\n4 3 3\n", "5\n1 1 1 1 2\n", "4\n2 2 3 3\n", "3\n4 2 3\n", "3\n1 3 4\n", "5\n1 1 1 1 1\n", "4\n2 2 1 3\n", "4\n1 4 0 1\n", "7\n1 2 2 2 10 5 1\n", "4\n1 1 1 0\n", "20\n1 1 1 1 1 1 1 1 1 1 8 8 8 8 8 8 8 8 4 8\n", "8\n1 1 1 1 2 4 3 40\n", "15\n1 2 2 20 23 25 28 60 66 71 76 77 79 120 100\n", "2\n5 3\n", "4\n1 0 1 2\n", "3\n3 5 1\n", "2\n1 2\n", "3\n2 2 3\n", "4\n2 2 2 0\n", "4\n2 1 2 3\n", "4\n1 4 2 3\n", "4\n2 2 5 2\n", "4\n2 5 1 2\n", "3\n5 4 4\n", "3\n1 0 1\n", "5\n1 1 1 0 10000\n", "4\n2 2 2 8\n", "4\n2 3 2 1\n", "3\n3 4 3\n", "3\n1 0 4\n", "4\n2 1 8 1\n", "4\n2 0 2 1\n", "3\n2 1 3\n", "4\n3 3 3 2\n", "4\n7 4 4 4\n", "7\n1 2 2 2 2 2 3\n", "4\n3 0 1 1\n", "4\n1 2 2 4\n", "4\n4 1 1 4\n", "4\n3 4 3 4\n", "4\n1 1 0 1\n", "3\n1 1 3\n", "4\n2 0 1 1\n", "4\n8 11 8 8\n", "4\n3 2 3 1\n", "10\n1 1 1 1 1 1 1 1 3 3\n", "1\n3\n", "4\n2 1 2 1\n", "3\n1 2 1\n", "3\n2 3 1\n", "5\n1 0 1 3 4\n", "4\n0 1 1 3\n", "4\n4 3 3 3\n", "4\n3 3 2 2\n", "4\n2 2 1 4\n", "2\n0 1\n", "4\n4 4 4 1\n", "4\n5 1 3 3\n", "4\n4 4 3 3\n", "10\n1 1 1 10000000 10000000 10000000 10000000 10000000 10000000 11000000\n", "3\n6 2 2\n", "4\n1 3 4 0\n", "3\n4 2 4\n", "4\n1 2 2 2\n", "1\n1001000000\n", "4\n1 1 4 5\n", "5\n5 6 6 2 7\n", "11\n1 1 1 1 1 1 2 1 1 3 3\n", "3\n0 1 1\n", "2\n1 6\n", "7\n1 3 2 3 3 3 6\n", "4\n2 1 7 1\n", "3\n2 2 1\n", "4\n2 4 4 3\n", "10\n1 1 1 1 1 1 0 1 1 100\n", "4\n3 3 1 4\n", "3\n4 4 5\n", "3\n4 1 5\n", "3\n4 1 3\n", "5\n1 0 1 1 2\n", "4\n1 2 3 3\n", "3\n4 3 1\n", "3\n1 5 4\n", "5\n1 0 1 1 1\n", "5\n1 1 3 3 6\n", "4\n2 2 1 0\n", "4\n2 1 0 1\n", "2\n3 6\n", "4\n2 0 1 2\n", "3\n3 5 2\n", "2\n1 0\n", "3\n4 2 1\n", "4\n2 1 2 0\n", "4\n4 1 2 3\n", "7\n1 2 3 2 10 5 1\n", "4\n1 4 4 6\n", "4\n2 2 5 3\n", "4\n2 5 1 4\n", "3\n5 4 8\n", "4\n1 2 1 0\n", "3\n1 0 2\n", "5\n1 0 1 0 10000\n", "4\n2 2 3 0\n", "20\n1 1 1 1 1 1 1 1 1 0 8 8 8 8 8 8 8 8 4 8\n", "4\n4 3 2 1\n", "3\n5 4 3\n" ], "output": [ "5\n", "3\n", "4\n", "3\n", "3\n", "3\n", "4\n", "4\n", "2\n", "3\n", "3\n", "4\n", "5\n", "5\n", "4\n", "4\n", "4\n", "2\n", "2\n", "3\n", "4\n", "9\n", "4\n", "4\n", "3\n", "4\n", "3\n", "3\n", "5\n", "5\n", "4\n", "4\n", "5\n", "5\n", "5\n", "3\n", "3\n", "5\n", "5\n", "5\n", "5\n", "5\n", "4\n", "2\n", "3\n", "3\n", "4\n", "4\n", "4\n", "3\n", "4\n", "4\n", "5\n", "3\n", "5\n", "4\n", "5\n", "9\n", "4\n", "4\n", "4\n", "3\n", "2\n", "4\n", "6\n", "4\n", "15\n", "4\n", "3\n", "3\n", "5\n", "3\n", "3\n", "5\n", "5\n", "3\n", "4\n", "4\n", "4\n", "2\n", "4\n", "3\n", "4\n", "4\n", "4\n", "2\n", "4\n", "3\n", "5\n", "2\n", "9\n", "6\n", "15\n", "3\n", "3\n", "4\n", "3\n", "4\n", "3\n", "4\n", "5\n", "4\n", "4\n", "4\n", "2\n", "3\n", "4\n", "4\n", "4\n", "3\n", "4\n", "3\n", "4\n", "4\n", "5\n", "4\n", "3\n", "4\n", "4\n", "5\n", "2\n", "3\n", "3\n", "5\n", "4\n", "4\n", "2\n", "3\n", "3\n", "4\n", "4\n", "3\n", "5\n", "4\n", "4\n", "2\n", "5\n", "5\n", "5\n", "9\n", "4\n", "4\n", "4\n", "3\n", "2\n", "4\n", "6\n", "4\n", "2\n", "3\n", "5\n", "4\n", "3\n", "5\n", "3\n", "5\n", "4\n", "4\n", "4\n", "3\n", "4\n", "4\n", "4\n", "2\n", "5\n", "3\n", "3\n", "3\n", "3\n", "4\n", "2\n", "4\n", "3\n", "5\n", "6\n", "5\n", "5\n", "5\n", "4\n", "3\n", "3\n", "3\n", "4\n", "9\n", "5\n", "4\n" ] }
2CODEFORCES
Below is a problem description that describes the problem. Write code in Python that appropriately solves the problem. ### Description: Someone gave Alyona an array containing n positive integers a1, a2, ..., an. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not apply any operation to the array at all. Formally, after applying some operations Alyona will get an array of n positive integers b1, b2, ..., bn such that 1 ≤ bi ≤ ai for every 1 ≤ i ≤ n. Your task is to determine the maximum possible value of mex of this array. Mex of an array in this problem is the minimum positive integer that doesn't appear in this array. For example, mex of the array containing 1, 3 and 4 is equal to 2, while mex of the array containing 2, 3 and 2 is equal to 1. Input The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of elements in the Alyona's array. The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the elements of the array. Output Print one positive integer — the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. Examples Input 5 1 3 3 3 6 Output 5 Input 2 2 1 Output 3 Note In the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5. To reach the answer to the second sample case one must not decrease any of the array elements. ### Input: 5 1 3 3 3 6 ### Output: 5 ### Input: 2 2 1 ### Output: 3 ### Code: import sys n = int(input()) arr = list(map(int,input().split())) arr.sort() ans = 1 for i in range(1,n+1): if arr[i-1]>=ans: ans+=1 print(ans)
705_A. Hulk_38307
Dr. Bruce Banner hates his enemies (like others don't). As we all know, he can barely talk when he turns into the incredible Hulk. That's w