├── .gitignore ├── APIO ├── apio09p3.cpp ├── apio10p1.cpp ├── apio10p2.cpp ├── apio12p1.cpp ├── apio14p1.cpp ├── apio15p1.cpp └── apio15p2.cpp ├── Atcoder ├── dpa.cpp ├── dpb.cpp ├── dpc.cpp ├── dpd.cpp ├── dpe.cpp ├── dpf.cpp ├── dpg.cpp ├── dph.cpp ├── dpi.cpp ├── dpj.cpp ├── dpk.cpp ├── dpl.cpp ├── dpm.cpp ├── dpn.cpp ├── dpo.cpp ├── dpp.cpp ├── dpq.cpp ├── dpr.cpp ├── dps.cpp ├── dpt.cpp ├── dpu.cpp ├── dpv.cpp ├── dpw.cpp ├── dpx.cpp ├── dpy.cpp └── dpz.cpp ├── BOI ├── boi2007p1.cpp └── boi2007p3.cpp ├── BubbleCup ├── bbc08d.txt ├── bbc08f.cpp └── bbc09d.cpp ├── CCC ├── ccc00j1.cpp ├── ccc00j2.cpp ├── ccc00s1.cpp ├── ccc00s2.cpp ├── ccc00s3.cpp ├── ccc00s4.cpp ├── ccc00s5.cpp ├── ccc01j1.cpp ├── ccc01j2.cpp ├── ccc01s1.cpp ├── ccc01s2.cpp ├── ccc01s2exact.cpp ├── ccc01s3.cpp ├── ccc01s4.cpp ├── ccc01s5.cpp ├── ccc02j1.cpp ├── ccc02j2.cpp ├── ccc02s1.cpp ├── ccc02s2.cpp ├── ccc02s3.cpp ├── ccc02s4.cpp ├── ccc02s5.cpp ├── ccc03j1.cpp ├── ccc03j2.cpp ├── ccc03s1.cpp ├── ccc03s2.cpp ├── ccc03s3.cpp ├── ccc03s4.cpp ├── ccc03s5.cpp ├── ccc04j1.cpp ├── ccc04j2.cpp ├── ccc04j3.cpp ├── ccc04j4.cpp ├── ccc04s1.cpp ├── ccc04s2.cpp ├── ccc04s3.py ├── ccc04s4.cpp ├── ccc05j1.cpp ├── ccc05j2.cpp ├── ccc05j3.cpp ├── ccc05j4.cpp ├── ccc05j5.cpp ├── ccc05s1.cpp ├── ccc05s2.cpp ├── ccc05s3.cpp ├── ccc05s4.cpp ├── ccc05s5.cpp ├── ccc06j1.cpp ├── ccc06j2.cpp ├── ccc06j3.cpp ├── ccc06j4.cpp ├── ccc06s1.cpp ├── ccc06s2.t ├── ccc06s3.cpp ├── ccc06s4.cpp ├── ccc06s5.cpp ├── ccc07j1.cpp ├── ccc07j2.py ├── ccc07j3.cpp ├── ccc07j4.cpp ├── ccc07j5.cpp ├── ccc07s1.t ├── ccc07s2.cpp ├── ccc07s3.cpp ├── ccc07s4.cpp ├── ccc07s5.cpp ├── ccc08j1.cpp ├── ccc08j2.cpp ├── ccc08j3.cpp ├── ccc08j4.cpp ├── ccc08s1.cpp ├── ccc08s2.cpp ├── ccc08s3.cpp ├── ccc08s4.cpp ├── ccc08s5.cpp ├── ccc09j1.cpp ├── ccc09j2.cpp ├── ccc09j3.cpp ├── ccc09j4.cpp ├── ccc09s1.cpp ├── ccc09s2.cpp ├── ccc09s3.cpp ├── ccc09s4.cpp ├── ccc09s5.cpp ├── ccc10j1.cpp ├── ccc10j2.cpp ├── ccc10j3.cpp ├── ccc10j4.cpp ├── ccc10j5.cpp ├── ccc10s1.cpp ├── ccc10s2.cpp ├── ccc10s3.cpp ├── ccc10s4.cpp ├── ccc10s5.cpp ├── ccc11j1.cpp ├── ccc11j2.cpp ├── ccc11j3.t ├── ccc11j4.cpp ├── ccc11j5.cpp ├── ccc11s1.cpp ├── ccc11s2.cpp ├── ccc11s3.cpp ├── ccc11s4.cpp ├── ccc11s5.cpp ├── ccc12j1.cpp ├── ccc12j2.cpp ├── ccc12j3.cpp ├── ccc12j4.cpp ├── ccc12s1.cpp ├── ccc12s2.cpp ├── ccc12s3.cpp ├── ccc12s4.cpp ├── ccc12s5.cpp ├── ccc13j1.cpp ├── ccc13j2.cpp ├── ccc13j4.cpp ├── ccc13s1.cpp ├── ccc13s2.cpp ├── ccc13s3.cpp ├── ccc13s4.cpp ├── ccc13s5.cpp ├── ccc14j1.cpp ├── ccc14j2.cpp ├── ccc14j3.cpp ├── ccc14s1.cpp ├── ccc14s2.cpp ├── ccc14s3.cpp ├── ccc14s4.cpp ├── ccc14s5.cpp ├── ccc15j1.cpp ├── ccc15j2.t ├── ccc15j3.cpp ├── ccc15j4.cpp ├── ccc15j5.cpp ├── ccc15s1.cpp ├── ccc15s2.cpp ├── ccc15s3.cpp ├── ccc15s4.cpp ├── ccc15s5.cpp ├── ccc16j1.cpp ├── ccc16j2.t ├── ccc16j3.cpp ├── ccc16j4.t ├── ccc16s1.cpp ├── ccc16s2.cpp ├── ccc16s3.cpp ├── ccc16s4.cpp ├── ccc16s5.cpp ├── ccc17j1.cpp ├── ccc17j2.cpp ├── ccc17j3.cpp ├── ccc17j4.cpp ├── ccc17s1.cpp ├── ccc17s2.cpp ├── ccc17s3.cpp ├── ccc17s4.cpp ├── ccc17s5.cpp ├── ccc18j1.cpp ├── ccc18j2.cpp ├── ccc18j3.cpp ├── ccc18j5.cpp ├── ccc18s1.cpp ├── ccc18s2.cpp ├── ccc18s3.cpp ├── ccc18s4.cpp ├── ccc18s5.cpp ├── ccc19j1.cpp ├── ccc19j2.cpp ├── ccc19j3.cpp ├── ccc19s1.cpp ├── ccc19s2.cpp ├── ccc19s3.cpp ├── ccc19s5.cpp ├── ccc20j1.cpp ├── ccc20j2.cpp ├── ccc20j3.cpp ├── ccc20j4.cpp ├── ccc20s1.cpp ├── ccc20s2.cpp ├── ccc20s2hard.cpp ├── ccc20s3.cpp ├── ccc20s4.cpp ├── ccc21j1.py ├── ccc21j2.py ├── ccc21j3.py ├── ccc21j4.cpp ├── ccc21s1.cpp ├── ccc21s2.cpp ├── ccc21s3.cpp ├── ccc21s4.cpp ├── ccc21s5.cpp ├── ccc96s1.cpp ├── ccc96s2.cpp ├── ccc96s3.cpp ├── ccc96s4.cpp ├── ccc96s5.cpp ├── ccc97s1.cpp ├── ccc97s2.cpp ├── ccc97s3.cpp ├── ccc97s4.py ├── ccc97s5.cpp ├── ccc98s1.cpp ├── ccc98s2.cpp ├── ccc98s4.cpp ├── ccc98s5.cpp ├── ccc99s1.cpp ├── ccc99s4.cpp ├── ccc99s5.cpp ├── ccoqr16p1.cpp ├── ccoqr16p2.cpp ├── ccoqr16p3.cpp ├── hkccc08j1.py ├── hkccc08j2.py ├── hkccc08j3.cpp ├── hkccc15j1.py ├── hkccc15j2.cpp ├── hkccc15j4.cpp └── hkccc15j5.cpp ├── CCO ├── cco00p1.cpp ├── cco05p1.cpp ├── cco05p5.cpp ├── cco07p1.cpp ├── cco07p2.cpp ├── cco07p3.cpp ├── cco07p6.cpp ├── cco08p4.cpp ├── cco08p5.cpp ├── cco09p4.cpp ├── cco10p2.cpp ├── cco10p3.cpp ├── cco10p4.cpp ├── cco10p6.cpp ├── cco11p2.cpp ├── cco11p3.cpp ├── cco11p4.cpp ├── cco11p6.cpp ├── cco12p2.cpp ├── cco12p4.cpp ├── cco13p2.cpp ├── cco13p3.cpp ├── cco13p4.cpp ├── cco14p1.cpp ├── cco14p2.cpp ├── cco15p1.cpp ├── cco15p2.cpp ├── cco15p4.cpp ├── cco15p5.cpp ├── cco16p1.cpp ├── cco16p2.cpp ├── cco16p3.cpp ├── cco16p4.cpp ├── cco16p5.cpp ├── cco16p6.cpp ├── cco17p1.cpp ├── cco17p3.cpp ├── cco17p5.cpp ├── cco18p1.cpp ├── cco18p2.cpp ├── cco18p4.cpp ├── cco18p5.cpp ├── cco18p5online.cpp ├── cco18p6.cpp ├── cco19p1.cpp ├── cco19p2.cpp ├── cco19p3.cpp ├── cco19p4.cpp ├── cco20p1.cpp ├── cco20p2.cpp └── cco98p1.cpp ├── COCI ├── coci06c1p1.cpp ├── coci06c1p2.cpp ├── coci06c1p4.cpp ├── coci06c1p5.cpp ├── coci06c2p1.cpp ├── coci06c2p2.hs ├── coci06c2p3.cpp ├── coci06c2p4.cpp ├── coci06c2p5.cpp ├── coci06c3p1.cpp ├── coci06c3p5.cpp ├── coci06c4p4.cpp ├── coci06c4p6.cpp ├── coci06c5p5.cpp ├── coci06c5p6.cpp ├── coci06c6p4.cpp ├── coci07c1p3.cpp ├── coci07c1p4.cpp ├── coci07c1p5.cpp ├── coci07c2p1.hs ├── coci07c2p4.cpp ├── coci07c3p2.cpp ├── coci07c3p4.cpp ├── coci07c3p5.cpp ├── coci07c3p6.cpp ├── coci07c4p1.cpp ├── coci07c4p4.cpp ├── coci07c4p5.cpp ├── coci07c5p3.cpp ├── coci07c6p3.cpp ├── coci07c6p4.cpp ├── coci08c1p5.cpp ├── coci08c1p6.cpp ├── coci08c4p4.cpp ├── coci08c4p6.cpp ├── coci08c5p5.cpp ├── coci08c5p6.cpp ├── coci08c6p1.hs ├── coci08c6p2.cpp ├── coci08c6p3.cpp ├── coci08c6p4.cpp ├── coci13c1p4.cpp ├── coci13c1p5.cpp ├── coci14c1p2.cpp ├── coci14c1p3.cpp ├── coci14c1p4.cpp ├── coci14c1p6.cpp ├── coci14c2p2.cpp ├── coci14c3p1.py ├── coci14c3p2.cpp ├── coci14c3p3.cpp ├── coci14c3p4.cpp ├── coci14c3p5.cpp ├── coci14c4p2.cpp ├── coci14c5p2.cpp ├── coci14c6p2.cpp ├── coci14c6p4.cpp ├── coci14c6p5.cpp ├── coci14c7p1.cpp ├── coci14c7p3.cpp ├── coci15c1p3.cpp ├── coci15c2p5.cpp ├── coci15c3p5.cpp ├── coci15c4p4.cpp ├── coci15c5p3.cpp ├── coci16c1p1.cpp ├── coci17c4p2.cpp ├── coci17c4p3.cpp ├── coci17c5p3.cpp ├── coci18c4p5.cpp ├── coi06p1.cpp ├── coi06p2.cpp ├── coi08p2.cpp ├── crci07p2.cpp └── crci07p3.cpp ├── DMOJ ├── 16bitswonly.cpp ├── 2drmq.cpp ├── AnotherContest │ ├── acc1p1.cpp │ ├── acc1p2.cpp │ ├── acc1p3.cpp │ ├── acc2p1.cpp │ ├── acc2p2.cpp │ ├── acc2p3.cpp │ ├── acc3p1.cpp │ ├── acc3p2.cpp │ ├── acc3p3.cpp │ ├── acc3p4.cpp │ ├── acc4p0.cpp │ └── acc5p1.py ├── BackFromSummer │ ├── bfs17p1.cpp │ ├── bfs17p2.cpp │ ├── bfs17p3.cpp │ ├── bfs17p4.cpp │ ├── bfs17p6.cpp │ ├── bfs19p1.cpp │ ├── bfs19p2.cpp │ ├── bfs19p3.cpp │ ├── bfs19p4.cpp │ ├── bfs19p5.cpp │ └── bfs19p6.cpp ├── BackToSchool │ ├── bts16p1.cpp │ ├── bts16p2.cpp │ ├── bts16p3.cpp │ ├── bts16p4.cpp │ ├── bts16p5.cpp │ ├── bts16p6.cpp │ ├── bts16p7.cpp │ ├── bts16p8.cpp │ ├── bts17p1.cpp │ ├── bts17p2.cpp │ ├── bts17p3.cpp │ ├── bts17p4.cpp │ ├── bts17p5.cpp │ ├── bts17p6.cpp │ ├── bts17p7.cpp │ ├── bts18p1.cpp │ ├── bts18p2.cpp │ ├── bts18p3.cpp │ ├── bts18p4.cpp │ ├── bts18p5.cpp │ ├── bts18p6.cpp │ ├── bts18p7.cpp │ ├── bts18p8.cpp │ ├── bts19p1.cpp │ ├── bts19p2.cpp │ ├── bts19p3.cpp │ ├── bts19p4.cpp │ ├── bts19p5.cpp │ ├── bts19p6.cpp │ ├── bts19p7.cpp │ └── bts19p8.cpp ├── GFSSOC │ ├── gfssoc16j1.py │ ├── gfssoc16j2.hs │ ├── gfssoc16s1.cpp │ ├── gfssoc16s4.cpp │ ├── gfssoc1j1.cpp │ ├── gfssoc1j2.cpp │ ├── gfssoc1j3.cpp │ ├── gfssoc1j4.cpp │ ├── gfssoc1j5.cpp │ ├── gfssoc1s3.cpp │ ├── gfssoc1s4.cpp │ ├── gfssoc2j1.py │ ├── gfssoc2j3.cpp │ ├── gfssoc2j4.cpp │ ├── gfssoc2j5.cpp │ ├── gfssoc2s3.cpp │ ├── gfssoc2s4.cpp │ ├── gfssoc2s5.cpp │ ├── gfssoc3j1.py │ ├── gfssoc3s3.py │ ├── gfssoc3s4.cpp │ ├── gfssoc3s5.cpp │ ├── gfsspc1p1.py │ └── gfsspc1p5.cpp ├── GlobeXCup │ ├── globexcup18j0.cpp │ ├── globexcup18j1.cpp │ ├── globexcup18j2.cpp │ ├── globexcup18j3.cpp │ ├── globexcup18j4.cpp │ ├── globexcup18j5.cpp │ ├── globexcup18s0.cpp │ ├── globexcup18s1.cpp │ ├── globexcup18s2.cpp │ ├── globexcup18s3.cpp │ ├── globexcup18s4.cpp │ ├── globexcup18s5.cpp │ ├── globexcup19j1.py │ ├── globexcup19j2.cpp │ ├── globexcup19j3.py │ ├── globexcup19j4.py │ ├── globexcup19j5.cpp │ ├── globexcup19j5hard.cpp │ ├── globexcup19s1.cpp │ ├── globexcup19s2.py │ ├── globexcup19s3.cpp │ └── globexcup19s4.cpp ├── InahoContest │ ├── inaho10.cpp │ ├── inaho11.cpp │ ├── inaho2.cpp │ ├── inaho3.cpp │ ├── inaho4.cpp │ ├── inaho5.cpp │ ├── inaho6.cpp │ ├── inaho7.cpp │ ├── inaho8.cpp │ └── inaho9.c ├── MockCCC │ ├── mccc1s1.py │ ├── mccc1s2.cpp │ ├── mccc2s1.cpp │ ├── mccc2s2.cpp │ ├── mccc2s3.cpp │ ├── mccc2s4.cpp │ ├── mccc2s5.cpp │ ├── mockccc15j1.cpp │ ├── mockccc15j2.py │ ├── mockccc15j3.hs │ ├── mockccc15j5.cpp │ ├── mockccc2020c1j1.py │ ├── mockccc2020c1j2.py │ ├── mockccc2020c1j3.py │ ├── mockccc2020c1j4.cpp │ ├── mockccc2020c1j5.cpp │ ├── nccc1j1.cpp │ ├── nccc1j2.cpp │ ├── nccc1j3s1.cpp │ ├── nccc1j4s2.cpp │ ├── nccc1j5s3.cpp │ ├── nccc1s4.cpp │ ├── nccc1s5.cpp │ ├── nccc2j1.cpp │ ├── nccc2j2.cpp │ ├── nccc2j3s1.cpp │ ├── nccc2j4s2.cpp │ ├── nccc2j5s3.cpp │ ├── nccc2s4.cpp │ ├── nccc2s5.cpp │ ├── nccc3j1.py │ ├── nccc3j2.cpp │ ├── nccc3j3s1.cpp │ ├── nccc3j4s2.cpp │ ├── nccc3j5s3.cpp │ ├── nccc3s4.cpp │ ├── nccc3s5.cpp │ ├── nccc5j1.py │ ├── nccc5j2.cpp │ ├── nccc5j3s1.cpp │ ├── nccc5j4s2.cpp │ ├── nccc5j5s3.cpp │ ├── nccc5s4.cpp │ ├── nccc5s5.cpp │ ├── nccc6j1.cpp │ ├── nccc6j2.py │ ├── nccc6j3.py │ ├── nccc6j4.cpp │ ├── nccc6j5.cpp │ ├── nccc6s1.cpp │ ├── nccc6s2.cpp │ ├── nccc6s3.cpp │ ├── nccc6s4.cpp │ ├── nccc6s4hard.cpp │ ├── nccc6s5.cpp │ ├── nccc6s5hard.cpp │ ├── nccc7j1.cpp │ ├── nccc7j2.cpp │ ├── nccc7j3.hs │ ├── nccc7s1.cpp │ ├── nccc7s2.cpp │ ├── nccc7s3.cpp │ └── nccc7s5.cpp ├── MockCCO │ ├── mcco17p1.cpp │ ├── mcco17p2.cpp │ ├── mcco17p4.cpp │ ├── mcco17p6.cpp │ ├── mcco19c1d2p3.cpp │ ├── mcco19c2d1p1.cpp │ ├── ncco3d1p3.cpp │ ├── ncco3d2p1.cpp │ ├── ncco4d1p1.cpp │ ├── ncco4d1p2.cpp │ ├── ncco4d1p3.cpp │ ├── ncco4d2p1.cpp │ └── ncco4d2p3.cpp ├── THICC │ ├── thicc17p1.cpp │ ├── thicc17p2.cpp │ ├── thicc17p3.cpp │ ├── thicc17p4.cpp │ ├── thicc17p5.cpp │ └── thicc17p6.cpp ├── VMSS │ ├── vmss15c1p2.cpp │ ├── vmss15c1p3.cpp │ ├── vmss15c1p4.cpp │ ├── vmss7wc15c1p1.py │ ├── vmss7wc15c2p1.hs │ ├── vmss7wc15c2p3.cpp │ ├── vmss7wc15c3p2.hs │ ├── vmss7wc15c4p3.cpp │ ├── vmss7wc15c5p3.cpp │ ├── vmss7wc15c6p3.cpp │ ├── vmss7wc16c2p2.cpp │ ├── vmss7wc16c2p3.cpp │ ├── vmss7wc16c3p2.cpp │ ├── vmss7wc16c3p3.cpp │ ├── vmss7wc16c4p3.cpp │ ├── vmss7wc16c5p3.cpp │ ├── vmss7wc16c5p4.cpp │ ├── vmss7wc16c6p1.cpp │ └── vmss7wc16c6p3.cpp ├── Valentines │ ├── valentines18s4.cpp │ ├── valentines19j1.py │ ├── valentines19j2.py │ ├── valentines19j3.cpp │ ├── valentines19j4.cpp │ ├── valentines19j5.cpp │ ├── valentines19s1.cpp │ ├── valentines19s2.cpp │ ├── valentines19s3.cpp │ ├── valentines19s4.cpp │ └── valentines19s5.cpp ├── WAC │ ├── wac6p3.cpp │ └── wac6p4.cpp ├── a20.cpp ├── ac19p4.cpp ├── ac19p5.cpp ├── acoinproblem.cpp ├── acombiningproblem.cpp ├── adigitproblem.cpp ├── alawnsproblem.cpp ├── aminusb.cpp ├── anct1.cpp ├── anewcountry.cpp ├── anoisyclass.cpp ├── aplusb2.cpp ├── asm0.asm ├── asm1.asm ├── asm2.asm ├── asm3.asm ├── asm4.asm ├── atimesb.cpp ├── bf1.cpp ├── bf1easy.cpp ├── bf1hard.cpp ├── bf2.cpp ├── bf2hard.cpp ├── bf3.t ├── bf3hard.cpp ├── bf4hard.cpp ├── binary.cpp ├── bitduplication.cpp ├── bobsrocks.py ├── boolean.cpp ├── bsat.cpp ├── casinv.cpp ├── ccoprep16c2q2.cpp ├── ccoprep16c2q3.cpp ├── ccoprep16q1.cpp ├── ccoprep1p2.cpp ├── ccoprep1p3.cpp ├── ccoprep3p2.cpp ├── cerc2000h.py ├── countingtofour.cpp ├── cpc19c1p0.py ├── cpc19c1p1.cpp ├── cpc19c1p2.cpp ├── ddrp3.cpp ├── ddrp4.cpp ├── ddrp5.cpp ├── denoun.py ├── dmpg18s4.cpp ├── ds1.cpp ├── ds2.cpp ├── ds3.cpp ├── ds4.cpp ├── ds5easy.cpp ├── ectf20p1.txt ├── ectf20p10.txt ├── ectf20p11.txt ├── ectf20p12.txt ├── ectf20p13.txt ├── ectf20p14.txt ├── ectf20p15.txt ├── ectf20p16.txt ├── ectf20p17.txt ├── ectf20p18.txt ├── ectf20p19.txt ├── ectf20p2.txt ├── ectf20p3.txt ├── ectf20p4.txt ├── ectf20p5.txt ├── ectf20p6.txt ├── ectf20p7.txt ├── ectf20p8.txt ├── ectf20p9.txt ├── emojisearch.cpp ├── evanscube.java ├── expectedvalue.cpp ├── factorial.cpp ├── factorial2.cpp ├── fallingsnowflakes.cpp ├── fastbit.cpp ├── fibonacci.cpp ├── fibonacci2.cpp ├── frimp.cpp ├── gcc16p1.cpp ├── geometry1.cpp ├── gfsspc1p4.cpp ├── globexcup18s5hard.cpp ├── graph1.cpp ├── grid3.cpp ├── hailstone.cpp ├── halfgrid.py ├── halloween14p1.cpp ├── halloween14p2.cpp ├── hardquestion.py ├── hci16boxes.cpp ├── hci16foodie.cpp ├── hci16jumping.cpp ├── hci16oversleep.cpp ├── hci16police.cpp ├── hci16redstone.cpp ├── hci16stacker.cpp ├── hci16taxi.cpp ├── hci16xorpow.cpp ├── helloworld.cpp ├── hopscotch2.cpp ├── ichb2017p2.cpp ├── ichb2017p3.cpp ├── ics4p1.cpp ├── infinity.cpp ├── joshua.py ├── largeperm.cpp ├── lazy.cpp ├── lcs.cpp ├── linked.c ├── lis.java ├── ludipq.py ├── mathtermind.py ├── meta.cpp ├── miniaturesudoku.cpp ├── miraclesort.cpp ├── mmcc14p1.cpp ├── mmcc14p3.cpp ├── mmcc15p1.cpp ├── mnyc17p1.cpp ├── mnyc17p3.cpp ├── mnyc17p6.cpp ├── mnycp1.cpp ├── mnycp5.cpp ├── mnycp6.cpp ├── mockingspongebob.py ├── modinv.py ├── mwc15c1p1.cpp ├── mwc15c1p5.cpp ├── mwc15c2p2.cpp ├── mwc15c4p4.cpp ├── mwc15c7p3.cpp ├── naq16c.cpp ├── naq16g.cpp ├── occ19g1.cpp ├── occ19g5.cpp ├── odd.cpp ├── oly18decp5.cpp ├── pacnw16c.cpp ├── phantom1.cpp ├── phantom2.cpp ├── phantom3.cpp ├── pib20p1.cpp ├── pib20p2.cpp ├── pib20p3.cpp ├── pib20p4.cpp ├── pib20p5.cpp ├── pib20p6.cpp ├── pib20p7.cpp ├── pickit.cpp ├── piggy.txt ├── postfix.py ├── ppwindsor18p1.cpp ├── ppwindsor18p2.cpp ├── ppwindsor18p3.cpp ├── ppwindsor18p4.cpp ├── ppwindsor18p5.cpp ├── ppwindsor18p6.cpp ├── ppwindsor18p7.cpp ├── primefactor.cpp ├── pulse.cpp ├── pwindsor18p1.cpp ├── pwindsor18p2.cpp ├── pwindsor18p3.cpp ├── pwindsor18p4.cpp ├── pwindsor18p5.py ├── pwindsor18p6.cpp ├── pwindsor18p7.cpp ├── python1.py ├── python2.py ├── python3.py ├── quine.c ├── raytracing.cpp ├── rgpc17p2.cpp ├── rgpc17p4.cpp ├── rgpc18p1.cpp ├── rgpc18p3.cpp ├── rgss1.cpp ├── rgss2.cpp ├── rgss4.cpp ├── rte16j1.cpp ├── rte16s3.cpp ├── scroll.cpp ├── seed1.cpp ├── seed2.cpp ├── seed3.cpp ├── seed4.cpp ├── seed5.cpp ├── segments.cpp ├── seq0.cpp ├── seq1.py ├── seq3.py ├── set.cpp ├── shortest1.cpp ├── si17c1p2.cpp ├── si17c1p8.cpp ├── si17c3p5.cpp ├── sort1.cpp ├── sssp.cpp ├── stnbd1.cpp ├── stnbd2.cpp ├── stnbd4.cpp ├── stnbd6.cpp ├── summaximization.cpp ├── tc18summera.cpp ├── tc18summerb.cpp ├── tc18summere.cpp ├── tc18summerf.py ├── tc18summerh.cpp ├── tc19summera.cpp ├── tc19summerb.cpp ├── tc19summere.cpp ├── tc19summerf.py ├── tc19summeri.txt ├── tkp0001.c ├── toosimple.c ├── tootsierolls.cpp ├── tree1.cpp ├── tree2.cpp ├── tsoc15c2p4.cpp ├── tsoc15c2p6.cpp ├── tsoc16c1p1.cpp ├── tsoc16c1p5.cpp ├── tsoc16c1p6.cpp ├── tsoc16c2p4.cpp ├── utso15p3.cpp ├── utso15p4.cpp ├── utso15p5.cpp ├── utso15p5hard.cpp ├── utso18p1.hs ├── utso18p7.cpp ├── valday15p2.cpp ├── vmss7wc16c1p1.cpp ├── vpex1p0.py ├── vpex1p1.py ├── vpex1p2.py ├── vpex1p4.cpp ├── vpex1p5.cpp ├── waterloow2017b.cpp ├── waterloow2017c.cpp ├── xor.cpp ├── xorm.cpp ├── xors.cpp ├── year2015p1.py ├── year2015p4.cpp ├── year2016p6.cpp ├── year2016p7.cpp ├── year2016p8.cpp ├── year2017p3.cpp ├── year2017p5.cpp ├── year2018p1.py ├── year2018p2.py ├── year2018p3.cpp ├── year2018p4.cpp ├── year2018p6.cpp ├── year2018p8.cpp └── year2019p1.cpp ├── DMOPC ├── dmopc13c1p4.cpp ├── dmopc13c1p5.cpp ├── dmopc13c3p1.cpp ├── dmopc13c3p3.cpp ├── dmopc14c1p1.cpp ├── dmopc14c1p2.cpp ├── dmopc14c1p3.cpp ├── dmopc14c1p5.cpp ├── dmopc14c2p1.cpp ├── dmopc14c2p2.cpp ├── dmopc14c2p3.cpp ├── dmopc14c2p4.cpp ├── dmopc14c2p5.cpp ├── dmopc14c2p6.cpp ├── dmopc14c3p1.cpp ├── dmopc14c3p4.cpp ├── dmopc14c3p5.cpp ├── dmopc14c3p6.cpp ├── dmopc14c4p3.cpp ├── dmopc14c4p6.cpp ├── dmopc14c5p1.py ├── dmopc14c5p2.cpp ├── dmopc14c6p1.cpp ├── dmopc14c6p4.cpp ├── dmopc14c6p6.cpp ├── dmopc14c7p1.py ├── dmopc14c7p3.cpp ├── dmopc14c7p5.cpp ├── dmopc14c7p6.cpp ├── dmopc14ce1p1.cpp ├── dmopc14ce1p3.cpp ├── dmopc14ce1p4.cpp ├── dmopc14ce1p5.cpp ├── dmopc15c1p1.cpp ├── dmopc15c1p4.cpp ├── dmopc15c1p5.cpp ├── dmopc15c1p6.cpp ├── dmopc15c2p1.cpp ├── dmopc15c2p2.cpp ├── dmopc15c2p4.cpp ├── dmopc15c2p5.cpp ├── dmopc15c3p1.cpp ├── dmopc15c3p2.cpp ├── dmopc15c3p4.cpp ├── dmopc15c3p5.cpp ├── dmopc15c4p1.py ├── dmopc15c4p2.cpp ├── dmopc15c4p6.cpp ├── dmopc15c5p5.cpp ├── dmopc15c6p2.cpp ├── dmopc15c6p3.cpp ├── dmopc15c6p4.cpp ├── dmopc15c6p5.cpp ├── dmopc15c6p6.cpp ├── dmopc15c7p2.py ├── dmopc15c7p5.cpp ├── dmopc16c1p0.cpp ├── dmopc16c1p1.cpp ├── dmopc16c1p3.cpp ├── dmopc16c1p5.cpp ├── dmopc16c2p1.cpp ├── dmopc16c2p5.cpp ├── dmopc16c2p6.cpp ├── dmopc16c3p0.py ├── dmopc16c3p1.py ├── dmopc16c3p3.cpp ├── dmopc16c3p6.cpp ├── dmopc16c4p1.cpp ├── dmopc16c4p3.cpp ├── dmopc16c4p4.cpp ├── dmopc16c4p5.cpp ├── dmopc17c1p1.cpp ├── dmopc17c1p4.cpp ├── dmopc17c1p5.cpp ├── dmopc17c1p6.cpp ├── dmopc17c2p0.cpp ├── dmopc17c2p1.cpp ├── dmopc17c2p2.cpp ├── dmopc17c2p3.cpp ├── dmopc17c2p4.cpp ├── dmopc17c2p6.cpp ├── dmopc17c3p0.cpp ├── dmopc17c3p1.py ├── dmopc17c3p2.cpp ├── dmopc17c3p3.cpp ├── dmopc17c5p1.py ├── dmopc17c5p2.cpp ├── dmopc17c5p3.cpp ├── dmopc17c5p4.cpp ├── dmopc17c5p5.cpp ├── dmopc18c1p0.py ├── dmopc18c1p4.cpp ├── dmopc18c2p0.cpp ├── dmopc18c2p1.cpp ├── dmopc18c2p3.cpp ├── dmopc18c2p4.cpp ├── dmopc18c2p5.cpp ├── dmopc18c3p4.cpp ├── dmopc18c4p0.cpp ├── dmopc18c4p2.cpp ├── dmopc18c5p0.cpp ├── dmopc18c5p1.cpp ├── dmopc18c5p2.cpp ├── dmopc18c5p3.cpp ├── dmopc18c5p4.cpp ├── dmopc18c5p5.cpp ├── dmopc18c6p0.cpp ├── dmopc18c6p1.py ├── dmopc18c6p2.cpp ├── dmopc18c6p3.cpp ├── dmopc18c6p4.cpp ├── dmopc18c6p5.cpp ├── dmopc19c1p0.py ├── dmopc19c2p0.py ├── dmopc19c2p1.cpp ├── dmopc19c2p2.cpp ├── dmopc19c2p3.cpp ├── dmopc19c3p0.py ├── dmopc19c3p1.py ├── dmopc19c3p2.cpp ├── dmopc19c3p3.cpp ├── dmopc19c3p4.cpp ├── dmopc19c4p0.py ├── dmopc19c4p1.cpp ├── dmopc19c4p2.cpp ├── dmopc19c4p3.cpp ├── dmopc19c4p5.cpp ├── dmopc19c5p0.py ├── dmopc19c5p1.py ├── dmopc19c6p0.py ├── dmopc19c7p0.py ├── dmpg15b1.cpp ├── dmpg15b2.cpp ├── dmpg15b4.cpp ├── dmpg15g1.cpp ├── dmpg15g3.cpp ├── dmpg15g4.cpp ├── dmpg15s1.cpp ├── dmpg15s2.cpp ├── dmpg15s3.cpp ├── dmpg15s4.cpp ├── dmpg15s5.cpp ├── dmpg15s6.cpp ├── dmpg16b1.cpp ├── dmpg16s1.cpp ├── dmpg16s2.cpp ├── dmpg16s5.cpp ├── dmpg17b1.cpp ├── dmpg17b3.cpp ├── dmpg17b4.cpp ├── dmpg17b5.cpp ├── dmpg17b6.cpp ├── dmpg17g2.cpp ├── dmpg17s1.cpp ├── dmpg17s2.cpp ├── dmpg17s5.cpp ├── dmpg17s6.cpp ├── dmpg18b1.py ├── dmpg18b2.hs ├── dmpg18g6.cpp ├── dmpg18s2.cpp ├── dmpg18s5.cpp ├── dmpg18s6.cpp └── dmpg19b1.py ├── DWITE ├── dwite07c2p5.cpp ├── dwite08c1p4.cpp ├── dwite08c3p4.cpp ├── dwite09c3p5.cpp ├── dwite09c5p2.cpp ├── dwite09c6p4.cpp ├── dwite09c7p2.cpp ├── dwite11c1p5.cpp ├── dwite11c4p2.cpp ├── dwite11c4p4.cpp ├── dwite11c5p3.cpp └── dwite12c2p4.cpp ├── ECOO ├── ecoo07r3p1.cpp ├── ecoo13r1p1.cpp ├── ecoo13r1p2.py ├── ecoo13r2p1.py ├── ecoo15r1p1.py ├── ecoo16r1p1.py ├── ecoo18r1p1.cpp ├── ecoo18r1p2.cpp ├── ecoo19r1p3.cpp ├── ecoo19r2p1.py ├── ecoo20p1.cpp ├── ecoo20p2.cpp └── ecoo20p4.py ├── FHC ├── fhc15c1p1.cpp ├── fhc15c2p1.cpp ├── fhc15c2p2.cpp ├── fhc15c2p4 │ ├── brute.cpp │ ├── brute.err │ ├── brute.in │ ├── brute.out │ ├── fhc15c2p4.cpp │ ├── fhc15c2p4.err │ ├── fhc15c2p4.in │ ├── fhc15c2p4.out │ └── generator.cpp └── fhc17c0p3.cpp ├── ICPC ├── ecna16d.cpp ├── ecna16i.cpp ├── naq15g.cpp ├── naq16j.hs ├── pacnw16e.cpp ├── pacnw16h.cpp ├── pacnw16j.cpp └── waterloow2017a.cpp ├── IOI ├── ioi01p1.cpp ├── ioi02p4.cpp ├── ioi09p4.cpp ├── ioi10p3.cpp ├── ioi11p2.cpp ├── ioi11p3.cpp ├── ioi13p1.cpp ├── ioi13p4.cpp ├── ioi13p6.cpp ├── ioi14p2.cpp ├── ioi14p3.cpp ├── ioi15p6.cpp ├── ioi16p1.cpp ├── ioi16p6 │ ├── generator.cpp │ ├── ioi16p6.cpp │ ├── ioi16p6.err │ ├── ioi16p6.in │ ├── ioi16p6.out │ ├── slow.cpp │ └── slowslow.cpp ├── ioi18p1.cpp ├── ioi94p1.cpp └── ioi98p4.cpp ├── JOI ├── joi14p1.cpp └── joi14p6.cpp ├── LKP ├── lkp18c1p3.cpp ├── lkp18c1p4.cpp ├── lkp18c1p5.cpp ├── lkp18c2p1.cpp ├── lkp18c2p2.cpp ├── lkp18c2p3.cpp ├── lkp18c2p4.cpp └── lkp18c2p5.cpp ├── NOI └── noi05p2 │ ├── brute.cpp │ ├── brute.err │ ├── brute.in │ ├── brute.out │ ├── generator.cpp │ ├── noi05p2.cpp │ ├── noi05p2.err │ ├── noi05p2.in │ └── noi05p2.out ├── README.md ├── SPOJ ├── DYNACON1.cpp ├── DYNALCA.cpp ├── HORRIBLE.cpp ├── HOTLINE.py ├── KQUERYO.cpp ├── OTOCI.cpp ├── QTREE.cpp ├── QTREE2.cpp ├── QTREE3.cpp └── SEQ2.cpp ├── TLE ├── tle15p1.py ├── tle15p2.cpp ├── tle15p4.cpp ├── tle16c2p2.cpp ├── tle16c4p1.cpp ├── tle16c4p4.cpp ├── tle16c5p5.cpp ├── tle16c6s3.cpp ├── tle16c6s5.cpp ├── tle16c7p6.cpp ├── tle16c8p5.cpp ├── tle17c1p4.cpp ├── tle17c2p1.cpp ├── tle17c2p2.cpp ├── tle17c2p3.cpp ├── tle17c3p3.cpp ├── tle17c3p5.cpp ├── tle17c4p5.cpp ├── tle17c4p6.cpp ├── tle17c6p4.cpp ├── tle17c8p3.cpp └── tle17c8p5.cpp └── WCIPEG ├── a4b1.cpp ├── cchange.cpp ├── dp1p1.cpp ├── foxl.cpp ├── graph1p2.cpp ├── graph3p2.cpp ├── q3.cpp ├── wc02p2.py ├── wc174j3.cpp ├── wc174j4.cpp ├── wc174s2.cpp ├── wc17fj1.cpp ├── wc17fs1.cpp ├── wc17fs2.cpp ├── wc181j3.cpp ├── wc181j4.cpp ├── wc181s1.cpp ├── wc181s2.cpp ├── wc182j3.cpp ├── wc182j4.cpp ├── wc182s1.cpp ├── wc182s2.cpp ├── wc183s1.cpp ├── wc183s2.cpp ├── wc184s1.cpp ├── wc184s3.cpp ├── wc18fj2.py ├── wc18fs1.cpp ├── wc18fs2.cpp └── wc18fs3.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | DMOJ/phantomc1.py 2 | -------------------------------------------------------------------------------- /Atcoder/dpa.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | vector arr(n+4), dp(n+4, INT_MAX); 10 | for (int x = 1; x <= n; x++) 11 | scanf("%lli", &arr[x]); 12 | dp[1] = 0; 13 | for (int x = 1; x < n; x++) 14 | { 15 | dp[x+1] = min(dp[x+1], dp[x] + abs(arr[x]-arr[x+1])); 16 | dp[x+2] = min(dp[x+2], dp[x] + abs(arr[x]-arr[x+2])); 17 | } 18 | printf("%lli\n", dp[n]); 19 | } 20 | -------------------------------------------------------------------------------- /Atcoder/dpb.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, k; 8 | scanf("%i%i", &n, &k); 9 | vector arr(n+200), dp(n+200, INT_MAX); 10 | for (int x = 1; x <= n; x++) 11 | scanf("%lli", &arr[x]); 12 | dp[1] = 0; 13 | for (int x = 1; x < n; x++) 14 | for (int y = 1; y <= k; y++) 15 | dp[x+y] = min(dp[x+y], dp[x] + abs(arr[x]-arr[x+y])); 16 | printf("%lli\n", dp[n]); 17 | } 18 | -------------------------------------------------------------------------------- /Atcoder/dpc.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 100005; 6 | 7 | int dp[3][MAXN]; 8 | 9 | int main() 10 | { 11 | int n, a, b, c; 12 | scanf("%i", &n); 13 | for (int x = 1; x <= n; x++) 14 | { 15 | scanf("%i%i%i", &a, &b, &c); 16 | dp[0][x] = max(dp[1][x-1], dp[2][x-1]) + a; 17 | dp[1][x] = max(dp[0][x-1], dp[2][x-1]) + b; 18 | dp[2][x] = max(dp[0][x-1], dp[1][x-1]) + c; 19 | } 20 | printf("%i\n", max(dp[0][n], max(dp[1][n], dp[2][n]))); 21 | } 22 | -------------------------------------------------------------------------------- /Atcoder/dpd.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | long long dp[2][100005]; 6 | 7 | int main() 8 | { 9 | int n, w, a, b; 10 | scanf("%i%i", &n, &w); 11 | for (int x = 0; x < n; x++) 12 | { 13 | scanf("%i%i", &a, &b); 14 | for (int y = 0; y <= w; y++) 15 | { 16 | dp[x&1][y] = dp[x&1^1][y]; 17 | if (y-a >= 0) 18 | dp[x&1][y] = max(dp[x&1][y], dp[x&1^1][y-a] + b); 19 | } 20 | } 21 | long long ma = 0; 22 | for (int x = 0; x <= w; x++) 23 | ma = max(ma, dp[n&1^1][x]); 24 | printf("%lli\n", ma); 25 | } 26 | -------------------------------------------------------------------------------- /Atcoder/dpk.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int dp[100005]; 6 | 7 | vector a; 8 | 9 | int solve(int k) 10 | { 11 | if (k < 0) 12 | return 0; 13 | if (~dp[k]) 14 | return dp[k]; 15 | dp[k] = 1; 16 | for (auto &x : a) 17 | dp[k] &= !solve(k-x); 18 | return dp[k]; 19 | } 20 | 21 | int main() 22 | { 23 | memset(dp, -1, sizeof dp); 24 | int n, k; 25 | scanf("%i%i", &n, &k); 26 | a.resize(n); 27 | for (auto &x : a) 28 | scanf("%i", &x); 29 | printf("%s\n", solve(k) ? "Second" : "First"); 30 | } 31 | -------------------------------------------------------------------------------- /Atcoder/dpl.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 3500; 6 | 7 | long long dp[MAXN][MAXN]; 8 | long long arr[MAXN]; 9 | 10 | long long solve(int l, int r) 11 | { 12 | long long &cur = dp[l][r]; 13 | if (~cur) 14 | return cur; 15 | if (l == r) 16 | return cur = arr[l]; 17 | return cur = max(-solve(l, r-1) + arr[r], -solve(l+1, r) + arr[l]); 18 | } 19 | 20 | int main() 21 | { 22 | memset(dp, -1, sizeof dp); 23 | int n; 24 | scanf("%i", &n); 25 | for (int x = 1; x <= n; x++) 26 | scanf("%lli", &arr[x]); 27 | printf("%lli\n", solve(1, n)); 28 | } 29 | -------------------------------------------------------------------------------- /BubbleCup/bbc09d.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | long long t = 0; 9 | scanf("%i", &n); 10 | vector a(n), b(n); 11 | while (n--) 12 | scanf("%i", &a[n]), b[n] = a[n]; 13 | sort(a.begin(), a.end()); 14 | sort(b.rbegin(), b.rend()); 15 | for (int x = 0; x < a.size(); x++) 16 | t += a[x]*b[x], t %=10007; 17 | printf("%lli", t); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /CCC/ccc00j1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | void print(int a) 6 | { 7 | printf("%3i", a); 8 | } 9 | 10 | int main() 11 | { 12 | int a, b; 13 | scanf("%i%i", &a, &b); 14 | int c = a; 15 | printf("Sun Mon Tue Wed Thr Fri Sat\n"); 16 | for (int x = 1; x < c; x++) 17 | printf(" "); 18 | for (int x = 1; x <= b; x++) 19 | { 20 | print(x); 21 | c++; 22 | if (c == 8 || x == b) 23 | { 24 | printf("\n"); 25 | c = 1; 26 | } 27 | else 28 | printf(" "); 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /CCC/ccc02s2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int a, b; 8 | scanf("%i%i", &a, &b); 9 | if (a%b == 0) 10 | printf("%i\n", a/b); 11 | else 12 | { 13 | int g = __gcd(a, b); 14 | a /= g; 15 | b /= g; 16 | if (a > b) 17 | printf("%i %i/%i\n", a/b, a%b, b); 18 | else 19 | printf("%i/%i\n", a, b); 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /CCC/ccc03j2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | for (scanf("%i", &n); n; scanf("%i", &n)) 9 | { 10 | int mi = 0; 11 | for (int x = 1; x*x <= n; x++) 12 | if (n%x == 0) 13 | mi = x; 14 | printf("Minimum perimeter is %i with dimensions %i x %i\n", 2 * (n/mi + mi), mi, n/mi); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /CCC/ccc04j1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | int a; 7 | scanf("%i", &a); 8 | printf("The largest square has side length %i.", (int)floor(sqrt(a))); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /CCC/ccc04j2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int x, y; 8 | scanf("%i%i", &x, &y); 9 | for (int a = 0; a < y-x+1; a++) 10 | if (a%4 == 0 && a%5 == 0 && a%2 == 0 && a%3 == 0) 11 | printf("All positions change in year %i\n", a + x); 12 | } 13 | -------------------------------------------------------------------------------- /CCC/ccc04j3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, m; 8 | scanf("%i%i", &n, &m); 9 | vector a(n), b(m); 10 | for (auto &x : a) 11 | cin>>x; 12 | for (auto &x : b) 13 | cin>>x; 14 | for (auto &x : a) 15 | for (auto &y : b) 16 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string a, b; 8 | cin>>a; 9 | do getline(cin, b); while (b.empty()); 10 | string c; 11 | for (auto &x : b) 12 | if ('A' <= x && x <= 'Z') 13 | c += x; 14 | for (int x = 0; x < c.size(); x++) 15 | printf("%c", 'A' + (c[x] - 'A' + a[x%a.size()] - 'A')%26); 16 | printf("\n"); 17 | } 18 | -------------------------------------------------------------------------------- /CCC/ccc05j2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int ctr(int n) 6 | { 7 | int cnt = 0; 8 | for (int x = 1; x <= n; x++) 9 | if (n%x == 0) 10 | cnt++; 11 | return cnt; 12 | } 13 | 14 | int main() 15 | { 16 | int a, b; 17 | scanf("%i%i", &a, &b); 18 | int ans = 0; 19 | for (int x = a; x <= b; x++) 20 | ans += (ctr(x) == 4); 21 | printf("The number of RSA numbers between %i and %i is %i\n", a, b, ans); 22 | } 23 | 24 | -------------------------------------------------------------------------------- /CCC/ccc05j5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string n; 8 | for (cin>>n; n != "X"; cin>>n) 9 | { 10 | bool ch = true; 11 | while (ch) 12 | { 13 | ch = false; 14 | int o = n.find("ANA"); 15 | if (o != -1) 16 | n.replace(o, 3, "A"), ch = true; 17 | o = n.find("BAS"); 18 | if (o != -1) 19 | n.replace(o, 3, "A"), ch = true; 20 | } 21 | if (n != "A") 22 | printf("NO\n"); 23 | else 24 | printf("YES\n"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /CCC/ccc05s2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int c, r; 8 | scanf("%i%i", &c, &r); 9 | int curx = 0, cury = 0; 10 | int a, b; 11 | for (scanf("%i%i", &a, &b); a || b; scanf("%i%i", &a, &b)) 12 | { 13 | curx += a; 14 | cury += b; 15 | curx = min(curx, c); 16 | curx = max(curx, 0); 17 | cury = min(cury, r); 18 | cury = max(cury, 0); 19 | printf("%i %i\n", curx, cury); 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /CCC/ccc06j1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int arr[4][4] = { 8 | {461, 431, 420, 0}, 9 | {100, 57, 70, 0}, 10 | {130, 160, 118, 0}, 11 | {167, 266, 75, 0}, 12 | }; 13 | int cnt = 0; 14 | for (int x = 0; x < 4; x++) 15 | { 16 | int a; 17 | scanf("%i", &a); 18 | cnt += arr[x][a-1]; 19 | } 20 | printf("Your total Calorie count is %i.\n", cnt); 21 | } 22 | -------------------------------------------------------------------------------- /CCC/ccc06j2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, m; 8 | scanf("%i%i", &n, &m); 9 | int cnt = 0; 10 | for (int x = 1; x <= n; x++) 11 | for (int y = 1; y <= m; y++) 12 | if (x+y == 10) 13 | cnt++; 14 | printf("There"); 15 | if (cnt == 1) 16 | printf(" is "); 17 | else 18 | printf(" are "); 19 | printf("%i way", cnt); 20 | if (cnt != 1) 21 | printf("s"); 22 | printf(" to get the sum 10.\n"); 23 | } 24 | 25 | -------------------------------------------------------------------------------- /CCC/ccc06s2.t: -------------------------------------------------------------------------------- 1 | var plain : string 2 | var cipher : string 3 | var input : string 4 | get plain : * 5 | get cipher : * 6 | get input : * 7 | 8 | var code : array 1 .. 26 of char := init ('.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.') 9 | 10 | for a : 1 .. length (plain) 11 | if cipher (a) not= ' ' then 12 | code (ord (cipher (a)) - 64) := plain (a) 13 | end if 14 | end for 15 | 16 | for x : 1 .. length (input) 17 | put code (ord (input (x)) - 64) .. 18 | end for 19 | -------------------------------------------------------------------------------- /CCC/ccc07j1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | vector a (3); 8 | scanf("%i%i%i", &a[0], &a[1], &a[2]); 9 | sort (a.begin(), a.end()); 10 | printf("%i", a[1]); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /CCC/ccc07j2.py: -------------------------------------------------------------------------------- 1 | import sys 2 | for y in sys.stdin.read().split('\n'): 3 | a = {'CU': 'see you', 4 | ':-)': 'I\'m happy', 5 | ':-(': 'I\'m unhappy', 6 | ';-)': 'wink', 7 | ':-P': 'stick out my tongue', 8 | '(~.~)': 'sleepy', 9 | 'TA': 'totally awesome', 10 | 'CCC': 'Canadian Computing Competition', 11 | 'CUZ': 'because', 12 | 'TY': 'thank-you', 13 | 'YW': 'you\'re welcome', 14 | 'TTYL': 'talk to you later'} 15 | try: 16 | print(a[y]) 17 | except: 18 | print(y) 19 | -------------------------------------------------------------------------------- /CCC/ccc07j3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | set ss({100, 500, 1000, 5000, 10000, 25000, 50000, 100000, 500000, 1000000}); 6 | vector mp({0, 100, 500, 1000, 5000, 10000, 25000, 50000, 100000, 500000, 1000000}); 7 | 8 | int main() 9 | { 10 | int n, a; 11 | scanf("%i", &n); 12 | while (n--) 13 | { 14 | scanf("%i", &a); 15 | ss.erase(ss.find(mp[a])); 16 | } 17 | long long s = 0; 18 | for (auto &x : ss) 19 | s += x; 20 | scanf("%i", &a); 21 | if (a*ss.size() > s) 22 | printf("deal\n"); 23 | else 24 | printf("no deal\n"); 25 | } 26 | 27 | -------------------------------------------------------------------------------- /CCC/ccc07j4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string a, b; 8 | do getline(cin, a); while (a.empty()); 9 | do getline(cin, b); while (b.empty()); 10 | vector freq(26); 11 | for (auto &x : a) 12 | if (x ^ ' ') 13 | freq[x-'A']++; 14 | for (auto &x : b) 15 | if (x ^ ' ') 16 | freq[x-'A']--; 17 | for (auto &x : freq) 18 | if (x) 19 | return 0 * printf("Is not an anagram.\n"); 20 | printf("Is an anagram.\n"); 21 | } 22 | 23 | -------------------------------------------------------------------------------- /CCC/ccc07s1.t: -------------------------------------------------------------------------------- 1 | var y, m, d, n : int 2 | get n 3 | for x : 1 .. n 4 | get y, m ,d 5 | if y > 1989 then 6 | put "No" 7 | elsif y = 1989 then 8 | if m > 2 then 9 | put "No" 10 | elsif m = 2 then 11 | if d > 27 then 12 | put "No" 13 | else 14 | put "Yes" 15 | end if 16 | else 17 | put "Yes" 18 | end if 19 | else 20 | put "Yes" 21 | end if 22 | end for 23 | -------------------------------------------------------------------------------- /CCC/ccc07s4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, a, b; 8 | scanf("%i%i%i", &n, &a, &b); 9 | vector> adj(n+1); 10 | while (a || b) 11 | { 12 | adj[b].push_back(a); 13 | scanf("%i%i", &a, &b); 14 | } 15 | vector dp(n+1); 16 | dp[1] = 1; 17 | for (int x = 2; x <= n; x++) 18 | for (auto &y : adj[x]) 19 | dp[x] += dp[y]; 20 | printf("%i", dp[n]); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /CCC/ccc08j1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | double w, h; 8 | scanf("%lf %lf", &w, &h); 9 | auto bmi = w/h/h; 10 | if (bmi < 18.5) 11 | printf("Underweight\n"); 12 | else if (bmi > 25) 13 | printf("Overweight\n"); 14 | else 15 | printf("Normal weight\n"); 16 | } 17 | 18 | -------------------------------------------------------------------------------- /CCC/ccc08s1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string a, mia; 8 | int b, mi = INT_MAX; 9 | for (cin>>a>>b; a != "Waterloo"; cin>>a>>b) 10 | if (b < mi) 11 | mi = b, mia = a; 12 | if (b < mi) 13 | mi = b, mia = a; 14 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | long long r; 8 | for (scanf("%lli", &r); r; scanf("%lli", &r)) 9 | { 10 | long long tot = 0; 11 | for (long long x = 1; x <= r; x++) 12 | tot += (long long)sqrt(r*r-x*x)+1; 13 | printf("%lli\n", 4*tot+1); 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /CCC/ccc09j1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string a = "9780921418"; 8 | char q, w, e; 9 | scanf(" %c %c %c", &q, &w, &e); 10 | a += q; 11 | a += w; 12 | a += e; 13 | int cur = 1; 14 | long long ans = 0; 15 | for (auto &x : a) 16 | { 17 | ans += (x-'0')*cur; 18 | cur ^= 2; 19 | } 20 | printf("The 1-3-sum is %lli\n", ans); 21 | } 22 | -------------------------------------------------------------------------------- /CCC/ccc09j3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | printf("%i in Ottawa\n", n); 10 | printf("%i in Victoria\n", (n-300+2400)%2400); 11 | printf("%i in Edmonton\n", (n-200+2400)%2400); 12 | printf("%i in Winnipeg\n", (n-100+2400)%2400); 13 | printf("%i in Toronto\n", n); 14 | printf("%i in Halifax\n", (n+100)%2400); 15 | int hour = (n/100+25)%24; 16 | int min = n%100+30; 17 | if (min >= 60) 18 | min -= 60, hour = (hour+1)%24; 19 | hour = hour*100+min; 20 | printf("%i in St. John's\n", hour); 21 | } 22 | 23 | -------------------------------------------------------------------------------- /CCC/ccc10j1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int i; 6 | scanf("%i", &i); 7 | if (i <= 5) 8 | printf("%i", i /2 + 1); 9 | else if (i < 8) 10 | printf("%i", 9 - i); 11 | else 12 | printf("%i", 10 - i); 13 | } 14 | -------------------------------------------------------------------------------- /CCC/ccc10j2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int a, b, c, d, s, d1 = 0, d2 = 0; 8 | scanf("%i%i%i%i%i", &a, &b, &c, &d, &s); 9 | for (int x = 0; x < s; x++) 10 | { 11 | if (!(x%(a+b))) d1+=a-b; 12 | if (!(x%(c+d))) d2+=c-d; 13 | } 14 | printf("%s", d1 > d2 ? "Nikky" : d1 == d2||s==19 ? "Tied" : "Byron"); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /CCC/ccc10s2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | map aa; 8 | int k; 9 | string a, b; 10 | char c; 11 | scanf("%i", &k); 12 | while (k--) 13 | { 14 | scanf(" %c", &c); 15 | cin>>a; 16 | aa[a] = c; 17 | } 18 | cin>>a; 19 | for (auto &x : a) 20 | { 21 | b += x; 22 | if (aa[b]) 23 | { 24 | printf("%c", aa[b]); 25 | b.clear(); 26 | } 27 | } 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /CCC/ccc11j1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i, u; 5 | scanf("%i", &i); 6 | scanf("%i", &u); 7 | if (i >= 3 && u <= 4) 8 | printf("%s", "TroyMartian\n"); 9 | if (i <= 6 && u >= 2) 10 | printf("%s", "VladSaturnian\n"); 11 | if (i <= 2 && u <= 3) 12 | printf("%s", "GraemeMercurian"); 13 | } 14 | -------------------------------------------------------------------------------- /CCC/ccc11j2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int h, m; 8 | scanf("%i%i", &h, &m); 9 | int c = 1; 10 | while (-6*pow(c,4) + h*pow(c,3) + 2*c*c + c > 0 && ++c <= m); 11 | if (c > m) 12 | printf("The balloon does not touch ground in the given time."); 13 | else 14 | printf("The balloon first touches ground at hour: \n%i", c); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /CCC/ccc11j3.t: -------------------------------------------------------------------------------- 1 | var s : int 2 | var a : int 3 | get s 4 | get a 5 | var k : int := 1 6 | loop 7 | s := s - a 8 | k += 1 9 | exit when s < 0 10 | a := a - s 11 | k+= 1 12 | exit when a < 0 13 | end loop 14 | put k 15 | -------------------------------------------------------------------------------- /CCC/ccc11j5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | vector> adj (10); 6 | 7 | int next(int u) 8 | { 9 | int a = 1; 10 | for (auto &x : adj[u]) 11 | a *= next(x) +1; 12 | return a; 13 | } 14 | 15 | int main() 16 | { 17 | int n, a; 18 | scanf("%i", &n); 19 | for (int x = 1; x < n; x++) 20 | { 21 | scanf("%i", &a); 22 | adj[a].push_back(x); 23 | } 24 | printf("%i", next(n)); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /CCC/ccc11s1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int s = 0, t = 0, n; 8 | scanf("%i", &n); 9 | string a; 10 | cin.ignore(numeric_limits ::max(),'\n'); 11 | while (n--) 12 | { 13 | getline(cin,a); 14 | 15 | for (auto &x : a) 16 | if (x=='S'||x=='s') s++; 17 | else if (x=='T'||x=='t') t++; 18 | } 19 | printf("%s\n", t>s ? "English" : "French"); 20 | } 21 | -------------------------------------------------------------------------------- /CCC/ccc11s2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int questions; 8 | int counter = 0; 9 | cin >> questions; 10 | char user[questions - 1]; 11 | char correct[questions - 1]; 12 | for (int x = 0; x < questions; x++) 13 | cin >> user[x]; 14 | for (int x = 0; x < questions; x++) 15 | cin >> correct[x]; 16 | for (int x = 0; x < questions; x++) 17 | if (correct[x] == user[x]) 18 | counter++; 19 | cout < 2 | int main() 3 | { 4 | int l, r; 5 | scanf("%i", &l); 6 | scanf("%i", &r); 7 | int k = r - l; 8 | if (k>0 && k < 21) 9 | printf("%s", "You are speeding and your fine is $100."); 10 | else if (k>20 && k < 31) 11 | printf("%s", "You are speeding and your fine is $270."); 12 | else if (k>30) 13 | printf("%s", "You are speeding and your fine is $500."); 14 | else 15 | printf("%s", "Congratulations, you are within the speed limit!"); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /CCC/ccc12j2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | 7 | int a,b,c,d; 8 | cin >> a; 9 | cin >> b; 10 | cin >> c; 11 | cin >> d; 12 | 13 | if (a>b && b>c && c>d){ 14 | cout << "Fish Diving"; 15 | } else if (a 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | vector> grid = 8 | {{'*', 'x', '*'}, 9 | {' ', 'x', 'x'}, 10 | {'*', ' ', '*'}}; 11 | int k; 12 | scanf("%i", &k); 13 | for (int x = 0; x < 3; x++) 14 | for (int i = 0; i < k; i++, printf("\n")) 15 | for (int y = 0; y < 3; y++) 16 | for (int j = 0; j < k; j++, printf("%c", grid[x][y])); 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /CCC/ccc12j4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int k; 8 | scanf("%i", &k); 9 | string a; 10 | cin>>a; 11 | for (int x = 0; x < a.size(); x++) 12 | printf("%c", (a[x]-'A'-((x+1)*3+k)+52)%26+'A'); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /CCC/ccc12s1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int j; 8 | scanf("%i", &j); 9 | printf("%i", (j-1)*(j-2)*(j-3)/6); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /CCC/ccc12s2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | vector rd(200); 8 | rd['I']=1; 9 | rd['V']=5; 10 | rd['X']=10; 11 | rd['L']=50; 12 | rd['C']=100; 13 | rd['D']=500; 14 | rd['M']=1000; 15 | string a; 16 | cin>>a; 17 | int total = rd[a[a.size()-1]]*(a[a.size()-2]-'0'); 18 | for (int x = a.size()-3; x >= 0; --x,x--) 19 | total += (rd[a[x]] < rd[a[x+2]] ? -1 : 1)*rd[a[x]]*(a[x-1]-'0'); 20 | printf("%i", total); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /CCC/ccc12s5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int r, c, k, a, b; 8 | scanf("%i%i", &r, &c); 9 | vector> aa(r+1, vector(c+1)); 10 | vector> dp(r+1, vector (c+1)); 11 | scanf("%i", &k); 12 | while (k--) 13 | { 14 | scanf("%i%i", &a, &b); 15 | aa[a][b] = true; 16 | } 17 | dp[1][1] = 1; 18 | for (int x = 1; x <= r; x++) 19 | for (int y = 1; y <= c; y++) 20 | if (!aa[x][y]) 21 | dp[x][y] += dp[x-1][y] + dp[x][y-1]; 22 | printf("%i", dp[r][c]); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /CCC/ccc13j1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int y, m; 6 | std::cin >>y; 7 | std::cin >>m; 8 | std::cout < 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string a; 8 | cin>>a; 9 | for (auto &x : a) 10 | { 11 | if (!(x == 'I' || x == 'O' || x == 'S' || x == 'H' || x == 'Z' || x == 'X' || x == 'N')) 12 | { 13 | printf("NO"); 14 | return 0; 15 | } 16 | } 17 | printf("YES"); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /CCC/ccc13j4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int t, c, i = 0; 8 | scanf("%i%i", &t, &c); 9 | vector aa (c); 10 | for (int x = 0; x < c; x++) 11 | scanf("%i", &aa[x]); 12 | sort(aa.begin(), aa.end()); 13 | while (t-aa[i] >= 0) t -= aa[i++]; 14 | printf("%i", i); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /CCC/ccc13s1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | bool dis(int n) 6 | { 7 | stringstream ss; 8 | ss << n; 9 | string s = ss.str(); 10 | vector exist(10); 11 | for (auto &x : s) 12 | { 13 | if (exist[x-'0']) return false; 14 | else exist[x-'0'] = true; 15 | } 16 | return true; 17 | } 18 | 19 | int main() 20 | { 21 | int n; 22 | scanf("%i", &n); 23 | while (!dis(++n)); 24 | printf("%i", n); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /CCC/ccc13s2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int w, n, s = 0; 8 | scanf("%i%i", &w, &n); 9 | vector aa(n); 10 | for (int x = 0; x < n; x++) 11 | { 12 | scanf("%i", &aa[x]); 13 | s += aa[x]; 14 | if (x > 3) 15 | s-= aa[x-4]; 16 | if (s > w) 17 | { 18 | printf("%i", x); 19 | return 0; 20 | } 21 | } 22 | printf("%i", n); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /CCC/ccc13s5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int n, cost = 0; 6 | scanf("%i", &n); 7 | while (n > 1) 8 | { 9 | int a = n, b = 1; 10 | for (int x = 2; x <= sqrt(n); x++) 11 | { 12 | if (!(n % x)) 13 | { 14 | a = x, b = n / x; 15 | break; 16 | } 17 | } 18 | cost+=a-1; 19 | n-=b; 20 | } 21 | 22 | printf("%i\n", cost); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /CCC/ccc14j1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int a, b, c; 8 | scanf("%i%i%i", &a, &b, &c); 9 | if (a+b+c != 180) 10 | printf("Error"); 11 | else if (a == b && b == c) 12 | printf("Equilateral"); 13 | else if (a == b || b == c || a == c) 14 | printf("Isosceles"); 15 | else 16 | printf("Scalene"); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /CCC/ccc14j2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int n, a = 0; 5 | scanf("%i", &n); 6 | char s[n]; 7 | scanf("%15s", s); 8 | for (int x = 0; x < n; x++) 9 | { 10 | if (s[x] == 'A') a++; 11 | else a--; 12 | } 13 | if (a > 0) printf("%c", 'A'); 14 | else if (a < 0) printf("%c", 'B'); 15 | else printf("%s", "Tie"); 16 | } 17 | -------------------------------------------------------------------------------- /CCC/ccc14j3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, a, b, aa = 100, bb = 100; 8 | scanf("%i", &n); 9 | while (n--) 10 | { 11 | scanf("%i%i", &a, &b); 12 | if (a > b) 13 | bb -= a; 14 | else if (a < b) 15 | aa -= b; 16 | } 17 | printf("%i\n%i\n", aa, bb); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /CCC/ccc14s1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int k, m, a; 8 | scanf("%i%i", &k, &m); 9 | vector aa (k+1); 10 | int s = 0; 11 | generate(aa.begin(), aa.end(), [&s](){return s++;}); 12 | while (m--) 13 | { 14 | scanf("%i", &a); 15 | for (int x = a; x < aa.size(); x+=a-1) 16 | aa.erase(aa.begin()+x); 17 | } 18 | for (int x = 1; x < aa.size(); x++) 19 | printf("%i\n", aa[x]); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /CCC/ccc15j1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int a; 8 | scanf("%i", &a); 9 | if (a > 2) printf("After"); 10 | else if (a < 2) printf("Before"); 11 | else 12 | { 13 | scanf("%i", &a); 14 | if (a > 18) printf("After"); 15 | else if (a < 18) printf("Before"); 16 | else printf("Special"); 17 | } 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /CCC/ccc15j2.t: -------------------------------------------------------------------------------- 1 | var s : string 2 | get s : * 3 | var a : int := 0 4 | var j : boolean := false 5 | for x : 1 .. length (s) 6 | if s (x) = ':' then 7 | j := true 8 | if s (x + 2) = '(' then 9 | a -= 1 10 | elsif s (x + 2) = ')' then 11 | a += 1 12 | end if 13 | end if 14 | end for 15 | if j then 16 | if a > 0 then 17 | put "happy" 18 | elsif a < 0 then 19 | put "sad" 20 | elsif a = 0 then 21 | put "unsure" 22 | end if 23 | else 24 | put "none" 25 | end if 26 | -------------------------------------------------------------------------------- /CCC/ccc15j4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | vector aa (105), bb (105), cc (105); 8 | int n, m, t = 0; 9 | char c; 10 | scanf("%i", &m); 11 | while (m--) 12 | { 13 | scanf(" %c%i", &c, &n); 14 | if (c == 'S') 15 | aa[n] += t-cc[n], bb[n]=1; 16 | else if (c == 'R') 17 | cc[n]=t, bb[n]=-1; 18 | else t+=n-2; 19 | t++; 20 | } 21 | for (int x = 0; x < 105; x++) 22 | if (bb[x]) 23 | printf("%i %i\n", x, (bb[x] > 0 ? aa[x] : bb[x])); 24 | } 25 | -------------------------------------------------------------------------------- /CCC/ccc15j5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | vector> aa; 6 | 7 | int next(int a, int b) 8 | { 9 | if (a < b) return 0; 10 | else if (b == 1 || a == b) return 1; 11 | else if (aa[a][b] != INT_MAX) return aa[a][b]; 12 | return aa[a][b] = next(a-1, b-1) + next(a-b, b); 13 | } 14 | 15 | int main() 16 | { 17 | int n, k; 18 | scanf("%i%i", &n, &k); 19 | aa.resize(n+1); 20 | for (auto &x : aa) 21 | x.resize(n+1, INT_MAX); 22 | printf("%i", next(n, k)); 23 | } 24 | -------------------------------------------------------------------------------- /CCC/ccc15s1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | vector aa; 8 | int k, a; 9 | scanf("%i", &k); 10 | while (k--) 11 | { 12 | scanf("%i", &a); 13 | if (!a) aa.pop_back(); 14 | else aa.push_back(a); 15 | } 16 | printf("%i", accumulate(aa.begin(), aa.end(), 0)); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /CCC/ccc15s3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | vector par (100001); 6 | 7 | int find(int n) 8 | { 9 | if (n != par[n]) 10 | par[n] = find(par[n]); 11 | return par[n]; 12 | } 13 | 14 | int main() 15 | { 16 | iota(par.begin(), par.end(), 0); 17 | int g, p, a, t = 0; 18 | scanf("%i%i", &g, &p); 19 | while (p--) 20 | { 21 | scanf("%i", &a); 22 | a = find(a); 23 | if (!a) 24 | { 25 | printf("%i", t); 26 | return 0; 27 | } 28 | par[a] = find(a-1); 29 | t++; 30 | } 31 | printf("%i", t); 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /CCC/ccc16j1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | char s; 5 | int w = 0; 6 | for (int x = 0; x < 6; x++) 7 | { 8 | scanf("%1s", &s); 9 | if (s == 'W') 10 | w++; 11 | } 12 | switch(w) 13 | { 14 | case 5 ... 6: 15 | printf("%i", 1); 16 | break; 17 | case 3 ... 4: 18 | printf("%i", 2); 19 | break; 20 | case 1 ... 2: 21 | printf("%i", 3); 22 | break; 23 | default: 24 | printf("%i", -1); 25 | break; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /CCC/ccc16j2.t: -------------------------------------------------------------------------------- 1 | var i : array 1 .. 16 of int 2 | var s : boolean := true 3 | for x : 1 .. 16 4 | get i (x) 5 | end for 6 | var o : int := i (1) + i (2) + i (3) + i (4) 7 | 8 | for x : 5 .. 13 by 4 9 | if i (x) + i (x + 1) + i (x + 2) + i (x + 3) not= o then 10 | s := false 11 | end if 12 | exit when not s 13 | end for 14 | for x : 1 .. 4 15 | exit when not s 16 | if i (x) + i (x + 4) + i (x + 8) + i (x + 12) not= o then 17 | s := false 18 | end if 19 | end for 20 | 21 | if s then 22 | put "magic" 23 | else 24 | put "not magic" 25 | end if 26 | -------------------------------------------------------------------------------- /CCC/ccc16j4.t: -------------------------------------------------------------------------------- 1 | var t, hm, mh : string := "" 2 | var h, m : int 3 | get t : * 4 | h := strint (t (1 .. 2)) 5 | m := strint (t (4 .. 5)) 6 | 7 | for x : 1 .. 120 8 | if h > 6 and h < 10 or h > 14 and h < 19 then 9 | m += 2 10 | else 11 | m += 1 12 | end if 13 | if m = 60 then 14 | h += 1 15 | m := 0 16 | end if 17 | if h = 24 then 18 | h := 0 19 | end if 20 | end for 21 | if length (intstr (m)) = 1 then 22 | mh := "0" 23 | end if 24 | if length (intstr (h)) = 1 then 25 | hm := "0" 26 | end if 27 | put hm, h, ":", mh, m 28 | -------------------------------------------------------------------------------- /CCC/ccc16s1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int s = 0; 8 | vector freq(26); 9 | string a; 10 | do getline(cin, a); while (a.empty()); 11 | for (auto &t : a) 12 | freq[t-'a']++; 13 | do getline(cin, a); while (a.empty()); 14 | for (auto &t : a) 15 | { 16 | 17 | if (t == '*') s++; 18 | else freq[t-'a']--; 19 | } 20 | for (auto &x : freq) 21 | { 22 | if (x < 0) return 0 * printf("N"); 23 | s -= x; 24 | } 25 | if (s) printf("N"); 26 | else printf("A"); 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /CCC/ccc16s2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int t, n; 8 | scanf("%i%i", &t, &n); 9 | vector a(n), b(n); 10 | for (auto &x : a) scanf("%i", &x); 11 | for (auto &x : b) scanf("%i", &x); 12 | sort(a.begin(), a.end()); 13 | if (!(t-1)) sort(b.begin(), b.end()); 14 | else sort(b.rbegin(), b.rend()); 15 | int s = 0; 16 | for (int x = 0; x < n; x++) 17 | s += max(a[x], b[x]); 18 | printf("%i", s); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /CCC/ccc17j1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int a, b; 6 | scanf("%i", &a); 7 | scanf("%i", &b); 8 | if (a > 0 && b > 0) 9 | printf("1"); 10 | else if (a < 0 && b > 0) 11 | printf("2"); 12 | else if (a < 0 && b < 0) 13 | printf("3"); 14 | else if (a > 0 && b < 0) 15 | printf("4"); 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /CCC/ccc17j2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | int a, k, c; 8 | scanf("%i", &a); 9 | scanf("%i", &k); 10 | c = a; 11 | for (int y = 1; y < k+1; y++) 12 | c += (a * pow(10, y)); 13 | cout << c; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /CCC/ccc17j3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int x1, y1, x2, y2, step, totalDif; 6 | scanf("%i", &x1); 7 | scanf("%i", &y1); 8 | scanf("%i", &x2); 9 | scanf("%i", &y2); 10 | scanf("%i", &step); 11 | totalDif = abs(x2 - x1) + abs(y2 - y1); 12 | char b = ((totalDif % 2 == step % 2) && step >= totalDif) ? 'Y' : 'N'; 13 | printf("%c", b); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /CCC/ccc17s1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, aa = 0, bb = 0, mn = 0; 8 | scanf("%i", &n); 9 | vector a(n), b(n); 10 | for (auto &x : a) 11 | scanf("%i", &x); 12 | for (auto &x : b) 13 | scanf("%i", &x); 14 | for (int x = 0; x < n; x++) 15 | { 16 | aa += a[x], bb += b[x]; 17 | if (aa == bb) 18 | mn = x+1; 19 | } 20 | if (aa == bb) 21 | mn = n; 22 | printf("%i", mn); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /CCC/ccc17s2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | vector a(n); 10 | for (auto &x : a) 11 | scanf("%i", &x); 12 | sort(a.begin(), a.end()); 13 | if (n&1) 14 | { 15 | printf("%i ", a[n/2]); 16 | for (int x = 1; x <= n/2; x++) 17 | printf("%i %i ", a[n/2 + x], a[n/2 - x]); 18 | } 19 | else 20 | { 21 | for (int x = 1; x <= n/2; x++) 22 | printf("%i %i ", a[n/2 - x], a[n/2 + x - 1]); 23 | } 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /CCC/ccc18j1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int a, b, c, d; 8 | scanf("%i%i%i%i", &a, &b, &c, &d); 9 | if ((a == 8 || a == 9) && b == c && (d == 8 || d == 9)) 10 | printf("ignore"); 11 | else 12 | printf("answer"); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /CCC/ccc18j2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, s = 0; 8 | scanf("%i", &n); 9 | string a, b; 10 | cin>>a>>b; 11 | for (int x = 0; x < n; x++) 12 | if (a[x] == 'C' && b[x] == 'C') 13 | s++; 14 | printf("%i", s); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /CCC/ccc18j3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | vector a(4); 8 | for (auto &x : a) 9 | scanf("%i", &x); 10 | for (int x = 0; x < 5; x++) 11 | { 12 | vector aa(5); 13 | for (int y = x-1; y >= 0; y--) 14 | aa[y] = aa[y+1]+a[y]; 15 | for (int y = x+1; y < 5; y++) 16 | aa[y] = aa[y-1]+a[y-1]; 17 | for (auto &y : aa) 18 | printf("%i ", y); 19 | printf("\n"); 20 | } 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /CCC/ccc18s1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | vector a(n); 10 | for (auto &x : a) 11 | scanf("%i", &x); 12 | double mi = INT_MAX; 13 | sort(a.begin(), a.end()); 14 | for (int x = 1; x < n-1; x++) 15 | mi = min(mi, abs(a[x]-a[x-1])/2.0 + abs(a[x+1]-a[x])/2.0); 16 | printf("%.1lf", mi); 17 | } 18 | -------------------------------------------------------------------------------- /CCC/ccc18s4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | unordered_map dp; 6 | 7 | long long next(int sz) 8 | { 9 | if (sz == 1) return 1; 10 | if (dp[sz]) return dp[sz]; 11 | dp[sz] = 0; 12 | for (int c = sz; c >= 2;) 13 | { 14 | int cur = sz/c, ne = sz/(cur+1); 15 | dp[sz] += (long long)(c-ne)*next(cur); 16 | c = ne; 17 | } 18 | return dp[sz]; 19 | } 20 | 21 | int main() 22 | { 23 | int n; 24 | scanf("%i", &n); 25 | printf("%lli\n", next(n)); 26 | } 27 | -------------------------------------------------------------------------------- /CCC/ccc19j1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int g() 6 | { 7 | int a, b, c; 8 | scanf("%i%i%i", &a, &b, &c); 9 | return a*3 + b*2 + c; 10 | } 11 | 12 | int main() 13 | { 14 | int a = g(); 15 | int b = g(); 16 | if (a > b) 17 | printf("A\n"); 18 | else if (a < b) 19 | printf("B\n"); 20 | else 21 | printf("T\n"); 22 | } 23 | -------------------------------------------------------------------------------- /CCC/ccc19j2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int l; 8 | scanf("%i", &l); 9 | while (l--) 10 | { 11 | int t; 12 | char c; 13 | scanf("%i %c", &t, &c); 14 | while (t--) 15 | printf("%c", c); 16 | printf("\n"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /CCC/ccc19j3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | while (n--) 10 | { 11 | string a; 12 | cin>>a; 13 | int c = 0; 14 | char prev = '\0'; 15 | for (auto &x : a) 16 | { 17 | if (prev != x) 18 | { 19 | if (c) 20 | printf("%i %c ", c, prev); 21 | c = 0; 22 | prev = x; 23 | } 24 | c++; 25 | } 26 | printf("%i %c\n", c, prev); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /CCC/ccc20j1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int s, m, l; 8 | scanf("%i%i%i", &s, &m, &l); 9 | printf("%s\n", s + m * 2 + l * 3 >= 10 ? "happy" : "sad"); 10 | } 11 | -------------------------------------------------------------------------------- /CCC/ccc20j2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int p, n, r; 8 | scanf("%i%i%i", &p, &n, &r); 9 | int t = 0; 10 | for (int s = 0; s <= p; t++) 11 | { 12 | s += n; 13 | n *= r; 14 | } 15 | printf("%i\n", t - 1); 16 | } 17 | -------------------------------------------------------------------------------- /CCC/ccc20j3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | int mx = INT_MIN, my = INT_MIN, mxx = INT_MAX, myy = INT_MAX; 10 | while (n--) 11 | { 12 | int x, y; 13 | scanf("%i,%i", &x, &y); 14 | mx = max(mx, x); 15 | my = max(my, y); 16 | mxx = min(mxx, x); 17 | myy = min(myy, y); 18 | } 19 | printf("%i,%i\n", mxx-1, myy-1); 20 | printf("%i,%i\n", mx+1, my+1); 21 | } 22 | -------------------------------------------------------------------------------- /CCC/ccc20j4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string t, s; 8 | cin>>t>>s; 9 | for (int x = 0; x <= t.length()-s.length(); x++) 10 | { 11 | for (int y = 0; y < s.length(); y++) 12 | { 13 | bool good = true; 14 | for (int z = 0; good && z < s.length(); z++) 15 | good &= s[(y + z) % s.length()] == t[x + z]; 16 | if (good) 17 | return 0 * printf("yes\n"); 18 | } 19 | } 20 | printf("no\n"); 21 | } 22 | -------------------------------------------------------------------------------- /CCC/ccc20s1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | vector> arr(n); 10 | for (auto &x : arr) 11 | scanf("%lli%lli", &x.first, &x.second); 12 | sort(arr.begin(), arr.end()); 13 | long double ans = 0; 14 | for (int x = 1; x < n; x++) 15 | ans = max(ans, (long double)abs(arr[x].second - arr[x-1].second) / (arr[x].first - arr[x-1].first)); 16 | printf("%.10Lf\n", ans); 17 | } 18 | -------------------------------------------------------------------------------- /CCC/ccc21j1.py: -------------------------------------------------------------------------------- 1 | def sgn(n): 2 | return 0 if not n else n // abs(n) 3 | 4 | b = int(input()) 5 | assert 80 <= b <= 200 6 | 7 | p = 5 * b - 400 8 | print(p) 9 | print(sgn(100 - p)) 10 | -------------------------------------------------------------------------------- /CCC/ccc21j2.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | assert 1 <= n <= 100 3 | bst_bid = -1e10 4 | bst_name = '' 5 | for i in range(n): 6 | name = input() 7 | bid = int(input()) 8 | assert 1 <= bid <= 2000 9 | if bid > bst_bid: 10 | bst_bid = bid 11 | bst_name = name 12 | 13 | print(bst_name) 14 | -------------------------------------------------------------------------------- /CCC/ccc21j3.py: -------------------------------------------------------------------------------- 1 | prev_dir = None 2 | while (s := input()) != '99999': 3 | assert len(s) == 5 4 | su = int(s[0]) + int(s[1]) 5 | if su % 2 == 1: 6 | prev_dir = 'left' 7 | elif su % 2 == 0 and su > 0: 8 | prev_dir = 'right' 9 | else: 10 | assert prev_dir 11 | print(prev_dir, s[2:]) 12 | -------------------------------------------------------------------------------- /CCC/ccc21s1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | vector h(n + 1); 10 | for (auto &x : h) 11 | scanf("%i", &x); 12 | vector w(n); 13 | for (auto &x : w) 14 | scanf("%i", &x); 15 | int full = 0; 16 | int half = 0; 17 | for (int x = 0; x < n; x++) 18 | { 19 | full += w[x] * min(h[x], h[x + 1]); 20 | half += w[x] * abs(h[x] - h[x + 1]); 21 | } 22 | full += half / 2; 23 | half %= 2; 24 | if (!half) 25 | printf("%i\n", full); 26 | else 27 | printf("%i.5\n", full); 28 | } 29 | -------------------------------------------------------------------------------- /CCC/ccc21s2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int m, n, k; 8 | scanf("%i%i%i", &m, &n, &k); 9 | vector row(m + 1); 10 | vector col(n + 1); 11 | while (k--) 12 | { 13 | char c; 14 | int i; 15 | scanf(" %c%i", &c, &i); 16 | if (c == 'R') 17 | row[i] ^= 1; 18 | else 19 | col[i] ^= 1; 20 | } 21 | int ans = 0; 22 | for (int x = 1; x <= m; x++) 23 | for (int y = 1; y <= n; y++) 24 | ans += row[x] ^ col[y]; 25 | printf("%i\n", ans); 26 | } 27 | -------------------------------------------------------------------------------- /CCC/ccc96s1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, a; 8 | scanf("%i", &n); 9 | while (n--) 10 | { 11 | int c = 0; 12 | scanf("%i", &a); 13 | for (int x = 1; x < a; x++) 14 | if (a%x==0) 15 | c+=x; 16 | if (c < a) 17 | printf("%i is a deficient number.\n", a); 18 | else if (c > a) 19 | printf("%i is an abundant number.\n", a); 20 | else 21 | printf("%i is a perfect number.\n", a); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /CCC/ccc96s5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int qq, n; 8 | scanf("%i", &qq); 9 | while(qq--) 10 | { 11 | scanf("%i", &n); 12 | vector a (n), b(n); 13 | for (auto &x : a) 14 | scanf("%i", &x); 15 | for (auto &x : b) 16 | scanf("%i", &x); 17 | int ma = 0; 18 | for (int x = 0; x < n; x++) 19 | for (int y = x; y < n; y++) 20 | if (b[y] >= a[x]) 21 | ma = max(ma, y-x); 22 | printf("The maximum distance is %i\n", ma); 23 | } 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /CCC/ccc97s4.py: -------------------------------------------------------------------------------- 1 | import sys 2 | n = int(input()) 3 | v = sys.stdin.read().strip().split('\n\n') 4 | for x in v: 5 | dic = {} 6 | cnt = 1 7 | for a in x.split('\n'): 8 | line = [] 9 | for b in a.split(): 10 | if b in dic: 11 | line.append(dic[b]) 12 | else: 13 | line.append(b) 14 | dic[b] = cnt 15 | cnt += 1 16 | print(' '.join(map(str, line))) 17 | print() 18 | -------------------------------------------------------------------------------- /CCC/ccc97s5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | cout<<"9\n0\n\n0\n11111111111111111111111111111111111111111111111111111111111111111111111111111111\n\n1111111111111111111111111111111111111111111111111111111111111111111111111111111\n1\n\n1234567890123456789012345678901234567890\n0\n\n80000000736900024706590314920054138664879387042756865\n8975143\n\n0\n13589\n"; 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /CCC/ccc98s2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | for (int x = 1000; x <= 9999; x++) 8 | { 9 | int sum = 0; 10 | for (int y = 1; y < x; y++) 11 | if (x%y == 0) 12 | sum += y; 13 | if (x == sum) 14 | printf("%i ", x); 15 | } 16 | printf("\n"); 17 | for (int x = 100; x <= 999; x++) 18 | { 19 | int sum = 0; 20 | for (int y = x; y; y /= 10) 21 | sum += (y%10) * (y%10) * (y%10); 22 | if (x == sum) 23 | printf("%i ", x); 24 | } 25 | printf("\n"); 26 | } 27 | -------------------------------------------------------------------------------- /CCC/hkccc08j1.py: -------------------------------------------------------------------------------- 1 | c = int(input()) 2 | def f(a, b): 3 | return a*b 4 | a = max(f(*map(int,input().split())) for x in range(c)) 5 | c = int(input()) 6 | b = max(f(*map(int,input().split())) for x in range(c)) 7 | if a > b: 8 | print("Casper") 9 | elif a < b: 10 | print("Natalie") 11 | else: 12 | print("Tie") 13 | -------------------------------------------------------------------------------- /CCC/hkccc08j2.py: -------------------------------------------------------------------------------- 1 | def f(s): 2 | return str(sum(map(int,s))) 3 | t = int(input()) 4 | for i in range(t): 5 | n = input() 6 | while len(n) > 1: 7 | n = f(n) 8 | print(n) 9 | -------------------------------------------------------------------------------- /CCC/hkccc15j1.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | a = input().split() 3 | b = input().split() 4 | c = [0, 0] 5 | for i in range(n): 6 | if a[i] == b[i]: 7 | continue 8 | if a[i] == "rock": 9 | c[b[i] == "paper"] += 1 10 | elif a[i] == "paper": 11 | c[b[i] == "scissors"] += 1 12 | elif a[i] == "scissors": 13 | c[b[i] == "rock"] += 1 14 | 15 | print(*c) 16 | -------------------------------------------------------------------------------- /CCC/hkccc15j2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, mi = INT_MAX; 8 | 9 | scanf("%i", &n); 10 | vector> a (n); 11 | for (auto &x : a) 12 | scanf("%i%i", &x.first, &x.second); 13 | for (auto &x : a) 14 | for (auto &y : a) 15 | if (x != y) 16 | mi = min(mi, max(abs(x.second - y.second), abs(x.first - y.first))); 17 | printf("%lli", mi*mi); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /COCI/coci06c1p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int num [10]; 6 | int temp, counter = 1; 7 | for (int x = 0; x < 10; x++) 8 | { 9 | scanf("%i", &temp); 10 | num[x] = temp % 42; 11 | for (int y = 0; y < x; y++) 12 | { 13 | if (num[x] == num[y]) break; 14 | if (y == x-1) counter++; 15 | } 16 | } 17 | printf("%i", counter); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /COCI/coci06c1p2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int a; 6 | scanf("%i", &a); 7 | printf("%lf\n%i", a*a*3.14159265359, a*a*2); 8 | } 9 | -------------------------------------------------------------------------------- /COCI/coci06c1p5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 20; 6 | 7 | long double dp[1<>y&1)) 22 | dp[z | 1< 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int r, s; 8 | scanf("%i%i", &r, &s); 9 | printf("%i\n", 2 * s - r); 10 | } 11 | -------------------------------------------------------------------------------- /COCI/coci06c2p2.hs: -------------------------------------------------------------------------------- 1 | import Data.Char 2 | import Data.List 3 | 4 | main = do 5 | arr <- map(read :: String -> Integer) <$> words <$> getLine 6 | let v = sort arr 7 | order <- getLine 8 | putStrLn(unwords(map (\x -> show(v!!(ord x - 65))) order)) 9 | -------------------------------------------------------------------------------- /COCI/coci06c2p4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | cin>>n; 9 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n = 9; 8 | vector arr(n); 9 | for (auto &x : arr) 10 | scanf("%i", &x); 11 | sort(arr.begin(), arr.end()); 12 | do 13 | { 14 | int s = 0; 15 | for (int x = 0; x < 7; x++) 16 | s += arr[x]; 17 | if (s == 100) 18 | { 19 | for (int x = 0; x < 7; x++) 20 | printf("%i\n", arr[x]); 21 | break; 22 | } 23 | } 24 | while (next_permutation(arr.begin(), arr.end())); 25 | } 26 | -------------------------------------------------------------------------------- /COCI/coci06c4p4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | long long dp[2][10005]; 6 | 7 | const int MOD = 1000000007; 8 | 9 | int main() 10 | { 11 | int n, c; 12 | scanf("%i%i", &n, &c); 13 | for (int x = 0; x <= c+1; x++) 14 | dp[1][x] = 1; 15 | for (int x = 2; x <= n; x++) 16 | { 17 | dp[x&1][0] = 1; 18 | for (int y = 1; y <= c; y++) 19 | dp[x&1][y] = (((dp[x&1^1][y] - (y-x >= 0 ? dp[x&1^1][y-x] : 0))%MOD+MOD + dp[x&1][y-1])%MOD+MOD)%MOD; 20 | } 21 | printf("%lli\n", (dp[n&1][c]-dp[n&1][c-1]+MOD)%MOD); 22 | } 23 | 24 | -------------------------------------------------------------------------------- /COCI/coci07c2p1.hs: -------------------------------------------------------------------------------- 1 | main = do 2 | let good = [1, 1, 2, 2, 2, 8] 3 | cur <- map (read :: String -> Integer) <$> words <$> getLine 4 | putStrLn . unwords $ map (\x -> show ((fst x) - (snd x))) (zip good cur) 5 | -------------------------------------------------------------------------------- /COCI/coci07c3p4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | long long ans = 0; 10 | vector xx(100005), yy(100005); 11 | vector> arr(n); 12 | for (auto &x : arr) 13 | { 14 | scanf("%i%i", &x.first, &x.second); 15 | xx[x.first]++; 16 | yy[x.second]++; 17 | } 18 | for (auto &x : arr) 19 | ans += (xx[x.first]-1)*(yy[x.second]-1); 20 | printf("%lli\n", ans); 21 | } 22 | 23 | -------------------------------------------------------------------------------- /COCI/coci07c6p3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, gcd = 0, p = 0, c = 0; 8 | scanf("%i", &n); 9 | for (int x = 0; x < n; x++) 10 | { 11 | scanf("%i", &c); 12 | if (x) gcd = __gcd(gcd, abs(c-p)); 13 | p = c; 14 | } 15 | for (int x = 2; x <= sqrt(gcd); x++) 16 | { 17 | if (!(gcd%x)) 18 | { 19 | printf("%i ", x); 20 | if (x != gcd/x) 21 | printf("%i ", gcd/x); 22 | } 23 | } 24 | printf("%i", gcd); 25 | } 26 | -------------------------------------------------------------------------------- /COCI/coci08c6p1.hs: -------------------------------------------------------------------------------- 1 | main = do 2 | a <- read <$> getLine :: IO Integer 3 | t <- getLine 4 | b <- read <$> getLine :: IO Integer 5 | if t == "+" 6 | then print(a + b) 7 | else print(a * b) 8 | -------------------------------------------------------------------------------- /COCI/coci13c1p5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 2000005; 6 | 7 | int freq[MAXN]; 8 | 9 | int main() 10 | { 11 | int n, a; 12 | scanf("%i", &n); 13 | while (n--) 14 | { 15 | scanf("%i", &a); 16 | freq[a]++; 17 | } 18 | long long ma = 0; 19 | for (int x = 1; x < MAXN; x++) 20 | { 21 | long long cnt = 0; 22 | for (int y = x; y < MAXN; y+=x) 23 | cnt += freq[y]; 24 | if (cnt > 1) 25 | ma = max(ma, cnt * x); 26 | } 27 | printf("%lli\n", ma); 28 | } 29 | -------------------------------------------------------------------------------- /COCI/coci14c1p2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, maxx = INT_MIN, mixx = INT_MAX, mayy = INT_MIN, miyy = INT_MAX, a, b; 8 | scanf("%i", &n); 9 | while (n--) 10 | { 11 | scanf("%i%i", &a, &b); 12 | maxx = max(a, maxx); 13 | mixx = min(a, mixx); 14 | mayy = max(b, mayy); 15 | miyy = min(b, miyy); 16 | } 17 | int l = max(maxx-mixx, mayy-miyy); 18 | printf("%i\n", l*l); 19 | } 20 | -------------------------------------------------------------------------------- /COCI/coci14c2p2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | cin.tie(0); 8 | cin.sync_with_stdio(0); 9 | int n; 10 | cin>>n; 11 | multiset mp; 12 | string a; 13 | for (int x = 0; x < n; x++) 14 | { 15 | cin>>a; 16 | mp.insert(a); 17 | } 18 | for (int x = 1; x < n; x++) 19 | { 20 | cin>>a; 21 | mp.erase(mp.find(a)); 22 | } 23 | cout<<*mp.begin()<<"\n"; 24 | } 25 | -------------------------------------------------------------------------------- /COCI/coci14c3p1.py: -------------------------------------------------------------------------------- 1 | k = [ 2 | "1QAZ", 3 | "2WSX", 4 | "3EDC", 5 | "4RFV5TGB", 6 | "6YHN7UJM", 7 | "8IK,", 8 | "9OL.", 9 | "0P;/-=[]'", 10 | ] 11 | a = input() 12 | cnt = [0] * 10 13 | for x in a: 14 | for y in range(8): 15 | if x in k[y]: 16 | cnt[y] += 1 17 | break 18 | for i in range(8): 19 | print(cnt[i]) 20 | 21 | -------------------------------------------------------------------------------- /COCI/coci14c6p4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int k, n; 8 | scanf("%i%i", &n, &k); 9 | vector arr(n); 10 | int cc = 1; 11 | for (int x = 0; x < k; x++) 12 | { 13 | int cnt = 0; 14 | int fi = x; 15 | while (fi < n) 16 | fi += k; 17 | fi -= k; 18 | for (int y = fi; y >= 0; y -= k) 19 | arr[y] = cc++, cnt++; 20 | if (cnt > k) 21 | return 0 * printf("-1\n"); 22 | } 23 | for (auto &x : arr) 24 | printf("%i ", x); 25 | printf("\n"); 26 | } 27 | -------------------------------------------------------------------------------- /COCI/coci15c1p3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, a; 8 | scanf("%i", &n); 9 | multiset gg; 10 | int cnt = 0; 11 | for (int x = 0; x < n; x++) 12 | { 13 | scanf("%i", &a); 14 | auto it = gg.find(a); 15 | if (it == gg.end()) 16 | cnt++; 17 | else 18 | gg.erase(it); 19 | gg.insert(a-1); 20 | } 21 | printf("%i\n", cnt); 22 | } 23 | -------------------------------------------------------------------------------- /COCI/coci16c1p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int preTotal, total, months, used; 6 | scanf("%i", &preTotal); 7 | total = preTotal; 8 | scanf("%i", &months); 9 | for (int x = 0; x < months; x++) 10 | { 11 | scanf("%i", &used); 12 | total += preTotal - used; 13 | } 14 | printf("%i", total); 15 | } 16 | -------------------------------------------------------------------------------- /COCI/coi06p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | unsigned long long a, total = 0; 9 | scanf("%i", &n); 10 | vector b; 11 | for (int x = 0; x < n; x++) 12 | { 13 | scanf("%llu", &a); 14 | auto it = upper_bound(b.rbegin(), b.rend(), a); 15 | total += b.size() < it-b.rbegin()+1 ? b.size() : it-b.rbegin()+1; 16 | while (!b.empty() && b.back() < a) 17 | b.pop_back(); 18 | b.push_back(a); 19 | } 20 | printf("%lli", total); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /DMOJ/16bitswonly.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | while (n--) 10 | { 11 | long long a, b, p; 12 | scanf("%lli%lli%lli", &a, &b, &p); 13 | if (a*b == p) 14 | printf("POSSIBLE DOUBLE SIGMA\n"); 15 | else 16 | printf("16 BIT S/W ONLY\n"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /DMOJ/AnotherContest/acc4p0.cpp: -------------------------------------------------------------------------------- 1 | string f() 2 | { 3 | return "All Kill"; 4 | } 5 | -------------------------------------------------------------------------------- /DMOJ/AnotherContest/acc5p1.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | print(2 + n * 2) 3 | -------------------------------------------------------------------------------- /DMOJ/BackFromSummer/bfs17p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, c = 0; 8 | scanf("%i", &n); 9 | string w; 10 | while (n--) 11 | { 12 | cin>>w; 13 | if (w.size() <= 10) c++; 14 | } 15 | printf("%i", c); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /DMOJ/BackFromSummer/bfs19p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, m, ma = INT_MAX, mai = 0, a, c; 8 | scanf("%i%i", &n, &m); 9 | for (int x = 1; x <= n; x++) 10 | { 11 | c = 0; 12 | for (int y = 1; y <= m; y++) 13 | { 14 | scanf("%i", &a); 15 | c += (a == 1 || a == 10); 16 | } 17 | if (c < ma) 18 | ma = c, mai = x; 19 | } 20 | printf("%i\n", mai); 21 | } 22 | -------------------------------------------------------------------------------- /DMOJ/BackToSchool/bts17p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string a; 8 | getline(cin, a); 9 | for (int x = 0; x < a.length(); x++) 10 | { 11 | if (a[x] == ' ' && a[x+1] >= 'A' && a[x+1] <= 'Z') 12 | printf("."); 13 | printf("%c", a[x]); 14 | } 15 | printf("."); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /DMOJ/BackToSchool/bts17p2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int g, e, p; 8 | double pp = 1; 9 | scanf("%i", &g); 10 | while (g--) 11 | { 12 | scanf("%i%i", &e, &p); 13 | pp *= (double)(p-e)/(double)p; 14 | } 15 | printf("%f", pp); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /DMOJ/BackToSchool/bts18p3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, x, m; 8 | long long ans = 0; 9 | scanf("%i%i", &n, &x); 10 | priority_queue buf; 11 | for (int i = 0; i < n; i++) 12 | { 13 | scanf("%i", &m); 14 | buf.push(m); 15 | } 16 | while (x--) 17 | { 18 | int u = buf.top(); 19 | buf.pop(); 20 | ans += u; 21 | if (!u) 22 | ++u; 23 | buf.push(--u); 24 | } 25 | printf("%lli\n", ans); 26 | } 27 | 28 | -------------------------------------------------------------------------------- /DMOJ/BackToSchool/bts18p5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MOD = 998244353; 6 | long long arr[2005], dp[2005][2005]; 7 | 8 | int main() 9 | { 10 | int N; 11 | scanf("%d", &N); 12 | for (int i = 1; i <= N; i++) 13 | scanf("%lld", arr + i); 14 | 15 | for (int n = 0; n <= N; n++) 16 | dp[0][n] = 1; 17 | 18 | for (int k = 1; k <= N; k++) 19 | for (int n = k; n <= N; n++) 20 | dp[k][n] = (dp[k][n - 1] + arr[n] * dp[k - 1][n - 1] % MOD) % MOD; 21 | 22 | for (int i = 1; i <= N; i++) 23 | printf("%lld%c", (dp[i][N] + MOD) % MOD, i==N ? '\n' : ' '); 24 | } 25 | -------------------------------------------------------------------------------- /DMOJ/BackToSchool/bts19p2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int x, y, h, v, t; 8 | scanf("%i%i%i%i%i", &x, &y, &h, &v, &t); 9 | int cx = 0, cy = 0; 10 | while (--t) 11 | { 12 | if (((x-cx > y-cy) || (x - cx == y-cy && h > v)) && cx + 2 < x + h) 13 | cx += 2, cy++; 14 | else 15 | cx++, cy += 2; 16 | if (x <= cx && cx < x + h && y <= cy && cy < y + v) 17 | break; 18 | } 19 | if (x <= cx && cx < x + h && y <= cy && cy < y + v) 20 | printf("YES\n"); 21 | else 22 | printf("NO\n"); 23 | } 24 | -------------------------------------------------------------------------------- /DMOJ/BackToSchool/bts19p3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | long long n; 8 | int m; 9 | scanf("%lli%i", &n, &m); 10 | assert(1 <= n && n <= 1000000000000000000L); 11 | assert(1 <= m && m <= 100); 12 | while (n & (n-1)) 13 | n += n&-n; 14 | printf("%i\n", (__builtin_ctzll(n) + m-1) / m); 15 | } 16 | -------------------------------------------------------------------------------- /DMOJ/GFSSOC/gfssoc16j1.py: -------------------------------------------------------------------------------- 1 | c, n = map(int, input().split()) 2 | 3 | mp = ['TOK', 'English', 'Chemistry', 'Math'] 4 | 5 | arr = [mp.index(input()) + 1 for x in range(c)] 6 | 7 | arr.sort() 8 | 9 | for i, j in enumerate(arr): 10 | n -= j 11 | if n < 0: 12 | print('Go to Metro') 13 | print(i) 14 | break 15 | else: 16 | print('YEA BOI') 17 | 18 | -------------------------------------------------------------------------------- /DMOJ/GFSSOC/gfssoc16j2.hs: -------------------------------------------------------------------------------- 1 | import Control.Monad 2 | main = do 3 | scores <- replicateM 6 (read <$> getLine :: IO Int) 4 | aif <- read <$> getLine :: IO Int 5 | limit <- read <$> getLine :: IO Int 6 | if (sum scores) + 6 * aif >= 6 * limit 7 | then putStrLn "yes" 8 | else putStrLn "no" 9 | -------------------------------------------------------------------------------- /DMOJ/GFSSOC/gfssoc1j1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, m, a; 8 | scanf("%i%i", &n, &m); 9 | int ans = 0; 10 | while (m--) 11 | { 12 | scanf("%i", &a); 13 | ans += (a >= n); 14 | } 15 | printf("%i\n", ans); 16 | } 17 | -------------------------------------------------------------------------------- /DMOJ/GFSSOC/gfssoc1j2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | int xx = 0, yy = 0; 10 | while (n--) 11 | { 12 | string a; 13 | int b; 14 | cin>>a>>b; 15 | if (a[0] == 'N') 16 | yy += b; 17 | else if (a[0] == 'S') 18 | yy -= b; 19 | else if (a[0] =='W') 20 | xx -= b; 21 | else 22 | xx += b; 23 | } 24 | printf("%i %i\n", xx, yy); 25 | } 26 | -------------------------------------------------------------------------------- /DMOJ/GFSSOC/gfssoc1j3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int a, b, c, d, e, f; 8 | scanf("%d:%d:%d", &a, &b, &c); 9 | scanf("%d:%d:%d", &d, &e, &f); 10 | printf("%i\n", (d-a) * 3600 + (e-b) * 60 + (f-c)); 11 | } 12 | -------------------------------------------------------------------------------- /DMOJ/GFSSOC/gfssoc2j1.py: -------------------------------------------------------------------------------- 1 | a = int(input()) 2 | n = int(input()) 3 | for i in range(n): 4 | k = int(input()) 5 | if abs(a-k) <= 100: 6 | print("fite me! >:3") 7 | else: 8 | print("go away! 3:<") 9 | -------------------------------------------------------------------------------- /DMOJ/GFSSOC/gfssoc2j3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | char c; 6 | int i; 7 | scanf("%d", &i); 8 | int a = i; 9 | do 10 | { 11 | scanf("%c", &c); 12 | if (c != '=') 13 | scanf("%d", &i); 14 | if (c == 'P') 15 | a = a + i; 16 | else if (c == 'M') 17 | a = a - i; 18 | } while (c != '='); 19 | printf("%d", a); 20 | } 21 | -------------------------------------------------------------------------------- /DMOJ/GFSSOC/gfssoc2j4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int n, q, a, b; 6 | scanf("%i%i", &n, &q); 7 | int val[n+1]; 8 | val[0] = 0; 9 | for (int x = 1; x <= n; x++) 10 | { 11 | scanf("%i", &val[x]); 12 | val[x] += val[x-1]; 13 | } 14 | for (int x = 0; x < q; x++) 15 | { 16 | scanf("%i%i", &a, &b); 17 | printf("%i\n", val[n] - val[b] + val[a-1]); 18 | } 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /DMOJ/GFSSOC/gfssoc2s3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int n; 6 | double c1, c2; 7 | scanf("%d%lf%lf", &n, &c1, &c2); 8 | printf("%.9f", -c2/c1/n); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /DMOJ/GFSSOC/gfssoc3j1.py: -------------------------------------------------------------------------------- 1 | for i in range(2): 2 | s = input() 3 | if s not in ['red', 'white', 'green']: 4 | print('Boring...') 5 | break 6 | else: 7 | print('Jingle Bells') 8 | -------------------------------------------------------------------------------- /DMOJ/GFSSOC/gfssoc3s3.py: -------------------------------------------------------------------------------- 1 | n = input() 2 | if len(n) > 2: 3 | print(999999998) 4 | else: 5 | if int(n)&1 == 0: 6 | print((2*(10**(int(n)>>1)-1)) % 1000000000) 7 | else: 8 | print((11*10**(int(n)>>1)-2) % 1000000000) 9 | -------------------------------------------------------------------------------- /DMOJ/GFSSOC/gfsspc1p1.py: -------------------------------------------------------------------------------- 1 | import sys 2 | a = list(map(int,sys.stdin.read().split())) 3 | a.sort() 4 | if a[0] + a[1] <= a[2]: 5 | print("Maybe I should go out to sea...") 6 | else: 7 | print("Huh? A triangle?") 8 | -------------------------------------------------------------------------------- /DMOJ/GlobeXCup/globexcup18j0.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, m; 8 | scanf("%i%i", &n, &m); 9 | assert(1 <= m && m <= n && n <= 100000); 10 | long long s = 0; 11 | vector arr(n); 12 | for (auto &x : arr) 13 | scanf("%i", &x), s += x, assert(1 <= x && x <= 100000); 14 | sort(arr.begin(), arr.end()); 15 | for (int x = 0; x < m; x++) 16 | s -= arr[x]; 17 | printf("%lli\n", s); 18 | } 19 | -------------------------------------------------------------------------------- /DMOJ/GlobeXCup/globexcup18j1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | int cnt = 0; 10 | long double a; 11 | for (int x = 0; x < n; x++) 12 | { 13 | scanf("%Lf", &a); 14 | if (a-(int)a < 0.5) 15 | cnt++; 16 | } 17 | printf("%i\n%i\n", n-cnt, cnt); 18 | } 19 | -------------------------------------------------------------------------------- /DMOJ/GlobeXCup/globexcup18j2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | long long sum = 0; 10 | vector arr(n); 11 | for (auto &x : arr) 12 | scanf("%lli", &x), sum += x; 13 | sort(arr.begin(), arr.end()); 14 | int mid = n/2; 15 | if (!(n&1)) 16 | mid--; 17 | if (arr[mid]*n > sum) 18 | printf("Winnie should take the risk\n"); 19 | else 20 | printf("That's too risky\n"); 21 | } 22 | -------------------------------------------------------------------------------- /DMOJ/GlobeXCup/globexcup18j4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const long long MOD = 1000000007; 6 | 7 | long long a, b, c, d, e; 8 | 9 | long long solve(int i) 10 | { 11 | if (!i) 12 | return e; 13 | return (a*solve(i/b)%MOD + c*solve(i/d)%MOD)%MOD; 14 | } 15 | 16 | int main() 17 | { 18 | int n; 19 | scanf("%lli%lli%lli%lli%lli%i", &a, &b, &c, &d, &e, &n); 20 | printf("%lli\n", solve(n)); 21 | } 22 | -------------------------------------------------------------------------------- /DMOJ/GlobeXCup/globexcup18s1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, a; 8 | scanf("%i", &n); 9 | assert(1 <= n && n <= 1000000); 10 | vector source(n+1, true); 11 | for (int x = 1; x <= n; x++) 12 | { 13 | scanf("%i", &a); 14 | assert(0 <= a && a < x); 15 | source[a] = false; 16 | } 17 | int cnt = 0; 18 | for (int x = 1; x <= n; x++) 19 | cnt += source[x]; 20 | printf("%i\n", cnt); 21 | } 22 | 23 | -------------------------------------------------------------------------------- /DMOJ/GlobeXCup/globexcup19j1.py: -------------------------------------------------------------------------------- 1 | n, m, a, b, c = map(int, input().split()) 2 | 3 | X = list(map(int, input().split())) 4 | Y = list(map(int, input().split())) 5 | 6 | for x in Y: 7 | m += [a, -b][1-X[x - 1]] 8 | 9 | print(m) 10 | -------------------------------------------------------------------------------- /DMOJ/GlobeXCup/globexcup19j3.py: -------------------------------------------------------------------------------- 1 | n, k = map(int, input().split()) 2 | 3 | arr = [] 4 | for x in range(n): 5 | name, size = input().split() 6 | arr.append((int(size), name)) 7 | 8 | arr.sort() 9 | 10 | good = [] 11 | 12 | for x in range(n): 13 | if (x+1 < n and arr[x+1][0] - arr[x][0] <= k) or (x > 0 and arr[x][0] - arr[x-1][0] <= k): 14 | continue 15 | good.append(arr[x][1]) 16 | 17 | print(*sorted(good)) 18 | -------------------------------------------------------------------------------- /DMOJ/GlobeXCup/globexcup19j4.py: -------------------------------------------------------------------------------- 1 | from collections import defaultdict 2 | 3 | n, m, k = map(int, input().split()) 4 | 5 | mp = defaultdict(int) 6 | 7 | for x in list(map(int, input().split())): 8 | mp[x] += 1 9 | 10 | arr = sorted(mp.values(), reverse=True) 11 | 12 | ans = 0 13 | 14 | for x in arr: 15 | if k - x <= 0: 16 | ans += k * (k-1) // 2 17 | break 18 | else: 19 | ans += x*(x-1) // 2 20 | k -= x 21 | print(ans) 22 | -------------------------------------------------------------------------------- /DMOJ/GlobeXCup/globexcup19s1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, k, a; 8 | scanf("%i%i", &n, &k); 9 | map mp; 10 | while (n--) 11 | { 12 | scanf("%i", &a); 13 | printf("%i\n", mp[a]); 14 | mp[a]++; 15 | } 16 | printf("%lu\n", mp.size()); 17 | } 18 | -------------------------------------------------------------------------------- /DMOJ/GlobeXCup/globexcup19s2.py: -------------------------------------------------------------------------------- 1 | def calc(f, x): 2 | xx = 1.0 3 | ret = 0.0 4 | for c in f: 5 | ret += c * xx 6 | xx *= x 7 | return ret 8 | 9 | n = int(input()) 10 | f = list(map(int, input().split()))[::-1] 11 | m = int(input()) 12 | g = list(map(int, input().split()))[::-1] 13 | l, r = map(float, input().split()) 14 | 15 | if calc(f, l) < calc(g, l) or calc(f, r) > calc(g, r): 16 | f, g = g, f 17 | 18 | while r - l > 1e-9: 19 | m = (l+r) / 2 20 | if calc(f, m) > calc(g, m): 21 | l = m 22 | else: 23 | r = m 24 | print('{:.10f}'.format((l+r)/2)) 25 | -------------------------------------------------------------------------------- /DMOJ/InahoContest/inaho4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | long double ans = 0; 9 | scanf ("%i", &n); 10 | vector> a (2, vector(n)); 11 | for (auto &x : a) 12 | for (auto &y : x) 13 | scanf ("%Lf", &y); 14 | for (int x = 0; x < n; x++) 15 | ans += pow (a[1][x] - a [0][x], 2); 16 | printf ("%Lf", sqrt (ans)); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /DMOJ/InahoContest/inaho5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | unsigned long long ans = 0; 9 | long long a; 10 | scanf("%i", &n); 11 | while (n--) 12 | { 13 | scanf("%lli", &a); 14 | ans += -a; 15 | } 16 | if (!ans) 17 | printf("0\n"); 18 | else 19 | printf("-%llu\n", ans); 20 | } 21 | -------------------------------------------------------------------------------- /DMOJ/InahoContest/inaho6.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | long long n; 8 | scanf("%lli", &n); 9 | if (n > 140) 10 | printf("0.438283\n0.360592\n"); 11 | else if (!n) 12 | printf("1\n0\n"); 13 | else 14 | { 15 | complex base(0, 1), exponent(0, 1); 16 | for (int x = 1; x < n; x++) 17 | exponent = pow(base, exponent); 18 | printf("%Lf\n%Lf\n", exponent.real(), exponent.imag()); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/mccc1s1.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | a = input().split() 3 | b = input().split() 4 | print(sum(a[i] == b[i] and (not i or a[i-1] != b[i-1]) for i in range(n))) 5 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/mccc2s1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | assert(1 <= n && n <= 100); 10 | vector arr(n); 11 | for (auto &x : arr) 12 | scanf("%i", &x), assert(1 <= x && x <= 1000000000); 13 | sort(arr.begin(), arr.end()); 14 | for (int x = 2; x < n; x++) 15 | assert(arr[x] - arr[x-1] == arr[x-1] - arr[x-2]); 16 | for (int x = 0; x < n; x++) 17 | printf("%i%c", arr[x], (x == n-1 ? '\n' : ' ')); 18 | } 19 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/mccc2s2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | assert(1 <= n && n <= 100000); 10 | string s; 11 | cin>>s; 12 | assert(n == s.length()); 13 | deque ans; 14 | for (auto &x : s) 15 | { 16 | if (ans.empty()) 17 | ans.push_back(x); 18 | else if (x <= ans.front()) 19 | ans.push_front(x); 20 | else 21 | ans.push_back(x); 22 | } 23 | for (auto &x : ans) 24 | printf("%c", x); 25 | printf("\n"); 26 | } 27 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/mockccc15j1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string a, b; 8 | cin>>a>>b; 9 | if (a.size() != 3 || b.size() != 7 || (a != "416" && a != "647" && a != "437")) 10 | cout<<"invalid\n"; 11 | else if (a != "416") 12 | cout<<"valueless\n"; 13 | else 14 | cout<<"valuable\n"; 15 | } 16 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/mockccc15j2.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | p = int(input()) 4 | q = int(input()) - 0.5 5 | w = int(input()) 6 | 7 | s = max(0, math.ceil(100 * (q - p) / w + p)) 8 | 9 | print('DROP THE COURSE' if s > 100 else s) 10 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/mockccc15j3.hs: -------------------------------------------------------------------------------- 1 | import qualified Data.Set 2 | 3 | main = do 4 | n <- read <$> getLine :: IO Int 5 | arr <- map(read :: String -> Int) <$> words <$> getLine 6 | print . Data.Set.size . Data.Set.fromList $ arr 7 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/mockccc2020c1j1.py: -------------------------------------------------------------------------------- 1 | a = list(int(input()) for x in range(4)) 2 | print(min(a)) 3 | print(max(a)) 4 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/mockccc2020c1j2.py: -------------------------------------------------------------------------------- 1 | a = int(input()) 2 | b = int(input()) 3 | c = int(input()) 4 | ma = 0 5 | for x in range(c+1): 6 | for y in range(c+1): 7 | if x+y <= c: 8 | ma = max(ma, a * x + b * y) 9 | print(ma) 10 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/mockccc2020c1j3.py: -------------------------------------------------------------------------------- 1 | a = int(input()) 2 | b = int(input()) 3 | k = a * b 4 | ot = ['00', '25', '50', '75'] 5 | print('{}.{}'.format(k // 4, ot[k % 4])) 6 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/nccc1j1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int n; 7 | scanf("%i", &n); 8 | for (n++; ;n++) 9 | { 10 | string a = to_string(n); 11 | for (auto &x : a) 12 | if (x == '0') 13 | goto un; 14 | break; 15 | un:; 16 | } 17 | cout< 2 | 3 | using namespace std; 4 | 5 | double f(double m, double k, double p, double x){ 6 | return m*x + k*p/m; 7 | } 8 | 9 | int main() { 10 | double k,p,x;cin >> k >> p >> x; 11 | 12 | double best = DBL_MAX; 13 | 14 | for(int m=1;f(m,k,p,x) < best;m++){ 15 | best = f(m,k,p,x); 16 | } 17 | cout.setf(ios::showpoint); 18 | cout << setprecision(3) << fixed << best<<"\n"; 19 | } 20 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/nccc1j5s3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | long long n; 8 | scanf("%lli", &n); 9 | long long lo = 0, hi = n - 1; 10 | while (lo <= hi) 11 | { 12 | int mid = lo + hi >> 1; 13 | if ((n + mid - 1) * (n - mid) < n*(n-1)/2) 14 | hi = --mid; 15 | else 16 | lo = ++mid; 17 | } 18 | printf("%lli\n", n - lo + 1); 19 | } 20 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/nccc2j1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int a, b, c; 8 | scanf("%i + %i = %i", &a, &b, &c); 9 | if (a+b == c) 10 | printf("True\n"); 11 | else 12 | printf("False\n"); 13 | } 14 | 15 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/nccc2j4s2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | vector> aa(3, vector(2)); 8 | for (auto &x : aa) 9 | for (auto &y : x) 10 | scanf("%i", &y); 11 | for (int x = 0; x < 3; x++) 12 | for (int y = 0, f = (x+1)%3, s = (x+2)%3; y < 2; y++) 13 | for (int z = 0; z < 2; z++) 14 | for (int a = 0; a < 2; a++) 15 | if (aa[f][z] == aa[s][a] && aa[f][!z] + aa[s][!a] == aa[x][y] && aa[f][z] + aa[x][!y] == aa[x][y]) 16 | return 0 * printf("YES\n"); 17 | return 0 * printf("NO\n"); 18 | } 19 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/nccc3j1.py: -------------------------------------------------------------------------------- 1 | print(sum(map(int,__import__('sys').stdin.read().split()[1:]))) 2 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/nccc3j2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | bool palin(string a) 6 | { 7 | string b = a; 8 | reverse(b.begin(), b.end()); 9 | return a == b; 10 | } 11 | 12 | int main() 13 | { 14 | string a; 15 | cin>>a; 16 | for (int x = 1; x < a.size(); x++) 17 | { 18 | if (palin(a.substr(0, x)) && palin(a.substr(x))) 19 | return 0 * printf("YES\n"); 20 | } 21 | printf("NO\n"); 22 | } 23 | 24 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/nccc3j3s1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string a; 8 | cin>>a; 9 | vector arr(26); 10 | for (auto &x : a) 11 | arr[x-'a']++; 12 | sort(arr.rbegin(), arr.rend()); 13 | printf("%i\n", a.size()-arr[0]-arr[1]); 14 | } 15 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/nccc3j4s2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | vector ret; 10 | for (int x = 0; x < n; x++) 11 | { 12 | vector cur(n); 13 | for (auto &y : cur) 14 | scanf("%i", &y); 15 | sort(cur.begin(), cur.end()); 16 | ret.push_back(cur[n/2]); 17 | } 18 | sort(ret.begin(), ret.end()); 19 | printf("%i\n", ret[n/2]); 20 | } 21 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/nccc3s4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | long long s = 0, a, b = 0; 9 | scanf("%i", &n); 10 | while (n--) 11 | { 12 | scanf("%lli", &a); 13 | s += a, b = max(b, a); 14 | } 15 | printf("%s", b*2 <= s && !(s&1) ? "YES\n" : "NO\n"); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/nccc5j1.py: -------------------------------------------------------------------------------- 1 | if "CCC" in input(): 2 | print("NO") 3 | else: 4 | print("YES") 5 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/nccc5j2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | vector arr(12); 10 | int a; 11 | while (n--) 12 | { 13 | scanf("%i", &a); 14 | arr[a]++; 15 | } 16 | int ma = 1; 17 | for (int x = 2; x <= 10; x++) 18 | if (arr[ma] < arr[x]) 19 | ma = x; 20 | printf("%i\n", ma); 21 | } 22 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/nccc5j3s1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, x; 8 | scanf("%i%i", &n, &x); 9 | int l = 0, e = 0, g = 0; 10 | while (n--) 11 | { 12 | int a; 13 | scanf("%i", &a); 14 | if (a < x) 15 | l++; 16 | else if (x == a) 17 | e++; 18 | else 19 | g++; 20 | } 21 | if (!e) 22 | printf("0\n"); 23 | else 24 | { 25 | int cnt = 0; 26 | for (int y = 0; y < e; y++) 27 | cnt += (l+y) * (g+e-y-1); 28 | printf("%i\n", cnt); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/nccc5j4s2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | vector arr(n); 10 | for (auto &x : arr) 11 | scanf("%i", &x); 12 | int cnt = 0; 13 | bool sorted = false; 14 | while (!sorted) 15 | { 16 | sorted = true; 17 | for (int x = 0; x < n-1; x++) 18 | if (arr[x] < arr[x+1]) 19 | swap(arr[x], arr[x+1]), cnt++, sorted = false; 20 | } 21 | printf("%i\n", cnt); 22 | } 23 | 24 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/nccc5s4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, k; 8 | scanf("%i%i", &n, &k); 9 | vector a(k); 10 | for (auto &x : a) 11 | scanf("%i", &x); 12 | sort(a.begin(), a.end()); 13 | long long ans = 0; 14 | for (int x = 2; x < a.size(); x++) 15 | ans += ((x == a.size()-1 ? n+1 : a[x+1])-a[x]) * (long long)(a[x-2]); 16 | printf("%lli\n", ans); 17 | } 18 | 19 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/nccc6j1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int a, b; 8 | scanf("%i%i", &a, &b); 9 | if (a > b) 10 | printf("CS452\n"); 11 | else if (b > a) 12 | printf("PHIL145\n"); 13 | } 14 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/nccc6j2.py: -------------------------------------------------------------------------------- 1 | a = input() 2 | b = "pusheen" 3 | print(sum(a[i] != b[i] for i in range(7))) 4 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/nccc6j3.py: -------------------------------------------------------------------------------- 1 | t = int(input()) 2 | for i in range(t): 3 | a, b, n = map(int,input().split()) 4 | for x in range(55): 5 | if (n - a*x) % b == 0 and a*x <= n: 6 | print("YES") 7 | break 8 | else: 9 | print("NO") 10 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/nccc6j5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | long long MOD = 998244353; 6 | 7 | const int MAXN = 1005; 8 | 9 | long long dp[MAXN][MAXN], arr[MAXN]; 10 | 11 | int main() 12 | { 13 | int n, k, a; 14 | scanf("%i%i", &n, &k); 15 | for (int x = 0; x < n; x++) 16 | { 17 | scanf("%i", &a); 18 | arr[a]++; 19 | } 20 | for (int x = 0; x <= n; x++) 21 | dp[0][x] = 1; 22 | for (int x = 1; x <= k; x++) 23 | for (int y = x; y <= n; y++) 24 | dp[x][y] = (dp[x][y-1] + arr[y] * dp[x-1][y-1])%MOD; 25 | printf("%lli\n", dp[k][n] % MOD); 26 | } 27 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/nccc6s1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, a, aa = 0; 8 | scanf("%i", &n); 9 | for (int x = 0; x < n; x++) 10 | { 11 | scanf("%i", &a); 12 | aa += a; 13 | } 14 | printf("%.1lf\n", (double)aa / n); 15 | } 16 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/nccc6s2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, a, mi = INT_MAX, ma = INT_MIN; 8 | scanf("%i", &n); 9 | for (int x = 0; x < n; x++) 10 | { 11 | for (int y = 0; y < n; y++) 12 | { 13 | scanf("%i", &a); 14 | if (a != x * n + y + 1) 15 | mi = min(mi, x), ma = max(ma, x); 16 | } 17 | } 18 | printf("%i\n", ma-mi+1); 19 | } 20 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/nccc7j1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int cnt = 0; 8 | char c; 9 | for (int x = 0; x< 5; x++) 10 | { 11 | scanf(" %c", &c); 12 | if (c == 'P') 13 | cnt++; 14 | } 15 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | vector arr(7); 8 | for (auto &x : arr) 9 | scanf(" %c", &x); 10 | char prev = 0; 11 | int cnt = 0; 12 | for (int x = 0; x < arr.size(); x++) 13 | { 14 | if (arr[x] == 'J' && prev != 'J') 15 | cnt++; 16 | prev = arr[x]; 17 | } 18 | printf("%i\n", cnt); 19 | } 20 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/nccc7j3.hs: -------------------------------------------------------------------------------- 1 | main = do 2 | [n, k] <- map(read :: String -> Integer) <$> words <$> getLine 3 | print (quot (n * k + k) (k + 1)) 4 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/nccc7s1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | long long x, y; 8 | scanf("%lli%lli", &x, &y); 9 | x *= y; 10 | printf("%lli.%i\n", x/2, x%2 ? 5 : 0); 11 | } 12 | -------------------------------------------------------------------------------- /DMOJ/MockCCC/nccc7s2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | long long x, y, x1, y1, x2, y2; 8 | cin>>x>>y>>x1>>y1>>x2>>y2; 9 | double dist = 0; 10 | if (x1 <= x && x <= x2) 11 | dist = min(abs(y1-y), abs(y2-y)); 12 | else if (y1 <= y && y <= y2) 13 | dist = min(abs(x1-x), abs(x2-x)); 14 | else 15 | { 16 | long long xx = min(abs(x1-x), abs(x2-x)); 17 | xx *= xx; 18 | long long yy = min(abs(y1-y), abs(y2-y)); 19 | yy *= yy; 20 | dist = sqrt(xx + yy); 21 | } 22 | printf("%.3lf\n", dist); 23 | } 24 | -------------------------------------------------------------------------------- /DMOJ/MockCCO/ncco4d1p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, a; 8 | scanf("%i", &n); 9 | priority_queue, greater> buf; 10 | long long ans = 0; 11 | while (n--) 12 | { 13 | scanf("%i", &a); 14 | buf.push(a); 15 | } 16 | while (buf.size() > 1) 17 | { 18 | int a = buf.top(); 19 | buf.pop(); 20 | int b = buf.top(); 21 | buf.pop(); 22 | ans += a+b; 23 | buf.push(a+b); 24 | } 25 | printf("%lli\n", ans); 26 | } 27 | -------------------------------------------------------------------------------- /DMOJ/THICC/thicc17p2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | long long totalNum = 0, subtractNum = 0, a; 8 | int n, b, m; 9 | scanf("%i", &n); 10 | scanf("%lli%i%i", &a, &b, &m); 11 | for (int x = 0; x < n; x++) 12 | totalNum += a, subtractNum += (a*a)%1000000007, a = (a*b)%m; 13 | 14 | totalNum %= 1000000007; 15 | totalNum *= totalNum; 16 | totalNum -= (subtractNum%1000000007); 17 | totalNum %= 1000000007; 18 | if (totalNum < 0) totalNum += 1000000007; 19 | 20 | printf("%lli\n", totalNum % 1000000007); 21 | } 22 | -------------------------------------------------------------------------------- /DMOJ/VMSS/vmss15c1p3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int a, b, c, d, n; 8 | scanf("%i%i%i%i", &a, &b, &c, &d); 9 | scanf("%i", &n); 10 | int ans = 0; 11 | long long A, B, C; 12 | while (n--) 13 | { 14 | scanf("%lli%lli%lli", &A, &B, &C); 15 | if (signbit(A*a + B*b + C) != signbit(A*c + B*d + C)) 16 | ans++; 17 | } 18 | printf("%i\n", ans); 19 | } 20 | -------------------------------------------------------------------------------- /DMOJ/VMSS/vmss7wc15c1p1.py: -------------------------------------------------------------------------------- 1 | def f(x): 2 | return sum(map(int,x)) 3 | n = input().split('-') 4 | if f(n[0]) == f(n[1]) == f(n[2]): 5 | print("Goony!") 6 | else: 7 | print("Pick up the phone!") 8 | -------------------------------------------------------------------------------- /DMOJ/VMSS/vmss7wc15c2p1.hs: -------------------------------------------------------------------------------- 1 | import Control.Monad 2 | 3 | f :: Int -> Bool 4 | f x = do 5 | x <= 41 6 | 7 | main = do 8 | n <- read <$> getLine :: IO Int 9 | arr <- replicateM n (read <$> getLine :: IO Int) 10 | print . sum $ map (\x -> if (x-1 < 0 || f(arr!!(x-1))) && f(arr!!x) && (x+1 > n-1 || f(arr!!(x+1))) then 1 else 0) [0..n-1] 11 | -------------------------------------------------------------------------------- /DMOJ/VMSS/vmss7wc15c2p3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | unsigned long long a, total = 0; 9 | scanf("%i", &n); 10 | vector b; 11 | for (int x = 0; x < n; x++) 12 | { 13 | scanf("%llu", &a); 14 | auto it = upper_bound(b.rbegin(), b.rend(), a); 15 | total += b.size() < it-b.rbegin()+1 ? b.size() : it-b.rbegin()+1; 16 | while (!b.empty() && b.back() < a) 17 | b.pop_back(); 18 | b.push_back(a); 19 | } 20 | printf("%lli", total); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /DMOJ/VMSS/vmss7wc15c3p2.hs: -------------------------------------------------------------------------------- 1 | import Control.Monad 2 | import Data.List 3 | 4 | main = do 5 | [n, k] <- map(read :: String -> Int) <$> words <$> getLine 6 | arr <- replicateM n (read <$> getLine :: IO Int) 7 | print(sum(take k (filter (>0) . reverse $ sort arr))) 8 | -------------------------------------------------------------------------------- /DMOJ/VMSS/vmss7wc16c2p2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int a[100001]; 7 | int n, c, d; 8 | string b; 9 | cin>>b; 10 | for (int x = 0; x < b.length(); x++) 11 | { 12 | if (b[x] == 'G') 13 | a[x] = a[x-1] + 1; 14 | else 15 | a[x] = a[x-1]; 16 | } 17 | scanf("%i", &n); 18 | for (int x = 0; x < n; x++) 19 | { 20 | scanf("%i%i", &c, &d); 21 | printf("%i\n", a[d] - a[c-1]); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /DMOJ/VMSS/vmss7wc16c5p4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | vector aa (3); 9 | scanf("%i", &n); 10 | for (auto &x : aa) 11 | scanf("%i", &x); 12 | vector len(n*2, INT_MAX); 13 | len[0] = 0; 14 | for (int x = 0; x <= n; x++) 15 | { 16 | if (len[x] != INT_MAX) 17 | for (auto &y : aa) 18 | len[x+y] = max(len[x+y] == INT_MAX ? 0 : len[x+y], len[x]+1); 19 | } 20 | printf("%i", len[n]); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /DMOJ/VMSS/vmss7wc16c6p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | long long sum = 0; 9 | scanf("%i", &n); 10 | vector> arr(n); 11 | for (auto &x : arr) 12 | scanf("%i%i", &x.first, &x.second); 13 | for (int x = 0; x < n; x++) 14 | { 15 | sum += arr[x].first * arr[(x+1)%n].second; 16 | sum -= arr[x].second * arr[(x+1)%n].first; 17 | } 18 | printf("%i\n", (abs(sum)+1)/2); 19 | } 20 | -------------------------------------------------------------------------------- /DMOJ/Valentines/valentines19j1.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import bisect 3 | vv = [-10**9, 1000, 1200, 1500, 1800, 2200, 3000, 4000] 4 | nn = ["Newbie", "Amateur", "Expert", "Candidate Master", "Master", "Grandmaster", "Target", "Rainbow Master"] 5 | for v in map(int,sys.stdin.read().split()[1:]): 6 | print(nn[bisect.bisect(vv, v)-1]) 7 | -------------------------------------------------------------------------------- /DMOJ/Valentines/valentines19j2.py: -------------------------------------------------------------------------------- 1 | print(sum(240 <= r <= 255 and 0 <= g <= 200 and 95 <= b <= 220 for r, g, b in (map(int,input().split()) for x in range(int(input()))))) 2 | -------------------------------------------------------------------------------- /DMOJ/Valentines/valentines19j3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string s; 8 | cin >> s; 9 | reverse(s.begin(), s.end()); 10 | long long arr[4] = {0, 0, 0, 0}; 11 | for (auto &x : s) 12 | { 13 | if (x == 'e') 14 | arr[3]++; 15 | else if (x == 'v') 16 | arr[2] += arr[3]; 17 | else if (x == 'o') 18 | arr[1] += arr[2]; 19 | else if (x == 'l') 20 | arr[0] += arr[1]; 21 | } 22 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, m, b; 8 | map mp; 9 | map, int> tmp; 10 | scanf("%i", &n); 11 | assert(1 <= n && n <= 100000); 12 | long long ans = 0; 13 | for (int x = 0; x < n; x++) 14 | { 15 | scanf("%i%i", &m, &b); 16 | assert(abs(m) <= 1000000000); 17 | assert(abs(b) <= 1000000000); 18 | ans += x - mp[m]; 19 | mp[m]++; 20 | ans += tmp[{m, b}]; 21 | tmp[{m, b}]++; 22 | } 23 | printf("%lli\n", ans); 24 | } 25 | -------------------------------------------------------------------------------- /DMOJ/a20.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int toDecimal(char c) 6 | { 7 | if (c >= '0' && c <= '9') 8 | return c - '0'; 9 | else 10 | return 10 + c - 'A'; 11 | } 12 | 13 | int main() 14 | { 15 | int n; 16 | string a, b; 17 | scanf("%i", &n); 18 | while (n--) 19 | { 20 | cin>>a; 21 | b = a; 22 | b[2] -= toDecimal(b[2])&1; 23 | if (a == b) 24 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | set> has; 10 | while (n--) 11 | { 12 | int x, y; 13 | scanf("%i%i", &x, &y); 14 | has.insert({x, y}); 15 | } 16 | int ma = 0; 17 | for (auto &x : has) 18 | { 19 | for (auto &y : has) 20 | if (has.count({x.first, y.second}) && has.count({y.first, x.second})) 21 | ma = max(ma, abs(x.first - y.first) * abs(x.second - y.second)); 22 | } 23 | printf("%i\n", ma); 24 | } 25 | -------------------------------------------------------------------------------- /DMOJ/aminusb.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | while (n--) 10 | { 11 | long long a, b; 12 | scanf("%lli%lli", &a, &b); 13 | printf("%lli\n", a-b); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /DMOJ/anct1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, d, a, mi = INT_MAX; 8 | scanf("%i%i", &n, &d); 9 | while (n--) 10 | { 11 | scanf("%i", &a); 12 | if (d/a == (double)d/a) 13 | mi = min(mi, abs(d/a)); 14 | } 15 | if (mi == INT_MAX) printf("This is not the best time for a trip.\n"); 16 | else printf("%i\n", mi); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /DMOJ/bf1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int n; 7 | cin>>n; 8 | vector arr (n); 9 | for (int x = 0; x < n; x++) 10 | cin>>arr[x]; 11 | sort(arr.begin(), arr.end()); 12 | for (int x = 0; x < n; x++) 13 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | for (int x = 1; x <= n; x++) 10 | printf("%i%c", x, " \n"[x == n]); 11 | } 12 | 13 | -------------------------------------------------------------------------------- /DMOJ/bf1hard.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int N; 7 | cin>>N; 8 | int arr[N]; 9 | for (int i = 0; i < N; i++) 10 | cin>>arr[i]; 11 | sort(arr, arr+N); 12 | for (int i = 0; i < N; i++) 13 | cout<> 16)) & 0x00000000ffff0000; 6 | n ^= (tmp ^ (tmp << 16)); 7 | tmp = (n ^ (n >> 8)) & 0x0000ff000000ff00; 8 | n ^= (tmp ^ (tmp << 8)); 9 | tmp = (n ^ (n >> 4)) & 0x00f000f000f000f0; 10 | n ^= (tmp ^ (tmp << 4)); 11 | tmp = (n ^ (n >> 2)) & 0x0c0c0c0c0c0c0c0c; 12 | n ^= (tmp ^ (tmp << 2)); 13 | tmp = (n ^ (n >> 1)) & 0x2222222222222222; 14 | n ^= (tmp ^ (tmp << 1)); 15 | return n | (n << 1); 16 | } 17 | -------------------------------------------------------------------------------- /DMOJ/bobsrocks.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | assert 1 <= n <= 10**6 3 | mp = [0] * 51 4 | arr = list(map(int, input().split(' '))) 5 | assert len(arr) == n 6 | assert all(0 <= x <= 50 for x in arr) 7 | 8 | for i in arr: 9 | mp[i] += 1 10 | 11 | ma = 0 12 | for i in range(len(mp)): 13 | if mp[ma] * ma < mp[i] * i: 14 | ma = i 15 | 16 | print(ma) 17 | -------------------------------------------------------------------------------- /DMOJ/ccoprep16c2q2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | vector dp(32, 0); 8 | int n, a, t = 0; 9 | scanf("%i", &n); 10 | while (n--) 11 | { 12 | scanf("%i", &a); 13 | int b = 0; 14 | for (int y = 0; y < 32; y++) 15 | if(a & (1< 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | for (int x = 0; x < n/2; x++) 10 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, k; 8 | scanf("%i%i", &n, &k); 9 | vector arr(n); 10 | for (auto &x : arr) 11 | scanf("%i", &x); 12 | sort(arr.begin(), arr.end()); 13 | int ma = 0; 14 | int l = 0, r = 0; 15 | while (r < n) 16 | { 17 | while (arr[r]-arr[l] > k) 18 | ++l; 19 | ma = max(ma, r-l+1); 20 | r++; 21 | } 22 | printf("%i\n", ma); 23 | } 24 | -------------------------------------------------------------------------------- /DMOJ/denoun.py: -------------------------------------------------------------------------------- 1 | import string 2 | n=int(input()) 3 | for i in range(n): 4 | print(sum(a[0] in string.ascii_uppercase for a in input().split())) 5 | 6 | -------------------------------------------------------------------------------- /DMOJ/ectf20p1.txt: -------------------------------------------------------------------------------- 1 | ctf{096058ecec0caff7865d13a6169b5b34} 2 | -------------------------------------------------------------------------------- /DMOJ/ectf20p10.txt: -------------------------------------------------------------------------------- 1 | ctf{sm4ll_prim3s_4r3_4lways_nice_db6} 2 | -------------------------------------------------------------------------------- /DMOJ/ectf20p11.txt: -------------------------------------------------------------------------------- 1 | ctf{AES_is_on1y_secure_if_prop3r1y_used} 2 | -------------------------------------------------------------------------------- /DMOJ/ectf20p12.txt: -------------------------------------------------------------------------------- 1 | ctf{a3s_strik3s_ag4in_2a4e512f18bec0} 2 | -------------------------------------------------------------------------------- /DMOJ/ectf20p13.txt: -------------------------------------------------------------------------------- 1 | ctf{une3d3d_recursive_functi0ns_cd3b} 2 | -------------------------------------------------------------------------------- /DMOJ/ectf20p14.txt: -------------------------------------------------------------------------------- 1 | ctf{D3compiling_Ex3cut4bl3s_Is_EZ_5e} 2 | -------------------------------------------------------------------------------- /DMOJ/ectf20p15.txt: -------------------------------------------------------------------------------- 1 | ctf{is_this_dp_in_a_ctf_c7144848b0} 2 | -------------------------------------------------------------------------------- /DMOJ/ectf20p16.txt: -------------------------------------------------------------------------------- 1 | ctf{cyc1es_in_python_ar3_fun_03278a3} 2 | -------------------------------------------------------------------------------- /DMOJ/ectf20p17.txt: -------------------------------------------------------------------------------- 1 | ctf{sup3r_s3cur3_prng_453f75a523ae3c} 2 | -------------------------------------------------------------------------------- /DMOJ/ectf20p18.txt: -------------------------------------------------------------------------------- 1 | ctf{3xp1oting_form4t_strings_is_ez_5} 2 | -------------------------------------------------------------------------------- /DMOJ/ectf20p19.txt: -------------------------------------------------------------------------------- 1 | ctf{1ove_c411ing_r4ndom_functions_84} 2 | -------------------------------------------------------------------------------- /DMOJ/ectf20p2.txt: -------------------------------------------------------------------------------- 1 | ctf{insp3ct_3lement_is_aw3some_fb5a9} 2 | -------------------------------------------------------------------------------- /DMOJ/ectf20p3.txt: -------------------------------------------------------------------------------- 1 | ctf{fi1e_diffs_4re_us3ful_a19fafbf51} 2 | -------------------------------------------------------------------------------- /DMOJ/ectf20p4.txt: -------------------------------------------------------------------------------- 1 | ctf{c0mpr3ss_EV3RYTHING_c0f35f5e3e40} 2 | -------------------------------------------------------------------------------- /DMOJ/ectf20p5.txt: -------------------------------------------------------------------------------- 1 | ctf{colours_560fb7e05836e11fb24f3d6f} 2 | -------------------------------------------------------------------------------- /DMOJ/ectf20p6.txt: -------------------------------------------------------------------------------- 1 | ctf{qu3ry_string_cr3d3nti4ls_4r3_sad} 2 | -------------------------------------------------------------------------------- /DMOJ/ectf20p7.txt: -------------------------------------------------------------------------------- 1 | ctf{m0rse_code_for_th3_win_2e0e30aa0} 2 | -------------------------------------------------------------------------------- /DMOJ/ectf20p8.txt: -------------------------------------------------------------------------------- 1 | ctf{wiresh4rk_can_do_anything_0838d3} 2 | -------------------------------------------------------------------------------- /DMOJ/ectf20p9.txt: -------------------------------------------------------------------------------- 1 | ctf{all_the_b4ses_4c7128eea55675dd43} 2 | -------------------------------------------------------------------------------- /DMOJ/factorial.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | 6 | int main() 7 | { 8 | vector fac (34,1); 9 | for (unsigned long long x = 1; x < 34; x++) 10 | fac[x] = (fac[x-1]*x)%4294967296; 11 | unsigned long long n, a; 12 | scanf("%llu", &n); 13 | while (n--) 14 | { 15 | scanf("%llu", &a); 16 | if (a > 33) printf("0\n"); 17 | else printf("%llu\n", fac[a]); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /DMOJ/fastbit.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int setbits (unsigned long long a) 6 | { 7 | bitset<64> aa (a); 8 | return aa.count(); 9 | } 10 | -------------------------------------------------------------------------------- /DMOJ/hailstone.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int y; 8 | cin >> y; 9 | int c = 0; 10 | if (y!= 1) 11 | { 12 | do 13 | { 14 | if (y % 2 == 1) 15 | y = y * 3 + 1; 16 | else 17 | y = y/ 2; 18 | c++; 19 | } 20 | while (y > 1); 21 | } 22 | cout < 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, k; 8 | return 0 * scanf("%i%i", &n, &k) * printf("%i", n < k ? k-n : min(k-(n%k), n%k)); 9 | } 10 | -------------------------------------------------------------------------------- /DMOJ/hardquestion.py: -------------------------------------------------------------------------------- 1 | g = float(input()) 2 | c = float(input()) 3 | t = float(input()) 4 | 5 | t0 = (-c + (c**2 + 2 * g * c * t)**0.5) / g 6 | print(g * t0**2 / 2) 7 | print(g * t0) 8 | -------------------------------------------------------------------------------- /DMOJ/helloworld.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | cout << "Hello, World!"; 8 | } 9 | -------------------------------------------------------------------------------- /DMOJ/ichb2017p2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | const unsigned long long mod = 666013; 4 | 5 | int tmpa[1000001], tmpb[1000001]; 6 | 7 | int main() 8 | { 9 | int n, q, a; 10 | scanf("%i%i", &n, &q); 11 | for (int x = 0, pow10 = 1, pow3 = 1; x <= n; x++, pow10*=10, pow10%= mod, pow3*=3, pow3%=mod) 12 | tmpa[x] = 9*pow10%mod, tmpb[x] = 2*pow3%mod; 13 | while (q--) 14 | { 15 | scanf("%i", &a); 16 | int b = (a-1)/2; 17 | printf("%llu\n", (20*mod + tmpa[a-1] - (tmpa[b] + tmpb[a-1] - tmpb[b])) % mod); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /DMOJ/ics4p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string a; 8 | cin>>a; 9 | sort(a.begin(), a.end()); 10 | do 11 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int a, b; 8 | scanf("%x%x", &a, &b); 9 | if (a + b > 0x3f3f3f3f) 10 | printf("Yes\n"); 11 | else 12 | printf("No\n"); 13 | } 14 | 15 | -------------------------------------------------------------------------------- /DMOJ/joshua.py: -------------------------------------------------------------------------------- 1 | r, c = map(int, input().split()) 2 | print(pow(2, (r - 1) * (c - 1), 10**9+7)) 3 | -------------------------------------------------------------------------------- /DMOJ/largeperm.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, k; 8 | scanf("%i%i", &n, &k); 9 | vector a(100005), b(100005); 10 | for (int x = 1; x <= n; x++) 11 | { 12 | scanf("%i", &a[x]); 13 | b[a[x]] = x; 14 | } 15 | for (int x = n; x > 0 && k; x--) 16 | if (b[x] ^ (n-x+1)) 17 | swap(a[b[x]], a[n-x+1]), swap(b[a[b[x]]], b[a[n-x+1]]), k--; 18 | for (int x = 1; x <= n; x++) 19 | printf("%i ", a[x]); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /DMOJ/ludipq.py: -------------------------------------------------------------------------------- 1 | print('''1 2 | 3 3 | 3 4 | 2 5 | 2 6 | 1 7 | 3 8 | 3 9 | 3 10 | 1 11 | 2 12 | 3 13 | 1 14 | 1 15 | 1''') 16 | -------------------------------------------------------------------------------- /DMOJ/miraclesort.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | long long a; 9 | scanf("%i", &n); 10 | while (n--) 11 | { 12 | scanf("%lli", &a); 13 | printf("%lli\n", a); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /DMOJ/mnyc17p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, a, ma = 0; 8 | vector sq (31); 9 | scanf("%i", &n); 10 | while (n--) 11 | { 12 | scanf("%i", &a); 13 | sq[log2(a)]++; 14 | ma = max(ma, (int)log2(a)); 15 | } 16 | for (int x = 0; x < 31; x++) 17 | { 18 | sq[x+1]+=sq[x]>>1; 19 | if (sq[x+1] && x+1 > ma) 20 | ma = x+1; 21 | } 22 | printf("%lli", 1LL< 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, m; 8 | scanf("%i%i", &n, &m); 9 | n%=m; 10 | if (n < 0) n += m; 11 | printf("%i", n); 12 | } 13 | -------------------------------------------------------------------------------- /DMOJ/mockingspongebob.py: -------------------------------------------------------------------------------- 1 | import string 2 | 3 | n = int(input()) 4 | for i in range(n): 5 | s = input() 6 | t = '' 7 | cur = 0 8 | for x in s: 9 | if x in string.ascii_letters: 10 | t += x.upper() if cur else x.lower() 11 | cur ^= 1 12 | else: 13 | t += x 14 | print(t) 15 | -------------------------------------------------------------------------------- /DMOJ/modinv.py: -------------------------------------------------------------------------------- 1 | def gcd(a, b): 2 | if not a: 3 | return b, 0, 1 4 | g, xx, yy = gcd(b%a, a) 5 | return g, yy - b//a*xx, xx 6 | 7 | n, m = map(int,input().split()) 8 | g, x, y = gcd(n, m) 9 | print(x%m) 10 | -------------------------------------------------------------------------------- /DMOJ/mwc15c1p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, m, s, t = 0, c = 0; 8 | scanf("%i", &n); 9 | vector aa; 10 | while (n--) 11 | { 12 | scanf("%i%i", &m, &s); 13 | aa.push_back(m*60 + s); 14 | } 15 | sort(aa.begin(), aa.end()); 16 | scanf("%i%i", &m, &s); 17 | s += m*60; 18 | while (t <= s && c < aa.size()) 19 | t += aa[c++]; 20 | c -= t > s; 21 | printf("%i", c); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /DMOJ/mwc15c1p5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int compat(string a) 6 | { 7 | int val = 0; 8 | for (int x = 0; x < a.size(); x++) 9 | val += pow((a[x]-'@')%10, x % 4 + 1); 10 | val %= 10; 11 | if (!val) val = 10; 12 | return val; 13 | } 14 | 15 | int main() 16 | { 17 | string a, b; 18 | cin>>a>>b; 19 | for (auto &x : a) 20 | x = toupper(x); 21 | for (auto &x : b) 22 | x = toupper(x); 23 | printf("%i", compat(a)+compat(b)); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /DMOJ/mwc15c2p2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | vector arr(n); 10 | for (auto &x : arr) 11 | scanf("%i", &x); 12 | vector> buf; 13 | for (int x = 0; x < n; x++) 14 | { 15 | while (!buf.empty() && buf.back().first <= arr[x]) 16 | buf.pop_back(); 17 | printf("%i ", buf.empty() ? x : x - buf.back().second); 18 | buf.push_back({arr[x], x}); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /DMOJ/naq16g.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | string in; 8 | cin>>in; 9 | double a = 0, b = in.length(), i = 0; 10 | while (a < b) a += log10(++i); 11 | {} 12 | if(in == "1") 13 | { 14 | cout<<"1"; 15 | }else if(in == "2") 16 | { 17 | cout<<"2"; 18 | }else 19 | { 20 | cout<<--i; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /DMOJ/odd.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int n, a, b = 0; 7 | scanf("%i", &n); 8 | while (n--) 9 | { 10 | scanf("%i", &a); 11 | b ^= a; 12 | } 13 | printf("%i\n", b); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /DMOJ/oly18decp5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, x, y; 8 | scanf("%i%i%i", &n, &x, &y); 9 | int ans = 0; 10 | while (true) 11 | { 12 | ans++; 13 | int m = x+y>>1; 14 | if (m < n) 15 | x = m; 16 | else if(m > n) 17 | y = m; 18 | else 19 | break; 20 | } 21 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | vector aa(100005); 8 | int n, k, r, a, b = 0, c = 0; 9 | scanf("%i%i%i", &n, &k, &r); 10 | while (k--) 11 | { 12 | scanf("%i", &a); 13 | aa[a]++; 14 | } 15 | for (int x = 1; x <= r; x++) 16 | b += aa[x]; 17 | for (int x = 1; x+r-1 <= n; x++) 18 | { 19 | int i = x+r-1; 20 | for (; b < 2; c++, b++) 21 | { 22 | while (aa[i]) 23 | i--; 24 | aa[i]++; 25 | } 26 | b += aa[x+r]-aa[x]; 27 | } 28 | printf("%i\n", c); 29 | } 30 | -------------------------------------------------------------------------------- /DMOJ/phantom1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | bool isPrime(int a) 6 | { 7 | for (int x = 2; x < sqrt(a)+1; x++) 8 | if (!(a%x)) 9 | return false; 10 | return true; 11 | } 12 | 13 | int main() 14 | { 15 | int n, a, b, t; 16 | scanf("%i", &n); 17 | while (n--) 18 | { 19 | scanf("%i%i", &a, &b); 20 | t = 0; 21 | while (a < b) 22 | t += isPrime(a++); 23 | printf("%i\n", t); 24 | } 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /DMOJ/pib20p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, v, cnt = 0; 8 | scanf("%i", &n); 9 | while (n--) 10 | { 11 | scanf("%i", &v); 12 | cnt += v > 0; 13 | } 14 | printf("%i\n", cnt); 15 | } 16 | -------------------------------------------------------------------------------- /DMOJ/pib20p2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | long long t; 8 | scanf("%lli", &t); 9 | long long ans = t * 2; 10 | for (int x = 0; x < 100; x++) 11 | ans = (t + ans / 7) * 2; 12 | for (int x = 100; x >= 0; x--) 13 | if ((ans + x) / 2 - (ans + x) / 7 <= t) 14 | ans += x; 15 | printf("%lli\n", ans); 16 | } 17 | -------------------------------------------------------------------------------- /DMOJ/postfix.py: -------------------------------------------------------------------------------- 1 | cur = input().split() 2 | buf = [] 3 | 4 | for x in cur: 5 | try: 6 | x = float(x) 7 | except ValueError: 8 | b = buf.pop() 9 | a = buf.pop() 10 | if x == '+': 11 | c = a + b 12 | elif x == '-': 13 | c = a - b 14 | elif x == '/': 15 | c = a / b 16 | elif x == '*': 17 | c = a * b 18 | elif x == '%': 19 | c = a % b 20 | elif x == '^': 21 | c = a ** b 22 | buf.append(c) 23 | else: 24 | buf.append(x) 25 | 26 | assert len(buf) == 1 27 | 28 | print(buf[0]) 29 | -------------------------------------------------------------------------------- /DMOJ/ppwindsor18p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | long long sum = 0; 10 | for (int x = 1; x <= n; x++) 11 | { 12 | if (n%x == 0) 13 | sum += x; 14 | } 15 | printf("%lli\n", sum); 16 | } 17 | -------------------------------------------------------------------------------- /DMOJ/ppwindsor18p2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int w, h; 8 | scanf("%i%i", &w, &h); 9 | for (int x = 0; x < h; x++) 10 | { 11 | for (int y = 0; y < w; y++) 12 | printf("%i", (x+y)&1); 13 | printf("\n"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /DMOJ/ppwindsor18p4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, m; 8 | scanf("%i%i", &n, &m); 9 | vector a(n); 10 | vector b(m); 11 | for (auto &x : a) 12 | scanf("%i", &x); 13 | for (auto &x : b) 14 | scanf("%i", &x); 15 | long long ma = 0, mai = 0; 16 | sort(a.begin(), a.end()); 17 | for (auto &x : a) 18 | { 19 | long long cur = INT_MAX; 20 | for (auto &y : b) 21 | cur = min(cur, (long long)abs(y-x)); 22 | if (cur > ma) 23 | ma = cur, mai = x; 24 | } 25 | printf("%lli\n", mai); 26 | } 27 | -------------------------------------------------------------------------------- /DMOJ/ppwindsor18p5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int nth(int m) 6 | { 7 | long long st = 1, len = 1, cnt = 9, n = m; 8 | while (n > len*cnt) 9 | { 10 | n -= len*cnt; 11 | len++; 12 | cnt *= 10; 13 | st *= 10; 14 | } 15 | st += (n-1)/len; 16 | return to_string(st)[(n-1)%len]-'0'; 17 | } 18 | 19 | int main() 20 | { 21 | int n; 22 | scanf("%i", &n); 23 | printf("%i\n", nth(n)); 24 | } 25 | -------------------------------------------------------------------------------- /DMOJ/ppwindsor18p6.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int nth(int m) 6 | { 7 | long long st = 1, len = 1, cnt = 9, n = m; 8 | while (n > len*cnt) 9 | { 10 | n -= len*cnt; 11 | len++; 12 | cnt *= 10; 13 | st *= 10; 14 | } 15 | st += (n-1)/len; 16 | return to_string(st)[(n-1)%len]-'0'; 17 | } 18 | 19 | int main() 20 | { 21 | int n; 22 | scanf("%i", &n); 23 | printf("%i\n", nth(n)); 24 | } 25 | -------------------------------------------------------------------------------- /DMOJ/ppwindsor18p7.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | long long dp[1005]; 6 | 7 | int main() 8 | { 9 | int n; 10 | scanf("%i", &n); 11 | vector v(n+1); 12 | for (int x = 1; x <= n; x++) 13 | scanf("%i", &v[x]); 14 | for (int x = 1; x <= n; x++) 15 | { 16 | dp[x] = dp[x-1]; 17 | for (int y = 1; y <= x; y++) 18 | { 19 | dp[x] = max(dp[x-y]+v[y], dp[x]); 20 | } 21 | } 22 | printf("%lli\n", dp[n]); 23 | } 24 | -------------------------------------------------------------------------------- /DMOJ/primefactor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | void prime(int n) 6 | { 7 | int root = ceil(sqrt(n))+3; 8 | for (int x = 2; x < root; x++) 9 | { 10 | while (!(n%x)) 11 | { 12 | printf("%i ", x); 13 | n/=x; 14 | } 15 | } 16 | if (n >= 2) printf("%i", n); 17 | } 18 | 19 | int main() 20 | { 21 | int n, a; 22 | scanf("%i", &n); 23 | while (n--) 24 | { 25 | scanf("%i", &a); 26 | prime(a); 27 | printf("\n"); 28 | } 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /DMOJ/pulse.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, s, t; 8 | scanf("%i%i%i", &n, &s, &t); 9 | int cnt = 0, a; 10 | for (int x = 0; x < n; x++) 11 | { 12 | scanf("%i", &a); 13 | if (s <= a*2 && a*2 <= t) 14 | cnt++; 15 | } 16 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string a; 8 | cin>>a; 9 | for (int x = 0; x < a.length()-3; x++) 10 | if (a.substr(x, 4) == "java") 11 | return 0 * printf("%i\n", x); 12 | printf("%u\n", a.length()); 13 | } 14 | -------------------------------------------------------------------------------- /DMOJ/pwindsor18p2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | long long mi = LONG_MIN, mix = 0, miy = 0; 10 | for (int x = 0; x < n; x++) 11 | { 12 | long long a, b; 13 | scanf("%lli%lli", &a, &b); 14 | if (a*a+b*b > mi) 15 | mi = a*a+b*b, mix = a, miy = b; 16 | } 17 | printf("%lli %lli\n", mix, miy); 18 | } 19 | -------------------------------------------------------------------------------- /DMOJ/pwindsor18p3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | bool prime(int n) 6 | { 7 | for (int x = 2; x <= sqrt(n); x++) 8 | if (n%x == 0) 9 | return false; 10 | return true; 11 | } 12 | 13 | int main() 14 | { 15 | int n; 16 | scanf("%i", &n); 17 | int cnt = 0, a; 18 | while (n--) 19 | { 20 | scanf("%i", &a); 21 | cnt += !prime(a); 22 | } 23 | printf("%i\n", cnt); 24 | } 25 | -------------------------------------------------------------------------------- /DMOJ/pwindsor18p4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string a, b; 8 | vector f(266), g(256); 9 | cin>>a>>b; 10 | for (auto &x : a) 11 | f[x]++; 12 | for (auto &x : b) 13 | g[x]++; 14 | for (int x = 32; x < 266; x++) 15 | if (f[x] ^ g[x]) 16 | return 0 * printf("%c\n", x); 17 | } 18 | -------------------------------------------------------------------------------- /DMOJ/pwindsor18p5.py: -------------------------------------------------------------------------------- 1 | dp = [0]*1010 2 | 3 | n = int(input()) 4 | dp[1] = 1 5 | for x in range(2, n+1): 6 | dp[x] = x 7 | for y in range(1, x): 8 | dp[x] = max(dp[x], dp[x-y]*y) 9 | print(dp[n]%1000000007) 10 | -------------------------------------------------------------------------------- /DMOJ/pwindsor18p7.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | struct num 6 | { 7 | string a; 8 | friend bool operator<(num &aa, num &bb) 9 | { 10 | return aa.a+bb.a < bb.a+aa.a; 11 | } 12 | } 13 | ; 14 | int main() 15 | { 16 | int n; 17 | scanf("%i", &n); 18 | vector aa(n); 19 | for (auto &x : aa) 20 | cin>>x.a; 21 | sort(aa.rbegin(), aa.rend()); 22 | for (auto &x : aa) 23 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int a, b; 8 | scanf("%i%i", &a, &b); 9 | if (a % b == 0) 10 | printf("yes %i\n", a / b); 11 | else 12 | { 13 | int c = b; 14 | while (a % b) 15 | b++; 16 | printf("no %i\n", b-c); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /DMOJ/rgss1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int a, b, c; 8 | scanf("%i%i%i", &a, &b, &c); 9 | vector cc (c+2000); 10 | cc[0] = true; 11 | for (int x = 0; x <= c; x++) 12 | if (cc[x]) 13 | cc[x+a] = cc[x+b] = true; 14 | for (int x = c; x >= 0; x--) 15 | if (cc[x]) 16 | {printf("%i", x); return 0;} 17 | } 18 | -------------------------------------------------------------------------------- /DMOJ/rgss2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int mix = INT_MAX, maxx = -INT_MAX, miy = INT_MAX, may = -INT_MAX, n, x, y; 8 | scanf("%i", &n); 9 | while (n--) 10 | { 11 | scanf("%i%i", &x, &y); 12 | mix = min(mix, x), maxx = max(maxx, x); 13 | miy = min(miy, y), may = max(may, y); 14 | } 15 | printf("%i", (maxx-mix)*(may-miy)); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /DMOJ/rte16j1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string s; 8 | getline(cin, s); 9 | int l = 0, cur = 0, ma = 0; 10 | for (auto &x : s) 11 | { 12 | if (x == 'L') 13 | l++, cur++; 14 | else if (x != ' ') 15 | ma = max(ma, cur), cur = 0; 16 | } 17 | ma = max(ma, cur); 18 | printf("%i %i\n", l, ma); 19 | } 20 | -------------------------------------------------------------------------------- /DMOJ/scroll.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | printf("0"); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /DMOJ/seed1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | map mp; 8 | for (auto x : "BFTLC") 9 | mp[x]++; 10 | mp['\0'] = 0; 11 | string s; 12 | cin>>s; 13 | for (auto &x : s) 14 | mp[x]--; 15 | bool d = false; 16 | for (auto &x : mp) 17 | if (x.second > 0) 18 | printf("%c", x.first), d = true; 19 | if (!d) 20 | printf("NO MISSING PARTS\n"); 21 | } 22 | -------------------------------------------------------------------------------- /DMOJ/seed2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | long long a = 1073741824, b = a>>1; 8 | string c; 9 | do 10 | { 11 | cout<>c; 13 | a += (c == "SINKS" ? 1 : -1) * b; 14 | a = min(a, 2000000000LL); 15 | b>>=1; 16 | } 17 | while (c != "OK"); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /DMOJ/seed3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int i, n, j, a, b, k, c = 0; 8 | scanf("%i%i%i", &i, &n, &j); 9 | vector aa(i+2); 10 | while(j--) 11 | { 12 | scanf("%i%i%i", &a, &b, &k); 13 | aa[a]+=k; 14 | aa[b+1]-=k; 15 | } 16 | for (int x = 1; x < aa.size() - 1; x++) 17 | { 18 | aa[x] += aa[x-1]; 19 | c += aa[x] < n; 20 | } 21 | printf("%i", c); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /DMOJ/seq0.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 1000005; 6 | 7 | long long dp[MAXN]; 8 | 9 | int main() 10 | { 11 | int n, a; 12 | scanf("%i", &n); 13 | for (int x = 2; x <= n+1; x++) 14 | { 15 | scanf("%i", &a); 16 | dp[x] = max(dp[x-2] + a, dp[x-1]); 17 | } 18 | printf("%lli\n", dp[n+1]); 19 | } 20 | -------------------------------------------------------------------------------- /DMOJ/seq1.py: -------------------------------------------------------------------------------- 1 | print((8 * (pow(2,int(input()),1000000007) - 1) + 3) % 1000000007) 2 | -------------------------------------------------------------------------------- /DMOJ/seq3.py: -------------------------------------------------------------------------------- 1 | n,k=map(int,input().split()) 2 | for i in range(n): 3 | if i < n-1: 4 | print(0, end=" ") 5 | else: 6 | print(k) 7 | -------------------------------------------------------------------------------- /DMOJ/set.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | vector arr(n); 10 | for (auto &x : arr) 11 | scanf("%i", &x); 12 | sort(arr.begin(), arr.end()); 13 | arr.erase(unique(arr.begin(), arr.end()), arr.end()); 14 | printf("%lu\n", arr.size()); 15 | } 16 | -------------------------------------------------------------------------------- /DMOJ/shortest1.cpp: -------------------------------------------------------------------------------- 1 | while 1:1 2 | -------------------------------------------------------------------------------- /DMOJ/si17c1p2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, k; 8 | long long mm = 0; 9 | scanf("%i%i", &n, &k); 10 | vector dp(n); 11 | for (int x = 0; x < n; x++) 12 | { 13 | scanf("%i", &dp[x]); 14 | if (x > k) 15 | dp[x] += dp[x-k-1]; 16 | for (int y = max(x-k, 0); y < x; y++) 17 | dp[x] = max(dp[x], dp[y]); 18 | mm = max(mm, dp[x]); 19 | } 20 | printf("%lli", mm); 21 | } 22 | -------------------------------------------------------------------------------- /DMOJ/si17c1p8.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, t, cc = 0; 8 | scanf("%i%i", &n, &t); 9 | int c[n]; 10 | for (auto &x : c) 11 | scanf("%i", &x); 12 | for (int x = 0; x < (1<>y)&1) 17 | s += c[y]; 18 | cc += s == t; 19 | } 20 | printf("%i", cc); 21 | } 22 | -------------------------------------------------------------------------------- /DMOJ/stnbd1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, ma, a; 8 | scanf("%i", &n); 9 | scanf("%i", &ma); 10 | while (--n) 11 | { 12 | scanf("%i", &a); 13 | if (a >= ma) 14 | return 0 * printf("NO\n"); 15 | } 16 | printf("YES\n"); 17 | } 18 | -------------------------------------------------------------------------------- /DMOJ/tc18summera.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | long long n, b, a; 8 | scanf("%lli%lli%lli", &n, &b, &a); 9 | if (!b) 10 | return 0 * printf("%lli\n", n*a); 11 | long long x = (b*n-a)/(2*b); 12 | printf("%lli\n", max((a+b*x)*(n-x), (a+b*(x+1))*(n-(x+1)))); 13 | } 14 | -------------------------------------------------------------------------------- /DMOJ/tc18summerb.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int c, d, e; 8 | scanf("%i%i%i", &c, &d, &e); 9 | if (d&e) 10 | return 0 * printf("0\n"); 11 | long long cc = 1; 12 | for (int x = 0; x < 30; x++) 13 | { 14 | if (d>>x&1) 15 | continue; 16 | if (!(e>>x&1)) 17 | continue; 18 | if (c>>x&1) 19 | cc *= 2; 20 | } 21 | printf("%lli\n", cc); 22 | } 23 | -------------------------------------------------------------------------------- /DMOJ/tc18summerf.py: -------------------------------------------------------------------------------- 1 | s = int(input()) 2 | t = int(input()) 3 | if s < t: 4 | print("T") 5 | elif t < s: 6 | print("S") 7 | else: 8 | print("E") 9 | -------------------------------------------------------------------------------- /DMOJ/tc19summere.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | long long calc(long long n, long long t) 6 | { 7 | long long tt = t/2; 8 | long long ans = n + 2*(((n - tt - 1) * tt) + tt * (tt + 1)/2); 9 | if (t&1) 10 | ans += n - tt - 1; 11 | return ans; 12 | } 13 | 14 | int main() 15 | { 16 | int n, t; 17 | scanf("%i%i", &n, &t); 18 | long long ans = calc(n, t-1) * (n / t); 19 | ans += calc(n, n%t - 1); 20 | cout< 2 | 3 | int main() 4 | { 5 | printf("Hello, TKP!\n"); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /DMOJ/toosimple.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define put(...) puts(#__VA_ARGS__) 4 | 5 | int main() 6 | { 7 | put(Hello, World!); 8 | } 9 | -------------------------------------------------------------------------------- /DMOJ/tsoc16c1p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | int l, a, b, f; 10 | while (n--) 11 | { 12 | scanf("%i%i%i%i", &l, &a, &b, &f); 13 | int t = abs(l-f); 14 | if (a <= t && t <= b) 15 | printf("Yes\n"); 16 | else 17 | printf("No\n"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /DMOJ/utso18p1.hs: -------------------------------------------------------------------------------- 1 | main = do 2 | [n, m] <- map(read :: String -> Integer) <$> words <$> getLine 3 | print(max (n * m) (max(n + m) (abs(n - m)))) 4 | -------------------------------------------------------------------------------- /DMOJ/valday15p2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int c, m, a, b; 8 | scanf("%i%i", &c, &m); 9 | vector> dp (c+1, vector (m+1, 0)); 10 | for (int x = 1; x <= c; x++) 11 | { 12 | scanf("%i%i", &a, &b); 13 | for (int y = 1; y <= m; y++) 14 | dp[x][y] = max (dp[x-1][y], b <= y ? a + dp[x-1][y-b] : 0); 15 | } 16 | printf("%d", dp[c][m]); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /DMOJ/vmss7wc16c1p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int y; 8 | scanf("%i", &y); 9 | vector f; 10 | for (long long x = 2; x*x <= y; x++) 11 | { 12 | while (y%x == 0) 13 | { 14 | f.push_back(x); 15 | y /= x; 16 | } 17 | } 18 | if (y > 1) 19 | f.push_back(y); 20 | sort(f.begin(), f.end()); 21 | for (auto &x : f) 22 | printf("%i\n", x); 23 | } 24 | -------------------------------------------------------------------------------- /DMOJ/vpex1p0.py: -------------------------------------------------------------------------------- 1 | x, n = map(int, input().split()) 2 | print(x // n, x % n) 3 | -------------------------------------------------------------------------------- /DMOJ/vpex1p1.py: -------------------------------------------------------------------------------- 1 | a = list(map(int, input().split())) 2 | b = list(map(int, input().split())) 3 | print(max(sum(a) - min(a), sum(b) - min(b))) 4 | -------------------------------------------------------------------------------- /DMOJ/vpex1p2.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | arr = list(map(int, input().split())) 3 | s = sum(arr) // n 4 | print(sum(s != x for x in arr)) 5 | -------------------------------------------------------------------------------- /DMOJ/waterloow2017c.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, k; 8 | scanf("%i%i", &n, &k); 9 | if ((k<<1) < n) 10 | return 0 * printf("0\n"); 11 | vector ans(n); 12 | int cnt = 0; 13 | for (int x = 0; x < k; x++) 14 | { 15 | int cur = 0, tot =0; 16 | for (int y = x; y < n; y += k) tot++; 17 | for (int y = x; y < n; y += k) 18 | ans[y] = (tot-cur) + cnt, cur++; 19 | cnt += cur; 20 | } 21 | for (auto &x : ans) 22 | printf("%i ", x); 23 | } 24 | -------------------------------------------------------------------------------- /DMOJ/xor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int t; 8 | scanf("%i", &t); 9 | while (t--) 10 | { 11 | int a, b; 12 | scanf("%i%i", &a, &b); 13 | int ans = 0; 14 | for (; a%4 && a <= b; a++) 15 | ans ^= a; 16 | for (; b%4 != 3 && a <= b; b--) 17 | ans ^= b; 18 | printf("%i\n", ans); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /DMOJ/xors.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | int a; 9 | scanf("%i", &n); 10 | long long mi = 0, ma = 0; 11 | while (n--) 12 | { 13 | scanf("%i", &a); 14 | mi ^= a; 15 | ma += a; 16 | } 17 | printf("%lli\n", ma - mi); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /DMOJ/year2015p1.py: -------------------------------------------------------------------------------- 1 | t = input() 2 | n = int(input()) 3 | for i in range(n): 4 | a = input() 5 | c = t.replace('>', a) 6 | print(c) 7 | -------------------------------------------------------------------------------- /DMOJ/year2017p3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | vector aa(1000005); 6 | 7 | long long fib(int n) 8 | { 9 | if (n < 2) 10 | return aa[n]; 11 | return max(aa[n], fib(n-2)+aa[n-1]); 12 | } 13 | 14 | int main() 15 | { 16 | int k, n; 17 | scanf("%i%i", &k, &n); 18 | if (k > n+1) 19 | return 0 * printf("-1"); 20 | for (int x = 1; x <= n; x++) 21 | scanf("%lli", &aa[x]); 22 | if (k == 1) 23 | printf("%lli", max(aa[1], aa[2])); 24 | else 25 | printf("%lli", fib(k)); 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /DMOJ/year2018p1.py: -------------------------------------------------------------------------------- 1 | import sys 2 | input = sys.stdin.readline().split(' ') 3 | h, m, s = [int(x) for x in input] 4 | m += s/60 5 | s %= 60 6 | h += m/60 7 | m %= 60 8 | h = 12 - h%12 9 | if s != 0 or m != 0: 10 | h -= 1 11 | else: 12 | h %= 12 13 | to_print = "" 14 | if h < 10: 15 | to_print += "0" 16 | to_print += str(h) + ":" 17 | m = (60-m)%60 18 | if s != 0: 19 | m -= 1 20 | if m < 10: 21 | to_print += "0" 22 | to_print += str(m) + ":" 23 | s = (60-s)%60 24 | if s < 10: 25 | to_print += "0" 26 | to_print += str(s) 27 | 28 | print to_print 29 | -------------------------------------------------------------------------------- /DMOJ/year2018p2.py: -------------------------------------------------------------------------------- 1 | import sys 2 | n = int(sys.stdin.readline()) 3 | prime = [True]*100002 4 | prime[0] = False 5 | prime[1] = False 6 | for x in range(2, 400): 7 | if prime[x]: 8 | for y in range(x*x, 100002, x): 9 | prime[y] = False 10 | a = [int(x) for x in sys.stdin.readline().split(' ')] 11 | b = 0 12 | for x in a: 13 | b += 1 if prime[x] else 0 14 | 15 | print b 16 | -------------------------------------------------------------------------------- /DMOJ/year2019p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int h1, h2, w1, w2; 8 | scanf("%i%i%i%i", &h1, &w1, &h2, &w2); 9 | --h1; 10 | --h2; 11 | if (w2 * h1 > w1 * h2) 12 | printf("1\n"); 13 | else if (w2 * h1 < w1 * h2) 14 | printf("2\n"); 15 | else 16 | printf("-1\n"); 17 | } 18 | -------------------------------------------------------------------------------- /DMOPC/dmopc14c1p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | vector arr(n); 10 | for (auto &x : arr) 11 | scanf("%i", &x); 12 | sort(arr.begin(), arr.end()); 13 | if (n&1) 14 | printf("%i\n", arr[n/2]); 15 | else 16 | printf("%i\n", (int)round((arr[n/2] + arr[n/2-1])/2.0)); 17 | } 18 | -------------------------------------------------------------------------------- /DMOPC/dmopc14c1p2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int a, b, c; 8 | scanf("%i%i%i", &a, &b, &c); 9 | printf("%i\n", (a/c) * (b/c)); 10 | } 11 | -------------------------------------------------------------------------------- /DMOPC/dmopc14c1p3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int i, s, sum = 0, a; 8 | scanf("%i", &i); 9 | for (int x = 0; x < i; x++) 10 | { 11 | scanf("%i", &a); 12 | sum += a; 13 | } 14 | scanf("%i", &s); 15 | for (int x = 0; x < s; x++) 16 | { 17 | scanf("%i", &a); 18 | sum += a; 19 | printf("%.10Lf\n", (long double)sum / (i+x+1)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /DMOPC/dmopc14c2p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int d; 8 | scanf("%i", &d); 9 | for (int x = 1; x <= d; x++) 10 | { 11 | int s = 0, a, t; 12 | scanf("%i", &t); 13 | while (t--) 14 | { 15 | scanf("%i", &a); 16 | s += a; 17 | } 18 | if (!s) 19 | printf("Weekend\n"); 20 | else 21 | printf("Day %i: %i\n", x, s); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /DMOPC/dmopc14c2p3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | vector e(n), l(n); 10 | for (auto &x : e) 11 | scanf("%lli", &x); 12 | for (auto &x : l) 13 | scanf("%lli", &x); 14 | sort(e.begin(), e.end()); 15 | sort(l.rbegin(), l.rend()); 16 | long long ans = 0; 17 | for (int x = 0; x < n; x++) 18 | ans += e[x] * l[x]; 19 | printf("%lli\n", ans); 20 | } 21 | -------------------------------------------------------------------------------- /DMOPC/dmopc14c2p4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | 5 | int main () 6 | { 7 | cin.sync_with_stdio(0); 8 | cin.tie(0); 9 | int a,b,c, d, y; 10 | cin >> a; 11 | int t[a]; 12 | cin >> t[0]; 13 | for (int x=1; x < a; x++) 14 | { 15 | cin >> y; 16 | t[x] = t[x-1] + y; 17 | } 18 | cin >> b; 19 | for (int x=0; x < b; x++) 20 | { 21 | cin >> c >> d; 22 | if (c==0) 23 | cout << t[d] << "\n"; 24 | else 25 | cout << t[d]-t[c-1] << "\n"; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /DMOPC/dmopc14c3p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | long long n, k, d; 8 | scanf("%lli%lli%lli", &n, &k, &d); 9 | while (d--) 10 | n *= k; 11 | printf("%lli\n", n); 12 | } 13 | -------------------------------------------------------------------------------- /DMOPC/dmopc14c5p1.py: -------------------------------------------------------------------------------- 1 | import math 2 | r = int(input()) 3 | h = int(input()) 4 | print(math.pi * r**2 * h / 3) 5 | -------------------------------------------------------------------------------- /DMOPC/dmopc14c5p2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, a, b; 8 | scanf("%i", &n); 9 | int ma = 0; 10 | while (n--) 11 | { 12 | scanf("%i%i", &a, &b); 13 | ma = max(ma, b-a); 14 | } 15 | printf("%i\n", ma); 16 | } 17 | -------------------------------------------------------------------------------- /DMOPC/dmopc14c6p4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, m, h; 8 | scanf("%i%i%i", &n, &m, &h); 9 | vector arr(n); 10 | for (auto &x : arr) 11 | scanf("%i", &x); 12 | int ans = 0; 13 | for (int x = n-2; x >= 0; x--) 14 | { 15 | int d = arr[x+1]-arr[x]-h; 16 | if (d > 0) 17 | { 18 | int t = (d+m-1)/m; 19 | ans += t; 20 | arr[x] += t*m; 21 | } 22 | } 23 | printf("%i\n", ans); 24 | } 25 | -------------------------------------------------------------------------------- /DMOPC/dmopc14c7p1.py: -------------------------------------------------------------------------------- 1 | b = int(input()) 2 | a = 0.5 * -9.8 3 | print((-2 * b)/a/2) 4 | -------------------------------------------------------------------------------- /DMOPC/dmopc14c7p3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int val[1000000]; 6 | 7 | int main() 8 | { 9 | int n, a, b, t, m = 0; 10 | scanf("%i%i%i", &n, &a, &b); 11 | for (int x = 0; x < a; x++) 12 | { 13 | scanf("%i", &t); 14 | val[t]++; 15 | } 16 | for (int x = 0; x < b; x++) 17 | { 18 | scanf("%i", &t); 19 | val[t]++; 20 | } 21 | for (int x = 0; x < 1000000; x++) 22 | if (val[x] == 2) 23 | m++; 24 | printf("%i", n-m); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /DMOPC/dmopc14ce1p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string a, b; 8 | cin>>a>>b; 9 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | vector> arr(n); 10 | for (auto &x : arr) 11 | cin>>x.second>>x.first; 12 | sort(arr.rbegin(), arr.rend()); 13 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, k; 8 | scanf("%i%i", &n, &k); 9 | int cnt = 0; 10 | while (n >= k) 11 | { 12 | cnt += k; 13 | n -= k-1; 14 | } 15 | cnt += n; 16 | printf("%i\n", cnt); 17 | } 18 | -------------------------------------------------------------------------------- /DMOPC/dmopc15c3p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int a, b, c, d; 8 | scanf("%i%i%i%i", &a, &b, &c, &d); 9 | printf("%s\n", (c < b && d >= b) || (a < d && b >= d) ? "YES" : "NO"); 10 | } 11 | -------------------------------------------------------------------------------- /DMOPC/dmopc15c3p2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | long long sum = 0, a; 9 | scanf("%i", &n); 10 | vector arr(n); 11 | for (auto &x : arr) 12 | { 13 | scanf("%lli", &x); 14 | sum += x; 15 | } 16 | if (sum%n) 17 | return 0 * printf("Impossible\n"); 18 | sum /= n; 19 | long long ans = 0; 20 | for (auto &x : arr) 21 | if (x > sum) 22 | ans += x-sum; 23 | printf("%lli\n", ans); 24 | } 25 | -------------------------------------------------------------------------------- /DMOPC/dmopc15c4p1.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | arr = sorted(input() for x in range(n)) 3 | v = [[] for x in range(26)] 4 | for x in arr: 5 | v[ord(x[0]) - ord('a')].append(x) 6 | for x in v: 7 | if len(x) > 0: 8 | print(', '.join(x)) 9 | -------------------------------------------------------------------------------- /DMOPC/dmopc15c4p2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int h, m, n; 8 | scanf("%i%i%i", &h, &m, &n); 9 | h += n/60; 10 | h %= 24; 11 | m += n%60; 12 | if (m >= 60) 13 | m -= 60, h++, h %= 24; 14 | printf("%i %i", h, m); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /DMOPC/dmopc15c6p2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | int n; 9 | double k, t = 0; 10 | scanf("%i", &n); 11 | for (int x = 0; x < n; x++) 12 | { 13 | cin >> k; 14 | t += k; 15 | t=fmod(t, 360); 16 | } 17 | cout < 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int w, c; 8 | scanf("%i%i", &w, &c); 9 | cout<<"C.C. is "; 10 | if (w == 3 && c >= 95) 11 | cout<<"absolutely"; 12 | else if (w == 1 && c <= 50) 13 | cout<<"fairly"; 14 | else 15 | cout<<"very"; 16 | cout<<" satisfied with her pizza.\n"; 17 | } 18 | -------------------------------------------------------------------------------- /DMOPC/dmopc16c1p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, a, cnt = 0; 8 | scanf("%i", &n); 9 | for (int x = 0; x < n; x++) 10 | { 11 | scanf("%i", &a); 12 | cnt += !((a&1)^(x&1)); 13 | } 14 | printf("%i\n", cnt); 15 | } 16 | -------------------------------------------------------------------------------- /DMOPC/dmopc16c1p3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | vector dp(n+1), arr(n+1); 10 | dp[0] = 0; 11 | for (int x = 1; x <= n; x++) 12 | { 13 | scanf("%i", &arr[x]); 14 | arr[x]*=2; 15 | dp[x] = dp[x-1] + arr[x]; 16 | if (x > 1) 17 | dp[x] = min(dp[x], dp[x-2] - min(arr[x-1], arr[x])/2 + arr[x-1] + arr[x]); 18 | if (x > 2) 19 | dp[x] = min(dp[x], dp[x-3] - min(arr[x-2], min(arr[x-1], arr[x])) +arr[x-2] + arr[x-1] + arr[x]); 20 | } 21 | printf("%.1f", dp[n]/2.0); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /DMOPC/dmopc16c2p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, k, t; 8 | int ans = 0; 9 | scanf("%i%i", &n, &k); 10 | while (k--) 11 | { 12 | scanf("%i", &t); 13 | if (t == 1) 14 | ans += 30; 15 | else if (t == 2) 16 | ans += 60; 17 | else 18 | ans += 300; 19 | } 20 | n *= 60; 21 | if (ans <= n) 22 | printf("Continue\n"); 23 | else 24 | printf("Return\n"); 25 | } 26 | -------------------------------------------------------------------------------- /DMOPC/dmopc16c3p0.py: -------------------------------------------------------------------------------- 1 | v, rf, rg = map(float,input().split()) 2 | print(float(v * (1 + rf/rg))) 3 | -------------------------------------------------------------------------------- /DMOPC/dmopc16c3p1.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | s = input() 3 | n2 = int(input()) 4 | if s == "Infront": 5 | print(n-n2) 6 | else: 7 | print(n+n2) 8 | -------------------------------------------------------------------------------- /DMOPC/dmopc16c4p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | long long a; 10 | while (n--) 11 | { 12 | scanf("%lli", &a); 13 | printf("%s\n", a&(a-1) ? "F" : "T"); 14 | } 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /DMOPC/dmopc17c1p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int r, c, q, xx, yy; 8 | char t; 9 | scanf("%i%i", &r, &c); 10 | vector cc (c+1), rr (r+1); 11 | for (int x = 1; x <= r; x++) 12 | for (int y = 1; y <= c; y++) 13 | {scanf (" %c", &t); if (t == 'X') rr[x] = cc[y] = true;} 14 | scanf("%i", &q); 15 | while (q--) 16 | { 17 | scanf("%i%i", &xx, &yy); 18 | printf("%c\n", rr[yy] || cc[xx] ? 'Y' : 'N'); 19 | } 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /DMOPC/dmopc17c2p0.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | inline int dist(int x, int y, int xx, int yy) {return (x-xx)*(x-xx) + (y-yy)*(y-yy);} 6 | 7 | int main() 8 | { 9 | vector> a (3); 10 | for (auto &x : a) 11 | scanf("%i%i", &x.first, &x.second); 12 | int d; 13 | scanf("%i", &d); 14 | d*=d; 15 | if (dist(a[2].first, a[2].second, a[0].first, a[0].second) <= d || dist(a[2].first, a[2].second, a[1].first, a[1].second) <= d) 16 | printf("Yes"); 17 | else 18 | printf("No"); 19 | } 20 | -------------------------------------------------------------------------------- /DMOPC/dmopc17c2p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, a, b; 8 | long long ma = 0; 9 | scanf("%i", &n); 10 | while (n--) 11 | { 12 | scanf("%i%i", &a, &b); 13 | if (b > 0) 14 | ma += a; 15 | } 16 | printf("%lli", ma); 17 | } 18 | -------------------------------------------------------------------------------- /DMOPC/dmopc17c2p2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string a; 8 | cin>>a; 9 | vector aa; 10 | for (auto &x : a) 11 | if (x == ')' && !aa.empty() && aa.back() == '(') aa.pop_back(); 12 | else aa.push_back(x); 13 | 14 | int bb = aa.size(), cc = 0; 15 | if (bb > 2) 16 | printf("NO"); 17 | else 18 | { 19 | while (!aa.empty() && aa.back() == '(') 20 | aa.pop_back(), cc++; 21 | printf("%s", (bb/2 + cc%2 < 2) ? "YES" : "NO"); 22 | } 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /DMOPC/dmopc17c2p3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, a, b; 8 | long long ma = 0; 9 | scanf("%i", &n); 10 | while (n--) 11 | { 12 | scanf("%i%i", &a, &b); 13 | if (b > 0) 14 | ma += a; 15 | } 16 | printf("%lli", ma); 17 | } 18 | -------------------------------------------------------------------------------- /DMOPC/dmopc17c3p0.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int b; 8 | scanf("%i", &b); 9 | printf("$%.2Lf $%.2Lf\n", (long double)b/2, (long double)b/2); 10 | } 11 | -------------------------------------------------------------------------------- /DMOPC/dmopc17c3p1.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | a = list(map(int,input().split())) 3 | print(min(a)) 4 | -------------------------------------------------------------------------------- /DMOPC/dmopc17c5p1.py: -------------------------------------------------------------------------------- 1 | a = [ 2 | ('0', 'O'), 3 | ('1', 'l'), 4 | ('3', 'E'), 5 | ('4', 'A'), 6 | ('5', 'S'), 7 | ('6', 'G'), 8 | ('8', 'B'), 9 | ('9', 'g'), 10 | ] 11 | s = input() 12 | for i in a: 13 | s = s.replace(*i) 14 | print(s) 15 | -------------------------------------------------------------------------------- /DMOPC/dmopc17c5p3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | long long a, GCD = 0, ma = 0; 9 | scanf("%i", &n); 10 | while (n--) 11 | { 12 | scanf("%lli", &a); 13 | GCD = __gcd(GCD, a); 14 | } 15 | for (long long x = 2; x <= sqrt(GCD); x++) 16 | { 17 | while (!(GCD%x)) 18 | GCD /= x, ma = x; 19 | } 20 | ma = max(ma, GCD); 21 | if (ma < 2) 22 | printf("DNE\n"); 23 | else 24 | printf("%lli\n", ma); 25 | } 26 | -------------------------------------------------------------------------------- /DMOPC/dmopc18c1p0.py: -------------------------------------------------------------------------------- 1 | print("Good job!" if (lambda x: x == sorted(x))(list(map(int,__import__('sys').stdin.read().split()))) else "Try again!") 2 | -------------------------------------------------------------------------------- /DMOPC/dmopc18c2p0.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, a, r; 8 | scanf("%i%i%i", &n, &a, &r); 9 | int c = min(n, r/a); 10 | printf("%i\n", c); 11 | } 12 | -------------------------------------------------------------------------------- /DMOPC/dmopc18c2p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int p; 8 | scanf("%i", &p); 9 | int mix = INT_MAX, maxx = INT_MIN, miy = INT_MAX, may = INT_MIN; 10 | while (p--) 11 | { 12 | int x, y; 13 | scanf("%i%i", &x, &y); 14 | mix = min(mix, x); 15 | maxx = max(maxx, x); 16 | miy = min(miy, y); 17 | may = max(may, y); 18 | } 19 | printf("%i\n", 2 * (maxx - mix + may - miy)); 20 | } 21 | -------------------------------------------------------------------------------- /DMOPC/dmopc18c2p4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | long long m; 9 | scanf("%i%lli", &n, &m); 10 | vector d(n); 11 | for (auto &x : d) 12 | scanf("%lli", &x); 13 | int l = 0, r = 0; 14 | int mi_len = INT_MAX; 15 | long long cur_sum = 0; 16 | while (r < n) 17 | { 18 | while (r < n && cur_sum < m) 19 | cur_sum += d[r++]; 20 | if (cur_sum >= m) 21 | mi_len = min(mi_len, r - l); 22 | cur_sum -= d[l++]; 23 | } 24 | printf("%i\n", mi_len == INT_MAX ? -1 : mi_len); 25 | } 26 | -------------------------------------------------------------------------------- /DMOPC/dmopc18c4p0.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int r, x, y, xx, yy, mm = INT_MAX, a, b, c; 8 | scanf("%i%i%i", &r, &x, &y); 9 | for (int i = 0; i < 3; i++) 10 | { 11 | scanf("%i%i%i", &a, &b, &c); 12 | if (c < mm) 13 | mm = c, xx = a, yy = b; 14 | } 15 | if ((x-xx)*(x-xx) + (y-yy)*(y-yy) < r*r) 16 | printf("What a beauty!\n"); 17 | else 18 | printf("Time to move my telescope!\n"); 19 | } 20 | -------------------------------------------------------------------------------- /DMOPC/dmopc18c5p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int b = 0, g = 0; 8 | int n, m, k; 9 | scanf("%i%i%i", &n, &m, &k); 10 | for (int x = 0; x < k; x++) 11 | { 12 | if ((n>>x&1) ^ (m>>x&1)) 13 | b++; 14 | else 15 | g++; 16 | } 17 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | long long m; 9 | scanf("%i%lli", &n, &m); 10 | vector arr(n); 11 | for (auto &x : arr) 12 | scanf("%lli", &x); 13 | int l = 0, r = 0, ma = 0; 14 | long long sum = 0; 15 | while (l < n) 16 | { 17 | while (r < n && sum + arr[r] < m) 18 | sum += arr[r++]; 19 | ma = max(ma, r-l); 20 | sum -= arr[l]; 21 | l++; 22 | } 23 | printf("%i\n", ma); 24 | } 25 | -------------------------------------------------------------------------------- /DMOPC/dmopc18c6p0.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | vector par(10); 6 | vector vis(10); 7 | 8 | bool dfs(int u) 9 | { 10 | if (!u) 11 | return true; 12 | if (vis[u]) 13 | return false; 14 | vis[u] = 1; 15 | return dfs(par[u]); 16 | } 17 | 18 | int main() 19 | { 20 | for (int x = 1; x <= 3; x++) 21 | scanf("%i", &par[x]); 22 | for (int x = 1; x <= 3; x++) 23 | { 24 | fill(vis.begin(), vis.end(), 0); 25 | if (!dfs(x)) 26 | return 0 * printf("NO\n"); 27 | } 28 | printf("YES\n"); 29 | } 30 | -------------------------------------------------------------------------------- /DMOPC/dmopc18c6p1.py: -------------------------------------------------------------------------------- 1 | n=int(input()) 2 | a=input() 3 | ALL="ACGTU" 4 | for x in a: 5 | if x not in ALL: 6 | print("neither") 7 | break 8 | else: 9 | TT = "T" in a 10 | UU = "U" in a 11 | if TT and UU: 12 | print("neither") 13 | elif TT: 14 | print("DNA") 15 | elif UU: 16 | print("RNA") 17 | else: 18 | print("both") 19 | -------------------------------------------------------------------------------- /DMOPC/dmopc19c1p0.py: -------------------------------------------------------------------------------- 1 | input() 2 | arr = list(map(int, input().split())) 3 | print(max(arr) - min(arr)) 4 | -------------------------------------------------------------------------------- /DMOPC/dmopc19c2p0.py: -------------------------------------------------------------------------------- 1 | n, a, b = map(int, input().split()) 2 | 3 | print(len([x for x in map(int, input().split()) if a <= x <= b])) 4 | -------------------------------------------------------------------------------- /DMOPC/dmopc19c2p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | vector arr(n); 10 | for (auto &x : arr) 11 | scanf("%lli", &x); 12 | sort(arr.begin(), arr.end()); 13 | int nn = n/2; 14 | int nk = n - nn; 15 | double q1 = (nn & 1) ? arr[nn/2] : (arr[nn/2] + arr[nn/2-1]) / 2.0; 16 | double q2 = (n & 1) ? arr[n/2] : (arr[n/2] + arr[n/2-1]) / 2.0; 17 | double q3 = (nn & 1) ? arr[nk + nn/2] : (arr[nk + nn/2] + arr[nk + nn/2-1]) / 2.0; 18 | printf("%lli %lli %.1lf %.1lf %.1lf\n", arr[0], arr[n-1], q1, q2, q3); 19 | } 20 | -------------------------------------------------------------------------------- /DMOPC/dmopc19c2p2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 1000; 6 | 7 | long long dp[MAXN][MAXN]; 8 | 9 | int main() 10 | { 11 | int n, m; 12 | scanf("%i%i", &n, &m); 13 | for (int x = 1; x <= n; x++) 14 | for (int y = 1; y <= m; y++) 15 | scanf("%lli", &dp[x][y]); 16 | for (int x = 2; x <= m; x++) 17 | dp[1][x] += dp[1][x-1]; 18 | for (int x = 2; x <= n; x++) 19 | dp[x][1] += dp[x-1][1]; 20 | for (int x = 2; x <= n; x++) 21 | for (int y = 2; y <= m; y++) 22 | dp[x][y] += min(dp[x-1][y], dp[x][y-1]); 23 | printf("%lli\n", dp[n][m]); 24 | } 25 | -------------------------------------------------------------------------------- /DMOPC/dmopc19c3p0.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | for i in range(n): 3 | arr = list(map(int, input().split())) 4 | arithmetic = all(arr[i] + arr[i+2] == arr[i+1] * 2 for i in range(8)) 5 | geometric = all(arr[i] * arr[i+2] == arr[i+1]**2 for i in range(8)) 6 | if arithmetic and geometric: 7 | print('both') 8 | elif arithmetic: 9 | print('arithmetic') 10 | elif geometric: 11 | print('geometric') 12 | else: 13 | print('neither') 14 | -------------------------------------------------------------------------------- /DMOPC/dmopc19c3p1.py: -------------------------------------------------------------------------------- 1 | from collections import defaultdict 2 | n = int(input()) 3 | mp = defaultdict(int) 4 | for x in list(map(int, input().split())): 5 | mp[x] += 1 6 | ma = 0 7 | arr = [] 8 | for x, y in mp.items(): 9 | if ma < y: 10 | ma = y 11 | arr = [x] 12 | elif ma == y: 13 | arr.append(x) 14 | print(*sorted(arr)) 15 | -------------------------------------------------------------------------------- /DMOPC/dmopc19c4p0.py: -------------------------------------------------------------------------------- 1 | a = input() 2 | b = input() 3 | 4 | c = sum(a[i] != b[i] for i in range(len(a))) 5 | 6 | print("LARRY IS {}!".format("DEAD" if c != 1 else "SAVED")) 7 | -------------------------------------------------------------------------------- /DMOPC/dmopc19c5p0.py: -------------------------------------------------------------------------------- 1 | n, c = map(int, input().split()) 2 | 3 | for i in range(n): 4 | s, x = input().split() 5 | print(s + ' will', end='') 6 | if int(x) <= c: 7 | print(' not', end='') 8 | print(' advance') 9 | -------------------------------------------------------------------------------- /DMOPC/dmopc19c5p1.py: -------------------------------------------------------------------------------- 1 | n, m = map(int, input().split()) 2 | has = set(input().strip() for i in range(n)) 3 | ans = 0 4 | for i in range(m): 5 | t = int(input()) 6 | v = [input().strip() for j in range(t)] 7 | ans += all(x in has for x in v) 8 | 9 | print(ans) 10 | -------------------------------------------------------------------------------- /DMOPC/dmopc19c6p0.py: -------------------------------------------------------------------------------- 1 | a = list(map(int, input().split())) 2 | a.sort() 3 | 4 | print(['yes', 'no'][a[0] + a[1] <= a[2]]) 5 | -------------------------------------------------------------------------------- /DMOPC/dmopc19c7p0.py: -------------------------------------------------------------------------------- 1 | a = [0] + list(map(int, input().split())) 2 | 3 | b = ['12', '13', '14', '23', '24', '34', '123', '124', '134', '234', '1234'] 4 | 5 | def avg(a): 6 | return sum(a) / len(a) 7 | 8 | for x in b: 9 | print(avg([a[int(y)] for y in x])) 10 | -------------------------------------------------------------------------------- /DMOPC/dmpg15b1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | int a; 9 | string c; 10 | scanf("%i", &a); 11 | for (int b = 0; b < a; b++) 12 | { 13 | cin>> c; 14 | if (c.length() == 10 && ((c[0] == '4' && c[1] == '1' && c[2] == '6') || (c[0] == '6' && c[1] == '4' && c[2] == '7'))) 15 | cout <<"("< 2 | 3 | using namespace std; 4 | 5 | 6 | int main() 7 | { 8 | int a, b, c, d, e, f; 9 | scanf("%i%i%i%i%i%i", &a, &b, &c, &d, &e, &f); 10 | printf("%c", ((a <= d && b <= e && c <= f) || 11 | (a <= d && b <= f && c <= e) || 12 | (a <= f && b <= d && c <= e) || 13 | (a <= e && b <= d && c <= f) || 14 | (a <= e && b <= f && c <= d) || 15 | (a <= f && b <= e && c <= d)) ? 16 | 'Y' : 'N' ); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /DMOPC/dmpg15s1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | int a, r, w, b, y, g; 7 | scanf("%i%i%i%i%i%i", &a, &r, &w, &b, &y, &g); 8 | a = a - ceil((float) r/4) - ceil((float) w/5) - ceil((float) b/4) - ceil((float) y/3) - ceil((float) g/6); 9 | if (a < 0) 10 | a = 0; 11 | printf("%i", a); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /DMOPC/dmpg16b1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int n, d, q, l, t; 6 | scanf("%i%i%i%i%i", &n,&d,&q,&l,&t); 7 | printf("%i", n*5+d*10+q*25+l*100+t*200); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /DMOPC/dmpg16s2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | long long n, z = 0; 8 | int k, d; 9 | scanf("%lli%i%i", &n, &k, &d); 10 | for (int x = 0; x < d; x++) 11 | { 12 | z += n % k; 13 | n /= k; 14 | } 15 | printf("%lli", z+n); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /DMOPC/dmpg17b1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, a, b, day = 0, cost = INT_MAX; 8 | scanf("%i", &n); 9 | for (int x = 0; x < n; x++) 10 | { 11 | scanf("%i%i", &a, &b); 12 | if (b > day) 13 | day = b, cost = a; 14 | else if (b == day) 15 | cost = min(cost, a); 16 | } 17 | printf("%i %i", cost, day); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /DMOPC/dmpg17b3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n, h, d, hf, df, htmp, c; 5 | scanf("%i%i%i", &n, &h, &d); 6 | for (int x = 0; x < n; x++) 7 | { 8 | c = 0; 9 | htmp = h; 10 | scanf("%i%i", &hf, &df); 11 | do 12 | { 13 | c++; 14 | hf -= d; 15 | if (hf <= 0) break; 16 | if (c%4 != 0) 17 | htmp -= df; 18 | } 19 | while (htmp > 0 && hf > 0); 20 | if (htmp <= 0) printf("Lose %i\n", c); 21 | else printf("Win %i\n", c); 22 | } 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /DMOPC/dmpg17b4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | for (int x = 1023; x > 0; x-=2) 5 | printf("%i\n", x); 6 | for (int x = 0; x < 1024; x+=2) 7 | printf("%i\n", x); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /DMOPC/dmpg17b6.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | long long n, a; 8 | double c = 0; 9 | scanf("%lli", &n); 10 | while (n--) 11 | { 12 | scanf("%lli", &a); 13 | c += log2(a); 14 | } 15 | printf("%i", (int)c+1); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /DMOPC/dmpg17s1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int compare (const void * a, const void * b) 7 | { 8 | return ( *(int*)a - *(int*)b ); 9 | } 10 | 11 | int main() 12 | { 13 | int n; 14 | int a = INT_MAX; 15 | cin >> n; 16 | int arr[n]; 17 | for (int x = 0; x < n; x++) 18 | cin >>arr[x]; 19 | qsort(arr, n, sizeof(int), compare); 20 | for (int x = 0; x < n-1; x++) 21 | a = min(abs(arr[x]-arr[x+1]), a); 22 | cout < 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, m; 8 | scanf("%i%i", &n, &m); 9 | for (int x = 0; x < n; x++, printf("\n")) 10 | for (int y = 0; y < m; y++) 11 | printf("%i ", ((x^(x>>1)) << 10) | (y^(y>>1))); 12 | } 13 | -------------------------------------------------------------------------------- /DMOPC/dmpg18b1.py: -------------------------------------------------------------------------------- 1 | a, b, c = map(int,input().split()) 2 | def f(x): 3 | return (x+2)//3 4 | 5 | print(f(a)+f(b)+f(c)) 6 | -------------------------------------------------------------------------------- /DMOPC/dmpg18b2.hs: -------------------------------------------------------------------------------- 1 | main = do 2 | [n, m] <- map(read :: String -> Int) <$> words <$> getLine 3 | if m > n 4 | then print n 5 | else print (m-1) 6 | -------------------------------------------------------------------------------- /DMOPC/dmpg18s2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | vector psa(200005); 6 | 7 | int main() 8 | { 9 | int n; 10 | scanf("%i", &n); 11 | for (int x = 1; x <= n; x++) 12 | { 13 | scanf("%lli", &psa[x]); 14 | psa[x] += psa[x-1]; 15 | } 16 | long long ans = 0; 17 | for (int x = 1; x <= n; x++) 18 | { 19 | ans += psa[n-x+1] - psa[x-1]; 20 | printf("%lli\n", ans); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /DMOPC/dmpg19b1.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | c = sum(map(int, input().split())) 3 | if c > 200: 4 | print("Over maximum capacity!") 5 | else: 6 | print(200 - c) 7 | -------------------------------------------------------------------------------- /DWITE/dwite08c3p4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | for (int q = 0; q < 5; q++) 8 | { 9 | int m, n; 10 | scanf("%i%i", &m, &n); 11 | vector c (n); 12 | for (auto &x : c) 13 | scanf("%i", &x); 14 | vector mm (m+1, INT_MAX); 15 | mm[0] = 0; 16 | for (int x = 0; x <= m; x++) 17 | { 18 | if (mm[x] != INT_MAX) 19 | for (auto &y : c) 20 | if (x+y <= m) 21 | mm[x+y] = min(mm[x+y], mm[x]+1); 22 | } 23 | printf("%i\n", mm[m]); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /DWITE/dwite09c6p4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | for (int ii = 0; ii < 5; ii++) 8 | { 9 | int n, m; 10 | scanf("%i%i", &m, &n); 11 | vector cc(n); 12 | for (auto &x : cc) 13 | scanf("%i", &x); 14 | vector dp(1000, INT_MAX); 15 | dp[0] = 0; 16 | for (int x = 0; x <= m; x++) 17 | if (dp[x] != INT_MAX) 18 | for (auto &y : cc) 19 | dp[x+y] = min(dp[x+y], dp[x]+1); 20 | printf("%i\n", dp[m]); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /DWITE/dwite09c7p2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | bool prime(int n) 6 | { 7 | for (int x = 2; x * x <= n; x++) 8 | if (n % x == 0) 9 | return false; 10 | return true; 11 | } 12 | 13 | int main() 14 | { 15 | for (int x = 0; x < 5; x++) 16 | { 17 | long long ans = 0; 18 | int a; 19 | scanf("%i", &a); 20 | do 21 | ans += a * prime(a); 22 | while (a-->2); 23 | printf("%lli\n", ans); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ECOO/ecoo13r1p2.py: -------------------------------------------------------------------------------- 1 | def good(x): 2 | x = x[::-1] 3 | return (sum(sum(map(int, str(int(y) * 2))) for y in x[1::2]) + sum(map(int, x[::2]))) % 10 == 0 4 | 5 | def calc(x): 6 | for v in range(10): 7 | if good(x + str(v)): 8 | return str(v) 9 | assert False 10 | 11 | for i in range(5): 12 | arr = input().split() 13 | ret = '' 14 | for x in arr: 15 | ret += calc(x) 16 | print(ret) 17 | -------------------------------------------------------------------------------- /ECOO/ecoo15r1p1.py: -------------------------------------------------------------------------------- 1 | from collections import defaultdict 2 | 3 | for i in range(10): 4 | cnt = defaultdict(int) 5 | 6 | while (s := input().strip()) != 'end of box': 7 | cnt[s] += 1 8 | 9 | def f(x): 10 | return (x + 6) // 7 * 13 11 | 12 | print(sum(f(cnt[x]) for x in ['orange', 'blue', 'green', 'yellow', 'pink', 'violet', 'brown']) + cnt['red'] * 16) 13 | -------------------------------------------------------------------------------- /ECOO/ecoo16r1p1.py: -------------------------------------------------------------------------------- 1 | def solve(): 2 | a, b, c, d = map(int, input().split()) 3 | cnt = 0 4 | for i in range(int(input())): 5 | aa, bb, cc, dd = map(int, input().split()) 6 | if aa * a + bb * b + cc * c + dd * d >= 5000: 7 | cnt += 1 8 | print(cnt) 9 | 10 | for i in range(10): 11 | solve() 12 | -------------------------------------------------------------------------------- /ECOO/ecoo18r1p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | for (int x = 0; x < 10; x++) 8 | { 9 | int t, n; 10 | scanf("%i%i", &t, &n); 11 | int cur = 0; 12 | char c; 13 | for (int y = 1; y <= n; y++) 14 | { 15 | scanf(" %c", &c); 16 | if (c == 'B') 17 | { 18 | if (cur > 0) 19 | cur += t; 20 | else 21 | cur = t; 22 | } 23 | cur--; 24 | } 25 | printf("%i\n", max(0, cur)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /ECOO/ecoo19r2p1.py: -------------------------------------------------------------------------------- 1 | def solve(): 2 | n = int(input()) 3 | a = set() 4 | for i in range(n): 5 | s = input().lower() 6 | s = s.split('@') 7 | s[0] = s[0].replace('.', '') 8 | s[0] = s[0].split('+')[0] 9 | a.add(s[0] + '@' + s[1]) 10 | print(len(a)) 11 | 12 | for i in range(10): 13 | solve() 14 | -------------------------------------------------------------------------------- /FHC/fhc15c2p4/brute.err: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ninjaclasher/Competitive-Programming/3812ff630488d7589754ff25a3eefd8898226301/FHC/fhc15c2p4/brute.err -------------------------------------------------------------------------------- /FHC/fhc15c2p4/brute.in: -------------------------------------------------------------------------------- 1 | 1 2 | 8 3 3 | 3 3 2 3 4 4 | 2 1 3 0 1 5 | 3 3 1 0 4 6 | 1 5 2 4 2 7 | 1 1 2 4 2 8 | 2 1 4 4 4 9 | -------------------------------------------------------------------------------- /FHC/fhc15c2p4/brute.out: -------------------------------------------------------------------------------- 1 | 3 3 19 67 243 867 3091 11011 2 | 3 3 1 67 243 867 3091 11011 3 | 3 3 2 69 246 871 3096 11011 4 | Case #1: 36 5 | -------------------------------------------------------------------------------- /FHC/fhc15c2p4/fhc15c2p4.err: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ninjaclasher/Competitive-Programming/3812ff630488d7589754ff25a3eefd8898226301/FHC/fhc15c2p4/fhc15c2p4.err -------------------------------------------------------------------------------- /FHC/fhc15c2p4/fhc15c2p4.in: -------------------------------------------------------------------------------- 1 | 5 2 | 5 4 3 | 0 0 0 0 0 4 | 1 2 0 1 0 5 | 1 1 0 0 0 6 | 1 1 0 0 0 7 | 0 0 0 0 0 8 | 0 0 0 0 0 9 | 5 4 10 | 1 2 0 1 1 11 | 1 2 0 1 0 12 | 1 1 0 0 0 13 | 5 5 0 1 4 14 | 0 0 0 0 0 15 | 0 0 0 0 0 16 | 5 4 17 | 1 2 0 1 1 18 | 1 2 0 1 0 19 | 1 1 0 0 0 20 | 5 5 0 1 4 21 | 1 2 0 1 1 22 | 1 2 0 1 1 23 | 5 2 24 | 1 2 0 1 1 25 | 4 4 0 0 0 26 | 1 1 0 0 0 27 | 5 5 0 0 0 28 | 0 0 0 0 0 29 | 0 0 0 0 0 30 | 100 100 31 | 1 2 3 4 5 32 | 1 2 3 4 5 33 | 1 2 3 4 5 34 | 1 2 3 4 5 35 | 1 2 3 4 5 36 | 1 2 3 4 5 37 | -------------------------------------------------------------------------------- /FHC/fhc15c2p4/fhc15c2p4.out: -------------------------------------------------------------------------------- 1 | Case #1: 0 2 | Case #2: 15 3 | Case #3: 65 4 | Case #4: 6 5 | Case #5: 505274484 6 | -------------------------------------------------------------------------------- /ICPC/naq16j.hs: -------------------------------------------------------------------------------- 1 | import Control.Monad 2 | 3 | main = do 4 | n <- read <$> getLine :: IO Int 5 | arr <- replicateM n (getLine) 6 | putStrLn . unlines $ map (\x -> show $ length x) arr 7 | -------------------------------------------------------------------------------- /ICPC/waterloow2017a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | long long ans = 0; 9 | scanf("%i", &n); 10 | for (int x = 1; x <= n; x++) 11 | ans += n-1; 12 | printf("%lli\n", ans); 13 | } 14 | -------------------------------------------------------------------------------- /IOI/ioi14p3.cpp: -------------------------------------------------------------------------------- 1 | void initialize (int n){} 2 | int q[5000]; 3 | int hasEdge(int u, int v){return ++q[u > v ? u : v] == (u > v ? u : v);} 4 | -------------------------------------------------------------------------------- /IOI/ioi16p6/ioi16p6.err: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ninjaclasher/Competitive-Programming/3812ff630488d7589754ff25a3eefd8898226301/IOI/ioi16p6/ioi16p6.err -------------------------------------------------------------------------------- /IOI/ioi16p6/ioi16p6.in: -------------------------------------------------------------------------------- 1 | 5 7 2 2 | 0 3 3 | 4 4 4 | 4 6 5 | 4 5 6 | 4 6 7 | -------------------------------------------------------------------------------- /IOI/ioi16p6/ioi16p6.out: -------------------------------------------------------------------------------- 1 | 25 2 | -------------------------------------------------------------------------------- /LKP/lkp18c2p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, m, a; 8 | scanf("%i%i", &n, &m); 9 | priority_queue,greater> buf; 10 | for (int x = 0; x < n; x++) 11 | { 12 | scanf("%i", &a); 13 | buf.push(a); 14 | } 15 | for (int x = 0; x < m; x++) 16 | { 17 | int u = buf.top(); 18 | buf.pop(); 19 | printf("%i\n", u); 20 | u++; 21 | buf.push(u); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /LKP/lkp18c2p2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, k; 8 | scanf("%i%i", &n, &k); 9 | vector kk(k); 10 | kk[0] = 1; 11 | vector arr(n); 12 | for (auto &x : arr) 13 | scanf("%i", &x); 14 | long long ans = 0, cur = 0; 15 | for (int x = 0; x < n; x++) 16 | { 17 | cur += arr[x]; 18 | ans += kk[cur%k]; 19 | kk[cur%k]++; 20 | } 21 | printf("%lli\n", ans); 22 | } 23 | -------------------------------------------------------------------------------- /NOI/noi05p2/brute.err: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ninjaclasher/Competitive-Programming/3812ff630488d7589754ff25a3eefd8898226301/NOI/noi05p2/brute.err -------------------------------------------------------------------------------- /NOI/noi05p2/brute.in: -------------------------------------------------------------------------------- 1 | 9 8 2 | 2 -6 3 5 1 -5 -3 6 3 3 | GET-SUM 5 4 4 | MAX-SUM 5 | INSERT 8 3 -5 7 2 6 | DELETE 12 1 7 | MAKE-SAME 3 3 2 8 | REVERSE 3 6 9 | GET-SUM 5 4 10 | MAX-SUM 11 | -------------------------------------------------------------------------------- /NOI/noi05p2/brute.out: -------------------------------------------------------------------------------- 1 | -1 2 | 10 3 | 1 4 | 10 5 | -------------------------------------------------------------------------------- /NOI/noi05p2/noi05p2.err: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ninjaclasher/Competitive-Programming/3812ff630488d7589754ff25a3eefd8898226301/NOI/noi05p2/noi05p2.err -------------------------------------------------------------------------------- /NOI/noi05p2/noi05p2.in: -------------------------------------------------------------------------------- 1 | 2 2 2 | -2 4 3 | MAKE-SAME 2 1 -6 4 | MAX-SUM 5 | -------------------------------------------------------------------------------- /NOI/noi05p2/noi05p2.out: -------------------------------------------------------------------------------- 1 | -2 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Competitive Programming Problem Solutions 2 | 3 | Problem solutions from various judges, including [DMOJ](https://dmoj.ca/), [SPOJ](https://www.spoj.com/), [WCIPEG](https://wcipeg.com/), as well as competitions, including the APIO, ACM-ICPC, Bubble Cup, CCC, CCO, COCI, DMOPC, DWITE, Facebook Hacker Cup, IOI, JOI, LKP, and TLE. 4 | 5 | Solutions are written in C, C++, Python, Turing, or Haskell. 6 | -------------------------------------------------------------------------------- /TLE/tle15p1.py: -------------------------------------------------------------------------------- 1 | n, p = map(int, input().split()) 2 | names = [input() for x in range(n)] 3 | scores = [0] * n 4 | for i in range(p): 5 | j = list(map(int, input().split())) 6 | for k in range(n): 7 | scores[k] += j[k] 8 | p = sorted(zip(scores, names), reverse=True) 9 | for i in range(n): 10 | print(str(i + 3) + '.', p[i][1]) 11 | -------------------------------------------------------------------------------- /TLE/tle16c4p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | vector arr(n); 10 | for (auto &x : arr) 11 | scanf("%i", &x); 12 | sort(arr.begin(), arr.end()); 13 | int cnt = 0, cur_sum = 0; 14 | for (auto &x : arr) 15 | { 16 | if (x >= cur_sum) 17 | { 18 | cur_sum += x; 19 | cnt++; 20 | } 21 | } 22 | printf("%i\n", cnt); 23 | } 24 | -------------------------------------------------------------------------------- /TLE/tle17c2p1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string a; 8 | int c = 0; 9 | getline(cin, a); 10 | for (auto &x : a) 11 | { 12 | if (x != 'r' && x != 'c' && x != '(' && x != ' ') 13 | { 14 | printf("(c%cr ", x); 15 | c++; 16 | } 17 | if (x == ' ') break; 18 | } 19 | printf(" x"); 20 | while (c--) 21 | printf(")"); 22 | } 23 | -------------------------------------------------------------------------------- /TLE/tle17c2p2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int k, n, a; 8 | scanf("%i", &k); 9 | vector aa (k); 10 | for (auto &x : aa) 11 | scanf("%i", &x); 12 | scanf("%i", &n); 13 | sort(aa.begin(),aa.end()); 14 | while (n--) 15 | { 16 | scanf("%i", &a); 17 | printf("%i\n", a-(upper_bound(aa.begin(), aa.end(), a)-aa.begin())); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /WCIPEG/a4b1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, a; 8 | scanf("%i", &n); 9 | vector aa; 10 | while (n--) 11 | { 12 | scanf("%i", &a); 13 | aa.push_back(a); 14 | } 15 | sort(aa.begin(), aa.end()); 16 | for (auto &x : aa) printf("%i\n", x); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /WCIPEG/cchange.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int k, n; 8 | scanf("%i%i", &k, &n); 9 | vector dp(k+20000, INT_MAX); 10 | dp[0] = 0; 11 | vector arr(n); 12 | for (auto &x : arr) 13 | scanf("%i", &x); 14 | for (int x = 0; x <= k; x++) 15 | if (dp[x] != INT_MAX) 16 | for (auto &y : arr) 17 | dp[x+y] = min(dp[x]+1, dp[x+y]); 18 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, a; 8 | scanf("%i", &n); 9 | vector dp(n+1); 10 | scanf("%i", &dp[0]); 11 | scanf("%i", &dp[1]); 12 | dp[1] = max(dp[1], dp[0]); 13 | for (int x = 2; x < n; x++) 14 | { 15 | scanf("%i", &a); 16 | dp[x] = max(dp[x-2]+a, dp[x-1]); 17 | } 18 | cout< 2 | 3 | using namespace std; 4 | 5 | map par; 6 | 7 | int find(int a) 8 | { 9 | int &x = par[a]; 10 | if (!x) x = a; 11 | else if (a != x) x = find(x); 12 | return x; 13 | } 14 | 15 | int main() 16 | { 17 | int n, m, a, b; 18 | scanf("%i%i", &n, &m); 19 | while (m--) 20 | { 21 | scanf("%i%i", &a, &b); 22 | a = find(a), b = find(b); 23 | if (a != b) par[a] = b, n--; 24 | } 25 | printf("%i", n); 26 | return 0; 27 | } 28 | 29 | -------------------------------------------------------------------------------- /WCIPEG/wc174j3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | set aa; 8 | aa.insert("Mind"); 9 | aa.insert("Power"); 10 | aa.insert("Reality"); 11 | aa.insert("Soul"); 12 | aa.insert("Space"); 13 | aa.insert("Time"); 14 | int n; 15 | scanf("%i", &n); 16 | string a; 17 | while (n--) 18 | { 19 | cin>>a; 20 | aa.erase(a); 21 | } 22 | for (auto &x : aa) 23 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, m, a, b, c, d, e, f; 8 | scanf("%i%i", &n, &f); 9 | for (int x = 0; x < n; x++) 10 | { 11 | scanf("%i", &a); 12 | int b = a/f; 13 | if (a%f == 0 && (b&(b-1)) == 0) 14 | continue; 15 | printf("%i\n", x+1); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /WCIPEG/wc17fs1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf("%i", &n); 9 | int ma = 0; 10 | vector a(n), b(n); 11 | for (auto &x : a) 12 | scanf("%i", &x); 13 | for (auto &x : b) 14 | scanf("%i", &x); 15 | sort(a.begin(), a.end()); 16 | sort(b.begin(), b.end()); 17 | for (int x = 0; x < n; x++) 18 | ma = max(abs(a[x]-b[x]), ma); 19 | printf("%i\n", ma); 20 | } 21 | -------------------------------------------------------------------------------- /WCIPEG/wc181j4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, m, a, p = -2; 8 | scanf("%i%i", &n, &m); 9 | int cnt = 0; 10 | while (m--) 11 | { 12 | scanf("%i", &a); 13 | if (abs(a-p) == 1) 14 | cnt++; 15 | else 16 | cnt+=2; 17 | p = a; 18 | } 19 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | int m; 9 | cin>>n; 10 | vector a(n); 11 | for (auto &x : a) 12 | cin>>x; 13 | cin>>m; 14 | vector b(m); 15 | for (auto &x : b) 16 | cin>>x; 17 | int cnt = 0; 18 | for (auto &x : a) 19 | for (auto &y : b) 20 | if (x == y) 21 | cnt++; 22 | cout< 2 | 3 | using namespace std; 4 | 5 | char arr[105][105]; 6 | 7 | int main() 8 | { 9 | int r, c; 10 | scanf("%i%i", &r, &c); 11 | for (int x = 0; x < r; x++) 12 | for (int y = 0; y < c; y++) 13 | arr[x][y] = '.'; 14 | for (int x = 1; x < c-1; x++) 15 | arr[r-x-1][x] = '#'; 16 | arr[r-1][0] = 'S'; 17 | arr[r-2][c-1] = 'E'; 18 | for (int x = 0; x < r; x++) 19 | { 20 | for (int y = 0; y < c; y++) 21 | cout<