├── 126 └── 126.cpp ├── 592 ├── a.cpp └── create.sh ├── 1234 └── main.cpp ├── 11488 └── 11488.cpp ├── 12506 └── 12506.cpp ├── 12526 └── 12526.cpp ├── .gitattributes ├── .gitignore ├── 1-sir ├── 1-sir.cpp └── main.cpp ├── 101hack29 ├── a.cpp ├── b.cpp └── c.cpp ├── 10298 - Power Strings └── main.cpp ├── 1056_Factors_and_Multiples └── main.cpp ├── 10679 - I Love Strings!! └── main.cpp ├── 1076_Design_Labirints └── main.cpp ├── 1081_DFSr_–_Depth_hierarchy └── main.cpp ├── 1082_Connected_Components └── main.cpp ├── 1085_Babel └── main.cpp ├── 1100_Knight_Moves └── main.cpp ├── 1123_Route_Change └── main.cpp ├── 11280 - Flying to Fredericton └── main.cpp ├── 1128_Come_and_go └── main.cpp ├── 1148_Countries_at_War └── main.cpp ├── 1152_Dark_Roads └── main.cpp ├── 11888 - Abnormal 89 └── main.cpp ├── 1191_Tree_Recovert └── main.cpp ├── 1195_BST └── main.cpp ├── 1195_Binary_Search_Tree └── main.cpp ├── 11d └── 11d.cpp ├── 1200_BST_operation_I └── main.cpp ├── 1209_St_petersburg └── main.cpp ├── 1213_ones └── main.cpp ├── 126B ├── 126b.cpp └── main.cpp ├── 12perm └── 12perm.cpp ├── 1302_Joining_Couples └── main.cpp ├── 1344_Telecommunication_Partners └── main.cpp ├── 1362_My_T-Shirt_Suits_Me └── main.cpp ├── 1391_Almost_Shortest_PAth └── main.cpp ├── 247E └── 247e.cpp ├── 2sah └── 2sah.cpp ├── 2sec └── main.cpp ├── 321A.cpp ├── 321B.cpp ├── 321C.cpp ├── 321D.cpp ├── 3color └── main.cpp ├── 525A └── 525a.cpp ├── 525B └── 525b.cpp ├── 525D └── 525d.cpp ├── 525E └── 525e.cpp ├── 534A └── 534a.cpp ├── 534B └── 534b.cpp ├── 534C └── 534c.cpp ├── 534D └── 534d.cpp ├── 534E └── 534e.cpp ├── 5644130656976896careercup └── 5644130656976896careercup.cpp ├── 584C └── 584c.cpp ├── 6898. Substring Problem └── main.cpp ├── 7segmente ├── 2numere │ └── 2numere.cpp └── 7segmente.cpp ├── AB └── main.cpp ├── ABCAcm └── abcacm.cpp ├── ACM-LA4682 └── acm-la4682.cpp ├── ACMLA-3562 └── acmla-3562.cpp ├── ACMTIMUS1306 └── acmtimus1306.cpp ├── ACMTJU-1056. Labyrinth └── main.cpp ├── ACMTJU2913. Frequent values └── main.cpp ├── ACMTJU3166 └── acmtju3166.cpp ├── ACM_LA-6140 - Joining Couples └── main.cpp ├── ADN ├── ADN.layout └── main.cpp ├── ADN2 └── main.cpp ├── APDM └── main.cpp ├── APM └── main.cpp ├── AVD └── main.cpp ├── AVL_Trees └── main.cpp ├── Ab2 └── ab2.cpp ├── Abc2 └── main.cpp ├── Acces ├── acces.cpp └── main.cpp ├── Adapost └── main.cpp ├── Aho-Corasick └── main.cpp ├── AhoCorasick └── ahocorasick.cpp ├── Ai └── main.cpp ├── AiB └── main.cpp ├── Aib ├── aib.cpp └── main.cpp ├── Albinuta └── main.cpp ├── Alee ├── main.cpp └── sursa_pentru_teste.cpp ├── Alegeri └── main.cpp ├── Alge └── main.cpp ├── Algebra2 └── algebra2.cpp ├── Algola ├── algola.cpp └── main.cpp ├── Algoritm └── algoritm.cpp ├── Algsort └── main.cpp ├── Alianta └── alianta.cpp ├── Alibaba └── main.cpp ├── Alpin └── main.cpp ├── Ambuscada └── main.cpp ├── Amedie └── main.cpp ├── Amici └── main.cpp ├── Amici2 └── main.cpp ├── Andrei └── main.cpp ├── Android └── android.cpp ├── Antobroasca └── main.cpp ├── Antocod └── main.cpp ├── Aparare └── main.cpp ├── Aparitii └── main.cpp ├── Apm ├── apm.cpp └── main.cpp ├── Arac └── main.cpp ├── Arb └── main.cpp ├── Arb2 └── main.cpp ├── ArbNR ├── arbnrsolofiicial └── main.cpp ├── Arbfind └── main.cpp ├── Arbint ├── arbint.cpp └── main.cpp ├── Arbore └── main.cpp ├── Arbore3 └── main.cpp ├── Arbore5 └── main.cpp ├── Arborest └── main.cpp ├── Arbsum └── main.cpp ├── Arbvalmax └── arbvalmax.cpp ├── Arhipeleag ├── arhipelag.in'' └── main.cpp ├── Aria ├── Aria.cbp ├── Aria.depend ├── aria.cpp ├── bin │ └── Debug │ │ └── Aria └── main.cpp ├── Arie └── main.cpp ├── Asfalt └── main.cpp ├── Asmax └── main.cpp ├── Asmin └── main.cpp ├── Atac └── main.cpp ├── Atac2 └── main.cpp ├── Ausoara └── main.cpp ├── Autobuze └── main.cpp ├── Autobuze2 └── main.cpp ├── Autostrazi └── main.cpp ├── Avarcolaci ├── avarcolaci.cpp └── main.cpp ├── Azerah └── azerah.cpp ├── BMatrix └── main.cpp ├── Bacterii └── main.cpp ├── Bal └── main.cpp ├── Bal2 └── main.cpp ├── Banana └── main.cpp ├── Bancomat └── main.cpp ├── Banuti └── main.cpp ├── Baruri └── main.cpp ├── Base3 └── main.cpp ├── Becuri └── main.cpp ├── Beep └── main.cpp ├── Bellmanford ├── bellmanford.cpp └── main.cpp ├── Bemo └── main.cpp ├── Ben └── main.cpp ├── Benzina2 └── main.cpp ├── Beri └── main.cpp ├── Betasah └── main.cpp ├── Bete2 ├── bete2.cpp ├── bete2100.cpp └── bete22.cpp ├── Bfs └── main.cpp ├── Biconex ├── biconex.cpp └── main.cpp ├── Bila └── main.cpp ├── Bile7 └── main.cpp ├── Bilete ├── ;q └── bilete.cpp ├── Binar └── main.cpp ├── Biscuiti ├── biscuiti.cpp └── main.cpp ├── Biti └── main.cpp ├── Biti2 ├── biti2.cpp └── biti2sergiu.cpp ├── Biti3 └── main.cpp ├── Bitonic └── main.cpp ├── Bleach └── main.cpp ├── Blinnet └── main.cpp ├── Blis └── main.cpp ├── Bmatrix └── bmatrix.cpp ├── Bool └── main.cpp ├── Boom └── main.cpp ├── Borcane └── main.cpp ├── Bottom └── main.cpp ├── Brazi └── main.cpp ├── Bridge └── main.cpp ├── Buline ├── Unknown ├── buline.cpp ├── buline2.cpp ├── ere └── main.cpp ├── Bursa └── main.cpp ├── Burse └── burse.cpp ├── CCM └── main.cpp ├── CF163-E - AhoCorasick + Aib + alte smenuri └── main.cpp ├── CF25E └── main.cpp ├── CF346B. Lucky Common Subsequence └── main.cpp ├── CF_-14D._Two_Paths └── main.cpp ├── CF_-_120H._Brevity_is_Soul_of_Wit └── main.cpp ├── CF_-_132E._Bits_of_merry_old_England └── main.cpp ├── CF_-_161D._Distance_in_Tree └── main.cpp ├── CF_-_166D._Shoe_Store └── main.cpp ├── CF_-_186A._Cut_Ribbon └── main.cpp ├── CF_-_21D._Traveling_Graph └── main.cpp ├── CF_-_343D._Water_Tree └── main.cpp ├── CF_-_397E._On_Changing_Tree └── main.cpp ├── CF_-_406D._Hill_Climbing └── main.cpp ├── CF_-_42E._Baldman_and_the_military └── main.cpp ├── CF_-_45H._Road_Problem └── main.cpp ├── CF_-_52C._Circular_RMQ └── main.cpp ├── CF_-_78E._Evacuation └── main.cpp ├── CF_236_A └── main.cpp ├── CF_236_B └── main.cpp ├── CF_236_C └── main.cpp ├── CF_236_D └── main.cpp ├── CF_236_E └── main.cpp ├── CF_237_A └── main.cpp ├── CF_237_B └── main.cpp ├── CF_237_C └── main.cpp ├── CF_237_D └── main.cpp ├── CF_237_E └── main.cpp ├── CF_272_D └── main.cpp ├── CF_273_C └── main.cpp ├── CF_277E._Binary_Tree_on_Plane └── main.cpp ├── CF_290A └── main.cpp ├── CF_290B └── main.cpp ├── CF_290C └── main.cpp ├── CF_290D └── main.cpp ├── CF_290E └── main.cpp ├── CF_379A └── main.cpp ├── CF_379B └── main.cpp ├── CODECHEF-PPTREE └── codechef-pptree.cpp ├── COT ├── cot.cpp └── cot2.cpp ├── CPal └── main.cpp ├── Cabana └── main.cpp ├── Cablaj └── main.cpp ├── Cadrane └── main.cpp ├── Cai └── main.cpp ├── Caibicol └── main.cpp ├── Cal └── main.cpp ├── Calatorie_intraplanetara └── main.cpp ├── Camion ├── camion.cpp └── main.cpp ├── Camion2 └── main.cpp ├── Camionas └── main.cpp ├── Campion └── main.cpp ├── Campion_-_Honest └── main.cpp ├── Campion_-_Razboi └── main.cpp ├── Campion_-_Trmv └── main.cpp ├── Campion_-_Zmeu └── main.cpp ├── Campion_-_apm └── main.cpp ├── Campion_-_auto2 └── main.cpp ├── Campion_-_caini └── main.cpp ├── Carnati └── main.cpp ├── Carte └── main.cpp ├── Carti └── main.cpp ├── Carti2 └── main.cpp ├── Carti3 ├── carti3.cpp └── main.cpp ├── Cartite └── cartite.cpp ├── Cast └── main.cpp ├── Castel └── main.cpp ├── Casute └── main.cpp ├── Catun └── main.cpp ├── Cautbin ├── cautbin.cpp └── main.cpp ├── Ceas2 └── main.cpp ├── Ceas3 └── ceas3.cpp ├── Centru └── main.cpp ├── Cerc5 └── cerc5.cpp ├── Cercuri └── main.cpp ├── Cercuri3 └── main.cpp ├── Cezar ├── main └── main.cpp ├── Char └── char.cpp ├── Chiftea └── main.cpp ├── Ciclu └── main.cpp ├── Ciclu2 └── ciclu2.cpp ├── Ciclueuler ├── ciclueuler.cpp └── main.cpp ├── Cifre3 ├── Ciclul_Hamiltonian_de_Cost_minim │ └── main.cpp ├── cifre4 └── main.cpp ├── Cifre4 └── cifre4.cpp ├── Cifru2 └── main.cpp ├── CityLog └── main.cpp ├── Ciuperci └── main.cpp ├── Ciur ├── ciur.cpp └── main.cpp ├── ClassicTask ├── classictask.cpp └── main.cpp ├── Clepsidra └── main.cpp ├── Cmcm └── cmcm.cpp ├── Cmlsc ├── cmlsc.cpp └── main.cpp ├── Codechef ├── chefst.cpp └── planediv.cpp ├── CodejamA └── codejama.cpp ├── CodejamB └── codejamb.cpp ├── Codificare └── main.cpp ├── Coins └── main.cpp ├── Collar └── main.cpp ├── Color └── main.cpp ├── Color5 └── main.cpp ├── Colorare ├── colorare.cpp └── main.cpp ├── Colorare2 ├── colorare2.cpp └── main.cpp ├── Combinari ├── combinari.cpp └── main.cpp ├── Coment └── main.cpp ├── Comoditate └── comoditate.cpp ├── Compact └── main.cpp ├── Compania └── main.cpp ├── Compresie └── main.cpp ├── Compress ├── compress.cpp └── main.cpp ├── Compute-GameHR └── compute-gamehr.cpp ├── Concert └── main.cpp ├── Concert2 ├── concert2.cpp └── main.cpp ├── Conexiuni └── main.cpp ├── Confuzie └── main.cpp ├── Congr └── main.cpp ├── Control2 └── main.cpp ├── Controlor └── main.cpp ├── CookingTheBook └── cookingthebook.cpp ├── Copaci2 └── main.cpp ├── CostPerm └── main.cpp ├── Count └── main.cpp ├── Courier └── main.cpp ├── Crescator ├── crescator1.cpp └── crescator100.cpp ├── Criptare2 └── criptare2.cpp ├── Cristal └── main.cpp ├── Cristale └── main.cpp ├── Critice └── main.cpp ├── Critice2 └── main.cpp ├── Croco └── main.cpp ├── Cruce └── main.cpp ├── Ctc ├── ctc.cpp └── main.cpp ├── Cuburi3 └── main.cpp ├── Cuburi5 └── main.cpp ├── Culmi └── main.cpp ├── Culori └── main.cpp ├── Culori3 └── main.cpp ├── Cuplaj ├── cuplaj.cpp └── main.cpp ├── Curatenie └── main.cpp ├── Curcubeu └── main.cpp ├── Curent └── main.cpp ├── Curs Valutar └── main.cpp ├── Custi └── main.cpp ├── Cutii └── main.cpp ├── Cuvinte2 └── cuvinte2.cpp ├── Dame2 └── main.cpp ├── Damesah ├── damesah.cpp └── main.cpp ├── Dans └── main.cpp ├── Darb └── darb.cpp ├── Dcmcp └── main.cpp ├── Deque ├── deque.cpp └── main.cpp ├── Derdelus └── main.cpp ├── Desc2 └── main.cpp ├── Descompuneri └── main.cpp ├── Desen └── main.cpp ├── Desen2 └── main.cpp ├── Dfs ├── dfs.cpp └── main.cpp ├── Diamante └── main.cpp ├── Diff └── main.cpp ├── Difprim ├── difprim(1).cpp ├── difprim.cpp ├── difprimADEVARATULAMEU.cpp ├── difprimadoua.cpp └── difreofpih.cpp ├── Dijkstra ├── dijkstra.cpp └── main.cpp ├── Dinozaur └── main.cpp ├── Dir └── main.cpp ├── Disconnect-cb └── main.cpp ├── Disconnect ├── disconnect └── disconnect.cpp ├── Disjoin └── disjoin.cpp ├── Disjoint ├── disjoint.cpp └── main.cpp ├── Dist2 └── main.cpp ├── Distanta └── distanta.cpp ├── Distante └── main.cpp ├── Distincte └── main.cpp ├── Div4 └── main.cpp ├── DivisorGraph └── divisorgraph.cpp ├── Divisorgraph └── divisorgraph.cpp ├── Diviz └── main.cpp ├── Diviz2 └── main.cpp ├── Divizor_si_multiplu └── main.cpp ├── Divizori └── main.cpp ├── Divizoriprimi └── Divizori_primi_2.cpp ├── Divmul └── main.cpp ├── Divprim └── divprim.cpp ├── Doipe └── main.cpp ├── Domino2 └── main.cpp ├── Dominouri └── main.cpp ├── Dosare └── main.cpp ├── Dragonas └── main.cpp ├── Dreapta └── main.cpp ├── DreptPal └── main.cpp ├── Drepte2 └── main.cpp ├── Dreptunghi └── main.cpp ├── Dreptunghi2 ├── Dreptunghi2,in └── main.cpp ├── Dreptunghiuri2 └── main.cpp ├── Dreptunghiuri5 └── main.cpp ├── DrumArb ├── brute_&_tester.cpp └── main.cpp ├── Drum_bugetat └── main.cpp ├── Drum_cu_valoare_maxima_intr-un_graf_orientat_aciclic_cu_K_schimbari_de_valoare └── main.cpp ├── Drumuri2 └── main.cpp ├── Drumuri3 ├── drumuri3.cpp └── main.cpp ├── Drumuri5 └── main.cpp ├── Dsart └── dsart.cpp ├── Dstart └── dstart.cpp ├── Dusman └── main.cpp ├── EPALIN - Extend to Palindrome └── main.cpp ├── EasyGraph └── main.cpp ├── Easylca └── easylca.cpp ├── Ec └── main.cpp ├── Echipe2 └── main.cpp ├── Economie └── main.cpp ├── Ecu2 └── main.cpp ├── Ecuatii2 └── main.cpp ├── Edist ├── edist,in ├── edist.cpp └── main.cpp ├── Egal ├── egal.cpp └── egal2.cpp ├── Egalitati └── main.cpp ├── Electrica ├── ceva.cpp └── electrica.cpp ├── Elicop ├── elicop.cpp ├── elicop_(2).cpp └── main.cpp ├── Elimin └── main.cpp ├── Eliminare └── eliminare.cpp ├── Elmaj ├── elmaj.cpp └── main.cpp ├── Energii ├── energii └── main.cpp ├── Enigma └── main.cpp ├── Ephie └── main.cpp ├── Erathia ├── main.cpp └── main.h ├── Euclid └── main.cpp ├── Euclid2 ├── euclid2.cpp └── main.cpp ├── Euclid3 ├── euclid3.cpp └── main.cpp ├── Euro2 ├── euro2.cpp └── main.cpp ├── Evaluare ├── brut ├── evaluare ├── generare └── sursabuna ├── Evaluarea_unei_expresii └── main.cpp ├── Evantai └── main.cpp ├── Examene └── main.cpp ├── ExpectedPos └── main.cpp ├── Expozitie └── main.cpp ├── Expr └── expr.cpp ├── Expresie └── main.cpp ├── Expresii_min-max └── main.cpp ├── Fabrica └── main.cpp ├── Far └── main.cpp ├── Fear └── main.cpp ├── Felinare └── main.cpp ├── Fenir └── fenir.cpp ├── Fenrirsmt └── fenrirsmt.cpp ├── Ferma └── main.cpp ├── Ferma2 └── main.cpp ├── Fetite └── main.cpp ├── Fibo └── fibo.cpp ├── Filme └── main.cpp ├── Flip └── flip.cpp ├── Flori └── main.cpp ├── Flori2 └── main.cpp ├── Flux2 └── main.cpp ├── Fmcm └── fmcm.cpp ├── Fold └── main.cpp ├── Football └── main.cpp ├── Fractal └── main.cpp ├── Free ├── free.cpp ├── free2.cpp └── main.cpp ├── Friends_of_Friends └── main.cpp ├── Fructe └── Fructe.cpp ├── Frumoasa └── main.cpp ├── Frunze └── main.cpp ├── Fsb └── main.cpp ├── Functii └── main.cpp ├── Furtuna └── main.cpp ├── G2 └── g2.cpp ├── G2mm └── main.cpp ├── GBC └── main.cpp ├── GCD └── main.cpp ├── GFact └── main.cpp ├── Galerie └── main.cpp ├── Garaj └── main.cpp ├── Gather └── main.cpp ├── Gaz └── main.cpp ├── Gcd └── gcd.cpp ├── GenerareFunctii └── generarefunctii.cpp ├── Gheizer └── main.cpp ├── Ghicit └── main.cpp ├── Gift1 └── gift1.cpp ├── Gminmax └── main.cpp ├── Go └── main.cpp ├── Gossips └── main.cpp ├── Gradina └── main.cpp ├── Gradina3 └── main.cpp ├── Graf2 └── main.cpp ├── Graph_Wars └── main.cpp ├── Grarb └── main.cpp ├── Grazing └── main.cpp ├── Greva └── main.cpp ├── Grid └── grid.cpp ├── Grigo └── Grigo.cpp ├── Grindina └── main.cpp ├── Gropi └── main.cpp ├── Grozavesti └── main.cpp ├── Gsr └── main.cpp ├── Guvern └── main.cpp ├── HPD └── hpd.cpp ├── HRKnapsack └── hrknapsack.cpp ├── HRTreepruning └── hrtreepruning.cpp ├── Hackerrank ├── BishopWar │ └── source.cpp ├── DeliverySystem │ └── main.cpp ├── Jim and his LAN party │ └── main.cpp ├── Journey to the Moon │ ├── Journey to the Moon.cbp │ ├── Journey to the Moon.layout │ ├── bin │ │ └── Debug │ │ │ └── Journey to the Moon │ └── main.cpp ├── LaurenAndInversions │ └── source.cpp ├── QuantumLand │ └── main.cpp ├── SumNim │ └── source.cpp ├── WorldCupGame │ └── source.cpp ├── WorldCupTeamFormation │ └── source.cpp └── martisoare │ ├── bin │ └── Debug │ │ └── martisoare │ ├── main.cpp │ ├── martisoare.cbp │ └── martisoare.layout ├── Hamilton ├── hamilton.cpp └── main.cpp ├── Hanoi4 └── main.cpp ├── Harta4 └── main.cpp ├── Hashuri ├── hashuri.cpp └── main.cpp ├── Heavypath └── heavypath.cpp ├── Helloworld └── helloworld.cpp ├── Heroes_of_Might_&_Magic └── main.cpp ├── Holiday └── main.cpp ├── Hotel └── main.cpp ├── Icrisop ├── icrisop.cpp └── main.cpp ├── Iepuras ├── main.cpp └── main.h ├── Iepuri └── main.cpp ├── Iepuri2 └── main.cpp ├── Immortal └── main.cpp ├── Import └── main.cpp ├── Imunitate └── main.cpp ├── Incantatii └── main.cpp ├── Indep └── main.cpp ├── Inel └── inel.cpp ├── Infasuratoare ├── infasuratoare.cpp └── main.cpp ├── Insula └── main.cpp ├── Insule └── main.cpp ├── Inter └── main.cpp ├── Interclasare └── interclasare.cpp ├── Interclasari └── main.cpp ├── Intersort └── main.cpp ├── Intervale2 ├── intervale2.cpp └── main.cpp ├── Interzis └── main.cpp ├── Intfm └── main.cpp ├── Inundatie ├── inundatie.cpp └── main.cpp ├── Inv └── inv.cpp ├── Invazia └── invazia.cpp ├── Invcs └── main.cpp ├── Inversari └── main.cpp ├── Inverseaza └── inverseaza.cpp ├── Inversmodular ├── inversmodular.cpp └── main.cpp ├── Invsort └── main.cpp ├── Iopds └── iopds.cpp ├── Ismquery └── main.cpp ├── Iunie └── main.cpp ├── J-Arbore └── main.cpp ├── Jap2 └── jap2.cpp ├── Jmenoasa └── main.cpp ├── Joben └── main.cpp ├── Joc └── main.cpp ├── Joc13 └── main.cpp ├── Joc4 └── main.cpp ├── Joc5 └── main.cpp ├── Joc8 └── joc8.cpp ├── Joctv └── main.cpp ├── Jocul └── jocul.cpp ├── Jocul_Flip └── Flip.cpp ├── Jocul_NIM └── main.cpp ├── Jstc └── main.cpp ├── KAMI └── main.cpp ├── KMP └── kmp.cpp ├── K_aparitii └── main.cpp ├── Karb └── main.cpp ├── Kdist └── main.cpp ├── Kfib ├── kfib.cpp └── main.cpp ├── Kgon └── main.cpp ├── Kgraf └── main.cpp ├── Kimberley └── main.cpp ├── Kinder ├── check.cpp └── kinder.cpp ├── Kinetic ├── kinetic.cpp └── kinetic_cautbin.cpp ├── Kino └── main.cpp ├── Kmp └── main.cpp ├── Knumere └── main.cpp ├── Kprime └── kprime.cpp ├── Ksecv3 └── main.cpp ├── Ksort └── main.cpp ├── Kss └── kss.cpp ├── Ktown └── main.cpp ├── LCA └── lca.cpp ├── LICENSE ├── La-4201 └── la-4201.cpp ├── Lac └── main.cpp ├── Lacusta └── main.cpp ├── Lant └── main.cpp ├── Lanterna └── main.cpp ├── Lapte └── main.cpp ├── Lca └── main.cpp ├── Lgput ├── lgput.cpp └── main.cpp ├── Lista_lui_Andrei └── main.cpp ├── Litere └── Litere.cpp ├── Litere2 └── main.cpp ├── Livada ├── Livada.cpp └── main.cpp ├── Log └── main.cpp ├── Logs └── main.cpp ├── Loto └── loto.cpp ├── Lover └── main.cpp ├── LowerBound └── main.cpp ├── Lumanari └── main.cpp ├── Luna ├── luna.cpp └── main.cpp ├── Magic2 ├── Magic2.cpp └── magic_22.cpp ├── MagicMatrix └── main.cpp ├── Magic_Numbers └── main.cpp ├── Magic_Trick └── main.cpp ├── Mai_marii_orasului └── main.cpp ├── Map └── main.cpp ├── Markon └── main.cpp ├── Matrice2 └── main.cpp ├── Matrice3 └── main.cpp ├── Matrice5 └── main.cpp ├── Matrice7 └── main.cpp ├── Matrice8 └── main.cpp ├── Matrici ├── Untitled1.cpp ├── a+b.cpp ├── el_negative.cpp ├── el_pozitive.cpp └── linia_k.cpp ├── Maxflow ├── main.cpp └── maxflow.cpp ├── Maxsecv ├── maxsecv.cpp └── maxsecv2.cpp ├── Meciul ├── main.cpp └── meciul.cpp ├── Medie └── main.cpp ├── Melodii └── main.cpp ├── Mere └── mere.cpp ├── MergeSort └── main.cpp ├── Mesaj └── main.cpp ├── Mesaj2 └── main.cpp ├── Mesaj4 └── main.cpp ├── Mesaje └── main.cpp ├── Mess └── main.cpp ├── Mincinosi ├── dreptunghiuri4.cpp ├── mincinosi.cpp ├── serpe.cpp └── take5.cpp ├── Mine └── main.cpp ├── Mine2 └── main.cpp ├── Minuni └── main.cpp ├── Minusk └── main.cpp ├── Misiune └── main.cpp ├── Mission └── main.cpp ├── Modulo ├── Untitled1modulo.cpp └── modulo.cpp ├── Monede └── main.cpp ├── Morcovi └── main.cpp ├── Mosia └── main.cpp ├── Move └── main.cpp ├── Multiplu └── main.cpp ├── Multiplu2 └── main.cpp ├── Muncitori └── main.cpp ├── Munte └── main.cpp ├── Muzeu ├── main.cpp ├── muzeu.cpp ├── muzeu2.cpp └── muzeu_me.cpp ├── Muzeu2 └── main.cpp ├── Mvc └── main.cpp ├── NKD └── main.cpp ├── Namlei ├── main.cpp └── main.h ├── Naveplanare └── naveplanare.cpp ├── Nc └── main.cpp ├── Neutroni └── main.cpp ├── NewYearsResolution └── newyearsresolution.cpp ├── Noname └── main.cpp ├── Noname2 └── noname2.cpp ├── Noroc └── main.cpp ├── Northrend └── main.cpp ├── Note └── main.cpp ├── NrsubSecv └── main.cpp ├── Numar └── main.cpp ├── Numar4 └── main.cpp ├── Numarare └── main.cpp ├── Numarare_triunghiuri └── nrtriunghiuri.cpp ├── Numere7 └── main.cpp ├── Numere8 └── main.cpp ├── NumereX └── main.cpp ├── Numerele_lui_Stirling └── main.cpp ├── Nums └── main.cpp ├── Nustiu └── nustiu.cpp ├── Obiective └── main.cpp ├── Oite └── main.cpp ├── Omizi └── omizi.cpp ├── Online └── main.cpp ├── Orase └── main.cpp ├── Orient └── main.cpp ├── POJ-DualCoreCPU └── poj-dualcorecpu.cpp ├── PP └── main.cpp ├── Padure └── main.cpp ├── Pagina └── main.cpp ├── Paginatie ├── main.cpp ├── paginatie.cpp └── paginatie_paun_matei.cpp ├── Paianjen └── main.cpp ├── Painting └── main.cpp ├── Pairs └── main.cpp ├── Pal2 ├── pal2.cpp └── pal22.cpp ├── Pali └── main.cpp ├── Palin3 └── main.cpp ├── Par ├── main.cpp └── par.cpp ├── Paralelogram2 └── paralelogram2.cpp ├── Parantezare └── main.cpp ├── Paranteze └── main.cpp ├── Pari └── main.cpp ├── Pariuri └── pariuri.cpp ├── Parpal └── parpal.cpp ├── Patrate1 └── main.cpp ├── Patrate3 └── main.cpp ├── Patrate6 └── patrate6.cpp ├── Patrol └── main.cpp ├── Pavare2 └── main.cpp ├── Paznici └── main.cpp ├── Paznici2 └── main.cpp ├── Paznici3 ├── main.cpp └── paznici3.cpp ├── Peisaj └── main.cpp ├── Per └── main.cpp ├── Perb └── main.cpp ├── Perechi3 └── perechi3.cpp ├── Perfect2 └── perfect2.cpp ├── Perioada01 └── perioada01.cpp ├── Perioada2 └── main.cpp ├── Perle2 └── main.cpp ├── Perm2 └── perm2.cpp ├── Permlcs └── main.cpp ├── Permsplit └── main.cpp ├── Permutari ├── main.cpp └── permutari.cpp ├── Pescari ├── main.cpp ├── pascari_v2.cpp ├── pescari.cpp └── pescarifill.cpp ├── PetSoft └── main.cpp ├── Petrecere └── petrecere.cpp ├── Petrecere2 └── main.cpp ├── Petrica └── main.cpp ├── Petrol └── main.cpp ├── Phryme └── phryme.cpp ├── Piata └── main.cpp ├── Pickachu └── main.cpp ├── Piese └── main.cpp ├── Pietre ├── pietre.cpp └── pietre2.cpp ├── Pietre2 ├── main.cpp └── pietre2.cpp ├── Pioni └── main.cpp ├── Pipe └── main.cpp ├── Piscina └── main.cpp ├── Pitici └── main.cpp ├── Pitici2 └── pitici2.cpp ├── Plagiat └── main.cpp ├── Plan └── main.cpp ├── Planificare └── main.cpp ├── Plantatie ├── main.cpp └── plantatie.cpp ├── Plicuri └── main.cpp ├── Plimbare └── main.cpp ├── Pluricex └── main.cpp ├── Pluton └── pluton.cpp ├── Poarta └── main.cpp ├── Police └── main.cpp ├── Poligon └── main.cpp ├── Politic └── politic.cpp ├── Poly └── main.cpp ├── Portal3 └── main.cpp ├── Posta3 └── main.cpp ├── Potrivire └── main.cpp ├── Potrivirea_sirurilor └── main.cpp ├── Praslea └── main.cpp ├── Prefix └── main.cpp ├── Prefix2 └── main.cpp ├── Prefixe └── main.cpp ├── Prieteni3 └── main.cpp ├── ProDiv └── main.cpp ├── Proc └── main.cpp ├── Proc2 └── main.cpp ├── Procesor └── main.cpp ├── Produs4 └── produs4.cpp ├── Produse └── produse.cpp ├── Progresii2 └── main.cpp ├── Propozitie └── main.cpp ├── PscPld └── main.cpp ├── Pscpld2d └── pscpld2d.cpp ├── Pufarina └── main.cpp ├── Pufu └── main.cpp ├── Puncte2 └── main.cpp ├── Puteri3 └── main.cpp ├── Puteri35 └── main.cpp ├── Pviz └── pviz.cpp ├── Qtri └── main.cpp ├── Quadratum └── qudratum.cpp ├── Queue └── queue.cpp ├── Quicksort └── main.cpp ├── REdu └── main.cpp ├── Rabin-Karp └── main.cpp ├── Raci └── main.cpp ├── Radiatie └── radiatie.cpp ├── Radio2 └── main.cpp ├── RadixSort └── main.cpp ├── Radix_Sort ├── include │ └── cosmin.h ├── main.cpp └── src │ └── cosmin.cpp ├── Radixsort ├── main.cpp └── radixsort.cpp ├── Raliu └── main.cpp ├── Randuri └── main.cpp ├── Ratphu └── main.cpp ├── Razboi └── razboi.cpp ├── Recurenta └── recurenta.cpp ├── Recurenta2 └── recurenta2.cpp ├── Reflex └── reflex.cpp ├── Rege └── main.cpp ├── Regiuni └── main.cpp ├── Reguli └── main.cpp ├── Reguli2 └── main.cpp ├── Relatii └── main.cpp ├── Rell └── main.cpp ├── Renovare └── main.cpp ├── Rest └── main.cpp ├── Restrictii ├── Untitled6 └── main.cpp ├── Retea └── main.cpp ├── Retea2 └── main.cpp ├── Retea3 └── main.cpp ├── Retele └── main.cpp ├── Return_of_the_MVC └── main.cpp ├── Reunire └── reunire.cpp ├── Rev └── main.cpp ├── Revolutie └── main.cpp ├── Rf └── rf.cpp ├── Risipa └── risipa.cpp ├── Rj └── main.cpp ├── Rk └── main.cpp ├── Rmq ├── main.cpp └── rmq.cpp ├── Roata └── main.cpp ├── Robot3 ├── main.cpp └── robot3.cpp ├── Roboti └── main.cpp ├── Rotatii └── main.cpp ├── Rotatii2 └── main.cpp ├── Royfloyd ├── main.cpp └── royfloyd.cpp ├── Rps └── main.cpp ├── Rrmst └── rrmst.cpp ├── Rucsac ├── rucsac.cpp ├── rucsac2.cpp ├── rucsac3.cpp └── rucsac_(2).cpp ├── SCANNER_PARSER_BY_ADI_BUDAU └── main.cpp ├── SPOJ-ANGELS └── spoj-angels.cpp ├── SPOJ-COCONUT └── spoj-coconut.cpp ├── SPOJ-DISJPATH └── spoj-disjpath.cpp ├── SPOJ-DIVREL └── spoj-divrel.cpp ├── SPOJ-GREED └── spoj-greed.cpp ├── SPOJ ├── SPOJ - 1391. Summing to a Square Prime │ └── main.cpp ├── SPOJ - 2175. Emoticons │ ├── input.in\ │ └── main.cpp ├── SPOJ - 394. Alphacode │ └── main.cpp ├── SPOJ - 413. Word Puzzles │ └── main.cpp ├── SPOJ - 6409. Suffix Array │ └── main.cpp ├── SPOJ - 694. Distinct Substrings │ └── main.cpp ├── SPOJ - Vpalin │ └── main.cpp ├── SPOJ-3273.Order_statitics_set │ └── main.cpp ├── SPOJ-3878. Rectangles Perimeter │ └── main.cpp ├── SPOJ-ASSIGN │ └── main.cpp ├── SPOJ-CPATTERN │ └── main.cpp ├── SPOJ-DISQUERY │ └── main.cpp ├── SPOJ-EXPEDI │ └── main.cpp ├── SPOJ-FASTFLOW │ └── spoj-fastflow.cpp ├── SPOJ-FILRTEST-Z │ └── main.cpp ├── SPOJ-FILRTEST │ └── main.cpp ├── SPOJ-FINDSR │ └── main.cpp ├── SPOJ-ORDESET │ └── spoj-ordeset.cpp ├── SPOJ-PERIOD │ └── main.cpp ├── SPOJ-POLQUERY - Police Query │ └── main.cpp ├── SPOJ-PSTRING │ └── main.cpp ├── SPOJ-STAR3CAS - THE WEIRD STAIRCASE │ └── main.cpp ├── SPOJ-Supper │ └── spoj-supper.cpp ├── SPOJ_-_1022._Angels_and_Devils │ └── main.cpp ├── SPOJ_-_1027._Fool_the_Police │ └── main.cpp ├── SPOJ_-_1029._Matrix_Summation │ └── main.cpp ├── SPOJ_-_10381._Search_in_the_dictionary! │ └── main.cpp ├── SPOJ_-_1043._Can_you_answer_these_queries_I │ └── main.cpp ├── SPOJ_-_11371._Answer_the_boss! │ └── main.cpp ├── SPOJ_-_11840._Sum_of_Squares_with_Segment_Tree │ └── main.cpp ├── SPOJ_-_11985._Gao_on_a_tree │ └── main.cpp ├── SPOJ_-_12005._Grass_Planting │ └── main.cpp ├── SPOJ_-_12184._Help_the_statistics_department │ └── main.cpp ├── SPOJ_-_12969._To_inifinity_and_Beyond │ └── main.cpp ├── SPOJ_-_13015._Counting_Primes │ └── main.cpp ├── SPOJ_-_13041._The_Black_Riders │ └── main.cpp ├── SPOJ_-_16210._Impossible_Boss │ └── main.cpp ├── SPOJ_-_16245._Living_with_Courage │ └── main.cpp ├── SPOJ_-_16487._Update_the_array_! │ └── main.cpp ├── SPOJ_-_1684._Frequent_values │ └── main.cpp ├── SPOJ_-_1716._Can_you_answer_these_queries_III │ └── main.cpp ├── SPOJ_-_17732._Salary_Management │ └── main.cpp ├── SPOJ_-_1805._Largest_Rectangle_in_a_Histogram │ └── main.cpp ├── SPOJ_-_181._Scuba_diver │ └── main.cpp ├── SPOJ_-_1846._Project_File_Dependencies │ └── main.cpp ├── SPOJ_-_203._Potholers │ └── main.cpp ├── SPOJ_-_263._Period │ └── main.cpp ├── SPOJ_-_2737._Perfect_Rhyme │ └── main.cpp ├── SPOJ_-_2798._Query_on_a_tree_again! │ └── main.cpp ├── SPOJ_-_282._Muddy_Fields │ └── main.cpp ├── SPOJ_-_287._Smart_Network_Administrator │ └── main.cpp ├── SPOJ_-_300._Cable_TV_Network │ └── main.cpp ├── SPOJ_-_3266._K-query │ └── main.cpp ├── SPOJ_-_3273._Order_statistic_set │ └── main.cpp ├── SPOJ_-_3314._Umnozak │ └── main.cpp ├── SPOJ_-_345._Mixtures │ └── main.cpp ├── SPOJ_-_3579._Disjoint_Paths │ └── main.cpp ├── SPOJ_-_3643._Traffic_Network │ └── main.cpp ├── SPOJ_-_3693._Maximum_Sum │ └── main.cpp ├── SPOJ_-_375._Query_on_a_tree │ └── main.cpp ├── SPOJ_-_3868._Total_Flow │ └── main.cpp ├── SPOJ_-_3921._The_Great_Ball │ └── main.cpp ├── SPOJ_-_3946._K-th_Number │ └── main.cpp ├── SPOJ_-_3977._Police_Query │ └── main.cpp ├── SPOJ_-_40._Lifting_the_Stone │ └── main.cpp ├── SPOJ_-_4033._Phone_List │ ├── Untitled1 │ └── main.cpp ├── SPOJ_-_4103._Extend_to_Palindrome │ └── main.cpp ├── SPOJ_-_4155._OTOCI │ └── main.cpp ├── SPOJ_-_4206._Fast_Maximum_Matching │ └── main.cpp ├── SPOJ_-_4227._Shortest_pair_of_paths │ └── main.cpp ├── SPOJ_-_4350._QMAX3VN │ └── main.cpp ├── SPOJ_-_4487._Can_you_answer_these_queries_VI │ └── main.cpp ├── SPOJ_-_4657._Gas_Wars │ └── main.cpp ├── SPOJ_-_6294._Yodaness_Level │ └── main.cpp ├── SPOJ_-_660._Dungeon_of_Death │ └── main.cpp ├── SPOJ_-_666._Con-Junctions │ └── main.cpp ├── SPOJ_-_6779._Can_you_answer_these_queries_VII │ └── main.cpp ├── SPOJ_-_7259._Light_Switching │ └── main.cpp ├── SPOJ_-_726._Promotion │ └── main.cpp ├── SPOJ_-_7299._Multiples_of_3 │ └── main.cpp ├── SPOJ_-_741._Steady_Cow_Assignment │ └── main.cpp ├── SPOJ_-_8002._Horrible_Queries │ └── main.cpp ├── SPOJ_-_8324._Military_patrol │ └── main.cpp ├── SPOJ_-_8728._Hierarchy │ └── main.cpp ├── SPOJ_-_913._Query_on_a_Tree_2 │ └── main.cpp ├── SPOJ_-_96._Shopping │ └── main.cpp ├── SPOJ_-_962._Intergalactic_Map │ └── main.cpp ├── SPOJ_-_97._Party_Schedule │ └── main.cpp ├── SPOJ_7826._Tree_Isomorphism │ └── main.cpp ├── SPoJ_-_286._Selfish_Cities │ └── main.cpp ├── Spoj_-_1435._Vertex_Cover │ └── main.cpp ├── spoj-dict │ └── spoj-dict.cpp └── spoj-morse │ ├── spoj-morse │ └── spoj-morse.cpp ├── STAR3CAS └── main.cpp ├── SUBXOR └── subxor.cpp ├── Sabotaj └── main.cpp ├── Sah └── main.cpp ├── Salvare └── main.cpp ├── Sant └── main.cpp ├── Saracsaurege └── saracsaurege.cpp ├── Sarpe └── main.cpp ├── Sarpe2 └── main.cpp ├── Sase49 └── sase49.cpp ├── Sate └── main.cpp ├── ScaleCrop ├── scalecrop.cpp └── scalecrop_(2).cpp ├── Scara2 └── main.cpp ├── Scara3 └── main.cpp ├── Scara_3 └── main.cpp ├── Sccm └── main.cpp ├── Scmax ├── main.cpp └── scmax.cpp ├── Scv7 └── main.cpp ├── Sdo ├── main.cpp └── sdo.cpp ├── Sea2 └── main.cpp ├── Search └── main.cpp ├── Secretul_Cifrului └── main.cpp ├── Secv └── main.cpp ├── Secv10 └── secv10.cpp ├── Secv4 └── main.cpp ├── Secv5 └── main.cpp ├── Secv6 └── secv6.cpp ├── Secv8 └── main.cpp ├── Secv9 └── main.cpp ├── Secvdist └── main.cpp ├── Secventa ├── main.cpp └── secventa.cpp ├── Secventa2 └── main.cpp ├── Secventa3 └── main.cpp ├── Secventa4 └── main.cpp ├── Secvmax └── main.cpp ├── Secvmin ├── main.cpp ├── secvmin.cpp └── secvmin30pc.cpp ├── Segmente └── main.cpp ├── Semipal └── semipal.cpp ├── Semne3 └── main.cpp ├── Seti └── main.cpp ├── Shift └── main.cpp ├── Shop └── main.cpp ├── Shpath └── main.cpp ├── Simetrii └── main.cpp ├── Simpla ├── Simpla.cpp └── simplasd.cpp ├── Sir └── main.cpp ├── Sir4 ├── a+b.cpp ├── main.cpp └── sir4.cpp ├── Sirag └── main.cpp ├── Sirag2 └── main.cpp ├── Siret └── main.cpp ├── Sireturi ├── main.cpp └── sireturi ├── Siruri └── main.cpp ├── SkylineVarena └── skylinevarena.cpp ├── SlidingWindow └── slidingwindow.cpp ├── Smen └── main.cpp ├── Smenul_lui_Mars └── main.cpp ├── Sobo └── main.cpp ├── Something └── something.cpp ├── Sort └── sort.cpp ├── Sortaret ├── main.cpp └── sortaret.cpp ├── Sortari └── main.cpp ├── Sotron └── main.cpp ├── Spargere2 └── main.cpp ├── Spargeri └── main.cpp ├── Spatiu └── spatiu.cpp ├── Speedy └── main.cpp ├── Spider-man └── spider-man.cpp ├── Spion └── main.cpp ├── Spirala └── Spirala.cpp ├── Spiridusi └── spiridusi.cpp ├── Srveni └── main.cpp ├── Ssm ├── main.cpp └── ssm.cpp ├── Ssnd ├── main.cpp └── ssnd.cpp ├── Stack └── stack.cpp ├── Stalpi └── main.cpp ├── Stalpi2 └── main.cpp ├── Stergeri ├── Stergeri.cpp └── stergeri1.cpp ├── Sticle ├── sticle.cpp └── sticle_(2).cpp ├── Stirling └── stirling.cpp ├── Stiva └── main.cpp ├── Stiva2 └── stiva.cpp ├── Stramosi └── main.cpp ├── Strazi └── main.cpp ├── Strigat └── main.cpp ├── String └── main.cpp ├── String_Repair └── sr.cpp ├── Strmatch ├── main.cpp └── strmatch.cpp ├── Struti └── main.cpp ├── Sub └── main.cpp ├── Subarbore └── main.cpp ├── Submatrix └── main.cpp ├── Submultimi └── main.cpp ├── Subsecventa2 └── main.cpp ├── Subsecvente └── main.cpp ├── Subsecvente2 └── main.cpp ├── Subset2 └── main.cpp ├── Subsir1000 └── main.cpp ├── Subsiruri2 ├── main.cpp └── subsiruri2.cpp ├── Suma4 └── main.cpp ├── Suma5 └── main.cpp ├── Swap └── main.cpp ├── Swaps2 └── main.cpp ├── Switch └── main.cpp ├── TAP2012D └── main.cpp ├── TIMUS-1471. Tree └── main.cpp ├── Tabara2 └── main.cpp ├── Taie ├── taie-1.cpp └── taie.cpp ├── Take5 ├── Combinari.cpp ├── Permutari2.cpp ├── Untitled6.cpp ├── main.cpp ├── take5.combinari.cpp ├── take5.cpp ├── take5.nichita.cpp └── take5_(1).cpp ├── Talent └── main.cpp ├── Tamplar └── main.cpp ├── Tarabe └── main.cpp ├── Taramul_Nicaieri └── main.cpp ├── Tarnacop └── main.cpp ├── Tastatura └── main.cpp ├── Taste └── taste.cpp ├── Taxa └── main.cpp ├── Team └── main.cpp ├── Teams ├── main.cpp ├── teams(2).cpp └── teams_citire_parsata.cpp ├── Telefon └── main.cpp ├── Tempest └── tempest.cpp ├── Temple └── main.cpp ├── Teren └── main.cpp ├── Teren2 └── main.cpp ├── Ternar ├── main.cpp └── ternar.cpp ├── Teroristi └── main.cpp ├── Test ├── Makefile ├── main.cpp └── nbproject │ ├── Package-Debug.bash │ ├── Package-Release.bash │ └── private │ └── launcher.properties ├── Tester └── tester.cpp ├── Text3 ├── text3.cpp └── text3_1.cpp ├── Texttrim └── texttrim.cpp ├── Timetravel └── main.cpp ├── Tort ├── comentata.cpp └── main.cpp ├── Toys └── main.cpp ├── Tractomarm └── main.cpp ├── Trafic └── main.cpp ├── Transport2 └── main.cpp ├── Trasee └── main.cpp ├── Traseu2 └── traseu2.cpp ├── Traseu3 └── main.cpp ├── Tree └── main.cpp ├── Tree2 └── main.cpp ├── Treesmen └── main.cpp ├── Tren └── tren.cpp ├── Trenuri2 └── main.cpp ├── Tri └── main.cpp ├── Tri2 └── main.cpp ├── Triang └── main.cpp ├── Triangles └── main.cpp ├── Trib └── main.cpp ├── Tribute └── main.cpp ├── Tric └── main.cpp ├── Tricouri └── main.cpp ├── Trie ├── main.cpp └── trie.cpp ├── Trilant └── main.cpp ├── Triopalindrom └── main.cpp ├── Trip └── main.cpp ├── Triplet ├── TRIPLET2.cpp ├── triplet.cpp ├── triplet100pcte.cpp └── tripletcautbin.cpp ├── Triplete(bac) └── main.cpp ├── Triplete └── main.cpp ├── Triti2 └── main.cpp ├── Triunghi └── main.cpp ├── Trmax └── main.cpp ├── Troll └── main.cpp ├── Trompeta └── main.cpp ├── Tsunami ├── DEV-FILL_ITERAR.cpp └── main.cpp ├── Ture └── main.cpp ├── Turnuri2 └── main.cpp ├── UVA-11418 └── uva-11418.cpp ├── Ubercool └── ubercool.cpp ├── Ubuntuzei └── main.cpp ├── Ubuntzei └── main.cpp ├── Unicat └── unicat.cpp ├── Unique └── main.cpp ├── Unudoi └── main.cpp ├── Unuzero └── main.cpp ├── Urgenta └── main.cpp ├── Uva-10000 ├── ok.ok └── uva-10000.cpp ├── Uva-10243 └── uva-10243.cpp ├── Uva-10308 └── uva-10308.cpp ├── Uva-10459 ├── da.ok └── uva-10459.cpp ├── Uva-10511 └── uva-10511.cpp ├── Uva-10938 └── uva-10938.cpp ├── Uva-11307 └── uva-11307.cpp ├── Uva-11324 └── uva-11324.cpp ├── Uva-3685 └── uva-3685.cpp ├── Vase └── vase.cpp ├── Verlab └── verlab.cpp ├── Victorie ├── victorie └── victorie.cpp ├── Vila └── main.cpp ├── Vila2 ├── main.cpp └── vila2.cpp ├── Virus └── main.cpp ├── Viteza └── main.cpp ├── Viteza2 └── main.cpp ├── Volum └── main.cpp ├── Vrejuri └── vrejuri.cpp ├── Vulcan └── main.cpp ├── War └── main.cpp ├── X └── x.cpp ├── Xcmmdc └── main.cpp ├── Xmoto └── main.cpp ├── Xnumere └── main.cpp ├── XorMax └── main.cpp ├── Xspe ├── main.cpp └── xspe.cpp ├── Zalgorithm └── main.cpp ├── Zapada └── main.cpp ├── Zeap └── main.cpp ├── Zero2 └── main.cpp ├── Zimeria └── main.cpp ├── Zip └── main.cpp ├── Zlego └── zlego.cpp ├── Zmeu └── main.cpp ├── Zmeu2 └── main.cpp ├── Zona └── main.cpp ├── Zone └── main.cpp ├── Zoo └── main.cpp ├── _codeforces ├── 527 │ └── 527.cpp ├── 149E │ └── main.cpp ├── 151A │ └── 151a.cpp ├── 165D │ └── 165d.cpp ├── 191C │ └── 191c.cpp ├── 247 - Calling Circles │ └── main.cpp ├── 339B │ └── 339b.cpp ├── 415D │ └── main.cpp ├── 416B │ └── main.cpp ├── 416C │ └── main.cpp ├── 416E │ └── main.cpp ├── 420D │ └── 420d.cpp ├── 420d │ └── 420d.cpp ├── 427C │ └── 427c.cpp ├── 427D │ └── 427d.cpp ├── 430C │ └── 430c.cpp ├── 430D │ └── 430d.cpp ├── 431C │ └── 431c.cpp ├── 431E │ └── 431e.cpp ├── 432D │ └── 432d.cpp ├── 432E │ └── 432e.cpp ├── 437B │ └── 437b.cpp ├── 437C │ └── 437c.cpp ├── 437D │ └── 437d.cpp ├── 438D │ └── 438d.cpp ├── 448B │ └── 448b.cpp ├── 448C │ └── 448c.cpp ├── 448D │ └── 448d.cpp ├── 449B │ └── 449b.cpp ├── 456C │ └── 456c.cpp ├── 456D │ └── 456d.cpp ├── 456E │ └── 456e.cpp ├── 459D │ ├── 459d.cpp │ └── oddtreeok.cpp ├── 459E │ └── 459e.cpp ├── 460B │ └── 460b.cpp ├── 460C │ └── 460c.cpp ├── 462C │ └── 462c.cpp ├── 462a │ └── 462a.cpp ├── 463A │ └── 463a.cpp ├── 463C │ └── 463c.cpp ├── 463D │ └── 463d.cpp ├── 463E │ └── 463e.cpp ├── 463b │ └── 463b.cpp ├── 465A │ └── 465a.cpp ├── 465B │ └── 465b.cpp ├── 465C │ └── 465c.cpp ├── 465D │ └── 465d.cpp ├── 466A │ └── 466a.cpp ├── 466B │ └── 466b.cpp ├── 466C │ └── 466c.cpp ├── 466E │ └── 466e.cpp ├── 467A │ └── 467a.cpp ├── 467B │ └── 467b.cpp ├── 467C │ └── 467c.cpp ├── 471A │ └── 471a.cpp ├── 471B │ └── 471b.cpp ├── 471C │ └── 471c.cpp ├── 471D │ └── 471d.cpp ├── 472A │ └── 472a.cpp ├── 472B │ └── 472b.cpp ├── 472C │ └── 472c.cpp ├── 472D │ └── 472d.cpp ├── 474A │ └── 474a.cpp ├── 474B │ └── 474b.cpp ├── 474C │ └── 474c.cpp ├── 474D │ └── 474d.cpp ├── 474E │ └── 474e.cpp ├── 474F │ └── 474f.cpp ├── 474f │ └── 474f.cpp ├── 475A │ └── 475a.cpp ├── 475B │ └── 475b.cpp ├── 476D │ └── 476d.cpp ├── 479A │ └── 479a.cpp ├── 479B │ └── 479b.cpp ├── 479C │ └── 479c.cpp ├── 479D │ └── 479d.cpp ├── 479DA │ └── 479da.cpp ├── 479F │ └── 479f.cpp ├── 483B │ └── 483b.cpp ├── 483D │ └── 483d.cpp ├── 485B │ └── 485b.cpp ├── 485C │ └── 485c.cpp ├── 485D │ └── 485d.cpp ├── 486A │ └── 486a.cpp ├── 486B │ └── 486b.cpp ├── 486C │ └── 486c.cpp ├── 486D │ └── 486d.cpp ├── 486E │ └── 486e.cpp ├── 489A │ └── 489a.cpp ├── 489B │ └── 489b.cpp ├── 489C │ └── 489c.cpp ├── 489D │ └── 489d.cpp ├── 490A │ └── 490a.cpp ├── 490B │ └── 490b.cpp ├── 490C │ └── 490c.cpp ├── 491C │ └── 491c.cpp ├── 492A │ └── 492a.cpp ├── 492B │ └── 492b.cpp ├── 492C │ └── 492c.cpp ├── 493A │ └── 493a.cpp ├── 493B │ └── 493b.cpp ├── 493C │ └── 493c.cpp ├── 494b │ └── 494b.cpp ├── 495A │ └── 495a.cpp ├── 495B │ └── 495b.cpp ├── 495c │ └── 495c.cpp ├── 496a │ └── 496a.cpp ├── 496ab │ └── 496ab.cpp ├── 496c │ └── 496c.cpp ├── 496d │ └── 496d.cpp ├── 496e │ └── 496e.cpp ├── 499A │ └── 499a.cpp ├── 499B │ └── 499b.cpp ├── 499C │ └── 499c.cpp ├── 500A │ └── 500a.cpp ├── 500B │ └── 500b.cpp ├── 500C │ └── 500c.cpp ├── 500D │ └── 500d.cpp ├── 501A │ └── 501a.cpp ├── 501B │ └── 501b.cpp ├── 501C │ └── 501c.cpp ├── 505A │ └── 505a.cpp ├── 505B │ └── 505b.cpp ├── 505C │ └── 505c.cpp ├── 507A │ └── 507a.cpp ├── 507B │ └── 507b.cpp ├── 507C │ └── 507c.cpp ├── 507b │ └── 507b.cpp ├── 507e │ └── 507e.cpp ├── 508A │ └── 508a.cpp ├── 508B │ └── 508b.cpp ├── 508D │ └── 508d.cpp ├── 509A │ └── 509a.cpp ├── 509B │ └── 509b.cpp ├── 510A │ └── 510a.cpp ├── 510B │ └── 510b.cpp ├── 510C │ └── 510c.cpp ├── 510E │ └── 510e.cpp ├── 513F1 │ └── 513f1.cpp ├── 514A │ └── 514a.cpp ├── 514B │ └── 514b.cpp ├── 514C │ └── 514c.cpp ├── 514D │ └── 514d.cpp ├── 514E │ └── 514e.cpp ├── 519B │ └── 519b.cpp ├── 519C │ └── 519c.cpp ├── 519D │ └── 519d.cpp ├── 519E │ └── 519e.cpp ├── 527A │ └── 527a.cpp ├── 527B │ └── 527b.cpp ├── 528A │ └── 528a.cpp ├── 528B │ └── 528b.cpp └── 528C │ └── 528c.cpp ├── _uri ├── Uri1057 │ └── uri1057.cpp ├── Uri1135 │ └── uri1135.cpp ├── Uri1201 │ └── main.cpp ├── Uri1270 │ └── uri1270.cpp ├── Uri1314 │ └── uri1314.cpp ├── Uri1317 │ └── uri1317.cpp ├── Uri1322 │ └── uri1322.cpp ├── Uri1362 │ └── uri1362.cpp ├── Uri1384 │ └── uri1384.cpp ├── Uri1391 │ └── uri1391.cpp ├── Uri1423 │ └── uri1423.cpp ├── Uri1427 │ └── uri1427.cpp ├── Uri1447 │ └── uri1447.cpp ├── Uri1454 │ └── uri1454.cpp ├── Uri1466 │ └── uri1466.cpp ├── Uri1469 │ └── uri1469.cpp ├── Uri1476 │ └── uri1476.cpp ├── Uri1479 │ └── uri1479.cpp ├── Uri1482 │ └── uri1482.cpp ├── Uri1489 │ └── uri1489.cpp ├── Uri1525 │ └── uri1525.cpp ├── Uri1529 │ └── uri1529.cpp ├── Uri1550 │ └── uri1550.cpp ├── Uri1610 │ └── uri1610.cpp ├── Uri1675 │ └── uri1675.cpp ├── Uri1695 │ └── uri1695.cpp └── Uri1738 │ └── uri1738.cpp ├── _uva ├── UVA-10449 - Traffic │ └── main.cpp ├── UVA10557 - XYZZY │ └── main.cpp ├── UVA11686 - Pick up sticks │ └── main.cpp ├── UVA_-_10048_-_Audiophobia │ └── main.cpp ├── UVA_-_10080_-_Gopher_II │ └── main.cpp ├── UVA_-_10092_-_The_Problem_with_the_Problem_Setter │ └── main.cpp ├── UVA_-_10099_-_The_Tourist_Guide │ └── main.cpp ├── UVA_-_101._Fishmonger │ └── main.cpp ├── UVA_-_10199_-_Tourist_Guide │ └── main.cpp ├── UVA_-_10330_-_Power_Transmission │ └── main.cpp ├── UVA_-_10480_-_Sabotage │ └── main.cpp ├── UVA_-_10594_-_Data_Flow │ └── main.cpp ├── UVA_-_10600_-_ACM_Contest_and_Blackout │ └── main.cpp ├── UVA_-_10679_-_I_Love_Strings!! │ └── main.cpp ├── UVA_-_10746_-_Crime_Wave_-_The_Sequel │ └── main.cpp ├── UVA_-_10804_-_Gopher_Strategy │ └── main.cpp ├── UVA_-_10806_-_Dijkstra,_Dijkstra │ └── main.cpp ├── UVA_-_11045_-_My_T-shirt_suits_me │ └── main.cpp ├── UVA_-_11138_-_Nuts_and_Bolts │ └── main.cpp ├── UVA_-_11262_-_Weird_Fence │ └── main.cpp ├── UVA_-_11419_-_SAM_I_AM │ └── main.cpp ├── UVA_-_11506_-_Angry_Programmer │ └── main.cpp ├── UVA_-_12436_-_Rip_Van_Winkle's_Code │ └── main.cpp ├── UVA_-_12532_-_Interval_Product │ └── main.cpp ├── UVA_-_12637_-_30_Minutes_or_Less │ └── main.cpp ├── UVA_-_259_-_Software_Allocation │ └── main.cpp ├── UVA_-_315_-_Network │ └── main.cpp ├── UVA_-_423_-_MPI_Maelstrom │ └── main.cpp ├── UVA_-_558_-_Wormholes │ └── main.cpp ├── UVA_-_610_-_Street_Directions │ └── main.cpp ├── UVA_-_670_-_The_dog_task │ └── main.cpp ├── UVA_-_7212._Find_String_Roots │ └── main.cpp ├── UVA_-_741._Steady_Cow_Assignment │ └── main.cpp ├── UVA_-_796_-_Critical_Links │ └── main.cpp ├── UVA_-_820_-_Internet_Bandwidth │ └── main.cpp ├── UVA_-_836_-_Largest_Submatrix │ └── main.cpp ├── UVa-11721 - Instant View of Big Bang │ └── main.cpp ├── UVa-12604-Caesar Cipher │ └── main.cpp └── UVa-147 - Dollars │ └── main.cpp ├── bac └── main.cpp ├── berarii2 └── main.cpp ├── bst └── main.cpp ├── cerere └── main.cpp ├── cf560 ├── a.cpp ├── b.cpp ├── c.cpp ├── d.cpp └── e.cpp ├── cf614 ├── a.cpp ├── b.cpp └── c.cpp ├── cmlsc └── cmlsc.cpp ├── codejam1ba └── codejam1ba.cpp ├── codejam1balarge └── codejam1balarge.cpp ├── codejam1bb ├── GIMNAZIU_SOL_TESTE.zip └── codejam1bb.cpp ├── color4 └── main.cpp ├── create.sh ├── curs1_n_engl.doc ├── curs2_engl.doc ├── divk └── divk.cpp ├── easygraph └── easygraph.cpp ├── echilibru └── main.cpp ├── eliminare └── main.cpp ├── emm └── emm.cpp ├── euclid2 └── euclid2.cpp ├── euclid3 └── euclid3.cpp ├── examen └── examen.cpp ├── gcj1b ├── a.cpp ├── b.cpp └── c.cpp ├── gcj1c ├── a.cpp ├── b.cpp └── c.cpp ├── geometrie └── geometrie.cpp ├── grid └── grid.cpp ├── hack └── hack.cpp ├── hacker3 └── main.cpp ├── hackercup2016_qualif ├── boomerang.cpp ├── me.jpg ├── texteditor.cpp ├── texteditor2.cpp └── thepriceiscorrect.cpp ├── hackercup2016_round1 ├── a.cpp ├── b.cpp └── c.cpp ├── infinitepatternmatching └── infinitepatternmatching.cpp ├── kfib └── main.cpp ├── kmp └── kmp.cpp ├── ksecv2 └── ksecv.cpp ├── la-2191 └── la-2191.cpp ├── la-2696 └── la-2696.cpp ├── la-3126 └── la-3126.cpp ├── la-4106 └── la-4106.cpp ├── la-4146 └── la-4146.cpp ├── lca └── lca.cpp ├── maxPal └── main.cpp ├── naveplanare └── naveplanare.cpp ├── password ├── main.cpp └── password.cpp ├── poj-3255 └── poj-3255.cpp ├── royfloyd └── royfloyd.cpp ├── s013 └── s013.cpp ├── sortaret └── sortaret.cpp ├── strmatch └── strmatch.cpp ├── tempest └── tempest.cpp ├── test ├── .test.cpp.stv ├── .test.cpp.stw ├── .test.cpp.sua ├── .test.cpp.suw ├── .test.cpp.suy ├── .test.cpp.svl ├── .test.cpp.svu ├── .test.cpp.swf ├── main.cpp └── test.cpp ├── triplete └── main.cpp ├── uva-10369 └── uva-10369.cpp ├── uva-10681 └── uva-10681.cpp ├── uva-11402 ├── uva-11402.cpp └── uva-11402.ok ├── uva-11495 └── uva-11495.cpp ├── uva-11503 └── uva-11503.cpp ├── uva-590 └── uva-590.cpp ├── uva-825 └── uva-825.cpp └── uva-988 └── uva-988.cpp /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.in 2 | *.out 3 | *.obj 4 | *.o 5 | \.*sw[klmnop] 6 | -------------------------------------------------------------------------------- /1-sir/1-sir.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define max_N 2 3 | #define max_S 32640 4 | 5 | using namespace std; 6 | 7 | ifstream fin("1-sir.in"); 8 | ofstream fout("1-sir.out"); 9 | 10 | int N, S, D[max_N][max_S], i, j, k; 11 | 12 | int main() 13 | { 14 | for(int i = 1 ; i <= n ; ++ i) { 15 | int x, y; 16 | fin >> x >> y; 17 | } 18 | fin >> N >> S; 19 | D[0][0] = 1; 20 | for(i = 1; i <= N - 1; i ++) 21 | { 22 | for(j = 0; j <= N*(N-1)/2; j ++) 23 | D[1][j] = D[0][j + (i - 1)] + D[0][j - (i - 1)]; 24 | 25 | for(k = 0; k <= N*(N-1)/2 ; k ++) 26 | { 27 | D[0][k] = D[1][k]; 28 | D[1][k] = 0; 29 | } 30 | } 31 | fout << D[0][S]; 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /101hack29/a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int cnt[2], diff[2]; 6 | 7 | int main() { 8 | #ifdef HOME 9 | freopen("input.in", "r", stdin); 10 | freopen("output.out", "w", stdout); 11 | #endif 12 | string a, b; 13 | cin >> a >> b; 14 | if(a.size() != b.size()) { 15 | cout << "-1\n"; 16 | return 0; 17 | } 18 | for(int i = 0 ; i < a.size() ; ++ i) 19 | if(a[i] != b[i]) 20 | ++ cnt[a[i] - '0']; 21 | if(cnt[1] != cnt[0]) 22 | cout << "-1\n"; 23 | else 24 | cout << cnt[0] << '\n'; 25 | } 26 | -------------------------------------------------------------------------------- /10298 - Power Strings/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | string s; 8 | int n, k; 9 | vector pi; 10 | 11 | int main() { 12 | #ifndef ONLINE_JUDGE 13 | freopen("input.in", "r", stdin); 14 | #endif // ONLINE_JUDGE 15 | while(getline(cin, s)) { 16 | if(s[0] == '.') 17 | break; 18 | n = s.size(); 19 | pi.resize(n); 20 | k = pi[0] = -1; 21 | for(int i = 1 ; i < n ; ++ i) { 22 | while(k != -1 && s[k + 1] != s[i]) 23 | k = pi[k]; 24 | if(s[k + 1] == s[i]) 25 | ++ k; 26 | pi[i] = k; 27 | ///cerr << pi[i] << ' '; 28 | } 29 | cout << n / (n - pi[n - 1] - 1) << '\n'; 30 | } 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /126/126.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/126/126.cpp -------------------------------------------------------------------------------- /12perm/12perm.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MOD 1048576 3 | using namespace std; 4 | ifstream cin("12perm.in"); 5 | ofstream cout("12perm.out"); 6 | int n, T[15000000]; 7 | 8 | int main () 9 | { 10 | 11 | cin>>n; 12 | T[1] = 1, T[2] = 2, T[3] = 6, T[4] = 12; 13 | for(int i=5;i<=n;i++) 14 | T[i] = (T[i - 1] + T[i - 3] + 2 * (i - 2)) & ( MOD - 1); 15 | cout< 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | const int maxn = 100005; 8 | 9 | int a[maxn], dp[maxn]; 10 | int n; 11 | 12 | int main() { 13 | cin >> n; 14 | for(int i = 1 ; i <= n ; ++ i) { 15 | cin >> a[i]; 16 | if(i == 1) 17 | dp[i] = 1; 18 | else if(a[i - 1] <= a[i]) 19 | dp[i] = dp[i - 1] + 1; 20 | else 21 | dp[i] = 1; 22 | } 23 | cout << *max_element(dp + 1, dp + n + 1) << '\n'; 24 | } 25 | -------------------------------------------------------------------------------- /525A/525a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | unordered_map fr; 10 | 11 | int main() { 12 | #ifndef ONLINE_JUDGE 13 | freopen("525a.in", "r", stdin); 14 | freopen("525a.out", "w", stdout); 15 | #endif 16 | int n; 17 | string s; 18 | cin >> n >> s; 19 | int ans = 0; 20 | for(int i = 0 ; i < s.size() ; ++ i) { 21 | if(i % 2 == 0) { 22 | ++ fr[s[i] - 'a']; 23 | } 24 | else 25 | if(!fr[s[i] - 'A']) 26 | ++ ans; 27 | else 28 | -- fr[s[i] - 'A']; 29 | } 30 | cout << ans << '\n'; 31 | } 32 | -------------------------------------------------------------------------------- /525B/525b.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | const int maxn = 2000005; 9 | 10 | char s[maxn]; 11 | int a[maxn]; 12 | int n; 13 | 14 | int main() { 15 | #ifndef ONLINE_JUDGE 16 | freopen("525b.in", "r", stdin); 17 | freopen("525b.out", "w", stdout); 18 | #endif 19 | int m; 20 | cin >> s + 1; 21 | n = strlen(s + 1); 22 | cin >> m; 23 | for(int i = 1 ; i <= m ; ++ i) { 24 | int x; 25 | cin >> x; 26 | a[x] ++; 27 | a[n - x + 1 + 1] --; 28 | } 29 | int sum = 0; 30 | for(int i = 1 ; i <= n ; ++ i) { 31 | sum = sum + a[i]; 32 | if(sum % 2 == 0) 33 | cout << s[i]; 34 | else 35 | cout << s[n - i + 1]; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /525D/525d.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | #ifndef ONLINE_JUDGE 8 | freopen("525d.in", "r", stdin); 9 | freopen("525d.out", "w", stdout); 10 | #endif 11 | } 12 | -------------------------------------------------------------------------------- /534A/534a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() { 8 | #ifndef ONLINE_JUDGE 9 | freopen("534a.in", "r", stdin); 10 | freopen("534a.out", "w", stdout); 11 | #endif 12 | int n; 13 | cin >> n; 14 | vector v[2]; 15 | for(int i = 1 ; i <= n ; ++ i) { 16 | v[i % 2].push_back(i); 17 | } 18 | if(n == 3) { 19 | cout << "2\n1 3\n"; 20 | return 0; 21 | } 22 | if(n <= 2) { 23 | cout << "1\n1\n"; 24 | return 0; 25 | } 26 | if(n == 4) { 27 | cout << "4\n2 4 1 3\n"; 28 | return 0; 29 | } 30 | cout << n << '\n'; 31 | for(auto it : v[0]) { 32 | cout << it << ' '; 33 | } 34 | for(auto it : v[1]) 35 | cout << it << ' '; 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /534B/534b.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int v1, v2, t, d; 7 | 8 | int main() { 9 | #ifndef ONLINE_JUDGE 10 | freopen("534b.in", "r", stdin); 11 | freopen("534b.out", "w", stdout); 12 | #endif 13 | cin >> v1 >> v2 >> t >> d; 14 | int total = v1; 15 | int actv = v1; 16 | for(int i = 2 ; i < t ; ++ i) { 17 | for(int delta = d ; delta >= -d ; -- delta) { 18 | if(actv + delta - (t - i) * d <= v2) { 19 | actv += delta; 20 | break; 21 | } 22 | } 23 | total += actv; 24 | } 25 | total += v2; 26 | cout << total << '\n'; 27 | } 28 | -------------------------------------------------------------------------------- /534C/534c.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | const int maxn = 200005; 7 | 8 | int n, a[maxn]; 9 | long long s, sum; 10 | 11 | int main() { 12 | #ifndef ONLINE_JUDGE 13 | freopen("534c.in", "r", stdin); 14 | freopen("534c.out", "w", stdout); 15 | #endif 16 | cin >> n >> s; 17 | for(int i = 1 ; i <= n ; ++ i) { 18 | cin >> a[i]; 19 | sum += a[i]; 20 | } 21 | for(int i = 1 ; i <= n ; ++ i) { 22 | long long acts = sum - a[i]; 23 | long long aux = max(0LL, s - acts - 1); 24 | long long bux = max(0LL, a[i] - s + n - 1); 25 | cout << aux + bux << ' '; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /534E/534e.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/534E/534e.cpp -------------------------------------------------------------------------------- /5644130656976896careercup/5644130656976896careercup.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int xorsum = 0; 7 | for(int i = 1 ; i <= 100 ; ++ i) { 8 | xorsum = xorsum ^ i; 9 | cout << i << " = " << xorsum << '\n'; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /592/create.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir -p $1 4 | cd $1 5 | newString=${1,,} 6 | 7 | cpp=$newString".cpp" 8 | in=$newString".in" 9 | out=$newString".out" 10 | 11 | touch $cpp 12 | touch $in 13 | touch $out 14 | 15 | vim $cpp -c "vs "$in -c "sp "$out -c ":30winc <" 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /7segmente/7segmente.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | ifstream cin("7segmente.in"); 5 | ofstream cout("7segmente.out"); 6 | int main() 7 | { 8 | int a[10]; 9 | long long n, p, aux,s=0, putere=0; 10 | // char n[100000000000000000000] ; 11 | a[1]=2; a[2]=5; a[3]=5; a[4]=4; a[5]=5; a[6]=6; a[7]=3; a[8]=7; a[9]=6; 12 | cin>>n; 13 | cin>>p; 14 | aux=n; 15 | while(aux!=0) 16 | { s+=a[aux%10]; 17 | aux=aux/10; 18 | } 19 | cout< 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Ab2/ab2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | const int maxn = 30005; 8 | 9 | int n, a, b, nr, sz[maxn]; 10 | 11 | int main() { 12 | ifstream fin("ab2.in"); 13 | ofstream fout("ab2.out"); 14 | fin >> n >> a >> b; 15 | 16 | int remaining = n; 17 | for(int i = a - 1 ; i >= 0 ; -- i) { 18 | sz[i] = min(remaining - i, b); 19 | remaining -= sz[i]; 20 | } 21 | for(int i = 0 ; i < a ; ++ i) { 22 | for(int j = remaining + sz[i] ; j > remaining ; -- j) 23 | fout << j << ' '; 24 | remaining += sz[i]; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /AiB/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | ifstream cin("input.in"); 6 | ofstream cout("output.out"); 7 | int main() 8 | { 9 | 10 | cin.close(); 11 | cout.close(); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /Alee/sursa_pentru_teste.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | ///#define DEBUG 3 | using namespace std; 4 | ofstream cout("alee.in"); 5 | 6 | // if(u>30625) 7 | int main() 8 | { 9 | cout<<175<<" "; 10 | cout<<30625-(175+175-1)<<"\n"; 11 | for(int i=1;i<=175;i++) 12 | for(int j=1;j<=175;j++) 13 | if(i!=1 && j!=175) 14 | cout< 2 | #include 3 | using namespace std; 4 | long long N, K, i; 5 | char stk[10005]; 6 | int stk_len; 7 | char s[10005]; 8 | bool ok[10005]; 9 | ifstream cin("alibaba.in"); 10 | ofstream cout("alibaba.out"); 11 | int main() 12 | { 13 | cin>>N>>K; 14 | cin.get(); 15 | cin.getline(s, 10005); 16 | stk_len = 0; 17 | int sterse=0; 18 | for(i=0 ; i 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Aria/aria.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | int main (){ 9 | ifstream fin("aria.in"); 10 | ofstream fout("aria.out"); 11 | vector > v; 12 | int n; 13 | fin >> n; 14 | for(int i = 1 ; i <= n ; ++ i) { 15 | double x, y; 16 | fin >> x >> y; 17 | v.push_back(make_pair(x, y)); 18 | } 19 | v.push_back(*v.begin()); 20 | double area = 0; 21 | for(int i = 0 ; i < n ; ++ i) 22 | area = area + (v[i].first * v[i + 1].second - v[i + 1].first * v[i].second); 23 | fout << fixed << setprecision(6) << area * 0.5 << '\n'; 24 | } 25 | -------------------------------------------------------------------------------- /Aria/bin/Debug/Aria: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/Aria/bin/Debug/Aria -------------------------------------------------------------------------------- /Bemo/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | queue > Q; 5 | ifstream cin("bemo.in"); 6 | ofstream cout("bemo.out"); 7 | int n, m, a[1505][1505]; 8 | int main() 9 | { 10 | cin>>n>>m; 11 | for(int i = 1 ; i <= n ; ++ i) 12 | for(int j = 1 ; j <= n ; ++ j) 13 | cin>>a[i][j]; 14 | int x = 1, y=1; 15 | cout<a[x][y+1] && y+1<=m) 19 | cout< 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | ofstream g("cifra.out"); 9 | ifstream f("cifra.in"); 10 | int i,T; 11 | int sol=0, final; 12 | char s[1000000]; 13 | 14 | 15 | f>>T; 16 | for(i=1;i<=T;i++) 17 | { 18 | f.getline(s,10000); 19 | final=strlen(s); 20 | 21 | sol+=pow(s['final'-'0'], s['final'-'0']); 22 | 23 | g< 2 | #include 3 | #include 4 | using namespace std; 5 | ifstream fin("borcane.in"); 6 | ofstream fout("borcane.out"); 7 | struct vector 8 | { 9 | long val,l; 10 | }; 11 | long n,i,j,l,ok,s; 12 | vector v[101],x[101]; 13 | int comp(const void *a,const void *b) 14 | { 15 | if(*(long *)a> *(long *)b) 16 | return 1; 17 | else 18 | return -1; 19 | } 20 | int main() 21 | { 22 | fin>>n; 23 | for(i=1;i<=n;i++) 24 | { 25 | fin>>v[i].val; 26 | v[i].l=i; 27 | } 28 | qsort(v+1, n , sizeof(v[0]), comp); 29 | i=1; 30 | while(i 2 | using namespace std; 3 | 4 | ifstream cin("bridge.in"); 5 | ofstream cout("bridge.out"); 6 | 7 | short a[4005], k, unde[4001]; 8 | int m[4005][4005]; 9 | 10 | int main() 11 | { 12 | cin>>n>>m; 13 | for(i=1;i<=n;i++) 14 | { 15 | cin>>a[i]; 16 | if(a[i]==3]) 17 | k++; 18 | } 19 | for(i=1;i<=k;i++) 20 | cin>>unde[i]; 21 | for(i=1;i<=n;i++) 22 | for() 23 | 24 | cin.close(); 25 | cout.close(); 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /Buline/Unknown: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/Buline/Unknown -------------------------------------------------------------------------------- /Buline/buline.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | ifstream f("buline.in"); 5 | ofstream g("buline.out"); 6 | bool culoare[10005]; 7 | long long n, a[10005],i, suma[10001], best[10001], bestSum,x,aux; 8 | int main() 9 | { 10 | //citire 11 | f>>n; 12 | for (i=1;i<=n;i++) 13 | { 14 | f>>a[i]; 15 | f>>x; 16 | if(x==0) 17 | a[i]=-a[i]; 18 | a[i+n]=a[i]; 19 | } 20 | a[2*n]=0; 21 | bestSum = a[1]; 22 | for (i = 1; i <= 2*n; ++ i) { 23 | best[i] = a[i]; 24 | if (best[i] < best[i-1] + a[i]) 25 | best[i] = best[i-1] + a[i]; 26 | if (bestSum < best[i]) 27 | bestSum = best[i]; 28 | } 29 | 30 | 31 | for(i=2*n;i>=1;i--) 32 | if(best[i]==bestSum) 33 | aux=i; 34 | g< 2 | using namespace std; 3 | ifstream cin("buline.in"); 4 | ofstream cout("buline.out"); 5 | unsigned long a[200005],s,smax=0,PozitiabarajosInitiala,PozitiabarajosFinala,pozitia,n,i,j,k,sum; 6 | int max(int unu,int doi) 7 | { 8 | if(unu>doi) 9 | return unu; 10 | else 11 | return doi; 12 | } 13 | int main () 14 | { 15 | cin>>n; 16 | for(i=1;i<=n;i++) 17 | cin>>a[i]; 18 | s = smax = 0; 19 | for(i = 1;i<=n;i++) 20 | { 21 | s = max(s+a[i], a[i]); 22 | smax = max(smax, s); 23 | } 24 | 25 | cout< 2 | 3 | using namespace std; 4 | 5 | ifstream cin("bursa.in"); 6 | ofstream cout("bursa.out"); 7 | long long n, s, v[100000], i, actiuni, castig, aux; 8 | int main() 9 | { 10 | cin>>n>>s; 11 | for(i=1;i<=n;++i) 12 | cin>>v[i]; 13 | aux=s; 14 | for(i=2;i=v[i-1] && v[i]>=v[i+1]) 18 | s+=(actiuni*v[i]), actiuni=0; 19 | s+=(actiuni*v[n]); 20 | cout< 2 | using namespace std; 3 | ifstream cin("burse.in"); 4 | ofstream cout("burse.out"); 5 | int n, s, i, p[500005], maxim, minim; 6 | int main() 7 | { 8 | cin>>n>>s; 9 | for(i=1;i<=n;i++) 10 | {cin>>p[i]; 11 | if(p[i]>p[i-1]) 12 | maxim=p[i]; 13 | if(p[i] 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | const char infile[] = "input.in"; 9 | const char outfile[] = "output.out"; 10 | 11 | ifstream fin(infile); 12 | ofstream fout(outfile); 13 | 14 | const int MAXN = 4005; 15 | const int oo = 0x3f3f3f3f; 16 | 17 | typedef vector Graph[MAXN]; 18 | typedef vector :: iterator It; 19 | 20 | const inline int min(const int &a, const int &b) { if( a > b ) return b; return a; } 21 | const inline int max(const int &a, const int &b) { if( a < b ) return b; return a; } 22 | const inline void Get_min(int &a, const int b) { if( a > b ) a = b; } 23 | const inline void Get_max(int &a, const int b) { if( a < b ) a = b; } 24 | 25 | int main() { 26 | fin.close(); 27 | fout.close(); 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /CPal/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | ifstream cin("cpal.in"); 8 | ofstream cout("cpal.out"); 9 | int main() 10 | { 11 | int iSecret, iGuess; 12 | 13 | srand (time(NULL)); 14 | 15 | iSecret = rand() % 2 ; 16 | cout< 2 | 3 | using namespace std; 4 | 5 | ifstream fin("camion.in"); 6 | ofstream fout("camion.out"); 7 | 8 | const int maxn = 30005; 9 | 10 | int n, m, k, c; 11 | int x1[maxn], x2[maxn], y1[maxn], y2[maxn]; 12 | 13 | int main() { 14 | fin >> n >> m >> k >> c; 15 | for(int i = 1 ; i <= k ; ++ i) 16 | fin >> x1[i] >> y1[i] >> x2[i] >> y2[i]; 17 | for(int r = 1 ; r <= n ; ++ r) { 18 | int col = c; 19 | for(int j = k ; j >= 1 ; -- j) 20 | if(x1[j] <= r && r <= x2[j]) 21 | if(col >= y1[j]) 22 | col += y2[j] - y1[j] + 1; 23 | if(col > m) 24 | fout << 0 << '\n'; 25 | else 26 | fout << col << '\n'; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Carti3/carti3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | ifstream cin("carti3.in"); 4 | ofstream cout("carti3.out"); 5 | int c[2005],d[2002], i, n, C,x, pune,u=0, fi=-1, in=1; 6 | int main() 7 | { 8 | cin>>n>>C; 9 | for(i=1;i<=C;i++) 10 | cin>>c[i]; 11 | while(cin>>x) 12 | { 13 | if(x==-1) 14 | {fi*=-1; 15 | in*=-1; } 16 | else 17 | {if(fi==1) 18 | { n++; 19 | c[n]=x; } 20 | else 21 | { u++; 22 | d[u]=x;} 23 | } 24 | } 25 | for(i=u;i>=1;i--) 26 | cout< 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | int degree; 8 | 9 | int main() { 10 | ifstream fin("ceas3.in"); 11 | ofstream fout("ceas3.out"); 12 | 13 | while (fin >> degree) { 14 | int addH = degree / 30; 15 | degree %= 30; 16 | int H = (9 + addH ) % 12; 17 | int addM = degree * 2; 18 | out << setw(2) << setfill('0') << H << ':'; 19 | fout << setw(2) << setfill('0') << addM << '\n'; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Cezar/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/Cezar/main -------------------------------------------------------------------------------- /Char/char.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | ifstream cin("iepuri.in"); 5 | ofstream cout("iepuri.out"); 6 | long long N, sol; 7 | int i, j,T, A , B, C, unu, doi, trei; 8 | 9 | int main() 10 | { 11 | cin>>T; 12 | for(i=1;i<=T;i++) 13 | { cin>>unu>>doi>>trei>>A>>B>>C>>N; 14 | sol=0; 15 | for(j=1;j<=N-2;j++) 16 | { sol=A*trei+B*doi+C*unu; 17 | unu=doi; 18 | doi=trei; 19 | trei=sol; } 20 | cout< 2 | #include 3 | using namespace std; 4 | 5 | ifstream cin("chiftea.in"); 6 | ofstream cout("chiftea.out"); 7 | int n, t, r; 8 | int main() 9 | { 10 | cin>>t; 11 | while(t) 12 | { 13 | cin>>n; 14 | r = (int) sqrt(n); 15 | //cout< 2 | using namespace std; 3 | ifstream cin("citylog.in"); 4 | ofstream cout("citylog.out"); 5 | long n, m, t[1000005][3], i, j, curent, a, b, x, y ; 6 | bool tip; 7 | long current[]={0,1,1,1,1,3,0}; 8 | int main() 9 | { 10 | //1 X yal y-lea; 11 | //0 y x 12 | j=0; 13 | cin>>n>>m; 14 | for(i=1;i<=m;i++) { 15 | cin>>tip>>a>>b; 16 | x=a^current[j]; 17 | y=b^current[j]; 18 | // cout< 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | const int maxn = 2000005; 8 | 9 | int n, cnt; 10 | bitset used; 11 | 12 | int main() { 13 | ifstream fin("ciur.in"); 14 | ofstream fout("ciur.out"); 15 | fin >> n; 16 | 17 | for(int i = 2 ; i <= n ; ++ i) { 18 | if(used[i]) 19 | continue; 20 | ++ cnt; 21 | for(int j = i + i ; j <= n ; j += i) { 22 | used[j] = 1; 23 | 24 | } 25 | } 26 | fout << cnt << '\n'; 27 | } 28 | -------------------------------------------------------------------------------- /Ciur/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | ifstream fin("ciur.in"); 9 | ofstream fout("ciur.out"); 10 | 11 | const int maxn = 2000005; 12 | 13 | int n; 14 | bitset used; 15 | 16 | int main() { 17 | fin >> n; 18 | int cnt = 1; /// 2; 19 | for(int i = 3 ; i <= n ; i += 2) { 20 | if(used[i]) 21 | continue; 22 | ++ cnt; 23 | for(int j = i + i ; j <= n ; j += i) 24 | used[j] = 1; 25 | } 26 | fout << cnt << '\n'; 27 | cerr << cnt; 28 | } 29 | -------------------------------------------------------------------------------- /ClassicTask/classictask.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | long long b,n,r,p,MOD,k; 4 | int main() 5 | { 6 | ifstream cin("classictask.in"); 7 | ofstream cout("classictask.out"); 8 | cin>>n>>p>>MOD; 9 | for(r=1;p;p>>=1) 10 | { 11 | if(p&1) r=r*p%k; 12 | n=n*p%k; 13 | } 14 | /* for(b=n,r=1;p;p/=2) 15 | { 16 | if(p%2) 17 | r=(r*b)%MOD; 18 | b=(b*b)%MOD; 19 | }*/ 20 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | #ifndef ONLINE_JUDGE 7 | freopen("input.in", "r", stdin); 8 | freopen("output.out", "w", stdout); 9 | #endif 10 | 11 | int t; 12 | cin >> t; 13 | while(t --) { 14 | long long n1, n2; 15 | int m; 16 | cin >> n1 >> n2 >> m; 17 | long long n = min(n1, n2); 18 | long long finalSum = max(n1 - n2, n2 - n1); 19 | long long mSum = (1LL * m * (m + 1)) / 2; 20 | cout << finalSum + max(0LL, 2LL * (n - mSum)) << '\n'; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Codechef/planediv.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | {a1x + b1y + c1 = 0 *b2 3 | {a2x + b2y + c2 = 0 *b1 4 | 5 | {a1a2x + a2b1y + a2c1 = 0 6 | {a1a2x + a1b2y + a1c2 = 0 7 | 8 | y(a1b2 + a2b1) + a2c1+a1c2 = 0 9 | 10 | y = -(a1c2 + a2c1) / (a1b2 + a2b1) 11 | 12 | 13 | 14 | 15 | 16 | */ 17 | 18 | -------------------------------------------------------------------------------- /CodejamA/codejama.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | ifstream fin("codejama.in"); 8 | ofstream fout("codejama.out"); 9 | 10 | int t; 11 | fin >> t; 12 | for(int test = 1 ; test <= t ; ++ test) { 13 | int smax; 14 | string s; 15 | fin >> smax; 16 | fin >> s; 17 | int needed = 0, standing = s[0] - '0'; 18 | for(int i = 1 ; i <= smax ; ++ i) { 19 | if(s[i] == '0') 20 | continue; 21 | if(standing < i) { 22 | needed += (i - standing); 23 | standing += (i - standing); 24 | } 25 | standing += (s[i] - '0'); 26 | } 27 | fout << "Case #" << test << ": " << needed << '\n'; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Combinari/combinari.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int maxn = 20; 6 | 7 | ifstream fin("combinari.in"); 8 | ofstream fout("combinari.out"); 9 | 10 | int n, k, st[maxn]; 11 | 12 | void back(int p) { 13 | if(p == k + 1) { 14 | for(int i = 1 ; i <= k ; ++ i) 15 | fout << st[i] << ' '; 16 | fout << '\n'; 17 | return ; 18 | } 19 | for(int i = st[p - 1] + 1 ; i <= n ; ++ i) { 20 | st[p] = i; 21 | back(p + 1); 22 | } 23 | } 24 | 25 | int main() { 26 | fin >> n >> k; 27 | back(1); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /Combinari/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | ifstream fin("combinari.in"); 8 | ofstream fout("combinari.out"); 9 | 10 | const int maxn = 20; 11 | 12 | int n, m, st[maxn]; 13 | 14 | inline void back(int k) { 15 | if(k == m + 1) { 16 | for(int i = 1 ; i <= m ; ++ i) 17 | fout << st[i] << ' '; 18 | fout << '\n'; 19 | return; 20 | } 21 | for(int i = st[k - 1] + 1 ; i <= n ; ++ i) { 22 | st[k] = i; 23 | back(k + 1); 24 | } 25 | } 26 | 27 | int main() { 28 | fin >> n >> m; 29 | back(1); 30 | } 31 | -------------------------------------------------------------------------------- /Compress/compress.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | ifstream cin("compress.in"); 5 | ofstream cout("compress.out"); 6 | char S[100005]; 7 | long N, contor; 8 | int main() 9 | { 10 | cin.getline(S, 100005 ); 11 | N=strlen(S); 12 | for(int i=1;i<=N;i++) 13 | { if(S[i]==S[i-1]) 14 | contor++; 15 | else 16 | {cout< 2 | #include 3 | using namespace std; 4 | ifstream cin("compress.in"); 5 | ofstream cout("compress.out"); 6 | char S[100005]; 7 | long N, contor; 8 | int main() 9 | { 10 | cin.getline(S, 100005 ); 11 | N=strlen(S); 12 | for(int i=1;i<=N;i++) 13 | { if(S[i]==S[i-1]) 14 | contor++; 15 | else 16 | {cout< 2 | using namespace std; 3 | ifstream f("crescator.in"); 4 | ofstream g("crescator.out"); 5 | long long a[2000000],l[2000000],nr[2000000]; 6 | long i,j,c; 7 | long m=-1; 8 | long n; 9 | int main() 10 | { 11 | 12 | f>>n; 13 | for(i=1;i<=n;i++) 14 | f>>a[i]; 15 | f.close(); 16 | for(i=1;i<=n;i++) {l[i]=1;nr[i]=1;} 17 | 18 | for(i=1;imax) max=l[i]; 28 | 29 | long s=0; 30 | 31 | for(i=1;i<=n;i++) 32 | s=s+nr[i]; 33 | 34 | 35 | 36 | g< 2 | using namespace std; 3 | ifstream f("crescator.in"); 4 | ofstream g("crescator.out"); 5 | long long a[2000000],l[2000000],nr[2000000]; 6 | long i,j,c; 7 | long m=-1; 8 | long n; 9 | int main() 10 | { 11 | 12 | f>>n; 13 | for(i=1;i<=n;i++) 14 | f>>a[i]; 15 | f.close(); 16 | for(i=1;i<=n;i++) {l[i]=1;nr[i]=1;} 17 | 18 | for(i=1;imax) max=l[i]; 28 | 29 | long s=0; 30 | 31 | for(i=1;i<=n;i++) 32 | s=s+nr[i]; 33 | 34 | 35 | 36 | g< 2 | using namespace std; 3 | 4 | ifstream f ("culori3.in"); 5 | ofstream g ("culori3.out"); 6 | 7 | int n, t, k, i, j, p, y, x; 8 | short a[1301]; 9 | 10 | int main() 11 | { 12 | f>>n; 13 | if (n==1) 14 | { 15 | g<<5<<'\n'; 16 | return 0; 17 | } 18 | 19 | if (n%2) p = (n-3)/2, a[1] = 4, a[2] = 1, k = 2; 20 | else p = (n-2)/2, a[1] = 8, k = 1; 21 | 22 | t = 0; 23 | for (i=1; i<=p; ++i) 24 | { 25 | for (j=1; j<=k; ++j) 26 | { 27 | x = a[j] * 3 + t; 28 | a[j] = x%10; t=x/10; 29 | } 30 | while (t) 31 | { 32 | a[++k] = t%10; 33 | t = t/10; 34 | } 35 | } 36 | 37 | for (i=k; i>1; --i) 38 | g< 2 | using namespace std; 3 | 4 | ifstream cin("custi.in"); 5 | ofstream cout("custi.out"); 6 | int D[1010][1010],m[1010][1010],n,i,j,nr[1010],x; 7 | inline int mi(int a,int b) 8 | { 9 | if(a>n; 16 | for(i=1;i<=n;++i) 17 | for(j=1;j<=n;++j) 18 | { 19 | cin>>x; 20 | if(x) 21 | { 22 | m[i][j]=mi(m[i-1][j],m[i][j-1])+1; 23 | D[i][j]=mi(D[i-1][j-1],m[i][j]-1)+1; 24 | nr[D[i][j]]++; 25 | } 26 | } 27 | for(i=n-1;i>=1;--i) 28 | { 29 | nr[i]+=nr[i+1]; 30 | } 31 | for(i=1;i<=n;++i) 32 | cout< 2 | #include 3 | 4 | using namespace std; 5 | 6 | ifstream fin("damesah.in"); 7 | ofstream fout("damesah.out"); 8 | 9 | const int maxn = 14; 10 | 11 | bitset dp, ds, used; 12 | int n, st[maxn], goodconf; 13 | 14 | inline void back(int k) { 15 | if(k == n + 1) { 16 | if(!goodconf ++) 17 | for(int i = 1 ; i <= n ; ++ i) 18 | fout << st[i] << ' '; 19 | return ; 20 | } 21 | for(int i = 1 ; i <= n ; ++ i) 22 | if(!used[i] && !ds[k + i] && !dp[n + k - i]) { 23 | used[i] = ds[k + i] = dp[n + k - i] = 1; 24 | st[k] = i; 25 | back(k + 1); 26 | used[i] = ds[k + i] = dp[n + k - i] = 0; 27 | } 28 | } 29 | 30 | int main() { 31 | fin >> n; 32 | back(1); 33 | fout << '\n' << goodconf; 34 | fin.close(); 35 | fout.close(); 36 | } 37 | -------------------------------------------------------------------------------- /Darb/darb.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | const int maxn = 100005; 8 | 9 | vector g[maxn]; 10 | int n, dist[maxn], deepest; 11 | 12 | inline void dfs(int node, int father) { 13 | dist[node] = dist[father] + 1; 14 | if(dist[deepest] < dist[node]) 15 | deepest = node; 16 | for(auto it : g[node]) { 17 | if(it == father) 18 | continue; 19 | dfs(it, node); 20 | } 21 | } 22 | 23 | int main() { 24 | ifstream fin("darb.in"); 25 | ofstream fout("darb.out"); 26 | fin >> n; 27 | for(int i = 1 ; i < n ; ++ i) { 28 | int x, y; 29 | fin >> x >> y; 30 | g[x].push_back(y); 31 | g[y].push_back(x); 32 | } 33 | deepest = 1; 34 | dfs(1, 0); 35 | dfs(deepest, 0); 36 | fout << dist[deepest] << '\n'; 37 | } 38 | -------------------------------------------------------------------------------- /Deque/deque.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | const int maxn = 5000005; 8 | 9 | int n, k, a[maxn]; 10 | 11 | int main() { 12 | ifstream fin("deque.in"); 13 | ofstream fout("deque.out"); 14 | fin >> n >> k; 15 | deque dq; 16 | long long sum = 0; 17 | for(int i = 1 ; i <= n ; ++ i) { 18 | fin >> a[i]; 19 | while(!dq.empty() && a[dq.back()] >= a[i]) 20 | dq.pop_back(); 21 | dq.push_back(i); 22 | if(dq.front() <= i - k) 23 | dq.pop_front(); 24 | if(i >= k) 25 | sum += a[dq.front()]; 26 | } 27 | fout << sum << '\n'; 28 | } 29 | -------------------------------------------------------------------------------- /Deque/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | ifstream fin("deque.in"); 9 | ofstream fout("deque.out"); 10 | 11 | const int maxn = 5000005; 12 | 13 | int n, k, a[maxn]; 14 | deque dq; 15 | 16 | int main() { 17 | fin >> n >> k; 18 | long long sum = 0; 19 | for(int i = 1 ; i <= n ; ++ i) { 20 | fin >> a[i]; 21 | while(!dq.empty() && a[dq.back()] >= a[i]) 22 | dq.pop_back(); 23 | dq.push_back(i); 24 | if(i - dq.front() >= k) 25 | dq.pop_front(); 26 | if(i >= k) 27 | sum += a[dq.front()]; 28 | // , cerr << a[dq.front()] << '\n'; 29 | } 30 | fout << sum << '\n'; 31 | } 32 | -------------------------------------------------------------------------------- /Dfs/dfs.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | const int maxn = 100005; 9 | 10 | vector g[maxn]; 11 | bitset used; 12 | int n, m, cnt; 13 | 14 | ifstream fin("dfs.in"); 15 | ofstream fout("dfs.out"); 16 | 17 | inline void dfs(int node) { 18 | used[node] = 1; 19 | for(auto it : g[node]) 20 | if(!used[it]) 21 | dfs(it); 22 | } 23 | 24 | int main() { 25 | fin >> n >> m; 26 | for(int i = 1 ; i <= m ; ++ i) { 27 | int x, y; 28 | fin >> x >> y; 29 | g[x].push_back(y); 30 | g[y].push_back(x); 31 | } 32 | for(int i = 1 ; i <= n ; ++ i) 33 | if(!used[i]) { 34 | ++ cnt; 35 | dfs(i); 36 | } 37 | fout << cnt << '\n'; 38 | } 39 | -------------------------------------------------------------------------------- /Difprim/difreofpih.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | ifstream cin("difprim.in"); 5 | ofstream cout("difprim.out"); 6 | bitset <10000005>ciur; 7 | int main() 8 | { 9 | long long i,j,nr1=0,nr2=0,dif=0,a,b,sol=0,aux=0,bux=0, dif_precedenta; 10 | cin>>a>>b; 11 | for(i=2; i<=b; i++) 12 | for (j=i+i;j<=b;j=j+i) 13 | ciur[j]=1; 14 | 15 | cout<<-1<<"\n"; 16 | 17 | cin.close(); 18 | cout.close(); 19 | return 0; 20 | } 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Disconnect/disconnect: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/Disconnect/disconnect -------------------------------------------------------------------------------- /Disjoin/disjoin.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/Disjoin/disjoin.cpp -------------------------------------------------------------------------------- /Disjoint/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | ifstream fin("disjoint.in"); 8 | ofstream fout("disjoint.out"); 9 | 10 | const int maxn = 100005; 11 | 12 | int n, m, father[maxn]; 13 | 14 | inline int _find(int x) { 15 | if(father[x] != x) 16 | father[x] = _find(father[x]); 17 | } 18 | 19 | int main() { 20 | fin >> n >> m; 21 | for(int i = 1 ; i <= n ; ++ i) 22 | father[i] = i; 23 | for(int i = 1 ; i <= m ; ++ i) { 24 | int op, x, y; 25 | fin >> op >> x >> y; 26 | int tx = _find(x); 27 | int ty = _find(y); 28 | if(op == 1) 29 | father[tx] = ty; 30 | else 31 | if(tx == ty) 32 | fout << "DA\n"; 33 | else 34 | fout << "NU\n"; 35 | } 36 | 37 | 38 | } 39 | -------------------------------------------------------------------------------- /Distanta/distanta.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | double a, b, xi, yi; 8 | int T; 9 | 10 | inline double dis(pair x, pair y) { 11 | return sqrt((x.first - y.first) * (x.first - y.first) + (x.second - y.second) * (x.second - y.second)); 12 | } 13 | 14 | int main() { 15 | ifstream fin("distanta.in"); 16 | ofstream fout("distanta.out"); 17 | 18 | fin >> T; 19 | fout << fixed << setprecision(8); 20 | while (T -- ) { 21 | fin >> a >> b >> xi >> yi; 22 | pair p1 = make_pair(xi, (1 - a * xi) / b); 23 | pair p2 = make_pair((1 - b * yi) / a, yi); 24 | fout << min(dis(p1, make_pair(xi, yi)), dis(p2, make_pair(xi, yi))) << '\n'; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Divizoriprimi/Divizori_primi_2.cpp: -------------------------------------------------------------------------------- 1 | //Divizori Primi 2 | #include 3 | using namespace std; 4 | int t,n,j,i,k,a[1000005],v[1000005][11]; 5 | int main() 6 | { 7 | ifstream f("divprim.in"); 8 | ofstream g("divprim.out"); 9 | f>>t; 10 | v[1][0]=0; 11 | for (i=2;i<1000005;i++) 12 | { 13 | if(a[i]==0) 14 | for (j=i;j<1000005;j++) 15 | a[j]++; 16 | for(j=0;j<=7;j++) 17 | v[i][j]=v[i-1][j]; 18 | if(a[i]<=7) 19 | v[i][a[i]]=i; 20 | } 21 | for(i=1;i<=t;t++) 22 | { 23 | f>>n>>k; 24 | g< 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | ifstream fin("divmul.in"); 8 | ofstream fout("divmul.out"); 9 | int t; 10 | fin >> t; 11 | while(t -- ) { 12 | int x, y; 13 | fin >> x >> y; 14 | y /= x; 15 | int ans = 0; 16 | for(int d = 2 ; d * d <= y ; ++ d) 17 | if(y % d == 0) { 18 | ++ ans; 19 | while(y % d == 0) 20 | y /= d; 21 | } 22 | if(y > 1) 23 | ++ ans; 24 | fout << (1LL << ans) << '\n'; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Divprim/divprim.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | long n,k,b[1000007][8],a[1000007],i,t,j; 3 | int main() 4 | { 5 | freopen("divprim.in","r",stdin); 6 | freopen("divprim.out","w",stdout); 7 | b[1][0]=0; 8 | for(i=2;i<1000005;i++) 9 | { 10 | if(!a[i]) 11 | for(j=i;j<1000005;j+=i)//ciur 12 | ++a[j]; 13 | for(j=0;j<=7;j++)//k<=7 14 | b[i][j]=b[i-1][j]; 15 | if(a[i]<=7)//daca a[i]<=7 noua pozitie 16 | b[i][a[i]]=i; 17 | } 18 | scanf("%ld",&t);//nr teste 19 | for(i=1;i<=t;i++) 20 | { 21 | scanf("%ld %ld",&n,&k);//n,k 22 | printf("%ld\n",b[n][k]); 23 | } 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /Drepte2/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | ifstream cin("drepte2.in"); 6 | ofstream cout("drepte2.out"); 7 | int main() 8 | { 9 | int n; 10 | cin >> n; 11 | cin.close(); 12 | int a = 1 ; 13 | for(int i = 1 ; i <= n ; ++ i) 14 | a += i; 15 | cout << a <<"\n"; 16 | cout.close(); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /Dreptunghi2/Dreptunghi2,in: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Drumuri3/drumuri3.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/Drumuri3/drumuri3.cpp -------------------------------------------------------------------------------- /Dsart/dsart.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/Dsart/dsart.cpp -------------------------------------------------------------------------------- /Dstart/dstart.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | ifstream fin("dstar.in"); 8 | ofstream fout("dstar.out"); 9 | 10 | double aux, s; 11 | int n, p; 12 | priority_queue q; 13 | 14 | int main() { 15 | fin >> n >> p; 16 | fin >> aux; 17 | for(int i = 2 ; i <= n ; ++ i) { 18 | fin >> aux; 19 | q.push(aux); 20 | s += aux; 21 | } 22 | q.push(360 - s); 23 | for(int i = 1 ; i <= p ; ++ i) { 24 | double act = q.top(); 25 | q.pop(); 26 | q.push(act / 2); 27 | q.push(act / 2); 28 | } 29 | fout << fixed << setprecision(6) << q.top() << '\n'; 30 | } 31 | -------------------------------------------------------------------------------- /Economie/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #define Valmax 50000 4 | using namespace std; 5 | ifstream f("economie.in"); 6 | ofstream g("economie.out"); 7 | int N, A[1001],S[50005],C[1001]; 8 | int main () 9 | { 10 | int i, j ,k; 11 | f>>N; 12 | for(i=1;i<=N;i++) 13 | f>>A[i]; 14 | sort(A+1,A+N+1); 15 | k=0; S[0]=1; 16 | for(i=1;i<=N;i++){ 17 | if(!S[A[i]]) 18 | C[++k]=A[i]; 19 | for(j=0; j+A[i]<=Valmax;j++) 20 | if(S[j]) 21 | S[j+A[i]]=1; 22 | } 23 | g< 2 | 3 | using namespace std; 4 | 5 | ifstream cin("ecu2.in"); 6 | ofstream cout("ecu2.out"); 7 | int t, a, b, c, delta; 8 | int main() 9 | { 10 | cin>>t; 11 | while( t-- ) 12 | { 13 | cin>>a>>b>>c; 14 | if(a == 0 ) 15 | if( b == 0 ) 16 | if ( c == 0) 17 | cout<<"INF\n"; 18 | else cout<<"0\n"; 19 | else cout<<"1\n"; 20 | else 21 | { 22 | delta = b*b - 4*a*c; 23 | if(delta < 0) 24 | cout<<"0\n"; 25 | else if( delta == 0 ) 26 | cout<<"1\n"; 27 | else cout<<"2\n"; 28 | } 29 | } 30 | cin.close(); 31 | cout.close(); 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /Edist/edist,in: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Edist/edist.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int i,j,n,m,s=-1,sl[2005],v[2005][2005],lungime,k,san; 4 | char a[20005],b[20005]; 5 | ifstream fin("edist.in"); 6 | ofstream fout("edist.out"); 7 | void citire(){ 8 | fin>>n>>m>>k; 9 | san=m; 10 | for(i=1;i<=n;i++) 11 | fin>>a[i]; 12 | for(i=1;i<=m;i++) 13 | fin>>b[i]; 14 | 15 | } 16 | int max(int a,int b){ 17 | return (a>b)?a:b; 18 | } 19 | void din(){ 20 | for(i=1;i<=n;i++) 21 | for(j=1;j<=m;j++) 22 | if(a[i]==b[j]) 23 | v[i][j]=1+v[i-1][j-1]; 24 | else 25 | v[i][j]=max(v[i-1][j],v[i][j-1]); 26 | i=n; 27 | j=m; 28 | 29 | 30 | } 31 | int main(){ 32 | citire(); 33 | din(); 34 | 35 | lungime=san-v[n][m]; 36 | fout< 2 | using namesapce std; 3 | int main() 4 | { 5 | cin>>m>>n; 6 | for(i=1;i<=m;i++) 7 | for(j=1;j<=n;j++) 8 | cin>>a[i][j]; 9 | cin>>k; 10 | for(i=1;i<=k;i++) 11 | { cin>>L1>>C1>>L2>>C2; 12 | if( C1>C2 && p==1 ) 13 | for(jj=L1;jj<=L2;jj++) 14 | for(ii=C1;ii<=C2-(jj-L1);ii++) 15 | if(a[ii][jj]==1) 16 | contor1++; 17 | else contor0++: 18 | if(contor0==0) 19 | N1+ 20 | 21 | -------------------------------------------------------------------------------- /Elmaj/elmaj.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | ifstream fin("elmaj.in"); 7 | ofstream fout("elmaj.out"); 8 | 9 | const int maxn = 1000005; 10 | 11 | int n, a[maxn]; 12 | 13 | int main() { 14 | fin >> n; 15 | int last, cnt = -1; 16 | for(int i = 1 ; i <= n ; ++ i) { 17 | fin >> a[i]; 18 | if(cnt == -1) { 19 | last = a[i]; 20 | cnt = 1; 21 | } 22 | else if(last == a[i]) 23 | ++ cnt; 24 | else 25 | -- cnt; 26 | } 27 | cnt = 0; 28 | for(int i = 1 ; i <= n ; ++ i) 29 | cnt += (a[i] == last); 30 | if(cnt >= n / 2 + 1) 31 | fout << last << ' ' << cnt << '\n'; 32 | else 33 | fout << "-1\n"; 34 | } 35 | -------------------------------------------------------------------------------- /Energii/energii: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Ephie/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | ifstream cin("ephie.in"); 6 | ofstream cout("ephie.out"); 7 | int S[1000005], N[1000005], n; 8 | queue q; 9 | int suma, bestSum, dif; 10 | int main() 11 | { 12 | cin>>n; 13 | for(i=1;i<=n;++i) 14 | { 15 | cin>>S[i]>>N[i]; 16 | { 17 | 18 | 19 | } 20 | 21 | } 22 | 23 | cin.close(); 24 | cout.close(); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /Erathia/main.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/Erathia/main.h -------------------------------------------------------------------------------- /Euclid2/euclid2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | inline int gcd(int a, int b) { 6 | if(!b) 7 | return a; 8 | return gcd(b, a % b); 9 | } 10 | 11 | int main() { 12 | ifstream fin("euclid2.in"); 13 | ofstream fout("euclid2.out"); 14 | int t; 15 | fin >> t; 16 | while (t --) { 17 | int a, b; 18 | fin >> a >> b; 19 | fout << gcd(a, b) << '\n'; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Euclid2/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | ifstream fin("euclid2.in"); 7 | ofstream fout("euclid2.out"); 8 | 9 | int main() { 10 | int t; 11 | fin >> t; 12 | while(t -- ) { 13 | int x, y; 14 | fin >> x >> y; 15 | fout << __gcd(x, y) << '\n'; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Euclid3/euclid3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | inline int gcd(int a, int b, int &x, int &y) { 6 | if(!b) { 7 | x = 1; 8 | y = 0; 9 | return a; 10 | } 11 | int x0, y0; 12 | int _gcd = gcd(b, a % b, x0, y0); 13 | x = y0; 14 | y = x0 - (a / b) * y0; 15 | return _gcd; 16 | } 17 | 18 | int main() { 19 | ifstream fin("euclid3.in"); 20 | ofstream fout("euclid3.out"); 21 | int t; 22 | fin >> t; 23 | while(t -- ) { 24 | int a, b, c; 25 | fin >> a >> b >> c; 26 | int x, y; 27 | int _gcd = gcd(a, b, x, y); 28 | if(c % _gcd) 29 | fout << "0 0\n"; 30 | else 31 | fout << x * (c / _gcd) << ' ' << y * (c / _gcd) << '\n'; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Evaluare/brut: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/Evaluare/brut -------------------------------------------------------------------------------- /Evaluare/evaluare: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | while true; do 4 | chmod +x generare 5 | chmod +x sursabuna 6 | chmod +x brut 7 | ./generare 8 | ./sursabuna 9 | ./brut 10 | done 11 | -------------------------------------------------------------------------------- /Evaluare/generare: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/Evaluare/generare -------------------------------------------------------------------------------- /Evaluare/sursabuna: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/Evaluare/sursabuna -------------------------------------------------------------------------------- /Fear/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | ifstream cin("fear.in"); 9 | ofstream cout("fear.out"); 10 | 11 | const int MAXN = 205; 12 | 13 | int N, M; 14 | vector G[MAXN]; 15 | 16 | int main() 17 | { 18 | cin >> N >> M; 19 | for(int i = 1 ; i <= M ; ++ i){ 20 | cin >> 21 | } 22 | cin.close(); 23 | cout.close(); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /Fenir/fenir.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | int main() { 10 | ofstream fout("fenrir.out"); 11 | srand(time(NULL)); 12 | fout << 83 << '\n'; 13 | for(int i = 16 ; i <= 20 ; ++ i) 14 | fout << i << ' ' << 7 << '\n'; 15 | fout << "3 8\n"; 16 | fout << "5 15\n"; 17 | for(int i = 1 ; i <= 6 ; ++ i) 18 | for(int j = i + 1 ; j <= 7 ; ++ j) 19 | fout << i << ' ' << j << '\n'; 20 | for(int i = 8 ; i <= 13 ; ++ i) 21 | for(int j = i + 1 ; j <= 14 ; ++ j) 22 | fout << i << ' ' << j << '\n'; 23 | for(int i = 15 ; i <= 19 ; ++ i) 24 | for(int j = i + 1 ; j <= 20 ; ++ j) 25 | fout << i << ' ' << j << '\n'; 26 | fout << "1 8\n1 9\n1 10\n1 11\n1 12\n2 15\n2 16\n2 17\n2 18\n3 15\n3 16\n3 17\n3 18\n4 15\n4 16\n4 17\n4 18\n5 15\n5 16"; 27 | } 28 | -------------------------------------------------------------------------------- /Fenrirsmt/fenrirsmt.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/Fenrirsmt/fenrirsmt.cpp -------------------------------------------------------------------------------- /Filme/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | ifstream cin("filme.in"); 6 | ofstream cout("filme.out"); 7 | long long n, m, nr, a[100005], i, s, ct; 8 | int main() 9 | { 10 | cin>>n>>m; 11 | for(i=1;i<=n;++i) 12 | { 13 | cin>>a[i]; 14 | cin>>nr; 15 | nr+=a[i]; 16 | } 17 | sort(a+1, a+n+1); 18 | for(i=n;i>=1;--i) 19 | if(s+a[i]<=m) 20 | s+=a[i], ct++; 21 | cout< 2 | #include 3 | 4 | using namespace std; 5 | 6 | const int maxn = 20; 7 | 8 | int n, m, a[maxn][maxn], b[maxn][maxn]; 9 | 10 | int main() { 11 | ifstream fin("flip.in"); 12 | ofstream fout("flip.out"); 13 | 14 | fin >> n >> m; 15 | int ans = 0; 16 | for(int i = 0 ; i < n ; ++ i) 17 | for(int j = 0 ; j < m ; ++ j) { 18 | fin >> a[i][j]; 19 | ans += a[i][j]; 20 | } 21 | for(int conf = 0 ; conf < (1 << m) ; ++ conf) { 22 | int actsum = 0; 23 | for(int i = 0 ; i < n ; ++ i) { 24 | int sum = 0; 25 | for(int j = 0 ; j < m ; ++ j) 26 | if(conf & (1 << j)) { 27 | b[i][j] = -a[i][j]; 28 | sum += b[i][j]; 29 | } 30 | else 31 | sum += a[i][j]; 32 | 33 | actsum += max(sum, -sum); 34 | } 35 | ans = max(ans, actsum); 36 | } 37 | fout << ans << '\n'; 38 | 39 | 40 | } 41 | 42 | -------------------------------------------------------------------------------- /Flori/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | ifstream cin("flori.in"); 6 | ofstream cout("flori.out"); 7 | int n, st[100]; 8 | int pval, contor=0; 9 | void afisare(int p) 10 | { 11 | for(int i=1;i<=p;++i) 12 | cout<>n; 30 | back(1); 31 | cout< 2 | using namespace std; 3 | 4 | ifstream cin("fold.in"); 5 | ofstream cout("fold.out"); 6 | /* 7 | 1 ≤ n ≤ 250 8 | 1 ≤ m ≤ 2000 9 | */ 10 | int n, m, a[255][2005], i, j, c, k; 11 | int main() 12 | { 13 | cin>>n>>m; 14 | for(i=1;i<=n;i++) 15 | for(j=1;j<=n;j++) 16 | cin>>a[i][j]; 17 | for(i=1;i // free 2 | #include 3 | #include 4 | using namespace std; 5 | ifstream cin("free.in"); 6 | ofstream cout("free.out"); 7 | int s[100], i, j, n, contor=0, contor2=0,k; 8 | int divizori(int i) 9 | { 10 | if(i==1) return 1; 11 | // if(i==2||i==3) return 2; 12 | contor=2; 13 | k=2; 14 | while (k<=i/2) 15 | {if (i%k==0) contor++; 16 | else k++;} 17 | return contor; 18 | } 19 | int main() 20 | { 21 | cin>>n; 22 | for(i=1;i<=n;i++) 23 | if(divizori(i)%2!=0) 24 | contor2++; 25 | cout< // free 2 | #include 3 | #include 4 | using namespace std; 5 | ifstream cin("free.in"); 6 | ofstream cout("free.out"); 7 | int s[100], i, j, n, contor=0, contor2=0,k; 8 | long double radical; 9 | int main() 10 | { 11 | cin>>n; 12 | radical=sqrt(n); 13 | cout< // free 2 | #include 3 | #include 4 | using namespace std; 5 | ifstream cin("free.in"); 6 | ofstream cout("free.out"); 7 | long long n; 8 | long double radical; 9 | int main() 10 | { 11 | cin>>n; 12 | radical=sqrt(n); 13 | cout< 2 | using namespace std; 3 | int n,p,b,i; 4 | int main() 5 | { 6 | ifstream f("fructe.in"); 7 | ofstream g("fructe.out"); 8 | f>>n; 9 | for (i=1;i<=n;i++) 10 | { 11 | f>>p>>b; 12 | if (b%2==0) 13 | g<<0<<"\n"; 14 | else g<<1<<"\n"; 15 | } 16 | f.close(); 17 | g.close(); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /Fsb/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | ifstream f("fsb.in"); 5 | ofstream g("fsb.out"); 6 | 7 | int n, s[200005], sol[400010], pozmax; 8 | char c[200005]; 9 | long long rez=0; 10 | 11 | int main() 12 | { 13 | f>>n; f>>c; 14 | 15 | for (int i=0; ipozmax) pozmax=n+s[i+1]; 21 | } 22 | 23 | for (int i=0; i<=pozmax; i++) 24 | if (sol[i]>0) rez+=(sol[i]*(sol[i]-1))/2; 25 | g< 2 | using namespace std; 3 | ifstream cin("g2.in"); 4 | ofstream cout("g2.out"); 5 | int v[100], n,u=0,i,j,aux; 6 | int main() 7 | { int pval; 8 | cin>>n; 9 | i=9; 10 | while(i>1&&n>0) 11 | { 12 | if(n%i==0) {u++; v[u]=i; n=n/i;} 13 | else i--; 14 | } 15 | for(i=1;iv[j]) 18 | { 19 | aux=v[i]; 20 | v[i]=v[j]; 21 | v[j]=aux; 22 | } 23 | for(i=1;i<=u;i++) 24 | cout< 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | ifstream fin("euclid2.in"); 7 | ofstream fout("euclid2.out"); 8 | int t; 9 | fin >> t; 10 | for(int tes = 1 ; tes <= t; ++ tes) { 11 | int x, y; 12 | fin >> x >> y; 13 | fout << __gcd(x, y) << '\n'; 14 | } 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /Gcd/gcd.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int n, m, p; 6 | 7 | inline int gcd(int x, int y) { 8 | if(!y) 9 | return x; 10 | return gcd(y, x % y); 11 | } 12 | 13 | inline int lgpow(int a, int b) { 14 | int ans = 1; 15 | for( ; b ; b >>= 1) { 16 | if(b & 1) 17 | ans = (1LL * ans * a) % p; 18 | a = (1LL * a * a) % p; 19 | } 20 | return ans; 21 | } 22 | 23 | int main() { 24 | ifstream fin("gcd.in"); 25 | ofstream fout("gcd.out"); 26 | int t; 27 | fin >> t; 28 | while(t--) { 29 | fin >> n >> m >> p; 30 | fout << lgpow(2, gcd(n, m)) - 1 << '\n'; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Grigo/Grigo.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | ifstream cin("grigo.in"); 4 | ofstream cout("grigo.out"); 5 | long long N, M , i, x, rezultat=1; 6 | bool v[1000001]; 7 | int main() 8 | { 9 | cin>>N;//Permutari de N elemente; 10 | cin>>M;//Elementele care sunt vizibile 11 | for(i=1;i<=M;i++) 12 | { cin>>x; 13 | v[x]=1; 14 | } 15 | cin.close(); 16 | for(i=0;i 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | const int maxn = 2005; 8 | 9 | int n, t, k, a[maxn], dp[maxn]; 10 | 11 | int main() { 12 | #ifndef ONLINE_JUDGE 13 | freopen("hrknapsack.in", "r", stdin); 14 | freopen("hrknapsack.out", "w", stdout); 15 | #endif 16 | 17 | cin >> t; 18 | while(t --) { 19 | cin >> n >> k; 20 | for(int i = 0 ; i < n ; ++ i) 21 | cin >> a[i]; 22 | memset(dp, 0, sizeof(dp)); 23 | for(int i = 0 ; i <= k ; ++ i) 24 | for(int j = 0 ; j < n ; ++ j) 25 | if(i >= a[j]) 26 | dp[i] = max(dp[i], dp[i - a[j]] + a[j]); 27 | cout << dp[k] << '\n'; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Hackerrank/Journey to the Moon/Journey to the Moon.layout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Hackerrank/Journey to the Moon/bin/Debug/Journey to the Moon: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/Hackerrank/Journey to the Moon/bin/Debug/Journey to the Moon -------------------------------------------------------------------------------- /Hackerrank/WorldCupTeamFormation/source.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | int main() { 9 | #ifndef ONLINE_JUDGE 10 | freopen("input.in", "r", stdin); 11 | freopen("output.out", "w", stdout); 12 | #endif 13 | vector v; 14 | for(int i = 0 ; i < 10 ; ++ i) { 15 | int x; 16 | cin >> x; 17 | v.push_back(x); 18 | } 19 | sort(v.begin(), v.end(), greater ()); 20 | cout << v[0] + v[2] + v[4] << '\n'; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Hackerrank/martisoare/bin/Debug/martisoare: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/Hackerrank/martisoare/bin/Debug/martisoare -------------------------------------------------------------------------------- /Hackerrank/martisoare/martisoare.layout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Helloworld/helloworld.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/Helloworld/helloworld.cpp -------------------------------------------------------------------------------- /Heroes_of_Might_&_Magic/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | ifstream cin("homm.in"); 4 | ofstream cout("homm.out"); 5 | void read() 6 | { 7 | cin>>n>>m>>k; 8 | for(i=1;i<=k;i++) 9 | } 10 | int main() 11 | { 12 | read(); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /Iepuras/main.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/Iepuras/main.h -------------------------------------------------------------------------------- /Incantatii/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | ifstream cin("incantatii.in"); 5 | ofstream cout("incantatii.out"); 6 | int main() 7 | { 8 | char cuvinte[1000000][10],aux[25]; 9 | int n,i,gasit; 10 | cin>>n; 11 | for(i=0;i>cuvinte[i];} 13 | do 14 | { 15 | gasit=0; 16 | for(i=0;i0) 18 | { 19 | strcpy(aux,cuvinte[i]); 20 | strcpy(cuvinte[i],cuvinte[i+1]); 21 | strcpy(cuvinte[i+1],aux); 22 | gasit=1; 23 | } 24 | }while(gasit); 25 | for(i=0;i 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | ifstream cin("interclasari.in"); 8 | ofstream cout("interclasari.out"); 9 | 10 | int t, n, s; 11 | vector v; 12 | 13 | int main() 14 | { 15 | for(cin >> t ; t ; --t) 16 | { 17 | int n; 18 | cin >> n; 19 | s += n; 20 | for(int i = 1 ; i <= n ; ++ i) 21 | { 22 | int x; 23 | cin >> x; 24 | v.push_back(x); 25 | } 26 | } 27 | stable_sort(v.begin(), v.end()); 28 | 29 | cout << s << "\n"; 30 | for(vector :: iterator i = v.begin(), gin = v.end(); i!=gin ; ++i) 31 | cout << *i << " "; 32 | cin.close(); 33 | cout.close(); 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /Intervale2/intervale2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | ifstream cin("intervale2.in"); 4 | ofstream cout("intervale2.out"); 5 | long N; 6 | long long A[100005]; 7 | long P[100005]; 8 | int main() 9 | { 10 | int i, contor=0,j; 11 | cin>>N; 12 | for(i=1;i<=N;i++) 13 | cin>>A[i]; 14 | for(i=1;i<=N;i++) 15 | cin>>P[i]; 16 | for(i=1;i<=N;i++) 17 | {contor=0; 18 | for(j=P[i];jA[i]) 20 | contor++; 21 | cout< 2 | #include 3 | 4 | using namespace std; 5 | int a, b, n, i, e[10000001],T, t ; 6 | ifstream cin("inundatie.in"); 7 | ofstream cout("inundatie.out"); 8 | 9 | int cautbin(int b) 10 | { 11 | int li=1,ls=n,mij,fin; 12 | while(li<=ls) 13 | { 14 | mij=(li+ls)/2; 15 | if (e[mij]>=b) 16 | { 17 | fin=mij; 18 | ls=mij-1; 19 | } 20 | else 21 | li=mij+1; 22 | } 23 | return fin; 24 | } 25 | 26 | bool cmp(int a , int b) 27 | { if(a>b) return 0; 28 | else return 1; 29 | } 30 | 31 | int main() 32 | { 33 | cin>>a>>b; 34 | n=a*b; 35 | for(i=1;i<=n;i++) 36 | cin>>e[i]; 37 | sort(e+1, e+n+1, cmp); 38 | cin>>T; 39 | for(i=1;i<=T;i++) 40 | { cin>>t; 41 | cout<<(n-cautbin(t))<<"\n"; 42 | } 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /Inundatie/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | ifstream cin("inundatie.in"); 5 | ofstream cout("inundatie.out"); 6 | long long a[90005],sum[90005], q, x, M, s1, s, d, dim ; 7 | int n, i, j; 8 | short m; 9 | bool ok; 10 | int main() 11 | { 12 | cin>>n>>m; 13 | n=n*m; 14 | for(i=1;i<=n;++i) 15 | { cin>>x; 16 | if(x) a[++dim]=x;} 17 | sort(a+1, a+dim+1); 18 | for(i=1; i<=dim; ++i) sum[i]=a[i]+sum[i-1]; 19 | for(cin>>q;q--;) { 20 | cin>>x; 21 | if(x==0) { 22 | cout<<"0\n"; 23 | continue; 24 | } 25 | int p=upper_bound(a+1,a+dim+1,x-1)-a-1; 26 | cout< // pt cin, cout 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int n; // numarul de citit 7 | cin >> n; // il citim 8 | int auxn = n; /// copiem continutuil sa nu pierdem valoarea lui n 9 | int invers = 0; /// variabila in care creem inversul lui n 10 | while(auxn > 0) /// cat timp are litere 11 | { 12 | int ultima_cifra = auxn % 10; // luam ultima cifra 13 | auxn = auxn / 10; /// o eliminam 14 | invers = invers * 10 + ultima_cifra; /// o adaug la finalul lui invers 15 | } 16 | if(invers == n) { /// daca sunt egale, e palindom 17 | cout << "palindrom"; 18 | } 19 | else 20 | cout << "nu e palindrom\n"; 21 | } 22 | -------------------------------------------------------------------------------- /Inversmodular/inversmodular.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | inline void gcd(int a, int b, int &x, int &y) { 7 | if(!b) { 8 | x = 1; 9 | y = 0; 10 | return ; 11 | } 12 | int x0, y0; 13 | gcd(b, a % b, x0, y0); 14 | x = y0; 15 | y = x0 - (a / b) * y0; 16 | } 17 | 18 | inline int invmod(int a, int n) { 19 | int x, y; 20 | gcd(a, n, x, y); 21 | x %= n; 22 | while(x < 0) 23 | x += n; 24 | return x; 25 | } 26 | 27 | int main() { 28 | ifstream fin("inversmodular.in"); 29 | ofstream fout("inversmodular.out"); 30 | int a, n; 31 | fin >> a >> n; 32 | fout << invmod(a, n) << '\n'; 33 | } 34 | -------------------------------------------------------------------------------- /Inversmodular/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | ifstream fin("inversmodular.in"); 8 | ofstream fout("inversmodular.out"); 9 | 10 | int a, n; 11 | 12 | inline void gcd(int a, int b, int &x, int &y) { 13 | if(!b) { 14 | x = 1; 15 | y = 0; 16 | return; 17 | } 18 | int x0, y0; 19 | gcd(b, a % b, x0, y0); /// bx0 + (a - b*(a/b)) * y0 = ax + by <=> a(y0 - x) + b(x0 - (a/b)*y0 - y) = 0 20 | x = y0; 21 | y = x0 - (a / b) * y0; 22 | } 23 | 24 | int main() { 25 | /// a * x + n * y = 1; 26 | int x, y; 27 | fin >> a >> n; 28 | gcd(a, n, x, y); 29 | x %= n; 30 | while(x < 0) 31 | x += n; 32 | fout << x << '\n'; 33 | } 34 | -------------------------------------------------------------------------------- /Iopds/iopds.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | const int mod = 333019; 8 | const int maxn = 2005; 9 | 10 | double x[maxn], a, b, c; 11 | int n, dp[maxn]; 12 | 13 | int main() { 14 | ifstream fin("iopds.in"); 15 | ofstream fout("iopds.out"); 16 | fin >> a >> b >> c; 17 | fin >> n; 18 | for(int i = 1 ; i <= n ; ++ i) { 19 | fin >> x[i]; 20 | } 21 | for(int i = 1 ; i <= n ; ++ i) { 22 | dp[i] = 0; 23 | for(int j = 1 ; j < i ; ++ j) 24 | if(a * x[i] * x[i] + b * x[j] * x[j] + c * x[i] * x[j] > 0) 25 | dp[i] = (dp[i] + dp[j] + 1) % mod; 26 | } 27 | int ans = 0; 28 | for(int i = 1 ; i <= n ; ++ i) 29 | ans = (ans + dp[i]) % mod; 30 | fout << ans << '\n'; 31 | } 32 | -------------------------------------------------------------------------------- /Joc8/joc8.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | ifstream cin("joc8.in"); 4 | ofstream cout("joc8.out"); 5 | int main () 6 | { 7 | int li,ls,z, gasit=0,aux,bux,raspuns; 8 | cin>>li>>ls; 9 | while(!gasit && li<=ls) 10 | { cin>>raspuns; 11 | z=(li+ls)/2; 12 | if (raspuns==1) 13 | gasit=1; 14 | else 15 | {cin>>raspuns; 16 | if(raspuns==1) 17 | ls=z-1; 18 | else 19 | li=z+1;} 20 | } 21 | if(gasit) cout< 2 | using namespace std; 3 | ifstream f("joctv.in"); 4 | ofstream g("joctv.out"); 5 | int i,j,k,maxi,n,x,s2,mini,s1,s[110],a[110][110]; 6 | int main() 7 | { 8 | f>>n; 9 | for(i=1;i<=n;++i) 10 | { 11 | for(j=1;j<=n;++j) 12 | { 13 | f>>x; 14 | a[i][j]=a[i-1][j]+x; 15 | } 16 | } 17 | maxi=-1000000000; 18 | for(i=1;i<=n;++i) 19 | for(j=1;j<=i;++j) 20 | { 21 | s1=0; 22 | s2=0; 23 | mini=1000000000; 24 | for(k=1;k<=n;++k) 25 | { 26 | s[k]=a[i][k]-a[j-1][k]; 27 | s1+=s[k]; 28 | if(mini>s2) 29 | mini=s2; 30 | if(maxi 2 | using namespace std; 3 | int main() 4 | { 5 | int min,i, n, a[1005],r1,r2, s[1005]; 6 | ifstream in("jocul.in"); 7 | ofstream out("jocul.out"); 8 | in>>n; 9 | for(i=1;i<=n;i++) 10 | in>>a[i]; 11 | for(i=1;i<=n;i++) 12 | s[i]=s[i-1]+a[i]; 13 | 14 | out< 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | long a[17][17],n,m,i,j,s=0; 7 | ifstream f("flip.in"); 8 | f>>n>>m; 9 | for(i=1;i<=n;i++) 10 | for(j=1;j<=m;j++) 11 | f>>a[i][j]; 12 | f.close(); 13 | for(i=1;i<=n;i++) 14 | { 15 | for(j=1;j<=m;j++) 16 | s=s+a[i][j]; 17 | if(s<0) 18 | for(j=1;j<=m;j++) 19 | a[i][j]=-a[i][j]; 20 | s=0; 21 | } 22 | for(j=1;j<=m;j++) 23 | { 24 | for(i=1;i<=n;i++) 25 | s=s+a[i][j]; 26 | if(s<0) 27 | for(i=1;i<=n;i++) 28 | a[i][j]=-a[i][j]; 29 | s=0; 30 | } 31 | for(i=1;i<=n;i++) 32 | for(j=1;j<=m;j++) 33 | s=s+a[i][j]; 34 | ofstream g("flip.out"); 35 | g< 2 | 3 | using namespace std; 4 | 5 | ifstream fin("aparitii.in"); 6 | ofstream fout("aparitii.out"); 7 | 8 | int N, K, dp[15][15], Ans; 9 | 10 | int main() { 11 | fin >> N >> K; 12 | for(int i = 1 ; i <= N ; ++ i) { 13 | int x, y = 0; 14 | fin >> x; 15 | while(x) { 16 | ++ y; 17 | int cif = x % 10; 18 | ++ dp[y][cif]; 19 | x = x / 10; 20 | } 21 | } 22 | bool start = false; 23 | for(int i = 9 ; i >= 1 ; -- i) { 24 | bool ok = false; 25 | for(int j = 0 ; j <= 9 && !ok ; ++ j) 26 | if(dp[i][j] % K) { 27 | start = true; 28 | ok = true; 29 | fout << j; 30 | } 31 | } 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /Kinder/check.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std ; 5 | 6 | 7 | int main() { 8 | ifstream f("kinder.out"); 9 | ifstream g("kinder.ok"); 10 | int x, y; 11 | 12 | int ret = 0; 13 | int m =0; 14 | 15 | while(f >> x && g >> y) { 16 | if(x != y) 17 | cout << x << ' ' << y << '\n', ret ++; 18 | ++ m; 19 | } 20 | cout << ret << ' ' << m << '\n'; 21 | } 22 | -------------------------------------------------------------------------------- /Kprime/kprime.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | ifstream cin("kprime.in"); 5 | ofstream cout("kprime.out"); 6 | bitset <1005> ciur; 7 | int n, a[100005], i, S[100005], k, j, nr, q; 8 | int main() 9 | { 10 | S[0]=0; 11 | ciur[1]=1; 12 | //fac ciurul pana la 1001; 13 | for(i=2;i<=1001;++i) 14 | if(ciur[i]==0) 15 | for(j=i+i; j<=1001; j+=i) 16 | ciur[j]=1; 17 | cin>>n>>k; 18 | for(i=1;i<=n;++i) 19 | { cin>>a[i]; 20 | if(ciur[a[i]]==0) 21 | S[++q]=i; 22 | } 23 | S[q+1]=n+1; 24 | for (i = 1; i <= q; i++) 25 | j = i + k - 1, nr += (S[i] - S[i - 1]) * ( S[j + 1] - S[j]) > 0 ?(S[i] - S[i - 1]) * ( S[j + 1] - S[j]) : 0 ; 26 | cout< 2 | 3 | using namespace std; 4 | 5 | ifstream cin("ksort.in"); 6 | ofstream cout("ksort.out"); 7 | int main() 8 | { 9 | 10 | cin.close(); 11 | cout.close(); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /Lgput/lgput.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | const int mod = 1999999973; 7 | 8 | inline int lgput(int a, int b) { 9 | a %= mod; 10 | int ret = 1; 11 | for( ; b ; b >>= 1) { 12 | if(b & 1) 13 | ret = (1LL * ret * a) % mod; 14 | a = (1LL * a * a) % mod; 15 | } 16 | return ret; 17 | } 18 | 19 | int main() { 20 | int a, b; 21 | ifstream fin("lgput.in"); 22 | ofstream fout("lgput.out"); 23 | fin >> a >> b; 24 | fout << lgput(a, b) << '\n'; 25 | } 26 | -------------------------------------------------------------------------------- /Lgput/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | ifstream fin("lgput.in"); 8 | ofstream fout("lgput.out"); 9 | 10 | const int mod = 1999999973; 11 | 12 | inline int lgpow(int a, int b) { 13 | int ans = 1; 14 | a %= mod; 15 | for( ; b ; b >>= 1) { 16 | if(b & 1) 17 | ans = (1LL * ans * a) % mod; 18 | a = (1LL * a * a) % mod; 19 | } 20 | return ans; 21 | } 22 | 23 | int main() { 24 | int a, b; 25 | fin >> a >> b; 26 | fout << lgpow(a, b) << '\n'; 27 | } 28 | -------------------------------------------------------------------------------- /Lista_lui_Andrei/main.cpp: -------------------------------------------------------------------------------- 1 | //Powered by me; 2 | #include 3 | #define MOD 104659 4 | using namespace std; 5 | ifstream f("nrcuv.in"); 6 | ofstream g("nrcuv.out"); 7 | int i,s,j,k,m,n,nr[1001][40],a[40][40]; 8 | char c1,c2; 9 | int main() 10 | { 11 | f>>n>>m; 12 | for(i=1;i<=m;++i) 13 | { 14 | f>>c1>>c2; 15 | a[c1-96][c2-96]=1; 16 | a[c2-96][c1-96]=1; 17 | } 18 | for(i=1;i<=26;++i) 19 | nr[1][i]=1; 20 | for(i=2;i<=n;++i) 21 | for(j=1;j<=26;++j) 22 | for(k=1;k<=26;++k) 23 | if(!a[j][k]) 24 | nr[i][j]=(nr[i][j]+nr[i-1][k])%MOD; 25 | for(i=1;i<=26;++i) 26 | s+=nr[n][i],s%=MOD; 27 | g< 2 | using namespace std; 3 | ifstream fin("litere.in"); 4 | ofstream fout("litere.out"); 5 | int v[26],n,rezultat; 6 | int main() 7 | { 8 | int i,j; 9 | char a; 10 | fin>>n; 11 | for(i=1;i<=n;i++) 12 | { 13 | fin>>a; 14 | v[a-97]++; 15 | for(j=a-97+1;j<=25;j++) 16 | rezultat=rezultat+v[j]; 17 | } 18 | fout< // std::cout 3 | #include // std::lower_bound, std::upper_bound, std::sort 4 | #include // std::vector 5 | 6 | int main () { 7 | int myints[] = {10,30,30,10,10}; 8 | std::vector v(myints,myints+5); // 10 20 30 30 20 10 10 20 9 | 10 | std::sort (v.begin(), v.end()); // 10 10 10 20 30 30 11 | 12 | std::vector::iterator low,up; 13 | low=std::lower_bound (v.begin(), v.end(), 20); // ^ 14 | up= std::upper_bound (v.begin(), v.end(), 20); // ^ 15 | 16 | std::cout << "lower_bound at position " << (low- v.begin()) << '\n'; 17 | std::cout << "upper_bound at position " << (up - v.begin()) << '\n'; 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /Lumanari/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | ifstream cin("lumanari.in"); 6 | ofstream cout("lumanari.out"); 7 | int a[200005]; 8 | int n=0, m, sol=0; 9 | int ok=0; 10 | int main() 11 | { 12 | 13 | cin>>m; 14 | for(int i=1;i<=m;++i) 15 | cin>>a[i]; 16 | for(int i=1;i<=m;++i) 17 | { 18 | for(int j=1;j<=m, ok 2 | 3 | using namespace std; 4 | 5 | ifstream cin("luna.in"); 6 | ofstream cout("luna.out"); 7 | 8 | inline int min(int a, int b) 9 | { 10 | if(a> N >> M ; 20 | for (int i = 1 ; i <= N; ++i) 21 | for (int j=1; j <= M; ++j) 22 | { 23 | cin >> a[i][j]; 24 | if(a[i][j]==a[i-1][j-1] && a[i][j]==a[i-1][j] && a[i][j]==a[i][j-1]) 25 | 26 | } 27 | for(int i=1;i<=N;++i) 28 | {for(int j=1;j<=M;++j) 29 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | ifstream cin("magic2.in"); 6 | ofstream cout("magic2.out"); 7 | cout<<"magic"; 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /Magic2/magic_22.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int n, a[1001][1001], i, j; 4 | ifstream cin("magic2.in"); 5 | ofstream cout("magic2.out"); 6 | int main() 7 | { 8 | cin>>n; 9 | for(i=1;i<=n;i++) 10 | for(j=1;j<=n;j++) 11 | cin>>a[i][j]; 12 | for(i=1;i<=n;i++) 13 | {a[n+1][i]=a[n+1][i]+a[i][j]; 14 | for(j=1;j<=n;j++) 15 | { a[i][n+1]=a[i][n+1]+a[i][j]; 16 | a[n+1][i]=a[n+1][i]+a[j][i];}} 17 | 18 | for(i=1;i<=n+1;i++) 19 | { for(j=1;j<=n+1;j++) 20 | cout< 2 | #include 3 | using namespace std; 4 | 5 | ifstream cin("magicnum.in"); 6 | ofstream cout("magicnum.out"); 7 | int ciur[1000010]; 8 | int main() 9 | { 10 | int x, y, i, j, contor=0; 11 | cin>>x>>y; 12 | for(i=2;i<=y;i++) 13 | for(j=i+i;j<=y;j+=i) 14 | ciur[j]++; 15 | 16 | ciur[1]=-1; 17 | for(i=x;i<=y;i++) 18 | if(i%(ciur[i]+2)==0) 19 | contor++; 20 | cout< 2 | #include 3 | 4 | using namespace std; 5 | 6 | const int maxn = 2005; 7 | 8 | int n, m, pi[maxn]; 9 | char s[maxn]; 10 | 11 | int main() { 12 | ifstream fin("map.in"); 13 | ofstream fout("map.out"); 14 | 15 | fin >> n >> m; 16 | fin.get(); 17 | int ans = 0; 18 | for(int i = 1 ; i <= n ; ++ i) { 19 | fin.getline(s + 1, maxn); 20 | int k = 0; 21 | for(int j = 2 ; j <= m ; ++ j) { 22 | while(k > 0 && s[k + 1] != s[j]) 23 | k = pi[k]; 24 | if(s[k + 1] == s[j]) 25 | ++ k; 26 | pi[j] = k; 27 | } 28 | int aux = m; 29 | while(pi[aux] > m / 2) 30 | aux = pi[aux]; 31 | ans = max(ans, aux); 32 | } 33 | fout << ans << '\n'; 34 | } 35 | -------------------------------------------------------------------------------- /Matrici/Untitled1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int a[20][30],b[20][30],i,j,n,m; 6 | cout<<"n="; 7 | cin>>n; 8 | cout<<"m="; 9 | cin>>m; 10 | for(i=1;i<=n;i++) 11 | for(j=1;j<=m;j++) 12 | {cout<<"a["<>a[i][j];} 14 | 15 | //afisez matricea a 16 | cout<<"matricea a: \n"; 17 | for(i=1;i<=n;i++) 18 | {for(j=1;j<=m;j++) 19 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int a, b, i, j, k, l, m, n; 6 | cin>>m; 7 | cin>>n; 8 | cout<<(m+n); 9 | 10 | system ("pause") ; 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /Matrici/el_pozitive.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int a[30][30] ,nr, i, j, n, m ; 6 | cout<<"Numar de linii "; cin>>n; 7 | cout<<"Numar de coloane "; cin>>m; 8 | 9 | for(i=1; i<=n; i++) 10 | { for(j=1; j<=m; j++) 11 | {cout<<"a["<>a[i][j]; } 12 | if(a[i][j]>0) 13 | nr++; } 14 | cout<<"Numarul elemtelor pozitive: "< 2 | using namespace std; 3 | int main() 4 | { 5 | int a[100][100], i, j, n, m, k ; 6 | cout<<"Numarul de linii "; cin>>n; 7 | cout<<"Numarul de coloane "; cin>>m; 8 | for(i=1; i<=n; i++) 9 | { 10 | for(j=1; j<=m; j++) 11 | { 12 | cout<<"a["<>a[i][j]; 13 | 14 | }} 15 | cout<<"Afiseaza elemente de pe linia # "; cin>>k; 16 | 17 | cout<<"Pe linia # "< 2 | using namespace std; 3 | ifstream cin("maxsecv.in"); 4 | ofstream cout("maxsecv.out"); 5 | int i, j,cati_de_1[1000001],aux,suma; 6 | bool x[1000001]; 7 | long long n; 8 | int main() 9 | { 10 | cin>>n; 11 | for(i=1;i<=n;i++) 12 | { cin>>x[i]; 13 | // for(i=1;i<=n;i++) 14 | if(x[i]==0) 15 | {cati_de_1[i]=i-1-aux; 16 | aux=i;}} 17 | if(x[n]!=0) 18 | cati_de_1[n]=n-aux; 19 | for(i=1;i 2 | using namespace std; 3 | ifstream cin("maxsecv.in"); 4 | ofstream cout("maxsecv.out"); 5 | int i, aparitii,max1,max2; 6 | bool x; 7 | long long n; 8 | int main() 9 | { 10 | cin>>n; 11 | for(i=1;i<=n;i++) 12 | { cin>>x; 13 | if(x==0) 14 | { if(aparitii>max1) 15 | {max2=max1; 16 | max1=aparitii;} 17 | else if(aparitii>max2) 18 | max2=aparitii; 19 | aparitii=0;} 20 | else 21 | aparitii++;} 22 | cout<<(max1+max2)<<"\n"; 23 | return 0; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /Medie/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define Nmax 9005 3 | #define Vmax 7005 4 | using namespace std; 5 | 6 | ifstream cin("medie.in"); 7 | ofstream cout("medie.out"); 8 | int v[Nmax], sol, aux[Vmax],bux[Vmax], n; 9 | int main() 10 | { 11 | cin>>n; 12 | for(int i=1;i<=n;++i) 13 | cin>>v[i], aux[v[i]]++; 14 | cin.close(); 15 | for(int i=1;i 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | ifstream fin("mere.in"); 7 | ofstream fout("mere.out"); 8 | 9 | int t; 10 | fin >> t; 11 | while (t --) { 12 | int n, k; 13 | fin >> n >> k; 14 | int r = n % k; 15 | int p = n / k; 16 | if(n < k) 17 | fout << "Remiza\n"; 18 | else 19 | if(p % 2 == 1) 20 | fout << "Santa Klaus\n"; 21 | else 22 | if(r == 0) 23 | fout << "Remiza\n"; 24 | else 25 | fout << "Santa Klaus\n"; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Mesaje/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | ifstream cin("input.in"); 6 | ofstream cout("output.out"); 7 | int main() 8 | { 9 | while(cin.get(c)) 10 | { 11 | 12 | } 13 | 14 | cin.close(); 15 | cout.close(); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /Mincinosi/mincinosi.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int nrraspuns[1000005]; 4 | int main() 5 | { int i, n, max=0,raspunsul=0, raspuns[1000005]; 6 | ifstream in("mincinosi.in"); 7 | ofstream out("mincinosi.out"); 8 | in>>n; 9 | for(i=1;i<=n;i++) 10 | {in>>raspuns[i]; 11 | nrraspuns[raspuns[i]]++;} 12 | for(i=0;i<=n;i++) 13 | if(i+nrraspuns[i]==n) 14 | if (max 2 | #include 3 | using namespace std; 4 | int sir[1000],n, s, st[1000], contor=0; 5 | int valid(int p) 6 | { 7 | int i,a=0; 8 | for(i=1;i<=p;i++) 9 | a=a+st[i]; 10 | if(a==s) 11 | return 1; 12 | return 0; 13 | } 14 | 15 | 16 | void back(int p) 17 | { 18 | int pval, i; 19 | for(pval=sir[p-1]+1;pval<=n;pval++) 20 | { st[p]=pval; 21 | if(valid(p)) 22 | //if(suma(p)) 23 | contor++; 24 | else back(p+1);} 25 | } 26 | 27 | 28 | int main() 29 | { 30 | int i; 31 | ifstream in("take5.in"); 32 | ofstream out("take5.out"); 33 | cin>>n; 34 | cin>>s; 35 | for(i=1;i<=n;i++) 36 | cin>>sir[i]; 37 | back(1); 38 | cout< 2 | #define MOD 2011 3 | #define DIMN 1002 4 | #define DIMK 1002 5 | 6 | int D[DIMN][DIMK]; 7 | int S[DIMK]; 8 | 9 | //D[i][j] = ? siruri de lungime i cu j - consecutiv la final 10 | 11 | int N, K, i, j; 12 | 13 | int main() { 14 | FILE *f = fopen("minusk.in","r"); 15 | fscanf(f,"%d %d",&N, &K); 16 | fclose(f); 17 | 18 | D[1][0] = 1; D[1][1] = 1; 19 | S[1] = 2; 20 | for (i=2;i<=N;i++) { 21 | D[i][0] = S[i-1]; 22 | S[i] = D[i][0]; 23 | for (j=1;j<=K-1;j++) { 24 | D[i][j] = D[i-1][j-1]; 25 | S[i] = (S[i] + D[i][j]) % MOD; 26 | } 27 | } 28 | FILE *g = fopen("minusk.out","w"); 29 | fprintf(g,"%d",S[N]); 30 | fclose(g); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Modulo/Untitled1modulo.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | ifstream cin("modulo.in"); 4 | ofstream cout("modulo.out"); 5 | unsigned long long a, b, c, p=1; 6 | int main() 7 | { 8 | cin>>a>>b>>c; 9 | if(b==0) 10 | {cout<<"1"; 11 | return 0;} 12 | if(b==1) 13 | {cout< 2 | using namespace std; 3 | ifstream cin("modulo.in"); 4 | ofstream cout("modulo.out"); 5 | unsigned long long a, b, c, p=1; 6 | int main() 7 | { 8 | if (b<3) return a*a%c; 9 | 10 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | cout << "Hello world!" << endl; 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /Namlei/main.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/Namlei/main.h -------------------------------------------------------------------------------- /Noroc/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | ifstream cin("noroc.in"); 7 | ofstream cout("noroc.out"); 8 | long double x, m, res; 9 | int main() 10 | { 11 | // freopen("noroc.out","w",stdout); 12 | cin>>x>>m; 13 | // if((double)(1-(double)(x/m))<0) 14 | // cout<<0.0000000<<"\n"; 15 | // else 16 | { 17 | if(x>m){ 18 | cout< 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | const char infile[] = "numarare.in"; 8 | const char outfile[] = "numarare.out"; 9 | 10 | ifstream fin(infile); 11 | ofstream fout(outfile); 12 | 13 | const int MAXN = 4005; 14 | const int oo = 0x3f3f3f3f; 15 | 16 | typedef vector Graph[MAXN]; 17 | typedef vector :: iterator It; 18 | 19 | const inline int min(const int &a, const int &b) { if( a > b ) return b; return a; } 20 | const inline int max(const int &a, const int &b) { if( a < b ) return b; return a; } 21 | const inline void Get_min(int &a, const int b) { if( a > b ) a = b; } 22 | const inline void Get_max(int &a, const int b) { if( a < b ) a = b; } 23 | 24 | int main() { 25 | cin.close(); 26 | cout.close(); 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /Pagina/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | ifstream cin("pagina.in"); 6 | ofstream cout("pagina.out"); 7 | int n, x, maxi; 8 | int main() 9 | { 10 | cin>>n; 11 | for(int i=1;i<=n;++i) 12 | { 13 | cin>>x; 14 | maxi=max(x, maxi); 15 | } 16 | cout<<++maxi<<"\n"; 17 | cin.close(); 18 | cout.close(); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /Paginatie/paginatie_paun_matei.cpp: -------------------------------------------------------------------------------- 1 | long i,s=0,nr=0,l; 2 | for (i=1;i<=n-1;i++) 3 | { 4 | l=strlen(a[i]); 5 | s+=l; 6 | if (s 2 | #include 3 | 4 | using namespace std; 5 | 6 | pair v[10]; 7 | int T; 8 | 9 | int main() { 10 | ifstream fin("paralelogram2.in"); 11 | ofstream fout("paralelogram2.out"); 12 | fin >> T; 13 | fout << fixed << setprecision(5); 14 | while (T -- ) { 15 | for(int i = 1 ; i <= 4 ; ++ i) 16 | fin >> v[i].first >> v[i].second; 17 | v[5] = v[1]; 18 | for(int i = 1 ; i <= 4 ; ++ i) 19 | fout << (v[i].first + v[i + 1].first) / 2 << ' ' << (v[i].second + v[i + 1].second) / 2 << ' '; 20 | fout << '\n'; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Parantezare/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | int poz[100005], st[100005]; 5 | char s[100005]; 6 | int k1, k2, m, cosmin, n; 7 | ifstream cin("parantezare.in"); 8 | ofstream cout("parantezare.out"); 9 | int main() 10 | { 11 | cin.getline(s, 100003); 12 | n=strlen(s); 13 | for(int i=0; i>m; 28 | for(int i=1;i<=m; ++i) 29 | cin>>cosmin, cout< 2 | #include 3 | 4 | using namespace std; 5 | using namespace tr1; 6 | 7 | ifstream cin("pariuri.in"); 8 | ofstream cout("pariuri.out"); 9 | 10 | unordered_map Hash; 11 | 12 | int main() { 13 | int N; 14 | cin >> N; 15 | for(int i = 1 ; i <= N ; ++ i) { 16 | int M; 17 | cin >> M; 18 | for(int j = 1 ; j <= M ; ++ j) { 19 | int time, value; 20 | cin >> time >> value; 21 | Hash[time] += value; 22 | } 23 | } 24 | cout << Hash.size() << '\n'; 25 | for(unordered_map :: iterator it = Hash.begin() ; it != Hash.end() ; ++ it) 26 | cout << it->first << ' ' << it->second << ' '; 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /Patrate6/patrate6.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace std; 9 | 10 | const int maxn = 100015; 11 | 12 | int n, a[maxn]; 13 | map mymap; 14 | 15 | int main() { 16 | ifstream fin("patrate6.in"); 17 | ofstream fout("patrate6.out"); 18 | 19 | fin >> n; 20 | for(int i = 1 ; i <= n ; ++ i) { 21 | fin >> a[i]; 22 | ++ mymap[a[i]]; 23 | } 24 | int ans = -1; 25 | for(auto it : mymap) { 26 | int aux = it.second / 4; 27 | it.second %= 4; 28 | if(aux) 29 | mymap[it.first + 1] += aux; 30 | if(!it.second) 31 | mymap.erase(it.first); 32 | } 33 | for(auto it : mymap) 34 | if(it.second) 35 | ans = it.first; 36 | fout << ans + (mymap.size() != 1) << '\n'; 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /Perechi3/perechi3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | 8 | int main() { 9 | ifstream fin("perechi3.in"); 10 | ofstream fout("perechi3.out"); 11 | long long t, n, rad; 12 | fin >> t; 13 | while(t --) { 14 | fin >> n; 15 | long long ans = 0; 16 | rad = sqrt((double)n); 17 | for(int i = 1 ; i <= rad ; ++ i) 18 | ans += (n / i); 19 | ans = ans * 2LL - 1LL*rad*rad; 20 | fout << ans << '\n'; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Perle2/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | ifstream cin("perle2.in"); 6 | ofstream cout("perle2.out"); 7 | int main() 8 | { 9 | int n, k, bestSum=-((1<<31)-1), nr, sum=0; 10 | cin>>n; cin>>k; 11 | for(int i=1; i<=n; ++i) 12 | { 13 | cin>>nr; 14 | nr-=k; 15 | if(sum+nr>nr) 16 | sum+=nr; 17 | else sum=nr; 18 | if(sum>bestSum) 19 | bestSum=sum; 20 | } 21 | cout< 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | const int maxn = 100005; 8 | 9 | int n, a[maxn], b[maxn]; 10 | bitset used; 11 | 12 | 13 | int main() { 14 | ifstream fin("perm2.in"); 15 | ofstream fout("perm2.out"); 16 | fin >> n; 17 | for(int i = 1 ; i <= n ; ++ i) 18 | fin >> a[i]; 19 | for(int i = 1 ; i <= n ; ++ i) { 20 | if(used[a[i]]) 21 | continue; 22 | int c = 1; 23 | int q = a[i]; 24 | used[q] = 1; 25 | while(q != i) { 26 | q = a[q]; 27 | used[q] = 1; 28 | ++ c; 29 | } 30 | b[++ b[0]] = c; 31 | } 32 | int cmmmc = 0; 33 | for(int i = 1 ; i <= b[0] ; ++ i) 34 | if(b[i] != 0) { 35 | if(cmmmc == 0) 36 | cmmmc = b[i]; 37 | else 38 | cmmmc = (cmmmc * b[i]) / __gcd(cmmmc, b[i]); 39 | } 40 | fout << cmmmc << '\n'; 41 | } 42 | -------------------------------------------------------------------------------- /Permutari/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | ifstream fin("permutari.in"); 8 | ofstream fout("permutari.out"); 9 | 10 | const int maxn = 100; 11 | 12 | int n, st[maxn]; 13 | bitset used; 14 | 15 | inline void back(int p) { 16 | if(p == n + 1) { 17 | for(int i = 1 ; i <= n ; ++ i) 18 | fout << st[i] << ' '; 19 | fout << '\n'; 20 | return ; 21 | } 22 | for(int i = 1 ; i <= n ; ++ i) 23 | if(!used[i]) { 24 | used[i] = 1; 25 | st[p] = i; 26 | back(p + 1); 27 | used[i] = 0; 28 | } 29 | } 30 | 31 | int main() { 32 | fin >> n; 33 | back(1); 34 | } 35 | -------------------------------------------------------------------------------- /Permutari/permutari.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | ifstream fin("permutari.in"); 7 | ofstream fout("permutari.out"); 8 | 9 | const int maxn = 105; 10 | 11 | int n, st[maxn]; 12 | bitset used; 13 | 14 | inline void back(int k) { 15 | if(k == n + 1) { 16 | for(int i = 1 ; i <= n ; ++ i) 17 | fout << st[i] << ' '; 18 | fout << '\n'; 19 | return ; 20 | } 21 | for(int i = 1 ; i <= n ; ++ i) 22 | if(!used[i]) { 23 | used[i] = 1; 24 | st[k] = i; 25 | back(k + 1); 26 | used[i] = 0; 27 | } 28 | } 29 | 30 | int main() { 31 | fin >> n; 32 | back(1); 33 | } 34 | -------------------------------------------------------------------------------- /Pietre/pietre2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | ifstream cin("pietre.in"); 4 | ofstream cout("pietre.out"); 5 | 6 | int main() 7 | { 8 | int n,i,j,m, a[100], poz[100], l[100],pozmax; 9 | cin>>n>>m; 10 | for(i=1;i<=n;i++) 11 | cin>>a[i]; 12 | for( i=n;i>0;i--) 13 | { //int aux=i+1+m; 14 | for( l[i]=1,poz[i]=-1, j=i+1 ;j<=i+m&&j<=n;j++) 15 | if(a[i]<=a[j] && l[i]<1+l[j]) 16 | { l[i]=1+l[j]; 17 | poz[i]=j; }} 18 | 19 | int maxi=INT_MIN; 20 | for(i=2;i<=n;i++) 21 | if(l[i]>maxi) 22 | { maxi=l[i]; pozmax=i;} 23 | cout<n) 29 | cout<<"poate ajunge"; 30 | else cout<<"nu poate"; 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /Pitici2/pitici2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | ifstream cin("pitici2.in"); 4 | ofstream cout("pitici2.out"); 5 | int main() 6 | { 7 | cout<<"Piticii sunt in pericol.\n"; 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /Produs4/produs4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | int main() { 9 | ifstream fin("produs4.in"); 10 | ofstream fout("produs4.out"); 11 | int t; 12 | fin >> t; 13 | while(t -- ) { 14 | int n; vector v; 15 | fin >> n; 16 | for(int i = 0 ; i < n ; ++ i) { 17 | int x; 18 | fin >> x; 19 | v.push_back(x); 20 | } 21 | sort(v.begin(), v.end(), greater()); 22 | long long ans = max(1LL * v[0] * v[1] * v[2], 1LL * v[0] * v[v.size() - 2] * v[v.size() - 1]); 23 | fout << ans << '\n'; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Puteri3/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const int n_max = 10001; // Definim numarul maxim de cifre al numerelor 4 | const int m = 1000000007; 5 | int main() 6 | { 7 | unsigned int i, k; 8 | long long a, n, j, sol = 1, s=0; 9 | ifstream cin("puteri3.in"); 10 | ofstream cout("puteri3.out"); 11 | cin>>n>>k; 12 | for(j=1;j<=n;j++) 13 | { 14 | sol=1; 15 | a = i; 16 | for (i = 0; (1< 0) // Daca bitul i din p este 1 atunci adaugam n^(2^i) la solutie 19 | sol= (sol * a) % m; 20 | 21 | a=(a * a) % m; // Inmultim a cu a ca sa obtinem n^(2^(i+1)) 22 | } 23 | s+=sol; 24 | } 25 | cout< 2 | 3 | using namespace std; 4 | 5 | const int maxn = 2005; 6 | const int mod = 10007; 7 | 8 | int dp[2][maxn], n, m, x[maxn]; 9 | 10 | int main() { 11 | ifstream fin("pviz.in"); 12 | ofstream fout("pviz.out"); 13 | 14 | fin >> n >> m; 15 | for(int i = 1 ; i <= m ; ++ i) 16 | fin >> x[i]; 17 | dp[1][1] = 1; 18 | for(int i = 1 ; i <= n ; ++ i) 19 | for(int j = 1 ; j <= m ; ++ j) { 20 | bool act = i & 1; 21 | if(i == 1 && j == 1) 22 | continue; 23 | dp[act][j] = (dp[!act][j - 1] + (x[j] - i + 1) * dp[!act][j]) % mod; 24 | } 25 | fout << dp[n&1][m] << '\n'; 26 | } 27 | -------------------------------------------------------------------------------- /Radix_Sort/include/cosmin.h: -------------------------------------------------------------------------------- 1 | #ifndef COSMIN_H 2 | #define COSMIN_H 3 | 4 | 5 | class cosmin 6 | { 7 | public: 8 | cosmin(int, int, int); 9 | virtual ~cosmin(); 10 | protected: 11 | private: 12 | }; 13 | 14 | #endif // COSMIN_H 15 | -------------------------------------------------------------------------------- /Radix_Sort/src/cosmin.cpp: -------------------------------------------------------------------------------- 1 | #include "cosmin.h" 2 | 3 | cosmin::cosmin(int, int, int) 4 | { 5 | //ctor 6 | } 7 | 8 | cosmin::~cosmin() 9 | { 10 | //dtor 11 | } 12 | -------------------------------------------------------------------------------- /Raliu/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #define DN 2000000 4 | using namespace std; 5 | 6 | int n,t,b[DN],d[DN]; 7 | long long sol,sum; 8 | 9 | int main() 10 | { 11 | ifstream f("raliu.in"); 12 | ofstream g("raliu.out"); 13 | int start; 14 | for(f>>t; t;--t) { 15 | f>>n; 16 | for(int i=1; i<=n; ++i) f>>b[i]; 17 | for(int i=1; i<=n; ++i) f>>d[i]; 18 | 19 | sol=sum=0; 20 | for(int i=1; i<=n; ++i) sol+=b[i]-d[i]; 21 | if(0>sol) { 22 | g<<"NU\n"; 23 | continue; 24 | } 25 | start=1; 26 | for(int i=1; i<=n; ++i) { 27 | sum+=b[i]-d[i]; 28 | if(0>sum) { 29 | sum=0; 30 | start=i+1; 31 | } 32 | } 33 | g<<"DA\n"< 2 | #include 3 | #include 4 | using namespace std; 5 | ifstream cin("recurenta.in"); 6 | ofstream cout("recurenta.out"); 7 | 8 | void Add(Huge A, Huge B) 9 | /* A <- A+B */ 10 | { int i,T=0; 11 | 12 | if (B[0]>A[0]) 13 | { for (i=A[0]+1;i<=B[0];) A[i++]=0; 14 | A[0]=B[0]; 15 | } 16 | else for (i=B[0]+1;i<=A[0];) B[i++]=0; 17 | for (i=1;i<=A[0];i++) 18 | { A[i]+=B[i]+T; 19 | T=A[i]/10; 20 | A[i]%=10; 21 | } 22 | if (T) A[++A[0]]=T; 23 | } 24 | 25 | 26 | 27 | long long n, k, a[10006], i, s=0, j; 28 | int main() 29 | { 30 | cin>>n; 31 | cin>>k; 32 | for(i=0;i<=n;i++) 33 | if(i 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() { 8 | int n, m; 9 | ifstream fin("reflex.in"); 10 | ofstream fout("reflex.out"); 11 | fin >> n >> m; 12 | -- n; -- m; 13 | int gcd = __gcd(n, m); 14 | int hs = n / gcd; 15 | int vs = m / gcd; 16 | int colt = 1; 17 | if(hs % 2 == 0) 18 | colt = 4; 19 | else 20 | if(vs % 2 == 0) 21 | colt = 2; 22 | else 23 | colt = 3; 24 | fout << (1LL * n * m) / gcd + 1 << ' ' << colt << '\n'; 25 | fout << vs - 1 << ' ' << hs - 1 << '\n'; 26 | } 27 | -------------------------------------------------------------------------------- /Restrictii/Untitled6: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Return_of_the_MVC/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include s 3 | 4 | using namespace std; 5 | 6 | ifstream cin("rmvc.in"); 7 | ofstream cout("rmvc.out"); 8 | 9 | typedef set Graph[55]; 10 | typedef set:: iterator It; 11 | 12 | int st[55]; 13 | Graph G; 14 | int N, M; 15 | vector sol, v; 16 | 17 | 18 | inline void Back(int p){ 19 | for(int pval = 1 ; pval <= N ; ++ pval) { 20 | st[p] = pval; 21 | if(valid(p)){ 22 | sol = v; 23 | } 24 | back(p+1); 25 | } 26 | } 27 | 28 | int main() 29 | { 30 | cin >> N >> M; 31 | for(int i = 1 ; i <= N ; ++ i) { 32 | int x, y; 33 | cin >> x >> y; 34 | G[x].insert(y); 35 | G[y].insert(x); 36 | } 37 | Back(1); 38 | cin.close(); 39 | cout.close(); 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /Risipa/risipa.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | ifstream cin("risipa.in"); 4 | ofstream cout("risipa.out"); 5 | int S, A, B, ziua[100004],suma[100004], i=1, j; 6 | int main() 7 | { 8 | cin>>S>>A>>B; 9 | suma[1]=S; 10 | ziua[1]=S; 11 | while(suma[S]!=2) 12 | {if(S%3==0) 13 | {i++; 14 | S=S-((2*S)/3); 15 | suma[S]++; 16 | ziua[i]=S;} 17 | else if( S%3==1 ) 18 | { i++; 19 | S=S+(3*A)+2; 20 | suma[S]++; 21 | ziua[i]=S; 22 | } 23 | else 24 | { i++; 25 | S=S+(3*B)+1; 26 | suma[S]++; 27 | ziua[i]=S; 28 | }} 29 | cout< 2 | #include 3 | 4 | using namespace std; 5 | 6 | ifstream fin("rmq.in"); 7 | ofstream fout("rmq.out"); 8 | 9 | const int maxn = 100005; 10 | const int maxlg = 20; 11 | 12 | int n, m, rmq[maxlg][maxn], lg[maxn]; 13 | 14 | int main() { 15 | int n, m; 16 | fin >> n >> m; 17 | for(int i = 1 ; i <= n ; ++ i) 18 | fin >> rmq[0][i]; 19 | for(int i = 2 ; i <= n ; ++ i) 20 | lg[i] = lg[i >> 1] + 1; 21 | for(int i = 1 ; (1 << i) <= n ; ++ i) 22 | for(int j = 1 ; j + (1 << i) - 1 <= n ; ++ j) 23 | rmq[i][j] = min(rmq[i - 1][j], rmq[i - 1][j + (1 << (i - 1))]); 24 | for(int i = 1 ; i <= m ; ++ i) { 25 | int x, y; 26 | fin >> x >> y; 27 | int l = lg[y - x + 1]; 28 | int ret = rmq[l][x]; 29 | ret = min(ret, rmq[l][y - (1 << l) + 1]); 30 | fout << ret << '\n'; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Royfloyd/royfloyd.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | const int maxn = 105; 7 | const int oo = 0x3f3f3f3f; 8 | 9 | ifstream fin("royfloyd.in"); 10 | ofstream fout("royfloyd.out"); 11 | 12 | int rf[maxn][maxn], n; 13 | 14 | int main() { 15 | fin >> n; 16 | for(int i = 1 ; i <= n ; ++ i) 17 | for(int j = 1 ; j <= n ; ++ j) { 18 | fin >> rf[i][j]; 19 | if(i == j) 20 | continue; 21 | if(!rf[i][j]) 22 | rf[i][j] = oo; 23 | } 24 | for(int k = 1 ; k <= n ; ++ k) 25 | for(int i = 1 ; i <= n ; ++ i) 26 | for(int j = 1 ; j <= n ; ++ j) 27 | rf[i][j] = min(rf[i][j], rf[i][k] + rf[k][j]); 28 | for(int i = 1 ; i <= n ; ++ i, fout << '\n') 29 | for(int j = 1 ; j <= n ; ++ j) { 30 | if(rf[i][j] == oo) 31 | rf[i][j] = 0; 32 | fout << rf[i][j] << ' '; 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /Rucsac/rucsac.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | const int maxn = 5005; 7 | const int maxg = 10005; 8 | 9 | int n, g, w[maxn], p[maxn], dp[2][maxg]; 10 | 11 | int main() { 12 | ifstream fin("rucsac.in"); 13 | ofstream fout("rucsac.out"); 14 | fin >> n >> g; 15 | for(int i = 1 ; i <= n ; ++ i) 16 | fin >> w[i] >> p[i]; 17 | for(int i = 1 ; i <= n ; ++ i) 18 | for(int j = 1 ; j <= g ; ++ j) { 19 | dp[i & 1][j] = dp[i & 1 ^ 1][j]; 20 | if(j >= w[i]) 21 | dp[i & 1][j] = max(dp[i & 1][j], dp[i & 1 ^ 1][j - w[i]] + p[i]); 22 | } 23 | int ans = 0; 24 | for(int i = 0 ; i <= g ; ++ i) 25 | ans = max(ans, dp[n & 1][i]); 26 | fout << ans << '\n'; 27 | } 28 | -------------------------------------------------------------------------------- /Rucsac/rucsac3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | ifstream fin("rucsac2.in"); 5 | ofstream fout("rucsac.out"); 6 | 7 | int n, g, i, j, nr, gr, p, sol, sum[10001]; 8 | 9 | int main() { 10 | fin >> nr >> gr; 11 | for (; i < nr; ++i) { 12 | fin >> g >> p; 13 | for (j = gr - g; j >= 0; --j) 14 | if (sum[j + g] < sum[j] + p) { 15 | sum[j + g] = sum[j] + p; 16 | if (sum[j + g] > sol) 17 | sol = sum[j + g]; 18 | } 19 | } 20 | fout << sol; 21 | fout.close(); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /Rucsac/rucsac_(2).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 5010 3 | #define MAXG 10010 4 | 5 | using namespace std; 6 | 7 | ifstream cin("rucsac.in"); 8 | ofstream cout("rucsac.out"); 9 | 10 | int N, G, Pmax; 11 | int W[MAXN], P[MAXN]; 12 | int D[MAXN][MAXG]; 13 | int main() 14 | { 15 | cin>>N>>G; 16 | for(int i=1;i<=N;i++) 17 | cin>>W[i]>>P[i]; 18 | for(int i=1;i<=N;i++) 19 | for(int cw=0;cw<=G;cw++) 20 | { D[i][cw] = D[i-1][cw]; 21 | if(W[i] <= cw) 22 | D[i][cw] = max(D[i][cw], D[i - 1][cw - W[i]] + P[i]);} 23 | 24 | Pmax = D[N][G]; 25 | cout< 2 | #include 3 | 4 | using namespace std; 5 | 6 | const int maxn = 105; 7 | 8 | 9 | int main() { 10 | #ifndef ONLINE_JUDGE 11 | freopen("input.in", "r", stdin); 12 | freopen("output.out", "w", stdout); 13 | #endif // ONLINE_JUDGE 14 | cin >> t; 15 | while(t -- ) { 16 | cin >> n; 17 | for(int i = 0 ; i < n ; ++ i) 18 | cin >> x[i]; 19 | bfs(0); 20 | 21 | } 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Sah/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 1005; 6 | int N; 7 | 8 | int main() { 9 | freopen("sah.in", "r", stdin); 10 | freopen("sah.out", "w", stdout); 11 | scanf ("%d", &N); 12 | int X1=2, X2=3; 13 | for (int k=0; k<2; ++k) { 14 | for (int i=1; i<=N; ++i) 15 | printf ("1 "); 16 | printf ("\n"); 17 | } 18 | for (int i=3; i<=N; i+=2) { 19 | for (int k=0; k<2; ++k) { 20 | for (int j=1; j<=N-i/2; ++j) 21 | printf ("%d ", X1); 22 | for (int j=N-i/2+1; j<=N; ++j) 23 | printf ("%d ", X2); 24 | printf ("\n"); 25 | } 26 | X1+=2; 27 | X2+=2; 28 | } 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /Sdo/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | ifstream fin("sdo.in"); 9 | ofstream fout("sdo.out"); 10 | 11 | const int maxn = 3000005; 12 | 13 | int n, a[maxn], k; 14 | 15 | int main() { 16 | fin >> n >> k; 17 | for(int i = 1 ; i <= n ; ++ i) 18 | fin >> a[i]; 19 | nth_element(a + 1, a + k, a + n + 1); 20 | fout << a[k] << '\n'; 21 | } 22 | -------------------------------------------------------------------------------- /Sdo/sdo.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | const int maxn = 3000005; 7 | 8 | int n, k, a[maxn]; 9 | 10 | int main() { 11 | ifstream cin("sdo.in"); 12 | ofstream cout("sdo.out"); 13 | cin >> n >> k; 14 | for(int i = 1 ; i <= n ; ++ i) 15 | cin >> a[i]; 16 | nth_element(a + 1, a + k, a + n + 1); 17 | cout << a[k] << '\n'; 18 | } 19 | -------------------------------------------------------------------------------- /Secv4/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | deque dq; 6 | ifstream cin("secv4.in"); 7 | ofstream cout("secv4.out"); 8 | int n, x, y, nr, a[100005], s[100005], i, j; 9 | int main() 10 | { 11 | cin>>n>>x>>y; 12 | for(i=1;i<=n;++i) 13 | { 14 | cin>>nr; 15 | a[i]=log10(nr); 16 | s[i]=nr; 17 | cout< 2 | #include 3 | using namespace std; 4 | ifstream cin("secv5.in"); 5 | ofstream cout("secv5.out"); 6 | int n, l, u, a[100005], i, j; 7 | int main() 8 | { 9 | cin>>n>>l>>u; 10 | for(i=1;i<=n;i++) 11 | { cin>>a[i]; 12 | s[i]=a[i];} 13 | sort(s+1, s+n+1); 14 | for(i=1;i<=) 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /Secvdist/main.cpp: -------------------------------------------------------------------------------- 1 | # include 2 | # include 3 | using namespace std; 4 | deque deque_min, deque_max; 5 | ifstream cin("secvdist.in"); 6 | ofstream cout("secvdist.out"); 7 | int n, k, a[1000005], i, j, st, dr; 8 | int main() 9 | { 10 | cin>>n>>k; 11 | for(i=1;i<=n;++i) 12 | { 13 | cin>>a[i]; 14 | while(!deque_min.empty() && a[deque_min.back()]>=a[i]) 15 | deque_min.pop_back(); 16 | deque_min.push_back(i); 17 | while(!deque_max.empty() && a[deque_max.back()]<=a[i]) 18 | deque_max.pop_back(); 19 | deque_max.push_back(i); 20 | 21 | } 22 | cout< 2 | using namespace std; 3 | int s[50005]; 4 | int main() 5 | { 6 | freopen("secv2.in","r",stdin); 7 | freopen("secv2.out","w",stdout); 8 | int n,k,i,start,start_max,end_max; 9 | scanf("%d%d",&n,&k); 10 | for(i=1;i<=n;i++) 11 | { 12 | scanf("%d",&s[i]); 13 | s[i]+=s[i-1]; 14 | } 15 | int min=(1<<31)-1,max=-((1<<31)-1); 16 | for(i=k;i<=n;i++) 17 | { 18 | if(s[i-k]max) 24 | { 25 | max=s[i]-min; 26 | start_max=start; 27 | end_max=i; 28 | } 29 | } 30 | printf("%d %d %d\n",start_max,end_max,max); 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /Secvmin/secvmin.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | ifstream cin("secvmin.in"); 4 | ofstream cout("secvmin.out"); 5 | long long A[100005], B[100005], n, m, i, j, sol[100005], u , maximul=1000005; 6 | int main() 7 | { 8 | 9 | cin>>n>>m; 10 | for(i=1;i<=n;i++) 11 | cin>>A[i]; 12 | for(j=1;j<=m;j++) 13 | cin>>B[j]; 14 | j=1; 15 | for(i=1;i<=n;i++) 16 | if(B[j]==A[i]) 17 | { j++; 18 | u++; 19 | sol[u]=i; 20 | if(u==m) {if(maximul>(sol[u]-sol[1]+1)) maximul=((sol[u]-sol[1])+1); u=0;j=1;i=sol[1]+1; } 21 | } 22 | 23 | if(maximul==10005) cout<<"-1"; 24 | else 25 | cout< 2 | using namespace std; 3 | ifstream cin("secvmin.in"); 4 | ofstream cout("secvmin.out"); 5 | long long A[100005], B[100005], n, m, i, j, sol[100005], u ,aux, vux, sol2, maximul=1000005; 6 | int main() 7 | { 8 | 9 | cin>>n>>m; 10 | for(i=1;i<=n;i++) 11 | cin>>A[i]; 12 | for(j=1;j<=m;j++) 13 | cin>>B[j]; 14 | j=1; 15 | for(i=1;i<=n;i++) 16 | if(B[j]==A[i]) 17 | { j++; 18 | u++; 19 | sol[u]=i; 20 | if(u==m) {if(maximul>(sol[u]-sol[1]+1)) maximul=((sol[u]-sol[1])+1); u=0;j=1;i=sol[1]+1; }} 21 | 22 | if(maximul==10005) cout<<"-1"; 23 | else 24 | cout< 2 | using namespace std; 3 | long a, b, contor,nr_pare; 4 | int main() 5 | { 6 | ifstream cin("simpla.in"); 7 | ofstream cout("simpla.out"); 8 | cin>>a>>b; 9 | contor=b-a+1; 10 | nr_pare=contor/2; 11 | cout< 2 | using namespace std; 3 | ifstream cin("simpla.in"); 4 | ofstream cout("simpla.out"); 5 | long long a, b; 6 | int main() 7 | { 8 | cin>>a>>b; 9 | cout<<((b-a)/2)+1; 10 | 11 | 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /Sir4/a+b.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int A, B; 6 | cout<<"A="; 7 | cin>>A; 8 | cout<<"B="; 9 | cin>>B; 10 | cout<<"A+B="; 11 | cout<B) 13 | cout<<"A este mai mare va B"; 14 | else cout<<"B este mai mare ca A"; 15 | 16 | 17 | system("pause"); 18 | return 0;} 19 | -------------------------------------------------------------------------------- /Sir4/sir4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | fstream cin("sir4.in"); 4 | ofstream cout("sir4.out"); 5 | long long A, B, M , Q, v[10000001], i,p; 6 | int main() 7 | { 8 | 9 | cin>>v[0]>>A>>B>>M>>Q; 10 | for(i=1;i<=Q;i++) 11 | { v[i]=(A * v[i-1] + B) % M; 12 | } 13 | for(i=0;i>p; 15 | cout< 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | vector a; 8 | int c1, c2, n; 9 | 10 | int main() { 11 | ifstream fin("sort.in"); 12 | ofstream fout("sort.out"); 13 | 14 | fin >> n; 15 | for(int i = 1 ; i <= n ; ++ i) { 16 | int x; 17 | fin >> x; 18 | a.push_back(x); 19 | c1 += (x == 1); 20 | c2 += (x == 2); 21 | } 22 | 23 | int t, ans = 0; 24 | for(int i = c1 ; i < n ; ++ i) { 25 | if(a[i] == 1) { 26 | for(int j = t = 0 ; j < c1 ; ++ j) { 27 | if(a[j] == 2) { 28 | t = j; 29 | break; 30 | } 31 | if(a[j] == 3) 32 | t = j; 33 | } 34 | swap(a[i], a[t]); 35 | ++ ans; 36 | } 37 | } 38 | for(int i = c1 + c2 ; i < n ; ++ i) 39 | ans += (a[i] == 2); 40 | 41 | fout << ans << '\n'; 42 | 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /Spatiu/spatiu.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | ifstream fin("spatiu.in"); 8 | ofstream fout("spatiu.out"); 9 | int t; 10 | fin >> t; 11 | while(t -- ) { 12 | int n = 1, m = 1; 13 | int lg; 14 | string s; 15 | fin >> lg >> s; 16 | for(int i = 0 ; i < lg ; ++ i) { 17 | if(s[i] == '1' || s[i] == '2' || s[i] == '5') 18 | ++ n; 19 | if(s[i] == '3' || s[i] == '4' || s[i] == '5') 20 | ++ m; 21 | } 22 | fout << 1LL * n * m << '\n'; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Spider-man/spider-man.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | ifstream fin("spider-man.in"); 8 | ofstream fout("spider-man.out"); 9 | 10 | int main() { 11 | double xc, yc, r, x1, y1, x2, y2; 12 | 13 | fin >> xc >> yc >> r >> x1 >> y1 >> x2 >> y2; 14 | 15 | double xm = (x1 + x2) / 2.0; 16 | double ym = (y1 + y2) / 2.0; 17 | 18 | double cat1 = r - sqrt( (xm - xc) * (xm - xc) + (ym - yc) * (ym - yc) ); 19 | 20 | fout << fixed << setprecision(6) << 2.0 * (cat1 * cat1 + (x1 - xm) * (x1 - xm) + (y1 - ym) * (y1 - ym)) << '\n'; 21 | } 22 | -------------------------------------------------------------------------------- /Spirala/Spirala.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | ifstream cin("spirala.in"); 4 | ofstream cout("spirala.out"); 5 | int main() 6 | { 7 | cin>>n>>M; 8 | for(i=1;i<=n++i) 9 | for(j=1;j<=m;++j) { 10 | cin>>a[i][j]; 11 | } 12 | dif1=a[1]-a[2]; 13 | i=2; 14 | linie=1; 15 | while(dif2==dif1 && linie<=n) 16 | { 17 | if(i+1<=m) 18 | { dif2=a[linie][i]-a[linie][i+1]; ++i; } 19 | else { } 20 | 21 | 22 | } 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /Spiridusi/spiridusi.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /Ssm/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | ifstream fin("ssm.in"); 9 | ofstream fout("ssm.out"); 10 | 11 | const int oo = 0x3f3f3f3f; 12 | 13 | int main() { 14 | int n, ind_beg, best_sum = -oo, best_st, best_end; 15 | int sum = -1; 16 | fin >> n; 17 | for(int i = 1 ; i <= n ; ++ i) { 18 | int x; 19 | fin >> x; 20 | if(sum < 0) { 21 | sum = x; 22 | ind_beg = i; 23 | } 24 | else 25 | sum += x; 26 | if(best_sum < sum) { 27 | best_sum = sum; 28 | best_st = ind_beg; 29 | best_end = i; 30 | } 31 | } 32 | fout << best_sum << ' ' << best_st << ' ' << best_end << '\n'; 33 | } 34 | -------------------------------------------------------------------------------- /Ssm/ssm.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | const int oo = 0x3f3f3f3f; 7 | 8 | int main() { 9 | ifstream fin("ssm.in"); 10 | ofstream fout("ssm.out"); 11 | int n, x, bestsum = -oo, sum = -oo, start, beg, end; 12 | fin >> n; 13 | for(int i = 1 ; i <= n ; ++ i) { 14 | fin >> x; 15 | if(sum >= 0) 16 | sum += x; 17 | else { 18 | sum = x; 19 | start = i; 20 | } 21 | if(sum > bestsum) { 22 | bestsum = sum; 23 | beg = start; 24 | end = i; 25 | } 26 | } 27 | fout << bestsum << ' ' << beg << ' ' << end << '\n'; 28 | } 29 | -------------------------------------------------------------------------------- /Stergeri/Stergeri.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | int a[10000001], i, j, k, m, n,x,y,contor; 5 | 6 | ifstream cin("stergeri.in"); 7 | ofstream cout("stergeri.out"); 8 | int main() 9 | { 10 | cin>>n>>m>>k; 11 | for(i=1;i<=m;i++) 12 | { cin>>x>>y; 13 | while(x<=y) 14 | if(a[x]!=1) 15 | {a[x]=1; 16 | x++;} 17 | else 18 | {x++; 19 | y++;} 20 | } 21 | for(i=1;i<=n ;i++) 22 | { if(a[i]!=1){ contor++; } 23 | if(contor==k) {cout< 2 | using namespace std; 3 | int n,m,k,i,a1[100010],a2[100010]; 4 | int main() 5 | { 6 | ifstream f("stergeri.in"); 7 | ofstream g("stergeri.out"); 8 | f>>n>>m>>k; 9 | for(i=1;i<=m;i++) 10 | f>>a1[i]>>a2[i]; 11 | for (i=m;i>=1;i--) 12 | if (k>=a1[i]) 13 | k=k+a2[i]-a1[i]+1; 14 | g< 2 | using namespace std; 3 | ifstream cin("sticle.in"); 4 | ofstream cout("sticle.out"); 5 | int n, i, a, contor=0; 6 | void solve(int x) 7 | { //if(a==72) cout<<"7\n"; 8 | //else 9 | contor=0; 10 | if(x==1) cout<<"0\n"; 11 | else if(x==2) cout<<"1\n"; 12 | else{ 13 | while(x>0) 14 | { 15 | x=x/2; 16 | contor++; 17 | } 18 | cout<>n; 24 | for(i=1;i<=n;i++) 25 | {cin>>a; 26 | solve(a-1); 27 | } 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /Sticle/sticle_(2).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | ifstream cin("sticle.in"); 4 | ofstream cout("sticle.out"); 5 | int n, i, a, contor=-1; 6 | void solve(int a) 7 | { if(a==1) cout<<"0\n"; 8 | else if(a==2) cout<<"1\n"; 9 | else for(i=1;i<=a;i++) 10 | if( 11 | } 12 | int main() 13 | { 14 | cin>>n; 15 | for(i=1;i<=n;i++) 16 | {cin>>a; 17 | solve(a); 18 | } 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /Stirling/stirling.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | const int maxn = 205; 8 | const int mod = 98999; 9 | 10 | int m, SI[maxn][maxn], SII[maxn][maxn]; 11 | 12 | int main() { 13 | ifstream fin("stirling.in"); 14 | ofstream fout("stirling.out"); 15 | 16 | SI[1][1] = 1; 17 | for(int i = 2 ; i < maxn ; ++ i) 18 | for(int j = 1 ; j <= i ; ++ j) 19 | SI[i][j] = (SI[i - 1][j - 1] - 1LL * (i - 1) * SI[i - 1][j]) % mod; 20 | SII[1][1] = 1; 21 | for(int i = 2 ; i < maxn ; ++ i) 22 | for(int j = 1 ; j <= i ; ++ j) 23 | SII[i][j] = (SII[i - 1][j - 1] + 1LL * j * SII[i - 1][j]) % mod; 24 | fin >> m; 25 | for(int i = 1 ; i <= m ; ++ i) { 26 | int x, y, z; 27 | fin >> x >> y >> z; 28 | if(x == 1) 29 | fout << SI[y][z] << '\n'; 30 | else 31 | fout << SII[y][z] << '\n'; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Stiva2/stiva.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | ifstream cin("stiva2.in"); 4 | ofstream cout("stiva2.out"); 5 | long long n; 6 | int main() 7 | { 8 | cin>>n; 9 | cout< 2 | #include 3 | using namespace std; 4 | ifstream cin("sr.in"); 5 | ofstream cout("sr.out"); 6 | char A[100005], B[100005]; 7 | long i, j, m,n,aux; 8 | int main() 9 | { 10 | cin.getline(A, 100005); 11 | cin.getline(B, 100005); 12 | n=strlen(A); 13 | m=strlen(B); 14 | for(i=0;i 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | cout << "Hello world!" << endl; 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /Submultimi/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() { 8 | ifstream fin("submultimi.in"); 9 | ofstream fout("submultimi.out"); 10 | int n; 11 | fin >> n; 12 | for(int i = 1 ; i < (1 << n ) ; ++ i) { 13 | for(int j = 0 ; j < n ; ++ j) 14 | if(i & (1 << j)) 15 | fout << j + 1 << ' '; 16 | fout << '\n'; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Subsecventa2/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | cout << "Hello world!" << endl; 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /Taie/taie-1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | ifstream cin("taie.in"); 5 | ofstream cout("taie.out"); 6 | int N ; 7 | double x1,y1,x2,y2,a[1005],b[1005]; 8 | int main() 9 | { 10 | cin>>N; 11 | for(int i=1; i<=N;i++) 12 | { cin>>x1>>y1>>x2>>y2; 13 | // cout< 2 | #include 3 | using namespace std; 4 | ifstream cin("taie.in"); 5 | ofstream cout("taie.out"); 6 | int N ; 7 | double x1,y1,x2,y2,a[1005],b[1005]; 8 | int main() 9 | { 10 | cin>>N; 11 | for(int i=1; i<=N;i++) 12 | { cin>>x1>>y1>>x2>>y2; 13 | cout< 2 | using namespace std; 3 | unsigned long long n, sir[1002],st[1002],suma[1002],k, contor=0,i, s; 4 | void back(int p) 5 | { unsigned int pval; 6 | for(pval=st[p-1]+1;pval<=n&&suma[p-1]>n; 19 | cin>>s; 20 | for(i=1;i<=n;i++) 21 | cin>>sir[i]; 22 | back(1); 23 | cout< 2 | using namespace std; 3 | const int MOD = 10007; 4 | 5 | int N, M; 6 | int P[301][301]; 7 | int perm[301]; 8 | 9 | int main() 10 | { 11 | ifstream fin("permutari2.in"); 12 | ofstream fout("permutari2.out"); 13 | 14 | fin >> N >> M; 15 | 16 | perm[1] = 1; 17 | for (int i = 2; i <= N; ++i) 18 | perm[i] = (perm[i - 1] * i) % MOD; 19 | 20 | P[1][1] = 1; 21 | for (int i = 2; i <= N; ++i) 22 | { 23 | int total = 0; 24 | for (int j = 2; j <= N; ++j) 25 | { 26 | for (int k = i - 1; k >= j - 1; --k) 27 | { 28 | P[i][j] += (P[k][j - 1] * P[i - k][1]) % MOD; 29 | P[i][j] %= MOD; 30 | } 31 | total += P[i][j], total %= MOD; 32 | } 33 | 34 | P[i][1] = (perm[i] - total + MOD) % MOD; 35 | } 36 | fout << P[N][M]; 37 | fin.close(); 38 | fout.close(); 39 | } 40 | 41 | -------------------------------------------------------------------------------- /Take5/take5.combinari.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int st[1003],n, k, sir[1003],suma[1003],s,contor=0; 4 | ifstream cin("take5.in"); 5 | ofstream cout("take5.out"); 6 | void back(int p) 7 | { int pval; //valorile pentru nivelul p; 8 | for(pval=st[p-1]+1;pval<=n&&suma[p-1]>n; 18 | cin>>s; 19 | for(i=1;i<=n;i++) 20 | cin>>sir[i]; 21 | back(1); 22 | cout< 2 | using namespace std; 3 | unsigned long long n, sir[1002],st[1002],suma[1002],k, contor=0,i, s; 4 | void back(unsigned int p) 5 | { unsigned int pval; 6 | for(pval=st[p-1]+1;pval<=n&&suma[p-1]>n; 19 | cin>>s; 20 | for(i=1;i<=n;i++) 21 | cin>>sir[i]; 22 | back(1); 23 | cout< 2 | using namespace std; 3 | unsigned long long n, sir[1001], k, contor=0,i, s; 4 | void back(unsigned int p, unsigned long long sum,unsigned int elem) 5 | { 6 | if(sum > s || p > n || elem > 5) return; 7 | if(sum==s && elem == 5) 8 | contor++; 9 | unsigned int i; 10 | //for(i=p+1;i<=n;i++) 11 | i=p+1; 12 | while(i<=n) 13 | { back(i, sum+sir[i], elem+1); 14 | i++;} 15 | 16 | } 17 | int main() 18 | { 19 | ifstream cin("take5.in"); 20 | ofstream cout("take5.out"); 21 | cin>>n; 22 | cin>>s; 23 | for(i=1;i<=n;i++) 24 | cin>>sir[i]; 25 | back(0, 0, 0); 26 | cout< 2 | using namespace std; 3 | unsigned long long n, sir[1001], k, contor=0,i, s; 4 | void back(int p, unsigned long long sum, int elem) 5 | { 6 | if(sum > s || p > n || elem > 5) return; 7 | if(sum==s && elem == 5) 8 | contor++; 9 | unsigned int i; 10 | for(i=p+1;i<=n;i++) 11 | { 12 | // else 13 | back(i, sum+sir[i], elem+1); 14 | } 15 | } 16 | int main() 17 | { 18 | ifstream cin("take5.in"); 19 | ofstream cout("take5.out"); 20 | cin>>n; 21 | cin>>s; 22 | for(i=1;i<=n;i++) 23 | cin>>sir[i]; 24 | back(0, 0, 0); 25 | cout< 2 | #include 3 | 4 | const int MAXN = 10000005; 5 | 6 | int n, huge[MAXN]; 7 | 8 | inline void multiply(int huge[MAXN], int a) { 9 | int rest = 0, i; 10 | for(i = 1 ; i <= huge[0] || rest ; ++ i, rest = rest / 10000) { 11 | huge[i] = (rest += huge[i] * a) % 10000; 12 | } 13 | huge[0] = i - 1; 14 | } 15 | 16 | int main(void) { 17 | freopen("tamplar.in","r",stdin); 18 | freopen("tamplar.out","w",stdout); 19 | int n; 20 | huge[0] = huge[1] = 1; 21 | scanf("%d",&n); 22 | for(int i = 2 ; i < n ; ++ i) 23 | multiply(huge, i); 24 | printf("%d", huge[huge[0]]); 25 | for(int i=huge[0]-1; i; i--){ 26 | printf("%04d", huge[i]); 27 | } 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /Teams/teams(2).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | unsigned long N, forta[100001], v[10000], sol; 4 | unsigned int A,B,c,i,j; 5 | int main() 6 | { 7 | ifstream cin("teams.in"); 8 | ofstream cout("teams.out"); 9 | cin>>N>>A>>B; 10 | for(i=1;i<=N;i++) 11 | cin>>forta[i]; 12 | cin.close(); 13 | for(i=1;i<=N;i++) 14 | // for(j=i+1;j<=N;j++) 15 | // if((forta[i]+forta[j])>=A && (forta[i]+forta[j])<=B) 16 | // c++; 17 | if(forta[i]<=i) 18 | v[i]++; 19 | for(i=1;i<=N;i++) 20 | if(i>=A && i<=B) 21 | sol=sol+v[i]; 22 | cout< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | using namespace std; 18 | 19 | int a[100]; 20 | 21 | int main() { 22 | cout << sizeof(a) << '\n'; 23 | 24 | 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /Tort/comentata.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/Tort/comentata.cpp -------------------------------------------------------------------------------- /Tren/tren.cpp: -------------------------------------------------------------------------------- 1 | //tren 2 | #include 3 | #define k 3 4 | using namespace std; 5 | ifstream cin("tren.in"); 6 | ofstream cout("tren.out"); 7 | int j,n,m, v[50005],i; 8 | int sum[1001],s[1001][4]; 9 | 10 | int main() 11 | { 12 | cin>>n; 13 | for(i=1;i<=n;i++) 14 | { cin>>v[i]; sum[i]=sum[i-1]+v[i]; } 15 | cin>>m; 16 | for(i=1;i<=n;i++) 17 | for(j=1;j<=k;j++) 18 | { s[i][j]=s[i-1][j]; 19 | if(s[i][j]<(s[i-m][j-1]+(sum[i]-sum[i-m])) ) 20 | s[i][j]=s[i-m][j-1]+(sum[i]-sum[i-m]);} 21 | cout< 2 | #include 3 | using namespace std; 4 | ifstream cin("triplet.in"); 5 | ofstream cout("triplet.out"); 6 | long long n, pp[200000005], i, j, li, ls, mij ; 7 | int cautbin1(int x) 8 | { 9 | li=1; ls=n; 10 | while(lix) ls=mij-1; 14 | else li=mij+1;} 15 | return 0; 16 | } 17 | int main() 18 | { 19 | cin>>n; 20 | for(i=1;i<=n;i++) 21 | {pp[i]=i*i; //cout< 2 | #include 3 | using namespace std; 4 | ifstream cin("triplet.in"); 5 | ofstream cout("triplet.out"); 6 | long long n; 7 | double r, q; 8 | 9 | int main() 10 | { cin>>n; 11 | r=sqrt(n); 12 | if(powl(floor(r),2)==n) 13 | cout<0) 16 | { q=sqrt((n-2)/3); 17 | if(q*q==(n-2)/3) 18 | cout<<(q-1)<<" "< 2 | using namespace std; 3 | ifstream cin("triplet.in"); 4 | ofstream cout("triplet.out"); 5 | long long n; 6 | 7 | 8 | 9 | 10 | int main() 11 | { 12 | cin>>n; 13 | if(n%2==0) 14 | cout<<(n/2)<<" "<<(-1)*((n/2)-1)<<" 1"; 15 | 16 | else 17 | cout<<(n+1)/2<<" "<<(-1)*((n-1)/2)<<" 0"; 18 | 19 | 20 | 21 | 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /Triplet/tripletcautbin.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | ifstream cin("triplet.in"); 5 | ofstream cout("triplet.out"); 6 | long long n, pp[200000005], i, j, li, ls, mij ; 7 | int cautbin2(int x) 8 | { 9 | 10 | 11 | 12 | } 13 | 14 | int cautbin1(int x) 15 | { 16 | li=1; ls=n/2; 17 | while(lix) ls=mij-1; 21 | else li=mij+1;} 22 | cautbin2(x); 23 | } 24 | int main() 25 | { 26 | cin>>n; 27 | for(i=1;i<=n;i++) 28 | pp[i]=i*i; 29 | for(i=1;i<=n;i++) 30 | for(j=1;j<=n;j++) 31 | if(cautbin1(n-pp[i]-pp[j])){ cout< 2 | 3 | using namespace std; 4 | 5 | inline void triplete(int n) { 6 | for(int i = 1 ; i * i <= n ; ++ i) { 7 | if(n % i == 0) { 8 | cerr << i << ' ' << n / i << '\n'; 9 | } 10 | } 11 | } 12 | 13 | int main() { 14 | int n; 15 | cin >> n; 16 | //triplete(n); 17 | } 18 | -------------------------------------------------------------------------------- /Trompeta/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | ifstream f("trompeta.in"); 4 | ofstream g("trompeta.out"); 5 | int n,m,i,c,up; 6 | char st[1000007]; 7 | char s[1000005]; 8 | int main() 9 | { 10 | f>>n>>m; 11 | f>>(s+1); 12 | up=1; 13 | st[1]=s[1]-'0'; 14 | for(i=2;i<=n;++i) 15 | { 16 | c=s[i]; 17 | while(st[up]=m&&up) 18 | --up; 19 | ++up; 20 | st[up]=c; 21 | } 22 | g<<(st+1); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /Uva-11307/uva-11307.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/Uva-11307/uva-11307.cpp -------------------------------------------------------------------------------- /Victorie/victorie: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/Victorie/victorie -------------------------------------------------------------------------------- /Viteza2/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | ifstream cin("vite.in"); 6 | ofstream cout("output.out"); 7 | int main() 8 | { 9 | 10 | cin.close(); 11 | cout.close(); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /Xspe/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | //#include 3 | using namespace std; 4 | //vector ST; 5 | ifstream cin("xspe.in"); 6 | ofstream cout("xspe.out"); 7 | int st[1000005],n, s[1000005],sol[1000005], i, vf; 8 | int main() 9 | { 10 | cin>>n; 11 | for(i=1;i<=n;++i) 12 | cin>>s[i]; 13 | for(int i=n; i>=1; --i) { 14 | sol[i]=s[i]; 15 | for(;vf && st[vf]>=s[i];--vf); 16 | if(vf) sol[i]+=st[vf]; 17 | st[++vf]=s[i]; 18 | } 19 | for(i=1;i<=n;++i) 20 | cout< 2 | using namespace std; 3 | 4 | ifstream cin("xspe.in"); 5 | ofstream cout("xspe.out"); 6 | int main() 7 | { 8 | cin.sync_with_stdio(false); 9 | long long n, a[1000005], i,j ; 10 | cin>>n; 11 | for(i=1;i<=n;i++) 12 | cin>>a[i]; 13 | for(i=1;ia[j]) 16 | {cout<<(a[i]+a[j])<<" "; 17 | break;} 18 | cout< 2 | 3 | using namespace std; 4 | 5 | int n, k, l, c, d, nl, np, p; 6 | 7 | int main() { 8 | #ifndef ONLINE_JUDGE 9 | freopen("151a.in", "r", stdin); 10 | freopen("151a.out", "w", stdout); 11 | #endif 12 | cin >> n >> k >> l >> c >> d >> p >> nl >> np; 13 | cout << (min((k * l) / nl, min(c * d, p / np))) / n << '\n'; 14 | } 15 | -------------------------------------------------------------------------------- /_codeforces/339B/339b.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/_codeforces/339B/339b.cpp -------------------------------------------------------------------------------- /_codeforces/415D/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | const int maxn = 2005; 7 | const int mod = 1000000007; 8 | 9 | int n, k, dp[maxn][maxn]; 10 | 11 | int main() { 12 | #ifndef ONLINE_JUDGE 13 | freopen("415d.in", "r", stdin); 14 | freopen("415d.out", "w", stdout); 15 | #endif // ONLINE_JUDGE 16 | cin >> n >> k; 17 | for(int i = 1 ; i <= n ; ++ i) 18 | dp[1][i] = 1; 19 | for(int i = 1 ; i + 1 <= k ; ++ i) 20 | for(int j = 1 ; j <= n ; ++ j) 21 | for(int k = 1 ; k * j <= n ; ++ k) 22 | dp[i + 1][k * j] = (dp[i + 1][k * j] + dp[i][j]) % mod; 23 | int ans = 0; 24 | for(int i = 1 ; i <= n ; ++ i) 25 | ans = (ans + dp[k][i]) % mod; 26 | cout << ans << '\n'; 27 | } 28 | -------------------------------------------------------------------------------- /_codeforces/420D/420d.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/_codeforces/420D/420d.cpp -------------------------------------------------------------------------------- /_codeforces/431C/431c.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | const int maxn = 105; 7 | const int mod = 1000000007; 8 | 9 | int n, k, d, dp[maxn][2]; 10 | 11 | int main() { 12 | #ifndef ONLINE_JUDGE 13 | freopen("431c.in", "r", stdin); 14 | freopen("431c.out", "w", stdout); 15 | #endif 16 | cin >> n >> k >> d; 17 | 18 | dp[0][0] = 1; 19 | for(int i = 1 ; i <= n ; ++ i) { 20 | int aux = 0; 21 | for(int j = i ; j >= i - min(d - 1, i) ; -- j) { 22 | dp[i][0] = (dp[i][0] + dp[j][0]) % mod; 23 | aux = (aux + dp[j][1]) % mod; 24 | } 25 | if(i < d) 26 | continue; 27 | dp[i][1] = aux; 28 | for(int j = i - d ; j >= i - min(k, i) ; -- j) 29 | dp[i][1] = (1LL * dp[i][1] + 1LL * dp[j][0] + 1LL * dp[j][1]) % mod; 30 | } 31 | cout << dp[n][1] << '\n'; 32 | } 33 | -------------------------------------------------------------------------------- /_codeforces/432D/432d.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | const int maxn = 100005; 10 | 11 | char s[maxn]; 12 | int n, pi[maxn], cnt[maxn]; 13 | 14 | int main() { 15 | cin >> s + 1; 16 | n = strlen(s + 1); 17 | int k = 0; 18 | for(int i = 2 ; i <= n ; ++ i) { 19 | while(k > 0 && s[k + 1] != s[i]) 20 | k = pi[k]; 21 | if(s[k + 1] == s[i]) 22 | ++ k; 23 | pi[i] = k; 24 | ++ cnt[pi[i]]; 25 | } 26 | for(int i = n ; i >= 1 ; -- i) 27 | cnt[pi[i]] += cnt[i]; 28 | k = n; 29 | vector > v; 30 | while(k) { 31 | v.push_back(make_pair(k, cnt[k] + 1)); 32 | k = pi[k]; 33 | } 34 | sort(v.begin(), v.end()); 35 | cout << v.size() << '\n'; 36 | for(auto it : v) 37 | cout << it.first << ' ' << it.second << '\n'; 38 | } 39 | -------------------------------------------------------------------------------- /_codeforces/437B/437b.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/_codeforces/437B/437b.cpp -------------------------------------------------------------------------------- /_codeforces/448D/448d.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | const int maxn = 100005; 7 | 8 | int n, m; 9 | long long k; 10 | 11 | inline long long check(long long mid) { 12 | long long ret = 0; 13 | for(int i = 1 ; i <= n ; ++ i) 14 | ret += min(1LL*m, (mid - 1) / i); 15 | return ret; 16 | } 17 | 18 | int main() { 19 | cin >> n >> m >> k; 20 | long long st = 1, dr = 1LL * n * m + 1; 21 | long long ret = -1; 22 | while(st <= dr) { 23 | long long mid = st + (dr - st) / 2; 24 | long long ans = check(mid); 25 | if(ans < k) { 26 | ret = mid; 27 | st = mid + 1; 28 | } 29 | else 30 | dr = mid - 1; 31 | } 32 | cout << ret << '\n'; 33 | } 34 | -------------------------------------------------------------------------------- /_codeforces/456C/456c.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | const int maxn = 100005; 7 | 8 | int a[maxn], cnt[maxn], m, n; 9 | long long dp[maxn]; 10 | 11 | int main() { 12 | cin >> n; 13 | for(int i = 1 ; i <= n ; ++ i) { 14 | cin >> a[i]; 15 | ++ cnt[a[i]]; 16 | m = max(m, a[i]); 17 | } 18 | dp[0] = 0; 19 | dp[1] = cnt[1]; 20 | for(int i = 2 ; i <= m ; ++ i) 21 | dp[i] = max(dp[i - 1], dp[i - 2] + 1LL * cnt[i] * i); 22 | cout << dp[m] << '\n'; 23 | } 24 | -------------------------------------------------------------------------------- /_codeforces/459D/oddtreeok.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/_codeforces/459D/oddtreeok.cpp -------------------------------------------------------------------------------- /_codeforces/460B/460b.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | inline int sum_digit(long long x) { 8 | if(x == 0) 9 | return 0; 10 | return x % 10 + sum_digit(x / 10); 11 | } 12 | 13 | int main() { 14 | int a, b, c; 15 | cin >> a >> b >> c; 16 | vector ans; 17 | for(int i = 1 ; i <= 81 ; ++ i) { 18 | long long p = 1; 19 | for(int j = 1 ; j <= a ; ++ j) 20 | p *= i; 21 | p *= b; 22 | p += c; 23 | if(p < 1000000000 && sum_digit(p) == i) 24 | ans.push_back(p); 25 | } 26 | cout << ans.size() << '\n'; 27 | for(auto it:ans) 28 | cout << it << ' '; 29 | } 30 | -------------------------------------------------------------------------------- /_codeforces/462C/462c.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | const int maxn = 300005; 7 | 8 | int n, a[maxn]; 9 | 10 | int main() { 11 | cin >> n; 12 | for(int i = 1 ; i <= n ; ++ i) 13 | cin >> a[i]; 14 | sort(a + 1, a + n + 1); 15 | long long ans = 1LL * n * a[n]; 16 | for(int i = 1 ; i < n ; ++ i) 17 | ans += 1LL * (i + 1) * a[i]; 18 | cout << ans << '\n'; 19 | } 20 | -------------------------------------------------------------------------------- /_codeforces/463A/463a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int maxn = 105; 6 | 7 | int a[maxn], n, s; 8 | 9 | int main() { 10 | cin >> n >> s; 11 | s *= 100; 12 | int ans = -1; 13 | for(int i = 1 ; i <= n ; ++ i) { 14 | int x, y; 15 | cin >> x >> y; 16 | x = x * 100 + y; 17 | if(s >= x) 18 | ans = max(ans, (s - x) % 100); 19 | } 20 | cout << ans << '\n'; 21 | } 22 | -------------------------------------------------------------------------------- /_codeforces/463C/463c.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | const int maxn = 2005; 8 | 9 | int n, a[maxn][maxn], dp[2*maxn], ds[2*maxn]; 10 | 11 | int main() { 12 | #ifndef ONLINE_JUDGE 13 | freopen("463c.in", "r", stdin); 14 | freopen("463c.out", "w", stdout); 15 | #endif 16 | cin >> n; 17 | for(int i = 1 ; i <= n ; ++ i) 18 | for(int j = 1 ; j <= n ; ++ j) { 19 | cin >> a[i][j]; 20 | cerr << i << ' ' << j << ' ' << n + i - j << ' ' << i + j - 1 << '\n'; 21 | dp[n + i - j] += a[i][j]; 22 | ds[i + j - 1] += a[i][j]; 23 | } 24 | for(int i = 1 ; i < n + n ; ++ i); 25 | } 26 | -------------------------------------------------------------------------------- /_codeforces/463b/463b.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int n, lastx = 0, energy = 0; 7 | cin >> n; 8 | int ans = 0; 9 | for(int i = 1 ; i <= n ; ++ i) { 10 | int x; 11 | cin >> x; 12 | energy += (lastx - x); 13 | if(energy < 0) { 14 | ans += -energy; 15 | energy = 0; 16 | } 17 | lastx = x; 18 | } 19 | cout << ans << '\n'; 20 | } 21 | -------------------------------------------------------------------------------- /_codeforces/465A/465a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | const int maxn = 105; 5 | 6 | int n; 7 | char s[maxn]; 8 | 9 | int main() { 10 | cin >> n; 11 | cin >> s + 1; 12 | for(int i = 1 ; i <= n ; ++ i) 13 | if(s[i] == '0') { 14 | cout << i << '\n'; 15 | return 0; 16 | } 17 | cout << n << '\n'; 18 | } 19 | -------------------------------------------------------------------------------- /_codeforces/465B/465b.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int maxn = 1005; 6 | 7 | int n, dp[maxn]; 8 | 9 | int main() { 10 | #ifndef ONLINE_JUDGE 11 | freopen("465b.in", "r", stdin); 12 | freopen("465b.out", "w", stdout); 13 | #endif 14 | cin >> n; 15 | for(int i = 1 ; i <= n ; ++ i) { 16 | cin >> dp[i]; 17 | } 18 | int ans = 0; 19 | for(int i = 1 ; i <= n ; ++ i) { 20 | if(dp[i] == 1) { 21 | ++ ans; 22 | ++ i; 23 | while(dp[i] == 1) 24 | ++ ans, ++ i; 25 | ++ ans; 26 | } 27 | } 28 | cout << max(0, ans - 1) << '\n'; 29 | } 30 | -------------------------------------------------------------------------------- /_codeforces/466A/466a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int n, m, a, b; 7 | cin >> n >> m >> a >> b; 8 | if(m * a > b) { 9 | int howmany = n / m; 10 | int rest = n % m; 11 | if(rest * a < b) 12 | cout << howmany * b + rest * a << '\n'; 13 | else 14 | cout << howmany * b + b << '\n'; 15 | } 16 | else 17 | cout << n * a << '\n'; 18 | } 19 | -------------------------------------------------------------------------------- /_codeforces/466C/466c.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int maxn = 500005; 6 | 7 | int n, a[maxn], sum[maxn]; 8 | 9 | int main() { 10 | #ifndef ONLINE_JUDGE 11 | freopen("466c.in", "r", stdin); 12 | freopen("466c.out", "w", stdout); 13 | #endif 14 | long long s = 0; 15 | cin >> n; 16 | for(int i = 1 ; i <= n ; ++ i) { 17 | cin >> a[i]; 18 | s += a[i]; 19 | } 20 | if(s % 3) { 21 | cout << "0\n"; 22 | return 0; 23 | } 24 | long long aux = 0; 25 | for(int i = n ; i ; -- i) { 26 | aux += a[i]; 27 | sum[i] = sum[i + 1] + (aux * 3 == s); 28 | } 29 | aux = 0; 30 | long long ans = 0; 31 | for(int i = 1 ; i <= n ; ++ i) { 32 | aux += a[i]; 33 | if(aux * 3 == s) 34 | ans = ans + sum[i + 2]; 35 | } 36 | cout << ans << '\n'; 37 | } 38 | -------------------------------------------------------------------------------- /_codeforces/467A/467a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int n, ans = 0; 7 | cin >> n; 8 | for(int i = 1 ; i <= n ; ++ i) { 9 | int p, q; 10 | cin >> p >> q; 11 | if(q - p >= 2) 12 | ++ ans; 13 | } 14 | cout << ans << '\n'; 15 | } 16 | -------------------------------------------------------------------------------- /_codeforces/467B/467b.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | //#include 5 | 6 | using namespace std; 7 | 8 | const int maxn = 1005; 9 | 10 | int n, m, x[maxn], k; 11 | 12 | int main() { 13 | #ifndef ONLINE_JUDGE 14 | freopen("467b.in", "r", stdin); 15 | freopen("467b.out", "w", stdout); 16 | #endif 17 | 18 | cin >> n >> m >> k; 19 | for(int i = 1 ; i <= m + 1 ; ++ i) 20 | cin >> x[i]; 21 | int ans = 0; 22 | for(int i = 1 ; i <= m ; ++ i) 23 | if(__builtin_popcount((x[i] ^ x[m + 1])) <= k) 24 | ++ ans; 25 | cout << ans << '\n'; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /_codeforces/467C/467c.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | const int maxn = 5005; 7 | 8 | long long dp[maxn][maxn], sum[maxn]; 9 | int n, m, k; 10 | 11 | int main() { 12 | #ifndef ONLINE_JUDGE 13 | freopen("467c.in", "r", stdin); 14 | freopen("467c.out", "w", stdout); 15 | #endif 16 | 17 | cin >> n >> m >> k; 18 | for(int i = 1 ; i <= n ; ++ i) { 19 | int x; 20 | cin >> x; 21 | sum[i] = sum[i - 1] + x; 22 | } 23 | long long ans = 0; 24 | for(int i = m ; i <= n ; ++ i) { 25 | for(int j = 1 ; j <= k ; ++ j) 26 | dp[i][j] = max(dp[i - 1][j], dp[i - m][j - 1] + sum[i] - sum[i - m]); 27 | ans = max(ans, dp[i][k]); 28 | } 29 | cout << ans << '\n'; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /_codeforces/471C/471c.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/_codeforces/471C/471c.cpp -------------------------------------------------------------------------------- /_codeforces/472A/472a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | int n; 8 | 9 | inline bool prime(int x) { 10 | for(int i = 2 ; i * i <= x ; ++ i) 11 | if(x % i == 0) 12 | return false; 13 | return true; 14 | } 15 | 16 | int main() { 17 | #ifndef ONLINE_JUDGE 18 | freopen("472a.in", "r", stdin); 19 | freopen("472a.out", "w", stdout); 20 | #endif 21 | cin >> n; 22 | for(int i = 4 ; i <= n ; ++ i) 23 | if(!prime(i) && !prime(n - i)) { 24 | cout << i << ' ' << n - i << '\n'; 25 | return 0; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /_codeforces/472B/472b.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/_codeforces/472B/472b.cpp -------------------------------------------------------------------------------- /_codeforces/474A/474a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | char keyboard[] = "qwertyuiopasdfghjkl;zxcvbnm,./"; 9 | 10 | int main() { 11 | char s, mess[105]; 12 | cin >> s >> mess; 13 | for(int i = 0 ; mess[i] ; ++ i) { 14 | int pos = strchr(keyboard, mess[i]) - keyboard; 15 | if(s == 'L') 16 | cout << keyboard[pos + 1]; 17 | else 18 | cout << keyboard[pos - 1]; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /_codeforces/474B/474b.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | const int maxn = 100005; 7 | 8 | int n, m, a[maxn], where[maxn * 10]; 9 | int sum; 10 | 11 | int main() { 12 | #ifndef ONLINE_JUDGE 13 | freopen("474b.in", "r", stdin); 14 | freopen("474b.out", "w", stdout); 15 | #endif 16 | cin >> n; 17 | for(int i = 1 ; i <= n ; ++ i) { 18 | cin >> a[i]; 19 | for(int j = 1 ; j <= a[i] ; ++ j) 20 | where[sum + j] = i; 21 | sum += a[i]; 22 | } 23 | cin >> m; 24 | for(int i = 1 ; i <= m ; ++ i) { 25 | int x; 26 | cin >> x; 27 | cout << where[x] << '\n'; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /_codeforces/474D/474d.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | const int maxn = 100005; 8 | const int mod = 1000000007; 9 | 10 | int t, n, k, dp[maxn], sum[maxn]; 11 | 12 | int main() { 13 | #ifndef ONLINE_JUDGE 14 | freopen("474d.in", "r", stdin); 15 | freopen("474d.out", "w", stdout); 16 | #endif 17 | 18 | cin >> t >> k; 19 | 20 | dp[0] = 1; 21 | for(int i = 1 ; i < maxn ; ++ i) { 22 | if(i < k) 23 | dp[i] = 1; 24 | else 25 | dp[i] = (dp[i - 1] + dp[i - k]) % mod; 26 | sum[i] = (sum[i - 1] + dp[i]) % mod; 27 | } 28 | for(int i = 1 ; i <= t ; ++ i) { 29 | int x, y; 30 | cin >> x >> y; 31 | cout << (sum[y] - sum[x - 1] + mod) % mod<< '\n'; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /_codeforces/475B/475b.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int n, m; 7 | string s1, s2; 8 | 9 | int main() { 10 | #ifndef ONLINE_JUDGE 11 | freopen("475b.in", "r", stdin); 12 | freopen("475b.out", "w", stdout); 13 | #endif 14 | cin >> n >> m; 15 | cin >> s1 >> s2; 16 | string corners = ""; corners += s1.front(); corners += s2.front(); corners += s1.back(); corners += s2.back(); 17 | if(corners == "^" || corners == ">^ 2 | #include 3 | 4 | using namespace std; 5 | 6 | int a, b, c; 7 | 8 | int main() { 9 | #ifndef ONLINE_JUDGE 10 | freopen("479a.in", "r", stdin); 11 | freopen("479a.out", "w", stdout); 12 | #endif 13 | cin >> a >> b >> c; 14 | int ans = a * b * c; 15 | ans = max(ans, a + b + c); 16 | ans = max(ans, (a + b) * c); 17 | ans = max(ans, a * (b + c)); 18 | cout << ans << '\n'; 19 | } 20 | -------------------------------------------------------------------------------- /_codeforces/479DA/479da.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/_codeforces/479DA/479da.cpp -------------------------------------------------------------------------------- /_codeforces/479F/479f.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/_codeforces/479F/479f.cpp -------------------------------------------------------------------------------- /_codeforces/485B/485b.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/_codeforces/485B/485b.cpp -------------------------------------------------------------------------------- /_codeforces/485C/485c.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | #ifndef ONLINE_JUDGE 8 | freopen("485c.in", "r", stdin); 9 | freopen("485c.out", "w", stdout); 10 | #endif 11 | 12 | int n; 13 | cin >> n; 14 | for(int i = 1 ; i <= n ; ++ i) { 15 | long long l, r; 16 | cin >> l >> r; 17 | for(int j = 0 ; j < 63 ; ++ j) 18 | if(!(l & (1LL << j)) && (l | (1LL << j)) <= r) 19 | l |= (1LL << j); 20 | cout << l << '\n'; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /_codeforces/485D/485d.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | const int maxn = 200005; 9 | const int maxvalue = maxn * 10; 10 | 11 | int n, v[maxvalue], m; 12 | bitset used; 13 | 14 | int main() { 15 | #ifndef ONLINE_JUDGE 16 | freopen("485d.in", "r", stdin); 17 | freopen("485d.out", "w", stdout); 18 | #endif 19 | cin >> n; 20 | for(int i = 1 ; i <= n ; ++ i) { 21 | int x; 22 | cin >> x; 23 | used[x] = 1; 24 | m = max(m, x); 25 | } 26 | int last = 0; 27 | for(int i = 1 ; i <= 2*m ; ++ i) { 28 | v[i] = last; 29 | if(used[i]) 30 | last = i; 31 | } 32 | int ans = 0; 33 | for(int i = 1 ; i <= m ; ++ i) 34 | if(used[i]) 35 | for(int j = 2 * i ; j <= 2*m ; j += i) 36 | ans = max(ans, v[j] % i); 37 | cout << ans << '\n'; 38 | } 39 | -------------------------------------------------------------------------------- /_codeforces/486A/486a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | long long n; 7 | cin >> n; 8 | if(n & 1) 9 | cout << -1LL * (n + 1LL) / 2LL << '\n'; 10 | else 11 | cout << n / 2LL << '\n'; 12 | } 13 | -------------------------------------------------------------------------------- /_codeforces/489A/489a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | const int maxn = 3005; 8 | 9 | int n, a[maxn]; 10 | 11 | int main() { 12 | cin >> n; 13 | for(int i = 1 ; i <= n ; ++ i) 14 | cin >> a[i]; 15 | cout << n << '\n'; 16 | for(int i = 1 ; i <= n ; ++ i) { 17 | int minindex = i; 18 | for(int j = i + 1 ; j <= n ; ++ j) 19 | if(a[minindex] > a[j]) 20 | minindex = j; 21 | swap(a[minindex], a[i]); 22 | cout << i - 1 << ' ' << minindex - 1 << '\n'; 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /_codeforces/489B/489b.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | const int maxn = 105; 9 | 10 | int n, m, a[maxn], b[maxn]; 11 | 12 | int main() { 13 | cin >> n; 14 | for(int i = 1 ; i <= n ; ++ i) 15 | cin >> a[i]; 16 | cin >> m; 17 | for(int j = 1 ; j <= m ; ++ j) 18 | cin >> b[j]; 19 | 20 | sort(a + 1, a + n + 1); 21 | sort(b + 1, b + m + 1); 22 | 23 | int ans = 0; 24 | 25 | for(int i = 1 ; i <= n ; ++ i) { 26 | for(int j = 1 ; j <= m ; ++ j) { 27 | if(abs(a[i] - b[j]) <= 1) { 28 | ++ ans; 29 | b[j] = 0x3f3f3f3f; 30 | break; 31 | } 32 | } 33 | } 34 | cout << ans << '\n'; 35 | } 36 | -------------------------------------------------------------------------------- /_codeforces/489D/489d.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | const int maxn = 3005; 7 | 8 | bool g[maxn][maxn]; 9 | vector adj[maxn]; 10 | int n, m; 11 | 12 | int main() { 13 | cin >> n >> m; 14 | for(int i = 1 ; i <= m ; ++ i) { 15 | int x, y; 16 | cin >> x >> y; 17 | g[x][y] = 1; 18 | adj[x].push_back(y); 19 | } 20 | long long ans = 0; 21 | for(int i = 1 ; i <= n ; ++ i) { 22 | for(int j = 1 ; j <= n ; ++ j) { 23 | if(i == j) 24 | continue; 25 | int r = 0; 26 | for(vector :: iterator it = adj[i].begin() ; it != adj[i].end() ; ++ it) 27 | if(*it != i && *it != j && g[*it][j]) 28 | ++ r; 29 | ans += (1LL * r * (r - 1)) / 2; 30 | } 31 | } 32 | cout << ans << '\n'; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /_codeforces/490A/490a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | int n; 8 | vector g[3]; 9 | 10 | int main() { 11 | cin >> n; 12 | for(int i = 1 ; i <= n ; ++ i) { 13 | int x; 14 | cin >> x; 15 | g[x - 1].push_back(i); 16 | } 17 | 18 | cout << min(g[0].size(), min(g[1].size(), g[2].size())) << '\n'; 19 | for(int i = 0 ; i < min(g[0].size(), min(g[1].size(), g[2].size())) ; ++ i) 20 | cout << g[0][i] << ' ' << g[1][i] << ' ' << g[2][i] << '\n'; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /_codeforces/492A/492a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | int n, ans; 8 | long long sum = 0; 9 | cin >> n; 10 | for(int h = 1 ; ; ++ h) { 11 | sum = sum + h; 12 | if(n >= sum) { 13 | ans = h; 14 | n -= sum; 15 | } 16 | else { 17 | cout << h - 1 << '\n'; 18 | break; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /_codeforces/495A/495a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int cnt[] = {1, 6, 1, 2, 2, 3, 1, 4, 0, 1}; 6 | 7 | int main() { 8 | int n; 9 | cin >> n; 10 | cout << (cnt[n / 10] + 1) * (cnt[n % 10] + 1) << '\n'; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /_codeforces/495B/495b.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | #ifndef ONLINE_JUDGE 7 | freopen("495b.in", "r", stdin); 8 | freopen("495b.out", "w", stdout); 9 | #endif 10 | int a, b; 11 | cin >> a >> b; 12 | int diff = a - b; 13 | if(diff == 0) { 14 | cout << "infinity\n"; 15 | return 0; 16 | } 17 | if(diff < 0) { 18 | cout << "0\n"; 19 | return 0; 20 | } 21 | int aux = diff; 22 | int ans = 0; 23 | for(int div = 1 ; div * div <= aux ; ++ div) { 24 | if(diff % div == 0) { 25 | if((a / div) * div == diff) 26 | ++ ans; 27 | int div2 = diff / div; 28 | if(div == div2) 29 | continue; 30 | if((a / div2) * div2 == diff) 31 | ++ ans; 32 | } 33 | } 34 | cout << ans << '\n'; 35 | } 36 | -------------------------------------------------------------------------------- /_codeforces/496a/496a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | vector a, b; 7 | int n; 8 | 9 | int main() { 10 | cin >> n; 11 | for(int i = 1 ; i <= n ; ++ i) { 12 | int x; 13 | cin >> x; 14 | a.push_back(x); 15 | } 16 | int ans = 0x3f3f3f3f; 17 | for(int i = 1 ; i < n - 1 ; ++ i) { 18 | b.clear(); 19 | for(int j = 0 ; j < n ; ++ j) { 20 | if(i == j) 21 | continue; 22 | b.push_back(a[j]); 23 | } 24 | int actmax = -0x3f3f3f3f; 25 | for(int j = 0 ; j < b.size() - 1 ; ++ j) 26 | actmax = max(actmax, b[j + 1] - b[j]); 27 | ans = min(ans, actmax); 28 | } 29 | cout << ans << '\n'; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /_codeforces/499A/499a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | const int maxn = 100005; 7 | 8 | map mymap; 9 | mymap > auxmap; 10 | 11 | int main() { 12 | #ifndef ONLINE_JUDGE 13 | freopen("499a.in", "r", stdin); 14 | freopen("499a.out", "w", stdout); 15 | #endif 16 | 17 | int n, x; 18 | cin >> n >> x; 19 | int actminute = 1; 20 | int ans = 0; 21 | for(int i = 1 ; i <= n ; ++ i) { 22 | int l, r; 23 | cin >> l >> r; 24 | while(actminute + x <= l) 25 | actminute += x; 26 | while(actminute < l) { 27 | ++ actminute; 28 | ++ ans; 29 | } 30 | actminute = r + 1; 31 | ans += (r - l + 1); 32 | } 33 | cout << ans << '\n'; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /_codeforces/499B/499b.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | map lower; 10 | map ind; 11 | int n, m; 12 | 13 | int main() { 14 | #ifndef ONLINE_JUDGE 15 | freopen("499b.in", "r", stdin); 16 | #endif 17 | cin >> n >> m; 18 | for(int i = 1 ; i <= m ; ++ i) { 19 | string a, b; 20 | cin >> a >> b; 21 | ind[a] = ind[b] = i; 22 | if(a.size() <= b.size()) 23 | lower[i] = a; 24 | else 25 | lower[i] = b; 26 | } 27 | for(int i = 1 ; i <= n ; ++ i) { 28 | string s; 29 | cin >> s; 30 | cout << lower[ind[s]] << ' '; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /_codeforces/499C/499c.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int maxn = 305; 6 | 7 | int xa, ya, xb, yb, ans, n; 8 | 9 | inline bool check(int a, int b, int c, int x, int y) { 10 | return (1LL * a * x + 1LL * b * y + c) > 0; 11 | } 12 | 13 | int main() { 14 | #ifndef ONLINE_JUDGE 15 | freopen("499c.in", "r", stdin); 16 | freopen("499c.out", "w", stdout); 17 | #endif 18 | 19 | cin >> xa >> ya >> xb >> yb; 20 | cin >> n; 21 | for(int i = 0 ; i < n ; ++ i) { 22 | int a, b, c; 23 | cin >> a >> b >> c; 24 | if(check(a, b, c, xa, ya) != check(a, b, c, xb, yb)) 25 | ++ ans; 26 | } 27 | cout << ans << '\n'; 28 | } 29 | -------------------------------------------------------------------------------- /_codeforces/500A/500a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | const int maxn = 100005; 9 | 10 | bitset used; 11 | int n, t, a[maxn]; 12 | 13 | inline void dfs(int node) { 14 | used[node] = 1; 15 | if(node >= n) 16 | return ; 17 | dfs(node + a[node]); 18 | } 19 | 20 | int main() { 21 | #ifndef ONLINE_JUDGE 22 | freopen("500a.in", "r", stdin); 23 | freopen("500a.out", "w", stdout); 24 | #endif 25 | cin >> n >> t; 26 | for(int i = 1 ; i < n ; ++ i) 27 | cin >> a[i]; 28 | dfs(1); 29 | if(used[t]) 30 | cout << "YES\n"; 31 | else 32 | cout << "NO\n"; 33 | } 34 | -------------------------------------------------------------------------------- /_codeforces/501A/501a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | inline int cost(int p, int t) { 5 | return max((3 * p / 10), (p - (p * t) / 250)); 6 | } 7 | 8 | int main() { 9 | int a, b, c, d; 10 | cin >> a >> b >> c >> d; 11 | if(cost(a, c) > cost(b, d)) 12 | cout << "Misha\n"; 13 | else 14 | if(cost(a, c) == cost(b, d)) 15 | cout << "Tie\n"; 16 | else 17 | cout << "Vasya\n"; 18 | } 19 | -------------------------------------------------------------------------------- /_codeforces/501B/501b.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | map idx; 10 | map aux, last; 11 | 12 | int main() { 13 | #ifndef ONLINE_JUDGE 14 | freopen("501b.in", "r", stdin); 15 | freopen("501b.out", "w", stdout); 16 | #endif 17 | int n; 18 | cin >> n; 19 | int users = 0; 20 | for(int i = 1 ; i <= n ; ++ i) { 21 | string a, b; 22 | cin >> a >> b; 23 | if(!idx[a]) { 24 | idx[a] = ++ users; 25 | aux[users] = a; 26 | } 27 | last[idx[a]] = b; 28 | idx[b] = idx[a]; 29 | } 30 | cout << users << '\n'; 31 | for(int i = 1 ; i <= users ; ++ i) { 32 | cout << aux[i] << ' ' << last[i] << '\n'; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /_codeforces/505A/505a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | const int maxn = 10005; 9 | 10 | char s[maxn]; 11 | 12 | int main() { 13 | string s; 14 | cin >> s; 15 | for(int i = 0 ; i <= s.size() ; ++ i) { 16 | for(char x = 'a' ; x <= 'z' ; ++ x) { 17 | s.insert(i, 1, x); 18 | string aux = s; 19 | reverse(aux.begin(), aux.end()); 20 | if(aux == s) { 21 | cout << aux << '\n'; 22 | return 0; 23 | } 24 | s.erase(i, 1); 25 | } 26 | } 27 | cout << "NA\n"; 28 | } 29 | -------------------------------------------------------------------------------- /_codeforces/505C/505c.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() { 8 | } 9 | -------------------------------------------------------------------------------- /_codeforces/507B/507b.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | int r, xa, ya, xb, yb; 8 | 9 | int main() { 10 | #ifndef ONLINE_JUDGE 11 | freopen("507b.in", "r", stdin); 12 | freopen("507b.out", "w", stdout); 13 | #endif 14 | 15 | cin >> r >> xa >> ya >> xb >> yb; 16 | 17 | if(xa == xb && ya == yb) { 18 | cout << "0\n"; 19 | return 0; 20 | } 21 | 22 | 23 | double distance = sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb)); 24 | 25 | double ans = (distance / (2 * r)) + (((int)(distance / (2 * r)) * (r * 2) == 0)); 26 | 27 | 28 | cout << floor(ans) + ((ans - floor(ans)) != 0) << '\n'; 29 | } 30 | -------------------------------------------------------------------------------- /_codeforces/507b/507b.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/_codeforces/507b/507b.cpp -------------------------------------------------------------------------------- /_codeforces/508B/508b.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | const int maxn = 100005; 9 | 10 | char s[maxn]; 11 | int n; 12 | 13 | int main() { 14 | cin.getline(s + 1, maxn); 15 | n = strlen(s + 1); 16 | bool haseven = 0; 17 | for(int i = 1 ; i <= n ; ++ i) 18 | if((s[i] - '0') % 2 == 0) 19 | haseven = 1; 20 | if(!haseven) { 21 | cout << "-1\n"; 22 | return 0; 23 | } 24 | for(int i = 1 ; i < n ; ++ i) 25 | if((s[i] - '0') % 2 == 0 && s[i] <= s[n]) { 26 | swap(s[i], s[n]); 27 | cout << s + 1 << '\n'; 28 | return 0; 29 | } 30 | for(int i = n - 1 ; i >= 1 ; -- i) 31 | if((s[i] - '0') % 2 == 0 && s[i] >= s[n]) { 32 | swap(s[i], s[n]); 33 | cout << s + 1 << '\n'; 34 | return 0; 35 | } 36 | 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /_codeforces/509A/509a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int maxn = 1005; 6 | 7 | int a[maxn][maxn], n; 8 | 9 | int main() { 10 | cin >> n; 11 | for(int i = 1 ; i <= n ; ++ i) 12 | for(int j = 1 ; j <= n ; ++ j) 13 | if(i == 1 || j == 1) 14 | a[i][j] = 1; 15 | else 16 | a[i][j] = a[i - 1][j] + a[i][j - 1]; 17 | cout << a[n][n] << '\n'; 18 | } 19 | -------------------------------------------------------------------------------- /_codeforces/510A/510a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | const int maxn = 100005; 8 | 9 | int main() { 10 | #ifndef ONLINE_JUDGE 11 | freopen("510a.in", "r", stdin); 12 | freopen("510a.out", "w", stdout); 13 | #endif 14 | 15 | int n, m; 16 | cin >> n >> m; 17 | 18 | bool aux = false; 19 | for(int i = 1 ; i <= n ; ++ i) { 20 | if(i % 2 == 1) { 21 | for(int j = 1 ; j <= m ; ++ j) 22 | cout << "#"; 23 | } 24 | else { 25 | aux = !aux; 26 | if(aux) { 27 | for(int j = 1 ; j < m ; ++ j) 28 | cout << "."; 29 | cout << "#"; 30 | } 31 | else { 32 | cout << "#"; 33 | for(int j = 2 ; j <= m ; ++ j) 34 | cout << "."; 35 | } 36 | } 37 | cout << "\n"; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /_codeforces/514A/514a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int maxn = 1005; 6 | 7 | char s[maxn]; 8 | 9 | int main() { 10 | cin >> s + 1; 11 | for(int i = 1 + (s[1] == '9') ; s[i] ; ++ i) { 12 | if(s[i] >= '5') 13 | s[i] = '9' - s[i] + '0'; 14 | } 15 | cout << s + 1 << '\n'; 16 | } 17 | -------------------------------------------------------------------------------- /_codeforces/514B/514b.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | const int maxn = 1005; 8 | 9 | int n; 10 | double x[maxn], y[maxn]; 11 | 12 | inline double getslope(int i, int j) { 13 | if(x[i] == x[j]) 14 | return -100000003; 15 | return (y[j] - y[i]) / (x[j] - x[i]); 16 | } 17 | 18 | int main() { 19 | #ifndef ONLINE_JUDGE 20 | freopen("514b.in", "r", stdin); 21 | freopen("514b.out", "w", stdout); 22 | #endif 23 | 24 | cin >> n >> x[0] >> y[0]; 25 | vector slopes; 26 | for(int i = 1 ; i <= n ; ++ i) { 27 | cin >> x[i] >> y[i]; 28 | slopes.push_back(getslope(0, i)); 29 | } 30 | sort(slopes.begin(), slopes.end()); 31 | slopes.resize(unique(slopes.begin(), slopes.end()) - slopes.begin()); 32 | cout << slopes.size() << '\n'; 33 | } 34 | -------------------------------------------------------------------------------- /_codeforces/514E/514e.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/_codeforces/514E/514e.cpp -------------------------------------------------------------------------------- /_codeforces/519B/519b.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | multiset s1, s2; 8 | int n; 9 | 10 | int main() { 11 | #ifndef ONLINE_JUDGE 12 | freopen("519b.in", "r", stdin); 13 | freopen("519b.out", "w", stdout); 14 | #endif 15 | cin >> n; 16 | for(int i = 1 ; i <= n ; ++ i) { 17 | int x; 18 | cin >> x; 19 | s1.insert(x); 20 | } 21 | for(int i = 1 ; i < n ; ++ i) { 22 | int x; 23 | cin >> x; 24 | s1.erase(s1.find(x)); 25 | s2.insert(x); 26 | } 27 | cout << *s1.begin() << '\n'; 28 | for(int i = 1 ; i < n - 1 ; ++ i) { 29 | int x; 30 | cin >> x; 31 | s2.erase(s2.find(x)); 32 | } 33 | cout << *s2.begin() << '\n'; 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /_codeforces/519C/519c.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int n, m, teams; 7 | cin >> n >> m; 8 | while(1) { 9 | if(!n || !m) 10 | break; 11 | if(n == 1 && m == 1) 12 | break; 13 | if(n >= m) { 14 | -- m; 15 | n -= 2; 16 | } 17 | else { 18 | -- n; 19 | m -= 2; 20 | } 21 | ++ teams; 22 | } 23 | cout << teams << '\n'; 24 | } 25 | -------------------------------------------------------------------------------- /_codeforces/519D/519d.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | const int maxn = 100005; 8 | const int sigma = 26; 9 | 10 | unordered_map mymap[sigma]; 11 | int n, a[maxn]; 12 | string s; 13 | 14 | int main() { 15 | #ifndef ONLINE_JUDGE 16 | freopen("519d.in", "r", stdin); 17 | freopen("519d.out", "w", stdout); 18 | #endif 19 | for(int i = 0 ; i < 26 ; ++ i) 20 | cin >> a[i]; 21 | cin >> s; 22 | long long sum = 0, ans = 0; 23 | for(int i = 0 ; i < s.size() ; ++ i) { 24 | ans += mymap[s[i] - 'a'][sum]; 25 | sum += a[s[i] - 'a']; 26 | ++ mymap[s[i] - 'a'][sum]; 27 | } 28 | cout << ans << '\n'; 29 | } 30 | -------------------------------------------------------------------------------- /_codeforces/527/527.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/_codeforces/527/527.cpp -------------------------------------------------------------------------------- /_codeforces/527A/527a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | inline long long gcd(long long x, long long y) { 7 | if(y == 0) 8 | return 0; 9 | return x / y + gcd(y, x % y); 10 | } 11 | 12 | int main ( ){ 13 | #ifndef ONLINE_JUDGE 14 | freopen("527a.in", "r", stdin); 15 | freopen("527a.out", "w", stdout); 16 | #endif 17 | long long a, b; 18 | cin >> a >> b; 19 | cout << gcd(a, b) << '\n'; 20 | } 21 | -------------------------------------------------------------------------------- /bac/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | ifstream fin("bac.txt"); 7 | ofstream fout("bac.out"); 8 | 9 | int n, cnt[10], x; 10 | 11 | int main() { 12 | fin >> n; 13 | while(fin >> x) { 14 | int p = 0; 15 | while(x != 1) { 16 | ++ p; 17 | x /= 10; 18 | } 19 | ++ cnt[p]; 20 | } 21 | int sum = 0, nr = 1; 22 | bool okay = false; 23 | for(int i = 0 ; i < 10 ; ++ i) { 24 | sum = sum + cnt[i]; 25 | if(sum >= n) { 26 | cout << nr << '\n'; 27 | okay = true; 28 | break; 29 | } 30 | nr = nr * 10; 31 | } 32 | if(!okay) 33 | cout << "Nu exista"; 34 | } 35 | -------------------------------------------------------------------------------- /cf560/a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | const int maxn = 1005; 8 | 9 | int n, a[maxn]; 10 | 11 | int main() { 12 | #ifndef ONLINE_JUDGE 13 | freopen("input.in", "r", stdin); 14 | freopen("output.out", "w", stdout); 15 | #endif 16 | cin >> n; 17 | for(int i = 1 ; i <= n ; ++ i) 18 | cin >> a[i]; 19 | sort(a + 1, a + n + 1); 20 | if(a[1] == 1) 21 | cout << "-1\n"; 22 | else 23 | cout << "1\n"; 24 | } 25 | -------------------------------------------------------------------------------- /cf560/b.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | inline bool solve(int a1, int b1, int a2, int b2, int a3, int b3) { 6 | if(a2 + a3 <= a1 && max(b2, b3) <= b1) 7 | return 1; 8 | else 9 | if(a2 + b3 <= a1 && max(a3, b2) <= b1) 10 | return 1; 11 | else 12 | if(b2 + a3 <= a1 && max(b3, a2) <= b1) 13 | return 1; 14 | else 15 | if(b2 + b3 <= a1 && max(a2, a3) <= b1) 16 | return 1; 17 | else 18 | return 0; 19 | } 20 | 21 | int main() { 22 | #ifndef ONLINE_JUDGE 23 | freopen("input.in", "r", stdin); 24 | freopen("output.out", "w", stdout); 25 | #endif 26 | int a1, b1, a2, b2, a3, b3; 27 | cin >> a1 >> b1 >> a2 >> b2 >> a3 >> b3; 28 | if(solve(a1, b1, a2, b2, a3, b3) || solve(b1, a1, a2, b2, a3, b3)) 29 | cout << "YES\n"; 30 | else 31 | cout << "NO\n"; 32 | } 33 | -------------------------------------------------------------------------------- /cf560/c.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int a[10]; 7 | 8 | int main() { 9 | #ifndef ONLINE_JUDGE 10 | freopen("input.in", "r", stdin); 11 | freopen("output.out", "w", stdout); 12 | #endif 13 | for(int i = 1 ; i <= 6 ; ++ i) 14 | cin >> a[i]; 15 | int cnt = 2*a[1] + 1; 16 | long long sum = 0; 17 | for(int i = 1 ; i <= min(a[2], a[6]) ; ++ i) { 18 | sum += cnt; 19 | cnt += 2; 20 | } 21 | int aux = cnt - 1; 22 | cnt = 2*a[4] + 1; 23 | for(int i = 1 ; i <= min(a[3], a[5]) ; ++ i) { 24 | sum += cnt; 25 | cnt += 2; 26 | } 27 | int bux = cnt - 1; 28 | for(int i = min(a[2], a[6]) + 1 ; i <= max(a[2], a[6]) ; ++ i) 29 | sum += aux; 30 | cout << sum << '\n'; 31 | } 32 | -------------------------------------------------------------------------------- /cf560/e.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/cf560/e.cpp -------------------------------------------------------------------------------- /cf614/a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | long long l, r, k, kpow = 1; 7 | 8 | int main() { 9 | #ifndef ONLINE_JUDGE 10 | freopen("input.in", "r", stdin); 11 | freopen("output.out", "w", stdout); 12 | #endif 13 | cin >> l >> r >> k; 14 | vector v; 15 | v.push_back(1); 16 | for(int i = 0 ; kpow <= r / k ; ++ i) { 17 | kpow *= k; 18 | v.push_back(kpow); 19 | } 20 | bool ok = false; 21 | for(auto it : v) { 22 | if(it >= l) { 23 | cout << it << ' '; 24 | ok = true; 25 | } 26 | } 27 | if(!ok) 28 | cout << "-1\n"; 29 | } 30 | -------------------------------------------------------------------------------- /codejam1bb/GIMNAZIU_SOL_TESTE.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/codejam1bb/GIMNAZIU_SOL_TESTE.zip -------------------------------------------------------------------------------- /create.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir -p $1 4 | cd $1 5 | newString=${1,,} 6 | 7 | cpp=$newString".cpp" 8 | in=$newString".in" 9 | out=$newString".out" 10 | 11 | touch $cpp 12 | touch $in 13 | touch $out 14 | 15 | vim $cpp -c "vs "$in -c "sp "$out -c ":30winc <" 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /curs1_n_engl.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/curs1_n_engl.doc -------------------------------------------------------------------------------- /curs2_engl.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/curs2_engl.doc -------------------------------------------------------------------------------- /divk/divk.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | ifstream in("divk.in"); 5 | ofstream out("divk.out"); 6 | 7 | long long N, K, A, B, sol; 8 | long long V[500010], app[100010]; 9 | 10 | int main() 11 | { 12 | long long i, x; 13 | 14 | in >> N >> K >> A >> B; 15 | for(i = 1; i <= N; i++) 16 | { 17 | in >> x; 18 | V[i] = ( V[i-1] + x )%K; 19 | } 20 | for(i = 1; i <= N; i++) 21 | { 22 | if( i - A >= 0 ) 23 | ++app[V[i - A]]; 24 | if( i - B > 0 ) 25 | --app[V[i - B - 1]]; 26 | 27 | sol += app[V[i]]; 28 | } 29 | out << sol; 30 | return 0; 31 | } 32 | 33 | -------------------------------------------------------------------------------- /euclid2/euclid2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int gcd(int a, int b) { 7 | if(b == 0) 8 | return a; 9 | return gcd(b, a % b); 10 | } 11 | 12 | int gcdNonRecursive(int a, int b) { 13 | int r = 0; 14 | while(a % b != 0) { 15 | r = a % b; 16 | a = b; 17 | b = r; 18 | } 19 | return b; 20 | } 21 | 22 | int main() { 23 | ifstream fin("euclid2.in"); 24 | ofstream fout("euclid2.out"); 25 | int t; 26 | fin >> t; 27 | while(t --) { 28 | int a, b; 29 | fin >> a >> b; 30 | fout << gcd(a, b) << '\n'; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /gcj1c/c.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | freopen("input.in", "r", stdin); 7 | freopen("output.out", "w", stdout); 8 | 9 | int t; 10 | cin >> t; 11 | while(t --) { 12 | int 13 | } 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /hack/hack.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | ofstream cout("hack.in"); 7 | cout << "10000 5 999999999\n"; 8 | for(int i = 1 ; i <= 10000 ; ++ i, cout << '\n') 9 | for(int j = 1 ; j <= 5 ; ++ j) 10 | cout << 1 << ' '; 11 | } 12 | -------------------------------------------------------------------------------- /hackercup2016_qualif/me.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/hackercup2016_qualif/me.jpg -------------------------------------------------------------------------------- /hackercup2016_round1/c.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/hackercup2016_round1/c.cpp -------------------------------------------------------------------------------- /kfib/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | ifstream fin("kfib.in"): 7 | ofstream fout("kfib.out"); 8 | 9 | int main() { 10 | 11 | 12 | } 13 | -------------------------------------------------------------------------------- /kmp/kmp.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/kmp/kmp.cpp -------------------------------------------------------------------------------- /ksecv2/ksecv.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | ifstream cin("ksecv2.in"); 4 | ofstream cout("ksecv2.out"); 5 | int n, k, i, contor, sacosa, nr; 6 | long long a[3005], b[300005] ; 7 | int main() 8 | { 9 | cin>>n>>k; 10 | sacosa=1; 11 | for(i=1;i<=n;i++) 12 | cin>>a[i]; 13 | for(i=1;i<=n;i++) 14 | {if(a[i-1]<=a[i]) 15 | b[sacosa]++; 16 | else { sacosa++; 17 | b[sacosa]=b[sacosa-1]+1; 18 | }} 19 | if(b[k]) cout< 2 | using namespace std; 3 | ifstream fin("password.in"); 4 | ofstream fout("password.out"); 5 | int v[26],n,rezultat; 6 | int main() 7 | { 8 | int i,j; 9 | char n[100004]; 10 | fin>>n; 11 | for(i=0;i 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | void minimum_coins(const vector &v, int e) { 8 | // Write your code here 9 | // To print results to the standard output you can use the cout stream 10 | // Example: cout << "Hello world!"; 11 | vector dp(e + 1, numeric_limits::max()); /// dp[i] = min number of coins witch sum up to i 12 | dp[0] = 0; 13 | for(int i = 1 ; i <= e ; ++ i) 14 | for(int j = 0 ; j < v.size() ; ++ j) 15 | if(i - v[j] >= 0) 16 | dp[i] = min(dp[i], dp[i - v[j]] + 1); 17 | cout << dp[e] << '\n'; 18 | } 19 | -------------------------------------------------------------------------------- /test/test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | const int maxn = 100005; 7 | 8 | int main() { 9 | cout << "Hello world!\n"; 10 | } 11 | -------------------------------------------------------------------------------- /triplete/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | inline void triplete(int n) { 6 | for(int i = 1 ; i * i <= n ; ++ i) { 7 | if(n % i == 0) { 8 | int y = i; 9 | int sum = n / i; 10 | for(int x = 0 ; x <= sum ; ++ x) { 11 | int z = sum - x; 12 | if(x < y && y < z) 13 | cerr << x << ' ' << y << ' ' << z << '\n'; 14 | } 15 | } 16 | } 17 | } 18 | 19 | int main() { 20 | int n; 21 | cin >> n; 22 | /* for(int i = 1 ; i <= n ; ++ i) 23 | for(int j = i + 1 ; j <= n ; ++ j) 24 | for(int k = j + 1 ; k <= n ; ++ j) 25 | if(i * j + j * k == n) 26 | cout << i << ' ' << j << ' ' << k<< "\n"; 27 | */ 28 | triplete(n); 29 | } 30 | -------------------------------------------------------------------------------- /uva-10681/uva-10681.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rusucosmin/cplusplus/0e95cd01d20b22404aa4166c71d5a9e834a5a21b/uva-10681/uva-10681.cpp -------------------------------------------------------------------------------- /uva-825/uva-825.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | const int maxn = 1005; 10 | 11 | int t, n, m, cnt; 12 | long long dp[maxn][maxn]; 13 | bitset used[maxn]; 14 | 15 | int main() { 16 | #ifndef ONLINE_JUDGE 17 | freopen("uva-825.in", "r", stdin); 18 | freopen("uva-825.out", "w", stdout); 19 | #endif 20 | cin >> t; 21 | while(t -- ) { 22 | cin >> n >> m; 23 | memset(dp, 0, sizeof(dp)); 24 |  25 | for(int i = 1 ; i <= n ; ++ i) 26 | for(int j = 1 ; j <= m ; ++ j) 27 | if(i == 1 && j == 1) 28 | dp[i][j] = 1; 29 | else 30 | if(!used[i][j]) 31 | dp[i][j] = dp[i - 1][j] + dp[i][j - 1]; 32 | cout << dp[n][m] << '\n'; 33 | for(int i = 1 ; i <= n ; ++ i) 34 | used[i].reset(); 35 | } 36 | } 37 | --------------------------------------------------------------------------------