├── .gitattributes ├── 1 A Theatre Square.cpp ├── 1 B Spreadsheets.cpp ├── 1003A.cpp ├── 1003B.cpp ├── 1003C.cpp ├── 1003D.cpp ├── 1005C Summarize to the Power of Two.cpp ├── 1005D Polycarp and Div 3.cpp ├── 1006D.cpp ├── 1006E.cpp ├── 101 representation of decimal number (101 equal to decimal number).cpp ├── 1011A Stages.cpp ├── 1011B Planning The Expedition.cpp ├── 101466B.cpp ├── 101466D.cpp ├── 101466E(Using Hashing).cpp ├── 101466E.cpp ├── 1015C Songs Compression .cpp ├── 1016B Segment Occurrences.cpp ├── 102152C.cpp ├── 102152D.cpp ├── 102569E.cpp ├── 1025B.cpp ├── 102B sum of digit.cpp ├── 1030B Vasya and Cornfield.cpp ├── 1034A Enlarge GCD.cpp ├── 1037C Equalize.cpp ├── 1037D Valid BFS.cpp ├── 103D Cthulhu.cpp ├── 1042C Array Product.cpp ├── 1043A Elections.cpp ├── 1043B Lost Array.cpp ├── 1051B Relatively Prime Pairs.cpp ├── 1054A Elevator or Stairs.cpp ├── 1056A Determine Line.cpp ├── 1056B Divide Candies.cpp ├── 1060A Phone Numbers.cpp ├── 1061A Coins.cpp ├── 1061B Views Matter 1.cpp ├── 1061B Views Matter.cpp ├── 1061C.cpp ├── 1062A A Prank.cpp ├── 1066A.cpp ├── 1066B.cpp ├── 1066C.cpp ├── 1068A Birthday.cpp ├── 1070H BerOS File Suggestion.cpp ├── 1073A Diverse Substring.cpp ├── 1073B Vasya and Books.cpp ├── 1076A Minimizing the String.cpp ├── 1076B Divisor Subtraction.cpp ├── 1076C Meme Problem.cpp ├── 1077A Frog Jumping.cpp ├── 1077B Disturbed People.cpp ├── 1077C Good Array.cpp ├── 1077D Cutting Out.cpp ├── 1080A Petya and Origami.cpp ├── 1081A Definite Game.cpp ├── 1081B Farewell Party.cpp ├── 1084C.cpp ├── 1084D.cpp ├── 1087 - Diablo.cpp ├── 1087A Right-Left Cipher.cpp ├── 1087B Div Times Mod.cpp ├── 1088A Ehab and another construction problem.cpp ├── 1088B Ehab and subtraction.cpp ├── 1088C.cpp ├── 108A Palindromic Times.cpp ├── 1091A New Year and the Christmas Ornament.cpp ├── 1092A Uniform String.cpp ├── 1092B Teams Forming.cpp ├── 1093A Dice Rolling.cpp ├── 1093B Letters Rearranging.cpp ├── 1093C.cpp ├── 1094 - Farthest Nodes in a Tree.cpp ├── 1095A Repeating Cipher.cpp ├── 1095B Array Stabilization.cpp ├── 1095C Powers Of Two.cpp ├── 1095D Circular Dance.cpp ├── 1096A Find Divisible.cpp ├── 1096B Substring Removal.cpp ├── 1096C.cpp ├── 1096D.cpp ├── 1097A Gennady and a Card Game.cpp ├── 1097B Petr and a Combination Lock.cpp ├── 1097C Yuhao and a Parenthesis.cpp ├── 1099A Snowball.cpp ├── 1099C Postcard.cpp ├── 1100A Roman and Browser.cpp ├── 1100B Build a Contest.cpp ├── 1100B Tape.cpp ├── 1101A Minimum Integer.cpp ├── 1101B Accordion.cpp ├── 1102A Integer Sequence Dividing.cpp ├── 1102B Array K-Coloring.cpp ├── 1102C Doors Breaking and Repairing.cpp ├── 1102D Balanced Ternary String.cpp ├── 1104A Splitting into digits.cpp ├── 1104B Game with string.cpp ├── 1104C Grid game.cpp ├── 1105A Salem and Sticks.cpp ├── 1105B Zuhair and Strings.cpp ├── 1105C Ayoub and Lost Array.cpp ├── 1106B.cpp ├── 1106D.cpp ├── 1107A Digits Sequence Dividing.cpp ├── 1107B Digital root.cpp ├── 1107C Brutality.cpp ├── 1108A Two distinct points.cpp ├── 1108B Divisors of Two Integers.cpp ├── 1108D Diverse Garland.cpp ├── 110A(A. Nearly Lucky Number).cpp ├── 110B Lucky String.cpp ├── 1110A Parity.cpp ├── 11113A Sasha and His Trip.cpp ├── 1111B Average Superhero Gang Power.cpp ├── 1111C.cpp ├── 1113B Sasha and Magnetic Machines.cpp ├── 1114A Got Any Grapes.cpp ├── 1118A Water Buying.cpp ├── 1118B Tanya and Candies.cpp ├── 1118C Palindromic Matrix.cpp ├── 1119A Ilya and a Colorful Walk.cpp ├── 1119B.cpp ├── 112A(A. Petya and Strings).cpp ├── 1130A Be Positive.cpp ├── 1130B Two Cakes.cpp ├── 1130C Connect.cpp ├── 1131A Sea Battle.cpp ├── 1132A Regular Bracket Sequence.cpp ├── 1132B Discounts.cpp ├── 1132C Painting the Fence.cpp ├── 1133 Middle of the Contest.cpp ├── 1133A Middle of the Contest.cpp ├── 1133B Preparation for International Women's Day.cpp ├── 1133C Balanced Team.cpp ├── 1133D Zero Quantity Maximization.cpp ├── 1136A Nastya Is Reading a Book.cpp ├── 11370C.cpp ├── 1139C Edgy Trees.cpp ├── 1140C.cpp ├── 1141A.cpp ├── 1141B.cpp ├── 1141C.cpp ├── 1141D.cpp ├── 1143B Nirvana.cpp ├── 1143C Queen.cpp ├── 1143C using dfs.cpp ├── 1144A Diverse Strings.cpp ├── 1144B Parity Alternated Deletions.cpp ├── 1144C Two Shuffled Sequences.cpp ├── 1144D Equalize Them All.cpp ├── 1144F Graph Without Long Directed Paths.cpp ├── 1145A Thanos Sort.cpp ├── 1148A Another One Bites The Dust.cpp ├── 1148D.cpp ├── 1150A Stock Arbitraging.cpp ├── 1150B Tiling Challenge.cpp ├── 1150C Prefix Sum Primes.cpp ├── 1150D Three Religions.cpp ├── 1151B.cpp ├── 1151C.cpp ├── 1151D.cpp ├── 1152A Neko Finds Grapes.cpp ├── 1152B Neko Performs Cat Furrier Transform.cpp ├── 1152C Neko does Maths.cpp ├── 1153A Serval and Bus.cpp ├── 1153B Serval and Toy Bricks.cpp ├── 1153C Serval and Parenthesis Sequence.cpp ├── 1154 Restoring Three Numbers.cpp ├── 1154A.cpp ├── 1154B Make Them Equal.cpp ├── 1154B.cpp ├── 1154C.cpp ├── 1155A Reverse a Substring.cpp ├── 1155B Game with Telephone Numbers.cpp ├── 1155C Alarm Clocks Everywhere.cpp ├── 1156C Match Points.cpp ├── 1157A Reachable Numbers.cpp ├── 1157B Long Number.cpp ├── 1157C Increasing Subsequence.cpp ├── 1157E Minimum Array.cpp ├── 1159A A pile of stones.cpp ├── 1159B Expansion coefficient of the array.cpp ├── 115A Party.cpp ├── 1162 Zoning Restrictions Again.cpp ├── 1162B Double Matrix.cpp ├── 1162C Hide and Seek.cpp ├── 1163A Eating Soup.cpp ├── 1163B Cat Party (Easy Edition).cpp ├── 1165A Remainder.cpp ├── 1165B Polycarp Training.cpp ├── 1165C Good String.cpp ├── 1165D Almost All Divisors.cpp ├── 1165E Two Arrays and Sum of Functions.cpp ├── 1166A Silent Classroom.cpp ├── 1166B All the Vowels Please.cpp ├── 1166C.cpp ├── 1167A Telephone Number.cpp ├── 1167B Lost Numbers.cpp ├── 1167C.cpp ├── 1169A Circle Metro.cpp ├── 1169B Pairs.cpp ├── 1174A Ehab Fails to Be Thanos.cpp ├── 1174B Ehab Is an Odd Person.cpp ├── 1174C Ehab and a Special Coloring Problem.cpp ├── 1174D.cpp ├── 1174DA.cpp ├── 1175A.cpp ├── 1175B.cpp ├── 1175C.cpp ├── 1176A Divide it!.cpp ├── 1176B Merge it!.cpp ├── 1176C.cpp ├── 1180C.cpp ├── 1181A Chunga-Changa.cpp ├── 1181B Split a Number.cpp ├── 1182A.cpp ├── 1182B.cpp ├── 1182C.cpp ├── 1183 Computer Game.cpp ├── 1183 Nearest Interesting Number.cpp ├── 1183B Equalize Prices.cpp ├── 1183D Candy Box (easy version).cpp ├── 1185D.cpp ├── 1186 Vus the Cossack and a Contest.cpp ├── 1186B Vus the Cossack and a Game.cpp ├── 1186C.cpp ├── 1186D.cpp ├── 1187B Letters Shop.cpp ├── 1187C.cpp ├── 1187D Subarray Sorting.cpp ├── 1189A Keanu Reeves.cpp ├── 1189B Number Circle.cpp ├── 1189C.cpp ├── 118A(string task).cpp ├── 118B Present from Lena.cpp ├── 118D.cpp ├── 1194B.cpp ├── 1194C From S To T.cpp ├── 1194C.cpp ├── 1194D.cpp ├── 1195B Sport Mafia.cpp ├── 1196A Three Piles of Candies.cpp ├── 1196B Odd Sum Segments.cpp ├── 1196D2.cpp ├── 1197A DIY Wooden Ladder.cpp ├── 1197B Pillars.cpp ├── 1197C Array Splitting.cpp ├── 1199A City Day.cpp ├── 1200A Hotelier.cpp ├── 1200B Block Adventure.cpp ├── 1201C Maximum Median.cpp ├── 1202D Print a 1337-string.cpp ├── 1203A Circle of Students.cpp ├── 1203B Equal Rectangles.cpp ├── 1203C Common Divisors.cpp ├── 1204 Mislove Has Lost an Array.cpp ├── 1204A BowWow and the Timetable.cpp ├── 1206A Choose Two Numbers.cpp ├── 1206B Make Product Equal One.cpp ├── 1206C Almost Equal.cpp ├── 1206D.cpp ├── 1207A There Are Two Types Of Burgers.cpp ├── 1207B Square Filling.cpp ├── 1208A XORinacci.cpp ├── 1208B Uniqueness.cpp ├── 1208C Magic Grid.cpp ├── 1213A Chips Moving.cpp ├── 1213B Bad Prices.cpp ├── 1213C Book Reading.cpp ├── 1213D Equalizing by Division (hard version).cpp ├── 1214 Badges.cpp ├── 1214A Optimal Currency Exchange.cpp ├── 1214C Bad Sequence.cpp ├── 1216B Shooting.cpp ├── 1216D Swords.cpp ├── 1217A Creating a Character.cpp ├── 1217B Zmei Gorynich.cpp ├── 1217C The Number Of Good Substrings.cpp ├── 121C Lucky Sum.cpp ├── 1220A cards.cpp ├── 1220B Multiplication table.cpp ├── 1221B knight.cpp ├── 1221C Perfect Team.cpp ├── 1221D.cpp ├── 1225C Minimum Diameter Tree.cpp ├── 1228A Distinct Digits.cpp ├── 1228B Filling the Grid.cpp ├── 1228C Primes and Multiplication.cpp ├── 122A(A. Lucky Division).cpp ├── 1230A Dawid and Bags of Candies.cpp ├── 1230B Ania and Minimizing.cpp ├── 1234A Equalize Prices Again.cpp ├── 1234B Social Network (hard version).cpp ├── 1234B Social Network (hardd version).cpp ├── 1234D Distinct Characters Queries.cpp ├── 1235 - Coin Change (IV).cpp ├── 1236A Stones.cpp ├── 1236B Alice and the List of Presents.cpp ├── 1236C Labs.cpp ├── 1238A Prime Subtraction.cpp ├── 1238B Kill 'Em All.cpp ├── 1238C.cpp ├── 1241A CME.cpp ├── 1241B Strings Equalization.cpp ├── 1243A Maximum Square.cpp ├── 1243B Character Swap (Easy Version).cpp ├── 1243B Character Swap (Hard Version).cpp ├── 1243C Tile Painting.cpp ├── 1244A Pens and Pencils.cpp ├── 1244B Rooms and Staircases.cpp ├── 1244D Paint the Tree.cpp ├── 1244E Minimizing Difference.cpp ├── 1244E Minimizing Difference1.cpp ├── 1245B Restricted RPS.cpp ├── 1245C.cpp ├── 1247A Forgetting Things.cpp ├── 1247B TV Subscriptions (Easy Version).cpp ├── 1247B TV Subscriptions (Hard Version).cpp ├── 1247C p-binary.cpp ├── 1249A Yet Another Dividing into Teams.cpp ├── 1249B Books Exchange (easy version).cpp ├── 1249C Good Numbers (Hard version).cpp ├── 1249C Good Numbers (easy version).cpp ├── 1251A Broken Keyboard.cpp ├── 1251A Good ol' Numbers Coloring.cpp ├── 1251B Binary Palindromes.cpp ├── 1251C minimize the number.cpp ├── 1251D Salary Changing.cpp ├── 1253A Single Push.cpp ├── 1253B Silly Mistake.cpp ├── 1253C.cpp ├── 1253D Harmonious Graph.cpp ├── 1255A Changing Volume.cpp ├── 1255B Fridge Lockers.cpp ├── 1255C League of Leesins.cpp ├── 1256A Payment Without Change.cpp ├── 1256B Minimize the Permutation.cpp ├── 1256C Platforms Jumping.cpp ├── 1256D Binary String Minimizing.cpp ├── 1257A Two Rival Students.cpp ├── 1257B Magic Stick.cpp ├── 1257C Dominated Subarray.cpp ├── 1257D Yet Another Monster Killing Problem.cpp ├── 1260B Obtain Two Zeroes.cpp ├── 1260C Infinite Fence.cpp ├── 1263A Sweet Problem.cpp ├── 1263B PIN Codes.cpp ├── 1263C Everyone is a Winner!.cpp ├── 1263D Secret Passwords.cpp ├── 1265A Beautiful String.cpp ├── 1265B Beautiful Numbers.cpp ├── 1265C Beautiful Regional Contest.cpp ├── 1267L.cpp ├── 1269C.cpp ├── 126B Password.cpp ├── 1270A Card Game.cpp ├── 1270B Interesting Subarray.cpp ├── 1270C Make Good.cpp ├── 1271A.cpp ├── 1271B.cpp ├── 1271C.cpp ├── 1272A Three Friends.cpp ├── 1272B Snow Walking Robot.cpp ├── 1272B Yet Another Broken Keyboard.cpp ├── 1272D Remove One Element.cpp ├── 1272E.cpp ├── 1277B Make Them Odd.cpp ├── 1277C As Simple as One and Two.cpp ├── 1278A Shuffle Hashing.cpp ├── 1278B.cpp ├── 1279A New Year Garland.cpp ├── 1279B Verse For Santa.cpp ├── 1279C Stack of Presents.cpp ├── 127B Canvas Frames.cpp ├── 127D Password.cpp ├── 1281A.cpp ├── 1281B.cpp ├── 1282A Temporarily unavailable.cpp ├── 1282B K for the Price of One (Easy Version).cpp ├── 1283A Minutes Before the New Year.cpp ├── 1283B Candies Division.cpp ├── 1284A New Year and Naming.cpp ├── 1284B New Year and Ascent Sequence.cpp ├── 1285D Dr Evil Underscores.cpp ├── 1287A Angry Students.cpp ├── 1287B Hyperset.cpp ├── 1287C Garland.cpp ├── 1288 Deadline.cpp ├── 1288B Yet Another Meme Problem.cpp ├── 1288C Two Arrays.cpp ├── 1291A Even But Not Even.cpp ├── 1291B Array Sharpening.cpp ├── 1291C.cpp ├── 1293A ConneR and the A.R.C. Markland-N.cpp ├── 1293B JOE is on TV!.cpp ├── 1293C NEKO's Maze Game.cpp ├── 1294A Collecting Coins.cpp ├── 1294B Collecting Packages.cpp ├── 1294C Product of Three Numbers.cpp ├── 1294D MEX maximizing.cpp ├── 1295A Display The Number.cpp ├── 1295C Obtain The String.cpp ├── 1295D Same GCDs.cpp ├── 1296A Array with Odd Sum.cpp ├── 1296A Equation.cpp ├── 1296B Food Buying.cpp ├── 1296B Modulo Equality.cpp ├── 1296C Long Beautiful Integer.cpp ├── 1296C Yet Another Walking Robot.cpp ├── 1296D Fight with Monsters.cpp ├── 1296F Berland Beauty.cpp ├── 129A Cookies .cpp ├── 1300A Non-zero.cpp ├── 1300C Anu Has a Function.cpp ├── 1301A Three Strings.cpp ├── 1301B Motarack's Birthday.cpp ├── 1301C Ayoub's function.cpp ├── 1303A Erasing Zeroes.cpp ├── 1303C Perfect Keyboard.cpp ├── 1303C Perfect Keyboard_.cpp ├── 1303D Fill The Bag.cpp ├── 1304A Two Rabbits.cpp ├── 1304B Longest Palindrome.cpp ├── 1304C Air Conditioner.cpp ├── 1305A Kuroni and the Gifts.cpp ├── 1305B Kuroni and Simple Strings.cpp ├── 1305C Kuroni and Impossible Calculation.cpp ├── 1307A Cow and Haybales.cpp ├── 1307B Cow and Friend.cpp ├── 1307C Cow and Message.cpp ├── 1307D Cow and Fields.cpp ├── 1311A Add Odd or Subtract Even.cpp ├── 1311B WeirdSort.cpp ├── 1311C Perform the Combo.cpp ├── 1312 Two Regular Polygons.cpp ├── 1312B Bogosort.cpp ├── 1312C Adding Powers.cpp ├── 1312C Adding Powers.exe ├── 1312C Adding Powers.o ├── 1312D.cpp ├── 1313A Fast Food Restaurant.cpp ├── 1313C Skyscrapers (easy version).cpp ├── 1315A Dead Pixel.cpp ├── 1315B Homecoming.cpp ├── 1315C Restoring Permutation.cpp ├── 1315D Three Integers.cpp ├── 1316B String Modification.cpp ├── 131A(A. cAPS lOCK).c ├── 131A(A. cAPS lOCK).cpp ├── 131B Opposites Attract.cpp ├── 131C The World is a Theatre.cpp ├── 1321A Contest for Robots.cpp ├── 1321B Journey Planning.cpp ├── 1321C.cpp ├── 1322A.cpp ├── 1323A Even Subset Sum Problem.cpp ├── 1323C Unusual Competitions.cpp ├── 1324A.cpp ├── 1324B.cpp ├── 1324C.cpp ├── 1324D.cpp ├── 1324E.cpp ├── 1325A.cpp ├── 1325B.cpp ├── 1325C.cpp ├── 1325D.cpp ├── 1326A.cpp ├── 1326B.cpp ├── 1326C.cpp ├── 1326D2.cpp ├── 1327A.cpp ├── 1327B.cpp ├── 1327C.cpp ├── 1328B.cpp ├── 1329A.cpp ├── 1329B.cpp ├── 1332A.cpp ├── 1332B.cpp ├── 1332C.cpp ├── 1333A.cpp ├── 1333B.cpp ├── 1333C.cpp ├── 1333F.cpp ├── 1334A.cpp ├── 1334B.cpp ├── 1334C.cpp ├── 1335A.cpp ├── 1335B.cpp ├── 1335C.cpp ├── 1335D.cpp ├── 1337A.cpp ├── 1337B.cpp ├── 1337C.cpp ├── 1337D.cpp ├── 1339A.cpp ├── 1339B.cpp ├── 1339C.cpp ├── 1341A.cpp ├── 1341B.cpp ├── 1341C.cpp ├── 1341D.cpp ├── 1342A.cpp ├── 1342B.cpp ├── 1342C.cpp ├── 1343A.cpp ├── 1343B.cpp ├── 1343C.cpp ├── 1343D.cpp ├── 1345A.cpp ├── 1345B.cpp ├── 1345C.cpp ├── 1348A.cpp ├── 1348B.cpp ├── 1348C.cpp ├── 1348D.cpp ├── 1350A.cpp ├── 1350B.cpp ├── 1350C.cpp ├── 1350D.cpp ├── 1351C.cpp ├── 1352A.cpp ├── 1352B.cpp ├── 1352C.cpp ├── 1352D.cpp ├── 1352F.cpp ├── 1352G.cpp ├── 1353A.cpp ├── 1353B.cpp ├── 1353C.cpp ├── 1353D.cpp ├── 1353E.cpp ├── 1354A.cpp ├── 1354B.cpp ├── 1354C.cpp ├── 1354D.cpp ├── 1355A.cpp ├── 1355B.cpp ├── 1355D.cpp ├── 1358A.cpp ├── 1358B.cpp ├── 1358C.cpp ├── 1359A.cpp ├── 1359B.cpp ├── 1359C.cpp ├── 1359D.cpp ├── 1360A.cpp ├── 1360B.cpp ├── 1360C.cpp ├── 1360D.cpp ├── 1360E.cpp ├── 1362A.cpp ├── 1362B.cpp ├── 1362C.cpp ├── 1362D.cpp ├── 1363A.cpp ├── 1363B.cpp ├── 1363C.cpp ├── 1364A.cpp ├── 1364B.cpp ├── 1364C.cpp ├── 1365A.cpp ├── 1365B.cpp ├── 1365C.cpp ├── 1365D.cpp ├── 1366D.cpp ├── 1367A.cpp ├── 1367B.cpp ├── 1367C.cpp ├── 1367D.cpp ├── 1368B.cpp ├── 1368C.cpp ├── 1368D.cpp ├── 1369A.cpp ├── 1369B.cpp ├── 1369C.cpp ├── 1370A.cpp ├── 1370B.cpp ├── 1371A.cpp ├── 1371B.cpp ├── 1371C.cpp ├── 1371D.cpp ├── 1372A.cpp ├── 1372B.cpp ├── 1372C.cpp ├── 1372D.cpp ├── 1373A.cpp ├── 1373B.cpp ├── 1373C.cpp ├── 1373D.cpp ├── 1374A.cpp ├── 1374B.cpp ├── 1374C.cpp ├── 1374D.cpp ├── 1374E1.cpp ├── 1375A.cpp ├── 1375B.cpp ├── 1375C.cpp ├── 1375D.cpp ├── 1379A.cpp ├── 1379B.cpp ├── 1379C.cpp ├── 1379D.cpp ├── 137B Permutation.cpp ├── 1380A.cpp ├── 1380B.cpp ├── 1380C.cpp ├── 1382A.cpp ├── 1382B.cpp ├── 1382C.cpp ├── 1382C2.cpp ├── 1384A.cpp ├── 1384B.cpp ├── 1384C.cpp ├── 1385A.cpp ├── 1385B.cpp ├── 1385C.cpp ├── 1385D.cpp ├── 1388A.cpp ├── 1388B.cpp ├── 1389.cpp ├── 1389A.cpp ├── 1389B.cpp ├── 1389C.cpp ├── 1391A.cpp ├── 1391B.cpp ├── 1391C.cpp ├── 1393A.cpp ├── 1393B.cpp ├── 1393C.cpp ├── 1395A.cpp ├── 1395B.cpp ├── 1395C.cpp ├── 1397A.cpp ├── 1397B.cpp ├── 1397C.cpp ├── 1398A.cpp ├── 1398B.cpp ├── 1398C.cpp ├── 1398D.cpp ├── 1399A.cpp ├── 1399B.cpp ├── 1399C.cpp ├── 1399D.cpp ├── 1400A.cpp ├── 1400B.cpp ├── 1400C.cpp ├── 1400D.cpp ├── 1405A.cpp ├── 1405B.cpp ├── 1405C.cpp ├── 1406A.cpp ├── 1406B.cpp ├── 1406C.cpp ├── 1407A.cpp ├── 1407B.cpp ├── 1407C.cpp ├── 1408A.cpp ├── 1408B.cpp ├── 1408C.cpp ├── 1409A.cpp ├── 1409B.cpp ├── 1409C.cpp ├── 1409D.cpp ├── 1417A.cpp ├── 1417B.cpp ├── 1418A.cpp ├── 1418B.cpp ├── 1418C.cpp ├── 1419A.cpp ├── 1419B.cpp ├── 1419D1_D2.cpp ├── 1420A.cpp ├── 1420B.cpp ├── 1420C.cpp ├── 1426A.cpp ├── 1426B.cpp ├── 1426C.cpp ├── 144A(A Arrival of the Genera).cpp ├── 144C Anagram Search.cpp ├── 145C Lucky Conversion.cpp ├── 155A (A I_love_HP).cpp ├── 155B Combination.cpp ├── 158B(B-Texi).c ├── 158B(B-Texi).cpp ├── 161D Distance in Tree.cpp ├── 165C Another Problem on Strings.cpp ├── 180C.cpp ├── 180E.cpp ├── 180F.cpp ├── 182D Common Divisors.cpp ├── 189A(A Cut Ribbon).cpp ├── 189B Counting Rhombi.cpp ├── 18C strip.cpp ├── 196C Lexicographically Maximum Subsequence.cpp ├── 197C Lexicographically Maximum Subsequence.cpp ├── 2048 Game A.cpp ├── 20C Dijkstra.cpp ├── 214B Hometask.cpp ├── 218B Airport.cpp ├── 218C.cpp ├── 219C Color Stripe.cpp ├── 225C.cpp ├── 230B T-primes.cpp ├── 231A..(A. Team).c ├── 233B Non-square Equation.cpp ├── 235A LCM Challenge.cpp ├── 236B Easy Number Challenge.cpp ├── 237C.cpp ├── 242B Big Segment.cpp ├── 242C.cpp ├── 242E XOR on Segment.cpp ├── 242E.cpp ├── 245B Internet Address.cpp ├── 255B Code Parsing.cpp ├── 256C.cpp ├── 262B Roma and Changing Signs.cpp ├── 263A(A Beautiful Matrix).cpp ├── 263D Cycle in Graph.cpp ├── 265D.cpp ├── 266A(A. Stones on the Table).cpp ├── 268B( Buttons).cpp ├── 268C Beautiful Sets of Points.cpp ├── 26B Regular Bracket Sequence.cpp ├── 270B Multithreading.cpp ├── 271A (A Beautiful Year).cpp ├── 271A.cpp ├── 271B Prime Matrix.cpp ├── 271D.cpp ├── 272c Dima and Staircase.cpp ├── 274A k-Multiple Free Set.cpp ├── 276B Little Girl and Game.cpp ├── 276C Little Girl and Maximum Sum.cpp ├── 276C Little Girl and Maximum Sum1.cpp ├── 276D Little Girl and Maximum XOR.cpp ├── 277C Learning Languages.cpp ├── 279B (Books).cpp ├── 281A(A. Word Capitalization).cpp ├── 282A(A. Bit++).cpp ├── 282C.cpp ├── 283C Cows and Sequence.cpp ├── 284B Cows and Poker Game.cpp ├── 285C Building Permutation.cpp ├── 289B Polo the Penguin and Matrix.cpp ├── 289C Polo the Penguin and Strings.cpp ├── 294B Shaass and Bookshelf.cpp ├── 296C.cpp ├── 296D.cpp ├── 299B Ksusha the Squirrel.cpp ├── 299C Weird Game.cpp ├── 300C.cpp ├── 302B.cpp ├── 305C Ivan and Powers of Two.cpp ├── 313A (A Ilya and Bank Account).CPP ├── 313B Ilya and Queries.cpp ├── 313C Ilya and Matrix.cpp ├── 318A(A Even Odds).cpp ├── 318B Strings of Power.cpp ├── 327A Flipping Game.cpp ├── 32B Borze.cpp ├── 339A(A. Helpful Maths).cpp ├── 339B Xenia and Ringroad.cpp ├── 339C Xenia and Weights.cpp ├── 339C Xenia and Weights1.cpp ├── 339D Xenia and Bit Operations.cpp ├── 347A Difference Row.cpp ├── 347B Fixed Points.cpp ├── 347C.cpp ├── 348C Mafia.cpp ├── 34C.cpp ├── 359B Permutation.cpp ├── 359C Prime Number.cpp ├── 365A Good Number.cpp ├── 368B Sereja and Suffixes.cpp ├── 369E.cpp ├── 371B Fox Dividing Cheese.cpp ├── 371C.cpp ├── 373C Counting Kangaroos is Fun.cpp ├── 374B Inna and Nine.cpp ├── 375B Maximum Submatrix 2.cpp ├── 375D Tree and Queries.cpp ├── 376A Lever.cpp ├── 379(A New Year Candles).cpp ├── 384B.cpp ├── 384E.cpp ├── 384E_.cpp ├── 385B Bear and Strings.cpp ├── 385C Bear and Prime Numbers.cpp ├── 387C.cpp ├── 389B Fox and Cross.cpp ├── 3A Shortest path of the king.cpp ├── 401C.cpp ├── 415B Mashmokh and Tokens.cpp ├── 415C.cpp ├── 415D.cpp ├── 416A Guess a number!.cpp ├── 416C.cpp ├── 41A(A. Translation).cpp ├── 424B.cpp ├── 427B Prison Transfer.cpp ├── 427C Checkposts.cpp ├── 431C k-Tree.cpp ├── 437B.cpp ├── 437C The Child and Toy.cpp ├── 43B Letter.cpp ├── 443A B - Anton and Letters .cpp ├── 443A.cpp ├── 445B DZY Loves Chemistry.cpp ├── 446C DZY Loves Sequences.cpp ├── 447B DZY Loves Strings.cpp ├── 448D Multiplication Table.cpp ├── 450B Jzzhu and Sequences.cpp ├── 451A(A Game With Sticks).cpp ├── 451B v.cpp ├── 454C.cpp ├── 456A (A Laptops).cpp ├── 456B Fedya and Maths.cpp ├── 456C.cpp ├── 459B(B. Pashmak and Flowers).cpp ├── 459C Pashmak and Garden.cpp ├── 459E Pashmak and Graph.cpp ├── 462B Appleman and Card Game.cpp ├── 465C.cpp ├── 466A (A Cheap Travel).cpp ├── 466C - Number of Ways.cpp ├── 467A(A. George and Accommodation).cpp ├── 467B Fedor and New Game.cpp ├── 467C George and Job.cpp ├── 469B Chat Online.cpp ├── 472A(A Calculating Function).cpp ├── 472A(Design Tutorial Learn from Math).cpp ├── 474B Worms.cpp ├── 474D Flowers.cpp ├── 478B Random Teams.cpp ├── 478C Table Decorations.cpp ├── 479A(A. Expression).cpp ├── 482C Diverse Permutation.cpp ├── 483A Counterexample.cpp ├── 483B Friends and Presents.cpp ├── 483C Diverse Permutation.cpp ├── 484A Bits.cpp ├── 485C.cpp ├── 485d.cpp ├── 486A(A Calculating Function).cpp ├── 486B OR in Matrix.cpp ├── 486C.cpp ├── 486D.cpp ├── 489A(A SwapSort).cpp ├── 489B BerSU Ball.cpp ├── 489C ( Given Length and Sum of Digits...).cpp ├── 492B Vanya and Lanterns.cpp ├── 492C Vanya and Exams.cpp ├── 492D Vanya and Computer Game.cpp ├── 499B Lecture.cpp ├── 4A - Watermelon.c ├── 4C Registration system.cpp ├── 501A(A Contest).cpp ├── 501B Misha and Changing Handles.cpp ├── 501B Misha and Changing Handles.vpp.c ├── 501B Misha and Changing Handles_my.cpp ├── 505B.cpp ├── 507B Amr and Pins.cpp ├── 507C.cpp ├── 508B Anton and currency you all know.cpp ├── 50A(A. Domino piling).cpp ├── 510B Fox And Two Dots.cpp ├── 514C.cpp ├── 515B Drazil and His Happy Friends.cpp ├── 515C Drazil and Factorial.cpp ├── 519B(B A and B and Compilation Errors).cpp ├── 519C A and B and Team Training.cpp ├── 520A(A Pangram).cpp ├── 520B Two Buttons.cpp ├── 522B.cpp ├── 525C Ilya and Sticks.cpp ├── 538B(quasi binary).cpp ├── 53C Little Frog.cpp ├── 543A Writing Code.cpp ├── 545B Equidistant String.cpp ├── 545C Woodcutters.cpp ├── 545D Queue.cpp ├── 546D Soldier and Number Game.cpp ├── 549A(A. Soldier and Bananas).cpp ├── 550A(A Two Substrings).cpp ├── 550B Preparing Olympiad.cpp ├── 550C(Divisibility by Eight).cpp ├── 550D Regular Bridge.cpp ├── 552C Vanya and Scales.cpp ├── 554C.cpp ├── 55B Easter Eggs.cpp ├── 560A.cpp ├── 560B.cpp ├── 560D.cpp ├── 567B Berland National Library.cpp ├── 570C.cpp ├── 573A Bear and Poker.cpp ├── 576A Lineland Mail.cpp ├── 576C Vasya and Petya's Game.cpp ├── 577A Multiplication Table.cpp ├── 577B Modulo Sum n.cpp ├── 577B Modulo Sum.cpp ├── 579A Raising Bacteria.cpp ├── 579B.cpp ├── 579D.cpp ├── 580C.cpp ├── 581C.cpp ├── 582B Once Again.c ├── 582B Once Again.cpp ├── 583C.cpp ├── 584B.cpp ├── 584C.cpp ├── 584D Dima and Lisa.cpp ├── 586B Laurenty and Shop.cpp ├── 588B Duff in love.cpp ├── 588C.cpp ├── 58A(A. Chat room).cpp ├── 591B.cpp ├── 598B Queries on a String.cpp ├── 598D Igor In the Museum.cpp ├── 599A(A Patrick and Shopping).cpp ├── 59A (A Word).cpp ├── 5C Longest Regular Bracket Sequence.cpp ├── 600B Queries about less or equal elements.cpp ├── 600C.cpp ├── 602C.cpp ├── 611B.cpp ├── 612C Replace To Make Regular Bracket Sequence.cpp ├── 617(A Elephant).cpp ├── 617B Chocolate.cpp ├── 617D.cpp ├── 617E XOR and Favorite Number.cpp ├── 621B Wet Shark and Bishops.cpp ├── 622A Infinite Sequence.cpp ├── 622B The Time.cpp ├── 622C Not Equal on a Segment.cpp ├── 625C.cpp ├── 629A Far Relative’s Birthday Cake.cpp ├── 629B Far Relative’s Problem.cpp ├── 630C Lucky Numbers.cpp ├── 630D Hexagons.cpp ├── 631B Print Check .cpp ├── 632C.cpp ├── 632D.cpp ├── 633A Ebony and Ivory.cpp ├── 633B.cpp ├── 633C.cpp ├── 633D.cpp ├── 637B Chat Order.cpp ├── 650C Watchmen.cpp ├── 651B Beautiful Paintings.cpp ├── 651C Watchmen.cpp ├── 660C Hard Process.cpp ├── 660D.cpp ├── 661A(A Lazy Caterer Sequence).cpp ├── 664A Complicated GCD.cpp ├── 664B Rebus.cpp ├── 66B Petya and Countryside.cpp ├── 66B Petya and Countryside1.cpp ├── 670B Game of Robots.cpp ├── 670C.cpp ├── 670D1 Magic Powder - 1.cpp ├── 670E.cpp ├── 672B(Different is Good).cpp ├── 675A Infinite Sequence.cpp ├── 675B Restoring Painting.cpp ├── 675C Money Transfers.cpp ├── 676C Vasya and String.cpp ├── 677C.cpp ├── 681A A Good Contest.cpp ├── 681B Economy Game.cpp ├── 682A Alyona and Numbers.cpp ├── 697B Barnicle.cpp ├── 69A(A. Young Physicist).cpp ├── 700B Connecting Universities.cpp ├── 701C.cpp ├── 702B Powers of Two.cpp ├── 706B(B Interesting drink).cpp ├── 706C.cpp ├── 714B Filya and Homework.cpp ├── 714C.cpp ├── 71A (A Way Too Long Words).cpp ├── 721B( Passwords).cpp ├── 721C Journey.cpp ├── 731B Coupons and Discounts .cpp ├── 731C Socks.cpp ├── 732C Sanatorium.cpp ├── 735C.cpp ├── 735D Taxes.cpp ├── 738A Interview with Oleg .cpp ├── 738B Spotlights .cpp ├── 740C.cpp ├── 742A Arpa’s hard exam and Mehrdad’s naive cheat.cpp ├── 742B Arpa’s obvious problem and Mehrdad’s terrible solution.cpp ├── 743B.cpp ├── 749A(Bachgold problem).cpp ├── 750A New Year and Hurry.cpp ├── 750C New Year and Rating.cpp ├── 757B Bash's Big Day.cpp ├── 758B Blown Garland.cpp ├── 75C Modified GCD.cpp ├── 762A(A k-th divisor).cpp ├── 765A Neverending competitions.cpp ├── 765C(C Table Tennis Game 2).cpp ├── 768A - Oath of the Night's Watch .cpp ├── 770B Maximize Sum of Digits.cpp ├── 772B Verse Pattern.cpp ├── 773A Success Rate.cpp ├── 775C PolandBall and Forest.cpp ├── 776B Sherlock and his girlfriend.cpp ├── 7787 A The Monster.cpp ├── 779B Weird Rounding.cpp ├── 779C Dishonest Sellers.cpp ├── 785B Anton and Classes.cpp ├── 785C Anton and Fairy Tale.cpp ├── 797A k-Factorization.cpp ├── 797B Odd sum.cpp ├── 798B Mike and strings.cpp ├── 798C Mike and gcd problem.cpp ├── 799B T-shirt buying.cpp ├── 799C.cpp ├── 801B Valued Keys.cpp ├── 803C Maximal GCD.cpp ├── 804D Minimum number of steps.cpp ├── 805B 3-palindrome.cpp ├── 805C Find Amir.cpp ├── 811A - Vladik and Courtesy .cpp ├── 812A (Sagheer and Crossroads).cpp ├── 812C Sagheer and Nubian Market.cpp ├── 817A Treasure Hunt.cpp ├── 817B.cpp ├── 817C Really Big Numbers.cpp ├── 818D Multicolored Cars.cpp ├── 822A I'm bored with life.cpp ├── 82A(A. Double Cola).cpp ├── 831A Unimodal Array.cpp ├── 834C The Meaningless Game.cpp ├── 835B The number on the board.cpp ├── 839C Journey.cpp ├── 840C Leha and Function.cpp ├── 841B Godsend.cpp ├── 845B.cpp ├── 846B Math Show.cpp ├── 849A.cpp ├── 849B.cpp ├── 849C.cpp ├── 84A Toy Army.cpp ├── 84B.cpp ├── 852A Digits.cpp ├── 861C.cpp ├── 862C.cpp ├── 863D Yet Another Array Queries Problem.cpp ├── 864B Polycarp and Letters.cpp ├── 86D.cpp ├── 870B Maximum of Maximums of Minimums.cpp ├── 870C Maximum splitting.cpp ├── 893A Chess For Three.cpp ├── 893B Beautiful Divisors.cpp ├── 893C Rumor.cpp ├── 894B.c ├── 894B.cpp ├── 894C.cpp ├── 899C.cpp ├── 902B Coloring a Tree.cpp ├── 909B.cpp ├── 911C.cpp ├── 912B.cpp ├── 913 A Modular Exponentiation.cpp ├── 913B Christmas Spruce.cpp ├── 913C.cpp ├── 919D.cpp ├── 922B Magic Forest.cpp ├── 922C Cave Painting.cpp ├── 931B World Cup.cpp ├── 932B Recursive Queries.cpp ├── 932C Permutation.cpp ├── 934A A Compatible Pair.cpp ├── 935C.cpp ├── 946B Weird Subtraction Process.cpp ├── 946C String Transformation.cpp ├── 94B.cpp ├── 950B (Intercepted Message).cpp ├── 95B Lucky Numbers.cpp ├── 961A.cpp ├── 961B.cpp ├── 961C.cpp ├── 977B Two-gram.cpp ├── 977C Less or Equal.cpp ├── 977D Cyclic Components.cpp ├── 977D Divide by three, multiply by two.cpp ├── 977E Cyclic Components.cpp ├── 977F.cpp ├── 978C Letters.cpp ├── 978F Mentors.cpp ├── 979C.cpp ├── 982B Bus of Characters.cpp ├── 982C.cpp ├── 987C Three displays.cpp ├── 988C Equal Sums.cpp ├── 988D Points and Powers of Two.cpp ├── 991C.cpp ├── 991D.cpp ├── 996A Hit the Lottery.cpp ├── A Vladik and flights.cpp ├── A Hexadecimal's theorem 199A.cpp ├── A Holiday Of Equality.cpp ├── A New Year and Hurry.cpp ├── A. Word Correction.cpp ├── All prime factor.cpp ├── Badge.cpp ├── Bracket sequence.cpp ├── Caisa and Sugar 463A.cpp ├── Codeforces (A boy @ girl 236).cpp ├── Cokacola.cpp ├── Comparing Two Long Integers 616A.cpp ├── Contest string.cpp ├── Creating the Contest 1029B.cpp ├── D.cpp ├── Decoding 746B.cpp ├── Diverse Team.cpp ├── Doggo Recoloring.cpp ├── E - System of Equations 214A.cpp ├── Equality 1038A.cpp ├── Football.cpp ├── Fox And Snake.cpp ├── Friends and Presents 483.cpp ├── Godsend 841B.cpp ├── Hamster Farm.cpp ├── Little Pony and Sort by Shift .cpp ├── Lovely Palindromes 688B.cpp ├── Lucky Numbers (easy).cpp ├── Lucky Substring.cpp ├── Lucky Sum 121A.cpp ├── Lucky Sum of Digits 109A.cpp ├── Magnets 344A.cpp ├── Many Equal Substrings 1029A .cpp ├── Measure amgle between minute and hour.cpp ├── Memory and Trident 712B .cpp ├── Nastya Studies Informatics.cpp ├── New Building for SIS.cpp ├── Non-Coprime Partition 1038 B.cpp ├── Number of Ways(466C).cpp ├── Numbers on the Chessboard.cpp ├── Pair of Toys.cpp ├── Palindromic Twist.cpp ├── Points in Segments.cpp ├── Points on the line 940A.cpp ├── Powers of Two 720B .cpp ├── Puzzles 337A.cpp ├── Pythagorus tringle (707C).cpp ├── README.md ├── Single Wildcard Pattern Matching.cpp ├── String Game 778 A .cpp ├── SubXor .cpp ├── Substrings Sort.cpp ├── The Bits.cpp ├── The Rank 1017A .cpp ├── Tommy.cpp ├── Towers 37A.cpp ├── Tricky Sum 598A.cpp ├── Two no-repating number find by XOR.cpp ├── Weakened Common Divisor.cpp ├── Wet Shark and Odd and Even.cpp ├── Wrong Subtraction.cpp ├── `1296D Fight with Monsters.cpp ├── a^b-b^a.cpp ├── add.c ├── b.cpp ├── big multiply.cpp ├── capslock.c ├── capslock.cpp ├── cf( A k-th divisor).cpp ├── cf(A Lazy Caterer Sequence).cpp ├── cocacola.cpp ├── code forces.c ├── codef (706B).c ├── codemarsal-2.cpp ├── codemarsal.cpp ├── cokacola.c ├── contest 1.cpp ├── contest.cpp ├── even odd (kth term difference).cpp ├── factorial when n more then 20.cpp ├── helpful math.cpp ├── input.txt ├── interactive problems └── 101021A Guess the Number.cpp ├── k-string.cpp ├── kjhgf.c ├── kmp.cpp ├── maximam longest substring integer .cpp ├── next round(158).c ├── next round.....c ├── output.txt ├── pair power of 2.cpp ├── palindrom game 276B.cpp ├── pp.c ├── pppp.cpp ├── reverse & add.c ├── siv algoritham for prime.cpp ├── sort string.c ├── sort string.cpp ├── speed.cpp ├── string task....cpp ├── string task.cpp ├── swap sort from and to.cpp ├── test.cpp └── testa.cpp /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /1 A Theatre Square.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | long long m,n,a; 6 | cin>>m>>n>>a; 7 | cout<<((n/a)+1)*(((m)/a)+1); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /1005D Polycarp and Div 3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define ll long long 4 | #define fr(i,n) for (ll i=0;i>s) 11 | { 12 | ll sum=0, cnt=0, res=0; 13 | ll sz=s.size(); 14 | fr(i,sz) 15 | { 16 | n=s[i]-'0'; 17 | n%=3; 18 | sum+=n; 19 | cnt++; ///My assummtion : any 3 digit that are not divisible by 3 their addition divisible by 3, if not there must have 2 digit their addition divided by 3 20 | if(n==0 || sum%3==0 || cnt==3 )res++, cnt=0, sum=0; 21 | } 22 | cout< 2 | using namespace std; 3 | #define ll long long 4 | int main() 5 | { 6 | ll i, j, m, n; 7 | cin>>n; 8 | ll a[n]; 9 | for(i=0; i>a[i]; 10 | sort(a, a+n, greater()); 11 | 12 | ll ans=1 , tmp=1; 13 | for(i=0; i 2 | using namespace std; 3 | #define ll long long 4 | 5 | int main() 6 | { 7 | ll n, m, j, i; 8 | ll t; 9 | cin>>t; 10 | while(t--) 11 | { 12 | cin>>n>>m; 13 | if(n%2==0 or m%2==0)cout<<2< 2 | using namespace std; 3 | #define ll long long 4 | #define fr(i,n) for (ll i=0;i>n; 10 | ll a[n]; 11 | for(i=0; i>a[i]; 12 | 13 | ll mn=0, sum=0, ans=0; 14 | 15 | fr(i, n) 16 | { 17 | ans+=a[i]; 18 | mn=min(mn, ans); 19 | } 20 | mn=abs(mn); 21 | 22 | cout< 8 | #include 9 | using namespace std; 10 | 11 | 12 | #define ll long long 13 | 14 | 15 | int main() 16 | { 17 | ll m,n,t,b,c,d,i,j,k,x,y,z,l,q,r; 18 | 19 | ll cnt=0,ans=0; 20 | cin>>n>>d>>q; 21 | while(q--) 22 | { 23 | cin>>x>>y; 24 | if(x+y>=d && x+y<=(2*n -d) && ( x-y>=-d && x-y<=d ))cout<<"YES"< 2 | using namespace std; 3 | int main() 4 | { 5 | int m,n,i,arr[105], total=0,total1=0,mx=-10; 6 | cin>>n; 7 | for(i=0; i>arr[i]; 10 | total+=arr[i]; 11 | mx=max(mx,arr[i]); 12 | } 13 | 14 | for(i=0; i total) 22 | { 23 | cout< 8 | #include 9 | using namespace std; 10 | 11 | 12 | #define ll long long 13 | #define fr(i,n) for(int i=0;i>n; 30 | a[0]=0; 31 | fr1(i,n)cin>>a[i]; 32 | vectorv; 33 | fr1(i,n){if( ok(i )==true )v.push_back(i); } 34 | 35 | cout< 8 | #include 9 | using namespace std; 10 | 11 | 12 | #define ll long long 13 | #define fr(i,n) for(int i=0;i>n>>m) 19 | { 20 | k=(m-n+1)/2; 21 | cout<<"YES"< 8 | #include 9 | using namespace std; 10 | 11 | #define ll long long 12 | 13 | int main() 14 | { 15 | 16 | ll m,n,t,b,c,d,i,j,k,x,y,z,ans,t1,t2,t3; 17 | while(cin>>x>>y>>z>>t1>>t2>>t3) 18 | { 19 | int ele=(abs(x-z)*t2)+2*t3+(abs(x-y)*t2)+t3; 20 | int str= abs(x-y)*t1; 21 | 22 | if(ele>str) cout<<"No"< 7 | #include 8 | using namespace std; 9 | 10 | #define ll long long 11 | 12 | ll Sum_digit(ll n) 13 | { 14 | int sum = 0; 15 | while (n != 0) 16 | { 17 | sum = sum + n % 10; 18 | n = n/10; 19 | } 20 | return sum; 21 | } 22 | 23 | 24 | int main() 25 | { 26 | ll m,n,i,a=0,b,c,d,cnt=0,ans,x,y; 27 | cin>>n; 28 | 29 | x=log10(n)+1; 30 | 31 | for(i=0; i 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | #define fr(i,n) for (ll i=0;i>n; 12 | ll a[n]; 13 | a[0]=0, a[n+1]=1001; 14 | 15 | fr1(i,n) cin>>a[i]; 16 | 17 | fr1(i,n) 18 | { 19 | if(a[i]==a[i-1]+1 && a[i]==a[i+1]-1 ){cnt++;ans=max(ans,cnt);} 20 | else cnt=0; 21 | } 22 | cout< 9 | #include 10 | using namespace std; 11 | 12 | #define ll long long 13 | #define fr(i,n) for(int i=0;i>n>>m>>k>>l; 18 | 19 | if(m>n)cout<<"-1"<= m-k && m-k>=l ) ans=(n-k)/m; 23 | else ans=-1; 24 | 25 | if(ans >0 )cout< 2 | using namespace std; 3 | #define sortD(a) sort(a,a+n,greater()) 4 | int main() 5 | { 6 | string s; 7 | int a,b,n,l,i,cnt[1000]; 8 | cin>>n>>s; 9 | setst; 10 | l=s.length(); 11 | for(i=1; i 8 | #include 9 | using namespace std; 10 | #define ll long long 11 | #define fr(i,n) for (ll i=0;i>n>>s; 19 | 20 | for(i=0; i s[i+1]) 23 | { 24 | save=i; 25 | break; 26 | } 27 | } 28 | if(save!=-1) 29 | s.erase(s.begin()+ save ); 30 | else 31 | s.erase(s.begin()+ n-1 ); 32 | 33 | cout< 8 | #include 9 | using namespace std; 10 | 11 | #define ll long long 12 | #define fr(i,n) for (ll i=0;i>n; 23 | for(i=2;i<=sqrt(n);i++) 24 | { 25 | if(n%i==0){ k=i; 26 | break;} 27 | } 28 | if(k==0)cout<<"1\n"; 29 | else 30 | cout<<(n-k)/2 +1< 2 | #include 3 | using namespace std; 4 | 5 | #define ll long long 6 | #define fr(i,n) for (ll i=0;i>t; 13 | while(t--) 14 | { 15 | cin>>n; 16 | double mid,low=0, high=sqrt(n)+1e-6; 17 | k=100; 18 | while( k--) 19 | { 20 | mid=(low+high)/2; 21 | if(mid *(n-mid) > n) high=mid; 22 | else low=mid; 23 | } 24 | //cout< 8 | #include 9 | using namespace std; 10 | 11 | 12 | #define ll long long 13 | #define fr(i,n) for (ll i=0;i>t; 22 | while(t--){ 23 | cin>>x>>y>>n; 24 | m=n%2; 25 | p=n/2; 26 | res=((m+p)*x)-p*y; 27 | cout< 2 | #include 3 | using namespace std; 4 | 5 | #define ll long long 6 | #define fr(i,n) for (ll i=0;i cnt; 11 | 12 | int main() 13 | { 14 | ll m,n,i,j=0,res,x,y,p; 15 | 16 | cin>>n; 17 | ll a[n]; 18 | 19 | ll sum=0, ans=0; 20 | 21 | fr(i, n)cin>>a[i] , ans+=a[i] , cnt[a[i] ]++; 22 | 23 | vectorv; 24 | fr(i, n) 25 | { 26 | x=0; 27 | ans-=a[i]; 28 | ll tmp=ans/2; 29 | if(cnt[a[i]]) x=1, cnt[a[i] ]--; 30 | 31 | if(ans%2==0 and cnt[tmp] )v.push_back(i+1); 32 | 33 | ans+=a[i]; 34 | if(x) cnt[a[i] ]++; 35 | } 36 | 37 | if(v.size()) 38 | { 39 | cout< 2 | using namespace std; 3 | #define ll long long 4 | ll cnt[200006]; 5 | mapmp; 6 | priority_queue >v; 7 | 8 | int main() 9 | { 10 | ll m,n,k,i,j; 11 | cin>>n>>k; 12 | ll a[n]; 13 | for(i=0;i>a[i], cnt[a[i]]++, mp[a[i] ]++; 14 | ll d=mp.size(); 15 | 16 | for(i=0;i 2 | using namespace std; 3 | #define ll long long 4 | int main() 5 | { 6 | ll m,n,p,ans,a,b,c; 7 | while(cin>>n>>m) 8 | { 9 | a=n*2/m; 10 | if(n*2%m)a++; 11 | b=n*5/m; 12 | if(n*5%m)b++; 13 | c=n*8/m; 14 | if(n*8%m)c++; 15 | ans=a+b+c; 16 | cout< 2 | using namespace std; 3 | #define ll long long 4 | #define fr1(i,n) for(ll i=1;i<=n;i++) 5 | ll m,n,i,k,j; 6 | int main() 7 | { 8 | ll i,ans,p; 9 | cin>>n>>k; 10 | fr1(i,k-1) if(n%i==0) 11 | ans=k*(n/i)+i; 12 | cout< 2 | using namespace std; 3 | #define ll long long 4 | int main() {ll n; while(cin>>n) n-1?cout< 2 | using namespace std; 3 | #define ll long long 4 | #define pb push_back 5 | #define fr(i,n) for (ll i=0;is; 11 | vectorv; 12 | cin>>n>>m; 13 | ll arr[n]; 14 | 15 | fr(i,n) 16 | { 17 | cin>>arr[i]; 18 | s.insert(arr[i] ); 19 | } 20 | 21 | set< ll > :: iterator it; 22 | for(it = s.begin(); it != s.end(); it++) 23 | v.pb(*it); 24 | 25 | ll ans=v[0]; 26 | 27 | fr(i,m) 28 | { 29 | if(v.size()>i) 30 | { 31 | cout< 2 | using namespace std; 3 | #define ll long long 4 | #define fr(i,n) for (ll i=0;i>n) 12 | { 13 | ll a[n]; 14 | fr1(i, n)cin>>a[i] , a[i]+=N; 15 | 16 | cout< 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | 6 | int main() 7 | { 8 | int m,h; 9 | ll cnt=0,ans=0; 10 | string s; 11 | scanf("%d : %d",&h,&m); 12 | 13 | while(1) 14 | { 15 | m++; 16 | if(m==60){ m=0, h++;} 17 | if( h==24)h=0; 18 | if(h/10==m%10 && h%10==m/10)break; 19 | } 20 | cout< 8 | #include 9 | using namespace std; 10 | 11 | #define ll long long 12 | #define fr1(i,n) for (ll i=1;i<=n;i++) 13 | 14 | int main() 15 | { 16 | ll m,n,t,b,c,d,i,j,k,x,y,z,l,q,r,ans=0; 17 | cin>>y>>b>>r; 18 | 19 | fr1(i,y) 20 | { 21 | if(b>=i+1 && r>=i+2) ans=3*i+3; 22 | } 23 | cout< 2 | using namespace std; 3 | #define ll long long 4 | #define fr(i,n) for (ll i=0;i>t; 11 | while(t--){ 12 | s.clear(), s1.clear(), s3.clear(); 13 | cin>>n>>k; 14 | m=n/k; 15 | ll rem=n%k; 16 | 17 | fr(i,k) s1+=s2[i]; 18 | 19 | if(rem==0){ fr(i,m) {s3+=s1; } sort(s3.begin(),s3.end()); cout< 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | #define dsort(a) sort(a,a+n,greater()) 6 | 7 | int main() 8 | { 9 | ll m,n,t,b,c,d,i,j,k,x,y,z,l,ans=0,q; 10 | cin>>n; 11 | ll a[n]; 12 | for(i=0; i>a[i]; 13 | dsort(a); 14 | for(i=0;i 2 | using namespace std; 3 | 4 | #define ll long long 5 | #define N 200005 6 | 7 | vector v[N]; 8 | bool vis[N]; 9 | ll a[N], b[N]; 10 | 11 | 12 | ll dfs(ll s) 13 | { 14 | vis[s]=true; 15 | cout<>n; 29 | for(i=1;i<=n;i++) 30 | { 31 | ll x, y; 32 | cin>>x>>y; 33 | v[x].push_back(y); 34 | v[y].push_back(x); 35 | 36 | a[i]=x, b[i]=y; 37 | } 38 | 39 | dfs(1); 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /1096A Find Divisible.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | 6 | int main() 7 | { 8 | ll m,n,i,j=1,k,l,r; 9 | cin>>n; 10 | while(n--) 11 | { 12 | cin>>l>>r; 13 | cout< 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | #define fr(i,n) for (ll i=0;iv; 10 | 11 | ll dfs(int i, int sum) 12 | { 13 | //cout<>n; 21 | fr(i,n) cin>>l, v.push_back(l); 22 | 23 | if(dfs(0,0))cout<<"Yes"< 8 | #include 9 | using namespace std; 10 | #define ll long long 11 | 12 | int main() 13 | { 14 | ll i,w,h,s_w,s_h,s2_w,s2_h,ans,stp=0; 15 | 16 | cin>>w>>h; 17 | cin>>s_w>>s_h; 18 | cin>>s2_w>>s2_h; 19 | ans=(w); 20 | 21 | for(i=h; i>=0;i--){ 22 | ans+=i; 23 | if(i==s_h ){ ans-=s_w; if(ans<0 )ans=0; } 24 | if(i==s2_h){ ans-=s2_w; if(ans<0) ans=0;} } 25 | 26 | cout< 8 | #include 9 | using namespace std; 10 | #define ll long long 11 | #define fr(i,n) for (ll i=0;i>n>>m; 21 | 22 | fr(i,m) 23 | { 24 | cin>>x; 25 | a[x]++; 26 | cnt[a[x]]++; 27 | // cout< "<< cnt[a[x]]< 8 | #include 9 | using namespace std; 10 | #define ll long long 11 | 12 | 13 | int main() 14 | { 15 | ll m,n,t,b,c,d,i,j,k,x,y,z,l,q,r; 16 | while(cin>>n) 17 | { 18 | x=(n*(n+1))/2; 19 | if(x%2) cout<<"1"< 2 | #include 3 | using namespace std; 4 | 5 | #define ll long long 6 | #define pfl(x) printf("%lld\n",x) 7 | #define fr(i,n) for (ll i=0;i>n) 12 | { 13 | pfl(n); 14 | fr(i,n)cout<<"1"<<" "; 15 | } 16 | return 0; 17 | } 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /1104C Grid game.cpp: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1105B Zuhair and Strings.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define ll long long 4 | #define fr(i,n) for (ll i=0;i>n>>k>>s; 15 | 16 | ll cnt1=1,ans=0,mx=-1; 17 | 18 | for(i=0;i 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | 6 | int main() 7 | { 8 | ll m,n,t,b,c,d,i,j,k,x,y,z,l,q,r; 9 | cin>>n; 10 | for(i=0; i>k>>x; 13 | cout<<(x+9*(k-1) )< 8 | #include 9 | using namespace std; 10 | 11 | 12 | #define ll long long 13 | 14 | int main() 15 | { 16 | ll m,n,t,b,c,d,i,j,k,x,y,z,l,q,r; 17 | 18 | ll cnt=0,ans=0; 19 | cin>>n>>k; 20 | ll a[n+1]; 21 | for(i=0;i>a[i];} 22 | string s,s1; 23 | cin>>s; 24 | 25 | for(i=0,j=0;i 8 | #include 9 | using namespace std; 10 | 11 | 12 | #define ll long long 13 | 14 | 15 | int main() 16 | { 17 | ll m,n,t,a,b,c,d,i,j,k,x,y,z,l,q,r; 18 | 19 | ll cnt=0,ans=0; 20 | cin>>n; 21 | while(n--) 22 | { 23 | cin>>a>>b>>x>>y; 24 | if(a==x && b==y) 25 | cout< 2 | using namespace std; 3 | int main(){ 4 | string s; long long i,d,cnt=0,len; 5 | cin>>s; 6 | len=s.length(); int a[len]; //cout< 3 | #include 4 | using namespace std; 5 | 6 | 7 | #define ll long long 8 | #define scl(n) cin>>n; 9 | #define scc(c) cin>>c; 10 | #define fr(i,n) for (ll i=0;i>n; 25 | string s="abcd", s1; 26 | 27 | k=n/4; 28 | 29 | fr(i, k) s1+=s; 30 | 31 | k=n%4; 32 | fr(i, k)s1+=s[i]; 33 | 34 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | long long n,k,m; 6 | cin>>n>>k>>m; 7 | long long a[n]; 8 | long long sum = 0; 9 | for(int i=0; i>a[i]; 12 | sum += a[i]; 13 | } 14 | sort(a,a+n); 15 | double cnt1 = 0,ans; 16 | for(int i=0; i< min(n,m+1); i++) 17 | { 18 | cout< 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | 6 | int main() 7 | { 8 | ll m,n,t,a,b,c,d,i,j,k,x,y,z,l,q,r,ex_a,ex_b; 9 | 10 | ll cnt=0,ans=0; 11 | cin>>x>>y>>z>>a>>b>>c; 12 | 13 | if(a>=x) { ex_a= (a-x); b+=ex_a;} 14 | 15 | if(b>=y) { ex_b=(b-y); c+=ex_b; } 16 | 17 | 18 | if(a>=x && b>=y && c>=z )cout<<"YES"< 2 | using namespace std; 3 | int main(){ 4 | string s1,s2; int l,l1,i; 5 | cin>>s1>>s2; 6 | l=s1.length(); 7 | for(i=0;i0) 12 | { 13 | cout<<"1"; 14 | } 15 | else if(s1.compare(s2)<0) 16 | { 17 | cout<<"-1"; 18 | } 19 | else 20 | cout<<"0"; 21 | // if(s1.compare(s2)<0) 22 | // { 23 | // cout<<"-1"; 24 | // } 25 | return 0;} 26 | -------------------------------------------------------------------------------- /1130B Two Cakes.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | #define scl(n) scanf("%lld", &n) 6 | #define scf(n) scanf("%lf", &n) 7 | #define pfl(x) printf("%lld\n",x) 8 | #define md 10000007 9 | #define pb push_back 10 | #define fr(i,n) for (ll i=0;iv[2*n]; 19 | for(i=0;i<2*n;i++) 20 | { 21 | cin>>x; 22 | v[x].pb(i); 23 | } 24 | ans=v[1][0]+v[1][1]; 25 | for(i=2;i<=n;i++) 26 | { 27 | ans+=abs( v[i][0] - v[i-1][0] ) + abs( v[i][1] - v[i-1][1]); 28 | } 29 | pfl(ans); 30 | 31 | return 0; 32 | } 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /1133 Middle of the Contest.cpp: -------------------------------------------------------------------------------- 1 | //! Bismillahi-Rahamanirahim. 2 | /** ========================================** 3 | ** @Author: Md. Abu Farhad ( RUET, CSE'15) 4 | ** @Category: 5 | /** ========================================**/ 6 | 7 | #include 8 | #include 9 | using namespace std; 10 | #define ll long long 11 | #define pn printf("\n") 12 | 13 | 14 | int main() 15 | { 16 | ll m,n,t,i,j,k,x,y,z,l,q,r,t1,t2,t3,h,h1,m1,h2,m3,h3; 17 | 18 | ll cnt=0,ans=0; 19 | scanf("%lld:%lld",&h,&m); 20 | scanf("%lld:%lld",&h1,&m1); 21 | 22 | t1=h*60+m; 23 | t2=h1*60+m1; 24 | 25 | t3=(t1+t2)/2; 26 | 27 | h3=(t3/60); 28 | m3=(t3)%60; 29 | 30 | printf("%02lld:%02lld\n",h3,m3); 31 | 32 | return 0; 33 | } 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /1133A Middle of the Contest.cpp: -------------------------------------------------------------------------------- 1 | //! Bismillahi-Rahamanirahim. 2 | /** ========================================** 3 | ** @Author: Md. Abu Farhad ( RUET, CSE'15) 4 | ** @Category: 5 | /** ========================================**/ 6 | 7 | #include 8 | #include 9 | using namespace std; 10 | #define ll long long 11 | #define pn printf("\n") 12 | 13 | 14 | int main() 15 | { 16 | ll m,n,t,i,j,k,x,y,z,l,q,r,t1,t2,t3,h,h1,m1,h2,m3,h3; 17 | 18 | ll cnt=0,ans=0; 19 | scanf("%lld:%lld",&h,&m); 20 | scanf("%lld:%lld",&h1,&m1); 21 | 22 | t1=h*60+m; 23 | t2=h1*60+m1; 24 | 25 | t3=(t1+t2)/2; 26 | 27 | h3=(t3/60); 28 | m3=(t3)%60; 29 | 30 | printf("%02lld:%02lld\n",h3,m3); 31 | 32 | return 0; 33 | } 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /1133B Preparation for International Women's Day.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | 6 | #define ll long long 7 | #define scl(n) scanf("%lld", &n) 8 | #define scf(n) scanf("%lf", &n) 9 | #define pfl(x) printf("%lld\n",x) 10 | 11 | ll cnt[105]; 12 | 13 | int main() 14 | { 15 | ll m,n,t,b,c,d,i,j,k,x,y,z,l,q,r; 16 | 17 | ll ans=0; 18 | scl(n);scl(k); 19 | for(i=1;i<=n;i++) 20 | { 21 | cin>>x; 22 | cnt[x%k]++; 23 | } 24 | for(i=1;i< (k+1)/2;i++)ans+=min(cnt[k-i],cnt[i] ); 25 | if(k%2==0)ans+=cnt[k/2]/2; 26 | ans+=cnt[0]/2; 27 | pfl(ans*2); 28 | 29 | 30 | return 0; 31 | } 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /1133D Zero Quantity Maximization.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define ll long long 4 | #define scl(n) scanf("%lld", &n) 5 | #define fr(i,n) for (ll i=0;i>n; 13 | ll a[n], b[n]; 14 | fr(i,n)cin>>a[i]; 15 | fr(i,n)cin>>b[i]; 16 | ll ans=0, mx=0; 17 | mapmp; 18 | fr(i,n) 19 | { 20 | if(a[i]==0 and b[i]==0)ans++; 21 | else 22 | { 23 | if(a[i]!=0) 24 | { 25 | mp[ (- 1.0 *b[i] )/ a[i] ]++; 26 | mx= max(mx,mp[ (- 1.0 *b[i] )/ a[i] ] ); 27 | } 28 | } 29 | } 30 | cout<<(mx+ans )< 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | #define scl(n) scanf("%lld", &n) 6 | #define scf(n) scanf("%lf", &n) 7 | #define pfl(x) printf("%lld\n",x) 8 | 9 | ll calc(ll n) 10 | { 11 | //cout<<"rem = "<"<"< "< 2 | using namespace std; 3 | #define ll long long 4 | int main() 5 | { 6 | ll a,b,c; 7 | cin>> a>>b>>c; 8 | ll ans=2* min(a, b )+ 2*c; 9 | if(a!=b)ans++; 10 | cout< 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | #define scl(n) scanf("%lld", &n) 6 | #define fr(i,n) for (ll i=0;i>n) 12 | { 13 | cout<<39< 2 | using namespace std; 3 | #define ll long long 4 | #define fr1(i,n) for(ll i=1;i<=n;i++) 5 | #define fr(i,n) for (ll i=0;i>a>>b) 18 | { 19 | ll div=abs(b-a); 20 | ans=(a*b)/__gcd(a,b); 21 | 22 | fr1(i, sqrt(div)) 23 | { 24 | if(div % i ==0) 25 | { 26 | find_k(i), find_k(div/i); 27 | } 28 | } 29 | cout< 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | int main() 6 | { 7 | ll m,n,i,j,b,c,d; 8 | ll a[5]; 9 | for(i=0;i<4;i++)cin>>a[i]; 10 | sort(a,a+4); 11 | 12 | printf("%lld %lld %lld\n", a[3]-a[0], a[3]-a[1], a[3]-a[2]); 13 | } 14 | -------------------------------------------------------------------------------- /1157A Reachable Numbers.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define ll long long 4 | int main() 5 | { 6 | ll m,n,i,k=0; 7 | cin>>n; 8 | while(n>9) 9 | { 10 | k++,n++; 11 | while(n%10==0)n/=10; 12 | } 13 | k+=9; 14 | cout< 2 | using namespace std; 3 | #define ll long long 4 | #define fr(i,n) for (ll i=0;i>n; 10 | ll a[n+1]; 11 | 12 | fr(i,n)cin>>a[i]; 13 | string s; 14 | 15 | i=0,j=n-1; 16 | ll last=0; 17 | 18 | while(i <=j ) 19 | { 20 | if( a[i] <=last && a[j]<=last ) break; 21 | if((a[i]<=a[j] && a[i] > last ) || ( a[j]<=a[i] && a[j]<=last )) 22 | { 23 | // cout< 2 | using namespace std; 3 | #define ll long long 4 | #define fr(i,n) for (ll i=0;is; 9 | ll m,n,i,j,k; 10 | cin>>n; 11 | ll b[n], a[n]; 12 | fr(i,n)cin>>a[i]; 13 | fr(i,n){cin>>b[i]; s.insert(b[i]); } 14 | fr(i,n) 15 | { 16 | auto x=s.lower_bound(n-a[i]); 17 | 18 | //cout<<*x<<"-- "< 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | #define scl(n) scanf("%lld", &n) 6 | #define fr(i,n) for (ll i=0;i>n; 15 | string s; 16 | cin>>s; 17 | ll sz=s.size(); 18 | ll ans=0; 19 | fr(i,sz) 20 | { 21 | if(s[i]=='+')ans++; 22 | else ans--; 23 | ans=max(0ll, ans); 24 | } 25 | cout< 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | #define scl(n) scanf("%lld", &n) 6 | #define fr(i,n) for (ll i=0;i>n; 15 | ll a[n]; 16 | fr1(i,n)cin>>a[i]; 17 | 18 | fr1(i,n) ans=min(ans, a[i]/ (max(i-1, n-i)) ); 19 | cout< 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | #define scl(n) scanf("%lld", &n) 6 | #define fr(i,n) for (ll i=0;i>n>>k; 15 | 16 | if(k==0)ans=1; 17 | else if(k==n) ans=0; 18 | else 19 | { 20 | if(n/k >= 2)ans=k; 21 | else ans=n-k; 22 | } 23 | 24 | pfl(ans); 25 | } 26 | -------------------------------------------------------------------------------- /1163B Cat Party (Easy Edition).cpp: -------------------------------------------------------------------------------- 1 | 2 | ///********Incomplete************** 3 | 4 | #include 5 | #include 6 | using namespace std; 7 | #define ll long long 8 | #define scl(n) scanf("%lld", &n) 9 | #define fr(i,n) for (ll i=0;i>n; 19 | fr(i,n)cin>>a[i]; cnt[a[i] ]++; 20 | 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /1165A Remainder.cpp: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1165B Polycarp Training.cpp: -------------------------------------------------------------------------------- 1 | //! Bismillahi-Rahamanirahim. 2 | /** ========================================** 3 | ** @Author: Md. Abu Farhad ( RUET, CSE'15) 4 | ** @Category: 5 | /** ========================================**/ 6 | 7 | #include 8 | #include 9 | using namespace std; 10 | 11 | 12 | #define ll long long 13 | #define scl(n) scanf("%lld", &n) 14 | #define fr(i,n) for (ll i=0;i>n; 24 | ll a[n]; 25 | fr(i,n)cin>>a[i]; 26 | sort(a,a+n); 27 | fr(i,n)if(a[i]>=ans)ans++; 28 | 29 | pfl(ans-1); 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /1166C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define ll long long 4 | 5 | int main() 6 | { 7 | ll i ,n; 8 | while(cin>>n) 9 | { 10 | ll a[n]; 11 | for(ll o=0; o>a[o], a[o]=abs(a[o]); 12 | 13 | //Need number of pair such that this eqn hold =>[ min(abs(x-y) , abs(x+y) ) <= x<= y<= max(abs(x-y) , abs(x+y) ) ] 14 | //Formalize the eqn if all ( x, y ) > 0 then y-x<=x<=y<=y+x then ==> x<=y<=2x 15 | //So , All we need to care about x<=2*x how many such pair 16 | 17 | sort(a, a+n); 18 | ll ans=0; 19 | for(i=0; i 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | #define scl(n) scanf("%lld", &n) 6 | int main() 7 | { 8 | 9 | ll m,n,t,b,c,d,i,j,k,x,y,z,l,q,r; 10 | ll cn=0,ans=0; 11 | cin>>m>>n>>x; 12 | i=m%x, j=n%x; 13 | ans=(i+j)/x; 14 | if( ans >=1 ) 15 | cn=x- max(i,j); 16 | ans+=(m/x + n/x ); 17 | cout<< ans << " "< 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | #define scl(n) scanf("%lld", &n) 6 | #define fr(i,n) for (ll i=0;i>a[i]; 21 | asort(a); 22 | ll mid=k+a[0]; 23 | 24 | if(abs(mid-a[0])<=k and abs(mid-a[n-1])<=k )ans=mid; else ans=-1; 25 | 26 | pfl(ans); 27 | } 28 | return 0; 29 | } 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /1186 Vus the Cossack and a Contest.cpp: -------------------------------------------------------------------------------- 1 | //! Bismillahi-Rahamanirahim. 2 | /** ========================================** 3 | ** @Author: Md. Abu Farhad ( RUET, CSE'15) 4 | ** @Category: 5 | /** ========================================**/ 6 | 7 | #include 8 | #include 9 | using namespace std; 10 | #define ll long long 11 | #define scl(n) scanf("%lld", &n) 12 | int main() 13 | { 14 | ll m,n,t,b,c,d,i,j,k,x,y,z,l,q,r; 15 | 16 | ll cnt=0,ans=0; 17 | cin>>n>>m>>k; 18 | 19 | if(n<=m && n<=k)cout<<"YES"< 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | #define scl(n) scanf("%lld", &n) 6 | #define fr(i,n) for (ll i=0;i>n>>s; 14 | x=s.size(); 15 | y=x; 16 | fr(i,x) 17 | { 18 | if(s[i]=='0')cnt++; 19 | else cn++; 20 | } 21 | if(cnt!=cn) cout<<1< 2 | using namespace std; 3 | #define ll long long 4 | #define fr(i,n) for (ll i=0;i>n; 10 | ll a[n]; 11 | fr(i,n)cin>>a[i]; 12 | sort(a,a+n); 13 | 14 | if(a[n-3]+a[n-2] <=a[n-1])cout<<"NO"<=0;i-- )cout< 2 | using namespace std; 3 | int main() 4 | { 5 | char s[101]; 6 | while(gets(s)){ 7 | for(int i=0; i 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n; 7 | cin>>n; 8 | 9 | int gap=n,inc=0,i,g; ///before middle line 10 | for(i=0; i=0; g--) 24 | { 25 | cout<<" "< 2 | using namespace std; 3 | #define ll long long 4 | int main() 5 | { 6 | ll m,n,i,j,k; 7 | cin>>n>>k; 8 | ll x=(n+k); 9 | ll cnt=0; 10 | 11 | while(x !=(cnt*(cnt+1))/2 ) 12 | { 13 | cnt++, x--; 14 | } 15 | cout< 2 | #include 3 | using namespace std; 4 | 5 | 6 | #define ll long long 7 | #define scl(n) scanf("%lld", &n) 8 | #define fr(i,n) for (ll i=0;i>n>>x>>y; 17 | 18 | ll a[n]; 19 | fr1(i,n)cin>>a[i]; 20 | 21 | fr1(i, n) 22 | { 23 | cnt=0; 24 | for (j=i-x; j0 && a[j] 2 | using namespace std; 3 | #define ll long long 4 | #define scl(n) scanf("%lld", &n) 5 | #define fr(i,n) for (ll i=0;i>n; 14 | ll cnt=0; 15 | fr(i,n) 16 | { 17 | fr(j,n) 18 | { 19 | a[i][j]=cnt; 20 | if(cnt+2==(n*n ))cnt=1; 21 | else cnt+=2; 22 | 23 | } 24 | //pn; 25 | } 26 | 27 | fr(i,n){fr(j,n){cout< 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | #define scl(n) scanf("%lld", &n) 6 | #define fr(i,n) for (ll i=0;i>b>>g>>n; 14 | fr(i,n+1) if(i<=b and (n-i)<=g )cnt++; 15 | pfl(cnt); 16 | return 0; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /1217A Creating a Character.cpp: -------------------------------------------------------------------------------- 1 | //! Bismillahi-Rahamanirahim. 2 | /** ========================================** 3 | ** @Author: Md. Abu Farhad ( RUET, CSE'15) 4 | ** @Category: 5 | /** ========================================**/ 6 | #include 7 | #include 8 | using namespace std; 9 | #define ll long long 10 | #define scl(n) scanf("%lld", &n) 11 | #define fr(i,n) for (ll i=0;i>x; 19 | while(x--) 20 | { 21 | ll ans=0; 22 | cin>>n>>m>>k; 23 | 24 | ll x=0,y=k, p,q; 25 | while(x<=y) 26 | { 27 | ll mid=(x+y)/2; 28 | if(n+mid > (m+(k-mid ) ) ) y=mid-1, ans=( k-mid+1 ); 29 | else x=mid +1; 30 | } 31 | 32 | pfl(ans); 33 | 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /1225C Minimum Diameter Tree.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define ll long long 5 | int main() 6 | { 7 | ll i,p, j, k, n; 8 | cin>>n>>p; 9 | 10 | for(i=0;i<32;i++) 11 | { 12 | ll tmp=n-i*p; 13 | 14 | ll bit=__builtin_popcount(tmp); 15 | 16 | if(i>=bit and tmp >= i ){cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int n; 6 | cin>>n; 7 | if(n%4==0||n%7==0||n%47==0||n%744==0||n%74==0||n%477==0||n%747==0||n%447==0||n%474==0){ 8 | cout<<"YES"; 9 | } 10 | else cout<<"NO"; 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /1230A Dawid and Bags of Candies.cpp: -------------------------------------------------------------------------------- 1 | //! Bismillahi-Rahamanirahim. 2 | /** ========================================** 3 | ** @Author: Md. Abu Farhad ( RUET, CSE'15) 4 | ** @Category: 5 | /** ========================================**/ 6 | 7 | #include 8 | #include 9 | using namespace std; 10 | 11 | 12 | #define ll long long 13 | #define scl(n) scanf("%lld", &n) 14 | #define fr(i,n) for (ll i=0;i>a>>b>>c>>d; 23 | 24 | if((a+b)==(c+d) || (a+c)==(b+d) || ( a+d)==(b+c) || a==(b+c+d) ||b==(a+c+d) || c==(b+a+d) || d==(b+c+a) )cout<<"YES"< 2 | using namespace std; 3 | 4 | #define ll long long 5 | ll md= 1e+7; 6 | 7 | ll big(ll x,ll y) 8 | { 9 | if(y==0)return 1; 10 | if(y%2)return (x*big(x, y-1) )%md; 11 | else return (big(x, y/2)*big(x, y/2))%md; 12 | } 13 | 14 | int main() 15 | { 16 | ll m,n,i,j; 17 | cin>>n>>m; 18 | cout<< big( big(2, m )-1, n )%md< 7 | #include 8 | using namespace std; 9 | #define ll long long 10 | #define scl(n) scanf("%lld", &n) 11 | int main() 12 | { 13 | ll m,n,i,j; 14 | cin>>i; 15 | while(i--) 16 | { 17 | scl(m), scl(n); 18 | 19 | if(m%2==0 and n%2==0)cout<<"YES"<=2)cout<<"YES"< 8 | #include 9 | using namespace std; 10 | #define ll long long 11 | 12 | int main() 13 | { 14 | ll m,n,u,i; 15 | cin>>i; 16 | while(i--) 17 | { 18 | cin>>n; 19 | 20 | if(n==2)cout<<2< 2 | using namespace std; 3 | #define ll long long 4 | 5 | int main() 6 | { 7 | ll i,j,m,n,t; 8 | cin>>t; 9 | while(t--) 10 | { 11 | double a,b,c,d,k; 12 | cin>>a>>b>>c>>d>>k; 13 | ll cnt=ceil(a/c); 14 | ll cn=ceil(b/d); 15 | if(cn+cnt <=k) cout< 2 | using namespace std; 3 | #define ll long long 4 | #define fr(i,n) for (ll i=0;i>t; 10 | while(t--) 11 | { 12 | string s; 13 | cin>>n>>s; 14 | ll cnt=0,zro=0, one=0,ans=0,lzro=0, rzro=0, left=0, right=0; 15 | 16 | fr(i,n)if(s[i]=='0')zro++; else one++; 17 | 18 | 19 | fr(i,n)if(s[i]!='1'){lzro++; left++; }else break; 20 | 21 | for(i=n-1 ; i>=0; i--)if(s[i]!='1'){rzro++; right++;} else break; 22 | 23 | if(zro==n)ans=n; 24 | else if(s[0]=='1' or s[n-1]=='1')ans=2*n; 25 | else 26 | { 27 | if(lzro >=rzro) 28 | { 29 | ans=(n-rzro)*2; 30 | } 31 | else ans=(n-lzro)*2; 32 | } 33 | 34 | cout< 7 | #include 8 | using namespace std; 9 | #define ll long long 10 | #define scl(n) scanf("%lld", &n) 11 | #define scc(c) scanf(" %c", &c); 12 | #define fr(i,n) for (ll i=0;i>m>>n; 19 | if(m==n )cout<n and n*10-m==1)cout< 2 | using namespace std; 3 | #define ll long long 4 | int main() 5 | { 6 | ll m,n,i,j,k; 7 | cin>>k; 8 | while(k--) 9 | { 10 | cin>>n; 11 | ll res=1, p=3; 12 | while(res=n)res-=p; 20 | p/=3; 21 | } 22 | cout< 3 | #include 4 | using namespace std; 5 | #define ll long long 6 | #define scl(n) scanf("%lld", &n) 7 | #define scc(c) scanf(" %c", &c); 8 | #define fr(i,n) for (ll i=0;i 1 )return 0; 14 | return f(n/3); 15 | } 16 | 17 | int main() 18 | { 19 | ll m,n,t,b,c,d,i,j,k,x,y,z,l,q,r; 20 | scl(t); 21 | while(t--) 22 | { 23 | scl(n); 24 | while( f(n) !=1)n++; 25 | cout< 2 | using namespace std; 3 | #define fr(i,n) for (ll i=0;i>t; 10 | while(t--) 11 | { 12 | string s; 13 | cin>>s; 14 | s+="#"; 15 | vectorv; 16 | for(i=0; ist; 24 | fr1(i, v.size()-1)st.insert(v[i]); for(auto it: st)cout< 2 | using namespace std; 3 | #define fr(i,n) for (ll i=0;i>t; 10 | while(t--) 11 | { 12 | ll one=0, zro=0, cnt=0, ans=0; 13 | cin>>n; 14 | 15 | vector v; 16 | fr(j, n) 17 | { 18 | string s; 19 | cin>>s; 20 | fr(i, s.size()){if(s[i]=='1')one++; else zro++;} 21 | v.push_back(s.size()); 22 | } 23 | sort(v.begin(), v.end()); 24 | 25 | ll pr=one/2+zro/2; 26 | fr(i, v.size()) 27 | { 28 | ll need=v[i]/2; 29 | if(need <=pr)pr-=need, ans++; 30 | } 31 | cout< 2 | using namespace std; 3 | #define ll long long 4 | #define fr(i,n) for (ll i=0;i>t; 11 | while(t--) 12 | { 13 | string s, s1, ans="", od, ev; 14 | cin>>s; 15 | fr(i, sz(s)) 16 | { 17 | if( (s[i]-'0' )%2!=0)od+=s[i]; else ev+=s[i]; 18 | } 19 | i=j=0; 20 | /* 21 | while(i 2 | using namespace std; 3 | #define ll long long 4 | #define fr(i,n) for (ll i=0;i>k; 12 | while(k--) 13 | { 14 | ll m,n,i,j,x,y; 15 | cin>>n; 16 | vector v(n+1, 0); 17 | ll a[n]; 18 | fr1(i,n)cin>>a[i]; 19 | ll ans=n+1; 20 | fr1(i, n) 21 | { 22 | if(v[ a[i] ]>0) 23 | { 24 | x=i- v[a[i] ]+1; 25 | ans=min(ans, x); 26 | } 27 | v[ a[i]]=i; 28 | } 29 | 30 | if(ans>n)ans=-1; 31 | cout< 2 | using namespace std; 3 | #define ll long long 4 | 5 | int main() 6 | { 7 | ll i, j, k, n; 8 | string s, s1 , b; 9 | cin>>n>>k>>s; 10 | 11 | b=s; 12 | for(i=k ; i=s)cout<=0; i--) 19 | { 20 | if(b[i]=='9' )b[i]='0'; 21 | else 22 | { 23 | b[i]++; 24 | break; 25 | } 26 | } 27 | 28 | for(i=k ; i 2 | using namespace std; 3 | #define ll long long 4 | #define fr(i,n) for (ll i=0;i>n; 12 | ll a[n]; 13 | 14 | vectorv; 15 | 16 | for(i=0;i>a[i]; 19 | cnt[a[i] ]++; 20 | 21 | } 22 | 23 | 24 | for(i=1; i<=105; i++) if(cnt[i]>=2 )v.push_back(cnt[i] ); 25 | 26 | fr(i, v.size() ) ans+=(v[i]/2 ); 27 | 28 | ans/=2; 29 | cout< 8 | #include 9 | using namespace std; 10 | 11 | 12 | #define ll long long 13 | #define scl(n) cin>>n; 14 | #define scc(c) cin>>c; 15 | #define fr(i,n) for (ll i=0;i>n) 22 | { 23 | double ans=0; 24 | for(double i=1; i<=n;i++) ans+=(1/i); 25 | printf("%.15lf\n", ans); 26 | } 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /1293C NEKO's Maze Game.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define ll long long 4 | #define fr(i,n) for (ll i=0;i>n>>q; 12 | ll cnt=0; 13 | 14 | fr(i, q) 15 | { 16 | cin>>x>>y; 17 | 18 | if( vis[x][y]) 19 | { 20 | if(vis[3-x][y-1])cnt++; 21 | if(vis[3-x][y])cnt++; 22 | if(vis[3-x][y+1])cnt++; 23 | 24 | vis[x][y]=false; 25 | } 26 | else 27 | { 28 | if(vis[3-x][y-1])cnt--; 29 | if(vis[3-x][y])cnt--; 30 | if(vis[3-x][y+1])cnt--; 31 | 32 | vis[x][y]=true; 33 | } 34 | 35 | if(cnt)cout<<"NO"< 2 | using namespace std; 3 | #define ll long long 4 | #define fr(i,n) for (ll i=0;i>n) 21 | { 22 | ll x, y; 23 | x=2*n; 24 | y=n; 25 | if( n%2==0 and n!=2)cout< 2 | using namespace std; 3 | #define ll long long 4 | #define fr(i,n) for (ll i=0;i>n>>m) 13 | { 14 | ll a[n], b[n]; 15 | fr(i, n)cin>>a[i]; 16 | fr(i,n)cin>>b[i]; 17 | ll x, y; 18 | sort(a, a+n), sort(b, b+n); 19 | 20 | ll dif[n]; 21 | ll mn=1e15; 22 | set s; 23 | fr(i, n)dif[i]=b[i]-a[i], s.insert(dif[i]); 24 | vector v; 25 | 26 | for(auto it: s)v.push_back(it); 27 | 28 | 29 | 30 | ll cnt=0; 31 | fr(i, n)if(b[i]-a[i]==0)cnt++; 32 | 33 | if(cnt==n)cout<<0< 2 | using namespace std; 3 | int main() 4 | { 5 | string a,b; 6 | int i,l,cnt=0; 7 | cin>>a; 8 | l=a.length(); 9 | for(i=0;i 3 | #include 4 | using namespace std; 5 | 6 | 7 | #define ll long long 8 | #define scl(n) cin>>n; 9 | #define scc(c) cin>>c; 10 | #define fr(i,n) for (ll i=0;i>t; 20 | while(t--) 21 | { 22 | ll m,n,b,c,d,i,j,k,x,y,z,l,q,r; 23 | string s,s1, s2, s3, s4; 24 | 25 | ll cnt=0,ans=0,sum=0; 26 | scl(n); 27 | ll a[n]; 28 | 29 | 30 | cout<<1<<" "< 3 | #include 4 | using namespace std; 5 | #define ll long long 6 | #define fr(i,n) for (ll i=0;i>t; 13 | while(t--) 14 | { 15 | ll m, n; 16 | cin>>n>>m; 17 | 18 | fr1(i, n) 19 | { 20 | fr1(j, m) 21 | { 22 | if(i==n and j==m)cout<<'W'; 23 | else cout<<'B'; 24 | } 25 | pn; 26 | } 27 | } 28 | 29 | return 0; 30 | } 31 | 32 | ///Before submit=> 33 | /// *check for integer overflow,array bounds 34 | /// *check for n=1 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /1333C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define ll long long 5 | map mp; 6 | 7 | int main() 8 | { 9 | ll m, n, i, j; 10 | ll t; 11 | 12 | ll sm=0 , mx=0, ans=0; 13 | mp[0]=1; 14 | cin>>n; 15 | for(i=1; i<=n; i++) 16 | { 17 | cin>>m; 18 | sm+=m; 19 | 20 | cout< 2 | using namespace std; 3 | #define ll long long 4 | #define scl(n) scanf("%lld",&n) 5 | #define scc(c) scanf("%c",&c) 6 | #define fr(i,n) for (ll i=0;i>t; 13 | while(t--) 14 | { 15 | ll m,n,b,c,d,i,j,k,x,y,z,l,q,r; 16 | //string s,s1, s2, s3, s4; 17 | 18 | ll cnt=0,ans=0,sum=0; 19 | ll a[10][10]; 20 | 21 | string s[10]; 22 | 23 | fr(i, 9)cin>>s[i]; 24 | 25 | fr(i, 9)fr(j, 9)if(s[i][j] =='3' ){s[i][j]='1';break;} 26 | 27 | //cout< 38 | /// *check for integer overflow,array bounds 39 | /// *check for n=1 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /1341C.cpp: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1342C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define ll long long 4 | 5 | ll total, lcm, a, b; 6 | ll calc(ll n ) 7 | { 8 | return (n/lcm)*total + max(0ll , n%lcm - b +1 ); 9 | } 10 | 11 | int main() 12 | { 13 | ll m, t, n, i , j ; 14 | cin>>t; 15 | while(t--) 16 | { 17 | vectorv; 18 | ll q; 19 | cin>>a>>b>>q; 20 | 21 | if(a>b)swap(a, b); 22 | 23 | lcm=a*b/__gcd(a, b); 24 | total=lcm- b; 25 | 26 | while(q--) 27 | { 28 | ll l , r; 29 | cin>>l>>r; 30 | 31 | ll ans=calc( r ) - calc( l-1 ) ; 32 | v.push_back(ans); 33 | } 34 | for(auto it : v)cout< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | long long N, K, mx = 0; 7 | cin >> N >> K; 8 | if(K >= 2e5) 9 | { 10 | puts("-1"); 11 | return 0; 12 | } 13 | for(long long i = 1 ; i * i <= N ; ++i) 14 | if(N % i == 0) 15 | { 16 | if(N / i >= K * (K + 1) / 2) 17 | mx = max(mx, i); 18 | if(i >= K * (K + 1) / 2) 19 | mx = max(mx, N / i); 20 | } 21 | if(mx == 0) 22 | puts("-1"); 23 | else 24 | { 25 | N /= mx; 26 | for(int i = 1 ; i < K ; ++i) 27 | { 28 | N -= i; 29 | cout << i * mx << ' '; 30 | } 31 | cout << N * mx; 32 | } 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /1362D.cpp: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1367D.cpp: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1379C.cpp: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /137B Permutation.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define ll long long 4 | #define fr(i,n) for (ll i=0;i>n; 10 | sets; 11 | fr(i,n)cin>>k, s.insert(k), mx=max(mx, k); 12 | ll cnt=0; 13 | for(auto it: s) if( it <=n)cnt++; 14 | 15 | cout< 2 | using namespace std; 3 | int main(){ 4 | int i,j,n,cnt=0,Min,Max; 5 | cin>>n; 6 | int k[n]; 7 | for(i=0;i>k[i]; 9 | if(i==0){ 10 | Max=k[i]; 11 | Min=k[i]; } 12 | 13 | if(k[i]Max){ 17 | Max=k[i]; cnt++; 18 | }} 19 | cout< 2 | int main() 3 | { 4 | int n,m,r,d=0,i,f,j,t; 5 | scanf("%d",&n); 6 | int a[n]; 7 | for(i=0;i 2 | #include 3 | using namespace std; 4 | 5 | #define ll long long 6 | #define scl(n) scanf("%lld", &n) 7 | #define scf(n) scanf("%lf", &n) 8 | #define pfl(x) printf("%lld\n",x) 9 | #define md 10000007 10 | #define pb push_back 11 | #define fr(i,n) for (ll i=0;i>k>>s; 21 | l=s.size(); 22 | cnt[0]=1; 23 | fr(i, l) 24 | { 25 | if(s[i]=='1' )one++; 26 | if( one>=k ) ans+=cnt[one-k]; 27 | ++cnt[one]; 28 | } 29 | pfl(ans); 30 | 31 | return 0; 32 | } 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /180C.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #pragma GCC optimize("Ofast") 5 | #pragma GCC target("avx,avx2,fma") 6 | using namespace std; 7 | #define ll long long 8 | #define fr(i,n) for (ll i=0;i>s; 20 | n=l(s); 21 | fr(i, n) 22 | { 23 | if(s[i]>='a' and s[i]<='z' )cnt++; 24 | else if(cnt> 0 )cnt--, ans++; 25 | } 26 | cout< 34 | /// *check for integer overflow,array bounds 35 | /// *check for n=1 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /189A(A Cut Ribbon).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define ll long long 4 | #define fr(i,n) for (ll i=0;i>n>>a>>b>>c) 10 | { 11 | ll ans=-1; 12 | fr(i,n+1) 13 | fr(j,n+1) 14 | { 15 | k=n-(a*i+b*j); 16 | if(k>=0 && k%c==0 ) ans=max(ans, (i+j+k/c) ); 17 | } 18 | pfl(ans); 19 | } 20 | return 0; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /189B Counting Rhombi.cpp: -------------------------------------------------------------------------------- 1 | //! Bismillahi-Rahamanirahim. 2 | /** ========================================** 3 | ** @Author: Md. Abu Farhad ( RUET, CSE'15) 4 | ** @Category: 5 | /** ========================================**/ 6 | 7 | #include 8 | #include 9 | using namespace std; 10 | 11 | 12 | #define ll long long 13 | #define scl(n) scanf("%lld", &n) 14 | #define fr(i,n) for (ll i=0;i>x>>y) 25 | { 26 | c=x/2, d=y/2; 27 | e=x%2, f=y%2; 28 | if(c>0 && d>0)pfl(c*d *(c+e)*(d+f) ); 29 | else pfl(ans); 30 | } 31 | return 0; 32 | } 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /18C strip.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define ll long long 4 | 5 | int main() 6 | { 7 | ll m,n,i,j,k; 8 | while(cin>>n) 9 | { 10 | ll ans=0, cnt=0, res=0; 11 | ll a[n]; 12 | for(i=0; i>a[i], ans+=a[i]; 13 | for(i=0;i 2 | using namespace std; 3 | #define ll long long 4 | int main() 5 | { 6 | ll j,i,m,n; 7 | //while(1){ 8 | cin>>n>>m; 9 | ll ans=0, cnt=0, mx=0, mn=0,x,y; 10 | ll a[m]; 11 | y=n; 12 | for(i=0;i>a[i], ans+=a[i]; 13 | sort(a, a+m); 14 | /// for mini 15 | for(i=0;i0;i++) 16 | { 17 | x=a[i]; 18 | while(x>0 and n>0)mn+=x, x--, n--; 19 | } 20 | 21 | ///for maxi 22 | 23 | n=y; 24 | for(i=0; i 2 | using namespace std; 3 | 4 | #define ll long long 5 | #define N 100005 6 | 7 | vector >v; 8 | bool vis[N]; 9 | ll n; 10 | 11 | void dfs(ll s) 12 | { 13 | vis[s]=1; 14 | for(ll i=0;i>n; 26 | for(i=0;i>x>>y; 29 | v.push_back({x, y}); 30 | } 31 | 32 | memset(vis , 0 , sizeof vis); 33 | 34 | for(i=0;i 2 | int main(){ 3 | 4 | int i,a,c,v,b,cnt=0; 5 | scanf("%d",&v); 6 | for(i=0;i 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | #define scl(n) scanf("%lld", &n) 6 | #define fr(i,n) for (ll i=0;i=n ) 31 | { 32 | if(x*x+ digit_sum(x)*x ==n){cout< 2 | using namespace std; 3 | 4 | void read_arr(int Array[10][10],int r,int c){ 5 | int i,j; 6 | for(i=1;i<=r;i++){ 7 | for(j=1;j<=c;j++){ scanf("%d",&Array[i][j]); }}} 8 | 9 | struct location { int x; int y; }; 10 | 11 | int main() 12 | { 13 | int temp = 0; 14 | location l; 15 | int a,b,c=5,d,m,n,i,j,Array[10][10],m2[10][10],cnt=0,r=5,N=5,M=5; 16 | //cin>>i,j; 17 | read_arr(Array,r,c); 18 | 19 | for(int i = 1; i <=5; i++) 20 | for(int j = 1; j<=5; j++) 21 | if(temp < Array[i][j]) 22 | { 23 | temp = Array[i][j]; 24 | l.x = i; 25 | l.y = j; 26 | } 27 | // cout<<"Maximum Value is "< 2 | using namespace std; 3 | int main() 4 | { 5 | char a[100]; 6 | int i,n,cnt=0; 7 | cin>>n; 8 | for(i=0; i>a[i]; 11 | } 12 | 13 | for(i=0; i 2 | using namespace std; 3 | #define ll long long 4 | int main() 5 | { 6 | ll m,n,i,j,k; 7 | cin>>m>>n; 8 | n=min(m,n); 9 | cout< 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | #define scl(n) scanf("%lld", &n) 6 | #define fr(i,n) for (ll i=0;i>a[i]; 18 | for(i=n-1;i>=0;i--) if(a[i] 2 | using namespace std; 3 | int main() 4 | { 5 | int year; 6 | int a,b,c,d; 7 | cin >> year; 8 | while(1){ 9 | year++; 10 | a=year/1000; 11 | b=year/100; 12 | b=b%10; 13 | c=year/10; 14 | c=c%10; 15 | d=year%10; 16 | if(a!=b && a!=c && a!=d && b!=c && b!=d && c!=d) 17 | break; 18 | } 19 | cout<< year << endl; 20 | return 0; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /271A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int a,b,c,d,e,f,y; 6 | cin>>y; 7 | while(1){ 8 | y++; 9 | a=y/1000; 10 | b=y/100; 11 | c=b%10; d=y/10; e=d%10; f=y%10; 12 | if(a!=c&&a!=e&&a!=f&&c!=e&&c!=f&&e!=f) break; 13 | 14 | } 15 | cout< 2 | using namespace std; 3 | #define ll long long 4 | #define fr(i,n) for (ll i=0;i>n; 11 | ll a[n]; 12 | fr1(i,n)cin>>a[i]; 13 | 14 | ll l=0,w=0,h=0, h1=0; 15 | cin>>m; 16 | while(m--) 17 | { 18 | cin>>w>>h; 19 | l=max(l+h1, a[w]); 20 | cout< 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | 6 | ll cnt[30]; 7 | int main() 8 | { 9 | ll m,n,t,i,j,k,x=0,ans,odd=0; 10 | string s; 11 | cin>>s; 12 | 13 | for(i=0; i 2 | using namespace std; 3 | #define ll long long 4 | int main() 5 | { 6 | ll i=1,j,k,a,b; 7 | cin>>a>>b; 8 | // k=a^b; 9 | // while(i<=k) i<<=1; 10 | // cout< 2 | using namespace std; 3 | int main() 4 | { 5 | string a; 6 | int i,l; 7 | cin>>a; 8 | l=a.size(); 9 | // for(i=0;i 2 | using namespace std; 3 | int main(){ 4 | string s; 5 | int n,x=0; 6 | cin>>n; 7 | while(n--){ 8 | cin>>s; 9 | if(s[0]=='+'||s[1]=='+') 10 | x++; 11 | //cout< 2 | using namespace std; 3 | #define ll long long 4 | 5 | int main() 6 | { 7 | ll m,i,k,j; 8 | cin>>m; 9 | string s; 10 | cin>>s; 11 | ll a=count(s.begin(), s.end(), 'A'); 12 | i=count(s.begin(), s.end(), 'I'); 13 | 14 | if(i==1)cout<<1<1)cout<<0< 2 | using namespace std; 3 | #define ll long long 4 | #define fr(i,n) for (ll i=0;i>n>>k>>s) 12 | { 13 | ll cnt=0; 14 | vector v; 15 | fr(i,n) if(s[i]=='.')v.push_back(i+1); 16 | 17 | fr(i, v.size()-1) if( v[i+1]-v[i] >k){cnt=1; break;} 18 | if(cnt)cout<<"NO"< 2 | using namespace std; 3 | int main() 4 | { 5 | int i,j,k,l,m; 6 | string n; 7 | cin>>n; 8 | l=n.length(); 9 | if(n[0]!='-') 10 | { 11 | cout<= n[l-2]-'0') { n.erase(n.begin()+(l-1)); if(n=="-0") cout< 8 | #include 9 | using namespace std; 10 | 11 | #define ll long long 12 | #define fr(i,n) for(int i=0;i>s>>t; 22 | l=s.length(); 23 | 24 | sum[0]=a[0]; 25 | 26 | for(i=1;i>b>>c; 34 | ans=sum[c-1]-sum[b-1]; 35 | cout< 2 | using namespace std; 3 | int main(){ 4 | long long m,n,k,p; 5 | cin>>n>>m; 6 | if(m<=((n+1)/2)) p=2*m-1; 7 | else p=2*(m-(n+1)/2); 8 | cout< 8 | #include 9 | using namespace std; 10 | 11 | #define ll long long 12 | #define fr(i,n) for(int i=0;i>s; 20 | l=s.size(); 21 | 22 | fr(i,l) 23 | { 24 | if(s.substr(i,5)==str1) hv++; 25 | else if( s.substr(i,5)==str2) cnt+=hv; 26 | } 27 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int l,i,c,j=0,len=0; string a; 6 | int b[100]; 7 | cin>>a; 8 | l=a.size(); 9 | for(i=0;i 2 | using namespace std; 3 | #define ll long long 4 | int main() 5 | { 6 | ll m,n,i,j; 7 | while(cin>>m>>n) 8 | { 9 | ll a[n]; 10 | for(i=0;i>a[i]; 13 | } 14 | 15 | ll ans=a[0]-1, tmp=0; 16 | for(i=0;ia[i+1]) 24 | { 25 | ans+=(m-a[i]+a[i+1]); 26 | // tmp=m-a[i]; 27 | // //cout<<"tmp "< 2 | #include 3 | using namespace std; 4 | 5 | #define ll long long 6 | #define scl(n) scanf("%lld", &n) 7 | #define scf(n) scanf("%lf", &n) 8 | 9 | int main() 10 | { 11 | ll m,n,t,c,d,i,j,k,x,y,z,l,q,r; 12 | 13 | ll cnt=0,ans=0; 14 | scl(n); 15 | scl(m); 16 | sets; 17 | ll a[n],b[n]; 18 | for(i=1; i<=n; i++) 19 | { 20 | cin>>a[i]; 21 | } 22 | 23 | for(i=n; i>=1; i--) 24 | { 25 | s.insert(a[i]); 26 | b[i]=s.size(); 27 | } 28 | while(m--) 29 | { 30 | cin>>x; 31 | cout< 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | #define scl(n) scanf("%lld", &n) 6 | ll a[6]; 7 | int main() 8 | { 9 | ll m,n,t,b,c,d,i,j,k,x,y,z,l,q,r; 10 | 11 | ll cnt=0,ans=0; 12 | cin>>n>>m; 13 | 14 | while(n%2==0)n/=2,a[2]++; 15 | while(n%3==0)n/=3,a[3]++; 16 | while(n%5==0)n/=5,a[5]++; 17 | while(m%2==0)m/=2,a[2]--; 18 | while(m%3==0)m/=3,a[3]--; 19 | while(m%5==0)m/=5,a[5]--; 20 | 21 | if(m!=n)cout<<-1< 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | #define pb push_back 6 | #define fr(i,n) for (ll i=0;i>s; 16 | ll cnt=0; 17 | fr(i,s.size()-1) 18 | { 19 | x=s[i]-'0'; 20 | y=s[i+1]-'0'; 21 | if(x+y==9) cnt++; 22 | else 23 | { 24 | if(cnt>0 && cnt%2==0) ans*=((cnt+2)/2);cnt=0; 25 | } 26 | } 27 | 28 | if(cnt>0 && cnt%2==0) ans*=((cnt+2)/2); 29 | 30 | cout< 2 | using namespace std; 3 | int N, M, H, X, i, j, k, l, A[5000][5000]; 4 | char C; 5 | int main () 6 | { 7 | ios_base::sync_with_stdio(0); 8 | cin.tie(0); 9 | cout.tie(0); 10 | cin>>N>>M; 11 | for (i=0; i>C; 16 | A[j][i]=C-'0'; 17 | } 18 | } 19 | for (i=0; i 2 | using namespace std; 3 | int main(){ 4 | int m,n,d,s,e; 5 | cin>>m>>n; 6 | d=m; s=m; 7 | while(d>=n){ 8 | d=m/n; e=m%n; 9 | s=s+d; 10 | d=d+e; m=d; 11 | } 12 | cout< 2 | using namespace std; 3 | #define ll long long 4 | 5 | int main() 6 | { 7 | ll i, j, k, n, m , x; 8 | cin>>n>>m>>k; 9 | for(i=0; i>x; 10 | 11 | 12 | ll ans=m*(m-1)/ 2; 13 | 14 | cout< 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | int main() 6 | { 7 | ll m,n,t,b,c,d,i,j,k,x,y,z,l,q,r; 8 | while(cin>>n>>y>>x) 9 | for(i=0;i>z; 12 | cout<<(y*z)%x/y<<" "; 13 | } 14 | return 0; 15 | } 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /415D.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | using namespace std; 4 | #define N 2005 5 | #define ll long long 6 | ll dp[N][N]; 7 | void pre() 8 | { 9 | for(int i=1; i<=N; i++) 10 | dp[1][i]=1; 11 | } 12 | const ll int mod=1e9+7; 13 | int main() 14 | { 15 | pre(); 16 | ll n,k, l; 17 | cin>>n>>l; 18 | for(int i=2; i<=l; i++) 19 | { 20 | for(int j=1; j<=n; j++) 21 | { 22 | for(int k=j; k<=n; k+=j) 23 | { 24 | dp[i][k]+=(dp[i-1][j])%mod; 25 | 26 | } 27 | } 28 | } 29 | 30 | ll res=0; 31 | for(int i=1; i<=n; i++) 32 | res=(res+dp[k][i])%mod; 33 | cout< 2 | using namespace std; 3 | int main(){ 4 | string s,s1; 5 | cin>>s>>s1; 6 | reverse(s.begin(),s.end()); 7 | if(s==s1) 8 | cout<<"YES"; 9 | else 10 | cout<<"NO"; 11 | 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /424B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define ll long long 4 | double area, r; 5 | 6 | int main() 7 | { 8 | ll m, n,i ,j, p; 9 | 10 | cin>>n>>m; 11 | vector>v; 12 | 13 | for(i=0;i>x>>y>>p; 17 | v.push_back({ sqrt(x*x+y*y) , p}); 18 | } 19 | sort(v.begin(), v.end()); 20 | 21 | for(i=0;i=1000000)break; 24 | m+=v[i].second; 25 | r=v[i].first; 26 | } 27 | 28 | if(m>=1000000)printf("%.10llf\n", r); 29 | else cout<<-1< 7 | using namespace std; 8 | 9 | #define ll long long 10 | #define mod 1000000007 11 | int main() 12 | { 13 | ll n,m,i,j,ans=0,x,y,a[10]; 14 | 15 | cin>>x>>y>>n; 16 | a[1]=x, a[2]=y, a[3]=y-x ,a[4]=-x, a[5]=-y, a[0]=x-y; 17 | 18 | ans=a[n%6]%mod; 19 | if(ans<0) ans+=mod; 20 | 21 | cout< 2 | using namespace std; 3 | int main(){ 4 | int m,n,a,b; 5 | cin>>m>>n; 6 | a=m*n; 7 | if(m>n){ b=a/m;} else b=a/n; 8 | 9 | // if(n==1){ cout<<"Akshat"; } 10 | if(b%2==0){ 11 | cout<<"Malvika"; 12 | } 13 | else 14 | cout<<"Akshat"; 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /451B v.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define ll long long 4 | #define fr(i,n) for (ll i=0;i>n; 12 | 13 | ll a[n], b[n]; 14 | fr(i,n) 15 | { 16 | cin>>a[i]; 17 | b[i]=a[i]; 18 | } 19 | 20 | sort(a,a+n); 21 | fr(i,n) if(a[i] !=b[i]) {x=i; break;} 22 | 23 | for(i=n-1; i>=0; i--) if(a[i]!=b[i]) {y=i; break;} 24 | 25 | reverse(b+x, b+y+1); 26 | 27 | fr(i,n) if(a[i]!=b[i]) j=1; 28 | 29 | if(j) cout<<"no"< 2 | #include 3 | #pragma GCC optimize("Ofast") 4 | #pragma GCC target("avx,avx2,fma") 5 | using namespace std; 6 | #define ll long long 7 | 8 | int main() 9 | { 10 | double m,n, i, j; 11 | cin>>m>>n; 12 | double ans=0 ; 13 | 14 | /* 15 | double ans=m , tmp=m; 16 | while(tmp--) 17 | { 18 | ans-=pow( tmp/m , n ); 19 | } 20 | */ 21 | 22 | for(i=1;i<=m;i++) ans+=(i* (pow(i/m , n) - pow((i-1)/m , n )) ) ; 23 | 24 | printf("%.12llf\n", ans); 25 | 26 | return 0; 27 | } 28 | 29 | ///***************Before submit***************** 30 | 31 | /// ****Please check all base case output*** 32 | /// *check for integer overflow,array bounds 33 | /// *check for n=1 34 | 35 | 36 | -------------------------------------------------------------------------------- /456A (A Laptops).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main(){ 4 | long long i,n,j; 5 | cin>>n; 6 | pair a[n]; 7 | for(i=0;i>a[i].first>>a[i].second; } 9 | 10 | sort(a,a+n); 11 | 12 | for(i=0;ia[i+1].second)){ 14 | printf("Happy Alex"); return 0; 15 | }} 16 | printf("Poor Alex"); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /459B(B. Pashmak and Flowers).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | long long i,j,m,n,b,cnt1=0,cnt2=0,ans1,ans2,l; 6 | cin>>n; 7 | long long a[n]; 8 | //cin>>l; 9 | for(i=0; i>a[i]; 12 | } 13 | sort(a,a+n); 14 | 15 | int cn; 16 | 17 | for(i=0; i 2 | using namespace std; 3 | int main(){ 4 | int n,m,a,b,c,d,i,j,cnt=0,cn=0,h,g,f; 5 | cin>>n>>m>>a>>b; 6 | 7 | h=n/m; i=n%m; 8 | if(i==0){ 9 | g=h*b; d=n*a; 10 | if(g>d) cout <n){ if(n==a){if(a>b) cout <f) cout< 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | #define sci(x) scanf("%d",&x) 6 | #define scl(x) scanf("%lld",&x) 7 | 8 | int main() 9 | { 10 | ll m,n,t,b,d,j,k,x,y,z, i; 11 | scl(n); 12 | ll a[n]; 13 | 14 | ll total=0; 15 | for( i=0; i>a[i]; 18 | total+=a[i]; 19 | } 20 | 21 | ll one_third=total/3; 22 | ll two_third=one_third*2; 23 | ll sum=0, cnt=0, ans=0; 24 | 25 | 26 | for(i=0; i 2 | using namespace std; 3 | #define ll long long 4 | int main() 5 | { 6 | ll m,n,i,j,p,q,cnt=0; 7 | cin>>n; 8 | for(i=0;i>p>>q; 11 | if(p 2 | using namespace std; 3 | int main() 4 | { 5 | long long i,n,f=0; cin>>n; 6 | if(n%2==0){ cout< 2 | using namespace std; 3 | #define ll long long 4 | 5 | ll a[100005],f[100005]; 6 | vectorfrom; 7 | int main() 8 | { 9 | ll i,m,n,k,ans; 10 | f[0]=1; 11 | from.push_back(1); 12 | cin>>n; 13 | for(i=0; i>a[i]; 14 | for(i=1; i>m; while(m--) {cin>>k; cout< 3 | #include 4 | using namespace std; 5 | #define ll long long 6 | #define scl(n) scanf("%lld", &n) 7 | #define fr(i,n) for (ll i=0;i>a[i]; ans+=a[i];} 17 | sort(a, a+n); 18 | ans/=3; 19 | if(a[0]+a[1] < ans)ans=a[0]+a[1] ; 20 | pfl(ans); 21 | } 22 | -------------------------------------------------------------------------------- /479A(A. Expression).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int ans[6]; 6 | int n,i,a,b,c,d,e,f,g,h; 7 | cin>>a>>b>>c; 8 | 9 | ans[0]= a+b*c; 10 | ans[1]= a*(b+c); 11 | ans[2]= a*b*c; 12 | ans[3]=(a+b)*c; 13 | ans[4]=(a+b+c); 14 | ans[5]=(a*b+c); 15 | sort( ans,ans+5); 16 | cout< 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | #define scl(n) scanf("%lld", &n) 6 | #define fr(i,n) for (ll i=0;i 2 | using namespace std; 3 | int main() 4 | { 5 | long long i,n,f=0; cin>>n; 6 | if(n%2==0){ cout< 8 | #include 9 | using namespace std; 10 | 11 | #define ll long long 12 | #define fr(i,n) for(int i=0;i>n; 21 | fr(i,n)cin>>a[i]; 22 | cin>>m; 23 | fr(i,m)cin>>b[i]; 24 | 25 | sort(a,a+n); sort(b,b+m); 26 | 27 | fr(i,n) 28 | { 29 | fr(j,m) 30 | { 31 | if( (a[i]-b[j]== 1) or (a[i]-b[j]== 0) or (a[i]-b[j]== -1) ) 32 | {b[j]=1000; cnt++ ; break; } 33 | } 34 | 35 | } 36 | cout< 8 | #include 9 | using namespace std; 10 | 11 | #define ll long long 12 | 13 | int main() 14 | { 15 | ll m,n,i,k; 16 | string a,b,query,tmp; 17 | map mp; 18 | cin>>n>>m; 19 | 20 | while(m--) 21 | { 22 | cin>>a>>b; 23 | mp.insert( make_pair(a,b) ); 24 | mp.insert( make_pair(b,a) ); 25 | } 26 | while(n--) 27 | { 28 | cin>>query; 29 | tmp=mp.find(query)->second; 30 | if(query.size()>tmp.size()) 31 | { 32 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int n; 6 | cin>>n; 7 | if(n==2) 8 | cout<<"NO"; 9 | else if (n%2==0) 10 | { 11 | cout<<"YES"; 12 | } 13 | else 14 | cout<<"NO"; 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /501A(A Contest).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main(){ 4 | long long int i,j,a,b,c,d,t1,t2; 5 | cin>>a>>b>>c>>d; 6 | 7 | t1=max (((3*a)/10), (a-((a/250)*c) )); 8 | t2=max(((3*b)/10),(b-((b/250)*d) )); 9 | 10 | if(t1>t2) cout<<"Misha"< 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int q; 8 | map old; 9 | cin >> q; 10 | for (int i=0; i> a >> b; 14 | if (old.count(a)==0) old[a]=a; 15 | 16 | old[b] = old[a]; 17 | old.erase(a); 18 | } 19 | cout << old.size() << endl; 20 | 21 | for (auto kv : old) 22 | { 23 | cout << kv.second << " " << kv.first << endl; 24 | } 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /501B Misha and Changing Handles.vpp.c: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /501B Misha and Changing Handles_my.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | #define scl(n) scanf("%lld", &n) 6 | #define fr(i,n) for (ll i=0;imp; 16 | 17 | fr(i,n) 18 | { 19 | cin>>s>>s1; 20 | if( mp.count(s)==0 )mp[s]=s; 21 | mp[s1]=mp[s]; 22 | mp.erase(s); 23 | } 24 | cout< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int m,n,i; 7 | double a,b,r,x,y,p; 8 | cin>>r>>a>>b>>x>>y; 9 | 10 | double dist=pow((a-x),2) +pow((b-y),2); 11 | 12 | p=sqrt(dist); 13 | // cout< 7 | #include 8 | using namespace std; 9 | #define ll long long 10 | #define fr(i,n) for(int i=0;i>s) 17 | { 18 | ll cnt=0,k=0,index=-1,indx,ans; 19 | n=s.length()-1; 20 | 21 | fr(i,n) { if( (s[i]-'0') %2 ==0 ) { index=i ; if(s[n]>s[i]) break; } } 22 | 23 | if(index==-1)cout<<"-1"< 2 | using namespace std; 3 | int main(){ 4 | int m,n,r; 5 | cin>>m>>n; 6 | r=(m*n)/2; 7 | cout< 2 | using namespace std; 3 | int main(){ 4 | int n,i,j,cnt=0,cn=0,cd=0,a,b,c; 5 | cin>>n; 6 | for(i=0;i>a; cnt+=a;} 8 | for(i=0;i>b; cn+=b;} 10 | for(i=0;i>c; cd+=c;} 12 | 13 | cout<<(cnt-cn)< 2 | using namespace std; 3 | #define ll long long 4 | int main() { ll m,n,k; while(cin>>n>>m) { cout< 8 | #include 9 | using namespace std; 10 | #define ll long long 11 | int main() 12 | { 13 | 14 | ll m,n,t,b,c,d,i,j,k,x,y,z,ans,cnt=0; 15 | cnt=0; 16 | cin>>n>>m; 17 | while(n 2 | #include 3 | using namespace std; 4 | int n,m,b,mod; 5 | int a[1010],f[1010][1010]; 6 | int main() 7 | { 8 | scanf("%d%d%d%d",&n,&m,&b,&mod); 9 | for(int i=1;i<=n;i++) scanf("%d",&a[i]); 10 | for(int i=0;i<=b;i++) f[0][i]=1; 11 | for(int i=1;i<=n;i++) 12 | { 13 | for(int j=1;j<=m;j++) 14 | { 15 | for(int k=a[i];k<=b;k++) 16 | { 17 | f[j][k]=(f[j-1][k-a[i]]+f[j][k])%mod; 18 | cout<<"j "< 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | #define scl(n) scanf("%lld", &n) 6 | #define fr(i,n) for (ll i=0;i>a[i]; 21 | sort(a,a+n); 22 | fr(i,n) if(a[i]>=cnt )ans++, cnt+=a[i]; 23 | pfl(ans); 24 | 25 | return 0; 26 | } 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /549A(A. Soldier and Bananas).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main(){ 4 | int k,n,w,i,d=0,m; 5 | cin>>k>>n>>w; 6 | for(i=1;i<=w;i++){ 7 | d=d+(k*i); 8 | } 9 | m=d-n; 10 | if(m<0){ 11 | cout<<"0"; 12 | } 13 | else 14 | cout< 3 | #include 4 | using namespace std; 5 | 6 | 7 | #define ll long long 8 | #define scl(n) cin>>n; 9 | #define scc(c) cin>>c; 10 | #define fr(i,n) for (ll i=0;i 2 | using namespace std; 3 | 4 | 5 | string go(string s) 6 | { 7 | if(s.size()%2)return s; 8 | 9 | string half1=go(s.substr(0 , s.size()/2 ) ); 10 | string half2=go(s.substr(s.size()/2 ) ); 11 | 12 | if(half1> s1 >> s2; 22 | 23 | //finding lexicographically smallest string for both case using given condition 24 | if( go( s1 ) == go( s2 ) ) cout<<"YES"< 8 | #include 9 | using namespace std; 10 | #define ll long long 11 | #define fr(i,n) for(int i=0;i()) 14 | int main() 15 | { 16 | ll m=0,n,k,l,a[100005],i; 17 | cin>>n; 18 | 19 | fr(i,n){cin>>a[i]; while( a[i]%2==0 ) a[i]/=2; while ( a[i]%3==0) a[i]/=3;} 20 | 21 | for(i=1;i 8 | #include 9 | using namespace std; 10 | 11 | #define ll long long 12 | #define fr(i,n) for(int i=0;i>n>>m){ 19 | ll i,k,ans=0; 20 | 21 | if(m>n*n) ans=0; 22 | else 23 | for(i=1;i<=n;i++){if(m/i <=n && m%i==0) ans++;}//cout< 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | 6 | int main() 7 | { 8 | ll i,n,pow2[35],ans=0; 9 | cin>>n; 10 | while(n) 11 | { 12 | if(n&1)ans+=1; 13 | n/=2; 14 | } 15 | cout< 2 | using namespace std; 3 | #define ll long long 4 | #define fr(i,n) for (ll i=0;i>n>>m; 12 | ll a[n][m]; 13 | fr(i, n)fr(j,m)cin>>a[i][j]; 14 | 15 | fr(i,n) 16 | { 17 | fr(j,m) 18 | { 19 | cout< 4 | using namespace std; 5 | #define ll long long 6 | #define fr(i,n) for (ll i=0;i>n>>m; 14 | ll a[n], b[n][m]; 15 | 16 | fr(i,n)cin>>a[i]; 17 | k=0; 18 | 19 | fr(i, m)fr(j,n){ b[i][j]=a[j];} 20 | 21 | 22 | fr(i,m) 23 | { 24 | fr(j,n) 25 | { 26 | cout< 2 | using namespace std; 3 | 4 | #define ll long long 5 | #define md 1000000007 6 | 7 | 8 | ll bigmd(ll b, ll p) 9 | { 10 | ll res=1, rem=b; 11 | while(p) 12 | { 13 | if(p%2==1 ) 14 | { 15 | res=res*rem%md ; 16 | p--; 17 | } 18 | rem=rem*rem%md; 19 | p>>=1; 20 | } 21 | return res; 22 | } 23 | 24 | int main() 25 | { 26 | ll m, n, i,j; 27 | cin>>n; 28 | ll p=n; 29 | 30 | ll ans=(( bigmd(27, p)-bigmd(7, n))+md)%md ; 31 | 32 | cout< 2 | using namespace std; 3 | #define ll long long 4 | bool p(ll n) 5 | { 6 | for( ll i=2; i<=sqrt(n);i++) 7 | { 8 | if(n%i==0 ) return 0; 9 | } 10 | return 1; 11 | } 12 | 13 | int main() 14 | { 15 | ll m,n,i,j,k; 16 | cin>>n; 17 | 18 | if(p(n) ) 19 | { 20 | cout<<1< 2 | using namespace std; 3 | #define ll long long 4 | 5 | int main() 6 | { 7 | ll m,n,a,b,ans,i; 8 | cin>>n; 9 | for(i=2; i*i<=n; i++) 10 | { 11 | while( n%(i*i)==0) n/=i; 12 | } 13 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | string s,w="hello"; 6 | int i,l,a=0,cnt=0; 7 | cin>>s; 8 | l=s.size(); 9 | for(i=0;i 2 | using namespace std; 3 | int main(){ 4 | int a,b,c,i,m,n,x,k; 5 | cin>>a>>b>>c; 6 | m=a+b; k=a+c; x=b+c; 7 | if(m 2 | using namespace std; 3 | int main() 4 | { 5 | int l,i,cnt=0,ct=0; 6 | char s[100]; 7 | cin>>s; 8 | for(i=0;i='A'&&s[i]<='Z') {cnt++;} 10 | else if (s[i]>='a'&&s[i]<='z') ct++; 11 | } 12 | if(cnt>ct){ 13 | for( i=0; i 2 | using namespace std; 3 | int main(){ 4 | int a,n,d,e; 5 | cin>>n; 6 | d=n/5; 7 | e=n%5; 8 | if(e!=0){ a=d+1;} 9 | else a=d; 10 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | long long m,n,a[200],i,b,res=1; 6 | cin>>n; 7 | for(i=0; i>a[i]; 8 | 9 | vectorv; 10 | 11 | for(i=0; i 2 | using namespace std; 3 | #define ll long long 4 | #define fr(i,n) for (ll i=0;i mp, mp1; 7 | int main() 8 | { 9 | ll m,n,i,j,k,l,x,y,ans=0; 10 | cin>>n; 11 | fr(i,n) 12 | { 13 | cin>>x>>y; 14 | ans+=mp[x+y]++, ans+=mp1[x-y]++; 15 | } 16 | cout< 8 | #include 9 | using namespace std; 10 | 11 | 12 | #define ll long long 13 | #define scl(n) scanf("%lld", &n) 14 | 15 | ll find_pos(ll n) 16 | { 17 | ll i=1; 18 | n--; 19 | while(n>=0) 20 | { 21 | n-=i; 22 | i++; 23 | } 24 | return (n+i); 25 | } 26 | int main() 27 | { 28 | ll m,n,t,b,c,d,i,j,k,x,y,z,l,q,r; 29 | 30 | ll cnt=0,ans=0; 31 | scl(n); 32 | ans=find_pos(n); 33 | cout<<(ans); 34 | 35 | return 0; 36 | } 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /622B The Time.cpp: -------------------------------------------------------------------------------- 1 | //! Bismillahi-Rahamanirahim. 2 | /** ========================================** 3 | ** @Author: Md. Abu Farhad ( RUET, CSE'15) 4 | ** @Category: 5 | /** ========================================**/ 6 | #include 7 | #include 8 | using namespace std; 9 | 10 | #define ll long long 11 | #define scl(n) scanf("%lld", &n) 12 | 13 | int main() 14 | { 15 | ll m,n,t,b,c,d,i,j,k,x,y,z,l,q,r; 16 | 17 | ll cnt=0,ans=0; 18 | 19 | scanf("%lld:%lld ",&x,&y); 20 | scl(z); 21 | 22 | 23 | m=x*60+y+z; 24 | 25 | ll h1=m/60; 26 | ll m1=m%60; 27 | h1%=24; 28 | 29 | printf("%02lld:%02lld\n", h1,m1); 30 | 31 | 32 | 33 | return 0; 34 | } 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /629B Far Relative’s Problem.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | #define scl(n) scanf("%lld", &n) 6 | #define fr(i,n) for (ll i=0;i>n; 15 | char c; 16 | 17 | fr(i,n) {cin>>c>>l>>r; for(ll i=l; i<=r;i++)if(c=='F')f[i]++; else m[i]++;} 18 | 19 | fr1(i,366) ans=max(ans, min(f[i], m[i]) ); 20 | 21 | pfl(2*ans); 22 | } 23 | -------------------------------------------------------------------------------- /630C Lucky Numbers.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | #define scl(n) scanf("%lld", &n) 6 | int main() 7 | { 8 | ll n; 9 | ll cnt=0,ans=0; 10 | scl(n); 11 | ans =((2ll << n )-2); 12 | cout< 2 | using namespace std; 3 | #define ll long long 4 | int main() 5 | { 6 | ll m,n,k; 7 | while(cin>>n) cout<<(6* n* (n+1) /2 ) +1< 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | #define scl(n) scanf("%lld", &n) 6 | #define fr(i,n) for (ll i=0;i>n>>m>>k; 17 | 18 | fr1(i,k) 19 | { 20 | cin>>x>>y>>ok[i]; 21 | if(x==1)r[y]=i; else c[y]=i; 22 | } 23 | 24 | fr1(i,n) 25 | { 26 | fr1(j,m) 27 | { 28 | cout< 2 | using namespace std; 3 | #define ll long long 4 | 5 | bool cmp(string s, string s1) 6 | { 7 | return s+s1 < s1+s; 8 | } 9 | 10 | int main() 11 | { 12 | ll m, n,j, i; 13 | string s1, s2; 14 | cin>>n; 15 | vectors; 16 | for(i=0; i>s1; 19 | s.push_back(s1); 20 | } 21 | sort(s.begin() , s.end() , cmp); 22 | 23 | for(auto it: s)cout< 8 | #include 9 | using namespace std; 10 | 11 | 12 | #define ll long long 13 | #define fr(i,n) for(int i=0;i>m>>n>>k) 19 | { 20 | ans=0; 21 | fr(i,1000) 22 | { 23 | d=(k-(m*i)); 24 | if(d<0){ans=0;break;} 25 | if (d%n==0 ) { ans=1;break;} 26 | } 27 | 28 | if(ans)cout<<"Yes"< 2 | using namespace std; 3 | #define ll long long 4 | 5 | ll calc(ll n) 6 | { 7 | ll res=0; 8 | while(n%5==0) 9 | { 10 | n/=5; 11 | res++; 12 | } 13 | return res; 14 | } 15 | 16 | 17 | int main() 18 | { 19 | ll j , i, n; 20 | 21 | while(cin>>n) 22 | { 23 | ll cnt, k=0, ans=0; 24 | while(k 8 | #include 9 | using namespace std; 10 | #define ll long long 11 | int main() 12 | { 13 | ll m,n,i,k, mx=0, a[10000]; 14 | sets; 15 | cin>>n; 16 | 17 | for(i=0; i>m; 20 | a[m]++; 21 | if(a[m]>mx) mx=a[m]; 22 | } 23 | cout< 8 | #include 9 | using namespace std; 10 | #define ll long long 11 | int main() 12 | { 13 | ll a,b,m,n,i,k, sum=0, a[10000]; 14 | cin>>n; 15 | mapmp; 16 | while(n--) 17 | { 18 | cin>>a>>b; 19 | mp[a]=b; 20 | } 21 | 22 | 23 | return 0; 24 | } 25 | 26 | 27 | -------------------------------------------------------------------------------- /661A(A Lazy Caterer Sequence).cpp: -------------------------------------------------------------------------------- 1 | //#include 2 | //using namespace std; 3 | // int main(){ 4 | // int m,n,k; 5 | // cin>>n; 6 | // k=n*(n+1)/2+1; 7 | // cout< 11 | using namespace std; 12 | int main() 13 | { 14 | int n,c; 15 | cin>>n; 16 | c=((n*(n+1))/2)+1; 17 | cout< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | string s,s1; 7 | cin>>s>>s1; 8 | 9 | int sz=s.size(), sz1=s1.size(); 10 | if(s==s1)cout< 2 | #include 3 | using namespace std; 4 | 5 | 6 | #define ll long long 7 | #define scl(n) scanf("%lld", &n) 8 | #define scf(n) scanf("%lf", &n) 9 | #define pfl(x) printf("%lld\n",x) 10 | #define md 10000007 11 | #define pb push_back 12 | 13 | int main() 14 | { 15 | ll m,n,t,b,c,d,i,j,k,x,y,z,l,q,r; 16 | 17 | ll a; 18 | cin>>a>>b>>c; 19 | if(c==0) 20 | { 21 | if(a==b) 22 | cout<<"YES"<=0 ) 29 | cout<<"YES"< 2 | using namespace std; 3 | int main() { long long m,n,i,k,ans,l; while(cin>>m>>n) { ans=0; for( i=1;i<=m;i++) {ans+=(n+(i%5) )/5;} cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int t; 6 | cin>>t; 7 | int i,i1,i2,i3,x=0,y=0,z=0; 8 | for(i=0;i>i1;x=x+i1; 10 | cin>> i2; y=y+i2; 11 | cin>>i3; z=z+i3; 12 | } 13 | if(x==0&&y==0&&z==0) 14 | cout<<"YES"; 15 | else 16 | cout<<"NO"; 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /701C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define scc(c) scanf("%c",&c) 4 | #define fr(i,n) for (ll i=0;i>n>>s; 14 | map mp; 15 | 16 | fr(i, n) 17 | { 18 | mp[s[i] ]++; 19 | cnt=mp[s[i] ]; 20 | 21 | while(mp[s[k] ] > 1 ) 22 | { 23 | mp[s[k] ]--; 24 | k++; 25 | } 26 | 27 | if(cnt==1)ans=i-k+1; 28 | else ans=min( ans , i-k+1 ); 29 | } 30 | 31 | cout< 2 | using namespace std; 3 | 4 | 5 | int main() 6 | { 7 | int m,n,i,j,k,ans; 8 | cin>>n; 9 | int a[n],p; 10 | int cnt=0; 11 | for(i=0; i>a[i]; 14 | } 15 | cin>>m; 16 | sort(a,a+n); 17 | while(m--) 18 | { 19 | cin>>k; 20 | ans=upper_bound(a,a+n, k)-a; 21 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int i,cnt=0,cn=0,j,t; 6 | cin>>t; 7 | for(j=0; j>s; 11 | 12 | if(s.length()>10) 13 | cout< 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | #define scl(n) scanf("%lld", &n) 6 | #define fr(i,n) for (ll i=0;i>b>>d>>s) 16 | { 17 | ll ans=0; 18 | ll mx=max({b,d,s})-1; /// -1 cz between this 3 time onece he left 19 | 20 | ans=( max(0ll , mx-b )) +( max(0ll , mx-d )) + ( max(0ll , mx-s )); ///otherwise he miss so take max 21 | pfl(ans); 22 | 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /735D Taxes.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define ll long long 4 | bool is_prime(ll n) 5 | { 6 | for(ll i=2;i*i<=n;i++)if(n%i==0){return 0;break;} return 1; 7 | } 8 | int main() 9 | { 10 | int n;cin>>n; if(is_prime(n)==1)cout<<1< 2 | #include 3 | using namespace std; 4 | 5 | 6 | #define ll long long 7 | #define scl(n) scanf("%lld", &n) 8 | #define fr(i,n) for (ll i=0;i>n>>s; 16 | 17 | //string ans = regex_replace(s, regex{"ogo(go)*"}, "***"); 18 | 19 | fr(i,n) 20 | { 21 | if(s[i]=='o') 22 | { 23 | if(i+2 8 | #include 9 | using namespace std; 10 | 11 | #define ll long long 12 | #define fr(i,n) for(int i=0;i>n; 17 | 18 | m=n%8; 19 | //cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int n,m=0,l=0,i,cnt=0, k,j,sum=0; 6 | cin>>n; 7 | if(n%2==0) 8 | { 9 | k=n/2; 10 | cout< 8 | #include 9 | using namespace std; 10 | 11 | 12 | #define ll long long 13 | #define scl(n) scanf("%lld", &n) 14 | #define scf(n) scanf("%lf", &n) 15 | #define pfl(x) printf("%lld\n",x) 16 | 17 | int main() 18 | { 19 | ll m,n,t,b,c,d,i=1,j,k,x,y,z,l,q,r; 20 | 21 | ll cnt=0,ans=0; 22 | cin>>n>>m; 23 | ll baki=240-m; 24 | while( 1 ) 25 | { 26 | ans+=5*i; 27 | i++; 28 | //cout<cnt)cnt++; 30 | else break; 31 | } 32 | pfl(cnt); 33 | 34 | return 0; 35 | } 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /765A Neverending competitions.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int n,m,i,l; 6 | string s,s1,s2,s3; 7 | cin>>n; 8 | cin>>s; 9 | for(i=0;i>s1; 12 | } 13 | if( n%2==0 ) cout<<"home"; 14 | else cout<<"contest"; 15 | } 16 | -------------------------------------------------------------------------------- /765C(C Table Tennis Game 2).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define ll long long 4 | int main() 5 | { 6 | long long int k,a,b,c,d,e; 7 | while(cin>>k>>a>>b) 8 | { 9 | ll x=a/k; 10 | ll y=b/k; 11 | 12 | ll x1=(a%k); 13 | ll y1=(b%k); 14 | 15 | 16 | if(x1!=0 && y==0 || y1!=0 && x==0) e=-1; 17 | else 18 | { 19 | e=x+y; 20 | } 21 | 22 | cout< 2 | using namespace std; 3 | 4 | #define ll long long 5 | #define scl(n) cin>>n; 6 | #define scc(c) cin>>c; 7 | #define fr(i,n) for (ll i=0;i=x and (q-p)*t >=(y-x) )return true; 15 | else return 0; 16 | } 17 | 18 | int main() 19 | { 20 | ll t; 21 | cin>>t; 22 | while(t--) 23 | { 24 | cin>>x>>y>>p>>q; 25 | ll ans=0, cnt=0; 26 | ll l=0, r=1e9+5; 27 | if(!can_mid(y)){cout<<-1<1) 31 | { 32 | mid=(l+r)/2.0; 33 | if( can_mid(mid) ) r=mid; 34 | else l=mid; 35 | } 36 | cout< 2 | #include 3 | using namespace std; 4 | 5 | #define ll long long 6 | #define scl(n) scanf("%lld", &n) 7 | #define scf(n) scanf("%lf", &n) 8 | #define pfl(x) printf("%lld\n",x) 9 | #define md 10000007 10 | #define pb push_back 11 | #define fr(i,n) for (ll i=0;i=n)pfl(n); 22 | else 23 | { 24 | x=m; 25 | while(z<(n-x) ) 26 | { 27 | i++; 28 | z+=i; 29 | } 30 | pfl(i+x); 31 | } 32 | 33 | return 0; 34 | } 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /798B Mike and strings.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define ll long long 4 | string a[100]; 5 | int main() 6 | { 7 | ll m,n,i,j,ans, mn=99999999999999; 8 | string s,s1; 9 | cin>>n; 10 | 11 | for(i=0;i>a[i]; 12 | 13 | for(i=0;i 8 | #include 9 | using namespace std; 10 | 11 | 12 | #define ll long long 13 | #define scl(n) scanf("%lld", &n) 14 | #define scf(n) scanf("%lf", &n) 15 | #define pfl(x) printf("%lld\n",x) 16 | #define fr(i,n) for (ll i=0;i>x>>y; 25 | fr(i,x.size()) if(x[i] 8 | #include 9 | using namespace std; 10 | 11 | 12 | #define ll long long 13 | #define scl(n) scanf("%lld", &n) 14 | #define scf(n) scanf("%lf", &n) 15 | #define pfl(x) printf("%lld\n",x) 16 | #define md 1000000007 17 | 18 | int main() 19 | { 20 | ll m,n,i,j; 21 | 22 | ll cnt=0,ans=0; 23 | string s; 24 | cin>>s; 25 | for(i=s.size()-1; i>=0;i--) 26 | { 27 | if(s[i]=='b')cnt++; 28 | else 29 | { 30 | ans+=cnt, cnt*=2, ans%=md, cnt%=md; 31 | } 32 | } 33 | pfl(ans); 34 | 35 | return 0; 36 | } 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /805B 3-palindrome.cpp: -------------------------------------------------------------------------------- 1 | //! Bismillahi-Rahamanirahim. 2 | /** ========================================** 3 | ** @Author: Md. Abu Farhad ( RUET, CSE'15) 4 | ** @Category: 5 | /** ========================================**/ 6 | 7 | #include 8 | #include 9 | using namespace std; 10 | #define ll long long 11 | #define fr(i,n) for (ll i=0;i>n; 21 | fr(i,n) if(i%4==1 || i%4==0 ) cout<<"a"; else cout<<"b"; 22 | 23 | return 0; 24 | } 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /805C Find Amir.cpp: -------------------------------------------------------------------------------- 1 | //! Bismillahi-Rahamanirahim. 2 | /** ========================================** 3 | ** @Author: Md. Abu Farhad ( RUET, CSE'15) 4 | ** @Category: 5 | /** ========================================**/ 6 | 7 | #include 8 | #include 9 | using namespace std; 10 | 11 | #define ll long long 12 | #define fr(i,n) for (ll i=0;i>n; 21 | for(i=1;i<=n;i+=2) 22 | { 23 | ans=min(ans, (i+(i+1) ) % (n+1) ); 24 | } 25 | 26 | cout< 2 | using namespace std; 3 | int main(){ 4 | long long i,j,m,n,d,e; 5 | cin>>m>>n; 6 | 7 | for(i=1; ; i++){ 8 | if(i%2!=0){ 9 | m-=i; 10 | if(m<0) { cout<<"Vladik"< 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int x1,x2,y1,y2,x,y,z,l,q,r; 8 | 9 | cin>>x1>>y1>>x2>>y2>>x>>y; 10 | l=abs(x1-x2); 11 | r=abs(y1-y2); 12 | if( l%x==0 && r%y==0 && (l/x)%2 ==(r/y)%2 ) cout<<"YES"< 8 | #include 9 | using namespace std; 10 | 11 | #define ll long long 12 | #define fr(i,n) for(int i=0;i>m>>n; 18 | if(m>=n) 19 | { 20 | fr1(i,n) ans*=i; 21 | } 22 | else 23 | { 24 | fr1(i,m) ans*=i; 25 | } 26 | 27 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int n,i; 6 | int a=1,b=2,c=3,d=4,e=5; 7 | cin>>n; 8 | for(i=0; ;i++){ 9 | a=a+5; b=b+5; c=c+5; d=d+5;e=e+5; 10 | if(n==1||n==a){ cout<<"Sheldon"; break;} 11 | if(n==2||n==b){ cout<<" Leonard";break;} 12 | if(n==3||n==c){ cout<<"Penny";break;} 13 | if(n==4||n==d){ cout<<"Rajesh";break;} 14 | if(n==5||n==e){ cout<<"Howard";break;} 15 | } 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /831A Unimodal Array.cpp: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /835B The number on the board.cpp: -------------------------------------------------------------------------------- 1 | //! Bismillahi-Rahamanirahim. 2 | /** ========================================** 3 | ** @Author: Md. Abu Farhad ( RUET, CSE'15) 4 | ** @Category: 5 | /** ========================================**/ 6 | 7 | #include 8 | #include 9 | using namespace std; 10 | 11 | #define ll long long 12 | #define fr(i,n) for(int i=0;i>k>>s) 18 | { 19 | ll ans=0; 20 | n=s.size(); 21 | sort(s.begin(), s.end()); 22 | // cout<0){ k-=9-(s[i]-'0'); ans++; } } 26 | cout< 8 | #include 9 | using namespace std; 10 | 11 | 12 | #define ll long long 13 | #define scl(n) scanf("%lld", &n) 14 | #define scf(n) scanf("%lf", &n) 15 | #define pfl(x) printf("%lld\n",x) 16 | 17 | int main() 18 | { 19 | unsigned long long n,i,j,k,x,y,z,l,q,r,cnt=0,ans=0, evn=0,odd=0; 20 | 21 | cin>>n; 22 | for(i=0;i>x; 25 | ans+=(x%2); 26 | } 27 | 28 | if(ans==0)cout<<"Second"< 2 | using namespace std; 3 | int main() 4 | { 5 | 6 | int m,n,i,b; 7 | cin>>n; 8 | int a[n]; 9 | for(i=0;i>a[i]; 12 | } 13 | if(n%2) 14 | { 15 | if(a[0]%2 and a[n-1]%2) 16 | { 17 | cout<<"Yes"< 2 | using namespace std; 3 | #define ll long long 4 | int n, a[1010]; 5 | bool isparallel(double slop) 6 | { 7 | sets; 8 | for(int i=0; i>n; 17 | for(i=0; i>a[i]; 20 | } 21 | cout<< (isparallel(a[2]-a[1]) || isparallel(a[3]-a[2]) || isparallel((a[3]-a[1])/2.0)?"Yes" : "No")< 8 | #include 9 | using namespace std; 10 | #define ll long long 11 | int main() 12 | { 13 | ll m,n,i; 14 | cin>>n; 15 | m=n/2; 16 | cout<<(m)*3< 2 | using namespace std; 3 | #define ll long long 4 | 5 | int main() 6 | { 7 | ll m,n,i,k=0; 8 | string s,s1; 9 | cin>>n>>s; 10 | setst; 11 | for(i=0;i 8 | #include 9 | using namespace std; 10 | 11 | 12 | #define ll long long 13 | #define scl(n) scanf("%lld", &n) 14 | #define scf(n) scanf("%lf", &n) 15 | #define pfl(x) printf("%lld\n",x) 16 | 17 | 18 | int main() 19 | { 20 | ll m,n,t,b,c,d,i,j,k,x,y,z,l,q,r; 21 | 22 | ll cnt=0,ans=0; 23 | scl(n); 24 | for(i=0; i>x; 27 | 28 | if( x<=3 || x==5 || x==7 || x==11 ) cout<<"-1"< 3 | #include 4 | using namespace std; 5 | 6 | 7 | #define ll long long 8 | #define scl(n) cin>>n; 9 | #define scc(c) cin>>c; 10 | #define fr(i,n) for (ll i=0;i>a[i]; 26 | if(a[i]%a[0])cnt=1 ; 27 | } 28 | if(!cnt){ cout<<2*n< 35 | /// *check for integer overflow,array bounds 36 | /// *check for n=1 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /909B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | #define fr(i,n) for (ll i=0;i>n) 10 | { 11 | ll ans=-1; 12 | fr(i, n) 13 | { 14 | ans=max(ans, (i+1)*(n-i) ); 15 | } 16 | cout< 2 | #include 3 | #pragma GCC optimize("Ofast") 4 | #pragma GCC target("avx,avx2,fma") 5 | using namespace std; 6 | #define ll long long 7 | 8 | int main() 9 | { 10 | ll m,n,b,c,d,i,j,k,x,y,z,l,q,r; 11 | 12 | ll cnt=1,cn=0,ans=0,sum=0 ; 13 | cin>>n>>k; 14 | 15 | if(k==1){cout<>=1) cnt++; 18 | ans=1< 2 | using namespace std; 3 | #define ll long long 4 | 5 | int main() 6 | { 7 | ll n, m ,l , i, j, k, x; 8 | cin>>n>>l; 9 | ll a[n]; 10 | for(i=0; i>a[i]; 11 | 12 | // to optimize the cost 13 | for(i=1; i=0; i--) 20 | { 21 | x=(1<0 )*a[i] ); 26 | } 27 | 28 | 29 | cout< 2 | #include 3 | using namespace std; 4 | 5 | #define ll long long 6 | #define scl(n) scanf("%lld", &n) 7 | #define scf(n) scanf("%lf", &n) 8 | #define pfl(x) printf("%lld\n",x) 9 | 10 | int main() 11 | { 12 | ll m,n,t,b,c,d,i,j,k,x,y,z,l,q,r; 13 | 14 | ll cnt=0,ans=0; 15 | scl(n); 16 | 17 | for(i=1; i<=n; i++) 18 | { 19 | for(j=1; j<=n; j++) 20 | { 21 | x=i^j; 22 | if(i+j>x && j+x>i && x+i>j && i<=j && j<=x && x<=n) 23 | ans++; 24 | } 25 | } 26 | pfl(ans); 27 | 28 | return 0; 29 | } 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /931B World Cup.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define ll long long 4 | 5 | int main() 6 | { 7 | ll i,j,k,m,n,a,b; 8 | while(cin>>n>>a>>b) 9 | { 10 | a--, b--; 11 | ll cnt=0; 12 | while(a!=b)a/=2, b/=2, n/=2,cnt++; 13 | 14 | if(n==1)cout<<"Final!"< 2 | using namespace std; 3 | #define ll long long 4 | const ll Inf = 1LL << 62; 5 | int main() 6 | { 7 | ll m,n,i,k, j,a[51], b[51]; 8 | vectorv; 9 | cin>>n>>m; 10 | 11 | for(i=0;i>a[i]; 12 | for(i=0;i>b[i]; 13 | 14 | for(i=0;i 8 | #include 9 | using namespace std; 10 | #define ll long long 11 | 12 | int main() 13 | { 14 | ll a,b,n,i,l,x,y; 15 | while(cin>>a>>b) 16 | { 17 | for(i=0;; i++) 18 | { 19 | if(a==0 or b==0) break; 20 | else if(a>=2*b) a=a %(2*b); 21 | else if(b>=2*a) { b=b %(2*a);} 22 | else break; 23 | } 24 | cout< 2 | using namespace std; 3 | #define ll long long 4 | #define fr(i,n) for (ll i=0;i>n>>s; 12 | ll cnt=0, ans=0, mx=0; 13 | vectorv; 14 | 15 | fr(i,n-1) 16 | { 17 | cnt=0; 18 | fr(j,n-1) 19 | { 20 | if(s[j]==s[i] and s[j+1]==s[i+1])cnt++; 21 | } 22 | if(mx < cnt)mx=cnt, v.push_back(s[i]), v.push_back(s[i+1]); 23 | } 24 | cout< 2 | using namespace std; 3 | #define ll long long 4 | #define fr(i,n) for (ll i=0;i>n>>k; 11 | ll a[n]; 12 | ll cnt=0, ans=0; 13 | fr(i,n)cin>>a[i]; 14 | sort(a, a+n); 15 | 16 | if(k==0)ans=a[0]-1; 17 | else ans=a[k-1]; 18 | 19 | 20 | fr(i,n) if(ans >= a[i])cnt++; 21 | 22 | if( ans<1 or cnt!=k)cout<<-1< 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | int main() 6 | { 7 | ll m,n,t,a,b,c,d,i,j,k,x,y,z,ans; 8 | cin>>n; 9 | 10 | a=n/100;b=n%100; 11 | c=b/20; d=b%20; 12 | x=d/10; y=d%10; 13 | i=y/5; j=y%5; 14 | 15 | ll p=a+c+x+i+j; 16 | cout< 2 | using namespace std; 3 | int main(){ 4 | int m,n,i,j,a,b; 5 | cin>>n>>a>>b; 6 | int f[n]; 7 | string s; 8 | cin>>s; 9 | for(i=1;i<=n;i++){ 10 | if(s[a]!=s[b]){ 11 | cout<<"1"< 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int m,n; 8 | cin>>n; 9 | printf("0 0 %d",n); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /A Holiday Of Equality.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main(){ 4 | int n,j,a,i; 5 | cin>>n; int N[n]; 6 | for(i=0;i>N[i]; } 8 | sort(N,N+i); 9 | int cnt=0,d,s,e; 10 | for(i=0;i 2 | using namespace std; 3 | int main() 4 | { 5 | int n,c,i,cnt=0,d,m=0; 6 | cin>>n>>c; 7 | for(i=1; i<=n; i++) 8 | { 9 | d=i*5; 10 | m=m+d; 11 | if((240-m)>=c) 12 | { 13 | cnt++; 14 | } 15 | } 16 | cout< 2 | using namespace std; 3 | void primefactor(int n) 4 | { 5 | while(n%2==0) 6 | { 7 | cout<<"2"<<" "; 8 | n=n/2; 9 | } 10 | for(int i=3; i2) 19 | { 20 | cout<>n; 28 | primefactor( n); 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /Caisa and Sugar 463A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | #define ll long long 6 | int main() 7 | { 8 | ll ans,i,m,n,s,k=0,mini=100,x,y,cnt=0; 9 | cin>>n>>s; 10 | for(i=0;i>x>>y; 13 | if(x 2 | using namespace std; 3 | int main( ){ 4 | char str[100]; 5 | int i,l,count=0,j; 6 | cin>>str; 7 | l=strlen(str); 8 | sort(str,str+l); 9 | for(i=0;i 2 | using namespace std; 3 | int main(){ 4 | int a,b,i,c=0,n=0,j; 5 | cin>>a; 6 | for(i=0;i>n; 8 | if(n==0) break; 9 | for(j=0; ;j++){ 10 | c=c+n/3; 11 | n=n+n%3; 12 | if(n==2) n=n+1; 13 | if(n==1) break;} 14 | cout< 2 | using namespace std; 3 | int main(){ 4 | int m,i,cnt=0,cntt=0; 5 | char a[1000]; 6 | //string a; 7 | cin>>m; 8 | //while(m--){ 9 | for(i=0;i>a; 11 | //for(i=0;i 2 | using namespace std; 3 | 4 | // Function to find if count 5 | // of divisors is even or 6 | // odd 7 | int countDivisors(int n) 8 | { 9 | int root_n = sqrt(n); 10 | 11 | // If n is a perfect square, 12 | // then it has odd divisors 13 | if (root_n * root_n == n) 14 | printf("Odd\n"); 15 | else 16 | printf("Even\n"); 17 | } 18 | 19 | // Driver Code 20 | int main() 21 | { 22 | int i; 23 | for( i=1;i<=100;i++) 24 | printf("%d, %d\n",i,countDivisors(i)) < 2 | #include 3 | using namespace std; 4 | 5 | #define ll long long 6 | 7 | #define sci(x) scanf("%d",&x) 8 | #define scl(x) scanf("%lld",&x) 9 | #define scd(x) scanf("%lf",&x) 10 | #define scc(x) scanf("%[^\n]s",x); // For charecter string input , It will read all charecter untill Enter new line . 11 | 12 | #define pfi(x) printf("%d",x) 13 | #define pfl(x) printf("%lld\n",x) 14 | #define pfd(x) printf("%lf",x) 15 | #define pfc(x) printf("Case %d: ",x) 16 | #define ps printf(" ") 17 | #define pn printf("\n") 18 | 19 | 20 | 21 | int main() 22 | { 23 | 24 | ll m,n,t,b,c,d,i,j,k,x,y,z,ans=0; 25 | cin>>n>>m; 26 | 27 | for(i=0;i<=1005;i++) 28 | { 29 | for(j=0;j<=1005;j++) 30 | { 31 | if(i*i+j==n and i+j*j==m) 32 | ans++; 33 | } 34 | } 35 | pfl(ans); 36 | 37 | 38 | return 0; 39 | } 40 | 41 | -------------------------------------------------------------------------------- /Little Pony and Sort by Shift .cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define ll long long 5 | 6 | int main() 7 | { 8 | ll m,n,i,ans=0,cnt=0; 9 | cin>>n; 10 | ll a[n]; 11 | 12 | for(i=0; i>a[i]; 15 | if( i>0 && a[i] 2 | using namespace std; 3 | 4 | #define ll long long 5 | 6 | int main() 7 | { 8 | string n,m,i; 9 | cin>>n; 10 | cout< 2 | #include 3 | using namespace std; 4 | 5 | #define ll long long 6 | 7 | int main() 8 | { 9 | 10 | ll i,fr=0,svn=0,nai=0; 11 | string s; 12 | cin>>s; 13 | 14 | for(i=0;i=svn) cout<<"4"< 2 | #include 3 | using namespace std; 4 | 5 | #define ll long long 6 | 7 | int main() 8 | { 9 | ll m,n,t; 10 | cin>>n; 11 | string s; 12 | 13 | while(n>0) 14 | { 15 | if(n%7==0){ s+='7'; n-=7;} 16 | else { s+='4'; n-=4;} 17 | } 18 | if(n) cout<<-1< 2 | using namespace std; 3 | 4 | #define ll long long 5 | int main() 6 | { 7 | ll m,n,t,i,k=0; 8 | string s; 9 | cin>>n>>t>>s; 10 | 11 | for(i=0;i 2 | using namespace std; 3 | int main(){ 4 | int h,m; 5 | float a,b,c,d; 6 | while(scanf("%d:%d",&h,&m)==2){ 7 | if(h==0&&m==0) break; 8 | a=(0.5*(h*60+m)); 9 | b=(6*m); 10 | if(a>b) {c=a-b;} 11 | else c=b-a; 12 | //c=(.5*((60*h)-(11*m))); 13 | if(c>180){ 14 | d=360-c; 15 | printf("%.3f",d); } 16 | else 17 | printf("%.3f",c);} 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /Memory and Trident 712B .cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | #define ll long long 6 | 7 | 8 | 9 | int main() 10 | { 11 | 12 | ll m,n,t,b,c,i,j,l=0,r=0,u=0,d=0,ans,lr,ud; 13 | string s; 14 | cin>>s; 15 | n=s.size(); 16 | if(n%2==0) 17 | { 18 | for(i=0;i 2 | #include 3 | using namespace std; 4 | 5 | #define ll long long 6 | int main() 7 | { 8 | 9 | ll m,n,t,a,b,c,d,i,j,k,x,y,z,ans=0; 10 | 11 | cin>>a>>b>>x>>y; 12 | if(y%x !=0) 13 | { 14 | cout<<"0"<=a && i*x<=b && j*x>=a && j*x<=b ) 24 | { 25 | ans+=1+(i!=j); 26 | } 27 | } 28 | } 29 | cout< 2 | using namespace std; 3 | long long a[500005],n,ans,x; 4 | int main(){ 5 | cin>>n; 6 | for(int i=0;i>a[i];a[i]=a[i-1]+a[i]; 7 | //cout< 3 | #include 4 | using namespace std; 5 | 6 | #define ll long long 7 | 8 | 9 | 10 | 11 | bool v[10000]={0}; 12 | 13 | int main() 14 | { 15 | 16 | ll m,n,t,b,c,d,i,j,k,x,y,z,ans,cnt=0; 17 | 18 | cin>>n>>m; 19 | 20 | for(i=0; i>x>>y; 23 | for(j=x; j<=y; j++) 24 | { 25 | v[j]=true; 26 | } 27 | } 28 | 29 | 30 | for(i=1; i<=m; i++) 31 | { 32 | if(v[i]==false) 33 | { 34 | cnt++; 35 | } 36 | } 37 | cout< 2 | using namespace std; 3 | mapM; 4 | long long ans=0; 5 | int main() 6 | { 7 | int n,a; 8 | cin>>n; 9 | while(n--) 10 | { 11 | cin>>a; 12 | for(int i=0; i<=31; i++) 13 | { 14 | ans+=M[(1LL< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int m,n,i,k,ans=100000; 7 | cin>>n>>m; 8 | int a[m]; 9 | for(i=0; i>a[i]; 10 | sort(a,a+m); 11 | n--, m-=n; 12 | //for(i=0;i 2 | using namespace std; 3 | 4 | #define ll long long 5 | int main() 6 | { 7 | ll i,j,cnt=0,sunno=0,sunno1=0,p=0,k=0; 8 | string s,s1,s2, a,b; 9 | cin>>s>>s1; 10 | 11 | i=0; 12 | while( s[i] == '0' ) 13 | { 14 | sunno++; 15 | i++; 16 | } 17 | 18 | while( s1[p] == '0' ) 19 | { 20 | sunno1++; 21 | p++; 22 | } 23 | 24 | //s.erase(sunno); 25 | //s1.erase(sunno1); 26 | for(i=sunno ; i 2 | #include 3 | using namespace std; 4 | 5 | #define ll long long 6 | 7 | 8 | bool cmp(string x, string y) 9 | { 10 | return x.length()>n; 21 | for(i=0; i>st[i]; 24 | } 25 | 26 | sort(st,st+n,cmp); 27 | 28 | 29 | for(int i=0; i 3 | #include 4 | using namespace std; 5 | 6 | #define ll long long 7 | 8 | #define sv(a) sort(a.begin(),a.end()) 9 | #define sortD(a) sort(a,a+n,greater()) 10 | #define sortA(a) sort(a,a+n) 11 | int main() 12 | { 13 | ll ans,i,m,n,s,tomas,a,b,c,d,e; 14 | cin>>n; 15 | ll sum[1005]; 16 | for(i=0; i>a>>b>>c>>d; 19 | sum[i]=(a+b+c+d); 20 | tomas=sum[0]; 21 | } 22 | sortD(sum); 23 | for(i=0; i 2 | using namespace std; 3 | #define ll long long 4 | int main() 5 | { 6 | ll m,n,i,j, ans=0; 7 | scanf("%lld %lld",&n,&m); 8 | ll a[n], b[m]; 9 | for(i=0;i()); 19 | // sort(b,b+m,greater()); 20 | ans= a[n-2]*b[m-1]; 21 | printf("%lld\n",ans); 22 | } 23 | -------------------------------------------------------------------------------- /Towers 37A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | #define ll long long 6 | 7 | 8 | int main() 9 | { 10 | 11 | ll m,n,t,i,a,mx=0,cnt[1008]={0}; 12 | cin>>t; 13 | sets; 14 | 15 | for(i=0; i>a; 18 | s.insert(a); 19 | cnt[a]++; 20 | mx=max(mx, cnt[a]); 21 | 22 | } 23 | cout< 2 | using namespace std; 3 | #define ll long long 4 | int main() 5 | { 6 | ll m,n,t,d,ans,a; 7 | cin>>t; 8 | while(t--) 9 | { 10 | cin>>n; 11 | ans=n*(n+1)/2; 12 | //cout< 2 | using namespace std; 3 | #define ll long long 4 | int main() 5 | { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /a^b-b^a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | #define fr(i,n) for (ll i=0;i>a>>b; 41 | cout< 2 | int main(){ 3 | int n,i,a=3; 4 | for(i=0;i<1000 ; i++){ 5 | a=a+5; 6 | 7 | printf("%d\n",a);} 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /big multiply.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "BigIntegerLibrary.hh" 3 | using namespace std; 4 | BigInteger a = 65536; 5 | cout << (a * a * a * a * a * a * a * a); 6 | return 0; 7 | 8 | -------------------------------------------------------------------------------- /capslock.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | int main() { 7 | int a; 8 | char s[105]; 9 | a=0; 10 | scanf("%s", s); 11 | for(int i=0; i96 && a==strlen(s)-1) { 13 | printf("%c", s[0]-32); 14 | for(int i=1; i 2 | using namespace std; 3 | int main() 4 | { 5 | int i,d,e,k,m,j,n,cnt=0; 6 | cin>>n>>k; 7 | for(i=1;icnt){cout<<"-1";} 13 | sort(all(d)); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /cf(A Lazy Caterer Sequence).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int n,c; 6 | cin>>n; 7 | c=((n*(n+1))/2)+1; 8 | cout< 2 | using namespace std; 3 | int main(){ 4 | int h,m; 5 | float a,b,c,d; 6 | while(scanf("%d:%d",&h,&m)==2){ 7 | if(h==0&&m==0) break; 8 | //a=(0.5*(h*60+30)); 9 | //b=(6*m); 10 | c=(.5*((60*h)-(11*m))); 11 | if(c>180){ 12 | d=360-c; 13 | printf("%.3f",d); } 14 | else 15 | printf("%.3f",c);} 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /code forces.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i,j,k,l,n,sum1,sum2,c; 5 | scanf("%d",&n); 6 | for(i=1;i<=n;i++) 7 | { 8 | int sum=0; 9 | scanf("%d %d\n",&k,&l); 10 | sum1=sum+k; 11 | sum2=sum+l; 12 | } 13 | if(sum1>sum2){ 14 | printf("Missak");} 15 | else 16 | printf("chek"); 17 | 18 | if(sum1==sum2) 19 | printf("drew"); 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /codef (706B).c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(){ 3 | int d,p,i,j,count=0; 4 | scanf("%d",&d); 5 | int a[d]; 6 | for(i=0;i=a[j]){ 14 | count++;} 15 | } 16 | printf("%d\n",count); 17 | count=0; 18 | } 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /codemarsal-2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main(){ 4 | int a,b,c,d,e,f,i,m,maxi,mm,n,j,p; 5 | cin>>n; 6 | while(n--){ 7 | cin>>a; 8 | for(i=0;i>b>>c; p=-100; 9 | d=b; c=e; f=d-e; m=f; if(m>p) {maxi=m;} else maxi=p; 10 | e=f+m; if(maxi>e) {mm=maxi ;} else mm=e; 11 | }} 12 | printf("case %d: %d",i+1,mm); 13 | } 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /codemarsal.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main(){ 4 | int a,b,n,i; 5 | cin>>n; 6 | while(n--){ 7 | cin>>a; 8 | if(a<0){ 9 | for(i=a;i<=0;i++){ printf("%d",i); if(i==0)break; else printf(" "); } 10 | } else 11 | for(i=0;i<=a;i++){ 12 | printf("%d",i); if(i==a)break; else printf(" ");} 13 | printf("\n"); 14 | } 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /cokacola.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | long int cola,half,total; 5 | while(scanf("%ld",&cola)==1) 6 | { 7 | if(cola==0) 8 | break; 9 | printf("%ld\n",cola>>1); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contest 1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | char s; 6 | int n,cn=0,cnt=0; 7 | cin>>n; 8 | while(n--){ 9 | 10 | cin>>s; 11 | if(s=='A') cnt++; 12 | if(s=='D') cn++; 13 | } 14 | if(cnt>cn){ cout<<"Anton";} 15 | if(cnt 2 | using namespace std; 3 | int main(){ 4 | char s[100]; 5 | int i,r,cnt=0; 6 | gets(s); 7 | for(i=0;i 2 | using namespace std; 3 | int main() 4 | { 5 | string a; 6 | //char a[100]; 7 | int b[100]; 8 | //gets(a); 9 | cin>>a; 10 | int i, j=0,len=0; 11 | int l = a.size(); 12 | for(i=0 ; i='1')||(a[i]<='100')){ 14 | if(a[i]== '1'|| a[i]== '2' || a[i]=='3' ){ 15 | int c = atoi(&a[i]); 16 | b[j]=c; 17 | j++; 18 | len++; 19 | } 20 | } 21 | sort(b,b+len); 22 | for(i=0;i 2 | using namespace std; 3 | 4 | #define ll long long 5 | int main() 6 | { 7 | ll m,n,i,j,k; 8 | ll l=1, h=1000000; 9 | 10 | 11 | while( l !=h ) 12 | { 13 | ll mid=(l+h+1)/2; 14 | printf("%lld\n", mid); 15 | fflush(stdout); 16 | 17 | char c[3]; 18 | scanf("%s", c); 19 | if( strcmp(c, "<" )==0 ) 20 | { 21 | h=mid-1; 22 | } 23 | else l=mid; 24 | } 25 | printf("! %lld\n", l); 26 | fflush(stdout); 27 | } 28 | -------------------------------------------------------------------------------- /kjhgf.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | long int cola,half,total; 5 | while(scanf("%ld",&cola)==1) 6 | { 7 | if(cola==0) 8 | break; 9 | printf("%ld\n",cola>1); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /kmp.cpp: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /maximam longest substring integer .cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | #define ll long long 6 | 7 | #define sci(x) scanf("%d",&x) 8 | #define scl(x) scanf("%lld",&x) 9 | int main() 10 | { 11 | ll b,c,d,p=0,q=0,n,i,ans=0; 12 | 13 | scanf("%lld" ,&n); 14 | ll a[n]; 15 | for(i=0; i>c; 18 | if(q 2 | int main() 3 | { 4 | int m; 5 | scanf("%d",&m); 6 | //m=k/2.0; 7 | if(m%2==0 && m!=2) 8 | printf("YES"); 9 | else 10 | printf("NO"); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /next round.....c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(){ 3 | int i,j,k,n,cnt=0; 4 | scanf("%d%d",&n,&k); 5 | int a[n]; 6 | for(i=0;i=a[k-1]&&a[i]>0 ){ 11 | cnt++; 12 | }//printf("%d",cnt); 13 | } 14 | printf("%d",cnt); 15 | return 0;} 16 | -------------------------------------------------------------------------------- /output.txt: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /pair power of 2.cpp: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /pp.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,f,gg; 5 | scanf("%d%d",&a,&f); 6 | gg=a+f; 7 | printf("%d+%d=%d\n",a,f,gg); 8 | printf("Hello world\n"); 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /pppp.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int a[8]={1,3,5,7,9,11,13,15}; 6 | for(int i1=0;i1<8;i1++) 7 | for(int i2=0;i2<8;i2++) 8 | for(int i3=0;i3<8;i3++) 9 | // for(int i4=0;i4<8;i4++) 10 | // for(int i5=0;i5<8;i5++) 11 | if((a[i1]+a[i2]+a[i3]) == 30) 12 | printf("%d %d %d \n",a[i1],a[i2],a[i3]); 13 | } 14 | -------------------------------------------------------------------------------- /reverse & add.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int t,count,i,j,k; 5 | long int rev,d,add,num; 6 | scanf("%d",&t); 7 | for(i=0;i 2 | int main(){ 3 | int i,j,n; 4 | char str[20][20],temp[20]; 5 | puts("Enter the no. of string to be sorted"); 6 | scanf("%d",&n); 7 | for(i=0;i<=n;i++) 8 | gets(str[i]); 9 | for(i=0;i<=n;i++) 10 | for(j=i+1;j<=n;j++){ 11 | if(strcmp(str[i],str[j])>0){ 12 | strcpy(temp,str[i]); 13 | strcpy(str[i],str[j]); 14 | strcpy(str[j],temp); 15 | } 16 | } 17 | printf("The sorted string\n"); 18 | for(i=0;i<=n;i++) 19 | if(i>0) 20 | puts(str[i]); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /sort string.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int main(){ 3 | int i,j,n; 4 | char str[20][20],temp[20]; 5 | puts("Enter the no. of string to be sorted"); 6 | scanf("%d",&n); 7 | for(i=0;i<=n;i++) 8 | gets(str[i]); 9 | for(i=0;i<=n;i++) 10 | for(j=i+1;j<=n;j++){ 11 | if(strcmp(str[i],str[j])>0){ 12 | strcpy(temp,str[i]); 13 | strcpy(str[i],str[j]); 14 | strcpy(str[j],temp); 15 | } 16 | } 17 | printf("The sorted string\n"); 18 | for(i=0;i<=n;i++) 19 | puts(str[i]); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /string task....cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main(){ 4 | char s[100]; 5 | int i,r; 6 | gets(s); 7 | for(i=0;i 2 | using namespace std; 3 | #define ll long 4 | struct value 5 | { 6 | int to,from; 7 | }; 8 | 9 | int main() 10 | { 11 | vectorsave; 12 | 13 | ll m,n,v[5000],i; 14 | cin>>n; 15 | for(i=0;i>v[i]; 16 | 17 | for(i=0;iv[j]) index=j; 23 | } 24 | 25 | if(index!=i) 26 | { 27 | value tmp; 28 | tmp.from=i; 29 | tmp.to=index; 30 | 31 | save.push_back(tmp); 32 | 33 | 34 | ll tmp2=v[i]; 35 | v[i]=v[index]; 36 | v[index]=tmp2; 37 | 38 | } 39 | } 40 | 41 | cout< 2 | using namespace std; 3 | 4 | #define ll long long 5 | 6 | int main() 7 | { 8 | printf("Testing dark theme "); 9 | for (ll i=0; i<=10 ; i++) 10 | { 11 | printf("Farhad\n"); 12 | } 13 | } 14 | --------------------------------------------------------------------------------