├── Code ├── .gitignore ├── Code.iml ├── WorkspaceB │ ├── C++_Files │ │ ├── C++ Files.iml │ │ ├── CC │ │ │ ├── A2.cpp │ │ │ ├── ABROADS.cpp │ │ │ ├── ACM14AM1.cpp │ │ │ ├── ACM14AM3.cpp │ │ │ ├── ACM14KP2.cpp │ │ │ ├── ACM15KP5.cpp │ │ │ ├── ACUGRAM.cpp │ │ │ ├── ACUGRAY.cpp │ │ │ ├── ADDMUL.cpp │ │ │ ├── ADIGIT.cpp │ │ │ ├── ADTRI.cpp │ │ │ ├── AMMEAT2.cpp │ │ │ ├── ANUARM.cpp │ │ │ ├── ASP.cpp │ │ │ ├── BANROB.cpp │ │ │ ├── BRCD2015.cpp │ │ │ ├── CANDLE.cpp │ │ │ ├── CAOS1.cpp │ │ │ ├── CBALLS.cpp │ │ │ ├── CDMU02.cpp │ │ │ ├── CDQT2015_ICQ1.cpp │ │ │ ├── CDQT2015_ICQ2.cpp │ │ │ ├── CDQT2015_ICQ3.cpp │ │ │ ├── CDQT2015_ICQ4.cpp │ │ │ ├── CDSE06.cpp │ │ │ ├── CFRTEST.cpp │ │ │ ├── CHEFBM.cpp │ │ │ ├── CHEFGR.cpp │ │ │ ├── CHEFLAPT.cpp │ │ │ ├── CHEFLCM.cpp │ │ │ ├── CHEFPD.cpp │ │ │ ├── CHEFTREE.cpp │ │ │ ├── CHSTAMP.cpp │ │ │ ├── CLMBSTRS.cpp │ │ │ ├── COALSCAM.cpp │ │ │ ├── CODECRCK.cpp │ │ │ ├── CSEQ.cpp │ │ │ ├── DBOY.cpp │ │ │ ├── DEVPERF.cpp │ │ │ ├── DEVUGRAP.cpp │ │ │ ├── DGCD.cpp │ │ │ ├── DISHOWN.cpp │ │ │ ├── E2 Codechef.cpp │ │ │ ├── EGBOBRD.cpp │ │ │ ├── EQIIDLIS.cpp │ │ │ ├── FBFRW1.cpp │ │ │ ├── FBFRW2.cpp │ │ │ ├── FCBARCA.cpp │ │ │ ├── FGFS.cpp │ │ │ ├── FIREESC.cpp │ │ │ ├── FRGTNLNG.cpp │ │ │ ├── FRMQ.cpp │ │ │ ├── GARDENSQ.cpp │ │ │ ├── GCDQ.cpp │ │ │ ├── GRID.cpp │ │ │ ├── GRIDPATH.cpp │ │ │ ├── HANGOVER.cpp │ │ │ ├── HDELIVER.cpp │ │ │ ├── HOMEDEL.cpp │ │ │ ├── KINGCON.cpp │ │ │ ├── KPRIME.cpp │ │ │ ├── KSPHERES.cpp │ │ │ ├── LASTDIG.cpp │ │ │ ├── LEDIV.cpp │ │ │ ├── LEVY.cpp │ │ │ ├── LIGHTHSE.cpp │ │ │ ├── MARBLEGF.cpp │ │ │ ├── MARBLEGF_BIT.cpp │ │ │ ├── MAXCOUNT.cpp │ │ │ ├── MCHEF_C.cpp │ │ │ ├── MGCH3D_15.cpp │ │ │ ├── MIME2.cpp │ │ │ ├── MONTRANS.cpp │ │ │ ├── MSTICK.cpp │ │ │ ├── NUKES.cpp │ │ │ ├── ONP.cpp │ │ │ ├── PERMSUFF.cpp │ │ │ ├── PRGIFT.cpp │ │ │ ├── PRIMEGEN.cpp │ │ │ ├── PRIMES2.cpp │ │ │ ├── PRLADDU.cpp │ │ │ ├── PROSUM.cpp │ │ │ ├── PT07Y.cpp │ │ │ ├── RECRECOV.cpp │ │ │ ├── RGAME.cpp │ │ │ ├── RRFRNDS.cpp │ │ │ ├── SAD.cpp │ │ │ ├── SMPLSUM.cpp │ │ │ ├── SPIT3.cpp │ │ │ ├── SPREAD.cpp │ │ │ ├── SPRNMBRS.cpp │ │ │ ├── STACKS.cpp │ │ │ ├── SUBANAGR.cpp │ │ │ ├── SUBINC.cpp │ │ │ ├── SUBSTR.cpp │ │ │ ├── TAQTREE_HLD.cpp │ │ │ ├── TASHIFT.cpp │ │ │ ├── TEST │ │ │ ├── TEST.cpp │ │ │ ├── TIMEASR.cpp │ │ │ ├── TMSLT.cpp │ │ │ ├── TSORT.cpp │ │ │ ├── TWTCLOSE.cpp │ │ │ ├── UGLYF │ │ │ ├── UGLYF.cpp │ │ │ ├── WDTBAM.cpp │ │ │ └── XORNUMBER.cpp │ │ ├── CF │ │ │ ├── 474_V │ │ │ │ ├── A.cpp │ │ │ │ ├── B.cpp │ │ │ │ ├── C.cpp │ │ │ │ └── D.cpp │ │ │ ├── 476_V │ │ │ │ ├── A.cpp │ │ │ │ ├── B.cpp │ │ │ │ └── D.cpp │ │ │ ├── 478_V │ │ │ │ ├── 478_A.cpp │ │ │ │ └── 478_B.cpp │ │ │ ├── 479_V │ │ │ │ ├── A.cpp │ │ │ │ ├── B.java │ │ │ │ └── C.cpp │ │ │ ├── 486_V │ │ │ │ └── A.cpp │ │ │ ├── 545_V │ │ │ │ ├── A.cpp │ │ │ │ ├── B.cpp │ │ │ │ ├── C.cpp │ │ │ │ └── D.cpp │ │ │ ├── 570_V │ │ │ │ ├── A.cpp │ │ │ │ └── B.cpp │ │ │ ├── 588_V │ │ │ │ ├── A.cpp │ │ │ │ ├── B.cpp │ │ │ │ └── C.cpp │ │ │ ├── 727_A │ │ │ ├── 727_A.cpp │ │ │ ├── CF.iml │ │ │ └── Practice │ │ │ │ ├── 103_B.cpp │ │ │ │ ├── 109_A.cpp │ │ │ │ ├── 115_A.cpp │ │ │ │ ├── 137_C.cpp │ │ │ │ ├── 217_A.cpp │ │ │ │ ├── 276_C.cpp │ │ │ │ ├── 286_C.cpp │ │ │ │ ├── 292_B.cpp │ │ │ │ ├── 339_C.cpp │ │ │ │ ├── 385_C.cpp │ │ │ │ ├── 427_C.cpp │ │ │ │ ├── 463_C.cpp │ │ │ │ ├── 466_C.cpp │ │ │ │ ├── 4_C.cpp │ │ │ │ ├── 500_B.cpp │ │ │ │ ├── 500_a.cpp │ │ │ │ ├── 508_C.cpp │ │ │ │ ├── 508_D.cpp │ │ │ │ ├── 520_B.cpp │ │ │ │ ├── 551_C.cpp │ │ │ │ ├── 552_B.cpp │ │ │ │ ├── 552_C.cpp │ │ │ │ ├── 552_D.cpp │ │ │ │ ├── 552_a.cpp │ │ │ │ ├── 558_C.cpp │ │ │ │ ├── 580_B.cpp │ │ │ │ ├── 590_c.cpp │ │ │ │ ├── 591_C(median smooting).cpp │ │ │ │ ├── 592_C.py │ │ │ │ ├── 592_D(SuperM).cpp │ │ │ │ ├── 593B_antonAndLines.cpp │ │ │ │ ├── 604_A.cpp │ │ │ │ ├── 604_B.cpp │ │ │ │ ├── 612_c │ │ │ │ ├── 612_c.cpp │ │ │ │ ├── CF_131_C.cpp │ │ │ │ ├── CF_500B.cpp │ │ │ │ ├── CF_DIJKSTRA_C.cpp │ │ │ │ ├── Child_and_Toy_C_CF.cpp │ │ │ │ ├── DIC2_312_C.cpp │ │ │ │ ├── DP │ │ │ │ ├── 394_C.cpp │ │ │ │ ├── 455_A.cpp │ │ │ │ ├── BerSUBall_489_B.cpp │ │ │ │ ├── IlyaAndQueries_313_B.cpp │ │ │ │ └── SerejaAndSuffixes_368_B.cpp │ │ │ │ ├── Maze_377_A.cpp │ │ │ │ └── scratch.cpp │ │ ├── DS_ALGO │ │ │ ├── BIT │ │ │ │ ├── BIT_Range_Update_AND_Queries.cpp │ │ │ │ ├── BIT_Range_Update_Point_Queries.cpp │ │ │ │ └── BIT_Regular.cpp │ │ │ ├── COMBINATIONS │ │ │ │ ├── Combinations_Pascal_Triangle.cpp │ │ │ │ └── PASCALTRI_USE.cpp │ │ │ ├── GRAPH ALGOS │ │ │ │ ├── DIJKSTRA │ │ │ │ │ ├── DIJKSTRA_EXPLAINED.cpp │ │ │ │ │ ├── DIJKSTRA_NEAT.cpp │ │ │ │ │ └── DIJKSTRA_USE.cpp │ │ │ │ ├── EulerTour_Heirholzer.cpp │ │ │ │ ├── FLOYD_WARSHALL.cpp │ │ │ │ ├── HEAVY-LIGHT │ │ │ │ │ ├── HEAVY-LIGHT_EDGE.cpp │ │ │ │ │ └── HEAVY_LIGHT_NODE.cpp │ │ │ │ ├── HOPCROFT-KARP BIPARTITE MATCHING │ │ │ │ │ ├── HopcroftKarp_EXPLAIN.cpp │ │ │ │ │ ├── MaximalMatchingHopcroftKarp_USE.cpp │ │ │ │ │ └── MaximalMatchingHopcroftKarp_USE_2.cpp │ │ │ │ ├── LCA │ │ │ │ │ ├── LCA_EXPLAIN.cpp │ │ │ │ │ └── LCA_USE.cpp │ │ │ │ ├── MST │ │ │ │ │ ├── KRUSKAL_EXPLAINED.cpp │ │ │ │ │ └── KRUSKAL_USE.cpp │ │ │ │ └── TARJAN │ │ │ │ │ ├── TARJAN_UNDERSTAND.cpp │ │ │ │ │ ├── TARJAN_USE.cpp │ │ │ │ │ └── Tarjans_ArticulationPoints.cpp │ │ │ ├── MISC │ │ │ │ ├── DSU_USE.cpp │ │ │ │ ├── TSP.cpp │ │ │ │ └── convexHullTrick.cpp │ │ │ ├── SEGMENT TREE │ │ │ │ ├── SEGTREE_EXPLAINED.cpp │ │ │ │ └── SEGTREE_USE.cpp │ │ │ ├── SIEVE │ │ │ │ ├── SieveOfEros_USE.cpp │ │ │ │ └── SieveofErosthosnes_EXPLAIN.cpp │ │ │ └── STRING │ │ │ │ ├── RABIN_KARP_ROLLING_HASHING.cpp │ │ │ │ └── Z_Algorithm.cpp │ │ ├── INPUT.txt │ │ ├── LIGHTOJ │ │ │ ├── 1348.cpp │ │ │ └── Array_Queries_1082.cpp │ │ ├── SPOJ │ │ │ ├── AE00.cpp │ │ │ ├── AGGRCOW.cpp │ │ │ ├── ARMY.cpp │ │ │ ├── BUGLIFE.cpp │ │ │ ├── CANDY3.cpp │ │ │ ├── CANTON.cpp │ │ │ ├── CHICAGO.cpp │ │ │ ├── COINS.cpp │ │ │ ├── CONFLIP.cpp │ │ │ ├── CSTREET_KRUSKAL.cpp │ │ │ ├── CSTREET_PRIMS.cpp │ │ │ ├── DCEP11B.cpp │ │ │ ├── EIGHTS.cpp │ │ │ ├── ELIS.cpp │ │ │ ├── EPALIN_spoj.cpp │ │ │ ├── EZDIJKST.cpp │ │ │ ├── FACT.cpp │ │ │ ├── FENCE1.cpp │ │ │ ├── GSS1.cpp │ │ │ ├── HORRIBLE.cpp │ │ │ ├── INVCNT.cpp │ │ │ ├── JZYPHYZ_spoj.cpp │ │ │ ├── KQUERY.cpp │ │ │ ├── LCA.cpp │ │ │ ├── LCS0.cpp │ │ │ ├── MATCHING.cpp │ │ │ ├── MISINTER.cpp │ │ │ ├── NAJPF.cpp │ │ │ ├── NHAY.cpp │ │ │ ├── OLOLO.cpp │ │ │ ├── PERMUT2.cpp │ │ │ ├── PRATA.cpp │ │ │ ├── PRIME1.cpp │ │ │ ├── PRINT.cpp │ │ │ ├── PT07X │ │ │ ├── PT07X.cpp │ │ │ ├── PT07Y.cpp │ │ │ ├── PT07Z.cpp │ │ │ ├── QTREE.cpp │ │ │ ├── QTREE2.cpp │ │ │ ├── RPLN.cpp │ │ │ ├── SHPATH.cpp │ │ │ ├── STAMPS.cpp │ │ │ ├── STPAR.cpp │ │ │ ├── TRICOUNT.cpp │ │ │ ├── TSHPATH.cpp │ │ │ ├── Trie_test.cpp │ │ │ ├── UPDATEIT.cpp │ │ │ ├── WACHOVIA.cpp │ │ │ ├── WCOUNT.cpp │ │ │ ├── WILLITST.cpp │ │ │ └── YODANESS.cpp │ │ └── terminate.bat │ ├── College_stuff │ │ ├── CSE 219(OOPS) │ │ │ ├── fh.cpp │ │ │ ├── inher.cpp │ │ │ ├── inher2.cpp │ │ │ ├── oops_w10_1.cpp │ │ │ ├── oops_w10_2.cpp │ │ │ ├── oper_overl.cpp │ │ │ ├── temp_sort.cpp │ │ │ ├── templates_egs.cpp │ │ │ ├── vl_2.cpp │ │ │ ├── vl_4_24_2015.cpp │ │ │ └── w11_2.cpp │ │ ├── CSE 220 (DSA) │ │ │ ├── ADV_DS_PROJECT │ │ │ │ ├── BIT │ │ │ │ │ ├── BIT.cpp │ │ │ │ │ ├── BIT.h │ │ │ │ │ └── main.cpp │ │ │ │ ├── DSU.cpp │ │ │ │ ├── SEGMENT_TREE │ │ │ │ │ ├── Segment_tree.cpp │ │ │ │ │ └── main.cpp │ │ │ │ └── Trie.cpp │ │ │ ├── BFS.cpp │ │ │ ├── BIT.cpp │ │ │ ├── BST.cpp │ │ │ ├── Basic OOPS.cpp │ │ │ ├── DFS.cpp │ │ │ ├── Dijkstra.cpp │ │ │ ├── DoublyLinkedList.cpp │ │ │ ├── FloydWarshall.cpp │ │ │ ├── HashTable.cpp │ │ │ ├── HeapSort.cpp │ │ │ ├── Heap_BST.cpp │ │ │ ├── InfixToPostfix.cpp │ │ │ ├── Kruskal.cpp │ │ │ ├── Linked_list.cpp │ │ │ ├── Linked_list2.cpp │ │ │ ├── MergeSort.cpp │ │ │ ├── Prims.cpp │ │ │ ├── Queue.cpp │ │ │ ├── QuickSort.cpp │ │ │ └── Stack.cpp │ │ ├── CSE 222 (OS) │ │ │ ├── BankersAlgorithm.java │ │ │ ├── DiningPhilosopherProblem.java │ │ │ ├── FCFS-AND-SJT.cpp │ │ │ ├── ForkAndExecvp.cpp │ │ │ ├── PageReplacementPolicies.cpp │ │ │ ├── ReaderWritersProblem.java │ │ │ └── RoundRobinScheduling.cpp │ │ └── College stuff.iml │ ├── Coursera_Algo1 │ │ ├── BFS.py │ │ ├── BST.cpp │ │ ├── COURSERA_PS5_Dijkstra.java │ │ ├── COURSERA_PS6_1.java │ │ ├── COURSERA_PS6_2.java │ │ ├── DFS.cpp │ │ ├── Dijkstra_PS5.java │ │ ├── HashTable_2Sum.cpp │ │ ├── Inversion_Quiz.py │ │ ├── Karatsuba.py │ │ ├── KragersMinCut.java │ │ ├── MergeSort.py │ │ ├── MinCut.py │ │ ├── NoOfInversions.py │ │ ├── QuickSort.py │ │ ├── QuickSort_Quiz.py │ │ ├── RandomizedSelection.py │ │ └── TARJAN_COURSERA.cpp │ ├── Java_Extras │ │ ├── ABSYS.java │ │ ├── ACUGRAY.java │ │ ├── AMMEAT2.java │ │ ├── BFSGRID.java │ │ ├── CANDY3.java │ │ ├── CHEFTMA.java │ │ ├── FLAGS.java │ │ ├── FLIPCOIN_TEST.java │ │ ├── HashTable_coursera_2sum.java │ │ ├── InvalidParen.java │ │ ├── KragersMinCut.java │ │ ├── MOREFB_E.java │ │ ├── MixerMatcher.java │ │ ├── MyTask.java │ │ ├── PRO.java │ │ ├── RegexMatch.java │ │ ├── SETDIFF.java │ │ ├── gukizhatesboxes.java │ │ └── test.java │ ├── Misc │ │ ├── Add2NumbersLinkedList.cpp │ │ ├── AutoCorrect.cpp │ │ ├── BALSEQ.cpp │ │ ├── E3.cpp │ │ ├── FightInNinjaWorld.cpp │ │ ├── GCJ16 │ │ │ ├── A_CountingSheep │ │ │ │ ├── A-large-answer.txt │ │ │ │ ├── A-large.in │ │ │ │ ├── A-small-answer.txt │ │ │ │ ├── A-small-attempt0.in │ │ │ │ └── GCJ16_A.cpp │ │ │ └── B_RevengeOfThePancakes │ │ │ │ ├── B-large-answer.txt │ │ │ │ ├── B-large.in │ │ │ │ ├── B-small-answer.txt │ │ │ │ ├── B-small-attempt0.in │ │ │ │ └── GCJ16_B.cpp │ │ ├── MultitaskEasy.cpp │ │ ├── N1.cpp │ │ ├── OBJSEARCH.cpp │ │ ├── PALHAPPY.cpp │ │ ├── PE23.cpp │ │ ├── PE25.cpp │ │ ├── Pattern.cpp │ │ ├── PrimeSoccer.cpp │ │ ├── ReverseLinkedList.cpp │ │ ├── SUPER_FAST_IO.cpp │ │ ├── Sentence Break.cpp │ │ ├── Swap_pairs_LL.cpp │ │ ├── TEST.cs │ │ ├── Test1.cpp │ │ ├── remove_comments.txt │ │ ├── scratch.cpp │ │ ├── testp.cpp │ │ └── w7_p1.cpp │ ├── Python Scripts │ │ ├── ACMKP02.py │ │ ├── ADDMAG.py │ │ ├── BRACKETS.py │ │ ├── CANTON.py │ │ ├── CAPPLE.py │ │ ├── CFRTEST.py │ │ ├── CIELNUM2.py │ │ ├── DBOY.py │ │ ├── DISCHAR.py │ │ ├── DISHOWN.py │ │ ├── ELIS.py │ │ ├── GUESS.py │ │ ├── HHAL.py │ │ ├── InfStr.py │ │ ├── KFUNC.py │ │ ├── ListSub.py │ │ ├── MONTRANS.py │ │ ├── PPNUM.py │ │ ├── PROB.py │ │ ├── SDSQUARE.py │ │ ├── SUMPAIR.py │ │ ├── TEST.py │ │ ├── TWOSTR.py │ │ ├── XORNUMBER.py │ │ ├── basics.py │ │ ├── createPatientInOpenMRS.py │ │ └── hello.py │ └── WorkspaceB.iml └── src │ ├── CODECHEF │ ├── COOK_OFFS │ │ ├── COOK54 │ │ │ └── src │ │ │ │ └── ANUBTG.java │ │ ├── COOK55 │ │ │ └── src │ │ │ │ ├── TRISQ.java │ │ │ │ ├── scratch.java │ │ │ │ └── scratch2.java │ │ ├── COOK57 │ │ │ └── src │ │ │ │ ├── EQUALITY.java │ │ │ │ └── VCS.java │ │ ├── COOK58 │ │ │ └── src │ │ │ │ ├── CFRTEST.java │ │ │ │ └── REARRSTR.java │ │ ├── COOK59 │ │ │ └── src │ │ │ │ └── UTMOPR.java │ │ ├── COOK60 │ │ │ └── src │ │ │ │ ├── COPS.java │ │ │ │ └── SUMPAIR.java │ │ ├── COOK61 │ │ │ └── src │ │ │ │ ├── DUALPAL.java │ │ │ │ ├── TWOSTR.java │ │ │ │ └── XORNUM.java │ │ └── COOK63 │ │ │ └── src │ │ │ ├── ASP.java │ │ │ └── STEM.java │ ├── LOCAL_CONTESTS │ │ ├── CDBR2015 │ │ │ └── src │ │ │ │ └── CDBSTR7.java │ │ ├── CDER2015 │ │ │ └── src │ │ │ │ ├── DISPLAY.java │ │ │ │ ├── ESYYSE.java │ │ │ │ ├── EXORO.java │ │ │ │ ├── FACT25.java │ │ │ │ ├── LUCKYR.java │ │ │ │ ├── PALIND.java │ │ │ │ ├── REVER.java │ │ │ │ └── SHORTCUT.java │ │ ├── CDMU2015 │ │ │ └── src │ │ │ │ ├── CDMU01.java │ │ │ │ └── CDMU02.java │ │ ├── CDVA2015 │ │ │ └── src │ │ │ │ ├── CDVA1502.java │ │ │ │ ├── CDVA1503.java │ │ │ │ ├── CDVA1504.java │ │ │ │ ├── CDVA1505.java │ │ │ │ ├── CDVA1508.java │ │ │ │ └── CDVA1510.java │ │ ├── DCL15 │ │ │ ├── DCL15.eml │ │ │ └── src │ │ │ │ ├── DCL1501.java │ │ │ │ └── DCL1502.java │ │ ├── EXCU2015 │ │ │ └── src │ │ │ │ ├── BEAN.java │ │ │ │ ├── GOKU.java │ │ │ │ ├── JERRY.java │ │ │ │ └── OLIVE.java │ │ ├── HUMP15R │ │ │ └── src │ │ │ │ ├── CHEFLAPT.java │ │ │ │ └── YJUMP.java │ │ ├── MDSW2015 │ │ │ └── src │ │ │ │ ├── ALNUM.java │ │ │ │ ├── IDCLOVE.java │ │ │ │ └── IDCMSG.java │ │ ├── OPC_ACUMEN_2015 │ │ │ ├── ACUCRYPT.java │ │ │ ├── ACUGRAM.java │ │ │ ├── ACUGRAY.java │ │ │ ├── ACULIST.java │ │ │ ├── ACUPALIN.java │ │ │ └── ACUSET.java │ │ └── XCPT2015 │ │ │ └── src │ │ │ ├── XC201.java │ │ │ ├── XC202.java │ │ │ ├── scratch.java │ │ │ └── scratch2.java │ ├── LONG_CHALLENGE │ │ ├── APRIL15 │ │ │ └── src │ │ │ │ ├── BROKPHON.java │ │ │ │ ├── CHEFLCM.java │ │ │ │ ├── CSEQ.java │ │ │ │ ├── FRMQ.java │ │ │ │ └── PIANO1.java │ │ ├── FEB15 │ │ │ └── src │ │ │ │ ├── CHEFCH.java │ │ │ │ ├── CHEFEQ.java │ │ │ │ ├── RANKLIST.java │ │ │ │ ├── STFM.java │ │ │ │ ├── STRQ.java │ │ │ │ └── scratch.java │ │ ├── JAN16 │ │ │ └── src │ │ │ │ ├── CBALLS.java │ │ │ │ ├── CHEFTMA.java │ │ │ │ ├── DEVPERF.java │ │ │ │ ├── RGAME.java │ │ │ │ └── SEAKAM.java │ │ ├── JULY15 │ │ │ └── src │ │ │ │ ├── CHCUBE.java │ │ │ │ ├── EGBOBRD.java │ │ │ │ ├── LUCKST.java │ │ │ │ └── MCHEF.java │ │ ├── JUNE15 │ │ │ └── src │ │ │ │ ├── CBARG.java │ │ │ │ ├── CHPLGNS.java │ │ │ │ ├── CHSTR.java │ │ │ │ ├── FRNDMTNG.java │ │ │ │ └── STDYTAB.java │ │ ├── MAR15 │ │ │ └── src │ │ │ │ ├── CNOTE.java │ │ │ │ ├── DEVCLASS.java │ │ │ │ ├── SIGNWAVE.java │ │ │ │ └── STRSUB.java │ │ ├── MAY15 │ │ │ └── src │ │ │ │ ├── CHAPD.java │ │ │ │ ├── CHEFRP.java │ │ │ │ ├── DEVSTR.java │ │ │ │ └── SETDIFF.java │ │ ├── NOV15 │ │ │ └── src │ │ │ │ ├── CHSTAMP.cpp │ │ │ │ ├── EGRCAKE.java │ │ │ │ ├── KFUNC.py │ │ │ │ ├── RECRECOV.java │ │ │ │ └── SMPLSUM.cpp │ │ ├── OCT15 │ │ │ └── src │ │ │ │ ├── ADTRI.java │ │ │ │ ├── KSPHERES.java │ │ │ │ ├── SUBINC.java │ │ │ │ ├── TIMEASR.java │ │ │ │ └── WDTBAM.java │ │ └── SEPT15 │ │ │ └── src │ │ │ ├── BANROB.java │ │ │ ├── CODECRCK.java │ │ │ ├── DONUTS.java │ │ │ ├── LIGHTHSE.java │ │ │ ├── MGCH3D_15.java │ │ │ ├── MSTEP.java │ │ │ ├── REBXOR.java │ │ │ ├── TERVEC.java │ │ │ └── THEGAME.java │ └── PRACTICE │ │ ├── EASY │ │ └── src │ │ │ ├── ACM14KP2.java │ │ │ ├── ALEXNUMB.java │ │ │ ├── AMIFIB.java │ │ │ ├── AMMEAT.java │ │ │ ├── AMMEAT2.java │ │ │ ├── AMRIT13D.java │ │ │ ├── AMSGAME1.java │ │ │ ├── ANUARM.java │ │ │ ├── ANUDTC.java │ │ │ ├── ANUUND.java │ │ │ ├── ANUWTA.java │ │ │ ├── APPROX.java │ │ │ ├── ARRANGE.java │ │ │ ├── ATTIC.java │ │ │ ├── BESTBATS.java │ │ │ ├── BUY1GET1.java │ │ │ ├── BUYING2.java │ │ │ ├── CANDLE.java │ │ │ ├── CAOS1.java │ │ │ ├── CARVANS.java │ │ │ ├── CHEFLUCK.java │ │ │ ├── CHEFSTON.java │ │ │ ├── CHEFZOT.java │ │ │ ├── CHSTR.java │ │ │ ├── CIELAB.java │ │ │ ├── CIELDIST.java │ │ │ ├── CIELRCPT.java │ │ │ ├── CKISSHUG.java │ │ │ ├── CLEANUP.java │ │ │ ├── CLPERM.java │ │ │ ├── COMM3.java │ │ │ ├── COMMUTE.java │ │ │ ├── COMPILER.java │ │ │ ├── CONFLIP.java │ │ │ ├── COOLING.java │ │ │ ├── CSUB.java │ │ │ ├── CVOTE.java │ │ │ ├── DAILY.java │ │ │ ├── DBOY.java │ │ │ ├── DECSTR.java │ │ │ ├── DELISH.java │ │ │ ├── DIGJUMP.java │ │ │ ├── DINP1501_CHEFHILL.java │ │ │ ├── DINP1501_CHEFPOW.java │ │ │ ├── DINP1501_FIBGCD.java │ │ │ ├── DIRECTI.java │ │ │ ├── DIVGOLD.java │ │ │ ├── DIVIDING.java │ │ │ ├── DOUBLE.java │ │ │ ├── DRAGNXOR.java │ │ │ ├── DRGNBOOL.java │ │ │ ├── E1.java │ │ │ ├── EQUATION.java │ │ │ ├── ERROR.java │ │ │ ├── FCTRL.java │ │ │ ├── FCTRL2.java │ │ │ ├── FGFS.java │ │ │ ├── FLAGS.java │ │ │ ├── FROGV.java │ │ │ ├── GCD2.java │ │ │ ├── GCDQ.java │ │ │ ├── GRANAMA.java │ │ │ ├── GRID.java │ │ │ ├── HELLO.java │ │ │ ├── HELPLIRA.java │ │ │ ├── HOLES.java │ │ │ ├── HORSES.java │ │ │ ├── HOTEL.java │ │ │ ├── HS08TEST.java │ │ │ ├── INTEG.java │ │ │ ├── INTEST.java │ │ │ ├── J7.java │ │ │ ├── JOHNY.java │ │ │ ├── KINGCON.java │ │ │ ├── KINGSHIP.java │ │ │ ├── KNIGHTMV.java │ │ │ ├── KPRIME.java │ │ │ ├── LAPIN.java │ │ │ ├── LASTDIG.java │ │ │ ├── LCPESY.java │ │ │ ├── LEBOMBS.java │ │ │ ├── LECANDY.java │ │ │ ├── LEDIV.java │ │ │ ├── LELEMON.java │ │ │ ├── LUCKY5.java │ │ │ ├── LUCKYSTR.java │ │ │ ├── MAANDI.java │ │ │ ├── MANYCHEF.java │ │ │ ├── MARCHA1.java │ │ │ ├── MARCHA2.java │ │ │ ├── MAXCOUNT.java │ │ │ ├── MAXDIFF.java │ │ │ ├── MCHAIRS.java │ │ │ ├── MGCRNK.java │ │ │ ├── MIKE1.java │ │ │ ├── MIME2.java │ │ │ ├── MONTRANS.java │ │ │ ├── MSTICK.java │ │ │ ├── MUFFINS3.java │ │ │ ├── NAME1.java │ │ │ ├── NAME2.java │ │ │ ├── NOCODING.java │ │ │ ├── NOLOGIC.java │ │ │ ├── NOTATRI.java │ │ │ ├── NUKES.java │ │ │ ├── NUMGAME.java │ │ │ ├── NUMGAME2.java │ │ │ ├── OJUMPS.java │ │ │ ├── ONEKING.java │ │ │ ├── ONP.java │ │ │ ├── PAIRING.java │ │ │ ├── PERMUT2.java │ │ │ ├── PLAYFIT.java │ │ │ ├── PLZLYKME.java │ │ │ ├── PNTNG.java │ │ │ ├── POINTS.java │ │ │ ├── POTATOES.java │ │ │ ├── PPTEST.java │ │ │ ├── PRGIFT.java │ │ │ ├── PROSUM.java │ │ │ ├── PRPALIN.java │ │ │ ├── PRPOTION.java │ │ │ ├── RECIPE.java │ │ │ ├── REMISS.java │ │ │ ├── RESIST.java │ │ │ ├── RESQ.java │ │ │ ├── RIGHTRI.java │ │ │ ├── ROWCOLOP.java │ │ │ ├── RRCODE.java │ │ │ ├── RRCOPY.java │ │ │ ├── RRECIPE.java │ │ │ ├── RRMATRIX.java │ │ │ ├── RRSTONE.java │ │ │ ├── RRSUM.java │ │ │ ├── SAD.java │ │ │ ├── SALARY.java │ │ │ ├── SEAGRP.java │ │ │ ├── SEAVOTE.java │ │ │ ├── SNAPE.java │ │ │ ├── SPCANDY.java │ │ │ ├── SPOON.java │ │ │ ├── SPRNMBRS.java │ │ │ ├── STONES.java │ │ │ ├── STRBIT.java │ │ │ ├── SUBGCD.java │ │ │ ├── SUMTRAIN.java │ │ │ ├── TAAPLUSB.java │ │ │ ├── TACHSTCK.java │ │ │ ├── TAPALIN.java │ │ │ ├── TAVISUAL.java │ │ │ ├── TEST.java │ │ │ ├── TEST1.java │ │ │ ├── TEST2.java │ │ │ ├── THREEDIFF.java │ │ │ ├── TIDRICE.java │ │ │ ├── TLG.java │ │ │ ├── TMSLT.java │ │ │ ├── TOTR.java │ │ │ ├── TSORT.java │ │ │ ├── TWODOGS.java │ │ │ ├── VOTERS.java │ │ │ ├── WALK.java │ │ │ ├── progtest.java │ │ │ └── scratch.java │ │ ├── MEDIUM │ │ └── src │ │ │ ├── ABROADS.java │ │ │ ├── COALSCAM.java │ │ │ ├── FLIPCOIN.java │ │ │ ├── MARBLES.java │ │ │ ├── RRFRNDS.java │ │ │ ├── SRC2.java │ │ │ └── TWTCLOSE.java │ │ └── PEER │ │ └── src │ │ ├── BYTESD.java │ │ ├── CDSE06.java │ │ ├── GOOGOL05.java │ │ ├── N1.java │ │ ├── SPIT04.java │ │ ├── SPIT1.java │ │ └── SPIT2.java │ ├── CODEFORCES │ ├── C_Practice │ │ └── src │ │ │ ├── ArithmeticProgression.java │ │ │ ├── Bombs.java │ │ │ ├── FixingTypos.java │ │ │ ├── FoxAndBoxAccumulation.java │ │ │ ├── GagariAndBishop.java │ │ │ ├── GivenLengthandSumofDigits.java │ │ │ ├── HackingCypher.java │ │ │ ├── Hamburgers.java │ │ │ ├── HexadecimalsNumbers.java │ │ │ ├── Ktree_431.java │ │ │ ├── LittleElephantAndProblem.java │ │ │ ├── Maze.java │ │ │ ├── NumberOfWays_466_C.cpp │ │ │ ├── PashmakAndBuses.java │ │ │ ├── Team_401.java │ │ │ └── ValeraAndTubes_441.java │ ├── DIV2_217 │ │ └── src │ │ │ ├── A.java │ │ │ ├── B.java │ │ │ └── C.java │ ├── DIV2_298 │ │ └── src │ │ │ ├── A_EXAM.java │ │ │ ├── D_HANDSHAKES.java │ │ │ └── scratch.java │ ├── DIV2_299 │ │ └── src │ │ │ ├── A_TAVAS_AND_NAFAS.java │ │ │ └── B.java │ ├── DIV2_300 │ │ └── src │ │ │ ├── A.java │ │ │ ├── B.java │ │ │ └── C.java │ ├── DIV2_301 │ │ └── src │ │ │ ├── A.java │ │ │ ├── B.java │ │ │ └── C.java │ ├── DIV2_302 │ │ └── src │ │ │ ├── A.java │ │ │ ├── B.java │ │ │ └── C_DP.java │ ├── DIV2_305 │ │ └── src │ │ │ ├── A.java │ │ │ └── B.java │ ├── DIV2_309 │ │ └── src │ │ │ ├── A.java │ │ │ ├── B.java │ │ │ └── C.java │ ├── DIV2_310 │ │ └── src │ │ │ ├── A.java │ │ │ ├── B.java │ │ │ ├── C.java │ │ │ └── D.java │ ├── DIV2_312 │ │ └── src │ │ │ ├── A.java │ │ │ └── B.java │ ├── DIV2_313 │ │ └── src │ │ │ ├── A.java │ │ │ ├── B.java │ │ │ ├── C.java │ │ │ └── D.java │ ├── DIV2_314 │ │ └── src │ │ │ ├── A.java │ │ │ ├── B.java │ │ │ └── C.java │ ├── DIV2_315 │ │ └── src │ │ │ ├── A.java │ │ │ ├── B.java │ │ │ └── C.java │ ├── DIV2_318 │ │ └── src │ │ │ ├── A.java │ │ │ ├── B.java │ │ │ ├── B_2.java │ │ │ └── C.java │ ├── DIV2_327 │ │ └── src │ │ │ ├── A.java │ │ │ ├── B.java │ │ │ └── E.java │ ├── DIV2_328 │ │ └── src │ │ │ ├── A.java │ │ │ ├── B.java │ │ │ └── C.java │ ├── DIV2_329 │ │ └── src │ │ │ └── A.java │ ├── DIV2_330 │ │ └── src │ │ │ ├── A.java │ │ │ └── B.java │ ├── DIV2_332 │ │ └── src │ │ │ ├── A.java │ │ │ └── B.java │ ├── DIV2_335 │ │ └── src │ │ │ ├── A.java │ │ │ ├── B.java │ │ │ ├── C.java │ │ │ └── Ideone.java │ ├── DIV2_337 │ │ └── src │ │ │ ├── A.java │ │ │ ├── B.java │ │ │ └── C.java │ ├── DIV2_339 │ │ └── src │ │ │ ├── A.java │ │ │ ├── B.java │ │ │ └── C.java │ ├── DIV2_365 │ │ ├── A.java │ │ └── B.java │ ├── DIV2_366 │ │ ├── A.java │ │ ├── B.java │ │ └── C.java │ ├── DIV2_371 │ │ ├── A.java │ │ ├── B.java │ │ └── C.java │ ├── DIV2_376 │ │ ├── A.java │ │ ├── B.java │ │ ├── C.java │ │ └── F.java │ ├── DIV2_377 │ │ ├── A.java │ │ ├── B.java │ │ └── C.java │ ├── GOODBYE2015 │ │ └── src │ │ │ ├── A.java │ │ │ ├── B.java │ │ │ └── C.java │ ├── Practice │ │ ├── A_160.java │ │ ├── A_455.java │ │ ├── A_550.java │ │ ├── A_579.java │ │ ├── AlternativeThinking_604_C.java │ │ ├── B_479.java │ │ ├── B_550.java │ │ ├── B_579.java │ │ ├── C_4.java │ │ ├── C_486.java │ │ ├── C_550.java │ │ ├── C_560.java │ │ ├── C_588.java │ │ ├── CutRibbon_189_A.java │ │ ├── DIV2_551_B.java │ │ ├── D_474.java │ │ ├── D_552.java │ │ ├── FlippingGames.java │ │ ├── MoreCowbell_604_B.java │ │ ├── R399_D.java │ │ └── TheTextSplitting.java │ └── Virtual │ │ └── src │ │ └── 288_V │ │ └── src │ │ ├── A.java │ │ ├── B.java │ │ ├── C.java │ │ └── D.java │ ├── DSA │ ├── DP │ │ └── src │ │ │ ├── Coin_Change.java │ │ │ ├── KNAPSACK.java │ │ │ ├── LCS.java │ │ │ ├── LIS.java │ │ │ ├── MAZE.java │ │ │ └── ROD_CUTTING.java │ ├── GRAPH │ │ └── src │ │ │ ├── ADJACENCY_LIST_EXPLAINED.java │ │ │ ├── ADJACENCY_LIST_IMPLEMENTED.java │ │ │ ├── BFS_IMP_1.java │ │ │ ├── BFS_IMP_2.java │ │ │ ├── DFS_1.java │ │ │ ├── DIJKSTRA.java │ │ │ ├── FAST_ADJ_LIST.java │ │ │ ├── FLOYD_WARSHALL.java │ │ │ ├── KRUSKAL.java │ │ │ ├── KragersMinCut.java │ │ │ ├── Tarjan_SCC.java │ │ │ └── test1.java │ ├── MergeSort.java │ ├── PAIR.java │ ├── SEGMENT_TREES.java │ └── TRIE.java │ ├── INTERVIEW │ ├── DS_IMPL │ │ ├── MySinglyLinkedList.java │ │ └── SinglyLinkedLinkedList.java │ └── QUES_TRY │ │ ├── AddTwoNosLL.java │ │ ├── AllPalindromes.java │ │ ├── AssignMiceToHoles.java │ │ ├── BlackShapes.java │ │ ├── BreakStringIntoWords.java │ │ ├── CycleGraph.java │ │ ├── FB1000.java │ │ ├── FBVid.java │ │ ├── GroupSeats.java │ │ ├── IntToRoman.java │ │ ├── LIstCycle.java │ │ ├── Leetcode_UNIVALTREE.java │ │ ├── LinkedListPalindromeLinear.java │ │ ├── MeetingRooms.java │ │ ├── MergeIntervals.java │ │ ├── MergeKLists.java │ │ ├── MergeKSortedLinkedLists.java │ │ ├── MinNumOfCoveringIntervals.java │ │ ├── NQueens.java │ │ ├── NearestSmallestElement.java │ │ ├── PhoneNum.java │ │ ├── PhoneNumberCombination.java │ │ ├── RepeatingFractions.java │ │ ├── ReturnListOfAnagrams.java │ │ ├── ReverseSublist.java │ │ ├── SimplifyPath.java │ │ ├── SortColorsDutchNationalFlag.java │ │ ├── StringAllPalindromes.java │ │ ├── SwapAdjLL.java │ │ ├── TestMySinglyLinkedList.java │ │ ├── ThreeSumAllPairs.java │ │ ├── TreeBal.java │ │ ├── TrieShortestUniquePrefix.java │ │ ├── WildcardMatcher.java │ │ ├── WindowAllChars.java │ │ └── WordBreak.java │ ├── MISC │ ├── AWISSample.java │ ├── BinaryTreeToDoublyLinkedList.java │ ├── FIBal.java │ ├── Facebook Hacker Cup '14 │ │ ├── Facebook Hacker Cup '14.eml │ │ ├── OUTPUT FHC '14 PROB 1.txt │ │ ├── OUTPUT FHC '14 PROB 2.txt │ │ ├── OUTPUT FHC_R1_PRIMALITY.txt │ │ └── src │ │ │ ├── FBHC_R1_PRIMALITY.java │ │ │ ├── R1CookingTheBooks.java │ │ │ ├── R1LaserMaze.java │ │ │ ├── R1NewYearsResolution.java │ │ │ └── scratch1.java │ ├── GOOGLE_CODE_JAM'15 │ │ ├── PROBLEM FILES │ │ │ ├── A │ │ │ │ ├── A-large.in │ │ │ │ ├── A-small-attempt0.in │ │ │ │ ├── A_BIG_CODE.txt │ │ │ │ ├── A_BIG_OP.txt │ │ │ │ ├── A_SMALL_CODE.txt │ │ │ │ └── A_SMALL_OP.txt │ │ │ └── B │ │ │ │ ├── B-small-attempt0.in │ │ │ │ ├── B-small-attempt1.in │ │ │ │ ├── B-small-attempt2.in │ │ │ │ ├── B_SMALL_CODE.txt │ │ │ │ └── B_SMALL_OP.txt │ │ └── src │ │ │ ├── INFINITE_HOUSE_OF_PANCAKES.java │ │ │ └── STANDING_OVATION.java │ ├── ICPC16 │ │ ├── A.java │ │ ├── B.java │ │ └── C.java │ ├── MI1.java │ └── TwitterHR │ │ ├── HackingTime.java │ │ └── Kracken.java │ ├── SPOJ │ └── src │ │ ├── ABCPATH.java │ │ ├── ABSYS.java │ │ ├── ACPC10A.java │ │ ├── ADDREV.java │ │ ├── AE00.java │ │ ├── CAM5.java │ │ ├── CANDY.java │ │ ├── CHICAGO.java │ │ ├── COINS.java │ │ ├── CRDS.java │ │ ├── CSTREET.java │ │ ├── ELIS.java │ │ ├── EZDIJKST.java │ │ ├── FACEFRND.java │ │ ├── FASHION.java │ │ ├── FCTRL.java │ │ ├── FCTRL2.java │ │ ├── GSS1.java │ │ ├── HERDING.java │ │ ├── HORRIBLE.java │ │ ├── JULKA.java │ │ ├── KNAPSACK.java │ │ ├── LASTDIG.java │ │ ├── LCS0.java │ │ ├── MAXSEQ.java │ │ ├── NOCHANGE.java │ │ ├── NSTEPS.java │ │ ├── OLOLO.java │ │ ├── PHONELIST.java │ │ ├── PPATH.java │ │ ├── PRATA.java │ │ ├── PRIME1.java │ │ ├── PRINT.java │ │ ├── PRO.java │ │ ├── SAMER08F.java │ │ ├── SID.java │ │ ├── SPATH.java │ │ ├── STPAR.java │ │ ├── TEST.java │ │ ├── TOANDFRO.java │ │ ├── YODANESS.java │ │ └── testgen.java │ ├── TOPCODER │ └── src │ │ ├── ANDEquation.java │ │ ├── AccessChanger.java │ │ ├── AccessLevel.java │ │ ├── AccountBalance.java │ │ ├── AdditionCycles.java │ │ ├── AdditionGame.java │ │ ├── AimToTen.java │ │ ├── ColoredStrokes.java │ │ ├── CostOfDancing.java │ │ ├── Cyclemin.java │ │ ├── DistanceBetweenStrings.java │ │ ├── FindTriangle.java │ │ ├── HuffmanDecoding.java │ │ ├── InfStr.py │ │ ├── InfiniteString.java │ │ ├── LargestSubsequence.java │ │ ├── LeftOrRight.java │ │ ├── LittleElephantAndDouble.java │ │ ├── LuckyXor.java │ │ ├── MutaliskEasy.java │ │ ├── PipeCuts.java │ │ ├── PrimeSoccer.java │ │ ├── PrivateD2party.java │ │ ├── RabbitNumbering.java │ │ ├── SquareScoresDiv2.java │ │ ├── TheAirTripDivTwo.java │ │ ├── UniqueDigits.java │ │ └── grafixCorrupt.java │ └── input.txt ├── README.md └── Settings-Template-Docs ├── CP Topics.docx ├── DP.docx ├── FAST IO TEMPLATE INTELLIJ.txt ├── ICPC_Codes.md ├── Problems.docx ├── cpp.sublime-snippet └── settings.jar /Code/Code.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/C++ Files.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/CC/A2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define ReadFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 4 | #define BoostIO ios_base::sync_with_stdio(false) 5 | #define endl '\n' 6 | 7 | typedef long long int ll; 8 | 9 | //Created by Shreyans Sheth [bholagabbar] 10 | 11 | ll a[1000005]; 12 | 13 | int main() 14 | { 15 | BoostIO; 16 | //ReadFile; 17 | int tc; 18 | cin>>tc; 19 | ll x; 20 | ll p; 21 | x=pow(2,p); 22 | cout< 11 | using namespace std; 12 | #define readFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 13 | #define boostIO ios_base::sync_with_stdio(false) 14 | #define ld long double 15 | #define ll long long int 16 | #define CLR(s) memset(&s, 0, sizeof(s)) 17 | #define scani(s) scanf("%d",&s) 18 | #define scanl(s) scanf("%lld",&s) 19 | #define hashset unordered_set //JAVA feels :') 20 | #define hashmap unordered_map 21 | #define pll pair 22 | #define pii pair 23 | #define pb push_back 24 | #define mp make_pair 25 | #define F first 26 | #define S second 27 | #define endl '\n' 28 | 29 | int main() 30 | { 31 | //readFile; 32 | boostIO; 33 | int tc; 34 | cin>>tc; 35 | while(tc--) 36 | { 37 | int n,p,cnt=0; 38 | cin>>n>>p; 39 | int temp; 40 | for(int i=0;i>temp; 43 | if(temp>=p) 44 | cnt++; 45 | } 46 | cout< 9 | using namespace std; 10 | #define readFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 11 | #define boostIO ios_base::sync_with_stdio(false) 12 | #define ld long double 13 | #define ll long long int 14 | #define CLR(s) memset(&s, 0, sizeof(s)) 15 | #define scani(s) scanf("%d",&s) 16 | #define scanl(s) scanf("%lld",&s) 17 | #define hashset unordered_set //JAVA feels :') 18 | #define hashmap unordered_map 19 | #define pll pair 20 | #define pii pair 21 | #define pb push_back 22 | #define mp make_pair 23 | #define F first 24 | #define S second 25 | #define endl '\n' 26 | 27 | int main() 28 | { 29 | //readFile; 30 | boostIO; 31 | int tc; 32 | cin>>tc; 33 | while(tc--) 34 | { 35 | int n; 36 | cin>>n; 37 | ll a[n]; 38 | for(int i=0;i>a[i]; 40 | sort(a,a+n); 41 | ll sum=a[n-1]+a[n-2]+a[n-3]; 42 | cout< 2 | #include 3 | #include 4 | using namespace std; 5 | int main() 6 | { 7 | int x; 8 | cin>>x; 9 | while(x--) 10 | { 11 | int n; 12 | cin>>n; 13 | string s[n]; 14 | for(int j=0;j>s[j]; 17 | } 18 | sort(s, s+n); 19 | for(int j=0;j 2 | using namespace std; 3 | #define ReadFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 4 | #define BoostIO ios_base::sync_with_stdio(false) 5 | #define endl '\n' 6 | 7 | typedef long long int ll; 8 | 9 | //Created by Shreyans Sheth [bholagabbar] 10 | 11 | int main() 12 | { 13 | BoostIO; 14 | //ReadFile; 15 | int n,x,y; 16 | cin>>n>>x; 17 | string s; 18 | cin>>s; 19 | int a[n+1][10]={0}; 20 | for(int i=1;i<=n;i++) 21 | { 22 | y=s[i-1]-48; 23 | a[i][y]++; 24 | for(int j=0;j<10;j++) 25 | a[i][j]+=a[i-1][j]; 26 | } 27 | while(x--) 28 | { 29 | cin>>y; 30 | ll sum=0; 31 | int x1=s[y-1]-48; 32 | for(int i=0;i<10;i++) 33 | sum+=(ll)a[y][i]*(ll)abs(x1-i); 34 | cout< 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | ios_base::sync_with_stdio(false);cin.tie(0); 7 | int t; 8 | cin>>t; 9 | while(t--) 10 | { 11 | int n,k; 12 | cin>>n>>k; 13 | if(k==1&&n==1) 14 | { 15 | cout<<"1\n"; 16 | } 17 | else 18 | { 19 | if(k>(n/2)) 20 | { 21 | cout<<"-1\n"; 22 | } 23 | else 24 | { 25 | int x=2; 26 | int cnt=0; 27 | while(cnt!=k) 28 | { 29 | cout< 9 | using namespace std; 10 | #define ReadFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 11 | #define BoostIO ios_base::sync_with_stdio(false) 12 | #define pb emplace_back 13 | #define mp make_pair 14 | #define pii pair 15 | #define endl '\n' 16 | 17 | typedef long long int ll; 18 | const double ia=1000000000.0; 19 | //Created by Shreyans Sheth [bholagabbar] 20 | 21 | int main() 22 | { 23 | BoostIO; 24 | //ReadFile; 25 | int tc; 26 | cin>>tc; 27 | while(1) 28 | { 29 | int m; 30 | double p; 31 | cin>>m>>p; 32 | if(m==1) 33 | { 34 | printf("%.2f 0.00\n",ia); 35 | } 36 | else if(m==2) 37 | { 38 | double f=(p)*ia; 39 | double c=(1.0-p)*ia; 40 | printf("%.2f %.2f\n",c,f); 41 | } 42 | else if(m==3) 43 | { 44 | double f=(p-(p*p*p))*ia; 45 | double c=(1.0-p+(p*p*p))*ia; 46 | printf("%.2f %.2f\n",c,f); 47 | } 48 | else 49 | { 50 | cout<<"1\n"; 51 | } 52 | } 53 | return 0; 54 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/CC/BRCD2015.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() 4 | { 5 | int t; 6 | scanf("%d",&t); 7 | while(t--) 8 | { 9 | int o,r,s; 10 | scanf("%d%d%d",&o,&r,&s); 11 | double ans=((r*o+s)/(o+1)); 12 | printf("%0.2d \n",ans); 13 | } 14 | return 0; 15 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/CC/CANDLE.cpp: -------------------------------------------------------------------------------- 1 | /*input 2 | 1 3 | 1 2 3 4 1 2 3 1 4 1 4 | */ 5 | #include 6 | #include 7 | #include 8 | int main() 9 | { 10 | int t; 11 | scanf("%d",&t); 12 | int i=0; 13 | for(i=0;i-1) 30 | { 31 | a[cnt]=j2%10; 32 | j2=j2/10; 33 | cnt--; 34 | } 35 | int s2[10]; 36 | int u=0; 37 | for(u=0;u<10;u++) 38 | { 39 | s2[u]=s[u]; 40 | } 41 | for(k=0;k 2 | #include 3 | #include 4 | int main() 5 | { 6 | char s[1000000]; 7 | int n; 8 | scanf("%s",&s); 9 | std::set st; 10 | for(int j=0;j 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | ios_base::sync_with_stdio(false);cin.tie(0); 7 | int t; 8 | cin>>t; 9 | while(t--) 10 | { 11 | string a; 12 | cin>>a; 13 | int ans=0; 14 | if(a.size()==1) 15 | { 16 | ans=0; 17 | } 18 | else 19 | { 20 | for(int i=0;i 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | ios_base::sync_with_stdio(false);cin.tie(0);//FAST IO 7 | int t; 8 | cin>>t; 9 | while(t--) 10 | { 11 | long n; 12 | cin>>n; 13 | string s; 14 | while(n>0) 15 | { 16 | long temp=n%2; 17 | s+=(char)(temp+48); 18 | n=n/2; 19 | } 20 | int cnt=0; 21 | int i=0; 22 | while(s.at(i)=='0') 23 | { 24 | i++; 25 | } 26 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | ios_base::sync_with_stdio(false);cin.tie(0);//FAST IO 6 | int t; 7 | cin>>t; 8 | while(t--) 9 | { 10 | string s; 11 | cin>>s; 12 | vector al; 13 | vector num; 14 | for(int i=0;i=48 &&s.at(i)<=57) 17 | { 18 | num.push_back(s.at(i)); 19 | } 20 | else 21 | { 22 | al.push_back(s.at(i)); 23 | } 24 | } 25 | sort(num.begin(),num.end()); 26 | sort(al.begin(),al.end()); 27 | 28 | stack ans; 29 | 30 | for(int i=s.size()-1;i>=0;i--) 31 | { 32 | if(s.at(i)>=48 &&s.at(i)<=57) 33 | { 34 | ans.push(num.at(num.size()-1)); 35 | num.pop_back(); 36 | } 37 | else 38 | { 39 | ans.push(al.at(al.size()-1)); 40 | al.pop_back(); 41 | } 42 | } 43 | while(!ans.empty()) 44 | { 45 | cout< 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | ios_base::sync_with_stdio(false);cin.tie(0);//FAST IO 7 | int t; 8 | cin>>t; 9 | while(t--) 10 | { 11 | int n; 12 | cin>>n; 13 | int a[n-1]; 14 | for(int i=0;i>a[i]; 17 | } 18 | sort(a,(a+n-1)); 19 | for(int i=1;i<=n;i++) 20 | { 21 | if(a[i-1]!=i) 22 | { 23 | cout< 4 | using namespace std; 5 | //MACROS 6 | #define endl '\n' 7 | 8 | int main() 9 | { 10 | ios_base::sync_with_stdio(false);//FAST IO 11 | //cin.tie(NULL);//Untie streams before submission 12 | int t; 13 | cin>>t; 14 | while(t--) 15 | { 16 | int n,m; 17 | cin>>n>>m; 18 | int h[m+1]; 19 | int c[m+1]; 20 | for(int i=1;i<=m;i++) 21 | { 22 | cin>>h[i]>>c[i]; 23 | } 24 | int dp[m+1][n+1]; 25 | for(int i=0;i<=m;i++) 26 | { 27 | dp[i][0]=0; 28 | } 29 | for(int i=0;i<=n;i++) 30 | { 31 | dp[0][i]=0; 32 | } 33 | for(int i=1;i<=m;i++) 34 | { 35 | for(int j=1;j<=n;j++) 36 | { 37 | if(h[i]<=j) 38 | { 39 | dp[i][j]=max(dp[i-1][j], c[i]+dp[i-1][j-h[i]]); 40 | } 41 | else 42 | { 43 | dp[i][j]=dp[i-1][j]; 44 | } 45 | } 46 | } 47 | cout< 10 | using namespace std; 11 | #define endl '\n' 12 | 13 | //Created by Shreyans Sheth [bholagabbar] using Sublime 3 and SublimeInput Plugin 14 | 15 | int main() 16 | { 17 | ios_base::sync_with_stdio(false);//FAST IO 18 | int tc; 19 | cin>>tc; 20 | while(tc--) 21 | { 22 | int n,x; 23 | cin>>n; 24 | set ans; 25 | for(int i=0;i>x; 28 | ans.insert(x); 29 | } 30 | cout< 2 | #define endl '\n' 3 | using namespace std; 4 | int main() 5 | { 6 | ios_base::sync_with_stdio(false);//FAST IO 7 | //cin.tie(NULL);//Untie streams before submitting 8 | int t; 9 | cin>>t; 10 | while(t--) 11 | { 12 | int n,m; 13 | cin>>n>>m; 14 | int a[n]; 15 | int max=-1; 16 | for(int i=0;i>a[i]; 19 | if(a[i]>max) 20 | { 21 | max=a[i]; 22 | } 23 | } 24 | int flag=1; 25 | for(int i=0;i0&&m%n!=0)) 37 | { 38 | flag=0; 39 | } 40 | if(flag==1) 41 | { 42 | cout<<"Yes"< 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int t; 7 | scanf("%d",&t); 8 | while(t--) 9 | { 10 | int n; 11 | scanf("%d",&n); 12 | int a[n]; 13 | for(int j=0;j 2 | #include 3 | using namespace std; 4 | #define endl '\n' 5 | #define cout cout.flush() 6 | 7 | int main() 8 | { 9 | ios_base::sync_with_stdio(false);cin.tie(NULL);//FAST IO 10 | while(t--) 11 | { 12 | 13 | long long n; 14 | cin>>n; 15 | long long j=(long long)sqrt(n); 16 | long long ans=0; 17 | for(long long i=1;i<=j;i++) 18 | { 19 | if(n%i==0) 20 | { 21 | ans+=i; 22 | if(i!=(n/i))//dont double count square roots 23 | { 24 | ans+=(n/i); 25 | } 26 | } 27 | } 28 | cout< 2 | using namespace std; 3 | 4 | //Created by Shreyans Sheth [bholagabbar] using Sublime 3 5 | 6 | int main() 7 | { 8 | ios_base::sync_with_stdio(false);cin.tie(NULL);//FAST IO 9 | int tc; 10 | cin>>tc; 11 | while(tc--) 12 | { 13 | long long a; 14 | long long b; 15 | cin>>a>>b; 16 | if(b==1) 17 | { 18 | cout<<"Yes\n"; 19 | continue; 20 | } 21 | else if(a==1) 22 | { 23 | cout<<"No\n"; 24 | continue; 25 | } 26 | long long x=a; 27 | int flag=1; 28 | while(x>1) 29 | { 30 | x=__gcd(x,b); 31 | b/=x; 32 | if(x==1&&b>1) 33 | { 34 | flag=0; 35 | break; 36 | } 37 | } 38 | if(flag==1) 39 | { 40 | cout<<"Yes\n"; 41 | } 42 | else 43 | { 44 | cout<<"No\n"; 45 | } 46 | } 47 | return 0; 48 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/CC/CHEFTREE.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bholagabbar/algorithmic-programming/a5482cca93f79ec8495256fa1a08525e61bfb899/Code/WorkspaceB/C++_Files/CC/CHEFTREE.cpp -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/CC/CLMBSTRS.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define ReadFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 4 | #define endl '\n' 5 | #define MOD 1000000007 6 | #define size 1000005 7 | 8 | typedef long long int ll; 9 | 10 | //Created by Shreyans Sheth (bholagabbar) 11 | 12 | ll f[size]; 13 | 14 | void CalculateFib() 15 | { 16 | f[0]=1; 17 | f[1]=1; 18 | for(ll i=2;i0) 26 | { 27 | if(x%2!=0) 28 | cnt++; 29 | x/=2; 30 | } 31 | return cnt; 32 | } 33 | 34 | int main() 35 | { 36 | ios_base::sync_with_stdio(false); 37 | //ReadFile; 38 | CalculateFib(); 39 | int tc; 40 | cin>>tc; 41 | while(tc--) 42 | { 43 | ll n,k; 44 | cin>>n>>k; 45 | int m=OnesinBase2(f[n]); 46 | if(m==k) 47 | cout<<"CORRECT\n"; 48 | else 49 | cout<<"INCORRECT\n"; 50 | } 51 | return 0; 52 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/CC/DEVUGRAP.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define endl '\n' 4 | 5 | //Created by Shreyans Sheth [bholagabbar] using Sublime 3 and SublimeInput Plugin 6 | 7 | int main() 8 | { 9 | ios_base::sync_with_stdio(false);//FAST IO 10 | int tc; 11 | cin>>tc; 12 | while(tc--) 13 | { 14 | long n,k; 15 | cin>>n>>k; 16 | long long a[n]; 17 | long long sum=0; 18 | for(long i=0;i>a[i]; 21 | if(a[i]>=k) 22 | { 23 | long long m=a[i]%k; 24 | sum+=min(m,(k-m)); 25 | } 26 | else 27 | { 28 | sum+=(k-a[i]); 29 | } 30 | } 31 | cout< 2 | #include 3 | int main() 4 | { 5 | int i=0,wit=0; 6 | float bal=0; 7 | scanf("%d",&wit); 8 | scanf("%f",&bal); 9 | if(((wit>0)&&(wit<=2000))&&((bal>=0)&&(bal<=2000))) 10 | { 11 | if((bal>=((wit+0.5))&&(wit%5==0))) 12 | { 13 | float ans=round(((bal-wit)-(0.50))*100.0)/100.0; 14 | printf("%.2f",ans); 15 | } 16 | else if(((wit+0.5)>bal)) 17 | { 18 | bal=round(bal*100.0)/100.0; 19 | printf("%.2f",bal); 20 | } 21 | else if(((int)wit%5!=0)) 22 | { 23 | bal=round(bal*100.0)/100.0; 24 | printf("%.2f",bal); 25 | } 26 | } 27 | return (0); 28 | } 29 | 30 | 31 | -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/CC/EGBOBRD.cpp: -------------------------------------------------------------------------------- 1 | /*input 2 | 3 3 | 3 4 4 | 3 1 2 5 | 1 1 6 | 1 7 | 2 4 8 | 8 8 9 | */ 10 | #include 11 | using namespace std; 12 | 13 | int main() 14 | { 15 | ios_base::sync_with_stdio(false);//FAST IO 16 | int tc; 17 | cin>>tc; 18 | while(tc--) 19 | { 20 | long long n,k; 21 | cin>>n>>k; 22 | long long arr[n]; 23 | for(int i=0;i>arr[i]; 26 | } 27 | long long c=0,r=0; 28 | for(int i=0;i=k) 31 | { 32 | c+=r/k; 33 | r=r%k; 34 | } 35 | c+=arr[i]/k; 36 | r+=arr[i]%k+1; 37 | } 38 | if(r-1>=k) 39 | { 40 | c+=r/k; 41 | } 42 | cout< 11 | using namespace std; 12 | #define endl '\n' 13 | 14 | //Created by Shreyans Sheth [bholagabbar] using Sublime 3 and SublimeInput Plugin 15 | 16 | int main() 17 | { 18 | ios_base::sync_with_stdio(false);//FAST IO 19 | int t; 20 | cin>>t; 21 | while(t--) 22 | { 23 | int n; 24 | cin>>n; 25 | int a[n]; 26 | long long sum=0; 27 | for(int i=0;i>a[i]; 30 | sum+=a[i]; 31 | } 32 | if(sum%n==0) 33 | { 34 | int cnt=0; 35 | for(;;) 36 | { 37 | int mx=0,mn=INT_MAX,mxi=0,mni=0; 38 | for(int i=0;imx) 41 | { 42 | mx=a[i]; 43 | mxi=i; 44 | } 45 | if(a[i] 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int n,m; 7 | scanf("%d%d",&n,&m); 8 | int a[n]; 9 | for(int j=0;j 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int t; 7 | scanf("%d",&t); 8 | while(t--) 9 | { 10 | int n; 11 | scanf("%d",&n); 12 | int a[n]; 13 | for(int j=0;j 7 | using namespace std; 8 | #define readFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 9 | #define boostIO ios_base::sync_with_stdio(false) 10 | #define ld long double 11 | #define ll long long int 12 | #define CLR(s) memset(&s, 0, sizeof(s)) 13 | #define scani(s) scanf("%d",&s) 14 | #define scanl(s) scanf("%lld",&s) 15 | #define hashset unordered_set //JAVA feels :') 16 | #define hashmap unordered_map 17 | #define pll pair 18 | #define pii pair 19 | #define pb push_back 20 | #define mp make_pair 21 | #define F first 22 | #define S second 23 | #define endl '\n' 24 | 25 | const ll MOD=1000000007; 26 | ll dp[100005]; 27 | 28 | int main() 29 | { 30 | //readFile; 31 | boostIO; 32 | int tc; 33 | cin>>tc; 34 | while(tc--) 35 | { 36 | int n,cnt; 37 | ll k,val=1; 38 | cin>>n>>k; 39 | n%2==0?cnt=1:cnt=-1; 40 | for(int i=1;i 11 | using namespace std; 12 | #define endl '\n' 13 | 14 | //Created by Shreyans Sheth [bholagabbar] using Sublime 3 and SublimeInput Plugin 15 | 16 | int main() 17 | { 18 | ios_base::sync_with_stdio(false);//FAST IO 19 | int tc; 20 | cin>>tc; 21 | while(tc--) 22 | { 23 | int n,m; 24 | cin>>n>>m; 25 | char a[n][m]; 26 | string x; 27 | for(int i=0;i>x; 30 | for(int j=0;j=n) 42 | break; 43 | 44 | for(int j=0;j=m) 47 | break; 48 | 49 | if(a[i][j]==a[i][j+k] && a[i][j]==a[i+k][j] && a[i][j]==a[i+k][j+k]) 50 | { 51 | cnt++; 52 | } 53 | } 54 | } 55 | } 56 | cout< 9 | using namespace std; 10 | #define endl '\n' 11 | #define pb emplace_back 12 | 13 | //Created by Shreyans Sheth [bholagabbar] using Sublime 3 and SublimeInput Plugin 14 | 15 | int main() 16 | { 17 | ios_base::sync_with_stdio(false);//FAST IO 18 | vector predef; 19 | float cnt=2; 20 | float sum=0; 21 | while(sum<=5.20) 22 | { 23 | sum+=(1/cnt); 24 | predef.pb(sum); 25 | cnt++; 26 | } 27 | float n; 28 | cin>>n; 29 | while(n!=0) 30 | { 31 | int c=0; 32 | while(predef[c]<=n) 33 | { 34 | c++; 35 | } 36 | cout<<(c+1)<<" card(s)\n"; 37 | cin>>n; 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/CC/KPRIME.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | using namespace std; 4 | 5 | bool p[100001]; 6 | int size=100000; 7 | void SOE(); 8 | 9 | int main() 10 | { 11 | ios_base::sync_with_stdio(false);//FAST IO 12 | cin.tie(NULL); 13 | SOE(); 14 | int a[100001]={0}; 15 | for(int i=2;i<=100000;i++) 16 | { 17 | if(p[i]) 18 | { 19 | a[i]=1; 20 | } 21 | else 22 | { 23 | for(int j=2;j<=(i/2);j++) 24 | { 25 | if((p[j])&&(i%j==0)) 26 | { 27 | a[i]++; 28 | } 29 | } 30 | } 31 | } 32 | int t; 33 | cin>>t; 34 | while(t--) 35 | { 36 | int l,r,k,ans=0;; 37 | cin>>l>>r>>k; 38 | for(int i=l;i<=r;i++) 39 | { 40 | if(a[i]==k) 41 | { 42 | ans++; 43 | } 44 | } 45 | cout< 2 | using namespace std; 3 | 4 | typedef long long int ll; 5 | const ll MOD=(ll)(1e9+7); 6 | 7 | ll l[1001]={0},u[1001]={0},sum[1002]={0}; 8 | ll dp[1001][1001]={0}; 9 | 10 | int main() 11 | { 12 | ios_base::sync_with_stdio(false); 13 | int n,m,c,x; 14 | cin>>n>>m>>c; 15 | for(int i=0;i>x; 18 | l[x]++; 19 | } 20 | for(int i=0;i>x; 23 | u[x]++; 24 | } 25 | dp[0][1000]=sum[1000]=u[1000]*l[1000]; 26 | for(int i=999;i>=1;i--) 27 | { 28 | sum[i]=u[i]*l[i]; 29 | dp[0][i]=(dp[0][i+1]%MOD+(sum[i])%MOD)%MOD; 30 | } 31 | for(int i=1;i<=c;i++) 32 | { 33 | for(int j=1000-i;j>=1;j--) 34 | dp[i][j]=(dp[i][j+1]%MOD+(sum[j]%MOD*dp[i-1][j+1]%MOD)%MOD)%MOD; 35 | cout< 7 | #include 8 | using namespace std; 9 | int main() 10 | { 11 | ios_base::sync_with_stdio(false);cin.tie(0); 12 | int t; 13 | cin>>t; 14 | while(t--) 15 | { 16 | long long x, y; 17 | cin>>x>>y; 18 | if(y==0) 19 | { 20 | cout<<"1\n"; 21 | } 22 | else 23 | { 24 | int a[10]; 25 | int con[10]; 26 | for(int i=0;i<10;i++) 27 | { 28 | a[i]=con[i]=0; 29 | } 30 | int cnt=0; 31 | for(int i=1;;i++) 32 | { 33 | long long temp=ceil(pow(x,i)); 34 | //cout< 9 | using namespace std; 10 | #define endl '\n' 11 | 12 | //Created by Shreyans Sheth [bholagabbar] using Sublime 3 and SublimeInput Plugin 13 | 14 | int main() 15 | { 16 | ios_base::sync_with_stdio(false);//FAST IO 17 | int tc; 18 | cin>>tc; 19 | while(tc--) 20 | { 21 | long n; 22 | cin>>n; 23 | long a[n]; 24 | for(int i=0;i>a[i]; 27 | } 28 | long f=0; 29 | int flag=1; 30 | for(int i=0;i 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | ios_base::sync_with_stdio(false);cin.tie(0);//okay it halved my time so it's fast 7 | int t; 8 | cin>>t; 9 | while(t--) 10 | { 11 | int n; 12 | cin>>n; 13 | int a[n]; 14 | for(int i=0;i>a[i]; 17 | } 18 | std::sort(a, a+n); 19 | int max=0; 20 | int no=a[0]; 21 | int cnt=1; 22 | for(int j=1;jmax) 31 | { 32 | no=a[j-1]; 33 | max=cnt; 34 | } 35 | cnt=1; 36 | } 37 | } 38 | if(cnt>max) 39 | { 40 | max=cnt; 41 | no=a[n-1]; 42 | } 43 | cout< 16 | using namespace std; 17 | #define endl '\n' 18 | 19 | //Created by Shreyans Sheth [bholagabbar] 20 | 21 | int main() 22 | { 23 | ios_base::sync_with_stdio(false); 24 | //freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 25 | int n,q; 26 | cin>>n>>q; 27 | unordered_map m; 28 | unordered_map::iterator it; 29 | for(int i=0;i>x>>y; 33 | m[x]=y; 34 | } 35 | for(int i=0;i>x; 39 | size_t g=x.find_last_of('.'); 40 | if(g!=string::npos) 41 | { 42 | string y=x.substr(g+1,x.size()-g); 43 | it=m.find(y); 44 | if(it==m.end()) 45 | cout<<"unknown\n"; 46 | else 47 | cout< 7 | #include 8 | using namespace std; 9 | #define endl '\n' 10 | 11 | //Created by Shreyans Sheth [bholagabbar] using Sublime 3 and SublimeInput Plugin 12 | 13 | int main() 14 | { 15 | int t; 16 | scanf("%d",&t); 17 | while(t--) 18 | { 19 | int a,b,c; 20 | scanf("%d%d%d",&a,&b,&c); 21 | int ans=0,cnt=0; 22 | float f=(float)(a*100.0+b); 23 | float max=f; 24 | while(cnt<10000 && (a>0||b>=c)) 25 | { 26 | if(b>=c) 27 | { 28 | b-=c; 29 | } 30 | else 31 | { 32 | b+=100; 33 | b-=c; 34 | a-=1; 35 | } 36 | swap(a,b); 37 | cnt++; 38 | f=(float)(a*100.0+b); 39 | if(f>max) 40 | { 41 | max=f; 42 | ans=cnt; 43 | } 44 | } 45 | printf("%d\n",ans); 46 | } 47 | 48 | return 0; 49 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/CC/NUKES.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,n,k; 5 | scanf("%d",&a); 6 | scanf("%d",&n); 7 | scanf("%d",&k); 8 | int p[k+1]; 9 | int i=0; 10 | for(i=0;i n) 25 | { 26 | while (p[cnt] > n && cnt < k) 27 | { 28 | p[cnt] = 0; 29 | p[cnt+1]++; 30 | cnt++; 31 | } 32 | } 33 | } 34 | } 35 | for(i=0;i 15 | using namespace std; 16 | #define endl '\n' 17 | 18 | //Created by Shreyans Sheth [bholagabbar] using Sublime 3 and SublimeInput Plugin 19 | 20 | int main() 21 | { 22 | ios_base::sync_with_stdio(false);//FAST IO 23 | int tc; 24 | cin>>tc; 25 | while(tc--) 26 | { 27 | int n,m,x,y,flag=1; 28 | cin>>n>>m; 29 | int s[n]; 30 | int a[n]; 31 | for(int i=1;i<=n;i++) 32 | { 33 | s[i-1]=i; 34 | } 35 | for(int i=0;i>a[i]; 38 | } 39 | for(int i=0;i>x>>y; 42 | sort(a+x-1,a+y); 43 | } 44 | for(int i=0;i 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | ios_base::sync_with_stdio(false);cin.tie(0); 7 | int t; 8 | cin>>t; 9 | while(t--) 10 | { 11 | int n,k; 12 | cin>>n>>k; 13 | int a[n]; 14 | int cnt=0; 15 | for(int i=0;i>a[i]; 18 | if(a[i]%2==0) 19 | { 20 | cnt++; 21 | } 22 | } 23 | if((k>0&&cnt>=k)||(k==0&&cnt 2 | #include 3 | #define endl '\n' 4 | using namespace std; 5 | int main() 6 | { 7 | ios_base::sync_with_stdio(false);//FAST IO 8 | ifstream infile; 9 | infile.open("pr.txt"); 10 | string x; 11 | while(!infile.eof()) 12 | { 13 | infile>>x; 14 | cout< 11 | using namespace std; 12 | #define endl '\n' 13 | 14 | //Created by Shreyans Sheth [bholagabbar] using Sublime 3 and SublimeInput Plugin 15 | 16 | int main() 17 | { 18 | ios_base::sync_with_stdio(false);//FAST IO 19 | int t; 20 | cin>>t; 21 | while(t--) 22 | { 23 | int n; 24 | cin>>n; 25 | int cnt0=0,cnt1=0,cnt2=0,x; 26 | for(int i=0;i>x; 29 | if (x==0) 30 | cnt0++; 31 | else if (x==1) 32 | cnt1++; 33 | else if(x==2) 34 | cnt2++; 35 | } 36 | long long sum=((n*(n-1))/2)-((cnt0+cnt1)*(n-1))-((cnt2*(cnt2-1))/2)+((cnt0*(cnt0-1))/2)+((cnt1*(cnt1-1))/2); 37 | cout< 13 | using namespace std; 14 | #define endl '\n' 15 | 16 | int u[100000]; 17 | 18 | void init(int n) 19 | { 20 | for(int i=0;i<=n;i++) 21 | { 22 | u[i]=i; 23 | } 24 | } 25 | 26 | 27 | int FIND(int x) 28 | { 29 | if(u[x]!=u[u[x]]) 30 | { 31 | u[x]=FIND(u[x]); 32 | } 33 | return u[x]; 34 | } 35 | 36 | bool UNION(int x, int y) 37 | { 38 | int px=FIND(x); 39 | int py=FIND(y); 40 | 41 | if(px==py) 42 | return false; 43 | 44 | u[px]=py; 45 | return true; 46 | } 47 | 48 | 49 | //Created by Shreyans Sheth [bholagabbar] using Sublime 3 and SublimeInput Plugin 50 | 51 | int main() 52 | { 53 | ios_base::sync_with_stdio(false);//FAST IO 54 | int n,m,a,b; 55 | cin>>n>>m; 56 | init(n); 57 | int flag=1; 58 | for(int i=0;i>a>>b; 61 | if(flag==1) 62 | { 63 | if(!UNION(a,b)) 64 | { 65 | flag=0; 66 | } 67 | } 68 | } 69 | if(flag==0) 70 | { 71 | cout<<"NO\n"; 72 | } 73 | else 74 | { 75 | cout<<"YES\n"; 76 | } 77 | return 0; 78 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/CC/RGAME.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | typedef long long ll; 5 | 6 | const int N=100005; 7 | const ll MOD=1e9+7; 8 | 9 | ll a[N]; 10 | ll dp[N]; 11 | 12 | int main() { 13 | ios_base::sync_with_stdio(0), cin.tie(0); 14 | int tc, n; 15 | ll pre, pow2; 16 | cin >> tc; 17 | while (tc--) { 18 | cin >> n; 19 | for (int i = 0; i <= n; i++) { 20 | cin >> a[i]; 21 | } 22 | dp[1] = a[0]*a[1] + a[1]*a[0]; 23 | pre = 2* (a[0] + a[1]); 24 | pow2 = 4; 25 | for (int i = 2; i <= n; i++) { 26 | dp[i] = (2 * (dp[i-1] % MOD) + (a[i] % MOD * pre % MOD) % MOD) % MOD; 27 | pre = (pre % MOD + (pow2 % MOD * a[i] % MOD) % MOD) % MOD; 28 | pow2 = (pow2 % MOD * 2) % MOD; 29 | } 30 | dp[n] %= MOD; 31 | cout << dp[n] << "\n"; 32 | } 33 | return 0; 34 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/CC/RRFRNDS.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | ios_base::sync_with_stdio(false);cin.tie(NULL); 6 | int v; 7 | cin>>v; 8 | bitset<2001>gr[v]; 9 | string x; 10 | for(int i=0;i>x; 13 | for(int j=0;j0) 29 | { 30 | cnt+=2; 31 | } 32 | } 33 | } 34 | } 35 | cout< 2 | int main() 3 | { 4 | int r,c; 5 | scanf("%d%d",&r,&c); 6 | long a[r][c]; 7 | for(int i=0;imax) 22 | { 23 | max=a[j][i]; 24 | } 25 | } 26 | co[i]=max; 27 | } 28 | for(int i=0;i 4 | using namespace std; 5 | //MACROS 6 | #define endl '\n' 7 | #define cout cout.flush() 8 | 9 | int main() 10 | { 11 | ios_base::sync_with_stdio(false);cin.tie(NULL);//FAST IO 12 | string a; 13 | cin>>a; 14 | if(a.size()<5) 15 | { 16 | cout<<"NO"; 17 | } 18 | else 19 | { 20 | int b=0,s=0,n=0; 21 | for(int i=0;i=97&&a.at(i)<=122) 24 | { 25 | s++; 26 | } 27 | else if(a.at(i)>=65&&a.at(i)<=90) 28 | { 29 | b++; 30 | } 31 | else if(a.at(i)>=48&&a.at(i)<=57) 32 | { 33 | n++; 34 | } 35 | } 36 | if(b>0&&s>0&&n>0) 37 | { 38 | cout<<"YES"; 39 | } 40 | else 41 | { 42 | cout<<"NO"; 43 | } 44 | } 45 | return 0; 46 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/CC/SUBANAGR.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | ios_base::sync_with_stdio(false);//FAST IO 6 | int n; 7 | cin>>n; 8 | int a[n][26]; 9 | for(int i=0;i>x; 20 | for(int j=0;ja[j][i]) 40 | { 41 | cnt=a[j][i]; 42 | } 43 | } 44 | } 45 | if(flag==1) 46 | { 47 | for(int j=0;j 9 | using namespace std; 10 | 11 | typedef long long int ll; 12 | 13 | int main() 14 | { 15 | int n,t; 16 | scanf("%d",&t); 17 | while(t--) 18 | { 19 | scanf("%d",&n); 20 | ll x,x1,cnt=1,ans=0; 21 | scanf("%lld",&x); 22 | for(int i=1;i=x) 26 | cnt++; 27 | else 28 | { 29 | ans+=(cnt*(cnt+1))/2; 30 | cnt=1; 31 | } 32 | x=x1; 33 | } 34 | ans+=(cnt*(cnt+1))/2; 35 | printf("%lld\n",ans); 36 | } 37 | return 0; 38 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/CC/TASHIFT.cpp: -------------------------------------------------------------------------------- 1 | /*input 2 | 5 3 | ccadd 4 | bddcc 5 | */ 6 | #include 7 | using namespace std; 8 | #define endl '\n' 9 | 10 | //Created by Shreyans Sheth [bholagabbar] using Sublime 3 and SublimeInput Plugin 11 | 12 | int z[5000000]; 13 | int main() 14 | { 15 | - ios_base::sync_with_stdio(false);//FAST IO 16 | int n; 17 | string a,b; 18 | cin>>n>>a>>b; 19 | string s=a+"$"+b+b; 20 | n*=3; 21 | int ans=0,max=INT_MIN; 22 | for(int i=1,l=0,r=0;ir) 30 | r=i+z[i]-1,l=i; 31 | if(i>a.size() && z[i]>max) 32 | max=z[i],ans=i-a.size()-1; 33 | } 34 | cout< 7 | using namespace std; 8 | #define readFile freopen("E:/Shreyans/Documents/algorithmic-programming/Code/WorkspaceB/C++_Files/INPUT.txt","r",stdin); 9 | #define getPrecision(s,p) fixed< pii; 32 | typedef pair pll; 33 | 34 | int main() { 35 | boostIO; 36 | int n; 37 | cin >> n; 38 | cout<< n; 39 | 40 | return 0; 41 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/CC/TIMEASR.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | vector>> v; 5 | 6 | void preCompute() 7 | { 8 | double hadd=0,min=0; 9 | for(int i=0;i<12;i++) 10 | { 11 | for(int j=0;j<60;j++) 12 | { 13 | double kurt_angle=abs(min-(0.5*(double)j)); 14 | if(kurt_angle>180) 15 | kurt_angle=360-kurt_angle; 16 | v.push_back({kurt_angle,{i,j}}); 17 | min+=6; 18 | } 19 | min=(hadd-=30); 20 | } 21 | sort(v.begin(),v.end()); 22 | } 23 | 24 | 25 | int main() 26 | { 27 | preCompute(); 28 | int tc; 29 | cin>>tc; 30 | while(tc--) 31 | { 32 | double n; 33 | cin>>n; 34 | int dis=0; 35 | while((n-v[dis].first)>(1/120.0)) 36 | dis++; 37 | set s; 38 | while(dis!= v.size() && (v[dis].first-n)<(double)(1/120.0)) 39 | { 40 | string hours=to_string(v[dis].second.first); 41 | string minutes=to_string(v[dis].second.second); 42 | if(hours.size()<2) 43 | hours="0"+hours; 44 | if(minutes.size()<2) 45 | minutes="0"+minutes; 46 | string curr_time=hours+":"+minutes; 47 | s.insert(curr_time); 48 | dis++; 49 | } 50 | for(auto i:s) 51 | cout< 9 | using namespace std; 10 | #define ReadFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 11 | #define endl '\n' 12 | 13 | //Created by Shreyans Sheth [bholagabbar] 14 | 15 | typedef long long int ll; 16 | const ll mod=1000000; 17 | const ll mc=1000005; 18 | ll s[3000005]; 19 | int cnt[mc]; 20 | 21 | int main() 22 | { 23 | ios_base::sync_with_stdio(false); 24 | //ReadFile; 25 | int tc; 26 | cin>>tc; 27 | while(tc--) 28 | { 29 | ll n,a,b,c,d; 30 | cin>>n>>a>>b>>c>>d; 31 | s[0]=d; 32 | for(int i=1;i 11 | using namespace std; 12 | #define ReadFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 13 | #define BoostIO ios_base::sync_with_stdio(false) 14 | #define endl '\n' 15 | 16 | typedef long long int ll; 17 | 18 | //Created by Shreyans Sheth [bholagabbar] 19 | 20 | int main() 21 | { 22 | BoostIO; 23 | //ReadFile; 24 | int n,t; 25 | cin>>n>>t; 26 | unordered_set hs; 27 | string s; 28 | int x; 29 | while(t--) 30 | { 31 | cin>>s; 32 | if(s.compare("CLICK")==0) 33 | { 34 | cin>>x; 35 | auto it=hs.find(x); 36 | if(it==hs.end()) 37 | hs.insert(x); 38 | else 39 | hs.erase(x); 40 | } 41 | else 42 | hs.clear(); 43 | cout< 2 | using namespace std; 3 | 4 | typedef long long int ll; 5 | 6 | int main() 7 | { 8 | ios_base::sync_with_stdio(false); 9 | int tc; 10 | cin>>tc; 11 | while(tc--) 12 | { 13 | int n; 14 | string ans,chef; 15 | cin>>n>>ans>>chef; 16 | ll w[n+1]; 17 | for(int i=0;i<=n;i++) 18 | cin>>w[i]; 19 | ll fans=w[0]; 20 | int end=0; 21 | if(ans.compare(chef)!=0) 22 | for(int i=0;i 2 | using namespace std; 3 | 4 | typedef unsigned long long int ll; 5 | 6 | int main() 7 | { 8 | ios_base::sync_with_stdio(false); 9 | int tc; 10 | cin>>tc; 11 | NXT:while(tc--) 12 | { 13 | ll n; 14 | cin>>n; 15 | double x=log2(n+1); 16 | if(x!=0) 17 | { 18 | cout<<"-1\n"; 19 | goto NXT; 20 | } 21 | else 22 | { 23 | ll y=n/2; 24 | cout< 8 | #include 9 | #define pb push_back 10 | #define endl '\n' 11 | using namespace std; 12 | 13 | typedef long long int ll; 14 | 15 | int main() 16 | { 17 | int n; 18 | cin>>n; 19 | ll a[n]; 20 | vector prefix_sum; 21 | for(int i=0;i>a[i]; 24 | if(i==0) 25 | prefix_sum.pb(a[i]); 26 | else 27 | prefix_sum.pb(prefix_sum[i-1]+a[i]); 28 | } 29 | int m; 30 | cin>>m; 31 | int q; 32 | for(int i=0;i>q; 35 | auto it=lower_bound(prefix_sum.begin(),prefix_sum.end(),q); 36 | cout<<(it-prefix_sum.begin()+1)< 10 | #define endl '\n' 11 | using namespace std; 12 | 13 | typedef long long int ll; 14 | const ll MOD=1000000007; 15 | 16 | ll prefix[100005]; 17 | 18 | ll Calc(ll n,ll k,ll p) 19 | { 20 | //ll ans=(n*p)-((p*(p+1)/2))*k+p+1; 21 | //cout<>t>>k; 38 | Pre(k); 39 | while(t--) 40 | { 41 | cin>>a>>b; 42 | cout<<(prefix[b]-prefix[a-1])%MOD< 5 | using namespace std; 6 | #define readFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 7 | #define boostIO ios_base::sync_with_stdio(false) 8 | #define ld long double 9 | #define ll long long int 10 | #define CLR(s) memset(&s, 0, sizeof(s)) 11 | #define scani(s) scanf("%d",&s) 12 | #define scanl(s) scanf("%lld",&s) 13 | #define hashset unordered_set //JAVA feels :') 14 | #define hashmap unordered_map 15 | #define pll pair 16 | #define pii pair 17 | #define pb push_back 18 | #define mp make_pair 19 | #define F first 20 | #define S second 21 | #define endl '\n' 22 | 23 | int main() 24 | { 25 | //readFile; 26 | boostIO; 27 | int n,m; 28 | cin>>n>>m; 29 | if(m>n) 30 | { 31 | cout<<"-1"; 32 | return 0; 33 | } 34 | int moves=n/2+n%2; 35 | while(moves%m!=0) 36 | moves++; 37 | cout< 5 | using namespace std; 6 | #define readFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 7 | #define boostIO ios_base::sync_with_stdio(false) 8 | #define ld long double 9 | #define ll long long int 10 | #define CLR(s) memset(&s, 0, sizeof(s)) 11 | #define scani(s) scanf("%d",&s) 12 | #define scanl(s) scanf("%lld",&s) 13 | #define hashset unordered_set //JAVA feels :') 14 | #define hashmap unordered_map 15 | #define pll pair 16 | #define pii pair 17 | #define pb push_back 18 | #define mp make_pair 19 | #define F first 20 | #define S second 21 | #define endl '\n' 22 | 23 | int main() 24 | { 25 | //readFile; 26 | boostIO; 27 | ll n,k; 28 | cin>>n>>k; 29 | cout<<(6*(n-1)+5)*k< 2 | using namespace std; 3 | #define ReadFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 4 | #define BoostIO ios_base::sync_with_stdio(false) 5 | #define pll pair 6 | #define CLR(s) memset(&s, 0, sizeof(s)) 7 | #define hashset unordered_set 8 | #define hashmap unordered_map 9 | #define pii pair 10 | #define pb push_back 11 | #define mp make_pair 12 | #define F first 13 | #define S second 14 | #define endl '\n' 15 | 16 | typedef long long int ll; 17 | typedef long double ld; 18 | 19 | //Created by Shreyans Sheth [bholagabbar] 20 | 21 | int main() 22 | { 23 | //ReadFile; 24 | BoostIO; 25 | long sum=0; 26 | for(int i=0;i<5;i++) 27 | { 28 | ll x; 29 | cin>>x; 30 | sum+=x; 31 | } 32 | if(sum%5!=0) 33 | cout<<"-1"; 34 | else 35 | cout<<(sum/5); 36 | 37 | return 0; 38 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/CF/478_V/478_B.cpp: -------------------------------------------------------------------------------- 1 | /*input 2 | 6 3 3 | */ 4 | #include 5 | using namespace std; 6 | #define ReadFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 7 | #define BoostIO ios_base::sync_with_stdio(false) 8 | #define pll pair 9 | #define CLR(s) memset(&s, 0, sizeof(s)) 10 | #define hashset unordered_set 11 | #define hashmap unordered_map 12 | #define pii pair 13 | #define pb push_back 14 | #define mp make_pair 15 | #define F first 16 | #define S second 17 | #define endl '\n' 18 | 19 | typedef unsigned long long int ll; 20 | typedef long double ld; 21 | 22 | //Created by Shreyans Sheth [bholagabbar] 23 | 24 | int main() 25 | { 26 | //ReadFile; 27 | BoostIO; 28 | ll n,m,min,max; 29 | cin>>n>>m; 30 | if(m==1) 31 | max=min=(n*(n-1))/2; 32 | else 33 | { 34 | max=((n-m+1)*(n-m))/2; 35 | ll m1=n/m;//min 36 | ll mintimes=m; 37 | ll maxtimes=n%m; 38 | mintimes-=maxtimes; 39 | min=mintimes*((m1*(m1-1))/2)+maxtimes*(m1*(m1+1))/2; 40 | } 41 | cout< 7 | using namespace std; 8 | #define readFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 9 | #define boostIO ios_base::sync_with_stdio(false) 10 | #define ld long double 11 | #define ll long long int 12 | #define CLR(s) memset(&s, 0, sizeof(s)) 13 | #define scani(s) scanf("%d",&s) 14 | #define scanl(s) scanf("%64d",&s) 15 | #define hashset unordered_set //JAVA feels :') 16 | #define hashmap unordered_map 17 | #define pll pair 18 | #define pii pair 19 | #define pb push_back 20 | #define mp make_pair 21 | #define F first 22 | #define S second 23 | #define endl '\n' 24 | 25 | int main() 26 | { 27 | //readFile; 28 | boostIO; 29 | int a,b,c; 30 | cin>>a>>b>>c; 31 | int x1=a+(b*c),x2=a*(b+c),x3=a*b*c,x4=(a+b)*c,x5=(a*b)+c,x6=(a+b+c); 32 | cout< 5 | using namespace std; 6 | #define readFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 7 | #define boostIO ios_base::sync_with_stdio(false) 8 | #define ld long double 9 | #define ll long long int 10 | #define CLR(s) memset(&s, 0, sizeof(s)) 11 | #define scani(s) scanf("%d",&s) 12 | #define scanl(s) scanf("%lld",&s) 13 | #define hashset unordered_set //JAVA feels :') 14 | #define hashmap unordered_map 15 | #define pll pair 16 | #define pii pair 17 | #define pb push_back 18 | #define mp make_pair 19 | #define F first 20 | #define S second 21 | #define endl '\n' 22 | 23 | int main() 24 | { 25 | //readFile; 26 | boostIO; 27 | ll n,s1; 28 | int ep; 29 | cin>>n; 30 | if(n%2==1) 31 | { 32 | n++; 33 | s1=n/2; 34 | s1-=n; 35 | } 36 | else 37 | { 38 | s1=n/2; 39 | } 40 | cout< 6 | using namespace std; 7 | #define readFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 8 | #define boostIO ios_base::sync_with_stdio(false) 9 | #define ld long double 10 | #define ll long long int 11 | #define CLR(s) memset(&s, 0, sizeof(s)) 12 | #define scani(s) scanf("%d",&s) 13 | #define scanl(s) scanf("%lld",&s) 14 | #define hashset unordered_set //JAVA feels :') 15 | #define hashmap unordered_map 16 | #define pll pair 17 | #define pii pair 18 | #define pb push_back 19 | #define mp make_pair 20 | #define F first 21 | #define S second 22 | #define endl '\n' 23 | 24 | int main() 25 | { 26 | //readFile; 27 | boostIO; 28 | int n; 29 | cin>>n; 30 | ll arr[n]; 31 | for(int i=0;i>arr[i]; 34 | } 35 | sort(arr,arr+n); 36 | ll prsum=0; 37 | int cnt=0; 38 | for(int i=0;i=prsum) 41 | { 42 | cnt++; 43 | prsum+=arr[i]; 44 | } 45 | } 46 | cout< 8 | using namespace std; 9 | #define ReadFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 10 | #define BoostIO ios_base::sync_with_stdio(false) 11 | #define pll pair 12 | #define CLR(s) memset(&s, 0, sizeof(s)) 13 | #define hashset unordered_set 14 | #define hashmap unordered_map 15 | #define pii pair 16 | #define pb push_back 17 | #define mp make_pair 18 | #define F first 19 | #define S second 20 | #define endl '\n' 21 | 22 | typedef long long int ll; 23 | typedef long double ld; 24 | 25 | //Created by Shreyans Sheth [bholagabbar] 26 | 27 | int a[100005],p[100005]; 28 | 29 | int main() 30 | { 31 | //ReadFile; 32 | BoostIO; 33 | int n; 34 | cin>>n; 35 | for(int i=0;i>a[i]>>p[i]; 37 | ll sum=0; 38 | for(int i=0;i 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/CF/Practice/286_C.cpp: -------------------------------------------------------------------------------- 1 | /*input 2 | 2 4 3 | */ 4 | //Shreyans Sheth [bholagabbar] 5 | 6 | #include 7 | using namespace std; 8 | #define readFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 9 | #define getPrecision(s,p) fixed< pii; 24 | typedef pair pll; 25 | 26 | int main() 27 | { 28 | boostIO; 29 | int n,m; 30 | cin>>n>>m; 31 | int cnt=min(n,m); 32 | cout< 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | //Created by Shreyans Sheth [bholagabbar] 7 | 8 | int main() 9 | { 10 | //ReadFile; 11 | int n; 12 | cin>>n; 13 | set hs; 14 | string x; 15 | set::iterator it; 16 | for(int i=0;i>x; 19 | it=hs.find(x); 20 | if(it!=hs.end()) 21 | { 22 | int cnt=1; 23 | while(it!=hs.end()) 24 | it=hs.find(x=x+std::to_string(cnt++)); 25 | cout< 6 | using namespace std; 7 | #define ReadFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 8 | #define BoostIO ios_base::sync_with_stdio(false) 9 | #define pii pair 10 | #define f first 11 | #define s second 12 | #define mp make_pair 13 | #define endl '\n' 14 | 15 | typedef long long int ll; 16 | 17 | //Created by Shreyans Sheth [bholagabbar] 18 | 19 | int a[100000]={0}; 20 | bool visited[100000]={0}; 21 | 22 | bool BFS(int t) 23 | { 24 | queue q; 25 | q.push(1); 26 | while(!q.empty()) 27 | { 28 | int cv=q.front(); 29 | q.pop(); 30 | if(cv==t) 31 | return 1; 32 | if(!visited[cv]) 33 | { 34 | visited[cv]=1; 35 | q.push(cv+a[cv]); 36 | } 37 | } 38 | return 0; 39 | } 40 | 41 | int main() 42 | { 43 | BoostIO; 44 | //ReadFile; 45 | int n,t,x; 46 | cin>>n>>t; 47 | for(int i=1;i<=n;i++) 48 | { 49 | cin>>x; 50 | a[i]=x; 51 | } 52 | if(BFS(t)) 53 | cout<<"YES"; 54 | else 55 | cout<<"NO"; 56 | return 0; 57 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/CF/Practice/520_B.cpp: -------------------------------------------------------------------------------- 1 | /*input 2 | 99 100 3 | */ 4 | #include 5 | using namespace std; 6 | #define ReadFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 7 | #define BoostIO ios_base::sync_with_stdio(false) 8 | #define pb emplace_back 9 | #define mp make_pair 10 | #define f first 11 | #define s second 12 | #define pii pair 13 | #define endl '\n' 14 | 15 | typedef long long int ll; 16 | vector a[100000]; 17 | 18 | //Created by Shreyans Sheth [bholagabbar] 19 | 20 | int BFS(int n,int m) 21 | { 22 | queue q; 23 | bool visited[100001]={0}; 24 | q.push({n,0});//number,times; 25 | int cnt=0; 26 | while(!q.empty()) 27 | { 28 | pii c=q.front(); 29 | q.pop(); 30 | int cv=c.f; 31 | if(c.f==m) 32 | return c.s; 33 | if(!visited[cv]) 34 | { 35 | visited[cv]=1; 36 | for(int x:a[cv]) 37 | { 38 | //cout<>n>>m; 51 | a[1].pb(2); 52 | for(int i=2;i<10005;i++) 53 | { 54 | a[i].pb(i*2); 55 | a[i].pb(i-1); 56 | } 57 | cout< 5 | using namespace std; 6 | #define endl '\n' 7 | 8 | //Created by Shreyans Sheth [bholagabbar] 9 | 10 | int main() 11 | { 12 | ios_base::sync_with_stdio(false); 13 | //freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 14 | long long n; 15 | long long ans=0; 16 | cin>>n; 17 | long long len=0; 18 | long long n1=n; 19 | while(n1>0) 20 | { 21 | n1/=10; 22 | len++; 23 | } 24 | if(len==1) 25 | ans=n; 26 | else 27 | { 28 | for(long long i=0;i 2 | using namespace std; 3 | #define endl '\n' 4 | 5 | //Created by Shreyans Sheth [bholagabbar] 6 | 7 | int main() 8 | { 9 | ios_base::sync_with_stdio(false); 10 | int a[101][101]; 11 | for(int i=0;i<101;i++) 12 | for(int j=0;j<101;j++) 13 | a[i][j]=0; 14 | int n,x1,y1,x2,y2; 15 | cin>>n; 16 | for(int q=0;q>x1>>y1>>x2>>y2; 19 | for(int i=min(x1,x2);i<=abs(x1+(x2-x1));i++) 20 | for(int j=min(y1,y2);j<=abs(y1+(y2-y1));j++) 21 | a[i][j]++; 22 | } 23 | long sum=0; 24 | for(int i=1;i<=100;i++) 25 | for(int j=1;j<=100;j++) 26 | sum+=a[i][j]; 27 | cout< 5 | using namespace std; 6 | #define readFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 7 | #define getPrecision(s,p) fixed< pii; 20 | typedef long long int ll; 21 | typedef pair pll; 22 | typedef long double ld; 23 | 24 | //Shreyans Sheth [bholagabbar] 25 | 26 | bool a[(sz+5)*5]; 27 | 28 | int main() 29 | { 30 | //readFile 31 | boostIO; 32 | int n; 33 | cin>>n; 34 | for(int i=0;i>a[i]; 36 | int max=0; 37 | for(int i=1;it: #cant be greater than total 11 | ans+=(t-umax); 12 | hcf=fractions.gcd(ans,t) 13 | ans//=hcf 14 | t//=hcf 15 | print(str(ans)+'/'+str(t)) -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/CF/Practice/593B_antonAndLines.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define readFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 4 | #define getPrecision(s,p) fixed< pii; 19 | typedef pair pll; 20 | 21 | //Shreyans Sheth [bholagabbar] 22 | 23 | int main() 24 | { 25 | //readFile 26 | boostIO; 27 | int n; 28 | cin>>n; 29 | ll x1,x2,m,c,y1,y2; 30 | cin>>x1>>x2; 31 | pll a[n]; 32 | for(int i=0;i>m>>c; 35 | y1=m*x1+c; 36 | y2=m*x2+c; 37 | a[i]={y1,y2}; 38 | } 39 | sort(a,a+n); 40 | for(int i=1;ia[i].S) 42 | { 43 | cout<<"YES"; 44 | return 0; 45 | } 46 | cout<<"NO"; 47 | return 0; 48 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/CF/Practice/604_A.cpp: -------------------------------------------------------------------------------- 1 | /*input 2 | 55 66 75 44 47 3 | 6 0 6 6 10 4 | 19 0 5 | */ 6 | //Shreyans Sheth [bholagabbar] 7 | 8 | #include 9 | using namespace std; 10 | #define readFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 11 | #define getPrecision(s,p) fixed< pii; 26 | typedef pair pll; 27 | 28 | int main() 29 | { 30 | boostIO; 31 | int m[5],w[5],sh,wh; 32 | for(int i=0;i<5;i++) 33 | cin>>m[i]; 34 | for(int i=0;i<5;i++) 35 | cin>>w[i]; 36 | cin>>sh>>wh; 37 | double ans=0; 38 | double cnt[5]={500, 1000, 1500, 2000,2500}; 39 | for(int i=0;i<5;i++) 40 | ans+=max(0.3*cnt[i],(1-(m[i]/250.0))*cnt[i]-50.0*w[i]); 41 | cout<<(int)(floor(ans+100.0*sh-50.0*wh+0.5)); 42 | return 0; 43 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/CF/Practice/612_c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bholagabbar/algorithmic-programming/a5482cca93f79ec8495256fa1a08525e61bfb899/Code/WorkspaceB/C++_Files/CF/Practice/612_c -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/CF/Practice/CF_131_C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define endl '\n' 4 | #define pb emplace_back 5 | 6 | //Created by Shreyans Sheth [bholagabbar] using Sublime 3 and SublimeInput Plugin 7 | vector C[61]; 8 | void COMBINATIONS() 9 | { 10 | for(long long i=0;i<=60;i++) 11 | { 12 | for(long long j=0;j<=i;j++) 13 | { 14 | if(j==0 || j==i) 15 | { 16 | C[i].pb(1); 17 | } 18 | else 19 | { 20 | C[i].pb(C[i-1][j-1]+C[i-1][j]); 21 | } 22 | } 23 | } 24 | } 25 | 26 | 27 | int main() 28 | { 29 | ios_base::sync_with_stdio(false);//FAST IO 30 | COMBINATIONS(); 31 | long long n,m,t; 32 | cin>>n>>m>>t; 33 | long long ans=C[n][4]*C[m][1]*C[n+m-5][t-5]; 34 | cout< 2 | using namespace std; 3 | #define endl '\n' 4 | 5 | //Created by Shreyans Sheth [bholagabbar] using Sublime 3 and SublimeInput Plugin 6 | 7 | int main() 8 | { 9 | ios_base::sync_with_stdio(false);//FAST IO 10 | int n; 11 | cin>>n; 12 | int a[n]; 13 | int pos[n][n]; 14 | for(int i=0;i>a[i]; 17 | } 18 | int x; 19 | for(int i=0;i>x; 24 | if(x==1) 25 | pos[i][j]=true; 26 | else 27 | pos[i][j]=false; 28 | } 29 | } 30 | for(int i=0;i 6 | using namespace std; 7 | #define endl '\n' 8 | 9 | //Created by Shreyans Sheth [bholagabbar] using Sublime 3 and SublimeInput Plugin 10 | 11 | int main() 12 | { 13 | ios_base::sync_with_stdio(false);//FAST IO 14 | int n,m; 15 | m=0; 16 | cin>>n; 17 | int a,x; 18 | cin>>x; 19 | a=x; 20 | vectorv; 21 | v.push_back(x); 22 | for(int i=1;i>x; 25 | m=max(m,x); 26 | v.push_back(x); 27 | if(a!=1) 28 | { 29 | a=__gcd(a,x); 30 | } 31 | } 32 | if(a!=1) 33 | { 34 | a=m/a; 35 | } 36 | int cnt=0; 37 | for(int i=0;ia) 48 | { 49 | while(v[i]!=a) 50 | { 51 | v[i]/=2; 52 | cnt++; 53 | } 54 | } 55 | } 56 | cout< 8 | using namespace std; 9 | #define readFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 10 | #define getPrecision(s,p) fixed< pii; 25 | typedef pair pll; 26 | 27 | ll d[sz<<1], ans[sz<<1]; 28 | 29 | int main() 30 | { 31 | boostIO; 32 | ll n,a; 33 | cin>>n>>a; 34 | ll sum=0, ans; 35 | for(int i=0;i>d[i]; 38 | sum+=d[i]; 39 | } 40 | for(int i=0;i= a) 43 | ans=0; 44 | else 45 | ans=a-(sum-d[i]+1); 46 | ans+=max((ll)0, d[i]-(a-n+1)); 47 | cout< 5 | using namespace std; 6 | #include 7 | 8 | /* 9 | C(n,r) mod m 10 | Using recurrence: 11 | C(i,k) = C(i-1,k-1) + C(i-1,k) 12 | Time Complexity: O(n*r) 13 | Space Complexity: O(n*r) 14 | */ 15 | 16 | long long Calculate(int n, int r, int MOD) 17 | { 18 | vector< vector > C(n+1,vector (r+1,0)); 19 | 20 | for (int i=0; i<=n; i++) 21 | { 22 | for (int k=0; k<=r && k<=i; k++) 23 | if (k==0 || k==i) 24 | { 25 | C[i][k] = 1; 26 | cout< 5 | using namespace std; 6 | #define readFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 7 | #define getPrecision(s,p) fixed< pii; 22 | typedef pair pll; 23 | 24 | const ll MOD = 1e9 + 7; 25 | 26 | ll C[5001][5001]; 27 | 28 | void getCombinations(int n, int r) { 29 | for (int i = 0; i <= n; i++) { 30 | for (int k = 0; k <= r && k <= i; k++) { 31 | C[i][k] = (k == 0 || k == i) ? 1 : (C[i - 1][k - 1] % MOD + C[i - 1][k] % MOD) % MOD; 32 | } 33 | } 34 | } 35 | 36 | int main() { 37 | getCombinations(5000, 5000); 38 | cout << C[4][2] << endl; 39 | return 0; 40 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/DS_ALGO/GRAPH ALGOS/HEAVY-LIGHT/HEAVY-LIGHT_EDGE.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bholagabbar/algorithmic-programming/a5482cca93f79ec8495256fa1a08525e61bfb899/Code/WorkspaceB/C++_Files/DS_ALGO/GRAPH ALGOS/HEAVY-LIGHT/HEAVY-LIGHT_EDGE.cpp -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/DS_ALGO/SIEVE/SieveOfEros_USE.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include 4 | using namespace std; 5 | #define readFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 6 | #define getPrecision(s,p) fixed< pii; 21 | typedef pair pll; 22 | 23 | 24 | bool prime[sz]; 25 | 26 | void Sieve() { 27 | prime[0] = prime[1] = 0; 28 | prime[i] = 1; 29 | for (ll i = 2; i <= sz; i++) { 30 | } 31 | for (ll i = 2; i * i <= sz; i++) { 32 | if (prime[i]) { 33 | for (ll j = i * i; j < size; j += i) { 34 | prime[j] = 0; 35 | } 36 | } 37 | } 38 | } 39 | 40 | 41 | int main() { 42 | boostIO; 43 | 44 | 45 | return 0; 46 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/DS_ALGO/SIEVE/SieveofErosthosnes_EXPLAIN.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define endl '\n' 4 | 5 | //Created by Shreyans Sheth [bholagabbar] 6 | 7 | #define size 100005 8 | bool prime[size]; 9 | 10 | void Sieve() 11 | { 12 | for(int i=2;i 5 | using namespace std; 6 | #define endl '\n' 7 | 8 | int main() { 9 | ios_base::sync_with_stdio(false);//FAST IO 10 | string s; 11 | cin >> s; 12 | int n = s.size(); 13 | int z[n]; 14 | for (int i = 0; i < n; i++) 15 | z[i] = 0; 16 | for (int i = 1, l = 0, r = 0; i < n; ++i) { 17 | if (i <= r) 18 | z[i] = min(r - i + 1, z[i - l]); 19 | while (i + z[i] < n && s[z[i]] == s[i + z[i]]) 20 | z[i]++; 21 | if (i + z[i] - 1 > r) 22 | r = i + z[i] - 1, l = i; 23 | } 24 | for (auto i : z) 25 | cout << i << " "; 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/INPUT.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/SPOJ/AE00.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define readFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 4 | #define printPrecision(s,p) fixed< pii; 17 | typedef pair pll; 18 | 19 | //Shreyans Sheth [bholagabbar] 20 | 21 | const int lim=10000; 22 | bool prime[lim+1]; 23 | int dp[lim+1]={0}; 24 | 25 | void Sieve() 26 | { 27 | fill(prime,prime+lim+1,1); 28 | prime[0]=prime[1]=0; 29 | for(int i=0;i*i<=lim;i++) 30 | if(prime[i]) 31 | for(int j=i*i;j<=lim;j+=i) 32 | prime[j]=0; 33 | } 34 | 35 | int main() 36 | { 37 | //readFile; 38 | boostIO; 39 | Sieve(); 40 | int n; 41 | cin>>n; 42 | for(int i=1;i<=n;i++) 43 | { 44 | for(int j=2;j*j<=i;j++) 45 | if(i%j==0) 46 | dp[i]++; 47 | dp[i]+=dp[i-1]+1; 48 | } 49 | cout< 2 | using namespace std; 3 | #define endl '\n' 4 | #define ll long long int 5 | 6 | //Created by Shreyans Sheth [bholagabbar] 7 | 8 | vector a; 9 | ll c; 10 | 11 | int check(int x) { 12 | int cowsplaced = 1; 13 | ll lastpos = a[0]; 14 | for (int i = 1; i < a.size(); i++) 15 | if (a[i] - lastpos >= x) { 16 | cowsplaced++; 17 | if (cowsplaced == c) 18 | return 1; 19 | lastpos = a[i]; 20 | } 21 | return 0; 22 | } 23 | 24 | ll BinarySearch() { 25 | ll lo = 0, hi = (ll)1e9; 26 | ll n = a.size(); 27 | while (lo < hi) { 28 | ll x = lo + (hi - lo + 1) / 2; //May become buggy!! 29 | if (check(x) == 1) 30 | lo = x; 31 | else 32 | hi = x - 1; 33 | } 34 | return lo; 35 | } 36 | 37 | int main() { 38 | ios_base::sync_with_stdio(false); 39 | //freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 40 | int t; 41 | cin >> t; 42 | while (t--) { 43 | int n; 44 | ll x; 45 | cin >> n >> c; 46 | a.clear(); 47 | for (int i = 0; i < n; i++) { 48 | cin >> x; 49 | a.push_back(x); 50 | } 51 | sort(a.begin(), a.end()); 52 | cout << BinarySearch() << endl; 53 | } 54 | return 0; 55 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/SPOJ/CANDY3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | ios_base::sync_with_stdio(false);cin.tie(0);//FAST IO 6 | unsigned long long t; 7 | cin>>t; 8 | while(t--) 9 | { 10 | unsigned long long n=0; 11 | cin>>n; 12 | unsigned long long sum=0; 13 | for(int i=0;i>x; 17 | sum+=x; 18 | if(sum%n==0) 19 | { 20 | sum=sum/n; 21 | } 22 | } 23 | if(sum%n==0) 24 | { 25 | cout<<"YES"; 26 | } 27 | else 28 | { 29 | cout<<"NO"; 30 | } 31 | } 32 | return 0; 33 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/SPOJ/EIGHTS.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define readFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 4 | #define printPrecision(s,p) fixed< pii; 17 | typedef pair pll; 18 | 19 | //Shreyans Sheth [bholagabbar] 20 | 21 | int main() 22 | { 23 | //readFile 24 | boostIO; 25 | int a[4]={192, 442, 692, 942}; 26 | ll tc; 27 | cin>>tc; 28 | while(tc--) 29 | { 30 | ll k; 31 | cin>>k; 32 | k--; 33 | ll n1=k/4; 34 | if(n1!=0) 35 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | ios_base::sync_with_stdio(false);cin.tie(0);//FAST IO 6 | int n; 7 | cin>>n; 8 | int a[n]; 9 | for(int i=0;i>a[i]; 12 | } 13 | int dp[n]; 14 | int max=-1; 15 | for(int i=0;i=0;j--) 19 | { 20 | if(a[j]dp[i]-1) 21 | { 22 | dp[i]=dp[j]+1; 23 | } 24 | } 25 | if(dp[i]>max) 26 | { 27 | max=dp[i]; 28 | } 29 | } 30 | cout< 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int num; 7 | cin>>num; 8 | int square_root = (int) sqrt(num); 9 | for (int i = 1; i <=square_root; i++) 10 | { 11 | if (num % i == 0) 12 | { 13 | cout << i< 6 | using namespace std; 7 | #define readFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 8 | #define getPrecision(s,p) fixed< pii; 23 | typedef pair pll; 24 | 25 | //Shreyans Sheth [bholagabbar] 26 | 27 | int main() 28 | { 29 | //readFile 30 | ld l; 31 | cin>>l; 32 | while(l!=0) 33 | { 34 | ld ans=(l*l)/(2.0*3.14159265359); 35 | cout<>l; 37 | } 38 | return 0; 39 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/SPOJ/JZYPHYZ_spoj.cpp: -------------------------------------------------------------------------------- 1 | /*input 2 | 3 3 3 | hi,I'mChuYuXun..YouaresohandsomethatIfallinlovewithyou 4 | butIlovesevenk..you'dbettergoaway 5 | 55555555555 6 | ChuYuXun 7 | you 8 | 55555555 9 | */ 10 | #include 11 | using namespace std; 12 | #define endl '\n' 13 | 14 | //Created by Shreyans Sheth [bholagabbar] using Sublime 3 and SublimeInput Plugin 15 | 16 | int z[5000000]; 17 | int main() 18 | { 19 | ios_base::sync_with_stdio(false);//FAST IO 20 | int n,m; 21 | cin>>n>>m; 22 | string a[n],x; 23 | for(int i=0;i>a[i]; 26 | } 27 | for(int q=0;q>x; 30 | long ans=0; 31 | for(int j=0;jr) 47 | { 48 | l=i,r=i+z[i]-1; 49 | } 50 | if(i>x.size() && z[i]==x.size()) 51 | { 52 | ans++; 53 | break; 54 | } 55 | } 56 | } 57 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | ios_base::sync_with_stdio(false);cin.tie(0);//FAST IO 6 | string a1,b1; 7 | cin>>a1>>b1; 8 | int n=a1.size(); 9 | int m=b1.size(); 10 | char a [n+1]; 11 | char b [m+1]; 12 | for (int i = 1; i <=n; i++) 13 | { 14 | a[i] = a1.at(i - 1); 15 | } 16 | for (int i = 1; i <=m; i++) 17 | { 18 | b[i] = b1.at(i - 1); 19 | } 20 | int dp[n+1][m+1]; 21 | 22 | for (int i = 0; i <=n; i++) 23 | { 24 | dp[i][0]=0; 25 | } 26 | for (int i = 0; i <=m; i++) 27 | { 28 | dp[0][i]=0; 29 | } 30 | for (int i = 1; i <=n; i++) 31 | { 32 | for (int j = 1; j <=m; j++) 33 | { 34 | if (a[i] == b[j]) 35 | { 36 | dp[i][j] = 1 + dp[i - 1][j - 1]; 37 | } 38 | else 39 | { 40 | dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]); 41 | } 42 | } 43 | } 44 | cout< 13 | using namespace std; 14 | #define endl '\n' 15 | 16 | //Created by Shreyans Sheth [bholagabbar] using Sublime 3 and SublimeInput Plugin 17 | char a[9000000]; 18 | char b[9000000]; 19 | char s[9000000]; 20 | long z[9000000]; 21 | int main() 22 | { 23 | int n; 24 | while(scanf("%d\n",&n)!=EOF) 25 | { 26 | scanf("%s",a); 27 | scanf("%s",b); 28 | strcpy(s,a); 29 | strcat(s,"$"); 30 | strcat(s,b); 31 | long n=strlen(s); 32 | vectorval; 33 | long plen=strlen(a); 34 | for(long i=1,l=0,r=0;ir) 46 | { 47 | r=i+z[i]-1,l=i; 48 | } 49 | if(i>plen && z[i]==plen) 50 | { 51 | val.emplace_back(i-plen-1); 52 | } 53 | } 54 | for(auto i:val) 55 | { 56 | printf("%ld\n",i); 57 | } 58 | printf("\n"); 59 | } 60 | return 0; 61 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/SPOJ/OLOLO.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define pb push_back 3 | using namespace std; 4 | int main() 5 | { 6 | ios_base::sync_with_stdio(false);cin.tie(0);//FAST IO 7 | int n,x; 8 | cin>>n; 9 | vector v; 10 | for(int i=0;i>x; 13 | v.pb(x); 14 | } 15 | sort(v.begin(),v.end()); 16 | if(v.at(0)!=v.at(1)) 17 | { 18 | cout< 2 | using namespace std; 3 | 4 | //Shreyans Sheth [bholagabbar] 5 | typedef long long int ll; 6 | int main() 7 | { 8 | //readFile 9 | //boostIO; 10 | int tc; 11 | cin>>tc; 12 | while(tc--){ 13 | ll n; 14 | cin>>n; 15 | ll ans=(n*(n+2)*(2*n+1))/8; 16 | cout< 2 | using namespace std; 3 | 4 | class Trie 5 | { 6 | private: 7 | struct node 8 | { 9 | int data; 10 | bool end; 11 | 12 | list next; 13 | }; 14 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/SPOJ/WACHOVIA.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | ios_base::sync_with_stdio(false);cin.tie(0);//FAST IO 6 | int t; 7 | cin>>t; 8 | while(t--) 9 | { 10 | int K,n; 11 | cin>>K>>n; 12 | int c[n+1]; 13 | int k[n+1]; 14 | for(int i=1;i<=n;i++) 15 | { 16 | cin>>k[i]>>c[i]; 17 | } 18 | int dp[n+1][K+1]; 19 | for(int i=0;i<=n;i++) 20 | { 21 | dp[i][0]=0; 22 | } 23 | for(int i=0;i<=K;i++) 24 | { 25 | dp[0][i]=0; 26 | } 27 | for(int i=1;i<=n;i++) 28 | { 29 | for(int j=1;j<=K;j++) 30 | { 31 | dp[i][j]=dp[i-1][j]; 32 | if(k[i]<=j) 33 | { 34 | dp[i][j]=max(dp[i-1][j], c[i]+dp[i-1][j-k[i]]); 35 | } 36 | } 37 | } 38 | cout<<"Hey stupid robber, you can get "< 2 | using namespace std; 3 | #define readFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 4 | #define printPrecision(s,p) fixed< pii; 22 | typedef long long int ll; 23 | typedef pair pll; 24 | typedef long double ld; 25 | 26 | //Shreyans Sheth [bholagabbar] 27 | 28 | int main() 29 | { 30 | //readFile 31 | boostIO; 32 | ll n; 33 | cin>>n; 34 | if(n>0 && (n&(n-1))==0)//Property that it is a power of 2 35 | cout<<"TAK\n"; 36 | else 37 | cout<<"NIE\n"; 38 | 39 | return 0; 40 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/C++_Files/terminate.bat: -------------------------------------------------------------------------------- 1 | taskkill /F /IM a.exe -------------------------------------------------------------------------------- /Code/WorkspaceB/College_stuff/CSE 219(OOPS)/fh.cpp: -------------------------------------------------------------------------------- 1 | 2 | //Shreyans Sheth [bholagabbar] 3 | 4 | #include 5 | using namespace std; 6 | #define readFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 7 | #define getPrecision(s,p) fixed< pii; 22 | typedef pair pll; 23 | 24 | int main() 25 | { 26 | boostIO; 27 | 28 | ll op=(ll)1.8446744e+19; 29 | cout< 2 | using namespace std; 3 | #define endl '\n' 4 | 5 | class A 6 | { 7 | 8 | public: 9 | int y; 10 | }; 11 | 12 | class B:protected A 13 | { 14 | 15 | }; 16 | 17 | int main() 18 | { 19 | ios_base::sync_with_stdio(false);//FAST IO 20 | //cin.tie(NULL);//Untie streams before submission 21 | B obj; 22 | //obj.x=3; 23 | obj.y=4; 24 | //cout< 2 | using namespace std; 3 | #define endl '\n' 4 | 5 | template 6 | T* bsort(T a[], int size) 7 | { 8 | for(int i=0;i 2 | #include "BIT.cpp" 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | cout<<"Enter size of initial array\n"; 9 | cin>>n; 10 | int array[n+1]; 11 | cout<<"Enter the array\n"; 12 | for(int i=1;i<=n;i++) 13 | cin>>array[i]; 14 | FenwickTree bit(n);//Initliazed Fenwick Tree 15 | bit.Build(array,n); 16 | cout<<"Built a Fenwick Tree for the array to execute queries\n"; 17 | cout<<"Enter 1 to Query, 0 to Update, -1 to Exit\n"; 18 | int q,a,b,val; 19 | cin>>q; 20 | while(q!=-1) 21 | { 22 | if(q==1) 23 | { 24 | cout<<"Enter 'a' and 'b' for Range Sum query between a and b\n"; 25 | cin>>a>>b; 26 | cout<>a>>val; 32 | bit.Update(a,val); 33 | cout<<"Update done\n"; 34 | } 35 | else 36 | { 37 | cout<<"Sorry enter again:\n"; 38 | goto nxt; 39 | } 40 | nxt:cout<<"Enter 1 to Query, 0 to Update, -1 to Exit\n"; 41 | cin>>q; 42 | } 43 | return 0; 44 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/College_stuff/CSE 220 (DSA)/ADV_DS_PROJECT/SEGMENT_TREE/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #include "Segment_tree.cpp" 4 | 5 | 6 | int main() 7 | { 8 | int n; 9 | cout<<"Enter size of initial array\n"; 10 | cin>>n; 11 | int array[n]; 12 | cout<<"Enter the array\n"; 13 | for(int i=0;i>array[i]; 15 | segmentTree st(n); 16 | st.buildST(1,0,n-1,array); 17 | cout<<"Built a Segment Tree for the array to execute queries\n"; 18 | cout<<"Enter 1 to Query, 0 to Update, -1 to Exit\n"; 19 | int q,a,b,val; 20 | cin>>q; 21 | while(q!=-1) 22 | { 23 | if(q==1) 24 | { 25 | cout<<"Enter 'a' and 'b' for Range Sum query between a and b\n"; 26 | cin>>a>>b; 27 | cout<>a>>b>>val; 33 | st.updateST(1,0,n-1,a-1,b-1,val); 34 | cout<<"Update done\n"; 35 | } 36 | else 37 | { 38 | cout<<"Sorry enter again:\n"; 39 | goto nxt; 40 | } 41 | nxt:cout<<"Enter 1 to Query, 0 to Update, -1 to Exit\n"; 42 | cin>>q; 43 | } 44 | return 0; 45 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/College_stuff/CSE 220 (DSA)/ADV_DS_PROJECT/Trie.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | #define end _end 6 | #define next _nxt 7 | 8 | const int MaxN = 500500; 9 | int sz = 0; 10 | 11 | int next[27][MaxN]; 12 | int end[MaxN]; 13 | bool created[MaxN]; 14 | 15 | void insert (string &s) { 16 | int v = 0; 17 | 18 | for (int i = 0; i < s.size(); ++i) { 19 | int c = s[i] - 'a'; 20 | if (!created[next[c][v]]) { 21 | next[c][v] = ++sz; 22 | created[sz] = true; 23 | } 24 | v = next[c][v]; 25 | } 26 | ++end[v]; 27 | } 28 | 29 | bool search (string tmp) { 30 | int v = 0; 31 | 32 | for (int i = 0; i < tmp.size(); ++i) { 33 | int c = tmp[i] - 'a'; 34 | if (!created[next[c][v]]) 35 | return false; 36 | v = next[c][v]; 37 | } 38 | return end[v] > 0; 39 | } 40 | 41 | int main () { 42 | string keys[] = {"hi", "hello", "you", "ekta", "me"}; 43 | string output[] = {"NO", "YES"}; 44 | 45 | for (int i = 0; i < 5; ++i) 46 | insert (keys[i]); 47 | 48 | cout << output[search ("my")] << endl; 49 | cout << output[search ("me")] << endl; 50 | 51 | return 0; 52 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/College_stuff/CSE 220 (DSA)/DFS.cpp: -------------------------------------------------------------------------------- 1 | //DFS: http://ideone.com/jlsQnW 2 | #include 3 | using namespace std; 4 | 5 | bool adj_matrix[101][101]={0};//Adjacency matrix. 1 represents an edge between indices i and j 6 | bool visited[101]={0};//Visited array for DFS to avoid visiting visited vertices again 7 | int n;//Number of vertices in the graph 8 | 9 | void DFS(int s) 10 | { 11 | visited[s]=1; 12 | cout<>n; 22 | int m;//Number of edges 23 | cin>>m; 24 | //cout<<"Enter number of edges\nVertices in the graph should be numbered between 1 to 100\n"; 25 | for(int i=0;i>x>>y; 29 | adj_matrix[x][y]=1; 30 | //adj_matrix[y][x]=1;//Add this to build an undirected graph 31 | } 32 | int s; 33 | //cout<<"Enter source for DFS\n"; 34 | cin>>s; 35 | cout<<"DFS with Source "< 10 | #include 11 | #define LEFT(s) 2*s 12 | #define RIGHT(s) 2*s+1 13 | using namespace std; 14 | 15 | int *a; 16 | int n; 17 | 18 | void MaxHeapify(int i) 19 | { 20 | int l=LEFT(i); 21 | int r=RIGHT(i); 22 | int largest=i; 23 | if(l<=n && a[l]>a[i]) 24 | largest=l; 25 | if(r<=n && a[r]>a[largest]) 26 | largest=r; 27 | if(largest!=i) 28 | { 29 | std::swap(a[i],a[largest]); 30 | MaxHeapify(largest); 31 | } 32 | } 33 | 34 | void BuildMaxHeap() 35 | { 36 | for(int i=floor(n/2);i>=1;i--) 37 | MaxHeapify(i); 38 | } 39 | 40 | void HeapSort() 41 | { 42 | BuildMaxHeap(); 43 | for(int i=n;i>=2;i--) 44 | { 45 | swap(a[i],a[1]); 46 | n--; 47 | MaxHeapify(1); 48 | } 49 | } 50 | 51 | 52 | int main() 53 | { 54 | cin>>n; 55 | int x=n; 56 | a=new int[n+1]; 57 | for(int i=1;i<=n;i++) 58 | cin>>a[i]; 59 | HeapSort(); 60 | for(int i=1;i<=x;i++) 61 | cout< 2 | using namespace std; 3 | 4 | int partition(int a[], int l ,int r) { 5 | swap(a[l], a[l + rand() % (r - l + 1)]); 6 | int pos = l + 1; 7 | int pivot = a[l]; 8 | for(int i = l + 1; i <= r; i++) { 9 | if(a[j] < pivot) { 10 | swap(a[pos], a[i]); 11 | pos++; 12 | } 13 | } 14 | swap(a[--pos], a[l]); 15 | return pos; 16 | } 17 | 18 | void quickSort(int a[], int l, int r) { 19 | if(l < r) { 20 | int p = partition(a, l, r); 21 | quickSort(a, 0, p-1); 22 | quickSort(a, p+1, r); 23 | } 24 | } 25 | 26 | int main() 27 | { 28 | int a[]={1,6,12,2,7,90,45,23,101,1,893,1236,390,1902,345,12,45}; 29 | int sz=sizeof(a)/sizeof(a[0]); 30 | quickSort(a,0,sz); 31 | for(int i:a) 32 | cout< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | using namespace std; 8 | 9 | int main() { 10 | pid_t pid; 11 | pid = fork(); 12 | if (pid < 0) { 13 | cout << "For failed\n"; 14 | exit(-1); 15 | } else if(pid == 0) { //Child process 16 | cout << "Executing Child Process\n"; 17 | char *name[2]; 18 | name[0] = "/home/swe404/Desktop/even.out"; //make this file wherever 19 | name[1] = NULL; 20 | execvp(name[0], name); 21 | } else { 22 | wait(NULL); //Wait for child process to compelte. Short hand for waitpid(-1, NULL, 0); 23 | printf("Child complete. Executing parent\n"); 24 | for(int i = 1; i <= 20; i += 2) { 25 | printf("%d ", i); 26 | } 27 | printf("\n"); 28 | exit(0); 29 | } 30 | return 0; 31 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/College_stuff/College stuff.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Code/WorkspaceB/Coursera_Algo1/BFS.py: -------------------------------------------------------------------------------- 1 | import queue 2 | def BFS(n,s,g):#size,source,graph 3 | visited=[0]*(n+1) 4 | q=queue.Queue(0) 5 | q.put(s) 6 | visited[s]=1; 7 | bfslist=list() 8 | while not q.empty(): 9 | x=q.get() 10 | bfslist.append(x) 11 | for i in g[x]: 12 | if visited[i]!=1: 13 | visited[i]=1; 14 | q.put(i) 15 | return bfslist 16 | 17 | g=[[],[2,3],[1,3],[1,2]] 18 | x=BFS(3,1,g) 19 | print(x) 20 | -------------------------------------------------------------------------------- /Code/WorkspaceB/Coursera_Algo1/BST.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | template 6 | class BST 7 | { 8 | private: 9 | struct node 10 | { 11 | t data;//Data 12 | node* left;//Left child 13 | node* right;//Right Child 14 | node() 15 | { 16 | left=right=NULL; 17 | } 18 | }; 19 | node* head; 20 | node* curr; 21 | public: 22 | void Insert(t x) 23 | { 24 | node* n=new node(); 25 | n->data=x; 26 | if(head==NULL)//This is the head itself 27 | head=n; 28 | else 29 | { 30 | curr=head; 31 | while(curr!=NULL) 32 | { 33 | if(xdata)//If the entry is less than the curr one, got to hte left child 34 | curr=curr->left; 35 | else//else the right child 36 | curr=curr->right; 37 | } 38 | curr=n; 39 | } 40 | } 41 | bool Find(t x) 42 | { 43 | 44 | } 45 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/Coursera_Algo1/DFS.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define pb emplace_back 4 | 5 | vector g[6]; 6 | bool visited[6]={0}; 7 | 8 | void DFS(int x, int n) 9 | { 10 | visited[x]=1; 11 | cout< 2 | using namespace std; 3 | #define ReadFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 4 | #define endl '\n' 5 | 6 | typedef long long int ll; 7 | 8 | //Created by Shreyans Sheth [bholagabbar] 9 | 10 | int main() 11 | { 12 | ios_base::sync_with_stdio(false); 13 | ReadFile; 14 | unordered_set s; 15 | ll x; 16 | vector a; 17 | for(ll i=0;i<1000000;i++) 18 | { 19 | cin>>x; 20 | s.insert() 21 | } 22 | for(auto i:s) 23 | a.push_back(i); 24 | sort(v.begin(),v.end()); 25 | for(auto i:v) 26 | { 27 | BinarySearch() 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/Coursera_Algo1/Inversion_Quiz.py: -------------------------------------------------------------------------------- 1 | def MergeAndCntInv(l,r,a): 2 | i=j=k=cnt=0 3 | ll,rl,al=len(l),len(r),len(a) 4 | #Counting Split Inversions 5 | 6 | '''Essentially left inversions from sorted array which become split inversions 7 | inside of themselves, right inversions same fo for right sorted array and then stich the 2 together by final 8 | split inversion counting 9 | ''' 10 | while i 2: 17 | v1, v2 = choose_random_key(G) 18 | G[v1].extend(G[v2]) 19 | print (v1,v2,G[v1]) 20 | for x in G[v2]: 21 | G[x].remove(v2) 22 | G[x].append(v1) 23 | while v1 in G[v1]: 24 | G[v1].remove(v1) 25 | del G[v2] 26 | print(G) 27 | for key in G.keys(): 28 | length.append(len(G[key])) 29 | return length[0] 30 | 31 | def operation(n): 32 | i = 0 33 | count = 10000 34 | while i < n: 35 | data = copy.deepcopy(G) 36 | min_cut = karger(data) 37 | if min_cut < count: 38 | count = min_cut 39 | i = i + 1 40 | return count 41 | 42 | 43 | print(operation(100)) -------------------------------------------------------------------------------- /Code/WorkspaceB/Coursera_Algo1/NoOfInversions.py: -------------------------------------------------------------------------------- 1 | '''input 2 | 1 3 | 4 | 6 5 | 1 6 | 2 7 | 8 8 | 4 9 | 5 10 | 6 11 | ''' 12 | def MergeAndCntInv(l,r,a): 13 | i=j=k=cnt=0 14 | ll,rl,al=len(l),len(r),len(a) 15 | #Counting Split Inversions 16 | 17 | '''Essentially left inversions from sorted array which become split inversions 18 | inside of themselves, right inversions same fo for right sorted array and then stich the 2 together by final 19 | split inversion counting 20 | ''' 21 | while i0: 57 | tp=input() 58 | while(tp=='\n'): 59 | tp=input(); 60 | x=int(input()) 61 | a=[] 62 | for i in range(x): 63 | a.append(int(input())) 64 | print(MergeSort(a)) 65 | tc-=1 66 | 67 | -------------------------------------------------------------------------------- /Code/WorkspaceB/Coursera_Algo1/QuickSort.py: -------------------------------------------------------------------------------- 1 | #Implementation of QuickSort in Python 2 | def Partition(a,l,r): 3 | a[l],a[(l+r)//2]=a[(l+r)//2],a[l] #Middle Element as pivot. Getting to front 4 | pivot=a[l] # choosing pivot 5 | i=l+1 # partition between elements less than pivot and greater than pivot 6 | 7 | for j in range(l+1,r+1): 8 | if a[j]=3: #medain of 3 which is fastest 5 | x,y,z=a[l],a[(r+l)//2],a[r] 6 | w=[x,y,z] 7 | w.sort(); 8 | ind=0 9 | if w[1]==x: 10 | ind=l 11 | elif w[1]==z: 12 | ind=r 13 | else: 14 | ind=((r+l)//2) 15 | a[l],a[ind]=a[ind],a[l] 16 | 17 | pivot=a[l] #remove previous statements for default 1st element as pivot 18 | i=l+1 19 | for j in range(l+1,r+1): 20 | if a[j]=3: #medain of 3 which is fastest 3 | x,y,z=a[l],a[(r+l)//2],a[r] 4 | w=[x,y,z] 5 | w.sort(); 6 | ind=0 7 | if w[1]==x: 8 | ind=l 9 | elif w[1]==z: 10 | ind=r 11 | else: 12 | ind=((r+l)//2) 13 | a[l],a[ind]=a[ind],a[l] 14 | 15 | pivot=a[l] 16 | i=l+1 17 | for j in range(l+1,r+1): 18 | if a[j]stat: 32 | RSelect(a[0:part], stat) 33 | else: 34 | RSelect(a[part:len(a)], stat-part+1) 35 | 36 | a=[1,4,5,23,67] 37 | print(RSelect(a,1), RSelect(a,2), RSelect (a,3)) -------------------------------------------------------------------------------- /Code/WorkspaceB/Java_Extras/ABSYS.java: -------------------------------------------------------------------------------- 1 | /*input 2 | 3 3 | 4 | 23 + 47 = machula 5 | 6 | 3247 + 5machula2 = 3749 7 | 8 | machula13 + 75425 = 77038 9 | */ 10 | import java.io.*; 11 | import java.util.*; 12 | import java.math.*; 13 | class ABSYS 14 | { 15 | public static void main(String[] args) throws IOException 16 | { 17 | BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); 18 | PrintWriter pw=new PrintWriter(System.out); 19 | int n=Integer.parseInt(br.readLine()); 20 | String d=br.readLine(); 21 | for(int i=0;i(n/2)) 22 | { 23 | pw.println("-1"); 24 | } 25 | else 26 | { 27 | int x=2; 28 | int cnt=0; 29 | while(cnt!=k) 30 | { 31 | pw.print(x+" "); 32 | cnt++; 33 | x+=2; 34 | } 35 | pw.println(); 36 | } 37 | } 38 | pw.flush(); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/Java_Extras/CANDY3.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.io.*; 3 | import java.math.*; 4 | 5 | class CANDY3 6 | { 7 | public static void main (String[] args) throws IOException 8 | { 9 | BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); 10 | PrintWriter pw=new PrintWriter(System.out); 11 | long t; 12 | t=Integer.parseInt(br.readLine()); 13 | for(long i1=0;i1 ts=new TreeSet (); 12 | long sum=0; 13 | for(int i=0;i 2 | #include 3 | #include 4 | int main() 5 | { 6 | char s[1000000]; 7 | int n; 8 | scanf("%s",&s); 9 | std::set st; 10 | for(int j=0;j 2 | int main() 3 | { 4 | int cnt=0; 5 | int nos=0; 6 | scanf("%d",&nos); 7 | int z[nos]; 8 | int i; 9 | for(i=0;i 5 | using namespace std; 6 | #define readFile freopen("E:/Shreyans/Documents/Coding Workspace/STDINPUT.txt","r",stdin); 7 | #define getPrecision(s,p) fixed< pii; 22 | typedef pair pll; 23 | 24 | int main() { 25 | boostIO; 26 | int tcno; 27 | cin >> tcno; 28 | for (int tc = 1; tc <= tcno; tc++) { 29 | string s; 30 | cin >> s; 31 | int len = s.size(), ptr = 1, cnt = 0; 32 | while (ptr < len) { 33 | if (s[ptr] == s[ptr - 1]) { 34 | ptr++; 35 | } else { 36 | s[ptr - 1] = s[ptr]; 37 | cnt++; 38 | } 39 | } 40 | if (s[ptr - 1] == '-') { 41 | cnt++; 42 | } 43 | cout << "Case #" << tc << ": " << cnt << endl; 44 | } 45 | return 0; 46 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/Misc/MultitaskEasy.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bholagabbar/algorithmic-programming/a5482cca93f79ec8495256fa1a08525e61bfb899/Code/WorkspaceB/Misc/MultitaskEasy.cpp -------------------------------------------------------------------------------- /Code/WorkspaceB/Misc/OBJSEARCH.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class A 5 | { 6 | public: 7 | int a, b; 8 | }; 9 | 10 | int main() 11 | { 12 | A objarr[10]; //Object array 13 | for(int i=0;i<10;i++)//Populating the class array variable randomly (i and i+2. Can change to anythign) 14 | { 15 | objarr[i].a=i; 16 | objarr[i].b=i+2; 17 | } 18 | int fa=7,fb=9;//If these values match any objects values, you have found the object 19 | for(int i=0;i<10;i++) 20 | { 21 | if(objarr[i].a==fa && objarr[i].b==fb)//Matching fa and fb to the objects values and checking if they match 22 | { 23 | cout<<"Object found at index "<<(i+1)< 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int t; 7 | cin>>t; 8 | for(int i=0;i>a; 12 | int l=strlen(a); 13 | int f=0; 14 | int b=l-1; 15 | int cnt=0; 16 | int flag=1; 17 | while(f>=b) 18 | { 19 | if(a[f]!=a[b]) 20 | { 21 | cnt++; 22 | if(cnt>1) 23 | { 24 | flag=0; 25 | break; 26 | } 27 | } 28 | f++; 29 | b--; 30 | } 31 | if(flag==1) 32 | { 33 | cout<<"yes"< 2 | #include 3 | main() 4 | { 5 | int dsum=0; 6 | int c1=-1; 7 | int abno [28124]; 8 | int i=0; 9 | int j=0; 10 | int k=0; 11 | int l=0; 12 | for(i=2;i<28124;i++) 13 | { 14 | int f=(i/2); 15 | for(j=1;j<=f;j++) 16 | { 17 | if(i%j==0) 18 | { 19 | dsum+=j; 20 | } 21 | } 22 | if(dsum>i) 23 | { 24 | c1++; 25 | abno[c1]=i; 26 | } 27 | } 28 | int h=((c1*(c1+1))/2); 29 | int abnos[h]; 30 | int cnt=0; 31 | for(i=0;i 2 | #include 3 | using namespace std; 4 | int main () 5 | { 6 | ios_base::sync_with_stdio(false);cin.tie(0); 7 | int a[] = {0,1,2,3,4,5,6,7,8,9}; 8 | int cnt=1; 9 | while(cnt<1000000) 10 | { 11 | next_permutation(a,a+10); 12 | cnt++; 13 | } 14 | for(int j:a) 15 | { 16 | cout< 2 | #include 3 | main() 4 | { 5 | int max, min, i,j,h,cnt1=-1,cnt2=-1; 6 | printf("Please enter min no\n"); 7 | scanf("%d",&min); 8 | printf("Please enter max no\n"); 9 | scanf("%d",&max); 10 | printf("\n\n"); 11 | for(i=min;i<=(max);i++) 12 | { 13 | cnt1++; 14 | for((j=min+cnt1);j<=(max);j++) 15 | { 16 | printf("%d",j); 17 | } 18 | if(j>min) 19 | { 20 | cnt2++; 21 | for(h=min;h<(min+cnt2);h++) 22 | { 23 | printf("%d",h); 24 | } 25 | } 26 | printf("\n"); 27 | } 28 | getch(); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /Code/WorkspaceB/Misc/SUPER_FAST_IO.cpp: -------------------------------------------------------------------------------- 1 | //Doesnt work on windows. Only OJ 2 | #include 3 | using namespace std; 4 | 5 | inline int scanFast() 6 | { 7 | int num = 0; 8 | char c = getchar_unlocked(); 9 | bool flag = 0; 10 | while(!((c>='0' & c<='9') || c == '-')) 11 | c=getchar_unlocked(); 12 | if(c == '-') 13 | { 14 | flag = 1; 15 | c=getchar_unlocked(); 16 | } 17 | while(c>='0' && c<='9') 18 | { 19 | num = (num<<1)+(num<<3)+c-'0'; 20 | c=getchar_unlocked(); 21 | } 22 | if(flag==0) 23 | return num; 24 | else 25 | return -1*num; 26 | } 27 | 28 | //Created by Shreyans Sheth [bholagabbar] 29 | 30 | int main() 31 | { 32 | int n=scanFast(); 33 | printf("%d\n",n); 34 | return 0; 35 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/Misc/Sentence Break.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | main() 5 | { 6 | char t[100]; 7 | printf("Please enter title\n"); 8 | gets(t); 9 | int i=0,j=0; 10 | int cntw=1; 11 | int len=strlen(t); 12 | for(i=0;i=97)&&(t[0]<=122)) 15 | { 16 | t[0]-=32; 17 | } 18 | if(t[i]==' ') 19 | { 20 | cntw++; 21 | if((t[i+1]>=97)&&(t[0]<=122)) 22 | { 23 | t[i]-=32; 24 | } 25 | } 26 | } 27 | printf("No of words:%d",cntw); 28 | printf("\n"); 29 | for(i=0;i 2 | 3 | int main() { 4 | int b[3]; 5 | b[0] = 10; 6 | b[1] = 21; 7 | //std::cout << b << " " << b+1 << " " << b+2 << '\n'; 8 | std::cout << *(b+1) << "\n"; 9 | std::cout << *b + 1; 10 | return 0; 11 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/Misc/remove_comments.txt: -------------------------------------------------------------------------------- 1 | (^\/\/.*)|(\s+\/\/.*)|((\/\*)(.|\n)+?(\*\/)) -------------------------------------------------------------------------------- /Code/WorkspaceB/Misc/scratch.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | ios_base::sync_with_stdio(false);cin.tie(0); 7 | int t=5; 8 | while(t--) 9 | { 10 | cout<<"Hello world"< 5 | using namespace std; 6 | #define readFile freopen("E:/Shreyans/Documents/CP-algorithmic-programming-database/Code/WorkspaceB/C++ Files/INPUT.txt","r",stdin); 7 | #define getPrecision(s,p) fixed< pii; 22 | typedef pair pll; 23 | 24 | int main() { 25 | boostIO; 26 | readFile; 27 | int a [5]; 28 | for (int i = 0; i < 4; i++) { 29 | cin >> a[i]; 30 | } 31 | for (int i : a) { 32 | cout << i <<" "; 33 | } 34 | 35 | return 0; 36 | } -------------------------------------------------------------------------------- /Code/WorkspaceB/Python Scripts/ACMKP02.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bholagabbar/algorithmic-programming/a5482cca93f79ec8495256fa1a08525e61bfb899/Code/WorkspaceB/Python Scripts/ACMKP02.py -------------------------------------------------------------------------------- /Code/WorkspaceB/Python Scripts/ADDMAG.py: -------------------------------------------------------------------------------- 1 | import math 2 | t=int(input()); 3 | for q in range(t): 4 | n=int(input()) 5 | if n==1: 6 | print("1") 7 | elif n==2: 8 | print("2") 9 | else: 10 | ans=3+((n+1-3)//2) 11 | print(int(ans)) -------------------------------------------------------------------------------- /Code/WorkspaceB/Python Scripts/BRACKETS.py: -------------------------------------------------------------------------------- 1 | '''input 2 | 1 3 | ()((()())) 4 | ''' 5 | def mbal(a): 6 | bal=0 7 | mb=0 8 | for i in range(len(a)): 9 | if(a[i]=='('): 10 | bal+=1 11 | elif(a[i]==')'): 12 | bal-=1 13 | mb=max(mb,bal) 14 | 15 | return mb 16 | 17 | tc=eval(input()) 18 | for t in range (tc): 19 | mxb=mbal(input()) 20 | a='('*mxb+')'*mxb 21 | print(a) -------------------------------------------------------------------------------- /Code/WorkspaceB/Python Scripts/CANTON.py: -------------------------------------------------------------------------------- 1 | '''input 2 | 3 3 | 2 4 | 14 5 | 7 6 | ''' 7 | 8 | sum=[] 9 | 10 | def init_sum(): 11 | cnt=1 12 | for i in range (1,4472): 13 | sum.append((i*(i+1))>>1) 14 | 15 | def find(n): 16 | for i in range (len(sum)): 17 | if n<=sum[i]: 18 | if ((n*(n+1))>>1)==sum[i]: 19 | return (n) 20 | else: 21 | return (i+1) 22 | 23 | init_sum() 24 | tc=eval(input()) 25 | for i in range(tc): 26 | n=eval(input()) 27 | n1=find(n) 28 | z=sum[n1-1] 29 | x=z-n+1 30 | y=(n1+1)-x 31 | if(n1%2==1): 32 | print ('TERM '+str(n)+' IS '+str(x)+'/'+str(y)) 33 | else: 34 | print ('TERM '+str(n)+' IS '+str(y)+'/'+str(x)) -------------------------------------------------------------------------------- /Code/WorkspaceB/Python Scripts/CAPPLE.py: -------------------------------------------------------------------------------- 1 | '''input 2 | 2 3 | 3 4 | 3 3 3 5 | 4 6 | 1 2 3 3 7 | ''' 8 | tc=eval(input()) 9 | for t in range(tc): 10 | n=eval(input()) 11 | a=input().strip().split(' ') 12 | x=set() 13 | for i in range (n): 14 | x.add(a[i]) 15 | print(len(x)) -------------------------------------------------------------------------------- /Code/WorkspaceB/Python Scripts/CFRTEST.py: -------------------------------------------------------------------------------- 1 | tc=eval(input()) 2 | for j in range(tc): 3 | n=eval(input()) 4 | s=input().split(' ') 5 | a=set() 6 | for i in range(n): a.add(eval(s[i])) #Keep adding elements to set and print the size in the end 7 | print(len(a)) -------------------------------------------------------------------------------- /Code/WorkspaceB/Python Scripts/CIELNUM2.py: -------------------------------------------------------------------------------- 1 | '''input 2 | 6 3 | milk 58 4 | Ciel's Drink 80 5 | The curry 2nd edition 888888 6 | rice omelet 85855 7 | unagi 1 8 | The first and last letters can be a space 358 9 | ''' 10 | sum=0 11 | for tc in range(int(input())): 12 | a=input().strip().split() 13 | n=int(a[len(a)-1]) 14 | c8,c5,c3=0,0,0 15 | flag=1 16 | while(n>0): 17 | rem=n%10 18 | n=n//10 19 | if rem !=8 and rem!=5 and rem!=3: 20 | flag=0 21 | break 22 | else: 23 | if rem==8: 24 | c8+=1 25 | elif rem==5: 26 | c5+=1 27 | elif rem==3: 28 | c3+=1 29 | if flag==1: 30 | if c8>=c5 and c5>=c3: 31 | sum+=1 32 | 33 | print(sum) 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /Code/WorkspaceB/Python Scripts/DBOY.py: -------------------------------------------------------------------------------- 1 | '''input 2 | 1 3 | 4 4 | 1 2 3 4 5 | 1 4 5 3 6 | ''' 7 | import sys 8 | 9 | inf=sys.maxsize 10 | tc=eval(input()) 11 | while tc>0: 12 | n=eval(input()) 13 | h=input().split(' ')#dis 14 | p=input().split(' ')#pumps fuel 15 | dp=[] 16 | sum=0 17 | 18 | for i in range (n): 19 | val=int(h[i])#dist for del e.i need to find min pumps for this 20 | dp.append([inf]*(val+1)) 21 | 22 | dp[i][0]=0 23 | #for each del 24 | for j in range(1,val+1): 25 | #for the pumps 26 | for k in range (0,n): 27 | p[k]=int(p[k]) 28 | 29 | if p[k]<=j and 1+dp[i][j-p[k]]j: 33 | break 34 | 35 | sum+=dp[i][val] 36 | 37 | print(sum) 38 | tc-=1 39 | 40 | -------------------------------------------------------------------------------- /Code/WorkspaceB/Python Scripts/DISCHAR.py: -------------------------------------------------------------------------------- 1 | '''input 2 | 2 3 | abc 4 | aba 5 | ''' 6 | tc=eval(input()) 7 | for j in range(tc): 8 | s=input() 9 | a=set() 10 | for i in range(len(s)): 11 | a.add(s[i]) 12 | print(len(a)) -------------------------------------------------------------------------------- /Code/WorkspaceB/Python Scripts/DISHOWN.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bholagabbar/algorithmic-programming/a5482cca93f79ec8495256fa1a08525e61bfb899/Code/WorkspaceB/Python Scripts/DISHOWN.py -------------------------------------------------------------------------------- /Code/WorkspaceB/Python Scripts/ELIS.py: -------------------------------------------------------------------------------- 1 | '''input 2 | 5 3 | 1 4 2 4 3 4 | ''' 5 | n=int(input().strip()) 6 | a=input().split() 7 | for i in range(len(a)): 8 | a[i]=int(a[i]) 9 | dp=[0]*(len(a)) 10 | for i in range(len(a)): 11 | dp[i]=1 12 | for j in range(i-1,-1,-1): #looped backwards to check for smaller numbers 13 | if a[j]dp[i]: #check if the len of the subsequence including this is longer 14 | dp[i]=dp[j]+1 15 | print(max(dp)) -------------------------------------------------------------------------------- /Code/WorkspaceB/Python Scripts/GUESS.py: -------------------------------------------------------------------------------- 1 | '''input 2 | 3 3 | 1 1 4 | 1 2 5 | 2 3 6 | ''' 7 | 8 | import math 9 | import fractions 10 | 11 | tc=eval(input()) 12 | for tc in range (tc): 13 | s=input().split(' ') 14 | a=int(s[0]) 15 | b=int(s[1]) 16 | x=math.ceil(a/2)*(b//2) 17 | y=math.ceil(b/2)*(a//2) 18 | #print(x,y) 19 | z1=(x+y) 20 | z2=(a*b) 21 | #print(z1,z2) 22 | g=fractions.gcd(z1,z2) 23 | #print(g) 24 | z1=z1//g 25 | z2=z2//g 26 | print(str(z1)+'/'+str(z2)) 27 | 28 | 29 | -------------------------------------------------------------------------------- /Code/WorkspaceB/Python Scripts/HHAL.py: -------------------------------------------------------------------------------- 1 | '''input 2 | 1 3 | abbabaab 4 | ''' 5 | tc=eval(input()) 6 | while tc>0: 7 | s=input() 8 | if s==s[::-1]: 9 | print('1') 10 | else: 11 | print('2') 12 | tc-=1 -------------------------------------------------------------------------------- /Code/WorkspaceB/Python Scripts/InfStr.py: -------------------------------------------------------------------------------- 1 | class InfiniteString: 2 | def equal(self,x1,x2): 3 | if(x1*len(x2)==x2*len(x1)): 4 | return("Equal") 5 | else: 6 | return("Not equal") 7 | print(InfiniteString().equal("aaa","bbb")) -------------------------------------------------------------------------------- /Code/WorkspaceB/Python Scripts/KFUNC.py: -------------------------------------------------------------------------------- 1 | '''input 2 | 2 3 | 1 1 1 3 4 | 14 7 2 4 5 | ''' 6 | #use PYPY 7 | 8 | def convert(a): 9 | a=str(a) 10 | while len(a)!=1: 11 | sum=0 12 | for i in a: 13 | sum+=int(i) 14 | a=str(sum) 15 | return int(a) 16 | 17 | tc=int(input()) 18 | for q in range(tc): 19 | a,d,l,r=map(int, raw_input().split()) 20 | sum,ans,start,cnt=convert(a),0,a+d,1 21 | conv=sum 22 | while convert(start)!=conv: 23 | sum+=convert(start) 24 | start+=d 25 | cnt+=1 26 | ans-=sum*((l-1)//cnt) 27 | start=a+(l-2)*d 28 | for i in range(0,(l-1)%cnt): 29 | ans-=convert(start) 30 | start-=d 31 | ans+=sum*(r//cnt) 32 | start=a+(r-1)*d 33 | for i in range (0,r%cnt): 34 | ans+=convert(start) 35 | start-=d 36 | print ans -------------------------------------------------------------------------------- /Code/WorkspaceB/Python Scripts/ListSub.py: -------------------------------------------------------------------------------- 1 | n=eval(input("Enter n: ")) # keep sub 20-ish max 2 | for i in range(0,(2**n)):# loop from 0 to (2^n)-1 3 | cursub="Subset "+str(i+1)+" Contains Elements: " 4 | for j in range(0,n): 5 | if((1<0): #Checking if jth bit in i is set 6 | cursub+=(str(j+1)+" ") 7 | print (cursub) 8 | print ("All ", (2**n)," Subsets printed") -------------------------------------------------------------------------------- /Code/WorkspaceB/Python Scripts/MONTRANS.py: -------------------------------------------------------------------------------- 1 | '''input 2 | 2 3 | 9 77 69 4 | 98 99 0 5 | ''' 6 | tc=eval(input().strip()) 7 | for tl in range (0,tc): 8 | s1=input().strip().split(' ') 9 | a=int(s1[0]) 10 | b=int(s1[1]) 11 | c=int(s1[2]) 12 | ans=0 13 | f=float((str(a)+'.'+str(b))) 14 | m=f 15 | cnt=0 16 | cd=float('0.'+str(c)) 17 | while cnt<=10000 and (a>0 or b>=c): 18 | if(b>=c): 19 | b-=c 20 | elif bm: 29 | m=f 30 | ans=cnt 31 | 32 | print (ans) 33 | -------------------------------------------------------------------------------- /Code/WorkspaceB/Python Scripts/PPNUM.py: -------------------------------------------------------------------------------- 1 | '''input 2 | 1 3 | 1 2 4 | 5 | ''' 6 | 7 | def sumf(a): 8 | s=((a*(a+1))//2)# //->AC /->WA. 3 hours wasted. FML 9 | return s 10 | 11 | t=list() 12 | for i in range (10): 13 | t.append(10**i) 14 | 15 | m=1000000007 16 | tc=eval(input()) 17 | while (tc>0): 18 | s1=input().split(' ') 19 | a=int(s1[0]) 20 | b=int(s1[1]) 21 | l1=len(s1[0]) 22 | l2=len(s1[1]) 23 | s=0 24 | if(l1==l2): 25 | s=((sumf(b)-sumf(a-1))%m*l1) 26 | 27 | else: 28 | x=((sumf(t[l1]-1)-sumf(a-1))%m*l1)%m 29 | y=((sumf(b)-sumf(t[l2-1]-1))%m*l2)%m 30 | s=x+y 31 | for i in range(l1+1,l2): 32 | s+=(sumf(t[i]-1)-sumf(t[i-1]-1))*i 33 | 34 | print (s%m) 35 | tc-=1 -------------------------------------------------------------------------------- /Code/WorkspaceB/Python Scripts/PROB.py: -------------------------------------------------------------------------------- 1 | tc =eval(input()) 2 | for i in range (0,tc): 3 | a=input().split(' ') 4 | print(int(a[0])/(int(a[0])+int(a[1]))) -------------------------------------------------------------------------------- /Code/WorkspaceB/Python Scripts/SDSQUARE.py: -------------------------------------------------------------------------------- 1 | '''input 2 | 2 3 | 1 10 4 | 100 10000 5 | ''' 6 | import math 7 | 8 | tc=eval(input()) 9 | for i in range (tc): 10 | #s=input() 11 | s=input().split(' ') 12 | a=int(s[0]) 13 | b=int(s[1]) 14 | cnt=0 15 | sqa=int(math.sqrt(a)) 16 | sqb=int(math.sqrt(b)) 17 | if sqa*sqa==a or sqb*sqb==b: 18 | cnt+=1 19 | 20 | cnt+=(sqb-sqa) 21 | print (cnt) 22 | -------------------------------------------------------------------------------- /Code/WorkspaceB/Python Scripts/SUMPAIR.py: -------------------------------------------------------------------------------- 1 | '''input 2 | 3 3 | 3 3 4 | 3 5 8 5 | 4 3 6 | 5 8 10 12 7 | 5 3 8 | 3 2 8 17 15 9 | ''' 10 | def MergeAndCntInv(l,r,a,D): 11 | i=j=k=cnt=0 12 | ll,rl,al=len(l),len(r),len(a) 13 | while i0: 51 | s=input().split() 52 | D=int(s[0]) 53 | n=int(s[1]) 54 | s1=input().split() 55 | a=[] 56 | for i in range(len(s1)): 57 | a.append(int(s1[i])) 58 | print(MergeSort(a,D)) 59 | tc-=1 -------------------------------------------------------------------------------- /Code/WorkspaceB/Python Scripts/TEST.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy 3 | 4 | def rmse(predictions, targets): 5 | return numpy.sqrt(numpy.mean((numpy.array(predictions)-numpy.array(targets))**2)) 6 | 7 | a = [[1 ,2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]] 8 | rotated = a 9 | final = rotated 10 | min_rmse = rmse(rotated, a) 11 | for i in xrange(3): 12 | rotated = numpy.rot90(rotated, 1) 13 | curr_rmse = rmse(rotated, a) 14 | print min_rmse, curr_rmse 15 | if curr_rmse > min_rmse: 16 | min_rmse = curr_rmse 17 | final = rotated 18 | print final -------------------------------------------------------------------------------- /Code/WorkspaceB/Python Scripts/TWOSTR.py: -------------------------------------------------------------------------------- 1 | t=int(input()) 2 | for ts in range (t): 3 | s1=input() 4 | s2=input() 5 | f=1 6 | for i in range (len(s1)): 7 | if s1[i]!='?' and s2[i]!='?' and s1[i]!=s2[i]: 8 | f=0 9 | break 10 | if f==1: 11 | print("Yes") 12 | else: 13 | print("No") -------------------------------------------------------------------------------- /Code/WorkspaceB/Python Scripts/XORNUMBER.py: -------------------------------------------------------------------------------- 1 | import math 2 | t=eval(input()) 3 | for q in range(t): 4 | n=int(input()) 5 | x=int(math.log(n+1,2)) 6 | if 1< 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/LOCAL_CONTESTS/DCL15/DCL15.eml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/LOCAL_CONTESTS/OPC_ACUMEN_2015/ACUGRAM.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.LOCAL_CONTESTS.OPC_ACUMEN_2015; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | import java.util.Arrays; 7 | 8 | /* Name of the class has to be "Main" only if the class is public. */ 9 | class ACUGRAM { 10 | public static void main(String[] args) throws IOException { 11 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 12 | int t = Integer.parseInt(br.readLine()); 13 | for (int i = 0; i < t; i++) { 14 | int n = Integer.parseInt(br.readLine()); 15 | String[] a = new String[n]; 16 | for (int j = 0; j < n; j++) { 17 | a[j] = br.readLine(); 18 | } 19 | Arrays.sort(a); 20 | for (int j = 0; j < n; j++) { 21 | System.out.println(a[j]); 22 | } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Code/src/CODECHEF/LOCAL_CONTESTS/OPC_ACUMEN_2015/ACUGRAY.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.LOCAL_CONTESTS.OPC_ACUMEN_2015; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | 7 | class ACUGRAY { 8 | public static void main(String args[]) throws IOException { 9 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 10 | int t = Integer.parseInt(br.readLine()); 11 | for (int i = 0; i < t; i++) { 12 | char[] a = br.readLine().toCharArray(); 13 | String ans = ""; 14 | ans += a[0]; 15 | for (int j = 0; j < a.length - 1; j++) { 16 | int x = (a[j] - 48) ^ (a[j + 1] - 48); 17 | ans += x; 18 | } 19 | System.out.println(ans); 20 | } 21 | 22 | } 23 | } -------------------------------------------------------------------------------- /Code/src/CODECHEF/LOCAL_CONTESTS/XCPT2015/src/XC202.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.LOCAL_CONTESTS.XCPT2015.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | 7 | /** 8 | * Created by Shreyans on 31/1/15 at 9:04 PM using IntelliJ IDEA (Fast IO Template) 9 | */ 10 | 11 | class XC202 { 12 | public static void main(String[] args) throws IOException { 13 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 14 | int t = Integer.parseInt(br.readLine()); 15 | StringBuffer sb = new StringBuffer(); 16 | for (int i = 0; i < t; i++) { 17 | int n = Integer.parseInt(br.readLine()); 18 | String a2[] = br.readLine().split(" "); 19 | int[] a = new int[n]; 20 | int max = Integer.parseInt(a2[0]); 21 | int ind = 1; 22 | for (int j = 1; j < a2.length; j++) { 23 | a[j] = Integer.parseInt(a2[j]); 24 | if (a[j] > max) { 25 | ind = j + 1; 26 | max = a[j]; 27 | } 28 | } 29 | sb.append(ind + "\n"); 30 | } 31 | System.out.println(sb); 32 | } 33 | } -------------------------------------------------------------------------------- /Code/src/CODECHEF/LONG_CHALLENGE/NOV15/src/KFUNC.py: -------------------------------------------------------------------------------- 1 | '''input 2 | 2 3 | 1 1 1 3 4 | 14 7 2 4 5 | ''' 6 | #use PYPY 7 | 8 | def convert(a): 9 | a=str(a) 10 | while len(a)!=1: 11 | sum=0 12 | for i in a: 13 | sum+=int(i) 14 | a=str(sum) 15 | return int(a) 16 | 17 | tc=int(input()) 18 | for q in range(tc): 19 | a,d,l,r=map(int, raw_input().split()) 20 | sum,ans,start,cnt=convert(a),0,a+d,1 21 | conv=sum 22 | while convert(start)!=conv: 23 | sum+=convert(start) 24 | start+=d 25 | cnt+=1 26 | ans-=sum*((l-1)//cnt) 27 | start=a+(l-2)*d 28 | for i in range(0,(l-1)%cnt): 29 | ans-=convert(start) 30 | start-=d 31 | ans+=sum*(r//cnt) 32 | start=a+(r-1)*d 33 | for i in range (0,r%cnt): 34 | ans+=convert(start) 35 | start-=d 36 | print ans -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/ALEXNUMB.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | 7 | /** 8 | * Created by Shreyans on 1/16/2015 using IntelliJ IDEA 9 | */ 10 | 11 | class ALEXNUMB { 12 | public static void main(String[] args) throws IOException { 13 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 14 | int t = Integer.parseInt(br.readLine()); 15 | for (int i = 0; i < t; i++) { 16 | Long n = Long.parseLong(br.readLine()); 17 | String[] s = br.readLine().split(" "); 18 | n--; 19 | System.out.println((n * (n + 1)) / 2); 20 | } 21 | } 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/ANUDTC.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | 7 | /** 8 | * Created by Shreyans on 1/8/2015 using IntelliJ IDEA 9 | */ 10 | 11 | class ANUDTC { 12 | public static void main(String[] args) throws IOException { 13 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 14 | int t = Integer.parseInt(br.readLine()); 15 | for (int i = 0; i < t; i++) { 16 | long a = Integer.parseInt(br.readLine()); 17 | String ans = ""; 18 | if (360 % a == 0) { 19 | ans += "y "; 20 | } else { 21 | ans += "n "; 22 | } 23 | if (a <= 360) { 24 | ans += "y "; 25 | } else { 26 | ans += "n "; 27 | } 28 | if ((a * (a + 1) / 2) <= 360) { 29 | ans += "y"; 30 | } else { 31 | ans += "n"; 32 | } 33 | System.out.println(ans); 34 | } 35 | } 36 | } 37 | 38 | 39 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/ANUWTA.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | import java.math.BigInteger; 7 | 8 | /** 9 | * Created by Shreyans on 1/30/2015 using IntelliJ IDEA 10 | */ 11 | 12 | class ANUWTA { 13 | public static void main(String[] args) throws IOException { 14 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 15 | int t = Integer.parseInt(br.readLine()); 16 | StringBuffer sb = new StringBuffer(); 17 | for (int i = 0; i < t; i++) { 18 | BigInteger bi = new BigInteger(br.readLine()); 19 | BigInteger ans = ((bi.multiply(new BigInteger("3").add(bi))).divide(new BigInteger("2"))); 20 | System.out.println(ans); 21 | } 22 | } 23 | } 24 | 25 | 26 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/ATTIC.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | 7 | /** 8 | * Created by Shreyans on 1/16/2015 using IntelliJ IDEA 9 | */ 10 | 11 | class ATTIC { 12 | public static void main(String[] args) throws IOException { 13 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 14 | int t = Integer.parseInt(br.readLine()); 15 | StringBuffer sb = new StringBuffer(); 16 | for (int i = 0; i < t; i++) { 17 | String s = br.readLine(); 18 | int cnt = 0; 19 | int d = 0; 20 | for (int j = 0; j < s.length(); j++) { 21 | if (s.charAt(j) == '.') { 22 | int x = (s.indexOf('#', j + 1) - j); 23 | if (x > cnt) { 24 | cnt = x; 25 | d++; 26 | } 27 | j += x - 1; 28 | } 29 | } 30 | sb.append(d).append("\n"); 31 | } 32 | System.out.println(sb); 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/CARVANS.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | 7 | /** 8 | * Created by Shreyans on 12/6/2014 in IntelliJ 9 | */ 10 | class CARVANS { 11 | public static void main(String[] args) throws IOException { 12 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 13 | int t = Integer.parseInt(br.readLine()); 14 | for (int i = 0; i < t; i++) { 15 | int n = Integer.parseInt(br.readLine()); 16 | String[] s = br.readLine().split(" "); 17 | int len = s.length; 18 | int cnt = 1; 19 | for (int j = 1; j < s.length; j++) { 20 | if (Integer.parseInt(s[j]) > Integer.parseInt(s[j - 1])) { 21 | s[j] = s[j - 1]; 22 | } else { 23 | cnt++; 24 | } 25 | } 26 | System.out.println(cnt); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/CHEFSTON.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | 7 | /** 8 | * Created by Shreyans on 1/4/2015 using IntelliJ IDEA 9 | */ 10 | 11 | class CHEFSTON { 12 | public static void main(String[] args) throws IOException { 13 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 14 | int t = Integer.parseInt(br.readLine()); 15 | StringBuffer sb = new StringBuffer(); 16 | for (int i = 0; i < t; i++) { 17 | String[] s = br.readLine().split(" "); 18 | int n1 = Integer.parseInt(s[0]); 19 | long k1 = Long.parseLong(s[1]); 20 | String[] n = br.readLine().split(" "); 21 | String[] k = br.readLine().split(" "); 22 | long max = 0, min = 0; 23 | for (int j = 0; j < n.length; j++) { 24 | min = k1 / Long.parseLong(n[j]); 25 | if (min * Long.parseLong(k[j]) > max) { 26 | max = min * Integer.parseInt(k[j]); 27 | } 28 | } 29 | sb.append(max + "\n"); 30 | } 31 | System.out.println(sb); 32 | } 33 | } 34 | 35 | 36 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/CIELRCPT.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | 7 | /** 8 | * Created by Shreyans on 11/23/2014 in IntelliJ 9 | */ 10 | class CIELRCPT { 11 | public static void main(String[] args) throws IOException { 12 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 13 | int t = Integer.parseInt(br.readLine()); 14 | int[] et = new int[12]; 15 | int ei = 0; 16 | StringBuffer sb = new StringBuffer(); 17 | for (int i = 0; i < 12; i++) { 18 | et[i] = (int) Math.pow(2, ei); 19 | ei++; 20 | } 21 | for (int i = 0; i < t; i++) { 22 | int n = Integer.parseInt(br.readLine()); 23 | int cnt = 0; 24 | int mi = 11; 25 | while ((n > -1) && (mi > -1)) { 26 | if (n - et[mi] >= 0) { 27 | n = n - et[mi]; 28 | cnt++; 29 | } else { 30 | mi--; 31 | } 32 | } 33 | System.out.println(cnt); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/COMMUTE.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | 7 | /** 8 | * Created by Shreyans on 1/17/2015 using IntelliJ IDEA 9 | */ 10 | 11 | class COMMUTE { 12 | public static void main(String[] args) throws IOException { 13 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 14 | StringBuffer sb = new StringBuffer(); 15 | int t = Integer.parseInt(br.readLine()); 16 | for (int i = 0; i < t; i++) { 17 | int n = Integer.parseInt(br.readLine()); 18 | int time = 0; 19 | for (int j = 0; j < n; j++) { 20 | String[] s = br.readLine().split(" "); 21 | int x = Integer.parseInt(s[0]); 22 | int l = Integer.parseInt(s[1]); 23 | int f = Integer.parseInt(s[2]); 24 | if (time == x) { 25 | time += l; 26 | } else if (time < x) { 27 | time += (x - time) + l; 28 | } else if (time > x) { 29 | int et = f + x; 30 | while (et < time) { 31 | et += f; 32 | } 33 | time += (et - time) + l; 34 | } 35 | } 36 | sb.append(time + "\n"); 37 | } 38 | System.out.println(sb); 39 | } 40 | } -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/COOLING.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; /** 2 | * Created by Shreyans on 11/20/2014. 3 | */ 4 | 5 | import java.io.IOException; 6 | import java.util.Arrays; 7 | import java.util.Scanner; 8 | 9 | class COOLING { 10 | public static void main(String[] args) throws IOException { 11 | Scanner sc = new Scanner(System.in); 12 | int a = sc.nextInt(); 13 | int[] ans = new int[a]; 14 | int cnta = 0; 15 | for (int i = 0; i < a; i++) { 16 | int n = sc.nextInt(); 17 | int[] pi = new int[n]; 18 | int[] cr = new int[n]; 19 | int cnt = 0; 20 | for (int j = 0; j < n; j++) { 21 | pi[j] = sc.nextInt(); 22 | } 23 | for (int j = 0; j < n; j++) { 24 | cr[j] = sc.nextInt(); 25 | } 26 | Arrays.sort(pi); 27 | Arrays.sort(cr); 28 | int cntp = 0; 29 | for (int j = 0; j < n; j++) { 30 | if (pi[cntp] <= cr[j]) { 31 | cntp++; 32 | } 33 | } 34 | ans[cnta] = cntp; 35 | cnta++; 36 | } 37 | StringBuilder sb = new StringBuilder(); 38 | for (int i : ans) { 39 | sb.append(i + "\n"); 40 | } 41 | System.out.println(sb); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/DINP1501_CHEFHILL.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | 7 | /** 8 | * Created by Shreyans on 1/17/2015 using IntelliJ IDEA 9 | */ 10 | 11 | class DINP1501_CHEFHILL { 12 | public static void main(String[] args) throws IOException { 13 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 14 | int n1 = Integer.parseInt(br.readLine()); 15 | String[] s = br.readLine().split(" "); 16 | int n[] = new int[n1]; 17 | for (int j = 0; j < n1; j++) { 18 | n[j] = Integer.parseInt(s[j]); 19 | } 20 | int n2 = Integer.parseInt(br.readLine()); 21 | for (int i = 0; i < n2; i++) { 22 | String[] s1 = br.readLine().split(" "); 23 | int flag = 1; 24 | int x = n[Integer.parseInt(s1[0]) - 1]; 25 | for (int j = Integer.parseInt(s1[0]); j < Integer.parseInt(s1[1]) - 1; j++) { 26 | if (n[j] > x) { 27 | flag = 0; 28 | break; 29 | } 30 | } 31 | if (flag == 1) { 32 | System.out.println("YES"); 33 | } else { 34 | System.out.println("NO"); 35 | } 36 | } 37 | } 38 | } 39 | 40 | 41 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/DINP1501_CHEFPOW.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | import java.math.BigInteger; 7 | 8 | /** 9 | * Created by Shreyans on 1/16/2015 using IntelliJ IDEA 10 | */ 11 | 12 | class DINP1501_CHEFPOW { 13 | public static void main(String[] args) throws IOException { 14 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 15 | String h = br.readLine(); 16 | BigInteger n = new BigInteger(h); 17 | String[] s = new String[100000]; 18 | String ans = ""; 19 | int cnt = 0; 20 | while (n.compareTo(BigInteger.ZERO) > 0) { 21 | double x = Math.log(n.doubleValue()) / Math.log(2); 22 | BigInteger p = new BigInteger(Long.toString((long) Math.pow(2, (long) x))); 23 | n = n.subtract(p); 24 | s[cnt] = String.valueOf(p); 25 | cnt++; 26 | } 27 | for (int j = cnt - 1; j >= 0; j--) { 28 | System.out.print(s[j] + " "); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/DIVIDING.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | 7 | /** 8 | * Created by Shreyans on 1/9/2015 using IntelliJ IDEA 9 | */ 10 | 11 | class DIVIDING { 12 | public static void main(String[] args) throws IOException { 13 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 14 | int n = Integer.parseInt(br.readLine()); 15 | int asum = ((n * (n + 1)) / 2); 16 | int qsum = 0; 17 | String[] a = br.readLine().split(" "); 18 | for (int j = 0; j < n; j++) { 19 | qsum += Integer.parseInt(a[j]); 20 | } 21 | if (qsum == asum) { 22 | System.out.println("YES"); 23 | } else { 24 | System.out.println("NO"); 25 | } 26 | } 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/DOUBLE.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | 7 | class DOUBLE { 8 | public static void main(String[] args) throws IOException { 9 | 10 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 11 | int no = Integer.parseInt(br.readLine()); 12 | int[] ans = new int[no]; 13 | int cnt = 0; 14 | for (int i = 0; i < no; i++) { 15 | int a = Integer.parseInt(br.readLine()); 16 | if (a % 2 == 0) { 17 | ans[cnt] = a; 18 | cnt++; 19 | } else { 20 | ans[cnt] = a - 1; 21 | cnt++; 22 | } 23 | } 24 | for (int i = 0; i < cnt; i++) { 25 | System.out.println(ans[i]); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/ERROR.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | 7 | /** 8 | * Created by Shreyans on 1/6/2015 using IntelliJ IDEA 9 | */ 10 | 11 | class ERROR { 12 | public static void main(String[] args) throws IOException { 13 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 14 | int t = Integer.parseInt(br.readLine()); 15 | for (int i = 0; i < t; i++) { 16 | String a = br.readLine(); 17 | int flag = 0; 18 | for (int j = 0; j < a.length() - 2; j++) { 19 | if ((a.charAt(j) == '1' && a.charAt(j + 1) == '0' && a.charAt(j + 2) == '1') || (a.charAt(j) == '0' && a.charAt(j + 1) == '1' && a.charAt(j + 2) == '0')) { 20 | System.out.println("Good"); 21 | flag = 1; 22 | break; 23 | } 24 | } 25 | if (flag == 0) { 26 | System.out.println("Bad"); 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/FCTRL.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | 7 | class FCTRL { 8 | public static void main(String[] args) throws IOException { 9 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 10 | int a = Integer.parseInt(br.readLine()); 11 | int st[] = new int[a]; 12 | int cnt1 = 0; 13 | for (int i = 0; i < a; i++) { 14 | int cnt = 0, f = 5, f1 = 1; 15 | int nos = Integer.parseInt(br.readLine()); 16 | while (f1 > 0) { 17 | f1 = (int) (nos / f); 18 | cnt = cnt + f1; 19 | f *= 5; 20 | } 21 | st[cnt1] = cnt; 22 | cnt1++; 23 | } 24 | for (int i = 0; i < a; i++) { 25 | System.out.println(st[i]); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/FCTRL2.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | import java.math.BigInteger; 7 | 8 | class FCTRL2 { 9 | public static void main(String[] args) throws IOException { 10 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 11 | int in = Integer.parseInt(br.readLine()); 12 | BigInteger st[] = new BigInteger[in]; 13 | int cnt1 = 0; 14 | for (int i = 1; i <= in; i++) { 15 | BigInteger f = new BigInteger("1"); 16 | int b = Integer.parseInt(br.readLine()); 17 | for (int j = 2; j <= b; j++) { 18 | BigInteger j1 = new BigInteger(Integer.toString(j)); 19 | f = f.multiply(j1); 20 | } 21 | st[cnt1] = f; 22 | cnt1++; 23 | } 24 | for (int j = 0; j < cnt1; j++) { 25 | System.out.println(st[j]); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/HOLES.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.util.Scanner; 4 | 5 | class HOLES { 6 | public static void main(String[] args) { 7 | Scanner sc = new Scanner(System.in); 8 | int in = sc.nextInt(); 9 | int st[] = new int[in]; 10 | int cnt = 0, cnt1 = 0; 11 | for (int i = 0; i < in; i++) { 12 | String s = sc.next(); 13 | for (int j = 0; j < (s.length()); j++) { 14 | char ch = s.charAt(j); 15 | ch = Character.toUpperCase(ch); 16 | if (ch == 'A' || ch == 'D' || ch == 'O' || ch == 'P' || ch == 'Q' || ch == 'R') { 17 | cnt += 1; 18 | } else if (ch == 'B') { 19 | cnt += 2; 20 | } 21 | } 22 | st[cnt1] = cnt; 23 | cnt1++; 24 | cnt = 0; 25 | } 26 | for (int i = 0; i < cnt1; i++) { 27 | System.out.println(st[i]); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/HORSES.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | import java.util.Arrays; 7 | 8 | /** 9 | * Created by Shreyans on 12/5/2014 in IntelliJ 10 | */ 11 | class HORSES { 12 | public static void main(String[] args) throws IOException { 13 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 14 | int t = Integer.parseInt(br.readLine()); 15 | StringBuffer sb = new StringBuffer(); 16 | for (int i = 0; i < t; i++) { 17 | int n = Integer.parseInt(br.readLine()); 18 | String s[] = (br.readLine()).split(" "); 19 | long[] a = new long[n]; 20 | for (int j = 0; j < n; j++) { 21 | a[j] = Integer.parseInt(s[j]); 22 | } 23 | long min = Math.abs(a[1] - a[0]); 24 | Arrays.sort(a); 25 | for (int k = 0; k < n - 1; k++) { 26 | if (Math.abs(a[k] - a[k + 1]) < min) { 27 | min = Math.abs(a[k] - a[k + 1]); 28 | } 29 | } 30 | sb.append(min + "\n"); 31 | } 32 | System.out.println(sb); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/HS08TEST.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.util.Scanner; 4 | 5 | class HS08TEST { 6 | public static void main(String args[]) { 7 | Scanner sc = new Scanner(System.in); 8 | int wit; 9 | double bal; 10 | wit = sc.nextInt(); 11 | bal = sc.nextFloat(); 12 | if (((wit > 0) && (wit <= 2000)) && ((bal >= 0) && (bal <= 2000))) { 13 | if ((bal >= ((wit + 0.5)) && (wit % 5 == 0))) { 14 | double ans = Math.round(((bal - wit) - (0.50)) * 100.0) / 100.0; 15 | System.out.println(ans); 16 | } else if (((wit + 0.5) > bal)) { 17 | bal = Math.round(bal * 100.0) / 100.0; 18 | System.out.println(bal); 19 | } else if (((int) wit % 5 != 0)) { 20 | bal = Math.round(bal * 100.0) / 100.0; 21 | System.out.println(bal); 22 | } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/J7.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | 7 | /** 8 | * Created by Shreyans on 12/11/2014 in IntelliJ IDEA 9 | */ 10 | class J7 { 11 | public static void main(String[] args) throws IOException { 12 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 13 | int t = Integer.parseInt(br.readLine()); 14 | StringBuffer sb = new StringBuffer(); 15 | for (int i = 0; i < t; i++) { 16 | String[] s1 = br.readLine().split(" "); 17 | double p = Double.parseDouble(s1[0]); 18 | double s = Double.parseDouble(s1[1]); 19 | double ans1 = Math.pow((Math.sqrt(24 * s) / 12), 3); 20 | double ans2 = Math.pow((p / 12), 3); 21 | ans1 = Math.round(ans1 * 100.0) / 100.0; 22 | ; 23 | ans2 = Math.round(ans2 * 100.0) / 100.0; 24 | System.out.println(ans1 + " " + ans2); 25 | } 26 | //System.out.println(sb); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/JOHNY.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | import java.util.Arrays; 7 | 8 | /** 9 | * Created by Shreyans on 12/15/2014 in IntelliJ IDEA 10 | */ 11 | class JOHNY { 12 | public static void main(String[] args) throws IOException { 13 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 14 | int t = Integer.parseInt(br.readLine()); 15 | StringBuffer sb = new StringBuffer(); 16 | for (int i = 0; i < t; i++) { 17 | int n = Integer.parseInt(br.readLine()); 18 | int[] a = new int[n]; 19 | String[] s = br.readLine().split(" "); 20 | for (int j = 0; j < s.length; j++) { 21 | a[j] = Integer.parseInt(s[j]); 22 | } 23 | int uj = a[Integer.parseInt(br.readLine()) - 1]; 24 | Arrays.sort(a); 25 | int fi = 1 + (Arrays.binarySearch(a, uj)); 26 | sb.append(fi + "\n"); 27 | } 28 | System.out.println(String.valueOf(sb).trim()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/LUCKY5.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | 7 | /** 8 | * Created by Shreyans on 1/16/2015 using IntelliJ IDEA 9 | */ 10 | 11 | class LUCKY5 { 12 | public static void main(String[] args) throws IOException { 13 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 14 | int t = Integer.parseInt(br.readLine()); 15 | for (int i = 0; i < t; i++) { 16 | String a = br.readLine(); 17 | a = a.trim(); 18 | int cnt = 0; 19 | for (int j = 0; j < a.length(); j++) { 20 | if (a.charAt(j) != '4' && a.charAt(j) != '7') { 21 | cnt++; 22 | } 23 | } 24 | System.out.println(cnt); 25 | } 26 | } 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/MUFFINS3.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | 7 | /** 8 | * Created by Shreyans on 11/21/2014 in IntelliJ 9 | */ 10 | class MUFFINS3 { 11 | public static void main(String[] args) throws IOException { 12 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 13 | StringBuffer sb = new StringBuffer(); 14 | int t = Integer.parseInt(br.readLine()); 15 | for (int i = 0; i < t; i++) { 16 | int n = Integer.parseInt(br.readLine()); 17 | int a = n / 2; 18 | while ((a * 2) <= n) { 19 | a++; 20 | } 21 | sb.append(a + "\n"); 22 | } 23 | System.out.println(sb); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/NAME2.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | 7 | /** 8 | * Created by Shreyans on 1/6/2015 using IntelliJ IDEA 9 | */ 10 | 11 | class NAME2 { 12 | public static void main(String[] args) throws IOException { 13 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 14 | int t = Integer.parseInt(br.readLine()); 15 | for (int i = 0; i < t; i++) { 16 | String a[] = br.readLine().split(" "); 17 | if (a[0].length() > a[1].length()) { 18 | String temp = a[0]; 19 | a[0] = a[1]; 20 | a[1] = temp; 21 | } 22 | int cnt = 0; 23 | int fl = a[0].length(); 24 | int flag = 0; 25 | for (int j = 0; j < a[1].length(); j++) { 26 | if (a[1].charAt(j) == a[0].charAt(cnt)) { 27 | cnt++; 28 | } 29 | if (cnt == fl) { 30 | flag = 1; 31 | System.out.println("YES"); 32 | break; 33 | } 34 | } 35 | if (flag == 0) { 36 | System.out.println("NO"); 37 | } 38 | } 39 | } 40 | } 41 | 42 | 43 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/NOCODING.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | 7 | /** 8 | * Created by Shreyans on 1/16/2015 using IntelliJ IDEA 9 | */ 10 | 11 | class NOCODING { 12 | public static void main(String[] args) throws IOException { 13 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 14 | int t = Integer.parseInt(br.readLine()); 15 | StringBuffer sb = new StringBuffer(); 16 | for (int i = 0; i < t; i++) { 17 | String a = br.readLine(); 18 | int flen = (11 * a.length()); 19 | int stp = 2; 20 | for (int j = 1; j < a.length(); j++) { 21 | char ch = a.charAt(j); 22 | if ((int) ch < (int) (a.charAt(j - 1))) { 23 | stp += 26 - ((int) a.charAt(j - 1) - (int) ch); 24 | } else { 25 | stp += (int) ch - (int) a.charAt(j - 1); 26 | } 27 | stp++; 28 | } 29 | if (stp <= flen) { 30 | sb.append("YES\n"); 31 | } else { 32 | sb.append("NO\n"); 33 | } 34 | } 35 | System.out.println(sb); 36 | } 37 | } -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/NUMGAME.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | 7 | class NUMGAME { 8 | public static void main(String[] args) throws IOException { 9 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 10 | int tc = Integer.parseInt(br.readLine()); 11 | String[] ans = new String[10000]; 12 | int cnt2 = 0; 13 | for (int i = 0; i < tc; i++) { 14 | int cnt = 0; 15 | long md = 0; 16 | long n = Long.parseLong(br.readLine()); 17 | if ((n % 2 != 0)) { 18 | System.out.println("BOB"); 19 | 20 | } else if ((n % 2 == 0)) { 21 | System.out.println("ALICE"); 22 | 23 | } 24 | 25 | } 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/NUMGAME2.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | class NUMGAME2 { 4 | 5 | 6 | public static void main(String[] args) throws java.lang.Exception { 7 | // TODO code application logic here 8 | java.io.BufferedReader reader = new java.io.BufferedReader( 9 | new java.io.InputStreamReader(System.in)); 10 | int t = Integer.parseInt(reader.readLine()); 11 | //String[] params; 12 | while (t-- > 0) { 13 | //params = reader.readLine().split(" "); 14 | int n = Integer.parseInt(reader.readLine()); 15 | if (n % 4 == 1) { 16 | System.out.println("ALICE"); 17 | } else { 18 | System.out.println("BOB"); 19 | } 20 | } 21 | 22 | } 23 | } -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/OJUMPS.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | import java.math.BigInteger; 7 | 8 | /** 9 | * Created by Shreyans on 1/16/2015 using IntelliJ IDEA 10 | */ 11 | 12 | class OJUMPS { 13 | public static void main(String[] args) throws IOException { 14 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 15 | BigInteger n = new BigInteger(br.readLine()); 16 | BigInteger s = new BigInteger("6"); 17 | String sa = String.valueOf(n.mod(s)); 18 | if (sa.equals("0") || sa.equals("1") || sa.equals("3") || sa.equals("6")) { 19 | System.out.println("yes"); 20 | } else { 21 | System.out.println("no"); 22 | } 23 | } 24 | } 25 | 26 | 27 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/REMISS.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | 7 | /** 8 | * Created by Shreyans on 12/12/2014 in IntelliJ IDEA 9 | */ 10 | class REMISS { 11 | public static void main(String[] args) throws IOException { 12 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 13 | StringBuffer sb = new StringBuffer(); 14 | int t = Integer.parseInt(br.readLine()); 15 | for (int i = 0; i < t; i++) { 16 | String[] s = (br.readLine()).split(" "); 17 | int a = Integer.parseInt(s[0]); 18 | int b = Integer.parseInt(s[1]); 19 | int max = a; 20 | if (b > max) { 21 | max = b; 22 | } 23 | int sum = (a + b); 24 | sb.append(max + " " + sum + "\n"); 25 | } 26 | System.out.println(sb); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/RESQ.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | 7 | /** 8 | * Created by Shreyans on 12/30/2014 using IntelliJ IDEA 9 | */ 10 | 11 | class RESQ { 12 | public static void main(String[] args) throws IOException { 13 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 14 | int t = Integer.parseInt(br.readLine()); 15 | StringBuffer sb = new StringBuffer(); 16 | for (int i = 0; i < t; i++) { 17 | int n = Integer.parseInt(br.readLine()); 18 | int sq = (int) Math.sqrt(n); 19 | int min; 20 | if ((sq * sq) == n) { 21 | min = 0; 22 | } else { 23 | min = n - 1; 24 | for (int j = 2; j <= sq; j++) { 25 | if (n % j == 0) { 26 | if (Math.abs((n / j) - j) < min) { 27 | min = (Math.abs((n / j) - j)); 28 | if (min == 1) { 29 | break; 30 | } 31 | } 32 | } 33 | } 34 | } 35 | sb.append(min + "\n"); 36 | } 37 | System.out.println(sb); 38 | } 39 | } -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/RIGHTRI.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | 7 | /** 8 | * Created by Shreyans on 12/29/2014 using IntelliJ IDEA 9 | */ 10 | 11 | class RIGHTRI { 12 | public static void main(String[] args) throws IOException { 13 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 14 | int t = Integer.parseInt(br.readLine()); 15 | int cnt = 0; 16 | for (int i = 0; i < t; i++) { 17 | String[] v = br.readLine().split(" "); 18 | double a = Math.pow(Integer.parseInt(v[0]) - Integer.parseInt(v[2]), 2) + Math.pow(Integer.parseInt(v[1]) - Integer.parseInt(v[3]), 2); 19 | double b = Math.pow(Integer.parseInt(v[0]) - Integer.parseInt(v[4]), 2) + Math.pow(Integer.parseInt(v[1]) - Integer.parseInt(v[5]), 2); 20 | double c = Math.pow(Integer.parseInt(v[2]) - Integer.parseInt(v[4]), 2) + Math.pow(Integer.parseInt(v[3]) - Integer.parseInt(v[5]), 2); 21 | if (a == b + c || b == a + c || c == a + b) { 22 | cnt++; 23 | } 24 | System.out.println(cnt); 25 | } 26 | } 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/RRCOPY.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | import java.util.Arrays; 7 | 8 | /** 9 | * Created by Shreyans on 1/17/2015 using IntelliJ IDEA 10 | */ 11 | 12 | class RRCOPY { 13 | public static void main(String[] args) throws IOException { 14 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 15 | StringBuffer sb = new StringBuffer(); 16 | int t = Integer.parseInt(br.readLine()); 17 | for (int i = 0; i < t; i++) { 18 | int n = Integer.parseInt(br.readLine()); 19 | String[] s = br.readLine().split(" "); 20 | int[] nu = new int[n]; 21 | for (int j = 0; j < n; j++) { 22 | nu[j] = Integer.parseInt(s[j]); 23 | } 24 | Arrays.sort(nu); 25 | int buff = nu[0]; 26 | int cnt = 1; 27 | for (int j = 1; j < n; j++) { 28 | if (nu[j] != buff) { 29 | cnt++; 30 | buff = nu[j]; 31 | } 32 | } 33 | sb.append(cnt + "\n"); 34 | } 35 | System.out.println(sb); 36 | } 37 | } 38 | 39 | 40 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/SALARY.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | import java.util.Arrays; 7 | 8 | /** 9 | * Created by shreyans on 22/1/15 at 11:03 PM using IntelliJ IDEA 10 | */ 11 | class SALARY { 12 | public static void main(String[] args) throws IOException { 13 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 14 | int t = Integer.parseInt(br.readLine()); 15 | StringBuffer sb = new StringBuffer(); 16 | for (int i = 0; i < t; i++) { 17 | int no = Integer.parseInt(br.readLine()); 18 | String[] s = br.readLine().split(" "); 19 | int[] n = new int[no]; 20 | for (int j = 0; j < no; j++) { 21 | n[j] = Integer.parseInt(s[j]); 22 | } 23 | Arrays.sort(n); 24 | int sum = 0; 25 | for (int j = 1; j < no; j++) { 26 | sum += n[j] - n[0]; 27 | } 28 | sb.append(sum + "\n"); 29 | } 30 | System.out.println(sb); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/SNAPE.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | 7 | /** 8 | * Created by Shreyans on 12/11/2014 in IntelliJ IDEA 9 | */ 10 | class SNAPE { 11 | public static void main(String[] args) throws IOException { 12 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 13 | int t = Integer.parseInt(br.readLine()); 14 | StringBuffer sb = new StringBuffer(); 15 | for (int i = 0; i < t; i++) { 16 | String s1[] = (br.readLine()).split(" "); 17 | double base = Double.parseDouble(s1[0]); 18 | double lhs = Double.parseDouble(s1[1]); 19 | double rhs0 = Math.sqrt((lhs * lhs) - (base * base)); 20 | double rhs1 = Math.sqrt((lhs * lhs) + (base * base)); 21 | rhs0 = Math.round(rhs0 * 10000.0) / 10000.0; 22 | rhs1 = Math.round(rhs1 * 10000.0) / 10000.0; 23 | sb.append(rhs0 + " " + rhs1 + "\n"); 24 | } 25 | System.out.println(sb); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/SPCANDY.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | 7 | /** 8 | * Created by Shreyans on 1/6/2015 using IntelliJ IDEA 9 | */ 10 | 11 | class SPCANDY { 12 | public static void main(String[] args) throws IOException { 13 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 14 | int t = Integer.parseInt(br.readLine()); 15 | for (int i = 0; i < t; i++) { 16 | String[] a = br.readLine().split(" "); 17 | if (a[0].equals("0")) { 18 | System.out.println("0 0"); 19 | } else if (!a[0].equals("0") && a[1].equals("0")) { 20 | System.out.println("0 " + a[0]); 21 | } else if (!a[0].equals("0") && !a[1].equals("0")) { 22 | Long a1 = Long.parseLong(a[0]) / Long.parseLong(a[1]); 23 | Long a2 = Long.parseLong(a[0]) % Long.parseLong(a[1]); 24 | System.out.println(a1 + " " + a2); 25 | } 26 | } 27 | } 28 | } 29 | 30 | 31 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/STONES.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | 7 | class STONES { 8 | public static void main(String[] args) throws IOException { 9 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 10 | int t = Integer.parseInt(br.readLine()); 11 | StringBuffer sb = new StringBuffer(); 12 | for (int i = 0; i < t; i++) { 13 | String a = br.readLine(); 14 | String b = br.readLine(); 15 | int cnt = 0; 16 | for (int j = 0; j < b.length(); j++) { 17 | for (int k = 0; k < a.length(); k++) { 18 | if (a.charAt(k) == b.charAt(j)) { 19 | cnt++; 20 | break; 21 | } 22 | } 23 | } 24 | sb.append(cnt + "\n"); 25 | } 26 | System.out.println(sb); 27 | } 28 | } -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/TACHSTCK.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | import java.util.Arrays; 7 | 8 | /** 9 | * Created by Shreyans on 1/17/2015 using IntelliJ IDEA 10 | */ 11 | 12 | class TACHSTCK { 13 | public static void main(String[] args) throws IOException { 14 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 15 | String[] s = br.readLine().split(" "); 16 | int n = Integer.parseInt(s[0]); 17 | long d = Long.parseLong(s[1]); 18 | long[] k = new long[n]; 19 | for (int j = 0; j < n; j++) { 20 | k[j] = Long.parseLong(br.readLine()); 21 | } 22 | Arrays.sort(k); 23 | int cnt = 0; 24 | for (int j = 1; j < n; j += 2) { 25 | if (k[j] - k[j - 1] <= d) { 26 | cnt++; 27 | } else { 28 | j--;//!!if it doesn't satisfy you cant directly skip to the next pair. You have to consider the present element int the next pair 29 | } 30 | } 31 | System.out.println(cnt); 32 | } 33 | } 34 | 35 | 36 | -------------------------------------------------------------------------------- /Code/src/CODECHEF/PRACTICE/EASY/src/TLG.java: -------------------------------------------------------------------------------- 1 | package CODECHEF.PRACTICE.EASY.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | 7 | class TLG { 8 | public static void main(String[] args) throws IOException { 9 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 10 | int in = Integer.parseInt(br.readLine()); 11 | int max = 0, win = 0, p1 = 1, p2 = 2, s1 = 0, s2 = 0; 12 | for (int i = 0; i < in; i++) { 13 | String s = br.readLine(); 14 | s1 += Integer.parseInt(s.substring(0, s.indexOf(' '))); 15 | s2 += Integer.parseInt(s.substring((s.indexOf(' ') + 1), s.length())); 16 | if ((s1 > s2) && ((s1 - s2) > max)) { 17 | 18 | max = s1 - s2; 19 | win = 1; 20 | } else if ((s2 > s1) && ((s2 - s1) > max)) { 21 | max = (s2 - s1); 22 | win = 2; 23 | } 24 | 25 | } 26 | if (win == 1) { 27 | 28 | System.out.print(p1 + " " + max); 29 | 30 | } else if (win == 2) { 31 | 32 | System.out.print(p2 + " " + max); 33 | 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Code/src/CODEFORCES/DIV2_335/src/Ideone.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bholagabbar/algorithmic-programming/a5482cca93f79ec8495256fa1a08525e61bfb899/Code/src/CODEFORCES/DIV2_335/src/Ideone.java -------------------------------------------------------------------------------- /Code/src/INTERVIEW/QUES_TRY/TestMySinglyLinkedList.java: -------------------------------------------------------------------------------- 1 | package INTERVIEW.QUES_TRY; 2 | 3 | import INTERVIEW.DS_IMPL.MySinglyLinkedList; 4 | 5 | /** 6 | * Shreyans Sheth [bholagabbar | http://shreyans-sheth.me] 7 | * 9/16/2016 8 | */ 9 | 10 | class TestMySinglyLinkedList { 11 | public static void main(String[] args) throws Exception { 12 | MySinglyLinkedList ln = new MySinglyLinkedList<>(); 13 | ln.addToHead(2); 14 | ln.addToHead(3); 15 | ln.addToHead(7); 16 | ln.addToHead(10); 17 | ln.addToHead(4); 18 | ln.printList(); 19 | 20 | ln.reverse(); 21 | ln.printList(); 22 | 23 | ln.recursiveReverse(ln.getHead(), null); 24 | ln.printList(); 25 | 26 | 27 | } 28 | 29 | 30 | } -------------------------------------------------------------------------------- /Code/src/MISC/Facebook Hacker Cup '14/Facebook Hacker Cup '14.eml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Code/src/MISC/Facebook Hacker Cup '14/OUTPUT FHC '14 PROB 1.txt: -------------------------------------------------------------------------------- 1 | Case #1: 133343270 731343230 2 | Case #2: 0 0 3 | Case #3: 239037548 933027548 4 | Case #4: 196888762 976888162 5 | Case #5: 126793189 916793182 6 | Case #6: 369689840 969684830 7 | Case #7: 17965734 97561734 8 | Case #8: 499967987 999967487 9 | Case #9: 120785607 720715608 10 | Case #10: 10 10 11 | Case #11: 364669874 964663874 12 | Case #12: 9990999 9999990 13 | Case #13: 26438949 96432948 14 | Case #14: 183606692 963606812 15 | Case #15: 296288077 986282077 16 | Case #16: 999999999 999999999 17 | Case #17: 17429777 91427777 18 | Case #18: 139294502 993214502 19 | Case #19: 122400250 422500210 20 | Case #20: 12753239 92753213 -------------------------------------------------------------------------------- /Code/src/MISC/Facebook Hacker Cup '14/OUTPUT FHC '14 PROB 2.txt: -------------------------------------------------------------------------------- 1 | Case #1: yes 2 | Case #2: no 3 | Case #3: yes 4 | Case #4: yes 5 | Case #5: yes 6 | Case #6: no 7 | Case #7: yes 8 | Case #8: no 9 | Case #9: yes 10 | Case #10: yes 11 | Case #11: yes 12 | Case #12: no 13 | Case #13: no 14 | Case #14: yes 15 | Case #15: no 16 | Case #16: no 17 | Case #17: no 18 | Case #18: no 19 | Case #19: no 20 | Case #20: yes -------------------------------------------------------------------------------- /Code/src/MISC/Facebook Hacker Cup '14/OUTPUT FHC_R1_PRIMALITY.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bholagabbar/algorithmic-programming/a5482cca93f79ec8495256fa1a08525e61bfb899/Code/src/MISC/Facebook Hacker Cup '14/OUTPUT FHC_R1_PRIMALITY.txt -------------------------------------------------------------------------------- /Code/src/MISC/Facebook Hacker Cup '14/src/scratch1.java: -------------------------------------------------------------------------------- 1 | import java.io.IOException; 2 | 3 | /** 4 | * Created by Shreyans on 1/18/2015 using IntelliJ IDEA 5 | */ 6 | 7 | class scratch1 { 8 | public static void main(String[] args) throws IOException { 9 | boolean[] k = SOE(); 10 | for (int i = 0; i <= 10000001; i++) { 11 | System.out.println(i + " " + k[i]); 12 | } 13 | } 14 | 15 | public static boolean[] SOE() { 16 | int max = 10000001; 17 | final boolean[] primeCandidates = new boolean[max]; // defaults to false 18 | for (int i = 2; i < max; i++) { 19 | primeCandidates[i] = true; 20 | } 21 | 22 | final double maxRoot = Math.sqrt(max); 23 | for (int candidate = 2; candidate < maxRoot; candidate++) { 24 | if (primeCandidates[candidate]) { 25 | for (int j = 2 * candidate; j < max; j += candidate) { 26 | primeCandidates[j] = false; 27 | } 28 | } 29 | 30 | } 31 | return primeCandidates; 32 | } 33 | } 34 | 35 | 36 | -------------------------------------------------------------------------------- /Code/src/SPOJ/src/FCTRL2.java: -------------------------------------------------------------------------------- 1 | package SPOJ.src; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.InputStreamReader; 5 | import java.io.PrintWriter; 6 | import java.math.BigInteger; 7 | 8 | class FCTRL2 { 9 | public static void main(String[] args) throws java.lang.Exception { 10 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 11 | PrintWriter pw = new PrintWriter(System.out); 12 | int t = Integer.parseInt(br.readLine()); 13 | for (int i = 0; i < t; i++) { 14 | int n = Integer.parseInt(br.readLine()); 15 | BigInteger bi = BigInteger.ONE; 16 | for (int j = 1; j <= n; j++) { 17 | bi = (bi.multiply(new BigInteger(Integer.toString(j)))); 18 | } 19 | pw.println(bi); 20 | } 21 | pw.close(); 22 | } 23 | } -------------------------------------------------------------------------------- /Code/src/SPOJ/src/testgen.java: -------------------------------------------------------------------------------- 1 | package SPOJ.src;/* package whatever; // don't place package name! */ 2 | 3 | import java.util.Random; 4 | 5 | /* Name of the class has to be "Main" only if the class is public. */ 6 | class testgen { 7 | public static void main(String[] args) throws java.lang.Exception { 8 | System.out.println("10"); 9 | Random randomGenerator = new Random(); 10 | for (int i = 0; i < 10; i++) { 11 | int y = randomGenerator.nextInt((5000)); 12 | System.out.println(y); 13 | for (int j = 0; j < y; j++) { 14 | int x = 2 + randomGenerator.nextInt((10000000 - 2) + 2); 15 | if (j < y - 1) { 16 | System.out.print(x + " "); 17 | } else { 18 | System.out.print(x + "\n"); 19 | } 20 | } 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Code/src/TOPCODER/src/InfStr.py: -------------------------------------------------------------------------------- 1 | x="asdf" 2 | print (len(x)) 3 | -------------------------------------------------------------------------------- /Code/src/TOPCODER/src/InfiniteString.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Shreyans on 5/5/2015 at 9:08 PM using IntelliJ IDEA (Fast IO Template) 3 | */ 4 | 5 | //ADD PUBLIC FOR CF,TC 6 | public class InfiniteString { 7 | public static void main(String[] args) throws Exception { 8 | 9 | } 10 | 11 | public static String equal(String a, String b) { 12 | String x = "", y = ""; 13 | for (int i = 0; i < b.length(); i++) { 14 | x += a; 15 | } 16 | for (int i = 0; i < a.length(); i++) { 17 | y += b; 18 | } 19 | System.out.println(x + "\n" + y); 20 | if (x.equals(y)) { 21 | return "Equal"; 22 | } else { 23 | return "Not equal"; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Code/src/input.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bholagabbar/algorithmic-programming/a5482cca93f79ec8495256fa1a08525e61bfb899/Code/src/input.txt -------------------------------------------------------------------------------- /Settings-Template-Docs/CP Topics.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bholagabbar/algorithmic-programming/a5482cca93f79ec8495256fa1a08525e61bfb899/Settings-Template-Docs/CP Topics.docx -------------------------------------------------------------------------------- /Settings-Template-Docs/DP.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bholagabbar/algorithmic-programming/a5482cca93f79ec8495256fa1a08525e61bfb899/Settings-Template-Docs/DP.docx -------------------------------------------------------------------------------- /Settings-Template-Docs/Problems.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bholagabbar/algorithmic-programming/a5482cca93f79ec8495256fa1a08525e61bfb899/Settings-Template-Docs/Problems.docx -------------------------------------------------------------------------------- /Settings-Template-Docs/cpp.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 7 | using namespace std; 8 | #define getPrecision(s,p) fixed< pii; 31 | typedef pair pll; 32 | 33 | int main() { 34 | boostIO; 35 | 36 | 37 | return 0; 38 | } 39 | ]]> 40 | cpp 41 | C++ Online Judge Template 42 | source.c++ 43 | 44 | -------------------------------------------------------------------------------- /Settings-Template-Docs/settings.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bholagabbar/algorithmic-programming/a5482cca93f79ec8495256fa1a08525e61bfb899/Settings-Template-Docs/settings.jar --------------------------------------------------------------------------------