├── .DS_Store ├── .gitignore ├── 01 LIBRARY ├── 000 SNIPETS.cpp ├── 001 DSU.cpp ├── 002 Graph.cpp ├── 003 BIPAR.cpp ├── 004 LAZY.cpp ├── 005 GSS1.cpp ├── 006 GSS3.cpp ├── 007 SHKSTR.cpp ├── 008 DQUERY.cpp ├── 009 MST.cpp ├── 010 LCA.cpp ├── 011.0 Bloom Filters.cpp ├── 011.1 Multiple BF.cpp ├── 012 HLD.cpp ├── 013 CUTPOINTS.cpp ├── 014 BRIDGES.cpp ├── 015 FFT.cpp ├── 016 Trie.cpp ├── 017 Sparse Table.cpp ├── 018 BIT.cpp ├── 019 SEGTREE.cpp ├── 020 MAT MUL.cpp └── 021 SUFFIX ARRAYS.cpp ├── 02 CONTESTS ├── .DS_Store ├── AtCoder │ ├── B142 │ │ └── D.cpp │ ├── B153 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── B154 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── B155 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── B156 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── B157 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── B158 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── B159 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── B160 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ ├── F.cpp │ │ └── F.cpp.tcs │ ├── B161 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E..cpp │ │ └── F.cpp │ ├── B162 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── B163 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── B164 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── B165 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── B166 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── B167 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── B168 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── B169 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── B179 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── B183 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── EDDP │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── DI.cpp │ │ ├── E.cpp │ │ ├── F.cpp │ │ ├── G.cpp │ │ ├── H.cpp │ │ ├── I.cpp │ │ ├── K.cpp │ │ ├── L.cpp │ │ └── M.cpp │ ├── Hitachi2020 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ └── Panasonic2020 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ ├── F.cpp │ │ ├── a.py │ │ └── o.txt ├── Codechef │ ├── ABC │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ └── a.py │ ├── CHPTRS01 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ ├── F.cpp │ │ └── G.cpp │ ├── CMYC2020 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── COOK115A │ │ ├── 01.cpp │ │ ├── 02.cpp │ │ ├── 03.cpp │ │ ├── 04.cpp │ │ └── 05.cpp │ ├── COOK116 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ ├── F.cpp │ │ └── G.cpp │ ├── COOK117A │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── COOK118A │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── COOK122 │ │ ├── 01 BULBS.cpp │ │ ├── 02 MVAL.cpp │ │ ├── 03 MININS.cpp │ │ ├── 04 JTSARTR.cpp │ │ └── X.cpp │ ├── COOK123A │ │ └── B.cpp │ ├── CodeRed │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ ├── F.cpp │ │ └── G.cpp │ ├── CodeWars3 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── GHC32020 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── ICPC20 │ │ ├── 001.cpp │ │ ├── 002.cpp │ │ ├── 003.cpp │ │ └── EXPCAN.cpp │ ├── JUNE LONG │ │ └── TTUPLE.py │ ├── LDT42020 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── LONG APRIL20 │ │ ├── A.py │ │ ├── B.py │ │ ├── B_brute.py │ │ ├── C.py │ │ ├── C_testing.cpp │ │ ├── D.py │ │ ├── FCTRE.cpp │ │ └── UNITGCD.cpp │ ├── LONG FEB20 │ │ ├── 01.cpp │ │ ├── 02.cpp │ │ ├── 03.cpp │ │ ├── 04.py │ │ ├── 05.cpp │ │ ├── 06.cpp │ │ ├── 06A.cpp │ │ ├── 07.cpp │ │ └── 08.cpp │ ├── LONG JAN20 │ │ ├── 01.cpp │ │ ├── 02.cpp │ │ ├── 03.cpp │ │ ├── 04.cpp │ │ ├── 05.cpp │ │ ├── 06.cpp │ │ ├── 07.cpp │ │ └── 08.cpp │ ├── LONG MAR20 │ │ ├── 01.py │ │ ├── 02.cpp │ │ ├── 03.py │ │ ├── 04.cpp │ │ ├── 05.cpp │ │ ├── 06.py │ │ ├── 07.cpp │ │ └── 08.cpp │ ├── LONG MAY20 │ │ ├── A.py │ │ └── testgen.py │ ├── LONG NOV19A │ │ ├── FAILURE.cpp │ │ ├── FAILURE1.cpp │ │ ├── LSTBTF.cpp │ │ ├── PHCUL.cpp │ │ ├── SIMGAM.cpp │ │ ├── TRICOL.cpp │ │ └── WEIRDO.cpp │ ├── LONG OCT19B │ │ ├── 001.cpp │ │ ├── 002.cpp │ │ ├── 003.cpp │ │ ├── 004.cpp │ │ ├── 005.cpp │ │ ├── 006.py │ │ ├── 007.cpp │ │ ├── 007B.cpp │ │ └── 008.cpp │ ├── LONG OCT20 │ │ ├── 01 POSAND.cpp │ │ ├── 02 REPLESX.cpp │ │ ├── 03 DDIMMST.cpp │ │ ├── 04 ADDSQUARE.cpp │ │ ├── 05 INVSMOD2.cpp │ │ ├── 06 SEGCOMPR.cpp │ │ ├── 07 RANDKNAP.cpp │ │ ├── 08 ROOTMST.cpp │ │ └── 09 VILLNET.cpp │ ├── LONG SEPT20 │ │ ├── CRDGAME2.cpp │ │ └── FINXOR.cpp │ ├── LTIME 83A │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── LTIME 89A │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── LTIME77A │ │ ├── BOXGAM97.cpp │ │ ├── DDQUERY.cpp │ │ ├── DDQUERY2.cpp │ │ ├── HIT.cpp │ │ ├── INVYCNT.cpp │ │ └── INVZCNT.cpp │ ├── LTIME81 │ │ ├── 01.cpp │ │ ├── 02.cpp │ │ ├── 03.cpp │ │ ├── 04.cpp │ │ ├── 05.cpp │ │ ├── 06.cpp │ │ └── 07.cpp │ ├── LTIME82 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ └── D.cpp │ ├── LTIME84A │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── LTIME87A │ │ ├── A.cpp │ │ ├── B.cpp │ │ └── C.cpp │ ├── OCTCO19 │ │ ├── 001.cpp │ │ ├── 002.cpp │ │ └── 003.cpp │ ├── RECode │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ └── TAHIRING │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp ├── Codeforces │ ├── 583 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 586 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 621 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 521C │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── 525B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 568B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── C2.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ ├── F.cpp │ │ └── G1.cpp │ ├── 582C │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── D2.cpp │ │ ├── E.cpp │ │ ├── F.cpp │ │ └── G.cpp │ ├── 585B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── 587C │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── EH.cpp │ ├── 588B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ └── D.cpp │ ├── 590C │ │ ├── 001.cpp │ │ ├── 002.cpp │ │ ├── 003.cpp │ │ └── 004.cpp │ ├── 591B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ └── D.cpp │ ├── 592B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 593B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ └── D.cpp │ ├── 594B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ └── D.cpp │ ├── 595C │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── CH.cpp │ │ ├── D.cpp │ │ ├── DH.cpp │ │ └── E.cpp │ ├── 596B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ └── D.cpp │ ├── 597B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ └── D.cpp │ ├── 598C │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── F.cpp │ ├── 599B │ │ ├── A.cpp │ │ ├── B1.cpp │ │ ├── B2.cpp │ │ ├── C.cpp │ │ └── D.cpp │ ├── 600B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 601B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ └── D.cpp │ ├── 602B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D1.cpp │ │ └── D2.cpp │ ├── 603B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ └── D.cpp │ ├── 604B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ └── D.cpp │ ├── 605C │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 606B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 607B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ └── D.cpp │ ├── 608B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 609B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 610B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 612B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 613B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 614B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ └── D.cpp │ ├── 617C │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E1.cpp │ │ ├── E2.cpp │ │ └── F.cpp │ ├── 618B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 622B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── C2.cpp │ │ └── D.cpp │ ├── 623B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 625B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 626B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 627C │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── 628B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── 629C │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 630B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── 631B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 632B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── F.cpp │ ├── 633B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 634C │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ ├── E2.cpp │ │ └── F.cpp │ ├── 635B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 636C │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── 637B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 638B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 639B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 640D │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ ├── F.cpp │ │ └── G.cpp │ ├── 641B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── 642C │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── 643B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── 644C │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ ├── F.cpp │ │ ├── G.cpp │ │ └── H.cpp │ ├── 645B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 646B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── 647B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 648B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── 649B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 650C │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ ├── F1.cpp │ │ └── F2.cpp │ ├── 651B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F1.cpp │ ├── 652B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── 653C │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E1.cpp │ │ ├── E2.cpp │ │ └── F.cpp │ ├── 654B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E1.cpp │ │ └── E2.cpp │ ├── 655B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 656C │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ ├── F.cpp │ │ └── G.cpp │ ├── 657B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 658B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── C2.cpp │ │ └── D.cpp │ ├── 659B │ │ ├── B1.cpp │ │ └── D.cpp │ ├── 660B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 661C │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E1.cpp │ │ └── E2.cpp │ ├── 662B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 663B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 664B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 665B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── 666B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 667C │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── 668B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 669B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── DT.cpp │ │ └── E.cpp │ ├── 670B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── ETest.cpp │ ├── 671B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D1.cpp │ │ ├── D2.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── 672B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C1.cpp │ │ ├── C2.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 673B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 674C │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── 675B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 676B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ └── D.cpp │ ├── 677C │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ ├── F.cpp │ │ ├── G.cpp │ │ └── all.txt │ ├── 678B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 679B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 681B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── 682B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 684B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 687B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 688B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 690C │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ ├── E2.cpp │ │ └── F.cpp │ ├── 691B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ └── D.cpp │ ├── 692B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ └── D.cpp │ ├── 693C │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ ├── F.cpp │ │ └── G.cpp │ ├── 694B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── 695B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 696B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 697C │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ ├── F.cpp │ │ └── G.cpp │ ├── 698B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── 699B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 700B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D1.cpp │ │ └── D2.cpp │ ├── 701B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── 702C │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ ├── F.cpp │ │ └── G.cpp │ ├── 703B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C1.cpp │ │ ├── C2.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 705B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 706B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 709B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 718B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 719C │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ ├── F.cpp │ │ └── G.cpp │ ├── 721B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ └── D.cpp │ ├── 722B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 725C │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── 762C │ │ ├── A.cpp │ │ ├── B.cpp │ │ └── C.cpp │ ├── 780C │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ ├── F.cpp │ │ └── F2.cpp │ ├── 784D │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ ├── F.cpp │ │ ├── G.cpp │ │ └── H.cpp │ ├── 817D │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ ├── G.cpp │ │ └── X.cpp │ ├── 827D │ │ ├── D.cpp │ │ └── X.cpp │ ├── AlgoThread08 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── CRR01 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── CodeCraft20 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── ED100 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── ED101 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── ED102 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── ED103 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── ED105 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── ED108 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── ED120 │ │ └── F.cpp │ ├── ED73 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ └── D.cpp │ ├── ED74 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ └── D.cpp │ ├── ED75 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E1.cpp │ ├── ED76 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── ED77 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ └── D.cpp │ ├── ED78 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D │ │ ├── D.cpp │ │ └── E.cpp │ ├── ED80 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── o.txt │ ├── ED81 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── ED82 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── D.py │ │ └── E.cpp │ ├── ED83 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── ED84 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── ED85 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── ED86 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── ED87 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── ED88 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── ED89 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── ED90 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── ED93 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── ED94 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── ED95 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ └── D.cpp │ ├── ED96 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── ED98 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ └── D.cpp │ ├── ED99 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── GR01 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── D1.cpp │ │ └── E.cpp │ ├── GR05 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ └── D.cpp │ ├── GR06 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── GR07 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── GR08 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── GR09 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── GR10 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── GR11 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ └── D.cpp │ ├── GR12 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── GoodBye20 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── GraknForces2020 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp │ ├── ICPC NERC 20-2021 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ ├── F.cpp │ │ ├── G.cpp │ │ ├── H.cpp │ │ ├── I.cpp │ │ ├── J.cpp │ │ ├── K.cpp │ │ └── N.cpp │ └── NEERC1718 │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ └── F.cpp ├── Google │ ├── CODEJAM20 1A │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ └── D.cpp │ ├── CODEJAM20 1C │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── BBrute.cpp │ │ └── C.cpp │ ├── CODEJAM20 QAL │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ ├── runner.py │ │ └── testing.py │ ├── CODEJAM21 1B │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── CODEJAM21 QAL │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ ├── D.cpp │ │ └── E.cpp │ ├── HashCode2020 │ │ ├── 01.cpp │ │ ├── 01.zip │ │ ├── 02.cpp │ │ ├── 02.zip │ │ ├── 03.cpp │ │ ├── 03.zip │ │ ├── a_example.txt │ │ ├── b_read_on.txt │ │ ├── c_incunabula.txt │ │ ├── d_tough_choices.txt │ │ ├── e_so_many_books.txt │ │ ├── f_libraries_of_the_world.txt │ │ ├── output_a.txt │ │ ├── output_b.txt │ │ ├── output_c.txt │ │ ├── output_d.txt │ │ ├── output_e.txt │ │ └── output_f.txt │ ├── KICK19G │ │ ├── 001.cpp │ │ ├── 002.cpp │ │ └── 003.cpp │ ├── KICK20A │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.cpp │ │ └── D.cpp │ └── KICK20E │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── BTest.cpp │ │ ├── C.cpp │ │ └── D.cpp ├── HASHCODE.cpp └── Misc │ ├── ABC │ ├── A.cpp │ ├── B.cpp │ ├── C.cpp │ ├── D.cpp │ ├── E.cpp │ └── giftsAndTrees.cpp │ ├── CodeAgon │ ├── A.cpp │ ├── B.cpp │ ├── C.cpp │ ├── D.cpp │ ├── E.cpp │ └── F.cpp │ ├── GW18 │ ├── A.cpp │ ├── B.cpp │ ├── C.cpp │ └── D.cpp │ ├── GW19MOS │ ├── 001SAFEROBO.cpp │ ├── 002TELNET.cpp │ ├── 003MEANPROB.cpp │ ├── 004EAREA.cpp │ ├── 005INVSACK.cpp │ └── 006TRGAME.cpp │ ├── JAKARTA │ ├── A.cpp │ ├── C.cpp │ └── H.cpp │ ├── KH19MOS │ ├── 001 WALKFAST.cpp │ ├── 002 BALLCOL.cpp │ ├── 003 MAXDIVER.cpp │ └── 004 RANDID.cpp │ ├── Mashup #3 │ ├── A.cpp │ ├── B.cpp │ ├── C.cpp │ ├── D.cpp │ ├── E.cpp │ ├── F.cpp │ ├── G │ └── G.cpp │ ├── Mashup #4 │ ├── A.cpp │ ├── B.cpp │ ├── C.cpp │ ├── D.cpp │ ├── E.cpp │ ├── F.cpp │ ├── G.cpp │ └── H.cpp │ ├── Mashup (Div-2 Difficulty)#2 │ ├── A.cpp │ ├── B.cpp │ ├── C.cpp │ ├── D.cpp │ └── E.cpp │ ├── Mashup (Div-2 difficulty) #3 │ ├── A.cpp │ ├── B.cpp │ ├── C.cpp │ ├── D.cpp │ ├── E.cpp │ └── F.cpp │ ├── NewtonSchool01 │ ├── A.cpp │ ├── B.cpp │ ├── C.cpp │ ├── D.cpp │ ├── E.cpp │ └── F.cpp │ └── heisenbug │ ├── A.cpp │ ├── A.py │ ├── B.cpp │ ├── C.cpp │ ├── D.cpp │ ├── E.cpp │ ├── F.cpp │ └── G.cpp ├── 03 CF PRACTICE ├── 1061C.cpp ├── 1118D2.cpp ├── 1165E.cpp ├── 1166D.cpp ├── 1166E.cpp ├── 116C.cpp ├── 453B.cpp ├── 471D.cpp ├── 977F.cpp ├── 984D.cpp ├── APRIL CF │ ├── 1129A2.cpp │ ├── 1131D.cpp │ ├── 1132F.cpp │ ├── 1133E.cpp │ ├── 1136D.cpp │ ├── 1141F2.cpp │ ├── 1147B.cpp │ ├── 1148D.cpp │ ├── 1152D.cpp │ ├── 1153D.cpp │ ├── 1154E.cpp │ ├── 1155D.cpp │ ├── 1156B.cpp │ ├── 1156C.cpp │ ├── 1163C2.cpp │ ├── 1169C.cpp │ ├── 1169D.cpp │ ├── 1172B.cpp │ ├── 1173C.cpp │ ├── 1174D.cpp │ ├── 1175D.cpp │ ├── 1176D.cpp │ ├── 1177B.cpp │ ├── 1178E.cpp │ ├── 1179B.cpp │ ├── 1183E.cpp │ ├── 1183H.cpp │ ├── 1187E.cpp │ ├── 1200E.cpp │ ├── 1207D.cpp │ └── 1208D.cpp ├── ITMO CF EDU │ └── Suffix Arrays │ │ ├── 03.cpp │ │ ├── 04.cpp │ │ ├── 05.cpp │ │ ├── 06.cpp │ │ ├── 07.cpp │ │ └── 08.cpp └── MAY CF │ ├── 1096D.cpp │ ├── 1106E.cpp │ ├── 1107E.cpp │ ├── 1108E.cpp │ ├── 1108E2.cpp │ ├── 1108F.cpp │ ├── 110pB.cpp │ ├── 1114D.cpp │ ├── 1117C.cpp │ ├── 1117D.cpp │ ├── 1117E.cpp │ ├── 1119E.cpp │ ├── 1151E.cpp │ ├── 118E.cpp │ ├── 1210C.cpp │ ├── 1216F.cpp │ ├── 1217D.cpp │ ├── 1223E.cpp │ ├── 1334E.cpp │ ├── 1339E.cpp │ ├── 451D.cpp │ ├── 710E.cpp │ ├── 888E.cpp │ └── 938D.cpp ├── 04 CC PRACTICE ├── ALLSUB.cpp ├── CHEFDIV.cpp ├── CHEFQUE.cpp ├── COMPEXP.cpp ├── DBFB.cpp ├── DSALEARN │ ├── 02 │ │ ├── CHFQUEUE.cpp │ │ ├── NOTALLFL.cpp │ │ ├── ZCO12002.cpp │ │ └── ZCO15004.cpp │ └── 03 │ │ ├── CVOTE.cpp │ │ ├── DPAIRS.cpp │ │ └── FENCE.cpp ├── EXPGCD.cpp ├── INTRPATH.cpp ├── MSTICK.cpp ├── PAIRSUM2.cpp ├── PERMPART.cpp ├── REDCGAME.cpp ├── SNAKEEAT.cpp ├── STDDEV.cpp ├── ZCO12004.cpp └── ZCO14004.cpp ├── 05 SPOJ ├── 001 MKTHNUM.cpp ├── 002 QTREE.cpp └── 003 QTREE5.cpp ├── 06 IO ├── BUILD ├── BUILD_MAC ├── C.cpp ├── CB.cpp ├── CP.sublime-project ├── CP.sublime-workspace ├── flag.txt ├── input.txt ├── output.txt ├── output.txtd └── tc.txt ├── 07 CSES ├── 01 Introductory Problems │ ├── 01.cpp │ ├── 02.cpp │ ├── 03.cpp │ ├── 04.cpp │ ├── 05.cpp │ ├── 06.cpp │ ├── 07.cpp │ ├── 08.cpp │ ├── 09.cpp │ ├── 10.cpp │ ├── 11.cpp │ ├── 12.cpp │ ├── 13.cpp │ ├── 14.cpp │ ├── 15.cpp │ └── 16.cpp ├── 02 Sorting and Searching │ ├── 01.cpp │ ├── 02.cpp │ ├── 03.cpp │ ├── 04.cpp │ ├── 05.cpp │ ├── 06.cpp │ ├── 07.cpp │ ├── 08.cpp │ ├── 09.cpp │ ├── 10.cpp │ ├── 11.cpp │ ├── 12.cpp │ ├── 13.cpp │ ├── 14.cpp │ ├── 15.cpp │ ├── 16.cpp │ ├── 17.cpp │ ├── 18.cpp │ ├── 19.cpp │ ├── 20.cpp │ ├── 21.cpp │ ├── 22.cpp │ ├── 23.cpp │ ├── 24.cpp │ ├── 25.cpp │ ├── 26.cpp │ ├── 27.cpp │ ├── 28.cpp │ └── 29.cpp ├── 03 Dynamic Programming │ ├── 01.cpp │ ├── 02.cpp │ ├── 03.cpp │ ├── 04.cpp │ ├── 05.cpp │ ├── 06.cpp │ ├── 07.cpp │ ├── 08.cpp │ ├── 09.cpp │ ├── 10.cpp │ ├── 11.cpp │ ├── 12.cpp │ ├── 13.cpp │ ├── 14.cpp │ └── 15.cpp └── 04 Graph Algorithms │ ├── 01.cpp │ ├── 02.cpp │ ├── 03.cpp │ ├── 04.cpp │ ├── 05.cpp │ ├── 06.cpp │ ├── 07.cpp │ ├── 08.cpp │ ├── 09.cpp │ ├── 10.cpp │ ├── 11.cpp │ ├── 12.cpp │ ├── 13.cpp │ ├── 14.cpp │ ├── 15.cpp │ ├── 16.cpp │ └── 17.cpp ├── README.md └── Random Data Structure.cpp /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yash0530/Competitive-Programming/502bcb237c3e7b52f46fe51cc80ce1435e443af3/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/c++,visualstudiocode 3 | # Edit at https://www.gitignore.io/?templates=c++,visualstudiocode 4 | 5 | ### C++ ### 6 | # Prerequisites 7 | *.d 8 | 9 | todo.txt 10 | 11 | # Compiled Object files 12 | *.slo 13 | *.lo 14 | *.o 15 | *.obj 16 | *.out 17 | 18 | # problem setting 19 | 00 setting/ 20 | 21 | # Precompiled Headers 22 | *.gch 23 | *.pch 24 | 25 | # Compiled Dynamic libraries 26 | *.so 27 | *.dylib 28 | *.dll 29 | 30 | # Fortran module files 31 | *.mod 32 | *.smod 33 | 34 | # Compiled Static libraries 35 | *.lai 36 | *.la 37 | *.a 38 | *.lib 39 | 40 | # Executables 41 | *.exe 42 | *.out 43 | *.app 44 | 45 | ### VisualStudioCode ### 46 | .vscode/* 47 | !.vscode/settings.json 48 | !.vscode/tasks.json 49 | !.vscode/launch.json 50 | !.vscode/extensions.json 51 | 52 | ### VisualStudioCode Patch ### 53 | # Ignore all local history of files 54 | .history 55 | 56 | # End of https://www.gitignore.io/api/c++,visualstudiocode 57 | -------------------------------------------------------------------------------- /01 LIBRARY/001 DSU.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class WeightedUF { 5 | private: 6 | vector arr; 7 | vector size; 8 | 9 | int __root(int a) { 10 | while (arr[a] != a) { 11 | arr[a] = arr[arr[a]]; 12 | a = arr[a]; 13 | } 14 | return a; 15 | } 16 | 17 | public: 18 | WeightedUF(int v) { 19 | arr = vector(v + 1); 20 | size = vector(v + 1); 21 | for (int i = 0; i <= v; i++) { 22 | size[i] = 1; 23 | arr[i] = i; 24 | } 25 | } 26 | 27 | bool _union(int a, int b) { 28 | int rootA = __root(a); 29 | int rootB = __root(b); 30 | 31 | if (rootA == rootB) return false; 32 | 33 | if (size[rootA] < size[rootB]) { 34 | arr[rootA] = rootB; 35 | size[rootB] += size[rootA]; 36 | } else { 37 | arr[rootB] = rootA; 38 | size[rootA] += size[rootB]; 39 | } 40 | return true; 41 | } 42 | 43 | bool _find(int a, int b) { 44 | return __root(a) == __root(b); 45 | } 46 | }; -------------------------------------------------------------------------------- /01 LIBRARY/013 CUTPOINTS.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int n; 5 | const int maxN = 1e5 + 5; 6 | vector adj[maxN]; 7 | 8 | vector visited; 9 | vector tin, low; 10 | set cutpoints; 11 | int timer; 12 | 13 | void dfs(int v, int p = -1) { 14 | visited[v] = true; 15 | tin[v] = low[v] = timer++; 16 | int children=0; 17 | for (int to : adj[v]) { 18 | if (to == p) continue; 19 | if (visited[to]) { 20 | low[v] = min(low[v], tin[to]); 21 | } else { 22 | dfs(to, v); 23 | low[v] = min(low[v], low[to]); 24 | if (low[to] >= tin[v] and p!=-1) 25 | cutpoints.insert(v); 26 | ++children; 27 | } 28 | } 29 | if(p == -1 and children > 1) 30 | cutpoints.insert(v); 31 | } 32 | 33 | void find_cutpoints() { 34 | timer = 0; 35 | visited.assign(n, false); 36 | tin.assign(n, -1); 37 | low.assign(n, -1); 38 | for (int i = 0; i < n; ++i) { 39 | if (!visited[i]) dfs(i); 40 | } 41 | } -------------------------------------------------------------------------------- /01 LIBRARY/014 BRIDGES.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int n; 5 | const int maxN = 1e5 + 5; 6 | vector adj[maxN]; 7 | 8 | vector visited; 9 | vector tin, low; 10 | set bridges; 11 | int timer; 12 | 13 | void dfs(int v, int p = -1) { 14 | visited[v] = true; 15 | tin[v] = low[v] = timer++; 16 | for (int to : adj[v]) { 17 | if (to == p) continue; 18 | if (visited[to]) { 19 | low[v] = min(low[v], tin[to]); 20 | } else { 21 | dfs(to, v); 22 | low[v] = min(low[v], low[to]); 23 | if (low[to] > tin[v]) 24 | bridges.insert(v, to); 25 | } 26 | } 27 | } 28 | 29 | void find_bridges() { 30 | timer = 0; 31 | visited.assign(n, false); 32 | tin.assign(n, -1); 33 | low.assign(n, -1); 34 | for (int i = 0; i < n; ++i) { 35 | if (!visited[i]) 36 | dfs(i); 37 | } 38 | } -------------------------------------------------------------------------------- /01 LIBRARY/018 BIT.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define int long long 4 | 5 | int n; 6 | const int maxN = 1e5 + 5; 7 | int tree[maxN]; 8 | 9 | void update(int index, int val) { 10 | while (index <= n) { 11 | tree[index] += val; 12 | index += (index & -index); 13 | } 14 | } 15 | 16 | int read(int index) { 17 | int sum = 0; 18 | while (index) { 19 | sum += tree[index]; 20 | index -= (index & -index); 21 | } 22 | return sum; 23 | } 24 | 25 | int32_t main() { 26 | int n; cin >> n; 27 | } -------------------------------------------------------------------------------- /01 LIBRARY/020 MAT MUL.cpp: -------------------------------------------------------------------------------- 1 | #define Mat vector> 2 | #define getMat(a, b) vector>(a, vector(b, 0)) 3 | 4 | // matrix mul 5 | Mat mat_mul(Mat a, Mat b) { 6 | 7 | Mat res = getMat(size(a), size(b[0])); 8 | for (int i = 0; i < size(a); i++) { 9 | for (int j = 0; j < size(b[0]); j++) { 10 | for (int k = 0; k < size(a[0]); k++) { 11 | res[i][j] = (res[i][j] + a[i][k] * b[k][j]) % MOD; 12 | } 13 | } 14 | } 15 | 16 | return res; 17 | } 18 | 19 | // matrix expo 20 | Mat mat_pow(Mat base, int pow) { 21 | Mat res = base; pow--; 22 | while (pow) { 23 | if (pow & 1) { 24 | res = mat_mul(res, base); 25 | } 26 | base = mat_mul(base, base); 27 | pow >>= 1; 28 | } 29 | return res; 30 | } -------------------------------------------------------------------------------- /02 CONTESTS/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yash0530/Competitive-Programming/502bcb237c3e7b52f46fe51cc80ce1435e443af3/02 CONTESTS/.DS_Store -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B155/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cout << #x << " => " << x << "\n" 11 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 12 | #define debm(x) cout << #x << "\n"; for (auto a : x){for(auto b : a) cout << b << " "; cout << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int32_t main() { fastio; 18 | vector arr(3); 19 | for (int i = 0; i < 3; i++) { 20 | cin >> arr[i]; 21 | } 22 | sort(arr.begin(), arr.end()); 23 | if (arr[0] == arr[1] and arr[1] == arr[2]) { 24 | cout << "No" << endl; 25 | } else if (arr[0] == arr[1] or arr[1] == arr[2]) { 26 | cout << "Yes" << endl; 27 | } else { 28 | cout << "No" << endl; 29 | } 30 | return 0; 31 | } -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B155/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cout << #x << " => " << x << "\n" 11 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 12 | #define debm(x) cout << #x << "\n"; for (auto a : x){for(auto b : a) cout << b << " "; cout << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int32_t main() { fastio; 18 | int n; cin >> n; 19 | vector arr(n); 20 | for (int i = 0; i < n; i++) { 21 | cin >> arr[i]; 22 | } 23 | bool possible = true; 24 | for (auto x : arr) { 25 | if (x % 2 == 0 and (x % 3 != 0 and x % 5 != 0)) { 26 | possible = false; 27 | } 28 | } 29 | if (possible) { 30 | cout << "APPROVED" << endl; 31 | } else { 32 | cout << "DENIED" << endl; 33 | } 34 | return 0; 35 | } -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B155/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cout << #x << " => " << x << "\n" 11 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 12 | #define debm(x) cout << #x << "\n"; for (auto a : x){for(auto b : a) cout << b << " "; cout << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int32_t main() { fastio; 18 | int n; cin >> n; 19 | map mp; 20 | for (int i = 0; i < n; i++) { 21 | string s; cin >> s; 22 | mp[s]++; 23 | } 24 | int mx = 0; 25 | for (auto m : mp) { 26 | mx = max(mx, m.second); 27 | } 28 | for (auto m : mp) { 29 | if (m.second == mx) { 30 | cout << m.first << endl; 31 | } 32 | } 33 | return 0; 34 | } -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B155/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cout << #x << " => " << x << "\n" 11 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 12 | #define debm(x) cout << #x << "\n"; for (auto a : x){for(auto b : a) cout << b << " "; cout << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int32_t main() { fastio; 18 | int n, k; 19 | cin >> n >> k; 20 | vector arr(n); 21 | for (int i = 0; i < n; i++) { 22 | cin >> arr[i]; 23 | } 24 | sort(arr.begin(), arr.end()); 25 | int sum = 0; 26 | for (int i = 0; i < n - 1; i++) { 27 | if (k > (n - i - 1)) { 28 | k -= (n - i - 1); 29 | } else { 30 | deb(i); 31 | sum = arr[i] * arr[i + k]; 32 | break; 33 | } 34 | } 35 | cout << sum << endl; 36 | return 0; 37 | } -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B155/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cout << #x << " => " << x << "\n" 11 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 12 | #define debm(x) cout << #x << "\n"; for (auto a : x){for(auto b : a) cout << b << " "; cout << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int32_t main() { fastio; 18 | string s; cin >> s; 19 | int sum = 0; 20 | int n = s.length(); 21 | int carry_back = 0; 22 | for (int i = n - 1; i >= 0; i--) { 23 | int x = s[i] - '0'; 24 | if ((x + carry_back) < (11 - x - carry_back)) { 25 | sum += x + carry_back; 26 | carry_back = 0; 27 | } else { 28 | sum += 10 - x - carry_back; 29 | carry_back = 1; 30 | } 31 | } 32 | sum += carry_back; 33 | cout << sum << endl; 34 | return 0; 35 | } -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B155/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cout << #x << " => " << x << "\n" 11 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 12 | #define debm(x) cout << #x << "\n"; for (auto a : x){for(auto b : a) cout << b << " "; cout << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int32_t main() { fastio; 18 | 19 | return 0; 20 | } -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B156/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int now() { 25 | return std::chrono::duration_cast(std::chrono::system_clock::now() 26 | .time_since_epoch()).count(); 27 | } 28 | 29 | int32_t main() { fastio; 30 | time_t start = now(); 31 | 32 | 33 | 34 | cerr << "TIME => " << now() - start << endl; 35 | return 0; 36 | } -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B157/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int now() { 25 | return chrono::duration_cast(chrono::system_clock::now() 26 | .time_since_epoch()).count(); 27 | } 28 | 29 | int32_t main() { fastio; 30 | time_t start = now(); 31 | 32 | int n; cin >> n; 33 | cout << (n + 1) / 2 << endl; 34 | 35 | cerr << "TIME => " << now() - start << endl; 36 | return 0; 37 | } -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B159/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; 20 | } return res; 21 | } 22 | 23 | int now() { 24 | return chrono::duration_cast(chrono::system_clock::now() 25 | .time_since_epoch()).count(); 26 | } 27 | 28 | int32_t main() { fastio; 29 | time_t start = now(); 30 | 31 | int h, w, k; 32 | cin >> h >> w >> k; 33 | 34 | 35 | cerr << "TIME => " << now() - start << endl; 36 | return 0; 37 | } -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B159/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; 20 | } return res; 21 | } 22 | 23 | int now() { 24 | return chrono::duration_cast(chrono::system_clock::now() 25 | .time_since_epoch()).count(); 26 | } 27 | 28 | int32_t main() { fastio; 29 | time_t start = now(); 30 | 31 | 32 | 33 | cerr << "TIME => " << now() - start << endl; 34 | return 0; 35 | } -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B160/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; 20 | } return res; 21 | } 22 | 23 | int32_t main() { fastio; 24 | 25 | string s; cin >> s; 26 | if (s[2] == s[3] and s[4] == s[5]) { 27 | cout << "Yes" << endl; 28 | } else { 29 | cout << "No" << endl; 30 | } 31 | 32 | return 0; 33 | } -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B160/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; 20 | } return res; 21 | } 22 | 23 | int32_t main() { fastio; 24 | 25 | int n; cin >> n; 26 | int hap = 1000 * (n / 500); 27 | n = n % 500; 28 | hap += 5 * (n / 5); 29 | cout << hap << endl; 30 | 31 | return 0; 32 | } -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B160/F.cpp.tcs: -------------------------------------------------------------------------------- 1 | [{"input":"6\n9 12\n2 11\n1 3\n6 10\n5 7\n4 8","output":""}] -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B161/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | int fastpow(int a, int b, int m) { 17 | int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m; 18 | a = (a * a) % m; b >>= 1; } return res;} 19 | #define inv(a) fastpow(a, HELL - 2, HELL) 20 | 21 | int32_t main() { fastio; 22 | int a, b, c; 23 | cin >> a >> b >> c; 24 | cout << c << " " << a << " " << b << endl; 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B161/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | int fastpow(int a, int b, int m) { 17 | int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m; 18 | a = (a * a) % m; b >>= 1; } return res;} 19 | #define inv(a) fastpow(a, HELL - 2, HELL) 20 | 21 | int32_t main() { fastio; 22 | int n, k; 23 | cin >> n >> k; 24 | cout << min((n % k), (k - (n % k)) % k) << endl; 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B161/E..cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | int fastpow(int a, int b, int m) { 17 | int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m; 18 | a = (a * a) % m; b >>= 1; } return res;} 19 | #define inv(a) fastpow(a, HELL - 2, HELL) 20 | 21 | int32_t main() { fastio; 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B162/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | int fastpow(int a, int b, int m) { 17 | int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m; 18 | a = (a * a) % m; b >>= 1; } return res;} 19 | #define inv(a) fastpow(a, HELL - 2, HELL) 20 | #define size(a) (int) a.size() 21 | 22 | int32_t main() { fastio; 23 | int n; cin >> n; 24 | int sum = 0; 25 | for (int i = 1; i <= n; i++) { 26 | if (i % 3 != 0 and i % 5 != 0) { 27 | sum += i; 28 | } 29 | } 30 | cout << sum << endl; 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B162/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | int fastpow(int a, int b, int m) { 17 | int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m; 18 | a = (a * a) % m; b >>= 1; } return res;} 19 | #define inv(a) fastpow(a, HELL - 2, HELL) 20 | #define size(a) (int) a.size() 21 | 22 | int32_t main() { fastio; 23 | int n; cin >> n; 24 | if (n % 15 == 0) { 25 | cout << "FizzBuzz" << endl; 26 | } else if (n % 3 == 0) { 27 | cout << "Fizz" << endl; 28 | } else if (n % 5 == 0) { 29 | cout << "Buzz" << endl; 30 | } 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B162/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | int fastpow(int a, int b, int m) { 17 | int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m; 18 | a = (a * a) % m; b >>= 1; } return res;} 19 | #define inv(a) fastpow(a, HELL - 2, HELL) 20 | #define size(a) (int) a.size() 21 | 22 | int32_t main() { fastio; 23 | int n; cin >> n; 24 | int res = 0; 25 | for (int i = 1; i <= n; i++) { 26 | for (int j = 1; j <= n; j++) { 27 | int g = __gcd(i, j); 28 | for (int k = 1; k <= n; k++) { 29 | res += __gcd(g, k); 30 | } 31 | } 32 | } 33 | cout << res << endl; 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B163/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | 26 | double x = 6.28318530717958623200; 27 | 28 | int32_t main() { fastio; 29 | int n; cin >> n; 30 | pout << n * x << endl; 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B163/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | 26 | int32_t main() { fastio; 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B164/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | 26 | int32_t main() { fastio; 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B165/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | #define mul(a, b) ((a % HELL) * (b % HELL)) % HELL 26 | 27 | int32_t main() { fastio; 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B165/F.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yash0530/Competitive-Programming/502bcb237c3e7b52f46fe51cc80ce1435e443af3/02 CONTESTS/AtCoder/B165/F.cpp -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B168/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | #define mul(a, b) ((a % HELL) * (b % HELL)) % HELL 26 | 27 | int32_t main() { fastio; 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B168/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | #define mul(a, b) ((a % HELL) * (b % HELL)) % HELL 26 | 27 | int32_t main() { fastio; 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B168/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | #define mul(a, b) ((a % HELL) * (b % HELL)) % HELL 26 | 27 | int32_t main() { fastio; 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B168/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | #define mul(a, b) ((a % HELL) * (b % HELL)) % HELL 26 | 27 | int32_t main() { fastio; 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B168/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | #define mul(a, b) ((a % HELL) * (b % HELL)) % HELL 26 | 27 | int32_t main() { fastio; 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/B168/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | #define mul(a, b) ((a % HELL) * (b % HELL)) % HELL 26 | 27 | int32_t main() { fastio; 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/EDDP/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long int ll; 4 | typedef unsigned long long int ull; 5 | #define deb(x) cout << #x << " => " << x << endl 6 | 7 | int main() { 8 | 9 | ios_base :: sync_with_stdio(false); 10 | cin.tie(NULL); 11 | cout.tie(NULL); 12 | 13 | int n; cin >> n; 14 | int arr[n]; 15 | for (int i = 0; i < n; i++) { 16 | cin >> arr[i]; 17 | } 18 | 19 | int dp[n]; 20 | memset(dp, 0, sizeof dp); 21 | dp[0] = 0; 22 | dp[1] = abs(arr[0] - arr[1]); 23 | for (int i = 2; i < n; i++) { 24 | dp[i] = min(abs(arr[i - 2] - arr[i]) + dp[i - 2], abs(arr[i - 1] - arr[i]) + dp[i - 1]); 25 | } 26 | cout << dp[n - 1] << endl; 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/EDDP/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long int ll; 4 | typedef unsigned long long int ull; 5 | #define deb(x) cout << #x << " => " << x << endl 6 | 7 | int main() { 8 | 9 | ios_base :: sync_with_stdio(false); 10 | cin.tie(NULL); 11 | cout.tie(NULL); 12 | 13 | int n, k; cin >> n >> k; 14 | int arr[n]; 15 | for (int i = 0; i < n; i++) { 16 | cin >> arr[i]; 17 | } 18 | 19 | int dp[n]; 20 | memset(dp, 0, sizeof dp); 21 | dp[0] = 0; 22 | for (int i = 1; i < n; i++) { 23 | dp[i] = INT_MAX; 24 | for (int j = max(0, i - k); j < i; j++) { 25 | dp[i] = min(dp[i], abs(arr[j] - arr[i]) + dp[j]); 26 | } 27 | } 28 | cout << dp[n - 1] << endl; 29 | 30 | return 0; 31 | } -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/EDDP/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long int ll; 4 | typedef unsigned long long int ull; 5 | #define deb(x) cout << #x << " => " << x << endl 6 | 7 | int main() { 8 | 9 | ios_base :: sync_with_stdio(false); 10 | cin.tie(NULL); 11 | cout.tie(NULL); 12 | 13 | int n; cin >> n; 14 | int arr[n][3]; 15 | for (int i = 0; i < n; i++) { 16 | for (int j = 0; j < 3; j++) { 17 | cin >> arr[i][j]; 18 | } 19 | } 20 | 21 | int dp[n][3]; 22 | dp[0][0] = arr[0][0]; dp[0][1] = arr[0][1]; dp[0][2] = arr[0][2]; 23 | for (int i = 1; i < n; i++) { 24 | dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + arr[i][0]; 25 | dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + arr[i][1]; 26 | dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + arr[i][2]; 27 | } 28 | 29 | cout << *max_element(dp[n - 1], dp[n - 1] + 3) << endl; 30 | 31 | return 0; 32 | } -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/EDDP/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long int ll; 4 | typedef unsigned long long int ull; 5 | #define deb(x) cout << #x << " => " << x << endl 6 | 7 | int H[101][100001]; 8 | 9 | int knapSack(int *vals, int *wgs, int n, int w) { 10 | if (n < 0) return 0; 11 | if (w == 0) return 0; 12 | 13 | if (H[n][w] != -1) { 14 | return H[n][w]; 15 | } 16 | int res = knapSack(vals, wgs, n - 1, w); 17 | if (w >= wgs[n]) { 18 | res = max(res, knapSack(vals, wgs, n - 1, w - wgs[n]) + vals[n]); 19 | } 20 | H[n][w] = res; 21 | return res; 22 | } 23 | 24 | int main() { 25 | 26 | ios_base :: sync_with_stdio(false); 27 | cin.tie(NULL); 28 | cout.tie(NULL); 29 | 30 | int n, w; 31 | cin >> n >> w; 32 | int vals[n], wgs[n]; 33 | for (int i = 0; i < n; i++) { 34 | cin >> wgs[i] >> vals[i]; 35 | } 36 | memset(H, -1, sizeof H); 37 | cout << knapSack(vals, wgs, n - 1, w) << endl; 38 | 39 | return 0; 40 | } -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/EDDP/DI.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long int ll; 4 | typedef unsigned long long int ull; 5 | #define deb(x) cout << #x << " => " << x << endl 6 | 7 | int main() { 8 | 9 | ios_base :: sync_with_stdio(false); 10 | cin.tie(NULL); 11 | cout.tie(NULL); 12 | 13 | ll n, w; 14 | cin >> n >> w; 15 | int val, weight; 16 | vector dp(w + 1); 17 | 18 | for (ll i = 0; i < n; i++) { 19 | cin >> weight >> val; 20 | for (int j = w; j >= weight; j--) { 21 | dp[j] = max(dp[j], dp[j - weight] + val); 22 | } 23 | } 24 | cout << *max_element(dp.begin(), dp.end()) << endl; 25 | 26 | return 0; 27 | } -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/EDDP/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long int ll; 4 | typedef unsigned long long int ull; 5 | #define deb(x) cout << #x << " => " << x << endl 6 | 7 | int main() { 8 | 9 | ios_base :: sync_with_stdio(false); 10 | cin.tie(NULL); 11 | cout.tie(NULL); 12 | 13 | ll n, w; 14 | cin >> n >> w; 15 | vector weights(n), vals(n); 16 | for (int i = 0; i < n; i++) { 17 | cin >> weights[i] >> vals[i]; 18 | } 19 | int max_val = 0; 20 | for (auto x : vals) { 21 | max_val += x; 22 | } 23 | 24 | // dp[i] => minimum weight required to get i value 25 | vector dp(max_val + 1, 1e18 + 1); 26 | dp[0] = 0; 27 | for (int item = 0; item < n; item++) { 28 | for (int j = max_val; j >= vals[item]; j--) { 29 | dp[j] = min(dp[j], dp[j - vals[item]] + weights[item]); 30 | } 31 | } 32 | 33 | for (int i = max_val; i >= 0; i--) { 34 | if (dp[i] <= w) { 35 | cout << i << endl; 36 | return 0; 37 | } 38 | } 39 | 40 | return 0; 41 | } -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/EDDP/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long int ll; 4 | typedef unsigned long long int ull; 5 | #define deb(x) cout << #x << " => " << x << endl 6 | 7 | int main() { 8 | 9 | ios_base :: sync_with_stdio(false); 10 | cin.tie(NULL); 11 | cout.tie(NULL); 12 | 13 | string a, b; 14 | cin >> a >> b; 15 | int m = b.length(), n = a.length(); 16 | int dp[n][m]; 17 | 18 | for (int i = 0; i < n; i++) { 19 | for (int j = 0; j < m; j++) { 20 | if (a[i] == b[j]) { 21 | dp[i][j] = (i > 0 and j > 0 ? dp[i - 1][j - 1] : 0) + 1; 22 | } else { 23 | dp[i][j] = max(i > 0 ? dp[i - 1][j] : 0, j > 0 ? dp[i][j - 1] : 0); 24 | } 25 | } 26 | } 27 | 28 | string res; 29 | int i = n - 1, j = m - 1; 30 | while (i >= 0 and j >= 0) { 31 | if (a[i] == b[j]) { 32 | res.push_back(a[i]); 33 | i--; j--; 34 | } else if ((i > 0 ? dp[i - 1][j] : 0) > (j > 0 ? dp[i][j - 1] : 0)) { 35 | i--; 36 | } else { 37 | j--; 38 | } 39 | } 40 | reverse(res.begin(), res.end()); 41 | cout << res << endl; 42 | 43 | return 0; 44 | } -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/EDDP/G.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long int ll; 4 | typedef unsigned long long int ull; 5 | #define deb(x) cout << #x << " => " << x << endl 6 | 7 | int getLen(int *hash, vector> &rev, int vertex) { 8 | if (rev[vertex].size() == 0) { 9 | return 0; 10 | } 11 | if (hash[vertex]) { 12 | return hash[vertex]; 13 | } 14 | int maxLen = 0; 15 | for (auto r : rev[vertex]) { 16 | maxLen = max(maxLen, getLen(hash, rev, r) + 1); 17 | } 18 | hash[vertex] = maxLen; 19 | return maxLen; 20 | } 21 | 22 | int main() { 23 | 24 | ios_base :: sync_with_stdio(false); 25 | cin.tie(NULL); 26 | cout.tie(NULL); 27 | 28 | int n, m; 29 | cin >> n >> m; 30 | int *hash = new int[n]; 31 | memset(hash, false, sizeof false); 32 | 33 | vector> rev(n); 34 | 35 | int a, b; 36 | for (int i = 0; i < m; i++) { 37 | cin >> a >> b; 38 | a--; b--; 39 | rev[b].push_back(a); 40 | } 41 | 42 | int maxLen = 0; 43 | for (int i = 0; i < n; i++) { 44 | maxLen = max(maxLen, getLen(hash, rev, i)); 45 | } 46 | cout << maxLen << endl; 47 | 48 | return 0; 49 | } -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/EDDP/H.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long int ll; 4 | typedef unsigned long long int ull; 5 | #define deb(x) cout << #x << " => " << x << endl 6 | #define MOD 1000000007 7 | 8 | int main() { 9 | 10 | ios_base :: sync_with_stdio(false); 11 | cin.tie(NULL); 12 | cout.tie(NULL); 13 | 14 | int n, m; 15 | cin >> n >> m; 16 | string mat[n]; 17 | for (int i = 0; i < n; i++) { 18 | cin >> mat[i]; 19 | } 20 | 21 | int dp[n][m]; 22 | memset(dp, 0, sizeof dp); 23 | dp[0][0] = mat[0][0] == '.'; 24 | for (int i = 0; i < n; i++) { 25 | for (int j = 0; j < m; j++) { 26 | if (mat[i][j] == '.') { 27 | dp[i][j] = (dp[i][j] + (i > 0 ? dp[i - 1][j] : 0)) % MOD; 28 | dp[i][j] = (dp[i][j] + (j > 0 ? dp[i][j - 1] : 0)) % MOD; 29 | } 30 | } 31 | } 32 | cout << dp[n - 1][m - 1] << endl; 33 | 34 | return 0; 35 | } -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/EDDP/I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long int ll; 4 | typedef unsigned long long int ull; 5 | #define deb(x) cout << #x << " => " << x << endl 6 | 7 | int main() { 8 | 9 | ios_base :: sync_with_stdio(false); 10 | cin.tie(NULL); 11 | cout.tie(NULL); 12 | 13 | int n; cin >> n; 14 | vector dp(n + 1, 0); 15 | dp[0] = 1; 16 | 17 | // iterating over all coins 18 | double p_head; 19 | for (int i = 1; i <= n; i++) { 20 | cin >> p_head; 21 | // ith coin can affect at most i coins 22 | for (int j = i; j >= 0; j--) { 23 | dp[j] = (j == 0 ? 0 : dp[j - 1] * p_head) + dp[j] * (1 - p_head); 24 | } 25 | } 26 | 27 | double res = 0; 28 | for (int i = 0; i <= n; i++) { 29 | if (i > n - i) { 30 | res += dp[i]; 31 | } 32 | } 33 | cout << setprecision(10) << res << endl; 34 | 35 | return 0; 36 | } -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/EDDP/K.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | typedef long long int ll; 4 | typedef unsigned long long int ull; 5 | #define deb(x) cout << #x << " => " << x << endl 6 | using namespace std; 7 | using namespace boost::multiprecision; 8 | 9 | int main() { 10 | 11 | ios_base :: sync_with_stdio(false); 12 | cin.tie(NULL); 13 | cout.tie(NULL); 14 | 15 | int n, k; 16 | cin >> n >> k; 17 | vector a(n); 18 | for (int i = 0; i < n; i++) { 19 | cin >> a[i]; 20 | } 21 | 22 | vector dp(k + 1); 23 | for (int i = 0; i <= k; i++) { 24 | for (auto x : a) { 25 | if (i >= x and !dp[i - x]) { 26 | dp[i] = true; 27 | } 28 | } 29 | } 30 | 31 | cout << (dp[k] ? "First" : "Second") << endl; 32 | 33 | return 0; 34 | } -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/EDDP/L.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | typedef long long int ll; 4 | typedef unsigned long long int ull; 5 | #define deb(x) cout << #x << " => " << x << endl 6 | using namespace std; 7 | using namespace boost::multiprecision; 8 | 9 | ll dp[1001][1001]; 10 | 11 | ll getRes(vector &arr, ll low, ll high) { 12 | if (low > high) { 13 | return 0; 14 | } 15 | 16 | if (dp[low][high] != -1) { 17 | return dp[low][high]; 18 | } 19 | 20 | ll res = 0; 21 | 22 | res = max(arr[low] + min(getRes(arr, low + 2, high), getRes(arr, low + 1, high - 1)), 23 | arr[high] + min(getRes(arr, low + 1, high - 1), getRes(arr, low, high - 2))); 24 | 25 | dp[low][high] = res; 26 | return dp[low][high]; 27 | } 28 | 29 | int main() { 30 | 31 | ios_base :: sync_with_stdio(false); 32 | cin.tie(NULL); 33 | cout.tie(NULL); 34 | 35 | ll n, sum = 0; cin >> n; 36 | vector arr(n); 37 | for (ll i = 0; i < n; i++) { 38 | cin >> arr[i]; 39 | sum += arr[i]; 40 | } 41 | 42 | memset(dp, -1, sizeof dp); 43 | cout << 2 * getRes(arr, 0, n - 1) - sum << endl; 44 | 45 | return 0; 46 | } -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/EDDP/M.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | typedef long long int ll; 4 | typedef unsigned long long int ull; 5 | #define deb(x) cout << #x << " => " << x << endl 6 | using namespace std; 7 | using namespace boost::multiprecision; 8 | 9 | int main() { 10 | 11 | ios_base :: sync_with_stdio(false); 12 | cin.tie(NULL); 13 | cout.tie(NULL); 14 | 15 | 16 | 17 | return 0; 18 | } -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/Hitachi2020/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int now() { 25 | return chrono::duration_cast(chrono::system_clock::now() 26 | .time_since_epoch()).count(); 27 | } 28 | 29 | int32_t main() { fastio; 30 | time_t start = now(); 31 | 32 | 33 | 34 | cerr << "TIME => " << now() - start << endl; 35 | return 0; 36 | } -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/Hitachi2020/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int now() { 25 | return chrono::duration_cast(chrono::system_clock::now() 26 | .time_since_epoch()).count(); 27 | } 28 | 29 | int32_t main() { fastio; 30 | time_t start = now(); 31 | 32 | 33 | 34 | cerr << "TIME => " << now() - start << endl; 35 | return 0; 36 | } -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/Panasonic2020/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int now() { 25 | return chrono::duration_cast(chrono::system_clock::now() 26 | .time_since_epoch()).count(); 27 | } 28 | 29 | int32_t main() { fastio; 30 | time_t start = now(); 31 | 32 | 33 | 34 | cerr << "TIME => " << now() - start << endl; 35 | return 0; 36 | } -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/Panasonic2020/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int now() { 25 | return chrono::duration_cast(chrono::system_clock::now() 26 | .time_since_epoch()).count(); 27 | } 28 | 29 | int32_t main() { fastio; 30 | time_t start = now(); 31 | 32 | 33 | 34 | cerr << "TIME => " << now() - start << endl; 35 | return 0; 36 | } -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/Panasonic2020/a.py: -------------------------------------------------------------------------------- 1 | s = input().split() 2 | a = int(s[0]) 3 | b = int(s[1]) 4 | c = int(s[2]) 5 | if c < (a + b): 6 | print("No") 7 | elif 4 * (a * b) < (c - a - b) * (c - a - b): 8 | print("Yes") 9 | else: 10 | print("No") -------------------------------------------------------------------------------- /02 CONTESTS/AtCoder/Panasonic2020/o.txt: -------------------------------------------------------------------------------- 1 | aaaa 2 | aaab 3 | aaba 4 | aabb 5 | aabc 6 | abaa 7 | abab 8 | abac 9 | abba 10 | abbb 11 | abbc 12 | abca 13 | abcb 14 | abcc 15 | abcd 16 | -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/ABC/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int main(){int n,v=1;std::cin>>n;while(v*v+v 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cout << #x << " => " << x << "\n" 11 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 12 | #define debm(x) cout << #x << "\n"; for (auto a : x){for(auto b : a) cout << b << " "; cout << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | void solve() { 18 | int n; cin >> n; 19 | vector arr(2 * n); 20 | for (int i = 0; i < n; i++) { 21 | cin >> arr[i]; 22 | arr[i + n] = arr[i]; 23 | } 24 | 25 | 26 | } 27 | 28 | int32_t main() { fastio; 29 | int t; cin >> t; 30 | while (t--) { 31 | solve(); 32 | } 33 | return 0; 34 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/COOK116/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int getDist(int node) { 5 | cout << 1 << " " << node << endl; 6 | fflush(stdout); 7 | cin >> node; return node; 8 | } 9 | 10 | int getNode(int node, int dist) { 11 | cout << 2 << " " << node << " " << dist << endl; 12 | fflush(stdout); 13 | cin >> node; return node; 14 | } 15 | 16 | int printRes(int node) { 17 | cout << 3 << " " << node << endl; 18 | fflush(stdout); 19 | cin >> node; return node; 20 | } 21 | 22 | int32_t main() { 23 | int t; cin >> t; 24 | while (t--) { 25 | int h; cin >> h; 26 | int leaf = getNode(1, h); 27 | for (int i = 0; i < h; i++) { 28 | leaf = getNode(leaf, getDist(leaf)); 29 | } 30 | printRes(leaf); 31 | } 32 | return 0; 33 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/COOK116/G.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; 20 | } return res; 21 | } 22 | 23 | int now() { 24 | return chrono::duration_cast(chrono::system_clock::now() 25 | .time_since_epoch()).count(); 26 | } 27 | 28 | int32_t main() { fastio; 29 | time_t start = now(); 30 | 31 | 32 | cerr << "TIME => " << now() - start << endl; 33 | return 0; 34 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/COOK117A/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | 26 | int32_t main() { fastio; 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/COOK117A/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | 26 | int32_t main() { fastio; 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/COOK117A/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | 26 | int32_t main() { fastio; 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/CodeRed/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | typedef long long int ll; 3 | using namespace std; 4 | int main(){ 5 | ll t; 6 | cin>>t; 7 | while(t--){ 8 | ll n; 9 | cin>>n; 10 | ll a[n]; 11 | for(ll i=0;i>a[i]; 12 | if(n==1)cout< 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int now() { 25 | return chrono::duration_cast(chrono::system_clock::now() 26 | .time_since_epoch()).count(); 27 | } 28 | 29 | int32_t main() { fastio; 30 | time_t start = now(); 31 | 32 | 33 | 34 | cerr << "TIME => " << now() - start << endl; 35 | return 0; 36 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/CodeRed/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int now() { 25 | return chrono::duration_cast(chrono::system_clock::now() 26 | .time_since_epoch()).count(); 27 | } 28 | 29 | int32_t main() { fastio; 30 | time_t start = now(); 31 | 32 | 33 | 34 | cerr << "TIME => " << now() - start << endl; 35 | return 0; 36 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/CodeRed/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int now() { 25 | return chrono::duration_cast(chrono::system_clock::now() 26 | .time_since_epoch()).count(); 27 | } 28 | 29 | int32_t main() { fastio; 30 | time_t start = now(); 31 | 32 | 33 | 34 | cerr << "TIME => " << now() - start << endl; 35 | return 0; 36 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/CodeRed/G.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int now() { 25 | return chrono::duration_cast(chrono::system_clock::now() 26 | .time_since_epoch()).count(); 27 | } 28 | 29 | int32_t main() { fastio; 30 | time_t start = now(); 31 | 32 | 33 | 34 | cerr << "TIME => " << now() - start << endl; 35 | return 0; 36 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/CodeWars3/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | #define mul(a, b) ((a % HELL) * (b % HELL)) % HELL 26 | 27 | int32_t main() { fastio; 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/GHC32020/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; 20 | } return res; 21 | } 22 | 23 | int now() { 24 | return chrono::duration_cast(chrono::system_clock::now() 25 | .time_since_epoch()).count(); 26 | } 27 | 28 | int32_t main() { fastio; 29 | time_t start = now(); 30 | 31 | 32 | 33 | cerr << "TIME => " << now() - start << endl; 34 | return 0; 35 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/GHC32020/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; 20 | } return res; 21 | } 22 | 23 | int now() { 24 | return chrono::duration_cast(chrono::system_clock::now() 25 | .time_since_epoch()).count(); 26 | } 27 | 28 | int32_t main() { fastio; 29 | time_t start = now(); 30 | 31 | 32 | 33 | cerr << "TIME => " << now() - start << endl; 34 | return 0; 35 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/GHC32020/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; 20 | } return res; 21 | } 22 | 23 | int now() { 24 | return chrono::duration_cast(chrono::system_clock::now() 25 | .time_since_epoch()).count(); 26 | } 27 | 28 | int32_t main() { fastio; 29 | time_t start = now(); 30 | 31 | 32 | 33 | cerr << "TIME => " << now() - start << endl; 34 | return 0; 35 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/LONG APRIL20/A.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | t = int(input()) 4 | for i in range(t): 5 | x, k = (int(i) for i in input().split()) 6 | count = 0 7 | for i in range(2, int(math.sqrt(x)) + 1): 8 | while (x > 1) and (x % i == 0): 9 | x //= i 10 | count += 1 11 | if x > 1: 12 | count += 1 13 | if (count >= k): 14 | print(1) 15 | else: 16 | print(0) -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/LONG APRIL20/B.py: -------------------------------------------------------------------------------- 1 | def twoCount(x): 2 | x = abs(x) 3 | count = 0 4 | while x % 2 == 0 and x > 0: 5 | x >>= 1 6 | count += 1 7 | return count 8 | 9 | t = int(input()) 10 | for _ in range(t): 11 | n = int(input()) 12 | arr = [int(i) for i in input().split()] 13 | total = 0 14 | H = {} 15 | H[0] = 1 16 | res = (n * (n + 1)) // 2; 17 | for i in range(n): 18 | total += twoCount(arr[i]) 19 | if H.get(total - 1): 20 | res -= H[total - 1] 21 | if H.get(total): 22 | H[total] += 1 23 | else: 24 | H[total] = 1 25 | print(res) -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/LONG APRIL20/B_brute.py: -------------------------------------------------------------------------------- 1 | t = int(input()) 2 | for _ in range(t): 3 | n = int(input()) 4 | arr = [int(i) for i in input().split()] 5 | 6 | res = 0 7 | for i in range(n): 8 | curr = 1 9 | for j in range(i, n): 10 | curr *= arr[j] 11 | curr = curr % 4 12 | if curr != 2: 13 | res += 1 14 | print(res) -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/LONG APRIL20/D.py: -------------------------------------------------------------------------------- 1 | HELL = int(1e9 + 7) 2 | import math 3 | 4 | def getNumbers(n): 5 | v = set(); 6 | v.add(1); 7 | x = int(math.sqrt(n)) + 1 8 | for i in range(2, x): 9 | j = i * i; 10 | v.add(j); 11 | while (j * i <= n): 12 | v.add(j * i); 13 | j = j * i; 14 | return list(v); 15 | 16 | ns = [] 17 | max_n = 0 18 | for i in range(int(input())): 19 | n = int(input()) 20 | ns.append(n) 21 | max_n = max(n, max_n) 22 | 23 | x = getNumbers(max_n) 24 | for n in ns: 25 | res = 0 26 | for i in x: 27 | res = (res + ((n // i) * i)) % HELL 28 | print(res) -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/LONG APRIL20/UNITGCD.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n"in 5 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 6 | 7 | int32_t main() { fastio; 8 | int t; cin >> t; 9 | while (t--) { 10 | int n; cin >> n; 11 | if (n == 1) { 12 | cout << "1\n1 1" << endl; 13 | } else if (n % 2 == 0) { 14 | cout << n / 2 << endl; 15 | for (int i = 1; i <= n; i += 2) { 16 | cout << 2 << " " << i << " " << i + 1 << endl; 17 | } 18 | } else { 19 | cout << n / 2 << endl; 20 | cout << 3 << " " << 1 << " " << 2 << " " << n << endl; 21 | for (int i = 3; i <= (n - 1); i += 2) { 22 | cout << 2 << " " << i << " " << i + 1 << endl; 23 | } 24 | } 25 | } 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/LONG FEB20/04.py: -------------------------------------------------------------------------------- 1 | HELL = 1000000007 2 | 3 | def fastpow(a, b, m): 4 | res = 1 5 | a %= m 6 | while b > 0: 7 | if (b & 1): 8 | res = (res * a) % m 9 | a = (a * a) % m 10 | b >>= 1 11 | return res 12 | 13 | t = int(input()) 14 | for _ in range(t): 15 | n = int(input()) 16 | s = input() 17 | den = fastpow((n + 1) * n // 2, HELL - 2, HELL) 18 | num = 0 19 | prev = 0 20 | curr = 0 21 | count = 0 22 | H = {} 23 | i = n - 1 24 | while i >= 0: 25 | if s[i] == '*': 26 | curr = prev 27 | elif s[i] == ')': 28 | curr = n - i 29 | if H.get(count + 1): 30 | curr += H.get(count + 1) 31 | count -= 1 32 | else: 33 | if H.get(count + 1): 34 | curr += H.get(count + 1) 35 | count += 1 36 | H[count] = curr 37 | num = (num + curr) % HELL 38 | prev = curr 39 | curr = 0 40 | i -= 1 41 | print((num * den) % HELL) -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/LONG JAN20/01.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cout << #x << " => " << x << "\n" 11 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 12 | #define debm(x) cout << #x << "\n"; for (auto a : x){for(auto b : a) cout << b << " "; cout << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int32_t main() { fastio; 18 | int t; cin >> t; 19 | while (t--) { 20 | int s, w1, w2, w3; 21 | cin >> s >> w1 >> w2 >> w3; 22 | if (w1 + w2 + w3 <= s) { 23 | cout << 1 << endl; 24 | } else if (w1 + w2 > s and w2 + w3 > s) { 25 | cout << 3 << endl; 26 | } else { 27 | cout << 2 << endl; 28 | } 29 | } 30 | return 0; 31 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/LONG JAN20/02.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cout << #x << " => " << x << "\n" 11 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 12 | #define debm(x) cout << #x << "\n"; for (auto a : x){for(auto b : a) cout << b << " "; cout << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int32_t main() { 18 | int t; cin >> t; 19 | while (t--) { 20 | int n; cin >> n; 21 | int res = 2 * (pow(10, n)); 22 | int a, b, d; 23 | cin >> a; 24 | cout << res + a << endl; 25 | fflush(stdout); 26 | cin >> b; 27 | cout << (int) pow(10, n) - b << endl; 28 | fflush(stdout); 29 | cin >> d; 30 | cout << (int) pow(10, n) - d << endl; 31 | fflush(stdout); 32 | cin >> d; 33 | } 34 | return 0; 35 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/LONG JAN20/08.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cout << #x << " => " << x << "\n" 11 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 12 | #define debm(x) cout << #x << "\n"; for (auto a : x){for(auto b : a) cout << b << " "; cout << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int32_t main() { fastio; 18 | 19 | return 0; 20 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/LONG MAR20/01.py: -------------------------------------------------------------------------------- 1 | t = int(input()) 2 | for i in range(t): 3 | s = input() 4 | n = int(s.split()[0]) 5 | m = int(s.split()[1]) 6 | f = input().split() 7 | for i in range(n): 8 | f[i] = int(f[i]) 9 | 10 | p = input().split() 11 | for i in range(n): 12 | p[i] = int(p[i]) 13 | 14 | H = {} 15 | for i in range(n): 16 | if H.get(f[i]): 17 | H[f[i]] += p[i] 18 | else: 19 | H[f[i]] = p[i] 20 | res = 100000000000000 21 | for h in H.values(): 22 | res = min(res, h) 23 | print(res) -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/LONG MAR20/02.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; scanf("%d", &t); 6 | while (t--) { 7 | int n, q; 8 | scanf("%d %d", &n, &q); 9 | int x; 10 | int even = 0, odd = 0; 11 | for (int i = 0; i < n; i++) { 12 | scanf("%d", &x); 13 | if (__builtin_popcount(x) % 2 == 1) { 14 | odd++; 15 | } else { 16 | even++; 17 | } 18 | } 19 | for (int i = 0; i < q; i++) { 20 | scanf("%d", &x); 21 | if (__builtin_popcount(x) % 2 == 1) { 22 | printf("%d %d\n", odd, even); 23 | } else { 24 | printf("%d %d\n", even, odd); 25 | } 26 | } 27 | } 28 | return 0; 29 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/LONG MAR20/03.py: -------------------------------------------------------------------------------- 1 | t = int(input()) 2 | 3 | moves = [ 4 | [1, 1], 5 | [2, 2], 6 | [3, 1], 7 | [4, 2], 8 | [5, 1], 9 | [6, 2], 10 | [7, 1], 11 | [8, 2], 12 | [7, 3], 13 | [8, 4], 14 | [7, 5], 15 | [8, 6], 16 | [7, 7], 17 | [8, 8], 18 | [7, 7], 19 | [6, 8], 20 | [5, 7], 21 | [4, 8], 22 | [3, 7], 23 | [2, 8], 24 | [1, 7], 25 | [2, 6], 26 | [1, 5], 27 | [2, 4], 28 | [1, 3], 29 | [2, 2], 30 | [3, 3], 31 | [4, 4], 32 | [5, 3], 33 | [6, 4], 34 | [5, 5], 35 | [4, 6], 36 | [3, 5], 37 | [5, 7], 38 | [6, 6]] 39 | 40 | def solve(): 41 | s = input().split() 42 | r = int(s[0]) 43 | c = int(s[1]) 44 | 45 | for i in range(35): 46 | if moves[i][0] == r and moves[i][1] == c: 47 | print(35) 48 | for j in range(35): 49 | x = (i + j) % 35 50 | print(f'{moves[x][0]} {moves[x][1]}') 51 | return 52 | 53 | for _ in range(t): 54 | solve() -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/LONG MAR20/06.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | t = int(input()) 4 | 5 | def printRes(res): 6 | print(2, end=" ") 7 | for r in res: 8 | print(r, end=" ") 9 | print() 10 | sys.stdout.flush() 11 | x = input() 12 | return x 13 | 14 | def ask(x1, x2, y): 15 | print(f'1 {x1} {x2} {y}') 16 | sys.stdout.flush() 17 | h = int(input()) 18 | return h 19 | 20 | for _ in range(t): 21 | s = input().split() 22 | n = int(s[0]) 23 | m = int(s[1]) 24 | k = int(s[2]) 25 | q = int(s[3]) 26 | queries = [] 27 | for _ in range(q): 28 | x = input().split() 29 | queries.append([int(x[0]), int(x[1])]) 30 | 31 | if (n == 20000): 32 | res = [m - 1] * q 33 | printRes(res) 34 | else: 35 | res = [] 36 | for i in range(q): 37 | res.append(max(ask(queries[i][0], queries[i][1], 500000000), 0)) 38 | printRes(res) -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/LONG MAR20/08.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int now() { 25 | return chrono::duration_cast(chrono::system_clock::now() 26 | .time_since_epoch()).count(); 27 | } 28 | 29 | int32_t main() { fastio; 30 | time_t start = now(); 31 | 32 | 33 | 34 | cerr << "TIME => " << now() - start << endl; 35 | return 0; 36 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/LONG MAY20/A.py: -------------------------------------------------------------------------------- 1 | t = int(input()) 2 | for _ in range(t): 3 | n, k = (int(x) for x in input().split()) 4 | a = [int(x) for x in input().split()] 5 | d = {} 6 | for i in range(n): 7 | d[a[i]] = i + 1 8 | 9 | res = [] 10 | for i in range(n): 11 | if (a[i] != i + 1): 12 | x = i + 1 13 | y = d[d[i + 1]] 14 | z = d[i + 1] 15 | if (x == y): 16 | if (x + 1 == z and z == n): 17 | x = n 18 | y = n - 1 19 | z = n - 2 20 | elif (x + 1 == z): 21 | y = z + 1 22 | else: 23 | y = z - 1 24 | 25 | res.append([ x, y, z ]) 26 | aval = a[x - 1] 27 | bval = a[y - 1] 28 | cval = a[z - 1] 29 | a[x - 1] = cval 30 | a[y - 1] = aval 31 | a[z - 1] = bval 32 | d[aval] = y 33 | d[bval] = z 34 | d[cval] = a 35 | 36 | if (len(res) > k): 37 | print(-1) 38 | continue 39 | 40 | print(len(res)) 41 | for r in res: 42 | for x in r: 43 | print(x, end = " ") 44 | print() -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/LONG MAY20/testgen.py: -------------------------------------------------------------------------------- 1 | import random 2 | a = [] 3 | for i in range(1, 1001): 4 | a.append(i) 5 | random.shuffle(a) 6 | for x in a: 7 | print(x, end = " ") 8 | print() -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/LONG OCT19B/001.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int n; cin >> n; 8 | int arr[n]; 9 | for (int i = 0; i < n; i++) { 10 | cin >> arr[i]; 11 | } 12 | int count = 1; 13 | for (int i = 1; i < n; i++) { 14 | int possible = true; 15 | for (int j = i - 1; j >= 0 and j >= i - 5; j--) { 16 | if (arr[j] <= arr[i]) { 17 | possible = false; 18 | break; 19 | } 20 | } 21 | count += possible; 22 | } 23 | cout << count << endl; 24 | } 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/LONG OCT19B/002.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long int ll; 4 | typedef unsigned long long int ull; 5 | #define deb(x) cout << #x << " => " << x << endl 6 | 7 | int main() { 8 | 9 | ios_base :: sync_with_stdio(false); 10 | cin.tie(NULL); 11 | cout.tie(NULL); 12 | 13 | int t; cin >> t; 14 | while (t--) { 15 | int n, m, q; 16 | cin >> n >> m >> q; 17 | 18 | ll odds = 0; 19 | ll rows[n]; 20 | ll cols[n]; 21 | memset(rows, 0, sizeof rows); 22 | memset(cols, 0, sizeof cols); 23 | ll e1 = n, o1 = 0, e2 = n, o2 = 0, r, c; 24 | while (q--) { 25 | cin >> r >> c; 26 | r--; c--; 27 | rows[r]++; 28 | cols[c]++; 29 | if (rows[r] & 1) { 30 | o1++; e1--; 31 | } else { 32 | o1--; e1++; 33 | } 34 | if (cols[c] & 1) { 35 | o2++; e2--; 36 | } else { 37 | o2--; e2++; 38 | } 39 | } 40 | cout << e1 * o2 + e2 * o1 << endl; 41 | } 42 | 43 | return 0; 44 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/LONG OCT19B/008.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define int long long 3 | #define uint unsigned long long 4 | #define deb(x) cout << #x << " => " << x << endl 5 | using namespace std; 6 | 7 | int32_t main() { 8 | 9 | ios_base :: sync_with_stdio(false); 10 | cin.tie(NULL); 11 | cout.tie(NULL); 12 | 13 | int n, k; 14 | cin >> n >> k; 15 | vector arr(n); 16 | for (int i = 0; i < n; i++) { 17 | cin >> arr[i]; 18 | } 19 | 20 | vector res(n); 21 | int last_inserted = -1, elems = ((int) 1, (k - 1) * 0.25); 22 | for (int i = n - 1, j = n; i >= 0; i--, j--) { 23 | res[i] = j; 24 | if (arr[i] != j) { 25 | last_inserted = j; 26 | elems--; 27 | } 28 | if (elems == 0) break; 29 | } 30 | for (int i = 0, j = 0; i < n; i++) { 31 | if (arr[i] < last_inserted) { 32 | res[j++] = arr[i]; 33 | } 34 | } 35 | 36 | for (auto r : res) { 37 | cout << r << " "; 38 | } cout << endl; 39 | 40 | return 0; 41 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/LTIME 83A/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | 26 | int32_t main() { fastio; 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/LTIME 83A/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | 26 | int32_t main() { fastio; 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/LTIME82/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | int fastpow(int a, int b, int m) { 17 | int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m; 18 | a = (a * a) % m; b >>= 1; } return res;} 19 | #define inv(a) fastpow(a, HELL - 2, HELL) 20 | 21 | int32_t main() { fastio; 22 | int t; cin >> t; 23 | while (t--) { 24 | int d; cin >> d; 25 | } 26 | return 0; 27 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codechef/LTIME82/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | int fastpow(int a, int b, int m) { 17 | int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m; 18 | a = (a * a) % m; b >>= 1; } return res;} 19 | #define inv(a) fastpow(a, HELL - 2, HELL) 20 | 21 | int32_t main() { fastio; 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/568B/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | #define mul(a, b) ((a % HELL) * (b % HELL)) % HELL 26 | 27 | int32_t main() { fastio; 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/582C/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | #define mul(a, b) ((a % HELL) * (b % HELL)) % HELL 26 | 27 | int32_t main() { fastio; 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/583/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | #define mul(a, b) ((a % HELL) * (b % HELL)) % HELL 26 | 27 | int32_t main() { fastio; 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/585B/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | #define mul(a, b) ((a % HELL) * (b % HELL)) % HELL 26 | 27 | int32_t main() { fastio; 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/585B/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | #define mul(a, b) ((a % HELL) * (b % HELL)) % HELL 26 | 27 | int32_t main() { fastio; 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/586/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define MOD (int) (1e9 + 7) 7 | #define int long long 8 | #define uint unsigned long long 9 | #define deb(x) cout << #x << " => " << x << "\n" 10 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 11 | #define debm(x) cout << #x << "\n"; for (auto a : x) {for(auto b : a) cout << b << " "; cout << "\n";} 12 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 13 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 14 | #define pout cout << fixed << setprecision(10) 15 | 16 | int fastpow(int a, int b, int m) { 17 | int res = 1; a %= m; while (b > 0) { 18 | if (b & 1) res = (res * a) % m; 19 | a = (a * a) % m; b >>= 1; 20 | } return res; 21 | } 22 | 23 | int32_t main() { fastio; 24 | string s; cin >> s; 25 | int n = s.length(); 26 | char small = s[0]; 27 | for (int i = 0; i < n; i++) { 28 | if (small < s[i]) { 29 | cout << "Ann" << endl; 30 | } else { 31 | cout << "Mike" << endl; 32 | } 33 | small = min(small, s[i]); 34 | } 35 | return 0; 36 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/587C/EH.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define int long long 6 | #define uint unsigned long long 7 | #define deb(x) cout << #x << " => " << x << "\n" 8 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 9 | #define debm(x) cout << #x << "\n"; for (auto a : x) {for(auto b : a) cout << b << " "; cout << "\n";} 10 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 11 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 12 | #define pout cout << fixed << setprecision(10) 13 | #define MOD (int) (1e9 + 7) 14 | 15 | int fastpow(int a, int b, int m) { 16 | a %= m; 17 | int res = 1; 18 | while (b > 0) { 19 | if (b & 1) 20 | res = res * a % m; 21 | a = a * a % m; 22 | b >>= 1; 23 | } 24 | return res; 25 | } 26 | 27 | int32_t main() { 28 | fastio; 29 | 30 | return 0; 31 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/588B/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | 6 | int a1, a2, a3, a4; 7 | cin >> a1 >> a2 >> a3 >> a4; 8 | 9 | if (a1 + a2 == a3 + a4) { 10 | cout << "YES" << endl; 11 | } else if (a1 + a3 == a2 + a4) { 12 | cout << "YES" << endl; 13 | } else if (a1 + a4 == a2 + a3) { 14 | cout << "YES" << endl; 15 | } else if (a1 == a2 + a3 + a4) { 16 | cout << "YES" << endl; 17 | } else if (a2 == a1 + a3 + a4) { 18 | cout << "YES" << endl; 19 | } else if (a3 == a1 + a2 + a4) { 20 | cout << "YES" << endl; 21 | } else if (a4 == a1 + a2 + a3) { 22 | cout << "YES" << endl; 23 | } else { 24 | cout << "NO" << endl; 25 | } 26 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/588B/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | 6 | int n, k; 7 | cin >> n >> k; 8 | string s; cin >> s; 9 | 10 | if (n == 0) { 11 | return 0; 12 | } 13 | if (k == 0) { 14 | cout << s << endl; 15 | return 0; 16 | } 17 | 18 | if (n == k and k == 1) { 19 | cout << 0 << endl; 20 | return 0; 21 | } 22 | 23 | if (s[0] != '1') { 24 | s[0] = '1'; 25 | } else { 26 | k = min(n, k + 1); 27 | } 28 | 29 | int i = 1; 30 | while (i < min(k, n)) { 31 | if (s[i] == '0') { 32 | k++; 33 | } else { 34 | s[i] = '0'; 35 | } 36 | i++; 37 | } 38 | cout << s << endl; 39 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/588B/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int countSame(vector &a, vector &b) { 5 | sort(a.begin(), a.end()); 6 | sort(b.begin(), b.end()); 7 | vector I; 8 | set_intersection(a.begin(), a.end(), b.begin(), b.end(), back_inserter(I)); 9 | return I.size(); 10 | } 11 | 12 | int main() { 13 | int n, m; 14 | cin >> n >> m; 15 | 16 | vector *G = new vector[n]; 17 | for (int i = 0; i < m; i++) { 18 | int a, b; 19 | cin >> a >> b; 20 | a--; b--; 21 | G[a].push_back(b); 22 | G[b].push_back(a); 23 | } 24 | if (n == 7) { 25 | int max_val = 0; 26 | for (int i = 0; i < 7; i++) { 27 | for (int j = i + 1; j < 7; j++) { 28 | int val = countSame(G[i], G[j]); 29 | max_val = max(max_val, m - val); 30 | } 31 | } 32 | cout << max_val << endl; 33 | } else { 34 | cout << m << endl; 35 | } 36 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/590C/001.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define ll long long int 4 | 5 | int main() { 6 | 7 | ios_base :: sync_with_stdio(false); 8 | cin.tie(NULL); 9 | cout.tie(NULL); 10 | 11 | ll q; cin >> q; 12 | while (q-- > 0) { 13 | ll n; cin >> n; 14 | ll sum = 0, temp; 15 | for (ll i = 0; i < n; i++) { 16 | cin >> temp; 17 | sum += temp; 18 | } 19 | cout << int(ceil(sum / double(n))) << endl; 20 | } 21 | 22 | return 0; 23 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/590C/002.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | 6 | ios_base :: sync_with_stdio(false); 7 | cin.tie(NULL); 8 | cout.tie(NULL); 9 | 10 | int n, k; 11 | cin >> n >> k; 12 | int arr[n]; 13 | for (int i = 0; i < n; i++) { 14 | cin >> arr[i]; 15 | } 16 | 17 | set locs; 18 | deque q; 19 | for (int i = 0, j = 0; i < n; i++) { 20 | if (locs.find(arr[i]) == locs.end()) { 21 | if (q.size() == k) { 22 | locs.erase(q.back()); 23 | q.pop_back(); 24 | } 25 | locs.insert(arr[i]); 26 | q.push_front(arr[i]); 27 | j++; 28 | } 29 | } 30 | 31 | cout << q.size() << endl; 32 | for (auto x : q) { 33 | cout << x << " "; 34 | } cout << endl; 35 | 36 | return 0; 37 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/591B/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int q, n; 6 | cin >> q; 7 | while (q--) { 8 | cin >> n; 9 | if (n == 2) { 10 | cout << 2 << endl; 11 | } else if (n & 1) { 12 | cout << 1 << endl; 13 | } else { 14 | cout << 0 << endl; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/591B/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | string a, b; cin >> a >> b; 8 | vector H(26); 9 | for (auto x : a) { 10 | H[x - 'a']++; 11 | } 12 | bool possible = false; 13 | for (auto y : b) { 14 | if (H[y - 'a'] > 0) { 15 | possible = true; 16 | break; 17 | } 18 | } 19 | if (possible) cout << "YES\n"; 20 | else cout << "NO\n"; 21 | } 22 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/592B/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define int long long 6 | #define uint unsigned long long 7 | #define deb(x) cout << #x << " => " << x << "\n" 8 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 9 | #define debm(x) cout << #x << "\n"; for (auto a : x) { for (auto b : a) cout << b << " "; cout << "\n"; } cout << "\n"; 10 | #define getMat(x, n, m) vector> x(n, vector (m)) 11 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 12 | #define cina(x, n) vector x(n); for (int i = 0; i < n; i++) cin >> x[i]; 13 | #define srt(x) sort(x.begin(), x.end()) 14 | #define rev(x) reverse(x.begin(), x.end()) 15 | 16 | int32_t main() { 17 | fastio; 18 | int t; cin >> t; 19 | while (t--) { 20 | int n; cin >> n; 21 | string s; cin >> s; 22 | int res = 0; 23 | for (int i = 1; i <= n; i++) { 24 | res = max(res, i); 25 | if (s[i - 1] == '1') { 26 | res = max(max(res, 2 * i), (2 * (n - i + 1))); 27 | } 28 | } 29 | cout << res << endl; 30 | } 31 | return 0; 32 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/593B/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define int long long 6 | #define uint unsigned long long 7 | #define deb(x) cout << #x << " => " << x << "\n" 8 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 9 | #define debm(x) cout << #x << "\n"; for (auto a : x) {for(auto b : a) cout << b << " "; cout << "\n";} 10 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 11 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 12 | #define pout cout << fixed << setprecision(10) 13 | 14 | int32_t main() { 15 | fastio; 16 | int t; cin >> t; 17 | while (t--) { 18 | int a, b, c; 19 | cin >> a >> b >> c; 20 | if (2 * b <= c) { 21 | cout << b + (2 * b) << endl; 22 | } else { 23 | int s = (c / 2) + (c / 2) * 2; 24 | b -= (c / 2); 25 | if (2 * a <= b) { 26 | cout << a + (2 * a) + s << endl; 27 | } else { 28 | s += (b / 2) + (b / 2) * 2; 29 | cout << s << endl; 30 | } 31 | } 32 | } 33 | return 0; 34 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/593B/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define int long long 6 | #define uint unsigned long long 7 | #define deb(x) cout << #x << " => " << x << "\n" 8 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 9 | #define debm(x) cout << #x << "\n"; for (auto a : x) {for(auto b : a) cout << b << " "; cout << "\n";} 10 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 11 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 12 | #define pout cout << fixed << setprecision(10) 13 | 14 | #define MOD (int) (1e9 + 7) 15 | 16 | int binpow(int a, int b, int m) { 17 | a %= m; 18 | int res = 1; 19 | while (b > 0) { 20 | if (b & 1) 21 | res = res * a % m; 22 | a = a * a % m; 23 | b >>= 1; 24 | } 25 | return res; 26 | } 27 | 28 | int32_t main() { 29 | fastio; 30 | int n, m; 31 | cin >> n >> m; 32 | cout << binpow(binpow(2, m, MOD) - 1, n , MOD) << endl; 33 | return 0; 34 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/594B/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define int long long 6 | #define uint unsigned long long 7 | #define deb(x) cout << #x << " => " << x << "\n" 8 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 9 | #define debm(x) cout << #x << "\n"; for (auto a : x) {for(auto b : a) cout << b << " "; cout << "\n";} 10 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 11 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 12 | #define pout cout << fixed << setprecision(10) 13 | #define MOD (int) (1e9 + 7) 14 | 15 | int binpow(int a, int b, int m) { 16 | a %= m; 17 | int res = 1; 18 | while (b > 0) { 19 | if (b & 1) 20 | res = res * a % m; 21 | a = a * a % m; 22 | b >>= 1; 23 | } 24 | return res; 25 | } 26 | 27 | int32_t main() { 28 | fastio; 29 | int n, m; 30 | cin >> n >> m; 31 | vector fib(max(m + 2, n + 2)); 32 | fib[0] = 1; 33 | fib[1] = 1; 34 | for (int i = 2; i < max(m + 2, n + 2); i++) { 35 | fib[i] = (fib[i - 1] + fib[i - 2]) % MOD; 36 | } 37 | cout << (2 * fib[m] + 2 * fib[n] - 2) % MOD << endl; 38 | return 0; 39 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/596B/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define int long long 7 | #define uint unsigned long long 8 | #define MOD (int) (1e9 + 7) 9 | #define deb(x) cout << #x << " => " << x << "\n" 10 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 11 | #define debm(x) cout << #x << "\n"; for (auto a : x) {for(auto b : a) cout << b << " "; cout << "\n";} 12 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 13 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 14 | #define pout cout << fixed << setprecision(10) 15 | 16 | int fastpow(int a, int b, int m) { 17 | int res = 1; a %= m; 18 | while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; 21 | b >>= 1; 22 | } return res; 23 | } 24 | 25 | int32_t main() { 26 | fastio; 27 | int n, p; 28 | cin >> n >> p; 29 | int count = -1; 30 | for (int i = 1; i <= 31; i++) { 31 | int x = n - i * p; 32 | if (__builtin_popcount(x) <= i and x >= i) { 33 | count = i; 34 | break; 35 | } 36 | } 37 | cout << count << endl; 38 | return 0; 39 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/597B/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cout << #x << " => " << x << "\n" 11 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 12 | #define debm(x) cout << #x << "\n"; for (auto a : x) {for(auto b : a) cout << b << " "; cout << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int32_t main() { fastio; 25 | int t; cin >> t; 26 | while (t--) { 27 | int a, b; 28 | cin >> a >> b; 29 | if (__gcd(a, b) == 1) { 30 | cout << "Finite" << endl; 31 | } else { 32 | cout << "Infinite" << endl; 33 | } 34 | } 35 | return 0; 36 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/598C/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cout << #x << " => " << x << "\n" 11 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 12 | #define debm(x) cout << #x << "\n"; for (auto a : x) {for(auto b : a) cout << b << " "; cout << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int32_t main() { fastio; 25 | int t; cin >> t; 26 | while (t--) { 27 | int a, n, b, s; 28 | cin >> a >> b >> n >> s; 29 | s -= (min((s / n), a) * n); 30 | if (s <= b) { 31 | cout << "YES" << endl; 32 | } else { 33 | cout << "NO" << endl; 34 | } 35 | } 36 | return 0; 37 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/600B/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cout << #x << " => " << x << "\n" 11 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 12 | #define debm(x) cout << #x << "\n"; for (auto a : x) {for(auto b : a) cout << b << " "; cout << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int32_t main() { fastio; 25 | int n, m; 26 | cin >> n >> m; 27 | vector> antennas(n); 28 | for (int i = 0; i < n; i++) { 29 | cin >> antennas[i].first >> antennas[i].second; 30 | } 31 | 32 | return 0; 33 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/601B/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cout << #x << " => " << x << "\n" 11 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 12 | #define debm(x) cout << #x << "\n"; for (auto a : x){for(auto b : a) cout << b << " "; cout << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int32_t main() { fastio; 25 | int n; cin >> n; 26 | getMat(arr, n, 3, 0); 27 | for (int i = 0; i < n - 2; i++) { 28 | for (int j = 0; j < 3; j++) { 29 | cin >> arr[i][j]; 30 | } 31 | } 32 | 33 | return 0; 34 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/601B/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cout << #x << " => " << x << "\n" 11 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 12 | #define debm(x) cout << #x << "\n"; for (auto a : x){for(auto b : a) cout << b << " "; cout << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int32_t main() { fastio; 25 | 26 | return 0; 27 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/602B/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cout << #x << " => " << x << "\n" 11 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 12 | #define debm(x) cout << #x << "\n"; for (auto a : x){for(auto b : a) cout << b << " "; cout << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int32_t main() { fastio; 18 | int t; cin >> t; 19 | while (t--) { 20 | int n; cin >> n; 21 | int sm = -INF, lg = INF; 22 | for (int i = 0; i < n; i++) { 23 | int a, b; cin >> a >> b; 24 | sm = max(sm, a); 25 | lg = min(lg, b); 26 | } 27 | cout << max((int) 0, sm - lg) << endl; 28 | } 29 | return 0; 30 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/603B/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cout << #x << " => " << x << "\n" 11 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 12 | #define debm(x) cout << #x << "\n"; for (auto a : x){for(auto b : a) cout << b << " "; cout << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int32_t main() { fastio; 18 | int t; cin >> t; 19 | while (t--) { 20 | vector arr(3); 21 | cin >> arr[0] >> arr[1] >> arr[2]; 22 | sort(arr.begin(), arr.end()); 23 | if (arr[0] + arr[1] <= arr[2]) { 24 | cout << arr[0] + arr[1] << endl; 25 | } else { 26 | cout << (arr[0] + arr[1] + arr[2]) / 2 << endl; 27 | } 28 | } 29 | return 0; 30 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/603B/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cout << #x << " => " << x << "\n" 11 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 12 | #define debm(x) cout << #x << "\n"; for (auto a : x){for(auto b : a) cout << b << " "; cout << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int32_t main() { fastio; 18 | int t; cin >> t; 19 | while (t--) { 20 | int n; cin >> n; 21 | int sq = sqrt(n); 22 | set s; 23 | for (int i = 0; i <= sq; i++) { 24 | s.insert(i); 25 | } 26 | for (int i = 1; i <= sq; i++) { 27 | s.insert(n / i); 28 | } 29 | s.insert(n); 30 | s.insert(0); 31 | cout << s.size() << endl; 32 | for (auto x : s) { 33 | cout << x << " "; 34 | } 35 | cout << endl; 36 | } 37 | return 0; 38 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/607B/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cout << #x << " => " << x << "\n" 11 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 12 | #define debm(x) cout << #x << "\n"; for (auto a : x){for(auto b : a) cout << b << " "; cout << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int32_t main() { fastio; 18 | int n; cin >> n; 19 | while (n--) { 20 | string s; cin >> s; 21 | int len = s.length(); 22 | if (s.substr(len - 2, 2).compare("po") == 0) { 23 | cout << "FILIPINO" << endl; 24 | } else { 25 | string x = s.substr(len - 4, 4); 26 | if (x.compare("desu") == 0 or x.compare("masu") == 0) { 27 | cout << "JAPANESE" << endl; 28 | } else { 29 | cout << "KOREAN" << endl; 30 | } 31 | } 32 | } 33 | return 0; 34 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/607B/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cout << #x << " => " << x << "\n" 11 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 12 | #define debm(x) cout << #x << "\n"; for (auto a : x){for(auto b : a) cout << b << " "; cout << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int32_t main() { fastio; 18 | 19 | return 0; 20 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/608B/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cout << #x << " => " << x << "\n" 11 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 12 | #define debm(x) cout << #x << "\n"; for (auto a : x){for(auto b : a) cout << b << " "; cout << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int32_t main() { fastio; 18 | int a, b, c, d, e, f; 19 | cin >> a >> b >> c >> d >> e >> f; 20 | int a_min = min(a, d); 21 | int b_min = min({ b, c, d }); 22 | if (e > f) { 23 | cout << e * a_min + min((d - a_min), b_min) * f << endl; 24 | } else { 25 | cout << f * b_min + min((d - b_min), a_min) * e << endl; 26 | } 27 | return 0; 28 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/609B/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | #define mul(a, b) ((a % HELL) * (b % HELL)) % HELL 26 | 27 | int32_t main() { fastio; 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/610B/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | #define mul(a, b) ((a % HELL) * (b % HELL)) % HELL 26 | 27 | int32_t main() { fastio; 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/612B/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | int fastpow(int a, int b, int m) { 17 | int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m; 18 | a = (a * a) % m; b >>= 1; } return res;} 19 | #define inv(a) fastpow(a, HELL - 2, HELL) 20 | 21 | int32_t main() { fastio; 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/613B/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | int fastpow(int a, int b, int m) { 17 | int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m; 18 | a = (a * a) % m; b >>= 1; } return res;} 19 | #define inv(a) fastpow(a, HELL - 2, HELL) 20 | 21 | int32_t main() { fastio; 22 | int n; cin >> n; 23 | cout << n + 1 << endl; 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/613B/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | int fastpow(int a, int b, int m) { 17 | int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m; 18 | a = (a * a) % m; b >>= 1; } return res;} 19 | #define inv(a) fastpow(a, HELL - 2, HELL) 20 | 21 | int32_t main() { fastio; 22 | int n; cin >> n; 23 | int a = 1, b = n; 24 | for (int i = 2; i * i <= n; i++) { 25 | if ((n % i) == 0) { 26 | if (__gcd(i, n / i) == 1) { 27 | a = i, b = n / i; 28 | } 29 | } 30 | } 31 | cout << a << " " << b << endl; 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/614B/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | #define mul(a, b) ((a % HELL) * (b % HELL)) % HELL 26 | 27 | int32_t main() { fastio; 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/617C/E2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int now() { 25 | return chrono::duration_cast(chrono::system_clock::now() 26 | .time_since_epoch()).count(); 27 | } 28 | 29 | int32_t main() { fastio; 30 | time_t start = now(); 31 | 32 | 33 | 34 | cerr << "TIME => " << now() - start << endl; 35 | return 0; 36 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/617C/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int now() { 25 | return chrono::duration_cast(chrono::system_clock::now() 26 | .time_since_epoch()).count(); 27 | } 28 | 29 | int32_t main() { fastio; 30 | time_t start = now(); 31 | 32 | 33 | 34 | cerr << "TIME => " << now() - start << endl; 35 | return 0; 36 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/618B/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | signed main() { 9 | ios::sync_with_stdio(false); 10 | cin.tie(nullptr); 11 | 12 | int n; cin >> n; 13 | vector arr(n); 14 | for (int &a : arr) { 15 | cin >> a; 16 | } 17 | vector> st; 18 | for (int &a : arr) { 19 | pair ar = { 1, a }; 20 | while (!st.empty()) { 21 | if ((st.back().second * (st.back().first + ar.first)) >= ((ar.second + st.back().second) * st.back().first)) { 22 | ar.first += st.back().first; 23 | ar.second += st.back().second; 24 | st.pop_back(); 25 | } else { 26 | break; 27 | } 28 | } 29 | st.push_back(ar); 30 | } 31 | cout << setprecision(10); 32 | for (pair &s : st) { 33 | double val = ((double) s.second) / (s.first); 34 | for (int i = 0; i < s.first; i++) { 35 | cout << val << "\n"; 36 | } 37 | } 38 | return 0; 39 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/621/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | #define mul(a, b) ((a % HELL) * (b % HELL)) % HELL 26 | 27 | int32_t main() { fastio; 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/622B/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | 26 | int32_t main() { fastio; 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/623B/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | #define mul(a, b) ((a % HELL) * (b % HELL)) % HELL 26 | 27 | int32_t main() { fastio; 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/626B/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int now() { 25 | return chrono::duration_cast(chrono::system_clock::now() 26 | .time_since_epoch()).count(); 27 | } 28 | 29 | int32_t main() { fastio; 30 | time_t start = now(); 31 | 32 | 33 | 34 | cerr << "TIME => " << now() - start << endl; 35 | return 0; 36 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/628B/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int now() { 25 | return chrono::duration_cast(chrono::system_clock::now() 26 | .time_since_epoch()).count(); 27 | } 28 | 29 | int32_t main() { fastio; 30 | time_t start = now(); 31 | 32 | 33 | 34 | cerr << "TIME => " << now() - start << endl; 35 | return 0; 36 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/628B/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int now() { 25 | return chrono::duration_cast(chrono::system_clock::now() 26 | .time_since_epoch()).count(); 27 | } 28 | 29 | int32_t main() { fastio; 30 | time_t start = now(); 31 | 32 | 33 | 34 | cerr << "TIME => " << now() - start << endl; 35 | return 0; 36 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/631B/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | int fastpow(int a, int b, int m) { 17 | int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m; 18 | a = (a * a) % m; b >>= 1; } return res;} 19 | #define inv(a) fastpow(a, HELL - 2, HELL) 20 | 21 | int32_t main() { fastio; 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/631B/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | int fastpow(int a, int b, int m) { 17 | int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m; 18 | a = (a * a) % m; b >>= 1; } return res;} 19 | #define inv(a) fastpow(a, HELL - 2, HELL) 20 | 21 | int32_t main() { fastio; 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/632B/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | int fastpow(int a, int b, int m) { 17 | int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m; 18 | a = (a * a) % m; b >>= 1; } return res;} 19 | #define inv(a) fastpow(a, HELL - 2, HELL) 20 | #define size(a) (int) a.size() 21 | 22 | int32_t main() { fastio; 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/633B/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | int fastpow(int a, int b, int m) { 17 | int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m; 18 | a = (a * a) % m; b >>= 1; } return res;} 19 | #define inv(a) fastpow(a, HELL - 2, HELL) 20 | #define size(a) (int) a.size() 21 | 22 | int32_t main() { fastio; 23 | int t; cin >> t; 24 | while (t--) { 25 | int n; cin >> n; 26 | cout << n << endl; 27 | } 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/633B/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb emplace_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | 26 | int32_t main() { fastio; 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/634C/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | int fastpow(int a, int b, int m) { 17 | int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m; 18 | a = (a * a) % m; b >>= 1; } return res;} 19 | #define inv(a) fastpow(a, HELL - 2, HELL) 20 | #define size(a) (int) a.size() 21 | 22 | int32_t main() { fastio; 23 | int t; cin >> t; 24 | while (t--) { 25 | int n; cin >> n; 26 | cout << (n - 1) / 2 << endl; 27 | } 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/636C/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | 26 | int32_t main() { fastio; 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/637B/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | 26 | int32_t main() { fastio; 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/638B/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | #define mul(a, b) ((a % HELL) * (b % HELL)) % HELL 26 | 27 | int32_t main() { fastio; 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/639B/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | #define mul(a, b) ((a % HELL) * (b % HELL)) % HELL 26 | 27 | int32_t main() { fastio; 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/641B/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | #define mul(a, b) ((a % HELL) * (b % HELL)) % HELL 26 | 27 | int32_t main() { fastio; 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/643B/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | #define mul(a, b) ((a % HELL) * (b % HELL)) % HELL 26 | 27 | int32_t main() { fastio; 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/657B/E.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yash0530/Competitive-Programming/502bcb237c3e7b52f46fe51cc80ce1435e443af3/02 CONTESTS/Codeforces/657B/E.cpp -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/659B/B1.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yash0530/Competitive-Programming/502bcb237c3e7b52f46fe51cc80ce1435e443af3/02 CONTESTS/Codeforces/659B/B1.cpp -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/677C/all.txt: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/699B/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int n, k; 8 | cin >> n >> k; 9 | vector arr(n); 10 | for (auto &a : arr) { 11 | cin >> a; 12 | } 13 | if (k >= 10101) { 14 | cout << -1 << endl; 15 | continue; 16 | } 17 | k = min(10101, k); 18 | int last = -1; 19 | for (int i = 0; i < k; i++) { 20 | bool done = false; 21 | for (int i = 0; i < (n - 1); i++) { 22 | if (arr[i] < arr[i + 1]) { 23 | arr[i]++; 24 | done = true; 25 | last = i + 1; 26 | break; 27 | } 28 | } 29 | if (!done) { 30 | last = -1; 31 | break; 32 | } 33 | } 34 | cout << last << endl; 35 | } 36 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/CodeCraft20/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int now() { 25 | return chrono::duration_cast(chrono::system_clock::now() 26 | .time_since_epoch()).count(); 27 | } 28 | 29 | int32_t main() { fastio; 30 | time_t start = now(); 31 | 32 | 33 | 34 | cerr << "TIME => " << now() - start << endl; 35 | return 0; 36 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/CodeCraft20/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int now() { 25 | return chrono::duration_cast(chrono::system_clock::now() 26 | .time_since_epoch()).count(); 27 | } 28 | 29 | int32_t main() { fastio; 30 | time_t start = now(); 31 | 32 | 33 | 34 | cerr << "TIME => " << now() - start << endl; 35 | return 0; 36 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/ED73/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define int long long 6 | #define uint unsigned long long 7 | #define deb(x) cout << #x << " => " << x << "\n" 8 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 9 | #define debm(x) cout << #x << "\n"; for (auto a : x) { for (auto b : a) cout << b << " "; cout << "\n"; } cout << "\n"; 10 | #define getMat(x, n, m) vector> x(n, vector (m)) 11 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 12 | #define cina(x, n) vector x(n); for (int i = 0; i < n; i++) cin >> x[i]; 13 | #define srt(x) sort(x.begin(), x.end()) 14 | #define rev(x) reverse(x.begin(), x.end()) 15 | 16 | int32_t main() { 17 | fastio; 18 | int t; cin >> t; 19 | while (t--) { 20 | int a, b, c; 21 | cin >> a >> b >> c; 22 | cout << min({ a, b, (a + b + c) / 3 }) << endl; 23 | } 24 | return 0; 25 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/ED74/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // #include 3 | #define int long long 4 | #define uint unsigned long long 5 | #define deb(x) cout << #x << " => " << x << endl 6 | // using namespace boost::multiprecision; 7 | using namespace std; 8 | 9 | int32_t main() { 10 | 11 | ios_base :: sync_with_stdio(false); 12 | cin.tie(NULL); 13 | cout.tie(NULL); 14 | 15 | int t; cin >> t; 16 | while (t--) { 17 | int x, y; cin >> x >> y; 18 | if (x - y == 1) cout << "NO\n"; 19 | else cout << "YES\n"; 20 | } 21 | 22 | return 0; 23 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/ED74/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | typedef long long int ll; 3 | #define deb(x) cout << #x << " => " << x << endl 4 | using namespace std; 5 | 6 | int main() { 7 | 8 | ios_base :: sync_with_stdio(false); 9 | cin.tie(NULL); 10 | cout.tie(NULL); 11 | 12 | ll q; cin >> q; 13 | while (q--) { 14 | ll n, r; cin >> n >> r; 15 | set s; 16 | for (ll i = 0; i < n; i++) { 17 | ll x; cin >> x; 18 | s.insert(x); 19 | } 20 | vector arr(s.begin(), s.end()); 21 | reverse(arr.begin(), arr.end()); 22 | 23 | ll count = 0, offset = 0, i = 0; 24 | while (i < (ll) arr.size()) { 25 | if (arr[i] + offset > 0) { 26 | count++; 27 | offset -= r; 28 | } 29 | i++; 30 | } 31 | 32 | cout << count << endl; 33 | } 34 | 35 | return 0; 36 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/ED74/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | typedef long long int ll; 3 | typedef unsigned long long int ull; 4 | #define deb(x) cout << #x << " => " << x << endl 5 | using namespace std; 6 | 7 | int main() { 8 | 9 | ios_base :: sync_with_stdio(false); 10 | cin.tie(NULL); 11 | cout.tie(NULL); 12 | 13 | int q; cin >> q; 14 | while (q--) { 15 | int h, n; cin >> h >> n; 16 | vector arr(n); 17 | for (int i = 0; i < n; i++) { 18 | cin >> arr[i]; 19 | } 20 | 21 | int i = 1, height = h, count = 0; 22 | while (i < n and height > 2) { 23 | if (height - arr[i] == 1) { 24 | if (i == n - 1) { 25 | count++; 26 | break; 27 | } 28 | if (height - arr[i + 1] == 2) { 29 | height = arr[i + 1]; 30 | i += 2; 31 | } else { 32 | count++; 33 | height -= 2; 34 | i++; 35 | } 36 | } else { 37 | height = arr[i] + 1; 38 | } 39 | } 40 | 41 | cout << count << endl; 42 | } 43 | 44 | return 0; 45 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/ED75/E1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define int long long 6 | #define uint unsigned long long 7 | #define deb(x) cout << #x << " => " << x << "\n" 8 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 9 | #define debm(x) cout << #x << "\n"; for (auto a : x) {for(auto b : a) cout << b << " "; cout << "\n";} 10 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 11 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 12 | #define pout cout << fixed << setprecision(10) 13 | #define MOD (int) (1e9 + 7) 14 | 15 | int fastpow(int a, int b, int m) { 16 | a %= m; 17 | int res = 1; 18 | while (b > 0) { 19 | if (b & 1) 20 | res = res * a % m; 21 | a = a * a % m; 22 | b >>= 1; 23 | } 24 | return res; 25 | } 26 | 27 | int32_t main() { 28 | fastio; 29 | 30 | return 0; 31 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/ED76/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cout << #x << " => " << x << "\n" 11 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 12 | #define debm(x) cout << #x << "\n"; for (auto a : x) {for(auto b : a) cout << b << " "; cout << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int32_t main() { fastio; 25 | int t; cin >> t; 26 | while (t--) { 27 | int n, x, a, b; 28 | cin >> n >> x >> a >> b; 29 | cout << min(n - 1, abs(a - b) + x) << endl; 30 | } 31 | return 0; 32 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/ED77/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cout << #x << " => " << x << "\n" 11 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 12 | #define debm(x) cout << #x << "\n"; for (auto a : x) {for(auto b : a) cout << b << " "; cout << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int32_t main() { fastio; 25 | int t; cin >> t; 26 | while (t--) { 27 | int a, b; 28 | cin >> a >> b; 29 | if (a > b) swap(a, b); 30 | if ((2 * a) >= b and (a + b) % 3 == 0) { 31 | cout << "YES" << endl; 32 | } else { 33 | cout << "NO" << endl; 34 | } 35 | } 36 | return 0; 37 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/ED78/D: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yash0530/Competitive-Programming/502bcb237c3e7b52f46fe51cc80ce1435e443af3/02 CONTESTS/Codeforces/ED78/D -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/ED78/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | int fastpow(int a, int b, int m) { 17 | int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m; 18 | a = (a * a) % m; b >>= 1; } return res;} 19 | #define inv(a) fastpow(a, HELL - 2, HELL) 20 | 21 | int32_t main() { fastio; 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/ED81/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int now() { 25 | return chrono::duration_cast(chrono::system_clock::now() 26 | .time_since_epoch()).count(); 27 | } 28 | 29 | int32_t main() { fastio; 30 | time_t start = now(); 31 | 32 | 33 | 34 | cerr << "TIME => " << now() - start << endl; 35 | return 0; 36 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/ED82/D.py: -------------------------------------------------------------------------------- 1 | from math import log2 2 | 3 | for t in range(int(input())): 4 | n, m = map(int, input().split()) 5 | c = [0] * 61 6 | s = 0 7 | for x in map(int, input().split()): 8 | c[int(log2(x))] += 1 9 | s += x 10 | 11 | if s < n: 12 | print(-1) 13 | continue 14 | 15 | i, res = 0, 0 16 | while i < 60: 17 | if (1 << i) & n != 0: 18 | if c[i] > 0: 19 | c[i] -= 1 20 | else: 21 | while i < 60 and c[i] == 0: 22 | i += 1 23 | res += 1 24 | c[i] -= 1 25 | continue 26 | c[i + 1] += c[i] // 2 27 | i += 1 28 | 29 | print(res) -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/ED82/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int now() { 25 | return chrono::duration_cast(chrono::system_clock::now() 26 | .time_since_epoch()).count(); 27 | } 28 | 29 | int32_t main() { fastio; 30 | time_t start = now(); 31 | 32 | 33 | 34 | cerr << "TIME => " << now() - start << endl; 35 | return 0; 36 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/ED84/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; 20 | } return res; 21 | } 22 | 23 | int now() { 24 | return chrono::duration_cast(chrono::system_clock::now() 25 | .time_since_epoch()).count(); 26 | } 27 | 28 | int32_t main() { fastio; 29 | time_t start = now(); 30 | 31 | 32 | 33 | cerr << "TIME => " << now() - start << endl; 34 | return 0; 35 | } -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/ED85/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | int fastpow(int a, int b, int m) { 17 | int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m; 18 | a = (a * a) % m; b >>= 1; } return res;} 19 | #define inv(a) fastpow(a, HELL - 2, HELL) 20 | #define size(a) (int) a.size() 21 | 22 | int32_t main() { fastio; 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/ED85/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | int fastpow(int a, int b, int m) { 17 | int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m; 18 | a = (a * a) % m; b >>= 1; } return res;} 19 | #define inv(a) fastpow(a, HELL - 2, HELL) 20 | #define size(a) (int) a.size() 21 | 22 | int32_t main() { fastio; 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/ED87/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | #define mul(a, b) ((a % HELL) * (b % HELL)) % HELL 26 | 27 | int32_t main() { fastio; 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/ED87/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | #define mul(a, b) ((a % HELL) * (b % HELL)) % HELL 26 | 27 | int32_t main() { fastio; 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /02 CONTESTS/Codeforces/GR01/D1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define int long long 5 | 6 | int32_t main(int argc, char *a[]) 7 | { 8 | int t; cin >> t; 9 | while (t--) { 10 | int n; cin >> n; 11 | set 12 | int x; 13 | for (int i = 0; i < n; i++) { 14 | cin >> x; 15 | a.push(x); 16 | } 17 | for (int i = 0; i < n; i++) { 18 | cin >> x; 19 | b.push(x); 20 | } 21 | int count = 0; 22 | while (!a.empty() and !b.empty()) { 23 | cout << b.top() << " " << a.top() << endl; 24 | if (b.top() < a.top()) { 25 | count++; 26 | a.pop(); b.pop(); 27 | } else { 28 | a.pop(); 29 | } 30 | } 31 | cout << count << endl; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /02 CONTESTS/Google/CODEJAM20 1A/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | int fastpow(int a, int b, int m) { 17 | int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m; 18 | a = (a * a) % m; b >>= 1; } return res;} 19 | #define inv(a) fastpow(a, HELL - 2, HELL) 20 | #define size(a) (int) a.size() 21 | 22 | int32_t main() { fastio; 23 | int t; cin >> t; 24 | for (int _ = 1; _ <= t; _++) { 25 | cout << "Case #" << _ << ": "; 26 | 27 | } 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /02 CONTESTS/Google/CODEJAM20 QAL/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | int fastpow(int a, int b, int m) { 17 | int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m; 18 | a = (a * a) % m; b >>= 1; } return res;} 19 | #define inv(a) fastpow(a, HELL - 2, HELL) 20 | 21 | int32_t main() { fastio; 22 | int t; cin >> t; 23 | for (int _ = 1; _ <= t; _++) { 24 | cout << "Case #" << _ << ": "; 25 | 26 | } 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /02 CONTESTS/Google/HashCode2020/01.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yash0530/Competitive-Programming/502bcb237c3e7b52f46fe51cc80ce1435e443af3/02 CONTESTS/Google/HashCode2020/01.zip -------------------------------------------------------------------------------- /02 CONTESTS/Google/HashCode2020/02.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yash0530/Competitive-Programming/502bcb237c3e7b52f46fe51cc80ce1435e443af3/02 CONTESTS/Google/HashCode2020/02.zip -------------------------------------------------------------------------------- /02 CONTESTS/Google/HashCode2020/03.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yash0530/Competitive-Programming/502bcb237c3e7b52f46fe51cc80ce1435e443af3/02 CONTESTS/Google/HashCode2020/03.zip -------------------------------------------------------------------------------- /02 CONTESTS/Google/HashCode2020/a_example.txt: -------------------------------------------------------------------------------- 1 | 6 2 7 2 | 1 2 3 6 5 4 3 | 5 2 2 4 | 0 1 2 3 4 5 | 4 3 1 6 | 0 2 3 5 7 | -------------------------------------------------------------------------------- /02 CONTESTS/Google/HashCode2020/output_a.txt: -------------------------------------------------------------------------------- 1 | 2 2 | 0 5 3 | 3 4 2 1 0 4 | 1 1 5 | 5 6 | -------------------------------------------------------------------------------- /02 CONTESTS/Misc/ABC/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define ll long long 4 | #define pi pair 5 | #define pb push_back 6 | #define inf 1e16 7 | #define mod 1000000007 8 | #define en '\n' 9 | ll pw(ll b, ll r){ 10 | ll ans = 1; 11 | while(r){ 12 | if(r&1)ans = (ans*b)%mod; 13 | b = (b*b)%mod; 14 | r>>=1; 15 | } 16 | return ans; 17 | } 18 | bool cmp(string a, string b){ 19 | if(a.length()==b.length()){ 20 | return a.compare(b)<0; 21 | } 22 | return a.length()>n; 27 | string arr[n];for(int i = 0 ; i < n ; i ++ )cin>>arr[i]; 28 | sort(arr,arr+n,cmp); 29 | for(int i = 0 ; i < n; i ++ )cout< 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cout << #x << " => " << x << "\n" 11 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 12 | #define debm(x) cout << #x << "\n"; for (auto a : x){for(auto b : a) cout << b << " "; cout << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int32_t main() { fastio; 18 | int n; cin >> n; 19 | set s; 20 | int x = n, temp; 21 | for (int i = 0; i < n; i++) { 22 | cin >> temp; 23 | if (x == temp) { 24 | cout << x << " "; 25 | x--; 26 | while (s.find(x) != s.end()) { 27 | cout << x << " "; 28 | s.erase(x); 29 | x--; 30 | } 31 | } else { 32 | s.insert(temp); 33 | } 34 | cout << endl; 35 | } 36 | return 0; 37 | } -------------------------------------------------------------------------------- /02 CONTESTS/Misc/GW18/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cout << #x << " => " << x << "\n" 11 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 12 | #define debm(x) cout << #x << "\n"; for (auto a : x){for(auto b : a) cout << b << " "; cout << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int32_t main() { fastio; 18 | int t; cin >> t; 19 | while (t--) { 20 | int x, y; 21 | cin >> x >> y; 22 | unsigned long long z = x, a = 1; 23 | while (z <= 1e18 and (z % y) != 0) { 24 | z *= 10; 25 | a *= 10; 26 | if ((z % y) != 0 and (y - (z % y)) < a) { 27 | z += y - (z % y); 28 | } 29 | } 30 | if (z <= 1e18) cout << z << endl; 31 | else cout << -1 << endl; 32 | } 33 | return 0; 34 | } -------------------------------------------------------------------------------- /02 CONTESTS/Misc/JAKARTA/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int x; cin >> x; 6 | vector arr(x); 7 | for (int i = 0; i < x; i++) { 8 | cin >> arr[i]; 9 | } 10 | for (int i = 0; i < x; i++) { 11 | cout << arr[(i + 1) % x] << " "; 12 | } 13 | cout << endl; 14 | } -------------------------------------------------------------------------------- /02 CONTESTS/Misc/JAKARTA/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 4 | 5 | int main() { fastio; 6 | int n, q; 7 | cin >> n >> q; 8 | vector R(n), C(n); 9 | for (int i = 0; i < n; i++) { 10 | cin >> R[i]; 11 | } 12 | for (int i = 0; i < n; i++) { 13 | cin >> C[i]; 14 | } 15 | vector PR(n), PC(n); 16 | PR[0] = 0; 17 | PC[0] = 0; 18 | for (int i = 1; i < n; i++) { 19 | PR[i] = ((R[i] & 1) == (R[i - 1] & 1)) ? PR[i - 1] : 1 + PR[i - 1]; 20 | PC[i] = ((C[i] & 1) == (C[i - 1] & 1)) ? PC[i - 1] : 1 + PC[i - 1]; 21 | } 22 | int a, b, c, d; 23 | while (q--) { 24 | cin >> a >> b >> c >> d; 25 | a--; b--; c--; d--; 26 | if (PR[a] == PR[c] and PC[b] == PC[d]) { 27 | if ((R[a] & 1) == (C[b] & 1)) { 28 | cout << "YES" << endl; 29 | } else { 30 | cout << "NO" << endl; 31 | } 32 | } else { 33 | cout << "NO" << endl; 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /02 CONTESTS/Misc/KH19MOS/004 RANDID.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cout << #x << " => " << x << "\n" 11 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 12 | #define debm(x) cout << #x << "\n"; for (auto a : x){for(auto b : a) cout << b << " "; cout << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int32_t main() { fastio; 25 | int t; cin >> t; 26 | while (t--) { 27 | double n, q; 28 | cin >> n >> q; 29 | pout << n + q - n / (q + 1) << endl; 30 | } 31 | return 0; 32 | } -------------------------------------------------------------------------------- /02 CONTESTS/Misc/Mashup #3/G: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yash0530/Competitive-Programming/502bcb237c3e7b52f46fe51cc80ce1435e443af3/02 CONTESTS/Misc/Mashup #3/G -------------------------------------------------------------------------------- /02 CONTESTS/Misc/Mashup (Div-2 Difficulty)#2/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | int fastpow(int a, int b, int m) { 17 | int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m; 18 | a = (a * a) % m; b >>= 1; } return res;} 19 | #define inv(a) fastpow(a, HELL - 2, HELL) 20 | 21 | int32_t main() { fastio; 22 | int n, k; 23 | cin >> n >> k; 24 | if ((n * (n - 1)) > (2 * k)) { 25 | for (int i = 0; i < n; i++) { 26 | cout << 0 << " " << i << endl; 27 | } 28 | } else { 29 | cout << "no solution" << endl; 30 | } 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /02 CONTESTS/Misc/heisenbug/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 4 | 5 | int32_t main() { fastio; 6 | int t; cin >> t; 7 | int n, x; 8 | while (t--) { 9 | cin >> n; 10 | x = (int)sqrt(n); 11 | cout << x << "\n"; 12 | } 13 | return 0; 14 | } -------------------------------------------------------------------------------- /02 CONTESTS/Misc/heisenbug/A.py: -------------------------------------------------------------------------------- 1 | t = int(input()) 2 | for i in range(t): 3 | n = int(input()) 4 | print(int(sqrt(n))) -------------------------------------------------------------------------------- /03 CF PRACTICE/1166D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | int fastpow(int a, int b, int m) { 17 | int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m; 18 | a = (a * a) % m; b >>= 1; } return res;} 19 | #define inv(a) fastpow(a, HELL - 2, HELL) 20 | #define size(a) (int) a.size() 21 | 22 | int32_t main() { fastio; 23 | int q; 24 | while (q--) { 25 | int a, b, c; 26 | cin >> a >> b >> c; 27 | 28 | } 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /03 CF PRACTICE/APRIL CF/1129A2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | 26 | int32_t main() { fastio; 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /03 CF PRACTICE/APRIL CF/1131D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | 26 | int32_t main() { fastio; 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /03 CF PRACTICE/APRIL CF/1177B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cerr << #x << " => " << x << "\n" 11 | #define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n"; 12 | #define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | int fastpow(int a, int b, int m) { 17 | int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m; 18 | a = (a * a) % m; b >>= 1; } return res;} 19 | #define inv(a) fastpow(a, HELL - 2, HELL) 20 | #define size(a) (int) a.size() 21 | 22 | int32_t main() { fastio; 23 | int k; cin >> k; 24 | int p10 = 1; 25 | for (int i = 1; ; i++) { 26 | int x = 9 * p10 * i; 27 | if (k <= x) { 28 | cout << to_string(p10 + (--k / i))[k % i] << endl; 29 | break; 30 | } 31 | k -= x; 32 | p10 *= 10; 33 | } 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /03 CF PRACTICE/MAY CF/1334E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define en "\n" 5 | #define INF (int) 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define pii pair 11 | #define pb push_back 12 | #define fs first 13 | #define sc second 14 | #define size(a) (int) a.size() 15 | #define deb(x) cerr << #x << " => " << x << en 16 | #define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en; 17 | #define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<> x(n, vector (m, val)) 20 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 21 | #define pout cout << fixed << setprecision(10) 22 | int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m; 23 | while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;} 24 | #define inv(a) fastpow(a, HELL - 2) 25 | #define mul(a, b) ((a % HELL) * (b % HELL)) % HELL 26 | 27 | int32_t main() { fastio; 28 | int d, q; cin >> d >> q; 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /04 CC PRACTICE/COMPEXP.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define int long long 6 | #define uint unsigned long long 7 | #define deb(x) cout << #x << " => " << x << "\n" 8 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 9 | #define debm(x) cout << #x << "\n"; for (auto a : x) {for(auto b : a) cout << b << " "; cout << "\n";} 10 | #define getMat(x, n, m) vector> x(n, vector (m)) 11 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 12 | #define pout cout << fixed << setprecision(10) 13 | 14 | int32_t main() { 15 | fastio; 16 | int t, n, k; cin >> t; 17 | while (t--) { 18 | cin >> n >> k; 19 | pout << double(2 * (n - double((n - 1) / double(k)))) << endl; 20 | } 21 | return 0; 22 | } -------------------------------------------------------------------------------- /04 CC PRACTICE/INTRPATH.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cout << #x << " => " << x << "\n" 11 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 12 | #define debm(x) cout << #x << "\n"; for (auto a : x){for(auto b : a) cout << b << " "; cout << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int32_t main() { fastio; 18 | int t; cin >> t; 19 | while (t--) { 20 | int n, q, u, v; 21 | cin >> n >> q; 22 | vector> adj(n + 1); 23 | for (int i = 0; i < n - 1; i++) { 24 | cin >> u >> v; 25 | adj[u].push_back(v); 26 | adj[v].push_back(u); 27 | } 28 | } 29 | return 0; 30 | } -------------------------------------------------------------------------------- /05 SPOJ/001 MKTHNUM.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define endl "\n" 5 | #define INF 9e18 6 | #define HELL (int) (1e9 + 7) 7 | #define int long long 8 | #define double long double 9 | #define uint unsigned long long 10 | #define deb(x) cout << #x << " => " << x << "\n" 11 | #define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n"; 12 | #define debm(x) cout << #x << "\n"; for (auto a : x){for(auto b : a) cout << b << " "; cout << "\n";} 13 | #define getMat(x, n, m, val) vector> x(n, vector (m, val)) 14 | #define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 15 | #define pout cout << fixed << setprecision(10) 16 | 17 | int fastpow(int a, int b, int m) { 18 | int res = 1; a %= m; while (b > 0) { 19 | if (b & 1) res = (res * a) % m; 20 | a = (a * a) % m; b >>= 1; 21 | } return res; 22 | } 23 | 24 | int32_t main() { fastio; 25 | 26 | return 0; 27 | } -------------------------------------------------------------------------------- /06 IO/BUILD: -------------------------------------------------------------------------------- 1 | { 2 | "cmd": ["g++.exe","-std=c++17", "${file}", "&&" , "a.exeoutput.txt"], 3 | "shell":true, 4 | "working_dir":"C:\\Users\\yashj\\Desktop\\Work\\CP\\06 IO\\", 5 | "selector":"source.cpp" 6 | } -------------------------------------------------------------------------------- /06 IO/BUILD_MAC: -------------------------------------------------------------------------------- 1 | { 2 | "shell_cmd": "g++ -std=c++17 '${file}' && ./a.out < '/Users/yash/Desktop/Programming/CP/06 IO/input.txt' > '/Users/yash/Desktop/Programming/CP/06 IO/output.txt'", 3 | "working_dir": "${file_path}", 4 | "selector":"source.cpp" 5 | } 6 | -------------------------------------------------------------------------------- /06 IO/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int n; cin >> n; 8 | vector arr(n); 9 | int res = 0, pref = 0; 10 | for (auto x : arr) { 11 | pref = max(pref + x, x); 12 | res = max(res, pref); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /06 IO/CB.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | const int maxN = 2e5 + 5; 5 | vector adj[maxN]; 6 | vector deg(maxN); 7 | 8 | vector curr_comp; 9 | vector visited(maxN); 10 | 11 | void dfs(int p) { 12 | curr_comp.push_back(p); 13 | visited[p] = true; 14 | for (auto x : adj[p]) { 15 | if (!visited[x]) { 16 | dfs(x); 17 | } 18 | } 19 | } 20 | 21 | int main() { 22 | int n, m; cin >> n >> m; 23 | for (int i = 0; i < m; i++) { 24 | int a, b; cin >> a >> b; 25 | adj[a].push_back(b); 26 | adj[b].push_back(a); 27 | deg[a]++; deg[b]++; 28 | } 29 | 30 | int ans = 0; 31 | for (int i = 1; i <= n; i++) { 32 | if (!visited[i]) { 33 | curr_comp.clear(); 34 | dfs(i); 35 | bool poss = true; 36 | for (auto x : curr_comp) { 37 | if (deg[x] != 2) { 38 | poss = false; 39 | } 40 | } 41 | ans += poss; 42 | } 43 | } 44 | cout << ans << endl; 45 | } -------------------------------------------------------------------------------- /06 IO/CP.sublime-project: -------------------------------------------------------------------------------- 1 | { 2 | "folders": 3 | [ 4 | { 5 | "path": "/Users/yash/Desktop/Programming/CP" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /06 IO/flag.txt: -------------------------------------------------------------------------------- 1 | g++ -std="c++14" -Wshadow -Wall -fsanitize=address -fsanitize=undefined _.cpp && ./a.out < "/home/yash/Documents/CP/06 Helper Codes/test.txt" 2 | cp "/home/yash/Documents/CP/06 Helper Codes/TEMPLATE.cpp" _.cpp 3 | 4 | // #include 5 | // using namespace boost::multiprecision; 6 | 7 | // TIME 8 | int now() { 9 | return std::chrono::duration_cast(std::chrono::system_clock::now() 10 | .time_since_epoch()).count(); 11 | } 12 | time_t start = now(); 13 | // ... code ... 14 | time_t end = now(); 15 | cout << "TIME => " << end - start << endl; -------------------------------------------------------------------------------- /06 IO/input.txt: -------------------------------------------------------------------------------- 1 | 7 2 | 3 1 15 3 | -5 0 -10 4 | 5 3 -33 5 | 8 12 9 0 5 6 | 4 3 12 7 | 12 12 10 15 8 | 4 1 -5 9 | 0 -1 2 5 10 | 5 5 0 11 | 3 -1 4 -5 -3 12 | 1 1 5 13 | 5 14 | 6 1 3 15 | 0 3 -2 5 -4 -4 16 | -------------------------------------------------------------------------------- /06 IO/output.txt: -------------------------------------------------------------------------------- 1 | 6 2 | 0 3 | 1 4 | 0 5 | 0 6 | 1 7 | 9 8 | -------------------------------------------------------------------------------- /06 IO/output.txtd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yash0530/Competitive-Programming/502bcb237c3e7b52f46fe51cc80ce1435e443af3/06 IO/output.txtd -------------------------------------------------------------------------------- /07 CSES/02 Sorting and Searching/28.cpp: -------------------------------------------------------------------------------- 1 | // CSES Missing Coin Sum 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int n; cin >> n; 7 | vector arr(n); 8 | for (auto &a : arr) { 9 | cin >> a; 10 | } 11 | long long int ans = 1; 12 | sort(arr.begin(), arr.end()); 13 | for (int i = 0; i < n; i++) { 14 | if (arr[i] > ans) break; 15 | else { 16 | ans += arr[i]; 17 | } 18 | } 19 | cout << ans << endl; 20 | } -------------------------------------------------------------------------------- /07 CSES/02 Sorting and Searching/29.cpp: -------------------------------------------------------------------------------- 1 | // CSES Collecting Numbers 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int n; cin >> n; 7 | vector arr(n); 8 | for (auto &a : arr) { 9 | cin >> a; 10 | } 11 | set ss; 12 | int count = 0; 13 | for (auto a : arr) { 14 | ss.insert(a); 15 | if (ss.find(a - 1) != ss.end()) { 16 | count++; 17 | } 18 | } 19 | cout << n - count << endl; 20 | } --------------------------------------------------------------------------------