├── .gitignore ├── Atcoder ├── ABC │ ├── abc104_C-All_Green.cpp │ ├── abc105_A-Atcoder_Crackers.cpp │ ├── abc105_B-Cakes_and_Donuts.cpp │ ├── abc149_C-Next_Prime.cpp │ ├── abc152_C-Low_Elements.cpp │ ├── abc154_C-Distinct_or_Not.cpp │ ├── abc157_C-Guess_The_Number.cpp │ ├── abc161_C-Replacing_Integer.cpp │ ├── abc162_C-Sum_of_gcd_of_Tuples.cpp │ ├── abc166_C-Peaks.cpp │ ├── abc167_C-Skill_Up.cpp │ ├── abc169_C-Multiplication_3.cpp │ ├── abc170_C-Forbiddeen_List.cpp │ ├── abc171_C-One_Quadrillion_and_One_Dalmatians.cpp │ ├── abc174_C-Repsept.cpp │ ├── abc175_C-Walking_Takahashi.cpp │ ├── abc177_A-Don't_be_late.cpp │ ├── abc177_B-Substring.cpp │ ├── abc177_C-Sum_of_product_of_pairs.cpp │ ├── abc177_D-Friends.cpp │ ├── abc177_E-Coprime.cpp │ ├── abc179_C-AxB+C.cpp │ ├── abc182_C-To_3.cpp │ ├── abc184_A-Determinant.cpp │ ├── abc185_A-ABC_Preparation.cpp │ ├── abc185_B-Smartphone_Addition.cpp │ ├── abc186_A-Brick.cpp │ ├── abc186_B-Blocks_on_Grid.cpp │ ├── abc186_C-Unlucky7.cpp │ ├── abc186_D-Sum_of_difference.cpp │ ├── abc187_A-Large_Digits.cpp │ ├── abc187_B-Gentle_Pairs.cpp │ ├── abc187_C-1-SAT.cpp │ ├── abc187_D-Choose_Me.cpp │ ├── abc188_A-Three-Point_Shot.cpp │ ├── abc188_B-Orthogonality.cpp │ ├── abc188_C-ABC_Tournament.cpp │ ├── abc188_D-Snuke_Prime.cpp │ ├── abc189_A-Slot.cpp │ ├── abc189_B-Alcoholic.cpp │ ├── abc189_C-Mandarin_Orange.cpp │ ├── abc190_A-Vey_Vey_Primitive_Game.cpp │ ├── abc190_B-Magic_3.cpp │ ├── abc190_C-Bowls_and_Dishes.cpp │ ├── abc190_D-Staircase_Sequences.cpp │ ├── abc191_A-Vanishing_Pitch.cpp │ ├── abc191_B-Remove_It.cpp │ ├── abc191_C-Digital_Graffiti.cpp │ ├── abc192_A-Star.cpp │ ├── abc192_B-uNrEaDaBlEsTrInG.cpp │ ├── abc192_C-Kaprekar_Number.cpp │ ├── abc193_A-Discount.cpp │ ├── abc193_B-Play_Snuke.cpp │ ├── abc193_C-Unexpressed.cpp │ ├── abc194_A-I_Scream.cpp │ ├── abc194_B-Job_Assignment.cpp │ ├── abc194_C-Squared_Error.cpp │ ├── abc194_D-Journey.cpp │ ├── abc195_A-Health_M_Death.cpp │ ├── abc195_B-Many_Oranges.cpp │ ├── abc196_A-Difference_Max.cpp │ ├── abc196_B-Round_Down.cpp │ ├── abc196_C-Doubled.cpp │ ├── abc199_B-Intersection.cpp │ ├── abc199_C-IPFL.cpp │ ├── abc200_A-Century.cpp │ ├── abc200_B-200th_ABC-200.cpp │ ├── abc200_C-Ringo's_Favorite_Numbers_2.cpp │ ├── abc202_A-Three_Dice.cpp │ ├── abc202_B-180.cpp │ ├── abc202_C-Made_Up.cpp │ ├── abc202_D-aab_aba_baa.cpp │ ├── abc206_A-Maxi-Buying.cpp │ ├── abc206_B-Savings.cpp │ ├── abc206_C-Swappable.cpp │ ├── abc206_D-KAIBUNsyo.cpp │ ├── abc208_C-Fair_Candy_Distribution.cpp │ ├── abc212_A-Alloy.cpp │ ├── abc212_B-Weak_Password.cpp │ ├── abc212_C-Min_Difference.cpp │ ├── abc212_D-Querying_Multiset.cpp │ ├── abc219_A-AtCoder_Quiz_2.cpp │ ├── abc219_B-Maritozzo.cpp │ ├── abc219_C-Neo-lexicographic_Ordering.cpp │ ├── abc222_d-Between_Two_Arrays.cpp │ ├── abc233_A-10yen Stamp.cpp │ ├── abc233_B-A_Reverse.cpp │ ├── abc233_C-Product.cpp │ ├── abc233_D-Count_Interval.cpp │ ├── abc233_E-Σ[k=0..10^100]floor(X/10^k).cpp │ ├── abc234_A-Weird_Function.cpp │ ├── abc234_B-Longest_Segment.cpp │ ├── abc234_C-Happy_New_Year!.cpp │ ├── abc234_D-Prefix_K-th_Max.cpp │ ├── abc234_E-Arithmetic_Number.cpp │ ├── abc235_A-Rotate.cpp │ ├── abc235_B-Climbing_Takahashi.cpp │ ├── abc235_C-The_Kth_Time_Query.cpp │ ├── abc236_A-chukodai.cpp │ ├── abc236_B-Who_is_missing.cpp │ ├── abc236_C-Route_Map.cpp │ ├── abc239_A-Horizon.cpp │ ├── abc239_B-Integer_Division.cpp │ ├── abc239_C-Knight_Fork.cpp │ ├── abc239_D-Prime_Sum_Game.cpp │ ├── abc239_E-Subtree_K-th_Max.cpp │ ├── abc246_A-Four_Points.cpp │ ├── abc246_B-Get_Closer.cpp │ ├── abc246_C-Coupon.cpp │ ├── abc248_A-Lacked_Number.cpp │ ├── abc248_B-Slimes.cpp │ ├── abc269_C-Submask.cpp │ ├── abc276_A-Rightmost.cpp │ ├── abc276_B-Adjacency_List.cpp │ ├── abc276_C-Previous_Permutation.cpp │ ├── abc276_D-Divide_by_2_or_3.cpp │ ├── abc276_E-Round_Trip.cpp │ ├── abc278_A-Shift.cpp │ ├── abc278_C-FF.cpp │ ├── abc281A-Count Down.cpp │ ├── abc281B-Sandwich Number.cpp │ └── abc281C-Circular Playlist.cpp ├── ARC │ ├── arc104_A-Plus_Minus.cpp │ ├── arc105_A-Fourtune_Cookies.cpp │ ├── arc106_A-106.cpp │ ├── arc107_A-Simple_Math.cpp │ ├── arc108_A-Sum_and_Product.cpp │ ├── arc108_B-Abbreviate_Fox.cpp │ ├── arc109_A-Hands.cpp │ ├── arc110_A-Redundant_Redundancy.cpp │ ├── arc111_A-Simple_Math_2.cpp │ ├── arc112_A-A-B=C.cpp │ ├── arc117_A-God_Sequence.cpp │ ├── arc117_B-ARC_Wrecker.cpp │ ├── arc133_A-Erase_By_Value.cpp │ └── arc134_A-Bridge_and_Sheets.cpp ├── Educational_DP_Contest │ ├── A-Frog_1.cpp │ ├── B-Frog_2.cpp │ ├── C-Vacation.cpp │ ├── D-Knapsack_1.cpp │ ├── E-Knapsack_2.cpp │ ├── F-LCS.cpp │ ├── G-Longest_Path.cpp │ ├── H-Grid_1.cpp │ ├── I-Coins.cpp │ ├── J-Sushi.cpp │ ├── K-Stones.cpp │ ├── L-Deque.cpp │ ├── M-Candies.cpp │ └── N-Slimes.cpp ├── jsc2021_A-Competition.cpp ├── jsc2021_B-Xor_of_Sequences.cpp ├── jsc2021_C-Max_GCD_2.cpp ├── jsc2021_D-Nowhere_P.cpp ├── keyence2021_A-Two_Sequence_2.cpp ├── keyence2021_B-Mex_Boxes.cpp └── zone2021_A-UFO_Invasion.cpp ├── Automated_Script_to_Create_File.sh ├── CP.css ├── CSES ├── Dynamic_Programming │ ├── coin_combinationsI.cpp │ ├── coin_combinationsII.cpp │ ├── dice_combinations.cpp │ ├── minimizing_coins.cpp │ ├── readme.md │ └── removing_digits.cpp ├── Graph_Algorithms │ └── Building_Roads.cpp ├── Introductory_Problems │ ├── Apple_Division.cpp │ ├── Bit_Strings.cpp │ ├── Chessboard_and_Queens.cpp │ ├── Coin_Piles.cpp │ ├── Creating_Strings_I.cpp │ ├── Digit_Queries.cpp │ ├── Gray_Code(Bitset).cpp │ ├── Grey_Code(Recursive).cpp │ ├── Grid_Paths.cpp │ ├── Increasing_Array.cpp │ ├── Missing_Number.cpp │ ├── Number_Spiral.cpp │ ├── Palindrome_Reorder.cpp │ ├── Permutations.cpp │ ├── Repetitions.cpp │ ├── Trailing_Zeros.cpp │ ├── Two_Knights.cpp │ ├── Two_Sets.cpp │ ├── Weird_Algorithum.cpp │ └── readme.md ├── Mathematics │ ├── Exponentiation.cpp │ └── Exponentiation_II.cpp ├── Sorting_and_Searching │ ├── Apartments.cpp │ ├── Collecting Numbers.cpp │ ├── Concert_Tickets.cpp │ ├── Ferris_Wheel.cpp │ ├── Josephus Problem I.cpp │ ├── Maximum Subarray Sum.cpp │ ├── Missing Coin Sum.cpp │ ├── Movie Festival II.cpp │ ├── Movie_Festival.cpp │ ├── Playlist.cpp │ ├── Readme.md │ ├── Restaurant_Customers.cpp │ ├── Stick Lengths.cpp │ ├── Subarray Sums I & II.cpp │ ├── Sum of Four Values.cpp │ ├── Sum of Three Values.cpp │ ├── Sum of Two Values.cpp │ ├── distinct_numbers.cpp │ └── towers.cpp └── readme.md ├── Codechef ├── A1.cpp ├── ABOVEAVG.cpp ├── ADADISH.cpp ├── ADAKING.cpp ├── ADAMAT.cpp ├── ADASCOOL.cpp ├── ADDSQUARE.cpp ├── ALEXNUMB.cpp ├── ALPHABET.cpp ├── ALTARAY.cpp ├── AMMEAT.cpp ├── AMMEAT2.cpp ├── AMR15A.cpp ├── AMR15D.cpp ├── AMSGAME1.cpp ├── ANDOR.cpp ├── ANKTRAIN.cpp ├── ANTSCHEF.cpp ├── ANUARM.cpp ├── ANUBTG.cpp ├── ANUDTC.cpp ├── ANUTHM.cpp ├── ANUWTA.cpp ├── APPROX.cpp ├── AREAPERI.cpp ├── ARRGAME.cpp ├── ARRROT.cpp ├── ATM2.cpp ├── ATTND.cpp ├── ATWNT.cpp ├── AVGARR.cpp ├── AXNODR.cpp ├── BENCHP.cpp ├── BFRIEND.cpp ├── BFTT.cpp ├── BIGSALE.cpp ├── BILLRD.cpp ├── BINARR.cpp ├── BININSC.cpp ├── BINMIS.cpp ├── BINSUBS.cpp ├── BMI.cpp ├── BOLT.cpp ├── BOOLGAME.cpp ├── BOWLERS.cpp ├── BRACKETS.cpp ├── BRKBKS.cpp ├── BRKNLIFE.cpp ├── BSTOPS.cpp ├── BSXOR.cpp ├── BUGCAL.cpp ├── BUNKGUY.cpp ├── Billiards.cpp ├── C00K0FF.cpp ├── CACHEHIT.cpp ├── CALCULUS.cpp ├── CANDY123.cpp ├── CAPPLE.cpp ├── CARSELL.cpp ├── CATDOGS.cpp ├── CCBTS01.cpp ├── CCHEAVEN.cpp ├── CCISLAND.cpp ├── CCOOK.cpp ├── CDQU5.cpp ├── CENS20A.cpp ├── CENS20D.cpp ├── CENS20G.cpp ├── CEQUAL.cpp ├── CFMM.cpp ├── CFRTEST.cpp ├── CFS2001.cpp ├── CHAOSEMP.cpp ├── CHARGES.cpp ├── CHCHCL.cpp ├── CHCOINSG.cpp ├── CHEALG.cpp ├── CHECHOC.cpp ├── CHEF1001.cpp ├── CHEF1002.cpp ├── CHEFA.cpp ├── CHEFAPAR.cpp ├── CHEFARRP.cpp ├── CHEFCAKE.cpp ├── CHEFCBA.cpp ├── CHEFCH.cpp ├── CHEFCHR.cpp ├── CHEFDETE.cpp ├── CHEFEQ.cpp ├── CHEFEZQ.cpp ├── CHEFFED.cpp ├── CHEFGR.cpp ├── CHEFING.cpp ├── CHEFINSQ.cpp ├── CHEFLCM.cpp ├── CHEFNWRK.cpp ├── CHEFPAT.cpp ├── CHEFPRMS.cpp ├── CHEFRECP.cpp ├── CHEFRES.cpp ├── CHEFRP.cpp ├── CHEFSETC.cpp ├── CHEFSOCK.cpp ├── CHEFSQ.cpp ├── CHEFST.cpp ├── CHEFSTLT.cpp ├── CHEFSTON.cpp ├── CHEFSTR1.cpp ├── CHEFSTUD.cpp ├── CHEFSUM.cpp ├── CHEFWARS.cpp ├── CHEFWORK.cpp ├── CHEFZOT.cpp ├── CHEGLOVE.cpp ├── CHESUB.cpp ├── CHESUM.cpp ├── CHFAR.cpp ├── CHFIDEAL.cpp ├── CHFINTRO.cpp ├── CHFM.cpp ├── CHFMIST.cpp ├── CHFMOT18.cpp ├── CHFNSWAP.cpp ├── CHFNSWPS.cpp ├── CHFPARTY.cpp ├── CHFTIRED.cpp ├── CHILLS.cpp ├── CHN09.cpp ├── CHN15A.cpp ├── CHNGOR.cpp ├── CHNUM.cpp ├── CHOPRT.cpp ├── CHPINTU.cpp ├── CHRL2.cpp ├── CHSERVE.cpp ├── CIELAB.cpp ├── CIELDIST.cpp ├── CIELRCPT.cpp ├── CIRCHAOS.cpp ├── CK87MEDI.cpp ├── CKISSHUG.cpp ├── CKWLK.cpp ├── CLEANUP.cpp ├── CLFIBD.cpp ├── CLIPLX.cpp ├── CLLCM.cpp ├── CLOSEVOWEL.cpp ├── CLPNT.cpp ├── CM164364.cpp ├── CNDYGAME.cpp ├── CNOTE.cpp ├── CO92JUDG.cpp ├── CO92SUBW.cpp ├── COG2002.cpp ├── COLDPLAY.cpp ├── COLGLF4.cpp ├── COLOR.cpp ├── COMME.cpp ├── COMPILER.cpp ├── COMPRESSVD.cpp ├── CONFLIP.cpp ├── CONSADD.cpp ├── CONVSTR.cpp ├── COPR16G.cpp ├── COPS.cpp ├── CPAIRS.cpp ├── CRDGAME.cpp ├── CRDGAME3.cpp ├── CSUB.cpp ├── CUTBOARD.cpp ├── CV.cpp ├── CVDRUN.cpp ├── CVOTE.cpp ├── DARLIG.cpp ├── DATE1.cpp ├── DECINC.cpp ├── DECODEIT.cpp ├── DECSTR.cpp ├── DEVUGRAP.cpp ├── DGTMAGIC.cpp ├── DIFFSUM.cpp ├── DIRECTI.cpp ├── DISCHAR.cpp ├── DISCSHOP.cpp ├── DISTCODE.cpp ├── DISTDILEM.cpp ├── DIVNINE.cpp ├── DIVTHREE.cpp ├── DOUBLEDDIST.cpp ├── DPS.cpp ├── DRCHEF.cpp ├── DREDIV.cpp ├── DSTAPLS.cpp ├── DWNLD.cpp ├── EATTWICE.cpp ├── EID2.cpp ├── ELEVSTRS.cpp ├── ENGXOR.cpp ├── ENTEXAM.cpp ├── EOOPR.cpp ├── EQDIV.cpp ├── EQUALITY.cpp ├── EQUATION.cpp ├── ERROR.cpp ├── ESUBXOR.cpp ├── EVENDIFF.cpp ├── EVENGAME.cpp ├── EVENPSUM.cpp ├── EVENTUAL.cpp ├── EXAMCHT.cpp ├── EXUNA.cpp ├── FAIRELCT.cpp ├── FCTRL2.cpp ├── FEMA2.cpp ├── FIBEASY.cpp ├── FINDSHOES.cpp ├── FLIP.cpp ├── FLIPSORT.cpp ├── FLOW005.cpp ├── FLOW007.cpp ├── FLOW008.cpp ├── FLOW009.cpp ├── FLOW010.cpp ├── FLOW011.cpp ├── FLOW014.cpp ├── FLOW016.cpp ├── FLOW017.cpp ├── FLOW018.cpp ├── FORESTGA.cpp ├── FRGTNLNG.cpp ├── FRK.cpp ├── FROGS.cpp ├── FROGV.cpp ├── FRUITS.cpp ├── FSQRT.cpp ├── GAMEPROF.cpp ├── GASOLINE.cpp ├── GCD2.cpp ├── GCDMOD.cpp ├── GCDOPS.cpp ├── GCDSET.cpp ├── GDOG.cpp ├── GDPERM.cpp ├── GEOPOS.cpp ├── GKSMNLC.cpp ├── GMINEQ.cpp ├── GOODBAD.cpp ├── GOODBINSTR.cpp ├── GOODGRID.cpp ├── GRANAMA.cpp ├── GRID.cpp ├── GRIDGM.cpp ├── GROUPS.cpp ├── GSUB.cpp ├── GUESSIT.cpp ├── GUESSNUM.cpp ├── GVAWAY.cpp ├── HDIVISR.cpp ├── HEADBOB.cpp ├── HELPLIRA.cpp ├── HILLS.cpp ├── HIRETEST.cpp ├── HORSES.cpp ├── HOTNCOLD.cpp ├── HOWMANY.cpp ├── HP18.cpp ├── HS08TEST.cpp ├── ICL1902.cpp ├── ICM0001.cpp ├── ICM0003.cpp ├── ICM0005.cpp ├── ICM0013.cpp ├── IMDB.cpp ├── INCRDEC.cpp ├── INFERNO.cpp ├── INTEST.cpp ├── INTRVS.cpp ├── IPCCERT.cpp ├── IPCTRAIN.cpp ├── IRSTXOR.cpp ├── ISITCAKE.cpp ├── ISREC.cpp ├── ISS.cpp ├── ISSNAKE.cpp ├── J7.cpp ├── JOHNY.cpp ├── KAVGMAT.cpp ├── KCON.cpp ├── KFIB.cpp ├── KFOLD.cpp ├── KINGSHIP.cpp ├── KOL15A.cpp ├── KOL16J.cpp ├── KPRIME.cpp ├── KTTABLE.cpp ├── L56GAME.cpp ├── LAPIN.cpp ├── LCH15JAB.cpp ├── LCPESY.cpp ├── LEBOMBS.cpp ├── LEDIV.cpp ├── LEMEMON.cpp ├── LEPERMUT.cpp ├── LEXOPAL.cpp ├── LIFELTD.cpp ├── LIKECS01.cpp ├── LINCHESS.cpp ├── LISDIGIT.cpp ├── LONGSEQ.cpp ├── LOOP.cpp ├── LOSTMAX.cpp ├── LTM40AB.cpp ├── LUCKFOUR.cpp ├── LUCKY5.cpp ├── LUCKYSTR.cpp ├── LUNCHTIM.cpp ├── MAANDI.cpp ├── MAGICHF.cpp ├── MAGICMED.cpp ├── MAKEHAPP.cpp ├── MAKEZERO.cpp ├── MAKPERM.cpp ├── MANYCHEF.cpp ├── MANYSUMS.cpp ├── MATCHES.cpp ├── MAX2.cpp ├── MAXAND18.cpp ├── MAXDIFF.cpp ├── MAXFUN.cpp ├── MAXMEX.cpp ├── MAXORMIN.cpp ├── MAXREM.cpp ├── MAXTHEMIN.cpp ├── MAZE100.cpp ├── MEXSTR.cpp ├── MGCSET.cpp ├── MINEAT.cpp ├── MINIL.cpp ├── MINPERM.cpp ├── MISSP.cpp ├── MIXCOLOR.cpp ├── MIXGA.cpp ├── MLINE.cpp ├── MNMX.cpp ├── MODEFREQ.cpp ├── MODEQ.cpp ├── MOVIEWKN.cpp ├── MTE.cpp ├── MUDAS.cpp ├── MUFFINS3.cpp ├── MULTHREE.cpp ├── MVALUE.cpp ├── MXCH.cpp ├── MXMODSUM.cpp ├── NAICHEF.cpp ├── NAME1.cpp ├── NAME2.cpp ├── NDIFFPAL.cpp ├── NOLOGIC.cpp ├── NOMATCH.cpp ├── NONADJFLIP.cpp ├── NOTATRI.cpp ├── NOTIME.cpp ├── NOTUNIT.cpp ├── NPLQ19D.cpp ├── NTCOL.cpp ├── NUM239.cpp ├── NUMCOMP.cpp ├── NUMCOMP1.cpp ├── NUMGAME2.cpp ├── ODDDIV.cpp ├── OMWG.cpp ├── ONP.cpp ├── ORAND.cpp ├── OROFAND.cpp ├── ORTHODOX.cpp ├── PAIRING.cpp ├── PAJAPONG.cpp ├── PALL01.cpp ├── PAPARAZI.cpp ├── PASSWD.cpp ├── PATHSUMS.cpp ├── PAWRI.cpp ├── PCJ18A.cpp ├── PCJ18B.cpp ├── PERFCONT.cpp ├── PERMPAL.cpp ├── PERMUT2.cpp ├── PLAYFIT.cpp ├── PLAYPIAN.cpp ├── PLAYSTR.cpp ├── PLMU.cpp ├── PLZLYKME.cpp ├── POLYREL.cpp ├── POPGATES.cpp ├── POSAND.cpp ├── POSPREFS.cpp ├── POTATOES.cpp ├── PPATTERN.cpp ├── PPSUM.cpp ├── PPTEST.cpp ├── PRB01.cpp ├── PRESENTS.cpp ├── PRFXGD.cpp ├── PRGIFT.cpp ├── PRICECON.cpp ├── PRIGAME.cpp ├── PRIME1.cpp ├── PRIMESM.cpp ├── PROC18A.cpp ├── PROSUM.cpp ├── PROXYC.cpp ├── PSEUDOSORT.cpp ├── PTMSSNG.cpp ├── PTUPLES.cpp ├── PUPPYGM.cpp ├── PUSH7PA.cpp ├── QFUN.cpp ├── QUADROOT.cpp ├── QUEENATTACK.cpp ├── RACINGEN.cpp ├── RAINBOWA.cpp ├── RD19.cpp ├── REACTION.cpp ├── RECNDNOS.cpp ├── RECNDSTR.cpp ├── RECTANGL.cpp ├── RECTSQ.cpp ├── REDONE.cpp ├── REMISS.cpp ├── REPLESX.cpp ├── RESQ.cpp ├── RESTORE.cpp ├── REVERSE.cpp ├── RIGHTRI.cpp ├── RISK.cpp ├── RNDPAIR.cpp ├── ROOTTREE.cpp ├── ROWCOLOP.cpp ├── RPD.cpp ├── RRCODE.cpp ├── RRCOPY.cpp ├── RRECIPE.cpp ├── RRJOKE.cpp ├── RRSTONE.cpp ├── RRSUM.cpp ├── S10E.cpp ├── SAD.cpp ├── SALARY.cpp ├── SCALSUM.cpp ├── SCTFIGHT.cpp ├── SDICE.cpp ├── SDSTRING.cpp ├── SEDARR.cpp ├── SEGM01.cpp ├── SHUFFLE.cpp ├── SIMDISH.cpp ├── SIMPSTAT.cpp ├── SINS.cpp ├── SKMP.cpp ├── SLAB.cpp ├── SMPAIR.cpp ├── SNAKPROC.cpp ├── SNCKYEAR.cpp ├── SNELECT.cpp ├── SNUG_FIT.cpp ├── SOCKS1.cpp ├── SOLBLTY.cpp ├── SOLDVAL.cpp ├── SPACEARR.cpp ├── SPCANDY.cpp ├── SPELLBOB.cpp ├── SPOON.cpp ├── SPTREE.cpp ├── SSCRIPT.cpp ├── SSEC0005.cpp ├── SSEC0006.CPP ├── SSEC0010.cpp ├── SSEC0014.cpp ├── SSEC0020.cpp ├── SSO.cpp ├── STACKS.cpp ├── STBMEX.cpp ├── STICKS.cpp ├── STONES.cpp ├── STRLBP.cpp ├── STRNO.cpp ├── STRPALIN.cpp ├── SUBGCD.cpp ├── SUBINC.cpp ├── SUBSFREQ.cpp ├── SUMPAIR.cpp ├── SUMPOS.cpp ├── SUMTRIAN.cpp ├── SUMXOR2.cpp ├── SWAP10HG.cpp ├── TABLET.cpp ├── TALAZY.cpp ├── TANDJ1.cpp ├── TANDP.cpp ├── TAVISUAL.cpp ├── TCTCTOE.cpp ├── TEAMNAME.cpp ├── TEMPLELA.cpp ├── TEST.cpp ├── THREE.cpp ├── THREEDIF.cpp ├── THREEFR.cpp ├── TICKETS5.cpp ├── TLG.cpp ├── TOTSCR.cpp ├── TOWIN.cpp ├── TRACE.cpp ├── TREE2.cpp ├── TRICOIN.cpp ├── TRISQ.cpp ├── TRUEDARE.cpp ├── TSORT.cpp ├── TSTROBOT.cpp ├── TTENIS.cpp ├── TWEED.cpp ├── TWONMS.cpp ├── TWOSTR.cpp ├── TWOVSTEN.cpp ├── TWTCLOSE.cpp ├── UNITGCD.cpp ├── URCALC.cpp ├── USANBOLT.cpp ├── UTMOPR.cpp ├── UWCOI20A.cpp ├── VALIDSTK.cpp ├── VCS.cpp ├── VILLINE.cpp ├── VILTRIBE.cpp ├── VOWELTB.cpp ├── WALK.cpp ├── WASHHAND.cpp ├── WATERFLOW.cpp ├── WEIGHTBL.cpp ├── WIPL.cpp ├── WWALK.cpp ├── XORAGN.cpp ├── XOREQUAL.cpp ├── XORGAND.cpp ├── XORGM.cpp ├── XORNEY.cpp ├── XORNUBER.cpp ├── XOR_PAL.cpp ├── XXOORR.cpp ├── ZOZ.cpp ├── even_matrix.cpp ├── ice_cream.cpp ├── price_control.cpp ├── readme.md ├── string.cpp └── tom_jerry.cpp ├── Codeforces ├── 1000A-Codehorses_T-shirts.cpp ├── 1006A-Adjacent_Replacements.cpp ├── 1006B-Polycarp`s_Practice.cpp ├── 1006C-Three_Parts_of_the_Array.cpp ├── 1008A-Romanji.cpp ├── 1008B-Turn_the_rectangles.cpp ├── 1011B-Planning_The_Expedition.cpp ├── 1013A-Piles_With_Stones.cpp ├── 1013B-And.cpp ├── 1015B-Obtain_the_String.cpp ├── 1015C-Songs_Compression.cpp ├── 1017B-The_Bits.cpp ├── 1020B-Badge.cpp ├── 1023A-Single Wildcard Pattern Matching.cpp ├── 1023C-Bracket_Subsequence.cpp ├── 1025B-Weakend_Common_Divisor.cpp ├── 1027A-Panlindromic_twist.cpp ├── 1027B-Numbers_on_the_Chessboard.cpp ├── 1028B-Unnatural_Conditions.cpp ├── 1029B-Creating_the_Contest.cpp ├── 102B-Sum_of_Digits.cpp ├── 1030B-Vasya_and_Cornfield.cpp ├── 1032B-Personalized_Cup.cpp ├── 1033A-King_Escape.cpp ├── 1033B-Square_Difference.cpp ├── 1037B-Reach_Median.cpp ├── 1037C-Equalize.cpp ├── 1038A-Equality.cpp ├── 1038B-Non-Coprime_Partition.cpp ├── 1038C-Gambling.cpp ├── 1042A-Benches.cpp ├── 1042B-Vitamins.cpp ├── 1051A-Vasya_And_Password.cpp ├── 1051B-Relatively_prime_pairs.cpp ├── 1055A-Metro.cpp ├── 1060B-Maximum_Sum_of_Digits.cpp ├── 1062B-Math.cpp ├── 1065B-Vasya_and_Isolated_Vertices.cpp ├── 1073A-Diverse_substring.cpp ├── 1073B-Vasya_and_books.cpp ├── 1075A-The_King`s_Race.cpp ├── 1075B-Taxi_drivers_and_Lyft.cpp ├── 1076A-Minimizing_the_String.cpp ├── 107B-Basketball_Team.cpp ├── 1081E-Missing_Numbers.cpp ├── 1082A-Vasya_and_Book.cpp ├── 1088B-Ehab_and_substraction.cpp ├── 108A-Palindromic_Times.cpp ├── 1091B-New_Year_and_Treasure_Geolocation.cpp ├── 1095B-Array_Stabilization.cpp ├── 1097A-Gennady_and_a_card_game.cpp ├── 1099B-Square_and_Segements.cpp ├── 109A-Lucky_Sum_of_Digits.cpp ├── 1100C-NN_and_the_Optical_Illusion.cpp ├── 1101A-Minimum_integer.cpp ├── 1104A-Splitting_into_digits.cpp ├── 1104B-Game_with_string.cpp ├── 1105ASalem_and_Sticks.cpp ├── 1106D-Lunar_New_Year_and_a_Wander.cpp ├── 1107B-Digital_root.cpp ├── 1108A-Two_distinct_points.cpp ├── 1108B-Divisors_of_Two_Integers.cpp ├── 1108C-Nice_Garland.cpp ├── 110B-Lucky_String.cpp ├── 1111A-Superhero_transofmation.cpp ├── 1117A-Best_Subsegment.cpp ├── 1117B-Emotes.cpp ├── 1118A-Water_Buying.cpp ├── 1118B-Tanya_and_Candies.cpp ├── 1121B-Mike_and_Children.cpp ├── 1131C-Birthday.cpp ├── 1132A-Regular_Bracket_Sequence.cpp ├── 1133C-Balanced_Team.cpp ├── 1136B-Nastya_Is_Playing_Computer_Games.cpp ├── 1138A-Sushi_for_Two.cpp ├── 1140B-Good-String.cpp ├── 1140D-Minimum_Triangulation.cpp ├── 1141B-Maximal Continuous Rest.cpp ├── 1143B-Nirvana.cpp ├── 1144B-Parity_alternated_deletions.cpp ├── 1144C-Two_suffeled_sequences.cpp ├── 1149A-Prefix_Sum_Primes.cpp ├── 114A-Cifera.cpp ├── 1151A-Maxim_and_biology.cpp ├── 1154B-Make_Them_Equal.cpp ├── 1155A-Reverse_a_substring.cpp ├── 1155B-Game_with_Telephone_Numbers.cpp ├── 1156A-Inscribed_Figures.cpp ├── 1157A-Reachable_number.cpp ├── 1157B-Long_Number.cpp ├── 1165A-Remainder.cpp ├── 1165B-Polycarp_training.cpp ├── 1166A-Silent_Classroom.cpp ├── 1166B-All_the_Vowels_Please.cpp ├── 1167C-News_Distribution.cpp ├── 116B-Little_Pigs_and_Wolves.cpp ├── 1173B-Nauuo_and_Chess.cpp ├── 1174A-Ehab_fails_to_be_thanos.cpp ├── 1174B-Ehab_Is_an_Odd_Person.cpp ├── 1176B-Merge_it!.cpp ├── 1176E-Cover_it!.cpp ├── 1177A-DIgits_Sequence(Easy_Edition).cpp ├── 1177B-Digit_Sequence(Hard_Edition).cpp ├── 1178C-Tiles.cpp ├── 1182A-Filling_shapes.cpp ├── 1183C-Computer_Game.cpp ├── 1184A1-Heidi_Learns_Hashing(Easy).cpp ├── 1185A-Rpoewalkers.cpp ├── 1185B-Email_from_polycarp.cpp ├── 1185C1-Exam_in_BerSU(easy_version).cpp ├── 1186A-Vus_the_Cossack_and_a_Contest.cpp ├── 1187B-Letters_Shop.cpp ├── 1189B-Number_Circle.cpp ├── 118B-Present_from_Lena.cpp ├── 118D-Caesar's_Legions.cpp ├── 1191B-Tokitsukaze_and_Mahjong.cpp ├── 1194B-Yet_Another_Crosses_Problem.cpp ├── 1194C-FromS_To_T.cpp ├── 1195B-Sport_Mafia.cpp ├── 1196B-Odd_Sum_Segments.cpp ├── 1199B-Water_lily.cpp ├── 11A-Increasing_sequence.cpp ├── 1200A-Hotelier.cpp ├── 1200B-Block_Adventure.cpp ├── 1203A-Circle_of_students.cpp ├── 1203B_Equal_Rectabgles.cpp ├── 1204A-BowWow_and_the_timetable.cpp ├── 1205A-Almost_Equal.cpp ├── 1207B-Square_Filling.cpp ├── 1213A-Chips Moving.c ├── 1213B-Bad_Prices.cpp ├── 1213C-Book_Reading.cpp ├── 1214C-Bad_Sequence.cpp ├── 1215A-Yellow_cards.cpp ├── 121A-Lucky_Sum.cpp ├── 1220A-Cards.cpp ├── 1220B-Multiplication_Table.cpp ├── 1220C-Substring_Game_in_the_Lesson.cpp ├── 1221A-2048Game.cpp ├── 1221B-Knights.cpp ├── 1221C-Perfect_Team.cpp ├── 1225A-Forgetting_Things.cpp ├── 1225B1-TV_Subscriptions(Easy_Version).cpp ├── 1225B2-TV_Subscriptions(Hard_Version).cpp ├── 1227A-Math_Problem.cpp ├── 1227B-Box.cpp ├── 1228A-Distinct Digits.cpp ├── 122A-Lucky_Division.cpp ├── 122B-Lucky_substring.cpp ├── 1230B-Ania_and_minimizing.cpp ├── 1231C-Increasing_Matrix.cpp ├── 1234B1-Social_Network(easy_version).cpp ├── 1234B2.Social_Network(hard_version).cpp ├── 1236A-Stones.cpp ├── 1236C-Labs.cpp ├── 1237A-Balanced_Rating_Changes.cpp ├── 1237B-Balanced_Tunnel.cpp ├── 1238B-Kill'Em_All.cpp ├── 1243B1_Character_Swap.cpp ├── 1245A-Good_ol_Numbers_Coloring.cpp ├── 1245B-Restricted_RPS.cpp ├── 1249A-Yet_Another_Dividing_into_Teams.cpp ├── 1249B1-Books_Exchange.cpp ├── 1249B2-Books_Exhange(hard_version).cpp ├── 1249C1-Good_Numbers(easy_version).cpp ├── 1249C2-Good_Numbers(hard_version).cpp ├── 124A-The_number_of_position.cpp ├── 1250F-Data_Center.cpp ├── 1251A-Broken_Keyword.cpp ├── 1251C-Minimize_The_Integer.cpp ├── 1252A-Copy_Homew0rk.cpp ├── 1257C-Dominated_Subarray.cpp ├── 1260B-Obtain_Two_Zeroes.cpp ├── 1263A-Sweet_Problem.cpp ├── 1265A-Beautiful_String.cpp ├── 1265B-Beautiful_Numbers.cpp ├── 1266A-Competitive_Programmer.cpp ├── 1266B-Dice_Tower.cpp ├── 1266C-Diverse_Matrix.cpp ├── 1270B-Interesting_Subarray.cpp ├── 1271A-Suits.cpp ├── 1271B-Blocks.cpp ├── 1272B-Snow_Walking_Robot.cpp ├── 1272C-Yet_Another_Broken_Keyword.cpp ├── 1277B-Make_Them_Odd.cpp ├── 1278A-Shuffle_Hashing.cpp ├── 1278B-A_and_B.cpp ├── 1279A-New_Year_Garland.cpp ├── 1279B-Verse_For_Santa.cpp ├── 1285A-Mezo_Playing_Zoma.cpp ├── 1285B-Just_Eat_It!.cpp ├── 1285C-Fadi_and_LCM.cpp ├── 1288B-Yet_Another_Meme_Problem.cpp ├── 1291A-even_but_not_even.cpp ├── 1291B-Array_Sharpening.cpp ├── 1293B-JOE_is_on_TV!.cpp ├── 1294A-Collecting_Coins.cpp ├── 1294B-Collecting_Packages.cpp ├── 1294C-Product_of_Three_Numbers.cpp ├── 12A-Super_Agent.cpp ├── 1300B-Assigning_to_Classes.cpp ├── 1305B-Kuroni_and_Simple_Strings.cpp ├── 1311B-WeirdSort.cpp ├── 1311C-Perform_the_Combo.cpp ├── 1312A-Two Regular Polygons.cpp ├── 1312B-Bogosort.cpp ├── 1315A-Dead_Pixel.cpp ├── 1315B-Homecoming.cpp ├── 1315C-Restoring_Permutation.cpp ├── 131B-Opposites_Attract.cpp ├── 131C-The_World_is_a_Theatre.cpp ├── 1322A-Unusal_Competitions.cpp ├── 1323A-Even_Subset_Sum_Problem.cpp ├── 1324B-Yet_Another_Palindrome_Problem.cpp ├── 1324C-Frog_Jumps.cpp ├── 1326A-Bad_ugly_numbers.cpp ├── 1326B-Maximums.cpp ├── 1326C-Permutation_Partitions.cpp ├── 1327A-Sum_of_Odd_Integers.cpp ├── 1327B-Princessess_and_Princes.cpp ├── 1328B-K-th_Beautiful_String.cpp ├── 1328C-Ternary_XOR.cpp ├── 1333B-Kind_Anton.cpp ├── 1339A-Filling_Diamond.cpp ├── 1339B-Sorted_Adjacent_Differences.cpp ├── 1340B-Longest_Palindrome.cpp ├── 1341A-Nastya_and_Rice.cpp ├── 1341B-Nastya_and_Door.cpp ├── 1342A-Road_To_Zero.cpp ├── 1342B-Binary_Period.cpp ├── 1342C-Yet_Another_Counting_Problem.cpp ├── 1354B-Ternary_String.cpp ├── 1355A-Sequence_with_digits.cpp ├── 1355B-Young_explorers.cpp ├── 1358A-Park Lighting.cpp ├── 1358B-Maria Breaks the Self-isolation.cpp ├── 1359A-Berland_Poker.cpp ├── 1359B-New_Theatre_Square.cpp ├── 1360A-Minimal Square.cpp ├── 1360B-Honest Coach.cpp ├── 1360C-Similar Pairs.cpp ├── 1360D-Buying_Sholvels.cpp ├── 1360E-Polygon.cpp ├── 1362A-Johnny and Ancient Computer.cpp ├── 1362B-Johnny_and_His_Hobies.cpp ├── 1363A-Odd_selection.cpp ├── 1364A-XXXXX.cpp ├── 1364B-Most_socially-distanced_subsequence.cpp ├── 1365A-Matrix Game.cpp ├── 1365B-Trouble sort.cpp ├── 1366A-Shovels_and_Swords.cpp ├── 1367A-Short_Substrings.cpp ├── 1367B-Even_array.cpp ├── 1368A-C+=.cpp ├── 1369A-FashionabLee.cpp ├── 1369B-AccurateLee.cpp ├── 1370A-Maximum_gcd.cpp ├── 1370B-GCD_compresssion.cpp ├── 1370C-Number_Game.cpp ├── 1371A-Magical_sticks.cpp ├── 1371B-Magical_claedar.cpp ├── 1371C-A_cookie_for_you.cpp ├── 1372A-Omkar_and_Completion.cpp ├── 1372B-Omkar_and_Last_Class_of_Math.cpp ├── 1372C-Omkar_and_Baseball.cpp ├── 1373A-Donut_shops.cpp ├── 1373B-01_game.cpp ├── 1373C-Pluses_and_Minuses.cpp ├── 1374A-Required_remainder.cpp ├── 1374B-Multiply_by_2_divide_by_6.cpp ├── 1374C-Move_brackets.cpp ├── 1375A-Sign_Flipping.cpp ├── 1375B-Neighbor_Grid.cpp ├── 1379A-Acacius_and_String.cpp ├── 137B-Permutation.cpp ├── 1380A-Three_Indices.cpp ├── 1380C-Create_The_Teams.cpp ├── 1382A-Common_Subsequence.cpp ├── 1382B-Sequential_Nim.cpp ├── 1384A-Common_Prefixes.cpp ├── 1385A-Three_Pairwise_Maximums.cpp ├── 1385B-Restore_the_permutation_by_merger.cpp ├── 1385C-Make_it_Good.cpp ├── 1388B-Captain_Flint_and_a_Long_Voyage.cpp ├── 1389A-Lcm_problem.cpp ├── 1390A-123_sequence.cpp ├── 1391A-Suborrays.cpp ├── 1391B-Fix_You.cpp ├── 1392A-Omkar_and_Password.cpp ├── 1392B-Omkar_and_infinity_Clock.cpp ├── 1392C-Omkar_and_Waterslide.cpp ├── 1393A-Rainbow_dash_fluttershy_and_chess_coloring.cpp ├── 1393B-Applejack_and_Storages.cpp ├── 1395A-Boboniu_likes_to_color_balls.cpp ├── 1395B-boboniu_Plays_chess.cpp ├── 1396B-Stoned_Game.cpp ├── 1397A-Juggling_Letters.cpp ├── 1398A-Bad_Triangle.cpp ├── 1398B-Substring_Removal_Game.cpp ├── 1398C-Good_Subarray.cpp ├── 1399A-Remove-smallest.cpp ├── 1399B-Gifts-fixing.cpp ├── 1399C-Boats-competition.cpp ├── 1399D-Binary_String_to_subsequence.cpp ├── 139A-Petr_and_Book.cpp ├── 13A-Numbers.cpp ├── 1400A-String_Similarity.cpp ├── 1400C-Binary_String_Reconstruction.cpp ├── 1401A-Distance_and_Axis.cpp ├── 1401B-Ternary_Sequence.cpp ├── 1401C-Mere_Array.cpp ├── 1405A-Permutation_Forgery.cpp ├── 1405B-Array_Cancellation.cpp ├── 1406A-Subset_Mex.cpp ├── 1406B-Maximum_Product.cpp ├── 1407A-Ahahahahahahahaha.cpp ├── 1407B-Big_Vova.cpp ├── 1408A-Circle_Colouring.cpp ├── 1408B-Arrays_Sum.cpp ├── 1409A-Yet_Another_Two_INtegers_Problem.cpp ├── 1409B-Minimum_Product.cpp ├── 1409C-Yet_Another_Array_Restoration.cpp ├── 1415A-Prison_Break.cpp ├── 1415B-Repainting_Street.cpp ├── 1415C-Bouncing_Ball.cpp ├── 1417A-Copy_Paste.cpp ├── 1417B-Two_arrays.cpp ├── 1418A-Buying_Torches.cpp ├── 1418B-Negative_Prefixes.cpp ├── 1419A-Digit_Game.cpp ├── 1419B-Stairs.cpp ├── 1419D1-Sage's_Birthday(easy_version).cpp ├── 1419D2-Sage's_Birthday(hard_version).cpp ├── 141A-Amusing_Joke.cpp ├── 1420A-Cubes_Sorting.cpp ├── 1420B-Rock_and_Lever.cpp ├── 1420C1-Pokemon_Army(easy_version).cpp ├── 1421A-XORwice.cpp ├── 1421B-Putting_Bricks_in_the_Wall.cpp ├── 1421C-Palindromifier.cpp ├── 1422A-Fence.cpp ├── 1422B-Nice_Matrix.cpp ├── 1424G-Years.cpp ├── 1425A-Arena_of_Greed.cpp ├── 1425F-Flamingoes_of_Mystery.cpp ├── 1425H-Huge_Boxes_of_Animal_Toys.cpp ├── 1426A-Floor_Number.cpp ├── 1426B-Symmetric_Matrix.cpp ├── 1426C-Increase_and_Copy.cpp ├── 1427A-Avoiding_Zero.cpp ├── 1428A-Box_is_Pull.cpp ├── 1428B-Belted_Rooms.cpp ├── 1428C-ABBB.cpp ├── 1430A-Number_of_Apartments.cpp ├── 1430B-Barrels.cpp ├── 1430C-Numbers_on_Whiteboard.cpp ├── 1433A-Boring_Apartments.cpp ├── 1433B-Yet_Another_Bookshelf.cpp ├── 1433C-Dominant_Piranha.cpp ├── 1433D-Districts_Connection.cpp ├── 1433E-Two_Round_Dances.cpp ├── 1436A-Reorder.cpp ├── 1436B-Prime_Square.cpp ├── 1436C-Binary_Search.cpp ├── 1437A-Marketing_Scheme.cpp ├── 1437B-Reverse_Binary_Strings.cpp ├── 1438A-Specific_Tastes_of_Andre.cpp ├── 1438B-Valerii_Against_Everyone.cpp ├── 1438C-Engineer_Artem.cpp ├── 1439A1-Binary_Table(Easy_Version).cpp ├── 1440A-Buy_the_String.cpp ├── 1440B-Sum_of_Medians.cpp ├── 1443A-Kids_Seating.cpp ├── 1443B-Saving_the_City.cpp ├── 1443C-The_Delivery_Dilemma.cpp ├── 1444A-Division.cpp ├── 1445A-Array_Rearrangement.cpp ├── 1445B-Elimination.cpp ├── 1446A-Knapsack.cpp ├── 1446B-Catching_Cheaters.cpp ├── 1447A-Add_Candies.cpp ├── 1447B-Numbers_Box.cpp ├── 144A-Arrival_of_the_General.cpp ├── 1450A-Avoid_Trygub.cpp ├── 1450B-Balls_of_Steel.cpp ├── 1451A-Substract_or_Divide.cpp ├── 1451B-Non-Substring_Subsequence.cpp ├── 1451C-String_Equality.cpp ├── 1451D-Circle_Game.cpp ├── 1452A-Robot_Program.cpp ├── 1452B-Toy_Blocks.cpp ├── 1452C-Two_Brackets.cpp ├── 1453A-Cancel_the_Trains.cpp ├── 1453B-Suffix_Operations.cpp ├── 1454A-Special_Permutation.cpp ├── 1454B-Unique_Bid_Auction.cpp ├── 1454C-Sequence_Transformation.cpp ├── 1454D-Number_into_Sequence.cpp ├── 1455A-Strange_Functions.cpp ├── 1455B-Jumps.cpp ├── 1455C-Ping-pong.cpp ├── 1455D-Sequence_and_Swaps.cpp ├── 1458A-Row_GCD.cpp ├── 1459A-Red-Blue_Shuffle.cpp ├── 1459B-Move_and_Turn.cpp ├── 1461A-String_Genertion.cpp ├── 1461B-Find_the_Spruce.cpp ├── 1462A-Favorite_Sequence.cpp ├── 1462B-Last_Year's_Substring.cpp ├── 1462C-Unique_Number.cpp ├── 1462D-Add_to_Neighbour_and_Remove.cpp ├── 1462E1-Close_Tuples(easy_version).cpp ├── 1463A-Dungeon.cpp ├── 1463B-Find_The_Array.cpp ├── 1465A-In-game_Chat.cpp ├── 1465B-Fair_Numbers.cpp ├── 1466A-Bovine_Dilemma.cpp ├── 1466B-Last_minute_enhancements.cpp ├── 1466C-Canine_poetry.cpp ├── 1466D-13th_Labour_of_Heracles.cpp ├── 1467A-Wizard_of_Orz.cpp ├── 1468C-Berpizza.cpp ├── 1468E-Four_Segments.cpp ├── 1468N-Waste_Sorting.cpp ├── 1469A-Regular_Bracket_Sequence.cpp ├── 1469B-Red_and_Blue.cpp ├── 1469C-Building_a_Fence.cpp ├── 1469D-Ceil_Divisions.cpp ├── 1470A-Strange_Birthday_Party.cpp ├── 1471A-Strange_Partition.cpp ├── 1471B-Strange_List.cpp ├── 1472A-Cards_for_Friends.cpp ├── 1472B-Fair_Division.cpp ├── 1472C-Long_Jumps.cpp ├── 1472D-Even-Odd_Game.cpp ├── 1473A-Replacing_Elements.cpp ├── 1473B-String_LCM.cpp ├── 1473C-No_More_Inversions.cpp ├── 1474A-Puzzle_From_the_Future.cpp ├── 1474B-Different_Divisors.cpp ├── 1474C-Array_Destruction.cpp ├── 1475A-Odd_Divisor.cpp ├── 1475B-New_Year's_Number.cpp ├── 1475C-Ball_in_Berland.cpp ├── 1476A-K-divisible_Sum.cpp ├── 1476B-Inflation.cpp ├── 1477A-Nezzar_and_Board.cpp ├── 1478A-Nezzar_and_Chocolate_Bars.cpp ├── 1478B-Nezzar_and_Lucky_Number.cpp ├── 1478C-Nezzar_and_Symmetric_Array.cpp ├── 1480A-Yet_Another_String_Game.cpp ├── 1480B-The_Great_Hero.cpp ├── 1481A-Space_Navigation.cpp ├── 1481B-New_Colony.cpp ├── 1481C-Fence_Painting.cpp ├── 1484A-Prison_Break.cpp ├── 1485A-Add_and_Divide.cpp ├── 1485B-Replace_and_Keep_Sorted.cpp ├── 1486A-Shifting_Stacks.cpp ├── 1487A-Arena.cpp ├── 1487B-Cat_Cyles.cpp ├── 1487D-Pythagorean_Triples.cpp ├── 1489A-Searching_Local_Minimum.cpp ├── 1490A-Dense_Array.cpp ├── 1490B-Balanced_Remainders.cpp ├── 1490C-Sum_of_Cubes.cpp ├── 1490D-Permutation_Transformation.cpp ├── 1490E-Accidental_Victory.cpp ├── 1491A-K-thLargest_Value.cpp ├── 1491B-Minimal_Cost.cpp ├── 1491C-Pekora_and_Trampoline.cpp ├── 1492A-Three_swimmers.cpp ├── 1492B-Card_Deck.cpp ├── 1492C-Maximum_width.cpp ├── 1493A-Anti-knapsack.cpp ├── 1493B-Planet_Lapituletti.cpp ├── 1494A-ABC_String.cpp ├── 1494B_Berland_Crossword.cpp ├── 1496A-Split_it!.cpp ├── 1496B-Max_and_Mex.cpp ├── 1496C-Diamond_Miner.cpp ├── 1496E-Garden_of_the_Sun.cpp ├── 1497A-Meximization.cpp ├── 1497B-M-arrays.cpp ├── 1497C-k-LCM(easy_version).cpp ├── 1497D-k_LCM(hard_version).cpp ├── 1498A-GCD_Sum.cpp ├── 1498B-Box_Fitting.cpp ├── 1498C-Planar_Reflectiions.cpp ├── 1499A-Domino_on_Windowsill.cpp ├── 1499B-Binary_Removals.cpp ├── 1499C-Minimum_Grid_Path.cpp ├── 1499D-The_Number_of_Pairs.cpp ├── 149A-Business_trip.cpp ├── 14A-Letter.cpp ├── 1500A-Going_Home.cpp ├── 1501A-Alexey_and_Train.cpp ├── 1501B-Napoleon_Cake.cpp ├── 1503A-Balance_the_Bits.cpp ├── 1504A-Deja_Vu.cpp ├── 1504B-Flip_the_BIts.cpp ├── 1504D-3_Coloring.cpp ├── 1505A-Is_it_rated-2.cpp ├── 1505B-DMCA.cpp ├── 1505C-Fibonacci_Words.cpp ├── 1505F-Math.cpp ├── 1505H-L_BREAK_into_program.cpp ├── 1506A-Strange_Table.cpp ├── 1506B-Partial_Replacement.cpp ├── 1506C-Double-ended_Strings.cpp ├── 1506D-Epic_Transformation.cpp ├── 1509A-Average_Height.cpp ├── 1509B-TMT_Document.cpp ├── 1510K-King's_Task.cpp ├── 1511A-Review_Site.cpp ├── 1511B-GCD_Length.cpp ├── 1512A-Spy_Detected!.cpp ├── 1512B-Almost_Rectangle.cpp ├── 1512C-A-B_Palindrome.cpp ├── 1512D-Corrupted_Array.cpp ├── 1512E-Permutation_by_Sum.cpp ├── 1512G-Short_Task.cpp ├── 1513A-Array_and_Peaks.cpp ├── 1513B-AND_Sequences.cpp ├── 1514A-Perfectly_Imperfect_Array.cpp ├── 1514B-AND_0,_Sum_Big.cpp ├── 1514C-Product_1_Modulo_N.cpp ├── 1515A-Phoenix_and_Gold.cpp ├── 1515B-Phoenix_and_Puzzle.cpp ├── 1515C-Phoenix_and_Towers.cpp ├── 1515D-Phoenix_and_Socks.cpp ├── 1516A-Tit_for_Tat.cpp ├── 1516B-AGAGA_XOOORRR.cpp ├── 1517A-Sum_of_2050.cpp ├── 1517C-Fillomino_2.cpp ├── 1519A-Red_and_Blue_Beans.cpp ├── 1519B-The_Cake_Is_a_Lie.cpp ├── 1519C-Berland_Regional.cpp ├── 1519D-Maximum_Sum_of_Products.cpp ├── 151A-Soft_Drinking.cpp ├── 151B-Phone_Numbers.cpp ├── 1520A-Do_Not_Be_Distracted!.cpp ├── 1520B-Ordinary_Numbers.cpp ├── 1520C-Not_Adjacent_Matrix.cpp ├── 1520D-Same_Differences.cpp ├── 1520E-Arranging_The_Sheep.cpp ├── 1520F1_Guess_the_K-th_Zero(Easy_version).cpp ├── 1520F2_Guess_the_K-th_Zero(Hard_version).cpp ├── 1521A-Nasia_and_Nearly_Good_Numbers.cpp ├── 1521B-Nastia_and_a_Good_Array.cpp ├── 1523A-Game_of_Life.cpp ├── 1523B-Lord_of_the_Values.cpp ├── 1523C-Compression_and_Expression.cpp ├── 1525A-Potion-making.cpp ├── 1525B-Permutation_Sort.cpp ├── 1526A-Mean_Inequality.cpp ├── 1526B-I_Hate_1111.cpp ├── 1526C2-Potions(Hard_Versioin).cpp ├── 1527A-And_Then_There_Were_K.cpp ├── 1527B1-Palindrome_Game(easy_varsion).cpp ├── 1528A-Parsa's_Humongous_Tree.cpp ├── 1529A-Eshag_Loves_Big_Arrays.cpp ├── 1529B-Sifid_and_Strange_Subsequences.cpp ├── 1529D-Kavi_on_Pairing_Duty.cpp ├── 152A-Marks.cpp ├── 152C-Pocket_Book.cpp ├── 1530A-Binary_Decimal.cpp ├── 1530B-Putting_Plates.cpp ├── 1534A-Colour_the_Flag.cpp ├── 1534B-Histogram_Ugliness.cpp ├── 1534C-Little_Alawn's_Puzzle.cpp ├── 1534D-Lost_Tree.cpp ├── 1535A-Fair_Playoff.cpp ├── 1535B-Array_Reordering.cpp ├── 1535C-Unstable_String.cpp ├── 1536A-Omkar_and_Bad_Story.cpp ├── 1536B-Prinzessin_der_Veruteilung.cpp ├── 1536C-Diluc_and_Kaeya.cpp ├── 1537A-Arithmetic_Array.cpp ├── 1537B-Bad_Boy.cpp ├── 1537C-Challenging_Cliffs.cpp ├── 1537D-Deleting_Divisors.cpp ├── 1537E1-Erase_and_Extend_(Easy_Version).cpp ├── 1538A-Stone_Game.cpp ├── 1538B-Friends_and_Candies.cpp ├── 1538C-Number_of_Pairs.cpp ├── 1538D-Another_Problem_About_Dividing_Numbers.cpp ├── 1538F-Interesting_Function.cpp ├── 1539A-Contest_Start.cpp ├── 1539B-Love_Song.cpp ├── 1539C-Stable_Groups.cpp ├── 1539D-PriceFixed.cpp ├── 1541A-Pretty_Permutation.cpp ├── 1541B-Pleasant_Pairs.cpp ├── 1541C-Great_Graphs.cpp ├── 1542A-Odd_Set.cpp ├── 1542B-Plus_and_Multiply.cpp ├── 1542C-Strange_Function.cpp ├── 1543A-Exciting_Bets.cpp ├── 1547A-Shortest_Path_with_Obstacle.cpp ├── 1547B-Alphabetical_Strings.cpp.cpp ├── 1547C-Pair_Programming.cpp.cpp ├── 1547D-Co-growing_Sequence.cpp.cpp ├── 1547E-Air_Conditioners.cpp ├── 1548A-Web_of_Lies.cpp ├── 1549A-Grogor_and_Cryptography.cpp ├── 1549B-Gregot_and_the_Pawn_Game.cpp ├── 1550A-Find_The_Array.cpp ├── 1550B-Maximum_Cost_Deletion.cpp ├── 1550C-Manhattan_Subarrays.cpp ├── 1551A-Polycarp_and_Coins.cpp ├── 1553A-Digits_Sum.cpp ├── 1554A-Cherry.cpp ├── 1554D-Diane.cpp ├── 1555A-PizzaForces.cpp ├── 1555B-Two_Tables.cpp ├── 1555C-Coin_Rows.cpp ├── 1555D-Say_No_to_Palindromes.cpp ├── 1557A-Ezzat_and_Two_Subsequences.cpp ├── 1557B-Moamen_and_k-subarrays.cpp ├── 1560A-Dislike_of_Threes.cpp ├── 1560B-Who's_Opposite.cpp ├── 1560C-Infinity_Table.cpp ├── 1566A-Median_Maximization.cpp ├── 1566D1-Seating_Arrangements_(easy_version) .cpp ├── 1566D2-Seating_Arrangements(Hard_version).cpp ├── 1566E-Buds_Re-hanging.java ├── 1566b-MIN-MEX_Cut.cpp ├── 1566c-MAX-MEX_Cut.cpp ├── 1569A-Balanced_Substring.cpp ├── 1573A-Countdown.java ├── 1574A-Regular_Bracket_Sequences.cpp ├── 1574B-Combinatorics_Homework.java ├── 1578E-Easy_Scheduling.cpp ├── 1579A-Casimir's_String_Solitaire.cpp ├── 1579B-Shifting_Sort.cpp ├── 1579C-Ticks.cpp ├── 1579D-Productive_Meeting.cpp ├── 1579E1-Permutation_Minimization_by_Deque.cpp ├── 157B-Trace.cpp ├── 1581A-CQXYM_Count_Permutations.cpp ├── 1581B-Diameter_of_Graph.cpp ├── 1583A-Windblume_Ode.cpp ├── 1583B-Omkar_and_Heavenly_Tree.cpp ├── 1584A-Mathematical_Addition.cpp ├── 1584B-Coloring_Rectangles.cpp ├── 1584C-Two_Arrays.cpp ├── 158B-Taxi.cpp ├── 1592A-Gamer_Hemose.cpp ├── 1594A-Conescutive_Sum_Riddle.cpp ├── 1594B-S]pecial_Numbers.cpp ├── 1594C-Make_Them_Equal.cpp ├── 1598A-Computer_Game.cpp ├── 1598B-Groups.cpp ├── 1598C-Delete_Two_Elements.cpp ├── 1598D-Training_Session.cpp ├── 160A-Twins.cpp ├── 160B-Unlucky_Ticket.cpp ├── 165A-Supercentural_Point.cpp ├── 166A-Rank_List.cpp ├── 166C-Median.cpp ├── 166E-Tetrahedron.cpp ├── 1670A-Prof.Slim.cpp ├── 168A-Wizards_and_Demonstration.cpp ├── 16A-Flag.cpp ├── 174A-Problem_About_Equation.cpp ├── 177A1-Good_Matrix_Elements.cpp ├── 177A2-Good_Matrix_Elements.cpp ├── 177B1-Rectangular_Game.cpp ├── 177B2-Rectangular_Game.cpp ├── 17A-Noldbach_problem.cpp ├── 186A-Comparing_Strings.cpp ├── 189A-Cut_Ribbon.cpp ├── 192A-Funky_Numbers.cpp ├── 1947C-Beautiful Triple Pairs.cpp ├── 196A-Lexicographically_Maximum_Subsequence.cpp ├── 199A-Hexadecimal's_theorem.cpp ├── 1A-Theatre Square.cpp ├── 205A-Little_Elephant_and_Rozdil.cpp ├── 208A-Dubstep.cpp ├── 214A-System_of_Equations.cpp ├── 215A-Bicycle_Chain.cpp ├── 217A-Ice_Skating.cpp ├── 218B-Airport.cpp ├── 219A-k-string.cpp ├── 219C-Color_Stripe.cpp ├── 221A-Little_Elephant_and_Function.cpp ├── 222A-Shooshuns_and_Sequence.cpp ├── 222B-Cosmic_Tables.cpp ├── 224A-Parallelepiped.cpp ├── 224B-Array.cpp ├── 227B-Effective_Approach.cpp ├── 230A-Dragons.cpp ├── 230B-T-primes.cpp ├── 231A-Team.cpp ├── 234B-Reading.cpp ├── 234C-Weather.cpp ├── 235A-LCM_Challenge.cpp ├── 236A-Boy or Girl.cpp ├── 236B-Easy_Number_Challenge.cpp ├── 237A-Free_Cash.cpp ├── 239A-Two_Bags_of_Potatoes.cpp ├── 242A-Heads_or_Tails.cpp ├── 242B-Big_Segment.cpp ├── 244A-Dividing_Orange.cpp ├── 246A-Buggy_Sorting.cpp ├── 246B-Increase_and_Decrease.cpp ├── 251A-Points_on_Line.cpp ├── 253A-Boys_and_Girls.cpp ├── 254A-Cards_with_Numbers.cpp ├── 255A-DIce_Tower.cpp ├── 257B-Playing_Cubes.cpp ├── 258A-Little_Elephant_and_Bits.cpp ├── 259A-Little_Elephant_and_chess.cpp ├── 25A-IQ_test.cpp ├── 260A-Adding_Digits.cpp ├── 262B-Roma_and_Changing_Signs.cpp ├── 265A-Roadside_Trees(Simplified_Edition).cpp ├── 266A-Stones_on_the_Table.cpp ├── 266B-Queue_at_the_School.cpp ├── 267A-Substraction.cpp ├── 268B-Buttons.cpp ├── 26A-Almost_prime.cpp ├── 26B-Regular_Bracket_Sequence.cpp ├── 270A-.Fancy_Fence.cpp ├── 271B-Prime_Matrix.cpp ├── 272A-Dima_and_Friends.cpp ├── 272C-Dima_and_Staircase.cpp ├── 275A-Lights_Out.cpp ├── 276A-Lunch_Rush.cpp ├── 276B-Little_Girl_and_Game.cpp ├── 276C-Little_Girl_and_Maximum_Sum.cpp ├── 277A-Learning_Languages.cpp ├── 279B-Books.cpp ├── 27A-Next_Test.cpp ├── 281A-Word _Capitalization.cpp ├── 282B-Painting_Eggs.cpp ├── 282C-XOR_and_OR.cpp ├── 285A-Slightly_Decreasing_Permutation.cpp ├── 285B-Find_Marble.cpp ├── 285C-Building_Permutation.cpp ├── 287A-IQ_Test.cpp ├── 289B-Polo_the_Penguin_and_Matrix.cpp ├── 296A-Yaroslav_and_Permutations.cpp ├── 298B-Sail.cpp ├── 299A-Ksusha _and_Array.cpp ├── 29A-Split_problem.cpp ├── 300A-Array.cpp ├── 304A-Pythagorean_Theorem_II.cpp ├── 313A-llya_and_Bank_Account.cpp ├── 313B-llya_and_quesries.cpp ├── 313C-Ilya_and_Matrix.cpp ├── 315A-Sereja_and_Bottles.cpp ├── 315B-Sereja_and_Array.cpp ├── 318A-Even_Odds.cpp ├── 320A-Magic_Numbers.cpp ├── 320B-Ping-Pong(Easy_Version).cpp ├── 322A-Ciel_and_Dancing.cpp ├── 322B-Ciel_and_Flowers.cpp ├── 327A-Flipping_Game.cpp ├── 327B-Hungry_Sequence.cpp ├── 32B-Borze.cpp ├── 330B-Road_Construction.cpp ├── 334A-Candy_Bags.cpp ├── 336A-Vasily_the_Bear_and_Triangle.cpp ├── 337A-Puzzles.cpp ├── 337B-Routine_Problem.cpp ├── 339B-Xenia_and_Ringroad.cpp ├── 342A-Xenia_and_Divisors.cpp ├── 344B-Simple_Molecules.cpp ├── 347A-Difference_Row.cpp ├── 347B-Fixed_Points.cpp ├── 349A-Cinema_Line.cpp ├── 34A-Reconnaissance_2.cpp ├── 34B-Sale.cpp ├── 350A-TL.cpp ├── 352A-Jeff_and_Digits.cpp ├── 352B-Jeff_and_Periods.cpp ├── 353A-Domino.cpp ├── 355A-Vasya_and_Digital_Root.cpp ├── 357B-Flag_Day.cpp ├── 358A-Dima_and_Continuous_Line.cpp ├── 363B-Fence.cpp ├── 363C-Fixing_Typos.cpp ├── 365A-Good_Number.cpp ├── 365B-The_Fibonacci_Segment.cpp ├── 368B-Sereja_and_Suffixes.cpp ├── 371B-Fox_Dividing_Cheese.cpp ├── 372A-Counting_Kangaroos_is_Fun.cpp ├── 377A-Maze.cpp ├── 395A-Table.cpp ├── 39H-Multiplication_Table.cpp ├── 40A-Find_Color.cpp ├── 412C-Pattern.cpp ├── 414B-Mashmokh_and_ACM.cpp ├── 41A-Translation.cpp ├── 421A-Pasha_and_Hamsters.cpp ├── 427A-Police_Recruits.cpp ├── 429A-Xor-tree.cpp ├── 430C-Xor-tree.cpp ├── 431A-Black_Square.cpp ├── 431B-Shower_Line.cpp ├── 433A-Kitahara_Haruki's_Gift.cpp ├── 433B-kuriyama_mirai`s_stones.cpp ├── 437C-The_Child_and_Toy.cpp ├── 43A-Football.cpp ├── 43B-Letter.cpp ├── 441B-Valera_and_Fruits.cpp ├── 443A-Anton_and_Letters.cpp ├── 445A-DZY_Loves_Chessboard.cpp ├── 447B-DZY_Loves_Strings.cpp ├── 450A-Jzzhu_and_Children.cpp ├── 450B-Jzzhu_and_Sequences.cpp ├── 451B-Sort_the_Array.cpp ├── 452A-Eevee.cpp ├── 453A-Little_Pony_and_Expected_Maximum.cpp ├── 454B-Little_Pony_and_Sort_by_Shift.cpp ├── 456A-Laptops.cpp ├── 456B-Fedya_and_Maths.cpp ├── 459A-Pashmak_and_Garden.cpp ├── 459B-Pashmak_and_Flowers.cpp ├── 460B-Little_Dima_and_Equation.cpp ├── 462B-Appleman_and_Card_Game.cpp ├── 466A-Cheap_Travel.cpp ├── 467C-George_and_Job.cpp ├── 476B-Dreamoon_and_WiFi.cpp ├── 479A-Expression.cpp ├── 479C-Exams.cpp ├── 485A-Factory.cpp ├── 489C-Given_length_and_sum_of_digits.cpp ├── 491A-Up_the_hill.cpp ├── 492A-Vanya_and_Cubes.cpp ├── 492C-Vanya_and_Exams.cpp ├── 4A-Watermelon.cpp ├── 4B-Before_an_Exam.cpp ├── 500A-New_Year_Transportation.cpp ├── 501B-Misha_and_Changing_Handles.cpp ├── 507A-Amr_and_music.cpp ├── 534A-Exam.cpp ├── 538B-Quasi_binary.cpp ├── 53C-Little_Frog.cpp ├── 544A-Set_of_Strings.cpp ├── 548A-Mike_and_fax.cpp ├── 550A-Two_Substrings.cpp ├── 560A-Currency_system_in_geraldion.cpp ├── 577A-Multiplication_table.cpp ├── 580A-Kefa_and_First_Steps.cpp ├── 580C-Kefa_and_Park.cpp ├── 58A-Chat_room.cpp ├── 596A-Wilbur_and_Swimming_Pool.cpp ├── 59A-Word.cpp ├── 610A-Pasha_and_Stick.cpp ├── 612C-Replace_To_Make_Regular_Bracket_Sequence.cpp ├── 615A-Bulbs.cpp ├── 616B-Dinner_with_emma.cpp ├── 617A-Elephant.cpp ├── 618B-Guess_the_Permutation.cpp ├── 61A-Ultra-Fast_Mathematician.cpp ├── 624B-Making_a_String.cpp ├── 630A-Again_twenty_five!.cpp ├── 630C-Lucky_Numbers.cpp ├── 630D-Hexagons.cpp ├── 630J-Divisibility.cpp ├── 633A-Ebony_and_Ivory.cpp ├── 633B-A_Trivial_Problem.cpp ├── 637B-Chat Order.cpp ├── 638B-Making_Genome_in_Berland.cpp ├── 650A-Watchmen.cpp ├── 652B-z-sort.cpp ├── 667A-Pouring_Rain.cpp ├── 667B-Coat_of_Anticubism.cpp ├── 672B-Different_is_good.cpp ├── 675A-Infinte_Sequence.cpp ├── 680B-Bear_and_Finding_Criminals.cpp ├── 682A-Alyona_and_Numbers.cpp ├── 686B-Little_Robber_Girls`s_Zoo.cpp ├── 688B-Lovely_Palindromes.cpp ├── 69A-Young_Physicist.cpp ├── 6C-Alice_Bob_and_Chocolate.cpp ├── 712B-Memory_and_Trident.cpp ├── 714B-Filya_and_Homework.cpp ├── 719A-Vitya_int_the_Countryside.cpp ├── 719B-Anatoly_and_Cockroaches.cpp ├── 721B-Passwords.cpp ├── 722B-Verse_Pattern.cpp ├── 727A-Transformation_from_A_to_B.cpp ├── 732B-Cormen-the_best_friend_of_a_man.cpp ├── 732C-Sanatorium.cpp ├── 735D-Taxes.cpp ├── 742A-Arpa`s _hard_exam_and_mehrdad`s_naive_cheat.cpp ├── 742B-Arpa's_obvious_problem_and_Mehradad's_terrible_solution.cpp ├── 747B-Mammoth`s_genome_decoding.cpp ├── 753A-Santa_claus_and_candies.cpp ├── 755B-PolandBall_and_Game.cpp ├── 75A-Life_Without_Zeroes.cpp ├── 760B-Interesting_walk.cpp ├── 761A-Dasha_and_Stairs.cpp ├── 764B-Timfoey_and_cubes.cpp ├── 765B-Code_obfuscation.cpp ├── 766A-Mahmoud_and_longest_uncommon_subsequence.cpp ├── 766B-Mahmoud_and_a_triangle.cpp ├── 774C-Maximum_Number.cpp ├── 776A-A_Serial_Killer.cpp ├── 777A-Shell_Game.cpp ├── 785B-Anton_and_Classes.cpp ├── 787A-The_Monster.cpp ├── 792A-New_Bus_Route.cpp ├── 797A-k-Factorization.cpp ├── 797B-Odd_sum.cpp ├── 798A-Mike_and_Palindrome.cpp ├── 798B-Mike_and_strings.cpp ├── 7A-Kalevitch_and_Chess.cpp ├── 803A-Maximal_Binary_Matrix.cpp ├── 803B-Distances_to_Zero.cpp ├── 804A-Find_Amir.cpp ├── 805B-3-Palindrome.cpp ├── 808A-lucky_year.cpp ├── 810A-Strainght_A.cpp ├── 817C-Really_Big_Numbers.cpp ├── 834A-The_useless_toy.cpp ├── 835B-The_number_on_the_board.cpp ├── 839A-Arya_and_Bran.cpp ├── 840A-Leha_and_Function.cpp ├── 841A-Generous_Kefa.cpp ├── 842B-Gleb_and_Pizza.cpp ├── 844A-Diversity.cpp ├── 844B-Rectangles.cpp ├── 845A-Chess Tourney.cpp ├── 859B-Lazy_security_guard.cpp ├── 863A-Quasi_palindrome.cpp ├── 864A-Fair_game.cpp ├── 864B-Polycarp_and_letters.cpp ├── 864C-Bus.cpp ├── 864D-Make_a_Permutation!.cpp ├── 877A-Alex_and_broken_contest.cpp ├── 886A-ACM ICPC.cpp ├── 887B-Cubes_for_Masha.cpp ├── 893B-Beautiful_Divisiors.cpp ├── 893C-Rumor.cpp ├── 898B-Proper_Nutrition.cpp ├── 899C-Dividing_the_numbers.cpp ├── 900B-Position_in_fraction.cpp ├── 909A-Generate_login.cpp ├── 909B-Segments.cpp ├── 90B-African_Crossword.cpp ├── 910A-The_way_to_home.cpp ├── 911A-Nearest_Minimums.cpp ├── 919A-Supermarket.cpp ├── 919B-Perfect_Number.cpp ├── 919C-Seat_Arrangements.cpp ├── 926A-2-3-numbers.cpp ├── 934A-A_Compatible_Pair.cpp ├── 935A-Fafa and his Company.cpp ├── 938B-Run_For_Your_Prize.cpp ├── 940A-Points_on_the_line.cpp ├── 960A-Check_the_string.cpp ├── 96A-Football.cpp ├── 96B-Lucky_Numbers(easy).cpp ├── 977A-Wrong_Substraction.cpp ├── 977B-Two-gram.cpp ├── 977C-Less_or_Equal.cpp ├── 977D-Divide_by_three,multiply_by_two.cpp ├── 977E-Cyclic_Components.cpp ├── 978A-Remove Duplicates.cpp ├── 979A-Pizza,_Pizza,_Pizza.cpp ├── 982A-Row.cpp ├── 985B-Switches_and_Lamps.cpp ├── 987C-Three_displays.cpp ├── 989B-A_Tide_of_Riverscape.cpp ├── 990A-Commentary_Boxes.cpp ├── 990B-Micro-World.cpp ├── 991A-If_at_first_you_don`t_succeed.cpp ├── 992B-Nastya_Studies_Information.cpp ├── 996A-hit_the_lottery.cpp ├── 998A-Balloons.cpp ├── 998B-Cutting.cpp ├── 999C-Alphabetic_Removals.cpp ├── 9A-Die_Roll.cpp ├── ACMSGURU │ ├── 100-A+B.cpp │ ├── 105-Div3.cpp │ ├── 112-a^b-b^a.py │ ├── 123-The_sum.cpp │ ├── 231-Prime_Sum.cpp │ ├── 533-Dice_Tower.cpp │ └── 538-Emoticons.cpp ├── After Placement │ ├── 1041B-Buying a TV Set.cpp │ ├── 1136B-Nastya Is Playing Computer Games.cpp │ ├── 115A-Party.cpp │ ├── 1165D-Almost All Divisors.cpp │ ├── 1181A-Chunga-Changa.cpp │ ├── 1202A-You Are Given Two Binary Strings....cpp │ ├── 1204B-Mislove Has Lost an Array.cpp │ ├── 1245B-Restricted_RPS.cpp │ ├── 1260A-Heating.cpp │ ├── 1350A-Orac_and_Factors.cpp │ ├── 140C-New Year Snowmen.cpp │ ├── 142A-Help Farmer.cpp │ ├── 148A-Insomnia cure.cpp │ ├── 148B-Escape.cpp │ ├── 150A-Win or Freeze.cpp │ ├── 1601A-Array_Elimination.cpp │ ├── 1602A-Two_Subsequences.cpp │ ├── 1602B-Divine_Array.cpp │ ├── 1603A-Di-visible Confusion.cpp │ ├── 1604A-Era.cpp │ ├── 1604B-XOR_Specia-LIS-t.cpp │ ├── 1606A-AB_Balance.cpp │ ├── 1606C-Banknotes.cpp │ ├── 1608A-Find_Array.cpp │ ├── 1609A-Divide_and_Multiply.cpp │ ├── 1609B-William_the_Vigilant.cpp │ ├── 1612A-Distance.cpp │ ├── 1613A-Long_Comparison.cpp │ ├── 1613B-Abssent_Remainder.cpp │ ├── 1613C-Poisoned_Dagger.cpp │ ├── 1615A-Closing_The_Gap.cpp │ ├── 1615B-And_It's_Non_Zero.cpp │ ├── 1616A-Integer_Diversity.cpp │ ├── 1616B-Mirror_in_the_String.cpp │ ├── 1617A-Forbidden_Subsequence.cpp │ ├── 1617B-GCD_Problem.cpp │ ├── 1618A-Ploycarp_and_Sums_of_Subsequences.cpp │ ├── 1618B-Missing_Bigram.cpp │ ├── 1618C-Paint_the_Array.cpp │ ├── 1618D-Array_and_Operatios.cpp │ ├── 1619A-Square_String.cpp │ ├── 1619B-Squares_and_Cubes.cpp │ ├── 1619C-Wrong_Addition.cpp │ ├── 1620B-Triangles on a Rectangle.cpp │ ├── 1621A-Stable_Arrangement_of_Rooks.cpp │ ├── 1622A-Construct_a_Rectangle.cpp │ ├── 1622B-Berland_Music.cpp │ ├── 1624A-Plus_One_on_the_Subset.cpp │ ├── 1624B-Make_AP.cpp │ ├── 1624C-Division_by_Two_and_Permutation.cpp │ ├── 1624D-Palindromes_Coloring.cpp │ ├── 1625A-Ancient_Civilization.cpp │ ├── 1625B-Elementary_Particles.cpp │ ├── 1626A-Equidistant_Letters.cpp │ ├── 1626B-Minor_Reduction.cpp │ ├── 1627A-Not_Shading.cpp │ ├── 1627B-Not_Sitting.cpp │ ├── 1627C-Not_Assigning.cpp │ ├── 1629A-Download_More_RAM.cpp │ ├── 1629B-GCD_Arrays.cpp │ ├── 1634A-Reverse_and_Concatenate.cpp │ ├── 1634C-OKEA.cpp │ ├── 1635A-Min_Or_Sum.cpp │ ├── 1635B-Avoid_Local_Maximums.cpp │ ├── 1635C-Differential_Sorting.cpp │ ├── 1638A-Reverse.cpp │ ├── 1638B-Odd_Swap_Sort.cpp │ ├── 1644A-Doors_and_Keys.cpp │ ├── 1644B-Anti-Fibonacci_Permutation.cpp │ ├── 1647A-Madoka_and_Math_Dad.cpp │ ├── 1654A-Maximum_Cake_Tastiness.cpp │ ├── 1654B-Prefix_Removals.cpp │ ├── 1654C-Alice_and_the_Cake.cpp │ ├── 1656A-Good_Pairs.cpp │ ├── 1657A-Integer_Moves.cpp │ ├── 1657B-XY_Sequence.cpp │ ├── 1657C-Bracket_Sequence_Deletion.cpp │ ├── 1658A-Marin_and_Photoshoot.cpp │ ├── 1658B-Marin_and_Anti-coprime_Permutation.cpp │ ├── 1659A-Red_Versus_Blue.cpp │ ├── 1659B-Bit_Flipping.cpp │ ├── 1660A-Vasya_and_Coins.cpp │ ├── 1660B-Vlad_and_Candies.cpp │ ├── 1663A-Who_Tested.cpp │ ├── 1665A-GCD_vs_LCM.cpp │ ├── 1665B-Array_Cloning_Technique.cpp │ ├── 1665C-Tree_Infection.cpp │ ├── 1668A-Direction_Change.cpp │ ├── 1669A-Division.cpp │ ├── 1669B-Triple.cpp │ ├── 1669C-Odd_Even_Increments.cpp │ ├── 1669D-Colorful_Stamp.cpp │ ├── 1669E-2_Letter_Strings.cpp │ ├── 1669F-Eating_Candies.cpp │ ├── 1669G-Fall_Down.cpp │ ├── 1669H-Maximal_AND.cpp │ ├── 1671A-String_Building.cpp │ ├── 1671B-Consecutive_Point_Segment.cpp │ ├── 1671C-Dolce_Vita.cpp │ ├── 1672A-Long_Chopping.cpp │ ├── 1672B-I_love_AAAB.cpp │ ├── 1673A-Subtle_Substring_Subtraction.cpp │ ├── 1673B-A_Perfectly_Balanced_String.cpp │ ├── 1674A-Number_Transformation.cpp │ ├── 1674B-Dictionary.cpp │ ├── 1674C-Infinte_Replacement.cpp │ ├── 1675A-Food_for_Animals.cpp │ ├── 1675B-Make_It_Increaseing.cpp │ ├── 1675C-Detective_Task.cpp │ ├── 1675D-Vertical_Paths.cpp │ ├── 1676A-Lucky.cpp │ ├── 1676B-Equal_Candies.cpp │ ├── 1676C-Most_Similar_Words.cpp │ ├── 1676D-X-Sum.cpp │ ├── 1676E-Eating_Queries.cpp │ ├── 1676F-Longest_Strike.cpp │ ├── 1676G-White-Black_Balanced_Subtrees.cpp │ ├── 1678A-Tokitsukaze_and_All_Zero_Sequence.cpp │ ├── 1678B1-Tokitsukaze_and_Good_01-String_(easy_version).cpp │ ├── 1679A-AvtoBus.cpp │ ├── 1680A-Minimums_and_Maximums.cpp │ ├── 1680B-Robots.cpp │ ├── 1684A-Digit_Minimization.cpp │ ├── 1684B-Z_mod_X_C.cpp │ ├── 1686A-Everything_Everywhere_All_But_One.cpp │ ├── 1688A-Cirno's_Perfect_Bitmasks_Classroom.cpp │ ├── 1690A-Print_a_Pedestal_(Codeforces_logo).cpp │ ├── 1690B-Array_Decrements.cpp │ ├── 1690C-Restoring_the_Duration_of_Tasks.cpp │ ├── 1690D-Black_and_White_Stripe.cpp │ ├── 1691A-Beat_The_Odds.cpp │ ├── 1691B-Shoe_Shuffling.cpp │ ├── 1692A-Marathon.cpp │ ├── 1692B-All_Distinct.cpp │ ├── 1692C-Where's_the_Bishop.cpp │ ├── 1694A-Creep.cpp │ ├── 1694B-Paranoid_String.cpp │ ├── 1695A-Subrectangle_Guess.cpp │ ├── 1696A-NIT_orz!.cpp │ ├── 1696B-NIT_Destroys_the_Universe.cpp │ ├── 1697A-Parkway_Walk.cpp │ ├── 1697B-Promo.cpp │ ├── 1698A-XOR_Mixup.cpp │ ├── 1698B-Rising_Sand.cpp │ ├── 1698C-3_SUM_Closure.cpp │ ├── 1699AThe_Third_Three_Number_Problem.cpp │ ├── 1699BAlmost_Ternary_Matrix.cpp │ ├── 1700A-Optimal_Path.cpp │ ├── 1703D-Double_Strings.cpp │ ├── 1703E-Mirror_Grid.cpp │ ├── 1705A-Mark_the_Photographer.cpp │ ├── 1705B-Mark_the_Dust_Sweeper.cpp │ ├── 1712A-Wonderful_Permutation.cpp │ ├── 1715A-Crossmarket.cpp │ ├── 1715B-Beautiful_Array.cpp │ ├── 1719A-Chip_Game.cpp │ ├── 1719B-Mathematical_Circus.cpp │ ├── 1720A-Burenka_Plays_with_Fractions.cpp │ ├── 1720B-Interesting_Sum.cpp │ ├── 1721A-Images.cpp │ ├── 1721B-B. Deadly_Laser.cpp │ ├── 1722A-Spell_Check.cpp │ ├── 1722B-Colourblindness.cpp │ ├── 1722C-Word_Game.cpp │ ├── 1722D-Line.cpp │ ├── 1722F-L-shapes.cpp │ ├── 1726A.Mainak_and_Array.cpp │ ├── 1728A-Colored_Balls_Revisited.cpp │ ├── 1728B-Best_Permutation.cpp │ ├── 1729A-Two_Elevators.cpp │ ├── 1729B-Decode_String.cpp │ ├── 1729C-Jumping_on_Tiles.cpp │ ├── 1729D-Friends_and_the_Restaurant.cpp │ ├── 1730A-Planets.cpp │ ├── 1733A-Consecutive_Sum.cpp │ ├── 1733B-Rule_of_League.cpp │ ├── 1734A-Select_Three_Sticks.cpp │ ├── 1735A-Working_Week.cpp │ ├── 1736-A.Make_A_Equal_to_B.cpp │ ├── 1736B-Playing_with_GCD.cpp │ ├── 1737A-Ela_Sorting_Books.cpp │ ├── 1737B-Ela's_Fitness_and_the_Luxury_Number.cpp │ ├── 1738A-Glory_Addicts.cpp │ ├── 1738B-Prefix_Sum_Addicts.cpp │ ├── 1739A-Immobile_Knight.cpp │ ├── 1739B-Array_Recovery.cpp │ ├── 1740A-Factorise_N+M.cpp │ ├── 1740B-Jumbo_Extra_Cheese_2.cpp │ ├── 1741A-Compare_T-Shirt_Sizes.cpp │ ├── 1741B-Funny_Permutation.cpp │ ├── 1741C-Minimize_the_Thickness.cpp │ ├── 1742A-Sum.cpp │ ├── 1742B-Increasing.cpp │ ├── 1742C-Stripes.cpp │ ├── 1742D-Coprime.cpp │ ├── 1742E-Scuza.cpp │ ├── 1743A-Password.cpp │ ├── 1744A-Number_Replacement.cpp │ ├── 1744B-Even-Odd_Increments.cpp │ ├── 1744C-Traffic_Light.cpp │ ├── 1746A-Mamina.cpp │ ├── 1746B-Rebellion.cpp │ ├── 1746C-Permutation_Operations.cpp │ ├── 1747A-Two_Groups.cpp │ ├── 1747B-BAN_BAN.cpp │ ├── 1748A-The_Ultimate_Square.cpp │ ├── 1748B-Diverse_Substrings.cpp │ ├── 1749A-Cowardly_Rooks.cpp │ ├── 1749B-Death's_Blessing.cpp │ ├── 1750A-Indirect_Sort.cpp │ ├── 1750B-Maximum_Substring.cpp │ ├── 1753A1-Make_Nonzero_Sum_(easy_version).cpp │ ├── 1754A-Technical_Support .cpp │ ├── 1754B-Kevin_and_Permutation.cpp │ ├── 1758A-SSeeeeiinngg DDoouubbllee.cpp │ ├── 1758B-XOR = Average.cpp │ ├── 1759A-Yes-Yes.cpp │ ├── 1759B-Lost_Permutation.cpp │ ├── 1759D-Make_It_Round.cpp │ ├── 1760A-Medium_Number.cpp │ ├── 1760B-Atilla's Favorite Problem.cpp │ ├── 1760C-Advantages.cpp │ ├── 1760D-Challenging Valleys.cpp │ ├── 1760E-Binary Inversions.cpp │ ├── 1761A-Two_Permutations.cpp │ ├── 1761B-Elimination of a Ring.cpp │ ├── 1762A-Divide and Conquer.cpp │ ├── 1762B-Make Array Good.cpp │ ├── 1763A-Absolute Maximization.cpp │ ├── 1766A-Extremely Round.cpp │ ├── 1766B-Notepad#.cpp │ ├── 1766C-Hamiltonian Wall.cpp │ ├── 1767A-Cut the Triangle.cpp │ ├── 1767B-Block Towers.cpp │ ├── 1768A-Greatest Convex.cpp │ ├── 1768B-Quick Sort.cpp │ ├── 1770A-Koxia and Whiteboards.cpp │ ├── 1770B-Koxia and Permutation.cpp │ ├── 1770C-Koxia and Number Theory.cpp │ ├── 1771A-Hossam and Combinatorics.cpp │ ├── 1771B-Hossam and Friends.cpp │ ├── 1773F-Football.cpp │ ├── 1774A-Add Plus Minus Sign.cpp │ ├── 1774B-Coloring.cpp │ ├── 1775a2-Gardener and the Capybaras (hard version).cpp │ ├── 1777A-Everybody Likes Good Arrays!.cpp │ ├── 1777B-Emordnilap.cpp │ ├── 1777B-Matrix Rotation.cpp │ ├── 1778A-Flip Flop Sum.cpp │ ├── 1779A-Hall of Fame.cpp │ ├── 1779B-MKnez's ConstructiveForces Task.cpp │ ├── 1780A-Hayato and School.cpp │ ├── 1780B-GCD Partition.cpp │ ├── 1782A-Parallel Projection.cpp │ ├── 1783A-Make it Beautiful.cpp │ ├── 1786A1. Non-alternating Deck (easy version).cpp │ ├── 1786A2. Alternating Deck (hard version).cpp │ ├── 1786B-Cake Assembly Line.cpp │ ├── 1786C-Monsters (easy version).cpp │ ├── 1788A-One and Two.cpp │ ├── 1788B-Sum of Two Numbers.cpp │ ├── 1791A-Codeforces Checking.cpp │ ├── 1791B-Following Directions.cpp │ ├── 1791C-Prepend and Append.cpp │ ├── 1791D-Distinct Split.cpp │ ├── 1791E-Negatives and Positives.cpp │ ├── 1791F-Range Update Point Query.cpp │ ├── 1791G1-Teleporters (Easy Version).cpp │ ├── 1792A-GamingForces.cpp │ ├── 1792B-Stand-up Comedian.cpp │ ├── 1793A-Yet Another Promotion.cpp │ ├── 1795A-Two Towers.cpp │ ├── 1795B-Ideal Point.cpp │ ├── 1796A-Typical Interview Problem.cpp │ ├── 1796B-Asterisk-Minor Template.cpp │ ├── 1797A-Li Hua and Maze.cpp │ ├── 1797B.Li Hua and Pattern.cpp │ ├── 1800B-Count the Number of Pairs.cpp │ ├── 1804A-Lame King.cpp │ ├── 1806A-Walking Master.cpp │ ├── 1809A-Garland.cpp │ ├── 1809B-Points on Plane.cpp │ ├── 1809C-Sum on Subarrays.cpp │ ├── 1810A-Beautiful Sequence.cpp │ ├── 1810B-Candies.cpp │ ├── 1810C-Make It Permutation.cpp │ ├── 1814B-Long Legs.cpp │ ├── 1820A-Yura's New Name.cpp │ ├── 1821A-Matching.cpp │ ├── 1821B-Sort the Subarray.cpp │ ├── 1823A-A-characteristic.cpp │ ├── 1823B-Sort with Step.cpp │ ├── 1828A-Divisible Array.cpp │ ├── 1828B-Permutation Swap.cpp.cpp │ ├── 1832A-New Palindrome.cpp │ ├── 1832C-Contrast Value.cpp │ ├── 1833C-Vlad Building Beautiful Array.cpp │ ├── 1837A-Grasshopper on a Line.cpp │ ├── 1837B-Comparison String.cpp │ ├── 1839A-The Good Array.cpp │ ├── 1840C-Ski Resort.cpp │ ├── 1841A-Game with Board.cpp │ ├── 1841B-Keep it Beautiful.cpp │ ├── 1843A-Sasha and Array Coloring.cpp │ ├── 1843B-Long Long.cpp │ ├── 1843C-Sum in Binary Tree.cpp │ ├── 1843D-Apple Tree.cpp │ ├── 1844B-Permutations & Primes.cpp │ ├── 1914A-Problemsolving Log.cpp │ ├── 1914B-Preparing for the Contest.cpp │ ├── 1946A.Median of an Array.cpp │ ├── 1998A-Find K Distinct Points with Fixed Center.cpp │ ├── 1998B-Minimize Equal Sum Subarrays.cpp │ ├── 2000B.Seating in a Bus.cpp │ ├── 2000C.Numeric String Template.cpp │ ├── 2008A.Sakurako's Exam.cpp │ ├── 2008B.Square or Not.cpp │ ├── 2008C.Longest Good Array.cpp │ ├── 2009C-The Legend of Freya the Frog.cpp │ ├── 2009D.Satyam and Counting.cpp │ ├── 2057A-MEX Table.cpp │ ├── 2057B-Gorilla and the Exam.cpp │ ├── 579A-Raising_Bacteria.cpp │ ├── 682A-Alyona and Numbers.cpp │ ├── 884B-Japanese Crosswords Strike Back.cpp │ ├── 961A-Tetris.cpp │ ├── 961B-Lecture Sleep.cpp │ └── readme.md ├── EDU │ ├── Binary_Search │ │ ├── Step1 │ │ │ ├── A-Binary_Search.cpp │ │ │ ├── B-Closest_to_the_Left.cpp │ │ │ ├── C-Closest_to_the_Right.cpp │ │ │ └── D-Fast_search.cpp │ │ └── Step2 │ │ │ ├── A-Packing_Rectangles.cpp │ │ │ ├── B-Ropes.cpp │ │ │ ├── C-Very_Easy_Task.cpp │ │ │ └── E-Equation.cpp │ └── Two_Pointers_Method │ │ ├── Step_1 │ │ ├── A.Merging_Arrays.cpp │ │ ├── B.Number_of_Smaller.cpp │ │ └── C.Number_of_Equal.cpp │ │ └── Step_2 │ │ ├── A-Segment_with_Small_Sum.cpp │ │ ├── B-Segment_with_Big_Sum.cpp │ │ ├── C-Number_of_Segments_with_Small_Sum.cpp │ │ ├── D-Number_of_Segments_with_Big_Sum.cpp │ │ ├── E-Segments_with_Small_Set.cpp │ │ └── F-Segments_with_Small_Spread.cpp └── readme.md ├── DevSkill └── DCP-496-Only_'1'_Substrings!!.cpp ├── Facebook_hacker_cup ├── 2020_Qualification_round │ ├── Alchemy.cpp │ ├── readme.md │ ├── timber.cpp │ └── travel_res.cpp └── readme.md ├── GFG ├── Binary Good.cpp ├── Majority_Element.cpp ├── Negative_weight_cycle.cpp ├── Prefix Subsequences.cpp ├── Sum_of_Subarrays.cpp ├── Tree Formation.cpp └── Virus Infection.cpp ├── Google ├── CodeJam │ ├── Practice │ │ └── 2019_Qualification_Round_Foregone_Solution.cpp │ └── Qualification_Round │ │ ├── Moons_and_Umbrellas.cpp │ │ ├── Reversort.cpp │ │ └── Reversort_Engineering.cpp ├── HashCode │ └── 2021 │ │ ├── Online_Qualification │ │ ├── A.cpp │ │ ├── B.cpp │ │ ├── C.java │ │ ├── D.cpp │ │ ├── E.cpp │ │ ├── F.cpp │ │ ├── TestCase │ │ │ ├── a.txt │ │ │ ├── b.txt │ │ │ ├── c.txt │ │ │ ├── d.txt │ │ │ ├── e.txt │ │ │ └── f.txt │ │ └── hashcode_2021_online_qualifications.pdf │ │ └── Practice │ │ ├── A-Example.txt │ │ ├── B-A_little_bit_of_everything.txt │ │ ├── C-Many_ingredients.txt │ │ ├── DMany_pizzas.txt │ │ ├── E-Many_teams.txt │ │ ├── hashcode.cpp │ │ ├── output1.txt │ │ ├── output2.txt │ │ ├── output3.txt │ │ ├── output4.txt │ │ ├── output5.txt │ │ └── practice_round_2021.pdf └── KickStart │ ├── 2016_Round_B-Sherlock_and_Parentheses.cpp │ ├── 2019_Round_B-Building_Palindromes.cpp │ ├── 2020_Round_A-Allocatio.cpp │ ├── 2020_Round_A-Plates.cpp │ ├── 2020_Round_E-Longest_Arithmetic.cpp │ ├── 2020_Round_F-ATM_Queue.cpp │ ├── 2020_Round_F-Metal_Harvest.cpp │ ├── 2020_Round_G-Combination_Lock.cpp │ ├── 2020_Round_G-Kick_Start.cpp │ ├── 2020_Round_G-Maximum_Coins.cpp │ ├── 2020_Round_H-Retype.cpp │ ├── 2021_Round_A-K-Goodness_String.cpp │ ├── 2021_Round_A-L_Shaped_Plots.cpp │ ├── 2021_Round_B-Consecutive_Primes.cpp │ ├── 2021_Round_B-Increasing_Substring.cpp │ ├── 2021_Round_B-Longest_Progression.cpp │ ├── 2021_Round_B-Truck_Delivery.cpp │ ├── 2021_Round_C-Alien_Generator.cpp │ ├── 2021_Round_C-Smaller_Strings.cpp │ ├── 2021_Round_H-Transform_the_String.cpp │ ├── 2022_Coding_Practice_Session_1-Centauri_Prime.cpp │ ├── 2022_Coding_Practice_Session_1-H-index.cpp │ ├── 2022_Coding_Practice_Session_1-Sample_Problem.cpp │ ├── 2022_Round_A-Challenge_Nine.cpp │ ├── 2022_Round_A-Interesting_Integers .cpp │ ├── 2022_Round_A-Speed_Typing.cpp │ ├── 2022_Round_B-Infinity_Area.cpp │ ├── 2022_Round_B-Palindromic_Factors.cpp │ ├── 2022_Round_C-New_Password.cpp │ ├── 2022_Round_C-Range_Partition.cpp │ ├── 2022_Round_E-Coloring_Game.cpp │ ├── 2022_Round_E-Students_and_Mentors.cpp │ ├── 2022_Round_F-Water_Container_System.cpp │ ├── 2022_Round_G-Curling.cpp │ ├── 2022_Round_G-Walktober.cpp │ └── readme.md ├── HackerRank ├── Java │ ├── Java_Currency_Formatter.java │ ├── Java_If-Else.java │ ├── Java_Loops.java │ ├── Java_Output_Formatting.java │ ├── Java_Stdin_and_Stdout.java │ └── Welcome_to_Java!.java └── SQL │ ├── African Cities.sql │ ├── New Companies.sql │ ├── asian-population.sql │ ├── average-population-of-each-continent.sql │ ├── contest-leaderboard.sql │ ├── draw-the-triangle-1.sql │ ├── draw-the-triangle-2.sql │ ├── earnings-of-employees.sql │ ├── occupations.sql │ ├── the-blunder.sql │ ├── the-pads.sql │ ├── weather-observation-station-13.sql │ ├── weather-observation-station-14.sql │ ├── weather-observation-station-15.sql │ ├── weather-observation-station-16.sql │ ├── weather-observation-station-17.sql │ ├── weather-observation-station-18.sql │ ├── weather-observation-station-19.sql │ ├── weather-observation-station-2.sql │ └── weather-observation-station-20.sql ├── Hackerearth ├── Circuits │ ├── April_Circuits_2021 │ │ ├── A-special_sequence.cpp │ │ ├── Divide_arrays.cpp │ │ ├── Minimum_operations.cpp │ │ ├── Palindrome_construction.cpp │ │ └── Smallest_subarrays.cpp │ ├── December_Circuits_2020 │ │ ├── A_matrix_and_XOR_operation.cpp │ │ ├── Customer_satisfaction.cpp │ │ ├── Multiple_occurances.cpp │ │ ├── Number_of_ways.cpp │ │ ├── The_minimum_cost.cpp │ │ └── test.cpp │ ├── February_Circuits21 │ │ ├── A_XOR_value.cpp │ │ ├── An_interesting_game.cpp │ │ ├── Array_operations.cpp │ │ ├── Incremental_queries.cpp │ │ ├── Robotic_moves.cpp │ │ ├── The_Smallest_permutation.cpp │ │ └── The_smallest_string.cpp │ ├── January_Circuits_2021 │ │ ├── A_chessboard.cpp │ │ ├── A_game_of_trees.cpp │ │ ├── Genrating_Python_code.cpp │ │ ├── Make_the_strings_equal.cpp │ │ ├── Replace_the_strings.cpp │ │ ├── Scoreboard_queries.cpp │ │ ├── The_GCD_function.cpp │ │ └── Tree_construction.cpp │ ├── July_circuit_2020 │ │ ├── LCM^k.cpp │ │ ├── Supernatural.cpp │ │ └── readme.md │ ├── March_Circuits_2021 │ │ ├── A-fair_competition.cpp │ │ ├── Bob_and_consulting_sessions.cpp │ │ ├── Equal_elements.cpp │ │ ├── Length_of_a_valley.cpp │ │ ├── Logic_design.cpp │ │ └── Permutation_deliveries.cpp │ └── October_Circuits_2020 │ │ ├── Array_modification.cpp │ │ ├── Letter_most.cpp │ │ └── Lonely_M's_array.cpp ├── Codathon-Inter_NIT_Coding_Competition_2021 │ ├── ABHISHEK_AND_HIS_POKEMON.cpp │ ├── GOLD_COIN_ROBBERY.cpp │ ├── GUESS_THE_INTEGER.cpp │ ├── LIMITED_SCHEME.cpp │ ├── SHUBHAM_AND_ACM-ICPC.cpp │ └── TUSHAR_KA_B'DAY.cpp ├── Data_Structure_and_Algorithms │ └── Jan2021 │ │ └── Providing_gifts.cpp ├── Easy │ └── May_Easy_2021 │ │ ├── Explosion.cpp │ │ ├── Filling_Stones.cpp │ │ ├── Odd_Subsequences.cpp │ │ ├── T-Rex_And_The_Pairs.cpp │ │ └── XOR_Challenge.cpp ├── Practice │ ├── A_XOR_value.cpp │ ├── A_bitwise_pair.cpp │ ├── A_movement.cpp │ ├── Aman&Mr.Sharma.cpp │ ├── Angoor_khatte_hain.cpp │ ├── Array_operations.cpp │ ├── Bulid_a_graph.cpp │ ├── Charged_Up_Array.cpp │ ├── Conject-it.cpp │ ├── Database.cpp │ ├── Decode_The_Code.cpp │ ├── Deleting_arrays.cpp │ ├── Divisible.cpp │ ├── Divisiblity.cpp │ ├── Doctor's_secret.cpp │ ├── Duration.cpp │ ├── Equalize_strings.cpp │ ├── Friend's_relationship.cpp │ ├── Goki_and_his_breakup.cpp │ ├── Hexadecimal_numbers.cpp │ ├── I_hate_Even_Subarrays.cpp │ ├── Infinite_arrays.cpp │ ├── Jumping_stones.cpp │ ├── Ladderophilia.cpp │ ├── Minimum_indexes.cpp │ ├── Monk_at_the_Graph_Factory.cpp │ ├── Monk_in_the_real_estate.cpp │ ├── Pizza_Confusion.cpp │ ├── Play_with_numbers.cpp │ ├── Remove_the_element.cpp │ ├── Save_Patients.cpp │ ├── Shubham_and_Xor.cpp │ ├── So_NP.cpp │ ├── Teddy_and_Tweety.cpp │ ├── The_smallest_permutation.cpp │ ├── The_smallest_string.cpp │ ├── Tree_query.cpp │ ├── ali_and_helping_innocent_people.cpp │ ├── anagrams.cpp │ ├── back_to_school.cpp │ ├── birthday_party.cpp │ ├── book_of_potion_making.cpp │ ├── bricks_game.cpp │ ├── bubble_sort.cpp │ ├── char_sum.cpp │ ├── colorful_floors.cpp │ ├── cost_of_ballon.cpp │ ├── distribute_chocolates.cpp │ ├── e-maze-in.cpp │ ├── easy_going.cpp │ ├── equal_subarray.cpp │ ├── find_product.cpp │ ├── fredo_and_array_update.cpp │ ├── going_to_office.cpp │ ├── hello.cpp │ ├── i_am_easy.cpp │ ├── little_shino_common_factor.cpp │ ├── no_of_steps.cpp │ ├── prime.cpp │ ├── readme.md │ ├── roy_and_profile.cpp │ ├── seating_arrangement.cpp │ ├── set_numbers.cpp │ ├── split_house.cpp │ ├── toggle_string.cpp │ ├── two_string.cpp │ └── zoos.cpp └── readme.md ├── ICPC └── 2020_Preliminary_Round │ └── E-The_Married-Unmarried_Riddle.cpp ├── LICENSE ├── LeetCode ├── 1.Two_sum.cpp ├── 1009.Complement_of_Base_10_Integer.cpp ├── 101.Symmetric_Tree.cpp ├── 1015.Smallest_Integer_Divisible_by_K.cpp ├── 102.Binary_Tree_Level_Order_Traversal.cpp ├── 1020.Number_of_Enclaves.cpp ├── 1022.Sum_of_Root_To_Leaf_Binary_Numbers.cpp ├── 1025.Divisor_Game.cpp ├── 1027.Longest Arithmetic Subsequence.cpp ├── 104.Maximum_Depth_of_Binary_Tree.cpp ├── 1043.Partition_Array_for_Maximum_Sum.cpp ├── 1046.Last_Stone_Weight.cpp ├── 1047.Remove_All_Adjacent_Duplicates_In_String.cpp ├── 105.Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal.cpp ├── 106.Construct_Binary_Tree_from_Inorder_and_Postorder_Traversal.cpp ├── 108.Convert_Sorted_Array_to_Binary_Search_Tree.cpp ├── 1091.Shortest_Path_in_Binary_Matrix.cpp ├── 1092.Shortest_Common_Supersequence.cpp ├── 1094.Car_Pooling.cpp ├── 11.Container_With_Most_Water.cpp ├── 111.Minimum Depth of Binary Tree.cpp ├── 112.Path_Sum.cpp ├── 113.Path_Sum_II.cpp ├── 1137.N-th_Tribonacci_Number.cpp ├── 1143.Longest_Common_Subsequence.cpp ├── 1146.Snapshot Array.cpp ├── 116.Populating_Next_Right_Pointers_in_Each_Node.cpp ├── 1161.Maximum Level Sum of a Binary Tree.cpp ├── 1162.As_Far_from_Land_as_Possible.cpp ├── 117.Populating_Next_Right_Pointers_in_Each_Node_II.cpp ├── 118.Pascal's Triangle.cpp ├── 120.Triangle.cpp ├── 1201.Ugly_Number_III.cpp ├── 1202.Smallest_String_With_Swaps.cpp ├── 121.Best_Time_to_Buy_and_Sell_Stock.cpp ├── 1218.Longest Arithmetic Subsequence of Given Difference.cpp ├── 1239.Maximum_Length_of_a_Concatenated_String_with_Unique_Characters.cpp ├── 1249.Minimum_Remove_to_Make_Valid_Parentheses.cpp ├── 125. Valid Palindrome.cpp ├── 1254.Number_of_Closed_Islands.cpp ├── 1260.Shift_2D_Grid.cpp ├── 1267.Count Servs that Communicate.cpp ├── 127.Word_Ladder.cpp ├── 1277.Count_Square_Submatrices_with_All_Ones.cpp ├── 1282.Group the People Given the Group Size They Belong To.cpp ├── 1288.Remove_Covered_Intervals.cpp ├── 1290.Convert_Binary_Number_in_a_Linked_List_to_Integer.cpp ├── 1291.Sequential_Digits.cpp ├── 13.Roman_to_Integer.cpp ├── 1305.All_Elements_in_Two_Binary_Search_Trees.cpp ├── 1306.Jump_Game_III.cpp ├── 1310.XOR Queries of a Subarray.cpp ├── 1314.Matrix_Block_Sum.cpp ├── 1318. Minimum Flips to Make a OR b Equal to C.cpp ├── 133.Clone_Graph.cpp ├── 1337.The_K_Weakest_Rows_in_a_Matrix.cpp ├── 1338.Reduce_Array_Size_to_The_Half.cpp ├── 1339.Maximum_Product_of_Splitted_Binary_Tree.cpp ├── 135.Candy.cpp ├── 1351.Count Negative Numbers in a Sorted Matrix.cpp ├── 136.Single_Number.cpp ├── 137.Single Number II.cpp ├── 1372.Longest ZigZag Path in a Binary Tree.cpp ├── 14.Longest_Common_Prefix.cpp ├── 1400.Construct K Palindrome Strings.cpp ├── 141.Linked List Cycle.cpp ├── 1416.Restore The Array.cpp ├── 142.Linked List Cycle II.cpp ├── 1422.Maximum Score After Splitting a String.cpp ├── 1431.Kids With the Greatest Number of Candies.cpp ├── 144.Binary_Tree_Preorder_Traversal.cpp ├── 1448.Count_Good_Nodes_in_Binary_Tree.cpp ├── 145.Binary_Tree_Postorder_Traversal.cpp ├── 1472. Design Browser History.cpp ├── 148.Sort_List.cpp ├── 1492.The kth Factor of n.cpp ├── 1493.Longest Subarray of 1's After Deleting One Element.cpp ├── 15.3Sum.cpp ├── 151.Reverse_Words_in_a_String.cpp ├── 1510.Stone_Game_IV.cpp ├── 152.Maximum_Product_Subarray.cpp ├── 153.Find_Minimum_in_Rotated_Sorted_Array.cpp ├── 154.Find_Minimum_in_Rotated_Sorted_Array_II.cpp ├── 155.Min_Stack.cpp ├── 1578-Minimum Time to Make Rope Colorful.cpp ├── 1583.Count_Unhappy_Friends.cpp ├── 160.Intersection of Two Linked Lists.cpp ├── 1608.Special Array With X Elements Greater Than Or Equal X.cpp ├── 162.Find_Peak_Element.cpp ├── 164.Maximum_Gap.cpp ├── 1641.Count_Sorted_Vowel_Strings.cpp ├── 167.Two_sumII_Input_array_is_sorted.cpp ├── 1672.Richest_Customer_Wealth.cpp ├── 1675.Minimize_Deviation_in_Array.cpp ├── 1678.Goal_Parser_Interpretation.cpp ├── 1679.Max_Number_of_K-Sum_Pairs.cpp ├── 168.Excel Sheet Column Title.cpp ├── 1680.Concatenation_of_Consecutive_Binary_Numbers.cpp ├── 169.Majority_Element.cpp ├── 171.Easy_Sheet_Column_Number.cpp ├── 1721.Swapping_Nodes_in_a_Linked_List.cpp ├── 1726.Tuple_with_Same_Product.cpp ├── 173.Binary_Search_Tree_Iterator.cpp ├── 1732.Find the Highest Altitude.cpp ├── 1743.Restore_the_Array_From_Adjacent_Pairs.cpp ├── 1750. Minimum Length of String After Deleting Similar Ends.cpp ├── 1750.Minimum_Length_of_String_After_Deletion_Similar_Ends.cpp ├── 1753.Maximum_Score_From_Removing_Stones.cpp ├── 1765.Map Of Highest Peak.cpp ├── 1769.Minimum Number of Operations to Move All Balls to Each Box.cpp ├── 179.Largest Number.cpp ├── 1790.Check_if_One_String_Swap_Can_Make_Strings_Equal.cpp ├── 1791.Find_Center_of_Star_Graph.cpp ├── 1792.Maximum_Average_Pass_Ratio.cpp ├── 1793.Maximum_Score_of_a_Good_Subarray.cpp ├── 1804B-Vaccination.cpp ├── 1812.Determine_Color_of_a_Chessboard_Square.cpp ├── 1814.Count_Nice_Pairs_in_an_Array.cpp ├── 1819.Number_of_Different_Subsequences_GCDs.cpp ├── 1824.Minimum_Sideway_Jumps.cpp ├── 1827.Minimum_Operations_to_Make_the_Array_Increasing.cpp ├── 1828.Queries_on_Number_of_Points_Inside_a_Circle.cpp ├── 1829.Maximum_XOR_for_Each_Query.cpp ├── 1834.Single-Threaded_CPU.cpp ├── 1835.Find_XOR_Sum_of_All_Pairs_Bitwise_AND.cpp ├── 1838.Frequency_of_the_Most_Frequemt_Element.cpp ├── 1847.Closest_Room.cpp ├── 1869.Longer_Contiguous_Segment_of_Ones_than_Zeros.cpp ├── 1870.Minimum_Speed_to_Arrive_on_Time.cpp ├── 1871.Jump_Game_VII.cpp ├── 189.Rotate_Array.cpp ├── 1893.Check_if_All_the_Integers_in_a_Range_Are_Covered.cpp ├── 1894.Find_the_Student_that_Will_Replace_the_Chalk.cpp ├── 19.Remove_Nth_Node_From_End_of_List.cpp ├── 190.Reverse Bits.cpp ├── 1905.Count_Sub_Islands.cpp ├── 191.Number_of_1_Bits.cpp ├── 1930. Unique Length-3 Palindromic Subsequences.cpp ├── 1952.Three_Divisors.cpp ├── 1953.Maximum_Number_of_Weeks_for_Which_You_Can_Work.cpp ├── 1954.Minimum_Garden_Perimeter_to_Collect_Enough_Apples.cpp ├── 1974.Minimum_Time_to_Type_Word_Using_Special_Typewriter.cpp ├── 1975.Maximum_Matrix_Sum.cpp ├── 1976.Number_of_Ways_to_Arrive_at_Destination.cpp ├── 198.House_Robber.cpp ├── 1981.Minimize_the_Difference_Between_Target_and_Chosen_Elements.cpp ├── 1984.Minimum_Difference_Between_Highest_and_Lowest_of_K_Scores.cpp ├── 1985.Find_the_Kth_Largest_Integer_in_the_Array.cpp ├── 1991.Find_the_Middle_Index_in_Array.cpp ├── 1992.Find_All_Groups_of_Farmland.cpp ├── 2.Add_Two_Numbers.cpp ├── 20.Valid_Parentheses.cpp ├── 200.Number_of_Islands.cpp ├── 2000..Reverse_Prefix_of_Word.cpp ├── 2001.Maximum_Product_of_the_Length_of_Two_Palindromic_Subsequences.cpp ├── 2001.Number_of_Pairs_of_Interchangeable_Rectangles.cpp ├── 201.Bitwise And of Numbers Range.cpp ├── 2017.Grid Game.cpp ├── 202.Happy_Number.cpp ├── 2022.Convert_1D_Array_Into_2D_Array.cpp ├── 2023.Number_of_Pairs_of_Strings_With_Concatenation_Equal_to_Target.cpp ├── 2024.Maximize_the_Confusion_of_an_Exam.cpp ├── 2027.Minimum_Moves_to_Convert_String.cpp ├── 2028.Find_Missing_Observations.cpp ├── 203.Remove_Linked_List_Elements.cpp ├── 2032.Two_Out_of_Three.cpp ├── 204-Count_Primes.cpp ├── 205.Isomorphic_Strings.cpp ├── 206.Reverse_Linked_List.cpp ├── 207.Course Schedule.cpp ├── 209.Minimum Size Subarray Sum.cpp ├── 2090.K Radius Subarray Averages.cpp ├── 21.Merge_Two_Sorted_Lists.cpp ├── 211.Design_Add_and_Search_Words_Data_Structure.cpp ├── 2119.A_Number_After_a_Double_Reversal.cpp ├── 2120.Execution_of_All_Suffix_Instructions_Staying_in_a_Grid.cpp ├── 2124.Check_if_All_A's_Appears_Before_All_B's.cpp ├── 2125.Number_of_Laser_Beams_in_a_Bank.cpp ├── 2126.Destroying_Asteroids.cpp ├── 2129.Capitalize_the_Title.cpp ├── 2130.Maximum_Twin_Sum_of_a_Linked_List.cpp ├── 2131.Longest_Palindrome_by_Concatenating_Two_Letter_Words.cpp ├── 2133.Check_if_Every_Row_and_Column_Contains_All_Numbers.cpp ├── 2148.Count_Elements_With_Strictly_Smaller_and_Greater_Elements.cpp ├── 2149.Rearrange_Array_Elements_by_Sign.cpp ├── 215.Kth Largest Element in an Array.cpp ├── 2150.Find_All_Lonely_Numbers_in_the_Array.cpp ├── 2154.Keep_Multiplying_Found_Values_by_Two.cpp ├── 2155.All_Divisions_With_the_Highest_Score_of_a_Binary_Array.cpp ├── 217.Contains_Duplicate.cpp ├── 2176.Count_Equal_and_Divisible_Pairs_in_an_Array.cpp ├── 2177.Find_Three_Consecutive_Integers_That_Sum_to_a_Given_Number.cpp ├── 2178.Maximum_Split_of_Positive_Even_Integers.cpp ├── 22.Generate_Parentheses.cpp ├── 2206.Divide_Array_Into_Equal_Pairs.cpp ├── 2207.Maximize_Number_of_Subsequences_in_a_String.cpp ├── 2208.Minimum_Operations_to_Halve_Array_ Sum.cpp ├── 221-Maximal_Square.cpp ├── 2210.Count_Hills_and_Valleys_in_an_Array.cpp ├── 2211.Count_Collisions_on_a_Road.cpp ├── 2212.Maximum_Points_in_an_Archery_Competition.cpp ├── 2215.Find_the_Difference_of_Two_Arrays.cpp ├── 2216.Minimum_Deletions_to_Make_Array_Beautiful.cpp ├── 2217.Find_Palindrome_With_Fixed_Length.cpp ├── 2218.Maximum Value of K Coins From Piles.cpp ├── 2220.Minimum_Bit_Flips_to_Convert_Number.cpp ├── 2221.Find_Triangular_Sum_of_an_Array.cpp ├── 2224.Minimum_Number_of_Operations_to_Convert_Time.cpp ├── 2225.Find_Players_With_Zero_or_One_Losses.cpp ├── 2226.Maximum_Candies_Allocated_to_K_Children.cpp ├── 2231.Largest_Number_After_Digit_Swaps_by_Parity.cpp ├── 2232.Minimize_Result_by_Adding_Parentheses_to_Expression.cpp ├── 2233.Maximum_Product_After_K_Increments.cpp ├── 2239.Find_Closest_Number_to_Zero.cpp ├── 2240.Number_of_Ways_to_Buy_Pens_and_Pencils.cpp ├── 2241.Design_an_ATM_Machine.cpp ├── 2243.Calculate_Digit_Sum_of_a_String.cpp ├── 2244.Minimum_Rounds_to_Complete_All_Tasks.cpp ├── 2245.Maximum_Trailing_Zeros_in_a_Cornered_Path.cpp ├── 2249.Count_Lattice_Points_Inside_a_Circle.cpp ├── 225.Implement_Stack_ using_Queues.cpp ├── 2259.Remove_Digit_From_Number_to_Maximize_Result.cpp ├── 2260.Minimum_Consecutive_Cards_to_Pick_Up.cpp ├── 2262.Total_Appeal_of_A_String.cpp ├── 2264.Largest 3_Same-Digit_Number_in_String.cpp ├── 2265.Count_Nodes_Equal_to_Average_of_Subtree.cpp ├── 2269.Find_the_K-Beauty_of_a_Number.cpp ├── 2270.Number_of_Ways_to_Split_Array.cpp ├── 2271.Maximum_White_Tiles_Covered_by_a_Carpet.cpp ├── 2273.Find_Resultant_Array_After_Removing_Anagrams.cpp ├── 2274.Maximum_Consecutive_Floors_Without_Special_Floors.cpp ├── 2275.Largest_Combination_With_Bitwise_AND_Greater_Than_Zero.cpp ├── 2278.Percentage_of_Letter_in_String.cpp ├── 2279.Maximum_Bags_With_Full_Capacity_of_Rocks.cpp ├── 228.Summary Ranges.cpp ├── 2280.Minimum_Lines_to_Represent_a_Line_Chart.cpp ├── 2283.Check_if_Number_Has_Equal_Digit_Count_and_Digit_Value.cpp ├── 2284.Sender_With_Largest_Word_Count.cpp ├── 2285.Maximum_Total_Importance_of_Roads.cpp ├── 2287.Rearrange_Characters_to_Make_Target_String.cpp ├── 2293.Min_Max_Game.cpp ├── 2294.Partition_Array_Such_That_Maximum_Difference_Is_K.cpp ├── 2295.Replace_Elements_in_an_Array.cpp ├── 2299.Strong_Password_Checker_II.cpp ├── 23.Merge_k_Sorted_Lists.cpp ├── 230.Kth_Smallest_Element_in_a_BST.cpp ├── 2303.Calculate_Amount_Paid_in_Taxes.cpp ├── 2309.Greatest_English_Letter_in_Upper_and_Lower_Case.cpp ├── 231.Power_of_Two.cpp ├── 2310.Sum_of_Numbers_With_Units_Digit_K.cpp ├── 232.Implement_Queue_using_Stacks.cpp ├── 2325.Decode_the_message.cpp ├── 2326.Sprial_Matrix_IV.cpp ├── 2336.Smallest Number in Infinite Set.cpp ├── 2337.Move_Pieces_to_Obtain_a_String.cpp ├── 234.Palindrome_Linked_List.cpp ├── 2341.Maximum_Number_of_Pairs_in_Array.cpp ├── 2342.Max_Sum_of_a_Pair_With_Equal_Sum_of_Digits.cpp ├── 2343.Query_Kth_Smallest_Trimmed_Number.cpp ├── 2344.Minimum_Deletions_to_Make_Array_Divisible.cpp ├── 235.Lowest_Common_Ancestor_of_a_Binary_Search_Tree.cpp ├── 2352.Equal Row and Column Pairs.cpp ├── 236.Lowest_Common_Ancestor_of_a_Binary_Tree.cpp ├── 237.Delete_Node_in_a-Linked_List.cpp ├── 2379.Minimum_Recolors_to_Get_K_Consecutive_Black_Blocks.cpp ├── 2380.Time_Needed_to_Rearrange_a_Binary_String.cpp ├── 2381.Shifting_Letters_II.cpp ├── 2383.Minimum_Hours_of_Training_to_Win_a_Competition.cpp ├── 2384.Largest_Palindromic_Number.cpp ├── 2385.Amount_of_Time for Binary_Tree_to_Be_Infected.cpp ├── 2389.Longest_Subsequence_With_Limited_Sum.cpp ├── 2390.Removing_Stars_From_a_String.cpp ├── 2391.Minimum_Amount_of_Time_to_Collect_Garbage.cpp ├── 2395.Find_Subarrays_With_Equal_Sum.cpp ├── 2396.Strictly_Palindromic_Number.cpp ├── 2397.Maximum_Rows_Covered_by_Columns.cpp ├── 2399.Check_Distances_Between_Same_Letters.cpp ├── 24.Swap_Nodes_ in_Pairs.cpp ├── 2404.Most_Frequent_Even_Element.cpp ├── 2405.Optimal_Partition_of_String.cpp ├── 2406.Divide_Intervals_Into_Minimum_Number_of_Groups.cpp ├── 2409.Count_Days_Spent_Together.cpp ├── 2410.Maximum_Matching_of_Players_With_Trainers.cpp ├── 2411.Smallest_Subarrays_With_Maximum_Bitwise_OR.cpp ├── 2413.Smallest_Even_Multiple.cpp ├── 2414.Length_of_the_Longest_Alphabetical_Continuous_Substring.cpp ├── 2415.Reverse_Odd_Levels_of_Binary_Tree.cpp ├── 2416.Sum_of_Prefix_Scores_of_Strings.cpp ├── 2419.Longest_Subarray_With_Maximum_Bitwise_AND.cpp ├── 242.Valid_Anagram.cpp ├── 2420.Find_All_Good_Indices.cpp ├── 2423.Remove_Letter_To_Equalize_Frequency.cpp ├── 2424.Longest_Uploaded_Prefix.cpp ├── 2425.Bitwise_XOR_of_All_Pairings.cpp ├── 2427.Number_of_Common_Factors.cpp ├── 2428.Maximum_Sum_of_an_Hourglass.cpp ├── 2429.Minimize_XOR.cpp ├── 2432.The_Employee_That_Worked_on_the_Longest_Task.cpp ├── 2433.Find_The_Original_Array_of_Prefix_Xor.cpp ├── 2434.Using_a_Robot_to_Print_the_Lexicographically_Smallest_String.cpp ├── 2437.Number_of_Valid_Clock_Times.cpp ├── 2438.Range_Product_Queries_of_Powers.cpp ├── 2441.Largest_Positive_Integer_That_Exists_With_Its_Negative.cpp ├── 2442.Count_Number_of_Distinct_Integers_After_Reverse_Operations.cpp ├── 2443.Sum_of_Number_and_Its_Reverse.cpp ├── 2446.Determine_if_Two_Events_Have_Conflict.cpp ├── 2447.Number_of_Subarrays_With_GCD_Equal_to_K.cpp ├── 2448.Minimum_Cost_to_Make_Array_Equal.cpp ├── 2453.Destroy_Sequential_Targets.cpp ├── 2460.Apply_Operations_to_an_Array.cpp ├── 2461.Maximum_Sum_of_Distinct_Subarrays_With_Length_K.cpp ├── 2462.Total_Cost_to_Hire_K_Workers.cpp ├── 2466.Count Ways to Build Good Strings.cpp ├── 2475. Number of Unequal Triplets in Array.cpp ├── 2476. Closest Nodes Queries in a Binary Search Tree.cpp ├── 2477.Minimum Fuel Cost_to_Report_to_the_Capital.cpp ├── 2485. Find the Pivot Integer.cpp ├── 2486. Append Characters to String to Make Subsequence.cpp ├── 2490. Circular Sentence.cpp ├── 2491. Divide Players Into Teams of Equal Skill.cpp ├── 2492. Minimum Score of a Path Between Two Cities.cpp ├── 2496. Maximum Value of a String in an Array.cpp ├── 2497. Maximum Star Sum of a Graph.cpp ├── 2500. Delete Greatest Value in Each Row.cpp ├── 2501. Longest Square Streak in an Array.cpp ├── 2502. Design Memory Allocator.cpp ├── 2508. Add Edges to Make Degrees of All Nodes Even.cpp ├── 2520. Count the Digits That Divide a Number.cpp ├── 2521. Distinct Prime Factors of Product of Array.cpp ├── 2522.Partition String Into Substrings With Values at Most K.cpp ├── 2523.Closest Prime Numbers in Range.cpp ├── 2525.Categorize Box According to Criteria.cpp ├── 2526.Find Consecutive Integers from a Data Stream.cpp ├── 2527.Find Xor-Beauty of Array.cpp ├── 2529. Maximum Count of Positive Integer and Negative Integer.cpp ├── 2530. Maximal Score After Applying K Operations.cpp ├── 2531. Make Number of Distinct Characters Equal.cpp ├── 2536. Increment Submatrices by One.cpp.cpp ├── 2536.Increment Submatrices by One.cpp ├── 2545. Sort the Students by Their Kth Score.cpp ├── 2546. Apply Bitwise Operations to Make Strings Equal.cpp ├── 2551.Put Marbles in Bags.cpp ├── 2553. Separate the Digits in an Array.cpp ├── 2554. Maximum Number of Integers to Choose From a Range I.cpp ├── 2555. Maximize Win From Two Segments.cpp ├── 2558. Take Gifts From the Richest Pile.cpp ├── 2559. Count Vowel Strings in Ranges.cpp ├── 2562.Find the Array Concatenation Value.cpp ├── 2563. Count the Number of Fair Pairs.cpp ├── 2564. Substring XOR Queries.cpp ├── 2566.Maximum Difference by Remapping a Digit.cpp ├── 2567.Minimum Score by Changing Two Elements.cpp ├── 2568.Minimum Impossible OR.cpp ├── 2575.Find the Divisibility Array of a String.cpp ├── 2576.Find the Maximum Number of Marked Indices.cpp ├── 2578. Split With Minimum Sum.cpp ├── 2579. Count Total Number of Colored Cells.cpp ├── 258.Add_Digits.cpp ├── 2580. Count Ways to Group Overlapping Ranges.cpp ├── 2586.Count the Number of Vowel Strings in Range.cpp ├── 2587.Rearrange Array to Maximize Prefix Score.cpp ├── 2588.Count the Number of Beautiful Subarrays.cpp ├── 2591.Distribute Money to Maximum Children.cpp ├── 2592.Maximize Greatness of an Array.cpp ├── 2593.Find Score of an Array After Marking All Elements.cpp ├── 26.Remove_Duplicates_from_Sorted_Array.cpp ├── 2600.K Items With the Maximum Sum.cpp ├── 2610.Convert an Array Into a 2D Array With Conditions.cpp ├── 2614.Prime In Diagonal.cpp ├── 263-Ugly_Number.cpp ├── 2639.Find the Width of Columns of a Grid.cpp ├── 264-Ugly_Number_II.cpp ├── 2640.Find the Score of All Prefixes of an Array.cpp ├── 2641.Cousins in Binary Tree II.cpp ├── 2657.Find The Prefix Common Array Of Two Arrays.cpp ├── 2658. Maximum Number of Fish In a Grid.cpp ├── 2661.First Completely Painted Row or Column.cpp ├── 268.Missing Number.cpp ├── 2683.Neighboring Bitwise XOR.cpp ├── 2697.Lexicographically Smallest Palindrome.cpp ├── 2698.Find the Punishment Number of an Integer.cpp ├── 27.Remove_Element.cpp ├── 2707.Extra Characters in a String.cpp ├── 2708.Maximum Strength of a Group.cpp ├── 2712.Minimum Cost to Make All Characters Equal.cpp ├── 2718.Sum of Matrix After Queries.cpp ├── 2740.Find the Value of the Partition.cpp ├── 2785.Sort Vowels in a String.cpp ├── 279-Perfect_Squares.cpp ├── 2799.Count Complete Subarrays in an Array.cpp ├── 283.Move_Zeroes.cpp ├── 284.Peeking_Iterator.cpp ├── 287.Find_the_Duplicate_Number.cpp ├── 289.Game_of_Life.cpp ├── 292.Nim_Game.cpp ├── 2997. Minimum Number of Operations to Make Array XOR Equal to K.cpp ├── 3.Longest_Substring_Without_Repeating_Characters.cpp ├── 300-Longest_Increasing_Subsequence.cpp ├── 303.Range_Sum_Query-Immutable.cpp ├── 304.Range_Sum_Query2D-Immutable.cpp ├── 307.Range_Sum_Query-Mutable.cpp ├── 31.Next_Permutation.cpp ├── 3160.Find The Number Of Distinct Colors Among The Balls.cpp ├── 318.Maximum_Product_of_Words_Lengths.cpp ├── 322.Coin_Change.cpp ├── 3223.Minimum Length of String After.cpp ├── 326.Power_of_Three.cpp ├── 338.Counting_Bits.cpp ├── 3412.Find Mirror Score of a String.cpp ├── 342.Power_of_Four.cpp ├── 344.Reverse_String.cpp ├── 347.Top_K_Frequent_Elements.cpp ├── 350.Intersection_of_Two_Arrays_II.cpp ├── 36.Valid_Sudoku.cpp ├── 373.Find K Pairs with Smallest Sums.cpp ├── 374.Guess_Number_Higher_or_Lower.cpp ├── 378. Kth_Smallest_Element_in_a_Sorted_Matrix.cpp ├── 380.Insert_Delete_GetRandom_O(1).cpp ├── 382.Linked_List_Random_Node.cpp ├── 384.Suffle_an_Array.cpp ├── 387.First_Unique_Character_in_a_String.cpp ├── 389.Find_the_Difference.cpp ├── 39.Combination_Sum.cpp ├── 390.Elimination_Game.cpp ├── 392.Is_Subsequence.cpp ├── 4.Median_of_Two_Sorted_Arrays.cpp ├── 402.Remove_K_Digits.cpp ├── 412.Fizz_Buzz.cpp ├── 415.Add_Strings.cpp ├── 417.Pacific_Atlantic_Water_Flow.cpp ├── 429.N-ary_Tree_Level_Order_Traversal.cpp ├── 435.Non-overlapping Intervals.cpp ├── 436.Find Right Interval.cpp ├── 438.Find_All_Anagrams_in_a_String.cpp ├── 45.Jump_Game_II.cpp ├── 451.Sort_Characters_By_Frequency.cpp ├── 452.Minimum_Number_of_Arriws_to_Brust_Ballons.cpp ├── 454.4Sum_II.cpp ├── 46.Permutations.cpp ├── 463.Island_Perimeter.cpp ├── 476.Number Compliment.cpp ├── 48.Rotate_Image.cpp ├── 5.Longest_Palindromic_Substring.cpp ├── 50.Pow(x,n).cpp ├── 520.Detect_Capital.cpp ├── 525.Contiguous_Array.cpp ├── 53.Maximum_Subarray.cpp ├── 530.Minimum Absolute Difference in BST.cpp ├── 532.K-diff_Pairs_in_an_Array.cpp ├── 535.Encode_and_Decode_TinyURL.cpp ├── 538.Convert_BST_to_Greater_Tree.cpp ├── 539. Minimum Time Difference.cpp ├── 54.Spiral Matrix.cpp ├── 542.01_Matrix.cpp ├── 543.Diameter_of_Binary_Tree.cpp ├── 5435.Maximum_Ice_Cream_Bars.cpp ├── 55.Jump_Game.cpp ├── 5523.Crawler_Log_Folder.cpp ├── 5535-Maximum_Nesting_Depth_of_the_Parantheses.cpp ├── 5536-Maximal_Network_Rank.cpp ├── 5537.Split_two_Stings_to_Make_Palindrome.cpp ├── 5543.Largest_Substring_Between_Two_Equal_Characters.cpp ├── 560.Subarray_Sum_Equals_K.cpp ├── 5649.Decode_XORed_Array.cpp ├── 5653.Number_of_Rectangles_That_Can_Form_The_Largest_Square.cpp ├── 5654.Maximum_Number_of_Balls_in_a_Box.cpp ├── 566.Reshape_the_Matrix.cpp ├── 567.Peermutation_in_String.cpp ├── 5672.Check_if_Array_Is_Sorted_and_Rotated.cpp.cpp ├── 5722.Truncate_Sentence.cpp ├── 5723.Finding_the_Users_Active_Minutes.cpp ├── 5724.Minimum_Absolute_Sum_Difference.cpp ├── 5726.Sign_of_the_Product_of_an_Array.cpp ├── 5727.Find_the_Winner_of_the_Circular_Game.cpp ├── 5730.Replace_All_Digits_with_Characters.cpp ├── 5731.Seat_Reservation_Manager.cpp ├── 5732.Maximum_Element_After_Decreasing_and_Rearranging.cpp ├── 5734.Check_if_the_Sentence_Is_Pangram.cpp ├── 5737.Find_XOR_Sum_of_All_Pairs_Bitwise_AND.cpp ├── 5738.Sum_of_digits_in_Base_K.cpp ├── 5740.Longest_Substring_Of_All_Vowels_in_Order.cpp ├── 5772.Check_if_Word_Equals_Summation_of_Two_Words.cpp ├── 5773.Maximum_Value_after_Insertion.cpp ├── 5800.Build_Array_from_Permutation.cpp ├── 5801.Eliminate_Maximum_Number_of_Monstes.cpp ├── 5802.Count_Good_Numbers.cpp ├── 5850.Find_Greatest_Common_Divisor_of_Array.cpp ├── 5851.Find_Unique_Binary_String.cpp ├── 5863._Count_Special_Quadruplets.cpp ├── 59.Spiral Matrix II.cpp ├── 590.N-ary_Tree_Postorder_Traversal.cpp ├── 593.Valid Square.cpp ├── 600.Non-negative_Integers_without_Consecutive_Ones.cpp ├── 605.Can_Place_Flowers.cpp ├── 611.Valid_Triangle_Number.cpp ├── 6116.Evaluate_Boolean_Binary_Tree.cpp ├── 62.Unique_Paths.cpp ├── 6275. Minimum Operations to Make Array Equal II.cpp ├── 628-Maxumum_Product_of_Three_Numbers.cpp ├── 63.Unique_Paths_II.cpp ├── 633.Sum_of_Square_Numbers.cpp ├── 64.Minimum_Path_Sum.cpp ├── 641.Design Circular Deque.cpp ├── 646.Maximum Length of Pair Chain.cpp ├── 653.Two_Sum_IV_-_Input_is_a_BST.cpp ├── 66.Plus_One.cpp ├── 662.Maximum Width of Binary Tree.cpp ├── 669.Trim_a_Binary_Search_Tree.cpp ├── 67.Add_Binary.cpp ├── 673.Number of Longest Increasing Subsequence.cpp ├── 674-Longest_Continuous_Increasing_Subsequence.cpp ├── 680.Valid_Palindrome_II.cpp ├── 682.Baseball_Game.cpp ├── 69.Sqrt(x).cpp ├── 695.Max_Area_of_Island.cpp ├── 7.Reverse_Integer.cpp ├── 70.Climbing_Stairs.cpp ├── 700.Search_in_a_Binary_Search_Tree.cpp ├── 703.Kth_Largest_Element_in_a_Stream.cpp ├── 705.Design_HashSet.cpp ├── 706.Design_HashMap.cpp ├── 71.Simplify Path.cpp ├── 718.Maximum_Length_of_Repeated_Subarray.cpp ├── 73.Set_Matrix_Zeroes.cpp ├── 733.Flood_Fill.cpp ├── 74.Search_a_2D_Matrix.cpp ├── 744.Find Smallest Letter Greater Than Target.cpp ├── 746.Min_Cost_Climbing_Stairs.cpp ├── 76.Minimum_Window_Substring.cpp ├── 78.Subsets.cpp ├── 783.Minimum Distance Between BST Nodes.cpp ├── 79.Word_Search.cpp ├── 791.Custom_Sort_String.cpp ├── 8.String_to_Integer(atoi).cpp ├── 80.Remove_Duplicates_from_Sorted_Array_II.cpp ├── 814.Binary_Tree_Pruning.cpp ├── 827.Making_A_Large_Island.cpp ├── 838.Push_Dominoes.cpp ├── 859.Buddy Strings.cpp ├── 875.Koko_Eating_Bananas.cpp ├── 877.Stone_Game.cpp ├── 88.Merge Sorted Array.cpp ├── 881.Boats_to_Save_People.cpp ├── 885.Spiral Matrix III.cpp ├── 897.Increasing_Order_Search_Tree.cpp ├── 9.Palindrome_Number.cpp ├── 90.Subsets_II.cpp ├── 91.Decode_Ways.cpp ├── 915.Partition_Array_into_Disjoint_Intervals.cpp ├── 922.Sort_Array_By_Parity_II.java ├── 923.3Sum_With_Multiplicity.cpp ├── 926.Flip_String_to_Monotone_Increasing.cpp ├── 932.Beautiful_Array.cpp ├── 94.Binary_Tree_Inorder_Traversal.cpp ├── 941.Valid_Mountain_Array.cpp ├── 946.Validate_Stack_Sequences.cpp ├── 954.Array_of_Doubled_Pairs.cpp ├── 977.Squares_of_a_Sorted_Array.cpp ├── 98.Validate_Binary_Search_Tree.cpp ├── 983.Minimum Cost For Tickets.cpp ├── 99.Recover_Binary_Search_Tree.cpp ├── 991.Broken_Calculator.cpp ├── 994.Rotting_Oranges.cpp └── README.md ├── Online_Judge └── 11029-Leading_and_Trailing.cpp ├── Open_Kattis └── m3ujhi │ ├── Bijele.cpp │ ├── Hello_World.cpp │ └── mars_window.cpp ├── README.md ├── Some_Important_Question.html ├── Some_important_link_for_CP.html ├── Spoj └── Practice │ ├── CCOMPS.cpp │ ├── CEQU.cpp │ ├── LASTDIG.cpp │ └── LOCKER.cpp ├── Template ├── Advanced_Template(CF).cpp ├── Atcoder_Template.cpp ├── C++_oops.cpp ├── Combinatorics.cpp ├── KickStart_Template.cpp ├── Leetcode_Template.cpp ├── Simple_Template.cpp ├── cpp.json └── java.json ├── Timus_problemset ├── 1000.A+B.cpp ├── 1001.Reverse_Root.cpp ├── 1068.Sum.cpp └── readme.md └── VsCode Snippet └── cpp.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | *.class 34 | 35 | # for mac 36 | **/.DS_Store 37 | -------------------------------------------------------------------------------- /CSES/Dynamic_Programming/readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /CSES/Sorting_and_Searching/Collecting Numbers.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | int solve() 10 | { 11 | int n; 12 | cin >> n; 13 | int count = 1; 14 | 15 | vector> v(n); 16 | for (int i = 0; i < n; i++) 17 | { 18 | cin >> v[i].first; 19 | v[i].second = i + 1; 20 | } 21 | 22 | sort(v.begin(), v.end()); 23 | int temp = -1; 24 | for (int i = 0; i < n; i++) 25 | { 26 | if (v[i].second < temp) 27 | { 28 | count++; 29 | } 30 | temp = v[i].second; 31 | } 32 | cout << count << endl; 33 | return 0; 34 | } 35 | int main() 36 | { 37 | int testCase = 1; 38 | while (testCase--) 39 | { 40 | solve(); 41 | } 42 | return 0; 43 | } -------------------------------------------------------------------------------- /CSES/Sorting_and_Searching/Concert_Tickets.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | ll n, m; 12 | cin >> n >> m; 13 | multiset price_of_ticket; 14 | for (ll i = 0; i < n; i++) 15 | { 16 | ll price; 17 | cin >> price; 18 | price_of_ticket.insert(price); 19 | } 20 | for (ll i = 0; i < m; i++) 21 | { 22 | ll price_paid_by_customer; 23 | cin >> price_paid_by_customer; 24 | 25 | auto it = price_of_ticket.upper_bound(price_paid_by_customer); 26 | if (it == price_of_ticket.begin()) 27 | { 28 | cout << -1 << endl; 29 | continue; 30 | } 31 | else 32 | { 33 | cout << *(--it) << endl; 34 | price_of_ticket.erase(it); 35 | } 36 | } 37 | return 0; 38 | } 39 | int main() 40 | { 41 | int testCase=1; 42 | while(testCase--){ 43 | solve(); 44 | } 45 | return 0; 46 | } -------------------------------------------------------------------------------- /CSES/Sorting_and_Searching/Josephus Problem I.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n; 12 | cin>>n; 13 | queue q; 14 | for(int i=1;i<=n;i++){ 15 | q.push(i); 16 | } 17 | bool flag=false; 18 | while(q.size()){ 19 | if(flag){ 20 | cout<>testCase; 35 | while(testCase--){ 36 | solve(); 37 | } 38 | return 0; 39 | } -------------------------------------------------------------------------------- /CSES/Sorting_and_Searching/Maximum Subarray Sum.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | ll n; 12 | cin >> n; 13 | vector v(n); 14 | for(int i=0;i>v[i]; 16 | } 17 | ll temp_sum = 0, max_sum = INT_MIN; 18 | for(int i=0;i max_sum) 22 | max_sum = temp_sum; 23 | if (temp_sum < 0) 24 | temp_sum = 0; 25 | } 26 | cout << max_sum << endl; 27 | return 0; 28 | } 29 | int main() 30 | { 31 | int testCase=1; 32 | while(testCase--){ 33 | solve(); 34 | } 35 | return 0; 36 | } -------------------------------------------------------------------------------- /CSES/Sorting_and_Searching/Missing Coin Sum.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() 8 | { 9 | int n; 10 | cin >> n; 11 | 12 | vector coins(n); 13 | for (int i = 0; i < n; i++) 14 | { 15 | cin >> coins[i]; 16 | } 17 | 18 | // Sort the coins in ascending order 19 | sort(coins.begin(), coins.end()); 20 | 21 | long long int target = 1; // Smallest sum that cannot be formed 22 | for (int i = 0; i < n; i++) 23 | { 24 | // If the current coin is greater than the target, we found the answer 25 | if (coins[i] > target) 26 | { 27 | break; 28 | } 29 | 30 | // Otherwise, update the target by adding the current coin 31 | target += coins[i]; 32 | } 33 | 34 | cout << target << endl; 35 | 36 | return 0; 37 | } -------------------------------------------------------------------------------- /CSES/Sorting_and_Searching/Movie_Festival.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | ll n; 12 | cin >> n; 13 | vector> t(n); 14 | for (ll i = 0; i < n; i++) 15 | { 16 | cin >> t[i].first >> t[i].second; 17 | } 18 | sort(t.begin(),t.end()); 19 | 20 | ll ans = 0, current = 0; 21 | for (ll i = 0; i < n; i++) 22 | { 23 | if (i == 0) 24 | { 25 | current = t[i].second; 26 | ans++; 27 | } 28 | else 29 | { 30 | if (t[i].first >= current) 31 | { 32 | current = t[i].second; 33 | ans++; 34 | } 35 | else 36 | { 37 | current = min(current, t[i].second); 38 | } 39 | } 40 | } 41 | cout << ans << endl; 42 | return 0; 43 | } 44 | int main() 45 | { 46 | int testCase=1; 47 | while(testCase--){ 48 | solve(); 49 | } 50 | return 0; 51 | } -------------------------------------------------------------------------------- /CSES/Sorting_and_Searching/Restaurant_Customers.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | ll n; 12 | cin >> n; 13 | ll a, b, ans = 0, maxo = 0; 14 | map m; 15 | for (ll i = 0; i < n; i++) 16 | { 17 | cin >> a >> b; 18 | m[a]++; 19 | m[b]--; 20 | } 21 | for (auto x : m) 22 | { 23 | ans += x.second; 24 | maxo = max(maxo, ans); 25 | } 26 | cout << maxo << endl; 27 | return 0; 28 | } 29 | int main() 30 | { 31 | int testCase=1; 32 | while(testCase--){ 33 | solve(); 34 | } 35 | return 0; 36 | } -------------------------------------------------------------------------------- /CSES/Sorting_and_Searching/Stick Lengths.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | ll n; 12 | cin >> n; 13 | vector v(n,0); 14 | for(int i=0;i>v[i]; 16 | } 17 | sort(v.begin(), v.end()); 18 | ll avg = v[n/2]; 19 | 20 | // give same result in this way also 21 | // if (n & 1) 22 | // { 23 | // avg = v[n / 2]; 24 | // } 25 | // else 26 | // { 27 | // avg = v[(n / 2) - 1]; 28 | // } 29 | 30 | ll res = 0; 31 | for(int i=0;i 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | ios_base::sync_with_stdio(0); 12 | cin.tie(0); 13 | ll n,x,ans=0,sum=0,temp; 14 | cin>>n>>x; 15 | map um; 16 | 17 | // for empty subarray 18 | um[0]=1; 19 | 20 | vector v(n); 21 | for(auto &x:v){ 22 | cin>>x; 23 | } 24 | 25 | for(int i=0;i>testCase; 37 | while(testCase--){ 38 | solve(); 39 | } 40 | return 0; 41 | } -------------------------------------------------------------------------------- /CSES/Sorting_and_Searching/Sum of Two Values.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | ll n, x; 12 | cin >> n >> x; 13 | vector> v; 14 | ll temp = 0; 15 | for(int i=0;i> temp; 18 | v.push_back({temp, i}); 19 | } 20 | sort(v.begin(), v.end()); 21 | ll i = 0, j = n - 1; 22 | while (j > i) 23 | { 24 | temp = v[i].first + v[j].first; 25 | if (temp == x) 26 | { 27 | cout << v[i].second+1 << " " << v[j].second + 1 << endl; 28 | return 0; 29 | } 30 | if (temp < x) 31 | i++; 32 | else 33 | j--; 34 | } 35 | cout << "IMPOSSIBLE" << endl; 36 | return 0; 37 | } 38 | int main() 39 | { 40 | int testCase=1; 41 | while(testCase--){ 42 | solve(); 43 | } 44 | return 0; 45 | } -------------------------------------------------------------------------------- /CSES/Sorting_and_Searching/distinct_numbers.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | /* ascii value 11 | A=65,Z=90,a=97,z=122 12 | */ 13 | 14 | // Techniques : 15 | // divide into cases, brute force, pattern finding 16 | // sort, greedy, binary search, two pointer 17 | // transform into graph 18 | 19 | int main() 20 | { 21 | int n; 22 | cin >> n; 23 | set s; 24 | int temp; 25 | for(int i=0;i> temp; 28 | s.insert(temp); 29 | } 30 | cout< 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | ll n, temp; 12 | cin >> n; 13 | vector v; 14 | for(int i=0;i> temp; 17 | auto it = upper_bound(v.begin(),v.end(), temp); 18 | if (it == v.end()) 19 | { 20 | v.push_back(temp); 21 | } 22 | else 23 | *it = temp; 24 | } 25 | cout << v.size() << endl; 26 | return 0; 27 | } 28 | int main() 29 | { 30 | int testCase=1; 31 | while(testCase--){ 32 | solve(); 33 | } 34 | return 0; 35 | } -------------------------------------------------------------------------------- /CSES/readme.md: -------------------------------------------------------------------------------- 1 | ### [CSES](https://cses.fi/problemset/) problem set
2 | --- 3 | #### About 4 | - 👑 All [Introductory problems](https://github.com/Pankajcoder1/Competitive_Programming/tree/master/CSES/Introductory_Problems) done. 5 | --- 6 | #### Video Solution 7 | > You can find step by step video explanation of these problems at [here](https://www.youtube.com/channel/UCSVfA_mo9u3_eglngWNpCWg) in hindi. 8 | -------------------------------------------------------------------------------- /Codechef/CALCULUS.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | long long mod=998244353; 8 | long long a=0,b=1; 9 | 10 | long long inverse(long long x) 11 | { 12 | long long res=1,y=mod-2; 13 | while(y>0) 14 | { 15 | if(y&1) res=(res*x)%mod; 16 | x=(x*x)%mod; 17 | y>>=1; 18 | } 19 | return res; 20 | } 21 | void fraction(long long x) 22 | { 23 | a=(a*x+2*b)%mod; 24 | b=(b*x)%mod; 25 | } 26 | 27 | int main() 28 | { 29 | long long n; 30 | cin>>n; 31 | for(int i=1;i<=n;i++) 32 | { 33 | fraction(2*i-1); 34 | } 35 | long long hcf=__gcd(a,b); 36 | a/=hcf; 37 | b/=hcf; 38 | cout<<(a*inverse(b))%mod< 6 | int main(){ 7 | int t; 8 | scanf("%d",&t); 9 | while(t--){ 10 | int n,m; 11 | scanf("%d%d",&n,&m); 12 | int a[n],i,max=-1,sum=0,j; 13 | for(i=0;im){ 26 | printf("No\n"); 27 | } 28 | else{ 29 | int rem = m - sum; 30 | if(rem%n == 0){ 31 | printf("Yes\n"); 32 | } 33 | else{ 34 | printf("No\n"); 35 | } 36 | } 37 | } 38 | return 0; 39 | } -------------------------------------------------------------------------------- /Codechef/COPR16G.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | 8 | int main() { 9 | ios::sync_with_stdio(false); 10 | cin.tie(0); 11 | int t; 12 | cin >> t; 13 | while (t--) { 14 | int a, b; 15 | cin >> a >> b; 16 | if (__gcd(a, b) == 1) cout << (long long)a * b - a - b + 1 << '\n'; 17 | else cout << -1 << '\n'; 18 | } 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /Codechef/DIVTHREE.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | 8 | long long solve() 9 | { 10 | long long n,k,d; 11 | cin>>n>>k>>d; 12 | long long count=0,sum=0; 13 | for(long long i=0;i>temp; 17 | sum+=temp; 18 | } 19 | count=sum/k; 20 | count=min(count,d); 21 | cout<>test; 33 | while(test--) 34 | { 35 | solve(); 36 | } 37 | return 0; 38 | } 39 | /* stuff you should look before submission 40 | * int overflow 41 | * special test case (n=0||n=1||n=2) 42 | * don't get stuck on one approach if you get wrong answer 43 | */ -------------------------------------------------------------------------------- /Codechef/GCD2.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | 8 | int gcd(int x, int y) 9 | { 10 | if(y==0) 11 | return x; 12 | else 13 | return gcd(y,x%y); 14 | } 15 | 16 | int main() 17 | { 18 | //freopen("input.txt"a, "r", stdin); 19 | long long n; 20 | cin>>n; 21 | while(n--) 22 | { 23 | long long a; 24 | string b; 25 | cin>>a>>b; 26 | if(a==0) 27 | cout< 6 | using namespace std; 7 | 8 | long long solve() 9 | { 10 | int n; 11 | cin>>n; 12 | for(int i=10;i>=1;i--) 13 | { 14 | if(n%i==0) 15 | { 16 | cout<>test; 31 | while(test--) 32 | { 33 | solve(); 34 | } 35 | return 0; 36 | } 37 | /* stuff you should look before submission 38 | * int overflow 39 | * special test case (n=0||n=1||n=2) 40 | * don't get stuck on one approach if you get wrong answer 41 | */ -------------------------------------------------------------------------------- /Codechef/IRSTXOR.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | Institute: National Institute of Technology, Uttarakhand 5 | */ 6 | #include 7 | using namespace std; 8 | typedef long long ll; 9 | 10 | long long solve() 11 | { 12 | ll n; 13 | cin>>n; 14 | ll d=log2(n); 15 | // d--; 16 | d=pow(2,d); 17 | d--; 18 | ll a=d,b=n^d; 19 | cout<>test; 31 | while(test--) 32 | { 33 | solve(); 34 | } 35 | return 0; 36 | } 37 | /* stuff you should look before submission 38 | * int overflow 39 | * special test case (n=0||n=1||n=2) 40 | * don't get stuck on one approach if you get wrong answer 41 | */ -------------------------------------------------------------------------------- /Codechef/readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Codeforces/1006A-Adjacent_Replacements.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by pankaj kumar. 3 | */ 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | using namespace std; 11 | typedef long long ll ; 12 | typedef vector vi; 13 | typedef vector> vpi; 14 | typedef vector vl; 15 | typedef vector> vpl; 16 | typedef set si; 17 | typedef set sl; 18 | typedef set> spi; 19 | typedef set> spl; 20 | // macros 21 | #define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0); 22 | #define mod 1000000007; 23 | #define phi 1.618 24 | #define line cout<>n; 34 | for(ll i=0;i>no; 37 | if(no%2==0) 38 | no=no-1; 39 | cout< 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0); 11 | #define mod 1000000007; 12 | using namespace std; 13 | typedef long long ll ; 14 | #define line cout<>n; 26 | for(int i=0;i>no; 29 | sum1+=no; 30 | } 31 | for(int i=0;i>no; 34 | sum2+=no; 35 | } 36 | if(sum1>=sum2) 37 | cout<<"YES"< 6 | #include 7 | #include 8 | 9 | int main() 10 | { 11 | int n,min_coin=1000,temp,coin=0,c; 12 | scanf("%d",&n); 13 | int *p=(int *)malloc(n*sizeof(int)); 14 | for(int i=0;icoin) 31 | { 32 | temp=coin; 33 | coin=min_coin; 34 | min_coin=temp; 35 | } 36 | } 37 | printf("%d \n",min_coin); 38 | } 39 | else 40 | printf("0"); 41 | return 0; 42 | } -------------------------------------------------------------------------------- /Codeforces/1225A-Forgetting_Things.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by pankaj kumar. 3 | */ 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0); 11 | #define mod 1000000007; 12 | using namespace std; 13 | typedef long long ll ; 14 | #define line cout<>da>>db; 24 | if(da==db) 25 | cout< 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0); 11 | #define mod 1000000007; 12 | using namespace std; 13 | typedef long long ll ; 14 | #define line cout<>t; 25 | while(t--) 26 | { 27 | ll a,b,c,temp,res=0; 28 | cin>>a>>b>>c; 29 | temp=min(c/2,b); 30 | b-=temp; 31 | res+=temp; 32 | temp=min(b/2,a); 33 | res+=temp; 34 | cout< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0); 7 | #define mod 1000000007; 8 | using namespace std; 9 | typedef long long ll ; 10 | #define line cout<>t; 17 | while(t--) 18 | { 19 | int count=0,n; 20 | cin>>n; 21 | int *arr=new int[n]; 22 | for(int i=0;i>arr[i]; 25 | } 26 | sort(arr,arr+n); 27 | for(int i=0;i 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0); 11 | #define mod 1000000007; 12 | using namespace std; 13 | typedef long long ll ; 14 | #define line cout<>a>>b>>c>>d>>e>>f; 24 | if(e>f) 25 | { 26 | res+=min({a,d})*e; 27 | d-=min({a,d}); 28 | res+=min({b,c,d})*f; 29 | } 30 | else 31 | { 32 | res+=min({b,c,d})*f; 33 | d-=min({b,c,d}); 34 | res+=min({a,d})*e; 35 | } 36 | cout< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0); 7 | #define mod 1000000007; 8 | using namespace std; 9 | typedef long long ll ; 10 | #define line cout<>t; 17 | while(t--) 18 | { 19 | ll arr[3]; 20 | cin>>arr[0]>>arr[1]>>arr[2]; 21 | sort(arr,arr+3); 22 | if(arr[0]+arr[1]>=arr[2]-1) 23 | cout<<"YES"< 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0); 11 | #define mod 1000000007; 12 | using namespace std; 13 | typedef long long ll ; 14 | #define line cout<>t; 24 | string s; 25 | cin>>s; 26 | for(ll i=0;i 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string str; 8 | int t,len,count,n; 9 | cin>>t; 10 | for(int j=0;j>n; 13 | str.resize(n); 14 | cin>>str; 15 | len=str.length(); 16 | string cop; 17 | count=0; 18 | for(int i=0;i 2 | #include 3 | #include 4 | #include 5 | #include 6 | #define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0); 7 | #define mod 1000000007; 8 | using namespace std; 9 | typedef long long ll ; 10 | #define line cout<>t; 17 | while(t--) 18 | { 19 | int a,b,c,d,temp; 20 | cin>>a>>b>>c>>d; 21 | if((a+b+c+d)%3!=0) 22 | cout<<"NO"<=a && temp>=b && temp>=c) 27 | cout<<"YES"< 7 | #include 8 | #include 9 | #include 10 | #define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0) 11 | using namespace std; 12 | typedef long long ll ; 13 | 14 | int main() 15 | { 16 | ll t,a,b,x,y; 17 | cin>>t; 18 | for(ll i=0;i>a>>b>>x>>y; 21 | cout< 7 | #include 8 | #define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0) 9 | using namespace std; 10 | typedef long long ll ; 11 | 12 | int main() 13 | { 14 | pan; 15 | ll t,x=0; 16 | cin>>t; 17 | vector a(t); 18 | for(ll i=0;i>a[i]; 21 | a[i]=a[i]+x; 22 | x=max(x,a[i]); 23 | cout< 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0); 11 | #define mod 1000000007; 12 | using namespace std; 13 | typedef long long ll ; 14 | #define line cout<>test; 27 | while(test--) 28 | { 29 | cin>>no; 30 | cout< 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | int solve() 10 | { 11 | vector a(3); 12 | for (auto &it : a) 13 | { 14 | cin >> it; 15 | } 16 | sort(a.begin(), a.end()); 17 | if (a[1] != a[2]) 18 | { 19 | cout << "NO" << endl; 20 | } 21 | else 22 | { 23 | cout << "YES" << endl; 24 | cout << a[0] << " " << a[0] << " " << a[2] << endl; 25 | } 26 | return 0; 27 | } 28 | int main() 29 | { 30 | int testCase = 1; 31 | cin >> testCase; 32 | while (testCase--) 33 | { 34 | solve(); 35 | } 36 | return 0; 37 | } -------------------------------------------------------------------------------- /Codeforces/1452B-Toy_Blocks.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | int solve() 10 | { 11 | int n; 12 | cin >> n; 13 | vector v(n); 14 | int maxo = 0; 15 | long long sum = 0; 16 | for (auto &x : v) 17 | { 18 | cin >> x; 19 | maxo = max(maxo, x); 20 | sum += x; 21 | } 22 | long long k = max((long long)maxo, ((sum + n - 2) / (n - 1))); 23 | cout << (k * (n - 1)) - sum << endl; 24 | return 0; 25 | } 26 | int main() 27 | { 28 | int testCase = 1; 29 | cin >> testCase; 30 | while (testCase--) 31 | { 32 | solve(); 33 | } 34 | return 0; 35 | } -------------------------------------------------------------------------------- /Codeforces/151A-Soft_Drinking.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by pankaj kumar. 3 | */ 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | using namespace std; 11 | typedef long long ll ; 12 | typedef vector vi; 13 | typedef vector> vpi; 14 | typedef vector vl; 15 | typedef vector> vpl; 16 | typedef vector vs; 17 | typedef set ss; 18 | typedef set si; 19 | typedef set sl; 20 | typedef set> spi; 21 | typedef set> spl; 22 | // macros 23 | #define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0); 24 | #define mod 1000000007; 25 | #define phi 1.618 26 | #define line cout<>n>>k>>l>>c>>d>>p>>nl>>np; 36 | cout< 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0); 11 | #define mod 1000000007; 12 | using namespace std; 13 | typedef long long ll ; 14 | #define phi 1.618 15 | #define line cout<>n; 27 | ll arr[n][n]; 28 | for(ll i=0;i>arr[i][j]; 33 | if(i==j || i+j==n-1 || i==(n-1)/2 || j==(n-1)/2) 34 | sum_d+=arr[i][j]; 35 | } 36 | } 37 | cout< 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0); 11 | #define mod 1000000007; 12 | using namespace std; 13 | typedef long long ll ; 14 | #define phi 1.618 15 | #define line cout<>n; 27 | ll arr[n][n]; 28 | for(ll i=0;i>arr[i][j]; 33 | if(i==j || i+j==n-1 || i==(n-1)/2 || j==(n-1)/2) 34 | sum_d+=arr[i][j]; 35 | } 36 | } 37 | cout< 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | ll n, ans=0; 12 | cin>>n; 13 | map,ll> mp; 14 | vector v(n); 15 | for(auto &x:v){ 16 | cin>>x; 17 | } 18 | for(ll i=0;i+2>testCase; 32 | while(testCase--){ 33 | solve(); 34 | } 35 | return 0; 36 | } -------------------------------------------------------------------------------- /Codeforces/236A-Boy or Girl.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by pankaj kumar. 3 | */ 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0); 11 | #define mod 1000000007; 12 | using namespace std; 13 | typedef long long ll ; 14 | #define phi 1.618 15 | #define line cout<s; 27 | string s1; 28 | getline(cin,s1); 29 | for(int i=0;i 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | using namespace std; 11 | typedef long long ll ; 12 | typedef vector vi; 13 | typedef vector> vpi; 14 | typedef vector vl; 15 | typedef vector> vpl; 16 | typedef set si; 17 | typedef set sl; 18 | typedef set> spi; 19 | typedef set> spl; 20 | // macros 21 | #define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0); 22 | #define mod 1000000007; 23 | #define phi 1.618 24 | #define line cout<>n; 35 | string s; 36 | cin>>s; 37 | for(int i=0;i 6 | #include 7 | using namespace std; 8 | 9 | int main() 10 | { 11 | string s; 12 | cin>>s; 13 | int i; 14 | if(int(s[0])>=97 && int(s[0])<=122) 15 | { 16 | i=int(s[0]); 17 | s[0]=char(i-32); 18 | } 19 | cout< 6 | #include 7 | using namespace std; 8 | 9 | int main() 10 | { 11 | int n,m,sum=0; 12 | cin>>n>>m; 13 | int *arr=new int[n]; 14 | for(int i=0;i>arr[i]; 17 | } 18 | sort(arr,arr+n); 19 | for(int i=0;i=0) 27 | cout< 6 | #include 7 | using namespace std; 8 | 9 | int main() 10 | { 11 | int n,no,count=0,rem=0; 12 | cin>>n; 13 | for(int i=1;i<=n;i++) 14 | { 15 | cin>>no; 16 | if(no>0) 17 | { 18 | count=count+no; 19 | } 20 | else if(no<0) 21 | { 22 | if(count<=0) 23 | { 24 | rem=rem+1; 25 | } 26 | else 27 | { 28 | count=count+no; 29 | } 30 | } 31 | } 32 | cout< 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0); 11 | #define mod 1000000007; 12 | using namespace std; 13 | typedef long long ll ; 14 | #define line cout<>a>>b>>c>>d; 24 | string s; 25 | cin>>s; 26 | for(ll i=0;i 6 | #include 7 | using namespace std; 8 | 9 | int main() 10 | { 11 | char ch; 12 | int d,count=0; 13 | int *arr=new int[26]; 14 | fill_n(arr,26,0); 15 | cin>>ch; 16 | while(ch!='}') 17 | { 18 | if(int(ch)>=97 && int(char(ch))<=122) 19 | { 20 | d=int(char(ch))-97; 21 | arr[d]=arr[d]+1; 22 | } 23 | cin>>ch; 24 | } 25 | for(int i=0;i<26;i++) 26 | { 27 | if(arr[i]!=0) 28 | { 29 | count++; 30 | } 31 | } 32 | cout< 6 | #include 7 | using namespace std; 8 | 9 | int main() 10 | { 11 | long long int n,m,count=0; 12 | cin>>n>>m; 13 | for(long long int i=1;i<=m;i++) 14 | { 15 | count=count+((n+(i%5))/5); 16 | } 17 | cout< 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | ll n,d; 12 | cin>>n>>d; 13 | string s; 14 | cin>>s; 15 | ll j=0,current_pos=0,count=0; 16 | while(j 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | long long a,b,x,y; 12 | cin>>a>>b>>x>>y; 13 | long long hcf=__gcd(x,y); 14 | x/=hcf; 15 | y/=hcf; 16 | cout< 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n,m; 12 | cin >> n >> m; 13 | cout << n * 3 + min(m - 1, n - m); 14 | return 0; 15 | } 16 | int main() 17 | { 18 | int testCase=1; 19 | while(testCase--){ 20 | solve(); 21 | } 22 | return 0; 23 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1181A-Chunga-Changa.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | int solve() 10 | { 11 | long long x,y,z; 12 | cin >> x >> y >> z; 13 | if(x%z+y%z 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n, l, r; 12 | cin >> n >> l >> r; 13 | int mini = 0, maxo = 0; 14 | int t = 1; 15 | for (int x = 1; x <= l; x++){ 16 | mini += t, t *= 2; 17 | } 18 | mini += (n - l); 19 | t=1; 20 | for(int x = 1; x <= r; x++){ 21 | maxo += t, t *= 2; 22 | } 23 | maxo += (n - r) * t / 2; 24 | cout << mini << " " << maxo << endl; 25 | return 0; 26 | } 27 | int main() 28 | { 29 | int testCase=1; 30 | while(testCase--){ 31 | solve(); 32 | } 33 | return 0; 34 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1260A-Heating.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int t, a, b; 6 | cin >> t; 7 | while (t--) 8 | { 9 | cin >> a >> b; 10 | int x = b / a; 11 | int y = b % a; 12 | cout << (a - y) * x * x + (x + 1) * (x + 1) * y << "\n"; 13 | } 14 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/148A-Insomnia cure.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by pankaj kumar. 3 | */ 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0); 11 | #define mod 1000000007; 12 | using namespace std; 13 | typedef long long ll ; 14 | #define line cout<>k>>l>>m>>n>>d; 24 | for(ll i=1;i<=d;i++) 25 | { 26 | if(i%k==0 || i%l==0||i%m==0||i%n==0) 27 | count++; 28 | } 29 | cout< 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int p,d,t,c,f; 12 | cin>>p>>d>>t>>f>>c; 13 | double princess = p * t,T; 14 | int bijous = 0; 15 | if (p < d) 16 | { 17 | while (princess < c) 18 | { 19 | T = princess / (d - p); 20 | princess += T * p; 21 | if (princess < c) 22 | { 23 | princess += (T + f) * p; 24 | bijous++; 25 | } 26 | } 27 | } 28 | cout< 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n; 12 | cin >> n; 13 | bool ok = true; 14 | for (int i = 1; i <= n; i++) 15 | { 16 | int x; 17 | cin >> x; 18 | bool found = false; 19 | for (int j = i + 1; j >= 2; j--) 20 | { 21 | if (x % j) 22 | { 23 | found = true; 24 | break; 25 | } 26 | } 27 | ok &= found; 28 | } 29 | if (ok) 30 | { 31 | cout << "YES\n"; 32 | } 33 | else 34 | { 35 | cout << "NO\n"; 36 | } 37 | return 0; 38 | } 39 | int main() 40 | { 41 | int testCase=1; 42 | cin>>testCase; 43 | while(testCase--){ 44 | solve(); 45 | } 46 | return 0; 47 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1735A-Working_Week.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | /* ascii value 11 | A=65,Z=90,a=97,z=122 12 | */ 13 | 14 | // Techniques : 15 | // divide into cases, brute force, pattern finding 16 | // sort, greedy, binary search, two pointer 17 | // transform into graph 18 | 19 | 20 | int main() 21 | { 22 | long long testCase; 23 | cin>>testCase; 24 | while(testCase--){ 25 | int n; 26 | cin>>n; 27 | n-=6; 28 | cout << n / 3 << endl; 29 | } 30 | return 0; 31 | } 32 | /* -----------------END OF PROGRAM --------------------*/ 33 | /* 34 | * stuff you should look before submission 35 | * constraint and time limit 36 | * int overflow 37 | * special test case (n=0||n=1||n=2) 38 | * don't get stuck on one approach if you get wrong answer 39 | */ 40 | -------------------------------------------------------------------------------- /Codeforces/After Placement/1740A-Factorise_N+M.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | /* ascii value 11 | A=65,Z=90,a=97,z=122 12 | */ 13 | 14 | // Techniques : 15 | // divide into cases, brute force, pattern finding 16 | // sort, greedy, binary search, two pointer 17 | // transform into graph 18 | 19 | 20 | int solve(){ 21 | int n; 22 | cin>>n; 23 | cout<>testCase; 30 | while(testCase--){ 31 | solve(); 32 | } 33 | return 0; 34 | } 35 | /* -----------------END OF PROGRAM --------------------*/ 36 | /* 37 | * stuff you should look before submission 38 | * constraint and time limit 39 | * int overflow 40 | * special test case (n=0||n=1||n=2) 41 | * don't get stuck on one approach if you get wrong answer 42 | */ -------------------------------------------------------------------------------- /Codeforces/After Placement/1768A-Greatest Convex.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int k; 12 | cin>>k; 13 | cout<>testCase; 20 | while(testCase--){ 21 | solve(); 22 | } 23 | return 0; 24 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1768B-Quick Sort.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n,k; 12 | cin>>n>>k; 13 | int count=0; 14 | for(int i=0;i>temp; 17 | if(temp==count+1){ 18 | count++; 19 | } 20 | } 21 | cout<<(n-count+k-1)/k<>testCase; 28 | while(testCase--){ 29 | solve(); 30 | } 31 | return 0; 32 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1770A-Koxia and Whiteboards.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n,m; 12 | cin>>n>>m; 13 | long long sum=0; 14 | // bucket 15 | priority_queue,greater> pq; 16 | for(int i=0;i>temp; 19 | pq.push(temp); 20 | } 21 | for(int i=0;i>temp; 24 | pq.pop(); 25 | pq.push(temp); 26 | } 27 | while(!pq.empty()){ 28 | sum+=pq.top(); 29 | pq.pop(); 30 | } 31 | cout<>testCase; 38 | while(testCase--){ 39 | solve(); 40 | } 41 | return 0; 42 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1770B-Koxia and Permutation.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n,k; 12 | cin>>n>>k; 13 | vector v(n); 14 | int first=n,second=1; 15 | for(int i=0;i>testCase; 33 | while(testCase--){ 34 | solve(); 35 | } 36 | return 0; 37 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1775a2-Gardener and the Capybaras (hard version).cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | int solve(){ 10 | string s; 11 | cin>>s; 12 | int n=s.size(); 13 | int pos=-1; 14 | for(int i=1;i<=n-2;i++){ 15 | if(s[i]=='a'){ 16 | pos=i; 17 | break; 18 | } 19 | } 20 | // cout<<"pos="<>testCase; 33 | while(testCase--){ 34 | solve(); 35 | } 36 | return 0; 37 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1777B-Emordnilap.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | long long mod=1e9+7; 9 | 10 | long long factorial(int n){ 11 | long long ans=1; 12 | for(int i=1;i<=n;i++){ 13 | ans*=i; 14 | ans%=mod; 15 | } 16 | return ans; 17 | } 18 | 19 | 20 | int solve(){ 21 | int n; 22 | cin>>n; 23 | long long ans=(long long)n*(n-1); 24 | ans%=mod; 25 | ans=(ans*factorial(n))%mod; 26 | cout<>testCase; 33 | while(testCase--){ 34 | solve(); 35 | } 36 | return 0; 37 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1777B-Matrix Rotation.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | int solve() 10 | { 11 | int a, b, c, d; 12 | cin >> a >> b >> c >> d; 13 | 14 | if ((b > a && d > c && c > a && d > b) || 15 | (a > c && b > d && d > c && b > a) || 16 | (c > d && a > b && b > d && a > c) || 17 | (d > b && c > a && a > b && c > d)) 18 | { 19 | cout << "YES" << endl; 20 | } 21 | else 22 | { 23 | cout << "NO" << endl; 24 | } 25 | return 0; 26 | } 27 | int main() 28 | { 29 | int testCase = 1; 30 | cin >> testCase; 31 | while (testCase--) 32 | { 33 | solve(); 34 | } 35 | return 0; 36 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1778A-Flip Flop Sum.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | int solve() 10 | { 11 | int n, minn = 4, sum = 0; 12 | cin >> n; 13 | vector v(n); 14 | for (int i = 0; i < n; i++) 15 | { 16 | cin >> v[i]; 17 | sum += v[i]; 18 | if (i > 0) 19 | minn = min(minn, 2 * v[i] + 2 * v[i - 1]); 20 | } 21 | cout << sum - minn << endl; 22 | return 0; 23 | } 24 | int main() 25 | { 26 | int testCase = 1; 27 | cin >> testCase; 28 | while (testCase--) 29 | { 30 | solve(); 31 | } 32 | return 0; 33 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1780B-GCD Partition.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n; 12 | cin>>n; 13 | vector v(n); 14 | vector prefix(n); 15 | for(int i=0;i>v[i]; 17 | if(i==0){ 18 | prefix[i]=v[i]; 19 | } 20 | else{ 21 | prefix[i]=prefix[i-1]+v[i]; 22 | } 23 | } 24 | long long ans=0; 25 | for(int i=1;i>testCase; 35 | while(testCase--){ 36 | solve(); 37 | } 38 | return 0; 39 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1782A-Parallel Projection.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int w,d,h,a,b,f,g; 12 | cin>>w>>d>>h>>a>>b>>f>>g; 13 | cout<>testCase; 20 | while(testCase--){ 21 | solve(); 22 | } 23 | return 0; 24 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1786B-Cake Assembly Line.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | long long n,h,w; 12 | cin >> n >> h >> w; 13 | vector a(n), b(n); 14 | for (int i = 0; i < n; i++) 15 | { 16 | cin >> a[i]; 17 | } 18 | for (int i = 0; i < n; i++) 19 | { 20 | cin >> b[i]; 21 | b[i] = a[i] - b[i]; 22 | } 23 | sort(b.begin(), b.end()); 24 | if (b[n-1] - b[0] <= 2 * (h - w)) 25 | cout << "YES" << endl; 26 | else 27 | cout << "NO" << endl; 28 | return 0; 29 | } 30 | int main() 31 | { 32 | int testCase=1; 33 | cin>>testCase; 34 | while(testCase--){ 35 | solve(); 36 | } 37 | return 0; 38 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1786C-Monsters (easy version).cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n; 12 | cin >> n; 13 | vector a(n); 14 | for (int i = 0; i < n; ++i) 15 | { 16 | cin >> a[i]; 17 | } 18 | sort(a.begin(), a.end()); 19 | long long ans = 0, cur_min = 1; 20 | for (int i = 0; i < n; ++i) 21 | { 22 | if (a[i] >= cur_min) 23 | { 24 | ans += a[i] - cur_min; 25 | cur_min++; 26 | } 27 | } 28 | cout << ans << "\n"; 29 | return 0; 30 | } 31 | int main() 32 | { 33 | int testCase=1; 34 | cin>>testCase; 35 | while(testCase--){ 36 | solve(); 37 | } 38 | return 0; 39 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1788A-One and Two.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n; 12 | cin>>n; 13 | int two=0; 14 | vector v(n); 15 | for(int i=0;i>v[i]; 17 | if(v[i]==2){ 18 | two++; 19 | } 20 | } 21 | int twoTillHere=0; 22 | for(int i=0;i>testCase; 38 | while(testCase--){ 39 | solve(); 40 | } 41 | return 0; 42 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1791A-Codeforces Checking.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | 12 | return 0; 13 | } 14 | int main() 15 | { 16 | int testCase=1; 17 | cin>>testCase; 18 | while(testCase--){ 19 | char ch; 20 | cin >> ch; 21 | bool flag=false; 22 | string str = "codeforces"; 23 | for (auto ch2 : str) 24 | { 25 | if (ch2 == ch) 26 | { 27 | flag=true; 28 | break; 29 | } 30 | } 31 | if(flag) 32 | cout << "YES" << endl; 33 | else 34 | cout << "NO" << endl; 35 | } 36 | return 0; 37 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1791C-Prepend and Append.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n; 12 | string str; 13 | cin>>n>>str; 14 | int l=0,r=n-1; 15 | while(true){ 16 | if(l==r){ 17 | cout<<1<r){ 21 | cout<<0<>testCase; 40 | while(testCase--){ 41 | solve(); 42 | } 43 | return 0; 44 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1791D-Distinct Split.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | long long n; 12 | string str; 13 | cin>>n>>str; 14 | vector prefix(n,0),suffix(n,0); 15 | set se; 16 | for(int i=0;i=0;i--){ 22 | se.insert(str[i]); 23 | suffix[i]=se.size(); 24 | } 25 | int ans=0,maxo=0; 26 | for(int i=0;i>testCase; 37 | while(testCase--){ 38 | solve(); 39 | } 40 | return 0; 41 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1791G1-Teleporters (Easy Version).cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | long long n,c; 12 | cin>>n>>c; 13 | vector v(n); 14 | long long sum = 0; 15 | 16 | for(long long i=0;i>v[i]; 18 | v[i]=v[i]+i+1; 19 | } 20 | 21 | sort(v.begin(),v.end()); 22 | for(int i=0;ic){ 25 | cout<>testCase; 36 | while(testCase--){ 37 | solve(); 38 | } 39 | return 0; 40 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1792A-GamingForces.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n,ones=0; 12 | cin>>n; 13 | for (int i = 0; i < n; i++) 14 | { 15 | int x; 16 | cin>>x; 17 | if (x == 1) 18 | ones++; 19 | } 20 | printf("%d\n", n - ones / 2); 21 | return 0; 22 | } 23 | int main() 24 | { 25 | int testCase=1; 26 | cin>>testCase; 27 | while(testCase--){ 28 | solve(); 29 | } 30 | return 0; 31 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1792B-Stand-up Comedian.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | int solve() 10 | { 11 | int a, b, c, d; 12 | cin >> a >> b >> c >> d; 13 | if (a == 0) 14 | { 15 | cout << 1 << endl; 16 | return 0; 17 | } 18 | int ans = a; 19 | ans += 2 * min(b, c); 20 | ans += min(a + 1, abs(c - b) + d); 21 | cout << ans << endl; 22 | return 0; 23 | } 24 | int main() 25 | { 26 | int testCase = 1; 27 | cin >> testCase; 28 | while (testCase--) 29 | { 30 | solve(); 31 | } 32 | return 0; 33 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1796A-Typical Interview Problem.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | string s = "FBFFBFFBFBFFBFFBFBFFBFFB"; 12 | int n; 13 | string temp; 14 | cin>>n>>temp; 15 | for(int i=0;i+n>testCase; 35 | while(testCase--){ 36 | solve(); 37 | } 38 | return 0; 39 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1797A-Li Hua and Maze.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n, m; 12 | cin >> n >> m; 13 | 14 | int x1, y1, x2, y2; 15 | cin >> x1 >> y1 >> x2 >> y2; 16 | 17 | int d1 = 0, d2 = 0; 18 | 19 | if (x1 - 1 >= 1) 20 | d1++; 21 | if (x1 + 1 <= n) 22 | d1++; 23 | if (y1 - 1 >= 1) 24 | d1++; 25 | if (y1 + 1 <= m) 26 | d1++; 27 | 28 | if (x2 - 1 >= 1) 29 | d2++; 30 | if (x2 + 1 <= n) 31 | d2++; 32 | if (y2 - 1 >= 1) 33 | d2++; 34 | if (y2 + 1 <= m) 35 | d2++; 36 | 37 | cout << min(d1, d2) << endl; 38 | return 0; 39 | } 40 | int main() 41 | { 42 | int testCase=1; 43 | cin>>testCase; 44 | while(testCase--){ 45 | solve(); 46 | } 47 | return 0; 48 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1804A-Lame King.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | int solve() 10 | { 11 | int a, b; 12 | cin >> a >> b; 13 | a = abs(a); 14 | b = abs(b); 15 | int ans = 2 * min(a, b); 16 | if (a != b) 17 | { 18 | ans += 2 * (abs(b - a)) - 1; 19 | } 20 | cout << ans << endl; 21 | 22 | return 0; 23 | } 24 | int main() 25 | { 26 | int testCase = 1; 27 | cin >> testCase; 28 | while (testCase--) 29 | { 30 | solve(); 31 | } 32 | return 0; 33 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1806A-Walking Master.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | long long a,b,c,d; 12 | cin>>a>>b>>c>>d; 13 | if(d>testCase; 32 | while(testCase--){ 33 | solve(); 34 | } 35 | return 0; 36 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1809A-Garland.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | string s; 12 | cin>>s; 13 | map m; 14 | int maxo=0; 15 | for(auto x:s){ 16 | m[x]++; 17 | maxo=max(maxo,m[x]); 18 | } 19 | if(maxo==1 || maxo==2){ 20 | cout<<4<>testCase; 34 | while(testCase--){ 35 | solve(); 36 | } 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /Codeforces/After Placement/1809B-Points on Plane.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | long long n; 12 | cin>>n; 13 | cout<<(long long)sqrt(n-1)<>testCase; 20 | while(testCase--){ 21 | solve(); 22 | } 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /Codeforces/After Placement/1809C-Sum on Subarrays.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n, k; 12 | cin >> n >> k; 13 | for (int i = 1; i <= n; i++) 14 | { 15 | if (k >= i) 16 | { 17 | k -= i; 18 | cout << 2 << " "; 19 | continue; 20 | } 21 | if (k == 0) 22 | { 23 | cout << -1000 << " "; 24 | continue; 25 | } 26 | cout << (i - k) * (-2) + 1 << " "; 27 | k = 0; 28 | } 29 | cout << endl; 30 | return 0; 31 | } 32 | int main() 33 | { 34 | int testCase=1; 35 | cin>>testCase; 36 | while(testCase--){ 37 | solve(); 38 | } 39 | return 0; 40 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1810A-Beautiful Sequence.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | int solve() 10 | { 11 | int n; 12 | cin >> n; 13 | vector v(n + 1); 14 | for (int i = 1; i <= n; i++) 15 | { 16 | cin >> v[i]; 17 | } 18 | for (int i = 1; i <= n; i++) 19 | { 20 | if (v[i] <= i) 21 | { 22 | cout << "YES" << endl; 23 | return 0; 24 | } 25 | } 26 | cout << "NO" << endl; 27 | return 0; 28 | } 29 | int main() 30 | { 31 | int testCase = 1; 32 | cin >> testCase; 33 | while (testCase--) 34 | { 35 | solve(); 36 | } 37 | return 0; 38 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1810C-Make It Permutation.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n; 12 | long long c, d; 13 | cin >> n >> c >> d; 14 | vector a(n); 15 | map mp; 16 | 17 | for (int j = 0; j < n; j++) 18 | { 19 | cin >> a[j]; 20 | mp[a[j]]++; 21 | } 22 | long long ans = n * c + d; 23 | int cnt = 0; 24 | for (auto x : mp) 25 | { 26 | cnt++; 27 | ans = min(ans, (n - cnt) * c + (x.first - cnt) * d); 28 | } 29 | cout << ans << endl; 30 | return 0; 31 | } 32 | int main() 33 | { 34 | int testCase=1; 35 | cin>>testCase; 36 | while(testCase--){ 37 | solve(); 38 | } 39 | return 0; 40 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1814B-Long Legs.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | long long k,a,b; 12 | cin >> a >> b; 13 | k = a + b; 14 | for (int i = 2; i <= 100000; i++) 15 | { 16 | k = min(k, (a + i - 1) / i + (b + i - 1) / i + i - 1); 17 | } 18 | cout << k << endl; 19 | return 0; 20 | } 21 | int main() 22 | { 23 | int testCase=1; 24 | cin>>testCase; 25 | while(testCase--){ 26 | solve(); 27 | } 28 | return 0; 29 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1820A-Yura's New Name.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | string s; 12 | cin >> s; 13 | string s1; 14 | int ans = 0; 15 | if (s[0] == '_') 16 | { 17 | s1 = "^"; 18 | ans++; 19 | } 20 | for (int i = 0; i < s.size(); i++) 21 | { 22 | if (s[i] == '_' && s1.back() == '_') 23 | { 24 | s1 += '^'; 25 | } 26 | s1 += s[i]; 27 | } 28 | if (s1.size() == 1){ 29 | s1 += '^'; 30 | } 31 | if (s1.back() == '_'){ 32 | s1 += '^'; 33 | } 34 | cout << s1.size() - s.size() << endl; 35 | return 0; 36 | } 37 | int main() 38 | { 39 | int testCase=1; 40 | cin>>testCase; 41 | while(testCase--){ 42 | solve(); 43 | } 44 | return 0; 45 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1821A-Matching.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | string s; 12 | cin>>s; 13 | int n=s.size(); 14 | int ans=1; 15 | if(s[0]=='?'){ 16 | ans=9; 17 | } 18 | else if(s[0]=='0'){ 19 | cout<<0<>testCase; 34 | while(testCase--){ 35 | solve(); 36 | } 37 | return 0; 38 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1821B-Sort the Subarray.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n; 12 | cin >> n; 13 | vector a(n), b(n); 14 | for (auto &i : a){ 15 | cin >> i; 16 | } 17 | for (auto &i : b){ 18 | cin >> i; 19 | } 20 | int l = 0, r = n - 1; 21 | 22 | while (a[l] == b[l]){ 23 | l++; 24 | } 25 | while (a[r] == b[r]){ 26 | r--; 27 | } 28 | while (l > 0 && b[l] >= b[l - 1]){ 29 | l--; 30 | } 31 | while (r < n - 1 && b[r] <= b[r + 1]){ 32 | r++; 33 | } 34 | 35 | cout << l + 1 << " " << r + 1 << endl; 36 | return 0; 37 | } 38 | int main() 39 | { 40 | int testCase=1; 41 | cin>>testCase; 42 | while(testCase--){ 43 | solve(); 44 | } 45 | return 0; 46 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1823A-A-characteristic.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n,k; 12 | cin>>n>>k; 13 | for(int i=0;i<=100;i++){ 14 | int j=n-i; 15 | int temp=(i*(i-1))/2+(j*(j-1))/2; 16 | if(temp==k){ 17 | cout<<"YES"<>testCase; 35 | while(testCase--){ 36 | solve(); 37 | } 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /Codeforces/After Placement/1828A-Divisible Array.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n; 12 | cin >> n; 13 | 14 | for (int i = 1; i <= n; i++) 15 | { 16 | cout << i * 2 << ' '; 17 | } 18 | cout << endl; 19 | return 0; 20 | } 21 | int main() 22 | { 23 | int testCase=1; 24 | cin>>testCase; 25 | while(testCase--){ 26 | solve(); 27 | } 28 | return 0; 29 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1832A-New Palindrome.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | string s; 12 | cin>>s; 13 | if (s.size() % 2) { 14 | s.erase(s.begin() + s.size() / 2); 15 | } 16 | if (s != std::string(s.size(), s[0])) { 17 | cout << "YES\n"; 18 | } else { 19 | cout << "NO\n"; 20 | } 21 | return 0; 22 | } 23 | int main() 24 | { 25 | int testCase=1; 26 | cin>>testCase; 27 | while(testCase--){ 28 | solve(); 29 | } 30 | return 0; 31 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1832C-Contrast Value.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n; 12 | cin>>n; 13 | int ans=0; 14 | vector a(n); 15 | for(auto &x:a){ 16 | cin>>x; 17 | } 18 | a.resize(unique(a.begin(), a.end()) - a.begin()); 19 | n = (int)a.size(); 20 | for (int i = 0; i < n; i++) 21 | { 22 | if (i == 0 || i == n - 1 || (a[i]>a[i-1] && a[i]>a[i+1]) || (a[i]>testCase; 34 | while(testCase--){ 35 | solve(); 36 | } 37 | return 0; 38 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1837A-Grasshopper on a Line.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int x,k; 12 | cin>>x>>k; 13 | if(x%k){ 14 | cout<<1<>testCase; 25 | while(testCase--){ 26 | solve(); 27 | } 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /Codeforces/After Placement/1837B-Comparison String.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n; 12 | string s; 13 | cin>>n>>s; 14 | int count=0,maxo=0; 15 | for(int i=0;i>testCase; 36 | while(testCase--){ 37 | solve(); 38 | } 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /Codeforces/After Placement/1841A-Game with Board.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n; 12 | cin >> n; 13 | if (n >= 5) { 14 | cout << "Alice" << '\n'; 15 | return 0; 16 | } 17 | cout << "Bob" << '\n'; 18 | return 0; 19 | } 20 | int main() 21 | { 22 | int testCase=1; 23 | cin>>testCase; 24 | while(testCase--){ 25 | solve(); 26 | } 27 | return 0; 28 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1843A-Sasha and Array Coloring.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n; 12 | cin>>n; 13 | vector v(n); 14 | for(auto &x:v){ 15 | cin>>x; 16 | } 17 | sort(v.begin(),v.end()); 18 | int ans=0; 19 | for(int i=0;i>testCase; 29 | while(testCase--){ 30 | solve(); 31 | } 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /Codeforces/After Placement/1843C-Sum in Binary Tree.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | long long n; 12 | cin>>n; 13 | long long sum=0; 14 | while(n){ 15 | sum+=n; 16 | n = n/2; 17 | } 18 | cout<>testCase; 25 | while(testCase--){ 26 | solve(); 27 | } 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /Codeforces/After Placement/1914A-Problemsolving Log.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n,ans=0; 12 | string s; 13 | cin>>n>>s; 14 | vector v(27,0); 15 | for(auto x:s){ 16 | v[x-'A'+1]++; 17 | } 18 | for(int i=1;i<=26;i++){ 19 | if(v[i]>=i){ 20 | ans++; 21 | } 22 | } 23 | cout<>testCase; 30 | while(testCase--){ 31 | solve(); 32 | } 33 | return 0; 34 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1914B-Preparing for the Contest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int k,n; 12 | cin>>n>>k; 13 | for(int i=n-k;i<=n;i++){ 14 | cout<0;i--){ 17 | cout<>testCase; 26 | while(testCase--){ 27 | solve(); 28 | } 29 | return 0; 30 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1946A.Median of an Array.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n; 12 | cin>>n; 13 | vector v(n); 14 | for(auto &x:v){ 15 | cin>>x; 16 | } 17 | sort(v.begin(),v.end()); 18 | // -1 because of 0 based indexing 19 | int mid=((n+1)/2)-1; 20 | int count=0; 21 | for(int i=mid;i>testCase; 33 | while(testCase--){ 34 | solve(); 35 | } 36 | return 0; 37 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1998A-Find K Distinct Points with Fixed Center.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int x,y,k; 12 | cin>>x>>y>>k; 13 | if(k&1){ 14 | cout<>testCase; 26 | while(testCase--){ 27 | solve(); 28 | } 29 | return 0; 30 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/1998B-Minimize Equal Sum Subarrays.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n; 12 | cin>>n; 13 | vector v(n); 14 | for(int i=0;i>v[i]; 16 | } 17 | for(int i=1;i>testCase; 27 | while(testCase--){ 28 | solve(); 29 | } 30 | return 0; 31 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/2000B.Seating in a Bus.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n; 12 | cin>>n; 13 | vector v(n); 14 | for(auto &x:v){ 15 | cin>>x; 16 | } 17 | int first=v[0],second=v[0]; 18 | for(int i=1;i>testCase; 40 | while(testCase--){ 41 | solve(); 42 | } 43 | return 0; 44 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/2008A.Sakurako's Exam.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int a,b; 12 | cin>>a>>b; 13 | b=b%2; 14 | if(b==0 && a%2==0){ 15 | cout<<"YES"<>testCase; 30 | while(testCase--){ 31 | solve(); 32 | } 33 | return 0; 34 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/2008C.Longest Good Array.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int l,r; 12 | cin>>l>>r; 13 | int diff=r-l; 14 | double temp = (-1 + sqrt(1 + 8.0 * diff)) / 2.0; 15 | int ans=(int)temp; 16 | 17 | cout<>testCase; 24 | while(testCase--){ 25 | solve(); 26 | } 27 | return 0; 28 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/2009C-The Legend of Freya the Frog.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int x,y,k; 12 | cin>>x>>y>>k; 13 | int ans=0; 14 | ans+=2*max((x+k-1)/k,(y+k-1)/k); 15 | if ((x + k - 1) / k > (y + k - 1) / k) 16 | { 17 | ans--; 18 | } 19 | cout<>testCase; 26 | while(testCase--){ 27 | solve(); 28 | } 29 | return 0; 30 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/2057A-MEX Table.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n,m; 12 | cin>>n>>m; 13 | cout<>testCase; 20 | while(testCase--){ 21 | solve(); 22 | } 23 | return 0; 24 | } -------------------------------------------------------------------------------- /Codeforces/After Placement/682A-Alyona and Numbers.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | long long n,m; 12 | cin>>n>>m; 13 | long long ans=0; 14 | for(int i=1;i<=n;i++){ 15 | long long temp=i%5; 16 | temp=(m+temp)/5; 17 | ans+=temp; 18 | } 19 | cout< 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n,x; 12 | cin>>n>>x; 13 | int sum=0,temp; 14 | for(int i=0;i>temp; 16 | sum+=temp; 17 | } 18 | sum=sum+n-1; 19 | if(sum==x){ 20 | cout<<"YES"< 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | 10 | int solve(){ 11 | int n,m; 12 | cin>>n>>m; 13 | vector v(n+1,0); 14 | for(int i=0;i>temp; 17 | v[temp]++; 18 | } 19 | int mini=INT_MAX; 20 | for(int i=1;i<=n;i++){ 21 | mini=min(mini,v[i]); 22 | } 23 | cout< File name of any problem is problem code with their name. 2 | -------------------------------------------------------------------------------- /Codeforces/readme.md: -------------------------------------------------------------------------------- 1 | > File name of any problem is problem code with their name. 2 | -------------------------------------------------------------------------------- /Facebook_hacker_cup/2020_Qualification_round/readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Facebook_hacker_cup/readme.md: -------------------------------------------------------------------------------- 1 | > Facebook organise coding challenge [Facebook hacker cup ](https://www.facebook.com/codingcompetitions/hacker-cup). 2 | -------------------------------------------------------------------------------- /Google/HashCode/2021/Online_Qualification/TestCase/a.txt: -------------------------------------------------------------------------------- 1 | 6 4 5 2 1000 2 | 2 0 rue-de-londres 1 3 | 0 1 rue-d-amsterdam 1 4 | 3 1 rue-d-athenes 1 5 | 2 3 rue-de-rome 2 6 | 1 2 rue-de-moscou 3 7 | 4 rue-de-londres rue-d-amsterdam rue-de-moscou rue-de-rome 8 | 3 rue-d-athenes rue-de-moscou rue-de-londres 9 | -------------------------------------------------------------------------------- /Google/HashCode/2021/Online_Qualification/hashcode_2021_online_qualifications.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pankajcoder1/Competitive_Programming/4b2bc800188c62dfc5777e6366f05c0050350cee/Google/HashCode/2021/Online_Qualification/hashcode_2021_online_qualifications.pdf -------------------------------------------------------------------------------- /Google/HashCode/2021/Practice/A-Example.txt: -------------------------------------------------------------------------------- 1 | 5 1 2 1 2 | 3 onion pepper olive 3 | 3 mushroom tomato basil 4 | 3 chicken mushroom pepper 5 | 3 tomato mushroom basil 6 | 2 chicken basil 7 | -------------------------------------------------------------------------------- /Google/HashCode/2021/Practice/output1.txt: -------------------------------------------------------------------------------- 1 | 2 2 | 2 0 1 3 | 3 2 3 4 4 | -------------------------------------------------------------------------------- /Google/HashCode/2021/Practice/practice_round_2021.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pankajcoder1/Competitive_Programming/4b2bc800188c62dfc5777e6366f05c0050350cee/Google/HashCode/2021/Practice/practice_round_2021.pdf -------------------------------------------------------------------------------- /Google/KickStart/readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /HackerRank/Java/Java_If-Else.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.math.*; 3 | import java.security.*; 4 | import java.text.*; 5 | import java.util.*; 6 | import java.util.concurrent.*; 7 | import java.util.regex.*; 8 | 9 | public class Solution { 10 | 11 | 12 | 13 | private static final Scanner scanner = new Scanner(System.in); 14 | 15 | public static void main(String[] args) { 16 | int N = scanner.nextInt(); 17 | scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); 18 | 19 | if(N%2==1 || (N>=6 && N <= 20)){ 20 | System.out.println("Weird"); 21 | } 22 | else{ 23 | System.out.println("Not Weird"); 24 | } 25 | scanner.close(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /HackerRank/Java/Java_Loops.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.math.*; 3 | import java.security.*; 4 | import java.text.*; 5 | import java.util.*; 6 | import java.util.concurrent.*; 7 | import java.util.regex.*; 8 | 9 | 10 | 11 | public class Solution { 12 | public static void main(String[] args) throws IOException { 13 | BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); 14 | 15 | int N = Integer.parseInt(bufferedReader.readLine().trim()); 16 | 17 | bufferedReader.close(); 18 | for(int i=1;i<=10;i++){ 19 | System.out.println(N+" x "+i+" = "+N*i); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /HackerRank/Java/Java_Output_Formatting.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class Solution { 4 | 5 | public static void main(String[] args) { 6 | Scanner sc=new Scanner(System.in); 7 | System.out.println("================================"); 8 | for(int i=0;i<3;i++){ 9 | String s1=sc.next(); 10 | int x=sc.nextInt(); 11 | //Complete this line 12 | System.out.printf("%-15s%03d",s1,x); 13 | System.out.printf("\n"); 14 | } 15 | System.out.println("================================"); 16 | 17 | } 18 | } 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /HackerRank/Java/Java_Stdin_and_Stdout.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | public class Solution { 4 | 5 | public static void main(String[] args) { 6 | Scanner scan = new Scanner(System.in); 7 | int a = scan.nextInt(); 8 | int b = scan.nextInt(); 9 | int c = scan.nextInt(); 10 | // Complete this line 11 | // Complete this line 12 | 13 | System.out.println(a); 14 | System.out.println(b); 15 | System.out.println(c); 16 | // Complete this line 17 | // Complete this line 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /HackerRank/Java/Welcome_to_Java!.java: -------------------------------------------------------------------------------- 1 | public class Solution { 2 | 3 | public static void main(String[] args) { 4 | /* Enter your code here. Print output to STDOUT. Your class should be named Solution. */ 5 | System.out.println("Hello, World."); 6 | System.out.println("Hello, Java."); 7 | } 8 | } 9 | 10 | -------------------------------------------------------------------------------- /HackerRank/SQL/African Cities.sql: -------------------------------------------------------------------------------- 1 | select ct.name FROM city as ct 2 | inner join country as cty 3 | on ct.countrycode = cty.code 4 | where cty.continent = "Africa" -------------------------------------------------------------------------------- /HackerRank/SQL/New Companies.sql: -------------------------------------------------------------------------------- 1 | select 2 | company.company_code, 3 | company.founder, 4 | count(distinct lead_manager.lead_manager_code), 5 | count(distinct senior_manager.senior_manager_code), 6 | count(distinct manager.manager_code), 7 | count(distinct employee.employee_code) 8 | from company 9 | inner join lead_manager on lead_manager.company_code = company.company_code 10 | inner join senior_manager on senior_manager.company_code = company.company_code 11 | inner join manager on manager.company_code = company.company_code 12 | inner join employee on employee.company_code = company.company_code 13 | group by company.company_code, company.founder 14 | order by company.company_code 15 | asc 16 | -------------------------------------------------------------------------------- /HackerRank/SQL/asian-population.sql: -------------------------------------------------------------------------------- 1 | select sum(cty.population) 2 | from city as cty 3 | inner join country as cuntry 4 | on cty.countrycode = cuntry.code 5 | where cuntry.continent = "Asia" -------------------------------------------------------------------------------- /HackerRank/SQL/average-population-of-each-continent.sql: -------------------------------------------------------------------------------- 1 | select cuntry.continent, floor(avg(cty.population)) 2 | from city as cty 3 | inner join country as cuntry 4 | on cty.countrycode = cuntry.code 5 | group by cuntry.continent 6 | 7 | -- floor() -> round down to nearest integer -------------------------------------------------------------------------------- /HackerRank/SQL/contest-leaderboard.sql: -------------------------------------------------------------------------------- 1 | with whole_data as ( 2 | select 3 | hackers.hacker_id as hacker_id, 4 | hackers.name as name, 5 | max(score) as max_score, 6 | submissions.challenge_id 7 | from hackers 8 | inner join submissions on submissions.hacker_id = hackers.hacker_id 9 | group by submissions.challenge_id, hackers.hacker_id, hackers.name 10 | having max(score) > 0 11 | ) 12 | 13 | select 14 | hacker_id, 15 | name, 16 | sum(max_score) as total_score 17 | from whole_data 18 | group by hacker_id, name 19 | order by total_score desc, hacker_id asc 20 | -------------------------------------------------------------------------------- /HackerRank/SQL/draw-the-triangle-1.sql: -------------------------------------------------------------------------------- 1 | declare @no_of_stars INT 2 | set @no_of_stars = 20 3 | while @no_of_stars > 0 4 | begin 5 | print replicate("* ", @no_of_stars) 6 | set @no_of_stars = @no_of_stars - 1 7 | end 8 | -------------------------------------------------------------------------------- /HackerRank/SQL/draw-the-triangle-2.sql: -------------------------------------------------------------------------------- 1 | declare @no_of_stars INT 2 | set @no_of_stars = 1 3 | while @no_of_stars < 21 4 | begin 5 | print replicate("* ", @no_of_stars) 6 | set @no_of_stars = @no_of_stars + 1 7 | end 8 | -------------------------------------------------------------------------------- /HackerRank/SQL/earnings-of-employees.sql: -------------------------------------------------------------------------------- 1 | with max_salary_cte as ( 2 | select max(months*salary) as highest_salary 3 | from employee 4 | ) 5 | 6 | select highest_salary, count(employee_id) 7 | from employee, max_salary_cte 8 | where employee.months*employee.salary = highest_salary 9 | group by highest_salary -------------------------------------------------------------------------------- /HackerRank/SQL/occupations.sql: -------------------------------------------------------------------------------- 1 | with data as ( 2 | select 3 | name, occupation, 4 | row_number() over(partition by occupation order by name asc) as row_num 5 | from occupations 6 | ) 7 | 8 | select 9 | max(case when occupation ="Doctor" then name end) as doc_n, 10 | max(case when occupation ="Professor" then name end) as pro_n, 11 | max(case when occupation ="Singer" then name end) as sin_n, 12 | max(case when occupation ="Actor" then name end) as act_n 13 | from 14 | data 15 | group by row_num 16 | -------------------------------------------------------------------------------- /HackerRank/SQL/the-blunder.sql: -------------------------------------------------------------------------------- 1 | select ceil(avg(salary)- avg(replace(salary,'0',''))) from employees; -------------------------------------------------------------------------------- /HackerRank/SQL/the-pads.sql: -------------------------------------------------------------------------------- 1 | select 2 | concat(name,'(',left(occupation,1),')') 3 | from occupations 4 | order by name; 5 | select 6 | "There are a total of",count(occupation) as cnt,concat(lower(occupation),'s.') 7 | from occupations 8 | group by occupation 9 | order by cnt asc; -------------------------------------------------------------------------------- /HackerRank/SQL/weather-observation-station-13.sql: -------------------------------------------------------------------------------- 1 | select round(sum(lat_n),4) 2 | from station 3 | where lat_n > 38.7880 and lat_n < 137.2345 -------------------------------------------------------------------------------- /HackerRank/SQL/weather-observation-station-14.sql: -------------------------------------------------------------------------------- 1 | select round(max(lat_n), 4) 2 | from station 3 | where lat_n < 137.2345 -------------------------------------------------------------------------------- /HackerRank/SQL/weather-observation-station-15.sql: -------------------------------------------------------------------------------- 1 | select round(long_w,4) 2 | from station 3 | where lat_n = ( 4 | select max(lat_n) from station where lat_n < 137.2345 5 | ) -------------------------------------------------------------------------------- /HackerRank/SQL/weather-observation-station-16.sql: -------------------------------------------------------------------------------- 1 | select round(min(lat_n), 4) 2 | from station 3 | where lat_n > 38.7780 -------------------------------------------------------------------------------- /HackerRank/SQL/weather-observation-station-17.sql: -------------------------------------------------------------------------------- 1 | select round(long_w, 4) 2 | from station 3 | where lat_n > 38.7780 4 | order by lat_n 5 | limit 1 -------------------------------------------------------------------------------- /HackerRank/SQL/weather-observation-station-18.sql: -------------------------------------------------------------------------------- 1 | select 2 | round(abs(min(lat_n)-max(lat_n)) + abs(min(long_w)-max(long_w)),4) as ans 3 | from station -------------------------------------------------------------------------------- /HackerRank/SQL/weather-observation-station-19.sql: -------------------------------------------------------------------------------- 1 | select 2 | round(sqrt( 3 | power(max(lat_n)-min(lat_n),2) + 4 | power(max(long_w)-min(long_w),2) 5 | ),4) as ans 6 | from 7 | station -------------------------------------------------------------------------------- /HackerRank/SQL/weather-observation-station-2.sql: -------------------------------------------------------------------------------- 1 | select round(sum(lat_n),2), round(sum(long_w),2) 2 | from station -------------------------------------------------------------------------------- /HackerRank/SQL/weather-observation-station-20.sql: -------------------------------------------------------------------------------- 1 | with rank_data as ( 2 | select 3 | lat_n, 4 | ROW_NUMBER() over (order by lat_n asc) as cnt, 5 | count(*) over () as total 6 | from station order by lat_n asc 7 | ) 8 | 9 | select 10 | round(src.lat_n,4) 11 | from 12 | rank_data as src 13 | where src.cnt = ( 14 | case 15 | when src.total%2=1 then (src.total+1)/2 16 | when src.total%2=0 then src.total/2 + ((src.total/2)+1)/2 17 | end 18 | ) -------------------------------------------------------------------------------- /Hackerearth/Circuits/July_circuit_2020/readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Hackerearth/Practice/A_movement.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n; 7 | cin>>n; 8 | if(n%5==0) 9 | cout<<(n/5); 10 | else 11 | cout<<(n/5)+1; 12 | } -------------------------------------------------------------------------------- /Hackerearth/Practice/Aman&Mr.Sharma.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int d,r,x,count=0; 7 | cin>>d; 8 | for(int i=0;i>r>>x; 11 | if((2*22*r)/7<=(100*x)) 12 | { 13 | count++; 14 | } 15 | } 16 | cout< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int T; 7 | cin>>T; 8 | for(int i=0;i 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int T,m,n; 8 | for(int i=0;i>m>>n; 11 | string *str=new string[m]; 12 | string **str1=new string[n][5]; 13 | 14 | } 15 | } -------------------------------------------------------------------------------- /Hackerearth/Practice/Divisible.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | long int N,number,temp=0,odd=0,even=0; 9 | string s; 10 | cin>>N; 11 | for(long int i=1;i<=N;i++) 12 | { 13 | //first digit 14 | if(i<=N/2) 15 | { 16 | cin>>s; 17 | temp=(int(s[0])-48); 18 | if(i%2==0) 19 | { 20 | even=even+temp; 21 | } 22 | else 23 | { 24 | odd=odd+temp; 25 | } 26 | } 27 | // last digit 28 | else 29 | { 30 | cin>>number; 31 | temp=number%10; 32 | if(i%2==0) 33 | { 34 | even=even+temp; 35 | } 36 | else 37 | { 38 | odd=odd+temp; 39 | } 40 | } 41 | } 42 | if((even-odd)%11==0) 43 | { 44 | cout<<"OUI"< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | ios_base::sync_with_stdio(false); 7 | cin.tie(false); 8 | cout.tie(false); 9 | long int N,temp=0; 10 | cin>>N; 11 | for(long int i=1;i<=N;i++) 12 | { 13 | cin>>temp; 14 | } 15 | 16 | if(temp%10==0) 17 | cout<<"Yes"; 18 | else 19 | cout<<"No"; 20 | } -------------------------------------------------------------------------------- /Hackerearth/Practice/Doctor's_secret.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int length,no_of_pages; 7 | cin>>length>>no_of_pages; 8 | if(length<=23&&(no_of_pages>=500&&no_of_pages<=1000)) 9 | cout<<"Take Medicine"; 10 | else 11 | cout<<"Don't take Medicine"; 12 | } -------------------------------------------------------------------------------- /Hackerearth/Practice/Duration.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int N; 7 | int a,b,c,d,result; 8 | cin>>N; 9 | for(int i=0;i>a>>b>>c>>d; 12 | result=((c*60)+d)-((a*60)+b); 13 | if(result>=60) 14 | { 15 | cout<<(result/60)<<" "<<(result%60)< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int T,X; 7 | cin>>T; 8 | for(int i=0;i>X; 11 | for(int j=0;j=k||2*X-j-1<=k) 16 | { 17 | cout<<"*"; 18 | } 19 | else 20 | cout<<"#"; 21 | } 22 | cout<<"\n"; 23 | } 24 | cout<<"\n"; 25 | } 26 | } -------------------------------------------------------------------------------- /Hackerearth/Practice/Goki_and_his_breakup.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int N,X,Y; 7 | cin>>N>>X; 8 | for(int i=0;i>Y; 11 | if(Y>=X) 12 | cout<<"YES\n"; 13 | else 14 | cout<<"NO\n"; 15 | } 16 | } -------------------------------------------------------------------------------- /Hackerearth/Practice/Ladderophilia.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n; 7 | cin>>n; 8 | for(int i=0;i 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int N; 7 | cin>>N; 8 | if(N%3==0) 9 | cout<<"YES"; 10 | else 11 | cout<<"NO"; 12 | } -------------------------------------------------------------------------------- /Hackerearth/Practice/ali_and_helping_innocent_people.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | char ch[9]; 7 | int first,second,third,forth; 8 | for(int i=0;i<9;i++) 9 | { 10 | cin>>ch[i]; 11 | } 12 | if(ch[2]=='A'||ch[2]=='E'||ch[2]=='I'||ch[2]=='O'||ch[2]=='U'||ch[2]=='Y') 13 | { 14 | cout<<"invalid"; 15 | } 16 | else 17 | { 18 | first=int(ch[0])-int(ch[1]); 19 | second=int(ch[3])-int(ch[4]); 20 | third=int(ch[4])-int(ch[5]); 21 | forth=int(ch[7])-int(ch[8]); 22 | if(first%2==0&&second%2==0&&third%2==0&&forth%2==0) 23 | { 24 | cout<<"valid"; 25 | } 26 | else 27 | { 28 | cout<<"invalid"; 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Hackerearth/Practice/anagrams.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string a,b; 8 | int t,len_a,len_b,count=0; 9 | cin>>t; 10 | for(int i=0;i>a>>b; 14 | len_a=a.length(); 15 | len_b=b.length(); 16 | for(int i=0;i 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int ar[3]; 8 | int *l; 9 | for(int i=0;i<3;i++) 10 | { 11 | cin>>ar[i]; 12 | } 13 | l=max_element(ar,ar+3); 14 | cout<<*l; 15 | } -------------------------------------------------------------------------------- /Hackerearth/Practice/birthday_party.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int T,M,N; 7 | cin>>T; 8 | for(int i=0;i>N>>M; 11 | if(M%N==0) 12 | { 13 | cout<<"Yes"< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int no,i=0,result=0,temp; 7 | cin>>no; 8 | int *array=new int[10]; 9 | while(no!=0) 10 | { 11 | temp=no%10; 12 | array[i]=temp; 13 | i++; 14 | no=no/10; 15 | } 16 | i=1; 17 | for(int j=9;j>=0;j--) 18 | { 19 | result=result+i*array[j]; 20 | i++; 21 | } 22 | if(result%11==0) 23 | { 24 | cout<<"Legal ISBN"; 25 | } 26 | else 27 | cout<<"Illegal ISBN"; 28 | } -------------------------------------------------------------------------------- /Hackerearth/Practice/bricks_game.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int N,k,temp; 8 | cin>>N; 9 | k=(-3+sqrt(9+24*N))/6; 10 | temp=N-((k*(k+1))*3)/2; 11 | if(temp==0||temp>k+1) 12 | { 13 | cout<<"Motu"< 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | ios_base::sync_with_stdio(false); 8 | cin.tie(false); 9 | cout.tie(false); 10 | string s; 11 | int len=0,sum=0; 12 | cin>>s; 13 | len=s.length(); 14 | for(int i=0;i 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int N,K; 7 | cin>>N>>K; 8 | if(k<=N) 9 | { 10 | cout<<0< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int T,cost_green,cost_purple,n; 7 | int a,b,cost=0,cost_1; 8 | cin>>T; 9 | for(int i=0;i>cost_green>>cost_purple; 13 | cin>>n; 14 | for(int j=0;j>a>>b; 17 | if(a!=0) 18 | { 19 | cost_1=cost_1+cost_purple; 20 | cost=cost+cost_green; 21 | } 22 | if(b!=0) 23 | { 24 | cost_1=cost_1+cost_green; 25 | cost=cost+cost_purple; 26 | } 27 | } 28 | cost=min(cost_1,cost); 29 | cout< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int T; 7 | // yanh pe agar ans and k ko else ke andar declare karo 8 | // ya int declare kiye to wrong dega. 9 | long int c,n,ans,k; 10 | cin>>T; 11 | for(int i=0;i>c>>n; 14 | if(c<(n*(n+1))/2) 15 | { 16 | cout< 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string s; 8 | cin>>s; 9 | int c[2]={0}; 10 | for(int i=0;i 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int N,K; 7 | cin>>N>>K; 8 | int *arr=new int[N]; 9 | for(int i=0;i>arr[i]; 12 | } 13 | cout<<"array is "; 14 | for(int i=0;i 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int N,temp; 7 | long int pro=1; 8 | cin>>N; 9 | for(int i=0;i>temp; 12 | pro = (pro*temp)%1000000007; 13 | } 14 | cout< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int N,sum=0,d; 7 | cin>>N; 8 | int *arr = new int[N]; 9 | for(int i=0;i>arr[i]; 12 | sum = sum+arr[i]; 13 | } 14 | if(sum%N==0) 15 | d=sum/N; 16 | else 17 | d=(sum/N); 18 | cout< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | long int D,oc,of,od,cs,cb,cm,cd; 7 | long int online,classic; 8 | cin>>D; 9 | cin>>oc>>of>>od; 10 | cin>>cs>>cb>>cm>>cd; 11 | online = oc + (D-of)*od; 12 | classic = cb+(D/cs)*cm+D*cd; 13 | if(classic=online) 18 | cout<<"Online Taxi"< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | cout<<"Hello Kirti"; 7 | } -------------------------------------------------------------------------------- /Hackerearth/Practice/i_am_easy.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int N; 7 | cin>>N; 8 | for(int i=1;i<=10;i++) 9 | { 10 | cout< 2 | #include 3 | using namespace std; 4 | long int hcf(long int a,long int b); 5 | 6 | int main() 7 | { 8 | long int a,b,count=0,temp; 9 | cin>>a>>b; 10 | if(a>b) 11 | { 12 | temp=a; 13 | a=b; 14 | b=temp; 15 | } 16 | temp=hcf(a,b); 17 | for(long int i=1;i<=sqrt(temp)+1;i++) 18 | { 19 | if(a%i==0 && b%i==0) 20 | { 21 | count ++; 22 | } 23 | } 24 | cout< 2 | using namespace std; 3 | int equal(int *array,int size); 4 | 5 | 6 | int main() 7 | { 8 | int n,count=1000; 9 | cin>>n; 10 | int *a=new int[n]; 11 | int *b=new int[n]; 12 | for(int i=0;i>a[i]; 15 | } 16 | for(int i=0;i>b[i]; 19 | } 20 | while(equal(a,n)!=1) 21 | { 22 | count--; 23 | for(int i=0;i=b[i]) 26 | { 27 | a[i]=a[i]-b[i]; 28 | } 29 | } 30 | } 31 | cout<<(1000-count); 32 | } 33 | 34 | int equal(int *array,int size) 35 | { 36 | int count=0; 37 | for(int i=0;i 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int no,count=0; 7 | cin>>no; 8 | for(int i=2;i<=no;i++) 9 | { 10 | count =0; 11 | for(int j=2;j<=i/2;j++) 12 | { 13 | if(i%j==0) 14 | { 15 | count++; 16 | } 17 | } 18 | if(count==0) 19 | { 20 | cout< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int L,N,W,H; 7 | cin>>L>>N; 8 | for(int i=0;i>W>>H; 11 | if(W>=L&&H>=L) 12 | { 13 | if(W==H) 14 | { 15 | cout<<"ACCEPTED"< 2 | using namespace std; 3 | #include 4 | 5 | 6 | int main() 7 | { 8 | int t,N,z=0; 9 | int *arr=new int[31]; 10 | for(int i=0;i<=30;i++) 11 | { 12 | arr[i]=(pow(2,i)-1); 13 | } 14 | cin>>t; 15 | for(int i=0;i>N; 18 | int previous; 19 | for(int j=0;j<30;j++) 20 | { 21 | previous=arr[j]; 22 | if(N 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n,flag=0; 7 | cin>>n; 8 | char *ch=new char[n]; 9 | cin>>ch; 10 | for(int i=0;i 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string n; 8 | int len=0,j; 9 | cin>>n; 10 | len=n.length(); 11 | for(int i=0;i=97&&j<=122) 15 | { 16 | j=j-32; 17 | n[i]=char(j); 18 | } 19 | else if(j>=65&&j<=90) 20 | { 21 | j=j+32; 22 | n[i]=char(j); 23 | } 24 | } 25 | cout< 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int T; 8 | long int len,count; 9 | string a,b; 10 | cin>>T; 11 | for(int i=0;i>a>>b; 15 | len=a.length(); 16 | for(int j=0;j 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | int len=0,c_z=0,c_o=0; 9 | string str; 10 | cin>>str; 11 | len = str.length(); 12 | for(int i=0;i bit(32, 0); 19 | int ans = 0; 20 | int pos = 0; 21 | while (n) 22 | { 23 | if (n & 1) 24 | { 25 | bit[pos] = 1; 26 | } 27 | n >>= 1; 28 | pos++; 29 | } 30 | for (ll i = 0; i < pos; i++) 31 | { 32 | ans += (1 - bit[i]) * pow(2, i); 33 | } 34 | return ans; 35 | } 36 | }; 37 | -------------------------------------------------------------------------------- /LeetCode/1025.Divisor_Game.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool divisorGame(int N) { 4 | if(N&1) 5 | return false; 6 | else 7 | return true; 8 | } 9 | }; -------------------------------------------------------------------------------- /LeetCode/1146.Snapshot Array.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class SnapshotArray 12 | { 13 | private: 14 | int snapId; 15 | map> data; 16 | 17 | public: 18 | SnapshotArray(int length) 19 | { 20 | snapId = 0; 21 | data = map>(); 22 | } 23 | 24 | void set(int index, int val) 25 | { 26 | data[index][snapId] = val; 27 | } 28 | 29 | int snap() 30 | { 31 | return snapId++; 32 | } 33 | 34 | int get(int index, int snap_id) 35 | { 36 | auto it = data[index].upper_bound(snap_id); 37 | if (it == data[index].begin()) 38 | { 39 | return 0; 40 | } 41 | return prev(it)->second; 42 | } 43 | }; -------------------------------------------------------------------------------- /LeetCode/120.Triangle.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int minimumTotal(vector>& triangle) { 4 | int n=triangle.size(); 5 | vector> dp(n,vector(n,0)); 6 | for(int i=n-1;i>=0;i--) 7 | { 8 | for(int j=0;j<=i;j++) 9 | { 10 | if(i==n-1) 11 | dp[i][j]=triangle[i][j]; 12 | else 13 | dp[i][j]=min(dp[i+1][j+1],dp[i+1][j])+triangle[i][j]; 14 | } 15 | } 16 | return dp[0][0]; 17 | } 18 | }; -------------------------------------------------------------------------------- /LeetCode/121.Best_Time_to_Buy_and_Sell_Stock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | int maxProfit(vector &prices) 15 | { 16 | if (prices.size() < 2) 17 | return 0; 18 | int mini = prices[0]; 19 | int n = prices.size(); 20 | int maxo = 0; 21 | for (int i = 1; i < n; i++) 22 | { 23 | int diff = prices[i] - mini; 24 | maxo = max(diff, maxo); 25 | mini = min(mini, prices[i]); 26 | } 27 | return maxo; 28 | } 29 | }; -------------------------------------------------------------------------------- /LeetCode/1218.Longest Arithmetic Subsequence of Given Difference.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | int longestSubsequence(vector &arr, int difference) 15 | { 16 | int longest = 0; 17 | unordered_map dp; // Map to store the length of subsequence ending at each element 18 | 19 | for (int num : arr) 20 | { 21 | dp[num] = dp[num - difference] + 1; // Increment the length by 1 22 | 23 | longest = max(longest, dp[num]); // Update the longest length 24 | } 25 | 26 | return longest; 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /LeetCode/1310.XOR Queries of a Subarray.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | vector xorQueries(vector &arr, vector> &queries) 15 | { 16 | vector ans(queries.size()); 17 | int n=arr.size(); 18 | vector pref_xor(n,arr[0]); 19 | 20 | for(int i=1;i> &grid) 15 | { 16 | int cnt = 0; 17 | int n = grid.size(); 18 | int m = grid[0].size(); 19 | int column = n - 1, row = 0; 20 | while (row < m && column >= 0) 21 | { 22 | if (grid[column][row] < 0) 23 | { 24 | cnt += (m - row); 25 | column--; 26 | } 27 | else 28 | row++; 29 | } 30 | return cnt; 31 | } 32 | }; -------------------------------------------------------------------------------- /LeetCode/1400.Construct K Palindrome Strings.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll; 6 | const ll INF = 1e18; 7 | const ll mod1 = 1e9 + 7; 8 | const ll mod2 = 998244353; 9 | // Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | bool canConstruct(string s, int k) 15 | { 16 | vector v(26,0); 17 | int n = s.size(); 18 | for (auto x : s) 19 | { 20 | v[x-'a']++; 21 | } 22 | int odd = 0, even = 0; 23 | for (auto x : v) 24 | { 25 | odd += (x % 2); 26 | even += (x / 2); 27 | } 28 | k-=odd; 29 | return k>=0 && k<=2*even; 30 | } 31 | }; 32 | -------------------------------------------------------------------------------- /LeetCode/1422.Maximum Score After Splitting a String.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll; 6 | const ll INF = 1e18; 7 | const ll mod1 = 1e9 + 7; 8 | const ll mod2 = 998244353; 9 | // Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | int maxScore(string s) 15 | { 16 | int sum = 0, zero = 0, ans = 0; 17 | for (auto x : s) 18 | { 19 | sum += (x - '0'); 20 | } 21 | for (int i = 0; i < s.size() - 1; i++) 22 | { 23 | zero += (s[i] == '0'); 24 | sum -= (s[i] - '0'); 25 | ans = max(sum + zero, ans); 26 | } 27 | return ans; 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /LeetCode/1431.Kids With the Greatest Number of Candies.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | vector kidsWithCandies(vector &candies, int extraCandies) 15 | { 16 | vector ans; 17 | int maxo=0; 18 | for(auto x:candies){ 19 | maxo=max(maxo,x); 20 | } 21 | for(auto x:candies){ 22 | if(x+extraCandies>=maxo){ 23 | ans.push_back(true); 24 | } 25 | else{ 26 | ans.push_back(false); 27 | } 28 | } 29 | return ans; 30 | } 31 | }; -------------------------------------------------------------------------------- /LeetCode/152.Maximum_Product_Subarray.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int maxProduct(vector& nums) { 4 | int maxo=nums[0],mini=nums[0]; 5 | int ans=nums[0]; 6 | for(int i=1;i &neededTime) 15 | { 16 | int ans = 0; 17 | for(int i=0;i pq; 20 | int j = i; 21 | while (j < colors.size() && colors[j] == colors[i]) 22 | { 23 | sum += neededTime[j]; 24 | pq.push(neededTime[j]); 25 | j++; 26 | } 27 | i = j - 1; 28 | ans += (sum - pq.top()); 29 | } 30 | return ans; 31 | } 32 | }; -------------------------------------------------------------------------------- /LeetCode/1608.Special Array With X Elements Greater Than Or Equal X.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll; 6 | const ll INF = 1e18; 7 | const ll mod1 = 1e9 + 7; 8 | const ll mod2 = 998244353; 9 | // Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | int specialArray(vector &nums) 15 | { 16 | int n = nums.size(); 17 | sort(nums.begin(), nums.end()); 18 | for (int i = 0; i <= n; i++) 19 | { 20 | auto it = lower_bound(nums.begin(), nums.end(), i); 21 | int pos = nums.end() - it; 22 | if (pos == i) 23 | { 24 | return i; 25 | } 26 | } 27 | return -1; 28 | } 29 | }; -------------------------------------------------------------------------------- /LeetCode/167.Two_sumII_Input_array_is_sorted.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | vector twoSum(vector& nums, int target) 4 | { 5 | vector v(2,0); 6 | int i=0,j=nums.size()-1; 7 | while(j>i) 8 | { 9 | int temp=nums[i]+nums[j]; 10 | if(temp>target) 11 | { 12 | j--; 13 | } 14 | else if(temp& nums, int k) { 4 | map m; 5 | int count=0; 6 | for(auto x:nums) 7 | { 8 | if(m[k-x]>0) 9 | { 10 | m[k-x]--; 11 | count++; 12 | } 13 | else 14 | m[x]++; 15 | } 16 | return count; 17 | } 18 | }; -------------------------------------------------------------------------------- /LeetCode/168.Excel Sheet Column Title.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | string convertToTitle(int columnNumber) 15 | { 16 | string ans=""; 17 | while (columnNumber) 18 | { 19 | columnNumber--; 20 | ans = ans + (char)((columnNumber) % 26 + 'A'); 21 | columnNumber = columnNumber / 26; 22 | } 23 | reverse(ans.begin(), ans.end()); 24 | return ans; 25 | } 26 | }; -------------------------------------------------------------------------------- /LeetCode/1680.Concatenation_of_Consecutive_Binary_Numbers.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int log2(int n){ 4 | int res=1; 5 | while(n>0) { 6 | res*=2; 7 | n>>=1; 8 | } 9 | return res; 10 | } 11 | int concatenatedBinary(int n) { 12 | long long mod=pow(10,9)+7; 13 | long long num=0; 14 | for(int i=1;i<=n;i++){ 15 | num=num*log2(i)+i; 16 | // cout<<"num is "<& nums) { 4 | map m; 5 | int ans=0; 6 | for(int i=0;i &gain) 15 | { 16 | int maxo=0,sum=0; 17 | for(auto x:gain){ 18 | sum+=x; 19 | maxo=max(maxo,sum); 20 | } 21 | return maxo; 22 | } 23 | }; -------------------------------------------------------------------------------- /LeetCode/1750. Minimum Length of String After Deleting Similar Ends.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll; 6 | const ll INF = 1e18; 7 | const ll mod1 = 1e9 + 7; 8 | const ll mod2 = 998244353; 9 | // Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | int minimumLength(string str) 15 | { 16 | int s = 0, e = str.size() - 1; 17 | while (s < e) 18 | { 19 | if (str[s] == str[e]) 20 | { 21 | while (str[s] == str[s + 1] && s < e) 22 | s++; 23 | while (str[e] == str[e - 1] && s < e) 24 | e--; 25 | s++; 26 | e--; 27 | } 28 | else 29 | break; 30 | } 31 | int ans = e - s + 1; 32 | if (ans < 0) 33 | return 0; 34 | return ans; 35 | } 36 | }; 37 | -------------------------------------------------------------------------------- /LeetCode/1750.Minimum_Length_of_String_After_Deletion_Similar_Ends.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll; 6 | const ll INF = 1e18; 7 | const ll mod1 = 1e9 + 7; 8 | const ll mod2 = 998244353; 9 | // Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | int minimumLength(string s) 15 | { 16 | int left = 0, right = s.size() - 1; 17 | 18 | while ((left < right) and s[left] == s[right]) 19 | { 20 | char ch = s[left]; 21 | while ((left <= right) and s[left] == ch) 22 | { 23 | left += 1; 24 | } 25 | while ((right >= left) and s[right] == ch) 26 | { 27 | right -= 1; 28 | } 29 | } 30 | return right - left + 1; 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /LeetCode/1753.Maximum_Score_From_Removing_Stones.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int maximumScore(int a, int b, int c) { 4 | int maxo=max({a,b,c}); 5 | if((2*maxo)>(a+b+c)) 6 | return (a+b+c)-maxo; 7 | else 8 | return (a+b+c)/2; 9 | } 10 | }; -------------------------------------------------------------------------------- /LeetCode/179.Largest Number.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | 15 | string largestNumber(vector &nums) 16 | { 17 | vector s(nums.size(),""); 18 | string ans=""; 19 | 20 | for(int i=0;ib+a; 25 | }); 26 | if(s[0]=="0"){ 27 | ans="0"; 28 | } 29 | else{ 30 | for(auto x:s){ 31 | ans+=x; 32 | } 33 | } 34 | return ans; 35 | } 36 | }; 37 | -------------------------------------------------------------------------------- /LeetCode/1790.Check_if_One_String_Swap_Can_Make_Strings_Equal.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool areAlmostEqual(string s1, string s2) { 4 | vector pos; 5 | for(int i=0;i>& edges) { 4 | map m; 5 | int n=edges.size(); 6 | for(int i=0;i pdi; 4 | 5 | double calc(vectorcls){ 6 | return 1.0*(cls[0]+1)/(cls[1]+1)-1.0*cls[0]/cls[1]; 7 | } 8 | 9 | double maxAverageRatio(vector>& classes, int extraStudents) { 10 | int n=classes.size(); 11 | priority_queue hp; 12 | for(int i=0;i& a, int k) { 4 | int n = a.size(); 5 | for(int i = k-1;i >= 0;i--){ 6 | a[i] = min(a[i], a[i+1]); 7 | } 8 | for(int i = k+1;i < n;i++){ 9 | a[i] = min(a[i], a[i-1]); 10 | } 11 | int ans = 0; 12 | int l = k, r = k; 13 | for(int v = a[k];v >= 1;v--){ 14 | while(l-1 >= 0 && a[l-1] >= v)l--; 15 | while(r+1 < n && a[r+1] >= v)r++; 16 | ans = max(ans, (r-l+1) * v); 17 | } 18 | return ans; 19 | } 20 | }; -------------------------------------------------------------------------------- /LeetCode/1804B-Vaccination.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | 9 | int solve() 10 | { 11 | int n,k,d,w; 12 | cin>>n>>k>>d>>w; 13 | 14 | vector t(n); 15 | for (int i = 0; i < n; i++) 16 | { 17 | cin >> t[i]; 18 | } 19 | int when = -1; 20 | int cnt = 0; 21 | int ans = 0; 22 | 23 | for (int i = 0; i < n; i++) 24 | { 25 | if (t[i] <= when + d && cnt > 0) 26 | { 27 | cnt -= 1; 28 | } 29 | else 30 | { 31 | when = t[i] + w; 32 | cnt = k - 1; 33 | ans += 1; 34 | } 35 | } 36 | cout << ans << endl; 37 | return 0; 38 | } 39 | int main() 40 | { 41 | int testCase = 1; 42 | cin >> testCase; 43 | while (testCase--) 44 | { 45 | solve(); 46 | } 47 | return 0; 48 | } -------------------------------------------------------------------------------- /LeetCode/1812.Determine_Color_of_a_Chessboard_Square.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool squareIsWhite(string coordinates) { 4 | string s=coordinates; 5 | 6 | if((s[0]=='a'||s[0]=='c'||s[0]=='e'||s[0]=='g')){ 7 | int d=s[1]-'0'; 8 | if(d&1) 9 | return false; 10 | else 11 | return true; 12 | } 13 | else{ 14 | int d=s[1]-'0'; 15 | if(d&1) 16 | return true; 17 | else 18 | return false; 19 | } 20 | } 21 | }; -------------------------------------------------------------------------------- /LeetCode/1819.Number_of_Different_Subsequences_GCDs.cpp: -------------------------------------------------------------------------------- 1 | const int maxo=200006; 2 | 3 | 4 | class Solution { 5 | public: 6 | int countDifferentSubsequenceGCDs(vector& nums) { 7 | int ans=0; 8 | vector check(maxo,false); 9 | for(auto x:nums) 10 | check[x]=true; 11 | for(int i=1;i 0) 20 | { 21 | x += (n % 2) << (31 - d); 22 | n >>= 1; 23 | d++; 24 | } 25 | return x; 26 | } 27 | }; -------------------------------------------------------------------------------- /LeetCode/198.House_Robber.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int rob(vector& nums) { 4 | int n=nums.size(); 5 | vector dp(n+1,0); 6 | if(n==0) 7 | return 0; 8 | else if(n==1) 9 | return nums[0]; 10 | else if(n==2) 11 | return max(nums[0],nums[1]); 12 | else 13 | { 14 | dp[0]=nums[0]; 15 | dp[1]=max(nums[0],nums[1]); 16 | for(int i=2;i missingRolls(vector &rolls, int mean, int n) 15 | { 16 | int m = rolls.size(); 17 | int sum = mean * (n + m); 18 | for (auto x : rolls) 19 | { 20 | sum -= x; 21 | } 22 | int a = sum / n, b = sum % n; 23 | vector ans(n, a), temp; 24 | if (sum > 6 * n || sum < n) 25 | { 26 | return temp; 27 | } 28 | for (int i = 0; i < b; i++) 29 | { 30 | ans[i]++; 31 | } 32 | return ans; 33 | } 34 | }; 35 | -------------------------------------------------------------------------------- /LeetCode/204-Count_Primes.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int countPrimes(int n) { 4 | int count=0; 5 | vector prime(n+1,0); 6 | for(int i=2;i*i &nums) 15 | { 16 | int n = nums.size(); 17 | int minLength = INT_MAX; 18 | int left = 0; 19 | int sum = 0; 20 | 21 | for (int right = 0; right < n; right++) 22 | { 23 | sum += nums[right]; 24 | 25 | while (sum >= target) 26 | { 27 | minLength = min(minLength, right - left + 1); 28 | sum -= nums[left]; 29 | left++; 30 | } 31 | } 32 | 33 | return (minLength != INT_MAX) ? minLength : 0; 34 | } 35 | }; 36 | -------------------------------------------------------------------------------- /LeetCode/2090.K Radius Subarray Averages.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll; 6 | const ll INF = 1e18; 7 | const ll mod1 = 1e9 + 7; 8 | const ll mod2 = 998244353; 9 | // Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | vector getAverages(vector &nums, int k) 15 | { 16 | int n = nums.size(); 17 | vector ans(n, -1); 18 | long long sum = 0; 19 | if (n < 2 * k) 20 | { 21 | return ans; 22 | } 23 | for (int i = 0; i < 2 * k; i++) 24 | { 25 | sum += nums[i]; 26 | } 27 | for (int i = 2 * k; i < n; i++) 28 | { 29 | sum += nums[i]; 30 | int average = (sum) / (2 * k + 1); 31 | ans[i - k] = average; 32 | sum -= nums[i - 2 * k]; 33 | } 34 | return ans; 35 | } 36 | }; -------------------------------------------------------------------------------- /LeetCode/2125.Number_of_Laser_Beams_in_a_Bank.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll; 6 | const ll INF = 1e18; 7 | const ll mod1 = 1e9 + 7; 8 | const ll mod2 = 998244353; 9 | // Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | int numberOfBeams(vector &bank) 15 | { 16 | int ans = 0; 17 | int previous = 0; 18 | for (int i = 0; i < bank.size(); i++) 19 | { 20 | int count = 0; 21 | for (int j = 0; j < bank[i].size(); j++) 22 | { 23 | if (bank[i][j] == '1') 24 | { 25 | count++; 26 | } 27 | } 28 | if (count) 29 | { 30 | ans += previous * count; 31 | previous = count; 32 | } 33 | } 34 | return ans; 35 | } 36 | }; 37 | -------------------------------------------------------------------------------- /LeetCode/2149.Rearrange_Array_Elements_by_Sign.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll; 6 | const ll INF = 1e18; 7 | const ll mod1 = 1e9 + 7; 8 | const ll mod2 = 998244353; 9 | // Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | vector rearrangeArray(vector &nums) 15 | { 16 | int pos = 0, neg = 1; 17 | int n = nums.size(); 18 | assert(n % 2 == 0); 19 | vector ans(n, 0); 20 | for (auto x : nums) 21 | { 22 | if (x > 0) 23 | { 24 | ans[pos] = x; 25 | pos += 2; 26 | } 27 | else 28 | { 29 | ans[neg] = x; 30 | neg += 2; 31 | } 32 | } 33 | return ans; 34 | } 35 | }; -------------------------------------------------------------------------------- /LeetCode/215.Kth Largest Element in an Array.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution { 12 | public: 13 | int findKthLargest(vector& nums, int k) { 14 | priority_queue pq(nums.begin(), nums.end()); 15 | for(int i = 0; i < k-1; ++i) pq.pop(); 16 | return pq.top(); 17 | } 18 | }; -------------------------------------------------------------------------------- /LeetCode/221-Maximal_Square.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int maximalSquare(vector>& matrix) { 4 | int m=matrix[0].size(); 5 | int n=matrix.size(); 6 | vector> dp(n+1,vector(m+1,0)); 7 | int ans=0; 8 | for(int i=1;i<=n;i++) 9 | { 10 | for(int j=1;j<=m;j++) 11 | { 12 | if(matrix[i-1][j-1]=='1') 13 | { 14 | dp[i][j]=1+min({dp[i-1][j],dp[i][j-1],dp[i-1][j-1]}); 15 | ans=max(ans,dp[i][j]); 16 | } 17 | else 18 | dp[i][j]=0; 19 | } 20 | } 21 | return ans*ans; 22 | } 23 | }; -------------------------------------------------------------------------------- /LeetCode/231.Power_of_Two.cpp: -------------------------------------------------------------------------------- 1 | // approach 1 2 | class Solution 3 | { 4 | public: 5 | bool isPowerOfTwo(int n) 6 | { 7 | if (n <= 0) 8 | return false; 9 | while (n > 1) 10 | { 11 | if (n & 1) 12 | { 13 | return false; 14 | } 15 | n >>= 1; 16 | } 17 | return true; 18 | } 19 | }; 20 | 21 | // approach 2 22 | 23 | // class Solution 24 | // { 25 | // public: 26 | // bool isPowerOfTwo(int n) 27 | // { 28 | // if (n <= 0) 29 | // return false; 30 | // // int temp=log2(n); 31 | // // temp=pow(2,temp); 32 | // // return temp==n; 33 | // int largest = pow(2, 31); 34 | // return largest % n == 0; 35 | // } 36 | // }; -------------------------------------------------------------------------------- /LeetCode/2466.Count Ways to Build Good Strings.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | int countGoodStrings(int low, int high, int zero, int one) 15 | { 16 | vector v(high+1,0); 17 | v[0]=1; // for empty string 18 | for(int i=1;i<=high;i++){ 19 | if(i-zero>=0){ 20 | v[i]+=v[i-zero]; 21 | v[i]%=mod1; 22 | } 23 | if(i-one>=0){ 24 | v[i]+=v[i-one]; 25 | v[i]%=mod1; 26 | } 27 | } 28 | ll ans=0; 29 | for(int i=low;i<=high;i++){ 30 | ans+=v[i]; 31 | ans%=mod1; 32 | } 33 | return ans; 34 | } 35 | }; 36 | -------------------------------------------------------------------------------- /LeetCode/2520. Count the Digits That Divide a Number.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | int countDigits(int num) 15 | { 16 | int count=0; 17 | int temp=num; 18 | while(temp){ 19 | int d=temp%10; 20 | if(!(num%d)){ 21 | count++; 22 | } 23 | temp/=10; 24 | } 25 | return count; 26 | } 27 | }; -------------------------------------------------------------------------------- /LeetCode/2527.Find Xor-Beauty of Array.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | int xorBeauty(vector &nums) 15 | { 16 | int ans=0; 17 | for(auto x:nums){ 18 | ans^=x; 19 | } 20 | return ans; 21 | } 22 | }; -------------------------------------------------------------------------------- /LeetCode/2529. Maximum Count of Positive Integer and Negative Integer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | int maximumCount(vector &nums) 15 | { 16 | int pos=0,neg=0,maxo=0; 17 | for(auto x:nums){ 18 | if(x>0){ 19 | pos++; 20 | } 21 | else if(x<0){ 22 | neg++; 23 | } 24 | maxo=max({maxo,pos,neg}); 25 | } 26 | return maxo; 27 | } 28 | }; -------------------------------------------------------------------------------- /LeetCode/2530. Maximal Score After Applying K Operations.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | long long maxKelements(vector &nums, int k) 15 | { 16 | // max heap 17 | priority_queue pq; 18 | for (int i = 0; i < nums.size(); i++) 19 | { 20 | pq.push(nums[i]); 21 | } 22 | long long ans = 0; 23 | while(k--){ 24 | int temp=pq.top(); 25 | pq.pop(); 26 | ans+=temp; 27 | pq.push((temp+2)/3); 28 | } 29 | return ans; 30 | } 31 | }; -------------------------------------------------------------------------------- /LeetCode/2545. Sort the Students by Their Kth Score.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll; 6 | const ll INF = 1e18; 7 | const ll mod1 = 1e9 + 7; 8 | const ll mod2 = 998244353; 9 | // Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | vector> sortTheStudents(vector> &score, int k) 15 | { 16 | sort(begin(score), end(score), [&](vector a, vector b) 17 | { return a[k] > b[k]; }); 18 | return score; 19 | } 20 | }; -------------------------------------------------------------------------------- /LeetCode/2546. Apply Bitwise Operations to Make Strings Equal.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | bool makeStringsEqual(string s, string target) 15 | { 16 | int one1=0,one2=0; 17 | one1=count(s.begin(),s.end(),'1'); 18 | one2=count(target.begin(),target.end(),'1'); 19 | if(one1==0 || one2==0){ 20 | return s==target; 21 | } 22 | else{ 23 | return true; 24 | } 25 | } 26 | }; -------------------------------------------------------------------------------- /LeetCode/2551.Put Marbles in Bags.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | long long putMarbles(vector &weights, int k) 15 | { 16 | vector store; 17 | for (int i = 1; i < weights.size(); i++) 18 | { 19 | store.push_back(weights[i] + weights[i - 1]); 20 | } 21 | sort(store.begin(), store.end()); 22 | int n = store.size(); 23 | long long mini = 0; 24 | for (int i = 0; i < k - 1; i++) 25 | { 26 | mini += store[i]; 27 | } 28 | 29 | long long maxi = 0; 30 | for (int i = 0; i < k - 1; i++) 31 | { 32 | maxi += store[n - 1 - i]; 33 | } 34 | return maxi - mini; 35 | } 36 | }; -------------------------------------------------------------------------------- /LeetCode/2553. Separate the Digits in an Array.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | vector separateDigits(vector &nums) 15 | { 16 | vector ans; 17 | for(auto x:nums) 18 | { 19 | vector temp; 20 | while(x>0) 21 | { 22 | temp.push_back(x%10); 23 | x/=10; 24 | } 25 | reverse(temp.begin(),temp.end()); 26 | for(auto y:temp) 27 | ans.push_back(y); 28 | } 29 | return ans; 30 | } 31 | }; -------------------------------------------------------------------------------- /LeetCode/2554. Maximum Number of Integers to Choose From a Range I.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | int maxCount(vector &banned, int n, int maxSum) 15 | { 16 | map m; 17 | for (int i = 0; i < banned.size(); i++) 18 | { 19 | m[banned[i]]++; 20 | } 21 | int count = 0; 22 | for(int i=1;i<=n;i++){ 23 | if(m[i]==0){ 24 | if(i<=maxSum){ 25 | count++; 26 | maxSum-=i; 27 | } 28 | } 29 | } 30 | return count; 31 | } 32 | }; -------------------------------------------------------------------------------- /LeetCode/2555. Maximize Win From Two Segments.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll; 6 | const ll INF = 1e18; 7 | const ll mod1 = 1e9 + 7; 8 | const ll mod2 = 998244353; 9 | // Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | int maximizeWin(vector &prizePositions, int k) 15 | { 16 | int res = 0, n = prizePositions.size(), j = 0; 17 | vector dp(n + 1, 0); 18 | for (int i = 0; i < n; ++i) 19 | { 20 | while (prizePositions[i]-prizePositions[j] > k) 21 | ++j; 22 | dp[i + 1] = max(dp[i], i - j + 1); 23 | res = max(res, i - j + 1 + dp[j]); 24 | } 25 | 26 | return res; 27 | } 28 | }; -------------------------------------------------------------------------------- /LeetCode/2558. Take Gifts From the Richest Pile.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | long long pickGifts(vector &gifts, int k) 15 | { 16 | priority_queue pq(gifts.begin(), gifts.end()); 17 | while (k--) 18 | { 19 | int x2 = pq.top(); 20 | pq.pop(); 21 | int x = sqrt(x2); 22 | pq.push(x); 23 | } 24 | long long ans = 0; 25 | while (pq.size()) 26 | { 27 | ans += pq.top(); 28 | pq.pop(); 29 | } 30 | return ans; 31 | } 32 | }; -------------------------------------------------------------------------------- /LeetCode/2566.Maximum Difference by Remapping a Digit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | int minMaxDifference(int num) 15 | { 16 | vector v; 17 | string s=to_string(num); 18 | for(int i=0;i<=9;i++){ 19 | for(int j=0;j<=9;j++){ 20 | string temp=to_string(num); 21 | for(int k=0;k &nums) 15 | { 16 | sort(nums.begin(), nums.end()); 17 | int n = nums.size(); 18 | int ans = min(nums[n - 1] - nums[2], nums[n - 3] - nums[0]); 19 | ans = min(ans, nums[n - 2] - nums[1]); 20 | 21 | return ans; 22 | } 23 | }; -------------------------------------------------------------------------------- /LeetCode/2568.Minimum Impossible OR.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | int minImpossibleOR(vector &nums) 15 | { 16 | set S; 17 | for (auto &&i : nums) 18 | { 19 | S.emplace(i); 20 | } 21 | int ans = 1; 22 | while (S.count(ans)) 23 | ans *= 2; 24 | return ans; 25 | } 26 | }; -------------------------------------------------------------------------------- /LeetCode/2575.Find the Divisibility Array of a String.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | vector divisibilityArray(string word, int m) 15 | { 16 | vector ans; 17 | long val = 0; 18 | for (auto &c : word) 19 | { 20 | val = (10 * val + (c - '0')) % m; 21 | if (val == 0) 22 | ans.push_back(1); 23 | else 24 | ans.push_back(0); 25 | } 26 | return ans; 27 | } 28 | }; -------------------------------------------------------------------------------- /LeetCode/2576.Find the Maximum Number of Marked Indices.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | int maxNumOfMarkedIndices(vector &v) 15 | { 16 | sort(v.begin(), v.end()); 17 | int i = 0, n = v.size(), j = n / 2, cnt = 0; 18 | while (i < n / 2 && j < n) 19 | { 20 | if (v[i] * 2 <= v[j]) 21 | { 22 | i++; 23 | j++; 24 | cnt += 2; 25 | } 26 | else 27 | j++; 28 | } 29 | return cnt; 30 | } 31 | }; -------------------------------------------------------------------------------- /LeetCode/2579. Count Total Number of Colored Cells.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | long long coloredCells(int n) 15 | { 16 | long long N=n; 17 | return (long long)(N*(N-1))*2+1; 18 | } 19 | }; -------------------------------------------------------------------------------- /LeetCode/2586.Count the Number of Vowel Strings in Range.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | bool isVowel(char ch){ 15 | if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u'){ 16 | return true; 17 | } 18 | return false; 19 | } 20 | 21 | 22 | int vowelStrings(vector &words, int left, int right) 23 | { 24 | int ans = 0; 25 | for (int i = left; i <= right; i++) 26 | { 27 | if(isVowel(words[i].front()) && isVowel(words[i].back())){ 28 | ans++; 29 | } 30 | } 31 | return ans; 32 | } 33 | }; -------------------------------------------------------------------------------- /LeetCode/2587.Rearrange Array to Maximize Prefix Score.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | int maxScore(vector &nums) 15 | { 16 | sort(nums.rbegin(), nums.rend()); 17 | int ans = 0; 18 | long long sum = 0; 19 | for (auto v : nums) 20 | { 21 | sum += v; 22 | if (sum > 0) 23 | ans++; 24 | } 25 | return ans; 26 | } 27 | }; -------------------------------------------------------------------------------- /LeetCode/2588.Count the Number of Beautiful Subarrays.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | long long beautifulSubarrays(vector &nums) 15 | { 16 | map seen; 17 | seen[0]++; 18 | long long ans = 0; 19 | int sum = 0; 20 | for (int v : nums) 21 | { 22 | sum ^= v; 23 | ans += seen[sum]; 24 | seen[sum]++; 25 | } 26 | return ans; 27 | } 28 | }; -------------------------------------------------------------------------------- /LeetCode/26.Remove_Duplicates_from_Sorted_Array.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int removeDuplicates(vector& nums) { 4 | if(nums.size()==0) 5 | return 0; 6 | int pos=1; 7 | for(int i=0;i= k) 18 | { 19 | return k; 20 | } 21 | else{ 22 | ans = numOnes; 23 | k -= numOnes; 24 | if(numZeros>=k){ 25 | return ans; 26 | } 27 | else{ 28 | k-=numZeros; 29 | ans-=k; 30 | return ans; 31 | } 32 | } 33 | } 34 | }; -------------------------------------------------------------------------------- /LeetCode/2610.Convert an Array Into a 2D Array With Conditions.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | vector> findMatrix(vector &nums) 15 | { 16 | map mp; 17 | for (int x : nums){ 18 | ++mp[x]; 19 | } 20 | int maxo = 0; 21 | for (auto &[element, freq] : mp){ 22 | maxo = max(maxo, freq); 23 | } 24 | vector> a(maxo); 25 | for (auto &[element, freq] : mp) 26 | { 27 | for (int i = 0; i < freq; i++) 28 | { 29 | a[i].push_back(element); 30 | } 31 | } 32 | return a; 33 | } 34 | }; -------------------------------------------------------------------------------- /LeetCode/263-Ugly_Number.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool isUgly(int num) { 4 | if(num==0) 5 | return false; 6 | while(num%2==0){ 7 | num/=2; 8 | } 9 | while(num%3==0){ 10 | num/=3; 11 | } 12 | while(num%5==0){ 13 | num/=5; 14 | } 15 | if(num==1) 16 | return true; 17 | else 18 | return false; 19 | } 20 | }; -------------------------------------------------------------------------------- /LeetCode/2639.Find the Width of Columns of a Grid.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | vector findColumnWidth(vector> &grid) 15 | { 16 | vector ans; 17 | int n=grid.size(); 18 | int m=grid[0].size(); 19 | for(int j=0;j v(n); 7 | v[0]=1; 8 | int num=1; 9 | while(num findPrefixScore(vector &nums) 15 | { 16 | vector ans; 17 | long long maxo=0; 18 | for(int i=0;i& nums, int val) { 4 | int pos=0; 5 | for(int i=0;i &dictionary) 15 | { 16 | int n = s.size(); 17 | vector dp(n + 1, n); 18 | dp[0] = 0; 19 | for (int i = 0; i < n; i += 1) 20 | { 21 | for (auto t : dictionary) 22 | { 23 | if (s.substr(i, t.size()) == t) 24 | { 25 | dp[i + t.size()] = min(dp[i + t.size()], dp[i]); 26 | } 27 | } 28 | dp[i + 1] = min(dp[i + 1], dp[i] + 1); 29 | } 30 | return dp.back(); 31 | } 32 | }; -------------------------------------------------------------------------------- /LeetCode/2708.Maximum Strength of a Group.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | long long maxStrength(vector &nums) 15 | { 16 | long long ans = nums[0]; 17 | for (int i = 1; i < (1 << nums.size()); i += 1) 18 | { 19 | long long pans = 1; 20 | for (int j = 0; j < nums.size(); j += 1) 21 | { 22 | if ((i >> j) & 1) 23 | { 24 | pans = pans * nums[j]; 25 | } 26 | } 27 | ans = max(ans, pans); 28 | } 29 | return ans; 30 | } 31 | }; -------------------------------------------------------------------------------- /LeetCode/2712.Minimum Cost to Make All Characters Equal.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | long long minimumCost(string s) 15 | { 16 | long long ans = 0; 17 | for (int i = 0; i + 1 < s.size(); i++) 18 | { 19 | if (s[i] != s[i + 1]) 20 | { 21 | ans += min(i + 1, (int)s.size() - i - 1); 22 | } 23 | } 24 | return ans; 25 | } 26 | }; -------------------------------------------------------------------------------- /LeetCode/2740.Find the Value of the Partition.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | int findValueOfPartition(vector &nums) 15 | { 16 | int mini=INT_MAX; 17 | sort(nums.begin(),nums.end()); 18 | for(int i=1;i &nums) 14 | { 15 | set s; 16 | for (int num : nums) 17 | { 18 | s.insert(num); 19 | } 20 | int count = 0; 21 | for (int i = 0; i < nums.size(); i++) 22 | { 23 | set temp; 24 | for (int j = i; j < nums.size(); j++) 25 | { 26 | temp.insert(nums[j]); 27 | count += temp.size() == s.size(); 28 | } 29 | } 30 | return count; 31 | } 32 | }; -------------------------------------------------------------------------------- /LeetCode/283.Move_Zeroes.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | void moveZeroes(vector& nums) { 4 | int pos=0; 5 | for(int i=0;i &nums, int k) 15 | { 16 | int ans=0; 17 | int all_xor=nums[0]; 18 | for(int i=1;idp; 4 | NumArray(vector& nums) { 5 | int sum=0; 6 | dp.push_back(0); 7 | for(int i=0;isumRange(i,j); 23 | */ -------------------------------------------------------------------------------- /LeetCode/3160.Find The Number Of Distinct Colors Among The Balls.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | vector queryResults(int limit, vector> &queries) 15 | { 16 | map cnt, color; 17 | 18 | int n = queries.size(); 19 | vector ans(n); 20 | 21 | for (int i = 0; i < n; i++) 22 | { 23 | int x = queries[i][0]; 24 | int y = queries[i][1]; 25 | if (color.find(x) != color.end()) 26 | { 27 | cnt[color[x]]--; 28 | if (cnt[color[x]] == 0) 29 | cnt.erase(color[x]); 30 | } 31 | 32 | color[x] = y; 33 | cnt[y]++; 34 | ans[i] = cnt.size(); 35 | } 36 | 37 | return ans; 38 | } 39 | }; 40 | -------------------------------------------------------------------------------- /LeetCode/3223.Minimum Length of String After.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll; 6 | const ll INF = 1e18; 7 | const ll mod1 = 1e9 + 7; 8 | const ll mod2 = 998244353; 9 | // Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | int minimumLength(string s) 15 | { 16 | vector v(26, 0); 17 | int ans = 0; 18 | for (auto x : s) 19 | { 20 | v[x - 'a']++; 21 | } 22 | for (auto x : v) 23 | { 24 | if (x & 1) 25 | { 26 | ans++; 27 | } 28 | else if (x > 0) 29 | { 30 | ans += 2; 31 | } 32 | } 33 | 34 | return ans; 35 | } 36 | }; 37 | -------------------------------------------------------------------------------- /LeetCode/3412.Find Mirror Score of a String.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | char find_mirror(char ch) { 4 | return 'a' + 'z' - ch ; 5 | } 6 | long long calculateScore(string s) { 7 | map> mp; 8 | 9 | long long score = 0 ; 10 | for(int i=0 ; i < s.size() ; i++) { 11 | char mir = find_mirror(s[i]); 12 | 13 | if( mp.find(mir) != mp.end() && mp[mir].size() > 0 ) { 14 | auto it = mp[mir].rbegin() ; 15 | score += i - *it ; 16 | mp[mir].erase(*it) ; 17 | } 18 | else { 19 | mp[s[i]].insert(i) ; 20 | } 21 | } 22 | return score ; 23 | } 24 | }; 25 | -------------------------------------------------------------------------------- /LeetCode/392.Is_Subsequence.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool isSubsequence(string s, string t) { 4 | int pos=0; 5 | for(int i=0;i=s.size()) 10 | return true; 11 | } 12 | if(pos>=s.size()) 13 | return true; 14 | return false; 15 | } 16 | }; -------------------------------------------------------------------------------- /LeetCode/435.Non-overlapping Intervals.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | int eraseOverlapIntervals(vector> &intervals) 15 | { 16 | int n = intervals.size(); 17 | sort(intervals.begin(), intervals.end()); 18 | int ans = 0; 19 | for (int i = 0; i < n - 1; i++) 20 | { 21 | if (intervals[i][1] > intervals[i + 1][0]) 22 | { 23 | ans++; 24 | intervals[i + 1][1] = min(intervals[i][1], intervals[i + 1][1]); 25 | } 26 | } 27 | return ans; 28 | } 29 | }; -------------------------------------------------------------------------------- /LeetCode/452.Minimum_Number_of_Arriws_to_Brust_Ballons.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int findMinArrowShots(vector>& points) { 4 | sort(points.begin(),points.end()); 5 | int count=0; 6 | long long min=LLONG_MIN; 7 | for(int i=0;imin){ 9 | min=points[i][1]; 10 | count++; 11 | } 12 | else if(points[i][1] bit(32, 0); 19 | int ans = 0; 20 | int pos = 0; 21 | while (n) 22 | { 23 | if (n & 1) 24 | { 25 | bit[pos] = 1; 26 | } 27 | n >>= 1; 28 | pos++; 29 | } 30 | for (ll i = 0; i < pos; i++) 31 | { 32 | ans += (1 - bit[i]) * pow(2, i); 33 | } 34 | return ans; 35 | } 36 | }; 37 | -------------------------------------------------------------------------------- /LeetCode/50.Pow(x,n).cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | double myPow(double x, int n) { 4 | return double (pow(x,n)); 5 | } 6 | }; -------------------------------------------------------------------------------- /LeetCode/53.Maximum_Subarray.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int maxSubArray(vector& nums) { 4 | int temp=0,maxo=INT_MIN; 5 | for(auto x:nums) 6 | { 7 | temp+=x; 8 | if(maxo& logs) { 4 | int count=0; 5 | for(auto x:logs) 6 | { 7 | // cout<0) 18 | return count; 19 | else 20 | return 0; 21 | } 22 | }; -------------------------------------------------------------------------------- /LeetCode/5535-Maximum_Nesting_Depth_of_the_Parantheses.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int maxDepth(string s) { 4 | int count=0; 5 | int maxo=0; 6 | for(auto x:s) 7 | { 8 | if(x=='(') 9 | count++; 10 | else if(x==')') 11 | count--; 12 | else if(x>='0'&&x<='9') 13 | { 14 | maxo=max(maxo,count); 15 | } 16 | } 17 | return maxo; 18 | } 19 | }; -------------------------------------------------------------------------------- /LeetCode/5537.Split_two_Stings_to_Make_Palindrome.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool checkPalindromeFormation(string a, string b) { 4 | int n=a.size(); 5 | int m=b.size(); 6 | int flag=2; 7 | for(int i=0;i> m; 5 | int n=s.size(); 6 | for(int i=0;i=2) 14 | maxo=max(maxo,abs(x.second[0]-x.second[x.second.size()-1])-1); 15 | } 16 | if(maxo<0) 17 | return -1; 18 | else 19 | return maxo; 20 | } 21 | }; -------------------------------------------------------------------------------- /LeetCode/5649.Decode_XORed_Array.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | vector decode(vector& encoded, int first) { 4 | vector v; 5 | v.push_back(first); 6 | int ans=first; 7 | for(auto x:encoded) 8 | { 9 | ans=ans^x; 10 | v.push_back(ans); 11 | } 12 | return v; 13 | } 14 | }; -------------------------------------------------------------------------------- /LeetCode/5653.Number_of_Rectangles_That_Can_Form_The_Largest_Square.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int countGoodRectangles(vector>& rectangles) { 4 | map m; 5 | int maxo=0; 6 | for(auto x:rectangles) 7 | { 8 | int mini=min(x[0],x[1]); 9 | maxo=max(maxo,mini); 10 | m[mini]++; 11 | } 12 | return m[maxo]; 13 | } 14 | }; -------------------------------------------------------------------------------- /LeetCode/5654.Maximum_Number_of_Balls_in_a_Box.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int countBalls(int lowLimit, int highLimit) { 4 | map m; 5 | for(int i=lowLimit;i<=highLimit;i++) 6 | { 7 | int sum=0; 8 | int temp=i; 9 | while(temp) 10 | { 11 | sum+=temp%10; 12 | temp/=10; 13 | } 14 | m[sum]++; 15 | } 16 | int maxo=0; 17 | for(auto x:m) 18 | { 19 | maxo=max(maxo,x.second); 20 | } 21 | return maxo; 22 | } 23 | }; -------------------------------------------------------------------------------- /LeetCode/5672.Check_if_Array_Is_Sorted_and_Rotated.cpp.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool check(vector& nums) { 4 | for(int i=0;i findingUsersActiveMinutes(vector>& logs, int k) { 4 | vectorans(k,0); 5 | map> m; 6 | for(auto x:logs){ 7 | m[x[0]].insert(x[1]); 8 | } 9 | for(auto x:m){ 10 | int temp=x.second.size(); 11 | ans[temp-1]++; 12 | } 13 | return ans; 14 | } 15 | }; -------------------------------------------------------------------------------- /LeetCode/62.Unique_Paths.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int uniquePaths(int m, int n) { 4 | vector> dp(m+1,vector(n+1,0)); 5 | for(int i=0;i& nums) { 4 | int n=nums.size(); 5 | sort(nums.begin(),nums.end(),greater()); 6 | int ans=1; 7 | ans=(nums[0]*nums[1]*nums[2]); 8 | int temp=nums[n-1]*nums[n-2]*nums[0]; 9 | ans=max(ans,temp); 10 | return ans; 11 | } 12 | }; -------------------------------------------------------------------------------- /LeetCode/63.Unique_Paths_II.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int uniquePathsWithObstacles(vector>& obstacleGrid) { 4 | vector> dp(101,vector(101,0)); 5 | int m=obstacleGrid.size(); 6 | int n=obstacleGrid[0].size(); 7 | for(int i=0;i>& grid) { 4 | int n=grid.size(); 5 | int m=grid[0].size(); 6 | vector> dp(n,vector(m,0)); 7 | for(int i=0;i0) 14 | dp[i][j]=grid[i][j]+dp[i][j-1]; 15 | else if(i>0 and j==0) 16 | dp[i][j]=grid[i][j]+dp[i-1][j]; 17 | else 18 | dp[i][j]=grid[i][j]+min(dp[i-1][j],dp[i][j-1]); 19 | } 20 | } 21 | return dp[n-1][m-1]; 22 | } 23 | }; -------------------------------------------------------------------------------- /LeetCode/646.Maximum Length of Pair Chain.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | int findLongestChain(vector> &pairs) 15 | { 16 | sort(pairs.begin(), pairs.end()); 17 | int m = pairs.size(), cnt = 1, prev = pairs[0][1]; 18 | for (int i = 1; i < m; i++) 19 | { 20 | if (prev < pairs[i][0]) 21 | { 22 | cnt++; 23 | prev = pairs[i][1]; 24 | } 25 | else if (prev > pairs[i][1]){ 26 | prev = pairs[i][1]; 27 | } 28 | } 29 | return cnt; 30 | } 31 | }; -------------------------------------------------------------------------------- /LeetCode/674-Longest_Continuous_Increasing_Subsequence.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int findLengthOfLCIS(vector& nums) { 4 | int count=0,maxo=1; 5 | int n=nums.size(); 6 | if(n==1) 7 | return 1; 8 | if(n==0) 9 | return 0; 10 | count=1; 11 | int temp=nums[0]; 12 | for(int i=1;itemp) 15 | count++; 16 | else 17 | count=1; 18 | maxo=max(maxo,count); 19 | temp=nums[i]; 20 | } 21 | return maxo; 22 | } 23 | }; -------------------------------------------------------------------------------- /LeetCode/7.Reverse_Integer.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int reverse(int x) { 4 | int ans=0; 5 | while(x) 6 | { 7 | if((ans)>INT_MAX/10||(ans) dp(n+1,0); 12 | dp[1]=1; 13 | dp[2]=2; 14 | for(int i=3;i<=n;i++) 15 | dp[i]=dp[i-1]+dp[i-2]; 16 | return dp[n]; 17 | } 18 | } 19 | }; -------------------------------------------------------------------------------- /LeetCode/746.Min_Cost_Climbing_Stairs.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int minCostClimbingStairs(vector& cost) { 4 | int n=cost.size(); 5 | vector dp(n+2,0); 6 | for(int i=n-1;i>=0;i--) 7 | { 8 | dp[i]=cost[i]+min(dp[i+1],dp[i+2]); 9 | } 10 | return min(dp[0],dp[1]); 11 | } 12 | }; -------------------------------------------------------------------------------- /LeetCode/8.String_to_Integer(atoi).cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int myAtoi(string str) { 4 | stringstream pk(str); 5 | int num=0; 6 | pk>>num; 7 | return num; 8 | } 9 | }; -------------------------------------------------------------------------------- /LeetCode/88.Merge Sorted Array.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | void merge(vector &nums1, int m, vector &nums2, int n) 15 | { 16 | int i = m - 1, j = n - 1, k = m + n - 1; 17 | while (i >= 0 && j >= 0) 18 | { 19 | if (nums1[i] > nums2[j]) 20 | { 21 | nums1[k] = nums1[i]; 22 | i--; 23 | } 24 | else 25 | { 26 | nums1[k] = nums2[j]; 27 | j--; 28 | } 29 | k--; 30 | } 31 | while (j >= 0) 32 | { 33 | nums1[k] = nums2[j]; 34 | j--; 35 | k--; 36 | } 37 | } 38 | }; -------------------------------------------------------------------------------- /LeetCode/9.Palindrome_Number.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool isPalindrome(int x) { 4 | int y=x; 5 | stack s; 6 | if(x<0) 7 | return false; 8 | while(y) 9 | { 10 | s.push(y%10); 11 | y/=10; 12 | } 13 | while(!s.empty()) 14 | { 15 | if(s.top()!=x%10) 16 | return false; 17 | s.pop(); 18 | x/=10; 19 | } 20 | return true; 21 | } 22 | }; -------------------------------------------------------------------------------- /LeetCode/922.Sort_Array_By_Parity_II.java: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | Institute: National Institute of Technology, Uttarakhand 5 | */ 6 | class Solution { 7 | public int[] sortArrayByParityII(int[] nums) { 8 | int n=nums.length; 9 | int[] even=new int[n/2]; 10 | int[] odd=new int[n/2]; 11 | int i=0,j=0; 12 | for(int k=0;k sortedSquares(vector &nums) 15 | { 16 | int n=nums.size(); 17 | vector ans(n); 18 | int first=0,second = n-1; 19 | for(int i=n-1;i>=0;i--){ 20 | if(abs(nums[first])>=abs(nums[second])){ 21 | ans[i]=nums[first]*nums[first]; 22 | first++; 23 | } 24 | else{ 25 | ans[i]=nums[second]*nums[second]; 26 | second--; 27 | } 28 | } 29 | return ans; 30 | } 31 | }; -------------------------------------------------------------------------------- /LeetCode/983.Minimum Cost For Tickets.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | typedef long long ll ; 6 | const ll INF=1e18; 7 | const ll mod1=1e9+7; 8 | const ll mod2=998244353; 9 | //Add main code here 10 | 11 | class Solution 12 | { 13 | public: 14 | int mincostTickets(vector &days, vector &costs) 15 | { 16 | vector dp(366, 0); 17 | 18 | for(int i=days[0];i<=365;i++){ 19 | if(find(days.begin(),days.end(),i)==days.end()){ 20 | dp[i]=dp[i-1]; 21 | continue; 22 | } 23 | else{ 24 | dp[i]=min({dp[i-1]+costs[0],dp[max(0,i-7)]+costs[1],dp[max(0,i-30)]+costs[2]}); 25 | } 26 | } 27 | return dp[days.back()]; 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /LeetCode/README.md: -------------------------------------------------------------------------------- 1 | ### After weekly contest 261 I decided to put all file in parent folder only, stopped making seprate folder for each and every contest. 2 | -------------------------------------------------------------------------------- /Spoj/Practice/LASTDIG.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | written by Pankaj Kumar. 3 | country:-INDIA 4 | */ 5 | #include 6 | #include 7 | using namespace std; 8 | 9 | int main() { 10 | // your code goes here 11 | int test; 12 | cin>>test; 13 | while(test--) 14 | { 15 | long long a,b; 16 | cin>>a>>b; 17 | if(b==0) 18 | { 19 | cout<<1< Contain practice file in c++ of [timus](https://acm.timus.ru/problemset.aspx) platform. 2 | --------------------------------------------------------------------------------