├── .gitignore ├── CSES Problem Set ├── 01 - Introductory Problems │ ├── Apple Division.cpp │ ├── Bit Strings.cpp │ ├── Chessboard and Queens.cpp │ ├── Coin Piles.cpp │ ├── Creating Strings I.cpp │ ├── Digit Queries.cpp │ ├── Gray Code.cpp │ ├── Grid Paths I.cpp │ ├── Increasing Array.cpp │ ├── Missing Number.cpp │ ├── Number Spiral.cpp │ ├── Palindrome Reorder.cpp │ ├── Permutations I.cpp │ ├── Repetitions.cpp │ ├── Tower of Hanoi.cpp │ ├── Trailing Zeros.cpp │ ├── Two Knights.cpp │ ├── Two Sets I.cpp │ └── Weird Algorithm.cpp ├── 02 - Sorting and Searching │ ├── Apartments.cpp │ ├── Array Division.cpp │ ├── Collecting Numbers I.cpp │ ├── Collecting Numbers II.cpp │ ├── Concert Tickets.cpp │ ├── Distinct Numbers.cpp │ ├── Factory Machines.cpp │ ├── Ferris Wheel.cpp │ ├── Josephus Problem I .cpp │ ├── Josephus Problem II.cpp │ ├── Maximum Subarray Sum I.cpp │ ├── Maximum Subarray Sum II.cpp │ ├── Missing Coin Sum.cpp │ ├── Movie Festival I.cpp │ ├── Movie Festival II.cpp │ ├── Nearest Smaller Values.cpp │ ├── Nested Ranges Check.cpp │ ├── Nested Ranges Count.cpp │ ├── Playlist.cpp │ ├── Reading Books.cpp │ ├── Restaurant Customers.cpp │ ├── Room Allocation.cpp │ ├── Sliding Cost.cpp │ ├── Sliding Median.cpp │ ├── Stick Lengths.cpp │ ├── Subarray Distinct Values.cpp │ ├── Subarray Divisibility.cpp │ ├── Subarray Sums I.cpp │ ├── Subarray Sums II.cpp │ ├── Sum of Four Values.cpp │ ├── Sum of Three Values.cpp │ ├── Sum of Two Values.cpp │ ├── Tasks and Deadlines.cpp │ ├── Towers.cpp │ └── Traffic Lights.cpp ├── 03 - Dynamic Programming │ ├── Array Description.cpp │ ├── Book Shop I.cpp │ ├── Coin Combinations I.cpp │ ├── Coin Combinations II.cpp │ ├── Counting Numbers.cpp │ ├── Counting Tilings.cpp │ ├── Counting Towers.cpp │ ├── Dice Combinations.cpp │ ├── Edit Distance.cpp │ ├── Elevator Rides.cpp │ ├── Grid Paths II.cpp │ ├── Increasing Subsequence I.cpp │ ├── Minimizing Coins.cpp │ ├── Money Sums.cpp │ ├── Projects.cpp │ ├── Rectangle Cutting.cpp │ ├── Removal Game.cpp │ ├── Removing Digits I.cpp │ └── Two Sets II.cpp ├── 04 - Graph Algorithms │ ├── Building Roads.cpp │ ├── Building Teams.cpp │ ├── Coin Collector.cpp │ ├── Counting Rooms.cpp │ ├── Course Schedule I.cpp │ ├── Cycle Finding.cpp │ ├── De Bruijn Sequence.cpp │ ├── Distinct Routes I.cpp │ ├── Download Speed.cpp │ ├── Flight Discount.cpp │ ├── Flight Routes Check.cpp │ ├── Flight Routes.cpp │ ├── Game Routes.cpp │ ├── Giant Pizza.cpp │ ├── Hamiltonian Flights.cpp │ ├── High Score.cpp │ ├── Investigation.cpp │ ├── Knight's Tour.cpp │ ├── Labyrinth.cpp │ ├── Longest Flight Route.cpp │ ├── Mail Delivery.cpp │ ├── Message Route.cpp │ ├── Monsters.cpp │ ├── Planets Cycles.cpp │ ├── Planets Queries I.cpp │ ├── Planets Queries II.cpp │ ├── Planets and Kingdoms.cpp │ ├── Police Chase.cpp │ ├── Road Construction.cpp │ ├── Road Reparation.cpp │ ├── Round Trip I.cpp │ ├── Round Trip II.cpp │ ├── School Dance.cpp │ ├── Shortest Routes I.cpp │ ├── Shortest Routes II.cpp │ └── Teleporters Path.cpp ├── 05 - Range Queries │ ├── Distinct Values Queries.cpp │ ├── Dynamic Range Minimum Queries.cpp │ ├── Dynamic Range Sum Queries.cpp │ ├── Forest Queries I.cpp │ ├── Forest Queries II.cpp │ ├── Hotel Queries.cpp │ ├── Increasing Array Queries.cpp │ ├── List Removals.cpp │ ├── Pizzeria Queries.cpp │ ├── Polynomial Queries.cpp │ ├── Prefix Sum Queries.cpp │ ├── Range Queries and Copies.cpp │ ├── Range Update Queries.cpp │ ├── Range Updates and Sums.cpp │ ├── Range XOR Queries.cpp │ ├── Salary Queries.cpp │ ├── Static Range Minimum Queries.cpp │ ├── Static Range Sum Queries.cpp │ └── Subarray Sum Queries.cpp ├── 06 - Tree Algorithms │ ├── Company Queries I.cpp │ ├── Company Queries II.cpp │ ├── Counting Paths.cpp │ ├── Distance Queries.cpp │ ├── Distinct Colors.cpp │ ├── Finding a Centroid.cpp │ ├── Fixed Length Paths I.cpp │ ├── Fixed Length Paths II.cpp │ ├── Path Queries I.cpp │ ├── Path Queries II.cpp │ ├── Subordinates.cpp │ ├── Subtree Queries.cpp │ ├── Tree Diameter.cpp │ ├── Tree Distances I.cpp │ ├── Tree Distances II.cpp │ └── Tree Matching.cpp ├── 07 - Mathematics │ ├── Another Game.cpp │ ├── Binomial Coefficients.cpp │ ├── Bracket Sequences I.cpp │ ├── Bracket Sequences II.cpp │ ├── Candy Lottery.cpp │ ├── Christmas Party.cpp │ ├── Common Divisors.cpp │ ├── Counting Coprime Pairs.cpp │ ├── Counting Divisors.cpp │ ├── Counting Grids.cpp │ ├── Counting Necklaces.cpp │ ├── Creating Strings II.cpp │ ├── Dice Probability.cpp │ ├── Distributing Apples.cpp │ ├── Divisor Analysis.cpp │ ├── Exponentiation I.cpp │ ├── Exponentiation II.cpp │ ├── Fibonacci Numbers.cpp │ ├── Graph Paths I.cpp │ ├── Graph Paths II.cpp │ ├── Grundy's Game.cpp │ ├── Inversion Probability.cpp │ ├── Josephus Queries.cpp │ ├── Moving Robots.cpp │ ├── Nim Game I.cpp │ ├── Nim Game II.cpp │ ├── Prime Multiples.cpp │ ├── Stair Game.cpp │ ├── Stick Game.cpp │ ├── Sum of Divisors.cpp │ └── Throwing Dice.cpp ├── 08 - String Algorithms │ ├── Counting Patterns.cpp │ ├── Distinct Substrings.cpp │ ├── Finding Borders.cpp │ ├── Finding Patterns.cpp │ ├── Finding Periods.cpp │ ├── Longest Palindrome.cpp │ ├── Minimal Rotation.cpp │ ├── Palindrome Queries.cpp │ ├── Pattern Positions.cpp │ ├── Repeating Substring.cpp │ ├── Required Substring.cpp │ ├── String Functions.cpp │ ├── String Matching.cpp │ ├── Substring Distribution.cpp │ ├── Substring Order I.cpp │ ├── Substring Order II.cpp │ └── Word Combinations.cpp ├── 09 - Geometry │ ├── Convex Hull.cpp │ ├── Line Segment Intersection.cpp │ ├── Minimum Euclidean Distance.cpp │ ├── Point Location Test.cpp │ ├── Point in Polygon.cpp │ ├── Polygon Area.cpp │ └── Polygon Lattice Points.cpp ├── 10 - Advanced Techniques │ ├── Apples and Bananas.cpp │ ├── Beautiful Subgrids.cpp │ ├── Cut and Paste.cpp │ ├── Distinct Routes II.cpp │ ├── Dynamic Connectivity.cpp │ ├── Eulerian Subgraphs.cpp │ ├── Hamming Distance.cpp │ ├── Houses and Schools.cpp │ ├── Knuth Division.cpp │ ├── Meet in the Middle.cpp │ ├── Monster Game I.cpp │ ├── Monster Game II.cpp │ ├── Necessary Cities.cpp │ ├── Necessary Roads.cpp │ ├── New Roads Queries.cpp │ ├── One Bit Positions.cpp │ ├── Parcel Delivery.cpp │ ├── Reachability Queries.cpp │ ├── Reachable Nodes.cpp │ ├── Reversals and Sums.cpp │ ├── Signal Processing.cpp │ ├── Subarray Squares.cpp │ ├── Substring Reversals.cpp │ └── Task Assignment.cpp ├── 11 - Additional Problems │ ├── Acyclic Graph Edges.cpp │ ├── Advertisement.cpp │ ├── Area of Rectangles.cpp │ ├── Binary Subsequences.cpp │ ├── Bit Inversions.cpp │ ├── Bit Problem.cpp │ ├── Bit Substrings.cpp │ ├── Chess Tournament.cpp │ ├── Coin Grid.cpp │ ├── Counting Bishops.cpp │ ├── Counting Bits.cpp │ ├── Counting Sequences.cpp │ ├── Course Schedule II.cpp │ ├── Critical Cities.cpp │ ├── Cyclic Array.cpp │ ├── Empty String.cpp │ ├── Even Outdegree Edges.cpp │ ├── Flight Route Requests.cpp │ ├── Food Division.cpp │ ├── Functional Graph Distribution.cpp │ ├── Graph Girth.cpp │ ├── Grid Paths III.cpp │ ├── Grid Puzzle I.cpp │ ├── Grid Puzzle II.cpp │ ├── Increasing Array II.cpp │ ├── Increasing Subsequence II.cpp │ ├── Intersection Points.cpp │ ├── Inverse Inversions.cpp │ ├── Letter Pair Move Game.cpp │ ├── List of Sums.cpp │ ├── Maximum Building I.cpp │ ├── Maximum Building II.cpp │ ├── Maximum XOR Subarray.cpp │ ├── Monotone Subsequences.cpp │ ├── Movie Festival Queries.cpp │ ├── Multiplication Table.cpp │ ├── Network Breakdown.cpp │ ├── Network Renovation.cpp │ ├── Number Grid.cpp │ ├── Permutation Inversions.cpp │ ├── Permutations II.cpp │ ├── Prufer Code.cpp │ ├── Pyramid Array.cpp │ ├── School Excursion.cpp │ ├── Shortest Subsequence.cpp │ ├── Sorting Methods.cpp │ ├── Special Substrings.cpp │ ├── Stack Weights.cpp │ ├── Stick Divisions.cpp │ ├── String Removals.cpp │ ├── String Reorder.cpp │ ├── String Transform.cpp │ ├── Strongly Connected Edges.cpp │ ├── Swap Game.cpp │ ├── Swap Round Sorting.cpp │ ├── Tree Isomorphism I.cpp │ ├── Tree Isomorphism II.cpp │ ├── Tree Traversals.cpp │ ├── Visiting Cities.cpp │ ├── Writing Numbers.cpp │ └── XOR Pyramid.cpp ├── CSES Problem Set Editorial.pdf └── README.md ├── Competitive Programming Syllabus ├── Level 0 │ ├── README.md │ ├── STL Data Structures.cpp │ └── STL Functions.cpp └── Level 1 │ ├── Basic Techniques │ └── README.md │ ├── Combinatorics │ └── README.md │ ├── Dynamic Programming │ └── README.md │ ├── Graph Algorithms │ └── README.md │ ├── Mathematics │ └── README.md │ ├── README.md │ ├── String Algorithms │ └── README.md │ └── Tree Algorithms │ └── README.md ├── Official ACM-ICPC Contests ├── ACPC 12 (BEFM Unsolved) │ ├── ACPC 12 (Without Editorial).pdf │ ├── Archery.cpp │ ├── Connecting Islands.cpp │ ├── Contest Hall Preparation.cpp │ ├── Encrypted Password.cpp │ ├── Kids Love Candies.cpp │ └── The New President.cpp ├── ACPC 18 (EGHJK Unsolved) │ ├── ACPC 18 (With Editorial).pdf │ ├── Awesome Shawarma.cpp │ ├── Baklava Tray.cpp │ ├── Coffee.cpp │ ├── Dull Chocolates.cpp │ ├── Flipping El Fetiera.cpp │ ├── Ice Cream Knapsack.cpp │ └── Looking for Taste.cpp ├── ACPC 19 (BGHIKL Unsolved) │ ├── ACPC 19 (Without Editorial).pdf │ ├── Ages of Universes.cpp │ ├── Cake for Summer.cpp │ ├── Dimension 35-C.cpp │ ├── Endure is Going to Space.cpp │ ├── Flip the Tree.cpp │ └── Jaguar on the Tower.cpp ├── ACPC 20 (Unsolved) │ ├── ACPC 20 (Without Editorial).pdf │ └── Differences.cpp ├── ACPC 20 KickOff (FIL Unsolved) │ ├── ACPC 20 KickOff (Wihtout Editorial).pdf │ ├── Absent Students.cpp │ ├── Bakery Chief.cpp │ ├── Grids Converting.cpp │ ├── Making the Array Equal Again.cpp │ ├── Max Radius of a Circle.cpp │ ├── Min Max 3n+1.cpp │ ├── OCR Mistake.cpp │ ├── Reduced Array.cpp │ └── Watching Builders.cpp ├── ACPC 21 (DHJL Unsolved) │ ├── ACPC 2021 (Without Editorial).pdf │ ├── ACPC Sites.cpp │ ├── Brimore and the Carpet Market.cpp │ ├── Coach Academy Tic Tac Toe.cpp │ ├── Endure Invests in Apples.cpp │ ├── Fouad Wears Suits.cpp │ ├── Game of Science.cpp │ ├── Index of Fame.cpp │ └── Kontestants and Group Photos.cpp ├── ACPC 21 Girls (BCN Unsolved) │ ├── A Nuclear Scientist.cpp │ ├── D Primes.cpp │ ├── Elevator Game.cpp │ ├── Girls ACPC (With Editorial).pdf │ ├── Growing World.cpp │ ├── Hamza.cpp │ ├── Hand Copying.cpp │ ├── Learning Languages.cpp │ ├── Letter Dal.cpp │ ├── Longest Statement.cpp │ ├── Phantom of the Opera.cpp │ └── XOR K.cpp ├── ACPC 21 KickOff (D Unsolved) │ ├── 2wix+.cpp │ ├── ACPC 21 KickOff (Without Editorial).pdf │ ├── AKA AKA Learns Number Theory.cpp │ ├── Annoying Posts.cpp │ ├── Binary String.cpp │ ├── Game With Strings.cpp │ ├── Helping Eagle.cpp │ ├── Memeable Ace.cpp │ ├── Memeable String.cpp │ ├── Sakally Soldier.cpp │ ├── Topology vs Geometry.cpp │ └── Zero Equals Infinity.cpp ├── ACPC 22 KickOff (EJL Unsolved) │ ├── ACPC 22 KickOff (Without Editorial).pdf │ ├── Ali's Schedule.cpp │ ├── Array Erasing.cpp │ ├── Bero the Gamer.cpp │ ├── K-Subarrays.cpp │ ├── Make it K-Good.cpp │ ├── Moving Balls.cpp │ ├── New Sorting Algorithm.cpp │ ├── Pizza Time.cpp │ ├── Plan the Event.cpp │ ├── Reversing Strings.cpp │ ├── Testa Road.cpp │ └── Ziko the Rabbit.cpp ├── BAPC 13 (BEH Unsolved) │ ├── Administrative Difficulties.cpp │ ├── BAPC 13 (With Editorial).pdf │ ├── Cracking the Code.cpp │ ├── Destination Unknown.cpp │ ├── Flying Safely.cpp │ ├── Getting Through.cpp │ ├── Incognito.cpp │ └── Jailbreak.cpp ├── BAPC 14 (DFHK Unsolved) │ ├── Avoiding the Appocalypse.cpp │ ├── BAPC 14 (With Editorial).pdf │ ├── Button Bashing.cpp │ ├── Citadel Construction.cpp │ ├── Excellent Engineers.cpp │ ├── Growling Gears.cpp │ ├── Interesting Integers.cpp │ └── Jury Jeopardy.cpp ├── BAPC 16 (ADFGK Unsolved) │ ├── BAPC 16 (With Editorial).pdf │ ├── Battle Simulation.cpp │ ├── Brexit.cpp │ ├── Charles in Charge.cpp │ ├── Multiplying Digits.cpp │ ├── Older Brother.cpp │ ├── Programming Tutors.cpp │ └── Sticky Situation.cpp ├── BAPC 17 (BGHJ Unsolved) │ ├── Amsterdam Distance.cpp │ ├── BAPC 17 (With Editorial).pdf │ ├── Collatz Conjecture.cpp │ ├── Detour.cpp │ ├── Easter Eggs.cpp │ ├── Falling Apart.cpp │ ├── Irrational Division.cpp │ ├── King of the Waves.cpp │ ├── Lemonade Trade.cpp │ └── Manhattan Mornings.cpp ├── BAPC 18 (EHI Unsolved) │ ├── A Prize No One Can Win.cpp │ ├── BAPC 18 (With Editorial).pdf │ ├── Birthday Boy.cpp │ ├── Cardboard Container.cpp │ ├── Driver Disagreement.cpp │ ├── Financial Planning.cpp │ ├── Game Night.cpp │ ├── Janitor Troubles.cpp │ └── Kingpin Escape.cpp ├── ECPC 18 (GIJK Unsolved) │ ├── Array Transformation.cpp │ ├── Count Permutations.cpp │ ├── ECPC 18 (Without Editorial).pdf │ ├── Find the Path.cpp │ ├── MO Salah Running Down the Wing.cpp │ ├── Reflection.cpp │ ├── The Business Man.cpp │ ├── The First Task.cpp │ ├── The Millenium Prize Problems.cpp │ └── Zeros and Ones.cpp ├── ECPC 19 KickOff (IL Unsolved) │ ├── ABC.cpp │ ├── Anany in the Army.cpp │ ├── Baby Ehab and a GCD Problem, Of Course.cpp │ ├── Baby Ehab's Whining Chance.cpp │ ├── Baby Ehab's XOR.cpp │ ├── Baby Ehab.cpp │ ├── Geometry.cpp │ ├── Officer Anany Collecting String Subsequences.cpp │ ├── Plants Watering.cpp │ ├── Shortest Array.cpp │ ├── Sort.cpp │ └── YSYS.cpp ├── GCPC 17 (ABFHJ Unsolved) │ ├── GCPC 17 (With Edirorial).pdf │ ├── Joyride.cpp │ ├── Pants on Fire.cpp │ ├── Perpetuum Mobile.cpp │ ├── Uberwatch.cpp │ ├── Water Testing.cpp │ └── You Are Fired!.cpp ├── GCPC 18 (KL Unsolved) │ ├── Attack on Alpha-Zet.cpp │ ├── Battle Royale.cpp │ ├── Coolest Ski Route.cpp │ ├── Down The Pyramid.cpp │ ├── Expired License.cpp │ ├── Fighting Monsters.cpp │ ├── GCPC 18 (With Editorial).pdf │ ├── GPS.cpp │ ├── Hyper Illuminati.cpp │ ├── It's Time for a Montage.cpp │ ├── Jigsaw Puzzle.cpp │ └── Mountainers.cpp ├── LCPC 16 (BD Unsolved) │ ├── A Personal Voyage.cpp │ ├── Brief History of Time.cpp │ ├── Cheers.cpp │ ├── Dealing with Sequences.cpp │ ├── Elements.cpp │ ├── Find the Divisors.cpp │ ├── Great Journey.cpp │ ├── Hack My Server.cpp │ ├── I Love Phuket.cpp │ └── Kill 'Em All.cpp ├── LCPC 17 (DF Unsolved) │ ├── Ballon D'Or.cpp │ ├── Isco's House.cpp │ ├── Madridista.cpp │ ├── Mercato.cpp │ ├── Milano Derby.cpp │ ├── Qatar 2022.cpp │ ├── Road to Camp Nou.cpp │ ├── Roger and Rafa.cpp │ ├── Ronaldo the Wise.cpp │ ├── Santiago Bernabeu.cpp │ ├── Syria in Russia 2018.cpp │ ├── The Egyptian Derby.cpp │ └── Triple Football Stars Tournament.cpp ├── LCPC 18 (K Unsolved) │ ├── Fun With Strings.cpp │ ├── Gifts Unjust Division.cpp │ ├── Group of Friends.cpp │ ├── Hussein's Army.cpp │ ├── Rhombuses Inside Rectangles.cpp │ ├── Ropes Connection.cpp │ ├── Shahhoud Training for a Marathon.cpp │ ├── Strips Coloring.cpp │ ├── Tonystan.cpp │ ├── Triple Jumps.cpp │ └── Zootopia's New Metro System.cpp ├── LCPC 19 (EJ Unsolved) │ ├── Baleez.cpp │ ├── Bitwise OR.cpp │ ├── Colored Shelves.cpp │ ├── Digit Count.cpp │ ├── Expected Sum.cpp │ ├── Get The Sum.cpp │ ├── Inequality Headache.cpp │ ├── Is Divisible.cpp │ ├── LCPC 19 (Without Editorial).pdf │ ├── Mr. AH and the Beautiful Substring.cpp │ ├── Salah and Encryption.cpp │ └── World Cup.cpp ├── LCPC 20 │ ├── Dice Game.cpp │ ├── Diffonacci.cpp │ ├── Digits.cpp │ ├── Game.cpp │ ├── Gifts.cpp │ ├── Good Grid.cpp │ ├── Good String.cpp │ ├── Instaduck.cpp │ ├── LCPC 20 (Without Editorial).pdf │ ├── Lucky Numbers.cpp │ ├── Magic Gates.cpp │ ├── Mahmoud and Unique List.cpp │ ├── Minimum X.cpp │ └── Stock Market.cpp ├── LCPC 21 │ ├── Consistent Tournament.cpp │ ├── Even Pairs.cpp │ ├── GGCD.cpp │ ├── How to be a Legend.cpp │ ├── Kofta Never Lose.cpp │ ├── LCPC 2021 (Without Editorial).pdf │ ├── New LIS Problem.cpp │ ├── Perfect Subarrays.cpp │ ├── Photo Album.cpp │ ├── Somar's Challenge.cpp │ ├── Somar's Game.cpp │ ├── Strange School.cpp │ └── Yet Another Partition Problem.cpp ├── MCPC 19 (D Unsolved) │ ├── Are You Safe.cpp │ ├── Help The Support Lady.cpp │ ├── I Don't Want To Pay For The Late Jar.cpp │ ├── Kitchen Plates.cpp │ ├── MCPC 19 (Without Editorial).pdf │ ├── Mental Rotation.cpp │ ├── Millitary Class.cpp │ ├── Optimal Slots.cpp │ ├── SpongeBob SquarePants.cpp │ ├── Time Out.cpp │ └── To Crash or Not to Crash.cpp ├── NCPC 15 (HIJ Unsolved) │ ├── Adjoin the Networks.cpp │ ├── Bell Ringing.cpp │ ├── Cryptographer's Conundrum.cpp │ ├── Disastrous Downtime.cpp │ ├── Entertainment Box.cpp │ ├── Floppy Music.cpp │ ├── Goblin Garden Guards.cpp │ └── NCPC 15 (With Editorial).pdf ├── NCPC 16 (FHIK Unsolved) │ ├── Artwork.cpp │ ├── Bless You Autocorrect.cpp │ ├── Card Hand Sorting.cpp │ ├── Daydreaming Stockbroker.cpp │ ├── Exponial.cpp │ ├── Game Rank.cpp │ ├── Jumbled Compass.cpp │ └── NCPC 16 (With Editorial).pdf ├── NCPC 17 (ACEFH Unsolved) │ ├── Best Relay Team.cpp │ ├── Distinctive Character.cpp │ ├── Galactic Collegiate Programming Contest.cpp │ ├── Import Spaghetti.cpp │ ├── Judging Moose.cpp │ ├── Kayaking Trip.cpp │ └── NCPC 17 (With Editorial).pdf ├── NCPC 18 (ADEFGK Unsolved) │ ├── Baby Bites.cpp │ ├── Code Cleanup.cpp │ ├── House Lawn.cpp │ ├── Intergalactic Bidding.cpp │ ├── Jumbled String.cpp │ └── NCPC 18 (With Editorial).pdf ├── NWERC 18 (ADFHJ Unsolved) │ ├── Brexit Negotiations.cpp │ ├── Circuit Board Design.cpp │ ├── Equality Control.cpp │ ├── Game Design.cpp │ ├── Inflation.cpp │ ├── Kleptography.cpp │ └── NWERC 18 (With Editorial).pdf ├── PNPC 18 (IM Unsolved) │ ├── Contest Setting.cpp │ ├── Coprime Integers.cpp │ ├── Cops and Robbers.cpp │ ├── Count the Bits.cpp │ ├── Exam.cpp │ ├── Goat on a Rope.cpp │ ├── Knockout.cpp │ ├── Liars.cpp │ ├── PNPC 18 (With Editorial).pdf │ ├── Rectangles.cpp │ ├── Repeating Goldbach.cpp │ └── Time Limits.cpp ├── SCPC 18 (CEFJL Unsolved) │ ├── Binary Hamming.cpp │ ├── Bugged System.cpp │ ├── Carnival Slots.cpp │ ├── Hello SCPC 18.cpp │ ├── Is Topo Logical.cpp │ ├── Rise of the Robots.cpp │ ├── SCPC 18 (Without Editorial).pdf │ └── Tourists' Tour.cpp ├── SEERC 17 (BCDEHIJL Unsolved) │ ├── Binary Transformation.cpp │ ├── Concerts.cpp │ ├── Escape Room.cpp │ ├── Robots.cpp │ └── SEERC 17 (Without Editorial).pdf ├── SEERC 19 (ACDFHJK Unsolved) │ ├── Absolute Game.cpp │ ├── Level Up.cpp │ ├── Life Transfer.cpp │ ├── Projection.cpp │ └── SEERC 19 (With Editorial).pdf ├── SWERC 13 (ABDEHJ Unsolved) │ ├── Odd and Even Zeroes.cpp │ ├── SWERC 13 (Without Editorial).pdf │ ├── Shopping Mall.cpp │ ├── Trending Topic.cpp │ └── VivoParc.cpp ├── SWERC 16 (BDEGHIJ Unsolved) │ ├── Balls and Needles.cpp │ ├── Candle Box.cpp │ ├── Performance Review.cpp │ ├── SWERC 16 (With Editorial).pdf │ └── Within Arm's Reach.cpp ├── SWERC 17 (BCDGHI Unsolved) │ ├── Blowing Candles.cpp │ ├── Cakey McCakeFree.cpp │ ├── Frosting on the Cake.cpp │ ├── Ingredients.cpp │ ├── SWERC 17 (With Editorial).pdf │ └── Shattered Cake.cpp ├── TCPC 17 (BEIL Unsolved) │ ├── A Missing Problem in TCPC 2017.cpp │ ├── Buying Product.cpp │ ├── Largest Group.cpp │ ├── Poor Ramzi.cpp │ ├── Printing Books.cpp │ ├── Robots.cpp │ ├── Shahhoud Training Hussein.cpp │ ├── TCPC 17 (Without Editorial).pdf │ └── The Volcano Erruption.cpp └── TCPC 18 (DGJ Unsolved) │ ├── Can Shahhoud Solve it.cpp │ ├── Create Your Own Nim Game.cpp │ ├── Defeat the Monsters.cpp │ ├── Don't Ever Ask a Girl Her Codeforces Account.cpp │ ├── Nim Cheater.cpp │ ├── Odd & Even Count.cpp │ ├── Odd & Even Queries.cpp │ ├── Quantum Stones.cpp │ ├── TCPC 18 (Without Editorial).pdf │ └── UCL Game Night.cpp ├── Pre-Written Code ├── Data Structures │ ├── 2D Fenwick Tree.cpp │ ├── 2D Prefix Sums.cpp │ ├── 2D Segment Tree.cpp │ ├── Binary Trie.cpp │ ├── DSU (FAST).cpp │ ├── DSU + History.cpp │ ├── DSU with Rollback.cpp │ ├── Explicit Treap.cpp │ ├── ExplicitTreap (BBST).cpp │ ├── Fenwick Tree.cpp │ ├── Implicit Treap.cpp │ ├── Lazy Segment Tree.cpp │ ├── Merge Sort Tree Dynamic.cpp │ ├── Merge Sort Tree Static.cpp │ ├── Persistent Segment Tree.cpp │ ├── Segment Tree Beats.cpp │ ├── Segment Tree.cpp │ ├── Sparse Table.cpp │ ├── Wavelet Tree (Swap or No Update).cpp │ └── Wavelet Tree (Toggle Update).cpp ├── Flows Algorithms │ ├── Bipartite Matching (Hopcroft-Karp).cpp │ ├── Bipartite Matching (Kuhn).cpp │ ├── Max Flow (Dinic).cpp │ ├── Max Flow (Edmond Karp).cpp │ ├── Min Cost Flow (Dijkstra).cpp │ ├── Min Cost Flow (SPFA).cpp │ └── Min Cost Matching (MCF).cpp ├── Geometry │ ├── Closest Pair of Points.cpp │ ├── Convex Hull Trick.cpp │ ├── Convex Hull.cpp │ ├── Li Chao Tree.cpp │ ├── Minimum Covering Circle.cpp │ ├── Old Geometry.cpp │ ├── Point Location and Intersection.cpp │ └── Polygon.cpp ├── Graph Algorithms │ ├── 0-1 BFS.cpp │ ├── 2SAT.cpp │ ├── BFS DFS.cpp │ ├── Bellman-Ford.cpp │ ├── Biconnected Components.cpp │ ├── Bridges & Articulation Points.cpp │ ├── Dijkstra (Dense).cpp │ ├── Dijkstra (Sparse).cpp │ ├── Dominator Tree.cpp │ ├── Euler Tour Directed.cpp │ ├── Euler Tour Undirected.cpp │ ├── Finding Cycles + Topological Sort.cpp │ ├── Floyd-Warshall APSP.cpp │ ├── Functional Graphs.cpp │ ├── Graph Coloring.cpp │ ├── Johnson APSP.cpp │ ├── Kruskal's MST.cpp │ ├── Manhattan MST.cpp │ ├── Most Vital Edge.cpp │ ├── Most Vital Node.cpp │ ├── Prim's MST.cpp │ └── Strongly-Connected Components.cpp ├── Number Theory │ ├── Basic Operations.cpp │ ├── Fast Fourier Transform (FFT).cpp │ ├── Matrix Operations.cpp │ ├── Number Theoretic Transform (NTT).cpp │ └── Sieving.cpp ├── String Algorithms │ ├── Aho-Corasick - Array Based.cpp │ ├── Aho-Corassick.cpp │ ├── Duval's Algorithm.cpp │ ├── Dynamic Hash.cpp │ ├── Manacher.cpp │ ├── Prefix Function.cpp │ ├── Suffix Array (NlogN).cpp │ ├── Suffix Array.cpp │ └── Z Algorithm.cpp └── Tree Algorithms │ ├── Centroid Decomposition.cpp │ ├── Heavy Light Decomposition.cpp │ ├── Lowest Common Ancestor (Binary Lifting).cpp │ ├── Lowest Common Ancestor (RMQ).cpp │ └── Tree Isomorphism.cpp ├── Problems Archive ├── 0000 - 0999 │ ├── 0000 - Stones.cpp │ ├── 0001 - Towers Of Hanoi.cpp │ ├── 0002 - 3 Bags.cpp │ ├── 0003 - Cutting Sticks.cpp │ ├── 0004 - Knapsack.cpp │ ├── 0005 - Longest Common Subsequence.cpp │ ├── 0006 - Make Palindrome.cpp │ ├── 0007 - Optimal Array Multiplication Sequence.cpp │ ├── 0008 - Game Of Sum.cpp │ ├── 0009 - Monster Valley.cpp │ ├── 0010 - Bachet's Game.cpp │ ├── 0011 - Injured Queens Problem.cpp │ ├── 0012 - Longest Run on a Snowboard.cpp │ ├── 0013 - New Theatre Square.cpp │ ├── 0014 - Weights and Measures.cpp │ ├── 0015 - Strings.cpp │ ├── 0016 - History Grading.cpp │ ├── 0017 - Unidirectional TSP.cpp │ ├── 0018 - Children's Game.cpp │ ├── 0019 - Foreign Exchange.cpp │ ├── 0020 - File Fragmentation.cpp │ ├── 0021 - Lining Up.cpp │ ├── 0022 - Solve It.cpp │ ├── 0023 - A Mid Summer Night's Dream.cpp │ ├── 0024 - Number Sequence.cpp │ ├── 0025 - Closest Sums.cpp │ ├── 0026 - All in All.cpp │ ├── 0027 - Camel Trading.cpp │ ├── 0028 - Shoemaker's Problem.cpp │ ├── 0029 - Packets.cpp │ ├── 0030 - Minimal Coverage.cpp │ ├── 0031 - Ants.cpp │ ├── 0032 - Add All.cpp │ ├── 0033 - Watering Grass.cpp │ ├── 0034 - Wine Trading In Gregovia.cpp │ ├── 0035 - Evil Straw Warts Live.cpp │ ├── 0036 - The Trip, 2007.cpp │ ├── 0037 - The Closest Pair Problem.cpp │ ├── 0038 - An Anti-Arithmetic Permutation.cpp │ ├── 0039 - Jill Rides Again.cpp │ ├── 0040 - Gone Fishing.cpp │ ├── 0041 - Salary For Robots.cpp │ ├── 0042 - Sliding Window Maximum.cpp │ ├── 0043 - Joy of The Cylinder Game.cpp │ ├── 0044 - Foregone Solution.cpp │ ├── 0045 - Cryptopangrams.cpp │ ├── 0046 - You Can Go Your Own Way.cpp │ ├── 0047 - Restoring 3 Numbers.cpp │ ├── 0048 - Make Them Equal.cpp │ ├── 0049 - Gourmet Cat.cpp │ ├── 0050 - Walking Robot.cpp │ ├── 0051 - Two Teams.cpp │ ├── 0052 - Shovels Shop.cpp │ ├── 0053 - Building Palindromes.cpp │ ├── 0054 - Reachable Numbers.cpp │ ├── 0055 - Long Number.cpp │ ├── 0056 - Increasing Subsequence.cpp │ ├── 0057 - N Problems During K Days.cpp │ ├── 0058 - Minimum Array.cpp │ ├── 0059 - Maximum Balanced Circle.cpp │ ├── 0060 - Manhattan Crepe Cart.cpp │ ├── 0061 - Remainder.cpp │ ├── 0062 - Polycarp Training.cpp │ ├── 0063 - Good String.cpp │ ├── 0064 - Almost All Divisors.cpp │ ├── 0065 - Two Arrays and Sum of Functions.cpp │ ├── 0066 - Microtransactions.cpp │ ├── 0067 - Robot Programming Strategy.cpp │ ├── 0068 - Telephone Number.cpp │ ├── 0069 - Lost Numbers.cpp │ ├── 0070 - News Distribution.cpp │ ├── 0071 - Colored RBS.cpp │ ├── 0072 - Range Deleting.cpp │ ├── 0073 - Super Sale.cpp │ ├── 0074 - String To Palindrome.cpp │ ├── 0075 - String Partiton.cpp │ ├── 0076 - Collecting Cards.cpp │ ├── 0077 - Silent Classroom.cpp │ ├── 0078 - All The Vowels Please.cpp │ ├── 0079 - A Tale of Two Lands.cpp │ ├── 0080 - Cute Sequence.cpp │ ├── 0081 - LCMs Must Be Large.cpp │ ├── 0082 - A Pile of Stones.cpp │ ├── 0083 - Expansion Coefficient.cpp │ ├── 0084 - Party and Sweets.cpp │ ├── 0085 - Circle Metro.cpp │ ├── 0086 - Pairs.cpp │ ├── 0087 - Increasing by Modulo.cpp │ ├── 0088 - Good Triple.cpp │ ├── 0089 - Wrong Subtraction.cpp │ ├── 0090 - Two Gram.cpp │ ├── 0091 - Less or Equal.cpp │ ├── 0092 - Divide by 3, Multiply by 2.cpp │ ├── 0093 - Cyclic Components.cpp │ ├── 0094 - Consecutive Subsequence.cpp │ ├── 0095 - Remove Duplicates.cpp │ ├── 0096 - File Name.cpp │ ├── 0097 - Letters.cpp │ ├── 0098 - Almost Arithmetic.cpp │ ├── 0099 - Bus Video System.cpp │ ├── 0100 - Mentors.cpp │ ├── 0101 - Petya's Exams.cpp │ ├── 0102 - Cutting Grass.cpp │ ├── 0103 - Ehab Fails to Be Thanos.cpp │ ├── 0104 - Ehab is an Odd Person.cpp │ ├── 0105 - Ehab & a Special Coloring Problem.cpp │ ├── 0106 - Ehab & The Expected XOR Problem.cpp │ ├── 0107 - From Hero to Zero.cpp │ ├── 0108 - Catch Overflow.cpp │ ├── 0109 - Electrification.cpp │ ├── 0110 - Array Splitting.cpp │ ├── 0111 - Digit Sequence.cpp │ ├── 0112 - Nauuo & Votes.cpp │ ├── 0113 - Nauuo & Chess.cpp │ ├── 0114 - Nauuo & Cards.cpp │ ├── 0115 - Watermelon.cpp │ ├── 0116 - Theater Square.cpp │ ├── 0117 - Domino Piling.cpp │ ├── 0118 - Bit++.cpp │ ├── 0119 - Laurenty and Shop.cpp │ ├── 0120 - Watchmen.cpp │ ├── 0121 - Amr and The Large Array.cpp │ ├── 0122 - Equivalent Strings.cpp │ ├── 0123 - Chess Match.cpp │ ├── 0124 - Divide It.cpp │ ├── 0125 - Merge It.cpp │ ├── 0126 - Lose It.cpp │ ├── 0127 - Recover It.cpp │ ├── 0128 - Cover It.cpp │ ├── 0129 - Destroy It.cpp │ ├── 0130 - Casket of Star.cpp │ ├── 0131 - Filling Shapes.cpp │ ├── 0132 - Plus From Picture.cpp │ ├── 0133 - Beautiful Lyrics.cpp │ ├── 0134 - Leapfrog 1.cpp │ ├── 0135 - Leapfrog 2.cpp │ ├── 0136 - Mr. X.cpp │ ├── 0137 - Beautiful Array.cpp │ ├── 0138 - Toy Train.cpp │ ├── 0139 - Nearest Interesting Number.cpp │ ├── 0140 - Equalize Prices.cpp │ ├── 0141 - Computer Game.cpp │ ├── 0142 - Top Forces Strike Again.cpp │ ├── 0143 - Candy Box H.cpp │ ├── 0144 - Subsequences.cpp │ ├── 0145 - Vus the Cossack & a Contest.cpp │ ├── 0146 - Vus the Cossack & Strings.cpp │ ├── 0147 - Vus the Cossack & Numbers.cpp │ ├── 0148 - Graphs as a Service.cpp │ ├── 0149 - Class Treasurer.cpp │ ├── 0150 - Maxim & Biology.cpp │ ├── 0151 - Dima & a Bad XOR.cpp │ ├── 0152 - Problem for Nazar.cpp │ ├── 0153 - Stas & The Queue at The Buffet.cpp │ ├── 0154 - Number of Components.cpp │ ├── 0155 - Reverse a Substring.cpp │ ├── 0156 - Game With Telephone Number.cpp │ ├── 0157 - Alarm Clocks Everywhere.cpp │ ├── 0158 - Neko Finds Grapes.cpp │ ├── 0159 - Neko Performs Cat Furrier Transform.cpp │ ├── 0160 - Remove a Progression.cpp │ ├── 0161 - Yet Another Crosses Problem.cpp │ ├── 0162 - From S to T.cpp │ ├── 0163 - 1-2-K Game.cpp │ ├── 0164 - Stock Arbitraging.cpp │ ├── 0165 - Tilling Challenge.cpp │ ├── 0166 - Prefix Sum Primes.cpp │ ├── 0167 - Inscribed Figures.cpp │ ├── 0168 - Ugly Pairs.cpp │ ├── 0169 - Match Points.cpp │ ├── 0170 - Drinks Choosing.cpp │ ├── 0171 - Sport Mafia.cpp │ ├── 0172 - Basketball Exercice.cpp │ ├── 0173 - Submarine in the Rybinsk Sea.cpp │ ├── 0174 - OpenStreetMap.cpp │ ├── 0175 - Neko Does Math.cpp │ ├── 0176 - Parity.cpp │ ├── 0177 - Tape.cpp │ ├── 0178 - Meaningless Operations.cpp │ ├── 0179 - Ilya and a Colorful Walk.cpp │ ├── 0180 - Alyona and a Narrow Fridge.cpp │ ├── 0181 - Ramesses and Corner Invasion.cpp │ ├── 0182 - Frets On Fire.cpp │ ├── 0183 - Prime Minister.cpp │ ├── 0184 - Wow Factor.cpp │ ├── 0185 - Tiles.cpp │ ├── 0186 - Prime Graph.cpp │ ├── 0187 - Archaeology.cpp │ ├── 0188 - Vicky's Delivery Service.cpp │ ├── 0189 - Another One Bites the Dust.cpp │ ├── 0190 - Born This Way.cpp │ ├── 0191 - Crazy Diamond.cpp │ ├── 0192 - Dirty Deeds Done Dirt Cheap.cpp │ ├── 0193 - DIY Wooden Ladder.cpp │ ├── 0194 - Pillars.cpp │ ├── 0195 - Array Splitting.cpp │ ├── 0196 - Yet Another Subarray Problem.cpp │ ├── 0197 - Three Piles of Candies.cpp │ ├── 0198 - Odd Sum Segments.cpp │ ├── 0199 - Robot Breakout.cpp │ ├── 0200 - RGB Substring.cpp │ ├── 0201 - Connected Component on a Chessboard.cpp │ ├── 0202 - Kth Probable Element.cpp │ ├── 0203 - Adjacent Swaps.cpp │ ├── 0204 - Diverse Team.cpp │ ├── 0205 - Substrings Sort.cpp │ ├── 0206 - Equal Sums.cpp │ ├── 0207 - Points & Powers of Two.cpp │ ├── 0208 - Divisibility by 25.cpp │ ├── 0209 - X or What.cpp │ ├── 0210 - Latest Guests.cpp │ ├── 0211 - Mishka & Contest.cpp │ ├── 0212 - Reversing Encryption.cpp │ ├── 0213 - Alphabetic Removals.cpp │ ├── 0214 - Equalize The Remainders.cpp │ ├── 0215 - Reachability From The Capital.cpp │ ├── 0216 - Earth, Wind & Fire.cpp │ ├── 0217 - Rain & Umbrellas.cpp │ ├── 0218 - Serval & Bus.cpp │ ├── 0219 - Serval & Toy Bricks.cpp │ ├── 0220 - Serval & Parenthesis Sequence.cpp │ ├── 0221 - City Day.cpp │ ├── 0222 - Water Lily.cpp │ ├── 0223 - MP3.cpp │ ├── 0224 - Welfare State.cpp │ ├── 0225 - Matching vs Independent Set.cpp │ ├── 0226 - Rectangle Painting 1.cpp │ ├── 0227 - Xenia & Bit Operations.cpp │ ├── 0228 - Enemies Weak.cpp │ ├── 0229 - Sereja & Brackets.cpp │ ├── 0230 - Knight Tournament.cpp │ ├── 0231 - Important Exam.cpp │ ├── 0232 - Zero Array.cpp │ ├── 0233 - Maximum Median.cpp │ ├── 0234 - Ant Colony.cpp │ ├── 0235 - Serge & Dining Room.cpp │ ├── 0236 - Pashmak & Parmida's Problem.cpp │ ├── 0237 - Muddy Road.cpp │ ├── 0238 - Palindromic Substrings.cpp │ ├── 0239 - Degree Set.cpp │ ├── 0240 - Minimum Possible LCM.cpp │ ├── 0241 - You are Given Two Binary Strings.cpp │ ├── 0242 - You Are Given a Decimal String.cpp │ ├── 0243 - You Are Given a WASD String.cpp │ ├── 0244 - Print a 1337 String.cpp │ ├── 0245 - Life, The Universe & Everything.cpp │ ├── 0246 - Euler Totient Function.cpp │ ├── 0247 - Red Paint.cpp │ ├── 0248 - Detective Book.cpp │ ├── 0249 - Good Strings.cpp │ ├── 0250 - Playlist.cpp │ ├── 0251 - Minimum Triangulization.cpp │ ├── 0252 - Archery.cpp │ ├── 0253 - Tricky Sum.cpp │ ├── 0254 - Queries on a String.cpp │ ├── 0255 - Nearest Vectors.cpp │ ├── 0256 - Igor in The Museum.cpp │ ├── 0257 - Copying Data.cpp │ ├── 0258 - Misha & Permutations Summation.cpp │ ├── 0259 - Circle of Students.cpp │ ├── 0260 - Equal Rectangles.cpp │ ├── 0261 - Common Divisors.cpp │ ├── 0262 - Remove The Substring.cpp │ ├── 0263 - Boxers.cpp │ ├── 0264 - Complete The Project 1.cpp │ ├── 0265 - Complete The Project 2.cpp │ ├── 0266 - Extract Numbers.cpp │ ├── 0267 - Queries About Less or Equal Elements.cpp │ ├── 0268 - Make Palindrome.cpp │ ├── 0269 - Area of Two Circles' Intersection.cpp │ ├── 0270 - Mental Rotation.cpp │ ├── 0271 - SpongeBob SquarePants.cpp │ ├── 0272 - I Don't Want To Pay For The Late Jar.cpp │ ├── 0273 - Optimal Slots.cpp │ ├── 0274 - Millitary Class.cpp │ ├── 0275 - Time Out.cpp │ ├── 0276 - Are You Safe.cpp │ ├── 0277 - To Crash or Not to Crash.cpp │ ├── 0278 - Kitchen Plates.cpp │ ├── 0279 - Help The Support Lady.cpp │ ├── 0280 - IBM Chill Zone.cpp │ ├── 0281 - The Doors.cpp │ ├── 0282 - Nirvana.cpp │ ├── 0283 - Queen.cpp │ ├── 0284 - The Beatles.cpp │ ├── 0285 - Diverse Strings.cpp │ ├── 0286 - Parity Alternated Deletion.cpp │ ├── 0287 - Two Shuffled Sequences.cpp │ ├── 0288 - Equalize Them All.cpp │ ├── 0289 - Median String.cpp │ ├── 0290 - Choose Two Numbers.cpp │ ├── 0291 - Make Product Equal One.cpp │ ├── 0292 - Almost Equal.cpp │ ├── 0293 - Shortest Cycle.cpp │ ├── 0294 - Shopping Mall.cpp │ ├── 0295 - Odd and Even Zeroes.cpp │ ├── 0296 - BowWow and The Time Table.cpp │ ├── 0297 - Mislove Has Lost an Array.cpp │ ├── 0298 - Anna, Svyatoslav and Maps.cpp │ ├── 0299 - The Game of Osho.cpp │ ├── 0300 - Game of Nim Everywhere.cpp │ ├── 0301 - Propagating Tree.cpp │ ├── 0302 - Trending Topic.cpp │ ├── 0303 - There Are Two Types of Burgers.cpp │ ├── 0304 - Square Filling.cpp │ ├── 0305 - Gas Pipeline.cpp │ ├── 0306 - Number of Permutations.cpp │ ├── 0307 - XOR Guessing.cpp │ ├── 0308 - Guess The Number.cpp │ ├── 0309 - VivoParc.cpp │ ├── 0310 - Hotelier.cpp │ ├── 0311 - Block Adventure.cpp │ ├── 0312 - Round Corridor.cpp │ ├── 0313 - White Lines.cpp │ ├── 0314 - USB Flash Drives.cpp │ ├── 0315 - The Best Gift.cpp │ ├── 0316 - Load Balancing.cpp │ ├── 0317 - Gadgets For Dollars and Pounds.cpp │ ├── 0318 - Water Tree.cpp │ ├── 0319 - XORinacci.cpp │ ├── 0320 - Uniqueness.cpp │ ├── 0321 - Magic Grid.cpp │ ├── 0322 - A Prize No One Can Win.cpp │ ├── 0323 - Birthday Boy.cpp │ ├── 0324 - Cardboard Container.cpp │ ├── 0325 - Financial Planning.cpp │ ├── 0326 - Game Night.cpp │ ├── 0327 - Janitor Troubles.cpp │ ├── 0328 - Kingpin Escape.cpp │ ├── 0329 - Design Tutorial, Learn From Math.cpp │ ├── 0330 - Chips Moving.cpp │ ├── 0331 - Bad Prices.cpp │ ├── 0332 - Book Reading.cpp │ ├── 0333 - Equalizing by Division.cpp │ ├── 0334 - Restore Permutation.cpp │ ├── 0335 - Amsterdam Distance.cpp │ ├── 0336 - Detour.cpp │ ├── 0337 - Falling Apart.cpp │ ├── 0338 - Irrational Division.cpp │ ├── 0339 - King of the Waves.cpp │ ├── 0340 - Two Smal Strings.cpp │ ├── 0341 - Path Queries.cpp │ ├── 0342 - Cows and Sequences.cpp │ ├── 0343 - Collatz Conjecture.cpp │ ├── 0344 - 0-1 Tree.cpp │ ├── 0345 - Special Segments of Permutation.cpp │ ├── 0346 - Creating a Character.cpp │ ├── 0347 - Zmei Gorynich.cpp │ ├── 0348 - The Number of Good Substring.cpp │ ├── 0349 - Coloring Edges.cpp │ ├── 0350 - Unstable String Sort.cpp │ ├── 0351 - Prince and Princess.cpp │ ├── 0352 - Manhattan Mornings.cpp │ ├── 0353 - Vasya the Hipster.cpp │ ├── 0354 - Sum Queries.cpp │ ├── 0355 - Magic Stones.cpp │ ├── 0356 - Neko and Flashbacks.cpp │ ├── 0357 - Reachability From The Capital.cpp │ ├── 0358 - Tokitsukaze & Enhancement.cpp │ ├── 0359 - Tokitsukaze & Mahjong.cpp │ ├── 0360 - Tokitsukaze & Discard Items.cpp │ ├── 0361 - Tokitsukaze, CSL & Stone Game.cpp │ ├── 0362 - Keanu Reeves.cpp │ ├── 0363 - Number Circle.cpp │ ├── 0364 - Candies!.cpp │ ├── 0365 - Add on a Tree.cpp │ ├── 0366 - Paint the Numbers.cpp │ ├── 0367 - Koala & Lights.cpp │ ├── 0368 - Paint The Digits.cpp │ ├── 0369 - Cow & Snacks.cpp │ ├── 0370 - Into Blocks.cpp │ ├── 0371 - Yellow Cards.cpp │ ├── 0372 - The Number Of Products.cpp │ ├── 0373 - Swap Letters.cpp │ ├── 0374 - Ticket Game.cpp │ ├── 0375 - Best Relay Team.cpp │ ├── 0376 - Galactic Collegiate Programming Contest.cpp │ ├── 0377 - Import Spaghetti.cpp │ ├── 0378 - Judging a Moose.cpp │ ├── 0379 - Kayaking Trip.cpp │ ├── 0380 - Cards.cpp │ ├── 0381 - Multiplication Table.cpp │ ├── 0382 - Substring Game in the Lesson.cpp │ ├── 0383 - Alex & Julian.cpp │ ├── 0384 - 2048 Game.cpp │ ├── 0385 - Knights.cpp │ ├── 0386 - Perfect Team.cpp │ ├── 0387 - Make The Fence Great Again.cpp │ ├── 0388 - Prefixes.cpp │ ├── 0389 - Shooting.cpp │ ├── 0390 - White Sheet.cpp │ ├── 0391 - Swords.cpp │ ├── 0392 - Numerical Sequence.cpp │ ├── 0393 - Dawid & Bags of Candies.cpp │ ├── 0394 - Ania & Minimizing.cpp │ ├── 0395 - Anadi & Domino.cpp │ ├── 0396 - Marcin & Training Camp.cpp │ ├── 0397 - Distinct Digits.cpp │ ├── 0398 - Filling The Grid.cpp │ ├── 0399 - Primes & Multiplication.cpp │ ├── 0400 - Complete Tripartite.cpp │ ├── 0401 - Printing Books.cpp │ ├── 0402 - Shahhoud Training Hussein.cpp │ ├── 0403 - A Missing Problem in TCPC 2017.cpp │ ├── 0404 - Buying Product.cpp │ ├── 0405 - The Volcano Erruption.cpp │ ├── 0406 - Exam.cpp │ ├── 0407 - Contest Setting.cpp │ ├── 0408 - Goat on a Rope.cpp │ ├── 0409 - Repeating Goldbach.cpp │ ├── 0410 - Time Limits.cpp │ ├── 0411 - Knockout.cpp │ ├── 0412 - Liars.cpp │ ├── 0413 - Flattening.cpp │ ├── 0414 - Equalize Prices Again.cpp │ ├── 0415 - Social Network.cpp │ ├── 0416 - Pipes.cpp │ ├── 0417 - Distinct Characters Queries.cpp │ ├── 0418 - Special Permutations.cpp │ ├── 0419 - Can Shahhoud Solve it.cpp │ ├── 0420 - Defeat the Monsters.cpp │ ├── 0421 - UCL Game Night.cpp │ ├── 0422 - Create Your Own Nim Game.cpp │ ├── 0423 - Nim Cheater.cpp │ ├── 0424 - Don't Ever Ask a Girl Her Codeforces Account.cpp │ ├── 0425 - Odd & Even Queries.cpp │ ├── 0426 - Odd & Even Count.cpp │ ├── 0427 - Joyride.cpp │ ├── 0428 - Pants on Fire.cpp │ ├── 0429 - Uberwatch.cpp │ ├── 0430 - You Are Fired!.cpp │ ├── 0431 - XYZZY.cpp │ ├── 0432 - Lexical Addition.cpp │ ├── 0433 - Xtreme Rappers.cpp │ ├── 0434 - Minimum Permutation.cpp │ ├── 0435 - Reshuffle Teams.cpp │ ├── 0436 - Xandra & Tree.cpp │ ├── 0437 - Monokeros.cpp │ ├── 0438 - Ave Ceasar.cpp │ ├── 0439 - Alfa Pool.cpp │ ├── 0440 - Ranged Alfa Pool.cpp │ ├── 0441 - CME.cpp │ ├── 0442 - String Equalization.cpp │ ├── 0443 - Save The Nature.cpp │ ├── 0444 - Yet Another Dividing Into Teams.cpp │ ├── 0445 - Books Exchange.cpp │ ├── 0446 - Good Numbers.cpp │ ├── 0447 - Too Many Segments.cpp │ ├── 0448 - By Elevator Or Stairs.cpp │ ├── 0449 - Prime Subtraction.cpp │ ├── 0450 - Kill 'Em All.cpp │ ├── 0451 - Standard Free2Play.cpp │ ├── 0452 - Broken Keyboard.cpp │ ├── 0453 - Binary Palindromes.cpp │ ├── 0454 - Minimize The Integer.cpp │ ├── 0455 - Salary Changing.cpp │ ├── 0456 - Infinite Strings.cpp │ ├── 0457 - Pens & Pencils.cpp │ ├── 0458 - Rooms & Staircases.cpp │ ├── 0459 - The Football Season.cpp │ ├── 0460 - Good Ol' Number Coloring.cpp │ ├── 0461 - Restricted RPS.cpp │ ├── 0462 - Constanze Machine.cpp │ ├── 0463 - Shichikuji & Power Grid.cpp │ ├── 0464 - Payement Without Change.cpp │ ├── 0465 - Minimize the Permutation.cpp │ ├── 0466 - Platforms Jumping.cpp │ ├── 0467 - Binary String Minimizing.cpp │ ├── 0468 - Maximum Square.cpp │ ├── 0469 - Character Swap.cpp │ ├── 0470 - Tile Painting.cpp │ ├── 0471 - 0-1 MST.cpp │ ├── 0472 - Two Rival Students.cpp │ ├── 0473 - Magic Stick.cpp │ ├── 0474 - Dominated Subarray.cpp │ ├── 0475 - Yet Another Monster Killing Problem.cpp │ ├── 0476 - The Contest.cpp │ ├── 0477 - Fox & Card Game.cpp │ ├── 0478 - Industrial Nim.cpp │ ├── 0479 - Dexterina's Lab.cpp │ ├── 0480 - H Index.cpp │ ├── 0481 - Elevenagram.cpp │ ├── 0482 - The New President.cpp │ ├── 0483 - Encrypted Password.cpp │ ├── 0484 - Kids Love Candies.cpp │ ├── 0485 - Archery.cpp │ ├── 0486 - Connecting Islands.cpp │ ├── 0487 - Contest Hall Preparation.cpp │ ├── 0488 - Dalek's Invasion Easy.cpp │ ├── 0489 - Dalek's Invalion Medium.cpp │ ├── 0490 - Minimum Spanning Tree For Each Edge.cpp │ ├── 0491 - Gargari & Permutations.cpp │ ├── 0492 - Jzzhu & Cities.cpp │ ├── 0493 - The Text Splitting.cpp │ ├── 0494 - HDD is Outdated Technology.cpp │ ├── 0495 - Replace to Make Regular Bracket Sequence.cpp │ ├── 0496 - The Union of k-Segments.cpp │ ├── 0497 - Square Root of a Permutation.cpp │ ├── 0498 - Comparing Two Long Integers.cpp │ ├── 0499 - Dinner With Emma.cpp │ ├── 0500 - The Labyrinth.cpp │ ├── 0501 - Longest k-Good Segment.cpp │ ├── 0502 - Professor GukiZ's Robot.cpp │ ├── 0503 - Grandfather Dovlet's Calculator.cpp │ ├── 0504 - Pearls in a Row.cpp │ ├── 0505 - New Year Tree.cpp │ ├── 0506 - Counter Attack.cpp │ ├── 0507 - Make It Connected.cpp │ ├── 0508 - Sweet Problem.cpp │ ├── 0509 - PIN Codes.cpp │ ├── 0510 - Everyone is a Winner.cpp │ ├── 0511 - Secret Passwords.cpp │ ├── 0512 - Editor.cpp │ ├── 0513 - Dream Team.cpp │ ├── 0514 - Enumerating Rational Numbers.cpp │ ├── 0515 - Irreducible Basic Fractions.cpp │ ├── 0516 - Three Friends.cpp │ ├── 0517 - Snow Walking Robot.cpp │ ├── 0518 - Yet Another Broken Keyboard.cpp │ ├── 0519 - Remove One Element.cpp │ ├── 0520 - Nearest Opposite Parity.cpp │ ├── 0521 - Two Bracket Sequences.cpp │ ├── 0522 - Temporarily Unavailable.cpp │ ├── 0523 - K for the Price of One.cpp │ ├── 0524 - Petya and Exam.cpp │ ├── 0525 - Enchanted Artifact.cpp │ ├── 0526 - A Single Push.cpp │ ├── 0527 - Silly Mistake.cpp │ ├── 0528 - Sweets Eating.cpp │ ├── 0529 - Harmonious Graph.cpp │ ├── 0530 - Card Game.cpp │ ├── 0531 - Interesting Subarray.cpp │ ├── 0532 - Make Good.cpp │ ├── 0533 - Strange Device.cpp │ ├── 0534 - Minutes Before The New Year.cpp │ ├── 0535 - Candies Division.cpp │ ├── 0536 - Angry Students.cpp │ ├── 0537 - HyperSet.cpp │ ├── 0538 - Garland.cpp │ ├── 0539 - Mike and Feet.cpp │ ├── 0540 - Stones.cpp │ ├── 0541 - Find Divisible.cpp │ ├── 0542 - Dice Tower.cpp │ ├── 0543 - Mezo Playing Zoma.cpp │ ├── 0544 - Just Eat It.cpp │ ├── 0545 - Fadi and LCM.cpp │ ├── 0546 - Dr. Evil Underscores.cpp │ ├── 0547 - Love 'A'.cpp │ ├── 0548 - Mr. Kitayuta, The Treasure Hunter.cpp │ ├── 0549 - Deadline.cpp │ ├── 0550 - Yet Another Meme Problem.cpp │ ├── 0551 - Two Arrays.cpp │ ├── 0552 - Maximal Continous Rest.cpp │ ├── 0553 - Balanced Team.cpp │ ├── 0554 - Books.cpp │ ├── 0555 - Game with Strings.cpp │ ├── 0556 - Multiplication Table.cpp │ ├── 0557 - Ciel The Commander.cpp │ ├── 0558 - Distance Tree.cpp │ ├── 0559 - Minimax Problem.cpp │ ├── 0560 - Messenger Simulator.cpp │ ├── 0561 - Hamburgers.cpp │ ├── 0562 - Really Big Numbers.cpp │ ├── 0563 - GukiZ Hates Boxes.cpp │ ├── 0564 - Two Strings.cpp │ ├── 0565 - ConneR and the ARC Markland.cpp │ ├── 0566 - Joe is on TV.cpp │ ├── 0567 - Neko's Maze Game.cpp │ ├── 0568 - Aroma's Search.cpp │ ├── 0569 - Collecting Coins.cpp │ ├── 0570 - Collecting Packages.cpp │ ├── 0571 - Product of Three Numbers.cpp │ ├── 0572 - MEX Maximizing.cpp │ ├── 0573 - Display The Number.cpp │ ├── 0574 - Infinite Prefixes.cpp │ ├── 0575 - Obtain The String.cpp │ ├── 0576 - Same GCDs.cpp │ ├── 0577 - Suits.cpp │ ├── 0578 - Blocks.cpp │ ├── 0579 - Shawarma Tent.cpp │ ├── 0580 - Portals.cpp │ ├── 0581 - Artwork.cpp │ ├── 0582 - Exponial.cpp │ ├── 0583 - Game Rank.cpp │ ├── 0584 - Even But Not Even.cpp │ ├── 0585 - Array Sharpening.cpp │ ├── 0586 - Mind Control.cpp │ ├── 0587 - Irreducible Anagrams.cpp │ ├── 0588 - Array With Odd Sum.cpp │ ├── 0589 - Food Buying.cpp │ ├── 0590 - Yet Another Walking Robot.cpp │ ├── 0591 - Fight With Monsters.cpp │ ├── 0592 - Berland Beauty.cpp │ ├── 0593 - A Whole New Word.cpp │ ├── 0594 - Bracket Subsequence.cpp │ ├── 0595 - Division and Union.cpp │ ├── 0596 - Beautiful Regional Contest.cpp │ ├── 0597 - Coffee & Coursework.cpp │ ├── 0598 - Little Pony and Crystal Mine.cpp │ ├── 0599 - Case of Matryochkas.cpp │ ├── 0600 - Even Odds.cpp │ ├── 0601 - Cheap Travel.cpp │ ├── 0602 - Dreamoon and Stairs.cpp │ ├── 0603 - Eevee.cpp │ ├── 0604 - Equidistant Strings.cpp │ ├── 0605 - Fox and Snake.cpp │ ├── 0606 - Tram.cpp │ ├── 0607 - George and Sleep.cpp │ ├── 0608 - Inbox.cpp │ ├── 0609 - Initial Bet.cpp │ ├── 0610 - Magnets.cpp │ ├── 0611 - Mashmokh and Lights.cpp │ ├── 0612 - MUH and Sticks.cpp │ ├── 0613 - Olesya and Rodion.cpp │ ├── 0614 - Pashmak and Garden.cpp │ ├── 0615 - Playing with Paper.cpp │ ├── 0616 - Stones on the Table.cpp │ ├── 0617 - Shaass and Oskols.cpp │ ├── 0618 - OR in Matrix.cpp │ ├── 0619 - Vitaly and Strings.cpp │ ├── 0620 - Find Marble.cpp │ ├── 0621 - 2Char.cpp │ ├── 0622 - Perform the Combo.cpp │ ├── 0623 - Even Subset Sum Problem.cpp │ ├── 0624 - Count Subrectangles.cpp │ ├── 0625 - Unusual Competitions.cpp │ ├── 0626 - Two Regular Polygon.cpp │ ├── 0627 - Bogosort.cpp │ ├── 0628 - Adding Powers.cpp │ ├── 0629 - Count the Arrays.cpp │ ├── 0630 - Yet Another Tetris Problem.cpp │ ├── 0631 - Yet Another Palindrome Problem.cpp │ ├── 0632 - Frog Jumps.cpp │ ├── 0633 - Pair of Topics.cpp │ ├── 0634 - Sleeping Schedule.cpp │ ├── 0635 - Maximum White Subtree.cpp │ ├── 0636 - Add Odd Subtract Even.cpp │ ├── 0637 - Weird Sort.cpp │ ├── 0638 - Three Integers.cpp │ ├── 0639 - EhAb AnD gCd.cpp │ ├── 0640 - CopyCopyCopyCopyCopy.cpp │ ├── 0641 - Ehab and Path-etic MEXs.cpp │ ├── 0642 - Ehab the Xorsist.cpp │ ├── 0643 - Baby Bites.cpp │ ├── 0644 - Code Cleanup.cpp │ ├── 0645 - House Lawn.cpp │ ├── 0646 - Intergalactic Bidding.cpp │ ├── 0647 - Jumbled String.cpp │ ├── 0648 - Bad Ugly Numbers.cpp │ ├── 0649 - Maximums.cpp │ ├── 0650 - Permutation Partitions.cpp │ ├── 0651 - Prefix Suffix Palindrome.cpp │ ├── 0652 - Soldier and a Number Game.cpp │ ├── 0653 - Sum of Odd Integers.cpp │ ├── 0654 - Princesses and Princes.cpp │ ├── 0655 - Game with Chips.cpp │ ├── 0656 - Divisibility Problem.cpp │ ├── 0657 - Kth Beautiful String.cpp │ ├── 0658 - Ternary XOR.cpp │ ├── 0659 - Carousel.cpp │ ├── 0660 - Tree Queries.cpp │ ├── 0661 - Make K Equal.cpp │ ├── 0662 - Attack on Alpha-Zet.cpp │ ├── 0663 - Battle Royale.cpp │ ├── 0664 - Coolest Ski Route.cpp │ ├── 0665 - Down The Pyramid.cpp │ ├── 0666 - Expired License.cpp │ ├── 0667 - Fighting Monsters.cpp │ ├── 0668 - GPS.cpp │ ├── 0669 -Hyper Illuminati.cpp │ ├── 0670 - It's Time for a Montage.cpp │ ├── 0671 - Jigsaw Puzzle.cpp │ ├── 0672 - Mountainers.cpp │ ├── 0673 - Dalek's Invasion Medium.cpp │ ├── 0674 - Thanos Sort.cpp │ ├── 0675 - Exercicing Walk.cpp │ ├── 0676 - Composite Coloring.cpp │ ├── 0677 - K-Complete Word.cpp │ ├── 0678 - Walk on Matrix.cpp │ ├── 0679 - Height All The Same.cpp │ ├── 0680 - Fedor and New Game.cpp │ ├── 0681 - Dreamoon and Ranking Collection.cpp │ ├── 0682 - Dreamoon Likes Permutations.cpp │ ├── 0683 - Dreamoon Likes Coloring.cpp │ ├── 0684 - Dreamoon Likes Sequences.cpp │ ├── 0685 - Chewbacca and a Number.cpp │ ├── 0686 - Elections.cpp │ ├── 0687 - A & B & Compilation Errors.cpp │ ├── 0688 - Vestigium.cpp │ ├── 0689 - Nesting Depth.cpp │ ├── 0690 - Parenting Partnering Returns.cpp │ ├── 0691 - Again About Distancing.cpp │ ├── 0692 - Bad Multisets.cpp │ ├── 0693 - Circles.cpp │ ├── 0694 - Fireballs.cpp │ ├── 0695 - King and Taverns.cpp │ ├── 0696 - Little Artem.cpp │ ├── 0697 - Kind Anton.cpp │ ├── 0698 - Eugene and an Array.cpp │ ├── 0699 - Challenges in School No.41.cpp │ ├── 0700 - Level Statistics.cpp │ ├── 0701 - Middle Class.cpp │ ├── 0702 - Circles of Monsters.cpp │ ├── 0703 - Minimum Euler Cycle.cpp │ ├── 0704 - Jzzhu and Children.cpp │ ├── 0705 - Mike and Fun.cpp │ ├── 0706 - Simple Game.cpp │ ├── 0707 - Soldiers and Badges.cpp │ ├── 0708 - Tavas and Nafas.cpp │ ├── 0709 - Toy Cars.cpp │ ├── 0710 - Pattern Matching.cpp │ ├── 0711 - Pascal Walk.cpp │ ├── 0712 - Square Dance.cpp │ ├── 0713 - Filling Diamonds.cpp │ ├── 0714 - Sorted Adjacent Differences.cpp │ ├── 0715 - Powered Addition.cpp │ ├── 0716 - Edge Weight Assignment.cpp │ ├── 0717 - Water Testing.cpp │ ├── 0718 - Perpetuum Mobile.cpp │ ├── 0719 - Robots.cpp │ ├── 0720 - Candies and Two Sisters.cpp │ ├── 0721 - Construct The String.cpp │ ├── 0722 - Two Teams Composing.cpp │ ├── 0723 - Anti Sudoku.cpp │ ├── 0724 - Three Blocks Palindrome.cpp │ ├── 0725 - Robots on a Grid.cpp │ ├── 0726 - Yet Another Division Into Teams.cpp │ ├── 0727 - Totient Extreme.cpp │ ├── 0728 - Ichihime and Triangle.cpp │ ├── 0729 - Kana and Dragon Quest game.cpp │ ├── 0730 - Linova and Kingdom.cpp │ ├── 0731 - Xenia and Colorful Gems.cpp │ ├── 0732 - Euler Totient Function Sieve.cpp │ ├── 0733 - LCM Sum.cpp │ ├── 0734 - Batchman and GCD.cpp │ ├── 0735 - GCD Extreme.cpp │ ├── 0736 - Divisor Path.cpp │ ├── 0737 - Quasi Binary.cpp │ ├── 0738 - Two Rabbits.cpp │ ├── 0739 - Longest Palindrome.cpp │ ├── 0740 - Air Conditioner.cpp │ ├── 0741 - Shortest and Longest LIS.cpp │ ├── 0742 - 1Trees and Queries.cpp │ ├── 0743 - Totient in Permutation.cpp │ ├── 0744 - Golu and Sweetness.cpp │ ├── 0745 - Another New Function.cpp │ ├── 0746 - Simple Calculations.cpp │ ├── 0747 - Googolplex.cpp │ ├── 0748 - Automatic Banking.cpp │ ├── 0749 - BasketBall Competition.cpp │ ├── 0750 - Coins Distribution.cpp │ ├── 0751 - Gregory's House.cpp │ ├── 0752 - Bike Tour.cpp │ ├── 0753 - Bus Routes.cpp │ ├── 0754 - Robot Path Decoding.cpp │ ├── 0755 - Minimum Vertex Cover.cpp │ ├── 0756 - Domino Tiling.cpp │ ├── 0757 - Birthday.cpp │ ├── 0758 - Expogo.cpp │ ├── 0759 - Balanced Bouldering.cpp │ ├── 0760 - Candies.cpp │ ├── 0761 - Balanced Array.cpp │ ├── 0762 - Alternating Subsequence.cpp │ ├── 0763 - Constant Palindrome Sum.cpp │ ├── 0764 - Weights Distributing.cpp │ ├── 0765 - Quantum Stones.cpp │ ├── 0766 - Largest Group.cpp │ ├── 0767 - GukiZ and Contest.cpp │ ├── 0768 - Poor Ramzi.cpp │ ├── 0769 - Distinctive Character.cpp │ ├── 0770 - The Cut.cpp │ ├── 0771 - Snails.cpp │ ├── 0772 - Perspective.cpp │ ├── 0773 - Nastya and Rice.cpp │ ├── 0774 - Natsya and Door.cpp │ ├── 0775 - Nastya and Strange Generator.cpp │ ├── 0776 - Nastya and Scoreboard.cpp │ ├── 0777 - Fire on Field.cpp │ ├── 0778 - Triangulation.cpp │ ├── 0779 - Road to Zero.cpp │ ├── 0780 - Binary Period.cpp │ ├── 0781 - Yet Another Counting Problem.cpp │ ├── 0782 - Multiple Test Cases.cpp │ ├── 0783 - Phoenix and Balance.cpp │ ├── 0784 - Phoenix and Beauty.cpp │ ├── 0785 - Phoenix and Distribution.cpp │ ├── 0786 - OverExcited Fan.cpp │ ├── 0787 - OverRandomized.cpp │ ├── 0788 - Friends and Gifts.cpp │ ├── 0789 - Baklava Tray.cpp │ ├── 0790 - Coffee.cpp │ ├── 0791 - Dull Chocolates.cpp │ ├── 0792 - Flipping El Fetiera.cpp │ ├── 0793 - Flow Decomposition.cpp │ ├── 0794 - Funny Frogs.cpp │ ├── 0795 - Sum of Round Numbers.cpp │ ├── 0796 - Same Parity Summands.cpp │ ├── 0797 - Kth Not Divisible by N.cpp │ ├── 0798 - Alice Bob and Candies.cpp │ ├── 0799 - Binary String Reconstruction.cpp │ ├── 0800 - Special Permutation.cpp │ ├── 0801 - Constructing the Array.cpp │ ├── 0802 - Incremental House of Pancakes.cpp │ ├── 0803 - Security Update.cpp │ ├── 0804 - Ternary String.cpp │ ├── 0805 - Stacking Boxes.cpp │ ├── 0806 - Coin Change.cpp │ ├── 0807 - Is Bigger Smarter.cpp │ ├── 0808 - MODEX.cpp │ ├── 0809 - Leading and Trailing.cpp │ ├── 0810 - The Last Digit.cpp │ ├── 0811 - Parking Lot.cpp │ ├── 0812 - Magic of the Locker.cpp │ ├── 0813 - Copying Books.cpp │ ├── 0814 - Jewel Eating Monsters.cpp │ ├── 0815 - Just Add It.cpp │ ├── 0816 - Euclid's Problem.cpp │ ├── 0817 - Duff and Meat.cpp │ ├── 0818 - Game of Robots.cpp │ ├── 0819 - George and Accomodation.cpp │ ├── 0820 - Vanya and Cubes.cpp │ ├── 0821 - Vasya and Socks.cpp │ ├── 0822 - Vitaly and Night.cpp │ ├── 0823 - Appleman and Easy Task.cpp │ ├── 0824 - Saitama Destroys Hotel.cpp │ ├── 0825 - Tavas and SaDDas.cpp │ ├── 0826 - Vanya and Books.cpp │ ├── 0827 - Center Allignment.cpp │ ├── 0828 - Anton and Currency you all Know.cpp │ ├── 0829 - Array.cpp │ ├── 0830 - Caisa and Pylons.cpp │ ├── 0831 - Far Relative's Problem.cpp │ ├── 0832 - Pasha and Stick.cpp │ ├── 0833 - TL.cpp │ ├── 0834 - Twins.cpp │ ├── 0835 - Battle Simulation.cpp │ ├── 0836 - Brexit.cpp │ ├── 0837 - Charles in Charge.cpp │ ├── 0838 - Ohana Cleans Up.cpp │ ├── 0839 - Caisa and Sugar.cpp │ ├── 0840 - Cutting Banner.cpp │ ├── 0841 - Internet Address.cpp │ ├── 0842 - Lecture.cpp │ ├── 0843 - Mr. Kitayuta's Gift.cpp │ ├── 0844 - Palindromic Times.cpp │ ├── 0845 - Set of Strings.cpp │ ├── 0846 - Tanya and Postcard.cpp │ ├── 0847 - Amusing Joke.cpp │ ├── 0848 - cAPS lOCK.cpp │ ├── 0849 - Chat Room.cpp │ ├── 0850 - Comparing Strings.cpp │ ├── 0851 - DNA Allignment.cpp │ ├── 0852 - Dubstep.cpp │ ├── 0853 - Football.cpp │ ├── 0854 - Strings of Power.cpp │ ├── 0855 - Professor GukiZ and Two Arrays.cpp │ ├── 0856 - Word.cpp │ ├── 0857 - ZgukistringZ.cpp │ ├── 0858 - Equivalent Strings.cpp │ ├── 0859 - Palindromization.cpp │ ├── 0860 - Toy Soldiers.cpp │ ├── 0861 - Two Pirates.cpp │ ├── 0862 - Meteor Flow.cpp │ ├── 0863 - Army Buddies.cpp │ ├── 0864 - Sagheer and Nubian Market.cpp │ ├── 0865 - Getting in Line.cpp │ ├── 0866 - Don't Get Rooked.cpp │ ├── 0867 - 23 out of 5.cpp │ ├── 0868 - Easter Eggs.cpp │ ├── 0869 - Jamie's Contact Groups.cpp │ ├── 0870 - Lemonade Trade.cpp │ ├── 0871 - Multiplying Digits.cpp │ ├── 0872 - Driver Disagreement.cpp │ ├── 0873 - Projection.cpp │ ├── 0874 - Maximum Sum.cpp │ ├── 0875 - Maximum Sum on a Torus.cpp │ ├── 0876 - Potholers.cpp │ ├── 0877 - Taxi.cpp │ ├── 0878 - Total Flow.cpp │ ├── 0879 - Shopping II.cpp │ ├── 0880 - Minimal Square.cpp │ ├── 0881 - Honest Coach.cpp │ ├── 0882 - Similar Pairs.cpp │ ├── 0883 - Buying Shovels.cpp │ ├── 0884 - Polygon.cpp │ ├── 0885 - SpyString.cpp │ ├── 0886 - AB Matrix.cpp │ ├── 0887 - Binary Median.cpp │ ├── 0888 - Ada and Cities.cpp │ ├── 0889 - Ada and Path.cpp │ ├── 0890 - Bank Robbery.cpp │ ├── 0891 - Birthday Cake.cpp │ ├── 0892 - Colliders.cpp │ ├── 0893 - Integer Sequence Dividing.cpp │ ├── 0894 - Park Lighting.cpp │ ├── 0895 - Maria Breaks Self Isolation.cpp │ ├── 0896 - Celex Update.cpp │ ├── 0897 - Cards and Joy.cpp │ ├── 0898 - Chocolate Bar.cpp │ ├── 0899 - Lomsat Gelral.cpp │ ├── 0900 - Mixing Water.cpp │ ├── 0901 - Helpful Maths.cpp │ ├── 0902 - Infinite Sequence.cpp │ ├── 0903 - The Time.cpp │ ├── 0904 - Not Equal on a Segment.cpp │ ├── 0905 - Optimal Number Permutation.cpp │ ├── 0906 - Ants in Leaves.cpp │ ├── 0907 - Berland Poker.cpp │ ├── 0908 - Protecting the Hive.cpp │ ├── 0909 - Christmas Tree.cpp │ ├── 0910 - New Year Parties.cpp │ ├── 0911 - Odd Selection.cpp │ ├── 0912 - Subsequence Hate.cpp │ ├── 0913 - Game on Leaves.cpp │ ├── 0914 - Guess the Maximums.cpp │ ├── 0915 - Tree Shuffling.cpp │ ├── 0916 - Karen and Coffee.cpp │ ├── 0917 - Escape Room.cpp │ ├── 0918 - Binary Transformation.cpp │ ├── 0919 - Johnny and Contribution.cpp │ ├── 0920 - Johnny and Grandmaster.cpp │ ├── 0921 - Johnny and Ancient Computer.cpp │ ├── 0922 - Johnny and His Hobbies.cpp │ ├── 0923 - Johnny and Another Rating Drops.cpp │ ├── 0924 - Card Game.cpp │ ├── 0925 - Programming Tutors.cpp │ ├── 0926 - Heidi Learns Hashing Easy.cpp │ ├── 0927 - Sentry Robots.cpp │ ├── 0928 - Maximum Islands.cpp │ ├── 0929 - Avoiding the Appocalypse.cpp │ ├── 0930 - Learning Languages.cpp │ ├── 0931 - Matrix Game.cpp │ ├── 0932 - Trouble Sort.cpp │ ├── 0933 - Rotation Matching.cpp │ ├── 0934 - Solve the Maze.cpp │ ├── 0935 - Maximum Subsequence Value.cpp │ ├── 0936 - Swaps Again.cpp │ ├── 0937 - Cakey McCakeFree.cpp │ ├── 0938 - Ingredients.cpp │ ├── 0939 - Shattered Cake.cpp │ ├── 0940 - Blowing Candles.cpp │ ├── 0941 - The Wall.cpp │ ├── 0942 - I Love KD-Trees 1.cpp │ ├── 0943 - I Love KD-Trees 2.cpp │ ├── 0944 - I Love KD-Trees 3.cpp │ ├── 0945 - Petya and Graph.cpp │ ├── 0946 - Shovels and Swords.cpp │ ├── 0947 - Shuffle.cpp │ ├── 0948 - Palindromic Path.cpp │ ├── 0949 - Two Divisors.cpp │ ├── 0950 - Two Arrays.cpp │ ├── 0951 - Stampede.cpp │ ├── 0952 - Minimal K-Covering.cpp │ ├── 0953 - XXXXX.cpp │ ├── 0954 - Most Socially Distanced Subsequence.cpp │ ├── 0955 - Ehab and Prefix MEX's.cpp │ ├── 0956 - Ehab's Last Corollary.cpp │ ├── 0957 - Coin Combinations 1.cpp │ ├── 0958 - Dice Combinations.cpp │ ├── 0959 - Minimizing Coins.cpp │ ├── 0960 - C+=.cpp │ ├── 0961 - Codeforces Subsequences.cpp │ ├── 0962 - Even Picture.cpp │ ├── 0963 - AND, OR and Square Sum.cpp │ ├── 0964 - Social Distance.cpp │ ├── 0965 - Maximum GCD.cpp │ ├── 0966 - GCD Compression.cpp │ ├── 0967 - Number Game.cpp │ ├── 0968 - Odd Even Subsequence.cpp │ ├── 0969 - Binary Subsequence Rotation.cpp │ ├── 0970 - The Hidden Pair.cpp │ ├── 0971 - The Doctor Meets Vader Medium.cpp │ ├── 0972 - FashionabLee.cpp │ ├── 0973 - AccurateLee.cpp │ ├── 0974 - RationaLee.cpp │ ├── 0975 - TediousLee.cpp │ ├── 0976 - DeadLee.cpp │ ├── 0977 - Administrative Difficulties.cpp │ ├── 0978 - Cracking the Code.cpp │ ├── 0979 - Flying Safely.cpp │ ├── 0980 - Getting Through.cpp │ ├── 0981 - Donut Shops.cpp │ ├── 0982 - 01 Game.cpp │ ├── 0983 - Plusses and Minuses.cpp │ ├── 0984 - Maximum Sum on Even Positions.cpp │ ├── 0985 - Maximum Students Taking Exam.cpp │ ├── 0986 - Short Substrings.cpp │ ├── 0987 - Even Array.cpp │ ├── 0988 - Task on the Board.cpp │ ├── 0989 - Magical Sticks.cpp │ ├── 0990 - Magical Calendar.cpp │ ├── 0991 - A Cookie for You.cpp │ ├── 0992 - Grid 00100.cpp │ ├── 0993 - Asterism.cpp │ ├── 0994 - Sign Flipping.cpp │ ├── 0995 - Neighbor Grid.cpp │ ├── 0996 - Element Extermination.cpp │ ├── 0997 - Replace by MEX.cpp │ ├── 0998 - Weird Algorithm.cpp │ └── 0999 - Missing Number.cpp ├── 1000 - 1999 │ ├── 1000 - Repetitions.cpp │ ├── 1001 - Increasing Array.cpp │ ├── 1002 - Permutations.cpp │ ├── 1003 - BitStrings.cpp │ ├── 1004 - Coin Piles.cpp │ ├── 1005 - Number Spiral.cpp │ ├── 1006 - Palindrome Reorder.cpp │ ├── 1007 - Trailing Zeroes.cpp │ ├── 1008 - Two Knights.cpp │ ├── 1009 - Two Sets.cpp │ ├── 1010 - XOR Sum.cpp │ ├── 1011 - Apple Division.cpp │ ├── 1012 - Chessboard and Queens.cpp │ ├── 1013 - Creating Strings 1.cpp │ ├── 1014 - Grid Paths.cpp │ ├── 1015 - Distinct Numbers.cpp │ ├── 1016 - Planet Queries 1.cpp │ ├── 1017 - Appartments.cpp │ ├── 1018 - Concert Tickets.cpp │ ├── 1019 - Ferris Wheel.cpp │ ├── 1020 - Maximum Sum Subarray.cpp │ ├── 1021 - Movie Festival.cpp │ ├── 1022 - Playlist.cpp │ ├── 1023 - Restaurant Customers.cpp │ ├── 1024 - Stick Lengths.cpp │ ├── 1025 - Sum of Two Values.cpp │ ├── 1026 - Towers.cpp │ ├── 1027 - Traffic Lights.cpp │ ├── 1028 - Array Division.cpp │ ├── 1029 - Factory Machines.cpp │ ├── 1030 - Maximum Subarray Sum 2.cpp │ ├── 1031 - Movie Festival 2.cpp │ ├── 1032 - Nearest Smaller Values.cpp │ ├── 1033 - Reading Books.cpp │ ├── 1034 - Room Allocation.cpp │ ├── 1035 - Sliding Cost.cpp │ ├── 1036 - Sliding Median.cpp │ ├── 1037 - Subarray Divisibility.cpp │ ├── 1038 - Subarray Sums 1.cpp │ ├── 1039 - Subarray Sums 2.cpp │ ├── 1040 - Sum of Four Values.cpp │ ├── 1041 - Sum of Three Values.cpp │ ├── 1042 - Tasks and Deadlines.cpp │ ├── 1043 - Coins Combinations 2.cpp │ ├── 1044 - Grid Paths.cpp │ ├── 1045 - Removing Digits.cpp │ ├── 1046 - Array Description.cpp │ ├── 1047 - Book Shop.cpp │ ├── 1048 - Edit Distance.cpp │ ├── 1049 - Money Sums.cpp │ ├── 1050 - Rectangle Cutting.cpp │ ├── 1051 - Ones and Zeroes.cpp │ ├── 1052 - Removal Game.cpp │ ├── 1053 - Two Sets 2.cpp │ ├── 1054 - Longest Increasing Subsequence.cpp │ ├── 1055 - Projects.cpp │ ├── 1056 - Building Routes.cpp │ ├── 1057 - Building Teams.cpp │ ├── 1058 - Counting Rooms.cpp │ ├── 1059 - Labyrinth.cpp │ ├── 1060 - Message Route.cpp │ ├── 1061 - Round Trip.cpp │ ├── 1062 - Maximum XOR Subarray.cpp │ ├── 1063 - Distance Queries.cpp │ ├── 1064 - High Score.cpp │ ├── 1065 - Monsters.cpp │ ├── 1066 - Shortest Routes 1.cpp │ ├── 1067 - Shortest Routes 2.cpp │ ├── 1068 - Random Mood.cpp │ ├── 1069 - Count Paths.cpp │ ├── 1070 - Fibonacci.cpp │ ├── 1071 - Knight Paths.cpp │ ├── 1072 - Min Path.cpp │ ├── 1073 - String Mood.cpp │ ├── 1074 - Three Pairwise Maximums.cpp │ ├── 1075 - Restore the Permutation by Merger.cpp │ ├── 1076 - Make it Good.cpp │ ├── 1077 - aGood String.cpp │ ├── 1078 - Directing Edges.cpp │ ├── 1079 - Recurrence With Square.cpp │ ├── 1080 - Product Oriented Recurrence.cpp │ ├── 1081 - Acacius and String.cpp │ ├── 1082 - Dubious Crypto.cpp │ ├── 1083 - Decoding Genome.cpp │ ├── 1084 - Magic Gems.cpp │ ├── 1085 - Plant.cpp │ ├── 1086 - Tetrahedron.cpp │ ├── 1087 - Smile House.cpp │ ├── 1088 - Assigning to Classes.cpp │ ├── 1089 - Balanced Rating Changes.cpp │ ├── 1090 - Case of Zeroes and Ones.cpp │ ├── 1091 - Equation.cpp │ ├── 1092 - Gennady and a Card Game.cpp │ ├── 1093 - Kuroni and Simple String.cpp │ ├── 1094 - Kuroni and the Gifts.cpp │ ├── 1095 - New Year and the Treasure Geolocation.cpp │ ├── 1096 - Suffix Three.cpp │ ├── 1097 - Wet Sharks and Blocks.cpp │ ├── 1098 - Range Minimum Queries 1.cpp │ ├── 1099 - Range Minimum Queries 2.cpp │ ├── 1100 - Range Sum Queries 1.cpp │ ├── 1101 - Range Sum Queries 2.cpp │ ├── 1102 - Range Update Queries.cpp │ ├── 1103 - Range XOR Queries.cpp │ ├── 1104 - Forest Queries.cpp │ ├── 1105 - Hotel Queries.cpp │ ├── 1106 - Right Triangles.cpp │ ├── 1107 - 123 Sequence.cpp │ ├── 1108 - Travel Restrictions.cpp │ ├── 1109 - Alchemy.cpp │ ├── 1110 - Timber.cpp │ ├── 1111 - Running on Fumes 1.cpp │ ├── 1112 - Coin Collector.cpp │ ├── 1113 - Flight Routes Check.cpp │ ├── 1114 - Giant Pizza.cpp │ ├── 1115 - Mail Delivery.cpp │ ├── 1116 - Planets and Kingdoms.cpp │ ├── 1117 - Road Construction.cpp │ ├── 1118 - Road Reparation.cpp │ ├── 1119 - Cycle Finding.cpp │ ├── 1120 - Flight Discount.cpp │ ├── 1121 - Flight Routes.cpp │ ├── 1122 - Round Trip 2.cpp │ ├── 1123 - Binomial Coefficients.cpp │ ├── 1124 - Christmass Party.cpp │ ├── 1125 - Common Divisors.cpp │ ├── 1126 - Counting Divisors.cpp │ ├── 1127 - Course Schedule.cpp │ ├── 1128 - Creating Strings 2.cpp │ ├── 1129 - Distributing Apples.cpp │ ├── 1130 - Exponentiation 1.cpp │ ├── 1131 - Exponentiation 2.cpp │ ├── 1132 - Fibonacci Numbers.cpp │ ├── 1133 - Game Routes.cpp │ ├── 1134 - Graph Path 1.cpp │ ├── 1135 - Graph Path 2.cpp │ ├── 1136 - List Removals.cpp │ ├── 1137 - Throwing Dice.cpp │ ├── 1138 - Longest Flight Route.cpp │ ├── 1139 - Negigent Nobert.cpp │ ├── 1140 - LCM Problem.cpp │ ├── 1141 - Good String.cpp │ ├── 1142 - Captain Flint and Crew Recruitement.cpp │ ├── 1143 - Captain Flint and a Long Voyage.cpp │ ├── 1144 - Uncle Bodgan and Country Happiness.cpp │ ├── 1145 - Captain Flint and a Treasure.cpp │ ├── 1146 - Dice Probability.cpp │ ├── 1147 - Moving Robots.cpp │ ├── 1148 - Candy Lottery.cpp │ ├── 1149 - Sum of Divisors.cpp │ ├── 1150 - Counting Bits.cpp │ ├── 1151 - Reactor Cooling.cpp │ ├── 1152 - Beautiful People.cpp │ ├── 1153 - Cracking RSA.cpp │ ├── 1154 - Stick Game.cpp │ ├── 1155 - Nim Game 1.cpp │ ├── 1156 - Nim Game 2.cpp │ ├── 1157 - Distinct Routes.cpp │ ├── 1158 - Download Speed.cpp │ ├── 1159 - March of the Penguins.cpp │ ├── 1160 - Objective Berlin.cpp │ ├── 1161 - Police Chase.cpp │ ├── 1162 - School Dance.cpp │ ├── 1163 - Salary Queries.cpp │ ├── 1164 - Advertisement.cpp │ ├── 1165 - Bit Inversions.cpp │ ├── 1166 - Edge Directions.cpp │ ├── 1167 - Increasing Subsequence 2.cpp │ ├── 1168 - Pyramid Array.cpp │ ├── 1169 - Subarray Sum Queries.cpp │ ├── 1170 - Remove Smallest.cpp │ ├── 1171 - Gifts Fixing.cpp │ ├── 1172 - Boats Competition.cpp │ ├── 1173 - Binary String to Subsequences.cpp │ ├── 1174 - Writing Numbers.cpp │ ├── 1175 - Subordinates.cpp │ ├── 1176 - Tree Matching.cpp │ ├── 1177 - Tree Diameter.cpp │ ├── 1178 - Tree Distances 1.cpp │ ├── 1179 - Tree Distances 2.cpp │ ├── 1180 - Company Queries 1.cpp │ ├── 1181 - Company Queries 2.cpp │ ├── 1182 - Subtree Queries.cpp │ ├── 1183 - Hyperhuffman.cpp │ ├── 1184 - Robbers.cpp │ ├── 1185 - Suborrays.cpp │ ├── 1186 - Fix You.cpp │ ├── 1187 - Cyclic Permutations.cpp │ ├── 1188 - Balloons.cpp │ ├── 1189 - Circles.cpp │ ├── 1190 - Cube.cpp │ ├── 1191 - Smallest Difference.cpp │ ├── 1192 - Working Time.cpp │ ├── 1193 - Zero Array.cpp │ ├── 1194 - Counting Paths.cpp │ ├── 1195 - Path Queries.cpp │ ├── 1196 - Distinct Colors.cpp │ ├── 1197 - Apple Pen.cpp │ ├── 1198 - Bike Race.cpp │ ├── 1199 - Calculatus Eliminatus.cpp │ ├── 1200 - One.cpp │ ├── 1201 - Last Robotics.cpp │ ├── 1202 - The Halting Problem.cpp │ ├── 1203 - Polynomial Queries.cpp │ ├── 1204 - Forest Queries 2.cpp │ ├── 1205 - Range Updates and Sums.cpp │ ├── 1206 - Box Game.cpp │ ├── 1207 - ENimEN.cpp │ ├── 1208 - Games are Important.cpp │ ├── 1209 - Playing With Stones.cpp │ ├── 1210 - Stone Game.cpp │ ├── 1211 - String Mood Updates.cpp │ ├── 1212 - Count Paths Queries.cpp │ ├── 1213 - Game of Stones.cpp │ ├── 1214 - Misere Nim.cpp │ ├── 1215 - Nimble Game.cpp │ ├── 1216 - Stair Game.cpp │ ├── 1217 - A Chessboard Game.cpp │ ├── 1218 - Tower Breakers.cpp │ ├── 1219 - Tower Breakers Revisited.cpp │ ├── 1220 - Tower Breakers Again.cpp │ ├── 1221 - Chessboard Game Again.cpp │ ├── 1222 - Digits Square Board.cpp │ ├── 1223 - Perimetric Chapter 1.cpp │ ├── 1224 - Perimetric Chapter 2.cpp │ ├── 1225 - Perimetric Chapter 3.cpp │ ├── 1226 - Dislodging Logs.cpp │ ├── 1227 - The Twin Towers.cpp │ ├── 1228 - Vacation.cpp │ ├── 1229 - Circumference of a Tree.cpp │ ├── 1230 - Dynamic Diameter.cpp │ ├── 1231 - Sloth Naptime.cpp │ ├── 1232 - Cycle Free Flow.cpp │ ├── 1233 - Filthy Rich Trees.cpp │ ├── 1234 - Orac and LCM.cpp │ ├── 1235 - Div Game.cpp │ ├── 1236 - Adjoin the Networks.cpp │ ├── 1237 - Bell Ringing.cpp │ ├── 1238 - Cryptographer's Conundrum.cpp │ ├── 1239 - Disastrous Downtime.cpp │ ├── 1240 - Entertainment Box.cpp │ ├── 1241 - Goblin Garden Guards.cpp │ ├── 1242 - Round Subset.cpp │ ├── 1243 - Fun Game.cpp │ ├── 1244 - Powers Game.cpp │ ├── 1245 - Deforestation.cpp │ ├── 1246 - Tower Breakers, The Final Battle.cpp │ ├── 1247 - Distance and Axis.cpp │ ├── 1248 - Ternary Sequence.cpp │ ├── 1249 - Mere Array.cpp │ ├── 1250 - Maximum Distributed Tree.cpp │ ├── 1251 - Divide Square.cpp │ ├── 1252 - Ada and GCD.cpp │ ├── 1253 - Ada and Manure.cpp │ ├── 1254 - Ada and Connections.cpp │ ├── 1255 - Ada and Taxes.cpp │ ├── 1256 - Shortest Subsequence.cpp │ ├── 1257 - Meet in the Middle.cpp │ ├── 1258 - Inversion Probability.cpp │ ├── 1259 - Candy Pair.cpp │ ├── 1260 - Intersection Points.cpp │ ├── 1261 - Jalil Got TLE.cpp │ ├── 1262 - Count Pairs.cpp │ ├── 1263 - String Similarity.cpp │ ├── 1264 - RPG Protagonist.cpp │ ├── 1265 - Binary String Reconstruction.cpp │ ├── 1266 - Zigzags.cpp │ ├── 1267 - Clear the Multiset.cpp │ ├── 1268 - The King's Race.cpp │ ├── 1269 - Taxi Drivers and Lyft.cpp │ ├── 1270 - The Tower is Going Home.cpp │ ├── 1271 - Intersecting Subtrees.cpp │ ├── 1272 - Don't be Late.cpp │ ├── 1273 - Substring.cpp │ ├── 1274 - Sum of Product of Pairs.cpp │ ├── 1275 - Friends.cpp │ ├── 1276 - Coprime.cpp │ ├── 1277 - I Hate Shortest Path Problem.cpp │ ├── 1278 - Ca-pasta-ty.cpp │ ├── 1279 - Coprime Integers.cpp │ ├── 1280 - Multiples of Length.cpp │ ├── 1281 - Stoned Game.cpp │ ├── 1282 - Juggling Letters.cpp │ ├── 1283 - Power Sequence.cpp │ ├── 1284 - Cops and Robbers.cpp │ ├── 1285 - Rectangles.cpp │ ├── 1286 - Button Bashing.cpp │ ├── 1287 - Citadel Construction.cpp │ ├── 1288 - Interesting Integers.cpp │ ├── 1289 - Simple Sum.cpp │ ├── 1290 - Coprime Triples.cpp │ ├── 1291 - Frog 1.cpp │ ├── 1292 - Frog 2.cpp │ ├── 1293 - Vacation.cpp │ ├── 1294 - Knapsack 1.cpp │ ├── 1295 - Knapsack 2.cpp │ ├── 1296 - LCS.cpp │ ├── 1297 - Longest Path.cpp │ ├── 1298 - Yet Another Two Integers Problem.cpp │ ├── 1299 - Minimum Product.cpp │ ├── 1300 - Yet Another Array Restoration.cpp │ ├── 1301 - Decrease the Sum of Digits.cpp │ ├── 1302 - Two Platforms.cpp │ ├── 1303 - Subsequences of Length Two.cpp │ ├── 1304 - Grid 1.cpp │ ├── 1305 - Coins.cpp │ ├── 1306 - Balanced Bitstring.cpp │ ├── 1307 - Tree Tag.cpp │ ├── 1308 - Weird Requirements.cpp │ ├── 1309 - Base and Power.cpp │ ├── 1310 - GCD of Polynomials.cpp │ ├── 1311 - Powers.cpp │ ├── 1312 - Divisors.cpp │ ├── 1313 - Magical GCD.cpp │ ├── 1314 - Subset Mex.cpp │ ├── 1315 - Maximum Product.cpp │ ├── 1316 - Link Cut Centroids.cpp │ ├── 1317 - Three Sequences.cpp │ ├── 1318 - Coprime Subsequences.cpp │ ├── 1319 - Number of Prime Strings.cpp │ ├── 1320 - Ubiquity.cpp │ ├── 1321 - Redistribution.cpp │ ├── 1322 - Dist Max.cpp │ ├── 1323 - Contrast.cpp │ ├── 1324 - Buying Torches.cpp │ ├── 1325 - Negative Prefixes.cpp │ ├── 1326 - Mortal Kombat Tower.cpp │ ├── 1327 - Sushi.cpp │ ├── 1328 - Stones.cpp │ ├── 1329 - Deque.cpp │ ├── 1330 - Candies.cpp │ ├── 1331 - Slimes.cpp │ ├── 1332 - Matching.cpp │ ├── 1333 - Independent Set.cpp │ ├── 1334 - Flowers.cpp │ ├── 1335 - Walk.cpp │ ├── 1336 - Digit Sum.cpp │ ├── 1337 - Brexit Negotiations.cpp │ ├── 1338 - Circuit Board Design.cpp │ ├── 1339 - Game Design.cpp │ ├── 1340 - Plural Form.cpp │ ├── 1341 - Go to Jail.cpp │ ├── 1342 - AxB+C.cpp │ ├── 1343 - Leaping Tak.cpp │ ├── 1344 - Sequence Sum.cpp │ ├── 1345 - Simplified Reversi.cpp │ ├── 1346 - Digit Game.cpp │ ├── 1347 - Stairs.cpp │ ├── 1348 - Killjoy.cpp │ ├── 1349 - Sage's Birthday.cpp │ ├── 1350 - Cubes Sorting.cpp │ ├── 1351 - Rock and Lever.cpp │ ├── 1352 - Rescue Nibel.cpp │ ├── 1353 - Within Arm's Reach.cpp │ ├── 1354 - Candle Box.cpp │ ├── 1355 - Circle Coloring.cpp │ ├── 1356 - Arrays Sum.cpp │ ├── 1357 - Discrete Acceleration.cpp │ ├── 1358 - Searchlights.cpp │ ├── 1359 - A String.cpp │ ├── 1360 - Why Omani Sings.cpp │ ├── 1361 - Extremely Basic.cpp │ ├── 1362 - Stone Piles.cpp │ ├── 1363 - Moustapha & The Mex.cpp │ ├── 1364 - Watching Builders.cpp │ ├── 1365 - Absent Students.cpp │ ├── 1366 - Reduced Array.cpp │ ├── 1367 - Making the Array Equal Again.cpp │ ├── 1368 - Max Radius of a Circle.cpp │ ├── 1369 - Grids Converting.cpp │ ├── 1370 - Min Max 3n+1.cpp │ ├── 1371 - Bakery Chief.cpp │ ├── 1372 - OCR Mistake.cpp │ ├── 1373 - Keyboard.cpp │ ├── 1374 - Futon.cpp │ ├── 1375 - Neq Min.cpp │ ├── 1376 - Lamps.cpp │ ├── 1377 - Avoiding Zero.cpp │ ├── 1378 - Chess Cheater.cpp │ ├── 1379 - The Hard Work of Paparazzi.cpp │ ├── 1380 - Number of Appartments.cpp │ ├── 1381 - Barrels.cpp │ ├── 1382 - Numbers on WhiteBoard.cpp │ ├── 1383 - String Deletion.cpp │ ├── 1384 - Fourtune Cookies.cpp │ ├── 1385 - MAX-=min.cpp │ ├── 1386 - Camels and Bridge.cpp │ ├── 1387 - Let's Play NIM.cpp │ ├── 1388 - Box.cpp │ ├── 1389 - Various Distances.cpp │ ├── 1390 - Cream Puffs.cpp │ ├── 1391 - Takahashi Unevolved.cpp │ ├── 1392 - Travelling Salesman Along Aerial Cities.cpp │ ├── 1393 - Unbranched.cpp │ ├── 1394 - Box is Pull.cpp │ ├── 1395 - Belted Rooms.cpp │ ├── 1396 - ABBB.cpp │ ├── 1397 - Bouncing Boomerang.cpp │ ├── 1398 - XORwice.cpp │ ├── 1399 - Putting Bricks in the Wall.cpp │ ├── 1400 - Palindromifier.cpp │ ├── 1401 - Hexagons.cpp │ ├── 1402 - ARM Constant Multiplication.cpp │ ├── 1403 - Coin Collector.cpp │ ├── 1404 - Coupon Codes.cpp │ ├── 1405 - Linearly Seperable Samples.cpp │ ├── 1406 - Magical Stones I.cpp │ ├── 1407 - Mosaic Decoration I.cpp │ ├── 1408 - Mosaic Decoration II.cpp │ ├── 1409 - Parkour.cpp │ ├── 1410 - Poker Game.cpp │ ├── 1411 - Rotational Lights.cpp │ ├── 1412 - Flights.cpp │ ├── 1413 - Trapezoid Sum.cpp │ ├── 1414 - Collinearity.cpp │ ├── 1415 - Hachi.cpp │ ├── 1416 - Transformable Teacher.cpp │ ├── 1417 - Silver Woods.cpp │ ├── 1418 - Akari.cpp │ ├── 1419 - Almost GCD.cpp │ ├── 1420 -Confluence.cpp │ ├── 1421 - Queen on the Grid.cpp │ ├── 1422 - To 3.cpp │ ├── 1423 - Twiblr.cpp │ ├── 1424 - Wandering.cpp │ ├── 1425 - Water Heater.cpp │ ├── 1426 - Large Digits.cpp │ ├── 1427 - Gentle Pairs.cpp │ ├── 1428 - 1SAT.cpp │ ├── 1429 - Choose Me.cpp │ ├── 1430 - Through Path.cpp │ ├── 1431 - Close Group.cpp │ ├── 1432 - Cards For Friends.cpp │ ├── 1433 - Fair Division.cpp │ ├── 1434 - Long Jumps.cpp │ ├── 1435 - Even Odd Game.cpp │ ├── 1436 - Correct Placement.cpp │ ├── 1437 - Moving to the Capital.cpp │ ├── 1438 - Hello SCPC 18.cpp │ ├── 1439 - Binary Hamming.cpp │ ├── 1440 - Rise of the Robots.cpp │ ├── 1441 - Tourists' Tour.cpp │ ├── 1442 - Is Topo Logical.cpp │ ├── 1443 - Strange Partition.cpp │ ├── 1444 - Strange List.cpp │ ├── 1445 - Strange Birthday Party.cpp │ ├── 1446 - Strange Definition.cpp │ ├── 1447 - Gray Code.cpp │ ├── 1448 - Towers of Hanoi.cpp │ ├── 1449 - Digit Queries.cpp │ ├── 1450 - Missing Coin Sum.cpp │ ├── 1451 - Collecting Numbers I.cpp │ ├── 1452 - Collecting Numbers II.cpp │ ├── 1453 - Josephus' Problem I .cpp │ ├── 1454 - Josephus' Problem II.cpp │ ├── 1455 - Nested Ranges Check.cpp │ ├── 1456 - Nested Ranges Count.cpp │ ├── 1457 - Subarray Distinct Values.cpp │ ├── 1458 - De Bruijn Sequence.cpp │ ├── 1459 - Teleporters' Path.cpp │ ├── 1460 - Hamiltonian Flights.cpp │ ├── 1461 - Prefix Sum Queries.cpp │ ├── 1462 - Wizard of Orz.cpp │ ├── 1463 - Hills and Valleys.cpp │ ├── 1464 - Three Bags.cpp │ ├── 1465 - Cleaning The Phone.cpp │ ├── 1466 - Knight's Tour.cpp │ ├── 1467 - Divisor Analysis.cpp │ ├── 1468 - Prime Multiples.cpp │ ├── 1469 - Counting Coprime Pairs.cpp │ ├── 1470 - Bracket Sequences 1.cpp │ ├── 1471 - Three Point Shot.cpp │ ├── 1472 - Orthogonality.cpp │ ├── 1473 - ABC Tournament.cpp │ ├── 1474 - Snuke Prime.cpp │ ├── 1475 - Peddler.cpp │ ├── 1476 - Counting Towers.cpp │ ├── 1477 - Replacing Elements.cpp │ ├── 1478 - String LCM.cpp │ ├── 1479 - No More Inversions.cpp │ ├── 1480 - Program.cpp │ ├── 1481 - Pizzeria Queries.cpp │ ├── 1482 - Counting Tilings.cpp │ ├── 1483 - Counting Numbers.cpp │ ├── 1484 - Elevator Rides.cpp │ ├── 1485 - Grundy's Game.cpp │ ├── 1486 - Another Game.cpp │ ├── 1487 - Puzzle From The Future.cpp │ ├── 1488 - Different Divisors.cpp │ ├── 1489 - Alcoholic.cpp │ ├── 1490 - Mandarin Orange.cpp │ ├── 1491 - Logical Expression.cpp │ ├── 1492 - Rotate and Flip.cpp │ ├── 1493 - Sugoroku2.cpp │ ├── 1494 - Investigation.cpp │ ├── 1495 - Planet Queries II.cpp │ ├── 1496 - Planet Cycles.cpp │ ├── 1497 - Odd Divisor.cpp │ ├── 1498 - New Year's Number.cpp │ ├── 1499 - Ball in Berland.cpp │ ├── 1500 - Advertising Agency.cpp │ ├── 1501 - Unusual Matrix.cpp │ ├── 1502 - Zeros and Ones.cpp │ ├── 1503 - The First Task.cpp │ ├── 1504 - Array Transformation.cpp │ ├── 1505 - The Millenium Prize Problems.cpp │ ├── 1506 - Nezzar and Board.cpp │ ├── 1507 - Nezzar and Binary String.cpp │ ├── 1508 - Nezzar and Nice Beatmap.cpp │ ├── 1509 - Distinct Values Queries.cpp │ ├── 1510 - K-Divisible Sum.cpp │ ├── 1511 - Inflation.cpp │ ├── 1512 - Longest Simple Cycle.cpp │ ├── 1513 - Journey.cpp │ ├── 1514 - Pattern Matching.cpp │ ├── 1515 - Very Very Primitive Game.cpp │ ├── 1516 - Magic 3.cpp │ ├── 1517 - Bowls and Dishes.cpp │ ├── 1518 - Staircase Sequences.cpp │ ├── 1519 - Magical Ornament.cpp │ ├── 1520 - Shitt and Inversions.cpp │ ├── 1521 - Increasing Array Queries.cpp │ ├── 1522 - Baleez.cpp │ ├── 1523 - Bitwise OR.cpp │ ├── 1524 - Colored Shelves.cpp │ ├── 1525 - Digit Count.cpp │ ├── 1526 - Expected Sum.cpp │ ├── 1527 - Get The Sum.cpp │ ├── 1528 - Inequality Headache.cpp │ ├── 1529 - Is Divisible.cpp │ ├── 1530 - Salah and Encryption.cpp │ ├── 1531 - World Cup.cpp │ ├── 1532 - Growling Gears.cpp │ ├── 1533 - Looking for Taste.cpp │ ├── 1534 - Older Brother.cpp │ ├── 1535 - Inflation.cpp │ ├── 1536 - Count the Bits.cpp │ ├── 1537 - Space Navigation.cpp │ ├── 1538 - New Colony.cpp │ ├── 1539 - Fence Painting.cpp │ ├── 1540 - AB Graph.cpp │ ├── 1541 - Vanishing Pitch.cpp │ ├── 1542 - Remove It.cpp │ ├── 1543 - Digital Graffiti.cpp │ ├── 1544 - Come Back Quickly.cpp │ ├── 1545 - Circle Lattice Points.cpp │ ├── 1546 - GCD or MIN.cpp │ ├── 1547 - Searching Local Minimum.cpp │ ├── 1548 - Moustafa and the Mex.cpp │ ├── 1549 - Why Omani Sings.cpp │ ├── 1550 - Good Grid.cpp │ ├── 1551 - Game.cpp │ ├── 1552 - Lucky Numbers.cpp │ ├── 1553 - Digits.cpp │ ├── 1554 - Diffonacci.cpp │ ├── 1555 - Good String.cpp │ ├── 1556 - Stock Market.cpp │ ├── 1557 - Gifts.cpp │ ├── 1558 - Minimum X.cpp │ ├── 1559 - Magic Gates.cpp │ ├── 1560 - Dice Game.cpp │ ├── 1561 - Mahmoud and Unique List.cpp │ ├── 1562 - Instaduck.cpp │ ├── 1563 - Add and Divide.cpp │ ├── 1564 - Replace and Keep Sorted.cpp │ ├── 1565 - Floor and Mod.cpp │ ├── 1566 - Multiples and Power Differences.cpp │ ├── 1567 - B = C.cpp │ ├── 1568 - B--.cpp │ ├── 1569 - Arena.cpp │ ├── 1570 - Cat Cycle.cpp │ ├── 1571 - Minimum Ties.cpp │ ├── 1572 - Pythagorean Triples.cpp │ ├── 1573 - Cheap Dinner.cpp │ ├── 1574 - Dense Array.cpp │ ├── 1575 - Balanced Remainders.cpp │ ├── 1576 - Sum of Cubes.cpp │ ├── 1577 - Permutation Transformation.cpp │ ├── 1578 - Accidental Victory.cpp │ ├── 1579 - Equalize the Array.cpp │ ├── 1580 - Old Floppy Drive.cpp │ ├── 1581 - Brief History of Time.cpp │ ├── 1582 - Cheers.cpp │ ├── 1583 - Dealing with Sequences.cpp │ ├── 1584 - Elements.cpp │ ├── 1585 - Find the Divisors.cpp │ ├── 1586 - Great Journey.cpp │ ├── 1587 - Hack My Server.cpp │ ├── 1588 - I Love Phuket.cpp │ ├── 1589 - Kill 'Em All.cpp │ ├── 1590 - Shifting Stacks.cpp │ ├── 1591 - Eastern Exhibition.cpp │ ├── 1592 - Guessing the Greatest.cpp │ ├── 1593 - Max Median.cpp │ ├── 1594 - Paired Payement.cpp │ ├── 1595 - Star.cpp │ ├── 1596 - uNrEaDaBlE sTrInG.cpp │ ├── 1597 - Kaprekar Number.cpp │ ├── 1598 - Base N.cpp │ ├── 1599 - Train.cpp │ ├── 1600 - Potion.cpp │ ├── 1601 - AxBxC.cpp │ ├── 1602 - A^B^C.cpp │ ├── 1603 - String Invasion.cpp │ ├── 1604 - Sky Reflector.cpp │ ├── 1605 - Three Swimmers.cpp │ ├── 1606 - Card Deck.cpp │ ├── 1607 - Maximum Width.cpp │ ├── 1608 - Genius's Gambit.cpp │ ├── 1609 - Kth Largest Value.cpp │ ├── 1610 - Minimal Cost.cpp │ ├── 1611 - Pekora and Trampoline.cpp │ ├── 1612 - Zookeeper and the Infinite Zoo.cpp │ ├── 1613 - ABC String.cpp │ ├── 1614 - Berland Crossword.cpp │ ├── 1615 - 1D Sokoban.cpp │ ├── 1616 - DogeForces.cpp │ ├── 1617 - Officer Anany Collecting String Subsequences.cpp │ ├── 1618 - Anany in the Army.cpp │ ├── 1619 - Sort.cpp │ ├── 1620 - YSYS.cpp │ ├── 1621 - Baby Ehab's XOR.cpp │ ├── 1622 - Geometry.cpp │ ├── 1623 - Baby Ehab and a GCD Problem, Of Course.cpp │ ├── 1624 - Shortest Array.cpp │ ├── 1625 - ABC.cpp │ ├── 1626 - Plants Watering.cpp │ ├── 1627 - Baby Ehab's Whining Chance.cpp │ ├── 1628 - Baby Ehab.cpp │ ├── 1629 - I Scream.cpp │ ├── 1630 - Job Assignment.cpp │ ├── 1631 - Squared Error.cpp │ ├── 1632 - Journey.cpp │ ├── 1633 - Mex Min.cpp │ ├── 1634 - Anti Knapsack.cpp │ ├── 1635 - Planet Lapituletti.cpp │ ├── 1636 - K-Beautiful String.cpp │ ├── 1637 - GCD of an Array.cpp │ ├── 1638 - Diamond Miner.cpp │ ├── 1639 - Let's Go Hiking.cpp │ ├── 1640 - Going Home.cpp │ ├── 1641 - Health M Death.cpp │ ├── 1642 - Comma.cpp │ ├── 1643 - Shipping Center.cpp │ ├── 1644 - Lucky 7 Battle.cpp │ ├── 1645 - Strange Table.cpp │ ├── 1646 - Partial Replacement.cpp │ ├── 1647 - Double Ended String.cpp │ ├── 1648 - Epic Transformation.cpp │ ├── 1649 - Restoring the Permutation.cpp │ ├── 1650 - Triangular Paths.cpp │ ├── 1651 - Maximize the Remaining String.cpp │ ├── 1652 - Reversort.cpp │ ├── 1653 - Moons and Umbrellas.cpp │ ├── 1654 - Reversort Engineer.cpp │ ├── 1655 - Rotate.cpp │ ├── 1656 - Visibility.cpp │ ├── 1657 - ORXOR.cpp │ ├── 1658 - Opposite.cpp │ ├── 1659 - Traveler.cpp │ ├── 1660 - GCD Sum.cpp │ ├── 1661 - Box Fitting.cpp │ ├── 1662 - Planar Reflections.cpp │ ├── 1663 - Flip the Bits.cpp │ ├── 1664 - Append Sort.cpp │ ├── 1665 - Prime Time.cpp │ ├── 1666 - Short Task.cpp │ ├── 1667 - Closest Pick.cpp │ ├── 1668 - Roaring Years.cpp │ ├── 1669 - Counting Necklaces.cpp │ ├── 1670 - Do Not Be Distracted.cpp │ ├── 1671 - Ordinary Numbers.cpp │ ├── 1672 - Not Adjacent Matrix.cpp │ ├── 1673 - Same Differences.cpp │ ├── 1674 - Arranging the Sheep.cpp │ ├── 1675 - Guess the Kth Zero Easy.cpp │ ├── 1676 - Guess the Kth Zero Hard.cpp │ ├── 1677 - To Go Or Not To Go.cpp │ ├── 1678 - Tiny Arithmetic Sequence.cpp │ ├── 1679 - Do you know the Second Highest Mountain.cpp │ ├── 1680 - Secret Number.cpp │ ├── 1681 - Game in Momotetsu World.cpp │ ├── 1682 - XOR Distances.cpp │ ├── 1683 - Minimum Sort.cpp │ ├── 1684 - Matrygons.cpp │ ├── 1685 - Hidden Pancakes.cpp │ ├── 1686 - Three Dice.cpp │ ├── 1687 - 180.cpp │ ├── 1688 - Made Up.cpp │ ├── 1689 - AAB ABA BAA.cpp │ ├── 1690 - Count Descendants.cpp │ ├── 1691 - Smaller Strings.cpp │ ├── 1692 - Alien Generator.cpp │ ├── 1693 - Maximum Sum of Products.cpp │ ├── 1694 - Parsa's Humongous Tree.cpp │ ├── 1695 - Kavi On Pairing Duty.cpp │ ├── 1696 - Trees of Tranquility.cpp │ ├── 1697 - Bracket Sequences 2.cpp │ ├── 1698 - Counting Grids.cpp │ ├── 1699 - Word Combination.cpp │ ├── 1700 - String Matching.cpp │ ├── 1701 - Finding Borders.cpp │ ├── 1702 - Mean Inequality.cpp │ ├── 1703 - I Hate 1111.cpp │ ├── 1704 - Potions.cpp │ ├── 1705 - Finding Periods.cpp │ ├── 1706 - Minimal Rotation.cpp │ ├── 1707 - Longest Palindrome.cpp │ ├── 1708 - Hamming Distance.cpp │ ├── 1709 - Reachable Nodes.cpp │ ├── 1710 - Reachability Queries.cpp │ ├── 1711 - Cut and Paste.cpp │ ├── 1712 - Substring Reversals.cpp │ ├── 1713 - Reversals and Sums.cpp │ ├── 1714 - Necessary Roads.cpp │ ├── 1715 - Necessary Cities.cpp │ ├── 1716 - Sakally Soldier.cpp │ ├── 1717 - Zero Equals Infinity.cpp │ ├── 1718 - Topology vs Geometry.cpp │ ├── 1719 - AKA AKA Learns Number Theory.cpp │ ├── 1720 - Memeable String.cpp │ ├── 1721 - Game With Strings.cpp │ ├── 1722 - Annoying Posts.cpp │ ├── 1723 - Binary String.cpp │ ├── 1724 - 2wix+.cpp │ ├── 1725 - Helping Eagle.cpp │ ├── 1726 - Memeable Ace.cpp │ ├── 1727 - New Road Queries.cpp │ ├── 1728 - Josephus Queries.cpp │ ├── 1729 - Point Location Test.cpp │ ├── 1730 - Line Segment Intersection.cpp │ ├── 1731 - Polygon Area.cpp │ ├── 1732 - Network Renovation.cpp │ ├── 1733 - Graph Girth.cpp │ ├── 1734 - Inverse Inversions.cpp │ ├── 1735 - String Removals.cpp │ ├── 1736 - Sorting Methods.cpp │ ├── 1737 - Odd Set.cpp │ ├── 1738 - Plus and Multiply.cpp │ ├── 1739 - Strange Function.cpp │ ├── 1740 - Ages of Universes.cpp │ ├── 1741 - Cake for Summer.cpp │ ├── 1742 - Dimension 35-C.cpp │ ├── 1743 - Endure is Going to Space.cpp │ ├── 1744 - Flip the Tree.cpp │ ├── 1745 - Jaguar on the Tower.cpp │ ├── 1746 - Phantom of the Opera.cpp │ ├── 1747 - A Nuclear Scientist.cpp │ ├── 1748 - Learning Languages.cpp │ ├── 1749 - Hand Copying.cpp │ ├── 1750 - D Primes.cpp │ ├── 1751 - Hamza.cpp │ ├── 1752 - Letter Dal.cpp │ ├── 1753 - XOR K.cpp │ ├── 1754 - Elevator Game.cpp │ ├── 1755 - Growing World.cpp │ ├── 1756 - Longest Statement.cpp │ ├── 1757 - Counting.cpp │ ├── 1758 - Can You Buy Them All.cpp │ ├── 1759 - Not Equal.cpp │ ├── 1760 - Collision.cpp │ ├── 1761 - Chess Tournament.cpp │ ├── 1762 - Coin Grid.cpp │ ├── 1763 - Grid Puzzle 1.cpp │ ├── 1764 - Swap Game.cpp │ ├── 1765 - Tree Traversals.cpp │ ├── 1766 - XOR Pyramid.cpp │ ├── 1767 - Counting Patterns.cpp │ ├── 1768 - Distinct Substrings.cpp │ ├── 1769 - Finding Patterns.cpp │ ├── 1770 - Pattern Positions.cpp │ ├── 1771 - Repeating Substring.cpp │ ├── 1772 - String Functions.cpp │ ├── 1773 - Substring Order 1.cpp │ ├── 1774 - Binary Decimals.cpp │ ├── 1775 - Putting Plates.cpp │ ├── 1776 - Pursuit.cpp │ ├── 1777 - Secret Santa.cpp │ ├── 1778 - Minimax.cpp │ ├── 1779 - Blood Pressure.cpp │ ├── 1780 - Cycle Hit.cpp │ ├── 1781 - Chokudai.cpp │ ├── 1782 - Number of Shortest Paths.cpp │ ├── 1783 - Red Polyomino.cpp │ ├── 1784 - LR Constraints.cpp │ ├── 1785 - XOR Matching 2.cpp │ ├── 1786 - LCM of GCDs.cpp │ ├── 1787 - Subsequence Permutation.cpp │ ├── 1788 - Running for Gold.cpp │ ├── 1789 - Array Differentiation.cpp │ ├── 1790 - Cherry.cpp │ ├── 1791 - Cobb.cpp │ ├── 1792 - Alloy.cpp │ ├── 1793 - Weak Password.cpp │ ├── 1794 - Min Difference.cpp │ ├── 1795 - Querying Multiset.cpp │ ├── 1796 - Safety Journey.cpp │ ├── 1797 - Mikasa.cpp │ ├── 1798 - Diane.cpp │ ├── 1799 - Pizza Forces.cpp │ ├── 1800 - Two Tables.cpp │ ├── 1801 - Coin Rows.cpp │ ├── 1802 - Say No To Palindromes.cpp │ ├── 1803 - Boring Segments.cpp │ ├── 1804 - Gregor and Cryptography.cpp │ ├── 1805 - Gregor and the Pawn Game.cpp │ ├── 1806 - Web of Lies.cpp │ ├── 1807 - Integers Have Friends.cpp │ ├── 1808 - Point in Polygon.cpp │ ├── 1809 - Polygon Lattice Points.cpp │ ├── 1810 - Minimum Euclidean Distance.cpp │ ├── 1811 - Convex Hull.cpp │ ├── 1812 - Multiplication Table.cpp │ ├── 1813 - Counting Sequences.cpp │ ├── 1814 - Bitwise Exclusive OR.cpp │ ├── 1815 - Booby Prize.cpp │ ├── 1816 - Reorder Cards.cpp │ ├── 1817 - Takahashi Tour.cpp │ ├── 1818 - Stronger Takahashi.cpp │ ├── 1819 - School Excursion.cpp │ ├── 1820 - Network Breakdown.cpp │ ├── 1821 - Course Schedule 2.cpp │ ├── 1822 - Consistency Chapter 1.cpp │ ├── 1823 - Consistency Chapter 2.cpp │ ├── 1824 - Xs and Os.cpp │ ├── 1825 - Gold Mine Chapter 1.cpp │ ├── 1826 - Lexicographic Order.cpp │ ├── 1827 - AtCoder Quiz.cpp │ ├── 1828 - Inverse of Permutation.cpp │ ├── 1829 - Cutting Woods.cpp │ ├── 1830 - Sorting Queries.cpp │ ├── 1831 - Weak Typing, Chapter 1.cpp │ ├── 1832 - Weak Typing, Chapter 2.cpp │ ├── 1833 - Weak Typing, Chapter 3.cpp │ ├── 1834 - Traffic Control.cpp │ ├── 1835 - Blockchain.cpp │ ├── 1836 - Regular Bracket Sequence.cpp │ ├── 1837 - Combinatorics Homework.cpp │ ├── 1838 - Slay the Dragon.cpp │ ├── 1839 - The Strongest Build.cpp │ ├── 1840 - Strange Lunchbox.cpp │ ├── 1841 - Runaway.cpp │ ├── 1842 - Chainblock.cpp │ ├── 1843 - Valet Parking - Chapter 1.cpp │ ├── 1844 - Find Multiple.cpp │ ├── 1845 - Base K.cpp │ ├── 1846 - Long Sequence.cpp │ ├── 1847 - FG Operation.cpp │ ├── 1848 - Distance on Large Perfect Binary Tree.cpp │ ├── 1849 - Distance Sums 2.cpp │ ├── 1850 - Casimir's String Solitaire.cpp │ ├── 1851 - Shifting Sort.cpp │ ├── 1852 - Ticks.cpp │ ├── 1853 - Productive Meeting.cpp │ ├── 1854 - Permutation Minimization By Deque.cpp │ ├── 1855 - Array Optimization by Deque.cpp │ ├── 1856 - Array Stabilization (AND Version).cpp │ ├── 1857 - Seismic Magnitude Scales.cpp │ ├── 1858 - Typo.cpp │ ├── 1859 - Select Mul.cpp │ ├── 1860 - Online Games.cpp │ ├── 1861 - LEQ.cpp │ ├── 1862 - Another Sorting Problem.cpp │ ├── 1863 - Gamer Hemose.cpp │ ├── 1864 - Hemose Shopping.cpp │ ├── 1865 - Bakry and Partitioning.cpp │ ├── 1866 - Hemose in ICPC.cpp │ ├── 1867 - Consecutive Sum Riddle.cpp │ ├── 1868 - Special Numbers.cpp │ ├── 1869 - Make Them Equal.cpp │ ├── 1870 - Rubik's Cube Coloring Easy.cpp │ ├── 1871 - Four Digits.cpp │ ├── 1872 - Failing Grade.cpp │ ├── 1873 - Swiss System Tournament.cpp │ ├── 1874 - Between Two Arrays.cpp │ ├── 1875 - Red and Blue Tree.cpp │ ├── 1876 - Expensive Expense.cpp │ ├── 1877 - Permutation.cpp │ ├── 1878 - Grouping.cpp │ ├── 1879 - Dogs and Cats.cpp │ ├── 1880 - Staying Hydrated.cpp │ ├── 1881 - Banana Bunches.cpp │ ├── 1882 - Path Queries II.cpp │ ├── 1883 - Finding a Centroid.cpp │ ├── 1884 - Windblume Ode.cpp │ ├── 1885 - Omkar and Heavinly Tree.cpp │ ├── 1886 - Apples and Bananas.cpp │ ├── 1887 - One Bit Positions.cpp │ ├── 1888 - Signal Processing.cpp │ ├── 1889 - Differences.cpp │ ├── 1890 - Chameleon Walk.cpp │ ├── 1891 - Doctor's Appointment.cpp │ ├── 1892 - Image Similarity.cpp │ ├── 1893 - Language Learning.cpp │ ├── 1894 - Spies of Red and Blues.cpp │ ├── 1895 - Xtreme Teams.cpp │ ├── 1896 - AM Deviation.cpp │ ├── 1897 - Reverse Sort.cpp │ ├── 1898 - Dominant Character.cpp │ ├── 1899 - Treelabeling.cpp │ ├── 1900 - Sequence with Digits.cpp │ ├── 1901 - Young Explorers.cpp │ ├── 1902 - Count Triangles.cpp │ ├── 1903 - Game with Arrays.cpp │ ├── 1904 - Anti Light's Cell Guessing.cpp │ ├── 1905 - Kalindrome Array.cpp │ ├── 1906 - Keshi is Throwing a Party.cpp │ ├── 1907 - Divan and a Store.cpp │ ├── 1908 - Divan and a New Project.cpp │ ├── 1909 - Divan and Bitwise Operations.cpp │ ├── 1910 - Merging Arrays.cpp │ ├── 1911 - Number of Smaller.cpp │ ├── 1912 - Number of Equal.cpp │ ├── 1913 - Segment with Small Sum.cpp │ ├── 1914 - Segment with Big Sum.cpp │ ├── 1915 - Number of Segments with Small Sum.cpp │ ├── 1916 - Number of Segments with Big Sum.cpp │ ├── 1917 - Segments with Small Set.cpp │ ├── 1918 - Segments with Small Spread.cpp │ ├── 1919 - Coprime Segment.cpp │ ├── 1920 - AND 0 Sum Big.cpp │ ├── 1921 - k-LCM Easy.cpp │ ├── 1922 - k-LCM Hard.cpp │ ├── 1923 - M-Arrays.cpp │ ├── 1924 - Meximization.cpp │ ├── 1925 - Kofta Never Lose.cpp │ ├── 1926 - Perfect Subarrays.cpp │ ├── 1927 - Even Pairs.cpp │ ├── 1928 - Somar's Game.cpp │ ├── 1929 - Somar's Challenge.cpp │ ├── 1930 - Strange School.cpp │ ├── 1931 - How to be a Legend.cpp │ ├── 1932 - GGCD.cpp │ ├── 1933 - New LIS Problem.cpp │ ├── 1934 - Consistent Tournament.cpp │ ├── 1935 - Photo Album.cpp │ ├── 1936 - ACPC Sites.cpp │ ├── 1937 - Brimore and the Carpet Market.cpp │ ├── 1938 - Coach Academy Tic Tac Toe.cpp │ ├── 1939 - Endure Invests in Apples.cpp │ ├── 1940 - Fouad Wears Suits.cpp │ ├── 1941 - Game of Science.cpp │ ├── 1942 - Index of Fame.cpp │ ├── 1943 - Kontestants and Group Photos.cpp │ ├── 1944 - Range Queries and Copies.cpp │ ├── 1945 - Weird Function.cpp │ ├── 1946 - Longest Segment.cpp │ ├── 1947 - Happy New Year.cpp │ ├── 1948 - Prefix Kth Max.cpp │ ├── 1949 - Arithmetic Number.cpp │ ├── 1950 - Reordering.cpp │ ├── 1951 - Fixed Length Paths 1.cpp │ ├── 1952 - Fixed Length Paths 2.cpp │ ├── 1953 - Rotate.cpp │ ├── 1954 - Climbing Takahashi.cpp │ ├── 1955 - The Kth Time Query.cpp │ ├── 1956 - Multiply and Rotate.cpp │ ├── 1957 - MST + 1.cpp │ ├── 1958 - Download More RAM.cpp │ ├── 1959 - GCD Arrays.cpp │ ├── 1960 - Meximum Array.cpp │ ├── 1961 - Peculiar Movie Preferences.cpp │ ├── 1962 - Required Substring.cpp │ ├── 1963 - Palindrome Queries.cpp │ ├── 1964 - Substring Order 2.cpp │ ├── 1965 - Substring Distribution.cpp │ ├── 1966 - Maximum Building 1.cpp │ ├── 1967 - Maximum Building 2.cpp │ ├── 1968 - Chukodai.cpp │ ├── 1969 - Who is Missing.cpp │ ├── 1970 - Route Map.cpp │ ├── 1971 - Dance.cpp │ ├── 1972 - Not Overflow.cpp │ ├── 1973 - Matrix Transposition.cpp │ ├── 1974 - Kasaka.cpp │ ├── 1975 - LR Insertion.cpp │ ├── 1976 - Infinite Set.cpp │ ├── 1977 - Interesting Outing.cpp │ ├── 1978 - Punched Cards.cpp │ ├── 1979 - 3D Printing.cpp │ ├── 1980 - D1000000.cpp │ ├── 1981 - Lacked Number.cpp │ ├── 1982 - Slimes.cpp │ ├── 1983 - Dice Sum.cpp │ ├── 1984 - Range Count Query.cpp │ ├── 1985 - K-Colinear.cpp │ ├── 1986 - Red Versus Blue.cpp │ ├── 1987 - Bit Flipping.cpp │ ├── 1988 - Line Empire.cpp │ ├── 1989 - Direction Change.cpp │ ├── 1990 - Social Distance.cpp │ ├── 1991 - Make It Increasing.cpp │ ├── 1992 - Division.cpp │ ├── 1993 - Triple.cpp │ ├── 1994 - Odd Even Increments.cpp │ ├── 1995 - Colorful Stamp.cpp │ ├── 1996 - 2 Letter Strings.cpp │ ├── 1997 - Eating Candies.cpp │ ├── 1998 - Fall Down.cpp │ └── 1999 - Maximal AND.cpp └── 2000 - 2999 │ ├── 2000 - String Building.cpp │ ├── 2001 - Consecutive Points Segments.cpp │ ├── 2002 - Dolce Vita.cpp │ ├── 2003 - Insert a Progression.cpp │ ├── 2004 - Preorder.cpp │ ├── 2005 - Jogging.cpp │ ├── 2006 - Perfect String.cpp │ ├── 2007 - Just K.cpp │ ├── 2008 - Index Trio.cpp │ ├── 2009 - Beautiful Subgrids.cpp │ ├── 2010 - Eulerian Subgraphs.cpp │ ├── 2011 - New Password.cpp │ ├── 2012 - Range Partition.cpp │ ├── 2013 - Ants on a Stick.cpp │ ├── 2014 - Beat The Odds.cpp │ ├── 2015 - Shoe Shuffling.cpp │ ├── 2016 - Critical Cities.cpp │ ├── 2017 - Subarray Squares.cpp │ ├── 2018 - Knuth Division.cpp │ ├── 2019 - Divisor Analysis.cpp │ ├── 2020 - Prime Multiples.cpp │ ├── 2021 - Exciting Bets.cpp │ ├── 2022 - Customizing the Track.cpp │ ├── 2023 - Need for Pink Slips.cpp │ ├── 2024 - RPD and Rap Sheet Easy.cpp │ ├── 2025 - RPD and Rap Sheet Hard.cpp │ ├── 2026 - XOR Mixup.cpp │ ├── 2027 - Rising Sand.cpp │ ├── 2028 - 3SUM Closure.cpp │ ├── 2029 - Fixed Point Guessing.cpp │ ├── 2030 - Is It Rated - 2.cpp │ ├── 2031 - Aquamoon and Stolen String.cpp │ ├── 2032 - PolandBall and Forest.cpp │ ├── 2033 - Bear and Prime 100.cpp │ ├── 2034 - Guess the Array.cpp │ ├── 2035 - Flamingoes of Mystery.cpp │ ├── 2036 - Chocolate Bunny.cpp │ ├── 2037 - Gifts Unjust Division.cpp │ ├── 2038 - Fun With Strings.cpp │ ├── 2039 - Strips Coloring.cpp │ ├── 2040 - Rhombuses Inside Rectangles.cpp │ ├── 2041 - Shahhoud Training for a Marathon.cpp │ ├── 2042 - Hussein's Army.cpp │ ├── 2043 - Group of Friends.cpp │ ├── 2044 - Ropes Connection.cpp │ ├── 2045 - Pizza Time.cpp │ ├── 2046 - Reversing Strings.cpp │ ├── 2047 - Ali's Schedule.cpp │ ├── 2048 - Make it K-Good.cpp │ ├── 2049 - Array Erasing.cpp │ ├── 2050 - Plan the Event.cpp │ ├── 2051 - Testa Road.cpp │ ├── 2052 - Moving Balls.cpp │ ├── 2053 - Bero the Gamer.cpp │ ├── 2054 - New Sorting Algorithm.cpp │ ├── 2055 - K-Subarrays.cpp │ ├── 2056 - Ziko the Rabbit.cpp │ ├── 2057 - When.cpp │ ├── 2058 - Number Box.cpp │ ├── 2059 - Rotation.cpp │ ├── 2060 - Trophy.cpp │ ├── 2061 - Packing Potatoes.cpp │ ├── 2062 - The Third Three Number Problem.cpp │ ├── 2063 - Almost Ternary Matrix.cpp │ ├── 2064 - The Third Problem.cpp │ ├── 2065 - Grass Field.cpp │ ├── 2066 - Permutation.cpp │ ├── 2067 - Schedule Management.cpp │ ├── 2068 - Permutation Restoration.cpp │ ├── 2069 - Growth Record.cpp │ ├── 2070 - Counterclockwise Rotation.cpp │ ├── 2071 - XX to XXX.cpp │ ├── 2072 - Circumferences.cpp │ ├── 2073 - LCM on Whiteboard.cpp │ ├── 2074 - Select Edges.cpp │ ├── 2075 - Round Down the Price.cpp │ ├── 2076 - Polycarp Writes a String from Memory.cpp │ ├── 2077 - Train and Queries.cpp │ ├── 2078 - Not a Cheap String.cpp │ ├── 2079 - Split Into Two Sets.cpp │ ├── 2080 - Equate Multisets.cpp │ ├── 2081 - Passable Paths.cpp │ ├── 2082 - YES or YES.cpp │ ├── 2083 - ICPC Balloons.cpp │ ├── 2084 - Cypher.cpp │ ├── 2085 - Double Strings.cpp │ ├── 2086 - Mirror Grid.cpp │ ├── 2087 - Yet Another Problem About Pairs Satisfying an Inequality.cpp │ ├── 2088 - Good Key Bad Key.cpp │ ├── 2089 - Mark the Photographer.cpp │ ├── 2090 - Mark the Dust Sweeper.cpp │ ├── 2091 - Mark and His Unfinished Essay.cpp │ ├── 2092 - Difference Operations.cpp │ ├── 2093 - Difference of GCDs.cpp │ ├── 2094 - Doremy's IQ.cpp │ ├── 2095 - Difference Array.cpp │ ├── 2096 - A Unique Letter.cpp │ ├── 2097 - Better Students are Needed.cpp │ ├── 2098 - Changing Jewels.cpp │ ├── 2099 - Draw your Cards.cpp │ ├── 2100 - At Least One.cpp │ ├── 2101 - Find 4-Cycle.cpp │ ├── 2102 - Three Doors.cpp │ ├── 2103 - Also Try Minecraft.cpp │ ├── 2104 - Recover an RBS.cpp │ ├── 2105 - Rorororobot.cpp │ ├── 2106 - Counting Grids.cpp │ ├── 2107 - Dice Probability.cpp │ ├── 2108 - Finding Periods.cpp │ ├── 2109 - Substring Order 2.cpp │ ├── 2110 - Minimum Euclidean Distance.cpp │ ├── 2111 - Reachable Nodes.cpp │ ├── 2112 - Reachability Queries.cpp │ ├── 2113 - Reversals and Sums.cpp │ ├── 2114 - Monster Game 1.cpp │ ├── 2115 - Monster Game 2.cpp │ ├── 2116 - Empty String.cpp │ ├── 2117 - Permutation Inversions.cpp │ ├── 2118 - Prufer Code.cpp │ ├── 2119 - Stack Weights.cpp │ ├── 2120 - Tree Isomorphism 1.cpp │ ├── 2121 - Tree Isomorphism 2.cpp │ ├── 2122 - Full House.cpp │ ├── 2123 - Ancestor.cpp │ ├── 2124 - Monotonically Increasing.cpp │ ├── 2125 - Left Right Operation.cpp │ ├── 2126 - Sugoroku 3.cpp │ ├── 2127 - Traveling Salesman Problem.cpp │ ├── 2128 - Optimal Reduction.cpp │ ├── 2129 - Build Permutation.cpp │ ├── 2130 - Tournament Countdown.cpp │ ├── 2131 - Houses and Schools.cpp │ ├── 2132 - Dynamic Connectivity.cpp │ ├── 2133 - Parcel Delivery.cpp │ ├── 2134 - Task Assignment.cpp │ ├── 2135 - Distinct Routes 2.cpp │ ├── 2136 - Even Outdegree Edges.cpp │ ├── 2137 - Flight Route Requests.cpp │ ├── 2138 - Grid Puzzle 2.cpp │ ├── 2139 - Special Substring.cpp │ ├── 2140 - Stick Divisions.cpp │ ├── 2141 - Strongly Connected Edges.cpp │ ├── 2142 - Visiting Cities.cpp │ ├── 2143 - Apple Division.cpp │ ├── 2144 - Acyclic Graph Edges.cpp │ ├── 2145 - Permutation Inversions.cpp │ ├── 2146 - Shortest Subsequence.cpp │ ├── 2147 - Quasi Palindrome.cpp │ ├── 2148 - Kayaking.cpp │ ├── 2149 - 1-2-3.cpp │ ├── 2150 - Yet Another Array Queries Problem.cpp │ ├── 2151 - Turn Off The TV.cpp │ ├── 2152 - Almost Permutation.cpp │ ├── 2153 - Chip Game.cpp │ ├── 2154 - Mathematical Circus.cpp │ ├── 2155 - Fighting Tournament.cpp │ ├── 2156 - Fibonacci Strings.cpp │ ├── 2157 - Burenka Plays with Fractions.cpp │ ├── 2158 - Interesting Sum.cpp │ ├── 2159 - Corners.cpp │ ├── 2160 -Segment Tree for the Sum.cpp │ ├── 2161 - Segment Tree for the Minimum.cpp │ ├── 2162 - Number of Minimums on a Segment.cpp │ ├── 2163 - Segment with the Maximum Sum.cpp │ ├── 2164 - Kth One.cpp │ ├── 2165 - First Element at Least X 1.cpp │ ├── 2166 - First Element at Least X 2.cpp │ ├── 2167 - Inversions 1.cpp │ ├── 2168 - Inversions 2.cpp │ ├── 2169 - Nested Segments.cpp │ ├── 2170 - Intersecting Segments.cpp │ ├── 2171 - Addition to Segment.cpp │ ├── 2172 - Sign Alternation.cpp │ ├── 2173 - Cryptography.cpp │ ├── 2174 - Number of Inversions on Segment.cpp │ ├── 2175 - Number of Different on Segment.cpp │ ├── 2176 - Earthquakes.cpp │ ├── 2177 - Addition to Segment.cpp │ ├── 2178 - Applying MAX to Segment.cpp │ ├── 2179 - Assignment to Segment.cpp │ ├── 2180 - Addition and Minimum.cpp │ ├── 2181 - Multiplication and Sum.cpp │ ├── 2182 - Bitwise OR and AND.cpp │ ├── 2183 - Addition and Sum.cpp │ ├── 2184 - Assignment and Minimum.cpp │ ├── 2185 - Assignment and Sum.cpp │ ├── 2186 - Assignment and Maximal Segment.cpp │ ├── 2187 - Inverse and Kth One.cpp │ ├── 2188 - Addition and First Element at Least X.cpp │ ├── 2189 - Middle Letter.cpp │ ├── 2190 - Modulo Number.cpp │ ├── 2191 - Convex Quadrilateral.cpp │ ├── 2192 - Snuke Panic 1D.cpp │ ├── 2193 - Throwing the Die.cpp │ ├── 2194 - Well Defined Path Queries on a Namori.cpp │ ├── 2195 - Image.cpp │ ├── 2196 - Deadly Laser.cpp │ ├── 2197 - Min Max Array Transformation.cpp │ ├── 2198 - Maximum AND.cpp │ ├── 2199 - Spell Check.cpp │ ├── 2200 - Colourblindness.cpp │ ├── 2201 - Word Game.cpp │ ├── 2202 - Line.cpp │ ├── 2203 - Counting Rectangles.cpp │ ├── 2204 - L-Shapes.cpp │ ├── 2205 - Even Odd XOR.cpp │ ├── 2206 - Area of Rectangles.cpp │ ├── 2207 - Cyclic Array.cpp │ ├── 2208 - Grid Paths.cpp │ ├── 2209 - Santiago Bernabeu.cpp │ ├── 2210 - Ronaldo the Wise.cpp │ ├── 2211 - Triple Football Stars Tournament.cpp │ ├── 2212 - Syria in Russia 2018.cpp │ ├── 2213 - Isco's House.cpp │ ├── 2214 - Qatar 2022.cpp │ ├── 2215 - Roger and Rafa.cpp │ ├── 2216 - Ballon D'Or.cpp │ ├── 2217 - Road to Camp Nou.cpp │ ├── 2218 - The Egyptian Derby.cpp │ ├── 2219 - Madridista.cpp │ ├── 2220 - Mr. AH and the Beautiful Substring.cpp │ ├── 2221 - Yet Another Partition Problem.cpp │ ├── 2222 - Madoka and Strange Thoughts.cpp │ ├── 2223 - Madoka and Underground Competitions.cpp │ ├── 2224 - Madoka and Formal Statements.cpp │ ├── 2225 - Madoka and the Corruption Scheme.cpp │ ├── 2226 - Saturday.cpp │ ├── 2227 - Split.cpp │ ├── 2228 - Index x A (Continuous).cpp │ ├── 2229 - Index x A (Not Continuous).cpp │ ├── 2230 - Erasing Vertices.cpp │ ├── 2231 - Exactly K Steps.cpp │ ├── 2232 - Colored Balls Revisited.cpp │ ├── 2233 - Best Permutation.cpp │ ├── 2234 - Digital Logarithm.cpp │ ├── 2235 - Letter Picking.cpp │ ├── 2236 - Five Integers.cpp │ ├── 2237 - Prefix.cpp │ ├── 2238 - Chinese Restaurant.cpp │ ├── 2239 - Unique Username.cpp │ ├── 2240 - Chinese Restaurant Three Star Version.cpp │ ├── 2241 - Two Elevators.cpp │ ├── 2242 - Decode String.cpp │ ├── 2243 - Jumping on Tiles.cpp │ ├── 2244 - Friends and The Restaurant.cpp │ ├── 2245 - Guess the Cycle Size.cpp │ ├── 2246 - Kirei and the Linear Function.cpp │ ├── 2247 - Suffix Array 1.cpp │ ├── 2248 - Suffix Array 2.cpp │ ├── 2249 - Substring Search.cpp │ ├── 2250 - Counting Substrings.cpp │ ├── 2251 - Suffix Array and LCP.cpp │ ├── 2252 - Anyway Takahashi.cpp │ ├── 2253 - Rectangle Detection.cpp │ ├── 2254 - Submask.cpp │ ├── 2255 - Do Use Hexagon Grid.cpp │ ├── 2256 - Last Rook.cpp │ ├── 2257 - A Personal Voyage.cpp │ ├── 2258 - Tonystan.cpp │ ├── 2259 - Triple Jumps.cpp │ ├── 2260 - Zootopia's New Metro System.cpp │ ├── 2261 - Counting Bishops.cpp │ ├── 2262 - Increasing Array 2.cpp │ ├── 2263 - String Reorder.cpp │ ├── 2264 - Binary Search.cpp │ ├── 2265 - Closest to the Left.cpp │ ├── 2266 - Closest to the Right.cpp │ ├── 2267 - Fast Search.cpp │ ├── 2268 - Packing Rectangles.cpp │ ├── 2269 - Ropes.cpp │ ├── 2270 - Very Easy Task.cpp │ ├── 2271 - Children Holiday.cpp │ ├── 2272 - Equation.cpp │ ├── 2273 - String Game.cpp │ ├── 2274 - Student Council.cpp │ ├── 2275 - Hamburgers.cpp │ ├── 2276 - Get Together.cpp │ ├── 2277 - Splitting an Array.cpp │ ├── 2278 - Cows in Stalls.cpp │ ├── 2279 - Minimum Maximum on the Path.cpp │ ├── 2280 - Maximum Average Segment.cpp │ ├── 2281 - Minimum Average Path.cpp │ ├── 2282 - Pair Selection.cpp │ ├── 2283 - Kth Number in the Union of Segments.cpp │ ├── 2284 - Multiplication Table.cpp │ ├── 2285 - Kth Sum.cpp │ ├── 2286 - 1-2-4 Test.cpp │ ├── 2287 - Hammer.cpp │ ├── 2288 - Simple Path.cpp │ ├── 2289 - Stones.cpp │ ├── 2290 - Apple Baskets on Circle.cpp │ ├── 2291 - Transportation.cpp │ ├── 2292 - Sequences in mod P.cpp │ ├── 2293 - Bit Problem.cpp │ ├── 2294 - Bit Substrings.cpp │ ├── 2295 - Number Grid.cpp │ ├── 2296 - Swap Round Sorting.cpp │ ├── 2297 - Second Hands.cpp │ ├── 2298 - Second Friend.cpp │ ├── 2299 - Second Second Friend.cpp │ ├── 2300 - Second Meaning.cpp │ ├── 2301 - Second Second Meaning.cpp │ ├── 2302 - Consecutive Cuts Chapter 1.cpp │ ├── 2303 - Consecutive Cuts Chapter 2.cpp │ ├── 2304 - Watering Well Chapter 1.cpp │ ├── 2305 - Watering Well Chapter 2.cpp │ ├── 2306 - Perfectly Balanced Chapter 1.cpp │ ├── 2307 - Perfectly Balanced Chapter 2.cpp │ ├── 2308 - Looped Playlist.cpp │ ├── 2309 - Total Length.cpp │ ├── 2310 - Che City.cpp │ ├── 2311 - Stylish Clothes.cpp │ ├── 2312 - Knapsack on a Segment.cpp │ ├── 2313 - Card Substrings.cpp │ ├── 2314 - Not Very Rude Substring.cpp │ ├── 2315 - A-B Knapsack.cpp │ ├── 2316 - Segment with the Required Subset.cpp │ ├── 2317 - Planets.cpp │ ├── 2318 - Meeting on the Line.cpp │ ├── 2319 - Minimum Notation.cpp │ ├── 2320 - Prefixes and Suffixes.cpp │ ├── 2321 - Immobile Knight.cpp │ ├── 2322 - Array Recovery.cpp │ ├── 2323 - Card Game.cpp │ ├── 2324 - Reset K Edges.cpp │ ├── 2325 - 484558.cpp │ ├── 2326 - Maintain Multiple Sequences.cpp │ ├── 2327 - Manga.cpp │ ├── 2328 - Flip and Adjust.cpp │ ├── 2329 - Subsequence Path.cpp │ ├── 2330 - XOR on Grid Path.cpp │ ├── 2331 - Chess Tournament.cpp │ ├── 2332 - Increasing Subsequence 2.cpp │ ├── 2333 - Intersection Points.cpp │ ├── 2334 - Inverse Inversion.cpp │ ├── 2335 - Monotone Subsequences.cpp │ ├── 2336 - Movie Festival Queries.cpp │ ├── 2337 - String Transform.cpp │ ├── 2338 - Writing Numbers.cpp │ ├── 2339 - Diffonacci.cpp │ ├── 2340 - Digits.cpp │ ├── 2341 - Lucky Numbers.cpp │ ├── 2342 - Make A Equal to B.cpp │ ├── 2343 - Playing with GCD.cpp │ ├── 2344 - Good Subarrays (Easy).cpp │ ├── 2345 - Good Subarrays (Hard).cpp │ ├── 2346 - Equal Binary Subsequences.cpp │ ├── 2347 - Compare T-Shirt Sizes.cpp │ ├── 2348 - Funny Permutation.cpp │ ├── 2349 - Minimize Thickness.cpp │ ├── 2350 - Masha and a Beautiful Tree.cpp │ ├── 2351 - Sending a Sequence over the Network.cpp │ ├── 2352 - MultiColored Segments.cpp │ ├── 2353 - Sum.cpp │ ├── 2354 - Increasing.cpp │ ├── 2355 - Stripes.cpp │ ├── 2356 - Coprime.cpp │ ├── 2357 - Scuza.cpp │ ├── 2358 - Smaller.cpp │ ├── 2359 - Orray.cpp │ ├── 2360 - Password.cpp │ ├── 2361 - Permutation Value.cpp │ ├── 2362 - Save the Magazines.cpp │ ├── 2363 - Problem with Random Tests.cpp │ ├── 2364 - Cowardly Rooks.cpp │ ├── 2365 - Death's Blessing.cpp │ ├── 2366 - Number Game.cpp │ ├── 2367 - Counting Arrays.cpp │ ├── 2368 - Cactus Wall.cpp │ ├── 2369 - Binary Subsequences.cpp │ ├── 2370 - Functional Graph Distribution.cpp │ ├── 2371 - Letter Pair Move Game.cpp │ ├── 2372 - List of Sums.cpp │ ├── 2373 - Mercato.cpp │ ├── 2374 - Milano Derby.cpp │ ├── 2375 - Bit Problem.cpp │ ├── 2376 - Food Division.cpp │ ├── 2377 - Permutations II.cpp │ ├── 2378 - Sorting Methods.cpp │ ├── 2379 - The Ultimate Square.cpp │ ├── 2380 - Diverse Substrings.cpp │ ├── 2381 - Zero-Sum Prefixes.cpp │ ├── 2382 - Two Permutations.cpp │ ├── 2383 - Elimination of a Ring.cpp │ ├── 2384 - Set Construction.cpp │ ├── 2385 - Carry Bit.cpp │ ├── 2386 - Wwwvvvvvv.cpp │ ├── 2387 - LOOKUP.cpp │ ├── 2388 - RANDOM.cpp │ ├── 2389 - Freefall.cpp │ ├── 2390 - Cheating Amidakuji.cpp │ ├── 2391 - BOX.cpp │ ├── 2392 - Doremy's Paint.cpp │ ├── 2393 - Doremy's Perfect Math Class.cpp │ ├── 2394 - Doremy's City Construction.cpp │ ├── 2395 - Doremy's Pegging Game.cpp │ ├── 2396 - Majority.cpp │ ├── 2397 - Postal Card.cpp │ ├── 2398 - Path Graph.cpp │ ├── 2399 - Match or Not.cpp │ ├── 2400 - Karuta.cpp │ ├── 2401 - Exponential Equation.cpp │ ├── 2402 - Number Factorization.cpp │ ├── 2403 - Remove the Bracket.cpp │ ├── 2404 - Game on Axis.cpp │ ├── 2405 - Flip Flop Sum.cpp │ ├── 2406 - The Forbidden Permutation.cpp │ ├── 2407 - Flexibe String.cpp │ ├── 2408 - Flexible String Revisit.cpp │ ├── 2409 - Codeforces Checking.cpp │ ├── 2410 - Following Directions.cpp │ ├── 2411 - Prepend and Append.cpp │ ├── 2412 - Distinct Split.cpp │ ├── 2413 - Negatives and Positives.cpp │ ├── 2414 - Range Update Point Query.cpp │ ├── 2415 - Teleporters Easy.cpp │ ├── 2416 - Many A+B problems.cpp │ ├── 2417 - Qualification Contest.cpp │ ├── 2418 - Don't Be Cycle.cpp │ ├── 2419 - Integer Division.cpp │ ├── 2420 - Camel Case.cpp │ ├── 2421 - Trimmed Mean.cpp │ ├── 2422 - LRUD Instructions 2.cpp │ ├── 2423 - Flip Cards.cpp │ ├── 2424 - Find Permutation.cpp │ ├── 2425 - Teleporter and Closed Off.cpp │ ├── 2426 - Alternately.cpp │ ├── 2427 - Chessboard.cpp │ ├── 2428 - Gap Existence.cpp │ ├── 2429 - M leq ab.cpp │ ├── 2430 - Transition Game.cpp │ ├── 2431 - Divisible Array.cpp │ ├── 2432 - Permutation Swap.cpp │ ├── 2433 - Counting Orders.cpp │ ├── 2434 - Musical Puzzle.cpp │ ├── 2435 - Restore the Weather.cpp │ ├── 2436 - Vlad Building Beautiful Array.cpp │ ├── 2437 - Flipper.cpp │ ├── 2438 - Round Dance.cpp │ ├── 2439 - Ira and Flamenco.cpp │ ├── 2440 - Attack.cpp │ ├── 2441 - Find Snuke.cpp │ ├── 2442 - Almost Equal.cpp │ ├── 2443 - Impartial Gift.cpp │ ├── 2444 - Isolation.cpp │ ├── 2445 - Merge Set.cpp │ ├── 2446 - Grasshopper on a Line.cpp │ ├── 2447 - Comparison String.cpp │ ├── 2448 - Best Binary String.cpp │ ├── 2449 - Bracket Coloring.cpp │ ├── 2450 - Playoff Fixing.cpp │ ├── 2451 - Similar String.cpp │ ├── 2452 - Discord.cpp │ ├── 2453 - Dash.cpp │ ├── 2454 - Shift vs CapsLock.cpp │ └── 2455 - Gift From The Stars.cpp └── README.md /CSES Problem Set/01 - Introductory Problems/Bit Strings.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | const ll mod = 1000 * 1000 * 1000 + 7; 5 | 6 | ll power2(int n) { 7 | ll res = 1; 8 | for (ll x = 2; n; n >>= 1, x = (x * x) % mod) 9 | if (n & 1) res = (res * x) % mod; 10 | return res; 11 | } 12 | 13 | int main() { 14 | int n; cin >> n; cout << power2(n) << '\n'; 15 | } -------------------------------------------------------------------------------- /CSES Problem Set/01 - Introductory Problems/Coin Piles.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int a, b; cin >> a >> b; 8 | if (a > b) { swap(a, b); } 9 | if (2 * a < b) { cout << "NO\n"; continue; } 10 | a -= (b - a); cout << (a % 3 ? "NO" : "YES") << '\n'; 11 | } 12 | } -------------------------------------------------------------------------------- /CSES Problem Set/01 - Introductory Problems/Creating Strings I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | string s; cin >> s; sort(s.begin(), s.end()); vector res(1, s); 6 | while (next_permutation(s.begin(), s.end())) { res.push_back(s); } 7 | cout << res.size() << '\n'; for (auto &x : res) 8 | cout << x << ' '; cout << '\n'; 9 | } -------------------------------------------------------------------------------- /CSES Problem Set/01 - Introductory Problems/Increasing Array.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | int n; cin >> n; vector v(n); 7 | for (auto &x : v) { cin >> x; } 8 | int cur = 0; ll res = 0; 9 | 10 | for (auto &x : v) { cur = max(cur, x); res += cur - x; } 11 | cout << res << '\n'; 12 | } -------------------------------------------------------------------------------- /CSES Problem Set/01 - Introductory Problems/Missing Number.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n; cin >> n; int res = 0; 6 | for (int i = 0; i < n - 1; i++) { 7 | int x; cin >> x; res ^= x ^ (i + 1); 8 | } 9 | cout << (res ^ n) << '\n'; 10 | } -------------------------------------------------------------------------------- /CSES Problem Set/01 - Introductory Problems/Permutations I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n; cin >> n; 6 | if (n == 1) { cout << "1\n"; return 0; } 7 | if (n < 4) { cout << "NO SOLUTION\n"; return 0; } 8 | for (int i = 2; i <= n; i += 2) cout << i << ' '; 9 | for (int i = 1; i <= n; i += 2) cout << i << ' '; 10 | cout << '\n'; 11 | } -------------------------------------------------------------------------------- /CSES Problem Set/01 - Introductory Problems/Repetitions.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | string s; cin >> s; int n = (int)s.size(); 6 | int i = 0, j = 0, res = 0; 7 | while (j != n) { 8 | if (s[j] == s[i]) { j++; continue; } 9 | res = max(res, j - i); i = j; 10 | } 11 | cout << max(res, j - i) << '\n'; 12 | } -------------------------------------------------------------------------------- /CSES Problem Set/01 - Introductory Problems/Tower of Hanoi.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | void Hanoi(int start, int mid, int end, int n) { 5 | if (n == 1) { cout << start << ' ' << end << '\n'; return; } 6 | 7 | Hanoi(start, end, mid, n - 1); 8 | cout << start << ' ' << end << '\n'; 9 | Hanoi(mid, start, end, n - 1); 10 | } 11 | 12 | int main() { 13 | int n; cin >> n; 14 | cout << (1 << n) - 1 << '\n'; 15 | Hanoi(1, 2, 3, n); 16 | } -------------------------------------------------------------------------------- /CSES Problem Set/01 - Introductory Problems/Trailing Zeros.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n; cin >> n; int res = 0; 6 | while (n) { res += (n /= 5); } 7 | cout << res << '\n'; 8 | } -------------------------------------------------------------------------------- /CSES Problem Set/01 - Introductory Problems/Two Knights.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | ll knights(ll n) { 6 | return n * n * (n * n - 1) / 2 - 4 * (n - 1) * (n - 2); 7 | } 8 | 9 | int main() { 10 | int n; cin >> n; 11 | for (int i = 0; i < n; i++) 12 | cout << knights(i + 1) << '\n'; 13 | } -------------------------------------------------------------------------------- /CSES Problem Set/01 - Introductory Problems/Weird Algorithm.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | ll n; cin >> n; 7 | for (; n != 1; n = n & 1 ? 3 * n + 1 : n >> 1) 8 | cout << n << ' '; cout << "1\n"; 9 | } -------------------------------------------------------------------------------- /CSES Problem Set/02 - Sorting and Searching/Collecting Numbers I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | vector v, a; 5 | 6 | int main() { 7 | int n; cin >> n; v.resize(n); a.resize(n); 8 | for (int i = 0; i < n; i++) { cin >> v[i]; a[--v[i]] = i; } 9 | int res = 1; for (int i = 1; i < n; i++) res += a[i] < a[i - 1]; 10 | cout << res << '\n'; 11 | } -------------------------------------------------------------------------------- /CSES Problem Set/02 - Sorting and Searching/Concert Tickets.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n, m; cin >> n >> m; 6 | multiset> s; 7 | while (n--) { int x; cin >> x; s.insert(x); } 8 | while (m--) { 9 | int p; cin >> p; 10 | auto it = s.lower_bound(p); 11 | if (it == s.end()) { cout << -1 << '\n'; continue; } 12 | cout << *it << '\n'; s.erase(it); 13 | } 14 | } -------------------------------------------------------------------------------- /CSES Problem Set/02 - Sorting and Searching/Distinct Numbers.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n; cin >> n; set s; 6 | while (n--) { int x; cin >> x; s.insert(x); } 7 | cout << s.size() << '\n'; 8 | } -------------------------------------------------------------------------------- /CSES Problem Set/02 - Sorting and Searching/Ferris Wheel.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | vector v; 5 | 6 | int main() { 7 | int n, X; cin >> n >> X; v.resize(n); 8 | for (auto &x : v) { cin >> x; } 9 | sort(v.begin(), v.end()); 10 | int i = 0, j = n - 1, res = 0; 11 | while (i <= j) 12 | if (v[i] + v[j] > X) { j--; res++; } 13 | else { i++; j--; res++; } 14 | cout << res << '\n'; 15 | } -------------------------------------------------------------------------------- /CSES Problem Set/02 - Sorting and Searching/Maximum Subarray Sum I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | vector v; 6 | 7 | int main() { 8 | int n; cin >> n; v.resize(n); 9 | for (auto &x : v) { cin >> x; } 10 | ll cur = 0, res = v[0]; 11 | for (auto &x : v) { 12 | cur += x; res = max(res, cur); 13 | if (cur < 0) { cur = 0; } 14 | } 15 | cout << res << '\n'; 16 | } -------------------------------------------------------------------------------- /CSES Problem Set/02 - Sorting and Searching/Missing Coin Sum.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | vector v; 6 | 7 | int main() { 8 | int n; cin >> n; v.resize(n); 9 | for (auto& x : v) { cin >> x; } 10 | sort(v.begin(), v.end()); 11 | ll res = 1; for (auto& x : v) { 12 | if (x > res) break; res += x; 13 | } 14 | cout << res << '\n'; 15 | } -------------------------------------------------------------------------------- /CSES Problem Set/02 - Sorting and Searching/Movie Festival I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | vector> v; 5 | 6 | int main() { 7 | int n; cin >> n; v.resize(n); 8 | for (auto &x : v) { cin >> x.second >> x.first; } 9 | sort(v.begin(), v.end()); int cur = 0, res = 0; 10 | for (auto &x : v) { 11 | if (x.second < cur) { continue; } 12 | res++; cur = x.first; 13 | } 14 | cout << res << '\n'; 15 | } -------------------------------------------------------------------------------- /CSES Problem Set/02 - Sorting and Searching/Reading Books.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | vector v; 6 | 7 | int main() { 8 | int n; cin >> n; v.resize(n); 9 | for (auto &x : v) { cin >> x; } 10 | sort(v.begin(), v.end()); 11 | cout << max(2 * v.back(), accumulate(v.begin(), v.end(), 0ll)) << '\n'; 12 | } -------------------------------------------------------------------------------- /CSES Problem Set/02 - Sorting and Searching/Stick Lengths.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | vector v; 6 | 7 | int main() { 8 | int n; cin >> n; v.resize(n); 9 | for (auto &x : v) { cin >> x; } 10 | sort(v.begin(), v.end()); 11 | int med = v[n / 2]; 12 | for (auto &x : v) { x = abs(x - med); } 13 | cout << accumulate(v.begin(), v.end(), 0ll) << '\n'; 14 | } -------------------------------------------------------------------------------- /CSES Problem Set/02 - Sorting and Searching/Tasks and Deadlines.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | vector> v; 6 | 7 | int main() { 8 | int n; cin >> n; v.resize(n); 9 | for (auto &x : v) { cin >> x.first >> x.second; } 10 | sort(v.begin(), v.end()); ll cur = 0, res = 0; 11 | for (auto &x : v) { cur += x.first; res += x.second - cur; } 12 | cout << res << '\n'; 13 | } -------------------------------------------------------------------------------- /CSES Problem Set/02 - Sorting and Searching/Towers.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | vector v; multiset s; 5 | 6 | int main() { 7 | int n; cin >> n; v.resize(n); int res = 0; 8 | for (auto &x : v) { 9 | cin >> x; auto it = s.upper_bound(x); 10 | if (it == s.end()) { s.insert(x); continue; } 11 | s.erase(it); s.insert(x); 12 | } 13 | cout << s.size() << '\n'; 14 | } -------------------------------------------------------------------------------- /CSES Problem Set/03 - Dynamic Programming/Increasing Subsequence I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | vector v, res; 5 | 6 | int main() { 7 | int n; cin >> n; v.resize(n); 8 | for (auto &x : v) { cin >> x; } 9 | res.resize(n + 1, 1 << 30); res[0] = -res[0]; 10 | for (auto &x : v) { *lower_bound(res.begin(), res.end(), x) = x; } 11 | cout << find(res.begin(), res.end(), 1 << 30) - res.begin() - 1 << '\n'; 12 | } -------------------------------------------------------------------------------- /CSES Problem Set/03 - Dynamic Programming/Money Sums.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | const int N = 100001; 5 | 6 | int main() { 7 | ios::sync_with_stdio(0); 8 | cin.tie(0); cout.tie(0); 9 | 10 | int n; cin >> n; bitset dp(1); 11 | while (n--) { int x; cin >> x; dp |= dp << x; } 12 | cout << dp.count() - 1 << '\n'; 13 | for (int i = 1; i < N; i++) if (dp[i]) 14 | cout << i << ' '; cout << '\n'; 15 | } -------------------------------------------------------------------------------- /CSES Problem Set/03 - Dynamic Programming/Removing Digits I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int dp[10] = {0, 1, 1, 1, 1, 1, 1, 1, 1, 1}; 5 | 6 | int main() { 7 | int n; cin >> n; 8 | for (int i = 10; i <= n; i++) { 9 | int x = i; dp[i % 10] = i; while (x) { 10 | if (x % 10) dp[i % 10] = min(dp[i % 10], 1 + dp[(i - (x % 10)) % 10]); 11 | x /= 10; 12 | } 13 | } 14 | cout << dp[n % 10] << '\n'; 15 | } -------------------------------------------------------------------------------- /CSES Problem Set/05 - Range Queries/Range XOR Queries.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | vector v; 5 | 6 | int main() { 7 | int n, q; cin >> n >> q; v.resize(n + 1, 0); 8 | for (int i = 1; i <= n; i++) { 9 | int x; cin >> x; v[i] = v[i - 1] ^ x; 10 | } 11 | while (q--) { 12 | int a, b; cin >> a >> b; 13 | cout << (v[b] ^ v[a - 1]) << endl; 14 | } 15 | } -------------------------------------------------------------------------------- /CSES Problem Set/05 - Range Queries/Static Range Sum Queries.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | vector v; 6 | 7 | int main() { 8 | int n, q; cin >> n >> q; v.resize(n + 1, 0); 9 | for (int i = 1; i <= n; i++) { 10 | int x; cin >> x; v[i] = v[i - 1] + x; 11 | } 12 | while (q--) { 13 | int a, b; cin >> a >> b; 14 | cout << v[b] - v[a - 1] << '\n'; 15 | } 16 | } -------------------------------------------------------------------------------- /CSES Problem Set/07 - Mathematics/Another Game.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | vector v; 5 | 6 | int main() { 7 | ios::sync_with_stdio(0); 8 | cin.tie(0); cout.tie(0); 9 | 10 | int t; cin >> t; while (t--) { 11 | int n; cin >> n; v.resize(n); 12 | for (auto& x : v) { cin >> x; x &= 1; } 13 | bool b = count(v.begin(), v.end(), 1); 14 | cout << (b ? "first" : "second") << '\n'; 15 | } 16 | } -------------------------------------------------------------------------------- /CSES Problem Set/07 - Mathematics/Candy Lottery.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long double ld; 4 | 5 | int main() { 6 | int n, k; cin >> n >> k; 7 | vector v(k); ld sum = 0.0, res = 0.0; 8 | for (int i = 0; i < k; i++) { 9 | v[i] = pow((i + 1.0) / (k + 0.0), n + 0.0); 10 | v[i] -= sum; sum += v[i]; 11 | } 12 | for (int i = 0; i < k; i++) { res += (i + 1) * v[i]; } 13 | cout << fixed << setprecision(6) << res << '\n'; 14 | } -------------------------------------------------------------------------------- /CSES Problem Set/07 - Mathematics/Exponentiation I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | const ll mod = 1000 * 1000 * 1000 + 7; 5 | 6 | ll power(ll x, ll n) { 7 | ll res = 1, a = x; 8 | for(; n; n >>= 1, a = (a * a) % mod) 9 | if (n & 1) { res = (res * a) % mod; } 10 | return res; 11 | } 12 | 13 | int main() { 14 | int n; cin >> n; while (n--) { 15 | int a, b; cin >> a >> b; 16 | cout << power(a, b) << endl; 17 | } 18 | } -------------------------------------------------------------------------------- /CSES Problem Set/07 - Mathematics/Nim Game I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int n; cin >> n; int res = 0; 8 | while (n--) { int x; cin >> x; res ^= x; } 9 | cout << (res ? "first" : "second") << '\n'; 10 | } 11 | } -------------------------------------------------------------------------------- /CSES Problem Set/07 - Mathematics/Nim Game II.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int n; cin >> n; int res = 0; 8 | while (n--) { int x; cin >> x; res ^= (x % 4); } 9 | cout << (res ? "first" : "second") << '\n'; 10 | } 11 | } -------------------------------------------------------------------------------- /CSES Problem Set/07 - Mathematics/Stair Game.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); cout.tie(0); 7 | 8 | int t; cin >> t; while (t--) { 9 | int n; cin >> n; int res = 0; 10 | for (int i = 0; i < n; i++) { 11 | int x; cin >> x; 12 | if (i & 1) res ^= x; 13 | } 14 | cout << (res ? "first" : "second") << '\n'; 15 | } 16 | } -------------------------------------------------------------------------------- /CSES Problem Set/11 - Additional Problems/Acyclic Graph Edges.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); cout.tie(0); 7 | 8 | int n, m; cin >> n >> m; while(m--){ 9 | int a, b; cin >> a >> b; 10 | if(a > b) swap(a, b); 11 | cout << a << ' ' << b << '\n'; 12 | } 13 | } -------------------------------------------------------------------------------- /CSES Problem Set/11 - Additional Problems/Counting Bits.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | ll n; cin >> n; ll res = 0; n++; 7 | for (int i = 0; i < 50; i++) { 8 | ll mask = 1ll << (i + 1); 9 | res += (n / mask) * (mask >> 1); 10 | res += max(0ll, n % mask - (mask >> 1)); 11 | } 12 | cout << res << '\n'; 13 | } -------------------------------------------------------------------------------- /CSES Problem Set/11 - Additional Problems/XOR Pyramid.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); cout.tie(0); 7 | 8 | int n; cin >> n; int res = 0; 9 | for (int i = 0; i < n; i++) { 10 | int x; cin >> x; 11 | if (!(i & (n - 1 - i))) { res ^= x; } 12 | } 13 | cout << res << '\n'; 14 | } -------------------------------------------------------------------------------- /CSES Problem Set/CSES Problem Set Editorial.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/CSES Problem Set/CSES Problem Set Editorial.pdf -------------------------------------------------------------------------------- /Competitive Programming Syllabus/Level 1/Combinatorics/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Competitive Programming Syllabus/Level 1/Combinatorics/README.md -------------------------------------------------------------------------------- /Competitive Programming Syllabus/Level 1/Dynamic Programming/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Competitive Programming Syllabus/Level 1/Dynamic Programming/README.md -------------------------------------------------------------------------------- /Competitive Programming Syllabus/Level 1/Graph Algorithms/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Competitive Programming Syllabus/Level 1/Graph Algorithms/README.md -------------------------------------------------------------------------------- /Competitive Programming Syllabus/Level 1/Mathematics/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Competitive Programming Syllabus/Level 1/Mathematics/README.md -------------------------------------------------------------------------------- /Competitive Programming Syllabus/Level 1/String Algorithms/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Competitive Programming Syllabus/Level 1/String Algorithms/README.md -------------------------------------------------------------------------------- /Competitive Programming Syllabus/Level 1/Tree Algorithms/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Competitive Programming Syllabus/Level 1/Tree Algorithms/README.md -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/ACPC 12 (BEFM Unsolved)/ACPC 12 (Without Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/ACPC 12 (BEFM Unsolved)/ACPC 12 (Without Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/ACPC 12 (BEFM Unsolved)/Kids Love Candies.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n, k; cin >> n >> k; 6 | int res = 0; 7 | for (int i = 0; i < n; i++) { 8 | int t; cin >> t; res += t / k; 9 | } 10 | cout << res << endl; 11 | cin.ignore(2); return 0; 12 | } 13 | -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/ACPC 18 (EGHJK Unsolved)/ACPC 18 (With Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/ACPC 18 (EGHJK Unsolved)/ACPC 18 (With Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/ACPC 18 (EGHJK Unsolved)/Looking for Taste.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | freopen("looking.in", "r", stdin); 6 | ios::sync_with_stdio(0); 7 | cin.tie(0); cout.tie(0); 8 | 9 | int t; cin >> t; while (t--) { 10 | int n, k; cin >> n >> k; int res = 0; 11 | while (n--) { int x; cin >> x; res |= x; } 12 | cout << res << '\n'; 13 | } 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/ACPC 19 (BGHIKL Unsolved)/ACPC 19 (Without Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/ACPC 19 (BGHIKL Unsolved)/ACPC 19 (Without Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/ACPC 19 (BGHIKL Unsolved)/Endure is Going to Space.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | typedef long long ll; 5 | 6 | int main() { 7 | freopen("endure.in", "r", stdin); 8 | ios::sync_with_stdio(0); 9 | cin.tie(0); cout.tie(0); 10 | 11 | int t; cin >> t; while (t--) { 12 | string a; ll y, s; 13 | cin >> a >> y >> s; 14 | y *= 365 * 24 * 3600; 15 | cout << y * s << '\n'; 16 | } 17 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/ACPC 20 (Unsolved)/ACPC 20 (Without Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/ACPC 20 (Unsolved)/ACPC 20 (Without Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/ACPC 20 KickOff (FIL Unsolved)/ACPC 20 KickOff (Wihtout Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/ACPC 20 KickOff (FIL Unsolved)/ACPC 20 KickOff (Wihtout Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/ACPC 20 KickOff (FIL Unsolved)/Absent Students.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | freopen("students.in", "r", stdin); 6 | 7 | int t; cin >> t; while (t--) { 8 | int n, m; cin >> n >> m; 9 | cout << n - m << '\n'; 10 | } 11 | return 0; 12 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/ACPC 20 KickOff (FIL Unsolved)/Bakery Chief.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | ios::sync_with_stdio(0); 7 | cin.tie(0); cout.tie(0); 8 | 9 | freopen("chief.in", "r", stdin); 10 | 11 | int t; cin >> t; while (t--) { 12 | int k, n; cin >> k >> n; 13 | cout << k / n << ' ' << k % n << '\n'; 14 | } 15 | return 0; 16 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/ACPC 21 (DHJL Unsolved)/ACPC 2021 (Without Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/ACPC 21 (DHJL Unsolved)/ACPC 2021 (Without Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/ACPC 21 (DHJL Unsolved)/Fouad Wears Suits.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | typedef long long ll; 5 | 6 | int main() { 7 | freopen("fouad.in", "r", stdin); 8 | ios::sync_with_stdio(0); 9 | cin.tie(0); cout.tie(0); 10 | 11 | int x, y; cin >> x >> y; 12 | cout << min(x, y) << '\n'; 13 | } 14 | -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/ACPC 21 Girls (BCN Unsolved)/Girls ACPC (With Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/ACPC 21 Girls (BCN Unsolved)/Girls ACPC (With Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/ACPC 21 Girls (BCN Unsolved)/Phantom of the Opera.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | freopen("phantom.in", "r", stdin); 7 | ios::sync_with_stdio(0); 8 | cin.tie(0); cout.tie(0); 9 | 10 | int t; cin >> t; while (t--) { 11 | int n, m; cin >> n >> m; 12 | cout << max(0, n - m) << '\n'; 13 | } 14 | 15 | cin.ignore(2); return 0; 16 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/ACPC 21 Girls (BCN Unsolved)/XOR K.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | freopen("xor.in", "r", stdin); 6 | ios::sync_with_stdio(0); 7 | cin.tie(0); cout.tie(0); 8 | 9 | int n, res = 0; cin >> n; while (n--) { 10 | int x; cin >> x; res |= x; 11 | } 12 | cout << res << '\n'; 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/ACPC 21 KickOff (D Unsolved)/2wix+.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | freopen("two2.in", "r", stdin); 6 | ios::sync_with_stdio(0); 7 | cin.tie(0); cout.tie(0); 8 | 9 | int t; cin >> t; while (t--) { 10 | int n; cin >> n; 11 | cout << (n & 1 ? -1 : n >> 1) << '\n'; 12 | } 13 | 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/ACPC 21 KickOff (D Unsolved)/ACPC 21 KickOff (Without Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/ACPC 21 KickOff (D Unsolved)/ACPC 21 KickOff (Without Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/ACPC 22 KickOff (EJL Unsolved)/ACPC 22 KickOff (Without Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/ACPC 22 KickOff (EJL Unsolved)/ACPC 22 KickOff (Without Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/ACPC 22 KickOff (EJL Unsolved)/Moving Balls.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | freopen("collisions.in", "r", stdin); 7 | ios::sync_with_stdio(0); 8 | cin.tie(0); cout.tie(0); 9 | 10 | int t; cin >> t; while (t--) { 11 | ll n, m; cin >> n >> m; 12 | cout << n * m << '\n'; 13 | } 14 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/ACPC 22 KickOff (EJL Unsolved)/Pizza Time.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | freopen("pizza.in", "r", stdin); 6 | ios::sync_with_stdio(0); 7 | cin.tie(0); cout.tie(0); 8 | 9 | int t; cin >> t; while (t--) { 10 | int n, a; cin >> n >> a; 11 | cout << n - a << '\n'; 12 | } 13 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/ACPC 22 KickOff (EJL Unsolved)/Ziko the Rabbit.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | freopen("ziko.in", "r", stdin); 6 | ios::sync_with_stdio(0); 7 | cin.tie(0); cout.tie(0); 8 | 9 | int t; cin >> t; while (t--) { 10 | int n; cin >> n; 11 | cout << (n << 1) - 1 << '\n'; 12 | } 13 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/BAPC 13 (BEH Unsolved)/BAPC 13 (With Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/BAPC 13 (BEH Unsolved)/BAPC 13 (With Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/BAPC 13 (BEH Unsolved)/Flying Safely.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int n, m; cin >> n >> m; 8 | while (m--) { int a, b; cin >> a >> b; } 9 | cout << n - 1 << endl; 10 | } 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/BAPC 14 (DFHK Unsolved)/BAPC 14 (With Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/BAPC 14 (DFHK Unsolved)/BAPC 14 (With Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/BAPC 16 (ADFGK Unsolved)/BAPC 16 (With Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/BAPC 16 (ADFGK Unsolved)/BAPC 16 (With Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/BAPC 17 (BGHJ Unsolved)/BAPC 17 (With Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/BAPC 17 (BGHJ Unsolved)/BAPC 17 (With Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/BAPC 17 (BGHJ Unsolved)/Irrational Division.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int p, q; cin >> p >> q; 6 | if (p % 2 == 0) { cout << 0 << endl; } 7 | else if (q % 2) { cout << 1 << endl; } 8 | else if (p < q) { cout << 2 << endl; } 9 | else { cout << 0 << endl; } 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/BAPC 18 (EHI Unsolved)/BAPC 18 (With Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/BAPC 18 (EHI Unsolved)/BAPC 18 (With Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/BAPC 18 (EHI Unsolved)/Game Night.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int dp[100001][3][3][3]; 6 | int n; string s; 7 | 8 | int min_dif(int i, int first, int cur, int past) { 9 | if (dp[i][first][cur][past] != -1) { return dp[i][first][cur][past]; } 10 | if (i == n) { return 0; } 11 | if(cur != first) 12 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/ECPC 18 (GIJK Unsolved)/ECPC 18 (Without Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/ECPC 18 (GIJK Unsolved)/ECPC 18 (Without Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/GCPC 17 (ABFHJ Unsolved)/GCPC 17 (With Edirorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/GCPC 17 (ABFHJ Unsolved)/GCPC 17 (With Edirorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/GCPC 18 (KL Unsolved)/GCPC 18 (With Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/GCPC 18 (KL Unsolved)/GCPC 18 (With Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/LCPC 16 (BD Unsolved)/Elements.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); cout.tie(0); 7 | 8 | int t; cin >> t; while (t--) { 9 | int n; cin >> n; 10 | cout << (n == 4 ? "yes" : "no") << '\n'; 11 | } 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/LCPC 17 (DF Unsolved)/Isco's House.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | freopen("isco.in", "r", stdin); 6 | ios::sync_with_stdio(0); 7 | cin.tie(0); cout.tie(0); 8 | 9 | int T; cin >> T; while (T--) { 10 | int X, Y, P, Z; cin >> X >> Y >> P >> Z; 11 | cout << (X * Y - Z) * P << '\n'; 12 | } 13 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/LCPC 18 (K Unsolved)/Gifts Unjust Division.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | freopen("gift.in", "r", stdin); 6 | ios::sync_with_stdio(0); 7 | cin.tie(0); cout.tie(0); 8 | 9 | int t; cin >> t; while (t--) { 10 | int n; cin >> n; 11 | cout << n / 8 << ' ' << 7 * n / 8 << '\n'; 12 | } 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/LCPC 19 (EJ Unsolved)/Digit Count.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | freopen("dahab.in", "r", stdin); 7 | int n; cin >> n; 8 | cout << to_string(n).size() << '\n'; 9 | cin.ignore(2); return 0; 10 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/LCPC 19 (EJ Unsolved)/Expected Sum.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | typedef long long ll; 5 | 6 | int main() { 7 | freopen("sum.in", "r", stdin); 8 | ios::sync_with_stdio(0); 9 | cin.tie(0); cout.tie(0); 10 | 11 | int t; cin >> t; while (t--) { 12 | ll n; cin >> n; 13 | ll res = (n + n * n * n) >> 1; 14 | 15 | cout << res << '\n'; 16 | } 17 | cin.ignore(2); return 0; 18 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/LCPC 19 (EJ Unsolved)/LCPC 19 (Without Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/LCPC 19 (EJ Unsolved)/LCPC 19 (Without Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/LCPC 19 (EJ Unsolved)/Salah and Encryption.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | freopen("string.in", "r", stdin); 6 | ios::sync_with_stdio(0); 7 | cin.tie(0); cout.tie(0); 8 | 9 | int k; char c; cin >> k >> c; 10 | int e = (c - 'a' + k) % 26; 11 | cout << (char)(e + 'a') << '\n'; 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/LCPC 20/LCPC 20 (Without Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/LCPC 20/LCPC 20 (Without Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/LCPC 20/Minimum X.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | freopen("min.in", "r", stdin); 6 | ios::sync_with_stdio(0); 7 | cin.tie(0); cout.tie(0); 8 | 9 | int t; cin >> t; while (t--) { 10 | int a; cin >> a; int x = 0; 11 | for (int i = 30; i >= 0; i--) { 12 | if ((1 << i) >= a) { continue; } 13 | if ((1 << i) & a) { continue; } 14 | x |= (1 << i); 15 | } 16 | cout << x << '\n'; 17 | } 18 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/LCPC 20/Stock Market.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | ios::sync_with_stdio(0); 7 | cin.tie(0), cout.tie(0); 8 | freopen("stock.in", "r", stdin); 9 | 10 | int t; cin >> t; 11 | while (t--) { 12 | int x, y; cin >> x >> y; 13 | cout << y - x << '\n'; 14 | } 15 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/LCPC 21/Kofta Never Lose.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | freopen("kofta.in", "r", stdin); 6 | ios::sync_with_stdio(0); 7 | cin.tie(0); cout.tie(0); 8 | 9 | int n; cin >> n; cout << "1\n"; 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/LCPC 21/LCPC 2021 (Without Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/LCPC 21/LCPC 2021 (Without Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/MCPC 19 (D Unsolved)/MCPC 19 (Without Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/MCPC 19 (D Unsolved)/MCPC 19 (Without Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/MCPC 19 (D Unsolved)/SpongeBob SquarePants.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int t; cin >> t; 7 | for (int i = 0; i < t; i++) { 8 | int a, b; cin >> a >> b; 9 | if (a == b) { cout << "YES" << endl; } 10 | else { cout << "NO" << endl; } 11 | } 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/NCPC 15 (HIJ Unsolved)/Cryptographer's Conundrum.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string s; cin >> s; int res = 0; 7 | for (int i = 0; i < (int)s.size(); i++) 8 | res += (s[i] != 'P') + (s[++i] != 'E') + (s[++i] != 'R'); 9 | cout << res << '\n'; cin.ignore(2); return 0; 10 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/NCPC 15 (HIJ Unsolved)/NCPC 15 (With Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/NCPC 15 (HIJ Unsolved)/NCPC 15 (With Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/NCPC 16 (FHIK Unsolved)/NCPC 16 (With Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/NCPC 16 (FHIK Unsolved)/NCPC 16 (With Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/NCPC 17 (ACEFH Unsolved)/Judging Moose.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int n, m; cin >> n >> m; 7 | if (!n && !m) { cout << "Not a moose"; } 8 | else if (n == m) { cout << "Even " << 2 * n; } 9 | else { cout << "Odd " << 2 * max(n, m); } 10 | cout << endl; cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/NCPC 17 (ACEFH Unsolved)/NCPC 17 (With Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/NCPC 17 (ACEFH Unsolved)/NCPC 17 (With Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/NCPC 18 (ADEFGK Unsolved)/NCPC 18 (With Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/NCPC 18 (ADEFGK Unsolved)/NCPC 18 (With Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/NWERC 18 (ADFHJ Unsolved)/NWERC 18 (With Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/NWERC 18 (ADFHJ Unsolved)/NWERC 18 (With Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/PNPC 18 (IM Unsolved)/PNPC 18 (With Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/PNPC 18 (IM Unsolved)/PNPC 18 (With Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/PNPC 18 (IM Unsolved)/Time Limits.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int n, s; cin >> n >> s; 7 | int maxTime = 0; 8 | for (int i = 0; i < n; i++) { 9 | int t; cin >> t; 10 | maxTime = max(maxTime, t); 11 | } 12 | maxTime *= s; maxTime = (maxTime + 999) / 1000; 13 | cout << maxTime << endl; 14 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/SCPC 18 (CEFJL Unsolved)/SCPC 18 (Without Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/SCPC 18 (CEFJL Unsolved)/SCPC 18 (Without Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/SEERC 17 (BCDEHIJL Unsolved)/SEERC 17 (Without Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/SEERC 17 (BCDEHIJL Unsolved)/SEERC 17 (Without Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/SEERC 19 (ACDFHJK Unsolved)/SEERC 19 (With Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/SEERC 19 (ACDFHJK Unsolved)/SEERC 19 (With Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/SWERC 13 (ABDEHJ Unsolved)/SWERC 13 (Without Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/SWERC 13 (ABDEHJ Unsolved)/SWERC 13 (Without Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/SWERC 16 (BDEGHIJ Unsolved)/Candle Box.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int d, r, t; cin >> d >> r >> t; 6 | int s = r + t, res = 0; 7 | for (int n = d; n < 100; n++) { 8 | int R = ((7 + n) * n) / 2; 9 | int T = ((6 + n - d) * (n - d + 1)) / 2; 10 | if (r - R < 0 || r - R != T - t) { continue; } 11 | res = T - t; break; 12 | } 13 | cout << res << '\n'; 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/SWERC 16 (BDEGHIJ Unsolved)/SWERC 16 (With Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/SWERC 16 (BDEGHIJ Unsolved)/SWERC 16 (With Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/SWERC 17 (BCDGHI Unsolved)/SWERC 17 (With Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/SWERC 17 (BCDGHI Unsolved)/SWERC 17 (With Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/SWERC 17 (BCDGHI Unsolved)/Shattered Cake.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); cout.tie(0); 7 | 8 | int w, n; cin >> w >> n; int res = 0; 9 | for (int i = 0; i < n; i++) { 10 | int a, b; cin >> a >> b; res += a * b; 11 | } 12 | cout << res / w << '\n'; 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/TCPC 17 (BEIL Unsolved)/Shahhoud Training Hussein.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int T; cin >> T; 6 | for (int z = 0; z < T; z++) { 7 | long long K, P, N; cin >> K >> P >> N; 8 | if (P >= K) { cout << 0 << endl; } 9 | else { cout << (K - P)*N << endl; } 10 | } 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/TCPC 17 (BEIL Unsolved)/TCPC 17 (Without Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/TCPC 17 (BEIL Unsolved)/TCPC 17 (Without Editorial).pdf -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/TCPC 18 (DGJ Unsolved)/Can Shahhoud Solve it.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int s, d; cin >> s >> d; 8 | cout << ((s >= d) ? "YES" : "NO") << endl; 9 | } 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/TCPC 18 (DGJ Unsolved)/Nim Cheater.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int m; cin >> m; int xs = 0; 8 | for (int i = 0; i < m; i++) { 9 | int a; cin >> a; xs ^= a; 10 | } 11 | cout << (xs == 0) << endl; 12 | } 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/TCPC 18 (DGJ Unsolved)/Odd & Even Count.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int n; cin >> n; 8 | cout << n - n / 2 << ' ' << n / 2 << endl; 9 | } 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Official ACM-ICPC Contests/TCPC 18 (DGJ Unsolved)/TCPC 18 (Without Editorial).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Official ACM-ICPC Contests/TCPC 18 (DGJ Unsolved)/TCPC 18 (Without Editorial).pdf -------------------------------------------------------------------------------- /Pre-Written Code/String Algorithms/Suffix Array.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Pre-Written Code/String Algorithms/Suffix Array.cpp -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0072 - Range Deleting.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | vector seq, freq; 6 | int n, x; 7 | 8 | long long pair_count() { 9 | for (int i = 0; i < n; i++) { freq[seq[i]]++; } 10 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0082 - A Pile of Stones.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int n; cin >> n; 7 | stack st; 8 | for (int i = 0; i < n; i++) { 9 | char c; cin >> c; 10 | if (c == '-' && st.empty()) { continue; } 11 | if (c == '-') { st.pop(); continue; } 12 | st.push(c); 13 | } 14 | cout << st.size() << endl; 15 | cin.ignore(2); return 0; 16 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0089 - Wrong Subtraction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int subtract(int n, int k) { 5 | for (int i = 0; i < k; i++) { 6 | if (n % 10 == 0) { n /= 10; continue; } 7 | n--; 8 | } 9 | return n; 10 | } 11 | 12 | int main() { 13 | int n, k; cin >> n >> k; 14 | cout << subtract(n, k) << endl; 15 | cin.ignore(2); return 0; 16 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0107 - From Hero to Zero.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | for (int i = 0; i < t; i++) { 7 | long long n, k; cin >> n >> k; 8 | long long count = 0; 9 | while (n != 0) { 10 | long long a = n % k; 11 | if (a != 0) { n -= a; count += a; } 12 | else { n /= k; count++; } 13 | } 14 | cout << count << endl; 15 | } 16 | cin.ignore(2); return 0; 17 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0112 - Nauuo & Votes.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int x, y, z; cin >> x >> y >> z; 6 | int diff = abs(x - y); 7 | if (diff < z || (z != 0 && diff == z)) { cout << '?' << endl; } 8 | else if (x > y) { cout << '+' << endl; } 9 | else if (y > x) { cout << '-' << endl; } 10 | else { cout << '0' << endl; } 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0113 - Nauuo & Chess.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | void find_min(int k) { 5 | int m = (k / 2) + 1; 6 | cout << m << endl; 7 | for (int i = 1; i <= m; i++) { 8 | cout << 1 << " " << i << endl; k--; 9 | } 10 | for (int i = 2; k != 0; i++) { 11 | cout << m << " " << i << endl; k--; 12 | } 13 | } 14 | 15 | int main() { 16 | int k; cin >> k; 17 | find_min(k); 18 | cin.ignore(2); return 0; 19 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0115 - Watermelon.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n; cin >> n; 6 | if (n % 2 == 1) { cout << "NO" << endl; } 7 | else if (n == 2) { cout << "NO" << endl; } 8 | else { cout << "YES" << endl; } 9 | cin.ignore(2); return 0; 10 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0116 - Theater Square.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n, m, a; cin >> n >> m >> a; 6 | long long v = (n + a - 1) / a; 7 | long long h = (m + a - 1) / a; 8 | cout << v * h << endl; 9 | cin.ignore(2); return 0; 10 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0117 - Domino Piling.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int m, n; cin >> m >> n; 6 | int count = 0; 7 | if (m % 2 == 0 || n % 2 == 0) { count = n * m / 2; } 8 | else if(m == 1 && n == 1){} 9 | else { 10 | int x = (m == 1) ? n : m; 11 | int y = (m == 1) ? m : n; 12 | count = (x - 1)*y / 2; 13 | count += y / 2; 14 | } 15 | cout << count << endl; 16 | cin.ignore(2); return 0; 17 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0118 - Bit++.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int n; cin >> n; 7 | int x = 0; 8 | for (int i = 0; i < n; i++) { 9 | string s; cin >> s; 10 | if (s == "X++" || s == "++X") { x++; } 11 | else { x--; } 12 | } 13 | cout << x << endl; 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0120 - Watchmen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | typedef long long ll; 6 | map X, Y; 7 | map, ll> P; 8 | 9 | int main() { 10 | int n; cin >> n; ll res = 0; 11 | for (int i = 0; i < n; i++) { 12 | int x, y; cin >> x >> y; 13 | res += X[x] + Y[y] - P[{x, y}]; 14 | X[x]++; Y[y]++; P[{x, y}]++; 15 | } 16 | cout << res << endl; cin.ignore(2); return 0; 17 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0131 - Filling Shapes.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n; cin >> n; 6 | if (n % 2 == 1) { cout << 0 << endl; } 7 | else { cout << (int)floor(pow(2.0, (n + 0.0) / 2.0)) << endl; } 8 | cin.ignore(2); return 0; 9 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0139 - Nearest Interesting Number.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int sum_dig(int n) { 5 | int sum = 0; 6 | while (n != 0) { 7 | sum += n % 10; n /= 10; 8 | } 9 | return sum; 10 | } 11 | 12 | int main() { 13 | int a; cin >> a; 14 | while (true) { 15 | int s = sum_dig(a); 16 | if (s % 4 == 0) { cout << a << endl; break; } 17 | a++; 18 | } 19 | cin.ignore(2); return 0; 20 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0145 - Vus the Cossack & a Contest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n, m, k; cin >> n >> m >> k; 6 | int min = (m < k) ? m : k; 7 | if (min < n) { cout << "No" << endl; } 8 | else { cout << "Yes" << endl; } 9 | cin.ignore(2); return 0; 10 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0160 - Remove a Progression.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | for (int i = 0; i < t; i++) { 7 | int n, x; cin >> n >> x; 8 | cout << 2 * x << endl; 9 | } 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0176 - Parity.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int b, k; cin >> b >> k; 6 | int o = 0; int a; 7 | for (int i = 0; i < k; i++) { 8 | cin >> a; if (a % 2) { o++; } 9 | } 10 | bool bo = false; 11 | if (b % 2) { bo = o % 2; } 12 | else { bo = a % 2; } 13 | if (!bo) { cout << "Even" << endl; } 14 | else { cout << "Odd" << endl; } 15 | cin.ignore(2); return 0; 16 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0185 - Tiles.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | const long long mod = 998244353ll; 5 | 6 | int main() { 7 | int w, h; cin >> w >> h; 8 | int a = 1, i = 0; 9 | while (i != w + h) { a = (2 * a) % mod; i++; } 10 | cout << a << endl; 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0189 - Another One Bites the Dust.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | long long a, b, c; cin >> a >> b >> c; 6 | long long len = 2 * c; 7 | long long min = (a < b) ? a : b; 8 | a -= min; b -= min; 9 | len += 2 * min; 10 | if (a != 0 || b != 0) { len++; } 11 | cout << len << endl; 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0197 - Three Piles of Candies.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | long long a, b, c; 5 | 6 | int main() { 7 | int q; cin >> q; 8 | for (int i = 0; i < q; i++) { 9 | cin >> a >> b >> c; 10 | cout << (a + b + c) / 2 << endl; 11 | } 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0211 - Mishka & Contest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int n, k; cin >> n >> k; 7 | int res = 0; 8 | vector v; 9 | for (int i = 0; i < n; i++) { 10 | int a; cin >> a; 11 | if (a > k) { v.push_back(i); } 12 | } 13 | if (v.empty()) { cout << n << endl; } 14 | else { cout << v.front() + n - v.back() - 1 << endl; } 15 | cin.ignore(2); return 0; 16 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0212 - Reversing Encryption.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | string s; 7 | 8 | int main() { 9 | int n; cin >> n >> s; 10 | for (int i = 2; i <= n / 2; i++) { 11 | if (n % i == 0) { 12 | reverse(s.begin(), s.begin() + i); 13 | } 14 | } 15 | reverse(s.begin(), s.end()); 16 | cout << s << endl; 17 | cin.ignore(2); return 0; 18 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0222 - Water Lily.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | long long h, l; cin >> h >> l; 7 | long long a = l * l - h * h; 8 | long double res = (a + 0.0) / (2 * h + 0.0); 9 | cout << fixed << setprecision(10) << res << endl; 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0245 - Life, The Universe & Everything.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | while (true) { 6 | int a; cin >> a; 7 | if (a == 42) { break; } 8 | cout << a << endl; 9 | } 10 | return 0; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0251 - Minimum Triangulization.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n; cin >> n; 6 | int res = 0, i = 2; 7 | while (i < n) { res += i * (i + 1); i++; } 8 | cout << res << endl; 9 | cin.ignore(2); return 0; 10 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0271 - SpongeBob SquarePants.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int t; cin >> t; 7 | for (int i = 0; i < t; i++) { 8 | int a, b; cin >> a >> b; 9 | if (a == b) { cout << "YES" << endl; } 10 | else { cout << "NO" << endl; } 11 | } 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0281 - The Doors.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int n; cin >> n; 7 | int last0 = -1, last1 = -1; 8 | for (int i = 0; i < n; i++) { 9 | int a; cin >> a; 10 | if (a == 0) { last0 = i; } 11 | else { last1 = i; } 12 | } 13 | cout << min(last0, last1) + 1 << endl; 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0297 - Mislove Has Lost an Array.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n, l, r; cin >> n >> l >> r; 6 | int min = n - l + (1 << l) - 1; 7 | int max = (1 << r) - 1 + (n - r)*(1 << (r - 1)); 8 | cout << min << ' ' << max << endl; 9 | cin.ignore(2); return 0; 10 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0308 - Guess The Number.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int l = 0, r = 1000000; 7 | while (l != r) { 8 | int mid = (l + r + 1) >> 1; 9 | cout << mid << endl; fflush(stdout); 10 | string s; cin >> s; 11 | if (s == "<") { r = mid - 1; continue; } 12 | else { l = mid; } 13 | } 14 | cout << "! " << l << endl; fflush(stdout); 15 | cin.ignore(2); return 0; 16 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0314 - USB Flash Drives.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | priority_queue pq; 6 | 7 | int main() { 8 | int n, m; cin >> n >> m; 9 | for (int i = 0; i < n; i++) { 10 | int a; cin >> a; pq.push(a); 11 | } 12 | int res = 0; 13 | while (m > 0) { res++; m -= pq.top(); pq.pop(); } 14 | cout << res << endl; 15 | cin.ignore(2); return 0; 16 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0315 - The Best Gift.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | vector freq; 6 | 7 | int main() { 8 | int n, m; cin >> n >> m; freq.resize(m + 1, 0); 9 | for (int i = 0; i < n; i++) { int a; cin >> a; freq[a]++; } 10 | long long res = (long long) n * (n - 1) / 2; 11 | for (auto &x : freq) { res -= x * (x - 1) / 2; } 12 | cout << res << endl; 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0319 - XORinacci.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | for (int i = 0; i < t; i++) { 7 | int a, b, n; cin >> a >> b >> n; 8 | n %= 3; int x = a ^ b; 9 | if (n == 0) { cout << a << endl; } 10 | else if (n == 1) { cout << b << endl; } 11 | else { cout << x << endl; } 12 | } 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0326 - Game Night.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int dp[100001][3][3][3]; 6 | int n; string s; 7 | 8 | int min_dif(int i, int first, int cur, int past) { 9 | if (dp[i][first][cur][past] != -1) { return dp[i][first][cur][past]; } 10 | if (i == n) { return 0; } 11 | if(cur != first) 12 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0329 - Design Tutorial, Learn From Math.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n; cin >> n; 6 | if (n % 2) { cout << 9 << ' ' << n - 9 << endl; } 7 | else { cout << 8 << ' ' << n - 8 << endl; } 8 | cin.ignore(2); return 0; 9 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0330 - Chips Moving.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int n; cin >> n; 7 | int e = 0, o = 0; 8 | for (int i = 0; i < n; i++) { 9 | int a; cin >> a; 10 | if (a % 2) { o++; } 11 | else { e++; } 12 | } 13 | cout << min(e, o) << endl; 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0338 - Irrational Division.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int p, q; cin >> p >> q; 6 | if (p % 2 == 0) { cout << 0 << endl; } 7 | else if (q % 2) { cout << 1 << endl; } 8 | else if (p < q) { cout << 2 << endl; } 9 | else { cout << 0 << endl; } 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0353 - Vasya the Hipster.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int a, b; cin >> a >> b; 6 | int &mi = (a < b) ? a : b; 7 | int &ma = (a < b) ? b : a; 8 | cout << mi << ' ' << (ma - mi) / 2 << endl; 9 | cin.ignore(2); return 0; 10 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0358 - Tokitsukaze & Enhancement.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int x; cin >> x; x %= 4; 6 | if (x == 0) { cout << 1 << " A" << endl; } 7 | else if (x == 1) { cout << 0 << " A" << endl; } 8 | else if (x == 2) { cout << 1 << " B" << endl; } 9 | else { cout << 2 << " A" << endl; } 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0378 - Judging a Moose.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int n, m; cin >> n >> m; 7 | if (!n && !m) { cout << "Not a moose"; } 8 | else if (n == m) { cout << "Even " << 2 * n; } 9 | else { cout << "Odd " << 2 * max(n, m); } 10 | cout << endl; cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0382 - Substring Game in the Lesson.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | string s; 6 | 7 | int main() { 8 | cin >> s; int n = (int)s.size(); 9 | int min = s[0]; cout << "Mike" << endl; 10 | for (int i = 1; i < n; i++) { 11 | if (s[i] <= min) { cout << "Mike" << endl; min = s[i]; } 12 | else { cout << "Ann" << endl; } 13 | } 14 | cin.ignore(2); return 0; 15 | } 16 | -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0385 - Knights.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | char c[2] = { 'B', 'W' }; 5 | 6 | int main() { 7 | int n; cin >> n; 8 | bool b = true; 9 | for (int i = 0; i < n; i++) { 10 | bool ch = b; 11 | for (int j = 0; j < n; j++) { cout << c[ch]; ch = !ch; } 12 | cout << endl; b = !b; 13 | } 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0386 - Perfect Team.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int q; cin >> q; 7 | while (q--) { 8 | int c, m, x; cin >> c >> m >> x; 9 | int dif = abs(c - m); x += dif; 10 | m = c = min(m, c); 11 | if (x > m) { cout << m << endl; } 12 | else { cout << x + (m + c - 2 * x) / 3 << endl; } 13 | } 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0402 - Shahhoud Training Hussein.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int T; cin >> T; 6 | for (int z = 0; z < T; z++) { 7 | long long K, P, N; cin >> K >> P >> N; 8 | if (P >= K) { cout << 0 << endl; } 9 | else { cout << (K - P)*N << endl; } 10 | } 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0410 - Time Limits.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int n, s; cin >> n >> s; 7 | int maxTime = 0; 8 | for (int i = 0; i < n; i++) { 9 | int t; cin >> t; 10 | maxTime = max(maxTime, t); 11 | } 12 | maxTime *= s; maxTime = (maxTime + 999) / 1000; 13 | cout << maxTime << endl; 14 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0414 - Equalize Prices Again.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int n; cin >> n; 8 | int avg = 0; 9 | for (int i = 0; i < n; i++) { 10 | int a; cin >> a; avg += a; 11 | } 12 | cout << (avg + n - 1) / n << endl; 13 | } 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0419 - Can Shahhoud Solve it.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int s, d; cin >> s >> d; 8 | cout << ((s >= d) ? "YES" : "NO") << endl; 9 | } 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0423 - Nim Cheater.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int m; cin >> m; int xs = 0; 8 | for (int i = 0; i < m; i++) { 9 | int a; cin >> a; xs ^= a; 10 | } 11 | cout << (xs == 0) << endl; 12 | } 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0426 - Odd & Even Count.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int n; cin >> n; 8 | cout << n - n / 2 << ' ' << n / 2 << endl; 9 | } 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0433 - Xtreme Rappers.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | long long a, b; cin >> a >> b; 6 | if (a > 2 * b) { cout << b << endl; } 7 | else if (b > 2 * a) { cout << a << endl; } 8 | else { cout << (a + b) / 3 << endl; } 9 | cin.ignore(2); return 0; 10 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0441 - CME.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int n; cin >> n; 8 | if (n < 4) { cout << 4 - n << endl; } 9 | else { cout << n % 2 << endl; } 10 | } 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0449 - Prime Subtraction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | long long x, y; cin >> x >> y; 8 | cout << (((x - y) > 1) ? "YES" : "NO") << endl; 9 | } 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0457 - Pens & Pencils.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main(){ 5 | int t; cin >> t; 6 | while (t--) { 7 | int a, b, c, d, k; cin >> a >> b >> c >> d >> k; 8 | int x = (a + c - 1) / c, y = (b + d - 1) / d; 9 | if (x + y <= k) { cout << x << ' ' << y << endl; } 10 | else { cout << -1 << endl; } 11 | } 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0460 - Good Ol' Number Coloring.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } 5 | 6 | int main() { 7 | int t; cin >> t; 8 | while (t--) { 9 | int a, b; cin >> a >> b; int g = gcd(a, b); 10 | cout << (g == 1 ? "Finite" : "Infinite") << endl; 11 | } 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0472 - Two Rival Students.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int n, x, a, b; cin >> n >> x >> a >> b; 8 | if (a > b) { swap(a, b); } 9 | if (a - 1 <= x) { x -= a - 1; a = 1; } 10 | else { a -= x; x = 0; } 11 | if (n - b <= x) { x -= n - b; b = n; } 12 | else { b += x; x = 0; } 13 | cout << b - a << endl; 14 | } 15 | cin.ignore(2); return 0; 16 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0484 - Kids Love Candies.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n, k; cin >> n >> k; 6 | int res = 0; 7 | for (int i = 0; i < n; i++) { 8 | int t; cin >> t; res += t / k; 9 | } 10 | cout << res << endl; 11 | cin.ignore(2); return 0; 12 | } 13 | -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0502 - Professor GukiZ's Robot.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int x1, y1; cin >> x1 >> y1; 7 | int x2, y2; cin >> x2 >> y2; 8 | 9 | int dx = abs(x1 - x2); 10 | int dy = abs(y1 - y2); 11 | 12 | cout << max(dx, dy) << endl; 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0522 - Temporarily Unavailable.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int t; cin >> t; 7 | while (t--) { 8 | int a, b, c, r; cin >> a >> b >> c >> r; 9 | if (b < a) { swap(a, b); } 10 | int ri = min(b, c + r), le = max(a, c - r); 11 | if (le > ri) { le = ri; } 12 | cout << b - a - (ri - le) << endl; 13 | } 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0532 - Make Good.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | vector v; 6 | 7 | int main() { 8 | int t; cin >> t; 9 | while (t--) { 10 | int n; cin >> n; v.resize(n); 11 | long long s = 0, xs = 0; 12 | for (auto &x : v) { cin >> x; s += x; xs ^= x; } 13 | cout << 2 << endl << xs << ' ' << s + xs << endl; 14 | } 15 | cin.ignore(2); return 0; 16 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0534 - Minutes Before The New Year.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | const int u = 24 * 60; 5 | 6 | int main() { 7 | int t; cin >> t; 8 | while (t--) { 9 | int h, m; cin >> h >> m; 10 | cout << u - 60 * h - m << endl; 11 | } 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0535 - Candies Division.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int t; cin >> t; 7 | while (t--) { 8 | int n, k; cin >> n >> k; 9 | int m = (n / k) * k + k / 2; 10 | cout << min(n, m) << endl; 11 | } 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0540 - Stones.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int t; cin >> t; 7 | while (t--) { 8 | int a, b, c; cin >> a >> b >> c; 9 | int f = min(b, c / 2); 10 | b -= f; c -= 2 * f; 11 | int s = min(a, b / 2); 12 | cout << 3*(f + s) << endl; 13 | } 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0541 - Find Divisible.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int l, r; cin >> l >> r; 8 | cout << l << ' ' << 2 * l << endl; 9 | } 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0542 - Dice Tower.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | long long x; cin >> x; 8 | if (x < 15) { cout << "NO" << endl; continue; } 9 | if (x % 14 == 0) { cout << "NO" << endl; continue; } 10 | if (x % 14 < 7) { cout << "YES" << endl; continue; } 11 | cout << "NO" << endl; 12 | } 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0543 - Mezo Playing Zoma.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n; cin >> n; 6 | int l = 0, r = 0; 7 | for (int i = 0; i < n; i++) { 8 | char c; cin >> c; 9 | (c == 'L' ? l : r)++; 10 | } 11 | cout << l + r + 1 << endl; 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0547 - Love 'A'.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | int main() { 7 | string s; cin >> s; 8 | int a = 0; 9 | for (char &c : s) 10 | a += (c == 'a'); 11 | cout << min((int)s.size(), 2 * a - 1) << endl; 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0550 - Yet Another Meme Problem.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | typedef long long ll; 6 | 7 | int main() { 8 | int t; cin >> t; 9 | while (t--) { 10 | ll A, B; cin >> A >> B; 11 | ll res = 0, t = 9; 12 | while (t <= B) { res += A; t = 10 * t + 9; } 13 | cout << res << endl; 14 | } 15 | cin.ignore(2); return 0; 16 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0566 - Joe is on TV.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n; cin >> n; 6 | double res = 0.0; 7 | while (n != 0) { 8 | res += (1.0 / (double)n); 9 | n--; 10 | } 11 | cout << res << endl; 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0573 - Display The Number.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int t; cin >> t; 7 | while (t--) { 8 | int n; cin >> n; 9 | string s(n / 2, '1'); 10 | if (n % 2) { s[0] = '7'; } 11 | cout << s << endl; 12 | } 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0600 - Even Odds.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | long long n, k; cin >> n >> k; 6 | if (k <= (n + 1) / 2) { cout << ((k << 1) - 1) << endl; } 7 | else { k -= (n + 1) / 2; cout << 2 * k << endl; } 8 | cin.ignore(2); return 0; 9 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0601 - Cheap Travel.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int n, m, a, b; cin >> n >> m >> a >> b; 7 | if (b > m*a) { cout << n * a << endl; } 8 | else { cout << b * (n / m) + min(b, a * (n % m)) << endl; } 9 | cin.ignore(2); return 0; 10 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0602 - Dreamoon and Stairs.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n, m; cin >> n >> m; 6 | int i = (n / 2) + n % 2; 7 | while (i <= n && i % m) { i++; } 8 | cout << (i > n ? -1 : i) << endl; 9 | cin.ignore(2); return 0; 10 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0606 - Tram.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | 7 | vector v; 8 | 9 | int main() { 10 | int n; cin >> n; v.resize(n); 11 | for (auto &x : v) { 12 | int a, b; cin >> a >> b; 13 | x = b - a; 14 | } 15 | partial_sum(v.begin(), v.end(), v.begin()); 16 | cout << *max_element(v.begin(), v.end()) << endl; 17 | cin.ignore(2); return 0; 18 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0609 - Initial Bet.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int sum = 0; int x = 5; 6 | while (x--) { int a; cin >> a; sum += a; } 7 | cout << (sum % 5 || !sum ? -1 : sum / 5) << endl; 8 | cin.ignore(2); return 0; 9 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0610 - Magnets.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int n; cin >> n; 7 | string prev = "00"; int res = 0; 8 | while (n--) { 9 | string a; cin >> a; 10 | if (a == prev) { continue; } 11 | prev = a; res++; 12 | } 13 | cout << res << endl; 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0611 - Mashmokh and Lights.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | vector res; 6 | 7 | int main() { 8 | int n, m; cin >> n >> m; 9 | res.resize(n); int on = n; 10 | for (int i = 0; i < m; i++) { 11 | int b; cin >> b; if (b > on) { continue; } 12 | while (on >= b) { res[on - 1] = b; on--; } 13 | } 14 | for (auto &x : res) { cout << x << ' '; } 15 | cout << endl; cin.ignore(2); return 0; 16 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0613 - Olesya and Rodion.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | string findNum(int n, int t) { 6 | if (n == 1 && t == 10) { return "-1"; } 7 | if (t == 10) { string s(n, '1'); s[n - 1] = '0'; return s; } 8 | return string(n, t + '0'); 9 | } 10 | 11 | int main() { 12 | int n, t; cin >> n >> t; 13 | cout << findNum(n, t) << endl; 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0615 - Playing with Paper.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | long long a, b; cin >> a >> b; 7 | long long res = 0; if (a < b) { swap(a, b); } 8 | while (true) { 9 | if (b == 0) { break; } 10 | res += a / b; a %= b; swap(a, b); 11 | } 12 | cout << res << endl; 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0616 - Stones on the Table.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int n; cin >> n; 7 | int prev = 0, res = 0; 8 | for (int i = 0; i < n; i++) { 9 | char c; cin >> c; 10 | if (c == prev) { res++; continue; } 11 | prev = c; 12 | } 13 | cout << res << endl; 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0619 - Vitaly and Strings.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | string s, t; 6 | 7 | int main() { 8 | cin >> s >> t; 9 | int i = (int) s.size() - 1; 10 | while (s[i] == 'z') { s[i] = 'a'; i--; } 11 | s[i]++; cout << (s == t ? "No such string" : s) << endl; 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0625 - Unusual Competitions.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int n; string s; cin >> n >> s; 7 | int res = 0, i = 0, j = 0, p = 0; 8 | while (j != n) { 9 | p += (s[j] == '(') ? 1 : -1; 10 | if (p) { j++; continue; } 11 | res += (s[i] == '(') ? 0 : j - i + 1; 12 | i = j = j + 1; 13 | } 14 | cout << (p ? -1 : res) << endl; 15 | cin.ignore(2); return 0; 16 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0626 - Two Regular Polygon.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int n, m; cin >> n >> m; 8 | cout << (n % m ? "NO" : "YES") << endl; 9 | } 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0627 - Bogosort.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | vector v; 7 | 8 | int main() { 9 | int t; cin >> t; 10 | while (t--) { 11 | int n; cin >> n; v.resize(n); 12 | for (auto &x : v) { cin >> x; } 13 | sort(v.rbegin(), v.rend()); 14 | for (auto &x : v) { cout << x << ' '; } cout << endl; 15 | } 16 | cin.ignore(2); return 0; 17 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0636 - Add Odd Subtract Even.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int ans[2][2] = { {2, 1}, {1, 2} }; 5 | 6 | int main() { 7 | int t; cin >> t; 8 | while (t--) { 9 | int a, b; cin >> a >> b; 10 | if (a == b) { cout << 0 << endl; continue; } 11 | cout << ans[a > b][abs(a - b) % 2] << endl; 12 | } 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0639 - EhAb AnD gCd.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int x; cin >> x; 8 | cout << 1 << ' ' << x - 1 << endl; 9 | } 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0640 - CopyCopyCopyCopyCopy.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int t; cin >> t; 7 | while (t--) { 8 | int n; cin >> n; set s; 9 | while (n--) { int x; cin >> x; s.insert(x); } 10 | cout << s.size() << endl; 11 | } 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0648 - Bad Ugly Numbers.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int t; cin >> t; 7 | while (t--) { 8 | int n; cin >> n; 9 | if (n == 1) { cout << -1 << endl; continue; } 10 | string s(n, '3'); s[n - 1] = '4'; cout << s << endl; 11 | } 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0649 - Maximums.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | vector v; 6 | 7 | int main() { 8 | int n; cin >> n; v.resize(n); 9 | for (auto &x : v) { cin >> x; } 10 | int max = 0; 11 | for (auto &x : v) { 12 | cout << x + max << ' '; 13 | if (x + max > max) { max = x + max; } 14 | } 15 | cout << endl; cin.ignore(2); return 0; 16 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0653 - Sum of Odd Integers.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | long long n, k; cin >> n >> k; 8 | long long x = n - k * k; 9 | cout << (x >= 0 && x % 2 == 0 ? "YES" : "NO") << endl; 10 | } 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0656 - Divisibility Problem.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int a, b; cin >> a >> b; 8 | cout << (b - (a % b)) % b << endl; 9 | } 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0685 - Chewbacca and a Number.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | char inv(char &c) { return 9 - (c - '0') + '0'; } 7 | 8 | int main() { 9 | string s; cin >> s; int n = s.size(); 10 | s[0] = (s[0] == '9') ? '9' : min(s[0], inv(s[0])); 11 | for (int i = 1; i < n; i++) { s[i] = min(s[i], inv(s[i])); } 12 | cout << s << endl; cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0691 - Again About Distancing.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string s; getline(cin, s); bool b = true; 7 | int i = 0, j = 1, n = (int)s.size(); 8 | while (j != n) { 9 | if (s[j] == ' ') { j++; continue; } 10 | if (j - i + 1 < 4) { b = false; break; } 11 | i = j; j++; 12 | } 13 | cout << (b ? "safe" : "unsafe") << endl; 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0692 - Bad Multisets.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int N; cin >> N; 6 | if (N <= 2) { cout << N << endl; return 0; } 7 | long long ans = 2, prev = 2; 8 | for (int i = 2; i < N; i++) { ans += prev; prev <<= 1; } 9 | cout << ans << endl; cin.ignore(2); return 0; 10 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0706 - Simple Game.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n, m; cin >> n >> m; 6 | if (n == 1) { cout << 1 << endl; return 0; } 7 | int a = m - 1, b = m + 1; 8 | cout << (n - b + 1 > a ? b : a) << endl; 9 | cin.ignore(2); return 0; 10 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0713 - Filling Diamonds.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { int n; cin >> n; cout << n << endl; } 7 | cin.ignore(2); return 0; 8 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0720 - Candies and Two Sisters.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int n; cin >> n; 8 | cout << (n - 1) / 2 << endl; 9 | } 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0723 - Anti Sudoku.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | 7 | vector v; 8 | 9 | int main() { 10 | int t; cin >> t; v.resize(9); 11 | while (t--) { 12 | for (auto &x : v) { cin >> x; x[find(x.begin(), x.end(), '1') - x.begin()] = '2'; } 13 | for (auto &x : v) { cout << x << '\n'; } 14 | } 15 | cin.ignore(2); return 0; 16 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0728 - Ichihime and Triangle.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int a, b, c, d; cin >> a >> b >> c >> d; 8 | cout << b << ' ' << c << ' ' << c << endl; 9 | } 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0729 - Kana and Dragon Quest game.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int spell(int x) { return 10 + (x >> 1); } 5 | 6 | int main() { 7 | int t; cin >> t; 8 | while (t--) { 9 | int x, n, m; cin >> x >> n >> m; 10 | while (n && spell(x) < x) { x = spell(x); n--; } 11 | cout << ((x <= 10 * m) ? "YES" : "NO") << endl; 12 | } 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0738 - Two Rabbits.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int t; cin >> t; 7 | while (t--) { 8 | int x, y, a, b; cin >> x >> y >> a >> b; 9 | int t = (y - x) / (a + b); 10 | cout << ((y - x) % (a + b) ? -1 : t) << endl; 11 | } 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0760 - Candies.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int n; cin >> n; int k = 2; 8 | while (n % ((1 << k) - 1)) { k++; } 9 | cout << n / ((1 << k) - 1) << endl; 10 | } 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0773 - Nastya and Rice.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int n, a, b, c, d; cin >> n >> a >> b >> c >> d; 8 | if (n*(a - b) > c + d) { cout << "No" << endl; continue; } 9 | if (n*(a + b) < c - d) { cout << "No" << endl; continue; } 10 | cout << "Yes" << endl; 11 | } 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0778 - Triangulation.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int minDiameter(int n) { 5 | if (n == 3) { return 0; } 6 | if (n == 4) { return 1; } 7 | if (n == 5) { return 2; } 8 | if (n == 6) { return 2; } 9 | 10 | return 2 + +minDiameter((n + 1) >> 1); 11 | } 12 | 13 | int main() { 14 | int n; cin >> n; 15 | cout << minDiameter(n) << endl; 16 | cin.ignore(2); return 0; 17 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0779 - Road to Zero.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | typedef long long ll; 5 | 6 | int main() { 7 | int t; cin >> t; 8 | while (t--) { 9 | ll x, y; cin >> x >> y; 10 | ll a, b; cin >> a >> b; 11 | if (2 * a <= b) { cout << a * (x + y) << endl; continue; } 12 | cout << b * min(x, y) + a * (max(x, y) - min(x, y)) << endl; 13 | } 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0783 - Phoenix and Balance.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int n; cin >> n; 8 | int a = 0, b = 0, i = 1; 9 | for (int j = 0; j < (n - 1) / 2; j++) { a |= i; i <<= 1; } 10 | for (int j = 0; j < n / 2; j++) { b |= i; i <<= 1; } 11 | cout << 2*(a | i) - 2*b << endl; 12 | } 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0819 - George and Accomodation.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n; cin >> n; int res = 0; 6 | for (int i = 0; i < n; i++) { 7 | int p, q; cin >> p >> q; 8 | res += (q - p) > 1; 9 | } 10 | cout << res << endl; 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0821 - Vasya and Socks.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n, m; cin >> n >> m; 6 | int s = n + n / (m - 1); 7 | if (n % (m - 1) == 0) { s--; } 8 | cout << s << endl; 9 | cin.ignore(2); return 0; 10 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0822 - Vitaly and Night.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n, m; cin >> n >> m; 6 | int res = 0; 7 | for (int i = 0; i < n; i++) 8 | for (int j = 0; j < m; j++) { 9 | int x, y; cin >> x >> y; 10 | res += (x + y != 0); 11 | } 12 | cout << res << endl; 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0826 - Vanya and Books.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | int n; cin >> n; int m = n; 7 | int d = 0; while (m) { d++; m /= 10; } 8 | int digCount = 1; ll mult = 1, res = 0; 9 | while (digCount < d) { res += 9 * mult*digCount; digCount++; mult *= 10; } 10 | cout << res + digCount * (n - mult + 1) << endl; 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0830 - Caisa and Pylons.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | vector v; 7 | 8 | int main() { 9 | int n; cin >> n; v.resize(n); 10 | for (auto &x : v) { cin >> x; } 11 | cout << *max_element(v.begin(), v.end()) << endl; 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0832 - Pasha and Stick.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n; cin >> n; 6 | if (n % 2) { cout << 0 << endl; } 7 | else { n >>= 1; cout << (n - 1) / 2 << endl; } 8 | cin.ignore(2); return 0; 9 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0847 - Amusing Joke.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | int main() { 7 | string a, b, t; cin >> a >> b >> t; 8 | string s = a + b; 9 | sort(s.begin(), s.end()); 10 | sort(t.begin(), t.end()); 11 | cout << (s == t ? "YES" : "NO") << endl; 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0849 - Chat Room.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | string s, t = "hello"; 7 | 8 | int main() { 9 | cin >> s; int j = -1, n = (int)s.size(); 10 | for (int i = 0; i < 5 && j < n; i++) 11 | j = find(s.begin() + 1 + j, s.end(), t[i]) - s.begin(); 12 | cout << (j == n ? "NO" : "YES") << endl; 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0853 - Football.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | map score; 7 | 8 | int main() { 9 | int n; cin >> n; 10 | while (n--) { string s; cin >> s; score[s]++; } 11 | cout << (score.rbegin()->second > score.begin()->second ? score.rbegin()->first : score.begin()->first) << endl; 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0880 - Minimal Square.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int t; cin >> t; 7 | while (t--) { 8 | int a, b; cin >> a >> b; 9 | if (a > b) { swap(a, b); } 10 | cout << max(4 * a*a, b*b) << endl; 11 | } 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0893 - Integer Sequence Dividing.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | long long n; cin >> n; 6 | cout << (((n * (n + 1)) >> 1) & 1); 7 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0894 - Park Lighting.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int t; cin >> t; 7 | while (t--) { 8 | int n, m; cin >> n >> m; 9 | if (n < m) { swap(n, m); } 10 | if (n % 2 == 0 || m % 2 == 0) { cout << (n*m) / 2 << endl; continue; } 11 | cout << m * (n - 1) / 2 + (m + 1) / 2 << endl; 12 | } 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0896 - Celex Update.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | ios::sync_with_stdio(0); 7 | cin.tie(0); cout.tie(0); 8 | 9 | int t; cin >> t; 10 | while (t--) { 11 | ll x1, x2, y1, y2; cin >> x1 >> y1 >> x2 >> y2; 12 | ll dx = x2 - x1, dy = y2 - y1; 13 | cout << dx * dy + 1 << '\n'; 14 | } 15 | cin.ignore(2); return 0; 16 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0902 - Infinite Sequence.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | typedef long long ll; 7 | 8 | int main() { 9 | ll n; cin >> n; ll i = 0; 10 | while (n > i) { n -= i++; } 11 | cout << n << endl; cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0907 - Berland Poker.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int n, m, k; cin >> n >> m >> k; 8 | if (m <= n/k) { cout << m << endl; continue; } 9 | cout << (n / k) - (m - (n / k) + k - 2) / (k - 1) << endl; 10 | } 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0923 - Johnny and Another Rating Drops.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | int t; cin >> t; 7 | while (t--) { 8 | ll n; cin >> n; ll res = 0; 9 | while (n) { res += n; n >>= 1; } 10 | cout << res << '\n'; 11 | } 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0926 - Heidi Learns Hashing Easy.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | long long r; cin >> r; 6 | if (r % 2 == 0 || r < 4) { cout << "NO" << endl; } 7 | else { cout << 1 << ' ' << ((r - 3) >> 1) << endl; } 8 | cin.ignore(2); return 0; 9 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0939 - Shattered Cake.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); cout.tie(0); 7 | 8 | int w, n; cin >> w >> n; int res = 0; 9 | for (int i = 0; i < n; i++) { 10 | int a, b; cin >> a >> b; res += a * b; 11 | } 12 | cout << res / w << '\n'; 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0965 - Maximum GCD.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int n; cin >> n; cout << n / 2 << endl; 8 | } 9 | cin.ignore(2); return 0; 10 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0972 - FashionabLee.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int n; cin >> n; 8 | cout << (n % 4 ? "NO" : "YES") << '\n'; 9 | } 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0979 - Flying Safely.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int n, m; cin >> n >> m; 8 | while (m--) { int a, b; cin >> a >> b; } 9 | cout << n - 1 << endl; 10 | } 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0981 - Donut Shops.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | int t; cin >> t; 7 | while (t--) { 8 | ll a, b, c; cin >> a >> b >> c; 9 | int res1 = (a < c) ? 1 : -1; 10 | int res2 = (a * b > c) ? b : -1; 11 | cout << res1 << ' ' << res2 << '\n'; 12 | } 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0982 - 01 Game.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | int main() { 7 | int t; cin >> t; 8 | while (t--) { 9 | string s; cin >> s; 10 | int z = 0, o = 0; 11 | for (char &c : s) (c - '0' ? o : z)++; 12 | cout << (min(z, o) % 2 ? "DA" : "NET") << '\n'; 13 | } 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0986 - Short Substrings.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int t; cin >> t; 7 | while (t--) { 8 | string b; cin >> b; int n = (int)b.size(); 9 | string a(1, b.front()); 10 | for (int i = 2; i < n; i += 2) 11 | a.push_back(b[i]); 12 | cout << a << b.back() << '\n'; 13 | } 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0989 - Magical Sticks.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int n; cin >> n; 8 | cout << (n + 1) / 2 << endl; 9 | } 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0990 - Magical Calendar.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | int t; cin >> t; 7 | while (t--) { 8 | ll n, r; cin >> n >> r; 9 | if (r < n) { cout << r * (r + 1) / 2 << endl; continue; } 10 | cout << n * (n - 1) / 2 + 1 << endl; 11 | } 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0991 - A Cookie for You.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | typedef long long ll; 5 | 6 | int main() { 7 | ios::sync_with_stdio(0); 8 | cin.tie(0); cout.tie(0); 9 | 10 | int t; cin >> t; 11 | while (t--) { 12 | ll a, b, n, m; cin >> a >> b >> n >> m; 13 | cout << (m <= min(a, b) && (a + b >= n + m) ? "Yes" : "No") << endl; 14 | } 15 | cin.ignore(2); return 0; 16 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0996 - Element Extermination.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | int main() { 7 | ios::sync_with_stdio(0); 8 | cin.tie(0); cout.tie(0); 9 | 10 | int t; cin >> t; 11 | while (t--) { 12 | int n; cin >> n; vector v(n); 13 | for (auto &x : v) { cin >> x; } 14 | cout << (v.back() < v.front() ? "NO" : "YES") << '\n'; 15 | } 16 | cin.ignore(2); return 0; 17 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0998 - Weird Algorithm.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | ll n; cin >> n; 7 | while (n != 1) { cout << n << ' '; n = (n % 2 ? 3 * n + 1 : n / 2); } 8 | cout << 1 << endl; cin.ignore(2); return 0; 9 | } -------------------------------------------------------------------------------- /Problems Archive/0000 - 0999/0999 - Missing Number.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n; cin >> n; int res = 0; 6 | for (int i = 0; i < n - 1; i++) { 7 | int x; cin >> x; res ^= x ^ (i + 1); 8 | } 9 | cout << (res ^ n) << endl; cin.ignore(2); return 0; 10 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1000 - Repetitions.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | int main() { 7 | string s; cin >> s; int n = (int)s.size(); 8 | int i = 0, j = 0, res = 0; 9 | while (j != n) { 10 | if (s[j] == s[i]) { j++; continue; } 11 | res = max(res, j - i); i = j; 12 | } 13 | cout << max(res, j - i) << endl; 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1001 - Increasing Array.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | typedef long long ll; 6 | 7 | int main() { 8 | int n; cin >> n; vector v(n); 9 | for (auto &x : v) { cin >> x; } 10 | int cur = 0; ll res = 0; 11 | 12 | for (auto &x : v) { cur = max(cur, x); res += cur - x; } 13 | cout << res << endl; cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1002 - Permutations.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n; cin >> n; 6 | if (n == 1) { cout << 1 << '\n'; return 0; } 7 | if (n < 4) { cout << "NO SOLUTION" << '\n'; return 0; } 8 | for (int i = 2; i <= n; i += 2) cout << i << ' '; 9 | for (int i = 1; i <= n; i += 2) cout << i << ' '; 10 | cout << '\n'; cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1003 - BitStrings.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | const ll mod = 1000 * 1000 * 1000 + 7; 5 | 6 | ll power2(int n) { 7 | if (!n) { return 1; } 8 | ll res = power2(n >> 1); 9 | res = (res * res) % mod; 10 | if (n % 2 == 0) { return res; } 11 | return (2 * res) % mod; 12 | } 13 | int main() { 14 | int n; cin >> n; cout << power2(n) << endl; 15 | cin.ignore(2); return 0; 16 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1004 - Coin Piles.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int a, b; cin >> a >> b; 8 | if (a > b) { swap(a, b); } 9 | if (2 * a < b) { cout << "NO" << endl; continue; } 10 | a -= (b - a); cout << (a % 3 ? "NO" : "YES") << endl; 11 | } 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1007 - Trailing Zeroes.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n; cin >> n; int res = 0; 6 | while (n) { res += (n /= 5); } 7 | cout << res << endl; 8 | cin.ignore(2); return 0; 9 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1008 - Two Knights.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | ll knights(ll n) { 6 | return n * n * (n * n - 1) / 2 - 4 * (n - 1) * (n - 2); 7 | } 8 | 9 | int main() { 10 | int n; cin >> n; 11 | for (int i = 0; i < n; i++) 12 | cout << knights(i + 1) << '\n'; 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1013 - Creating Strings 1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | 7 | int main() { 8 | string s; cin >> s; sort(s.begin(), s.end()); vector res(1, s); 9 | while (next_permutation(s.begin(), s.end())) { res.push_back(s); } 10 | cout << res.size() << '\n'; for (auto &x : res) { cout << x << ' '; } 11 | cout << '\n'; cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1015 - Distinct Numbers.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int n; cin >> n; set s; 7 | while (n--) { int x; cin >> x; s.insert(x); } 8 | cout << s.size() << endl; 9 | cin.ignore(2); return 0; 10 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1068 - Random Mood.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | int main() { 7 | int n; double p; cin >> n >> p; 8 | cout << fixed << setprecision(10) << (1 + pow(1.0 - 2 * p, n + 0.0)) / 2 << endl; 9 | cin.ignore(2); return 0; 10 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1088 - Assigning to Classes.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | vector v; 7 | 8 | int main() { 9 | int t; cin >> t; 10 | while (t--) { 11 | int n; cin >> n; v.resize(2 * n); 12 | for (auto &x : v) { cin >> x; } 13 | sort(v.begin(), v.end()); 14 | cout << v[n] - v[n - 1] << endl; 15 | } 16 | cin.ignore(2); return 0; 17 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1090 - Case of Zeroes and Ones.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n; cin >> n; int z = 0, o = 0; 6 | while (n--) { char c; cin >> c; (c == '0' ? z : o)++; } 7 | if (z > o) { swap(z, o); } 8 | cout << o - z << endl; 9 | cin.ignore(2); return 0; 10 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1091 - Equation.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n; cin >> n; 6 | if (n % 2) { cout << 9 + n << ' ' << 9 << '\n'; } 7 | else { cout << 4 + n << ' ' << 4 << '\n'; } 8 | cin.ignore(2); return 0; 9 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1092 - Gennady and a Card Game.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string s; cin >> s; int n = 5; bool b = false; 7 | while (n--) { string t; cin >> t; b = b || t[0] == s[0] || t[1] == s[1]; } 8 | cout << (b ? "YES" : "NO") << endl; cin.ignore(2); return 0; 9 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1096 - Suffix Three.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int t; cin >> t; 7 | while (t--) { 8 | string s; cin >> s; 9 | if (s.back() == 'o') { cout << "FILIPINO" << endl; continue; } 10 | if (s.back() == 'u') { cout << "JAPANESE" << endl; continue; } 11 | cout << "KOREAN" << endl; 12 | } 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1100 - Range Sum Queries 1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | typedef long long ll; 5 | 6 | vector v; 7 | 8 | int main() { 9 | int n, q; cin >> n >> q; v.resize(n + 1, 0); 10 | for (int i = 1; i <= n; i++) { 11 | int x; cin >> x; v[i] = v[i - 1] + x; 12 | } 13 | while (q--) { 14 | int a, b; cin >> a >> b; 15 | cout << v[b] - v[a - 1] << endl; 16 | } 17 | cin.ignore(2); return 0; 18 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1103 - Range XOR Queries.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | vector v; 6 | 7 | int main() { 8 | int n, q; cin >> n >> q; v.resize(n + 1, 0); 9 | for (int i = 1; i <= n; i++) { 10 | int x; cin >> x; v[i] = v[i - 1] ^ x; 11 | } 12 | while (q--) { 13 | int a, b; cin >> a >> b; 14 | cout << (v[b] ^ v[a - 1]) << endl; 15 | } 16 | cin.ignore(2); return 0; 17 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1107 - 123 Sequence.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int a[4]; 6 | 7 | int main() { 8 | int n; cin >> n; while (n--) { 9 | int x; cin >> x; a[x]++; 10 | } 11 | cout << min({ a[1] + a[2], a[2] + a[3], a[1] + a[3] }); 12 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1139 - Negigent Nobert.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | int t; cin >> t; while (t--) { 7 | ll q, n; cin >> q >> n; 8 | ll res = 0, c = 1, count = n; 9 | while (q) { 10 | if (count >= q) { res += q * c; q = 0; continue; } 11 | res += c * count; q -= count; count *= n; c++; 12 | } 13 | cout << res << endl; 14 | } 15 | cin.ignore(2); return 0; 16 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1140 - LCM Problem.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int l, r; cin >> l >> r; 8 | if (2 * l > r) { cout << -1 << ' ' << -1 << endl; continue; } 9 | cout << l << ' ' << 2 * l << endl; 10 | } 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1143 - Captain Flint and a Long Voyage.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | int main() { 7 | int t; cin >> t; 8 | while (t--) { 9 | int n; cin >> n; string res((n + 3) / 4, '8'); 10 | res += string(n - res.size(), '9'); 11 | reverse(res.begin(), res.end()); 12 | cout << res << endl; 13 | } 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1150 - Counting Bits.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | typedef long long ll; 5 | 6 | int main() { 7 | ll n; cin >> n; ll res = 0; n++; 8 | for (int i = 0; i < 50; i++) { 9 | ll mask = 1ll << (i + 1); 10 | res += (n / mask) * (mask >> 1); 11 | res += max(0ll, n % mask - (mask >> 1)); 12 | } 13 | cout << res << endl; 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1155 - Nim Game 1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int n; cin >> n; int res = 0; 8 | while (n--) { int x; cin >> x; res ^= x; } 9 | cout << (res ? "first" : "second") << '\n'; 10 | } 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1156 - Nim Game 2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; 6 | while (t--) { 7 | int n; cin >> n; int res = 0; 8 | while (n--) { int x; cin >> x; res ^= (x % 4); } 9 | cout << (res ? "first" : "second") << '\n'; 10 | } 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1166 - Edge Directions.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | vector> v; 6 | 7 | int main() { 8 | int n, m; cin >> n >> m; v.resize(m); 9 | for (auto &x : v) { cin >> x.first >> x.second; } 10 | for (auto &x : v) { 11 | if (x.first > x.second) swap(x.first, x.second); 12 | cout << x.first << ' ' << x.second << '\n'; 13 | } 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1185 - Suborrays.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; while (t--) { 6 | int n; cin >> n; 7 | for (int i = 1; i <= n; i++) 8 | cout << i << ' '; cout << '\n'; 9 | } 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1188 - Balloons.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | int main() { 7 | ios::sync_with_stdio(0); 8 | cin.tie(0); cout.tie(0); 9 | 10 | int t; cin >> t; while (t--) { 11 | int n; cin >> n; int res = 0; 12 | while (n--) { int x; cin >> x; res += (x != 0); } 13 | cout << res << '\n'; 14 | } 15 | cin.ignore(2); return 0; 16 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1189 - Circles.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | int t; cin >> t; while (t--) { 7 | ll a, b, d; cin >> a >> b >> d; 8 | cout << fixed << (d * d) / 2.0 << '\n'; 9 | } 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1190 - Cube.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; while (t--) { 6 | int n; cin >> n; n /= 6; 7 | int l = 0, r = 1000; while (l != r) { 8 | int mid = (l + r) >> 1; 9 | if (mid * mid == n) { l = r = mid; break; } 10 | mid * mid < n ? l = mid + 1 : r = mid - 1; 11 | } 12 | cout << l << '\n'; 13 | } 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1192 - Working Time.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; while (t--) { 6 | int n, m; cin >> n >> m; 7 | int res = 0; while (n--) { 8 | int h1, h2, m1, m2; char c; 9 | cin >> h1 >> c >> m1 >> h2 >> c >> m2; 10 | res += (h2 - h1) * 60 + m2 - m1; 11 | } 12 | cout << (res >= 60 * m ? "YES" : "NO") << '\n'; 13 | } 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1197 - Apple Pen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | string a, b; 6 | 7 | int main() { 8 | int t; cin >> t; getline(cin, a); 9 | while (t--) { 10 | getline(cin, a); getline(cin, b); 11 | a = a.substr(9); b = b.substr(9); 12 | cout << "Uh! " << b << '-' << a << '!' << '\n'; 13 | } 14 | cin.ignore(2);; return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1201 - Last Robotics.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | bool parity(ll x) { 6 | bool res = 0; 7 | while (x) { res ^= 1; x &= (x - 1); } 8 | return res; 9 | } 10 | 11 | int main() { 12 | int t; cin >> t; while (t--) { 13 | ll n; cin >> n; n--; 14 | cout << (parity(n) ? "Blue" : "Red") << '\n'; 15 | } 16 | cin.ignore(2); return 0; 17 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1206 - Box Game.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | while (true) { 6 | int n; cin >> n; if (!n++) break; 7 | cout << (n & (n - 1) ? "Alice" : "Bob") << '\n'; 8 | } 9 | cin.ignore(2); return 0; 10 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1207 - ENimEN.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; while (t--) { 6 | int n; cin >> n; int one = 0, other = 0; 7 | while (n--) { int x; cin >> x; (x == 1 ? one : other)++; } 8 | if (other) { cout << "poopi" << '\n'; continue; } 9 | cout << (one % 2 ? "poopi" : "piloop") << '\n'; 10 | } 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1209 - Playing With Stones.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | typedef long long ll; 5 | 6 | int main() { 7 | int t; cin >> t; while (t--) { 8 | int n; cin >> n; ll res = 0; 9 | while (n--) { 10 | ll x; cin >> x; 11 | while (x & 1) { x >>= 1; } 12 | res ^= x >> 1; 13 | } 14 | cout << (res ? "YES" : "NO") << '\n'; 15 | } 16 | cin.ignore(2); return 0; 17 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1210 - Stone Game.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | while (true) { 6 | int n; cin >> n; if (!n) break; 7 | int res = 0; while (n--) { 8 | int x; cin >> x; res ^= x; 9 | } 10 | cout << (res ? "Yes" : "No") << '\n'; 11 | } 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1213 - Game of Stones.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; while (t--) { 6 | int n; cin >> n; 7 | cout << (n % 7 < 2 ? "Second" : "First") << '\n'; 8 | } 9 | cin.ignore(2); return 0; 10 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1215 - Nimble Game.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; while (t--) { 6 | int n; cin >> n; int res = 0; 7 | for (int i = 0; i < n; i++) { 8 | int x; cin >> x; 9 | if (x & 1)res ^= i; 10 | } 11 | cout << (res ? "First" : "Second") << '\n'; 12 | } 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1216 - Stair Game.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); cout.tie(0); 7 | 8 | int t; cin >> t; while (t--) { 9 | int n; cin >> n; int res = 0; 10 | for (int i = 0; i < n; i++) { 11 | int x; cin >> x; 12 | if (i & 1) res ^= x; 13 | } 14 | cout << (res ? "first" : "second") << '\n'; 15 | } 16 | cin.ignore(2); return 0; 17 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1218 - Tower Breakers.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; while (t--) { 6 | int n, m; cin >> n >> m; 7 | if ((n & 1) == 0) { cout << 2 << '\n'; continue; } 8 | if (m == 1) { cout << 2 << '\n'; continue; } 9 | cout << 1 << '\n'; 10 | } 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1238 - Cryptographer's Conundrum.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string s; cin >> s; int res = 0; 7 | for (int i = 0; i < (int)s.size(); i++) 8 | res += (s[i] != 'P') + (s[++i] != 'E') + (s[++i] != 'R'); 9 | cout << res << '\n'; cin.ignore(2); return 0; 10 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1244 - Powers Game.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); cout.tie(0); 7 | 8 | int t; cin >> t; while (t--) { 9 | int n; cin >> n; n = n & 7; 10 | cout << (n ? "First" : "Second") << '\n'; 11 | } 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1247 - Distance and Axis.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; while (t--) { 6 | int n, k; cin >> n >> k; 7 | if (n < k) { cout << k - n << '\n'; continue; } 8 | cout << (n - k) % 2 << endl; 9 | } 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1261 - Jalil Got TLE.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | int T; cin >> T; 7 | for(int t = 1; t <= T; t++) { 8 | ll a, b, c; cin >> a >> b >> c; 9 | cout << "Case " << t << ": "; 10 | cout << a * (b * (b + 1) >> 1) * (c * (c + 1) >> 1) << '\n'; 11 | } 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1263 - String Similarity.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int t; cin >> t; while (t--) { 7 | int n; string s; cin >> n >> s; 8 | cout << string(n, s[n - 1]) << '\n'; 9 | } 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1268 - The King's Race.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | typedef long long ll; 5 | 6 | int main() { 7 | ll n, x, y; cin >> n >> x >> y; 8 | ll X = n - x, Y = n - y; 9 | ll W = max(x - 1, y - 1), B = max(X, Y); 10 | cout << (W > B ? "Black" : "White") << '\n'; 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1272 - Don't be Late.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int d, t, s; cin >> d >> t >> s; 6 | cout << (s*t >= d ? "Yes" : "No") << '\n'; 7 | cin.ignore(2); return 0; 8 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1298 - Yet Another Two Integers Problem.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; while (t--) { 6 | int a, b; cin >> a >> b; 7 | int d = abs(b - a); 8 | cout << (d % 10 != 0) + d / 10 << '\n'; 9 | } 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1324 - Buying Torches.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | int t; cin >> t; while (t--) { 7 | ll x, y, k; cin >> x >> y >> k; 8 | ll s = 1, S = (k * y + x - 2) / (x - 1); 9 | s += (x - 1) * S - k * y; 10 | cout << S + k + (k - s + x - 2) / (x - 1) << '\n'; 11 | } 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1340 - Plural Form.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string s; cin >> s; 7 | if (s.back() != 's') { s.push_back('s'); } 8 | else { s.push_back('e'); s.push_back('s'); } 9 | cout << s << '\n'; 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1341 - Go to Jail.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n; cin >> n; bool ok = false; int c = 0; 6 | for (int i = 0; i < n; i++) { 7 | int d1, d2; cin >> d1 >> d2; 8 | if (d1 != d2) { c = 0; continue; } 9 | c++; if (c == 3) { ok = true; } 10 | } 11 | cout << (ok ? "Yes" : "No") << '\n'; 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1354 - Candle Box.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int d, r, t; cin >> d >> r >> t; 6 | int s = r + t, res = 0; 7 | for (int n = d; n < 100; n++) { 8 | int R = ((7 + n) * n) / 2; 9 | int T = ((6 + n - d) * (n - d + 1)) / 2; 10 | if (r - R < 0 || r - R != T - t) { continue; } 11 | res = T - t; break; 12 | } 13 | cout << res << '\n'; 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1359 - A String.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | int main() { 7 | ifstream ifs("string.in"); 8 | 9 | int t; ifs >> t; while (t--) { 10 | string s; ifs >> s; cout << s << '\n'; 11 | } 12 | ifs.close(); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1361 - Extremely Basic.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | ifstream ifs("hello.in"); 7 | 8 | int t; ifs >> t; while (t--) { 9 | int x, y; ifs >> x >> y; 10 | cout << "sum = " << x + y << '\n'; 11 | } 12 | ifs.close(); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1365 - Absent Students.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | freopen("students.in", "r", stdin); 6 | 7 | int t; cin >> t; while (t--) { 8 | int n, m; cin >> n >> m; 9 | cout << n - m << '\n'; 10 | } 11 | return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1371 - Bakery Chief.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | ios::sync_with_stdio(0); 7 | cin.tie(0); cout.tie(0); 8 | 9 | freopen("chief.in", "r", stdin); 10 | 11 | int t; cin >> t; while (t--) { 12 | int k, n; cin >> k >> n; 13 | cout << k / n << ' ' << k % n << '\n'; 14 | } 15 | return 0; 16 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1373 - Keyboard.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | char S, T; cin >> S >> T; 6 | char r = (S == 'Y') ? T + 'A' - 'a' : T; 7 | cout << r << '\n'; 8 | cin.ignore(2); return 0; 9 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1375 - Neq Min.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | vector v; set s; 7 | 8 | int main() { 9 | int n; cin >> n; v.resize(n); 10 | for (int i = 0; i <= n; i++) s.insert(i); 11 | for (auto &x : v) { cin >> x; } 12 | 13 | for (int i = 0; i < n; i++) { 14 | s.erase(v[i]); cout << *s.begin() << '\n'; 15 | } 16 | cin.ignore(2); return 0; 17 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1384 - Fourtune Cookies.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int a[4]; cin >> a[0] >> a[1] >> a[2] >> a[3]; 7 | sort(a, a + 4); 8 | if (a[3] == a[0] + a[1] + a[2]) { cout << "Yes" << '\n'; } 9 | else if (a[3] + a[0] == a[1] + a[2]) { cout << "Yes" << '\n'; } 10 | else { cout << "No" << '\n'; } 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1385 - MAX-=min.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | vector v; 6 | 7 | int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } 8 | 9 | int main() { 10 | int n; cin >> n; v.resize(n); int g = 0; 11 | for (auto &x : v) { cin >> x; g = gcd(g, x); } 12 | cout << g << '\n'; cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1388 - Box.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n, a, b; cin >> n >> a >> b; 6 | cout << n - a + b << '\n'; 7 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1390 - Cream Puffs.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | typedef long long ll; 5 | 6 | set res; 7 | 8 | int main() { 9 | ll n; cin >> n; 10 | for(ll i = 1; i * i <= n; i++) 11 | if (n % i == 0) { res.insert(i); res.insert(n / i); } 12 | 13 | for (auto &x : res) cout << x << '\n'; 14 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1394 - Box is Pull.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; while (t--) { 6 | int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; 7 | int dx = abs(x1 - x2), dy = abs(y1 - y2); 8 | if (dx == 0) { cout << dy << '\n'; } 9 | else if (dy == 0) { cout << dx << '\n'; } 10 | else { cout << dx + dy + 2 << '\n'; } 11 | } 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1398 - XORwice.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main(){ 5 | int t; cin >> t; while(t--) { 6 | int a, b; cin >> a >> b; 7 | int x = a & b; 8 | cout << (a ^ x) + (b ^ x) << '\n'; 9 | } 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1400 - Palindromifier.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string s; cin >> s; int n = (int)s.size(); 7 | cout << 3 << '\n'; 8 | cout << "L 2" << '\n'; 9 | cout << "R " << 2 << '\n'; 10 | cout << "R " << 2*n - 1 << '\n'; 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1407 - Mosaic Decoration I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n, b, p; cin >> n >> b >> p; 6 | int B = 0, P = 0; 7 | for (int i = 0; i < n; i++) { 8 | int bi, pi; cin >> bi >> pi; 9 | B += bi; P += pi; 10 | } 11 | cout << ((B + 9) / 10) * b + ((P + 9) / 10) * p << '\n'; 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1408 - Mosaic Decoration II.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | ll w, h, a, b, m, c; 7 | cin >> w >> h >> a >> b >> m >> c; 8 | ll hor = (w + a - 1) / a, ver = (h + b - 1) / b; 9 | ll buy = (hor * ver + 9) / 10; buy *= m; 10 | ll cutW = (w % a != 0) * c * h; 11 | ll cutH = (h % b != 0) * c * w; 12 | cout << buy + cutW + cutH << '\n'; 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1413 - Trapezoid Sum.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | int n; cin >> n; ll res = 0; 7 | for (int i = 0; i < n; i++) { 8 | ll a, b; cin >> a >> b; 9 | res += b * (b + 1) / 2 - a * (a - 1) / 2; 10 | } 11 | cout << res << '\n'; 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1423 - Twiblr.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int a, b; cin >> a >> b; 6 | cout << (2 * a + 100) - b << '\n'; 7 | cin.ignore(2); return 0; 8 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1426 - Large Digits.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int sumDigits(int n) { 6 | int res = 0; 7 | while (n) { res += n % 10; n /= 10; } 8 | return res; 9 | } 10 | 11 | int main() { 12 | int a, b; cin >> a >> b; 13 | cout << max(sumDigits(a), sumDigits(b)) << '\n'; 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1432 - Cards For Friends.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | int t; cin >> t; while (t--) { 7 | ll w, h, n; cin >> w >> h >> n; 8 | ll W = 1, H = 1; 9 | while ((w & 1) == 0) { W <<= 1; w >>= 1; } 10 | while ((h & 1) == 0) { H <<= 1; h >>= 1; } 11 | cout << (W * H >= n ? "YES" : "NO") << '\n'; 12 | } 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1450 - Missing Coin Sum.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | typedef long long ll; 6 | 7 | vector v; 8 | 9 | int main() { 10 | int n; cin >> n; v.resize(n); 11 | for (auto& x : v) { cin >> x; } 12 | sort(v.begin(), v.end()); 13 | ll res = 1; for (auto& x : v) { 14 | if (x > res) break; res += x; 15 | } 16 | cout << res << '\n'; 17 | cin.ignore(2); return 0; 18 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1451 - Collecting Numbers I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | vector v, a; 7 | 8 | int main() { 9 | int n; cin >> n; v.resize(n); a.resize(n); 10 | for (int i = 0; i < n; i++) { cin >> v[i]; a[--v[i]] = i; } 11 | int res = 1; for (int i = 1; i < n; i++) res += a[i] < a[i - 1]; 12 | cout << res << '\n'; cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1462 - Wizard of Orz.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int t; cin >> t; while (t--) { 7 | int n; cin >> n; if (n == 1) { cout << '9' << '\n'; continue; } 8 | string s(n, '0'); s[0] = '9'; s[1] = '8'; int cur = 9; 9 | for (int i = 2; i < n; i++) { s[i] = cur + '0'; cur = (cur + 1) % 10; } 10 | cout << s << '\n'; 11 | } 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1471 - Three Point Shot.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int x, y; cin >> x >> y; 6 | cout << (abs(x - y) < 3 ? "Yes" : "No") << '\n'; 7 | cin.ignore(2); return 0; 8 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1472 - Orthogonality.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | vector v; 7 | 8 | int main() { 9 | int n; cin >> n; v.resize(n); 10 | for (auto& x : v) { cin >> x; } 11 | for (auto& x : v) { int y; cin >> y; x *= y; } 12 | 13 | cout << (accumulate(v.begin(), v.end(), 0ll) == 0 ? "Yes" : "No") << '\n'; 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1477 - Replacing Elements.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | vector v; 7 | 8 | int main() { 9 | int t; cin >> t; while (t--) { 10 | int n, d; cin >> n >> d; v.resize(n); 11 | for (auto& x : v) { cin >> x; } 12 | sort(v.begin(), v.end()); 13 | cout << (v[n - 1] <= d || v[0] + v[1] <= d ? "YES" : "NO") << '\n'; 14 | } 15 | cin.ignore(2); return 0; 16 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1497 - Odd Divisor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; while (t--) { 6 | long long n; cin >> n; while (n % 2 == 0) { n >>= 1; } 7 | cout << (n == 1 ? "NO" : "YES") << '\n'; 8 | } 9 | cin.ignore(2); return 0; 10 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1498 - New Year's Number.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; while (t--) { 6 | int n; cin >> n; bool ok = false; 7 | for (int i = 0; i <= n / 2020; i++) { 8 | if ((n - (i * 2020)) % 2021 == 0) { ok = true; break; } 9 | } 10 | cout << (ok ? "YES" : "NO") << '\n'; 11 | } 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1510 - K-Divisible Sum.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | int t; cin >> t; while (t--) { 7 | ll n, k; cin >> n >> k; 8 | ll s = (n + k - 1) / k; 9 | 10 | cout << (s * k + n - 1) / n << '\n'; 11 | } 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1515 - Very Very Primitive Game.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int a, b, c; cin >> a >> b >> c; 6 | bool ok = (a != b && a > b) || (a == b && c); 7 | cout << (ok ? "Takahashi" : "Aoki") << '\n'; 8 | cin.ignore(2); return 0; 9 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1516 - Magic 3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n, s, d; cin >> n >> s >> d; bool ok = false; 6 | for (int i = 0; i < n; i++) { 7 | int x, y; cin >> x >> y; 8 | ok = ok || (x < s && y > d); 9 | } 10 | cout << (ok ? "Yes" : "No") << '\n'; 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1518 - Staircase Sequences.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | ll s; cin >> s; s <<= 1; int res = 0; 7 | for (ll i = 1; i * i <= s; i++) { 8 | if (s % i) { continue; } 9 | res += ((s / i) - (i - 1)) % 2 == 0; 10 | if (s / i <= i) { continue; } 11 | res += ((s / (s / i)) - ((s / i) - 1)) % 2 == 0; 12 | } 13 | cout << res << '\n'; 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1525 - Digit Count.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | freopen("dahab.in", "r", stdin); 7 | int n; cin >> n; 8 | cout << to_string(n).size() << '\n'; 9 | cin.ignore(2); return 0; 10 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1526 - Expected Sum.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | typedef long long ll; 5 | 6 | int main() { 7 | freopen("sum.in", "r", stdin); 8 | ios::sync_with_stdio(0); 9 | cin.tie(0); cout.tie(0); 10 | 11 | int t; cin >> t; while (t--) { 12 | ll n; cin >> n; 13 | ll res = (n + n * n * n) >> 1; 14 | 15 | cout << res << '\n'; 16 | } 17 | cin.ignore(2); return 0; 18 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1530 - Salah and Encryption.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | freopen("string.in", "r", stdin); 6 | ios::sync_with_stdio(0); 7 | cin.tie(0); cout.tie(0); 8 | 9 | int k; char c; cin >> k >> c; 10 | int e = (c - 'a' + k) % 26; 11 | cout << (char)(e + 'a') << '\n'; 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1533 - Looking for Taste.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | freopen("looking.in", "r", stdin); 6 | ios::sync_with_stdio(0); 7 | cin.tie(0); cout.tie(0); 8 | 9 | int t; cin >> t; while (t--) { 10 | int n, k; cin >> n >> k; int res = 0; 11 | while (n--) { int x; cin >> x; res |= x; } 12 | cout << res << '\n'; 13 | } 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1541 - Vanishing Pitch.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int v, t, s, d; cin >> v >> t >> s >> d; 6 | cout << (d <= (s * v) && d >= (t * v) ? "No" : "Yes") << '\n'; 7 | cin.ignore(2); return 0; 8 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1542 - Remove It.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | vector v, res; 6 | 7 | int main() { 8 | int n, x; cin >> n >> x; 9 | for (int i = 0; i < n; i++) { 10 | int y; cin >> y; 11 | if (y != x) v.push_back(y); 12 | } 13 | for (auto& x : v) cout << x << ' '; cout << '\n'; 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1569 - Arena.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | vector v; 7 | 8 | int main() { 9 | int t; cin >> t; while (t--) { 10 | int n; cin >> n; v.resize(n); 11 | for (auto& x : v) { cin >> x; } 12 | int mi = *min_element(v.begin(), v.end()); 13 | int res = n - count(v.begin(), v.end(), mi); 14 | cout << res << '\n'; 15 | } 16 | cin.ignore(2); return 0; 17 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1570 - Cat Cycle.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | int t; cin >> t; while (t--) { 7 | ll n, k; cin >> n >> k; k--; 8 | if (!(n & 1)) { cout << (k % n) + 1 << '\n'; continue; } 9 | ll mid = n >> 1; 10 | ll res = (k / mid) * (mid + 1) + (k % mid); 11 | cout << 1 + (res % n) << '\n'; 12 | } 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1584 - Elements.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); cout.tie(0); 7 | 8 | int t; cin >> t; while (t--) { 9 | int n; cin >> n; 10 | cout << (n == 4 ? "yes" : "no") << '\n'; 11 | } 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1595 - Star.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n; cin >> n; 6 | cout << 100 - (n % 100) << '\n'; 7 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1596 - uNrEaDaBlE sTrInG.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | bool isRange(char c, char a) { return c >= a && c <= a + 25; } 5 | 6 | int main() { 7 | string s; cin >> s; bool b = true; 8 | for (int i = 0; i < (int)s.size(); i++) 9 | if (!isRange(s[i], i % 2 ? 'A' : 'a')) { b = false; break; } 10 | cout << (b ? "Yes" : "No") << '\n'; 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1601 - AxBxC.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | typedef long long ll; 5 | 6 | vector v; 7 | 8 | int main() { 9 | int k; cin >> k; v.resize(k + 1); 10 | for (int i = 1; i <= k; i++) 11 | v[i] = k / i; 12 | 13 | ll res = 0; 14 | for (int i = 1; i <= k; i++) 15 | for (int j = i; j <= k; j += i) 16 | res += v[j]; 17 | 18 | cout << res << '\n'; 19 | cin.ignore(2); return 0; 20 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1605 - Three Swimmers.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | typedef long long ll; 5 | 6 | int main() { 7 | int t; cin >> t; while (t--) { 8 | ll p, a, b, c; cin >> p >> a >> b >> c; 9 | ll A = (a - (p % a)) % a; 10 | ll B = (b - (p % b)) % b; 11 | ll C = (c - (p % c)) % c; 12 | cout << min({ A, B, C }) << '\n'; 13 | } 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1628 - Baby Ehab.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | freopen("equal.in", "r", stdin); 7 | ios::sync_with_stdio(0); 8 | cin.tie(0), cout.tie(0); 9 | 10 | int t; cin >> t; 11 | while (t--) { 12 | int a, b, c; cin >> a >> b >> c; 13 | bool b = a == b || a == c || b == c; 14 | cout << (b ? "YES" : "NO") << '\n'; 15 | } 16 | 17 | cin.ignore(2); return 0; 18 | } 19 | -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1629 - I Scream.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int a, b; cin >> a >> b; a += b; 6 | if (a >= 15 && b >= 8) { cout << 1 << '\n'; } 7 | else if (a >= 10 && b >= 3) { cout << 2 << '\n'; } 8 | else if (a >= 3) { cout << 3 << '\n'; } 9 | else { cout << 4 << '\n'; } 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1632 - Journey.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | typedef double ld; 5 | 6 | int main() { 7 | int n; cin >> n; 8 | ld res = 0.0;; int i = 1; 9 | while (i < n) { res += 1.0 / i++; } 10 | cout << fixed << setprecision(10) << n * res << '\n'; 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1641 - Health M Death.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int m, h; cin >> m >> h; 6 | cout << (h % m ? "No" : "Yes") << '\n'; 7 | cin.ignore(2); return 0; 8 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1642 - Comma.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | ll n; cin >> n; 7 | ll l = 1, r = 9, c = 9, d = 0, res = 0; 8 | while (r <= n) { 9 | res += (d / 3) * c; 10 | l *= 10; c *= 10; r = r * 10 + 9; d++; 11 | } 12 | if (l <= n) { res += (d / 3) * (n - l + 1); } 13 | cout << res << '\n'; 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1645 - Strange Table.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | int t; cin >> t; while (t--) { 7 | ll n, m, x; cin >> n >> m >> x; x--; 8 | ll j = x / n, i = x % n; 9 | cout << i * m + j + 1 << '\n'; 10 | } 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1655 - Rotate.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string s; cin >> s; s.push_back(s[0]); 7 | s.erase(s.begin()); cout << s << '\n'; 8 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1678 - Tiny Arithmetic Sequence.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int a[3]; 6 | 7 | int main() { 8 | cin >> a[0] >> a[1] >> a[2]; sort(a, a + 3); 9 | 10 | cout << (a[1] - a[0] == a[2] - a[1] ? "Yes" : "No") << '\n'; 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1679 - Do you know the Second Highest Mountain.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | 7 | vector> v; 8 | 9 | int main() { 10 | int n; cin >> n; v.resize(n); 11 | for (auto& x : v) cin >> x.second >> x.first; 12 | sort(v.rbegin(), v.rend()); 13 | cout << v[1].second << '\n'; 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1686 - Three Dice.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int a, b, c; cin >> a >> b >> c; 6 | cout << 21 - a - b - c << '\n'; 7 | cin.ignore(2); return 0; 8 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1687 - 180.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | int main() { 7 | string s; cin >> s; 8 | reverse(s.begin(), s.end()); 9 | for (char& c : s) 10 | c = (c == '9') ? '6' : (c == '6' ? '9' : c); 11 | 12 | cout << s << '\n'; 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1703 - I Hate 1111.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); cout.tie(0); 7 | 8 | int t; cin >> t; while (t--) { 9 | int n; cin >> n; 10 | n -= (n % 11) * 111; 11 | cout << (n >= 0 ? "YES" : "NO") << '\n'; 12 | } 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1724 - 2wix+.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | freopen("two2.in", "r", stdin); 6 | ios::sync_with_stdio(0); 7 | cin.tie(0); cout.tie(0); 8 | 9 | int t; cin >> t; while (t--) { 10 | int n; cin >> n; 11 | cout << (n & 1 ? -1 : n >> 1) << '\n'; 12 | } 13 | 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1737 - Odd Set.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; while (t--) { 6 | int n, e = 0, o = 0; cin >> n; n <<= 1; 7 | while (n--) { int x; cin >> x; (x & 1 ? o : e)++; } 8 | cout << (e == o ? "Yes" : "No") << '\n'; 9 | } 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1743 - Endure is Going to Space.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | typedef long long ll; 5 | 6 | int main() { 7 | freopen("endure.in", "r", stdin); 8 | ios::sync_with_stdio(0); 9 | cin.tie(0); cout.tie(0); 10 | 11 | int t; cin >> t; while (t--) { 12 | string a; ll y, s; 13 | cin >> a >> y >> s; 14 | y *= 365 * 24 * 3600; 15 | cout << y * s << '\n'; 16 | } 17 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1746 - Phantom of the Opera.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | freopen("phantom.in", "r", stdin); 7 | ios::sync_with_stdio(0); 8 | cin.tie(0); cout.tie(0); 9 | 10 | int t; cin >> t; while (t--) { 11 | int n, m; cin >> n >> m; 12 | cout << max(0, n - m) << '\n'; 13 | } 14 | 15 | cin.ignore(2); return 0; 16 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1753 - XOR K.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | freopen("xor.in", "r", stdin); 6 | ios::sync_with_stdio(0); 7 | cin.tie(0); cout.tie(0); 8 | 9 | int n, res = 0; cin >> n; while (n--) { 10 | int x; cin >> x; res |= x; 11 | } 12 | cout << res << '\n'; 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1757 - Counting.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int a, b; cin >> a >> b; 7 | cout << max(0, b - a + 1) << '\n'; 8 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1758 - Can You Buy Them All.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n, x; cin >> n >> x; 6 | x += n/2; while (n--) { 7 | int s; cin >> s; x -= s; 8 | } 9 | cout << (x < 0 ? "No" : "Yes") << '\n'; 10 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1766 - XOR Pyramid.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); cout.tie(0); 7 | 8 | int n; cin >> n; int res = 0; 9 | for (int i = 0; i < n; i++) { 10 | int x; cin >> x; 11 | if (!(i & (n - 1 - i))) { res ^= x; } 12 | } 13 | cout << res << '\n'; 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1774 - Binary Decimals.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | int main() { 7 | int t; cin >> t; while (t--) { 8 | string s; cin >> s; char ma = '0'; 9 | for (char& c : s) ma = max(ma, c); 10 | cout << ma << '\n'; 11 | } 12 | 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1779 - Blood Pressure.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int a, b; cin >> a >> b; 7 | double res = b + (a - b) / 3.0; 8 | cout << fixed << setprecision(6) << res << '\n'; 9 | cin.ignore(2); return 0; 10 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1780 - Cycle Hit.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | int main() { 7 | set st; 8 | for (int i = 0; i < 4; i++) { 9 | string s; cin >> s; 10 | st.insert(s); 11 | } 12 | cout << (st.size() == 4 ? "Yes" : "No") << '\n'; 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1792 - Alloy.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int a, b; cin >> a >> b; 6 | cout << (a && b ? "Alloy" : a ? "Gold" : "Silver"); 7 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1804 - Gregor and Cryptography.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); cout.tie(0); 7 | 8 | int t; cin >> t; while (t--) { 9 | int p; cin >> p; 10 | cout << 2 << ' ' << p - 1 << '\n'; 11 | } 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1814 - Bitwise Exclusive OR.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int a, b; cin >> a >> b; 6 | cout << (a ^ b) << '\n'; 7 | cin.ignore(2); return 0; 8 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1815 - Booby Prize.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | vector v; 7 | 8 | int main() { 9 | int n; cin >> n; v.resize(n); 10 | for (auto& x : v) { cin >> x; } 11 | *max_element(v.begin(), v.end()) = 0; 12 | cout << max_element(v.begin(), v.end()) - v.begin() + 1 << '\n'; 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1826 - Lexicographic Order.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string s, t; cin >> s >> t; 7 | cout << (s < t ? "Yes" : "No") << '\n'; 8 | cin.ignore(2); return 0; 9 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1827 - AtCoder Quiz.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | set st = { "ABC", "ARC", "AGC", "AHC" }; 7 | 8 | int main() { 9 | for (int i = 0; i < 3; i++) { 10 | string s; cin >> s; st.erase(s); 11 | } 12 | cout << *st.begin() << '\n'; 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1828 - Inverse of Permutation.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | vector v; 6 | 7 | int main() { 8 | int n; cin >> n; v.resize(n); 9 | for (auto& x : v) { cin >> x; x--; } 10 | 11 | vector res(n); 12 | for (int i = 0; i < n; i++) res[v[i]] = i; 13 | for (auto& x : res) cout << x + 1 << ' '; cout << '\n'; 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1829 - Cutting Woods.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | set s; 6 | 7 | int main() { 8 | int l, q; cin >> l >> q; 9 | s.insert(0); s.insert(l); 10 | 11 | while (q--) { 12 | int c, x; cin >> c >> x; 13 | if (c == 1) { s.insert(x); continue; } 14 | auto it = s.lower_bound(x); auto itt = it; itt--; 15 | cout << *it - *itt << '\n'; 16 | } 17 | 18 | cin.ignore(2); return 0; 19 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1836 - Regular Bracket Sequence.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int t; cin >> t; while (t--) { 7 | int n; cin >> n; 8 | for (int i = 0; i < n; i++) { 9 | string L = string(n - i, '(') + string(n - i, ')'); 10 | string R = string(i, '(') + string(i, ')'); 11 | cout << L + R << '\n'; 12 | } 13 | } 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1844 - Find Multiple.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int a, b, c; cin >> a >> b >> c; 6 | int x = (a + c - 1) / c; 7 | cout << (x * c <= b ? x * c : -1) << '\n'; 8 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1845 - Base K.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | ll toBase10(ll x, ll k) { 6 | ll res = 0, mult = 1; 7 | while (x) { 8 | res += ((x % 10) * mult); 9 | x /= 10; mult *= k; 10 | } 11 | return res; 12 | } 13 | 14 | int main() { 15 | ll k, a, b; cin >> k >> a >> b; 16 | cout << toBase10(a, k) * toBase10(b, k) << '\n'; 17 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1846 - Long Sequence.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | typedef long long ll; 5 | 6 | vector v; 7 | 8 | int main() { 9 | int n; cin >> n; v.resize(n); ll sum = 0; 10 | for (auto& x : v) { cin >> x; sum += x; } 11 | ll X; cin >> X; ll k = (X / sum) * n; X %= sum; 12 | int i = 0; while (X >= 0) { X -= v[i++]; k++; } 13 | cout << k << '\n'; 14 | cin.ignore(2); return 0; 15 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1850 - Casimir's String Solitaire.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | int main() { 7 | int t; cin >> t; while (t--) { 8 | string s; cin >> s; int n = (int)s.size(); 9 | int b = count(s.begin(), s.end(), 'B'); 10 | cout << (b == n / 2 ? "YES" : "NO") << '\n'; 11 | } 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1857 - Seismic Magnitude Scales.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | ll a, b; cin >> a >> b; ll c = a - b; 7 | ll res = 1; while (c--) { res <<= 5; } 8 | cout << res << '\n'; 9 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1858 - Typo.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | string s, t; 6 | 7 | int main() { 8 | cin >> s >> t; int n = (int)s.size(); 9 | bool ok = (s == t); for (int i = 1; (i < n) && !ok; i++) { 10 | swap(s[i], s[i - 1]); 11 | if (s == t) { ok = true; break; } 12 | swap(s[i], s[i - 1]); 13 | } 14 | cout << (ok ? "Yes" : "No") << '\n'; 15 | cin.ignore(2); return 0; 16 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1867 - Consecutive Sum Riddle.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | int t; cin >> t; while (t--) { 7 | ll n; cin >> n; 8 | cout << (-n + 1) << ' ' << n << '\n'; 9 | } 10 | cout << '\n'; cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1871 - Four Digits.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string s; cin >> s; 7 | cout << string(4 - s.size(), '0') << s << '\n'; 8 | cin.ignore(2); return 0; 9 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1872 - Failing Grade.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | vector v; 7 | 8 | int main() { 9 | int n, p; cin >> n >> p; v.resize(n); 10 | for (auto& x : v) { cin >> x; } 11 | int res = 0; for (auto& x : v) res += (x < p); 12 | cout << res << '\n'; 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1896 - AM Deviation.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | int t; cin >> t; while (t--) { 7 | ll a, b, c; cin >> a >> b >> c; 8 | ll d = abs(a + c - (b << 1)); 9 | cout << (d % 3 != 0) << '\n'; 10 | } 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1903 - Game with Arrays.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); cout.tie(0); 7 | 8 | int n, s; cin >> n >> s; 9 | if (s < (n << 1)) { cout << "NO\n"; return 0; } 10 | cout << "YES" << '\n'; int N = n - 1; 11 | while (N--) cout << 1 << ' '; 12 | cout << s - n + 1 << '\n' << n << '\n'; 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1904 - Anti Light's Cell Guessing.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t; cin >> t; while (t--) { 6 | int n, m; cin >> n >> m; 7 | if (n > m) { swap(n, m); } 8 | if (m == 1) { cout << 0 << '\n'; continue; } 9 | cout << (n == 1 ? 1 : 2) << '\n'; 10 | } 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1920 - AND 0 Sum Big.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | const ll mod = 1000 * 1000 * 1000 + 7; 5 | 6 | int main() { 7 | int t; cin >> t; while (t--) { 8 | int n, k; cin >> n >> k; 9 | ll res = 1, x = n; 10 | for (; k; k >>= 1, x = (x * x) % mod) 11 | if (k & 1) res = (res * x) % mod; 12 | 13 | cout << res << '\n'; 14 | } 15 | cin.ignore(2); return 0; 16 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1925 - Kofta Never Lose.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | freopen("kofta.in", "r", stdin); 6 | ios::sync_with_stdio(0); 7 | cin.tie(0); cout.tie(0); 8 | 9 | int n; cin >> n; cout << "1\n"; 10 | cin.ignore(2); return 0; 11 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1940 - Fouad Wears Suits.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | typedef long long ll; 5 | 6 | int main() { 7 | freopen("fouad.in", "r", stdin); 8 | ios::sync_with_stdio(0); 9 | cin.tie(0); cout.tie(0); 10 | 11 | int x, y; cin >> x >> y; 12 | cout << min(x, y) << '\n'; 13 | } 14 | -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1945 - Weird Function.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int f(int x) { 5 | return x * x + 2 * x + 3; 6 | } 7 | 8 | int main() { 9 | int x; cin >> x; 10 | cout << f(f(f(x) + x) + f(f(x))) << '\n'; 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1953 - Rotate.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | char a; cin >> a; string A(1, a); 7 | char b; cin >> b; string B(1, b); 8 | char c; cin >> c; string C(1, c); 9 | 10 | cout << stoi(A + B + C) + stoi(B + C + A) + stoi(C + A + B) << '\n'; 11 | cin.ignore(2); return 0; 12 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1968 - Chukodai.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main(){ 6 | string s; int a, b; cin >> s >> a >> b; 7 | swap(s[--a], s[--b]); cout << s << '\n'; 8 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1969 - Who is Missing.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | vector v; 7 | 8 | int main() { 9 | ios::sync_with_stdio(0); 10 | cin.tie(0); cout.tie(0); 11 | 12 | int n; cin >> n; v.resize(n + 1, 4); 13 | for (int i = 0; i < 4 * n - 1; i++) { 14 | int x; cin >> x; v[x]--; 15 | } 16 | 17 | cout << (find(v.begin(), v.end(), 1) - v.begin()) << '\n'; 18 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1972 - Not Overflow.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | long long x; cin >> x; 7 | cout << (x <= INT_MAX && x >= INT_MIN ? "Yes" : "No") << '\n'; 8 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1981 - Lacked Number.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string s; cin >> s; 7 | int res = 0; 8 | for (int i = 0; i < 9; i++) 9 | res ^= (s[i] - '0') ^ i; 10 | 11 | cout << (res ^ 9) << '\n'; 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/1000 - 1999/1982 - Slimes.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | ios::sync_with_stdio(0); 7 | cin.tie(0); cout.tie(0); 8 | 9 | ll a, b, k; cin >> a >> b >> k; 10 | int res = 0; while (a < b) { res++; a *= k; } 11 | cout << res << '\n'; 12 | cin.ignore(2); return 0; 13 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2014 - Beat The Odds.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | vector v; 7 | 8 | int main() { 9 | int t; cin >> t; while (t--) { 10 | int n; cin >> n; v.resize(n); 11 | for (int& x : v) { cin >> x; } 12 | int even = 0, odd = 0; 13 | for (int& x : v) (x & 1 ? odd : even)++; 14 | 15 | cout << min(even, odd) << '\n'; 16 | } 17 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2021 - Exciting Bets.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | typedef long long ll; 5 | 6 | int main() { 7 | ios::sync_with_stdio(0); 8 | cin.tie(0); cout.tie(0); 9 | 10 | int t; cin >> t; while (t--) { 11 | ll a, b; cin >> a >> b; 12 | if (a == b) { cout << "0 0\n"; continue; } 13 | ll ma = abs(a - b); a %= ma; 14 | cout << ma << ' ' << min(a, ma - a) << '\n'; 15 | } 16 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2024 - RPD and Rap Sheet Easy.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | bool query(int x) { 5 | cout << x << endl; 6 | int r; cin >> r; 7 | return r; 8 | } 9 | 10 | int main() { 11 | int t; cin >> t; while (t--) { 12 | int n, k; cin >> n >> k; 13 | if (query(0)) { continue; } 14 | 15 | for (int i = 1; i < n; i++) 16 | if (query(i ^ (i - 1))) break; 17 | } 18 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2026 - XOR Mixup.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | vector v; 6 | 7 | int main() { 8 | ios::sync_with_stdio(0); 9 | cin.tie(0); cout.tie(0); 10 | 11 | int t; cin >> t; while (t--) { 12 | int n; cin >> n; v.resize(n); 13 | for (auto& x : v) cin >> x; 14 | cout << v.front() << '\n'; 15 | } 16 | 17 | cin.ignore(2); return 0; 18 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2030 - Is It Rated - 2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string s; 7 | while (getline(cin, s)) { 8 | cout << "NO" << endl; 9 | } 10 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2032 - PolandBall and Forest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | vector v; set s; 7 | 8 | int main() { 9 | int n; cin >> n; v.resize(n); 10 | for (auto& x : v) cin >> x; 11 | 12 | int res = 0; 13 | for (int i = 0; i < n; i++) { 14 | if (v[i] == i + 1) { res++; } 15 | else { s.insert(v[i]); } 16 | } 17 | 18 | cout << res + s.size() / 2 << endl; 19 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2037 - Gifts Unjust Division.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | freopen("gift.in", "r", stdin); 6 | ios::sync_with_stdio(0); 7 | cin.tie(0); cout.tie(0); 8 | 9 | int t; cin >> t; while (t--) { 10 | int n; cin >> n; 11 | cout << n / 8 << ' ' << 7 * n / 8 << '\n'; 12 | } 13 | cin.ignore(2); return 0; 14 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2045 - Pizza Time.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | freopen("pizza.in", "r", stdin); 6 | ios::sync_with_stdio(0); 7 | cin.tie(0); cout.tie(0); 8 | 9 | int t; cin >> t; while (t--) { 10 | int n, a; cin >> n >> a; 11 | cout << n - a << '\n'; 12 | } 13 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2052 - Moving Balls.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | freopen("collisions.in", "r", stdin); 7 | ios::sync_with_stdio(0); 8 | cin.tie(0); cout.tie(0); 9 | 10 | int t; cin >> t; while (t--) { 11 | ll n, m; cin >> n >> m; 12 | cout << n * m << '\n'; 13 | } 14 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2056 - Ziko the Rabbit.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | freopen("ziko.in", "r", stdin); 6 | ios::sync_with_stdio(0); 7 | cin.tie(0); cout.tie(0); 8 | 9 | int t; cin >> t; while (t--) { 10 | int n; cin >> n; 11 | cout << (n << 1) - 1 << '\n'; 12 | } 13 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2057 - When.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int k; cin >> k; 6 | if (k < 10) cout << "21:0" << k << '\n'; 7 | else if (k < 60) cout << "21:" << k << '\n'; 8 | else if (k < 70) cout << "22:0" << k - 60 << '\n'; 9 | else cout << "22:" << k - 60 << '\n'; 10 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2062 - The Third Three Number Problem.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); cout.tie(0); 7 | 8 | int t; cin >> t; while (t--) { 9 | int n; cin >> n; 10 | if (n & 1) { cout << -1 << '\n'; continue; } 11 | cout << n / 2 << ' ' << n / 2 << ' ' << 0 << '\n'; 12 | } 13 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2069 - Growth Record.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n, m, x, t, d; cin >> n >> m >> x >> t >> d; 6 | if (m >= x) { cout << t << '\n'; } 7 | else { cout << t - (x - m) * d << '\n'; } 8 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2070 - Counterclockwise Rotation.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | typedef double ld; 6 | const ld PI = 3.14159265358979; 7 | 8 | int main() { 9 | int x, y, d; cin >> x >> y >> d; 10 | ld D = d * PI / 180.0; 11 | cout << fixed << setprecision(6); 12 | cout << x * cos(D) - y * sin(D) << ' '; 13 | cout << x * sin(D) + y * cos(D) << '\n'; 14 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2075 - Round Down the Price.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); cout.tie(0); 7 | 8 | int t; cin >> t; while (t--) { 9 | int n; cin >> n; int cur = 1; 10 | while (cur * 10 <= min(1000000000, n)) { cur *= 10; } 11 | cout << n - cur << '\n'; 12 | } 13 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2082 - YES or YES.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | void change(char& c) { 6 | if (c >= 'A' && c <= 'Z') { c += 'a' - 'A'; } 7 | } 8 | 9 | int main() { 10 | ios::sync_with_stdio(0); 11 | cin.tie(0); cout.tie(0); 12 | 13 | int t; cin >> t; while (t--) { 14 | string s; cin >> s; 15 | for (char& c : s) change(c); 16 | cout << (s == "yes" ? "YES" : "NO") << '\n'; 17 | } 18 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2096 - A Unique Letter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | string s; 7 | 8 | int main() { 9 | ios::sync_with_stdio(0); 10 | cin.tie(0); cout.tie(0); 11 | 12 | string s; cin >> s; 13 | sort(s.begin(), s.end()); 14 | 15 | if (s[0] != s[1]) { cout << s[0] << '\n'; } 16 | else if (s[1] != s[2]) { cout << s[2] << '\n'; } 17 | else { cout << -1 << '\n'; } 18 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2123 - Ancestor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | vector p; 6 | 7 | int main() { 8 | ios::sync_with_stdio(0); 9 | cin.tie(0); cout.tie(0); 10 | 11 | int n; cin >> n; p.resize(n - 1); 12 | for (auto& x : p) { cin >> x; x--; } 13 | 14 | int cur = n - 2, res = 0; 15 | while (cur >= 0) { res++; cur = p[cur] - 1; } 16 | cout << res << '\n'; 17 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2144 - Acyclic Graph Edges.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); cout.tie(0); 7 | 8 | int n, m; cin >> n >> m; while(m--){ 9 | int a, b; cin >> a >> b; 10 | if(a > b) swap(a, b); 11 | cout << a << ' ' << b << '\n'; 12 | } 13 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2153 - Chip Game.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); cout.tie(0); 7 | 8 | int t; cin >> t; while (t--) { 9 | int n, m; cin >> n >> m; 10 | cout << (n % 2 == m % 2 ? "Tonya" : "Burenka") << '\n'; 11 | } 12 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2189 - Middle Letter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | ios::sync_with_stdio(0); 7 | cin.tie(0); cout.tie(0); 8 | 9 | string s; cin >> s; int n = (int)s.size(); 10 | cout << s[n >> 1] << '\n'; 11 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2190 - Modulo Number.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | const ll mod = 998244353; 5 | 6 | int main() { 7 | ios::sync_with_stdio(0); 8 | cin.tie(0); cout.tie(0); 9 | 10 | ll n; cin >> n; 11 | cout << ((n % mod) + mod) % mod << '\n'; 12 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2213 - Isco's House.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | freopen("isco.in", "r", stdin); 6 | ios::sync_with_stdio(0); 7 | cin.tie(0); cout.tie(0); 8 | 9 | int T; cin >> T; while (T--) { 10 | int X, Y, P, Z; cin >> X >> Y >> P >> Z; 11 | cout << (X * Y - Z) * P << '\n'; 12 | } 13 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2222 - Madoka and Strange Thoughts.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); cout.tie(0); 7 | 8 | int t; cin >> t; while (t--) { 9 | int n; cin >> n; 10 | cout << n + (n / 2) * 2 + (n / 3) * 2 << '\n'; 11 | } 12 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2226 - Saturday.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | 7 | map m = { {"Monday", 5}, {"Tuesday", 4}, {"Wednesday", 3}, {"Thursday", 2}, {"Friday", 1} }; 8 | 9 | int main() { 10 | ios::sync_with_stdio(0); 11 | cin.tie(0); cout.tie(0); 12 | 13 | string s; cin >> s; 14 | cout << m[s] << '\n'; 15 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2236 - Five Integers.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | int main() { 7 | ios::sync_with_stdio(0); 8 | cin.tie(0); cout.tie(0); 9 | 10 | vector v(5); 11 | for (auto& x : v) cin >> x; 12 | cout << (set(v.begin(), v.end()).size()) << '\n'; 13 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2237 - Prefix.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | string s, t; 6 | 7 | int main() { 8 | ios::sync_with_stdio(0); 9 | cin.tie(0); cout.tie(0); 10 | 11 | cin >> s >> t; 12 | while (t.size() > s.size()) t.pop_back(); 13 | cout << (t == s ? "Yes" : "No") << '\n'; 14 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2241 - Two Elevators.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); cout.tie(0); 7 | 8 | int t; cin >> t; while (t--) { 9 | int a, b, c; cin >> a >> b >> c; 10 | int f = a, s = abs(b - c) + c; 11 | cout << (f == s ? 3 : f < s ? 1 : 2) << '\n'; 12 | } 13 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2247 - Suffix Array 1.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Problems Archive/2000 - 2999/2247 - Suffix Array 1.cpp -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2248 - Suffix Array 2.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Problems Archive/2000 - 2999/2248 - Suffix Array 2.cpp -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2249 - Substring Search.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Problems Archive/2000 - 2999/2249 - Substring Search.cpp -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2250 - Counting Substrings.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Problems Archive/2000 - 2999/2250 - Counting Substrings.cpp -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2251 - Suffix Array and LCP.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0-jij-0/CompetitiveProgramming/97c068cd64fa973f081fca039f0a55398e743784/Problems Archive/2000 - 2999/2251 - Suffix Array and LCP.cpp -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2252 - Anyway Takahashi.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); cout.tie(0); 7 | 8 | int a, b, c, d; cin >> a >> b >> c >> d; 9 | cout << (a + b) * (c - d) << "\nTakahashi\n"; 10 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2286 - 1-2-4 Test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); cout.tie(0); 7 | 8 | int a, b; cin >> a >> b; 9 | cout << (a | b) << '\n'; 10 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2287 - Hammer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); cout.tie(0); 7 | 8 | int x, y, z; cin >> x >> y >> z; 9 | if (x < 0) { x *= -1; y *= -1; z *= -1; } 10 | 11 | if (x < y || y < 0) { cout << x << '\n'; return 0; } 12 | if (z > y) { cout << "-1\n"; return 0; } 13 | cout << abs(z) + abs(x - z) << '\n'; 14 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2321 - Immobile Knight.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); cout.tie(0); 7 | 8 | int t; cin >> t; while (t--) { 9 | int n, m; cin >> n >> m; 10 | if (n == 1 || m == 1) { cout << "1 1\n"; continue; } 11 | cout << "2 2\n"; 12 | } 13 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2325 - 484558.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | string dig = "0123456789ABCDEF"; 5 | 6 | int main() { 7 | ios::sync_with_stdio(0); 8 | cin.tie(0); cout.tie(0); 9 | 10 | int n; cin >> n; 11 | if (n < 16) { cout << "0" + string(1, dig[n]) << '\n'; } 12 | else { cout << string(1, dig[n / 16]) + string(1, dig[n % 16]) << '\n'; } 13 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2353 - Sum.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); cout.tie(0); 7 | 8 | int t; cin >> t; while (t--) { 9 | int a[3]; cin >> a[0] >> a[1] >> a[2]; 10 | sort(a, a + 3); 11 | cout << (a[0] + a[1] == a[2] ? "YES" : "NO") << '\n'; 12 | } 13 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2354 - Increasing.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); cout.tie(0); 7 | 8 | int t; cin >> t; while (t--) { 9 | int n; cin >> n; vector v(n); 10 | for (auto& x : v) cin >> x; 11 | cout << (n == set(v.begin(), v.end()).size() ? "YES" : "NO") << '\n'; 12 | } 13 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2360 - Password.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); cout.tie(0); 7 | 8 | int t; cin >> t; while (t--) { 9 | int n; cin >> n; 10 | for (int i = 0, x = 0; i < n; i++) cin >> x; 11 | cout << 3 * (10 - n) * (10 - n - 1) << '\n'; 12 | } 13 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2361 - Permutation Value.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); cout.tie(0); 7 | 8 | int t; cin >> t; while (t--) { 9 | int n; cin >> n; vector res(n); 10 | iota(res.begin(), res.end(), 1); 11 | swap(res[1], res[n - 1]); 12 | for (auto& x : res) cout << x << ' '; cout << '\n'; 13 | } 14 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2364 - Cowardly Rooks.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); cout.tie(0); 7 | 8 | int t; cin >> t; while (t--) { 9 | int n, m; cin >> n >> m; 10 | for (int i = 0; i < m; i++) { 11 | int x, y; cin >> x >> y; 12 | } 13 | cout << (m < n ? "YES" : "NO") << '\n'; 14 | } 15 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2379 - The Ultimate Square.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | ios::sync_with_stdio(0); 7 | cin.tie(0); cout.tie(0); 8 | 9 | int t; cin >> t; while (t--) { 10 | int n; cin >> n; 11 | cout << (n + 1) / 2 << '\n'; 12 | } 13 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2382 - Two Permutations.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | cin.tie(0)->sync_with_stdio(0); 6 | 7 | int t; cin >> t; while (t--) { 8 | int n, a, b; cin >> n >> a >> b; 9 | if (a == b && a == n) { cout << "Yes\n"; continue; } 10 | cout << (a + b < n - 1 ? "Yes" : "No") << '\n'; 11 | } 12 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2386 - Wwwvvvvvv.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | cin.tie(0)->sync_with_stdio(0); 6 | 7 | string s; cin >> s; 8 | cout << count(s.begin(), s.end(), 'v') + 9 | 2 * count(s.begin(), s.end(), 'w') << '\n'; 10 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2387 - LOOKUP.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | cin.tie(0)->sync_with_stdio(0); 6 | 7 | string s, t; cin >> s >> t; 8 | int n = (int)s.size(); 9 | cout << (s.find(t) != -1 ? "Yes" : "No") << '\n'; 10 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2389 - Freefall.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef double ld; 4 | 5 | int main() { 6 | cin.tie(0)->sync_with_stdio(0); 7 | 8 | ld A, B; cin >> A >> B; 9 | ld X = pow(A / (2 * B), 2.0 / 3.0) - 1; 10 | ld x1 = floor(X), x2 = ceil(X); 11 | ld res1 = B * x1 + A / (pow(1 + x1, 0.5)); 12 | ld res2 = B * x2 + A / (pow(1 + x2, 0.5)); 13 | cout << fixed << setprecision(6) << min(res1, res2) << '\n'; 14 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2392 - Doremy's Paint.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | cin.tie(0)->sync_with_stdio(0); 6 | 7 | int t; cin >> t; while (t--) { 8 | int n; cin >> n; 9 | for (int i = 0; i < n; i++) { 10 | int x; cin >> x; 11 | } 12 | cout << "1 " << n << '\n'; 13 | } 14 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2393 - Doremy's Perfect Math Class.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | vector v; 5 | 6 | int main() { 7 | cin.tie(0)->sync_with_stdio(0); 8 | 9 | int t; cin >> t; while (t--) { 10 | int n; cin >> n; int g = 0, last = 0; 11 | while (n--) { cin >> last; g = gcd(g, last); } 12 | cout << last / g << '\n'; 13 | } 14 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2396 - Majority.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | cin.tie(0)->sync_with_stdio(0); 6 | 7 | int n, f = 0, a = 0; cin >> n; 8 | for (int i = 0; i < n; i++) { 9 | string s; cin >> s; 10 | (s == "For" ? f : a)++; 11 | } 12 | 13 | cout << (f > a ? "Yes" : "No") << '\n'; 14 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2397 - Postal Card.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | set s; 5 | vector v; 6 | 7 | int main() { 8 | cin.tie(0)->sync_with_stdio(0); 9 | 10 | int n, m; cin >> n >> m; v.resize(n); 11 | for (auto& x : v) { cin >> x; x = x.substr(3, 3); } 12 | while (m--) { string x; cin >> x; s.insert(x); } 13 | int res = 0; for (auto& x : v) res += s.count(x); 14 | cout << res << '\n'; 15 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2401 - Exponential Equation.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | cin.tie(0)->sync_with_stdio(0); 6 | 7 | int t; cin >> t; while (t--) { 8 | int n; cin >> n; 9 | if (n & 1) cout << -1 << '\n'; 10 | else cout << n / 2 << ' ' << 1 << '\n'; 11 | } 12 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2409 - Codeforces Checking.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | string s = "codeforces"; 5 | 6 | int main() { 7 | cin.tie(0)->sync_with_stdio(0); 8 | 9 | int t; cin >> t; while (t--) { 10 | char c; cin >> c; 11 | cout << (s.find(c) != string::npos ? "YES" : "NO") << '\n'; 12 | } 13 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2411 - Prepend and Append.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | string s; 5 | 6 | int main() { 7 | cin.tie(0)->sync_with_stdio(0); 8 | 9 | int t; cin >> t; while (t--) { 10 | int n; cin >> n >> s; 11 | int i = 0, j = n - 1; 12 | while (i < j && (s[i] ^ s[j])) { ++i; --j; } 13 | cout << j - i + 1 << '\n'; 14 | } 15 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2416 - Many A+B problems.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() { 4 | cin.tie(0)->sync_with_stdio(0); 5 | 6 | int n; cin >> n; while (n--) { 7 | int a, b; cin >> a >> b; 8 | cout << a + b << '\n'; 9 | } 10 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2417 - Qualification Contest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | vector v; 5 | 6 | int main() { 7 | cin.tie(0)->sync_with_stdio(0); 8 | 9 | int n, k; cin >> n >> k; v.resize(n); 10 | for (auto& x : v) cin >> x; 11 | sort(v.begin(), v.begin() + k); 12 | for (int i = 0; i < k; i++) 13 | cout << v[i] << '\n'; 14 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2419 - Integer Division.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | const ll mod = 998244353; 5 | 6 | ll DP[200001]; string s; 7 | 8 | int main() { 9 | cin.tie(0)->sync_with_stdio(0); 10 | 11 | int n; cin >> n >> s; DP[0] = 0; ll sum = 1; 12 | for (int i = 1; i <= n; sum = (sum + DP[i++]) % mod) 13 | DP[i] = ((DP[i - 1] * 10) + sum * (s[i - 1] - '0')) % mod; 14 | cout << DP[n] << '\n'; 15 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2420 - Camel Case.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | cin.tie(0)->sync_with_stdio(0); 6 | 7 | string s; cin >> s; 8 | cout << find_if(s.begin(), s.end(), [&](char c) { return c >= 'A' && c <= 'Z'; }) - s.begin() + 1 << '\n'; 9 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2421 - Trimmed Mean.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | vector X; 5 | 6 | int main() { 7 | cin.tie(0)->sync_with_stdio(0); 8 | 9 | int n; cin >> n; X.resize(5 * n); 10 | for (auto& x : X) cin >> x; 11 | sort(X.begin(), X.end()); 12 | cout << fixed << setprecision(5) << accumulate(X.begin() + n, X.begin() + 4 * n, 0.0) / (3.0 * n) << '\n'; 13 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2426 - Alternately.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | cin.tie(0)->sync_with_stdio(0); 6 | 7 | int n; string s; cin >> n >> s; bool ok = true; 8 | for (int i = 1; i < n; i++) 9 | ok = ok && (s[i] != s[i - 1]); 10 | 11 | cout << (ok ? "Yes" : "No") << '\n'; 12 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2427 - Chessboard.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | vector v; 5 | 6 | int main() { 7 | cin.tie(0)->sync_with_stdio(0); 8 | 9 | v.resize(8); for (auto& x : v) cin >> x; 10 | for (int i = 0; i < 8; i++) 11 | for (int j = 0; j < 8; j++) 12 | if (v[i][j] == '*') 13 | cout << char(j + 'a') << 8 - i << '\n'; 14 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2428 - Gap Existence.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | vector A; 5 | 6 | int main() { 7 | cin.tie(0)->sync_with_stdio(0); 8 | 9 | int n, X; cin >> n >> X; A.resize(n); 10 | for (auto& x : A) cin >> x; 11 | 12 | bool ok = false; 13 | set s(A.begin(), A.end()); 14 | for (auto& x : s) 15 | ok = (ok || s.count(x - X)); 16 | 17 | cout << (ok ? "Yes" : "No") << '\n'; 18 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2440 - Attack.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | cin.tie(0)->sync_with_stdio(0); 7 | 8 | ll A, B; cin >> A >> B; 9 | cout << (A + B - 1) / B << '\n'; 10 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2446 - Grasshopper on a Line.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() { 6 | cin.tie(0)->sync_with_stdio(0); 7 | 8 | int t; cin >> t; while (t--) { 9 | int x, k; cin >> x >> k; 10 | if (x % k) { cout << 1 << '\n' << x << '\n'; continue; } 11 | cout << 2 << '\n' << 1 << ' ' << x - 1 << '\n'; 12 | } 13 | } -------------------------------------------------------------------------------- /Problems Archive/2000 - 2999/2447 - Comparison String.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | cin.tie(0)->sync_with_stdio(0); 6 | 7 | int t; cin >> t; while (t--) { 8 | int n; string s; cin >> n >> s; 9 | int i = 0, j = 0, res = 0; 10 | while (i != n) { 11 | while (j < n && s[j] == s[i]) j++; 12 | res = max(res, j - i); i = j; 13 | } 14 | cout << res + 1 << '\n'; 15 | } 16 | } --------------------------------------------------------------------------------